okmodel 0.2.1 → 0.4.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 +882 -48
- package/dist/contracts/catalog/document.d.ts +6 -2
- package/dist/contracts/catalog/enum.d.ts +31 -4
- package/dist/contracts/catalog/extension.d.ts +61 -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 +164 -10
- package/dist/contracts/catalog/view.d.ts +73 -0
- package/dist/dialects/pg/column.d.ts +3 -1
- 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/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.js +104 -19
- package/dist/dialects/pg/introspect.d.ts +10 -1
- package/dist/dialects/pg/operators.d.ts +8 -1
- 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 +51 -0
- package/dist/dialects/pg/table.d.ts +24 -1
- package/dist/dialects/pg/tenancy.d.ts +9 -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 +22 -0
- package/dist/dialects/pg/where.d.ts +2 -2
- package/dist/runtime/catalog-cache.d.ts +17 -0
- package/dist/runtime/compat-words.d.ts +23 -0
- package/dist/runtime/drift-detail.d.ts +20 -4
- package/dist/runtime/drift.d.ts +4 -2
- package/dist/runtime/pg/bun.js +3 -3
- package/dist/runtime/pg/pg.js +3 -3
- package/dist/runtime/pg/pglite.js +3 -3
- package/dist/runtime/pg/postgresjs.js +3 -3
- package/dist/runtime/tenancy/index.js +6 -3
- package/dist/runtime/traits/index.d.ts +7 -2
- package/dist/runtime/traits/index.js +151 -13
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{xkz8g6by.js → 1g0drakv.js} +2 -2
- package/dist/shared/2321avmn.js +418 -0
- package/dist/shared/{7mht49yd.js → 3p4b1fg0.js} +57 -18
- package/dist/shared/41kv2xdm.js +318 -0
- package/dist/shared/{97g2jnrw.js → 4ef7mmqf.js} +3 -3
- package/dist/shared/{sacqha1y.js → 4m9fn52z.js} +2 -2
- package/dist/shared/5mtf6cj3.js +94 -0
- package/dist/shared/{1dp5knt7.js → 5vdm4sgp.js} +2 -2
- package/dist/shared/{a1gdp7j9.js → 6693j9rs.js} +1 -1
- package/dist/shared/{38crxbgn.js → 6p5k20sm.js} +3 -3
- package/dist/shared/7nk68fj8.js +751 -0
- package/dist/shared/84ptn35q.js +71 -0
- package/dist/shared/{d2whjz4k.js → 8jb4ymh2.js} +581 -28
- package/dist/shared/8ktwd3rh.js +97 -0
- package/dist/shared/94ez8kzh.js +19 -0
- package/dist/shared/{3a5ne750.js → 9m80mkac.js} +2 -2
- package/dist/shared/9x25fxhc.js +150 -0
- package/dist/shared/9yn6a2vd.js +11 -0
- package/dist/shared/ady1ms74.js +72 -0
- package/dist/shared/{4jzzghr6.js → awrsqrn7.js} +6 -6
- package/dist/shared/{4b9da9d7.js → axhk06q1.js} +19 -1
- package/dist/shared/{d04j53v8.js → c5g81ngb.js} +82 -14
- package/dist/shared/{n47rd821.js → c8aghh05.js} +1 -1
- package/dist/shared/{dd4f8mnx.js → c9z5g0fm.js} +4 -2
- package/dist/shared/{ps43134h.js → dyj86cmj.js} +4 -4
- package/dist/shared/{0qkxbm1f.js → fa9vt245.js} +1 -1
- package/dist/shared/{qa5dsc7z.js → fb00y8fp.js} +3 -3
- package/dist/shared/{qxa0yb9j.js → g7ez901n.js} +30 -1
- package/dist/shared/{py3nh7jy.js → gdh9mrtp.js} +2 -2
- package/dist/shared/{yw5c610b.js → gjthds9j.js} +2 -2
- package/dist/shared/hcmdtwgh.js +102 -0
- package/dist/shared/hqjsxnz7.js +13 -0
- package/dist/shared/htnaj77v.js +17 -0
- package/dist/shared/{v18jva5b.js → jgxzjzcz.js} +1 -1
- package/dist/shared/{x9v1qgeb.js → jsd07prz.js} +3 -3
- package/dist/shared/{g9f0zqce.js → kafaa5zv.js} +1 -1
- package/dist/shared/kj680nxv.js +19 -0
- package/dist/shared/{mxmcdsh5.js → kkzwp3d2.js} +9 -9
- package/dist/shared/{g1b5zzj9.js → n0dgs0pb.js} +1 -1
- package/dist/shared/n5y9zyj1.js +2431 -0
- package/dist/shared/{zt8y0wzb.js → n7mcc1gk.js} +1 -1
- package/dist/shared/{ge03bfca.js → nxb42q7h.js} +2 -2
- package/dist/shared/q6zsyh31.js +2192 -0
- package/dist/shared/{sfh4pk75.js → q795afwa.js} +26 -21
- package/dist/shared/{10tjenmd.js → qn0srwwq.js} +1 -1
- package/dist/shared/s4mb6a4b.js +545 -0
- package/dist/shared/{ytg3xf9p.js → sf8m6tfy.js} +3 -3
- package/dist/shared/{zd93g3rq.js → sr5ms7b3.js} +1 -1
- package/dist/shared/{xatfg0gn.js → tmbdywx0.js} +4 -19
- package/dist/shared/tny2t3sm.js +100 -0
- package/dist/shared/{e7a268fy.js → v7tpnhnz.js} +1 -1
- package/dist/shared/{ecdzej21.js → wqem4jed.js} +7 -7
- package/dist/shared/xghkt7a9.js +1144 -0
- package/dist/shared/y005b761.js +112 -0
- package/dist/shared/ycatkxmq.js +84 -0
- package/dist/shared/ygem90rn.js +900 -0
- package/dist/shared/{eaxwrgby.js → yjw02enp.js} +6 -3
- package/dist/shared/{mrq77sgw.js → zg24x0hm.js} +1 -1
- package/dist/shared/{cstgkzdx.js → zvbjc949.js} +1 -1
- package/dist/tooling/cli.js +66 -13
- package/dist/tooling/migrate/apply.d.ts +75 -5
- package/dist/tooling/migrate/backfill.d.ts +136 -0
- package/dist/tooling/migrate/check.d.ts +65 -0
- package/dist/tooling/migrate/classify.d.ts +108 -0
- package/dist/tooling/migrate/commands.d.ts +2 -1
- package/dist/tooling/migrate/config.d.ts +30 -0
- package/dist/tooling/migrate/doctor.d.ts +28 -0
- package/dist/tooling/migrate/drift.d.ts +35 -0
- package/dist/tooling/migrate/estimate.d.ts +50 -0
- package/dist/tooling/migrate/ext.d.ts +17 -0
- package/dist/tooling/migrate/extensions.d.ts +53 -0
- package/dist/tooling/migrate/files.d.ts +12 -0
- package/dist/tooling/migrate/index.d.ts +3 -2
- package/dist/tooling/migrate/index.js +67 -1
- package/dist/tooling/migrate/lint-rules.d.ts +51 -0
- package/dist/tooling/migrate/lint.d.ts +71 -0
- package/dist/tooling/migrate/managed.d.ts +17 -0
- package/dist/tooling/migrate/plan.d.ts +78 -10
- package/dist/tooling/migrate/project.d.ts +64 -5
- package/dist/tooling/migrate/provision.d.ts +18 -0
- package/dist/tooling/migrate/reference.d.ts +40 -0
- package/dist/tooling/migrate/runner.d.ts +108 -0
- package/dist/tooling/migrate/safe.d.ts +77 -0
- package/dist/tooling/migrate/seed.d.ts +20 -0
- package/dist/tooling/migrate/snapshot.d.ts +78 -0
- package/dist/tooling/migrate/status.d.ts +25 -6
- package/dist/tooling/migrate/type-name.d.ts +19 -0
- package/dist/tooling/testing/factories.d.ts +117 -0
- package/dist/tooling/testing/facts.d.ts +72 -0
- package/dist/tooling/testing/index.d.ts +89 -0
- package/dist/tooling/testing/index.js +8 -0
- package/dist/tooling/testing/isolation.d.ts +30 -0
- package/dist/tooling/testing/random.d.ts +40 -0
- package/dist/tooling/testing/record.d.ts +38 -0
- package/package.json +26 -2
- package/dist/shared/5z4q2zda.js +0 -2073
- package/dist/shared/eqmtn1bj.js +0 -399
- package/dist/shared/rtnaqre0.js +0 -37
- package/dist/shared/zwmqxb0g.js +0 -79
- package/dist/shared/{m9tv7xn7.js → radd3z4g.js} +3 -3
- /package/dist/shared/{9k6vetvf.js → rrstp3kb.js} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
open2
|
|
3
|
+
} from "./wqem4jed.js";
|
|
4
|
+
import"./8jb4ymh2.js";
|
|
5
|
+
import"./n442h54c.js";
|
|
6
|
+
import {
|
|
7
|
+
assertTargetPolicy,
|
|
8
|
+
selectTarget,
|
|
9
|
+
openProject
|
|
10
|
+
} from "./q6zsyh31.js";
|
|
11
|
+
import"./n5y9zyj1.js";
|
|
12
|
+
import"./41kv2xdm.js";
|
|
13
|
+
import {
|
|
14
|
+
isExactVersion,
|
|
15
|
+
compareExtensionVersions
|
|
16
|
+
} from "./8ktwd3rh.js";
|
|
17
|
+
import {
|
|
18
|
+
OkmError2
|
|
19
|
+
} from "./52szzakm.js";
|
|
20
|
+
|
|
21
|
+
// src/tooling/migrate/ext.ts
|
|
22
|
+
async function extProject(cwd, command, flags) {
|
|
23
|
+
const opened = await openProject(cwd);
|
|
24
|
+
const target = selectTarget(opened.config, flags.target);
|
|
25
|
+
assertTargetPolicy(target, "check", flags.allowProtected);
|
|
26
|
+
const pool = open2({ url: target.url, max: 1 });
|
|
27
|
+
try {
|
|
28
|
+
if (command === "list")
|
|
29
|
+
return formatList(await readExtensions(pool));
|
|
30
|
+
return formatCheck(opened.built.catalog.objects, await readExtensions(pool));
|
|
31
|
+
} finally {
|
|
32
|
+
await pool.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var LIST_SQL = `
|
|
36
|
+
select a.name, a.default_version, e.extversion, n.nspname
|
|
37
|
+
from pg_available_extensions a
|
|
38
|
+
left join pg_extension e on e.extname = a.name
|
|
39
|
+
left join pg_namespace n on n.oid = e.extnamespace
|
|
40
|
+
order by a.name
|
|
41
|
+
`;
|
|
42
|
+
async function readExtensions(pool) {
|
|
43
|
+
const result = await pool.execute(LIST_SQL);
|
|
44
|
+
return result.rows.map((row) => ({
|
|
45
|
+
name: cell(row[0]),
|
|
46
|
+
defaultVersion: cell(row[1]),
|
|
47
|
+
installedVersion: cell(row[2]),
|
|
48
|
+
schema: cell(row[3])
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
function cell(value) {
|
|
52
|
+
return typeof value === "string" ? value : "";
|
|
53
|
+
}
|
|
54
|
+
function formatList(rows) {
|
|
55
|
+
const lines = ["name\tdefault\tinstalled\tschema"];
|
|
56
|
+
for (const row of rows) {
|
|
57
|
+
lines.push([row.name, row.defaultVersion, row.installedVersion, row.schema].join("\t"));
|
|
58
|
+
}
|
|
59
|
+
return `${lines.join(`
|
|
60
|
+
`)}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
function formatCheck(objects, server) {
|
|
64
|
+
const declared = objects.filter((object) => object.kind === "extension");
|
|
65
|
+
if (declared.length === 0)
|
|
66
|
+
return `no extensions
|
|
67
|
+
`;
|
|
68
|
+
const installed = new Map(server.map((row) => [row.name, row.installedVersion]));
|
|
69
|
+
const lines = ["name\tdeclared\tinstalled"];
|
|
70
|
+
for (const object of [...declared].sort((left, right) => left.identity.name < right.identity.name ? -1 : 1)) {
|
|
71
|
+
const name = object.identity.name;
|
|
72
|
+
const have = installed.get(name) ?? "";
|
|
73
|
+
if (have.length === 0) {
|
|
74
|
+
throw new OkmError2("OKM1811", `Extension ${name} is not installed on the server.`, {
|
|
75
|
+
fix: { summary: "Install the extension, or remove the declaration." }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const want = object.definition.version;
|
|
79
|
+
if (!versionAccepted(want, have)) {
|
|
80
|
+
throw new OkmError2("OKM1812", `Extension ${name} is ${have} on the server. The schema requires ${want ?? ""}.`, { fix: { summary: "Install a version the declaration accepts, or change the pin." } });
|
|
81
|
+
}
|
|
82
|
+
lines.push([name, want ?? "-", have].join("\t"));
|
|
83
|
+
}
|
|
84
|
+
return `${lines.join(`
|
|
85
|
+
`)}
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
function versionAccepted(declared, installed) {
|
|
89
|
+
if (declared === undefined)
|
|
90
|
+
return true;
|
|
91
|
+
const floor = /^>=(\d+(?:\.\d+)*)$/.exec(declared);
|
|
92
|
+
const minimum = floor?.[1];
|
|
93
|
+
if (minimum !== undefined) {
|
|
94
|
+
return isExactVersion(installed) && compareExtensionVersions(installed, minimum) >= 0;
|
|
95
|
+
}
|
|
96
|
+
return declared === installed;
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
extProject
|
|
100
|
+
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
runCall,
|
|
7
7
|
EMPTY_NOTICES,
|
|
8
8
|
resultFrom
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./rrstp3kb.js";
|
|
10
10
|
|
|
11
11
|
// src/adapters/pg/postgresjs.ts
|
|
12
12
|
import net from "node:net";
|
|
@@ -117,7 +117,7 @@ function open2(config) {
|
|
|
117
117
|
},
|
|
118
118
|
async batch(statements, options) {
|
|
119
119
|
return sockets.occupy(async () => {
|
|
120
|
-
const { checkout } = await import("./
|
|
120
|
+
const { checkout } = await import("./5vdm4sgp.js");
|
|
121
121
|
const connection = await checkout(held);
|
|
122
122
|
try {
|
|
123
123
|
return await connection.batch(statements, options);
|
|
@@ -129,12 +129,12 @@ function open2(config) {
|
|
|
129
129
|
reserve() {
|
|
130
130
|
const gate = sockets.busyGate();
|
|
131
131
|
gate.enter();
|
|
132
|
-
return import("./
|
|
132
|
+
return import("./5vdm4sgp.js").then((mod) => mod.holdCheckout(gate, () => mod.checkout(held)), (error) => {
|
|
133
133
|
gate.leave();
|
|
134
134
|
throw error;
|
|
135
135
|
});
|
|
136
136
|
},
|
|
137
|
-
describe: (text, params) => sockets.occupy(() => import("./
|
|
137
|
+
describe: (text, params) => sockets.occupy(() => import("./5vdm4sgp.js").then((mod) => mod.describe(sql, text, params))),
|
|
138
138
|
stream(text, params) {
|
|
139
139
|
const gate = sockets.busyGate();
|
|
140
140
|
return async function* () {
|
|
@@ -149,7 +149,7 @@ function open2(config) {
|
|
|
149
149
|
listen(channel, onNotify) {
|
|
150
150
|
const gate = sockets.listenerGate();
|
|
151
151
|
gate.enter();
|
|
152
|
-
return import("./
|
|
152
|
+
return import("./5vdm4sgp.js").then((mod) => mod.holdListener(gate, async () => {
|
|
153
153
|
const listening = await sql.listen(channel, onNotify);
|
|
154
154
|
return async () => {
|
|
155
155
|
await listening.unlisten();
|
|
@@ -219,7 +219,7 @@ class PgSession {
|
|
|
219
219
|
onAbort();
|
|
220
220
|
else
|
|
221
221
|
watch.signal.addEventListener("abort", onAbort, { once: true });
|
|
222
|
-
return import("./
|
|
222
|
+
return import("./5vdm4sgp.js").then((mod) => mod.watchQuery(pending, watch, onAbort, {
|
|
223
223
|
start,
|
|
224
224
|
text,
|
|
225
225
|
notices: this.notices,
|
|
@@ -271,7 +271,7 @@ class PgSession {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
async function* loadStream(sql, text, params) {
|
|
274
|
-
const { stream } = await import("./
|
|
274
|
+
const { stream } = await import("./5vdm4sgp.js");
|
|
275
275
|
yield* stream(sql, text, params);
|
|
276
276
|
}
|
|
277
277
|
function send(sql, text, params, named) {
|