@prisma-next/target-postgres 0.14.0-dev.8 → 0.14.0-dev.80
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-Bi9aa8zG.mjs +574 -0
- package/dist/authoring-Bi9aa8zG.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-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-5LE2kwfb.mjs +1285 -0
- package/dist/control-policy-5LE2kwfb.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-BQzITB_e.mjs} +128 -6
- package/dist/ddl-BQzITB_e.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-DzL6vXAz.mjs +22 -0
- package/dist/descriptor-meta-DzL6vXAz.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-DULhiCNM.mjs +305 -0
- package/dist/diff-database-schema-DULhiCNM.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-Bc2N3tMy.d.mts +170 -0
- package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
- package/dist/nodes-DJC5B8Id.mjs +192 -0
- package/dist/nodes-DJC5B8Id.mjs.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-D6yu-PlS.mjs} +469 -32
- package/dist/op-factory-call-D6yu-PlS.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 +300 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-DwDxdYxi.mjs +390 -0
- package/dist/planner-DwDxdYxi.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-BGPpq56_.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-BGPpq56_.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-CDXn2uaS.mjs} +5 -5
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CDXn2uaS.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-C3LPCLP_.mjs} +45 -41
- package/dist/postgres-contract-view-C3LPCLP_.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-Y4YBJqkS.d.mts → postgres-migration-DbckK1su.d.mts} +58 -9
- package/dist/postgres-migration-DbckK1su.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-et1td40f.mjs} +78 -45
- package/dist/postgres-migration-et1td40f.mjs.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-DKq6s1P3.d.mts +269 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DYATroNx.mjs} +200 -11
- package/dist/postgres-schema-DYATroNx.mjs.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-DpGte50u.mjs +22 -0
- package/dist/resolve-ddl-schema-DpGte50u.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/{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-rHHtr1h0.mjs +75 -0
- package/dist/wire-name-rHHtr1h0.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 +509 -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 +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 +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 +48 -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 +7 -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,gBA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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,269 @@
|
|
|
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-native-enum.d.ts
|
|
8
|
+
interface PostgresNativeEnumInput<Members extends readonly string[] = readonly string[]> {
|
|
9
|
+
/** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
|
|
10
|
+
readonly typeName: string;
|
|
11
|
+
/** Member values in declaration order — this is the Postgres enum sort order. */
|
|
12
|
+
readonly members: Members;
|
|
13
|
+
readonly control?: ControlPolicy;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).
|
|
17
|
+
*
|
|
18
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
19
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
20
|
+
* the schema-diff tree will use `PostgresNativeEnumSchemaNode` when the managed phase
|
|
21
|
+
* builds it.
|
|
22
|
+
*
|
|
23
|
+
* A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM
|
|
24
|
+
* ('a', 'b')`, which has no separate member name.
|
|
25
|
+
*
|
|
26
|
+
* Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,
|
|
27
|
+
* frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`
|
|
28
|
+
* discriminant is enumerable so it survives JSON. Lives at
|
|
29
|
+
* `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key
|
|
30
|
+
* (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this
|
|
31
|
+
* node's own `kind` literal — the same shape as `table`/`StorageTable` and
|
|
32
|
+
* `valueSet`/`StorageValueSet`.
|
|
33
|
+
*/
|
|
34
|
+
declare class PostgresNativeEnum<Members extends readonly string[] = readonly string[]> extends SqlNode {
|
|
35
|
+
static is(node: unknown): node is PostgresNativeEnum;
|
|
36
|
+
readonly kind: "postgres-enum";
|
|
37
|
+
readonly typeName: string;
|
|
38
|
+
readonly members: Members;
|
|
39
|
+
readonly control?: ControlPolicy;
|
|
40
|
+
constructor(input: PostgresNativeEnumInput<Members>);
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/core/postgres-rls-enablement.d.ts
|
|
44
|
+
interface PostgresRlsEnablementInput {
|
|
45
|
+
/** Name of the table this marker declares RLS-controlled. */
|
|
46
|
+
readonly tableName: string;
|
|
47
|
+
/** Namespace coordinate (schema name). Markers are schema-scoped like policies. */
|
|
48
|
+
readonly namespaceId: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Postgres contract-IR marker for `@@rls` on a model: the table named here is
|
|
52
|
+
* RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never
|
|
53
|
+
* by the policy set).
|
|
54
|
+
*
|
|
55
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an
|
|
56
|
+
* entity kind, extends `SqlNode`, and is stored in `contract.json` under
|
|
57
|
+
* `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.
|
|
58
|
+
* Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`
|
|
59
|
+
* discriminant is enumerable so it survives JSON serialization; the literal
|
|
60
|
+
* matches the entries key (one-string rule).
|
|
61
|
+
*/
|
|
62
|
+
declare class PostgresRlsEnablement extends SqlNode {
|
|
63
|
+
readonly kind: "rls";
|
|
64
|
+
readonly tableName: string;
|
|
65
|
+
readonly namespaceId: string;
|
|
66
|
+
constructor(input: PostgresRlsEnablementInput);
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/core/postgres-role.d.ts
|
|
70
|
+
interface PostgresRoleInput {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
/**
|
|
73
|
+
* Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`
|
|
74
|
+
* from `@prisma-next/framework-components/ir`.
|
|
75
|
+
*/
|
|
76
|
+
readonly namespaceId: string;
|
|
77
|
+
/**
|
|
78
|
+
* Defaults to {@link ROLE_DEFAULT_CONTROL_POLICY} when omitted. Roles are
|
|
79
|
+
* referenced but never owned, so `'external'` is the only allowed value.
|
|
80
|
+
*/
|
|
81
|
+
readonly control?: 'external';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Postgres contract-IR class for a database role (`CREATE ROLE …`).
|
|
85
|
+
*
|
|
86
|
+
* This is an authored, serialized Contract-IR entity — it is registered as an entity
|
|
87
|
+
* kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
|
|
88
|
+
* the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
|
|
89
|
+
*
|
|
90
|
+
* Roles are cluster-scoped, so their namespace coordinate is always
|
|
91
|
+
* `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
|
|
92
|
+
* Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
|
|
93
|
+
* The `kind: 'role'` discriminant is enumerable so it survives JSON.
|
|
94
|
+
* Matches the entries key (one-string rule).
|
|
95
|
+
*
|
|
96
|
+
* `control` always carries a value (never omitted): it defaults to
|
|
97
|
+
* {@link ROLE_DEFAULT_CONTROL_POLICY} in the constructor, so both a
|
|
98
|
+
* freshly-authored role and one hydrated from an older `contract.json`
|
|
99
|
+
* lacking the field resolve the same way — the control-policy resolver
|
|
100
|
+
* reads it directly off the entity instead of special-casing role issues.
|
|
101
|
+
*/
|
|
102
|
+
declare class PostgresRole extends SqlNode {
|
|
103
|
+
readonly kind: "role";
|
|
104
|
+
readonly name: string;
|
|
105
|
+
readonly namespaceId: string;
|
|
106
|
+
readonly control: 'external';
|
|
107
|
+
constructor(input: PostgresRoleInput);
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/core/postgres-schema.d.ts
|
|
111
|
+
type PostgresContract = Contract<SqlStorage> & {
|
|
112
|
+
readonly target: 'postgres';
|
|
113
|
+
};
|
|
114
|
+
type PostgresNamespaceEntries = SqlNamespaceEntries & {
|
|
115
|
+
readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
|
|
116
|
+
readonly role?: Readonly<Record<string, PostgresRole>>;
|
|
117
|
+
readonly rls?: Readonly<Record<string, PostgresRlsEnablement>>;
|
|
118
|
+
readonly native_enum?: Readonly<Record<string, PostgresNativeEnum>>;
|
|
119
|
+
};
|
|
120
|
+
interface PostgresSchemaInput {
|
|
121
|
+
readonly id: string;
|
|
122
|
+
readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Postgres target `Namespace` concretion — a Postgres schema (`CREATE
|
|
126
|
+
* SCHEMA …`). Each Postgres `SqlStorage` carries a
|
|
127
|
+
* `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
|
|
128
|
+
* the Postgres PSL interpreter from `namespace { … }` AST buckets.
|
|
129
|
+
*
|
|
130
|
+
* `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
|
|
131
|
+
* emission is the rendering seam: DDL / SQL emission asks the namespace
|
|
132
|
+
* for its qualifier (`"<schema>"`) or for a qualified table name
|
|
133
|
+
* (`"<schema>"."<table>"`) and consumes the result polymorphically.
|
|
134
|
+
* The unbound singleton below overrides these methods to elide the
|
|
135
|
+
* prefix entirely — call sites stay polymorphic and never branch on
|
|
136
|
+
* `id === UNBOUND_NAMESPACE_ID`.
|
|
137
|
+
*/
|
|
138
|
+
declare class PostgresSchema extends SqlNamespaceBase {
|
|
139
|
+
/**
|
|
140
|
+
* Stable singleton reference for the late-bound slot. Materialised
|
|
141
|
+
* lazily below the singleton subclass declaration so the static
|
|
142
|
+
* initialiser sees the subclass before assigning. Consumers always
|
|
143
|
+
* reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
|
|
144
|
+
* — same identity).
|
|
145
|
+
*/
|
|
146
|
+
static unbound: PostgresUnboundSchema;
|
|
147
|
+
readonly kind: 'schema';
|
|
148
|
+
readonly id: string;
|
|
149
|
+
readonly entries: PostgresNamespaceEntries;
|
|
150
|
+
constructor(input: PostgresSchemaInput);
|
|
151
|
+
get table(): Readonly<Record<string, StorageTable>>;
|
|
152
|
+
get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
|
|
153
|
+
get policy(): Readonly<Record<string, PostgresRlsPolicy>>;
|
|
154
|
+
get role(): Readonly<Record<string, PostgresRole>>;
|
|
155
|
+
get rls(): Readonly<Record<string, PostgresRlsEnablement>>;
|
|
156
|
+
/**
|
|
157
|
+
* The bare schema qualifier as it would appear in a rendered SQL
|
|
158
|
+
* fragment (already quoted). The unbound-schema singleton overrides
|
|
159
|
+
* this to return `''`.
|
|
160
|
+
*/
|
|
161
|
+
qualifier(): string;
|
|
162
|
+
/**
|
|
163
|
+
* Qualify a table name with the schema prefix
|
|
164
|
+
* (`"<schema>"."<table>"`). The unbound-schema singleton overrides
|
|
165
|
+
* this to emit just `"<table>"` so the resolved DDL is unqualified
|
|
166
|
+
* and `search_path` decides where the object lands at runtime.
|
|
167
|
+
*/
|
|
168
|
+
qualifyTable(tableName: string): string;
|
|
169
|
+
/**
|
|
170
|
+
* Render a SQL string-literal containing the qualified-name form
|
|
171
|
+
* suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
|
|
172
|
+
* The unbound singleton overrides this to elide the schema prefix
|
|
173
|
+
* (`'"user"'`) so `search_path` resolves the object at runtime.
|
|
174
|
+
*/
|
|
175
|
+
regclassLiteral(name: string): string;
|
|
176
|
+
/**
|
|
177
|
+
* Render a SQL expression that evaluates to this namespace's schema
|
|
178
|
+
* name at runtime, ready to drop into a `WHERE table_schema = …` /
|
|
179
|
+
* `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
|
|
180
|
+
* literal (`'public'`); the unbound singleton overrides this to emit
|
|
181
|
+
* `current_schema()` so catalog queries match whichever schema the
|
|
182
|
+
* connection's `search_path` resolved at runtime.
|
|
183
|
+
*/
|
|
184
|
+
schemaSqlExpression(): string;
|
|
185
|
+
/**
|
|
186
|
+
* Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
|
|
187
|
+
* builder-built catalog check compares `n.nspname` / `table_schema`
|
|
188
|
+
* against. Named schemas bind the schema name as a text parameter; the
|
|
189
|
+
* unbound singleton overrides this to the opaque `current_schema()`
|
|
190
|
+
* expression so the live connection's `search_path` decides at runtime.
|
|
191
|
+
*/
|
|
192
|
+
schemaFilterExpression(): CfExpr;
|
|
193
|
+
/**
|
|
194
|
+
* Typed-AST counterpart of {@link qualifyTable}: the FROM source a
|
|
195
|
+
* builder-built check uses to address a user table in this namespace.
|
|
196
|
+
* Named schemas qualify (`"schema"."table"`); the unbound singleton
|
|
197
|
+
* overrides this to leave the table unqualified so `search_path`
|
|
198
|
+
* resolves it at runtime.
|
|
199
|
+
*/
|
|
200
|
+
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
201
|
+
/**
|
|
202
|
+
* The bare schema name a DDL planner should target when emitting
|
|
203
|
+
* statements that need to identify this namespace in the live
|
|
204
|
+
* database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
|
|
205
|
+
* catalog filters, planner conflict lookups). Named schemas resolve
|
|
206
|
+
* to their own id. The `PostgresUnboundSchema` singleton inherits
|
|
207
|
+
* this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
|
|
208
|
+
* through `qualifyTableName` route through the polymorphic
|
|
209
|
+
* `PostgresUnboundSchema` overrides and produce unqualified
|
|
210
|
+
* (search-path-resolved) output automatically.
|
|
211
|
+
*/
|
|
212
|
+
ddlSchemaName(_storage: SqlStorage): string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Singleton subclass for the reserved sentinel namespace id
|
|
216
|
+
* (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
|
|
217
|
+
* the connection's `search_path` resolves at runtime. Overrides
|
|
218
|
+
* qualifier emission to elide the schema prefix; call sites that consume
|
|
219
|
+
* `qualifier()` / `qualifyTable()` get unqualified output without
|
|
220
|
+
* branching on the namespace id.
|
|
221
|
+
*
|
|
222
|
+
* This is the target-side materialization of "the framework provides
|
|
223
|
+
* affordances; targets implement specifics": the framework names the
|
|
224
|
+
* sentinel; Postgres decides what late-bound means here (the table
|
|
225
|
+
* name, naked — the schema is supplied by the live connection's
|
|
226
|
+
* `search_path`).
|
|
227
|
+
*
|
|
228
|
+
* `ddlSchemaName` is inherited from `PostgresSchema` and returns
|
|
229
|
+
* `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
|
|
230
|
+
* route through the polymorphic factory and produce unqualified output
|
|
231
|
+
* automatically.
|
|
232
|
+
*/
|
|
233
|
+
declare class PostgresUnboundSchema extends PostgresSchema {
|
|
234
|
+
static readonly instance: PostgresUnboundSchema;
|
|
235
|
+
constructor(input?: PostgresSchemaInput);
|
|
236
|
+
qualifier(): string;
|
|
237
|
+
qualifyTable(tableName: string): string;
|
|
238
|
+
schemaSqlExpression(): string;
|
|
239
|
+
schemaFilterExpression(): CfExpr;
|
|
240
|
+
tableSource(tableName: string, alias?: string): PostgresTableSource;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`
|
|
244
|
+
* so callers can dispatch to the polymorphic emission methods without
|
|
245
|
+
* branching at the call site. Uses the structural `kind` discriminator
|
|
246
|
+
* (`'schema'`) rather than `instanceof` so the check survives realm /
|
|
247
|
+
* bundle / hot-reload boundaries — matching the rest of the IR's
|
|
248
|
+
* narrowing convention. `PostgresUnboundSchema` passes through because
|
|
249
|
+
* it inherits the same `kind: 'schema'` from `PostgresSchema`.
|
|
250
|
+
*/
|
|
251
|
+
declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
|
|
252
|
+
/**
|
|
253
|
+
* Target-supplied `Namespace` factory the Postgres target plumbs
|
|
254
|
+
* through `defineContract({ createNamespace })` and the SQL PSL
|
|
255
|
+
* interpreter. Returns the unbound singleton for the framework
|
|
256
|
+
* sentinel and a fresh `PostgresSchema` for any other coordinate.
|
|
257
|
+
*
|
|
258
|
+
* The factory has no per-call state — every named id deterministically
|
|
259
|
+
* maps to a distinct schema instance — so callers can pass it through
|
|
260
|
+
* by reference and trust the resulting `SqlStorage.namespaces` map to
|
|
261
|
+
* be value-stable for a given input set. Native-enum column type names are
|
|
262
|
+
* schema-qualified earlier, at column construction, via the target's
|
|
263
|
+
* `authoring.qualifyColumnType` hook (`postgresQualifyColumnType`), so this
|
|
264
|
+
* factory just materialises the namespace from already-qualified entries.
|
|
265
|
+
*/
|
|
266
|
+
declare function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema;
|
|
267
|
+
//#endregion
|
|
268
|
+
export { postgresCreateNamespace as a, PostgresRlsEnablement as c, PostgresNativeEnumInput as d, isPostgresSchema as i, PostgresRlsEnablementInput as l, PostgresSchema as n, PostgresRole as o, PostgresUnboundSchema as r, PostgresRoleInput as s, PostgresContract as t, PostgresNativeEnum as u };
|
|
269
|
+
//# sourceMappingURL=postgres-schema-DKq6s1P3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-schema-DKq6s1P3.d.mts","names":[],"sources":["../src/core/postgres-native-enum.ts","../src/core/postgres-rls-enablement.ts","../src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