okmodel 0.1.1 → 0.3.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 +727 -37
- package/dist/adapters/capabilities.d.ts +34 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +17 -0
- package/dist/adapters/pg/bunsql.d.ts +60 -0
- package/dist/adapters/pg/call.d.ts +2 -12
- package/dist/adapters/pg/nodepostgres-extra.d.ts +18 -0
- package/dist/adapters/pg/nodepostgres.d.ts +57 -0
- package/dist/adapters/pg/postgres-extra.d.ts +50 -1
- package/dist/adapters/pg/postgresjs.d.ts +0 -4
- package/dist/adapters/pg/session.d.ts +94 -0
- package/dist/adapters/pg/watch.d.ts +18 -0
- package/dist/contracts/catalog/enum.d.ts +31 -4
- package/dist/contracts/catalog/extension.d.ts +61 -0
- package/dist/contracts/catalog/object.d.ts +1 -0
- package/dist/contracts/catalog/privilege.d.ts +64 -0
- package/dist/contracts/catalog/routine.d.ts +56 -0
- package/dist/contracts/catalog/types.d.ts +179 -18
- package/dist/contracts/catalog/view.d.ts +73 -0
- package/dist/contracts/connection.d.ts +13 -0
- package/dist/contracts/driver.d.ts +18 -5
- package/dist/contracts/error.d.ts +17 -1
- package/dist/contracts/generator.d.ts +63 -0
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/internal.js +11 -9
- package/dist/contracts/location.d.ts +24 -0
- package/dist/contracts/rows.d.ts +15 -0
- package/dist/dialects/pg/archive-bind.d.ts +22 -0
- package/dist/dialects/pg/column.d.ts +129 -10
- package/dist/dialects/pg/compile.d.ts +1 -0
- package/dist/dialects/pg/custom.d.ts +6 -0
- package/dist/dialects/pg/ddl.d.ts +65 -1
- package/dist/dialects/pg/enum.d.ts +10 -8
- package/dist/dialects/pg/ext/citext.d.ts +14 -0
- package/dist/dialects/pg/ext/citext.js +11 -0
- package/dist/dialects/pg/ext/index.d.ts +52 -0
- package/dist/dialects/pg/ext/index.js +6 -0
- package/dist/dialects/pg/ext/pg-trgm.d.ts +53 -0
- package/dist/dialects/pg/ext/pg-trgm.js +42 -0
- package/dist/dialects/pg/filter-parse.d.ts +19 -0
- package/dist/dialects/pg/filters.d.ts +19 -0
- package/dist/dialects/pg/fn/index.d.ts +107 -0
- package/dist/dialects/pg/fn/index.js +175 -0
- package/dist/dialects/pg/fn/touch.d.ts +14 -0
- package/dist/dialects/pg/index.d.ts +11 -2
- package/dist/dialects/pg/index.js +243 -1062
- package/dist/dialects/pg/introspect.d.ts +10 -1
- package/dist/dialects/pg/keys.d.ts +19 -3
- package/dist/dialects/pg/model.d.ts +223 -2
- package/dist/dialects/pg/operator-fit.d.ts +86 -0
- package/dist/dialects/pg/operators.d.ts +46 -1
- package/dist/dialects/pg/ops/arr-append.d.ts +9 -0
- package/dist/dialects/pg/ops/arr-ns.d.ts +7 -0
- package/dist/dialects/pg/ops/arr-remove.d.ts +9 -0
- package/dist/dialects/pg/ops/containedBy.d.ts +9 -0
- package/dist/dialects/pg/ops/contains.d.ts +8 -4
- package/dist/dialects/pg/ops/hasAnyKey.d.ts +8 -0
- package/dist/dialects/pg/ops/hasKey.d.ts +8 -0
- package/dist/dialects/pg/ops/json-ns.d.ts +6 -0
- package/dist/dialects/pg/ops/json-set.d.ts +12 -0
- package/dist/dialects/pg/ops/matches.d.ts +16 -0
- package/dist/dialects/pg/ops/overlaps.d.ts +9 -0
- package/dist/dialects/pg/ops/path.d.ts +13 -0
- package/dist/dialects/pg/preset.d.ts +76 -0
- package/dist/dialects/pg/relations.d.ts +59 -2
- package/dist/dialects/pg/role/check.d.ts +45 -0
- package/dist/dialects/pg/role/index.d.ts +50 -0
- package/dist/dialects/pg/role/sql.d.ts +44 -0
- package/dist/dialects/pg/schema.d.ts +109 -5
- package/dist/dialects/pg/table.d.ts +137 -11
- package/dist/dialects/pg/temporal.d.ts +9 -7
- package/dist/dialects/pg/tenancy.d.ts +103 -0
- package/dist/dialects/pg/through.d.ts +21 -0
- package/dist/dialects/pg/trait.d.ts +141 -0
- package/dist/dialects/pg/view/client.d.ts +30 -0
- package/dist/dialects/pg/view/depend.d.ts +35 -0
- package/dist/dialects/pg/view/index.d.ts +114 -0
- package/dist/dialects/pg/view/index.js +289 -0
- package/dist/dialects/pg/view/scratch.d.ts +21 -0
- package/dist/dialects/pg/where.d.ts +37 -0
- package/dist/runtime/aggregate.d.ts +25 -0
- package/dist/runtime/archive-handle.d.ts +18 -0
- package/dist/runtime/archive-rules.d.ts +12 -0
- package/dist/runtime/archive.d.ts +73 -0
- package/dist/runtime/batch.d.ts +20 -0
- package/dist/runtime/client.d.ts +114 -5
- package/dist/runtime/conflict.d.ts +2 -1
- package/dist/runtime/exposure.d.ts +27 -0
- package/dist/runtime/hookm.d.ts +39 -0
- package/dist/runtime/ids/index.d.ts +11 -0
- package/dist/runtime/ids/index.js +193 -0
- package/dist/runtime/ids/okid-extended.d.ts +19 -0
- package/dist/runtime/ids/okid-generator.d.ts +21 -0
- package/dist/runtime/ids/okid-shared.d.ts +89 -0
- package/dist/runtime/ids/okid.d.ts +24 -0
- package/dist/runtime/ids/uuid.d.ts +21 -0
- package/dist/runtime/lock.d.ts +22 -0
- package/dist/runtime/operator-sql.d.ts +8 -0
- package/dist/runtime/page.d.ts +25 -0
- package/dist/runtime/pg/bun.d.ts +30 -0
- package/dist/runtime/pg/bun.js +52 -0
- package/dist/runtime/pg/pg.d.ts +29 -0
- package/dist/runtime/pg/pg.js +52 -0
- package/dist/runtime/pg/pglite.js +16 -17
- package/dist/runtime/pg/postgresjs.js +14 -24
- package/dist/runtime/plan.d.ts +146 -7
- package/dist/runtime/preset-stack.d.ts +17 -0
- package/dist/runtime/presets.d.ts +48 -0
- package/dist/runtime/read-stream.d.ts +26 -0
- package/dist/runtime/safety/index.d.ts +159 -0
- package/dist/runtime/safety/index.js +294 -0
- package/dist/runtime/safety-hook.d.ts +42 -0
- package/dist/runtime/server-check.d.ts +34 -0
- package/dist/runtime/tenancy/index.d.ts +37 -0
- package/dist/runtime/tenancy/index.js +368 -0
- package/dist/runtime/trait-read.d.ts +30 -0
- package/dist/runtime/traits/index.d.ts +133 -0
- package/dist/runtime/traits/index.js +646 -0
- package/dist/runtime/transaction.d.ts +19 -0
- package/dist/runtime/tx.d.ts +22 -7
- package/dist/runtime/types.d.ts +376 -27
- package/dist/runtime/validate/bind.d.ts +11 -0
- package/dist/runtime/validate/closed.d.ts +16 -0
- package/dist/runtime/validate/engine.d.ts +41 -0
- package/dist/runtime/validate/hook.d.ts +17 -0
- package/dist/runtime/validate/index.d.ts +21 -0
- package/dist/runtime/validate/index.js +175 -0
- package/dist/runtime/validate/load.d.ts +13 -0
- package/dist/runtime/validate/places.d.ts +41 -0
- package/dist/runtime/validate/rules.d.ts +108 -0
- package/dist/runtime/validate/surface.d.ts +102 -0
- package/dist/runtime/write.d.ts +30 -5
- package/dist/shared/01yr20s5.js +149 -0
- package/dist/shared/0jc3ffzf.js +154 -0
- package/dist/shared/0v1g424p.js +26 -0
- package/dist/shared/1g0drakv.js +225 -0
- package/dist/shared/{kprcwaha.js → 1tfdfvhh.js} +5 -3
- package/dist/shared/{05w44d8g.js → 2ssqrv66.js} +767 -715
- package/dist/shared/3ekj9x92.js +210 -0
- package/dist/shared/49ypnfwt.js +1122 -0
- package/dist/shared/4e4c6vq2.js +62 -0
- package/dist/shared/4m9fn52z.js +70 -0
- package/dist/shared/{ycwz42az.js → 52szzakm.js} +6 -26
- package/dist/shared/5nmdenb6.js +1229 -0
- package/dist/shared/672t5vym.js +12 -0
- package/dist/shared/6bazvqwm.js +86 -0
- package/dist/shared/6w5j844a.js +201 -0
- package/dist/shared/{fgqgsb5z.js → 75xkjv0t.js} +2 -2
- package/dist/shared/7fvtrkwr.js +84 -0
- package/dist/shared/7m88x3e9.js +45 -0
- package/dist/shared/{mtkwv8wx.js → 7p2wbz7f.js} +1 -1
- package/dist/shared/83eaefwr.js +10 -0
- package/dist/shared/94ez8kzh.js +19 -0
- package/dist/shared/96ps4g1z.js +32 -0
- package/dist/shared/{xqbhg6cn.js → 999ade2q.js} +95 -10
- package/dist/shared/9m80mkac.js +158 -0
- package/dist/shared/9x25fxhc.js +150 -0
- package/dist/shared/a5sxz52y.js +13 -0
- package/dist/shared/axhk06q1.js +156 -0
- package/dist/shared/{dynq16vb.js → b066g80h.js} +8 -6
- package/dist/shared/bqha5cg6.js +229 -0
- package/dist/shared/bryqk9k9.js +31 -0
- package/dist/shared/c8aghh05.js +442 -0
- package/dist/shared/c9z5g0fm.js +309 -0
- package/dist/shared/{m3ypagh5.js → dbjej1tw.js} +124 -15
- package/dist/shared/dyj86cmj.js +69 -0
- package/dist/shared/e6wg00wd.js +164 -0
- package/dist/shared/{hadrfb9h.js → edwqqryd.js} +17 -14
- package/dist/shared/{qk3hxfja.js → fptpmvxp.js} +5 -5
- package/dist/shared/fs0ex00p.js +76 -0
- package/dist/shared/{jjb7yht9.js → g4f5kcx9.js} +3 -3
- package/dist/shared/gjthds9j.js +48 -0
- package/dist/shared/hcmdtwgh.js +102 -0
- package/dist/shared/{g5fhqmwe.js → jkc6ws1p.js} +6 -56
- package/dist/shared/{yd1kzwn2.js → jns2wx4t.js} +55 -12
- package/dist/shared/k34e0xf2.js +450 -0
- package/dist/shared/k3ted12y.js +33 -0
- package/dist/shared/k7dwkhvq.js +31 -0
- package/dist/shared/{8b04d28c.js → kgnc8grt.js} +2 -2
- package/dist/shared/{hd293j9g.js → kyxb62mc.js} +14 -2
- package/dist/shared/m78s7898.js +376 -0
- package/dist/shared/m9tv7xn7.js +404 -0
- package/dist/shared/meck53jv.js +99 -0
- package/dist/shared/mt5wswjz.js +90 -0
- package/dist/shared/n0dgs0pb.js +75 -0
- package/dist/shared/n442h54c.js +14 -0
- package/dist/shared/n4jqhpqz.js +27 -0
- package/dist/shared/n7mcc1gk.js +132 -0
- package/dist/shared/ne02ng5c.js +68 -0
- package/dist/shared/{mkjmqjv4.js → nfzc5z0w.js} +2 -104
- package/dist/shared/nsva2a6b.js +42 -0
- package/dist/shared/p24x2334.js +195 -0
- package/dist/shared/qbxzvwwc.js +88 -0
- package/dist/shared/{w8samvk1.js → qybh48nd.js} +1 -1
- package/dist/shared/r6nwkxnt.js +86 -0
- package/dist/shared/{xy79j5hq.js → rrstp3kb.js} +25 -36
- package/dist/shared/rwmrejjz.js +26 -0
- package/dist/shared/{zhc5vmgf.js → s6gqfn5j.js} +2 -2
- package/dist/shared/{523ft3e8.js → scwxrpx2.js} +7 -5
- package/dist/shared/{j5cn2963.js → t4tbsy9h.js} +13 -64
- package/dist/shared/{y9m15dfv.js → t616ynfn.js} +544 -32
- package/dist/shared/{ngk8gj61.js → tbszx8mz.js} +15 -1
- package/dist/shared/th14ygv2.js +69 -0
- package/dist/shared/tmbdywx0.js +178 -0
- package/dist/shared/ty3v3hfk.js +64 -0
- package/dist/shared/wekze34d.js +246 -0
- package/dist/shared/x6wysh83.js +1132 -0
- package/dist/shared/{rgs0st28.js → xrfnq5k8.js} +237 -434
- package/dist/shared/{x5x59srr.js → xva8v7qk.js} +416 -83
- package/dist/shared/{dkn3y60a.js → xw1d69vd.js} +76 -112
- package/dist/shared/y005b761.js +112 -0
- package/dist/shared/ydaz1sv3.js +55 -0
- package/dist/shared/{p0cbr3g2.js → zwmqxb0g.js} +1 -1
- package/dist/tooling/cli.js +40 -12
- package/dist/tooling/migrate/apply.d.ts +16 -0
- package/dist/tooling/migrate/commands.d.ts +12 -1
- package/dist/tooling/migrate/config.d.ts +8 -0
- package/dist/tooling/migrate/doctor.d.ts +25 -0
- package/dist/tooling/migrate/drift.d.ts +19 -0
- package/dist/tooling/migrate/engine.d.ts +36 -0
- package/dist/tooling/migrate/ext.d.ts +17 -0
- package/dist/tooling/migrate/extensions.d.ts +51 -0
- package/dist/tooling/migrate/managed.d.ts +17 -0
- package/dist/tooling/migrate/plan.d.ts +14 -1
- package/dist/tooling/migrate/project.d.ts +25 -1
- package/dist/tooling/migrate/type-name.d.ts +19 -0
- package/package.json +61 -4
- package/dist/shared/gk7cs7sp.js +0 -566
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stack
|
|
3
|
+
} from "./672t5vym.js";
|
|
4
|
+
import {
|
|
5
|
+
checkPresetNames
|
|
6
|
+
} from "./nsva2a6b.js";
|
|
7
|
+
import {
|
|
8
|
+
isOperator,
|
|
9
|
+
operatorValue
|
|
10
|
+
} from "./cn0n68ft.js";
|
|
11
|
+
import {
|
|
12
|
+
OkmError2
|
|
13
|
+
} from "./52szzakm.js";
|
|
14
|
+
|
|
15
|
+
// src/runtime/presets.ts
|
|
16
|
+
function checkSchema(schema) {
|
|
17
|
+
for (const name in schema.model) {
|
|
18
|
+
const presets = schema.model[name]?.presets;
|
|
19
|
+
if (presets !== undefined)
|
|
20
|
+
checkPresetNames(Object.keys(presets), `table ${name}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function resolve(schema, table, uses) {
|
|
24
|
+
const model = schema.model[table];
|
|
25
|
+
const known = model?.presets ?? {};
|
|
26
|
+
const chain = [];
|
|
27
|
+
for (let use = uses;use !== undefined; use = use[0])
|
|
28
|
+
chain.unshift(use);
|
|
29
|
+
const wheres = [];
|
|
30
|
+
const rules = [];
|
|
31
|
+
for (const [, name, args] of chain) {
|
|
32
|
+
const preset = known[name];
|
|
33
|
+
if (typeof preset !== "function") {
|
|
34
|
+
throw new OkmError2("OKM1120", `Table ${table} has no preset ${name}.`, {
|
|
35
|
+
fix: { summary: `Use one of: ${Object.keys(known).join(", ")}.` }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const added = [];
|
|
39
|
+
const q = {
|
|
40
|
+
where(filter) {
|
|
41
|
+
added.push(filter);
|
|
42
|
+
return q;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
if (preset(q, ...args) !== q) {
|
|
46
|
+
throw new OkmError2("OKM1121", `Preset ${name} on ${table} must return the builder it was given.`, { fix: { summary: "Return q, as in (q) => q.where({ ... })." } });
|
|
47
|
+
}
|
|
48
|
+
for (const filter of added)
|
|
49
|
+
wheres.push(filter);
|
|
50
|
+
rules.push({
|
|
51
|
+
rule: "preset",
|
|
52
|
+
contribution: `${name} filters ${[...new Set(added.flatMap(fieldsOf))].join(", ") || "nothing"}`,
|
|
53
|
+
provenance: ownerOf(model, name, table),
|
|
54
|
+
...model?.source !== undefined ? { source: model.source } : {}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return { wheres, rules };
|
|
58
|
+
}
|
|
59
|
+
function refine(schema, call, uses) {
|
|
60
|
+
const { wheres, rules } = resolve(schema, call.table, uses);
|
|
61
|
+
return {
|
|
62
|
+
...call,
|
|
63
|
+
where: stack(call.where, wheres),
|
|
64
|
+
ruleLines: [...call.ruleLines ?? [], ...rules]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function ownerOf(model, name, table) {
|
|
68
|
+
for (const trait of model?.traits ?? []) {
|
|
69
|
+
const presets = trait.presets;
|
|
70
|
+
if (presets !== undefined && Object.hasOwn(presets, name))
|
|
71
|
+
return `trait ${trait.name}`;
|
|
72
|
+
}
|
|
73
|
+
return `table ${table}`;
|
|
74
|
+
}
|
|
75
|
+
function fieldsOf(filter) {
|
|
76
|
+
if (isOperator(filter)) {
|
|
77
|
+
const branches = operatorValue(filter);
|
|
78
|
+
return Array.isArray(branches) ? branches.flatMap(fieldsOf) : [];
|
|
79
|
+
}
|
|
80
|
+
return typeof filter === "object" && filter !== null ? Object.keys(filter) : [];
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
checkSchema,
|
|
84
|
+
refine,
|
|
85
|
+
resolve
|
|
86
|
+
};
|
|
@@ -15,6 +15,22 @@ var PGLITE_CAPABILITIES = {
|
|
|
15
15
|
prepared: "unnamed",
|
|
16
16
|
describe: true
|
|
17
17
|
};
|
|
18
|
+
var NODE_POSTGRES_CAPABILITIES = {
|
|
19
|
+
transactions: "interactive",
|
|
20
|
+
stream: true,
|
|
21
|
+
listen: true,
|
|
22
|
+
cancel: true,
|
|
23
|
+
prepared: "unnamed",
|
|
24
|
+
describe: false
|
|
25
|
+
};
|
|
26
|
+
var BUNSQL_CAPABILITIES = {
|
|
27
|
+
transactions: "interactive",
|
|
28
|
+
stream: true,
|
|
29
|
+
listen: true,
|
|
30
|
+
cancel: false,
|
|
31
|
+
prepared: "unnamed",
|
|
32
|
+
describe: false
|
|
33
|
+
};
|
|
18
34
|
function readCapability2(flags, name) {
|
|
19
35
|
return flags[name];
|
|
20
36
|
}
|
|
@@ -25,7 +41,7 @@ function hasCapability2(flags, name) {
|
|
|
25
41
|
// src/adapters/failure.ts
|
|
26
42
|
var loading;
|
|
27
43
|
function driverErrors() {
|
|
28
|
-
loading ??= import("./
|
|
44
|
+
loading ??= import("./7p2wbz7f.js");
|
|
29
45
|
return loading;
|
|
30
46
|
}
|
|
31
47
|
function rejectClosed(message = "The pool is closed.") {
|
|
@@ -48,9 +64,8 @@ function needsWatch(options) {
|
|
|
48
64
|
}
|
|
49
65
|
function nextTransactionDepth(depth, text) {
|
|
50
66
|
const command = text.trim().replace(/;\s*$/, "").trim().toLowerCase();
|
|
51
|
-
if (
|
|
67
|
+
if (/^(?:begin|start transaction)(?:\s|$)/.test(command))
|
|
52
68
|
return depth + 1;
|
|
53
|
-
}
|
|
54
69
|
if (command === "commit" || command === "commit work" || command === "end") {
|
|
55
70
|
return Math.max(0, depth - 1);
|
|
56
71
|
}
|
|
@@ -58,35 +73,6 @@ function nextTransactionDepth(depth, text) {
|
|
|
58
73
|
return 0;
|
|
59
74
|
return depth;
|
|
60
75
|
}
|
|
61
|
-
function openWatch(options) {
|
|
62
|
-
let kind;
|
|
63
|
-
const controller = new AbortController;
|
|
64
|
-
const onAbort = () => {
|
|
65
|
-
if (kind === undefined)
|
|
66
|
-
kind = "cancelled";
|
|
67
|
-
controller.abort();
|
|
68
|
-
};
|
|
69
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
70
|
-
let timer;
|
|
71
|
-
if (options.timeout !== undefined) {
|
|
72
|
-
timer = setTimeout(() => {
|
|
73
|
-
if (kind === undefined)
|
|
74
|
-
kind = "timeout";
|
|
75
|
-
controller.abort();
|
|
76
|
-
}, options.timeout);
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
signal: controller.signal,
|
|
80
|
-
finish() {
|
|
81
|
-
if (timer !== undefined)
|
|
82
|
-
clearTimeout(timer);
|
|
83
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
84
|
-
},
|
|
85
|
-
reason() {
|
|
86
|
-
return kind;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
76
|
function runCall(closed, options, fn) {
|
|
91
77
|
if (closed)
|
|
92
78
|
return rejectClosed();
|
|
@@ -96,9 +82,12 @@ function runCall(closed, options, fn) {
|
|
|
96
82
|
return rejectTimedOut();
|
|
97
83
|
if (options === undefined || !needsWatch(options))
|
|
98
84
|
return fn(undefined);
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
watch
|
|
85
|
+
const watched = options;
|
|
86
|
+
return import("./k3ted12y.js").then(({ openWatch }) => {
|
|
87
|
+
const watch = openWatch(watched);
|
|
88
|
+
return fn(watch).finally(() => {
|
|
89
|
+
watch.finish();
|
|
90
|
+
});
|
|
102
91
|
});
|
|
103
92
|
}
|
|
104
93
|
|
|
@@ -174,4 +163,4 @@ function countFrom(value, rows) {
|
|
|
174
163
|
return rows;
|
|
175
164
|
}
|
|
176
165
|
|
|
177
|
-
export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
|
|
166
|
+
export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, NODE_POSTGRES_CAPABILITIES, BUNSQL_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/contracts/generator.ts
|
|
2
|
+
var CLIENT_DEFAULT = Symbol.for("okmodel.clientDefault");
|
|
3
|
+
function clientGenerator(call, name, options) {
|
|
4
|
+
const marked = call;
|
|
5
|
+
Object.defineProperty(marked, CLIENT_DEFAULT, {
|
|
6
|
+
value: options === undefined ? { label: "client", name } : { label: "client", name, options },
|
|
7
|
+
enumerable: false
|
|
8
|
+
});
|
|
9
|
+
return marked;
|
|
10
|
+
}
|
|
11
|
+
function readClientGenerator(value) {
|
|
12
|
+
if (typeof value !== "function")
|
|
13
|
+
return;
|
|
14
|
+
const mark = value[CLIENT_DEFAULT];
|
|
15
|
+
if (isMark(mark))
|
|
16
|
+
return { label: "client", name: mark.name, call: value };
|
|
17
|
+
return { label: "client", name: "function", call: value };
|
|
18
|
+
}
|
|
19
|
+
function isMark(value) {
|
|
20
|
+
if (typeof value !== "object" || value === null)
|
|
21
|
+
return false;
|
|
22
|
+
const name = value.name;
|
|
23
|
+
return value.label === "client" && typeof name === "string" && name !== "function";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { clientGenerator, readClientGenerator };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isConnectionSqlstate,
|
|
3
3
|
isConnectionFailure
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./tbszx8mz.js";
|
|
5
5
|
import {
|
|
6
6
|
OkmError2,
|
|
7
7
|
stripRowValues,
|
|
8
8
|
matchingParen
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./52szzakm.js";
|
|
10
10
|
|
|
11
11
|
// src/dialects/pg/errors.ts
|
|
12
12
|
function mapPostgresError(error, options) {
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
open2
|
|
3
|
-
} from "./
|
|
4
|
-
import"./
|
|
3
|
+
} from "./xw1d69vd.js";
|
|
4
|
+
import"./t616ynfn.js";
|
|
5
|
+
import"./n442h54c.js";
|
|
5
6
|
import {
|
|
6
7
|
loadMigrations
|
|
7
|
-
} from "./
|
|
8
|
+
} from "./g4f5kcx9.js";
|
|
8
9
|
import {
|
|
9
10
|
assertTargetPolicy,
|
|
10
11
|
listTargets,
|
|
11
12
|
loadConfig
|
|
12
|
-
} from "./
|
|
13
|
+
} from "./5nmdenb6.js";
|
|
14
|
+
import"./2ssqrv66.js";
|
|
13
15
|
import {
|
|
14
16
|
OkmError2
|
|
15
|
-
} from "./
|
|
17
|
+
} from "./52szzakm.js";
|
|
16
18
|
|
|
17
19
|
// src/tooling/migrate/status.ts
|
|
18
20
|
import { join } from "node:path";
|
|
@@ -1,73 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
referentialAction
|
|
3
|
+
} from "./4e4c6vq2.js";
|
|
1
4
|
import {
|
|
2
5
|
assertIdentifier2,
|
|
3
6
|
fitIdentifier2,
|
|
4
7
|
deterministicName2,
|
|
5
8
|
assertStoredText
|
|
6
|
-
} from "./
|
|
9
|
+
} from "./nfzc5z0w.js";
|
|
7
10
|
import {
|
|
8
11
|
catalogError2
|
|
9
|
-
} from "./
|
|
10
|
-
|
|
11
|
-
// src/contracts/catalog/types.ts
|
|
12
|
-
var OWNERS2 = ["managed", "external", "ignored"];
|
|
13
|
-
var OBJECT_KINDS2 = [
|
|
14
|
-
"table",
|
|
15
|
-
"column",
|
|
16
|
-
"index",
|
|
17
|
-
"constraint",
|
|
18
|
-
"sequence",
|
|
19
|
-
"view",
|
|
20
|
-
"materializedView",
|
|
21
|
-
"type",
|
|
22
|
-
"function",
|
|
23
|
-
"trigger",
|
|
24
|
-
"policy",
|
|
25
|
-
"extension",
|
|
26
|
-
"role",
|
|
27
|
-
"grant",
|
|
28
|
-
"defaultPrivilege"
|
|
29
|
-
];
|
|
30
|
-
var BUILT_KINDS2 = ["table", "column", "index", "constraint", "sequence", "type"];
|
|
31
|
-
var OBJECT_OPERATIONS2 = [
|
|
32
|
-
"create",
|
|
33
|
-
"replace",
|
|
34
|
-
"alter",
|
|
35
|
-
"drop",
|
|
36
|
-
"recreateWithDependents"
|
|
37
|
-
];
|
|
38
|
-
var KIND_OPERATIONS2 = {
|
|
39
|
-
table: ["create", "alter", "drop", "recreateWithDependents"],
|
|
40
|
-
column: ["create", "alter", "drop", "recreateWithDependents"],
|
|
41
|
-
index: ["create", "drop", "recreateWithDependents"],
|
|
42
|
-
constraint: ["create", "alter", "drop", "recreateWithDependents"],
|
|
43
|
-
sequence: ["create", "alter", "drop"],
|
|
44
|
-
view: ["create", "replace", "drop", "recreateWithDependents"],
|
|
45
|
-
materializedView: ["create", "drop", "recreateWithDependents"],
|
|
46
|
-
type: ["create", "alter", "drop"],
|
|
47
|
-
function: ["create", "replace", "drop", "recreateWithDependents"],
|
|
48
|
-
trigger: ["create", "drop", "recreateWithDependents"],
|
|
49
|
-
policy: ["create", "alter", "drop"],
|
|
50
|
-
extension: ["create", "alter", "drop"],
|
|
51
|
-
role: ["create", "alter"],
|
|
52
|
-
grant: ["create", "drop"],
|
|
53
|
-
defaultPrivilege: ["create", "alter", "drop"]
|
|
54
|
-
};
|
|
55
|
-
var REFERENTIAL_ACTIONS = [
|
|
56
|
-
"cascade",
|
|
57
|
-
"no action",
|
|
58
|
-
"restrict",
|
|
59
|
-
"set default",
|
|
60
|
-
"set null"
|
|
61
|
-
];
|
|
62
|
-
function referentialAction(value) {
|
|
63
|
-
for (const action of REFERENTIAL_ACTIONS) {
|
|
64
|
-
if (action === value) {
|
|
65
|
-
return action;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
var CATALOG_VERSION2 = 1;
|
|
12
|
+
} from "./52szzakm.js";
|
|
71
13
|
|
|
72
14
|
// src/contracts/catalog/json.ts
|
|
73
15
|
function canonicalJson(value) {
|
|
@@ -431,6 +373,12 @@ function column2(input) {
|
|
|
431
373
|
if (input.defaultExpression !== undefined) {
|
|
432
374
|
assertStoredText(input.defaultExpression, "column default");
|
|
433
375
|
}
|
|
376
|
+
if (input.collation !== undefined) {
|
|
377
|
+
assertStoredText(input.collation, "column collation");
|
|
378
|
+
if (input.collation.length === 0) {
|
|
379
|
+
catalogError2("OKM1020", `Column ${input.name} has an empty collation.`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
434
382
|
if (input.generated !== undefined) {
|
|
435
383
|
assertStoredText(input.generated.expression, "column generated expression");
|
|
436
384
|
}
|
|
@@ -443,6 +391,7 @@ function column2(input) {
|
|
|
443
391
|
dataType: input.dataType,
|
|
444
392
|
nullable: input.nullable,
|
|
445
393
|
...input.defaultExpression !== undefined ? { defaultExpression: input.defaultExpression } : {},
|
|
394
|
+
...input.collation !== undefined ? { collation: input.collation } : {},
|
|
446
395
|
...input.identity !== undefined ? { identity: { always: input.identity.always } } : {},
|
|
447
396
|
...input.generated !== undefined ? {
|
|
448
397
|
generated: {
|
|
@@ -698,4 +647,4 @@ function copyPartition(partition) {
|
|
|
698
647
|
return { method: partition.method, columns: [...partition.columns] };
|
|
699
648
|
}
|
|
700
649
|
|
|
701
|
-
export {
|
|
650
|
+
export { canonicalJson, staticNamespace2, templateNamespace2, assertNamespace2, resolveNamespace2, identityKey2, identifierLimitApplies2, identityLabel2, sameRef2, sameNamespace2, identityToJson, namespaceToJson, table3, column2, index3, constraint2, sequence2, normaliseEdges, compareText, assertProvenance };
|