@asaidimu/anansi 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/index.cjs +46 -1415
  2. package/index.d.cts +282 -2
  3. package/index.d.ts +282 -2
  4. package/index.js +46 -1364
  5. package/package.json +1 -1
package/index.d.cts CHANGED
@@ -286,7 +286,7 @@ interface Migration<T> {
286
286
  * Defines the interface for a migration engine.
287
287
  * The migration engine is responsible for applying, rolling back, and tracking schema migrations.
288
288
  */
289
- interface MigrationEngine<T> {
289
+ interface MigrationEngineInterface<T> {
290
290
  /**
291
291
  * Applies all pending migrations.
292
292
  * @returns A promise that resolves when all migrations are applied.
@@ -413,6 +413,98 @@ declare function createPatch(oldObj: any, newObj: any): PatchOperation[];
413
413
  */
414
414
  declare function schemaChangeToPatch(change: SchemaChange<any>, schema: SchemaDefinition): PatchOperation[];
415
415
 
416
+ /**
417
+ * Schema event types.
418
+ */
419
+ type SchemaEventType = SchemaEvent["type"];
420
+ /**
421
+ * Represents a schema event.
422
+ */
423
+ type SchemaEvent = {
424
+ type: "migration:started";
425
+ description: string;
426
+ currentVersion: string;
427
+ changes: SchemaChange<any>[];
428
+ dryRun?: boolean;
429
+ } | {
430
+ type: "migration:committed";
431
+ currentVersion: string;
432
+ previousVersion: string;
433
+ changes: SchemaChange<any>[];
434
+ dryRun?: boolean;
435
+ } | {
436
+ type: "migration:rollingBack";
437
+ currentVersion: string;
438
+ targetVersion: string;
439
+ changes: SchemaChange<any>[];
440
+ dryRun?: boolean;
441
+ } | {
442
+ type: "migration:rolledBack";
443
+ currentVersion: string;
444
+ previousVersion: string;
445
+ changes: SchemaChange<any>[];
446
+ dryRun?: boolean;
447
+ } | {
448
+ type: "migration:ended";
449
+ currentVersion: string;
450
+ status: "committed" | "rolledBack";
451
+ };
452
+ /**
453
+ * Schema interface for managing schema evolution.
454
+ * @template T The type of data associated with the schema.
455
+ */
456
+ interface Schema<T = any> {
457
+ /**
458
+ * Subscribes to schema events. The listener will be called for each event.
459
+ * @param event The type of schema event to subscribe to.
460
+ * @param listener The listener function that receives the schema event.
461
+ * @returns A function that, when called, unsubscribes the listener.
462
+ */
463
+ subscribe(event: SchemaEventType, listener: (event: SchemaEvent) => void): () => void;
464
+ /**
465
+ * Returns a read-only copy of the schema definition.
466
+ * @returns A read-only version of the current schema definition.
467
+ */
468
+ definition(): Readonly<SchemaDefinition>;
469
+ /**
470
+ * Returns a promise that resolves to a read-only copy of the migration history.
471
+ * @returns A promise that resolves to a read-only array of migrations.
472
+ */
473
+ migrations(): Promise<Readonly<Migration<any>[]>>;
474
+ /**
475
+ * Exports the schema state (definition and migrations) as a JSON string.
476
+ * @returns A JSON string representation of the schema state.
477
+ */
478
+ export(): string;
479
+ /**
480
+ * Imports the schema state (definition and migrations) from a JSON string.
481
+ * @param json The JSON string representing the schema state to import.
482
+ * @throws Error if the imported state is invalid.
483
+ */
484
+ import(json: string): void;
485
+ /**
486
+ * Creates a migration from a list of changes.
487
+ * @param description A description of the migration.
488
+ * @param changes A list of schema changes to apply.
489
+ * @param dryRun Indicates whether the migration should actually be executed
490
+ * @throws Error if the changes are not valid.
491
+ * @returns A promise that resolves when the migration is complete.
492
+ */
493
+ migrate(description: string, changes: SchemaChange<T>[], dryRun?: boolean): Promise<void>;
494
+ /**
495
+ * Rolls back a migration.
496
+ * @param version The version to rollback from. If not specified, rolls back the last migration.
497
+ * @throws Error if the rollback cannot be performed.
498
+ * @returns A promise that resolves when the rollback is complete.
499
+ */
500
+ rollback(version?: string): Promise<void>;
501
+ /**
502
+ * Creates a migration helper to assist in creating a migration.
503
+ * @param description A description of the migration.
504
+ * @returns A `SchemaMigrationHelper` instance to build the migration.
505
+ */
506
+ migrationHelper(description: string): SchemaMigrationHelper;
507
+ }
416
508
  /**
417
509
  * Helper for building schema migrations.
418
510
  * @template T The type of data associated with the schema.
@@ -765,6 +857,190 @@ declare enum MigrationErrorCode {
765
857
  ROLLBACK_ERROR = "ROLLBACK_ERROR",
766
858
  MISSING_TRANSFORM = "MISSING_TRANSFORM"
767
859
  }
860
+ /**
861
+ * @class MigrationEngine
862
+ * @param {SchemaDefinition} currentSchema - The current schema definition
863
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
864
+ * @throws {MigrationError} If the initial schema or migrations are invalid
865
+ */
866
+ declare class MigrationEngine {
867
+ private currentSchema;
868
+ private history;
869
+ private migrations;
870
+ private isProcessing;
871
+ /**
872
+ * @constructor
873
+ * @param {SchemaDefinition} currentSchema - The current schema definition
874
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
875
+ */
876
+ constructor(currentSchema: SchemaDefinition, migrations?: Array<Migration<any>>, history?: Array<SchemaDefinition>);
877
+ /**
878
+ * Gets the current state of the migration helper
879
+ * @returns {Object} Current state containing schema, history, and migrations
880
+ * @example
881
+ * ```javascript
882
+ * const state = migrationEngine.data();
883
+ * // state contains currentSchema, history, and migrations
884
+ * ```
885
+ */
886
+ data(): {
887
+ schema: SchemaDefinition;
888
+ history: SchemaDefinition[];
889
+ migrations: Migration<any>[];
890
+ };
891
+ /**
892
+ * Generates a SHA-256 checksum for a migration
893
+ * @private
894
+ * @param {Omit<Migration<any>, "checksum">} migration - The migration object
895
+ * @returns {Promise<string>} The generated checksum
896
+ * @throws {MigrationError} If checksum generation fails
897
+ */
898
+ private generateChecksum;
899
+ /**
900
+ * Adds a new migration to the engine
901
+ * @async
902
+ * @param {Object} opts - Options for the new migration
903
+ * @param {SchemaChange<any>[]} opts.changes - Array of schema changes
904
+ * @param {string} opts.description - Description of the migration
905
+ * @param {SchemaChange<any>[]} [opts.rollback] - Optional rollback changes
906
+ * @param {DataTransform<any, any>} [opts.transform] - Optional data transform
907
+ * @throws {MigrationError} If adding the migration fails
908
+ */
909
+ add(opts: {
910
+ changes: SchemaChange<any>[];
911
+ description: string;
912
+ rollback?: SchemaChange<any>[];
913
+ transform?: string | DataTransform<any, any>;
914
+ }): Promise<void>;
915
+ /**
916
+ * Performs a dry run of the migration
917
+ * @async
918
+ * @param {ReadableStream<any>} input - Input data stream
919
+ * @param {"forward" | "backward"} direction - Direction of migration
920
+ * @param {version} version - Version to rollback to
921
+ * @returns {Promise<Object>} Object containing newSchema and dataPreview
922
+ * @throws {MigrationError} If dry run fails
923
+ */
924
+ dryRun(input: ReadableStream<any>, direction: "forward" | "backward", version?: string): Promise<{
925
+ newSchema: SchemaDefinition;
926
+ dataPreview: ReadableStream<any>;
927
+ }>;
928
+ /**
929
+ * Gets relevant migrations based on direction
930
+ * @private
931
+ * @param {"forward" | "backward"} direction - Direction of migration
932
+ * @returns {Array<Migration<any>>} Relevant migrations
933
+ */
934
+ private getRelevantMigrations;
935
+ /**
936
+ * Applies schema changes to a given schema
937
+ * @private
938
+ * @param {SchemaDefinition} schema - The schema to modify
939
+ * @param {SchemaChange<any>[]} changes - Array of schema changes
940
+ * @param {string} [migrationId] - ID of the migration
941
+ * @returns {SchemaDefinition} Modified schema
942
+ * @throws {MigrationError} If applying changes fails
943
+ */
944
+ private applySchemaChanges;
945
+ /**
946
+ * Prepares the list of pending migrations for application
947
+ * @async
948
+ * @returns {Promise<Array<Migration<any>>} List of pending migrations
949
+ * @throws {MigrationError} If preparation fails
950
+ */
951
+ prepareMigration(): Promise<Array<Migration<any>>>;
952
+ /**
953
+ * Applies pending migrations
954
+ * @async
955
+ * @param {ReadableStream<any>} input - Input data stream
956
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
957
+ * @throws {MigrationError} If migration fails
958
+ */
959
+ migrate(input: ReadableStream<any>): Promise<ReadableStream<any>>;
960
+ /**
961
+ * Validates migrations by checking their checksums
962
+ * @private
963
+ * @async
964
+ * @param {Array<Migration<any>>} migrations - Migrations to validate
965
+ * @throws {MigrationError} If validation fails
966
+ */
967
+ private validateMigrations;
968
+ /**
969
+ * Marks migrations as applied
970
+ * @private
971
+ * @param {Array<Migration<any>>} migrations - Migrations to mark as applied
972
+ */
973
+ private markMigrationsApplied;
974
+ /**
975
+ * Rolls back the last applied migration
976
+ * @async
977
+ * @param {ReadableStream<any>} input - Input data stream
978
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
979
+ */
980
+ rollback(input: ReadableStream<any>): Promise<ReadableStream<any>>;
981
+ /**
982
+ * Rolls back to a specific schema version
983
+ * @async
984
+ * @param {string} targetVersion - Target schema version
985
+ * @param {ReadableStream<any>} input - Input data stream
986
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
987
+ * @throws {Error} If target version is not found
988
+ */
989
+ rollbackToVersion(targetVersion: string, input: ReadableStream<any>): Promise<ReadableStream<any>>;
990
+ /**
991
+ * Processes a list of migrations on a data stream, applying transformations
992
+ * in the specified direction (forward or backward).
993
+ *
994
+ * @static
995
+ * @async
996
+ * @param {ReadableStream<any>} input - The input data stream to process
997
+ * @param {"forward" | "backward"} direction - Direction of migration (either "forward" or "backward")
998
+ * @param {Array<Migration<any>>} migrations - Array of Migration objects to process
999
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
1000
+ * @throws {MigrationError} If any migration processing fails
1001
+ */
1002
+ static processMigrationList(input: ReadableStream<any>, direction: "forward" | "backward", migrations: Migration<any>[]): Promise<ReadableStream<any>>;
1003
+ /**
1004
+ * Resolves the transform function for a given migration in the specified direction.
1005
+ *
1006
+ * @private
1007
+ * @async
1008
+ * @param {Migration<any>} migration - The migration to resolve the transform for
1009
+ * @param {"forward" | "backward"} direction - Direction of migration
1010
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1011
+ * @throws {MigrationError} If transform resolution fails
1012
+ */
1013
+ private static resolveTransform;
1014
+ /**
1015
+ * Resolves a transform function from a remote URL.
1016
+ *
1017
+ * @private
1018
+ * @async
1019
+ * @param {string} url - URL of the transform module
1020
+ * @param {"forward" | "backward"} direction - Direction of migration
1021
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1022
+ * @throws {MigrationError} If resolution fails
1023
+ */
1024
+ private static resolveRemoteTransform;
1025
+ /**
1026
+ * Resolves a transform function from a local module path.
1027
+ *
1028
+ * @private
1029
+ * @async
1030
+ * @param {string} path - Local module path
1031
+ * @param {"forward" | "backward"} direction - Direction of migration
1032
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1033
+ * @throws {MigrationError} If resolution fails
1034
+ */
1035
+ private static resolveLocalTransform;
1036
+ /**
1037
+ * Transforms the schema either forward or backward
1038
+ * @private
1039
+ * @param {"forward" | "backward"} direction - Direction of transformation
1040
+ * @throws {Error} If transformation fails
1041
+ */
1042
+ private transformSchema;
1043
+ }
768
1044
 
769
1045
  /**
770
1046
  * Helper for building schema migrations with forward and rollback changes.
@@ -1600,4 +1876,8 @@ declare function compareSemanticVersions(a: string, b: string): number;
1600
1876
  */
1601
1877
  declare function sortSemanticVars(vars: string[]): string[];
1602
1878
 
1603
- export { type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type FieldDefinition, type FieldType, type FunctionMap, type IndexDefinition, type IndexType, JsonPatchError, type LogicalOperator, type Migration, type MigrationEngine, MigrationError, MigrationErrorCode, type MigrationMetadata, MigrationSchema, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaIndex, type SchemaMetadata, type SchemaRegistry, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaToTypes, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };
1879
+ declare function docgen(schema: SchemaDefinition, options?: {
1880
+ faker?: Faker;
1881
+ }): string;
1882
+
1883
+ export { type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type FieldDefinition, type FieldType, type FunctionMap, type IndexDefinition, type IndexType, JsonPatchError, type LogicalOperator, type Migration, MigrationEngine, type MigrationEngineInterface, MigrationError, MigrationErrorCode, type MigrationMetadata, MigrationSchema, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, type SchemaRegistry, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaToTypes, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };
package/index.d.ts CHANGED
@@ -286,7 +286,7 @@ interface Migration<T> {
286
286
  * Defines the interface for a migration engine.
287
287
  * The migration engine is responsible for applying, rolling back, and tracking schema migrations.
288
288
  */
289
- interface MigrationEngine<T> {
289
+ interface MigrationEngineInterface<T> {
290
290
  /**
291
291
  * Applies all pending migrations.
292
292
  * @returns A promise that resolves when all migrations are applied.
@@ -413,6 +413,98 @@ declare function createPatch(oldObj: any, newObj: any): PatchOperation[];
413
413
  */
414
414
  declare function schemaChangeToPatch(change: SchemaChange<any>, schema: SchemaDefinition): PatchOperation[];
415
415
 
416
+ /**
417
+ * Schema event types.
418
+ */
419
+ type SchemaEventType = SchemaEvent["type"];
420
+ /**
421
+ * Represents a schema event.
422
+ */
423
+ type SchemaEvent = {
424
+ type: "migration:started";
425
+ description: string;
426
+ currentVersion: string;
427
+ changes: SchemaChange<any>[];
428
+ dryRun?: boolean;
429
+ } | {
430
+ type: "migration:committed";
431
+ currentVersion: string;
432
+ previousVersion: string;
433
+ changes: SchemaChange<any>[];
434
+ dryRun?: boolean;
435
+ } | {
436
+ type: "migration:rollingBack";
437
+ currentVersion: string;
438
+ targetVersion: string;
439
+ changes: SchemaChange<any>[];
440
+ dryRun?: boolean;
441
+ } | {
442
+ type: "migration:rolledBack";
443
+ currentVersion: string;
444
+ previousVersion: string;
445
+ changes: SchemaChange<any>[];
446
+ dryRun?: boolean;
447
+ } | {
448
+ type: "migration:ended";
449
+ currentVersion: string;
450
+ status: "committed" | "rolledBack";
451
+ };
452
+ /**
453
+ * Schema interface for managing schema evolution.
454
+ * @template T The type of data associated with the schema.
455
+ */
456
+ interface Schema<T = any> {
457
+ /**
458
+ * Subscribes to schema events. The listener will be called for each event.
459
+ * @param event The type of schema event to subscribe to.
460
+ * @param listener The listener function that receives the schema event.
461
+ * @returns A function that, when called, unsubscribes the listener.
462
+ */
463
+ subscribe(event: SchemaEventType, listener: (event: SchemaEvent) => void): () => void;
464
+ /**
465
+ * Returns a read-only copy of the schema definition.
466
+ * @returns A read-only version of the current schema definition.
467
+ */
468
+ definition(): Readonly<SchemaDefinition>;
469
+ /**
470
+ * Returns a promise that resolves to a read-only copy of the migration history.
471
+ * @returns A promise that resolves to a read-only array of migrations.
472
+ */
473
+ migrations(): Promise<Readonly<Migration<any>[]>>;
474
+ /**
475
+ * Exports the schema state (definition and migrations) as a JSON string.
476
+ * @returns A JSON string representation of the schema state.
477
+ */
478
+ export(): string;
479
+ /**
480
+ * Imports the schema state (definition and migrations) from a JSON string.
481
+ * @param json The JSON string representing the schema state to import.
482
+ * @throws Error if the imported state is invalid.
483
+ */
484
+ import(json: string): void;
485
+ /**
486
+ * Creates a migration from a list of changes.
487
+ * @param description A description of the migration.
488
+ * @param changes A list of schema changes to apply.
489
+ * @param dryRun Indicates whether the migration should actually be executed
490
+ * @throws Error if the changes are not valid.
491
+ * @returns A promise that resolves when the migration is complete.
492
+ */
493
+ migrate(description: string, changes: SchemaChange<T>[], dryRun?: boolean): Promise<void>;
494
+ /**
495
+ * Rolls back a migration.
496
+ * @param version The version to rollback from. If not specified, rolls back the last migration.
497
+ * @throws Error if the rollback cannot be performed.
498
+ * @returns A promise that resolves when the rollback is complete.
499
+ */
500
+ rollback(version?: string): Promise<void>;
501
+ /**
502
+ * Creates a migration helper to assist in creating a migration.
503
+ * @param description A description of the migration.
504
+ * @returns A `SchemaMigrationHelper` instance to build the migration.
505
+ */
506
+ migrationHelper(description: string): SchemaMigrationHelper;
507
+ }
416
508
  /**
417
509
  * Helper for building schema migrations.
418
510
  * @template T The type of data associated with the schema.
@@ -765,6 +857,190 @@ declare enum MigrationErrorCode {
765
857
  ROLLBACK_ERROR = "ROLLBACK_ERROR",
766
858
  MISSING_TRANSFORM = "MISSING_TRANSFORM"
767
859
  }
860
+ /**
861
+ * @class MigrationEngine
862
+ * @param {SchemaDefinition} currentSchema - The current schema definition
863
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
864
+ * @throws {MigrationError} If the initial schema or migrations are invalid
865
+ */
866
+ declare class MigrationEngine {
867
+ private currentSchema;
868
+ private history;
869
+ private migrations;
870
+ private isProcessing;
871
+ /**
872
+ * @constructor
873
+ * @param {SchemaDefinition} currentSchema - The current schema definition
874
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
875
+ */
876
+ constructor(currentSchema: SchemaDefinition, migrations?: Array<Migration<any>>, history?: Array<SchemaDefinition>);
877
+ /**
878
+ * Gets the current state of the migration helper
879
+ * @returns {Object} Current state containing schema, history, and migrations
880
+ * @example
881
+ * ```javascript
882
+ * const state = migrationEngine.data();
883
+ * // state contains currentSchema, history, and migrations
884
+ * ```
885
+ */
886
+ data(): {
887
+ schema: SchemaDefinition;
888
+ history: SchemaDefinition[];
889
+ migrations: Migration<any>[];
890
+ };
891
+ /**
892
+ * Generates a SHA-256 checksum for a migration
893
+ * @private
894
+ * @param {Omit<Migration<any>, "checksum">} migration - The migration object
895
+ * @returns {Promise<string>} The generated checksum
896
+ * @throws {MigrationError} If checksum generation fails
897
+ */
898
+ private generateChecksum;
899
+ /**
900
+ * Adds a new migration to the engine
901
+ * @async
902
+ * @param {Object} opts - Options for the new migration
903
+ * @param {SchemaChange<any>[]} opts.changes - Array of schema changes
904
+ * @param {string} opts.description - Description of the migration
905
+ * @param {SchemaChange<any>[]} [opts.rollback] - Optional rollback changes
906
+ * @param {DataTransform<any, any>} [opts.transform] - Optional data transform
907
+ * @throws {MigrationError} If adding the migration fails
908
+ */
909
+ add(opts: {
910
+ changes: SchemaChange<any>[];
911
+ description: string;
912
+ rollback?: SchemaChange<any>[];
913
+ transform?: string | DataTransform<any, any>;
914
+ }): Promise<void>;
915
+ /**
916
+ * Performs a dry run of the migration
917
+ * @async
918
+ * @param {ReadableStream<any>} input - Input data stream
919
+ * @param {"forward" | "backward"} direction - Direction of migration
920
+ * @param {version} version - Version to rollback to
921
+ * @returns {Promise<Object>} Object containing newSchema and dataPreview
922
+ * @throws {MigrationError} If dry run fails
923
+ */
924
+ dryRun(input: ReadableStream<any>, direction: "forward" | "backward", version?: string): Promise<{
925
+ newSchema: SchemaDefinition;
926
+ dataPreview: ReadableStream<any>;
927
+ }>;
928
+ /**
929
+ * Gets relevant migrations based on direction
930
+ * @private
931
+ * @param {"forward" | "backward"} direction - Direction of migration
932
+ * @returns {Array<Migration<any>>} Relevant migrations
933
+ */
934
+ private getRelevantMigrations;
935
+ /**
936
+ * Applies schema changes to a given schema
937
+ * @private
938
+ * @param {SchemaDefinition} schema - The schema to modify
939
+ * @param {SchemaChange<any>[]} changes - Array of schema changes
940
+ * @param {string} [migrationId] - ID of the migration
941
+ * @returns {SchemaDefinition} Modified schema
942
+ * @throws {MigrationError} If applying changes fails
943
+ */
944
+ private applySchemaChanges;
945
+ /**
946
+ * Prepares the list of pending migrations for application
947
+ * @async
948
+ * @returns {Promise<Array<Migration<any>>} List of pending migrations
949
+ * @throws {MigrationError} If preparation fails
950
+ */
951
+ prepareMigration(): Promise<Array<Migration<any>>>;
952
+ /**
953
+ * Applies pending migrations
954
+ * @async
955
+ * @param {ReadableStream<any>} input - Input data stream
956
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
957
+ * @throws {MigrationError} If migration fails
958
+ */
959
+ migrate(input: ReadableStream<any>): Promise<ReadableStream<any>>;
960
+ /**
961
+ * Validates migrations by checking their checksums
962
+ * @private
963
+ * @async
964
+ * @param {Array<Migration<any>>} migrations - Migrations to validate
965
+ * @throws {MigrationError} If validation fails
966
+ */
967
+ private validateMigrations;
968
+ /**
969
+ * Marks migrations as applied
970
+ * @private
971
+ * @param {Array<Migration<any>>} migrations - Migrations to mark as applied
972
+ */
973
+ private markMigrationsApplied;
974
+ /**
975
+ * Rolls back the last applied migration
976
+ * @async
977
+ * @param {ReadableStream<any>} input - Input data stream
978
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
979
+ */
980
+ rollback(input: ReadableStream<any>): Promise<ReadableStream<any>>;
981
+ /**
982
+ * Rolls back to a specific schema version
983
+ * @async
984
+ * @param {string} targetVersion - Target schema version
985
+ * @param {ReadableStream<any>} input - Input data stream
986
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
987
+ * @throws {Error} If target version is not found
988
+ */
989
+ rollbackToVersion(targetVersion: string, input: ReadableStream<any>): Promise<ReadableStream<any>>;
990
+ /**
991
+ * Processes a list of migrations on a data stream, applying transformations
992
+ * in the specified direction (forward or backward).
993
+ *
994
+ * @static
995
+ * @async
996
+ * @param {ReadableStream<any>} input - The input data stream to process
997
+ * @param {"forward" | "backward"} direction - Direction of migration (either "forward" or "backward")
998
+ * @param {Array<Migration<any>>} migrations - Array of Migration objects to process
999
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
1000
+ * @throws {MigrationError} If any migration processing fails
1001
+ */
1002
+ static processMigrationList(input: ReadableStream<any>, direction: "forward" | "backward", migrations: Migration<any>[]): Promise<ReadableStream<any>>;
1003
+ /**
1004
+ * Resolves the transform function for a given migration in the specified direction.
1005
+ *
1006
+ * @private
1007
+ * @async
1008
+ * @param {Migration<any>} migration - The migration to resolve the transform for
1009
+ * @param {"forward" | "backward"} direction - Direction of migration
1010
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1011
+ * @throws {MigrationError} If transform resolution fails
1012
+ */
1013
+ private static resolveTransform;
1014
+ /**
1015
+ * Resolves a transform function from a remote URL.
1016
+ *
1017
+ * @private
1018
+ * @async
1019
+ * @param {string} url - URL of the transform module
1020
+ * @param {"forward" | "backward"} direction - Direction of migration
1021
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1022
+ * @throws {MigrationError} If resolution fails
1023
+ */
1024
+ private static resolveRemoteTransform;
1025
+ /**
1026
+ * Resolves a transform function from a local module path.
1027
+ *
1028
+ * @private
1029
+ * @async
1030
+ * @param {string} path - Local module path
1031
+ * @param {"forward" | "backward"} direction - Direction of migration
1032
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1033
+ * @throws {MigrationError} If resolution fails
1034
+ */
1035
+ private static resolveLocalTransform;
1036
+ /**
1037
+ * Transforms the schema either forward or backward
1038
+ * @private
1039
+ * @param {"forward" | "backward"} direction - Direction of transformation
1040
+ * @throws {Error} If transformation fails
1041
+ */
1042
+ private transformSchema;
1043
+ }
768
1044
 
769
1045
  /**
770
1046
  * Helper for building schema migrations with forward and rollback changes.
@@ -1600,4 +1876,8 @@ declare function compareSemanticVersions(a: string, b: string): number;
1600
1876
  */
1601
1877
  declare function sortSemanticVars(vars: string[]): string[];
1602
1878
 
1603
- export { type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type FieldDefinition, type FieldType, type FunctionMap, type IndexDefinition, type IndexType, JsonPatchError, type LogicalOperator, type Migration, type MigrationEngine, MigrationError, MigrationErrorCode, type MigrationMetadata, MigrationSchema, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaIndex, type SchemaMetadata, type SchemaRegistry, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaToTypes, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };
1879
+ declare function docgen(schema: SchemaDefinition, options?: {
1880
+ faker?: Faker;
1881
+ }): string;
1882
+
1883
+ export { type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type FieldDefinition, type FieldType, type FunctionMap, type IndexDefinition, type IndexType, JsonPatchError, type LogicalOperator, type Migration, MigrationEngine, type MigrationEngineInterface, MigrationError, MigrationErrorCode, type MigrationMetadata, MigrationSchema, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, type SchemaRegistry, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaToTypes, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };