@prisma-next/target-postgres 0.14.0-dev.8 → 0.14.0-dev.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/dist/authoring-ChmUI_tC.mjs +674 -0
  2. package/dist/authoring-ChmUI_tC.mjs.map +1 -0
  3. package/dist/canonicalize-D1F4vUnP.d.mts +48 -0
  4. package/dist/canonicalize-D1F4vUnP.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-BemGS69L.mjs +927 -0
  15. package/dist/codecs-BemGS69L.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-BfQLCrha.mjs +1285 -0
  26. package/dist/control-policy-BfQLCrha.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-eBZav_MS.mjs} +128 -6
  36. package/dist/ddl-eBZav_MS.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-DAwRBZpA.mjs +23 -0
  44. package/dist/descriptor-meta-DAwRBZpA.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-jsEOfSYT.mjs +305 -0
  48. package/dist/diff-database-schema-jsEOfSYT.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-DJC5B8Id.mjs +192 -0
  68. package/dist/nodes-DJC5B8Id.mjs.map +1 -0
  69. package/dist/nodes-Dv5eCSq9.d.mts +170 -0
  70. package/dist/nodes-Dv5eCSq9.d.mts.map +1 -0
  71. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Bn9zDx4_.d.mts} +114 -15
  72. package/dist/op-factory-call-Bn9zDx4_.d.mts.map +1 -0
  73. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-Dwsb1xzl.mjs} +469 -32
  74. package/dist/op-factory-call-Dwsb1xzl.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 +321 -3
  78. package/dist/pack.d.mts.map +1 -1
  79. package/dist/pack.mjs +1 -1
  80. package/dist/planner-ChCtpEGe.mjs +390 -0
  81. package/dist/planner-ChCtpEGe.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-QqHa2C2l.d.mts → planner-produced-postgres-migration-BEY1T0Xm.d.mts} +4 -4
  92. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-BEY1T0Xm.d.mts.map} +1 -1
  93. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-Bb16yHNX.mjs} +3 -3
  94. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-Bb16yHNX.mjs.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-Cx0ATsPc.mjs} +5 -5
  98. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-Cx0ATsPc.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-BiDhl5Ez.mjs} +45 -41
  109. package/dist/postgres-contract-view-BiDhl5Ez.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-Cj5Tpj1a.mjs} +78 -45
  115. package/dist/postgres-migration-Cj5Tpj1a.mjs.map +1 -0
  116. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DbckK1su.d.mts} +58 -9
  117. package/dist/postgres-migration-DbckK1su.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-COGZ1ark.mjs → postgres-schema-ChBj22nX.mjs} +200 -11
  125. package/dist/postgres-schema-ChBj22nX.mjs.map +1 -0
  126. package/dist/postgres-schema-DKq6s1P3.d.mts +269 -0
  127. package/dist/postgres-schema-DKq6s1P3.d.mts.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-BCSMHFwl.mjs +22 -0
  135. package/dist/resolve-ddl-schema-BCSMHFwl.mjs.map +1 -0
  136. package/dist/rls-canonicalize.d.mts +27 -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-DbQ9-2RC.mjs +104 -0
  154. package/dist/wire-name-DbQ9-2RC.mjs.map +1 -0
  155. package/package.json +26 -20
  156. package/src/contract-free/checks.ts +153 -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 +726 -2
  160. package/src/core/codec-helpers.ts +33 -7
  161. package/src/core/codec-ids.ts +1 -0
  162. package/src/core/codec-type-map.ts +2 -0
  163. package/src/core/codecs.ts +193 -12
  164. package/src/core/ddl/nodes.ts +185 -2
  165. package/src/core/default-normalizer.ts +122 -2
  166. package/src/core/descriptor-meta.ts +12 -1
  167. package/src/core/entity-kinds.ts +41 -0
  168. package/src/core/errors.ts +14 -12
  169. package/src/core/migrations/bound-schema.ts +10 -0
  170. package/src/core/migrations/column-ddl-rendering.ts +117 -0
  171. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +189 -0
  172. package/src/core/migrations/control-policy.ts +217 -65
  173. package/src/core/migrations/diff-database-schema.ts +252 -0
  174. package/src/core/migrations/issue-planner.ts +817 -656
  175. package/src/core/migrations/op-factory-call.ts +383 -23
  176. package/src/core/migrations/operations/columns.ts +24 -12
  177. package/src/core/migrations/operations/constraints.ts +1 -1
  178. package/src/core/migrations/operations/data-transform.ts +6 -0
  179. package/src/core/migrations/operations/dependencies.ts +2 -1
  180. package/src/core/migrations/operations/native-enum-types.ts +62 -0
  181. package/src/core/migrations/operations/rls.ts +187 -0
  182. package/src/core/migrations/operations/shared.ts +0 -30
  183. package/src/core/migrations/planner-ddl-builders.ts +31 -59
  184. package/src/core/migrations/planner-identity-values.ts +1 -1
  185. package/src/core/migrations/planner-recipes.ts +31 -13
  186. package/src/core/migrations/planner-sql-checks.ts +1 -1
  187. package/src/core/migrations/planner-strategies.ts +248 -216
  188. package/src/core/migrations/planner-target-details.ts +3 -1
  189. package/src/core/migrations/planner.ts +357 -67
  190. package/src/core/migrations/postgres-migration.ts +118 -86
  191. package/src/core/migrations/render-typescript.ts +42 -15
  192. package/src/core/migrations/resolve-ddl-schema.ts +26 -0
  193. package/src/core/migrations/runner.ts +11 -16
  194. package/src/core/migrations/verify-postgres-namespaces.ts +46 -31
  195. package/src/core/namespace-ids.ts +3 -0
  196. package/src/core/postgres-contract-serializer.ts +46 -71
  197. package/src/core/postgres-contract-view.ts +48 -0
  198. package/src/core/postgres-native-enum.ts +61 -0
  199. package/src/core/postgres-rls-enablement.ts +34 -0
  200. package/src/core/postgres-rls-policy.ts +64 -0
  201. package/src/core/postgres-role.ts +59 -0
  202. package/src/core/postgres-schema-verifier.ts +10 -7
  203. package/src/core/postgres-schema.ts +85 -15
  204. package/src/core/postgres-validators.ts +34 -0
  205. package/src/core/psl-infer/infer-psl-contract.ts +1273 -0
  206. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  207. package/src/core/psl-infer/postgres-type-map.ts +128 -0
  208. package/src/core/rls/canonicalize.ts +65 -0
  209. package/src/core/rls/wire-name.ts +33 -0
  210. package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
  211. package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
  212. package/src/core/schema-ir/postgres-namespace-schema-node.ts +70 -0
  213. package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
  214. package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
  215. package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
  216. package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
  217. package/src/core/schema-ir/schema-node-kinds.ts +122 -0
  218. package/src/core/sql-utils.ts +15 -2
  219. package/src/exports/codecs.ts +3 -0
  220. package/src/exports/contract-free.ts +11 -1
  221. package/src/exports/control.ts +27 -33
  222. package/src/exports/ddl.ts +8 -0
  223. package/src/exports/diff-database-schema.ts +7 -0
  224. package/src/exports/issue-planner.ts +1 -1
  225. package/src/exports/migration.ts +1 -0
  226. package/src/exports/op-factory-call.ts +4 -0
  227. package/src/exports/planner-ddl-builders.ts +0 -2
  228. package/src/exports/planner-identity-values.ts +4 -1
  229. package/src/exports/planner.ts +1 -0
  230. package/src/exports/rls-canonicalize.ts +12 -0
  231. package/src/exports/runtime.ts +1 -0
  232. package/src/exports/schema-ir-annotations.ts +1 -0
  233. package/src/exports/sql-utils.ts +1 -0
  234. package/src/exports/types.ts +37 -0
  235. package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
  236. package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
  237. package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
  238. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  239. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  240. package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
  241. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  242. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  243. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  244. package/dist/errors-CUk87ByX.mjs +0 -33
  245. package/dist/errors-CUk87ByX.mjs.map +0 -1
  246. package/dist/issue-planner-DL6g3CmE.mjs +0 -824
  247. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  248. package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
  249. package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
  250. package/dist/nodes-Bbhs2rwj.mjs +0 -76
  251. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  252. package/dist/nodes-pLeLgdis.d.mts +0 -67
  253. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  254. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  255. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  256. package/dist/planner-Bs_baQax.mjs +0 -324
  257. package/dist/planner-Bs_baQax.mjs.map +0 -1
  258. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  259. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  260. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  261. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  262. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  263. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  264. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  265. package/dist/types.d.mts.map +0 -1
  266. package/src/core/postgres-enum-type-schema.ts +0 -17
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-ChBj22nX.mjs","names":[],"sources":["../src/core/postgres-rls-enablement.ts","../src/core/postgres-rls-policy.ts","../src/core/postgres-role.ts","../src/core/postgres-validators.ts","../src/core/ast/table-source.ts","../src/core/entity-kinds.ts","../src/core/postgres-schema.ts"],"sourcesContent":["import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresRlsEnablementInput {\n /** Name of the table this marker declares RLS-controlled. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). Markers are schema-scoped like policies. */\n readonly namespaceId: string;\n}\n\n/**\n * Postgres contract-IR marker for `@@rls` on a model: the table named here is\n * RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never\n * by the policy set).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an\n * entity kind, extends `SqlNode`, and is stored in `contract.json` under\n * `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`\n * discriminant is enumerable so it survives JSON serialization; the literal\n * matches the entries key (one-string rule).\n */\nexport class PostgresRlsEnablement extends SqlNode {\n override readonly kind = 'rls' as const;\n readonly tableName: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRlsEnablementInput) {\n super();\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';\n\nexport interface PostgresRlsPolicyInput {\n /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). Policies are schema-scoped. */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n}\n\n/**\n * Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresPolicySchemaNode` for that role.\n *\n * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`\n * discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it\n * survives JSON serialization and enables dispatch. The literal matches the\n * entries key (one-string rule: node.kind === entries key === entity kind).\n */\nexport class PostgresRlsPolicy extends SqlNode {\n override readonly kind = 'policy' as const;\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n\n constructor(input: PostgresRlsPolicyInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\n/**\n * Roles are referenced by the contract but never owned — the framework\n * issues no `CREATE`/`DROP ROLE`, so a role's effective governance is always\n * `external`: a missing declared role fails verify, an extra live role is\n * tolerated, and the planner emits zero role DDL. `external` is the only\n * value a role's control can ever carry.\n */\nexport const ROLE_DEFAULT_CONTROL_POLICY = 'external';\n\nexport interface PostgresRoleInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`\n * from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n /**\n * Defaults to {@link ROLE_DEFAULT_CONTROL_POLICY} when omitted. Roles are\n * referenced but never owned, so `'external'` is the only allowed value.\n */\n readonly control?: 'external';\n}\n\n/**\n * Postgres contract-IR class for a database role (`CREATE ROLE …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresRoleSchemaNode` for that role.\n *\n * Roles are cluster-scoped, so their namespace coordinate is always\n * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.\n * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.\n * The `kind: 'role'` discriminant is enumerable so it survives JSON.\n * Matches the entries key (one-string rule).\n *\n * `control` always carries a value (never omitted): it defaults to\n * {@link ROLE_DEFAULT_CONTROL_POLICY} in the constructor, so both a\n * freshly-authored role and one hydrated from an older `contract.json`\n * lacking the field resolve the same way — the control-policy resolver\n * reads it directly off the entity instead of special-casing role issues.\n */\nexport class PostgresRole extends SqlNode {\n override readonly kind = 'role' as const;\n readonly name: string;\n readonly namespaceId: string;\n readonly control: 'external';\n\n constructor(input: PostgresRoleInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n this.control = input.control ?? ROLE_DEFAULT_CONTROL_POLICY;\n freezeNode(this);\n }\n}\n","import { type } from 'arktype';\n\nexport const PostgresRoleSchema = type({\n kind: \"'role'\",\n name: 'string',\n namespaceId: 'string',\n 'control?': \"'external'\",\n});\n\nexport const PostgresRlsPolicySchema = type({\n kind: \"'policy'\",\n name: 'string',\n prefix: 'string',\n tableName: 'string',\n namespaceId: 'string',\n operation: \"'select' | 'insert' | 'update' | 'delete' | 'all'\",\n roles: type.string.array().readonly(),\n 'using?': 'string',\n 'withCheck?': 'string',\n permissive: 'boolean',\n});\n\nexport const PostgresRlsEnablementSchema = type({\n kind: \"'rls'\",\n tableName: 'string',\n namespaceId: 'string',\n});\n\nexport const PostgresNativeEnumSchema = type({\n kind: \"'postgres-enum'\",\n typeName: 'string',\n members: type.string.array().readonly(),\n 'control?': \"'managed' | 'tolerated' | 'external' | 'observed'\",\n});\n","import {\n type AnyFromSource,\n type AstRewriter,\n TableSource,\n} from '@prisma-next/sql-relational-core/ast';\n\nexport class PostgresTableSource extends TableSource {\n readonly schema: string | undefined;\n\n constructor(options: {\n readonly name: string;\n readonly schema?: string;\n readonly alias?: string;\n }) {\n super(options.name, options.alias);\n this.schema = options.schema;\n this.freeze();\n }\n\n override rewrite(rewriter: AstRewriter): AnyFromSource {\n return rewriter.tableSource ? rewriter.tableSource(this) : this;\n }\n}\n","import type { EntityKindDescriptor } from '@prisma-next/framework-components/ir';\nimport { PostgresNativeEnum, type PostgresNativeEnumInput } from './postgres-native-enum';\nimport { PostgresRlsEnablement, type PostgresRlsEnablementInput } from './postgres-rls-enablement';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsEnablementSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\n\nexport const policyEntityKind: EntityKindDescriptor<PostgresRlsPolicyInput, PostgresRlsPolicy> = {\n kind: 'policy',\n schema: PostgresRlsPolicySchema,\n construct: (input) => new PostgresRlsPolicy(input),\n};\n\nexport const roleEntityKind: EntityKindDescriptor<PostgresRoleInput, PostgresRole> = {\n kind: 'role',\n schema: PostgresRoleSchema,\n construct: (input) => new PostgresRole(input),\n};\n\nexport const rlsEnablementEntityKind: EntityKindDescriptor<\n PostgresRlsEnablementInput,\n PostgresRlsEnablement\n> = {\n kind: 'rls',\n schema: PostgresRlsEnablementSchema,\n construct: (input) => new PostgresRlsEnablement(input),\n};\n\nexport const nativeEnumEntityKind: EntityKindDescriptor<\n PostgresNativeEnumInput,\n PostgresNativeEnum\n> = {\n kind: 'native_enum',\n schema: PostgresNativeEnumSchema,\n construct: (input) => new PostgresNativeEnum(input),\n};\n","import type { Contract } from '@prisma-next/contract/types';\nimport {\n freezeNode,\n hydrateNamespaceEntities,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { composeSqlEntityKinds } from '@prisma-next/sql-contract/entity-kinds';\nimport {\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceInput,\n type SqlStorage,\n type StorageTable,\n type StorageValueSet,\n} from '@prisma-next/sql-contract/types';\n\nimport { type CfExpr, cfExpr } from '@prisma-next/sql-relational-core/contract-free';\nimport { invariant } from '@prisma-next/utils/assertions';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PostgresTableSource } from './ast/table-source';\nimport { PG_TEXT_CODEC_ID } from './codec-ids';\nimport {\n nativeEnumEntityKind,\n policyEntityKind,\n rlsEnablementEntityKind,\n roleEntityKind,\n} from './entity-kinds';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport type { PostgresRlsEnablement } from './postgres-rls-enablement';\nimport type { PostgresRlsPolicy } from './postgres-rls-policy';\nimport type { PostgresRole } from './postgres-role';\nimport { escapeLiteral } from './sql-utils';\n\nexport type PostgresContract = Contract<SqlStorage> & { readonly target: 'postgres' };\n\nexport type PostgresNamespaceEntries = SqlNamespaceEntries & {\n readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;\n readonly role?: Readonly<Record<string, PostgresRole>>;\n readonly rls?: Readonly<Record<string, PostgresRlsEnablement>>;\n readonly native_enum?: Readonly<Record<string, PostgresNativeEnum>>;\n};\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends SqlNamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: PostgresNamespaceEntries;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n composeSqlEntityKinds([\n policyEntityKind,\n roleEntityKind,\n rlsEnablementEntityKind,\n nativeEnumEntityKind,\n ]),\n 'carry',\n );\n\n // A native enum keys under its PHYSICAL type name in storage `entries`\n // (ADR 221 coordinate `entityName`). The family/authoring layer keys every\n // block by its author handle, so re-key the `native_enum` slot by each\n // entity's `typeName` here — target-local Postgres code that already knows\n // this entity kind. This runs at both authoring and hydration; a serialized\n // contract's key already equals the `typeName`, so the re-key is idempotent.\n const nativeEnumSlot = dispatched['native_enum'];\n if (nativeEnumSlot !== undefined) {\n const rekeyed: Record<string, unknown> = {};\n for (const [handle, entity] of Object.entries(nativeEnumSlot)) {\n const physicalName = PostgresNativeEnum.is(entity) ? entity.typeName : handle;\n invariant(\n !Object.hasOwn(rekeyed, physicalName),\n `PostgresSchema \"${input.id}\": two native_enum entities resolve to the same physical type name \"${physicalName}\". Give them distinct @@map type names.`,\n );\n rekeyed[physicalName] = entity;\n }\n dispatched['native_enum'] = Object.freeze(rekeyed);\n }\n\n // Drop an empty valueSet so presence signals non-emptiness.\n const valueSetRaw = dispatched['valueSet'];\n const withPresence =\n valueSetRaw !== undefined && Object.keys(valueSetRaw).length === 0\n ? { ...dispatched, valueSet: undefined }\n : dispatched;\n\n const entriesInput: Record<string, Readonly<Record<string, unknown>> | undefined> = {\n ...withPresence,\n };\n\n this.entries = Object.freeze(\n blindCast<\n PostgresNamespaceEntries,\n 'composeSqlEntityKinds([policyEntityKind, roleEntityKind, rlsEnablementEntityKind, nativeEnumEntityKind]) supplies table→StorageTable, valueSet→StorageValueSet, policy→PostgresRlsPolicy, role→PostgresRole, rls→PostgresRlsEnablement, native_enum→PostgresNativeEnum descriptors'\n >(entriesInput),\n );\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined {\n return this.entries.valueSet;\n }\n\n get policy(): Readonly<Record<string, PostgresRlsPolicy>> {\n return this.entries.policy ?? Object.freeze({});\n }\n\n get role(): Readonly<Record<string, PostgresRole>> {\n return this.entries.role ?? Object.freeze({});\n }\n\n get rls(): Readonly<Record<string, PostgresRlsEnablement>> {\n return this.entries.rls ?? Object.freeze({});\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a\n * builder-built catalog check compares `n.nspname` / `table_schema`\n * against. Named schemas bind the schema name as a text parameter; the\n * unbound singleton overrides this to the opaque `current_schema()`\n * expression so the live connection's `search_path` decides at runtime.\n */\n schemaFilterExpression(): CfExpr {\n return cfExpr.param(this.id, PG_TEXT_CODEC_ID);\n }\n\n /**\n * Typed-AST counterpart of {@link qualifyTable}: the FROM source a\n * builder-built check uses to address a user table in this namespace.\n * Named schemas qualify (`\"schema\".\"table\"`); the unbound singleton\n * overrides this to leave the table unqualified so `search_path`\n * resolves it at runtime.\n */\n tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n schema: this.id,\n ...ifDefined('alias', alias),\n });\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` route through the polymorphic\n * `PostgresUnboundSchema` overrides and produce unqualified\n * (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`\n * route through the polymorphic factory and produce unqualified output\n * automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n\n override schemaFilterExpression(): CfExpr {\n return cfExpr.raw('current_schema()', { codecId: PG_TEXT_CODEC_ID, nullable: false });\n }\n\n override tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n ...ifDefined('alias', alias),\n });\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set. Native-enum column type names are\n * schema-qualified earlier, at column construction, via the target's\n * `authoring.qualifyColumnType` hook (`postgresQualifyColumnType`), so this\n * factory just materialises the namespace from already-qualified entries.\n */\nexport function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n ...input.entries,\n table: input.entries['table'] ?? {},\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,wBAAb,cAA2C,QAAQ;CACjD,OAAyB;CACzB;CACA;CAEA,YAAY,OAAmC;EAC7C,MAAM;EACN,KAAK,YAAY,MAAM;EACvB,KAAK,cAAc,MAAM;EACzB,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;ACKA,IAAa,oBAAb,cAAuC,QAAQ;CAC7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B;EACvC,MAAM,SAAS;GAAE,IAAI;GAAsB,SAAS,EAAE,OAAO,CAAC,EAAE;EAAE,CAAC;CACrE;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;CAEA,yBAA0C;EACxC,OAAO,OAAO,IAAI,oBAAoB;GAAE,SAAS;GAAkB,UAAU;EAAM,CAAC;CACtF;CAEA,YAAqB,WAAmB,OAAqC;EAC3E,OAAO,IAAI,oBAAoB;GAC7B,MAAM;GACN,GAAG,UAAU,SAAS,KAAK;EAC7B,CAAC;CACH;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;;;;AAgBA,SAAgB,wBAAwB,OAA0C;CAChF,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,GAAG,MAAM;GACT,OAAO,MAAM,QAAQ,YAAY,CAAC;EACpC;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
@@ -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/core/postgres-role.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;UAKiB,uBAAA;;WAEN,QAAA;;WAEA,OAAA,EAAS,OAAA;EAAA,SACT,OAAA,GAAU,aAAa;AAAA;;;;;;;;;;AAAA;AA6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raintIR, 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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AAA,GAAW,KAAK,cAAc,MAAM;EAC9D,IAAI,MAAM,WAAW,KAAA,KAAa,MAAM,OAAO,SAAS,GACtD,KAAK,SAAS,OAAO,OACnB,MAAM,OAAO,KAAK,MAChB,aAAa,uBAAuB,IAAI,IAAI,qBAAqB,CAAC,CACpE,CACF;EAEF,KAAK,WAAW,OAAO,OAAO,CAAC,GAAI,MAAM,YAAY,CAAC,CAAE,CAAC;EACzD,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;;;;;;;CAQA,UAAU,OAA8B;EACtC,MAAM,OAAO,UAGX,KAAK;EACP,wBAAwB,OAAO,IAAI;EACnC,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,eAAe,KAAK;CACzD;CAEA,WAAoC;EAClC,OAAO;GACL,GAAG,OAAO,OAAO,KAAK,OAAO;GAC7B,GAAI,KAAK,aAAa,CAAC,KAAK,UAAU,IAAI,CAAC;GAC3C,GAAG,KAAK;GACR,GAAG,KAAK;GACR,GAAG,KAAK;GACR,GAAI,KAAK,UAAU,CAAC;GACpB,GAAG,KAAK;EACV;CACF;CAEA,OAAO,GAAG,MAAwD;EAChE,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAAgE;EAC5E,WAAW,MAAM,2BAA2B,wBAAwB,EAAE;CACxE;AACF"}
@@ -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";