@prisma/orm-family-sql 8.0.0-rc.14-dev.15 → 8.0.0-rc.14-dev.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/contract-prisma7__provider.mjs +15 -25
  2. package/dist/contract-prisma7__provider.mjs.map +1 -1
  3. package/dist/contract-psl.d.mts +6 -24
  4. package/dist/contract-psl.d.mts.map +1 -1
  5. package/dist/contract-psl.mjs +1 -1
  6. package/dist/contract-psl__attribute-specs.d.mts +11 -3
  7. package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
  8. package/dist/contract-psl__attribute-specs.mjs +2 -2
  9. package/dist/contract-psl__provider.mjs +12 -5
  10. package/dist/contract-psl__provider.mjs.map +1 -1
  11. package/dist/{control-B8LE0HRq.mjs → control-DIVsNXHK.mjs} +4 -2
  12. package/dist/control-DIVsNXHK.mjs.map +1 -0
  13. package/dist/{control--13SHD7X.d.mts → control-nLCfcNhb.d.mts} +4 -1
  14. package/dist/control-nLCfcNhb.d.mts.map +1 -0
  15. package/dist/family.d.mts +1 -1
  16. package/dist/family.mjs +1 -1
  17. package/dist/family__control.d.mts +1 -1
  18. package/dist/family__control.mjs +1 -1
  19. package/dist/family__pack.mjs +1 -1
  20. package/dist/{interpreter-CkCfPqup-DF7bZvNM.mjs → interpreter-C8cP92FD-Co9RsuUU.mjs} +58 -1549
  21. package/dist/interpreter-C8cP92FD-Co9RsuUU.mjs.map +1 -0
  22. package/dist/psl-column-resolution-sNpXQygQ-BQr15EoR.d.mts +28 -0
  23. package/dist/psl-column-resolution-sNpXQygQ-BQr15EoR.d.mts.map +1 -0
  24. package/dist/psl-field-resolution-_o74AUE4-CKYNRnzL.mjs +1868 -0
  25. package/dist/psl-field-resolution-_o74AUE4-CKYNRnzL.mjs.map +1 -0
  26. package/package.json +18 -18
  27. package/dist/control--13SHD7X.d.mts.map +0 -1
  28. package/dist/control-B8LE0HRq.mjs.map +0 -1
  29. package/dist/interpreter-CkCfPqup-DF7bZvNM.mjs.map +0 -1
  30. package/dist/sql-attribute-specs-DxpHr9Fk-CeWmMP7y.mjs +0 -543
  31. package/dist/sql-attribute-specs-DxpHr9Fk-CeWmMP7y.mjs.map +0 -1
@@ -1,543 +0,0 @@
1
- import { isAuthoringFieldPresetDescriptor } from "@prisma/orm-framework/components/authoring";
2
- import { blindCast } from "@prisma/orm-framework/utils/casts";
3
- import { FunctionCallAst } from "@prisma/orm-framework/psl-parser/syntax";
4
- import { assertDefined } from "@prisma/orm-framework/utils/assertions";
5
- import { notOk, ok } from "@prisma/orm-framework/utils/result";
6
- import { bool, createBinder, diagnosticSource, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str, taggedLiteral } from "@prisma/orm-framework/psl-parser";
7
- //#region ../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-DxpHr9Fk.mjs
8
- function formatSupportedFunctionList(registry) {
9
- const signatures = Array.from(registry.entries()).sort(([a], [b]) => a.localeCompare(b)).flatMap(([functionName, entry]) => {
10
- const usageSignatures = entry.usageSignatures?.filter((signature) => signature.length > 0);
11
- return usageSignatures && usageSignatures.length > 0 ? usageSignatures : [`${functionName}()`];
12
- });
13
- return signatures.length > 0 ? signatures.join(", ") : "none";
14
- }
15
- /** The diagnostic message for a `dbgenerated(...)` call, which raw SQL tagged literals replaced. */
16
- function removedDbgeneratedMessage(registry) {
17
- return `Default function "dbgenerated" was removed. Write the SQL as a tagged literal: @default(sql\`<expression>\`). Supported functions: ${formatSupportedFunctionList(registry)}.`;
18
- }
19
- function lowerDefaultFunctionWithRegistry(input) {
20
- const entry = input.registry.get(input.call.fn);
21
- if (entry) {
22
- const result = entry.lower({
23
- call: input.call,
24
- context: input.context
25
- });
26
- return result.ok ? result : {
27
- ...result,
28
- kind: "external"
29
- };
30
- }
31
- const supportedFunctionList = formatSupportedFunctionList(input.registry);
32
- return {
33
- ok: false,
34
- kind: "owned",
35
- diagnostic: {
36
- code: "PSL_UNKNOWN_DEFAULT_FUNCTION",
37
- message: `Default function "${input.call.fn}" is not supported in SQL PSL provider v1. Supported functions: ${supportedFunctionList}.`,
38
- ...input.source.at(input.call.span)
39
- }
40
- };
41
- }
42
- function storageName(symbol, physicalNames) {
43
- const name = physicalNames.get(symbol);
44
- assertDefined(name, "Physical names are populated for every model and field before lowering");
45
- return name;
46
- }
47
- function getAttribute(attributes, name) {
48
- return attributes?.find((attribute) => attribute.name === name);
49
- }
50
- function formatDbAttributeMigrationMessage(attribute) {
51
- const renderedArguments = attribute.args.map((argument) => argument.kind === "named" && argument.name !== void 0 ? `${argument.name}: ${argument.value}` : argument.value).join(", ");
52
- const argumentList = attribute.args.length === 0 ? "" : `(${renderedArguments})`;
53
- const constructorName = attribute.name.slice(3);
54
- return `@${attribute.name}${argumentList} is no longer supported; use ${constructorName}${argumentList} in type position`;
55
- }
56
- function getNamedArgument(attribute, name) {
57
- const entry = attribute.args.find((arg) => arg.kind === "named" && arg.name === name);
58
- if (entry?.kind !== "named") return;
59
- return entry.value;
60
- }
61
- function mapFieldNamesToColumns(input) {
62
- const columns = [];
63
- for (const fieldName of input.fieldNames) {
64
- const field = input.model.fields[fieldName];
65
- if (field === void 0) {
66
- input.diagnostics.push({
67
- code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
68
- message: `${input.entityLabel} references unknown field "${input.model.name}.${fieldName}"`,
69
- ...input.source.at(input.span)
70
- });
71
- return;
72
- }
73
- columns.push(storageName(field, input.physicalNames));
74
- }
75
- return columns;
76
- }
77
- function buildModelAttributeCtx(input) {
78
- return {
79
- sources: input.sources,
80
- selfModel: input.selfModel,
81
- binder: input.binder,
82
- symbols: input.symbols
83
- };
84
- }
85
- function buildFieldAttributeCtx(input) {
86
- return {
87
- sources: input.sources,
88
- selfModel: input.selfModel,
89
- field: input.field,
90
- binder: input.binder,
91
- symbols: input.symbols
92
- };
93
- }
94
- function fieldPresetsAsTypeNames(namespace) {
95
- if (namespace === void 0) return {};
96
- const result = {};
97
- for (const [name, value] of Object.entries(namespace)) result[name] = isAuthoringFieldPresetDescriptor(value) ? {
98
- kind: "typeConstructor",
99
- output: { codecId: value.output.codecId }
100
- } : fieldPresetsAsTypeNames(value);
101
- return result;
102
- }
103
- function modelAttributeSpecsFrom(modelAttributesByName) {
104
- const result = Object.create(null);
105
- for (const [name, descriptor] of modelAttributesByName) result[name] = blindCast(descriptor.spec);
106
- return result;
107
- }
108
- function createSqlBinder(input) {
109
- const scalars = {};
110
- for (const [name, descriptor] of input.scalarColumnDescriptors ?? []) scalars[name] = {
111
- kind: "typeConstructor",
112
- output: { codecId: descriptor.codecId }
113
- };
114
- return createBinder({
115
- sources: input.sources,
116
- symbolTable: input.symbolTable,
117
- ...input.pslBlockDescriptors === void 0 ? {} : { pslBlockDescriptors: input.pslBlockDescriptors },
118
- typeConstructors: {
119
- ...scalars,
120
- ...fieldPresetsAsTypeNames(input.authoringContributions?.field),
121
- ...input.authoringContributions?.type ?? {}
122
- },
123
- attributeSpecs: {
124
- model: Object.assign(Object.create(null), sqlAttributeSpecs.model, input.contributedModelAttributeSpecs),
125
- field: sqlAttributeSpecs.field
126
- },
127
- controlMutationDefaults: input.controlMutationDefaults ?? {
128
- defaultFunctionRegistry: /* @__PURE__ */ new Map(),
129
- dataTypeEntries: {}
130
- },
131
- describeUnsupportedAttribute: input.describeUnsupportedAttribute
132
- });
133
- }
134
- function interpretModelAttribute(input) {
135
- const result = interpretAttribute(input.node, input.spec, buildModelAttributeCtx({
136
- symbols: input.symbols,
137
- selfModel: input.model,
138
- sources: input.sources,
139
- binder: input.binder
140
- }));
141
- if (!result.ok) {
142
- input.diagnostics.push(...result.failure);
143
- return;
144
- }
145
- return result.value;
146
- }
147
- function interpretFieldAttribute(input) {
148
- const result = interpretAttribute(input.node, input.spec, buildFieldAttributeCtx({
149
- symbols: input.symbols,
150
- selfModel: input.model,
151
- field: input.field,
152
- sources: input.sources,
153
- binder: input.binder
154
- }));
155
- if (!result.ok) {
156
- input.diagnostics.push(...result.failure);
157
- return;
158
- }
159
- return result.value;
160
- }
161
- function validateMappedName(value, ctx, attributeNode) {
162
- return value.name === "" ? [leafDiagnostic(ctx, attributeNode, "Mapped name must not be empty")] : [];
163
- }
164
- const mapModelSpec = modelAttribute("map", {
165
- documentation: "Maps this model to a database table name.",
166
- positional: [{
167
- key: "name",
168
- type: str(),
169
- documentation: "The nonempty database table name."
170
- }],
171
- refine: validateMappedName
172
- });
173
- const mapFieldSpec = fieldAttribute("map", {
174
- documentation: "Maps this field to a database column name.",
175
- positional: [{
176
- key: "name",
177
- type: str(),
178
- documentation: "The nonempty database column name."
179
- }],
180
- refine: validateMappedName
181
- });
182
- function nullLiteral() {
183
- const nullIdentifier = identifier("null", { documentation: "A null list element or nullable scalar default." });
184
- return {
185
- kind: "null",
186
- label: "null",
187
- parse: (arg, ctx) => {
188
- const result = nullIdentifier.parse(arg, ctx);
189
- return result.ok ? ok(null) : result;
190
- }
191
- };
192
- }
193
- function scalarDefaultArms(isList, registries) {
194
- const tagsByDocumentation = /* @__PURE__ */ new Map();
195
- for (const entry of Object.values(registries.dataTypeEntries)) {
196
- if (entry.written.kind !== "tag") continue;
197
- const tags = tagsByDocumentation.get(entry.documentation);
198
- if (tags === void 0) tagsByDocumentation.set(entry.documentation, [entry.written.tag]);
199
- else tags.push(entry.written.tag);
200
- }
201
- const tagArms = () => [...tagsByDocumentation].map(([documentation, tags]) => taggedLiteral(tags, { documentation }));
202
- const literal = () => oneOf(str(), numLiteral(), bool(), nullLiteral(), ...tagArms());
203
- const listArm = () => list(literal(), { label: `list of (${literal().label})` });
204
- const funcArms = [...registries.defaultFunctionRegistry.entries()].map(([name, entry]) => funcCall(name, blindCast(entry.signature)));
205
- return isList ? [
206
- listArm(),
207
- ...funcArms,
208
- ...tagArms()
209
- ] : [
210
- str(),
211
- numLiteral(),
212
- bool(),
213
- nullLiteral(),
214
- ...funcArms,
215
- ...tagArms(),
216
- listArm()
217
- ];
218
- }
219
- /**
220
- * The `@default` value arms, with a `dbgenerated(...)` call reported as removed before the arms
221
- * are tried, so the author is told what replaced it instead of being shown the list of arms.
222
- */
223
- function defaultValueArm(arms, registry) {
224
- const value = arms.length === 1 && arms[0].kind === "list" ? arms[0] : oneOf(...arms);
225
- return {
226
- ...value,
227
- parse: (arg, ctx) => FunctionCallAst.cast(arg.syntax)?.path().join(".") === "dbgenerated" ? notOk([leafDiagnostic(ctx, arg, removedDbgeneratedMessage(registry), "PSL_UNKNOWN_DEFAULT_FUNCTION")]) : value.parse(arg, ctx)
228
- };
229
- }
230
- function noEnumMember() {
231
- return {
232
- kind: "rejecting",
233
- label: "enum member",
234
- message: "Enum declares no members",
235
- parse: (arg, ctx) => notOk([leafDiagnostic(ctx, arg, "Enum declares no members")])
236
- };
237
- }
238
- function enumMemberNames(ctx) {
239
- const block = (ctx.field.typeNamespaceId === void 0 ? ctx.symbols.topLevel : ctx.symbols.topLevel.namespaces[ctx.field.typeNamespaceId])?.blocks[ctx.field.typeName];
240
- if (block === void 0 || block.keyword !== "enum") return void 0;
241
- const names = [];
242
- const seen = /* @__PURE__ */ new Set();
243
- for (const entry of block.node.entries()) {
244
- const key = entry.key()?.name();
245
- if (key === void 0 || seen.has(key)) continue;
246
- seen.add(key);
247
- names.push(key);
248
- }
249
- return names;
250
- }
251
- function enumDefaultArms(members, enumName, isList) {
252
- const [first, ...rest] = members;
253
- if (first === void 0) return [noEnumMember()];
254
- const member = (name) => identifier(name, { documentation: `The \`${name}\` member of enum \`${enumName}\`.` });
255
- if (isList) return [list(oneOf(member(first), ...rest.map(member), nullLiteral()))];
256
- return [member(first), ...rest.map(member)];
257
- }
258
- function defaultFieldSpec(ctx) {
259
- const members = enumMemberNames(ctx);
260
- return fieldAttribute("default", {
261
- documentation: "Supplies a default value when this field is omitted from a mutation.",
262
- positional: [{
263
- key: "value",
264
- type: defaultValueArm(members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members, ctx.field.typeName, ctx.field.list), ctx.controlMutationDefaults.defaultFunctionRegistry),
265
- documentation: "A literal, enum member, or registered default function compatible with this field."
266
- }]
267
- });
268
- }
269
- const idFieldSpec = fieldAttribute("id", {
270
- documentation: "Makes this field the primary key of the table.",
271
- named: { map: {
272
- type: optional(str()),
273
- documentation: "The database primary-key constraint name."
274
- } }
275
- });
276
- const uniqueFieldSpec = fieldAttribute("unique", {
277
- documentation: "Requires values in this field to be unique.",
278
- named: { map: {
279
- type: optional(str()),
280
- documentation: "The database unique-constraint name."
281
- } }
282
- });
283
- const noCheckKindArgument = () => oneOf(identifier("membership", { documentation: "Waives the generated check that values belong to the declared domain enum." }), identifier("elementNotNull", { documentation: "Waives the generated check that scalar-list elements are non-null." }));
284
- /**
285
- * `@noCheck` waives generated CHECK constraints on one column: bare for every
286
- * kind the column's shape derives, or naming concrete kinds. Two optional
287
- * positional slots cover the whole kind vocabulary; a third argument is
288
- * necessarily a duplicate and fails as excess arity.
289
- */
290
- const noCheckFieldSpec = fieldAttribute("noCheck", {
291
- documentation: "Waives generated CHECK constraints for this column. With no arguments, waives every generated kind.",
292
- positional: [{
293
- key: "first",
294
- type: optional(noCheckKindArgument()),
295
- documentation: "The first generated check kind to waive: `membership` or `elementNotNull`."
296
- }, {
297
- key: "second",
298
- type: optional(noCheckKindArgument()),
299
- documentation: "A second, distinct generated check kind to waive."
300
- }],
301
- refine: (value, ctx, attributeNode) => {
302
- if (value.first !== void 0 && value.first === value.second) return [leafDiagnostic(ctx, attributeNode, "`@noCheck` names the same kind twice")];
303
- return [];
304
- }
305
- });
306
- const idModelSpec = modelAttribute("id", {
307
- documentation: "Declares a compound primary key for this table.",
308
- positional: [{
309
- key: "fields",
310
- type: list(fieldRef(), {
311
- allowEmpty: false,
312
- unique: true
313
- }),
314
- documentation: "The ordered, nonempty list of distinct primary-key fields."
315
- }],
316
- named: { map: {
317
- type: optional(str()),
318
- documentation: "The database primary-key constraint name."
319
- } }
320
- });
321
- const uniqueModelSpec = modelAttribute("unique", {
322
- documentation: "Requires the combination of these fields to be unique.",
323
- positional: [{
324
- key: "fields",
325
- type: list(fieldRef(), {
326
- allowEmpty: false,
327
- unique: true
328
- }),
329
- documentation: "The ordered, nonempty list of distinct fields in the unique constraint."
330
- }],
331
- named: { map: {
332
- type: optional(str()),
333
- documentation: "The database unique-constraint name."
334
- } }
335
- });
336
- const PSL_INDEX_FIELDS_XOR_EXPRESSION = "PSL_INDEX_FIELDS_XOR_EXPRESSION";
337
- const PSL_INDEX_EXPRESSION_REQUIRES_NAME = "PSL_INDEX_EXPRESSION_REQUIRES_NAME";
338
- const PSL_INDEX_NAME_XOR_MAP = "PSL_INDEX_NAME_XOR_MAP";
339
- const indexModelSpec = modelAttribute("index", {
340
- documentation: "Declares a database index over fields or a SQL expression, optionally restricted by a predicate.",
341
- positional: [{
342
- key: "fields",
343
- type: optional(list(fieldRef(), {
344
- allowEmpty: false,
345
- unique: true
346
- })),
347
- documentation: "The ordered list of distinct indexed fields. Mutually exclusive with `expression`."
348
- }],
349
- named: {
350
- expression: {
351
- type: optional(str()),
352
- documentation: "The SQL index expression. Requires `name` or `map` and cannot be combined with a fields list."
353
- },
354
- where: {
355
- type: optional(str()),
356
- documentation: "The SQL predicate restricting rows included in a partial index."
357
- },
358
- unique: {
359
- type: optional(bool()),
360
- documentation: "Whether the index enforces uniqueness."
361
- },
362
- name: {
363
- type: optional(str()),
364
- documentation: "The index name. Mutually exclusive with `map`."
365
- },
366
- map: {
367
- type: optional(str()),
368
- documentation: "The database index name. Mutually exclusive with `name`."
369
- },
370
- type: {
371
- type: optional(str()),
372
- documentation: "The target-specific index access method."
373
- },
374
- options: {
375
- type: optional(record(str())),
376
- documentation: "Target-specific index options. Requires an explicit `type`."
377
- }
378
- },
379
- refine: (value, ctx, attributeNode) => {
380
- const diagnostics = [];
381
- if (value.fields === void 0 === (value.expression === void 0)) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` requires exactly one of a fields list or an `expression` argument", PSL_INDEX_FIELDS_XOR_EXPRESSION));
382
- if (value.expression !== void 0 && value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` with an `expression` argument requires a `name` or `map` argument (a default name cannot be derived from an expression)", PSL_INDEX_EXPRESSION_REQUIRES_NAME));
383
- if (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` takes at most one of `name` and `map`", PSL_INDEX_NAME_XOR_MAP));
384
- if (value.options !== void 0 && value.type === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` options argument requires a type argument"));
385
- return diagnostics;
386
- }
387
- });
388
- const PSL_CHECK_REQUIRES_NAME_OR_MAP = "PSL_CHECK_REQUIRES_NAME_OR_MAP";
389
- const PSL_CHECK_NAME_XOR_MAP = "PSL_CHECK_NAME_XOR_MAP";
390
- const PSL_CHECK_EXPRESSION_EMPTY = "PSL_CHECK_EXPRESSION_EMPTY";
391
- /**
392
- * A single-table-inheritance variant (`@@base` with no own `@@map`) shares
393
- * its base model's storage table and has no table of its own to declare a
394
- * check on — raised from {@link interpretPslDocumentToSqlContract}, not from
395
- * this spec's own `refine`, because the rule needs the model's `@@base`
396
- * declaration, which a single attribute's `refine` cannot see.
397
- */
398
- const PSL_CHECK_ON_STI_VARIANT = "PSL_CHECK_ON_STI_VARIANT";
399
- const checkModelSpec = modelAttribute("check", {
400
- documentation: "Declares a named database CHECK constraint on this table.",
401
- named: {
402
- expression: {
403
- type: str(),
404
- documentation: "The nonempty SQL predicate checked for each row."
405
- },
406
- name: {
407
- type: optional(str()),
408
- documentation: "The constraint name. Exactly one of `name` and `map` is required."
409
- },
410
- map: {
411
- type: optional(str()),
412
- documentation: "The database constraint name. Exactly one of `name` and `map` is required."
413
- }
414
- },
415
- refine: (value, ctx, attributeNode) => {
416
- const diagnostics = [];
417
- if (value.expression.trim().length === 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@check` expression must not be empty — an empty predicate is not a constraint", PSL_CHECK_EXPRESSION_EMPTY));
418
- if (value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@check` requires a `name` or `map` argument (a default name cannot be derived — a check has no column tuple to name itself after)", PSL_CHECK_REQUIRES_NAME_OR_MAP));
419
- if (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@check` takes at most one of `name` and `map`", PSL_CHECK_NAME_XOR_MAP));
420
- return diagnostics;
421
- }
422
- });
423
- const controlModelSpec = modelAttribute("control", {
424
- documentation: "Sets how schema management treats this model’s storage.",
425
- positional: [{
426
- key: "policy",
427
- documentation: "The storage control policy: `managed`, `tolerated`, `external`, or `observed`.",
428
- type: oneOf(identifier("managed", { documentation: "Verifies the declared shape strictly and allows migrations to create, alter, or drop the storage object." }), identifier("tolerated", { documentation: "Verifies declared columns while allowing extra columns. Migrations may create missing storage, but never alter or drop existing storage." }), identifier("external", { documentation: "Verifies declared storage without creating, altering, or dropping it." }), identifier("observed", { documentation: "Reports storage differences as warnings rather than verification failures and never emits migration operations." }))
429
- }]
430
- });
431
- const discriminatorModelSpec = modelAttribute("discriminator", {
432
- documentation: "Selects the field that identifies inheritance variants of this model.",
433
- positional: [{
434
- key: "field",
435
- type: fieldRef(),
436
- documentation: "The discriminator field on this model."
437
- }]
438
- });
439
- function baseModelSpec() {
440
- return modelAttribute("base", {
441
- documentation: "Declares this model as a variant of a base model.",
442
- positional: [{
443
- key: "base",
444
- type: entityRef({ kind: "model" }),
445
- documentation: "The base model to inherit from."
446
- }, {
447
- key: "value",
448
- type: str(),
449
- documentation: "The discriminator value identifying this variant."
450
- }]
451
- });
452
- }
453
- function relationAttributeSpan(ctx) {
454
- const node = getAttribute(ctx.field.attributes, "relation")?.node;
455
- if (node !== void 0) return nodePslSpan(node.syntax, ctx.sources);
456
- return ctx.field.span;
457
- }
458
- function relationInvariants(parsed, ctx) {
459
- if (parsed.fields !== void 0 !== (parsed.references !== void 0)) return [{
460
- code: "PSL_INVALID_ATTRIBUTE_SYNTAX",
461
- message: `Relation field "${ctx.selfModel.name}.${ctx.field.name}" requires fields and references arguments`,
462
- ...diagnosticSource(ctx.sources, ctx.field.node.syntax).at(relationAttributeSpan(ctx))
463
- }];
464
- return [];
465
- }
466
- const referentialActionArgument = () => oneOf(identifier("NoAction", { documentation: "Rejects a change that would violate the foreign key when the constraint is checked; checking may be deferred when supported and configured." }), identifier("Restrict", { documentation: "Rejects deleting or updating a referenced row while referencing rows remain, without deferring the check." }), identifier("Cascade", { documentation: "Propagates deletion or key updates of a referenced row to its referencing rows." }), identifier("SetNull", { documentation: "Sets referencing foreign-key fields to null when the referenced row is deleted or its key changes. The fields must allow null." }), identifier("SetDefault", { documentation: "Sets referencing foreign-key fields to their defaults when the referenced row is deleted or its key changes. The resulting values must satisfy the foreign key." }));
467
- const relationFieldSpec = fieldAttribute("relation", {
468
- documentation: "Defines the relation name, foreign-key fields, and referential actions for this relation.",
469
- positional: [{
470
- key: "name",
471
- type: optional(str()),
472
- documentation: "The relation name used to pair both sides. May also be supplied by name."
473
- }],
474
- named: {
475
- name: {
476
- type: optional(str()),
477
- documentation: "The relation name used to pair both sides. Cannot also be supplied positionally."
478
- },
479
- fields: {
480
- type: optional(list(fieldRef(), {
481
- allowEmpty: false,
482
- unique: true
483
- })),
484
- documentation: "The ordered local foreign-key fields. Must be supplied together with `references`."
485
- },
486
- references: {
487
- type: optional(list(referencedFieldRef(), {
488
- allowEmpty: false,
489
- unique: true
490
- })),
491
- documentation: "The corresponding fields on the referenced model. Must be supplied together with `fields`."
492
- },
493
- map: {
494
- type: optional(str()),
495
- documentation: "The database foreign-key constraint name."
496
- },
497
- onDelete: {
498
- type: optional(referentialActionArgument()),
499
- documentation: "The referential action when a referenced row is deleted."
500
- },
501
- onUpdate: {
502
- type: optional(referentialActionArgument()),
503
- documentation: "The referential action when a referenced key is updated."
504
- },
505
- index: {
506
- type: optional(bool()),
507
- documentation: "Whether to create an index for the relation’s foreign-key fields."
508
- }
509
- },
510
- refine: relationInvariants
511
- });
512
- function fieldSpecContext(input) {
513
- return {
514
- symbols: input.symbols,
515
- model: input.model,
516
- field: input.field,
517
- controlMutationDefaults: input.controlMutationDefaults
518
- };
519
- }
520
- const sqlAttributeSpecs = {
521
- model: {
522
- map: () => mapModelSpec,
523
- id: () => idModelSpec,
524
- unique: () => uniqueModelSpec,
525
- index: () => indexModelSpec,
526
- check: () => checkModelSpec,
527
- control: () => controlModelSpec,
528
- discriminator: () => discriminatorModelSpec,
529
- base: baseModelSpec
530
- },
531
- field: {
532
- map: () => mapFieldSpec,
533
- id: () => idFieldSpec,
534
- unique: () => uniqueFieldSpec,
535
- noCheck: () => noCheckFieldSpec,
536
- relation: () => relationFieldSpec,
537
- default: defaultFieldSpec
538
- }
539
- };
540
- //#endregion
541
- export { getAttribute as a, interpretModelAttribute as c, modelAttributeSpecsFrom as d, sqlAttributeSpecs as f, formatDbAttributeMigrationMessage as i, lowerDefaultFunctionWithRegistry as l, createSqlBinder as n, getNamedArgument as o, storageName as p, fieldSpecContext as r, interpretFieldAttribute as s, PSL_CHECK_ON_STI_VARIANT as t, mapFieldNamesToColumns as u };
542
-
543
- //# sourceMappingURL=sql-attribute-specs-DxpHr9Fk-CeWmMP7y.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sql-attribute-specs-DxpHr9Fk-CeWmMP7y.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-DxpHr9Fk.mjs"],"sourcesContent":["import { isAuthoringFieldPresetDescriptor } from \"@internal/framework-components/authoring\";\nimport { bool, createBinder, diagnosticSource, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str, taggedLiteral } from \"@internal/psl-parser\";\nimport { FunctionCallAst } from \"@internal/psl-parser/syntax\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertDefined } from \"@internal/utils/assertions\";\n//#region src/default-function-registry.ts\nfunction formatSupportedFunctionList(registry) {\n\tconst signatures = Array.from(registry.entries()).sort(([a], [b]) => a.localeCompare(b)).flatMap(([functionName, entry]) => {\n\t\tconst usageSignatures = entry.usageSignatures?.filter((signature) => signature.length > 0);\n\t\treturn usageSignatures && usageSignatures.length > 0 ? usageSignatures : [`${functionName}()`];\n\t});\n\treturn signatures.length > 0 ? signatures.join(\", \") : \"none\";\n}\n/** The diagnostic message for a `dbgenerated(...)` call, which raw SQL tagged literals replaced. */\nfunction removedDbgeneratedMessage(registry) {\n\treturn `Default function \"dbgenerated\" was removed. Write the SQL as a tagged literal: @default(sql\\`<expression>\\`). Supported functions: ${formatSupportedFunctionList(registry)}.`;\n}\nfunction lowerDefaultFunctionWithRegistry(input) {\n\tconst entry = input.registry.get(input.call.fn);\n\tif (entry) {\n\t\tconst result = entry.lower({\n\t\t\tcall: input.call,\n\t\t\tcontext: input.context\n\t\t});\n\t\treturn result.ok ? result : {\n\t\t\t...result,\n\t\t\tkind: \"external\"\n\t\t};\n\t}\n\tconst supportedFunctionList = formatSupportedFunctionList(input.registry);\n\treturn {\n\t\tok: false,\n\t\tkind: \"owned\",\n\t\tdiagnostic: {\n\t\t\tcode: \"PSL_UNKNOWN_DEFAULT_FUNCTION\",\n\t\t\tmessage: `Default function \"${input.call.fn}\" is not supported in SQL PSL provider v1. Supported functions: ${supportedFunctionList}.`,\n\t\t\t...input.source.at(input.call.span)\n\t\t}\n\t};\n}\n//#endregion\n//#region src/psl-attribute-parsing.ts\nfunction storageName(symbol, physicalNames) {\n\tconst name = physicalNames.get(symbol);\n\tassertDefined(name, \"Physical names are populated for every model and field before lowering\");\n\treturn name;\n}\nfunction getAttribute(attributes, name) {\n\treturn attributes?.find((attribute) => attribute.name === name);\n}\nfunction formatDbAttributeMigrationMessage(attribute) {\n\tconst renderedArguments = attribute.args.map((argument) => argument.kind === \"named\" && argument.name !== void 0 ? `${argument.name}: ${argument.value}` : argument.value).join(\", \");\n\tconst argumentList = attribute.args.length === 0 ? \"\" : `(${renderedArguments})`;\n\tconst constructorName = attribute.name.slice(3);\n\treturn `@${attribute.name}${argumentList} is no longer supported; use ${constructorName}${argumentList} in type position`;\n}\nfunction getNamedArgument(attribute, name) {\n\tconst entry = attribute.args.find((arg) => arg.kind === \"named\" && arg.name === name);\n\tif (entry?.kind !== \"named\") return;\n\treturn entry.value;\n}\nfunction mapFieldNamesToColumns(input) {\n\tconst columns = [];\n\tfor (const fieldName of input.fieldNames) {\n\t\tconst field = input.model.fields[fieldName];\n\t\tif (field === void 0) {\n\t\t\tinput.diagnostics.push({\n\t\t\t\tcode: \"PSL_INVALID_ATTRIBUTE_ARGUMENT\",\n\t\t\t\tmessage: `${input.entityLabel} references unknown field \"${input.model.name}.${fieldName}\"`,\n\t\t\t\t...input.source.at(input.span)\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tcolumns.push(storageName(field, input.physicalNames));\n\t}\n\treturn columns;\n}\n//#endregion\n//#region src/sql-attribute-specs.ts\nfunction buildModelAttributeCtx(input) {\n\treturn {\n\t\tsources: input.sources,\n\t\tselfModel: input.selfModel,\n\t\tbinder: input.binder,\n\t\tsymbols: input.symbols\n\t};\n}\nfunction buildFieldAttributeCtx(input) {\n\treturn {\n\t\tsources: input.sources,\n\t\tselfModel: input.selfModel,\n\t\tfield: input.field,\n\t\tbinder: input.binder,\n\t\tsymbols: input.symbols\n\t};\n}\nfunction fieldPresetsAsTypeNames(namespace) {\n\tif (namespace === void 0) return {};\n\tconst result = {};\n\tfor (const [name, value] of Object.entries(namespace)) result[name] = isAuthoringFieldPresetDescriptor(value) ? {\n\t\tkind: \"typeConstructor\",\n\t\toutput: { codecId: value.output.codecId }\n\t} : fieldPresetsAsTypeNames(value);\n\treturn result;\n}\nfunction modelAttributeSpecsFrom(modelAttributesByName) {\n\tconst result = Object.create(null);\n\tfor (const [name, descriptor] of modelAttributesByName) result[name] = blindCast(descriptor.spec);\n\treturn result;\n}\nfunction createSqlBinder(input) {\n\tconst scalars = {};\n\tfor (const [name, descriptor] of input.scalarColumnDescriptors ?? []) scalars[name] = {\n\t\tkind: \"typeConstructor\",\n\t\toutput: { codecId: descriptor.codecId }\n\t};\n\treturn createBinder({\n\t\tsources: input.sources,\n\t\tsymbolTable: input.symbolTable,\n\t\t...input.pslBlockDescriptors === void 0 ? {} : { pslBlockDescriptors: input.pslBlockDescriptors },\n\t\ttypeConstructors: {\n\t\t\t...scalars,\n\t\t\t...fieldPresetsAsTypeNames(input.authoringContributions?.field),\n\t\t\t...input.authoringContributions?.type ?? {}\n\t\t},\n\t\tattributeSpecs: {\n\t\t\tmodel: Object.assign(Object.create(null), sqlAttributeSpecs.model, input.contributedModelAttributeSpecs),\n\t\t\tfield: sqlAttributeSpecs.field\n\t\t},\n\t\tcontrolMutationDefaults: input.controlMutationDefaults ?? {\n\t\t\tdefaultFunctionRegistry: /* @__PURE__ */ new Map(),\n\t\t\tdataTypeEntries: {}\n\t\t},\n\t\tdescribeUnsupportedAttribute: input.describeUnsupportedAttribute\n\t});\n}\nfunction interpretModelAttribute(input) {\n\tconst result = interpretAttribute(input.node, input.spec, buildModelAttributeCtx({\n\t\tsymbols: input.symbols,\n\t\tselfModel: input.model,\n\t\tsources: input.sources,\n\t\tbinder: input.binder\n\t}));\n\tif (!result.ok) {\n\t\tinput.diagnostics.push(...result.failure);\n\t\treturn;\n\t}\n\treturn result.value;\n}\nfunction interpretFieldAttribute(input) {\n\tconst result = interpretAttribute(input.node, input.spec, buildFieldAttributeCtx({\n\t\tsymbols: input.symbols,\n\t\tselfModel: input.model,\n\t\tfield: input.field,\n\t\tsources: input.sources,\n\t\tbinder: input.binder\n\t}));\n\tif (!result.ok) {\n\t\tinput.diagnostics.push(...result.failure);\n\t\treturn;\n\t}\n\treturn result.value;\n}\nfunction validateMappedName(value, ctx, attributeNode) {\n\treturn value.name === \"\" ? [leafDiagnostic(ctx, attributeNode, \"Mapped name must not be empty\")] : [];\n}\nconst mapModelSpec = modelAttribute(\"map\", {\n\tdocumentation: \"Maps this model to a database table name.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str(),\n\t\tdocumentation: \"The nonempty database table name.\"\n\t}],\n\trefine: validateMappedName\n});\nconst mapFieldSpec = fieldAttribute(\"map\", {\n\tdocumentation: \"Maps this field to a database column name.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str(),\n\t\tdocumentation: \"The nonempty database column name.\"\n\t}],\n\trefine: validateMappedName\n});\nfunction nullLiteral() {\n\tconst nullIdentifier = identifier(\"null\", { documentation: \"A null list element or nullable scalar default.\" });\n\treturn {\n\t\tkind: \"null\",\n\t\tlabel: \"null\",\n\t\tparse: (arg, ctx) => {\n\t\t\tconst result = nullIdentifier.parse(arg, ctx);\n\t\t\treturn result.ok ? ok(null) : result;\n\t\t}\n\t};\n}\nfunction scalarDefaultArms(isList, registries) {\n\tconst tagsByDocumentation = /* @__PURE__ */ new Map();\n\tfor (const entry of Object.values(registries.dataTypeEntries)) {\n\t\tif (entry.written.kind !== \"tag\") continue;\n\t\tconst tags = tagsByDocumentation.get(entry.documentation);\n\t\tif (tags === void 0) tagsByDocumentation.set(entry.documentation, [entry.written.tag]);\n\t\telse tags.push(entry.written.tag);\n\t}\n\tconst tagArms = () => [...tagsByDocumentation].map(([documentation, tags]) => taggedLiteral(tags, { documentation }));\n\tconst literal = () => oneOf(str(), numLiteral(), bool(), nullLiteral(), ...tagArms());\n\tconst listArm = () => list(literal(), { label: `list of (${literal().label})` });\n\tconst funcArms = [...registries.defaultFunctionRegistry.entries()].map(([name, entry]) => funcCall(name, blindCast(entry.signature)));\n\treturn isList ? [\n\t\tlistArm(),\n\t\t...funcArms,\n\t\t...tagArms()\n\t] : [\n\t\tstr(),\n\t\tnumLiteral(),\n\t\tbool(),\n\t\tnullLiteral(),\n\t\t...funcArms,\n\t\t...tagArms(),\n\t\tlistArm()\n\t];\n}\n/**\n* The `@default` value arms, with a `dbgenerated(...)` call reported as removed before the arms\n* are tried, so the author is told what replaced it instead of being shown the list of arms.\n*/\nfunction defaultValueArm(arms, registry) {\n\tconst value = arms.length === 1 && arms[0].kind === \"list\" ? arms[0] : oneOf(...arms);\n\treturn {\n\t\t...value,\n\t\tparse: (arg, ctx) => FunctionCallAst.cast(arg.syntax)?.path().join(\".\") === \"dbgenerated\" ? notOk([leafDiagnostic(ctx, arg, removedDbgeneratedMessage(registry), \"PSL_UNKNOWN_DEFAULT_FUNCTION\")]) : value.parse(arg, ctx)\n\t};\n}\nfunction noEnumMember() {\n\treturn {\n\t\tkind: \"rejecting\",\n\t\tlabel: \"enum member\",\n\t\tmessage: \"Enum declares no members\",\n\t\tparse: (arg, ctx) => notOk([leafDiagnostic(ctx, arg, \"Enum declares no members\")])\n\t};\n}\nfunction enumMemberNames(ctx) {\n\tconst block = (ctx.field.typeNamespaceId === void 0 ? ctx.symbols.topLevel : ctx.symbols.topLevel.namespaces[ctx.field.typeNamespaceId])?.blocks[ctx.field.typeName];\n\tif (block === void 0 || block.keyword !== \"enum\") return void 0;\n\tconst names = [];\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (const entry of block.node.entries()) {\n\t\tconst key = entry.key()?.name();\n\t\tif (key === void 0 || seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tnames.push(key);\n\t}\n\treturn names;\n}\nfunction enumDefaultArms(members, enumName, isList) {\n\tconst [first, ...rest] = members;\n\tif (first === void 0) return [noEnumMember()];\n\tconst member = (name) => identifier(name, { documentation: `The \\`${name}\\` member of enum \\`${enumName}\\`.` });\n\tif (isList) return [list(oneOf(member(first), ...rest.map(member), nullLiteral()))];\n\treturn [member(first), ...rest.map(member)];\n}\nfunction defaultFieldSpec(ctx) {\n\tconst members = enumMemberNames(ctx);\n\treturn fieldAttribute(\"default\", {\n\t\tdocumentation: \"Supplies a default value when this field is omitted from a mutation.\",\n\t\tpositional: [{\n\t\t\tkey: \"value\",\n\t\t\ttype: defaultValueArm(members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members, ctx.field.typeName, ctx.field.list), ctx.controlMutationDefaults.defaultFunctionRegistry),\n\t\t\tdocumentation: \"A literal, enum member, or registered default function compatible with this field.\"\n\t\t}]\n\t});\n}\nconst idFieldSpec = fieldAttribute(\"id\", {\n\tdocumentation: \"Makes this field the primary key of the table.\",\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database primary-key constraint name.\"\n\t} }\n});\nconst uniqueFieldSpec = fieldAttribute(\"unique\", {\n\tdocumentation: \"Requires values in this field to be unique.\",\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database unique-constraint name.\"\n\t} }\n});\nconst noCheckKindArgument = () => oneOf(identifier(\"membership\", { documentation: \"Waives the generated check that values belong to the declared domain enum.\" }), identifier(\"elementNotNull\", { documentation: \"Waives the generated check that scalar-list elements are non-null.\" }));\n/**\n* `@noCheck` waives generated CHECK constraints on one column: bare for every\n* kind the column's shape derives, or naming concrete kinds. Two optional\n* positional slots cover the whole kind vocabulary; a third argument is\n* necessarily a duplicate and fails as excess arity.\n*/\nconst noCheckFieldSpec = fieldAttribute(\"noCheck\", {\n\tdocumentation: \"Waives generated CHECK constraints for this column. With no arguments, waives every generated kind.\",\n\tpositional: [{\n\t\tkey: \"first\",\n\t\ttype: optional(noCheckKindArgument()),\n\t\tdocumentation: \"The first generated check kind to waive: `membership` or `elementNotNull`.\"\n\t}, {\n\t\tkey: \"second\",\n\t\ttype: optional(noCheckKindArgument()),\n\t\tdocumentation: \"A second, distinct generated check kind to waive.\"\n\t}],\n\trefine: (value, ctx, attributeNode) => {\n\t\tif (value.first !== void 0 && value.first === value.second) return [leafDiagnostic(ctx, attributeNode, \"`@noCheck` names the same kind twice\")];\n\t\treturn [];\n\t}\n});\nconst idModelSpec = modelAttribute(\"id\", {\n\tdocumentation: \"Declares a compound primary key for this table.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t}),\n\t\tdocumentation: \"The ordered, nonempty list of distinct primary-key fields.\"\n\t}],\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database primary-key constraint name.\"\n\t} }\n});\nconst uniqueModelSpec = modelAttribute(\"unique\", {\n\tdocumentation: \"Requires the combination of these fields to be unique.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t}),\n\t\tdocumentation: \"The ordered, nonempty list of distinct fields in the unique constraint.\"\n\t}],\n\tnamed: { map: {\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The database unique-constraint name.\"\n\t} }\n});\nconst PSL_INDEX_FIELDS_XOR_EXPRESSION = \"PSL_INDEX_FIELDS_XOR_EXPRESSION\";\nconst PSL_INDEX_EXPRESSION_REQUIRES_NAME = \"PSL_INDEX_EXPRESSION_REQUIRES_NAME\";\nconst PSL_INDEX_NAME_XOR_MAP = \"PSL_INDEX_NAME_XOR_MAP\";\nconst indexModelSpec = modelAttribute(\"index\", {\n\tdocumentation: \"Declares a database index over fields or a SQL expression, optionally restricted by a predicate.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: optional(list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t})),\n\t\tdocumentation: \"The ordered list of distinct indexed fields. Mutually exclusive with `expression`.\"\n\t}],\n\tnamed: {\n\t\texpression: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The SQL index expression. Requires `name` or `map` and cannot be combined with a fields list.\"\n\t\t},\n\t\twhere: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The SQL predicate restricting rows included in a partial index.\"\n\t\t},\n\t\tunique: {\n\t\t\ttype: optional(bool()),\n\t\t\tdocumentation: \"Whether the index enforces uniqueness.\"\n\t\t},\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The index name. Mutually exclusive with `map`.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database index name. Mutually exclusive with `name`.\"\n\t\t},\n\t\ttype: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The target-specific index access method.\"\n\t\t},\n\t\toptions: {\n\t\t\ttype: optional(record(str())),\n\t\t\tdocumentation: \"Target-specific index options. Requires an explicit `type`.\"\n\t\t}\n\t},\n\trefine: (value, ctx, attributeNode) => {\n\t\tconst diagnostics = [];\n\t\tif (value.fields === void 0 === (value.expression === void 0)) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` requires exactly one of a fields list or an `expression` argument\", PSL_INDEX_FIELDS_XOR_EXPRESSION));\n\t\tif (value.expression !== void 0 && value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` with an `expression` argument requires a `name` or `map` argument (a default name cannot be derived from an expression)\", PSL_INDEX_EXPRESSION_REQUIRES_NAME));\n\t\tif (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` takes at most one of `name` and `map`\", PSL_INDEX_NAME_XOR_MAP));\n\t\tif (value.options !== void 0 && value.type === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@index` options argument requires a type argument\"));\n\t\treturn diagnostics;\n\t}\n});\nconst PSL_CHECK_REQUIRES_NAME_OR_MAP = \"PSL_CHECK_REQUIRES_NAME_OR_MAP\";\nconst PSL_CHECK_NAME_XOR_MAP = \"PSL_CHECK_NAME_XOR_MAP\";\nconst PSL_CHECK_EXPRESSION_EMPTY = \"PSL_CHECK_EXPRESSION_EMPTY\";\n/**\n* A single-table-inheritance variant (`@@base` with no own `@@map`) shares\n* its base model's storage table and has no table of its own to declare a\n* check on — raised from {@link interpretPslDocumentToSqlContract}, not from\n* this spec's own `refine`, because the rule needs the model's `@@base`\n* declaration, which a single attribute's `refine` cannot see.\n*/\nconst PSL_CHECK_ON_STI_VARIANT = \"PSL_CHECK_ON_STI_VARIANT\";\nconst checkModelSpec = modelAttribute(\"check\", {\n\tdocumentation: \"Declares a named database CHECK constraint on this table.\",\n\tnamed: {\n\t\texpression: {\n\t\t\ttype: str(),\n\t\t\tdocumentation: \"The nonempty SQL predicate checked for each row.\"\n\t\t},\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The constraint name. Exactly one of `name` and `map` is required.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database constraint name. Exactly one of `name` and `map` is required.\"\n\t\t}\n\t},\n\trefine: (value, ctx, attributeNode) => {\n\t\tconst diagnostics = [];\n\t\tif (value.expression.trim().length === 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@check` expression must not be empty — an empty predicate is not a constraint\", PSL_CHECK_EXPRESSION_EMPTY));\n\t\tif (value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@check` requires a `name` or `map` argument (a default name cannot be derived — a check has no column tuple to name itself after)\", PSL_CHECK_REQUIRES_NAME_OR_MAP));\n\t\tif (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@check` takes at most one of `name` and `map`\", PSL_CHECK_NAME_XOR_MAP));\n\t\treturn diagnostics;\n\t}\n});\nconst controlModelSpec = modelAttribute(\"control\", {\n\tdocumentation: \"Sets how schema management treats this model’s storage.\",\n\tpositional: [{\n\t\tkey: \"policy\",\n\t\tdocumentation: \"The storage control policy: `managed`, `tolerated`, `external`, or `observed`.\",\n\t\ttype: oneOf(identifier(\"managed\", { documentation: \"Verifies the declared shape strictly and allows migrations to create, alter, or drop the storage object.\" }), identifier(\"tolerated\", { documentation: \"Verifies declared columns while allowing extra columns. Migrations may create missing storage, but never alter or drop existing storage.\" }), identifier(\"external\", { documentation: \"Verifies declared storage without creating, altering, or dropping it.\" }), identifier(\"observed\", { documentation: \"Reports storage differences as warnings rather than verification failures and never emits migration operations.\" }))\n\t}]\n});\nconst discriminatorModelSpec = modelAttribute(\"discriminator\", {\n\tdocumentation: \"Selects the field that identifies inheritance variants of this model.\",\n\tpositional: [{\n\t\tkey: \"field\",\n\t\ttype: fieldRef(),\n\t\tdocumentation: \"The discriminator field on this model.\"\n\t}]\n});\nfunction baseModelSpec() {\n\treturn modelAttribute(\"base\", {\n\t\tdocumentation: \"Declares this model as a variant of a base model.\",\n\t\tpositional: [{\n\t\t\tkey: \"base\",\n\t\t\ttype: entityRef({ kind: \"model\" }),\n\t\t\tdocumentation: \"The base model to inherit from.\"\n\t\t}, {\n\t\t\tkey: \"value\",\n\t\t\ttype: str(),\n\t\t\tdocumentation: \"The discriminator value identifying this variant.\"\n\t\t}]\n\t});\n}\nfunction relationAttributeSpan(ctx) {\n\tconst node = getAttribute(ctx.field.attributes, \"relation\")?.node;\n\tif (node !== void 0) return nodePslSpan(node.syntax, ctx.sources);\n\treturn ctx.field.span;\n}\nfunction relationInvariants(parsed, ctx) {\n\tif (parsed.fields !== void 0 !== (parsed.references !== void 0)) return [{\n\t\tcode: \"PSL_INVALID_ATTRIBUTE_SYNTAX\",\n\t\tmessage: `Relation field \"${ctx.selfModel.name}.${ctx.field.name}\" requires fields and references arguments`,\n\t\t...diagnosticSource(ctx.sources, ctx.field.node.syntax).at(relationAttributeSpan(ctx))\n\t}];\n\treturn [];\n}\nconst referentialActionArgument = () => oneOf(identifier(\"NoAction\", { documentation: \"Rejects a change that would violate the foreign key when the constraint is checked; checking may be deferred when supported and configured.\" }), identifier(\"Restrict\", { documentation: \"Rejects deleting or updating a referenced row while referencing rows remain, without deferring the check.\" }), identifier(\"Cascade\", { documentation: \"Propagates deletion or key updates of a referenced row to its referencing rows.\" }), identifier(\"SetNull\", { documentation: \"Sets referencing foreign-key fields to null when the referenced row is deleted or its key changes. The fields must allow null.\" }), identifier(\"SetDefault\", { documentation: \"Sets referencing foreign-key fields to their defaults when the referenced row is deleted or its key changes. The resulting values must satisfy the foreign key.\" }));\nconst relationFieldSpec = fieldAttribute(\"relation\", {\n\tdocumentation: \"Defines the relation name, foreign-key fields, and referential actions for this relation.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: optional(str()),\n\t\tdocumentation: \"The relation name used to pair both sides. May also be supplied by name.\"\n\t}],\n\tnamed: {\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The relation name used to pair both sides. Cannot also be supplied positionally.\"\n\t\t},\n\t\tfields: {\n\t\t\ttype: optional(list(fieldRef(), {\n\t\t\t\tallowEmpty: false,\n\t\t\t\tunique: true\n\t\t\t})),\n\t\t\tdocumentation: \"The ordered local foreign-key fields. Must be supplied together with `references`.\"\n\t\t},\n\t\treferences: {\n\t\t\ttype: optional(list(referencedFieldRef(), {\n\t\t\t\tallowEmpty: false,\n\t\t\t\tunique: true\n\t\t\t})),\n\t\t\tdocumentation: \"The corresponding fields on the referenced model. Must be supplied together with `fields`.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database foreign-key constraint name.\"\n\t\t},\n\t\tonDelete: {\n\t\t\ttype: optional(referentialActionArgument()),\n\t\t\tdocumentation: \"The referential action when a referenced row is deleted.\"\n\t\t},\n\t\tonUpdate: {\n\t\t\ttype: optional(referentialActionArgument()),\n\t\t\tdocumentation: \"The referential action when a referenced key is updated.\"\n\t\t},\n\t\tindex: {\n\t\t\ttype: optional(bool()),\n\t\t\tdocumentation: \"Whether to create an index for the relation’s foreign-key fields.\"\n\t\t}\n\t},\n\trefine: relationInvariants\n});\nfunction fieldSpecContext(input) {\n\treturn {\n\t\tsymbols: input.symbols,\n\t\tmodel: input.model,\n\t\tfield: input.field,\n\t\tcontrolMutationDefaults: input.controlMutationDefaults\n\t};\n}\nconst sqlAttributeSpecs = {\n\tmodel: {\n\t\tmap: () => mapModelSpec,\n\t\tid: () => idModelSpec,\n\t\tunique: () => uniqueModelSpec,\n\t\tindex: () => indexModelSpec,\n\t\tcheck: () => checkModelSpec,\n\t\tcontrol: () => controlModelSpec,\n\t\tdiscriminator: () => discriminatorModelSpec,\n\t\tbase: baseModelSpec\n\t},\n\tfield: {\n\t\tmap: () => mapFieldSpec,\n\t\tid: () => idFieldSpec,\n\t\tunique: () => uniqueFieldSpec,\n\t\tnoCheck: () => noCheckFieldSpec,\n\t\trelation: () => relationFieldSpec,\n\t\tdefault: defaultFieldSpec\n\t}\n};\n//#endregion\nexport { interpretModelAttribute as a, formatDbAttributeMigrationMessage as c, mapFieldNamesToColumns as d, storageName as f, interpretFieldAttribute as i, getAttribute as l, createSqlBinder as n, modelAttributeSpecsFrom as o, lowerDefaultFunctionWithRegistry as p, fieldSpecContext as r, sqlAttributeSpecs as s, PSL_CHECK_ON_STI_VARIANT as t, getNamedArgument as u };\n\n//# sourceMappingURL=sql-attribute-specs-DxpHr9Fk.mjs.map"],"mappings":";;;;;;;AAOA,SAAS,4BAA4B,UAAU;CAC9C,MAAM,aAAa,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,WAAW;EAC3H,MAAM,kBAAkB,MAAM,iBAAiB,QAAQ,cAAc,UAAU,SAAS,CAAC;EACzF,OAAO,mBAAmB,gBAAgB,SAAS,IAAI,kBAAkB,CAAC,GAAG,aAAa,GAAG;CAC9F,CAAC;CACD,OAAO,WAAW,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI;AACxD;;AAEA,SAAS,0BAA0B,UAAU;CAC5C,OAAO,sIAAsI,4BAA4B,QAAQ,EAAE;AACpL;AACA,SAAS,iCAAiC,OAAO;CAChD,MAAM,QAAQ,MAAM,SAAS,IAAI,MAAM,KAAK,EAAE;CAC9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