@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
@@ -1,6 +1,7 @@
1
+ import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
1
2
  import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
2
- import { Namespace } from "@prisma-next/framework-components/ir";
3
- import { SqlNamespaceTablesInput, SqlStorage } from "@prisma-next/sql-contract/types";
3
+ import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir";
4
+ import { SqlNamespaceInput, SqlStorage } from "@prisma-next/sql-contract/types";
4
5
  import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
5
6
  import { Contract } from "@prisma-next/contract/types";
6
7
  import { RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
@@ -8,12 +9,9 @@ import { JsonObject } from "@prisma-next/utils/json";
8
9
 
9
10
  //#region src/core/postgres-contract-serializer.d.ts
10
11
  declare class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
11
- constructor();
12
- protected get defaultNamespaceId(): string;
13
- protected hydrateSqlNamespaceEntry(nsId: string, raw: Namespace | Record<string, unknown>): Namespace | SqlNamespaceTablesInput;
12
+ constructor(extraPackEntityKinds?: readonly AnyEntityKindDescriptor[]);
13
+ protected hydrateSqlNamespaceEntry(nsId: string, raw: Record<string, unknown>): Namespace | SqlNamespaceInput;
14
14
  serializeContract(contract: Contract<SqlStorage>): JsonObject;
15
- private serializePostgresNamespace;
16
- private serializeJsonValue;
17
15
  }
18
16
  //#endregion
19
17
  //#region src/exports/runtime.d.ts
@@ -28,5 +26,5 @@ declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'p
28
26
  readonly codecs: () => readonly AnyCodecDescriptor[];
29
27
  };
30
28
  //#endregion
31
- export { PostgresContractSerializer, PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
29
+ export { PostgresContractSerializer, PostgresContractView, PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
32
30
  //# sourceMappingURL=runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAkEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;gBAM1D,kBAAA;EAAA,UAIJ,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA0BN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QAyBA,kBAAA;AAAA;;;UChKO,6BAAA,SAAsC,qBAAqB;;;;;ADyD5E;;cCjDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;;cA0Ea,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;cACrE,oBAAA,YAA+B,uBAAA;EAAA,UAWxB,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,MAAA,oBACJ,SAAA,GAAY,iBAAA;EAyBN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;AAAA;;;UCxG7C,6BAAA,SAAsC,qBAAqB;;;;;ADgE5E;;cCxDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { n as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-CpGygXpI.mjs";
2
- import { t as PostgresContractSerializer } from "./postgres-contract-serializer-k3TAcPMY.mjs";
1
+ import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-UwYdV8fD.mjs";
2
+ import { n as PostgresContractSerializer, t as PostgresContractView } from "./postgres-contract-view-DWLNQbdR.mjs";
3
3
  //#region src/exports/runtime.ts
4
4
  /**
5
5
  * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
@@ -18,6 +18,6 @@ const postgresRuntimeTargetDescriptor = {
18
18
  }
19
19
  };
20
20
  //#endregion
21
- export { PostgresContractSerializer, postgresRuntimeTargetDescriptor as default };
21
+ export { PostgresContractSerializer, PostgresContractView, postgresRuntimeTargetDescriptor as default };
22
22
 
23
23
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMetaRuntime } from '../core/descriptor-meta-runtime';\n\nexport { PostgresContractSerializer } from '../core/postgres-contract-serializer';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMetaRuntime,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;AAiBA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,CAAC;CACf,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMetaRuntime } from '../core/descriptor-meta-runtime';\n\nexport { PostgresContractSerializer } from '../core/postgres-contract-serializer';\nexport { PostgresContractView } from '../core/postgres-contract-view';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMetaRuntime,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;AAkBA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,CAAC;CACf,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
@@ -0,0 +1,15 @@
1
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
2
+
3
+ //#region src/core/migrations/resolve-ddl-schema.d.ts
4
+ /**
5
+ * Given the contract's storage and a namespace id, returns the live Postgres
6
+ * DDL schema name that namespace maps to. A named Postgres namespace dispatches
7
+ * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to
8
+ * `DEFAULT_NAMESPACE_ID` (the search-path default for offline planning); a
9
+ * bare object payload (used by some tests) falls back to the namespace id
10
+ * itself.
11
+ */
12
+ declare function resolveDdlSchemaForNamespaceStorage(storage: SqlStorage, namespaceId: string): string;
13
+ //#endregion
14
+ export { resolveDdlSchemaForNamespaceStorage };
15
+ //# sourceMappingURL=schema-ir-annotations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-ir-annotations.d.mts","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"mappings":";;;;;AAaA;;;;;;iBAAgB,mCAAA,CACd,OAAA,EAAS,UAAU,EACnB,WAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-ZkKxt2Fm.mjs";
2
+ export { resolveDdlSchemaForNamespaceStorage };
package/dist/types.d.mts CHANGED
@@ -1,141 +1,5 @@
1
- import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
1
+ import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.mjs";
2
+ import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNode, d as PostgresPolicySchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresTableSchemaNodeInput, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresNativeEnumIntrospection, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNode } from "./postgres-database-schema-node-BVdOffjC.mjs";
2
3
  import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
3
- import { NamespaceBase } from "@prisma-next/framework-components/ir";
4
- import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
5
- import { SqlNamespaceEntries, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
6
-
7
- //#region src/core/postgres-schema.d.ts
8
- interface PostgresSchemaInput {
9
- readonly id: string;
10
- readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
11
- }
12
- /**
13
- * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
14
- * SCHEMA …`). Each Postgres `SqlStorage` carries a
15
- * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
16
- * the Postgres PSL interpreter from `namespace { … }` AST buckets.
17
- *
18
- * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
19
- * emission is the rendering seam: DDL / SQL emission asks the namespace
20
- * for its qualifier (`"<schema>"`) or for a qualified table name
21
- * (`"<schema>"."<table>"`) and consumes the result polymorphically.
22
- * The unbound singleton below overrides these methods to elide the
23
- * prefix entirely — call sites stay polymorphic and never branch on
24
- * `id === UNBOUND_NAMESPACE_ID`.
25
- */
26
- declare class PostgresSchema extends NamespaceBase {
27
- /**
28
- * Stable singleton reference for the late-bound slot. Materialised
29
- * lazily below the singleton subclass declaration so the static
30
- * initialiser sees the subclass before assigning. Consumers always
31
- * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
32
- * — same identity).
33
- */
34
- static unbound: PostgresUnboundSchema;
35
- readonly kind: 'schema';
36
- readonly id: string;
37
- readonly entries: SqlNamespaceEntries;
38
- constructor(input: PostgresSchemaInput);
39
- get table(): Readonly<Record<string, StorageTable>>;
40
- get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
41
- /**
42
- * The bare schema qualifier as it would appear in a rendered SQL
43
- * fragment (already quoted). The unbound-schema singleton overrides
44
- * this to return `''`.
45
- */
46
- qualifier(): string;
47
- /**
48
- * Qualify a table name with the schema prefix
49
- * (`"<schema>"."<table>"`). The unbound-schema singleton overrides
50
- * this to emit just `"<table>"` so the resolved DDL is unqualified
51
- * and `search_path` decides where the object lands at runtime.
52
- */
53
- qualifyTable(tableName: string): string;
54
- /**
55
- * Render a SQL string-literal containing the qualified-name form
56
- * suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
57
- * The unbound singleton overrides this to elide the schema prefix
58
- * (`'"user"'`) so `search_path` resolves the object at runtime.
59
- */
60
- regclassLiteral(name: string): string;
61
- /**
62
- * Render a SQL expression that evaluates to this namespace's schema
63
- * name at runtime, ready to drop into a `WHERE table_schema = …` /
64
- * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
65
- * literal (`'public'`); the unbound singleton overrides this to emit
66
- * `current_schema()` so catalog queries match whichever schema the
67
- * connection's `search_path` resolved at runtime.
68
- */
69
- schemaSqlExpression(): string;
70
- /**
71
- * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
72
- * builder-built catalog check compares `n.nspname` / `table_schema`
73
- * against. Named schemas bind the schema name as a text parameter; the
74
- * unbound singleton overrides this to the opaque `current_schema()`
75
- * expression so the live connection's `search_path` decides at runtime.
76
- */
77
- schemaFilterExpression(): CfExpr;
78
- /**
79
- * Typed-AST counterpart of {@link qualifyTable}: the FROM source a
80
- * builder-built check uses to address a user table in this namespace.
81
- * Named schemas qualify (`"schema"."table"`); the unbound singleton
82
- * overrides this to leave the table unqualified so `search_path`
83
- * resolves it at runtime.
84
- */
85
- tableSource(tableName: string, alias?: string): PostgresTableSource;
86
- /**
87
- * The bare schema name a DDL planner should target when emitting
88
- * statements that need to identify this namespace in the live
89
- * database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
90
- * catalog filters, planner conflict lookups). Named schemas resolve
91
- * to their own id. The `PostgresUnboundSchema` singleton inherits
92
- * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
93
- * through `qualifyTableName` route through the polymorphic
94
- * `PostgresUnboundSchema` overrides and produce unqualified
95
- * (search-path-resolved) output automatically.
96
- */
97
- ddlSchemaName(_storage: SqlStorage): string;
98
- }
99
- /**
100
- * Singleton subclass for the reserved sentinel namespace id
101
- * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
102
- * the connection's `search_path` resolves at runtime. Overrides
103
- * qualifier emission to elide the schema prefix; call sites that consume
104
- * `qualifier()` / `qualifyTable()` get unqualified output without
105
- * branching on the namespace id.
106
- *
107
- * This is the target-side materialization of "the framework provides
108
- * affordances; targets implement specifics": the framework names the
109
- * sentinel; Postgres decides what late-bound means here (the table
110
- * name, naked — the schema is supplied by the live connection's
111
- * `search_path`).
112
- *
113
- * `ddlSchemaName` is inherited from `PostgresSchema` and returns
114
- * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
115
- * route through the polymorphic factory and produce unqualified output
116
- * automatically.
117
- */
118
- declare class PostgresUnboundSchema extends PostgresSchema {
119
- static readonly instance: PostgresUnboundSchema;
120
- constructor(input?: PostgresSchemaInput);
121
- qualifier(): string;
122
- qualifyTable(tableName: string): string;
123
- schemaSqlExpression(): string;
124
- schemaFilterExpression(): CfExpr;
125
- tableSource(tableName: string, alias?: string): PostgresTableSource;
126
- }
127
- /**
128
- * Target-supplied `Namespace` factory the Postgres target plumbs
129
- * through `defineContract({ createNamespace })` and the SQL PSL
130
- * interpreter. Returns the unbound singleton for the framework
131
- * sentinel and a fresh `PostgresSchema` for any other coordinate.
132
- *
133
- * The factory has no per-call state — every named id deterministically
134
- * maps to a distinct schema instance — so callers can pass it through
135
- * by reference and trust the resulting `SqlStorage.namespaces` map to
136
- * be value-stable for a given input set.
137
- */
138
- declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
139
- //#endregion
140
- export { type PostgresColumnDefault, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
141
- //# sourceMappingURL=types.d.mts.map
4
+ import { a as postgresCreateNamespace, c as PostgresRlsEnablement, d as PostgresRoleInput, i as isPostgresSchema, l as PostgresRlsEnablementInput, n as PostgresSchema, o as PostgresNativeEnum, r as PostgresUnboundSchema, s as PostgresNativeEnumInput, t as PostgresContract, u as PostgresRole } from "./postgres-schema-DsrtYp2v.mjs";
5
+ export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresNativeEnum, type PostgresNativeEnumInput, type PostgresNativeEnumIntrospection, PostgresPolicySchemaNode, type PostgresPolicySchemaNodeInput, PostgresRlsEnablement, type PostgresRlsEnablementInput, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresRoleSchemaNode, type PostgresRoleSchemaNodeInput, PostgresSchema, PostgresTableSchemaNode, type PostgresTableSchemaNodeInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, postgresCreateNamespace };
package/dist/types.mjs CHANGED
@@ -1,2 +1,5 @@
1
- import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-COGZ1ark.mjs";
2
- export { PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
1
+ import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
2
+ import { _ as PostgresRlsEnablement, g as PostgresRlsPolicy, i as postgresCreateNamespace, m as PostgresRole, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-COEca21H.mjs";
3
+ import { t as PostgresTableSchemaNode } from "./postgres-table-schema-node-9FCtCUz2.mjs";
4
+ import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-BmCboEa_.mjs";
5
+ export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnum, PostgresPolicySchemaNode, PostgresRlsEnablement, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema, PostgresTableSchemaNode, PostgresUnboundSchema, isPostgresSchema, postgresCreateNamespace };
@@ -0,0 +1,75 @@
1
+ import { createHash } from "node:crypto";
2
+ //#region src/core/rls/canonicalize.ts
3
+ /**
4
+ * Stabilizes an authored predicate for hashing: trim, and collapse runs of
5
+ * internal whitespace to a single space.
6
+ *
7
+ * This is deliberately minimal. The content hash is the equivalence relation
8
+ * for a policy, and the wire name (prefix + hash) is the only thing ever
9
+ * compared — we never recompute the hash from an introspected policy body, so
10
+ * there is no need to match Postgres's reprinted form. Minimal normalization
11
+ * also protects the no-collision property: aggressive rewriting (lowercasing,
12
+ * paren-stripping, cast-alias folding) risks collapsing two distinct predicates
13
+ * onto one hash. Out-of-band alteration of a hashed policy is unsupported.
14
+ *
15
+ * The normalizer is a stability commitment: any change re-suffixes all wire names.
16
+ */
17
+ function normalizePredicate(sql) {
18
+ return sql.replace(/\s+/g, " ").trim();
19
+ }
20
+ /**
21
+ * Returns the first 8 lowercase hex characters of the SHA-256 digest over the
22
+ * canonical content tuple for an RLS policy:
23
+ *
24
+ * [normalize(using), normalize(withCheck), sortedRoles, operation, permissive]
25
+ *
26
+ * Schema and table are excluded (they are orthogonal to policy equivalence).
27
+ * Uses `JSON.stringify` for a deterministic encoding.
28
+ */
29
+ function computeContentHash(parts) {
30
+ const using = normalizePredicate(parts.using ?? "");
31
+ const withCheck = normalizePredicate(parts.withCheck ?? "");
32
+ const roles = [...new Set(parts.roles)].sort();
33
+ const permissive = parts.permissive ? "permissive" : "restrictive";
34
+ const tuple = JSON.stringify([
35
+ using,
36
+ withCheck,
37
+ roles,
38
+ parts.operation,
39
+ permissive
40
+ ]);
41
+ return createHash("sha256").update(tuple).digest("hex").slice(0, 8);
42
+ }
43
+ //#endregion
44
+ //#region src/core/rls/wire-name.ts
45
+ const WIRE_NAME_PATTERN = /^(.+)_([0-9a-f]{8})$/;
46
+ /**
47
+ * Assembles an RLS policy wire name from its user-supplied prefix and its
48
+ * 8-hex content-hash suffix. This module owns the `<prefix>_<hash>` format
49
+ * on both sides — construction here and parsing in
50
+ * {@link parseRlsPolicyWireName} — so the two never drift.
51
+ */
52
+ function formatRlsPolicyWireName(prefix, hash) {
53
+ return `${prefix}_${hash}`;
54
+ }
55
+ /**
56
+ * Splits an RLS policy wire name (`<prefix>_<8hex>`) into its prefix and
57
+ * content-hash suffix. Returns `undefined` when the name does not follow the
58
+ * wire-name shape (e.g. a policy created outside the toolchain) — callers
59
+ * treat such names as all-prefix. Consumed by introspection (prefix
60
+ * extraction) and by rename pairing (same hash, different prefix).
61
+ */
62
+ function parseRlsPolicyWireName(name) {
63
+ const match = WIRE_NAME_PATTERN.exec(name);
64
+ const prefix = match?.[1];
65
+ const hash = match?.[2];
66
+ if (prefix === void 0 || hash === void 0) return void 0;
67
+ return {
68
+ prefix,
69
+ hash
70
+ };
71
+ }
72
+ //#endregion
73
+ export { normalizePredicate as i, parseRlsPolicyWireName as n, computeContentHash as r, formatRlsPolicyWireName as t };
74
+
75
+ //# sourceMappingURL=wire-name-rHHtr1h0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-name-rHHtr1h0.mjs","names":[],"sources":["../src/core/rls/canonicalize.ts","../src/core/rls/wire-name.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\n\nexport type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';\n\nexport interface ContentHashParts {\n readonly using?: string;\n readonly withCheck?: string;\n readonly roles: readonly string[];\n readonly operation: RlsPolicyOperation;\n readonly permissive: boolean;\n}\n\n/**\n * Stabilizes an authored predicate for hashing: trim, and collapse runs of\n * internal whitespace to a single space.\n *\n * This is deliberately minimal. The content hash is the equivalence relation\n * for a policy, and the wire name (prefix + hash) is the only thing ever\n * compared — we never recompute the hash from an introspected policy body, so\n * there is no need to match Postgres's reprinted form. Minimal normalization\n * also protects the no-collision property: aggressive rewriting (lowercasing,\n * paren-stripping, cast-alias folding) risks collapsing two distinct predicates\n * onto one hash. Out-of-band alteration of a hashed policy is unsupported.\n *\n * The normalizer is a stability commitment: any change re-suffixes all wire names.\n */\nexport function normalizePredicate(sql: string): string {\n return sql.replace(/\\s+/g, ' ').trim();\n}\n\n/**\n * Returns the first 8 lowercase hex characters of the SHA-256 digest over the\n * canonical content tuple for an RLS policy:\n *\n * [normalize(using), normalize(withCheck), sortedRoles, operation, permissive]\n *\n * Schema and table are excluded (they are orthogonal to policy equivalence).\n * Uses `JSON.stringify` for a deterministic encoding.\n */\nexport function computeContentHash(parts: ContentHashParts): string {\n const using = normalizePredicate(parts.using ?? '');\n const withCheck = normalizePredicate(parts.withCheck ?? '');\n const roles = [...new Set(parts.roles)].sort();\n const permissive = parts.permissive ? 'permissive' : 'restrictive';\n\n const tuple = JSON.stringify([using, withCheck, roles, parts.operation, permissive]);\n return createHash('sha256').update(tuple).digest('hex').slice(0, 8);\n}\n","export interface RlsPolicyWireName {\n /** The user-supplied part before the `_<8hex>` suffix. */\n readonly prefix: string;\n /** The 8-lowercase-hex content-hash suffix. */\n readonly hash: string;\n}\n\nconst WIRE_NAME_PATTERN = /^(.+)_([0-9a-f]{8})$/;\n\n/**\n * Assembles an RLS policy wire name from its user-supplied prefix and its\n * 8-hex content-hash suffix. This module owns the `<prefix>_<hash>` format\n * on both sides — construction here and parsing in\n * {@link parseRlsPolicyWireName} — so the two never drift.\n */\nexport function formatRlsPolicyWireName(prefix: string, hash: string): string {\n return `${prefix}_${hash}`;\n}\n\n/**\n * Splits an RLS policy wire name (`<prefix>_<8hex>`) into its prefix and\n * content-hash suffix. Returns `undefined` when the name does not follow the\n * wire-name shape (e.g. a policy created outside the toolchain) — callers\n * treat such names as all-prefix. Consumed by introspection (prefix\n * extraction) and by rename pairing (same hash, different prefix).\n */\nexport function parseRlsPolicyWireName(name: string): RlsPolicyWireName | undefined {\n const match = WIRE_NAME_PATTERN.exec(name);\n const prefix = match?.[1];\n const hash = match?.[2];\n if (prefix === undefined || hash === undefined) return undefined;\n return { prefix, hash };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,SAAgB,mBAAmB,KAAqB;CACtD,OAAO,IAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AACvC;;;;;;;;;;AAWA,SAAgB,mBAAmB,OAAiC;CAClE,MAAM,QAAQ,mBAAmB,MAAM,SAAS,EAAE;CAClD,MAAM,YAAY,mBAAmB,MAAM,aAAa,EAAE;CAC1D,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK;CAC7C,MAAM,aAAa,MAAM,aAAa,eAAe;CAErD,MAAM,QAAQ,KAAK,UAAU;EAAC;EAAO;EAAW;EAAO,MAAM;EAAW;CAAU,CAAC;CACnF,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;AACpE;;;ACxCA,MAAM,oBAAoB;;;;;;;AAQ1B,SAAgB,wBAAwB,QAAgB,MAAsB;CAC5E,OAAO,GAAG,OAAO,GAAG;AACtB;;;;;;;;AASA,SAAgB,uBAAuB,MAA6C;CAClF,MAAM,QAAQ,kBAAkB,KAAK,IAAI;CACzC,MAAM,SAAS,QAAQ;CACvB,MAAM,OAAO,QAAQ;CACrB,IAAI,WAAW,KAAA,KAAa,SAAS,KAAA,GAAW,OAAO,KAAA;CACvD,OAAO;EAAE;EAAQ;CAAK;AACxB"}
package/package.json CHANGED
@@ -1,32 +1,35 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.14.0-dev.6",
3
+ "version": "0.14.0-dev.61",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Postgres target pack for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/cli": "0.14.0-dev.6",
10
- "@prisma-next/contract": "0.14.0-dev.6",
11
- "@prisma-next/errors": "0.14.0-dev.6",
12
- "@prisma-next/family-sql": "0.14.0-dev.6",
13
- "@prisma-next/framework-components": "0.14.0-dev.6",
14
- "@prisma-next/migration-tools": "0.14.0-dev.6",
15
- "@prisma-next/ts-render": "0.14.0-dev.6",
16
- "@prisma-next/sql-contract": "0.14.0-dev.6",
17
- "@prisma-next/sql-errors": "0.14.0-dev.6",
18
- "@prisma-next/sql-operations": "0.14.0-dev.6",
19
- "@prisma-next/sql-relational-core": "0.14.0-dev.6",
20
- "@prisma-next/sql-schema-ir": "0.14.0-dev.6",
21
- "@prisma-next/utils": "0.14.0-dev.6",
9
+ "@prisma-next/cli": "0.14.0-dev.61",
10
+ "@prisma-next/contract": "0.14.0-dev.61",
11
+ "@prisma-next/errors": "0.14.0-dev.61",
12
+ "@prisma-next/family-sql": "0.14.0-dev.61",
13
+ "@prisma-next/framework-components": "0.14.0-dev.61",
14
+ "@prisma-next/migration-tools": "0.14.0-dev.61",
15
+ "@prisma-next/psl-parser": "0.14.0-dev.61",
16
+ "@prisma-next/sql-contract": "0.14.0-dev.61",
17
+ "@prisma-next/sql-errors": "0.14.0-dev.61",
18
+ "@prisma-next/sql-operations": "0.14.0-dev.61",
19
+ "@prisma-next/sql-relational-core": "0.14.0-dev.61",
20
+ "@prisma-next/sql-schema-ir": "0.14.0-dev.61",
21
+ "@prisma-next/ts-render": "0.14.0-dev.61",
22
+ "@prisma-next/utils": "0.14.0-dev.61",
22
23
  "@standard-schema/spec": "^1.1.0",
23
24
  "arktype": "^2.2.0",
24
25
  "pathe": "^2.0.3"
25
26
  },
26
27
  "devDependencies": {
27
- "@prisma-next/test-utils": "0.14.0-dev.6",
28
- "@prisma-next/tsconfig": "0.14.0-dev.6",
29
- "@prisma-next/tsdown": "0.14.0-dev.6",
28
+ "@prisma-next/psl-printer": "0.14.0-dev.61",
29
+ "@prisma-next/sql-contract-psl": "0.14.0-dev.61",
30
+ "@prisma-next/test-utils": "0.14.0-dev.61",
31
+ "@prisma-next/tsconfig": "0.14.0-dev.61",
32
+ "@prisma-next/tsdown": "0.14.0-dev.61",
30
33
  "tsdown": "0.22.1",
31
34
  "typescript": "5.9.3",
32
35
  "vitest": "4.1.8"
@@ -53,6 +56,7 @@
53
56
  "./data-transform": "./dist/data-transform.mjs",
54
57
  "./ddl": "./dist/ddl.mjs",
55
58
  "./default-normalizer": "./dist/default-normalizer.mjs",
59
+ "./diff-database-schema": "./dist/diff-database-schema.mjs",
56
60
  "./errors": "./dist/errors.mjs",
57
61
  "./issue-planner": "./dist/issue-planner.mjs",
58
62
  "./migration": "./dist/migration.mjs",
@@ -68,7 +72,9 @@
68
72
  "./planner-target-details": "./dist/planner-target-details.mjs",
69
73
  "./render-ops": "./dist/render-ops.mjs",
70
74
  "./render-typescript": "./dist/render-typescript.mjs",
75
+ "./rls-canonicalize": "./dist/rls-canonicalize.mjs",
71
76
  "./runtime": "./dist/runtime.mjs",
77
+ "./schema-ir-annotations": "./dist/schema-ir-annotations.mjs",
72
78
  "./sql-utils": "./dist/sql-utils.mjs",
73
79
  "./types": "./dist/types.mjs",
74
80
  "./package.json": "./package.json"
@@ -345,6 +345,79 @@ export function extensionExistsAst(extensionName: string): ExtensionExistsCheckB
345
345
  };
346
346
  }
347
347
 
348
+ export interface RlsPolicyExistsCheckBuilder {
349
+ policyPresent(): SelectAst;
350
+ policyAbsent(): SelectAst;
351
+ }
352
+
353
+ /**
354
+ * Typed RLS-policy existence check over `pg_policies`, with schema, table,
355
+ * and policy names bound as text parameters (never inlined). The `schema`
356
+ * coordinate is the resolved live-database schema name (e.g. `'public'`),
357
+ * compared against `pg_policies.schemaname` as a bound parameter.
358
+ */
359
+ export function rlsPolicyExistsAst(options: {
360
+ readonly schema: string;
361
+ readonly table: string;
362
+ readonly policyName: string;
363
+ }): RlsPolicyExistsCheckBuilder {
364
+ const inner = () =>
365
+ exprSelect()
366
+ .from(cfTable('pg_policies'))
367
+ .project('one', cfExpr.lit(1))
368
+ .where(
369
+ cfExpr.allOf([
370
+ cfExpr.identifierRef('schemaname').eqParam(options.schema, PG_TEXT_CODEC_ID),
371
+ cfExpr.identifierRef('tablename').eqParam(options.table, PG_TEXT_CODEC_ID),
372
+ cfExpr.identifierRef('policyname').eqParam(options.policyName, PG_TEXT_CODEC_ID),
373
+ ]),
374
+ );
375
+ return {
376
+ policyPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),
377
+ policyAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),
378
+ };
379
+ }
380
+
381
+ export interface RlsEnabledCheckBuilder {
382
+ rlsEnabled(): SelectAst;
383
+ rlsDisabled(): SelectAst;
384
+ }
385
+
386
+ /**
387
+ * Typed row-level-security enabled check over `pg_class` joined to
388
+ * `pg_namespace`, comparing `pg_class.relrowsecurity` against the expected
389
+ * boolean. Schema and table names are bound as text parameters.
390
+ */
391
+ export function rlsEnabledAst(schema: string, table: string): RlsEnabledCheckBuilder {
392
+ const inner = (enabled: boolean) =>
393
+ exprSelect()
394
+ .from(cfTable('pg_class', 'c'))
395
+ .join(
396
+ cfTable('pg_namespace', 'n'),
397
+ cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),
398
+ )
399
+ .project('one', cfExpr.lit(1))
400
+ .where(
401
+ cfExpr.allOf([
402
+ cfExpr.columnRef('n', 'nspname').eqParam(schema, PG_TEXT_CODEC_ID),
403
+ cfExpr.columnRef('c', 'relname').eqParam(table, PG_TEXT_CODEC_ID),
404
+ enabled
405
+ ? cfExpr.columnRef('c', 'relrowsecurity')
406
+ : cfExpr.columnRef('c', 'relrowsecurity').not(),
407
+ ]),
408
+ );
409
+ return {
410
+ rlsEnabled: () =>
411
+ exprSelect()
412
+ .project('result', cfExpr.exists(inner(true)))
413
+ .build(),
414
+ rlsDisabled: () =>
415
+ exprSelect()
416
+ .project('result', cfExpr.exists(inner(false)))
417
+ .build(),
418
+ };
419
+ }
420
+
348
421
  export interface IndexExistsCheckBuilder {
349
422
  indexPresent(): SelectAst;
350
423
  indexAbsent(): SelectAst;
@@ -2,9 +2,15 @@ import type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-
2
2
  import {
3
3
  AddColumnAction,
4
4
  type AnyAlterTableAction,
5
+ DropDefaultAction,
6
+ PostgresAlterPolicyRename,
5
7
  PostgresAlterTable,
8
+ PostgresCreatePolicy,
6
9
  PostgresCreateSchema,
7
10
  PostgresCreateTable,
11
+ PostgresDisableRowLevelSecurity,
12
+ PostgresDropPolicy,
13
+ type RlsPolicyOperation,
8
14
  } from '../core/ddl/nodes';
9
15
 
10
16
  /**
@@ -51,9 +57,17 @@ export function addColumnAction(column: DdlColumn): AddColumnAction {
51
57
  return new AddColumnAction(column);
52
58
  }
53
59
 
60
+ /**
61
+ * Build a `DROP DEFAULT` action (`ALTER COLUMN "<name>" DROP DEFAULT`) for
62
+ * use inside {@link alterTable}. The renderer quotes the column name.
63
+ */
64
+ export function dropDefaultAction(columnName: string): DropDefaultAction {
65
+ return new DropDefaultAction(columnName);
66
+ }
67
+
54
68
  /**
55
69
  * Build a Postgres `ALTER TABLE` query node carrying one or more actions.
56
- * See {@link addColumnAction} for building actions.
70
+ * See {@link addColumnAction} / {@link dropDefaultAction} for building actions.
57
71
  */
58
72
  export function alterTable(options: {
59
73
  readonly table: string;
@@ -62,3 +76,59 @@ export function alterTable(options: {
62
76
  }): PostgresAlterTable {
63
77
  return new PostgresAlterTable(options);
64
78
  }
79
+
80
+ /**
81
+ * Build a Postgres `CREATE POLICY` DDL node.
82
+ *
83
+ * Identifiers (`schema`, `table`, `name`) are quoted by the renderer.
84
+ * `using` and `withCheck` are emitted verbatim as predicate SQL — callers
85
+ * must supply safe, pre-validated SQL expressions.
86
+ */
87
+ export function createPolicy(options: {
88
+ readonly schema: string;
89
+ readonly table: string;
90
+ readonly name: string;
91
+ readonly permissive: boolean;
92
+ readonly operation: RlsPolicyOperation;
93
+ readonly roles: readonly string[];
94
+ readonly using?: string;
95
+ readonly withCheck?: string;
96
+ }): PostgresCreatePolicy {
97
+ return new PostgresCreatePolicy(options);
98
+ }
99
+
100
+ /**
101
+ * Build a Postgres `DROP POLICY` DDL node.
102
+ * Identifiers (`schema`, `table`, `name`) are quoted by the renderer.
103
+ */
104
+ export function dropPolicy(options: {
105
+ readonly schema: string;
106
+ readonly table: string;
107
+ readonly name: string;
108
+ }): PostgresDropPolicy {
109
+ return new PostgresDropPolicy(options);
110
+ }
111
+
112
+ /**
113
+ * Build a Postgres `ALTER POLICY … RENAME TO` DDL node.
114
+ * Identifiers (`schema`, `table`, `name`, `newName`) are quoted by the renderer.
115
+ */
116
+ export function alterPolicyRename(options: {
117
+ readonly schema: string;
118
+ readonly table: string;
119
+ readonly name: string;
120
+ readonly newName: string;
121
+ }): PostgresAlterPolicyRename {
122
+ return new PostgresAlterPolicyRename(options);
123
+ }
124
+
125
+ /**
126
+ * Build a Postgres `ALTER TABLE … DISABLE ROW LEVEL SECURITY` DDL node.
127
+ * Identifiers (`schema`, `table`) are quoted by the renderer.
128
+ */
129
+ export function disableRowLevelSecurity(options: {
130
+ readonly schema: string;
131
+ readonly table: string;
132
+ }): PostgresDisableRowLevelSecurity {
133
+ return new PostgresDisableRowLevelSecurity(options);
134
+ }