okmodel 0.8.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 (202) hide show
  1. package/README.md +14 -0
  2. package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
  3. package/dist/dialects/pg/ext/btree-gin.js +20 -0
  4. package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
  5. package/dist/dialects/pg/ext/btree-gist.js +20 -0
  6. package/dist/dialects/pg/ext/call.d.ts +53 -0
  7. package/dist/dialects/pg/ext/citext.js +1 -1
  8. package/dist/dialects/pg/ext/feature.d.ts +26 -0
  9. package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
  10. package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
  11. package/dist/dialects/pg/ext/hstore.d.ts +41 -0
  12. package/dist/dialects/pg/ext/hstore.js +29 -0
  13. package/dist/dialects/pg/ext/index.d.ts +56 -0
  14. package/dist/dialects/pg/ext/index.js +1 -1
  15. package/dist/dialects/pg/ext/ltree.d.ts +41 -0
  16. package/dist/dialects/pg/ext/ltree.js +29 -0
  17. package/dist/dialects/pg/ext/pg-trgm.js +4 -13
  18. package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
  19. package/dist/dialects/pg/ext/pgcrypto.js +33 -0
  20. package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
  21. package/dist/dialects/pg/ext/unaccent.js +21 -0
  22. package/dist/dialects/pg/ext/using.d.ts +23 -0
  23. package/dist/dialects/pg/ext/versions.d.ts +36 -0
  24. package/dist/dialects/pg/external.d.ts +19 -0
  25. package/dist/dialects/pg/fn/index.js +4 -4
  26. package/dist/dialects/pg/index.d.ts +1 -0
  27. package/dist/dialects/pg/index.js +16 -11
  28. package/dist/dialects/pg/view/index.js +5 -5
  29. package/dist/dialects/pg/view/scratch.d.ts +4 -1
  30. package/dist/runtime/artifact-file.d.ts +22 -0
  31. package/dist/runtime/client.d.ts +10 -0
  32. package/dist/runtime/drift-detail.d.ts +2 -1
  33. package/dist/runtime/drift.d.ts +3 -10
  34. package/dist/runtime/pg/bun.js +4 -4
  35. package/dist/runtime/pg/neon.js +4 -4
  36. package/dist/runtime/pg/pg.js +4 -4
  37. package/dist/runtime/pg/pglite.js +4 -4
  38. package/dist/runtime/pg/postgresjs.js +4 -4
  39. package/dist/runtime/server-check.d.ts +36 -6
  40. package/dist/runtime/traits/index.js +5 -5
  41. package/dist/runtime/validate/index.js +1 -1
  42. package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
  43. package/dist/shared/{14x60fbf.js → 1mxm04fy.js} +5 -5
  44. package/dist/shared/{b6d6p0zc.js → 2szgv6yj.js} +5 -5
  45. package/dist/shared/{f4jy1j7x.js → 2zdxkt7b.js} +909 -100
  46. package/dist/shared/{mnvjvqyp.js → 3456242y.js} +17 -17
  47. package/dist/shared/3t6kw83m.js +1 -1
  48. package/dist/shared/{6m78c8ss.js → 5kyb3tqx.js} +1 -1
  49. package/dist/shared/61bmrmhr.js +35 -0
  50. package/dist/shared/{zbqbmmrp.js → 62b603gr.js} +8 -8
  51. package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
  52. package/dist/shared/{dpc2r7rb.js → 6nae0spm.js} +150 -89
  53. package/dist/shared/{0wrea3jq.js → 71n0jmhc.js} +1 -1
  54. package/dist/shared/7ba5h6pb.js +17 -0
  55. package/dist/shared/{k86n8vq3.js → 8jesqsrk.js} +1 -1
  56. package/dist/shared/{qd9hhd8f.js → 8n688yjg.js} +1 -1
  57. package/dist/shared/{zgex00fd.js → 8qzkd9f3.js} +5 -5
  58. package/dist/shared/{mkrn359n.js → 90sg0w5a.js} +159 -31
  59. package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
  60. package/dist/shared/{bxas03mq.js → 9dtgn1z2.js} +1 -1
  61. package/dist/shared/{p5nh3r8q.js → aksb89mn.js} +2 -2
  62. package/dist/shared/{wcrheftc.js → bphrgwz9.js} +2 -2
  63. package/dist/shared/{wz2a78mp.js → c3mvnq7a.js} +1 -1
  64. package/dist/shared/{pan0370z.js → ccsmhv9r.js} +24 -6
  65. package/dist/shared/{n0jmpgj1.js → cexb7z6b.js} +1 -1
  66. package/dist/shared/{wvdjznah.js → cf8zdz5p.js} +5 -5
  67. package/dist/shared/{3449rcae.js → ckz05z15.js} +4 -4
  68. package/dist/shared/{35q0n9tz.js → dd5pmnky.js} +7 -7
  69. package/dist/shared/{e8zyaqvj.js → ds229x4r.js} +1 -1
  70. package/dist/{tooling/shared/yw30vnq2.js → shared/e275q7sd.js} +1 -1
  71. package/dist/shared/{mfedzr74.js → ebhz8vh6.js} +4 -4
  72. package/dist/shared/{z581d7ny.js → fdsz3w80.js} +2 -2
  73. package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
  74. package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
  75. package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
  76. package/dist/shared/h9811jjm.js +17 -0
  77. package/dist/shared/{kj9d8maq.js → jpybhf98.js} +1 -1
  78. package/dist/shared/kzgrnckd.js +29 -0
  79. package/dist/shared/{agsfb86s.js → mazpbcdj.js} +4 -4
  80. package/dist/shared/{195pzzzz.js → mgaq2sd3.js} +10 -7
  81. package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
  82. package/dist/shared/{p3xbdcvt.js → myk8fswx.js} +55 -6
  83. package/dist/shared/{njga14v4.js → n306gqkd.js} +8 -8
  84. package/dist/shared/n5whk3mt.js +665 -0
  85. package/dist/shared/{bah9nbg3.js → npdftanb.js} +12 -20
  86. package/dist/shared/{16kvjebh.js → pg4ezgyf.js} +7 -26
  87. package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
  88. package/dist/shared/{jp36k7dp.js → qvwwp1mp.js} +61 -40
  89. package/dist/shared/rbxt795q.js +1766 -0
  90. package/dist/shared/{g5yc06ka.js → s7he5e5d.js} +1 -1
  91. package/dist/shared/{hfqmpasr.js → ss2kv2rs.js} +5 -5
  92. package/dist/shared/stfa9xcw.js +450 -0
  93. package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
  94. package/dist/shared/{jebgrkeq.js → tw1nvvfj.js} +2 -2
  95. package/dist/shared/{v1wad97q.js → wvtjg5m3.js} +1 -1
  96. package/dist/shared/xqacq37x.js +61 -0
  97. package/dist/shared/{n05z9nwz.js → xtsydxjg.js} +1 -1
  98. package/dist/shared/{jx2m62cs.js → xv8qj97g.js} +5 -5
  99. package/dist/shared/{63f4ksbz.js → xwhdcrm4.js} +1 -1
  100. package/dist/shared/{hm5f8jby.js → yvabyg9k.js} +6 -6
  101. package/dist/shared/yybhre6n.js +136 -0
  102. package/dist/shared/zdqf8k5d.js +8 -0
  103. package/dist/tooling/cli.js +94 -22
  104. package/dist/tooling/driver-run.js +15 -332
  105. package/dist/tooling/github/comment.d.ts +50 -0
  106. package/dist/tooling/github/post-comment.d.ts +17 -0
  107. package/dist/tooling/migrate/commands.d.ts +2 -1
  108. package/dist/tooling/migrate/config.d.ts +13 -0
  109. package/dist/tooling/migrate/export.d.ts +165 -0
  110. package/dist/tooling/migrate/ext-surface.d.ts +80 -0
  111. package/dist/tooling/migrate/ext.d.ts +31 -4
  112. package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
  113. package/dist/tooling/migrate/index.d.ts +3 -0
  114. package/dist/tooling/migrate/index.js +55 -10
  115. package/dist/tooling/migrate/lint-rules.d.ts +18 -1
  116. package/dist/tooling/migrate/lint.d.ts +14 -1
  117. package/dist/tooling/migrate/place.d.ts +18 -0
  118. package/dist/tooling/migrate/plan-json.d.ts +65 -0
  119. package/dist/tooling/migrate/project.d.ts +10 -1
  120. package/dist/tooling/migrate/pull-emit.d.ts +98 -0
  121. package/dist/tooling/migrate/pull-routines.d.ts +126 -0
  122. package/dist/tooling/migrate/pull-verify.d.ts +26 -0
  123. package/dist/tooling/migrate/pull.d.ts +62 -0
  124. package/dist/tooling/migrate/reprint.d.ts +32 -0
  125. package/dist/tooling/migrate/sandbox.d.ts +8 -2
  126. package/dist/tooling/migrate/schema-api.d.ts +43 -0
  127. package/dist/tooling/migrate/sql-lex.d.ts +18 -0
  128. package/dist/tooling/shared/{3m1hkg7z.js → 04svnxxj.js} +4 -4
  129. package/dist/tooling/shared/{ppnnnvj8.js → 0j0jtse1.js} +1 -1
  130. package/dist/tooling/shared/{z8d7ptht.js → 0r05zhyq.js} +5 -5
  131. package/dist/tooling/shared/{a6pp9d12.js → 1800eymw.js} +3 -3
  132. package/dist/tooling/shared/{cmptmb4f.js → 35zemrmf.js} +1 -1
  133. package/dist/tooling/shared/{w7qe8sj1.js → 3rmaz3pq.js} +1 -1
  134. package/dist/{shared/q0cqt2sp.js → tooling/shared/3yn79q5m.js} +1 -1
  135. package/dist/tooling/shared/{2revefqt.js → 57btdkgm.js} +2 -2
  136. package/dist/tooling/shared/{ma2340rx.js → 5bmksndh.js} +2 -2
  137. package/dist/tooling/shared/{9xzm7hjg.js → 5p8km5jb.js} +3 -3
  138. package/dist/tooling/shared/{xhrnjch9.js → 5x3pf400.js} +3 -3
  139. package/dist/tooling/shared/{wwnekq5n.js → 5zrzffnk.js} +1 -1
  140. package/dist/tooling/shared/{p7f08ktn.js → 62fxpc1p.js} +7 -7
  141. package/dist/tooling/shared/{7ae7rjmn.js → 68tf18v4.js} +2 -2
  142. package/dist/tooling/shared/{rf83gr2d.js → 6vk28rjp.js} +7 -3
  143. package/dist/tooling/shared/76pv6qff.js +9 -0
  144. package/dist/tooling/shared/{bz2dqhab.js → 7aews1zg.js} +3 -3
  145. package/dist/tooling/shared/{9kazs5p6.js → 7b3xp9gc.js} +3 -3
  146. package/dist/tooling/shared/{4d2w25vw.js → 7pxncnzs.js} +2 -2
  147. package/dist/tooling/shared/{zvnhh1n0.js → 829fjxyw.js} +2 -2
  148. package/dist/tooling/shared/{dzx85q70.js → 8m5znpdt.js} +1 -1
  149. package/dist/tooling/shared/{g9ad4n80.js → 8yr7ges1.js} +7 -7
  150. package/dist/tooling/shared/{tn8gay14.js → 9qr9rkbh.js} +6 -6
  151. package/dist/tooling/shared/{8sqrsw3s.js → 9sfbtwsk.js} +3 -3
  152. package/dist/{shared/bnby0esn.js → tooling/shared/9wsnsvbf.js} +1 -1
  153. package/dist/tooling/shared/{aftb2mwr.js → a2xe04bm.js} +1 -1
  154. package/dist/tooling/shared/{nf7jmhfa.js → a4pzghha.js} +2 -2
  155. package/dist/tooling/shared/{y5656f0e.js → am04v8na.js} +5 -5
  156. package/dist/tooling/shared/{417zdsk7.js → asgr07mp.js} +5 -5
  157. package/dist/tooling/shared/{pqy21k24.js → c0xevn1h.js} +4 -4
  158. package/dist/tooling/shared/dhatassp.js +134 -0
  159. package/dist/tooling/shared/{spk1jg3r.js → ezqn88nj.js} +8 -8
  160. package/dist/tooling/shared/{6nyfyw70.js → f77nnfqy.js} +2 -2
  161. package/dist/tooling/shared/{wt7j7nf6.js → fh07z1dt.js} +1 -1
  162. package/dist/tooling/shared/{3rrw5w8f.js → gqwevek4.js} +1 -1
  163. package/dist/tooling/shared/{f9mphxej.js → hfq3n3bd.js} +346 -19
  164. package/dist/tooling/shared/{vs0t6qt8.js → j664qjrt.js} +2 -2
  165. package/dist/tooling/shared/{733a1tq3.js → jpgmjsx3.js} +3 -3
  166. package/dist/tooling/shared/{mtrqn2hn.js → jr2nmr81.js} +22 -30
  167. package/dist/{shared/mtw6jz76.js → tooling/shared/jsjjz875.js} +1 -1
  168. package/dist/tooling/shared/{2wtvc7rw.js → kbqnrs1x.js} +2 -2
  169. package/dist/tooling/shared/{gfvtj6d0.js → kz715295.js} +7 -7
  170. package/dist/tooling/shared/{a7q7t4n3.js → m3xt8b1h.js} +2 -2
  171. package/dist/tooling/shared/{dw08f3m8.js → m4hhb8aa.js} +2 -2
  172. package/dist/tooling/shared/{y031jct9.js → mw5npye0.js} +2 -2
  173. package/dist/tooling/shared/{vraj6d74.js → nxq95eb6.js} +3 -3
  174. package/dist/tooling/shared/{fb9k2qwd.js → qartgazh.js} +11 -30
  175. package/dist/tooling/shared/{xjs6zqtc.js → rcywj2w8.js} +9 -9
  176. package/dist/tooling/shared/{dy672fz6.js → s6qha57m.js} +2 -2
  177. package/dist/tooling/shared/{vx86qjv8.js → shjs0379.js} +3 -3
  178. package/dist/tooling/shared/{345tbc2k.js → sjwkt1pg.js} +1 -1
  179. package/dist/tooling/shared/{rq5kk8j6.js → stebqyyd.js} +3 -3
  180. package/dist/tooling/shared/{yk9mp7vb.js → t4xveemq.js} +4 -4
  181. package/dist/tooling/shared/{djydjpqt.js → t6zjeake.js} +5 -5
  182. package/dist/tooling/shared/{zhwnfyb2.js → tcwpjvxe.js} +1 -1
  183. package/dist/tooling/shared/{72fyg4zv.js → tpssp7ac.js} +1 -1
  184. package/dist/tooling/shared/{jne7b93p.js → v6j1ep6w.js} +3 -3
  185. package/dist/tooling/shared/{ec71zqgt.js → vwr2y833.js} +2 -2
  186. package/dist/tooling/shared/{j9t5s12a.js → w17sj05d.js} +2 -2
  187. package/dist/tooling/shared/{3tq8pnb8.js → w5d89rb4.js} +1 -1
  188. package/dist/tooling/shared/{smn6kz1p.js → wbwq1jsa.js} +2 -2
  189. package/dist/tooling/shared/{pwsytxm5.js → wezxf3h8.js} +1 -1
  190. package/dist/tooling/shared/{5bvw2nev.js → yb4kd19s.js} +1 -1
  191. package/dist/tooling/shared/{gmcf9cxf.js → ybdew6j7.js} +2 -2
  192. package/dist/tooling/shared/{ep8zh3bk.js → yfedr1zb.js} +1 -1
  193. package/dist/tooling/shared/{ddjtfgnx.js → yhp829bx.js} +3 -3
  194. package/dist/tooling/shared/{yfr8hzhm.js → ytk1tjs0.js} +1 -1
  195. package/dist/tooling/shared/{03k6res6.js → zs9aymcp.js} +1 -1
  196. package/dist/tooling/shared/zx3v9phv.js +8 -0
  197. package/dist/tooling/testing/index.js +2 -2
  198. package/package.json +38 -9
  199. package/dist/shared/fjpnhqan.js +0 -71
  200. package/dist/shared/n41w4fbz.js +0 -113
  201. package/dist/tooling/shared/pw8fgahx.js +0 -69
  202. /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Replays pulled routines on a scratch schema.
3
+ *
4
+ * Create order is the catalog's dependency order, plus lexical edges for a
5
+ * plpgsql or SQL-string body. `check_function_bodies` is on. A SQL function
6
+ * or a view whose dependency is missing fails creation. A plpgsql body is
7
+ * not proved by creation, so a function that is created is still
8
+ * candidate-only. The scratch schema is dropped before this returns.
9
+ */
10
+ import type { Catalog } from "../../contracts/catalog/types.js";
11
+ import type { CatalogQuery } from "../../dialects/pg/introspect.js";
12
+ import { type RoutinePlan, type RoutineVerdict } from "./pull-routines.js";
13
+ /**
14
+ * Creates the planned routines from empty and records what that proved.
15
+ *
16
+ * Types are created first. Everything else follows the catalog dependency
17
+ * order, so a function with no edge is created before its tables. Routine
18
+ * bodies see only the scratch schema. A role that cannot create a schema
19
+ * leaves every function unproved.
20
+ *
21
+ * @param runner - Database connection. Statements share its session
22
+ * @param source - Introspected catalog
23
+ * @param plan - Routines `okm pull` will write
24
+ * @returns One verdict per planned function, trigger, and view
25
+ */
26
+ export declare function verifyPulled(runner: CatalogQuery, source: Catalog, plan: RoutinePlan): Promise<readonly RoutineVerdict[]>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `okm pull` reads a database and writes table files plus a schema file.
3
+ *
4
+ * The selected namespaces are only read. A scratch schema is created and
5
+ * dropped to verify functions and views, then dropped before this returns.
6
+ * A protected target is allowed. An existing file is refused before anything
7
+ * is written.
8
+ */
9
+ import { type PullFile, type PullLayout, type PullSkip } from "./pull-emit.js";
10
+ /** What `okm pull` prints, and the objects the files leave out. */
11
+ export type PullResult = {
12
+ /** Report text, including the trailing newline. */
13
+ readonly text: string;
14
+ /** Objects that were not written. */
15
+ readonly skipped: readonly PullSkip[];
16
+ };
17
+ /**
18
+ * Introspects the selected namespaces and writes the schema source.
19
+ *
20
+ * The default namespace is `current_schema()`. `--schema` selects others and
21
+ * may be repeated. `--out` is the directory that receives `schema.ts` and
22
+ * `tables/`. Without it, the project's schema path and tables directory are
23
+ * used. A tables directory that the config omits is `tables` beside the
24
+ * schema file.
25
+ *
26
+ * @param cwd - Project directory
27
+ * @param argv - Arguments after `pull`
28
+ * @returns The report
29
+ */
30
+ export declare function pullProject(cwd: string, argv: readonly string[]): Promise<PullResult>;
31
+ /**
32
+ * Reads `--out`, `--schema`, and `--target` from a pull invocation.
33
+ *
34
+ * @param argv - Arguments after `pull`
35
+ * @returns The flags this command reads
36
+ */
37
+ export declare function parsePullArgs(argv: readonly string[]): {
38
+ readonly target: string | undefined;
39
+ readonly allowProtected: boolean;
40
+ readonly out: string | undefined;
41
+ readonly schemas: readonly string[];
42
+ };
43
+ /**
44
+ * Resolves the schema file and the tables directory for a pull or an import.
45
+ *
46
+ * `--out` writes `schema.ts` and `tables/` under that directory. Without it,
47
+ * the project's schema path and tables directory are used.
48
+ *
49
+ * @param cwd - Project directory
50
+ * @param schema - Config schema path
51
+ * @param tables - Config tables directory, when set
52
+ * @param out - `--out` directory, when set
53
+ * @returns Absolute paths
54
+ */
55
+ export declare function pullLayout(cwd: string, schema: string, tables: string | undefined, out: string | undefined): PullLayout;
56
+ /**
57
+ * Refuses an existing file, writes the rest, and formats them.
58
+ *
59
+ * @param files - Files from {@link emitPull}
60
+ * @param verb - `Pull` or `Import`, named in OKM1855
61
+ */
62
+ export declare function commitPullFiles(files: readonly PullFile[], verb?: "Pull" | "Import"): void;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Warns when a domain check or a `LANGUAGE sql` body reprints (D276).
3
+ *
4
+ * The comparison runs after `okm migrate check` has created the objects.
5
+ * The linter itself does not connect. A matching stored text is silent.
6
+ */
7
+ import type { Catalog } from "../../contracts/catalog/types.js";
8
+ import type { LintSeverity } from "./lint-rules.js";
9
+ import type { PlanStep } from "./plan.js";
10
+ /** Check-stage warning for a reprinted domain check or SQL function body. */
11
+ export declare const REPRINT_CODE = "OKM1552";
12
+ /** One reprint comparison, before the registry sentence is attached. */
13
+ export type ReprintHit = {
14
+ readonly severity: LintSeverity;
15
+ readonly code: string;
16
+ readonly place: string;
17
+ readonly reason: string;
18
+ };
19
+ /**
20
+ * Compares declared text with the text Postgres stored.
21
+ *
22
+ * A step that does not create or replace the object is skipped, so a later
23
+ * migration does not repeat the warning. `-- okm-allow OKM1552: reason` on
24
+ * that step silences it. An empty reason, or an allow on a statement whose
25
+ * text matches, is OKM1510.
26
+ *
27
+ * @param declared - Catalog stored with the migration
28
+ * @param stored - Catalog introspection read back after the replay
29
+ * @param steps - Statements of that migration, including allows
30
+ * @returns Findings in catalog order
31
+ */
32
+ export declare function reprintHits(declared: Catalog, stored: Catalog, steps: readonly PlanStep[]): readonly ReprintHit[];
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import type { Catalog } from "../../contracts/catalog/types.js";
9
9
  import type { MigrateConfig } from "./config.js";
10
+ import { type Finding } from "./lint.js";
10
11
  import { type MigrationPlan, type PlanStep } from "./plan.js";
11
12
  /** One migration the check replays. */
12
13
  export type CheckMigration = {
@@ -22,6 +23,7 @@ export type ReplayStop = {
22
23
  /** Replay result. `skips` are statements check did not execute. */
23
24
  export type ReplayOutcome = {
24
25
  readonly skips: readonly string[];
26
+ readonly reprints: readonly Finding[];
25
27
  readonly stop?: ReplayStop;
26
28
  };
27
29
  /**
@@ -48,10 +50,14 @@ export declare function replayCheckHistory(url: string, scratch: string, config:
48
50
  */
49
51
  export declare function proveCheckSnapshot(url: string, provided: string, replayed: string, config: MigrateConfig, allowPooler: boolean, history: readonly CheckMigration[]): Promise<string | undefined>;
50
52
  /**
51
- * Rewrites `"public".` to the scratch schema.
53
+ * Rewrites the catalog schema to the scratch schema.
54
+ *
55
+ * `source` defaults to `public`. A foreign key aimed at another schema is
56
+ * left in place.
52
57
  *
53
58
  * @param steps - Plan steps
54
59
  * @param schema - Scratch schema
60
+ * @param source - Schema the statements currently name
55
61
  * @returns The same steps, aimed at `schema`
56
62
  */
57
- export declare function retargetSteps(steps: readonly PlanStep[], schema: string): readonly PlanStep[];
63
+ export declare function retargetSteps(steps: readonly PlanStep[], schema: string, source?: string): readonly PlanStep[];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Programmatic schema API (D26, D284).
3
+ *
4
+ * `describe` turns a `schema()` result into JSON. `buildCatalog` reads that
5
+ * JSON back into the catalog tooling already plans. Codecs and client
6
+ * generators stay on the schema. They are functions, and the catalog hash
7
+ * does not include them.
8
+ */
9
+ import type { Catalog } from "../../contracts/catalog/types.js";
10
+ import { type LogicalIdentity } from "./export.js";
11
+ /**
12
+ * JSON description of one schema.
13
+ *
14
+ * `logical` names the schema. It is not the catalog hash. `catalog` is the
15
+ * catalog document: no functions, and object keys in sorted order.
16
+ */
17
+ export type SchemaDescription = {
18
+ readonly logical: LogicalIdentity;
19
+ readonly catalog: Catalog;
20
+ };
21
+ /**
22
+ * Describes a schema as JSON.
23
+ *
24
+ * The logical identity is `public`. Placing the same catalog into another
25
+ * namespace does not change it. The catalog document keeps the namespaces
26
+ * the catalog already has, so the catalog hash still changes with placement.
27
+ *
28
+ * @param schema - A `schema()` result, or any value that carries its catalog
29
+ * @returns A description `JSON.stringify` can store
30
+ */
31
+ export declare function describe(schema: {
32
+ readonly catalog: Catalog;
33
+ }): SchemaDescription;
34
+ /**
35
+ * Builds the catalog from a description.
36
+ *
37
+ * `JSON.parse(JSON.stringify(describe(schema)))` is a valid argument. The
38
+ * result has the same catalog hash as `schema.catalog`.
39
+ *
40
+ * @param description - Description from {@link describe}, including one read back from JSON
41
+ * @returns The catalog `okm` plans
42
+ */
43
+ export declare function buildCatalog(description: SchemaDescription): Catalog;
@@ -37,3 +37,21 @@ export declare function sqlQuoteOpen(sql: string): boolean;
37
37
  * @returns The command, or `undefined` when the step stays in one transaction
38
38
  */
39
39
  export declare function transactionControl(sql: string): string | undefined;
40
+ /** One identifier {@link sqlIdentifiers} found outside a string or a comment. */
41
+ export type SqlName = {
42
+ /** Spelling as written. A quoted name is unescaped. An unquoted name is not folded. */
43
+ readonly text: string;
44
+ /** True when the name was a double-quoted identifier. */
45
+ readonly quoted: boolean;
46
+ };
47
+ /**
48
+ * Identifiers outside comments, strings, and dollar quotes.
49
+ *
50
+ * The quote rules are the same ones {@link sqlStatements} uses. A name inside
51
+ * a string or a dollar quote is not a match: Postgres still resolves
52
+ * `'notes'::regclass`, and this scan does not.
53
+ *
54
+ * @param sql - Function body or view query
55
+ * @returns Identifiers in source order
56
+ */
57
+ export declare function sqlIdentifiers(sql: string): readonly SqlName[];
@@ -2,10 +2,10 @@ import {
2
2
  DriverError2,
3
3
  timedOut2,
4
4
  isConnectionLost
5
- } from "./f9mphxej.js";
5
+ } from "./hfq3n3bd.js";
6
6
  import {
7
7
  PgSession2
8
- } from "./p7f08ktn.js";
8
+ } from "./62fxpc1p.js";
9
9
  import {
10
10
  driverErrors,
11
11
  rejectClosed,
@@ -13,7 +13,7 @@ import {
13
13
  runCall,
14
14
  rowsFrom,
15
15
  resultFrom
16
- } from "./xhrnjch9.js";
16
+ } from "./5x3pf400.js";
17
17
 
18
18
  // src/adapters/pg/postgres-extra.ts
19
19
  var RESET_ALL = "RESET ALL";
@@ -48,7 +48,7 @@ async function checkout(pool, timeoutMs) {
48
48
  batch: (statements, options) => {
49
49
  remember(options?.timeout);
50
50
  return guard(() => runCall(pool.isClosed(), options, async (watch) => {
51
- const { runAtomicBatch } = await import("./3rrw5w8f.js");
51
+ const { runAtomicBatch } = await import("./gqwevek4.js");
52
52
  return runAtomicBatch(session, statements, watch);
53
53
  }));
54
54
  },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fail2
3
- } from "./f9mphxej.js";
3
+ } from "./hfq3n3bd.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 "./ec71zqgt.js";
3
+ } from "./vwr2y833.js";
4
4
  import {
5
5
  runWrite
6
6
  } from "./n4jqhpqz.js";
7
7
  import {
8
8
  queryHandle,
9
9
  settleCall
10
- } from "./mtrqn2hn.js";
10
+ } from "./jr2nmr81.js";
11
11
  import {
12
12
  OkmError,
13
13
  throwNamed,
@@ -22,7 +22,7 @@ import {
22
22
  list,
23
23
  isRecord,
24
24
  fail2
25
- } from "./f9mphxej.js";
25
+ } from "./hfq3n3bd.js";
26
26
 
27
27
  // src/runtime/sync.ts
28
28
  var OPTIONS = ["expect", "signal", "timeout", "route"];
@@ -539,8 +539,8 @@ function callOf(options) {
539
539
  async function presetWhere(schema, table, uses) {
540
540
  if (uses === undefined)
541
541
  return;
542
- const { resolve } = await import("./ma2340rx.js");
543
- const { stack } = await import("./wwnekq5n.js");
542
+ const { resolve } = await import("./5bmksndh.js");
543
+ const { stack } = await import("./5zrzffnk.js");
544
544
  return stack(undefined, resolve(schema, table, uses).wheres);
545
545
  }
546
546
  function noteSafety(session, table, view) {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  markClientPool2,
3
3
  open2
4
- } from "./xjs6zqtc.js";
4
+ } from "./rcywj2w8.js";
5
5
  import {
6
6
  createClient
7
- } from "./mtrqn2hn.js";
7
+ } from "./jr2nmr81.js";
8
8
 
9
9
  // src/runtime/pg/bun.ts
10
10
  function connect(target, options) {
11
11
  if (typeof target === "object" && !isPool(target)) {
12
- return import("./2wtvc7rw.js").then((mod) => mod.default(target, options, (config) => {
12
+ return import("./kbqnrs1x.js").then((mod) => mod.default(target, options, (config) => {
13
13
  const pool = open2(config);
14
14
  markClientPool2(pool);
15
15
  return pool;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tag
3
- } from "./f9mphxej.js";
3
+ } from "./hfq3n3bd.js";
4
4
 
5
5
  // src/runtime/preset-stack.ts
6
6
  function stack2(where, presets) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  quote,
3
3
  fail2
4
- } from "./f9mphxej.js";
4
+ } from "./hfq3n3bd.js";
5
5
 
6
6
  // src/runtime/sort.ts
7
7
  function insertAtEnd(table, columns, rows, group, tenantFields) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rejectUncancellable
3
- } from "./ae4j5f42.js";
3
+ } from "./5x3pf400.js";
4
4
 
5
5
  // src/adapters/pg/no-inflight-timeout.ts
6
6
  function noTimeout(options) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  refusePrototypeKey
3
- } from "./ppnnnvj8.js";
3
+ } from "./0j0jtse1.js";
4
4
  import {
5
5
  throwNamed,
6
6
  parseOrder,
@@ -9,7 +9,7 @@ import {
9
9
  list,
10
10
  isRecord,
11
11
  fail2
12
- } from "./f9mphxej.js";
12
+ } from "./hfq3n3bd.js";
13
13
 
14
14
  // src/dialects/pg/ops/bucket.ts
15
15
  var RUNTIME = Symbol.for("okmodel.bucket");
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  stack2
3
- } from "./cmptmb4f.js";
3
+ } from "./35zemrmf.js";
4
4
  import {
5
5
  OkmError,
6
6
  isOperator,
7
7
  operatorValue
8
- } from "./f9mphxej.js";
8
+ } from "./hfq3n3bd.js";
9
9
 
10
10
  // src/dialects/pg/preset.ts
11
11
  var RESERVED_PRESETS = new Set([
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  open6,
3
3
  seal2
4
- } from "./djydjpqt.js";
4
+ } from "./t6zjeake.js";
5
5
  import {
6
6
  createClient
7
- } from "./mtrqn2hn.js";
7
+ } from "./jr2nmr81.js";
8
8
 
9
9
  // src/runtime/pg/pglite.ts
10
10
  async function connect(target, options) {
11
11
  if (typeof target === "object" && !isPool(target)) {
12
- return import("./2wtvc7rw.js").then((mod) => mod.default(target, options, open6));
12
+ return import("./kbqnrs1x.js").then((mod) => mod.default(target, options, open6));
13
13
  }
14
14
  const pool = isPool(target) ? seal2(target) : await open6({
15
15
  ...target !== undefined ? { dataDir: target } : {},
@@ -57,14 +57,14 @@ function hasCapability2(flags, name) {
57
57
  // src/adapters/failure.ts
58
58
  var loading;
59
59
  function driverErrors() {
60
- loading ??= import("./aftb2mwr.js");
60
+ loading ??= import("./a2xe04bm.js");
61
61
  return loading;
62
62
  }
63
63
  function rejectClosed() {
64
- return import("./345tbc2k.js").then((mod) => mod.closed());
64
+ return import("./sjwkt1pg.js").then((mod) => mod.closed());
65
65
  }
66
66
  function rejectUncancellable() {
67
- return import("./345tbc2k.js").then((mod) => mod.refused());
67
+ return import("./sjwkt1pg.js").then((mod) => mod.refused());
68
68
  }
69
69
  function rejectCancelled() {
70
70
  return driverErrors().then((mod) => Promise.reject(mod.cancelled()));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  stack2
3
- } from "./cmptmb4f.js";
3
+ } from "./35zemrmf.js";
4
4
  export {
5
5
  stack2 as stack
6
6
  };
@@ -6,7 +6,7 @@ import {
6
6
  runCall,
7
7
  EMPTY_NOTICES,
8
8
  resultFrom
9
- } from "./xhrnjch9.js";
9
+ } from "./5x3pf400.js";
10
10
 
11
11
  // src/adapters/pg/postgresjs.ts
12
12
  import net from "node:net";
@@ -118,17 +118,17 @@ function open3(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("./3m1hkg7z.js").then((mod) => mod.runBatch(held, statements, options)));
121
+ return sockets.occupy(() => import("./04svnxxj.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("./3m1hkg7z.js").then((mod) => mod.holdCheckout(gate, () => mod.checkout(held)), (error) => {
126
+ return import("./04svnxxj.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("./3m1hkg7z.js").then((mod) => mod.describe(sql, text, params))),
131
+ describe: (text, params) => sockets.occupy(() => import("./04svnxxj.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 open3(config) {
143
143
  listen(channel, onNotify) {
144
144
  const gate = sockets.listenerGate();
145
145
  gate.enter();
146
- return import("./3m1hkg7z.js").then((mod) => mod.holdListener(gate, async () => {
146
+ return import("./04svnxxj.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 PgSession2 {
213
213
  onAbort();
214
214
  else
215
215
  watch.signal.addEventListener("abort", onAbort, { once: true });
216
- return import("./3m1hkg7z.js").then((mod) => mod.watchQuery(pending, watch, onAbort, {
216
+ return import("./04svnxxj.js").then((mod) => mod.watchQuery(pending, watch, onAbort, {
217
217
  start,
218
218
  text,
219
219
  notices: this.notices,
@@ -265,7 +265,7 @@ class PgSession2 {
265
265
  }
266
266
  }
267
267
  async function* loadStream(sql, text, params) {
268
- const { stream } = await import("./3m1hkg7z.js");
268
+ const { stream } = await import("./04svnxxj.js");
269
269
  yield* stream(sql, text, params);
270
270
  }
271
271
  function send(sql, text, params, named) {
@@ -2,13 +2,13 @@ import {
2
2
  open5,
3
3
  connectClient3,
4
4
  send4
5
- } from "./y5656f0e.js";
5
+ } from "./am04v8na.js";
6
6
  import {
7
7
  NEON_WEBSOCKET_CAPABILITIES,
8
8
  NEON_HTTP_CAPABILITIES,
9
9
  readCapability2,
10
10
  hasCapability2
11
- } from "./xhrnjch9.js";
11
+ } from "./5x3pf400.js";
12
12
  export {
13
13
  NEON_WEBSOCKET_CAPABILITIES as capabilities,
14
14
  connectClient3 as connectClient,
@@ -1,6 +1,10 @@
1
+ import {
2
+ historySql2
3
+ } from "./dhatassp.js";
4
+ import"./jr2nmr81.js";
1
5
  import {
2
6
  OkmError
3
- } from "./f9mphxej.js";
7
+ } from "./hfq3n3bd.js";
4
8
 
5
9
  // src/runtime/compat-words.ts
6
10
  var BEHIND_EXPAND = "behind by expand";
@@ -37,10 +41,10 @@ function driftVerdict(codeHash, recordedHash, migrations) {
37
41
  const last = migrations.at(-1);
38
42
  return { state: "behind", migrationId: last?.id ?? "" };
39
43
  }
40
- async function assertDrift(pool, codeHash, recordedHash, options) {
44
+ async function assertDrift(pool, codeHash, recordedHash, options, namespace = "public") {
41
45
  let rows;
42
46
  try {
43
- const result = await pool.execute("select migration_id, class, catalog_hash from okm_history order by migration_id, step_index", undefined, options);
47
+ const result = await pool.execute(await historySql2(namespace), undefined, options);
44
48
  rows = result.rows;
45
49
  } catch (error) {
46
50
  throw gapError({ state: "behind", migrationId: "" }, error);
@@ -0,0 +1,9 @@
1
+ import {
2
+ historySql2,
3
+ acceptServer2
4
+ } from "./dhatassp.js";
5
+ import"./jr2nmr81.js";
6
+ export {
7
+ acceptServer2 as acceptServer,
8
+ historySql2 as historySql
9
+ };
@@ -3,7 +3,7 @@ import {
3
3
  readHandle,
4
4
  readCall,
5
5
  attachHttp
6
- } from "./mtrqn2hn.js";
6
+ } from "./jr2nmr81.js";
7
7
  import {
8
8
  OkmError,
9
9
  throwNamed,
@@ -19,13 +19,13 @@ import {
19
19
  list,
20
20
  isRecord,
21
21
  fail2
22
- } from "./f9mphxej.js";
22
+ } from "./hfq3n3bd.js";
23
23
 
24
24
  // src/runtime/aggregate.ts
25
25
  var BUCKET = Symbol.for("okmodel.bucket");
26
26
  var bucketChunk;
27
27
  function loadBucketGroup() {
28
- return bucketChunk ??= import("./2revefqt.js");
28
+ return bucketChunk ??= import("./57btdkgm.js");
29
29
  }
30
30
  var OPTIONS = [
31
31
  "where",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  emitSqlValue
3
- } from "./gmcf9cxf.js";
3
+ } from "./ybdew6j7.js";
4
4
  import {
5
5
  assertOperatorFits,
6
6
  sqlType,
@@ -8,7 +8,7 @@ import {
8
8
  assertBoundText,
9
9
  assertRegconfig,
10
10
  textArray
11
- } from "./3tq8pnb8.js";
11
+ } from "./w5d89rb4.js";
12
12
  import {
13
13
  isOperator,
14
14
  operatorName,
@@ -17,7 +17,7 @@ import {
17
17
  quote,
18
18
  isRecord,
19
19
  fail2
20
- } from "./f9mphxej.js";
20
+ } from "./hfq3n3bd.js";
21
21
 
22
22
  // src/runtime/operator-sql.ts
23
23
  function emitStructured(table, column, ref, name, value, sink, order) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  rejectClosed
3
- } from "./xhrnjch9.js";
3
+ } from "./5x3pf400.js";
4
4
  import {
5
5
  isConnectionLost
6
- } from "./f9mphxej.js";
6
+ } from "./hfq3n3bd.js";
7
7
 
8
8
  // src/adapters/pg/reserved.ts
9
9
  var RESET_ALL = "RESET ALL";
@@ -3,7 +3,7 @@ import {
3
3
  readHandle,
4
4
  readCall,
5
5
  attachHttp
6
- } from "./mtrqn2hn.js";
6
+ } from "./jr2nmr81.js";
7
7
  import {
8
8
  OkmError,
9
9
  throwNamed,
@@ -17,7 +17,7 @@ import {
17
17
  isRecord,
18
18
  registerFailFix,
19
19
  fail2
20
- } from "./f9mphxej.js";
20
+ } from "./hfq3n3bd.js";
21
21
 
22
22
  // src/runtime/page.ts
23
23
  registerFailFix("OKM1130", "Request the next page with the same orderBy and the exact next value the previous page returned. The cursor encodes that order.");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mapFailure
3
- } from "./xhrnjch9.js";
3
+ } from "./5x3pf400.js";
4
4
 
5
5
  // src/adapters/pg/pglite-wire.ts
6
6
  var OIDS = [