@prisma-next/target-postgres 0.14.0-dev.7 → 0.14.0-dev.70

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.
Files changed (265) hide show
  1. package/dist/authoring-Bi9aa8zG.mjs +574 -0
  2. package/dist/authoring-Bi9aa8zG.mjs.map +1 -0
  3. package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
  4. package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
  5. package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
  6. package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
  7. package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
  8. package/dist/codec-ids-C_-Hj6bL.mjs.map +1 -0
  9. package/dist/codec-ids.d.mts +2 -2
  10. package/dist/codec-ids.mjs +2 -2
  11. package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-BiIWziRO.d.mts} +3 -2
  12. package/dist/codec-types-BiIWziRO.d.mts.map +1 -0
  13. package/dist/codec-types.d.mts +1 -1
  14. package/dist/codecs-Cl_hQHg-.mjs +913 -0
  15. package/dist/codecs-Cl_hQHg-.mjs.map +1 -0
  16. package/dist/{codecs--0A5_4Bq.d.mts → codecs-Cm-nS4mQ.d.mts} +111 -4
  17. package/dist/codecs-Cm-nS4mQ.d.mts.map +1 -0
  18. package/dist/codecs.d.mts +2 -2
  19. package/dist/codecs.mjs +3 -757
  20. package/dist/codecs.mjs.map +1 -1
  21. package/dist/contract-free.d.mts +33 -3
  22. package/dist/contract-free.d.mts.map +1 -1
  23. package/dist/contract-free.mjs +23 -7
  24. package/dist/contract-free.mjs.map +1 -1
  25. package/dist/control-policy-5_5odTg9.mjs +1258 -0
  26. package/dist/control-policy-5_5odTg9.mjs.map +1 -0
  27. package/dist/control.d.mts +2 -2
  28. package/dist/control.d.mts.map +1 -1
  29. package/dist/control.mjs +866 -36
  30. package/dist/control.mjs.map +1 -1
  31. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  32. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
  33. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
  34. package/dist/data-transform.d.mts +1 -1
  35. package/dist/{ddl-QDyOSeLc.mjs → ddl-Dqgs-bDc.mjs} +93 -6
  36. package/dist/ddl-Dqgs-bDc.mjs.map +1 -0
  37. package/dist/ddl.d.mts +3 -2
  38. package/dist/ddl.mjs +2 -2
  39. package/dist/default-normalizer.d.mts +1 -1
  40. package/dist/default-normalizer.d.mts.map +1 -1
  41. package/dist/default-normalizer.mjs +247 -1
  42. package/dist/default-normalizer.mjs.map +1 -0
  43. package/dist/descriptor-meta-UugzVM-U.mjs +22 -0
  44. package/dist/descriptor-meta-UugzVM-U.mjs.map +1 -0
  45. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
  46. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
  47. package/dist/diff-database-schema-Dis8SMoT.mjs +305 -0
  48. package/dist/diff-database-schema-Dis8SMoT.mjs.map +1 -0
  49. package/dist/diff-database-schema.d.mts +46 -0
  50. package/dist/diff-database-schema.d.mts.map +1 -0
  51. package/dist/diff-database-schema.mjs +2 -0
  52. package/dist/errors-DO-w0EUS.mjs +35 -0
  53. package/dist/errors-DO-w0EUS.mjs.map +1 -0
  54. package/dist/errors.d.mts +11 -9
  55. package/dist/errors.d.mts.map +1 -1
  56. package/dist/errors.mjs +1 -1
  57. package/dist/issue-planner.d.mts +35 -11
  58. package/dist/issue-planner.d.mts.map +1 -1
  59. package/dist/issue-planner.mjs +2 -2
  60. package/dist/migration.d.mts +5 -5
  61. package/dist/migration.d.mts.map +1 -1
  62. package/dist/migration.mjs +4 -4
  63. package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
  64. package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
  65. package/dist/native-type-normalizer.mjs +37 -1
  66. package/dist/native-type-normalizer.mjs.map +1 -0
  67. package/dist/nodes-Bc2N3tMy.d.mts +170 -0
  68. package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
  69. package/dist/nodes-DJC5B8Id.mjs +192 -0
  70. package/dist/nodes-DJC5B8Id.mjs.map +1 -0
  71. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CSIg5XDu.d.mts} +91 -15
  72. package/dist/op-factory-call-CSIg5XDu.d.mts.map +1 -0
  73. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-WFZUHrbI.mjs} +400 -32
  74. package/dist/op-factory-call-WFZUHrbI.mjs.map +1 -0
  75. package/dist/op-factory-call.d.mts +2 -2
  76. package/dist/op-factory-call.mjs +2 -2
  77. package/dist/pack.d.mts +300 -3
  78. package/dist/pack.d.mts.map +1 -1
  79. package/dist/pack.mjs +1 -1
  80. package/dist/planner-BXlWpNsT.mjs +390 -0
  81. package/dist/planner-BXlWpNsT.mjs.map +1 -0
  82. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-BKlmGDJl.mjs} +17 -28
  83. package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
  84. package/dist/planner-ddl-builders.d.mts +4 -6
  85. package/dist/planner-ddl-builders.d.mts.map +1 -1
  86. package/dist/planner-ddl-builders.mjs +2 -2
  87. package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
  88. package/dist/planner-identity-values.d.mts +8 -2
  89. package/dist/planner-identity-values.d.mts.map +1 -1
  90. package/dist/planner-identity-values.mjs +2 -2
  91. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-C8vSaHku.mjs} +3 -3
  92. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-C8vSaHku.mjs.map} +1 -1
  93. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-CXue-6M9.d.mts} +4 -4
  94. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-CXue-6M9.d.mts.map} +1 -1
  95. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  96. package/dist/planner-produced-postgres-migration.mjs +1 -1
  97. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-CxJ8W66T.mjs} +3 -3
  98. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CxJ8W66T.mjs.map} +1 -1
  99. package/dist/planner-sql-checks.d.mts +2 -2
  100. package/dist/planner-sql-checks.d.mts.map +1 -1
  101. package/dist/planner-sql-checks.mjs +1 -1
  102. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  103. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  104. package/dist/planner-target-details.d.mts +1 -1
  105. package/dist/planner.d.mts +72 -17
  106. package/dist/planner.d.mts.map +1 -1
  107. package/dist/planner.mjs +3 -2
  108. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-C3LPCLP_.mjs} +45 -41
  109. package/dist/postgres-contract-view-C3LPCLP_.mjs.map +1 -0
  110. package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
  111. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
  112. package/dist/postgres-database-schema-node-CJv5bfbs.d.mts +262 -0
  113. package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
  114. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-B3u0erMT.mjs} +69 -45
  115. package/dist/postgres-migration-B3u0erMT.mjs.map +1 -0
  116. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DkmgGNcv.d.mts} +47 -9
  117. package/dist/postgres-migration-DkmgGNcv.d.mts.map +1 -0
  118. package/dist/postgres-native-enum-BwVNf0Ku.mjs +45 -0
  119. package/dist/postgres-native-enum-BwVNf0Ku.mjs.map +1 -0
  120. package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
  121. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  122. package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs +190 -0
  123. package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
  124. package/dist/postgres-schema-DKq6s1P3.d.mts +269 -0
  125. package/dist/postgres-schema-DKq6s1P3.d.mts.map +1 -0
  126. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DYATroNx.mjs} +200 -11
  127. package/dist/postgres-schema-DYATroNx.mjs.map +1 -0
  128. package/dist/postgres-table-schema-node-D6LvInCe.mjs +216 -0
  129. package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
  130. package/dist/render-ops.d.mts +1 -1
  131. package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
  132. package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
  133. package/dist/render-typescript.mjs +1 -1
  134. package/dist/resolve-ddl-schema-DpGte50u.mjs +22 -0
  135. package/dist/resolve-ddl-schema-DpGte50u.mjs.map +1 -0
  136. package/dist/rls-canonicalize.d.mts +20 -0
  137. package/dist/rls-canonicalize.d.mts.map +1 -0
  138. package/dist/rls-canonicalize.mjs +2 -0
  139. package/dist/runtime.d.mts +6 -8
  140. package/dist/runtime.d.mts.map +1 -1
  141. package/dist/runtime.mjs +3 -3
  142. package/dist/runtime.mjs.map +1 -1
  143. package/dist/schema-ir-annotations.d.mts +15 -0
  144. package/dist/schema-ir-annotations.d.mts.map +1 -0
  145. package/dist/schema-ir-annotations.mjs +2 -0
  146. package/dist/{sql-utils-DcfMz4MQ.mjs → sql-utils-SU4FDvIV.mjs} +12 -3
  147. package/dist/{sql-utils-DcfMz4MQ.mjs.map → sql-utils-SU4FDvIV.mjs.map} +1 -1
  148. package/dist/sql-utils.d.mts +8 -1
  149. package/dist/sql-utils.d.mts.map +1 -1
  150. package/dist/sql-utils.mjs +2 -2
  151. package/dist/types.d.mts +4 -140
  152. package/dist/types.mjs +5 -2
  153. package/dist/wire-name-rHHtr1h0.mjs +75 -0
  154. package/dist/wire-name-rHHtr1h0.mjs.map +1 -0
  155. package/package.json +23 -17
  156. package/src/contract-free/checks.ts +73 -0
  157. package/src/contract-free/control-bootstrap.ts +20 -3
  158. package/src/contract-free/ddl.ts +98 -1
  159. package/src/core/authoring.ts +509 -2
  160. package/src/core/codec-ids.ts +1 -0
  161. package/src/core/codec-type-map.ts +2 -0
  162. package/src/core/codecs.ts +180 -1
  163. package/src/core/ddl/nodes.ts +185 -2
  164. package/src/core/default-normalizer.ts +122 -2
  165. package/src/core/descriptor-meta.ts +10 -1
  166. package/src/core/entity-kinds.ts +41 -0
  167. package/src/core/errors.ts +14 -12
  168. package/src/core/migrations/bound-schema.ts +10 -0
  169. package/src/core/migrations/column-ddl-rendering.ts +117 -0
  170. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +189 -0
  171. package/src/core/migrations/control-policy.ts +217 -65
  172. package/src/core/migrations/diff-database-schema.ts +252 -0
  173. package/src/core/migrations/issue-planner.ts +769 -656
  174. package/src/core/migrations/op-factory-call.ts +273 -21
  175. package/src/core/migrations/operations/columns.ts +24 -12
  176. package/src/core/migrations/operations/constraints.ts +1 -1
  177. package/src/core/migrations/operations/data-transform.ts +6 -0
  178. package/src/core/migrations/operations/dependencies.ts +2 -1
  179. package/src/core/migrations/operations/native-enum-types.ts +62 -0
  180. package/src/core/migrations/operations/rls.ts +187 -0
  181. package/src/core/migrations/operations/shared.ts +0 -30
  182. package/src/core/migrations/planner-ddl-builders.ts +31 -59
  183. package/src/core/migrations/planner-identity-values.ts +1 -1
  184. package/src/core/migrations/planner-recipes.ts +31 -13
  185. package/src/core/migrations/planner-sql-checks.ts +1 -1
  186. package/src/core/migrations/planner-strategies.ts +248 -216
  187. package/src/core/migrations/planner-target-details.ts +3 -1
  188. package/src/core/migrations/planner.ts +357 -67
  189. package/src/core/migrations/postgres-migration.ts +101 -86
  190. package/src/core/migrations/render-typescript.ts +42 -15
  191. package/src/core/migrations/resolve-ddl-schema.ts +26 -0
  192. package/src/core/migrations/runner.ts +11 -16
  193. package/src/core/migrations/verify-postgres-namespaces.ts +46 -31
  194. package/src/core/namespace-ids.ts +3 -0
  195. package/src/core/postgres-contract-serializer.ts +46 -71
  196. package/src/core/postgres-contract-view.ts +48 -0
  197. package/src/core/postgres-native-enum.ts +61 -0
  198. package/src/core/postgres-rls-enablement.ts +34 -0
  199. package/src/core/postgres-rls-policy.ts +64 -0
  200. package/src/core/postgres-role.ts +59 -0
  201. package/src/core/postgres-schema-verifier.ts +10 -7
  202. package/src/core/postgres-schema.ts +85 -15
  203. package/src/core/postgres-validators.ts +34 -0
  204. package/src/core/psl-infer/infer-psl-contract.ts +1273 -0
  205. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  206. package/src/core/psl-infer/postgres-type-map.ts +128 -0
  207. package/src/core/rls/canonicalize.ts +48 -0
  208. package/src/core/rls/wire-name.ts +33 -0
  209. package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
  210. package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
  211. package/src/core/schema-ir/postgres-namespace-schema-node.ts +70 -0
  212. package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
  213. package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
  214. package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
  215. package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
  216. package/src/core/schema-ir/schema-node-kinds.ts +122 -0
  217. package/src/core/sql-utils.ts +15 -2
  218. package/src/exports/codecs.ts +3 -0
  219. package/src/exports/contract-free.ts +11 -1
  220. package/src/exports/control.ts +27 -33
  221. package/src/exports/ddl.ts +8 -0
  222. package/src/exports/diff-database-schema.ts +7 -0
  223. package/src/exports/issue-planner.ts +1 -1
  224. package/src/exports/migration.ts +1 -0
  225. package/src/exports/op-factory-call.ts +3 -0
  226. package/src/exports/planner-ddl-builders.ts +0 -2
  227. package/src/exports/planner-identity-values.ts +4 -1
  228. package/src/exports/planner.ts +1 -0
  229. package/src/exports/rls-canonicalize.ts +7 -0
  230. package/src/exports/runtime.ts +1 -0
  231. package/src/exports/schema-ir-annotations.ts +1 -0
  232. package/src/exports/sql-utils.ts +1 -0
  233. package/src/exports/types.ts +37 -0
  234. package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
  235. package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
  236. package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
  237. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  238. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  239. package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
  240. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  241. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  242. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  243. package/dist/errors-CUk87ByX.mjs +0 -33
  244. package/dist/errors-CUk87ByX.mjs.map +0 -1
  245. package/dist/issue-planner-DL6g3CmE.mjs +0 -824
  246. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  247. package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
  248. package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
  249. package/dist/nodes-Bbhs2rwj.mjs +0 -76
  250. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  251. package/dist/nodes-pLeLgdis.d.mts +0 -67
  252. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  253. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  254. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  255. package/dist/planner-Bs_baQax.mjs +0 -324
  256. package/dist/planner-Bs_baQax.mjs.map +0 -1
  257. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  258. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  259. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  260. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  261. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  262. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  263. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  264. package/dist/types.d.mts.map +0 -1
  265. package/src/core/postgres-enum-type-schema.ts +0 -17
@@ -1,11 +1,151 @@
1
- import { _ as PG_TEXT_CODEC_ID } from "./codec-ids-BvytN2P8.mjs";
2
- import { n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
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 { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
7
10
  import { composeSqlEntityKinds } from "@prisma-next/sql-contract/entity-kinds";
8
11
  import { cfExpr } from "@prisma-next/sql-relational-core/contract-free";
12
+ import { invariant } from "@prisma-next/utils/assertions";
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 NamespaceBase {
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(), "carry");
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 withPresence = valueSetRaw !== void 0 && Object.keys(valueSetRaw).length === 0 ? {
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(withPresence));
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 { PostgresTableSource as a, postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
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-COGZ1ark.mjs.map
424
+ //# sourceMappingURL=postgres-schema-DYATroNx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-DYATroNx.mjs","names":[],"sources":["../src/core/postgres-rls-enablement.ts","../src/core/postgres-rls-policy.ts","../src/core/postgres-role.ts","../src/core/postgres-validators.ts","../src/core/ast/table-source.ts","../src/core/entity-kinds.ts","../src/core/postgres-schema.ts"],"sourcesContent":["import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresRlsEnablementInput {\n /** Name of the table this marker declares RLS-controlled. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). Markers are schema-scoped like policies. */\n readonly namespaceId: string;\n}\n\n/**\n * Postgres contract-IR marker for `@@rls` on a model: the table named here is\n * RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never\n * by the policy set).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an\n * entity kind, extends `SqlNode`, and is stored in `contract.json` under\n * `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`\n * discriminant is enumerable so it survives JSON serialization; the literal\n * matches the entries key (one-string rule).\n */\nexport class PostgresRlsEnablement extends SqlNode {\n override readonly kind = 'rls' as const;\n readonly tableName: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRlsEnablementInput) {\n super();\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';\n\nexport interface PostgresRlsPolicyInput {\n /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). Policies are schema-scoped. */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n}\n\n/**\n * Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresPolicySchemaNode` for that role.\n *\n * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`\n * discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it\n * survives JSON serialization and enables dispatch. The literal matches the\n * entries key (one-string rule: node.kind === entries key === entity kind).\n */\nexport class PostgresRlsPolicy extends SqlNode {\n override readonly kind = 'policy' as const;\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n\n constructor(input: PostgresRlsPolicyInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\n/**\n * Roles are referenced by the contract but never owned — the framework\n * issues no `CREATE`/`DROP ROLE`, so a role's effective governance is always\n * `external`: a missing declared role fails verify, an extra live role is\n * tolerated, and the planner emits zero role DDL. `external` is the only\n * value a role's control can ever carry.\n */\nexport const ROLE_DEFAULT_CONTROL_POLICY = 'external';\n\nexport interface PostgresRoleInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`\n * from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n /**\n * Defaults to {@link ROLE_DEFAULT_CONTROL_POLICY} when omitted. Roles are\n * referenced but never owned, so `'external'` is the only allowed value.\n */\n readonly control?: 'external';\n}\n\n/**\n * Postgres contract-IR class for a database role (`CREATE ROLE …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresRoleSchemaNode` for that role.\n *\n * Roles are cluster-scoped, so their namespace coordinate is always\n * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.\n * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.\n * The `kind: 'role'` discriminant is enumerable so it survives JSON.\n * Matches the entries key (one-string rule).\n *\n * `control` always carries a value (never omitted): it defaults to\n * {@link ROLE_DEFAULT_CONTROL_POLICY} in the constructor, so both a\n * freshly-authored role and one hydrated from an older `contract.json`\n * lacking the field resolve the same way — the control-policy resolver\n * reads it directly off the entity instead of special-casing role issues.\n */\nexport class PostgresRole extends SqlNode {\n override readonly kind = 'role' as const;\n readonly name: string;\n readonly namespaceId: string;\n readonly control: 'external';\n\n constructor(input: PostgresRoleInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n this.control = input.control ?? ROLE_DEFAULT_CONTROL_POLICY;\n freezeNode(this);\n }\n}\n","import { type } from 'arktype';\n\nexport const PostgresRoleSchema = type({\n kind: \"'role'\",\n name: 'string',\n namespaceId: 'string',\n 'control?': \"'external'\",\n});\n\nexport const PostgresRlsPolicySchema = type({\n kind: \"'policy'\",\n name: 'string',\n prefix: 'string',\n tableName: 'string',\n namespaceId: 'string',\n operation: \"'select' | 'insert' | 'update' | 'delete' | 'all'\",\n roles: type.string.array().readonly(),\n 'using?': 'string',\n 'withCheck?': 'string',\n permissive: 'boolean',\n});\n\nexport const PostgresRlsEnablementSchema = type({\n kind: \"'rls'\",\n tableName: 'string',\n namespaceId: 'string',\n});\n\nexport const PostgresNativeEnumSchema = type({\n kind: \"'postgres-enum'\",\n typeName: 'string',\n members: type.string.array().readonly(),\n 'control?': \"'managed' | 'tolerated' | 'external' | 'observed'\",\n});\n","import {\n type AnyFromSource,\n type AstRewriter,\n TableSource,\n} from '@prisma-next/sql-relational-core/ast';\n\nexport class PostgresTableSource extends TableSource {\n readonly schema: string | undefined;\n\n constructor(options: {\n readonly name: string;\n readonly schema?: string;\n readonly alias?: string;\n }) {\n super(options.name, options.alias);\n this.schema = options.schema;\n this.freeze();\n }\n\n override rewrite(rewriter: AstRewriter): AnyFromSource {\n return rewriter.tableSource ? rewriter.tableSource(this) : this;\n }\n}\n","import type { EntityKindDescriptor } from '@prisma-next/framework-components/ir';\nimport { PostgresNativeEnum, type PostgresNativeEnumInput } from './postgres-native-enum';\nimport { PostgresRlsEnablement, type PostgresRlsEnablementInput } from './postgres-rls-enablement';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsEnablementSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\n\nexport const policyEntityKind: EntityKindDescriptor<PostgresRlsPolicyInput, PostgresRlsPolicy> = {\n kind: 'policy',\n schema: PostgresRlsPolicySchema,\n construct: (input) => new PostgresRlsPolicy(input),\n};\n\nexport const roleEntityKind: EntityKindDescriptor<PostgresRoleInput, PostgresRole> = {\n kind: 'role',\n schema: PostgresRoleSchema,\n construct: (input) => new PostgresRole(input),\n};\n\nexport const rlsEnablementEntityKind: EntityKindDescriptor<\n PostgresRlsEnablementInput,\n PostgresRlsEnablement\n> = {\n kind: 'rls',\n schema: PostgresRlsEnablementSchema,\n construct: (input) => new PostgresRlsEnablement(input),\n};\n\nexport const nativeEnumEntityKind: EntityKindDescriptor<\n PostgresNativeEnumInput,\n PostgresNativeEnum\n> = {\n kind: 'native_enum',\n schema: PostgresNativeEnumSchema,\n construct: (input) => new PostgresNativeEnum(input),\n};\n","import type { Contract } from '@prisma-next/contract/types';\nimport {\n freezeNode,\n hydrateNamespaceEntities,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { composeSqlEntityKinds } from '@prisma-next/sql-contract/entity-kinds';\nimport {\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceInput,\n type SqlStorage,\n type StorageTable,\n type StorageValueSet,\n} from '@prisma-next/sql-contract/types';\n\nimport { type CfExpr, cfExpr } from '@prisma-next/sql-relational-core/contract-free';\nimport { invariant } from '@prisma-next/utils/assertions';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PostgresTableSource } from './ast/table-source';\nimport { PG_TEXT_CODEC_ID } from './codec-ids';\nimport {\n nativeEnumEntityKind,\n policyEntityKind,\n rlsEnablementEntityKind,\n roleEntityKind,\n} from './entity-kinds';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport type { PostgresRlsEnablement } from './postgres-rls-enablement';\nimport type { PostgresRlsPolicy } from './postgres-rls-policy';\nimport type { PostgresRole } from './postgres-role';\nimport { escapeLiteral } from './sql-utils';\n\nexport type PostgresContract = Contract<SqlStorage> & { readonly target: 'postgres' };\n\nexport type PostgresNamespaceEntries = SqlNamespaceEntries & {\n readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;\n readonly role?: Readonly<Record<string, PostgresRole>>;\n readonly rls?: Readonly<Record<string, PostgresRlsEnablement>>;\n readonly native_enum?: Readonly<Record<string, PostgresNativeEnum>>;\n};\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends SqlNamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: PostgresNamespaceEntries;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n composeSqlEntityKinds([\n policyEntityKind,\n roleEntityKind,\n rlsEnablementEntityKind,\n nativeEnumEntityKind,\n ]),\n 'carry',\n );\n\n // A native enum keys under its PHYSICAL type name in storage `entries`\n // (ADR 221 coordinate `entityName`). The family/authoring layer keys every\n // block by its author handle, so re-key the `native_enum` slot by each\n // entity's `typeName` here — target-local Postgres code that already knows\n // this entity kind. This runs at both authoring and hydration; a serialized\n // contract's key already equals the `typeName`, so the re-key is idempotent.\n const nativeEnumSlot = dispatched['native_enum'];\n if (nativeEnumSlot !== undefined) {\n const rekeyed: Record<string, unknown> = {};\n for (const [handle, entity] of Object.entries(nativeEnumSlot)) {\n const physicalName = PostgresNativeEnum.is(entity) ? entity.typeName : handle;\n invariant(\n !Object.hasOwn(rekeyed, physicalName),\n `PostgresSchema \"${input.id}\": two native_enum entities resolve to the same physical type name \"${physicalName}\". Give them distinct @@map type names.`,\n );\n rekeyed[physicalName] = entity;\n }\n dispatched['native_enum'] = Object.freeze(rekeyed);\n }\n\n // Drop an empty valueSet so presence signals non-emptiness.\n const valueSetRaw = dispatched['valueSet'];\n const withPresence =\n valueSetRaw !== undefined && Object.keys(valueSetRaw).length === 0\n ? { ...dispatched, valueSet: undefined }\n : dispatched;\n\n const entriesInput: Record<string, Readonly<Record<string, unknown>> | undefined> = {\n ...withPresence,\n };\n\n this.entries = Object.freeze(\n blindCast<\n PostgresNamespaceEntries,\n 'composeSqlEntityKinds([policyEntityKind, roleEntityKind, rlsEnablementEntityKind, nativeEnumEntityKind]) supplies table→StorageTable, valueSet→StorageValueSet, policy→PostgresRlsPolicy, role→PostgresRole, rls→PostgresRlsEnablement, native_enum→PostgresNativeEnum descriptors'\n >(entriesInput),\n );\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined {\n return this.entries.valueSet;\n }\n\n get policy(): Readonly<Record<string, PostgresRlsPolicy>> {\n return this.entries.policy ?? Object.freeze({});\n }\n\n get role(): Readonly<Record<string, PostgresRole>> {\n return this.entries.role ?? Object.freeze({});\n }\n\n get rls(): Readonly<Record<string, PostgresRlsEnablement>> {\n return this.entries.rls ?? Object.freeze({});\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a\n * builder-built catalog check compares `n.nspname` / `table_schema`\n * against. Named schemas bind the schema name as a text parameter; the\n * unbound singleton overrides this to the opaque `current_schema()`\n * expression so the live connection's `search_path` decides at runtime.\n */\n schemaFilterExpression(): CfExpr {\n return cfExpr.param(this.id, PG_TEXT_CODEC_ID);\n }\n\n /**\n * Typed-AST counterpart of {@link qualifyTable}: the FROM source a\n * builder-built check uses to address a user table in this namespace.\n * Named schemas qualify (`\"schema\".\"table\"`); the unbound singleton\n * overrides this to leave the table unqualified so `search_path`\n * resolves it at runtime.\n */\n tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n schema: this.id,\n ...ifDefined('alias', alias),\n });\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` route through the polymorphic\n * `PostgresUnboundSchema` overrides and produce unqualified\n * (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`\n * route through the polymorphic factory and produce unqualified output\n * automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n\n override schemaFilterExpression(): CfExpr {\n return cfExpr.raw('current_schema()', { codecId: PG_TEXT_CODEC_ID, nullable: false });\n }\n\n override tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n ...ifDefined('alias', alias),\n });\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set. Native-enum column type names are\n * schema-qualified earlier, at column construction, via the target's\n * `authoring.qualifyColumnType` hook (`postgresQualifyColumnType`), so this\n * factory just materialises the namespace from already-qualified entries.\n */\nexport function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n ...input.entries,\n table: input.entries['table'] ?? {},\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":"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"}
@@ -0,0 +1,216 @@
1
+ import { freezeNode } from "@prisma-next/framework-components/ir";
2
+ import { blindCast } from "@prisma-next/utils/casts";
3
+ import { PrimaryKey, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlUniqueIR, assertNode, relationalNodeEntityKind, relationalNodeGranularity } from "@prisma-next/sql-schema-ir/types";
4
+ //#region src/core/schema-ir/schema-node-kinds.ts
5
+ /**
6
+ * The `nodeKind` discriminant for each Postgres schema-diff node. Each node
7
+ * carries a unique value; the static `is`/`assert` guards compare against these
8
+ * identifiers rather than spelling the string inline or using `instanceof`. The
9
+ * field is an enumerable own property carried on every node instance.
10
+ */
11
+ const PostgresSchemaNodeKind = {
12
+ database: "postgres-database",
13
+ namespace: "postgres-namespace",
14
+ table: "postgres-table",
15
+ policy: "postgres-policy",
16
+ role: "postgres-role",
17
+ nativeEnum: "postgres-native-enum"
18
+ };
19
+ /**
20
+ * The one real map from a Postgres-specific `nodeKind` to the
21
+ * framework-neutral {@link DiffSubjectGranularity} its diff issues carry —
22
+ * resolution is by `nodeKind` equality against this map, never a
23
+ * `nodeKind`-suffix string match and never anything stamped on the node.
24
+ */
25
+ const POSTGRES_NODE_GRANULARITY = {
26
+ [PostgresSchemaNodeKind.database]: "structural",
27
+ [PostgresSchemaNodeKind.namespace]: "namespace",
28
+ [PostgresSchemaNodeKind.table]: "entity",
29
+ [PostgresSchemaNodeKind.policy]: "structural",
30
+ [PostgresSchemaNodeKind.role]: "structural",
31
+ [PostgresSchemaNodeKind.nativeEnum]: "entity"
32
+ };
33
+ function isPostgresSchemaNodeKind(nodeKind) {
34
+ return Object.hasOwn(POSTGRES_NODE_GRANULARITY, nodeKind);
35
+ }
36
+ /** Looks up the subject granularity for a Postgres-specific `nodeKind`. */
37
+ function postgresNodeGranularity(nodeKind) {
38
+ return POSTGRES_NODE_GRANULARITY[nodeKind];
39
+ }
40
+ /**
41
+ * The subject granularity for any node kind that appears in a Postgres diff
42
+ * tree — the tree mixes Postgres-specific kinds (database/namespace/table/
43
+ * policy/role) with the relational leaf kinds (columns, constraints, indexes,
44
+ * …), so this dispatches to whichever family/target map owns the kind. Called
45
+ * on demand by consumers (the family verdict, the framework aggregate's
46
+ * unclaimed-elements sweep, via the {@link
47
+ * import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}
48
+ * capability) — never stamped onto the issue or the node.
49
+ */
50
+ function postgresDiffSubjectGranularity(nodeKind) {
51
+ return isPostgresSchemaNodeKind(nodeKind) ? postgresNodeGranularity(nodeKind) : relationalNodeGranularity(nodeKind);
52
+ }
53
+ /**
54
+ * The map from a Postgres-specific `nodeKind` to its storage `entityKind` — the
55
+ * same vocabulary the contract storage's `entries` dictionary keys use. The
56
+ * whole-table and native-enum kinds each have an entity of their own;
57
+ * database/namespace/policy/role nodes map to nothing here (a namespace is
58
+ * addressed by id, not by an `entries` kind; policies and roles are
59
+ * structural, never a sibling space's unclaimed entity).
60
+ *
61
+ * The native enum keys under its PHYSICAL type name in `entries.native_enum`
62
+ * (ADR 221), so its diff node's `typeName` addresses the entity on the generic
63
+ * coordinate directly — no by-type-name walk needed. This lets the framework's
64
+ * unclaimed-elements sweep classify enum ownership the same coordinate way it
65
+ * classifies tables.
66
+ */
67
+ const POSTGRES_NODE_ENTITY_KIND = {
68
+ [PostgresSchemaNodeKind.table]: "table",
69
+ [PostgresSchemaNodeKind.nativeEnum]: "native_enum"
70
+ };
71
+ /** Looks up the storage entityKind for a Postgres-specific `nodeKind`. */
72
+ function postgresNodeEntityKind(nodeKind) {
73
+ return POSTGRES_NODE_ENTITY_KIND[nodeKind];
74
+ }
75
+ /**
76
+ * The storage `entityKind` for any node kind that appears in a Postgres diff
77
+ * tree — sibling of {@link postgresDiffSubjectGranularity}, dispatching the
78
+ * same way to whichever family/target map owns the kind. Called on demand by
79
+ * the framework aggregate's unclaimed-elements sweep via the {@link
80
+ * import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}
81
+ * capability — never stamped onto the issue or the node.
82
+ */
83
+ function postgresDiffSubjectEntityKind(nodeKind) {
84
+ return isPostgresSchemaNodeKind(nodeKind) ? postgresNodeEntityKind(nodeKind) : relationalNodeEntityKind(nodeKind);
85
+ }
86
+ //#endregion
87
+ //#region src/core/schema-ir/postgres-native-enum-schema-node.ts
88
+ /**
89
+ * Schema-diff leaf node for a native Postgres enum type.
90
+ *
91
+ * This is a derived, transient node walked by the differ — it is NEVER
92
+ * serialized. Both sides derive it on the namespace node: the expected side
93
+ * from the contract's hydrated `entries.native_enum` entities, the actual
94
+ * side from the adapter's introspected `nativeEnums`.
95
+ *
96
+ * Enum types are schema-scoped, so identity is (namespace, type name): the
97
+ * namespace coordinate comes from tree position (the differ pairs enum nodes
98
+ * only inside an already-paired namespace) and `id` carries the type name,
99
+ * prefixed with the entries-kind vocabulary (`native_enum:<typeName>`) so it
100
+ * cannot collide with a sibling table of the same name — the same
101
+ * sibling-prefix convention relational column nodes use (`column:<name>`).
102
+ *
103
+ * `isEqualTo` compares members POSITIONALLY — `['a','b'] ≠ ['b','a']` —
104
+ * because Postgres enum sort order is semantic. `control` is contract
105
+ * metadata, not database state, and does not participate in equality.
106
+ */
107
+ var PostgresNativeEnumSchemaNode = class PostgresNativeEnumSchemaNode extends SqlSchemaIRNode {
108
+ nodeKind = PostgresSchemaNodeKind.nativeEnum;
109
+ typeName;
110
+ namespaceId;
111
+ members;
112
+ constructor(input) {
113
+ super();
114
+ this.typeName = input.typeName;
115
+ this.namespaceId = input.namespaceId;
116
+ this.members = Object.freeze([...input.members]);
117
+ if (input.control !== void 0) this.control = input.control;
118
+ freezeNode(this);
119
+ }
120
+ get id() {
121
+ return `native_enum:${this.typeName}`;
122
+ }
123
+ children() {
124
+ return [];
125
+ }
126
+ isEqualTo(other) {
127
+ const node = blindCast(other);
128
+ PostgresNativeEnumSchemaNode.assert(node);
129
+ return this.typeName === node.typeName && this.members.length === node.members.length && this.members.every((member, index) => member === node.members[index]);
130
+ }
131
+ static is(node) {
132
+ return node.nodeKind === PostgresSchemaNodeKind.nativeEnum;
133
+ }
134
+ static assert(node) {
135
+ assertNode(node, "PostgresNativeEnumSchemaNode", PostgresNativeEnumSchemaNode.is);
136
+ }
137
+ };
138
+ //#endregion
139
+ //#region src/core/schema-ir/postgres-table-schema-node.ts
140
+ /**
141
+ * Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields
142
+ * plus `policies`, and implements `DiffableNode` so the table instance is
143
+ * directly the diff-tree node — no separate wrapper needed.
144
+ *
145
+ * Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because
146
+ * `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
147
+ * subclass field initialisation.
148
+ *
149
+ * `id` is the table name. `isEqualTo` compares id + `rlsEnabled` — the
150
+ * table's one own diffable attribute; all other structural drift is
151
+ * expressed by its children. `children()` returns every column, the primary
152
+ * key (when present), every foreign key, unique, index, and check constraint,
153
+ * plus the policy nodes — one flat list, so a drifted column and a drifted
154
+ * policy are both reported by the same walk. Order is deterministic (object
155
+ * key order for columns, array order for the rest) so two structurally equal
156
+ * tables always produce the same child list.
157
+ */
158
+ var PostgresTableSchemaNode = class PostgresTableSchemaNode extends SqlSchemaIRNode {
159
+ nodeKind = PostgresSchemaNodeKind.table;
160
+ name;
161
+ columns;
162
+ foreignKeys;
163
+ uniques;
164
+ indexes;
165
+ policies;
166
+ rlsEnabled;
167
+ constructor(input) {
168
+ super();
169
+ this.name = input.name;
170
+ this.rlsEnabled = input.rlsEnabled;
171
+ this.columns = Object.freeze(Object.fromEntries(Object.entries(input.columns).map(([key, col]) => [key, col instanceof SqlColumnIR ? col : new SqlColumnIR(col)])));
172
+ this.foreignKeys = Object.freeze(input.foreignKeys.map((fk) => fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk)));
173
+ this.uniques = Object.freeze(input.uniques.map((u) => u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u)));
174
+ this.indexes = Object.freeze(input.indexes.map((i) => i instanceof SqlIndexIR ? i : new SqlIndexIR(i)));
175
+ if (input.primaryKey !== void 0) this.primaryKey = input.primaryKey instanceof PrimaryKey ? input.primaryKey : new PrimaryKey(input.primaryKey);
176
+ if (input.annotations !== void 0) this.annotations = input.annotations;
177
+ if (input.checks !== void 0 && input.checks.length > 0) this.checks = Object.freeze(input.checks.map((c) => c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c)));
178
+ this.policies = Object.freeze([...input.policies ?? []]);
179
+ freezeNode(this);
180
+ }
181
+ get id() {
182
+ return this.name;
183
+ }
184
+ /**
185
+ * Equal iff the ids (names) match AND `rlsEnabled` matches — the table's
186
+ * one own attribute in the diff; all other structural drift is expressed
187
+ * by children. A paired `not-equal` therefore always means enablement
188
+ * drift, which the planner maps to ENABLE/DISABLE ROW LEVEL SECURITY.
189
+ */
190
+ isEqualTo(other) {
191
+ const node = blindCast(other);
192
+ PostgresTableSchemaNode.assert(node);
193
+ return this.id === node.id && this.rlsEnabled === node.rlsEnabled;
194
+ }
195
+ children() {
196
+ return [
197
+ ...Object.values(this.columns),
198
+ ...this.primaryKey ? [this.primaryKey] : [],
199
+ ...this.foreignKeys,
200
+ ...this.uniques,
201
+ ...this.indexes,
202
+ ...this.checks ?? [],
203
+ ...this.policies
204
+ ];
205
+ }
206
+ static is(node) {
207
+ return node.nodeKind === PostgresSchemaNodeKind.table;
208
+ }
209
+ static assert(node) {
210
+ assertNode(node, "PostgresTableSchemaNode", PostgresTableSchemaNode.is);
211
+ }
212
+ };
213
+ //#endregion
214
+ export { postgresDiffSubjectGranularity as a, postgresDiffSubjectEntityKind as i, PostgresNativeEnumSchemaNode as n, postgresNodeEntityKind as o, PostgresSchemaNodeKind as r, PostgresTableSchemaNode as t };
215
+
216
+ //# sourceMappingURL=postgres-table-schema-node-D6LvInCe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-table-schema-node-D6LvInCe.mjs","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts","../src/core/schema-ir/postgres-native-enum-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts"],"sourcesContent":["import type {\n DiffableNode,\n DiffSubjectGranularity,\n} from '@prisma-next/framework-components/control';\nimport {\n relationalNodeEntityKind,\n relationalNodeGranularity,\n type SqlSchemaIRNode,\n} from '@prisma-next/sql-schema-ir/types';\n\n/**\n * A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements\n * `DiffableNode` (the five `Postgres*SchemaNode` classes). `SqlSchemaIRNode`\n * alone is not a `DiffableNode` — its relational subclasses (`SqlColumnIR`, …)\n * carry no `id`/`isEqualTo`/`children` — so this intersection is the honest node\n * type the differ produces and the planner consumes (`SchemaDiff<SqlSchemaDiffNode>`).\n */\nexport type SqlSchemaDiffNode = SqlSchemaIRNode & DiffableNode;\n\n/**\n * The `nodeKind` discriminant for each Postgres schema-diff node. Each node\n * carries a unique value; the static `is`/`assert` guards compare against these\n * identifiers rather than spelling the string inline or using `instanceof`. The\n * field is an enumerable own property carried on every node instance.\n */\nexport const PostgresSchemaNodeKind = {\n database: 'postgres-database',\n namespace: 'postgres-namespace',\n table: 'postgres-table',\n policy: 'postgres-policy',\n role: 'postgres-role',\n nativeEnum: 'postgres-native-enum',\n} as const;\n\nexport type PostgresSchemaNodeKind =\n (typeof PostgresSchemaNodeKind)[keyof typeof PostgresSchemaNodeKind];\n\n/**\n * The one real map from a Postgres-specific `nodeKind` to the\n * framework-neutral {@link DiffSubjectGranularity} its diff issues carry —\n * resolution is by `nodeKind` equality against this map, never a\n * `nodeKind`-suffix string match and never anything stamped on the node.\n */\nconst POSTGRES_NODE_GRANULARITY: Readonly<Record<PostgresSchemaNodeKind, DiffSubjectGranularity>> =\n {\n [PostgresSchemaNodeKind.database]: 'structural',\n [PostgresSchemaNodeKind.namespace]: 'namespace',\n [PostgresSchemaNodeKind.table]: 'entity',\n // A policy set is owned by the managed table it attaches to; a role is\n // referenced by the contract but not owned (the framework names it in a\n // policy but never owns the cluster's role list). Both classify as\n // `structural`. The asymmetry for roles — a missing declared one fails, an\n // undeclared live one is tolerated unconditionally — comes from the\n // control policy the diff resolves a role issue against (`external`),\n // not from the granularity.\n [PostgresSchemaNodeKind.policy]: 'structural',\n [PostgresSchemaNodeKind.role]: 'structural',\n [PostgresSchemaNodeKind.nativeEnum]: 'entity',\n };\n\nfunction isPostgresSchemaNodeKind(nodeKind: string): nodeKind is PostgresSchemaNodeKind {\n return Object.hasOwn(POSTGRES_NODE_GRANULARITY, nodeKind);\n}\n\n/** Looks up the subject granularity for a Postgres-specific `nodeKind`. */\nexport function postgresNodeGranularity(nodeKind: PostgresSchemaNodeKind): DiffSubjectGranularity {\n return POSTGRES_NODE_GRANULARITY[nodeKind];\n}\n\n/**\n * The subject granularity for any node kind that appears in a Postgres diff\n * tree — the tree mixes Postgres-specific kinds (database/namespace/table/\n * policy/role) with the relational leaf kinds (columns, constraints, indexes,\n * …), so this dispatches to whichever family/target map owns the kind. Called\n * on demand by consumers (the family verdict, the framework aggregate's\n * unclaimed-elements sweep, via the {@link\n * import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}\n * capability) — never stamped onto the issue or the node.\n */\nexport function postgresDiffSubjectGranularity(nodeKind: string): DiffSubjectGranularity {\n return isPostgresSchemaNodeKind(nodeKind)\n ? postgresNodeGranularity(nodeKind)\n : relationalNodeGranularity(nodeKind);\n}\n\n/**\n * The map from a Postgres-specific `nodeKind` to its storage `entityKind` — the\n * same vocabulary the contract storage's `entries` dictionary keys use. The\n * whole-table and native-enum kinds each have an entity of their own;\n * database/namespace/policy/role nodes map to nothing here (a namespace is\n * addressed by id, not by an `entries` kind; policies and roles are\n * structural, never a sibling space's unclaimed entity).\n *\n * The native enum keys under its PHYSICAL type name in `entries.native_enum`\n * (ADR 221), so its diff node's `typeName` addresses the entity on the generic\n * coordinate directly — no by-type-name walk needed. This lets the framework's\n * unclaimed-elements sweep classify enum ownership the same coordinate way it\n * classifies tables.\n */\nconst POSTGRES_NODE_ENTITY_KIND: Partial<Readonly<Record<PostgresSchemaNodeKind, string>>> = {\n [PostgresSchemaNodeKind.table]: 'table',\n [PostgresSchemaNodeKind.nativeEnum]: 'native_enum',\n};\n\n/** Looks up the storage entityKind for a Postgres-specific `nodeKind`. */\nexport function postgresNodeEntityKind(nodeKind: PostgresSchemaNodeKind): string | undefined {\n return POSTGRES_NODE_ENTITY_KIND[nodeKind];\n}\n\n/**\n * The storage `entityKind` for any node kind that appears in a Postgres diff\n * tree — sibling of {@link postgresDiffSubjectGranularity}, dispatching the\n * same way to whichever family/target map owns the kind. Called on demand by\n * the framework aggregate's unclaimed-elements sweep via the {@link\n * import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}\n * capability — never stamped onto the issue or the node.\n */\nexport function postgresDiffSubjectEntityKind(nodeKind: string): string | undefined {\n return isPostgresSchemaNodeKind(nodeKind)\n ? postgresNodeEntityKind(nodeKind)\n : relationalNodeEntityKind(nodeKind);\n}\n","import type { ControlPolicy } from '@prisma-next/contract/types';\nimport 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 PostgresNativeEnumSchemaNodeInput {\n /** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */\n readonly typeName: string;\n /** The owning DDL schema name — enum types are schema-scoped. */\n readonly namespaceId: string;\n /** Member values in declaration (`pg_enum.enumsortorder`) order. */\n readonly members: readonly string[];\n /** The contract entity's control grade — expected-side nodes only. */\n readonly control?: ControlPolicy;\n}\n\n/**\n * Schema-diff leaf node for a native Postgres enum type.\n *\n * This is a derived, transient node walked by the differ — it is NEVER\n * serialized. Both sides derive it on the namespace node: the expected side\n * from the contract's hydrated `entries.native_enum` entities, the actual\n * side from the adapter's introspected `nativeEnums`.\n *\n * Enum types are schema-scoped, so identity is (namespace, type name): the\n * namespace coordinate comes from tree position (the differ pairs enum nodes\n * only inside an already-paired namespace) and `id` carries the type name,\n * prefixed with the entries-kind vocabulary (`native_enum:<typeName>`) so it\n * cannot collide with a sibling table of the same name — the same\n * sibling-prefix convention relational column nodes use (`column:<name>`).\n *\n * `isEqualTo` compares members POSITIONALLY — `['a','b'] ≠ ['b','a']` —\n * because Postgres enum sort order is semantic. `control` is contract\n * metadata, not database state, and does not participate in equality.\n */\nexport class PostgresNativeEnumSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.nativeEnum;\n\n readonly typeName: string;\n readonly namespaceId: string;\n readonly members: readonly string[];\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresNativeEnumSchemaNodeInput) {\n super();\n this.typeName = input.typeName;\n this.namespaceId = input.namespaceId;\n this.members = Object.freeze([...input.members]);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get id(): string {\n return `native_enum:${this.typeName}`;\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-enum kinds'\n >(other);\n PostgresNativeEnumSchemaNode.assert(node);\n return (\n this.typeName === node.typeName &&\n this.members.length === node.members.length &&\n this.members.every((member, index) => member === node.members[index])\n );\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresNativeEnumSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.nativeEnum;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresNativeEnumSchemaNode {\n assertNode(node, 'PostgresNativeEnumSchemaNode', PostgresNativeEnumSchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport {\n assertNode,\n PrimaryKey,\n type SqlAnnotations,\n SqlCheckConstraintIR,\n SqlColumnIR,\n SqlForeignKeyIR,\n SqlIndexIR,\n SqlSchemaIRNode,\n type SqlTableIRInput,\n SqlUniqueIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { PostgresPolicySchemaNode } from './postgres-policy-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresTableSchemaNodeInput extends SqlTableIRInput {\n readonly policies?: readonly PostgresPolicySchemaNode[];\n /**\n * Whether row-level security is enabled on this table. Expected side:\n * stamped from the contract's `entries.rls` marker (never from the\n * policy set). Actual side: stamped from `pg_class.relrowsecurity` at\n * introspection. Required with no default so every construction site\n * supplies a deliberate value.\n */\n readonly rlsEnabled: boolean;\n}\n\n/**\n * Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields\n * plus `policies`, and implements `DiffableNode` so the table instance is\n * directly the diff-tree node — no separate wrapper needed.\n *\n * Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because\n * `SqlTableIR` calls `freezeNode` in its own constructor, which prevents\n * subclass field initialisation.\n *\n * `id` is the table name. `isEqualTo` compares id + `rlsEnabled` — the\n * table's one own diffable attribute; all other structural drift is\n * expressed by its children. `children()` returns every column, the primary\n * key (when present), every foreign key, unique, index, and check constraint,\n * plus the policy nodes — one flat list, so a drifted column and a drifted\n * policy are both reported by the same walk. Order is deterministic (object\n * key order for columns, array order for the rest) so two structurally equal\n * tables always produce the same child list.\n */\nexport class PostgresTableSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.table;\n\n readonly name: string;\n readonly columns: Readonly<Record<string, SqlColumnIR>>;\n readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;\n readonly uniques: ReadonlyArray<SqlUniqueIR>;\n readonly indexes: ReadonlyArray<SqlIndexIR>;\n declare readonly primaryKey?: PrimaryKey;\n declare readonly annotations?: SqlAnnotations;\n declare readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;\n readonly policies: readonly PostgresPolicySchemaNode[];\n readonly rlsEnabled: boolean;\n\n constructor(input: PostgresTableSchemaNodeInput) {\n super();\n this.name = input.name;\n this.rlsEnabled = input.rlsEnabled;\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([key, col]) => [\n key,\n col instanceof SqlColumnIR ? col : new SqlColumnIR(col),\n ]),\n ),\n );\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk))),\n );\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u))),\n );\n this.indexes = Object.freeze(\n input.indexes.map((i) => (i instanceof SqlIndexIR ? i : new SqlIndexIR(i))),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n if (input.annotations !== undefined) this.annotations = input.annotations;\n if (input.checks !== undefined && input.checks.length > 0) {\n this.checks = Object.freeze(\n input.checks.map((c) =>\n c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c),\n ),\n );\n }\n this.policies = Object.freeze([...(input.policies ?? [])]);\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n /**\n * Equal iff the ids (names) match AND `rlsEnabled` matches — the table's\n * one own attribute in the diff; all other structural drift is expressed\n * by children. A paired `not-equal` therefore always means enablement\n * drift, which the planner maps to ENABLE/DISABLE ROW LEVEL SECURITY.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n PostgresTableSchemaNode.assert(node);\n return this.id === node.id && this.rlsEnabled === node.rlsEnabled;\n }\n\n children(): readonly DiffableNode[] {\n return [\n ...Object.values(this.columns),\n ...(this.primaryKey ? [this.primaryKey] : []),\n ...this.foreignKeys,\n ...this.uniques,\n ...this.indexes,\n ...(this.checks ?? []),\n ...this.policies,\n ];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresTableSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.table;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresTableSchemaNode {\n assertNode(node, 'PostgresTableSchemaNode', PostgresTableSchemaNode.is);\n }\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { OpFactoryCall } from "@prisma-next/framework-components/control";
4
4
  import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";