/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { type TreeFieldStoredSchema, type TreeNodeStoredSchema, type TreeStoredSchema } from "../core/index.js";
import { type FlexFieldKind } from "../feature-libraries/index.js";
import { ExpectStored, Unchanged, type SimpleSchemaTransformationOptions, type StoredFromViewSchemaGenerationOptions } from "./core/index.js";
import { FieldKind, type ImplicitFieldSchema } from "./fieldSchema.js";
import type { SchemaType, SimpleAllowedTypes, SimpleFieldSchema, SimpleNodeSchema, SimpleTreeSchema } from "./simpleSchema.js";
/**
 * Maximally restrictive transformation of a view to stored schema.
 * @remarks
 * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.
 * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.
 */
export declare const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions;
/**
 * Maximally permissive transformation of a view to stored schema.
 * @remarks
 * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.
 * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.
 *
 * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.
 *
 * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.
 * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.
 * This could be useful to use as the schema for unhydrated content cloned from hydrated content.
 */
export declare const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions;
/**
 * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.
 *
 * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.
 */
export declare function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema;
/**
 * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.
 */
export declare function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema;
/**
 * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.
 * @remarks
 * This allows as much as possible, relying on further validation when inserting the content.
 *
 * TODO: this should get additional options to enable support for unknown optional fields.
 */
export declare const toUnhydratedSchema: StoredFromViewSchemaGenerationOptions;
/**
 * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.
 *
 * @privateRemarks
 * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if
 * a staged allowed type has been upgraded and if so, include it in the conversion.
 *
 * Even if this took in a SimpleTreeSchema,
 * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.
 *
 * @throws
 * Throws a `UsageError` if multiple schemas are encountered with the same identifier.
 */
export declare function toStoredSchema(root: ImplicitFieldSchema, options: StoredFromViewSchemaGenerationOptions): TreeStoredSchema;
/**
 * Converts a {@link SimpleTreeSchema} from `SchemaType.View` to `SchemaType.Stored`.
 */
export declare function transformSimpleSchema(schema: SimpleTreeSchema<SchemaType.View>, options: StoredFromViewSchemaGenerationOptions): SimpleTreeSchema<SchemaType.Stored>;
/**
 * Copies a `SchemaType.Stored` {@link SimpleTreeSchema}.
 */
export declare function transformSimpleSchema(schema: SimpleTreeSchema<SchemaType.Stored>, options: ExpectStored): SimpleTreeSchema<SchemaType.Stored>;
/**
 * Copies a {@link SimpleTreeSchema}.
 */
export declare function transformSimpleSchema<T extends SchemaType>(schema: SimpleTreeSchema<T>, options: Unchanged): SimpleTreeSchema<T>;
/**
 * Converts a {@link SimpleTreeSchema}.
 */
export declare function transformSimpleSchema(schema: SimpleTreeSchema, options: SimpleSchemaTransformationOptions): SimpleTreeSchema;
/**
 * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.
 * @remarks
 * This only supports simple schemas that are already logically stored schemas.
 * @privateRemarks
 * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.
 * @see {@link ExpectStored}.
 */
export declare function simpleStoredSchemaToStoredSchema(treeSchema: SimpleTreeSchema<SchemaType.Stored>): TreeStoredSchema;
/**
 * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.
 */
export declare function convertField(schema: SimpleFieldSchema<SchemaType.Stored>): TreeFieldStoredSchema;
/**
 * A map that converts {@link FieldKind} to {@link FlexFieldKind}.
 */
export declare const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind>;
/**
 * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
 * @privateRemarks
 * TODO: Persist node metadata once schema FormatV2 is supported.
 */
export declare function getStoredSchema(schema: SimpleNodeSchema<SchemaType.Stored>): TreeNodeStoredSchema;
/**
 * Converts a {@link SimpleNodeSchema} from view to stored.
 */
export declare function transformSimpleNodeSchema(schema: SimpleNodeSchema<SchemaType.View>, options: StoredFromViewSchemaGenerationOptions): SimpleNodeSchema<SchemaType.Stored>;
/**
 * Converts a {@link SimpleNodeSchema}.
 */
export declare function transformSimpleNodeSchema(schema: SimpleNodeSchema, options: SimpleSchemaTransformationOptions): SimpleNodeSchema;
/**
 * Converts a {@link SimpleAllowedTypes} to a stored schema.
 * @param schema - The schema to convert.
 * @param options - The options to use for filtering.
 * @returns The converted stored schema.
 */
export declare function filterAllowedTypes(schema: SimpleAllowedTypes, options: SimpleSchemaTransformationOptions): SimpleAllowedTypes;
//# sourceMappingURL=toStoredSchema.d.ts.map