@asaidimu/anansi 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/index.cjs +35 -35
  2. package/index.d.cts +299 -113
  3. package/index.d.ts +299 -113
  4. package/index.js +35 -35
  5. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -102,6 +102,8 @@ interface ConstraintGroup<T extends FieldType> {
102
102
  * @template T The type of the field.
103
103
  */
104
104
  interface FieldDefinition<T> {
105
+ /** The name of the field. */
106
+ name: string;
105
107
  /** The type of the field. */
106
108
  type: FieldType;
107
109
  /** Whether the field is required. */
@@ -194,14 +196,14 @@ interface SchemaDefinition {
194
196
  */
195
197
  type SchemaChange<T> = {
196
198
  type: "addField";
197
- name: string;
199
+ id: string;
198
200
  definition: FieldDefinition<T>;
199
201
  } | {
200
202
  type: "removeField";
201
- name: string;
203
+ id: string;
202
204
  } | {
203
205
  type: "modifyField";
204
- name: string;
206
+ id: string;
205
207
  changes: Partial<FieldDefinition<T>>;
206
208
  } | {
207
209
  type: "addIndex";
@@ -225,7 +227,7 @@ type SchemaChange<T> = {
225
227
  changes: Partial<SchemaConstraint<any> | Constraint<any>>;
226
228
  } | {
227
229
  type: "deprecateField";
228
- name: string;
230
+ id: string;
229
231
  };
230
232
  /**
231
233
  * Defines a transform function for data migration.
@@ -857,6 +859,190 @@ declare enum MigrationErrorCode {
857
859
  ROLLBACK_ERROR = "ROLLBACK_ERROR",
858
860
  MISSING_TRANSFORM = "MISSING_TRANSFORM"
859
861
  }
862
+ /**
863
+ * @class MigrationEngine
864
+ * @param {SchemaDefinition} currentSchema - The current schema definition
865
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
866
+ * @throws {MigrationError} If the initial schema or migrations are invalid
867
+ */
868
+ declare class MigrationEngine {
869
+ private currentSchema;
870
+ private history;
871
+ private migrations;
872
+ private isProcessing;
873
+ /**
874
+ * @constructor
875
+ * @param {SchemaDefinition} currentSchema - The current schema definition
876
+ * @param {Array<Migration<any>>} [migrations] - Optional array of migrations
877
+ */
878
+ constructor(currentSchema: SchemaDefinition, migrations?: Array<Migration<any>>, history?: Array<SchemaDefinition>);
879
+ /**
880
+ * Gets the current state of the migration helper
881
+ * @returns {Object} Current state containing schema, history, and migrations
882
+ * @example
883
+ * ```javascript
884
+ * const state = migrationEngine.data();
885
+ * // state contains currentSchema, history, and migrations
886
+ * ```
887
+ */
888
+ data(): {
889
+ schema: SchemaDefinition;
890
+ history: SchemaDefinition[];
891
+ migrations: Migration<any>[];
892
+ };
893
+ /**
894
+ * Generates a SHA-256 checksum for a migration
895
+ * @private
896
+ * @param {Omit<Migration<any>, "checksum">} migration - The migration object
897
+ * @returns {Promise<string>} The generated checksum
898
+ * @throws {MigrationError} If checksum generation fails
899
+ */
900
+ private generateChecksum;
901
+ /**
902
+ * Adds a new migration to the engine
903
+ * @async
904
+ * @param {Object} opts - Options for the new migration
905
+ * @param {SchemaChange<any>[]} opts.changes - Array of schema changes
906
+ * @param {string} opts.description - Description of the migration
907
+ * @param {SchemaChange<any>[]} [opts.rollback] - Optional rollback changes
908
+ * @param {DataTransform<any, any>} [opts.transform] - Optional data transform
909
+ * @throws {MigrationError} If adding the migration fails
910
+ */
911
+ add(opts: {
912
+ changes: SchemaChange<any>[];
913
+ description: string;
914
+ rollback?: SchemaChange<any>[];
915
+ transform?: string | DataTransform<any, any>;
916
+ }): Promise<void>;
917
+ /**
918
+ * Performs a dry run of the migration
919
+ * @async
920
+ * @param {ReadableStream<any>} input - Input data stream
921
+ * @param {"forward" | "backward"} direction - Direction of migration
922
+ * @param {version} version - Version to rollback to
923
+ * @returns {Promise<Object>} Object containing newSchema and dataPreview
924
+ * @throws {MigrationError} If dry run fails
925
+ */
926
+ dryRun(input: ReadableStream<any>, direction: "forward" | "backward", version?: string): Promise<{
927
+ newSchema: SchemaDefinition;
928
+ dataPreview: ReadableStream<any>;
929
+ }>;
930
+ /**
931
+ * Gets relevant migrations based on direction
932
+ * @private
933
+ * @param {"forward" | "backward"} direction - Direction of migration
934
+ * @returns {Array<Migration<any>>} Relevant migrations
935
+ */
936
+ private getRelevantMigrations;
937
+ /**
938
+ * Applies schema changes to a given schema
939
+ * @private
940
+ * @param {SchemaDefinition} schema - The schema to modify
941
+ * @param {SchemaChange<any>[]} changes - Array of schema changes
942
+ * @param {string} [migrationId] - ID of the migration
943
+ * @returns {SchemaDefinition} Modified schema
944
+ * @throws {MigrationError} If applying changes fails
945
+ */
946
+ private applySchemaChanges;
947
+ /**
948
+ * Prepares the list of pending migrations for application
949
+ * @async
950
+ * @returns {Promise<Array<Migration<any>>} List of pending migrations
951
+ * @throws {MigrationError} If preparation fails
952
+ */
953
+ prepareMigration(): Promise<Array<Migration<any>>>;
954
+ /**
955
+ * Applies pending migrations
956
+ * @async
957
+ * @param {ReadableStream<any>} input - Input data stream
958
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
959
+ * @throws {MigrationError} If migration fails
960
+ */
961
+ migrate(input: ReadableStream<any>): Promise<ReadableStream<any>>;
962
+ /**
963
+ * Validates migrations by checking their checksums
964
+ * @private
965
+ * @async
966
+ * @param {Array<Migration<any>>} migrations - Migrations to validate
967
+ * @throws {MigrationError} If validation fails
968
+ */
969
+ private validateMigrations;
970
+ /**
971
+ * Marks migrations as applied
972
+ * @private
973
+ * @param {Array<Migration<any>>} migrations - Migrations to mark as applied
974
+ */
975
+ private markMigrationsApplied;
976
+ /**
977
+ * Rolls back the last applied migration
978
+ * @async
979
+ * @param {ReadableStream<any>} input - Input data stream
980
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
981
+ */
982
+ rollback(input: ReadableStream<any>): Promise<ReadableStream<any>>;
983
+ /**
984
+ * Rolls back to a specific schema version
985
+ * @async
986
+ * @param {string} targetVersion - Target schema version
987
+ * @param {ReadableStream<any>} input - Input data stream
988
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
989
+ * @throws {Error} If target version is not found
990
+ */
991
+ rollbackToVersion(targetVersion: string, input: ReadableStream<any>): Promise<ReadableStream<any>>;
992
+ /**
993
+ * Processes a list of migrations on a data stream, applying transformations
994
+ * in the specified direction (forward or backward).
995
+ *
996
+ * @static
997
+ * @async
998
+ * @param {ReadableStream<any>} input - The input data stream to process
999
+ * @param {"forward" | "backward"} direction - Direction of migration (either "forward" or "backward")
1000
+ * @param {Array<Migration<any>>} migrations - Array of Migration objects to process
1001
+ * @returns {Promise<ReadableStream<any>>} Transformed data stream
1002
+ * @throws {MigrationError} If any migration processing fails
1003
+ */
1004
+ static processMigrationList(input: ReadableStream<any>, direction: "forward" | "backward", migrations: Migration<any>[]): Promise<ReadableStream<any>>;
1005
+ /**
1006
+ * Resolves the transform function for a given migration in the specified direction.
1007
+ *
1008
+ * @private
1009
+ * @async
1010
+ * @param {Migration<any>} migration - The migration to resolve the transform for
1011
+ * @param {"forward" | "backward"} direction - Direction of migration
1012
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1013
+ * @throws {MigrationError} If transform resolution fails
1014
+ */
1015
+ private static resolveTransform;
1016
+ /**
1017
+ * Resolves a transform function from a remote URL.
1018
+ *
1019
+ * @private
1020
+ * @async
1021
+ * @param {string} url - URL of the transform module
1022
+ * @param {"forward" | "backward"} direction - Direction of migration
1023
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1024
+ * @throws {MigrationError} If resolution fails
1025
+ */
1026
+ private static resolveRemoteTransform;
1027
+ /**
1028
+ * Resolves a transform function from a local module path.
1029
+ *
1030
+ * @private
1031
+ * @async
1032
+ * @param {string} path - Local module path
1033
+ * @param {"forward" | "backward"} direction - Direction of migration
1034
+ * @returns {Promise<TransformFunction<any, any>>} Resolved transform function
1035
+ * @throws {MigrationError} If resolution fails
1036
+ */
1037
+ private static resolveLocalTransform;
1038
+ /**
1039
+ * Transforms the schema either forward or backward
1040
+ * @private
1041
+ * @param {"forward" | "backward"} direction - Direction of transformation
1042
+ * @throws {Error} If transformation fails
1043
+ */
1044
+ private transformSchema;
1045
+ }
860
1046
 
861
1047
  /**
862
1048
  * Helper for building schema migrations with forward and rollback changes.
@@ -871,36 +1057,36 @@ declare const MigrationSchema: z.ZodObject<{
871
1057
  schemaVersion: z.ZodString;
872
1058
  changes: z.ZodArray<z.ZodUnion<[z.ZodObject<{
873
1059
  type: z.ZodLiteral<"addField">;
874
- name: z.ZodString;
1060
+ id: z.ZodString;
875
1061
  definition: any;
876
1062
  }, "strip", z.ZodTypeAny, {
877
1063
  type: "addField";
878
- name: string;
1064
+ id: string;
879
1065
  definition?: any;
880
1066
  }, {
881
1067
  type: "addField";
882
- name: string;
1068
+ id: string;
883
1069
  definition?: any;
884
1070
  }>, z.ZodObject<{
885
1071
  type: z.ZodLiteral<"removeField">;
886
- name: z.ZodString;
1072
+ id: z.ZodString;
887
1073
  }, "strip", z.ZodTypeAny, {
888
1074
  type: "removeField";
889
- name: string;
1075
+ id: string;
890
1076
  }, {
891
1077
  type: "removeField";
892
- name: string;
1078
+ id: string;
893
1079
  }>, z.ZodObject<{
894
1080
  type: z.ZodLiteral<"modifyField">;
895
- name: z.ZodString;
1081
+ id: z.ZodString;
896
1082
  changes: any;
897
1083
  }, "strip", z.ZodTypeAny, {
898
1084
  type: "modifyField";
899
- name: string;
1085
+ id: string;
900
1086
  changes?: any;
901
1087
  }, {
902
1088
  type: "modifyField";
903
- name: string;
1089
+ id: string;
904
1090
  changes?: any;
905
1091
  }>, z.ZodObject<{
906
1092
  type: z.ZodLiteral<"addIndex">;
@@ -916,18 +1102,18 @@ declare const MigrationSchema: z.ZodObject<{
916
1102
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
917
1103
  fields: string[];
918
1104
  unique?: boolean | undefined;
1105
+ name?: string | undefined;
919
1106
  description?: string | undefined;
920
1107
  partial?: any;
921
1108
  order?: "asc" | "desc" | undefined;
922
- name?: string | undefined;
923
1109
  }, {
924
1110
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
925
1111
  fields: string[];
926
1112
  unique?: boolean | undefined;
1113
+ name?: string | undefined;
927
1114
  description?: string | undefined;
928
1115
  partial?: any;
929
1116
  order?: "asc" | "desc" | undefined;
930
- name?: string | undefined;
931
1117
  }>;
932
1118
  }, "strip", z.ZodTypeAny, {
933
1119
  type: "addIndex";
@@ -935,10 +1121,10 @@ declare const MigrationSchema: z.ZodObject<{
935
1121
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
936
1122
  fields: string[];
937
1123
  unique?: boolean | undefined;
1124
+ name?: string | undefined;
938
1125
  description?: string | undefined;
939
1126
  partial?: any;
940
1127
  order?: "asc" | "desc" | undefined;
941
- name?: string | undefined;
942
1128
  };
943
1129
  }, {
944
1130
  type: "addIndex";
@@ -946,20 +1132,20 @@ declare const MigrationSchema: z.ZodObject<{
946
1132
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
947
1133
  fields: string[];
948
1134
  unique?: boolean | undefined;
1135
+ name?: string | undefined;
949
1136
  description?: string | undefined;
950
1137
  partial?: any;
951
1138
  order?: "asc" | "desc" | undefined;
952
- name?: string | undefined;
953
1139
  };
954
1140
  }>, z.ZodObject<{
955
1141
  type: z.ZodLiteral<"removeIndex">;
956
1142
  name: z.ZodString;
957
1143
  }, "strip", z.ZodTypeAny, {
958
- type: "removeIndex";
959
1144
  name: string;
960
- }, {
961
1145
  type: "removeIndex";
1146
+ }, {
962
1147
  name: string;
1148
+ type: "removeIndex";
963
1149
  }>, z.ZodObject<{
964
1150
  type: z.ZodLiteral<"modifyIndex">;
965
1151
  name: z.ZodString;
@@ -973,44 +1159,44 @@ declare const MigrationSchema: z.ZodObject<{
973
1159
  name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
974
1160
  }, "strip", z.ZodTypeAny, {
975
1161
  unique?: boolean | undefined;
1162
+ name?: string | undefined;
976
1163
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
977
1164
  description?: string | undefined;
978
1165
  fields?: string[] | undefined;
979
1166
  partial?: any;
980
1167
  order?: "asc" | "desc" | undefined;
981
- name?: string | undefined;
982
1168
  }, {
983
1169
  unique?: boolean | undefined;
1170
+ name?: string | undefined;
984
1171
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
985
1172
  description?: string | undefined;
986
1173
  fields?: string[] | undefined;
987
1174
  partial?: any;
988
1175
  order?: "asc" | "desc" | undefined;
989
- name?: string | undefined;
990
1176
  }>;
991
1177
  }, "strip", z.ZodTypeAny, {
992
- type: "modifyIndex";
993
1178
  name: string;
1179
+ type: "modifyIndex";
994
1180
  changes: {
995
1181
  unique?: boolean | undefined;
1182
+ name?: string | undefined;
996
1183
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
997
1184
  description?: string | undefined;
998
1185
  fields?: string[] | undefined;
999
1186
  partial?: any;
1000
1187
  order?: "asc" | "desc" | undefined;
1001
- name?: string | undefined;
1002
1188
  };
1003
1189
  }, {
1004
- type: "modifyIndex";
1005
1190
  name: string;
1191
+ type: "modifyIndex";
1006
1192
  changes: {
1007
1193
  unique?: boolean | undefined;
1194
+ name?: string | undefined;
1008
1195
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1009
1196
  description?: string | undefined;
1010
1197
  fields?: string[] | undefined;
1011
1198
  partial?: any;
1012
1199
  order?: "asc" | "desc" | undefined;
1013
- name?: string | undefined;
1014
1200
  };
1015
1201
  }>, z.ZodObject<{
1016
1202
  type: z.ZodLiteral<"addConstraint">;
@@ -1049,11 +1235,11 @@ declare const MigrationSchema: z.ZodObject<{
1049
1235
  type: z.ZodLiteral<"removeConstraint">;
1050
1236
  name: z.ZodString;
1051
1237
  }, "strip", z.ZodTypeAny, {
1052
- type: "removeConstraint";
1053
1238
  name: string;
1054
- }, {
1055
1239
  type: "removeConstraint";
1240
+ }, {
1056
1241
  name: string;
1242
+ type: "removeConstraint";
1057
1243
  }>, z.ZodObject<{
1058
1244
  type: z.ZodLiteral<"modifyConstraint">;
1059
1245
  name: z.ZodString;
@@ -1066,41 +1252,41 @@ declare const MigrationSchema: z.ZodObject<{
1066
1252
  field: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1067
1253
  errorMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1068
1254
  }, "strip", z.ZodTypeAny, {
1255
+ name?: string | undefined;
1069
1256
  type?: string | undefined;
1070
1257
  description?: string | undefined;
1071
- name?: string | undefined;
1072
1258
  predicate?: string | undefined;
1073
1259
  field?: string | undefined;
1074
1260
  parameters?: ((params: any) => boolean) | undefined;
1075
1261
  errorMessage?: string | undefined;
1076
1262
  }, {
1263
+ name?: string | undefined;
1077
1264
  type?: string | undefined;
1078
1265
  description?: string | undefined;
1079
- name?: string | undefined;
1080
1266
  predicate?: string | undefined;
1081
1267
  field?: string | undefined;
1082
1268
  parameters?: ((params: any) => boolean) | undefined;
1083
1269
  errorMessage?: string | undefined;
1084
1270
  }>;
1085
1271
  }, "strip", z.ZodTypeAny, {
1086
- type: "modifyConstraint";
1087
1272
  name: string;
1273
+ type: "modifyConstraint";
1088
1274
  changes: {
1275
+ name?: string | undefined;
1089
1276
  type?: string | undefined;
1090
1277
  description?: string | undefined;
1091
- name?: string | undefined;
1092
1278
  predicate?: string | undefined;
1093
1279
  field?: string | undefined;
1094
1280
  parameters?: ((params: any) => boolean) | undefined;
1095
1281
  errorMessage?: string | undefined;
1096
1282
  };
1097
1283
  }, {
1098
- type: "modifyConstraint";
1099
1284
  name: string;
1285
+ type: "modifyConstraint";
1100
1286
  changes: {
1287
+ name?: string | undefined;
1101
1288
  type?: string | undefined;
1102
1289
  description?: string | undefined;
1103
- name?: string | undefined;
1104
1290
  predicate?: string | undefined;
1105
1291
  field?: string | undefined;
1106
1292
  parameters?: ((params: any) => boolean) | undefined;
@@ -1108,48 +1294,48 @@ declare const MigrationSchema: z.ZodObject<{
1108
1294
  };
1109
1295
  }>, z.ZodObject<{
1110
1296
  type: z.ZodLiteral<"deprecateField">;
1111
- name: z.ZodString;
1297
+ id: z.ZodString;
1112
1298
  }, "strip", z.ZodTypeAny, {
1113
1299
  type: "deprecateField";
1114
- name: string;
1300
+ id: string;
1115
1301
  }, {
1116
1302
  type: "deprecateField";
1117
- name: string;
1303
+ id: string;
1118
1304
  }>]>, "many">;
1119
1305
  description: z.ZodString;
1120
1306
  status: z.ZodEnum<["pending", "applied", "failed"]>;
1121
1307
  rollback: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
1122
1308
  type: z.ZodLiteral<"addField">;
1123
- name: z.ZodString;
1309
+ id: z.ZodString;
1124
1310
  definition: any;
1125
1311
  }, "strip", z.ZodTypeAny, {
1126
1312
  type: "addField";
1127
- name: string;
1313
+ id: string;
1128
1314
  definition?: any;
1129
1315
  }, {
1130
1316
  type: "addField";
1131
- name: string;
1317
+ id: string;
1132
1318
  definition?: any;
1133
1319
  }>, z.ZodObject<{
1134
1320
  type: z.ZodLiteral<"removeField">;
1135
- name: z.ZodString;
1321
+ id: z.ZodString;
1136
1322
  }, "strip", z.ZodTypeAny, {
1137
1323
  type: "removeField";
1138
- name: string;
1324
+ id: string;
1139
1325
  }, {
1140
1326
  type: "removeField";
1141
- name: string;
1327
+ id: string;
1142
1328
  }>, z.ZodObject<{
1143
1329
  type: z.ZodLiteral<"modifyField">;
1144
- name: z.ZodString;
1330
+ id: z.ZodString;
1145
1331
  changes: any;
1146
1332
  }, "strip", z.ZodTypeAny, {
1147
1333
  type: "modifyField";
1148
- name: string;
1334
+ id: string;
1149
1335
  changes?: any;
1150
1336
  }, {
1151
1337
  type: "modifyField";
1152
- name: string;
1338
+ id: string;
1153
1339
  changes?: any;
1154
1340
  }>, z.ZodObject<{
1155
1341
  type: z.ZodLiteral<"addIndex">;
@@ -1165,18 +1351,18 @@ declare const MigrationSchema: z.ZodObject<{
1165
1351
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1166
1352
  fields: string[];
1167
1353
  unique?: boolean | undefined;
1354
+ name?: string | undefined;
1168
1355
  description?: string | undefined;
1169
1356
  partial?: any;
1170
1357
  order?: "asc" | "desc" | undefined;
1171
- name?: string | undefined;
1172
1358
  }, {
1173
1359
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1174
1360
  fields: string[];
1175
1361
  unique?: boolean | undefined;
1362
+ name?: string | undefined;
1176
1363
  description?: string | undefined;
1177
1364
  partial?: any;
1178
1365
  order?: "asc" | "desc" | undefined;
1179
- name?: string | undefined;
1180
1366
  }>;
1181
1367
  }, "strip", z.ZodTypeAny, {
1182
1368
  type: "addIndex";
@@ -1184,10 +1370,10 @@ declare const MigrationSchema: z.ZodObject<{
1184
1370
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1185
1371
  fields: string[];
1186
1372
  unique?: boolean | undefined;
1373
+ name?: string | undefined;
1187
1374
  description?: string | undefined;
1188
1375
  partial?: any;
1189
1376
  order?: "asc" | "desc" | undefined;
1190
- name?: string | undefined;
1191
1377
  };
1192
1378
  }, {
1193
1379
  type: "addIndex";
@@ -1195,20 +1381,20 @@ declare const MigrationSchema: z.ZodObject<{
1195
1381
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1196
1382
  fields: string[];
1197
1383
  unique?: boolean | undefined;
1384
+ name?: string | undefined;
1198
1385
  description?: string | undefined;
1199
1386
  partial?: any;
1200
1387
  order?: "asc" | "desc" | undefined;
1201
- name?: string | undefined;
1202
1388
  };
1203
1389
  }>, z.ZodObject<{
1204
1390
  type: z.ZodLiteral<"removeIndex">;
1205
1391
  name: z.ZodString;
1206
1392
  }, "strip", z.ZodTypeAny, {
1207
- type: "removeIndex";
1208
1393
  name: string;
1209
- }, {
1210
1394
  type: "removeIndex";
1395
+ }, {
1211
1396
  name: string;
1397
+ type: "removeIndex";
1212
1398
  }>, z.ZodObject<{
1213
1399
  type: z.ZodLiteral<"modifyIndex">;
1214
1400
  name: z.ZodString;
@@ -1222,44 +1408,44 @@ declare const MigrationSchema: z.ZodObject<{
1222
1408
  name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1223
1409
  }, "strip", z.ZodTypeAny, {
1224
1410
  unique?: boolean | undefined;
1411
+ name?: string | undefined;
1225
1412
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1226
1413
  description?: string | undefined;
1227
1414
  fields?: string[] | undefined;
1228
1415
  partial?: any;
1229
1416
  order?: "asc" | "desc" | undefined;
1230
- name?: string | undefined;
1231
1417
  }, {
1232
1418
  unique?: boolean | undefined;
1419
+ name?: string | undefined;
1233
1420
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1234
1421
  description?: string | undefined;
1235
1422
  fields?: string[] | undefined;
1236
1423
  partial?: any;
1237
1424
  order?: "asc" | "desc" | undefined;
1238
- name?: string | undefined;
1239
1425
  }>;
1240
1426
  }, "strip", z.ZodTypeAny, {
1241
- type: "modifyIndex";
1242
1427
  name: string;
1428
+ type: "modifyIndex";
1243
1429
  changes: {
1244
1430
  unique?: boolean | undefined;
1431
+ name?: string | undefined;
1245
1432
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1246
1433
  description?: string | undefined;
1247
1434
  fields?: string[] | undefined;
1248
1435
  partial?: any;
1249
1436
  order?: "asc" | "desc" | undefined;
1250
- name?: string | undefined;
1251
1437
  };
1252
1438
  }, {
1253
- type: "modifyIndex";
1254
1439
  name: string;
1440
+ type: "modifyIndex";
1255
1441
  changes: {
1256
1442
  unique?: boolean | undefined;
1443
+ name?: string | undefined;
1257
1444
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1258
1445
  description?: string | undefined;
1259
1446
  fields?: string[] | undefined;
1260
1447
  partial?: any;
1261
1448
  order?: "asc" | "desc" | undefined;
1262
- name?: string | undefined;
1263
1449
  };
1264
1450
  }>, z.ZodObject<{
1265
1451
  type: z.ZodLiteral<"addConstraint">;
@@ -1298,11 +1484,11 @@ declare const MigrationSchema: z.ZodObject<{
1298
1484
  type: z.ZodLiteral<"removeConstraint">;
1299
1485
  name: z.ZodString;
1300
1486
  }, "strip", z.ZodTypeAny, {
1301
- type: "removeConstraint";
1302
1487
  name: string;
1303
- }, {
1304
1488
  type: "removeConstraint";
1489
+ }, {
1305
1490
  name: string;
1491
+ type: "removeConstraint";
1306
1492
  }>, z.ZodObject<{
1307
1493
  type: z.ZodLiteral<"modifyConstraint">;
1308
1494
  name: z.ZodString;
@@ -1315,41 +1501,41 @@ declare const MigrationSchema: z.ZodObject<{
1315
1501
  field: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1316
1502
  errorMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
1317
1503
  }, "strip", z.ZodTypeAny, {
1504
+ name?: string | undefined;
1318
1505
  type?: string | undefined;
1319
1506
  description?: string | undefined;
1320
- name?: string | undefined;
1321
1507
  predicate?: string | undefined;
1322
1508
  field?: string | undefined;
1323
1509
  parameters?: ((params: any) => boolean) | undefined;
1324
1510
  errorMessage?: string | undefined;
1325
1511
  }, {
1512
+ name?: string | undefined;
1326
1513
  type?: string | undefined;
1327
1514
  description?: string | undefined;
1328
- name?: string | undefined;
1329
1515
  predicate?: string | undefined;
1330
1516
  field?: string | undefined;
1331
1517
  parameters?: ((params: any) => boolean) | undefined;
1332
1518
  errorMessage?: string | undefined;
1333
1519
  }>;
1334
1520
  }, "strip", z.ZodTypeAny, {
1335
- type: "modifyConstraint";
1336
1521
  name: string;
1522
+ type: "modifyConstraint";
1337
1523
  changes: {
1524
+ name?: string | undefined;
1338
1525
  type?: string | undefined;
1339
1526
  description?: string | undefined;
1340
- name?: string | undefined;
1341
1527
  predicate?: string | undefined;
1342
1528
  field?: string | undefined;
1343
1529
  parameters?: ((params: any) => boolean) | undefined;
1344
1530
  errorMessage?: string | undefined;
1345
1531
  };
1346
1532
  }, {
1347
- type: "modifyConstraint";
1348
1533
  name: string;
1534
+ type: "modifyConstraint";
1349
1535
  changes: {
1536
+ name?: string | undefined;
1350
1537
  type?: string | undefined;
1351
1538
  description?: string | undefined;
1352
- name?: string | undefined;
1353
1539
  predicate?: string | undefined;
1354
1540
  field?: string | undefined;
1355
1541
  parameters?: ((params: any) => boolean) | undefined;
@@ -1357,13 +1543,13 @@ declare const MigrationSchema: z.ZodObject<{
1357
1543
  };
1358
1544
  }>, z.ZodObject<{
1359
1545
  type: z.ZodLiteral<"deprecateField">;
1360
- name: z.ZodString;
1546
+ id: z.ZodString;
1361
1547
  }, "strip", z.ZodTypeAny, {
1362
1548
  type: "deprecateField";
1363
- name: string;
1549
+ id: string;
1364
1550
  }, {
1365
1551
  type: "deprecateField";
1366
- name: string;
1552
+ id: string;
1367
1553
  }>]>, "many">>;
1368
1554
  transform: z.ZodUnknown;
1369
1555
  createdAt: z.ZodString;
@@ -1372,14 +1558,14 @@ declare const MigrationSchema: z.ZodObject<{
1372
1558
  description: string;
1373
1559
  changes: ({
1374
1560
  type: "addField";
1375
- name: string;
1561
+ id: string;
1376
1562
  definition?: any;
1377
1563
  } | {
1378
1564
  type: "removeField";
1379
- name: string;
1565
+ id: string;
1380
1566
  } | {
1381
1567
  type: "modifyField";
1382
- name: string;
1568
+ id: string;
1383
1569
  changes?: any;
1384
1570
  } | {
1385
1571
  type: "addIndex";
@@ -1387,39 +1573,39 @@ declare const MigrationSchema: z.ZodObject<{
1387
1573
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1388
1574
  fields: string[];
1389
1575
  unique?: boolean | undefined;
1576
+ name?: string | undefined;
1390
1577
  description?: string | undefined;
1391
1578
  partial?: any;
1392
1579
  order?: "asc" | "desc" | undefined;
1393
- name?: string | undefined;
1394
1580
  };
1395
1581
  } | {
1396
- type: "removeIndex";
1397
1582
  name: string;
1583
+ type: "removeIndex";
1398
1584
  } | {
1399
- type: "modifyIndex";
1400
1585
  name: string;
1586
+ type: "modifyIndex";
1401
1587
  changes: {
1402
1588
  unique?: boolean | undefined;
1589
+ name?: string | undefined;
1403
1590
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1404
1591
  description?: string | undefined;
1405
1592
  fields?: string[] | undefined;
1406
1593
  partial?: any;
1407
1594
  order?: "asc" | "desc" | undefined;
1408
- name?: string | undefined;
1409
1595
  };
1410
1596
  } | {
1411
1597
  type: "addConstraint";
1412
1598
  constraint?: any;
1413
1599
  } | {
1414
- type: "removeConstraint";
1415
1600
  name: string;
1601
+ type: "removeConstraint";
1416
1602
  } | {
1417
- type: "modifyConstraint";
1418
1603
  name: string;
1604
+ type: "modifyConstraint";
1419
1605
  changes: {
1606
+ name?: string | undefined;
1420
1607
  type?: string | undefined;
1421
1608
  description?: string | undefined;
1422
- name?: string | undefined;
1423
1609
  predicate?: string | undefined;
1424
1610
  field?: string | undefined;
1425
1611
  parameters?: ((params: any) => boolean) | undefined;
@@ -1427,7 +1613,7 @@ declare const MigrationSchema: z.ZodObject<{
1427
1613
  };
1428
1614
  } | {
1429
1615
  type: "deprecateField";
1430
- name: string;
1616
+ id: string;
1431
1617
  })[];
1432
1618
  status: "pending" | "applied" | "failed";
1433
1619
  id: string;
@@ -1435,14 +1621,14 @@ declare const MigrationSchema: z.ZodObject<{
1435
1621
  createdAt: string;
1436
1622
  rollback?: ({
1437
1623
  type: "addField";
1438
- name: string;
1624
+ id: string;
1439
1625
  definition?: any;
1440
1626
  } | {
1441
1627
  type: "removeField";
1442
- name: string;
1628
+ id: string;
1443
1629
  } | {
1444
1630
  type: "modifyField";
1445
- name: string;
1631
+ id: string;
1446
1632
  changes?: any;
1447
1633
  } | {
1448
1634
  type: "addIndex";
@@ -1450,39 +1636,39 @@ declare const MigrationSchema: z.ZodObject<{
1450
1636
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1451
1637
  fields: string[];
1452
1638
  unique?: boolean | undefined;
1639
+ name?: string | undefined;
1453
1640
  description?: string | undefined;
1454
1641
  partial?: any;
1455
1642
  order?: "asc" | "desc" | undefined;
1456
- name?: string | undefined;
1457
1643
  };
1458
1644
  } | {
1459
- type: "removeIndex";
1460
1645
  name: string;
1646
+ type: "removeIndex";
1461
1647
  } | {
1462
- type: "modifyIndex";
1463
1648
  name: string;
1649
+ type: "modifyIndex";
1464
1650
  changes: {
1465
1651
  unique?: boolean | undefined;
1652
+ name?: string | undefined;
1466
1653
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1467
1654
  description?: string | undefined;
1468
1655
  fields?: string[] | undefined;
1469
1656
  partial?: any;
1470
1657
  order?: "asc" | "desc" | undefined;
1471
- name?: string | undefined;
1472
1658
  };
1473
1659
  } | {
1474
1660
  type: "addConstraint";
1475
1661
  constraint?: any;
1476
1662
  } | {
1477
- type: "removeConstraint";
1478
1663
  name: string;
1664
+ type: "removeConstraint";
1479
1665
  } | {
1480
- type: "modifyConstraint";
1481
1666
  name: string;
1667
+ type: "modifyConstraint";
1482
1668
  changes: {
1669
+ name?: string | undefined;
1483
1670
  type?: string | undefined;
1484
1671
  description?: string | undefined;
1485
- name?: string | undefined;
1486
1672
  predicate?: string | undefined;
1487
1673
  field?: string | undefined;
1488
1674
  parameters?: ((params: any) => boolean) | undefined;
@@ -1490,7 +1676,7 @@ declare const MigrationSchema: z.ZodObject<{
1490
1676
  };
1491
1677
  } | {
1492
1678
  type: "deprecateField";
1493
- name: string;
1679
+ id: string;
1494
1680
  })[] | undefined;
1495
1681
  transform?: unknown;
1496
1682
  checksum?: string | undefined;
@@ -1498,14 +1684,14 @@ declare const MigrationSchema: z.ZodObject<{
1498
1684
  description: string;
1499
1685
  changes: ({
1500
1686
  type: "addField";
1501
- name: string;
1687
+ id: string;
1502
1688
  definition?: any;
1503
1689
  } | {
1504
1690
  type: "removeField";
1505
- name: string;
1691
+ id: string;
1506
1692
  } | {
1507
1693
  type: "modifyField";
1508
- name: string;
1694
+ id: string;
1509
1695
  changes?: any;
1510
1696
  } | {
1511
1697
  type: "addIndex";
@@ -1513,39 +1699,39 @@ declare const MigrationSchema: z.ZodObject<{
1513
1699
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1514
1700
  fields: string[];
1515
1701
  unique?: boolean | undefined;
1702
+ name?: string | undefined;
1516
1703
  description?: string | undefined;
1517
1704
  partial?: any;
1518
1705
  order?: "asc" | "desc" | undefined;
1519
- name?: string | undefined;
1520
1706
  };
1521
1707
  } | {
1522
- type: "removeIndex";
1523
1708
  name: string;
1709
+ type: "removeIndex";
1524
1710
  } | {
1525
- type: "modifyIndex";
1526
1711
  name: string;
1712
+ type: "modifyIndex";
1527
1713
  changes: {
1528
1714
  unique?: boolean | undefined;
1715
+ name?: string | undefined;
1529
1716
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1530
1717
  description?: string | undefined;
1531
1718
  fields?: string[] | undefined;
1532
1719
  partial?: any;
1533
1720
  order?: "asc" | "desc" | undefined;
1534
- name?: string | undefined;
1535
1721
  };
1536
1722
  } | {
1537
1723
  type: "addConstraint";
1538
1724
  constraint?: any;
1539
1725
  } | {
1540
- type: "removeConstraint";
1541
1726
  name: string;
1727
+ type: "removeConstraint";
1542
1728
  } | {
1543
- type: "modifyConstraint";
1544
1729
  name: string;
1730
+ type: "modifyConstraint";
1545
1731
  changes: {
1732
+ name?: string | undefined;
1546
1733
  type?: string | undefined;
1547
1734
  description?: string | undefined;
1548
- name?: string | undefined;
1549
1735
  predicate?: string | undefined;
1550
1736
  field?: string | undefined;
1551
1737
  parameters?: ((params: any) => boolean) | undefined;
@@ -1553,7 +1739,7 @@ declare const MigrationSchema: z.ZodObject<{
1553
1739
  };
1554
1740
  } | {
1555
1741
  type: "deprecateField";
1556
- name: string;
1742
+ id: string;
1557
1743
  })[];
1558
1744
  status: "pending" | "applied" | "failed";
1559
1745
  id: string;
@@ -1561,14 +1747,14 @@ declare const MigrationSchema: z.ZodObject<{
1561
1747
  createdAt: string;
1562
1748
  rollback?: ({
1563
1749
  type: "addField";
1564
- name: string;
1750
+ id: string;
1565
1751
  definition?: any;
1566
1752
  } | {
1567
1753
  type: "removeField";
1568
- name: string;
1754
+ id: string;
1569
1755
  } | {
1570
1756
  type: "modifyField";
1571
- name: string;
1757
+ id: string;
1572
1758
  changes?: any;
1573
1759
  } | {
1574
1760
  type: "addIndex";
@@ -1576,39 +1762,39 @@ declare const MigrationSchema: z.ZodObject<{
1576
1762
  type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
1577
1763
  fields: string[];
1578
1764
  unique?: boolean | undefined;
1765
+ name?: string | undefined;
1579
1766
  description?: string | undefined;
1580
1767
  partial?: any;
1581
1768
  order?: "asc" | "desc" | undefined;
1582
- name?: string | undefined;
1583
1769
  };
1584
1770
  } | {
1585
- type: "removeIndex";
1586
1771
  name: string;
1772
+ type: "removeIndex";
1587
1773
  } | {
1588
- type: "modifyIndex";
1589
1774
  name: string;
1775
+ type: "modifyIndex";
1590
1776
  changes: {
1591
1777
  unique?: boolean | undefined;
1778
+ name?: string | undefined;
1592
1779
  type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
1593
1780
  description?: string | undefined;
1594
1781
  fields?: string[] | undefined;
1595
1782
  partial?: any;
1596
1783
  order?: "asc" | "desc" | undefined;
1597
- name?: string | undefined;
1598
1784
  };
1599
1785
  } | {
1600
1786
  type: "addConstraint";
1601
1787
  constraint?: any;
1602
1788
  } | {
1603
- type: "removeConstraint";
1604
1789
  name: string;
1790
+ type: "removeConstraint";
1605
1791
  } | {
1606
- type: "modifyConstraint";
1607
1792
  name: string;
1793
+ type: "modifyConstraint";
1608
1794
  changes: {
1795
+ name?: string | undefined;
1609
1796
  type?: string | undefined;
1610
1797
  description?: string | undefined;
1611
- name?: string | undefined;
1612
1798
  predicate?: string | undefined;
1613
1799
  field?: string | undefined;
1614
1800
  parameters?: ((params: any) => boolean) | undefined;
@@ -1616,7 +1802,7 @@ declare const MigrationSchema: z.ZodObject<{
1616
1802
  };
1617
1803
  } | {
1618
1804
  type: "deprecateField";
1619
- name: string;
1805
+ id: string;
1620
1806
  })[] | undefined;
1621
1807
  transform?: unknown;
1622
1808
  checksum?: string | undefined;
@@ -1696,4 +1882,4 @@ declare function docgen(schema: SchemaDefinition, options?: {
1696
1882
  faker?: Faker;
1697
1883
  }): string;
1698
1884
 
1699
- export { type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type FieldDefinition, type FieldType, type FunctionMap, type IndexDefinition, type IndexType, JsonPatchError, type LogicalOperator, type Migration, type MigrationEngineInterface, MigrationError, MigrationErrorCode, type MigrationMetadata, MigrationSchema, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, type SchemaRegistry, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaToTypes, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };
1885
+ export { type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type FieldDefinition, type FieldType, type FunctionMap, type IndexDefinition, type IndexType, JsonPatchError, type LogicalOperator, type Migration, MigrationEngine, type MigrationEngineInterface, MigrationError, MigrationErrorCode, type MigrationMetadata, MigrationSchema, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, type SchemaRegistry, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaToTypes, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };