import { type Schema } from 'effect'; import type { Type } from '@dxos/echo'; import { type DXN } from '@dxos/keys'; import type { EchoDatabase } from './database'; import type { AnyLiveObject } from '../echo-handler'; type DefineObjectMigrationOptions = { from: From; to: To; /** * Pure function that converts the old object data to the new object data. */ transform: (from: Schema.Schema.Type, context: ObjectMigrationContext) => Promise, 'id' | Type.KindId>>; /** * Callback that is called after the object is migrated. Called for every object that is migrated. * * NOTE: Database mutations performed in this callback are not guaranteed to be idempotent. * If multiple peers run the migration separately, the effects may be applied multiple times. */ onMigration: (params: OnMigrateParams) => Promise; }; type ObjectMigrationContext = {}; type OnMigrateParams = { before: Schema.Schema.Type; object: AnyLiveObject>; db: EchoDatabase; }; export type ObjectMigration = { fromType: DXN; toType: DXN; fromSchema: Schema.Schema.AnyNoContext; toSchema: Schema.Schema.AnyNoContext; transform: (from: unknown, context: ObjectMigrationContext) => Promise; onMigration: (params: OnMigrateParams) => Promise; }; export declare const defineObjectMigration: (options: DefineObjectMigrationOptions) => ObjectMigration; export {}; //# sourceMappingURL=object-migration.d.ts.map