@datarails-ai/dr-appspace-cli 0.12.68 → 0.12.70
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/dist/cli.js +129 -21
- 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.70",
|
|
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-06T08:12:14.679Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -9316,6 +9316,8 @@ function pageGateKey(roles) {
|
|
|
9316
9316
|
var NAV_OPEN = /<nav\b[^>]*\bdata-dr-kit\s*=\s*["']nav["'][^>]*>/gi;
|
|
9317
9317
|
var ANCHOR = /<a\b([^>]*)>/gi;
|
|
9318
9318
|
var HREF = /\bhref\s*=\s*["']([^"']*)["']/i;
|
|
9319
|
+
var NAV_HREF = /(?<![\w-])href\s*=\s*["']([^"']*)["']/i;
|
|
9320
|
+
var NAV_CLOSE = /<\/nav\s*>/i;
|
|
9319
9321
|
var ROLE_ATTR2 = /\bdata-dr-role\s*=\s*["']([^"']*)["']/i;
|
|
9320
9322
|
var PAGE_LITERAL = /["'`](?:\.\/)?([A-Za-z0-9_-]+\.html)(?:[?#][^"'`]*)?["'`]/g;
|
|
9321
9323
|
function targetOf(href, from = "ui/index.html") {
|
|
@@ -9335,15 +9337,15 @@ function navLinks(html, { owned = false, from } = {}) {
|
|
|
9335
9337
|
if (owned) regions.push(text4);
|
|
9336
9338
|
else {
|
|
9337
9339
|
for (const open2 of text4.matchAll(NAV_OPEN)) {
|
|
9338
|
-
const
|
|
9339
|
-
const end =
|
|
9340
|
-
regions.push(
|
|
9340
|
+
const rest = text4.slice(open2.index + open2[0].length);
|
|
9341
|
+
const end = rest.search(NAV_CLOSE);
|
|
9342
|
+
regions.push(end === -1 ? rest : rest.slice(0, end));
|
|
9341
9343
|
}
|
|
9342
9344
|
}
|
|
9343
9345
|
const out = [];
|
|
9344
9346
|
for (const region of regions) {
|
|
9345
9347
|
for (const anchor of region.matchAll(ANCHOR)) {
|
|
9346
|
-
const target = targetOf(HREF.exec(anchor[1])?.[1], from);
|
|
9348
|
+
const target = targetOf((owned ? HREF : NAV_HREF).exec(anchor[1])?.[1], from);
|
|
9347
9349
|
if (target === null) continue;
|
|
9348
9350
|
out.push({ target, gate: gateRoles(ROLE_ATTR2.exec(anchor[1])?.[1]) });
|
|
9349
9351
|
}
|
|
@@ -11696,8 +11698,11 @@ function tabBars(pages, typed) {
|
|
|
11696
11698
|
if (tabs.length > 0) stored.set(page.path, tabs);
|
|
11697
11699
|
}
|
|
11698
11700
|
const targetsOf = (path3) => stored.has(path3) ? new Set(stored.get(path3).map((tab) => tab.target)) : null;
|
|
11699
|
-
const
|
|
11700
|
-
const carries = (path3,
|
|
11701
|
+
const suffix = (href) => href.replace(/^[^?#]*/, "");
|
|
11702
|
+
const carries = (path3, tabs) => {
|
|
11703
|
+
const other = stored.get(path3);
|
|
11704
|
+
return other !== void 0 && other.length === tabs.length && other.every((tab, index) => !tab.current && tab.target === tabs[index].target && tab.label === tabs[index].label && suffix(tab.href) === suffix(tabs[index].href));
|
|
11705
|
+
};
|
|
11701
11706
|
const out = /* @__PURE__ */ new Map();
|
|
11702
11707
|
for (const page of pages) {
|
|
11703
11708
|
const tabs = stored.get(page.path);
|
|
@@ -11716,7 +11721,7 @@ function tabBars(pages, typed) {
|
|
|
11716
11721
|
return tab.target !== null && // The href as `composedTabs` writes it: a `?view=monthly` or `#sales` the author added is theirs.
|
|
11717
11722
|
tab.href === relativeTo(page.path, tab.target) && ascending && tab.current === (tab.target === page.path) && (target === void 0 || tab.label === headingOf(target));
|
|
11718
11723
|
});
|
|
11719
|
-
const stale = kitShaped && (dead.length > 0 || missing.length > 0 && !missing.every((path3) => carries(path3,
|
|
11724
|
+
const stale = kitShaped && (dead.length > 0 || missing.length > 0 && !missing.every((path3) => carries(path3, tabs)));
|
|
11720
11725
|
if (stale) {
|
|
11721
11726
|
out.set(page.path, { kind: "recomposed", tabs, problem: null });
|
|
11722
11727
|
continue;
|
|
@@ -21576,6 +21581,72 @@ async function readHandlers(handlersDir, state) {
|
|
|
21576
21581
|
}
|
|
21577
21582
|
return handlers;
|
|
21578
21583
|
}
|
|
21584
|
+
var PYTHON_KEYWORDS = /* @__PURE__ */ new Set([
|
|
21585
|
+
"False",
|
|
21586
|
+
"None",
|
|
21587
|
+
"True",
|
|
21588
|
+
"and",
|
|
21589
|
+
"as",
|
|
21590
|
+
"assert",
|
|
21591
|
+
"async",
|
|
21592
|
+
"await",
|
|
21593
|
+
"break",
|
|
21594
|
+
"class",
|
|
21595
|
+
"continue",
|
|
21596
|
+
"def",
|
|
21597
|
+
"del",
|
|
21598
|
+
"elif",
|
|
21599
|
+
"else",
|
|
21600
|
+
"except",
|
|
21601
|
+
"finally",
|
|
21602
|
+
"for",
|
|
21603
|
+
"from",
|
|
21604
|
+
"global",
|
|
21605
|
+
"if",
|
|
21606
|
+
"import",
|
|
21607
|
+
"in",
|
|
21608
|
+
"is",
|
|
21609
|
+
"lambda",
|
|
21610
|
+
"nonlocal",
|
|
21611
|
+
"not",
|
|
21612
|
+
"or",
|
|
21613
|
+
"pass",
|
|
21614
|
+
"raise",
|
|
21615
|
+
"return",
|
|
21616
|
+
"try",
|
|
21617
|
+
"while",
|
|
21618
|
+
"with",
|
|
21619
|
+
"yield"
|
|
21620
|
+
]);
|
|
21621
|
+
function libNameProblem(name) {
|
|
21622
|
+
if (name.length > 64) return "is longer than 64 characters";
|
|
21623
|
+
if (!/^[a-z_][a-z0-9_]*$/.test(name)) return "must match [a-z_][a-z0-9_]*";
|
|
21624
|
+
if (name.startsWith("__")) return 'must not start with "__"';
|
|
21625
|
+
if (name === "lib") return 'must not be "lib"';
|
|
21626
|
+
if (PYTHON_KEYWORDS.has(name)) return "is a Python keyword";
|
|
21627
|
+
return null;
|
|
21628
|
+
}
|
|
21629
|
+
async function readLib(libDir) {
|
|
21630
|
+
const lib = {};
|
|
21631
|
+
for (const file of (await readDirIfPresent(libDir)).sort()) {
|
|
21632
|
+
if (!file.endsWith(".py")) continue;
|
|
21633
|
+
const full = join5(libDir, file);
|
|
21634
|
+
try {
|
|
21635
|
+
if (!(await stat(full)).isFile()) continue;
|
|
21636
|
+
} catch {
|
|
21637
|
+
continue;
|
|
21638
|
+
}
|
|
21639
|
+
const name = file.slice(0, -3);
|
|
21640
|
+
const problem6 = libNameProblem(name);
|
|
21641
|
+
if (problem6 !== null) {
|
|
21642
|
+
process.stderr.write(`warning: lib/${file} was not sent: the module name "${name}" ${problem6}.
|
|
21643
|
+
`);
|
|
21644
|
+
continue;
|
|
21645
|
+
}
|
|
21646
|
+
lib[name] = await readFile3(full, "utf8");
|
|
21647
|
+
}
|
|
21648
|
+
return lib;
|
|
21649
|
+
}
|
|
21579
21650
|
async function recordRevision(dir, revision, stage2, handlers, identity = {}) {
|
|
21580
21651
|
const statePath = join5(dir, ".appspace.json");
|
|
21581
21652
|
const state = { ...await readState(dir) };
|
|
@@ -21890,6 +21961,7 @@ async function runLiveness(dir, appId, whole, client, only) {
|
|
|
21890
21961
|
`${handler.file} is not in this folder, so no handler was run`
|
|
21891
21962
|
);
|
|
21892
21963
|
}
|
|
21964
|
+
const lib = await readLib(join7(dir, "lib"));
|
|
21893
21965
|
const groups = pagesToLoad(whole, only);
|
|
21894
21966
|
const merged = {};
|
|
21895
21967
|
const violations = /* @__PURE__ */ new Map();
|
|
@@ -21927,7 +21999,7 @@ async function runLiveness(dir, appId, whole, client, only) {
|
|
|
21927
21999
|
`/apps/${encodeURIComponent(appId)}/dry-run`,
|
|
21928
22000
|
{
|
|
21929
22001
|
method: "POST",
|
|
21930
|
-
body: { code, payload }
|
|
22002
|
+
body: { code, payload, ...Object.keys(lib).length > 0 ? { lib } : {} }
|
|
21931
22003
|
}
|
|
21932
22004
|
);
|
|
21933
22005
|
} catch (err) {
|
|
@@ -24365,6 +24437,7 @@ async function pushBody(dir, opts) {
|
|
|
24365
24437
|
const modelRaw = await readIfPresent(join8(dir, "data_model.json"));
|
|
24366
24438
|
const handlers = await readHandlers(join8(dir, "handlers"), state);
|
|
24367
24439
|
const uiFiles = await readUiTree(join8(dir, "ui"));
|
|
24440
|
+
const lib = await readLib(join8(dir, "lib"));
|
|
24368
24441
|
for (const line2 of chartsWithoutEcharts(uiFiles)) process.stderr.write(`warning: ${line2}
|
|
24369
24442
|
`);
|
|
24370
24443
|
const ui = bundleUi(uiFiles);
|
|
@@ -24380,6 +24453,7 @@ async function pushBody(dir, opts) {
|
|
|
24380
24453
|
if (ui?.field === "frontend_bundle_gz") {
|
|
24381
24454
|
body["frontend_bundle_gz"] = ui.files;
|
|
24382
24455
|
}
|
|
24456
|
+
if (Object.keys(lib).length > 0) body["lib"] = lib;
|
|
24383
24457
|
const connectTables = manifest["connect_tables"];
|
|
24384
24458
|
if (typeof connectTables === "object" && connectTables !== null && !Array.isArray(connectTables)) {
|
|
24385
24459
|
if (Object.keys(connectTables).length > 0) body["connect_tables"] = connectTables;
|
|
@@ -24527,7 +24601,7 @@ async function pushFolder(dir, opts) {
|
|
|
24527
24601
|
}
|
|
24528
24602
|
|
|
24529
24603
|
// src/commands/appspace/get.ts
|
|
24530
|
-
import { mkdtemp, mkdir as mkdir4, readFile as readFile9, rm as rm2, writeFile as writeFile5 } from "fs/promises";
|
|
24604
|
+
import { lstat, mkdtemp, mkdir as mkdir4, readFile as readFile9, rm as rm2, writeFile as writeFile5 } from "fs/promises";
|
|
24531
24605
|
import { tmpdir as tmpdir2 } from "os";
|
|
24532
24606
|
import { dirname as dirname3, join as join10 } from "path";
|
|
24533
24607
|
|
|
@@ -24637,14 +24711,14 @@ function requireBundlePath(name) {
|
|
|
24637
24711
|
return name;
|
|
24638
24712
|
}
|
|
24639
24713
|
async function unpushedInputs(dir, pkg) {
|
|
24714
|
+
const out = await unpushedLib(dir, pkg);
|
|
24640
24715
|
let inputs = [];
|
|
24641
24716
|
try {
|
|
24642
24717
|
const parsed2 = JSON.parse(await readFile9(reportPath(dir), "utf8"));
|
|
24643
24718
|
if (Array.isArray(parsed2.inputs)) inputs = parsed2.inputs.map(String);
|
|
24644
24719
|
} catch {
|
|
24645
|
-
return
|
|
24720
|
+
return out;
|
|
24646
24721
|
}
|
|
24647
|
-
const out = [];
|
|
24648
24722
|
for (const path3 of inputs.sort()) {
|
|
24649
24723
|
let remote;
|
|
24650
24724
|
if (path3.startsWith("handlers/") && path3.endsWith(".py")) {
|
|
@@ -24659,6 +24733,18 @@ async function unpushedInputs(dir, pkg) {
|
|
|
24659
24733
|
}
|
|
24660
24734
|
return out;
|
|
24661
24735
|
}
|
|
24736
|
+
async function unpushedLib(dir, pkg) {
|
|
24737
|
+
const remote = pkg.lib;
|
|
24738
|
+
if (typeof remote !== "object" || remote === null || Array.isArray(remote)) return [];
|
|
24739
|
+
const out = [];
|
|
24740
|
+
const libDir = join10(dir, "lib");
|
|
24741
|
+
for (const file of (await readDirIfPresent(libDir)).sort()) {
|
|
24742
|
+
if (!file.endsWith(".py")) continue;
|
|
24743
|
+
const local = await readIfPresent(join10(libDir, file));
|
|
24744
|
+
if (local !== void 0 && local !== remote[file.slice(0, -".py".length)]) out.push(`lib/${file}`);
|
|
24745
|
+
}
|
|
24746
|
+
return out;
|
|
24747
|
+
}
|
|
24662
24748
|
async function writePackage(dir, appId, pkg) {
|
|
24663
24749
|
await mkdir4(dir, { recursive: true });
|
|
24664
24750
|
await Promise.all([
|
|
@@ -24692,6 +24778,24 @@ async function writePackage(dir, appId, pkg) {
|
|
|
24692
24778
|
}
|
|
24693
24779
|
}
|
|
24694
24780
|
}
|
|
24781
|
+
if (typeof pkg.lib === "object" && pkg.lib !== null && !Array.isArray(pkg.lib)) {
|
|
24782
|
+
const libDir = join10(dir, "lib");
|
|
24783
|
+
const linked = await lstat(libDir).then((st) => st.isSymbolicLink(), () => false);
|
|
24784
|
+
if (linked) throw new Error(`refusing to write lib modules: ${libDir} is a symbolic link.`);
|
|
24785
|
+
for (const name of Object.keys(pkg.lib)) {
|
|
24786
|
+
const problem6 = libNameProblem(name);
|
|
24787
|
+
if (problem6 !== null) {
|
|
24788
|
+
throw new Error(`refusing to write a lib module named ${JSON.stringify(name)}: it ${problem6}.`);
|
|
24789
|
+
}
|
|
24790
|
+
}
|
|
24791
|
+
for (const file of await readDirIfPresent(libDir)) {
|
|
24792
|
+
if (file.endsWith(".py")) await rm2(join10(libDir, file), { force: true });
|
|
24793
|
+
}
|
|
24794
|
+
for (const [name, code] of Object.entries(pkg.lib)) {
|
|
24795
|
+
await mkdir4(libDir, { recursive: true });
|
|
24796
|
+
await writeFile5(join10(libDir, `${name}.py`), code);
|
|
24797
|
+
}
|
|
24798
|
+
}
|
|
24695
24799
|
const ui = Object.entries(pkg.frontend_bundle ?? {});
|
|
24696
24800
|
if (ui.length > 0) {
|
|
24697
24801
|
await mkdir4(join10(dir, "ui"), { recursive: true });
|
|
@@ -24855,7 +24959,7 @@ async function runGet(appId, opts) {
|
|
|
24855
24959
|
if (unpushed.length > 0) {
|
|
24856
24960
|
const them = unpushed.length === 1 ? "it" : "them";
|
|
24857
24961
|
process.stderr.write(
|
|
24858
|
-
`${dir} holds ${unpushed.join(", ")}, which
|
|
24962
|
+
`${dir} holds ${unpushed.join(", ")}, which are yours and which the pushed package does not hold as written: get replaces handlers/, ui/ and the modules in lib/, and would lose ${them}. Push first (app-space push), or pass --force to discard your copy. Nothing was written.
|
|
24859
24963
|
`
|
|
24860
24964
|
);
|
|
24861
24965
|
return 1;
|
|
@@ -31889,6 +31993,8 @@ function pageRoles2(page) {
|
|
|
31889
31993
|
var NAV_OPEN2 = /<nav\b[^>]*\bdata-dr-kit\s*=\s*["']nav["'][^>]*>/gi;
|
|
31890
31994
|
var ANCHOR2 = /<a\b([^>]*)>/gi;
|
|
31891
31995
|
var HREF2 = /\bhref\s*=\s*["']([^"']*)["']/i;
|
|
31996
|
+
var NAV_HREF2 = /(?<![\w-])href\s*=\s*["']([^"']*)["']/i;
|
|
31997
|
+
var NAV_CLOSE2 = /<\/nav\s*>/i;
|
|
31892
31998
|
var ROLE_ATTR4 = /\bdata-dr-role\s*=\s*["']([^"']*)["']/i;
|
|
31893
31999
|
var PAGE_LITERAL2 = /["'`](?:\.\/)?([A-Za-z0-9_-]+\.html)(?:[?#][^"'`]*)?["'`]/g;
|
|
31894
32000
|
function targetOf2(href, from = "ui/index.html") {
|
|
@@ -31908,15 +32014,15 @@ function navLinks2(html, { owned = false, from } = {}) {
|
|
|
31908
32014
|
if (owned) regions.push(text4);
|
|
31909
32015
|
else {
|
|
31910
32016
|
for (const open2 of text4.matchAll(NAV_OPEN2)) {
|
|
31911
|
-
const
|
|
31912
|
-
const end =
|
|
31913
|
-
regions.push(
|
|
32017
|
+
const rest = text4.slice(open2.index + open2[0].length);
|
|
32018
|
+
const end = rest.search(NAV_CLOSE2);
|
|
32019
|
+
regions.push(end === -1 ? rest : rest.slice(0, end));
|
|
31914
32020
|
}
|
|
31915
32021
|
}
|
|
31916
32022
|
const out = [];
|
|
31917
32023
|
for (const region of regions) {
|
|
31918
32024
|
for (const anchor of region.matchAll(ANCHOR2)) {
|
|
31919
|
-
const target = targetOf2(HREF2.exec(anchor[1])?.[1], from);
|
|
32025
|
+
const target = targetOf2((owned ? HREF2 : NAV_HREF2).exec(anchor[1])?.[1], from);
|
|
31920
32026
|
if (target === null) continue;
|
|
31921
32027
|
out.push({ target, gate: gateRoles2(ROLE_ATTR4.exec(anchor[1])?.[1]) });
|
|
31922
32028
|
}
|
|
@@ -34119,7 +34225,7 @@ function ontoLiveBackoff(attempt, random = Math.random) {
|
|
|
34119
34225
|
return Math.floor(random() * ceiling);
|
|
34120
34226
|
}
|
|
34121
34227
|
var ONTO_LIVE_MARK = ".onto-live";
|
|
34122
|
-
var ONTO_LIVE_OWNED = ["contract.json", "manifest.json", "data_model.json", "handlers", "ui", "transforms", ".appspace.json", ".appspace"];
|
|
34228
|
+
var ONTO_LIVE_OWNED = ["contract.json", "manifest.json", "data_model.json", "handlers", "lib", "ui", "transforms", ".appspace.json", ".appspace"];
|
|
34123
34229
|
async function runShipOntoLive(dir, opts) {
|
|
34124
34230
|
const appId = opts.appId;
|
|
34125
34231
|
const refuse2 = (why) => {
|
|
@@ -40616,6 +40722,7 @@ async function loadFixtures(dir, explicit) {
|
|
|
40616
40722
|
}
|
|
40617
40723
|
async function runHandlerCases(cases, dir, appId, client, roleOf = () => void 0) {
|
|
40618
40724
|
const code = /* @__PURE__ */ new Map();
|
|
40725
|
+
const lib = await readLib(join18(dir, "lib"));
|
|
40619
40726
|
const outcomes = [];
|
|
40620
40727
|
for (const kase of cases) {
|
|
40621
40728
|
requirePlainName("handler", kase.handler, "read");
|
|
@@ -40675,7 +40782,7 @@ async function runHandlerCases(cases, dir, appId, client, roleOf = () => void 0)
|
|
|
40675
40782
|
try {
|
|
40676
40783
|
res = await client.request(`/apps/${encodeURIComponent(appId)}/dry-run`, {
|
|
40677
40784
|
method: "POST",
|
|
40678
|
-
body: { code: source, payload },
|
|
40785
|
+
body: { code: source, payload, ...Object.keys(lib).length > 0 ? { lib } : {} },
|
|
40679
40786
|
...asRole === void 0 ? {} : { headers: { [PREVIEW_ROLE_HEADER]: asRole } }
|
|
40680
40787
|
});
|
|
40681
40788
|
} catch (err) {
|
|
@@ -41732,6 +41839,7 @@ function registerTryCommand(parent) {
|
|
|
41732
41839
|
`no handlers/${handler}.py in ${opts.dir} \u2014 is this an app folder?`
|
|
41733
41840
|
);
|
|
41734
41841
|
});
|
|
41842
|
+
const lib = await readLib(join19(opts.dir, "lib"));
|
|
41735
41843
|
let payload = await readPayloadOption(opts.payload ?? "{}");
|
|
41736
41844
|
const files = parseFileSpecs(opts.file ?? []);
|
|
41737
41845
|
const withFiles = payloadForFiles(payload, files);
|
|
@@ -41772,7 +41880,7 @@ function registerTryCommand(parent) {
|
|
|
41772
41880
|
const fileFields = attached.length === 0 ? {} : { files: attached };
|
|
41773
41881
|
const res = await client.request(`/apps/${encodeURIComponent(appId)}/dry-run`, {
|
|
41774
41882
|
method: "POST",
|
|
41775
|
-
body: { code, payload },
|
|
41883
|
+
body: { code, payload, ...Object.keys(lib).length > 0 ? { lib } : {} },
|
|
41776
41884
|
...asRole === void 0 ? {} : { headers: { [PREVIEW_ROLE_HEADER]: asRole } }
|
|
41777
41885
|
});
|
|
41778
41886
|
if (opts.json === true) {
|