okmodel 0.0.0 → 0.1.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 +44 -1
- package/dist/adapters/capabilities.d.ts +62 -0
- package/dist/adapters/error.d.ts +91 -0
- package/dist/adapters/failure.d.ts +39 -0
- package/dist/adapters/pg/batch.d.ts +36 -0
- package/dist/adapters/pg/call.d.ts +59 -0
- package/dist/adapters/pg/pglite.d.ts +21 -0
- package/dist/adapters/pg/postgres-extra.d.ts +43 -0
- package/dist/adapters/pg/postgresjs.d.ts +95 -0
- package/dist/adapters/pg/result.d.ts +30 -0
- package/dist/contracts/catalog/build.d.ts +18 -0
- package/dist/contracts/catalog/document.d.ts +79 -0
- package/dist/contracts/catalog/enum.d.ts +35 -0
- package/dist/contracts/catalog/identifier.d.ts +71 -0
- package/dist/contracts/catalog/identity.d.ts +98 -0
- package/dist/contracts/catalog/index.d.ts +11 -0
- package/dist/contracts/catalog/json.d.ts +17 -0
- package/dist/contracts/catalog/object.d.ts +142 -0
- package/dist/contracts/catalog/order.d.ts +43 -0
- package/dist/contracts/catalog/rewrite.d.ts +18 -0
- package/dist/contracts/catalog/types.d.ts +292 -0
- package/dist/contracts/catalog/words.d.ts +13 -0
- package/dist/contracts/connection.d.ts +33 -0
- package/dist/contracts/driver.d.ts +163 -0
- package/dist/contracts/error.d.ts +298 -0
- package/dist/contracts/index.d.ts +11 -0
- package/dist/contracts/index.js +16 -0
- package/dist/contracts/internal.d.ts +15 -0
- package/dist/contracts/internal.js +68 -0
- package/dist/contracts/nearest.d.ts +15 -0
- package/dist/contracts/rows.d.ts +84 -0
- package/dist/contracts/sha256.d.ts +14 -0
- package/dist/contracts/utf8.d.ts +33 -0
- package/dist/dialects/pg/array-literal.d.ts +25 -0
- package/dist/dialects/pg/bool.d.ts +46 -0
- package/dist/dialects/pg/column.d.ts +386 -0
- package/dist/dialects/pg/compile.d.ts +81 -0
- package/dist/dialects/pg/custom.d.ts +21 -0
- package/dist/dialects/pg/ddl.d.ts +70 -0
- package/dist/dialects/pg/decimal.d.ts +62 -0
- package/dist/dialects/pg/declarations.d.ts +34 -0
- package/dist/dialects/pg/emit.d.ts +18 -0
- package/dist/dialects/pg/enum.d.ts +30 -0
- package/dist/dialects/pg/errors.d.ts +30 -0
- package/dist/dialects/pg/finite.d.ts +15 -0
- package/dist/dialects/pg/geometry.d.ts +55 -0
- package/dist/dialects/pg/index.d.ts +45 -0
- package/dist/dialects/pg/index.js +1821 -0
- package/dist/dialects/pg/integer.d.ts +96 -0
- package/dist/dialects/pg/introspect.d.ts +43 -0
- package/dist/dialects/pg/json.d.ts +43 -0
- package/dist/dialects/pg/keys.d.ts +32 -0
- package/dist/dialects/pg/misuse.d.ts +31 -0
- package/dist/dialects/pg/model.d.ts +71 -0
- package/dist/dialects/pg/namespace.d.ts +63 -0
- package/dist/dialects/pg/network.d.ts +28 -0
- package/dist/dialects/pg/operators.d.ts +71 -0
- package/dist/dialects/pg/ops/between.d.ts +10 -0
- package/dist/dialects/pg/ops/contains.d.ts +8 -0
- package/dist/dialects/pg/ops/endsWith.d.ts +8 -0
- package/dist/dialects/pg/ops/eq.d.ts +9 -0
- package/dist/dialects/pg/ops/every.d.ts +9 -0
- package/dist/dialects/pg/ops/gt.d.ts +9 -0
- package/dist/dialects/pg/ops/gte.d.ts +9 -0
- package/dist/dialects/pg/ops/has.d.ts +9 -0
- package/dist/dialects/pg/ops/ilike.d.ts +8 -0
- package/dist/dialects/pg/ops/inList.d.ts +9 -0
- package/dist/dialects/pg/ops/inc.d.ts +13 -0
- package/dist/dialects/pg/ops/like.d.ts +8 -0
- package/dist/dialects/pg/ops/lt.d.ts +9 -0
- package/dist/dialects/pg/ops/lte.d.ts +9 -0
- package/dist/dialects/pg/ops/none.d.ts +9 -0
- package/dist/dialects/pg/ops/not.d.ts +9 -0
- package/dist/dialects/pg/ops/notIn.d.ts +9 -0
- package/dist/dialects/pg/ops/or.d.ts +9 -0
- package/dist/dialects/pg/ops/startsWith.d.ts +8 -0
- package/dist/dialects/pg/quote.d.ts +24 -0
- package/dist/dialects/pg/range.d.ts +50 -0
- package/dist/dialects/pg/relations.d.ts +45 -0
- package/dist/dialects/pg/schema.d.ts +77 -0
- package/dist/dialects/pg/search.d.ts +23 -0
- package/dist/dialects/pg/table.d.ts +201 -0
- package/dist/dialects/pg/temporal.d.ts +211 -0
- package/dist/dialects/pg/text.d.ts +44 -0
- package/dist/dialects/pg/time.d.ts +46 -0
- package/dist/okm.js +2 -0
- package/dist/okmodel.js +2 -0
- package/dist/runtime/client.d.ts +47 -0
- package/dist/runtime/conflict.d.ts +38 -0
- package/dist/runtime/drift-detail.d.ts +32 -0
- package/dist/runtime/drift.d.ts +29 -0
- package/dist/runtime/include.d.ts +15 -0
- package/dist/runtime/pg/pglite.d.ts +25 -0
- package/dist/runtime/pg/pglite.js +48 -0
- package/dist/runtime/pg/postgresjs.d.ts +29 -0
- package/dist/runtime/pg/postgresjs.js +62 -0
- package/dist/runtime/plan.d.ts +167 -0
- package/dist/runtime/tx.d.ts +29 -0
- package/dist/runtime/types.d.ts +369 -0
- package/dist/runtime/write.d.ts +48 -0
- package/dist/shared/4j72449d.js +37 -0
- package/dist/shared/79ggp945.js +148 -0
- package/dist/shared/7ck0dtry.js +259 -0
- package/dist/shared/8b04d28c.js +14 -0
- package/dist/shared/ax16zpvm.js +171 -0
- package/dist/shared/ckb1p0a4.js +566 -0
- package/dist/shared/cn0n68ft.js +16 -0
- package/dist/shared/dynq16vb.js +81 -0
- package/dist/shared/f5thc1s0.js +1050 -0
- package/dist/shared/fgqgsb5z.js +281 -0
- package/dist/shared/g2v6gnc8.js +347 -0
- package/dist/shared/g5fhqmwe.js +188 -0
- package/dist/shared/gk7cs7sp.js +566 -0
- package/dist/shared/hd293j9g.js +98 -0
- package/dist/shared/j5cn2963.js +701 -0
- package/dist/shared/kynx7vbm.js +1490 -0
- package/dist/shared/mkjmqjv4.js +456 -0
- package/dist/shared/mtkwv8wx.js +18 -0
- package/dist/shared/ngk8gj61.js +40 -0
- package/dist/shared/p0cbr3g2.js +79 -0
- package/dist/shared/px90pf9p.js +396 -0
- package/dist/shared/qk3hxfja.js +83 -0
- package/dist/shared/tb4ze1tr.js +119 -0
- package/dist/shared/vkm3q4x1.js +30 -0
- package/dist/shared/w8samvk1.js +18 -0
- package/dist/shared/xy79j5hq.js +177 -0
- package/dist/shared/y9m15dfv.js +888 -0
- package/dist/shared/ycwz42az.js +412 -0
- package/dist/shared/zhc5vmgf.js +257 -0
- package/dist/tooling/cli.d.ts +1 -0
- package/dist/tooling/cli.js +193 -0
- package/dist/tooling/errors/registry.d.ts +33 -0
- package/dist/tooling/migrate/apply.d.ts +86 -0
- package/dist/tooling/migrate/commands.d.ts +21 -0
- package/dist/tooling/migrate/config.d.ts +48 -0
- package/dist/tooling/migrate/dev.d.ts +16 -0
- package/dist/tooling/migrate/equal.d.ts +15 -0
- package/dist/tooling/migrate/files.d.ts +19 -0
- package/dist/tooling/migrate/index.d.ts +7 -0
- package/dist/tooling/migrate/index.js +7 -0
- package/dist/tooling/migrate/plan.d.ts +76 -0
- package/dist/tooling/migrate/policy.d.ts +78 -0
- package/dist/tooling/migrate/project.d.ts +69 -0
- package/dist/tooling/migrate/status.d.ts +74 -0
- package/dist/tooling/migrate/values.d.ts +29 -0
- package/package.json +94 -7
- package/dist/index.js +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// src/adapters/capabilities.ts
|
|
2
|
+
var POSTGRESJS_CAPABILITIES = {
|
|
3
|
+
transactions: "interactive",
|
|
4
|
+
stream: true,
|
|
5
|
+
listen: true,
|
|
6
|
+
cancel: true,
|
|
7
|
+
prepared: "unnamed",
|
|
8
|
+
describe: true
|
|
9
|
+
};
|
|
10
|
+
var PGLITE_CAPABILITIES = {
|
|
11
|
+
transactions: "interactive",
|
|
12
|
+
stream: false,
|
|
13
|
+
listen: true,
|
|
14
|
+
cancel: false,
|
|
15
|
+
prepared: "unnamed",
|
|
16
|
+
describe: true
|
|
17
|
+
};
|
|
18
|
+
function readCapability2(flags, name) {
|
|
19
|
+
return flags[name];
|
|
20
|
+
}
|
|
21
|
+
function hasCapability2(flags, name) {
|
|
22
|
+
return flags[name];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/adapters/failure.ts
|
|
26
|
+
var loading;
|
|
27
|
+
function driverErrors() {
|
|
28
|
+
loading ??= import("./mtkwv8wx.js");
|
|
29
|
+
return loading;
|
|
30
|
+
}
|
|
31
|
+
function rejectClosed(message = "The pool is closed.") {
|
|
32
|
+
return driverErrors().then((mod) => Promise.reject(new mod.DriverError(message)));
|
|
33
|
+
}
|
|
34
|
+
function rejectCancelled() {
|
|
35
|
+
return driverErrors().then((mod) => Promise.reject(mod.cancelled()));
|
|
36
|
+
}
|
|
37
|
+
function rejectTimedOut() {
|
|
38
|
+
return driverErrors().then((mod) => Promise.reject(mod.timedOut()));
|
|
39
|
+
}
|
|
40
|
+
async function mapFailure(error) {
|
|
41
|
+
const mod = await driverErrors();
|
|
42
|
+
return mod.mapDriverError(error);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/adapters/pg/call.ts
|
|
46
|
+
function needsWatch(options) {
|
|
47
|
+
return options?.signal !== undefined || options?.timeout !== undefined;
|
|
48
|
+
}
|
|
49
|
+
function nextTransactionDepth(depth, text) {
|
|
50
|
+
const command = text.trim().replace(/;\s*$/, "").trim().toLowerCase();
|
|
51
|
+
if (command === "begin" || command === "begin work" || command === "begin transaction") {
|
|
52
|
+
return depth + 1;
|
|
53
|
+
}
|
|
54
|
+
if (command === "commit" || command === "commit work" || command === "end") {
|
|
55
|
+
return Math.max(0, depth - 1);
|
|
56
|
+
}
|
|
57
|
+
if (command === "rollback" || command === "rollback work")
|
|
58
|
+
return 0;
|
|
59
|
+
return depth;
|
|
60
|
+
}
|
|
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
|
+
function runCall(closed, options, fn) {
|
|
91
|
+
if (closed)
|
|
92
|
+
return rejectClosed();
|
|
93
|
+
if (options?.signal?.aborted === true)
|
|
94
|
+
return rejectCancelled();
|
|
95
|
+
if (options?.timeout !== undefined && options.timeout <= 0)
|
|
96
|
+
return rejectTimedOut();
|
|
97
|
+
if (options === undefined || !needsWatch(options))
|
|
98
|
+
return fn(undefined);
|
|
99
|
+
const watch = openWatch(options);
|
|
100
|
+
return fn(watch).finally(() => {
|
|
101
|
+
watch.finish();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/adapters/pg/result.ts
|
|
106
|
+
var EMPTY_NOTICES = [];
|
|
107
|
+
function cell(value) {
|
|
108
|
+
if (value === null || value === undefined)
|
|
109
|
+
return null;
|
|
110
|
+
if (typeof value === "string")
|
|
111
|
+
return value;
|
|
112
|
+
if (typeof value === "bigint")
|
|
113
|
+
return value.toString();
|
|
114
|
+
if (value instanceof Uint8Array)
|
|
115
|
+
return new TextDecoder().decode(value);
|
|
116
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
117
|
+
return String(value);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
function rowsFrom(value) {
|
|
121
|
+
const list = rowList(value);
|
|
122
|
+
const rows = Array.from({ length: list.length });
|
|
123
|
+
for (let index = 0;index < list.length; index += 1) {
|
|
124
|
+
rows[index] = rowCells(list[index]);
|
|
125
|
+
}
|
|
126
|
+
return rows;
|
|
127
|
+
}
|
|
128
|
+
function resultFrom(value, notices) {
|
|
129
|
+
const rows = rowsFrom(value);
|
|
130
|
+
return {
|
|
131
|
+
rows,
|
|
132
|
+
count: countFrom(value, rows.length),
|
|
133
|
+
notices
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function rowList(value) {
|
|
137
|
+
if (Array.isArray(value))
|
|
138
|
+
return value;
|
|
139
|
+
if (typeof value === "object" && value !== null && "rows" in value) {
|
|
140
|
+
const rows = Reflect.get(value, "rows");
|
|
141
|
+
if (Array.isArray(rows))
|
|
142
|
+
return rows;
|
|
143
|
+
}
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
function rowCells(row) {
|
|
147
|
+
if (Array.isArray(row)) {
|
|
148
|
+
const cells = Array.from({ length: row.length });
|
|
149
|
+
for (let index = 0;index < row.length; index += 1)
|
|
150
|
+
cells[index] = cell(row[index]);
|
|
151
|
+
return cells;
|
|
152
|
+
}
|
|
153
|
+
if (typeof row === "object" && row !== null) {
|
|
154
|
+
const values = Object.values(row);
|
|
155
|
+
const cells = Array.from({ length: values.length });
|
|
156
|
+
for (let index = 0;index < values.length; index += 1)
|
|
157
|
+
cells[index] = cell(values[index]);
|
|
158
|
+
return cells;
|
|
159
|
+
}
|
|
160
|
+
return [cell(row)];
|
|
161
|
+
}
|
|
162
|
+
function countFrom(value, rows) {
|
|
163
|
+
if (typeof value !== "object" || value === null)
|
|
164
|
+
return rows;
|
|
165
|
+
const count = Reflect.get(value, "count");
|
|
166
|
+
if (typeof count === "number" && !Number.isNaN(count))
|
|
167
|
+
return count;
|
|
168
|
+
const rowCount = Reflect.get(value, "rowCount");
|
|
169
|
+
if (typeof rowCount === "number" && !Number.isNaN(rowCount))
|
|
170
|
+
return rowCount;
|
|
171
|
+
const affected = Reflect.get(value, "affectedRows");
|
|
172
|
+
if (typeof affected === "number" && !Number.isNaN(affected))
|
|
173
|
+
return affected;
|
|
174
|
+
return rows;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export { POSTGRESJS_CAPABILITIES, PGLITE_CAPABILITIES, readCapability2, hasCapability2, driverErrors, rejectClosed, rejectCancelled, rejectTimedOut, mapFailure, nextTransactionDepth, runCall, EMPTY_NOTICES, rowsFrom, resultFrom };
|