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,62 @@
|
|
|
1
|
+
// src/contracts/catalog/types.ts
|
|
2
|
+
var OWNERS2 = ["managed", "external", "ignored"];
|
|
3
|
+
var OBJECT_KINDS2 = [
|
|
4
|
+
"table",
|
|
5
|
+
"column",
|
|
6
|
+
"index",
|
|
7
|
+
"constraint",
|
|
8
|
+
"sequence",
|
|
9
|
+
"view",
|
|
10
|
+
"materializedView",
|
|
11
|
+
"type",
|
|
12
|
+
"function",
|
|
13
|
+
"trigger",
|
|
14
|
+
"policy",
|
|
15
|
+
"extension",
|
|
16
|
+
"role",
|
|
17
|
+
"grant",
|
|
18
|
+
"defaultPrivilege"
|
|
19
|
+
];
|
|
20
|
+
var BUILT_KINDS2 = ["table", "column", "index", "constraint", "sequence", "type"];
|
|
21
|
+
var OBJECT_OPERATIONS2 = [
|
|
22
|
+
"create",
|
|
23
|
+
"replace",
|
|
24
|
+
"alter",
|
|
25
|
+
"drop",
|
|
26
|
+
"recreateWithDependents"
|
|
27
|
+
];
|
|
28
|
+
var KIND_OPERATIONS2 = {
|
|
29
|
+
table: ["create", "alter", "drop", "recreateWithDependents"],
|
|
30
|
+
column: ["create", "alter", "drop", "recreateWithDependents"],
|
|
31
|
+
index: ["create", "drop", "recreateWithDependents"],
|
|
32
|
+
constraint: ["create", "alter", "drop", "recreateWithDependents"],
|
|
33
|
+
sequence: ["create", "alter", "drop"],
|
|
34
|
+
view: ["create", "replace", "drop", "recreateWithDependents"],
|
|
35
|
+
materializedView: ["create", "drop", "recreateWithDependents"],
|
|
36
|
+
type: ["create", "alter", "drop"],
|
|
37
|
+
function: ["create", "replace", "drop", "recreateWithDependents"],
|
|
38
|
+
trigger: ["create", "drop", "recreateWithDependents"],
|
|
39
|
+
policy: ["create", "alter", "drop"],
|
|
40
|
+
extension: ["create", "alter", "drop"],
|
|
41
|
+
role: ["create", "alter"],
|
|
42
|
+
grant: ["create", "drop"],
|
|
43
|
+
defaultPrivilege: ["create", "alter", "drop"]
|
|
44
|
+
};
|
|
45
|
+
var REFERENTIAL_ACTIONS = [
|
|
46
|
+
"cascade",
|
|
47
|
+
"no action",
|
|
48
|
+
"restrict",
|
|
49
|
+
"set default",
|
|
50
|
+
"set null"
|
|
51
|
+
];
|
|
52
|
+
function referentialAction(value) {
|
|
53
|
+
for (const action of REFERENTIAL_ACTIONS) {
|
|
54
|
+
if (action === value) {
|
|
55
|
+
return action;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var CATALOG_VERSION2 = 1;
|
|
61
|
+
|
|
62
|
+
export { OWNERS2, OBJECT_KINDS2, BUILT_KINDS2, OBJECT_OPERATIONS2, KIND_OPERATIONS2, REFERENTIAL_ACTIONS, referentialAction, CATALOG_VERSION2 };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
required
|
|
3
|
+
} from "./c9z5g0fm.js";
|
|
4
|
+
import {
|
|
5
|
+
definition,
|
|
6
|
+
rejected
|
|
7
|
+
} from "./tmbdywx0.js";
|
|
8
|
+
|
|
9
|
+
// src/dialects/pg/text.ts
|
|
10
|
+
function text2() {
|
|
11
|
+
return required({ baseType: "text", encode: encodeText, decode: decodeText, sqlForm: "quote" });
|
|
12
|
+
}
|
|
13
|
+
function varchar2(length) {
|
|
14
|
+
const limit = boundedLength(length, "varchar");
|
|
15
|
+
return required({
|
|
16
|
+
baseType: `varchar(${String(limit)})`,
|
|
17
|
+
encode: (value) => encodeLimited(value, limit, "varchar"),
|
|
18
|
+
decode: decodeText,
|
|
19
|
+
sqlForm: "quote"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function char2(length) {
|
|
23
|
+
const limit = boundedLength(length, "char");
|
|
24
|
+
return required({
|
|
25
|
+
baseType: `char(${String(limit)})`,
|
|
26
|
+
encode: (value) => encodeLimited(value, limit, "char"),
|
|
27
|
+
decode: decodeText,
|
|
28
|
+
sqlForm: "quote"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function citext2() {
|
|
32
|
+
return required({
|
|
33
|
+
baseType: "citext",
|
|
34
|
+
encode: encodeText,
|
|
35
|
+
decode: decodeText,
|
|
36
|
+
sqlForm: "quote",
|
|
37
|
+
extension: "citext"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function encodeText(value) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
function decodeText(wire) {
|
|
44
|
+
return wire;
|
|
45
|
+
}
|
|
46
|
+
function encodeLimited(value, limit, role) {
|
|
47
|
+
if (characterLength(value) > limit) {
|
|
48
|
+
rejected(`${role} accepts at most ${String(limit)} characters.`);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function boundedLength(length, role) {
|
|
53
|
+
if (!Number.isInteger(length) || length < 1 || length > 10485760) {
|
|
54
|
+
definition(`${role} length ${String(length)} must be an integer from 1 to 10485760.`);
|
|
55
|
+
}
|
|
56
|
+
return length;
|
|
57
|
+
}
|
|
58
|
+
function characterLength(value) {
|
|
59
|
+
let count = 0;
|
|
60
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
61
|
+
const code = value.charCodeAt(index);
|
|
62
|
+
if (code >= 55296 && code <= 56319) {
|
|
63
|
+
index += 1;
|
|
64
|
+
}
|
|
65
|
+
count += 1;
|
|
66
|
+
}
|
|
67
|
+
return count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { text2, varchar2, char2, citext2, encodeText, decodeText };
|
|
@@ -158,6 +158,7 @@ class OkmError2 extends Error {
|
|
|
158
158
|
#fields;
|
|
159
159
|
#values;
|
|
160
160
|
#http;
|
|
161
|
+
issues;
|
|
161
162
|
get summary() {
|
|
162
163
|
return this.message;
|
|
163
164
|
}
|
|
@@ -180,6 +181,8 @@ class OkmError2 extends Error {
|
|
|
180
181
|
this.fieldReason = options?.fieldReason ?? kind;
|
|
181
182
|
this.#values = options?.includeValues === true ? options.values : undefined;
|
|
182
183
|
this.#http = options?.http;
|
|
184
|
+
if (options?.issues !== undefined)
|
|
185
|
+
this.issues = options.issues;
|
|
183
186
|
}
|
|
184
187
|
static from(error) {
|
|
185
188
|
if (error instanceof OkmError2)
|
|
@@ -238,7 +241,8 @@ class OkmError2 extends Error {
|
|
|
238
241
|
...this.table !== undefined ? { table: this.table } : {},
|
|
239
242
|
...this.columns.length > 0 ? { columns: this.columns } : {},
|
|
240
243
|
...this.constraint !== undefined ? { constraint: this.constraint } : {},
|
|
241
|
-
...this.sqlstate !== undefined ? { sqlstate: this.sqlstate } : {}
|
|
244
|
+
...this.sqlstate !== undefined ? { sqlstate: this.sqlstate } : {},
|
|
245
|
+
...this.issues !== undefined ? { issues: this.issues } : {}
|
|
242
246
|
};
|
|
243
247
|
}
|
|
244
248
|
match(handlers) {
|
|
@@ -300,31 +304,7 @@ function kindFromCode(code) {
|
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
306
|
function isErrorKind(code) {
|
|
303
|
-
|
|
304
|
-
case "invalid":
|
|
305
|
-
case "not_null":
|
|
306
|
-
case "check":
|
|
307
|
-
case "foreign_key":
|
|
308
|
-
case "unique":
|
|
309
|
-
case "exclusion":
|
|
310
|
-
case "conflict":
|
|
311
|
-
case "not_found":
|
|
312
|
-
case "not_unique":
|
|
313
|
-
case "forbidden":
|
|
314
|
-
case "serialization":
|
|
315
|
-
case "deadlock":
|
|
316
|
-
case "lock_timeout":
|
|
317
|
-
case "timeout":
|
|
318
|
-
case "cancelled":
|
|
319
|
-
case "unavailable":
|
|
320
|
-
case "schema_drift":
|
|
321
|
-
case "driver":
|
|
322
|
-
case "read_only":
|
|
323
|
-
case "outcome_unknown":
|
|
324
|
-
return true;
|
|
325
|
-
default:
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
307
|
+
return Object.hasOwn(CATEGORY_OF, code);
|
|
328
308
|
}
|
|
329
309
|
function defaultRetryable(kind) {
|
|
330
310
|
if (kind === "cancelled" || kind === "outcome_unknown")
|