@prisma/orm-family-sql 8.0.0-rc.11-dev.18 → 8.0.0-rc.11-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-BD-XuavC-CW5J4Z8r.mjs → authoring-type-constructors-I_mkqWGC-D9IpXjba.mjs} +10 -6
- package/dist/authoring-type-constructors-I_mkqWGC-D9IpXjba.mjs.map +1 -0
- package/dist/contract-prisma7__provider.mjs +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +1 -1
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/{control-xNkuCauS.mjs → control-DVNPQod2.mjs} +3 -3
- package/dist/{control-xNkuCauS.mjs.map → control-DVNPQod2.mjs.map} +1 -1
- package/dist/family.mjs +1 -1
- package/dist/family__control.mjs +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__pack.mjs.map +1 -1
- package/dist/{interpreter-QDw8KJeP-Bc93B8xi.mjs → interpreter-DAdB9lVL-qgJYQ9Yz.mjs} +3 -3
- package/dist/{interpreter-QDw8KJeP-Bc93B8xi.mjs.map → interpreter-DAdB9lVL-qgJYQ9Yz.mjs.map} +1 -1
- package/dist/{sql-attribute-specs-BnUIuOy5-8t7OYHpi.mjs → sql-attribute-specs-DWUP6JTq-5-fgijvM.mjs} +163 -60
- package/dist/sql-attribute-specs-DWUP6JTq-5-fgijvM.mjs.map +1 -0
- package/package.json +18 -18
- package/dist/authoring-type-constructors-BD-XuavC-CW5J4Z8r.mjs.map +0 -1
- package/dist/sql-attribute-specs-BnUIuOy5-8t7OYHpi.mjs.map +0 -1
package/dist/{sql-attribute-specs-BnUIuOy5-8t7OYHpi.mjs → sql-attribute-specs-DWUP6JTq-5-fgijvM.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
2
2
|
import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str } from "@prisma/orm-framework/psl-parser";
|
|
3
3
|
import { notOk } from "@prisma/orm-framework/utils/result";
|
|
4
|
-
//#region ../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-
|
|
4
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-DWUP6JTq.mjs
|
|
5
5
|
function findModelAttributeNode(model, name) {
|
|
6
6
|
for (const attribute of model.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;
|
|
7
7
|
}
|
|
@@ -54,16 +54,20 @@ function validateMappedName(value, ctx, attributeNode) {
|
|
|
54
54
|
return value.name === "" ? [leafDiagnostic(ctx, attributeNode, "Mapped name must not be empty")] : [];
|
|
55
55
|
}
|
|
56
56
|
const mapModelSpec = modelAttribute("map", {
|
|
57
|
+
documentation: "Maps this model to a database table name.",
|
|
57
58
|
positional: [{
|
|
58
59
|
key: "name",
|
|
59
|
-
type: str()
|
|
60
|
+
type: str(),
|
|
61
|
+
documentation: "The nonempty database table name."
|
|
60
62
|
}],
|
|
61
63
|
refine: validateMappedName
|
|
62
64
|
});
|
|
63
65
|
const mapFieldSpec = fieldAttribute("map", {
|
|
66
|
+
documentation: "Maps this field to a database column name.",
|
|
64
67
|
positional: [{
|
|
65
68
|
key: "name",
|
|
66
|
-
type: str()
|
|
69
|
+
type: str(),
|
|
70
|
+
documentation: "The nonempty database column name."
|
|
67
71
|
}],
|
|
68
72
|
refine: validateMappedName
|
|
69
73
|
});
|
|
@@ -90,21 +94,38 @@ function enumMemberNames(ctx) {
|
|
|
90
94
|
if (block === void 0 || block.keyword !== "enum") return void 0;
|
|
91
95
|
return Object.keys(block.block.parameters);
|
|
92
96
|
}
|
|
93
|
-
function enumDefaultArms(members) {
|
|
97
|
+
function enumDefaultArms(members, enumName) {
|
|
94
98
|
const [first, ...rest] = members;
|
|
95
99
|
if (first === void 0) return [noEnumMember()];
|
|
96
|
-
|
|
100
|
+
const member = (name) => identifier(name, { documentation: `The \`${name}\` member of enum \`${enumName}\`.` });
|
|
101
|
+
return [member(first), ...rest.map(member)];
|
|
97
102
|
}
|
|
98
103
|
function defaultFieldSpec(ctx) {
|
|
99
104
|
const members = enumMemberNames(ctx);
|
|
100
|
-
return fieldAttribute("default", {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
return fieldAttribute("default", {
|
|
106
|
+
documentation: "Supplies a default value when this field is omitted from a mutation.",
|
|
107
|
+
positional: [{
|
|
108
|
+
key: "value",
|
|
109
|
+
type: oneOf(...members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members, ctx.field.typeName)),
|
|
110
|
+
documentation: "A literal, enum member, or registered default function compatible with this field."
|
|
111
|
+
}]
|
|
112
|
+
});
|
|
104
113
|
}
|
|
105
|
-
const idFieldSpec = fieldAttribute("id", {
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
const idFieldSpec = fieldAttribute("id", {
|
|
115
|
+
documentation: "Makes this field the primary key of the table.",
|
|
116
|
+
named: { map: {
|
|
117
|
+
type: optional(str()),
|
|
118
|
+
documentation: "The database primary-key constraint name."
|
|
119
|
+
} }
|
|
120
|
+
});
|
|
121
|
+
const uniqueFieldSpec = fieldAttribute("unique", {
|
|
122
|
+
documentation: "Requires values in this field to be unique.",
|
|
123
|
+
named: { map: {
|
|
124
|
+
type: optional(str()),
|
|
125
|
+
documentation: "The database unique-constraint name."
|
|
126
|
+
} }
|
|
127
|
+
});
|
|
128
|
+
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." }));
|
|
108
129
|
/**
|
|
109
130
|
* `@noCheck` waives generated CHECK constraints on one column: bare for every
|
|
110
131
|
* kind the column's shape derives, or naming concrete kinds. Two optional
|
|
@@ -112,12 +133,15 @@ const noCheckKindArgument = () => oneOf(identifier("membership"), identifier("el
|
|
|
112
133
|
* necessarily a duplicate and fails as excess arity.
|
|
113
134
|
*/
|
|
114
135
|
const noCheckFieldSpec = fieldAttribute("noCheck", {
|
|
136
|
+
documentation: "Waives generated CHECK constraints for this column. With no arguments, waives every generated kind.",
|
|
115
137
|
positional: [{
|
|
116
138
|
key: "first",
|
|
117
|
-
type: optional(noCheckKindArgument())
|
|
139
|
+
type: optional(noCheckKindArgument()),
|
|
140
|
+
documentation: "The first generated check kind to waive: `membership` or `elementNotNull`."
|
|
118
141
|
}, {
|
|
119
142
|
key: "second",
|
|
120
|
-
type: optional(noCheckKindArgument())
|
|
143
|
+
type: optional(noCheckKindArgument()),
|
|
144
|
+
documentation: "A second, distinct generated check kind to waive."
|
|
121
145
|
}],
|
|
122
146
|
refine: (value, ctx, attributeNode) => {
|
|
123
147
|
if (value.first !== void 0 && value.first === value.second) return [leafDiagnostic(ctx, attributeNode, "`@noCheck` names the same kind twice")];
|
|
@@ -125,44 +149,77 @@ const noCheckFieldSpec = fieldAttribute("noCheck", {
|
|
|
125
149
|
}
|
|
126
150
|
});
|
|
127
151
|
const idModelSpec = modelAttribute("id", {
|
|
152
|
+
documentation: "Declares a compound primary key for this table.",
|
|
128
153
|
positional: [{
|
|
129
154
|
key: "fields",
|
|
130
155
|
type: list(fieldRef(), {
|
|
131
156
|
allowEmpty: false,
|
|
132
157
|
unique: true
|
|
133
|
-
})
|
|
158
|
+
}),
|
|
159
|
+
documentation: "The ordered, nonempty list of distinct primary-key fields."
|
|
134
160
|
}],
|
|
135
|
-
named: { map:
|
|
161
|
+
named: { map: {
|
|
162
|
+
type: optional(str()),
|
|
163
|
+
documentation: "The database primary-key constraint name."
|
|
164
|
+
} }
|
|
136
165
|
});
|
|
137
166
|
const uniqueModelSpec = modelAttribute("unique", {
|
|
167
|
+
documentation: "Requires the combination of these fields to be unique.",
|
|
138
168
|
positional: [{
|
|
139
169
|
key: "fields",
|
|
140
170
|
type: list(fieldRef(), {
|
|
141
171
|
allowEmpty: false,
|
|
142
172
|
unique: true
|
|
143
|
-
})
|
|
173
|
+
}),
|
|
174
|
+
documentation: "The ordered, nonempty list of distinct fields in the unique constraint."
|
|
144
175
|
}],
|
|
145
|
-
named: { map:
|
|
176
|
+
named: { map: {
|
|
177
|
+
type: optional(str()),
|
|
178
|
+
documentation: "The database unique-constraint name."
|
|
179
|
+
} }
|
|
146
180
|
});
|
|
147
181
|
const PSL_INDEX_FIELDS_XOR_EXPRESSION = "PSL_INDEX_FIELDS_XOR_EXPRESSION";
|
|
148
182
|
const PSL_INDEX_EXPRESSION_REQUIRES_NAME = "PSL_INDEX_EXPRESSION_REQUIRES_NAME";
|
|
149
183
|
const PSL_INDEX_NAME_XOR_MAP = "PSL_INDEX_NAME_XOR_MAP";
|
|
150
184
|
const indexModelSpec = modelAttribute("index", {
|
|
185
|
+
documentation: "Declares a database index over fields or a SQL expression, optionally restricted by a predicate.",
|
|
151
186
|
positional: [{
|
|
152
187
|
key: "fields",
|
|
153
188
|
type: optional(list(fieldRef(), {
|
|
154
189
|
allowEmpty: false,
|
|
155
190
|
unique: true
|
|
156
|
-
}))
|
|
191
|
+
})),
|
|
192
|
+
documentation: "The ordered list of distinct indexed fields. Mutually exclusive with `expression`."
|
|
157
193
|
}],
|
|
158
194
|
named: {
|
|
159
|
-
expression:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
195
|
+
expression: {
|
|
196
|
+
type: optional(str()),
|
|
197
|
+
documentation: "The SQL index expression. Requires `name` or `map` and cannot be combined with a fields list."
|
|
198
|
+
},
|
|
199
|
+
where: {
|
|
200
|
+
type: optional(str()),
|
|
201
|
+
documentation: "The SQL predicate restricting rows included in a partial index."
|
|
202
|
+
},
|
|
203
|
+
unique: {
|
|
204
|
+
type: optional(bool()),
|
|
205
|
+
documentation: "Whether the index enforces uniqueness."
|
|
206
|
+
},
|
|
207
|
+
name: {
|
|
208
|
+
type: optional(str()),
|
|
209
|
+
documentation: "The index name. Mutually exclusive with `map`."
|
|
210
|
+
},
|
|
211
|
+
map: {
|
|
212
|
+
type: optional(str()),
|
|
213
|
+
documentation: "The database index name. Mutually exclusive with `name`."
|
|
214
|
+
},
|
|
215
|
+
type: {
|
|
216
|
+
type: optional(str()),
|
|
217
|
+
documentation: "The target-specific index access method."
|
|
218
|
+
},
|
|
219
|
+
options: {
|
|
220
|
+
type: optional(record(str())),
|
|
221
|
+
documentation: "Target-specific index options. Requires an explicit `type`."
|
|
222
|
+
}
|
|
166
223
|
},
|
|
167
224
|
refine: (value, ctx, attributeNode) => {
|
|
168
225
|
const diagnostics = [];
|
|
@@ -185,10 +242,20 @@ const PSL_CHECK_EXPRESSION_EMPTY = "PSL_CHECK_EXPRESSION_EMPTY";
|
|
|
185
242
|
*/
|
|
186
243
|
const PSL_CHECK_ON_STI_VARIANT = "PSL_CHECK_ON_STI_VARIANT";
|
|
187
244
|
const checkModelSpec = modelAttribute("check", {
|
|
245
|
+
documentation: "Declares a named database CHECK constraint on this table.",
|
|
188
246
|
named: {
|
|
189
|
-
expression:
|
|
190
|
-
|
|
191
|
-
|
|
247
|
+
expression: {
|
|
248
|
+
type: str(),
|
|
249
|
+
documentation: "The nonempty SQL predicate checked for each row."
|
|
250
|
+
},
|
|
251
|
+
name: {
|
|
252
|
+
type: optional(str()),
|
|
253
|
+
documentation: "The constraint name. Exactly one of `name` and `map` is required."
|
|
254
|
+
},
|
|
255
|
+
map: {
|
|
256
|
+
type: optional(str()),
|
|
257
|
+
documentation: "The database constraint name. Exactly one of `name` and `map` is required."
|
|
258
|
+
}
|
|
192
259
|
},
|
|
193
260
|
refine: (value, ctx, attributeNode) => {
|
|
194
261
|
const diagnostics = [];
|
|
@@ -198,21 +265,34 @@ const checkModelSpec = modelAttribute("check", {
|
|
|
198
265
|
return diagnostics;
|
|
199
266
|
}
|
|
200
267
|
});
|
|
201
|
-
const controlModelSpec = modelAttribute("control", {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}]
|
|
268
|
+
const controlModelSpec = modelAttribute("control", {
|
|
269
|
+
documentation: "Sets how schema management treats this model’s storage.",
|
|
270
|
+
positional: [{
|
|
271
|
+
key: "policy",
|
|
272
|
+
documentation: "The storage control policy: `managed`, `tolerated`, `external`, or `observed`.",
|
|
273
|
+
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." }))
|
|
274
|
+
}]
|
|
275
|
+
});
|
|
276
|
+
const discriminatorModelSpec = modelAttribute("discriminator", {
|
|
277
|
+
documentation: "Selects the field that identifies inheritance variants of this model.",
|
|
278
|
+
positional: [{
|
|
279
|
+
key: "field",
|
|
280
|
+
type: fieldRef(),
|
|
281
|
+
documentation: "The discriminator field on this model."
|
|
282
|
+
}]
|
|
283
|
+
});
|
|
284
|
+
const baseModelSpec = modelAttribute("base", {
|
|
285
|
+
documentation: "Declares this model as a variant of a base model.",
|
|
286
|
+
positional: [{
|
|
287
|
+
key: "base",
|
|
288
|
+
type: entityRef(),
|
|
289
|
+
documentation: "The base model to inherit from."
|
|
290
|
+
}, {
|
|
291
|
+
key: "value",
|
|
292
|
+
type: str(),
|
|
293
|
+
documentation: "The discriminator value identifying this variant."
|
|
294
|
+
}]
|
|
295
|
+
});
|
|
216
296
|
function relationAttributeSpan(ctx) {
|
|
217
297
|
const node = findFieldAttributeNode(ctx.field, "relation");
|
|
218
298
|
if (node !== void 0) return nodePslSpan(node.syntax, ctx.sourceFile);
|
|
@@ -227,26 +307,49 @@ function relationInvariants(parsed, ctx) {
|
|
|
227
307
|
}];
|
|
228
308
|
return [];
|
|
229
309
|
}
|
|
230
|
-
const referentialActionArgument = () => oneOf(identifier("NoAction"), identifier("Restrict"), identifier("Cascade"), identifier("SetNull"), identifier("SetDefault"));
|
|
310
|
+
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." }));
|
|
231
311
|
const relationFieldSpec = fieldAttribute("relation", {
|
|
312
|
+
documentation: "Defines the relation name, foreign-key fields, and referential actions for this relation.",
|
|
232
313
|
positional: [{
|
|
233
314
|
key: "name",
|
|
234
|
-
type: optional(str())
|
|
315
|
+
type: optional(str()),
|
|
316
|
+
documentation: "The relation name used to pair both sides. May also be supplied by name."
|
|
235
317
|
}],
|
|
236
318
|
named: {
|
|
237
|
-
name:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
319
|
+
name: {
|
|
320
|
+
type: optional(str()),
|
|
321
|
+
documentation: "The relation name used to pair both sides. Cannot also be supplied positionally."
|
|
322
|
+
},
|
|
323
|
+
fields: {
|
|
324
|
+
type: optional(list(fieldRef(), {
|
|
325
|
+
allowEmpty: false,
|
|
326
|
+
unique: true
|
|
327
|
+
})),
|
|
328
|
+
documentation: "The ordered local foreign-key fields. Must be supplied together with `references`."
|
|
329
|
+
},
|
|
330
|
+
references: {
|
|
331
|
+
type: optional(list(referencedFieldRef(), {
|
|
332
|
+
allowEmpty: false,
|
|
333
|
+
unique: true
|
|
334
|
+
})),
|
|
335
|
+
documentation: "The corresponding fields on the referenced model. Must be supplied together with `fields`."
|
|
336
|
+
},
|
|
337
|
+
map: {
|
|
338
|
+
type: optional(str()),
|
|
339
|
+
documentation: "The database foreign-key constraint name."
|
|
340
|
+
},
|
|
341
|
+
onDelete: {
|
|
342
|
+
type: optional(referentialActionArgument()),
|
|
343
|
+
documentation: "The referential action when a referenced row is deleted."
|
|
344
|
+
},
|
|
345
|
+
onUpdate: {
|
|
346
|
+
type: optional(referentialActionArgument()),
|
|
347
|
+
documentation: "The referential action when a referenced key is updated."
|
|
348
|
+
},
|
|
349
|
+
index: {
|
|
350
|
+
type: optional(bool()),
|
|
351
|
+
documentation: "Whether to create an index for the relation’s foreign-key fields."
|
|
352
|
+
}
|
|
250
353
|
},
|
|
251
354
|
refine: relationInvariants
|
|
252
355
|
});
|
|
@@ -281,4 +384,4 @@ const sqlAttributeSpecs = {
|
|
|
281
384
|
//#endregion
|
|
282
385
|
export { interpretFieldAttribute as a, findModelAttributeNode as i, fieldSpecContext as n, interpretModelAttribute as o, findFieldAttributeNode as r, sqlAttributeSpecs as s, PSL_CHECK_ON_STI_VARIANT as t };
|
|
283
386
|
|
|
284
|
-
//# sourceMappingURL=sql-attribute-specs-
|
|
387
|
+
//# sourceMappingURL=sql-attribute-specs-DWUP6JTq-5-fgijvM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-attribute-specs-DWUP6JTq-5-fgijvM.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-DWUP6JTq.mjs"],"sourcesContent":["import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str } from \"@internal/psl-parser\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { notOk } from \"@internal/utils/result\";\n//#region src/sql-attribute-specs.ts\nfunction findModelAttributeNode(model, name) {\n\tfor (const attribute of model.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;\n}\nfunction findFieldAttributeNode(field, name) {\n\tfor (const attribute of field.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;\n}\nfunction buildModelAttributeCtx(input) {\n\treturn {\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel\n\t};\n}\nfunction buildFieldAttributeCtx(input) {\n\treturn {\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel,\n\t\tresolveReferencedModel: input.resolveReferencedModel ?? (() => void 0),\n\t\tfield: input.field\n\t};\n}\nfunction interpretModelAttribute(input) {\n\tconst result = interpretAttribute(input.node, input.spec, buildModelAttributeCtx({\n\t\tselfModel: input.model,\n\t\tsourceFile: input.sourceFile,\n\t\tsourceId: input.sourceId\n\t}));\n\tif (!result.ok) {\n\t\tfor (const failure of result.failure) input.diagnostics.push(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\tselfModel: input.model,\n\t\tfield: input.field,\n\t\tsourceFile: input.sourceFile,\n\t\tsourceId: input.sourceId,\n\t\tresolveReferencedModel: input.resolveReferencedModel\n\t}));\n\tif (!result.ok) {\n\t\tfor (const failure of result.failure) input.diagnostics.push(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 scalarDefaultArms(isList, registry) {\n\tconst literal = () => oneOf(str(), numLiteral(), bool());\n\tconst funcArms = [...registry.entries()].map(([name, entry]) => funcCall(name, blindCast(entry.signature)));\n\treturn isList ? [list(literal()), ...funcArms] : [\n\t\tstr(),\n\t\tnumLiteral(),\n\t\tbool(),\n\t\t...funcArms\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\treturn Object.keys(block.block.parameters);\n}\nfunction enumDefaultArms(members, enumName) {\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\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: oneOf(...members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members, ctx.field.typeName)),\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});\nconst baseModelSpec = modelAttribute(\"base\", {\n\tdocumentation: \"Declares this model as a variant of a base model.\",\n\tpositional: [{\n\t\tkey: \"base\",\n\t\ttype: entityRef(),\n\t\tdocumentation: \"The base model to inherit from.\"\n\t}, {\n\t\tkey: \"value\",\n\t\ttype: str(),\n\t\tdocumentation: \"The discriminator value identifying this variant.\"\n\t}]\n});\nfunction relationAttributeSpan(ctx) {\n\tconst node = findFieldAttributeNode(ctx.field, \"relation\");\n\tif (node !== void 0) return nodePslSpan(node.syntax, ctx.sourceFile);\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\tsourceId: ctx.sourceId,\n\t\tspan: 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 { interpretFieldAttribute as a, findModelAttributeNode as i, fieldSpecContext as n, interpretModelAttribute as o, findFieldAttributeNode as r, sqlAttributeSpecs as s, PSL_CHECK_ON_STI_VARIANT as t };\n\n//# sourceMappingURL=sql-attribute-specs-DWUP6JTq.mjs.map"],"mappings":";;;;AAIA,SAAS,uBAAuB,OAAO,MAAM;CAC5C,KAAK,MAAM,aAAa,MAAM,KAAK,WAAW,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE,aAAa,IAAI,MAAM,MAAM,OAAO;AAC5G;AACA,SAAS,uBAAuB,OAAO,MAAM;CAC5C,KAAK,MAAM,aAAa,MAAM,KAAK,WAAW,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE,aAAa,IAAI,MAAM,MAAM,OAAO;AAC5G;AACA,SAAS,uBAAuB,OAAO;CACtC,OAAO;EACN,UAAU,MAAM;EAChB,YAAY,MAAM;EAClB,WAAW,MAAM;CAClB;AACD;AACA,SAAS,uBAAuB,OAAO;CACtC,OAAO;EACN,UAAU,MAAM;EAChB,YAAY,MAAM;EAClB,WAAW,MAAM;EACjB,wBAAwB,MAAM,iCAAiC,KAAK;EACpE,OAAO,MAAM;CACd;AACD;AACA,SAAS,wBAAwB,OAAO;CACvC,MAAM,SAAS,mBAAmB,MAAM,MAAM,MAAM,MAAM,uBAAuB;EAChF,WAAW,MAAM;EACjB,YAAY,MAAM;EAClB,UAAU,MAAM;CACjB,CAAC,CAAC;CACF,IAAI,CAAC,OAAO,IAAI;EACf,KAAK,MAAM,WAAW,OAAO,SAAS,MAAM,YAAY,KAAK,OAAO;EACpE;CACD;CACA,OAAO,OAAO;AACf;AACA,SAAS,wBAAwB,OAAO;CACvC,MAAM,SAA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e;EACf,qBAAqB;EACrB,YAAY;CACb;CACA,OAAO;EACN,WAAW;EACX,UAAU;EACV,cAAc;EACd,eAAe;EACf,gBAAgB;EAChB,SAAS;CACV;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/orm-family-sql",
|
|
3
|
-
"version": "8.0.0-rc.11-dev.
|
|
3
|
+
"version": "8.0.0-rc.11-dev.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@prisma/orm-framework": "8.0.0-rc.11-dev.
|
|
13
|
-
"@prisma/orm-toolchain": "8.0.0-rc.11-dev.
|
|
12
|
+
"@prisma/orm-framework": "8.0.0-rc.11-dev.20",
|
|
13
|
+
"@prisma/orm-toolchain": "8.0.0-rc.11-dev.20",
|
|
14
14
|
"@standard-schema/spec": "^1.1.0",
|
|
15
15
|
"arktype": "^2.2.2",
|
|
16
16
|
"pathe": "^2.0.3",
|
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
"ts-toolbelt": "^9.6.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@internal/family-sql": "8.0.0-rc.11-dev.
|
|
22
|
-
"@internal/sql-builder": "8.0.0-rc.11-dev.
|
|
23
|
-
"@internal/sql-contract": "8.0.0-rc.11-dev.
|
|
24
|
-
"@internal/sql-contract-emitter": "8.0.0-rc.11-dev.
|
|
25
|
-
"@internal/sql-contract-prisma7": "8.0.0-rc.11-dev.
|
|
26
|
-
"@internal/sql-contract-psl": "8.0.0-rc.11-dev.
|
|
27
|
-
"@internal/sql-contract-ts": "8.0.0-rc.11-dev.
|
|
28
|
-
"@internal/sql-errors": "8.0.0-rc.11-dev.
|
|
29
|
-
"@internal/sql-operations": "8.0.0-rc.11-dev.
|
|
30
|
-
"@internal/sql-orm-client": "8.0.0-rc.11-dev.
|
|
31
|
-
"@internal/sql-relational-core": "8.0.0-rc.11-dev.
|
|
32
|
-
"@internal/sql-runtime": "8.0.0-rc.11-dev.
|
|
33
|
-
"@internal/sql-schema-ir": "8.0.0-rc.11-dev.
|
|
34
|
-
"@repo/tsconfig": "8.0.0-rc.11-dev.
|
|
35
|
-
"@repo/tsdown": "8.0.0-rc.11-dev.
|
|
21
|
+
"@internal/family-sql": "8.0.0-rc.11-dev.20",
|
|
22
|
+
"@internal/sql-builder": "8.0.0-rc.11-dev.20",
|
|
23
|
+
"@internal/sql-contract": "8.0.0-rc.11-dev.20",
|
|
24
|
+
"@internal/sql-contract-emitter": "8.0.0-rc.11-dev.20",
|
|
25
|
+
"@internal/sql-contract-prisma7": "8.0.0-rc.11-dev.20",
|
|
26
|
+
"@internal/sql-contract-psl": "8.0.0-rc.11-dev.20",
|
|
27
|
+
"@internal/sql-contract-ts": "8.0.0-rc.11-dev.20",
|
|
28
|
+
"@internal/sql-errors": "8.0.0-rc.11-dev.20",
|
|
29
|
+
"@internal/sql-operations": "8.0.0-rc.11-dev.20",
|
|
30
|
+
"@internal/sql-orm-client": "8.0.0-rc.11-dev.20",
|
|
31
|
+
"@internal/sql-relational-core": "8.0.0-rc.11-dev.20",
|
|
32
|
+
"@internal/sql-runtime": "8.0.0-rc.11-dev.20",
|
|
33
|
+
"@internal/sql-schema-ir": "8.0.0-rc.11-dev.20",
|
|
34
|
+
"@repo/tsconfig": "8.0.0-rc.11-dev.20",
|
|
35
|
+
"@repo/tsdown": "8.0.0-rc.11-dev.20",
|
|
36
36
|
"tsdown": "0.22.14",
|
|
37
37
|
"typescript": "5.9.3"
|
|
38
38
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-type-constructors-BD-XuavC-CW5J4Z8r.mjs","names":[],"sources":["../../../../2-sql/9-family/dist/authoring-type-constructors-BD-XuavC.mjs"],"sourcesContent":["import { resolveEnumCodecId } from \"@internal/framework-components/authoring\";\nimport { blockAttribute, str } from \"@internal/psl-parser\";\nimport { enumType } from \"@internal/sql-contract-ts/contract-builder\";\nimport { blindCast } from \"@internal/utils/casts\";\nconst sqlFamilyEntityTypes = { enum: {\n\tkind: \"entity\",\n\tdiscriminator: \"enum\",\n\toutput: { factory: (block, ctx) => {\n\t\tconst sourceId = ctx.sourceId ?? \"unknown\";\n\t\tconst diagnostics = ctx.diagnostics;\n\t\tconst resolved = resolveEnumCodecId(block, ctx);\n\t\tif (resolved === void 0) return;\n\t\tconst { codecId, codecSpan } = resolved;\n\t\tconst nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];\n\t\tif (nativeType === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type references unknown codec \"${codecId}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst codec = ctx.codecLookup?.get(codecId);\n\t\tif (codec === void 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\tmessage: `enum \"${block.name}\" @@type codec \"${codecId}\" resolves in targetTypesFor but is absent from codecLookup.get`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: codecSpan\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst seenValues = /* @__PURE__ */ new Set();\n\t\tconst members = [];\n\t\tlet memberError = false;\n\t\tfor (const [memberName, paramValue] of Object.entries(block.parameters)) {\n\t\t\tlet value;\n\t\t\tif (paramValue.kind === \"bare\") try {\n\t\t\t\tvalue = codec.decodeJson(memberName);\n\t\t\t} catch {\n\t\t\t\tdiagnostics?.push({\n\t\t\t\t\tcode: \"PSL_ENUM_BARE_MEMBER_NON_STRING_CODEC\",\n\t\t\t\t\tmessage: `enum \"${block.name}\" member \"${memberName}\" has no value and codec \"${codecId}\" does not accept a bare name as input`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: paramValue.span\n\t\t\t\t});\n\t\t\t\tmemberError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (paramValue.kind === \"value\") {\n\t\t\t\tlet jsonValue;\n\t\t\t\ttry {\n\t\t\t\t\tjsonValue = JSON.parse(paramValue.raw);\n\t\t\t\t} catch {\n\t\t\t\t\tdiagnostics?.push({\n\t\t\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\t\t\tmessage: `enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n\t\t\t\t\t\tsourceId,\n\t\t\t\t\t\tspan: paramValue.span\n\t\t\t\t\t});\n\t\t\t\t\tmemberError = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tvalue = codec.decodeJson(blindCast(jsonValue));\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst reason = err instanceof Error ? err.message : String(err);\n\t\t\t\t\tdiagnostics?.push({\n\t\t\t\t\t\tcode: \"PSL_EXTENSION_INVALID_VALUE\",\n\t\t\t\t\t\tmessage: `enum \"${block.name}\" member \"${memberName}\" was rejected by codec \"${codecId}\": ${reason}`,\n\t\t\t\t\t\tsourceId,\n\t\t\t\t\t\tspan: paramValue.span\n\t\t\t\t\t});\n\t\t\t\t\tmemberError = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else continue;\n\t\t\tconst valueKey = String(value);\n\t\t\tif (seenValues.has(valueKey)) {\n\t\t\t\tdiagnostics?.push({\n\t\t\t\t\tcode: \"PSL_ENUM_DUPLICATE_MEMBER_VALUE\",\n\t\t\t\t\tmessage: `enum \"${block.name}\": duplicate member value \"${valueKey}\"`,\n\t\t\t\t\tsourceId,\n\t\t\t\t\tspan: paramValue.span\n\t\t\t\t});\n\t\t\t\tmemberError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseenValues.add(valueKey);\n\t\t\tmembers.push({\n\t\t\t\tname: memberName,\n\t\t\t\tvalue\n\t\t\t});\n\t\t}\n\t\tif (memberError) return void 0;\n\t\tif (members.length === 0) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: \"PSL_ENUM_MISSING_TYPE\",\n\t\t\t\tmessage: `enum \"${block.name}\" must have at least one member`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: block.span\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\treturn enumType(block.name, {\n\t\t\tcodecId,\n\t\t\tnativeType\n\t\t}, ...members.map((m) => ({\n\t\t\tname: m.name,\n\t\t\tvalue: m.value\n\t\t})));\n\t} }\n} };\nconst enumTypeBlockAttribute = blockAttribute(\"type\", { positional: [{\n\tkey: \"codecId\",\n\ttype: str()\n}] });\nconst sqlFamilyPslBlockDescriptors = { enum: {\n\tkind: \"pslBlock\",\n\tkeyword: \"enum\",\n\tdiscriminator: \"enum\",\n\tname: { required: true },\n\tparameters: {},\n\tvariadicParameters: true,\n\tattributes: { type: () => enumTypeBlockAttribute }\n} };\n//#endregion\n//#region src/core/authoring-field-presets.ts\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 `@internal/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 `@internal/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 `@internal/target-postgres`) so the\n* TS callback surface and the PSL scalar surface lower to byte-identical\n* contracts for the active target.\n*/\nconst CHARACTER_CODEC_ID = \"sql/char@1\";\nconst CHARACTER_NATIVE_TYPE = \"character\";\nconst nanoidOptionsArgument = {\n\tkind: \"object\",\n\toptional: true,\n\tproperties: { size: {\n\t\tkind: \"number\",\n\t\toptional: true,\n\t\tinteger: true,\n\t\tminimum: 2,\n\t\tmaximum: 255\n\t} }\n};\nconst sqlFamilyAuthoringFieldPresets = {\n\tuuidString: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\ttypeParams: { length: 36 }\n\t\t}\n\t},\n\tulid: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\ttypeParams: { length: 26 }\n\t\t}\n\t},\n\tnanoid: {\n\t\tkind: \"fieldPreset\",\n\t\targs: [nanoidOptionsArgument],\n\t\toutput: {\n\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\ttypeParams: { length: {\n\t\t\t\tkind: \"arg\",\n\t\t\t\tindex: 0,\n\t\t\t\tpath: [\"size\"],\n\t\t\t\tdefault: 21\n\t\t\t} }\n\t\t}\n\t},\n\tcuid2: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\ttypeParams: { length: 24 }\n\t\t}\n\t},\n\tksuid: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\ttypeParams: { length: 27 }\n\t\t}\n\t},\n\tid: {\n\t\tuuidv4String: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\t\ttypeParams: { length: 36 },\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"uuidv4\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t},\n\t\tuuidv7String: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\t\ttypeParams: { length: 36 },\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"uuidv7\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t},\n\t\tulid: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\t\ttypeParams: { length: 26 },\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"ulid\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t},\n\t\tnanoid: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\targs: [nanoidOptionsArgument],\n\t\t\toutput: {\n\t\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\t\ttypeParams: { length: {\n\t\t\t\t\tkind: \"arg\",\n\t\t\t\t\tindex: 0,\n\t\t\t\t\tpath: [\"size\"],\n\t\t\t\t\tdefault: 21\n\t\t\t\t} },\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"nanoid\",\n\t\t\t\t\tparams: { size: {\n\t\t\t\t\t\tkind: \"arg\",\n\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\tpath: [\"size\"]\n\t\t\t\t\t} }\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t},\n\t\tcuid2: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\t\ttypeParams: { length: 24 },\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"cuid2\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t},\n\t\tksuid: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: CHARACTER_CODEC_ID,\n\t\t\t\tnativeType: CHARACTER_NATIVE_TYPE,\n\t\t\t\ttypeParams: { length: 27 },\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"ksuid\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/authoring-type-constructors.ts\nconst sqlFamilyAuthoringTypes = { sql: { String: {\n\tkind: \"typeConstructor\",\n\targs: [{\n\t\tkind: \"number\",\n\t\tname: \"length\",\n\t\tinteger: true,\n\t\tminimum: 1,\n\t\tmaximum: 10485760\n\t}],\n\toutput: {\n\t\tcodecId: \"sql/varchar@1\",\n\t\tnativeType: \"character varying\",\n\t\ttypeParams: { length: {\n\t\t\tkind: \"arg\",\n\t\t\tindex: 0\n\t\t} }\n\t}\n} } };\n//#endregion\nexport { sqlFamilyPslBlockDescriptors as i, sqlFamilyAuthoringFieldPresets as n, sqlFamilyEntityTypes as r, sqlFamilyAuthoringTypes as t };\n\n//# sourceMappingURL=authoring-type-constructors-BD-XuavC.mjs.map"],"mappings":";;;;;AAIA,MAAM,uBAAuB,EAAE,MAAM;CACpC,MAAM;CACN,eAAe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AM;GACN,MAAM,CAAC,qBAAqB;GAC5B,QAAQ;IACP,SAAS;IACT,YAAY;IACZ,YAAY,EAAE,QAAQ;KACrB,MAAM;KACN,OAAO;KACP,MAAM,CAAC,MAAM;KACb,SAAS;IACV,EAAE;IACF,mBAAmB,EAAE,UAAU;KAC9B,MAAM;KACN,IAAI;KACJ,QAAQ,EAAE,MAAM;MACf,MAAM;MACN,OAAO;MACP,MAAM,CAAC,MAAM;KACd,EAAE;IACH,EAAE;IACF,IAAI;GACL;EACD;EACA,OAAO;GACN,MAAM;GACN,QAAQ;IACP,SAAS;IACT,YAAY;IACZ,YAAY,EAAE,QAAQ,GAAG;IACzB,mBAAmB,EAAE,UAAU;KAC9B,MAAM;KACN,IAAI;IACL,EAAE;IACF,IAAI;GACL;EACD;EACA,OAAO;GACN,MAAM;GACN,QAAQ;IACP,SAAS;IACT,YAAY;IACZ,YAAY,EAAE,QAAQ,GAAG;IACzB,mBAAmB,EAAE,UAAU;KAC9B,MAAM;KACN,IAAI;IACL,EAAE;IACF,IAAI;GACL;EACD;CACD;AACD;AAGA,MAAM,0BAA0B,EAAE,KAAK,EAAE,QAAQ;CAChD,MAAM;CACN,MAAM,CAAC;EACN,MAAM;EACN,MAAM;EACN,SAAS;EACT,SAAS;EACT,SAAS;CACV,CAAC;CACD,QAAQ;EACP,SAAS;EACT,YAAY;EACZ,YAAY,EAAE,QAAQ;GACrB,MAAM;GACN,OAAO;EACR,EAAE;CACH;AACD,EAAE,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sql-attribute-specs-BnUIuOy5-8t7OYHpi.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-BnUIuOy5.mjs"],"sourcesContent":["import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, numLiteral, oneOf, optional, record, referencedFieldRef, str } from \"@internal/psl-parser\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { notOk } from \"@internal/utils/result\";\n//#region src/sql-attribute-specs.ts\nfunction findModelAttributeNode(model, name) {\n\tfor (const attribute of model.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;\n}\nfunction findFieldAttributeNode(field, name) {\n\tfor (const attribute of field.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;\n}\nfunction buildModelAttributeCtx(input) {\n\treturn {\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel\n\t};\n}\nfunction buildFieldAttributeCtx(input) {\n\treturn {\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel,\n\t\tresolveReferencedModel: input.resolveReferencedModel ?? (() => void 0),\n\t\tfield: input.field\n\t};\n}\nfunction interpretModelAttribute(input) {\n\tconst result = interpretAttribute(input.node, input.spec, buildModelAttributeCtx({\n\t\tselfModel: input.model,\n\t\tsourceFile: input.sourceFile,\n\t\tsourceId: input.sourceId\n\t}));\n\tif (!result.ok) {\n\t\tfor (const failure of result.failure) input.diagnostics.push(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\tselfModel: input.model,\n\t\tfield: input.field,\n\t\tsourceFile: input.sourceFile,\n\t\tsourceId: input.sourceId,\n\t\tresolveReferencedModel: input.resolveReferencedModel\n\t}));\n\tif (!result.ok) {\n\t\tfor (const failure of result.failure) input.diagnostics.push(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\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str()\n\t}],\n\trefine: validateMappedName\n});\nconst mapFieldSpec = fieldAttribute(\"map\", {\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str()\n\t}],\n\trefine: validateMappedName\n});\nfunction scalarDefaultArms(isList, registry) {\n\tconst literal = () => oneOf(str(), numLiteral(), bool());\n\tconst funcArms = [...registry.entries()].map(([name, entry]) => funcCall(name, blindCast(entry.signature)));\n\treturn isList ? [list(literal()), ...funcArms] : [\n\t\tstr(),\n\t\tnumLiteral(),\n\t\tbool(),\n\t\t...funcArms\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\treturn Object.keys(block.block.parameters);\n}\nfunction enumDefaultArms(members) {\n\tconst [first, ...rest] = members;\n\tif (first === void 0) return [noEnumMember()];\n\treturn [identifier(first), ...rest.map((name) => identifier(name))];\n}\nfunction defaultFieldSpec(ctx) {\n\tconst members = enumMemberNames(ctx);\n\treturn fieldAttribute(\"default\", { positional: [{\n\t\tkey: \"value\",\n\t\ttype: oneOf(...members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members))\n\t}] });\n}\nconst idFieldSpec = fieldAttribute(\"id\", { named: { map: optional(str()) } });\nconst uniqueFieldSpec = fieldAttribute(\"unique\", { named: { map: optional(str()) } });\nconst noCheckKindArgument = () => oneOf(identifier(\"membership\"), identifier(\"elementNotNull\"));\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\tpositional: [{\n\t\tkey: \"first\",\n\t\ttype: optional(noCheckKindArgument())\n\t}, {\n\t\tkey: \"second\",\n\t\ttype: optional(noCheckKindArgument())\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\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}],\n\tnamed: { map: optional(str()) }\n});\nconst uniqueModelSpec = modelAttribute(\"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}],\n\tnamed: { map: optional(str()) }\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\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}],\n\tnamed: {\n\t\texpression: optional(str()),\n\t\twhere: optional(str()),\n\t\tunique: optional(bool()),\n\t\tname: optional(str()),\n\t\tmap: optional(str()),\n\t\ttype: optional(str()),\n\t\toptions: optional(record(str()))\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\tnamed: {\n\t\texpression: str(),\n\t\tname: optional(str()),\n\t\tmap: optional(str())\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\", { positional: [{\n\tkey: \"policy\",\n\ttype: oneOf(identifier(\"managed\"), identifier(\"tolerated\"), identifier(\"external\"), identifier(\"observed\"))\n}] });\nconst discriminatorModelSpec = modelAttribute(\"discriminator\", { positional: [{\n\tkey: \"field\",\n\ttype: fieldRef()\n}] });\nconst baseModelSpec = modelAttribute(\"base\", { positional: [{\n\tkey: \"base\",\n\ttype: entityRef()\n}, {\n\tkey: \"value\",\n\ttype: str()\n}] });\nfunction relationAttributeSpan(ctx) {\n\tconst node = findFieldAttributeNode(ctx.field, \"relation\");\n\tif (node !== void 0) return nodePslSpan(node.syntax, ctx.sourceFile);\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\tsourceId: ctx.sourceId,\n\t\tspan: relationAttributeSpan(ctx)\n\t}];\n\treturn [];\n}\nconst referentialActionArgument = () => oneOf(identifier(\"NoAction\"), identifier(\"Restrict\"), identifier(\"Cascade\"), identifier(\"SetNull\"), identifier(\"SetDefault\"));\nconst relationFieldSpec = fieldAttribute(\"relation\", {\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: optional(str())\n\t}],\n\tnamed: {\n\t\tname: optional(str()),\n\t\tfields: optional(list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t})),\n\t\treferences: optional(list(referencedFieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t})),\n\t\tmap: optional(str()),\n\t\tonDelete: optional(referentialActionArgument()),\n\t\tonUpdate: optional(referentialActionArgument()),\n\t\tindex: optional(bool())\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 { interpretFieldAttribute as a, findModelAttributeNode as i, fieldSpecContext as n, interpretModelAttribute as o, findFieldAttributeNode as r, sqlAttributeSpecs as s, PSL_CHECK_ON_STI_VARIANT as t };\n\n//# sourceMappingURL=sql-attribute-specs-BnUIuOy5.mjs.map"],"mappings":";;;;AAIA,SAAS,uBAAuB,OAAO,MAAM;CAC5C,KAAK,MAAM,aAAa,MAAM,KAAK,WAAW,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE,aAAa,IAAI,MAAM,MAAM,OAAO;AAC5G;AACA,SAAS,uBAAuB,OAAO,MAAM;CAC5C,KAAK,MAAM,aAAa,MAAM,KAAK,WAAW,GAAG,IAAI,UAAU,KAAK,CAAC,EAAE,aAAa,IAAI,MAAM,MAAM,OAAO;AAC5G;AACA,SAAS,uBAAuB,OAAO;CACtC,OAAO;EACN,UAAU,MAAM;EAChB,YAAY,MAAM;EAClB,WAAW,MAAM;CAClB;AACD;AAC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