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.
- package/README.md +14 -0
- package/dist/adapters/capabilities.d.ts +32 -0
- package/dist/adapters/failure.d.ts +1 -1
- package/dist/adapters/pg/bun-sql.d.ts +53 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +1 -1
- package/dist/adapters/pg/bunsql.d.ts +1 -1
- package/dist/adapters/pg/neon-extra.d.ts +18 -0
- package/dist/adapters/pg/neon.d.ts +104 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +1 -1
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gin.js +20 -0
- package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gist.js +20 -0
- package/dist/dialects/pg/ext/call.d.ts +53 -0
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/feature.d.ts +26 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
- package/dist/dialects/pg/ext/hstore.d.ts +41 -0
- package/dist/dialects/pg/ext/hstore.js +29 -0
- package/dist/dialects/pg/ext/index.d.ts +56 -0
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/ltree.d.ts +41 -0
- package/dist/dialects/pg/ext/ltree.js +29 -0
- package/dist/dialects/pg/ext/pg-trgm.js +4 -13
- package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
- package/dist/dialects/pg/ext/pgcrypto.js +33 -0
- package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
- package/dist/dialects/pg/ext/unaccent.js +21 -0
- package/dist/dialects/pg/ext/using.d.ts +23 -0
- package/dist/dialects/pg/ext/versions.d.ts +36 -0
- package/dist/dialects/pg/external.d.ts +19 -0
- package/dist/dialects/pg/fn/index.d.ts +39 -1
- package/dist/dialects/pg/fn/index.js +118 -26
- package/dist/dialects/pg/index.d.ts +3 -0
- package/dist/dialects/pg/index.js +394 -14
- package/dist/dialects/pg/introspect.d.ts +11 -0
- package/dist/dialects/pg/operators.d.ts +1 -1
- package/dist/dialects/pg/ops/fragment.d.ts +119 -0
- package/dist/dialects/pg/ops/lane.d.ts +49 -0
- package/dist/dialects/pg/view/client.d.ts +14 -6
- package/dist/dialects/pg/view/index.d.ts +73 -1
- package/dist/dialects/pg/view/index.js +156 -5
- package/dist/dialects/pg/view/scratch.d.ts +11 -5
- package/dist/runtime/artifact-file.d.ts +22 -0
- package/dist/runtime/client.d.ts +10 -0
- package/dist/runtime/drift-detail.d.ts +2 -1
- package/dist/runtime/drift.d.ts +3 -10
- package/dist/runtime/otel.d.ts +105 -0
- package/dist/runtime/otel.js +97 -0
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.d.ts +38 -0
- package/dist/runtime/pg/neon.js +64 -0
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +4 -4
- package/dist/runtime/plan.d.ts +1 -1
- package/dist/runtime/server-check.d.ts +36 -6
- package/dist/runtime/sql-fragment.d.ts +43 -0
- package/dist/runtime/tenancy/index.js +10 -10
- package/dist/runtime/topology.d.ts +1 -1
- package/dist/runtime/traits/index.js +16 -17
- package/dist/runtime/types.d.ts +15 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{81ebdx9p.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
- package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
- package/dist/shared/{w79hsckn.js → 1mxm04fy.js} +5 -5
- package/dist/shared/{7k9grvf6.js → 2szgv6yj.js} +5 -5
- package/dist/shared/{gs74dbj5.js → 2zdxkt7b.js} +933 -111
- package/dist/shared/{m6p12kbr.js → 3456242y.js} +23 -23
- package/dist/shared/3bb7wsqt.js +99 -0
- package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
- package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
- package/dist/shared/{pt94kz7f.js → 5kyb3tqx.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{x933k9a3.js → 62b603gr.js} +10 -10
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{tsvww22q.js → 6nae0spm.js} +156 -95
- package/dist/shared/{mtaszv5a.js → 71n0jmhc.js} +102 -4
- package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
- package/dist/shared/7ba5h6pb.js +17 -0
- package/dist/shared/{sfz1ksn6.js → 8jesqsrk.js} +2 -2
- package/dist/shared/{5v3xf80k.js → 8n688yjg.js} +1 -1
- package/dist/shared/{rs73fca9.js → 8qzkd9f3.js} +6 -6
- package/dist/shared/{ax7qv55k.js → 90sg0w5a.js} +202 -25
- package/dist/shared/{zm0ptry0.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
- package/dist/shared/{1w508jbr.js → 9dtgn1z2.js} +21 -17
- package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
- package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
- package/dist/shared/{te5as7z7.js → aksb89mn.js} +3 -3
- package/dist/shared/{bz84tkzm.js → bphrgwz9.js} +2 -2
- package/dist/shared/bsek72fg.js +225 -0
- package/dist/shared/{7mnme5tn.js → c3mvnq7a.js} +1 -1
- package/dist/shared/{p6qc5gcp.js → ccsmhv9r.js} +25 -7
- package/dist/shared/{pbp1ss85.js → cexb7z6b.js} +2 -2
- package/dist/shared/{ab9gmbwy.js → cf8zdz5p.js} +5 -5
- package/dist/shared/{jvd0mqag.js → ckz05z15.js} +5 -5
- package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
- package/dist/shared/{14vx95q4.js → dd5pmnky.js} +7 -7
- package/dist/shared/{vb6qfyve.js → ds229x4r.js} +2 -2
- package/dist/shared/{1qa0qajz.js → e275q7sd.js} +1 -1
- package/dist/shared/{zp9fmend.js → ebhz8vh6.js} +4 -4
- package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
- package/dist/shared/{je4axnm8.js → fdsz3w80.js} +2 -2
- package/dist/shared/{9s0ypp87.js → fk9vef30.js} +85 -74
- package/dist/shared/{g6evj1j3.js → g89fmz5s.js} +1 -1
- package/dist/shared/{aytqh5y2.js → ghqzdp94.js} +2 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
- package/dist/shared/{8skf0cam.js → jpybhf98.js} +1 -1
- package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/mazpbcdj.js +233 -0
- package/dist/shared/{kb2sdhfb.js → mfvx6kjx.js} +17 -1
- package/dist/shared/{svncdeh5.js → mgaq2sd3.js} +11 -8
- package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
- package/dist/shared/{b5pftnn2.js → myk8fswx.js} +66 -21
- package/dist/shared/{2shdbn8q.js → n306gqkd.js} +9 -9
- package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
- package/dist/shared/n5whk3mt.js +665 -0
- package/dist/shared/n7kg8mmx.js +61 -0
- package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
- package/dist/shared/{tbrvgw6z.js → npdftanb.js} +19 -26
- package/dist/shared/{ek2wt2dz.js → pg4ezgyf.js} +11 -30
- package/dist/shared/{5fe3kbsh.js → pgsak1yw.js} +1 -1
- package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
- package/dist/shared/{wa07eas9.js → qvwwp1mp.js} +62 -41
- package/dist/shared/rbxt795q.js +1766 -0
- package/dist/shared/{xjk7hnn5.js → s7he5e5d.js} +2 -2
- package/dist/shared/{w72kgg4q.js → ss2kv2rs.js} +6 -6
- package/dist/shared/stfa9xcw.js +450 -0
- package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
- package/dist/shared/{79dt02vc.js → tr64w5p0.js} +1 -1
- package/dist/shared/{cn957f8d.js → tw1nvvfj.js} +3 -3
- package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
- package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
- package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
- package/dist/shared/{vczs8gd4.js → wvtjg5m3.js} +2 -2
- package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
- package/dist/shared/xqacq37x.js +61 -0
- package/dist/shared/{1est4ezg.js → xtsydxjg.js} +3 -3
- package/dist/shared/xv8qj97g.js +96 -0
- package/dist/shared/{bg3rym3g.js → xwhdcrm4.js} +2 -2
- package/dist/shared/{kr0jzbw2.js → yvabyg9k.js} +7 -7
- package/dist/shared/yybhre6n.js +136 -0
- package/dist/shared/zdqf8k5d.js +8 -0
- package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
- package/dist/tooling/cli.js +108 -23
- package/dist/tooling/driver-run.js +4654 -0
- package/dist/tooling/driver-test.d.ts +36 -0
- package/dist/tooling/github/comment.d.ts +50 -0
- package/dist/tooling/github/post-comment.d.ts +17 -0
- package/dist/tooling/migrate/commands.d.ts +3 -2
- package/dist/tooling/migrate/config.d.ts +13 -0
- package/dist/tooling/migrate/export.d.ts +165 -0
- package/dist/tooling/migrate/ext-surface.d.ts +80 -0
- package/dist/tooling/migrate/ext.d.ts +31 -4
- package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
- package/dist/tooling/migrate/index.d.ts +3 -0
- package/dist/tooling/migrate/index.js +55 -10
- package/dist/tooling/migrate/lint-rules.d.ts +18 -1
- package/dist/tooling/migrate/lint.d.ts +14 -1
- package/dist/tooling/migrate/place.d.ts +18 -0
- package/dist/tooling/migrate/plan-json.d.ts +65 -0
- package/dist/tooling/migrate/project.d.ts +13 -1
- package/dist/tooling/migrate/pull-emit.d.ts +98 -0
- package/dist/tooling/migrate/pull-routines.d.ts +126 -0
- package/dist/tooling/migrate/pull-verify.d.ts +26 -0
- package/dist/tooling/migrate/pull.d.ts +62 -0
- package/dist/tooling/migrate/reprint.d.ts +32 -0
- package/dist/tooling/migrate/sandbox.d.ts +8 -2
- package/dist/tooling/migrate/schema-api.d.ts +43 -0
- package/dist/tooling/migrate/sql-lex.d.ts +18 -0
- package/dist/tooling/shared/04svnxxj.js +344 -0
- package/dist/tooling/shared/0j0jtse1.js +13 -0
- package/dist/tooling/shared/0r05zhyq.js +618 -0
- package/dist/tooling/shared/1800eymw.js +49 -0
- package/dist/tooling/shared/35zemrmf.js +12 -0
- package/dist/tooling/shared/3rmaz3pq.js +140 -0
- package/dist/tooling/shared/3yn79q5m.js +12 -0
- package/dist/tooling/shared/54tqkxja.js +51 -0
- package/dist/tooling/shared/57btdkgm.js +209 -0
- package/dist/tooling/shared/5bmksndh.js +118 -0
- package/dist/tooling/shared/5p8km5jb.js +38 -0
- package/dist/tooling/shared/5x3pf400.js +185 -0
- package/dist/tooling/shared/5zrzffnk.js +6 -0
- package/dist/tooling/shared/62fxpc1p.js +332 -0
- package/dist/tooling/shared/68tf18v4.js +20 -0
- package/dist/tooling/shared/6vk28rjp.js +98 -0
- package/dist/tooling/shared/76pv6qff.js +9 -0
- package/dist/tooling/shared/7aews1zg.js +311 -0
- package/dist/tooling/shared/7b3xp9gc.js +195 -0
- package/dist/tooling/shared/7kms6fvj.js +20 -0
- package/dist/tooling/shared/7pxncnzs.js +40 -0
- package/dist/tooling/shared/829fjxyw.js +198 -0
- package/dist/tooling/shared/8m5znpdt.js +66 -0
- package/dist/tooling/shared/8yr7ges1.js +211 -0
- package/dist/tooling/shared/96ps4g1z.js +32 -0
- package/dist/tooling/shared/9qr9rkbh.js +143 -0
- package/dist/tooling/shared/9sfbtwsk.js +49 -0
- package/dist/tooling/shared/9wsnsvbf.js +10 -0
- package/dist/tooling/shared/a2xe04bm.js +18 -0
- package/dist/tooling/shared/a4pzghha.js +20 -0
- package/dist/tooling/shared/am04v8na.js +233 -0
- package/dist/tooling/shared/asgr07mp.js +194 -0
- package/dist/tooling/shared/c0xevn1h.js +312 -0
- package/dist/tooling/shared/dhatassp.js +134 -0
- package/dist/tooling/shared/ezqn88nj.js +1696 -0
- package/dist/tooling/shared/f77nnfqy.js +231 -0
- package/dist/tooling/shared/fh07z1dt.js +15 -0
- package/dist/tooling/shared/gqwevek4.js +81 -0
- package/dist/tooling/shared/hfq3n3bd.js +4116 -0
- package/dist/tooling/shared/htnaj77v.js +17 -0
- package/dist/tooling/shared/j664qjrt.js +64 -0
- package/dist/tooling/shared/jpgmjsx3.js +38 -0
- package/dist/tooling/shared/jr2nmr81.js +497 -0
- package/dist/tooling/shared/jsjjz875.js +139 -0
- package/dist/tooling/shared/kbqnrs1x.js +1425 -0
- package/dist/tooling/shared/kz715295.js +94 -0
- package/dist/tooling/shared/m3xt8b1h.js +22 -0
- package/dist/tooling/shared/m4hhb8aa.js +9 -0
- package/dist/tooling/shared/mw5npye0.js +16 -0
- package/dist/tooling/shared/n4jqhpqz.js +27 -0
- package/dist/tooling/shared/nxq95eb6.js +42 -0
- package/dist/tooling/shared/qartgazh.js +70 -0
- package/dist/tooling/shared/rcywj2w8.js +190 -0
- package/dist/tooling/shared/s6qha57m.js +16 -0
- package/dist/tooling/shared/shjs0379.js +150 -0
- package/dist/tooling/shared/sjwkt1pg.js +16 -0
- package/dist/tooling/shared/stebqyyd.js +401 -0
- package/dist/tooling/shared/t4xveemq.js +250 -0
- package/dist/tooling/shared/t6zjeake.js +261 -0
- package/dist/tooling/shared/tcwpjvxe.js +9 -0
- package/dist/tooling/shared/tpssp7ac.js +160 -0
- package/dist/tooling/shared/v6j1ep6w.js +42 -0
- package/dist/tooling/shared/vwr2y833.js +270 -0
- package/dist/tooling/shared/w17sj05d.js +7 -0
- package/dist/tooling/shared/w5d89rb4.js +131 -0
- package/dist/tooling/shared/wbwq1jsa.js +157 -0
- package/dist/tooling/shared/wezxf3h8.js +17 -0
- package/dist/tooling/shared/yb4kd19s.js +12 -0
- package/dist/tooling/shared/ybdew6j7.js +294 -0
- package/dist/tooling/shared/yfedr1zb.js +6 -0
- package/dist/tooling/shared/yhp829bx.js +177 -0
- package/dist/tooling/shared/ytk1tjs0.js +604 -0
- package/dist/tooling/shared/zs9aymcp.js +210 -0
- package/dist/tooling/shared/zx3v9phv.js +8 -0
- package/dist/tooling/testing/index.js +3 -3
- package/package.json +50 -9
- package/dist/shared/ktz42yez.js +0 -113
- package/dist/shared/ttsqgp4p.js +0 -71
- package/dist/shared/y34a8714.js +0 -150
- package/dist/shared/zy8r7qvz.js +0 -116
- package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
- package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./cnkky55j.js";
|
|
5
5
|
import {
|
|
6
6
|
createClient
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./npdftanb.js";
|
|
8
8
|
import {
|
|
9
9
|
OkmError2
|
|
10
10
|
} from "./52szzakm.js";
|
|
@@ -96,8 +96,7 @@ async function connectTopology(target, options, open) {
|
|
|
96
96
|
const client = createClient(options.schema, router, { ownsPool: true, ...shared });
|
|
97
97
|
const routed = client;
|
|
98
98
|
routed.using = (route) => derive(options.schema, handle, router, shared, route);
|
|
99
|
-
|
|
100
|
-
return routed;
|
|
99
|
+
return instrument(routed, handle);
|
|
101
100
|
} catch (error) {
|
|
102
101
|
for (const endpoint of opened) {
|
|
103
102
|
if (endpoint.timer !== undefined)
|
|
@@ -108,6 +107,105 @@ async function connectTopology(target, options, open) {
|
|
|
108
107
|
throw error;
|
|
109
108
|
}
|
|
110
109
|
}
|
|
110
|
+
function instrument(client, handle, forced) {
|
|
111
|
+
const proxy = new Proxy(client, {
|
|
112
|
+
get(target, key, receiver) {
|
|
113
|
+
if (key === "using")
|
|
114
|
+
return Reflect.get(target, key, receiver);
|
|
115
|
+
const value = Reflect.get(target, key, receiver);
|
|
116
|
+
if (typeof value !== "function")
|
|
117
|
+
return retarget(value, handle, forced);
|
|
118
|
+
if (key === "tx") {
|
|
119
|
+
return (...args) => {
|
|
120
|
+
const index = typeof args[0] === "function" ? 0 : 1;
|
|
121
|
+
const fn = args[index];
|
|
122
|
+
if (typeof fn === "function") {
|
|
123
|
+
args[index] = (inner, ...rest) => fn(typeof inner === "object" && inner !== null ? instrument(inner, handle, "primary") : inner, ...rest);
|
|
124
|
+
}
|
|
125
|
+
return value.apply(target, args);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return (...args) => retarget(value.apply(target, args), handle, forced);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
handles.set(proxy, handle);
|
|
132
|
+
return proxy;
|
|
133
|
+
}
|
|
134
|
+
function wrapTable(table, handle, forced) {
|
|
135
|
+
return new Proxy(table, {
|
|
136
|
+
get(target, key, receiver) {
|
|
137
|
+
const value = Reflect.get(target, key, receiver);
|
|
138
|
+
if (typeof value !== "function")
|
|
139
|
+
return value;
|
|
140
|
+
return (...args) => {
|
|
141
|
+
const route = forced ?? readCallRoute(args[0]);
|
|
142
|
+
return retarget(value.apply(target, args), handle, route);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function retarget(value, handle, route) {
|
|
148
|
+
if (typeof value !== "object" || value === null)
|
|
149
|
+
return value;
|
|
150
|
+
if (typeof Reflect.get(value, "inspect") === "function" && typeof Reflect.get(value, "then") === "function") {
|
|
151
|
+
return showReason(value, handle, route);
|
|
152
|
+
}
|
|
153
|
+
if (typeof Reflect.get(value, "find") === "function")
|
|
154
|
+
return wrapTable(value, handle, route);
|
|
155
|
+
if (typeof Reflect.get(value, "table") === "function")
|
|
156
|
+
return instrument(value, handle, route);
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
function showReason(query, handle, route) {
|
|
160
|
+
return new Proxy(query, {
|
|
161
|
+
get(target, key, receiver) {
|
|
162
|
+
const value = Reflect.get(target, key, receiver);
|
|
163
|
+
if (key === "inspect" && typeof value === "function") {
|
|
164
|
+
const inspect = value;
|
|
165
|
+
return () => Promise.resolve(inspect.call(target)).then(async (view) => {
|
|
166
|
+
if (typeof view !== "object" || view === null)
|
|
167
|
+
return view;
|
|
168
|
+
const sql = Reflect.get(view, "sql");
|
|
169
|
+
const text = typeof sql === "object" && sql !== null && typeof Reflect.get(sql, "text") === "string" ? Reflect.get(sql, "text") : "";
|
|
170
|
+
const choice = await preview(handle, text, route);
|
|
171
|
+
return {
|
|
172
|
+
...view,
|
|
173
|
+
routing: {
|
|
174
|
+
endpoint: choice.endpoint.name,
|
|
175
|
+
role: choice.endpoint.role,
|
|
176
|
+
reason: choice.reason
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if ((key === "all" || key === "required") && typeof value === "function") {
|
|
182
|
+
const method = value;
|
|
183
|
+
return (...args) => retarget(method.apply(target, args), handle, route);
|
|
184
|
+
}
|
|
185
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function readCallRoute(value) {
|
|
190
|
+
if (typeof value !== "object" || value === null)
|
|
191
|
+
return;
|
|
192
|
+
const route = Reflect.get(value, "route");
|
|
193
|
+
return route === "primary" || route === "replica" ? route : undefined;
|
|
194
|
+
}
|
|
195
|
+
async function preview(handle, text, route) {
|
|
196
|
+
const currents = handle.endpoints.map((endpoint) => endpoint.current);
|
|
197
|
+
const rrLast = handle.rrLast;
|
|
198
|
+
try {
|
|
199
|
+
return await choose(handle, text, route);
|
|
200
|
+
} finally {
|
|
201
|
+
for (let index = 0;index < handle.endpoints.length; index += 1) {
|
|
202
|
+
const endpoint = handle.endpoints[index];
|
|
203
|
+
if (endpoint !== undefined)
|
|
204
|
+
endpoint.current = currents[index] ?? 0;
|
|
205
|
+
}
|
|
206
|
+
handle.rrLast = rrLast;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
111
209
|
function refuseRouting(routing) {
|
|
112
210
|
if (routing === undefined)
|
|
113
211
|
return;
|
|
@@ -574,7 +672,7 @@ function derive(schema, handle, router, shared, route) {
|
|
|
574
672
|
const name = readRoute(route);
|
|
575
673
|
const client = createClient(schema, force(handle, router, name), { ...shared, ownsPool: false });
|
|
576
674
|
delete client.close;
|
|
577
|
-
return client;
|
|
675
|
+
return instrument(client, handle, name);
|
|
578
676
|
}
|
|
579
677
|
function force(handle, router, route) {
|
|
580
678
|
const pool = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encodeUuid,
|
|
3
3
|
decodeUuid
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./ecn8mfdq.js";
|
|
5
5
|
import {
|
|
6
6
|
encodeText,
|
|
7
7
|
decodeText
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./typ3vy7t.js";
|
|
9
9
|
import {
|
|
10
10
|
snakeCase
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./gcefca6p.js";
|
|
12
12
|
import {
|
|
13
13
|
OkmError2
|
|
14
14
|
} from "./52szzakm.js";
|
|
@@ -28,19 +28,27 @@ function viewMentions(query, name) {
|
|
|
28
28
|
pattern += '"?(?![A-Za-z0-9_])';
|
|
29
29
|
return new RegExp(pattern).test(query);
|
|
30
30
|
}
|
|
31
|
+
function readColumns(source) {
|
|
32
|
+
return typeof source === "function" ? source() : source;
|
|
33
|
+
}
|
|
34
|
+
function readQuery(source) {
|
|
35
|
+
return typeof source === "function" ? source() : source;
|
|
36
|
+
}
|
|
31
37
|
function viewClient(name, columns, query, tenancy, refresh = "plain") {
|
|
32
38
|
const field = camelCase(name);
|
|
33
39
|
const marked = readGlobal(name, tenancy);
|
|
34
40
|
return {
|
|
35
41
|
field,
|
|
36
42
|
install(model, scope, tables, casing, scoped) {
|
|
43
|
+
const listed = readColumns(columns);
|
|
44
|
+
const text = readQuery(query);
|
|
37
45
|
if (Object.hasOwn(model, field)) {
|
|
38
46
|
throw new OkmError2("OKM1023", `View ${name} uses the client name ${field}.`, {
|
|
39
47
|
fix: { summary: "Give the view a name that no table uses." }
|
|
40
48
|
});
|
|
41
49
|
}
|
|
42
|
-
const exposes = exposesKey(
|
|
43
|
-
if (scope !== undefined && readsTenant(
|
|
50
|
+
const exposes = exposesKey(listed, scope);
|
|
51
|
+
if (scope !== undefined && readsTenant(text, tables, casing, scoped)) {
|
|
44
52
|
if (!exposes && marked === undefined) {
|
|
45
53
|
throw new OkmError2("OKM1820", `View ${name} reads a tenant table and does not expose ${scope.key}.`, {
|
|
46
54
|
fix: {
|
|
@@ -58,7 +66,7 @@ function viewClient(name, columns, query, tenancy, refresh = "plain") {
|
|
|
58
66
|
sql: name,
|
|
59
67
|
primary: [],
|
|
60
68
|
uniques: [],
|
|
61
|
-
columns: columnModels(
|
|
69
|
+
columns: columnModels(listed, scope),
|
|
62
70
|
relations: []
|
|
63
71
|
};
|
|
64
72
|
if (marked !== undefined)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pullProject2,
|
|
3
|
+
pullLayout2,
|
|
4
|
+
commitPullFiles2
|
|
5
|
+
} from "./rbxt795q.js";
|
|
6
|
+
import"./myk8fswx.js";
|
|
7
|
+
import"./2zdxkt7b.js";
|
|
8
|
+
import"./6nae0spm.js";
|
|
9
|
+
import"./n442h54c.js";
|
|
10
|
+
import"./fk9vef30.js";
|
|
11
|
+
import"./12z7aznj.js";
|
|
12
|
+
import"./dd5pmnky.js";
|
|
13
|
+
export {
|
|
14
|
+
commitPullFiles2 as commitPullFiles,
|
|
15
|
+
pullLayout2 as pullLayout,
|
|
16
|
+
pullProject2 as pullProject
|
|
17
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import"./
|
|
1
|
+
import"./12z7aznj.js";
|
|
2
2
|
import"./n442h54c.js";
|
|
3
|
-
import"./
|
|
3
|
+
import"./fk9vef30.js";
|
|
4
|
+
import"./dd5pmnky.js";
|
|
4
5
|
import {
|
|
5
6
|
projectPath,
|
|
6
7
|
loadConfig
|
|
7
|
-
} from "./
|
|
8
|
+
} from "./2zdxkt7b.js";
|
|
8
9
|
import {
|
|
9
10
|
listTargets
|
|
10
|
-
} from "./
|
|
11
|
-
import"./9s0ypp87.js";
|
|
11
|
+
} from "./6nae0spm.js";
|
|
12
12
|
|
|
13
13
|
// src/tooling/migrate/dev.ts
|
|
14
14
|
import { mkdirSync } from "node:fs";
|
|
@@ -20,7 +20,7 @@ async function devProject(cwd) {
|
|
|
20
20
|
`;
|
|
21
21
|
const directory = projectPath(cwd, config.out ?? ".okm", "dev-db");
|
|
22
22
|
mkdirSync(directory, { recursive: true });
|
|
23
|
-
const { open } = await import("./
|
|
23
|
+
const { open } = await import("./ghqzdp94.js");
|
|
24
24
|
const pool = await open({ dataDir: directory });
|
|
25
25
|
try {
|
|
26
26
|
await pool.execute("select 1");
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normaliseViewQuery,
|
|
3
|
+
viewObject,
|
|
4
|
+
materializedViewObject
|
|
5
|
+
} from "./12z7aznj.js";
|
|
6
|
+
import {
|
|
7
|
+
quoteIdent2,
|
|
8
|
+
createObjectSql2
|
|
9
|
+
} from "./fk9vef30.js";
|
|
1
10
|
import {
|
|
2
11
|
cellText,
|
|
3
12
|
VIEW_DEPENDENCIES,
|
|
4
13
|
viewDependencyEdges,
|
|
5
14
|
PUBLIC,
|
|
6
|
-
introspectSchema
|
|
7
|
-
|
|
15
|
+
introspectSchema,
|
|
16
|
+
atomicBody
|
|
17
|
+
} from "./myk8fswx.js";
|
|
8
18
|
import {
|
|
9
19
|
planMigration,
|
|
10
20
|
sessionFailure,
|
|
11
21
|
finishQuiet,
|
|
12
22
|
assertDirectConnection,
|
|
13
23
|
assertStableBackend
|
|
14
|
-
} from "./
|
|
15
|
-
import {
|
|
16
|
-
quoteIdent,
|
|
17
|
-
createObjectSql
|
|
18
|
-
} from "./9s0ypp87.js";
|
|
19
|
-
import {
|
|
20
|
-
normaliseViewQuery,
|
|
21
|
-
viewObject,
|
|
22
|
-
materializedViewObject
|
|
23
|
-
} from "./zy8r7qvz.js";
|
|
24
|
+
} from "./6nae0spm.js";
|
|
24
25
|
import {
|
|
25
26
|
catalog
|
|
26
27
|
} from "./ywspezzx.js";
|
|
@@ -49,10 +50,11 @@ var VIEW_SHAPE = `
|
|
|
49
50
|
`;
|
|
50
51
|
async function sealViews(runner, source) {
|
|
51
52
|
const views = source.objects.filter((object) => object.kind === "view" || object.kind === "materializedView");
|
|
52
|
-
|
|
53
|
+
const hasAtomic = source.objects.some((object) => object.kind === "function" && object.definition.atomic === true);
|
|
54
|
+
if (views.length === 0 && !hasAtomic)
|
|
53
55
|
return source;
|
|
54
56
|
await dropScratch(runner);
|
|
55
|
-
await runner.query(`create schema ${
|
|
57
|
+
await runner.query(`create schema ${quoteIdent2(SCRATCH)}`);
|
|
56
58
|
const previous = await runner.query(`select current_setting('search_path') as path`);
|
|
57
59
|
const saved = cellText(previous[0]?.path);
|
|
58
60
|
const path = await scratchSearchPath(runner, source);
|
|
@@ -65,12 +67,15 @@ async function sealViews(runner, source) {
|
|
|
65
67
|
await runner.query(stubTable(object, source));
|
|
66
68
|
}
|
|
67
69
|
await createObjects(runner, source, "function");
|
|
70
|
+
const reprinted = await reprintAtomicBodies(runner, source);
|
|
71
|
+
if (views.length === 0)
|
|
72
|
+
return reprinted;
|
|
68
73
|
await createViews(runner, views);
|
|
69
74
|
const shapes = await runner.query(VIEW_SHAPE, [SCRATCH]);
|
|
70
75
|
const deps = await runner.query(VIEW_DEPENDENCIES, [SCRATCH]);
|
|
71
76
|
const edges = viewDependencyEdges(deps, PUBLIC, source.objects);
|
|
72
77
|
const byName = new Map(shapes.map((row) => [cellText(row.name), row]));
|
|
73
|
-
const next =
|
|
78
|
+
const next = reprinted.objects.map((object) => {
|
|
74
79
|
if (object.kind !== "view" && object.kind !== "materializedView")
|
|
75
80
|
return object;
|
|
76
81
|
const row = byName.get(object.identity.name);
|
|
@@ -136,17 +141,165 @@ async function scratchSearchPath(runner, source) {
|
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
extra.sort();
|
|
139
|
-
return [SCRATCH, ...extra, "public"].map((name) =>
|
|
144
|
+
return [SCRATCH, ...extra, "public"].map((name) => quoteIdent2(name)).join(", ");
|
|
140
145
|
}
|
|
141
146
|
async function createObjects(runner, source, kind) {
|
|
142
147
|
for (const object of source.objects) {
|
|
143
148
|
if (object.kind !== kind)
|
|
144
149
|
continue;
|
|
145
|
-
const statement =
|
|
150
|
+
const statement = createObjectSql2(object, SCRATCH);
|
|
146
151
|
if (statement !== undefined)
|
|
147
152
|
await runner.query(statement);
|
|
148
153
|
}
|
|
149
154
|
}
|
|
155
|
+
var FUNCTION_DEFS = `
|
|
156
|
+
select p.proname as name,
|
|
157
|
+
pg_get_function_identity_arguments(p.oid) as args,
|
|
158
|
+
pg_get_functiondef(p.oid) as definition
|
|
159
|
+
from pg_proc p
|
|
160
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
161
|
+
where n.nspname = $1 and p.prokind = 'f'
|
|
162
|
+
`;
|
|
163
|
+
async function reprintAtomicBodies(runner, source) {
|
|
164
|
+
const created = source.objects.filter((object) => object.kind === "function");
|
|
165
|
+
if (!created.some((object) => object.definition.atomic === true))
|
|
166
|
+
return source;
|
|
167
|
+
const rows = await runner.query(FUNCTION_DEFS, [SCRATCH]);
|
|
168
|
+
const printed = rows.map((row) => ({
|
|
169
|
+
name: cellText(row.name),
|
|
170
|
+
args: splitIdentityArguments(cellText(row.args)),
|
|
171
|
+
body: atomicBody(cellText(row.definition))
|
|
172
|
+
}));
|
|
173
|
+
const byName = new Map;
|
|
174
|
+
for (let index = 0;index < printed.length; index += 1) {
|
|
175
|
+
const name = printed[index]?.name ?? "";
|
|
176
|
+
const list = byName.get(name);
|
|
177
|
+
if (list === undefined)
|
|
178
|
+
byName.set(name, [index]);
|
|
179
|
+
else
|
|
180
|
+
list.push(index);
|
|
181
|
+
}
|
|
182
|
+
const used = new Set;
|
|
183
|
+
let changed = false;
|
|
184
|
+
const objects = source.objects.map((object) => {
|
|
185
|
+
if (object.kind !== "function" || object.definition.atomic !== true)
|
|
186
|
+
return object;
|
|
187
|
+
const named = byName.get(object.identity.name) ?? [];
|
|
188
|
+
const index = chooseReprint(object, printed, named, used);
|
|
189
|
+
used.add(index);
|
|
190
|
+
const body = printed[index]?.body;
|
|
191
|
+
if (body === undefined || body === object.definition.body)
|
|
192
|
+
return object;
|
|
193
|
+
changed = true;
|
|
194
|
+
return { ...object, definition: { ...object.definition, body } };
|
|
195
|
+
});
|
|
196
|
+
return changed ? catalog(objects) : source;
|
|
197
|
+
}
|
|
198
|
+
function chooseReprint(object, printed, named, used) {
|
|
199
|
+
const only = named[0];
|
|
200
|
+
if (named.length === 1 && only !== undefined && !used.has(only))
|
|
201
|
+
return only;
|
|
202
|
+
const matches = named.filter((index) => {
|
|
203
|
+
const row = printed[index];
|
|
204
|
+
return row !== undefined && !used.has(index) && identityMatches(object, row.args);
|
|
205
|
+
});
|
|
206
|
+
const index = matches[0];
|
|
207
|
+
if (named.length > 1 && matches.length === 1 && index !== undefined)
|
|
208
|
+
return index;
|
|
209
|
+
throw reprintMiss(object, named.map((index) => printed[index]).filter((row) => row !== undefined));
|
|
210
|
+
}
|
|
211
|
+
function reprintMiss(object, rows) {
|
|
212
|
+
const catalog = object.identity.argTypes.join(", ");
|
|
213
|
+
const scratch = rows.length === 0 ? "(none)" : rows.map((row) => row.args.length === 0 ? "(no arguments)" : row.args.join(", ")).join("; ");
|
|
214
|
+
return new OkmError2("OKM1020", `Function ${object.identity.name}(${catalog}) was not created in the scratch schema. Catalog arguments: ${catalog}. Scratch arguments: ${scratch}.`, { fix: { summary: "The function body has to run against the tables in this schema." } });
|
|
215
|
+
}
|
|
216
|
+
function identityMatches(object, args) {
|
|
217
|
+
if (args.length !== object.identity.argTypes.length)
|
|
218
|
+
return false;
|
|
219
|
+
return args.every((printed, index) => printedHasType(object.identity.argTypes[index] ?? "", printed));
|
|
220
|
+
}
|
|
221
|
+
function splitIdentityArguments(args) {
|
|
222
|
+
const trimmed = args.trim();
|
|
223
|
+
if (trimmed.length === 0)
|
|
224
|
+
return [];
|
|
225
|
+
const parts = [];
|
|
226
|
+
let current = "";
|
|
227
|
+
let depth = 0;
|
|
228
|
+
for (const char of trimmed) {
|
|
229
|
+
if (char === "(")
|
|
230
|
+
depth += 1;
|
|
231
|
+
else if (char === ")" && depth > 0)
|
|
232
|
+
depth -= 1;
|
|
233
|
+
if (char === "," && depth === 0) {
|
|
234
|
+
parts.push(current.trim());
|
|
235
|
+
current = "";
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
current += char;
|
|
239
|
+
}
|
|
240
|
+
parts.push(current.trim());
|
|
241
|
+
return parts;
|
|
242
|
+
}
|
|
243
|
+
var ARG_TYPE_ALIASES = {
|
|
244
|
+
int: "integer",
|
|
245
|
+
int2: "smallint",
|
|
246
|
+
int4: "integer",
|
|
247
|
+
int8: "bigint",
|
|
248
|
+
bool: "boolean",
|
|
249
|
+
decimal: "numeric",
|
|
250
|
+
char: "character",
|
|
251
|
+
float4: "real",
|
|
252
|
+
float8: "double precision",
|
|
253
|
+
varchar: "character varying",
|
|
254
|
+
time: "time without time zone",
|
|
255
|
+
timetz: "time with time zone",
|
|
256
|
+
timestamp: "timestamp without time zone",
|
|
257
|
+
timestamptz: "timestamp with time zone"
|
|
258
|
+
};
|
|
259
|
+
function printedHasType(author, printed) {
|
|
260
|
+
const want = canonicalArgType(author);
|
|
261
|
+
const got = printed.trim().replaceAll(/\s+/g, " ").toLowerCase();
|
|
262
|
+
if (canonicalArgType(got) === want)
|
|
263
|
+
return true;
|
|
264
|
+
const space = got.indexOf(" ");
|
|
265
|
+
if (space < 0)
|
|
266
|
+
return false;
|
|
267
|
+
const name = got.slice(0, space);
|
|
268
|
+
if (!/^[a-z_][a-z0-9_]*$/.test(name))
|
|
269
|
+
return false;
|
|
270
|
+
return canonicalArgType(got.slice(space + 1)) === want;
|
|
271
|
+
}
|
|
272
|
+
function canonicalArgType(type) {
|
|
273
|
+
let compact = type.trim().replaceAll(/\s+/g, " ").toLowerCase();
|
|
274
|
+
const dot = compact.lastIndexOf(".");
|
|
275
|
+
if (dot >= 0)
|
|
276
|
+
compact = compact.slice(dot + 1);
|
|
277
|
+
compact = stripTypmods(compact).replaceAll(/\s+/g, " ").trim();
|
|
278
|
+
let arrays = 0;
|
|
279
|
+
while (compact.endsWith("[]")) {
|
|
280
|
+
arrays += 1;
|
|
281
|
+
compact = compact.slice(0, -2).trim();
|
|
282
|
+
}
|
|
283
|
+
const aliased = ARG_TYPE_ALIASES[compact] ?? compact;
|
|
284
|
+
return arrays === 0 ? aliased : `${aliased}${"[]".repeat(arrays)}`;
|
|
285
|
+
}
|
|
286
|
+
function stripTypmods(type) {
|
|
287
|
+
let out = "";
|
|
288
|
+
let depth = 0;
|
|
289
|
+
for (const char of type) {
|
|
290
|
+
if (char === "(") {
|
|
291
|
+
depth += 1;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (char === ")" && depth > 0) {
|
|
295
|
+
depth -= 1;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (depth === 0)
|
|
299
|
+
out += char;
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
150
303
|
async function createViews(runner, views) {
|
|
151
304
|
const pending = [...views];
|
|
152
305
|
let last = "";
|
|
@@ -154,7 +307,7 @@ async function createViews(runner, views) {
|
|
|
154
307
|
const failed = [];
|
|
155
308
|
let created = 0;
|
|
156
309
|
for (const object of pending) {
|
|
157
|
-
const sql = object.kind === "materializedView" ? `create materialized view ${
|
|
310
|
+
const sql = object.kind === "materializedView" ? `create materialized view ${quoteIdent2(object.identity.name)} as ${object.definition.query} with no data` : `create view ${quoteIdent2(object.identity.name)} as ${object.definition.query}`;
|
|
158
311
|
try {
|
|
159
312
|
await runner.query(sql);
|
|
160
313
|
created += 1;
|
|
@@ -174,8 +327,8 @@ async function createViews(runner, views) {
|
|
|
174
327
|
}
|
|
175
328
|
function stubTable(object, source) {
|
|
176
329
|
const columns = source.objects.filter((item) => item.kind === "column" && item.identity.parent.name === object.identity.name);
|
|
177
|
-
const lines = columns.map((column) => `${
|
|
178
|
-
return `create table ${
|
|
330
|
+
const lines = columns.map((column) => `${quoteIdent2(column.identity.name)} ${column.definition.dataType}`);
|
|
331
|
+
return `create table ${quoteIdent2(object.identity.name)} (${lines.join(", ")})`;
|
|
179
332
|
}
|
|
180
333
|
function readColumns(object, printed) {
|
|
181
334
|
const live = printed.length === 0 ? [] : printed.split(`
|
|
@@ -210,21 +363,31 @@ async function dropScratch(runner) {
|
|
|
210
363
|
join pg_namespace n on n.oid = c.relnamespace
|
|
211
364
|
where n.nspname = $1 and c.relkind in ('v', 'm', 'r')
|
|
212
365
|
`, [SCRATCH]);
|
|
366
|
+
const routines = await runner.query(`
|
|
367
|
+
select p.proname as name, pg_get_function_identity_arguments(p.oid) as args
|
|
368
|
+
from pg_proc p
|
|
369
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
370
|
+
where n.nspname = $1
|
|
371
|
+
`, [SCRATCH]);
|
|
213
372
|
const views = rows.filter((row) => cellText(row.kind) === "v" || cellText(row.kind) === "m");
|
|
214
373
|
for (let pass = 0;pass < Math.max(views.length, 1); pass += 1) {
|
|
215
374
|
for (const row of views) {
|
|
216
375
|
const kind = cellText(row.kind) === "m" ? "materialized view" : "view";
|
|
217
376
|
try {
|
|
218
|
-
await runner.query(`drop ${kind} if exists ${
|
|
377
|
+
await runner.query(`drop ${kind} if exists ${quoteIdent2(SCRATCH)}.${quoteIdent2(cellText(row.name))}`);
|
|
219
378
|
} catch {}
|
|
220
379
|
}
|
|
221
380
|
}
|
|
381
|
+
for (const row of routines) {
|
|
382
|
+
const args = cellText(row.args);
|
|
383
|
+
await runner.query(`drop function if exists ${quoteIdent2(SCRATCH)}.${quoteIdent2(cellText(row.name))}(${args})`);
|
|
384
|
+
}
|
|
222
385
|
for (const row of rows) {
|
|
223
386
|
if (cellText(row.kind) !== "r")
|
|
224
387
|
continue;
|
|
225
|
-
await runner.query(`drop table if exists ${
|
|
388
|
+
await runner.query(`drop table if exists ${quoteIdent2(SCRATCH)}.${quoteIdent2(cellText(row.name))}`);
|
|
226
389
|
}
|
|
227
|
-
await runner.query(`drop schema if exists ${
|
|
390
|
+
await runner.query(`drop schema if exists ${quoteIdent2(SCRATCH)} cascade`);
|
|
228
391
|
}
|
|
229
392
|
|
|
230
393
|
// src/tooling/migrate/drift.ts
|
|
@@ -241,14 +404,15 @@ async function assertAuthorDrift2(url, author, roles, allowPooler = false) {
|
|
|
241
404
|
const rows = await sql`select pg_backend_pid()::text as pid`;
|
|
242
405
|
return rows[0]?.pid ?? "";
|
|
243
406
|
}, allowPooler);
|
|
407
|
+
const schema = authorSchema(author);
|
|
244
408
|
const present = await sql`
|
|
245
|
-
select to_regclass(
|
|
409
|
+
select to_regclass(${metaReg(schema)})::text as reg
|
|
246
410
|
`;
|
|
247
411
|
if (present[0]?.reg == null)
|
|
248
412
|
return;
|
|
249
413
|
const runner = catalogQuery2(sql);
|
|
250
414
|
const authorOnServer = await sealViews(runner, author);
|
|
251
|
-
const live = await introspectSchema(runner,
|
|
415
|
+
const live = await introspectSchema(runner, schema, schema, managedRoleOptions2(roles));
|
|
252
416
|
const plan = planMigration({ before: live, after: authorOnServer, name: "check" });
|
|
253
417
|
if (plan.steps.length === 0)
|
|
254
418
|
return;
|
|
@@ -285,6 +449,19 @@ function managedRoleOptions2(roles) {
|
|
|
285
449
|
...roles?.reporting !== undefined ? { reportingRole: roles.reporting } : {}
|
|
286
450
|
};
|
|
287
451
|
}
|
|
452
|
+
function authorSchema(author) {
|
|
453
|
+
for (const object of author.objects) {
|
|
454
|
+
if (object.kind === "table" && object.owner !== "external" && object.identity.namespace.form === "static") {
|
|
455
|
+
return object.identity.namespace.name;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return "public";
|
|
459
|
+
}
|
|
460
|
+
function metaReg(schema) {
|
|
461
|
+
if (schema === "public")
|
|
462
|
+
return "public.okm_meta";
|
|
463
|
+
return `${quoteIdent2(schema)}.okm_meta`;
|
|
464
|
+
}
|
|
288
465
|
function managedRoleNames(roles) {
|
|
289
466
|
if (roles === undefined)
|
|
290
467
|
return;
|
|
@@ -6,27 +6,33 @@ import {
|
|
|
6
6
|
minPostgresDefinition,
|
|
7
7
|
uuidv7NeedsPostgres
|
|
8
8
|
} from "./ga9j92qj.js";
|
|
9
|
-
import {
|
|
10
|
-
catalog,
|
|
11
|
-
enumType,
|
|
12
|
-
sameEnumLabels
|
|
13
|
-
} from "./ywspezzx.js";
|
|
14
9
|
import {
|
|
15
10
|
isRelationCall
|
|
16
11
|
} from "./exn3sd90.js";
|
|
17
12
|
import {
|
|
18
13
|
encodeText,
|
|
19
14
|
decodeText
|
|
20
|
-
} from "./
|
|
15
|
+
} from "./typ3vy7t.js";
|
|
21
16
|
import {
|
|
22
17
|
snakeCase,
|
|
23
18
|
emittedTypeName,
|
|
24
19
|
rejectLater
|
|
25
|
-
} from "./
|
|
20
|
+
} from "./gcefca6p.js";
|
|
26
21
|
import {
|
|
27
22
|
ColumnBuilder2,
|
|
28
23
|
formatType
|
|
29
|
-
} from "./
|
|
24
|
+
} from "./606g0nbf.js";
|
|
25
|
+
import {
|
|
26
|
+
readClientGenerator
|
|
27
|
+
} from "./rwmrejjz.js";
|
|
28
|
+
import {
|
|
29
|
+
withLocation
|
|
30
|
+
} from "./y6jdds7g.js";
|
|
31
|
+
import {
|
|
32
|
+
catalog,
|
|
33
|
+
enumType,
|
|
34
|
+
sameEnumLabels
|
|
35
|
+
} from "./ywspezzx.js";
|
|
30
36
|
import {
|
|
31
37
|
definition,
|
|
32
38
|
unavailable
|
|
@@ -34,9 +40,6 @@ import {
|
|
|
34
40
|
import {
|
|
35
41
|
quoteLiteral
|
|
36
42
|
} from "./94ez8kzh.js";
|
|
37
|
-
import {
|
|
38
|
-
withLocation
|
|
39
|
-
} from "./y6jdds7g.js";
|
|
40
43
|
import {
|
|
41
44
|
staticNamespace2,
|
|
42
45
|
table3,
|
|
@@ -56,9 +59,6 @@ import {
|
|
|
56
59
|
catalogError2,
|
|
57
60
|
throwNamed2
|
|
58
61
|
} from "./52szzakm.js";
|
|
59
|
-
import {
|
|
60
|
-
readClientGenerator
|
|
61
|
-
} from "./rwmrejjz.js";
|
|
62
62
|
|
|
63
63
|
// src/dialects/pg/compile.ts
|
|
64
64
|
function compileColumn(builder, input) {
|