@prisma/orm-family-sql 8.0.0-rc.9-dev.3 → 8.0.0-rc.9-dev.4
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.mjs +1 -1
- package/dist/contract-psl__provider.mjs +1 -1
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/{control-CMYPT7Ek.mjs → control-BJ9sRUe-.mjs} +2 -2
- package/dist/{control-CMYPT7Ek.mjs.map → control-BJ9sRUe-.mjs.map} +1 -1
- package/dist/family.mjs +1 -1
- package/dist/family__control.mjs +1 -1
- package/dist/family__pack.mjs +1 -1
- package/dist/{interpreter-_KWQDsAm-B2goMgB0.mjs → interpreter-CZ_iVQV4-BERgkqtm.mjs} +3 -3
- package/dist/{interpreter-_KWQDsAm-B2goMgB0.mjs.map → interpreter-CZ_iVQV4-BERgkqtm.mjs.map} +1 -1
- package/dist/{sql-attribute-specs-BbZ53xbF-CiX6O5aY.mjs → sql-attribute-specs-CG0yitvD-CG-0eW98.mjs} +9 -8
- package/dist/sql-attribute-specs-CG0yitvD-CG-0eW98.mjs.map +1 -0
- package/package.json +17 -17
- package/dist/sql-attribute-specs-BbZ53xbF-CiX6O5aY.mjs.map +0 -1
package/dist/{sql-attribute-specs-BbZ53xbF-CiX6O5aY.mjs → sql-attribute-specs-CG0yitvD-CG-0eW98.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, num, 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-CG0yitvD.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
|
}
|
|
@@ -70,8 +70,9 @@ function scalarDefaultArms(isList, registry) {
|
|
|
70
70
|
}
|
|
71
71
|
function noEnumMember() {
|
|
72
72
|
return {
|
|
73
|
-
kind: "
|
|
73
|
+
kind: "rejecting",
|
|
74
74
|
label: "enum member",
|
|
75
|
+
message: "Enum declares no members",
|
|
75
76
|
parse: (arg, ctx) => notOk([leafDiagnostic(ctx, arg, "Enum declares no members")])
|
|
76
77
|
};
|
|
77
78
|
}
|
|
@@ -118,7 +119,7 @@ const idModelSpec = modelAttribute("id", {
|
|
|
118
119
|
positional: [{
|
|
119
120
|
key: "fields",
|
|
120
121
|
type: list(fieldRef(), {
|
|
121
|
-
|
|
122
|
+
allowEmpty: false,
|
|
122
123
|
unique: true
|
|
123
124
|
})
|
|
124
125
|
}],
|
|
@@ -128,7 +129,7 @@ const uniqueModelSpec = modelAttribute("unique", {
|
|
|
128
129
|
positional: [{
|
|
129
130
|
key: "fields",
|
|
130
131
|
type: list(fieldRef(), {
|
|
131
|
-
|
|
132
|
+
allowEmpty: false,
|
|
132
133
|
unique: true
|
|
133
134
|
})
|
|
134
135
|
}],
|
|
@@ -141,7 +142,7 @@ const indexModelSpec = modelAttribute("index", {
|
|
|
141
142
|
positional: [{
|
|
142
143
|
key: "fields",
|
|
143
144
|
type: optional(list(fieldRef(), {
|
|
144
|
-
|
|
145
|
+
allowEmpty: false,
|
|
145
146
|
unique: true
|
|
146
147
|
}))
|
|
147
148
|
}],
|
|
@@ -226,11 +227,11 @@ const relationFieldSpec = fieldAttribute("relation", {
|
|
|
226
227
|
named: {
|
|
227
228
|
name: optional(str()),
|
|
228
229
|
fields: optional(list(fieldRef(), {
|
|
229
|
-
|
|
230
|
+
allowEmpty: false,
|
|
230
231
|
unique: true
|
|
231
232
|
})),
|
|
232
233
|
references: optional(list(referencedFieldRef(), {
|
|
233
|
-
|
|
234
|
+
allowEmpty: false,
|
|
234
235
|
unique: true
|
|
235
236
|
})),
|
|
236
237
|
map: optional(str()),
|
|
@@ -271,4 +272,4 @@ const sqlAttributeSpecs = {
|
|
|
271
272
|
//#endregion
|
|
272
273
|
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 };
|
|
273
274
|
|
|
274
|
-
//# sourceMappingURL=sql-attribute-specs-
|
|
275
|
+
//# sourceMappingURL=sql-attribute-specs-CG0yitvD-CG-0eW98.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-attribute-specs-CG0yitvD-CG-0eW98.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-CG0yitvD.mjs"],"sourcesContent":["import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, num, 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}\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: \"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-CG0yitvD.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,SAAS,mBAAmB,MAAM,MAAM,MAAM,MAAM,uBAAuB;EAChF,WAAW,MAAM;EACjB,OAAO,MAAM;EACb,YAAY,MAAM;EAClB,UAAU,MAAM;EAChB,wBAAwB,MAAM;CAC/B,CAAC,CAAC;CACF,IAAI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AAK,GAAG,IAAI,MAAM,KAAK;EACjE,UAAU,IAAI;EACd,MAAM,sBAAsB,GAAG;CAChC,CAAC;CACD,OAAO,CAAC;AACT;AACA,MAAM,kCAAkC,MAAM,WAAW,UAAU,GAAG,WAAW,UAAU,GAAG,WAAW,SAAS,GAAG,WAAW,SAAS,GAAG,WAAW,YAAY,CAAC;AACpK,MAAM,oBAAoB,eAAe,YAAY;CACpD,YAAY,CAAC;EACZ,KAAK;EACL,MAAM,SAAS,IAAI,CAAC;CACrB,CAAC;CACD,OAAO;EACN,MAAM,SAAS,IAAI,CAAC;EACpB,QAAQ,SAAS,KAAK,SAAS,GAAG;GACjC,YAAY;GACZ,QAAQ;EACT,CAAC,CAAC;EACF,YAAY,SAAS,KAAK,mBAAmB,GAAG;GAC/C,YAAY;GACZ,QAAQ;EACT,CAAC,CAAC;EACF,KAAK,SAAS,IAAI,CAAC;EACnB,UAAU,SAAS,0BAA0B,CAAC;EAC9C,UAAU,SAAS,0BAA0B,CAAC;EAC9C,OAAO,SAAS,KAAK,CAAC;CACvB;CACA,QAAQ;AACT,CAAC;AACD,SAAS,iBAAiB,OAAO;CAChC,OAAO;EACN,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO,MAAM;EACb,yBAAyB,MAAM;CAChC;AACD;AACA,MAAM,oBAAoB;CACzB,OAAO;EACN,WAAW;EACX,UAAU;EACV,cAAc;EACd,aAAa;EACb,aAAa;EACb,eAAe;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.9-dev.
|
|
3
|
+
"version": "8.0.0-rc.9-dev.4",
|
|
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.9-dev.
|
|
13
|
-
"@prisma/orm-toolchain": "8.0.0-rc.9-dev.
|
|
12
|
+
"@prisma/orm-framework": "8.0.0-rc.9-dev.4",
|
|
13
|
+
"@prisma/orm-toolchain": "8.0.0-rc.9-dev.4",
|
|
14
14
|
"@standard-schema/spec": "^1.1.0",
|
|
15
15
|
"arktype": "^2.2.2",
|
|
16
16
|
"pathe": "^2.0.3",
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
"ts-toolbelt": "^9.6.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@internal/family-sql": "8.0.0-rc.9-dev.
|
|
22
|
-
"@internal/sql-builder": "8.0.0-rc.9-dev.
|
|
23
|
-
"@internal/sql-contract": "8.0.0-rc.9-dev.
|
|
24
|
-
"@internal/sql-contract-emitter": "8.0.0-rc.9-dev.
|
|
25
|
-
"@internal/sql-contract-psl": "8.0.0-rc.9-dev.
|
|
26
|
-
"@internal/sql-contract-ts": "8.0.0-rc.9-dev.
|
|
27
|
-
"@internal/sql-errors": "8.0.0-rc.9-dev.
|
|
28
|
-
"@internal/sql-operations": "8.0.0-rc.9-dev.
|
|
29
|
-
"@internal/sql-orm-client": "8.0.0-rc.9-dev.
|
|
30
|
-
"@internal/sql-relational-core": "8.0.0-rc.9-dev.
|
|
31
|
-
"@internal/sql-runtime": "8.0.0-rc.9-dev.
|
|
32
|
-
"@internal/sql-schema-ir": "8.0.0-rc.9-dev.
|
|
33
|
-
"@repo/tsconfig": "8.0.0-rc.9-dev.
|
|
34
|
-
"@repo/tsdown": "8.0.0-rc.9-dev.
|
|
21
|
+
"@internal/family-sql": "8.0.0-rc.9-dev.4",
|
|
22
|
+
"@internal/sql-builder": "8.0.0-rc.9-dev.4",
|
|
23
|
+
"@internal/sql-contract": "8.0.0-rc.9-dev.4",
|
|
24
|
+
"@internal/sql-contract-emitter": "8.0.0-rc.9-dev.4",
|
|
25
|
+
"@internal/sql-contract-psl": "8.0.0-rc.9-dev.4",
|
|
26
|
+
"@internal/sql-contract-ts": "8.0.0-rc.9-dev.4",
|
|
27
|
+
"@internal/sql-errors": "8.0.0-rc.9-dev.4",
|
|
28
|
+
"@internal/sql-operations": "8.0.0-rc.9-dev.4",
|
|
29
|
+
"@internal/sql-orm-client": "8.0.0-rc.9-dev.4",
|
|
30
|
+
"@internal/sql-relational-core": "8.0.0-rc.9-dev.4",
|
|
31
|
+
"@internal/sql-runtime": "8.0.0-rc.9-dev.4",
|
|
32
|
+
"@internal/sql-schema-ir": "8.0.0-rc.9-dev.4",
|
|
33
|
+
"@repo/tsconfig": "8.0.0-rc.9-dev.4",
|
|
34
|
+
"@repo/tsdown": "8.0.0-rc.9-dev.4",
|
|
35
35
|
"tsdown": "0.22.14",
|
|
36
36
|
"typescript": "5.9.3"
|
|
37
37
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sql-attribute-specs-BbZ53xbF-CiX6O5aY.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/sql-attribute-specs-BbZ53xbF.mjs"],"sourcesContent":["import { bool, entityRef, fieldAttribute, fieldRef, funcCall, identifier, interpretAttribute, leafDiagnostic, list, modelAttribute, nodePslSpan, num, 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}\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(), {\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(), {\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(), {\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()\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\tnonEmpty: true,\n\t\t\tunique: true\n\t\t})),\n\t\treferences: optional(list(referencedFieldRef(), {\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-BbZ53xbF.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,SAAS,mBAAmB,MAAM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