@prisma/orm-family-sql 8.0.0-rc.8-dev.17 → 8.0.0-rc.8-dev.18
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/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.d.mts +77 -0
- package/dist/contract-psl__attribute-specs.d.mts.map +1 -0
- package/dist/contract-psl__attribute-specs.mjs +2 -0
- package/dist/contract-psl__provider.mjs +1 -1
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/{control-CyOPr5No.d.mts → control-CCQP4VFK.d.mts} +69 -1
- package/dist/control-CCQP4VFK.d.mts.map +1 -0
- package/dist/{control-CK4QOli_.mjs → control-DheONC4E.mjs} +4 -2
- package/dist/control-DheONC4E.mjs.map +1 -0
- package/dist/family.d.mts +2 -1
- package/dist/family.mjs +1 -1
- package/dist/family__control.d.mts +1 -1
- package/dist/family__control.mjs +1 -1
- package/dist/family__pack.d.mts +2 -249
- package/dist/family__pack.mjs +3 -1
- package/dist/family__pack.mjs.map +1 -1
- package/dist/index-DrcrDbOI-BlARY_6q.d.mts +536 -0
- package/dist/index-DrcrDbOI-BlARY_6q.d.mts.map +1 -0
- package/dist/{interpreter-RTglKUpM-B-iOLic9.mjs → interpreter-DQIdQxL1-DyNYhhep.mjs} +67 -296
- package/dist/interpreter-DQIdQxL1-DyNYhhep.mjs.map +1 -0
- package/dist/pack-Chia4J0l.d.mts +317 -0
- package/dist/pack-Chia4J0l.d.mts.map +1 -0
- package/dist/sql-attribute-specs-Cr8_u9ma-ENY2C_np.mjs +281 -0
- package/dist/sql-attribute-specs-Cr8_u9ma-ENY2C_np.mjs.map +1 -0
- package/package.json +18 -17
- package/dist/control-CK4QOli_.mjs.map +0 -1
- package/dist/control-CyOPr5No.d.mts.map +0 -1
- package/dist/family__pack.d.mts.map +0 -1
- package/dist/interpreter-RTglKUpM-B-iOLic9.mjs.map +0 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { n as FieldAttributeSpecContext, r as TypedFuncCall, t as AttributeSpec } from "./index-DrcrDbOI-BlARY_6q.mjs";
|
|
2
|
+
//#region ../../../2-sql/9-family/dist/pack.d.mts
|
|
3
|
+
//#region src/exports/pack.d.ts
|
|
4
|
+
declare const sqlFamilyPack: {
|
|
5
|
+
readonly kind: "family";
|
|
6
|
+
readonly id: "sql";
|
|
7
|
+
readonly familyId: "sql";
|
|
8
|
+
readonly version: "0.0.1";
|
|
9
|
+
readonly authoring: {
|
|
10
|
+
readonly field: {
|
|
11
|
+
readonly uuidString: {
|
|
12
|
+
readonly kind: "fieldPreset";
|
|
13
|
+
readonly output: {
|
|
14
|
+
readonly codecId: "sql/char@1";
|
|
15
|
+
readonly nativeType: "character";
|
|
16
|
+
readonly typeParams: {
|
|
17
|
+
readonly length: 36;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly ulid: {
|
|
22
|
+
readonly kind: "fieldPreset";
|
|
23
|
+
readonly output: {
|
|
24
|
+
readonly codecId: "sql/char@1";
|
|
25
|
+
readonly nativeType: "character";
|
|
26
|
+
readonly typeParams: {
|
|
27
|
+
readonly length: 26;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly nanoid: {
|
|
32
|
+
readonly kind: "fieldPreset";
|
|
33
|
+
readonly args: readonly [{
|
|
34
|
+
readonly kind: "object";
|
|
35
|
+
readonly optional: true;
|
|
36
|
+
readonly properties: {
|
|
37
|
+
readonly size: {
|
|
38
|
+
readonly kind: "number";
|
|
39
|
+
readonly optional: true;
|
|
40
|
+
readonly integer: true;
|
|
41
|
+
readonly minimum: 2;
|
|
42
|
+
readonly maximum: 255;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}];
|
|
46
|
+
readonly output: {
|
|
47
|
+
readonly codecId: "sql/char@1";
|
|
48
|
+
readonly nativeType: "character";
|
|
49
|
+
readonly typeParams: {
|
|
50
|
+
readonly length: {
|
|
51
|
+
readonly kind: "arg";
|
|
52
|
+
readonly index: 0;
|
|
53
|
+
readonly path: readonly ["size"];
|
|
54
|
+
readonly default: 21;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
readonly cuid2: {
|
|
60
|
+
readonly kind: "fieldPreset";
|
|
61
|
+
readonly output: {
|
|
62
|
+
readonly codecId: "sql/char@1";
|
|
63
|
+
readonly nativeType: "character";
|
|
64
|
+
readonly typeParams: {
|
|
65
|
+
readonly length: 24;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly ksuid: {
|
|
70
|
+
readonly kind: "fieldPreset";
|
|
71
|
+
readonly output: {
|
|
72
|
+
readonly codecId: "sql/char@1";
|
|
73
|
+
readonly nativeType: "character";
|
|
74
|
+
readonly typeParams: {
|
|
75
|
+
readonly length: 27;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readonly id: {
|
|
80
|
+
readonly uuidv4String: {
|
|
81
|
+
readonly kind: "fieldPreset";
|
|
82
|
+
readonly output: {
|
|
83
|
+
readonly codecId: "sql/char@1";
|
|
84
|
+
readonly nativeType: "character";
|
|
85
|
+
readonly typeParams: {
|
|
86
|
+
readonly length: 36;
|
|
87
|
+
};
|
|
88
|
+
readonly executionDefaults: {
|
|
89
|
+
readonly onCreate: {
|
|
90
|
+
readonly kind: "generator";
|
|
91
|
+
readonly id: "uuidv4";
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
readonly id: true;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
readonly uuidv7String: {
|
|
98
|
+
readonly kind: "fieldPreset";
|
|
99
|
+
readonly output: {
|
|
100
|
+
readonly codecId: "sql/char@1";
|
|
101
|
+
readonly nativeType: "character";
|
|
102
|
+
readonly typeParams: {
|
|
103
|
+
readonly length: 36;
|
|
104
|
+
};
|
|
105
|
+
readonly executionDefaults: {
|
|
106
|
+
readonly onCreate: {
|
|
107
|
+
readonly kind: "generator";
|
|
108
|
+
readonly id: "uuidv7";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
readonly id: true;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
readonly ulid: {
|
|
115
|
+
readonly kind: "fieldPreset";
|
|
116
|
+
readonly output: {
|
|
117
|
+
readonly codecId: "sql/char@1";
|
|
118
|
+
readonly nativeType: "character";
|
|
119
|
+
readonly typeParams: {
|
|
120
|
+
readonly length: 26;
|
|
121
|
+
};
|
|
122
|
+
readonly executionDefaults: {
|
|
123
|
+
readonly onCreate: {
|
|
124
|
+
readonly kind: "generator";
|
|
125
|
+
readonly id: "ulid";
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
readonly id: true;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
readonly nanoid: {
|
|
132
|
+
readonly kind: "fieldPreset";
|
|
133
|
+
readonly args: readonly [{
|
|
134
|
+
readonly kind: "object";
|
|
135
|
+
readonly optional: true;
|
|
136
|
+
readonly properties: {
|
|
137
|
+
readonly size: {
|
|
138
|
+
readonly kind: "number";
|
|
139
|
+
readonly optional: true;
|
|
140
|
+
readonly integer: true;
|
|
141
|
+
readonly minimum: 2;
|
|
142
|
+
readonly maximum: 255;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
}];
|
|
146
|
+
readonly output: {
|
|
147
|
+
readonly codecId: "sql/char@1";
|
|
148
|
+
readonly nativeType: "character";
|
|
149
|
+
readonly typeParams: {
|
|
150
|
+
readonly length: {
|
|
151
|
+
readonly kind: "arg";
|
|
152
|
+
readonly index: 0;
|
|
153
|
+
readonly path: readonly ["size"];
|
|
154
|
+
readonly default: 21;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
readonly executionDefaults: {
|
|
158
|
+
readonly onCreate: {
|
|
159
|
+
readonly kind: "generator";
|
|
160
|
+
readonly id: "nanoid";
|
|
161
|
+
readonly params: {
|
|
162
|
+
readonly size: {
|
|
163
|
+
readonly kind: "arg";
|
|
164
|
+
readonly index: 0;
|
|
165
|
+
readonly path: readonly ["size"];
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
readonly id: true;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
readonly cuid2: {
|
|
174
|
+
readonly kind: "fieldPreset";
|
|
175
|
+
readonly output: {
|
|
176
|
+
readonly codecId: "sql/char@1";
|
|
177
|
+
readonly nativeType: "character";
|
|
178
|
+
readonly typeParams: {
|
|
179
|
+
readonly length: 24;
|
|
180
|
+
};
|
|
181
|
+
readonly executionDefaults: {
|
|
182
|
+
readonly onCreate: {
|
|
183
|
+
readonly kind: "generator";
|
|
184
|
+
readonly id: "cuid2";
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
readonly id: true;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
readonly ksuid: {
|
|
191
|
+
readonly kind: "fieldPreset";
|
|
192
|
+
readonly output: {
|
|
193
|
+
readonly codecId: "sql/char@1";
|
|
194
|
+
readonly nativeType: "character";
|
|
195
|
+
readonly typeParams: {
|
|
196
|
+
readonly length: 27;
|
|
197
|
+
};
|
|
198
|
+
readonly executionDefaults: {
|
|
199
|
+
readonly onCreate: {
|
|
200
|
+
readonly kind: "generator";
|
|
201
|
+
readonly id: "ksuid";
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
readonly id: true;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
readonly type: {
|
|
210
|
+
readonly sql: {
|
|
211
|
+
readonly String: {
|
|
212
|
+
readonly kind: "typeConstructor";
|
|
213
|
+
readonly args: readonly [{
|
|
214
|
+
readonly kind: "number";
|
|
215
|
+
readonly name: "length";
|
|
216
|
+
readonly integer: true;
|
|
217
|
+
readonly minimum: 1;
|
|
218
|
+
readonly maximum: 10485760;
|
|
219
|
+
}];
|
|
220
|
+
readonly output: {
|
|
221
|
+
readonly codecId: "sql/varchar@1";
|
|
222
|
+
readonly nativeType: "character varying";
|
|
223
|
+
readonly typeParams: {
|
|
224
|
+
readonly length: {
|
|
225
|
+
readonly kind: "arg";
|
|
226
|
+
readonly index: 0;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
readonly entityTypes: import("@prisma/orm-framework/components/authoring").AuthoringEntityTypeNamespace;
|
|
234
|
+
readonly pslBlockDescriptors: {
|
|
235
|
+
readonly enum: {
|
|
236
|
+
readonly kind: "pslBlock";
|
|
237
|
+
readonly keyword: "enum";
|
|
238
|
+
readonly discriminator: "enum";
|
|
239
|
+
readonly name: {
|
|
240
|
+
readonly required: true;
|
|
241
|
+
};
|
|
242
|
+
readonly parameters: {};
|
|
243
|
+
readonly variadicParameters: true;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
readonly attributeSpecs: {
|
|
247
|
+
readonly model: {
|
|
248
|
+
readonly map: () => AttributeSpec<{
|
|
249
|
+
name: string;
|
|
250
|
+
}>;
|
|
251
|
+
readonly id: () => AttributeSpec<{
|
|
252
|
+
fields: string[];
|
|
253
|
+
readonly map?: string;
|
|
254
|
+
}>;
|
|
255
|
+
readonly unique: () => AttributeSpec<{
|
|
256
|
+
fields: string[];
|
|
257
|
+
readonly map?: string;
|
|
258
|
+
}>;
|
|
259
|
+
readonly index: () => AttributeSpec<{
|
|
260
|
+
fields?: string[];
|
|
261
|
+
readonly expression?: string;
|
|
262
|
+
readonly where?: string;
|
|
263
|
+
readonly unique?: boolean;
|
|
264
|
+
readonly name?: string;
|
|
265
|
+
readonly map?: string;
|
|
266
|
+
readonly type?: string;
|
|
267
|
+
readonly options?: Record<string, string>;
|
|
268
|
+
}>;
|
|
269
|
+
readonly check: () => AttributeSpec<{
|
|
270
|
+
readonly expression: string;
|
|
271
|
+
readonly name?: string;
|
|
272
|
+
readonly map?: string;
|
|
273
|
+
}>;
|
|
274
|
+
readonly control: () => AttributeSpec<{
|
|
275
|
+
policy: "managed" | "tolerated" | "external" | "observed";
|
|
276
|
+
}>;
|
|
277
|
+
readonly discriminator: () => AttributeSpec<{
|
|
278
|
+
field: string;
|
|
279
|
+
}>;
|
|
280
|
+
readonly base: () => AttributeSpec<{
|
|
281
|
+
base: string;
|
|
282
|
+
value: string;
|
|
283
|
+
}>;
|
|
284
|
+
};
|
|
285
|
+
readonly field: {
|
|
286
|
+
readonly map: () => AttributeSpec<{
|
|
287
|
+
name: string;
|
|
288
|
+
}>;
|
|
289
|
+
readonly id: () => AttributeSpec<{
|
|
290
|
+
readonly map?: string;
|
|
291
|
+
}>;
|
|
292
|
+
readonly unique: () => AttributeSpec<{
|
|
293
|
+
readonly map?: string;
|
|
294
|
+
}>;
|
|
295
|
+
readonly noCheck: () => AttributeSpec<{
|
|
296
|
+
first?: "membership" | "elementNotNull";
|
|
297
|
+
second?: "membership" | "elementNotNull";
|
|
298
|
+
}>;
|
|
299
|
+
readonly relation: () => AttributeSpec<{
|
|
300
|
+
name?: string;
|
|
301
|
+
readonly fields?: string[];
|
|
302
|
+
readonly references?: string[];
|
|
303
|
+
readonly map?: string;
|
|
304
|
+
readonly onDelete?: "NoAction" | "Restrict" | "Cascade" | "SetNull" | "SetDefault";
|
|
305
|
+
readonly onUpdate?: "NoAction" | "Restrict" | "Cascade" | "SetNull" | "SetDefault";
|
|
306
|
+
readonly index?: boolean;
|
|
307
|
+
}>;
|
|
308
|
+
readonly default: (ctx: FieldAttributeSpecContext) => AttributeSpec<{
|
|
309
|
+
value: string | number | boolean | (string | number | boolean)[] | TypedFuncCall;
|
|
310
|
+
}>;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
//#endregion
|
|
316
|
+
export { sqlFamilyPack as t };
|
|
317
|
+
//# sourceMappingURL=pack-Chia4J0l.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-Chia4J0l.d.mts","names":[],"sources":["../../../../2-sql/9-family/dist/pack.d.mts"],"mappings":";;;cAEc;WACH;WACA;WACA;WACA;WACA;aACE;eACE;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;uBACE;uBACA;uBACA;uBACA;uBACA;;;;iBAIN;mBACE;mBACA;mBACA;qBACE;uBACE;uBACA;uBACA;uBACA;;;;;eAKR;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;iBACA;mBACE;mBACA;mBACA;qBACE;;;;eAIN;iBACE;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;yBACE;yBACA;yBACA;yBACA;yBACA;;;;mBAIN;qBACE;qBACA;qBACA;uBACE;yBACE;yBACA;yBACA;yBACA;;;qBAGJ;uBACE;yBACE;yBACA;yBACA;2BACE;6BACE;6BACA;6BACA;;;;;qBAKR;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;iBAGJ;mBACE;mBACA;qBACE;qBACA;qBACA;uBACE;;qBAEF;uBACE;yBACE;yBACA;;;qBAGJ;;;;;aAKR;eACE;iBACE;mBACE;mBACA;qBACE;qBACA;qBACA;qBACA;qBACA;;mBAEF;qBACE;qBACA;qBACA;uBACE;yBACE;yBACA;;;;;;;aAOZ,gEAAgE;aAChE;eACE;iBACE;iBACA;iBACA;iBACA;mBACE;;iBAEF;iBACA;;;aAGJ;eACE;iBACE,WAAW;UAClB;;iBAEO,UAAU;UACjB;mBACS;;iBAEF,cAAc;UACrB;mBACS;;iBAEF,aAAa;UACpB;mBACS;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA,UAAU;;iBAEZ,aAAa;mBACX;mBACA;mBACA;;iBAEF,eAAe;UACtB;;iBAEO,qBAAqB;UAC5B;;iBAEO,YAAY;UACnB;UACA;;;eAGK;iBACE,WAAW;UAClB;;iBAEO,UAAU;mBACR;;iBAEF,cAAc;mBACZ;;iBAEF,eAAe;UACtB;UACA;;iBAEO,gBAAgB;UACvB;mBACS;mBACA;mBACA;mBACA;mBACA;mBACA;;iBAEF,UAAU,KAAK,8BAA8B;UACpD,mEAAmE"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
2
|
+
import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, num, oneOf, optional, record, str } from "@prisma/orm-framework/psl-parser";
|
|
3
|
+
import { notOk } from "@prisma/orm-framework/utils/result";
|
|
4
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-Cr8_u9ma.mjs
|
|
5
|
+
function findModelAttributeNode(model, name) {
|
|
6
|
+
for (const attribute of model.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;
|
|
7
|
+
}
|
|
8
|
+
function findFieldAttributeNode(field, name) {
|
|
9
|
+
for (const attribute of field.node.attributes()) if (attribute.name()?.isSimpleName(name) === true) return attribute;
|
|
10
|
+
}
|
|
11
|
+
function buildModelInterpretCtx(input) {
|
|
12
|
+
return {
|
|
13
|
+
level: "model",
|
|
14
|
+
sourceId: input.sourceId,
|
|
15
|
+
sourceFile: input.sourceFile,
|
|
16
|
+
selfModel: input.selfModel,
|
|
17
|
+
resolveReferencedModel: () => void 0
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function buildFieldInterpretCtx(input) {
|
|
21
|
+
return {
|
|
22
|
+
level: "field",
|
|
23
|
+
sourceId: input.sourceId,
|
|
24
|
+
sourceFile: input.sourceFile,
|
|
25
|
+
selfModel: input.selfModel,
|
|
26
|
+
resolveReferencedModel: input.resolveReferencedModel ?? (() => void 0),
|
|
27
|
+
field: input.field
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function interpretModelAttribute(input) {
|
|
31
|
+
const result = interpretAttribute(input.node, input.spec, buildModelInterpretCtx({
|
|
32
|
+
selfModel: input.model,
|
|
33
|
+
sourceFile: input.sourceFile,
|
|
34
|
+
sourceId: input.sourceId
|
|
35
|
+
}));
|
|
36
|
+
if (!result.ok) {
|
|
37
|
+
for (const failure of result.failure) input.diagnostics.push(failure);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return result.value;
|
|
41
|
+
}
|
|
42
|
+
function interpretFieldAttribute(input) {
|
|
43
|
+
const result = interpretAttribute(input.node, input.spec, buildFieldInterpretCtx({
|
|
44
|
+
selfModel: input.model,
|
|
45
|
+
field: input.field,
|
|
46
|
+
sourceFile: input.sourceFile,
|
|
47
|
+
sourceId: input.sourceId,
|
|
48
|
+
resolveReferencedModel: input.resolveReferencedModel
|
|
49
|
+
}));
|
|
50
|
+
if (!result.ok) {
|
|
51
|
+
for (const failure of result.failure) input.diagnostics.push(failure);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
return result.value;
|
|
55
|
+
}
|
|
56
|
+
const mapModelSpec = modelAttribute("map", { positional: [{
|
|
57
|
+
key: "name",
|
|
58
|
+
type: str()
|
|
59
|
+
}] });
|
|
60
|
+
const mapFieldSpec = fieldAttribute("map", { positional: [{
|
|
61
|
+
key: "name",
|
|
62
|
+
type: str()
|
|
63
|
+
}] });
|
|
64
|
+
function scalarDefaultArms(isList, registry) {
|
|
65
|
+
const literal = () => oneOf(str(), num(), bool());
|
|
66
|
+
const funcArms = [...registry.entries()].map(([name, entry]) => funcCall(name, blindCast(entry.signature)));
|
|
67
|
+
return isList ? [list(literal()), ...funcArms] : [
|
|
68
|
+
str(),
|
|
69
|
+
num(),
|
|
70
|
+
bool(),
|
|
71
|
+
...funcArms
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
function noEnumMember() {
|
|
75
|
+
return {
|
|
76
|
+
kind: "identifier",
|
|
77
|
+
label: "enum member",
|
|
78
|
+
parse: (arg, ctx) => notOk([leafDiagnostic(ctx, arg, "Enum declares no members")])
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function enumMemberNames(ctx) {
|
|
82
|
+
const block = (ctx.field.typeNamespaceId === void 0 ? ctx.symbols.topLevel : ctx.symbols.topLevel.namespaces[ctx.field.typeNamespaceId])?.blocks[ctx.field.typeName];
|
|
83
|
+
if (block === void 0 || block.keyword !== "enum") return void 0;
|
|
84
|
+
return Object.keys(block.block.parameters);
|
|
85
|
+
}
|
|
86
|
+
function enumDefaultArms(members) {
|
|
87
|
+
const [first, ...rest] = members;
|
|
88
|
+
if (first === void 0) return [noEnumMember()];
|
|
89
|
+
return [identifier(first), ...rest.map((name) => identifier(name))];
|
|
90
|
+
}
|
|
91
|
+
function defaultFieldSpec(ctx) {
|
|
92
|
+
const members = enumMemberNames(ctx);
|
|
93
|
+
return fieldAttribute("default", { positional: [{
|
|
94
|
+
key: "value",
|
|
95
|
+
type: oneOf(...members === void 0 ? scalarDefaultArms(ctx.field.list, ctx.controlMutationDefaults) : enumDefaultArms(members))
|
|
96
|
+
}] });
|
|
97
|
+
}
|
|
98
|
+
const idFieldSpec = fieldAttribute("id", { named: { map: optional(str()) } });
|
|
99
|
+
const uniqueFieldSpec = fieldAttribute("unique", { named: { map: optional(str()) } });
|
|
100
|
+
const noCheckKindArgument = () => oneOf(identifier("membership"), identifier("elementNotNull"));
|
|
101
|
+
/**
|
|
102
|
+
* `@noCheck` waives generated CHECK constraints on one column: bare for every
|
|
103
|
+
* kind the column's shape derives, or naming concrete kinds. Two optional
|
|
104
|
+
* positional slots cover the whole kind vocabulary; a third argument is
|
|
105
|
+
* necessarily a duplicate and fails as excess arity.
|
|
106
|
+
*/
|
|
107
|
+
const noCheckFieldSpec = fieldAttribute("noCheck", {
|
|
108
|
+
positional: [{
|
|
109
|
+
key: "first",
|
|
110
|
+
type: optional(noCheckKindArgument())
|
|
111
|
+
}, {
|
|
112
|
+
key: "second",
|
|
113
|
+
type: optional(noCheckKindArgument())
|
|
114
|
+
}],
|
|
115
|
+
refine: (value, ctx, attributeNode) => {
|
|
116
|
+
if (value.first !== void 0 && value.first === value.second) return [leafDiagnostic(ctx, attributeNode, "`@noCheck` names the same kind twice")];
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const idModelSpec = modelAttribute("id", {
|
|
121
|
+
positional: [{
|
|
122
|
+
key: "fields",
|
|
123
|
+
type: list(fieldRef("self"), {
|
|
124
|
+
nonEmpty: true,
|
|
125
|
+
unique: true
|
|
126
|
+
})
|
|
127
|
+
}],
|
|
128
|
+
named: { map: optional(str()) }
|
|
129
|
+
});
|
|
130
|
+
const uniqueModelSpec = modelAttribute("unique", {
|
|
131
|
+
positional: [{
|
|
132
|
+
key: "fields",
|
|
133
|
+
type: list(fieldRef("self"), {
|
|
134
|
+
nonEmpty: true,
|
|
135
|
+
unique: true
|
|
136
|
+
})
|
|
137
|
+
}],
|
|
138
|
+
named: { map: optional(str()) }
|
|
139
|
+
});
|
|
140
|
+
const PSL_INDEX_FIELDS_XOR_EXPRESSION = "PSL_INDEX_FIELDS_XOR_EXPRESSION";
|
|
141
|
+
const PSL_INDEX_EXPRESSION_REQUIRES_NAME = "PSL_INDEX_EXPRESSION_REQUIRES_NAME";
|
|
142
|
+
const PSL_INDEX_NAME_XOR_MAP = "PSL_INDEX_NAME_XOR_MAP";
|
|
143
|
+
const indexModelSpec = modelAttribute("index", {
|
|
144
|
+
positional: [{
|
|
145
|
+
key: "fields",
|
|
146
|
+
type: optional(list(fieldRef("self"), {
|
|
147
|
+
nonEmpty: true,
|
|
148
|
+
unique: true
|
|
149
|
+
}))
|
|
150
|
+
}],
|
|
151
|
+
named: {
|
|
152
|
+
expression: optional(str()),
|
|
153
|
+
where: optional(str()),
|
|
154
|
+
unique: optional(bool()),
|
|
155
|
+
name: optional(str()),
|
|
156
|
+
map: optional(str()),
|
|
157
|
+
type: optional(str()),
|
|
158
|
+
options: optional(record(str()))
|
|
159
|
+
},
|
|
160
|
+
refine: (value, ctx, attributeNode) => {
|
|
161
|
+
const diagnostics = [];
|
|
162
|
+
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));
|
|
163
|
+
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));
|
|
164
|
+
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));
|
|
165
|
+
if (value.options !== void 0 && value.type === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, "`@@index` options argument requires a type argument"));
|
|
166
|
+
return diagnostics;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const PSL_CHECK_REQUIRES_NAME_OR_MAP = "PSL_CHECK_REQUIRES_NAME_OR_MAP";
|
|
170
|
+
const PSL_CHECK_NAME_XOR_MAP = "PSL_CHECK_NAME_XOR_MAP";
|
|
171
|
+
const PSL_CHECK_EXPRESSION_EMPTY = "PSL_CHECK_EXPRESSION_EMPTY";
|
|
172
|
+
/**
|
|
173
|
+
* A single-table-inheritance variant (`@@base` with no own `@@map`) shares
|
|
174
|
+
* its base model's storage table and has no table of its own to declare a
|
|
175
|
+
* check on — raised from {@link interpretPslDocumentToSqlContract}, not from
|
|
176
|
+
* this spec's own `refine`, because the rule needs the model's `@@base`
|
|
177
|
+
* declaration, which a single attribute's `refine` cannot see.
|
|
178
|
+
*/
|
|
179
|
+
const PSL_CHECK_ON_STI_VARIANT = "PSL_CHECK_ON_STI_VARIANT";
|
|
180
|
+
const checkModelSpec = modelAttribute("check", {
|
|
181
|
+
named: {
|
|
182
|
+
expression: str(),
|
|
183
|
+
name: optional(str()),
|
|
184
|
+
map: optional(str())
|
|
185
|
+
},
|
|
186
|
+
refine: (value, ctx, attributeNode) => {
|
|
187
|
+
const diagnostics = [];
|
|
188
|
+
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));
|
|
189
|
+
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));
|
|
190
|
+
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));
|
|
191
|
+
return diagnostics;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const controlModelSpec = modelAttribute("control", { positional: [{
|
|
195
|
+
key: "policy",
|
|
196
|
+
type: oneOf(identifier("managed"), identifier("tolerated"), identifier("external"), identifier("observed"))
|
|
197
|
+
}] });
|
|
198
|
+
const discriminatorModelSpec = modelAttribute("discriminator", { positional: [{
|
|
199
|
+
key: "field",
|
|
200
|
+
type: fieldRef("self")
|
|
201
|
+
}] });
|
|
202
|
+
const baseModelSpec = modelAttribute("base", { positional: [{
|
|
203
|
+
key: "base",
|
|
204
|
+
type: entityRef()
|
|
205
|
+
}, {
|
|
206
|
+
key: "value",
|
|
207
|
+
type: str()
|
|
208
|
+
}] });
|
|
209
|
+
function relationAttributeSpan(ctx) {
|
|
210
|
+
const field = ctx.field;
|
|
211
|
+
if (field !== void 0) {
|
|
212
|
+
const node = findFieldAttributeNode(field, "relation");
|
|
213
|
+
if (node !== void 0) return nodePslSpan(node.syntax, ctx.sourceFile);
|
|
214
|
+
return field.span;
|
|
215
|
+
}
|
|
216
|
+
return ctx.selfModel.span;
|
|
217
|
+
}
|
|
218
|
+
function relationInvariants(parsed, ctx) {
|
|
219
|
+
if (parsed.fields !== void 0 !== (parsed.references !== void 0)) return [{
|
|
220
|
+
code: "PSL_INVALID_ATTRIBUTE_SYNTAX",
|
|
221
|
+
message: `Relation field "${ctx.selfModel.name}.${ctx.field?.name ?? ""}" requires fields and references arguments`,
|
|
222
|
+
sourceId: ctx.sourceId,
|
|
223
|
+
span: relationAttributeSpan(ctx)
|
|
224
|
+
}];
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
const referentialActionArgument = () => oneOf(identifier("NoAction"), identifier("Restrict"), identifier("Cascade"), identifier("SetNull"), identifier("SetDefault"));
|
|
228
|
+
const relationFieldSpec = fieldAttribute("relation", {
|
|
229
|
+
positional: [{
|
|
230
|
+
key: "name",
|
|
231
|
+
type: optional(str())
|
|
232
|
+
}],
|
|
233
|
+
named: {
|
|
234
|
+
name: optional(str()),
|
|
235
|
+
fields: optional(list(fieldRef("self"), {
|
|
236
|
+
nonEmpty: true,
|
|
237
|
+
unique: true
|
|
238
|
+
})),
|
|
239
|
+
references: optional(list(fieldRef("referenced"), {
|
|
240
|
+
nonEmpty: true,
|
|
241
|
+
unique: true
|
|
242
|
+
})),
|
|
243
|
+
map: optional(str()),
|
|
244
|
+
onDelete: optional(referentialActionArgument()),
|
|
245
|
+
onUpdate: optional(referentialActionArgument()),
|
|
246
|
+
index: optional(bool())
|
|
247
|
+
},
|
|
248
|
+
refine: relationInvariants
|
|
249
|
+
});
|
|
250
|
+
function fieldSpecContext(input) {
|
|
251
|
+
return {
|
|
252
|
+
symbols: input.symbols,
|
|
253
|
+
model: input.model,
|
|
254
|
+
field: input.field,
|
|
255
|
+
controlMutationDefaults: input.controlMutationDefaults
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const sqlAttributeSpecs = {
|
|
259
|
+
model: {
|
|
260
|
+
map: () => mapModelSpec,
|
|
261
|
+
id: () => idModelSpec,
|
|
262
|
+
unique: () => uniqueModelSpec,
|
|
263
|
+
index: () => indexModelSpec,
|
|
264
|
+
check: () => checkModelSpec,
|
|
265
|
+
control: () => controlModelSpec,
|
|
266
|
+
discriminator: () => discriminatorModelSpec,
|
|
267
|
+
base: () => baseModelSpec
|
|
268
|
+
},
|
|
269
|
+
field: {
|
|
270
|
+
map: () => mapFieldSpec,
|
|
271
|
+
id: () => idFieldSpec,
|
|
272
|
+
unique: () => uniqueFieldSpec,
|
|
273
|
+
noCheck: () => noCheckFieldSpec,
|
|
274
|
+
relation: () => relationFieldSpec,
|
|
275
|
+
default: defaultFieldSpec
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
//#endregion
|
|
279
|
+
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 };
|
|
280
|
+
|
|
281
|
+
//# sourceMappingURL=sql-attribute-specs-Cr8_u9ma-ENY2C_np.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-attribute-specs-Cr8_u9ma-ENY2C_np.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-Cr8_u9ma.mjs"],"sourcesContent":["import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, num, oneOf, optional, record, 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 buildModelInterpretCtx(input) {\n\treturn {\n\t\tlevel: \"model\",\n\t\tsourceId: input.sourceId,\n\t\tsourceFile: input.sourceFile,\n\t\tselfModel: input.selfModel,\n\t\tresolveReferencedModel: () => void 0\n\t};\n}\nfunction buildFieldInterpretCtx(input) {\n\treturn {\n\t\tlevel: \"field\",\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, buildModelInterpretCtx({\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, buildFieldInterpretCtx({\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}\nconst mapModelSpec = modelAttribute(\"map\", { positional: [{\n\tkey: \"name\",\n\ttype: str()\n}] });\nconst mapFieldSpec = fieldAttribute(\"map\", { positional: [{\n\tkey: \"name\",\n\ttype: str()\n}] });\nfunction scalarDefaultArms(isList, registry) {\n\tconst literal = () => oneOf(str(), num(), 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\tnum(),\n\t\tbool(),\n\t\t...funcArms\n\t];\n}\nfunction noEnumMember() {\n\treturn {\n\t\tkind: \"identifier\",\n\t\tlabel: \"enum member\",\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(\"self\"), {\n\t\t\tnonEmpty: true,\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(\"self\"), {\n\t\t\tnonEmpty: true,\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(\"self\"), {\n\t\t\tnonEmpty: true,\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(\"self\")\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 field = ctx.field;\n\tif (field !== void 0) {\n\t\tconst node = findFieldAttributeNode(field, \"relation\");\n\t\tif (node !== void 0) return nodePslSpan(node.syntax, ctx.sourceFile);\n\t\treturn field.span;\n\t}\n\treturn ctx.selfModel.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(\"self\"), {\n\t\t\tnonEmpty: true,\n\t\t\tunique: true\n\t\t})),\n\t\treferences: optional(list(fieldRef(\"referenced\"), {\n\t\t\tnonEmpty: true,\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-Cr8_u9ma.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,OAAO;EACP,UAAU,MAAM;EAChB,YAAY,MAAM;EAClB,WAAW,MAAM;EACjB,8BAA8B,KAAK;CACpC;AACD;AACA,SAAS,uBAAuB,OAA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