@datarails-ai/dr-appspace-cli 0.12.87 → 0.12.89
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 +5 -1
- package/dist/cli.js +1188 -209
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { fileURLToPath as fileURLToPath6 } from "url";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@datarails-ai/dr-appspace-cli",
|
|
16
|
-
version: "0.12.
|
|
16
|
+
version: "0.12.89",
|
|
17
17
|
description: "Datarails App Space CLI \u2014 build, try, push and publish App Space apps",
|
|
18
18
|
type: "module",
|
|
19
19
|
engines: {
|
|
@@ -57,7 +57,7 @@ var package_default = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/buildInfo.ts
|
|
60
|
-
var BUILD_TIME = "2026-11-
|
|
60
|
+
var BUILD_TIME = "2026-11-15T18:08:34.863Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -3181,10 +3181,8 @@ function formatUtc(unix) {
|
|
|
3181
3181
|
return `${d.getUTCFullYear()}-${pad2(d.getUTCMonth() + 1)}-${pad2(d.getUTCDate())} ${pad2(d.getUTCHours())}:${pad2(d.getUTCMinutes())}:${pad2(d.getUTCSeconds())} UTC`;
|
|
3182
3182
|
}
|
|
3183
3183
|
|
|
3184
|
-
// src/commands/appspace/
|
|
3185
|
-
import {
|
|
3186
|
-
import { chmod as chmod2, readFile as readFile12, writeFile as writeFile8 } from "fs/promises";
|
|
3187
|
-
import { join as join17 } from "path";
|
|
3184
|
+
// src/commands/appspace/approveHosts.ts
|
|
3185
|
+
import { createInterface } from "readline/promises";
|
|
3188
3186
|
|
|
3189
3187
|
// src/commands/appspace/_client.ts
|
|
3190
3188
|
function withServerOptions(cmd) {
|
|
@@ -3512,6 +3510,97 @@ ${l}`).join("");
|
|
|
3512
3510
|
${detail}`}`;
|
|
3513
3511
|
}
|
|
3514
3512
|
|
|
3513
|
+
// src/commands/appspace/approveHosts.ts
|
|
3514
|
+
function parseHosts(value) {
|
|
3515
|
+
return value.split(",").map((h) => h.trim()).filter((h) => h !== "");
|
|
3516
|
+
}
|
|
3517
|
+
function describeEntries(res) {
|
|
3518
|
+
if (res.entries.length === 0) return "The app declares no outside hosts.\n";
|
|
3519
|
+
const lines = res.entries.map((e) => {
|
|
3520
|
+
const prefix = e.prefix === "" ? "" : ` with prefix ${JSON.stringify(e.prefix)}`;
|
|
3521
|
+
const key = e.secret === null ? "" : `, sends secret ${e.secret} in ${e.header}${prefix}`;
|
|
3522
|
+
const state = e.approved ? "approved" : "WAITS FOR APPROVAL";
|
|
3523
|
+
return `${e.name}: ${e.methods.join("/")} https://${e.host}${key} \u2014 ${state}`;
|
|
3524
|
+
});
|
|
3525
|
+
return lines.join("\n") + "\n";
|
|
3526
|
+
}
|
|
3527
|
+
async function askYes(question, output) {
|
|
3528
|
+
const rl = createInterface({ input: process.stdin, output });
|
|
3529
|
+
try {
|
|
3530
|
+
const answer = await rl.question(question);
|
|
3531
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
3532
|
+
} finally {
|
|
3533
|
+
rl.close();
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
function approvalsPath(appId) {
|
|
3537
|
+
return `/apps/${encodeURIComponent(appId)}/http-approvals`;
|
|
3538
|
+
}
|
|
3539
|
+
function registerApproveHostsCommand(parent) {
|
|
3540
|
+
withJsonOption(
|
|
3541
|
+
withServerOptions(
|
|
3542
|
+
parent.command("approve-hosts <app-id>").description(
|
|
3543
|
+
"List an app's outside hosts, or approve them with --hosts (the app's Owner only, never an agent)."
|
|
3544
|
+
).option("--hosts <hosts>", "comma-separated host names to approve").option("--yes", "approve the entries shown without asking")
|
|
3545
|
+
)
|
|
3546
|
+
).action(async (appId, opts) => {
|
|
3547
|
+
const hosts = opts.hosts === void 0 ? void 0 : parseHosts(opts.hosts);
|
|
3548
|
+
if (hosts !== void 0 && hosts.length === 0) {
|
|
3549
|
+
throw new Error("--hosts needs at least one host name");
|
|
3550
|
+
}
|
|
3551
|
+
const client = await connect(opts);
|
|
3552
|
+
try {
|
|
3553
|
+
let res = await client.request(approvalsPath(appId));
|
|
3554
|
+
if (hosts !== void 0) {
|
|
3555
|
+
const wanted = new Set(hosts);
|
|
3556
|
+
const waiting = res.entries.filter((e) => wanted.has(e.host) && !e.approved);
|
|
3557
|
+
if (waiting.length > 0) {
|
|
3558
|
+
const say = opts.json === true ? process.stderr : process.stdout;
|
|
3559
|
+
say.write(`About to approve for ${appId}:
|
|
3560
|
+
`);
|
|
3561
|
+
say.write(describeEntries({ entries: waiting, pending_hosts: [] }));
|
|
3562
|
+
if (opts.yes !== true) {
|
|
3563
|
+
if (process.stdin.isTTY !== true) {
|
|
3564
|
+
throw new Error("pass --yes to approve without a terminal to confirm on");
|
|
3565
|
+
}
|
|
3566
|
+
if (!await askYes("Approve these? [y/N] ", say)) {
|
|
3567
|
+
throw new Error("not approved");
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
res = await client.request(approvalsPath(appId), {
|
|
3572
|
+
method: "POST",
|
|
3573
|
+
body: { hosts, fingerprints: waiting.map((e) => e.fingerprint) }
|
|
3574
|
+
});
|
|
3575
|
+
}
|
|
3576
|
+
if (opts.json === true) {
|
|
3577
|
+
printJson(res);
|
|
3578
|
+
return;
|
|
3579
|
+
}
|
|
3580
|
+
if (hosts !== void 0) {
|
|
3581
|
+
const done = res.approved ?? [];
|
|
3582
|
+
process.stdout.write(
|
|
3583
|
+
done.length === 0 ? `Nothing new to approve for ${appId}.
|
|
3584
|
+
` : `Approved ${done.join(", ")} for ${appId}.
|
|
3585
|
+
`
|
|
3586
|
+
);
|
|
3587
|
+
}
|
|
3588
|
+
process.stdout.write(describeEntries(res));
|
|
3589
|
+
if (res.approve_with !== void 0) {
|
|
3590
|
+
process.stdout.write(`To approve: ${res.approve_with}
|
|
3591
|
+
`);
|
|
3592
|
+
}
|
|
3593
|
+
} finally {
|
|
3594
|
+
client.cleanup();
|
|
3595
|
+
}
|
|
3596
|
+
});
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
// src/commands/appspace/compare.ts
|
|
3600
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
|
|
3601
|
+
import { chmod as chmod2, readFile as readFile12, writeFile as writeFile8 } from "fs/promises";
|
|
3602
|
+
import { join as join17 } from "path";
|
|
3603
|
+
|
|
3515
3604
|
// src/commands/appspace/_folder.ts
|
|
3516
3605
|
import { readFile, readdir, stat, writeFile as writeFile2 } from "fs/promises";
|
|
3517
3606
|
import { join as join4 } from "path";
|
|
@@ -3563,7 +3652,7 @@ async function readDirIfPresent(path3) {
|
|
|
3563
3652
|
}
|
|
3564
3653
|
async function readUiTree(uiDir) {
|
|
3565
3654
|
const out = [];
|
|
3566
|
-
const
|
|
3655
|
+
const walk6 = async (dir, prefix) => {
|
|
3567
3656
|
for (const name of (await readDirIfPresent(dir)).sort()) {
|
|
3568
3657
|
const full = join4(dir, name);
|
|
3569
3658
|
let entry;
|
|
@@ -3573,14 +3662,14 @@ async function readUiTree(uiDir) {
|
|
|
3573
3662
|
continue;
|
|
3574
3663
|
}
|
|
3575
3664
|
if (entry.isDirectory()) {
|
|
3576
|
-
await
|
|
3665
|
+
await walk6(full, `${prefix}${name}/`);
|
|
3577
3666
|
continue;
|
|
3578
3667
|
}
|
|
3579
3668
|
if (!entry.isFile()) continue;
|
|
3580
3669
|
out.push({ path: `${prefix}${name}`, bytes: await readFile(full) });
|
|
3581
3670
|
}
|
|
3582
3671
|
};
|
|
3583
|
-
await
|
|
3672
|
+
await walk6(uiDir, "");
|
|
3584
3673
|
return out.sort((a, b) => a.path < b.path ? -1 : 1);
|
|
3585
3674
|
}
|
|
3586
3675
|
async function readManifest(dir) {
|
|
@@ -3833,7 +3922,7 @@ endobj
|
|
|
3833
3922
|
0 ${String(objects.length + 1)}
|
|
3834
3923
|
0000000000 65535 f
|
|
3835
3924
|
`;
|
|
3836
|
-
for (const
|
|
3925
|
+
for (const offset2 of offsets) out += `${String(offset2).padStart(10, "0")} 00000 n
|
|
3837
3926
|
`;
|
|
3838
3927
|
out += `trailer
|
|
3839
3928
|
<< /Size ${String(objects.length + 1)} /Root 1 0 R >>
|
|
@@ -4727,8 +4816,8 @@ function parseHtml(html) {
|
|
|
4727
4816
|
let match;
|
|
4728
4817
|
while ((match = TAG.exec(html)) !== null) {
|
|
4729
4818
|
if (match[0].startsWith("<!--")) continue;
|
|
4730
|
-
const [whole,
|
|
4731
|
-
if (
|
|
4819
|
+
const [whole, closing2, rawTag, rawAttrs] = match;
|
|
4820
|
+
if (closing2) continue;
|
|
4732
4821
|
const tag = rawTag.toLowerCase();
|
|
4733
4822
|
const attrs = parseAttrs(rawAttrs);
|
|
4734
4823
|
const line2 = lineAt(html, match.index);
|
|
@@ -4771,9 +4860,9 @@ function parseTree(html) {
|
|
|
4771
4860
|
let match;
|
|
4772
4861
|
while ((match = TAG.exec(html)) !== null) {
|
|
4773
4862
|
if (match[0].startsWith("<!--")) continue;
|
|
4774
|
-
const [whole,
|
|
4863
|
+
const [whole, closing2, rawTag, rawAttrs, selfClosed] = match;
|
|
4775
4864
|
const tag = rawTag.toLowerCase();
|
|
4776
|
-
if (
|
|
4865
|
+
if (closing2) {
|
|
4777
4866
|
const top = stack[stack.length - 1];
|
|
4778
4867
|
if (top === void 0 || nodes[top].tag !== tag) {
|
|
4779
4868
|
wellFormed = false;
|
|
@@ -7293,15 +7382,15 @@ function inputTypeOf(node) {
|
|
|
7293
7382
|
}
|
|
7294
7383
|
function optionsOf(node, text4, tree) {
|
|
7295
7384
|
const options = [];
|
|
7296
|
-
const
|
|
7385
|
+
const walk6 = (index) => {
|
|
7297
7386
|
for (const child of tree.nodes[index].children) {
|
|
7298
7387
|
const candidate = tree.nodes[child];
|
|
7299
7388
|
if (candidate.tag === "option") {
|
|
7300
7389
|
if (!("disabled" in candidate.attrs)) options.push(candidate.attrs.value ?? textOf(text4, candidate));
|
|
7301
|
-
} else
|
|
7390
|
+
} else walk6(child);
|
|
7302
7391
|
}
|
|
7303
7392
|
};
|
|
7304
|
-
|
|
7393
|
+
walk6(node.index);
|
|
7305
7394
|
return options;
|
|
7306
7395
|
}
|
|
7307
7396
|
function splitList(value) {
|
|
@@ -7320,14 +7409,14 @@ function textOf(text4, node) {
|
|
|
7320
7409
|
function slotsOf(node, tree) {
|
|
7321
7410
|
if (!(WIDGET_ATTR in node.attrs)) return {};
|
|
7322
7411
|
const slots = {};
|
|
7323
|
-
const
|
|
7412
|
+
const walk6 = (index) => {
|
|
7324
7413
|
for (const child of tree.nodes[index].children) {
|
|
7325
7414
|
const kind = classify(tree.nodes[child]);
|
|
7326
7415
|
if (kind?.type === "slot") slots[kind.role] = kind.role === "body" ? classesOf(tree.nodes[child])[0] ?? true : true;
|
|
7327
|
-
else
|
|
7416
|
+
else walk6(child);
|
|
7328
7417
|
}
|
|
7329
7418
|
};
|
|
7330
|
-
|
|
7419
|
+
walk6(node.index);
|
|
7331
7420
|
return slots;
|
|
7332
7421
|
}
|
|
7333
7422
|
function bindingOf(entry, node, spec) {
|
|
@@ -8068,15 +8157,15 @@ function hasCycle(tables) {
|
|
|
8068
8157
|
}
|
|
8069
8158
|
}
|
|
8070
8159
|
const state = /* @__PURE__ */ new Map();
|
|
8071
|
-
const
|
|
8160
|
+
const walk6 = (name) => {
|
|
8072
8161
|
if (state.get(name) === "done") return false;
|
|
8073
8162
|
if (state.get(name) === "open") return true;
|
|
8074
8163
|
state.set(name, "open");
|
|
8075
|
-
for (const next of graph.get(name) ?? []) if (
|
|
8164
|
+
for (const next of graph.get(name) ?? []) if (walk6(next)) return true;
|
|
8076
8165
|
state.set(name, "done");
|
|
8077
8166
|
return false;
|
|
8078
8167
|
};
|
|
8079
|
-
return [...graph.keys()].some((name) =>
|
|
8168
|
+
return [...graph.keys()].some((name) => walk6(name));
|
|
8080
8169
|
}
|
|
8081
8170
|
function byProblem(a, b) {
|
|
8082
8171
|
return natural3(a.code, b.code) || natural3(a.where ?? "", b.where ?? "") || natural3(a.message, b.message);
|
|
@@ -9613,16 +9702,16 @@ function payloadProducers(contract, { moduleSource = () => void 0, pageSource =
|
|
|
9613
9702
|
};
|
|
9614
9703
|
const fieldsUnder = (uid) => {
|
|
9615
9704
|
const fields = [];
|
|
9616
|
-
const
|
|
9705
|
+
const walk6 = (at) => {
|
|
9617
9706
|
for (const child of children.get(at) ?? []) {
|
|
9618
9707
|
const element = elements[child];
|
|
9619
9708
|
const field = fieldOf(element);
|
|
9620
9709
|
if (field !== null && !fields.includes(field)) fields.push(field);
|
|
9621
9710
|
if (element?.type === "form" || element?.type === "dialog") continue;
|
|
9622
|
-
|
|
9711
|
+
walk6(child);
|
|
9623
9712
|
}
|
|
9624
9713
|
};
|
|
9625
|
-
|
|
9714
|
+
walk6(uid);
|
|
9626
9715
|
return fields;
|
|
9627
9716
|
};
|
|
9628
9717
|
for (const uid of Object.keys(elements).sort()) {
|
|
@@ -10865,20 +10954,20 @@ function untitledCards(contract) {
|
|
|
10865
10954
|
if (page?.owned === true) continue;
|
|
10866
10955
|
const seen = /* @__PURE__ */ new Set();
|
|
10867
10956
|
const drawn2 = [];
|
|
10868
|
-
const
|
|
10957
|
+
const walk6 = (uids) => {
|
|
10869
10958
|
for (const uid of uids) {
|
|
10870
10959
|
const element = elements[uid];
|
|
10871
10960
|
if (element === void 0 || seen.has(uid)) continue;
|
|
10872
10961
|
seen.add(uid);
|
|
10873
10962
|
if (LAYOUT.has(element.type ?? "")) {
|
|
10874
10963
|
const children = element.children?.length ? element.children : Object.keys(elements).filter((other) => elements[other]?.parent === uid);
|
|
10875
|
-
|
|
10964
|
+
walk6(children);
|
|
10876
10965
|
} else {
|
|
10877
10966
|
drawn2.push(uid);
|
|
10878
10967
|
}
|
|
10879
10968
|
}
|
|
10880
10969
|
};
|
|
10881
|
-
|
|
10970
|
+
walk6(rootsOf(contract, page));
|
|
10882
10971
|
for (const uid of drawn2) {
|
|
10883
10972
|
const element = elements[uid];
|
|
10884
10973
|
const type = element.type ?? "";
|
|
@@ -11971,12 +12060,12 @@ function shelf(path3, kit, charts, contract, problems) {
|
|
|
11971
12060
|
};
|
|
11972
12061
|
}
|
|
11973
12062
|
function appbar(page, elements) {
|
|
11974
|
-
const
|
|
11975
|
-
const summary = typeof
|
|
12063
|
+
const header2 = isPlainObject7(page.header) ? page.header : { title: page.title ?? "", summary: null };
|
|
12064
|
+
const summary = typeof header2.summary === "string" && header2.summary !== "" ? `${text(header2.summary)} ` : "";
|
|
11976
12065
|
return [
|
|
11977
12066
|
`<header class="${classesOf2(elements, "region", "header", ["dr-appbar"])}" data-dr-kit="header">`,
|
|
11978
12067
|
' <div class="dr-appbar__text">',
|
|
11979
|
-
` <h1 class="dr-appbar__title">${text(
|
|
12068
|
+
` <h1 class="dr-appbar__title">${text(header2.title ?? "")}</h1>`,
|
|
11980
12069
|
// The "as of" slot is filled from the payload's own `fetched_at`, so chrome
|
|
11981
12070
|
// that states a time cannot go stale.
|
|
11982
12071
|
` <p class="dr-appbar__summary">`,
|
|
@@ -12301,11 +12390,11 @@ function restateDashboard(composed, pages, handlerName, handler, { refuse: refus
|
|
|
12301
12390
|
}
|
|
12302
12391
|
return uids[0];
|
|
12303
12392
|
};
|
|
12304
|
-
const
|
|
12393
|
+
const header2 = onlyOne(regions("header"), "header region") ?? fresh();
|
|
12305
12394
|
const chrome = HEADER_CHROME.map((role) => onlyOne(regions(role), `${role} region`) ?? fresh());
|
|
12306
|
-
elements[
|
|
12395
|
+
elements[header2] = region(header2, "header", "header", chrome);
|
|
12307
12396
|
chrome.forEach((uid, index) => {
|
|
12308
|
-
elements[uid] = region(uid, HEADER_CHROME[index], "section", [],
|
|
12397
|
+
elements[uid] = region(uid, HEADER_CHROME[index], "section", [], header2);
|
|
12309
12398
|
});
|
|
12310
12399
|
let nav = onlyOne(own2.filter((uid) => typed[uid].type === "nav"), "nav");
|
|
12311
12400
|
const bar = bars.get(path3);
|
|
@@ -12383,7 +12472,7 @@ function restateDashboard(composed, pages, handlerName, handler, { refuse: refus
|
|
|
12383
12472
|
const sections = sectionsOf(page);
|
|
12384
12473
|
const cards = own2.filter((uid) => typed[uid].type === "widget");
|
|
12385
12474
|
const dropped = new Set(own2.filter((uid) => DROPPED.has(typed[uid].type) || typed[uid].type === "region" && DROPPED_REGIONS.has(typed[uid].role ?? "header")));
|
|
12386
|
-
const handled = /* @__PURE__ */ new Set([
|
|
12475
|
+
const handled = /* @__PURE__ */ new Set([header2, ...chrome, filters, ...nav === void 0 ? [] : [nav, ...elements[nav].children], ...parts, ...cards]);
|
|
12387
12476
|
const kept = own2.filter((uid) => !handled.has(uid) && !dropped.has(uid) && !["region", "nav", "tab", "control", "widget"].includes(typed[uid].type));
|
|
12388
12477
|
for (const uid of kept) {
|
|
12389
12478
|
if (conflicts.has(uid)) refuse2(conflicts.get(uid).code, conflicts.get(uid).pointer, conflicts.get(uid).message);
|
|
@@ -12400,7 +12489,7 @@ function restateDashboard(composed, pages, handlerName, handler, { refuse: refus
|
|
|
12400
12489
|
const indexOfSection = (uid) => sections.findIndex((entry) => entry.id === elements[uid]?.section);
|
|
12401
12490
|
const ownRoots = [...parts, ...kept.filter((uid) => elements[uid].parent === null), ...otherRegions].sort((a, b) => rank(a) - rank(b) || natural3(a, b));
|
|
12402
12491
|
const rankedCards = cards.filter((uid) => elements[uid].parent === null).sort((a, b) => indexOfSection(a) - indexOfSection(b) || orderOf(typed[a]) - orderOf(typed[b]) || natural3(a, b));
|
|
12403
|
-
const tree = [
|
|
12492
|
+
const tree = [header2, ...nav === void 0 ? [] : [nav], filters, ...ownRoots, ...rankedCards];
|
|
12404
12493
|
for (const root of tree) inheritSection(root, elements);
|
|
12405
12494
|
const route = routeOf2(app, path3);
|
|
12406
12495
|
const authored = stated2.findIndex((one) => isPlainObject8(one) && one.path === path3);
|
|
@@ -12667,15 +12756,15 @@ function routeOf2(app, path3) {
|
|
|
12667
12756
|
return null;
|
|
12668
12757
|
}
|
|
12669
12758
|
function pageOf(page, tree, params, handlerName, app, sections, route) {
|
|
12670
|
-
const
|
|
12759
|
+
const header2 = isPlainObject8(page.header) ? page.header : {};
|
|
12671
12760
|
const mount = isPlainObject8(page.mount) ? page.mount : {};
|
|
12672
12761
|
const out = {
|
|
12673
12762
|
path: page.path,
|
|
12674
12763
|
route,
|
|
12675
12764
|
title: String(page.title ?? app.name ?? page.path),
|
|
12676
12765
|
header: {
|
|
12677
|
-
title: named5(
|
|
12678
|
-
summary: named5(
|
|
12766
|
+
title: named5(header2.title) ? header2.title : shortTitle(page, named5(app.name) ? app.name : ""),
|
|
12767
|
+
summary: named5(header2.summary) ? header2.summary : null
|
|
12679
12768
|
},
|
|
12680
12769
|
sections,
|
|
12681
12770
|
scripts: [],
|
|
@@ -13006,15 +13095,15 @@ function parseFormula(text4) {
|
|
|
13006
13095
|
}
|
|
13007
13096
|
function formulaNames(node) {
|
|
13008
13097
|
const out = /* @__PURE__ */ new Set();
|
|
13009
|
-
const
|
|
13098
|
+
const walk6 = (one) => {
|
|
13010
13099
|
if (one[0] === "name") out.add(one[1]);
|
|
13011
|
-
else if (one[0] === "neg")
|
|
13100
|
+
else if (one[0] === "neg") walk6(one[1]);
|
|
13012
13101
|
else if (one[0] === "bin" || one[0] === "cmp") {
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
} else if (one[0] === "fn") one[2].forEach(
|
|
13102
|
+
walk6(one[2]);
|
|
13103
|
+
walk6(one[3]);
|
|
13104
|
+
} else if (one[0] === "fn") one[2].forEach(walk6);
|
|
13016
13105
|
};
|
|
13017
|
-
|
|
13106
|
+
walk6(node);
|
|
13018
13107
|
return out;
|
|
13019
13108
|
}
|
|
13020
13109
|
function takesAnOperand(node) {
|
|
@@ -13134,10 +13223,10 @@ function timeModifierProblem(mod) {
|
|
|
13134
13223
|
const shift = SHIFT_RE.exec(mod);
|
|
13135
13224
|
if (shift) {
|
|
13136
13225
|
const unit = shift[1].toLowerCase();
|
|
13137
|
-
const
|
|
13226
|
+
const offset2 = Number(shift[2]);
|
|
13138
13227
|
if (!SHIFT_UNITS.includes(unit)) return `has an invalid SHIFT unit "${shift[1]}" (valid: ${SHIFT_UNITS.join(", ")})`;
|
|
13139
|
-
if (
|
|
13140
|
-
if (Math.abs(
|
|
13228
|
+
if (offset2 > 0) return `has a future SHIFT offset ${shift[2]}; the offset must be negative or zero (e.g. SHIFT(${unit}, -1))`;
|
|
13229
|
+
if (Math.abs(offset2) > MAX_SHIFT_OFFSET_MAGNITUDE) {
|
|
13141
13230
|
return `has a SHIFT offset ${shift[2]} whose magnitude exceeds the server maximum of ${MAX_SHIFT_OFFSET_MAGNITUDE}; use a smaller offset`;
|
|
13142
13231
|
}
|
|
13143
13232
|
return null;
|
|
@@ -13263,8 +13352,8 @@ function scan(formula, declared, pinned = false) {
|
|
|
13263
13352
|
if (pinned && working.includes("|")) {
|
|
13264
13353
|
refuse(`pins a scenario other than ${CALCULATION_PIN}, or pins no operand; a calculation pins an operand to ${CALCULATION_PIN} only, written [@key] | ${CALCULATION_PIN} before its modifier ([@revenue] | ${CALCULATION_PIN}.SHIFT(year, -1))`);
|
|
13265
13354
|
}
|
|
13266
|
-
working = working.replace(SYSTEM_VARIABLE_RE, (token,
|
|
13267
|
-
if (/^\s*\.(?:SHIFT|AS_OF)\(/i.test(whole.slice(
|
|
13355
|
+
working = working.replace(SYSTEM_VARIABLE_RE, (token, offset2, whole) => {
|
|
13356
|
+
if (/^\s*\.(?:SHIFT|AS_OF)\(/i.test(whole.slice(offset2 + token.length))) refuse(modifierOnSystemVariable(token));
|
|
13268
13357
|
return put({ kind: "token", token });
|
|
13269
13358
|
});
|
|
13270
13359
|
if (working.includes("[") || working.includes("]")) refuse("has unbalanced bracket(s); each operand must be wrapped as [@key]");
|
|
@@ -13635,8 +13724,8 @@ function httpProblems(http) {
|
|
|
13635
13724
|
for (const key of ["header", "prefix"]) {
|
|
13636
13725
|
if (Object.hasOwn(entry, key) && secret === null) say(`${at}/${key}`, `${label}.${key} needs ${label}.secret`);
|
|
13637
13726
|
}
|
|
13638
|
-
const
|
|
13639
|
-
if (
|
|
13727
|
+
const header2 = entry.header ?? null;
|
|
13728
|
+
if (header2 !== null && (typeof header2 !== "string" || !HTTP_HEADER_NAME_RE.test(header2) || httpHeaderReserved(header2))) {
|
|
13640
13729
|
say(`${at}/header`, `${label}.header must be an HTTP header name that is not a transport, cookie or proxy header`);
|
|
13641
13730
|
}
|
|
13642
13731
|
const prefix = entry.prefix ?? null;
|
|
@@ -13928,9 +14017,9 @@ function readsMetric(read) {
|
|
|
13928
14017
|
function readTables(contract) {
|
|
13929
14018
|
const tables = [];
|
|
13930
14019
|
const aliased = [];
|
|
13931
|
-
const
|
|
14020
|
+
const walk6 = (node, pointer2) => {
|
|
13932
14021
|
if (Array.isArray(node)) {
|
|
13933
|
-
node.forEach((one, index) =>
|
|
14022
|
+
node.forEach((one, index) => walk6(one, `${pointer2}/${index}`));
|
|
13934
14023
|
return;
|
|
13935
14024
|
}
|
|
13936
14025
|
if (!isPlainObject9(node)) return;
|
|
@@ -13940,9 +14029,9 @@ function readTables(contract) {
|
|
|
13940
14029
|
if (id === null && named5(node.table_alias)) aliased.push(pointer2);
|
|
13941
14030
|
return;
|
|
13942
14031
|
}
|
|
13943
|
-
for (const key of Object.keys(node).sort(natural3))
|
|
14032
|
+
for (const key of Object.keys(node).sort(natural3)) walk6(node[key], `${pointer2}/${escapePointer3(key)}`);
|
|
13944
14033
|
};
|
|
13945
|
-
|
|
14034
|
+
walk6(contract?.data, "/data");
|
|
13946
14035
|
return { tables, aliased };
|
|
13947
14036
|
}
|
|
13948
14037
|
function tableIdOf(value) {
|
|
@@ -15122,7 +15211,7 @@ function tokenValueProblem(value) {
|
|
|
15122
15211
|
if (value.includes("\\")) return "holds a backslash, which escapes what follows it";
|
|
15123
15212
|
if (value.includes("<")) return "holds <, which no CSS value needs";
|
|
15124
15213
|
if (/url\s*\(/i.test(value)) return "holds url(, and a theme loads nothing";
|
|
15125
|
-
const
|
|
15214
|
+
const closing2 = { ")": "(", "]": "[" };
|
|
15126
15215
|
const open3 = [];
|
|
15127
15216
|
let quote = null;
|
|
15128
15217
|
for (const ch of value) {
|
|
@@ -15132,7 +15221,7 @@ function tokenValueProblem(value) {
|
|
|
15132
15221
|
}
|
|
15133
15222
|
if (ch === '"' || ch === "'") quote = ch;
|
|
15134
15223
|
else if (ch === "(" || ch === "[") open3.push(ch);
|
|
15135
|
-
else if (ch in
|
|
15224
|
+
else if (ch in closing2 && open3.pop() !== closing2[ch]) return "holds an unbalanced bracket";
|
|
15136
15225
|
}
|
|
15137
15226
|
if (quote !== null) return "holds an unbalanced quote";
|
|
15138
15227
|
if (open3.length > 0) return "holds an unbalanced bracket";
|
|
@@ -16011,19 +16100,19 @@ function hoistHeaderActions(pages, elements) {
|
|
|
16011
16100
|
let outPages = pages;
|
|
16012
16101
|
for (const [pageIndex, page] of pages.entries()) {
|
|
16013
16102
|
if (page?.owned === true || !Array.isArray(page?.header?.actions) || page.header.actions.length === 0) continue;
|
|
16014
|
-
const
|
|
16015
|
-
if (
|
|
16103
|
+
const header2 = Object.keys(elements).sort(natural3).find((uid) => elements[uid].page === page.path && elements[uid].type === "region" && (elements[uid].role ?? "header") === "header");
|
|
16104
|
+
if (header2 === void 0) continue;
|
|
16016
16105
|
const moved = [];
|
|
16017
16106
|
for (const id of page.header.actions) {
|
|
16018
16107
|
const uid = Object.keys(elements).sort(natural3).find((one) => elements[one].page === page.path && elements[one].type !== "region" && (named5(elements[one].props?.id) ? elements[one].props.id : elements[one].id) === id);
|
|
16019
16108
|
if (uid !== void 0 && !moved.includes(uid)) moved.push(uid);
|
|
16020
16109
|
}
|
|
16021
|
-
const region = out[
|
|
16022
|
-
const already = moved.every((uid) => out[uid].parent ===
|
|
16110
|
+
const region = out[header2];
|
|
16111
|
+
const already = moved.every((uid) => out[uid].parent === header2 && out[uid].section === "header") && JSON.stringify(region.children ?? []) === JSON.stringify(moved);
|
|
16023
16112
|
if (moved.length === 0 || already) continue;
|
|
16024
16113
|
if (out === elements) out = { ...elements };
|
|
16025
|
-
for (const uid of moved) out[uid] = { ...out[uid], parent:
|
|
16026
|
-
out[
|
|
16114
|
+
for (const uid of moved) out[uid] = { ...out[uid], parent: header2, section: "header" };
|
|
16115
|
+
out[header2] = { ...region, children: moved };
|
|
16027
16116
|
if (Array.isArray(page.tree) && page.tree.some((uid) => moved.includes(uid))) {
|
|
16028
16117
|
if (outPages === pages) outPages = [...pages];
|
|
16029
16118
|
outPages[pageIndex] = { ...page, tree: page.tree.filter((uid) => !moved.includes(uid)) };
|
|
@@ -16650,8 +16739,8 @@ function numberPinProblems(elements, pins) {
|
|
|
16650
16739
|
const pin = pins[module];
|
|
16651
16740
|
if (typeof pin !== "string" || drawsPlatformNumbers(pin)) continue;
|
|
16652
16741
|
const need = typeof PLATFORM_NUMBERS2[module] === "string" ? `${module}@${PLATFORM_NUMBERS2[module]}` : `a ${module} release that draws it`;
|
|
16653
|
-
const
|
|
16654
|
-
if (Array.isArray(node)) return node.forEach((child, i) =>
|
|
16742
|
+
const walk6 = (node, at) => {
|
|
16743
|
+
if (Array.isArray(node)) return node.forEach((child, i) => walk6(child, `${at}/${i}`));
|
|
16655
16744
|
if (!isPlainObject9(node)) return;
|
|
16656
16745
|
for (const [key, value] of Object.entries(node)) {
|
|
16657
16746
|
const pointer2 = `${at}/${escapePointer3(key)}`;
|
|
@@ -16662,10 +16751,10 @@ function numberPinProblems(elements, pins) {
|
|
|
16662
16751
|
});
|
|
16663
16752
|
if (key === "format" && isPlatformFormat(value)) say(`format ${JSON.stringify(value)}`);
|
|
16664
16753
|
else if (key === "negative" && value !== void 0 && value !== null) say(`negative ${JSON.stringify(value)}`);
|
|
16665
|
-
else
|
|
16754
|
+
else walk6(value, pointer2);
|
|
16666
16755
|
}
|
|
16667
16756
|
};
|
|
16668
|
-
|
|
16757
|
+
walk6(element.props ?? {}, `/elements/${escapePointer3(uid)}/props`);
|
|
16669
16758
|
}
|
|
16670
16759
|
return problems;
|
|
16671
16760
|
}
|
|
@@ -19499,11 +19588,11 @@ function nodeLines(uid, contract, page, elements, tree, model, depth) {
|
|
|
19499
19588
|
switch (element.type) {
|
|
19500
19589
|
case "region": {
|
|
19501
19590
|
if ((element.role ?? "header") !== "header") return [`${pad}<section data-dr-kit="${attr2(element.role ?? "")}"></section>`];
|
|
19502
|
-
const
|
|
19503
|
-
const heading = named5(
|
|
19504
|
-
const lede = named5(
|
|
19505
|
-
const actions = Array.isArray(
|
|
19506
|
-
const from = named5(
|
|
19591
|
+
const header2 = page.header ?? {};
|
|
19592
|
+
const heading = named5(header2.title) ? header2.title : shortTitle(page, contract.app?.name ?? "");
|
|
19593
|
+
const lede = named5(header2.summary) ? `<p>${text2(header2.summary)}</p>` : "";
|
|
19594
|
+
const actions = Array.isArray(header2.actions) && header2.actions.length > 0 ? ` data-dr-header-actions="${attr2(JSON.stringify(header2.actions))}"` : "";
|
|
19595
|
+
const from = named5(header2.title_from) ? ` data-dr-title-from="${attr2(header2.title_from)}"` : "";
|
|
19507
19596
|
const open3 = `${pad}<header data-dr-kit="header"${gridAttrs(element)}${actions}${from}><h1>${text2(heading)}</h1>${lede}`;
|
|
19508
19597
|
if (kids.length === 0) return [`${open3}</header>`];
|
|
19509
19598
|
return [open3, ...kids.flatMap((child) => nodeLines(child, contract, page, elements, tree, model, depth + 1)), `${pad}</header>`];
|
|
@@ -27305,9 +27394,9 @@ function rootTokens(css) {
|
|
|
27305
27394
|
const out = /* @__PURE__ */ new Map();
|
|
27306
27395
|
const text4 = css.replace(/\/\*[\s\S]*?\*\//g, (hit) => hit.replace(/[^\n]/g, " "));
|
|
27307
27396
|
for (const block of text4.matchAll(/:root\s*\{([^}]*)\}/g)) {
|
|
27308
|
-
const
|
|
27397
|
+
const offset2 = block.index + block[0].indexOf("{");
|
|
27309
27398
|
for (const hit of block[1].matchAll(/(--dr-[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
|
|
27310
|
-
out.set(hit[1], { value: hit[2].trim(), line: lineOf(text4,
|
|
27399
|
+
out.set(hit[1], { value: hit[2].trim(), line: lineOf(text4, offset2 + hit.index) });
|
|
27311
27400
|
}
|
|
27312
27401
|
}
|
|
27313
27402
|
return out;
|
|
@@ -27598,8 +27687,8 @@ function parseHtml2(html) {
|
|
|
27598
27687
|
let match;
|
|
27599
27688
|
while ((match = TAG2.exec(html)) !== null) {
|
|
27600
27689
|
if (match[0].startsWith("<!--")) continue;
|
|
27601
|
-
const [whole,
|
|
27602
|
-
if (
|
|
27690
|
+
const [whole, closing2, rawTag, rawAttrs] = match;
|
|
27691
|
+
if (closing2) continue;
|
|
27603
27692
|
const tag = rawTag.toLowerCase();
|
|
27604
27693
|
const attrs = parseAttrs2(rawAttrs);
|
|
27605
27694
|
const line2 = lineAt2(html, match.index);
|
|
@@ -27642,9 +27731,9 @@ function parseTree2(html) {
|
|
|
27642
27731
|
let match;
|
|
27643
27732
|
while ((match = TAG2.exec(html)) !== null) {
|
|
27644
27733
|
if (match[0].startsWith("<!--")) continue;
|
|
27645
|
-
const [whole,
|
|
27734
|
+
const [whole, closing2, rawTag, rawAttrs, selfClosed] = match;
|
|
27646
27735
|
const tag = rawTag.toLowerCase();
|
|
27647
|
-
if (
|
|
27736
|
+
if (closing2) {
|
|
27648
27737
|
const top = stack[stack.length - 1];
|
|
27649
27738
|
if (top === void 0 || nodes[top].tag !== tag) {
|
|
27650
27739
|
wellFormed = false;
|
|
@@ -29222,15 +29311,15 @@ function inputTypeOf2(node) {
|
|
|
29222
29311
|
}
|
|
29223
29312
|
function optionsOf2(node, text4, tree) {
|
|
29224
29313
|
const options = [];
|
|
29225
|
-
const
|
|
29314
|
+
const walk6 = (index) => {
|
|
29226
29315
|
for (const child of tree.nodes[index].children) {
|
|
29227
29316
|
const candidate = tree.nodes[child];
|
|
29228
29317
|
if (candidate.tag === "option") {
|
|
29229
29318
|
if (!("disabled" in candidate.attrs)) options.push(candidate.attrs.value ?? textOf2(text4, candidate));
|
|
29230
|
-
} else
|
|
29319
|
+
} else walk6(child);
|
|
29231
29320
|
}
|
|
29232
29321
|
};
|
|
29233
|
-
|
|
29322
|
+
walk6(node.index);
|
|
29234
29323
|
return options;
|
|
29235
29324
|
}
|
|
29236
29325
|
function splitList2(value) {
|
|
@@ -29249,14 +29338,14 @@ function textOf2(text4, node) {
|
|
|
29249
29338
|
function slotsOf2(node, tree) {
|
|
29250
29339
|
if (!(WIDGET_ATTR2 in node.attrs)) return {};
|
|
29251
29340
|
const slots = {};
|
|
29252
|
-
const
|
|
29341
|
+
const walk6 = (index) => {
|
|
29253
29342
|
for (const child of tree.nodes[index].children) {
|
|
29254
29343
|
const kind = classify3(tree.nodes[child]);
|
|
29255
29344
|
if (kind?.type === "slot") slots[kind.role] = kind.role === "body" ? classesOf3(tree.nodes[child])[0] ?? true : true;
|
|
29256
|
-
else
|
|
29345
|
+
else walk6(child);
|
|
29257
29346
|
}
|
|
29258
29347
|
};
|
|
29259
|
-
|
|
29348
|
+
walk6(node.index);
|
|
29260
29349
|
return slots;
|
|
29261
29350
|
}
|
|
29262
29351
|
function bindingOf2(entry, node, spec) {
|
|
@@ -29986,15 +30075,15 @@ function hasCycle2(tables) {
|
|
|
29986
30075
|
}
|
|
29987
30076
|
}
|
|
29988
30077
|
const state = /* @__PURE__ */ new Map();
|
|
29989
|
-
const
|
|
30078
|
+
const walk6 = (name) => {
|
|
29990
30079
|
if (state.get(name) === "done") return false;
|
|
29991
30080
|
if (state.get(name) === "open") return true;
|
|
29992
30081
|
state.set(name, "open");
|
|
29993
|
-
for (const next of graph.get(name) ?? []) if (
|
|
30082
|
+
for (const next of graph.get(name) ?? []) if (walk6(next)) return true;
|
|
29994
30083
|
state.set(name, "done");
|
|
29995
30084
|
return false;
|
|
29996
30085
|
};
|
|
29997
|
-
return [...graph.keys()].some((name) =>
|
|
30086
|
+
return [...graph.keys()].some((name) => walk6(name));
|
|
29998
30087
|
}
|
|
29999
30088
|
function byProblem3(a, b) {
|
|
30000
30089
|
return natural5(a.code, b.code) || natural5(a.where ?? "", b.where ?? "") || natural5(a.message, b.message);
|
|
@@ -30554,16 +30643,16 @@ function payloadProducers2(contract, { moduleSource = () => void 0, pageSource =
|
|
|
30554
30643
|
};
|
|
30555
30644
|
const fieldsUnder = (uid) => {
|
|
30556
30645
|
const fields = [];
|
|
30557
|
-
const
|
|
30646
|
+
const walk6 = (at) => {
|
|
30558
30647
|
for (const child of children.get(at) ?? []) {
|
|
30559
30648
|
const element = elements[child];
|
|
30560
30649
|
const field = fieldOf2(element);
|
|
30561
30650
|
if (field !== null && !fields.includes(field)) fields.push(field);
|
|
30562
30651
|
if (element?.type === "form" || element?.type === "dialog") continue;
|
|
30563
|
-
|
|
30652
|
+
walk6(child);
|
|
30564
30653
|
}
|
|
30565
30654
|
};
|
|
30566
|
-
|
|
30655
|
+
walk6(uid);
|
|
30567
30656
|
return fields;
|
|
30568
30657
|
};
|
|
30569
30658
|
for (const uid of Object.keys(elements).sort()) {
|
|
@@ -31625,20 +31714,20 @@ function untitledCards2(contract) {
|
|
|
31625
31714
|
if (page?.owned === true) continue;
|
|
31626
31715
|
const seen = /* @__PURE__ */ new Set();
|
|
31627
31716
|
const drawn2 = [];
|
|
31628
|
-
const
|
|
31717
|
+
const walk6 = (uids) => {
|
|
31629
31718
|
for (const uid of uids) {
|
|
31630
31719
|
const element = elements[uid];
|
|
31631
31720
|
if (element === void 0 || seen.has(uid)) continue;
|
|
31632
31721
|
seen.add(uid);
|
|
31633
31722
|
if (LAYOUT2.has(element.type ?? "")) {
|
|
31634
31723
|
const children = element.children?.length ? element.children : Object.keys(elements).filter((other) => elements[other]?.parent === uid);
|
|
31635
|
-
|
|
31724
|
+
walk6(children);
|
|
31636
31725
|
} else {
|
|
31637
31726
|
drawn2.push(uid);
|
|
31638
31727
|
}
|
|
31639
31728
|
}
|
|
31640
31729
|
};
|
|
31641
|
-
|
|
31730
|
+
walk6(rootsOf3(contract, page));
|
|
31642
31731
|
for (const uid of drawn2) {
|
|
31643
31732
|
const element = elements[uid];
|
|
31644
31733
|
const type = element.type ?? "";
|
|
@@ -32226,9 +32315,9 @@ function rootTokens2(css) {
|
|
|
32226
32315
|
const out = /* @__PURE__ */ new Map();
|
|
32227
32316
|
const text4 = css.replace(/\/\*[\s\S]*?\*\//g, (hit) => hit.replace(/[^\n]/g, " "));
|
|
32228
32317
|
for (const block of text4.matchAll(/:root\s*\{([^}]*)\}/g)) {
|
|
32229
|
-
const
|
|
32318
|
+
const offset2 = block.index + block[0].indexOf("{");
|
|
32230
32319
|
for (const hit of block[1].matchAll(/(--dr-[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
|
|
32231
|
-
out.set(hit[1], { value: hit[2].trim(), line: lineOf2(text4,
|
|
32320
|
+
out.set(hit[1], { value: hit[2].trim(), line: lineOf2(text4, offset2 + hit.index) });
|
|
32232
32321
|
}
|
|
32233
32322
|
}
|
|
32234
32323
|
return out;
|
|
@@ -32507,7 +32596,7 @@ function checkUx(app, contract, contractError) {
|
|
|
32507
32596
|
return out;
|
|
32508
32597
|
};
|
|
32509
32598
|
const nameOf5 = (uid) => said(elements[uid]?.props?.id) ?? said(elements[uid]?.id) ?? uid;
|
|
32510
|
-
const
|
|
32599
|
+
const tableOf5 = (el) => said(el?.props?.entity) ?? said(handlers[el?.props?.source]?.table);
|
|
32511
32600
|
const violations = [];
|
|
32512
32601
|
for (const uid of uids) {
|
|
32513
32602
|
const el = elements[uid];
|
|
@@ -32517,7 +32606,7 @@ function checkUx(app, contract, contractError) {
|
|
|
32517
32606
|
if (!table || handlers[el.props?.action]?.role === "save") continue;
|
|
32518
32607
|
const listing = uids.find((other) => {
|
|
32519
32608
|
const o = elements[other];
|
|
32520
|
-
return o?.page === el.page && ROWS.has(o.type) &&
|
|
32609
|
+
return o?.page === el.page && ROWS.has(o.type) && tableOf5(o) === table && !ancestors(other).some((up) => up.type === "detail");
|
|
32521
32610
|
});
|
|
32522
32611
|
if (!listing) continue;
|
|
32523
32612
|
const label = said(el.props?.label) ?? "New";
|
|
@@ -32534,7 +32623,7 @@ function checkUx(app, contract, contractError) {
|
|
|
32534
32623
|
const el = elements[uid];
|
|
32535
32624
|
if (!ROWS.has(el?.type)) continue;
|
|
32536
32625
|
if (ancestors(uid).some((up) => up.type === "detail")) continue;
|
|
32537
|
-
const table =
|
|
32626
|
+
const table = tableOf5(el);
|
|
32538
32627
|
if (!table || table.startsWith("_") || !isPlainObject17(tables[table]?.columns) || tables[table].singleton === true) continue;
|
|
32539
32628
|
const columns = tables[table].columns;
|
|
32540
32629
|
const pk = Object.keys(columns).find((c) => isPlainObject17(columns[c]) && columns[c].pk === true) ?? "id";
|
|
@@ -32575,7 +32664,7 @@ function checkUx(app, contract, contractError) {
|
|
|
32575
32664
|
for (const uid of uids) {
|
|
32576
32665
|
const el = elements[uid];
|
|
32577
32666
|
if (!ROWS.has(el?.type) || el.type === "data_grid") continue;
|
|
32578
|
-
const table =
|
|
32667
|
+
const table = tableOf5(el);
|
|
32579
32668
|
const columns = isPlainObject17(tables[table]?.columns) ? tables[table].columns : {};
|
|
32580
32669
|
const state = STATE_COLUMNS.find((c) => isPlainObject17(columns[c]) && Array.isArray(columns[c].enum));
|
|
32581
32670
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -34642,9 +34731,9 @@ function livenessLine(report) {
|
|
|
34642
34731
|
return `liveness: not checked \u2014 ${live.skipped.join("; ") || "no reason given"}
|
|
34643
34732
|
`;
|
|
34644
34733
|
}
|
|
34645
|
-
const
|
|
34646
|
-
const line2 =
|
|
34647
|
-
` : `liveness: ${String(
|
|
34734
|
+
const blank5 = live.problems.length;
|
|
34735
|
+
const line2 = blank5 === 0 ? `liveness: ${String(live.widgets)} of ${String(live.widgets)} widget(s) came back with a figure.
|
|
34736
|
+
` : `liveness: ${String(blank5)} of ${String(live.widgets)} widget(s) came back with NO figure.
|
|
34648
34737
|
`;
|
|
34649
34738
|
const others = live.others ?? [];
|
|
34650
34739
|
if (others.length === 0) return line2;
|
|
@@ -35510,6 +35599,910 @@ ${JSON.stringify(res.result, null, 2)}
|
|
|
35510
35599
|
});
|
|
35511
35600
|
}
|
|
35512
35601
|
|
|
35602
|
+
// src/commands/appspace/_writeScan.ts
|
|
35603
|
+
var REACHES_TABLES = /\.\s*(?:data|tables)\b|\.\s*table\b/;
|
|
35604
|
+
var TABLE_WRITE = /\.\s*(insert|update|delete|save|next_number|transaction|assign_author)\b/g;
|
|
35605
|
+
var REACHES_STATE = /\.\s*state\b/;
|
|
35606
|
+
var STATE_WRITE = /\.\s*(set|set_in|delete)\b/g;
|
|
35607
|
+
var REACHES_FILEBOXES = /\bfileboxes\b/;
|
|
35608
|
+
var UPLOAD = /\.\s*upload\b/;
|
|
35609
|
+
var AGENTS = /\.\s*agents\b/;
|
|
35610
|
+
var REACHES_HTTP = /\.\s*http\b/;
|
|
35611
|
+
var HTTP_WRITE = /\.\s*(post|put|patch|delete|request)\b/;
|
|
35612
|
+
var DYNAMIC = new RegExp(
|
|
35613
|
+
[
|
|
35614
|
+
String.raw`\b(?:getattr|setattr|eval|exec|__import__|methodcaller|attrgetter|partial|partialmethod)\b`,
|
|
35615
|
+
String.raw`__getattribute__|__dict__|\bimportlib\b|\bvars\s*\(`,
|
|
35616
|
+
String.raw`\bglobals\s*\(|\blocals\s*\(|\bglobal\b|_getframe|\bf_globals\b|__globals__|__builtins__`,
|
|
35617
|
+
String.raw`\bsys\s*\.\s*modules\b|\bgc\s*\.|\binspect\b`
|
|
35618
|
+
].join("|")
|
|
35619
|
+
);
|
|
35620
|
+
var STRING_PREFIX3 = /^(?:[rRuUfFbBtT]|[rR][bBfFtT]|[bBfFtT][rR])$/;
|
|
35621
|
+
function hasFields(prefix) {
|
|
35622
|
+
return STRING_PREFIX3.test(prefix) && /[fFtT]/.test(prefix);
|
|
35623
|
+
}
|
|
35624
|
+
function prefixAt(code, j) {
|
|
35625
|
+
return /[A-Za-z]*$/.exec(code.slice(Math.max(0, j - 3), j))[0];
|
|
35626
|
+
}
|
|
35627
|
+
function fieldAt(code, j, out) {
|
|
35628
|
+
const from = j;
|
|
35629
|
+
let brackets = 0;
|
|
35630
|
+
let spec = false;
|
|
35631
|
+
while (j < code.length) {
|
|
35632
|
+
const c = code[j];
|
|
35633
|
+
if (spec) {
|
|
35634
|
+
if (c === "}") return j;
|
|
35635
|
+
j = c === "{" ? fieldAt(code, j + 1, out) + 1 : j + 1;
|
|
35636
|
+
continue;
|
|
35637
|
+
}
|
|
35638
|
+
if (c === '"' || c === "'") {
|
|
35639
|
+
j = stringAt(code, j, hasFields(prefixAt(code, j))).end;
|
|
35640
|
+
continue;
|
|
35641
|
+
}
|
|
35642
|
+
if (c === "#") {
|
|
35643
|
+
const end = code.indexOf("\n", j);
|
|
35644
|
+
j = end < 0 ? code.length : end;
|
|
35645
|
+
continue;
|
|
35646
|
+
}
|
|
35647
|
+
if (c === "(" || c === "[" || c === "{") brackets += 1;
|
|
35648
|
+
else if ((c === ")" || c === "]") && brackets > 0) brackets -= 1;
|
|
35649
|
+
else if (c === "}" && brackets > 0) brackets -= 1;
|
|
35650
|
+
else if (c === "}" || c === ":" && brackets === 0) {
|
|
35651
|
+
out.push([from, j]);
|
|
35652
|
+
if (c === "}") return j;
|
|
35653
|
+
spec = true;
|
|
35654
|
+
}
|
|
35655
|
+
j += 1;
|
|
35656
|
+
}
|
|
35657
|
+
if (!spec) out.push([from, j]);
|
|
35658
|
+
return j;
|
|
35659
|
+
}
|
|
35660
|
+
function stringAt(code, i, fields = false) {
|
|
35661
|
+
const ch = code[i];
|
|
35662
|
+
const triple = code.startsWith(ch.repeat(3), i);
|
|
35663
|
+
const close = triple ? ch.repeat(3) : ch;
|
|
35664
|
+
let j = i + close.length;
|
|
35665
|
+
let closed = false;
|
|
35666
|
+
while (j < code.length) {
|
|
35667
|
+
const c = code[j];
|
|
35668
|
+
if (code.startsWith(close, j)) {
|
|
35669
|
+
closed = true;
|
|
35670
|
+
break;
|
|
35671
|
+
}
|
|
35672
|
+
if (c === "\\") j += 2;
|
|
35673
|
+
else if (!triple && c === "\n") break;
|
|
35674
|
+
else if (fields && c === "{") j = code[j + 1] === "{" ? j + 2 : fieldAt(code, j + 1, []) + 1;
|
|
35675
|
+
else j += 1;
|
|
35676
|
+
}
|
|
35677
|
+
const bodyEnd = Math.min(code.length, j);
|
|
35678
|
+
return { close, bodyEnd, end: closed ? j + close.length : bodyEnd };
|
|
35679
|
+
}
|
|
35680
|
+
function fStringFields(body) {
|
|
35681
|
+
const out = [];
|
|
35682
|
+
let i = 0;
|
|
35683
|
+
while (i < body.length) {
|
|
35684
|
+
if (body[i] !== "{") i += 1;
|
|
35685
|
+
else if (body[i + 1] === "{") i += 2;
|
|
35686
|
+
else i = fieldAt(body, i + 1, out) + 1;
|
|
35687
|
+
}
|
|
35688
|
+
return out.sort((a, b) => a[0] - b[0]);
|
|
35689
|
+
}
|
|
35690
|
+
function walk5(code, sink, comments = true) {
|
|
35691
|
+
let i = 0;
|
|
35692
|
+
while (i < code.length) {
|
|
35693
|
+
const ch = code[i];
|
|
35694
|
+
if (ch === "#" && comments) {
|
|
35695
|
+
const end = code.indexOf("\n", i);
|
|
35696
|
+
sink.comment(code.slice(i, end < 0 ? code.length : end));
|
|
35697
|
+
i = end < 0 ? code.length : end;
|
|
35698
|
+
continue;
|
|
35699
|
+
}
|
|
35700
|
+
if (ch === '"' || ch === "'") {
|
|
35701
|
+
const fString = hasFields(sink.prefix());
|
|
35702
|
+
const at = stringAt(code, i, fString);
|
|
35703
|
+
sink.string(at.close, code.slice(i + at.close.length, at.bodyEnd), at.end > at.bodyEnd, fString);
|
|
35704
|
+
i = at.end;
|
|
35705
|
+
continue;
|
|
35706
|
+
}
|
|
35707
|
+
sink.code(ch);
|
|
35708
|
+
i += 1;
|
|
35709
|
+
}
|
|
35710
|
+
}
|
|
35711
|
+
function fieldsOnly(body, inner) {
|
|
35712
|
+
return fStringFields(body).map(([s, e]) => `{${inner(body.slice(s, e))}}`).join("");
|
|
35713
|
+
}
|
|
35714
|
+
function codeOnly(code, comments = true) {
|
|
35715
|
+
let out = "";
|
|
35716
|
+
walk5(
|
|
35717
|
+
code.replace(/\r\n?/g, "\n"),
|
|
35718
|
+
{
|
|
35719
|
+
code: (ch) => {
|
|
35720
|
+
out += ch;
|
|
35721
|
+
},
|
|
35722
|
+
comment: () => void 0,
|
|
35723
|
+
// An unclosed string is closed here: the rest of its line stays code.
|
|
35724
|
+
string: (quote, body, _closed, fString) => {
|
|
35725
|
+
out += fString ? `${quote}${fieldsOnly(body, (field) => codeOnly(field, field.includes("\n")))}${quote}` : `${quote}${quote}`;
|
|
35726
|
+
},
|
|
35727
|
+
// The prefix letters just before the quote (r, b, u, f and their mixes).
|
|
35728
|
+
// `*` always matches, so the match is never null.
|
|
35729
|
+
prefix: () => /[A-Za-z]*$/.exec(out)[0]
|
|
35730
|
+
},
|
|
35731
|
+
comments
|
|
35732
|
+
);
|
|
35733
|
+
return out;
|
|
35734
|
+
}
|
|
35735
|
+
function blank4(text4) {
|
|
35736
|
+
return text4.replace(/[^\n]/g, " ");
|
|
35737
|
+
}
|
|
35738
|
+
function maskCode(code, comments = true) {
|
|
35739
|
+
let out = "";
|
|
35740
|
+
walk5(
|
|
35741
|
+
code,
|
|
35742
|
+
{
|
|
35743
|
+
code: (ch) => {
|
|
35744
|
+
out += ch;
|
|
35745
|
+
},
|
|
35746
|
+
comment: (text4) => {
|
|
35747
|
+
out += blank4(text4);
|
|
35748
|
+
},
|
|
35749
|
+
string: (quote, body, closed, fString) => {
|
|
35750
|
+
let inner = blank4(body);
|
|
35751
|
+
if (fString) {
|
|
35752
|
+
const chars = inner.split("");
|
|
35753
|
+
for (const [s, e] of fStringFields(body)) {
|
|
35754
|
+
const text4 = body.slice(s, e);
|
|
35755
|
+
const field = maskCode(text4, text4.includes("\n"));
|
|
35756
|
+
for (let k = 0; k < field.length; k += 1) chars[s + k] = field[k];
|
|
35757
|
+
}
|
|
35758
|
+
inner = chars.join("");
|
|
35759
|
+
}
|
|
35760
|
+
out += `${quote}${inner}${closed ? quote : ""}`;
|
|
35761
|
+
},
|
|
35762
|
+
prefix: () => /[A-Za-z]*$/.exec(out)[0]
|
|
35763
|
+
},
|
|
35764
|
+
comments
|
|
35765
|
+
);
|
|
35766
|
+
return out;
|
|
35767
|
+
}
|
|
35768
|
+
function writeReasons(code) {
|
|
35769
|
+
const bare = codeOnly(code);
|
|
35770
|
+
const text4 = bare.normalize("NFKC");
|
|
35771
|
+
const reasons = /* @__PURE__ */ new Set();
|
|
35772
|
+
if (REACHES_TABLES.test(text4)) {
|
|
35773
|
+
for (const match of text4.matchAll(TABLE_WRITE)) reasons.add(`a table write (.${match[1]})`);
|
|
35774
|
+
}
|
|
35775
|
+
if (REACHES_STATE.test(text4)) {
|
|
35776
|
+
for (const match of text4.matchAll(STATE_WRITE)) reasons.add(`a state write (.${match[1]})`);
|
|
35777
|
+
}
|
|
35778
|
+
if (REACHES_FILEBOXES.test(text4) && UPLOAD.test(text4)) reasons.add("a filebox upload (ctx.dr.fileboxes.upload)");
|
|
35779
|
+
if (AGENTS.test(text4)) reasons.add("an agent call (ctx.agents): it starts real work");
|
|
35780
|
+
if (REACHES_HTTP.test(text4) && HTTP_WRITE.test(text4))
|
|
35781
|
+
reasons.add("an outgoing HTTP call that is not a GET (ctx.http)");
|
|
35782
|
+
if (DYNAMIC.test(text4)) {
|
|
35783
|
+
reasons.add("dynamic access (getattr, eval, partial, methodcaller, an import by name): the call is not known");
|
|
35784
|
+
}
|
|
35785
|
+
if (/[^\x00-\x7f]/.test(bare)) reasons.add("a name that is not ASCII: the text may hide a call");
|
|
35786
|
+
return [...reasons].sort();
|
|
35787
|
+
}
|
|
35788
|
+
function handlerText(code, lib) {
|
|
35789
|
+
return [
|
|
35790
|
+
code,
|
|
35791
|
+
...Object.keys(lib).sort().map((name) => lib[name])
|
|
35792
|
+
].map((part) => codeOnly(part)).join("\n");
|
|
35793
|
+
}
|
|
35794
|
+
|
|
35795
|
+
// src/commands/appspace/_readActions.ts
|
|
35796
|
+
var STRING_START = /(?:[rRuUfFbBtT]|[rR][bBfFtT]|[bBfFtT][rR])?(['"])/y;
|
|
35797
|
+
var NAME = /[A-Za-z_][A-Za-z0-9_]*/y;
|
|
35798
|
+
var NUMBER2 = /[0-9][0-9A-Za-z_.]*/y;
|
|
35799
|
+
var OPS = [
|
|
35800
|
+
"**=",
|
|
35801
|
+
"//=",
|
|
35802
|
+
">>=",
|
|
35803
|
+
"<<=",
|
|
35804
|
+
"...",
|
|
35805
|
+
"==",
|
|
35806
|
+
"!=",
|
|
35807
|
+
"<=",
|
|
35808
|
+
">=",
|
|
35809
|
+
":=",
|
|
35810
|
+
"->",
|
|
35811
|
+
"+=",
|
|
35812
|
+
"-=",
|
|
35813
|
+
"*=",
|
|
35814
|
+
"/=",
|
|
35815
|
+
"%=",
|
|
35816
|
+
"&=",
|
|
35817
|
+
"|=",
|
|
35818
|
+
"^=",
|
|
35819
|
+
"@=",
|
|
35820
|
+
"**",
|
|
35821
|
+
"//",
|
|
35822
|
+
"<<",
|
|
35823
|
+
">>"
|
|
35824
|
+
];
|
|
35825
|
+
var ASSIGN = /* @__PURE__ */ new Set(["=", ":=", "+=", "-=", "*=", "/=", "//=", "%=", "**=", ">>=", "<<=", "&=", "|=", "^=", "@="]);
|
|
35826
|
+
var OPEN = /* @__PURE__ */ new Set(["(", "[", "{"]);
|
|
35827
|
+
var CLOSE = /* @__PURE__ */ new Set([")", "]", "}"]);
|
|
35828
|
+
function matchAt(re, text4, i) {
|
|
35829
|
+
re.lastIndex = i;
|
|
35830
|
+
return re.exec(text4);
|
|
35831
|
+
}
|
|
35832
|
+
function tokenize4(mask, raw, from = 0, to = mask.length) {
|
|
35833
|
+
const out = [];
|
|
35834
|
+
let i = from;
|
|
35835
|
+
while (i < to) {
|
|
35836
|
+
const ch = mask[i];
|
|
35837
|
+
if (/\s/.test(ch) || ch === "\\") {
|
|
35838
|
+
i += 1;
|
|
35839
|
+
continue;
|
|
35840
|
+
}
|
|
35841
|
+
const str = matchAt(STRING_START, mask, i);
|
|
35842
|
+
if (str !== null) {
|
|
35843
|
+
const q = i + str[0].length - 1;
|
|
35844
|
+
const prefix = str[0].slice(0, -1);
|
|
35845
|
+
const at = stringAt(raw, q, hasFields(prefix));
|
|
35846
|
+
const end = Math.min(at.end, to);
|
|
35847
|
+
const body = raw.slice(q + at.close.length, Math.min(at.bodyEnd, to));
|
|
35848
|
+
const plain = at.close.length === 1 && at.end > at.bodyEnd && prefix === "" && !body.includes("\\") ? { plain: body } : {};
|
|
35849
|
+
out.push({ kind: "str", v: raw.slice(i, end), s: i, e: end, ...plain });
|
|
35850
|
+
if (hasFields(prefix)) {
|
|
35851
|
+
for (const [fs3, fe] of fStringFields(body))
|
|
35852
|
+
out.push(...tokenize4(mask, raw, q + at.close.length + fs3, q + at.close.length + fe));
|
|
35853
|
+
}
|
|
35854
|
+
i = end;
|
|
35855
|
+
continue;
|
|
35856
|
+
}
|
|
35857
|
+
const word = matchAt(NAME, mask, i) ?? matchAt(NUMBER2, mask, i);
|
|
35858
|
+
if (word !== null) {
|
|
35859
|
+
out.push({
|
|
35860
|
+
kind: /^[0-9]/.test(word[0]) ? "num" : "name",
|
|
35861
|
+
v: word[0],
|
|
35862
|
+
s: i,
|
|
35863
|
+
e: i + word[0].length
|
|
35864
|
+
});
|
|
35865
|
+
i += word[0].length;
|
|
35866
|
+
continue;
|
|
35867
|
+
}
|
|
35868
|
+
const op = OPS.find((one) => mask.startsWith(one, i)) ?? ch;
|
|
35869
|
+
out.push({ kind: "op", v: op, s: i, e: i + op.length });
|
|
35870
|
+
i += op.length;
|
|
35871
|
+
}
|
|
35872
|
+
return out;
|
|
35873
|
+
}
|
|
35874
|
+
function closing(t, i) {
|
|
35875
|
+
let depth = 0;
|
|
35876
|
+
for (let k = i; k < t.length; k += 1) {
|
|
35877
|
+
const v = t[k].v;
|
|
35878
|
+
if (OPEN.has(v)) depth += 1;
|
|
35879
|
+
else if (CLOSE.has(v)) {
|
|
35880
|
+
depth -= 1;
|
|
35881
|
+
if (depth === 0) return k;
|
|
35882
|
+
}
|
|
35883
|
+
}
|
|
35884
|
+
return -1;
|
|
35885
|
+
}
|
|
35886
|
+
var GiveUp = class extends Error {
|
|
35887
|
+
};
|
|
35888
|
+
function parseModule(raw) {
|
|
35889
|
+
const mask = maskCode(raw);
|
|
35890
|
+
const lines = mask.split("\n");
|
|
35891
|
+
const lineStart = [];
|
|
35892
|
+
let at = 0;
|
|
35893
|
+
for (const line2 of lines) {
|
|
35894
|
+
lineStart.push(at);
|
|
35895
|
+
at += line2.length + 1;
|
|
35896
|
+
}
|
|
35897
|
+
const lineOf3 = (offset2) => {
|
|
35898
|
+
let lo = 0;
|
|
35899
|
+
let hi = lineStart.length - 1;
|
|
35900
|
+
while (lo < hi) {
|
|
35901
|
+
const mid = lo + hi + 1 >> 1;
|
|
35902
|
+
if (lineStart[mid] <= offset2) lo = mid;
|
|
35903
|
+
else hi = mid - 1;
|
|
35904
|
+
}
|
|
35905
|
+
return lo;
|
|
35906
|
+
};
|
|
35907
|
+
if (/[^\x00-\x7f]/.test(mask)) throw new GiveUp("the code has a name that is not ASCII");
|
|
35908
|
+
const toks = tokenize4(mask, raw);
|
|
35909
|
+
const cont = lines.map(() => false);
|
|
35910
|
+
let depth = 0;
|
|
35911
|
+
let k = 0;
|
|
35912
|
+
for (let line2 = 0; line2 < lines.length; line2 += 1) {
|
|
35913
|
+
if (depth > 0) cont[line2] = true;
|
|
35914
|
+
if (line2 > 0 && /\\\s*$/.test(lines[line2 - 1])) cont[line2] = true;
|
|
35915
|
+
const next = line2 + 1 < lines.length ? lineStart[line2 + 1] : Infinity;
|
|
35916
|
+
while (k < toks.length && toks[k].s < next) {
|
|
35917
|
+
const tok = toks[k];
|
|
35918
|
+
if (OPEN.has(tok.v)) depth += 1;
|
|
35919
|
+
else if (CLOSE.has(tok.v)) depth = Math.max(0, depth - 1);
|
|
35920
|
+
if (tok.kind === "str") for (let l = lineOf3(tok.s) + 1; l <= lineOf3(tok.e - 1); l += 1) cont[l] = true;
|
|
35921
|
+
k += 1;
|
|
35922
|
+
}
|
|
35923
|
+
}
|
|
35924
|
+
const starts = [];
|
|
35925
|
+
for (let line2 = 0; line2 < lines.length; line2 += 1) {
|
|
35926
|
+
const text4 = lines[line2];
|
|
35927
|
+
if (cont[line2] || text4.trim() === "") continue;
|
|
35928
|
+
const lead = /^[ \t\f]*/.exec(text4)[0];
|
|
35929
|
+
if (/[\t\f]/.test(lead)) throw new GiveUp("an indent holds a tab");
|
|
35930
|
+
starts.push({ line: line2, indent: lead.length });
|
|
35931
|
+
}
|
|
35932
|
+
const stmts = starts.map((one, i) => {
|
|
35933
|
+
let headEnd = one.line + 1;
|
|
35934
|
+
while (headEnd < lines.length && cont[headEnd]) headEnd += 1;
|
|
35935
|
+
let end = lines.length;
|
|
35936
|
+
for (let j = i + 1; j < starts.length; j += 1) {
|
|
35937
|
+
if (starts[j].indent <= one.indent) {
|
|
35938
|
+
end = starts[j].line;
|
|
35939
|
+
break;
|
|
35940
|
+
}
|
|
35941
|
+
}
|
|
35942
|
+
return { line: one.line, headEnd, end, indent: one.indent };
|
|
35943
|
+
});
|
|
35944
|
+
return { raw, toks, lineStart, stmts };
|
|
35945
|
+
}
|
|
35946
|
+
function offset(mod, line2) {
|
|
35947
|
+
return line2 < mod.lineStart.length ? mod.lineStart[line2] : mod.raw.length;
|
|
35948
|
+
}
|
|
35949
|
+
function toksIn(mod, s, e) {
|
|
35950
|
+
let lo = 0;
|
|
35951
|
+
let hi = mod.toks.length;
|
|
35952
|
+
while (lo < hi) {
|
|
35953
|
+
const mid = lo + hi >> 1;
|
|
35954
|
+
if (mod.toks[mid].s < s) lo = mid + 1;
|
|
35955
|
+
else hi = mid;
|
|
35956
|
+
}
|
|
35957
|
+
const out = [];
|
|
35958
|
+
for (let k = lo; k < mod.toks.length && mod.toks[k].s < e; k += 1) out.push(mod.toks[k]);
|
|
35959
|
+
return out;
|
|
35960
|
+
}
|
|
35961
|
+
function header(mod, st) {
|
|
35962
|
+
return toksIn(mod, offset(mod, st.line), offset(mod, st.headEnd));
|
|
35963
|
+
}
|
|
35964
|
+
function blockOf(mod, from, to) {
|
|
35965
|
+
const inside2 = mod.stmts.filter((st) => st.line >= from && st.line < to);
|
|
35966
|
+
if (inside2.length === 0) return [];
|
|
35967
|
+
const indent2 = Math.min(...inside2.map((st) => st.indent));
|
|
35968
|
+
return inside2.filter((st) => st.indent === indent2);
|
|
35969
|
+
}
|
|
35970
|
+
function colonAt(t) {
|
|
35971
|
+
let depth = 0;
|
|
35972
|
+
for (let i = 0; i < t.length; i += 1) {
|
|
35973
|
+
const v = t[i].v;
|
|
35974
|
+
if (OPEN.has(v)) depth += 1;
|
|
35975
|
+
else if (CLOSE.has(v)) depth -= 1;
|
|
35976
|
+
else if (v === ":" && depth === 0) return i;
|
|
35977
|
+
}
|
|
35978
|
+
return -1;
|
|
35979
|
+
}
|
|
35980
|
+
var isAction = (tok) => tok?.plain === "action";
|
|
35981
|
+
function payloadExpr(t, i, p) {
|
|
35982
|
+
if (t[i]?.v === p && t[i]?.kind === "name") return i + 1;
|
|
35983
|
+
if (t[i]?.v !== "(" || t[i + 1]?.v !== p || t[i + 2]?.v !== "or") return -1;
|
|
35984
|
+
if (t[i + 3]?.v === "{" && t[i + 4]?.v === "}" && t[i + 5]?.v === ")") return i + 6;
|
|
35985
|
+
if (t[i + 3]?.v === "dict" && t[i + 4]?.v === "(" && t[i + 5]?.v === ")" && t[i + 6]?.v === ")") return i + 7;
|
|
35986
|
+
return -1;
|
|
35987
|
+
}
|
|
35988
|
+
function actionRead(t, i, p) {
|
|
35989
|
+
const j = payloadExpr(t, i, p);
|
|
35990
|
+
if (j < 0) return -1;
|
|
35991
|
+
if (t[j]?.v === "." && t[j + 1]?.v === "get" && t[j + 2]?.v === "(" && isAction(t[j + 3])) {
|
|
35992
|
+
if (t[j + 4]?.v === ")") return j + 5;
|
|
35993
|
+
if (t[j + 4]?.v === "," && t[j + 5]?.plain !== void 0 && t[j + 6]?.v === ")") return j + 7;
|
|
35994
|
+
return -1;
|
|
35995
|
+
}
|
|
35996
|
+
if (t[j]?.v === "[" && isAction(t[j + 1]) && t[j + 2]?.v === "]") return j + 3;
|
|
35997
|
+
return -1;
|
|
35998
|
+
}
|
|
35999
|
+
function actionValue(t, i, p, aliases) {
|
|
36000
|
+
let end = actionRead(t, i, p);
|
|
36001
|
+
let viaAlias = false;
|
|
36002
|
+
if (end < 0 && t[i]?.kind === "name" && aliases.has(t[i].v)) {
|
|
36003
|
+
end = i + 1;
|
|
36004
|
+
viaAlias = true;
|
|
36005
|
+
}
|
|
36006
|
+
if (end < 0 && t[i]?.v === "(") {
|
|
36007
|
+
const inner = actionValue(t, i + 1, p, aliases);
|
|
36008
|
+
if (inner !== null && t[inner.end]?.v === ")") {
|
|
36009
|
+
end = inner.end + 1;
|
|
36010
|
+
viaAlias = inner.viaAlias;
|
|
36011
|
+
}
|
|
36012
|
+
}
|
|
36013
|
+
if (end < 0) return null;
|
|
36014
|
+
if (t[end]?.v === "or" && t[end + 1]?.plain !== void 0) end += 2;
|
|
36015
|
+
return { end, viaAlias };
|
|
36016
|
+
}
|
|
36017
|
+
function literalSet(t, i) {
|
|
36018
|
+
const open3 = t[i]?.v;
|
|
36019
|
+
if (open3 === void 0 || !OPEN.has(open3) || closing(t, i) !== t.length - 1) return null;
|
|
36020
|
+
const items = t.slice(i + 1, t.length - 1);
|
|
36021
|
+
const names = [];
|
|
36022
|
+
for (let k = 0; k < items.length; k += 2) {
|
|
36023
|
+
const item = items[k];
|
|
36024
|
+
if (item.plain === void 0) return null;
|
|
36025
|
+
names.push(item.plain);
|
|
36026
|
+
if (k + 1 < items.length && items[k + 1].v !== ",") return null;
|
|
36027
|
+
}
|
|
36028
|
+
if (names.length === 0 || open3 === "(" && !items.some((tok) => tok.v === ",")) return null;
|
|
36029
|
+
return names;
|
|
36030
|
+
}
|
|
36031
|
+
function actionTest(t, p, aliases) {
|
|
36032
|
+
const value = actionValue(t, 0, p, aliases);
|
|
36033
|
+
if (value !== null) {
|
|
36034
|
+
const op2 = t[value.end]?.v;
|
|
36035
|
+
const lit2 = t[value.end + 1];
|
|
36036
|
+
if ((op2 === "==" || op2 === "!=") && lit2?.plain !== void 0 && value.end + 2 === t.length) {
|
|
36037
|
+
return {
|
|
36038
|
+
names: [lit2.plain],
|
|
36039
|
+
negate: op2 === "!=",
|
|
36040
|
+
viaAlias: value.viaAlias
|
|
36041
|
+
};
|
|
36042
|
+
}
|
|
36043
|
+
const not = op2 === "not" && t[value.end + 1]?.v === "in";
|
|
36044
|
+
if (op2 === "in" || not) {
|
|
36045
|
+
const names = literalSet(t, value.end + (not ? 2 : 1));
|
|
36046
|
+
if (names !== null) return { names, negate: not, viaAlias: value.viaAlias };
|
|
36047
|
+
}
|
|
36048
|
+
return null;
|
|
36049
|
+
}
|
|
36050
|
+
const lit = t[0];
|
|
36051
|
+
const op = t[1]?.v;
|
|
36052
|
+
if (lit?.plain === void 0 || op !== "==" && op !== "!=") return null;
|
|
36053
|
+
const right = actionValue(t, 2, p, aliases);
|
|
36054
|
+
if (right === null || right.end !== t.length) return null;
|
|
36055
|
+
return { names: [lit.plain], negate: op === "!=", viaAlias: right.viaAlias };
|
|
36056
|
+
}
|
|
36057
|
+
var COMPOUND = /* @__PURE__ */ new Set([
|
|
36058
|
+
"if",
|
|
36059
|
+
"elif",
|
|
36060
|
+
"else",
|
|
36061
|
+
"while",
|
|
36062
|
+
"for",
|
|
36063
|
+
"with",
|
|
36064
|
+
"try",
|
|
36065
|
+
"except",
|
|
36066
|
+
"finally",
|
|
36067
|
+
"def",
|
|
36068
|
+
"class",
|
|
36069
|
+
"async",
|
|
36070
|
+
"match",
|
|
36071
|
+
"case"
|
|
36072
|
+
]);
|
|
36073
|
+
var BINDS_AFTER = /* @__PURE__ */ new Set(["as", "global", "nonlocal", "del", "import", "def", "class", "lambda", "case"]);
|
|
36074
|
+
function boundNames(t) {
|
|
36075
|
+
const out = [];
|
|
36076
|
+
const names = (from2, to) => {
|
|
36077
|
+
for (let k = from2; k < to; k += 1) if (t[k].kind === "name") out.push(t[k]);
|
|
36078
|
+
};
|
|
36079
|
+
let from = 0;
|
|
36080
|
+
if (COMPOUND.has(t[0]?.v ?? "")) {
|
|
36081
|
+
const colon = colonAt(t);
|
|
36082
|
+
from = colon < 0 ? t.length : colon + 1;
|
|
36083
|
+
}
|
|
36084
|
+
let lastAssign = -1;
|
|
36085
|
+
let depth = 0;
|
|
36086
|
+
for (let k = from; k < t.length; k += 1) {
|
|
36087
|
+
const v = t[k].v;
|
|
36088
|
+
if (OPEN.has(v)) depth += 1;
|
|
36089
|
+
else if (CLOSE.has(v)) depth -= 1;
|
|
36090
|
+
else if (v === "=" && depth === 0) lastAssign = k;
|
|
36091
|
+
}
|
|
36092
|
+
if (lastAssign >= 0) names(from, lastAssign);
|
|
36093
|
+
const upTo = (k, stops) => {
|
|
36094
|
+
let j = k + 1;
|
|
36095
|
+
while (j < t.length && !stops.includes(t[j].v)) j += 1;
|
|
36096
|
+
return j;
|
|
36097
|
+
};
|
|
36098
|
+
for (let k = 0; k < t.length; k += 1) {
|
|
36099
|
+
const v = t[k].v;
|
|
36100
|
+
if (ASSIGN.has(v) && v !== "=" && t[k - 1]?.kind === "name") out.push(t[k - 1]);
|
|
36101
|
+
if (v === "for") names(k + 1, upTo(k, ["in"]));
|
|
36102
|
+
if (BINDS_AFTER.has(v)) names(k + 1, upTo(k, [":", "="]));
|
|
36103
|
+
}
|
|
36104
|
+
return out;
|
|
36105
|
+
}
|
|
36106
|
+
function tableOf4(t, st) {
|
|
36107
|
+
if (t[0]?.kind !== "name" || t[1]?.v !== "=" || t[2]?.v !== "{" || closing(t, 2) !== t.length - 1) return null;
|
|
36108
|
+
const entries = /* @__PURE__ */ new Map();
|
|
36109
|
+
const body = t.slice(3, t.length - 1);
|
|
36110
|
+
for (let k = 0; k < body.length; k += 4) {
|
|
36111
|
+
const [key, colon, fn, comma] = [body[k], body[k + 1], body[k + 2], body[k + 3]];
|
|
36112
|
+
if (key?.plain === void 0 || colon?.v !== ":" || fn?.kind !== "name") return null;
|
|
36113
|
+
if (comma !== void 0 && comma.v !== ",") return null;
|
|
36114
|
+
entries.set(key.plain, fn.v);
|
|
36115
|
+
}
|
|
36116
|
+
return entries.size > 0 ? { name: t[0].v, stmt: st, entries } : null;
|
|
36117
|
+
}
|
|
36118
|
+
function readUnit(mod, aliases) {
|
|
36119
|
+
const top = blockOf(mod, 0, Infinity);
|
|
36120
|
+
if (top.length > 0 && top[0].indent !== 0) throw new GiveUp("a module starts with an indent");
|
|
36121
|
+
const unit = { mod, defs: /* @__PURE__ */ new Map(), seeds: [] };
|
|
36122
|
+
const tables = [];
|
|
36123
|
+
const handle = [];
|
|
36124
|
+
let decorated = false;
|
|
36125
|
+
for (const st of top) {
|
|
36126
|
+
const t = header(mod, st);
|
|
36127
|
+
const whole = {
|
|
36128
|
+
mod,
|
|
36129
|
+
s: offset(mod, st.line),
|
|
36130
|
+
e: offset(mod, st.end)
|
|
36131
|
+
};
|
|
36132
|
+
const first = t[0].v;
|
|
36133
|
+
const isDef = first === "def" || first === "async" && t[1]?.v === "def";
|
|
36134
|
+
if (first === "@" || first === "class" || isDef && decorated) {
|
|
36135
|
+
unit.seeds.push(whole);
|
|
36136
|
+
decorated = first === "@";
|
|
36137
|
+
continue;
|
|
36138
|
+
}
|
|
36139
|
+
decorated = false;
|
|
36140
|
+
if (isDef) {
|
|
36141
|
+
const name = t[first === "def" ? 1 : 2].v;
|
|
36142
|
+
if (/^__\w+__$/.test(name)) {
|
|
36143
|
+
unit.seeds.push(whole);
|
|
36144
|
+
continue;
|
|
36145
|
+
}
|
|
36146
|
+
if (name === "handle") handle.push(st);
|
|
36147
|
+
unit.defs.set(name, [...unit.defs.get(name) ?? [], [whole.s, whole.e]]);
|
|
36148
|
+
continue;
|
|
36149
|
+
}
|
|
36150
|
+
if (first === "import" || first === "from") {
|
|
36151
|
+
for (let k = 0; k + 2 < t.length; k += 1) {
|
|
36152
|
+
if (t[k + 1].v === "as" && t[k].kind === "name") {
|
|
36153
|
+
const alias = t[k + 2].v;
|
|
36154
|
+
aliases.set(alias, /* @__PURE__ */ new Set([...aliases.get(alias) ?? [], t[k].v]));
|
|
36155
|
+
}
|
|
36156
|
+
}
|
|
36157
|
+
unit.seeds.push({ ...whole, noMentions: true });
|
|
36158
|
+
continue;
|
|
36159
|
+
}
|
|
36160
|
+
const table = tableOf4(t, st);
|
|
36161
|
+
if (table !== null) tables.push(table);
|
|
36162
|
+
unit.seeds.push(whole);
|
|
36163
|
+
}
|
|
36164
|
+
return { unit, tables, handle };
|
|
36165
|
+
}
|
|
36166
|
+
function readDispatch(mod, handle, tables) {
|
|
36167
|
+
const head = header(mod, handle);
|
|
36168
|
+
if (head[head.length - 1].v !== ":") throw new GiveUp("`handle` has its body on the def line");
|
|
36169
|
+
const open3 = head.findIndex((tok) => tok.v === "(");
|
|
36170
|
+
const shut = closing(head, open3);
|
|
36171
|
+
const params = [];
|
|
36172
|
+
for (let k = open3 + 1, depth = 0, fresh = true; k < shut; k += 1) {
|
|
36173
|
+
const v = head[k].v;
|
|
36174
|
+
if (OPEN.has(v)) depth += 1;
|
|
36175
|
+
else if (CLOSE.has(v)) depth -= 1;
|
|
36176
|
+
else if (v === "," && depth === 0) fresh = true;
|
|
36177
|
+
else if (fresh && depth === 0) {
|
|
36178
|
+
params.push(head[k].kind === "name" ? v : "");
|
|
36179
|
+
fresh = false;
|
|
36180
|
+
}
|
|
36181
|
+
}
|
|
36182
|
+
const p = params[1];
|
|
36183
|
+
if (p === void 0 || p === "") throw new GiveUp("`handle` has no plain second parameter (the payload)");
|
|
36184
|
+
const bodyFrom = offset(mod, handle.headEnd);
|
|
36185
|
+
const bodyTo = offset(mod, handle.end);
|
|
36186
|
+
const body = blockOf(mod, handle.headEnd, handle.end);
|
|
36187
|
+
const inBody = mod.stmts.filter((st) => st.line >= handle.headEnd && st.line < handle.end);
|
|
36188
|
+
const lines = inBody.map((st) => ({ st, t: header(mod, st) }));
|
|
36189
|
+
const bodyToks = toksIn(mod, bodyFrom, bodyTo);
|
|
36190
|
+
const binds = /* @__PURE__ */ new Map();
|
|
36191
|
+
for (const { t } of lines) for (const tok of boundNames(t)) binds.set(tok.v, [...binds.get(tok.v) ?? [], tok]);
|
|
36192
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
36193
|
+
const aliasAt = /* @__PURE__ */ new Map();
|
|
36194
|
+
for (const st of body) {
|
|
36195
|
+
const t = header(mod, st);
|
|
36196
|
+
if (t[0]?.kind === "name" && t[1]?.v === "=" && actionValue(t, 2, p, /* @__PURE__ */ new Set())?.end === t.length) {
|
|
36197
|
+
const name = t[0].v;
|
|
36198
|
+
if (binds.get(name).length === 1) {
|
|
36199
|
+
aliases.add(name);
|
|
36200
|
+
aliasAt.set(name, t[0].s);
|
|
36201
|
+
}
|
|
36202
|
+
}
|
|
36203
|
+
}
|
|
36204
|
+
const reset = /* @__PURE__ */ new Set();
|
|
36205
|
+
for (const st of body) {
|
|
36206
|
+
const t = header(mod, st);
|
|
36207
|
+
const rest = t.slice(2).map((tok) => tok.v).join(" ");
|
|
36208
|
+
if (t[0]?.v === p && t[1]?.v === "=" && (rest === `${p} or { }` || rest === `${p} or dict ( )`)) {
|
|
36209
|
+
reset.add(t[0].s);
|
|
36210
|
+
reset.add(t[2].s);
|
|
36211
|
+
}
|
|
36212
|
+
}
|
|
36213
|
+
if ((binds.get(p) ?? []).some((tok) => !reset.has(tok.s))) throw new GiveUp("`handle` binds the payload again");
|
|
36214
|
+
const decisions = [];
|
|
36215
|
+
const chains = /* @__PURE__ */ new Map();
|
|
36216
|
+
const actions = /* @__PURE__ */ new Set();
|
|
36217
|
+
for (let i = 0; i < body.length; i += 1) {
|
|
36218
|
+
const t = header(mod, body[i]);
|
|
36219
|
+
if (t[0]?.v !== "if") continue;
|
|
36220
|
+
const test = actionTest(t.slice(1, colonAt(t)), p, aliases);
|
|
36221
|
+
if (test === null) continue;
|
|
36222
|
+
const chain = [{ st: body[i], test, t }];
|
|
36223
|
+
for (let j = i + 1; j < body.length; j += 1) {
|
|
36224
|
+
const u = header(mod, body[j]);
|
|
36225
|
+
if (u[0]?.v === "elif")
|
|
36226
|
+
chain.push({
|
|
36227
|
+
st: body[j],
|
|
36228
|
+
test: actionTest(u.slice(1, colonAt(u)), p, aliases),
|
|
36229
|
+
t: u
|
|
36230
|
+
});
|
|
36231
|
+
else if (u[0]?.v === "else") chain.push({ st: body[j], test: null, t: u });
|
|
36232
|
+
else break;
|
|
36233
|
+
if (u[0]?.v === "else") break;
|
|
36234
|
+
}
|
|
36235
|
+
chains.set(body[i], chain);
|
|
36236
|
+
for (const one of chain) {
|
|
36237
|
+
if (one.test === null) continue;
|
|
36238
|
+
one.test.names.forEach((name) => actions.add(name));
|
|
36239
|
+
decisions.push({ at: one.t[0].s, viaAlias: one.test.viaAlias });
|
|
36240
|
+
}
|
|
36241
|
+
i += chain.length - 1;
|
|
36242
|
+
}
|
|
36243
|
+
const lookups = [];
|
|
36244
|
+
const named13 = new Map(tables.map((table) => [table.name, table]));
|
|
36245
|
+
const plainUse = /* @__PURE__ */ new Set();
|
|
36246
|
+
for (let k = 0; k < bodyToks.length; k += 1) {
|
|
36247
|
+
const tok = bodyToks[k];
|
|
36248
|
+
const table = named13.get(tok.v);
|
|
36249
|
+
if (tok.kind !== "name" || table === void 0) continue;
|
|
36250
|
+
let found = null;
|
|
36251
|
+
if (bodyToks[k - 1]?.v !== "." && bodyToks[k + 1]?.v === "." && bodyToks[k + 2]?.v === "get" && bodyToks[k + 3]?.v === "(") {
|
|
36252
|
+
const value = actionValue(bodyToks, k + 4, p, aliases);
|
|
36253
|
+
const shut2 = closing(bodyToks, k + 3);
|
|
36254
|
+
if (value !== null && shut2 > 0 && (bodyToks[value.end]?.v === ")" || bodyToks[value.end]?.v === ",")) {
|
|
36255
|
+
const fallback = bodyToks[value.end]?.v === "," && value.end + 1 < shut2 ? [bodyToks[value.end + 1].s, bodyToks[shut2 - 1].e] : null;
|
|
36256
|
+
if (bodyToks[value.end]?.v === ")" || fallback !== null) {
|
|
36257
|
+
found = {
|
|
36258
|
+
table,
|
|
36259
|
+
s: tok.s,
|
|
36260
|
+
e: bodyToks[shut2].e,
|
|
36261
|
+
fallback,
|
|
36262
|
+
at: tok.s,
|
|
36263
|
+
viaAlias: value.viaAlias
|
|
36264
|
+
};
|
|
36265
|
+
}
|
|
36266
|
+
}
|
|
36267
|
+
} else if (bodyToks[k - 1]?.v !== "." && bodyToks[k + 1]?.v === "[") {
|
|
36268
|
+
const value = actionValue(bodyToks, k + 2, p, aliases);
|
|
36269
|
+
if (value !== null && bodyToks[value.end]?.v === "]") {
|
|
36270
|
+
found = {
|
|
36271
|
+
table,
|
|
36272
|
+
s: tok.s,
|
|
36273
|
+
e: bodyToks[value.end].e,
|
|
36274
|
+
fallback: null,
|
|
36275
|
+
at: tok.s,
|
|
36276
|
+
viaAlias: value.viaAlias
|
|
36277
|
+
};
|
|
36278
|
+
}
|
|
36279
|
+
}
|
|
36280
|
+
if (found === null) plainUse.add(table.name);
|
|
36281
|
+
else lookups.push(found);
|
|
36282
|
+
}
|
|
36283
|
+
for (const table of tables) {
|
|
36284
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
36285
|
+
mod.toks.find((tok) => tok.s >= offset(mod, table.stmt.line)).s,
|
|
36286
|
+
...lookups.filter((one) => one.table === table).map((one) => one.s)
|
|
36287
|
+
]);
|
|
36288
|
+
if (mod.toks.some((tok) => tok.kind === "name" && tok.v === table.name && !allowed.has(tok.s)))
|
|
36289
|
+
plainUse.add(table.name);
|
|
36290
|
+
}
|
|
36291
|
+
const used = lookups.filter((one) => !plainUse.has(one.table.name));
|
|
36292
|
+
for (const one of used) {
|
|
36293
|
+
one.table.entries.forEach((_fn, name) => actions.add(name));
|
|
36294
|
+
decisions.push({ at: one.at, viaAlias: one.viaAlias });
|
|
36295
|
+
}
|
|
36296
|
+
actions.delete("");
|
|
36297
|
+
if (actions.size === 0) throw new GiveUp('`handle` has no dispatch on payload["action"] that this check can read');
|
|
36298
|
+
for (const one of decisions) {
|
|
36299
|
+
const around = inBody.filter((st) => offset(mod, st.line) <= one.at && one.at < offset(mod, st.end));
|
|
36300
|
+
for (const st of around) {
|
|
36301
|
+
const t = header(mod, st);
|
|
36302
|
+
const first = t[0]?.v === "async" ? t[1]?.v : t[0]?.v;
|
|
36303
|
+
if (["for", "while", "def", "class"].includes(first)) {
|
|
36304
|
+
throw new GiveUp("`handle` reads the action in a loop or a nested function");
|
|
36305
|
+
}
|
|
36306
|
+
if (one.at < offset(mod, st.headEnd) && t.some((tok) => tok.v === "lambda" || tok.v === "for")) {
|
|
36307
|
+
throw new GiveUp("`handle` reads the action in a lambda or a comprehension");
|
|
36308
|
+
}
|
|
36309
|
+
}
|
|
36310
|
+
}
|
|
36311
|
+
const chainSpans = [...chains.values()].map((chain) => [
|
|
36312
|
+
offset(mod, chain[0].st.line),
|
|
36313
|
+
offset(mod, chain[chain.length - 1].st.end)
|
|
36314
|
+
]);
|
|
36315
|
+
const sameChain = (a, b) => chainSpans.some(([s, e]) => s <= a && a < e && s <= b && b < e);
|
|
36316
|
+
const reads = [
|
|
36317
|
+
...decisions.filter((one) => !one.viaAlias).map((one) => one.at),
|
|
36318
|
+
...decisions.some((one) => one.viaAlias) ? [...aliasAt.values()] : []
|
|
36319
|
+
];
|
|
36320
|
+
const lineStarts = new Set(lines.flatMap(({ t }) => t[0] === void 0 ? [] : [t[0].s]));
|
|
36321
|
+
for (let k = 0; k < bodyToks.length; k += 1) {
|
|
36322
|
+
const tok = bodyToks[k];
|
|
36323
|
+
if (tok.kind !== "name" || tok.v !== p || bodyToks[k - 1]?.v === "." || safeUse(bodyToks, k, reset, lineStarts))
|
|
36324
|
+
continue;
|
|
36325
|
+
if (reads.some((at) => tok.s < at && !sameChain(tok.s, at))) {
|
|
36326
|
+
throw new GiveUp("`handle` passes or changes the payload before it reads the action");
|
|
36327
|
+
}
|
|
36328
|
+
}
|
|
36329
|
+
const piecesFor = (action) => {
|
|
36330
|
+
const pieces = [{ mod, s: offset(mod, handle.line), e: offset(mod, handle.headEnd) }];
|
|
36331
|
+
const whole = (st) => ({
|
|
36332
|
+
mod,
|
|
36333
|
+
s: offset(mod, st.line),
|
|
36334
|
+
e: offset(mod, st.end)
|
|
36335
|
+
});
|
|
36336
|
+
const bodyOf = (st, t) => {
|
|
36337
|
+
const colon = colonAt(t);
|
|
36338
|
+
return {
|
|
36339
|
+
mod,
|
|
36340
|
+
s: colon === t.length - 1 ? offset(mod, st.headEnd) : t[colon].e,
|
|
36341
|
+
e: offset(mod, st.end)
|
|
36342
|
+
};
|
|
36343
|
+
};
|
|
36344
|
+
for (let i = 0; i < body.length; i += 1) {
|
|
36345
|
+
const chain = chains.get(body[i]);
|
|
36346
|
+
if (chain === void 0) {
|
|
36347
|
+
pieces.push(whole(body[i]));
|
|
36348
|
+
continue;
|
|
36349
|
+
}
|
|
36350
|
+
for (let c = 0; c < chain.length; c += 1) {
|
|
36351
|
+
const one = chain[c];
|
|
36352
|
+
if (one.test === null && one.t[0].v !== "else") {
|
|
36353
|
+
for (const rest of chain.slice(c)) pieces.push(whole(rest.st));
|
|
36354
|
+
break;
|
|
36355
|
+
}
|
|
36356
|
+
if (one.test === null || one.test.names.includes(action) !== one.test.negate) {
|
|
36357
|
+
pieces.push(bodyOf(one.st, one.t));
|
|
36358
|
+
break;
|
|
36359
|
+
}
|
|
36360
|
+
}
|
|
36361
|
+
i += chain.length - 1;
|
|
36362
|
+
}
|
|
36363
|
+
const mentions3 = [];
|
|
36364
|
+
const self = head.find((tok) => tok.v === "handle");
|
|
36365
|
+
const skip2 = [[self.s, self.e]];
|
|
36366
|
+
for (const one of used) {
|
|
36367
|
+
skip2.push([one.s, one.e]);
|
|
36368
|
+
const fn = one.table.entries.get(action);
|
|
36369
|
+
if (fn !== void 0) mentions3.push(fn);
|
|
36370
|
+
if (one.fallback !== null) {
|
|
36371
|
+
for (const tok of toksIn(mod, one.fallback[0], one.fallback[1])) if (tok.kind === "name") mentions3.push(tok.v);
|
|
36372
|
+
}
|
|
36373
|
+
}
|
|
36374
|
+
return { pieces, mentions: mentions3, skip: skip2 };
|
|
36375
|
+
};
|
|
36376
|
+
return {
|
|
36377
|
+
actions: [...actions].sort(),
|
|
36378
|
+
piecesFor,
|
|
36379
|
+
tables: new Set(used.map((one) => one.table))
|
|
36380
|
+
};
|
|
36381
|
+
}
|
|
36382
|
+
var COMPARE = /* @__PURE__ */ new Set(["==", "!=", "<", ">", "<=", ">="]);
|
|
36383
|
+
var OPERAND_START = /* @__PURE__ */ new Set([
|
|
36384
|
+
"",
|
|
36385
|
+
"(",
|
|
36386
|
+
"[",
|
|
36387
|
+
"{",
|
|
36388
|
+
",",
|
|
36389
|
+
"=",
|
|
36390
|
+
":",
|
|
36391
|
+
"return",
|
|
36392
|
+
"if",
|
|
36393
|
+
"elif",
|
|
36394
|
+
"while",
|
|
36395
|
+
"or",
|
|
36396
|
+
"and",
|
|
36397
|
+
"not",
|
|
36398
|
+
"else",
|
|
36399
|
+
"assert"
|
|
36400
|
+
]);
|
|
36401
|
+
var OPERAND_END = /* @__PURE__ */ new Set(["", ")", "]", "}", ",", ":", ";", "or", "and", "if", "else"]);
|
|
36402
|
+
var CHAIN_END = /* @__PURE__ */ new Set([...OPERAND_END, "is", "in", "not", ...COMPARE]);
|
|
36403
|
+
function constantEnd(t, i) {
|
|
36404
|
+
const tok = t[i];
|
|
36405
|
+
if (tok === void 0) return -1;
|
|
36406
|
+
if (tok.kind === "num" || tok.kind === "str" && !/^[A-Za-z]*[fFtT]/.test(tok.v)) return i + 1;
|
|
36407
|
+
if (["None", "True", "False"].includes(tok.v)) return i + 1;
|
|
36408
|
+
const pair = { "{": "}", "[": "]", "(": ")" };
|
|
36409
|
+
return pair[tok.v] !== void 0 && t[i + 1]?.v === pair[tok.v] ? i + 2 : -1;
|
|
36410
|
+
}
|
|
36411
|
+
function safeUse(t, k, reset, lineStarts) {
|
|
36412
|
+
let first = k;
|
|
36413
|
+
let last = k;
|
|
36414
|
+
if (t[k - 1]?.v === "(" && t[k + 1]?.v === "or") {
|
|
36415
|
+
if (t[k + 2]?.v === "{" && t[k + 3]?.v === "}" && t[k + 4]?.v === ")") [first, last] = [k - 1, k + 4];
|
|
36416
|
+
else if (t[k + 2]?.v === "dict" && t[k + 3]?.v === "(" && t[k + 4]?.v === ")" && t[k + 5]?.v === ")") {
|
|
36417
|
+
[first, last] = [k - 1, k + 5];
|
|
36418
|
+
}
|
|
36419
|
+
}
|
|
36420
|
+
const at = (i) => {
|
|
36421
|
+
const tok = t[i];
|
|
36422
|
+
return tok === void 0 || lineStarts.has(tok.s) ? "" : tok.v;
|
|
36423
|
+
};
|
|
36424
|
+
const next = at(last + 1);
|
|
36425
|
+
const prev = lineStarts.has(t[first].s) ? "" : t[first - 1].v;
|
|
36426
|
+
if (next === "." && t[last + 2]?.v === "get" && t[last + 3]?.v === "(") return true;
|
|
36427
|
+
if (next === "[") {
|
|
36428
|
+
const shut = closing(t, last + 1);
|
|
36429
|
+
return shut > 0 && !ASSIGN.has(t[shut + 1]?.v ?? "");
|
|
36430
|
+
}
|
|
36431
|
+
if (OPERAND_START.has(prev)) {
|
|
36432
|
+
if (next === "is") return true;
|
|
36433
|
+
const op = next === "not" && t[last + 2]?.v === "in" ? 2 : COMPARE.has(next) || next === "in" ? 1 : 0;
|
|
36434
|
+
if (op > 0) {
|
|
36435
|
+
const end = constantEnd(t, last + 1 + op);
|
|
36436
|
+
return end > 0 && CHAIN_END.has(at(end));
|
|
36437
|
+
}
|
|
36438
|
+
}
|
|
36439
|
+
if (!OPERAND_END.has(next)) return reset.has(t[k].s);
|
|
36440
|
+
if (prev === "is" || prev === "in" || prev === "not") return true;
|
|
36441
|
+
if (COMPARE.has(prev)) {
|
|
36442
|
+
const lit = first - 2;
|
|
36443
|
+
const start = t[lit]?.v === "}" || t[lit]?.v === "]" || t[lit]?.v === ")" ? lit - 1 : lit;
|
|
36444
|
+
return constantEnd(t, start) === first - 1 && OPERAND_START.has(lineStarts.has(t[start].s) ? "" : t[start - 1].v);
|
|
36445
|
+
}
|
|
36446
|
+
if (["if", "elif", "while"].includes(prev) && next === ":") return true;
|
|
36447
|
+
if (prev === "if" && next === "else") return true;
|
|
36448
|
+
return reset.has(t[k].s);
|
|
36449
|
+
}
|
|
36450
|
+
function scanActions(code, lib) {
|
|
36451
|
+
try {
|
|
36452
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
36453
|
+
const lines = (text4) => text4.replace(/\r\n?/g, "\n");
|
|
36454
|
+
const main2 = readUnit(parseModule(lines(code)), aliases);
|
|
36455
|
+
const units = [
|
|
36456
|
+
main2.unit,
|
|
36457
|
+
...Object.keys(lib).sort().map((name) => readUnit(parseModule(lines(lib[name])), aliases).unit)
|
|
36458
|
+
];
|
|
36459
|
+
if (main2.handle.length !== 1) throw new GiveUp("the handler has no single top-level `def handle`");
|
|
36460
|
+
const handle = main2.handle[0];
|
|
36461
|
+
const dispatch = readDispatch(main2.unit.mod, handle, main2.tables);
|
|
36462
|
+
const tableAt = new Set([...dispatch.tables].map((table) => offset(main2.unit.mod, table.stmt.line)));
|
|
36463
|
+
const seeds = units.flatMap((unit) => unit.seeds).filter((one) => !(one.mod === main2.unit.mod && tableAt.has(one.s)));
|
|
36464
|
+
const tablePieces = [...dispatch.tables].map((table) => ({
|
|
36465
|
+
mod: main2.unit.mod,
|
|
36466
|
+
s: offset(main2.unit.mod, table.stmt.line),
|
|
36467
|
+
e: offset(main2.unit.mod, table.stmt.end)
|
|
36468
|
+
}));
|
|
36469
|
+
const actions = dispatch.actions.map((action) => {
|
|
36470
|
+
const { pieces, mentions: mentions3, skip: skip2 } = dispatch.piecesFor(action);
|
|
36471
|
+
const text4 = [];
|
|
36472
|
+
const queue = [...mentions3];
|
|
36473
|
+
const take = (piece, holes = []) => {
|
|
36474
|
+
text4.push(piece.mod.raw.slice(piece.s, piece.e));
|
|
36475
|
+
if (piece.noMentions === true) return;
|
|
36476
|
+
for (const tok of toksIn(piece.mod, piece.s, piece.e)) {
|
|
36477
|
+
if (tok.kind === "name" && !holes.some(([s, e]) => tok.s >= s && tok.s < e)) queue.push(tok.v);
|
|
36478
|
+
}
|
|
36479
|
+
};
|
|
36480
|
+
seeds.forEach((piece) => take(piece));
|
|
36481
|
+
pieces.forEach((piece) => take(piece, skip2));
|
|
36482
|
+
const seen = /* @__PURE__ */ new Set();
|
|
36483
|
+
while (queue.length > 0) {
|
|
36484
|
+
const name = queue.pop();
|
|
36485
|
+
if (seen.has(name)) continue;
|
|
36486
|
+
seen.add(name);
|
|
36487
|
+
queue.push(...aliases.get(name) ?? []);
|
|
36488
|
+
for (const unit of units) {
|
|
36489
|
+
for (const [s, e] of unit.defs.get(name) ?? []) {
|
|
36490
|
+
take({ mod: unit.mod, s, e });
|
|
36491
|
+
if (unit === main2.unit && s === offset(unit.mod, handle.line)) tablePieces.forEach((piece) => take(piece));
|
|
36492
|
+
}
|
|
36493
|
+
}
|
|
36494
|
+
}
|
|
36495
|
+
return { action, reasons: writeReasons(text4.map((part) => codeOnly(part)).join("\n")) };
|
|
36496
|
+
});
|
|
36497
|
+
return { ok: true, actions };
|
|
36498
|
+
} catch (err) {
|
|
36499
|
+
return {
|
|
36500
|
+
ok: false,
|
|
36501
|
+
why: err instanceof GiveUp ? err.message : "the check could not read the code"
|
|
36502
|
+
};
|
|
36503
|
+
}
|
|
36504
|
+
}
|
|
36505
|
+
|
|
35513
36506
|
// src/commands/appspace/compare.ts
|
|
35514
36507
|
var READ_ONLY_ERROR = "ReadOnlyRefused";
|
|
35515
36508
|
var PLAIN_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
@@ -35597,7 +36590,7 @@ function diffJson(published, migrated, masks = []) {
|
|
|
35597
36590
|
const add = (path3, kind, sides) => {
|
|
35598
36591
|
differences.push({ path: formatPath(path3), steps: path3, kind, ...sides });
|
|
35599
36592
|
};
|
|
35600
|
-
const
|
|
36593
|
+
const walk6 = (a, b, path3) => {
|
|
35601
36594
|
if (hidden(path3)) return;
|
|
35602
36595
|
const ta = jsonType(a);
|
|
35603
36596
|
const tb = jsonType(b);
|
|
@@ -35614,7 +36607,7 @@ function diffJson(published, migrated, masks = []) {
|
|
|
35614
36607
|
if (!hidden(at)) add(at, "missing", { published: left[i] });
|
|
35615
36608
|
} else if (i >= left.length) {
|
|
35616
36609
|
if (!hidden(at)) add(at, "extra", { migrated: right[i] });
|
|
35617
|
-
} else
|
|
36610
|
+
} else walk6(left[i], right[i], at);
|
|
35618
36611
|
}
|
|
35619
36612
|
return;
|
|
35620
36613
|
}
|
|
@@ -35623,7 +36616,7 @@ function diffJson(published, migrated, masks = []) {
|
|
|
35623
36616
|
const right = b;
|
|
35624
36617
|
for (const key of Object.keys(left).sort()) {
|
|
35625
36618
|
const at = [...path3, { key }];
|
|
35626
|
-
if (Object.prototype.hasOwnProperty.call(right, key))
|
|
36619
|
+
if (Object.prototype.hasOwnProperty.call(right, key)) walk6(left[key], right[key], at);
|
|
35627
36620
|
else if (!hidden(at)) add(at, "missing", { published: left[key] });
|
|
35628
36621
|
}
|
|
35629
36622
|
for (const key of Object.keys(right).sort()) {
|
|
@@ -35635,7 +36628,7 @@ function diffJson(published, migrated, masks = []) {
|
|
|
35635
36628
|
}
|
|
35636
36629
|
if (a !== b) add(path3, "value", { published: a, migrated: b });
|
|
35637
36630
|
};
|
|
35638
|
-
|
|
36631
|
+
walk6(published, migrated, []);
|
|
35639
36632
|
return { differences, masked, perMask };
|
|
35640
36633
|
}
|
|
35641
36634
|
function isEmptyAnswer(value) {
|
|
@@ -35655,72 +36648,6 @@ function canonical5(value) {
|
|
|
35655
36648
|
function shortHash(value, salt) {
|
|
35656
36649
|
return createHash4("sha256").update(salt).update(canonical5(value)).digest("hex").slice(0, 8);
|
|
35657
36650
|
}
|
|
35658
|
-
var REACHES_TABLES = /\.\s*(?:data|tables)\b|\.\s*table\b/;
|
|
35659
|
-
var TABLE_WRITE = /\.\s*(insert|update|delete|save|next_number|transaction|assign_author)\b/g;
|
|
35660
|
-
var REACHES_STATE = /\.\s*state\b/;
|
|
35661
|
-
var STATE_WRITE = /\.\s*(set|set_in|delete)\b/g;
|
|
35662
|
-
var REACHES_FILEBOXES = /\bfileboxes\b/;
|
|
35663
|
-
var UPLOAD = /\.\s*upload\b/;
|
|
35664
|
-
var AGENTS = /\.\s*agents\b/;
|
|
35665
|
-
var REACHES_HTTP = /\.\s*http\b/;
|
|
35666
|
-
var HTTP_WRITE = /\.\s*(post|put|patch|delete|request)\b/;
|
|
35667
|
-
var DYNAMIC = /\b(?:getattr|setattr|eval|exec|__import__|methodcaller|attrgetter|partial|partialmethod)\b|__getattribute__|__dict__|\bimportlib\b|\bvars\s*\(/;
|
|
35668
|
-
function codeOnly(code) {
|
|
35669
|
-
let out = "";
|
|
35670
|
-
let i = 0;
|
|
35671
|
-
while (i < code.length) {
|
|
35672
|
-
const ch = code[i];
|
|
35673
|
-
if (ch === "#") {
|
|
35674
|
-
while (i < code.length && code[i] !== "\n") i += 1;
|
|
35675
|
-
continue;
|
|
35676
|
-
}
|
|
35677
|
-
if (ch === '"' || ch === "'") {
|
|
35678
|
-
const prefix = /[A-Za-z]*$/.exec(out)[0];
|
|
35679
|
-
const fString = /f/i.test(prefix);
|
|
35680
|
-
const triple = code.startsWith(ch.repeat(3), i);
|
|
35681
|
-
const close = triple ? ch.repeat(3) : ch;
|
|
35682
|
-
let j = i + close.length;
|
|
35683
|
-
let closed = false;
|
|
35684
|
-
while (j < code.length) {
|
|
35685
|
-
if (code.startsWith(close, j)) {
|
|
35686
|
-
closed = true;
|
|
35687
|
-
break;
|
|
35688
|
-
}
|
|
35689
|
-
if (code[j] === "\\") j += 1;
|
|
35690
|
-
else if (!triple && code[j] === "\n") break;
|
|
35691
|
-
j += 1;
|
|
35692
|
-
}
|
|
35693
|
-
const end = closed ? j + close.length : Math.min(code.length, j);
|
|
35694
|
-
out += fString ? code.slice(i, end) : `${close}${close}`;
|
|
35695
|
-
i = end;
|
|
35696
|
-
continue;
|
|
35697
|
-
}
|
|
35698
|
-
out += ch;
|
|
35699
|
-
i += 1;
|
|
35700
|
-
}
|
|
35701
|
-
return out;
|
|
35702
|
-
}
|
|
35703
|
-
function writeReasons(code) {
|
|
35704
|
-
const text4 = codeOnly(code).normalize("NFKC");
|
|
35705
|
-
const reasons = /* @__PURE__ */ new Set();
|
|
35706
|
-
if (REACHES_TABLES.test(text4)) {
|
|
35707
|
-
for (const match of text4.matchAll(TABLE_WRITE)) reasons.add(`a table write (.${match[1]})`);
|
|
35708
|
-
}
|
|
35709
|
-
if (REACHES_STATE.test(text4)) {
|
|
35710
|
-
for (const match of text4.matchAll(STATE_WRITE)) reasons.add(`a state write (.${match[1]})`);
|
|
35711
|
-
}
|
|
35712
|
-
if (REACHES_FILEBOXES.test(text4) && UPLOAD.test(text4)) reasons.add("a filebox upload (ctx.dr.fileboxes.upload)");
|
|
35713
|
-
if (AGENTS.test(text4)) reasons.add("an agent call (ctx.agents): it starts real work");
|
|
35714
|
-
if (REACHES_HTTP.test(text4) && HTTP_WRITE.test(text4)) reasons.add("an outgoing HTTP call that is not a GET (ctx.http)");
|
|
35715
|
-
if (DYNAMIC.test(text4)) {
|
|
35716
|
-
reasons.add("dynamic access (getattr, eval, partial, methodcaller, an import by name): the call is not known");
|
|
35717
|
-
}
|
|
35718
|
-
if (/[^\x00-\x7f]/.test(codeOnly(code))) reasons.add("a name that is not ASCII: the text may hide a call");
|
|
35719
|
-
return [...reasons].sort();
|
|
35720
|
-
}
|
|
35721
|
-
function handlerText(code, lib) {
|
|
35722
|
-
return [code, ...Object.keys(lib).sort().map((name) => lib[name])].join("\n");
|
|
35723
|
-
}
|
|
35724
36651
|
function missingGrants(disk, stored) {
|
|
35725
36652
|
const asObject = (raw) => typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : {};
|
|
35726
36653
|
const have = asObject(stored);
|
|
@@ -35862,18 +36789,20 @@ function sameLib(a, b) {
|
|
|
35862
36789
|
async function compareOne(client, appId, handler, sides, ctx) {
|
|
35863
36790
|
const { published, migrated } = sides;
|
|
35864
36791
|
if (published === void 0) {
|
|
35865
|
-
return { handler, status: "skipped", label: "skipped (new: the published app has no such handler)" };
|
|
36792
|
+
return [{ handler, status: "skipped", label: "skipped (new: the published app has no such handler)" }];
|
|
35866
36793
|
}
|
|
35867
36794
|
if (migrated === void 0) {
|
|
35868
|
-
return
|
|
35869
|
-
|
|
35870
|
-
|
|
35871
|
-
|
|
35872
|
-
|
|
35873
|
-
|
|
36795
|
+
return [
|
|
36796
|
+
{
|
|
36797
|
+
handler,
|
|
36798
|
+
status: "error",
|
|
36799
|
+
label: "error",
|
|
36800
|
+
reasons: [`handlers/${handler}.py is not in the folder: the migrated app has lost this handler`]
|
|
36801
|
+
}
|
|
36802
|
+
];
|
|
35874
36803
|
}
|
|
35875
36804
|
if (published === migrated && sameLib(sides.publishedLib, sides.migratedLib)) {
|
|
35876
|
-
return { handler, status: "unchanged", label: "unchanged (same text, same lib)" };
|
|
36805
|
+
return [{ handler, status: "unchanged", label: "unchanged (same text, same lib)" }];
|
|
35877
36806
|
}
|
|
35878
36807
|
const writes = [
|
|
35879
36808
|
.../* @__PURE__ */ new Set([
|
|
@@ -35881,29 +36810,77 @@ async function compareOne(client, appId, handler, sides, ctx) {
|
|
|
35881
36810
|
...writeReasons(handlerText(migrated, sides.migratedLib))
|
|
35882
36811
|
])
|
|
35883
36812
|
].sort();
|
|
35884
|
-
if (writes.length
|
|
35885
|
-
|
|
36813
|
+
if (writes.length === 0) {
|
|
36814
|
+
const role2 = chooseRole(handler, ctx.view, ctx.asRole);
|
|
36815
|
+
if ("refused" in role2) return [{ handler, status: "skipped", label: "skipped (role)", reasons: [role2.refused] }];
|
|
36816
|
+
return [await runPair(client, appId, { handler, published, migrated, ...sides }, ctx, role2, ctx.payload)];
|
|
36817
|
+
}
|
|
36818
|
+
const pubScan = scanActions(published, sides.publishedLib);
|
|
36819
|
+
const migScan = scanActions(migrated, sides.migratedLib);
|
|
36820
|
+
if (!pubScan.ok || !migScan.ok) {
|
|
36821
|
+
const why = [
|
|
36822
|
+
...pubScan.ok ? [] : [`the published code: ${pubScan.why}`],
|
|
36823
|
+
...migScan.ok ? [] : [`the migrated code: ${migScan.why}`]
|
|
36824
|
+
];
|
|
36825
|
+
return [
|
|
36826
|
+
{
|
|
36827
|
+
handler,
|
|
36828
|
+
status: "skipped",
|
|
36829
|
+
label: "skipped (writes: check by hand)",
|
|
36830
|
+
reasons: [...writes, `no read-only action was found (${why.join("; ")})`]
|
|
36831
|
+
}
|
|
36832
|
+
];
|
|
35886
36833
|
}
|
|
35887
36834
|
const role = chooseRole(handler, ctx.view, ctx.asRole);
|
|
35888
|
-
if ("refused" in role) {
|
|
35889
|
-
|
|
36835
|
+
if ("refused" in role) return [{ handler, status: "skipped", label: "skipped (role)", reasons: [role.refused] }];
|
|
36836
|
+
const pubActions = new Map(pubScan.actions.map((one) => [one.action, one.reasons]));
|
|
36837
|
+
const migActions = new Map(migScan.actions.map((one) => [one.action, one.reasons]));
|
|
36838
|
+
const out = [];
|
|
36839
|
+
for (const action of [.../* @__PURE__ */ new Set([...pubActions.keys(), ...migActions.keys()])].sort()) {
|
|
36840
|
+
const pubReasons = pubActions.get(action);
|
|
36841
|
+
const migReasons = migActions.get(action);
|
|
36842
|
+
if (migReasons === void 0) {
|
|
36843
|
+
out.push({
|
|
36844
|
+
handler,
|
|
36845
|
+
action,
|
|
36846
|
+
status: "error",
|
|
36847
|
+
label: "error",
|
|
36848
|
+
reasons: ["the migrated code has lost this action: the published code dispatches it, the migrated code does not"]
|
|
36849
|
+
});
|
|
36850
|
+
} else if (pubReasons === void 0) {
|
|
36851
|
+
out.push({ handler, action, status: "skipped", label: "skipped (new: the published code has no such action)" });
|
|
36852
|
+
} else if (pubReasons.length > 0 || migReasons.length > 0) {
|
|
36853
|
+
const reasons = [.../* @__PURE__ */ new Set([...pubReasons, ...migReasons])].sort();
|
|
36854
|
+
out.push({ handler, action, status: "skipped", label: "skipped (writes: check by hand)", reasons });
|
|
36855
|
+
} else {
|
|
36856
|
+
const payload = { ...ctx.payload, action };
|
|
36857
|
+
out.push(await runPair(client, appId, { handler, published, migrated, ...sides }, ctx, role, payload, action));
|
|
36858
|
+
}
|
|
35890
36859
|
}
|
|
36860
|
+
return out;
|
|
36861
|
+
}
|
|
36862
|
+
async function runPair(client, appId, sides, ctx, role, payload, action) {
|
|
36863
|
+
const { handler, published, migrated } = sides;
|
|
35891
36864
|
const pub = await dryRunSafely(client, appId, {
|
|
35892
36865
|
code: published,
|
|
35893
|
-
payload
|
|
36866
|
+
payload,
|
|
35894
36867
|
lib: sides.publishedLib,
|
|
35895
36868
|
asRole: role.asRole
|
|
35896
36869
|
});
|
|
35897
36870
|
const mig = await dryRunSafely(client, appId, {
|
|
35898
36871
|
code: migrated,
|
|
35899
|
-
payload
|
|
36872
|
+
payload,
|
|
35900
36873
|
lib: sides.migratedLib,
|
|
35901
36874
|
asRole: role.asRole
|
|
35902
36875
|
});
|
|
35903
|
-
const base = { handler, role: role.role };
|
|
36876
|
+
const base = { handler, ...action === void 0 ? {} : { action }, role: role.role };
|
|
35904
36877
|
const pubWrites = triedToWrite(pub);
|
|
35905
36878
|
const migWrites = triedToWrite(mig);
|
|
36879
|
+
const missed = action !== void 0 && (pubWrites || migWrites) ? ["the static check found no write in this action, but the run tried one: the check missed it. Report this."] : [];
|
|
35906
36880
|
if (pubWrites && migWrites) {
|
|
36881
|
+
if (missed.length > 0) {
|
|
36882
|
+
return { ...base, status: "error", label: "error", reasons: ["both sides tried to write (stopped by the read-only run).", ...missed] };
|
|
36883
|
+
}
|
|
35907
36884
|
return {
|
|
35908
36885
|
...base,
|
|
35909
36886
|
status: "writes",
|
|
@@ -35916,7 +36893,7 @@ async function compareOne(client, appId, handler, sides, ctx) {
|
|
|
35916
36893
|
...pub.ok ? [] : [sideError("published", pub, ctx.showValues)],
|
|
35917
36894
|
...mig.ok ? [] : [sideError("migrated", mig, ctx.showValues)]
|
|
35918
36895
|
];
|
|
35919
|
-
const reasons = [];
|
|
36896
|
+
const reasons = [...missed];
|
|
35920
36897
|
if (pubWrites !== migWrites && (pubWrites ? mig.ok : pub.ok)) {
|
|
35921
36898
|
reasons.push(
|
|
35922
36899
|
`only the ${pubWrites ? "published" : "migrated"} code tried to write (stopped by the read-only run): the two versions do not do the same thing.`
|
|
@@ -36021,7 +36998,8 @@ function renderReport(report, showValues) {
|
|
|
36021
36998
|
for (const one of report.handlers) {
|
|
36022
36999
|
const role = one.role === void 0 || one.role === null ? "" : ` (as ${one.role})`;
|
|
36023
37000
|
const masked = one.masked === void 0 ? "" : ` masked: ${String(one.masked)}`;
|
|
36024
|
-
|
|
37001
|
+
const action = one.action === void 0 ? "" : ` action=${one.action}`;
|
|
37002
|
+
lines.push(` ${one.label.padEnd(width)} ${one.handler}${action}${role}${masked}`);
|
|
36025
37003
|
for (const reason of one.reasons ?? []) lines.push(` ${reason}`);
|
|
36026
37004
|
for (const err of one.errors ?? []) {
|
|
36027
37005
|
const where2 = err.line === void 0 ? "" : ` (line ${String(err.line)})`;
|
|
@@ -36172,7 +37150,7 @@ async function compareInner(dir, opts) {
|
|
|
36172
37150
|
for (const handler of handlerNames) {
|
|
36173
37151
|
if (only.length > 0 && !only.includes(handler)) continue;
|
|
36174
37152
|
results.push(
|
|
36175
|
-
await compareOne(
|
|
37153
|
+
...await compareOne(
|
|
36176
37154
|
client,
|
|
36177
37155
|
appId,
|
|
36178
37156
|
handler,
|
|
@@ -36789,12 +37767,12 @@ function applyDiff(diff, sent) {
|
|
|
36789
37767
|
n += 2;
|
|
36790
37768
|
continue;
|
|
36791
37769
|
}
|
|
36792
|
-
const
|
|
36793
|
-
if (
|
|
37770
|
+
const header2 = HUNK_RE.exec(line2);
|
|
37771
|
+
if (header2 === null || current === null) throw invalid();
|
|
36794
37772
|
const hunk = {
|
|
36795
|
-
oldStart: Number(
|
|
36796
|
-
oldCount:
|
|
36797
|
-
newCount:
|
|
37773
|
+
oldStart: Number(header2[1]),
|
|
37774
|
+
oldCount: header2[2] === void 0 ? 1 : Number(header2[2]),
|
|
37775
|
+
newCount: header2[4] === void 0 ? 1 : Number(header2[4]),
|
|
36798
37776
|
lines: []
|
|
36799
37777
|
};
|
|
36800
37778
|
current.push(hunk);
|
|
@@ -38218,19 +39196,19 @@ function figuresIn(text4) {
|
|
|
38218
39196
|
}
|
|
38219
39197
|
function seriesNumbers(data) {
|
|
38220
39198
|
const out = [];
|
|
38221
|
-
const
|
|
39199
|
+
const walk6 = (one) => {
|
|
38222
39200
|
if (Array.isArray(one)) {
|
|
38223
|
-
for (const item of one)
|
|
39201
|
+
for (const item of one) walk6(item);
|
|
38224
39202
|
return;
|
|
38225
39203
|
}
|
|
38226
39204
|
if (typeof one === "object" && one !== null) {
|
|
38227
|
-
|
|
39205
|
+
walk6(one.value);
|
|
38228
39206
|
return;
|
|
38229
39207
|
}
|
|
38230
39208
|
const n = numberOf(one);
|
|
38231
39209
|
if (n !== null) out.push(n);
|
|
38232
39210
|
};
|
|
38233
|
-
|
|
39211
|
+
walk6(data);
|
|
38234
39212
|
return out;
|
|
38235
39213
|
}
|
|
38236
39214
|
var INPUT_TAGS = /* @__PURE__ */ new Set(["input", "select", "textarea"]);
|
|
@@ -41159,7 +42137,7 @@ async function runScreenshots(opts) {
|
|
|
41159
42137
|
async function readLocalUi(dir) {
|
|
41160
42138
|
const root = join20(dir, "ui");
|
|
41161
42139
|
const out = {};
|
|
41162
|
-
const
|
|
42140
|
+
const walk6 = async (folder) => {
|
|
41163
42141
|
let names;
|
|
41164
42142
|
try {
|
|
41165
42143
|
names = await readdir4(folder, { withFileTypes: true });
|
|
@@ -41168,11 +42146,11 @@ async function readLocalUi(dir) {
|
|
|
41168
42146
|
}
|
|
41169
42147
|
for (const one of names) {
|
|
41170
42148
|
const full = join20(folder, one.name);
|
|
41171
|
-
if (one.isDirectory()) await
|
|
42149
|
+
if (one.isDirectory()) await walk6(full);
|
|
41172
42150
|
else if (one.isFile()) out[relative3(root, full).split(sep7).join("/")] = await readFile14(full);
|
|
41173
42151
|
}
|
|
41174
42152
|
};
|
|
41175
|
-
await
|
|
42153
|
+
await walk6(root);
|
|
41176
42154
|
return out;
|
|
41177
42155
|
}
|
|
41178
42156
|
function looksLikeShelf(root) {
|
|
@@ -42231,21 +43209,21 @@ function partFindings(runs) {
|
|
|
42231
43209
|
const fresh = (component.values ?? []).filter((value) => value.value === "").map((value) => value.field);
|
|
42232
43210
|
if (fresh.length > 0) {
|
|
42233
43211
|
const seen = unfilled.get(where2);
|
|
42234
|
-
const
|
|
43212
|
+
const blank5 = [.../* @__PURE__ */ new Set([...seen?.blank ?? [], ...fresh])];
|
|
42235
43213
|
const named13 = component.props.source;
|
|
42236
43214
|
const answerer = typeof named13 === "string" && named13 !== "" ? `"${named13}"` : "its source";
|
|
42237
43215
|
const finding = {
|
|
42238
43216
|
code: "callout-unfilled",
|
|
42239
43217
|
where: where2,
|
|
42240
|
-
message: `${partName(component)} drew its sentence with no value for ${
|
|
42241
|
-
fix: `make the source answer ${
|
|
43218
|
+
message: `${partName(component)} drew its sentence with no value for ${blank5.map((path3) => `{${path3}}`).join(", ")}: ${answerer} answered nothing at ${blank5.length === 1 ? "that path" : "those paths"}, so the sentence \u2014 and the rule that chose it \u2014 is not about the numbers.`,
|
|
43219
|
+
fix: `make the source answer ${blank5.join(", ")} (app-space try <source> shows the keys it answers), or write the paths it does answer into props.props.rules and the text.`,
|
|
42242
43220
|
see: SEE.parts
|
|
42243
43221
|
};
|
|
42244
43222
|
if (seen === void 0) {
|
|
42245
|
-
unfilled.set(where2, { at: out.length, blank:
|
|
43223
|
+
unfilled.set(where2, { at: out.length, blank: blank5 });
|
|
42246
43224
|
out.push(finding);
|
|
42247
43225
|
} else {
|
|
42248
|
-
seen.blank =
|
|
43226
|
+
seen.blank = blank5;
|
|
42249
43227
|
out[seen.at] = finding;
|
|
42250
43228
|
}
|
|
42251
43229
|
}
|
|
@@ -44750,6 +45728,7 @@ function registerAppSpaceCommand(root) {
|
|
|
44750
45728
|
registerCompareCommand(cmd);
|
|
44751
45729
|
registerPublishCommands(cmd);
|
|
44752
45730
|
registerSecretsCommand(cmd);
|
|
45731
|
+
registerApproveHostsCommand(cmd);
|
|
44753
45732
|
}
|
|
44754
45733
|
|
|
44755
45734
|
// src/commands/update.ts
|