@prisma-next/target-postgres 0.14.0-dev.9 → 0.14.0-dev.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/dist/authoring-BtsOWgI3.mjs +674 -0
  2. package/dist/authoring-BtsOWgI3.mjs.map +1 -0
  3. package/dist/canonicalize-D1F4vUnP.d.mts +48 -0
  4. package/dist/canonicalize-D1F4vUnP.d.mts.map +1 -0
  5. package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-B10ZZHzw.mjs} +4 -2
  6. package/dist/codec-ids-B10ZZHzw.mjs.map +1 -0
  7. package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-CI144z7g.d.mts} +4 -2
  8. package/dist/codec-ids-CI144z7g.d.mts.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-CTfT4U4O.d.mts} +4 -2
  12. package/dist/codec-types-CTfT4U4O.d.mts.map +1 -0
  13. package/dist/codec-types.d.mts +1 -1
  14. package/dist/{codecs--0A5_4Bq.d.mts → codecs-D7W9O0Xx.d.mts} +134 -4
  15. package/dist/codecs-D7W9O0Xx.d.mts.map +1 -0
  16. package/dist/codecs-DRbb26Or.mjs +955 -0
  17. package/dist/codecs-DRbb26Or.mjs.map +1 -0
  18. package/dist/codecs.d.mts +2 -2
  19. package/dist/codecs.mjs +3 -757
  20. package/dist/codecs.mjs.map +1 -1
  21. package/dist/contract-free.d.mts +33 -3
  22. package/dist/contract-free.d.mts.map +1 -1
  23. package/dist/contract-free.mjs +23 -7
  24. package/dist/contract-free.mjs.map +1 -1
  25. package/dist/control-policy-DtbkLLGv.mjs +1285 -0
  26. package/dist/control-policy-DtbkLLGv.mjs.map +1 -0
  27. package/dist/control.d.mts +2 -2
  28. package/dist/control.d.mts.map +1 -1
  29. package/dist/control.mjs +880 -36
  30. package/dist/control.mjs.map +1 -1
  31. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  32. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
  33. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
  34. package/dist/data-transform.d.mts +1 -1
  35. package/dist/{ddl-QDyOSeLc.mjs → ddl-GTTOvjx_.mjs} +128 -6
  36. package/dist/ddl-GTTOvjx_.mjs.map +1 -0
  37. package/dist/ddl.d.mts +3 -2
  38. package/dist/ddl.mjs +2 -2
  39. package/dist/default-normalizer.d.mts +1 -1
  40. package/dist/default-normalizer.d.mts.map +1 -1
  41. package/dist/default-normalizer.mjs +247 -1
  42. package/dist/default-normalizer.mjs.map +1 -0
  43. package/dist/descriptor-meta-CFQKLXl_.mjs +23 -0
  44. package/dist/descriptor-meta-CFQKLXl_.mjs.map +1 -0
  45. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
  46. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
  47. package/dist/diff-database-schema-GncqMuSI.mjs +305 -0
  48. package/dist/diff-database-schema-GncqMuSI.mjs.map +1 -0
  49. package/dist/diff-database-schema.d.mts +46 -0
  50. package/dist/diff-database-schema.d.mts.map +1 -0
  51. package/dist/diff-database-schema.mjs +2 -0
  52. package/dist/errors-DO-w0EUS.mjs +35 -0
  53. package/dist/errors-DO-w0EUS.mjs.map +1 -0
  54. package/dist/errors.d.mts +11 -9
  55. package/dist/errors.d.mts.map +1 -1
  56. package/dist/errors.mjs +1 -1
  57. package/dist/issue-planner.d.mts +35 -11
  58. package/dist/issue-planner.d.mts.map +1 -1
  59. package/dist/issue-planner.mjs +2 -2
  60. package/dist/migration.d.mts +5 -5
  61. package/dist/migration.d.mts.map +1 -1
  62. package/dist/migration.mjs +4 -4
  63. package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
  64. package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
  65. package/dist/native-type-normalizer.mjs +37 -1
  66. package/dist/native-type-normalizer.mjs.map +1 -0
  67. package/dist/nodes-DJC5B8Id.mjs +192 -0
  68. package/dist/nodes-DJC5B8Id.mjs.map +1 -0
  69. package/dist/nodes-Dv5eCSq9.d.mts +170 -0
  70. package/dist/nodes-Dv5eCSq9.d.mts.map +1 -0
  71. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Bn9zDx4_.d.mts} +114 -15
  72. package/dist/op-factory-call-Bn9zDx4_.d.mts.map +1 -0
  73. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-C38NzvQD.mjs} +469 -32
  74. package/dist/op-factory-call-C38NzvQD.mjs.map +1 -0
  75. package/dist/op-factory-call.d.mts +2 -2
  76. package/dist/op-factory-call.mjs +2 -2
  77. package/dist/pack.d.mts +321 -3
  78. package/dist/pack.d.mts.map +1 -1
  79. package/dist/pack.mjs +1 -1
  80. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-BKlmGDJl.mjs} +17 -28
  81. package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
  82. package/dist/planner-ddl-builders.d.mts +4 -6
  83. package/dist/planner-ddl-builders.d.mts.map +1 -1
  84. package/dist/planner-ddl-builders.mjs +2 -2
  85. package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
  86. package/dist/planner-identity-values.d.mts +8 -2
  87. package/dist/planner-identity-values.d.mts.map +1 -1
  88. package/dist/planner-identity-values.mjs +2 -2
  89. package/dist/planner-kql24i_F.mjs +390 -0
  90. package/dist/planner-kql24i_F.mjs.map +1 -0
  91. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-BEY1T0Xm.d.mts} +4 -4
  92. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-BEY1T0Xm.d.mts.map} +1 -1
  93. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-D7y-PEHK.mjs} +3 -3
  94. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-D7y-PEHK.mjs.map} +1 -1
  95. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  96. package/dist/planner-produced-postgres-migration.mjs +1 -1
  97. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-zqNfs2XZ.mjs} +5 -5
  98. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-zqNfs2XZ.mjs.map} +1 -1
  99. package/dist/planner-sql-checks.d.mts +2 -2
  100. package/dist/planner-sql-checks.d.mts.map +1 -1
  101. package/dist/planner-sql-checks.mjs +1 -1
  102. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  103. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  104. package/dist/planner-target-details.d.mts +1 -1
  105. package/dist/planner.d.mts +72 -17
  106. package/dist/planner.d.mts.map +1 -1
  107. package/dist/planner.mjs +3 -2
  108. package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
  109. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
  110. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-DM8sN1Ot.mjs} +45 -41
  111. package/dist/postgres-contract-view-DM8sN1Ot.mjs.map +1 -0
  112. package/dist/postgres-database-schema-node-CJv5bfbs.d.mts +262 -0
  113. package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
  114. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DbckK1su.d.mts} +58 -9
  115. package/dist/postgres-migration-DbckK1su.d.mts.map +1 -0
  116. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-arMSWU9b.mjs} +78 -45
  117. package/dist/postgres-migration-arMSWU9b.mjs.map +1 -0
  118. package/dist/postgres-native-enum-BwVNf0Ku.mjs +45 -0
  119. package/dist/postgres-native-enum-BwVNf0Ku.mjs.map +1 -0
  120. package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
  121. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  122. package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs +190 -0
  123. package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
  124. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-Cm4DtiGA.mjs} +200 -11
  125. package/dist/postgres-schema-Cm4DtiGA.mjs.map +1 -0
  126. package/dist/postgres-schema-DKq6s1P3.d.mts +269 -0
  127. package/dist/postgres-schema-DKq6s1P3.d.mts.map +1 -0
  128. package/dist/postgres-table-schema-node-D6LvInCe.mjs +216 -0
  129. package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
  130. package/dist/render-ops.d.mts +1 -1
  131. package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
  132. package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
  133. package/dist/render-typescript.mjs +1 -1
  134. package/dist/resolve-ddl-schema-XyBaaenM.mjs +22 -0
  135. package/dist/resolve-ddl-schema-XyBaaenM.mjs.map +1 -0
  136. package/dist/rls-canonicalize.d.mts +27 -0
  137. package/dist/rls-canonicalize.d.mts.map +1 -0
  138. package/dist/rls-canonicalize.mjs +2 -0
  139. package/dist/runtime.d.mts +6 -8
  140. package/dist/runtime.d.mts.map +1 -1
  141. package/dist/runtime.mjs +3 -3
  142. package/dist/runtime.mjs.map +1 -1
  143. package/dist/schema-ir-annotations.d.mts +15 -0
  144. package/dist/schema-ir-annotations.d.mts.map +1 -0
  145. package/dist/schema-ir-annotations.mjs +2 -0
  146. package/dist/{sql-utils-DcfMz4MQ.mjs → sql-utils-SU4FDvIV.mjs} +12 -3
  147. package/dist/{sql-utils-DcfMz4MQ.mjs.map → sql-utils-SU4FDvIV.mjs.map} +1 -1
  148. package/dist/sql-utils.d.mts +8 -1
  149. package/dist/sql-utils.d.mts.map +1 -1
  150. package/dist/sql-utils.mjs +2 -2
  151. package/dist/types.d.mts +4 -140
  152. package/dist/types.mjs +5 -2
  153. package/dist/wire-name-DbQ9-2RC.mjs +104 -0
  154. package/dist/wire-name-DbQ9-2RC.mjs.map +1 -0
  155. package/package.json +26 -20
  156. package/src/contract-free/checks.ts +153 -0
  157. package/src/contract-free/control-bootstrap.ts +20 -3
  158. package/src/contract-free/ddl.ts +98 -1
  159. package/src/core/authoring.ts +726 -2
  160. package/src/core/codec-helpers.ts +33 -7
  161. package/src/core/codec-ids.ts +2 -0
  162. package/src/core/codec-type-map.ts +4 -0
  163. package/src/core/codecs.ts +236 -12
  164. package/src/core/ddl/nodes.ts +185 -2
  165. package/src/core/default-normalizer.ts +122 -2
  166. package/src/core/descriptor-meta.ts +12 -1
  167. package/src/core/entity-kinds.ts +41 -0
  168. package/src/core/errors.ts +14 -12
  169. package/src/core/migrations/bound-schema.ts +10 -0
  170. package/src/core/migrations/column-ddl-rendering.ts +117 -0
  171. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +189 -0
  172. package/src/core/migrations/control-policy.ts +217 -65
  173. package/src/core/migrations/diff-database-schema.ts +252 -0
  174. package/src/core/migrations/issue-planner.ts +817 -656
  175. package/src/core/migrations/op-factory-call.ts +383 -23
  176. package/src/core/migrations/operations/columns.ts +24 -12
  177. package/src/core/migrations/operations/constraints.ts +1 -1
  178. package/src/core/migrations/operations/data-transform.ts +6 -0
  179. package/src/core/migrations/operations/dependencies.ts +2 -1
  180. package/src/core/migrations/operations/native-enum-types.ts +62 -0
  181. package/src/core/migrations/operations/rls.ts +187 -0
  182. package/src/core/migrations/operations/shared.ts +0 -30
  183. package/src/core/migrations/planner-ddl-builders.ts +31 -59
  184. package/src/core/migrations/planner-identity-values.ts +1 -1
  185. package/src/core/migrations/planner-recipes.ts +31 -13
  186. package/src/core/migrations/planner-sql-checks.ts +1 -1
  187. package/src/core/migrations/planner-strategies.ts +248 -216
  188. package/src/core/migrations/planner-target-details.ts +3 -1
  189. package/src/core/migrations/planner.ts +357 -67
  190. package/src/core/migrations/postgres-migration.ts +118 -86
  191. package/src/core/migrations/render-typescript.ts +42 -15
  192. package/src/core/migrations/resolve-ddl-schema.ts +26 -0
  193. package/src/core/migrations/runner.ts +11 -16
  194. package/src/core/migrations/verify-postgres-namespaces.ts +46 -31
  195. package/src/core/namespace-ids.ts +3 -0
  196. package/src/core/postgres-contract-serializer.ts +46 -71
  197. package/src/core/postgres-contract-view.ts +48 -0
  198. package/src/core/postgres-native-enum.ts +61 -0
  199. package/src/core/postgres-rls-enablement.ts +34 -0
  200. package/src/core/postgres-rls-policy.ts +64 -0
  201. package/src/core/postgres-role.ts +59 -0
  202. package/src/core/postgres-schema-verifier.ts +10 -7
  203. package/src/core/postgres-schema.ts +85 -15
  204. package/src/core/postgres-validators.ts +34 -0
  205. package/src/core/psl-infer/infer-psl-contract.ts +1290 -0
  206. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  207. package/src/core/psl-infer/postgres-type-map.ts +129 -0
  208. package/src/core/rls/canonicalize.ts +65 -0
  209. package/src/core/rls/wire-name.ts +33 -0
  210. package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
  211. package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
  212. package/src/core/schema-ir/postgres-namespace-schema-node.ts +70 -0
  213. package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
  214. package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
  215. package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
  216. package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
  217. package/src/core/schema-ir/schema-node-kinds.ts +122 -0
  218. package/src/core/sql-utils.ts +15 -2
  219. package/src/exports/codecs.ts +5 -0
  220. package/src/exports/contract-free.ts +11 -1
  221. package/src/exports/control.ts +27 -33
  222. package/src/exports/ddl.ts +8 -0
  223. package/src/exports/diff-database-schema.ts +7 -0
  224. package/src/exports/issue-planner.ts +1 -1
  225. package/src/exports/migration.ts +1 -0
  226. package/src/exports/op-factory-call.ts +4 -0
  227. package/src/exports/planner-ddl-builders.ts +0 -2
  228. package/src/exports/planner-identity-values.ts +4 -1
  229. package/src/exports/planner.ts +1 -0
  230. package/src/exports/rls-canonicalize.ts +12 -0
  231. package/src/exports/runtime.ts +1 -0
  232. package/src/exports/schema-ir-annotations.ts +1 -0
  233. package/src/exports/sql-utils.ts +1 -0
  234. package/src/exports/types.ts +37 -0
  235. package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
  236. package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
  237. package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
  238. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  239. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  240. package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
  241. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  242. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  243. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  244. package/dist/errors-CUk87ByX.mjs +0 -33
  245. package/dist/errors-CUk87ByX.mjs.map +0 -1
  246. package/dist/issue-planner-DL6g3CmE.mjs +0 -824
  247. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  248. package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
  249. package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
  250. package/dist/nodes-Bbhs2rwj.mjs +0 -76
  251. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  252. package/dist/nodes-pLeLgdis.d.mts +0 -67
  253. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  254. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  255. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  256. package/dist/planner-Bs_baQax.mjs +0 -324
  257. package/dist/planner-Bs_baQax.mjs.map +0 -1
  258. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  259. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  260. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  261. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  262. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  263. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  264. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  265. package/dist/types.d.mts.map +0 -1
  266. package/src/core/postgres-enum-type-schema.ts +0 -17
@@ -0,0 +1,22 @@
1
+ import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86.mjs";
2
+ import { r as isPostgresSchema } from "./postgres-schema-Cm4DtiGA.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-XyBaaenM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-ddl-schema-XyBaaenM.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,27 @@
1
+ import { a as normalizePredicate, i as computeContentHash, n as POLICY_OPERATION_PREDICATES, r as RlsPolicyOperation, t as ContentHashParts } from "./canonicalize-D1F4vUnP.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
+ * Assembles an RLS policy wire name from its user-supplied prefix and its
12
+ * 8-hex content-hash suffix. This module owns the `<prefix>_<hash>` format
13
+ * on both sides — construction here and parsing in
14
+ * {@link parseRlsPolicyWireName} — so the two never drift.
15
+ */
16
+ declare function formatRlsPolicyWireName(prefix: string, hash: string): string;
17
+ /**
18
+ * Splits an RLS policy wire name (`<prefix>_<8hex>`) into its prefix and
19
+ * content-hash suffix. Returns `undefined` when the name does not follow the
20
+ * wire-name shape (e.g. a policy created outside the toolchain) — callers
21
+ * treat such names as all-prefix. Consumed by introspection (prefix
22
+ * extraction) and by rename pairing (same hash, different prefix).
23
+ */
24
+ declare function parseRlsPolicyWireName(name: string): RlsPolicyWireName | undefined;
25
+ //#endregion
26
+ export { type ContentHashParts, POLICY_OPERATION_PREDICATES, type RlsPolicyOperation, type RlsPolicyWireName, computeContentHash, formatRlsPolicyWireName, normalizePredicate, parseRlsPolicyWireName };
27
+ //# 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;;AAAA;AAWf;;;;iBAAgB,uBAAA,CAAwB,MAAA,UAAgB,IAAY;AAWpE;;;;AAAuE;;;AAAvE,iBAAgB,sBAAA,CAAuB,IAAA,WAAe,iBAAiB"}
@@ -0,0 +1,2 @@
1
+ import { a as normalizePredicate, i as computeContentHash, n as parseRlsPolicyWireName, r as POLICY_OPERATION_PREDICATES, t as formatRlsPolicyWireName } from "./wire-name-DbQ9-2RC.mjs";
2
+ export { POLICY_OPERATION_PREDICATES, computeContentHash, formatRlsPolicyWireName, normalizePredicate, parseRlsPolicyWireName };
@@ -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-DM8sN1Ot.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-XyBaaenM.mjs";
2
+ export { resolveDdlSchemaForNamespaceStorage };
@@ -59,6 +59,15 @@ function qualifyName(schemaName, objectName) {
59
59
  return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;
60
60
  }
61
61
  /**
62
+ * Quotes a possibly dot-qualified name segment-by-segment:
63
+ * `order_status` -> `"order_status"`, `auth.aal_level` -> `"auth"."aal_level"`.
64
+ * A single-segment name round-trips to exactly {@link quoteIdentifier}; whole-
65
+ * string quoting (`"auth.aal_level"`) would be one wrong identifier.
66
+ */
67
+ function quoteQualifiedName(name) {
68
+ return name.split(".").map((segment) => quoteIdentifier(segment)).join(".");
69
+ }
70
+ /**
62
71
  * Validates that an enum value doesn't exceed PostgreSQL's label length limit.
63
72
  *
64
73
  * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).
@@ -70,9 +79,9 @@ function qualifyName(schemaName, objectName) {
70
79
  * @throws {SqlEscapeError} If the value exceeds the maximum length
71
80
  */
72
81
  function validateEnumValueLength(value, enumTypeName) {
73
- if (value.length > MAX_IDENTIFIER_LENGTH) throw new SqlEscapeError(`Enum value "${value.slice(0, 20)}..." for type "${enumTypeName}" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character label limit`, value, "literal");
82
+ if (new TextEncoder().encode(value).length > MAX_IDENTIFIER_LENGTH) throw new SqlEscapeError(`Enum value "${value.slice(0, 20)}..." for type "${enumTypeName}" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-byte label limit`, value, "literal");
74
83
  }
75
84
  //#endregion
76
- export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
85
+ export { quoteQualifiedName as a, quoteIdentifier as i, escapeLiteral as n, validateEnumValueLength as o, qualifyName as r, SqlEscapeError as t };
77
86
 
78
- //# sourceMappingURL=sql-utils-DcfMz4MQ.mjs.map
87
+ //# sourceMappingURL=sql-utils-SU4FDvIV.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils-DcfMz4MQ.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres target.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n *\n * They live in `target-postgres` because both the control adapter (used at\n * emit time) and the runtime adapter (used at execute time) need the same\n * escaping/validation behavior, and the target package is the natural shared\n * home that both adapters can depend on without crossing planes.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,YAAY;CAEjF,IAAI,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,KAAK,GAC/B,YACF;CAEF,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,EAAE,EAAE,4BAA4B,sBAAsB,uCAC3F;CAEF,OAAO,IAAI,WAAW,QAAQ,MAAM,MAAI,EAAE;AAC5C;;;;;;;;;;;;AAaA,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,IAAI,GACrB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,KAAK,GAC1B,SACF;CAEF,OAAO,MAAM,QAAQ,MAAM,IAAI;AACjC;;;;AAKA,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,UAAU,EAAE,GAAG,gBAAgB,UAAU;AACrE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,MAAM,SAAS,uBACjB,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,EAAE,EAAE,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,SACF;AAEJ"}
1
+ {"version":3,"file":"sql-utils-SU4FDvIV.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres target.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n *\n * They live in `target-postgres` because both the control adapter (used at\n * emit time) and the runtime adapter (used at execute time) need the same\n * escaping/validation behavior, and the target package is the natural shared\n * home that both adapters can depend on without crossing planes.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Quotes a possibly dot-qualified name segment-by-segment:\n * `order_status` -> `\"order_status\"`, `auth.aal_level` -> `\"auth\".\"aal_level\"`.\n * A single-segment name round-trips to exactly {@link quoteIdentifier}; whole-\n * string quoting (`\"auth.aal_level\"`) would be one wrong identifier.\n */\nexport function quoteQualifiedName(name: string): string {\n return name\n .split('.')\n .map((segment) => quoteIdentifier(segment))\n .join('.');\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n if (new TextEncoder().encode(value).length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-byte label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,YAAY;CAEjF,IAAI,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,KAAK,GAC/B,YACF;CAEF,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,EAAE,EAAE,4BAA4B,sBAAsB,uCAC3F;CAEF,OAAO,IAAI,WAAW,QAAQ,MAAM,MAAI,EAAE;AAC5C;;;;;;;;;;;;AAaA,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,IAAI,GACrB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,KAAK,GAC1B,SACF;CAEF,OAAO,MAAM,QAAQ,MAAM,IAAI;AACjC;;;;AAKA,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,UAAU,EAAE,GAAG,gBAAgB,UAAU;AACrE;;;;;;;AAQA,SAAgB,mBAAmB,MAAsB;CACvD,OAAO,KACJ,MAAM,GAAG,CAAC,CACV,KAAK,YAAY,gBAAgB,OAAO,CAAC,CAAC,CAC1C,KAAK,GAAG;AACb;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,SAAS,uBAC3C,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,EAAE,EAAE,iBAAiB,aAAa,yBAC3D,sBAAsB,oBAC3B,OACA,SACF;AAEJ"}
@@ -42,6 +42,13 @@ declare function escapeLiteral(value: string): string;
42
42
  * Builds a qualified name (schema.object) with proper quoting.
43
43
  */
44
44
  declare function qualifyName(schemaName: string, objectName: string): string;
45
+ /**
46
+ * Quotes a possibly dot-qualified name segment-by-segment:
47
+ * `order_status` -> `"order_status"`, `auth.aal_level` -> `"auth"."aal_level"`.
48
+ * A single-segment name round-trips to exactly {@link quoteIdentifier}; whole-
49
+ * string quoting (`"auth.aal_level"`) would be one wrong identifier.
50
+ */
51
+ declare function quoteQualifiedName(name: string): string;
45
52
  /**
46
53
  * Validates that an enum value doesn't exceed PostgreSQL's label length limit.
47
54
  *
@@ -55,5 +62,5 @@ declare function qualifyName(schemaName: string, objectName: string): string;
55
62
  */
56
63
  declare function validateEnumValueLength(value: string, enumTypeName: string): void;
57
64
  //#endregion
58
- export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
65
+ export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, quoteQualifiedName, validateEnumValueLength };
59
66
  //# sourceMappingURL=sql-utils.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAK;EAAA,SAGrB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;;;AAmB8B;AA8BlD;;;;AAA2C;AAc3C;;iBA5CgB,eAAA,CAAgB,UAAkB;;AA4CgB;AAelE;;;;AAA2E;;;;;iBA7B3D,aAAA,CAAc,KAAa;;;;iBAc3B,WAAA,CAAY,UAAA,UAAoB,UAAkB;;;;;;;;;;;;iBAelD,uBAAA,CAAwB,KAAA,UAAe,YAAoB"}
1
+ {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAK;EAAA,SAGrB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;;;AAmB8B;AA8BlD;;;;AAA2C;AAc3C;;iBA5CgB,eAAA,CAAgB,UAAkB;;AA4CgB;AAUlE;;;;AAA+C;AAkB/C;;;;iBA1CgB,aAAA,CAAc,KAAa;;;;iBAc3B,WAAA,CAAY,UAAA,UAAoB,UAAkB;;;;;;;iBAUlD,kBAAA,CAAmB,IAAY;;;;;;;;;;;;iBAkB/B,uBAAA,CAAwB,KAAA,UAAe,YAAoB"}
@@ -1,2 +1,2 @@
1
- import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-DcfMz4MQ.mjs";
2
- export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
1
+ import { a as quoteQualifiedName, i as quoteIdentifier, n as escapeLiteral, o as validateEnumValueLength, r as qualifyName, t as SqlEscapeError } from "./sql-utils-SU4FDvIV.mjs";
2
+ export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, quoteQualifiedName, validateEnumValueLength };
package/dist/types.d.mts CHANGED
@@ -1,141 +1,5 @@
1
- import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
1
+ import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNodeInput, d as PostgresNativeEnumSchemaNode, f as PostgresNativeEnumSchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresPolicySchemaNode, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresTableSchemaNode, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNodeInput } from "./postgres-database-schema-node-CJv5bfbs.mjs";
2
+ import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.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 PostgresNativeEnumInput, i as isPostgresSchema, l as PostgresRlsEnablementInput, n as PostgresSchema, o as PostgresRole, r as PostgresUnboundSchema, s as PostgresRoleInput, t as PostgresContract, u as PostgresNativeEnum } from "./postgres-schema-DKq6s1P3.mjs";
5
+ export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresNativeEnum, type PostgresNativeEnumInput, PostgresNativeEnumSchemaNode, type PostgresNativeEnumSchemaNodeInput, 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-BwVNf0Ku.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-Cm4DtiGA.mjs";
3
+ import { n as PostgresNativeEnumSchemaNode, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-D6LvInCe.mjs";
4
+ import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-Cm-j0ZGM.mjs";
5
+ export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnum, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRlsEnablement, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema, PostgresTableSchemaNode, PostgresUnboundSchema, isPostgresSchema, postgresCreateNamespace };
@@ -0,0 +1,104 @@
1
+ import { createHash } from "node:crypto";
2
+ //#region src/core/rls/canonicalize.ts
3
+ /**
4
+ * Which predicate each RLS operation admits, mirroring Postgres: SELECT and
5
+ * DELETE decide row visibility/eligibility with `USING` only; INSERT
6
+ * validates the new row with `WITH CHECK` only; UPDATE and ALL take either
7
+ * or both. Single-homed here so the PSL lowering and the TS handle
8
+ * constructors enforce the same matrix.
9
+ */
10
+ const POLICY_OPERATION_PREDICATES = {
11
+ select: {
12
+ using: true,
13
+ withCheck: false
14
+ },
15
+ insert: {
16
+ using: false,
17
+ withCheck: true
18
+ },
19
+ update: {
20
+ using: true,
21
+ withCheck: true
22
+ },
23
+ delete: {
24
+ using: true,
25
+ withCheck: false
26
+ },
27
+ all: {
28
+ using: true,
29
+ withCheck: true
30
+ }
31
+ };
32
+ /**
33
+ * Stabilizes an authored predicate for hashing: trim, and collapse runs of
34
+ * internal whitespace to a single space.
35
+ *
36
+ * This is deliberately minimal. The content hash is the equivalence relation
37
+ * for a policy, and the wire name (prefix + hash) is the only thing ever
38
+ * compared — we never recompute the hash from an introspected policy body, so
39
+ * there is no need to match Postgres's reprinted form. Minimal normalization
40
+ * also protects the no-collision property: aggressive rewriting (lowercasing,
41
+ * paren-stripping, cast-alias folding) risks collapsing two distinct predicates
42
+ * onto one hash. Out-of-band alteration of a hashed policy is unsupported.
43
+ *
44
+ * The normalizer is a stability commitment: any change re-suffixes all wire names.
45
+ */
46
+ function normalizePredicate(sql) {
47
+ return sql.replace(/\s+/g, " ").trim();
48
+ }
49
+ /**
50
+ * Returns the first 8 lowercase hex characters of the SHA-256 digest over the
51
+ * canonical content tuple for an RLS policy:
52
+ *
53
+ * [normalize(using), normalize(withCheck), sortedRoles, operation, permissive]
54
+ *
55
+ * Schema and table are excluded (they are orthogonal to policy equivalence).
56
+ * Uses `JSON.stringify` for a deterministic encoding.
57
+ */
58
+ function computeContentHash(parts) {
59
+ const using = normalizePredicate(parts.using ?? "");
60
+ const withCheck = normalizePredicate(parts.withCheck ?? "");
61
+ const roles = [...new Set(parts.roles)].sort();
62
+ const permissive = parts.permissive ? "permissive" : "restrictive";
63
+ const tuple = JSON.stringify([
64
+ using,
65
+ withCheck,
66
+ roles,
67
+ parts.operation,
68
+ permissive
69
+ ]);
70
+ return createHash("sha256").update(tuple).digest("hex").slice(0, 8);
71
+ }
72
+ //#endregion
73
+ //#region src/core/rls/wire-name.ts
74
+ const WIRE_NAME_PATTERN = /^(.+)_([0-9a-f]{8})$/;
75
+ /**
76
+ * Assembles an RLS policy wire name from its user-supplied prefix and its
77
+ * 8-hex content-hash suffix. This module owns the `<prefix>_<hash>` format
78
+ * on both sides — construction here and parsing in
79
+ * {@link parseRlsPolicyWireName} — so the two never drift.
80
+ */
81
+ function formatRlsPolicyWireName(prefix, hash) {
82
+ return `${prefix}_${hash}`;
83
+ }
84
+ /**
85
+ * Splits an RLS policy wire name (`<prefix>_<8hex>`) into its prefix and
86
+ * content-hash suffix. Returns `undefined` when the name does not follow the
87
+ * wire-name shape (e.g. a policy created outside the toolchain) — callers
88
+ * treat such names as all-prefix. Consumed by introspection (prefix
89
+ * extraction) and by rename pairing (same hash, different prefix).
90
+ */
91
+ function parseRlsPolicyWireName(name) {
92
+ const match = WIRE_NAME_PATTERN.exec(name);
93
+ const prefix = match?.[1];
94
+ const hash = match?.[2];
95
+ if (prefix === void 0 || hash === void 0) return void 0;
96
+ return {
97
+ prefix,
98
+ hash
99
+ };
100
+ }
101
+ //#endregion
102
+ export { normalizePredicate as a, computeContentHash as i, parseRlsPolicyWireName as n, POLICY_OPERATION_PREDICATES as r, formatRlsPolicyWireName as t };
103
+
104
+ //# sourceMappingURL=wire-name-DbQ9-2RC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-name-DbQ9-2RC.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\n/**\n * Which predicate each RLS operation admits, mirroring Postgres: SELECT and\n * DELETE decide row visibility/eligibility with `USING` only; INSERT\n * validates the new row with `WITH CHECK` only; UPDATE and ALL take either\n * or both. Single-homed here so the PSL lowering and the TS handle\n * constructors enforce the same matrix.\n */\nexport const POLICY_OPERATION_PREDICATES: Readonly<\n Record<RlsPolicyOperation, { readonly using: boolean; readonly withCheck: boolean }>\n> = {\n select: { using: true, withCheck: false },\n insert: { using: false, withCheck: true },\n update: { using: true, withCheck: true },\n delete: { using: true, withCheck: false },\n all: { using: true, withCheck: true },\n};\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":";;;;;;;;;AAWA,MAAa,8BAET;CACF,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAM;CACxC,QAAQ;EAAE,OAAO;EAAO,WAAW;CAAK;CACxC,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAK;CACvC,QAAQ;EAAE,OAAO;EAAM,WAAW;CAAM;CACxC,KAAK;EAAE,OAAO;EAAM,WAAW;CAAK;AACtC;;;;;;;;;;;;;;;AAwBA,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;;;ACzDA,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,35 +1,38 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.14.0-dev.9",
3
+ "version": "0.14.0-dev.90",
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.9",
10
- "@prisma-next/contract": "0.14.0-dev.9",
11
- "@prisma-next/errors": "0.14.0-dev.9",
12
- "@prisma-next/family-sql": "0.14.0-dev.9",
13
- "@prisma-next/framework-components": "0.14.0-dev.9",
14
- "@prisma-next/migration-tools": "0.14.0-dev.9",
15
- "@prisma-next/ts-render": "0.14.0-dev.9",
16
- "@prisma-next/sql-contract": "0.14.0-dev.9",
17
- "@prisma-next/sql-errors": "0.14.0-dev.9",
18
- "@prisma-next/sql-operations": "0.14.0-dev.9",
19
- "@prisma-next/sql-relational-core": "0.14.0-dev.9",
20
- "@prisma-next/sql-schema-ir": "0.14.0-dev.9",
21
- "@prisma-next/utils": "0.14.0-dev.9",
9
+ "@prisma-next/cli": "0.14.0-dev.90",
10
+ "@prisma-next/contract": "0.14.0-dev.90",
11
+ "@prisma-next/errors": "0.14.0-dev.90",
12
+ "@prisma-next/family-sql": "0.14.0-dev.90",
13
+ "@prisma-next/framework-components": "0.14.0-dev.90",
14
+ "@prisma-next/migration-tools": "0.14.0-dev.90",
15
+ "@prisma-next/psl-parser": "0.14.0-dev.90",
16
+ "@prisma-next/sql-contract": "0.14.0-dev.90",
17
+ "@prisma-next/sql-errors": "0.14.0-dev.90",
18
+ "@prisma-next/sql-operations": "0.14.0-dev.90",
19
+ "@prisma-next/sql-relational-core": "0.14.0-dev.90",
20
+ "@prisma-next/sql-schema-ir": "0.14.0-dev.90",
21
+ "@prisma-next/ts-render": "0.14.0-dev.90",
22
+ "@prisma-next/utils": "0.14.0-dev.90",
22
23
  "@standard-schema/spec": "^1.1.0",
23
- "arktype": "^2.2.0",
24
+ "arktype": "^2.2.2",
24
25
  "pathe": "^2.0.3"
25
26
  },
26
27
  "devDependencies": {
27
- "@prisma-next/test-utils": "0.14.0-dev.9",
28
- "@prisma-next/tsconfig": "0.14.0-dev.9",
29
- "@prisma-next/tsdown": "0.14.0-dev.9",
30
- "tsdown": "0.22.1",
28
+ "@prisma-next/psl-printer": "0.14.0-dev.90",
29
+ "@prisma-next/sql-contract-psl": "0.14.0-dev.90",
30
+ "@prisma-next/test-utils": "0.14.0-dev.90",
31
+ "@prisma-next/tsconfig": "0.14.0-dev.90",
32
+ "@prisma-next/tsdown": "0.14.0-dev.90",
33
+ "tsdown": "0.22.3",
31
34
  "typescript": "5.9.3",
32
- "vitest": "4.1.8"
35
+ "vitest": "4.1.10"
33
36
  },
34
37
  "peerDependencies": {
35
38
  "typescript": ">=5.9"
@@ -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"