okmodel 0.2.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 +710 -36
- 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 +44 -0
- package/dist/dialects/pg/table.d.ts +7 -0
- 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 +21 -0
- package/dist/dialects/pg/where.d.ts +2 -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 +149 -12
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{ytg3xf9p.js → 01yr20s5.js} +3 -3
- package/dist/shared/{cstgkzdx.js → 0jc3ffzf.js} +1 -1
- package/dist/shared/{xkz8g6by.js → 1g0drakv.js} +2 -2
- package/dist/shared/{eaxwrgby.js → 1tfdfvhh.js} +4 -3
- package/dist/shared/2ssqrv66.js +1576 -0
- package/dist/shared/{10tjenmd.js → 3ekj9x92.js} +1 -1
- package/dist/shared/49ypnfwt.js +1122 -0
- package/dist/shared/{sacqha1y.js → 4m9fn52z.js} +2 -2
- package/dist/shared/5nmdenb6.js +1229 -0
- package/dist/shared/{qa5dsc7z.js → 6bazvqwm.js} +3 -3
- package/dist/shared/{x9v1qgeb.js → 6w5j844a.js} +1 -1
- package/dist/shared/{0qkxbm1f.js → 75xkjv0t.js} +1 -1
- package/dist/shared/7fvtrkwr.js +84 -0
- package/dist/shared/94ez8kzh.js +19 -0
- package/dist/shared/{1dp5knt7.js → 999ade2q.js} +2 -2
- package/dist/shared/{3a5ne750.js → 9m80mkac.js} +2 -2
- package/dist/shared/9x25fxhc.js +150 -0
- package/dist/shared/{4b9da9d7.js → axhk06q1.js} +19 -1
- package/dist/shared/{38crxbgn.js → bqha5cg6.js} +3 -3
- package/dist/shared/{zd93g3rq.js → bryqk9k9.js} +1 -1
- package/dist/shared/{n47rd821.js → c8aghh05.js} +1 -1
- package/dist/shared/{dd4f8mnx.js → c9z5g0fm.js} +4 -2
- package/dist/shared/{eqmtn1bj.js → dbjej1tw.js} +71 -14
- package/dist/shared/{ps43134h.js → dyj86cmj.js} +4 -4
- package/dist/shared/{sfh4pk75.js → fptpmvxp.js} +3 -3
- package/dist/shared/{97g2jnrw.js → fs0ex00p.js} +3 -3
- package/dist/shared/{rtnaqre0.js → g4f5kcx9.js} +2 -2
- package/dist/shared/{yw5c610b.js → gjthds9j.js} +2 -2
- package/dist/shared/hcmdtwgh.js +102 -0
- package/dist/shared/{qxa0yb9j.js → jkc6ws1p.js} +2 -54
- package/dist/shared/{mxmcdsh5.js → k34e0xf2.js} +9 -9
- package/dist/shared/{py3nh7jy.js → kgnc8grt.js} +2 -2
- package/dist/shared/{g9f0zqce.js → m78s7898.js} +1 -1
- package/dist/shared/meck53jv.js +99 -0
- package/dist/shared/{v18jva5b.js → mt5wswjz.js} +1 -1
- package/dist/shared/{g1b5zzj9.js → n0dgs0pb.js} +1 -1
- package/dist/shared/{zt8y0wzb.js → n7mcc1gk.js} +1 -1
- package/dist/shared/ne02ng5c.js +68 -0
- package/dist/shared/{e7a268fy.js → p24x2334.js} +1 -1
- package/dist/shared/qbxzvwwc.js +88 -0
- package/dist/shared/{a1gdp7j9.js → qybh48nd.js} +1 -1
- package/dist/shared/{d04j53v8.js → scwxrpx2.js} +5 -4
- package/dist/shared/{d2whjz4k.js → t616ynfn.js} +530 -24
- package/dist/shared/th14ygv2.js +69 -0
- package/dist/shared/{xatfg0gn.js → tmbdywx0.js} +4 -19
- package/dist/shared/{ge03bfca.js → ty3v3hfk.js} +2 -2
- package/dist/shared/wekze34d.js +246 -0
- package/dist/shared/{7mht49yd.js → x6wysh83.js} +59 -18
- package/dist/shared/{4jzzghr6.js → xva8v7qk.js} +8 -8
- package/dist/shared/{ecdzej21.js → xw1d69vd.js} +7 -7
- package/dist/shared/y005b761.js +112 -0
- package/dist/shared/{mrq77sgw.js → ydaz1sv3.js} +1 -1
- package/dist/tooling/cli.js +32 -8
- package/dist/tooling/migrate/apply.d.ts +16 -0
- package/dist/tooling/migrate/commands.d.ts +2 -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/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 +22 -2
- package/dist/shared/5z4q2zda.js +0 -2073
- /package/dist/shared/{9k6vetvf.js → rrstp3kb.js} +0 -0
package/dist/runtime/pg/bun.js
CHANGED
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "../../shared/kyxb62mc.js";
|
|
4
4
|
import {
|
|
5
5
|
open5
|
|
6
|
-
} from "../../shared/
|
|
6
|
+
} from "../../shared/01yr20s5.js";
|
|
7
7
|
import {
|
|
8
8
|
BUNSQL_CAPABILITIES,
|
|
9
9
|
readCapability2,
|
|
10
10
|
hasCapability2
|
|
11
|
-
} from "../../shared/
|
|
11
|
+
} from "../../shared/rrstp3kb.js";
|
|
12
12
|
import {
|
|
13
13
|
createClient
|
|
14
|
-
} from "../../shared/
|
|
14
|
+
} from "../../shared/k34e0xf2.js";
|
|
15
15
|
|
|
16
16
|
// src/runtime/pg/bun.ts
|
|
17
17
|
function connect(target, options) {
|
package/dist/runtime/pg/pg.js
CHANGED
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "../../shared/kyxb62mc.js";
|
|
4
4
|
import {
|
|
5
5
|
open4
|
|
6
|
-
} from "../../shared/
|
|
6
|
+
} from "../../shared/bqha5cg6.js";
|
|
7
7
|
import {
|
|
8
8
|
NODE_POSTGRES_CAPABILITIES,
|
|
9
9
|
readCapability2,
|
|
10
10
|
hasCapability2
|
|
11
|
-
} from "../../shared/
|
|
11
|
+
} from "../../shared/rrstp3kb.js";
|
|
12
12
|
import {
|
|
13
13
|
createClient
|
|
14
|
-
} from "../../shared/
|
|
14
|
+
} from "../../shared/k34e0xf2.js";
|
|
15
15
|
|
|
16
16
|
// src/runtime/pg/pg.ts
|
|
17
17
|
function connect(target, options) {
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "../../shared/kyxb62mc.js";
|
|
4
4
|
import {
|
|
5
5
|
open3
|
|
6
|
-
} from "../../shared/
|
|
6
|
+
} from "../../shared/75xkjv0t.js";
|
|
7
7
|
import {
|
|
8
8
|
PGLITE_CAPABILITIES,
|
|
9
9
|
readCapability2,
|
|
10
10
|
hasCapability2
|
|
11
|
-
} from "../../shared/
|
|
11
|
+
} from "../../shared/rrstp3kb.js";
|
|
12
12
|
import {
|
|
13
13
|
createClient
|
|
14
|
-
} from "../../shared/
|
|
14
|
+
} from "../../shared/k34e0xf2.js";
|
|
15
15
|
|
|
16
16
|
// src/runtime/pg/pglite.ts
|
|
17
17
|
async function connect(target, options) {
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "../../shared/kyxb62mc.js";
|
|
4
4
|
import {
|
|
5
5
|
open2
|
|
6
|
-
} from "../../shared/
|
|
6
|
+
} from "../../shared/xw1d69vd.js";
|
|
7
7
|
import {
|
|
8
8
|
POSTGRESJS_CAPABILITIES,
|
|
9
9
|
readCapability2,
|
|
10
10
|
hasCapability2
|
|
11
|
-
} from "../../shared/
|
|
11
|
+
} from "../../shared/rrstp3kb.js";
|
|
12
12
|
import {
|
|
13
13
|
createClient
|
|
14
|
-
} from "../../shared/
|
|
14
|
+
} from "../../shared/k34e0xf2.js";
|
|
15
15
|
|
|
16
16
|
// src/runtime/pg/postgresjs.ts
|
|
17
17
|
function connect(target, options) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
uuid2
|
|
3
|
-
} from "../../shared/
|
|
3
|
+
} from "../../shared/dyj86cmj.js";
|
|
4
4
|
import {
|
|
5
5
|
ColumnBuilder2,
|
|
6
6
|
retarget
|
|
7
|
-
} from "../../shared/
|
|
7
|
+
} from "../../shared/c9z5g0fm.js";
|
|
8
8
|
import {
|
|
9
9
|
definition,
|
|
10
10
|
unavailable
|
|
11
|
-
} from "../../shared/
|
|
11
|
+
} from "../../shared/tmbdywx0.js";
|
|
12
12
|
import {
|
|
13
13
|
quote
|
|
14
14
|
} from "../../shared/xrfnq5k8.js";
|
|
@@ -76,6 +76,9 @@ function columnTenancy(input) {
|
|
|
76
76
|
rules(table, source, scope) {
|
|
77
77
|
return tenancyRules(table, source, scope, tenants, globals, exemptions);
|
|
78
78
|
},
|
|
79
|
+
scopeView(name) {
|
|
80
|
+
tenants.add(name);
|
|
81
|
+
},
|
|
79
82
|
hook(target, ctx) {
|
|
80
83
|
if (ctx.tables === undefined || ctx.names === undefined || ctx.open === undefined || ctx.scoped === undefined) {
|
|
81
84
|
return;
|
|
@@ -51,13 +51,14 @@ export declare function trait<const TFields extends Readonly<Record<string, obje
|
|
|
51
51
|
readonly touch?: readonly (keyof TFields & string)[];
|
|
52
52
|
readonly sealed?: readonly (keyof TFields & string)[];
|
|
53
53
|
apply(model: TraitModel, ctx: TraitContext): void;
|
|
54
|
+
contribute(peers: unknown, built: unknown): readonly unknown[];
|
|
54
55
|
} & ([keyof TPresets] extends [never] ? unknown : {
|
|
55
56
|
readonly presets: TPresets;
|
|
56
57
|
});
|
|
57
58
|
/**
|
|
58
59
|
* Options for {@link timestamps}.
|
|
59
60
|
*
|
|
60
|
-
* `enforce: "trigger"`
|
|
61
|
+
* `enforce: "trigger"` adds a before-update trigger and its function.
|
|
61
62
|
*/
|
|
62
63
|
export type TimestampsOptions = {
|
|
63
64
|
readonly enforce?: "trigger";
|
|
@@ -68,8 +69,10 @@ export type TimestampsOptions = {
|
|
|
68
69
|
* Both are `timestamptz not null default now()`, and input cannot set either
|
|
69
70
|
* of them. Insert leaves them to the default, so one statement stamps both
|
|
70
71
|
* with the same time. Update sets `updatedAt` to `now()` and leaves `createdAt`.
|
|
72
|
+
* `{ enforce: "trigger" }` also writes `updatedAt` in the database, including
|
|
73
|
+
* for writers that bypass the client.
|
|
71
74
|
*
|
|
72
|
-
* @param options - Pass `{ enforce: "trigger" }`
|
|
75
|
+
* @param options - Pass `{ enforce: "trigger" }` for the database trigger
|
|
73
76
|
* @returns The timestamps trait
|
|
74
77
|
*/
|
|
75
78
|
export declare function timestamps(options?: TimestampsOptions): {
|
|
@@ -81,6 +84,7 @@ export declare function timestamps(options?: TimestampsOptions): {
|
|
|
81
84
|
readonly touch?: readonly ("createdAt" | "updatedAt")[];
|
|
82
85
|
readonly sealed?: readonly ("createdAt" | "updatedAt")[];
|
|
83
86
|
apply(model: TraitModel, ctx: TraitContext): void;
|
|
87
|
+
contribute(peers: unknown, built: unknown): readonly unknown[];
|
|
84
88
|
};
|
|
85
89
|
/**
|
|
86
90
|
* Options for {@link archivable}.
|
|
@@ -111,6 +115,7 @@ export declare function archivable(options?: ArchivableOptions): {
|
|
|
111
115
|
};
|
|
112
116
|
touch?: readonly ("archiveId" | "archivedAt")[];
|
|
113
117
|
sealed?: readonly ("archiveId" | "archivedAt")[];
|
|
118
|
+
contribute(peers: unknown, built: unknown): readonly unknown[];
|
|
114
119
|
"~archive": true;
|
|
115
120
|
apply(model: TraitModel, ctx: TraitContext): void;
|
|
116
121
|
/**
|
|
@@ -4,35 +4,46 @@ import {
|
|
|
4
4
|
} from "../../shared/nsva2a6b.js";
|
|
5
5
|
import {
|
|
6
6
|
checkTrait
|
|
7
|
-
} from "../../shared/
|
|
7
|
+
} from "../../shared/n0dgs0pb.js";
|
|
8
|
+
import {
|
|
9
|
+
quoteIdent
|
|
10
|
+
} from "../../shared/wekze34d.js";
|
|
11
|
+
import {
|
|
12
|
+
functionObject,
|
|
13
|
+
triggerObject
|
|
14
|
+
} from "../../shared/9x25fxhc.js";
|
|
8
15
|
import {
|
|
9
16
|
timestamptz2
|
|
10
|
-
} from "../../shared/
|
|
17
|
+
} from "../../shared/1g0drakv.js";
|
|
11
18
|
import {
|
|
12
19
|
uuid2
|
|
13
|
-
} from "../../shared/
|
|
20
|
+
} from "../../shared/dyj86cmj.js";
|
|
14
21
|
import {
|
|
15
22
|
snakeCase
|
|
16
|
-
} from "../../shared/
|
|
23
|
+
} from "../../shared/6w5j844a.js";
|
|
17
24
|
import {
|
|
18
25
|
ColumnBuilder2,
|
|
19
26
|
retarget
|
|
20
|
-
} from "../../shared/
|
|
27
|
+
} from "../../shared/c9z5g0fm.js";
|
|
21
28
|
import {
|
|
22
29
|
definition,
|
|
23
30
|
unavailable
|
|
24
|
-
} from "../../shared/
|
|
31
|
+
} from "../../shared/tmbdywx0.js";
|
|
25
32
|
import {
|
|
33
|
+
staticNamespace2,
|
|
26
34
|
compareText
|
|
27
35
|
} from "../../shared/t4tbsy9h.js";
|
|
28
36
|
import {
|
|
29
37
|
queryHandle,
|
|
30
38
|
attachHttp,
|
|
31
39
|
settleCall
|
|
32
|
-
} from "../../shared/
|
|
40
|
+
} from "../../shared/k34e0xf2.js";
|
|
33
41
|
import {
|
|
34
42
|
installArchiveInspect
|
|
35
43
|
} from "../../shared/xrfnq5k8.js";
|
|
44
|
+
import {
|
|
45
|
+
fitIdentifier2
|
|
46
|
+
} from "../../shared/nfzc5z0w.js";
|
|
36
47
|
import {
|
|
37
48
|
OkmError2,
|
|
38
49
|
catalogError2,
|
|
@@ -256,6 +267,124 @@ function list(names) {
|
|
|
256
267
|
return names.join(", ");
|
|
257
268
|
}
|
|
258
269
|
|
|
270
|
+
// src/dialects/pg/fn/touch.ts
|
|
271
|
+
function timestampRecords(built) {
|
|
272
|
+
const columns = updatedColumns(built);
|
|
273
|
+
if (columns.length === 0)
|
|
274
|
+
return [];
|
|
275
|
+
const namespace = staticNamespace2("public");
|
|
276
|
+
const byColumn = new Map;
|
|
277
|
+
for (const column of columns) {
|
|
278
|
+
const list = byColumn.get(column.name) ?? [];
|
|
279
|
+
list.push(column.parent);
|
|
280
|
+
byColumn.set(column.name, list);
|
|
281
|
+
}
|
|
282
|
+
const records = [];
|
|
283
|
+
for (const [column, tables] of byColumn) {
|
|
284
|
+
const name = fitIdentifier2(`okm_touch_${column}`);
|
|
285
|
+
const present = hasFunction(built, name) || records.some((object) => object.kind === "function" && object.identity.name === name);
|
|
286
|
+
if (!present) {
|
|
287
|
+
records.push(functionObject({
|
|
288
|
+
namespace,
|
|
289
|
+
name,
|
|
290
|
+
returns: "trigger",
|
|
291
|
+
language: "plpgsql",
|
|
292
|
+
volatility: "volatile",
|
|
293
|
+
body: `begin new.${quoteIdent(column)} = now(); return new; end`,
|
|
294
|
+
provenance: { origin: "trait", name: "timestamps" },
|
|
295
|
+
dependencies: []
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
for (const parent of tables) {
|
|
299
|
+
const triggerName = fitIdentifier2(`${parent.name}_touch`);
|
|
300
|
+
if (hasTrigger(built, parent.name, triggerName))
|
|
301
|
+
continue;
|
|
302
|
+
if (records.some((object) => object.kind === "trigger" && object.identity.name === triggerName && object.identity.parent.name === parent.name)) {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
records.push(triggerObject({
|
|
306
|
+
parent,
|
|
307
|
+
name: triggerName,
|
|
308
|
+
timing: "before",
|
|
309
|
+
events: ["update"],
|
|
310
|
+
level: "row",
|
|
311
|
+
calls: { namespace, name, argTypes: [] },
|
|
312
|
+
provenance: { origin: "trait", name: "timestamps" }
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return records;
|
|
317
|
+
}
|
|
318
|
+
function updatedColumns(built) {
|
|
319
|
+
if (!Array.isArray(built))
|
|
320
|
+
return [];
|
|
321
|
+
const found = [];
|
|
322
|
+
for (const object of built) {
|
|
323
|
+
if (typeof object !== "object" || object === null)
|
|
324
|
+
continue;
|
|
325
|
+
if (!("kind" in object) || object.kind !== "column")
|
|
326
|
+
continue;
|
|
327
|
+
if (!("provenance" in object) || !("identity" in object))
|
|
328
|
+
continue;
|
|
329
|
+
const provenance = object.provenance;
|
|
330
|
+
const identity = object.identity;
|
|
331
|
+
if (typeof provenance !== "object" || provenance === null)
|
|
332
|
+
continue;
|
|
333
|
+
if (typeof identity !== "object" || identity === null)
|
|
334
|
+
continue;
|
|
335
|
+
if (!("origin" in provenance) || provenance.origin !== "trait")
|
|
336
|
+
continue;
|
|
337
|
+
if (!("name" in provenance) || provenance.name !== "timestamps")
|
|
338
|
+
continue;
|
|
339
|
+
if (!("name" in identity) || identity.name !== "updated_at" && identity.name !== "updatedAt")
|
|
340
|
+
continue;
|
|
341
|
+
if (!("parent" in identity) || typeof identity.parent !== "object" || identity.parent === null)
|
|
342
|
+
continue;
|
|
343
|
+
const parent = identity.parent;
|
|
344
|
+
if (!("name" in parent) || typeof parent.name !== "string")
|
|
345
|
+
continue;
|
|
346
|
+
if (!("namespace" in parent) || typeof parent.namespace !== "object" || parent.namespace === null)
|
|
347
|
+
continue;
|
|
348
|
+
const namespace = parent.namespace;
|
|
349
|
+
if (!("form" in namespace) || namespace.form !== "static")
|
|
350
|
+
continue;
|
|
351
|
+
if (!("name" in namespace) || typeof namespace.name !== "string")
|
|
352
|
+
continue;
|
|
353
|
+
found.push({
|
|
354
|
+
parent: { namespace: staticNamespace2(namespace.name), name: parent.name },
|
|
355
|
+
name: identity.name
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return found;
|
|
359
|
+
}
|
|
360
|
+
function hasFunction(built, name) {
|
|
361
|
+
return named(built, "function", name);
|
|
362
|
+
}
|
|
363
|
+
function hasTrigger(built, table, name) {
|
|
364
|
+
if (!Array.isArray(built))
|
|
365
|
+
return false;
|
|
366
|
+
return built.some((object) => {
|
|
367
|
+
if (!isNamed(object, "trigger", name))
|
|
368
|
+
return false;
|
|
369
|
+
const identity = object.identity;
|
|
370
|
+
return typeof identity === "object" && identity !== null && "parent" in identity && typeof identity.parent === "object" && identity.parent !== null && "name" in identity.parent && identity.parent.name === table;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
function named(built, kind, name) {
|
|
374
|
+
if (!Array.isArray(built))
|
|
375
|
+
return false;
|
|
376
|
+
return built.some((object) => isNamed(object, kind, name));
|
|
377
|
+
}
|
|
378
|
+
function isNamed(object, kind, name) {
|
|
379
|
+
if (typeof object !== "object" || object === null)
|
|
380
|
+
return false;
|
|
381
|
+
if (!("kind" in object) || object.kind !== kind)
|
|
382
|
+
return false;
|
|
383
|
+
if (!("identity" in object) || typeof object.identity !== "object" || object.identity === null)
|
|
384
|
+
return false;
|
|
385
|
+
return "name" in object.identity && object.identity.name === name;
|
|
386
|
+
}
|
|
387
|
+
|
|
259
388
|
// src/runtime/archive-rules.ts
|
|
260
389
|
function installArchiveContributions() {
|
|
261
390
|
installArchiveInspect(archiveContributions);
|
|
@@ -376,6 +505,9 @@ function trait(name, input) {
|
|
|
376
505
|
addFields(name, checked.fields, model, ctx);
|
|
377
506
|
if (input.presets !== undefined)
|
|
378
507
|
addPresets(name, input.presets, model, ctx);
|
|
508
|
+
},
|
|
509
|
+
contribute() {
|
|
510
|
+
return [];
|
|
379
511
|
}
|
|
380
512
|
};
|
|
381
513
|
}
|
|
@@ -398,14 +530,11 @@ function timestamps(options) {
|
|
|
398
530
|
definition(`timestamps() option ${key} is not supported. Accepted options: enforce.`);
|
|
399
531
|
}
|
|
400
532
|
}
|
|
401
|
-
if (options.enforce
|
|
402
|
-
unavailable(`timestamps({ enforce: "trigger" }) is not available yet. It arrives in 0.3.`);
|
|
403
|
-
}
|
|
404
|
-
if (options.enforce !== undefined) {
|
|
533
|
+
if (options.enforce !== undefined && options.enforce !== "trigger") {
|
|
405
534
|
definition(`timestamps() enforce ${String(options.enforce)} must be trigger.`);
|
|
406
535
|
}
|
|
407
536
|
}
|
|
408
|
-
|
|
537
|
+
const base = trait("timestamps", {
|
|
409
538
|
fields: {
|
|
410
539
|
createdAt: stamped(),
|
|
411
540
|
updatedAt: stamped()
|
|
@@ -413,6 +542,14 @@ function timestamps(options) {
|
|
|
413
542
|
touch: ["updatedAt"],
|
|
414
543
|
sealed: ["createdAt", "updatedAt"]
|
|
415
544
|
});
|
|
545
|
+
if (options?.enforce !== "trigger")
|
|
546
|
+
return base;
|
|
547
|
+
return {
|
|
548
|
+
...base,
|
|
549
|
+
contribute(_peers, built) {
|
|
550
|
+
return timestampRecords(built);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
416
553
|
}
|
|
417
554
|
function stamped() {
|
|
418
555
|
return timestamptz2().defaultSql("now()").guarded();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validationGate
|
|
3
|
-
} from "../../shared/
|
|
3
|
+
} from "../../shared/9m80mkac.js";
|
|
4
4
|
import {
|
|
5
5
|
addSchemaHook
|
|
6
|
-
} from "../../shared/
|
|
6
|
+
} from "../../shared/x6wysh83.js";
|
|
7
7
|
import {
|
|
8
8
|
queryHandle
|
|
9
|
-
} from "../../shared/
|
|
9
|
+
} from "../../shared/k34e0xf2.js";
|
|
10
10
|
import {
|
|
11
11
|
OkmError2
|
|
12
12
|
} from "../../shared/52szzakm.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
// src/runtime/validate/load.ts
|
|
15
15
|
var engine;
|
|
16
16
|
function loadEngine() {
|
|
17
|
-
engine ??= import("../../shared/
|
|
17
|
+
engine ??= import("../../shared/c8aghh05.js");
|
|
18
18
|
return engine;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
noticeBuffer,
|
|
3
3
|
WireSession,
|
|
4
4
|
cursorStream
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./0jc3ffzf.js";
|
|
6
6
|
import {
|
|
7
7
|
BUNSQL_CAPABILITIES,
|
|
8
8
|
driverErrors,
|
|
9
9
|
rejectClosed,
|
|
10
10
|
mapFailure,
|
|
11
11
|
runCall
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./rrstp3kb.js";
|
|
13
13
|
|
|
14
14
|
// src/adapters/pg/bunsql.ts
|
|
15
15
|
import { SQL } from "bun";
|
|
@@ -41,7 +41,7 @@ function open5(config) {
|
|
|
41
41
|
counters.busy = Math.max(0, counters.busy - 1);
|
|
42
42
|
});
|
|
43
43
|
const held = { sql, parked, acquireMs, counters, notices, isClosed };
|
|
44
|
-
const checkout = () => closed ? rejectClosed() : import("./
|
|
44
|
+
const checkout = () => closed ? rejectClosed() : import("./fs0ex00p.js").then((mod) => mod.checkout(held));
|
|
45
45
|
return {
|
|
46
46
|
capabilities: BUNSQL_CAPABILITIES,
|
|
47
47
|
execute(text, params, options) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
required
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./c9z5g0fm.js";
|
|
4
4
|
import {
|
|
5
5
|
definition,
|
|
6
6
|
rejected
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./tmbdywx0.js";
|
|
8
8
|
|
|
9
9
|
// src/dialects/pg/temporal.ts
|
|
10
10
|
var TEMPORAL_MISSING = "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.";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import"./
|
|
1
|
+
import"./t616ynfn.js";
|
|
2
2
|
import"./n442h54c.js";
|
|
3
3
|
import {
|
|
4
4
|
listTargets,
|
|
5
5
|
loadConfig
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./5nmdenb6.js";
|
|
7
|
+
import"./2ssqrv66.js";
|
|
7
8
|
|
|
8
9
|
// src/tooling/migrate/dev.ts
|
|
9
10
|
import { mkdirSync } from "node:fs";
|
|
@@ -16,7 +17,7 @@ async function devProject(cwd) {
|
|
|
16
17
|
`;
|
|
17
18
|
const directory = join(cwd, config.out ?? ".okm", "dev-db");
|
|
18
19
|
mkdirSync(directory, { recursive: true });
|
|
19
|
-
const { open } = await import("./
|
|
20
|
+
const { open } = await import("./kgnc8grt.js");
|
|
20
21
|
const pool = await open({ dataDir: directory });
|
|
21
22
|
try {
|
|
22
23
|
await pool.execute("select 1");
|