@prisma-next/target-postgres 0.14.0-dev.61 → 0.14.0-dev.62
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/dist/{authoring-BLkL4fFG.mjs → authoring-CdIZ0yvD.mjs} +2 -2
- package/dist/{authoring-BLkL4fFG.mjs.map → authoring-CdIZ0yvD.mjs.map} +1 -1
- package/dist/contract-free.d.mts +1 -1
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +2 -2
- package/dist/{control-policy-BpmChlAK.mjs → control-policy-DKp0HKpY.mjs} +180 -45
- package/dist/control-policy-DKp0HKpY.mjs.map +1 -0
- package/dist/control.mjs +21 -25
- package/dist/control.mjs.map +1 -1
- package/dist/{ddl-BovUVFVi.mjs → ddl-gmxHf68z.mjs} +20 -4
- package/dist/{ddl-BovUVFVi.mjs.map → ddl-gmxHf68z.mjs.map} +1 -1
- package/dist/ddl.d.mts +2 -2
- package/dist/ddl.mjs +2 -2
- package/dist/{descriptor-meta-C1T4BXJ8.mjs → descriptor-meta-DEuXJfpR.mjs} +3 -3
- package/dist/{descriptor-meta-C1T4BXJ8.mjs.map → descriptor-meta-DEuXJfpR.mjs.map} +1 -1
- package/dist/{diff-database-schema-RMwnSOnz.mjs → diff-database-schema-D2sjvMw9.mjs} +14 -10
- package/dist/diff-database-schema-D2sjvMw9.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +1 -1
- package/dist/diff-database-schema.d.mts.map +1 -1
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +2 -2
- package/dist/{nodes-BtQyZha6.d.mts → nodes-Bc2N3tMy.d.mts} +27 -3
- package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
- package/dist/{nodes-B815pj_X.mjs → nodes-DJC5B8Id.mjs} +32 -2
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/{op-factory-call-CI00nS4z.mjs → op-factory-call-C4flTtTG.mjs} +105 -6
- package/dist/op-factory-call-C4flTtTG.mjs.map +1 -0
- package/dist/{op-factory-call-D6_7-7Vc.d.mts → op-factory-call-CSIg5XDu.d.mts} +26 -3
- package/dist/{op-factory-call-D6_7-7Vc.d.mts.map → op-factory-call-CSIg5XDu.d.mts.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CAHZN1Ez.mjs → planner-BtEd5LMr.mjs} +32 -64
- package/dist/planner-BtEd5LMr.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B8Nn6nHN.mjs → planner-ddl-builders-BKlmGDJl.mjs} +7 -3
- package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-a-tjfKsA.d.mts → planner-produced-postgres-migration-CXue-6M9.d.mts} +2 -2
- package/dist/{planner-produced-postgres-migration-a-tjfKsA.d.mts.map → planner-produced-postgres-migration-CXue-6M9.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-flkG4Y7n.mjs → planner-produced-postgres-migration-Jat3hg4u.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-flkG4Y7n.mjs.map → planner-produced-postgres-migration-Jat3hg4u.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-C1-Kk3Eu.mjs → planner-sql-checks-Br1c_QsH.mjs} +3 -3
- package/dist/{planner-sql-checks-C1-Kk3Eu.mjs.map → planner-sql-checks-Br1c_QsH.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/planner.d.mts +2 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-view-DWLNQbdR.mjs → postgres-contract-view-BAPW0ec1.mjs} +3 -3
- package/dist/{postgres-contract-view-DWLNQbdR.mjs.map → postgres-contract-view-BAPW0ec1.mjs.map} +1 -1
- package/dist/{postgres-database-schema-node-BVdOffjC.d.mts → postgres-database-schema-node-CJv5bfbs.d.mts} +62 -21
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-C92swCzd.mjs → postgres-migration-ChLMQRd-.mjs} +19 -3
- package/dist/postgres-migration-ChLMQRd-.mjs.map +1 -0
- package/dist/{postgres-migration-Bzzi0Asr.d.mts → postgres-migration-DkmgGNcv.d.mts} +21 -2
- package/dist/postgres-migration-DkmgGNcv.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-BmCboEa_.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs} +11 -19
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/{postgres-schema-COEca21H.mjs → postgres-schema-DWQ0-CPb.mjs} +13 -2
- package/dist/postgres-schema-DWQ0-CPb.mjs.map +1 -0
- package/dist/postgres-schema-DsrtYp2v.d.mts.map +1 -1
- package/dist/{postgres-table-schema-node-9FCtCUz2.mjs → postgres-table-schema-node-D6LvInCe.mjs} +71 -8
- package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
- package/dist/{resolve-ddl-schema-ZkKxt2Fm.mjs → resolve-ddl-schema-CAza65Iy.mjs} +2 -2
- package/dist/{resolve-ddl-schema-ZkKxt2Fm.mjs.map → resolve-ddl-schema-CAza65Iy.mjs.map} +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/schema-ir-annotations.mjs +1 -1
- package/dist/{sql-utils-DcfMz4MQ.mjs → sql-utils-SU4FDvIV.mjs} +12 -3
- package/dist/{sql-utils-DcfMz4MQ.mjs.map → sql-utils-SU4FDvIV.mjs.map} +1 -1
- package/dist/sql-utils.d.mts +8 -1
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +4 -4
- package/package.json +20 -20
- package/src/contract-free/ddl.ts +27 -0
- package/src/core/ddl/nodes.ts +44 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +12 -1
- package/src/core/migrations/control-policy.ts +143 -45
- package/src/core/migrations/diff-database-schema.ts +1 -2
- package/src/core/migrations/issue-planner.ts +77 -4
- package/src/core/migrations/op-factory-call.ts +84 -0
- package/src/core/migrations/operations/native-enum-types.ts +62 -0
- package/src/core/migrations/planner-ddl-builders.ts +12 -2
- package/src/core/migrations/planner.ts +25 -62
- package/src/core/migrations/postgres-migration.ts +31 -0
- package/src/core/migrations/verify-postgres-namespaces.ts +0 -1
- package/src/core/postgres-schema.ts +22 -1
- package/src/core/psl-infer/infer-psl-contract.ts +6 -16
- package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +18 -27
- package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
- package/src/core/schema-ir/schema-node-kinds.ts +12 -3
- package/src/core/sql-utils.ts +15 -2
- package/src/exports/ddl.ts +2 -0
- package/src/exports/op-factory-call.ts +2 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/types.ts +4 -1
- package/dist/control-policy-BpmChlAK.mjs.map +0 -1
- package/dist/diff-database-schema-RMwnSOnz.mjs.map +0 -1
- package/dist/nodes-B815pj_X.mjs.map +0 -1
- package/dist/nodes-BtQyZha6.d.mts.map +0 -1
- package/dist/op-factory-call-CI00nS4z.mjs.map +0 -1
- package/dist/planner-CAHZN1Ez.mjs.map +0 -1
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +0 -1
- package/dist/postgres-database-schema-node-BVdOffjC.d.mts.map +0 -1
- package/dist/postgres-migration-Bzzi0Asr.d.mts.map +0 -1
- package/dist/postgres-migration-C92swCzd.mjs.map +0 -1
- package/dist/postgres-role-schema-node-BmCboEa_.mjs.map +0 -1
- package/dist/postgres-schema-COEca21H.mjs.map +0 -1
- package/dist/postgres-table-schema-node-9FCtCUz2.mjs.map +0 -1
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
import { r as RlsPolicyOperation } from "./postgres-rls-policy--CSddvMR.mjs";
|
|
2
2
|
import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
3
|
import { DiffableNode } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { ControlPolicy } from "@prisma-next/contract/types";
|
|
4
5
|
|
|
6
|
+
//#region src/core/schema-ir/postgres-native-enum-schema-node.d.ts
|
|
7
|
+
interface PostgresNativeEnumSchemaNodeInput {
|
|
8
|
+
/** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
|
|
9
|
+
readonly typeName: string;
|
|
10
|
+
/** The owning DDL schema name — enum types are schema-scoped. */
|
|
11
|
+
readonly namespaceId: string;
|
|
12
|
+
/** Member values in declaration (`pg_enum.enumsortorder`) order. */
|
|
13
|
+
readonly members: readonly string[];
|
|
14
|
+
/** The contract entity's control grade — expected-side nodes only. */
|
|
15
|
+
readonly control?: ControlPolicy;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Schema-diff leaf node for a native Postgres enum type.
|
|
19
|
+
*
|
|
20
|
+
* This is a derived, transient node walked by the differ — it is NEVER
|
|
21
|
+
* serialized. Both sides derive it on the namespace node: the expected side
|
|
22
|
+
* from the contract's hydrated `entries.native_enum` entities, the actual
|
|
23
|
+
* side from the adapter's introspected `nativeEnums`.
|
|
24
|
+
*
|
|
25
|
+
* Enum types are schema-scoped, so identity is (namespace, type name): the
|
|
26
|
+
* namespace coordinate comes from tree position (the differ pairs enum nodes
|
|
27
|
+
* only inside an already-paired namespace) and `id` carries the type name,
|
|
28
|
+
* prefixed with the entries-kind vocabulary (`native_enum:<typeName>`) so it
|
|
29
|
+
* cannot collide with a sibling table of the same name — the same
|
|
30
|
+
* sibling-prefix convention relational column nodes use (`column:<name>`).
|
|
31
|
+
*
|
|
32
|
+
* `isEqualTo` compares members POSITIONALLY — `['a','b'] ≠ ['b','a']` —
|
|
33
|
+
* because Postgres enum sort order is semantic. `control` is contract
|
|
34
|
+
* metadata, not database state, and does not participate in equality.
|
|
35
|
+
*/
|
|
36
|
+
declare class PostgresNativeEnumSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
37
|
+
readonly nodeKind: "postgres-native-enum";
|
|
38
|
+
readonly typeName: string;
|
|
39
|
+
readonly namespaceId: string;
|
|
40
|
+
readonly members: readonly string[];
|
|
41
|
+
readonly control?: ControlPolicy;
|
|
42
|
+
constructor(input: PostgresNativeEnumSchemaNodeInput);
|
|
43
|
+
get id(): string;
|
|
44
|
+
children(): readonly DiffableNode[];
|
|
45
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
46
|
+
static is(node: SqlSchemaIRNode): node is PostgresNativeEnumSchemaNode;
|
|
47
|
+
static assert(node: SqlSchemaIRNode): asserts node is PostgresNativeEnumSchemaNode;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
5
50
|
//#region src/core/schema-ir/postgres-policy-schema-node.d.ts
|
|
6
51
|
interface PostgresPolicySchemaNodeInput {
|
|
7
52
|
/** Full wire name: `<prefix>_<8hex>`. */
|
|
@@ -109,42 +154,38 @@ declare class PostgresTableSchemaNode extends SqlSchemaIRNode implements Diffabl
|
|
|
109
154
|
}
|
|
110
155
|
//#endregion
|
|
111
156
|
//#region src/core/schema-ir/postgres-namespace-schema-node.d.ts
|
|
112
|
-
/** One introspected native Postgres enum type, in `pg_enum.enumsortorder` (declaration) order. */
|
|
113
|
-
interface PostgresNativeEnumIntrospection {
|
|
114
|
-
readonly typeName: string;
|
|
115
|
-
readonly values: readonly string[];
|
|
116
|
-
}
|
|
117
157
|
interface PostgresNamespaceSchemaNodeInput {
|
|
118
158
|
readonly schemaName: string;
|
|
119
159
|
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
120
|
-
|
|
121
|
-
|
|
160
|
+
/**
|
|
161
|
+
* The native-enum diff nodes belonging to this namespace, member values in
|
|
162
|
+
* `pg_enum.enumsortorder` (declaration) order. The expected
|
|
163
|
+
* (contract-projected) side attaches each node's `control` (the contract
|
|
164
|
+
* entity's grade); introspection builds nodes with no `control`.
|
|
165
|
+
*/
|
|
166
|
+
readonly nativeEnums?: readonly PostgresNativeEnumSchemaNode[];
|
|
122
167
|
}
|
|
123
168
|
/**
|
|
124
169
|
* One-per-Postgres-schema diff-tree node. Groups the tables belonging to a
|
|
125
170
|
* single namespace. Per-schema consumers (the relational planner,
|
|
126
171
|
* toSchemaView) read this node's `tables` field structurally via
|
|
127
172
|
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
128
|
-
* assignment — because `nodeKind`
|
|
173
|
+
* assignment — because `nodeKind` carries this node's own literal
|
|
129
174
|
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
130
175
|
*
|
|
131
|
-
* `id` is the schema name
|
|
132
|
-
*
|
|
133
|
-
* nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`
|
|
134
|
-
* field, not an annotations bag.
|
|
176
|
+
* `id` is the schema name; `isEqualTo` is identity on it; `children()` returns
|
|
177
|
+
* the table nodes plus `nativeEnums`.
|
|
135
178
|
*
|
|
136
|
-
* `nativeEnums`
|
|
137
|
-
*
|
|
138
|
-
* (
|
|
139
|
-
*
|
|
140
|
-
* hooks, the infer throw) so none of them need the values to keep working.
|
|
179
|
+
* `nativeEnums` is the diff-tree representation of native enum types the
|
|
180
|
+
* differ pairs — the sole enum carrier, built directly by both sides: the
|
|
181
|
+
* expected (contract-projected) side and introspection alike hand in
|
|
182
|
+
* `PostgresNativeEnumSchemaNode`s.
|
|
141
183
|
*/
|
|
142
184
|
declare class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {
|
|
143
185
|
readonly nodeKind: "postgres-namespace";
|
|
144
186
|
readonly schemaName: string;
|
|
145
187
|
readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
|
|
146
|
-
readonly
|
|
147
|
-
readonly nativeEnums: readonly PostgresNativeEnumIntrospection[];
|
|
188
|
+
readonly nativeEnums: readonly PostgresNativeEnumSchemaNode[];
|
|
148
189
|
constructor(input: PostgresNamespaceSchemaNodeInput);
|
|
149
190
|
get id(): string;
|
|
150
191
|
isEqualTo(other: DiffableNode): boolean;
|
|
@@ -217,5 +258,5 @@ declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements Diff
|
|
|
217
258
|
static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode;
|
|
218
259
|
}
|
|
219
260
|
//#endregion
|
|
220
|
-
export { PostgresNamespaceSchemaNode as a,
|
|
221
|
-
//# sourceMappingURL=postgres-database-schema-node-
|
|
261
|
+
export { PostgresNamespaceSchemaNode as a, PostgresTableSchemaNodeInput as c, PostgresNativeEnumSchemaNode as d, PostgresNativeEnumSchemaNodeInput as f, PostgresRoleSchemaNodeInput as i, PostgresPolicySchemaNode as l, PostgresDatabaseSchemaNodeInput as n, PostgresNamespaceSchemaNodeInput as o, PostgresRoleSchemaNode as r, PostgresTableSchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresPolicySchemaNodeInput as u };
|
|
262
|
+
//# sourceMappingURL=postgres-database-schema-node-CJv5bfbs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-database-schema-node-CJv5bfbs.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-native-enum-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts","../src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,0BAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as SetNotNullCall, C as DropNotNullCall, P as installExtension, S as DropNativeEnumTypeCall, T as DropTableCall, _ as DropCheckConstraintCall, b as DropDefaultCall, c as AlterColumnTypeCall, d as CreateNativeEnumTypeCall, k as SetDefaultCall, m as CreateTableCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateSchemaCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropColumnCall, x as DropIndexCall, y as DropConstraintCall } from "./op-factory-call-C4flTtTG.mjs";
|
|
2
2
|
import { t as errorPostgresMigrationStackMissing } from "./errors-DO-w0EUS.mjs";
|
|
3
|
-
import { t as PostgresContractView } from "./postgres-contract-view-
|
|
3
|
+
import { t as PostgresContractView } from "./postgres-contract-view-BAPW0ec1.mjs";
|
|
4
4
|
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
5
5
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
6
6
|
import { MigrationContractViews } from "@prisma-next/migration-tools/migration";
|
|
@@ -95,6 +95,22 @@ var PostgresMigration = class extends Migration {
|
|
|
95
95
|
createSchema(options) {
|
|
96
96
|
return new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor("createSchema"));
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed
|
|
100
|
+
* native enum. Builds a typed DDL node and lowers it through the stored
|
|
101
|
+
* control adapter (members render in declaration order). Throws if no adapter
|
|
102
|
+
* is present.
|
|
103
|
+
*/
|
|
104
|
+
createNativeEnumType(options) {
|
|
105
|
+
return new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor("createNativeEnumType"));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Emit a `DROP TYPE` migration operation for a managed native enum, lowered
|
|
109
|
+
* through the stored control adapter. Throws if no adapter is present.
|
|
110
|
+
*/
|
|
111
|
+
dropNativeEnumType(options) {
|
|
112
|
+
return new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor("dropNativeEnumType"));
|
|
113
|
+
}
|
|
98
114
|
addColumn(options) {
|
|
99
115
|
return new AddColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor("addColumn"));
|
|
100
116
|
}
|
|
@@ -150,4 +166,4 @@ var PostgresMigration = class extends Migration {
|
|
|
150
166
|
//#endregion
|
|
151
167
|
export { PostgresMigration as t };
|
|
152
168
|
|
|
153
|
-
//# sourceMappingURL=postgres-migration-
|
|
169
|
+
//# sourceMappingURL=postgres-migration-ChLMQRd-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-ChLMQRd-.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { PostgresContractView } from '../postgres-contract-view';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateNativeEnumTypeCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNativeEnumTypeCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a PN-MIG-2007 in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a PN-MIG-2007 naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'postgres'> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return dataTransform(contract, name, options, this.controlAdapterFor('dataTransform'));\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapterFor('createTable'));\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor('createSchema'));\n }\n\n /**\n * Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n * native enum. Builds a typed DDL node and lowers it through the stored\n * control adapter (members render in declaration order). Throws if no adapter\n * is present.\n */\n protected createNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly members: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(\n this.controlAdapterFor('createNativeEnumType'),\n );\n }\n\n /**\n * Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n * through the stored control adapter. Throws if no adapter is present.\n */\n protected dropNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(\n this.controlAdapterFor('dropNativeEnumType'),\n );\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addPrimaryKey'));\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addUnique'));\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapterFor('addForeignKey'),\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapterFor('addCheckConstraint'));\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapterFor('dropCheckConstraint'),\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapterFor('dropConstraint'));\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropTableCall(options.schema, options.table).toOp(\n this.controlAdapterFor('dropTable'),\n );\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapterFor('alterColumnType'));\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('setNotNull'),\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropNotNull'),\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapterFor('setDefault'));\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropDefault'),\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapterFor('createIndex'));\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return installExtension(options, this.controlAdapterFor('installExtension'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,kBAA0B,WAAkD;EAC1E,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC,SAAS;EAEpD,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,cAAyC;EAC3C,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAoD;EACtD,OAAO,KAAKC,WAAW;CACzB;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,kBAAkB,eAA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AAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,kBAAkB,aAAa,CACtC;CACF;CAEA,YAAsB,SAM4C;EAChE,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,OACR,QAAQ,SACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,kBAAkB,aAAa,CAAC;CAC9C;CAEA,UAAoB,SAI8C;EAChE,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,kBAAkB,WAAW,CACpC;CACF;CAEA,iBAA2B,SAKuC;EAChE,OAAO,iBAAiB,SAAS,KAAK,kBAAkB,kBAAkB,CAAC;CAC7E;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
|
|
2
2
|
import { n as DataTransformOptions } from "./data-transform-DPzwBMhW.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { D as ForeignKeySpec, c as AlterColumnTypeOptions } from "./op-factory-call-CSIg5XDu.mjs";
|
|
4
4
|
import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
|
|
5
5
|
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
6
6
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -99,6 +99,25 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
|
|
|
99
99
|
readonly schema: string;
|
|
100
100
|
readonly ifNotExists?: boolean;
|
|
101
101
|
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
102
|
+
/**
|
|
103
|
+
* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed
|
|
104
|
+
* native enum. Builds a typed DDL node and lowers it through the stored
|
|
105
|
+
* control adapter (members render in declaration order). Throws if no adapter
|
|
106
|
+
* is present.
|
|
107
|
+
*/
|
|
108
|
+
protected createNativeEnumType(options: {
|
|
109
|
+
readonly schema: string;
|
|
110
|
+
readonly typeName: string;
|
|
111
|
+
readonly members: readonly string[];
|
|
112
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
113
|
+
/**
|
|
114
|
+
* Emit a `DROP TYPE` migration operation for a managed native enum, lowered
|
|
115
|
+
* through the stored control adapter. Throws if no adapter is present.
|
|
116
|
+
*/
|
|
117
|
+
protected dropNativeEnumType(options: {
|
|
118
|
+
readonly schema: string;
|
|
119
|
+
readonly typeName: string;
|
|
120
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
102
121
|
protected addColumn(options: {
|
|
103
122
|
readonly schema: string;
|
|
104
123
|
readonly table: string;
|
|
@@ -197,4 +216,4 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
|
|
|
197
216
|
}
|
|
198
217
|
//#endregion
|
|
199
218
|
export { PostgresMigration as t };
|
|
200
|
-
//# sourceMappingURL=postgres-migration-
|
|
219
|
+
//# sourceMappingURL=postgres-migration-DkmgGNcv.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-DkmgGNcv.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;;;;AC6C3B;;;;;;;;;;;;;;;AD/CA,uBC+CsB,iBAAA,eACN,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,eAClC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,WACpC,SAAA,CAAa,yBAAA,cAAuC,KAAA,EAAO,GAAA;EAAA;WAC1D,QAAA;EAwDiC;;;;;;EAAA,mBAhDvB,cAAA,EAAgB,iBAAA;cAavB,KAAA,GAAQ,YAAA;EAg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AY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAM5B,UAAA,CAAW,OAAA;IAAA,SACV,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;IAAA,SACA,UAAA;IAAA,SACA,cAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAU5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAM5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;IAAA,SACA,MAAA,GAAS,iBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAU5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAM5B,gBAAA,CAAiB,OAAA;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
|
package/dist/{postgres-role-schema-node-BmCboEa_.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as PostgresSchemaNodeKind } from "./postgres-table-schema-node-D6LvInCe.mjs";
|
|
2
2
|
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
4
|
import { SqlSchemaIRNode, assertNode } from "@prisma-next/sql-schema-ir/types";
|
|
@@ -50,35 +50,27 @@ var PostgresDatabaseSchemaNode = class PostgresDatabaseSchemaNode extends SqlSch
|
|
|
50
50
|
* single namespace. Per-schema consumers (the relational planner,
|
|
51
51
|
* toSchemaView) read this node's `tables` field structurally via
|
|
52
52
|
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
53
|
-
* assignment — because `nodeKind`
|
|
53
|
+
* assignment — because `nodeKind` carries this node's own literal
|
|
54
54
|
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
55
55
|
*
|
|
56
|
-
* `id` is the schema name
|
|
57
|
-
*
|
|
58
|
-
* nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`
|
|
59
|
-
* field, not an annotations bag.
|
|
56
|
+
* `id` is the schema name; `isEqualTo` is identity on it; `children()` returns
|
|
57
|
+
* the table nodes plus `nativeEnums`.
|
|
60
58
|
*
|
|
61
|
-
* `nativeEnums`
|
|
62
|
-
*
|
|
63
|
-
* (
|
|
64
|
-
*
|
|
65
|
-
* hooks, the infer throw) so none of them need the values to keep working.
|
|
59
|
+
* `nativeEnums` is the diff-tree representation of native enum types the
|
|
60
|
+
* differ pairs — the sole enum carrier, built directly by both sides: the
|
|
61
|
+
* expected (contract-projected) side and introspection alike hand in
|
|
62
|
+
* `PostgresNativeEnumSchemaNode`s.
|
|
66
63
|
*/
|
|
67
64
|
var PostgresNamespaceSchemaNode = class PostgresNamespaceSchemaNode extends SqlSchemaIRNode {
|
|
68
65
|
nodeKind = PostgresSchemaNodeKind.namespace;
|
|
69
66
|
schemaName;
|
|
70
67
|
tables;
|
|
71
|
-
nativeEnumTypeNames;
|
|
72
68
|
nativeEnums;
|
|
73
69
|
constructor(input) {
|
|
74
70
|
super();
|
|
75
71
|
this.schemaName = input.schemaName;
|
|
76
72
|
this.tables = Object.freeze({ ...input.tables });
|
|
77
|
-
this.
|
|
78
|
-
this.nativeEnums = Object.freeze((input.nativeEnums ?? []).map((entry) => Object.freeze({
|
|
79
|
-
typeName: entry.typeName,
|
|
80
|
-
values: Object.freeze([...entry.values])
|
|
81
|
-
})));
|
|
73
|
+
this.nativeEnums = Object.freeze([...input.nativeEnums ?? []]);
|
|
82
74
|
freezeNode(this);
|
|
83
75
|
}
|
|
84
76
|
get id() {
|
|
@@ -88,7 +80,7 @@ var PostgresNamespaceSchemaNode = class PostgresNamespaceSchemaNode extends SqlS
|
|
|
88
80
|
return this.id === other.id;
|
|
89
81
|
}
|
|
90
82
|
children() {
|
|
91
|
-
return Object.values(this.tables);
|
|
83
|
+
return [...Object.values(this.tables), ...this.nativeEnums];
|
|
92
84
|
}
|
|
93
85
|
static is(node) {
|
|
94
86
|
return node.nodeKind === PostgresSchemaNodeKind.namespace;
|
|
@@ -195,4 +187,4 @@ var PostgresRoleSchemaNode = class PostgresRoleSchemaNode extends SqlSchemaIRNod
|
|
|
195
187
|
//#endregion
|
|
196
188
|
export { PostgresDatabaseSchemaNode as i, PostgresPolicySchemaNode as n, PostgresNamespaceSchemaNode as r, PostgresRoleSchemaNode as t };
|
|
197
189
|
|
|
198
|
-
//# sourceMappingURL=postgres-role-schema-node-
|
|
190
|
+
//# sourceMappingURL=postgres-role-schema-node-Cm-j0ZGM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-role-schema-node-Cm-j0ZGM.mjs","names":[],"sources":["../src/core/schema-ir/postgres-database-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts"],"sourcesContent":["import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNamespaceSchemaNode } from './postgres-namespace-schema-node';\nimport type { PostgresRoleSchemaNode } from './postgres-role-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresDatabaseSchemaNodeInput {\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n}\n\n/**\n * The root of the Postgres schema-diff tree: one node per database.\n *\n * `id` is the fixed sentinel `'database'` — the root has no siblings and\n * the value is never emitted into migration paths. `isEqualTo` is identity\n * (roots always share the `'database'` id). `children()` yields the namespace\n * nodes followed by the role nodes — both are root-level diff subjects. The\n * differ pairs siblings by `(nodeKind, id)`, so a role and a namespace may\n * share a name without colliding.\n */\nexport class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.database;\n\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n\n constructor(input: PostgresDatabaseSchemaNodeInput) {\n super();\n this.namespaces = Object.freeze({ ...input.namespaces });\n this.roles = Object.freeze([...input.roles]);\n this.existingSchemas = Object.freeze([...input.existingSchemas]);\n this.pgVersion = input.pgVersion;\n freezeNode(this);\n }\n\n get id(): string {\n return 'database';\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [...Object.values(this.namespaces), ...this.roles];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.database;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode {\n assertNode(node, 'PostgresDatabaseSchemaNode', PostgresDatabaseSchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNativeEnumSchemaNode } from './postgres-native-enum-schema-node';\nimport type { PostgresTableSchemaNode } from './postgres-table-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresNamespaceSchemaNodeInput {\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n /**\n * The native-enum diff nodes belonging to this namespace, member values in\n * `pg_enum.enumsortorder` (declaration) order. The expected\n * (contract-projected) side attaches each node's `control` (the contract\n * entity's grade); introspection builds nodes with no `control`.\n */\n readonly nativeEnums?: readonly PostgresNativeEnumSchemaNode[];\n}\n\n/**\n * One-per-Postgres-schema diff-tree node. Groups the tables belonging to a\n * single namespace. Per-schema consumers (the relational planner,\n * toSchemaView) read this node's `tables` field structurally via\n * `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`\n * assignment — because `nodeKind` carries this node's own literal\n * (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).\n *\n * `id` is the schema name; `isEqualTo` is identity on it; `children()` returns\n * the table nodes plus `nativeEnums`.\n *\n * `nativeEnums` is the diff-tree representation of native enum types the\n * differ pairs — the sole enum carrier, built directly by both sides: the\n * expected (contract-projected) side and introspection alike hand in\n * `PostgresNativeEnumSchemaNode`s.\n */\nexport class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.namespace;\n\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n readonly nativeEnums: readonly PostgresNativeEnumSchemaNode[];\n\n constructor(input: PostgresNamespaceSchemaNodeInput) {\n super();\n this.schemaName = input.schemaName;\n this.tables = Object.freeze({ ...input.tables });\n this.nativeEnums = Object.freeze([...(input.nativeEnums ?? [])]);\n freezeNode(this);\n }\n\n get id(): string {\n return this.schemaName;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [...Object.values(this.tables), ...this.nativeEnums];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.namespace;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode {\n assertNode(node, 'PostgresNamespaceSchemaNode', PostgresNamespaceSchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { RlsPolicyOperation } from '../postgres-rls-policy';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresPolicySchemaNodeInput {\n /** Full wire name: `<prefix>_<8hex>`. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n}\n\n/**\n * Schema-diff leaf node for a Postgres row-level security policy.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRlsPolicy` contract entities / introspected rows.\n *\n * `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is\n * body-equality. `isEqualTo` compares names only — never byte-compare predicate\n * bodies, because Postgres reprints them.\n */\nexport class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.policy;\n\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n\n constructor(input: PostgresPolicySchemaNodeInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-policy kinds'\n >(other);\n PostgresPolicySchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.policy;\n }\n\n static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode {\n assertNode(node, 'PostgresPolicySchemaNode', PostgresPolicySchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresRoleSchemaNodeInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; callers pass\n * `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n}\n\n/**\n * Schema-diff leaf node for a Postgres database role.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRole` contract entities / introspected rows.\n *\n * Roles are cluster-scoped, so `id` is the bare role name. The differ pairs\n * siblings by `(nodeKind, id)`, so a role and a namespace may share a name\n * (role `public`, schema `public`) without colliding. `isEqualTo` compares\n * ids — name-equality is role-equality for cluster-scoped objects.\n */\nexport class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.role;\n\n readonly name: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRoleSchemaNodeInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-role kinds'\n >(other);\n PostgresRoleSchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.role;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode {\n assertNode(node, 'PostgresRoleSchemaNode', PostgresRoleSchemaNode.is);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAa,6BAAb,MAAa,mCAAmC,gBAAwC;CACtF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CACA;CAEA,YAAY,OAAwC;EAClD,MAAM;EACN,KAAK,aAAa,OAAO,OAAO,EAAE,GAAG,MAAM,WAAW,CAAC;EACvD,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;EAC3C,KAAK,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,eAAe,CAAC;EAC/D,KAAK,YAAY,MAAM;EACvB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO;CACT;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO,CAAC,GAAG,OAAO,OAAO,KAAK,UAAU,GAAG,GAAG,KAAK,KAAK;CAC1D;CAEA,OAAO,GAAG,MAA2D;EACnE,OAAO,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AI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,WAAoC;EAClC,OAAO,CAAC;CACV;CAEA,UAAU,OAA8B;EACtC,MAAM,OAAO,UAGX,KAAK;EACP,yBAAyB,OAAO,IAAI;EACpC,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,OAAO,GAAG,MAAyD;EACjE,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAA6E;EACzF,WAAW,MAAM,4BAA4B,yBAAyB,EAAE;CAC1E;AACF;;;;;;;;;;;;;;;AC9DA,IAAa,yBAAb,MAAa,+BAA+B,gBAAwC;CAClF,WAA6B,uBAAuB;CAEpD;CACA;CAEA,YAAY,OAAoC;EAC9C,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,cAAc,MAAM;EACzB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,WAAoC;EAClC,OAAO,CAAC;CACV;CAEA,UAAU,OAA8B;EACtC,MAAM,OAAO,UAGX,KAAK;EACP,uBAAuB,OAAO,IAAI;EAClC,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,OAAO,GAAG,MAAuD;EAC/D,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAA+D;EAC3E,WAAW,MAAM,0BAA0B,uBAAuB,EAAE;CACtE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v as PG_TEXT_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
|
|
2
2
|
import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
|
|
3
|
-
import { n as escapeLiteral } from "./sql-utils-
|
|
3
|
+
import { n as escapeLiteral } from "./sql-utils-SU4FDvIV.mjs";
|
|
4
4
|
import { TableSource } from "@prisma-next/sql-relational-core/ast";
|
|
5
5
|
import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
|
|
6
6
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
@@ -9,6 +9,7 @@ import { SqlNamespaceBase, SqlNode } from "@prisma-next/sql-contract/types";
|
|
|
9
9
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
10
10
|
import { composeSqlEntityKinds } from "@prisma-next/sql-contract/entity-kinds";
|
|
11
11
|
import { cfExpr } from "@prisma-next/sql-relational-core/contract-free";
|
|
12
|
+
import { invariant } from "@prisma-next/utils/assertions";
|
|
12
13
|
//#region src/core/postgres-rls-enablement.ts
|
|
13
14
|
/**
|
|
14
15
|
* Postgres contract-IR marker for `@@rls` on a model: the table named here is
|
|
@@ -215,6 +216,16 @@ var PostgresSchema = class extends SqlNamespaceBase {
|
|
|
215
216
|
rlsEnablementEntityKind,
|
|
216
217
|
nativeEnumEntityKind
|
|
217
218
|
]), "carry");
|
|
219
|
+
const nativeEnumSlot = dispatched["native_enum"];
|
|
220
|
+
if (nativeEnumSlot !== void 0) {
|
|
221
|
+
const rekeyed = {};
|
|
222
|
+
for (const [handle, entity] of Object.entries(nativeEnumSlot)) {
|
|
223
|
+
const physicalName = PostgresNativeEnum.is(entity) ? entity.typeName : handle;
|
|
224
|
+
invariant(!Object.hasOwn(rekeyed, physicalName), `PostgresSchema "${input.id}": two native_enum entities resolve to the same physical type name "${physicalName}". Give them distinct @@map type names.`);
|
|
225
|
+
rekeyed[physicalName] = entity;
|
|
226
|
+
}
|
|
227
|
+
dispatched["native_enum"] = Object.freeze(rekeyed);
|
|
228
|
+
}
|
|
218
229
|
const valueSetRaw = dispatched["valueSet"];
|
|
219
230
|
const entriesInput = { ...valueSetRaw !== void 0 && Object.keys(valueSetRaw).length === 0 ? {
|
|
220
231
|
...dispatched,
|
|
@@ -410,4 +421,4 @@ function postgresCreateNamespace(input) {
|
|
|
410
421
|
//#endregion
|
|
411
422
|
export { PostgresRlsEnablement as _, nativeEnumEntityKind as a, roleEntityKind as c, PostgresRlsEnablementSchema as d, PostgresRlsPolicySchema as f, PostgresRlsPolicy as g, ROLE_DEFAULT_CONTROL_POLICY as h, postgresCreateNamespace as i, PostgresTableSource as l, PostgresRole as m, PostgresUnboundSchema as n, policyEntityKind as o, PostgresRoleSchema as p, isPostgresSchema as r, rlsEnablementEntityKind as s, PostgresSchema as t, PostgresNativeEnumSchema as u };
|
|
412
423
|
|
|
413
|
-
//# sourceMappingURL=postgres-schema-
|
|
424
|
+
//# sourceMappingURL=postgres-schema-DWQ0-CPb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-DWQ0-CPb.mjs","names":[],"sources":["../src/core/postgres-rls-enablement.ts","../src/core/postgres-rls-policy.ts","../src/core/postgres-role.ts","../src/core/postgres-validators.ts","../src/core/ast/table-source.ts","../src/core/entity-kinds.ts","../src/core/postgres-schema.ts"],"sourcesContent":["import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresRlsEnablementInput {\n /** Name of the table this marker declares RLS-controlled. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). Markers are schema-scoped like policies. */\n readonly namespaceId: string;\n}\n\n/**\n * Postgres contract-IR marker for `@@rls` on a model: the table named here is\n * RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never\n * by the policy set).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an\n * entity kind, extends `SqlNode`, and is stored in `contract.json` under\n * `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`\n * discriminant is enumerable so it survives JSON serialization; the literal\n * matches the entries key (one-string rule).\n */\nexport class PostgresRlsEnablement extends SqlNode {\n override readonly kind = 'rls' as const;\n readonly tableName: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRlsEnablementInput) {\n super();\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';\n\nexport interface PostgresRlsPolicyInput {\n /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). Policies are schema-scoped. */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n}\n\n/**\n * Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresPolicySchemaNode` for that role.\n *\n * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`\n * discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it\n * survives JSON serialization and enables dispatch. The literal matches the\n * entries key (one-string rule: node.kind === entries key === entity kind).\n */\nexport class PostgresRlsPolicy extends SqlNode {\n override readonly kind = 'policy' as const;\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n\n constructor(input: PostgresRlsPolicyInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\n/**\n * Roles are referenced by the contract but never owned — the framework\n * issues no `CREATE`/`DROP ROLE`, so a role's effective governance is always\n * `external`: a missing declared role fails verify, an extra live role is\n * tolerated, and the planner emits zero role DDL. `external` is the only\n * value a role's control can ever carry.\n */\nexport const ROLE_DEFAULT_CONTROL_POLICY = 'external';\n\nexport interface PostgresRoleInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`\n * from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n /**\n * Defaults to {@link ROLE_DEFAULT_CONTROL_POLICY} when omitted. Roles are\n * referenced but never owned, so `'external'` is the only allowed value.\n */\n readonly control?: 'external';\n}\n\n/**\n * Postgres contract-IR class for a database role (`CREATE ROLE …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresRoleSchemaNode` for that role.\n *\n * Roles are cluster-scoped, so their namespace coordinate is always\n * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.\n * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.\n * The `kind: 'role'` discriminant is enumerable so it survives JSON.\n * Matches the entries key (one-string rule).\n *\n * `control` always carries a value (never omitted): it defaults to\n * {@link ROLE_DEFAULT_CONTROL_POLICY} in the constructor, so both a\n * freshly-authored role and one hydrated from an older `contract.json`\n * lacking the field resolve the same way — the control-policy resolver\n * reads it directly off the entity instead of special-casing role issues.\n */\nexport class PostgresRole extends SqlNode {\n override readonly kind = 'role' as const;\n readonly name: string;\n readonly namespaceId: string;\n readonly control: 'external';\n\n constructor(input: PostgresRoleInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n this.control = input.control ?? ROLE_DEFAULT_CONTROL_POLICY;\n freezeNode(this);\n }\n}\n","import { type } from 'arktype';\n\nexport const PostgresRoleSchema = type({\n kind: \"'role'\",\n name: 'string',\n namespaceId: 'string',\n 'control?': \"'external'\",\n});\n\nexport const PostgresRlsPolicySchema = type({\n kind: \"'policy'\",\n name: 'string',\n prefix: 'string',\n tableName: 'string',\n namespaceId: 'string',\n operation: \"'select' | 'insert' | 'update' | 'delete' | 'all'\",\n roles: type.string.array().readonly(),\n 'using?': 'string',\n 'withCheck?': 'string',\n permissive: 'boolean',\n});\n\nexport const PostgresRlsEnablementSchema = type({\n kind: \"'rls'\",\n tableName: 'string',\n namespaceId: 'string',\n});\n\nexport const PostgresNativeEnumSchema = type({\n kind: \"'postgres-enum'\",\n typeName: 'string',\n members: type.string.array().readonly(),\n 'control?': \"'managed' | 'tolerated' | 'external' | 'observed'\",\n});\n","import {\n type AnyFromSource,\n type AstRewriter,\n TableSource,\n} from '@prisma-next/sql-relational-core/ast';\n\nexport class PostgresTableSource extends TableSource {\n readonly schema: string | undefined;\n\n constructor(options: {\n readonly name: string;\n readonly schema?: string;\n readonly alias?: string;\n }) {\n super(options.name, options.alias);\n this.schema = options.schema;\n this.freeze();\n }\n\n override rewrite(rewriter: AstRewriter): AnyFromSource {\n return rewriter.tableSource ? rewriter.tableSource(this) : this;\n }\n}\n","import type { EntityKindDescriptor } from '@prisma-next/framework-components/ir';\nimport { PostgresNativeEnum, type PostgresNativeEnumInput } from './postgres-native-enum';\nimport { PostgresRlsEnablement, type PostgresRlsEnablementInput } from './postgres-rls-enablement';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsEnablementSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\n\nexport const policyEntityKind: EntityKindDescriptor<PostgresRlsPolicyInput, PostgresRlsPolicy> = {\n kind: 'policy',\n schema: PostgresRlsPolicySchema,\n construct: (input) => new PostgresRlsPolicy(input),\n};\n\nexport const roleEntityKind: EntityKindDescriptor<PostgresRoleInput, PostgresRole> = {\n kind: 'role',\n schema: PostgresRoleSchema,\n construct: (input) => new PostgresRole(input),\n};\n\nexport const rlsEnablementEntityKind: EntityKindDescriptor<\n PostgresRlsEnablementInput,\n PostgresRlsEnablement\n> = {\n kind: 'rls',\n schema: PostgresRlsEnablementSchema,\n construct: (input) => new PostgresRlsEnablement(input),\n};\n\nexport const nativeEnumEntityKind: EntityKindDescriptor<\n PostgresNativeEnumInput,\n PostgresNativeEnum\n> = {\n kind: 'native_enum',\n schema: PostgresNativeEnumSchema,\n construct: (input) => new PostgresNativeEnum(input),\n};\n","import type { Contract } from '@prisma-next/contract/types';\nimport {\n freezeNode,\n hydrateNamespaceEntities,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { composeSqlEntityKinds } from '@prisma-next/sql-contract/entity-kinds';\nimport {\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceInput,\n type SqlStorage,\n type StorageTable,\n type StorageValueSet,\n} from '@prisma-next/sql-contract/types';\n\nimport { type CfExpr, cfExpr } from '@prisma-next/sql-relational-core/contract-free';\nimport { invariant } from '@prisma-next/utils/assertions';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PostgresTableSource } from './ast/table-source';\nimport { PG_TEXT_CODEC_ID } from './codec-ids';\nimport {\n nativeEnumEntityKind,\n policyEntityKind,\n rlsEnablementEntityKind,\n roleEntityKind,\n} from './entity-kinds';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport type { PostgresRlsEnablement } from './postgres-rls-enablement';\nimport type { PostgresRlsPolicy } from './postgres-rls-policy';\nimport type { PostgresRole } from './postgres-role';\nimport { escapeLiteral } from './sql-utils';\n\nexport type PostgresContract = Contract<SqlStorage> & { readonly target: 'postgres' };\n\nexport type PostgresNamespaceEntries = SqlNamespaceEntries & {\n readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;\n readonly role?: Readonly<Record<string, PostgresRole>>;\n readonly rls?: Readonly<Record<string, PostgresRlsEnablement>>;\n readonly native_enum?: Readonly<Record<string, PostgresNativeEnum>>;\n};\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends SqlNamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: PostgresNamespaceEntries;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n composeSqlEntityKinds([\n policyEntityKind,\n roleEntityKind,\n rlsEnablementEntityKind,\n nativeEnumEntityKind,\n ]),\n 'carry',\n );\n\n // A native enum keys under its PHYSICAL type name in storage `entries`\n // (ADR 221 coordinate `entityName`). The family/authoring layer keys every\n // block by its author handle, so re-key the `native_enum` slot by each\n // entity's `typeName` here — target-local Postgres code that already knows\n // this entity kind. This runs at both authoring and hydration; a serialized\n // contract's key already equals the `typeName`, so the re-key is idempotent.\n const nativeEnumSlot = dispatched['native_enum'];\n if (nativeEnumSlot !== undefined) {\n const rekeyed: Record<string, unknown> = {};\n for (const [handle, entity] of Object.entries(nativeEnumSlot)) {\n const physicalName = PostgresNativeEnum.is(entity) ? entity.typeName : handle;\n invariant(\n !Object.hasOwn(rekeyed, physicalName),\n `PostgresSchema \"${input.id}\": two native_enum entities resolve to the same physical type name \"${physicalName}\". Give them distinct @@map type names.`,\n );\n rekeyed[physicalName] = entity;\n }\n dispatched['native_enum'] = Object.freeze(rekeyed);\n }\n\n // Drop an empty valueSet so presence signals non-emptiness.\n const valueSetRaw = dispatched['valueSet'];\n const withPresence =\n valueSetRaw !== undefined && Object.keys(valueSetRaw).length === 0\n ? { ...dispatched, valueSet: undefined }\n : dispatched;\n\n const entriesInput: Record<string, Readonly<Record<string, unknown>> | undefined> = {\n ...withPresence,\n };\n\n this.entries = Object.freeze(\n blindCast<\n PostgresNamespaceEntries,\n 'composeSqlEntityKinds([policyEntityKind, roleEntityKind, rlsEnablementEntityKind, nativeEnumEntityKind]) supplies table→StorageTable, valueSet→StorageValueSet, policy→PostgresRlsPolicy, role→PostgresRole, rls→PostgresRlsEnablement, native_enum→PostgresNativeEnum descriptors'\n >(entriesInput),\n );\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined {\n return this.entries.valueSet;\n }\n\n get policy(): Readonly<Record<string, PostgresRlsPolicy>> {\n return this.entries.policy ?? Object.freeze({});\n }\n\n get role(): Readonly<Record<string, PostgresRole>> {\n return this.entries.role ?? Object.freeze({});\n }\n\n get rls(): Readonly<Record<string, PostgresRlsEnablement>> {\n return this.entries.rls ?? Object.freeze({});\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a\n * builder-built catalog check compares `n.nspname` / `table_schema`\n * against. Named schemas bind the schema name as a text parameter; the\n * unbound singleton overrides this to the opaque `current_schema()`\n * expression so the live connection's `search_path` decides at runtime.\n */\n schemaFilterExpression(): CfExpr {\n return cfExpr.param(this.id, PG_TEXT_CODEC_ID);\n }\n\n /**\n * Typed-AST counterpart of {@link qualifyTable}: the FROM source a\n * builder-built check uses to address a user table in this namespace.\n * Named schemas qualify (`\"schema\".\"table\"`); the unbound singleton\n * overrides this to leave the table unqualified so `search_path`\n * resolves it at runtime.\n */\n tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n schema: this.id,\n ...ifDefined('alias', alias),\n });\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` route through the polymorphic\n * `PostgresUnboundSchema` overrides and produce unqualified\n * (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`\n * route through the polymorphic factory and produce unqualified output\n * automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n\n override schemaFilterExpression(): CfExpr {\n return cfExpr.raw('current_schema()', { codecId: PG_TEXT_CODEC_ID, nullable: false });\n }\n\n override tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n ...ifDefined('alias', alias),\n });\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set. Native-enum column type names are\n * schema-qualified earlier, at column construction, via the target's\n * `authoring.qualifyColumnType` hook (`postgresQualifyColumnType`), so this\n * factory just materialises the namespace from already-qualified entries.\n */\nexport function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n ...input.entries,\n table: input.entries['table'] ?? {},\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,wBAAb,cAA2C,QAAQ;CACjD,OAAyB;CACzB;CACA;CAEA,YAAY,OAAmC;EAC7C,MAAM;EACN,KAAK,YAAY,MAAM;EACvB,KAAK,cAAc,MAAM;EACzB,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;ACKA,IAAa,oBAAb,cAAuC,QAAQ;CAC7C,OAAyB;CAC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M,SAAS;GAAE,IAAI;GAAsB,SAAS,EAAE,OAAO,CAAC,EAAE;EAAE,CAAC;CACrE;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;CAEA,yBAA0C;EACxC,OAAO,OAAO,IAAI,oBAAoB;GAAE,SAAS;GAAkB,UAAU;EAAM,CAAC;CACtF;CAEA,YAAqB,WAAmB,OAAqC;EAC3E,OAAO,IAAI,oBAAoB;GAC7B,MAAM;GACN,GAAG,UAAU,SAAS,KAAK;EAC7B,CAAC;CACH;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;;;;AAgBA,SAAgB,wBAAwB,OAA0C;CAChF,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,GAAG,MAAM;GACT,OAAO,MAAM,QAAQ,YAAY,CAAC;EACpC;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-schema-DsrtYp2v.d.mts","names":[],"sources":["../src/core/postgres-role.ts","../src/core/postgres-rls-enablement.ts","../src/core/postgres-native-enum.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;UAYiB,iBAAA;EAAA,SACN,IAAA;EAAA;;;;EAAA,SAKA,WAAA;EA2BE;;;;EAAA,SAtBF,OAAA;AAAA;;;;;;;;AA4B2B;;;;AChDtC;;;;AAIsB;AAetB;;;cDuBa,YAAA,SAAqB,OAAO;EAAA,SACrB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA;cAEG,KAAA,EAAO,iBAAA;AAAA;;;UChDJ,0BAAA;;WAEN,SAAA;;WAEA,WAAW;AAAA;ADKtB;;;;;;;;AAWkB;AAsBlB;;;AAjCA,cCUa,qBAAA,SAA8B,OAAO;EAAA,SAC9B,IAAA;EAAA,SACT,SAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,0BAAA;AAAA;;;UCvBJ,uBAAA;;WAEN,QAAA;;WAEA,OAAA;EAAA,SACA,OAAA,GAAU,aAAa;AAAA;;;;;;;AFchB;AAsBlB;;;;;;;;;;;;cEda,kBAAA,SAA2B,OAAA;EAAA,OAC/B,EAAA,CAAG,IAAA,YAAgB,IAAA,IAAQ,kBAAA;EAAA,SAMhB,IAAA;EAAA,SACT,QAAA;EAAA,SACA,OAAA;EAAA,SACQ,OAAA,GAAU,aAAA;cAEf,KAAA,EAAO,uBAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"postgres-schema-DsrtYp2v.d.mts","names":[],"sources":["../src/core/postgres-role.ts","../src/core/postgres-rls-enablement.ts","../src/core/postgres-native-enum.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;UAYiB,iBAAA;EAAA,SACN,IAAA;EAAA;;;;EAAA,SAKA,WAAA;EA2BE;;;;EAAA,SAtBF,OAAA;AAAA;;;;;;;;AA4B2B;;;;AChDtC;;;;AAIsB;AAetB;;;cDuBa,YAAA,SAAqB,OAAO;EAAA,SACrB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA;cAEG,KAAA,EAAO,iBAAA;AAAA;;;UChDJ,0BAAA;;WAEN,SAAA;;WAEA,WAAW;AAAA;ADKtB;;;;;;;;AAWkB;AAsBlB;;;AAjCA,cCUa,qBAAA,SAA8B,OAAO;EAAA,SAC9B,IAAA;EAAA,SACT,SAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,0BAAA;AAAA;;;UCvBJ,uBAAA;;WAEN,QAAA;;WAEA,OAAA;EAAA,SACA,OAAA,GAAU,aAAa;AAAA;;;;;;;AFchB;AAsBlB;;;;;;;;;;;;cEda,kBAAA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;;;;;ECmKtC,mBAAA;EDzJ2B;;;;;AAEe;;ECkK1C,sBAAA,IAA0B,MAAA;;AA3K5B;;;;;;EAsLE,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;EAtLqB;AAAA;AAEvE;;;;;;;;;EAuME,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;;;;;;;;;;;;;;;;;cAwBb,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA;EAIA,sBAAA,IAA0B,MAAA;EAI1B,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;AAAA;;;;;;;;;;iBAmB3C,gBAAA,CAAiB,EAAA,YAAc,EAAA,IAAM,cAAc;;;;;AAhQR;AAiB3D;;;;;;;;;iBAiQgB,uBAAA,CAAwB,KAAA,EAAO,iBAAA,GAAoB,cAAc"}
|
package/dist/{postgres-table-schema-node-9FCtCUz2.mjs → postgres-table-schema-node-D6LvInCe.mjs}
RENAMED
|
@@ -13,7 +13,8 @@ const PostgresSchemaNodeKind = {
|
|
|
13
13
|
namespace: "postgres-namespace",
|
|
14
14
|
table: "postgres-table",
|
|
15
15
|
policy: "postgres-policy",
|
|
16
|
-
role: "postgres-role"
|
|
16
|
+
role: "postgres-role",
|
|
17
|
+
nativeEnum: "postgres-native-enum"
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* The one real map from a Postgres-specific `nodeKind` to the
|
|
@@ -26,7 +27,8 @@ const POSTGRES_NODE_GRANULARITY = {
|
|
|
26
27
|
[PostgresSchemaNodeKind.namespace]: "namespace",
|
|
27
28
|
[PostgresSchemaNodeKind.table]: "entity",
|
|
28
29
|
[PostgresSchemaNodeKind.policy]: "structural",
|
|
29
|
-
[PostgresSchemaNodeKind.role]: "structural"
|
|
30
|
+
[PostgresSchemaNodeKind.role]: "structural",
|
|
31
|
+
[PostgresSchemaNodeKind.nativeEnum]: "entity"
|
|
30
32
|
};
|
|
31
33
|
function isPostgresSchemaNodeKind(nodeKind) {
|
|
32
34
|
return Object.hasOwn(POSTGRES_NODE_GRANULARITY, nodeKind);
|
|
@@ -49,14 +51,23 @@ function postgresDiffSubjectGranularity(nodeKind) {
|
|
|
49
51
|
return isPostgresSchemaNodeKind(nodeKind) ? postgresNodeGranularity(nodeKind) : relationalNodeGranularity(nodeKind);
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* The map from a Postgres-specific `nodeKind` to its storage `entityKind` — the
|
|
55
|
+
* same vocabulary the contract storage's `entries` dictionary keys use. The
|
|
56
|
+
* whole-table and native-enum kinds each have an entity of their own;
|
|
55
57
|
* database/namespace/policy/role nodes map to nothing here (a namespace is
|
|
56
58
|
* addressed by id, not by an `entries` kind; policies and roles are
|
|
57
59
|
* structural, never a sibling space's unclaimed entity).
|
|
60
|
+
*
|
|
61
|
+
* The native enum keys under its PHYSICAL type name in `entries.native_enum`
|
|
62
|
+
* (ADR 221), so its diff node's `typeName` addresses the entity on the generic
|
|
63
|
+
* coordinate directly — no by-type-name walk needed. This lets the framework's
|
|
64
|
+
* unclaimed-elements sweep classify enum ownership the same coordinate way it
|
|
65
|
+
* classifies tables.
|
|
58
66
|
*/
|
|
59
|
-
const POSTGRES_NODE_ENTITY_KIND = {
|
|
67
|
+
const POSTGRES_NODE_ENTITY_KIND = {
|
|
68
|
+
[PostgresSchemaNodeKind.table]: "table",
|
|
69
|
+
[PostgresSchemaNodeKind.nativeEnum]: "native_enum"
|
|
70
|
+
};
|
|
60
71
|
/** Looks up the storage entityKind for a Postgres-specific `nodeKind`. */
|
|
61
72
|
function postgresNodeEntityKind(nodeKind) {
|
|
62
73
|
return POSTGRES_NODE_ENTITY_KIND[nodeKind];
|
|
@@ -73,6 +84,58 @@ function postgresDiffSubjectEntityKind(nodeKind) {
|
|
|
73
84
|
return isPostgresSchemaNodeKind(nodeKind) ? postgresNodeEntityKind(nodeKind) : relationalNodeEntityKind(nodeKind);
|
|
74
85
|
}
|
|
75
86
|
//#endregion
|
|
87
|
+
//#region src/core/schema-ir/postgres-native-enum-schema-node.ts
|
|
88
|
+
/**
|
|
89
|
+
* Schema-diff leaf node for a native Postgres enum type.
|
|
90
|
+
*
|
|
91
|
+
* This is a derived, transient node walked by the differ — it is NEVER
|
|
92
|
+
* serialized. Both sides derive it on the namespace node: the expected side
|
|
93
|
+
* from the contract's hydrated `entries.native_enum` entities, the actual
|
|
94
|
+
* side from the adapter's introspected `nativeEnums`.
|
|
95
|
+
*
|
|
96
|
+
* Enum types are schema-scoped, so identity is (namespace, type name): the
|
|
97
|
+
* namespace coordinate comes from tree position (the differ pairs enum nodes
|
|
98
|
+
* only inside an already-paired namespace) and `id` carries the type name,
|
|
99
|
+
* prefixed with the entries-kind vocabulary (`native_enum:<typeName>`) so it
|
|
100
|
+
* cannot collide with a sibling table of the same name — the same
|
|
101
|
+
* sibling-prefix convention relational column nodes use (`column:<name>`).
|
|
102
|
+
*
|
|
103
|
+
* `isEqualTo` compares members POSITIONALLY — `['a','b'] ≠ ['b','a']` —
|
|
104
|
+
* because Postgres enum sort order is semantic. `control` is contract
|
|
105
|
+
* metadata, not database state, and does not participate in equality.
|
|
106
|
+
*/
|
|
107
|
+
var PostgresNativeEnumSchemaNode = class PostgresNativeEnumSchemaNode extends SqlSchemaIRNode {
|
|
108
|
+
nodeKind = PostgresSchemaNodeKind.nativeEnum;
|
|
109
|
+
typeName;
|
|
110
|
+
namespaceId;
|
|
111
|
+
members;
|
|
112
|
+
constructor(input) {
|
|
113
|
+
super();
|
|
114
|
+
this.typeName = input.typeName;
|
|
115
|
+
this.namespaceId = input.namespaceId;
|
|
116
|
+
this.members = Object.freeze([...input.members]);
|
|
117
|
+
if (input.control !== void 0) this.control = input.control;
|
|
118
|
+
freezeNode(this);
|
|
119
|
+
}
|
|
120
|
+
get id() {
|
|
121
|
+
return `native_enum:${this.typeName}`;
|
|
122
|
+
}
|
|
123
|
+
children() {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
isEqualTo(other) {
|
|
127
|
+
const node = blindCast(other);
|
|
128
|
+
PostgresNativeEnumSchemaNode.assert(node);
|
|
129
|
+
return this.typeName === node.typeName && this.members.length === node.members.length && this.members.every((member, index) => member === node.members[index]);
|
|
130
|
+
}
|
|
131
|
+
static is(node) {
|
|
132
|
+
return node.nodeKind === PostgresSchemaNodeKind.nativeEnum;
|
|
133
|
+
}
|
|
134
|
+
static assert(node) {
|
|
135
|
+
assertNode(node, "PostgresNativeEnumSchemaNode", PostgresNativeEnumSchemaNode.is);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
//#endregion
|
|
76
139
|
//#region src/core/schema-ir/postgres-table-schema-node.ts
|
|
77
140
|
/**
|
|
78
141
|
* Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields
|
|
@@ -148,6 +211,6 @@ var PostgresTableSchemaNode = class PostgresTableSchemaNode extends SqlSchemaIRN
|
|
|
148
211
|
}
|
|
149
212
|
};
|
|
150
213
|
//#endregion
|
|
151
|
-
export { postgresDiffSubjectGranularity as i,
|
|
214
|
+
export { postgresDiffSubjectGranularity as a, postgresDiffSubjectEntityKind as i, PostgresNativeEnumSchemaNode as n, postgresNodeEntityKind as o, PostgresSchemaNodeKind as r, PostgresTableSchemaNode as t };
|
|
152
215
|
|
|
153
|
-
//# sourceMappingURL=postgres-table-schema-node-
|
|
216
|
+
//# sourceMappingURL=postgres-table-schema-node-D6LvInCe.mjs.map
|