@prisma-next/family-sql 0.13.0-dev.2 → 0.13.0-dev.20
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/dist/authoring-type-constructors-CN60DEWb.mjs +342 -0
- package/dist/authoring-type-constructors-CN60DEWb.mjs.map +1 -0
- package/dist/{control-adapter-CgIL9Vtx.d.mts → control-adapter-B_s-UMXg.d.mts} +13 -14
- package/dist/control-adapter-B_s-UMXg.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +2 -2
- package/dist/control.d.mts +36 -34
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +14 -11
- package/dist/control.mjs.map +1 -1
- package/dist/ir.mjs +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +2 -1
- package/dist/migration.mjs.map +1 -1
- package/dist/pack.d.mts +16 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +4 -2
- package/dist/pack.mjs.map +1 -1
- package/dist/schema-verify.mjs +1 -1
- package/dist/{sql-contract-serializer-CY7qnms7.mjs → sql-contract-serializer-DlmNUCRw.mjs} +2 -2
- package/dist/{sql-contract-serializer-CY7qnms7.mjs.map → sql-contract-serializer-DlmNUCRw.mjs.map} +1 -1
- package/dist/{types-CbwQCzXY.d.mts → types-BR5vHjvX.d.mts} +5 -5
- package/dist/types-BR5vHjvX.d.mts.map +1 -0
- package/dist/{verify-sql-schema-DlAgBiT_.mjs → verify-sql-schema-Dj8GrEZ-.mjs} +27 -13
- package/dist/verify-sql-schema-Dj8GrEZ-.mjs.map +1 -0
- package/package.json +21 -21
- package/src/core/authoring-entity-types.ts +178 -0
- package/src/core/authoring-field-presets.ts +8 -3
- package/src/core/control-adapter.ts +16 -12
- package/src/core/control-descriptor.ts +3 -0
- package/src/core/control-instance.ts +11 -5
- package/src/core/migrations/contract-to-schema-ir.ts +61 -47
- package/src/core/migrations/types.ts +4 -1
- package/src/core/psl-contract-infer/postgres-type-map.ts +18 -9
- package/src/core/sql-migration.ts +5 -1
- package/src/exports/control-adapter.ts +1 -0
- package/src/exports/control.ts +1 -1
- package/src/exports/pack.ts +3 -0
- package/dist/authoring-type-constructors-D4lQ-qpj.mjs +0 -192
- package/dist/authoring-type-constructors-D4lQ-qpj.mjs.map +0 -1
- package/dist/control-adapter-CgIL9Vtx.d.mts.map +0 -1
- package/dist/types-CbwQCzXY.d.mts.map +0 -1
- package/dist/verify-sql-schema-DlAgBiT_.mjs.map +0 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { enumType } from "@prisma-next/sql-contract-ts/contract-builder";
|
|
2
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
3
|
+
//#region src/core/authoring-entity-types.ts
|
|
4
|
+
function parseQuotedString(raw) {
|
|
5
|
+
if (raw.startsWith("\"") && raw.endsWith("\"") && raw.length >= 2) return raw.slice(1, -1);
|
|
6
|
+
}
|
|
7
|
+
const sqlFamilyEntityTypes = { enum2: {
|
|
8
|
+
kind: "entity",
|
|
9
|
+
discriminator: "enum2",
|
|
10
|
+
output: { factory: (block, ctx) => {
|
|
11
|
+
const sourceId = ctx.sourceId ?? "unknown";
|
|
12
|
+
const diagnostics = ctx.diagnostics;
|
|
13
|
+
const typeAttr = block.blockAttributes.find((a) => a.name === "type");
|
|
14
|
+
if (!typeAttr) {
|
|
15
|
+
diagnostics?.push({
|
|
16
|
+
code: "PSL_ENUM2_MISSING_TYPE",
|
|
17
|
+
message: `enum2 "${block.name}" is missing a @@type("codecId") attribute`,
|
|
18
|
+
sourceId,
|
|
19
|
+
span: block.span
|
|
20
|
+
});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const rawCodecArg = typeAttr.args[0]?.value;
|
|
24
|
+
const codecId = rawCodecArg !== void 0 ? parseQuotedString(rawCodecArg) : void 0;
|
|
25
|
+
if (!codecId) {
|
|
26
|
+
diagnostics?.push({
|
|
27
|
+
code: "PSL_ENUM2_MISSING_TYPE",
|
|
28
|
+
message: `enum2 "${block.name}" @@type attribute must have a quoted codec id argument`,
|
|
29
|
+
sourceId,
|
|
30
|
+
span: typeAttr.span
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];
|
|
35
|
+
if (nativeType === void 0) {
|
|
36
|
+
const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;
|
|
37
|
+
diagnostics?.push({
|
|
38
|
+
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
39
|
+
message: `enum2 "${block.name}" @@type references unknown codec "${codecId}"`,
|
|
40
|
+
sourceId,
|
|
41
|
+
span: typeArgSpan
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const codec = ctx.codecLookup?.get(codecId);
|
|
46
|
+
if (codec === void 0) {
|
|
47
|
+
const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;
|
|
48
|
+
diagnostics?.push({
|
|
49
|
+
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
50
|
+
message: `enum2 "${block.name}" @@type codec "${codecId}" resolves in targetTypesFor but is absent from codecLookup.get`,
|
|
51
|
+
sourceId,
|
|
52
|
+
span: typeArgSpan
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
57
|
+
const members = [];
|
|
58
|
+
let memberError = false;
|
|
59
|
+
for (const [memberName, paramValue] of Object.entries(block.parameters)) {
|
|
60
|
+
let value;
|
|
61
|
+
if (paramValue.kind === "bare") try {
|
|
62
|
+
value = codec.decodeJson(memberName);
|
|
63
|
+
} catch {
|
|
64
|
+
diagnostics?.push({
|
|
65
|
+
code: "PSL_ENUM2_BARE_MEMBER_NON_STRING_CODEC",
|
|
66
|
+
message: `enum2 "${block.name}" member "${memberName}" has no value and codec "${codecId}" does not accept a bare name as input`,
|
|
67
|
+
sourceId,
|
|
68
|
+
span: paramValue.span
|
|
69
|
+
});
|
|
70
|
+
memberError = true;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
else if (paramValue.kind === "value") {
|
|
74
|
+
let jsonValue;
|
|
75
|
+
try {
|
|
76
|
+
jsonValue = JSON.parse(paramValue.raw);
|
|
77
|
+
} catch {
|
|
78
|
+
diagnostics?.push({
|
|
79
|
+
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
80
|
+
message: `enum2 "${block.name}" member "${memberName}" value "${paramValue.raw}" is not valid JSON`,
|
|
81
|
+
sourceId,
|
|
82
|
+
span: paramValue.span
|
|
83
|
+
});
|
|
84
|
+
memberError = true;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
value = codec.decodeJson(blindCast(jsonValue));
|
|
89
|
+
} catch (err) {
|
|
90
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
91
|
+
diagnostics?.push({
|
|
92
|
+
code: "PSL_EXTENSION_INVALID_VALUE",
|
|
93
|
+
message: `enum2 "${block.name}" member "${memberName}" was rejected by codec "${codecId}": ${reason}`,
|
|
94
|
+
sourceId,
|
|
95
|
+
span: paramValue.span
|
|
96
|
+
});
|
|
97
|
+
memberError = true;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
} else continue;
|
|
101
|
+
const valueKey = String(value);
|
|
102
|
+
if (seenValues.has(valueKey)) {
|
|
103
|
+
diagnostics?.push({
|
|
104
|
+
code: "PSL_ENUM2_DUPLICATE_MEMBER_VALUE",
|
|
105
|
+
message: `enum2 "${block.name}": duplicate member value "${valueKey}"`,
|
|
106
|
+
sourceId,
|
|
107
|
+
span: paramValue.span
|
|
108
|
+
});
|
|
109
|
+
memberError = true;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
seenValues.add(valueKey);
|
|
113
|
+
members.push({
|
|
114
|
+
name: memberName,
|
|
115
|
+
value
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (memberError) return void 0;
|
|
119
|
+
if (members.length === 0) {
|
|
120
|
+
diagnostics?.push({
|
|
121
|
+
code: "PSL_ENUM2_MISSING_TYPE",
|
|
122
|
+
message: `enum2 "${block.name}" must have at least one member`,
|
|
123
|
+
sourceId,
|
|
124
|
+
span: block.span
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
return enumType(block.name, {
|
|
129
|
+
codecId,
|
|
130
|
+
nativeType
|
|
131
|
+
}, ...members.map((m) => ({
|
|
132
|
+
name: m.name,
|
|
133
|
+
value: m.value
|
|
134
|
+
})));
|
|
135
|
+
} }
|
|
136
|
+
} };
|
|
137
|
+
const sqlFamilyPslBlockDescriptors = { enum2: {
|
|
138
|
+
kind: "pslBlock",
|
|
139
|
+
keyword: "enum2",
|
|
140
|
+
discriminator: "enum2",
|
|
141
|
+
name: { required: true },
|
|
142
|
+
parameters: {},
|
|
143
|
+
variadicParameters: true
|
|
144
|
+
} };
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/core/authoring-field-presets.ts
|
|
147
|
+
/**
|
|
148
|
+
* Family-level SQL authoring field presets.
|
|
149
|
+
*
|
|
150
|
+
* Only presets whose codec IDs align with the ID generator metadata live here
|
|
151
|
+
* (see `@prisma-next/ids`). These presets are target-agnostic because the
|
|
152
|
+
* generator metadata fixes their codec/native-type to `sql/char@1`
|
|
153
|
+
* (`character`) regardless of target, and the PSL interpreter lets the
|
|
154
|
+
* generator override the scalar descriptor.
|
|
155
|
+
*
|
|
156
|
+
* The `uuidString` / `id.uuidv4String` / `id.uuidv7String` presets store UUID
|
|
157
|
+
* values as `character(36)` — portable across all SQL targets. For a native
|
|
158
|
+
* Postgres `uuid` column use `uuidNative` / `id.uuidv4Native` /
|
|
159
|
+
* `id.uuidv7Native` from `@prisma-next/target-postgres`.
|
|
160
|
+
*
|
|
161
|
+
* Scalar presets that map to target-specific codecs (e.g. `text`, `int`,
|
|
162
|
+
* `boolean`, `dateTime`) are contributed by the target pack (see
|
|
163
|
+
* `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the
|
|
164
|
+
* TS callback surface and the PSL scalar surface lower to byte-identical
|
|
165
|
+
* contracts for the active target.
|
|
166
|
+
*/
|
|
167
|
+
const CHARACTER_CODEC_ID = "sql/char@1";
|
|
168
|
+
const CHARACTER_NATIVE_TYPE = "character";
|
|
169
|
+
const nanoidOptionsArgument = {
|
|
170
|
+
kind: "object",
|
|
171
|
+
optional: true,
|
|
172
|
+
properties: { size: {
|
|
173
|
+
kind: "number",
|
|
174
|
+
optional: true,
|
|
175
|
+
integer: true,
|
|
176
|
+
minimum: 2,
|
|
177
|
+
maximum: 255
|
|
178
|
+
} }
|
|
179
|
+
};
|
|
180
|
+
const sqlFamilyAuthoringFieldPresets = {
|
|
181
|
+
uuidString: {
|
|
182
|
+
kind: "fieldPreset",
|
|
183
|
+
output: {
|
|
184
|
+
codecId: CHARACTER_CODEC_ID,
|
|
185
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
186
|
+
typeParams: { length: 36 }
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
ulid: {
|
|
190
|
+
kind: "fieldPreset",
|
|
191
|
+
output: {
|
|
192
|
+
codecId: CHARACTER_CODEC_ID,
|
|
193
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
194
|
+
typeParams: { length: 26 }
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
nanoid: {
|
|
198
|
+
kind: "fieldPreset",
|
|
199
|
+
args: [nanoidOptionsArgument],
|
|
200
|
+
output: {
|
|
201
|
+
codecId: CHARACTER_CODEC_ID,
|
|
202
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
203
|
+
typeParams: { length: {
|
|
204
|
+
kind: "arg",
|
|
205
|
+
index: 0,
|
|
206
|
+
path: ["size"],
|
|
207
|
+
default: 21
|
|
208
|
+
} }
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
cuid2: {
|
|
212
|
+
kind: "fieldPreset",
|
|
213
|
+
output: {
|
|
214
|
+
codecId: CHARACTER_CODEC_ID,
|
|
215
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
216
|
+
typeParams: { length: 24 }
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
ksuid: {
|
|
220
|
+
kind: "fieldPreset",
|
|
221
|
+
output: {
|
|
222
|
+
codecId: CHARACTER_CODEC_ID,
|
|
223
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
224
|
+
typeParams: { length: 27 }
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
id: {
|
|
228
|
+
uuidv4String: {
|
|
229
|
+
kind: "fieldPreset",
|
|
230
|
+
output: {
|
|
231
|
+
codecId: CHARACTER_CODEC_ID,
|
|
232
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
233
|
+
typeParams: { length: 36 },
|
|
234
|
+
executionDefaults: { onCreate: {
|
|
235
|
+
kind: "generator",
|
|
236
|
+
id: "uuidv4"
|
|
237
|
+
} },
|
|
238
|
+
id: true
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
uuidv7String: {
|
|
242
|
+
kind: "fieldPreset",
|
|
243
|
+
output: {
|
|
244
|
+
codecId: CHARACTER_CODEC_ID,
|
|
245
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
246
|
+
typeParams: { length: 36 },
|
|
247
|
+
executionDefaults: { onCreate: {
|
|
248
|
+
kind: "generator",
|
|
249
|
+
id: "uuidv7"
|
|
250
|
+
} },
|
|
251
|
+
id: true
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
ulid: {
|
|
255
|
+
kind: "fieldPreset",
|
|
256
|
+
output: {
|
|
257
|
+
codecId: CHARACTER_CODEC_ID,
|
|
258
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
259
|
+
typeParams: { length: 26 },
|
|
260
|
+
executionDefaults: { onCreate: {
|
|
261
|
+
kind: "generator",
|
|
262
|
+
id: "ulid"
|
|
263
|
+
} },
|
|
264
|
+
id: true
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
nanoid: {
|
|
268
|
+
kind: "fieldPreset",
|
|
269
|
+
args: [nanoidOptionsArgument],
|
|
270
|
+
output: {
|
|
271
|
+
codecId: CHARACTER_CODEC_ID,
|
|
272
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
273
|
+
typeParams: { length: {
|
|
274
|
+
kind: "arg",
|
|
275
|
+
index: 0,
|
|
276
|
+
path: ["size"],
|
|
277
|
+
default: 21
|
|
278
|
+
} },
|
|
279
|
+
executionDefaults: { onCreate: {
|
|
280
|
+
kind: "generator",
|
|
281
|
+
id: "nanoid",
|
|
282
|
+
params: { size: {
|
|
283
|
+
kind: "arg",
|
|
284
|
+
index: 0,
|
|
285
|
+
path: ["size"]
|
|
286
|
+
} }
|
|
287
|
+
} },
|
|
288
|
+
id: true
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
cuid2: {
|
|
292
|
+
kind: "fieldPreset",
|
|
293
|
+
output: {
|
|
294
|
+
codecId: CHARACTER_CODEC_ID,
|
|
295
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
296
|
+
typeParams: { length: 24 },
|
|
297
|
+
executionDefaults: { onCreate: {
|
|
298
|
+
kind: "generator",
|
|
299
|
+
id: "cuid2"
|
|
300
|
+
} },
|
|
301
|
+
id: true
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
ksuid: {
|
|
305
|
+
kind: "fieldPreset",
|
|
306
|
+
output: {
|
|
307
|
+
codecId: CHARACTER_CODEC_ID,
|
|
308
|
+
nativeType: CHARACTER_NATIVE_TYPE,
|
|
309
|
+
typeParams: { length: 27 },
|
|
310
|
+
executionDefaults: { onCreate: {
|
|
311
|
+
kind: "generator",
|
|
312
|
+
id: "ksuid"
|
|
313
|
+
} },
|
|
314
|
+
id: true
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/core/authoring-type-constructors.ts
|
|
321
|
+
const sqlFamilyAuthoringTypes = { sql: { String: {
|
|
322
|
+
kind: "typeConstructor",
|
|
323
|
+
args: [{
|
|
324
|
+
kind: "number",
|
|
325
|
+
name: "length",
|
|
326
|
+
integer: true,
|
|
327
|
+
minimum: 1,
|
|
328
|
+
maximum: 10485760
|
|
329
|
+
}],
|
|
330
|
+
output: {
|
|
331
|
+
codecId: "sql/varchar@1",
|
|
332
|
+
nativeType: "character varying",
|
|
333
|
+
typeParams: { length: {
|
|
334
|
+
kind: "arg",
|
|
335
|
+
index: 0
|
|
336
|
+
} }
|
|
337
|
+
}
|
|
338
|
+
} } };
|
|
339
|
+
//#endregion
|
|
340
|
+
export { sqlFamilyPslBlockDescriptors as i, sqlFamilyAuthoringFieldPresets as n, sqlFamilyEntityTypes as r, sqlFamilyAuthoringTypes as t };
|
|
341
|
+
|
|
342
|
+
//# sourceMappingURL=authoring-type-constructors-CN60DEWb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-type-constructors-CN60DEWb.mjs","names":[],"sources":["../src/core/authoring-entity-types.ts","../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { JsonValue } from '@prisma-next/contract/types';\nimport type {\n AuthoringEntityContext,\n AuthoringEntityTypeDescriptor,\n AuthoringEntityTypeNamespace,\n AuthoringPslBlockDescriptorNamespace,\n PslExtensionBlock,\n} from '@prisma-next/framework-components/authoring';\nimport { type EnumTypeHandle, enumType } from '@prisma-next/sql-contract-ts/contract-builder';\nimport { blindCast } from '@prisma-next/utils/casts';\n\nfunction parseQuotedString(raw: string): string | undefined {\n if (raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2) {\n return raw.slice(1, -1);\n }\n return undefined;\n}\n\nexport const sqlFamilyEnum2EntityDescriptor = {\n kind: 'entity' as const,\n discriminator: 'enum2',\n output: {\n factory: (\n block: PslExtensionBlock,\n ctx: AuthoringEntityContext,\n ): EnumTypeHandle | undefined => {\n const sourceId = ctx.sourceId ?? 'unknown';\n const diagnostics = ctx.diagnostics;\n\n const typeAttr = block.blockAttributes.find((a) => a.name === 'type');\n if (!typeAttr) {\n diagnostics?.push({\n code: 'PSL_ENUM2_MISSING_TYPE',\n message: `enum2 \"${block.name}\" is missing a @@type(\"codecId\") attribute`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n const rawCodecArg = typeAttr.args[0]?.value;\n const codecId = rawCodecArg !== undefined ? parseQuotedString(rawCodecArg) : undefined;\n if (!codecId) {\n diagnostics?.push({\n code: 'PSL_ENUM2_MISSING_TYPE',\n message: `enum2 \"${block.name}\" @@type attribute must have a quoted codec id argument`,\n sourceId,\n span: typeAttr.span,\n });\n return undefined;\n }\n\n const nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];\n if (nativeType === undefined) {\n const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum2 \"${block.name}\" @@type references unknown codec \"${codecId}\"`,\n sourceId,\n span: typeArgSpan,\n });\n return undefined;\n }\n\n const codec = ctx.codecLookup?.get(codecId);\n if (codec === undefined) {\n const typeArgSpan = typeAttr.args[0]?.span ?? typeAttr.span;\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum2 \"${block.name}\" @@type codec \"${codecId}\" resolves in targetTypesFor but is absent from codecLookup.get`,\n sourceId,\n span: typeArgSpan,\n });\n return undefined;\n }\n\n const seenValues = new Set<string>();\n const members: { name: string; value: unknown }[] = [];\n let memberError = false;\n\n for (const [memberName, paramValue] of Object.entries(block.parameters)) {\n let value: unknown;\n if (paramValue.kind === 'bare') {\n try {\n value = codec.decodeJson(memberName);\n } catch {\n diagnostics?.push({\n code: 'PSL_ENUM2_BARE_MEMBER_NON_STRING_CODEC',\n message: `enum2 \"${block.name}\" member \"${memberName}\" has no value and codec \"${codecId}\" does not accept a bare name as input`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n } else if (paramValue.kind === 'value') {\n let jsonValue: unknown;\n try {\n jsonValue = JSON.parse(paramValue.raw);\n } catch {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum2 \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n try {\n value = codec.decodeJson(\n blindCast<JsonValue, 'JSON.parse returns a JsonValue-compatible value'>(jsonValue),\n );\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `enum2 \"${block.name}\" member \"${memberName}\" was rejected by codec \"${codecId}\": ${reason}`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n } else {\n continue;\n }\n\n const valueKey = String(value);\n if (seenValues.has(valueKey)) {\n diagnostics?.push({\n code: 'PSL_ENUM2_DUPLICATE_MEMBER_VALUE',\n message: `enum2 \"${block.name}\": duplicate member value \"${valueKey}\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n seenValues.add(valueKey);\n members.push({ name: memberName, value });\n }\n\n if (memberError) return undefined;\n\n if (members.length === 0) {\n diagnostics?.push({\n code: 'PSL_ENUM2_MISSING_TYPE',\n message: `enum2 \"${block.name}\" must have at least one member`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n return enumType(\n block.name,\n { codecId, nativeType },\n ...members.map((m) => ({ name: m.name, value: m.value })),\n );\n },\n },\n} satisfies AuthoringEntityTypeDescriptor;\n\nexport const sqlFamilyEntityTypes: AuthoringEntityTypeNamespace = {\n enum2: sqlFamilyEnum2EntityDescriptor,\n};\n\nexport const sqlFamilyPslBlockDescriptors = {\n enum2: {\n kind: 'pslBlock',\n keyword: 'enum2',\n discriminator: 'enum2',\n name: { required: true },\n parameters: {},\n variadicParameters: true,\n },\n} as const satisfies AuthoringPslBlockDescriptorNamespace;\n","import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\n/**\n * Family-level SQL authoring field presets.\n *\n * Only presets whose codec IDs align with the ID generator metadata live here\n * (see `@prisma-next/ids`). These presets are target-agnostic because the\n * generator metadata fixes their codec/native-type to `sql/char@1`\n * (`character`) regardless of target, and the PSL interpreter lets the\n * generator override the scalar descriptor.\n *\n * The `uuidString` / `id.uuidv4String` / `id.uuidv7String` presets store UUID\n * values as `character(36)` — portable across all SQL targets. For a native\n * Postgres `uuid` column use `uuidNative` / `id.uuidv4Native` /\n * `id.uuidv7Native` from `@prisma-next/target-postgres`.\n *\n * Scalar presets that map to target-specific codecs (e.g. `text`, `int`,\n * `boolean`, `dateTime`) are contributed by the target pack (see\n * `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the\n * TS callback surface and the PSL scalar surface lower to byte-identical\n * contracts for the active target.\n */\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n uuidString: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4String: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7String: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ulid',\n },\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'cuid2',\n },\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'ksuid',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";;;AAWA,SAAS,kBAAkB,KAAiC;CAC1D,IAAI,IAAI,WAAW,IAAG,KAAK,IAAI,SAAS,IAAG,KAAK,IAAI,UAAU,GAC5D,OAAO,IAAI,MAAM,GAAG,EAAE;AAG1B;AAoJA,MAAa,uBAAqD,EAChE,OAAO;CAlJP,MAAM;CACN,eAAe;CACf,QAAQ,EACN,UACE,OACA,QAC+B;EAC/B,MAAM,WAAW,IAAI,YAAY;EACjC,MAAM,cAAc,IAAI;EAExB,MAAM,WAAW,MAAM,gBAAgB,MAAM,MAAM,EAAE,SAAS,MAAM;EACpE,IAAI,CAAC,UAAU;GACb,aAAa,KAAK;IAChB,MAAM;IACN,SAAS,UAAU,MAAM,KAAK;IAC9B;IACA,MAAM,MAAM;GACd,CAAC;GACD;EACF;EAEA,MAAM,cAAc,SAAS,KAAK,EAAE,EAAE;EACtC,MAAM,UAAU,gBAAgB,KAAA,IAAY,kBAAkB,WAAW,IAAI,KAAA;EAC7E,IAAI,CAAC,SAAS;GACZ,aAAa,KAAK;IAChB,MAAM;IACN,SAAS,UAAU,MAAM,KAAK;IAC9B;IACA,MAAM,SAAS;GACjB,C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ACN,OAAO;MACP,MAAM,CAAC,MAAM;KACf,EACF;IACF,EACF;IACA,IAAI;GACN;EACF;EACA,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,GACV;IACA,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;EACA,OAAO;GACL,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,YAAY,EACV,QAAQ,GACV;IACA,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;CACF;AACF;;;ACpNA,MAAa,0BAA0B,EACrC,KAAK,EACH,QAAQ;CACN,MAAM;CACN,MAAM,CAAC;EAAE,MAAM;EAAU,MAAM;EAAU,SAAS;EAAM,SAAS;EAAG,SAAS;CAAS,CAAC;CACvF,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,YAAY,EACV,QAAQ;GAAE,MAAM;GAAO,OAAO;EAAE,EAClC;CACF;AACF,EACF,EACF"}
|
|
@@ -2,7 +2,7 @@ import { n as NativeTypeNormalizer, t as DefaultNormalizer } from "./verify-sql-
|
|
|
2
2
|
import { ControlAdapterInstance, ControlStack } from "@prisma-next/framework-components/control";
|
|
3
3
|
import { PostgresEnumStorageEntry, SqlControlDriverInstance, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { Contract, ContractMarkerRecord, LedgerEntryRecord } from "@prisma-next/contract/types";
|
|
5
|
-
import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext } from "@prisma-next/sql-relational-core/ast";
|
|
5
|
+
import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext, SqlExecuteRequest } from "@prisma-next/sql-relational-core/ast";
|
|
6
6
|
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
7
7
|
|
|
8
8
|
//#region src/core/control-adapter.d.ts
|
|
@@ -16,13 +16,22 @@ import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
|
16
16
|
interface Lowerer {
|
|
17
17
|
lower(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): LoweredStatement;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Extends {@link Lowerer} with async codec-routed DDL lowering. Control
|
|
21
|
+
* adapters implement this; the planner's `CreateTableCall.toOp` and
|
|
22
|
+
* `CreateSchemaCall.toOp` accept it to produce executable DDL statements
|
|
23
|
+
* with literal defaults encoded through their codec.
|
|
24
|
+
*/
|
|
25
|
+
interface ExecuteRequestLowerer extends Lowerer {
|
|
26
|
+
lowerToExecuteRequest(ast: AnyQueryAst | DdlNode, context?: LowererContext<unknown>): Promise<SqlExecuteRequest>;
|
|
27
|
+
}
|
|
19
28
|
/**
|
|
20
29
|
* SQL control adapter interface for control-plane operations.
|
|
21
30
|
* Implemented by target-specific adapters (e.g., Postgres, MySQL).
|
|
22
31
|
*
|
|
23
32
|
* @template TTarget - The target ID (e.g., 'postgres', 'mysql')
|
|
24
33
|
*/
|
|
25
|
-
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget
|
|
34
|
+
interface SqlControlAdapter<TTarget extends string = string> extends ControlAdapterInstance<'sql', TTarget>, ExecuteRequestLowerer {
|
|
26
35
|
/**
|
|
27
36
|
* Reads the contract marker for `space` from the database, returning
|
|
28
37
|
* `null` if no marker row exists for that space (or if the marker
|
|
@@ -151,16 +160,6 @@ interface SqlControlAdapter<TTarget extends string = string> extends ControlAdap
|
|
|
151
160
|
* `sign` — excludes the ledger table.
|
|
152
161
|
*/
|
|
153
162
|
bootstrapSignMarkerQueries(): readonly DdlNode[];
|
|
154
|
-
/**
|
|
155
|
-
* Lower a SQL query AST into a target-flavored `{ sql, params }` payload.
|
|
156
|
-
*
|
|
157
|
-
* Migration tooling (e.g. the `dataTransform` operation) needs to materialize
|
|
158
|
-
* SQL at emit/plan time without instantiating the runtime adapter. The control
|
|
159
|
-
* adapter's `lower` is byte-equivalent to the runtime adapter's `lower` for the
|
|
160
|
-
* same AST and contract, ensuring planned SQL matches what the runtime would
|
|
161
|
-
* emit.
|
|
162
|
-
*/
|
|
163
|
-
lower(ast: AnyQueryAst | DdlNode, context: LowererContext<unknown>): LoweredStatement;
|
|
164
163
|
}
|
|
165
164
|
/**
|
|
166
165
|
* SQL control adapter descriptor interface.
|
|
@@ -178,5 +177,5 @@ interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
|
178
177
|
create(stack: ControlStack<'sql', TTarget>): SqlControlAdapter<TTarget>;
|
|
179
178
|
}
|
|
180
179
|
//#endregion
|
|
181
|
-
export {
|
|
182
|
-
//# sourceMappingURL=control-adapter-
|
|
180
|
+
export { SqlControlAdapterDescriptor as i, Lowerer as n, SqlControlAdapter as r, ExecuteRequestLowerer as t };
|
|
181
|
+
//# sourceMappingURL=control-adapter-B_s-UMXg.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter-B_s-UMXg.d.mts","names":[],"sources":["../src/core/control-adapter.ts"],"mappings":";;;;;;;;;;AA+BA;;;;;UAAiB,OAAA;EACf,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,OAAA,EAAS,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;;;;;;;UAStD,qBAAA,SAA8B,OAAA;EAC7C,qBAAA,CACE,GAAA,EAAK,WAAA,GAAc,OAAA,EACnB,OAAA,GAAU,cAAA,YACT,OAAA,CAAQ,iBAAA;AAAA;AAb0E;AASvF;;;;;AATuF,UAsBtE,iBAAA,0CACP,sBAAA,QAA8B,OAAA,GACpC,qBAAA;EAXS;;;;;;;;;;;;;;;EA2BX,UAAA,CACE,MAAA,EAAQ,wBAAA,CAAyB,OAAA,GACjC,KAAA,WACC,OAAA,CAAQ,oBAAA;EArBI;;;;;;;EA8Bf,cAAA,CACE,MAAA,EAAQ,wBAAA,CAAyB,OAAA,IAChC,OAAA,CAAQ,WAAA,SAAoB,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WAAA;EA7EC;;;;EAoFH,4BAAA,aAAyC,OAAA;EA1EvC;;;;EAgFF,0BAAA,aAAuC,OAAA;AAAA;;;;;;;UASxB,2BAAA;EAhEb;;;;;;EAuEF,MAAA,CAAO,KAAA,EAAO,YAAA,QAAoB,OAAA,IAAW,iBAAA,CAAkB,OAAA;AAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export type { Lowerer, SqlControlAdapter, SqlControlAdapterDescriptor };
|
|
1
|
+
import { i as SqlControlAdapterDescriptor, n as Lowerer, r as SqlControlAdapter, t as ExecuteRequestLowerer } from "./control-adapter-B_s-UMXg.mjs";
|
|
2
|
+
export type { ExecuteRequestLowerer, Lowerer, SqlControlAdapter, SqlControlAdapterDescriptor };
|
package/dist/control.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-
|
|
1
|
+
import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-BR5vHjvX.mjs";
|
|
2
2
|
import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
3
3
|
import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { ColumnDefault, Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
@@ -16,7 +16,7 @@ declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlC
|
|
|
16
16
|
readonly emission: EmissionSpi;
|
|
17
17
|
readonly authoring: {
|
|
18
18
|
readonly field: {
|
|
19
|
-
readonly
|
|
19
|
+
readonly uuidString: {
|
|
20
20
|
readonly kind: "fieldPreset";
|
|
21
21
|
readonly output: {
|
|
22
22
|
readonly codecId: "sql/char@1";
|
|
@@ -85,7 +85,7 @@ declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlC
|
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
readonly id: {
|
|
88
|
-
readonly
|
|
88
|
+
readonly uuidv4String: {
|
|
89
89
|
readonly kind: "fieldPreset";
|
|
90
90
|
readonly output: {
|
|
91
91
|
readonly codecId: "sql/char@1";
|
|
@@ -102,7 +102,7 @@ declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlC
|
|
|
102
102
|
readonly id: true;
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
-
readonly
|
|
105
|
+
readonly uuidv7String: {
|
|
106
106
|
readonly kind: "fieldPreset";
|
|
107
107
|
readonly output: {
|
|
108
108
|
readonly codecId: "sql/char@1";
|
|
@@ -238,6 +238,19 @@ declare class SqlFamilyDescriptor implements ControlFamilyDescriptor<'sql', SqlC
|
|
|
238
238
|
};
|
|
239
239
|
};
|
|
240
240
|
};
|
|
241
|
+
readonly entityTypes: import("@prisma-next/framework-components/authoring").AuthoringEntityTypeNamespace;
|
|
242
|
+
readonly pslBlockDescriptors: {
|
|
243
|
+
readonly enum2: {
|
|
244
|
+
readonly kind: "pslBlock";
|
|
245
|
+
readonly keyword: "enum2";
|
|
246
|
+
readonly discriminator: "enum2";
|
|
247
|
+
readonly name: {
|
|
248
|
+
readonly required: true;
|
|
249
|
+
};
|
|
250
|
+
readonly parameters: {};
|
|
251
|
+
readonly variadicParameters: true;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
241
254
|
};
|
|
242
255
|
create<TTargetId extends string>(stack: ControlStack<'sql', TTargetId>): SqlControlFamilyInstance;
|
|
243
256
|
}
|
|
@@ -272,33 +285,22 @@ type NativeTypeExpander = (input: {
|
|
|
272
285
|
*/
|
|
273
286
|
type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;
|
|
274
287
|
/**
|
|
275
|
-
* Target-supplied callback that
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* Enum lookups (`readExistingEnumValues`) are namespace/schema-qualified so two
|
|
279
|
-
* namespaces holding an enum with the same TypeScript name (and even the same
|
|
280
|
-
* native type) resolve to distinct live-database types. The *format* of that
|
|
281
|
-
* key — and the namespace → DDL-schema resolution it depends on — is a
|
|
282
|
-
* target-specific concern (Postgres schemas; SQLite/MySQL differ), so the
|
|
283
|
-
* target injects it here as data rather than the family layer importing a
|
|
284
|
-
* concrete `ddlSchemaName`/key implementation. This keeps the family layer
|
|
285
|
-
* target-agnostic (no `@prisma-next/target-*` dependency) while the projection
|
|
286
|
-
* still emits keys that match the target's read side exactly.
|
|
287
|
-
*/
|
|
288
|
-
type EnumStorageKeyResolver = (storage: SqlStorage, namespaceId: string, nativeType: string) => string;
|
|
289
|
-
/**
|
|
290
|
-
* Resolves a `ValueSetRef` to its permitted values from the contract storage.
|
|
288
|
+
* Target-supplied callback that resolves a contract namespace to the live
|
|
289
|
+
* database schema its enums are stored under.
|
|
291
290
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
291
|
+
* The projected enum annotations are nested by schema
|
|
292
|
+
* (`storageTypes[schema][nativeType]`) so two namespaces holding an enum with
|
|
293
|
+
* the same native type resolve to distinct live-database types. Mapping a
|
|
294
|
+
* namespace to its DDL schema is target-specific (Postgres schemas;
|
|
295
|
+
* SQLite/MySQL differ), so the target injects it here rather than the family
|
|
296
|
+
* importing a concrete `ddlSchemaName`. This keeps the family layer
|
|
297
|
+
* target-agnostic while the projection nests under the same schema the
|
|
298
|
+
* target's read side (`readExistingEnumValues`) looks up.
|
|
298
299
|
*/
|
|
300
|
+
type EnumNamespaceSchemaResolver = (storage: SqlStorage, namespaceId: string) => string;
|
|
299
301
|
declare function resolveValueSetValues(ref: {
|
|
300
302
|
readonly namespaceId: string;
|
|
301
|
-
readonly
|
|
303
|
+
readonly entityName: string;
|
|
302
304
|
}, storage: SqlStorage, contextLabel: string): readonly string[];
|
|
303
305
|
/**
|
|
304
306
|
* Detects destructive changes between two contract storages.
|
|
@@ -315,13 +317,13 @@ interface ContractToSchemaIROptions {
|
|
|
315
317
|
readonly expandNativeType?: NativeTypeExpander;
|
|
316
318
|
readonly renderDefault?: DefaultRenderer;
|
|
317
319
|
/**
|
|
318
|
-
* Target-supplied resolver
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* `readExistingEnumValues` lookup. Targets without
|
|
322
|
-
* storage (SQLite) omit it; enums are absent there.
|
|
320
|
+
* Target-supplied resolver mapping a namespace to the live database schema
|
|
321
|
+
* its enums are stored under. When provided (Postgres), namespace-scoped
|
|
322
|
+
* enums are nested by that schema in `enumTypes` so the projection matches
|
|
323
|
+
* the target's `readExistingEnumValues` lookup. Targets without
|
|
324
|
+
* schema-scoped enum storage (SQLite) omit it; enums are absent there.
|
|
323
325
|
*/
|
|
324
|
-
readonly
|
|
326
|
+
readonly resolveEnumNamespaceSchema?: EnumNamespaceSchemaResolver;
|
|
325
327
|
}
|
|
326
328
|
/**
|
|
327
329
|
* Converts a `Contract` to `SqlSchemaIR`.
|
|
@@ -562,5 +564,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
|
|
|
562
564
|
//#region src/exports/control.d.ts
|
|
563
565
|
declare const _default: SqlFamilyDescriptor;
|
|
564
566
|
//#endregion
|
|
565
|
-
export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type
|
|
567
|
+
export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumNamespaceSchemaResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, 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 SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
566
568
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +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/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;
|
|
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/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/mig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