@prisma-next/psl-parser 0.14.0-dev.73 → 0.14.0-dev.75

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.
@@ -1,6 +1,8 @@
1
1
  import { c as DocumentAst, et as SourceFile } from "./parse-BazJr7Ye.mjs";
2
2
  import { l as SymbolTable } from "./symbol-table-C-AH04Ug.mjs";
3
- import { ContractSourceContext, ContractSourceDiagnostic, ContractSourceProvider, PslContractSourceProvider } from "@prisma-next/config/config-types";
3
+ import { Result } from "@prisma-next/utils/result";
4
+ import { ContractSourceContext, ContractSourceDiagnostic, ContractSourceDiagnostics, ContractSourceProvider, PslContractSourceProvider } from "@prisma-next/config/config-types";
5
+ import { Contract } from "@prisma-next/contract/types";
4
6
 
5
7
  //#region src/interpret.d.ts
6
8
  /**
@@ -20,10 +22,17 @@ interface PslInterpretInput {
20
22
  * types.
21
23
  */
22
24
  interface PslInterpretCapable extends PslContractSourceProvider {
23
- interpret(input: PslInterpretInput, context: ContractSourceContext): readonly ContractSourceDiagnostic[];
25
+ interpret(input: PslInterpretInput, context: ContractSourceContext): Result<Contract, ContractSourceDiagnostics>;
24
26
  }
27
+ /**
28
+ * Merges caller-side diagnostics (e.g. parse / symbol-table findings) into an
29
+ * interpretation result. The authored headline is deliberately uniform — it
30
+ * reports how many errors the schema has, never which pipeline stage found
31
+ * them.
32
+ */
33
+ declare function withSeedDiagnostics(result: Result<Contract, ContractSourceDiagnostics>, seedDiagnostics: readonly ContractSourceDiagnostic[]): Result<Contract, ContractSourceDiagnostics>;
25
34
  /** The single seam that narrows a contract source to the interpret capability. */
26
35
  declare function hasPslInterpreter(source: ContractSourceProvider): source is PslInterpretCapable;
27
36
  //#endregion
28
- export { type PslInterpretCapable, type PslInterpretInput, hasPslInterpreter };
37
+ export { type PslInterpretCapable, type PslInterpretInput, hasPslInterpreter, withSeedDiagnostics };
29
38
  //# sourceMappingURL=interpret.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interpret.d.mts","names":[],"sources":["../src/interpret.ts"],"mappings":";;;;;;AAeA;;;;UAAiB,iBAAA;EAAA,SACN,QAAA,EAAU,WAAA;EAAA,SACV,UAAA,EAAY,UAAA;EAAA,SACZ,WAAA,EAAa,WAAA;EAAA,SACb,QAAA;AAAA;;;;;;UAQM,mBAAA,SAA4B,yBAAA;EAC3C,SAAA,CACE,KAAA,EAAO,iBAAA,EACP,OAAA,EAAS,qBAAA,YACC,wBAAA;AAAA;;iBAIE,iBAAA,CAAkB,MAAA,EAAQ,sBAAA,GAAyB,MAAA,IAAU,mBAAmB"}
1
+ {"version":3,"file":"interpret.d.mts","names":[],"sources":["../src/interpret.ts"],"mappings":";;;;;;;;AAkBA;;;;UAAiB,iBAAA;EAAA,SACN,QAAA,EAAU,WAAA;EAAA,SACV,UAAA,EAAY,UAAA;EAAA,SACZ,WAAA,EAAa,WAAA;EAAA,SACb,QAAA;AAAA;;;;;;UAQM,mBAAA,SAA4B,yBAAA;EAC3C,SAAA,CACE,KAAA,EAAO,iBAAA,EACP,OAAA,EAAS,qBAAA,GACR,MAAA,CAAO,QAAA,EAAU,yBAAA;AAAA;;;;;;;iBASN,mBAAA,CACd,MAAA,EAAQ,MAAA,CAAO,QAAA,EAAU,yBAAA,GACzB,eAAA,WAA0B,wBAAA,KACzB,MAAA,CAAO,QAAA,EAAU,yBAAA;;iBAeJ,iBAAA,CAAkB,MAAA,EAAQ,sBAAA,GAAyB,MAAA,IAAU,mBAAmB"}
@@ -1,9 +1,25 @@
1
+ import { notOk } from "@prisma-next/utils/result";
1
2
  //#region src/interpret.ts
3
+ /**
4
+ * Merges caller-side diagnostics (e.g. parse / symbol-table findings) into an
5
+ * interpretation result. The authored headline is deliberately uniform — it
6
+ * reports how many errors the schema has, never which pipeline stage found
7
+ * them.
8
+ */
9
+ function withSeedDiagnostics(result, seedDiagnostics) {
10
+ if (seedDiagnostics.length === 0) return result;
11
+ const diagnostics = result.ok ? seedDiagnostics : [...seedDiagnostics, ...result.failure.diagnostics];
12
+ return notOk({
13
+ summary: `Schema has ${diagnostics.length} error${diagnostics.length === 1 ? "" : "s"}`,
14
+ diagnostics,
15
+ ...result.ok || result.failure.meta === void 0 ? {} : { meta: result.failure.meta }
16
+ });
17
+ }
2
18
  /** The single seam that narrows a contract source to the interpret capability. */
3
19
  function hasPslInterpreter(source) {
4
20
  return source.sourceFormat === "psl" && "interpret" in source && typeof source.interpret === "function";
5
21
  }
6
22
  //#endregion
7
- export { hasPslInterpreter };
23
+ export { hasPslInterpreter, withSeedDiagnostics };
8
24
 
9
25
  //# sourceMappingURL=interpret.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"interpret.mjs","names":[],"sources":["../src/interpret.ts"],"sourcesContent":["import type {\n ContractSourceContext,\n ContractSourceDiagnostic,\n ContractSourceProvider,\n PslContractSourceProvider,\n} from '@prisma-next/config/config-types';\nimport type { SourceFile } from './source-file';\nimport type { SymbolTable } from './symbol-table';\nimport type { DocumentAst } from './syntax/ast/declarations';\n\n/**\n * Lets editor tooling that already parses incrementally (e.g. the language\n * server) hand cached artifacts to the interpreter instead of forcing a\n * disk re-parse.\n */\nexport interface PslInterpretInput {\n readonly document: DocumentAst;\n readonly sourceFile: SourceFile;\n readonly symbolTable: SymbolTable;\n readonly sourceId: string;\n}\n\n/**\n * Declared here — the authoring layer that owns `DocumentAst` / `SourceFile` /\n * `SymbolTable` — because `@prisma-next/config` (core) cannot name authoring\n * types.\n */\nexport interface PslInterpretCapable extends PslContractSourceProvider {\n interpret(\n input: PslInterpretInput,\n context: ContractSourceContext,\n ): readonly ContractSourceDiagnostic[];\n}\n\n/** The single seam that narrows a contract source to the interpret capability. */\nexport function hasPslInterpreter(source: ContractSourceProvider): source is PslInterpretCapable {\n return (\n source.sourceFormat === 'psl' && 'interpret' in source && typeof source.interpret === 'function'\n );\n}\n"],"mappings":";;AAmCA,SAAgB,kBAAkB,QAA+D;CAC/F,OACE,OAAO,iBAAiB,SAAS,eAAe,UAAU,OAAO,OAAO,cAAc;AAE1F"}
1
+ {"version":3,"file":"interpret.mjs","names":[],"sources":["../src/interpret.ts"],"sourcesContent":["import type {\n ContractSourceContext,\n ContractSourceDiagnostic,\n ContractSourceDiagnostics,\n ContractSourceProvider,\n PslContractSourceProvider,\n} from '@prisma-next/config/config-types';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { notOk, type Result } from '@prisma-next/utils/result';\nimport type { SourceFile } from './source-file';\nimport type { SymbolTable } from './symbol-table';\nimport type { DocumentAst } from './syntax/ast/declarations';\n\n/**\n * Lets editor tooling that already parses incrementally (e.g. the language\n * server) hand cached artifacts to the interpreter instead of forcing a\n * disk re-parse.\n */\nexport interface PslInterpretInput {\n readonly document: DocumentAst;\n readonly sourceFile: SourceFile;\n readonly symbolTable: SymbolTable;\n readonly sourceId: string;\n}\n\n/**\n * Declared here — the authoring layer that owns `DocumentAst` / `SourceFile` /\n * `SymbolTable` — because `@prisma-next/config` (core) cannot name authoring\n * types.\n */\nexport interface PslInterpretCapable extends PslContractSourceProvider {\n interpret(\n input: PslInterpretInput,\n context: ContractSourceContext,\n ): Result<Contract, ContractSourceDiagnostics>;\n}\n\n/**\n * Merges caller-side diagnostics (e.g. parse / symbol-table findings) into an\n * interpretation result. The authored headline is deliberately uniform — it\n * reports how many errors the schema has, never which pipeline stage found\n * them.\n */\nexport function withSeedDiagnostics(\n result: Result<Contract, ContractSourceDiagnostics>,\n seedDiagnostics: readonly ContractSourceDiagnostic[],\n): Result<Contract, ContractSourceDiagnostics> {\n if (seedDiagnostics.length === 0) {\n return result;\n }\n const diagnostics = result.ok\n ? seedDiagnostics\n : [...seedDiagnostics, ...result.failure.diagnostics];\n return notOk({\n summary: `Schema has ${diagnostics.length} error${diagnostics.length === 1 ? '' : 's'}`,\n diagnostics,\n ...(result.ok || result.failure.meta === undefined ? {} : { meta: result.failure.meta }),\n });\n}\n\n/** The single seam that narrows a contract source to the interpret capability. */\nexport function hasPslInterpreter(source: ContractSourceProvider): source is PslInterpretCapable {\n return (\n source.sourceFormat === 'psl' && 'interpret' in source && typeof source.interpret === 'function'\n );\n}\n"],"mappings":";;;;;;;;AA2CA,SAAgB,oBACd,QACA,iBAC6C;CAC7C,IAAI,gBAAgB,WAAW,GAC7B,OAAO;CAET,MAAM,cAAc,OAAO,KACvB,kBACA,CAAC,GAAG,iBAAiB,GAAG,OAAO,QAAQ,WAAW;CACtD,OAAO,MAAM;EACX,SAAS,cAAc,YAAY,OAAO,QAAQ,YAAY,WAAW,IAAI,KAAK;EAClF;EACA,GAAI,OAAO,MAAM,OAAO,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO,QAAQ,KAAK;CACxF,CAAC;AACH;;AAGA,SAAgB,kBAAkB,QAA+D;CAC/F,OACE,OAAO,iBAAiB,SAAS,eAAe,UAAU,OAAO,OAAO,cAAc;AAE1F"}
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@prisma-next/psl-parser",
3
- "version": "0.14.0-dev.73",
3
+ "version": "0.14.0-dev.75",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Reusable parser for Prisma Schema Language (PSL)",
8
8
  "dependencies": {
9
- "@prisma-next/config": "0.14.0-dev.73",
10
- "@prisma-next/framework-components": "0.14.0-dev.73",
11
- "@prisma-next/utils": "0.14.0-dev.73"
9
+ "@prisma-next/config": "0.14.0-dev.75",
10
+ "@prisma-next/contract": "0.14.0-dev.75",
11
+ "@prisma-next/framework-components": "0.14.0-dev.75",
12
+ "@prisma-next/utils": "0.14.0-dev.75"
12
13
  },
13
14
  "devDependencies": {
14
- "@prisma-next/tsconfig": "0.14.0-dev.73",
15
- "@prisma-next/tsdown": "0.14.0-dev.73",
15
+ "@prisma-next/tsconfig": "0.14.0-dev.75",
16
+ "@prisma-next/tsdown": "0.14.0-dev.75",
16
17
  "tsdown": "0.22.3",
17
18
  "typescript": "5.9.3",
18
19
  "vitest": "4.1.10"
@@ -1,2 +1,2 @@
1
1
  export type { PslInterpretCapable, PslInterpretInput } from '../interpret';
2
- export { hasPslInterpreter } from '../interpret';
2
+ export { hasPslInterpreter, withSeedDiagnostics } from '../interpret';
package/src/interpret.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import type {
2
2
  ContractSourceContext,
3
3
  ContractSourceDiagnostic,
4
+ ContractSourceDiagnostics,
4
5
  ContractSourceProvider,
5
6
  PslContractSourceProvider,
6
7
  } from '@prisma-next/config/config-types';
8
+ import type { Contract } from '@prisma-next/contract/types';
9
+ import { notOk, type Result } from '@prisma-next/utils/result';
7
10
  import type { SourceFile } from './source-file';
8
11
  import type { SymbolTable } from './symbol-table';
9
12
  import type { DocumentAst } from './syntax/ast/declarations';
@@ -29,7 +32,30 @@ export interface PslInterpretCapable extends PslContractSourceProvider {
29
32
  interpret(
30
33
  input: PslInterpretInput,
31
34
  context: ContractSourceContext,
32
- ): readonly ContractSourceDiagnostic[];
35
+ ): Result<Contract, ContractSourceDiagnostics>;
36
+ }
37
+
38
+ /**
39
+ * Merges caller-side diagnostics (e.g. parse / symbol-table findings) into an
40
+ * interpretation result. The authored headline is deliberately uniform — it
41
+ * reports how many errors the schema has, never which pipeline stage found
42
+ * them.
43
+ */
44
+ export function withSeedDiagnostics(
45
+ result: Result<Contract, ContractSourceDiagnostics>,
46
+ seedDiagnostics: readonly ContractSourceDiagnostic[],
47
+ ): Result<Contract, ContractSourceDiagnostics> {
48
+ if (seedDiagnostics.length === 0) {
49
+ return result;
50
+ }
51
+ const diagnostics = result.ok
52
+ ? seedDiagnostics
53
+ : [...seedDiagnostics, ...result.failure.diagnostics];
54
+ return notOk({
55
+ summary: `Schema has ${diagnostics.length} error${diagnostics.length === 1 ? '' : 's'}`,
56
+ diagnostics,
57
+ ...(result.ok || result.failure.meta === undefined ? {} : { meta: result.failure.meta }),
58
+ });
33
59
  }
34
60
 
35
61
  /** The single seam that narrows a contract source to the interpret capability. */