@asaidimu/anansi 1.3.3 → 1.4.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.cjs +45 -46
- package/index.d.cts +401 -904
- package/index.d.ts +401 -904
- package/index.js +45 -46
- package/package.json +5 -3
package/index.d.cts
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
|
+
import * as _faker_js_faker from '@faker-js/faker';
|
|
1
2
|
import { Faker } from '@faker-js/faker';
|
|
2
3
|
import { QueryDSL, QueryFilter } from '@asaidimu/query';
|
|
3
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import
|
|
5
|
+
import LightningFS from '@isomorphic-git/lightning-fs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* SchemaDefinition.ts
|
|
9
|
+
*
|
|
10
|
+
* Defines a robust schema specification for modeling data structures in an ERP system.
|
|
11
|
+
* Supports atomic schemas with reusable nested definitions (now as mini-SchemaDefinitions),
|
|
12
|
+
* flexible constraints, and indexing. Inspired by SQL pragmatism, it allows circular references
|
|
13
|
+
* (via 'reference' and 'nestedSchema.id') and relies on tooling for runtime handling
|
|
14
|
+
* (e.g., breaking validation/serialization loops). Intended for use with an IDE that validates
|
|
15
|
+
* syntax and semantics at publish time. Versioning is managed at the root level only,
|
|
16
|
+
* avoiding unnecessary API complexity.
|
|
17
|
+
*
|
|
18
|
+
* NOTE: Most places where a Record<string, something> is used, and something has
|
|
19
|
+
* a name property,then string should be treated as an id and will be a uuid.
|
|
20
|
+
* for display purposes: validation, code generation, e.t.c something.name
|
|
21
|
+
* should be prefered
|
|
8
22
|
*/
|
|
9
|
-
|
|
10
23
|
/**
|
|
11
|
-
* Logical operators for constraints
|
|
24
|
+
* Logical operators for combining constraints or index conditions.
|
|
12
25
|
*/
|
|
13
26
|
type LogicalOperator = "and" | "or" | "not" | "nor" | "xor";
|
|
14
27
|
/**
|
|
15
28
|
* Basic field types supported by the schema system.
|
|
16
29
|
*/
|
|
17
|
-
type FieldType = "string" | "number" | "boolean" | "array" | "object" | "dynamic";
|
|
30
|
+
type FieldType = "string" | "number" | "boolean" | "array" | "set" | "enum" | "object" | "dynamic";
|
|
18
31
|
/**
|
|
19
32
|
* Index types for optimizing different query patterns.
|
|
20
33
|
*/
|
|
21
34
|
type IndexType = "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
22
35
|
/**
|
|
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.
|
|
36
|
+
* Defines a predicate function for data validation, mapped to a PredicateMap at runtime.
|
|
31
37
|
*/
|
|
32
38
|
type Predicate = <T, K extends FieldType = any>(params: {
|
|
33
39
|
data: T;
|
|
@@ -35,21 +41,21 @@ type Predicate = <T, K extends FieldType = any>(params: {
|
|
|
35
41
|
arguments: PredicateParameters<K>;
|
|
36
42
|
}) => boolean;
|
|
37
43
|
/**
|
|
38
|
-
* A map of
|
|
39
|
-
* @template T The type of the data object.
|
|
44
|
+
* A map of predicate names to their validation functions, implemented by the runtime environment.
|
|
40
45
|
*/
|
|
41
46
|
type PredicateMap = Record<string, Predicate>;
|
|
47
|
+
/**
|
|
48
|
+
* A map of function names to generic functions, used elsewhere in the system.
|
|
49
|
+
*/
|
|
42
50
|
type FunctionMap = Record<string, Function>;
|
|
43
|
-
/** @deprecated */
|
|
51
|
+
/** @deprecated Use PredicateMap instead. */
|
|
44
52
|
type ConstraintsMap = Record<string, Predicate>;
|
|
45
53
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @template T The type of the constraints map.
|
|
54
|
+
* Names of supported predicates, derived from a PredicateMap.
|
|
48
55
|
*/
|
|
49
56
|
type PredicateName<T extends PredicateMap = any> = keyof T;
|
|
50
57
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @template T The field type.
|
|
58
|
+
* Parameters for predicates, tailored to each field type.
|
|
53
59
|
*/
|
|
54
60
|
type PredicateParameters<T extends FieldType> = T extends "string" ? string | string[] | RegExp | {
|
|
55
61
|
field: string;
|
|
@@ -58,146 +64,122 @@ type PredicateParameters<T extends FieldType> = T extends "string" ? string | st
|
|
|
58
64
|
scale?: number;
|
|
59
65
|
} | {
|
|
60
66
|
field: string;
|
|
61
|
-
} : T extends "boolean" ? boolean : T extends "array" ? number | {
|
|
67
|
+
} : T extends "boolean" ? boolean : T extends "array" | "set" ? number | {
|
|
62
68
|
minItems: number;
|
|
63
69
|
maxItems: number;
|
|
64
70
|
} : T extends "object" ? {
|
|
65
71
|
schema: Record<string, unknown>;
|
|
66
|
-
} : never;
|
|
67
|
-
/** @deprecated */
|
|
72
|
+
} : T extends "dynamic" ? any : never;
|
|
73
|
+
/** @deprecated Use PredicateParameters instead. */
|
|
68
74
|
type ConstraintParameters<T extends FieldType> = PredicateParameters<T>;
|
|
69
75
|
/**
|
|
70
|
-
* Defines a constraint on a field.
|
|
71
|
-
* @template T The field type.
|
|
76
|
+
* Defines a constraint on a field or schema, using a predicate for validation.
|
|
72
77
|
*/
|
|
73
78
|
type Constraint<T extends FieldType> = {
|
|
74
79
|
type?: "schema";
|
|
75
|
-
/** The predicate function for the constraint */
|
|
76
80
|
predicate: string;
|
|
77
|
-
/** The field the constraint applies to */
|
|
78
81
|
field?: keyof any;
|
|
79
|
-
/** The parameters for the constraint. */
|
|
80
82
|
parameters?: PredicateParameters<T>;
|
|
81
|
-
/** The name of the constraint. */
|
|
82
83
|
name: string;
|
|
83
|
-
/** A description of the constraint. */
|
|
84
84
|
description?: string;
|
|
85
|
-
/** A custom error message for the constraint. */
|
|
86
85
|
errorMessage?: string;
|
|
87
86
|
};
|
|
88
87
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @template T The field type.
|
|
88
|
+
* Groups multiple constraints with a logical operator for complex validation logic.
|
|
91
89
|
*/
|
|
92
90
|
interface ConstraintGroup<T extends FieldType> {
|
|
93
|
-
/** The name of the constraint. */
|
|
94
91
|
name: string;
|
|
95
|
-
/** The logical operator for the group (AND or OR). */
|
|
96
92
|
operator: LogicalOperator;
|
|
97
|
-
/** The rules in the group, which can be constraints or other constraint groups. */
|
|
98
93
|
rules: Array<Constraint<T> | ConstraintGroup<T>>;
|
|
99
94
|
}
|
|
100
95
|
/**
|
|
101
|
-
*
|
|
102
|
-
|
|
96
|
+
* Collection of constraints or groups applied at the schema or nested level.
|
|
97
|
+
*/
|
|
98
|
+
type SchemaConstraint<T extends FieldType> = Array<Constraint<T> | ConstraintGroup<T>>;
|
|
99
|
+
/**
|
|
100
|
+
* Defines a field within a schema, including its type, constraints, and nesting.
|
|
103
101
|
*/
|
|
104
102
|
interface FieldDefinition<T> {
|
|
105
|
-
/** The name of the field. */
|
|
106
103
|
name: string;
|
|
107
|
-
/** The type of the field. */
|
|
108
104
|
type: FieldType;
|
|
109
|
-
/** Whether the field is required. */
|
|
110
105
|
required?: boolean;
|
|
111
|
-
/** The constraints on the field. */
|
|
112
106
|
constraints?: Constraint<any>[];
|
|
113
|
-
/** The default value of the field. */
|
|
114
107
|
default?: T;
|
|
115
|
-
|
|
108
|
+
values?: Array<unknown>;
|
|
116
109
|
itemsType?: FieldType;
|
|
117
|
-
/**
|
|
118
|
-
nestedSchema?:
|
|
119
|
-
|
|
110
|
+
/** Reference to a nested schema (mini-SchemaDefinition) with optional overrides. */
|
|
111
|
+
nestedSchema?: {
|
|
112
|
+
id: string;
|
|
113
|
+
constraints?: SchemaConstraint<any>;
|
|
114
|
+
indexes?: IndexDefinition[];
|
|
115
|
+
};
|
|
120
116
|
deprecated?: boolean;
|
|
121
|
-
/** A reference to another schema and field. */
|
|
122
117
|
reference?: {
|
|
123
118
|
schema: string;
|
|
124
119
|
field: string;
|
|
125
120
|
};
|
|
126
|
-
/** A description of the field. */
|
|
127
121
|
description?: string;
|
|
128
|
-
/** Whether the field is unique. */
|
|
129
122
|
unique?: boolean;
|
|
130
123
|
}
|
|
131
124
|
/**
|
|
132
|
-
* Condition for partial indexes.
|
|
125
|
+
* Condition for partial indexes, allowing conditional indexing based on field values.
|
|
133
126
|
*/
|
|
134
127
|
interface PartialIndexCondition {
|
|
135
|
-
/** The logical operator for the condition. */
|
|
136
128
|
operator: LogicalOperator;
|
|
137
|
-
/** The field to which condition applies. */
|
|
138
129
|
field: string;
|
|
139
|
-
/** The value to compare against (optional). */
|
|
140
130
|
value?: any;
|
|
141
|
-
/** Nested conditions (optional). */
|
|
142
131
|
conditions?: PartialIndexCondition[];
|
|
143
132
|
}
|
|
144
133
|
/**
|
|
145
|
-
*
|
|
134
|
+
* Defines an index for optimizing queries or enforcing uniqueness.
|
|
146
135
|
*/
|
|
147
136
|
interface IndexDefinition {
|
|
148
|
-
/** The fields included in the index. */
|
|
149
137
|
fields: string[];
|
|
150
|
-
/** The type of the index. */
|
|
151
138
|
type: IndexType;
|
|
152
|
-
/** Whether the index is unique. */
|
|
153
139
|
unique?: boolean;
|
|
154
|
-
/** A partial index condition. */
|
|
155
140
|
partial?: PartialIndexCondition;
|
|
156
|
-
/** A description of the index. */
|
|
157
141
|
description?: string;
|
|
158
|
-
/** Sorting order for the index */
|
|
159
142
|
order?: "asc" | "desc";
|
|
160
|
-
/** A name for the index. */
|
|
161
143
|
name: string;
|
|
162
144
|
}
|
|
163
145
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
146
|
+
* A mini-schema definition for reusable nested structures within a larger schema.
|
|
147
|
+
* Mirrors SchemaDefinition but omits top-level-only properties like version and migrations.
|
|
166
148
|
*/
|
|
167
|
-
|
|
149
|
+
interface NestedSchemaDefinition {
|
|
150
|
+
name: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
fields: Record<string, FieldDefinition<any>>;
|
|
153
|
+
indexes?: IndexDefinition[];
|
|
154
|
+
constraints?: SchemaConstraint<any>;
|
|
155
|
+
metadata?: Record<string, any>;
|
|
156
|
+
}
|
|
168
157
|
/**
|
|
169
|
-
*
|
|
158
|
+
* Defines a complete schema, intended as an atomic unit within a larger domain model.
|
|
170
159
|
*/
|
|
171
160
|
interface SchemaDefinition {
|
|
172
|
-
/** The name of the schema. */
|
|
173
161
|
name: string;
|
|
174
|
-
/** The version of the schema. */
|
|
175
162
|
version: string;
|
|
176
|
-
/** A description of the schema. */
|
|
177
163
|
description?: string;
|
|
178
|
-
/** The field definitions in the schema. */
|
|
179
164
|
fields: Record<string, FieldDefinition<any>>;
|
|
180
|
-
/**
|
|
165
|
+
/** Reusable nested schema definitions, now as mini-SchemaDefinitions. */
|
|
166
|
+
nestedSchemas: Record<string, NestedSchemaDefinition>;
|
|
181
167
|
indexes?: IndexDefinition[];
|
|
182
|
-
/** The constraints defined for the schema. */
|
|
183
168
|
constraints?: SchemaConstraint<any>;
|
|
184
|
-
/** Metadata associated with the schema. */
|
|
185
169
|
metadata?: Record<string, any>;
|
|
186
|
-
/**
|
|
170
|
+
/** @deprecated Use dependencies in DomainModel instead. */
|
|
187
171
|
dependencies?: string[];
|
|
188
|
-
/** Migrations associated with the schema. */
|
|
189
172
|
migrations?: Array<Migration<any>>;
|
|
190
|
-
|
|
191
|
-
mock?: <T>(faker: Faker) => Generator<T, void, unknown>;
|
|
173
|
+
mock?: <T>(faker: typeof _faker_js_faker) => Generator<T, void, unknown>;
|
|
192
174
|
}
|
|
193
175
|
/**
|
|
194
|
-
* Defines a change that can be made to a schema.
|
|
195
|
-
*
|
|
176
|
+
* Defines a change that can be made to a schema during migration.
|
|
177
|
+
* Updated to support the new NestedSchemaDefinition structure.
|
|
196
178
|
*/
|
|
197
179
|
type SchemaChange<T> = {
|
|
198
180
|
type: "modifyProperty";
|
|
199
|
-
id: keyof Omit<SchemaDefinition, "fields" | "indexes" | "constraints">;
|
|
200
|
-
changes: Partial<Omit<SchemaDefinition, "fields" | "indexes" | "constraints">>;
|
|
181
|
+
id: keyof Omit<SchemaDefinition, "fields" | "indexes" | "constraints" | "nestedSchemas">;
|
|
182
|
+
changes: Partial<Omit<SchemaDefinition, "fields" | "indexes" | "constraints" | "nestedSchemas">>;
|
|
201
183
|
} | {
|
|
202
184
|
type: "addField";
|
|
203
185
|
id: string;
|
|
@@ -209,6 +191,11 @@ type SchemaChange<T> = {
|
|
|
209
191
|
type: "modifyField";
|
|
210
192
|
id: string;
|
|
211
193
|
changes: Partial<FieldDefinition<T>>;
|
|
194
|
+
nestedSchemaChanges?: {
|
|
195
|
+
id?: string;
|
|
196
|
+
constraints?: SchemaConstraint<any>;
|
|
197
|
+
indexes?: IndexDefinition[];
|
|
198
|
+
};
|
|
212
199
|
} | {
|
|
213
200
|
type: "addIndex";
|
|
214
201
|
definition: IndexDefinition;
|
|
@@ -232,61 +219,49 @@ type SchemaChange<T> = {
|
|
|
232
219
|
} | {
|
|
233
220
|
type: "deprecateField";
|
|
234
221
|
id: string;
|
|
222
|
+
} | {
|
|
223
|
+
type: "addNestedSchema";
|
|
224
|
+
id: string;
|
|
225
|
+
definition: NestedSchemaDefinition;
|
|
226
|
+
} | {
|
|
227
|
+
type: "removeNestedSchema";
|
|
228
|
+
id: string;
|
|
229
|
+
} | {
|
|
230
|
+
type: "modifyNestedSchema";
|
|
231
|
+
id: string;
|
|
232
|
+
changes: Partial<NestedSchemaDefinition>;
|
|
235
233
|
};
|
|
236
234
|
/**
|
|
237
|
-
* Defines a transform function for data migration.
|
|
238
|
-
* @template Initial The initial data type.
|
|
239
|
-
* @template Next The transformed data type.
|
|
240
|
-
* @param {Initial} data - The initial data.
|
|
241
|
-
* @returns {Next | Promise<Next>} The transformed data or a promise that resolves to the transformed data.
|
|
235
|
+
* Defines a transform function for data migration between schema versions.
|
|
242
236
|
*/
|
|
243
237
|
type TransformFunction<Initial, Next> = (data: Initial) => Next | Promise<Next>;
|
|
244
238
|
/**
|
|
245
|
-
* Represents a pair of transformations for data migration
|
|
246
|
-
* @template Initial The initial data type.
|
|
247
|
-
* @template Next The transformed data type.
|
|
239
|
+
* Represents a pair of transformations for bidirectional data migration.
|
|
248
240
|
*/
|
|
249
241
|
interface DataTransform<Initial, Next> {
|
|
250
|
-
/** The forward transformation function. */
|
|
251
242
|
forward: TransformFunction<Initial, Next>;
|
|
252
|
-
/** The backward transformation function. */
|
|
253
243
|
backward: TransformFunction<Next, Initial>;
|
|
254
244
|
}
|
|
255
245
|
/**
|
|
256
|
-
* Defines a migration,
|
|
257
|
-
* Each migration is a set of atomic changes that can be applied in a single operation.
|
|
258
|
-
* @template T The type of the data being migrated.
|
|
246
|
+
* Defines a migration, consisting of schema changes and data transforms.
|
|
259
247
|
*/
|
|
260
248
|
interface Migration<T> {
|
|
261
|
-
/** A unique identifier for the migration. */
|
|
262
249
|
id: string;
|
|
263
|
-
/** the schema version for which this migration is applicable */
|
|
264
250
|
schemaVersion: string;
|
|
265
|
-
/** A list of schema changes to be applied in the migration. */
|
|
266
251
|
changes: SchemaChange<T>[];
|
|
267
|
-
/** A description of what the migration does. */
|
|
268
252
|
description: string;
|
|
269
|
-
/** The current status of the migration. */
|
|
270
253
|
status: "pending" | "applied" | "failed";
|
|
271
|
-
/** An optional list of schema changes to revert the migration. */
|
|
272
254
|
rollback?: SchemaChange<T>[];
|
|
273
|
-
/**
|
|
274
|
-
* A checksum/string/url representing the js file exporting
|
|
275
|
-
* the data transforms for this migration.
|
|
276
|
-
* Each transform file exports a `DataTransform` object.
|
|
277
|
-
*/
|
|
278
255
|
transform: string | DataTransform<any, any>;
|
|
279
|
-
/** A timestamp for when the migration was created (in ISO 8601 format). */
|
|
280
256
|
createdAt: string;
|
|
281
|
-
/** @deprecated
|
|
257
|
+
/** @deprecated Use dependencies in DomainModel instead. */
|
|
282
258
|
dependencies?: string[];
|
|
283
|
-
/**
|
|
284
|
-
* A checksum to ensure the integrity of the migration.
|
|
285
|
-
* This is the hash of the stringified/minified version of this object,
|
|
286
|
-
* excluding the `checksum` field itself (to avoid circular dependencies).
|
|
287
|
-
*/
|
|
288
259
|
checksum: string;
|
|
289
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Generator type for mock data functions (used with Faker).
|
|
263
|
+
*/
|
|
264
|
+
type Generator<T, TReturn, TNext> = Iterator<T, TReturn, TNext>;
|
|
290
265
|
|
|
291
266
|
/**
|
|
292
267
|
* Defines the interface for a migration engine.
|
|
@@ -570,6 +545,23 @@ interface SchemaMigrationHelper {
|
|
|
570
545
|
* @param changes The changes to apply to the constraint.
|
|
571
546
|
*/
|
|
572
547
|
modifyConstraint(constraintName: string, changes: Partial<Constraint<any>>): void;
|
|
548
|
+
/**
|
|
549
|
+
* Adds a new nested schema to the schema.
|
|
550
|
+
* @param {string} schemaId - The ID of the nested schema to add.
|
|
551
|
+
* @param {NestedSchemaDefinition} nestedDefinition - The definition of the nested schema to add.
|
|
552
|
+
*/
|
|
553
|
+
addNestedSchema(schemaId: string, nestedDefinition: NestedSchemaDefinition): void;
|
|
554
|
+
/**
|
|
555
|
+
* Removes a nested schema from the schema.
|
|
556
|
+
* @param {string} schemaId - The ID of the nested schema to remove.
|
|
557
|
+
*/
|
|
558
|
+
removeNestedSchema(schemaId: string): void;
|
|
559
|
+
/**
|
|
560
|
+
* Modifies an existing nested schema in the schema.
|
|
561
|
+
* @param {string} schemaId - The ID of the nested schema to modify.
|
|
562
|
+
* @param {Partial<NestedSchemaDefinition>} changes - The changes to apply to the nested schema.
|
|
563
|
+
*/
|
|
564
|
+
modifyNestedSchema(schemaId: string, changes: Partial<NestedSchemaDefinition>): void;
|
|
573
565
|
/**
|
|
574
566
|
* Returns the list of changes made through this helper.
|
|
575
567
|
* @returns An array of schema changes.
|
|
@@ -795,45 +787,307 @@ type RegistryLock = {
|
|
|
795
787
|
updated: string;
|
|
796
788
|
hashes: [filepath: string, filehash: string][];
|
|
797
789
|
};
|
|
798
|
-
interface
|
|
799
|
-
/**
|
|
790
|
+
interface SchemaRegistryInterface {
|
|
791
|
+
/** Initializes the repository **/
|
|
800
792
|
init(): Promise<void>;
|
|
801
|
-
/** Clone an existing registry from a remote source */
|
|
802
|
-
clone(): Promise<void>;
|
|
803
793
|
/** Create a new schema version */
|
|
804
|
-
create(
|
|
794
|
+
create(_: {
|
|
795
|
+
schema: SchemaDefinition;
|
|
796
|
+
}): Promise<void>;
|
|
805
797
|
/** Update an existing schema version */
|
|
806
|
-
update(
|
|
798
|
+
update(_: {
|
|
799
|
+
schema: SchemaDefinition;
|
|
800
|
+
}): Promise<void>;
|
|
807
801
|
/** Delete a schema and its associated branch */
|
|
808
|
-
delete(
|
|
802
|
+
delete(_: {
|
|
803
|
+
name: string;
|
|
804
|
+
}): Promise<void>;
|
|
809
805
|
/** List all schemas with their latest version */
|
|
810
806
|
list(): Promise<{
|
|
811
807
|
name: string;
|
|
812
808
|
version: string;
|
|
813
809
|
}[]>;
|
|
814
810
|
/** Retrieve schema definition for a specific version (or latest if no version is provided) */
|
|
815
|
-
schema(
|
|
811
|
+
schema(_: {
|
|
812
|
+
name: string;
|
|
813
|
+
version?: string;
|
|
814
|
+
migrations?: boolean;
|
|
815
|
+
}): Promise<SchemaDefinition | null>;
|
|
816
816
|
/** Get schema statistics (returns the full SchemaIndex) */
|
|
817
|
-
stats(
|
|
817
|
+
stats(_: {
|
|
818
|
+
schema?: string;
|
|
819
|
+
}): Promise<SchemaIndex | RegistryMetadata>;
|
|
818
820
|
/** Regenerate index & lockfile, then push changes */
|
|
819
821
|
sync(): Promise<void>;
|
|
820
|
-
/** Retrieve all predicate names required by a specific schema version (or latest if no version is provided) */
|
|
821
|
-
predicates(name: string, version?: string): Promise<string[]>;
|
|
822
822
|
/** Retrieve all migrations for a specific schema version (or latest if no version is provided) */
|
|
823
|
-
migrations(
|
|
823
|
+
migrations(_: {
|
|
824
|
+
name: string;
|
|
825
|
+
version?: string;
|
|
826
|
+
}): Promise<Array<Migration<any>>>;
|
|
824
827
|
/** Retrieve the full history of a schema */
|
|
825
|
-
history(
|
|
828
|
+
history(_: {
|
|
829
|
+
name: string;
|
|
830
|
+
}): Promise<SchemaDefinition[]>;
|
|
826
831
|
}
|
|
827
832
|
|
|
828
833
|
/**
|
|
829
|
-
*
|
|
830
|
-
* @returns {Promise<SchemaRegistry>} A promise that resolves to the SchemaRegistry instance.
|
|
834
|
+
* Interface for interacting with a remotely hosted repository (e.g., GitHub, GitLab).
|
|
831
835
|
*/
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
836
|
+
interface RemoteRepository {
|
|
837
|
+
/**
|
|
838
|
+
* Creates a new repository on the remote service.
|
|
839
|
+
* @param options.name - The name of the repository.
|
|
840
|
+
* @param options.private - Whether the repository should be private (default: false).
|
|
841
|
+
* @returns A promise resolving to the repository's authenticated URL (e.g., "https://username:token@github.com/username/repo.git").
|
|
842
|
+
* @param options
|
|
843
|
+
*/
|
|
844
|
+
create(options: {
|
|
845
|
+
name: string;
|
|
846
|
+
private?: boolean;
|
|
847
|
+
}): Promise<RemoteRepository>;
|
|
848
|
+
/**
|
|
849
|
+
* Checks if a repository exists on the remote service.
|
|
850
|
+
* @param options - Repository lookup details.
|
|
851
|
+
* @param options.name - The name of the repository.
|
|
852
|
+
* @returns A promise resolving to true if the repository exists, false otherwise.
|
|
853
|
+
*/
|
|
854
|
+
exists({ name }: {
|
|
855
|
+
name: string;
|
|
856
|
+
}): Promise<boolean>;
|
|
857
|
+
/**
|
|
858
|
+
* Deletes a repository on the remote service.
|
|
859
|
+
*/
|
|
860
|
+
remove(): Promise<void>;
|
|
861
|
+
/**
|
|
862
|
+
* Returns a properly formatted authenticated URL for a specific repository.
|
|
863
|
+
* @returns A string representing the auth-enabled URL (e.g., "https://username:token@github.com/username/repo.git").
|
|
864
|
+
*/
|
|
865
|
+
authURL(): string;
|
|
866
|
+
/**
|
|
867
|
+
* Returns the plain URL to this repository.
|
|
868
|
+
* @returns A string representing the repository URL (e.g., "https://github.com/username/repo.git").
|
|
869
|
+
* @throws RemoteRepositoryError if no repository is set.
|
|
870
|
+
*/
|
|
871
|
+
url(): string;
|
|
872
|
+
credentials(): {
|
|
873
|
+
username: string;
|
|
874
|
+
password: string;
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
declare function createGitSchemaRegistry(rootDir?: string, options?: {
|
|
879
|
+
remote?: RemoteRepository;
|
|
880
|
+
mainBranch?: string;
|
|
881
|
+
createRemote?: boolean;
|
|
882
|
+
author?: {
|
|
883
|
+
name: string;
|
|
884
|
+
email: string;
|
|
885
|
+
};
|
|
886
|
+
proxy?: string;
|
|
887
|
+
cacheTtl?: number;
|
|
888
|
+
}): Promise<SchemaRegistryInterface>;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Implementation of a schema registry using an in-memory LightningFS.
|
|
892
|
+
* Combines refined filesystem management with original serialization for functions and mocks.
|
|
893
|
+
*/
|
|
894
|
+
declare class SchemaRegistry implements SchemaRegistryInterface {
|
|
895
|
+
/** In-memory filesystem instance for storing registry data. */
|
|
896
|
+
fs: LightningFS;
|
|
897
|
+
/** Promise-based API for asynchronous filesystem operations. */
|
|
898
|
+
fsp: LightningFS.PromisifiedFS;
|
|
899
|
+
/** Root directory path in the filesystem (e.g., '/registry'). */
|
|
900
|
+
rootDir: string;
|
|
901
|
+
/**
|
|
902
|
+
* Constructs a new SchemaRegistryImpl instance.
|
|
903
|
+
* @param rootDir - The root directory for the registry (defaults to '/registry').
|
|
904
|
+
*/
|
|
905
|
+
constructor(rootDir?: string);
|
|
906
|
+
/**
|
|
907
|
+
* Ensures the registry is initialized with base files if they don't exist.
|
|
908
|
+
* Implements refined conditional initialization for idempotency.
|
|
909
|
+
*/
|
|
910
|
+
init(): Promise<void>;
|
|
911
|
+
/**
|
|
912
|
+
* Creates a new schema in the registry.
|
|
913
|
+
* @param params - Object containing the schema definition.
|
|
914
|
+
* @throws Error if schema name or version is missing, or if schema already exists.
|
|
915
|
+
*/
|
|
916
|
+
create({ schema }: {
|
|
917
|
+
schema: SchemaDefinition;
|
|
918
|
+
}): Promise<void>;
|
|
919
|
+
/**
|
|
920
|
+
* Updates an existing schema in the registry.
|
|
921
|
+
* @param params - Object containing the updated schema definition.
|
|
922
|
+
* @throws Error if schema name or version is missing, or if schema doesn't exist.
|
|
923
|
+
*/
|
|
924
|
+
update({ schema }: {
|
|
925
|
+
schema: SchemaDefinition;
|
|
926
|
+
}): Promise<void>;
|
|
927
|
+
/**
|
|
928
|
+
* Saves a schema (create or update) with serialization and metadata updates.
|
|
929
|
+
* @param schema - The schema definition to save.
|
|
930
|
+
* @param action - Whether this is a create or update operation.
|
|
931
|
+
* @private - Internal method to reduce duplication in create/update.
|
|
932
|
+
*/
|
|
933
|
+
private saveSchema;
|
|
934
|
+
/**
|
|
935
|
+
* Deletes a schema and all its associated data from the registry.
|
|
936
|
+
* Implements refined full filesystem cleanup.
|
|
937
|
+
* @param params - Object containing the schema name to delete.
|
|
938
|
+
* @throws Error if schema doesn't exist.
|
|
939
|
+
*/
|
|
940
|
+
delete({ name }: {
|
|
941
|
+
name: string;
|
|
942
|
+
}): Promise<void>;
|
|
943
|
+
/**
|
|
944
|
+
* Lists all schemas in the registry with their latest versions.
|
|
945
|
+
* @returns Array of schema names and versions.
|
|
946
|
+
*/
|
|
947
|
+
list(): Promise<{
|
|
948
|
+
name: string;
|
|
949
|
+
version: string;
|
|
950
|
+
}[]>;
|
|
951
|
+
/**
|
|
952
|
+
* Retrieves a schema definition, optionally with a specific version and migrations.
|
|
953
|
+
* Incorporates original serialization for mocks.
|
|
954
|
+
* @param params - Object with schema name, optional version, and migrations flag.
|
|
955
|
+
* @returns Schema definition or null if not found.
|
|
956
|
+
*/
|
|
957
|
+
schema({ name, version, migrations, }: {
|
|
958
|
+
name: string;
|
|
959
|
+
version?: string;
|
|
960
|
+
migrations?: boolean;
|
|
961
|
+
}): Promise<SchemaDefinition | null>;
|
|
962
|
+
/**
|
|
963
|
+
* Retrieves statistics for a specific schema or the entire registry.
|
|
964
|
+
* @param params - Optional schema name to get SchemaIndex instead of RegistryMetadata.
|
|
965
|
+
* @returns SchemaIndex or RegistryMetadata.
|
|
966
|
+
* @throws Error if specific schema stats requested but schema not found.
|
|
967
|
+
*/
|
|
968
|
+
stats({ schema, }: {
|
|
969
|
+
schema?: string;
|
|
970
|
+
}): Promise<SchemaIndex | RegistryMetadata>;
|
|
971
|
+
/**
|
|
972
|
+
* Synchronizes the registry by updating the lockfile with current file hashes.
|
|
973
|
+
* Implements refined sync behavior.
|
|
974
|
+
*/
|
|
975
|
+
sync(): Promise<void>;
|
|
976
|
+
/**
|
|
977
|
+
* Retrieves migrations for a schema up to a specified version.
|
|
978
|
+
* Incorporates original serialization for migration transforms.
|
|
979
|
+
* @param params - Object with schema name and optional version.
|
|
980
|
+
* @returns Array of migrations, sorted by version.
|
|
981
|
+
*/
|
|
982
|
+
migrations({ name, version, }: {
|
|
983
|
+
name: string;
|
|
984
|
+
version?: string;
|
|
985
|
+
}): Promise<Array<Migration<any>>>;
|
|
986
|
+
/**
|
|
987
|
+
* Retrieves the version history of a schema.
|
|
988
|
+
* Incorporates original serialization for mocks and migrations.
|
|
989
|
+
* @param params - Object with schema name.
|
|
990
|
+
* @returns Array of schema definitions for each version.
|
|
991
|
+
*/
|
|
992
|
+
history({ name }: {
|
|
993
|
+
name: string;
|
|
994
|
+
}): Promise<SchemaDefinition[]>;
|
|
995
|
+
/**
|
|
996
|
+
* Processes and stores migrations with serialization of transforms.
|
|
997
|
+
* Adopts original's approach to handling executable transforms.
|
|
998
|
+
* @param schemaDir - Directory path for the schema.
|
|
999
|
+
* @param schema - Schema definition containing migrations.
|
|
1000
|
+
* @returns Array of migration metadata.
|
|
1001
|
+
* @private
|
|
1002
|
+
*/
|
|
1003
|
+
private processAndStoreMigrations;
|
|
1004
|
+
/**
|
|
1005
|
+
* Serializes a schema definition, handling mocks as per original.
|
|
1006
|
+
* @param schema - Schema definition to serialize.
|
|
1007
|
+
* @returns JSON string of serialized schema.
|
|
1008
|
+
* @private
|
|
1009
|
+
*/
|
|
1010
|
+
private serializeSchema;
|
|
1011
|
+
/**
|
|
1012
|
+
* Deserializes a schema content object, restoring mocks as per original.
|
|
1013
|
+
* @param schemaContent - Raw schema content from JSON.
|
|
1014
|
+
* @returns Deserialized schema definition.
|
|
1015
|
+
* @private
|
|
1016
|
+
*/
|
|
1017
|
+
private deserializeSchema;
|
|
1018
|
+
/**
|
|
1019
|
+
* Deserializes a migration content object, restoring transforms as per original.
|
|
1020
|
+
* @param content - Raw migration content from JSON.
|
|
1021
|
+
* @returns Deserialized migration object.
|
|
1022
|
+
* @private
|
|
1023
|
+
*/
|
|
1024
|
+
private deserializeMigration;
|
|
1025
|
+
/**
|
|
1026
|
+
* Writes the schema file to the filesystem.
|
|
1027
|
+
* @param schemaDir - Directory path for the schema.
|
|
1028
|
+
* @param content - Serialized schema content.
|
|
1029
|
+
* @returns Path to the written schema file.
|
|
1030
|
+
* @private
|
|
1031
|
+
*/
|
|
1032
|
+
private writeSchemaFile;
|
|
1033
|
+
/**
|
|
1034
|
+
* Updates the schema index with new version history and migrations.
|
|
1035
|
+
* @param schemaDir - Directory path for the schema.
|
|
1036
|
+
* @param schema - Schema definition being saved.
|
|
1037
|
+
* @param schemaHash - Hash of the schema content.
|
|
1038
|
+
* @param migrations - Processed migration metadata.
|
|
1039
|
+
* @param action - Whether this is a create or update operation.
|
|
1040
|
+
* @private
|
|
1041
|
+
*/
|
|
1042
|
+
private updateIndex;
|
|
1043
|
+
/**
|
|
1044
|
+
* Updates the registry metadata with schema information.
|
|
1045
|
+
* @param schema - Schema definition being saved.
|
|
1046
|
+
* @param action - Whether this is a create or update operation.
|
|
1047
|
+
* @private
|
|
1048
|
+
*/
|
|
1049
|
+
private updateRegistryMetadata;
|
|
1050
|
+
/**
|
|
1051
|
+
* Reads the registry metadata from the filesystem.
|
|
1052
|
+
* @returns Parsed RegistryMetadata object.
|
|
1053
|
+
* @private
|
|
1054
|
+
*/
|
|
1055
|
+
private readRegistryMetadata;
|
|
1056
|
+
/**
|
|
1057
|
+
* Writes the registry metadata to the filesystem.
|
|
1058
|
+
* @param metadata - RegistryMetadata object to write.
|
|
1059
|
+
* @private
|
|
1060
|
+
*/
|
|
1061
|
+
private writeRegistryMetadata;
|
|
1062
|
+
/**
|
|
1063
|
+
* Reads the schema index from the filesystem.
|
|
1064
|
+
* @param name - Name of the schema.
|
|
1065
|
+
* @returns Parsed SchemaIndex object.
|
|
1066
|
+
* @throws Error if schema index not found.
|
|
1067
|
+
* @private
|
|
1068
|
+
*/
|
|
1069
|
+
private readSchemaIndex;
|
|
1070
|
+
/**
|
|
1071
|
+
* Checks if a file exists in the filesystem.
|
|
1072
|
+
* @param path - Path to check.
|
|
1073
|
+
* @returns True if file exists, false otherwise.
|
|
1074
|
+
* @private
|
|
1075
|
+
*/
|
|
1076
|
+
fileExists(path: string): Promise<boolean>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Recursively removes a directory and its contents.
|
|
1079
|
+
* @param path - Directory path to remove.
|
|
1080
|
+
* @private
|
|
1081
|
+
*/
|
|
1082
|
+
private rmdirRecursive;
|
|
1083
|
+
/**
|
|
1084
|
+
* Lists all files recursively in a directory.
|
|
1085
|
+
* @param path - Directory path to scan.
|
|
1086
|
+
* @returns Array of file paths.
|
|
1087
|
+
* @private
|
|
1088
|
+
*/
|
|
1089
|
+
private listFilesRecursive;
|
|
1090
|
+
}
|
|
837
1091
|
|
|
838
1092
|
/**
|
|
839
1093
|
* @fileoverview Provides a MigrationEngine class that handles schema migrations,
|
|
@@ -1062,765 +1316,10 @@ declare class MigrationEngine {
|
|
|
1062
1316
|
* Helper for building schema migrations with forward and rollback changes.
|
|
1063
1317
|
* @template T The type of data associated with the schema.
|
|
1064
1318
|
* @param {Readonly<SchemaDefinition>} schema - The original schema to base the migration on.
|
|
1065
|
-
* @returns {
|
|
1319
|
+
* @returns {SchemaMigrationHelper} An object with methods to build migration changes and retrieve the changes.
|
|
1066
1320
|
*/
|
|
1067
1321
|
declare const createSchemaMigrationHelper: <T>(schema: Readonly<SchemaDefinition>) => SchemaMigrationHelper;
|
|
1068
1322
|
|
|
1069
|
-
declare const MigrationSchema: z.ZodObject<{
|
|
1070
|
-
id: z.ZodString;
|
|
1071
|
-
schemaVersion: z.ZodString;
|
|
1072
|
-
changes: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
1073
|
-
type: z.ZodLiteral<"addField">;
|
|
1074
|
-
id: z.ZodString;
|
|
1075
|
-
definition: any;
|
|
1076
|
-
}, "strip", z.ZodTypeAny, {
|
|
1077
|
-
type: "addField";
|
|
1078
|
-
id: string;
|
|
1079
|
-
definition?: any;
|
|
1080
|
-
}, {
|
|
1081
|
-
type: "addField";
|
|
1082
|
-
id: string;
|
|
1083
|
-
definition?: any;
|
|
1084
|
-
}>, z.ZodObject<{
|
|
1085
|
-
type: z.ZodLiteral<"removeField">;
|
|
1086
|
-
id: z.ZodString;
|
|
1087
|
-
}, "strip", z.ZodTypeAny, {
|
|
1088
|
-
type: "removeField";
|
|
1089
|
-
id: string;
|
|
1090
|
-
}, {
|
|
1091
|
-
type: "removeField";
|
|
1092
|
-
id: string;
|
|
1093
|
-
}>, z.ZodObject<{
|
|
1094
|
-
type: z.ZodLiteral<"modifyField">;
|
|
1095
|
-
id: z.ZodString;
|
|
1096
|
-
changes: any;
|
|
1097
|
-
}, "strip", z.ZodTypeAny, {
|
|
1098
|
-
type: "modifyField";
|
|
1099
|
-
id: string;
|
|
1100
|
-
changes?: any;
|
|
1101
|
-
}, {
|
|
1102
|
-
type: "modifyField";
|
|
1103
|
-
id: string;
|
|
1104
|
-
changes?: any;
|
|
1105
|
-
}>, z.ZodObject<{
|
|
1106
|
-
type: z.ZodLiteral<"addIndex">;
|
|
1107
|
-
definition: z.ZodObject<{
|
|
1108
|
-
fields: z.ZodArray<z.ZodString, "many">;
|
|
1109
|
-
type: z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>;
|
|
1110
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
1111
|
-
partial: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
|
|
1112
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1113
|
-
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
1114
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1115
|
-
}, "strip", z.ZodTypeAny, {
|
|
1116
|
-
fields: string[];
|
|
1117
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1118
|
-
unique?: boolean | undefined;
|
|
1119
|
-
name?: string | undefined;
|
|
1120
|
-
description?: string | undefined;
|
|
1121
|
-
partial?: any;
|
|
1122
|
-
order?: "asc" | "desc" | undefined;
|
|
1123
|
-
}, {
|
|
1124
|
-
fields: string[];
|
|
1125
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1126
|
-
unique?: boolean | undefined;
|
|
1127
|
-
name?: string | undefined;
|
|
1128
|
-
description?: string | undefined;
|
|
1129
|
-
partial?: any;
|
|
1130
|
-
order?: "asc" | "desc" | undefined;
|
|
1131
|
-
}>;
|
|
1132
|
-
}, "strip", z.ZodTypeAny, {
|
|
1133
|
-
type: "addIndex";
|
|
1134
|
-
definition: {
|
|
1135
|
-
fields: string[];
|
|
1136
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1137
|
-
unique?: boolean | undefined;
|
|
1138
|
-
name?: string | undefined;
|
|
1139
|
-
description?: string | undefined;
|
|
1140
|
-
partial?: any;
|
|
1141
|
-
order?: "asc" | "desc" | undefined;
|
|
1142
|
-
};
|
|
1143
|
-
}, {
|
|
1144
|
-
type: "addIndex";
|
|
1145
|
-
definition: {
|
|
1146
|
-
fields: string[];
|
|
1147
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1148
|
-
unique?: boolean | undefined;
|
|
1149
|
-
name?: string | undefined;
|
|
1150
|
-
description?: string | undefined;
|
|
1151
|
-
partial?: any;
|
|
1152
|
-
order?: "asc" | "desc" | undefined;
|
|
1153
|
-
};
|
|
1154
|
-
}>, z.ZodObject<{
|
|
1155
|
-
type: z.ZodLiteral<"removeIndex">;
|
|
1156
|
-
name: z.ZodString;
|
|
1157
|
-
}, "strip", z.ZodTypeAny, {
|
|
1158
|
-
name: string;
|
|
1159
|
-
type: "removeIndex";
|
|
1160
|
-
}, {
|
|
1161
|
-
name: string;
|
|
1162
|
-
type: "removeIndex";
|
|
1163
|
-
}>, z.ZodObject<{
|
|
1164
|
-
type: z.ZodLiteral<"modifyIndex">;
|
|
1165
|
-
name: z.ZodString;
|
|
1166
|
-
changes: z.ZodObject<{
|
|
1167
|
-
fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1168
|
-
type: z.ZodOptional<z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>>;
|
|
1169
|
-
unique: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
1170
|
-
partial: z.ZodOptional<z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>>;
|
|
1171
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1172
|
-
order: z.ZodOptional<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
|
|
1173
|
-
name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1174
|
-
}, "strip", z.ZodTypeAny, {
|
|
1175
|
-
unique?: boolean | undefined;
|
|
1176
|
-
fields?: string[] | undefined;
|
|
1177
|
-
name?: string | undefined;
|
|
1178
|
-
description?: string | undefined;
|
|
1179
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1180
|
-
partial?: any;
|
|
1181
|
-
order?: "asc" | "desc" | undefined;
|
|
1182
|
-
}, {
|
|
1183
|
-
unique?: boolean | undefined;
|
|
1184
|
-
fields?: string[] | undefined;
|
|
1185
|
-
name?: string | undefined;
|
|
1186
|
-
description?: string | undefined;
|
|
1187
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1188
|
-
partial?: any;
|
|
1189
|
-
order?: "asc" | "desc" | undefined;
|
|
1190
|
-
}>;
|
|
1191
|
-
}, "strip", z.ZodTypeAny, {
|
|
1192
|
-
name: string;
|
|
1193
|
-
type: "modifyIndex";
|
|
1194
|
-
changes: {
|
|
1195
|
-
unique?: boolean | undefined;
|
|
1196
|
-
fields?: string[] | undefined;
|
|
1197
|
-
name?: string | undefined;
|
|
1198
|
-
description?: string | undefined;
|
|
1199
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1200
|
-
partial?: any;
|
|
1201
|
-
order?: "asc" | "desc" | undefined;
|
|
1202
|
-
};
|
|
1203
|
-
}, {
|
|
1204
|
-
name: string;
|
|
1205
|
-
type: "modifyIndex";
|
|
1206
|
-
changes: {
|
|
1207
|
-
unique?: boolean | undefined;
|
|
1208
|
-
fields?: string[] | undefined;
|
|
1209
|
-
name?: string | undefined;
|
|
1210
|
-
description?: string | undefined;
|
|
1211
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1212
|
-
partial?: any;
|
|
1213
|
-
order?: "asc" | "desc" | undefined;
|
|
1214
|
-
};
|
|
1215
|
-
}>, z.ZodObject<{
|
|
1216
|
-
type: z.ZodLiteral<"addConstraint">;
|
|
1217
|
-
constraint: z.ZodUnion<[z.ZodObject<{
|
|
1218
|
-
type: z.ZodOptional<z.ZodString>;
|
|
1219
|
-
name: z.ZodString;
|
|
1220
|
-
predicate: z.ZodOptional<z.ZodString>;
|
|
1221
|
-
parameters: z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>;
|
|
1222
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1223
|
-
field: z.ZodOptional<z.ZodString>;
|
|
1224
|
-
errorMessage: z.ZodOptional<z.ZodString>;
|
|
1225
|
-
}, "strip", z.ZodTypeAny, {
|
|
1226
|
-
name: string;
|
|
1227
|
-
description?: string | undefined;
|
|
1228
|
-
type?: string | undefined;
|
|
1229
|
-
predicate?: string | undefined;
|
|
1230
|
-
field?: string | undefined;
|
|
1231
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1232
|
-
errorMessage?: string | undefined;
|
|
1233
|
-
}, {
|
|
1234
|
-
name: string;
|
|
1235
|
-
description?: string | undefined;
|
|
1236
|
-
type?: string | undefined;
|
|
1237
|
-
predicate?: string | undefined;
|
|
1238
|
-
field?: string | undefined;
|
|
1239
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1240
|
-
errorMessage?: string | undefined;
|
|
1241
|
-
}>, any]>;
|
|
1242
|
-
}, "strip", z.ZodTypeAny, {
|
|
1243
|
-
type: "addConstraint";
|
|
1244
|
-
constraint?: any;
|
|
1245
|
-
}, {
|
|
1246
|
-
type: "addConstraint";
|
|
1247
|
-
constraint?: any;
|
|
1248
|
-
}>, z.ZodObject<{
|
|
1249
|
-
type: z.ZodLiteral<"removeConstraint">;
|
|
1250
|
-
name: z.ZodString;
|
|
1251
|
-
}, "strip", z.ZodTypeAny, {
|
|
1252
|
-
name: string;
|
|
1253
|
-
type: "removeConstraint";
|
|
1254
|
-
}, {
|
|
1255
|
-
name: string;
|
|
1256
|
-
type: "removeConstraint";
|
|
1257
|
-
}>, z.ZodObject<{
|
|
1258
|
-
type: z.ZodLiteral<"modifyConstraint">;
|
|
1259
|
-
name: z.ZodString;
|
|
1260
|
-
changes: z.ZodObject<{
|
|
1261
|
-
type: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1262
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1263
|
-
predicate: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1264
|
-
parameters: z.ZodOptional<z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>>;
|
|
1265
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1266
|
-
field: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1267
|
-
errorMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1268
|
-
}, "strip", z.ZodTypeAny, {
|
|
1269
|
-
name?: string | undefined;
|
|
1270
|
-
description?: string | undefined;
|
|
1271
|
-
type?: string | undefined;
|
|
1272
|
-
predicate?: string | undefined;
|
|
1273
|
-
field?: string | undefined;
|
|
1274
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1275
|
-
errorMessage?: string | undefined;
|
|
1276
|
-
}, {
|
|
1277
|
-
name?: string | undefined;
|
|
1278
|
-
description?: string | undefined;
|
|
1279
|
-
type?: string | undefined;
|
|
1280
|
-
predicate?: string | undefined;
|
|
1281
|
-
field?: string | undefined;
|
|
1282
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1283
|
-
errorMessage?: string | undefined;
|
|
1284
|
-
}>;
|
|
1285
|
-
}, "strip", z.ZodTypeAny, {
|
|
1286
|
-
name: string;
|
|
1287
|
-
type: "modifyConstraint";
|
|
1288
|
-
changes: {
|
|
1289
|
-
name?: string | undefined;
|
|
1290
|
-
description?: string | undefined;
|
|
1291
|
-
type?: string | undefined;
|
|
1292
|
-
predicate?: string | undefined;
|
|
1293
|
-
field?: string | undefined;
|
|
1294
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1295
|
-
errorMessage?: string | undefined;
|
|
1296
|
-
};
|
|
1297
|
-
}, {
|
|
1298
|
-
name: string;
|
|
1299
|
-
type: "modifyConstraint";
|
|
1300
|
-
changes: {
|
|
1301
|
-
name?: string | undefined;
|
|
1302
|
-
description?: string | undefined;
|
|
1303
|
-
type?: string | undefined;
|
|
1304
|
-
predicate?: string | undefined;
|
|
1305
|
-
field?: string | undefined;
|
|
1306
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1307
|
-
errorMessage?: string | undefined;
|
|
1308
|
-
};
|
|
1309
|
-
}>, z.ZodObject<{
|
|
1310
|
-
type: z.ZodLiteral<"deprecateField">;
|
|
1311
|
-
id: z.ZodString;
|
|
1312
|
-
}, "strip", z.ZodTypeAny, {
|
|
1313
|
-
type: "deprecateField";
|
|
1314
|
-
id: string;
|
|
1315
|
-
}, {
|
|
1316
|
-
type: "deprecateField";
|
|
1317
|
-
id: string;
|
|
1318
|
-
}>]>, "many">;
|
|
1319
|
-
description: z.ZodString;
|
|
1320
|
-
status: z.ZodEnum<["pending", "applied", "failed"]>;
|
|
1321
|
-
rollback: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
1322
|
-
type: z.ZodLiteral<"addField">;
|
|
1323
|
-
id: z.ZodString;
|
|
1324
|
-
definition: any;
|
|
1325
|
-
}, "strip", z.ZodTypeAny, {
|
|
1326
|
-
type: "addField";
|
|
1327
|
-
id: string;
|
|
1328
|
-
definition?: any;
|
|
1329
|
-
}, {
|
|
1330
|
-
type: "addField";
|
|
1331
|
-
id: string;
|
|
1332
|
-
definition?: any;
|
|
1333
|
-
}>, z.ZodObject<{
|
|
1334
|
-
type: z.ZodLiteral<"removeField">;
|
|
1335
|
-
id: z.ZodString;
|
|
1336
|
-
}, "strip", z.ZodTypeAny, {
|
|
1337
|
-
type: "removeField";
|
|
1338
|
-
id: string;
|
|
1339
|
-
}, {
|
|
1340
|
-
type: "removeField";
|
|
1341
|
-
id: string;
|
|
1342
|
-
}>, z.ZodObject<{
|
|
1343
|
-
type: z.ZodLiteral<"modifyField">;
|
|
1344
|
-
id: z.ZodString;
|
|
1345
|
-
changes: any;
|
|
1346
|
-
}, "strip", z.ZodTypeAny, {
|
|
1347
|
-
type: "modifyField";
|
|
1348
|
-
id: string;
|
|
1349
|
-
changes?: any;
|
|
1350
|
-
}, {
|
|
1351
|
-
type: "modifyField";
|
|
1352
|
-
id: string;
|
|
1353
|
-
changes?: any;
|
|
1354
|
-
}>, z.ZodObject<{
|
|
1355
|
-
type: z.ZodLiteral<"addIndex">;
|
|
1356
|
-
definition: z.ZodObject<{
|
|
1357
|
-
fields: z.ZodArray<z.ZodString, "many">;
|
|
1358
|
-
type: z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>;
|
|
1359
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
1360
|
-
partial: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
|
|
1361
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1362
|
-
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
1363
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1364
|
-
}, "strip", z.ZodTypeAny, {
|
|
1365
|
-
fields: string[];
|
|
1366
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1367
|
-
unique?: boolean | undefined;
|
|
1368
|
-
name?: string | undefined;
|
|
1369
|
-
description?: string | undefined;
|
|
1370
|
-
partial?: any;
|
|
1371
|
-
order?: "asc" | "desc" | undefined;
|
|
1372
|
-
}, {
|
|
1373
|
-
fields: string[];
|
|
1374
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1375
|
-
unique?: boolean | undefined;
|
|
1376
|
-
name?: string | undefined;
|
|
1377
|
-
description?: string | undefined;
|
|
1378
|
-
partial?: any;
|
|
1379
|
-
order?: "asc" | "desc" | undefined;
|
|
1380
|
-
}>;
|
|
1381
|
-
}, "strip", z.ZodTypeAny, {
|
|
1382
|
-
type: "addIndex";
|
|
1383
|
-
definition: {
|
|
1384
|
-
fields: string[];
|
|
1385
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1386
|
-
unique?: boolean | undefined;
|
|
1387
|
-
name?: string | undefined;
|
|
1388
|
-
description?: string | undefined;
|
|
1389
|
-
partial?: any;
|
|
1390
|
-
order?: "asc" | "desc" | undefined;
|
|
1391
|
-
};
|
|
1392
|
-
}, {
|
|
1393
|
-
type: "addIndex";
|
|
1394
|
-
definition: {
|
|
1395
|
-
fields: string[];
|
|
1396
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1397
|
-
unique?: boolean | undefined;
|
|
1398
|
-
name?: string | undefined;
|
|
1399
|
-
description?: string | undefined;
|
|
1400
|
-
partial?: any;
|
|
1401
|
-
order?: "asc" | "desc" | undefined;
|
|
1402
|
-
};
|
|
1403
|
-
}>, z.ZodObject<{
|
|
1404
|
-
type: z.ZodLiteral<"removeIndex">;
|
|
1405
|
-
name: z.ZodString;
|
|
1406
|
-
}, "strip", z.ZodTypeAny, {
|
|
1407
|
-
name: string;
|
|
1408
|
-
type: "removeIndex";
|
|
1409
|
-
}, {
|
|
1410
|
-
name: string;
|
|
1411
|
-
type: "removeIndex";
|
|
1412
|
-
}>, z.ZodObject<{
|
|
1413
|
-
type: z.ZodLiteral<"modifyIndex">;
|
|
1414
|
-
name: z.ZodString;
|
|
1415
|
-
changes: z.ZodObject<{
|
|
1416
|
-
fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1417
|
-
type: z.ZodOptional<z.ZodEnum<["normal", "unique", "btree", "hash", "spatial", "fulltext", "gi", "expression", "composite"]>>;
|
|
1418
|
-
unique: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
1419
|
-
partial: z.ZodOptional<z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>>;
|
|
1420
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1421
|
-
order: z.ZodOptional<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
|
|
1422
|
-
name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1423
|
-
}, "strip", z.ZodTypeAny, {
|
|
1424
|
-
unique?: boolean | undefined;
|
|
1425
|
-
fields?: string[] | undefined;
|
|
1426
|
-
name?: string | undefined;
|
|
1427
|
-
description?: string | undefined;
|
|
1428
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1429
|
-
partial?: any;
|
|
1430
|
-
order?: "asc" | "desc" | undefined;
|
|
1431
|
-
}, {
|
|
1432
|
-
unique?: boolean | undefined;
|
|
1433
|
-
fields?: string[] | undefined;
|
|
1434
|
-
name?: string | undefined;
|
|
1435
|
-
description?: string | undefined;
|
|
1436
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1437
|
-
partial?: any;
|
|
1438
|
-
order?: "asc" | "desc" | undefined;
|
|
1439
|
-
}>;
|
|
1440
|
-
}, "strip", z.ZodTypeAny, {
|
|
1441
|
-
name: string;
|
|
1442
|
-
type: "modifyIndex";
|
|
1443
|
-
changes: {
|
|
1444
|
-
unique?: boolean | undefined;
|
|
1445
|
-
fields?: string[] | undefined;
|
|
1446
|
-
name?: string | undefined;
|
|
1447
|
-
description?: string | undefined;
|
|
1448
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1449
|
-
partial?: any;
|
|
1450
|
-
order?: "asc" | "desc" | undefined;
|
|
1451
|
-
};
|
|
1452
|
-
}, {
|
|
1453
|
-
name: string;
|
|
1454
|
-
type: "modifyIndex";
|
|
1455
|
-
changes: {
|
|
1456
|
-
unique?: boolean | undefined;
|
|
1457
|
-
fields?: string[] | undefined;
|
|
1458
|
-
name?: string | undefined;
|
|
1459
|
-
description?: string | undefined;
|
|
1460
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1461
|
-
partial?: any;
|
|
1462
|
-
order?: "asc" | "desc" | undefined;
|
|
1463
|
-
};
|
|
1464
|
-
}>, z.ZodObject<{
|
|
1465
|
-
type: z.ZodLiteral<"addConstraint">;
|
|
1466
|
-
constraint: z.ZodUnion<[z.ZodObject<{
|
|
1467
|
-
type: z.ZodOptional<z.ZodString>;
|
|
1468
|
-
name: z.ZodString;
|
|
1469
|
-
predicate: z.ZodOptional<z.ZodString>;
|
|
1470
|
-
parameters: z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>;
|
|
1471
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1472
|
-
field: z.ZodOptional<z.ZodString>;
|
|
1473
|
-
errorMessage: z.ZodOptional<z.ZodString>;
|
|
1474
|
-
}, "strip", z.ZodTypeAny, {
|
|
1475
|
-
name: string;
|
|
1476
|
-
description?: string | undefined;
|
|
1477
|
-
type?: string | undefined;
|
|
1478
|
-
predicate?: string | undefined;
|
|
1479
|
-
field?: string | undefined;
|
|
1480
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1481
|
-
errorMessage?: string | undefined;
|
|
1482
|
-
}, {
|
|
1483
|
-
name: string;
|
|
1484
|
-
description?: string | undefined;
|
|
1485
|
-
type?: string | undefined;
|
|
1486
|
-
predicate?: string | undefined;
|
|
1487
|
-
field?: string | undefined;
|
|
1488
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1489
|
-
errorMessage?: string | undefined;
|
|
1490
|
-
}>, any]>;
|
|
1491
|
-
}, "strip", z.ZodTypeAny, {
|
|
1492
|
-
type: "addConstraint";
|
|
1493
|
-
constraint?: any;
|
|
1494
|
-
}, {
|
|
1495
|
-
type: "addConstraint";
|
|
1496
|
-
constraint?: any;
|
|
1497
|
-
}>, z.ZodObject<{
|
|
1498
|
-
type: z.ZodLiteral<"removeConstraint">;
|
|
1499
|
-
name: z.ZodString;
|
|
1500
|
-
}, "strip", z.ZodTypeAny, {
|
|
1501
|
-
name: string;
|
|
1502
|
-
type: "removeConstraint";
|
|
1503
|
-
}, {
|
|
1504
|
-
name: string;
|
|
1505
|
-
type: "removeConstraint";
|
|
1506
|
-
}>, z.ZodObject<{
|
|
1507
|
-
type: z.ZodLiteral<"modifyConstraint">;
|
|
1508
|
-
name: z.ZodString;
|
|
1509
|
-
changes: z.ZodObject<{
|
|
1510
|
-
type: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1511
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1512
|
-
predicate: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1513
|
-
parameters: z.ZodOptional<z.ZodOptional<z.ZodType<(params: any) => boolean, z.ZodTypeDef, (params: any) => boolean>>>;
|
|
1514
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1515
|
-
field: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1516
|
-
errorMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1517
|
-
}, "strip", z.ZodTypeAny, {
|
|
1518
|
-
name?: string | undefined;
|
|
1519
|
-
description?: string | undefined;
|
|
1520
|
-
type?: string | undefined;
|
|
1521
|
-
predicate?: string | undefined;
|
|
1522
|
-
field?: string | undefined;
|
|
1523
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1524
|
-
errorMessage?: string | undefined;
|
|
1525
|
-
}, {
|
|
1526
|
-
name?: string | undefined;
|
|
1527
|
-
description?: string | undefined;
|
|
1528
|
-
type?: string | undefined;
|
|
1529
|
-
predicate?: string | undefined;
|
|
1530
|
-
field?: string | undefined;
|
|
1531
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1532
|
-
errorMessage?: string | undefined;
|
|
1533
|
-
}>;
|
|
1534
|
-
}, "strip", z.ZodTypeAny, {
|
|
1535
|
-
name: string;
|
|
1536
|
-
type: "modifyConstraint";
|
|
1537
|
-
changes: {
|
|
1538
|
-
name?: string | undefined;
|
|
1539
|
-
description?: string | undefined;
|
|
1540
|
-
type?: string | undefined;
|
|
1541
|
-
predicate?: string | undefined;
|
|
1542
|
-
field?: string | undefined;
|
|
1543
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1544
|
-
errorMessage?: string | undefined;
|
|
1545
|
-
};
|
|
1546
|
-
}, {
|
|
1547
|
-
name: string;
|
|
1548
|
-
type: "modifyConstraint";
|
|
1549
|
-
changes: {
|
|
1550
|
-
name?: string | undefined;
|
|
1551
|
-
description?: string | undefined;
|
|
1552
|
-
type?: string | undefined;
|
|
1553
|
-
predicate?: string | undefined;
|
|
1554
|
-
field?: string | undefined;
|
|
1555
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1556
|
-
errorMessage?: string | undefined;
|
|
1557
|
-
};
|
|
1558
|
-
}>, z.ZodObject<{
|
|
1559
|
-
type: z.ZodLiteral<"deprecateField">;
|
|
1560
|
-
id: z.ZodString;
|
|
1561
|
-
}, "strip", z.ZodTypeAny, {
|
|
1562
|
-
type: "deprecateField";
|
|
1563
|
-
id: string;
|
|
1564
|
-
}, {
|
|
1565
|
-
type: "deprecateField";
|
|
1566
|
-
id: string;
|
|
1567
|
-
}>]>, "many">>;
|
|
1568
|
-
transform: z.ZodUnknown;
|
|
1569
|
-
createdAt: z.ZodString;
|
|
1570
|
-
checksum: z.ZodOptional<z.ZodString>;
|
|
1571
|
-
}, "strip", z.ZodTypeAny, {
|
|
1572
|
-
description: string;
|
|
1573
|
-
changes: ({
|
|
1574
|
-
type: "addField";
|
|
1575
|
-
id: string;
|
|
1576
|
-
definition?: any;
|
|
1577
|
-
} | {
|
|
1578
|
-
type: "removeField";
|
|
1579
|
-
id: string;
|
|
1580
|
-
} | {
|
|
1581
|
-
type: "modifyField";
|
|
1582
|
-
id: string;
|
|
1583
|
-
changes?: any;
|
|
1584
|
-
} | {
|
|
1585
|
-
type: "addIndex";
|
|
1586
|
-
definition: {
|
|
1587
|
-
fields: string[];
|
|
1588
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1589
|
-
unique?: boolean | undefined;
|
|
1590
|
-
name?: string | undefined;
|
|
1591
|
-
description?: string | undefined;
|
|
1592
|
-
partial?: any;
|
|
1593
|
-
order?: "asc" | "desc" | undefined;
|
|
1594
|
-
};
|
|
1595
|
-
} | {
|
|
1596
|
-
name: string;
|
|
1597
|
-
type: "removeIndex";
|
|
1598
|
-
} | {
|
|
1599
|
-
name: string;
|
|
1600
|
-
type: "modifyIndex";
|
|
1601
|
-
changes: {
|
|
1602
|
-
unique?: boolean | undefined;
|
|
1603
|
-
fields?: string[] | undefined;
|
|
1604
|
-
name?: string | undefined;
|
|
1605
|
-
description?: string | undefined;
|
|
1606
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1607
|
-
partial?: any;
|
|
1608
|
-
order?: "asc" | "desc" | undefined;
|
|
1609
|
-
};
|
|
1610
|
-
} | {
|
|
1611
|
-
type: "addConstraint";
|
|
1612
|
-
constraint?: any;
|
|
1613
|
-
} | {
|
|
1614
|
-
name: string;
|
|
1615
|
-
type: "removeConstraint";
|
|
1616
|
-
} | {
|
|
1617
|
-
name: string;
|
|
1618
|
-
type: "modifyConstraint";
|
|
1619
|
-
changes: {
|
|
1620
|
-
name?: string | undefined;
|
|
1621
|
-
description?: string | undefined;
|
|
1622
|
-
type?: string | undefined;
|
|
1623
|
-
predicate?: string | undefined;
|
|
1624
|
-
field?: string | undefined;
|
|
1625
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1626
|
-
errorMessage?: string | undefined;
|
|
1627
|
-
};
|
|
1628
|
-
} | {
|
|
1629
|
-
type: "deprecateField";
|
|
1630
|
-
id: string;
|
|
1631
|
-
})[];
|
|
1632
|
-
status: "pending" | "applied" | "failed";
|
|
1633
|
-
id: string;
|
|
1634
|
-
schemaVersion: string;
|
|
1635
|
-
createdAt: string;
|
|
1636
|
-
rollback?: ({
|
|
1637
|
-
type: "addField";
|
|
1638
|
-
id: string;
|
|
1639
|
-
definition?: any;
|
|
1640
|
-
} | {
|
|
1641
|
-
type: "removeField";
|
|
1642
|
-
id: string;
|
|
1643
|
-
} | {
|
|
1644
|
-
type: "modifyField";
|
|
1645
|
-
id: string;
|
|
1646
|
-
changes?: any;
|
|
1647
|
-
} | {
|
|
1648
|
-
type: "addIndex";
|
|
1649
|
-
definition: {
|
|
1650
|
-
fields: string[];
|
|
1651
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1652
|
-
unique?: boolean | undefined;
|
|
1653
|
-
name?: string | undefined;
|
|
1654
|
-
description?: string | undefined;
|
|
1655
|
-
partial?: any;
|
|
1656
|
-
order?: "asc" | "desc" | undefined;
|
|
1657
|
-
};
|
|
1658
|
-
} | {
|
|
1659
|
-
name: string;
|
|
1660
|
-
type: "removeIndex";
|
|
1661
|
-
} | {
|
|
1662
|
-
name: string;
|
|
1663
|
-
type: "modifyIndex";
|
|
1664
|
-
changes: {
|
|
1665
|
-
unique?: boolean | undefined;
|
|
1666
|
-
fields?: string[] | undefined;
|
|
1667
|
-
name?: string | undefined;
|
|
1668
|
-
description?: string | undefined;
|
|
1669
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1670
|
-
partial?: any;
|
|
1671
|
-
order?: "asc" | "desc" | undefined;
|
|
1672
|
-
};
|
|
1673
|
-
} | {
|
|
1674
|
-
type: "addConstraint";
|
|
1675
|
-
constraint?: any;
|
|
1676
|
-
} | {
|
|
1677
|
-
name: string;
|
|
1678
|
-
type: "removeConstraint";
|
|
1679
|
-
} | {
|
|
1680
|
-
name: string;
|
|
1681
|
-
type: "modifyConstraint";
|
|
1682
|
-
changes: {
|
|
1683
|
-
name?: string | undefined;
|
|
1684
|
-
description?: string | undefined;
|
|
1685
|
-
type?: string | undefined;
|
|
1686
|
-
predicate?: string | undefined;
|
|
1687
|
-
field?: string | undefined;
|
|
1688
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1689
|
-
errorMessage?: string | undefined;
|
|
1690
|
-
};
|
|
1691
|
-
} | {
|
|
1692
|
-
type: "deprecateField";
|
|
1693
|
-
id: string;
|
|
1694
|
-
})[] | undefined;
|
|
1695
|
-
transform?: unknown;
|
|
1696
|
-
checksum?: string | undefined;
|
|
1697
|
-
}, {
|
|
1698
|
-
description: string;
|
|
1699
|
-
changes: ({
|
|
1700
|
-
type: "addField";
|
|
1701
|
-
id: string;
|
|
1702
|
-
definition?: any;
|
|
1703
|
-
} | {
|
|
1704
|
-
type: "removeField";
|
|
1705
|
-
id: string;
|
|
1706
|
-
} | {
|
|
1707
|
-
type: "modifyField";
|
|
1708
|
-
id: string;
|
|
1709
|
-
changes?: any;
|
|
1710
|
-
} | {
|
|
1711
|
-
type: "addIndex";
|
|
1712
|
-
definition: {
|
|
1713
|
-
fields: string[];
|
|
1714
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1715
|
-
unique?: boolean | undefined;
|
|
1716
|
-
name?: string | undefined;
|
|
1717
|
-
description?: string | undefined;
|
|
1718
|
-
partial?: any;
|
|
1719
|
-
order?: "asc" | "desc" | undefined;
|
|
1720
|
-
};
|
|
1721
|
-
} | {
|
|
1722
|
-
name: string;
|
|
1723
|
-
type: "removeIndex";
|
|
1724
|
-
} | {
|
|
1725
|
-
name: string;
|
|
1726
|
-
type: "modifyIndex";
|
|
1727
|
-
changes: {
|
|
1728
|
-
unique?: boolean | undefined;
|
|
1729
|
-
fields?: string[] | undefined;
|
|
1730
|
-
name?: string | undefined;
|
|
1731
|
-
description?: string | undefined;
|
|
1732
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1733
|
-
partial?: any;
|
|
1734
|
-
order?: "asc" | "desc" | undefined;
|
|
1735
|
-
};
|
|
1736
|
-
} | {
|
|
1737
|
-
type: "addConstraint";
|
|
1738
|
-
constraint?: any;
|
|
1739
|
-
} | {
|
|
1740
|
-
name: string;
|
|
1741
|
-
type: "removeConstraint";
|
|
1742
|
-
} | {
|
|
1743
|
-
name: string;
|
|
1744
|
-
type: "modifyConstraint";
|
|
1745
|
-
changes: {
|
|
1746
|
-
name?: string | undefined;
|
|
1747
|
-
description?: string | undefined;
|
|
1748
|
-
type?: string | undefined;
|
|
1749
|
-
predicate?: string | undefined;
|
|
1750
|
-
field?: string | undefined;
|
|
1751
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1752
|
-
errorMessage?: string | undefined;
|
|
1753
|
-
};
|
|
1754
|
-
} | {
|
|
1755
|
-
type: "deprecateField";
|
|
1756
|
-
id: string;
|
|
1757
|
-
})[];
|
|
1758
|
-
status: "pending" | "applied" | "failed";
|
|
1759
|
-
id: string;
|
|
1760
|
-
schemaVersion: string;
|
|
1761
|
-
createdAt: string;
|
|
1762
|
-
rollback?: ({
|
|
1763
|
-
type: "addField";
|
|
1764
|
-
id: string;
|
|
1765
|
-
definition?: any;
|
|
1766
|
-
} | {
|
|
1767
|
-
type: "removeField";
|
|
1768
|
-
id: string;
|
|
1769
|
-
} | {
|
|
1770
|
-
type: "modifyField";
|
|
1771
|
-
id: string;
|
|
1772
|
-
changes?: any;
|
|
1773
|
-
} | {
|
|
1774
|
-
type: "addIndex";
|
|
1775
|
-
definition: {
|
|
1776
|
-
fields: string[];
|
|
1777
|
-
type: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite";
|
|
1778
|
-
unique?: boolean | undefined;
|
|
1779
|
-
name?: string | undefined;
|
|
1780
|
-
description?: string | undefined;
|
|
1781
|
-
partial?: any;
|
|
1782
|
-
order?: "asc" | "desc" | undefined;
|
|
1783
|
-
};
|
|
1784
|
-
} | {
|
|
1785
|
-
name: string;
|
|
1786
|
-
type: "removeIndex";
|
|
1787
|
-
} | {
|
|
1788
|
-
name: string;
|
|
1789
|
-
type: "modifyIndex";
|
|
1790
|
-
changes: {
|
|
1791
|
-
unique?: boolean | undefined;
|
|
1792
|
-
fields?: string[] | undefined;
|
|
1793
|
-
name?: string | undefined;
|
|
1794
|
-
description?: string | undefined;
|
|
1795
|
-
type?: "normal" | "unique" | "btree" | "hash" | "spatial" | "fulltext" | "gi" | "expression" | "composite" | undefined;
|
|
1796
|
-
partial?: any;
|
|
1797
|
-
order?: "asc" | "desc" | undefined;
|
|
1798
|
-
};
|
|
1799
|
-
} | {
|
|
1800
|
-
type: "addConstraint";
|
|
1801
|
-
constraint?: any;
|
|
1802
|
-
} | {
|
|
1803
|
-
name: string;
|
|
1804
|
-
type: "removeConstraint";
|
|
1805
|
-
} | {
|
|
1806
|
-
name: string;
|
|
1807
|
-
type: "modifyConstraint";
|
|
1808
|
-
changes: {
|
|
1809
|
-
name?: string | undefined;
|
|
1810
|
-
description?: string | undefined;
|
|
1811
|
-
type?: string | undefined;
|
|
1812
|
-
predicate?: string | undefined;
|
|
1813
|
-
field?: string | undefined;
|
|
1814
|
-
parameters?: ((params: any) => boolean) | undefined;
|
|
1815
|
-
errorMessage?: string | undefined;
|
|
1816
|
-
};
|
|
1817
|
-
} | {
|
|
1818
|
-
type: "deprecateField";
|
|
1819
|
-
id: string;
|
|
1820
|
-
})[] | undefined;
|
|
1821
|
-
transform?: unknown;
|
|
1822
|
-
checksum?: string | undefined;
|
|
1823
|
-
}>;
|
|
1824
1323
|
declare function validateMigration<T>(change: any): change is Migration<T>;
|
|
1825
1324
|
declare function validateSchemaChange<T>(change: any): change is SchemaChange<T>;
|
|
1826
1325
|
declare function validateSchemaDefinition(schema: any): schema is SchemaDefinition;
|
|
@@ -1845,28 +1344,26 @@ declare function deepMerge<T extends object>(target: T, update: Partial<T>): T;
|
|
|
1845
1344
|
/**
|
|
1846
1345
|
* Converts a SchemaDefinition to TypeScript type definitions
|
|
1847
1346
|
*
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1850
|
-
*
|
|
1347
|
+
* Analyzes a schema definition and generates TypeScript type declarations for the main schema,
|
|
1348
|
+
* nested schemas, and union types for enum-like constraints. Uses capitalized field.name for field names,
|
|
1349
|
+
* capitalized nestedSchema.name for type names, and ignores UUID keys. Handles required/optional fields,
|
|
1350
|
+
* union types, primitives, arrays, sets, references, and nested structures with strict type safety.
|
|
1851
1351
|
*
|
|
1852
|
-
* @param
|
|
1853
|
-
* @param
|
|
1854
|
-
* @param
|
|
1855
|
-
* @returns
|
|
1352
|
+
* @param schema - The schema definition to convert
|
|
1353
|
+
* @param includeComments - Whether to include JSDoc comments (default: true)
|
|
1354
|
+
* @param exportTypes - Whether to export the generated types (default: true)
|
|
1355
|
+
* @returns TypeScript type definitions as a string
|
|
1856
1356
|
*/
|
|
1857
1357
|
declare function schemaToTypes(schema: SchemaDefinition, includeComments?: boolean, exportTypes?: boolean): string;
|
|
1858
1358
|
/**
|
|
1859
1359
|
* Generates a TypeScript interface for validating schema data
|
|
1860
|
-
*
|
|
1861
|
-
* This function creates a validation interface with methods that
|
|
1862
|
-
* correspond to the schema constraints.
|
|
1863
|
-
*
|
|
1864
|
-
* @param {SchemaDefinition} schema - The schema definition
|
|
1865
|
-
* @param {boolean} [exportType=true] - Whether to export the generated interface
|
|
1866
|
-
* @returns {string} TypeScript interface definition for validation
|
|
1867
1360
|
*/
|
|
1868
1361
|
declare function generateValidationInterface(schema: SchemaDefinition, exportType?: boolean): string;
|
|
1869
1362
|
|
|
1363
|
+
/**
|
|
1364
|
+
* Serializes constraint parameters for error messages, handling special types like RegExp.
|
|
1365
|
+
*/
|
|
1366
|
+
declare function serializeParams(params: any): string;
|
|
1870
1367
|
/**
|
|
1871
1368
|
* Creates a Standard Schema validator that conforms to the StandardSchemaV1 interface.
|
|
1872
1369
|
* The validator uses a closure pattern to maintain internal state and avoid prop drilling.
|
|
@@ -1914,4 +1411,4 @@ declare function docgen(schema: SchemaDefinition, options?: {
|
|
|
1914
1411
|
faker?: Faker;
|
|
1915
1412
|
}): string;
|
|
1916
1413
|
|
|
1917
|
-
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,
|
|
1414
|
+
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, type NestedSchemaDefinition, 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 RemoteRepository, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, SchemaRegistry, type SchemaRegistryInterface, type SchemaVersion, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createGitSchemaRegistry, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, generateSHA256Hash, generateValidationInterface, normalizePath, schemaChangeToPatch, schemaToTypes, serializeParams, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };
|