"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleTreeSchemaFormat = exports.SimpleSchemaDefinitionsFormat = exports.SimpleNodeSchemaUnionFormat = exports.SimpleObjectNodeSchemaFormat = exports.SimpleObjectFieldSchemasFormat = exports.SimpleLeafNodeSchemaFormat = exports.SimpleRecordNodeSchemaFormat = exports.SimpleMapNodeSchemaFormat = exports.SimpleArrayNodeSchemaFormat = exports.SimpleObjectFieldSchemaFormat = exports.SimpleFieldSchemaFormat = exports.SimpleAllowedTypesFormat = exports.SimpleAllowedTypeAttributesFormat = exports.SimpleSchemaFormatVersion = void 0;
/*
 * This file contains a format for serializing the compatibility impacting subset of simple schema.

 * This format can be used for both view and stored simple schema.
 * This only includes all parts of the schema that impact compatibility according to SchemaCompatibilityTester.
 * It may not include some details which impact maintenance of application enforced invariants (like persisted metadata or logic in view schema).
 */
const Type = __importStar(require("@sinclair/typebox"));
const noAdditionalProps = { additionalProperties: false };
/**
 * The format version for the schema.
 */
exports.SimpleSchemaFormatVersion = {
    v1: 1,
};
/**
 * The allowed types and their attributes in the simple schema format.
 * @see {@link SimpleAllowedTypes}.
 */
exports.SimpleAllowedTypeAttributesFormat = Type.Object({
    isStaged: Type.Optional(Type.Boolean()),
}, noAdditionalProps);
/**
 * A set of allowed types in the simple schema format.
 * The keys are the type identifiers, and the values are their attributes.
 */
exports.SimpleAllowedTypesFormat = Type.Record(Type.String(), exports.SimpleAllowedTypeAttributesFormat);
/**
 * Persisted format for a field schema in the simple schema format.
 * @see {@link SimpleFieldSchema}.
 */
exports.SimpleFieldSchemaFormat = Type.Object({
    kind: Type.Integer(),
    simpleAllowedTypes: exports.SimpleAllowedTypesFormat,
}, noAdditionalProps);
/**
 * Persisted format for an object field schema in the simple schema format.
 * @see {@link SimpleObjectFieldSchema}.
 */
exports.SimpleObjectFieldSchemaFormat = Type.Object({
    kind: Type.Integer(),
    simpleAllowedTypes: exports.SimpleAllowedTypesFormat,
    storedKey: Type.String(),
}, noAdditionalProps);
/**
 * Persisted format for an array node schema in the simple schema format.
 * @see {@link SimpleArrayNodeSchema}.
 */
exports.SimpleArrayNodeSchemaFormat = Type.Object({
    kind: Type.Integer(),
    simpleAllowedTypes: exports.SimpleAllowedTypesFormat,
}, noAdditionalProps);
/**
 * Persisted format for a map node schema in the simple schema format.
 * @see {@link SimpleMapNodeSchema}.
 */
exports.SimpleMapNodeSchemaFormat = Type.Object({
    kind: Type.Integer(),
    simpleAllowedTypes: exports.SimpleAllowedTypesFormat,
}, noAdditionalProps);
/**
 * Persisted format for a record node schema in the simple schema format.
 * @see {@link SimpleRecordNodeSchema}.
 */
exports.SimpleRecordNodeSchemaFormat = Type.Object({
    kind: Type.Integer(),
    simpleAllowedTypes: exports.SimpleAllowedTypesFormat,
}, noAdditionalProps);
/**
 * Persisted format for a leaf node schema in the simple schema format.
 * @see {@link SimpleLeafNodeSchema}.
 */
exports.SimpleLeafNodeSchemaFormat = Type.Object({
    kind: Type.Integer(),
    leafKind: Type.Integer(),
}, noAdditionalProps);
/**
 * Persisted format for the field schemas of an object node in the simple schema format.
 */
exports.SimpleObjectFieldSchemasFormat = Type.Record(Type.String(), exports.SimpleObjectFieldSchemaFormat);
/**
 * Persisted format for an object node schema in the simple schema format.
 * @see {@link SimpleObjectNodeSchema}.
 */
exports.SimpleObjectNodeSchemaFormat = Type.Object({
    kind: Type.Integer(),
    fields: exports.SimpleObjectFieldSchemasFormat,
    allowUnknownOptionalFields: Type.Optional(Type.Boolean()),
}, noAdditionalProps);
/**
 * Discriminated union of all possible node schemas.
 *
 * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.
 */
exports.SimpleNodeSchemaUnionFormat = Type.Object({
    array: Type.Optional(exports.SimpleArrayNodeSchemaFormat),
    map: Type.Optional(exports.SimpleMapNodeSchemaFormat),
    record: Type.Optional(exports.SimpleRecordNodeSchemaFormat),
    leaf: Type.Optional(exports.SimpleLeafNodeSchemaFormat),
    object: Type.Optional(exports.SimpleObjectNodeSchemaFormat),
});
/**
 * Helper type for the schema definitions map in the persisted format.
 */
exports.SimpleSchemaDefinitionsFormat = Type.Record(Type.String(), exports.SimpleNodeSchemaUnionFormat);
/**
 * Persisted format for the compatibility impacting subset of simple schema.
 * @see {@link SimpleTreeSchema}.
 */
exports.SimpleTreeSchemaFormat = Type.Object({
    version: Type.Literal(exports.SimpleSchemaFormatVersion.v1),
    root: exports.SimpleFieldSchemaFormat,
    definitions: exports.SimpleSchemaDefinitionsFormat,
}, noAdditionalProps);
//# sourceMappingURL=simpleSchemaFormatV1.js.map