@prisma-next/target-postgres 0.14.0-dev.6 → 0.14.0-dev.60
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-WkqG_MkU.mjs +419 -0
- package/dist/authoring-WkqG_MkU.mjs.map +1 -0
- package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
- package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
- package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
- package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
- package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
- package/dist/codec-ids-C_-Hj6bL.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-BiIWziRO.d.mts} +3 -2
- package/dist/codec-types-BiIWziRO.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/codecs-CkVQrZ4G.mjs +913 -0
- package/dist/codecs-CkVQrZ4G.mjs.map +1 -0
- package/dist/{codecs--0A5_4Bq.d.mts → codecs-Cm-nS4mQ.d.mts} +111 -4
- package/dist/codecs-Cm-nS4mQ.d.mts.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +3 -757
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +33 -3
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +4 -4
- package/dist/control-policy-Co_13Hxa.mjs +1128 -0
- package/dist/control-policy-Co_13Hxa.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +900 -35
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
- package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-QDyOSeLc.mjs → ddl-B-krEXY1.mjs} +77 -6
- package/dist/ddl-B-krEXY1.mjs.map +1 -0
- package/dist/ddl.d.mts +3 -2
- package/dist/ddl.mjs +2 -2
- package/dist/default-normalizer.d.mts +1 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +247 -1
- package/dist/default-normalizer.mjs.map +1 -0
- package/dist/descriptor-meta-BOcKPaLE.mjs +22 -0
- package/dist/descriptor-meta-BOcKPaLE.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
- package/dist/diff-database-schema-BOsDnH64.mjs +266 -0
- package/dist/diff-database-schema-BOsDnH64.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +46 -0
- package/dist/diff-database-schema.d.mts.map +1 -0
- package/dist/diff-database-schema.mjs +2 -0
- package/dist/errors-DO-w0EUS.mjs +35 -0
- package/dist/errors-DO-w0EUS.mjs.map +1 -0
- package/dist/errors.d.mts +11 -9
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/issue-planner.d.mts +35 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -2
- package/dist/migration.d.mts +5 -5
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -4
- package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
- package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
- package/dist/native-type-normalizer.mjs +37 -1
- package/dist/native-type-normalizer.mjs.map +1 -0
- package/dist/nodes-B815pj_X.mjs +162 -0
- package/dist/nodes-B815pj_X.mjs.map +1 -0
- package/dist/nodes-BtQyZha6.d.mts +146 -0
- package/dist/nodes-BtQyZha6.d.mts.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-D6_7-7Vc.d.mts} +68 -15
- package/dist/op-factory-call-D6_7-7Vc.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-DxNNKUeZ.mjs} +300 -31
- package/dist/op-factory-call-DxNNKUeZ.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +144 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-CNrc1Odu.mjs +422 -0
- package/dist/planner-CNrc1Odu.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -6
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
- package/dist/planner-identity-values.d.mts +8 -2
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -2
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-NI-oGKcw.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-NI-oGKcw.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-a-tjfKsA.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-a-tjfKsA.d.mts.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-jqUUGyQR.mjs → planner-sql-checks-AXoxB1Jl.mjs} +2 -2
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-AXoxB1Jl.mjs.map} +1 -1
- package/dist/planner-sql-checks.d.mts +2 -2
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +72 -17
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +3 -2
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-Dg-N7KA7.mjs} +45 -41
- package/dist/postgres-contract-view-Dg-N7KA7.mjs.map +1 -0
- package/dist/postgres-database-schema-node-CfdTY-Qs.d.mts +218 -0
- package/dist/postgres-database-schema-node-CfdTY-Qs.d.mts.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-Bzzi0Asr.d.mts} +28 -9
- package/dist/postgres-migration-Bzzi0Asr.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-ChyRsWvE.mjs} +53 -45
- package/dist/postgres-migration-ChyRsWvE.mjs.map +1 -0
- package/dist/postgres-native-enum-xdiqmBf_.mjs +41 -0
- package/dist/postgres-native-enum-xdiqmBf_.mjs.map +1 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
- package/dist/postgres-role-schema-node-BiSTCTNg.mjs +195 -0
- package/dist/postgres-role-schema-node-BiSTCTNg.mjs.map +1 -0
- package/dist/postgres-schema-CU4gF6QZ.d.mts +257 -0
- package/dist/postgres-schema-CU4gF6QZ.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DTLA_aRi.mjs} +171 -10
- package/dist/postgres-schema-DTLA_aRi.mjs.map +1 -0
- package/dist/postgres-table-schema-node-9FCtCUz2.mjs +153 -0
- package/dist/postgres-table-schema-node-9FCtCUz2.mjs.map +1 -0
- package/dist/render-ops.d.mts +1 -1
- package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
- package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/resolve-ddl-schema-Ca88Tg6W.mjs +22 -0
- package/dist/resolve-ddl-schema-Ca88Tg6W.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +20 -0
- package/dist/rls-canonicalize.d.mts.map +1 -0
- package/dist/rls-canonicalize.mjs +2 -0
- package/dist/runtime.d.mts +6 -8
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-ir-annotations.d.mts +15 -0
- package/dist/schema-ir-annotations.d.mts.map +1 -0
- package/dist/schema-ir-annotations.mjs +2 -0
- package/dist/types.d.mts +4 -140
- package/dist/types.mjs +5 -2
- package/dist/wire-name-rHHtr1h0.mjs +75 -0
- package/dist/wire-name-rHHtr1h0.mjs.map +1 -0
- package/package.json +23 -17
- package/src/contract-free/checks.ts +73 -0
- package/src/contract-free/ddl.ts +71 -1
- package/src/core/authoring.ts +356 -2
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +2 -0
- package/src/core/codecs.ts +180 -1
- package/src/core/ddl/nodes.ts +141 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +10 -1
- package/src/core/entity-kinds.ts +41 -0
- package/src/core/errors.ts +14 -12
- package/src/core/migrations/bound-schema.ts +10 -0
- package/src/core/migrations/column-ddl-rendering.ts +117 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +160 -0
- package/src/core/migrations/control-policy.ts +99 -46
- package/src/core/migrations/diff-database-schema.ts +217 -0
- package/src/core/migrations/issue-planner.ts +692 -652
- package/src/core/migrations/op-factory-call.ts +189 -21
- package/src/core/migrations/operations/columns.ts +24 -12
- package/src/core/migrations/operations/constraints.ts +1 -1
- package/src/core/migrations/operations/data-transform.ts +6 -0
- package/src/core/migrations/operations/dependencies.ts +2 -1
- package/src/core/migrations/operations/rls.ts +187 -0
- package/src/core/migrations/operations/shared.ts +0 -30
- package/src/core/migrations/planner-ddl-builders.ts +20 -58
- package/src/core/migrations/planner-identity-values.ts +1 -1
- package/src/core/migrations/planner-recipes.ts +31 -13
- package/src/core/migrations/planner-sql-checks.ts +1 -1
- package/src/core/migrations/planner-strategies.ts +248 -216
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +381 -59
- package/src/core/migrations/postgres-migration.ts +70 -86
- package/src/core/migrations/render-typescript.ts +42 -15
- package/src/core/migrations/resolve-ddl-schema.ts +26 -0
- package/src/core/migrations/runner.ts +10 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +47 -31
- package/src/core/namespace-ids.ts +3 -0
- package/src/core/postgres-contract-serializer.ts +46 -71
- package/src/core/postgres-contract-view.ts +48 -0
- package/src/core/postgres-native-enum.ts +51 -0
- package/src/core/postgres-rls-enablement.ts +34 -0
- package/src/core/postgres-rls-policy.ts +64 -0
- package/src/core/postgres-role.ts +37 -0
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/postgres-schema.ts +64 -15
- package/src/core/postgres-validators.ts +33 -0
- package/src/core/psl-infer/infer-psl-contract.ts +1325 -0
- package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
- package/src/core/psl-infer/postgres-type-map.ts +128 -0
- package/src/core/rls/canonicalize.ts +48 -0
- package/src/core/rls/wire-name.ts +33 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +60 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +79 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +63 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
- package/src/core/schema-ir/schema-node-kinds.ts +106 -0
- package/src/exports/codecs.ts +3 -0
- package/src/exports/contract-free.ts +11 -1
- package/src/exports/control.ts +27 -33
- package/src/exports/ddl.ts +6 -0
- package/src/exports/diff-database-schema.ts +7 -0
- package/src/exports/issue-planner.ts +1 -1
- package/src/exports/migration.ts +1 -0
- package/src/exports/op-factory-call.ts +1 -0
- package/src/exports/planner-ddl-builders.ts +0 -2
- package/src/exports/planner-identity-values.ts +4 -1
- package/src/exports/planner.ts +1 -0
- package/src/exports/rls-canonicalize.ts +7 -0
- package/src/exports/runtime.ts +1 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/types.ts +34 -0
- package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
- package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
- package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
- package/dist/ddl-QDyOSeLc.mjs.map +0 -1
- package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
- package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
- package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
- package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
- package/dist/errors-CUk87ByX.mjs +0 -33
- package/dist/errors-CUk87ByX.mjs.map +0 -1
- package/dist/issue-planner-DL6g3CmE.mjs +0 -824
- package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
- package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
- package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
- package/dist/nodes-Bbhs2rwj.mjs +0 -76
- package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
- package/dist/nodes-pLeLgdis.d.mts +0 -67
- package/dist/nodes-pLeLgdis.d.mts.map +0 -1
- package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
- package/dist/planner-Bs_baQax.mjs +0 -324
- package/dist/planner-Bs_baQax.mjs.map +0 -1
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
- package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
- package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
- package/dist/render-typescript-KMgosran.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/src/core/postgres-enum-type-schema.ts +0 -17
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { n as PostgresSchemaNodeKind } from "./postgres-table-schema-node-9FCtCUz2.mjs";
|
|
2
|
+
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
+
import { SqlSchemaIRNode, assertNode } from "@prisma-next/sql-schema-ir/types";
|
|
5
|
+
//#region src/core/schema-ir/postgres-database-schema-node.ts
|
|
6
|
+
/**
|
|
7
|
+
* The root of the Postgres schema-diff tree: one node per database.
|
|
8
|
+
*
|
|
9
|
+
* `id` is the fixed sentinel `'database'` — the root has no siblings and
|
|
10
|
+
* the value is never emitted into migration paths. `isEqualTo` is identity
|
|
11
|
+
* (roots always share the `'database'` id). `children()` returns namespace
|
|
12
|
+
* nodes only; roles are held on the root but not yielded (role diffing is a
|
|
13
|
+
* later slice).
|
|
14
|
+
*/
|
|
15
|
+
var PostgresDatabaseSchemaNode = class PostgresDatabaseSchemaNode extends SqlSchemaIRNode {
|
|
16
|
+
nodeKind = PostgresSchemaNodeKind.database;
|
|
17
|
+
namespaces;
|
|
18
|
+
roles;
|
|
19
|
+
existingSchemas;
|
|
20
|
+
pgVersion;
|
|
21
|
+
constructor(input) {
|
|
22
|
+
super();
|
|
23
|
+
this.namespaces = Object.freeze({ ...input.namespaces });
|
|
24
|
+
this.roles = Object.freeze([...input.roles]);
|
|
25
|
+
this.existingSchemas = Object.freeze([...input.existingSchemas]);
|
|
26
|
+
this.pgVersion = input.pgVersion;
|
|
27
|
+
freezeNode(this);
|
|
28
|
+
}
|
|
29
|
+
get id() {
|
|
30
|
+
return "database";
|
|
31
|
+
}
|
|
32
|
+
isEqualTo(other) {
|
|
33
|
+
return this.id === other.id;
|
|
34
|
+
}
|
|
35
|
+
children() {
|
|
36
|
+
return Object.values(this.namespaces);
|
|
37
|
+
}
|
|
38
|
+
static is(node) {
|
|
39
|
+
return node.nodeKind === PostgresSchemaNodeKind.database;
|
|
40
|
+
}
|
|
41
|
+
static assert(node) {
|
|
42
|
+
assertNode(node, "PostgresDatabaseSchemaNode", PostgresDatabaseSchemaNode.is);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/core/schema-ir/postgres-namespace-schema-node.ts
|
|
47
|
+
/**
|
|
48
|
+
* One-per-Postgres-schema diff-tree node. Groups the tables belonging to a
|
|
49
|
+
* single namespace. Per-schema consumers (the relational planner,
|
|
50
|
+
* toSchemaView) read this node's `tables` field structurally via
|
|
51
|
+
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
52
|
+
* assignment — because `nodeKind` now carries this node's own literal
|
|
53
|
+
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
54
|
+
*
|
|
55
|
+
* `id` is the schema name. `isEqualTo` is identity — two namespace nodes are
|
|
56
|
+
* equal iff their ids (schema names) match. `children()` returns the table
|
|
57
|
+
* nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`
|
|
58
|
+
* field, not an annotations bag.
|
|
59
|
+
*
|
|
60
|
+
* `nativeEnums` carries the same enum types with their ordered member
|
|
61
|
+
* values (`{ typeName, values }`), for consumers that need the values
|
|
62
|
+
* (PSL inference, the printer). `nativeEnumTypeNames` stays a plain name
|
|
63
|
+
* list read independently by existing consumers (codec `planTypeOperations`
|
|
64
|
+
* hooks, the infer throw) so none of them need the values to keep working.
|
|
65
|
+
*/
|
|
66
|
+
var PostgresNamespaceSchemaNode = class PostgresNamespaceSchemaNode extends SqlSchemaIRNode {
|
|
67
|
+
nodeKind = PostgresSchemaNodeKind.namespace;
|
|
68
|
+
schemaName;
|
|
69
|
+
tables;
|
|
70
|
+
nativeEnumTypeNames;
|
|
71
|
+
nativeEnums;
|
|
72
|
+
constructor(input) {
|
|
73
|
+
super();
|
|
74
|
+
this.schemaName = input.schemaName;
|
|
75
|
+
this.tables = Object.freeze({ ...input.tables });
|
|
76
|
+
this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);
|
|
77
|
+
this.nativeEnums = Object.freeze((input.nativeEnums ?? []).map((entry) => Object.freeze({
|
|
78
|
+
typeName: entry.typeName,
|
|
79
|
+
values: Object.freeze([...entry.values])
|
|
80
|
+
})));
|
|
81
|
+
freezeNode(this);
|
|
82
|
+
}
|
|
83
|
+
get id() {
|
|
84
|
+
return this.schemaName;
|
|
85
|
+
}
|
|
86
|
+
isEqualTo(other) {
|
|
87
|
+
return this.id === other.id;
|
|
88
|
+
}
|
|
89
|
+
children() {
|
|
90
|
+
return Object.values(this.tables);
|
|
91
|
+
}
|
|
92
|
+
static is(node) {
|
|
93
|
+
return node.nodeKind === PostgresSchemaNodeKind.namespace;
|
|
94
|
+
}
|
|
95
|
+
static assert(node) {
|
|
96
|
+
assertNode(node, "PostgresNamespaceSchemaNode", PostgresNamespaceSchemaNode.is);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/core/schema-ir/postgres-policy-schema-node.ts
|
|
101
|
+
/**
|
|
102
|
+
* Schema-diff leaf node for a Postgres row-level security policy.
|
|
103
|
+
*
|
|
104
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
105
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
106
|
+
* `PostgresRlsPolicy` contract entities / introspected rows.
|
|
107
|
+
*
|
|
108
|
+
* `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is
|
|
109
|
+
* body-equality. `isEqualTo` compares names only — never byte-compare predicate
|
|
110
|
+
* bodies, because Postgres reprints them.
|
|
111
|
+
*/
|
|
112
|
+
var PostgresPolicySchemaNode = class PostgresPolicySchemaNode extends SqlSchemaIRNode {
|
|
113
|
+
nodeKind = PostgresSchemaNodeKind.policy;
|
|
114
|
+
name;
|
|
115
|
+
prefix;
|
|
116
|
+
tableName;
|
|
117
|
+
namespaceId;
|
|
118
|
+
operation;
|
|
119
|
+
roles;
|
|
120
|
+
permissive;
|
|
121
|
+
constructor(input) {
|
|
122
|
+
super();
|
|
123
|
+
this.name = input.name;
|
|
124
|
+
this.prefix = input.prefix;
|
|
125
|
+
this.tableName = input.tableName;
|
|
126
|
+
this.namespaceId = input.namespaceId;
|
|
127
|
+
this.operation = input.operation;
|
|
128
|
+
this.roles = Object.freeze([...input.roles]);
|
|
129
|
+
if (input.using !== void 0) this.using = input.using;
|
|
130
|
+
if (input.withCheck !== void 0) this.withCheck = input.withCheck;
|
|
131
|
+
this.permissive = input.permissive;
|
|
132
|
+
freezeNode(this);
|
|
133
|
+
}
|
|
134
|
+
get id() {
|
|
135
|
+
return this.name;
|
|
136
|
+
}
|
|
137
|
+
children() {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
isEqualTo(other) {
|
|
141
|
+
const node = blindCast(other);
|
|
142
|
+
PostgresPolicySchemaNode.assert(node);
|
|
143
|
+
return this.id === node.id;
|
|
144
|
+
}
|
|
145
|
+
static is(node) {
|
|
146
|
+
return node.nodeKind === PostgresSchemaNodeKind.policy;
|
|
147
|
+
}
|
|
148
|
+
static assert(node) {
|
|
149
|
+
assertNode(node, "PostgresPolicySchemaNode", PostgresPolicySchemaNode.is);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/core/schema-ir/postgres-role-schema-node.ts
|
|
154
|
+
/**
|
|
155
|
+
* Schema-diff leaf node for a Postgres database role.
|
|
156
|
+
*
|
|
157
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
158
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
159
|
+
* `PostgresRole` contract entities / introspected rows.
|
|
160
|
+
*
|
|
161
|
+
* Roles are cluster-scoped, so `id` is the role name alone. `isEqualTo` compares
|
|
162
|
+
* names — name-equality is role-equality for cluster-scoped objects.
|
|
163
|
+
*/
|
|
164
|
+
var PostgresRoleSchemaNode = class PostgresRoleSchemaNode extends SqlSchemaIRNode {
|
|
165
|
+
nodeKind = PostgresSchemaNodeKind.role;
|
|
166
|
+
name;
|
|
167
|
+
namespaceId;
|
|
168
|
+
constructor(input) {
|
|
169
|
+
super();
|
|
170
|
+
this.name = input.name;
|
|
171
|
+
this.namespaceId = input.namespaceId;
|
|
172
|
+
freezeNode(this);
|
|
173
|
+
}
|
|
174
|
+
get id() {
|
|
175
|
+
return this.name;
|
|
176
|
+
}
|
|
177
|
+
children() {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
isEqualTo(other) {
|
|
181
|
+
const node = blindCast(other);
|
|
182
|
+
PostgresRoleSchemaNode.assert(node);
|
|
183
|
+
return this.id === node.id;
|
|
184
|
+
}
|
|
185
|
+
static is(node) {
|
|
186
|
+
return node.nodeKind === PostgresSchemaNodeKind.role;
|
|
187
|
+
}
|
|
188
|
+
static assert(node) {
|
|
189
|
+
assertNode(node, "PostgresRoleSchemaNode", PostgresRoleSchemaNode.is);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
//#endregion
|
|
193
|
+
export { PostgresDatabaseSchemaNode as i, PostgresPolicySchemaNode as n, PostgresNamespaceSchemaNode as r, PostgresRoleSchemaNode as t };
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=postgres-role-schema-node-BiSTCTNg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-role-schema-node-BiSTCTNg.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()` returns namespace\n * nodes only; roles are held on the root but not yielded (role diffing is a\n * later slice).\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);\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 { PostgresTableSchemaNode } from './postgres-table-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\n/** One introspected native Postgres enum type, in `pg_enum.enumsortorder` (declaration) order. */\nexport interface PostgresNativeEnumIntrospection {\n readonly typeName: string;\n readonly values: readonly string[];\n}\n\nexport interface PostgresNamespaceSchemaNodeInput {\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n readonly nativeEnumTypeNames: readonly string[];\n readonly nativeEnums?: readonly PostgresNativeEnumIntrospection[];\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` now 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 — two namespace nodes are\n * equal iff their ids (schema names) match. `children()` returns the table\n * nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`\n * field, not an annotations bag.\n *\n * `nativeEnums` carries the same enum types with their ordered member\n * values (`{ typeName, values }`), for consumers that need the values\n * (PSL inference, the printer). `nativeEnumTypeNames` stays a plain name\n * list read independently by existing consumers (codec `planTypeOperations`\n * hooks, the infer throw) so none of them need the values to keep working.\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 nativeEnumTypeNames: readonly string[];\n readonly nativeEnums: readonly PostgresNativeEnumIntrospection[];\n\n constructor(input: PostgresNamespaceSchemaNodeInput) {\n super();\n this.schemaName = input.schemaName;\n this.tables = Object.freeze({ ...input.tables });\n this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);\n this.nativeEnums = Object.freeze(\n (input.nativeEnums ?? []).map((entry) =>\n Object.freeze({ typeName: entry.typeName, values: Object.freeze([...entry.values]) }),\n ),\n );\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);\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 role name alone. `isEqualTo` compares\n * names — 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":";;;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AI,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"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
|
|
2
|
+
import { t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.mjs";
|
|
3
|
+
import { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, SqlNode, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
|
+
import { Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
6
|
+
|
|
7
|
+
//#region src/core/postgres-role.d.ts
|
|
8
|
+
interface PostgresRoleInput {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`
|
|
12
|
+
* from `@prisma-next/framework-components/ir`.
|
|
13
|
+
*/
|
|
14
|
+
readonly namespaceId: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Postgres contract-IR class for a database role (`CREATE ROLE …`).
|
|
18
|
+
*
|
|
19
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
20
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
21
|
+
* the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
|
|
22
|
+
*
|
|
23
|
+
* Roles are cluster-scoped, so their namespace coordinate is always
|
|
24
|
+
* `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
|
|
25
|
+
* Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
|
|
26
|
+
* The `kind: 'role'` discriminant is enumerable so it survives JSON.
|
|
27
|
+
* Matches the entries key (one-string rule).
|
|
28
|
+
*/
|
|
29
|
+
declare class PostgresRole extends SqlNode {
|
|
30
|
+
readonly kind: "role";
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly namespaceId: string;
|
|
33
|
+
constructor(input: PostgresRoleInput);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/core/postgres-rls-enablement.d.ts
|
|
37
|
+
interface PostgresRlsEnablementInput {
|
|
38
|
+
/** Name of the table this marker declares RLS-controlled. */
|
|
39
|
+
readonly tableName: string;
|
|
40
|
+
/** Namespace coordinate (schema name). Markers are schema-scoped like policies. */
|
|
41
|
+
readonly namespaceId: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Postgres contract-IR marker for `@@rls` on a model: the table named here is
|
|
45
|
+
* RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never
|
|
46
|
+
* by the policy set).
|
|
47
|
+
*
|
|
48
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an
|
|
49
|
+
* entity kind, extends `SqlNode`, and is stored in `contract.json` under
|
|
50
|
+
* `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.
|
|
51
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`
|
|
52
|
+
* discriminant is enumerable so it survives JSON serialization; the literal
|
|
53
|
+
* matches the entries key (one-string rule).
|
|
54
|
+
*/
|
|
55
|
+
declare class PostgresRlsEnablement extends SqlNode {
|
|
56
|
+
readonly kind: "rls";
|
|
57
|
+
readonly tableName: string;
|
|
58
|
+
readonly namespaceId: string;
|
|
59
|
+
constructor(input: PostgresRlsEnablementInput);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/core/postgres-native-enum.d.ts
|
|
63
|
+
interface PostgresNativeEnumInput {
|
|
64
|
+
/** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
|
|
65
|
+
readonly typeName: string;
|
|
66
|
+
/** Member values in declaration order — this is the Postgres enum sort order. */
|
|
67
|
+
readonly members: readonly string[];
|
|
68
|
+
readonly control?: ControlPolicy;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).
|
|
72
|
+
*
|
|
73
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
74
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
75
|
+
* the schema-diff tree will use `PostgresNativeEnumSchemaNode` when the managed phase
|
|
76
|
+
* builds it.
|
|
77
|
+
*
|
|
78
|
+
* A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM
|
|
79
|
+
* ('a', 'b')`, which has no separate member name.
|
|
80
|
+
*
|
|
81
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,
|
|
82
|
+
* frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`
|
|
83
|
+
* discriminant is enumerable so it survives JSON. Lives at
|
|
84
|
+
* `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key
|
|
85
|
+
* (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this
|
|
86
|
+
* node's own `kind` literal — the same shape as `table`/`StorageTable` and
|
|
87
|
+
* `valueSet`/`StorageValueSet`.
|
|
88
|
+
*/
|
|
89
|
+
declare class PostgresNativeEnum extends SqlNode {
|
|
90
|
+
static is(node: unknown): node is PostgresNativeEnum;
|
|
91
|
+
readonly kind: "postgres-enum";
|
|
92
|
+
readonly typeName: string;
|
|
93
|
+
readonly members: readonly string[];
|
|
94
|
+
readonly control?: ControlPolicy;
|
|
95
|
+
constructor(input: PostgresNativeEnumInput);
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/core/postgres-schema.d.ts
|
|
99
|
+
type PostgresContract = Contract<SqlStorage> & {
|
|
100
|
+
readonly target: 'postgres';
|
|
101
|
+
};
|
|
102
|
+
type PostgresNamespaceEntries = SqlNamespaceEntries & {
|
|
103
|
+
readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
|
|
104
|
+
readonly role?: Readonly<Record<string, PostgresRole>>;
|
|
105
|
+
readonly rls?: Readonly<Record<string, PostgresRlsEnablement>>;
|
|
106
|
+
readonly native_enum?: Readonly<Record<string, PostgresNativeEnum>>;
|
|
107
|
+
};
|
|
108
|
+
interface PostgresSchemaInput {
|
|
109
|
+
readonly id: string;
|
|
110
|
+
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
114
|
+
* SCHEMA …`). Each Postgres `SqlStorage` carries a
|
|
115
|
+
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
116
|
+
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
117
|
+
*
|
|
118
|
+
* `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
|
|
119
|
+
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
120
|
+
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
121
|
+
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
122
|
+
* The unbound singleton below overrides these methods to elide the
|
|
123
|
+
* prefix entirely — call sites stay polymorphic and never branch on
|
|
124
|
+
* `id === UNBOUND_NAMESPACE_ID`.
|
|
125
|
+
*/
|
|
126
|
+
declare class PostgresSchema extends SqlNamespaceBase {
|
|
127
|
+
/**
|
|
128
|
+
* Stable singleton reference for the late-bound slot. Materialised
|
|
129
|
+
* lazily below the singleton subclass declaration so the static
|
|
130
|
+
* initialiser sees the subclass before assigning. Consumers always
|
|
131
|
+
* reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
|
|
132
|
+
* — same identity).
|
|
133
|
+
*/
|
|
134
|
+
static unbound: PostgresUnboundSchema;
|
|
135
|
+
readonly kind: 'schema';
|
|
136
|
+
readonly id: string;
|
|
137
|
+
readonly entries: PostgresNamespaceEntries;
|
|
138
|
+
constructor(input: PostgresSchemaInput);
|
|
139
|
+
get table(): Readonly<Record<string, StorageTable>>;
|
|
140
|
+
get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
|
|
141
|
+
get policy(): Readonly<Record<string, PostgresRlsPolicy>>;
|
|
142
|
+
get role(): Readonly<Record<string, PostgresRole>>;
|
|
143
|
+
get rls(): Readonly<Record<string, PostgresRlsEnablement>>;
|
|
144
|
+
/**
|
|
145
|
+
* The bare schema qualifier as it would appear in a rendered SQL
|
|
146
|
+
* fragment (already quoted). The unbound-schema singleton overrides
|
|
147
|
+
* this to return `''`.
|
|
148
|
+
*/
|
|
149
|
+
qualifier(): string;
|
|
150
|
+
/**
|
|
151
|
+
* Qualify a table name with the schema prefix
|
|
152
|
+
* (`"<schema>"."<table>"`). The unbound-schema singleton overrides
|
|
153
|
+
* this to emit just `"<table>"` so the resolved DDL is unqualified
|
|
154
|
+
* and `search_path` decides where the object lands at runtime.
|
|
155
|
+
*/
|
|
156
|
+
qualifyTable(tableName: string): string;
|
|
157
|
+
/**
|
|
158
|
+
* Render a SQL string-literal containing the qualified-name form
|
|
159
|
+
* suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
|
|
160
|
+
* The unbound singleton overrides this to elide the schema prefix
|
|
161
|
+
* (`'"user"'`) so `search_path` resolves the object at runtime.
|
|
162
|
+
*/
|
|
163
|
+
regclassLiteral(name: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* Render a SQL expression that evaluates to this namespace's schema
|
|
166
|
+
* name at runtime, ready to drop into a `WHERE table_schema = …` /
|
|
167
|
+
* `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
|
|
168
|
+
* literal (`'public'`); the unbound singleton overrides this to emit
|
|
169
|
+
* `current_schema()` so catalog queries match whichever schema the
|
|
170
|
+
* connection's `search_path` resolved at runtime.
|
|
171
|
+
*/
|
|
172
|
+
schemaSqlExpression(): string;
|
|
173
|
+
/**
|
|
174
|
+
* Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
|
|
175
|
+
* builder-built catalog check compares `n.nspname` / `table_schema`
|
|
176
|
+
* against. Named schemas bind the schema name as a text parameter; the
|
|
177
|
+
* unbound singleton overrides this to the opaque `current_schema()`
|
|
178
|
+
* expression so the live connection's `search_path` decides at runtime.
|
|
179
|
+
*/
|
|
180
|
+
schemaFilterExpression(): CfExpr;
|
|
181
|
+
/**
|
|
182
|
+
* Typed-AST counterpart of {@link qualifyTable}: the FROM source a
|
|
183
|
+
* builder-built check uses to address a user table in this namespace.
|
|
184
|
+
* Named schemas qualify (`"schema"."table"`); the unbound singleton
|
|
185
|
+
* overrides this to leave the table unqualified so `search_path`
|
|
186
|
+
* resolves it at runtime.
|
|
187
|
+
*/
|
|
188
|
+
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
189
|
+
/**
|
|
190
|
+
* The bare schema name a DDL planner should target when emitting
|
|
191
|
+
* statements that need to identify this namespace in the live
|
|
192
|
+
* database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
|
|
193
|
+
* catalog filters, planner conflict lookups). Named schemas resolve
|
|
194
|
+
* to their own id. The `PostgresUnboundSchema` singleton inherits
|
|
195
|
+
* this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
|
|
196
|
+
* through `qualifyTableName` route through the polymorphic
|
|
197
|
+
* `PostgresUnboundSchema` overrides and produce unqualified
|
|
198
|
+
* (search-path-resolved) output automatically.
|
|
199
|
+
*/
|
|
200
|
+
ddlSchemaName(_storage: SqlStorage): string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Singleton subclass for the reserved sentinel namespace id
|
|
204
|
+
* (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
|
|
205
|
+
* the connection's `search_path` resolves at runtime. Overrides
|
|
206
|
+
* qualifier emission to elide the schema prefix; call sites that consume
|
|
207
|
+
* `qualifier()` / `qualifyTable()` get unqualified output without
|
|
208
|
+
* branching on the namespace id.
|
|
209
|
+
*
|
|
210
|
+
* This is the target-side materialization of "the framework provides
|
|
211
|
+
* affordances; targets implement specifics": the framework names the
|
|
212
|
+
* sentinel; Postgres decides what late-bound means here (the table
|
|
213
|
+
* name, naked — the schema is supplied by the live connection's
|
|
214
|
+
* `search_path`).
|
|
215
|
+
*
|
|
216
|
+
* `ddlSchemaName` is inherited from `PostgresSchema` and returns
|
|
217
|
+
* `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
|
|
218
|
+
* route through the polymorphic factory and produce unqualified output
|
|
219
|
+
* automatically.
|
|
220
|
+
*/
|
|
221
|
+
declare class PostgresUnboundSchema extends PostgresSchema {
|
|
222
|
+
static readonly instance: PostgresUnboundSchema;
|
|
223
|
+
constructor(input?: PostgresSchemaInput);
|
|
224
|
+
qualifier(): string;
|
|
225
|
+
qualifyTable(tableName: string): string;
|
|
226
|
+
schemaSqlExpression(): string;
|
|
227
|
+
schemaFilterExpression(): CfExpr;
|
|
228
|
+
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`
|
|
232
|
+
* so callers can dispatch to the polymorphic emission methods without
|
|
233
|
+
* branching at the call site. Uses the structural `kind` discriminator
|
|
234
|
+
* (`'schema'`) rather than `instanceof` so the check survives realm /
|
|
235
|
+
* bundle / hot-reload boundaries — matching the rest of the IR's
|
|
236
|
+
* narrowing convention. `PostgresUnboundSchema` passes through because
|
|
237
|
+
* it inherits the same `kind: 'schema'` from `PostgresSchema`.
|
|
238
|
+
*/
|
|
239
|
+
declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
|
|
240
|
+
/**
|
|
241
|
+
* Target-supplied `Namespace` factory the Postgres target plumbs
|
|
242
|
+
* through `defineContract({ createNamespace })` and the SQL PSL
|
|
243
|
+
* interpreter. Returns the unbound singleton for the framework
|
|
244
|
+
* sentinel and a fresh `PostgresSchema` for any other coordinate.
|
|
245
|
+
*
|
|
246
|
+
* The factory has no per-call state — every named id deterministically
|
|
247
|
+
* maps to a distinct schema instance — so callers can pass it through
|
|
248
|
+
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
249
|
+
* be value-stable for a given input set. Native-enum column type names are
|
|
250
|
+
* schema-qualified earlier, at column construction, via the target's
|
|
251
|
+
* `authoring.qualifyColumnType` hook (`postgresQualifyColumnType`), so this
|
|
252
|
+
* factory just materialises the namespace from already-qualified entries.
|
|
253
|
+
*/
|
|
254
|
+
declare function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema;
|
|
255
|
+
//#endregion
|
|
256
|
+
export { postgresCreateNamespace as a, PostgresRlsEnablement as c, PostgresRoleInput as d, isPostgresSchema as i, PostgresRlsEnablementInput as l, PostgresSchema as n, PostgresNativeEnum as o, PostgresUnboundSchema as r, PostgresNativeEnumInput as s, PostgresContract as t, PostgresRole as u };
|
|
257
|
+
//# sourceMappingURL=postgres-schema-CU4gF6QZ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-CU4gF6QZ.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":";;;;;;;UAGiB,iBAAA;EAAA,SACN,IAAA;;;;;WAKA,WAAW;AAAA;;;AAAA;AAgBtB;;;;;;;;;;cAAa,YAAA,SAAqB,OAAO;EAAA,SACrB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,iBAAA;AAAA;;;UC3BJ,0BAAA;;WAEN,SAAA;;WAEA,WAAW;AAAA;ADJtB;;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