/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { valueSymbol, FieldKinds, typeNameSymbol, FlexFieldSchema, } from "../../../feature-libraries/index.js";
import { leaf, SchemaBuilder } from "../../../domains/index.js";
// Test UnbrandedName
{
}
{
    // Aliases for conciseness
    const { optional, required, sequence } = FieldKinds;
    // Example Schema:
    const builder = new SchemaBuilder({ scope: "SchemaAwareTests" });
    // Declare a simple type which just holds a number.
    const numberSchema = leaf.number;
    // Check the various ways to refer to child types produce the same results
    {
        const numberField1 = FlexFieldSchema.create(required, [numberSchema]);
        const numberField2 = SchemaBuilder.required(numberSchema);
        const numberField3 = FlexFieldSchema.createUnsafe(required, [numberSchema]);
        const numberFieldLazy = FlexFieldSchema.create(required, [() => numberSchema]);
    }
    // Simple object
    {
        const simpleObject = builder.object("simple", {
            x: builder.required(numberSchema),
        });
    }
    const ballSchema = builder.object("ball", {
        // Test schema objects in as well as lazy functions
        x: numberSchema,
        y: [() => numberSchema],
        size: builder.optional(numberSchema),
    });
    // Recursive case:
    const boxSchema = builder.objectRecursive("box", {
        children: FlexFieldSchema.createUnsafe(sequence, [ballSchema, () => boxSchema]),
    });
    {
    }
    const schemaData = builder.intoLibrary();
    {
    }
    const n1 = 5;
    const b1 = { x: 1, y: 2, size: 10 };
    const b1x = { x: 1, y: 2, size: undefined }; // TODO: restore ability to omit optional fields.
    const b2 = { [typeNameSymbol]: ballSchema.name, x: 1, y: 2, size: undefined };
    const b4 = {
        [typeNameSymbol]: "SchemaAwareTests.ball",
        x: 1,
        y: 5,
        size: undefined,
    };
    const b6 = { [typeNameSymbol]: ballSchema.name, x: 1, y: 5, size: undefined };
    // This is type safe, so we can only access fields that are in the schema.
    // @ts-expect-error This is an error since it accesses an invalid field.
    const b5 = { [typeNameSymbol]: ballSchema.name, x: 1, z: 5 };
    // @ts-expect-error Missing required field
    const b7 = { [typeNameSymbol]: ballSchema.name, x: 1 };
    {
    }
    // @ts-expect-error Wrong type
    const nError1 = { [typeNameSymbol]: ballSchema.name, [valueSymbol]: 5 };
    {
    }
    // Test terminal cases:
    {
    }
    // Test non recursive cases:
    {
    }
    // Test polymorphic cases:
    {
        const builder2 = new SchemaBuilder({ scope: "SchemaAwarePolymorphicTest" });
        const bool = leaf.boolean;
        const str = leaf.string;
        const parentField = SchemaBuilder.required([str, bool]);
        const parent = builder2.object("parent", { child: parentField });
        // Check child handling
        {
        }
        {
        }
    }
    // Test simple recursive cases:
    {
        const builder2 = new SchemaBuilder({ scope: "SchemaAwareRecursiveTest" });
        const rec = builder2.objectRecursive("rec", {
            x: FlexFieldSchema.createUnsafe(optional, [() => rec]),
        });
        {
        }
        // Confirm schema's recursive type is correct.
        {
        }
        // Check generated schema aware types
        {
            // Check Simple's field type unit tests
            {
            }
        }
    }
    // Test recursive cases:
    {
        // Check child handling
        {
            {
                {
                }
            }
        }
        {
            const child = {
                [typeNameSymbol]: boxSchema.name,
                children: [],
            };
            const parent = {
                [typeNameSymbol]: boxSchema.name,
                children: [
                    child,
                    {
                        [typeNameSymbol]: ballSchema.name,
                        x: 1,
                        y: 2,
                        size: undefined,
                    },
                ],
            };
        }
    }
}
//# sourceMappingURL=schemaAware.spec.js.map