import { InstantDBAttr, InstantDBCheckedDataType, InstantDBIdent } from '@instantdb/core'; import { GenericSchemaDef } from './util.ts'; export type InstantAPIPlatformSchema = { refs: Record; blobs: Record>; }; export type InstantAPISchemaPlanAddAttrStep = { type: 'add-attr'; friendlyDescription: string; attr: InstantDBAttr; }; export type InstantAPISchemaPlanDeleteAttrStep = { type: 'delete-attr'; friendlyDescription: string; attrId: string; }; export type InstantAPISchemaPlanUpdateAttrStep = { type: 'update-attr'; friendlyDescription: string; attr: InstantDBAttr; }; export type InstantAPISchemaPlanIndexStep = { type: 'index'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; export type InstantAPISchemaPlanRemoveIndexStep = { type: 'remove-index'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; export type InstantAPISchemaPlanUniqueStep = { type: 'unique'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; export type InstantAPISchemaPlanRemoveUniqueStep = { type: 'remove-unique'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; export type InstantAPISchemaPlanRequiredStep = { type: 'required'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; export type InstantAPISchemaPlanRemoveRequiredStep = { type: 'remove-required'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; export type InstantAPISchemaPlanCheckDataTypeStep = { type: 'check-data-type'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; checkedDataType: InstantDBCheckedDataType; }; export type InstantAPISchemaPlanRemoveDataTypeStep = { type: 'remove-data-type'; friendlyDescription: string; attrId: string; forwardIdentity: InstantDBIdent; }; type InstantBackgroundSchemaBaseJob = { id: string; createdAt: Date; updatedAt: Date; status: 'completed' | 'waiting' | 'processing' | 'errored'; workEstimate: number | null; workCompleted: number | null; error?: 'invalid-triple-error' | 'invalid-attr-state-error' | 'triple-not-unique-error' | 'triple-too-large-error' | 'missing-required-error' | 'unexpected-error'; invalidTriplesSample?: { entityId: string; value: any; jsonType: 'string' | 'number' | 'boolean' | 'null' | 'object' | 'array' | 'date'; }[]; }; type InstantBackgroundSchemaBaseJobWithInvalidTriples = InstantBackgroundSchemaBaseJob & { invalidTriplesSample?: { entityId: string; value: any; jsonType: 'string' | 'number' | 'boolean' | 'null' | 'object' | 'array' | 'date'; }[]; }; export interface InstantBackgroundSchemaRemoveDataTypeJob extends InstantBackgroundSchemaBaseJob { type: 'remove-data-type'; } export interface InstantBackgroundSchemaCheckDataTypeJob extends InstantBackgroundSchemaBaseJobWithInvalidTriples { type: 'check-data-type'; checkedDataType: InstantDBCheckedDataType; } export interface InstantBackgroundSchemaAddIndexJob extends InstantBackgroundSchemaBaseJobWithInvalidTriples { type: 'index'; } export interface InstantBackgroundSchemaRemoveIndexJob extends InstantBackgroundSchemaBaseJob { type: 'remove-index'; } export interface InstantBackgroundSchemaAddUniqueJob extends InstantBackgroundSchemaBaseJobWithInvalidTriples { type: 'unique'; invalidUniqueValue?: any; } export interface InstantBackgroundSchemaRemoveUniqueJob extends InstantBackgroundSchemaBaseJob { type: 'remove-unique'; } export interface InstantBackgroundSchemaAddRequiredJob extends InstantBackgroundSchemaBaseJobWithInvalidTriples { type: 'required'; } export interface InstantBackgroundSchemaRemoveRequiredJob extends InstantBackgroundSchemaBaseJob { type: 'remove-required'; } export type InstantAPISchemaPlanStep = InstantAPISchemaPlanAddAttrStep | InstantAPISchemaPlanDeleteAttrStep | InstantAPISchemaPlanUpdateAttrStep | InstantAPISchemaPlanIndexStep | InstantAPISchemaPlanRemoveIndexStep | InstantAPISchemaPlanUniqueStep | InstantAPISchemaPlanRemoveUniqueStep | InstantAPISchemaPlanRequiredStep | InstantAPISchemaPlanRemoveRequiredStep | InstantAPISchemaPlanCheckDataTypeStep | InstantAPISchemaPlanRemoveDataTypeStep; type BackgroundJobByStep = { index: InstantBackgroundSchemaAddIndexJob; 'remove-index': InstantBackgroundSchemaRemoveIndexJob; unique: InstantBackgroundSchemaAddUniqueJob; 'remove-unique': InstantBackgroundSchemaRemoveUniqueJob; required: InstantBackgroundSchemaAddRequiredJob; 'remove-required': InstantBackgroundSchemaRemoveRequiredJob; 'check-data-type': InstantBackgroundSchemaCheckDataTypeJob; 'remove-data-type': InstantBackgroundSchemaRemoveDataTypeJob; }; export type WithBackgroundJob

= P['type'] extends keyof BackgroundJobByStep ? P & { backgroundJob: BackgroundJobByStep[P['type']]; } : P; export type InstantAPISchemaPushAddAttrStep = WithBackgroundJob; export type InstantAPISchemaPushUpdateAttrStep = WithBackgroundJob; export type InstantAPISchemaPushIndexStep = WithBackgroundJob; export type InstantAPISchemaPushRemoveIndexStep = WithBackgroundJob; export type InstantAPISchemaPushUniqueStep = WithBackgroundJob; export type InstantAPISchemaPushRemoveUniqueStep = WithBackgroundJob; export type InstantAPISchemaPushRequiredStep = WithBackgroundJob; export type InstantAPISchemaPushRemoveRequiredStep = WithBackgroundJob; export type InstantAPISchemaPushCheckDataTypeStep = WithBackgroundJob; export type InstantAPISchemaPushRemoveDataTypeStep = WithBackgroundJob; export type InstantAPISchemaPushStep = InstantAPISchemaPushAddAttrStep | InstantAPISchemaPushUpdateAttrStep | InstantAPISchemaPushIndexStep | InstantAPISchemaPushRemoveIndexStep | InstantAPISchemaPushUniqueStep | InstantAPISchemaPushRemoveUniqueStep | InstantAPISchemaPushRequiredStep | InstantAPISchemaPushRemoveRequiredStep | InstantAPISchemaPushCheckDataTypeStep | InstantAPISchemaPushRemoveDataTypeStep; export declare function identEtype(ident: InstantDBIdent): string; export declare function identLabel(ident: InstantDBIdent): string; export declare function identName(ident: InstantDBIdent): string; export declare function attrFwdLabel(attr: InstantDBAttr): string; export declare function attrFwdEtype(attr: InstantDBAttr): string; export declare function attrRevLabel(attr: InstantDBAttr): string | undefined; export declare function attrRevEtype(attr: InstantDBAttr): string | undefined; export declare function attrFwdName(attr: InstantDBAttr): string; export declare function attrRevName(attr: InstantDBAttr): string | undefined; export declare function generateSchemaTypescriptFile(prevSchema: GenericSchemaDef | null | undefined, newSchema: GenericSchemaDef, instantModuleName: string): string; export declare class SchemaValidationError extends Error { constructor(message: string); } export declare function collectSystemCatalogIdentNames(currentAttrs: InstantDBAttr[]): Record>; export declare const validateSchema: (schema: GenericSchemaDef, systemCatalogIdentNames: Record>) => void; export {}; //# sourceMappingURL=schema.d.ts.map