@prisma-next/psl-printer 0.5.0-dev.9 → 0.6.0-dev.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 CHANGED
@@ -4,29 +4,25 @@
4
4
  > and is published only to support its runtime. Its API is unstable and may change
5
5
  > without notice. Do not depend on this package directly; install `prisma-next` instead.
6
6
 
7
- Prints Prisma Schema Language (PSL) from introspected SQL schema IR.
7
+ Prints Prisma Schema Language (PSL) from `PslDocumentAst` (`@prisma-next/framework-components/psl-ast`).
8
8
 
9
9
  ## Overview
10
10
 
11
- `@prisma-next/psl-printer` converts `SqlSchemaIR` into deterministic PSL text for brownfield authoring and database introspection flows. It is intentionally printer-only: database inspection, semantic verification, and contract emission stay in adjacent packages.
11
+ `@prisma-next/psl-printer` renders deterministic PSL text from a `PslDocumentAst` (defined in `@prisma-next/framework-components/psl-ast`). The package is target-agnostic: SQL AST construction lives in the SQL family (`@prisma-next/family-sql`'s `inferPslContract` capability).
12
12
 
13
13
  ## Responsibilities
14
14
 
15
- - Convert `SqlSchemaIR` tables, relations, enums, defaults, and indexes into valid PSL output.
16
- - Normalize database names into stable PSL identifiers while preserving original names with `@map` and `@@map`.
17
- - Preserve storage-level defaults when PSL client-side defaults would change semantics.
18
- - Generate deterministic output so round-tripping and snapshot-based tests remain stable.
19
- - Surface unsupported types and raw defaults in a way that keeps the emitted PSL readable.
15
+ - Convert structured AST (`model`, `field`, `enum`, `types`) into valid PSL output.
16
+ - Preserve `@map` / `@@map` and relation attributes from AST nodes.
17
+ - Generate deterministic output so snapshot-based tests remain stable.
20
18
 
21
19
  ## Dependencies
22
20
 
23
21
  - **Depends on**
24
- - `@prisma-next/contract`
25
- - `@prisma-next/sql-schema-ir`
26
- - `@prisma-next/utils`
22
+ - `@prisma-next/framework-components`
27
23
  - **Used by**
28
- - `@prisma-next/cli` for `db introspect`
29
- - future authoring and emit flows that need PSL output from SQL schema IR
24
+ - `@prisma-next/cli` (consumes `printPsl(ast)` after the SQL family produces the AST)
25
+ - `@prisma-next/family-sql` (tests; consumes the printer to verify AST construction)
30
26
 
31
27
  ## Related Docs
32
28
 
package/dist/index.d.mts CHANGED
@@ -1,45 +1,7 @@
1
- import { i as PslTypeResolution, n as PslPrinterOptions, r as PslTypeMap, t as EnumInfo } from "./types-BmnVaMF1.mjs";
2
- import { ColumnDefault } from "@prisma-next/contract/types";
3
- import { PrimaryKey, SqlAnnotations, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
1
+ import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
4
2
 
5
- //#region src/schema-validation.d.ts
6
- type PrintableSqlColumnDefault = string | ColumnDefault;
7
- type PslPrintableSqlColumn = {
8
- readonly name: string;
9
- readonly nativeType: string;
10
- readonly nullable: boolean;
11
- readonly default?: PrintableSqlColumnDefault;
12
- readonly annotations?: SqlAnnotations;
13
- };
14
- type PslPrintableSqlTable = {
15
- readonly name: string;
16
- readonly columns: Record<string, PslPrintableSqlColumn>;
17
- readonly primaryKey?: PrimaryKey;
18
- readonly foreignKeys: readonly SqlForeignKeyIR[];
19
- readonly uniques: readonly SqlUniqueIR[];
20
- readonly indexes: readonly SqlIndexIR[];
21
- readonly annotations?: SqlAnnotations;
22
- };
23
- type PslPrintableSqlSchemaIR = Omit<SqlSchemaIR, 'tables'> & {
24
- readonly tables: Record<string, PslPrintableSqlTable>;
25
- };
26
- declare function validatePrintableSqlSchemaIR(value: unknown): PslPrintableSqlSchemaIR;
27
- //#endregion
28
3
  //#region src/print-psl.d.ts
29
- /**
30
- * Converts a SqlSchemaIR to a PSL (Prisma Schema Language) string.
31
- *
32
- * The output follows PSL formatting conventions:
33
- * - Header comment
34
- * - `types` block (if parameterized types exist)
35
- * - `enum` blocks (alphabetical)
36
- * - `model` blocks (topologically sorted by FK deps, alphabetical fallback)
37
- *
38
- * @param schemaIR - The introspected schema IR
39
- * @param options - Printer configuration (type map, header)
40
- * @returns A valid PSL string
41
- */
42
- declare function printPsl(schemaIR: PslPrintableSqlSchemaIR, options: PslPrinterOptions): string;
4
+ declare function printPslFromAst(ast: PslDocumentAst): string;
43
5
  //#endregion
44
- export { type EnumInfo, type PslPrintableSqlColumn, type PslPrintableSqlSchemaIR, type PslPrintableSqlTable, type PslPrinterOptions, type PslTypeMap, type PslTypeResolution, printPsl, validatePrintableSqlSchemaIR };
6
+ export { printPslFromAst as printPsl };
45
7
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/schema-validation.ts","../src/print-psl.ts"],"sourcesContent":[],"mappings":";;;;;KAoBY,yBAAA,YAAqC;KAIrC,qBAAA;;EAJA,SAAA,UAAA,EAAA,MAAA;EAIA,SAAA,QAAA,EAAA,OAAqB;EAQrB,SAAA,OAAA,CAAA,EAJS,yBAIW;EAEG,SAAA,WAAA,CAAA,EALV,cAKU;CAAf;AACI,KAHZ,oBAAA,GAGY;EACS,SAAA,IAAA,EAAA,MAAA;EACJ,SAAA,OAAA,EAHT,MAGS,CAAA,MAAA,EAHM,qBAGN,CAAA;EACA,SAAA,UAAA,CAAA,EAHL,UAGK;EACJ,SAAA,WAAA,EAAA,SAHQ,eAGR,EAAA;EAAc,SAAA,OAAA,EAAA,SAFV,WAEU,EAAA;EAG3B,SAAA,OAAA,EAAA,SAJiB,UAIM,EAAA;EAAQ,SAAA,WAAA,CAAA,EAHlB,cAGkB;CAAL;AACJ,KADtB,uBAAA,GAA0B,IACJ,CADS,WACT,EAAA,QAAA,CAAA,GAAA;EAAf,SAAA,MAAA,EAAA,MAAA,CAAA,MAAA,EAAe,oBAAf,CAAA;CAAM;AAGT,iBAAA,4BAAA,CAA8C,KAAA,EAAA,OAAA,CAAA,EAAA,uBAAuB;;;;;;AA1BrF;AAIA;AAQA;;;;;;;;AAOuC,iBC8CvB,QAAA,CD9CuB,QAAA,EC8CJ,uBD9CI,EAAA,OAAA,EC8C8B,iBD9C9B,CAAA,EAAA,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/print-psl.ts"],"mappings":";;;iBAIgB,eAAA,CAAgB,GAAA,EAAK,cAAA"}