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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
emitSqlValue
|
|
3
|
+
} from "./3bb7wsqt.js";
|
|
1
4
|
import {
|
|
2
5
|
assertOperatorFits,
|
|
3
6
|
sqlType,
|
|
@@ -11,7 +14,7 @@ import {
|
|
|
11
14
|
quote,
|
|
12
15
|
isRecord,
|
|
13
16
|
fail2
|
|
14
|
-
} from "./
|
|
17
|
+
} from "./kgwp4jdd.js";
|
|
15
18
|
import {
|
|
16
19
|
isOperator,
|
|
17
20
|
operatorName,
|
|
@@ -19,7 +22,11 @@ import {
|
|
|
19
22
|
} from "./cn0n68ft.js";
|
|
20
23
|
|
|
21
24
|
// src/runtime/operator-sql.ts
|
|
22
|
-
function emitStructured(column, ref, name, value, sink, order) {
|
|
25
|
+
function emitStructured(table, column, ref, name, value, sink, order) {
|
|
26
|
+
if (name === "sql") {
|
|
27
|
+
emitSqlValue(table, ref, value, sink);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
23
30
|
if (name === "contains" || name === "containedBy" || name === "overlaps") {
|
|
24
31
|
emitContainment(column, ref, name, value, sink);
|
|
25
32
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
touchFields,
|
|
3
3
|
fieldSealed
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./bxas03mq.js";
|
|
5
5
|
import {
|
|
6
6
|
projectExpr,
|
|
7
7
|
quote,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isRecord,
|
|
10
10
|
registerFailFix,
|
|
11
11
|
fail2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./kgwp4jdd.js";
|
|
13
13
|
import {
|
|
14
14
|
throwNamed2
|
|
15
15
|
} from "./52szzakm.js";
|
|
@@ -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)
|
|
@@ -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) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fail2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./kgwp4jdd.js";
|
|
4
4
|
|
|
5
5
|
// src/runtime/result-name.ts
|
|
6
6
|
var PROTOTYPE_KEYS = ",__proto__,constructor,toString,hasOwnProperty,valueOf,isPrototypeOf,propertyIsEnumerable,toLocaleString,__defineGetter__,__defineSetter__,__lookupGetter__,__lookupSetter__,then,";
|
|
@@ -31,6 +31,22 @@ var BUNSQL_CAPABILITIES = {
|
|
|
31
31
|
prepared: "unnamed",
|
|
32
32
|
describe: false
|
|
33
33
|
};
|
|
34
|
+
var NEON_WEBSOCKET_CAPABILITIES = {
|
|
35
|
+
transactions: "interactive",
|
|
36
|
+
stream: false,
|
|
37
|
+
listen: false,
|
|
38
|
+
cancel: false,
|
|
39
|
+
prepared: "unnamed",
|
|
40
|
+
describe: false
|
|
41
|
+
};
|
|
42
|
+
var NEON_HTTP_CAPABILITIES = {
|
|
43
|
+
transactions: "batch",
|
|
44
|
+
stream: false,
|
|
45
|
+
listen: false,
|
|
46
|
+
cancel: false,
|
|
47
|
+
prepared: "none",
|
|
48
|
+
describe: false
|
|
49
|
+
};
|
|
34
50
|
function readCapability2(flags, name) {
|
|
35
51
|
return flags[name];
|
|
36
52
|
}
|
|
@@ -166,4 +182,4 @@ function countFrom(value, rows) {
|
|
|
166
182
|
return rows;
|
|
167
183
|
}
|
|
168
184
|
|
|
169
|
-
export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, NODE_POSTGRES_CAPABILITIES, BUNSQL_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectUncancellable, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
|
|
185
|
+
export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, NODE_POSTGRES_CAPABILITIES, BUNSQL_CAPABILITIES, NEON_WEBSOCKET_CAPABILITIES, NEON_HTTP_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectUncancellable, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
outcomeUnknown2
|
|
3
|
+
} from "./cm3w0ywp.js";
|
|
4
|
+
import {
|
|
5
|
+
noTimeout
|
|
6
|
+
} from "./q0cqt2sp.js";
|
|
7
|
+
import {
|
|
8
|
+
noticeBuffer,
|
|
9
|
+
WireSession
|
|
10
|
+
} from "./mtw6jz76.js";
|
|
11
|
+
import {
|
|
12
|
+
NEON_WEBSOCKET_CAPABILITIES,
|
|
13
|
+
NEON_HTTP_CAPABILITIES,
|
|
14
|
+
driverErrors,
|
|
15
|
+
rejectClosed,
|
|
16
|
+
mapFailure,
|
|
17
|
+
runCall,
|
|
18
|
+
EMPTY_NOTICES,
|
|
19
|
+
resultFrom
|
|
20
|
+
} from "./ae4j5f42.js";
|
|
21
|
+
|
|
22
|
+
// src/adapters/pg/neon.ts
|
|
23
|
+
import {
|
|
24
|
+
Pool,
|
|
25
|
+
neon,
|
|
26
|
+
neonConfig
|
|
27
|
+
} from "@neondatabase/serverless";
|
|
28
|
+
var CONNECT_MS = 30000;
|
|
29
|
+
var WIRE = {
|
|
30
|
+
getTypeParser() {
|
|
31
|
+
return (value) => value;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var names = new Map;
|
|
35
|
+
async function open6(config) {
|
|
36
|
+
if (config.mode === "http")
|
|
37
|
+
return openHttp(config);
|
|
38
|
+
return openWebSocket(config);
|
|
39
|
+
}
|
|
40
|
+
function connectClient2(pool, acquireMs, counters) {
|
|
41
|
+
counters.waiting += 1;
|
|
42
|
+
let settled = false;
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
let timer;
|
|
45
|
+
if (acquireMs !== undefined) {
|
|
46
|
+
timer = setTimeout(() => {
|
|
47
|
+
settled = true;
|
|
48
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
49
|
+
driverErrors().then((errors) => {
|
|
50
|
+
reject(errors.acquireTimeout());
|
|
51
|
+
});
|
|
52
|
+
}, acquireMs);
|
|
53
|
+
}
|
|
54
|
+
take(pool).then((client) => {
|
|
55
|
+
if (settled) {
|
|
56
|
+
client.release();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (timer !== undefined)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
62
|
+
resolve(client);
|
|
63
|
+
}, (error) => {
|
|
64
|
+
if (settled)
|
|
65
|
+
return;
|
|
66
|
+
if (timer !== undefined)
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
counters.waiting = Math.max(0, counters.waiting - 1);
|
|
69
|
+
mapFailure(error).then(reject);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function send3(runner, text, params, named) {
|
|
74
|
+
const query = {
|
|
75
|
+
text,
|
|
76
|
+
rowMode: "array",
|
|
77
|
+
types: WIRE,
|
|
78
|
+
...params !== undefined && params.length > 0 ? { values: params } : {},
|
|
79
|
+
...named ? { name: statementName(text) } : {}
|
|
80
|
+
};
|
|
81
|
+
return runner.query(query);
|
|
82
|
+
}
|
|
83
|
+
async function openWebSocket(config) {
|
|
84
|
+
ensureWebSocket();
|
|
85
|
+
const max = config.max ?? 10;
|
|
86
|
+
const acquireMs = config.timeouts?.acquire;
|
|
87
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
88
|
+
const notices = noticeBuffer();
|
|
89
|
+
let closed = false;
|
|
90
|
+
const isClosed = () => closed;
|
|
91
|
+
const named = config.prepared === "named";
|
|
92
|
+
const pool = new Pool({
|
|
93
|
+
connectionString: config.url,
|
|
94
|
+
max,
|
|
95
|
+
idleTimeoutMillis: 0,
|
|
96
|
+
allowExitOnIdle: true,
|
|
97
|
+
connectionTimeoutMillis: CONNECT_MS,
|
|
98
|
+
application_name: "okmodel",
|
|
99
|
+
types: WIRE,
|
|
100
|
+
...config.searchPath !== undefined ? { options: `-c search_path=${config.searchPath}` } : {}
|
|
101
|
+
});
|
|
102
|
+
pool.on("error", () => {
|
|
103
|
+
return;
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
const warmed = await take(pool);
|
|
107
|
+
warmed.release();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
await pool.end().catch(() => {
|
|
110
|
+
return;
|
|
111
|
+
});
|
|
112
|
+
throw await mapFailure(error);
|
|
113
|
+
}
|
|
114
|
+
const root = new WireSession((text, params) => send3(pool, text, params, named), notices, isClosed, false, () => {
|
|
115
|
+
counters.busy += 1;
|
|
116
|
+
}, () => {
|
|
117
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
118
|
+
});
|
|
119
|
+
const held = { pool, acquireMs, counters, notices, named, isClosed };
|
|
120
|
+
const checkout = () => closed ? rejectClosed() : import("./jx2m62cs.js").then((mod) => mod.checkout(held));
|
|
121
|
+
return {
|
|
122
|
+
capabilities: NEON_WEBSOCKET_CAPABILITIES,
|
|
123
|
+
execute(text, params, options) {
|
|
124
|
+
const refused = noTimeout(options);
|
|
125
|
+
if (refused !== undefined)
|
|
126
|
+
return refused;
|
|
127
|
+
return runCall(closed, options, (watch) => root.query(text, params, watch));
|
|
128
|
+
},
|
|
129
|
+
async batch(statements, options) {
|
|
130
|
+
const refused = noTimeout(options);
|
|
131
|
+
if (refused !== undefined)
|
|
132
|
+
return refused;
|
|
133
|
+
const connection = await checkout();
|
|
134
|
+
try {
|
|
135
|
+
return await connection.batch(statements, options);
|
|
136
|
+
} finally {
|
|
137
|
+
await connection.release();
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
reserve: () => checkout(),
|
|
141
|
+
stats: () => statsOf(counters, max),
|
|
142
|
+
async close() {
|
|
143
|
+
closed = true;
|
|
144
|
+
await pool.end();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function openHttp(config) {
|
|
149
|
+
const max = config.max ?? 10;
|
|
150
|
+
const counters = { reserved: 0, busy: 0, reservedBusy: 0, waiting: 0 };
|
|
151
|
+
let closed = false;
|
|
152
|
+
const sql = neon(config.url, { arrayMode: true, fullResults: true });
|
|
153
|
+
const run = async (text, params) => {
|
|
154
|
+
counters.busy += 1;
|
|
155
|
+
try {
|
|
156
|
+
const result = await sql.query(text, params === undefined ? [] : [...params]);
|
|
157
|
+
return resultFrom(result, EMPTY_NOTICES);
|
|
158
|
+
} finally {
|
|
159
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
capabilities: NEON_HTTP_CAPABILITIES,
|
|
164
|
+
execute(text, params, options) {
|
|
165
|
+
const refused = noTimeout(options);
|
|
166
|
+
if (refused !== undefined)
|
|
167
|
+
return refused;
|
|
168
|
+
if (closed)
|
|
169
|
+
return rejectClosed();
|
|
170
|
+
return runCall(closed, options, () => run(text, params).catch((error) => mapFailure(error).then((mapped) => Promise.reject(mapped))));
|
|
171
|
+
},
|
|
172
|
+
async batch(statements, options) {
|
|
173
|
+
const refused = noTimeout(options);
|
|
174
|
+
if (refused !== undefined)
|
|
175
|
+
return refused;
|
|
176
|
+
if (closed)
|
|
177
|
+
return rejectClosed();
|
|
178
|
+
counters.busy += 1;
|
|
179
|
+
try {
|
|
180
|
+
const queries = statements.map((statement) => sql.query(statement.text, statement.params === undefined ? [] : [...statement.params]));
|
|
181
|
+
const results = await sql.transaction(queries, httpOptions());
|
|
182
|
+
return results.map((result) => resultFrom(result, EMPTY_NOTICES));
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (!isDatabaseError(error))
|
|
185
|
+
throw outcomeUnknown2(error);
|
|
186
|
+
throw await mapFailure(error);
|
|
187
|
+
} finally {
|
|
188
|
+
counters.busy = Math.max(0, counters.busy - 1);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
stats: () => statsOf(counters, max),
|
|
192
|
+
close() {
|
|
193
|
+
closed = true;
|
|
194
|
+
return Promise.resolve();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function httpOptions() {
|
|
199
|
+
return { arrayMode: true, fullResults: true };
|
|
200
|
+
}
|
|
201
|
+
function isDatabaseError(error) {
|
|
202
|
+
if (typeof error !== "object" || error === null)
|
|
203
|
+
return false;
|
|
204
|
+
const code = Reflect.get(error, "code");
|
|
205
|
+
return typeof code === "string" && /^[0-9A-Z]{5}$/.test(code);
|
|
206
|
+
}
|
|
207
|
+
function take(pool) {
|
|
208
|
+
const connect = pool.connect.bind(pool);
|
|
209
|
+
return connect();
|
|
210
|
+
}
|
|
211
|
+
function ensureWebSocket() {
|
|
212
|
+
if (neonConfig.webSocketConstructor === undefined && typeof WebSocket === "function") {
|
|
213
|
+
neonConfig.webSocketConstructor = WebSocket;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function statementName(text) {
|
|
217
|
+
const existing = names.get(text);
|
|
218
|
+
if (existing !== undefined)
|
|
219
|
+
return existing;
|
|
220
|
+
const name = `okm_${String(names.size)}`;
|
|
221
|
+
names.set(text, name);
|
|
222
|
+
return name;
|
|
223
|
+
}
|
|
224
|
+
function statsOf(counters, size) {
|
|
225
|
+
return {
|
|
226
|
+
size,
|
|
227
|
+
idle: Math.max(0, size - counters.reserved - counters.busy),
|
|
228
|
+
inflight: counters.busy + counters.reservedBusy,
|
|
229
|
+
waiting: counters.waiting
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { open6, connectClient2, send3 };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
renderCatalog
|
|
3
|
-
} from "./9s0ypp87.js";
|
|
4
1
|
import {
|
|
5
2
|
viewGlobalReason,
|
|
6
3
|
viewMentions
|
|
7
|
-
} from "./
|
|
4
|
+
} from "./760ppr76.js";
|
|
5
|
+
import {
|
|
6
|
+
renderCatalog
|
|
7
|
+
} from "./sjk86yrx.js";
|
|
8
8
|
import {
|
|
9
9
|
createClient
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./bah9nbg3.js";
|
|
11
11
|
import {
|
|
12
12
|
OkmError2
|
|
13
13
|
} from "./52szzakm.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
logicalIntent,
|
|
9
9
|
appliedRules,
|
|
10
10
|
rejectKeys
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./kgwp4jdd.js";
|
|
12
12
|
import {
|
|
13
13
|
OkmError2,
|
|
14
14
|
safe2,
|
|
@@ -86,7 +86,7 @@ function openClient(session) {
|
|
|
86
86
|
},
|
|
87
87
|
close,
|
|
88
88
|
connected: session.connected,
|
|
89
|
-
tx: (...args) => import("./
|
|
89
|
+
tx: (...args) => import("./v1wad97q.js").then((mod) => mod.tx(session, args)),
|
|
90
90
|
batch: (ops, options) => batchHandle(session, ops, options),
|
|
91
91
|
...session.tx?.extras
|
|
92
92
|
};
|
|
@@ -121,7 +121,7 @@ function tableApi(session, table, view, uses) {
|
|
|
121
121
|
const api = {
|
|
122
122
|
find(options = {}) {
|
|
123
123
|
if ("lock" in options) {
|
|
124
|
-
return lazyRead(session, () => import("./
|
|
124
|
+
return lazyRead(session, () => import("./k86n8vq3.js"), table, options, base, view);
|
|
125
125
|
}
|
|
126
126
|
return start(session, "find", table, options, base, view);
|
|
127
127
|
},
|
|
@@ -135,10 +135,10 @@ function tableApi(session, table, view, uses) {
|
|
|
135
135
|
return start(session, "exists", table, options, base, view);
|
|
136
136
|
},
|
|
137
137
|
page(options) {
|
|
138
|
-
return lazyRead(session, () => import("./
|
|
138
|
+
return lazyRead(session, () => import("./6m78c8ss.js"), table, options, base, view);
|
|
139
139
|
},
|
|
140
140
|
aggregate(options = {}) {
|
|
141
|
-
return lazyRead(session, () => import("./
|
|
141
|
+
return lazyRead(session, () => import("./n05z9nwz.js"), table, options, base, view);
|
|
142
142
|
},
|
|
143
143
|
insert(data, options = {}) {
|
|
144
144
|
return writeHandle(session, "insert", table, data, options, mods);
|
|
@@ -151,9 +151,9 @@ function tableApi(session, table, view, uses) {
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
for (const walk of ["descendants", "ancestors"]) {
|
|
154
|
-
api[walk] = (id, options) => lazyRead(session, () => import("./
|
|
154
|
+
api[walk] = (id, options) => lazyRead(session, () => import("./wz2a78mp.js"), table, { id, walk, options }, base, view);
|
|
155
155
|
}
|
|
156
|
-
api.sync = (id, relation, ids, options) => lazyRead(session, () => import("./
|
|
156
|
+
api.sync = (id, relation, ids, options) => lazyRead(session, () => import("./p5nh3r8q.js"), table, { id, relation, ids, options }, base, view, true);
|
|
157
157
|
const hooks = session.schema.hooks;
|
|
158
158
|
if (hooks !== undefined) {
|
|
159
159
|
for (const hook of hooks) {
|
|
@@ -169,16 +169,17 @@ function tableApi(session, table, view, uses) {
|
|
|
169
169
|
for (const name in session.schema.model[table]?.presets) {
|
|
170
170
|
api[name] = (...args) => tableApi(session, table, view, [uses, name, args]);
|
|
171
171
|
}
|
|
172
|
+
api[Symbol.for("okm.lane")] = [session, table, mapError];
|
|
172
173
|
return api;
|
|
173
174
|
}
|
|
174
175
|
function batchHandle(session, ops, options, replica) {
|
|
175
|
-
return queryHandle(() => import("./
|
|
176
|
+
return queryHandle(() => import("./e8zyaqvj.js").then((mod) => mod.batch(session, ops, options, replica)), {
|
|
176
177
|
replica: () => batchHandle(session, ops, options, true)
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
var writers;
|
|
180
181
|
function loadWrite() {
|
|
181
|
-
writers ??= import("./
|
|
182
|
+
writers ??= import("./qd9hhd8f.js");
|
|
182
183
|
return writers;
|
|
183
184
|
}
|
|
184
185
|
function queryHandle(run, extra) {
|
|
@@ -288,7 +289,7 @@ function lazyRead(session, load, table, options, mods, view, sync) {
|
|
|
288
289
|
return queryHandle(() => read().then((box) => box.it), extra);
|
|
289
290
|
}
|
|
290
291
|
async function decodeRows(plan, rows, table) {
|
|
291
|
-
return plan.outputs.includes.length === 0 ? decodeResult(plan, rows, table) : (await import("./
|
|
292
|
+
return plan.outputs.includes.length === 0 ? decodeResult(plan, rows, table) : (await import("./hqpxf4a4.js")).decodeIncluded(plan, rows, table);
|
|
292
293
|
}
|
|
293
294
|
function readHandle(session, table, call, mods, decode, extra) {
|
|
294
295
|
let prepared;
|
|
@@ -301,14 +302,14 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
301
302
|
call = (await import("./m7n9h2a5.js")).refine(session.schema, origin, mods.uses);
|
|
302
303
|
}
|
|
303
304
|
if (searched) {
|
|
304
|
-
call = (await import("./
|
|
305
|
+
call = (await import("./zq1he88x.js")).applyTextSearch(session.schema, call);
|
|
305
306
|
}
|
|
306
307
|
const hooks = await hooksFor(call);
|
|
307
308
|
if (readNeedsOperatorSql(session.schema, call) || hooks?.needsOperator(session.schema, call)) {
|
|
308
309
|
await loadOperatorSql();
|
|
309
310
|
}
|
|
310
311
|
if (call.build === undefined && selectHasWindow(call.select)) {
|
|
311
|
-
call = (await import("./
|
|
312
|
+
call = (await import("./1d9q9cv2.js")).attach(session.schema, call);
|
|
312
313
|
}
|
|
313
314
|
const bound = bindCall(session.schema, call, hooks);
|
|
314
315
|
let plan = session.cache.get(bound.key);
|
|
@@ -371,7 +372,7 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
371
372
|
}
|
|
372
373
|
function streamLazy(session, call, mods, view, batch) {
|
|
373
374
|
return async function* () {
|
|
374
|
-
const { streamRows } = await import("./
|
|
375
|
+
const { streamRows } = await import("./jebgrkeq.js");
|
|
375
376
|
yield* streamRows(session, call, mods, view, batch, (error) => logged(session, error));
|
|
376
377
|
}();
|
|
377
378
|
}
|
|
@@ -404,7 +405,7 @@ function readCall(op, table, options, all, scope, model, schema, view) {
|
|
|
404
405
|
};
|
|
405
406
|
}
|
|
406
407
|
async function checkServer(pool, schema, http, requireMeta, options, source) {
|
|
407
|
-
const server = await import("./
|
|
408
|
+
const server = await import("./fjpnhqan.js");
|
|
408
409
|
let rows;
|
|
409
410
|
try {
|
|
410
411
|
const result = await pool.execute(server.versionQuery, undefined, options);
|
|
@@ -433,7 +434,7 @@ function errorFields(error) {
|
|
|
433
434
|
var includeHooks;
|
|
434
435
|
var operatorSql;
|
|
435
436
|
function loadOperatorSql() {
|
|
436
|
-
operatorSql ??= import("./
|
|
437
|
+
operatorSql ??= import("./4vbf83xx.js").then(() => {
|
|
437
438
|
return;
|
|
438
439
|
});
|
|
439
440
|
return operatorSql;
|
|
@@ -444,7 +445,7 @@ function selectHasWindow(select) {
|
|
|
444
445
|
function hooksFor(call) {
|
|
445
446
|
if (call.include === undefined)
|
|
446
447
|
return Promise.resolve(undefined);
|
|
447
|
-
includeHooks ??= import("./
|
|
448
|
+
includeHooks ??= import("./hqpxf4a4.js").then((mod) => mod.includeHooks);
|
|
448
449
|
return includeHooks;
|
|
449
450
|
}
|
|
450
451
|
function bindNow(schema, call) {
|