import { RichTextNodeType, type Component, type EntityReference, type Location, type RichText } from '../Types.js'; import type { LooseAutocomplete } from '../utils/TypeUtils.js'; export interface EntityTypeSpecification { name: string; publishable: boolean; authKeyPattern: string | null; nameField: string | null; fields: FieldSpecification[]; } export interface ComponentTypeSpecification { name: string; adminOnly: boolean; fields: FieldSpecification[]; } export interface EntityTypeSpecificationUpdate { name: string; publishable?: boolean; authKeyPattern?: string | null; nameField?: string | null; fields: FieldSpecificationUpdate[]; } export interface ComponentTypeSpecificationUpdate { name: string; adminOnly?: boolean; fields: FieldSpecificationUpdate[]; } export interface PublishedEntityTypeSpecification { name: string; authKeyPattern: string | null; fields: PublishedFieldSpecification[]; } export interface PublishedComponentTypeSpecification { name: string; fields: PublishedFieldSpecification[]; } export declare const FieldType: { readonly Boolean: "Boolean"; readonly Component: "Component"; readonly Location: "Location"; readonly Number: "Number"; readonly Reference: "Reference"; readonly RichText: "RichText"; readonly String: "String"; }; export type FieldType = (typeof FieldType)[keyof typeof FieldType]; interface SharedFieldSpecification { name: string; list: boolean; required: boolean; adminOnly: boolean; } export interface BooleanFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.Boolean; } export interface ComponentFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.Component; componentTypes: string[]; } export interface ReferenceFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.Reference; entityTypes: string[]; } export interface LocationFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.Location; } export interface NumberFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.Number; integer: boolean; } export interface RichTextFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.RichText; entityTypes: string[]; linkEntityTypes: string[]; componentTypes: string[]; /** All node types are enabled if none are specified. * * The type can either be a standard RichTextNodeType or any type that's supported by the * application. */ richTextNodes: LooseAutocomplete[]; } export interface StringFieldSpecification extends SharedFieldSpecification { type: typeof FieldType.String; multiline: boolean; matchPattern: string | null; values: { value: string; }[]; index: string | null; } export type FieldSpecification = BooleanFieldSpecification | ComponentFieldSpecification | LocationFieldSpecification | NumberFieldSpecification | ReferenceFieldSpecification | RichTextFieldSpecification | StringFieldSpecification; type PartialExcept = Pick & Partial>; export type BooleanFieldSpecificationUpdate = PartialExcept; export type ComponentFieldSpecificationUpdate = PartialExcept; export type ReferenceFieldSpecificationUpdate = PartialExcept; export type LocationFieldSpecificationUpdate = PartialExcept; export type NumberFieldSpecificationUpdate = PartialExcept; export type RichTextFieldSpecificationUpdate = PartialExcept; export type StringFieldSpecificationUpdate = PartialExcept; export type FieldSpecificationUpdate = BooleanFieldSpecificationUpdate | ComponentFieldSpecificationUpdate | LocationFieldSpecificationUpdate | NumberFieldSpecificationUpdate | ReferenceFieldSpecificationUpdate | RichTextFieldSpecificationUpdate | StringFieldSpecificationUpdate; export type PublishedBooleanFieldSpecification = Omit; export type PublishedComponentFieldSpecification = Omit; export type PublishedReferenceFieldSpecification = Omit; export type PublishedLocationFieldSpecification = Omit; export type PublishedNumberFieldSpecification = Omit; export type PublishedRichTextFieldSpecification = Omit; export type PublishedStringFieldSpecification = Omit; export type PublishedFieldSpecification = PublishedBooleanFieldSpecification | PublishedComponentFieldSpecification | PublishedReferenceFieldSpecification | PublishedLocationFieldSpecification | PublishedNumberFieldSpecification | PublishedRichTextFieldSpecification | PublishedStringFieldSpecification; export interface FieldValueTypeMap { [FieldType.Boolean]: boolean; [FieldType.Component]: Component; [FieldType.Location]: Location; [FieldType.Number]: number; [FieldType.Reference]: EntityReference; [FieldType.RichText]: RichText; [FieldType.String]: string; } export interface SchemaPatternSpecification { name: string; pattern: string; } export interface SchemaIndexSpecification { name: string; type: 'unique'; } export interface PublishedSchemaSpecification { schemaKind: 'published'; version: number; entityTypes: PublishedEntityTypeSpecification[]; componentTypes: PublishedComponentTypeSpecification[]; patterns: SchemaPatternSpecification[]; indexes: SchemaIndexSpecification[]; } export interface SchemaSpecification { schemaKind: 'full'; version: number; entityTypes: EntityTypeSpecification[]; componentTypes: ComponentTypeSpecification[]; patterns: SchemaPatternSpecification[]; indexes: SchemaIndexSpecification[]; } export interface SchemaSpecificationWithMigrations extends SchemaSpecification { migrations: SchemaVersionMigration[]; } export interface SchemaVersionMigration { version: number; actions: SchemaMigrationAction[]; } export type SchemaMigrationAction = { action: 'renameType'; entityType: string; newName: string; } | { action: 'renameType'; componentType: string; newName: string; } | { action: 'renameField'; entityType: string; field: string; newName: string; } | { action: 'renameField'; componentType: string; field: string; newName: string; } | { action: 'deleteType'; entityType: string; } | { action: 'deleteType'; componentType: string; } | { action: 'deleteField'; entityType: string; field: string; } | { action: 'deleteField'; componentType: string; field: string; }; export type SchemaTransientMigrationAction = { action: 'renameIndex'; index: string; newName: string; } | { action: 'deleteIndex'; index: string; }; export interface SchemaSpecificationUpdate { version?: number; entityTypes?: EntityTypeSpecificationUpdate[]; componentTypes?: ComponentTypeSpecificationUpdate[]; patterns?: SchemaPatternSpecification[]; indexes?: SchemaIndexSpecification[]; migrations?: SchemaVersionMigration[]; transientMigrations?: SchemaTransientMigrationAction[]; } export interface SchemaSpecificationUpdatePayload { effect: 'updated' | 'none'; schemaSpecification: TSpec; } export type LegacySchemaSpecificationWithMigrations = Legacy_V0_4_7_SchemaSpecificationWithMigrations | Legacy_V0_6_2_SchemaSpecificationWithMigrations; export type LegacyEntityTypeSpecification = Legacy_V0_4_7_SchemaSpecificationWithMigrations['entityTypes'][number] | Legacy_V0_6_2_SchemaSpecificationWithMigrations['entityTypes'][number]; export type LegacyComponentTypeSpecification = Legacy_V0_4_7_SchemaSpecificationWithMigrations['valueTypes'][number] | Legacy_V0_6_2_SchemaSpecificationWithMigrations['componentTypes'][number]; /** In version after 0.4.7: * - valueTypes was renamed to componentTypes * - field type ValueItem was renamed to Component * - field spec validations valueTypes were renamed to componentTypes * - migration actions valueType selector was renamed to componentType */ interface Legacy_V0_4_7_SchemaSpecificationWithMigrations extends Omit { entityTypes: (Omit & { adminOnly: boolean; fields: Legacy_V0_4_7_FieldSpecification[]; })[]; valueTypes: (Omit & { fields: Legacy_V0_4_7_FieldSpecification[]; })[]; migrations: (Omit & { actions: Legacy_v0_4_7_SchemaMigrationAction[]; })[]; } type Legacy_V0_4_7_FieldSpecification = T extends ComponentFieldSpecification ? Omit & { type: 'ValueItem'; valueTypes: string[]; } : T extends RichTextFieldSpecification ? Omit & { valueTypes: string[]; } : T; type Legacy_v0_4_7_SchemaMigrationAction = T extends { componentType: string; } ? Omit & { valueType: string; } : T; /** In version after 0.6.2: * - Entity field type was renamed to Reference * - adminOnly in EntityTypeSpecification was renamed to publishable (and inverted) */ interface Legacy_V0_6_2_SchemaSpecificationWithMigrations extends Omit { entityTypes: (Omit & { adminOnly: boolean; fields: Legacy_V0_6_2_FieldSpecification[]; })[]; componentTypes: (Omit & { fields: Legacy_V0_6_2_FieldSpecification[]; })[]; } type Legacy_V0_6_2_FieldSpecification = T extends ReferenceFieldSpecification ? Omit & { type: 'Entity'; } : T; export declare const REQUIRED_RICH_TEXT_NODES: RichTextNodeType[]; export declare const GROUPED_RICH_TEXT_NODE_TYPES: RichTextNodeType[][]; export {};