tree: Improve non-schema aware typing (#22763)
## Description See changeset ## Breaking Changes See changeset
This commit is contained in:
Родитель
5806a27f6e
Коммит
05197d6d3f
|
@ -0,0 +1,122 @@
|
|||
---
|
||||
"fluid-framework": minor
|
||||
"@fluidframework/tree": minor
|
||||
---
|
||||
---
|
||||
"section": tree
|
||||
---
|
||||
|
||||
Improve typing when exact TypeScript type for a schema is not provided
|
||||
|
||||
The Tree APIs are designed to be used in a strongly typed way, with the full TypeScript type for the schema always being provided.
|
||||
Due to limitations of the TypeScript language, there was no practical way to prevent less descriptive types, like `TreeNodeSchema` or `ImplicitFieldSchema`, from being used where the type of a specific schema was intended.
|
||||
Code which does this will encounter several issues with tree APIs, and this change fixes some of those issues.
|
||||
This change mainly fixes that `NodeFromSchema<TreeNodeSchema>` used to return `unknown` and now returns `TreeNode | TreeLeafValue`.
|
||||
|
||||
This change by itself seems mostly harmless, as it just improves the precision of the typing in this one edge case.
|
||||
Unfortunately, there are other typing bugs which complicate the situation, causing APIs for inserting data into the tree to also behave poorly when given non-specific types like `TreeNodeSchema`.
|
||||
These APIs include cases like `TreeView.initialize`.
|
||||
|
||||
This incorrectly allowed some usage like taking a type-erased schema and initial tree pair, creating a view of type `TreeView<ImplicitFieldSchema>`, then initializing it.
|
||||
With the typing being partly fixed, some unsafe inputs are still allowed when trying to initialize such a view, but some are now prevented.
|
||||
|
||||
This use-case of modifying trees in code not that is not strongly typed by the exact schema was not intended to be supported.
|
||||
Despite this, it did mostly work in some cases, and has some real use-cases (like tests looping over test data consisting of pairs of schema and initial trees).
|
||||
To help mitigate the impact of this change, some experimental `@alpha` APIs have been introduced to help address these previously unsupported but somewhat working use-cases.
|
||||
|
||||
Before this change:
|
||||
|
||||
```typescript
|
||||
import { TinyliciousClient } from "@fluidframework/tinylicious-client";
|
||||
import {
|
||||
SchemaFactory,
|
||||
SharedTree,
|
||||
TreeViewConfiguration,
|
||||
type TreeNodeSchema,
|
||||
} from "fluid-framework";
|
||||
|
||||
// Create a ITree instance
|
||||
const tinyliciousClient = new TinyliciousClient();
|
||||
const { container } = await tinyliciousClient.createContainer({ initialObjects: {} }, "2");
|
||||
const tree = await container.create(SharedTree);
|
||||
|
||||
const schemaFactory = new SchemaFactory("demo");
|
||||
|
||||
// Bad: This loses the schema aware type information. `: TreeNodeSchema` should be omitted to preserve strong typing.
|
||||
const schema: TreeNodeSchema = schemaFactory.array(schemaFactory.number);
|
||||
const config = new TreeViewConfiguration({ schema });
|
||||
|
||||
// This view is typed as `TreeView<TreeNodeSchema>`, which does not work well since it's missing the actual schema type information.
|
||||
const view = tree.viewWith(config);
|
||||
// Root is typed as `unknown` allowing invalid assignment operations.
|
||||
view.root = "invalid";
|
||||
view.root = {};
|
||||
// Since all assignments are allowed, valid ones still work:
|
||||
view.root = [];
|
||||
```
|
||||
|
||||
After this change:
|
||||
|
||||
|
||||
```typescript
|
||||
// Root is now typed as `TreeNode | TreeLeafValue`, still allowing some invalid assignment operations.
|
||||
// In the future this should be prevented as well, since the type of the setter in this case should be `never`.
|
||||
view.root = "invalid";
|
||||
// This no longer compiles:
|
||||
view.root = {};
|
||||
// This also no longer compiles despite being valid at runtime:
|
||||
view.root = [];
|
||||
```
|
||||
|
||||
For code that wants to continue using an unsafe API, which can result in runtime errors if the data does not follow the schema, a new alternative has been added to address this use-case. A special type `UnsafeUnknownSchema` can now be used to opt into allowing all valid trees to be provided.
|
||||
Note that this leaves ensuring the data is in schema up to the user.
|
||||
For now these adjusted APIs can be accessed by casting the view to `TreeViewAlpha<UnsafeUnknownSchema>`.
|
||||
If stabilized, this option will be added to `TreeView` directly.
|
||||
|
||||
```typescript
|
||||
const viewAlpha = view as TreeViewAlpha<UnsafeUnknownSchema>;
|
||||
viewAlpha.initialize([]);
|
||||
viewAlpha.root = [];
|
||||
```
|
||||
|
||||
Additionally, this seems to have negatively impacted co-recursive schema which declare a co-recursive array as the first schema in the co-recursive cycle.
|
||||
Like the TypeScript language our schema system is built on, we don't guarantee exactly which recursive type will compile, but will do our best to ensure useful recursive schema can be created easily.
|
||||
In this case a slight change may be required to some recursive schema to get them to compile again:
|
||||
|
||||
For example this schema used to compile:
|
||||
|
||||
|
||||
```typescript
|
||||
class A extends sf.arrayRecursive("A", [() => B]) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof A>;
|
||||
}
|
||||
// Used to work, but breaks in this update.
|
||||
class B extends sf.object("B", { x: A }) {}
|
||||
```
|
||||
|
||||
But now you must use the recursive functions like `objectRecursive` for types which are co-recursive with an array in some cases.
|
||||
In our example, it can be fixed as follows:
|
||||
|
||||
```typescript
|
||||
class A extends sf.arrayRecursive("A", [() => B]) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof A>;
|
||||
}
|
||||
// Fixed corecursive type, using "Recursive" method variant to declare schema.
|
||||
class B extends sf.objectRecursive("B", { x: A }) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof B>;
|
||||
}
|
||||
```
|
||||
|
||||
Note: while the following pattern may still compile, we recommend using the previous pattern instead since the one below may break in the future.
|
||||
|
||||
```typescript
|
||||
class B extends sf.objectRecursive("B", { x: [() => A] }) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof B>;
|
||||
}
|
||||
// Works, for now, but not recommended.
|
||||
class A extends sf.array("A", B) {}
|
||||
```
|
|
@ -34,6 +34,7 @@
|
|||
"cSpell.words": [
|
||||
"boop",
|
||||
"contoso",
|
||||
"corecursive",
|
||||
"debuggability",
|
||||
"denormalized",
|
||||
"endregion",
|
||||
|
|
|
@ -15,7 +15,15 @@
|
|||
// This extension appears to invoke mocha programmatically, meaning that the enablement of this option in the common
|
||||
// mocha test config isn't sufficient; it also needs to be enabled here.
|
||||
"mochaExplorer.nodeArgv": ["--conditions", "allow-ff-test-exports"],
|
||||
"cSpell.words": ["deprioritized", "endregion", "insertable", "reentrantly", "unhydrated"],
|
||||
"cSpell.words": [
|
||||
"contravariantly",
|
||||
"covariantly",
|
||||
"deprioritized",
|
||||
"endregion",
|
||||
"insertable",
|
||||
"reentrantly",
|
||||
"unhydrated",
|
||||
],
|
||||
|
||||
// Enable biome as default formatter, and disable rules that disagree with it
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
|
|
|
@ -16,6 +16,9 @@ export function adaptEnum<TScope extends string, const TEnum extends Record<stri
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -58,6 +61,14 @@ type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ?
|
|||
// @alpha
|
||||
export function extractPersistedSchema(schema: ImplicitFieldSchema): JsonCompatible;
|
||||
|
||||
// @alpha
|
||||
export type FactoryContent = IFluidHandle | string | number | boolean | null | Iterable<readonly [string, InsertableContent]> | readonly InsertableContent[] | FactoryContentObject;
|
||||
|
||||
// @alpha
|
||||
export type FactoryContentObject = {
|
||||
readonly [P in string]?: InsertableContent;
|
||||
};
|
||||
|
||||
// @public
|
||||
type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<FieldKind.Optional | FieldKind.Identifier> ? true : false;
|
||||
|
||||
|
@ -132,7 +143,7 @@ export enum ForestType {
|
|||
export function getBranch(tree: ITree): TreeBranch;
|
||||
|
||||
// @alpha
|
||||
export function getBranch(view: TreeView<ImplicitFieldSchema>): TreeBranch;
|
||||
export function getBranch<T extends ImplicitFieldSchema>(view: TreeView<T>): TreeBranch;
|
||||
|
||||
// @alpha
|
||||
export function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema;
|
||||
|
@ -151,6 +162,15 @@ export type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;
|
|||
// @public
|
||||
type _InlineTrick = 0;
|
||||
|
||||
// @alpha
|
||||
export type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> = TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : InsertableContent;
|
||||
|
||||
// @alpha
|
||||
export type InsertableContent = Unhydrated<TreeNode> | FactoryContent;
|
||||
|
||||
// @alpha
|
||||
export type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = TSchema extends ImplicitFieldSchema ? InsertableTreeFieldFromImplicitField<TSchema> : InsertableContent | undefined;
|
||||
|
||||
// @public
|
||||
type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
|
||||
readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property] & string>;
|
||||
|
@ -166,7 +186,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -175,7 +195,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -220,6 +240,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -347,10 +370,10 @@ export interface MakeNominal {
|
|||
export type MapNodeInsertableData<T extends ImplicitAllowedTypes> = Iterable<readonly [string, InsertableTreeNodeFromImplicitAllowedTypes<T>]> | RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @beta @sealed
|
||||
export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
||||
|
@ -361,7 +384,7 @@ export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
|||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -395,6 +418,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -446,17 +473,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -547,7 +574,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -556,7 +583,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -578,7 +605,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @beta @sealed
|
||||
|
@ -618,7 +645,7 @@ export enum TreeCompressionStrategy {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -667,13 +694,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -689,11 +722,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -709,7 +751,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -719,6 +761,15 @@ export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposab
|
|||
upgradeSchema(): void;
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeView<TSchema extends ImplicitFieldSchema ? TSchema : ImplicitFieldSchema>, "root" | "initialize"> {
|
||||
// (undocumented)
|
||||
initialize(content: InsertableField<TSchema>): void;
|
||||
// (undocumented)
|
||||
get root(): TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeLeafValue | TreeNode;
|
||||
set root(newRoot: InsertableField<TSchema>);
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
export class TreeViewConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
|
||||
constructor(props: ITreeViewConfiguration<TSchema>);
|
||||
|
@ -754,6 +805,12 @@ export type Unenforced<_DesiredExtendsConstraint> = unknown;
|
|||
// @public
|
||||
export type Unhydrated<T> = T;
|
||||
|
||||
// @alpha
|
||||
export const UnsafeUnknownSchema: unique symbol;
|
||||
|
||||
// @alpha
|
||||
export type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;
|
||||
|
||||
// @public
|
||||
export type ValidateRecursiveSchema<T extends TreeNodeSchemaClass<string, NodeKind.Array | NodeKind.Map | NodeKind.Object, TreeNode & WithType<T["identifier"], T["kind"]>, {
|
||||
[NodeKind.Object]: T["info"] extends RestrictiveStringRecord<ImplicitFieldSchema> ? InsertableObjectFromSchemaRecord<T["info"]> : unknown;
|
||||
|
@ -774,7 +831,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -113,7 +116,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -122,7 +125,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -167,6 +170,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -219,10 +225,10 @@ export interface MakeNominal {
|
|||
export type MapNodeInsertableData<T extends ImplicitAllowedTypes> = Iterable<readonly [string, InsertableTreeNodeFromImplicitAllowedTypes<T>]> | RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @beta @sealed
|
||||
export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
||||
|
@ -233,7 +239,7 @@ export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
|||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -264,6 +270,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -315,17 +325,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -385,7 +395,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -394,7 +404,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -416,7 +426,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @beta @sealed
|
||||
|
@ -437,7 +447,7 @@ export interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode> extends
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -486,13 +496,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -508,11 +524,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -528,7 +553,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -587,7 +612,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -113,7 +116,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -122,7 +125,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -167,6 +170,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -219,16 +225,16 @@ export interface MakeNominal {
|
|||
export type MapNodeInsertableData<T extends ImplicitAllowedTypes> = Iterable<readonly [string, InsertableTreeNodeFromImplicitAllowedTypes<T>]> | RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -259,6 +265,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -310,17 +320,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -383,7 +393,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -392,7 +402,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -414,7 +424,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
|
@ -424,7 +434,7 @@ export interface TreeChangeEvents {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -473,13 +483,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -495,11 +511,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -515,7 +540,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -574,7 +599,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -113,7 +116,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -122,7 +125,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -167,6 +170,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -219,16 +225,16 @@ export interface MakeNominal {
|
|||
export type MapNodeInsertableData<T extends ImplicitAllowedTypes> = Iterable<readonly [string, InsertableTreeNodeFromImplicitAllowedTypes<T>]> | RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -259,6 +265,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -310,17 +320,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -380,7 +390,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -389,7 +399,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -411,7 +421,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
|
@ -421,7 +431,7 @@ export interface TreeChangeEvents {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -470,13 +480,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -492,11 +508,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -512,7 +537,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -571,7 +596,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -113,7 +116,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -122,7 +125,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -167,6 +170,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -219,16 +225,16 @@ export interface MakeNominal {
|
|||
export type MapNodeInsertableData<T extends ImplicitAllowedTypes> = Iterable<readonly [string, InsertableTreeNodeFromImplicitAllowedTypes<T>]> | RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -259,6 +265,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -310,17 +320,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -380,7 +390,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -389,7 +399,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -411,7 +421,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
|
@ -421,7 +431,7 @@ export interface TreeChangeEvents {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -470,13 +480,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -492,11 +508,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -512,7 +537,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -571,7 +596,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
|
|
@ -227,7 +227,26 @@
|
|||
}
|
||||
},
|
||||
"typeValidation": {
|
||||
"broken": {},
|
||||
"broken": {
|
||||
"TypeAlias_InsertableTreeFieldFromImplicitField": {
|
||||
"backCompat": false
|
||||
},
|
||||
"Interface_TreeArrayNode": {
|
||||
"backCompat": false
|
||||
},
|
||||
"TypeAlias_InsertableTreeNodeFromImplicitAllowedTypes": {
|
||||
"backCompat": false
|
||||
},
|
||||
"TypeAlias_NodeFromSchema": {
|
||||
"backCompat": false
|
||||
},
|
||||
"TypeAlias_TreeFieldFromImplicitField": {
|
||||
"backCompat": false
|
||||
},
|
||||
"TypeAlias_TreeNodeFromImplicitAllowedTypes": {
|
||||
"backCompat": false
|
||||
}
|
||||
},
|
||||
"entrypoint": "public"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ export {
|
|||
type InsertableObjectFromSchemaRecordUnsafe,
|
||||
type InsertableTreeFieldFromImplicitFieldUnsafe,
|
||||
type FieldSchemaUnsafe,
|
||||
type TreeNodeSchemaClassUnsafe,
|
||||
// System types (not in Internal types for various reasons, like doc links or cannot be named errors).
|
||||
type typeSchemaSymbol,
|
||||
type TreeNodeSchemaNonClass,
|
||||
|
@ -125,6 +126,13 @@ export {
|
|||
enumFromStrings,
|
||||
singletonSchema,
|
||||
typedObjectValues,
|
||||
type UnsafeUnknownSchema,
|
||||
type TreeViewAlpha,
|
||||
type InsertableField,
|
||||
type Insertable,
|
||||
type InsertableContent,
|
||||
type FactoryContent,
|
||||
type FactoryContentObject,
|
||||
// test recursive schema for checking that d.ts files handles schema correctly
|
||||
test_RecursiveObject,
|
||||
test_RecursiveObject_base,
|
||||
|
@ -151,6 +159,7 @@ export {
|
|||
getJsonSchema,
|
||||
type LazyItem,
|
||||
type Unenforced,
|
||||
type ReadonlyArrayNode,
|
||||
} from "./simple-tree/index.js";
|
||||
export {
|
||||
SharedTree,
|
||||
|
|
|
@ -33,6 +33,9 @@ export type {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
} from "./simple-tree/index.js";
|
||||
export type { FlexList, FlexListToUnion, ExtractItemType } from "./simple-tree/index.js";
|
||||
|
||||
|
|
|
@ -353,8 +353,10 @@ export function getBranch(tree: ITree): TreeBranch;
|
|||
* but it (or something like it) is necessary in the meantime to prevent the alpha types from being exposed as public.
|
||||
* @alpha
|
||||
*/
|
||||
export function getBranch(view: TreeView<ImplicitFieldSchema>): TreeBranch;
|
||||
export function getBranch(treeOrView: ITree | TreeView<ImplicitFieldSchema>): TreeBranch {
|
||||
export function getBranch<T extends ImplicitFieldSchema>(view: TreeView<T>): TreeBranch;
|
||||
export function getBranch<T extends ImplicitFieldSchema>(
|
||||
treeOrView: ITree | TreeView<T>,
|
||||
): TreeBranch {
|
||||
assert(
|
||||
treeOrView instanceof SharedTree || treeOrView instanceof SchematizingSimpleTreeView,
|
||||
0xa48 /* Unsupported implementation */,
|
||||
|
|
|
@ -78,7 +78,10 @@ export interface RunTransaction {
|
|||
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
||||
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
||||
*/
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
||||
// TODO: TreeView is invariant over the schema, so to accept any view, `any` is the only real option unless a non generic (or covariant) base type for view is introduced (which is planned).
|
||||
// This use of any is actually type safe as it is only used as a constraint, and the actual strongly typed view (TView) is passed to the callback.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
<TView extends TreeView<any>, TResult>(
|
||||
tree: TView,
|
||||
transaction: (root: TView["root"]) => TResult,
|
||||
): TResult;
|
||||
|
@ -123,7 +126,9 @@ export interface RunTransaction {
|
|||
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
||||
* If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.
|
||||
*/
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
||||
// See comment on previous overload about use of any here.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
<TView extends TreeView<any>, TResult>(
|
||||
tree: TView,
|
||||
transaction: (root: TView["root"]) => TResult | typeof rollback,
|
||||
): TResult | typeof rollback;
|
||||
|
@ -161,10 +166,9 @@ export interface RunTransaction {
|
|||
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
||||
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
||||
*/
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(
|
||||
tree: TView,
|
||||
transaction: (root: TView["root"]) => void,
|
||||
): void;
|
||||
// See comment on previous overload about use of any here.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
/**
|
||||
* Apply one or more edits to the tree as a single atomic unit.
|
||||
* @param node - The node that will be passed to `transaction`.
|
||||
|
@ -211,7 +215,9 @@ export interface RunTransaction {
|
|||
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
||||
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
||||
*/
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
||||
// See comment on previous overload about use of any here.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
<TView extends TreeView<any>, TResult>(
|
||||
tree: TView,
|
||||
transaction: (root: TView["root"]) => TResult,
|
||||
preconditions?: readonly TransactionConstraint[],
|
||||
|
@ -264,7 +270,9 @@ export interface RunTransaction {
|
|||
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
||||
* If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.
|
||||
*/
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(
|
||||
// See comment on previous overload about use of any here.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
<TView extends TreeView<any>, TResult>(
|
||||
tree: TView,
|
||||
transaction: (root: TView["root"]) => TResult | typeof rollback,
|
||||
preconditions?: readonly TransactionConstraint[],
|
||||
|
@ -313,7 +321,9 @@ export interface RunTransaction {
|
|||
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
||||
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
||||
*/
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(
|
||||
// See comment on previous overload about use of any here.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
<TView extends TreeView<any>>(
|
||||
tree: TView,
|
||||
transaction: (root: TView["root"]) => void,
|
||||
preconditions?: readonly TransactionConstraint[],
|
||||
|
|
|
@ -12,6 +12,7 @@ export {
|
|||
type ITreeViewConfiguration,
|
||||
type SchemaCompatibilityStatus,
|
||||
type ITreeConfigurationOptions,
|
||||
type TreeViewAlpha,
|
||||
} from "./tree.js";
|
||||
export { SchemaFactory, type ScopedSchemaName } from "./schemaFactory.js";
|
||||
export type {
|
||||
|
@ -62,6 +63,10 @@ export type {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaClassUnsafe,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
} from "./typesUnsafe.js";
|
||||
|
||||
export type {
|
||||
|
|
|
@ -11,11 +11,14 @@ import type { Listenable } from "../../events/index.js";
|
|||
|
||||
import {
|
||||
type ImplicitFieldSchema,
|
||||
type InsertableField,
|
||||
type InsertableTreeFieldFromImplicitField,
|
||||
type TreeFieldFromImplicitField,
|
||||
type TreeLeafValue,
|
||||
type UnsafeUnknownSchema,
|
||||
FieldKind,
|
||||
} from "../schemaTypes.js";
|
||||
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
||||
import { NodeKind, type TreeNode, type TreeNodeSchema } from "../core/index.js";
|
||||
import { toStoredSchema } from "../toFlexSchema.js";
|
||||
import { LeafNodeSchema } from "../leafNodeSchema.js";
|
||||
import { assert } from "@fluidframework/core-utils/internal";
|
||||
|
@ -363,7 +366,7 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|||
* Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.
|
||||
* @sealed @public
|
||||
*/
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
/**
|
||||
* The current root of the tree.
|
||||
*
|
||||
|
@ -424,6 +427,25 @@ export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposab
|
|||
readonly schema: TSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.
|
||||
* @alpha
|
||||
*/
|
||||
export interface TreeViewAlpha<
|
||||
in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
|
||||
> extends Omit<
|
||||
TreeView<TSchema extends ImplicitFieldSchema ? TSchema : ImplicitFieldSchema>,
|
||||
"root" | "initialize"
|
||||
> {
|
||||
get root(): TSchema extends ImplicitFieldSchema
|
||||
? TreeFieldFromImplicitField<TSchema>
|
||||
: TreeLeafValue | TreeNode;
|
||||
|
||||
set root(newRoot: InsertableField<TSchema>);
|
||||
|
||||
initialize(content: InsertableField<TSchema>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about a view schema's compatibility with the document's stored schema.
|
||||
*
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
import type { RestrictiveStringRecord, _InlineTrick } from "../../util/index.js";
|
||||
|
||||
import type {
|
||||
AllowedTypes,
|
||||
ApplyKind,
|
||||
FieldKind,
|
||||
FieldSchema,
|
||||
ImplicitAllowedTypes,
|
||||
ImplicitFieldSchema,
|
||||
NodeFromSchema,
|
||||
TreeNodeFromImplicitAllowedTypes,
|
||||
TreeLeafValue,
|
||||
} from "../schemaTypes.js";
|
||||
import type {
|
||||
NodeKind,
|
||||
TreeNodeSchema,
|
||||
WithType,
|
||||
TreeNode,
|
||||
Unhydrated,
|
||||
InternalTreeNode,
|
||||
TreeNodeSchema,
|
||||
TreeNodeSchemaCore,
|
||||
} from "../core/index.js";
|
||||
import type { TreeArrayNodeBase, TreeArrayNode } from "../arrayNode.js";
|
||||
import type { FlexListToUnion } from "../flexList.js";
|
||||
import type { TreeArrayNodeBase } from "../arrayNode.js";
|
||||
import type { FlexListToUnion, LazyItem } from "../flexList.js";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -59,6 +59,65 @@ export type ObjectFromSchemaRecordUnsafe<
|
|||
-readonly [Property in keyof T]: TreeFieldFromImplicitFieldUnsafe<T[Property]>;
|
||||
};
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link TreeNodeSchema}.
|
||||
* @remarks
|
||||
* Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
||||
* @system @public
|
||||
*/
|
||||
export type TreeNodeSchemaUnsafe<
|
||||
Name extends string = string,
|
||||
Kind extends NodeKind = NodeKind,
|
||||
TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown,
|
||||
TBuild = never,
|
||||
ImplicitlyConstructable extends boolean = boolean,
|
||||
Info = unknown,
|
||||
> =
|
||||
| TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
|
||||
| TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link TreeNodeSchemaClass}.
|
||||
* @remarks
|
||||
* Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
||||
* @system @public
|
||||
*/
|
||||
export interface TreeNodeSchemaClassUnsafe<
|
||||
out Name extends string,
|
||||
out Kind extends NodeKind,
|
||||
// TODO: maybe this can be more specific (exclude leaves)
|
||||
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
||||
in TInsertable,
|
||||
out ImplicitlyConstructable extends boolean,
|
||||
out Info,
|
||||
> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
/**
|
||||
* Constructs an {@link Unhydrated} node with this schema.
|
||||
* @remarks
|
||||
* This constructor is also used internally to construct hydrated nodes with a different parameter type.
|
||||
* Therefore, overriding this constructor with different argument types is not type-safe and is not supported.
|
||||
* @sealed
|
||||
*/
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link TreeNodeSchemaNonClass}.
|
||||
* @remarks
|
||||
* Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
||||
* @system @public
|
||||
*/
|
||||
export interface TreeNodeSchemaNonClassUnsafe<
|
||||
out Name extends string,
|
||||
out Kind extends NodeKind,
|
||||
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
||||
in TInsertable,
|
||||
out ImplicitlyConstructable extends boolean,
|
||||
out Info = unknown,
|
||||
> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link TreeObjectNode}.
|
||||
* @remarks
|
||||
|
@ -83,6 +142,14 @@ export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<Implicit
|
|||
? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema>
|
||||
: unknown;
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link AllowedTypes}.
|
||||
* @remarks
|
||||
* Do not use this type directly: it is only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
||||
* @system @public
|
||||
*/
|
||||
export type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link TreeNodeFromImplicitAllowedTypes}.
|
||||
* @remarks
|
||||
|
@ -91,13 +158,11 @@ export type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<Implicit
|
|||
*/
|
||||
export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
||||
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
||||
> = TSchema extends ImplicitAllowedTypes
|
||||
? TreeNodeFromImplicitAllowedTypes<TSchema>
|
||||
: TSchema extends TreeNodeSchema
|
||||
? NodeFromSchema<TSchema>
|
||||
: TSchema extends AllowedTypes
|
||||
? NodeFromSchema<FlexListToUnion<TSchema>>
|
||||
: unknown;
|
||||
> = TSchema extends TreeNodeSchemaUnsafe
|
||||
? NodeFromSchemaUnsafe<TSchema>
|
||||
: TSchema extends AllowedTypesUnsafe
|
||||
? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>>
|
||||
: unknown;
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
||||
|
@ -107,7 +172,7 @@ export type TreeNodeFromImplicitAllowedTypesUnsafe<
|
|||
*/
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<
|
||||
TSchema extends Unenforced<ImplicitAllowedTypes>,
|
||||
> = TSchema extends AllowedTypes
|
||||
> = TSchema extends AllowedTypesUnsafe
|
||||
? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>>
|
||||
: InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
|
@ -129,7 +194,7 @@ export type InsertableTypedNodeUnsafe<T extends Unenforced<TreeNodeSchema>> = [
|
|||
* @system @public
|
||||
*/
|
||||
export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
||||
T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link InsertableTreeNodeFromImplicitAllowedTypes}.
|
||||
|
@ -138,7 +203,7 @@ export type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|||
* @system @public
|
||||
*/
|
||||
export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
||||
T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
/**
|
||||
* {@link Unenforced} version of {@link (TreeArrayNode:interface)}.
|
||||
|
@ -149,8 +214,7 @@ export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>>
|
||||
extends TreeArrayNodeBase<
|
||||
TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,
|
||||
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,
|
||||
TreeArrayNode
|
||||
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>
|
||||
> {}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
normalizeAllowedTypes,
|
||||
type ImplicitAllowedTypes,
|
||||
type InsertableTreeNodeFromImplicitAllowedTypes,
|
||||
type TreeLeafValue,
|
||||
type TreeNodeFromImplicitAllowedTypes,
|
||||
} from "./schemaTypes.js";
|
||||
import {
|
||||
|
@ -34,6 +35,7 @@ import {
|
|||
type TreeNodeSchemaBoth,
|
||||
getSimpleNodeSchemaFromInnerNode,
|
||||
getOrCreateInnerNode,
|
||||
type TreeNodeSchemaClass,
|
||||
} from "./core/index.js";
|
||||
import { type InsertableContent, mapTreeFromNodeData } from "./toMapTree.js";
|
||||
import { fail } from "../util/index.js";
|
||||
|
@ -45,6 +47,19 @@ import {
|
|||
import { TreeNodeValid, type MostDerivedData } from "./treeNodeValid.js";
|
||||
import { getUnhydratedContext } from "./createContext.js";
|
||||
|
||||
/**
|
||||
* A covariant base type for {@link (TreeArrayNode:interface)}.
|
||||
*
|
||||
* This provides the readonly subset of TreeArrayNode functionality, and is used as the source interface for moves since that needs to be covariant.
|
||||
* @privateRemarks
|
||||
* Ideally this would just include `TreeNode, WithType<string, NodeKind.Array>` in the extends list but https://github.com/microsoft/TypeScript/issues/16936 prevents that from compiling.
|
||||
* As a workaround around for this TypeScript limitation, the conflicting type intersection is wrapped in `Awaited` (which has no effect on the type in this case) which allows it to compile.
|
||||
* @system @sealed @public
|
||||
*/
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue>
|
||||
extends ReadonlyArray<T>,
|
||||
Awaited<TreeNode & WithType<string, NodeKind.Array>> {}
|
||||
|
||||
/**
|
||||
* A generic array type, used to defined types like {@link (TreeArrayNode:interface)}.
|
||||
*
|
||||
|
@ -53,9 +68,8 @@ import { getUnhydratedContext } from "./createContext.js";
|
|||
*
|
||||
* @system @sealed @public
|
||||
*/
|
||||
export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom>
|
||||
extends ReadonlyArray<T>,
|
||||
TreeNode {
|
||||
export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode>
|
||||
extends ReadonlyArrayNode<T> {
|
||||
/**
|
||||
* Inserts new item(s) at a specified location.
|
||||
* @param index - The index at which to insert `value`.
|
||||
|
@ -366,8 +380,7 @@ export interface TreeArrayNode<
|
|||
TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
||||
> extends TreeArrayNodeBase<
|
||||
TreeNodeFromImplicitAllowedTypes<TAllowedTypes>,
|
||||
InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>,
|
||||
TreeArrayNode
|
||||
InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>
|
||||
> {}
|
||||
|
||||
/**
|
||||
|
@ -417,9 +430,7 @@ export class IterableTreeArrayContent<T> implements Iterable<T> {
|
|||
/**
|
||||
* Given a array node proxy, returns its underlying LazySequence field.
|
||||
*/
|
||||
function getSequenceField<TSimpleType extends ImplicitAllowedTypes>(
|
||||
arrayNode: TreeArrayNode<TSimpleType>,
|
||||
): FlexTreeSequenceField {
|
||||
function getSequenceField(arrayNode: ReadonlyArrayNode): FlexTreeSequenceField {
|
||||
return getOrCreateInnerNode(arrayNode).getBoxed(EmptyKey) as FlexTreeSequenceField;
|
||||
}
|
||||
|
||||
|
@ -799,6 +810,11 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|||
protected abstract get simpleSchema(): T;
|
||||
protected abstract get allowedTypes(): ReadonlySet<TreeNodeSchema>;
|
||||
|
||||
public abstract override get [typeSchemaSymbol](): TreeNodeSchemaClass<
|
||||
string,
|
||||
NodeKind.Array
|
||||
>;
|
||||
|
||||
public constructor(
|
||||
input: Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>> | InternalTreeNode,
|
||||
) {
|
||||
|
@ -901,13 +917,13 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|||
}
|
||||
field.editor.remove(removeStart, removeEnd - removeStart);
|
||||
}
|
||||
public moveToStart(sourceIndex: number, source?: TreeArrayNode): void {
|
||||
public moveToStart(sourceIndex: number, source?: ReadonlyArrayNode): void {
|
||||
const sourceArray = source ?? this;
|
||||
const sourceField = getSequenceField(sourceArray);
|
||||
validateIndex(sourceIndex, sourceField, "moveToStart");
|
||||
this.moveRangeToIndex(0, sourceIndex, sourceIndex + 1, source);
|
||||
}
|
||||
public moveToEnd(sourceIndex: number, source?: TreeArrayNode): void {
|
||||
public moveToEnd(sourceIndex: number, source?: ReadonlyArrayNode): void {
|
||||
const sourceArray = source ?? this;
|
||||
const sourceField = getSequenceField(sourceArray);
|
||||
validateIndex(sourceIndex, sourceField, "moveToEnd");
|
||||
|
@ -916,7 +932,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|||
public moveToIndex(
|
||||
destinationGap: number,
|
||||
sourceIndex: number,
|
||||
source?: TreeArrayNode,
|
||||
source?: ReadonlyArrayNode,
|
||||
): void {
|
||||
const sourceArray = source ?? this;
|
||||
const sourceField = getSequenceField(sourceArray);
|
||||
|
@ -928,7 +944,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|||
public moveRangeToStart(
|
||||
sourceStart: number,
|
||||
sourceEnd: number,
|
||||
source?: TreeArrayNode,
|
||||
source?: ReadonlyArrayNode,
|
||||
): void {
|
||||
validateIndexRange(
|
||||
sourceStart,
|
||||
|
@ -938,7 +954,11 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|||
);
|
||||
this.moveRangeToIndex(0, sourceStart, sourceEnd, source);
|
||||
}
|
||||
public moveRangeToEnd(sourceStart: number, sourceEnd: number, source?: TreeArrayNode): void {
|
||||
public moveRangeToEnd(
|
||||
sourceStart: number,
|
||||
sourceEnd: number,
|
||||
source?: ReadonlyArrayNode,
|
||||
): void {
|
||||
validateIndexRange(
|
||||
sourceStart,
|
||||
sourceEnd,
|
||||
|
@ -951,7 +971,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|||
destinationGap: number,
|
||||
sourceStart: number,
|
||||
sourceEnd: number,
|
||||
source?: TreeArrayNode,
|
||||
source?: ReadonlyArrayNode,
|
||||
): void {
|
||||
const destinationField = getSequenceField(this);
|
||||
const destinationSchema = this.allowedTypes;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
import type { InternalTreeNode, Unhydrated } from "./types.js";
|
||||
import type { TreeLeafValue } from "../schemaTypes.js";
|
||||
import type { InternalTreeNode, TreeNode, Unhydrated } from "./types.js";
|
||||
|
||||
/**
|
||||
* Schema for a tree node.
|
||||
|
@ -19,7 +20,7 @@ import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|||
export type TreeNodeSchema<
|
||||
Name extends string = string,
|
||||
Kind extends NodeKind = NodeKind,
|
||||
TNode = unknown,
|
||||
TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,
|
||||
TBuild = never,
|
||||
ImplicitlyConstructable extends boolean = boolean,
|
||||
Info = unknown,
|
||||
|
@ -38,7 +39,7 @@ export type TreeNodeSchema<
|
|||
export interface TreeNodeSchemaNonClass<
|
||||
out Name extends string = string,
|
||||
out Kind extends NodeKind = NodeKind,
|
||||
out TNode = unknown,
|
||||
out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,
|
||||
in TInsertable = never,
|
||||
out ImplicitlyConstructable extends boolean = boolean,
|
||||
out Info = unknown,
|
||||
|
@ -94,7 +95,8 @@ export interface TreeNodeSchemaNonClass<
|
|||
export interface TreeNodeSchemaClass<
|
||||
out Name extends string = string,
|
||||
out Kind extends NodeKind = NodeKind,
|
||||
out TNode = unknown,
|
||||
// TODO: maybe this can be more specific (exclude leaves)
|
||||
out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,
|
||||
in TInsertable = never,
|
||||
out ImplicitlyConstructable extends boolean = boolean,
|
||||
out Info = unknown,
|
||||
|
@ -115,7 +117,7 @@ export interface TreeNodeSchemaClass<
|
|||
export type TreeNodeSchemaBoth<
|
||||
Name extends string = string,
|
||||
Kind extends NodeKind = NodeKind,
|
||||
TNode = unknown,
|
||||
TNode extends TreeNode = TreeNode,
|
||||
TInsertable = never,
|
||||
ImplicitlyConstructable extends boolean = boolean,
|
||||
Info = unknown,
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
import type { TreeLeafValue } from "../schemaTypes.js";
|
||||
import type { NodeKind, TreeNodeSchemaClass } from "./treeNodeSchema.js";
|
||||
import type { TreeNode } from "./types.js";
|
||||
|
||||
/**
|
||||
* The type of a {@link TreeNode}.
|
||||
|
@ -87,5 +89,12 @@ export interface WithType<
|
|||
/**
|
||||
* Type symbol, marking a type in a way to increase type safety via strong type checking.
|
||||
*/
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<
|
||||
TName,
|
||||
TKind,
|
||||
TreeNode | TreeLeafValue,
|
||||
never,
|
||||
boolean,
|
||||
TInfo
|
||||
>;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,11 @@ export {
|
|||
type NodeBuilderDataUnsafe,
|
||||
type NodeFromSchemaUnsafe,
|
||||
type ReadonlyMapInlined,
|
||||
type TreeNodeSchemaClassUnsafe,
|
||||
type TreeNodeSchemaUnsafe,
|
||||
type AllowedTypesUnsafe,
|
||||
type TreeNodeSchemaNonClassUnsafe,
|
||||
type TreeViewAlpha,
|
||||
} from "./api/index.js";
|
||||
export {
|
||||
type NodeFromSchema,
|
||||
|
@ -113,6 +118,9 @@ export {
|
|||
normalizeFieldSchema,
|
||||
type ApplyKind,
|
||||
type FieldSchemaMetadata,
|
||||
type InsertableField,
|
||||
type Insertable,
|
||||
type UnsafeUnknownSchema,
|
||||
} from "./schemaTypes.js";
|
||||
export {
|
||||
getTreeNodeForField,
|
||||
|
@ -122,6 +130,7 @@ export {
|
|||
TreeArrayNode,
|
||||
IterableTreeArrayContent,
|
||||
type TreeArrayNodeBase,
|
||||
type ReadonlyArrayNode,
|
||||
} from "./arrayNode.js";
|
||||
export {
|
||||
type FieldHasDefault,
|
||||
|
@ -131,7 +140,12 @@ export {
|
|||
setField,
|
||||
} from "./objectNode.js";
|
||||
export type { TreeMapNode, MapNodeInsertableData } from "./mapNode.js";
|
||||
export { mapTreeFromNodeData, type InsertableContent } from "./toMapTree.js";
|
||||
export {
|
||||
mapTreeFromNodeData,
|
||||
type InsertableContent,
|
||||
type FactoryContent,
|
||||
type FactoryContentObject,
|
||||
} from "./toMapTree.js";
|
||||
export { toStoredSchema, getStoredSchema } from "./toFlexSchema.js";
|
||||
export {
|
||||
numberSchema,
|
||||
|
|
|
@ -14,6 +14,7 @@ import type {
|
|||
NodeKind,
|
||||
TreeNodeSchema,
|
||||
TreeNodeSchemaClass,
|
||||
TreeNode,
|
||||
} from "./core/index.js";
|
||||
import type { FieldKey } from "../core/index.js";
|
||||
import type { InsertableContent } from "./toMapTree.js";
|
||||
|
@ -25,7 +26,7 @@ import { isLazy, type FlexListToUnion, type LazyItem } from "./flexList.js";
|
|||
export function isTreeNodeSchemaClass<
|
||||
Name extends string,
|
||||
Kind extends NodeKind,
|
||||
TNode,
|
||||
TNode extends TreeNode | TreeLeafValue,
|
||||
TBuild,
|
||||
ImplicitlyConstructable extends boolean,
|
||||
Info,
|
||||
|
@ -381,7 +382,17 @@ export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|||
export type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;
|
||||
|
||||
/**
|
||||
* Converts ImplicitFieldSchema to the corresponding tree node's field type.
|
||||
* Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.
|
||||
*
|
||||
* @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).
|
||||
* This is ideal for "output APIs" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.
|
||||
* Examples of such "non-exact" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.
|
||||
* @privateRemarks
|
||||
* TODO:
|
||||
* There are two known problematic usages of this type (which produce invalid/unsound results when given non-specific schema):
|
||||
* 1. setters for fields (on object nodes the Tree.view.root).
|
||||
* 2. Indirectly in InsertableTreeFieldFromImplicitField via InsertableTypedNode including NodeFromSchema.
|
||||
* These cases should be mitigated by introducing a way to detect inexact schema and special casing them in these two places.
|
||||
* @public
|
||||
*/
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =
|
||||
|
@ -389,7 +400,7 @@ export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = Fie
|
|||
? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false>
|
||||
: TSchema extends ImplicitAllowedTypes
|
||||
? TreeNodeFromImplicitAllowedTypes<TSchema>
|
||||
: unknown;
|
||||
: TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
/**
|
||||
* Type of content that can be inserted into the tree for a field of the given schema.
|
||||
|
@ -401,7 +412,55 @@ export type InsertableTreeFieldFromImplicitField<
|
|||
? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>
|
||||
: TSchema extends ImplicitAllowedTypes
|
||||
? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>
|
||||
: unknown;
|
||||
: never;
|
||||
|
||||
/**
|
||||
* {@inheritdoc (UnsafeUnknownSchema:type)}
|
||||
* @alpha
|
||||
*/
|
||||
export const UnsafeUnknownSchema: unique symbol = Symbol("UnsafeUnknownSchema");
|
||||
|
||||
/**
|
||||
* A special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.
|
||||
* @remarks
|
||||
* When used, this means the TypeScript typing should err on the side of completeness (allow all inputs that could be valid).
|
||||
* This introduces the risk that out-of-schema data could be allowed at compile time, and only error at runtime.
|
||||
*
|
||||
* @privateRemarks
|
||||
* This only applies to APIs which input data which is expected to be in schema, since APIs outputting have easy mechanisms to do so in a type safe way even when the schema is unknown.
|
||||
* In most cases that amounts to returning `TreeNode | TreeLeafValue`.
|
||||
*
|
||||
* This can be contrasted with the default behavior of TypeScript, which is to require the intersection of the possible types for input APIs,
|
||||
* which for unknown schema defining input trees results in the `never` type.
|
||||
*
|
||||
* Any APIs which use this must produce UsageErrors when out of schema data is encountered, and never produce unrecoverable errors,
|
||||
* or silently accept invalid data.
|
||||
* This is currently only type exported from the package: the symbol is just used as a way to get a named type.
|
||||
* @alpha
|
||||
*/
|
||||
export type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;
|
||||
|
||||
/**
|
||||
* Content which could be inserted into a tree.
|
||||
* @remarks
|
||||
* Extended version of {@link InsertableTreeNodeFromImplicitAllowedTypes} that also allows {@link (UnsafeUnknownSchema:type)}.
|
||||
* @alpha
|
||||
*/
|
||||
export type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> =
|
||||
TSchema extends ImplicitAllowedTypes
|
||||
? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>
|
||||
: InsertableContent;
|
||||
|
||||
/**
|
||||
* Content which could be inserted into a field within a tree.
|
||||
* @remarks
|
||||
* Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.
|
||||
* @alpha
|
||||
*/
|
||||
export type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =
|
||||
TSchema extends ImplicitFieldSchema
|
||||
? InsertableTreeFieldFromImplicitField<TSchema>
|
||||
: InsertableContent | undefined;
|
||||
|
||||
/**
|
||||
* Suitable for output.
|
||||
|
@ -453,6 +512,10 @@ export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<
|
|||
/**
|
||||
* Data which can be used as a node to be inserted.
|
||||
* Either an unhydrated node, or content to build a new node.
|
||||
* @privateRemarks
|
||||
* TODO:
|
||||
* This should behave contravariantly, but it uses NodeFromSchema which behaves covariantly.
|
||||
* This results in unsoundness where, when the schema is less specific, more types are allowed instead of less.
|
||||
* @public
|
||||
*/
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> =
|
||||
|
@ -471,7 +534,7 @@ export type InsertableTypedNode<T extends TreeNodeSchema> =
|
|||
export type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<
|
||||
string,
|
||||
NodeKind,
|
||||
unknown,
|
||||
TreeNode | TreeLeafValue,
|
||||
infer TBuild
|
||||
>
|
||||
? TBuild
|
||||
|
|
|
@ -726,6 +726,7 @@ function tryGetInnerNode(target: unknown): InnerNode | undefined {
|
|||
* Content which can be used to build a node.
|
||||
* @remarks
|
||||
* Can contain unhydrated nodes, but can not be an unhydrated node at the root.
|
||||
* @system @alpha
|
||||
*/
|
||||
export type FactoryContent =
|
||||
| IFluidHandle
|
||||
|
@ -744,12 +745,14 @@ export type FactoryContent =
|
|||
* Can contain unhydrated nodes, but can not be an unhydrated node at the root.
|
||||
*
|
||||
* Supports object and map nodes.
|
||||
* @system @alpha
|
||||
*/
|
||||
type FactoryContentObject = {
|
||||
export type FactoryContentObject = {
|
||||
readonly [P in string]?: InsertableContent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Content which can be inserted into a tree.
|
||||
* @system @alpha
|
||||
*/
|
||||
export type InsertableContent = Unhydrated<TreeNode> | FactoryContent;
|
||||
|
|
|
@ -248,6 +248,7 @@ describe("SchemaFactory Recursive methods", () => {
|
|||
type _check = ValidateRecursiveSchema<typeof ObjectRecursive>;
|
||||
}
|
||||
|
||||
// Explicit construction under recursive type
|
||||
const tree2 = hydrate(
|
||||
ObjectRecursive,
|
||||
new ObjectRecursive({
|
||||
|
@ -259,6 +260,60 @@ describe("SchemaFactory Recursive methods", () => {
|
|||
e: new Other({ y: 5 }),
|
||||
}),
|
||||
);
|
||||
|
||||
// implicit construction under recursive type
|
||||
const tree3 = hydrate(
|
||||
ObjectRecursive,
|
||||
new ObjectRecursive({
|
||||
x: undefined,
|
||||
a: { y: 5 },
|
||||
b: { y: 5 },
|
||||
c: { y: 5 },
|
||||
d: { y: 5 },
|
||||
e: { y: 5 },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("array under recursive object", () => {
|
||||
class Other extends sf.array("Other", sf.number) {}
|
||||
class ObjectRecursive extends sf.objectRecursive("Object", {
|
||||
x: sf.optionalRecursive([() => ObjectRecursive]),
|
||||
a: Other,
|
||||
b: [Other],
|
||||
c: [() => Other],
|
||||
d: sf.optional(Other),
|
||||
e: sf.optional([() => Other]),
|
||||
}) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof ObjectRecursive>;
|
||||
}
|
||||
|
||||
// Explicit construction under recursive type
|
||||
const tree2 = hydrate(
|
||||
ObjectRecursive,
|
||||
new ObjectRecursive({
|
||||
x: undefined,
|
||||
a: new Other([5]),
|
||||
b: new Other([5]),
|
||||
c: new Other([5]),
|
||||
d: new Other([5]),
|
||||
e: new Other([5]),
|
||||
}),
|
||||
);
|
||||
|
||||
// implicit construction under recursive type
|
||||
const tree3 = hydrate(
|
||||
ObjectRecursive,
|
||||
new ObjectRecursive({
|
||||
x: undefined,
|
||||
a: [5],
|
||||
b: [5],
|
||||
c: [5],
|
||||
d: [5],
|
||||
e: [5],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("object nested construction", () => {
|
||||
|
@ -476,6 +531,51 @@ describe("SchemaFactory Recursive methods", () => {
|
|||
data[0].insertAtEnd(new ArrayRecursive([]));
|
||||
}
|
||||
});
|
||||
|
||||
it("co-recursive", () => {
|
||||
class A extends sf.arrayRecursive("A", [() => B]) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof A>;
|
||||
}
|
||||
class B extends sf.arrayRecursive("B", A) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof B>;
|
||||
}
|
||||
// Explicit constructor call
|
||||
{
|
||||
const data: A = hydrate(A, new A([]));
|
||||
assert.deepEqual([...data], []);
|
||||
}
|
||||
});
|
||||
|
||||
it("co-recursive with object", () => {
|
||||
class A extends sf.arrayRecursive("A", [() => B]) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof A>;
|
||||
}
|
||||
class B extends sf.objectRecursive("B", { x: A }) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof B>;
|
||||
}
|
||||
// Explicit constructor call
|
||||
{
|
||||
const data: A = hydrate(A, new A([]));
|
||||
assert.deepEqual([...data], []);
|
||||
}
|
||||
});
|
||||
|
||||
it("co-recursive with object first", () => {
|
||||
class B extends sf.objectRecursive("B", { x: [() => A] }) {}
|
||||
{
|
||||
type _check = ValidateRecursiveSchema<typeof B>;
|
||||
}
|
||||
class A extends sf.array("A", B) {}
|
||||
// Explicit constructor call
|
||||
{
|
||||
const data: A = hydrate(A, new A([]));
|
||||
assert.deepEqual([...data], []);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("mapRecursive", () => {
|
||||
|
|
|
@ -7,16 +7,38 @@ import { strict as assert } from "assert";
|
|||
|
||||
import {
|
||||
type ImplicitFieldSchema,
|
||||
type InsertableTreeFieldFromImplicitField,
|
||||
SchemaFactory,
|
||||
type TreeFieldFromImplicitField,
|
||||
type InsertableField,
|
||||
type UnsafeUnknownSchema,
|
||||
} from "../../simple-tree/index.js";
|
||||
|
||||
import { hydrate, pretty } from "./utils.js";
|
||||
|
||||
interface TestCase<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> {
|
||||
interface TestCase<TSchema extends ImplicitFieldSchema> {
|
||||
readonly name?: string;
|
||||
readonly schema: TSchema;
|
||||
readonly initialTree: InsertableTreeFieldFromImplicitField<TSchema>;
|
||||
}
|
||||
|
||||
interface TestCaseErased {
|
||||
name?: string;
|
||||
schema: TSchema;
|
||||
initialTree: TreeFieldFromImplicitField<TSchema>;
|
||||
schema: ImplicitFieldSchema;
|
||||
initialTree: InsertableField<UnsafeUnknownSchema>;
|
||||
}
|
||||
|
||||
function test<T extends ImplicitFieldSchema>(t: TestCase<T>): TestCaseErased {
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a generic function over an array, assuming that doing so is well defined.
|
||||
* @remarks
|
||||
* This is useful for processing arrays of generically parameterized values with differing values for their type parameter.
|
||||
* If the type parameter got type erased when collecting the items into the array, this utility can be used to process the items as iff they each still had the type parameter.
|
||||
*/
|
||||
function unsafeMapErased<E, R>(data: readonly E[], f: <T>(t: never) => R): R[] {
|
||||
return data.map((item) => f(item as never));
|
||||
}
|
||||
|
||||
export function testObjectPrototype(proxy: object, prototype: object) {
|
||||
|
@ -39,15 +61,18 @@ export function testObjectPrototype(proxy: object, prototype: object) {
|
|||
});
|
||||
}
|
||||
|
||||
function testObjectLike(testCases: TestCase[]) {
|
||||
function testObjectLike(testCases: TestCaseErased[]) {
|
||||
describe("Object-like", () => {
|
||||
describe("satisfies 'deepEqual'", () => {
|
||||
for (const { schema, initialTree, name } of testCases) {
|
||||
it(name ?? pretty(initialTree).toString(), () => {
|
||||
const proxy = hydrate(schema, initialTree);
|
||||
assert.deepEqual(proxy, initialTree, "Proxy must satisfy 'deepEqual'.");
|
||||
});
|
||||
}
|
||||
unsafeMapErased(
|
||||
testCases,
|
||||
<TSchema extends ImplicitFieldSchema>(item: TestCase<TSchema>) => {
|
||||
it(item.name ?? pretty(item.initialTree).toString(), () => {
|
||||
const proxy = hydrate(item.schema, item.initialTree);
|
||||
assert.deepEqual(proxy, item.initialTree, "Proxy must satisfy 'deepEqual'.");
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("inherits from Object.prototype", () => {
|
||||
|
@ -59,60 +84,63 @@ function testObjectLike(testCases: TestCase[]) {
|
|||
) as object;
|
||||
}
|
||||
|
||||
for (const { schema, initialTree } of testCases) {
|
||||
describe("instanceof Object", () => {
|
||||
it(`${pretty(initialTree)} -> true`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
assert(root instanceof Object, "object must be instanceof Object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("properties inherited from Object.prototype", () => {
|
||||
for (const [key, descriptor] of Object.entries(
|
||||
Object.getOwnPropertyDescriptors(Object.prototype),
|
||||
)) {
|
||||
it(`Object.getOwnPropertyDescriptor(${pretty(initialTree)}, ${key}) -> ${pretty(
|
||||
descriptor,
|
||||
)}`, () => {
|
||||
unsafeMapErased(
|
||||
testCases,
|
||||
<TSchema extends ImplicitFieldSchema>({ initialTree, schema }: TestCase<TSchema>) => {
|
||||
describe("instanceof Object", () => {
|
||||
it(`${pretty(initialTree)} -> true`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
assert.deepEqual(
|
||||
Object.getOwnPropertyDescriptor(findObjectPrototype(root), key),
|
||||
descriptor,
|
||||
`Proxy must expose Object.prototype.${key}`,
|
||||
);
|
||||
assert(root instanceof Object, "object must be instanceof Object");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("methods inherited from Object.prototype", () => {
|
||||
it(`${pretty(initialTree)}.isPrototypeOf(Object.create(root)) -> true`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
const asObject = root as object;
|
||||
// eslint-disable-next-line no-prototype-builtins -- compatibility test
|
||||
assert.equal(asObject.isPrototypeOf(Object.create(asObject)), true);
|
||||
});
|
||||
|
||||
it(`${pretty(initialTree)}.isPrototypeOf(root) -> false`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
const asObject = root as object;
|
||||
// eslint-disable-next-line no-prototype-builtins -- compatibility test
|
||||
assert.equal(asObject.isPrototypeOf(asObject), false);
|
||||
describe("properties inherited from Object.prototype", () => {
|
||||
for (const [key, descriptor] of Object.entries(
|
||||
Object.getOwnPropertyDescriptors(Object.prototype),
|
||||
)) {
|
||||
it(`Object.getOwnPropertyDescriptor(${pretty(initialTree)}, ${key}) -> ${pretty(
|
||||
descriptor,
|
||||
)}`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
assert.deepEqual(
|
||||
Object.getOwnPropertyDescriptor(findObjectPrototype(root), key),
|
||||
descriptor,
|
||||
`Proxy must expose Object.prototype.${key}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe(`${pretty(initialTree)}.propertyIsEnumerable`, () => {
|
||||
for (const key of Object.getOwnPropertyNames(initialTree)) {
|
||||
const expected = Object.prototype.propertyIsEnumerable.call(initialTree, key);
|
||||
|
||||
it(`${key} -> ${expected}`, () => {
|
||||
describe("methods inherited from Object.prototype", () => {
|
||||
it(`${pretty(initialTree)}.isPrototypeOf(Object.create(root)) -> true`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
const asObject = root as object;
|
||||
// eslint-disable-next-line no-prototype-builtins -- compatibility test
|
||||
assert.equal(asObject.propertyIsEnumerable(key), expected);
|
||||
assert.equal(asObject.isPrototypeOf(Object.create(asObject)), true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it(`${pretty(initialTree)}.isPrototypeOf(root) -> false`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
const asObject = root as object;
|
||||
// eslint-disable-next-line no-prototype-builtins -- compatibility test
|
||||
assert.equal(asObject.isPrototypeOf(asObject), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`${pretty(initialTree)}.propertyIsEnumerable`, () => {
|
||||
for (const key of Object.getOwnPropertyNames(initialTree)) {
|
||||
const expected = Object.prototype.propertyIsEnumerable.call(initialTree, key);
|
||||
|
||||
it(`${key} -> ${expected}`, () => {
|
||||
const root = hydrate(schema, initialTree);
|
||||
const asObject = root as object;
|
||||
// eslint-disable-next-line no-prototype-builtins -- compatibility test
|
||||
assert.equal(asObject.propertyIsEnumerable(key), expected);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -120,16 +148,23 @@ function testObjectLike(testCases: TestCase[]) {
|
|||
* The results are asserted to be equal with nodes's assert.deepEqual.
|
||||
*/
|
||||
function test1(fn: (subject: object) => unknown) {
|
||||
for (const { schema, initialTree, name } of testCases) {
|
||||
const pojo = structuredClone(initialTree) as object;
|
||||
unsafeMapErased(
|
||||
testCases,
|
||||
<TSchema extends ImplicitFieldSchema>({
|
||||
initialTree,
|
||||
schema,
|
||||
name,
|
||||
}: TestCase<TSchema>) => {
|
||||
const pojo = structuredClone(initialTree) as object;
|
||||
|
||||
it(name ?? `${pretty(pojo)} -> ${pretty(fn(pojo))}`, () => {
|
||||
const expected = fn(pojo);
|
||||
const node = hydrate(schema, initialTree);
|
||||
const actual = fn(node as object);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}
|
||||
it(name ?? `${pretty(pojo)} -> ${pretty(fn(pojo))}`, () => {
|
||||
const expected = fn(pojo);
|
||||
const node = hydrate(schema, initialTree);
|
||||
const actual = fn(node as object);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
describe("Object.keys", () => {
|
||||
|
@ -225,15 +260,15 @@ function testObjectLike(testCases: TestCase[]) {
|
|||
});
|
||||
}
|
||||
|
||||
const tcs: TestCase[] = [
|
||||
{
|
||||
const tcs: TestCaseErased[] = [
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testA");
|
||||
return _.object("empty", {});
|
||||
})(),
|
||||
initialTree: {},
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testB");
|
||||
return _.object("primitives", {
|
||||
|
@ -247,8 +282,8 @@ const tcs: TestCase[] = [
|
|||
number: Math.E,
|
||||
string: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
name: "Empty tree, optional fields",
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testC");
|
||||
|
@ -259,8 +294,8 @@ const tcs: TestCase[] = [
|
|||
});
|
||||
})(),
|
||||
initialTree: {},
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testD");
|
||||
return _.object("optional (defined)", {
|
||||
|
@ -274,8 +309,8 @@ const tcs: TestCase[] = [
|
|||
number: 0,
|
||||
string: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testE");
|
||||
|
||||
|
@ -286,9 +321,9 @@ const tcs: TestCase[] = [
|
|||
});
|
||||
})(),
|
||||
initialTree: { nested: {} },
|
||||
},
|
||||
}),
|
||||
// Case with explicit stored keys
|
||||
{
|
||||
test({
|
||||
schema: (() => {
|
||||
const schemaFactoryInner = new SchemaFactory("testE");
|
||||
return schemaFactoryInner.object("object", {
|
||||
|
@ -305,9 +340,9 @@ const tcs: TestCase[] = [
|
|||
bar: "hello world",
|
||||
baz: null,
|
||||
},
|
||||
},
|
||||
}),
|
||||
// Case with omitted optional property
|
||||
{
|
||||
test({
|
||||
schema: (() => {
|
||||
const schemaFactoryInner = new SchemaFactory("test-inner");
|
||||
return schemaFactoryInner.object("object", {
|
||||
|
@ -317,29 +352,29 @@ const tcs: TestCase[] = [
|
|||
initialTree: {
|
||||
// `foo` property omitted - property should be implicitly treated as `undefined`.
|
||||
},
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testF");
|
||||
return _.array(_.string);
|
||||
})(),
|
||||
initialTree: [],
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testG");
|
||||
return _.array(_.string);
|
||||
})(),
|
||||
initialTree: ["A"],
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testH");
|
||||
return _.array(_.string);
|
||||
})(),
|
||||
initialTree: ["A", "B"],
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
name: "Special Keys",
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testI");
|
||||
|
@ -360,8 +395,8 @@ const tcs: TestCase[] = [
|
|||
constructor: 5,
|
||||
setting: 6,
|
||||
},
|
||||
},
|
||||
{
|
||||
}),
|
||||
test({
|
||||
name: "toString key",
|
||||
schema: (() => {
|
||||
const _ = new SchemaFactory("testI");
|
||||
|
@ -372,7 +407,7 @@ const tcs: TestCase[] = [
|
|||
initialTree: {
|
||||
toString: 1,
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
testObjectLike(tcs);
|
||||
|
|
|
@ -8,7 +8,7 @@ import { strict as assert } from "node:assert";
|
|||
import { validateAssertionError } from "@fluidframework/test-runtime-utils/internal";
|
||||
|
||||
import type { TreeValue } from "../../core/index.js";
|
||||
import { SchemaFactory, type TreeNodeSchema } from "../../simple-tree/index.js";
|
||||
import { SchemaFactory, type TreeNode, type TreeNodeSchema } from "../../simple-tree/index.js";
|
||||
import {
|
||||
type InsertableTreeFieldFromImplicitField,
|
||||
type InsertableTypedNode,
|
||||
|
@ -20,7 +20,6 @@ import {
|
|||
normalizeAllowedTypes,
|
||||
// eslint-disable-next-line import/no-internal-modules
|
||||
} from "../../simple-tree/schemaTypes.js";
|
||||
import { TreeFactory } from "../../treeFactory.js";
|
||||
import type {
|
||||
areSafelyAssignable,
|
||||
requireAssignableTo,
|
||||
|
@ -29,9 +28,33 @@ import type {
|
|||
|
||||
const schema = new SchemaFactory("com.example");
|
||||
|
||||
const factory = new TreeFactory({});
|
||||
|
||||
describe("schemaTypes", () => {
|
||||
// Unconstrained
|
||||
{
|
||||
// Input
|
||||
type I1 = InsertableTreeFieldFromImplicitField;
|
||||
type I2 = InsertableTypedNode<TreeNodeSchema>;
|
||||
type I3 = NodeBuilderData<TreeNodeSchema>;
|
||||
|
||||
// TODO: these types should behave contravariantly, but they do not.
|
||||
// When fixed, these checks should pass (with the expected error indicators removed):
|
||||
// @ts-expect-error - incorrect variance
|
||||
type _check1 = requireTrue<areSafelyAssignable<I1, never>>;
|
||||
// @ts-expect-error - incorrect variance
|
||||
type _check2 = requireTrue<areSafelyAssignable<I2, never>>;
|
||||
|
||||
type _check3 = requireTrue<areSafelyAssignable<I3, never>>;
|
||||
|
||||
// Output
|
||||
type N1 = NodeFromSchema<TreeNodeSchema>;
|
||||
type N2 = TreeNodeFromImplicitAllowedTypes;
|
||||
type N3 = TreeFieldFromImplicitField;
|
||||
|
||||
type _check4 = requireTrue<areSafelyAssignable<N1, TreeNode | TreeLeafValue>>;
|
||||
type _check5 = requireTrue<areSafelyAssignable<N2, TreeNode | TreeLeafValue>>;
|
||||
type _check6 = requireTrue<areSafelyAssignable<N3, TreeNode | TreeLeafValue | undefined>>;
|
||||
}
|
||||
|
||||
describe("insertable", () => {
|
||||
it("Lists", () => {
|
||||
const List = schema.array(schema.number);
|
||||
|
|
|
@ -24,6 +24,8 @@ import {
|
|||
type InsertableTreeFieldFromImplicitField,
|
||||
type NodeKind,
|
||||
type TreeFieldFromImplicitField,
|
||||
type TreeLeafValue,
|
||||
type TreeNode,
|
||||
type TreeNodeSchema,
|
||||
} from "../../simple-tree/index.js";
|
||||
import {
|
||||
|
@ -51,7 +53,7 @@ import { CheckoutFlexTreeView, createTreeCheckout } from "../../shared-tree/inde
|
|||
*/
|
||||
export function initNode<
|
||||
TInsertable,
|
||||
TSchema extends TreeNodeSchema<string, NodeKind, unknown, TInsertable>,
|
||||
TSchema extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, TInsertable>,
|
||||
>(
|
||||
schema: TSchema,
|
||||
content: TInsertable,
|
||||
|
@ -85,7 +87,7 @@ export function describeHydration(
|
|||
runBoth: (
|
||||
init: <
|
||||
TInsertable,
|
||||
TSchema extends TreeNodeSchema<string, NodeKind, unknown, TInsertable>,
|
||||
TSchema extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, TInsertable>,
|
||||
>(
|
||||
schema: TSchema,
|
||||
tree: TInsertable,
|
||||
|
|
|
@ -427,6 +427,7 @@ declare type current_as_old_for_Interface_SchemaCompatibilityStatus = requireAss
|
|||
* typeValidation.broken:
|
||||
* "Interface_TreeArrayNode": {"backCompat": false}
|
||||
*/
|
||||
// @ts-expect-error compatibility expected to be broken
|
||||
declare type current_as_old_for_Interface_TreeArrayNode = requireAssignableTo<TypeOnly<current.TreeArrayNode>, TypeOnly<old.TreeArrayNode>>
|
||||
|
||||
/*
|
||||
|
@ -625,6 +626,7 @@ declare type old_as_current_for_TypeAlias_InsertableTreeFieldFromImplicitField =
|
|||
* typeValidation.broken:
|
||||
* "TypeAlias_InsertableTreeFieldFromImplicitField": {"backCompat": false}
|
||||
*/
|
||||
// @ts-expect-error compatibility expected to be broken
|
||||
declare type current_as_old_for_TypeAlias_InsertableTreeFieldFromImplicitField = requireAssignableTo<TypeOnly<current.InsertableTreeFieldFromImplicitField>, TypeOnly<old.InsertableTreeFieldFromImplicitField>>
|
||||
|
||||
/*
|
||||
|
@ -661,6 +663,7 @@ declare type old_as_current_for_TypeAlias_InsertableTreeNodeFromImplicitAllowedT
|
|||
* typeValidation.broken:
|
||||
* "TypeAlias_InsertableTreeNodeFromImplicitAllowedTypes": {"backCompat": false}
|
||||
*/
|
||||
// @ts-expect-error compatibility expected to be broken
|
||||
declare type current_as_old_for_TypeAlias_InsertableTreeNodeFromImplicitAllowedTypes = requireAssignableTo<TypeOnly<current.InsertableTreeNodeFromImplicitAllowedTypes>, TypeOnly<old.InsertableTreeNodeFromImplicitAllowedTypes>>
|
||||
|
||||
/*
|
||||
|
@ -1174,6 +1177,7 @@ declare type old_as_current_for_TypeAlias_NodeFromSchema = requireAssignableTo<T
|
|||
* typeValidation.broken:
|
||||
* "TypeAlias_NodeFromSchema": {"backCompat": false}
|
||||
*/
|
||||
// @ts-expect-error compatibility expected to be broken
|
||||
declare type current_as_old_for_TypeAlias_NodeFromSchema = requireAssignableTo<TypeOnly<current.NodeFromSchema<any>>, TypeOnly<old.NodeFromSchema<any>>>
|
||||
|
||||
/*
|
||||
|
@ -1273,6 +1277,7 @@ declare type old_as_current_for_TypeAlias_TreeFieldFromImplicitField = requireAs
|
|||
* typeValidation.broken:
|
||||
* "TypeAlias_TreeFieldFromImplicitField": {"backCompat": false}
|
||||
*/
|
||||
// @ts-expect-error compatibility expected to be broken
|
||||
declare type current_as_old_for_TypeAlias_TreeFieldFromImplicitField = requireAssignableTo<TypeOnly<current.TreeFieldFromImplicitField>, TypeOnly<old.TreeFieldFromImplicitField>>
|
||||
|
||||
/*
|
||||
|
@ -1309,6 +1314,7 @@ declare type old_as_current_for_TypeAlias_TreeNodeFromImplicitAllowedTypes = req
|
|||
* typeValidation.broken:
|
||||
* "TypeAlias_TreeNodeFromImplicitAllowedTypes": {"backCompat": false}
|
||||
*/
|
||||
// @ts-expect-error compatibility expected to be broken
|
||||
declare type current_as_old_for_TypeAlias_TreeNodeFromImplicitAllowedTypes = requireAssignableTo<TypeOnly<current.TreeNodeFromImplicitAllowedTypes>, TypeOnly<old.TreeNodeFromImplicitAllowedTypes>>
|
||||
|
||||
/*
|
||||
|
|
|
@ -105,6 +105,6 @@ export class SharedTreeBranchManager {
|
|||
export function sharedTreeDiff(obj: Record<string, unknown> | unknown[], newObj: Record<string, unknown> | unknown[], options?: Options, _stack?: (Record<string, unknown> | unknown[])[]): Difference[];
|
||||
|
||||
// @alpha
|
||||
export function sharedTreeTraverse<T = unknown>(jsonObject: TreeMapNode | TreeArrayNode | Record<string, unknown> | unknown[], path: ObjectPath): T | undefined;
|
||||
export function sharedTreeTraverse<T = unknown>(jsonObject: TreeMapNode | TreeArrayNode | Record<string, unknown>, path: ObjectPath): T | undefined;
|
||||
|
||||
```
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import type {
|
||||
ImplicitFieldSchema,
|
||||
TreeArrayNode,
|
||||
TreeMapNode,
|
||||
TreeView,
|
||||
TreeViewConfiguration,
|
||||
} from "@fluidframework/tree";
|
||||
|
@ -38,8 +39,8 @@ export class SharedTreeBranchManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compares the differences between either two objects or a TreeeNode and a plain object.
|
||||
* TODO: Should allow comparing two tree nodes? Should we allowe comparing two plain objects? Or just leave as tree node vs object?
|
||||
* Compares the differences between either two objects or a TreeNode and a plain object.
|
||||
* TODO: Should allow comparing two tree nodes? Should we allow comparing two plain objects? Or just leave as tree node vs object?
|
||||
*/
|
||||
public compare(
|
||||
obj: Record<string, unknown> | TreeArrayNode,
|
||||
|
@ -103,7 +104,7 @@ export class SharedTreeBranchManager {
|
|||
|
||||
console.log("traveling to absolute path from root:", absolutePathToObjectNode);
|
||||
const newBranchTargetNode = sharedTreeTraverse(
|
||||
forkView.root as Record<string, unknown> | unknown[],
|
||||
forkView.root as unknown as TreeMapNode | TreeArrayNode | Record<string, unknown>,
|
||||
absolutePathToObjectNode,
|
||||
) as Record<string, unknown> | TreeArrayNode;
|
||||
|
||||
|
@ -140,7 +141,7 @@ export class SharedTreeBranchManager {
|
|||
const forkBranch = originalBranch.branch();
|
||||
const forkView = forkBranch.viewWith(treeViewConfiguration);
|
||||
const newBranchTargetNode = sharedTreeTraverse(
|
||||
forkView.root as Record<string, unknown> | unknown[],
|
||||
forkView.root as TreeMapNode | TreeArrayNode | Record<string, unknown>,
|
||||
absolutePathToObjectNode,
|
||||
) as Record<string, unknown> | TreeArrayNode;
|
||||
// this.mergeDiffs(differences, newBranchTargetNode);
|
||||
|
@ -183,7 +184,10 @@ export class SharedTreeBranchManager {
|
|||
switch (diff.type) {
|
||||
case "CHANGE":
|
||||
case "CREATE": {
|
||||
targetObject.set(diff.path[diff.path.length - 1] as string, diff.value);
|
||||
// This code is doing non-schema aware editing, which is not a supported feature of this API.
|
||||
// Casting to any is a way to get this unsupported and rather unsafe operation to compile.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
||||
targetObject.set(diff.path[diff.path.length - 1] as string, diff.value as any);
|
||||
return true;
|
||||
}
|
||||
case "REMOVE": {
|
||||
|
@ -201,10 +205,16 @@ export class SharedTreeBranchManager {
|
|||
case "CHANGE":
|
||||
case "CREATE": {
|
||||
if (isTargetIndexValid) {
|
||||
targetObject.insertAt(targetIndex, diff.value);
|
||||
// This code is doing non-schema aware editing, which is not a supported feature of this API.
|
||||
// Casting to any is a way to get this unsupported and rather unsafe operation to compile.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
||||
targetObject.insertAt(targetIndex, diff.value as any);
|
||||
return true;
|
||||
} else {
|
||||
targetObject.insertAtEnd(diff.value);
|
||||
// This code is doing non-schema aware editing, which is not a supported feature of this API.
|
||||
// Casting to any is a way to get this unsupported and rather unsafe operation to compile.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
||||
targetObject.insertAtEnd(diff.value as any);
|
||||
console.warn(
|
||||
"CREATE diff specified an invalid index, defaulting to pushing to end of array",
|
||||
);
|
||||
|
|
|
@ -37,7 +37,7 @@ export function isTreeArrayNode(obj: unknown): obj is TreeArrayNode {
|
|||
* @alpha
|
||||
*/
|
||||
export function sharedTreeTraverse<T = unknown>(
|
||||
jsonObject: TreeMapNode | TreeArrayNode | Record<string, unknown> | unknown[],
|
||||
jsonObject: TreeMapNode | TreeArrayNode | Record<string, unknown>,
|
||||
path: ObjectPath,
|
||||
): T | undefined {
|
||||
let current: unknown = jsonObject;
|
||||
|
|
|
@ -16,6 +16,9 @@ export function adaptEnum<TScope extends string, const TEnum extends Record<stri
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -102,6 +105,14 @@ type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ?
|
|||
// @alpha
|
||||
export function extractPersistedSchema(schema: ImplicitFieldSchema): JsonCompatible;
|
||||
|
||||
// @alpha
|
||||
export type FactoryContent = IFluidHandle | string | number | boolean | null | Iterable<readonly [string, InsertableContent]> | readonly InsertableContent[] | FactoryContentObject;
|
||||
|
||||
// @alpha
|
||||
export type FactoryContentObject = {
|
||||
readonly [P in string]?: InsertableContent;
|
||||
};
|
||||
|
||||
// @public
|
||||
type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<FieldKind.Optional | FieldKind.Identifier> ? true : false;
|
||||
|
||||
|
@ -184,7 +195,7 @@ export enum ForestType {
|
|||
export function getBranch(tree: ITree): TreeBranch;
|
||||
|
||||
// @alpha
|
||||
export function getBranch(view: TreeView<ImplicitFieldSchema>): TreeBranch;
|
||||
export function getBranch<T extends ImplicitFieldSchema>(view: TreeView<T>): TreeBranch;
|
||||
|
||||
// @alpha
|
||||
export function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema;
|
||||
|
@ -461,6 +472,15 @@ export type InitialObjects<T extends ContainerSchema> = {
|
|||
// @public
|
||||
type _InlineTrick = 0;
|
||||
|
||||
// @alpha
|
||||
export type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> = TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : InsertableContent;
|
||||
|
||||
// @alpha
|
||||
export type InsertableContent = Unhydrated<TreeNode> | FactoryContent;
|
||||
|
||||
// @alpha
|
||||
export type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = TSchema extends ImplicitFieldSchema ? InsertableTreeFieldFromImplicitField<TSchema> : InsertableContent | undefined;
|
||||
|
||||
// @public
|
||||
type InsertableObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = FlattenKeys<{
|
||||
readonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<T[Property] & string>;
|
||||
|
@ -476,7 +496,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -485,7 +505,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -530,6 +550,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -695,10 +718,10 @@ export type Myself<M extends IMember = IMember> = M & {
|
|||
};
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @beta @sealed
|
||||
export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
||||
|
@ -709,7 +732,7 @@ export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
|||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -743,6 +766,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -799,17 +826,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -922,7 +949,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -931,7 +958,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -953,7 +980,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @beta @sealed
|
||||
|
@ -993,7 +1020,7 @@ export enum TreeCompressionStrategy {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -1042,13 +1069,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -1064,11 +1097,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -1084,7 +1126,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -1094,6 +1136,15 @@ export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposab
|
|||
upgradeSchema(): void;
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export interface TreeViewAlpha<in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> extends Omit<TreeView<TSchema extends ImplicitFieldSchema ? TSchema : ImplicitFieldSchema>, "root" | "initialize"> {
|
||||
// (undocumented)
|
||||
initialize(content: InsertableField<TSchema>): void;
|
||||
// (undocumented)
|
||||
get root(): TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeLeafValue | TreeNode;
|
||||
set root(newRoot: InsertableField<TSchema>);
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
export class TreeViewConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>> {
|
||||
constructor(props: ITreeViewConfiguration<TSchema>);
|
||||
|
@ -1129,6 +1180,12 @@ export type Unenforced<_DesiredExtendsConstraint> = unknown;
|
|||
// @public
|
||||
export type Unhydrated<T> = T;
|
||||
|
||||
// @alpha
|
||||
export const UnsafeUnknownSchema: unique symbol;
|
||||
|
||||
// @alpha
|
||||
export type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;
|
||||
|
||||
// @public
|
||||
export type ValidateRecursiveSchema<T extends TreeNodeSchemaClass<string, NodeKind.Array | NodeKind.Map | NodeKind.Object, TreeNode & WithType<T["identifier"], T["kind"]>, {
|
||||
[NodeKind.Object]: T["info"] extends RestrictiveStringRecord<ImplicitFieldSchema> ? InsertableObjectFromSchemaRecord<T["info"]> : unknown;
|
||||
|
@ -1149,7 +1206,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
```
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -420,7 +423,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -429,7 +432,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -474,6 +477,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -564,10 +570,10 @@ export type Myself<M extends IMember = IMember> = M & {
|
|||
};
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @beta @sealed
|
||||
export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
||||
|
@ -578,7 +584,7 @@ export interface NodeChangedData<TNode extends TreeNode = TreeNode> {
|
|||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -609,6 +615,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -665,17 +675,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -757,7 +767,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -766,7 +776,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -788,7 +798,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @beta @sealed
|
||||
|
@ -809,7 +819,7 @@ export interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode> extends
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -858,13 +868,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -880,11 +896,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -900,7 +925,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -959,7 +984,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
```
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -520,7 +523,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -529,7 +532,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -576,6 +579,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -870,16 +876,16 @@ export type Myself<M extends IMember = IMember> = M & {
|
|||
};
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -910,6 +916,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -966,17 +976,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -1153,7 +1163,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -1162,7 +1172,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -1184,7 +1194,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
|
@ -1194,7 +1204,7 @@ export interface TreeChangeEvents {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -1243,13 +1253,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -1265,11 +1281,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -1285,7 +1310,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -1344,7 +1369,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
```
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -448,7 +451,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -457,7 +460,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -504,6 +507,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -600,16 +606,16 @@ export type Myself<M extends IMember = IMember> = M & {
|
|||
};
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -640,6 +646,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -696,17 +706,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -792,7 +802,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -801,7 +811,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -823,7 +833,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
|
@ -833,7 +843,7 @@ export interface TreeChangeEvents {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -882,13 +892,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -904,11 +920,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -924,7 +949,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -983,7 +1008,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
```
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// @public
|
||||
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
||||
|
||||
// @public
|
||||
type AllowedTypesUnsafe = readonly LazyItem<TreeNodeSchemaUnsafe>[];
|
||||
|
||||
// @public
|
||||
type ApplyKind<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = {
|
||||
[FieldKind.Required]: T;
|
||||
|
@ -420,7 +423,7 @@ export type InsertableObjectFromSchemaRecordUnsafe<T extends Unenforced<Restrict
|
|||
};
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type InsertableTreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true> : TSchema extends ImplicitAllowedTypes ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, true> : InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema>;
|
||||
|
@ -429,7 +432,7 @@ export type InsertableTreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforce
|
|||
export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? InsertableTypedNode<TSchema> : TSchema extends AllowedTypes ? InsertableTypedNode<FlexListToUnion<TSchema>> : never;
|
||||
|
||||
// @public
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypes ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
export type InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends AllowedTypesUnsafe ? InsertableTypedNodeUnsafe<FlexListToUnion<TSchema>> : InsertableTypedNodeUnsafe<TSchema>;
|
||||
|
||||
// @public
|
||||
export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
|
||||
|
@ -474,6 +477,9 @@ declare namespace InternalTypes {
|
|||
NodeBuilderDataUnsafe,
|
||||
NodeFromSchemaUnsafe,
|
||||
ReadonlyMapInlined,
|
||||
TreeNodeSchemaUnsafe,
|
||||
AllowedTypesUnsafe,
|
||||
TreeNodeSchemaNonClassUnsafe,
|
||||
FlexList,
|
||||
FlexListToUnion,
|
||||
ExtractItemType,
|
||||
|
@ -564,16 +570,16 @@ export type Myself<M extends IMember = IMember> = M & {
|
|||
};
|
||||
|
||||
// @public
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderData<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, unknown, infer TBuild> ? TBuild : never;
|
||||
|
||||
// @public
|
||||
export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchema<string, NodeKind, infer TNode> ? TNode : never;
|
||||
type NodeFromSchemaUnsafe<T extends Unenforced<TreeNodeSchema>> = T extends TreeNodeSchemaUnsafe<string, NodeKind, infer TNode> ? TNode : never;
|
||||
|
||||
// @public
|
||||
export interface NodeInDocumentConstraint {
|
||||
|
@ -604,6 +610,10 @@ type ObjectFromSchemaRecordUnsafe<T extends Unenforced<RestrictiveStringRecord<I
|
|||
// @public
|
||||
export type Off = () => void;
|
||||
|
||||
// @public @sealed
|
||||
export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue> extends ReadonlyArray<T>, Awaited<TreeNode & WithType<string, NodeKind.Array>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
interface ReadonlyMapInlined<K, T extends Unenforced<ImplicitAllowedTypes>> {
|
||||
[Symbol.iterator](): IterableIterator<[K, TreeNodeFromImplicitAllowedTypesUnsafe<T>]>;
|
||||
|
@ -660,17 +670,17 @@ export const rollback: unique symbol;
|
|||
// @public @sealed
|
||||
export interface RunTransaction {
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult, preconditions?: readonly TransactionConstraint[]): TResult;
|
||||
<TNode extends TreeNode, TResult>(node: TNode, transaction: (node: TNode) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<ImplicitFieldSchema>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TView extends TreeView<any>, TResult>(tree: TView, transaction: (root: TView["root"]) => TResult | typeof rollback, preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
|
||||
<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
|
||||
readonly rollback: typeof rollback;
|
||||
}
|
||||
|
||||
|
@ -752,7 +762,7 @@ interface TreeApi extends TreeNodeApi {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public
|
||||
|
@ -761,7 +771,7 @@ export const TreeArrayNode: {
|
|||
};
|
||||
|
||||
// @public @sealed
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode {
|
||||
interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayNode> extends ReadonlyArrayNode<T> {
|
||||
insertAt(index: number, ...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
||||
|
@ -783,7 +793,7 @@ interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, TreeArrayNode> {
|
||||
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>> {
|
||||
}
|
||||
|
||||
// @public @sealed
|
||||
|
@ -793,7 +803,7 @@ export interface TreeChangeEvents {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
|
||||
export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TreeNode | TreeLeafValue | undefined;
|
||||
|
||||
// @public
|
||||
type TreeFieldFromImplicitFieldUnsafe<TSchema extends Unenforced<ImplicitFieldSchema>> = TSchema extends FieldSchemaUnsafe<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypesUnsafe<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypesUnsafe<TSchema> : unknown;
|
||||
|
@ -842,13 +852,19 @@ export interface TreeNodeApi {
|
|||
export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
|
||||
type TreeNodeFromImplicitAllowedTypesUnsafe<TSchema extends Unenforced<ImplicitAllowedTypes>> = TSchema extends TreeNodeSchemaUnsafe ? NodeFromSchemaUnsafe<TSchema> : TSchema extends AllowedTypesUnsafe ? NodeFromSchemaUnsafe<FlexListToUnion<TSchema>> : unknown;
|
||||
|
||||
// @public @sealed
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface TreeNodeSchemaClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// @sealed
|
||||
new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
|
||||
}
|
||||
|
@ -864,11 +880,20 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode = unknown, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
export interface TreeNodeSchemaNonClass<out Name extends string = string, out Kind extends NodeKind = NodeKind, out TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, in TInsertable = never, out ImplicitlyConstructable extends boolean = boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
interface TreeNodeSchemaNonClassUnsafe<out Name extends string, out Kind extends NodeKind, out TNode extends Unenforced<TreeNode | TreeLeafValue>, in TInsertable, out ImplicitlyConstructable extends boolean, out Info = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {
|
||||
// (undocumented)
|
||||
create(data: TInsertable): TNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
type TreeNodeSchemaUnsafe<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends Unenforced<TreeNode | TreeLeafValue> = unknown, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaNonClassUnsafe<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
||||
|
||||
// @public
|
||||
export type TreeObjectNode<T extends RestrictiveStringRecord<ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;
|
||||
|
||||
|
@ -884,7 +909,7 @@ export enum TreeStatus {
|
|||
}
|
||||
|
||||
// @public @sealed
|
||||
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {
|
||||
readonly compatibility: SchemaCompatibilityStatus;
|
||||
readonly events: Listenable<TreeViewEvents>;
|
||||
initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;
|
||||
|
@ -943,7 +968,7 @@ export interface ViewableTree {
|
|||
export interface WithType<out TName extends string = string, out TKind extends NodeKind = NodeKind, out TInfo = unknown> {
|
||||
// @deprecated
|
||||
get [typeNameSymbol](): TName;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, unknown, never, boolean, TInfo>;
|
||||
get [typeSchemaSymbol](): TreeNodeSchemaClass<TName, TKind, TreeNode | TreeLeafValue, never, boolean, TInfo>;
|
||||
}
|
||||
|
||||
```
|
||||
|
|
Загрузка…
Ссылка в новой задаче