okmodel 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -1131
- package/dist/adapters/capabilities.d.ts +3 -0
- package/dist/adapters/failure.d.ts +13 -2
- package/dist/adapters/lazy-errors.d.ts +22 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +54 -3
- package/dist/adapters/pg/bunsql.d.ts +14 -1
- package/dist/adapters/pg/cursor.d.ts +17 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +11 -8
- package/dist/adapters/pg/nodepostgres-extra.d.ts +22 -1
- package/dist/adapters/pg/nodepostgres.d.ts +12 -0
- package/dist/adapters/pg/pglite-wire.d.ts +24 -0
- package/dist/adapters/pg/pglite.d.ts +10 -0
- package/dist/adapters/pg/postgres-extra.d.ts +27 -11
- package/dist/adapters/pg/reserved.d.ts +42 -0
- package/dist/adapters/pg/session.d.ts +0 -18
- package/dist/contracts/connection.d.ts +7 -6
- package/dist/dialects/pg/floor.d.ts +68 -0
- package/dist/dialects/pg/index.d.ts +6 -1
- package/dist/dialects/pg/index.js +49 -159
- package/dist/dialects/pg/keys.d.ts +11 -8
- package/dist/dialects/pg/model.d.ts +40 -0
- package/dist/dialects/pg/morph.d.ts +43 -0
- package/dist/dialects/pg/operator-fit.d.ts +2 -2
- package/dist/dialects/pg/operators.d.ts +14 -7
- package/dist/dialects/pg/ops/bucket.d.ts +65 -0
- package/dist/dialects/pg/ops/inc.d.ts +2 -2
- package/dist/dialects/pg/ops/matches.d.ts +9 -12
- package/dist/dialects/pg/ops/relevance.d.ts +13 -0
- package/dist/dialects/pg/ops/search-query.d.ts +22 -0
- package/dist/dialects/pg/ops/window.d.ts +103 -0
- package/dist/dialects/pg/preset.d.ts +1 -1
- package/dist/dialects/pg/relations.d.ts +100 -3
- package/dist/dialects/pg/schema.d.ts +31 -3
- package/dist/dialects/pg/view/index.js +1 -1
- package/dist/runtime/aggregate.d.ts +8 -2
- package/dist/runtime/bucket-group.d.ts +70 -0
- package/dist/runtime/conflict.d.ts +22 -4
- package/dist/runtime/include.d.ts +0 -8
- package/dist/runtime/inflight.d.ts +1 -1
- package/dist/runtime/page.d.ts +4 -1
- package/dist/runtime/pg/bun.js +12 -6
- package/dist/runtime/pg/pg.js +5 -5
- package/dist/runtime/pg/pglite.d.ts +1 -0
- package/dist/runtime/pg/pglite.js +9 -9
- package/dist/runtime/pg/postgresjs.js +5 -5
- package/dist/runtime/plan.d.ts +95 -5
- package/dist/runtime/read-stream.d.ts +13 -16
- package/dist/runtime/result-name.d.ts +17 -0
- package/dist/runtime/server-check.d.ts +3 -3
- package/dist/runtime/sort-bind.d.ts +21 -0
- package/dist/runtime/sort.d.ts +56 -0
- package/dist/runtime/sync.d.ts +70 -0
- package/dist/runtime/tenancy/index.js +7 -5
- package/dist/runtime/text-search.d.ts +20 -0
- package/dist/runtime/traits/index.d.ts +80 -0
- package/dist/runtime/traits/index.js +175 -11
- package/dist/runtime/tree.d.ts +38 -0
- package/dist/runtime/types.d.ts +218 -22
- package/dist/runtime/validate/index.js +2 -2
- package/dist/runtime/version.d.ts +39 -0
- package/dist/runtime/window.d.ts +21 -0
- package/dist/runtime/write.d.ts +54 -2
- package/dist/shared/{wkme6tep.js → 14vx95q4.js} +8 -16
- package/dist/shared/1est4ezg.js +313 -0
- package/dist/shared/{4az561fn.js → 1qa0qajz.js} +8 -23
- package/dist/shared/{2cg3wnxc.js → 1w508jbr.js} +593 -130
- package/dist/shared/2c13q96h.js +18 -0
- package/dist/shared/{b4v57v3x.js → 2d3xq4ps.js} +2 -2
- package/dist/shared/{1nw1f3vs.js → 2shdbn8q.js} +7 -7
- package/dist/shared/3v7t1yrv.js +208 -0
- package/dist/shared/{x3jc53kg.js → 5e3tf63j.js} +2 -2
- package/dist/shared/5fe3kbsh.js +10 -0
- package/dist/shared/5v3xf80k.js +37 -0
- package/dist/shared/{c58secgj.js → 63qtkrca.js} +38 -4
- package/dist/shared/{2z7wv5tj.js → 67txcrcw.js} +55 -34
- package/dist/shared/79dt02vc.js +12 -0
- package/dist/shared/{8x72s86k.js → 7k9grvf6.js} +10 -4
- package/dist/shared/7kms6fvj.js +20 -0
- package/dist/shared/7mnme5tn.js +8 -0
- package/dist/shared/7n7ddwt4.js +6 -0
- package/dist/shared/{5j36z8dn.js → 81ebdx9p.js} +39 -70
- package/dist/shared/{knmes2kh.js → 8skf0cam.js} +1 -1
- package/dist/shared/9a4ae4p8.js +31 -0
- package/dist/shared/9y3mmmh1.js +436 -0
- package/dist/shared/ab9gmbwy.js +213 -0
- package/dist/shared/{f0f1n281.js → ax7qv55k.js} +2 -2
- package/dist/shared/{g90m9b0g.js → aytqh5y2.js} +6 -5
- package/dist/shared/{vjpnzwjz.js → b5pftnn2.js} +1 -1
- package/dist/shared/{ag4c7516.js → b76b8d95.js} +2 -2
- package/dist/shared/{vmfkhszw.js → bg3rym3g.js} +33 -26
- package/dist/shared/{mb2ycs1p.js → bm22fvzr.js} +15 -15
- package/dist/shared/{q3j1tq7a.js → bz84tkzm.js} +148 -23
- package/dist/shared/{31vm914h.js → cm3w0ywp.js} +15 -16
- package/dist/shared/cn957f8d.js +179 -0
- package/dist/shared/{gwn6v667.js → cnkky55j.js} +25 -14
- package/dist/shared/{ys0xzyaj.js → dkxgzaqd.js} +224 -19
- package/dist/shared/dzj09cye.js +10 -0
- package/dist/shared/exn3sd90.js +359 -0
- package/dist/shared/g6evj1j3.js +66 -0
- package/dist/shared/ga9j92qj.js +25 -0
- package/dist/shared/{t3g0k88x.js → gs74dbj5.js} +16 -12
- package/dist/shared/gzaveazc.js +285 -0
- package/dist/shared/{2jd1sn0e.js → hyh73qk6.js} +1 -1
- package/dist/shared/{r1fdd0f6.js → je4axnm8.js} +5 -2
- package/dist/shared/{1f0xa3cb.js → jvd0mqag.js} +3 -3
- package/dist/shared/jznfax0y.js +155 -0
- package/dist/shared/{cgbamx3e.js → kb2sdhfb.js} +7 -4
- package/dist/shared/{wt5rzv1h.js → kr0jzbw2.js} +5 -5
- package/dist/shared/{p6bjzq9q.js → ktz42yez.js} +12 -4
- package/dist/shared/{p248q79y.js → m6p12kbr.js} +2 -2
- package/dist/shared/{r6nwkxnt.js → m7n9h2a5.js} +4 -4
- package/dist/shared/{672t5vym.js → mss6ctgv.js} +2 -2
- package/dist/shared/{929h19xp.js → mtaszv5a.js} +40 -10
- package/dist/shared/{b3awxn7h.js → n816peh1.js} +1 -1
- package/dist/shared/nbw1z4yd.js +18 -0
- package/dist/shared/{nx9hh281.js → p6qc5gcp.js} +12 -11
- package/dist/shared/{pjr6xrm5.js → pbp1ss85.js} +20 -17
- package/dist/shared/pt94kz7f.js +6 -0
- package/dist/shared/q5c6ngn3.js +13 -0
- package/dist/shared/{xq0mvhts.js → rs73fca9.js} +4 -4
- package/dist/shared/{r11n8grd.js → sfz1ksn6.js} +7 -4
- package/dist/shared/{wynzeggs.js → svncdeh5.js} +6 -6
- package/dist/shared/{j60w0dvr.js → tbrvgw6z.js} +57 -38
- package/dist/shared/te5as7z7.js +622 -0
- package/dist/shared/{ttmg09vd.js → tsvww22q.js} +1 -1
- package/dist/shared/{y2t3jktd.js → ttsqgp4p.js} +19 -12
- package/dist/shared/{x72jb7ad.js → v8g1vgv8.js} +1 -1
- package/dist/shared/{sbdme3vy.js → vb6qfyve.js} +60 -10
- package/dist/shared/{5d8t84hg.js → vczs8gd4.js} +14 -14
- package/dist/shared/{5yv4k6a6.js → vqrjpcqn.js} +144 -2
- package/dist/shared/{3fqwmr09.js → w72kgg4q.js} +4 -4
- package/dist/shared/{1z04fa85.js → w79hsckn.js} +12 -57
- package/dist/shared/{09p049xa.js → wa07eas9.js} +42 -14
- package/dist/shared/{32cnm7kn.js → x933k9a3.js} +74 -38
- package/dist/shared/{n076ydsc.js → xhfsfkgk.js} +62 -28
- package/dist/shared/xjk7hnn5.js +272 -0
- package/dist/shared/{hazqqecq.js → xnxsed62.js} +50 -21
- package/dist/shared/y6njgyda.js +249 -0
- package/dist/shared/{8etn7d8w.js → z7s6fpxv.js} +1 -1
- package/dist/shared/{n7mcc1gk.js → zchaghkf.js} +4 -3
- package/dist/shared/zm0ptry0.js +40 -0
- package/dist/shared/{nsva2a6b.js → znm0bpp5.js} +3 -0
- package/dist/shared/zp9fmend.js +145 -0
- package/dist/tooling/cli.js +11 -11
- package/dist/tooling/migrate/engine.d.ts +3 -2
- package/dist/tooling/migrate/index.js +7 -7
- package/dist/tooling/testing/index.js +1 -1
- package/package.json +4 -2
- package/dist/shared/3qnhc7w5.js +0 -38
- package/dist/shared/7m88x3e9.js +0 -45
- package/dist/shared/8dqhth8c.js +0 -12
- package/dist/shared/d5azex6s.js +0 -6
- package/dist/shared/j3rkk835.js +0 -99
- package/dist/shared/k68eedmy.js +0 -85
- package/dist/shared/venqrjna.js +0 -216
- package/dist/shared/wxr8cwns.js +0 -6
- package/dist/shared/zm0mafk4.js +0 -92
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DriverError2
|
|
3
|
+
} from "./cm3w0ywp.js";
|
|
4
|
+
import {
|
|
5
|
+
OkmError2
|
|
6
|
+
} from "./52szzakm.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/lazy-errors.ts
|
|
9
|
+
function refused() {
|
|
10
|
+
return Promise.reject(new OkmError2("OKM1120", "timeout"));
|
|
11
|
+
}
|
|
12
|
+
function closed() {
|
|
13
|
+
return Promise.reject(new DriverError2("The pool is closed.", { sqlstate: "08006" }));
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
closed,
|
|
17
|
+
refused
|
|
18
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
async function refuseUncancellableTimeout(pool, timeout) {
|
|
3
3
|
if (pool.capabilities.cancel === true || timeout === undefined || !(timeout > 0))
|
|
4
4
|
return;
|
|
5
|
-
const {
|
|
6
|
-
|
|
5
|
+
const { refused } = await import("./2c13q96h.js");
|
|
6
|
+
await refused();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { refuseUncancellableTimeout };
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
applyProject2,
|
|
5
5
|
pushProject2,
|
|
6
6
|
backfillTiming2
|
|
7
|
-
} from "./
|
|
8
|
-
import"./
|
|
9
|
-
import"./
|
|
10
|
-
import"./
|
|
11
|
-
import"./
|
|
12
|
-
import"./
|
|
7
|
+
} from "./p6qc5gcp.js";
|
|
8
|
+
import"./m6p12kbr.js";
|
|
9
|
+
import"./8skf0cam.js";
|
|
10
|
+
import"./b5pftnn2.js";
|
|
11
|
+
import"./gs74dbj5.js";
|
|
12
|
+
import"./tsvww22q.js";
|
|
13
13
|
import"./n442h54c.js";
|
|
14
14
|
import"./9s0ypp87.js";
|
|
15
15
|
import"./qq3899ht.js";
|
|
16
|
-
import"./
|
|
16
|
+
import"./14vx95q4.js";
|
|
17
17
|
export {
|
|
18
18
|
applyProject2 as applyProject,
|
|
19
19
|
applyTarget2 as applyTarget,
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
refusePrototypeKey
|
|
3
|
+
} from "./q5c6ngn3.js";
|
|
4
|
+
import {
|
|
5
|
+
isBucket
|
|
6
|
+
} from "./nbw1z4yd.js";
|
|
7
|
+
import {
|
|
8
|
+
parseOrder,
|
|
9
|
+
projectExpr,
|
|
10
|
+
quote,
|
|
11
|
+
list,
|
|
12
|
+
isRecord,
|
|
13
|
+
fail2
|
|
14
|
+
} from "./67txcrcw.js";
|
|
15
|
+
import {
|
|
16
|
+
throwNamed2
|
|
17
|
+
} from "./52szzakm.js";
|
|
18
|
+
|
|
19
|
+
// src/runtime/bucket-group.ts
|
|
20
|
+
function readBucket(table, value, fields, aliases) {
|
|
21
|
+
if (!isBucket(value))
|
|
22
|
+
fail2("OKM1120", "bucket group");
|
|
23
|
+
const column = typeof value.column === "string" ? table.columns.get(value.column) : undefined;
|
|
24
|
+
if (typeof value.column !== "string" || column === undefined) {
|
|
25
|
+
throwNamed2("OKM1120", String(value.column), table.names, `Field ${String(value.column)} is not on ${table.model.name}. Accepted names: ${list(table.names)}.`);
|
|
26
|
+
}
|
|
27
|
+
if (column.hidden) {
|
|
28
|
+
fail2("OKM1120", `Field ${column.field} is hidden, so groupBy cannot read it.`);
|
|
29
|
+
}
|
|
30
|
+
const unit = unitOf(value.unit);
|
|
31
|
+
if (unit === undefined) {
|
|
32
|
+
fail2("OKM1120", `bucket() unit ${String(value.unit)} is not a time unit. Accepted units: second, minute, hour, day, week, month, quarter, year.`);
|
|
33
|
+
}
|
|
34
|
+
const shift = weekShift(value.weekStart, unit);
|
|
35
|
+
const kind = temporalKind(column.dataType);
|
|
36
|
+
if (kind !== "timestamptz" && kind !== "date") {
|
|
37
|
+
fail2("OKM1120", `bucket() does not apply to ${kind === "timestamp" ? "timestamp" : column.dataType} column ${column.field}. Use timestamptz or date.`);
|
|
38
|
+
}
|
|
39
|
+
if (kind === "date" && clockUnit(unit)) {
|
|
40
|
+
fail2("OKM1120", `bucket() unit ${unit} does not apply to date column ${column.field}. Accepted units: day, week, month, quarter, year.`);
|
|
41
|
+
}
|
|
42
|
+
let tz;
|
|
43
|
+
if (kind === "timestamptz") {
|
|
44
|
+
if (typeof value.tz !== "string") {
|
|
45
|
+
fail2("OKM1120", `bucket() on timestamptz column ${column.field} needs tz, an IANA time zone.`);
|
|
46
|
+
}
|
|
47
|
+
if (!iana(value.tz))
|
|
48
|
+
fail2("OKM1120", `bucket() tz ${value.tz} is not an IANA time zone.`);
|
|
49
|
+
tz = value.tz;
|
|
50
|
+
} else if (value.tz !== undefined) {
|
|
51
|
+
fail2("OKM1120", `bucket() on date column ${column.field} does not take tz.`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof value.as !== "string" || value.as.length === 0) {
|
|
54
|
+
fail2("OKM1120", "bucket() needs as, the name of the result key.");
|
|
55
|
+
}
|
|
56
|
+
refusePrototypeKey(value.as, "bucket as");
|
|
57
|
+
if (value.as === "count" || value.as === "sum" || value.as === "avg" || value.as === "min" || value.as === "max") {
|
|
58
|
+
fail2("OKM1120", `bucket as ${value.as} clashes with an aggregate key.`);
|
|
59
|
+
}
|
|
60
|
+
if (fields.has(value.as) || aliases.has(value.as)) {
|
|
61
|
+
fail2("OKM1120", `bucket as ${value.as} clashes with another group.`);
|
|
62
|
+
}
|
|
63
|
+
aliases.add(value.as);
|
|
64
|
+
return { kind: "bucket", column, unit, tz, as: value.as, shift, clock: clockUnit(unit) };
|
|
65
|
+
}
|
|
66
|
+
function writeBucket(sink, outputs, wrote, group) {
|
|
67
|
+
if (wrote.at > 0)
|
|
68
|
+
sink.text(", ");
|
|
69
|
+
if (group.clock)
|
|
70
|
+
emitClock(sink, group);
|
|
71
|
+
else
|
|
72
|
+
emitCalendar(sink, group);
|
|
73
|
+
outputs?.fields.push({
|
|
74
|
+
key: `g:${group.as}`,
|
|
75
|
+
at: wrote.at,
|
|
76
|
+
decode: bucketDecode(group)
|
|
77
|
+
});
|
|
78
|
+
wrote.at += 1;
|
|
79
|
+
}
|
|
80
|
+
function writeGrouped(sink, names, orderBy) {
|
|
81
|
+
sink.text(ordinals(names.length));
|
|
82
|
+
if (isRecord(orderBy) && Object.keys(orderBy).length > 0) {
|
|
83
|
+
sink.text(" order by ");
|
|
84
|
+
const keys = Object.keys(orderBy);
|
|
85
|
+
for (let index = 0;index < keys.length; index += 1) {
|
|
86
|
+
const key = keys[index];
|
|
87
|
+
if (key === undefined)
|
|
88
|
+
continue;
|
|
89
|
+
const parsed = parseOrder(key, orderBy[key]);
|
|
90
|
+
if (index > 0)
|
|
91
|
+
sink.text(", ");
|
|
92
|
+
sink.text(String(names.indexOf(key) + 1));
|
|
93
|
+
sink.text(parsed.dir === "asc" ? " asc" : " desc");
|
|
94
|
+
sink.text(parsed.nulls === "first" ? " nulls first" : " nulls last");
|
|
95
|
+
sink.mark(`o:${key}:${parsed.dir}:${parsed.nulls}`);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
sink.text(" order by ");
|
|
100
|
+
const parts = [];
|
|
101
|
+
for (let index = 1;index <= names.length; index += 1) {
|
|
102
|
+
parts.push(`${String(index)} asc nulls last`);
|
|
103
|
+
}
|
|
104
|
+
sink.text(parts.join(", "));
|
|
105
|
+
}
|
|
106
|
+
function unitOf(value) {
|
|
107
|
+
if (value === "second" || value === "minute" || value === "hour" || value === "day" || value === "week" || value === "month" || value === "quarter" || value === "year") {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
function clockUnit(unit) {
|
|
113
|
+
return unit === "second" || unit === "minute" || unit === "hour";
|
|
114
|
+
}
|
|
115
|
+
function weekShift(value, unit) {
|
|
116
|
+
if (value === undefined)
|
|
117
|
+
return 0;
|
|
118
|
+
if (unit !== "week")
|
|
119
|
+
fail2("OKM1120", "bucket() weekStart applies to unit week.");
|
|
120
|
+
if (value === "monday")
|
|
121
|
+
return 0;
|
|
122
|
+
if (value === "sunday")
|
|
123
|
+
return 1;
|
|
124
|
+
if (value === "saturday")
|
|
125
|
+
return 2;
|
|
126
|
+
return fail2("OKM1120", "bucket() weekStart must be monday, sunday, or saturday.");
|
|
127
|
+
}
|
|
128
|
+
function temporalKind(dataType) {
|
|
129
|
+
if (dataType === "date")
|
|
130
|
+
return "date";
|
|
131
|
+
if (dataType === "timestamptz" || dataType.startsWith("timestamptz("))
|
|
132
|
+
return "timestamptz";
|
|
133
|
+
if (dataType === "timestamp" || dataType.startsWith("timestamp("))
|
|
134
|
+
return "timestamp";
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
function iana(tz) {
|
|
138
|
+
try {
|
|
139
|
+
Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
140
|
+
return true;
|
|
141
|
+
} catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function bucketDecode(group) {
|
|
146
|
+
if (group.clock || !group.column.dataType.startsWith("timestamptz"))
|
|
147
|
+
return group.column.decode;
|
|
148
|
+
return decodeDay;
|
|
149
|
+
}
|
|
150
|
+
function decodeDay(wire) {
|
|
151
|
+
const temporal = globalThis.Temporal;
|
|
152
|
+
if (typeof temporal !== "object" || temporal === null || !("PlainDate" in temporal)) {
|
|
153
|
+
return fail2("OKM1120", "Date and time codecs need the Temporal global. okmodel does not ship a polyfill. Use a runtime that provides Temporal, or assign a polyfill to globalThis.Temporal before using these columns.");
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
return temporal.PlainDate.from(wire);
|
|
157
|
+
} catch {
|
|
158
|
+
return fail2("OKM1120", `date ${wire} must be YYYY-MM-DD.`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var ZONE = "\x00";
|
|
162
|
+
function emitClock(sink, group) {
|
|
163
|
+
const column = `t.${quote(group.column.sql)}`;
|
|
164
|
+
const wrapped = projectExpr(`date_trunc('${group.unit}', ${column}, ${ZONE})`, "timestamptz");
|
|
165
|
+
const at = wrapped.indexOf(ZONE);
|
|
166
|
+
sink.text(wrapped.slice(0, at));
|
|
167
|
+
sink.param(group.tz ?? "");
|
|
168
|
+
sink.text(wrapped.slice(at + ZONE.length));
|
|
169
|
+
}
|
|
170
|
+
function emitCalendar(sink, group) {
|
|
171
|
+
const column = `t.${quote(group.column.sql)}`;
|
|
172
|
+
sink.text("(date_trunc('");
|
|
173
|
+
sink.text(group.unit);
|
|
174
|
+
sink.text("', ");
|
|
175
|
+
emitLocal(sink, column, group.tz);
|
|
176
|
+
if (group.shift === 0) {
|
|
177
|
+
sink.text("))::date");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const days = group.shift === 1 ? "1 day" : "2 days";
|
|
181
|
+
sink.text(" + interval '");
|
|
182
|
+
sink.text(days);
|
|
183
|
+
sink.text("') - interval '");
|
|
184
|
+
sink.text(days);
|
|
185
|
+
sink.text("')::date");
|
|
186
|
+
}
|
|
187
|
+
function emitLocal(sink, column, tz) {
|
|
188
|
+
if (tz === undefined) {
|
|
189
|
+
sink.text(column);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
sink.text("(");
|
|
193
|
+
sink.text(column);
|
|
194
|
+
sink.text(" AT TIME ZONE ");
|
|
195
|
+
sink.param(tz);
|
|
196
|
+
sink.text(")");
|
|
197
|
+
}
|
|
198
|
+
function ordinals(count) {
|
|
199
|
+
const parts = [];
|
|
200
|
+
for (let index = 1;index <= count; index += 1)
|
|
201
|
+
parts.push(String(index));
|
|
202
|
+
return parts.join(", ");
|
|
203
|
+
}
|
|
204
|
+
export {
|
|
205
|
+
readBucket,
|
|
206
|
+
writeBucket,
|
|
207
|
+
writeGrouped
|
|
208
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encodeUuid,
|
|
3
3
|
decodeUuid
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./hyh73qk6.js";
|
|
5
5
|
import {
|
|
6
6
|
encodeText,
|
|
7
7
|
decodeText
|
|
@@ -77,7 +77,7 @@ function viewClient(name, columns, query, tenancy, refresh = "plain") {
|
|
|
77
77
|
}
|
|
78
78
|
function refreshHandle(session, name, mode) {
|
|
79
79
|
const concurrently = mode === "concurrently";
|
|
80
|
-
return () => lazyRefresh(() => import("./
|
|
80
|
+
return () => lazyRefresh(() => import("./z7s6fpxv.js").then((mod) => mod.refreshView(session, name, concurrently)));
|
|
81
81
|
}
|
|
82
82
|
function lazyRefresh(run) {
|
|
83
83
|
let pending;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 "./1w508jbr.js";
|
|
19
|
+
import"./mss6ctgv.js";
|
|
20
|
+
export {
|
|
21
|
+
Sql2 as Sql,
|
|
22
|
+
WRITE_PARAM_BUDGET2 as WRITE_PARAM_BUDGET,
|
|
23
|
+
allowSet2 as allowSet,
|
|
24
|
+
emitSet2 as emitSet,
|
|
25
|
+
executeWrite2 as executeWrite,
|
|
26
|
+
expectOf2 as expectOf,
|
|
27
|
+
explainWrite2 as explainWrite,
|
|
28
|
+
noteGuarded2 as noteGuarded,
|
|
29
|
+
readClaim2 as readClaim,
|
|
30
|
+
rejectDuplicateTargets2 as rejectDuplicateTargets,
|
|
31
|
+
rejectMixedSets2 as rejectMixedSets,
|
|
32
|
+
rejectUpdateKeys2 as rejectUpdateKeys,
|
|
33
|
+
requireFilter2 as requireFilter,
|
|
34
|
+
returningOption2 as returningOption,
|
|
35
|
+
updateSliceBody2 as updateSliceBody,
|
|
36
|
+
writeSet2 as writeSet
|
|
37
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isConnectionSqlstate,
|
|
3
3
|
isConnectionFailure
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./cnkky55j.js";
|
|
5
5
|
import {
|
|
6
6
|
OkmError2,
|
|
7
7
|
stripRowValues,
|
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
} from "./52szzakm.js";
|
|
10
10
|
|
|
11
11
|
// src/dialects/pg/errors.ts
|
|
12
|
-
function
|
|
12
|
+
function mapPostgresError(error, options) {
|
|
13
13
|
if (error instanceof OkmError2)
|
|
14
14
|
return error;
|
|
15
15
|
if (!isDriverError(error))
|
|
16
16
|
return OkmError2.from(error);
|
|
17
|
+
const search = searchInputError(error);
|
|
18
|
+
if (search !== undefined)
|
|
19
|
+
return search;
|
|
17
20
|
const kind = kindOf(error);
|
|
18
21
|
const columns = columnsOf(error);
|
|
19
22
|
const hint = hintOf(error, kind);
|
|
@@ -45,6 +48,36 @@ function isDriverError(error) {
|
|
|
45
48
|
return false;
|
|
46
49
|
return "batchIndex" in error;
|
|
47
50
|
}
|
|
51
|
+
function searchQuery(error) {
|
|
52
|
+
const cause = error.cause;
|
|
53
|
+
if (typeof cause !== "object" || cause === null)
|
|
54
|
+
return false;
|
|
55
|
+
const query = Reflect.get(cause, "query");
|
|
56
|
+
return typeof query === "string" && query.includes("to_tsquery");
|
|
57
|
+
}
|
|
58
|
+
function searchInputError(error) {
|
|
59
|
+
const sqlstate = error.sqlstate;
|
|
60
|
+
const message = error.message;
|
|
61
|
+
if (sqlstate === "42601" && (message.includes("tsquery") || searchQuery(error))) {
|
|
62
|
+
return new OkmError2("OKM1120", `Search input is not valid. ${stripRowValues(message)}`, {
|
|
63
|
+
kind: "invalid",
|
|
64
|
+
sqlstate,
|
|
65
|
+
cause: error.cause ?? error,
|
|
66
|
+
fix: { summary: "Fix the advanced search text, or use natural, all-words, or phrase." }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (sqlstate === "42704" && message.includes("text search configuration") && message.includes("does not exist")) {
|
|
70
|
+
return new OkmError2("OKM1122", stripRowValues(message), {
|
|
71
|
+
kind: "invalid",
|
|
72
|
+
sqlstate,
|
|
73
|
+
cause: error.cause ?? error,
|
|
74
|
+
fix: {
|
|
75
|
+
summary: "Use a text search configuration that exists, such as english, or omit language."
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
48
81
|
function kindOf(error) {
|
|
49
82
|
if (error.kind === "timeout" || error.kind === "cancelled" || error.kind === "outcome_unknown") {
|
|
50
83
|
return error.kind;
|
|
@@ -370,5 +403,6 @@ function labelOf(kind) {
|
|
|
370
403
|
return "Driver error";
|
|
371
404
|
}
|
|
372
405
|
}
|
|
373
|
-
|
|
374
|
-
|
|
406
|
+
export {
|
|
407
|
+
mapPostgresError
|
|
408
|
+
};
|