import { DataAttrDef, InstantDBAttr, InstantDBAttrOnDelete, InstantDBCheckedDataType, InstantSchemaDef, LinkDef } from '@instantdb/core'; import { PlanStep } from './api.ts'; export type Identifier = { namespace: string; attrName: string; }; type AttrWithIdentifier = { 'value-type': 'blob' | 'ref'; cardinality?: 'many' | 'one'; 'forward-identity'?: Identifier; 'reverse-identity'?: Identifier | null; 'on-delete'?: InstantDBAttrOnDelete | null | undefined; 'on-delete-reverse'?: InstantDBAttrOnDelete | null | undefined; }; export type MigrationTxTypes = { 'delete-attr': { identifier: Identifier; }; 'update-attr': { identifier: Identifier; partialAttr: AttrWithIdentifier; }; 'add-attr': { identifier: Identifier; 'unique?': boolean; 'index?': boolean; 'required?': boolean; 'reverse-identity'?: Identifier | null; 'forward-identity': Identifier; cardinality: 'many' | 'one'; 'value-type': 'blob' | 'ref'; 'on-delete'?: InstantDBAttrOnDelete | null; 'on-delete-reverse'?: InstantDBAttrOnDelete | null; 'checked-data-type'?: InstantDBCheckedDataType | null; }; index: { identifier: Identifier; }; 'remove-index': { identifier: Identifier; }; unique: { identifier: Identifier; }; 'remove-unique': { identifier: Identifier; }; required: { identifier: Identifier; }; 'remove-required': { identifier: Identifier; }; 'check-data-type': { identifier: Identifier; 'checked-data-type': InstantDBCheckedDataType; }; 'remove-data-type': { identifier: Identifier; }; }; export declare const convertTxSteps: (txs: MigrationTx[], existingAttrs: InstantDBAttr[]) => PlanStep[]; export type MigrationTx = { [K in keyof MigrationTxTypes]: { type: K; } & MigrationTxTypes[K]; }[keyof MigrationTxTypes]; export type MigrationTxSpecific = { type: T; } & MigrationTxTypes[T]; export type AnyLink = LinkDef; export type AnyBlob = DataAttrDef; export declare const diffSchemas: (oldSchema: InstantSchemaDef, newSchema: InstantSchemaDef, resolveFn: RenameResolveFn, systemCatalogIdentNames: Record>) => Promise; export interface RenamePromptItem { from: T; to: T; } export declare const compareBlobs: (identity: Identifier, oldBlob: AnyBlob, newBlob: AnyBlob) => MigrationTx[]; export declare const compareLinks: (identity: Identifier, oldLink: AnyLink, newLink: AnyLink) => MigrationTx[]; export declare const isRenamePromptItem: (item: RenamePromptItem | T) => item is RenamePromptItem; export type RenameResolveFn = (created: T, promptData: (RenamePromptItem | T)[], extraInfo?: any) => Promise>; /** * a `rename command` lets us know your intent to rename a particular entity * * The format is `from:to`, where `from` and `to` are lookups. * * For example, to rename `posts.name` to `posts.title`, a command could * look like: * * `posts.name:posts.title` */ export type RenameCommand = `${string}.${string}:${string}.${string}`; /** * Given a list of RenameCommands, builds a cusotm `resolveFn` for * `diffSchemas`, which automatically resolves rename conflicts with these commands. */ export declare function buildAutoRenameSelector(renames: RenameCommand[]): RenameResolveFn; export {}; //# sourceMappingURL=migrations.d.ts.map