"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaFactoryAlpha = void 0;
const index_js_1 = require("../node-kinds/index.js");
const schemaFactory_js_1 = require("./schemaFactory.js");
/**
 * {@link SchemaFactory} with additional alpha APIs.
 *
 * @alpha
 * @privateRemarks
 *
 * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.
 * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.
 */
class SchemaFactoryAlpha extends schemaFactory_js_1.SchemaFactory {
    constructor() {
        super(...arguments);
        /**
         * {@inheritDoc SchemaStatics.leaves}
         */
        this.leaves = schemaFactory_js_1.schemaStatics.leaves;
        /**
         * {@inheritDoc SchemaStatics.optional}
         */
        this.optional = schemaFactory_js_1.schemaStatics.optional;
        /**
         * {@inheritDoc SchemaStatics.required}
         */
        this.required = schemaFactory_js_1.schemaStatics.required;
        /**
         * {@inheritDoc SchemaStatics.optionalRecursive}
         */
        this.optionalRecursive = schemaFactory_js_1.schemaStatics.optionalRecursive;
        /**
         * {@inheritDoc SchemaStatics.requiredRecursive}
         */
        this.requiredRecursive = schemaFactory_js_1.schemaStatics.requiredRecursive;
    }
    scoped2(name) {
        return (this.scope === undefined ? `${name}` : `${this.scope}.${name}`);
    }
    /**
     * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
     *
     * @param name - Unique identifier for this schema within this factory's scope.
     * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
     * @param options - Additional options for the schema.
     */
    objectAlpha(name, fields, options) {
        return (0, index_js_1.objectSchema)(this.scoped2(name), fields, true, options?.allowUnknownOptionalFields ??
            schemaFactory_js_1.defaultSchemaFactoryObjectOptions.allowUnknownOptionalFields, options?.metadata, options?.persistedMetadata);
    }
    /**
     * {@inheritdoc SchemaFactory.objectRecursive}
     */
    objectRecursive(name, t, options) {
        return this.objectAlpha(name, t, options);
    }
    /**
     * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.
     *
     * @param name - Unique identifier for this schema within this factory's scope.
     * @param allowedTypes - The types that may appear as values in the map.
     * @param options - Additional options for the schema.
     *
     * @example
     * ```typescript
     * class NamedMap extends factory.map("name", factory.number, {
     * 	metadata: { description: "A map of numbers" }
     * }) {}
     * ```
     */
    mapAlpha(name, allowedTypes, options) {
        return (0, index_js_1.mapSchema)(this.scoped2(name), allowedTypes, true, true, options?.metadata, options?.persistedMetadata);
    }
    /**
     * {@inheritDoc SchemaFactory.objectRecursive}
     */
    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
    mapRecursive(name, allowedTypes, options) {
        return this.mapAlpha(name, allowedTypes, options);
    }
    /**
     * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.
     *
     * @param name - Unique identifier for this schema within this factory's scope.
     * @param allowedTypes - The types that may appear in the array.
     * @param options - Additional options for the schema.
     *
     * @example
     * ```typescript
     * class NamedArray extends factory.arrayAlpha("name", factory.number) {}
     * ```
     */
    arrayAlpha(name, allowedTypes, options) {
        return (0, index_js_1.arraySchema)(this.scoped2(name), allowedTypes, true, true, options?.metadata, options?.persistedMetadata);
    }
    /**
     * {@inheritDoc SchemaFactory.objectRecursive}
     */
    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
    arrayRecursive(name, allowedTypes, options) {
        return this.arrayAlpha(name, allowedTypes, options);
    }
    /**
     * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.
     * @remarks
     * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).
     * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.
     */
    scopedFactory(name) {
        return new SchemaFactoryAlpha(this.scoped2(name));
    }
}
exports.SchemaFactoryAlpha = SchemaFactoryAlpha;
/**
 * {@inheritDoc SchemaStatics.leaves}
 */
SchemaFactoryAlpha.leaves = schemaFactory_js_1.schemaStatics.leaves;
/**
 * {@inheritDoc SchemaStatics.optional}
 */
SchemaFactoryAlpha.optional = schemaFactory_js_1.schemaStatics.optional;
/**
 * {@inheritDoc SchemaStatics.required}
 */
SchemaFactoryAlpha.required = schemaFactory_js_1.schemaStatics.required;
/**
 * {@inheritDoc SchemaStatics.optionalRecursive}
 */
SchemaFactoryAlpha.optionalRecursive = schemaFactory_js_1.schemaStatics.optionalRecursive;
/**
 * {@inheritDoc SchemaStatics.requiredRecursive}
 */
SchemaFactoryAlpha.requiredRecursive = schemaFactory_js_1.schemaStatics.requiredRecursive;
/**
 * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.
 */
SchemaFactoryAlpha.identifier = schemaFactory_js_1.schemaStatics.identifier;
//# sourceMappingURL=schemaFactoryAlpha.js.map