@asaidimu/anansi 8.6.4 → 8.6.6
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.cjs +1 -1
- package/index.d.cts +192 -19
- package/index.d.mts +192 -19
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -399,6 +399,179 @@ declare class AnansiCodec {
|
|
|
399
399
|
encodeColumnar(docs: Record<string, unknown>[]): Promise<Uint8Array>;
|
|
400
400
|
}
|
|
401
401
|
//#endregion
|
|
402
|
+
//#region src/schema/migration.d.ts
|
|
403
|
+
/**
|
|
404
|
+
* Partial update semantics:
|
|
405
|
+
* - `undefined` → no change
|
|
406
|
+
* - `null` → clear/remove the property
|
|
407
|
+
* - `value` → set to the provided value
|
|
408
|
+
*/
|
|
409
|
+
type Patch<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
|
|
410
|
+
type FieldPatch = Patch<FieldDefinition, "name" | "type">;
|
|
411
|
+
type ConstraintPatch = Patch<Constraint, "name">;
|
|
412
|
+
type IndexPatch = Patch<IndexDefinition, "name">;
|
|
413
|
+
type SchemaChange = {
|
|
414
|
+
type: "modifyProperty";
|
|
415
|
+
id: keyof SchemaDefinition | "version";
|
|
416
|
+
value: unknown;
|
|
417
|
+
} | {
|
|
418
|
+
type: "addField";
|
|
419
|
+
id: string;
|
|
420
|
+
definition: FieldDefinition;
|
|
421
|
+
} | {
|
|
422
|
+
type: "removeField";
|
|
423
|
+
id: string;
|
|
424
|
+
} | {
|
|
425
|
+
type: "modifyField";
|
|
426
|
+
id: string;
|
|
427
|
+
changes: FieldPatch;
|
|
428
|
+
} | {
|
|
429
|
+
type: "addIndex";
|
|
430
|
+
id: string;
|
|
431
|
+
definition: IndexDefinition;
|
|
432
|
+
} | {
|
|
433
|
+
type: "removeIndex";
|
|
434
|
+
id: string;
|
|
435
|
+
} | {
|
|
436
|
+
type: "modifyIndex";
|
|
437
|
+
id: string;
|
|
438
|
+
changes: IndexPatch;
|
|
439
|
+
} | {
|
|
440
|
+
type: "addConstraint";
|
|
441
|
+
id: string;
|
|
442
|
+
constraint: Constraint;
|
|
443
|
+
} | {
|
|
444
|
+
type: "removeConstraint";
|
|
445
|
+
id: string;
|
|
446
|
+
} | {
|
|
447
|
+
type: "modifyConstraint";
|
|
448
|
+
id: string;
|
|
449
|
+
changes: ConstraintPatch;
|
|
450
|
+
} | {
|
|
451
|
+
type: "addSchema";
|
|
452
|
+
id: string;
|
|
453
|
+
definition: NonNullable<SchemaDefinition["schemas"]>[string];
|
|
454
|
+
} | {
|
|
455
|
+
type: "removeSchema";
|
|
456
|
+
id: string;
|
|
457
|
+
} | {
|
|
458
|
+
type: "modifySchema";
|
|
459
|
+
id: string;
|
|
460
|
+
changes: SchemaChange[];
|
|
461
|
+
};
|
|
462
|
+
type TransformFunction<Initial, Next> = (ctx: unknown, data: Initial) => Next | Promise<Next>;
|
|
463
|
+
interface DataTransform<Initial = unknown, Next = unknown> {
|
|
464
|
+
forward: TransformFunction<Initial, Next>;
|
|
465
|
+
backward: TransformFunction<Next, Initial>;
|
|
466
|
+
}
|
|
467
|
+
interface Migration<Initial = unknown, Next = unknown> {
|
|
468
|
+
id: string;
|
|
469
|
+
schemaVersion: string;
|
|
470
|
+
changes: SchemaChange[];
|
|
471
|
+
description: string;
|
|
472
|
+
status?: "pending" | "applied" | "rolled_back";
|
|
473
|
+
rollback?: SchemaChange[];
|
|
474
|
+
transform?: string | DataTransform<Initial, Next>;
|
|
475
|
+
createdAt: string;
|
|
476
|
+
dependencies?: string[];
|
|
477
|
+
checksum: string;
|
|
478
|
+
}
|
|
479
|
+
interface PatchOp {
|
|
480
|
+
op: "add" | "remove" | "replace" | "move" | "copy" | "test";
|
|
481
|
+
path: string;
|
|
482
|
+
value?: unknown;
|
|
483
|
+
from?: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Convert a `SchemaChange` into one or more RFC 6902 JSON Patch operations
|
|
487
|
+
* that can be applied to a `SchemaDefinition` object.
|
|
488
|
+
*/
|
|
489
|
+
declare function schemaChangeToPatch(change: SchemaChange, schema: SchemaDefinition): PatchOp[];
|
|
490
|
+
type ChangeImpact = "major" | "minor" | "patch";
|
|
491
|
+
/**
|
|
492
|
+
* Classify the semver impact of a single schema change.
|
|
493
|
+
*
|
|
494
|
+
* - `major` — field/index/constraint removal, breaking field changes (type
|
|
495
|
+
* change, required added, unique added, nested schema changed)
|
|
496
|
+
* - `minor` — field/index/constraint addition, deprecation
|
|
497
|
+
* - `patch` — non-breaking field/constraint modifications
|
|
498
|
+
*/
|
|
499
|
+
declare function classifyChangeImpact(change: SchemaChange, currentSchema?: SchemaDefinition): ChangeImpact;
|
|
500
|
+
/**
|
|
501
|
+
* Calculate the next semver version from a set of schema changes.
|
|
502
|
+
*
|
|
503
|
+
* Returns `"major"`, `"minor"`, or `"patch"` as the bump kind.
|
|
504
|
+
* The caller applies it to the current version string.
|
|
505
|
+
*/
|
|
506
|
+
declare function calculateNextBump(changes: SchemaChange[], currentSchema?: SchemaDefinition): ChangeImpact;
|
|
507
|
+
/**
|
|
508
|
+
* Bump a semver string by the given kind.
|
|
509
|
+
*/
|
|
510
|
+
declare function bumpVersion(current: string, kind: ChangeImpact): string;
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/engine.d.ts
|
|
513
|
+
interface EngineState {
|
|
514
|
+
schema: SchemaDefinition;
|
|
515
|
+
migrations: Migration[];
|
|
516
|
+
history: SchemaDefinition[];
|
|
517
|
+
}
|
|
518
|
+
interface DryRunResult {
|
|
519
|
+
schema: SchemaDefinition;
|
|
520
|
+
migrations: Migration[];
|
|
521
|
+
}
|
|
522
|
+
declare class MigrationEngine {
|
|
523
|
+
private currentSchema;
|
|
524
|
+
private migrations;
|
|
525
|
+
private history;
|
|
526
|
+
private processing;
|
|
527
|
+
constructor(schema: SchemaDefinition, migrations?: Migration[], history?: SchemaDefinition[]);
|
|
528
|
+
/** Current engine state (read-only snapshot). */
|
|
529
|
+
data(): EngineState;
|
|
530
|
+
/** Add a pending migration. */
|
|
531
|
+
add(opts: {
|
|
532
|
+
changes: SchemaChange[];
|
|
533
|
+
description: string;
|
|
534
|
+
rollback?: SchemaChange[];
|
|
535
|
+
transform?: string | DataTransform;
|
|
536
|
+
}): Promise<Migration>;
|
|
537
|
+
/**
|
|
538
|
+
* Dry-run: simulate migration (forward or backward) without modifying
|
|
539
|
+
* internal state. Returns the projected schema and list of migrations
|
|
540
|
+
* that would be applied.
|
|
541
|
+
*/
|
|
542
|
+
dryRun(direction: "forward" | "backward", version?: string): Promise<DryRunResult>;
|
|
543
|
+
/**
|
|
544
|
+
* Apply pending forward migrations.
|
|
545
|
+
*
|
|
546
|
+
* `transform` — optional async function called for each migration. Receive
|
|
547
|
+
* the migration and a `ReadableStream` of data chunks; return a transformed
|
|
548
|
+
* stream. If omitted, only schema state is updated (no data).
|
|
549
|
+
*/
|
|
550
|
+
migrate(transform?: (migration: Migration, data: ReadableStream<unknown>) => Promise<ReadableStream<unknown>>): Promise<ReadableStream<unknown>>;
|
|
551
|
+
/**
|
|
552
|
+
* Roll back the last applied migration, or all migrations back to
|
|
553
|
+
* `version`.
|
|
554
|
+
*/
|
|
555
|
+
rollback(version?: string, transform?: (migration: Migration, data: ReadableStream<unknown>) => Promise<ReadableStream<unknown>>): Promise<ReadableStream<unknown>>;
|
|
556
|
+
private assertIdle;
|
|
557
|
+
private getRelevant;
|
|
558
|
+
private validateMigrations;
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/utils.d.ts
|
|
562
|
+
/**
|
|
563
|
+
* Deep-merge `update` into `target`, returning a new object.
|
|
564
|
+
* Arrays are replaced, not merged.
|
|
565
|
+
*/
|
|
566
|
+
declare function deepMerge<T extends Record<string, unknown>>(target: T, update: Partial<T>): T;
|
|
567
|
+
/**
|
|
568
|
+
* Isomorphic SHA-256 hex digest.
|
|
569
|
+
*
|
|
570
|
+
* Uses `globalThis.crypto.subtle` when available (browsers, Node 20+,
|
|
571
|
+
* Bun, Deno), falls back to `node:crypto` for older Node runtimes.
|
|
572
|
+
*/
|
|
573
|
+
declare function sha256(input: string): Promise<string>;
|
|
574
|
+
//#endregion
|
|
402
575
|
//#region src/validation/types/hints.d.ts
|
|
403
576
|
/**
|
|
404
577
|
* hints.ts
|
|
@@ -750,7 +923,7 @@ interface SchemaDefinition$1 extends NamedMetadata {
|
|
|
750
923
|
* Optional data migration definitions.
|
|
751
924
|
* @extension
|
|
752
925
|
*/
|
|
753
|
-
migrations?: Array<Migration>;
|
|
926
|
+
migrations?: Array<Migration$1>;
|
|
754
927
|
/**
|
|
755
928
|
* UI/input hints.
|
|
756
929
|
* @extension
|
|
@@ -783,11 +956,11 @@ interface SchemaDefinition$1 extends NamedMetadata {
|
|
|
783
956
|
* - `null`: Clear/remove the property (if allowed by NonNullable).
|
|
784
957
|
* - `value`: Set the property to the provided value.
|
|
785
958
|
*/
|
|
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 = {
|
|
959
|
+
type Patch$1<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
|
|
960
|
+
type FieldPatch$1 = Patch$1<FieldDefinition$1, "name" | "type">;
|
|
961
|
+
type ConstraintPatch$1 = Patch$1<Constraint$1, "name">;
|
|
962
|
+
type IndexPatch$1 = Patch$1<IndexDefinition$1, "name">;
|
|
963
|
+
type SchemaChange$1 = {
|
|
791
964
|
type: "modifyProperty";
|
|
792
965
|
id: keyof NamedMetadata | "version";
|
|
793
966
|
value: any;
|
|
@@ -801,7 +974,7 @@ type SchemaChange = {
|
|
|
801
974
|
} | {
|
|
802
975
|
type: "modifyField";
|
|
803
976
|
id: string;
|
|
804
|
-
changes: FieldPatch;
|
|
977
|
+
changes: FieldPatch$1;
|
|
805
978
|
} | {
|
|
806
979
|
type: "addIndex";
|
|
807
980
|
id: string;
|
|
@@ -812,7 +985,7 @@ type SchemaChange = {
|
|
|
812
985
|
} | {
|
|
813
986
|
type: "modifyIndex";
|
|
814
987
|
id: string;
|
|
815
|
-
changes: IndexPatch;
|
|
988
|
+
changes: IndexPatch$1;
|
|
816
989
|
} | {
|
|
817
990
|
type: "addConstraint";
|
|
818
991
|
id: string;
|
|
@@ -823,7 +996,7 @@ type SchemaChange = {
|
|
|
823
996
|
} | {
|
|
824
997
|
type: "modifyConstraint";
|
|
825
998
|
id: string;
|
|
826
|
-
changes: ConstraintPatch;
|
|
999
|
+
changes: ConstraintPatch$1;
|
|
827
1000
|
} | {
|
|
828
1001
|
type: "addSchema";
|
|
829
1002
|
id: string;
|
|
@@ -834,23 +1007,23 @@ type SchemaChange = {
|
|
|
834
1007
|
} | {
|
|
835
1008
|
type: "modifySchema";
|
|
836
1009
|
id: string;
|
|
837
|
-
changes: Array<SchemaChange>;
|
|
1010
|
+
changes: Array<SchemaChange$1>;
|
|
838
1011
|
};
|
|
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>;
|
|
1012
|
+
type TransformFunction$1<Initial, Next> = (ctx: any, data: Initial) => Next | Promise<Next>;
|
|
1013
|
+
interface DataTransform$1<Initial, Next> {
|
|
1014
|
+
forward: TransformFunction$1<Initial, Next>;
|
|
1015
|
+
backward: TransformFunction$1<Next, Initial>;
|
|
843
1016
|
}
|
|
844
|
-
interface Migration<Initial = any, Next = any> {
|
|
1017
|
+
interface Migration$1<Initial = any, Next = any> {
|
|
845
1018
|
id: string;
|
|
846
1019
|
version: {
|
|
847
1020
|
source: string;
|
|
848
1021
|
target?: string;
|
|
849
1022
|
};
|
|
850
|
-
changes: SchemaChange[];
|
|
1023
|
+
changes: SchemaChange$1[];
|
|
851
1024
|
description: string;
|
|
852
|
-
rollback?: SchemaChange[];
|
|
853
|
-
transform: string | DataTransform<Initial, Next>;
|
|
1025
|
+
rollback?: SchemaChange$1[];
|
|
1026
|
+
transform: string | DataTransform$1<Initial, Next>;
|
|
854
1027
|
createdAt: string;
|
|
855
1028
|
dependencies?: string[];
|
|
856
1029
|
checksum: string;
|
|
@@ -1078,4 +1251,4 @@ declare class SchemaValidator {
|
|
|
1078
1251
|
//#region src/validation/predicates.d.ts
|
|
1079
1252
|
declare const metaSchemaPredicateMap: PredicateMap;
|
|
1080
1253
|
//#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 };
|
|
1254
|
+
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, 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
|
@@ -399,6 +399,179 @@ declare class AnansiCodec {
|
|
|
399
399
|
encodeColumnar(docs: Record<string, unknown>[]): Promise<Uint8Array>;
|
|
400
400
|
}
|
|
401
401
|
//#endregion
|
|
402
|
+
//#region src/schema/migration.d.ts
|
|
403
|
+
/**
|
|
404
|
+
* Partial update semantics:
|
|
405
|
+
* - `undefined` → no change
|
|
406
|
+
* - `null` → clear/remove the property
|
|
407
|
+
* - `value` → set to the provided value
|
|
408
|
+
*/
|
|
409
|
+
type Patch<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
|
|
410
|
+
type FieldPatch = Patch<FieldDefinition, "name" | "type">;
|
|
411
|
+
type ConstraintPatch = Patch<Constraint, "name">;
|
|
412
|
+
type IndexPatch = Patch<IndexDefinition, "name">;
|
|
413
|
+
type SchemaChange = {
|
|
414
|
+
type: "modifyProperty";
|
|
415
|
+
id: keyof SchemaDefinition | "version";
|
|
416
|
+
value: unknown;
|
|
417
|
+
} | {
|
|
418
|
+
type: "addField";
|
|
419
|
+
id: string;
|
|
420
|
+
definition: FieldDefinition;
|
|
421
|
+
} | {
|
|
422
|
+
type: "removeField";
|
|
423
|
+
id: string;
|
|
424
|
+
} | {
|
|
425
|
+
type: "modifyField";
|
|
426
|
+
id: string;
|
|
427
|
+
changes: FieldPatch;
|
|
428
|
+
} | {
|
|
429
|
+
type: "addIndex";
|
|
430
|
+
id: string;
|
|
431
|
+
definition: IndexDefinition;
|
|
432
|
+
} | {
|
|
433
|
+
type: "removeIndex";
|
|
434
|
+
id: string;
|
|
435
|
+
} | {
|
|
436
|
+
type: "modifyIndex";
|
|
437
|
+
id: string;
|
|
438
|
+
changes: IndexPatch;
|
|
439
|
+
} | {
|
|
440
|
+
type: "addConstraint";
|
|
441
|
+
id: string;
|
|
442
|
+
constraint: Constraint;
|
|
443
|
+
} | {
|
|
444
|
+
type: "removeConstraint";
|
|
445
|
+
id: string;
|
|
446
|
+
} | {
|
|
447
|
+
type: "modifyConstraint";
|
|
448
|
+
id: string;
|
|
449
|
+
changes: ConstraintPatch;
|
|
450
|
+
} | {
|
|
451
|
+
type: "addSchema";
|
|
452
|
+
id: string;
|
|
453
|
+
definition: NonNullable<SchemaDefinition["schemas"]>[string];
|
|
454
|
+
} | {
|
|
455
|
+
type: "removeSchema";
|
|
456
|
+
id: string;
|
|
457
|
+
} | {
|
|
458
|
+
type: "modifySchema";
|
|
459
|
+
id: string;
|
|
460
|
+
changes: SchemaChange[];
|
|
461
|
+
};
|
|
462
|
+
type TransformFunction<Initial, Next> = (ctx: unknown, data: Initial) => Next | Promise<Next>;
|
|
463
|
+
interface DataTransform<Initial = unknown, Next = unknown> {
|
|
464
|
+
forward: TransformFunction<Initial, Next>;
|
|
465
|
+
backward: TransformFunction<Next, Initial>;
|
|
466
|
+
}
|
|
467
|
+
interface Migration<Initial = unknown, Next = unknown> {
|
|
468
|
+
id: string;
|
|
469
|
+
schemaVersion: string;
|
|
470
|
+
changes: SchemaChange[];
|
|
471
|
+
description: string;
|
|
472
|
+
status?: "pending" | "applied" | "rolled_back";
|
|
473
|
+
rollback?: SchemaChange[];
|
|
474
|
+
transform?: string | DataTransform<Initial, Next>;
|
|
475
|
+
createdAt: string;
|
|
476
|
+
dependencies?: string[];
|
|
477
|
+
checksum: string;
|
|
478
|
+
}
|
|
479
|
+
interface PatchOp {
|
|
480
|
+
op: "add" | "remove" | "replace" | "move" | "copy" | "test";
|
|
481
|
+
path: string;
|
|
482
|
+
value?: unknown;
|
|
483
|
+
from?: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Convert a `SchemaChange` into one or more RFC 6902 JSON Patch operations
|
|
487
|
+
* that can be applied to a `SchemaDefinition` object.
|
|
488
|
+
*/
|
|
489
|
+
declare function schemaChangeToPatch(change: SchemaChange, schema: SchemaDefinition): PatchOp[];
|
|
490
|
+
type ChangeImpact = "major" | "minor" | "patch";
|
|
491
|
+
/**
|
|
492
|
+
* Classify the semver impact of a single schema change.
|
|
493
|
+
*
|
|
494
|
+
* - `major` — field/index/constraint removal, breaking field changes (type
|
|
495
|
+
* change, required added, unique added, nested schema changed)
|
|
496
|
+
* - `minor` — field/index/constraint addition, deprecation
|
|
497
|
+
* - `patch` — non-breaking field/constraint modifications
|
|
498
|
+
*/
|
|
499
|
+
declare function classifyChangeImpact(change: SchemaChange, currentSchema?: SchemaDefinition): ChangeImpact;
|
|
500
|
+
/**
|
|
501
|
+
* Calculate the next semver version from a set of schema changes.
|
|
502
|
+
*
|
|
503
|
+
* Returns `"major"`, `"minor"`, or `"patch"` as the bump kind.
|
|
504
|
+
* The caller applies it to the current version string.
|
|
505
|
+
*/
|
|
506
|
+
declare function calculateNextBump(changes: SchemaChange[], currentSchema?: SchemaDefinition): ChangeImpact;
|
|
507
|
+
/**
|
|
508
|
+
* Bump a semver string by the given kind.
|
|
509
|
+
*/
|
|
510
|
+
declare function bumpVersion(current: string, kind: ChangeImpact): string;
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/engine.d.ts
|
|
513
|
+
interface EngineState {
|
|
514
|
+
schema: SchemaDefinition;
|
|
515
|
+
migrations: Migration[];
|
|
516
|
+
history: SchemaDefinition[];
|
|
517
|
+
}
|
|
518
|
+
interface DryRunResult {
|
|
519
|
+
schema: SchemaDefinition;
|
|
520
|
+
migrations: Migration[];
|
|
521
|
+
}
|
|
522
|
+
declare class MigrationEngine {
|
|
523
|
+
private currentSchema;
|
|
524
|
+
private migrations;
|
|
525
|
+
private history;
|
|
526
|
+
private processing;
|
|
527
|
+
constructor(schema: SchemaDefinition, migrations?: Migration[], history?: SchemaDefinition[]);
|
|
528
|
+
/** Current engine state (read-only snapshot). */
|
|
529
|
+
data(): EngineState;
|
|
530
|
+
/** Add a pending migration. */
|
|
531
|
+
add(opts: {
|
|
532
|
+
changes: SchemaChange[];
|
|
533
|
+
description: string;
|
|
534
|
+
rollback?: SchemaChange[];
|
|
535
|
+
transform?: string | DataTransform;
|
|
536
|
+
}): Promise<Migration>;
|
|
537
|
+
/**
|
|
538
|
+
* Dry-run: simulate migration (forward or backward) without modifying
|
|
539
|
+
* internal state. Returns the projected schema and list of migrations
|
|
540
|
+
* that would be applied.
|
|
541
|
+
*/
|
|
542
|
+
dryRun(direction: "forward" | "backward", version?: string): Promise<DryRunResult>;
|
|
543
|
+
/**
|
|
544
|
+
* Apply pending forward migrations.
|
|
545
|
+
*
|
|
546
|
+
* `transform` — optional async function called for each migration. Receive
|
|
547
|
+
* the migration and a `ReadableStream` of data chunks; return a transformed
|
|
548
|
+
* stream. If omitted, only schema state is updated (no data).
|
|
549
|
+
*/
|
|
550
|
+
migrate(transform?: (migration: Migration, data: ReadableStream<unknown>) => Promise<ReadableStream<unknown>>): Promise<ReadableStream<unknown>>;
|
|
551
|
+
/**
|
|
552
|
+
* Roll back the last applied migration, or all migrations back to
|
|
553
|
+
* `version`.
|
|
554
|
+
*/
|
|
555
|
+
rollback(version?: string, transform?: (migration: Migration, data: ReadableStream<unknown>) => Promise<ReadableStream<unknown>>): Promise<ReadableStream<unknown>>;
|
|
556
|
+
private assertIdle;
|
|
557
|
+
private getRelevant;
|
|
558
|
+
private validateMigrations;
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/utils.d.ts
|
|
562
|
+
/**
|
|
563
|
+
* Deep-merge `update` into `target`, returning a new object.
|
|
564
|
+
* Arrays are replaced, not merged.
|
|
565
|
+
*/
|
|
566
|
+
declare function deepMerge<T extends Record<string, unknown>>(target: T, update: Partial<T>): T;
|
|
567
|
+
/**
|
|
568
|
+
* Isomorphic SHA-256 hex digest.
|
|
569
|
+
*
|
|
570
|
+
* Uses `globalThis.crypto.subtle` when available (browsers, Node 20+,
|
|
571
|
+
* Bun, Deno), falls back to `node:crypto` for older Node runtimes.
|
|
572
|
+
*/
|
|
573
|
+
declare function sha256(input: string): Promise<string>;
|
|
574
|
+
//#endregion
|
|
402
575
|
//#region src/validation/types/hints.d.ts
|
|
403
576
|
/**
|
|
404
577
|
* hints.ts
|
|
@@ -750,7 +923,7 @@ interface SchemaDefinition$1 extends NamedMetadata {
|
|
|
750
923
|
* Optional data migration definitions.
|
|
751
924
|
* @extension
|
|
752
925
|
*/
|
|
753
|
-
migrations?: Array<Migration>;
|
|
926
|
+
migrations?: Array<Migration$1>;
|
|
754
927
|
/**
|
|
755
928
|
* UI/input hints.
|
|
756
929
|
* @extension
|
|
@@ -783,11 +956,11 @@ interface SchemaDefinition$1 extends NamedMetadata {
|
|
|
783
956
|
* - `null`: Clear/remove the property (if allowed by NonNullable).
|
|
784
957
|
* - `value`: Set the property to the provided value.
|
|
785
958
|
*/
|
|
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 = {
|
|
959
|
+
type Patch$1<T, NonNullable extends keyof T = never> = { [K in keyof T]?: K extends NonNullable ? T[K] : T[K] | null; };
|
|
960
|
+
type FieldPatch$1 = Patch$1<FieldDefinition$1, "name" | "type">;
|
|
961
|
+
type ConstraintPatch$1 = Patch$1<Constraint$1, "name">;
|
|
962
|
+
type IndexPatch$1 = Patch$1<IndexDefinition$1, "name">;
|
|
963
|
+
type SchemaChange$1 = {
|
|
791
964
|
type: "modifyProperty";
|
|
792
965
|
id: keyof NamedMetadata | "version";
|
|
793
966
|
value: any;
|
|
@@ -801,7 +974,7 @@ type SchemaChange = {
|
|
|
801
974
|
} | {
|
|
802
975
|
type: "modifyField";
|
|
803
976
|
id: string;
|
|
804
|
-
changes: FieldPatch;
|
|
977
|
+
changes: FieldPatch$1;
|
|
805
978
|
} | {
|
|
806
979
|
type: "addIndex";
|
|
807
980
|
id: string;
|
|
@@ -812,7 +985,7 @@ type SchemaChange = {
|
|
|
812
985
|
} | {
|
|
813
986
|
type: "modifyIndex";
|
|
814
987
|
id: string;
|
|
815
|
-
changes: IndexPatch;
|
|
988
|
+
changes: IndexPatch$1;
|
|
816
989
|
} | {
|
|
817
990
|
type: "addConstraint";
|
|
818
991
|
id: string;
|
|
@@ -823,7 +996,7 @@ type SchemaChange = {
|
|
|
823
996
|
} | {
|
|
824
997
|
type: "modifyConstraint";
|
|
825
998
|
id: string;
|
|
826
|
-
changes: ConstraintPatch;
|
|
999
|
+
changes: ConstraintPatch$1;
|
|
827
1000
|
} | {
|
|
828
1001
|
type: "addSchema";
|
|
829
1002
|
id: string;
|
|
@@ -834,23 +1007,23 @@ type SchemaChange = {
|
|
|
834
1007
|
} | {
|
|
835
1008
|
type: "modifySchema";
|
|
836
1009
|
id: string;
|
|
837
|
-
changes: Array<SchemaChange>;
|
|
1010
|
+
changes: Array<SchemaChange$1>;
|
|
838
1011
|
};
|
|
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>;
|
|
1012
|
+
type TransformFunction$1<Initial, Next> = (ctx: any, data: Initial) => Next | Promise<Next>;
|
|
1013
|
+
interface DataTransform$1<Initial, Next> {
|
|
1014
|
+
forward: TransformFunction$1<Initial, Next>;
|
|
1015
|
+
backward: TransformFunction$1<Next, Initial>;
|
|
843
1016
|
}
|
|
844
|
-
interface Migration<Initial = any, Next = any> {
|
|
1017
|
+
interface Migration$1<Initial = any, Next = any> {
|
|
845
1018
|
id: string;
|
|
846
1019
|
version: {
|
|
847
1020
|
source: string;
|
|
848
1021
|
target?: string;
|
|
849
1022
|
};
|
|
850
|
-
changes: SchemaChange[];
|
|
1023
|
+
changes: SchemaChange$1[];
|
|
851
1024
|
description: string;
|
|
852
|
-
rollback?: SchemaChange[];
|
|
853
|
-
transform: string | DataTransform<Initial, Next>;
|
|
1025
|
+
rollback?: SchemaChange$1[];
|
|
1026
|
+
transform: string | DataTransform$1<Initial, Next>;
|
|
854
1027
|
createdAt: string;
|
|
855
1028
|
dependencies?: string[];
|
|
856
1029
|
checksum: string;
|
|
@@ -1078,4 +1251,4 @@ declare class SchemaValidator {
|
|
|
1078
1251
|
//#region src/validation/predicates.d.ts
|
|
1079
1252
|
declare const metaSchemaPredicateMap: PredicateMap;
|
|
1080
1253
|
//#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 };
|
|
1254
|
+
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, 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 };
|