"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeKeySchema = exports.nodeKeyField = exports.nodeKeyTreeSchema = void 0;
const core_utils_1 = require("@fluidframework/core-utils");
const core_1 = require("../../core");
const feature_libraries_1 = require("../../feature-libraries");
const builder = new feature_libraries_1.SchemaBuilderInternal({ scope: "com.fluidframework.nodeKey" });
/**
 * Schema for a node which holds a {@link StableNodeKey}.
 * @alpha
 *
 * @privateRemarks
 * This being a leaf may cause issues with leaf unboxing plans.
 * This might need to be changed to be a node holding a string node instead.
 */
exports.nodeKeyTreeSchema = builder.leaf("NodeKey", core_1.ValueSchema.String);
(0, core_utils_1.assert)(exports.nodeKeyTreeSchema.name === feature_libraries_1.nodeKeyTreeIdentifier, 0x7ae /* mismatched identifiers */);
/**
 * Key and Field schema for working with {@link LocalNodeKey}s in a shared tree.
 * Node keys are added to object nodes via a field.
 * This object can be expanded into a schema to add the field.
 *
 * Requires including {@link nodeKeySchema}.
 * @alpha
 */
exports.nodeKeyField = {
    [feature_libraries_1.nodeKeyFieldKey]: feature_libraries_1.TreeFieldSchema.create(feature_libraries_1.FieldKinds.nodeKey, [exports.nodeKeyTreeSchema]),
};
/**
 * The schema library for working with {@link StableNodeKey}s in a tree.
 * Required to use {@link nodeKeyField}.
 * @alpha
 */
exports.nodeKeySchema = builder.intoLibrary();
//# sourceMappingURL=nodeKeySchema.js.map