@prisma-next/sql-contract-psl 0.0.1

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/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @prisma-next/sql-contract-psl
2
+
3
+ PSL-first SQL contract interpretation and provider composition for Prisma Next.
4
+
5
+ ## Overview
6
+
7
+ `@prisma-next/sql-contract-psl` provides two entrypoints:
8
+
9
+ - **Pure interpreter** (`@prisma-next/sql-contract-psl`): parsed PSL document -> SQL `ContractIR`
10
+ - **Provider helper** (`@prisma-next/sql-contract-psl/provider`): read file -> parse -> interpret -> `ContractConfig`
11
+
12
+ This keeps core/CLI source-agnostic while giving PSL-first SQL users a one-line config helper.
13
+
14
+ ## Responsibilities
15
+
16
+ - Interpret `ParsePslDocumentResult` into SQL `ContractIR`
17
+ - Interpret generic PSL attributes into SQL contract semantics (`@id`, `@unique`, `@default`, `@relation`, `@map`, `@@map`)
18
+ - Support pgvector parity mapping from PSL attributes to existing TS-representable descriptor shape (`codecId`, `nativeType`, `typeParams`)
19
+ - Map PSL relation action tokens to SQL contract referential actions and emit diagnostics for unsupported values
20
+ - Enforce extension composition for supported namespaced attributes (for example `@pgvector.column(...)`)
21
+ - Compose provider flow for SQL PSL-first config (`read -> parse -> interpret`)
22
+ - Preserve parser diagnostics and add interpreter diagnostics with stable codes
23
+ - Return `notOk` with structured diagnostics for unsupported constructs
24
+ - Keep interpretation deterministic for equivalent AST inputs
25
+
26
+ ## Non-responsibilities
27
+
28
+ - Canonical artifact emission (`contract.json`, `contract.d.ts`) and hashing
29
+ - CLI or ControlClient orchestration
30
+
31
+ The **pure interpreter entrypoint** specifically excludes:
32
+ - File I/O (`schema.prisma` reading)
33
+ - PSL parsing (`parsePslDocument`)
34
+ - Artifact emission (`contract.json`, `contract.d.ts`) and hashing
35
+ - CLI or ControlClient orchestration
36
+
37
+ Current scope is SQL/Postgres-first: scalar and enum mappings resolve to Postgres codec/native type descriptors in v1.
38
+
39
+ ## Public API
40
+
41
+ - `@prisma-next/sql-contract-psl`
42
+ - `interpretPslDocumentToSqlContractIR({ document, target? })`
43
+ - `@prisma-next/sql-contract-psl/provider`
44
+ - `prismaContract(schemaPath, { output?, target?, composedExtensionPacks? })`
45
+ - `composedExtensionPacks` is currently a milestone-local string-id hook for namespace
46
+ availability checks (for example `['pgvector']`); plan to evolve to richer composed pack
47
+ metadata/manifest inputs before broadening namespaced-attribute validation.
48
+
49
+ ## Dependencies
50
+
51
+ - **Depends on**
52
+ - `@prisma-next/psl-parser` for parser + parser result types
53
+ - `@prisma-next/sql-contract-ts` for SQL authoring builder composition
54
+ - `@prisma-next/core-control-plane` for contract source diagnostics types
55
+ - `pathe` for provider path resolution
56
+ - `@prisma-next/contract` and `@prisma-next/utils`
57
+ - **Used by**
58
+ - PSL contract providers configured via `contract.source`
59
+
60
+ ## Architecture
61
+
62
+ ```mermaid
63
+ flowchart LR
64
+ config[prisma-next.config.ts] --> providerHelper[@prisma-next/sql-contract-psl/provider]
65
+ providerHelper --> fsRead[read schema.prisma]
66
+ fsRead --> parser[@prisma-next/psl-parser]
67
+ parser --> parsed[ParsePslDocumentResult]
68
+ parsed --> interpreter[@prisma-next/sql-contract-psl]
69
+ interpreter --> irResult[Result_ContractIR_Diagnostics]
70
+ irResult --> emit[Framework emit pipeline]
71
+ ```
72
+
73
+ ## Related Docs
74
+
75
+ - `docs/Architecture Overview.md`
76
+ - `docs/architecture docs/subsystems/1. Data Contract.md`
77
+ - `docs/architecture docs/subsystems/2. Contract Emitter & Types.md`
78
+ - `docs/architecture docs/adrs/ADR 006 - Dual Authoring Modes.md`
79
+ - `docs/architecture docs/adrs/ADR 163 - Provider-invoked source interpretation packages.md`
@@ -0,0 +1,16 @@
1
+ import { Result } from "@prisma-next/utils/result";
2
+ import { ParsePslDocumentResult } from "@prisma-next/psl-parser";
3
+ import { ContractSourceDiagnostics } from "@prisma-next/config/config-types";
4
+ import { TargetPackRef } from "@prisma-next/contract/framework-components";
5
+ import { ContractIR } from "@prisma-next/contract/ir";
6
+
7
+ //#region src/interpreter.d.ts
8
+ interface InterpretPslDocumentToSqlContractIRInput {
9
+ readonly document: ParsePslDocumentResult;
10
+ readonly target?: TargetPackRef<'sql', 'postgres'>;
11
+ readonly composedExtensionPacks?: readonly string[];
12
+ }
13
+ declare function interpretPslDocumentToSqlContractIR(input: InterpretPslDocumentToSqlContractIRInput): Result<ContractIR, ContractSourceDiagnostics>;
14
+ //#endregion
15
+ export { type InterpretPslDocumentToSqlContractIRInput, interpretPslDocumentToSqlContractIR };
16
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/interpreter.ts"],"sourcesContent":[],"mappings":";;;;;;;UAyBiB,wCAAA;qBACI;EADJ,SAAA,MAAA,CAAA,EAEG,aAFH,CAAA,KAAA,EAAA,UAAwC,CAAA;EAulBzC,SAAA,sBAAA,CAAA,EAAA,SAAmC,MAAA,EAAA;;AAEzC,iBAFM,mCAAA,CAEN,KAAA,EADD,wCACC,CAAA,EAAP,MAAO,CAAA,UAAA,EAAY,yBAAZ,CAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { t as interpretPslDocumentToSqlContractIR } from "./interpreter-_6-Xk1_m.mjs";
2
+
3
+ export { interpretPslDocumentToSqlContractIR };