diff --git a/api-report/tree2.api.md b/api-report/tree2.api.md index 41a3ada736c0..0c6588898c37 100644 --- a/api-report/tree2.api.md +++ b/api-report/tree2.api.md @@ -1667,9 +1667,9 @@ export function recordDependency(dependent: ObservingDependent | undefined, depe const recursiveStruct: TreeSchema<"Test Recursive Domain.struct", { structFields: { readonly recursive: FieldSchema TreeSchema<"Test Recursive Domain.struct", any>]>; -readonly number: FieldSchema]>; +}>; }; }>; @@ -1776,9 +1776,6 @@ export class SchemaBuilder; - static fieldOptional(...allowedTypes: T): FieldSchema; - static fieldRequired(...allowedTypes: T): FieldSchema; - static fieldSequence(...t: T): FieldSchema; leaf(name: Name, t: T): TreeSchema<`${TScope}.${Name}`, { leafValue: T; }>; @@ -1788,6 +1785,12 @@ export class SchemaBuilder>(name: Name, t: T): TreeSchema<`${TScope}.${Name}`, { mapFields: T; }>; + static optional(allowedTypes: T): FieldSchema>; + readonly optional: typeof SchemaBuilder.optional; + static required(allowedTypes: T): FieldSchema>; + readonly required: typeof SchemaBuilder.required; + static sequence(allowedTypes: T): FieldSchema>; + readonly sequence: typeof SchemaBuilder.sequence; struct>(name: Name, t: T): TreeSchema<`${TScope}.${Name}`, { structFields: { [key in keyof T]: NormalizeField_2; @@ -1813,7 +1816,6 @@ export class SchemaBuilderBase>>(kind: Kind, ...allowedTypes: T): FieldSchema; finalize(): SchemaLibrary; readonly name: string; - // (undocumented) readonly scope: TScope; // (undocumented) protected scoped(name: Name): `${TScope}.${Name}` & TreeSchemaIdentifier; diff --git a/examples/benchmarks/bubblebench/editable-shared-tree/src/schema.ts b/examples/benchmarks/bubblebench/editable-shared-tree/src/schema.ts index 223490ae78bc..1efcf9d3435f 100644 --- a/examples/benchmarks/bubblebench/editable-shared-tree/src/schema.ts +++ b/examples/benchmarks/bubblebench/editable-shared-tree/src/schema.ts @@ -19,10 +19,10 @@ export const bubbleSchema = builder.struct("BubbleBenchAppStateBubble-1.0.0", { export const clientSchema = builder.struct("BubbleBenchAppStateClient-1.0.0", { clientId: leaf.string, color: leaf.string, - bubbles: SchemaBuilder.fieldSequence(bubbleSchema), + bubbles: builder.sequence(bubbleSchema), }); -export const rootAppStateSchema = SchemaBuilder.fieldSequence(clientSchema); +export const rootAppStateSchema = SchemaBuilder.sequence(clientSchema); export const appSchemaData = builder.toDocumentSchema(rootAppStateSchema); diff --git a/examples/data-objects/inventory-app/src/schema.ts b/examples/data-objects/inventory-app/src/schema.ts index 1d9e2101a2d7..ce6614d3546f 100644 --- a/examples/data-objects/inventory-app/src/schema.ts +++ b/examples/data-objects/inventory-app/src/schema.ts @@ -8,15 +8,15 @@ import { SchemaBuilder, TypedField, TypedNode, leaf } from "@fluid-experimental/ const builder = new SchemaBuilder({ scope: "inventory app", libraries: [leaf.library] }); export const part = builder.struct("Contoso:Part-1.0.0", { - name: SchemaBuilder.fieldRequired(leaf.string), - quantity: SchemaBuilder.fieldRequired(leaf.number), + name: leaf.string, + quantity: leaf.number, }); export const inventory = builder.struct("Contoso:Inventory-1.0.0", { - parts: SchemaBuilder.fieldSequence(part), + parts: builder.sequence(part), }); -export const inventoryField = SchemaBuilder.fieldRequired(inventory); +export const inventoryField = SchemaBuilder.required(inventory); export type InventoryField = TypedField; export const schema = builder.toDocumentSchema(inventoryField); diff --git a/examples/data-objects/inventory-app/src/view/counter.tsx b/examples/data-objects/inventory-app/src/view/counter.tsx index 8d591cfd63e9..af8912a572c1 100644 --- a/examples/data-objects/inventory-app/src/view/counter.tsx +++ b/examples/data-objects/inventory-app/src/view/counter.tsx @@ -7,7 +7,7 @@ import { useTreeContext } from "@fluid-experimental/tree-react-api"; import { SchemaBuilder, TypedField, leaf } from "@fluid-experimental/tree2"; import * as React from "react"; -const schema = SchemaBuilder.fieldRequired(leaf.number); +const schema = SchemaBuilder.required(leaf.number); export interface ICounterProps { title: string; diff --git a/experimental/PropertyDDS/packages/property-shared-tree-interop/src/schemaConverter.ts b/experimental/PropertyDDS/packages/property-shared-tree-interop/src/schemaConverter.ts index d91da16cb738..7b633545dc0c 100644 --- a/experimental/PropertyDDS/packages/property-shared-tree-interop/src/schemaConverter.ts +++ b/experimental/PropertyDDS/packages/property-shared-tree-interop/src/schemaConverter.ts @@ -134,7 +134,7 @@ function buildTreeSchema( !fields.has(nodePropertyField), 0x712 /* name collision for nodePropertyField */, ); - fields.set(nodePropertyField, SchemaBuilder.fieldRequired(nodePropertySchema)); + fields.set(nodePropertyField, SchemaBuilder.required(nodePropertySchema)); } const fieldsObject = mapToObject(fields); cache.treeSchema = builder.struct(typeid, fieldsObject); @@ -312,7 +312,7 @@ const builtinBuilder = new SchemaBuilder({ // to be put into one library like this. export const nodePropertySchema = builtinBuilder.map( nodePropertyType, - SchemaBuilder.fieldOptional(Any), + builtinBuilder.optional(Any), ); const builtinLibrary = builtinBuilder.finalize(); diff --git a/experimental/dds/tree2/src/domains/testRecursiveDomain.ts b/experimental/dds/tree2/src/domains/testRecursiveDomain.ts index 582fba280967..2110d0f0c9c9 100644 --- a/experimental/dds/tree2/src/domains/testRecursiveDomain.ts +++ b/experimental/dds/tree2/src/domains/testRecursiveDomain.ts @@ -21,7 +21,7 @@ const builder = new SchemaBuilder({ scope: "Test Recursive Domain", libraries: [ */ export const recursiveStruct = builder.structRecursive("struct", { recursive: FieldSchema.createUnsafe(FieldKinds.optional, [() => recursiveStruct]), - number: SchemaBuilder.fieldRequired(leaf.number), + number: leaf.number, }); // Some related information in https://github.com/microsoft/TypeScript/issues/55758. @@ -35,7 +35,7 @@ fixRecursiveReference(recursiveReference); */ export const recursiveStruct2 = builder.struct("struct2", { recursive: FieldSchema.create(FieldKinds.optional, [recursiveReference]), - number: SchemaBuilder.fieldRequired(leaf.number), + number: leaf.number, }); type _0 = requireFalse>; diff --git a/experimental/dds/tree2/src/feature-libraries/editable-tree-2/lazyTree.ts b/experimental/dds/tree2/src/feature-libraries/editable-tree-2/lazyTree.ts index fb238c095245..fb9afdc7172e 100644 --- a/experimental/dds/tree2/src/feature-libraries/editable-tree-2/lazyTree.ts +++ b/experimental/dds/tree2/src/feature-libraries/editable-tree-2/lazyTree.ts @@ -366,11 +366,11 @@ export class LazyMap // TODO: when appropriate add setter that delegates to field kind specific setter. // public set(key: FieldKey, content: FlexibleFieldContent): void { // const field = this.get(key); - // if (field.is(SchemaBuilder.fieldOptional(...this.schema.mapFields.allowedTypes))) { + // if (field.is(SchemaBuilder.optional(this.schema.mapFields.allowedTypes))) { // field.setContent(content); // } else { // assert( - // field.is(SchemaBuilder.fieldSequence(...this.schema.mapFields.allowedTypes)), + // field.is(SchemaBuilder.sequence(this.schema.mapFields.allowedTypes)), // "unexpected map field kind", // ); // // TODO: fix merge semantics. diff --git a/experimental/dds/tree2/src/feature-libraries/schemaBuilder.ts b/experimental/dds/tree2/src/feature-libraries/schemaBuilder.ts index 7f620417d268..0bf1af45e206 100644 --- a/experimental/dds/tree2/src/feature-libraries/schemaBuilder.ts +++ b/experimental/dds/tree2/src/feature-libraries/schemaBuilder.ts @@ -185,38 +185,75 @@ export class SchemaBuilder< /** * Define a schema for an {@link OptionalField}. - * Shorthand or passing `FieldKinds.optional` to {@link FieldSchema}. + * @remarks + * Shorthand or passing `FieldKinds.optional` to {@link FieldSchema.create}. + * + * This method is also available as an instance method on {@link SchemaBuilder} */ - public static fieldOptional( - ...allowedTypes: T - ): FieldSchema { - return FieldSchema.create(FieldKinds.optional, allowedTypes); + public static optional( + allowedTypes: T, + ): FieldSchema> { + return FieldSchema.create(FieldKinds.optional, normalizeAllowedTypes(allowedTypes)); } /** - * Define a schema for a {@link RequiredField}. - * Shorthand or passing `FieldKinds.required` to {@link FieldSchema}. + * Define a schema for an {@link OptionalField}. + * @remarks + * Shorthand or passing `FieldKinds.optional` to {@link FieldSchema.create}. * - * @privateRemarks - * TODO: Consider adding even shorter syntax where: - * - AllowedTypes can be used as a FieldSchema (Or SchemaBuilder takes a default field kind). - * - A TreeSchema can be used as AllowedTypes in the non-polymorphic case. + * Since this creates a {@link FieldSchema} (and not a {@link TreeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}: + * therefore this method is the same as the static version. */ - public static fieldRequired( - ...allowedTypes: T - ): FieldSchema { - return FieldSchema.create(FieldKinds.required, allowedTypes); + public readonly optional = SchemaBuilder.optional; + + /** + * Define a schema for an {@link RequiredField}. + * @remarks + * Shorthand or passing `FieldKinds.required` to {@link FieldSchema.create}. + * + * This method is also available as an instance method on {@link SchemaBuilder} + */ + public static required( + allowedTypes: T, + ): FieldSchema> { + return FieldSchema.create(FieldKinds.required, normalizeAllowedTypes(allowedTypes)); } /** - * Define a schema for a {@link Sequence} field. + * Define a schema for a {@link RequiredField}. + * @remarks + * Shorthand or passing `FieldKinds.required` to {@link FieldSchema.create}. + * Note that `FieldKinds.required` is the current default field kind, so APIs accepting {@link ImplicitFieldSchema} + * can be passed the `allowedTypes` and will implicitly wrap it up in a {@link RequiredField}. + * + * Since this creates a {@link FieldSchema} (and not a {@link TreeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}: + * therefor this method is the same as the static version. + */ + public readonly required = SchemaBuilder.required; + + /** + * Define a schema for a {@link Sequence}. + * @remarks + * Shorthand or passing `FieldKinds.sequence` to {@link FieldSchema.create}. + * + * This method is also available as an instance method on {@link SchemaBuilder} */ - public static fieldSequence( - ...t: T - ): FieldSchema { - return FieldSchema.create(FieldKinds.sequence, t); + public static sequence( + allowedTypes: T, + ): FieldSchema> { + return FieldSchema.create(FieldKinds.sequence, normalizeAllowedTypes(allowedTypes)); } + /** + * Define a schema for a {@link Sequence}. + * @remarks + * Shorthand or passing `FieldKinds.sequence` to {@link FieldSchema.create}. + * + * Since this creates a {@link FieldSchema} (and not a {@link TreeSchema}), the resulting schema is structurally typed, and not impacted by the {@link SchemaBuilderBase.scope}: + * therefor this method is the same as the static version. + */ + public readonly sequence = SchemaBuilder.sequence; + /** * Produce a TypedSchemaCollection which captures the content added to this builder, any additional SchemaLibraries that were added to it and a root field. * Can be used with schematize to provide schema aware access to document content. diff --git a/experimental/dds/tree2/src/feature-libraries/schemaBuilderBase.ts b/experimental/dds/tree2/src/feature-libraries/schemaBuilderBase.ts index e009cab9477a..ffaf4945d83c 100644 --- a/experimental/dds/tree2/src/feature-libraries/schemaBuilderBase.ts +++ b/experimental/dds/tree2/src/feature-libraries/schemaBuilderBase.ts @@ -34,6 +34,9 @@ export class SchemaBuilderBase = new Map(); private readonly adapters: Adapters = {}; + /** + * Prefix appended to the identifiers of all {@link TreeSchema} produced by this builder. + */ public readonly scope: TScope; /** @@ -42,7 +45,7 @@ export class SchemaBuilderBase { diff --git a/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts index 1783e5b10265..7934c12eeb90 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts @@ -45,9 +45,9 @@ import { polygonTree, testData } from "./uniformChunkTestData"; const builder = new SchemaBuilder({ scope: "chunkTree", libraries: [leaf.library] }); const empty = builder.struct("empty", {}); -const valueField = SchemaBuilder.fieldRequired(leaf.number); +const valueField = SchemaBuilder.required(leaf.number); const structValue = builder.struct("structValue", { x: valueField }); -const optionalField = SchemaBuilder.fieldOptional(leaf.number); +const optionalField = builder.optional(leaf.number); const structOptional = builder.struct("structOptional", { x: optionalField }); const schema = builder.finalize(); diff --git a/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/codec/schemaBasedEncoding.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/codec/schemaBasedEncoding.spec.ts index 680bea60349c..cd43192f6a80 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/codec/schemaBasedEncoding.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/chunked-forest/codec/schemaBasedEncoding.spec.ts @@ -72,7 +72,7 @@ describe("schemaBasedEncoding", () => { return onlyTypeShape; }, }, - SchemaBuilder.fieldRequired(minimal), + SchemaBuilder.required(minimal), cache, ); // This is expected since this case should be optimized to just encode the inner shape. @@ -98,7 +98,7 @@ describe("schemaBasedEncoding", () => { return onlyTypeShape; }, }, - SchemaBuilder.fieldRequired(minimal, leaf.number), + SchemaBuilder.required([minimal, leaf.number]), cache, ); // There are multiple choices about how this case should be optimized, but the current implementation does this: @@ -120,7 +120,7 @@ describe("schemaBasedEncoding", () => { return onlyTypeShape; }, }, - SchemaBuilder.fieldSequence(minimal), + SchemaBuilder.sequence(minimal), cache, ); // There are multiple choices about how this case should be optimized, but the current implementation does this: diff --git a/experimental/dds/tree2/src/test/feature-libraries/contextuallyTyped.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/contextuallyTyped.spec.ts index 399b4e5f7bf7..fc1a6675def6 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/contextuallyTyped.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/contextuallyTyped.spec.ts @@ -94,7 +94,7 @@ describe("ContextuallyTyped", () => { it("applyTypesFromContext omits empty fields", () => { const builder = new SchemaBuilder({ scope: "applyTypesFromContext" }); const numberSchema = builder.leaf("number", ValueSchema.Number); - const numberSequence = SchemaBuilder.fieldSequence(numberSchema); + const numberSequence = SchemaBuilder.sequence(numberSchema); const numbersObject = builder.struct("numbers", { numbers: numberSequence }); const schema = builder.toDocumentSchema(numberSequence); const mapTree = applyTypesFromContext({ schema }, new Set([numbersObject.name]), { @@ -107,7 +107,7 @@ describe("ContextuallyTyped", () => { it("applyTypesFromContext omits empty primary fields", () => { const builder = new SchemaBuilder({ scope: "applyTypesFromContext" }); const numberSchema = builder.leaf("number", ValueSchema.Number); - const numberSequence = SchemaBuilder.fieldSequence(numberSchema); + const numberSequence = SchemaBuilder.sequence(numberSchema); const primaryObject = builder.struct("numbers", { [EmptyKey]: numberSequence }); const schema = builder.toDocumentSchema(numberSequence); const mapTree = applyTypesFromContext({ schema }, new Set([primaryObject.name]), []); @@ -120,12 +120,10 @@ describe("ContextuallyTyped", () => { const builder = new SchemaBuilder({ scope: "cursorFromContextualData" }); const generatedSchema = builder.leaf("generated", ValueSchema.String); const nodeSchema = builder.struct("node", { - foo: SchemaBuilder.fieldRequired(generatedSchema), + foo: generatedSchema, }); - const nodeSchemaData = builder.toDocumentSchema( - SchemaBuilder.fieldOptional(nodeSchema), - ); + const nodeSchemaData = builder.toDocumentSchema(builder.optional(nodeSchema)); const contextualData: ContextuallyTypedNodeDataObject = {}; const generatedField = [ @@ -154,13 +152,11 @@ describe("ContextuallyTyped", () => { const generatedSchema = builder.leaf("generated", ValueSchema.String); const nodeSchema = builder.structRecursive("node", { - foo: SchemaBuilder.fieldRequired(generatedSchema), + foo: builder.required(generatedSchema), child: FieldSchema.createUnsafe(FieldKinds.optional, [() => nodeSchema]), }); - const nodeSchemaData = builder.toDocumentSchema( - SchemaBuilder.fieldOptional(nodeSchema), - ); + const nodeSchemaData = builder.toDocumentSchema(builder.optional(nodeSchema)); const contextualData: ContextuallyTypedNodeDataObject = { child: {} }; const generatedField = [ diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTree.identifier.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTree.identifier.spec.ts index a0b7d1289700..a36ffaa6e45a 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTree.identifier.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTree.identifier.spec.ts @@ -20,15 +20,14 @@ const builder = new SchemaBuilder({ scope: "EditableTree Node Keys", libraries: const stringSchema = builder.leaf("string", ValueSchema.String); const childNodeSchema = builder.struct("ChildNode", { ...nodeKeyField, - name: SchemaBuilder.fieldRequired(stringSchema), + name: stringSchema, }); const parentNodeSchema = builder.struct("ParentNode", { ...nodeKeyField, - children: SchemaBuilder.fieldSequence(childNodeSchema), + children: builder.sequence(childNodeSchema), }); -const rootField = SchemaBuilder.fieldRequired(parentNodeSchema); -const schema = builder.toDocumentSchema(rootField); +const schema = builder.toDocumentSchema(parentNodeSchema); // TODO: this can probably be removed once daesun's stuff goes in function addKey(view: NodeKeyManager, key: LocalNodeKey): { [nodeKeyFieldKey]: StableNodeKey } { diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTreeTypes.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTreeTypes.spec.ts index 8e633677129e..27d3762ab1f5 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTreeTypes.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/editableTreeTypes.spec.ts @@ -5,17 +5,7 @@ import { strict as assert } from "assert"; import { unreachableCase } from "@fluidframework/core-utils"; -import { - jsonArray, - jsonBoolean, - jsonNull, - jsonNumber, - jsonObject, - jsonRoot, - jsonSchema, - jsonString, - leaf, -} from "../../../domains"; +import { jsonArray, jsonNull, jsonObject, jsonRoot, jsonSchema, leaf } from "../../../domains"; import { Sequence, @@ -81,19 +71,19 @@ describe("editableTreeTypes", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [jsonSchema] }); const emptyStruct = builder.struct("empty", {}); - const basicStruct = builder.struct("basicStruct", { foo: SchemaBuilder.fieldOptional(Any) }); - const basicFieldNode = builder.fieldNode("field", SchemaBuilder.fieldOptional(Any)); + const basicStruct = builder.struct("basicStruct", { foo: builder.optional(Any) }); + const basicFieldNode = builder.fieldNode("field", builder.optional(Any)); // TODO: once schema kinds are separated, test struct with EmptyKey. const mixedStruct = builder.struct("mixedStruct", { /** * Test doc comment. */ - leaf: SchemaBuilder.fieldRequired(jsonNumber), - polymorphic: SchemaBuilder.fieldRequired(jsonNumber, jsonString), - optionalLeaf: SchemaBuilder.fieldOptional(jsonNumber), - optionalObject: SchemaBuilder.fieldOptional(jsonObject), - sequence: SchemaBuilder.fieldSequence(jsonNumber), + leaf: leaf.number, + polymorphic: [leaf.number, leaf.string], + optionalLeaf: builder.optional(leaf.number), + optionalObject: SchemaBuilder.optional(jsonObject), + sequence: SchemaBuilder.sequence(leaf.number), }); type Mixed = TypedNode; @@ -105,7 +95,7 @@ describe("editableTreeTypes", () => { /** * Data field. */ - x: SchemaBuilder.fieldRequired(jsonNumber), + x: SchemaBuilder.required(leaf.number), }); type Recursive = TypedNode; @@ -114,24 +104,24 @@ describe("editableTreeTypes", () => { */ function boxingExample(mixed: Mixed): void { const leafNode: number = mixed.leaf; - const leafBoxed: TypedNode = mixed.boxedLeaf.boxedContent; + const leafBoxed: TypedNode = mixed.boxedLeaf.boxedContent; // Current policy is to box polymorphic values so they can be checked for type with `is`. // Note that this still unboxes the value field. - const polymorphic: TypedNode | TypedNode = + const polymorphic: TypedNode | TypedNode = mixed.polymorphic; // Fully boxed, including the value field. - const boxedPolymorphic: RequiredField<[typeof jsonNumber, typeof jsonString]> = + const boxedPolymorphic: RequiredField<[typeof leaf.number, typeof leaf.string]> = mixed.boxedPolymorphic; const optionalLeaf: number | undefined = mixed.optionalLeaf; - const boxedOptionalLeaf: TypedNode | undefined = + const boxedOptionalLeaf: TypedNode | undefined = mixed.boxedOptionalLeaf.boxedContent; - const sequence: Sequence<[typeof jsonNumber]> = mixed.sequence; + const sequence: Sequence<[typeof leaf.number]> = mixed.sequence; const child: number = sequence.at(0); - const childBoxed: TypedNode = sequence.boxedAt(0); + const childBoxed: TypedNode = sequence.boxedAt(0); } function recursiveStructExample(struct: Recursive): void { @@ -151,11 +141,11 @@ describe("editableTreeTypes", () => { function iteratorsExample(mixed: Mixed): void { const unboxedListIteration: number[] = [...mixed.sequence]; - const boxedListIteration: TypedNode[] = [ + const boxedListIteration: TypedNode[] = [ ...mixed.sequence[boxedIterator](), ]; - const optionalNumberField = SchemaBuilder.fieldOptional(jsonNumber); + const optionalNumberField = SchemaBuilder.optional(leaf.number); const mapSchema = undefined as unknown as TreeSchema< "MapIteration", { mapFields: typeof optionalNumberField } @@ -168,7 +158,7 @@ describe("editableTreeTypes", () => { } { - type _1 = requireAssignableTo; + type _1 = requireAssignableTo; type _2a = requireAssignableTo; type _2 = requireAssignableTo; type _3 = requireAssignableTo; @@ -177,10 +167,10 @@ describe("editableTreeTypes", () => { } { - type _1 = requireTrue>; - type _2 = requireFalse>; - type _3 = requireFalse>; - type _4 = requireFalse>; + type _1 = requireTrue>; + type _2 = requireFalse>; + type _3 = requireFalse>; + type _4 = requireFalse>; } { diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyField.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyField.spec.ts index 59dd6691b876..b2126d9dd004 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyField.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyField.spec.ts @@ -83,26 +83,26 @@ describe("LazyField", () => { it("LazyField implementations do not allow edits to detached trees", () => { const builder = new SchemaBuilder({ scope: "lazyTree" }); builder.struct("empty", {}); - const schema = builder.toDocumentSchema(SchemaBuilder.fieldOptional(Any)); + const schema = builder.toDocumentSchema(SchemaBuilder.optional(Any)); const forest = forestWithContent({ schema, initialTree: {} }); const context = getReadonlyContext(forest, schema); const cursor = initializeCursor(context, detachedFieldAnchor); const sequenceField = new LazySequence( context, - SchemaBuilder.fieldSequence(Any), + SchemaBuilder.sequence(Any), cursor, detachedFieldAnchor, ); const optionalField = new LazyOptionalField( context, - SchemaBuilder.fieldOptional(Any), + SchemaBuilder.optional(Any), cursor, detachedFieldAnchor, ); const valueField = new LazyValueField( context, - SchemaBuilder.fieldRequired(Any), + SchemaBuilder.required(Any), cursor, detachedFieldAnchor, ); @@ -137,7 +137,7 @@ describe("LazyField", () => { // #region Tree and schema initialization const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const rootSchema = SchemaBuilder.fieldOptional(builder.struct("struct", {})); + const rootSchema = SchemaBuilder.optional(builder.struct("struct", {})); const schema = builder.toDocumentSchema(rootSchema); // Note: this tree initialization is strictly to enable construction of the lazy field. @@ -150,21 +150,21 @@ describe("LazyField", () => { const anyOptionalField = new TestLazyField( context, - SchemaBuilder.fieldOptional(Any), + SchemaBuilder.optional(Any), cursor, detachedFieldAnchor, ); - assert(anyOptionalField.is(SchemaBuilder.fieldOptional(Any))); + assert(anyOptionalField.is(SchemaBuilder.optional(Any))); - assert(!anyOptionalField.is(SchemaBuilder.fieldOptional())); - assert(!anyOptionalField.is(SchemaBuilder.fieldOptional(leafDomain.boolean))); - assert(!anyOptionalField.is(SchemaBuilder.fieldRequired())); - assert(!anyOptionalField.is(SchemaBuilder.fieldRequired(Any))); - assert(!anyOptionalField.is(SchemaBuilder.fieldRequired(leafDomain.boolean))); - assert(!anyOptionalField.is(SchemaBuilder.fieldSequence())); - assert(!anyOptionalField.is(SchemaBuilder.fieldSequence(Any))); - assert(!anyOptionalField.is(SchemaBuilder.fieldSequence(leafDomain.boolean))); + assert(!anyOptionalField.is(SchemaBuilder.optional([]))); + assert(!anyOptionalField.is(SchemaBuilder.optional(leafDomain.boolean))); + assert(!anyOptionalField.is(SchemaBuilder.required([]))); + assert(!anyOptionalField.is(SchemaBuilder.required(Any))); + assert(!anyOptionalField.is(SchemaBuilder.required(leafDomain.boolean))); + assert(!anyOptionalField.is(SchemaBuilder.sequence([]))); + assert(!anyOptionalField.is(SchemaBuilder.sequence(Any))); + assert(!anyOptionalField.is(SchemaBuilder.sequence(leafDomain.boolean))); // #endregion @@ -172,24 +172,24 @@ describe("LazyField", () => { const booleanOptionalField = new LazyOptionalField( context, - SchemaBuilder.fieldOptional(leafDomain.boolean), + SchemaBuilder.optional(leafDomain.boolean), cursor, detachedFieldAnchor, ); - assert(booleanOptionalField.is(SchemaBuilder.fieldOptional(leafDomain.boolean))); + assert(booleanOptionalField.is(SchemaBuilder.optional(leafDomain.boolean))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldOptional(Any))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldOptional(leafDomain.number))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldRequired())); - assert(!booleanOptionalField.is(SchemaBuilder.fieldRequired(Any))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldRequired(leafDomain.boolean))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldRequired(leafDomain.number))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldSequence())); - assert(!booleanOptionalField.is(SchemaBuilder.fieldSequence(Any))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldSequence(leafDomain.boolean))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldSequence(leafDomain.number))); - assert(!booleanOptionalField.is(SchemaBuilder.fieldOptional())); + assert(!booleanOptionalField.is(SchemaBuilder.optional(Any))); + assert(!booleanOptionalField.is(SchemaBuilder.optional(leafDomain.number))); + assert(!booleanOptionalField.is(SchemaBuilder.required([]))); + assert(!booleanOptionalField.is(SchemaBuilder.required(Any))); + assert(!booleanOptionalField.is(SchemaBuilder.required(leafDomain.boolean))); + assert(!booleanOptionalField.is(SchemaBuilder.required(leafDomain.number))); + assert(!booleanOptionalField.is(SchemaBuilder.sequence([]))); + assert(!booleanOptionalField.is(SchemaBuilder.sequence(Any))); + assert(!booleanOptionalField.is(SchemaBuilder.sequence(leafDomain.boolean))); + assert(!booleanOptionalField.is(SchemaBuilder.sequence(leafDomain.number))); + assert(!booleanOptionalField.is(SchemaBuilder.optional([]))); // #endregion }); @@ -197,9 +197,9 @@ describe("LazyField", () => { it("parent", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); const struct = builder.struct("struct", { - foo: SchemaBuilder.fieldOptional(...leafDomain.primitives), + foo: SchemaBuilder.optional(leafDomain.primitives), }); - const rootSchema = SchemaBuilder.fieldOptional(struct); + const rootSchema = SchemaBuilder.optional(struct); const schema = builder.toDocumentSchema(rootSchema); const { context, cursor } = initializeTreeWithContent({ @@ -225,7 +225,7 @@ describe("LazyField", () => { const leafField = new TestLazyField( context, - SchemaBuilder.fieldOptional(...leafDomain.primitives), + SchemaBuilder.optional(leafDomain.primitives), cursor, { parent: parentAnchor, @@ -238,7 +238,7 @@ describe("LazyField", () => { describe("LazyOptionalField", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const rootSchema = SchemaBuilder.fieldOptional(leafDomain.number); + const rootSchema = SchemaBuilder.optional(leafDomain.number); const schema = builder.toDocumentSchema(rootSchema); describe("Field with value", () => { @@ -312,7 +312,7 @@ describe("LazyOptionalField", () => { describe("LazyValueField", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const rootSchema = SchemaBuilder.fieldRequired(leafDomain.string); + const rootSchema = SchemaBuilder.required(leafDomain.string); const schema = builder.toDocumentSchema(rootSchema); const initialTree = "Hello world"; @@ -351,7 +351,7 @@ describe("LazyValueField", () => { describe("LazySequence", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const rootSchema = SchemaBuilder.fieldSequence(leafDomain.number); + const rootSchema = SchemaBuilder.sequence(leafDomain.number); const schema = builder.toDocumentSchema(rootSchema); const { context, cursor } = initializeTreeWithContent({ diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyTree.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyTree.spec.ts index 595ffec92ddd..e2ee07700413 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyTree.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/lazyTree.spec.ts @@ -125,7 +125,7 @@ describe("LazyTree", () => { it("property names", () => { const builder = new SchemaBuilder({ scope: "lazyTree" }); const emptyStruct = builder.struct("empty", {}); - const testSchema = builder.toDocumentSchema(SchemaBuilder.fieldOptional(emptyStruct)); + const testSchema = builder.toDocumentSchema(SchemaBuilder.optional(emptyStruct)); const { cursor, context } = initializeTreeWithContent({ schema: testSchema, @@ -176,11 +176,11 @@ describe("LazyTree", () => { const fieldNodeOptionalAnySchema = schemaBuilder.fieldNode( "optionalAny", - SchemaBuilder.fieldOptional(Any), + SchemaBuilder.optional(Any), ); const fieldNodeOptionalStringSchema = schemaBuilder.fieldNode( "optionalString", - SchemaBuilder.fieldOptional(leafDomain.string), + SchemaBuilder.optional(leafDomain.string), ); const fieldNodeRequiredAnySchema = schemaBuilder.fieldNode("requiredAny", Any); const fieldNodeRequiredStringSchema = schemaBuilder.fieldNode( @@ -188,10 +188,10 @@ describe("LazyTree", () => { leafDomain.string, ); const structNodeSchema = schemaBuilder.struct("struct", {}); - const mapNodeAnySchema = schemaBuilder.map("mapAny", SchemaBuilder.fieldOptional(Any)); + const mapNodeAnySchema = schemaBuilder.map("mapAny", SchemaBuilder.optional(Any)); const mapNodeStringSchema = schemaBuilder.map( "mapString", - SchemaBuilder.fieldOptional(leafDomain.string), + SchemaBuilder.optional(leafDomain.string), ); const schema = schemaBuilder.toDocumentSchema(fieldNodeOptionalAnySchema); @@ -229,7 +229,7 @@ describe("LazyTree", () => { }); const fieldNodeSchema = schemaBuilder.fieldNode( "field", - SchemaBuilder.fieldOptional(leafDomain.string), + SchemaBuilder.optional(leafDomain.string), ); const schema = schemaBuilder.toDocumentSchema(fieldNodeSchema); @@ -295,7 +295,7 @@ describe("LazyFieldNode", () => { }); const fieldNodeSchema = schemaBuilder.fieldNode( "field", - SchemaBuilder.fieldOptional(leafDomain.string), + SchemaBuilder.optional(leafDomain.string), ); const schema = schemaBuilder.toDocumentSchema(fieldNodeSchema); @@ -317,7 +317,7 @@ describe("LazyFieldNode", () => { it("tryGetField", () => { const field = node.tryGetField(EmptyKey); assert(field !== undefined); - assert(field.is(SchemaBuilder.fieldOptional(leafDomain.string))); + assert(field.is(SchemaBuilder.optional(leafDomain.string))); }); }); @@ -348,10 +348,7 @@ describe("LazyMap", () => { scope: "test", libraries: [leafDomain.library], }); - const mapNodeSchema = schemaBuilder.map( - "mapString", - SchemaBuilder.fieldOptional(leafDomain.string), - ); + const mapNodeSchema = schemaBuilder.map("mapString", SchemaBuilder.optional(leafDomain.string)); const schema = schemaBuilder.toDocumentSchema(mapNodeSchema); const { context, cursor } = initializeTreeWithContent({ @@ -384,10 +381,10 @@ describe("LazyStruct", () => { libraries: [leafDomain.library], }); const structNodeSchema = schemaBuilder.struct("struct", { - foo: SchemaBuilder.fieldOptional(leafDomain.string), - bar: SchemaBuilder.fieldSequence(leafDomain.number), + foo: SchemaBuilder.optional(leafDomain.string), + bar: SchemaBuilder.sequence(leafDomain.number), }); - const schema = schemaBuilder.toDocumentSchema(SchemaBuilder.fieldOptional(Any)); + const schema = schemaBuilder.toDocumentSchema(SchemaBuilder.optional(Any)); const context = contextWithContentReadonly({ schema, diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/structFactory.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/structFactory.spec.ts index 780725ced736..32c2bd938560 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/structFactory.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/structFactory.spec.ts @@ -4,7 +4,6 @@ */ // This file contains several lambdas that do a simple property access -/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable import/no-internal-modules */ import { strict as assert } from "node:assert"; @@ -29,10 +28,10 @@ describe("raw structs", () => { }); const structSchema = builder.struct("struct", { foo: leaf.number, - bar: SchemaBuilder.fieldOptional(leaf.string), - baz: SchemaBuilder.fieldSequence(leaf.boolean), + bar: builder.optional(leaf.string), + baz: builder.sequence(leaf.boolean), }); - const rootFieldSchema = SchemaBuilder.fieldRequired(structSchema); + const rootFieldSchema = SchemaBuilder.required(structSchema); const schema = builder.toDocumentSchema(rootFieldSchema); const context = contextWithContentReadonly({ schema, diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/unboxed.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/unboxed.spec.ts index e79ac3651a58..6229c3b01a96 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/unboxed.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree-2/unboxed.spec.ts @@ -67,7 +67,7 @@ describe("unboxedField", () => { describe("Optional field", () => { it("No value", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldOptional(leafDomain.number); + const fieldSchema = SchemaBuilder.optional(leafDomain.number); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ @@ -80,7 +80,7 @@ describe("unboxedField", () => { it("With value (leaf)", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldOptional(leafDomain.number); + const fieldSchema = SchemaBuilder.optional(leafDomain.number); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ @@ -95,10 +95,10 @@ describe("unboxedField", () => { it("Value field (struct)", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); const structSchema = builder.structRecursive("struct", { - name: SchemaBuilder.fieldRequired(leafDomain.string), + name: SchemaBuilder.required(leafDomain.string), child: FieldSchema.createUnsafe(FieldKinds.optional, [() => structSchema]), }); - const fieldSchema = SchemaBuilder.fieldOptional(structSchema); + const fieldSchema = SchemaBuilder.optional(structSchema); const schema = builder.toDocumentSchema(fieldSchema); const initialTree = { @@ -125,7 +125,7 @@ describe("unboxedField", () => { it("Sequence field", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldSequence(leafDomain.string); + const fieldSchema = SchemaBuilder.sequence(leafDomain.string); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ @@ -140,7 +140,7 @@ describe("unboxedField", () => { it("Schema: Any", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldOptional(Any); + const fieldSchema = SchemaBuilder.optional(Any); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ schema, initialTree: 42 }); @@ -169,8 +169,8 @@ describe("unboxedTree", () => { it("Map", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const mapSchema = builder.map("map", SchemaBuilder.fieldOptional(leafDomain.string)); - const rootSchema = SchemaBuilder.fieldOptional(mapSchema); + const mapSchema = builder.map("map", builder.optional(leafDomain.string)); + const rootSchema = SchemaBuilder.optional(mapSchema); const schema = builder.toDocumentSchema(rootSchema); const { context, cursor } = initializeTreeWithContent({ @@ -191,10 +191,10 @@ describe("unboxedTree", () => { it("Struct", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); const structSchema = builder.structRecursive("struct", { - name: SchemaBuilder.fieldRequired(leafDomain.string), + name: SchemaBuilder.required(leafDomain.string), child: FieldSchema.createUnsafe(FieldKinds.optional, [() => structSchema]), }); - const rootSchema = SchemaBuilder.fieldOptional(structSchema); + const rootSchema = builder.optional(structSchema); const schema = builder.toDocumentSchema(rootSchema); const initialTree = { @@ -220,7 +220,7 @@ describe("unboxedTree", () => { describe("unboxedUnion", () => { it("Any", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldOptional(Any); + const fieldSchema = SchemaBuilder.optional(Any); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ schema, initialTree: 42 }); @@ -234,7 +234,7 @@ describe("unboxedUnion", () => { it("Single type", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldRequired(leafDomain.boolean); + const fieldSchema = SchemaBuilder.required(leafDomain.boolean); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ @@ -248,7 +248,7 @@ describe("unboxedUnion", () => { it("Multi-type", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [leafDomain.library] }); - const fieldSchema = SchemaBuilder.fieldOptional(leafDomain.string, leafDomain.handle); + const fieldSchema = SchemaBuilder.optional([leafDomain.string, leafDomain.handle]); const schema = builder.toDocumentSchema(fieldSchema); const { context, cursor } = initializeTreeWithContent({ diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree/editableTree.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree/editableTree.spec.ts index d0e7b9618e7e..5c454c0c72aa 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree/editableTree.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree/editableTree.spec.ts @@ -347,7 +347,7 @@ describe("editable-tree: read-only", () => { }); it("value roots are unwrapped", () => { - const schemaData = buildTestSchema(SchemaBuilder.fieldRequired(optionalChildSchema)); + const schemaData = buildTestSchema(SchemaBuilder.required(optionalChildSchema)); const forest = setupForest(schemaData, {}); const context = getReadonlyEditableTreeContext(forest, schemaData); assert(isEditableTree(context.unwrappedRoot)); @@ -356,7 +356,7 @@ describe("editable-tree: read-only", () => { }); it("optional roots are unwrapped", () => { - const schemaData = buildTestSchema(SchemaBuilder.fieldOptional(optionalChildSchema)); + const schemaData = buildTestSchema(SchemaBuilder.optional(optionalChildSchema)); // Empty { const forest = setupForest(schemaData, undefined); diff --git a/experimental/dds/tree2/src/test/feature-libraries/editable-tree/mockData.ts b/experimental/dds/tree2/src/test/feature-libraries/editable-tree/mockData.ts index d9e73cd9d922..430034e6c2b6 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/editable-tree/mockData.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/editable-tree/mockData.ts @@ -61,13 +61,13 @@ export const complexPhoneSchema = builder.struct("Test:Phone-1.0.0", { export const phonesSchema = builder.fieldNode( "Test:Phones-1.0.0", - SchemaBuilder.fieldSequence( + builder.sequence([ stringSchema, int32Schema, complexPhoneSchema, // array of arrays simplePhonesSchema, - ), + ]), ); export const addressSchema = builder.struct("Test:Address-1.0.0", { @@ -94,7 +94,7 @@ export const personSchema = builder.struct("Test:Person-1.0.0", { }); export const optionalChildSchema = builder.struct("Test:OptionalChild-1.0.0", { - child: SchemaBuilder.fieldOptional(Any), + child: SchemaBuilder.optional(Any), }); export const arraySchema = builder.fieldNode( diff --git a/experimental/dds/tree2/src/test/feature-libraries/modular-schema/schemaEvolutionExamples.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/modular-schema/schemaEvolutionExamples.spec.ts index 1f309a40f7a1..9b800d0c7f0a 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/modular-schema/schemaEvolutionExamples.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/modular-schema/schemaEvolutionExamples.spec.ts @@ -405,7 +405,7 @@ describe("Schema Evolution Examples", () => { // }); // const viewCollection: SchemaCollection = builder.toDocumentSchema( - // SchemaBuilder.fieldRequired(canvas2), + // SchemaBuilder.required(canvas2), // ); // const textAdapter: TreeAdapter = { input: textIdentifier, output: formattedTextIdentifier }; diff --git a/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.bench.ts b/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.bench.ts index dc9ad969f4ce..057c48edec41 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.bench.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.bench.ts @@ -47,7 +47,7 @@ const nodeWithKeySchema = builder.struct("nodeWithKey", { // ), }); const schemaData = builder.intoDocumentSchema( - SchemaBuilder.fieldSequence(nodeSchema, nodeWithKeySchema), + SchemaBuilder.sequence(nodeSchema, nodeWithKeySchema), ); describe("Node Key Index Benchmarks", () => { diff --git a/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.spec.ts index 4a113d2428f6..22dc1c6d1b0a 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/node-key/nodeKeyIndex.spec.ts @@ -29,7 +29,7 @@ const nodeSchema = builder.structRecursive("node", { ...nodeKeyField, child: FieldSchema.createUnsafe(FieldKinds.optional, [() => nodeSchema]), }); -const nodeSchemaData = builder.toDocumentSchema(SchemaBuilder.fieldOptional(nodeSchema)); +const nodeSchemaData = builder.toDocumentSchema(SchemaBuilder.optional(nodeSchema)); // TODO: this can probably be removed once daesun's stuff goes in function contextualizeKey(view: NodeKeys, key: LocalNodeKey): { [nodeKeyFieldKey]: StableNodeKey } { @@ -207,10 +207,10 @@ describe("Node Key Index", () => { name: "node key index test", libraries: [leaf.library], }); - const nodeSchemaNoKey = builder2.map("node", SchemaBuilder.fieldOptional(Any)); + const nodeSchemaNoKey = builder2.map("node", SchemaBuilder.optional(Any)); const nodeSchemaDataNoKey = builder2.toDocumentSchema( - SchemaBuilder.fieldOptional(nodeSchemaNoKey), + SchemaBuilder.optional(nodeSchemaNoKey), ); assert(!nodeSchemaDataNoKey.treeSchema.has(nodeKeyTreeSchema.name)); @@ -265,7 +265,7 @@ describe("Node Key Index", () => { child: FieldSchema.createUnsafe(FieldKinds.optional, [() => nodeSchemaNoKey]), }); const nodeSchemaDataNoKey = builder2.toDocumentSchema( - SchemaBuilder.fieldOptional(nodeSchemaNoKey), + SchemaBuilder.optional(nodeSchemaNoKey), ); const view = createView(undefined); diff --git a/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaAware.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaAware.spec.ts index 5b2564dfce8a..7008e228f3d4 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaAware.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaAware.spec.ts @@ -60,7 +60,7 @@ import { SimpleNodeDataFor } from "./schemaAwareSimple"; // Check the various ways to refer to child types produce the same results { const numberField1 = FieldSchema.create(required, [numberSchema]); - const numberField2 = SchemaBuilder.fieldRequired(numberSchema); + const numberField2 = SchemaBuilder.required(numberSchema); const numberField3 = FieldSchema.createUnsafe(required, [numberSchema]); type check1_ = requireAssignableTo; type check2_ = requireAssignableTo; @@ -76,15 +76,15 @@ import { SimpleNodeDataFor } from "./schemaAwareSimple"; // Simple object { const simpleObject = builder.struct("simple", { - x: SchemaBuilder.fieldRequired(numberSchema), + x: builder.required(numberSchema), }); } const ballSchema = builder.struct("ball", { // Test schema objects in as well as lazy functions - x: SchemaBuilder.fieldRequired(numberSchema), - y: SchemaBuilder.fieldRequired(() => numberSchema), - size: SchemaBuilder.fieldOptional(numberSchema), + x: numberSchema, + y: [() => numberSchema], + size: builder.optional(numberSchema), }); // Recursive case: @@ -219,7 +219,7 @@ import { SimpleNodeDataFor } from "./schemaAwareSimple"; const builder2 = new SchemaBuilder({ scope: "SchemaAwarePolymorphicTest" }); const bool = builder2.leaf("bool", ValueSchema.Boolean); const str = builder2.leaf("str", ValueSchema.String); - const parentField = SchemaBuilder.fieldRequired(str, bool); + const parentField = SchemaBuilder.required([str, bool]); const parent = builder2.struct("parent", { child: parentField }); type FlexBool = @@ -461,7 +461,7 @@ describe("SchemaAware Editing", () => { it("Use a sequence field", () => { const builder = new SchemaBuilder({ scope: "SchemaAware", libraries: [leaf.library] }); const rootNodeSchema = builder.struct("Test", { - children: SchemaBuilder.fieldSequence(leaf.string), + children: SchemaBuilder.sequence(leaf.string), }); const schema = builder.toDocumentSchema( FieldSchema.create(FieldKinds.required, [rootNodeSchema]), diff --git a/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaComplex.ts b/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaComplex.ts index 05341bb46be6..4e519de11ea3 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaComplex.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaComplex.ts @@ -23,7 +23,7 @@ export const listTaskSchema = builder.structRecursive("ListTask", { type _check = requireAssignableTo; } -export const rootFieldSchema = SchemaBuilder.fieldRequired(stringTaskSchema, listTaskSchema); +export const rootFieldSchema = SchemaBuilder.required([stringTaskSchema, listTaskSchema]); export const appSchemaData = builder.toDocumentSchema(rootFieldSchema); diff --git a/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaSimple.ts b/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaSimple.ts index 24bc709344d4..c4e4e666e52a 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaSimple.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/schema-aware/schemaSimple.ts @@ -15,7 +15,7 @@ export const pointSchema = builder.struct("point", { y: numberSchema, }); -export const appSchemaData = builder.toDocumentSchema(SchemaBuilder.fieldSequence(pointSchema)); +export const appSchemaData = builder.toDocumentSchema(builder.sequence(pointSchema)); // Schema aware types export type Number = SchemaAware.TypedNode; diff --git a/experimental/dds/tree2/src/test/feature-libraries/schemaBuilder.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/schemaBuilder.spec.ts index 682eafae3200..a20728be07ea 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/schemaBuilder.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/schemaBuilder.spec.ts @@ -91,7 +91,7 @@ describe("SchemaBuilder", () => { it("Simple", () => { const schemaBuilder = new SchemaBuilder({ scope: "test" }); const leafSchema = schemaBuilder.leaf("leaf", ValueSchema.Boolean); - const schema = schemaBuilder.toDocumentSchema(SchemaBuilder.fieldOptional(leafSchema)); + const schema = schemaBuilder.toDocumentSchema(SchemaBuilder.optional(leafSchema)); assert.equal(schema.treeSchema.size, 1); // "leaf" assert.equal(schema.treeSchema.get(brand("test.leaf")), leafSchema); diff --git a/experimental/dds/tree2/src/test/feature-libraries/schemaIndex.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/schemaIndex.spec.ts index 032eef4f06ae..827ec23d9a7d 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/schemaIndex.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/schemaIndex.spec.ts @@ -23,7 +23,7 @@ describe("SchemaIndex", () => { const data: SchemaData = new SchemaBuilder({ scope: "roundtrip", libraries: [jsonSchema], - }).toDocumentSchema(SchemaBuilder.fieldOptional(...jsonRoot)); + }).toDocumentSchema(SchemaBuilder.optional(jsonRoot)); const s = codec.encode(data); const parsed = codec.decode(s); const s2 = codec.encode(parsed); diff --git a/experimental/dds/tree2/src/test/feature-libraries/typedSchema/example.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/typedSchema/example.spec.ts index d8686df2bede..e809ede1952e 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/typedSchema/example.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/typedSchema/example.spec.ts @@ -28,7 +28,7 @@ const diagramSchema = builder.structRecursive("Diagram", { children: FieldSchema.createUnsafe(FieldKinds.sequence, [() => diagramSchema, ballSchema]), }); -const rootField = SchemaBuilder.fieldOptional(diagramSchema); +const rootField = builder.optional(diagramSchema); // Collect the schema together. const schemaData = builder.toDocumentSchema(rootField); diff --git a/experimental/dds/tree2/src/test/feature-libraries/typedSchema/typedTreeSchema.spec.ts b/experimental/dds/tree2/src/test/feature-libraries/typedSchema/typedTreeSchema.spec.ts index f9e5e6a7b9b4..a0404e2fa05e 100644 --- a/experimental/dds/tree2/src/test/feature-libraries/typedSchema/typedTreeSchema.spec.ts +++ b/experimental/dds/tree2/src/test/feature-libraries/typedSchema/typedTreeSchema.spec.ts @@ -24,8 +24,8 @@ import { FieldKinds, SchemaBuilder } from "../../../feature-libraries"; describe("typedTreeSchema", () => { const builder = new SchemaBuilder({ scope: "test", libraries: [jsonSchema] }); const emptyStruct = builder.struct("empty", {}); - const basicStruct = builder.struct("basicStruct", { foo: SchemaBuilder.fieldOptional(Any) }); - const basicFieldNode = builder.fieldNode("field", SchemaBuilder.fieldOptional(Any)); + const basicStruct = builder.struct("basicStruct", { foo: builder.optional(Any) }); + const basicFieldNode = builder.fieldNode("field", builder.optional(Any)); // TODO: once schema kinds are separated, test struct with EmptyKey. const recursiveStruct = builder.structRecursive("recursiveStruct", { diff --git a/experimental/dds/tree2/src/test/forestTestSuite.ts b/experimental/dds/tree2/src/test/forestTestSuite.ts index 4f7a894b5923..1f758622fd22 100644 --- a/experimental/dds/tree2/src/test/forestTestSuite.ts +++ b/experimental/dds/tree2/src/test/forestTestSuite.ts @@ -69,7 +69,7 @@ export interface ForestTestConfiguration { const jsonDocumentSchema = new SchemaBuilder({ scope: "jsonDocumentSchema", libraries: [jsonSchema], -}).toDocumentSchema(SchemaBuilder.fieldSequence(...jsonRoot)); +}).toDocumentSchema(SchemaBuilder.sequence(jsonRoot)); const detachId = { minor: 42 }; @@ -854,10 +854,10 @@ export function testForest(config: ForestTestConfiguration): void { const builder = new SchemaBuilder({ scope: "moving" }); const leaf = builder.leaf("leaf", ValueSchema.Number); const root = builder.struct("root", { - x: SchemaBuilder.fieldSequence(leaf), - y: SchemaBuilder.fieldSequence(leaf), + x: SchemaBuilder.sequence(leaf), + y: SchemaBuilder.sequence(leaf), }); - const schema = builder.toDocumentSchema(SchemaBuilder.fieldOptional(root)); + const schema = builder.toDocumentSchema(builder.optional(root)); const forest = factory(new InMemoryStoredSchemaRepository(schema)); initializeForest(forest, [ diff --git a/experimental/dds/tree2/src/test/shared-tree-core/sharedTreeCore.spec.ts b/experimental/dds/tree2/src/test/shared-tree-core/sharedTreeCore.spec.ts index 02f99a4baed8..2d5f49ae6f41 100644 --- a/experimental/dds/tree2/src/test/shared-tree-core/sharedTreeCore.spec.ts +++ b/experimental/dds/tree2/src/test/shared-tree-core/sharedTreeCore.spec.ts @@ -334,7 +334,7 @@ describe("SharedTreeCore", () => { const node = b.structRecursive("test node", { child: FieldSchema.createUnsafe(FieldKinds.optional, [() => node, leaf.number]), }); - const schema = b.toDocumentSchema(SchemaBuilder.fieldOptional(node)); + const schema = b.toDocumentSchema(b.optional(node)); const tree2 = await factory.load( dataStoreRuntime2, diff --git a/experimental/dds/tree2/src/test/shared-tree/opSize.bench.ts b/experimental/dds/tree2/src/test/shared-tree/opSize.bench.ts index ff8f44112396..e26fb988fd03 100644 --- a/experimental/dds/tree2/src/test/shared-tree/opSize.bench.ts +++ b/experimental/dds/tree2/src/test/shared-tree/opSize.bench.ts @@ -36,15 +36,13 @@ const builder = new SchemaBuilder({ scope: "opSize" }); const stringSchema = builder.leaf("String", ValueSchema.String); const childSchema = builder.struct("Test:Opsize-Bench-Child", { - data: SchemaBuilder.fieldRequired(stringSchema), + data: stringSchema, }); const parentSchema = builder.struct("Test:Opsize-Bench-Root", { - children: SchemaBuilder.fieldSequence(childSchema), + children: builder.sequence(childSchema), }); -const rootSchema = SchemaBuilder.fieldRequired(parentSchema); - -const fullSchemaData = builder.toDocumentSchema(rootSchema); +const fullSchemaData = builder.toDocumentSchema(parentSchema); const initialTestJsonTree = { type: parentSchema.name, diff --git a/experimental/dds/tree2/src/test/shared-tree/schematizeTree.spec.ts b/experimental/dds/tree2/src/test/shared-tree/schematizeTree.spec.ts index 2c9dc4f8b890..1bbc4873e228 100644 --- a/experimental/dds/tree2/src/test/shared-tree/schematizeTree.spec.ts +++ b/experimental/dds/tree2/src/test/shared-tree/schematizeTree.spec.ts @@ -29,18 +29,18 @@ import { createEmitter } from "../../events"; const builder = new SchemaBuilder({ scope: "test", name: "Schematize Tree Tests" }); const root = builder.leaf("root", ValueSchema.Number); -const schema = builder.toDocumentSchema(SchemaBuilder.fieldOptional(root)); +const schema = builder.toDocumentSchema(SchemaBuilder.optional(root)); const builderGeneralized = new SchemaBuilder({ scope: "test", name: "Schematize Tree Tests Generalized", }); const rootGeneralized = builderGeneralized.leaf("root", ValueSchema.Number); -const schemaGeneralized = builderGeneralized.toDocumentSchema(SchemaBuilder.fieldOptional(Any)); +const schemaGeneralized = builderGeneralized.toDocumentSchema(SchemaBuilder.optional(Any)); const builderValue = new SchemaBuilder({ scope: "test", name: "Schematize Tree Tests2" }); const root2 = builderValue.leaf("root", ValueSchema.Number); -const schemaValueRoot = builderValue.toDocumentSchema(SchemaBuilder.fieldRequired(Any)); +const schemaValueRoot = builderValue.toDocumentSchema(SchemaBuilder.required(Any)); const emptySchema = new SchemaBuilder({ scope: "Empty", diff --git a/experimental/dds/tree2/src/test/shared-tree/sharedTree.spec.ts b/experimental/dds/tree2/src/test/shared-tree/sharedTree.spec.ts index ec35229144f2..7c6f36306ce0 100644 --- a/experimental/dds/tree2/src/test/shared-tree/sharedTree.spec.ts +++ b/experimental/dds/tree2/src/test/shared-tree/sharedTree.spec.ts @@ -540,7 +540,7 @@ describe("SharedTree", () => { const schema = new SchemaBuilder({ scope: "optional", libraries: [jsonSchema], - }).toDocumentSchema(SchemaBuilder.fieldOptional(jsonNumber)); + }).toDocumentSchema(SchemaBuilder.optional(leaf.number)); const config: InitializeAndSchematizeConfiguration = { schema, initialTree: value, @@ -1069,7 +1069,7 @@ describe("SharedTree", () => { const treeSchema = builder.struct("root", { x: numberSchema, }); - const schema = builder.toDocumentSchema(SchemaBuilder.fieldOptional(Any)); + const schema = builder.toDocumentSchema(builder.optional(Any)); it("triggers events for local and subtree changes", () => { const view = viewWithContent({ @@ -1885,12 +1885,12 @@ describe("SharedTree", () => { it("Anchor Stability fails when root node is deleted", async () => { const provider = await TestTreeProvider.create(1, SummarizeType.onDemand); - const rootFieldSchema = SchemaBuilder.fieldRequired(Any); + const rootFieldSchema = SchemaBuilder.required(Any); const testSchemaBuilder = new SchemaBuilder({ scope: "testSchema" }); const numberSchema = testSchemaBuilder.leaf("Number", ValueSchema.Number); const rootNodeSchema = testSchemaBuilder.structRecursive("Node", { - foo: SchemaBuilder.fieldSequence(numberSchema), - foo2: SchemaBuilder.fieldSequence(numberSchema), + foo: SchemaBuilder.sequence(numberSchema), + foo2: SchemaBuilder.sequence(numberSchema), }); const testSchema = testSchemaBuilder.toDocumentSchema(rootFieldSchema); diff --git a/experimental/dds/tree2/src/test/shared-tree/sharedTreeView.spec.ts b/experimental/dds/tree2/src/test/shared-tree/sharedTreeView.spec.ts index 470c564b1bf2..8b8784ee7392 100644 --- a/experimental/dds/tree2/src/test/shared-tree/sharedTreeView.spec.ts +++ b/experimental/dds/tree2/src/test/shared-tree/sharedTreeView.spec.ts @@ -9,14 +9,14 @@ import { ValueSchema, AllowedUpdateType, storedEmptyFieldSchema } from "../../co const builder = new SchemaBuilder({ scope: "test", name: "Schematize Tree Tests" }); const root = builder.leaf("root", ValueSchema.Number); -const schema = builder.toDocumentSchema(SchemaBuilder.fieldOptional(root)); +const schema = builder.toDocumentSchema(SchemaBuilder.optional(root)); const builderGeneralized = new SchemaBuilder({ scope: "test", name: "Schematize Tree Tests Generalized", }); const rootGeneralized = builderGeneralized.leaf("root", ValueSchema.Number); -const schemaGeneralized = builderGeneralized.toDocumentSchema(SchemaBuilder.fieldOptional(Any)); +const schemaGeneralized = builderGeneralized.toDocumentSchema(SchemaBuilder.optional(Any)); describe("sharedTreeView", () => { describe("schematize", () => { diff --git a/experimental/dds/tree2/src/test/snapshots/testTrees.ts b/experimental/dds/tree2/src/test/snapshots/testTrees.ts index 70219473e604..73d7560feeb5 100644 --- a/experimental/dds/tree2/src/test/snapshots/testTrees.ts +++ b/experimental/dds/tree2/src/test/snapshots/testTrees.ts @@ -35,8 +35,8 @@ import { leaf } from "../../domains"; const factory = new SharedTreeFactory({ jsonValidator: typeboxValidator }); const builder = new SchemaBuilder({ scope: "test trees", libraries: [leaf.library] }); -const rootNodeSchema = builder.map("TestInner", SchemaBuilder.fieldSequence(Any)); -const testSchema = builder.toDocumentSchema(SchemaBuilder.fieldSequence(Any)); +const rootNodeSchema = builder.map("TestInner", SchemaBuilder.sequence(Any)); +const testSchema = builder.toDocumentSchema(SchemaBuilder.sequence(Any)); function generateCompleteTree( fields: FieldKey[], @@ -275,7 +275,7 @@ export function generateTestTrees() { libraries: [leaf.library], }); const docSchema = innerBuilder.toDocumentSchema( - SchemaBuilder.fieldOptional(leaf.handle), + SchemaBuilder.optional(leaf.handle), ); const config = { @@ -308,7 +308,7 @@ export function generateTestTrees() { FieldSchema.createUnsafe(FieldKinds.sequence, [() => seqMapSchema]), ); const docSchema = innerBuilder.toDocumentSchema( - SchemaBuilder.fieldSequence(seqMapSchema), + SchemaBuilder.sequence(seqMapSchema), ); const config = { diff --git a/experimental/dds/tree2/src/test/testTrees.ts b/experimental/dds/tree2/src/test/testTrees.ts index fb7b6051c7ee..aa7fe4e919a9 100644 --- a/experimental/dds/tree2/src/test/testTrees.ts +++ b/experimental/dds/tree2/src/test/testTrees.ts @@ -40,7 +40,7 @@ function testTree( rootNode: T, data: SchemaAware.AllowedTypesToTypedTrees, ): TestTree { - const fieldSchema = SchemaBuilder.fieldRequired(rootNode); + const fieldSchema = FieldSchema.create(FieldKinds.required, [rootNode]); return testField(name, schemaData, fieldSchema, data); } @@ -105,27 +105,27 @@ export const hasAnyValueField = builder.struct("hasAnyValueField", { field: Any, }); export const hasOptionalField = builder.struct("hasOptionalField", { - field: SchemaBuilder.fieldOptional(leaf.number), + field: builder.optional(leaf.number), }); export const allTheFields = builder.struct("allTheFields", { - optional: SchemaBuilder.fieldOptional(leaf.number), + optional: builder.optional(leaf.number), valueField: leaf.number, - sequence: SchemaBuilder.fieldSequence(leaf.number), + sequence: builder.sequence(leaf.number), }); export const anyFields = builder.struct("anyFields", { - optional: SchemaBuilder.fieldOptional(Any), + optional: builder.optional(Any), valueField: Any, - sequence: SchemaBuilder.fieldSequence(Any), + sequence: builder.sequence(Any), }); -export const numericMap = builder.map("numericMap", SchemaBuilder.fieldOptional(leaf.number)); +export const numericMap = builder.map("numericMap", builder.optional(leaf.number)); type NumericMapData = SchemaAware.AllowedTypesToTypedTrees< SchemaAware.ApiMode.Flexible, [typeof numericMap] >; -export const anyMap = builder.map("anyMap", SchemaBuilder.fieldSequence(Any)); +export const anyMap = builder.map("anyMap", builder.sequence(Any)); export const recursiveType = builder.structRecursive("recursiveType", { field: FieldSchema.createUnsafe(FieldKinds.optional, [() => recursiveType]), @@ -134,10 +134,10 @@ export const recursiveType = builder.structRecursive("recursiveType", { export const library = builder.finalize(); export const testTrees: readonly TestTree[] = [ - testField("empty", library, SchemaBuilder.fieldOptional(), undefined), + testField("empty", library, SchemaBuilder.optional([]), undefined), testTree("minimal", library, minimal, {}), testTree("numeric", library, leaf.number, 5), - testField("numericSequence", library, SchemaBuilder.fieldSequence(leaf.number), [1, 2, 3]), + testField("numericSequence", library, SchemaBuilder.sequence(leaf.number), [1, 2, 3]), testTree("true boolean", library, leaf.boolean, { [typeNameSymbol]: leaf.boolean.name, [valueSymbol]: true, diff --git a/experimental/dds/tree2/src/test/typed-tree/typedTree.spec.ts b/experimental/dds/tree2/src/test/typed-tree/typedTree.spec.ts index bb9e28e98b8e..b6a58f78ffff 100644 --- a/experimental/dds/tree2/src/test/typed-tree/typedTree.spec.ts +++ b/experimental/dds/tree2/src/test/typed-tree/typedTree.spec.ts @@ -14,7 +14,7 @@ import { leaf } from "../../domains"; describe("TypedTree", () => { it("editable-tree-2-end-to-end", () => { const builder = new SchemaBuilder({ scope: "e2e", libraries: [leaf.library] }); - const schema = builder.toDocumentSchema(SchemaBuilder.fieldRequired(leaf.number)); + const schema = builder.toDocumentSchema(leaf.number); const factory = new TypedTreeFactory({ jsonValidator: typeboxValidator, forest: ForestType.Reference, diff --git a/experimental/dds/tree2/src/test/utils.ts b/experimental/dds/tree2/src/test/utils.ts index bfd8ea639947..ef59d34812f0 100644 --- a/experimental/dds/tree2/src/test/utils.ts +++ b/experimental/dds/tree2/src/test/utils.ts @@ -614,7 +614,7 @@ export function treeWithContent( ); } -const jsonSequenceRootField = SchemaBuilder.fieldSequence(...jsonRoot); +const jsonSequenceRootField = SchemaBuilder.sequence(jsonRoot); export const jsonSequenceRootSchema = new SchemaBuilder({ scope: "JsonSequenceRoot", libraries: [jsonSchema], @@ -894,7 +894,7 @@ export const wrongSchema = new SchemaBuilder({ lint: { rejectEmpty: false, }, -}).toDocumentSchema(SchemaBuilder.fieldSequence(Any)); +}).toDocumentSchema(SchemaBuilder.sequence(Any)); /** * Schematize config Schema which is not correct. diff --git a/packages/tools/devtools/devtools-core/src/test/DefaultVisualizers.test.ts b/packages/tools/devtools/devtools-core/src/test/DefaultVisualizers.test.ts index 87fac87627e3..fd0383dbe8ba 100644 --- a/packages/tools/devtools/devtools-core/src/test/DefaultVisualizers.test.ts +++ b/packages/tools/devtools/devtools-core/src/test/DefaultVisualizers.test.ts @@ -410,20 +410,20 @@ describe("DefaultVisualizers unit tests", () => { const sharedTree = factory.create(new MockFluidDataStoreRuntime(), "test"); const leafSchema = builder.struct("leaf-item", { - leafField: SchemaBuilder.fieldRequired(leaf.boolean, leaf.handle, leaf.string), + leafField: [leaf.boolean, leaf.handle, leaf.string], }); const childSchema = builder.struct("child-item", { - childField: SchemaBuilder.fieldRequired(leaf.string, leaf.boolean), - childData: SchemaBuilder.fieldOptional(leafSchema), + childField: [leaf.string, leaf.boolean], + childData: builder.optional(leafSchema), }); const rootNodeSchema = builder.struct("root-item", { - childrenOne: SchemaBuilder.fieldSequence(childSchema), - childrenTwo: SchemaBuilder.fieldRequired(leaf.number), + childrenOne: builder.sequence(childSchema), + childrenTwo: leaf.number, }); - const schema = builder.toDocumentSchema(SchemaBuilder.fieldRequired(rootNodeSchema)); + const schema = builder.toDocumentSchema(rootNodeSchema); sharedTree.schematize({ schema, diff --git a/packages/tools/devtools/devtools-example/src/FluidObject.ts b/packages/tools/devtools/devtools-example/src/FluidObject.ts index f3d6f18def78..e32fb09b08ee 100644 --- a/packages/tools/devtools/devtools-example/src/FluidObject.ts +++ b/packages/tools/devtools/devtools-example/src/FluidObject.ts @@ -223,20 +223,20 @@ export class AppData extends DataObject { // TODO: Maybe include example handle const leafSchema = builder.struct("leaf-item", { - leafField: SchemaBuilder.fieldRequired(leaf.boolean, leaf.handle, leaf.string), + leafField: [leaf.boolean, leaf.handle, leaf.string], }); const childSchema = builder.struct("child-item", { - childField: SchemaBuilder.fieldRequired(leaf.string, leaf.boolean), - childData: SchemaBuilder.fieldOptional(leafSchema), + childField: [leaf.string, leaf.boolean], + childData: builder.optional(leafSchema), }); const rootNodeSchema = builder.struct("root-item", { - childrenOne: SchemaBuilder.fieldSequence(childSchema), - childrenTwo: SchemaBuilder.fieldRequired(leaf.number), + childrenOne: builder.sequence(childSchema), + childrenTwo: leaf.number, }); - const schema = builder.toDocumentSchema(SchemaBuilder.fieldRequired(rootNodeSchema)); + const schema = builder.toDocumentSchema(rootNodeSchema); sharedTree.schematize({ schema,