@asaidimu/anansi 8.6.5 → 8.6.7

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.
package/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "@asaidimu/query";
2
+ import "@standard-schema/spec";
2
3
  //#region src/schema/generated.d.ts
3
4
  type ComparisonOperator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte" | "in" | "nin" | "contains" | "ncontains" | "exists" | "nexists";
4
5
  type Constraint = ConstraintMetadata & ConstraintUnion;
@@ -399,6 +400,207 @@ declare class AnansiCodec {
399
400
  encodeColumnar(docs: Record<string, unknown>[]): Promise<Uint8Array>;
400
401
  }
401
402
  //#endregion
403
+ //#region src/schema/migration.d.ts
404
+ /**
405
+ * Partial update semantics:
406
+ * - `undefined` → no change
407
+ * - `null` → clear/remove the property
408
+ * - `value` → set to the provided value
409
+ */
410
+ type Patch<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
411
+ type FieldPatch = Patch<FieldDefinition, "name" | "type">;
412
+ type ConstraintPatch = Patch<Constraint, "name">;
413
+ type IndexPatch = Patch<IndexDefinition, "name">;
414
+ type SchemaChange = {
415
+ type: "modifyProperty";
416
+ id: keyof SchemaDefinition | "version";
417
+ value: unknown;
418
+ } | {
419
+ type: "addField";
420
+ id: string;
421
+ definition: FieldDefinition;
422
+ } | {
423
+ type: "removeField";
424
+ id: string;
425
+ } | {
426
+ type: "modifyField";
427
+ id: string;
428
+ changes: FieldPatch;
429
+ } | {
430
+ type: "addIndex";
431
+ id: string;
432
+ definition: IndexDefinition;
433
+ } | {
434
+ type: "removeIndex";
435
+ id: string;
436
+ } | {
437
+ type: "modifyIndex";
438
+ id: string;
439
+ changes: IndexPatch;
440
+ } | {
441
+ type: "addConstraint";
442
+ id: string;
443
+ constraint: Constraint;
444
+ } | {
445
+ type: "removeConstraint";
446
+ id: string;
447
+ } | {
448
+ type: "modifyConstraint";
449
+ id: string;
450
+ changes: ConstraintPatch;
451
+ } | {
452
+ type: "addSchema";
453
+ id: string;
454
+ definition: NonNullable<SchemaDefinition["schemas"]>[string];
455
+ } | {
456
+ type: "removeSchema";
457
+ id: string;
458
+ } | {
459
+ type: "modifySchema";
460
+ id: string;
461
+ changes: SchemaChange[];
462
+ };
463
+ type TransformFunction<Initial, Next> = (ctx: unknown, data: Initial) => Next | Promise<Next>;
464
+ interface DataTransform<Initial = unknown, Next = unknown> {
465
+ forward: TransformFunction<Initial, Next>;
466
+ backward: TransformFunction<Next, Initial>;
467
+ }
468
+ interface Migration<Initial = unknown, Next = unknown> {
469
+ id: string;
470
+ schemaVersion: string;
471
+ changes: SchemaChange[];
472
+ description: string;
473
+ status?: "pending" | "applied" | "rolled_back";
474
+ rollback?: SchemaChange[];
475
+ transform?: string | DataTransform<Initial, Next>;
476
+ createdAt: string;
477
+ dependencies?: string[];
478
+ checksum: string;
479
+ }
480
+ interface PatchOp {
481
+ op: "add" | "remove" | "replace" | "move" | "copy" | "test";
482
+ path: string;
483
+ value?: unknown;
484
+ from?: string;
485
+ }
486
+ /**
487
+ * Convert a `SchemaChange` into one or more RFC 6902 JSON Patch operations
488
+ * that can be applied to a `SchemaDefinition` object.
489
+ */
490
+ declare function schemaChangeToPatch(change: SchemaChange, schema: SchemaDefinition): PatchOp[];
491
+ type ChangeImpact = "major" | "minor" | "patch";
492
+ /**
493
+ * Classify the semver impact of a single schema change.
494
+ *
495
+ * - `major` — field/index/constraint removal, breaking field changes (type
496
+ * change, required added, unique added, nested schema changed)
497
+ * - `minor` — field/index/constraint addition, deprecation
498
+ * - `patch` — non-breaking field/constraint modifications
499
+ */
500
+ declare function classifyChangeImpact(change: SchemaChange, currentSchema?: SchemaDefinition): ChangeImpact;
501
+ /**
502
+ * Calculate the next semver version from a set of schema changes.
503
+ *
504
+ * Returns `"major"`, `"minor"`, or `"patch"` as the bump kind.
505
+ * The caller applies it to the current version string.
506
+ */
507
+ declare function calculateNextBump(changes: SchemaChange[], currentSchema?: SchemaDefinition): ChangeImpact;
508
+ /**
509
+ * Bump a semver string by the given kind.
510
+ */
511
+ declare function bumpVersion(current: string, kind: ChangeImpact): string;
512
+ //#endregion
513
+ //#region src/engine.d.ts
514
+ declare enum MigrationErrorCode {
515
+ INVALID_SCHEMA = "INVALID_SCHEMA",
516
+ INVALID_MIGRATION = "INVALID_MIGRATION",
517
+ CHECKSUM_MISMATCH = "CHECKSUM_MISMATCH",
518
+ TIMEOUT = "TIMEOUT",
519
+ MEMORY_LIMIT = "MEMORY_LIMIT",
520
+ CONCURRENT_OPERATION = "CONCURRENT_OPERATION",
521
+ TRANSFORM_ERROR = "TRANSFORM_ERROR",
522
+ VERSION_NOT_FOUND = "VERSION_NOT_FOUND",
523
+ CIRCULAR_DEPENDENCY = "CIRCULAR_DEPENDENCY",
524
+ STREAM_ERROR = "STREAM_ERROR",
525
+ ROLLBACK_ERROR = "ROLLBACK_ERROR",
526
+ MISSING_TRANSFORM = "MISSING_TRANSFORM"
527
+ }
528
+ declare class MigrationError extends Error {
529
+ readonly code: MigrationErrorCode;
530
+ readonly migrationId?: string | undefined;
531
+ readonly cause?: Error | undefined;
532
+ constructor(message: string, code: MigrationErrorCode, migrationId?: string | undefined, cause?: Error | undefined);
533
+ }
534
+ interface EngineState {
535
+ schema: SchemaDefinition;
536
+ migrations: Migration[];
537
+ history: SchemaDefinition[];
538
+ }
539
+ interface DryRunResult {
540
+ newSchema: SchemaDefinition;
541
+ dataPreview: ReadableStream<any>;
542
+ }
543
+ declare class MigrationEngine {
544
+ private currentSchema;
545
+ private history;
546
+ private migrations;
547
+ private isProcessing;
548
+ constructor(currentSchema: SchemaDefinition, migrations?: Array<Migration<any>>, history?: Array<SchemaDefinition>);
549
+ data(): EngineState;
550
+ add(opts: {
551
+ changes: SchemaChange[];
552
+ description: string;
553
+ rollback?: SchemaChange[];
554
+ transform?: string | DataTransform<any, any>;
555
+ }): Promise<void>;
556
+ /**
557
+ * Dry-run: simulate migration without modifying internal state.
558
+ * Returns the projected schema and a data preview stream.
559
+ */
560
+ dryRun(input: ReadableStream<any>, direction: "forward" | "backward", version?: string): Promise<DryRunResult>;
561
+ /**
562
+ * Prepare pending migrations: validate checksums, return the list.
563
+ */
564
+ prepareMigration(): Promise<Array<Migration<any>>>;
565
+ /**
566
+ * Apply pending migrations. Takes an input data stream and returns
567
+ * a transformed stream with all migration transforms applied.
568
+ */
569
+ migrate(input: ReadableStream<any>): Promise<ReadableStream<any>>;
570
+ /**
571
+ * Roll back the last applied migration.
572
+ */
573
+ rollback(input: ReadableStream<any>): Promise<ReadableStream<any>>;
574
+ /**
575
+ * Roll back to a specific schema version.
576
+ */
577
+ rollbackToVersion(targetVersion: string, input: ReadableStream<any>): Promise<ReadableStream<any>>;
578
+ /**
579
+ * Process a list of migrations on a data stream, applying transforms
580
+ * in the specified direction (forward or backward).
581
+ */
582
+ static processMigrationList(input: ReadableStream<any>, direction: "forward" | "backward", migrations: Migration<any>[]): Promise<ReadableStream<any>>;
583
+ private getRelevantMigrations;
584
+ private applySchemaChanges;
585
+ private validateMigrations;
586
+ private markMigrationsApplied;
587
+ private transformSchema;
588
+ }
589
+ //#endregion
590
+ //#region src/utils.d.ts
591
+ /**
592
+ * Deep-merge `update` into `target`, returning a new object.
593
+ * Arrays are replaced, not merged.
594
+ */
595
+ declare function deepMerge<T extends Record<string, unknown>>(target: T, update: Partial<T>): T;
596
+ /**
597
+ * Isomorphic SHA-256 hex digest.
598
+ *
599
+ * Uses `globalThis.crypto.subtle` when available (browsers, Node 20+,
600
+ * Bun, Deno), falls back to `node:crypto` for older Node runtimes.
601
+ */
602
+ declare function sha256(input: string): Promise<string>;
603
+ //#endregion
402
604
  //#region src/validation/types/hints.d.ts
403
605
  /**
404
606
  * hints.ts
@@ -750,7 +952,7 @@ interface SchemaDefinition$1 extends NamedMetadata {
750
952
  * Optional data migration definitions.
751
953
  * @extension
752
954
  */
753
- migrations?: Array<Migration>;
955
+ migrations?: Array<Migration$1>;
754
956
  /**
755
957
  * UI/input hints.
756
958
  * @extension
@@ -783,11 +985,11 @@ interface SchemaDefinition$1 extends NamedMetadata {
783
985
  * - `null`: Clear/remove the property (if allowed by NonNullable).
784
986
  * - `value`: Set the property to the provided value.
785
987
  */
786
- type Patch<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
787
- type FieldPatch = Patch<FieldDefinition$1, "name" | "type">;
788
- type ConstraintPatch = Patch<Constraint$1, "name">;
789
- type IndexPatch = Patch<IndexDefinition$1, "name">;
790
- type SchemaChange = {
988
+ type Patch$1<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
989
+ type FieldPatch$1 = Patch$1<FieldDefinition$1, "name" | "type">;
990
+ type ConstraintPatch$1 = Patch$1<Constraint$1, "name">;
991
+ type IndexPatch$1 = Patch$1<IndexDefinition$1, "name">;
992
+ type SchemaChange$1 = {
791
993
  type: "modifyProperty";
792
994
  id: keyof NamedMetadata | "version";
793
995
  value: any;
@@ -801,7 +1003,7 @@ type SchemaChange = {
801
1003
  } | {
802
1004
  type: "modifyField";
803
1005
  id: string;
804
- changes: FieldPatch;
1006
+ changes: FieldPatch$1;
805
1007
  } | {
806
1008
  type: "addIndex";
807
1009
  id: string;
@@ -812,7 +1014,7 @@ type SchemaChange = {
812
1014
  } | {
813
1015
  type: "modifyIndex";
814
1016
  id: string;
815
- changes: IndexPatch;
1017
+ changes: IndexPatch$1;
816
1018
  } | {
817
1019
  type: "addConstraint";
818
1020
  id: string;
@@ -823,7 +1025,7 @@ type SchemaChange = {
823
1025
  } | {
824
1026
  type: "modifyConstraint";
825
1027
  id: string;
826
- changes: ConstraintPatch;
1028
+ changes: ConstraintPatch$1;
827
1029
  } | {
828
1030
  type: "addSchema";
829
1031
  id: string;
@@ -834,23 +1036,23 @@ type SchemaChange = {
834
1036
  } | {
835
1037
  type: "modifySchema";
836
1038
  id: string;
837
- changes: Array<SchemaChange>;
1039
+ changes: Array<SchemaChange$1>;
838
1040
  };
839
- type TransformFunction<Initial, Next> = (ctx: any, data: Initial) => Next | Promise<Next>;
840
- interface DataTransform<Initial, Next> {
841
- forward: TransformFunction<Initial, Next>;
842
- backward: TransformFunction<Next, Initial>;
1041
+ type TransformFunction$1<Initial, Next> = (ctx: any, data: Initial) => Next | Promise<Next>;
1042
+ interface DataTransform$1<Initial, Next> {
1043
+ forward: TransformFunction$1<Initial, Next>;
1044
+ backward: TransformFunction$1<Next, Initial>;
843
1045
  }
844
- interface Migration<Initial = any, Next = any> {
1046
+ interface Migration$1<Initial = any, Next = any> {
845
1047
  id: string;
846
1048
  version: {
847
1049
  source: string;
848
1050
  target?: string;
849
1051
  };
850
- changes: SchemaChange[];
1052
+ changes: SchemaChange$1[];
851
1053
  description: string;
852
- rollback?: SchemaChange[];
853
- transform: string | DataTransform<Initial, Next>;
1054
+ rollback?: SchemaChange$1[];
1055
+ transform: string | DataTransform$1<Initial, Next>;
854
1056
  createdAt: string;
855
1057
  dependencies?: string[];
856
1058
  checksum: string;
@@ -1078,4 +1280,4 @@ declare class SchemaValidator {
1078
1280
  //#region src/validation/predicates.d.ts
1079
1281
  declare const metaSchemaPredicateMap: PredicateMap;
1080
1282
  //#endregion
1081
- export { AnansiCodec, type AnansiCodecOptions, ComparisonOperator, Compiler, Constraint, ConstraintGroup, ConstraintMetadata, ConstraintRule, ConstraintUnion, container as DataTypes, type DecodeTransforms, DocumentValidator, type EncodeKind, type EncodeTransforms, FD_NO_CHILD, FLAG_COMPRESSED, FLAG_ENCRYPTED, FLAG_HASH_PRESENT, FieldDef, FieldDefinition, type FieldDescriptor, FieldType, IndexCondition, IndexConditionGroup, IndexConditionUnion, IndexDefinition, IndexOrder, IndexType, InlineTypeDescriptor, InlineTypeKind, type Issue, type LinkResult, type LinkedField, type LinkedSlot, Literal, LogicalOperatorEnum, MAX_SCHEMA_SLOTS, MULTI_STEP_BASE, type ManifestField, NestedSchemaDefinition, type PredicateMap, type ResolvedEnum, type ResolvedField, type ResolvedNested, SchemaDefinition, SchemaReference, SchemaReferenceArray, SchemaValidator, type Slot, String, Unknown, type ValidationConfig, addressForSteps, buildEnum, buildManifest, decodeAnansiBatch, decodeAnansiPacket, decodeBatch, decodeDocument, defaultValidationConfig, encodeAnansiBatchColumnar, encodeAnansiBatchRows, encodeAnansiPacket, encodeBatchColumnar, encodeBatchRows, encodeDocument, internalDP, link, makeDescriptor, metaSchemaPredicateMap, parseSchema, unpackDescriptor, userDataDP };
1283
+ export { AnansiCodec, type AnansiCodecOptions, type ChangeImpact, ComparisonOperator, Compiler, Constraint, ConstraintGroup, ConstraintMetadata, type ConstraintPatch, ConstraintRule, ConstraintUnion, type DataTransform, container as DataTypes, type DecodeTransforms, DocumentValidator, type DryRunResult, type EncodeKind, type EncodeTransforms, type EngineState, FD_NO_CHILD, FLAG_COMPRESSED, FLAG_ENCRYPTED, FLAG_HASH_PRESENT, FieldDef, FieldDefinition, type FieldDescriptor, type FieldPatch, FieldType, IndexCondition, IndexConditionGroup, IndexConditionUnion, IndexDefinition, IndexOrder, type IndexPatch, IndexType, InlineTypeDescriptor, InlineTypeKind, type Issue, type LinkResult, type LinkedField, type LinkedSlot, Literal, LogicalOperatorEnum, MAX_SCHEMA_SLOTS, MULTI_STEP_BASE, type ManifestField, type Migration, MigrationEngine, MigrationError, MigrationErrorCode, NestedSchemaDefinition, type Patch, type PatchOp, type PredicateMap, type ResolvedEnum, type ResolvedField, type ResolvedNested, type SchemaChange, SchemaDefinition, SchemaReference, SchemaReferenceArray, SchemaValidator, type Slot, String, type TransformFunction, Unknown, type ValidationConfig, addressForSteps, buildEnum, buildManifest, bumpVersion, calculateNextBump, classifyChangeImpact, decodeAnansiBatch, decodeAnansiPacket, decodeBatch, decodeDocument, deepMerge, defaultValidationConfig, encodeAnansiBatchColumnar, encodeAnansiBatchRows, encodeAnansiPacket, encodeBatchColumnar, encodeBatchRows, encodeDocument, internalDP, link, makeDescriptor, metaSchemaPredicateMap, parseSchema, schemaChangeToPatch, sha256, unpackDescriptor, userDataDP };
package/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "@asaidimu/query";
2
+ import "@standard-schema/spec";
2
3
  //#region src/schema/generated.d.ts
3
4
  type ComparisonOperator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte" | "in" | "nin" | "contains" | "ncontains" | "exists" | "nexists";
4
5
  type Constraint = ConstraintMetadata & ConstraintUnion;
@@ -399,6 +400,207 @@ declare class AnansiCodec {
399
400
  encodeColumnar(docs: Record<string, unknown>[]): Promise<Uint8Array>;
400
401
  }
401
402
  //#endregion
403
+ //#region src/schema/migration.d.ts
404
+ /**
405
+ * Partial update semantics:
406
+ * - `undefined` → no change
407
+ * - `null` → clear/remove the property
408
+ * - `value` → set to the provided value
409
+ */
410
+ type Patch<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
411
+ type FieldPatch = Patch<FieldDefinition, "name" | "type">;
412
+ type ConstraintPatch = Patch<Constraint, "name">;
413
+ type IndexPatch = Patch<IndexDefinition, "name">;
414
+ type SchemaChange = {
415
+ type: "modifyProperty";
416
+ id: keyof SchemaDefinition | "version";
417
+ value: unknown;
418
+ } | {
419
+ type: "addField";
420
+ id: string;
421
+ definition: FieldDefinition;
422
+ } | {
423
+ type: "removeField";
424
+ id: string;
425
+ } | {
426
+ type: "modifyField";
427
+ id: string;
428
+ changes: FieldPatch;
429
+ } | {
430
+ type: "addIndex";
431
+ id: string;
432
+ definition: IndexDefinition;
433
+ } | {
434
+ type: "removeIndex";
435
+ id: string;
436
+ } | {
437
+ type: "modifyIndex";
438
+ id: string;
439
+ changes: IndexPatch;
440
+ } | {
441
+ type: "addConstraint";
442
+ id: string;
443
+ constraint: Constraint;
444
+ } | {
445
+ type: "removeConstraint";
446
+ id: string;
447
+ } | {
448
+ type: "modifyConstraint";
449
+ id: string;
450
+ changes: ConstraintPatch;
451
+ } | {
452
+ type: "addSchema";
453
+ id: string;
454
+ definition: NonNullable<SchemaDefinition["schemas"]>[string];
455
+ } | {
456
+ type: "removeSchema";
457
+ id: string;
458
+ } | {
459
+ type: "modifySchema";
460
+ id: string;
461
+ changes: SchemaChange[];
462
+ };
463
+ type TransformFunction<Initial, Next> = (ctx: unknown, data: Initial) => Next | Promise<Next>;
464
+ interface DataTransform<Initial = unknown, Next = unknown> {
465
+ forward: TransformFunction<Initial, Next>;
466
+ backward: TransformFunction<Next, Initial>;
467
+ }
468
+ interface Migration<Initial = unknown, Next = unknown> {
469
+ id: string;
470
+ schemaVersion: string;
471
+ changes: SchemaChange[];
472
+ description: string;
473
+ status?: "pending" | "applied" | "rolled_back";
474
+ rollback?: SchemaChange[];
475
+ transform?: string | DataTransform<Initial, Next>;
476
+ createdAt: string;
477
+ dependencies?: string[];
478
+ checksum: string;
479
+ }
480
+ interface PatchOp {
481
+ op: "add" | "remove" | "replace" | "move" | "copy" | "test";
482
+ path: string;
483
+ value?: unknown;
484
+ from?: string;
485
+ }
486
+ /**
487
+ * Convert a `SchemaChange` into one or more RFC 6902 JSON Patch operations
488
+ * that can be applied to a `SchemaDefinition` object.
489
+ */
490
+ declare function schemaChangeToPatch(change: SchemaChange, schema: SchemaDefinition): PatchOp[];
491
+ type ChangeImpact = "major" | "minor" | "patch";
492
+ /**
493
+ * Classify the semver impact of a single schema change.
494
+ *
495
+ * - `major` — field/index/constraint removal, breaking field changes (type
496
+ * change, required added, unique added, nested schema changed)
497
+ * - `minor` — field/index/constraint addition, deprecation
498
+ * - `patch` — non-breaking field/constraint modifications
499
+ */
500
+ declare function classifyChangeImpact(change: SchemaChange, currentSchema?: SchemaDefinition): ChangeImpact;
501
+ /**
502
+ * Calculate the next semver version from a set of schema changes.
503
+ *
504
+ * Returns `"major"`, `"minor"`, or `"patch"` as the bump kind.
505
+ * The caller applies it to the current version string.
506
+ */
507
+ declare function calculateNextBump(changes: SchemaChange[], currentSchema?: SchemaDefinition): ChangeImpact;
508
+ /**
509
+ * Bump a semver string by the given kind.
510
+ */
511
+ declare function bumpVersion(current: string, kind: ChangeImpact): string;
512
+ //#endregion
513
+ //#region src/engine.d.ts
514
+ declare enum MigrationErrorCode {
515
+ INVALID_SCHEMA = "INVALID_SCHEMA",
516
+ INVALID_MIGRATION = "INVALID_MIGRATION",
517
+ CHECKSUM_MISMATCH = "CHECKSUM_MISMATCH",
518
+ TIMEOUT = "TIMEOUT",
519
+ MEMORY_LIMIT = "MEMORY_LIMIT",
520
+ CONCURRENT_OPERATION = "CONCURRENT_OPERATION",
521
+ TRANSFORM_ERROR = "TRANSFORM_ERROR",
522
+ VERSION_NOT_FOUND = "VERSION_NOT_FOUND",
523
+ CIRCULAR_DEPENDENCY = "CIRCULAR_DEPENDENCY",
524
+ STREAM_ERROR = "STREAM_ERROR",
525
+ ROLLBACK_ERROR = "ROLLBACK_ERROR",
526
+ MISSING_TRANSFORM = "MISSING_TRANSFORM"
527
+ }
528
+ declare class MigrationError extends Error {
529
+ readonly code: MigrationErrorCode;
530
+ readonly migrationId?: string | undefined;
531
+ readonly cause?: Error | undefined;
532
+ constructor(message: string, code: MigrationErrorCode, migrationId?: string | undefined, cause?: Error | undefined);
533
+ }
534
+ interface EngineState {
535
+ schema: SchemaDefinition;
536
+ migrations: Migration[];
537
+ history: SchemaDefinition[];
538
+ }
539
+ interface DryRunResult {
540
+ newSchema: SchemaDefinition;
541
+ dataPreview: ReadableStream<any>;
542
+ }
543
+ declare class MigrationEngine {
544
+ private currentSchema;
545
+ private history;
546
+ private migrations;
547
+ private isProcessing;
548
+ constructor(currentSchema: SchemaDefinition, migrations?: Array<Migration<any>>, history?: Array<SchemaDefinition>);
549
+ data(): EngineState;
550
+ add(opts: {
551
+ changes: SchemaChange[];
552
+ description: string;
553
+ rollback?: SchemaChange[];
554
+ transform?: string | DataTransform<any, any>;
555
+ }): Promise<void>;
556
+ /**
557
+ * Dry-run: simulate migration without modifying internal state.
558
+ * Returns the projected schema and a data preview stream.
559
+ */
560
+ dryRun(input: ReadableStream<any>, direction: "forward" | "backward", version?: string): Promise<DryRunResult>;
561
+ /**
562
+ * Prepare pending migrations: validate checksums, return the list.
563
+ */
564
+ prepareMigration(): Promise<Array<Migration<any>>>;
565
+ /**
566
+ * Apply pending migrations. Takes an input data stream and returns
567
+ * a transformed stream with all migration transforms applied.
568
+ */
569
+ migrate(input: ReadableStream<any>): Promise<ReadableStream<any>>;
570
+ /**
571
+ * Roll back the last applied migration.
572
+ */
573
+ rollback(input: ReadableStream<any>): Promise<ReadableStream<any>>;
574
+ /**
575
+ * Roll back to a specific schema version.
576
+ */
577
+ rollbackToVersion(targetVersion: string, input: ReadableStream<any>): Promise<ReadableStream<any>>;
578
+ /**
579
+ * Process a list of migrations on a data stream, applying transforms
580
+ * in the specified direction (forward or backward).
581
+ */
582
+ static processMigrationList(input: ReadableStream<any>, direction: "forward" | "backward", migrations: Migration<any>[]): Promise<ReadableStream<any>>;
583
+ private getRelevantMigrations;
584
+ private applySchemaChanges;
585
+ private validateMigrations;
586
+ private markMigrationsApplied;
587
+ private transformSchema;
588
+ }
589
+ //#endregion
590
+ //#region src/utils.d.ts
591
+ /**
592
+ * Deep-merge `update` into `target`, returning a new object.
593
+ * Arrays are replaced, not merged.
594
+ */
595
+ declare function deepMerge<T extends Record<string, unknown>>(target: T, update: Partial<T>): T;
596
+ /**
597
+ * Isomorphic SHA-256 hex digest.
598
+ *
599
+ * Uses `globalThis.crypto.subtle` when available (browsers, Node 20+,
600
+ * Bun, Deno), falls back to `node:crypto` for older Node runtimes.
601
+ */
602
+ declare function sha256(input: string): Promise<string>;
603
+ //#endregion
402
604
  //#region src/validation/types/hints.d.ts
403
605
  /**
404
606
  * hints.ts
@@ -750,7 +952,7 @@ interface SchemaDefinition$1 extends NamedMetadata {
750
952
  * Optional data migration definitions.
751
953
  * @extension
752
954
  */
753
- migrations?: Array<Migration>;
955
+ migrations?: Array<Migration$1>;
754
956
  /**
755
957
  * UI/input hints.
756
958
  * @extension
@@ -783,11 +985,11 @@ interface SchemaDefinition$1 extends NamedMetadata {
783
985
  * - `null`: Clear/remove the property (if allowed by NonNullable).
784
986
  * - `value`: Set the property to the provided value.
785
987
  */
786
- type Patch<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
787
- type FieldPatch = Patch<FieldDefinition$1, "name" | "type">;
788
- type ConstraintPatch = Patch<Constraint$1, "name">;
789
- type IndexPatch = Patch<IndexDefinition$1, "name">;
790
- type SchemaChange = {
988
+ type Patch$1<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
989
+ type FieldPatch$1 = Patch$1<FieldDefinition$1, "name" | "type">;
990
+ type ConstraintPatch$1 = Patch$1<Constraint$1, "name">;
991
+ type IndexPatch$1 = Patch$1<IndexDefinition$1, "name">;
992
+ type SchemaChange$1 = {
791
993
  type: "modifyProperty";
792
994
  id: keyof NamedMetadata | "version";
793
995
  value: any;
@@ -801,7 +1003,7 @@ type SchemaChange = {
801
1003
  } | {
802
1004
  type: "modifyField";
803
1005
  id: string;
804
- changes: FieldPatch;
1006
+ changes: FieldPatch$1;
805
1007
  } | {
806
1008
  type: "addIndex";
807
1009
  id: string;
@@ -812,7 +1014,7 @@ type SchemaChange = {
812
1014
  } | {
813
1015
  type: "modifyIndex";
814
1016
  id: string;
815
- changes: IndexPatch;
1017
+ changes: IndexPatch$1;
816
1018
  } | {
817
1019
  type: "addConstraint";
818
1020
  id: string;
@@ -823,7 +1025,7 @@ type SchemaChange = {
823
1025
  } | {
824
1026
  type: "modifyConstraint";
825
1027
  id: string;
826
- changes: ConstraintPatch;
1028
+ changes: ConstraintPatch$1;
827
1029
  } | {
828
1030
  type: "addSchema";
829
1031
  id: string;
@@ -834,23 +1036,23 @@ type SchemaChange = {
834
1036
  } | {
835
1037
  type: "modifySchema";
836
1038
  id: string;
837
- changes: Array<SchemaChange>;
1039
+ changes: Array<SchemaChange$1>;
838
1040
  };
839
- type TransformFunction<Initial, Next> = (ctx: any, data: Initial) => Next | Promise<Next>;
840
- interface DataTransform<Initial, Next> {
841
- forward: TransformFunction<Initial, Next>;
842
- backward: TransformFunction<Next, Initial>;
1041
+ type TransformFunction$1<Initial, Next> = (ctx: any, data: Initial) => Next | Promise<Next>;
1042
+ interface DataTransform$1<Initial, Next> {
1043
+ forward: TransformFunction$1<Initial, Next>;
1044
+ backward: TransformFunction$1<Next, Initial>;
843
1045
  }
844
- interface Migration<Initial = any, Next = any> {
1046
+ interface Migration$1<Initial = any, Next = any> {
845
1047
  id: string;
846
1048
  version: {
847
1049
  source: string;
848
1050
  target?: string;
849
1051
  };
850
- changes: SchemaChange[];
1052
+ changes: SchemaChange$1[];
851
1053
  description: string;
852
- rollback?: SchemaChange[];
853
- transform: string | DataTransform<Initial, Next>;
1054
+ rollback?: SchemaChange$1[];
1055
+ transform: string | DataTransform$1<Initial, Next>;
854
1056
  createdAt: string;
855
1057
  dependencies?: string[];
856
1058
  checksum: string;
@@ -1078,4 +1280,4 @@ declare class SchemaValidator {
1078
1280
  //#region src/validation/predicates.d.ts
1079
1281
  declare const metaSchemaPredicateMap: PredicateMap;
1080
1282
  //#endregion
1081
- export { AnansiCodec, type AnansiCodecOptions, ComparisonOperator, Compiler, Constraint, ConstraintGroup, ConstraintMetadata, ConstraintRule, ConstraintUnion, container as DataTypes, type DecodeTransforms, DocumentValidator, type EncodeKind, type EncodeTransforms, FD_NO_CHILD, FLAG_COMPRESSED, FLAG_ENCRYPTED, FLAG_HASH_PRESENT, FieldDef, FieldDefinition, type FieldDescriptor, FieldType, IndexCondition, IndexConditionGroup, IndexConditionUnion, IndexDefinition, IndexOrder, IndexType, InlineTypeDescriptor, InlineTypeKind, type Issue, type LinkResult, type LinkedField, type LinkedSlot, Literal, LogicalOperatorEnum, MAX_SCHEMA_SLOTS, MULTI_STEP_BASE, type ManifestField, NestedSchemaDefinition, type PredicateMap, type ResolvedEnum, type ResolvedField, type ResolvedNested, SchemaDefinition, SchemaReference, SchemaReferenceArray, SchemaValidator, type Slot, String, Unknown, type ValidationConfig, addressForSteps, buildEnum, buildManifest, decodeAnansiBatch, decodeAnansiPacket, decodeBatch, decodeDocument, defaultValidationConfig, encodeAnansiBatchColumnar, encodeAnansiBatchRows, encodeAnansiPacket, encodeBatchColumnar, encodeBatchRows, encodeDocument, internalDP, link, makeDescriptor, metaSchemaPredicateMap, parseSchema, unpackDescriptor, userDataDP };
1283
+ export { AnansiCodec, type AnansiCodecOptions, type ChangeImpact, ComparisonOperator, Compiler, Constraint, ConstraintGroup, ConstraintMetadata, type ConstraintPatch, ConstraintRule, ConstraintUnion, type DataTransform, container as DataTypes, type DecodeTransforms, DocumentValidator, type DryRunResult, type EncodeKind, type EncodeTransforms, type EngineState, FD_NO_CHILD, FLAG_COMPRESSED, FLAG_ENCRYPTED, FLAG_HASH_PRESENT, FieldDef, FieldDefinition, type FieldDescriptor, type FieldPatch, FieldType, IndexCondition, IndexConditionGroup, IndexConditionUnion, IndexDefinition, IndexOrder, type IndexPatch, IndexType, InlineTypeDescriptor, InlineTypeKind, type Issue, type LinkResult, type LinkedField, type LinkedSlot, Literal, LogicalOperatorEnum, MAX_SCHEMA_SLOTS, MULTI_STEP_BASE, type ManifestField, type Migration, MigrationEngine, MigrationError, MigrationErrorCode, NestedSchemaDefinition, type Patch, type PatchOp, type PredicateMap, type ResolvedEnum, type ResolvedField, type ResolvedNested, type SchemaChange, SchemaDefinition, SchemaReference, SchemaReferenceArray, SchemaValidator, type Slot, String, type TransformFunction, Unknown, type ValidationConfig, addressForSteps, buildEnum, buildManifest, bumpVersion, calculateNextBump, classifyChangeImpact, decodeAnansiBatch, decodeAnansiPacket, decodeBatch, decodeDocument, deepMerge, defaultValidationConfig, encodeAnansiBatchColumnar, encodeAnansiBatchRows, encodeAnansiPacket, encodeBatchColumnar, encodeBatchRows, encodeDocument, internalDP, link, makeDescriptor, metaSchemaPredicateMap, parseSchema, schemaChangeToPatch, sha256, unpackDescriptor, userDataDP };