@prisma-next/target-postgres 0.14.0-dev.5 → 0.14.0-dev.51

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 (238) hide show
  1. package/dist/authoring-DzHOdWTl.mjs +364 -0
  2. package/dist/authoring-DzHOdWTl.mjs.map +1 -0
  3. package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
  4. package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
  5. package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
  6. package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
  7. package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
  8. package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
  9. package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
  10. package/dist/codec-ids-C_-Hj6bL.mjs.map +1 -0
  11. package/dist/codec-ids.d.mts +2 -2
  12. package/dist/codec-ids.mjs +2 -2
  13. package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-BDVmvKAW.d.mts} +3 -2
  14. package/dist/codec-types-BDVmvKAW.d.mts.map +1 -0
  15. package/dist/codec-types.d.mts +1 -1
  16. package/dist/{codecs--0A5_4Bq.d.mts → codecs-Dk2sxGLv.d.mts} +77 -4
  17. package/dist/codecs-Dk2sxGLv.d.mts.map +1 -0
  18. package/dist/codecs.d.mts +1 -1
  19. package/dist/codecs.mjs +117 -2
  20. package/dist/codecs.mjs.map +1 -1
  21. package/dist/contract-free.d.mts +8 -3
  22. package/dist/contract-free.d.mts.map +1 -1
  23. package/dist/contract-free.mjs +4 -4
  24. package/dist/control-policy-DUFgy9jO.mjs +1103 -0
  25. package/dist/control-policy-DUFgy9jO.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 +757 -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-ujxH2A7r.mjs} +63 -6
  35. package/dist/ddl-ujxH2A7r.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-CuGDsrG4.mjs +19 -0
  43. package/dist/descriptor-meta-CuGDsrG4.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-BmSmWcaY.mjs +313 -0
  47. package/dist/diff-database-schema-BmSmWcaY.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/issue-planner.d.mts +35 -11
  52. package/dist/issue-planner.d.mts.map +1 -1
  53. package/dist/issue-planner.mjs +2 -2
  54. package/dist/migration.d.mts +5 -5
  55. package/dist/migration.d.mts.map +1 -1
  56. package/dist/migration.mjs +4 -4
  57. package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
  58. package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
  59. package/dist/native-type-normalizer.mjs +37 -1
  60. package/dist/native-type-normalizer.mjs.map +1 -0
  61. package/dist/nodes-CSkPX3rI.d.mts +120 -0
  62. package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
  63. package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
  64. package/dist/nodes-Dh__NS58.mjs.map +1 -0
  65. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-BKRnMgrB.mjs} +205 -31
  66. package/dist/op-factory-call-BKRnMgrB.mjs.map +1 -0
  67. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Dt-Jx5JS.d.mts} +46 -15
  68. package/dist/op-factory-call-Dt-Jx5JS.d.mts.map +1 -0
  69. package/dist/op-factory-call.d.mts +2 -2
  70. package/dist/op-factory-call.mjs +2 -2
  71. package/dist/pack.d.mts +115 -3
  72. package/dist/pack.d.mts.map +1 -1
  73. package/dist/pack.mjs +1 -1
  74. package/dist/planner-BMBRPzsv.mjs +367 -0
  75. package/dist/planner-BMBRPzsv.mjs.map +1 -0
  76. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  77. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  78. package/dist/planner-ddl-builders.d.mts +4 -6
  79. package/dist/planner-ddl-builders.d.mts.map +1 -1
  80. package/dist/planner-ddl-builders.mjs +2 -2
  81. package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
  82. package/dist/planner-identity-values.d.mts +8 -2
  83. package/dist/planner-identity-values.d.mts.map +1 -1
  84. package/dist/planner-identity-values.mjs +2 -2
  85. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-C0a7I1-e.d.mts} +4 -4
  86. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-C0a7I1-e.d.mts.map} +1 -1
  87. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-Dp6IO_gj.mjs} +3 -3
  88. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-Dp6IO_gj.mjs.map} +1 -1
  89. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  90. package/dist/planner-produced-postgres-migration.mjs +1 -1
  91. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-Cze3vMfe.mjs} +2 -2
  92. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-Cze3vMfe.mjs.map} +1 -1
  93. package/dist/planner-sql-checks.d.mts +2 -2
  94. package/dist/planner-sql-checks.d.mts.map +1 -1
  95. package/dist/planner-sql-checks.mjs +1 -1
  96. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  97. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  98. package/dist/planner-target-details.d.mts +1 -1
  99. package/dist/planner.d.mts +55 -17
  100. package/dist/planner.d.mts.map +1 -1
  101. package/dist/planner.mjs +3 -2
  102. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-3xfUgjnC.mjs} +44 -41
  103. package/dist/postgres-contract-view-3xfUgjnC.mjs.map +1 -0
  104. package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
  105. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
  106. package/dist/postgres-database-schema-node-C9bTuMrd.d.mts +190 -0
  107. package/dist/postgres-database-schema-node-C9bTuMrd.d.mts.map +1 -0
  108. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-D0jwzYDT.mjs} +21 -2
  109. package/dist/postgres-migration-D0jwzYDT.mjs.map +1 -0
  110. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DFaxuRyI.d.mts} +20 -7
  111. package/dist/postgres-migration-DFaxuRyI.d.mts.map +1 -0
  112. package/dist/postgres-native-enum-xdiqmBf_.mjs +41 -0
  113. package/dist/postgres-native-enum-xdiqmBf_.mjs.map +1 -0
  114. package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
  115. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  116. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-CajYAwny.mjs} +135 -7
  117. package/dist/postgres-schema-CajYAwny.mjs.map +1 -0
  118. package/dist/postgres-schema-DqnhQRvR.d.mts +226 -0
  119. package/dist/postgres-schema-DqnhQRvR.d.mts.map +1 -0
  120. package/dist/postgres-table-schema-node-BgaSrxYN.mjs +249 -0
  121. package/dist/postgres-table-schema-node-BgaSrxYN.mjs.map +1 -0
  122. package/dist/render-ops.d.mts +1 -1
  123. package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
  124. package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
  125. package/dist/render-typescript.mjs +1 -1
  126. package/dist/resolve-ddl-schema-Bv1ZvjX8.mjs +22 -0
  127. package/dist/resolve-ddl-schema-Bv1ZvjX8.mjs.map +1 -0
  128. package/dist/rls-canonicalize.d.mts +2 -0
  129. package/dist/rls-canonicalize.mjs +2 -0
  130. package/dist/runtime.d.mts +6 -8
  131. package/dist/runtime.d.mts.map +1 -1
  132. package/dist/runtime.mjs +3 -3
  133. package/dist/runtime.mjs.map +1 -1
  134. package/dist/schema-ir-annotations.d.mts +15 -0
  135. package/dist/schema-ir-annotations.d.mts.map +1 -0
  136. package/dist/schema-ir-annotations.mjs +2 -0
  137. package/dist/schema-node-kinds-ClScchhi.mjs +76 -0
  138. package/dist/schema-node-kinds-ClScchhi.mjs.map +1 -0
  139. package/dist/types.d.mts +4 -140
  140. package/dist/types.mjs +3 -2
  141. package/package.json +23 -17
  142. package/src/contract-free/checks.ts +73 -0
  143. package/src/contract-free/ddl.ts +45 -1
  144. package/src/core/authoring.ts +287 -2
  145. package/src/core/codec-ids.ts +1 -0
  146. package/src/core/codec-type-map.ts +2 -0
  147. package/src/core/codecs.ts +141 -1
  148. package/src/core/ddl/nodes.ts +94 -2
  149. package/src/core/default-normalizer.ts +122 -2
  150. package/src/core/descriptor-meta.ts +6 -1
  151. package/src/core/entity-kinds.ts +30 -0
  152. package/src/core/migrations/bound-schema.ts +10 -0
  153. package/src/core/migrations/column-ddl-rendering.ts +117 -0
  154. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +149 -0
  155. package/src/core/migrations/control-policy.ts +70 -47
  156. package/src/core/migrations/diff-database-schema.ts +280 -0
  157. package/src/core/migrations/issue-planner.ts +647 -652
  158. package/src/core/migrations/op-factory-call.ts +109 -21
  159. package/src/core/migrations/operations/columns.ts +24 -12
  160. package/src/core/migrations/operations/constraints.ts +1 -1
  161. package/src/core/migrations/operations/data-transform.ts +6 -0
  162. package/src/core/migrations/operations/dependencies.ts +2 -1
  163. package/src/core/migrations/operations/rls.ts +106 -0
  164. package/src/core/migrations/operations/shared.ts +0 -30
  165. package/src/core/migrations/planner-ddl-builders.ts +20 -58
  166. package/src/core/migrations/planner-identity-values.ts +1 -1
  167. package/src/core/migrations/planner-recipes.ts +31 -13
  168. package/src/core/migrations/planner-sql-checks.ts +1 -1
  169. package/src/core/migrations/planner-strategies.ts +248 -216
  170. package/src/core/migrations/planner-target-details.ts +3 -1
  171. package/src/core/migrations/planner.ts +297 -59
  172. package/src/core/migrations/postgres-migration.ts +34 -4
  173. package/src/core/migrations/render-typescript.ts +42 -15
  174. package/src/core/migrations/resolve-ddl-schema.ts +26 -0
  175. package/src/core/migrations/runner.ts +10 -16
  176. package/src/core/migrations/verify-postgres-namespaces.ts +47 -30
  177. package/src/core/namespace-ids.ts +3 -0
  178. package/src/core/postgres-contract-serializer.ts +41 -71
  179. package/src/core/postgres-contract-view.ts +48 -0
  180. package/src/core/postgres-native-enum.ts +51 -0
  181. package/src/core/postgres-rls-policy.ts +64 -0
  182. package/src/core/postgres-role.ts +37 -0
  183. package/src/core/postgres-schema-verifier.ts +10 -7
  184. package/src/core/postgres-schema.ts +62 -14
  185. package/src/core/postgres-validators.ts +27 -0
  186. package/src/core/psl-infer/infer-psl-contract.ts +1068 -0
  187. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  188. package/src/core/psl-infer/postgres-type-map.ts +157 -0
  189. package/src/core/rls/canonicalize.ts +48 -0
  190. package/src/core/schema-ir/postgres-database-schema-node.ts +60 -0
  191. package/src/core/schema-ir/postgres-namespace-schema-node.ts +60 -0
  192. package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
  193. package/src/core/schema-ir/postgres-role-schema-node.ts +63 -0
  194. package/src/core/schema-ir/postgres-table-schema-node.ts +118 -0
  195. package/src/core/schema-ir/schema-node-kinds.ts +106 -0
  196. package/src/exports/contract-free.ts +7 -1
  197. package/src/exports/control.ts +27 -33
  198. package/src/exports/ddl.ts +4 -0
  199. package/src/exports/diff-database-schema.ts +7 -0
  200. package/src/exports/issue-planner.ts +1 -1
  201. package/src/exports/migration.ts +1 -0
  202. package/src/exports/op-factory-call.ts +1 -0
  203. package/src/exports/planner-ddl-builders.ts +0 -2
  204. package/src/exports/planner-identity-values.ts +4 -1
  205. package/src/exports/planner.ts +1 -0
  206. package/src/exports/rls-canonicalize.ts +6 -0
  207. package/src/exports/runtime.ts +1 -0
  208. package/src/exports/schema-ir-annotations.ts +1 -0
  209. package/src/exports/types.ts +28 -0
  210. package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
  211. package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
  212. package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
  213. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  214. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  215. package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
  216. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  217. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  218. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  219. package/dist/issue-planner-DL6g3CmE.mjs +0 -824
  220. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  221. package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
  222. package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
  223. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  224. package/dist/nodes-pLeLgdis.d.mts +0 -67
  225. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  226. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  227. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  228. package/dist/planner-Bs_baQax.mjs +0 -324
  229. package/dist/planner-Bs_baQax.mjs.map +0 -1
  230. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  231. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  232. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  233. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  234. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  235. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  236. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  237. package/dist/types.d.mts.map +0 -1
  238. package/src/core/postgres-enum-type-schema.ts +0 -17
@@ -0,0 +1,364 @@
1
+ import { a as PG_ENUM_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
2
+ import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
3
+ import { d as PostgresRoleSchema, f as PostgresRole, l as PostgresNativeEnumSchema, p as PostgresRlsPolicy, u as PostgresRlsPolicySchema } from "./postgres-schema-CajYAwny.mjs";
4
+ import { n as normalizePredicate, t as computeContentHash } from "./canonicalize-Bn3BM1Cn.mjs";
5
+ import { temporalAuthoringPresets } from "@prisma-next/family-sql/control";
6
+ //#region src/core/authoring.ts
7
+ /**
8
+ * `pg.enum(<ref>)` registers as an ordinary type constructor whose sole
9
+ * positional argument names a `native_enum` entity instead of carrying a
10
+ * literal value. The interpreter resolves the ref to the `native_enum`
11
+ * entity generically (driven by `entityRefArg`); the `pg/enum@1` codec
12
+ * descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that
13
+ * entity into the column's `typeParams` and native type.
14
+ */
15
+ const postgresAuthoringTypes = { pg: { enum: {
16
+ kind: "typeConstructor",
17
+ entityRefArg: {
18
+ index: 0,
19
+ entityKind: "native_enum"
20
+ },
21
+ output: { codecId: PG_ENUM_CODEC_ID }
22
+ } } };
23
+ function readRefParam(block, key) {
24
+ const param = block.parameters[key];
25
+ return param?.kind === "ref" ? param.identifier : void 0;
26
+ }
27
+ function readValueParam(block, key) {
28
+ const param = block.parameters[key];
29
+ return param?.kind === "value" ? param.raw : void 0;
30
+ }
31
+ function readListRefParams(block, key) {
32
+ const param = block.parameters[key];
33
+ if (param?.kind !== "list") return [];
34
+ return param.items.flatMap((item) => item.kind === "ref" ? [item.identifier] : []);
35
+ }
36
+ function unwrapQuotedString(raw) {
37
+ if (raw.startsWith("\"") && raw.endsWith("\"") && raw.length >= 2) return raw.slice(1, -1).replace(/\\"/g, "\"");
38
+ return raw;
39
+ }
40
+ function lowerRlsPolicyFromBlock(block, _ctx) {
41
+ const prefix = block.name;
42
+ const targetModelName = readRefParam(block, "target") ?? "";
43
+ const tableName = targetModelName.charAt(0).toLowerCase() + targetModelName.slice(1);
44
+ const roles = [...readListRefParams(block, "roles")].sort();
45
+ const using = unwrapQuotedString(readValueParam(block, "using") ?? "");
46
+ return new PostgresRlsPolicy({
47
+ name: `${prefix}_${computeContentHash({
48
+ using: normalizePredicate(using),
49
+ roles,
50
+ operation: "select",
51
+ permissive: true
52
+ })}`,
53
+ prefix,
54
+ tableName,
55
+ namespaceId: block.namespaceId,
56
+ operation: "select",
57
+ roles,
58
+ using,
59
+ permissive: true
60
+ });
61
+ }
62
+ /**
63
+ * Lowers a `native_enum { memberName = "value" … @@map("type_name") }` block
64
+ * into a {@link PostgresNativeEnum}. Members must be authored as explicit
65
+ * `key = "value"` pairs — a bare (value-less) member is a diagnostic, not
66
+ * accepted (authoring-design.md §2.1). The parsed `memberName` is only used
67
+ * to duplicate-check and report diagnostics; the lowered entity carries just
68
+ * the member values (a native enum is value-only — the member "name" isn't
69
+ * a separate authoring concept from the value). `typeName` comes from
70
+ * `@@map` or defaults to the block name verbatim.
71
+ */
72
+ function lowerNativeEnumFromBlock(block, ctx) {
73
+ const sourceId = ctx.sourceId ?? "unknown";
74
+ const diagnostics = ctx.diagnostics;
75
+ const mapAttr = block.blockAttributes.find((a) => a.name === "map");
76
+ let typeName = block.name;
77
+ if (mapAttr) {
78
+ const rawArg = mapAttr.args[0]?.value;
79
+ const mapped = rawArg !== void 0 ? unwrapQuotedString(rawArg) : void 0;
80
+ if (mapped === void 0) {
81
+ diagnostics?.push({
82
+ code: "PSL_NATIVE_ENUM_INVALID_MAP",
83
+ message: `native_enum "${block.name}" @@map attribute must have a quoted type-name argument`,
84
+ sourceId,
85
+ span: mapAttr.span
86
+ });
87
+ return;
88
+ }
89
+ typeName = mapped;
90
+ }
91
+ let memberError = false;
92
+ const seenValues = /* @__PURE__ */ new Set();
93
+ const members = [];
94
+ for (const [memberName, paramValue] of Object.entries(block.parameters)) {
95
+ if (paramValue.kind === "bare") {
96
+ diagnostics?.push({
97
+ code: "PSL_NATIVE_ENUM_BARE_MEMBER",
98
+ message: `native_enum "${block.name}" member "${memberName}" has no value; members must be authored as "${memberName} = \\"value\\""`,
99
+ sourceId,
100
+ span: paramValue.span
101
+ });
102
+ memberError = true;
103
+ continue;
104
+ }
105
+ if (paramValue.kind !== "value") continue;
106
+ let jsonValue;
107
+ try {
108
+ jsonValue = JSON.parse(paramValue.raw);
109
+ } catch {
110
+ diagnostics?.push({
111
+ code: "PSL_EXTENSION_INVALID_VALUE",
112
+ message: `native_enum "${block.name}" member "${memberName}" value "${paramValue.raw}" is not valid JSON`,
113
+ sourceId,
114
+ span: paramValue.span
115
+ });
116
+ memberError = true;
117
+ continue;
118
+ }
119
+ if (typeof jsonValue !== "string") {
120
+ diagnostics?.push({
121
+ code: "PSL_EXTENSION_INVALID_VALUE",
122
+ message: `native_enum "${block.name}" member "${memberName}" value must be a string`,
123
+ sourceId,
124
+ span: paramValue.span
125
+ });
126
+ memberError = true;
127
+ continue;
128
+ }
129
+ if (seenValues.has(jsonValue)) {
130
+ diagnostics?.push({
131
+ code: "PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE",
132
+ message: `native_enum "${block.name}": duplicate member value "${jsonValue}"`,
133
+ sourceId,
134
+ span: paramValue.span
135
+ });
136
+ memberError = true;
137
+ continue;
138
+ }
139
+ seenValues.add(jsonValue);
140
+ members.push(jsonValue);
141
+ }
142
+ if (memberError) return void 0;
143
+ if (members.length === 0) {
144
+ diagnostics?.push({
145
+ code: "PSL_NATIVE_ENUM_MISSING_MEMBERS",
146
+ message: `native_enum "${block.name}" must have at least one member`,
147
+ sourceId,
148
+ span: block.span
149
+ });
150
+ return;
151
+ }
152
+ return new PostgresNativeEnum({
153
+ typeName,
154
+ members
155
+ });
156
+ }
157
+ const postgresAuthoringEntityTypes = {
158
+ role: {
159
+ kind: "entity",
160
+ discriminator: "role",
161
+ validatorSchema: PostgresRoleSchema,
162
+ output: { factory: (input) => new PostgresRole(input) }
163
+ },
164
+ policy: {
165
+ kind: "entity",
166
+ discriminator: "policy",
167
+ validatorSchema: PostgresRlsPolicySchema,
168
+ output: { factory: lowerRlsPolicyFromBlock }
169
+ },
170
+ native_enum: {
171
+ kind: "entity",
172
+ discriminator: "native_enum",
173
+ validatorSchema: PostgresNativeEnumSchema,
174
+ output: {
175
+ factory: lowerNativeEnumFromBlock,
176
+ deriveValueSet: (entity) => ({
177
+ kind: "valueSet",
178
+ values: [...entity.members]
179
+ })
180
+ }
181
+ }
182
+ };
183
+ /**
184
+ * Field presets contributed by the Postgres target pack.
185
+ *
186
+ * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter
187
+ * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field
188
+ * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar
189
+ * surface (e.g. `Int`) lowers to byte-identical contracts.
190
+ *
191
+ * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the
192
+ * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target
193
+ * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from
194
+ * the family pack instead.
195
+ */
196
+ /**
197
+ * PSL block descriptor for `policy_select`.
198
+ *
199
+ * The parser learns the block shape from this descriptor; lowering from
200
+ * `PslExtensionBlock` to `PostgresRlsPolicy` is wired in the PSL
201
+ * interpreter (a later dispatch). The `discriminator` matches
202
+ * `PostgresRlsPolicy.kind` so the parsed block node carries the same
203
+ * discriminant as the IR class it will lower to.
204
+ *
205
+ * The `roles` list uses `scope:'cross-space'` because same-namespace
206
+ * role ref resolution requires PSL namespace entries keyed by `refKind`
207
+ * (i.e. `'role'`), which in turn requires the role block discriminator to
208
+ * equal `'role'`. Aligning discriminator with refKind is tracked for
209
+ * slice 4 (cross-space roles). Until then cross-space passes validation
210
+ * unconditionally and the authored role names flow through unchanged.
211
+ */
212
+ const postgresAuthoringPslBlockDescriptors = {
213
+ policy_select: {
214
+ kind: "pslBlock",
215
+ keyword: "policy_select",
216
+ discriminator: "policy",
217
+ name: { required: true },
218
+ parameters: {
219
+ target: {
220
+ kind: "ref",
221
+ refKind: "model",
222
+ scope: "same-namespace",
223
+ required: true
224
+ },
225
+ roles: {
226
+ kind: "list",
227
+ of: {
228
+ kind: "ref",
229
+ refKind: "role",
230
+ scope: "cross-space"
231
+ }
232
+ },
233
+ using: {
234
+ kind: "value",
235
+ codecId: "pg/text@1",
236
+ required: true
237
+ }
238
+ }
239
+ },
240
+ /**
241
+ * PSL block descriptor for `native_enum`.
242
+ *
243
+ * Reuses the existing variadic-block mechanism (the same shape the SQL
244
+ * family's `enum` block ships): the body is an open `memberName = "value"`
245
+ * list. `variadicParameters: true` opens the block to arbitrary keys
246
+ * beyond the declared (empty) `parameters` set — the lowering factory
247
+ * (`lowerNativeEnumFromBlock`) turns the variadic entries into ordered
248
+ * members and rejects a bare (value-less) member.
249
+ */
250
+ native_enum: {
251
+ kind: "pslBlock",
252
+ keyword: "native_enum",
253
+ discriminator: "native_enum",
254
+ name: { required: true },
255
+ parameters: {},
256
+ variadicParameters: true
257
+ }
258
+ };
259
+ const postgresAuthoringFieldPresets = {
260
+ text: {
261
+ kind: "fieldPreset",
262
+ output: {
263
+ codecId: "pg/text@1",
264
+ nativeType: "text"
265
+ }
266
+ },
267
+ int: {
268
+ kind: "fieldPreset",
269
+ output: {
270
+ codecId: "pg/int4@1",
271
+ nativeType: "int4"
272
+ }
273
+ },
274
+ bigint: {
275
+ kind: "fieldPreset",
276
+ output: {
277
+ codecId: "pg/int8@1",
278
+ nativeType: "int8"
279
+ }
280
+ },
281
+ float: {
282
+ kind: "fieldPreset",
283
+ output: {
284
+ codecId: "pg/float8@1",
285
+ nativeType: "float8"
286
+ }
287
+ },
288
+ decimal: {
289
+ kind: "fieldPreset",
290
+ output: {
291
+ codecId: "pg/numeric@1",
292
+ nativeType: "numeric"
293
+ }
294
+ },
295
+ boolean: {
296
+ kind: "fieldPreset",
297
+ output: {
298
+ codecId: "pg/bool@1",
299
+ nativeType: "bool"
300
+ }
301
+ },
302
+ json: {
303
+ kind: "fieldPreset",
304
+ output: {
305
+ codecId: "pg/jsonb@1",
306
+ nativeType: "jsonb"
307
+ }
308
+ },
309
+ bytes: {
310
+ kind: "fieldPreset",
311
+ output: {
312
+ codecId: "pg/bytea@1",
313
+ nativeType: "bytea"
314
+ }
315
+ },
316
+ dateTime: {
317
+ kind: "fieldPreset",
318
+ output: {
319
+ codecId: "pg/timestamptz@1",
320
+ nativeType: "timestamptz"
321
+ }
322
+ },
323
+ temporal: /* @__PURE__ */ temporalAuthoringPresets({
324
+ codecId: "pg/timestamptz@1",
325
+ nativeType: "timestamptz"
326
+ }),
327
+ uuidNative: {
328
+ kind: "fieldPreset",
329
+ output: {
330
+ codecId: "pg/uuid@1",
331
+ nativeType: "uuid"
332
+ }
333
+ },
334
+ id: {
335
+ uuidv4Native: {
336
+ kind: "fieldPreset",
337
+ output: {
338
+ codecId: "pg/uuid@1",
339
+ nativeType: "uuid",
340
+ executionDefaults: { onCreate: {
341
+ kind: "generator",
342
+ id: "uuidv4"
343
+ } },
344
+ id: true
345
+ }
346
+ },
347
+ uuidv7Native: {
348
+ kind: "fieldPreset",
349
+ output: {
350
+ codecId: "pg/uuid@1",
351
+ nativeType: "uuid",
352
+ executionDefaults: { onCreate: {
353
+ kind: "generator",
354
+ id: "uuidv7"
355
+ } },
356
+ id: true
357
+ }
358
+ }
359
+ }
360
+ };
361
+ //#endregion
362
+ export { postgresAuthoringTypes as i, postgresAuthoringFieldPresets as n, postgresAuthoringPslBlockDescriptors as r, postgresAuthoringEntityTypes as t };
363
+
364
+ //# sourceMappingURL=authoring-DzHOdWTl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-DzHOdWTl.mjs","names":[],"sources":["../src/core/authoring.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type {\n AuthoringEntityContext,\n AuthoringEntityTypeFactoryOutput,\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringPslBlockDescriptorNamespace,\n AuthoringTypeNamespace,\n PslExtensionBlock,\n} from '@prisma-next/framework-components/authoring';\nimport type { SqlValueSetDerivingEntityTypeOutput } from '@prisma-next/sql-contract/value-set-derivation-hook';\nimport { PG_ENUM_CODEC_ID } from './codec-ids';\nimport { PostgresNativeEnum } from './postgres-native-enum';\nimport { PostgresRlsPolicy } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport {\n PostgresNativeEnumSchema,\n PostgresRlsPolicySchema,\n PostgresRoleSchema,\n} from './postgres-validators';\nimport { computeContentHash, normalizePredicate } from './rls/canonicalize';\n\n/**\n * `pg.enum(<ref>)` registers as an ordinary type constructor whose sole\n * positional argument names a `native_enum` entity instead of carrying a\n * literal value. The interpreter resolves the ref to the `native_enum`\n * entity generically (driven by `entityRefArg`); the `pg/enum@1` codec\n * descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that\n * entity into the column's `typeParams` and native type.\n */\nexport const postgresAuthoringTypes = {\n pg: {\n enum: {\n kind: 'typeConstructor',\n entityRefArg: { index: 0, entityKind: 'native_enum' },\n output: {\n codecId: PG_ENUM_CODEC_ID,\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n\nexport interface RlsPolicyExtensionBlock extends PslExtensionBlock {\n readonly namespaceId: string;\n}\n\nfunction readRefParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'ref' ? param.identifier : undefined;\n}\n\nfunction readValueParam(block: PslExtensionBlock, key: string): string | undefined {\n const param = block.parameters[key];\n return param?.kind === 'value' ? param.raw : undefined;\n}\n\nfunction readListRefParams(block: PslExtensionBlock, key: string): string[] {\n const param = block.parameters[key];\n if (param?.kind !== 'list') return [];\n return param.items.flatMap((item) => (item.kind === 'ref' ? [item.identifier] : []));\n}\n\nfunction unwrapQuotedString(raw: string): string {\n if (raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2) {\n return raw.slice(1, -1).replace(/\\\\\"/g, '\"');\n }\n return raw;\n}\n\nfunction lowerRlsPolicyFromBlock(\n block: RlsPolicyExtensionBlock,\n _ctx: AuthoringEntityContext,\n): PostgresRlsPolicy {\n const prefix = block.name;\n const targetModelName = readRefParam(block, 'target') ?? '';\n const tableName = targetModelName.charAt(0).toLowerCase() + targetModelName.slice(1);\n const roles = [...readListRefParams(block, 'roles')].sort();\n const using = unwrapQuotedString(readValueParam(block, 'using') ?? '');\n\n const wireHash = computeContentHash({\n using: normalizePredicate(using),\n roles,\n operation: 'select',\n permissive: true,\n });\n const wireName = `${prefix}_${wireHash}`;\n\n return new PostgresRlsPolicy({\n name: wireName,\n prefix,\n tableName,\n namespaceId: block.namespaceId,\n operation: 'select',\n roles,\n using,\n permissive: true,\n });\n}\n\n/**\n * Lowers a `native_enum { memberName = \"value\" … @@map(\"type_name\") }` block\n * into a {@link PostgresNativeEnum}. Members must be authored as explicit\n * `key = \"value\"` pairs — a bare (value-less) member is a diagnostic, not\n * accepted (authoring-design.md §2.1). The parsed `memberName` is only used\n * to duplicate-check and report diagnostics; the lowered entity carries just\n * the member values (a native enum is value-only — the member \"name\" isn't\n * a separate authoring concept from the value). `typeName` comes from\n * `@@map` or defaults to the block name verbatim.\n */\nfunction lowerNativeEnumFromBlock(\n block: PslExtensionBlock,\n ctx: AuthoringEntityContext,\n): PostgresNativeEnum | undefined {\n const sourceId = ctx.sourceId ?? 'unknown';\n const diagnostics = ctx.diagnostics;\n\n const mapAttr = block.blockAttributes.find((a) => a.name === 'map');\n let typeName = block.name;\n if (mapAttr) {\n const rawArg = mapAttr.args[0]?.value;\n const mapped = rawArg !== undefined ? unwrapQuotedString(rawArg) : undefined;\n if (mapped === undefined) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_INVALID_MAP',\n message: `native_enum \"${block.name}\" @@map attribute must have a quoted type-name argument`,\n sourceId,\n span: mapAttr.span,\n });\n return undefined;\n }\n typeName = mapped;\n }\n\n let memberError = false;\n const seenValues = new Set<string>();\n const members: string[] = [];\n for (const [memberName, paramValue] of Object.entries(block.parameters)) {\n if (paramValue.kind === 'bare') {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_BARE_MEMBER',\n message: `native_enum \"${block.name}\" member \"${memberName}\" has no value; members must be authored as \"${memberName} = \\\\\"value\\\\\"\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (paramValue.kind !== 'value') continue;\n\n let jsonValue: unknown;\n try {\n jsonValue = JSON.parse(paramValue.raw);\n } catch {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value \"${paramValue.raw}\" is not valid JSON`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (typeof jsonValue !== 'string') {\n diagnostics?.push({\n code: 'PSL_EXTENSION_INVALID_VALUE',\n message: `native_enum \"${block.name}\" member \"${memberName}\" value must be a string`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n if (seenValues.has(jsonValue)) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE',\n message: `native_enum \"${block.name}\": duplicate member value \"${jsonValue}\"`,\n sourceId,\n span: paramValue.span,\n });\n memberError = true;\n continue;\n }\n seenValues.add(jsonValue);\n members.push(jsonValue);\n }\n\n if (memberError) return undefined;\n\n if (members.length === 0) {\n diagnostics?.push({\n code: 'PSL_NATIVE_ENUM_MISSING_MEMBERS',\n message: `native_enum \"${block.name}\" must have at least one member`,\n sourceId,\n span: block.span,\n });\n return undefined;\n }\n\n // `control` stays unset — the effective grade is resolved at read time via `effectiveControlPolicy`, like `StorageTable`/`StorageColumn`.\n return new PostgresNativeEnum({ typeName, members });\n}\n\n/**\n * `native_enum`'s entity-type factory output, checked separately from the assembled\n * `postgresAuthoringEntityTypes` map below: `deriveValueSet` is SQL-family surface\n * ({@link SqlValueSetDerivingEntityTypeOutput}), not part of the framework\n * `AuthoringEntityTypeFactoryOutput` shape, so folding it directly into the map's single\n * `satisfies AuthoringEntityTypeNamespace` check would trip an excess-property error. Checking it\n * here against the intersection of both shapes keeps it structurally valid against each without\n * widening the map's own check.\n */\nconst nativeEnumEntityTypeOutput = {\n factory: lowerNativeEnumFromBlock,\n deriveValueSet: (entity: PostgresNativeEnum) => ({\n kind: 'valueSet' as const,\n values: [...entity.members],\n }),\n} satisfies AuthoringEntityTypeFactoryOutput<PslExtensionBlock, PostgresNativeEnum | undefined> &\n SqlValueSetDerivingEntityTypeOutput;\n\nexport const postgresAuthoringEntityTypes = {\n role: {\n kind: 'entity',\n discriminator: 'role',\n validatorSchema: PostgresRoleSchema,\n output: {\n factory: (input: PostgresRoleInput): PostgresRole => new PostgresRole(input),\n },\n },\n policy: {\n kind: 'entity',\n discriminator: 'policy',\n validatorSchema: PostgresRlsPolicySchema,\n output: {\n factory: lowerRlsPolicyFromBlock,\n },\n },\n native_enum: {\n kind: 'entity',\n discriminator: 'native_enum',\n validatorSchema: PostgresNativeEnumSchema,\n output: nativeEnumEntityTypeOutput,\n },\n} as const satisfies AuthoringEntityTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n *\n * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n * the family pack instead.\n */\n/**\n * PSL block descriptor for `policy_select`.\n *\n * The parser learns the block shape from this descriptor; lowering from\n * `PslExtensionBlock` to `PostgresRlsPolicy` is wired in the PSL\n * interpreter (a later dispatch). The `discriminator` matches\n * `PostgresRlsPolicy.kind` so the parsed block node carries the same\n * discriminant as the IR class it will lower to.\n *\n * The `roles` list uses `scope:'cross-space'` because same-namespace\n * role ref resolution requires PSL namespace entries keyed by `refKind`\n * (i.e. `'role'`), which in turn requires the role block discriminator to\n * equal `'role'`. Aligning discriminator with refKind is tracked for\n * slice 4 (cross-space roles). Until then cross-space passes validation\n * unconditionally and the authored role names flow through unchanged.\n */\nexport const postgresAuthoringPslBlockDescriptors = {\n policy_select: {\n kind: 'pslBlock',\n keyword: 'policy_select',\n discriminator: 'policy',\n name: { required: true },\n parameters: {\n target: { kind: 'ref', refKind: 'model', scope: 'same-namespace', required: true },\n roles: {\n kind: 'list',\n of: { kind: 'ref', refKind: 'role', scope: 'cross-space' },\n },\n using: { kind: 'value', codecId: 'pg/text@1', required: true },\n },\n },\n /**\n * PSL block descriptor for `native_enum`.\n *\n * Reuses the existing variadic-block mechanism (the same shape the SQL\n * family's `enum` block ships): the body is an open `memberName = \"value\"`\n * list. `variadicParameters: true` opens the block to arbitrary keys\n * beyond the declared (empty) `parameters` set — the lowering factory\n * (`lowerNativeEnumFromBlock`) turns the variadic entries into ordered\n * members and rejects a bare (value-less) member.\n */\n native_enum: {\n kind: 'pslBlock',\n keyword: 'native_enum',\n discriminator: 'native_enum',\n name: { required: true },\n parameters: {},\n variadicParameters: true,\n },\n} as const satisfies AuthoringPslBlockDescriptorNamespace;\n\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n }),\n uuidNative: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n },\n },\n id: {\n uuidv4Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n"],"mappings":"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T,YAAY;EACd;CACF;CACA,SAAS;EACP,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAAU;EACR,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,UAA0B,yCAAyB;EACjD,SAAS;EACT,YAAY;CACd,CAAC;CACD,YAAY;EACV,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,IAAI;EACF,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;EACA,cAAc;GACZ,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,mBAAmB,EACjB,UAAU;KACR,MAAM;KACN,IAAI;IACN,EACF;IACA,IAAI;GACN;EACF;CACF;AACF"}
@@ -0,0 +1,46 @@
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
+ export { normalizePredicate as n, computeContentHash as t };
45
+
46
+ //# sourceMappingURL=canonicalize-Bn3BM1Cn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalize-Bn3BM1Cn.mjs","names":[],"sources":["../src/core/rls/canonicalize.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"],"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"}
@@ -0,0 +1,37 @@
1
+ //#region src/core/rls/canonicalize.d.ts
2
+ type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
3
+ interface ContentHashParts {
4
+ readonly using?: string;
5
+ readonly withCheck?: string;
6
+ readonly roles: readonly string[];
7
+ readonly operation: RlsPolicyOperation;
8
+ readonly permissive: boolean;
9
+ }
10
+ /**
11
+ * Stabilizes an authored predicate for hashing: trim, and collapse runs of
12
+ * internal whitespace to a single space.
13
+ *
14
+ * This is deliberately minimal. The content hash is the equivalence relation
15
+ * for a policy, and the wire name (prefix + hash) is the only thing ever
16
+ * compared — we never recompute the hash from an introspected policy body, so
17
+ * there is no need to match Postgres's reprinted form. Minimal normalization
18
+ * also protects the no-collision property: aggressive rewriting (lowercasing,
19
+ * paren-stripping, cast-alias folding) risks collapsing two distinct predicates
20
+ * onto one hash. Out-of-band alteration of a hashed policy is unsupported.
21
+ *
22
+ * The normalizer is a stability commitment: any change re-suffixes all wire names.
23
+ */
24
+ declare function normalizePredicate(sql: string): string;
25
+ /**
26
+ * Returns the first 8 lowercase hex characters of the SHA-256 digest over the
27
+ * canonical content tuple for an RLS policy:
28
+ *
29
+ * [normalize(using), normalize(withCheck), sortedRoles, operation, permissive]
30
+ *
31
+ * Schema and table are excluded (they are orthogonal to policy equivalence).
32
+ * Uses `JSON.stringify` for a deterministic encoding.
33
+ */
34
+ declare function computeContentHash(parts: ContentHashParts): string;
35
+ //#endregion
36
+ export { normalizePredicate as i, RlsPolicyOperation as n, computeContentHash as r, ContentHashParts as t };
37
+ //# sourceMappingURL=canonicalize-CAbXtVtB.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalize-CAbXtVtB.d.mts","names":[],"sources":["../src/core/rls/canonicalize.ts"],"mappings":";KAEY,kBAAA;AAAA,UAEK,gBAAA;EAAA,SACN,KAAA;EAAA,SACA,SAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA,EAAW,kBAAkB;EAAA,SAC7B,UAAA;AAAA;;;;;;;;;;AAAU;AAiBrB;;;;iBAAgB,kBAAA,CAAmB,GAAW;AAa9C;;;;AAA0D;;;;;AAA1D,iBAAgB,kBAAA,CAAmB,KAAuB,EAAhB,gBAAgB"}
@@ -3,6 +3,7 @@ import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC
3
3
  //#region src/core/codec-ids.d.ts
4
4
  declare const PG_TEXT_CODEC_ID: "pg/text@1";
5
5
  declare const PG_TEXT_ARRAY_CODEC_ID: "pg/text-array@1";
6
+ declare const PG_ENUM_CODEC_ID: "pg/enum@1";
6
7
  declare const PG_CHAR_CODEC_ID: "pg/char@1";
7
8
  declare const PG_VARCHAR_CODEC_ID: "pg/varchar@1";
8
9
  declare const PG_INT_CODEC_ID: "pg/int@1";
@@ -26,5 +27,5 @@ declare const PG_JSONB_CODEC_ID: "pg/jsonb@1";
26
27
  declare const PG_BYTEA_CODEC_ID: "pg/bytea@1";
27
28
  declare const PG_UUID_CODEC_ID: "pg/uuid@1";
28
29
  //#endregion
29
- export { SQL_VARCHAR_CODEC_ID as A, PG_VARBIT_CODEC_ID as C, SQL_INT_CODEC_ID as D, SQL_FLOAT_CODEC_ID as E, SQL_TEXT_CODEC_ID as O, PG_UUID_CODEC_ID as S, SQL_CHAR_CODEC_ID as T, PG_TEXT_CODEC_ID as _, PG_FLOAT4_CODEC_ID as a, PG_TIMETZ_CODEC_ID as b, PG_INT2_CODEC_ID as c, PG_INTERVAL_CODEC_ID as d, PG_INT_CODEC_ID as f, PG_TEXT_ARRAY_CODEC_ID as g, PG_NUMERIC_CODEC_ID as h, PG_CHAR_CODEC_ID as i, SQL_TIMESTAMP_CODEC_ID as k, PG_INT4_CODEC_ID as l, PG_JSON_CODEC_ID as m, PG_BOOL_CODEC_ID as n, PG_FLOAT8_CODEC_ID as o, PG_JSONB_CODEC_ID as p, PG_BYTEA_CODEC_ID as r, PG_FLOAT_CODEC_ID as s, PG_BIT_CODEC_ID as t, PG_INT8_CODEC_ID as u, PG_TIMESTAMPTZ_CODEC_ID as v, PG_VARCHAR_CODEC_ID as w, PG_TIME_CODEC_ID as x, PG_TIMESTAMP_CODEC_ID as y };
30
- //# sourceMappingURL=codec-ids-CnXu9Qy3.d.mts.map
30
+ export { SQL_TIMESTAMP_CODEC_ID as A, PG_UUID_CODEC_ID as C, SQL_FLOAT_CODEC_ID as D, SQL_CHAR_CODEC_ID as E, SQL_INT_CODEC_ID as O, PG_TIME_CODEC_ID as S, PG_VARCHAR_CODEC_ID as T, PG_TEXT_ARRAY_CODEC_ID as _, PG_ENUM_CODEC_ID as a, PG_TIMESTAMP_CODEC_ID as b, PG_FLOAT_CODEC_ID as c, PG_INT8_CODEC_ID as d, PG_INTERVAL_CODEC_ID as f, PG_NUMERIC_CODEC_ID as g, PG_JSON_CODEC_ID as h, PG_CHAR_CODEC_ID as i, SQL_VARCHAR_CODEC_ID as j, SQL_TEXT_CODEC_ID as k, PG_INT2_CODEC_ID as l, PG_JSONB_CODEC_ID as m, PG_BOOL_CODEC_ID as n, PG_FLOAT4_CODEC_ID as o, PG_INT_CODEC_ID as p, PG_BYTEA_CODEC_ID as r, PG_FLOAT8_CODEC_ID as s, PG_BIT_CODEC_ID as t, PG_INT4_CODEC_ID as u, PG_TEXT_CODEC_ID as v, PG_VARBIT_CODEC_ID as w, PG_TIMETZ_CODEC_ID as x, PG_TIMESTAMPTZ_CODEC_ID as y };
31
+ //# sourceMappingURL=codec-ids-BzrFF-I4.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-ids-BzrFF-I4.d.mts","names":[],"sources":["../src/core/codec-ids.ts"],"mappings":";;;cAQa,gBAAA;AAAA,cACA,sBAAA;AAAA,cACA,gBAAA;AAAA,cACA,gBAAA;AAAA,cACA,mBAAA;AAAA,cACA,eAAA;AAAA,cACA,gBAAA;AAAA,cACA,gBAAA;AAAA,cACA,gBAAA;AAAA,cACA,iBAAA;AAAA,cACA,kBAAA;AAAA,cACA,kBAAA;AAAA,cACA,mBAAA;AAAA,cACA,gBAAA;AAAA,cACA,eAAA;AAAA,cACA,kBAAA;AAAA,cACA,qBAAA;AAAA,cACA,uBAAA;AAAA,cACA,gBAAA;AAAA,cACA,kBAAA;AAAA,cACA,oBAAA;AAAA,cACA,gBAAA;AAAA,cACA,iBAAA;AAAA,cACA,iBAAA;AAAA,cACA,gBAAA"}
@@ -2,6 +2,7 @@ import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC
2
2
  //#region src/core/codec-ids.ts
3
3
  const PG_TEXT_CODEC_ID = "pg/text@1";
4
4
  const PG_TEXT_ARRAY_CODEC_ID = "pg/text-array@1";
5
+ const PG_ENUM_CODEC_ID = "pg/enum@1";
5
6
  const PG_CHAR_CODEC_ID = "pg/char@1";
6
7
  const PG_VARCHAR_CODEC_ID = "pg/varchar@1";
7
8
  const PG_INT_CODEC_ID = "pg/int@1";
@@ -25,6 +26,6 @@ const PG_JSONB_CODEC_ID = "pg/jsonb@1";
25
26
  const PG_BYTEA_CODEC_ID = "pg/bytea@1";
26
27
  const PG_UUID_CODEC_ID = "pg/uuid@1";
27
28
  //#endregion
28
- export { SQL_VARCHAR_CODEC_ID as A, PG_VARBIT_CODEC_ID as C, SQL_INT_CODEC_ID as D, SQL_FLOAT_CODEC_ID as E, SQL_TEXT_CODEC_ID as O, PG_UUID_CODEC_ID as S, SQL_CHAR_CODEC_ID as T, PG_TEXT_CODEC_ID as _, PG_FLOAT4_CODEC_ID as a, PG_TIMETZ_CODEC_ID as b, PG_INT2_CODEC_ID as c, PG_INTERVAL_CODEC_ID as d, PG_INT_CODEC_ID as f, PG_TEXT_ARRAY_CODEC_ID as g, PG_NUMERIC_CODEC_ID as h, PG_CHAR_CODEC_ID as i, SQL_TIMESTAMP_CODEC_ID as k, PG_INT4_CODEC_ID as l, PG_JSON_CODEC_ID as m, PG_BOOL_CODEC_ID as n, PG_FLOAT8_CODEC_ID as o, PG_JSONB_CODEC_ID as p, PG_BYTEA_CODEC_ID as r, PG_FLOAT_CODEC_ID as s, PG_BIT_CODEC_ID as t, PG_INT8_CODEC_ID as u, PG_TIMESTAMPTZ_CODEC_ID as v, PG_VARCHAR_CODEC_ID as w, PG_TIME_CODEC_ID as x, PG_TIMESTAMP_CODEC_ID as y };
29
+ export { SQL_TIMESTAMP_CODEC_ID as A, PG_UUID_CODEC_ID as C, SQL_FLOAT_CODEC_ID as D, SQL_CHAR_CODEC_ID as E, SQL_INT_CODEC_ID as O, PG_TIME_CODEC_ID as S, PG_VARCHAR_CODEC_ID as T, PG_TEXT_ARRAY_CODEC_ID as _, PG_ENUM_CODEC_ID as a, PG_TIMESTAMP_CODEC_ID as b, PG_FLOAT_CODEC_ID as c, PG_INT8_CODEC_ID as d, PG_INTERVAL_CODEC_ID as f, PG_NUMERIC_CODEC_ID as g, PG_JSON_CODEC_ID as h, PG_CHAR_CODEC_ID as i, SQL_VARCHAR_CODEC_ID as j, SQL_TEXT_CODEC_ID as k, PG_INT2_CODEC_ID as l, PG_JSONB_CODEC_ID as m, PG_BOOL_CODEC_ID as n, PG_FLOAT4_CODEC_ID as o, PG_INT_CODEC_ID as p, PG_BYTEA_CODEC_ID as r, PG_FLOAT8_CODEC_ID as s, PG_BIT_CODEC_ID as t, PG_INT4_CODEC_ID as u, PG_TEXT_CODEC_ID as v, PG_VARBIT_CODEC_ID as w, PG_TIMETZ_CODEC_ID as x, PG_TIMESTAMPTZ_CODEC_ID as y };
29
30
 
30
- //# sourceMappingURL=codec-ids-BvytN2P8.mjs.map
31
+ //# sourceMappingURL=codec-ids-C_-Hj6bL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-ids-C_-Hj6bL.mjs","names":[],"sources":["../src/core/codec-ids.ts"],"sourcesContent":["export {\n SQL_CHAR_CODEC_ID,\n SQL_FLOAT_CODEC_ID,\n SQL_INT_CODEC_ID,\n SQL_TEXT_CODEC_ID,\n SQL_TIMESTAMP_CODEC_ID,\n SQL_VARCHAR_CODEC_ID,\n} from '@prisma-next/sql-relational-core/ast';\nexport const PG_TEXT_CODEC_ID = 'pg/text@1' as const;\nexport const PG_TEXT_ARRAY_CODEC_ID = 'pg/text-array@1' as const;\nexport const PG_ENUM_CODEC_ID = 'pg/enum@1' as const;\nexport const PG_CHAR_CODEC_ID = 'pg/char@1' as const;\nexport const PG_VARCHAR_CODEC_ID = 'pg/varchar@1' as const;\nexport const PG_INT_CODEC_ID = 'pg/int@1' as const;\nexport const PG_INT2_CODEC_ID = 'pg/int2@1' as const;\nexport const PG_INT4_CODEC_ID = 'pg/int4@1' as const;\nexport const PG_INT8_CODEC_ID = 'pg/int8@1' as const;\nexport const PG_FLOAT_CODEC_ID = 'pg/float@1' as const;\nexport const PG_FLOAT4_CODEC_ID = 'pg/float4@1' as const;\nexport const PG_FLOAT8_CODEC_ID = 'pg/float8@1' as const;\nexport const PG_NUMERIC_CODEC_ID = 'pg/numeric@1' as const;\nexport const PG_BOOL_CODEC_ID = 'pg/bool@1' as const;\nexport const PG_BIT_CODEC_ID = 'pg/bit@1' as const;\nexport const PG_VARBIT_CODEC_ID = 'pg/varbit@1' as const;\nexport const PG_TIMESTAMP_CODEC_ID = 'pg/timestamp@1' as const;\nexport const PG_TIMESTAMPTZ_CODEC_ID = 'pg/timestamptz@1' as const;\nexport const PG_TIME_CODEC_ID = 'pg/time@1' as const;\nexport const PG_TIMETZ_CODEC_ID = 'pg/timetz@1' as const;\nexport const PG_INTERVAL_CODEC_ID = 'pg/interval@1' as const;\nexport const PG_JSON_CODEC_ID = 'pg/json@1' as const;\nexport const PG_JSONB_CODEC_ID = 'pg/jsonb@1' as const;\nexport const PG_BYTEA_CODEC_ID = 'pg/bytea@1' as const;\nexport const PG_UUID_CODEC_ID = 'pg/uuid@1' as const;\n"],"mappings":";;AAQA,MAAa,mBAAmB;AAChC,MAAa,yBAAyB;AACtC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AACvC,MAAa,mBAAmB;AAChC,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;AACjC,MAAa,mBAAmB"}
@@ -1,2 +1,2 @@
1
- import { A as SQL_VARCHAR_CODEC_ID, C as PG_VARBIT_CODEC_ID, D as SQL_INT_CODEC_ID, E as SQL_FLOAT_CODEC_ID, O as SQL_TEXT_CODEC_ID, S as PG_UUID_CODEC_ID, T as SQL_CHAR_CODEC_ID, _ as PG_TEXT_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIMETZ_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_ARRAY_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_CHAR_CODEC_ID, k as SQL_TIMESTAMP_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMPTZ_CODEC_ID, w as PG_VARCHAR_CODEC_ID, x as PG_TIME_CODEC_ID, y as PG_TIMESTAMP_CODEC_ID } from "./codec-ids-CnXu9Qy3.mjs";
2
- export { PG_BIT_CODEC_ID, PG_BOOL_CODEC_ID, PG_BYTEA_CODEC_ID, PG_CHAR_CODEC_ID, PG_FLOAT4_CODEC_ID, PG_FLOAT8_CODEC_ID, PG_FLOAT_CODEC_ID, PG_INT2_CODEC_ID, PG_INT4_CODEC_ID, PG_INT8_CODEC_ID, PG_INTERVAL_CODEC_ID, PG_INT_CODEC_ID, PG_JSONB_CODEC_ID, PG_JSON_CODEC_ID, PG_NUMERIC_CODEC_ID, PG_TEXT_ARRAY_CODEC_ID, PG_TEXT_CODEC_ID, PG_TIMESTAMPTZ_CODEC_ID, PG_TIMESTAMP_CODEC_ID, PG_TIMETZ_CODEC_ID, PG_TIME_CODEC_ID, PG_UUID_CODEC_ID, PG_VARBIT_CODEC_ID, PG_VARCHAR_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID };
1
+ import { A as SQL_TIMESTAMP_CODEC_ID, C as PG_UUID_CODEC_ID, D as SQL_FLOAT_CODEC_ID, E as SQL_CHAR_CODEC_ID, O as SQL_INT_CODEC_ID, S as PG_TIME_CODEC_ID, T as PG_VARCHAR_CODEC_ID, _ as PG_TEXT_ARRAY_CODEC_ID, a as PG_ENUM_CODEC_ID, b as PG_TIMESTAMP_CODEC_ID, c as PG_FLOAT_CODEC_ID, d as PG_INT8_CODEC_ID, f as PG_INTERVAL_CODEC_ID, g as PG_NUMERIC_CODEC_ID, h as PG_JSON_CODEC_ID, i as PG_CHAR_CODEC_ID, j as SQL_VARCHAR_CODEC_ID, k as SQL_TEXT_CODEC_ID, l as PG_INT2_CODEC_ID, m as PG_JSONB_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT4_CODEC_ID, p as PG_INT_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_FLOAT8_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT4_CODEC_ID, v as PG_TEXT_CODEC_ID, w as PG_VARBIT_CODEC_ID, x as PG_TIMETZ_CODEC_ID, y as PG_TIMESTAMPTZ_CODEC_ID } from "./codec-ids-BzrFF-I4.mjs";
2
+ export { PG_BIT_CODEC_ID, PG_BOOL_CODEC_ID, PG_BYTEA_CODEC_ID, PG_CHAR_CODEC_ID, PG_ENUM_CODEC_ID, PG_FLOAT4_CODEC_ID, PG_FLOAT8_CODEC_ID, PG_FLOAT_CODEC_ID, PG_INT2_CODEC_ID, PG_INT4_CODEC_ID, PG_INT8_CODEC_ID, PG_INTERVAL_CODEC_ID, PG_INT_CODEC_ID, PG_JSONB_CODEC_ID, PG_JSON_CODEC_ID, PG_NUMERIC_CODEC_ID, PG_TEXT_ARRAY_CODEC_ID, PG_TEXT_CODEC_ID, PG_TIMESTAMPTZ_CODEC_ID, PG_TIMESTAMP_CODEC_ID, PG_TIMETZ_CODEC_ID, PG_TIME_CODEC_ID, PG_UUID_CODEC_ID, PG_VARBIT_CODEC_ID, PG_VARCHAR_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID };
@@ -1,2 +1,2 @@
1
- import { A as SQL_VARCHAR_CODEC_ID, C as PG_VARBIT_CODEC_ID, D as SQL_INT_CODEC_ID, E as SQL_FLOAT_CODEC_ID, O as SQL_TEXT_CODEC_ID, S as PG_UUID_CODEC_ID, T as SQL_CHAR_CODEC_ID, _ as PG_TEXT_CODEC_ID, a as PG_FLOAT4_CODEC_ID, b as PG_TIMETZ_CODEC_ID, c as PG_INT2_CODEC_ID, d as PG_INTERVAL_CODEC_ID, f as PG_INT_CODEC_ID, g as PG_TEXT_ARRAY_CODEC_ID, h as PG_NUMERIC_CODEC_ID, i as PG_CHAR_CODEC_ID, k as SQL_TIMESTAMP_CODEC_ID, l as PG_INT4_CODEC_ID, m as PG_JSON_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT8_CODEC_ID, p as PG_JSONB_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_FLOAT_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMPTZ_CODEC_ID, w as PG_VARCHAR_CODEC_ID, x as PG_TIME_CODEC_ID, y as PG_TIMESTAMP_CODEC_ID } from "./codec-ids-BvytN2P8.mjs";
2
- export { PG_BIT_CODEC_ID, PG_BOOL_CODEC_ID, PG_BYTEA_CODEC_ID, PG_CHAR_CODEC_ID, PG_FLOAT4_CODEC_ID, PG_FLOAT8_CODEC_ID, PG_FLOAT_CODEC_ID, PG_INT2_CODEC_ID, PG_INT4_CODEC_ID, PG_INT8_CODEC_ID, PG_INTERVAL_CODEC_ID, PG_INT_CODEC_ID, PG_JSONB_CODEC_ID, PG_JSON_CODEC_ID, PG_NUMERIC_CODEC_ID, PG_TEXT_ARRAY_CODEC_ID, PG_TEXT_CODEC_ID, PG_TIMESTAMPTZ_CODEC_ID, PG_TIMESTAMP_CODEC_ID, PG_TIMETZ_CODEC_ID, PG_TIME_CODEC_ID, PG_UUID_CODEC_ID, PG_VARBIT_CODEC_ID, PG_VARCHAR_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID };
1
+ import { A as SQL_TIMESTAMP_CODEC_ID, C as PG_UUID_CODEC_ID, D as SQL_FLOAT_CODEC_ID, E as SQL_CHAR_CODEC_ID, O as SQL_INT_CODEC_ID, S as PG_TIME_CODEC_ID, T as PG_VARCHAR_CODEC_ID, _ as PG_TEXT_ARRAY_CODEC_ID, a as PG_ENUM_CODEC_ID, b as PG_TIMESTAMP_CODEC_ID, c as PG_FLOAT_CODEC_ID, d as PG_INT8_CODEC_ID, f as PG_INTERVAL_CODEC_ID, g as PG_NUMERIC_CODEC_ID, h as PG_JSON_CODEC_ID, i as PG_CHAR_CODEC_ID, j as SQL_VARCHAR_CODEC_ID, k as SQL_TEXT_CODEC_ID, l as PG_INT2_CODEC_ID, m as PG_JSONB_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_FLOAT4_CODEC_ID, p as PG_INT_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_FLOAT8_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_INT4_CODEC_ID, v as PG_TEXT_CODEC_ID, w as PG_VARBIT_CODEC_ID, x as PG_TIMETZ_CODEC_ID, y as PG_TIMESTAMPTZ_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
2
+ export { PG_BIT_CODEC_ID, PG_BOOL_CODEC_ID, PG_BYTEA_CODEC_ID, PG_CHAR_CODEC_ID, PG_ENUM_CODEC_ID, PG_FLOAT4_CODEC_ID, PG_FLOAT8_CODEC_ID, PG_FLOAT_CODEC_ID, PG_INT2_CODEC_ID, PG_INT4_CODEC_ID, PG_INT8_CODEC_ID, PG_INTERVAL_CODEC_ID, PG_INT_CODEC_ID, PG_JSONB_CODEC_ID, PG_JSON_CODEC_ID, PG_NUMERIC_CODEC_ID, PG_TEXT_ARRAY_CODEC_ID, PG_TEXT_CODEC_ID, PG_TIMESTAMPTZ_CODEC_ID, PG_TIMESTAMP_CODEC_ID, PG_TIMETZ_CODEC_ID, PG_TIME_CODEC_ID, PG_UUID_CODEC_ID, PG_VARBIT_CODEC_ID, PG_VARCHAR_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID };
@@ -1,4 +1,4 @@
1
- import { C as PgVarcharDescriptor, S as PgVarbitDescriptor, _ as PgTimeDescriptor, a as PgFloat4Descriptor, b as PgTimetzDescriptor, c as PgInt2Descriptor, d as PgIntDescriptor, f as PgIntervalDescriptor, g as PgTextDescriptor, h as PgNumericDescriptor, i as PgCharDescriptor, l as PgInt4Descriptor, m as PgJsonbDescriptor, n as PgBoolDescriptor, o as PgFloat8Descriptor, p as PgJsonDescriptor, r as PgByteaDescriptor, s as PgFloatDescriptor, t as PgBitDescriptor, u as PgInt8Descriptor, v as PgTimestampDescriptor, x as PgUuidDescriptor, y as PgTimestamptzDescriptor } from "./codecs--0A5_4Bq.mjs";
1
+ import { C as PgVarbitDescriptor, S as PgUuidDescriptor, _ as PgTextDescriptor, a as PgEnumDescriptor, b as PgTimestamptzDescriptor, c as PgFloatDescriptor, d as PgInt8Descriptor, f as PgIntDescriptor, g as PgNumericDescriptor, h as PgJsonbDescriptor, i as PgCharDescriptor, l as PgInt2Descriptor, m as PgJsonDescriptor, n as PgBoolDescriptor, o as PgFloat4Descriptor, p as PgIntervalDescriptor, r as PgByteaDescriptor, s as PgFloat8Descriptor, t as PgBitDescriptor, u as PgInt4Descriptor, v as PgTimeDescriptor, w as PgVarcharDescriptor, x as PgTimetzDescriptor, y as PgTimestampDescriptor } from "./codecs-Dk2sxGLv.mjs";
2
2
  import { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
3
3
  import { JsonValue as JsonValue$1 } from "@prisma-next/contract/types";
4
4
 
@@ -11,6 +11,7 @@ declare const codecDescriptorMap: {
11
11
  readonly 'sql-text': import("@prisma-next/sql-relational-core/ast").SqlTextDescriptor;
12
12
  readonly 'sql-timestamp': import("@prisma-next/sql-relational-core/ast").SqlTimestampDescriptor;
13
13
  readonly text: PgTextDescriptor;
14
+ readonly enum: PgEnumDescriptor;
14
15
  readonly character: PgCharDescriptor;
15
16
  readonly 'character varying': PgVarcharDescriptor;
16
17
  readonly integer: PgIntDescriptor;
@@ -75,4 +76,4 @@ type Interval<P extends number | undefined = undefined> = BrandedString<{
75
76
  }>;
76
77
  //#endregion
77
78
  export { JsonValue$1 as a, Timestamp as c, VarBit as d, Varchar as f, Interval as i, Timestamptz as l, Char as n, Numeric as o, CodecTypes as r, Time as s, Bit as t, Timetz as u };
78
- //# sourceMappingURL=codec-types-DHCkwPKE.d.mts.map
79
+ //# sourceMappingURL=codec-types-BDVmvKAW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-types-BDVmvKAW.d.mts","names":[],"sources":["../src/core/codec-type-map.ts","../src/exports/codec-types.ts"],"mappings":";;;;;cA6Ca,kBAAA;EAAA;;;;;;iBA+BH,gBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;KAEE,OAAA,6BAAoC,CAAA,0BAA2B,CAAA,CAAE,CAAA,IAAK,CAAA,CAAE,CAAA,EAAG,CAAA;AAAA,KAE3E,kBAAA,UAA4B,kBAAkB;AAAA,KAE9C,mBAAA,GAAsB,iBAAiB,CAAC,kBAAA;;;KCvExC,UAAA,GAAa,OAAO,CAAC,mBAAA;AAAA,KAI5B,OAAA,kBAAyB,MAAA,qBAA2B,CAAA,0BAClC,KAAA,GAAQ,KAAA,CAAM,CAAA;AAAA,KAGhC,aAAA,eAA4B,MAAA,qBAA2B,OAAA,SAAgB,KAAA;AAAA,KAEhE,IAAA,qBAAyB,aAAa;EAAG,YAAA,EAAc,CAAA;AAAA;AAAA,KACvD,OAAA,qBAA4B,aAAa;EAAG,eAAA,EAAiB,CAAA;AAAA;AAAA,KAC7D,OAAA,+DAAsE,aAAA;EAChF,kBAAA,EAAoB,CAAA;EACpB,cAAA,EAAgB,CAAA;AAAA;AAAA,KAEN,GAAA,qBAAwB,aAAa;EAAG,WAAA,EAAa,CAAA;AAAA;AAAA,KACrD,MAAA,qBAA2B,aAAa;EAAG,cAAA,EAAgB,CAAA;AAAA;AAAA,KAC3D,SAAA,6CAAsD,aAAa;EAC7E,oBAAA,EAAsB,CAAA;AAAA;AAAA,KAEZ,WAAA,6CAAwD,aAAa;EAC/E,sBAAA,EAAwB,CAAA;AAAA;AAAA,KAEd,IAAA,6CAAiD,aAAa;EAAG,eAAA,EAAiB,CAAA;AAAA;AAAA,KAClF,MAAA,6CAAmD,aAAa;EAC1E,iBAAA,EAAmB,CAAA;AAAA;AAAA,KAET,QAAA,6CAAqD,aAAa;EAC5E,mBAAA,EAAqB,CAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { a as JsonValue, c as Timestamp, d as VarBit, f as Varchar, i as Interval, l as Timestamptz, n as Char, o as Numeric, r as CodecTypes, s as Time, t as Bit, u as Timetz } from "./codec-types-DHCkwPKE.mjs";
1
+ import { a as JsonValue, c as Timestamp, d as VarBit, f as Varchar, i as Interval, l as Timestamptz, n as Char, o as Numeric, r as CodecTypes, s as Time, t as Bit, u as Timetz } from "./codec-types-BDVmvKAW.mjs";
2
2
  export { Bit, Char, CodecTypes, Interval, type JsonValue, Numeric, Time, Timestamp, Timestamptz, Timetz, VarBit, Varchar };