@prisma-next/sql-schema-ir 0.3.0-dev.5 → 0.3.0-dev.50

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.
@@ -0,0 +1,2 @@
1
+ import { a as SqlIndexIR, c as SqlTableIR, d as SqlUniqueIR, i as SqlForeignKeyIR, l as SqlTypeMetadata, n as SqlAnnotations, o as SqlReferentialAction, r as SqlColumnIR, s as SqlSchemaIR, t as PrimaryKey, u as SqlTypeMetadataRegistry } from "../types-t7S29aXW.mjs";
2
+ export { PrimaryKey, SqlAnnotations, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlReferentialAction, SqlSchemaIR, SqlTableIR, SqlTypeMetadata, SqlTypeMetadataRegistry, SqlUniqueIR };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ import { a as SqlIndexIR, c as SqlTableIR, d as SqlUniqueIR, i as SqlForeignKeyIR, l as SqlTypeMetadata, n as SqlAnnotations, o as SqlReferentialAction, r as SqlColumnIR, s as SqlSchemaIR, t as PrimaryKey, u as SqlTypeMetadataRegistry } from "./types-t7S29aXW.mjs";
2
+ export { PrimaryKey, SqlAnnotations, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlReferentialAction, SqlSchemaIR, SqlTableIR, SqlTypeMetadata, SqlTypeMetadataRegistry, SqlUniqueIR };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import "./exports/types.mjs";
2
+
3
+ export { };
@@ -0,0 +1,123 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * SQL Schema IR types for target-agnostic schema representation.
4
+ *
5
+ * These types represent the canonical in-memory representation of SQL schemas
6
+ * for the SQL family, used for verification and future migration planning.
7
+ */
8
+ /**
9
+ * Primary key definition matching ContractIR format.
10
+ * Defined here to avoid circular dependency with sql-contract.
11
+ */
12
+ type PrimaryKey = {
13
+ readonly columns: readonly string[];
14
+ readonly name?: string;
15
+ };
16
+ /**
17
+ * Namespaced annotations for extensibility.
18
+ * Each namespace (e.g., 'pg', 'pgvector') owns its annotations.
19
+ */
20
+ type SqlAnnotations = {
21
+ readonly [namespace: string]: unknown;
22
+ };
23
+ /**
24
+ * SQL column IR representing a column in a table.
25
+ */
26
+ type SqlColumnIR = {
27
+ readonly name: string;
28
+ readonly nativeType: string;
29
+ readonly nullable: boolean;
30
+ readonly default?: string;
31
+ readonly annotations?: SqlAnnotations;
32
+ };
33
+ /**
34
+ * Referential action for foreign keys in the schema IR.
35
+ * Defined here independently from the contract package to avoid coupling.
36
+ */
37
+ type SqlReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
38
+ /**
39
+ * SQL foreign key IR.
40
+ */
41
+ type SqlForeignKeyIR = {
42
+ readonly columns: readonly string[];
43
+ readonly referencedTable: string;
44
+ readonly referencedColumns: readonly string[];
45
+ readonly name?: string;
46
+ readonly onDelete?: SqlReferentialAction;
47
+ readonly onUpdate?: SqlReferentialAction;
48
+ readonly annotations?: SqlAnnotations;
49
+ };
50
+ /**
51
+ * SQL unique constraint IR.
52
+ */
53
+ type SqlUniqueIR = {
54
+ readonly columns: readonly string[];
55
+ readonly name?: string;
56
+ readonly annotations?: SqlAnnotations;
57
+ };
58
+ /**
59
+ * SQL index IR.
60
+ */
61
+ type SqlIndexIR = {
62
+ readonly columns: readonly string[];
63
+ readonly name?: string;
64
+ readonly unique: boolean;
65
+ readonly annotations?: SqlAnnotations;
66
+ };
67
+ /**
68
+ * SQL table IR representing a table in the schema.
69
+ * Primary key format matches ContractIR for consistency.
70
+ */
71
+ type SqlTableIR = {
72
+ readonly name: string;
73
+ readonly columns: Record<string, SqlColumnIR>;
74
+ readonly primaryKey?: PrimaryKey;
75
+ readonly foreignKeys: readonly SqlForeignKeyIR[];
76
+ readonly uniques: readonly SqlUniqueIR[];
77
+ readonly indexes: readonly SqlIndexIR[];
78
+ readonly annotations?: SqlAnnotations;
79
+ };
80
+ /**
81
+ * SQL Schema IR representing the complete database schema.
82
+ * This is the target-agnostic representation used for verification and migration planning.
83
+ */
84
+ type SqlSchemaIR = {
85
+ readonly tables: Record<string, SqlTableIR>;
86
+ readonly extensions: readonly string[];
87
+ readonly annotations?: SqlAnnotations;
88
+ };
89
+ /**
90
+ * SQL type metadata for control-plane and execution-plane type availability and mapping.
91
+ * This abstraction provides a read-only view of type information without encode/decode behavior.
92
+ */
93
+ interface SqlTypeMetadata {
94
+ /**
95
+ * Namespaced type identifier in format 'namespace/name@version'
96
+ * Examples: 'pg/int4@1', 'pg/text@1', 'pg/timestamptz@1'
97
+ */
98
+ readonly typeId: string;
99
+ /**
100
+ * Contract scalar type IDs that this type can handle.
101
+ * Examples: ['text'], ['int4', 'float8'], ['timestamp', 'timestamptz']
102
+ */
103
+ readonly targetTypes: readonly string[];
104
+ /**
105
+ * Native database type name (target-specific).
106
+ * Examples: 'integer', 'text', 'character varying', 'timestamp with time zone'
107
+ * This is optional because not all types have a native database representation.
108
+ */
109
+ readonly nativeType?: string;
110
+ }
111
+ /**
112
+ * Registry interface for SQL type metadata.
113
+ * Provides read-only iteration over type metadata entries.
114
+ */
115
+ interface SqlTypeMetadataRegistry {
116
+ /**
117
+ * Returns an iterator over all type metadata entries.
118
+ */
119
+ values(): IterableIterator<SqlTypeMetadata>;
120
+ }
121
+ //#endregion
122
+ export { SqlIndexIR as a, SqlTableIR as c, SqlUniqueIR as d, SqlForeignKeyIR as i, SqlTypeMetadata as l, SqlAnnotations as n, SqlReferentialAction as o, SqlColumnIR as r, SqlSchemaIR as s, PrimaryKey as t, SqlTypeMetadataRegistry as u };
123
+ //# sourceMappingURL=types-t7S29aXW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-t7S29aXW.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;AAWA;AASA;AAOA;AAYA;AAKA;;;;;AAaY,KA9CA,UAAA,GA8CW;EASX,SAAA,OAAU,EAAA,SAIG,MAAA,EAAA;EAOb,SAAA,IAAU,CAAA,EAAA,MAAA;CAEa;;;;;AAIN,KA/DjB,cAAA,GA+DiB;EACJ,UAAA,SAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAAc;AAOvC;;;AAGyB,KAnEb,WAAA,GAmEa;EAAc,SAAA,IAAA,EAAA,MAAA;EAOtB,SAAA,UAAe,EAAA,MAAA;EAyBf,SAAA,QAAA,EAAA,OAAuB;;yBA9Ff;;;;;;KAOb,oBAAA;;;;KAKA,eAAA;;;;;sBAKU;sBACA;yBACG;;;;;KAMb,WAAA;;;yBAGa;;;;;KAMb,UAAA;;;;yBAIa;;;;;;KAOb,UAAA;;oBAEQ,eAAe;wBACX;iCACS;6BACJ;6BACA;yBACJ;;;;;;KAOb,WAAA;mBACO,eAAe;;yBAET;;;;;;UAOR,eAAA;;;;;;;;;;;;;;;;;;;;;;UAyBA,uBAAA;;;;YAIL,iBAAiB"}
package/package.json CHANGED
@@ -1,37 +1,48 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-schema-ir",
3
- "version": "0.3.0-dev.5",
3
+ "version": "0.3.0-dev.50",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "SQL Schema IR types for schema introspection and verification",
7
7
  "dependencies": {
8
- "@prisma-next/contract": "0.3.0-dev.5"
8
+ "@prisma-next/contract": "0.3.0-dev.50"
9
9
  },
10
10
  "devDependencies": {
11
- "@vitest/coverage-v8": "4.0.16",
12
- "tsup": "8.5.1",
11
+ "tsdown": "0.18.4",
13
12
  "typescript": "5.9.3",
14
- "vitest": "4.0.16",
15
- "@prisma-next/test-utils": "0.0.1"
13
+ "vitest": "4.0.17",
14
+ "@prisma-next/test-utils": "0.0.1",
15
+ "@prisma-next/tsconfig": "0.0.0",
16
+ "@prisma-next/tsdown": "0.0.0"
16
17
  },
17
18
  "files": [
18
19
  "dist",
19
20
  "src"
20
21
  ],
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
21
25
  "exports": {
22
- "./types": {
23
- "types": "./dist/exports/types.d.ts",
24
- "import": "./dist/exports/types.js"
25
- }
26
+ ".": "./dist/index.mjs",
27
+ "./types": "./dist/exports/types.mjs",
28
+ "./package.json": "./package.json"
29
+ },
30
+ "main": "./dist/index.mjs",
31
+ "module": "./dist/index.mjs",
32
+ "types": "./dist/index.d.mts",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/prisma/prisma-next.git",
36
+ "directory": "packages/2-sql/1-core/schema-ir"
26
37
  },
27
38
  "scripts": {
28
- "build": "tsup --config tsup.config.ts && tsc --project tsconfig.build.json",
39
+ "build": "tsdown",
29
40
  "test": "vitest run --passWithNoTests",
30
41
  "test:coverage": "vitest run --coverage --passWithNoTests",
31
- "typecheck": "tsc --project tsconfig.json --noEmit",
32
- "lint": "biome check . --config-path ../../../../biome.json --error-on-warnings",
33
- "lint:fix": "biome check --write . --config-path ../../../biome.json",
34
- "lint:fix:unsafe": "biome check --write --unsafe . --config-path ../../../biome.json",
35
- "clean": "node ../../../../scripts/clean.mjs"
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "biome check . --error-on-warnings",
44
+ "lint:fix": "biome check --write .",
45
+ "lint:fix:unsafe": "biome check --write --unsafe .",
46
+ "clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
36
47
  }
37
48
  }
@@ -4,6 +4,7 @@ export type {
4
4
  SqlColumnIR,
5
5
  SqlForeignKeyIR,
6
6
  SqlIndexIR,
7
+ SqlReferentialAction,
7
8
  SqlSchemaIR,
8
9
  SqlTableIR,
9
10
  SqlTypeMetadata,
package/src/types.ts CHANGED
@@ -29,9 +29,16 @@ export type SqlColumnIR = {
29
29
  readonly name: string;
30
30
  readonly nativeType: string; // explicit DB type, e.g. 'integer', 'vector'
31
31
  readonly nullable: boolean;
32
+ readonly default?: string; // Raw database default expression (e.g., "'hello'::text", "nextval('seq')")
32
33
  readonly annotations?: SqlAnnotations; // column-level metadata
33
34
  };
34
35
 
36
+ /**
37
+ * Referential action for foreign keys in the schema IR.
38
+ * Defined here independently from the contract package to avoid coupling.
39
+ */
40
+ export type SqlReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
41
+
35
42
  /**
36
43
  * SQL foreign key IR.
37
44
  */
@@ -40,6 +47,8 @@ export type SqlForeignKeyIR = {
40
47
  readonly referencedTable: string;
41
48
  readonly referencedColumns: readonly string[];
42
49
  readonly name?: string;
50
+ readonly onDelete?: SqlReferentialAction;
51
+ readonly onUpdate?: SqlReferentialAction;
43
52
  readonly annotations?: SqlAnnotations;
44
53
  };
45
54
 
@@ -1,2 +0,0 @@
1
- export type { PrimaryKey, SqlAnnotations, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlTableIR, SqlTypeMetadata, SqlTypeMetadataRegistry, SqlUniqueIR, } from '../types';
2
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,uBAAuB,EACvB,WAAW,GACZ,MAAM,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './exports/types';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,112 +0,0 @@
1
- /**
2
- * SQL Schema IR types for target-agnostic schema representation.
3
- *
4
- * These types represent the canonical in-memory representation of SQL schemas
5
- * for the SQL family, used for verification and future migration planning.
6
- */
7
- /**
8
- * Primary key definition matching ContractIR format.
9
- * Defined here to avoid circular dependency with sql-contract.
10
- */
11
- export type PrimaryKey = {
12
- readonly columns: readonly string[];
13
- readonly name?: string;
14
- };
15
- /**
16
- * Namespaced annotations for extensibility.
17
- * Each namespace (e.g., 'pg', 'pgvector') owns its annotations.
18
- */
19
- export type SqlAnnotations = {
20
- readonly [namespace: string]: unknown;
21
- };
22
- /**
23
- * SQL column IR representing a column in a table.
24
- */
25
- export type SqlColumnIR = {
26
- readonly name: string;
27
- readonly nativeType: string;
28
- readonly nullable: boolean;
29
- readonly annotations?: SqlAnnotations;
30
- };
31
- /**
32
- * SQL foreign key IR.
33
- */
34
- export type SqlForeignKeyIR = {
35
- readonly columns: readonly string[];
36
- readonly referencedTable: string;
37
- readonly referencedColumns: readonly string[];
38
- readonly name?: string;
39
- readonly annotations?: SqlAnnotations;
40
- };
41
- /**
42
- * SQL unique constraint IR.
43
- */
44
- export type SqlUniqueIR = {
45
- readonly columns: readonly string[];
46
- readonly name?: string;
47
- readonly annotations?: SqlAnnotations;
48
- };
49
- /**
50
- * SQL index IR.
51
- */
52
- export type SqlIndexIR = {
53
- readonly columns: readonly string[];
54
- readonly name?: string;
55
- readonly unique: boolean;
56
- readonly annotations?: SqlAnnotations;
57
- };
58
- /**
59
- * SQL table IR representing a table in the schema.
60
- * Primary key format matches ContractIR for consistency.
61
- */
62
- export type SqlTableIR = {
63
- readonly name: string;
64
- readonly columns: Record<string, SqlColumnIR>;
65
- readonly primaryKey?: PrimaryKey;
66
- readonly foreignKeys: readonly SqlForeignKeyIR[];
67
- readonly uniques: readonly SqlUniqueIR[];
68
- readonly indexes: readonly SqlIndexIR[];
69
- readonly annotations?: SqlAnnotations;
70
- };
71
- /**
72
- * SQL Schema IR representing the complete database schema.
73
- * This is the target-agnostic representation used for verification and migration planning.
74
- */
75
- export type SqlSchemaIR = {
76
- readonly tables: Record<string, SqlTableIR>;
77
- readonly extensions: readonly string[];
78
- readonly annotations?: SqlAnnotations;
79
- };
80
- /**
81
- * SQL type metadata for control-plane and execution-plane type availability and mapping.
82
- * This abstraction provides a read-only view of type information without encode/decode behavior.
83
- */
84
- export interface SqlTypeMetadata {
85
- /**
86
- * Namespaced type identifier in format 'namespace/name@version'
87
- * Examples: 'pg/int4@1', 'pg/text@1', 'pg/timestamptz@1'
88
- */
89
- readonly typeId: string;
90
- /**
91
- * Contract scalar type IDs that this type can handle.
92
- * Examples: ['text'], ['int4', 'float8'], ['timestamp', 'timestamptz']
93
- */
94
- readonly targetTypes: readonly string[];
95
- /**
96
- * Native database type name (target-specific).
97
- * Examples: 'integer', 'text', 'character varying', 'timestamp with time zone'
98
- * This is optional because not all types have a native database representation.
99
- */
100
- readonly nativeType?: string;
101
- }
102
- /**
103
- * Registry interface for SQL type metadata.
104
- * Provides read-only iteration over type metadata entries.
105
- */
106
- export interface SqlTypeMetadataRegistry {
107
- /**
108
- * Returns an iterator over all type metadata entries.
109
- */
110
- values(): IterableIterator<SqlTypeMetadata>;
111
- }
112
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,cAAc,CAAC;CACvC,CAAC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