@prisma-next/family-sql 0.3.0-pr.99.6 → 0.3.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/LICENSE +201 -0
- package/README.md +58 -22
- package/dist/authoring-type-constructors-DgU-RFaP.mjs +203 -0
- package/dist/authoring-type-constructors-DgU-RFaP.mjs.map +1 -0
- package/dist/control-adapter.d.mts +54 -0
- package/dist/control-adapter.d.mts.map +1 -0
- package/dist/control-adapter.mjs +1 -0
- package/dist/control.d.mts +386 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +643 -0
- package/dist/control.mjs.map +1 -0
- package/dist/operation-descriptors.d.mts +380 -0
- package/dist/operation-descriptors.d.mts.map +1 -0
- package/dist/operation-descriptors.mjs +294 -0
- package/dist/operation-descriptors.mjs.map +1 -0
- package/dist/pack.d.mts +248 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +18 -0
- package/dist/pack.mjs.map +1 -0
- package/dist/runtime.d.mts +27 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +38 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-verify.d.mts +48 -0
- package/dist/schema-verify.d.mts.map +1 -0
- package/dist/schema-verify.mjs +3 -0
- package/dist/test-utils.d.mts +2 -0
- package/dist/test-utils.mjs +3 -0
- package/dist/types-BaUzKt6Q.d.mts +353 -0
- package/dist/types-BaUzKt6Q.d.mts.map +1 -0
- package/dist/verify-DZHtfcmj.mjs +108 -0
- package/dist/verify-DZHtfcmj.mjs.map +1 -0
- package/dist/verify-sql-schema-BBhkqEDo.d.mts +67 -0
- package/dist/verify-sql-schema-BBhkqEDo.d.mts.map +1 -0
- package/dist/verify-sql-schema-lR-tlboL.mjs +1174 -0
- package/dist/verify-sql-schema-lR-tlboL.mjs.map +1 -0
- package/dist/verify.d.mts +31 -0
- package/dist/verify.d.mts.map +1 -0
- package/dist/verify.mjs +3 -0
- package/package.json +36 -44
- package/src/core/assembly.ts +123 -155
- package/src/core/authoring-field-presets.ts +207 -0
- package/src/core/authoring-type-constructors.ts +17 -0
- package/src/core/control-adapter.ts +18 -10
- package/src/core/control-descriptor.ts +28 -0
- package/src/core/control-instance.ts +700 -0
- package/src/core/migrations/contract-to-schema-ir.ts +269 -0
- package/src/core/migrations/descriptor-schemas.ts +172 -0
- package/src/core/migrations/operation-descriptors.ts +213 -0
- package/src/core/migrations/policies.ts +1 -1
- package/src/core/migrations/types.ts +199 -175
- package/src/core/runtime-descriptor.ts +19 -41
- package/src/core/runtime-instance.ts +11 -133
- package/src/core/schema-verify/verify-helpers.ts +104 -22
- package/src/core/schema-verify/verify-sql-schema.ts +964 -418
- package/src/core/verify.ts +4 -13
- package/src/exports/control.ts +31 -8
- package/src/exports/operation-descriptors.ts +52 -0
- package/src/exports/pack.ts +16 -0
- package/src/exports/runtime.ts +2 -6
- package/src/exports/schema-verify.ts +4 -1
- package/src/exports/test-utils.ts +3 -4
- package/dist/chunk-GYEG3I7U.js +0 -624
- package/dist/chunk-GYEG3I7U.js.map +0 -1
- package/dist/chunk-SU7LN2UH.js +0 -96
- package/dist/chunk-SU7LN2UH.js.map +0 -1
- package/dist/chunk-XH2Y5NTD.js +0 -715
- package/dist/chunk-XH2Y5NTD.js.map +0 -1
- package/dist/core/assembly.d.ts +0 -43
- package/dist/core/assembly.d.ts.map +0 -1
- package/dist/core/control-adapter.d.ts +0 -42
- package/dist/core/control-adapter.d.ts.map +0 -1
- package/dist/core/descriptor.d.ts +0 -28
- package/dist/core/descriptor.d.ts.map +0 -1
- package/dist/core/instance.d.ts +0 -140
- package/dist/core/instance.d.ts.map +0 -1
- package/dist/core/migrations/plan-helpers.d.ts +0 -20
- package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
- package/dist/core/migrations/policies.d.ts +0 -6
- package/dist/core/migrations/policies.d.ts.map +0 -1
- package/dist/core/migrations/types.d.ts +0 -280
- package/dist/core/migrations/types.d.ts.map +0 -1
- package/dist/core/runtime-descriptor.d.ts +0 -19
- package/dist/core/runtime-descriptor.d.ts.map +0 -1
- package/dist/core/runtime-instance.d.ts +0 -54
- package/dist/core/runtime-instance.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-helpers.d.ts +0 -96
- package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
- package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
- package/dist/core/verify.d.ts +0 -39
- package/dist/core/verify.d.ts.map +0 -1
- package/dist/exports/control-adapter.d.ts +0 -2
- package/dist/exports/control-adapter.d.ts.map +0 -1
- package/dist/exports/control-adapter.js +0 -1
- package/dist/exports/control-adapter.js.map +0 -1
- package/dist/exports/control.d.ts +0 -13
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -149
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -64
- package/dist/exports/runtime.js.map +0 -1
- package/dist/exports/schema-verify.d.ts +0 -11
- package/dist/exports/schema-verify.d.ts.map +0 -1
- package/dist/exports/schema-verify.js +0 -15
- package/dist/exports/schema-verify.js.map +0 -1
- package/dist/exports/test-utils.d.ts +0 -7
- package/dist/exports/test-utils.d.ts.map +0 -1
- package/dist/exports/test-utils.js +0 -17
- package/dist/exports/test-utils.js.map +0 -1
- package/dist/exports/verify.d.ts +0 -2
- package/dist/exports/verify.d.ts.map +0 -1
- package/dist/exports/verify.js +0 -11
- package/dist/exports/verify.js.map +0 -1
- package/src/core/descriptor.ts +0 -33
- package/src/core/instance.ts +0 -909
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { A as SqlPlannerConflict, B as SqlControlFamilyInstance, C as SqlMigrationRunner, D as SqlMigrationRunnerFailure, E as SqlMigrationRunnerExecuteOptions, F as SqlPlannerSuccessResult, I as StorageTypePlanResult, L as collectInitDependencies, M as SqlPlannerConflictLocation, N as SqlPlannerFailureResult, O as SqlMigrationRunnerResult, P as SqlPlannerResult, R as isDatabaseDependencyProvider, S as SqlMigrationPlannerPlanOptions, T as SqlMigrationRunnerExecuteCallbacks, _ as SqlMigrationPlanContractInfo, a as ControlMutationDefaultFunctionEntry, b as SqlMigrationPlanOperationTarget, c as CreateSqlMigrationPlanOptions, d as ResolveIdentityValueInput, f as SqlControlAdapterDescriptor, g as SqlMigrationPlan, h as SqlControlTargetDescriptor, i as ComponentDatabaseDependency, j as SqlPlannerConflictKind, k as SqlMigrationRunnerSuccessValue, l as ExpandNativeTypeInput, m as SqlControlStaticContributions, n as CodecControlHooks, o as ControlMutationDefaultFunctionHandler, p as SqlControlExtensionDescriptor, r as ComponentDatabaseDependencies, s as ControlMutationDefaultGeneratorDescriptor, t as AnyRecord, u as PslScalarTypeDescriptor, v as SqlMigrationPlanOperation, w as SqlMigrationRunnerErrorCode, x as SqlMigrationPlanner, y as SqlMigrationPlanOperationStep, z as SchemaVerifyOptions } from "./types-BaUzKt6Q.mjs";
|
|
2
|
+
import { Codec } from "@prisma-next/framework-components/codec";
|
|
3
|
+
import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { NotOk, Ok } from "@prisma-next/utils/result";
|
|
5
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
6
|
+
import * as _prisma_next_contract_types0 from "@prisma-next/contract/types";
|
|
7
|
+
import { ColumnDefault, Contract } from "@prisma-next/contract/types";
|
|
8
|
+
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
9
|
+
import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
10
|
+
import * as _prisma_next_framework_components_emission0 from "@prisma-next/framework-components/emission";
|
|
11
|
+
import { TypesImportSpec } from "@prisma-next/framework-components/emission";
|
|
12
|
+
import { AuthoringContributions } from "@prisma-next/framework-components/authoring";
|
|
13
|
+
|
|
14
|
+
//#region src/core/control-descriptor.d.ts
|
|
15
|
+
declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlControlFamilyInstance> {
|
|
16
|
+
readonly kind: "family";
|
|
17
|
+
readonly id = "sql";
|
|
18
|
+
readonly familyId: "sql";
|
|
19
|
+
readonly version = "0.0.1";
|
|
20
|
+
readonly emission: {
|
|
21
|
+
readonly id: "sql";
|
|
22
|
+
readonly validateTypes: (contract: _prisma_next_contract_types0.Contract, _ctx: _prisma_next_framework_components_emission0.ValidationContext) => void;
|
|
23
|
+
readonly validateStructure: (contract: _prisma_next_contract_types0.Contract) => void;
|
|
24
|
+
readonly generateStorageType: (contract: _prisma_next_contract_types0.Contract, storageHashTypeName: string) => string;
|
|
25
|
+
readonly generateModelStorageType: (_modelName: string, model: _prisma_next_contract_types0.ContractModel) => string;
|
|
26
|
+
readonly getFamilyImports: () => string[];
|
|
27
|
+
readonly getFamilyTypeAliases: (options?: _prisma_next_framework_components_emission0.GenerateContractTypesOptions) => string;
|
|
28
|
+
readonly getTypeMapsExpression: () => string;
|
|
29
|
+
readonly getContractWrapper: (contractBaseName: string, typeMapsName: string) => string;
|
|
30
|
+
};
|
|
31
|
+
readonly authoring: {
|
|
32
|
+
readonly field: {
|
|
33
|
+
readonly text: {
|
|
34
|
+
readonly kind: "fieldPreset";
|
|
35
|
+
readonly output: {
|
|
36
|
+
readonly codecId: "sql/text@1";
|
|
37
|
+
readonly nativeType: "text";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
readonly timestamp: {
|
|
41
|
+
readonly kind: "fieldPreset";
|
|
42
|
+
readonly output: {
|
|
43
|
+
readonly codecId: "sql/timestamp@1";
|
|
44
|
+
readonly nativeType: "timestamp";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly createdAt: {
|
|
48
|
+
readonly kind: "fieldPreset";
|
|
49
|
+
readonly output: {
|
|
50
|
+
readonly codecId: "sql/timestamp@1";
|
|
51
|
+
readonly nativeType: "timestamp";
|
|
52
|
+
readonly default: {
|
|
53
|
+
readonly kind: "function";
|
|
54
|
+
readonly expression: "CURRENT_TIMESTAMP";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
readonly uuid: {
|
|
59
|
+
readonly kind: "fieldPreset";
|
|
60
|
+
readonly output: {
|
|
61
|
+
readonly codecId: "sql/char@1";
|
|
62
|
+
readonly nativeType: "character";
|
|
63
|
+
readonly typeParams: {
|
|
64
|
+
readonly length: 36;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly ulid: {
|
|
69
|
+
readonly kind: "fieldPreset";
|
|
70
|
+
readonly output: {
|
|
71
|
+
readonly codecId: "sql/char@1";
|
|
72
|
+
readonly nativeType: "character";
|
|
73
|
+
readonly typeParams: {
|
|
74
|
+
readonly length: 26;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly nanoid: {
|
|
79
|
+
readonly kind: "fieldPreset";
|
|
80
|
+
readonly args: readonly [{
|
|
81
|
+
readonly kind: "object";
|
|
82
|
+
readonly optional: true;
|
|
83
|
+
readonly properties: {
|
|
84
|
+
readonly size: {
|
|
85
|
+
readonly kind: "number";
|
|
86
|
+
readonly optional: true;
|
|
87
|
+
readonly integer: true;
|
|
88
|
+
readonly minimum: 2;
|
|
89
|
+
readonly maximum: 255;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}];
|
|
93
|
+
readonly output: {
|
|
94
|
+
readonly codecId: "sql/char@1";
|
|
95
|
+
readonly nativeType: "character";
|
|
96
|
+
readonly typeParams: {
|
|
97
|
+
readonly length: {
|
|
98
|
+
readonly kind: "arg";
|
|
99
|
+
readonly index: 0;
|
|
100
|
+
readonly path: readonly ["size"];
|
|
101
|
+
readonly default: 21;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
readonly cuid2: {
|
|
107
|
+
readonly kind: "fieldPreset";
|
|
108
|
+
readonly output: {
|
|
109
|
+
readonly codecId: "sql/char@1";
|
|
110
|
+
readonly nativeType: "character";
|
|
111
|
+
readonly typeParams: {
|
|
112
|
+
readonly length: 24;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
readonly ksuid: {
|
|
117
|
+
readonly kind: "fieldPreset";
|
|
118
|
+
readonly output: {
|
|
119
|
+
readonly codecId: "sql/char@1";
|
|
120
|
+
readonly nativeType: "character";
|
|
121
|
+
readonly typeParams: {
|
|
122
|
+
readonly length: 27;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
readonly id: {
|
|
127
|
+
readonly uuidv4: {
|
|
128
|
+
readonly kind: "fieldPreset";
|
|
129
|
+
readonly output: {
|
|
130
|
+
readonly codecId: "sql/char@1";
|
|
131
|
+
readonly nativeType: "character";
|
|
132
|
+
readonly typeParams: {
|
|
133
|
+
readonly length: 36;
|
|
134
|
+
};
|
|
135
|
+
readonly executionDefault: {
|
|
136
|
+
readonly kind: "generator";
|
|
137
|
+
readonly id: "uuidv4";
|
|
138
|
+
};
|
|
139
|
+
readonly id: true;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
readonly uuidv7: {
|
|
143
|
+
readonly kind: "fieldPreset";
|
|
144
|
+
readonly output: {
|
|
145
|
+
readonly codecId: "sql/char@1";
|
|
146
|
+
readonly nativeType: "character";
|
|
147
|
+
readonly typeParams: {
|
|
148
|
+
readonly length: 36;
|
|
149
|
+
};
|
|
150
|
+
readonly executionDefault: {
|
|
151
|
+
readonly kind: "generator";
|
|
152
|
+
readonly id: "uuidv7";
|
|
153
|
+
};
|
|
154
|
+
readonly id: true;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
readonly ulid: {
|
|
158
|
+
readonly kind: "fieldPreset";
|
|
159
|
+
readonly output: {
|
|
160
|
+
readonly codecId: "sql/char@1";
|
|
161
|
+
readonly nativeType: "character";
|
|
162
|
+
readonly typeParams: {
|
|
163
|
+
readonly length: 26;
|
|
164
|
+
};
|
|
165
|
+
readonly executionDefault: {
|
|
166
|
+
readonly kind: "generator";
|
|
167
|
+
readonly id: "ulid";
|
|
168
|
+
};
|
|
169
|
+
readonly id: true;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
readonly nanoid: {
|
|
173
|
+
readonly kind: "fieldPreset";
|
|
174
|
+
readonly args: readonly [{
|
|
175
|
+
readonly kind: "object";
|
|
176
|
+
readonly optional: true;
|
|
177
|
+
readonly properties: {
|
|
178
|
+
readonly size: {
|
|
179
|
+
readonly kind: "number";
|
|
180
|
+
readonly optional: true;
|
|
181
|
+
readonly integer: true;
|
|
182
|
+
readonly minimum: 2;
|
|
183
|
+
readonly maximum: 255;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
}];
|
|
187
|
+
readonly output: {
|
|
188
|
+
readonly codecId: "sql/char@1";
|
|
189
|
+
readonly nativeType: "character";
|
|
190
|
+
readonly typeParams: {
|
|
191
|
+
readonly length: {
|
|
192
|
+
readonly kind: "arg";
|
|
193
|
+
readonly index: 0;
|
|
194
|
+
readonly path: readonly ["size"];
|
|
195
|
+
readonly default: 21;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
readonly executionDefault: {
|
|
199
|
+
readonly kind: "generator";
|
|
200
|
+
readonly id: "nanoid";
|
|
201
|
+
readonly params: {
|
|
202
|
+
readonly size: {
|
|
203
|
+
readonly kind: "arg";
|
|
204
|
+
readonly index: 0;
|
|
205
|
+
readonly path: readonly ["size"];
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
readonly id: true;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
readonly cuid2: {
|
|
213
|
+
readonly kind: "fieldPreset";
|
|
214
|
+
readonly output: {
|
|
215
|
+
readonly codecId: "sql/char@1";
|
|
216
|
+
readonly nativeType: "character";
|
|
217
|
+
readonly typeParams: {
|
|
218
|
+
readonly length: 24;
|
|
219
|
+
};
|
|
220
|
+
readonly executionDefault: {
|
|
221
|
+
readonly kind: "generator";
|
|
222
|
+
readonly id: "cuid2";
|
|
223
|
+
};
|
|
224
|
+
readonly id: true;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
readonly ksuid: {
|
|
228
|
+
readonly kind: "fieldPreset";
|
|
229
|
+
readonly output: {
|
|
230
|
+
readonly codecId: "sql/char@1";
|
|
231
|
+
readonly nativeType: "character";
|
|
232
|
+
readonly typeParams: {
|
|
233
|
+
readonly length: 27;
|
|
234
|
+
};
|
|
235
|
+
readonly executionDefault: {
|
|
236
|
+
readonly kind: "generator";
|
|
237
|
+
readonly id: "ksuid";
|
|
238
|
+
};
|
|
239
|
+
readonly id: true;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
readonly type: {
|
|
245
|
+
readonly sql: {
|
|
246
|
+
readonly String: {
|
|
247
|
+
readonly kind: "typeConstructor";
|
|
248
|
+
readonly args: readonly [{
|
|
249
|
+
readonly kind: "number";
|
|
250
|
+
readonly name: "length";
|
|
251
|
+
readonly integer: true;
|
|
252
|
+
readonly minimum: 1;
|
|
253
|
+
readonly maximum: 10485760;
|
|
254
|
+
}];
|
|
255
|
+
readonly output: {
|
|
256
|
+
readonly codecId: "sql/varchar@1";
|
|
257
|
+
readonly nativeType: "character varying";
|
|
258
|
+
readonly typeParams: {
|
|
259
|
+
readonly length: {
|
|
260
|
+
readonly kind: "arg";
|
|
261
|
+
readonly index: 0;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
create<TTargetId extends string>(stack: ControlStack<'sql', TTargetId>): SqlControlFamilyInstance;
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/core/assembly.d.ts
|
|
273
|
+
interface SqlControlDescriptorWithContributions extends SqlControlStaticContributions {
|
|
274
|
+
readonly id: string;
|
|
275
|
+
readonly authoring?: AuthoringContributions;
|
|
276
|
+
readonly types?: {
|
|
277
|
+
readonly codecTypes?: {
|
|
278
|
+
readonly import?: TypesImportSpec;
|
|
279
|
+
readonly codecInstances?: ReadonlyArray<Codec>;
|
|
280
|
+
readonly typeImports?: ReadonlyArray<TypesImportSpec>;
|
|
281
|
+
};
|
|
282
|
+
readonly operationTypes?: {
|
|
283
|
+
readonly import: TypesImportSpec;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
interface AssembledControlMutationDefaultContributions {
|
|
288
|
+
readonly defaultFunctionRegistry: ReadonlyMap<string, ControlMutationDefaultFunctionEntry>;
|
|
289
|
+
readonly generatorDescriptors: readonly ControlMutationDefaultGeneratorDescriptor[];
|
|
290
|
+
}
|
|
291
|
+
interface AssembledPslInterpretationContributions extends AssembledControlMutationDefaultContributions {
|
|
292
|
+
readonly scalarTypeDescriptors: ReadonlyMap<string, PslScalarTypeDescriptor>;
|
|
293
|
+
}
|
|
294
|
+
declare function extractCodecControlHooks(descriptors: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>): Map<string, CodecControlHooks>;
|
|
295
|
+
declare function assembleControlMutationDefaultContributions(descriptors: ReadonlyArray<SqlControlDescriptorWithContributions>): AssembledControlMutationDefaultContributions;
|
|
296
|
+
declare function assemblePslInterpretationContributions(descriptors: ReadonlyArray<SqlControlDescriptorWithContributions>): AssembledPslInterpretationContributions;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/core/migrations/contract-to-schema-ir.d.ts
|
|
299
|
+
/**
|
|
300
|
+
* Target-specific callback that expands a column's base `nativeType` and optional
|
|
301
|
+
* `typeParams` into the fully-qualified type string used by the database
|
|
302
|
+
* (e.g. `character` + `{ length: 36 }` → `character(36)`).
|
|
303
|
+
*
|
|
304
|
+
* This lives in the family layer as a callback rather than importing a concrete
|
|
305
|
+
* implementation because each target (Postgres, MySQL, SQLite, …) has its own
|
|
306
|
+
* parameterization syntax. The target wires its expander when calling
|
|
307
|
+
* `contractToSchemaIR`, keeping the family layer target-agnostic.
|
|
308
|
+
*/
|
|
309
|
+
type NativeTypeExpander = (input: {
|
|
310
|
+
readonly nativeType: string;
|
|
311
|
+
readonly codecId?: string;
|
|
312
|
+
readonly typeParams?: Record<string, unknown>;
|
|
313
|
+
}) => string;
|
|
314
|
+
/**
|
|
315
|
+
* Target-specific callback that renders a `ColumnDefault` into the raw SQL literal
|
|
316
|
+
* string stored in `SqlColumnIR.default`.
|
|
317
|
+
*
|
|
318
|
+
* Default value serialization is target-specific (quoting, casting, type syntax vary
|
|
319
|
+
* between Postgres, MySQL, SQLite, …). This callback follows the same IoC pattern as
|
|
320
|
+
* `NativeTypeExpander`: the target provides its renderer when calling
|
|
321
|
+
* `contractToSchemaIR`, keeping the family layer target-agnostic.
|
|
322
|
+
*/
|
|
323
|
+
type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;
|
|
324
|
+
/**
|
|
325
|
+
* Detects destructive changes between two contract storages.
|
|
326
|
+
*
|
|
327
|
+
* The additive-only planner silently ignores removals (tables, columns).
|
|
328
|
+
* This function detects those removals so callers can report them as conflicts
|
|
329
|
+
* rather than silently producing an empty plan.
|
|
330
|
+
*
|
|
331
|
+
* Returns an empty array if no destructive changes are found.
|
|
332
|
+
*/
|
|
333
|
+
declare function detectDestructiveChanges(from: SqlStorage | null, to: SqlStorage): readonly MigrationPlannerConflict$1[];
|
|
334
|
+
interface ContractToSchemaIROptions {
|
|
335
|
+
readonly annotationNamespace: string;
|
|
336
|
+
readonly expandNativeType?: NativeTypeExpander;
|
|
337
|
+
readonly renderDefault?: DefaultRenderer;
|
|
338
|
+
readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Converts a `Contract` to `SqlSchemaIR`.
|
|
342
|
+
*
|
|
343
|
+
* Reads `contract.storage` for tables, `contract.storage.types` for type
|
|
344
|
+
* annotations, and derives database dependencies from `frameworkComponents`
|
|
345
|
+
* (each component's `databaseDependencies.init[].id`).
|
|
346
|
+
* Storage-type annotations are written under `options.annotationNamespace`.
|
|
347
|
+
*
|
|
348
|
+
* Drops codec metadata (`codecId`, `typeRef`) since the schema IR only represents
|
|
349
|
+
* structural information. When `expandNativeType` is provided, parameterized types
|
|
350
|
+
* are expanded (e.g. `character` + `{ length: 36 }` → `character(36)`) so the
|
|
351
|
+
* resulting IR compares correctly against the "to" contract during planning.
|
|
352
|
+
*
|
|
353
|
+
* Returns an empty schema IR when `contract` is `null` (new project).
|
|
354
|
+
*/
|
|
355
|
+
declare function contractToSchemaIR(contract: Contract<SqlStorage> | null, options: ContractToSchemaIROptions): SqlSchemaIR;
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/core/migrations/plan-helpers.d.ts
|
|
358
|
+
declare function createMigrationPlan<TTargetDetails>(options: CreateSqlMigrationPlanOptions<TTargetDetails>): SqlMigrationPlan<TTargetDetails>;
|
|
359
|
+
declare function plannerSuccess<TTargetDetails>(plan: SqlMigrationPlan<TTargetDetails>): SqlPlannerSuccessResult<TTargetDetails>;
|
|
360
|
+
declare function plannerFailure(conflicts: readonly SqlPlannerConflict[]): SqlPlannerFailureResult;
|
|
361
|
+
/**
|
|
362
|
+
* Creates a successful migration runner result.
|
|
363
|
+
*/
|
|
364
|
+
declare function runnerSuccess(value: {
|
|
365
|
+
operationsPlanned: number;
|
|
366
|
+
operationsExecuted: number;
|
|
367
|
+
}): Ok<SqlMigrationRunnerSuccessValue>;
|
|
368
|
+
/**
|
|
369
|
+
* Creates a failed migration runner result.
|
|
370
|
+
*/
|
|
371
|
+
declare function runnerFailure(code: SqlMigrationRunnerErrorCode, summary: string, options?: {
|
|
372
|
+
why?: string;
|
|
373
|
+
meta?: AnyRecord;
|
|
374
|
+
}): NotOk<SqlMigrationRunnerFailure>;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/core/migrations/policies.d.ts
|
|
377
|
+
/**
|
|
378
|
+
* Policy used by `db init`: additive-only operations, no widening/destructive steps.
|
|
379
|
+
*/
|
|
380
|
+
declare const INIT_ADDITIVE_POLICY: MigrationOperationPolicy$1;
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/exports/control.d.ts
|
|
383
|
+
declare const _default: SqlFamilyDescriptor;
|
|
384
|
+
//#endregion
|
|
385
|
+
export { type CodecControlHooks, type ComponentDatabaseDependencies, type ComponentDatabaseDependency, type ContractToSchemaIROptions, type ControlMutationDefaultFunctionEntry, type ControlMutationDefaultFunctionHandler, type ControlMutationDefaultGeneratorDescriptor, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type ExpandNativeTypeInput, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PslScalarTypeDescriptor, type ResolveIdentityValueInput, type SchemaVerifyOptions, type SqlControlAdapterDescriptor, type SqlControlDescriptorWithContributions, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlStaticContributions, type SqlControlTargetDescriptor, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, assembleControlMutationDefaultContributions, assemblePslInterpretationContributions, collectInitDependencies, contractToSchemaIR, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, isDatabaseDependencyProvider, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess };
|
|
386
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;cASa,mBAAA,YACA,+BAA+B;;;;;;;uCAAwB,4BAAA,CAAA;;;;;IADvD,SAAA,oBACX,EAAA,CAAA,OAAA,CAAA,8CAMkB,4BANlB,EAAA,GAAA,MAAA;IAA0C,SAAA,qBAAA,EAAA,GAAA,GAAA,MAAA;IAAwB,SAAA,kBAAA,EAAA,CAAA,gBAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,GAAA,MAAA;;;;;;QAarC,SAAA,MAAA,EAAA;UAApB,SAAA,OAAA,EAAA,YAAA;UACN,SAAA,UAAA,EAAA,MAAA;QAdQ,CAAA;MAAuB,CAAA;;;;UCGnB,SAAA,OAAA,EAAA,iBAAsC;UAEhC,SAAA,UAAA,EAAA,WAAA;QAGC,CAAA;MACsB,CAAA;MAAd,SAAA,SAAA,EAAA;QACW,SAAA,IAAA,EAAA,aAAA;QAAd,SAAA,MAAA,EAAA;UAEoB,SAAA,OAAA,EAAA,iBAAA;UATc,SAAA,UAAA,EAAA,WAAA;UAA6B,SAAA,OAAA,EAAA;YAa3E,SAAA,IAAA,EAAA,UAAA;YACuC,SAAA,UAAA,EAAA,mBA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