okmodel 0.7.0 → 0.8.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/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/fn/index.d.ts +39 -1
- package/dist/dialects/pg/fn/index.js +118 -26
- package/dist/dialects/pg/index.d.ts +2 -0
- package/dist/dialects/pg/index.js +393 -18
- 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 +8 -5
- 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/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 +15 -16
- package/dist/runtime/types.d.ts +15 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{mtaszv5a.js → 0wrea3jq.js} +102 -4
- package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
- package/dist/shared/{w79hsckn.js → 14x60fbf.js} +5 -5
- package/dist/shared/{ek2wt2dz.js → 16kvjebh.js} +4 -4
- package/dist/shared/{svncdeh5.js → 195pzzzz.js} +8 -8
- package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
- package/dist/shared/{jvd0mqag.js → 3449rcae.js} +5 -5
- package/dist/shared/{14vx95q4.js → 35q0n9tz.js} +7 -7
- package/dist/shared/3bb7wsqt.js +99 -0
- package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
- package/dist/shared/{81ebdx9p.js → 4m6hskg8.js} +4 -4
- package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
- package/dist/shared/{bg3rym3g.js → 63f4ksbz.js} +2 -2
- package/dist/shared/{pt94kz7f.js → 6m78c8ss.js} +1 -1
- package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
- package/dist/shared/{zm0ptry0.js → 7ghwamrf.js} +1 -1
- package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
- package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
- package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
- package/dist/shared/{kb2sdhfb.js → ae4j5f42.js} +17 -1
- package/dist/shared/agsfb86s.js +233 -0
- package/dist/shared/{7k9grvf6.js → b6d6p0zc.js} +5 -5
- package/dist/shared/{tbrvgw6z.js → bah9nbg3.js} +17 -16
- package/dist/shared/{5fe3kbsh.js → bnby0esn.js} +1 -1
- package/dist/shared/bsek72fg.js +225 -0
- package/dist/shared/{1w508jbr.js → bxas03mq.js} +21 -17
- package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
- package/dist/shared/{tsvww22q.js → dpc2r7rb.js} +7 -7
- package/dist/shared/{vb6qfyve.js → e8zyaqvj.js} +2 -2
- package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
- package/dist/shared/{gs74dbj5.js → f4jy1j7x.js} +27 -14
- package/dist/shared/{ttsqgp4p.js → fjpnhqan.js} +2 -2
- package/dist/shared/{xjk7hnn5.js → g5yc06ka.js} +2 -2
- package/dist/shared/{w72kgg4q.js → hfqmpasr.js} +6 -6
- package/dist/shared/{kr0jzbw2.js → hm5f8jby.js} +7 -7
- package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
- package/dist/shared/{cn957f8d.js → jebgrkeq.js} +3 -3
- package/dist/shared/{wa07eas9.js → jp36k7dp.js} +11 -11
- package/dist/shared/jx2m62cs.js +96 -0
- package/dist/shared/{sfz1ksn6.js → k86n8vq3.js} +2 -2
- package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
- package/dist/shared/{8skf0cam.js → kj9d8maq.js} +1 -1
- package/dist/shared/{aytqh5y2.js → m4xff2a6.js} +2 -2
- package/dist/shared/{zp9fmend.js → mfedzr74.js} +4 -4
- package/dist/shared/{ax7qv55k.js → mkrn359n.js} +60 -11
- package/dist/shared/{m6p12kbr.js → mnvjvqyp.js} +10 -10
- package/dist/shared/{1qa0qajz.js → mtw6jz76.js} +1 -1
- package/dist/shared/{1est4ezg.js → n05z9nwz.js} +3 -3
- package/dist/shared/{pbp1ss85.js → n0jmpgj1.js} +2 -2
- package/dist/shared/{ktz42yez.js → n41w4fbz.js} +5 -5
- package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
- package/dist/shared/n7kg8mmx.js +61 -0
- package/dist/shared/{g6evj1j3.js → needfe47.js} +1 -1
- package/dist/shared/{2shdbn8q.js → njga14v4.js} +9 -9
- package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
- package/dist/shared/{b5pftnn2.js → p3xbdcvt.js} +14 -18
- package/dist/shared/{te5as7z7.js → p5nh3r8q.js} +3 -3
- package/dist/shared/{p6qc5gcp.js → pan0370z.js} +6 -6
- package/dist/shared/{79dt02vc.js → q0cqt2sp.js} +1 -1
- package/dist/shared/{5v3xf80k.js → qd9hhd8f.js} +1 -1
- package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
- package/dist/shared/{9s0ypp87.js → sjk86yrx.js} +1 -1
- package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
- package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
- package/dist/shared/{vczs8gd4.js → v1wad97q.js} +2 -2
- package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
- package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
- package/dist/shared/{bz84tkzm.js → wcrheftc.js} +2 -2
- package/dist/shared/{ab9gmbwy.js → wvdjznah.js} +5 -5
- package/dist/shared/{7mnme5tn.js → wz2a78mp.js} +1 -1
- package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
- package/dist/shared/{je4axnm8.js → z581d7ny.js} +2 -2
- package/dist/shared/{x933k9a3.js → zbqbmmrp.js} +10 -10
- package/dist/shared/{rs73fca9.js → zgex00fd.js} +6 -6
- package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
- package/dist/tooling/cli.js +26 -13
- package/dist/tooling/driver-run.js +4971 -0
- package/dist/tooling/driver-test.d.ts +36 -0
- package/dist/tooling/migrate/commands.d.ts +2 -2
- package/dist/tooling/migrate/index.js +9 -9
- package/dist/tooling/migrate/project.d.ts +3 -0
- package/dist/tooling/shared/03k6res6.js +210 -0
- package/dist/tooling/shared/08kemxjd.js +10 -0
- package/dist/tooling/shared/2revefqt.js +209 -0
- package/dist/tooling/shared/2wtvc7rw.js +1425 -0
- package/dist/tooling/shared/345tbc2k.js +16 -0
- package/dist/tooling/shared/3m1hkg7z.js +344 -0
- package/dist/tooling/shared/3rrw5w8f.js +81 -0
- package/dist/tooling/shared/3tq8pnb8.js +131 -0
- package/dist/tooling/shared/417zdsk7.js +194 -0
- package/dist/tooling/shared/4d2w25vw.js +40 -0
- package/dist/tooling/shared/54tqkxja.js +51 -0
- package/dist/tooling/shared/5bvw2nev.js +12 -0
- package/dist/tooling/shared/6nyfyw70.js +231 -0
- package/dist/tooling/shared/72fyg4zv.js +160 -0
- package/dist/tooling/shared/733a1tq3.js +38 -0
- package/dist/tooling/shared/7ae7rjmn.js +20 -0
- package/dist/tooling/shared/7kms6fvj.js +20 -0
- package/dist/tooling/shared/8sqrsw3s.js +49 -0
- package/dist/tooling/shared/96ps4g1z.js +32 -0
- package/dist/tooling/shared/9kazs5p6.js +195 -0
- package/dist/tooling/shared/9xzm7hjg.js +38 -0
- package/dist/tooling/shared/a6pp9d12.js +49 -0
- package/dist/tooling/shared/a7q7t4n3.js +22 -0
- package/dist/tooling/shared/aftb2mwr.js +18 -0
- package/dist/tooling/shared/bz2dqhab.js +311 -0
- package/dist/tooling/shared/cmptmb4f.js +12 -0
- package/dist/tooling/shared/ddjtfgnx.js +177 -0
- package/dist/tooling/shared/djydjpqt.js +261 -0
- package/dist/tooling/shared/dw08f3m8.js +9 -0
- package/dist/tooling/shared/dy672fz6.js +16 -0
- package/dist/tooling/shared/dzx85q70.js +66 -0
- package/dist/tooling/shared/ec71zqgt.js +270 -0
- package/dist/tooling/shared/ep8zh3bk.js +6 -0
- package/dist/tooling/shared/f9mphxej.js +3789 -0
- package/dist/tooling/shared/fb9k2qwd.js +89 -0
- package/dist/tooling/shared/g9ad4n80.js +211 -0
- package/dist/tooling/shared/gfvtj6d0.js +94 -0
- package/dist/tooling/shared/gmcf9cxf.js +294 -0
- package/dist/tooling/shared/htnaj77v.js +17 -0
- package/dist/tooling/shared/j9t5s12a.js +7 -0
- package/dist/tooling/shared/jne7b93p.js +42 -0
- package/dist/tooling/shared/ma2340rx.js +118 -0
- package/dist/tooling/shared/mtrqn2hn.js +505 -0
- package/dist/tooling/shared/n4jqhpqz.js +27 -0
- package/dist/tooling/shared/nf7jmhfa.js +20 -0
- package/dist/tooling/shared/p7f08ktn.js +332 -0
- package/dist/tooling/shared/ppnnnvj8.js +13 -0
- package/dist/tooling/shared/pqy21k24.js +312 -0
- package/dist/tooling/shared/pw8fgahx.js +69 -0
- package/dist/tooling/shared/pwsytxm5.js +17 -0
- package/dist/tooling/shared/rf83gr2d.js +94 -0
- package/dist/tooling/shared/rq5kk8j6.js +401 -0
- package/dist/tooling/shared/rs1jb051.js +12 -0
- package/dist/tooling/shared/smn6kz1p.js +157 -0
- package/dist/tooling/shared/spk1jg3r.js +1696 -0
- package/dist/tooling/shared/tn8gay14.js +143 -0
- package/dist/tooling/shared/vraj6d74.js +42 -0
- package/dist/tooling/shared/vs0t6qt8.js +64 -0
- package/dist/tooling/shared/vx86qjv8.js +150 -0
- package/dist/tooling/shared/w7qe8sj1.js +140 -0
- package/dist/tooling/shared/wt7j7nf6.js +15 -0
- package/dist/tooling/shared/wwnekq5n.js +6 -0
- package/dist/tooling/shared/xhrnjch9.js +185 -0
- package/dist/tooling/shared/xjs6zqtc.js +190 -0
- package/dist/tooling/shared/y031jct9.js +16 -0
- package/dist/tooling/shared/y5656f0e.js +233 -0
- package/dist/tooling/shared/yfr8hzhm.js +604 -0
- package/dist/tooling/shared/yk9mp7vb.js +250 -0
- package/dist/tooling/shared/yw30vnq2.js +139 -0
- package/dist/tooling/shared/z8d7ptht.js +618 -0
- package/dist/tooling/shared/zhwnfyb2.js +9 -0
- package/dist/tooling/shared/zvnhh1n0.js +198 -0
- package/dist/tooling/testing/index.js +3 -3
- package/package.json +14 -2
- 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WRITE_PARAM_BUDGET2,
|
|
3
|
+
executeWrite2,
|
|
4
|
+
explainWrite2,
|
|
5
|
+
updateSliceBody2,
|
|
6
|
+
rejectDuplicateTargets2,
|
|
7
|
+
emitSet2,
|
|
8
|
+
Sql2,
|
|
9
|
+
writeSet2,
|
|
10
|
+
rejectMixedSets2,
|
|
11
|
+
readClaim2,
|
|
12
|
+
rejectUpdateKeys2,
|
|
13
|
+
requireFilter2,
|
|
14
|
+
returningOption2,
|
|
15
|
+
expectOf2,
|
|
16
|
+
allowSet2,
|
|
17
|
+
noteGuarded2
|
|
18
|
+
} from "./spk1jg3r.js";
|
|
19
|
+
import"./3tq8pnb8.js";
|
|
20
|
+
import"./cmptmb4f.js";
|
|
21
|
+
export {
|
|
22
|
+
Sql2 as Sql,
|
|
23
|
+
WRITE_PARAM_BUDGET2 as WRITE_PARAM_BUDGET,
|
|
24
|
+
allowSet2 as allowSet,
|
|
25
|
+
emitSet2 as emitSet,
|
|
26
|
+
executeWrite2 as executeWrite,
|
|
27
|
+
expectOf2 as expectOf,
|
|
28
|
+
explainWrite2 as explainWrite,
|
|
29
|
+
noteGuarded2 as noteGuarded,
|
|
30
|
+
readClaim2 as readClaim,
|
|
31
|
+
rejectDuplicateTargets2 as rejectDuplicateTargets,
|
|
32
|
+
rejectMixedSets2 as rejectMixedSets,
|
|
33
|
+
rejectUpdateKeys2 as rejectUpdateKeys,
|
|
34
|
+
requireFilter2 as requireFilter,
|
|
35
|
+
returningOption2 as returningOption,
|
|
36
|
+
updateSliceBody2 as updateSliceBody,
|
|
37
|
+
writeSet2 as writeSet
|
|
38
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open5,
|
|
3
|
+
connectClient3,
|
|
4
|
+
send4
|
|
5
|
+
} from "./y5656f0e.js";
|
|
6
|
+
import {
|
|
7
|
+
NEON_WEBSOCKET_CAPABILITIES,
|
|
8
|
+
NEON_HTTP_CAPABILITIES,
|
|
9
|
+
readCapability2,
|
|
10
|
+
hasCapability2
|
|
11
|
+
} from "./xhrnjch9.js";
|
|
12
|
+
export {
|
|
13
|
+
NEON_WEBSOCKET_CAPABILITIES as capabilities,
|
|
14
|
+
connectClient3 as connectClient,
|
|
15
|
+
hasCapability2 as hasCapability,
|
|
16
|
+
NEON_HTTP_CAPABILITIES as httpCapabilities,
|
|
17
|
+
open5 as open,
|
|
18
|
+
readCapability2 as readCapability,
|
|
19
|
+
send4 as send
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/adapters/pg/cursor.ts
|
|
2
|
+
async function* cursorStream(run, text, params) {
|
|
3
|
+
const name = "okm_stream";
|
|
4
|
+
await run("BEGIN");
|
|
5
|
+
try {
|
|
6
|
+
await run(`DECLARE ${name} NO SCROLL CURSOR FOR ${text}`, params);
|
|
7
|
+
for (;; ) {
|
|
8
|
+
const chunk = await run(`FETCH 64 FROM ${name}`);
|
|
9
|
+
if (chunk.rows.length === 0)
|
|
10
|
+
break;
|
|
11
|
+
yield chunk.rows;
|
|
12
|
+
}
|
|
13
|
+
} finally {
|
|
14
|
+
await run("ROLLBACK").catch(() => {
|
|
15
|
+
return;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { cursorStream };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open5
|
|
3
|
+
} from "./y5656f0e.js";
|
|
4
|
+
import {
|
|
5
|
+
createClient
|
|
6
|
+
} from "./mtrqn2hn.js";
|
|
7
|
+
|
|
8
|
+
// src/runtime/pg/neon.ts
|
|
9
|
+
function connect(target, options) {
|
|
10
|
+
if (typeof target === "object" && !isPool(target)) {
|
|
11
|
+
return import("./2wtvc7rw.js").then((mod) => mod.default(target, options, (config) => open5({
|
|
12
|
+
url: config.url,
|
|
13
|
+
...options.mode !== undefined ? { mode: options.mode } : {},
|
|
14
|
+
...config.max !== undefined ? { max: config.max } : {},
|
|
15
|
+
...config.timeouts !== undefined ? { timeouts: config.timeouts } : {},
|
|
16
|
+
...config.prepared !== undefined ? { prepared: config.prepared } : {},
|
|
17
|
+
...config.searchPath !== undefined ? { searchPath: config.searchPath } : {}
|
|
18
|
+
})));
|
|
19
|
+
}
|
|
20
|
+
const owned = !isPool(target);
|
|
21
|
+
const opened = isPool(target) ? Promise.resolve(target) : open5({
|
|
22
|
+
url: target,
|
|
23
|
+
...options.mode !== undefined ? { mode: options.mode } : {},
|
|
24
|
+
...options.max !== undefined ? { max: options.max } : {},
|
|
25
|
+
...options.timeouts !== undefined ? { timeouts: options.timeouts } : {},
|
|
26
|
+
...options.prepared !== undefined ? { prepared: options.prepared } : {},
|
|
27
|
+
...options.searchPath !== undefined ? { searchPath: options.searchPath } : {}
|
|
28
|
+
});
|
|
29
|
+
return opened.then((pool) => createClient(options.schema, pool, {
|
|
30
|
+
ownsPool: owned,
|
|
31
|
+
http: options.errors?.http,
|
|
32
|
+
includeValues: options.errors?.includeValues,
|
|
33
|
+
logger: options.logger,
|
|
34
|
+
signal: options.signal,
|
|
35
|
+
timeout: options.timeout,
|
|
36
|
+
timeouts: options.timeouts,
|
|
37
|
+
hookm: options.hookm,
|
|
38
|
+
catalog: options.catalog,
|
|
39
|
+
catalogDir: options.catalogDir,
|
|
40
|
+
requireMeta: options.requireMeta,
|
|
41
|
+
generators: options.generators
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function isPool(target) {
|
|
45
|
+
return typeof target === "object" && "execute" in target && "capabilities" in target;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
connect
|
|
49
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/runtime/hookm.ts
|
|
2
|
+
function notices(hookm, notices) {
|
|
3
|
+
if (hookm === undefined)
|
|
4
|
+
return;
|
|
5
|
+
for (const notice of notices) {
|
|
6
|
+
for (const hook of hookm)
|
|
7
|
+
call(() => hook.onNotice?.(notice));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function phase(hookm, phase, depth) {
|
|
11
|
+
if (hookm === undefined)
|
|
12
|
+
return;
|
|
13
|
+
const event = { phase, depth };
|
|
14
|
+
for (const hook of hookm)
|
|
15
|
+
call(() => hook.onTransaction?.(event));
|
|
16
|
+
}
|
|
17
|
+
function report(session, error) {
|
|
18
|
+
for (const hook of session.hookm ?? [])
|
|
19
|
+
call(() => hook.onError?.(error));
|
|
20
|
+
const entry = error instanceof Error ? { code: "code" in error ? String(error.code) : error.name, summary: error.message } : { code: "error", summary: String(error) };
|
|
21
|
+
call(() => session.logger?.error?.(entry));
|
|
22
|
+
}
|
|
23
|
+
function call(fn) {
|
|
24
|
+
try {
|
|
25
|
+
fn();
|
|
26
|
+
} catch {}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
notices,
|
|
30
|
+
phase,
|
|
31
|
+
report
|
|
32
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
emitSqlValue
|
|
3
|
+
} from "./gmcf9cxf.js";
|
|
4
|
+
import {
|
|
5
|
+
assertOperatorFits,
|
|
6
|
+
sqlType,
|
|
7
|
+
assertNoControl,
|
|
8
|
+
assertBoundText,
|
|
9
|
+
assertRegconfig,
|
|
10
|
+
textArray
|
|
11
|
+
} from "./3tq8pnb8.js";
|
|
12
|
+
import {
|
|
13
|
+
isOperator,
|
|
14
|
+
operatorName,
|
|
15
|
+
operatorValue,
|
|
16
|
+
installOperatorSql,
|
|
17
|
+
quote,
|
|
18
|
+
isRecord,
|
|
19
|
+
fail2
|
|
20
|
+
} from "./f9mphxej.js";
|
|
21
|
+
|
|
22
|
+
// src/runtime/operator-sql.ts
|
|
23
|
+
function emitStructured(table, column, ref, name, value, sink, order) {
|
|
24
|
+
if (name === "sql") {
|
|
25
|
+
emitSqlValue(table, ref, value, sink);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (name === "contains" || name === "containedBy" || name === "overlaps") {
|
|
29
|
+
emitContainment(column, ref, name, value, sink);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (name === "hasKey" || name === "hasAnyKey") {
|
|
33
|
+
emitJsonKey(column, ref, name, value, sink);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (name === "path") {
|
|
37
|
+
emitPath(column, ref, value, sink);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (name === "matches") {
|
|
41
|
+
emitMatches(column, ref, value, sink);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (name === "relevance") {
|
|
45
|
+
if (order !== true)
|
|
46
|
+
fail2("OKM1121", `relevance on ${column.field} belongs in orderBy.`);
|
|
47
|
+
emitRelevance(column, ref, value, sink);
|
|
48
|
+
sink.text(" desc");
|
|
49
|
+
sink.mark(`o:${column.field}:relevance`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (name === "similar" || name === "wordSimilar") {
|
|
53
|
+
emitTrigram(column, ref, name, value, sink);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
assertOperatorFits(column, name);
|
|
57
|
+
fail2("OKM1121", `${name} is not a value operator on ${column.field}. Use has, none, or every on a relation.`);
|
|
58
|
+
}
|
|
59
|
+
function emitContainment(column, ref, name, value, sink) {
|
|
60
|
+
assertOperatorFits(column, name);
|
|
61
|
+
const op = name === "contains" ? " @> " : name === "containedBy" ? " <@ " : " && ";
|
|
62
|
+
sink.text(ref);
|
|
63
|
+
sink.text(op);
|
|
64
|
+
sink.param(column.encode(value));
|
|
65
|
+
sink.text("::");
|
|
66
|
+
sink.text(sqlType(column.dataType, column));
|
|
67
|
+
}
|
|
68
|
+
function emitJsonKey(column, ref, name, value, sink) {
|
|
69
|
+
assertOperatorFits(column, name);
|
|
70
|
+
if (name === "hasKey") {
|
|
71
|
+
if (typeof value !== "string")
|
|
72
|
+
fail2("OKM1121", `hasKey on ${column.field} needs a key.`);
|
|
73
|
+
assertBoundText(value, `key on ${column.field}`);
|
|
74
|
+
sink.text("jsonb_exists(");
|
|
75
|
+
sink.text(ref);
|
|
76
|
+
sink.text(", ");
|
|
77
|
+
sink.param(value);
|
|
78
|
+
sink.text(")");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
82
|
+
fail2("OKM1121", `hasAnyKey on ${column.field} needs a list of keys.`);
|
|
83
|
+
}
|
|
84
|
+
sink.text("jsonb_exists_any(");
|
|
85
|
+
sink.text(ref);
|
|
86
|
+
sink.text(", ");
|
|
87
|
+
sink.param(textArray(value, `key on ${column.field}`));
|
|
88
|
+
sink.text("::text[])");
|
|
89
|
+
}
|
|
90
|
+
function emitPath(column, ref, value, sink) {
|
|
91
|
+
assertOperatorFits(column, "path");
|
|
92
|
+
if (!isRecord(value) || !Array.isArray(value.segments) || !isOperator(value.op)) {
|
|
93
|
+
fail2("OKM1121", `path on ${column.field} needs segments and a comparison.`);
|
|
94
|
+
}
|
|
95
|
+
const segments = value.segments;
|
|
96
|
+
if (segments.length === 0 || segments.some((item) => typeof item !== "string")) {
|
|
97
|
+
fail2("OKM1121", `path on ${column.field} needs a list of segments.`);
|
|
98
|
+
}
|
|
99
|
+
const opName = operatorName(value.op);
|
|
100
|
+
if (opName !== "eq" && opName !== "lt" && opName !== "lte" && opName !== "gt" && opName !== "gte") {
|
|
101
|
+
fail2("OKM1121", `path on ${column.field} compares with eq, lt, lte, gt, or gte.`);
|
|
102
|
+
}
|
|
103
|
+
const operand = operatorValue(value.op);
|
|
104
|
+
const cast = pathCast(column, operand);
|
|
105
|
+
const sql = opName === "eq" ? " = " : opName === "lt" ? " < " : opName === "lte" ? " <= " : opName === "gt" ? " > " : " >= ";
|
|
106
|
+
sink.text("(");
|
|
107
|
+
sink.text(ref);
|
|
108
|
+
sink.text(" #>> ");
|
|
109
|
+
sink.param(textArray(segments, `path on ${column.field}`));
|
|
110
|
+
sink.text("::text[])::");
|
|
111
|
+
sink.text(cast);
|
|
112
|
+
sink.text(sql);
|
|
113
|
+
sink.param(pathParam(operand));
|
|
114
|
+
}
|
|
115
|
+
function pathCast(column, operand) {
|
|
116
|
+
if (typeof operand === "number")
|
|
117
|
+
return "numeric";
|
|
118
|
+
if (typeof operand === "boolean")
|
|
119
|
+
return "boolean";
|
|
120
|
+
if (typeof operand === "string")
|
|
121
|
+
return "text";
|
|
122
|
+
fail2("OKM1121", `path on ${column.field} compares a string, number, or boolean.`);
|
|
123
|
+
}
|
|
124
|
+
function pathParam(operand) {
|
|
125
|
+
if (typeof operand === "number")
|
|
126
|
+
return String(operand);
|
|
127
|
+
if (typeof operand === "boolean")
|
|
128
|
+
return operand ? "true" : "false";
|
|
129
|
+
if (typeof operand === "string")
|
|
130
|
+
return operand;
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
var MATCH_FN = {
|
|
134
|
+
natural: "websearch_to_tsquery",
|
|
135
|
+
"all-words": "plainto_tsquery",
|
|
136
|
+
phrase: "phraseto_tsquery",
|
|
137
|
+
advanced: "to_tsquery"
|
|
138
|
+
};
|
|
139
|
+
function readMatch(column, value, label) {
|
|
140
|
+
if (!isRecord(value) || typeof value.query !== "string" || value.query.length === 0) {
|
|
141
|
+
fail2("OKM1121", `${label} on ${column.field} needs text to look for.`);
|
|
142
|
+
}
|
|
143
|
+
assertNoControl(value.query, `${label} on ${column.field}`);
|
|
144
|
+
const match = value.match ?? "natural";
|
|
145
|
+
const fn = typeof match === "string" ? MATCH_FN[match] : undefined;
|
|
146
|
+
if (fn === undefined) {
|
|
147
|
+
fail2("OKM1121", `${label} on ${column.field} match must be natural, all-words, phrase, or advanced.`);
|
|
148
|
+
}
|
|
149
|
+
if (value.language === undefined)
|
|
150
|
+
return { fn, language: undefined, query: value.query };
|
|
151
|
+
if (typeof value.language !== "string") {
|
|
152
|
+
fail2("OKM1121", `${label} on ${column.field} language must be a name such as english.`);
|
|
153
|
+
}
|
|
154
|
+
assertRegconfig(value.language);
|
|
155
|
+
return { fn, language: value.language, query: value.query };
|
|
156
|
+
}
|
|
157
|
+
function emitTsquery(sink, query) {
|
|
158
|
+
sink.mark(query.language === undefined ? `:${query.fn}` : `:${query.fn}:lang`);
|
|
159
|
+
sink.text(query.fn);
|
|
160
|
+
sink.text("(");
|
|
161
|
+
if (query.language !== undefined) {
|
|
162
|
+
sink.param(query.language);
|
|
163
|
+
sink.text("::regconfig, ");
|
|
164
|
+
}
|
|
165
|
+
sink.param(query.query);
|
|
166
|
+
sink.text(")");
|
|
167
|
+
}
|
|
168
|
+
function emitMatches(column, ref, value, sink) {
|
|
169
|
+
assertOperatorFits(column, "matches");
|
|
170
|
+
sink.text(ref);
|
|
171
|
+
sink.text(" @@ ");
|
|
172
|
+
emitTsquery(sink, readMatch(column, value, "matches"));
|
|
173
|
+
}
|
|
174
|
+
function emitRelevance(column, ref, value, sink) {
|
|
175
|
+
assertOperatorFits(column, "relevance");
|
|
176
|
+
sink.text("ts_rank(");
|
|
177
|
+
sink.text(ref);
|
|
178
|
+
sink.text(", ");
|
|
179
|
+
emitTsquery(sink, readMatch(column, value, "relevance"));
|
|
180
|
+
sink.text(")");
|
|
181
|
+
}
|
|
182
|
+
function emitTrigram(column, ref, name, value, sink) {
|
|
183
|
+
if (!isRecord(value) || typeof value.query !== "string" || typeof value.schema !== "string") {
|
|
184
|
+
fail2("OKM1121", `${name} on ${column.field} needs query text.`);
|
|
185
|
+
}
|
|
186
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value.schema)) {
|
|
187
|
+
fail2("OKM1121", `${name} on ${column.field} needs an extension schema name.`);
|
|
188
|
+
}
|
|
189
|
+
sink.text(ref);
|
|
190
|
+
sink.text(" operator(");
|
|
191
|
+
sink.text(quote(value.schema));
|
|
192
|
+
sink.text(name === "similar" ? ".%) " : ".<%) ");
|
|
193
|
+
sink.param(value.query);
|
|
194
|
+
}
|
|
195
|
+
installOperatorSql(emitStructured);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open6,
|
|
3
|
+
seal2
|
|
4
|
+
} from "./djydjpqt.js";
|
|
5
|
+
import {
|
|
6
|
+
createClient
|
|
7
|
+
} from "./mtrqn2hn.js";
|
|
8
|
+
|
|
9
|
+
// src/runtime/pg/pglite.ts
|
|
10
|
+
async function connect(target, options) {
|
|
11
|
+
if (typeof target === "object" && !isPool(target)) {
|
|
12
|
+
return import("./2wtvc7rw.js").then((mod) => mod.default(target, options, open6));
|
|
13
|
+
}
|
|
14
|
+
const pool = isPool(target) ? seal2(target) : await open6({
|
|
15
|
+
...target !== undefined ? { dataDir: target } : {},
|
|
16
|
+
...options.timeouts !== undefined ? { timeouts: options.timeouts } : {}
|
|
17
|
+
});
|
|
18
|
+
return createClient(options.schema, pool, {
|
|
19
|
+
ownsPool: true,
|
|
20
|
+
http: options.errors?.http,
|
|
21
|
+
includeValues: options.errors?.includeValues,
|
|
22
|
+
logger: options.logger,
|
|
23
|
+
signal: options.signal,
|
|
24
|
+
requireMeta: options.requireMeta,
|
|
25
|
+
timeout: options.timeout,
|
|
26
|
+
timeouts: options.timeouts,
|
|
27
|
+
hookm: options.hookm,
|
|
28
|
+
catalog: options.catalog,
|
|
29
|
+
catalogDir: options.catalogDir,
|
|
30
|
+
generators: options.generators
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function isPool(target) {
|
|
34
|
+
return typeof target === "object" && target !== null && "execute" in target && "capabilities" in target;
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
connect
|
|
38
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
markClientPool2,
|
|
3
|
+
open2
|
|
4
|
+
} from "./xjs6zqtc.js";
|
|
5
|
+
import {
|
|
6
|
+
createClient
|
|
7
|
+
} from "./mtrqn2hn.js";
|
|
8
|
+
|
|
9
|
+
// src/runtime/pg/bun.ts
|
|
10
|
+
function connect(target, options) {
|
|
11
|
+
if (typeof target === "object" && !isPool(target)) {
|
|
12
|
+
return import("./2wtvc7rw.js").then((mod) => mod.default(target, options, (config) => {
|
|
13
|
+
const pool = open2(config);
|
|
14
|
+
markClientPool2(pool);
|
|
15
|
+
return pool;
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
const owned = !isPool(target);
|
|
19
|
+
const pool = isPool(target) ? target : open2({
|
|
20
|
+
url: target,
|
|
21
|
+
...options.max !== undefined ? { max: options.max } : {},
|
|
22
|
+
...options.timeouts !== undefined ? { timeouts: options.timeouts } : {},
|
|
23
|
+
...options.prepared !== undefined ? { prepared: options.prepared } : {},
|
|
24
|
+
...options.searchPath !== undefined ? { searchPath: options.searchPath } : {},
|
|
25
|
+
...options.ssl !== undefined ? { ssl: options.ssl } : {}
|
|
26
|
+
});
|
|
27
|
+
if (!isPool(target))
|
|
28
|
+
markClientPool2(pool);
|
|
29
|
+
return createClient(options.schema, pool, {
|
|
30
|
+
ownsPool: owned,
|
|
31
|
+
http: options.errors?.http,
|
|
32
|
+
includeValues: options.errors?.includeValues,
|
|
33
|
+
logger: options.logger,
|
|
34
|
+
signal: options.signal,
|
|
35
|
+
timeout: options.timeout,
|
|
36
|
+
timeouts: options.timeouts,
|
|
37
|
+
hookm: options.hookm,
|
|
38
|
+
catalog: options.catalog,
|
|
39
|
+
catalogDir: options.catalogDir,
|
|
40
|
+
requireMeta: options.requireMeta,
|
|
41
|
+
generators: options.generators
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function isPool(target) {
|
|
45
|
+
return typeof target === "object" && "execute" in target && "capabilities" in target;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
connect
|
|
49
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
markClientPool2,
|
|
3
|
+
open2,
|
|
4
|
+
send2,
|
|
5
|
+
reserve2,
|
|
6
|
+
park2
|
|
7
|
+
} from "./xjs6zqtc.js";
|
|
8
|
+
import {
|
|
9
|
+
BUNSQL_CAPABILITIES,
|
|
10
|
+
readCapability2,
|
|
11
|
+
hasCapability2
|
|
12
|
+
} from "./xhrnjch9.js";
|
|
13
|
+
export {
|
|
14
|
+
BUNSQL_CAPABILITIES as capabilities,
|
|
15
|
+
hasCapability2 as hasCapability,
|
|
16
|
+
markClientPool2 as markClientPool,
|
|
17
|
+
open2 as open,
|
|
18
|
+
park2 as park,
|
|
19
|
+
readCapability2 as readCapability,
|
|
20
|
+
reserve2 as reserve,
|
|
21
|
+
send2 as send
|
|
22
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DriverError2,
|
|
3
|
+
cancelled2,
|
|
4
|
+
timedOut2,
|
|
5
|
+
outcomeUnknown2,
|
|
6
|
+
acquireTimeout2,
|
|
7
|
+
errorField2,
|
|
8
|
+
mapDriverError2
|
|
9
|
+
} from "./f9mphxej.js";
|
|
10
|
+
export {
|
|
11
|
+
DriverError2 as DriverError,
|
|
12
|
+
acquireTimeout2 as acquireTimeout,
|
|
13
|
+
cancelled2 as cancelled,
|
|
14
|
+
errorField2 as errorField,
|
|
15
|
+
mapDriverError2 as mapDriverError,
|
|
16
|
+
outcomeUnknown2 as outcomeUnknown,
|
|
17
|
+
timedOut2 as timedOut
|
|
18
|
+
};
|