@prisma-next/target-postgres 0.14.0-dev.6 → 0.14.0-dev.61

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 (253) hide show
  1. package/dist/authoring-BLkL4fFG.mjs +528 -0
  2. package/dist/authoring-BLkL4fFG.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-CkVQrZ4G.mjs +913 -0
  15. package/dist/codecs-CkVQrZ4G.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 +4 -4
  24. package/dist/control-policy-BpmChlAK.mjs +1151 -0
  25. package/dist/control-policy-BpmChlAK.mjs.map +1 -0
  26. package/dist/control.d.mts +2 -2
  27. package/dist/control.d.mts.map +1 -1
  28. package/dist/control.mjs +901 -35
  29. package/dist/control.mjs.map +1 -1
  30. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  31. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
  32. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
  33. package/dist/data-transform.d.mts +1 -1
  34. package/dist/{ddl-QDyOSeLc.mjs → ddl-BovUVFVi.mjs} +77 -6
  35. package/dist/ddl-BovUVFVi.mjs.map +1 -0
  36. package/dist/ddl.d.mts +3 -2
  37. package/dist/ddl.mjs +2 -2
  38. package/dist/default-normalizer.d.mts +1 -1
  39. package/dist/default-normalizer.d.mts.map +1 -1
  40. package/dist/default-normalizer.mjs +247 -1
  41. package/dist/default-normalizer.mjs.map +1 -0
  42. package/dist/descriptor-meta-C1T4BXJ8.mjs +22 -0
  43. package/dist/descriptor-meta-C1T4BXJ8.mjs.map +1 -0
  44. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
  45. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
  46. package/dist/diff-database-schema-RMwnSOnz.mjs +298 -0
  47. package/dist/diff-database-schema-RMwnSOnz.mjs.map +1 -0
  48. package/dist/diff-database-schema.d.mts +46 -0
  49. package/dist/diff-database-schema.d.mts.map +1 -0
  50. package/dist/diff-database-schema.mjs +2 -0
  51. package/dist/errors-DO-w0EUS.mjs +35 -0
  52. package/dist/errors-DO-w0EUS.mjs.map +1 -0
  53. package/dist/errors.d.mts +11 -9
  54. package/dist/errors.d.mts.map +1 -1
  55. package/dist/errors.mjs +1 -1
  56. package/dist/issue-planner.d.mts +35 -11
  57. package/dist/issue-planner.d.mts.map +1 -1
  58. package/dist/issue-planner.mjs +2 -2
  59. package/dist/migration.d.mts +5 -5
  60. package/dist/migration.d.mts.map +1 -1
  61. package/dist/migration.mjs +4 -4
  62. package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
  63. package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
  64. package/dist/native-type-normalizer.mjs +37 -1
  65. package/dist/native-type-normalizer.mjs.map +1 -0
  66. package/dist/nodes-B815pj_X.mjs +162 -0
  67. package/dist/nodes-B815pj_X.mjs.map +1 -0
  68. package/dist/nodes-BtQyZha6.d.mts +146 -0
  69. package/dist/nodes-BtQyZha6.d.mts.map +1 -0
  70. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-CI00nS4z.mjs} +300 -31
  71. package/dist/op-factory-call-CI00nS4z.mjs.map +1 -0
  72. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-D6_7-7Vc.d.mts} +68 -15
  73. package/dist/op-factory-call-D6_7-7Vc.d.mts.map +1 -0
  74. package/dist/op-factory-call.d.mts +2 -2
  75. package/dist/op-factory-call.mjs +2 -2
  76. package/dist/pack.d.mts +287 -3
  77. package/dist/pack.d.mts.map +1 -1
  78. package/dist/pack.mjs +1 -1
  79. package/dist/planner-CAHZN1Ez.mjs +422 -0
  80. package/dist/planner-CAHZN1Ez.mjs.map +1 -0
  81. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  82. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  83. package/dist/planner-ddl-builders.d.mts +4 -6
  84. package/dist/planner-ddl-builders.d.mts.map +1 -1
  85. package/dist/planner-ddl-builders.mjs +2 -2
  86. package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
  87. package/dist/planner-identity-values.d.mts +8 -2
  88. package/dist/planner-identity-values.d.mts.map +1 -1
  89. package/dist/planner-identity-values.mjs +2 -2
  90. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-a-tjfKsA.d.mts} +4 -4
  91. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-a-tjfKsA.d.mts.map} +1 -1
  92. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-flkG4Y7n.mjs} +3 -3
  93. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-flkG4Y7n.mjs.map} +1 -1
  94. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  95. package/dist/planner-produced-postgres-migration.mjs +1 -1
  96. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-C1-Kk3Eu.mjs} +2 -2
  97. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-C1-Kk3Eu.mjs.map} +1 -1
  98. package/dist/planner-sql-checks.d.mts +2 -2
  99. package/dist/planner-sql-checks.d.mts.map +1 -1
  100. package/dist/planner-sql-checks.mjs +1 -1
  101. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  102. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  103. package/dist/planner-target-details.d.mts +1 -1
  104. package/dist/planner.d.mts +72 -17
  105. package/dist/planner.d.mts.map +1 -1
  106. package/dist/planner.mjs +3 -2
  107. package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
  108. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
  109. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-DWLNQbdR.mjs} +45 -41
  110. package/dist/postgres-contract-view-DWLNQbdR.mjs.map +1 -0
  111. package/dist/postgres-database-schema-node-BVdOffjC.d.mts +221 -0
  112. package/dist/postgres-database-schema-node-BVdOffjC.d.mts.map +1 -0
  113. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-Bzzi0Asr.d.mts} +28 -9
  114. package/dist/postgres-migration-Bzzi0Asr.d.mts.map +1 -0
  115. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-C92swCzd.mjs} +53 -45
  116. package/dist/postgres-migration-C92swCzd.mjs.map +1 -0
  117. package/dist/postgres-native-enum-xdiqmBf_.mjs +41 -0
  118. package/dist/postgres-native-enum-xdiqmBf_.mjs.map +1 -0
  119. package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
  120. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  121. package/dist/postgres-role-schema-node-BmCboEa_.mjs +198 -0
  122. package/dist/postgres-role-schema-node-BmCboEa_.mjs.map +1 -0
  123. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-COEca21H.mjs} +188 -10
  124. package/dist/postgres-schema-COEca21H.mjs.map +1 -0
  125. package/dist/postgres-schema-DsrtYp2v.d.mts +269 -0
  126. package/dist/postgres-schema-DsrtYp2v.d.mts.map +1 -0
  127. package/dist/postgres-table-schema-node-9FCtCUz2.mjs +153 -0
  128. package/dist/postgres-table-schema-node-9FCtCUz2.mjs.map +1 -0
  129. package/dist/render-ops.d.mts +1 -1
  130. package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
  131. package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
  132. package/dist/render-typescript.mjs +1 -1
  133. package/dist/resolve-ddl-schema-ZkKxt2Fm.mjs +22 -0
  134. package/dist/resolve-ddl-schema-ZkKxt2Fm.mjs.map +1 -0
  135. package/dist/rls-canonicalize.d.mts +20 -0
  136. package/dist/rls-canonicalize.d.mts.map +1 -0
  137. package/dist/rls-canonicalize.mjs +2 -0
  138. package/dist/runtime.d.mts +6 -8
  139. package/dist/runtime.d.mts.map +1 -1
  140. package/dist/runtime.mjs +3 -3
  141. package/dist/runtime.mjs.map +1 -1
  142. package/dist/schema-ir-annotations.d.mts +15 -0
  143. package/dist/schema-ir-annotations.d.mts.map +1 -0
  144. package/dist/schema-ir-annotations.mjs +2 -0
  145. package/dist/types.d.mts +4 -140
  146. package/dist/types.mjs +5 -2
  147. package/dist/wire-name-rHHtr1h0.mjs +75 -0
  148. package/dist/wire-name-rHHtr1h0.mjs.map +1 -0
  149. package/package.json +23 -17
  150. package/src/contract-free/checks.ts +73 -0
  151. package/src/contract-free/ddl.ts +71 -1
  152. package/src/core/authoring.ts +467 -2
  153. package/src/core/codec-ids.ts +1 -0
  154. package/src/core/codec-type-map.ts +2 -0
  155. package/src/core/codecs.ts +180 -1
  156. package/src/core/ddl/nodes.ts +141 -2
  157. package/src/core/default-normalizer.ts +122 -2
  158. package/src/core/descriptor-meta.ts +10 -1
  159. package/src/core/entity-kinds.ts +41 -0
  160. package/src/core/errors.ts +14 -12
  161. package/src/core/migrations/bound-schema.ts +10 -0
  162. package/src/core/migrations/column-ddl-rendering.ts +117 -0
  163. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +160 -0
  164. package/src/core/migrations/control-policy.ts +126 -44
  165. package/src/core/migrations/diff-database-schema.ts +253 -0
  166. package/src/core/migrations/issue-planner.ts +692 -652
  167. package/src/core/migrations/op-factory-call.ts +189 -21
  168. package/src/core/migrations/operations/columns.ts +24 -12
  169. package/src/core/migrations/operations/constraints.ts +1 -1
  170. package/src/core/migrations/operations/data-transform.ts +6 -0
  171. package/src/core/migrations/operations/dependencies.ts +2 -1
  172. package/src/core/migrations/operations/rls.ts +187 -0
  173. package/src/core/migrations/operations/shared.ts +0 -30
  174. package/src/core/migrations/planner-ddl-builders.ts +20 -58
  175. package/src/core/migrations/planner-identity-values.ts +1 -1
  176. package/src/core/migrations/planner-recipes.ts +31 -13
  177. package/src/core/migrations/planner-sql-checks.ts +1 -1
  178. package/src/core/migrations/planner-strategies.ts +248 -216
  179. package/src/core/migrations/planner-target-details.ts +3 -1
  180. package/src/core/migrations/planner.ts +386 -59
  181. package/src/core/migrations/postgres-migration.ts +70 -86
  182. package/src/core/migrations/render-typescript.ts +42 -15
  183. package/src/core/migrations/resolve-ddl-schema.ts +26 -0
  184. package/src/core/migrations/runner.ts +10 -16
  185. package/src/core/migrations/verify-postgres-namespaces.ts +47 -31
  186. package/src/core/namespace-ids.ts +3 -0
  187. package/src/core/postgres-contract-serializer.ts +46 -71
  188. package/src/core/postgres-contract-view.ts +48 -0
  189. package/src/core/postgres-native-enum.ts +51 -0
  190. package/src/core/postgres-rls-enablement.ts +34 -0
  191. package/src/core/postgres-rls-policy.ts +64 -0
  192. package/src/core/postgres-role.ts +59 -0
  193. package/src/core/postgres-schema-verifier.ts +10 -7
  194. package/src/core/postgres-schema.ts +64 -15
  195. package/src/core/postgres-validators.ts +34 -0
  196. package/src/core/psl-infer/infer-psl-contract.ts +1326 -0
  197. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  198. package/src/core/psl-infer/postgres-type-map.ts +128 -0
  199. package/src/core/rls/canonicalize.ts +48 -0
  200. package/src/core/rls/wire-name.ts +33 -0
  201. package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
  202. package/src/core/schema-ir/postgres-namespace-schema-node.ts +79 -0
  203. package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
  204. package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
  205. package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
  206. package/src/core/schema-ir/schema-node-kinds.ts +113 -0
  207. package/src/exports/codecs.ts +3 -0
  208. package/src/exports/contract-free.ts +11 -1
  209. package/src/exports/control.ts +27 -33
  210. package/src/exports/ddl.ts +6 -0
  211. package/src/exports/diff-database-schema.ts +7 -0
  212. package/src/exports/issue-planner.ts +1 -1
  213. package/src/exports/migration.ts +1 -0
  214. package/src/exports/op-factory-call.ts +1 -0
  215. package/src/exports/planner-ddl-builders.ts +0 -2
  216. package/src/exports/planner-identity-values.ts +4 -1
  217. package/src/exports/planner.ts +1 -0
  218. package/src/exports/rls-canonicalize.ts +7 -0
  219. package/src/exports/runtime.ts +1 -0
  220. package/src/exports/schema-ir-annotations.ts +1 -0
  221. package/src/exports/types.ts +34 -0
  222. package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
  223. package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
  224. package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
  225. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  226. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  227. package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
  228. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  229. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  230. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  231. package/dist/errors-CUk87ByX.mjs +0 -33
  232. package/dist/errors-CUk87ByX.mjs.map +0 -1
  233. package/dist/issue-planner-DL6g3CmE.mjs +0 -824
  234. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  235. package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
  236. package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
  237. package/dist/nodes-Bbhs2rwj.mjs +0 -76
  238. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  239. package/dist/nodes-pLeLgdis.d.mts +0 -67
  240. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  241. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  242. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  243. package/dist/planner-Bs_baQax.mjs +0 -324
  244. package/dist/planner-Bs_baQax.mjs.map +0 -1
  245. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  246. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  247. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  248. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  249. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  250. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  251. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  252. package/dist/types.d.mts.map +0 -1
  253. package/src/core/postgres-enum-type-schema.ts +0 -17
@@ -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-role.d.ts
8
+ interface PostgresRoleInput {
9
+ readonly name: string;
10
+ /**
11
+ * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`
12
+ * from `@prisma-next/framework-components/ir`.
13
+ */
14
+ readonly namespaceId: string;
15
+ /**
16
+ * Defaults to {@link ROLE_DEFAULT_CONTROL_POLICY} when omitted. Roles are
17
+ * referenced but never owned, so `'external'` is the only allowed value.
18
+ */
19
+ readonly control?: 'external';
20
+ }
21
+ /**
22
+ * Postgres contract-IR class for a database role (`CREATE ROLE …`).
23
+ *
24
+ * This is an authored, serialized Contract-IR entity — it is registered as an entity
25
+ * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
26
+ * the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
27
+ *
28
+ * Roles are cluster-scoped, so their namespace coordinate is always
29
+ * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
30
+ * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
31
+ * The `kind: 'role'` discriminant is enumerable so it survives JSON.
32
+ * Matches the entries key (one-string rule).
33
+ *
34
+ * `control` always carries a value (never omitted): it defaults to
35
+ * {@link ROLE_DEFAULT_CONTROL_POLICY} in the constructor, so both a
36
+ * freshly-authored role and one hydrated from an older `contract.json`
37
+ * lacking the field resolve the same way — the control-policy resolver
38
+ * reads it directly off the entity instead of special-casing role issues.
39
+ */
40
+ declare class PostgresRole extends SqlNode {
41
+ readonly kind: "role";
42
+ readonly name: string;
43
+ readonly namespaceId: string;
44
+ readonly control: 'external';
45
+ constructor(input: PostgresRoleInput);
46
+ }
47
+ //#endregion
48
+ //#region src/core/postgres-rls-enablement.d.ts
49
+ interface PostgresRlsEnablementInput {
50
+ /** Name of the table this marker declares RLS-controlled. */
51
+ readonly tableName: string;
52
+ /** Namespace coordinate (schema name). Markers are schema-scoped like policies. */
53
+ readonly namespaceId: string;
54
+ }
55
+ /**
56
+ * Postgres contract-IR marker for `@@rls` on a model: the table named here is
57
+ * RLS-controlled (`ENABLE ROW LEVEL SECURITY` is driven by this marker, never
58
+ * by the policy set).
59
+ *
60
+ * This is an authored, serialized Contract-IR entity — it is registered as an
61
+ * entity kind, extends `SqlNode`, and is stored in `contract.json` under
62
+ * `entries.rls[tableName]`. Target-only concept — no SQL-family abstract.
63
+ * Frozen at construction via `freezeNode(this)`. The `kind: 'rls'`
64
+ * discriminant is enumerable so it survives JSON serialization; the literal
65
+ * matches the entries key (one-string rule).
66
+ */
67
+ declare class PostgresRlsEnablement extends SqlNode {
68
+ readonly kind: "rls";
69
+ readonly tableName: string;
70
+ readonly namespaceId: string;
71
+ constructor(input: PostgresRlsEnablementInput);
72
+ }
73
+ //#endregion
74
+ //#region src/core/postgres-native-enum.d.ts
75
+ interface PostgresNativeEnumInput {
76
+ /** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
77
+ readonly typeName: string;
78
+ /** Member values in declaration order — this is the Postgres enum sort order. */
79
+ readonly members: readonly string[];
80
+ readonly control?: ControlPolicy;
81
+ }
82
+ /**
83
+ * Postgres contract-IR class for a native enum type (`CREATE TYPE … AS ENUM (…)`).
84
+ *
85
+ * This is an authored, serialized Contract-IR entity — it is registered as an entity
86
+ * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
87
+ * the schema-diff tree will use `PostgresNativeEnumSchemaNode` when the managed phase
88
+ * builds it.
89
+ *
90
+ * A member is a value, not a name→value pair — matching `CREATE TYPE … AS ENUM
91
+ * ('a', 'b')`, which has no separate member name.
92
+ *
93
+ * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly,
94
+ * frozen at construction via `freezeNode(this)`. The `kind: 'postgres-enum'`
95
+ * discriminant is enumerable so it survives JSON. Lives at
96
+ * `storage.namespaces[ns].entries.native_enum[HandleName]`; the entries key
97
+ * (`native_enum`) is the entity-kind descriptor's `kind`, decoupled from this
98
+ * node's own `kind` literal — the same shape as `table`/`StorageTable` and
99
+ * `valueSet`/`StorageValueSet`.
100
+ */
101
+ declare class PostgresNativeEnum extends SqlNode {
102
+ static is(node: unknown): node is PostgresNativeEnum;
103
+ readonly kind: "postgres-enum";
104
+ readonly typeName: string;
105
+ readonly members: readonly string[];
106
+ readonly control?: ControlPolicy;
107
+ constructor(input: PostgresNativeEnumInput);
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, PostgresRoleInput as d, isPostgresSchema as i, PostgresRlsEnablementInput as l, PostgresSchema as n, PostgresNativeEnum as o, PostgresUnboundSchema as r, PostgresNativeEnumInput as s, PostgresContract as t, PostgresRole as u };
269
+ //# sourceMappingURL=postgres-schema-DsrtYp2v.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-DsrtYp2v.d.mts","names":[],"sources":["../src/core/postgres-role.ts","../src/core/postgres-rls-enablement.ts","../src/core/postgres-native-enum.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;UAYiB,iBAAA;EAAA,SACN,IAAA;EAAA;;;;EAAA,SAKA,WAAA;EA2BE;;;;EAAA,SAtBF,OAAA;AAAA;;;;;;;;AA4B2B;;;;AChDtC;;;;AAIsB;AAetB;;;cDuBa,YAAA,SAAqB,OAAO;EAAA,SACrB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA;cAEG,KAAA,EAAO,iBAAA;AAAA;;;UChDJ,0BAAA;;WAEN,SAAA;;WAEA,WAAW;AAAA;ADKtB;;;;;;;;AAWkB;AAsBlB;;;AAjCA,cCUa,qBAAA,SAA8B,OAAO;EAAA,SAC9B,IAAA;EAAA,SACT,SAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,0BAAA;AAAA;;;UCvBJ,uBAAA;;WAEN,QAAA;;WAEA,OAAA;EAAA,SACA,OAAA,GAAU,aAAa;AAAA;;;;;;;AFchB;AAsBlB;;;;;;;;;;;;cEda,kBAAA,SAA2B,OAAA;EAAA,OAC/B,EAAA,CAAG,IAAA,YAAgB,IAAA,IAAQ,kBAAA;EAAA,SAMhB,IAAA;EAAA,SACT,QAAA;EAAA,SACA,OAAA;EAAA,SACQ,OAAA,GAAU,aAAA;cAEf,KAAA,EAAO,uBAAA;AAAA;;;KCVT,gBAAA,GAAmB,QAAQ,CAAC,UAAA;EAAA,SAAyB,MAAA;AAAA;AAAA,KAErD,wBAAA,GAA2B,mBAAA;EAAA,SAC5B,MAAA,GAAS,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,SACjC,IAAA,GAAO,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAC/B,GAAA,GAAM,QAAA,CAAS,MAAA,SAAe,qBAAA;EAAA,SAC9B,WAAA,GAAc,QAAA,CAAS,MAAA,SAAe,kBAAA;AAAA;AAAA,UAGhC,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;AAAA;;;;;;;;;AHOf;;;;AChDtC;;cE0Da,cAAA,SAAuB,gBAAA;EFxDzB;AAEW;AAetB;;;;;EAjBW,OEgEF,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,wBAAA;cAEN,KAAA,EAAO,mBAAA;EAAA,IAyCf,KAAA,IAAS,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,IAIjC,QAAA,IAAY,QAAA,CAAS,MAAA,SAAe,eAAA;EAAA,IAIpC,MAAA,IAAU,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,IAIlC,IAAA,IAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,IAIhC,GAAA,IAAO,QAAA,CAAS,MAAA,SAAe,qBAAA;;ADhIrC;;;;ECyIE,SAAA;EDrIS;;;;AACuB;AAsBlC;ECwHE,YAAA,CAAa,SAAA;;;;;;;EAUb,eAAA,CAAgB,IAAA;EDlIsB;;;;;;;;EC8ItC,mBAAA;EDpI2B;;;;;AAEe;;EC6I1C,sBAAA,IAA0B,MAAA;;AAvJ5B;;;;;;EAkKE,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;EAlKqB;AAAA;AAEvE;;;;;;;;;EAmLE,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;;;;;;;;;;;;;;;;;cAwBb,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA;EAIA,sBAAA,IAA0B,MAAA;EAI1B,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;AAAA;;;;;;;;;;iBAmB3C,gBAAA,CAAiB,EAAA,YAAc,EAAA,IAAM,cAAc;;;;;AA5OR;AAiB3D;;;;;;;;;iBA6OgB,uBAAA,CAAwB,KAAA,EAAO,iBAAA,GAAoB,cAAc"}
@@ -0,0 +1,153 @@
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
+ };
18
+ /**
19
+ * The one real map from a Postgres-specific `nodeKind` to the
20
+ * framework-neutral {@link DiffSubjectGranularity} its diff issues carry —
21
+ * resolution is by `nodeKind` equality against this map, never a
22
+ * `nodeKind`-suffix string match and never anything stamped on the node.
23
+ */
24
+ const POSTGRES_NODE_GRANULARITY = {
25
+ [PostgresSchemaNodeKind.database]: "structural",
26
+ [PostgresSchemaNodeKind.namespace]: "namespace",
27
+ [PostgresSchemaNodeKind.table]: "entity",
28
+ [PostgresSchemaNodeKind.policy]: "structural",
29
+ [PostgresSchemaNodeKind.role]: "structural"
30
+ };
31
+ function isPostgresSchemaNodeKind(nodeKind) {
32
+ return Object.hasOwn(POSTGRES_NODE_GRANULARITY, nodeKind);
33
+ }
34
+ /** Looks up the subject granularity for a Postgres-specific `nodeKind`. */
35
+ function postgresNodeGranularity(nodeKind) {
36
+ return POSTGRES_NODE_GRANULARITY[nodeKind];
37
+ }
38
+ /**
39
+ * The subject granularity for any node kind that appears in a Postgres diff
40
+ * tree — the tree mixes Postgres-specific kinds (database/namespace/table/
41
+ * policy/role) with the relational leaf kinds (columns, constraints, indexes,
42
+ * …), so this dispatches to whichever family/target map owns the kind. Called
43
+ * on demand by consumers (the family verdict, the framework aggregate's
44
+ * unclaimed-elements sweep, via the {@link
45
+ * import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}
46
+ * capability) — never stamped onto the issue or the node.
47
+ */
48
+ function postgresDiffSubjectGranularity(nodeKind) {
49
+ return isPostgresSchemaNodeKind(nodeKind) ? postgresNodeGranularity(nodeKind) : relationalNodeGranularity(nodeKind);
50
+ }
51
+ /**
52
+ * The one real map from a Postgres-specific `nodeKind` to its storage
53
+ * `entityKind` — the same vocabulary the contract storage's `entries`
54
+ * dictionary keys use. Only the whole-table kind has an entity of its own;
55
+ * database/namespace/policy/role nodes map to nothing here (a namespace is
56
+ * addressed by id, not by an `entries` kind; policies and roles are
57
+ * structural, never a sibling space's unclaimed entity).
58
+ */
59
+ const POSTGRES_NODE_ENTITY_KIND = { [PostgresSchemaNodeKind.table]: "table" };
60
+ /** Looks up the storage entityKind for a Postgres-specific `nodeKind`. */
61
+ function postgresNodeEntityKind(nodeKind) {
62
+ return POSTGRES_NODE_ENTITY_KIND[nodeKind];
63
+ }
64
+ /**
65
+ * The storage `entityKind` for any node kind that appears in a Postgres diff
66
+ * tree — sibling of {@link postgresDiffSubjectGranularity}, dispatching the
67
+ * same way to whichever family/target map owns the kind. Called on demand by
68
+ * the framework aggregate's unclaimed-elements sweep via the {@link
69
+ * import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable}
70
+ * capability — never stamped onto the issue or the node.
71
+ */
72
+ function postgresDiffSubjectEntityKind(nodeKind) {
73
+ return isPostgresSchemaNodeKind(nodeKind) ? postgresNodeEntityKind(nodeKind) : relationalNodeEntityKind(nodeKind);
74
+ }
75
+ //#endregion
76
+ //#region src/core/schema-ir/postgres-table-schema-node.ts
77
+ /**
78
+ * Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields
79
+ * plus `policies`, and implements `DiffableNode` so the table instance is
80
+ * directly the diff-tree node — no separate wrapper needed.
81
+ *
82
+ * Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because
83
+ * `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
84
+ * subclass field initialisation.
85
+ *
86
+ * `id` is the table name. `isEqualTo` compares id + `rlsEnabled` — the
87
+ * table's one own diffable attribute; all other structural drift is
88
+ * expressed by its children. `children()` returns every column, the primary
89
+ * key (when present), every foreign key, unique, index, and check constraint,
90
+ * plus the policy nodes — one flat list, so a drifted column and a drifted
91
+ * policy are both reported by the same walk. Order is deterministic (object
92
+ * key order for columns, array order for the rest) so two structurally equal
93
+ * tables always produce the same child list.
94
+ */
95
+ var PostgresTableSchemaNode = class PostgresTableSchemaNode extends SqlSchemaIRNode {
96
+ nodeKind = PostgresSchemaNodeKind.table;
97
+ name;
98
+ columns;
99
+ foreignKeys;
100
+ uniques;
101
+ indexes;
102
+ policies;
103
+ rlsEnabled;
104
+ constructor(input) {
105
+ super();
106
+ this.name = input.name;
107
+ this.rlsEnabled = input.rlsEnabled;
108
+ this.columns = Object.freeze(Object.fromEntries(Object.entries(input.columns).map(([key, col]) => [key, col instanceof SqlColumnIR ? col : new SqlColumnIR(col)])));
109
+ this.foreignKeys = Object.freeze(input.foreignKeys.map((fk) => fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk)));
110
+ this.uniques = Object.freeze(input.uniques.map((u) => u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u)));
111
+ this.indexes = Object.freeze(input.indexes.map((i) => i instanceof SqlIndexIR ? i : new SqlIndexIR(i)));
112
+ if (input.primaryKey !== void 0) this.primaryKey = input.primaryKey instanceof PrimaryKey ? input.primaryKey : new PrimaryKey(input.primaryKey);
113
+ if (input.annotations !== void 0) this.annotations = input.annotations;
114
+ if (input.checks !== void 0 && input.checks.length > 0) this.checks = Object.freeze(input.checks.map((c) => c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c)));
115
+ this.policies = Object.freeze([...input.policies ?? []]);
116
+ freezeNode(this);
117
+ }
118
+ get id() {
119
+ return this.name;
120
+ }
121
+ /**
122
+ * Equal iff the ids (names) match AND `rlsEnabled` matches — the table's
123
+ * one own attribute in the diff; all other structural drift is expressed
124
+ * by children. A paired `not-equal` therefore always means enablement
125
+ * drift, which the planner maps to ENABLE/DISABLE ROW LEVEL SECURITY.
126
+ */
127
+ isEqualTo(other) {
128
+ const node = blindCast(other);
129
+ PostgresTableSchemaNode.assert(node);
130
+ return this.id === node.id && this.rlsEnabled === node.rlsEnabled;
131
+ }
132
+ children() {
133
+ return [
134
+ ...Object.values(this.columns),
135
+ ...this.primaryKey ? [this.primaryKey] : [],
136
+ ...this.foreignKeys,
137
+ ...this.uniques,
138
+ ...this.indexes,
139
+ ...this.checks ?? [],
140
+ ...this.policies
141
+ ];
142
+ }
143
+ static is(node) {
144
+ return node.nodeKind === PostgresSchemaNodeKind.table;
145
+ }
146
+ static assert(node) {
147
+ assertNode(node, "PostgresTableSchemaNode", PostgresTableSchemaNode.is);
148
+ }
149
+ };
150
+ //#endregion
151
+ export { postgresDiffSubjectGranularity as i, PostgresSchemaNodeKind as n, postgresDiffSubjectEntityKind as r, PostgresTableSchemaNode as t };
152
+
153
+ //# sourceMappingURL=postgres-table-schema-node-9FCtCUz2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-table-schema-node-9FCtCUz2.mjs","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.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} 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 };\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 one real map from a Postgres-specific `nodeKind` to its storage\n * `entityKind` — the same vocabulary the contract storage's `entries`\n * dictionary keys use. Only the whole-table kind has an entity of its 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 */\nconst POSTGRES_NODE_ENTITY_KIND: Partial<Readonly<Record<PostgresSchemaNodeKind, string>>> = {\n [PostgresSchemaNodeKind.table]: 'table',\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 { 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":";;;;;;;;;;AAyBA,MAAa,yBAAyB;CACpC,UAAU;CACV,WAAW;CACX,OAAO;CACP,QAAQ;CACR,MAAM;AACR;;;;;;;AAWA,MAAM,4BACJ;EACG,uBAAuB,WAAW;EAClC,uBAAuB,YAAY;EACnC,uBAAuB,QAAQ;EAQ/B,uBAAuB,SAAS;EAChC,uBAAuB,OAAO;AACjC;AAEF,SAAS,yBAAyB,UAAsD;CACtF,OAAO,OAAO,OAAO,2BAA2B,QAAQ;AAC1D;;AAGA,SAAgB,wBAAwB,UAA0D;CAChG,OAAO,0BAA0B;AACnC;;;;;;;;;;;AAYA,SAAgB,+BAA+B,UAA0C;CACvF,OAAO,yBAAyB,QAAQ,IACpC,wBAAwB,QAAQ,IAChC,0BAA0B,QAAQ;AACxC;;;;;;;;;AAUA,MAAM,4BAAuF,GAC1F,uBAAuB,QAAQ,QAClC;;AAGA,SAAgB,uBAAuB,UAAsD;CAC3F,OAAO,0BAA0B;AACnC;;;;;;;;;AAUA,SAAgB,8BAA8B,UAAsC;CAClF,OAAO,yBAAyB,QAAQ,IACpC,uBAAuB,QAAQ,IAC/B,yBAAyB,QAAQ;AACvC;;;;;;;;;;;;;;;;;;;;;AChEA,IAAa,0BAAb,MAAa,gCAAgC,gBAAwC;CACnF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CACA;CACA;CAIA;CACA;CAEA,YAAY,OAAqC;EAC/C,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM;EACxB,KAAK,UAAU,OAAO,OACpB,OAAO,YACL,OAAO,QAAQ,MAAM,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CAChD,KACA,eAAe,cAAc,MAAM,IAAI,YAAY,GAAG,CACxD,CAAC,CACH,CACF;EACA,KAAK,cAAc,OAAO,OACxB,MAAM,YAAY,KAAK,OAAQ,cAAc,kBAAkB,KAAK,IAAI,gBAAgB,EAAE,CAAE,CAC9F;EACA,KAAK,UAAU,OAAO,OACpB,MAAM,QAAQ,KAAK,MAAO,aAAa,cAAc,IAAI,IAAI,YAAY,CAAC,CAAE,CAC9E;EACA,KAAK,UAAU,OAAO,OACpB,MAAM,QAAQ,KAAK,MAAO,aAAa,aAAa,IAAI,IAAI,WAAW,CAAC,CAAE,CAC5E;EACA,IAAI,MAAM,eAAe,KAAA,GACvB,KAAK,aACH,MAAM,sBAAsB,aACxB,MAAM,aACN,IAAI,WAAW,MAAM,UAAU;EAEvC,IAAI,MAAM,gBAAgB,KAAA,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";
@@ -27,14 +27,18 @@ const BASE_IMPORTS = [{
27
27
  symbol: "MigrationCLI"
28
28
  }];
29
29
  function renderCallsToTypeScript(calls, meta) {
30
- const imports = buildImports(calls);
30
+ const imports = buildImports(calls, meta);
31
31
  const operationsBody = calls.map((c) => renderCall(c)).join(",\n");
32
+ const hasStart = meta.from !== null;
33
+ const startField = hasStart ? [" override readonly startContractJson = startContract;"] : [];
32
34
  return [
33
35
  shebangLineFor(detectScaffoldRuntime()),
34
36
  imports,
35
37
  "",
36
- "export default class M extends Migration {",
37
- buildDescribeMethod(meta),
38
+ `export default class M extends Migration<${hasStart ? "Start" : "never"}, End> {`,
39
+ ...startField,
40
+ " override readonly endContractJson = endContract;",
41
+ "",
38
42
  " override get operations() {",
39
43
  " return [",
40
44
  indent(operationsBody, 6),
@@ -49,21 +53,46 @@ function renderCallsToTypeScript(calls, meta) {
49
53
  function renderCall(call) {
50
54
  return call.renderTypeScript();
51
55
  }
52
- function buildImports(calls) {
53
- const requirements = [...BASE_IMPORTS];
56
+ function buildImports(calls, meta) {
57
+ const requirements = [...BASE_IMPORTS, ...contractImports(meta)];
54
58
  for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
55
59
  return renderImports(requirements);
56
60
  }
57
- function buildDescribeMethod(meta) {
58
- const lines = [];
59
- lines.push(" override describe() {");
60
- lines.push(" return {");
61
- lines.push(` from: ${JSON.stringify(meta.from)},`);
62
- lines.push(` to: ${JSON.stringify(meta.to)},`);
63
- lines.push(" };");
64
- lines.push(" }");
65
- lines.push("");
66
- return lines.join("\n");
61
+ /**
62
+ * The committed contract-JSON imports the scaffold reads its from/to identity
63
+ * from. `end-contract.json` is always present; `start-contract.json` is added
64
+ * only for a non-baseline migration (`meta.from !== null`). The matching
65
+ * `Contract` type imports (aliased `Start`/`End`) feed the
66
+ * `Migration<Start, End>` generics. Baseline emits `Migration<never, End>` with
67
+ * no start imports — `never` is the honest "no prior contract" Start.
68
+ */
69
+ function contractImports(meta) {
70
+ const reqs = [{
71
+ moduleSpecifier: "./end-contract.json",
72
+ symbol: "endContract",
73
+ kind: "default",
74
+ attributes: { type: "json" }
75
+ }, {
76
+ moduleSpecifier: "./end-contract",
77
+ symbol: "Contract",
78
+ alias: "End",
79
+ typeOnly: true
80
+ }];
81
+ if (meta.from !== null) {
82
+ reqs.push({
83
+ moduleSpecifier: "./start-contract.json",
84
+ symbol: "startContract",
85
+ kind: "default",
86
+ attributes: { type: "json" }
87
+ });
88
+ reqs.push({
89
+ moduleSpecifier: "./start-contract",
90
+ symbol: "Contract",
91
+ alias: "Start",
92
+ typeOnly: true
93
+ });
94
+ }
95
+ return reqs;
67
96
  }
68
97
  function indent(text, spaces) {
69
98
  const pad = " ".repeat(spaces);
@@ -72,4 +101,4 @@ function indent(text, spaces) {
72
101
  //#endregion
73
102
  export { renderCallsToTypeScript as t };
74
103
 
75
- //# sourceMappingURL=render-typescript-KMgosran.mjs.map
104
+ //# sourceMappingURL=render-typescript-7yqILcwr.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-7yqILcwr.mjs","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `OpFactoryCall` renders itself via `renderTypeScript()` and\n * declares its own `importRequirements()`; this file just composes the module\n * source around those contributions. The design mirrors the Mongo target's\n * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required\n * (different factory module specifiers, different base-class name) but the\n * shape is, so future consolidation to a framework-level helper is mechanical.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/postgres/migration` so an authored Postgres\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint:\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `PostgresPlanTargetDetails` and the abstract `targetId`\n * to `'postgres'`, so user-authored migrations don't need to thread\n * target-details or redeclare `targetId`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n * The migration file owns this dependency directly: pulling CLI\n * machinery in at script run time is acceptable because the script's\n * whole purpose is to be invoked from the project that owns the\n * config.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls, meta);\n const operationsBody = calls.map((c) => renderCall(c)).join(',\\n');\n const hasStart = meta.from !== null;\n const startField = hasStart ? [' override readonly startContractJson = startContract;'] : [];\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n `export default class M extends Migration<${hasStart ? 'Start' : 'never'}, End> {`,\n ...startField,\n ' override readonly endContractJson = endContract;',\n '',\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction renderCall(call: OpFactoryCall): string {\n return call.renderTypeScript();\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>, meta: RenderMigrationMeta): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS, ...contractImports(meta)];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\n/**\n * The committed contract-JSON imports the scaffold reads its from/to identity\n * from. `end-contract.json` is always present; `start-contract.json` is added\n * only for a non-baseline migration (`meta.from !== null`). The matching\n * `Contract` type imports (aliased `Start`/`End`) feed the\n * `Migration<Start, End>` generics. Baseline emits `Migration<never, End>` with\n * no start imports — `never` is the honest \"no prior contract\" Start.\n */\nfunction contractImports(meta: RenderMigrationMeta): readonly ImportRequirement[] {\n const reqs: ImportRequirement[] = [\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n { moduleSpecifier: './end-contract', symbol: 'Contract', alias: 'End', typeOnly: true },\n ];\n if (meta.from !== null) {\n reqs.push({\n moduleSpecifier: './start-contract.json',\n symbol: 'startContract',\n kind: 'default',\n attributes: { type: 'json' },\n });\n reqs.push({\n moduleSpecifier: './start-contract',\n symbol: 'Contract',\n alias: 'Start',\n typeOnly: true,\n });\n }\n return reqs;\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAmC,QAAQ;AAAY,GAC1E;CAAE,iBAAiB;CAAmC,QAAQ;AAAe,CAC/E;AAEA,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,OAAO,IAAI;CACxC,MAAM,iBAAiB,MAAM,KAAK,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;CACjE,MAAM,WAAW,KAAK,SAAS;CAC/B,MAAM,aAAa,WAAW,CAAC,wDAAwD,IAAI,CAAC;CAE5F,OAAO;EACL,eAAe,sBAAsB,CAAC;EACtC;EACA;EACA,4CAA4C,WAAW,UAAU,QAAQ;EACzE,GAAG;EACH;EACA;EACA;EACA;EACA,OAAO,gBAAgB,CAAC;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,WAAW,MAA6B;CAC/C,OAAO,KAAK,iBAAiB;AAC/B;AAEA,SAAS,aAAa,OAAqC,MAAmC;CAC5F,MAAM,eAAoC,CAAC,GAAG,cAAc,GAAG,gBAAgB,IAAI,CAAC;CACpF,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,mBAAmB,GACxC,aAAa,KAAK,GAAG;CAGzB,OAAO,cAAc,YAAY;AACnC;;;;;;;;;AAUA,SAAS,gBAAgB,MAAyD;CAChF,MAAM,OAA4B,CAChC;EACE,iBAAiB;EACjB,QAAQ;EACR,MAAM;EACN,YAAY,EAAE,MAAM,OAAO;CAC7B,GACA;EAAE,iBAAiB;EAAkB,QAAQ;EAAY,OAAO;EAAO,UAAU;CAAK,CACxF;CACA,IAAI,KAAK,SAAS,MAAM;EACtB,KAAK,KAAK;GACR,iBAAiB;GACjB,QAAQ;GACR,MAAM;GACN,YAAY,EAAE,MAAM,OAAO;EAC7B,CAAC;EACD,KAAK,KAAK;GACR,iBAAiB;GACjB,QAAQ;GACR,OAAO;GACP,UAAU;EACZ,CAAC;CACH;CACA,OAAO;AACT;AAEA,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,MAAM;CAC7B,OAAO,KACJ,MAAM,IAAI,CAAC,CACX,KAAK,SAAU,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,IAAK,CAAC,CACrD,KAAK,IAAI;AACd"}
@@ -1,2 +1,2 @@
1
- import { t as renderCallsToTypeScript } from "./render-typescript-KMgosran.mjs";
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-7yqILcwr.mjs";
2
2
  export { renderCallsToTypeScript };
@@ -0,0 +1,22 @@
1
+ import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86.mjs";
2
+ import { r as isPostgresSchema } from "./postgres-schema-COEca21H.mjs";
3
+ import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
4
+ //#region src/core/migrations/resolve-ddl-schema.ts
5
+ /**
6
+ * Given the contract's storage and a namespace id, returns the live Postgres
7
+ * DDL schema name that namespace maps to. A named Postgres namespace dispatches
8
+ * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to
9
+ * `DEFAULT_NAMESPACE_ID` (the search-path default for offline planning); a
10
+ * bare object payload (used by some tests) falls back to the namespace id
11
+ * itself.
12
+ */
13
+ function resolveDdlSchemaForNamespaceStorage(storage, namespaceId) {
14
+ if (namespaceId === UNBOUND_NAMESPACE_ID) return DEFAULT_NAMESPACE_ID;
15
+ const namespace = storage.namespaces[namespaceId];
16
+ if (namespace && isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);
17
+ return namespaceId;
18
+ }
19
+ //#endregion
20
+ export { resolveDdlSchemaForNamespaceStorage as t };
21
+
22
+ //# sourceMappingURL=resolve-ddl-schema-ZkKxt2Fm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-ddl-schema-ZkKxt2Fm.mjs","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { DEFAULT_NAMESPACE_ID } from '../namespace-ids';\nimport { isPostgresSchema } from '../postgres-schema';\n\n/**\n * Given the contract's storage and a namespace id, returns the live Postgres\n * DDL schema name that namespace maps to. A named Postgres namespace dispatches\n * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to\n * `DEFAULT_NAMESPACE_ID` (the search-path default for offline planning); a\n * bare object payload (used by some tests) falls back to the namespace id\n * itself.\n */\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return DEFAULT_NAMESPACE_ID;\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,oCACd,SACA,aACQ;CACR,IAAI,gBAAgB,sBAClB,OAAO;CAET,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,aAAa,iBAAiB,SAAS,GACzC,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT"}
@@ -0,0 +1,20 @@
1
+ import { i as normalizePredicate, n as RlsPolicyOperation, r as computeContentHash, t as ContentHashParts } from "./canonicalize-CAbXtVtB.mjs";
2
+
3
+ //#region src/core/rls/wire-name.d.ts
4
+ interface RlsPolicyWireName {
5
+ /** The user-supplied part before the `_<8hex>` suffix. */
6
+ readonly prefix: string;
7
+ /** The 8-lowercase-hex content-hash suffix. */
8
+ readonly hash: string;
9
+ }
10
+ /**
11
+ * Splits an RLS policy wire name (`<prefix>_<8hex>`) into its prefix and
12
+ * content-hash suffix. Returns `undefined` when the name does not follow the
13
+ * wire-name shape (e.g. a policy created outside the toolchain) — callers
14
+ * treat such names as all-prefix. Consumed by introspection (prefix
15
+ * extraction) and by rename pairing (same hash, different prefix).
16
+ */
17
+ declare function parseRlsPolicyWireName(name: string): RlsPolicyWireName | undefined;
18
+ //#endregion
19
+ export { type ContentHashParts, type RlsPolicyOperation, type RlsPolicyWireName, computeContentHash, normalizePredicate, parseRlsPolicyWireName };
20
+ //# sourceMappingURL=rls-canonicalize.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rls-canonicalize.d.mts","names":[],"sources":["../src/core/rls/wire-name.ts"],"mappings":";;;UAAiB,iBAAA;;WAEN,MAAA;EAFM;EAAA,SAIN,IAAI;AAAA;;;;;;;;iBAsBC,sBAAA,CAAuB,IAAA,WAAe,iBAAiB"}
@@ -0,0 +1,2 @@
1
+ import { i as normalizePredicate, n as parseRlsPolicyWireName, r as computeContentHash } from "./wire-name-rHHtr1h0.mjs";
2
+ export { computeContentHash, normalizePredicate, parseRlsPolicyWireName };