@prisma-next/target-postgres 0.14.0-dev.8 → 0.14.0-dev.81
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-ChmUI_tC.mjs +674 -0
- package/dist/authoring-ChmUI_tC.mjs.map +1 -0
- package/dist/canonicalize-D1F4vUnP.d.mts +48 -0
- package/dist/canonicalize-D1F4vUnP.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-BemGS69L.mjs +927 -0
- package/dist/codecs-BemGS69L.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 +23 -7
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control-policy-BfQLCrha.mjs +1285 -0
- package/dist/control-policy-BfQLCrha.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +866 -36
- 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-eBZav_MS.mjs} +128 -6
- package/dist/ddl-eBZav_MS.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-DAwRBZpA.mjs +23 -0
- package/dist/descriptor-meta-DAwRBZpA.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-jsEOfSYT.mjs +305 -0
- package/dist/diff-database-schema-jsEOfSYT.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-DJC5B8Id.mjs +192 -0
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/nodes-Dv5eCSq9.d.mts +170 -0
- package/dist/nodes-Dv5eCSq9.d.mts.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Bn9zDx4_.d.mts} +114 -15
- package/dist/op-factory-call-Bn9zDx4_.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-Dwsb1xzl.mjs} +469 -32
- package/dist/op-factory-call-Dwsb1xzl.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 +321 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-ChCtpEGe.mjs +390 -0
- package/dist/planner-ChCtpEGe.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-BKlmGDJl.mjs} +17 -28
- package/dist/planner-ddl-builders-BKlmGDJl.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-QqHa2C2l.d.mts → planner-produced-postgres-migration-BEY1T0Xm.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-BEY1T0Xm.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-Bb16yHNX.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-Bb16yHNX.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-jqUUGyQR.mjs → planner-sql-checks-Cx0ATsPc.mjs} +5 -5
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-Cx0ATsPc.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-serializer-k3TAcPMY.mjs → postgres-contract-view-BiDhl5Ez.mjs} +45 -41
- package/dist/postgres-contract-view-BiDhl5Ez.mjs.map +1 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts +262 -0
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-Cj5Tpj1a.mjs} +78 -45
- package/dist/postgres-migration-Cj5Tpj1a.mjs.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DbckK1su.d.mts} +58 -9
- package/dist/postgres-migration-DbckK1su.d.mts.map +1 -0
- package/dist/postgres-native-enum-BwVNf0Ku.mjs +45 -0
- package/dist/postgres-native-enum-BwVNf0Ku.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-Cm-j0ZGM.mjs +190 -0
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-ChBj22nX.mjs} +200 -11
- package/dist/postgres-schema-ChBj22nX.mjs.map +1 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts +269 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts.map +1 -0
- package/dist/postgres-table-schema-node-D6LvInCe.mjs +216 -0
- package/dist/postgres-table-schema-node-D6LvInCe.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-BCSMHFwl.mjs +22 -0
- package/dist/resolve-ddl-schema-BCSMHFwl.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +27 -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/{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 +4 -140
- package/dist/types.mjs +5 -2
- package/dist/wire-name-DbQ9-2RC.mjs +104 -0
- package/dist/wire-name-DbQ9-2RC.mjs.map +1 -0
- package/package.json +26 -20
- package/src/contract-free/checks.ts +153 -0
- package/src/contract-free/control-bootstrap.ts +20 -3
- package/src/contract-free/ddl.ts +98 -1
- package/src/core/authoring.ts +726 -2
- package/src/core/codec-helpers.ts +33 -7
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +2 -0
- package/src/core/codecs.ts +193 -12
- package/src/core/ddl/nodes.ts +185 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +12 -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 +189 -0
- package/src/core/migrations/control-policy.ts +217 -65
- package/src/core/migrations/diff-database-schema.ts +252 -0
- package/src/core/migrations/issue-planner.ts +817 -656
- package/src/core/migrations/op-factory-call.ts +383 -23
- 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/native-enum-types.ts +62 -0
- 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 +31 -59
- 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 +357 -67
- package/src/core/migrations/postgres-migration.ts +118 -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 +11 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +46 -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 +61 -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 +59 -0
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/postgres-schema.ts +85 -15
- package/src/core/postgres-validators.ts +34 -0
- package/src/core/psl-infer/infer-psl-contract.ts +1273 -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 +65 -0
- package/src/core/rls/wire-name.ts +33 -0
- package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +70 -0
- package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
- package/src/core/schema-ir/schema-node-kinds.ts +122 -0
- package/src/core/sql-utils.ts +15 -2
- 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 +8 -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 +4 -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 +12 -0
- package/src/exports/runtime.ts +1 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/types.ts +37 -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,45 @@
|
|
|
1
|
+
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
2
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
3
|
+
import { SqlNode } from "@prisma-next/sql-contract/types";
|
|
4
|
+
//#region src/core/postgres-native-enum.ts
|
|
5
|
+
function freezeMembers(members) {
|
|
6
|
+
return blindCast(Object.freeze([...members]));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).
|
|
10
|
+
*
|
|
11
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
12
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
13
|
+
* the schema-diff tree will use `PostgresNativeEnumSchemaNode` when the managed phase
|
|
14
|
+
* builds it.
|
|
15
|
+
*
|
|
16
|
+
* A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM
|
|
17
|
+
* ('a', 'b')`, which has no separate member name.
|
|
18
|
+
*
|
|
19
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,
|
|
20
|
+
* frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`
|
|
21
|
+
* discriminant is enumerable so it survives JSON. Lives at
|
|
22
|
+
* `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key
|
|
23
|
+
* (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this
|
|
24
|
+
* node's own `kind` literal — the same shape as `table`/`StorageTable` and
|
|
25
|
+
* `valueSet`/`StorageValueSet`.
|
|
26
|
+
*/
|
|
27
|
+
var PostgresNativeEnum = class extends SqlNode {
|
|
28
|
+
static is(node) {
|
|
29
|
+
return typeof node === "object" && node !== null && "kind" in node && node.kind === "postgres-enum";
|
|
30
|
+
}
|
|
31
|
+
kind = "postgres-enum";
|
|
32
|
+
typeName;
|
|
33
|
+
members;
|
|
34
|
+
constructor(input) {
|
|
35
|
+
super();
|
|
36
|
+
this.typeName = input.typeName;
|
|
37
|
+
this.members = freezeMembers(input.members);
|
|
38
|
+
if (input.control !== void 0) this.control = input.control;
|
|
39
|
+
freezeNode(this);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { PostgresNativeEnum as t };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=postgres-native-enum-BwVNf0Ku.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-native-enum-BwVNf0Ku.mjs","names":[],"sources":["../src/core/postgres-native-enum.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\n\nexport interface PostgresNativeEnumInput<Members extends readonly string[] = readonly string[]> {\n /** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */\n readonly typeName: string;\n /** Member values in declaration order — this is the Postgres enum sort order. */\n readonly members: Members;\n readonly control?: ControlPolicy;\n}\n\nfunction freezeMembers<Members extends readonly string[]>(members: Members): Members {\n return blindCast<\n Members,\n 'Object.freeze clones+freezes the tuple for immutability; the clone widens to readonly string[], but it holds exactly the values of members (already typed Members)'\n >(Object.freeze([...members]));\n}\n\n/**\n * Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).\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 will use `PostgresNativeEnumSchemaNode` when the managed phase\n * builds it.\n *\n * A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM\n * ('a', 'b')`, which has no separate member name.\n *\n * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,\n * frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`\n * discriminant is enumerable so it survives JSON. Lives at\n * `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key\n * (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this\n * node's own `kind` literal — the same shape as `table`/`StorageTable` and\n * `valueSet`/`StorageValueSet`.\n */\nexport class PostgresNativeEnum<\n Members extends readonly string[] = readonly string[],\n> extends SqlNode {\n static is(node: unknown): node is PostgresNativeEnum {\n return (\n typeof node === 'object' && node !== null && 'kind' in node && node.kind === 'postgres-enum'\n );\n }\n\n override readonly kind = 'postgres-enum' as const;\n readonly typeName: string;\n readonly members: Members;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresNativeEnumInput<Members>) {\n super();\n this.typeName = input.typeName;\n this.members = freezeMembers(input.members);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n}\n"],"mappings":";;;;AAaA,SAAS,cAAiD,SAA2B;CACnF,OAAO,UAGL,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AAC/B;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,qBAAb,cAEU,QAAQ;CAChB,OAAO,GAAG,MAA2C;EACnD,OACE,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,KAAK,SAAS;CAEjF;CAEA,OAAyB;CACzB;CACA;CAGA,YAAY,OAAyC;EACnD,MAAM;EACN,KAAK,WAAW,MAAM;EACtB,KAAK,UAAU,cAAc,MAAM,OAAO;EAC1C,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SqlNode } from "@prisma-next/sql-contract/types";
|
|
2
|
+
|
|
3
|
+
//#region src/core/postgres-rls-policy.d.ts
|
|
4
|
+
type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
|
|
5
|
+
interface PostgresRlsPolicyInput {
|
|
6
|
+
/** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** User-supplied prefix (the part before the `_<8hex>` suffix). */
|
|
9
|
+
readonly prefix: string;
|
|
10
|
+
/** Name of the table this policy attaches to, by name within the same schema. */
|
|
11
|
+
readonly tableName: string;
|
|
12
|
+
/** Namespace coordinate (schema name). Policies are schema-scoped. */
|
|
13
|
+
readonly namespaceId: string;
|
|
14
|
+
readonly operation: RlsPolicyOperation;
|
|
15
|
+
/** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */
|
|
16
|
+
readonly roles: readonly string[];
|
|
17
|
+
/** USING predicate SQL string, if present. */
|
|
18
|
+
readonly using?: string;
|
|
19
|
+
/** WITH CHECK predicate SQL string, if present. */
|
|
20
|
+
readonly withCheck?: string;
|
|
21
|
+
/** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
|
|
22
|
+
readonly permissive: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).
|
|
26
|
+
*
|
|
27
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
28
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
29
|
+
* the schema-diff tree uses `PostgresPolicySchemaNode` for that role.
|
|
30
|
+
*
|
|
31
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
|
|
32
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
|
|
33
|
+
* discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it
|
|
34
|
+
* survives JSON serialization and enables dispatch. The literal matches the
|
|
35
|
+
* entries key (one-string rule: node.kind === entries key === entity kind).
|
|
36
|
+
*/
|
|
37
|
+
declare class PostgresRlsPolicy extends SqlNode {
|
|
38
|
+
readonly kind: "policy";
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly prefix: string;
|
|
41
|
+
readonly tableName: string;
|
|
42
|
+
readonly namespaceId: string;
|
|
43
|
+
readonly operation: RlsPolicyOperation;
|
|
44
|
+
readonly roles: readonly string[];
|
|
45
|
+
readonly using?: string;
|
|
46
|
+
readonly withCheck?: string;
|
|
47
|
+
readonly permissive: boolean;
|
|
48
|
+
constructor(input: PostgresRlsPolicyInput);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { PostgresRlsPolicyInput as n, RlsPolicyOperation as r, PostgresRlsPolicy as t };
|
|
52
|
+
//# sourceMappingURL=postgres-rls-policy--CSddvMR.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-rls-policy--CSddvMR.d.mts","names":[],"sources":["../src/core/postgres-rls-policy.ts"],"mappings":";;;KAGY,kBAAA;AAAA,UAEK,sBAAA;EAFL;EAAA,SAID,IAAA;;WAEA,MAAA;EANmB;EAAA,SAQnB,SAAA;EAN4B;EAAA,SAQ5B,WAAA;EAAA,SACA,SAAA,EAAW,kBAAkB;EAP7B;EAAA,SASA,KAAA;EALA;EAAA,SAOA,KAAA;EAJA;EAAA,SAMA,SAAA;EAJA;EAAA,SAMA,UAAA;AAAA;;;AAAU;AAgBrB;;;;;;;;;;cAAa,iBAAA,SAA0B,OAAA;EAAA,SACnB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,MAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA,EAAW,kBAAA;EAAA,SACX,KAAA;EAAA,SACQ,KAAA;EAAA,SACA,SAAA;EAAA,SACR,UAAA;cAEG,KAAA,EAAO,sBAAA;AAAA"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { r as PostgresSchemaNodeKind } from "./postgres-table-schema-node-D6LvInCe.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()` yields the namespace
|
|
12
|
+
* nodes followed by the role nodes — both are root-level diff subjects. The
|
|
13
|
+
* differ pairs siblings by `(nodeKind, id)`, so a role and a namespace may
|
|
14
|
+
* share a name without colliding.
|
|
15
|
+
*/
|
|
16
|
+
var PostgresDatabaseSchemaNode = class PostgresDatabaseSchemaNode extends SqlSchemaIRNode {
|
|
17
|
+
nodeKind = PostgresSchemaNodeKind.database;
|
|
18
|
+
namespaces;
|
|
19
|
+
roles;
|
|
20
|
+
existingSchemas;
|
|
21
|
+
pgVersion;
|
|
22
|
+
constructor(input) {
|
|
23
|
+
super();
|
|
24
|
+
this.namespaces = Object.freeze({ ...input.namespaces });
|
|
25
|
+
this.roles = Object.freeze([...input.roles]);
|
|
26
|
+
this.existingSchemas = Object.freeze([...input.existingSchemas]);
|
|
27
|
+
this.pgVersion = input.pgVersion;
|
|
28
|
+
freezeNode(this);
|
|
29
|
+
}
|
|
30
|
+
get id() {
|
|
31
|
+
return "database";
|
|
32
|
+
}
|
|
33
|
+
isEqualTo(other) {
|
|
34
|
+
return this.id === other.id;
|
|
35
|
+
}
|
|
36
|
+
children() {
|
|
37
|
+
return [...Object.values(this.namespaces), ...this.roles];
|
|
38
|
+
}
|
|
39
|
+
static is(node) {
|
|
40
|
+
return node.nodeKind === PostgresSchemaNodeKind.database;
|
|
41
|
+
}
|
|
42
|
+
static assert(node) {
|
|
43
|
+
assertNode(node, "PostgresDatabaseSchemaNode", PostgresDatabaseSchemaNode.is);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/core/schema-ir/postgres-namespace-schema-node.ts
|
|
48
|
+
/**
|
|
49
|
+
* One-per-Postgres-schema diff-tree node. Groups the tables belonging to a
|
|
50
|
+
* single namespace. Per-schema consumers (the relational planner,
|
|
51
|
+
* toSchemaView) read this node's `tables` field structurally via
|
|
52
|
+
* `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`
|
|
53
|
+
* assignment — because `nodeKind` carries this node's own literal
|
|
54
|
+
* (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).
|
|
55
|
+
*
|
|
56
|
+
* `id` is the schema name; `isEqualTo` is identity on it; `children()` returns
|
|
57
|
+
* the table nodes plus `nativeEnums`.
|
|
58
|
+
*
|
|
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.
|
|
63
|
+
*/
|
|
64
|
+
var PostgresNamespaceSchemaNode = class PostgresNamespaceSchemaNode extends SqlSchemaIRNode {
|
|
65
|
+
nodeKind = PostgresSchemaNodeKind.namespace;
|
|
66
|
+
schemaName;
|
|
67
|
+
tables;
|
|
68
|
+
nativeEnums;
|
|
69
|
+
constructor(input) {
|
|
70
|
+
super();
|
|
71
|
+
this.schemaName = input.schemaName;
|
|
72
|
+
this.tables = Object.freeze({ ...input.tables });
|
|
73
|
+
this.nativeEnums = Object.freeze([...input.nativeEnums ?? []]);
|
|
74
|
+
freezeNode(this);
|
|
75
|
+
}
|
|
76
|
+
get id() {
|
|
77
|
+
return this.schemaName;
|
|
78
|
+
}
|
|
79
|
+
isEqualTo(other) {
|
|
80
|
+
return this.id === other.id;
|
|
81
|
+
}
|
|
82
|
+
children() {
|
|
83
|
+
return [...Object.values(this.tables), ...this.nativeEnums];
|
|
84
|
+
}
|
|
85
|
+
static is(node) {
|
|
86
|
+
return node.nodeKind === PostgresSchemaNodeKind.namespace;
|
|
87
|
+
}
|
|
88
|
+
static assert(node) {
|
|
89
|
+
assertNode(node, "PostgresNamespaceSchemaNode", PostgresNamespaceSchemaNode.is);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/core/schema-ir/postgres-policy-schema-node.ts
|
|
94
|
+
/**
|
|
95
|
+
* Schema-diff leaf node for a Postgres row-level security policy.
|
|
96
|
+
*
|
|
97
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
98
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
99
|
+
* `PostgresRlsPolicy` contract entities / introspected rows.
|
|
100
|
+
*
|
|
101
|
+
* `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is
|
|
102
|
+
* body-equality. `isEqualTo` compares names only — never byte-compare predicate
|
|
103
|
+
* bodies, because Postgres reprints them.
|
|
104
|
+
*/
|
|
105
|
+
var PostgresPolicySchemaNode = class PostgresPolicySchemaNode extends SqlSchemaIRNode {
|
|
106
|
+
nodeKind = PostgresSchemaNodeKind.policy;
|
|
107
|
+
name;
|
|
108
|
+
prefix;
|
|
109
|
+
tableName;
|
|
110
|
+
namespaceId;
|
|
111
|
+
operation;
|
|
112
|
+
roles;
|
|
113
|
+
permissive;
|
|
114
|
+
constructor(input) {
|
|
115
|
+
super();
|
|
116
|
+
this.name = input.name;
|
|
117
|
+
this.prefix = input.prefix;
|
|
118
|
+
this.tableName = input.tableName;
|
|
119
|
+
this.namespaceId = input.namespaceId;
|
|
120
|
+
this.operation = input.operation;
|
|
121
|
+
this.roles = Object.freeze([...input.roles]);
|
|
122
|
+
if (input.using !== void 0) this.using = input.using;
|
|
123
|
+
if (input.withCheck !== void 0) this.withCheck = input.withCheck;
|
|
124
|
+
this.permissive = input.permissive;
|
|
125
|
+
freezeNode(this);
|
|
126
|
+
}
|
|
127
|
+
get id() {
|
|
128
|
+
return this.name;
|
|
129
|
+
}
|
|
130
|
+
children() {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
isEqualTo(other) {
|
|
134
|
+
const node = blindCast(other);
|
|
135
|
+
PostgresPolicySchemaNode.assert(node);
|
|
136
|
+
return this.id === node.id;
|
|
137
|
+
}
|
|
138
|
+
static is(node) {
|
|
139
|
+
return node.nodeKind === PostgresSchemaNodeKind.policy;
|
|
140
|
+
}
|
|
141
|
+
static assert(node) {
|
|
142
|
+
assertNode(node, "PostgresPolicySchemaNode", PostgresPolicySchemaNode.is);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/core/schema-ir/postgres-role-schema-node.ts
|
|
147
|
+
/**
|
|
148
|
+
* Schema-diff leaf node for a Postgres database role.
|
|
149
|
+
*
|
|
150
|
+
* This is a derived, transient node walked by the differ — it is NEVER serialized.
|
|
151
|
+
* Built by project-from-contract and project-from-database from their respective
|
|
152
|
+
* `PostgresRole` contract entities / introspected rows.
|
|
153
|
+
*
|
|
154
|
+
* Roles are cluster-scoped, so `id` is the bare role name. The differ pairs
|
|
155
|
+
* siblings by `(nodeKind, id)`, so a role and a namespace may share a name
|
|
156
|
+
* (role `public`, schema `public`) without colliding. `isEqualTo` compares
|
|
157
|
+
* ids — name-equality is role-equality for cluster-scoped objects.
|
|
158
|
+
*/
|
|
159
|
+
var PostgresRoleSchemaNode = class PostgresRoleSchemaNode extends SqlSchemaIRNode {
|
|
160
|
+
nodeKind = PostgresSchemaNodeKind.role;
|
|
161
|
+
name;
|
|
162
|
+
namespaceId;
|
|
163
|
+
constructor(input) {
|
|
164
|
+
super();
|
|
165
|
+
this.name = input.name;
|
|
166
|
+
this.namespaceId = input.namespaceId;
|
|
167
|
+
freezeNode(this);
|
|
168
|
+
}
|
|
169
|
+
get id() {
|
|
170
|
+
return this.name;
|
|
171
|
+
}
|
|
172
|
+
children() {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
isEqualTo(other) {
|
|
176
|
+
const node = blindCast(other);
|
|
177
|
+
PostgresRoleSchemaNode.assert(node);
|
|
178
|
+
return this.id === node.id;
|
|
179
|
+
}
|
|
180
|
+
static is(node) {
|
|
181
|
+
return node.nodeKind === PostgresSchemaNodeKind.role;
|
|
182
|
+
}
|
|
183
|
+
static assert(node) {
|
|
184
|
+
assertNode(node, "PostgresRoleSchemaNode", PostgresRoleSchemaNode.is);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
export { PostgresDatabaseSchemaNode as i, PostgresPolicySchemaNode as n, PostgresNamespaceSchemaNode as r, PostgresRoleSchemaNode as t };
|
|
189
|
+
|
|
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,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAAmE;EAC/E,WAAW,MAAM,8BAA8B,2BAA2B,EAAE;CAC9E;AACF;;;;;;;;;;;;;;;;;;;ACzBA,IAAa,8BAAb,MAAa,oCAAoC,gBAAwC;CACvF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CAEA,YAAY,OAAyC;EACnD,MAAM;EACN,KAAK,aAAa,MAAM;EACxB,KAAK,SAAS,OAAO,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC;EAC/C,KAAK,cAAc,OAAO,OAAO,CAAC,GAAI,MAAM,eAAe,CAAC,CAAE,CAAC;EAC/D,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO,CAAC,GAAG,OAAO,OAAO,KAAK,MAAM,GAAG,GAAG,KAAK,WAAW;CAC5D;CAEA,OAAO,GAAG,MAA4D;EACpE,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAAoE;EAChF,WAAW,MAAM,+BAA+B,4BAA4B,EAAE;CAChF;AACF;;;;;;;;;;;;;;AC/BA,IAAa,2BAAb,MAAa,iCAAiC,gBAAwC;CACpF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CACA;CACA;CACA;CAGA;CAEA,YAAY,OAAsC;EAChD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,SAAS,MAAM;EACpB,KAAK,YAAY,MAAM;EACvB,KAAK,cAAc,MAAM;EACzB,KAAK,YAAY,MAAM;EACvB,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;EAC3C,IAAI,MAAM,UAAU,KAAA,GAAW,KAAK,QAAQ,MAAM;EAClD,IAAI,MAAM,cAAc,KAAA,GAAW,KAAK,YAAY,MAAM;EAC1D,KAAK,aAAa,MAAM;EACxB,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,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,11 +1,151 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { v as PG_TEXT_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
|
|
2
|
+
import { t as PostgresNativeEnum } from "./postgres-native-enum-BwVNf0Ku.mjs";
|
|
3
|
+
import { n as escapeLiteral } from "./sql-utils-SU4FDvIV.mjs";
|
|
3
4
|
import { TableSource } from "@prisma-next/sql-relational-core/ast";
|
|
5
|
+
import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
|
|
4
6
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
7
|
+
import { type } from "arktype";
|
|
8
|
+
import { SqlNamespaceBase, SqlNode } from "@prisma-next/sql-contract/types";
|
|
5
9
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
|
-
import {
|
|
10
|
+
import { invariant } from "@prisma-next/utils/assertions";
|
|
7
11
|
import { composeSqlEntityKinds } from "@prisma-next/sql-contract/entity-kinds";
|
|
8
12
|
import { cfExpr } from "@prisma-next/sql-relational-core/contract-free";
|
|
13
|
+
//#region src/core/postgres-rls-enablement.ts
|
|
14
|
+
/**
|
|
15
|
+
* Postgres contract-IR marker for `@@rls` on a model: the table named here is
|
|
16
|
+
* RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never
|
|
17
|
+
* by the policy set).
|
|
18
|
+
*
|
|
19
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an
|
|
20
|
+
* entity kind, extends `SqlNode`, and is stored in `contract.json` under
|
|
21
|
+
* `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.
|
|
22
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`
|
|
23
|
+
* discriminant is enumerable so it survives JSON serialization; the literal
|
|
24
|
+
* matches the entries key (one-string rule).
|
|
25
|
+
*/
|
|
26
|
+
var PostgresRlsEnablement = class extends SqlNode {
|
|
27
|
+
kind = "rls";
|
|
28
|
+
tableName;
|
|
29
|
+
namespaceId;
|
|
30
|
+
constructor(input) {
|
|
31
|
+
super();
|
|
32
|
+
this.tableName = input.tableName;
|
|
33
|
+
this.namespaceId = input.namespaceId;
|
|
34
|
+
freezeNode(this);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/core/postgres-rls-policy.ts
|
|
39
|
+
/**
|
|
40
|
+
* Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).
|
|
41
|
+
*
|
|
42
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
43
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
44
|
+
* the schema-diff tree uses `PostgresPolicySchemaNode` for that role.
|
|
45
|
+
*
|
|
46
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
|
|
47
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
|
|
48
|
+
* discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it
|
|
49
|
+
* survives JSON serialization and enables dispatch. The literal matches the
|
|
50
|
+
* entries key (one-string rule: node.kind === entries key === entity kind).
|
|
51
|
+
*/
|
|
52
|
+
var PostgresRlsPolicy = class extends SqlNode {
|
|
53
|
+
kind = "policy";
|
|
54
|
+
name;
|
|
55
|
+
prefix;
|
|
56
|
+
tableName;
|
|
57
|
+
namespaceId;
|
|
58
|
+
operation;
|
|
59
|
+
roles;
|
|
60
|
+
permissive;
|
|
61
|
+
constructor(input) {
|
|
62
|
+
super();
|
|
63
|
+
this.name = input.name;
|
|
64
|
+
this.prefix = input.prefix;
|
|
65
|
+
this.tableName = input.tableName;
|
|
66
|
+
this.namespaceId = input.namespaceId;
|
|
67
|
+
this.operation = input.operation;
|
|
68
|
+
this.roles = Object.freeze([...input.roles]);
|
|
69
|
+
if (input.using !== void 0) this.using = input.using;
|
|
70
|
+
if (input.withCheck !== void 0) this.withCheck = input.withCheck;
|
|
71
|
+
this.permissive = input.permissive;
|
|
72
|
+
freezeNode(this);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/core/postgres-role.ts
|
|
77
|
+
/**
|
|
78
|
+
* Roles are referenced by the contract but never owned — the framework
|
|
79
|
+
* issues no `CREATE`/`DROP ROLE`, so a role's effective governance is always
|
|
80
|
+
* `external`: a missing declared role fails verify, an extra live role is
|
|
81
|
+
* tolerated, and the planner emits zero role DDL. `external` is the only
|
|
82
|
+
* value a role's control can ever carry.
|
|
83
|
+
*/
|
|
84
|
+
const ROLE_DEFAULT_CONTROL_POLICY = "external";
|
|
85
|
+
/**
|
|
86
|
+
* Postgres contract-IR class for a database role (`CREATE ROLE …`).
|
|
87
|
+
*
|
|
88
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
89
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
90
|
+
* the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
|
|
91
|
+
*
|
|
92
|
+
* Roles are cluster-scoped, so their namespace coordinate is always
|
|
93
|
+
* `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
|
|
94
|
+
* Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
|
|
95
|
+
* The `kind: 'role'` discriminant is enumerable so it survives JSON.
|
|
96
|
+
* Matches the entries key (one-string rule).
|
|
97
|
+
*
|
|
98
|
+
* `control` always carries a value (never omitted): it defaults to
|
|
99
|
+
* {@link ROLE_DEFAULT_CONTROL_POLICY} in the constructor, so both a
|
|
100
|
+
* freshly-authored role and one hydrated from an older `contract.json`
|
|
101
|
+
* lacking the field resolve the same way — the control-policy resolver
|
|
102
|
+
* reads it directly off the entity instead of special-casing role issues.
|
|
103
|
+
*/
|
|
104
|
+
var PostgresRole = class extends SqlNode {
|
|
105
|
+
kind = "role";
|
|
106
|
+
name;
|
|
107
|
+
namespaceId;
|
|
108
|
+
control;
|
|
109
|
+
constructor(input) {
|
|
110
|
+
super();
|
|
111
|
+
this.name = input.name;
|
|
112
|
+
this.namespaceId = input.namespaceId;
|
|
113
|
+
this.control = input.control ?? "external";
|
|
114
|
+
freezeNode(this);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/core/postgres-validators.ts
|
|
119
|
+
const PostgresRoleSchema = type({
|
|
120
|
+
kind: "'role'",
|
|
121
|
+
name: "string",
|
|
122
|
+
namespaceId: "string",
|
|
123
|
+
"control?": "'external'"
|
|
124
|
+
});
|
|
125
|
+
const PostgresRlsPolicySchema = type({
|
|
126
|
+
kind: "'policy'",
|
|
127
|
+
name: "string",
|
|
128
|
+
prefix: "string",
|
|
129
|
+
tableName: "string",
|
|
130
|
+
namespaceId: "string",
|
|
131
|
+
operation: "'select' | 'insert' | 'update' | 'delete' | 'all'",
|
|
132
|
+
roles: type.string.array().readonly(),
|
|
133
|
+
"using?": "string",
|
|
134
|
+
"withCheck?": "string",
|
|
135
|
+
permissive: "boolean"
|
|
136
|
+
});
|
|
137
|
+
const PostgresRlsEnablementSchema = type({
|
|
138
|
+
kind: "'rls'",
|
|
139
|
+
tableName: "string",
|
|
140
|
+
namespaceId: "string"
|
|
141
|
+
});
|
|
142
|
+
const PostgresNativeEnumSchema = type({
|
|
143
|
+
kind: "'postgres-enum'",
|
|
144
|
+
typeName: "string",
|
|
145
|
+
members: type.string.array().readonly(),
|
|
146
|
+
"control?": "'managed' | 'tolerated' | 'external' | 'observed'"
|
|
147
|
+
});
|
|
148
|
+
//#endregion
|
|
9
149
|
//#region src/core/ast/table-source.ts
|
|
10
150
|
var PostgresTableSource = class extends TableSource {
|
|
11
151
|
schema;
|
|
@@ -19,6 +159,28 @@ var PostgresTableSource = class extends TableSource {
|
|
|
19
159
|
}
|
|
20
160
|
};
|
|
21
161
|
//#endregion
|
|
162
|
+
//#region src/core/entity-kinds.ts
|
|
163
|
+
const policyEntityKind = {
|
|
164
|
+
kind: "policy",
|
|
165
|
+
schema: PostgresRlsPolicySchema,
|
|
166
|
+
construct: (input) => new PostgresRlsPolicy(input)
|
|
167
|
+
};
|
|
168
|
+
const roleEntityKind = {
|
|
169
|
+
kind: "role",
|
|
170
|
+
schema: PostgresRoleSchema,
|
|
171
|
+
construct: (input) => new PostgresRole(input)
|
|
172
|
+
};
|
|
173
|
+
const rlsEnablementEntityKind = {
|
|
174
|
+
kind: "rls",
|
|
175
|
+
schema: PostgresRlsEnablementSchema,
|
|
176
|
+
construct: (input) => new PostgresRlsEnablement(input)
|
|
177
|
+
};
|
|
178
|
+
const nativeEnumEntityKind = {
|
|
179
|
+
kind: "native_enum",
|
|
180
|
+
schema: PostgresNativeEnumSchema,
|
|
181
|
+
construct: (input) => new PostgresNativeEnum(input)
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
22
184
|
//#region src/core/postgres-schema.ts
|
|
23
185
|
/**
|
|
24
186
|
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
@@ -34,7 +196,7 @@ var PostgresTableSource = class extends TableSource {
|
|
|
34
196
|
* prefix entirely — call sites stay polymorphic and never branch on
|
|
35
197
|
* `id === UNBOUND_NAMESPACE_ID`.
|
|
36
198
|
*/
|
|
37
|
-
var PostgresSchema = class extends
|
|
199
|
+
var PostgresSchema = class extends SqlNamespaceBase {
|
|
38
200
|
/**
|
|
39
201
|
* Stable singleton reference for the late-bound slot. Materialised
|
|
40
202
|
* lazily below the singleton subclass declaration so the static
|
|
@@ -48,13 +210,28 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
48
210
|
constructor(input) {
|
|
49
211
|
super();
|
|
50
212
|
this.id = input.id;
|
|
51
|
-
const dispatched = hydrateNamespaceEntities(input.entries, composeSqlEntityKinds(
|
|
213
|
+
const dispatched = hydrateNamespaceEntities(input.entries, composeSqlEntityKinds([
|
|
214
|
+
policyEntityKind,
|
|
215
|
+
roleEntityKind,
|
|
216
|
+
rlsEnablementEntityKind,
|
|
217
|
+
nativeEnumEntityKind
|
|
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
|
+
}
|
|
52
229
|
const valueSetRaw = dispatched["valueSet"];
|
|
53
|
-
const
|
|
230
|
+
const entriesInput = { ...valueSetRaw !== void 0 && Object.keys(valueSetRaw).length === 0 ? {
|
|
54
231
|
...dispatched,
|
|
55
232
|
valueSet: void 0
|
|
56
|
-
} : dispatched;
|
|
57
|
-
this.entries = Object.freeze(blindCast(
|
|
233
|
+
} : dispatched };
|
|
234
|
+
this.entries = Object.freeze(blindCast(entriesInput));
|
|
58
235
|
Object.defineProperty(this, "kind", {
|
|
59
236
|
value: "schema",
|
|
60
237
|
writable: false,
|
|
@@ -69,6 +246,15 @@ var PostgresSchema = class extends NamespaceBase {
|
|
|
69
246
|
get valueSet() {
|
|
70
247
|
return this.entries.valueSet;
|
|
71
248
|
}
|
|
249
|
+
get policy() {
|
|
250
|
+
return this.entries.policy ?? Object.freeze({});
|
|
251
|
+
}
|
|
252
|
+
get role() {
|
|
253
|
+
return this.entries.role ?? Object.freeze({});
|
|
254
|
+
}
|
|
255
|
+
get rls() {
|
|
256
|
+
return this.entries.rls ?? Object.freeze({});
|
|
257
|
+
}
|
|
72
258
|
/**
|
|
73
259
|
* The bare schema qualifier as it would appear in a rendered SQL
|
|
74
260
|
* fragment (already quoted). The unbound-schema singleton overrides
|
|
@@ -216,7 +402,10 @@ function isPostgresSchema(ns) {
|
|
|
216
402
|
* The factory has no per-call state — every named id deterministically
|
|
217
403
|
* maps to a distinct schema instance — so callers can pass it through
|
|
218
404
|
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
219
|
-
* be value-stable for a given input set.
|
|
405
|
+
* be value-stable for a given input set. Native-enum column type names are
|
|
406
|
+
* schema-qualified earlier, at column construction, via the target's
|
|
407
|
+
* `authoring.qualifyColumnType` hook (`postgresQualifyColumnType`), so this
|
|
408
|
+
* factory just materialises the namespace from already-qualified entries.
|
|
220
409
|
*/
|
|
221
410
|
function postgresCreateNamespace(input) {
|
|
222
411
|
const schemaInput = {
|
|
@@ -230,6 +419,6 @@ function postgresCreateNamespace(input) {
|
|
|
230
419
|
return new PostgresSchema(schemaInput);
|
|
231
420
|
}
|
|
232
421
|
//#endregion
|
|
233
|
-
export {
|
|
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 };
|
|
234
423
|
|
|
235
|
-
//# sourceMappingURL=postgres-schema-
|
|
424
|
+
//# sourceMappingURL=postgres-schema-ChBj22nX.mjs.map
|