okmodel 0.5.1 → 0.7.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 (233) hide show
  1. package/README.md +100 -1116
  2. package/dist/adapters/capabilities.d.ts +3 -0
  3. package/dist/adapters/failure.d.ts +13 -2
  4. package/dist/adapters/lazy-errors.d.ts +22 -0
  5. package/dist/adapters/pg/bunsql-extra.d.ts +54 -3
  6. package/dist/adapters/pg/bunsql.d.ts +14 -1
  7. package/dist/adapters/pg/cursor.d.ts +17 -0
  8. package/dist/adapters/pg/no-inflight-timeout.d.ts +20 -0
  9. package/dist/adapters/pg/nodepostgres-extra.d.ts +22 -1
  10. package/dist/adapters/pg/nodepostgres.d.ts +12 -0
  11. package/dist/adapters/pg/pglite-wire.d.ts +24 -0
  12. package/dist/adapters/pg/pglite.d.ts +10 -0
  13. package/dist/adapters/pg/postgres-extra.d.ts +41 -3
  14. package/dist/adapters/pg/reserved.d.ts +42 -0
  15. package/dist/adapters/pg/session.d.ts +0 -18
  16. package/dist/contracts/catalog/document.d.ts +19 -5
  17. package/dist/contracts/catalog/object.d.ts +2 -1
  18. package/dist/contracts/catalog/policy.d.ts +48 -0
  19. package/dist/contracts/catalog/types.d.ts +25 -1
  20. package/dist/contracts/catalog/view.d.ts +2 -0
  21. package/dist/contracts/connection.d.ts +7 -6
  22. package/dist/contracts/internal.js +1 -1
  23. package/dist/contracts/location.d.ts +10 -0
  24. package/dist/dialects/pg/column.d.ts +13 -2
  25. package/dist/dialects/pg/ddl.d.ts +37 -1
  26. package/dist/dialects/pg/emit.d.ts +19 -1
  27. package/dist/dialects/pg/errors.d.ts +32 -1
  28. package/dist/dialects/pg/ext/citext.js +1 -1
  29. package/dist/dialects/pg/ext/index.js +1 -1
  30. package/dist/dialects/pg/ext/pg-trgm.js +1 -1
  31. package/dist/dialects/pg/filter-parse.d.ts +5 -4
  32. package/dist/dialects/pg/floor.d.ts +68 -0
  33. package/dist/dialects/pg/fn/index.js +2 -2
  34. package/dist/dialects/pg/index.d.ts +8 -2
  35. package/dist/dialects/pg/index.js +67 -171
  36. package/dist/dialects/pg/introspect.d.ts +7 -0
  37. package/dist/dialects/pg/keys.d.ts +11 -8
  38. package/dist/dialects/pg/model.d.ts +47 -2
  39. package/dist/dialects/pg/morph.d.ts +43 -0
  40. package/dist/dialects/pg/operator-fit.d.ts +2 -2
  41. package/dist/dialects/pg/operators.d.ts +14 -7
  42. package/dist/dialects/pg/ops/bucket.d.ts +65 -0
  43. package/dist/dialects/pg/ops/inc.d.ts +2 -2
  44. package/dist/dialects/pg/ops/matches.d.ts +9 -12
  45. package/dist/dialects/pg/ops/relevance.d.ts +13 -0
  46. package/dist/dialects/pg/ops/search-query.d.ts +22 -0
  47. package/dist/dialects/pg/ops/window.d.ts +103 -0
  48. package/dist/dialects/pg/owner.d.ts +42 -0
  49. package/dist/dialects/pg/path-endpoint.d.ts +20 -0
  50. package/dist/dialects/pg/preset.d.ts +1 -1
  51. package/dist/dialects/pg/relations.d.ts +100 -3
  52. package/dist/dialects/pg/role/check.d.ts +3 -0
  53. package/dist/dialects/pg/role/index.d.ts +71 -6
  54. package/dist/dialects/pg/role/sql.d.ts +11 -0
  55. package/dist/dialects/pg/schema.d.ts +33 -3
  56. package/dist/dialects/pg/table.d.ts +25 -3
  57. package/dist/dialects/pg/tenancy.d.ts +45 -3
  58. package/dist/dialects/pg/view/client.d.ts +19 -1
  59. package/dist/dialects/pg/view/index.d.ts +4 -0
  60. package/dist/dialects/pg/view/index.js +21 -178
  61. package/dist/dialects/pg/view/refresh.d.ts +24 -0
  62. package/dist/runtime/aggregate.d.ts +8 -2
  63. package/dist/runtime/batch.d.ts +1 -1
  64. package/dist/runtime/bucket-group.d.ts +70 -0
  65. package/dist/runtime/conflict.d.ts +24 -6
  66. package/dist/runtime/drift.d.ts +9 -0
  67. package/dist/runtime/include.d.ts +0 -8
  68. package/dist/runtime/inflight.d.ts +14 -0
  69. package/dist/runtime/page.d.ts +4 -1
  70. package/dist/runtime/pg/bun.js +12 -5
  71. package/dist/runtime/pg/pg.js +5 -5
  72. package/dist/runtime/pg/pglite.d.ts +1 -0
  73. package/dist/runtime/pg/pglite.js +9 -8
  74. package/dist/runtime/pg/postgresjs.js +5 -5
  75. package/dist/runtime/plan.d.ts +113 -15
  76. package/dist/runtime/predicate.d.ts +19 -0
  77. package/dist/runtime/read-stream.d.ts +13 -16
  78. package/dist/runtime/result-name.d.ts +17 -0
  79. package/dist/runtime/safety/index.js +1 -1
  80. package/dist/runtime/server-check.d.ts +3 -3
  81. package/dist/runtime/sort-bind.d.ts +21 -0
  82. package/dist/runtime/sort.d.ts +56 -0
  83. package/dist/runtime/sync.d.ts +70 -0
  84. package/dist/runtime/tenancy/composite.d.ts +26 -0
  85. package/dist/runtime/tenancy/context.d.ts +16 -0
  86. package/dist/runtime/tenancy/index.d.ts +9 -5
  87. package/dist/runtime/tenancy/index.js +1511 -38
  88. package/dist/runtime/tenancy/path.d.ts +87 -0
  89. package/dist/runtime/tenancy/rls.d.ts +67 -0
  90. package/dist/runtime/tenancy/via.d.ts +22 -0
  91. package/dist/runtime/text-search.d.ts +20 -0
  92. package/dist/runtime/traits/index.d.ts +80 -0
  93. package/dist/runtime/traits/index.js +187 -17
  94. package/dist/runtime/tree.d.ts +38 -0
  95. package/dist/runtime/types.d.ts +231 -23
  96. package/dist/runtime/validate/index.js +4 -4
  97. package/dist/runtime/version.d.ts +39 -0
  98. package/dist/runtime/window.d.ts +21 -0
  99. package/dist/runtime/write.d.ts +55 -3
  100. package/dist/shared/{krxx77g0.js → 14vx95q4.js} +12 -18
  101. package/dist/shared/1est4ezg.js +313 -0
  102. package/dist/shared/{4az561fn.js → 1qa0qajz.js} +8 -23
  103. package/dist/shared/1w508jbr.js +1611 -0
  104. package/dist/shared/2c13q96h.js +18 -0
  105. package/dist/shared/2d3xq4ps.js +9 -0
  106. package/dist/shared/2shdbn8q.js +23 -0
  107. package/dist/shared/{t4tbsy9h.js → 358zsv4r.js} +1 -1
  108. package/dist/shared/3v7t1yrv.js +208 -0
  109. package/dist/shared/5e3tf63j.js +220 -0
  110. package/dist/shared/5fe3kbsh.js +10 -0
  111. package/dist/shared/5v3xf80k.js +37 -0
  112. package/dist/shared/{51mvgj8w.js → 63qtkrca.js} +130 -3
  113. package/dist/shared/{gbtcc2d7.js → 67txcrcw.js} +62 -66
  114. package/dist/shared/79dt02vc.js +12 -0
  115. package/dist/shared/{v36c5g6p.js → 7k9grvf6.js} +407 -14
  116. package/dist/shared/7kms6fvj.js +20 -0
  117. package/dist/shared/7mnme5tn.js +8 -0
  118. package/dist/shared/7n7ddwt4.js +6 -0
  119. package/dist/shared/{87jvvhnt.js → 81ebdx9p.js} +48 -68
  120. package/dist/shared/{szm0cksa.js → 8skf0cam.js} +34 -6
  121. package/dist/shared/{gjthds9j.js → 9628a9xt.js} +1 -1
  122. package/dist/shared/9a4ae4p8.js +31 -0
  123. package/dist/shared/{8xsbagad.js → 9s0ypp87.js} +88 -7
  124. package/dist/shared/9y3mmmh1.js +436 -0
  125. package/dist/shared/ab9gmbwy.js +213 -0
  126. package/dist/shared/{sycnx8gt.js → ax7qv55k.js} +18 -8
  127. package/dist/shared/{f5cw5q5r.js → aytqh5y2.js} +6 -4
  128. package/dist/shared/{fancm5pt.js → b5pftnn2.js} +138 -15
  129. package/dist/shared/{efmy2gcg.js → b76b8d95.js} +2 -2
  130. package/dist/shared/bdk4sty6.js +58 -0
  131. package/dist/shared/{32zqc1dw.js → bg3rym3g.js} +63 -32
  132. package/dist/shared/{0t22wwh1.js → bm22fvzr.js} +16 -14
  133. package/dist/shared/bz84tkzm.js +342 -0
  134. package/dist/shared/{31vm914h.js → cm3w0ywp.js} +15 -16
  135. package/dist/shared/cn957f8d.js +179 -0
  136. package/dist/shared/{pf0d8f77.js → cnkky55j.js} +25 -14
  137. package/dist/shared/{5fqx9yh4.js → dk8v79p3.js} +3 -1
  138. package/dist/shared/{nkaxvt9q.js → dkxgzaqd.js} +224 -19
  139. package/dist/shared/dzj09cye.js +10 -0
  140. package/dist/shared/{4m9fn52z.js → ed0b8k4s.js} +1 -1
  141. package/dist/shared/{z2rnngj4.js → ek2wt2dz.js} +8 -5
  142. package/dist/shared/exn3sd90.js +359 -0
  143. package/dist/shared/g6evj1j3.js +66 -0
  144. package/dist/shared/ga9j92qj.js +25 -0
  145. package/dist/shared/{qv2ydck9.js → gs74dbj5.js} +651 -76
  146. package/dist/shared/gzaveazc.js +285 -0
  147. package/dist/shared/{8rsy3hxz.js → h15jx9bc.js} +1 -1
  148. package/dist/shared/{dyj86cmj.js → hyh73qk6.js} +3 -3
  149. package/dist/shared/je4axnm8.js +22 -0
  150. package/dist/shared/{ycatkxmq.js → jgqj11w4.js} +1 -1
  151. package/dist/shared/{6qd27mx0.js → jvd0mqag.js} +5 -5
  152. package/dist/shared/jznfax0y.js +155 -0
  153. package/dist/shared/{cgbamx3e.js → kb2sdhfb.js} +7 -4
  154. package/dist/shared/{ps7a6h14.js → kr0jzbw2.js} +12 -8
  155. package/dist/shared/{janx09m5.js → ktz42yez.js} +20 -8
  156. package/dist/shared/{gde73es6.js → m6p12kbr.js} +56 -55
  157. package/dist/shared/{r6nwkxnt.js → m7n9h2a5.js} +4 -4
  158. package/dist/shared/{672t5vym.js → mss6ctgv.js} +2 -2
  159. package/dist/shared/{nxdp2ze3.js → mtaszv5a.js} +144 -12
  160. package/dist/shared/n816peh1.js +45 -0
  161. package/dist/shared/nbw1z4yd.js +18 -0
  162. package/dist/shared/{cctw17hj.js → p6qc5gcp.js} +38 -34
  163. package/dist/shared/{6rk2gen5.js → pbp1ss85.js} +20 -17
  164. package/dist/shared/pt94kz7f.js +6 -0
  165. package/dist/shared/{wq9n6pwr.js → pz6rj8ay.js} +82 -9
  166. package/dist/shared/q5c6ngn3.js +13 -0
  167. package/dist/shared/{8bwbwy8h.js → qq3899ht.js} +128 -18
  168. package/dist/shared/{8ktwd3rh.js → r3j8s5y0.js} +1 -1
  169. package/dist/shared/rhs3xe4k.js +7 -0
  170. package/dist/shared/{ntneex2a.js → rpycarcr.js} +6 -6
  171. package/dist/shared/{sdc7r2ww.js → rs73fca9.js} +8 -8
  172. package/dist/shared/{tm5ab8we.js → sfz1ksn6.js} +7 -4
  173. package/dist/shared/{6mnp99hx.js → svncdeh5.js} +16 -12
  174. package/dist/shared/{hf22e0wt.js → tbrvgw6z.js} +62 -42
  175. package/dist/shared/te5as7z7.js +622 -0
  176. package/dist/shared/{ga3sfy93.js → tsvww22q.js} +535 -200
  177. package/dist/shared/{47x8x9ze.js → ttsqgp4p.js} +20 -13
  178. package/dist/shared/{x72jb7ad.js → v8g1vgv8.js} +1 -1
  179. package/dist/shared/vb6qfyve.js +152 -0
  180. package/dist/shared/{r2sp8hrc.js → vczs8gd4.js} +22 -13
  181. package/dist/shared/{1g0drakv.js → vqrjpcqn.js} +145 -3
  182. package/dist/shared/{2pqx26h8.js → w72kgg4q.js} +31 -22
  183. package/dist/shared/{96qcj21c.js → w79hsckn.js} +16 -51
  184. package/dist/shared/wa07eas9.js +730 -0
  185. package/dist/shared/{k8v5v5wj.js → x933k9a3.js} +75 -34
  186. package/dist/shared/{cr74e96e.js → xhfsfkgk.js} +62 -28
  187. package/dist/shared/xjk7hnn5.js +272 -0
  188. package/dist/shared/{5enne4ma.js → xnxsed62.js} +66 -113
  189. package/dist/shared/xqve9598.js +53 -0
  190. package/dist/shared/{9x25fxhc.js → y34a8714.js} +1 -1
  191. package/dist/shared/{k7dwkhvq.js → y6jdds7g.js} +4 -1
  192. package/dist/shared/y6njgyda.js +249 -0
  193. package/dist/shared/{c9z5g0fm.js → ywr8hmey.js} +5 -2
  194. package/dist/shared/{g7ez901n.js → ywspezzx.js} +1 -1
  195. package/dist/shared/z7s6fpxv.js +62 -0
  196. package/dist/shared/{n7mcc1gk.js → zchaghkf.js} +4 -3
  197. package/dist/shared/{9m80mkac.js → ze4hxsmy.js} +1 -1
  198. package/dist/shared/zm0ptry0.js +40 -0
  199. package/dist/shared/{nsva2a6b.js → znm0bpp5.js} +3 -0
  200. package/dist/shared/zp9fmend.js +145 -0
  201. package/dist/shared/{y005b761.js → zy8r7qvz.js} +6 -2
  202. package/dist/tooling/cli.js +41 -15
  203. package/dist/tooling/migrate/apply.d.ts +14 -0
  204. package/dist/tooling/migrate/check.d.ts +3 -4
  205. package/dist/tooling/migrate/classify.d.ts +4 -0
  206. package/dist/tooling/migrate/config.d.ts +3 -2
  207. package/dist/tooling/migrate/engine.d.ts +3 -2
  208. package/dist/tooling/migrate/files.d.ts +11 -1
  209. package/dist/tooling/migrate/index.js +14 -14
  210. package/dist/tooling/migrate/lint.d.ts +1 -1
  211. package/dist/tooling/migrate/lost.d.ts +28 -0
  212. package/dist/tooling/migrate/paths.d.ts +14 -0
  213. package/dist/tooling/migrate/plan.d.ts +6 -3
  214. package/dist/tooling/migrate/runner.d.ts +25 -0
  215. package/dist/tooling/migrate/sandbox.d.ts +57 -0
  216. package/dist/tooling/migrate/sql-lex.d.ts +20 -3
  217. package/dist/tooling/migrate/text.d.ts +42 -0
  218. package/dist/tooling/node-version.d.ts +21 -0
  219. package/dist/tooling/testing/facts.d.ts +33 -5
  220. package/dist/tooling/testing/index.d.ts +1 -1
  221. package/dist/tooling/testing/index.js +3 -3
  222. package/dist/tooling/testing/isolation.d.ts +11 -5
  223. package/package.json +8 -3
  224. package/dist/shared/7m88x3e9.js +0 -45
  225. package/dist/shared/7zwwyh0v.js +0 -448
  226. package/dist/shared/aj2qxyhj.js +0 -90
  227. package/dist/shared/caw8b9d8.js +0 -204
  228. package/dist/shared/jwtxdj06.js +0 -76
  229. package/dist/shared/kfjp0gck.js +0 -212
  230. package/dist/shared/q58y17hy.js +0 -21
  231. package/dist/shared/qm7cdtvr.js +0 -912
  232. package/dist/shared/r8x5qhd7.js +0 -86
  233. package/dist/shared/zqrnhwsq.js +0 -31
@@ -1,22 +1,25 @@
1
+ import {
2
+ policyObject
3
+ } from "./bdk4sty6.js";
1
4
  import {
2
5
  functionObject,
3
6
  triggerObject
4
- } from "./9x25fxhc.js";
7
+ } from "./y34a8714.js";
5
8
  import {
6
9
  viewObject,
7
10
  materializedViewObject,
8
11
  materializedViewIndex
9
- } from "./y005b761.js";
12
+ } from "./zy8r7qvz.js";
10
13
  import {
11
14
  extensionObject
12
- } from "./8ktwd3rh.js";
15
+ } from "./r3j8s5y0.js";
13
16
  import {
14
17
  dependencyOrder,
15
18
  catalog,
16
19
  enumType,
17
20
  domainType,
18
21
  isDomain
19
- } from "./g7ez901n.js";
22
+ } from "./ywspezzx.js";
20
23
  import {
21
24
  canonicalJson,
22
25
  staticNamespace2,
@@ -35,7 +38,7 @@ import {
35
38
  normaliseEdges,
36
39
  compareText,
37
40
  assertProvenance
38
- } from "./t4tbsy9h.js";
41
+ } from "./358zsv4r.js";
39
42
  import {
40
43
  OWNERS2,
41
44
  BUILT_KINDS2,
@@ -230,9 +233,28 @@ function catalogHash2(source) {
230
233
  return hash;
231
234
  }
232
235
  function startupCatalog2(source) {
233
- if (!source.objects.some(isPrivilege))
236
+ let privileges = false;
237
+ let foreign = false;
238
+ for (const object of source.objects) {
239
+ if (isPrivilege(object))
240
+ privileges = true;
241
+ else if (object.owner !== "managed")
242
+ foreign = true;
243
+ if (privileges && foreign)
244
+ break;
245
+ }
246
+ if (!privileges && !foreign)
234
247
  return source;
235
- return { version: source.version, objects: source.objects.filter((item) => !isPrivilege(item)) };
248
+ return {
249
+ version: source.version,
250
+ objects: source.objects.flatMap((item) => {
251
+ if (isPrivilege(item))
252
+ return [];
253
+ if (item.owner === "managed")
254
+ return [item];
255
+ return [{ ...item, owner: "managed" }];
256
+ })
257
+ };
236
258
  }
237
259
  function startupHash2(source) {
238
260
  return catalogHash2(startupCatalog2(source));
@@ -241,12 +263,13 @@ function isPrivilege(object) {
241
263
  return object.kind === "role" || object.kind === "grant" || object.kind === "defaultPrivilege";
242
264
  }
243
265
  function loadTrustedCatalog2(text, hash) {
244
- if (sha2562(text) !== hash) {
266
+ const canonical = catalogFileText2(text);
267
+ if (sha2562(canonical) !== hash) {
245
268
  catalogError2("OKM1027", "Catalog hash does not match the build artifact.");
246
269
  }
247
270
  let parsed;
248
271
  try {
249
- parsed = JSON.parse(text);
272
+ parsed = JSON.parse(canonical);
250
273
  } catch {
251
274
  catalogError2("OKM1027", "Catalog text is not valid JSON.");
252
275
  }
@@ -260,14 +283,25 @@ function loadTrustedCatalog2(text, hash) {
260
283
  version: CATALOG_VERSION2,
261
284
  objects: parsed.objects
262
285
  };
263
- serializedText.set(loaded, text);
286
+ serializedText.set(loaded, canonical);
264
287
  serializedHash.set(loaded, hash);
265
288
  return loaded;
266
289
  }
290
+ function catalogFileText2(text, label = "Catalog text") {
291
+ if (text.includes("\x00")) {
292
+ catalogError2("OKM1027", `${label} is UTF-16. Save the file as UTF-8.`, {
293
+ fieldReason: "utf16",
294
+ fix: { summary: "Save the file as UTF-8. This version does not read UTF-16." }
295
+ });
296
+ }
297
+ const withoutBom = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
298
+ return withoutBom.replaceAll("\r", "");
299
+ }
267
300
  function parseCatalog2(text) {
301
+ const canonical = catalogFileText2(text);
268
302
  let parsed;
269
303
  try {
270
- parsed = JSON.parse(text);
304
+ parsed = JSON.parse(canonical);
271
305
  } catch {
272
306
  catalogError2("OKM1027", "Catalog text is not valid JSON.");
273
307
  }
@@ -331,6 +365,8 @@ function rewriteRenamed(object, change, fromKey, toIdentity) {
331
365
  case "grant":
332
366
  case "defaultPrivilege":
333
367
  return retargeted(object, dependencies);
368
+ case "policy":
369
+ return rewritePolicyColumn(object, change, dependencies);
334
370
  case "trigger": {
335
371
  const local = sameRef2(object.identity.parent, change.parent);
336
372
  return triggerObject({
@@ -476,7 +512,23 @@ function rewriteView(object, dependencies, query) {
476
512
  ...object.definition.refresh !== undefined ? { refresh: object.definition.refresh } : {}
477
513
  });
478
514
  }
479
- return viewObject(input);
515
+ return viewObject({
516
+ ...input,
517
+ ...object.definition.securityInvoker === true ? { securityInvoker: true } : {}
518
+ });
519
+ }
520
+ function rewritePolicyColumn(object, change, dependencies) {
521
+ const local = sameRef2(object.identity.parent, change.parent);
522
+ return policyObject({
523
+ parent: object.identity.parent,
524
+ name: object.identity.name,
525
+ command: object.definition.command,
526
+ expression: rewriteExpr(object.definition.expression, change, local),
527
+ force: object.definition.force,
528
+ owner: object.owner,
529
+ provenance: object.provenance,
530
+ dependencies
531
+ });
480
532
  }
481
533
  function rewriteExpr(text, change, active) {
482
534
  if (!active)
@@ -619,6 +671,20 @@ function rewriteTableName(object, change, fromKey, toIdentity, source) {
619
671
  ...object.definition.when !== undefined ? { when: rewriteExpr(object.definition.when, { from: change.from, to: change.to }, local) } : {}
620
672
  });
621
673
  }
674
+ if (object.kind === "policy") {
675
+ const parent = movedParent(object.identity.parent, change);
676
+ const local = parent.name !== object.identity.parent.name;
677
+ return policyObject({
678
+ parent,
679
+ name: object.identity.name,
680
+ command: object.definition.command,
681
+ expression: rewriteExpr(object.definition.expression, { from: change.from, to: change.to }, local),
682
+ force: object.definition.force,
683
+ owner: object.owner,
684
+ provenance: object.provenance,
685
+ dependencies
686
+ });
687
+ }
622
688
  return assertNever(object);
623
689
  }
624
690
  function movedParent(parent, change) {
@@ -837,7 +903,14 @@ function definitionToJson(object) {
837
903
  dataType: column.dataType,
838
904
  name: column.name
839
905
  })),
840
- query: object.definition.query
906
+ query: object.definition.query,
907
+ ...object.definition.securityInvoker === true ? { securityInvoker: true } : {}
908
+ };
909
+ case "policy":
910
+ return {
911
+ command: object.definition.command,
912
+ expression: object.definition.expression,
913
+ force: object.definition.force
841
914
  };
842
915
  case "materializedView":
843
916
  return {
@@ -861,6 +934,8 @@ function parseObject(value) {
861
934
  const record = requireRecord(value, "catalog object");
862
935
  rejectUnknown(record, ["definition", "dependencies", "identity", "kind", "owner", "provenance"], "catalog object");
863
936
  const kind = requireString(record.kind, "kind");
937
+ if (kind === "policy")
938
+ return parsePolicy(record);
864
939
  if (!isBuiltKind(kind)) {
865
940
  catalogError2("OKM1020", `Kind ${kind} is not built yet. Built kinds are ${BUILT_KINDS2.join(", ")}.`);
866
941
  }
@@ -945,7 +1020,7 @@ function parseIndex(identity, definition, owner, provenance, dependencies) {
945
1020
  catalogError2("OKM1020", `Index object identity is ${identity.kind}, not an index.`);
946
1021
  }
947
1022
  rejectUnknown(definition, ["columns", "expression", "nameKey", "predicate", "unique"], "index definition");
948
- return index3({
1023
+ const shared = {
949
1024
  parent: identity.parent,
950
1025
  name: identity.name,
951
1026
  nameKey: requireString(definition.nameKey, "name key"),
@@ -956,7 +1031,11 @@ function parseIndex(identity, definition, owner, provenance, dependencies) {
956
1031
  dependencies,
957
1032
  ...definition.predicate === undefined ? {} : { predicate: requireString(definition.predicate, "predicate") },
958
1033
  ...definition.expression === undefined ? {} : { expression: requireString(definition.expression, "expression") }
959
- });
1034
+ };
1035
+ const onView = dependencies.some((edge) => edge.kind === "view" || edge.kind === "materializedView");
1036
+ if (onView)
1037
+ return materializedViewIndex(shared);
1038
+ return index3(shared);
960
1039
  }
961
1040
  function parseConstraint(identity, definition, owner, provenance, dependencies) {
962
1041
  if (identity.kind !== "constraint") {
@@ -1140,7 +1219,7 @@ function parseView(kind, identity, definition, owner, provenance, dependencies)
1140
1219
  if (identity.kind !== kind) {
1141
1220
  catalogError2("OKM1020", `View object identity is ${identity.kind}, not a ${kind}.`);
1142
1221
  }
1143
- const fields = kind === "view" ? ["columns", "query"] : ["columns", "query", "refresh"];
1222
+ const fields = kind === "view" ? ["columns", "query", "securityInvoker"] : ["columns", "query", "refresh"];
1144
1223
  rejectUnknown(definition, fields, "view definition");
1145
1224
  const columns = parseViewColumns(definition.columns);
1146
1225
  const query = requireString(definition.query, "view query");
@@ -1163,7 +1242,38 @@ function parseView(kind, identity, definition, owner, provenance, dependencies)
1163
1242
  ...refresh === "concurrently" ? { refresh: "concurrently" } : {}
1164
1243
  });
1165
1244
  }
1166
- return viewObject(input);
1245
+ if (definition.securityInvoker !== undefined && definition.securityInvoker !== true) {
1246
+ catalogError2("OKM1020", `View ${identity.name} securityInvoker must be true when set.`);
1247
+ }
1248
+ return viewObject({
1249
+ ...input,
1250
+ ...definition.securityInvoker === true ? { securityInvoker: true } : {}
1251
+ });
1252
+ }
1253
+ function parsePolicy(record) {
1254
+ const identity = parseIdentity(record.identity);
1255
+ if (identity.kind !== "policy") {
1256
+ catalogError2("OKM1020", `Policy object identity is ${identity.kind}, not a policy.`);
1257
+ }
1258
+ const owner = parseOwner(record.owner);
1259
+ const provenance = parseProvenance(record.provenance);
1260
+ const dependencies = parseDependencies(record.dependencies);
1261
+ const definition = requireRecord(record.definition, "definition");
1262
+ rejectUnknown(definition, ["command", "expression", "force"], "policy definition");
1263
+ const command = requireString(definition.command, "policy command");
1264
+ if (command !== "all" && command !== "select") {
1265
+ catalogError2("OKM1020", `Policy ${identity.name} command is not supported.`);
1266
+ }
1267
+ return policyObject({
1268
+ parent: identity.parent,
1269
+ name: identity.name,
1270
+ command,
1271
+ expression: requireString(definition.expression, "policy expression"),
1272
+ force: requireBoolean(definition.force, "policy force"),
1273
+ owner,
1274
+ provenance,
1275
+ dependencies
1276
+ });
1167
1277
  }
1168
1278
  function parseViewColumns(value) {
1169
1279
  if (!Array.isArray(value))
@@ -1455,4 +1565,4 @@ function assertNeverKind(value) {
1455
1565
  return catalogError2("OKM1020", `Unexpected kind ${JSON.stringify(value)}.`);
1456
1566
  }
1457
1567
 
1458
- export { roleObject, grantObject, defaultPrivilegeObject, creationOrder2, renameColumn2, renameTable2, serializeCatalog2, catalogHash2, startupCatalog2, startupHash2, loadTrustedCatalog2, parseCatalog2 };
1568
+ export { roleObject, grantObject, defaultPrivilegeObject, creationOrder2, renameColumn2, renameTable2, serializeCatalog2, catalogHash2, startupCatalog2, startupHash2, loadTrustedCatalog2, catalogFileText2, parseCatalog2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normaliseEdges,
3
3
  assertProvenance
4
- } from "./t4tbsy9h.js";
4
+ } from "./358zsv4r.js";
5
5
  import {
6
6
  assertIdentifier2
7
7
  } from "./nfzc5z0w.js";
@@ -0,0 +1,7 @@
1
+ // src/dialects/pg/path-endpoint.ts
2
+ var pathEndpoint = Symbol("okmodel.pathEndpoint");
3
+ function markPathEndpoint(table) {
4
+ return Object.assign(table, { [pathEndpoint]: true });
5
+ }
6
+
7
+ export { pathEndpoint, markPathEndpoint };
@@ -1,11 +1,11 @@
1
- import {
2
- callerLocation,
3
- withLocation
4
- } from "./k7dwkhvq.js";
5
1
  import {
6
2
  definition,
7
3
  unavailable
8
4
  } from "./tmbdywx0.js";
5
+ import {
6
+ callerLocation,
7
+ withLocation
8
+ } from "./y6jdds7g.js";
9
9
  import {
10
10
  OkmError2,
11
11
  throwNamed2
@@ -29,7 +29,7 @@ function openFilters(table, relations, spec, hiddenFields) {
29
29
  }
30
30
  return {
31
31
  parse(query) {
32
- return import("./wq9n6pwr.js").then((mod) => mod.parseQuery(allow, sort, query));
32
+ return import("./pz6rj8ay.js").then((mod) => mod.parseQuery(allow, sort, query, nested));
33
33
  }
34
34
  };
35
35
  }
@@ -38,7 +38,7 @@ function deny(hiddenFields, table, field) {
38
38
  return;
39
39
  throw new OkmError2("OKM1123", `Field ${table}.${field} is hidden.`, {
40
40
  fix: {
41
- summary: "Remove the hidden field from the allowlist. Hidden fields stay out of caller filters and sorts."
41
+ summary: "Remove this hidden field from the allowlist. Hidden fields stay out of caller filter or sort."
42
42
  }
43
43
  });
44
44
  }
@@ -1,26 +1,26 @@
1
- import"./8bwbwy8h.js";
1
+ import"./qq3899ht.js";
2
2
  import"./n442h54c.js";
3
- import"./krxx77g0.js";
3
+ import"./14vx95q4.js";
4
4
  import {
5
+ projectPath,
5
6
  loadConfig
6
- } from "./qv2ydck9.js";
7
+ } from "./gs74dbj5.js";
7
8
  import {
8
9
  listTargets
9
- } from "./ga3sfy93.js";
10
- import"./8xsbagad.js";
10
+ } from "./tsvww22q.js";
11
+ import"./9s0ypp87.js";
11
12
 
12
13
  // src/tooling/migrate/dev.ts
13
14
  import { mkdirSync } from "node:fs";
14
- import { join } from "node:path";
15
15
  async function devProject(cwd) {
16
16
  const config = await loadConfig(cwd);
17
17
  const named = listTargets(config).find((target) => target.name === "dev");
18
18
  if (named !== undefined)
19
19
  return `target ${named.name}
20
20
  `;
21
- const directory = join(cwd, config.out ?? ".okm", "dev-db");
21
+ const directory = projectPath(cwd, config.out ?? ".okm", "dev-db");
22
22
  mkdirSync(directory, { recursive: true });
23
- const { open } = await import("./f5cw5q5r.js");
23
+ const { open } = await import("./aytqh5y2.js");
24
24
  const pool = await open({ dataDir: directory });
25
25
  try {
26
26
  await pool.execute("select 1");
@@ -3,10 +3,10 @@ import {
3
3
  readHandle,
4
4
  readCall,
5
5
  attachHttp
6
- } from "./hf22e0wt.js";
6
+ } from "./tbrvgw6z.js";
7
7
  import {
8
- fail
9
- } from "./gbtcc2d7.js";
8
+ fail2
9
+ } from "./67txcrcw.js";
10
10
  import {
11
11
  OkmError2,
12
12
  throwNamed2
@@ -35,13 +35,16 @@ function plan(session, table, options, mods, view) {
35
35
  }
36
36
  });
37
37
  }
38
+ if (lock === "skip") {
39
+ fail2("OKM1120", 'lock: "skip" claims rows on update. A read uses lock: "update" and wait: "skip".', 'Pass lock: "update" and wait: "skip" inside tx(). An update can claim rows on its own.');
40
+ }
38
41
  if (session.tx === undefined) {
39
42
  throw new OkmError2("OKM1830", "A row lock needs a transaction. find was called outside tx().", {
40
43
  fix: { summary: "Move the find into tx(): the lock lasts until the transaction ends." }
41
44
  });
42
45
  }
43
46
  if (lock === undefined)
44
- fail("OKM1121", "wait needs lock: pass lock: update or lock: share.");
47
+ fail2("OKM1121", "wait needs lock: pass lock: update or lock: share.");
45
48
  if (typeof lock !== "string" || !LOCKS.includes(lock)) {
46
49
  throwNamed2("OKM1120", shown(lock), LOCKS, `lock must be one of: ${LOCKS.join(", ")}.`);
47
50
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  open2
3
- } from "./krxx77g0.js";
4
- import"./8bwbwy8h.js";
3
+ } from "./14vx95q4.js";
4
+ import"./qq3899ht.js";
5
5
  import"./n442h54c.js";
6
6
  import {
7
7
  CURRENT,
@@ -12,26 +12,28 @@ import {
12
12
  failedAt
13
13
  } from "./9yn6a2vd.js";
14
14
  import {
15
- loadMigrations,
16
15
  expandProvisioned,
17
16
  provisionHistoryIsKnown
18
- } from "./gde73es6.js";
19
- import"./szm0cksa.js";
20
- import"./fancm5pt.js";
17
+ } from "./m6p12kbr.js";
18
+ import"./8skf0cam.js";
19
+ import"./b5pftnn2.js";
21
20
  import {
21
+ projectPath,
22
+ loadMigrations,
22
23
  loadConfig
23
- } from "./qv2ydck9.js";
24
+ } from "./gs74dbj5.js";
24
25
  import {
26
+ sessionFailure,
27
+ finishQuiet,
25
28
  assertTargetPolicy,
26
29
  listTargets
27
- } from "./ga3sfy93.js";
28
- import"./8xsbagad.js";
30
+ } from "./tsvww22q.js";
31
+ import"./9s0ypp87.js";
29
32
  import {
30
33
  OkmError2
31
34
  } from "./52szzakm.js";
32
35
 
33
36
  // src/tooling/migrate/status.ts
34
- import { join } from "node:path";
35
37
  function describeStatus(migrations, history, recorded) {
36
38
  const known = new Set(migrations.map((migration) => migration.id));
37
39
  const done = expandProvisioned(migrations, new Set(history.map((row) => `${row.migrationId}:${String(row.stepIndex)}`)), history.map((row) => row.migrationId));
@@ -99,14 +101,16 @@ async function readTargetStatus(input) {
99
101
  protected: input.protected,
100
102
  backfills: await readBackfills(pool)
101
103
  };
104
+ } catch (error) {
105
+ throw sessionFailure(error) ?? error;
102
106
  } finally {
103
- await pool.close();
107
+ await finishQuiet(() => pool.close());
104
108
  }
105
109
  }
106
110
  async function statusProject(cwd, flags) {
107
111
  const config = await loadConfig(cwd);
108
112
  const targets = chosen(listTargets(config), flags.target);
109
- const migrations = loadMigrations(join(cwd, config.migrations ?? "migrations"));
113
+ const migrations = loadMigrations(projectPath(cwd, config.migrations ?? "migrations"));
110
114
  const rows = [];
111
115
  for (const target of targets) {
112
116
  rows.push(await readTargetStatus({