@prisma/orm-family-sql 8.0.0-rc.11-dev.53 → 8.0.0-rc.11-dev.54

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.
@@ -11,7 +11,7 @@ import { SymbolTable } from "@prisma/orm-framework/psl-parser";
11
11
  import { CapabilityMatrix, ExtensionPackRef, TargetPackRef } from "@prisma/orm-framework/components/components";
12
12
  import { ContractSourceDiagnostic, ContractSourceDiagnostics } from "@prisma/orm-framework/config/config-types";
13
13
  import "@prisma/orm-framework/components/psl-ast";
14
- //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-BmwDL5Cl.d.mts
14
+ //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-DNb8rW_7.d.mts
15
15
  //#endregion
16
16
  //#region src/psl-column-resolution.d.ts
17
17
  type ColumnDescriptor = {
@@ -32,7 +32,7 @@ type ColumnDescriptor = {
32
32
  //#endregion
33
33
  //#region src/interpreter.d.ts
34
34
  interface InterpretPslDocumentToSqlContractInput {
35
- readonly document: DocumentAst;
35
+ readonly documents: readonly DocumentAst[];
36
36
  readonly symbolTable: SymbolTable;
37
37
  readonly sources: PslSources;
38
38
  readonly target: TargetPackRef<'sql', string>;
@@ -1 +1 @@
1
- {"version":3,"file":"contract-psl.d.mts","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/interpreter-BmwDL5Cl.d.mts"],"mappings":";;;;;;;;;;;;;;;;KAmGK;WACM;WACA;WACA;WACA,aAAa;;;;;;;;;WASb,WAAW;;;;UAyDZ;WACC,UAAU;WACV,aAAa;WACb,SAAS;WACT,QAAQ;WACR,yBAAyB,oBAAoB;WAC7C;WACA,qCAAqC;WACrC,0BAA0B;;WAE1B,gBAAgB;WAChB,yBAAyB;;;;;;;;;;WAUzB,4BAA4B,oBAAoB;;WAEhD,kBAAkB,OAAO,sBAAsB;WAC/C,cAAc;WACd,2BAA2B;;WAE3B;aACE;aACA;;WAEF,cAAc;;iBASR,kCAAkC,OAAO,yCAAyC,OAAO,UAAU"}
1
+ {"version":3,"file":"contract-psl.d.mts","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/interpreter-DNb8rW_7.d.mts"],"mappings":";;;;;;;;;;;;;;;;KAmGK;WACM;WACA;WACA;WACA,aAAa;;;;;;;;;WASb,WAAW;;;;UAyDZ;WACC,oBAAoB;WACpB,aAAa;WACb,SAAS;WACT,QAAQ;WACR,yBAAyB,oBAAoB;WAC7C;WACA,qCAAqC;WACrC,0BAA0B;;WAE1B,gBAAgB;WAChB,yBAAyB;;;;;;;;;;WAUzB,4BAA4B,oBAAoB;;WAEhD,kBAAkB,OAAO,sBAAsB;WAC/C,cAAc;WACd,2BAA2B;;WAE3B;aACE;aACA;;WAEF,cAAc;;iBASR,kCAAkC,OAAO,yCAAyC,OAAO,UAAU"}
@@ -1,2 +1,2 @@
1
- import { a as interpretPslDocumentToSqlContract } from "./interpreter-BcaXUphN-C0qZ0ypa.mjs";
1
+ import { a as interpretPslDocumentToSqlContract } from "./interpreter-Cs1cxg-E-N_DDfih-.mjs";
2
2
  export { interpretPslDocumentToSqlContract };
@@ -1,23 +1,44 @@
1
1
  import { t as applySqlSpecifierControlPolicy } from "./derived-checks-6WZKIUxH-CWip2UN5.mjs";
2
- import { a as interpretPslDocumentToSqlContract } from "./interpreter-BcaXUphN-C0qZ0ypa.mjs";
2
+ import { a as interpretPslDocumentToSqlContract } from "./interpreter-Cs1cxg-E-N_DDfih-.mjs";
3
3
  import { collectScalarTypeConstructors } from "@prisma/orm-framework/components/authoring";
4
- import { InternalError } from "@prisma/orm-framework/utils/internal-error";
5
4
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
6
5
  import { readFile } from "node:fs/promises";
7
6
  import { parse } from "@prisma/orm-framework/psl-parser/syntax";
7
+ import { assertDefined } from "@prisma/orm-framework/utils/assertions";
8
8
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
9
9
  import { basename, extname } from "pathe";
10
- import { buildSymbolTable, mapPslDiagnostics } from "@prisma/orm-framework/psl-parser";
10
+ import { buildSymbolTable, isPrismaNextSchema, mapPslDiagnostics } from "@prisma/orm-framework/psl-parser";
11
11
  import { withSeedDiagnostics } from "@prisma/orm-framework/psl-parser/interpret";
12
+ import { isDynamicPattern } from "tinyglobby";
12
13
  //#region ../../../2-sql/2-authoring/contract-psl/dist/provider.mjs
13
14
  /**
15
+ * The directory portion of `pattern` before its first glob-magic segment,
16
+ * joined back with `/` (e.g. a `prisma` directory holding a recursive
17
+ * `.prisma` glob derives `./prisma`). A rootless pattern with no static
18
+ * segments yields `''`.
19
+ */
20
+ function staticPrefixDirectory(pattern) {
21
+ const staticSegments = [];
22
+ for (const segment of pattern.replaceAll("\\", "/").split("/")) {
23
+ if (isDynamicPattern(segment)) break;
24
+ staticSegments.push(segment);
25
+ }
26
+ return staticSegments.join("/");
27
+ }
28
+ /**
14
29
  * Derives the emit output path from the schema input path so artefacts land
15
30
  * colocated with the source (e.g. `src/contract/schema.prisma` →
16
- * `src/contract/contract.json`). The provider owns this because it is the
17
- * only layer that knows the input path; the upstream `normalizeContractConfig`
31
+ * `src/contract/contract.json`). A glob-shaped path derives from its static
32
+ * prefix directory instead (a recursive glob under `prisma` derives
33
+ * `./prisma/contract.json`). The provider owns this because it is the only
34
+ * layer that knows the input path; the upstream `normalizeContractConfig`
18
35
  * default is a last-resort fallback for providers that don't carry one.
19
36
  */
20
37
  function defaultOutputFromSchemaPath(schemaPath) {
38
+ if (isDynamicPattern(schemaPath)) {
39
+ const prefix = staticPrefixDirectory(schemaPath);
40
+ return prefix.length === 0 ? "contract.json" : `${prefix}/contract.json`;
41
+ }
21
42
  const ext = extname(schemaPath);
22
43
  if (ext.length === 0) return `${schemaPath}.json`;
23
44
  const base = schemaPath.slice(0, -ext.length);
@@ -32,7 +53,7 @@ function prismaContract(schemaPath, options) {
32
53
  interpret(input, context) {
33
54
  const scalarColumnDescriptors = collectScalarTypeConstructors(context.authoringContributions.type);
34
55
  return interpretPslDocumentToSqlContract({
35
- document: input.document,
56
+ documents: input.documents,
36
57
  symbolTable: input.symbolTable,
37
58
  sources: input.sources,
38
59
  seedDiagnostics: [],
@@ -51,36 +72,64 @@ function prismaContract(schemaPath, options) {
51
72
  });
52
73
  },
53
74
  async load(context) {
54
- const [absoluteSchemaPath] = context.resolvedInputs;
55
- if (absoluteSchemaPath === void 0) throw new InternalError("prismaContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.");
56
- let schema;
57
- try {
58
- schema = await readFile(absoluteSchemaPath, "utf-8");
59
- } catch (error) {
60
- const message = String(error);
61
- return notOk({
62
- summary: `Failed to read Prisma schema at "${schemaPath}"`,
63
- diagnostics: [{
75
+ const candidates = [...new Set(context.resolvedInputs)].sort();
76
+ if (candidates.length === 0) return notOk({
77
+ summary: "No schema files matched the configured contract source",
78
+ diagnostics: [{
79
+ code: "PSL_NO_SCHEMA_FILES_MATCHED",
80
+ message: `No files matched the configured pattern "${schemaPath}"`,
81
+ sourceId: schemaPath
82
+ }]
83
+ });
84
+ const readDiagnostics = [];
85
+ const members = [];
86
+ const undirected = [];
87
+ for (const path of candidates) {
88
+ let text;
89
+ try {
90
+ text = await readFile(path, "utf-8");
91
+ } catch (error) {
92
+ const message = String(error);
93
+ readDiagnostics.push({
64
94
  code: "PSL_SCHEMA_READ_FAILED",
65
95
  message,
96
+ sourceId: path
97
+ });
98
+ continue;
99
+ }
100
+ if (isPrismaNextSchema(text)) members.push({
101
+ path,
102
+ text
103
+ });
104
+ else undirected.push(path);
105
+ }
106
+ if (members.length === 0) {
107
+ if (undirected.length === 0) return notOk({
108
+ summary: "Failed to read Prisma schema files",
109
+ diagnostics: readDiagnostics
110
+ });
111
+ return notOk({
112
+ summary: "No schema file carries the \"// use prisma-8\" directive",
113
+ diagnostics: [...readDiagnostics, {
114
+ code: "PSL_NO_OPTED_IN_SCHEMA_FILES",
115
+ message: `None of the matched files carry the "// use prisma-8" directive: ${undirected.join(", ")}`,
66
116
  sourceId: schemaPath
67
- }],
68
- meta: {
69
- schemaPath,
70
- absoluteSchemaPath,
71
- cause: message
72
- }
117
+ }]
73
118
  });
74
119
  }
75
- const { document, sources, diagnostics: parseDiagnostics } = parse(schema, schemaPath);
120
+ const parsed = members.map(({ path, text }) => parse(text, path));
121
+ const documents = parsed.map(({ document }) => document);
122
+ const [firstSources, ...restSources] = parsed.map(({ sources }) => sources);
123
+ assertDefined(firstSources, "prismaContract requires at least one parsed schema file");
124
+ const sources = firstSources.merge(...restSources);
76
125
  const { symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({
77
- documents: [document],
126
+ documents,
78
127
  sources,
79
128
  pslBlockDescriptors: context.authoringContributions.pslBlockDescriptors
80
129
  });
81
- const seedDiagnostics = mapPslDiagnostics([...parseDiagnostics, ...symbolTableDiagnostics], sources);
130
+ const seedDiagnostics = [...readDiagnostics, ...mapPslDiagnostics([...parsed.flatMap(({ diagnostics }) => diagnostics), ...symbolTableDiagnostics], sources)];
82
131
  const interpreted = withSeedDiagnostics(this.interpret({
83
- document,
132
+ documents,
84
133
  sources,
85
134
  symbolTable
86
135
  }, context), seedDiagnostics);
@@ -1 +1 @@
1
- {"version":3,"file":"contract-psl__provider.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/provider.mjs"],"sourcesContent":["import { n as interpretPslDocumentToSqlContract } from \"./interpreter-BcaXUphN.mjs\";\nimport { buildSymbolTable, mapPslDiagnostics } from \"@internal/psl-parser\";\nimport { parse } from \"@internal/psl-parser/syntax\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { collectScalarTypeConstructors } from \"@internal/framework-components/authoring\";\nimport { withSeedDiagnostics } from \"@internal/psl-parser/interpret\";\nimport { applySqlSpecifierControlPolicy } from \"@internal/sql-contract-ts/contract-builder\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { readFile } from \"node:fs/promises\";\nimport { basename, extname } from \"pathe\";\n//#region src/provider.ts\n/**\n* Derives the emit output path from the schema input path so artefacts land\n* colocated with the source (e.g. `src/contract/schema.prisma` →\n* `src/contract/contract.json`). The provider owns this because it is the\n* only layer that knows the input path; the upstream `normalizeContractConfig`\n* default is a last-resort fallback for providers that don't carry one.\n*/\nfunction defaultOutputFromSchemaPath(schemaPath) {\n\tconst ext = extname(schemaPath);\n\tif (ext.length === 0) return `${schemaPath}.json`;\n\tconst base = schemaPath.slice(0, -ext.length);\n\tif (basename(base) === \"schema\") return `${base.slice(0, -6)}contract.json`;\n\treturn `${base}.json`;\n}\nfunction prismaContract(schemaPath, options) {\n\treturn {\n\t\tsource: {\n\t\t\tformat: \"psl\",\n\t\t\tinputs: [schemaPath],\n\t\t\tinterpret(input, context) {\n\t\t\t\tconst scalarColumnDescriptors = collectScalarTypeConstructors(context.authoringContributions.type);\n\t\t\t\treturn interpretPslDocumentToSqlContract({\n\t\t\t\t\tdocument: input.document,\n\t\t\t\t\tsymbolTable: input.symbolTable,\n\t\t\t\t\tsources: input.sources,\n\t\t\t\t\tseedDiagnostics: [],\n\t\t\t\t\ttarget: options.target,\n\t\t\t\t\tauthoringContributions: context.authoringContributions,\n\t\t\t\t\tscalarColumnDescriptors,\n\t\t\t\t\t...ifDefined(\"composedExtensions\", context.composedExtensions.length > 0 ? [...context.composedExtensions] : void 0),\n\t\t\t\t\tcomposedExtensionContracts: context.composedExtensionContracts,\n\t\t\t\t\t...ifDefined(\"composedExtensionPackRefs\", options.composedExtensionPackRefs?.length ? options.composedExtensionPackRefs : void 0),\n\t\t\t\t\tcontrolMutationDefaults: context.controlMutationDefaults,\n\t\t\t\t\tcreateNamespace: options.createNamespace,\n\t\t\t\t\tcapabilities: context.capabilities,\n\t\t\t\t\tcodecLookup: context.codecLookup,\n\t\t\t\t\tdataTypeLookup: context.dataTypeLookup,\n\t\t\t\t\t...ifDefined(\"enumInferenceCodecs\", options.enumInferenceCodecs)\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync load(context) {\n\t\t\t\tconst [absoluteSchemaPath] = context.resolvedInputs;\n\t\t\t\tif (absoluteSchemaPath === void 0) throw new InternalError(\"prismaContract: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.\");\n\t\t\t\tlet schema;\n\t\t\t\ttry {\n\t\t\t\t\tschema = await readFile(absoluteSchemaPath, \"utf-8\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = String(error);\n\t\t\t\t\treturn notOk({\n\t\t\t\t\t\tsummary: `Failed to read Prisma schema at \"${schemaPath}\"`,\n\t\t\t\t\t\tdiagnostics: [{\n\t\t\t\t\t\t\tcode: \"PSL_SCHEMA_READ_FAILED\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t\t}],\n\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\tschemaPath,\n\t\t\t\t\t\t\tabsoluteSchemaPath,\n\t\t\t\t\t\t\tcause: message\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst { document, sources, diagnostics: parseDiagnostics } = parse(schema, schemaPath);\n\t\t\t\tconst { symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n\t\t\t\t\tdocuments: [document],\n\t\t\t\t\tsources,\n\t\t\t\t\tpslBlockDescriptors: context.authoringContributions.pslBlockDescriptors\n\t\t\t\t});\n\t\t\t\tconst seedDiagnostics = mapPslDiagnostics([...parseDiagnostics, ...symbolTableDiagnostics], sources);\n\t\t\t\tconst interpreted = withSeedDiagnostics(this.interpret({\n\t\t\t\t\tdocument,\n\t\t\t\t\tsources,\n\t\t\t\t\tsymbolTable\n\t\t\t\t}, context), seedDiagnostics);\n\t\t\t\tif (!interpreted.ok) return interpreted;\n\t\t\t\treturn ok(applySqlSpecifierControlPolicy(interpreted.value, options.defaultControlPolicy, options.createNamespace));\n\t\t\t}\n\t\t},\n\t\toutput: options.output ?? defaultOutputFromSchemaPath(schemaPath)\n\t};\n}\n//#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O,KAAK;KAC5B,OAAO,MAAM;MACZ,SAAS,oCAAoC,WAAW;MACxD,aAAa,CAAC;OACb,MAAM;OACN;OACA,UAAU;MACX,CAAC;MACD,MAAM;OACL;OACA;OACA,OAAO;MACR;KACD,CAAC;IACF;IACA,MAAM,EAAE,UAAU,SAAS,aAAa,qBAAqB,MAAM,QAAQ,UAAU;IACrF,MAAM,EAAE,aAAa,aAAa,2BAA2B,iBAAiB;KAC7E,WAAW,CAAC,QAAQ;KACpB;KACA,qBAAqB,QAAQ,uBAAuB;IACrD,CAAC;IACD,MAAM,kBAAkB,kBAAkB,CAAC,GAAG,kBAAkB,GAAG,sBAAsB,GAAG,OAAO;IACnG,MAAM,cAAc,oBAAoB,KAAK,UAAU;KACtD;KACA;KACA;IACD,GAAG,OAAO,GAAG,eAAe;IAC5B,IAAI,CAAC,YAAY,IAAI,OAAO;IAC5B,OAAO,GAAG,+BAA+B,YAAY,OAAO,QAAQ,sBAAsB,QAAQ,eAAe,CAAC;GACnH;EACD;EACA,QAAQ,QAAQ,UAAU,4BAA4B,UAAU;CACjE;AACD"}
1
+ {"version":3,"file":"contract-psl__provider.mjs","names":[],"sources":["../../../../2-sql/2-authoring/contract-psl/dist/provider.mjs"],"sourcesContent":["import { n as interpretPslDocumentToSqlContract } from \"./interpreter-Cs1cxg-E.mjs\";\nimport { buildSymbolTable, isPrismaNextSchema, mapPslDiagnostics } from \"@internal/psl-parser\";\nimport { parse } from \"@internal/psl-parser/syntax\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { collectScalarTypeConstructors } from \"@internal/framework-components/authoring\";\nimport { withSeedDiagnostics } from \"@internal/psl-parser/interpret\";\nimport { applySqlSpecifierControlPolicy } from \"@internal/sql-contract-ts/contract-builder\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { readFile } from \"node:fs/promises\";\nimport { basename, extname } from \"pathe\";\nimport { isDynamicPattern } from \"tinyglobby\";\n//#region src/provider.ts\n/**\n* The directory portion of `pattern` before its first glob-magic segment,\n* joined back with `/` (e.g. a `prisma` directory holding a recursive\n* `.prisma` glob derives `./prisma`). A rootless pattern with no static\n* segments yields `''`.\n*/\nfunction staticPrefixDirectory(pattern) {\n\tconst staticSegments = [];\n\tfor (const segment of pattern.replaceAll(\"\\\\\", \"/\").split(\"/\")) {\n\t\tif (isDynamicPattern(segment)) break;\n\t\tstaticSegments.push(segment);\n\t}\n\treturn staticSegments.join(\"/\");\n}\n/**\n* Derives the emit output path from the schema input path so artefacts land\n* colocated with the source (e.g. `src/contract/schema.prisma` →\n* `src/contract/contract.json`). A glob-shaped path derives from its static\n* prefix directory instead (a recursive glob under `prisma` derives\n* `./prisma/contract.json`). The provider owns this because it is the only\n* layer that knows the input path; the upstream `normalizeContractConfig`\n* default is a last-resort fallback for providers that don't carry one.\n*/\nfunction defaultOutputFromSchemaPath(schemaPath) {\n\tif (isDynamicPattern(schemaPath)) {\n\t\tconst prefix = staticPrefixDirectory(schemaPath);\n\t\treturn prefix.length === 0 ? \"contract.json\" : `${prefix}/contract.json`;\n\t}\n\tconst ext = extname(schemaPath);\n\tif (ext.length === 0) return `${schemaPath}.json`;\n\tconst base = schemaPath.slice(0, -ext.length);\n\tif (basename(base) === \"schema\") return `${base.slice(0, -6)}contract.json`;\n\treturn `${base}.json`;\n}\nfunction prismaContract(schemaPath, options) {\n\treturn {\n\t\tsource: {\n\t\t\tformat: \"psl\",\n\t\t\tinputs: [schemaPath],\n\t\t\tinterpret(input, context) {\n\t\t\t\tconst scalarColumnDescriptors = collectScalarTypeConstructors(context.authoringContributions.type);\n\t\t\t\treturn interpretPslDocumentToSqlContract({\n\t\t\t\t\tdocuments: input.documents,\n\t\t\t\t\tsymbolTable: input.symbolTable,\n\t\t\t\t\tsources: input.sources,\n\t\t\t\t\tseedDiagnostics: [],\n\t\t\t\t\ttarget: options.target,\n\t\t\t\t\tauthoringContributions: context.authoringContributions,\n\t\t\t\t\tscalarColumnDescriptors,\n\t\t\t\t\t...ifDefined(\"composedExtensions\", context.composedExtensions.length > 0 ? [...context.composedExtensions] : void 0),\n\t\t\t\t\tcomposedExtensionContracts: context.composedExtensionContracts,\n\t\t\t\t\t...ifDefined(\"composedExtensionPackRefs\", options.composedExtensionPackRefs?.length ? options.composedExtensionPackRefs : void 0),\n\t\t\t\t\tcontrolMutationDefaults: context.controlMutationDefaults,\n\t\t\t\t\tcreateNamespace: options.createNamespace,\n\t\t\t\t\tcapabilities: context.capabilities,\n\t\t\t\t\tcodecLookup: context.codecLookup,\n\t\t\t\t\tdataTypeLookup: context.dataTypeLookup,\n\t\t\t\t\t...ifDefined(\"enumInferenceCodecs\", options.enumInferenceCodecs)\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync load(context) {\n\t\t\t\tconst candidates = [...new Set(context.resolvedInputs)].sort();\n\t\t\t\tif (candidates.length === 0) return notOk({\n\t\t\t\t\tsummary: \"No schema files matched the configured contract source\",\n\t\t\t\t\tdiagnostics: [{\n\t\t\t\t\t\tcode: \"PSL_NO_SCHEMA_FILES_MATCHED\",\n\t\t\t\t\t\tmessage: `No files matched the configured pattern \"${schemaPath}\"`,\n\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t}]\n\t\t\t\t});\n\t\t\t\tconst readDiagnostics = [];\n\t\t\t\tconst members = [];\n\t\t\t\tconst undirected = [];\n\t\t\t\tfor (const path of candidates) {\n\t\t\t\t\tlet text;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttext = await readFile(path, \"utf-8\");\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message = String(error);\n\t\t\t\t\t\treadDiagnostics.push({\n\t\t\t\t\t\t\tcode: \"PSL_SCHEMA_READ_FAILED\",\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tsourceId: path\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (isPrismaNextSchema(text)) members.push({\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\ttext\n\t\t\t\t\t});\n\t\t\t\t\telse undirected.push(path);\n\t\t\t\t}\n\t\t\t\tif (members.length === 0) {\n\t\t\t\t\tif (undirected.length === 0) return notOk({\n\t\t\t\t\t\tsummary: \"Failed to read Prisma schema files\",\n\t\t\t\t\t\tdiagnostics: readDiagnostics\n\t\t\t\t\t});\n\t\t\t\t\treturn notOk({\n\t\t\t\t\t\tsummary: \"No schema file carries the \\\"// use prisma-8\\\" directive\",\n\t\t\t\t\t\tdiagnostics: [...readDiagnostics, {\n\t\t\t\t\t\t\tcode: \"PSL_NO_OPTED_IN_SCHEMA_FILES\",\n\t\t\t\t\t\t\tmessage: `None of the matched files carry the \"// use prisma-8\" directive: ${undirected.join(\", \")}`,\n\t\t\t\t\t\t\tsourceId: schemaPath\n\t\t\t\t\t\t}]\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst parsed = members.map(({ path, text }) => parse(text, path));\n\t\t\t\tconst documents = parsed.map(({ document }) => document);\n\t\t\t\tconst [firstSources, ...restSources] = parsed.map(({ sources }) => sources);\n\t\t\t\tassertDefined(firstSources, \"prismaContract requires at least one parsed schema file\");\n\t\t\t\tconst sources = firstSources.merge(...restSources);\n\t\t\t\tconst { symbolTable, diagnostics: symbolTableDiagnostics } = buildSymbolTable({\n\t\t\t\t\tdocuments,\n\t\t\t\t\tsources,\n\t\t\t\t\tpslBlockDescriptors: context.authoringContributions.pslBlockDescriptors\n\t\t\t\t});\n\t\t\t\tconst seedDiagnostics = [...readDiagnostics, ...mapPslDiagnostics([...parsed.flatMap(({ diagnostics }) => diagnostics), ...symbolTableDiagnostics], sources)];\n\t\t\t\tconst interpreted = withSeedDiagnostics(this.interpret({\n\t\t\t\t\tdocuments,\n\t\t\t\t\tsources,\n\t\t\t\t\tsymbolTable\n\t\t\t\t}, context), seedDiagnostics);\n\t\t\t\tif (!interpreted.ok) return interpreted;\n\t\t\t\treturn ok(applySqlSpecifierControlPolicy(interpreted.value, options.defaultControlPolicy, options.createNamespace));\n\t\t\t}\n\t\t},\n\t\toutput: options.output ?? defaultOutputFromSchemaPath(schemaPath)\n\t};\n}\n//#endregion\nexport { prismaContract };\n\n//# sourceMappingURL=provider.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,SAAS,sBAAsB,SAAS;CACvC,MAAM,iBAAiB,CAAC;CACxB,KAAK,MAAM,WAAW,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,GAAG;EAC/D,IAAI,iBAAiB,OAAO,GAAG;EAC/B,eAAe,KAAK,OAAO;CAC5B;CACA,OAAO,eAAe,KAAK,GAAG;AAC/B;;;;;;;;;;AAUA,SAAS,4BAA4B,YAAY;CAChD,IAAI,iBAAiB,UAAU,GAAG;EACjC,MAAM,SAAS,sBAAsB,UAAU;EAC/C,OAAO,OAAO,WAAW,IAAI,kBAAkB,GAAG,OAAO;CAC1D;CACA,MAAM,MAAM,QAAQ,UAAU;CAC9B,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,WAAW;CAC3C,MAAM,OAAO,WAAW,MAAM,GAAG,CAAC,IAAI,MAAM;CAC5C,IAAI,SAAS,IAAI,MAAM,UAAU,OAAO,GAAG,KAAK,MAAM,GAAG,EAAE,EAAE;CAC7D,OAAO,GAAG,KAAK;AAChB;AACA,SAAS,eAAe,YAAY,SAAS;CAC5C,OAAO;EACN,QAAQ;GACP,QAAQ;GACR,QAAQ,CAAC,UAAU;GACnB,UAAU,OAAO,SAAS;IACzB,MAAM,0BAA0B,8BAA8B,QAAQ,uBAAuB,IAAI;IACjG,OAAO,kCAAkC;KACxC,WAAW,MAAM;KACjB,aAAa,MAAM;KACnB,SAAS,MAAM;KACf,iBAAiB,CAAC;KAClB,QAAQ,QAAQ;KAChB,wBAAwB,QAAQ;KAChC;KACA,GAAG,UAAU,sBAAsB,QAAQ,mBAAmB,SAAS,IAAI,CAAC,GAAG,QAAQ,kBAAkB,IAAI,KAAK,CAAC;KACnH,4BA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AE,eAAe,QAAQ;IACvD,MAAM,CAAC,cAAc,GAAG,eAAe,OAAO,KAAK,EAAE,cAAc,OAAO;IAC1E,cAAc,cAAc,yDAAyD;IACrF,MAAM,UAAU,aAAa,MAAM,GAAG,WAAW;IACjD,MAAM,EAAE,aAAa,aAAa,2BAA2B,iBAAiB;KAC7E;KACA;KACA,qBAAqB,QAAQ,uBAAuB;IACrD,CAAC;IACD,MAAM,kBAAkB,CAAC,GAAG,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,OAAO,SAAS,EAAE,kBAAkB,WAAW,GAAG,GAAG,sBAAsB,GAAG,OAAO,CAAC;IAC5J,MAAM,cAAc,oBAAoB,KAAK,UAAU;KACtD;KACA;KACA;IACD,GAAG,OAAO,GAAG,eAAe;IAC5B,IAAI,CAAC,YAAY,IAAI,OAAO;IAC5B,OAAO,GAAG,+BAA+B,YAAY,OAAO,QAAQ,sBAAsB,QAAQ,eAAe,CAAC;GACnH;EACD;EACA,QAAQ,QAAQ,UAAU,4BAA4B,UAAU;CACjE;AACD"}
@@ -1,4 +1,4 @@
1
1
  import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-6WZKIUxH-CWip2UN5.mjs";
2
2
  import { a as check, c as extensionModel, d as model, f as now, i as buildContractDefinition, l as field, m as sql, n as bindEnumType, o as defineContract, p as rel, r as buildBoundContract, s as enumType, t as autoincrement, u as member } from "./contract-builder-IOKzKHhU.mjs";
3
- import { n as typescriptContract, r as typescriptContractFromPath, t as emptyContract } from "./config-types-B1S5_Raa.mjs";
3
+ import { n as typescriptContract, r as typescriptContractFromPath, t as emptyContract } from "./config-types-DLERgC8A.mjs";
4
4
  export { applySqlSpecifierControlPolicy, autoincrement, bindEnumType, buildBoundContract, buildContractDefinition, buildSqlContractFromDefinition, check, defineContract, emptyContract, enumType, extensionModel, field, member, model, now, rel, sql, typescriptContract, typescriptContractFromPath };
@@ -1,2 +1,2 @@
1
- import { n as typescriptContract, r as typescriptContractFromPath, t as emptyContract } from "./config-types-B1S5_Raa.mjs";
1
+ import { n as typescriptContract, r as typescriptContractFromPath, t as emptyContract } from "./config-types-DLERgC8A.mjs";
2
2
  export { emptyContract, typescriptContract, typescriptContractFromPath };
@@ -17,7 +17,7 @@ import { describeTaggedLiteralFailure } from "@prisma/orm-framework/components/c
17
17
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
18
18
  import { createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, keywordPslSpan, nodePslSpan } from "@prisma/orm-framework/psl-parser";
19
19
  import { consumeInvalidFkPairing, fkRelationPairKey, requiredOneToOneBackrelationDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
20
- //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-BcaXUphN.mjs
20
+ //#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-Cs1cxg-E.mjs
21
21
  function contractError(code, message, options) {
22
22
  return structuredError(code, message, options);
23
23
  }
@@ -1194,45 +1194,54 @@ function lowerDefaultForField(input) {
1194
1194
  kind: "number",
1195
1195
  text: value.text
1196
1196
  });
1197
- const lowered = "tag" in value ? lowerTaggedLiteral(value, input.dataTypeSupport, context, source) : lowerDefaultFunctionWithRegistry({
1198
- call: value,
1199
- registry: input.defaultFunctionRegistry,
1200
- context,
1201
- source
1202
- });
1203
- if (!lowered.ok) {
1204
- if (lowered.kind === "owned") input.diagnostics.push(lowered.diagnostic);
1205
- else input.diagnostics.pushExternal(lowered.diagnostic);
1206
- return {};
1207
- }
1208
- if ("written" in lowered) return readAsLiteral(lowered.written);
1209
- if (lowered.value.kind === "storage") return { defaultValue: lowered.value.defaultValue };
1210
- const generatorDescriptor = input.generatorDescriptorById.get(lowered.value.generated.id);
1211
- if (!generatorDescriptor) {
1212
- input.diagnostics.push({
1213
- code: "PSL_INVALID_DEFAULT_APPLICABILITY",
1214
- message: `Default generator "${lowered.value.generated.id}" is not available in the composed mutation default registry.`,
1215
- ...source.at(value.span)
1216
- });
1217
- return {};
1218
- }
1219
- if (generatorDescriptor.applicableCodecIds === void 0) {
1220
- input.diagnostics.push({
1221
- code: "PSL_INVALID_DEFAULT_APPLICABILITY",
1222
- message: `Default generator "${generatorDescriptor.id}" is not applicable to "@default(...)" lowering. Use the corresponding field preset (e.g. \`temporal.${generatorDescriptor.id === "timestampNow" ? "updatedAt" : generatorDescriptor.id}()\`) instead.`,
1223
- ...source.at(value.span)
1224
- });
1225
- return {};
1226
- }
1227
- if (!generatorDescriptor.applicableCodecIds.includes(input.columnDescriptor.codecId)) {
1228
- input.diagnostics.push({
1229
- code: "PSL_INVALID_DEFAULT_APPLICABILITY",
1230
- message: `Default generator "${generatorDescriptor.id}" is not applicable to "${input.modelName}.${input.fieldName}" with codecId "${input.columnDescriptor.codecId}".`,
1231
- ...source.at(value.span)
1197
+ if (typeof value === "object") {
1198
+ const context = {
1199
+ sourceId: input.sources.sourceFileFor(node.syntax).filename,
1200
+ modelName: input.modelName,
1201
+ fieldName: input.fieldName,
1202
+ columnCodecId: input.columnDescriptor.codecId
1203
+ };
1204
+ const lowered = "tag" in value ? lowerTaggedLiteral(value, input.dataTypeSupport, context, source) : lowerDefaultFunctionWithRegistry({
1205
+ call: value,
1206
+ registry: input.defaultFunctionRegistry,
1207
+ context,
1208
+ source
1232
1209
  });
1233
- return {};
1210
+ if (!lowered.ok) {
1211
+ if (lowered.kind === "owned") input.diagnostics.push(lowered.diagnostic);
1212
+ else input.diagnostics.pushExternal(lowered.diagnostic);
1213
+ return {};
1214
+ }
1215
+ if ("written" in lowered) return readAsLiteral(lowered.written);
1216
+ if (lowered.value.kind === "storage") return { defaultValue: lowered.value.defaultValue };
1217
+ const generatorDescriptor = input.generatorDescriptorById.get(lowered.value.generated.id);
1218
+ if (!generatorDescriptor) {
1219
+ input.diagnostics.push({
1220
+ code: "PSL_INVALID_DEFAULT_APPLICABILITY",
1221
+ message: `Default generator "${lowered.value.generated.id}" is not available in the composed mutation default registry.`,
1222
+ ...source.at(value.span)
1223
+ });
1224
+ return {};
1225
+ }
1226
+ if (generatorDescriptor.applicableCodecIds === void 0) {
1227
+ input.diagnostics.push({
1228
+ code: "PSL_INVALID_DEFAULT_APPLICABILITY",
1229
+ message: `Default generator "${generatorDescriptor.id}" is not applicable to "@default(...)" lowering. Use the corresponding field preset (e.g. \`temporal.${generatorDescriptor.id === "timestampNow" ? "updatedAt" : generatorDescriptor.id}()\`) instead.`,
1230
+ ...source.at(value.span)
1231
+ });
1232
+ return {};
1233
+ }
1234
+ if (!generatorDescriptor.applicableCodecIds.includes(input.columnDescriptor.codecId)) {
1235
+ input.diagnostics.push({
1236
+ code: "PSL_INVALID_DEFAULT_APPLICABILITY",
1237
+ message: `Default generator "${generatorDescriptor.id}" is not applicable to "${input.modelName}.${input.fieldName}" with codecId "${input.columnDescriptor.codecId}".`,
1238
+ ...source.at(value.span)
1239
+ });
1240
+ return {};
1241
+ }
1242
+ return { executionDefaults: { onCreate: lowered.value.generated } };
1234
1243
  }
1235
- return { executionDefaults: { onCreate: lowered.value.generated } };
1244
+ return {};
1236
1245
  }
1237
1246
  function resolveColumnDescriptor(field, enumTypeDescriptors, namedTypeDescriptors, scalarColumnDescriptors) {
1238
1247
  if (namedTypeDescriptors.has(field.typeName)) return namedTypeDescriptors.get(field.typeName);
@@ -3492,30 +3501,12 @@ function stripStorageOnlyDomainFields(model, fieldNames) {
3492
3501
  };
3493
3502
  }
3494
3503
  function interpretPslDocumentToSqlContract(input) {
3495
- const source = diagnosticSource(input.sources, input.document.syntax);
3504
+ if (!input.target) throw new InternalError("PSL interpretation requires an explicit target context from composition.");
3505
+ if (!input.scalarColumnDescriptors) throw new InternalError("PSL interpretation requires composed scalar type descriptors.");
3506
+ const [anchorDocument] = input.documents;
3507
+ assertDefined(anchorDocument, "interpretPslDocumentToSqlContract requires at least one document");
3508
+ const source = diagnosticSource(input.sources, anchorDocument.syntax);
3496
3509
  const diagnostics = createPslDiagnosticCollector(input.sources);
3497
- if (!input.target) {
3498
- diagnostics.pushUnlocated({
3499
- code: "PSL_TARGET_CONTEXT_REQUIRED",
3500
- message: "PSL interpretation requires an explicit target context from composition.",
3501
- ...source.at()
3502
- });
3503
- return notOk({
3504
- summary: "PSL to SQL contract interpretation failed",
3505
- diagnostics: diagnostics.toExternal()
3506
- });
3507
- }
3508
- if (!input.scalarColumnDescriptors) {
3509
- diagnostics.pushUnlocated({
3510
- code: "PSL_SCALAR_TYPE_CONTEXT_REQUIRED",
3511
- message: "PSL interpretation requires composed scalar type descriptors.",
3512
- ...source.at()
3513
- });
3514
- return notOk({
3515
- summary: "PSL to SQL contract interpretation failed",
3516
- diagnostics: diagnostics.toExternal()
3517
- });
3518
- }
3519
3510
  const { topLevel } = input.symbolTable;
3520
3511
  const namespaceSymbols = Object.values(topLevel.namespaces);
3521
3512
  validateNamespaceBlocksForSqlTarget({
@@ -3902,4 +3893,4 @@ function interpretPslDocumentToSqlContract(input) {
3902
3893
  //#endregion
3903
3894
  export { interpretPslDocumentToSqlContract as a, resolveFieldTypeDescriptor as c, indexFkRelations as i, buildEntityTypesByDiscriminator as n, normalizeReferentialAction as o, entryForTag as r, readDataTypeDefault as s, applyBackrelationCandidates as t };
3904
3895
 
3905
- //# sourceMappingURL=interpreter-BcaXUphN-C0qZ0ypa.mjs.map
3896
+ //# sourceMappingURL=interpreter-Cs1cxg-E-N_DDfih-.mjs.map