@asaidimu/anansi 1.1.0

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.ts ADDED
@@ -0,0 +1,1920 @@
1
+ import { Faker } from '@faker-js/faker';
2
+ import { QueryDSL, QueryFilter } from '@asaidimu/query';
3
+ import { StandardSchemaV1 } from '@standard-schema/spec';
4
+ import { z } from 'zod';
5
+
6
+ /**
7
+ * Schema-related interfaces
8
+ */
9
+
10
+ /**
11
+ * Logical operators for constraints and partial indexes.
12
+ */
13
+ type LogicalOperator = "and" | "or" | "not" | "nor" | "xor";
14
+ /**
15
+ * Basic field types supported by the schema system.
16
+ */
17
+ type FieldType = "string" | "number" | "boolean" | "array" | "object" | "dynamic";
18
+ /**
19
+ * Index types for optimizing different query patterns.
20
+ */
21
+ type IndexType = "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
22
+ /**
23
+ * Defines a predicate function for data validation.
24
+ * @template T The type of the data object.
25
+ * @template K The type of the field being validated.
26
+ * @param {object} params - The parameters for the predicate.
27
+ * @param {T} params.data - The data object being validated.
28
+ * @param {keyof T} params.field - The field being validated.
29
+ * @param {ConstraintParameters<K>} params.arguments - The constraint parameters.
30
+ * @returns {boolean} True if the data is valid, false otherwise.
31
+ */
32
+ type Predicate = <T, K extends FieldType = any>(params: {
33
+ data: T;
34
+ field?: keyof T;
35
+ arguments: PredicateParameters<K>;
36
+ }) => boolean;
37
+ /**
38
+ * A map of constraint names to predicate functions.
39
+ * @template T The type of the data object.
40
+ */
41
+ type PredicateMap = Record<string, Predicate>;
42
+ type FunctionMap = Record<string, Function>;
43
+ /** @deprecated */
44
+ type ConstraintsMap = Record<string, Predicate>;
45
+ /**
46
+ * Supported constraint names.
47
+ * @template T The type of the constraints map.
48
+ */
49
+ type PredicateName<T extends PredicateMap = any> = keyof T;
50
+ /**
51
+ * Constraint parameters based on field type.
52
+ * @template T The field type.
53
+ */
54
+ type PredicateParameters<T extends FieldType> = T extends "string" ? string | string[] | RegExp | {
55
+ field: string;
56
+ } : T extends "number" ? number | number[] | {
57
+ precision: number;
58
+ scale?: number;
59
+ } | {
60
+ field: string;
61
+ } : T extends "boolean" ? boolean : T extends "array" ? number | {
62
+ minItems: number;
63
+ maxItems: number;
64
+ } : T extends "object" ? {
65
+ schema: Record<string, unknown>;
66
+ } : never;
67
+ /** @deprecated */
68
+ type ConstraintParameters<T extends FieldType> = PredicateParameters<T>;
69
+ /**
70
+ * Defines a constraint on a field.
71
+ * @template T The field type.
72
+ */
73
+ type Constraint<T extends FieldType> = {
74
+ type?: "schema";
75
+ /** The predicate function for the constraint */
76
+ predicate: string;
77
+ /** The field the constraint applies to */
78
+ field?: keyof any;
79
+ /** The parameters for the constraint. */
80
+ parameters?: PredicateParameters<T>;
81
+ /** The name of the constraint. */
82
+ name: string;
83
+ /** A description of the constraint. */
84
+ description?: string;
85
+ /** A custom error message for the constraint. */
86
+ errorMessage?: string;
87
+ };
88
+ /**
89
+ * Group of constraint rules with a logical operator.
90
+ * @template T The field type.
91
+ */
92
+ interface ConstraintGroup<T extends FieldType> {
93
+ /** The name of the constraint. */
94
+ name: string;
95
+ /** The logical operator for the group (AND or OR). */
96
+ operator: LogicalOperator;
97
+ /** The rules in the group, which can be constraints or other constraint groups. */
98
+ rules: Array<Constraint<T> | ConstraintGroup<T>>;
99
+ }
100
+ /**
101
+ * Definition of a field within the schema.
102
+ * @template T The type of the field.
103
+ */
104
+ interface FieldDefinition<T> {
105
+ /** The type of the field. */
106
+ type: FieldType;
107
+ /** Whether the field is required. */
108
+ required?: boolean;
109
+ /** The constraints on the field. */
110
+ constraints?: Constraint<any>[];
111
+ /** The default value of the field. */
112
+ default?: T;
113
+ /** The type of items in an array field. */
114
+ itemsType?: FieldType;
115
+ /** The schema for nested objects. */
116
+ nestedSchema?: Record<string, FieldDefinition<any>>;
117
+ /** Whether the field is deprecated. */
118
+ deprecated?: boolean;
119
+ /** A reference to another schema and field. */
120
+ reference?: {
121
+ schema: string;
122
+ field: string;
123
+ };
124
+ /** A description of the field. */
125
+ description?: string;
126
+ /** Whether the field is unique. */
127
+ unique?: boolean;
128
+ }
129
+ /**
130
+ * Condition for partial indexes.
131
+ */
132
+ interface PartialIndexCondition {
133
+ /** The logical operator for the condition. */
134
+ operator: LogicalOperator;
135
+ /** The field to which condition applies. */
136
+ field: string;
137
+ /** The value to compare against (optional). */
138
+ value?: any;
139
+ /** Nested conditions (optional). */
140
+ conditions?: PartialIndexCondition[];
141
+ }
142
+ /**
143
+ * Definition of an index.
144
+ */
145
+ interface IndexDefinition {
146
+ /** The fields included in the index. */
147
+ fields: string[];
148
+ /** The type of the index. */
149
+ type: IndexType;
150
+ /** Whether the index is unique. */
151
+ unique?: boolean;
152
+ /** A partial index condition. */
153
+ partial?: PartialIndexCondition;
154
+ /** A description of the index. */
155
+ description?: string;
156
+ /** Sorting order for the index */
157
+ order?: "asc" | "desc";
158
+ /** A name for the index. */
159
+ name: string;
160
+ }
161
+ /**
162
+ * Schema constraint definition.
163
+ * @template T The field type.
164
+ */
165
+ type SchemaConstraint<T extends FieldType> = Array<Constraint<T> | ConstraintGroup<T>>;
166
+ /**
167
+ * Complete schema definition.
168
+ */
169
+ interface SchemaDefinition {
170
+ /** The name of the schema. */
171
+ name: string;
172
+ /** The version of the schema. */
173
+ version: string;
174
+ /** A description of the schema. */
175
+ description?: string;
176
+ /** The field definitions in the schema. */
177
+ fields: Record<string, FieldDefinition<any>>;
178
+ /** The indexes defined for the schema. */
179
+ indexes?: IndexDefinition[];
180
+ /** The constraints defined for the schema. */
181
+ constraints?: SchemaConstraint<any>;
182
+ /** Metadata associated with the schema. */
183
+ metadata?: Record<string, any>;
184
+ /** Dependencies of the schema. */
185
+ dependencies?: string[];
186
+ /** Migrations associated with the schema. */
187
+ migrations?: Array<Migration<any>>;
188
+ /** A Mock associated with the schema. */
189
+ mock?: <T>(faker: Faker) => Generator<T, void, unknown>;
190
+ }
191
+ /**
192
+ * Defines a change that can be made to a schema.
193
+ * @template T The type of the field being changed.
194
+ */
195
+ type SchemaChange<T> = {
196
+ type: "addField";
197
+ name: string;
198
+ definition: FieldDefinition<T>;
199
+ } | {
200
+ type: "removeField";
201
+ name: string;
202
+ } | {
203
+ type: "modifyField";
204
+ name: string;
205
+ changes: Partial<FieldDefinition<T>>;
206
+ } | {
207
+ type: "addIndex";
208
+ definition: IndexDefinition;
209
+ } | {
210
+ type: "removeIndex";
211
+ name: string;
212
+ } | {
213
+ type: "modifyIndex";
214
+ name: string;
215
+ changes: Partial<IndexDefinition>;
216
+ } | {
217
+ type: "addConstraint";
218
+ constraint: Constraint<any> | ConstraintGroup<any>;
219
+ } | {
220
+ type: "removeConstraint";
221
+ name: string;
222
+ } | {
223
+ type: "modifyConstraint";
224
+ name: string;
225
+ changes: Partial<SchemaConstraint<any> | Constraint<any>>;
226
+ } | {
227
+ type: "deprecateField";
228
+ name: string;
229
+ };
230
+ /**
231
+ * Defines a transform function for data migration.
232
+ * @template Initial The initial data type.
233
+ * @template Next The transformed data type.
234
+ * @param {Initial} data - The initial data.
235
+ * @returns {Next | Promise<Next>} The transformed data or a promise that resolves to the transformed data.
236
+ */
237
+ type TransformFunction<Initial, Next> = (data: Initial) => Next | Promise<Next>;
238
+ /**
239
+ * Represents a pair of transformations for data migration (forward and backward).
240
+ * @template Initial The initial data type.
241
+ * @template Next The transformed data type.
242
+ */
243
+ interface DataTransform<Initial, Next> {
244
+ /** The forward transformation function. */
245
+ forward: TransformFunction<Initial, Next>;
246
+ /** The backward transformation function. */
247
+ backward: TransformFunction<Next, Initial>;
248
+ }
249
+ /**
250
+ * Defines a migration, which consists of a series of schema changes and data transforms.
251
+ * Each migration is a set of atomic changes that can be applied in a single operation.
252
+ * @template T The type of the data being migrated.
253
+ */
254
+ interface Migration<T> {
255
+ /** A unique identifier for the migration. */
256
+ id: string;
257
+ /** the schema version for which this migration is applicable */
258
+ schemaVersion: string;
259
+ /** A list of schema changes to be applied in the migration. */
260
+ changes: SchemaChange<T>[];
261
+ /** A description of what the migration does. */
262
+ description: string;
263
+ /** The current status of the migration. */
264
+ status: "pending" | "applied" | "failed";
265
+ /** An optional list of schema changes to revert the migration. */
266
+ rollback?: SchemaChange<T>[];
267
+ /**
268
+ * A checksum/string/url representing the js file exporting
269
+ * the data transforms for this migration.
270
+ * Each transform file exports a `DataTransform` object.
271
+ */
272
+ transform: string | DataTransform<any, any>;
273
+ /** A timestamp for when the migration was created (in ISO 8601 format). */
274
+ createdAt: string;
275
+ /** @deprecated An optional list of migration IDs that must be applied before this one. */
276
+ dependencies?: string[];
277
+ /**
278
+ * A checksum to ensure the integrity of the migration.
279
+ * This is the hash of the stringified/minified version of this object,
280
+ * excluding the `checksum` field itself (to avoid circular dependencies).
281
+ */
282
+ checksum: string;
283
+ }
284
+
285
+ type schemaDefinition_Constraint<T extends FieldType> = Constraint<T>;
286
+ type schemaDefinition_ConstraintGroup<T extends FieldType> = ConstraintGroup<T>;
287
+ type schemaDefinition_ConstraintParameters<T extends FieldType> = ConstraintParameters<T>;
288
+ type schemaDefinition_ConstraintsMap = ConstraintsMap;
289
+ type schemaDefinition_DataTransform<Initial, Next> = DataTransform<Initial, Next>;
290
+ type schemaDefinition_FieldDefinition<T> = FieldDefinition<T>;
291
+ type schemaDefinition_FieldType = FieldType;
292
+ type schemaDefinition_FunctionMap = FunctionMap;
293
+ type schemaDefinition_IndexDefinition = IndexDefinition;
294
+ type schemaDefinition_IndexType = IndexType;
295
+ type schemaDefinition_LogicalOperator = LogicalOperator;
296
+ type schemaDefinition_Migration<T> = Migration<T>;
297
+ type schemaDefinition_PartialIndexCondition = PartialIndexCondition;
298
+ type schemaDefinition_Predicate = Predicate;
299
+ type schemaDefinition_PredicateMap = PredicateMap;
300
+ type schemaDefinition_PredicateName<T extends PredicateMap = any> = PredicateName<T>;
301
+ type schemaDefinition_PredicateParameters<T extends FieldType> = PredicateParameters<T>;
302
+ type schemaDefinition_SchemaChange<T> = SchemaChange<T>;
303
+ type schemaDefinition_SchemaConstraint<T extends FieldType> = SchemaConstraint<T>;
304
+ type schemaDefinition_SchemaDefinition = SchemaDefinition;
305
+ type schemaDefinition_TransformFunction<Initial, Next> = TransformFunction<Initial, Next>;
306
+ declare namespace schemaDefinition {
307
+ export type { schemaDefinition_Constraint as Constraint, schemaDefinition_ConstraintGroup as ConstraintGroup, schemaDefinition_ConstraintParameters as ConstraintParameters, schemaDefinition_ConstraintsMap as ConstraintsMap, schemaDefinition_DataTransform as DataTransform, schemaDefinition_FieldDefinition as FieldDefinition, schemaDefinition_FieldType as FieldType, schemaDefinition_FunctionMap as FunctionMap, schemaDefinition_IndexDefinition as IndexDefinition, schemaDefinition_IndexType as IndexType, schemaDefinition_LogicalOperator as LogicalOperator, schemaDefinition_Migration as Migration, schemaDefinition_PartialIndexCondition as PartialIndexCondition, schemaDefinition_Predicate as Predicate, schemaDefinition_PredicateMap as PredicateMap, schemaDefinition_PredicateName as PredicateName, schemaDefinition_PredicateParameters as PredicateParameters, schemaDefinition_SchemaChange as SchemaChange, schemaDefinition_SchemaConstraint as SchemaConstraint, schemaDefinition_SchemaDefinition as SchemaDefinition, schemaDefinition_TransformFunction as TransformFunction };
308
+ }
309
+
310
+ /**
311
+ * Defines the interface for a migration engine.
312
+ * The migration engine is responsible for applying, rolling back, and tracking schema migrations.
313
+ */
314
+ interface MigrationEngine$1<T> {
315
+ /**
316
+ * Applies all pending migrations.
317
+ * @returns A promise that resolves when all migrations are applied.
318
+ */
319
+ applyMigrations(): Promise<void>;
320
+ /**
321
+ * Rolls back the most recently applied migration.
322
+ * @returns A promise that resolves when the migration is rolled back.
323
+ */
324
+ rollbackLastMigration(): Promise<void>;
325
+ /**
326
+ * Rolls back all migrations to a specific version.
327
+ * @param targetVersion The version to roll back to.
328
+ * @returns A promise that resolves when the rollback is complete.
329
+ */
330
+ rollbackToVersion(targetVersion: string): Promise<void>;
331
+ /**
332
+ * Returns the current schema version.
333
+ * @returns A promise that resolves to the current schema version.
334
+ */
335
+ getCurrentVersion(): Promise<string>;
336
+ /**
337
+ * Returns the list of applied migrations.
338
+ * @returns A promise that resolves to an array of applied migrations.
339
+ */
340
+ getAppliedMigrations(): Promise<Migration<T>[]>;
341
+ /**
342
+ * Returns the list of pending migrations.
343
+ * @returns A promise that resolves to an array of pending migrations.
344
+ */
345
+ getPendingMigrations(): Promise<Migration<T>[]>;
346
+ /**
347
+ * Validates the integrity of all migrations.
348
+ * @returns A promise that resolves to `true` if all migrations are valid, otherwise `false`.
349
+ */
350
+ validateMigrations(): Promise<boolean>;
351
+ /**
352
+ * Adds a new migration to the migration registry.
353
+ * @param migration The migration to add.
354
+ * @returns A promise that resolves when the migration is added.
355
+ */
356
+ addMigration(migration: Migration<T>): Promise<void>;
357
+ /**
358
+ * Removes a migration from the migration registry.
359
+ * @param migrationId The ID of the migration to remove.
360
+ * @returns A promise that resolves when the migration is removed.
361
+ */
362
+ removeMigration(migrationId: string): Promise<void>;
363
+ }
364
+
365
+ declare namespace migrations {
366
+ export type { MigrationEngine$1 as MigrationEngine };
367
+ }
368
+
369
+ /**
370
+ * @module JsonPatch
371
+ * @description A library for creating and applying JSON Patch operations according to RFC 6902
372
+ * @note This implementation includes an additional non-standard 'removeValue' operation that removes all instances of a value from an array.
373
+ */
374
+
375
+ /**
376
+ * Represents a single JSON Patch operation as defined in RFC 6902
377
+ */
378
+ type PatchOperation = {
379
+ op: "add";
380
+ path: string;
381
+ value: any;
382
+ } | {
383
+ op: "remove";
384
+ path: string;
385
+ } | {
386
+ op: "removeValue";
387
+ path: string;
388
+ value: any;
389
+ } | {
390
+ op: "replace";
391
+ path: string;
392
+ value: any;
393
+ } | {
394
+ op: "test";
395
+ path: string;
396
+ value: any;
397
+ } | {
398
+ op: "copy";
399
+ from: string;
400
+ path: string;
401
+ } | {
402
+ op: "move";
403
+ from: string;
404
+ path: string;
405
+ };
406
+ /**
407
+ * Error thrown when JSON Patch operations fail
408
+ * @extends Error
409
+ */
410
+ declare class JsonPatchError extends Error {
411
+ operation?: PatchOperation | undefined;
412
+ constructor(message: string, operation?: PatchOperation | undefined);
413
+ }
414
+ /**
415
+ * Converts a path string from dot notation to JSON Pointer notation
416
+ * @param {string} path - Path in either dot notation (e.g., 'a.b.c') or slash notation (e.g., '/a/b/c')
417
+ * @returns {string} Path in JSON Pointer notation
418
+ * @throws {JsonPatchError} If the path is invalid
419
+ */
420
+ declare function normalizePath(path: string): string;
421
+ /**
422
+ * Applies a sequence of JSON Patch operations to an object
423
+ * @template T
424
+ * @param {T} target - Target object
425
+ * @param {PatchOperation[]} patches - Array of patch operations
426
+ * @returns {T} Modified object
427
+ * @throws {JsonPatchError} If any operation fails
428
+ */
429
+ declare function applyPatch<T>(target: T, patches: PatchOperation[]): T;
430
+ /**
431
+ * Creates a sequence of JSON Patch operations that transform one object into another
432
+ * @param {any} oldObj - Source object
433
+ * @param {any} newObj - Target object
434
+ * @returns {PatchOperation[]} Array of patch operations
435
+ */
436
+ declare function createPatch(oldObj: any, newObj: any): PatchOperation[];
437
+ /**
438
+ * Converts a schema change to JSON Patch operations
439
+ * @param change The schema change to convert
440
+ * @param schema The current schema definition
441
+ * @returns Array of JSON Patch operations
442
+ */
443
+ declare function schemaChangeToPatch(change: SchemaChange<any>, schema: SchemaDefinition): PatchOperation[];
444
+
445
+ type patch_JsonPatchError = JsonPatchError;
446
+ declare const patch_JsonPatchError: typeof JsonPatchError;
447
+ type patch_PatchOperation = PatchOperation;
448
+ declare const patch_applyPatch: typeof applyPatch;
449
+ declare const patch_createPatch: typeof createPatch;
450
+ declare const patch_normalizePath: typeof normalizePath;
451
+ declare const patch_schemaChangeToPatch: typeof schemaChangeToPatch;
452
+ declare namespace patch {
453
+ export { patch_JsonPatchError as JsonPatchError, type patch_PatchOperation as PatchOperation, patch_applyPatch as applyPatch, patch_createPatch as createPatch, patch_normalizePath as normalizePath, patch_schemaChangeToPatch as schemaChangeToPatch };
454
+ }
455
+
456
+ /**
457
+ * Helper for building schema migrations.
458
+ * @template T The type of data associated with the schema.
459
+ */
460
+ interface SchemaMigrationHelper {
461
+ /**
462
+ * Adds a new field to the schema.
463
+ * @param fieldName The name of the field to add.
464
+ * @param fieldDefinition The definition of the field to add.
465
+ */
466
+ addField(fieldName: string, fieldDefinition: FieldDefinition<any>): void;
467
+ /**
468
+ * Removes a field from the schema. This marks the field as deprecated and scheduled for removal.
469
+ * @param fieldName The name of the field to deprecate.
470
+ */
471
+ removeField(fieldName: string): void;
472
+ /**
473
+ * Deprecates a field.
474
+ * @param {string} fieldName - The name of the field to deprecate.
475
+ */
476
+ deprecateField(fieldName: string): void;
477
+ /**
478
+ * Modifies an existing field in the schema.
479
+ * @param fieldName The name of the field to modify.
480
+ * @param changes The changes to apply to the field.
481
+ */
482
+ modifyField(fieldName: string, changes: Partial<FieldDefinition<any>>): void;
483
+ /**
484
+ * Adds a new index to the schema.
485
+ * @param indexDefinition The definition of the index to add.
486
+ */
487
+ addIndex(indexDefinition: IndexDefinition): void;
488
+ /**
489
+ * Removes an index from the schema.
490
+ * @param indexName The name of the index to remove.
491
+ */
492
+ removeIndex(indexName: string): void;
493
+ /**
494
+ * Modifies an existing index in the schema.
495
+ * @param indexName The name of the index to modify.
496
+ * @param changes The changes to apply to the index.
497
+ */
498
+ modifyIndex(indexName: string, changes: Partial<IndexDefinition>): void;
499
+ /**
500
+ * Adds a new constraint to the schema.
501
+ * @param constraint The constraint to add.
502
+ */
503
+ addConstraint(constraint: Constraint<any> | ConstraintGroup<any>): void;
504
+ /**
505
+ * Removes a constraint from the schema.
506
+ * @param constraintName The name of the constraint to remove.
507
+ */
508
+ removeConstraint(constraintName: string): void;
509
+ /**
510
+ * Modifies an existing constraint in the schema.
511
+ * @param constraintName The name of the constraint to modify.
512
+ * @param changes The changes to apply to the constraint.
513
+ */
514
+ modifyConstraint(constraintName: string, changes: Partial<Constraint<any>>): void;
515
+ /**
516
+ * Returns the list of changes made through this helper.
517
+ * @returns An array of schema changes.
518
+ */
519
+ changes(): {
520
+ migrate: SchemaChange<any>[];
521
+ rollback: SchemaChange<any>[];
522
+ };
523
+ }
524
+
525
+ /**
526
+ * Interface defining persistence operations for data management.
527
+ * Provides methods for CRUD operations, transactions, validation, and event subscription.
528
+ *
529
+ * @generic DataType - The type of data being persisted.
530
+ * @generic FunctionMap - A map of functions used in the persistence operations (default: Record<string, any>).
531
+ */
532
+ interface Persistence<FunctionMap> {
533
+ /**
534
+ * Returns a list of all collections
535
+ * @returns A promise that resolves to a list of collection names
536
+ */
537
+ collections(): Promise<Array<string>>;
538
+ /**
539
+ * Creates a new collection with the specified schema.
540
+ * @param schema - The schema definition for the new collection.
541
+ * @returns A promise that resolves when the collection is created.
542
+ */
543
+ createCollection<T>(schema: SchemaDefinition): Promise<PersistenceCollection<T, FunctionMap>>;
544
+ /**
545
+ * Deletes the specified collection.
546
+ * @param id - The ID of the collection to delete.
547
+ * @returns A promise that resolves when the collection is deleted.
548
+ */
549
+ deleteCollection(id: string): Promise<void>;
550
+ /**
551
+ * Retrieves the schema definition for the specified collection.
552
+ * @param id - The ID of the collection.
553
+ * @returns A promise that resolves to the schema definition of the collection.
554
+ */
555
+ schema(id: string): Promise<SchemaDefinition>;
556
+ /**
557
+ * Returns an object that can be used to interact with a collection of data
558
+ *
559
+ */
560
+ collection<T>(id: string): PersistenceCollection<T, FunctionMap>;
561
+ /**
562
+ * Subscribe to persistence events
563
+ * @param event - The event to subscribe to
564
+ * @param callback - A callback to handle the event
565
+ * @returns A callback that can be used to unsubscribe from the event
566
+ */
567
+ subscribe(event: PersistenceEventType, callback: (payload: PersistenceEvent<any>) => void): () => void;
568
+ /**
569
+ * Executes a transaction with multiple operations.
570
+ * @param callback A function that receives a PersistenceTransaction object to perform multiple operations.
571
+ * @param callback.tx The PersistenceTransaction object used to perform transactional operations.
572
+ * @returns A promise that resolves to the result of the transaction.
573
+ */
574
+ transact<ReturnType>(callback: (tx: PersistenceTransaction<FunctionMap>) => Promise<ReturnType>): Promise<ReturnType>;
575
+ }
576
+ type PersistenceTransaction<F> = Omit<Persistence<F>, "subscribe" | "transact">;
577
+ interface PersistenceCollection<T, FunctionMap> {
578
+ /**
579
+ * Creates a new record or multiple records in the specified collection.
580
+ * @param params An object containing the data to create and the collection name.
581
+ * @param params.data The data to be inserted; can be a single record or an array of records.
582
+ * @param params.collection The name of the collection to create records in.
583
+ * @returns A promise that resolves to the created record(s) with their generated IDs.
584
+ */
585
+ create(params: {
586
+ data: T | T[];
587
+ }): Promise<T | T[]>;
588
+ /**
589
+ * Retrieves one or more records from the specified collection.
590
+ * @param params An object containing the query and collection name.
591
+ * @param params.query The query defining the filter, sort, pagination, and projection options.
592
+ * @returns A promise that resolves to a single record or an array of matching records.
593
+ */
594
+ read(params: {
595
+ query: QueryDSL<T, FunctionMap>;
596
+ }): Promise<T | T[]>;
597
+ /**
598
+ * Updates one or more records in the specified collection.
599
+ * @param params An object containing the updated data, query, and collection name.
600
+ * @param params.data The updated data to be applied; can be a single partial record or an array of partial records.
601
+ * @param params.query The query defining which records to update.
602
+ * @returns A promise that resolves to the updated records.
603
+ */
604
+ update(params: {
605
+ data?: Partial<T>;
606
+ patch?: PatchOperation | Array<PatchOperation>;
607
+ query: QueryFilter<T, any>;
608
+ }): Promise<Array<T>>;
609
+ /**
610
+ * Deletes one or more records from the specified collection.
611
+ * @param params An object containing either the query or records to delete, and the collection name.
612
+ * @param params.query The query defining which records to delete.
613
+ * @param params.records An array of records to delete.
614
+ * @returns A promise that resolves to the number of deleted records or the deleted records themselves.
615
+ */
616
+ delete(params: {
617
+ query: QueryFilter<T, any>;
618
+ }): Promise<number>;
619
+ /**
620
+ * Validates an object against a schema.
621
+ * @param params An object containing the data, and collection name.
622
+ * @param params.data The object to validate.
623
+ * @returns An object containing validation results.
624
+ */
625
+ validate(data: any): {
626
+ valid: boolean;
627
+ issues: ReadonlyArray<StandardSchemaV1.Issue> | null;
628
+ };
629
+ /**
630
+ * Subscribe to persistence events
631
+ * @param event - The event to subscribe to
632
+ * @param callback - A callback to handle the event
633
+ * @returns A callback that can be used to unsubscribe from the event
634
+ */
635
+ subscribe(event: PersistenceEventType, callback: (payload: PersistenceEvent<T>) => void): () => void;
636
+ rollback(version?: string, dryRun?: boolean): Promise<{
637
+ newSchema: SchemaDefinition;
638
+ dataPreview: ReadableStream<any>;
639
+ } | undefined>;
640
+ migrate(description: string, cb: (h: Omit<SchemaMigrationHelper, "changes">) => DataTransform<any, any> | undefined, dryRun?: boolean): Promise<{
641
+ newSchema: SchemaDefinition;
642
+ dataPreview: ReadableStream<any>;
643
+ } | undefined>;
644
+ }
645
+ /**
646
+ * Defines the possible event types for persistence operations
647
+ */
648
+ type PersistenceEventType = "create:start" | "create:success" | "create:failed" | "read:start" | "read:success" | "read:failed" | "migrate:start" | "migrate:success" | "migrate:failed" | "rollback:start" | "rollback:success" | "rollback:failed" | "read:failed" | "update:start" | "update:success" | "update:failed" | "delete:start" | "delete:success" | "delete:failed" | "transaction:start" | "transaction:success" | "transaction:failed" | "telemetry" | "collection:create:start" | "collection:create:success" | "collection:create:failed" | "collection:update:start" | "collection:update:success" | "collection:update:failed" | "collection:delete:start" | "collection:delete:success" | "collection:delete:failed";
649
+ /**
650
+ * Interface representing events emitted during persistence operations
651
+ */
652
+ interface PersistenceEvent<DataType> {
653
+ /**
654
+ * The type of event (e.g., 'create:start', 'read:success')
655
+ */
656
+ type: PersistenceEventType;
657
+ /**
658
+ * Timestamp when the event occurred
659
+ */
660
+ timestamp: number;
661
+ /**
662
+ * The operation being performed (e.g., 'create', 'read')
663
+ */
664
+ operation: string;
665
+ /**
666
+ * Name of the collection affected by the operation (if applicable)
667
+ */
668
+ collection?: string;
669
+ /**
670
+ * Data passed to the operation (if applicable)
671
+ */
672
+ input?: any;
673
+ /**
674
+ * Data returned by the operation (if applicable)
675
+ */
676
+ output?: any;
677
+ /**
678
+ * Error object if the operation failed (if applicable)
679
+ */
680
+ error?: Error;
681
+ /**
682
+ * issues that caused the operation to fail (if applicable)
683
+ */
684
+ issues?: Array<StandardSchemaV1.Issue>;
685
+ /**
686
+ * Query used in the operation (if applicable)
687
+ */
688
+ query?: QueryDSL<DataType, any>;
689
+ /**
690
+ * Identifier for the transaction (if part of one)
691
+ */
692
+ transactionId?: string;
693
+ /**
694
+ * Duration of the operation in milliseconds.
695
+ * Useful for performance monitoring.
696
+ */
697
+ duration?: number;
698
+ /**
699
+ * Additional context or metadata specific to the operation.
700
+ * This field can be used to include extra debugging or contextual data.
701
+ */
702
+ context?: Record<string, any>;
703
+ }
704
+
705
+ type persistence_Persistence<FunctionMap> = Persistence<FunctionMap>;
706
+ type persistence_PersistenceCollection<T, FunctionMap> = PersistenceCollection<T, FunctionMap>;
707
+ type persistence_PersistenceEvent<DataType> = PersistenceEvent<DataType>;
708
+ type persistence_PersistenceEventType = PersistenceEventType;
709
+ type persistence_PersistenceTransaction<F> = PersistenceTransaction<F>;
710
+ declare namespace persistence {
711
+ export type { persistence_Persistence as Persistence, persistence_PersistenceCollection as PersistenceCollection, persistence_PersistenceEvent as PersistenceEvent, persistence_PersistenceEventType as PersistenceEventType, persistence_PersistenceTransaction as PersistenceTransaction };
712
+ }
713
+
714
+ type SchemaIndex = {
715
+ schema: string;
716
+ version: string;
717
+ history: Array<SchemaVersion>;
718
+ migrations: Record<string, MigrationMetadata>;
719
+ };
720
+ type SchemaVersion = {
721
+ version: string;
722
+ hash: string;
723
+ date: string;
724
+ description: string;
725
+ migrations?: string[];
726
+ predicates?: string[];
727
+ changelog: string[];
728
+ };
729
+ type MigrationMetadata = {
730
+ hash: string;
731
+ checksum: string;
732
+ };
733
+ type RegistryMetadata = {
734
+ schemas: Record<string, SchemaMetadata>;
735
+ created: string;
736
+ updated: string;
737
+ };
738
+ type SchemaMetadata = {
739
+ name: string;
740
+ version: string;
741
+ description: string;
742
+ created: string;
743
+ updated: string;
744
+ };
745
+ type RegistryLock = {
746
+ updated: string;
747
+ hashes: [filepath: string, filehash: string][];
748
+ };
749
+ interface SchemaRegistry {
750
+ /** Initialize a new registry */
751
+ init(): Promise<void>;
752
+ /** Clone an existing registry from a remote source */
753
+ clone(): Promise<void>;
754
+ /** Create a new schema version */
755
+ create(schema: SchemaDefinition): Promise<void>;
756
+ /** Update an existing schema version */
757
+ update(schema: SchemaDefinition): Promise<void>;
758
+ /** Delete a schema and its associated branch */
759
+ delete(name: string): Promise<void>;
760
+ /** List all schemas with their latest version */
761
+ list(): Promise<{
762
+ name: string;
763
+ version: string;
764
+ }[]>;
765
+ /** Retrieve schema definition for a specific version (or latest if no version is provided) */
766
+ schema(name: string, version?: string, migrations?: boolean): Promise<SchemaDefinition | null>;
767
+ /** Get schema statistics (returns the full SchemaIndex) */
768
+ stats(schema?: string): Promise<SchemaIndex | RegistryMetadata>;
769
+ /** Regenerate index & lockfile, then push changes */
770
+ sync(): Promise<void>;
771
+ /** Retrieve all predicate names required by a specific schema version (or latest if no version is provided) */
772
+ predicates(name: string, version?: string): Promise<string[]>;
773
+ /** Retrieve all migrations for a specific schema version (or latest if no version is provided) */
774
+ migrations(name: string, version?: string): Promise<Array<Migration<any>>>;
775
+ /** Retrieve the full history of a schema */
776
+ history(name: string): Promise<SchemaDefinition[]>;
777
+ }
778
+
779
+ type registry_MigrationMetadata = MigrationMetadata;
780
+ type registry_RegistryLock = RegistryLock;
781
+ type registry_RegistryMetadata = RegistryMetadata;
782
+ type registry_SchemaIndex = SchemaIndex;
783
+ type registry_SchemaMetadata = SchemaMetadata;
784
+ type registry_SchemaRegistry = SchemaRegistry;
785
+ type registry_SchemaVersion = SchemaVersion;
786
+ declare namespace registry {
787
+ export type { registry_MigrationMetadata as MigrationMetadata, registry_RegistryLock as RegistryLock, registry_RegistryMetadata as RegistryMetadata, registry_SchemaIndex as SchemaIndex, registry_SchemaMetadata as SchemaMetadata, registry_SchemaRegistry as SchemaRegistry, registry_SchemaVersion as SchemaVersion };
788
+ }
789
+
790
+ /**
791
+ * Creates an ephemeral persistence instance with in-memory storage.
792
+ * @template {PredicateMap} Predicates
793
+ * @template FunctionMap
794
+ * @param {FunctionMap} functionMap - Map of function names to their implementations
795
+ * @param {Predicates} predicateMap - Map of predicate names to their implementations
796
+ * @returns {Persistence<FunctionMap>} A persistence instance
797
+ */
798
+ declare function createEphemeralPersistence<Predicates extends PredicateMap, FunctionMap>(functionMap: FunctionMap, predicateMap: Predicates): Persistence<FunctionMap>;
799
+
800
+ declare namespace index$3 {
801
+ export { createEphemeralPersistence as default };
802
+ }
803
+
804
+ /**
805
+ * Creates and returns a new SchemaRegistry instance.
806
+ * @returns {Promise<SchemaRegistry>} A promise that resolves to the SchemaRegistry instance.
807
+ */
808
+ declare function createRegistry(credentials: {
809
+ username: string;
810
+ password: string;
811
+ repository: string;
812
+ }, dir?: string, proxy?: string): Promise<SchemaRegistry>;
813
+
814
+ declare namespace index$2 {
815
+ export { createRegistry as default };
816
+ }
817
+
818
+ /**
819
+ * @fileoverview Provides a MigrationEngine class that handles schema migrations,
820
+ * including validation, checksum generation, and migration application.
821
+ * @author Your Name
822
+ */
823
+
824
+ /**
825
+ * @class MigrationError
826
+ * @extends Error
827
+ * @param {string} message - The error message
828
+ * @param {MigrationErrorCode} code - The error code
829
+ * @param {string} [migrationId] - The ID of the migration that caused the error
830
+ * @param {Error} [cause] - The underlying error that caused this error
831
+ */
832
+ declare class MigrationError extends Error {
833
+ readonly code: MigrationErrorCode;
834
+ readonly migrationId?: string | undefined;
835
+ readonly cause?: Error | undefined;
836
+ constructor(message: string, code: MigrationErrorCode, migrationId?: string | undefined, cause?: Error | undefined);
837
+ }
838
+ /**
839
+ * @enum MigrationErrorCode
840
+ * @description Error codes for migration-related errors
841
+ */
842
+ declare enum MigrationErrorCode {
843
+ INVALID_SCHEMA = "INVALID_SCHEMA",
844
+ INVALID_MIGRATION = "INVALID_MIGRATION",
845
+ CHECKSUM_MISMATCH = "CHECKSUM_MISMATCH",
846
+ TIMEOUT = "TIMEOUT",
847
+ MEMORY_LIMIT = "MEMORY_LIMIT",
848
+ CONCURRENT_OPERATION = "CONCURRENT_OPERATION",
849
+ TRANSFORM_ERROR = "TRANSFORM_ERROR",
850
+ VERSION_NOT_FOUND = "VERSION_NOT_FOUND",
851
+ CIRCULAR_DEPENDENCY = "CIRCULAR_DEPENDENCY",
852
+ STREAM_ERROR = "STREAM_ERROR",
853
+ ROLLBACK_ERROR = "ROLLBACK_ERROR",
854
+ MISSING_TRANSFORM = "MISSING_TRANSFORM"
855
+ }
856
+ /**
857
+ * @class MigrationEngine
858
+ * @param {SchemaDefinition} currentSchema - The current schema definition
859
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
860
+ * @throws {MigrationError} If the initial schema or migrations are invalid
861
+ */
862
+ declare class MigrationEngine {
863
+ private currentSchema;
864
+ private history;
865
+ private migrations;
866
+ private isProcessing;
867
+ /**
868
+ * @constructor
869
+ * @param {SchemaDefinition} currentSchema - The current schema definition
870
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
871
+ */
872
+ constructor(currentSchema: SchemaDefinition, migrations?: Array<Migration<any>>, history?: Array<SchemaDefinition>);
873
+ /**
874
+ * Gets the current state of the migration helper
875
+ * @returns {Object} Current state containing schema, history, and migrations
876
+ * @example
877
+ * ```javascript
878
+ * const state = migrationEngine.data();
879
+ * // state contains currentSchema, history, and migrations
880
+ * ```
881
+ */
882
+ data(): {
883
+ schema: SchemaDefinition;
884
+ history: SchemaDefinition[];
885
+ migrations: Migration<any>[];
886
+ };
887
+ /**
888
+ * Generates a SHA-256 checksum for a migration
889
+ * @private
890
+ * @param {Omit<Migration<any>, "checksum">} migration - The migration object
891
+ * @returns {Promise<string>} The generated checksum
892
+ * @throws {MigrationError} If checksum generation fails
893
+ */
894
+ private generateChecksum;
895
+ /**
896
+ * Adds a new migration to the engine
897
+ * @async
898
+ * @param {Object} opts - Options for the new migration
899
+ * @param {SchemaChange<any>[]} opts.changes - Array of schema changes
900
+ * @param {string} opts.description - Description of the migration
901
+ * @param {SchemaChange<any>[]} [opts.rollback] - Optional rollback changes
902
+ * @param {DataTransform<any, any>} [opts.transform] - Optional data transform
903
+ * @throws {MigrationError} If adding the migration fails
904
+ */
905
+ add(opts: {
906
+ changes: SchemaChange<any>[];
907
+ description: string;
908
+ rollback?: SchemaChange<any>[];
909
+ transform?: string | DataTransform<any, any>;
910
+ }): Promise<void>;
911
+ /**
912
+ * Performs a dry run of the migration
913
+ * @async
914
+ * @param {ReadableStream<any>} input - Input data stream
915
+ * @param {"forward" | "backward"} direction - Direction of migration
916
+ * @param {version} version - Version to rollback to
917
+ * @returns {Promise<Object>} Object containing newSchema and dataPreview
918
+ * @throws {MigrationError} If dry run fails
919
+ */
920
+ dryRun(input: ReadableStream<any>, direction: "forward" | "backward", version?: string): Promise<{
921
+ newSchema: SchemaDefinition;
922
+ dataPreview: ReadableStream<any>;
923
+ }>;
924
+ /**
925
+ * Gets relevant migrations based on direction
926
+ * @private
927
+ * @param {"forward" | "backward"} direction - Direction of migration
928
+ * @returns {Array<Migration<any>>} Relevant migrations
929
+ */
930
+ private getRelevantMigrations;
931
+ /**
932
+ * Applies schema changes to a given schema
933
+ * @private
934
+ * @param {SchemaDefinition} schema - The schema to modify
935
+ * @param {SchemaChange<any>[]} changes - Array of schema changes
936
+ * @param {string} [migrationId] - ID of the migration
937
+ * @returns {SchemaDefinition} Modified schema
938
+ * @throws {MigrationError} If applying changes fails
939
+ */
940
+ private applySchemaChanges;
941
+ /**
942
+ * Prepares the list of pending migrations for application
943
+ * @async
944
+ * @returns {Promise<Array<Migration<any>>} List of pending migrations
945
+ * @throws {MigrationError} If preparation fails
946
+ */
947
+ prepareMigration(): Promise<Array<Migration<any>>>;
948
+ /**
949
+ * Applies pending migrations
950
+ * @async
951
+ * @param {ReadableStream<any>} input - Input data stream
952
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
953
+ * @throws {MigrationError} If migration fails
954
+ */
955
+ migrate(input: ReadableStream<any>): Promise<ReadableStream<any>>;
956
+ /**
957
+ * Validates migrations by checking their checksums
958
+ * @private
959
+ * @async
960
+ * @param {Array<Migration<any>>} migrations - Migrations to validate
961
+ * @throws {MigrationError} If validation fails
962
+ */
963
+ private validateMigrations;
964
+ /**
965
+ * Marks migrations as applied
966
+ * @private
967
+ * @param {Array<Migration<any>>} migrations - Migrations to mark as applied
968
+ */
969
+ private markMigrationsApplied;
970
+ /**
971
+ * Rolls back the last applied migration
972
+ * @async
973
+ * @param {ReadableStream<any>} input - Input data stream
974
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
975
+ */
976
+ rollback(input: ReadableStream<any>): Promise<ReadableStream<any>>;
977
+ /**
978
+ * Rolls back to a specific schema version
979
+ * @async
980
+ * @param {string} targetVersion - Target schema version
981
+ * @param {ReadableStream<any>} input - Input data stream
982
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
983
+ * @throws {Error} If target version is not found
984
+ */
985
+ rollbackToVersion(targetVersion: string, input: ReadableStream<any>): Promise<ReadableStream<any>>;
986
+ /**
987
+ * Processes a list of migrations on a data stream, applying transformations
988
+ * in the specified direction (forward or backward).
989
+ *
990
+ * @static
991
+ * @async
992
+ * @param {ReadableStream<any>} input - The input data stream to process
993
+ * @param {"forward" | "backward"} direction - Direction of migration (either "forward" or "backward")
994
+ * @param {Array<Migration<any>>} migrations - Array of Migration objects to process
995
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
996
+ * @throws {MigrationError} If any migration processing fails
997
+ */
998
+ static processMigrationList(input: ReadableStream<any>, direction: "forward" | "backward", migrations: Migration<any>[]): Promise<ReadableStream<any>>;
999
+ /**
1000
+ * Resolves the transform function for a given migration in the specified direction.
1001
+ *
1002
+ * @private
1003
+ * @async
1004
+ * @param {Migration<any>} migration - The migration to resolve the transform for
1005
+ * @param {"forward" | "backward"} direction - Direction of migration
1006
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1007
+ * @throws {MigrationError} If transform resolution fails
1008
+ */
1009
+ private static resolveTransform;
1010
+ /**
1011
+ * Resolves a transform function from a remote URL.
1012
+ *
1013
+ * @private
1014
+ * @async
1015
+ * @param {string} url - URL of the transform module
1016
+ * @param {"forward" | "backward"} direction - Direction of migration
1017
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1018
+ * @throws {MigrationError} If resolution fails
1019
+ */
1020
+ private static resolveRemoteTransform;
1021
+ /**
1022
+ * Resolves a transform function from a local module path.
1023
+ *
1024
+ * @private
1025
+ * @async
1026
+ * @param {string} path - Local module path
1027
+ * @param {"forward" | "backward"} direction - Direction of migration
1028
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1029
+ * @throws {MigrationError} If resolution fails
1030
+ */
1031
+ private static resolveLocalTransform;
1032
+ /**
1033
+ * Transforms the schema either forward or backward
1034
+ * @private
1035
+ * @param {"forward" | "backward"} direction - Direction of transformation
1036
+ * @throws {Error} If transformation fails
1037
+ */
1038
+ private transformSchema;
1039
+ }
1040
+
1041
+ type index$1_MigrationError = MigrationError;
1042
+ declare const index$1_MigrationError: typeof MigrationError;
1043
+ type index$1_MigrationErrorCode = MigrationErrorCode;
1044
+ declare const index$1_MigrationErrorCode: typeof MigrationErrorCode;
1045
+ declare namespace index$1 {
1046
+ export { index$1_MigrationError as MigrationError, index$1_MigrationErrorCode as MigrationErrorCode, MigrationEngine as default };
1047
+ }
1048
+
1049
+ /**
1050
+ * Helper for building schema migrations with forward and rollback changes.
1051
+ * @template T The type of data associated with the schema.
1052
+ * @param {Readonly<SchemaDefinition>} schema - The original schema to base the migration on.
1053
+ * @returns {Object} An object with methods to build migration changes and retrieve the changes.
1054
+ */
1055
+ declare const createSchemaMigrationHelper: <T>(schema: Readonly<SchemaDefinition>) => SchemaMigrationHelper;
1056
+
1057
+ declare const MigrationSchema: z.ZodObject<{
1058
+ id: z.ZodString;
1059
+ schemaVersion: z.ZodString;
1060
+ changes: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1061
+ type: z.ZodLiteral<"addField">;
1062
+ name: z.ZodString;
1063
+ definition: any;
1064
+ }, "strip", z.ZodTypeAny, {
1065
+ type: "addField";
1066
+ name: string;
1067
+ definition?: any;
1068
+ }, {
1069
+ type: "addField";
1070
+ name: string;
1071
+ definition?: any;
1072
+ }>, z.ZodObject<{
1073
+ type: z.ZodLiteral<"removeField">;
1074
+ name: z.ZodString;
1075
+ }, "strip", z.ZodTypeAny, {
1076
+ type: "removeField";
1077
+ name: string;
1078
+ }, {
1079
+ type: "removeField";
1080
+ name: string;
1081
+ }>, z.ZodObject<{
1082
+ type: z.ZodLiteral<"modifyField">;
1083
+ name: z.ZodString;
1084
+ changes: any;
1085
+ }, "strip", z.ZodTypeAny, {
1086
+ type: "modifyField";
1087
+ name: string;
1088
+ changes?: any;
1089
+ }, {
1090
+ type: "modifyField";
1091
+ name: string;
1092
+ changes?: any;
1093
+ }>, z.ZodObject<{
1094
+ type: z.ZodLiteral<"addIndex">;
1095
+ definition: z.ZodObject<{
1096
+ fields: z.ZodArray<z.ZodString, "many">;
1097
+ type: z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>;
1098
+ unique: z.ZodOptional<z.ZodBoolean>;
1099
+ partial: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
1100
+ description: z.ZodOptional<z.ZodString>;
1101
+ order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
1102
+ name: z.ZodOptional<z.ZodString>;
1103
+ }, "strip", z.ZodTypeAny, {
1104
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1105
+ fields: string[];
1106
+ unique?: boolean | undefined;
1107
+ description?: string | undefined;
1108
+ partial?: any;
1109
+ order?: "asc" | "desc" | undefined;
1110
+ name?: string | undefined;
1111
+ }, {
1112
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1113
+ fields: string[];
1114
+ unique?: boolean | undefined;
1115
+ description?: string | undefined;
1116
+ partial?: any;
1117
+ order?: "asc" | "desc" | undefined;
1118
+ name?: string | undefined;
1119
+ }>;
1120
+ }, "strip", z.ZodTypeAny, {
1121
+ type: "addIndex";
1122
+ definition: {
1123
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1124
+ fields: string[];
1125
+ unique?: boolean | undefined;
1126
+ description?: string | undefined;
1127
+ partial?: any;
1128
+ order?: "asc" | "desc" | undefined;
1129
+ name?: string | undefined;
1130
+ };
1131
+ }, {
1132
+ type: "addIndex";
1133
+ definition: {
1134
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1135
+ fields: string[];
1136
+ unique?: boolean | undefined;
1137
+ description?: string | undefined;
1138
+ partial?: any;
1139
+ order?: "asc" | "desc" | undefined;
1140
+ name?: string | undefined;
1141
+ };
1142
+ }>, z.ZodObject<{
1143
+ type: z.ZodLiteral<"removeIndex">;
1144
+ name: z.ZodString;
1145
+ }, "strip", z.ZodTypeAny, {
1146
+ type: "removeIndex";
1147
+ name: string;
1148
+ }, {
1149
+ type: "removeIndex";
1150
+ name: string;
1151
+ }>, z.ZodObject<{
1152
+ type: z.ZodLiteral<"modifyIndex">;
1153
+ name: z.ZodString;
1154
+ changes: z.ZodObject<{
1155
+ fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1156
+ type: z.ZodOptional<z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>>;
1157
+ unique: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
1158
+ partial: z.ZodOptional<z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>>;
1159
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1160
+ order: z.ZodOptional<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
1161
+ name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1162
+ }, "strip", z.ZodTypeAny, {
1163
+ unique?: boolean | undefined;
1164
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1165
+ description?: string | undefined;
1166
+ fields?: string[] | undefined;
1167
+ partial?: any;
1168
+ order?: "asc" | "desc" | undefined;
1169
+ name?: string | undefined;
1170
+ }, {
1171
+ unique?: boolean | undefined;
1172
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1173
+ description?: string | undefined;
1174
+ fields?: string[] | undefined;
1175
+ partial?: any;
1176
+ order?: "asc" | "desc" | undefined;
1177
+ name?: string | undefined;
1178
+ }>;
1179
+ }, "strip", z.ZodTypeAny, {
1180
+ type: "modifyIndex";
1181
+ name: string;
1182
+ changes: {
1183
+ unique?: boolean | undefined;
1184
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1185
+ description?: string | undefined;
1186
+ fields?: string[] | undefined;
1187
+ partial?: any;
1188
+ order?: "asc" | "desc" | undefined;
1189
+ name?: string | undefined;
1190
+ };
1191
+ }, {
1192
+ type: "modifyIndex";
1193
+ name: string;
1194
+ changes: {
1195
+ unique?: boolean | undefined;
1196
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1197
+ description?: string | undefined;
1198
+ fields?: string[] | undefined;
1199
+ partial?: any;
1200
+ order?: "asc" | "desc" | undefined;
1201
+ name?: string | undefined;
1202
+ };
1203
+ }>, z.ZodObject<{
1204
+ type: z.ZodLiteral<"addConstraint">;
1205
+ constraint: z.ZodUnion<[z.ZodObject<{
1206
+ type: z.ZodOptional<z.ZodString>;
1207
+ name: z.ZodString;
1208
+ predicate: z.ZodOptional<z.ZodString>;
1209
+ parameters: z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>;
1210
+ description: z.ZodOptional<z.ZodString>;
1211
+ field: z.ZodOptional<z.ZodString>;
1212
+ errorMessage: z.ZodOptional<z.ZodString>;
1213
+ }, "strip", z.ZodTypeAny, {
1214
+ name: string;
1215
+ type?: string | undefined;
1216
+ description?: string | undefined;
1217
+ predicate?: string | undefined;
1218
+ field?: string | undefined;
1219
+ parameters?: ((params: any) => boolean) | undefined;
1220
+ errorMessage?: string | undefined;
1221
+ }, {
1222
+ name: string;
1223
+ type?: string | undefined;
1224
+ description?: string | undefined;
1225
+ predicate?: string | undefined;
1226
+ field?: string | undefined;
1227
+ parameters?: ((params: any) => boolean) | undefined;
1228
+ errorMessage?: string | undefined;
1229
+ }>, any]>;
1230
+ }, "strip", z.ZodTypeAny, {
1231
+ type: "addConstraint";
1232
+ constraint?: any;
1233
+ }, {
1234
+ type: "addConstraint";
1235
+ constraint?: any;
1236
+ }>, z.ZodObject<{
1237
+ type: z.ZodLiteral<"removeConstraint">;
1238
+ name: z.ZodString;
1239
+ }, "strip", z.ZodTypeAny, {
1240
+ type: "removeConstraint";
1241
+ name: string;
1242
+ }, {
1243
+ type: "removeConstraint";
1244
+ name: string;
1245
+ }>, z.ZodObject<{
1246
+ type: z.ZodLiteral<"modifyConstraint">;
1247
+ name: z.ZodString;
1248
+ changes: z.ZodObject<{
1249
+ type: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1250
+ name: z.ZodOptional<z.ZodString>;
1251
+ predicate: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1252
+ parameters: z.ZodOptional<z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>>;
1253
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1254
+ field: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1255
+ errorMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1256
+ }, "strip", z.ZodTypeAny, {
1257
+ type?: string | undefined;
1258
+ description?: string | undefined;
1259
+ name?: string | undefined;
1260
+ predicate?: string | undefined;
1261
+ field?: string | undefined;
1262
+ parameters?: ((params: any) => boolean) | undefined;
1263
+ errorMessage?: string | undefined;
1264
+ }, {
1265
+ type?: string | undefined;
1266
+ description?: string | undefined;
1267
+ name?: string | undefined;
1268
+ predicate?: string | undefined;
1269
+ field?: string | undefined;
1270
+ parameters?: ((params: any) => boolean) | undefined;
1271
+ errorMessage?: string | undefined;
1272
+ }>;
1273
+ }, "strip", z.ZodTypeAny, {
1274
+ type: "modifyConstraint";
1275
+ name: string;
1276
+ changes: {
1277
+ type?: string | undefined;
1278
+ description?: string | undefined;
1279
+ name?: string | undefined;
1280
+ predicate?: string | undefined;
1281
+ field?: string | undefined;
1282
+ parameters?: ((params: any) => boolean) | undefined;
1283
+ errorMessage?: string | undefined;
1284
+ };
1285
+ }, {
1286
+ type: "modifyConstraint";
1287
+ name: string;
1288
+ changes: {
1289
+ type?: string | undefined;
1290
+ description?: string | undefined;
1291
+ name?: string | undefined;
1292
+ predicate?: string | undefined;
1293
+ field?: string | undefined;
1294
+ parameters?: ((params: any) => boolean) | undefined;
1295
+ errorMessage?: string | undefined;
1296
+ };
1297
+ }>, z.ZodObject<{
1298
+ type: z.ZodLiteral<"deprecateField">;
1299
+ name: z.ZodString;
1300
+ }, "strip", z.ZodTypeAny, {
1301
+ type: "deprecateField";
1302
+ name: string;
1303
+ }, {
1304
+ type: "deprecateField";
1305
+ name: string;
1306
+ }>]>, "many">;
1307
+ description: z.ZodString;
1308
+ status: z.ZodEnum<["pending", "applied", "failed"]>;
1309
+ rollback: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
1310
+ type: z.ZodLiteral<"addField">;
1311
+ name: z.ZodString;
1312
+ definition: any;
1313
+ }, "strip", z.ZodTypeAny, {
1314
+ type: "addField";
1315
+ name: string;
1316
+ definition?: any;
1317
+ }, {
1318
+ type: "addField";
1319
+ name: string;
1320
+ definition?: any;
1321
+ }>, z.ZodObject<{
1322
+ type: z.ZodLiteral<"removeField">;
1323
+ name: z.ZodString;
1324
+ }, "strip", z.ZodTypeAny, {
1325
+ type: "removeField";
1326
+ name: string;
1327
+ }, {
1328
+ type: "removeField";
1329
+ name: string;
1330
+ }>, z.ZodObject<{
1331
+ type: z.ZodLiteral<"modifyField">;
1332
+ name: z.ZodString;
1333
+ changes: any;
1334
+ }, "strip", z.ZodTypeAny, {
1335
+ type: "modifyField";
1336
+ name: string;
1337
+ changes?: any;
1338
+ }, {
1339
+ type: "modifyField";
1340
+ name: string;
1341
+ changes?: any;
1342
+ }>, z.ZodObject<{
1343
+ type: z.ZodLiteral<"addIndex">;
1344
+ definition: z.ZodObject<{
1345
+ fields: z.ZodArray<z.ZodString, "many">;
1346
+ type: z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>;
1347
+ unique: z.ZodOptional<z.ZodBoolean>;
1348
+ partial: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
1349
+ description: z.ZodOptional<z.ZodString>;
1350
+ order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
1351
+ name: z.ZodOptional<z.ZodString>;
1352
+ }, "strip", z.ZodTypeAny, {
1353
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1354
+ fields: string[];
1355
+ unique?: boolean | undefined;
1356
+ description?: string | undefined;
1357
+ partial?: any;
1358
+ order?: "asc" | "desc" | undefined;
1359
+ name?: string | undefined;
1360
+ }, {
1361
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1362
+ fields: string[];
1363
+ unique?: boolean | undefined;
1364
+ description?: string | undefined;
1365
+ partial?: any;
1366
+ order?: "asc" | "desc" | undefined;
1367
+ name?: string | undefined;
1368
+ }>;
1369
+ }, "strip", z.ZodTypeAny, {
1370
+ type: "addIndex";
1371
+ definition: {
1372
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1373
+ fields: string[];
1374
+ unique?: boolean | undefined;
1375
+ description?: string | undefined;
1376
+ partial?: any;
1377
+ order?: "asc" | "desc" | undefined;
1378
+ name?: string | undefined;
1379
+ };
1380
+ }, {
1381
+ type: "addIndex";
1382
+ definition: {
1383
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1384
+ fields: string[];
1385
+ unique?: boolean | undefined;
1386
+ description?: string | undefined;
1387
+ partial?: any;
1388
+ order?: "asc" | "desc" | undefined;
1389
+ name?: string | undefined;
1390
+ };
1391
+ }>, z.ZodObject<{
1392
+ type: z.ZodLiteral<"removeIndex">;
1393
+ name: z.ZodString;
1394
+ }, "strip", z.ZodTypeAny, {
1395
+ type: "removeIndex";
1396
+ name: string;
1397
+ }, {
1398
+ type: "removeIndex";
1399
+ name: string;
1400
+ }>, z.ZodObject<{
1401
+ type: z.ZodLiteral<"modifyIndex">;
1402
+ name: z.ZodString;
1403
+ changes: z.ZodObject<{
1404
+ fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1405
+ type: z.ZodOptional<z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>>;
1406
+ unique: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
1407
+ partial: z.ZodOptional<z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>>;
1408
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1409
+ order: z.ZodOptional<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
1410
+ name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1411
+ }, "strip", z.ZodTypeAny, {
1412
+ unique?: boolean | undefined;
1413
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1414
+ description?: string | undefined;
1415
+ fields?: string[] | undefined;
1416
+ partial?: any;
1417
+ order?: "asc" | "desc" | undefined;
1418
+ name?: string | undefined;
1419
+ }, {
1420
+ unique?: boolean | undefined;
1421
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1422
+ description?: string | undefined;
1423
+ fields?: string[] | undefined;
1424
+ partial?: any;
1425
+ order?: "asc" | "desc" | undefined;
1426
+ name?: string | undefined;
1427
+ }>;
1428
+ }, "strip", z.ZodTypeAny, {
1429
+ type: "modifyIndex";
1430
+ name: string;
1431
+ changes: {
1432
+ unique?: boolean | undefined;
1433
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1434
+ description?: string | undefined;
1435
+ fields?: string[] | undefined;
1436
+ partial?: any;
1437
+ order?: "asc" | "desc" | undefined;
1438
+ name?: string | undefined;
1439
+ };
1440
+ }, {
1441
+ type: "modifyIndex";
1442
+ name: string;
1443
+ changes: {
1444
+ unique?: boolean | undefined;
1445
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1446
+ description?: string | undefined;
1447
+ fields?: string[] | undefined;
1448
+ partial?: any;
1449
+ order?: "asc" | "desc" | undefined;
1450
+ name?: string | undefined;
1451
+ };
1452
+ }>, z.ZodObject<{
1453
+ type: z.ZodLiteral<"addConstraint">;
1454
+ constraint: z.ZodUnion<[z.ZodObject<{
1455
+ type: z.ZodOptional<z.ZodString>;
1456
+ name: z.ZodString;
1457
+ predicate: z.ZodOptional<z.ZodString>;
1458
+ parameters: z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>;
1459
+ description: z.ZodOptional<z.ZodString>;
1460
+ field: z.ZodOptional<z.ZodString>;
1461
+ errorMessage: z.ZodOptional<z.ZodString>;
1462
+ }, "strip", z.ZodTypeAny, {
1463
+ name: string;
1464
+ type?: string | undefined;
1465
+ description?: string | undefined;
1466
+ predicate?: string | undefined;
1467
+ field?: string | undefined;
1468
+ parameters?: ((params: any) => boolean) | undefined;
1469
+ errorMessage?: string | undefined;
1470
+ }, {
1471
+ name: string;
1472
+ type?: string | undefined;
1473
+ description?: string | undefined;
1474
+ predicate?: string | undefined;
1475
+ field?: string | undefined;
1476
+ parameters?: ((params: any) => boolean) | undefined;
1477
+ errorMessage?: string | undefined;
1478
+ }>, any]>;
1479
+ }, "strip", z.ZodTypeAny, {
1480
+ type: "addConstraint";
1481
+ constraint?: any;
1482
+ }, {
1483
+ type: "addConstraint";
1484
+ constraint?: any;
1485
+ }>, z.ZodObject<{
1486
+ type: z.ZodLiteral<"removeConstraint">;
1487
+ name: z.ZodString;
1488
+ }, "strip", z.ZodTypeAny, {
1489
+ type: "removeConstraint";
1490
+ name: string;
1491
+ }, {
1492
+ type: "removeConstraint";
1493
+ name: string;
1494
+ }>, z.ZodObject<{
1495
+ type: z.ZodLiteral<"modifyConstraint">;
1496
+ name: z.ZodString;
1497
+ changes: z.ZodObject<{
1498
+ type: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1499
+ name: z.ZodOptional<z.ZodString>;
1500
+ predicate: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1501
+ parameters: z.ZodOptional<z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>>;
1502
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1503
+ field: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1504
+ errorMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1505
+ }, "strip", z.ZodTypeAny, {
1506
+ type?: string | undefined;
1507
+ description?: string | undefined;
1508
+ name?: string | undefined;
1509
+ predicate?: string | undefined;
1510
+ field?: string | undefined;
1511
+ parameters?: ((params: any) => boolean) | undefined;
1512
+ errorMessage?: string | undefined;
1513
+ }, {
1514
+ type?: string | undefined;
1515
+ description?: string | undefined;
1516
+ name?: string | undefined;
1517
+ predicate?: string | undefined;
1518
+ field?: string | undefined;
1519
+ parameters?: ((params: any) => boolean) | undefined;
1520
+ errorMessage?: string | undefined;
1521
+ }>;
1522
+ }, "strip", z.ZodTypeAny, {
1523
+ type: "modifyConstraint";
1524
+ name: string;
1525
+ changes: {
1526
+ type?: string | undefined;
1527
+ description?: string | undefined;
1528
+ name?: string | undefined;
1529
+ predicate?: string | undefined;
1530
+ field?: string | undefined;
1531
+ parameters?: ((params: any) => boolean) | undefined;
1532
+ errorMessage?: string | undefined;
1533
+ };
1534
+ }, {
1535
+ type: "modifyConstraint";
1536
+ name: string;
1537
+ changes: {
1538
+ type?: string | undefined;
1539
+ description?: string | undefined;
1540
+ name?: string | undefined;
1541
+ predicate?: string | undefined;
1542
+ field?: string | undefined;
1543
+ parameters?: ((params: any) => boolean) | undefined;
1544
+ errorMessage?: string | undefined;
1545
+ };
1546
+ }>, z.ZodObject<{
1547
+ type: z.ZodLiteral<"deprecateField">;
1548
+ name: z.ZodString;
1549
+ }, "strip", z.ZodTypeAny, {
1550
+ type: "deprecateField";
1551
+ name: string;
1552
+ }, {
1553
+ type: "deprecateField";
1554
+ name: string;
1555
+ }>]>, "many">>;
1556
+ transform: z.ZodUnknown;
1557
+ createdAt: z.ZodString;
1558
+ checksum: z.ZodOptional<z.ZodString>;
1559
+ }, "strip", z.ZodTypeAny, {
1560
+ description: string;
1561
+ changes: ({
1562
+ type: "addField";
1563
+ name: string;
1564
+ definition?: any;
1565
+ } | {
1566
+ type: "removeField";
1567
+ name: string;
1568
+ } | {
1569
+ type: "modifyField";
1570
+ name: string;
1571
+ changes?: any;
1572
+ } | {
1573
+ type: "addIndex";
1574
+ definition: {
1575
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1576
+ fields: string[];
1577
+ unique?: boolean | undefined;
1578
+ description?: string | undefined;
1579
+ partial?: any;
1580
+ order?: "asc" | "desc" | undefined;
1581
+ name?: string | undefined;
1582
+ };
1583
+ } | {
1584
+ type: "removeIndex";
1585
+ name: string;
1586
+ } | {
1587
+ type: "modifyIndex";
1588
+ name: string;
1589
+ changes: {
1590
+ unique?: boolean | undefined;
1591
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1592
+ description?: string | undefined;
1593
+ fields?: string[] | undefined;
1594
+ partial?: any;
1595
+ order?: "asc" | "desc" | undefined;
1596
+ name?: string | undefined;
1597
+ };
1598
+ } | {
1599
+ type: "addConstraint";
1600
+ constraint?: any;
1601
+ } | {
1602
+ type: "removeConstraint";
1603
+ name: string;
1604
+ } | {
1605
+ type: "modifyConstraint";
1606
+ name: string;
1607
+ changes: {
1608
+ type?: string | undefined;
1609
+ description?: string | undefined;
1610
+ name?: string | undefined;
1611
+ predicate?: string | undefined;
1612
+ field?: string | undefined;
1613
+ parameters?: ((params: any) => boolean) | undefined;
1614
+ errorMessage?: string | undefined;
1615
+ };
1616
+ } | {
1617
+ type: "deprecateField";
1618
+ name: string;
1619
+ })[];
1620
+ status: "pending" | "applied" | "failed";
1621
+ id: string;
1622
+ schemaVersion: string;
1623
+ createdAt: string;
1624
+ rollback?: ({
1625
+ type: "addField";
1626
+ name: string;
1627
+ definition?: any;
1628
+ } | {
1629
+ type: "removeField";
1630
+ name: string;
1631
+ } | {
1632
+ type: "modifyField";
1633
+ name: string;
1634
+ changes?: any;
1635
+ } | {
1636
+ type: "addIndex";
1637
+ definition: {
1638
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1639
+ fields: string[];
1640
+ unique?: boolean | undefined;
1641
+ description?: string | undefined;
1642
+ partial?: any;
1643
+ order?: "asc" | "desc" | undefined;
1644
+ name?: string | undefined;
1645
+ };
1646
+ } | {
1647
+ type: "removeIndex";
1648
+ name: string;
1649
+ } | {
1650
+ type: "modifyIndex";
1651
+ name: string;
1652
+ changes: {
1653
+ unique?: boolean | undefined;
1654
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1655
+ description?: string | undefined;
1656
+ fields?: string[] | undefined;
1657
+ partial?: any;
1658
+ order?: "asc" | "desc" | undefined;
1659
+ name?: string | undefined;
1660
+ };
1661
+ } | {
1662
+ type: "addConstraint";
1663
+ constraint?: any;
1664
+ } | {
1665
+ type: "removeConstraint";
1666
+ name: string;
1667
+ } | {
1668
+ type: "modifyConstraint";
1669
+ name: string;
1670
+ changes: {
1671
+ type?: string | undefined;
1672
+ description?: string | undefined;
1673
+ name?: string | undefined;
1674
+ predicate?: string | undefined;
1675
+ field?: string | undefined;
1676
+ parameters?: ((params: any) => boolean) | undefined;
1677
+ errorMessage?: string | undefined;
1678
+ };
1679
+ } | {
1680
+ type: "deprecateField";
1681
+ name: string;
1682
+ })[] | undefined;
1683
+ transform?: unknown;
1684
+ checksum?: string | undefined;
1685
+ }, {
1686
+ description: string;
1687
+ changes: ({
1688
+ type: "addField";
1689
+ name: string;
1690
+ definition?: any;
1691
+ } | {
1692
+ type: "removeField";
1693
+ name: string;
1694
+ } | {
1695
+ type: "modifyField";
1696
+ name: string;
1697
+ changes?: any;
1698
+ } | {
1699
+ type: "addIndex";
1700
+ definition: {
1701
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1702
+ fields: string[];
1703
+ unique?: boolean | undefined;
1704
+ description?: string | undefined;
1705
+ partial?: any;
1706
+ order?: "asc" | "desc" | undefined;
1707
+ name?: string | undefined;
1708
+ };
1709
+ } | {
1710
+ type: "removeIndex";
1711
+ name: string;
1712
+ } | {
1713
+ type: "modifyIndex";
1714
+ name: string;
1715
+ changes: {
1716
+ unique?: boolean | undefined;
1717
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1718
+ description?: string | undefined;
1719
+ fields?: string[] | undefined;
1720
+ partial?: any;
1721
+ order?: "asc" | "desc" | undefined;
1722
+ name?: string | undefined;
1723
+ };
1724
+ } | {
1725
+ type: "addConstraint";
1726
+ constraint?: any;
1727
+ } | {
1728
+ type: "removeConstraint";
1729
+ name: string;
1730
+ } | {
1731
+ type: "modifyConstraint";
1732
+ name: string;
1733
+ changes: {
1734
+ type?: string | undefined;
1735
+ description?: string | undefined;
1736
+ name?: string | undefined;
1737
+ predicate?: string | undefined;
1738
+ field?: string | undefined;
1739
+ parameters?: ((params: any) => boolean) | undefined;
1740
+ errorMessage?: string | undefined;
1741
+ };
1742
+ } | {
1743
+ type: "deprecateField";
1744
+ name: string;
1745
+ })[];
1746
+ status: "pending" | "applied" | "failed";
1747
+ id: string;
1748
+ schemaVersion: string;
1749
+ createdAt: string;
1750
+ rollback?: ({
1751
+ type: "addField";
1752
+ name: string;
1753
+ definition?: any;
1754
+ } | {
1755
+ type: "removeField";
1756
+ name: string;
1757
+ } | {
1758
+ type: "modifyField";
1759
+ name: string;
1760
+ changes?: any;
1761
+ } | {
1762
+ type: "addIndex";
1763
+ definition: {
1764
+ type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1765
+ fields: string[];
1766
+ unique?: boolean | undefined;
1767
+ description?: string | undefined;
1768
+ partial?: any;
1769
+ order?: "asc" | "desc" | undefined;
1770
+ name?: string | undefined;
1771
+ };
1772
+ } | {
1773
+ type: "removeIndex";
1774
+ name: string;
1775
+ } | {
1776
+ type: "modifyIndex";
1777
+ name: string;
1778
+ changes: {
1779
+ unique?: boolean | undefined;
1780
+ type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1781
+ description?: string | undefined;
1782
+ fields?: string[] | undefined;
1783
+ partial?: any;
1784
+ order?: "asc" | "desc" | undefined;
1785
+ name?: string | undefined;
1786
+ };
1787
+ } | {
1788
+ type: "addConstraint";
1789
+ constraint?: any;
1790
+ } | {
1791
+ type: "removeConstraint";
1792
+ name: string;
1793
+ } | {
1794
+ type: "modifyConstraint";
1795
+ name: string;
1796
+ changes: {
1797
+ type?: string | undefined;
1798
+ description?: string | undefined;
1799
+ name?: string | undefined;
1800
+ predicate?: string | undefined;
1801
+ field?: string | undefined;
1802
+ parameters?: ((params: any) => boolean) | undefined;
1803
+ errorMessage?: string | undefined;
1804
+ };
1805
+ } | {
1806
+ type: "deprecateField";
1807
+ name: string;
1808
+ })[] | undefined;
1809
+ transform?: unknown;
1810
+ checksum?: string | undefined;
1811
+ }>;
1812
+ declare function validateMigration<T>(change: any): change is Migration<T>;
1813
+ declare function validateSchemaChange<T>(change: any): change is SchemaChange<T>;
1814
+ declare function validateSchemaDefinition(schema: any): schema is SchemaDefinition;
1815
+ declare const validate: typeof validateSchemaDefinition;
1816
+
1817
+ declare const index_MigrationSchema: typeof MigrationSchema;
1818
+ declare const index_createSchemaMigrationHelper: typeof createSchemaMigrationHelper;
1819
+ declare const index_validate: typeof validate;
1820
+ declare const index_validateMigration: typeof validateMigration;
1821
+ declare const index_validateSchemaChange: typeof validateSchemaChange;
1822
+ declare const index_validateSchemaDefinition: typeof validateSchemaDefinition;
1823
+ declare namespace index {
1824
+ export { index_MigrationSchema as MigrationSchema, index_createSchemaMigrationHelper as createSchemaMigrationHelper, index_validate as validate, index_validateMigration as validateMigration, index_validateSchemaChange as validateSchemaChange, index_validateSchemaDefinition as validateSchemaDefinition };
1825
+ }
1826
+
1827
+ /**
1828
+ * Generates a SHA-256 hash of the input string.
1829
+ *
1830
+ * @param input - The string to hash.
1831
+ * @returns A promise that resolves to the hexadecimal hash string.
1832
+ */
1833
+ declare const generateSHA256Hash: (input: string) => Promise<string>;
1834
+
1835
+ declare const crypto_generateSHA256Hash: typeof generateSHA256Hash;
1836
+ declare namespace crypto {
1837
+ export { crypto_generateSHA256Hash as generateSHA256Hash };
1838
+ }
1839
+
1840
+ /**
1841
+ * Deeply merges a partial update into a target object
1842
+ * @param target The complete target object
1843
+ * @param update The partial update to apply
1844
+ * @returns Updated object of type T
1845
+ */
1846
+ declare function deepMerge<T extends object>(target: T, update: Partial<T>): T;
1847
+
1848
+ declare const merge_deepMerge: typeof deepMerge;
1849
+ declare namespace merge {
1850
+ export { merge_deepMerge as deepMerge };
1851
+ }
1852
+
1853
+ /**
1854
+ * Converts a schema definition into TypeScript type definitions
1855
+ * @param schema - The schema definition
1856
+ * @returns A string containing all type definitions
1857
+ */
1858
+ declare function schemaToTypes(schema: SchemaDefinition): string;
1859
+
1860
+ declare const typegen_schemaToTypes: typeof schemaToTypes;
1861
+ declare namespace typegen {
1862
+ export { schemaToTypes as default, typegen_schemaToTypes as schemaToTypes };
1863
+ }
1864
+
1865
+ /**
1866
+ * Creates a Standard Schema validator that conforms to the StandardSchemaV1 interface.
1867
+ * The validator uses a closure pattern to maintain internal state and avoid prop drilling.
1868
+ * Instead of only returning a boolean, the validator collects detailed error issues if validation fails.
1869
+ *
1870
+ * @template T - The type of the data object to validate
1871
+ * @param {SchemaDefinition} schema - The schema definition containing field and constraint rules
1872
+ * @param {PredicateMap} constraintsMap - A map of constraint names to predicate functions
1873
+ * @returns {StandardSchemaV1<T, T>} An object conforming to the StandardSchemaV1 interface
1874
+ *
1875
+ * @example
1876
+ * const validator = createStandardSchemaValidator(mySchema, myConstraints);
1877
+ * const result = validator["~standard"].validate(data);
1878
+ * if ('issues' in result) {
1879
+ * console.log('Validation failed:', result.issues);
1880
+ * }
1881
+ */
1882
+ declare function createStandardSchemaValidator<T extends Record<string, any>>(schema: SchemaDefinition, constraintsMap: PredicateMap): StandardSchemaV1<T, T>;
1883
+
1884
+ declare const validator_createStandardSchemaValidator: typeof createStandardSchemaValidator;
1885
+ declare namespace validator {
1886
+ export { validator_createStandardSchemaValidator as createStandardSchemaValidator };
1887
+ }
1888
+
1889
+ /**
1890
+ * Calculates the next version number based on schema changes.
1891
+ * @param currentVersion - Current semantic version string
1892
+ * @param changes - List of schema changes to apply
1893
+ * @param currentSchema - Current schema for context
1894
+ * @returns Next semantic version string
1895
+ * @throws {Error} If version format is invalid or changes are invalid
1896
+ */
1897
+ declare function calculateNextVersion(currentVersion: string, changes: SchemaChange<any>[], currentSchema?: SchemaDefinition): string;
1898
+ /**
1899
+ * compareSemanticVersions(a: string, b: string): number
1900
+ * Compares two semantic version strings.
1901
+ * @param {string} a - The first version string.
1902
+ * @param {string} b - The second version string.
1903
+ * @returns {number} - A negative number if `a` is smaller, a positive number if `b` is smaller, or 0 if they are equal.
1904
+ */
1905
+ declare function compareSemanticVersions(a: string, b: string): number;
1906
+ /**
1907
+ * Sorts an array of semantic version strings in ascending order.
1908
+ * @param {string[]} vars - The array of version strings to sort.
1909
+ * @returns {string[]} - The sorted array of version strings.
1910
+ */
1911
+ declare function sortSemanticVars(vars: string[]): string[];
1912
+
1913
+ declare const version_calculateNextVersion: typeof calculateNextVersion;
1914
+ declare const version_compareSemanticVersions: typeof compareSemanticVersions;
1915
+ declare const version_sortSemanticVars: typeof sortSemanticVars;
1916
+ declare namespace version {
1917
+ export { version_calculateNextVersion as calculateNextVersion, version_compareSemanticVersions as compareSemanticVersions, version_sortSemanticVars as sortSemanticVars };
1918
+ }
1919
+
1920
+ export { migrations as MigrationTypes, persistence as PersistenceTypes, registry as RegistryType, schemaDefinition as SchemaTypes, crypto, merge, index$1 as migration, patch, index$3 as persistence, index$2 as registry, index as schema, typegen, validator, version };