@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 +8 -12
- package/dist/index.d.mts +3 -41
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +205 -873
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -13
- package/src/ast-to-print-document.ts +293 -0
- package/src/exports/index.ts +1 -8
- package/src/print-document.ts +14 -0
- package/src/print-psl.ts +6 -879
- package/src/serialize-print-document.ts +182 -0
- package/src/types.ts +14 -83
- package/dist/postgres.d.mts +0 -32
- package/dist/postgres.d.mts.map +0 -1
- package/dist/postgres.mjs +0 -346
- package/dist/postgres.mjs.map +0 -1
- package/dist/types-BmnVaMF1.d.mts +0 -54
- package/dist/types-BmnVaMF1.d.mts.map +0 -1
- package/src/default-mapping.ts +0 -66
- package/src/exports/postgres.ts +0 -8
- package/src/name-transforms.ts +0 -234
- package/src/postgres-default-mapping.ts +0 -16
- package/src/postgres-type-map.ts +0 -204
- package/src/raw-default-parser.ts +0 -98
- package/src/relation-inference.ts +0 -239
- package/src/schema-validation.ts +0 -308
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
|
|
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`
|
|
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
|
|
16
|
-
-
|
|
17
|
-
-
|
|
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/
|
|
25
|
-
- `@prisma-next/sql-schema-ir`
|
|
26
|
-
- `@prisma-next/utils`
|
|
22
|
+
- `@prisma-next/framework-components`
|
|
27
23
|
- **Used by**
|
|
28
|
-
- `@prisma-next/cli`
|
|
29
|
-
-
|
|
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 {
|
|
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 {
|
|
6
|
+
export { printPslFromAst as printPsl };
|
|
45
7
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/print-psl.ts"],"mappings":";;;iBAIgB,eAAA,CAAgB,GAAA,EAAK,cAAA"}
|