"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaBuilderInternal = void 0;
const schemaBuilderBase_1 = require("./schemaBuilderBase");
const default_field_kinds_1 = require("./default-field-kinds");
const typed_schema_1 = require("./typed-schema");
/**
 * Extends {@link SchemaBuilderBase} with functionality only used to create built in special libraries.
 * Defaults to "required" fields.
 * @privateRemarks Should not be package exported.
 */
class SchemaBuilderInternal extends schemaBuilderBase_1.SchemaBuilderBase {
    constructor(options) {
        super(default_field_kinds_1.FieldKinds.required, options);
    }
    /**
     * Define (and add to this library) a {@link TreeNodeSchema} for a node that wraps a value.
     * Such nodes will be implicitly unwrapped to the value in some APIs.
     *
     * The name must be unique among all TreeNodeSchema in the the document schema.
     *
     * In addition to the normal properties of all nodes (having a schema for example),
     * Leaf nodes only contain a value.
     * Leaf nodes cannot have fields.
     *
     * TODO: Maybe ban undefined from allowed values here.
     * TODO: Decide and document how unwrapping works for non-primitive terminals.
     */
    leaf(name, t) {
        const schema = new typed_schema_1.TreeNodeSchema(this, this.scoped(name), { leafValue: t });
        this.addNodeSchema(schema);
        return schema;
    }
}
exports.SchemaBuilderInternal = SchemaBuilderInternal;
//# sourceMappingURL=schemaBuilder.js.map