okmodel 0.5.0 → 0.6.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 +36 -18
- package/dist/adapters/pg/no-inflight-timeout.d.ts +17 -0
- package/dist/adapters/pg/postgres-extra.d.ts +22 -0
- package/dist/contracts/catalog/document.d.ts +19 -5
- package/dist/contracts/catalog/object.d.ts +2 -1
- package/dist/contracts/catalog/policy.d.ts +48 -0
- package/dist/contracts/catalog/types.d.ts +25 -1
- package/dist/contracts/catalog/view.d.ts +2 -0
- package/dist/contracts/internal.js +1 -1
- package/dist/contracts/location.d.ts +10 -0
- package/dist/dialects/pg/column.d.ts +13 -2
- package/dist/dialects/pg/ddl.d.ts +37 -1
- package/dist/dialects/pg/emit.d.ts +19 -1
- package/dist/dialects/pg/errors.d.ts +32 -1
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/pg-trgm.js +1 -1
- package/dist/dialects/pg/filter-parse.d.ts +10 -3
- package/dist/dialects/pg/fn/index.js +10 -2
- package/dist/dialects/pg/index.d.ts +2 -1
- package/dist/dialects/pg/index.js +29 -17
- package/dist/dialects/pg/introspect.d.ts +7 -0
- package/dist/dialects/pg/model.d.ts +7 -2
- package/dist/dialects/pg/ops/or.d.ts +1 -1
- package/dist/dialects/pg/owner.d.ts +42 -0
- package/dist/dialects/pg/path-endpoint.d.ts +20 -0
- package/dist/dialects/pg/role/check.d.ts +3 -0
- package/dist/dialects/pg/role/index.d.ts +71 -6
- package/dist/dialects/pg/role/sql.d.ts +11 -0
- package/dist/dialects/pg/schema.d.ts +2 -0
- package/dist/dialects/pg/table.d.ts +25 -3
- package/dist/dialects/pg/temporal.d.ts +5 -76
- package/dist/dialects/pg/tenancy.d.ts +45 -3
- package/dist/dialects/pg/view/client.d.ts +19 -1
- package/dist/dialects/pg/view/index.d.ts +4 -0
- package/dist/dialects/pg/view/index.js +21 -178
- package/dist/dialects/pg/view/refresh.d.ts +24 -0
- package/dist/runtime/batch.d.ts +1 -1
- package/dist/runtime/client.d.ts +6 -1
- package/dist/runtime/conflict.d.ts +2 -1
- package/dist/runtime/drift.d.ts +9 -0
- package/dist/runtime/inflight.d.ts +14 -0
- package/dist/runtime/pg/bun.js +6 -5
- package/dist/runtime/pg/pg.js +5 -5
- package/dist/runtime/pg/pglite.js +6 -5
- package/dist/runtime/pg/postgresjs.js +5 -5
- package/dist/runtime/plan.d.ts +22 -1
- package/dist/runtime/predicate.d.ts +19 -0
- package/dist/runtime/safety/index.js +1 -1
- package/dist/runtime/tenancy/composite.d.ts +26 -0
- package/dist/runtime/tenancy/context.d.ts +16 -0
- package/dist/runtime/tenancy/index.d.ts +9 -5
- package/dist/runtime/tenancy/index.js +1508 -37
- package/dist/runtime/tenancy/path.d.ts +87 -0
- package/dist/runtime/tenancy/rls.d.ts +67 -0
- package/dist/runtime/tenancy/via.d.ts +22 -0
- package/dist/runtime/traits/index.js +17 -11
- package/dist/runtime/types.d.ts +13 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/runtime/write.d.ts +1 -1
- package/dist/shared/09p049xa.js +702 -0
- package/dist/shared/{ykv7wh5b.js → 1f0xa3cb.js} +5 -5
- package/dist/shared/1nw1f3vs.js +23 -0
- package/dist/shared/{6p5k20sm.js → 1z04fa85.js} +21 -11
- package/dist/shared/{p7pfx624.js → 2cg3wnxc.js} +314 -65
- package/dist/shared/{dyj86cmj.js → 2jd1sn0e.js} +2 -2
- package/dist/shared/{qgvt8nx1.js → 2z7wv5tj.js} +21 -5
- package/dist/shared/{kyxb62mc.js → 31vm914h.js} +9 -1
- package/dist/shared/{sf8m6tfy.js → 32cnm7kn.js} +8 -3
- package/dist/shared/{t4tbsy9h.js → 358zsv4r.js} +1 -1
- package/dist/shared/{jdgqqx31.js → 3fqwmr09.js} +38 -14
- package/dist/shared/{922qbgnw.js → 3qnhc7w5.js} +16 -9
- package/dist/shared/{zvbjc949.js → 4az561fn.js} +1 -1
- package/dist/shared/{k3ted12y.js → 54tqkxja.js} +20 -2
- package/dist/shared/{k7cc9nzk.js → 5d8t84hg.js} +15 -3
- package/dist/shared/{fa9vt245.js → 5j36z8dn.js} +17 -6
- package/dist/shared/{1g0drakv.js → 5yv4k6a6.js} +1 -1
- package/dist/shared/8dqhth8c.js +12 -0
- package/dist/shared/8etn7d8w.js +62 -0
- package/dist/shared/{g516zdsb.js → 8x72s86k.js} +476 -30
- package/dist/shared/{nkc9sfqb.js → 929h19xp.js} +145 -7
- package/dist/shared/{gjthds9j.js → 9628a9xt.js} +1 -1
- package/dist/shared/{8xsbagad.js → 9s0ypp87.js} +88 -7
- package/dist/shared/{b066g80h.js → ag4c7516.js} +2 -2
- package/dist/shared/b3awxn7h.js +45 -0
- package/dist/shared/b4v57v3x.js +9 -0
- package/dist/shared/bdk4sty6.js +58 -0
- package/dist/shared/{s6gqfn5j.js → c58secgj.js} +125 -8
- package/dist/shared/{rrstp3kb.js → cgbamx3e.js} +2 -2
- package/dist/shared/d5azex6s.js +6 -0
- package/dist/shared/{5fqx9yh4.js → dk8v79p3.js} +3 -1
- package/dist/shared/{4m9fn52z.js → ed0b8k4s.js} +1 -1
- package/dist/shared/{z2rnngj4.js → ek2wt2dz.js} +8 -5
- package/dist/shared/{wxn4b7pp.js → f0f1n281.js} +59 -12
- package/dist/shared/{gdh9mrtp.js → g90m9b0g.js} +3 -2
- package/dist/shared/{tbszx8mz.js → gwn6v667.js} +2 -2
- package/dist/shared/{c8aghh05.js → h15jx9bc.js} +8 -2
- package/dist/shared/{3p4b1fg0.js → hazqqecq.js} +17 -93
- package/dist/shared/{4ef7mmqf.js → j3rkk835.js} +34 -11
- package/dist/shared/{bt9sfq0z.js → j60w0dvr.js} +56 -21
- package/dist/shared/{ycatkxmq.js → jgqj11w4.js} +1 -1
- package/dist/shared/k68eedmy.js +85 -0
- package/dist/shared/{szm0cksa.js → knmes2kh.js} +34 -6
- package/dist/shared/{ckjbyrt9.js → mb2ycs1p.js} +7 -9
- package/dist/shared/{tq9afp8d.js → n076ydsc.js} +1 -1
- package/dist/shared/{xhh1srw3.js → nx9hh281.js} +50 -32
- package/dist/shared/{kdkxh3kb.js → p248q79y.js} +58 -59
- package/dist/shared/{990a291j.js → p6bjzq9q.js} +14 -9
- package/dist/shared/{h4nqvjkp.js → pjr6xrm5.js} +2 -2
- package/dist/shared/pz6rj8ay.js +212 -0
- package/dist/shared/{5vdm4sgp.js → q3j1tq7a.js} +36 -23
- package/dist/shared/{8bwbwy8h.js → qq3899ht.js} +128 -18
- package/dist/shared/{dxjp14rk.js → r11n8grd.js} +2 -2
- package/dist/shared/r1fdd0f6.js +19 -0
- package/dist/shared/{8ktwd3rh.js → r3j8s5y0.js} +1 -1
- package/dist/shared/rhs3xe4k.js +7 -0
- package/dist/shared/{jsd07prz.js → rpycarcr.js} +6 -6
- package/dist/shared/{xsq7v6wp.js → sbdme3vy.js} +14 -2
- package/dist/shared/{xdpj5kkm.js → t3g0k88x.js} +775 -264
- package/dist/shared/{ayz64vzj.js → ttmg09vd.js} +708 -19
- package/dist/shared/{r6pj4fq2.js → venqrjna.js} +8 -4
- package/dist/shared/{fancm5pt.js → vjpnzwjz.js} +138 -15
- package/dist/shared/{9tgmr1gh.js → vmfkhszw.js} +44 -9
- package/dist/shared/{wqem4jed.js → wkme6tep.js} +11 -9
- package/dist/shared/{qy9rdq0g.js → wt5rzv1h.js} +15 -11
- package/dist/shared/wxr8cwns.js +6 -0
- package/dist/shared/{bzsjtd7c.js → wynzeggs.js} +19 -14
- package/dist/shared/x3jc53kg.js +220 -0
- package/dist/shared/{7p2wbz7f.js → x72jb7ad.js} +1 -1
- package/dist/shared/{fyqkk1m0.js → xq0mvhts.js} +10 -9
- package/dist/shared/xqve9598.js +53 -0
- package/dist/shared/{47xzb9fc.js → y2t3jktd.js} +2 -2
- package/dist/shared/{9x25fxhc.js → y34a8714.js} +1 -1
- package/dist/shared/{k7dwkhvq.js → y6jdds7g.js} +4 -1
- package/dist/shared/{h8ne16fq.js → ys0xzyaj.js} +1 -1
- package/dist/shared/{c9z5g0fm.js → ywr8hmey.js} +5 -2
- package/dist/shared/{g7ez901n.js → ywspezzx.js} +1 -1
- package/dist/shared/{9m80mkac.js → ze4hxsmy.js} +1 -1
- package/dist/shared/{fb00y8fp.js → zm0mafk4.js} +12 -6
- package/dist/shared/{y005b761.js → zy8r7qvz.js} +6 -2
- package/dist/tooling/cli.js +97 -24
- package/dist/tooling/migrate/apply.d.ts +14 -0
- package/dist/tooling/migrate/check.d.ts +3 -4
- package/dist/tooling/migrate/classify.d.ts +4 -0
- package/dist/tooling/migrate/commands.d.ts +1 -2
- package/dist/tooling/migrate/config.d.ts +3 -2
- package/dist/tooling/migrate/drift.d.ts +1 -1
- package/dist/tooling/migrate/estimate.d.ts +14 -1
- package/dist/tooling/migrate/files.d.ts +11 -1
- package/dist/tooling/migrate/index.js +17 -16
- package/dist/tooling/migrate/lint.d.ts +4 -4
- package/dist/tooling/migrate/lost.d.ts +28 -0
- package/dist/tooling/migrate/paths.d.ts +14 -0
- package/dist/tooling/migrate/plan.d.ts +10 -3
- package/dist/tooling/migrate/policy.d.ts +11 -0
- package/dist/tooling/migrate/runner.d.ts +25 -0
- package/dist/tooling/migrate/sandbox.d.ts +57 -0
- package/dist/tooling/migrate/sql-lex.d.ts +39 -0
- package/dist/tooling/migrate/text.d.ts +42 -0
- package/dist/tooling/node-version.d.ts +21 -0
- package/dist/tooling/testing/factories.d.ts +10 -0
- package/dist/tooling/testing/facts.d.ts +33 -5
- package/dist/tooling/testing/index.d.ts +1 -1
- package/dist/tooling/testing/index.js +3 -3
- package/dist/tooling/testing/isolation.d.ts +15 -8
- package/package.json +10 -6
- package/dist/shared/0v1g424p.js +0 -26
- package/dist/shared/r73pt594.js +0 -426
- package/dist/shared/rasvvzgz.js +0 -21
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
policyObject
|
|
3
|
+
} from "./bdk4sty6.js";
|
|
1
4
|
import {
|
|
2
5
|
functionObject,
|
|
3
6
|
triggerObject
|
|
4
|
-
} from "./
|
|
7
|
+
} from "./y34a8714.js";
|
|
5
8
|
import {
|
|
6
9
|
viewObject,
|
|
7
10
|
materializedViewObject,
|
|
8
11
|
materializedViewIndex
|
|
9
|
-
} from "./
|
|
12
|
+
} from "./zy8r7qvz.js";
|
|
10
13
|
import {
|
|
11
14
|
extensionObject
|
|
12
|
-
} from "./
|
|
15
|
+
} from "./r3j8s5y0.js";
|
|
13
16
|
import {
|
|
14
17
|
dependencyOrder,
|
|
15
18
|
catalog,
|
|
16
19
|
enumType,
|
|
17
20
|
domainType,
|
|
18
21
|
isDomain
|
|
19
|
-
} from "./
|
|
22
|
+
} from "./ywspezzx.js";
|
|
20
23
|
import {
|
|
21
24
|
canonicalJson,
|
|
22
25
|
staticNamespace2,
|
|
@@ -35,7 +38,7 @@ import {
|
|
|
35
38
|
normaliseEdges,
|
|
36
39
|
compareText,
|
|
37
40
|
assertProvenance
|
|
38
|
-
} from "./
|
|
41
|
+
} from "./358zsv4r.js";
|
|
39
42
|
import {
|
|
40
43
|
OWNERS2,
|
|
41
44
|
BUILT_KINDS2,
|
|
@@ -230,9 +233,28 @@ function catalogHash2(source) {
|
|
|
230
233
|
return hash;
|
|
231
234
|
}
|
|
232
235
|
function startupCatalog2(source) {
|
|
233
|
-
|
|
236
|
+
let privileges = false;
|
|
237
|
+
let foreign = false;
|
|
238
|
+
for (const object of source.objects) {
|
|
239
|
+
if (isPrivilege(object))
|
|
240
|
+
privileges = true;
|
|
241
|
+
else if (object.owner !== "managed")
|
|
242
|
+
foreign = true;
|
|
243
|
+
if (privileges && foreign)
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
if (!privileges && !foreign)
|
|
234
247
|
return source;
|
|
235
|
-
return {
|
|
248
|
+
return {
|
|
249
|
+
version: source.version,
|
|
250
|
+
objects: source.objects.flatMap((item) => {
|
|
251
|
+
if (isPrivilege(item))
|
|
252
|
+
return [];
|
|
253
|
+
if (item.owner === "managed")
|
|
254
|
+
return [item];
|
|
255
|
+
return [{ ...item, owner: "managed" }];
|
|
256
|
+
})
|
|
257
|
+
};
|
|
236
258
|
}
|
|
237
259
|
function startupHash2(source) {
|
|
238
260
|
return catalogHash2(startupCatalog2(source));
|
|
@@ -241,12 +263,13 @@ function isPrivilege(object) {
|
|
|
241
263
|
return object.kind === "role" || object.kind === "grant" || object.kind === "defaultPrivilege";
|
|
242
264
|
}
|
|
243
265
|
function loadTrustedCatalog2(text, hash) {
|
|
244
|
-
|
|
266
|
+
const canonical = catalogFileText2(text);
|
|
267
|
+
if (sha2562(canonical) !== hash) {
|
|
245
268
|
catalogError2("OKM1027", "Catalog hash does not match the build artifact.");
|
|
246
269
|
}
|
|
247
270
|
let parsed;
|
|
248
271
|
try {
|
|
249
|
-
parsed = JSON.parse(
|
|
272
|
+
parsed = JSON.parse(canonical);
|
|
250
273
|
} catch {
|
|
251
274
|
catalogError2("OKM1027", "Catalog text is not valid JSON.");
|
|
252
275
|
}
|
|
@@ -260,14 +283,25 @@ function loadTrustedCatalog2(text, hash) {
|
|
|
260
283
|
version: CATALOG_VERSION2,
|
|
261
284
|
objects: parsed.objects
|
|
262
285
|
};
|
|
263
|
-
serializedText.set(loaded,
|
|
286
|
+
serializedText.set(loaded, canonical);
|
|
264
287
|
serializedHash.set(loaded, hash);
|
|
265
288
|
return loaded;
|
|
266
289
|
}
|
|
290
|
+
function catalogFileText2(text, label = "Catalog text") {
|
|
291
|
+
if (text.includes("\x00")) {
|
|
292
|
+
catalogError2("OKM1027", `${label} is UTF-16. Save the file as UTF-8.`, {
|
|
293
|
+
fieldReason: "utf16",
|
|
294
|
+
fix: { summary: "Save the file as UTF-8. This version does not read UTF-16." }
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const withoutBom = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
298
|
+
return withoutBom.replaceAll("\r", "");
|
|
299
|
+
}
|
|
267
300
|
function parseCatalog2(text) {
|
|
301
|
+
const canonical = catalogFileText2(text);
|
|
268
302
|
let parsed;
|
|
269
303
|
try {
|
|
270
|
-
parsed = JSON.parse(
|
|
304
|
+
parsed = JSON.parse(canonical);
|
|
271
305
|
} catch {
|
|
272
306
|
catalogError2("OKM1027", "Catalog text is not valid JSON.");
|
|
273
307
|
}
|
|
@@ -331,6 +365,8 @@ function rewriteRenamed(object, change, fromKey, toIdentity) {
|
|
|
331
365
|
case "grant":
|
|
332
366
|
case "defaultPrivilege":
|
|
333
367
|
return retargeted(object, dependencies);
|
|
368
|
+
case "policy":
|
|
369
|
+
return rewritePolicyColumn(object, change, dependencies);
|
|
334
370
|
case "trigger": {
|
|
335
371
|
const local = sameRef2(object.identity.parent, change.parent);
|
|
336
372
|
return triggerObject({
|
|
@@ -476,7 +512,23 @@ function rewriteView(object, dependencies, query) {
|
|
|
476
512
|
...object.definition.refresh !== undefined ? { refresh: object.definition.refresh } : {}
|
|
477
513
|
});
|
|
478
514
|
}
|
|
479
|
-
return viewObject(
|
|
515
|
+
return viewObject({
|
|
516
|
+
...input,
|
|
517
|
+
...object.definition.securityInvoker === true ? { securityInvoker: true } : {}
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function rewritePolicyColumn(object, change, dependencies) {
|
|
521
|
+
const local = sameRef2(object.identity.parent, change.parent);
|
|
522
|
+
return policyObject({
|
|
523
|
+
parent: object.identity.parent,
|
|
524
|
+
name: object.identity.name,
|
|
525
|
+
command: object.definition.command,
|
|
526
|
+
expression: rewriteExpr(object.definition.expression, change, local),
|
|
527
|
+
force: object.definition.force,
|
|
528
|
+
owner: object.owner,
|
|
529
|
+
provenance: object.provenance,
|
|
530
|
+
dependencies
|
|
531
|
+
});
|
|
480
532
|
}
|
|
481
533
|
function rewriteExpr(text, change, active) {
|
|
482
534
|
if (!active)
|
|
@@ -619,6 +671,20 @@ function rewriteTableName(object, change, fromKey, toIdentity, source) {
|
|
|
619
671
|
...object.definition.when !== undefined ? { when: rewriteExpr(object.definition.when, { from: change.from, to: change.to }, local) } : {}
|
|
620
672
|
});
|
|
621
673
|
}
|
|
674
|
+
if (object.kind === "policy") {
|
|
675
|
+
const parent = movedParent(object.identity.parent, change);
|
|
676
|
+
const local = parent.name !== object.identity.parent.name;
|
|
677
|
+
return policyObject({
|
|
678
|
+
parent,
|
|
679
|
+
name: object.identity.name,
|
|
680
|
+
command: object.definition.command,
|
|
681
|
+
expression: rewriteExpr(object.definition.expression, { from: change.from, to: change.to }, local),
|
|
682
|
+
force: object.definition.force,
|
|
683
|
+
owner: object.owner,
|
|
684
|
+
provenance: object.provenance,
|
|
685
|
+
dependencies
|
|
686
|
+
});
|
|
687
|
+
}
|
|
622
688
|
return assertNever(object);
|
|
623
689
|
}
|
|
624
690
|
function movedParent(parent, change) {
|
|
@@ -837,7 +903,14 @@ function definitionToJson(object) {
|
|
|
837
903
|
dataType: column.dataType,
|
|
838
904
|
name: column.name
|
|
839
905
|
})),
|
|
840
|
-
query: object.definition.query
|
|
906
|
+
query: object.definition.query,
|
|
907
|
+
...object.definition.securityInvoker === true ? { securityInvoker: true } : {}
|
|
908
|
+
};
|
|
909
|
+
case "policy":
|
|
910
|
+
return {
|
|
911
|
+
command: object.definition.command,
|
|
912
|
+
expression: object.definition.expression,
|
|
913
|
+
force: object.definition.force
|
|
841
914
|
};
|
|
842
915
|
case "materializedView":
|
|
843
916
|
return {
|
|
@@ -861,6 +934,8 @@ function parseObject(value) {
|
|
|
861
934
|
const record = requireRecord(value, "catalog object");
|
|
862
935
|
rejectUnknown(record, ["definition", "dependencies", "identity", "kind", "owner", "provenance"], "catalog object");
|
|
863
936
|
const kind = requireString(record.kind, "kind");
|
|
937
|
+
if (kind === "policy")
|
|
938
|
+
return parsePolicy(record);
|
|
864
939
|
if (!isBuiltKind(kind)) {
|
|
865
940
|
catalogError2("OKM1020", `Kind ${kind} is not built yet. Built kinds are ${BUILT_KINDS2.join(", ")}.`);
|
|
866
941
|
}
|
|
@@ -945,7 +1020,7 @@ function parseIndex(identity, definition, owner, provenance, dependencies) {
|
|
|
945
1020
|
catalogError2("OKM1020", `Index object identity is ${identity.kind}, not an index.`);
|
|
946
1021
|
}
|
|
947
1022
|
rejectUnknown(definition, ["columns", "expression", "nameKey", "predicate", "unique"], "index definition");
|
|
948
|
-
|
|
1023
|
+
const shared = {
|
|
949
1024
|
parent: identity.parent,
|
|
950
1025
|
name: identity.name,
|
|
951
1026
|
nameKey: requireString(definition.nameKey, "name key"),
|
|
@@ -956,7 +1031,11 @@ function parseIndex(identity, definition, owner, provenance, dependencies) {
|
|
|
956
1031
|
dependencies,
|
|
957
1032
|
...definition.predicate === undefined ? {} : { predicate: requireString(definition.predicate, "predicate") },
|
|
958
1033
|
...definition.expression === undefined ? {} : { expression: requireString(definition.expression, "expression") }
|
|
959
|
-
}
|
|
1034
|
+
};
|
|
1035
|
+
const onView = dependencies.some((edge) => edge.kind === "view" || edge.kind === "materializedView");
|
|
1036
|
+
if (onView)
|
|
1037
|
+
return materializedViewIndex(shared);
|
|
1038
|
+
return index3(shared);
|
|
960
1039
|
}
|
|
961
1040
|
function parseConstraint(identity, definition, owner, provenance, dependencies) {
|
|
962
1041
|
if (identity.kind !== "constraint") {
|
|
@@ -1140,7 +1219,7 @@ function parseView(kind, identity, definition, owner, provenance, dependencies)
|
|
|
1140
1219
|
if (identity.kind !== kind) {
|
|
1141
1220
|
catalogError2("OKM1020", `View object identity is ${identity.kind}, not a ${kind}.`);
|
|
1142
1221
|
}
|
|
1143
|
-
const fields = kind === "view" ? ["columns", "query"] : ["columns", "query", "refresh"];
|
|
1222
|
+
const fields = kind === "view" ? ["columns", "query", "securityInvoker"] : ["columns", "query", "refresh"];
|
|
1144
1223
|
rejectUnknown(definition, fields, "view definition");
|
|
1145
1224
|
const columns = parseViewColumns(definition.columns);
|
|
1146
1225
|
const query = requireString(definition.query, "view query");
|
|
@@ -1163,7 +1242,38 @@ function parseView(kind, identity, definition, owner, provenance, dependencies)
|
|
|
1163
1242
|
...refresh === "concurrently" ? { refresh: "concurrently" } : {}
|
|
1164
1243
|
});
|
|
1165
1244
|
}
|
|
1166
|
-
|
|
1245
|
+
if (definition.securityInvoker !== undefined && definition.securityInvoker !== true) {
|
|
1246
|
+
catalogError2("OKM1020", `View ${identity.name} securityInvoker must be true when set.`);
|
|
1247
|
+
}
|
|
1248
|
+
return viewObject({
|
|
1249
|
+
...input,
|
|
1250
|
+
...definition.securityInvoker === true ? { securityInvoker: true } : {}
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
function parsePolicy(record) {
|
|
1254
|
+
const identity = parseIdentity(record.identity);
|
|
1255
|
+
if (identity.kind !== "policy") {
|
|
1256
|
+
catalogError2("OKM1020", `Policy object identity is ${identity.kind}, not a policy.`);
|
|
1257
|
+
}
|
|
1258
|
+
const owner = parseOwner(record.owner);
|
|
1259
|
+
const provenance = parseProvenance(record.provenance);
|
|
1260
|
+
const dependencies = parseDependencies(record.dependencies);
|
|
1261
|
+
const definition = requireRecord(record.definition, "definition");
|
|
1262
|
+
rejectUnknown(definition, ["command", "expression", "force"], "policy definition");
|
|
1263
|
+
const command = requireString(definition.command, "policy command");
|
|
1264
|
+
if (command !== "all" && command !== "select") {
|
|
1265
|
+
catalogError2("OKM1020", `Policy ${identity.name} command is not supported.`);
|
|
1266
|
+
}
|
|
1267
|
+
return policyObject({
|
|
1268
|
+
parent: identity.parent,
|
|
1269
|
+
name: identity.name,
|
|
1270
|
+
command,
|
|
1271
|
+
expression: requireString(definition.expression, "policy expression"),
|
|
1272
|
+
force: requireBoolean(definition.force, "policy force"),
|
|
1273
|
+
owner,
|
|
1274
|
+
provenance,
|
|
1275
|
+
dependencies
|
|
1276
|
+
});
|
|
1167
1277
|
}
|
|
1168
1278
|
function parseViewColumns(value) {
|
|
1169
1279
|
if (!Array.isArray(value))
|
|
@@ -1455,4 +1565,4 @@ function assertNeverKind(value) {
|
|
|
1455
1565
|
return catalogError2("OKM1020", `Unexpected kind ${JSON.stringify(value)}.`);
|
|
1456
1566
|
}
|
|
1457
1567
|
|
|
1458
|
-
export { roleObject, grantObject, defaultPrivilegeObject, creationOrder2, renameColumn2, renameTable2, serializeCatalog2, catalogHash2, startupCatalog2, startupHash2, loadTrustedCatalog2, parseCatalog2 };
|
|
1568
|
+
export { roleObject, grantObject, defaultPrivilegeObject, creationOrder2, renameColumn2, renameTable2, serializeCatalog2, catalogHash2, startupCatalog2, startupHash2, loadTrustedCatalog2, catalogFileText2, parseCatalog2 };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkout2,
|
|
3
|
+
describe2,
|
|
4
|
+
stream2,
|
|
5
|
+
watchReserved2,
|
|
6
|
+
holdCheckout2,
|
|
7
|
+
holdListener2,
|
|
8
|
+
watchQuery2
|
|
9
|
+
} from "./q3j1tq7a.js";
|
|
10
|
+
import"./wkme6tep.js";
|
|
11
|
+
export {
|
|
12
|
+
checkout2 as checkout,
|
|
13
|
+
describe2 as describe,
|
|
14
|
+
holdCheckout2 as holdCheckout,
|
|
15
|
+
holdListener2 as holdListener,
|
|
16
|
+
stream2 as stream,
|
|
17
|
+
watchQuery2 as watchQuery,
|
|
18
|
+
watchReserved2 as watchReserved
|
|
19
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
callerLocation,
|
|
3
|
-
withLocation
|
|
4
|
-
} from "./k7dwkhvq.js";
|
|
5
1
|
import {
|
|
6
2
|
definition,
|
|
7
3
|
unavailable
|
|
8
4
|
} from "./tmbdywx0.js";
|
|
5
|
+
import {
|
|
6
|
+
callerLocation,
|
|
7
|
+
withLocation
|
|
8
|
+
} from "./y6jdds7g.js";
|
|
9
9
|
import {
|
|
10
10
|
OkmError2,
|
|
11
11
|
throwNamed2
|
|
@@ -29,7 +29,7 @@ function openFilters(table, relations, spec, hiddenFields) {
|
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
31
|
parse(query) {
|
|
32
|
-
return import("./
|
|
32
|
+
return import("./pz6rj8ay.js").then((mod) => mod.parseQuery(allow, sort, query, nested));
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
@@ -38,7 +38,7 @@ function deny(hiddenFields, table, field) {
|
|
|
38
38
|
return;
|
|
39
39
|
throw new OkmError2("OKM1123", `Field ${table}.${field} is hidden.`, {
|
|
40
40
|
fix: {
|
|
41
|
-
summary: "Remove
|
|
41
|
+
summary: "Remove this hidden field from the allowlist. Hidden fields stay out of caller filter or sort."
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWrite
|
|
3
3
|
} from "./n4jqhpqz.js";
|
|
4
|
+
import {
|
|
5
|
+
refuseUncancellableTimeout
|
|
6
|
+
} from "./b4v57v3x.js";
|
|
4
7
|
import {
|
|
5
8
|
withHttp,
|
|
6
9
|
settleCall
|
|
7
|
-
} from "./
|
|
10
|
+
} from "./j60w0dvr.js";
|
|
8
11
|
import {
|
|
9
12
|
rejectKeys,
|
|
10
13
|
isRecord,
|
|
11
14
|
fail
|
|
12
|
-
} from "./
|
|
15
|
+
} from "./2z7wv5tj.js";
|
|
13
16
|
import {
|
|
14
17
|
OkmError2
|
|
15
18
|
} from "./52szzakm.js";
|
|
@@ -28,6 +31,12 @@ async function batch(session, ops, options, replica) {
|
|
|
28
31
|
if (!isRecord(record))
|
|
29
32
|
fail("OKM1121", "batch options must be an object.");
|
|
30
33
|
rejectKeys(record, ["signal", "timeout"], "batch");
|
|
34
|
+
await refuseUncancellableTimeout(session.pool, typeof record["timeout"] === "number" ? record["timeout"] : undefined);
|
|
35
|
+
for (const op of ops) {
|
|
36
|
+
if (typeof op === "object" && op !== null && op["~refresh"] === true) {
|
|
37
|
+
fail("OKM1121", "batch does not take refresh(). Await refresh() on its own. It is one statement and cannot share the batch.");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
31
40
|
const prepared = [];
|
|
32
41
|
for (const op of ops) {
|
|
33
42
|
const plan = typeof op === "object" && op !== null ? op["~plan"] : undefined;
|
|
@@ -35,6 +44,9 @@ async function batch(session, ops, options, replica) {
|
|
|
35
44
|
fail("OKM1121", "batch takes write operations: insert, update, delete, and archive. Pass them without awaiting.");
|
|
36
45
|
}
|
|
37
46
|
const item = await plan();
|
|
47
|
+
if (item.checked === "parent") {
|
|
48
|
+
throw new OkmError2("OKM1705", "batch does not take an update that sets a path column. The parent is checked in the statement, and a batch cannot report that after it commits. Use update({ where, set }) inside tx().", { fix: { summary: "Use update({ where, set }) inside tx()." } });
|
|
49
|
+
}
|
|
38
50
|
if (item.checked !== undefined) {
|
|
39
51
|
fail("OKM1121", item.checked === "restore" ? "batch does not take restore: it is refused while its parent is archived, and a batch cannot report that after it commits. Use tx()." : "batch does not take a write with expect: the count is checked after the statement ran, and a batch cannot report that after it commits. Use tx().");
|
|
40
52
|
}
|