okmodel 0.7.0 → 0.9.0

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 (258) hide show
  1. package/README.md +14 -0
  2. package/dist/adapters/capabilities.d.ts +32 -0
  3. package/dist/adapters/failure.d.ts +1 -1
  4. package/dist/adapters/pg/bun-sql.d.ts +53 -0
  5. package/dist/adapters/pg/bunsql-extra.d.ts +1 -1
  6. package/dist/adapters/pg/bunsql.d.ts +1 -1
  7. package/dist/adapters/pg/neon-extra.d.ts +18 -0
  8. package/dist/adapters/pg/neon.d.ts +104 -0
  9. package/dist/adapters/pg/no-inflight-timeout.d.ts +1 -1
  10. package/dist/contracts/error.d.ts +1 -1
  11. package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
  12. package/dist/dialects/pg/ext/btree-gin.js +20 -0
  13. package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
  14. package/dist/dialects/pg/ext/btree-gist.js +20 -0
  15. package/dist/dialects/pg/ext/call.d.ts +53 -0
  16. package/dist/dialects/pg/ext/citext.js +1 -1
  17. package/dist/dialects/pg/ext/feature.d.ts +26 -0
  18. package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
  19. package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
  20. package/dist/dialects/pg/ext/hstore.d.ts +41 -0
  21. package/dist/dialects/pg/ext/hstore.js +29 -0
  22. package/dist/dialects/pg/ext/index.d.ts +56 -0
  23. package/dist/dialects/pg/ext/index.js +1 -1
  24. package/dist/dialects/pg/ext/ltree.d.ts +41 -0
  25. package/dist/dialects/pg/ext/ltree.js +29 -0
  26. package/dist/dialects/pg/ext/pg-trgm.js +4 -13
  27. package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
  28. package/dist/dialects/pg/ext/pgcrypto.js +33 -0
  29. package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
  30. package/dist/dialects/pg/ext/unaccent.js +21 -0
  31. package/dist/dialects/pg/ext/using.d.ts +23 -0
  32. package/dist/dialects/pg/ext/versions.d.ts +36 -0
  33. package/dist/dialects/pg/external.d.ts +19 -0
  34. package/dist/dialects/pg/fn/index.d.ts +39 -1
  35. package/dist/dialects/pg/fn/index.js +118 -26
  36. package/dist/dialects/pg/index.d.ts +3 -0
  37. package/dist/dialects/pg/index.js +394 -14
  38. package/dist/dialects/pg/introspect.d.ts +11 -0
  39. package/dist/dialects/pg/operators.d.ts +1 -1
  40. package/dist/dialects/pg/ops/fragment.d.ts +119 -0
  41. package/dist/dialects/pg/ops/lane.d.ts +49 -0
  42. package/dist/dialects/pg/view/client.d.ts +14 -6
  43. package/dist/dialects/pg/view/index.d.ts +73 -1
  44. package/dist/dialects/pg/view/index.js +156 -5
  45. package/dist/dialects/pg/view/scratch.d.ts +11 -5
  46. package/dist/runtime/artifact-file.d.ts +22 -0
  47. package/dist/runtime/client.d.ts +10 -0
  48. package/dist/runtime/drift-detail.d.ts +2 -1
  49. package/dist/runtime/drift.d.ts +3 -10
  50. package/dist/runtime/otel.d.ts +105 -0
  51. package/dist/runtime/otel.js +97 -0
  52. package/dist/runtime/pg/bun.js +4 -4
  53. package/dist/runtime/pg/neon.d.ts +38 -0
  54. package/dist/runtime/pg/neon.js +64 -0
  55. package/dist/runtime/pg/pg.js +4 -4
  56. package/dist/runtime/pg/pglite.js +4 -4
  57. package/dist/runtime/pg/postgresjs.js +4 -4
  58. package/dist/runtime/plan.d.ts +1 -1
  59. package/dist/runtime/server-check.d.ts +36 -6
  60. package/dist/runtime/sql-fragment.d.ts +43 -0
  61. package/dist/runtime/tenancy/index.js +10 -10
  62. package/dist/runtime/topology.d.ts +1 -1
  63. package/dist/runtime/traits/index.js +16 -17
  64. package/dist/runtime/types.d.ts +15 -1
  65. package/dist/runtime/validate/index.js +4 -4
  66. package/dist/shared/{81ebdx9p.js → 0j6qe91y.js} +4 -4
  67. package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
  68. package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
  69. package/dist/shared/{w79hsckn.js → 1mxm04fy.js} +5 -5
  70. package/dist/shared/{7k9grvf6.js → 2szgv6yj.js} +5 -5
  71. package/dist/shared/{gs74dbj5.js → 2zdxkt7b.js} +933 -111
  72. package/dist/shared/{m6p12kbr.js → 3456242y.js} +23 -23
  73. package/dist/shared/3bb7wsqt.js +99 -0
  74. package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
  75. package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
  76. package/dist/shared/{pt94kz7f.js → 5kyb3tqx.js} +1 -1
  77. package/dist/shared/61bmrmhr.js +35 -0
  78. package/dist/shared/{x933k9a3.js → 62b603gr.js} +10 -10
  79. package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
  80. package/dist/shared/{tsvww22q.js → 6nae0spm.js} +156 -95
  81. package/dist/shared/{mtaszv5a.js → 71n0jmhc.js} +102 -4
  82. package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
  83. package/dist/shared/7ba5h6pb.js +17 -0
  84. package/dist/shared/{sfz1ksn6.js → 8jesqsrk.js} +2 -2
  85. package/dist/shared/{5v3xf80k.js → 8n688yjg.js} +1 -1
  86. package/dist/shared/{rs73fca9.js → 8qzkd9f3.js} +6 -6
  87. package/dist/shared/{ax7qv55k.js → 90sg0w5a.js} +202 -25
  88. package/dist/shared/{zm0ptry0.js → 99qp9vtg.js} +1 -1
  89. package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
  90. package/dist/shared/{1w508jbr.js → 9dtgn1z2.js} +21 -17
  91. package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
  92. package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
  93. package/dist/shared/{te5as7z7.js → aksb89mn.js} +3 -3
  94. package/dist/shared/{bz84tkzm.js → bphrgwz9.js} +2 -2
  95. package/dist/shared/bsek72fg.js +225 -0
  96. package/dist/shared/{7mnme5tn.js → c3mvnq7a.js} +1 -1
  97. package/dist/shared/{p6qc5gcp.js → ccsmhv9r.js} +25 -7
  98. package/dist/shared/{pbp1ss85.js → cexb7z6b.js} +2 -2
  99. package/dist/shared/{ab9gmbwy.js → cf8zdz5p.js} +5 -5
  100. package/dist/shared/{jvd0mqag.js → ckz05z15.js} +5 -5
  101. package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
  102. package/dist/shared/{14vx95q4.js → dd5pmnky.js} +7 -7
  103. package/dist/shared/{vb6qfyve.js → ds229x4r.js} +2 -2
  104. package/dist/shared/{1qa0qajz.js → e275q7sd.js} +1 -1
  105. package/dist/shared/{zp9fmend.js → ebhz8vh6.js} +4 -4
  106. package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
  107. package/dist/shared/{je4axnm8.js → fdsz3w80.js} +2 -2
  108. package/dist/shared/{9s0ypp87.js → fk9vef30.js} +85 -74
  109. package/dist/shared/{g6evj1j3.js → g89fmz5s.js} +1 -1
  110. package/dist/shared/{aytqh5y2.js → ghqzdp94.js} +2 -2
  111. package/dist/shared/h9811jjm.js +17 -0
  112. package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
  113. package/dist/shared/{8skf0cam.js → jpybhf98.js} +1 -1
  114. package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
  115. package/dist/shared/kzgrnckd.js +29 -0
  116. package/dist/shared/mazpbcdj.js +233 -0
  117. package/dist/shared/{kb2sdhfb.js → mfvx6kjx.js} +17 -1
  118. package/dist/shared/{svncdeh5.js → mgaq2sd3.js} +11 -8
  119. package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
  120. package/dist/shared/{b5pftnn2.js → myk8fswx.js} +66 -21
  121. package/dist/shared/{2shdbn8q.js → n306gqkd.js} +9 -9
  122. package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
  123. package/dist/shared/n5whk3mt.js +665 -0
  124. package/dist/shared/n7kg8mmx.js +61 -0
  125. package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
  126. package/dist/shared/{tbrvgw6z.js → npdftanb.js} +19 -26
  127. package/dist/shared/{ek2wt2dz.js → pg4ezgyf.js} +11 -30
  128. package/dist/shared/{5fe3kbsh.js → pgsak1yw.js} +1 -1
  129. package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
  130. package/dist/shared/{wa07eas9.js → qvwwp1mp.js} +62 -41
  131. package/dist/shared/rbxt795q.js +1766 -0
  132. package/dist/shared/{xjk7hnn5.js → s7he5e5d.js} +2 -2
  133. package/dist/shared/{w72kgg4q.js → ss2kv2rs.js} +6 -6
  134. package/dist/shared/stfa9xcw.js +450 -0
  135. package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
  136. package/dist/shared/{79dt02vc.js → tr64w5p0.js} +1 -1
  137. package/dist/shared/{cn957f8d.js → tw1nvvfj.js} +3 -3
  138. package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
  139. package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
  140. package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
  141. package/dist/shared/{vczs8gd4.js → wvtjg5m3.js} +2 -2
  142. package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
  143. package/dist/shared/xqacq37x.js +61 -0
  144. package/dist/shared/{1est4ezg.js → xtsydxjg.js} +3 -3
  145. package/dist/shared/xv8qj97g.js +96 -0
  146. package/dist/shared/{bg3rym3g.js → xwhdcrm4.js} +2 -2
  147. package/dist/shared/{kr0jzbw2.js → yvabyg9k.js} +7 -7
  148. package/dist/shared/yybhre6n.js +136 -0
  149. package/dist/shared/zdqf8k5d.js +8 -0
  150. package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
  151. package/dist/tooling/cli.js +108 -23
  152. package/dist/tooling/driver-run.js +4654 -0
  153. package/dist/tooling/driver-test.d.ts +36 -0
  154. package/dist/tooling/github/comment.d.ts +50 -0
  155. package/dist/tooling/github/post-comment.d.ts +17 -0
  156. package/dist/tooling/migrate/commands.d.ts +3 -2
  157. package/dist/tooling/migrate/config.d.ts +13 -0
  158. package/dist/tooling/migrate/export.d.ts +165 -0
  159. package/dist/tooling/migrate/ext-surface.d.ts +80 -0
  160. package/dist/tooling/migrate/ext.d.ts +31 -4
  161. package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
  162. package/dist/tooling/migrate/index.d.ts +3 -0
  163. package/dist/tooling/migrate/index.js +55 -10
  164. package/dist/tooling/migrate/lint-rules.d.ts +18 -1
  165. package/dist/tooling/migrate/lint.d.ts +14 -1
  166. package/dist/tooling/migrate/place.d.ts +18 -0
  167. package/dist/tooling/migrate/plan-json.d.ts +65 -0
  168. package/dist/tooling/migrate/project.d.ts +13 -1
  169. package/dist/tooling/migrate/pull-emit.d.ts +98 -0
  170. package/dist/tooling/migrate/pull-routines.d.ts +126 -0
  171. package/dist/tooling/migrate/pull-verify.d.ts +26 -0
  172. package/dist/tooling/migrate/pull.d.ts +62 -0
  173. package/dist/tooling/migrate/reprint.d.ts +32 -0
  174. package/dist/tooling/migrate/sandbox.d.ts +8 -2
  175. package/dist/tooling/migrate/schema-api.d.ts +43 -0
  176. package/dist/tooling/migrate/sql-lex.d.ts +18 -0
  177. package/dist/tooling/shared/04svnxxj.js +344 -0
  178. package/dist/tooling/shared/0j0jtse1.js +13 -0
  179. package/dist/tooling/shared/0r05zhyq.js +618 -0
  180. package/dist/tooling/shared/1800eymw.js +49 -0
  181. package/dist/tooling/shared/35zemrmf.js +12 -0
  182. package/dist/tooling/shared/3rmaz3pq.js +140 -0
  183. package/dist/tooling/shared/3yn79q5m.js +12 -0
  184. package/dist/tooling/shared/54tqkxja.js +51 -0
  185. package/dist/tooling/shared/57btdkgm.js +209 -0
  186. package/dist/tooling/shared/5bmksndh.js +118 -0
  187. package/dist/tooling/shared/5p8km5jb.js +38 -0
  188. package/dist/tooling/shared/5x3pf400.js +185 -0
  189. package/dist/tooling/shared/5zrzffnk.js +6 -0
  190. package/dist/tooling/shared/62fxpc1p.js +332 -0
  191. package/dist/tooling/shared/68tf18v4.js +20 -0
  192. package/dist/tooling/shared/6vk28rjp.js +98 -0
  193. package/dist/tooling/shared/76pv6qff.js +9 -0
  194. package/dist/tooling/shared/7aews1zg.js +311 -0
  195. package/dist/tooling/shared/7b3xp9gc.js +195 -0
  196. package/dist/tooling/shared/7kms6fvj.js +20 -0
  197. package/dist/tooling/shared/7pxncnzs.js +40 -0
  198. package/dist/tooling/shared/829fjxyw.js +198 -0
  199. package/dist/tooling/shared/8m5znpdt.js +66 -0
  200. package/dist/tooling/shared/8yr7ges1.js +211 -0
  201. package/dist/tooling/shared/96ps4g1z.js +32 -0
  202. package/dist/tooling/shared/9qr9rkbh.js +143 -0
  203. package/dist/tooling/shared/9sfbtwsk.js +49 -0
  204. package/dist/tooling/shared/9wsnsvbf.js +10 -0
  205. package/dist/tooling/shared/a2xe04bm.js +18 -0
  206. package/dist/tooling/shared/a4pzghha.js +20 -0
  207. package/dist/tooling/shared/am04v8na.js +233 -0
  208. package/dist/tooling/shared/asgr07mp.js +194 -0
  209. package/dist/tooling/shared/c0xevn1h.js +312 -0
  210. package/dist/tooling/shared/dhatassp.js +134 -0
  211. package/dist/tooling/shared/ezqn88nj.js +1696 -0
  212. package/dist/tooling/shared/f77nnfqy.js +231 -0
  213. package/dist/tooling/shared/fh07z1dt.js +15 -0
  214. package/dist/tooling/shared/gqwevek4.js +81 -0
  215. package/dist/tooling/shared/hfq3n3bd.js +4116 -0
  216. package/dist/tooling/shared/htnaj77v.js +17 -0
  217. package/dist/tooling/shared/j664qjrt.js +64 -0
  218. package/dist/tooling/shared/jpgmjsx3.js +38 -0
  219. package/dist/tooling/shared/jr2nmr81.js +497 -0
  220. package/dist/tooling/shared/jsjjz875.js +139 -0
  221. package/dist/tooling/shared/kbqnrs1x.js +1425 -0
  222. package/dist/tooling/shared/kz715295.js +94 -0
  223. package/dist/tooling/shared/m3xt8b1h.js +22 -0
  224. package/dist/tooling/shared/m4hhb8aa.js +9 -0
  225. package/dist/tooling/shared/mw5npye0.js +16 -0
  226. package/dist/tooling/shared/n4jqhpqz.js +27 -0
  227. package/dist/tooling/shared/nxq95eb6.js +42 -0
  228. package/dist/tooling/shared/qartgazh.js +70 -0
  229. package/dist/tooling/shared/rcywj2w8.js +190 -0
  230. package/dist/tooling/shared/s6qha57m.js +16 -0
  231. package/dist/tooling/shared/shjs0379.js +150 -0
  232. package/dist/tooling/shared/sjwkt1pg.js +16 -0
  233. package/dist/tooling/shared/stebqyyd.js +401 -0
  234. package/dist/tooling/shared/t4xveemq.js +250 -0
  235. package/dist/tooling/shared/t6zjeake.js +261 -0
  236. package/dist/tooling/shared/tcwpjvxe.js +9 -0
  237. package/dist/tooling/shared/tpssp7ac.js +160 -0
  238. package/dist/tooling/shared/v6j1ep6w.js +42 -0
  239. package/dist/tooling/shared/vwr2y833.js +270 -0
  240. package/dist/tooling/shared/w17sj05d.js +7 -0
  241. package/dist/tooling/shared/w5d89rb4.js +131 -0
  242. package/dist/tooling/shared/wbwq1jsa.js +157 -0
  243. package/dist/tooling/shared/wezxf3h8.js +17 -0
  244. package/dist/tooling/shared/yb4kd19s.js +12 -0
  245. package/dist/tooling/shared/ybdew6j7.js +294 -0
  246. package/dist/tooling/shared/yfedr1zb.js +6 -0
  247. package/dist/tooling/shared/yhp829bx.js +177 -0
  248. package/dist/tooling/shared/ytk1tjs0.js +604 -0
  249. package/dist/tooling/shared/zs9aymcp.js +210 -0
  250. package/dist/tooling/shared/zx3v9phv.js +8 -0
  251. package/dist/tooling/testing/index.js +3 -3
  252. package/package.json +50 -9
  253. package/dist/shared/ktz42yez.js +0 -113
  254. package/dist/shared/ttsqgp4p.js +0 -71
  255. package/dist/shared/y34a8714.js +0 -150
  256. package/dist/shared/zy8r7qvz.js +0 -116
  257. package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
  258. package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
@@ -3,21 +3,21 @@ import {
3
3
  } from "./mss6ctgv.js";
4
4
  import {
5
5
  effectivePredicate
6
- } from "./n816peh1.js";
7
- import {
8
- assertOperatorFits,
9
- textArray,
10
- arrayElementType
11
- } from "./zchaghkf.js";
6
+ } from "./n454kcnw.js";
12
7
  import {
13
8
  runWrite
14
9
  } from "./n4jqhpqz.js";
15
10
  import {
16
11
  writeWouldValidate
17
- } from "./ze4hxsmy.js";
12
+ } from "./w9ejzaqf.js";
18
13
  import {
19
14
  encodeJson
20
- } from "./9628a9xt.js";
15
+ } from "./vk7rag46.js";
16
+ import {
17
+ assertOperatorFits,
18
+ textArray,
19
+ arrayElementType
20
+ } from "./zchaghkf.js";
21
21
  import {
22
22
  withRowFilters,
23
23
  archiveRules,
@@ -32,7 +32,7 @@ import {
32
32
  isRecord,
33
33
  registerFailFix,
34
34
  fail2
35
- } from "./67txcrcw.js";
35
+ } from "./kgwp4jdd.js";
36
36
  import {
37
37
  safetyInstalled,
38
38
  runSafety
@@ -198,7 +198,7 @@ async function planWrite(schema, generators, op, tableName, input, options, mods
198
198
  }
199
199
  if (op === "update") {
200
200
  if (traitNamed(table, "versioned")) {
201
- const { planVersioned } = await import("./y6njgyda.js");
201
+ const { planVersioned } = await import("./3t6kw83m.js");
202
202
  return withRowFilters(scope, mods.archive, () => {
203
203
  noteArchive(table, mods.archive);
204
204
  const planned = planVersioned(schema, table, input, record, mods);
@@ -244,12 +244,12 @@ async function planInsert(table, input, options, mods, generators, scope, tenanc
244
244
  keyColumns: undefined
245
245
  };
246
246
  }
247
- const conflictMod = options.onConflict === undefined || options.onConflict === "error" ? undefined : await import("./bg3rym3g.js");
247
+ const conflictMod = options.onConflict === undefined || options.onConflict === "error" ? undefined : await import("./xwhdcrm4.js");
248
248
  const conflict = conflictMod?.readConflict(table, options.onConflict, allow, tenantKeyList(tenancy));
249
249
  if (conflict?.kind === "update" && traitNamed(table, "versioned")) {
250
250
  fail2("OKM1120", `onConflict update on ${table.model.name} does not check the version you read.`, "Read the row and update. ignore and return do not change the existing row.");
251
251
  }
252
- const sortMod = sorting ? await import("./9y3mmmh1.js") : undefined;
252
+ const sortMod = sorting ? await import("./xfhe73sb.js") : undefined;
253
253
  const chunks = chunkRows(rows.map((row) => cellsFor(columns, row)));
254
254
  const statements = [];
255
255
  const quiet = [];
@@ -1086,7 +1086,7 @@ function insertRow(table, value, allow, tenancy) {
1086
1086
  if (column === undefined)
1087
1087
  continue;
1088
1088
  tenancy?.guard(table.model.name, key, "insert");
1089
- if (!writable(table, column, allow))
1089
+ if (!writable(table, column, allow, "insert"))
1090
1090
  refuse(table, column);
1091
1091
  if (value[key] !== undefined)
1092
1092
  row[key] = value[key];
@@ -1142,7 +1142,7 @@ function writtenColumns(table, rows, allow, tenantKeys) {
1142
1142
  }
1143
1143
  const columns = [];
1144
1144
  for (const column of table.model.columns) {
1145
- if (present.has(column.field) && (writable(table, column, allow) || column.fill !== undefined || tenantKeys?.includes(column.field) === true)) {
1145
+ if (present.has(column.field) && (writable(table, column, allow, "insert") || column.fill !== undefined || tenantKeys?.includes(column.field) === true)) {
1146
1146
  columns.push(column);
1147
1147
  }
1148
1148
  }
@@ -1206,7 +1206,7 @@ function writeSet2(table, value, allow, tenancy) {
1206
1206
  if (column === undefined)
1207
1207
  continue;
1208
1208
  tenancy?.guard(table.model.name, key, "update");
1209
- if (column.guardUpdate || !writable(table, column, allow))
1209
+ if (column.guardUpdate || !writable(table, column, allow, "update"))
1210
1210
  refuse(table, column);
1211
1211
  set[key] = value[key];
1212
1212
  }
@@ -1475,12 +1475,16 @@ function refuse(table, column) {
1475
1475
  }
1476
1476
  fail2("OKM1120", `Field ${table.model.name}.${column.field} cannot be written.`);
1477
1477
  }
1478
- function writable(table, column, allow) {
1478
+ function writable(table, column, allow, op) {
1479
1479
  if (fieldSealed(table.model, column.field))
1480
1480
  return false;
1481
1481
  if (column.writable)
1482
1482
  return true;
1483
- return column.guarded && allow.has(column.field);
1483
+ if (!column.guarded || !allow.has(column.field))
1484
+ return false;
1485
+ if (!table.model.primary.includes(column.field))
1486
+ return true;
1487
+ return op === "insert" && column.fill !== undefined;
1484
1488
  }
1485
1489
  function allowSet2(table, value) {
1486
1490
  if (value === undefined)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validationGate
3
- } from "./ze4hxsmy.js";
3
+ } from "./w9ejzaqf.js";
4
4
  import {
5
5
  isOperator
6
6
  } from "./cn0n68ft.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fail2
3
- } from "./67txcrcw.js";
3
+ } from "./kgwp4jdd.js";
4
4
 
5
5
  // src/runtime/result-name.ts
6
6
  var PROTOTYPE_KEYS = ",__proto__,constructor,toString,hasOwnProperty,valueOf,isPrototypeOf,propertyIsEnumerable,toLocaleString,__defineGetter__,__defineSetter__,__lookupGetter__,__lookupSetter__,then,";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  identityColumn2
3
- } from "./xjk7hnn5.js";
3
+ } from "./s7he5e5d.js";
4
4
  import {
5
5
  runWrite
6
6
  } from "./n4jqhpqz.js";
7
7
  import {
8
8
  queryHandle,
9
9
  settleCall
10
- } from "./tbrvgw6z.js";
10
+ } from "./npdftanb.js";
11
11
  import {
12
12
  withRowFilters,
13
13
  archiveRules,
@@ -18,7 +18,7 @@ import {
18
18
  list,
19
19
  isRecord,
20
20
  fail2
21
- } from "./67txcrcw.js";
21
+ } from "./kgwp4jdd.js";
22
22
  import {
23
23
  safetyInstalled,
24
24
  runSafety
@@ -4,7 +4,7 @@ import {
4
4
  } from "./cm3w0ywp.js";
5
5
  import {
6
6
  PgSession
7
- } from "./14vx95q4.js";
7
+ } from "./dd5pmnky.js";
8
8
  import {
9
9
  isConnectionLost
10
10
  } from "./cnkky55j.js";
@@ -15,7 +15,7 @@ import {
15
15
  runCall,
16
16
  rowsFrom,
17
17
  resultFrom
18
- } from "./kb2sdhfb.js";
18
+ } from "./mfvx6kjx.js";
19
19
 
20
20
  // src/adapters/pg/postgres-extra.ts
21
21
  var RESET_ALL = "RESET ALL";
@@ -0,0 +1,225 @@
1
+ import {
2
+ assertNoControl
3
+ } from "./zchaghkf.js";
4
+ import {
5
+ isOperator,
6
+ operatorName,
7
+ operatorValue,
8
+ tag
9
+ } from "./cn0n68ft.js";
10
+ import {
11
+ OkmError2
12
+ } from "./52szzakm.js";
13
+
14
+ // src/dialects/pg/ops/fragment.ts
15
+ var IDENT = Symbol("okmodel.sql.ident");
16
+ var COLUMN = Symbol("okmodel.sql.column");
17
+ function fragmentError(message, fix) {
18
+ throw new OkmError2("OKM1125", message, { fix: { summary: fix } });
19
+ }
20
+ function isFragmentParts(value) {
21
+ return Array.isArray(value) && value.every(isPart);
22
+ }
23
+ function isPart(value) {
24
+ if (typeof value !== "object" || value === null || !("k" in value))
25
+ return false;
26
+ const kind = value.k;
27
+ if (kind === "t")
28
+ return "s" in value && typeof value.s === "string";
29
+ if (kind === "p")
30
+ return "v" in value && typeof value.v === "string";
31
+ if (kind === "n" || kind === "c")
32
+ return true;
33
+ if (kind === "i")
34
+ return "n" in value && typeof value.n === "string";
35
+ if (kind === "f")
36
+ return "parts" in value && isFragmentParts(value.parts);
37
+ return false;
38
+ }
39
+ function readSelectFragment(value) {
40
+ if (!isOperator(value) || operatorName(value) !== "sql")
41
+ return;
42
+ const named = value;
43
+ if (typeof named.as !== "string") {
44
+ fragmentError("A select fragment needs as(name).", 'Call .as("len") and pass that value in select.');
45
+ }
46
+ const stored = operatorValue(value);
47
+ if (!isFragmentParts(stored)) {
48
+ fragmentError("A fragment was not created by fragment``.", "Call fragment`...`.");
49
+ }
50
+ const textual = named.text === true;
51
+ return textual ? { as: named.as, parts: stored, textual: true } : { as: named.as, parts: stored };
52
+ }
53
+ function scanLiteral(literal, state) {
54
+ for (let index = 0;index < literal.length; index += 1) {
55
+ const char = literal[index] ?? "";
56
+ const code = literal.charCodeAt(index);
57
+ if (state.quote !== undefined) {
58
+ if (char !== state.quote)
59
+ continue;
60
+ if (literal[index + 1] === state.quote) {
61
+ index += 1;
62
+ continue;
63
+ }
64
+ state.quote = undefined;
65
+ continue;
66
+ }
67
+ if (code <= 31 && code !== 9 && code !== 10 && code !== 13 || code === 127) {
68
+ fragmentError("A fragment literal contains a control character.", "Remove NUL and other control characters. A newline, tab, or return is allowed.");
69
+ }
70
+ if (char === "'" || char === '"') {
71
+ state.quote = char;
72
+ continue;
73
+ }
74
+ if (char === "(") {
75
+ state.paren += 1;
76
+ continue;
77
+ }
78
+ if (char === ")") {
79
+ state.paren -= 1;
80
+ if (state.paren < 0) {
81
+ fragmentError("A fragment has unbalanced SQL.", "Keep parentheses and quotes balanced. A fragment cannot close the surrounding predicate.");
82
+ }
83
+ continue;
84
+ }
85
+ if (char === ";") {
86
+ fragmentError("A fragment cannot include a semicolon.", "Pass the value as an interpolation. The fragment is one expression.");
87
+ }
88
+ if (char === "$") {
89
+ fragmentError("A fragment cannot include a dollar quote or a parameter marker.", "Interpolate the value. The planner numbers parameters.");
90
+ }
91
+ if (char === "-" && literal[index + 1] === "-" || char === "/" && literal[index + 1] === "*") {
92
+ fragmentError("A fragment cannot include a comment.", "Remove the comment. A comment can hide the rest of the predicate.");
93
+ }
94
+ }
95
+ }
96
+ function appendText(parts, literal) {
97
+ if (literal.length === 0)
98
+ return;
99
+ parts.push({ k: "t", s: literal });
100
+ }
101
+ function appendValue(parts, value) {
102
+ if (value === null) {
103
+ parts.push({ k: "n" });
104
+ return;
105
+ }
106
+ if (typeof value === "string") {
107
+ parts.push({ k: "p", v: value });
108
+ return;
109
+ }
110
+ if (typeof value === "number") {
111
+ if (!Number.isFinite(value)) {
112
+ fragmentError("A fragment needs a finite number.", "Pass a finite number, or leave it out.");
113
+ }
114
+ parts.push({ k: "p", v: String(value) });
115
+ return;
116
+ }
117
+ if (typeof value === "boolean") {
118
+ parts.push({ k: "p", v: value ? "true" : "false" });
119
+ return;
120
+ }
121
+ if (typeof value === "bigint") {
122
+ parts.push({ k: "p", v: String(value) });
123
+ return;
124
+ }
125
+ if (typeof value === "object") {
126
+ if (COLUMN in value) {
127
+ parts.push({ k: "c" });
128
+ return;
129
+ }
130
+ if (IDENT in value) {
131
+ const name = value[IDENT];
132
+ if (typeof name === "string") {
133
+ parts.push({ k: "i", n: name });
134
+ return;
135
+ }
136
+ }
137
+ if (isOperator(value) && operatorName(value) === "sql") {
138
+ const nested = operatorValue(value);
139
+ if (!isFragmentParts(nested)) {
140
+ fragmentError("A fragment was not created by fragment``.", "Call fragment`...`.");
141
+ }
142
+ parts.push({ k: "f", parts: nested });
143
+ return;
144
+ }
145
+ }
146
+ fragmentError("A fragment cannot interpolate that value.", "Interpolate a string, number, boolean, null, ident(name), fragment.column, or another fragment.");
147
+ }
148
+ function hasSql(parts) {
149
+ for (const part of parts) {
150
+ if (part.k === "t") {
151
+ if (part.s.trim().length > 0)
152
+ return true;
153
+ continue;
154
+ }
155
+ return true;
156
+ }
157
+ return false;
158
+ }
159
+ function compile(strings, values) {
160
+ const state = { quote: undefined, paren: 0 };
161
+ const parts = [];
162
+ for (let index = 0;index < values.length + 1; index += 1) {
163
+ const literal = strings[index] ?? "";
164
+ scanLiteral(literal, state);
165
+ appendText(parts, literal);
166
+ if (index === values.length)
167
+ continue;
168
+ if (state.quote !== undefined) {
169
+ fragmentError("A fragment cannot interpolate inside quotes.", "Do not put an interpolation inside quotes. Write title = ${name}.");
170
+ }
171
+ appendValue(parts, values[index]);
172
+ }
173
+ if (state.quote !== undefined || state.paren !== 0) {
174
+ fragmentError("A fragment has unbalanced SQL.", "Keep parentheses and quotes balanced. A fragment cannot close the surrounding predicate.");
175
+ }
176
+ if (!hasSql(parts)) {
177
+ fragmentError("A fragment needs SQL text.", "Write an expression, or interpolate a value.");
178
+ }
179
+ return parts;
180
+ }
181
+ function isTemplate(value) {
182
+ return Array.isArray(value) && "raw" in value;
183
+ }
184
+ function bind(parts, textual = false) {
185
+ const tagged = tag("sql", parts);
186
+ return Object.assign(tagged, {
187
+ as(name) {
188
+ if (typeof name !== "string" || name.length === 0) {
189
+ fragmentError("as(name) needs a result name.", 'Call .as("len") with a name that is not a column.');
190
+ }
191
+ assertNoControl(name, "fragment as");
192
+ const selected = Object.assign(tag("sql", parts), { as: name });
193
+ return textual ? Object.assign(selected, { text: true }) : selected;
194
+ }
195
+ });
196
+ }
197
+ function sqlExpression(parts, textual = false) {
198
+ return bind(parts, textual);
199
+ }
200
+ function identName(value) {
201
+ if (typeof value !== "object" || value === null || !(IDENT in value))
202
+ return;
203
+ const stored = value[IDENT];
204
+ return typeof stored === "string" ? stored : undefined;
205
+ }
206
+ function fragmentTag(strings, ...values) {
207
+ if (!isTemplate(strings)) {
208
+ fragmentError("Call fragment as a template: fragment`...`.", "Write fragment`length(${fragment.column}) > ${1}`.");
209
+ }
210
+ return bind(compile(strings, values));
211
+ }
212
+ var fragment2 = Object.assign(fragmentTag, {
213
+ column: { [COLUMN]: true }
214
+ });
215
+ function ident2(name) {
216
+ if (typeof name !== "string" || name.length === 0) {
217
+ throw new OkmError2("OKM1122", "ident needs a name.", {
218
+ fix: { summary: "Pass the field name, such as title." }
219
+ });
220
+ }
221
+ assertNoControl(name, "ident");
222
+ return { [IDENT]: name };
223
+ }
224
+
225
+ export { isFragmentParts, readSelectFragment, sqlExpression, identName, fragment2, ident2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  build2,
3
3
  identityColumn2
4
- } from "./xjk7hnn5.js";
4
+ } from "./s7he5e5d.js";
5
5
  export {
6
6
  build2 as build,
7
7
  identityColumn2 as identityColumn
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  open2
3
- } from "./14vx95q4.js";
3
+ } from "./dd5pmnky.js";
4
4
  import {
5
5
  startupHash2
6
- } from "./qq3899ht.js";
6
+ } from "./12z7aznj.js";
7
+ import {
8
+ quoteIdent2
9
+ } from "./fk9vef30.js";
7
10
  import {
8
11
  runTarget,
9
12
  assumeRole,
@@ -14,12 +17,12 @@ import {
14
17
  provisionMark,
15
18
  expandProvisioned,
16
19
  installSnapshot
17
- } from "./m6p12kbr.js";
20
+ } from "./3456242y.js";
18
21
  import {
19
22
  assertCreateRole,
20
23
  currentUser,
21
24
  roleExists
22
- } from "./8skf0cam.js";
25
+ } from "./jpybhf98.js";
23
26
  import {
24
27
  projectPath,
25
28
  loadMigrations,
@@ -30,7 +33,7 @@ import {
30
33
  projectHead,
31
34
  loadBuiltSchema,
32
35
  loadConfig
33
- } from "./gs74dbj5.js";
36
+ } from "./2zdxkt7b.js";
34
37
  import {
35
38
  changesRole,
36
39
  batchSizeField,
@@ -41,7 +44,7 @@ import {
41
44
  assertDirectConnection,
42
45
  assertStableBackend,
43
46
  selectTarget
44
- } from "./tsvww22q.js";
47
+ } from "./6nae0spm.js";
45
48
  import {
46
49
  UUIDV7_POSTGRES,
47
50
  uuidv7NeedsPostgres
@@ -198,6 +201,7 @@ async function applyTarget2(request) {
198
201
  await prepareMigrationRole(connection, request, session);
199
202
  await assertExtensionsAvailable(connection, request.migrations);
200
203
  await assertUuidV7Available(connection, request.migrations);
204
+ await enterCatalogSchema(connection, request.schema ?? "public");
201
205
  const state = request.snapshot === undefined ? undefined : await targetState(connection);
202
206
  if (request.snapshot !== undefined && state !== undefined) {
203
207
  if (state.kind === "empty") {
@@ -273,6 +277,7 @@ nothing to apply
273
277
  reference: built === undefined ? [] : readReference(built.tables, built.casing, head.catalog)
274
278
  },
275
279
  ...config.roles !== undefined ? { migrationRole: config.roles.migration, appRole: config.roles.app } : {},
280
+ ...catalogSchema(config.namespace),
276
281
  lintDirectory: directory,
277
282
  onProgress: (line) => {
278
283
  if (write !== undefined)
@@ -299,6 +304,7 @@ async function pushProject2(cwd, flags) {
299
304
  after: head.catalog,
300
305
  renames: head.renames,
301
306
  name: "push",
307
+ ...catalogSchema(config.namespace),
302
308
  ...batchSizeField(config.backfill?.batchSize)
303
309
  });
304
310
  if (plan.steps.length === 0)
@@ -319,7 +325,8 @@ no changes
319
325
  steps: plan.steps
320
326
  }
321
327
  ],
322
- ...config.roles !== undefined ? { migrationRole: config.roles.migration, appRole: config.roles.app } : {}
328
+ ...config.roles !== undefined ? { migrationRole: config.roles.migration, appRole: config.roles.app } : {},
329
+ ...catalogSchema(config.namespace)
323
330
  });
324
331
  return formatReport(report);
325
332
  }
@@ -514,6 +521,17 @@ async function insertReference(connection, request) {
514
521
  function concreteSchema(request) {
515
522
  return request.searchPath ?? request.schema ?? "public";
516
523
  }
524
+ function catalogSchema(namespace) {
525
+ if (namespace === undefined || namespace === "public")
526
+ return;
527
+ return { schema: namespace };
528
+ }
529
+ async function enterCatalogSchema(connection, schema) {
530
+ if (schema === "public")
531
+ return;
532
+ await connection.execute(`create schema if not exists ${quoteIdent2(schema)}`);
533
+ await connection.execute(`set search_path to ${quoteIdent2(schema)}`);
534
+ }
517
535
  async function targetState(connection) {
518
536
  const meta = await connection.execute(`select to_regclass('okm_meta') is not null
519
537
  or to_regclass('okm_history') is not null
@@ -3,7 +3,7 @@ import {
3
3
  readHandle,
4
4
  readCall,
5
5
  attachHttp
6
- } from "./tbrvgw6z.js";
6
+ } from "./npdftanb.js";
7
7
  import {
8
8
  selectedColumns,
9
9
  parseOrder,
@@ -15,7 +15,7 @@ import {
15
15
  isRecord,
16
16
  registerFailFix,
17
17
  fail2
18
- } from "./67txcrcw.js";
18
+ } from "./kgwp4jdd.js";
19
19
  import {
20
20
  OkmError2,
21
21
  throwNamed2
@@ -5,11 +5,11 @@ import {
5
5
  send2,
6
6
  reserve,
7
7
  park
8
- } from "./x933k9a3.js";
8
+ } from "./62b603gr.js";
9
9
  import {
10
10
  resetSession2,
11
11
  refuseWhenLost2
12
- } from "./zm0ptry0.js";
12
+ } from "./99qp9vtg.js";
13
13
  import {
14
14
  cursorStream
15
15
  } from "./7kms6fvj.js";
@@ -18,14 +18,14 @@ import {
18
18
  } from "./cnkky55j.js";
19
19
  import {
20
20
  noTimeout
21
- } from "./79dt02vc.js";
21
+ } from "./tr64w5p0.js";
22
22
  import {
23
23
  WireSession
24
- } from "./1qa0qajz.js";
24
+ } from "./e275q7sd.js";
25
25
  import {
26
26
  rejectClosed,
27
27
  runCall
28
- } from "./kb2sdhfb.js";
28
+ } from "./mfvx6kjx.js";
29
29
 
30
30
  // src/adapters/pg/bunsql-extra.ts
31
31
  async function recover(sql, error, text, depth, clientRead, closedDuring, again) {
@@ -2,11 +2,11 @@ import {
2
2
  assertAuthorDrift2,
3
3
  catalogQuery2,
4
4
  managedRoleOptions2
5
- } from "./ax7qv55k.js";
6
- import"./b5pftnn2.js";
7
- import"./tsvww22q.js";
8
- import"./9s0ypp87.js";
9
- import"./qq3899ht.js";
5
+ } from "./90sg0w5a.js";
6
+ import"./myk8fswx.js";
7
+ import"./6nae0spm.js";
8
+ import"./fk9vef30.js";
9
+ import"./12z7aznj.js";
10
10
  export {
11
11
  assertAuthorDrift2 as assertAuthorDrift,
12
12
  catalogQuery2 as catalogQuery,
@@ -9,7 +9,7 @@ import {
9
9
  loadTrustedCatalog2,
10
10
  catalogFileText2,
11
11
  parseCatalog2
12
- } from "./qq3899ht.js";
12
+ } from "./12z7aznj.js";
13
13
  export {
14
14
  catalogFileText2 as catalogFileText,
15
15
  catalogHash2 as catalogHash,
@@ -6,7 +6,7 @@ import {
6
6
  runCall,
7
7
  EMPTY_NOTICES,
8
8
  resultFrom
9
- } from "./kb2sdhfb.js";
9
+ } from "./mfvx6kjx.js";
10
10
 
11
11
  // src/adapters/pg/postgresjs.ts
12
12
  import net from "node:net";
@@ -118,17 +118,17 @@ function open2(config) {
118
118
  return sockets.occupy(() => runCall(closed, options, (watch) => root.query(text, params, watch)));
119
119
  },
120
120
  batch(statements, options) {
121
- return sockets.occupy(() => import("./je4axnm8.js").then((mod) => mod.runBatch(held, statements, options)));
121
+ return sockets.occupy(() => import("./fdsz3w80.js").then((mod) => mod.runBatch(held, statements, options)));
122
122
  },
123
123
  reserve() {
124
124
  const gate = sockets.busyGate();
125
125
  gate.enter();
126
- return import("./je4axnm8.js").then((mod) => mod.holdCheckout(gate, () => mod.checkout(held)), (error) => {
126
+ return import("./fdsz3w80.js").then((mod) => mod.holdCheckout(gate, () => mod.checkout(held)), (error) => {
127
127
  gate.leave();
128
128
  throw error;
129
129
  });
130
130
  },
131
- describe: (text, params) => sockets.occupy(() => import("./je4axnm8.js").then((mod) => mod.describe(sql, text, params))),
131
+ describe: (text, params) => sockets.occupy(() => import("./fdsz3w80.js").then((mod) => mod.describe(sql, text, params))),
132
132
  stream(text, params) {
133
133
  const gate = sockets.busyGate();
134
134
  return async function* () {
@@ -143,7 +143,7 @@ function open2(config) {
143
143
  listen(channel, onNotify) {
144
144
  const gate = sockets.listenerGate();
145
145
  gate.enter();
146
- return import("./je4axnm8.js").then((mod) => mod.holdListener(gate, async () => {
146
+ return import("./fdsz3w80.js").then((mod) => mod.holdListener(gate, async () => {
147
147
  const listening = await sql.listen(channel, onNotify);
148
148
  return async () => {
149
149
  await listening.unlisten();
@@ -213,7 +213,7 @@ class PgSession {
213
213
  onAbort();
214
214
  else
215
215
  watch.signal.addEventListener("abort", onAbort, { once: true });
216
- return import("./je4axnm8.js").then((mod) => mod.watchQuery(pending, watch, onAbort, {
216
+ return import("./fdsz3w80.js").then((mod) => mod.watchQuery(pending, watch, onAbort, {
217
217
  start,
218
218
  text,
219
219
  notices: this.notices,
@@ -265,7 +265,7 @@ class PgSession {
265
265
  }
266
266
  }
267
267
  async function* loadStream(sql, text, params) {
268
- const { stream } = await import("./je4axnm8.js");
268
+ const { stream } = await import("./fdsz3w80.js");
269
269
  yield* stream(sql, text, params);
270
270
  }
271
271
  function send(sql, text, params, named) {
@@ -7,12 +7,12 @@ import {
7
7
  import {
8
8
  withHttp,
9
9
  settleCall
10
- } from "./tbrvgw6z.js";
10
+ } from "./npdftanb.js";
11
11
  import {
12
12
  rejectKeys,
13
13
  isRecord,
14
14
  fail2
15
- } from "./67txcrcw.js";
15
+ } from "./kgwp4jdd.js";
16
16
  import {
17
17
  OkmError2
18
18
  } from "./52szzakm.js";
@@ -4,7 +4,7 @@ import {
4
4
  nextTransactionDepth,
5
5
  EMPTY_NOTICES,
6
6
  resultFrom
7
- } from "./kb2sdhfb.js";
7
+ } from "./mfvx6kjx.js";
8
8
 
9
9
  // src/adapters/pg/session.ts
10
10
  function noticeBuffer() {