@datarails-ai/dr-appspace-cli 0.12.59 → 0.12.61
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 +20 -0
- package/dist/cli.js +143 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -318,6 +318,26 @@ column on the record and nothing else: the contract document, the compiled
|
|
|
318
318
|
pages and the dashboard are the same with or without it. The builder flows
|
|
319
319
|
set `DR_APPSPACE_KIT` in their sandboxes.
|
|
320
320
|
|
|
321
|
+
**A transform edited since the compile is refused by `push`.** A handler is
|
|
322
|
+
one file, so each source's (or dashboard's) transform rides inside it as text,
|
|
323
|
+
copied in by the last `compile`; `push` sends `handlers/`, not `transforms/`.
|
|
324
|
+
When a `transforms/*.py` differs from the text the compiled handlers carry,
|
|
325
|
+
`push` sends nothing and names the file and the handlers: run `compile --push`
|
|
326
|
+
(or `compile`, then `push`). It refuses rather than recompiling because `push`
|
|
327
|
+
writes nothing into the folder — what a handler may be overwritten with is
|
|
328
|
+
`compile`'s to decide.
|
|
329
|
+
|
|
330
|
+
**The `tests.json` the compiler writes is the compiler's** until somebody
|
|
331
|
+
edits it: an unedited one (its bytes still the digest `.appspace/compile.json`
|
|
332
|
+
recorded) is written again from the contract on every compile, so it gains a
|
|
333
|
+
case for a handler added since and loses one a newer generator no longer
|
|
334
|
+
writes. An edited one is carried as written and recorded under `inputs`. The
|
|
335
|
+
generated cases hold in a dry run: an insert (`save`/`submit` with no
|
|
336
|
+
`required`) carries a sample of every column the table requires (an enum's
|
|
337
|
+
first value, `1`, `2000-01-01`, text marked `app-space test`), and a source
|
|
338
|
+
reading a declared metric (`"@key"`), which a dry run cannot bind, is asked
|
|
339
|
+
only for `meta.source.kind`, not its kind's payload.
|
|
340
|
+
|
|
321
341
|
**Push before `get`**: `get` replaces `handlers/` and `ui/` with what the
|
|
322
342
|
platform holds, and refuses (unless `--force`) while the compile record lists
|
|
323
343
|
files as yours that the pushed package does not hold as written.
|
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.61",
|
|
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-01T20:35:20.518Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -12243,16 +12243,16 @@ function metricFormatProblem(format) {
|
|
|
12243
12243
|
}
|
|
12244
12244
|
|
|
12245
12245
|
// ../flows/insights-builder/kit/contract/compileApp.mjs
|
|
12246
|
-
var RUNTIME = "dr-app-runtime@1.13.
|
|
12246
|
+
var RUNTIME = "dr-app-runtime@1.13.5";
|
|
12247
12247
|
var UI_KIT2 = "ui-kit/v4";
|
|
12248
12248
|
var CHARTS = "echarts@5.6.0";
|
|
12249
12249
|
var FMT = "dr-fmt@2.1.0";
|
|
12250
12250
|
var TOKENS = "dr-tokens@1.0.0";
|
|
12251
|
-
var WIDGETS = "dr-app-widgets@1.6.
|
|
12251
|
+
var WIDGETS = "dr-app-widgets@1.6.3";
|
|
12252
12252
|
var COMPONENTS = "dr-components@1.6.0";
|
|
12253
|
-
var CONTROLS = "dr-components-controls@1.2.
|
|
12253
|
+
var CONTROLS = "dr-components-controls@1.2.1";
|
|
12254
12254
|
var DASHBOARD_RUNTIME = "dr-app-runtime@1.13.4";
|
|
12255
|
-
var DASHBOARD_WIDGETS = "dr-app-widgets@1.6.
|
|
12255
|
+
var DASHBOARD_WIDGETS = "dr-app-widgets@1.6.3";
|
|
12256
12256
|
var DASHBOARD_BAR = "dr-app-dashboard@1.0.0";
|
|
12257
12257
|
var ASSISTANT = "dr-insights@1.4.1";
|
|
12258
12258
|
var MARKDOWN = "dr-md@1.0.0";
|
|
@@ -13860,7 +13860,7 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
13860
13860
|
for (const page of compiled) files[page.path] = pageHtml2(whole, page, elements, tree, model, pageOpts);
|
|
13861
13861
|
}
|
|
13862
13862
|
if (typeof extra["seed.json"] === "string") files["seed.json"] = extra["seed.json"];
|
|
13863
|
-
files["tests.json"] = typeof extra["tests.json"] === "string" ? extra["tests.json"] : json(testsOf(handlers, names, sources, served));
|
|
13863
|
+
files["tests.json"] = typeof extra["tests.json"] === "string" ? extra["tests.json"] : json(testsOf(handlers, names, sources, served, model));
|
|
13864
13864
|
return { files, problems, contract: whole, order: order2, warnings };
|
|
13865
13865
|
}
|
|
13866
13866
|
function refreshPins(contract, compiled, files) {
|
|
@@ -17302,20 +17302,59 @@ contract, not this file.`,
|
|
|
17302
17302
|
].join("\n")
|
|
17303
17303
|
}
|
|
17304
17304
|
};
|
|
17305
|
-
function testsOf(handlers, names, sources = {}, served = []) {
|
|
17305
|
+
function testsOf(handlers, names, sources = {}, served = [], model = { tables: {} }) {
|
|
17306
17306
|
const cases = {};
|
|
17307
17307
|
for (const name of names) {
|
|
17308
17308
|
const row = handlers[name] ?? {};
|
|
17309
|
-
const one = testCase(name, row);
|
|
17309
|
+
const one = testCase(name, row, model);
|
|
17310
17310
|
if (one !== null) cases[name] = [one];
|
|
17311
17311
|
}
|
|
17312
17312
|
for (const name of served) {
|
|
17313
17313
|
const shape = sources[name]?.shape;
|
|
17314
|
-
cases[name] =
|
|
17314
|
+
cases[name] = readsDeclaredMetric(sources[name]) ? (
|
|
17315
|
+
// Bound or not, the card names where its figure comes from
|
|
17316
|
+
// (`meta.source.kind: "metric"`): the one fact a dry run, which binds
|
|
17317
|
+
// nothing, shares with a pushed version. `app-space ship` binds the
|
|
17318
|
+
// metric and checks the source against the draft after its push.
|
|
17319
|
+
[{ name: `${name} names the declared metric it reads`, payload: {}, shape: { meta: { source: { kind: "string" } } } }]
|
|
17320
|
+
) : shape === void 0 || shape === "rows" ? [{ name: `${name} answers with rows`, payload: {}, shape: { rows: [] } }] : [{ name: `${name} answers a ${shape} payload`, payload: {}, shape: { kind: "string" } }];
|
|
17315
17321
|
}
|
|
17316
17322
|
return { handlers: Object.fromEntries(Object.keys(cases).sort(natural3).map((name) => [name, cases[name]])), ui: { entry: "index.html" } };
|
|
17317
17323
|
}
|
|
17318
|
-
function
|
|
17324
|
+
function readsDeclaredMetric(source) {
|
|
17325
|
+
const metric = source?.from?.financeos?.metric;
|
|
17326
|
+
return typeof metric === "string" && metric.startsWith("@");
|
|
17327
|
+
}
|
|
17328
|
+
var SAMPLE_MARK = "app-space test";
|
|
17329
|
+
function sampleValue(column) {
|
|
17330
|
+
if (column.ref !== null || column.type === "file") return void 0;
|
|
17331
|
+
if (Array.isArray(column.enum) && column.enum.length > 0) return column.enum[0];
|
|
17332
|
+
if (column.type === "bool") return true;
|
|
17333
|
+
if (column.type === "int" || column.type === "bigint" || /^decimal\(/.test(column.type)) return 1;
|
|
17334
|
+
if (column.type === "date") return "2000-01-01";
|
|
17335
|
+
if (column.type === "timestamptz") return "2000-01-01T00:00:00Z";
|
|
17336
|
+
if (column.type === "jsonb") return {};
|
|
17337
|
+
if (column.type === "uuid") return "00000000-0000-4000-8000-000000000000";
|
|
17338
|
+
return `${SAMPLE_MARK} ${column.name}`;
|
|
17339
|
+
}
|
|
17340
|
+
function insertPayload(row, model) {
|
|
17341
|
+
const table = model?.tables?.[row.table];
|
|
17342
|
+
if (table === void 0) return {};
|
|
17343
|
+
const fields = new Set(Array.isArray(row.fields) ? row.fields : []);
|
|
17344
|
+
const fixed = isPlainObject8(row.fixed) ? row.fixed : {};
|
|
17345
|
+
const defaults = isPlainObject8(table.defaults) ? table.defaults : {};
|
|
17346
|
+
const payload = {};
|
|
17347
|
+
for (const column of Object.values(table.columns)) {
|
|
17348
|
+
if (column.pk || column.nullable || column.default !== null || column.computed !== null) continue;
|
|
17349
|
+
if (Object.prototype.hasOwnProperty.call(fixed, column.name) || Object.prototype.hasOwnProperty.call(defaults, column.name)) continue;
|
|
17350
|
+
if (!fields.has(column.name)) return null;
|
|
17351
|
+
const value = sampleValue(column);
|
|
17352
|
+
if (value === void 0) return null;
|
|
17353
|
+
payload[column.name] = value;
|
|
17354
|
+
}
|
|
17355
|
+
return payload;
|
|
17356
|
+
}
|
|
17357
|
+
function testCase(name, row, model = { tables: {} }) {
|
|
17319
17358
|
switch (row.role) {
|
|
17320
17359
|
case "list":
|
|
17321
17360
|
case "inbox":
|
|
@@ -17340,7 +17379,10 @@ function testCase(name, row) {
|
|
|
17340
17379
|
if (required.length === 0 && row.role === "submit" && named5(row.by)) {
|
|
17341
17380
|
return { name: `${name} refuses a row with no ${row.by}`, payload: {}, expect: { error: `${row.by} is required` } };
|
|
17342
17381
|
}
|
|
17343
|
-
if (required.length === 0)
|
|
17382
|
+
if (required.length === 0) {
|
|
17383
|
+
const payload = insertPayload(row, model);
|
|
17384
|
+
return payload === null ? null : { name: `${name} writes the row it is given`, payload, shape: { row: {} } };
|
|
17385
|
+
}
|
|
17344
17386
|
return { name: `${name} refuses a row with nothing in it`, payload: {}, expect: { error: `${required[0]} is required` } };
|
|
17345
17387
|
}
|
|
17346
17388
|
case "remove":
|
|
@@ -23119,8 +23161,41 @@ function chartsWithoutEcharts(files) {
|
|
|
23119
23161
|
}
|
|
23120
23162
|
return out;
|
|
23121
23163
|
}
|
|
23164
|
+
async function staleTransforms(dir, handlers) {
|
|
23165
|
+
const stale = /* @__PURE__ */ new Map();
|
|
23166
|
+
const onDisk = /* @__PURE__ */ new Map();
|
|
23167
|
+
for (const name of Object.keys(handlers).sort()) {
|
|
23168
|
+
const code = handlers[name]?.code ?? "";
|
|
23169
|
+
if (!code.includes("TRANSFORMS")) continue;
|
|
23170
|
+
const carried = [
|
|
23171
|
+
...readSources([{ source: code }]).owned
|
|
23172
|
+
];
|
|
23173
|
+
const table = readTransforms(code);
|
|
23174
|
+
for (const [path3, text4] of Object.entries(table.texts ?? {})) carried.push({ path: path3, text: text4 });
|
|
23175
|
+
for (const { path: path3, text: text4 } of carried) {
|
|
23176
|
+
if (!onDisk.has(path3)) onDisk.set(path3, await readIfPresent(join8(dir, path3)));
|
|
23177
|
+
const current = onDisk.get(path3);
|
|
23178
|
+
if (current === void 0 || current === text4) continue;
|
|
23179
|
+
if (!stale.has(path3)) stale.set(path3, /* @__PURE__ */ new Set());
|
|
23180
|
+
stale.get(path3)?.add(`handlers/${name}.py`);
|
|
23181
|
+
}
|
|
23182
|
+
}
|
|
23183
|
+
return [...stale.keys()].sort().map((path3) => ({ path: path3, handlers: [...stale.get(path3) ?? []].sort() }));
|
|
23184
|
+
}
|
|
23185
|
+
function staleTransformsMessage(stale) {
|
|
23186
|
+
const lines = stale.map((one) => {
|
|
23187
|
+
const shown2 = one.handlers.slice(0, 3).join(", ");
|
|
23188
|
+
const more = one.handlers.length > 3 ? ` and ${String(one.handlers.length - 3)} more` : "";
|
|
23189
|
+
return ` ${one.path} \u2014 ${shown2}${more} still carry the text of the last compile`;
|
|
23190
|
+
});
|
|
23191
|
+
return `nothing was pushed: ${stale.length === 1 ? "a transform has" : "transforms have"} changed since the handlers were compiled, and push sends the handlers (which carry each transform as text), not transforms/ \u2014 so it would upload the old code:
|
|
23192
|
+
${lines.join("\n")}
|
|
23193
|
+
Run \`app-space compile --push\` (or \`app-space compile\`, then push) so the handlers carry what transforms/ holds.`;
|
|
23194
|
+
}
|
|
23122
23195
|
async function pushFolder(dir, opts) {
|
|
23123
23196
|
const { appId, body, handlers } = await pushBody(dir, opts);
|
|
23197
|
+
const stale = await staleTransforms(dir, handlers);
|
|
23198
|
+
if (stale.length > 0) throw new Error(staleTransformsMessage(stale));
|
|
23124
23199
|
const client = await connect(opts);
|
|
23125
23200
|
try {
|
|
23126
23201
|
if (opts.metricBindings === void 0 && Object.keys(declaredMetrics(body["contract"])).length > 0) {
|
|
@@ -31245,9 +31320,9 @@ var kit_default2 = {
|
|
|
31245
31320
|
checks: "checks/run.mjs",
|
|
31246
31321
|
contract: "contract/extract.mjs",
|
|
31247
31322
|
charts: "echarts@5.6.0",
|
|
31248
|
-
appWidgets: "dr-app-widgets@1.6.
|
|
31323
|
+
appWidgets: "dr-app-widgets@1.6.3",
|
|
31249
31324
|
appComponents: "dr-components@1.6.0",
|
|
31250
|
-
appControls: "dr-components-controls@1.2.
|
|
31325
|
+
appControls: "dr-components-controls@1.2.1"
|
|
31251
31326
|
};
|
|
31252
31327
|
|
|
31253
31328
|
// src/commands/appspace/compile.ts
|
|
@@ -31839,7 +31914,8 @@ async function writePlan(dir, kind, contract, files, paths, force) {
|
|
|
31839
31914
|
}
|
|
31840
31915
|
const existing = await readIfPresent(join15(dir, path3));
|
|
31841
31916
|
if (existing === files[path3]) {
|
|
31842
|
-
|
|
31917
|
+
const ours = owned.has(path3) && (!AUTHOR_FILES.has(path3) || existing !== void 0 && digests[path3] === digestOf(existing));
|
|
31918
|
+
if (!ours && AUTHOR_FILES.has(path3)) plan.inputs.push(path3);
|
|
31843
31919
|
else plan.owned.push(path3);
|
|
31844
31920
|
continue;
|
|
31845
31921
|
}
|
|
@@ -32423,6 +32499,9 @@ async function folderFiles(dir) {
|
|
|
32423
32499
|
const text4 = await readIfPresent(join15(dir, name));
|
|
32424
32500
|
if (text4 !== void 0) out[name] = text4;
|
|
32425
32501
|
}
|
|
32502
|
+
if (out["tests.json"] !== void 0 && await generatedUnedited(dir, "tests.json", out["tests.json"])) {
|
|
32503
|
+
delete out["tests.json"];
|
|
32504
|
+
}
|
|
32426
32505
|
for (const file of await readDirIfPresent(join15(dir, "handlers"))) {
|
|
32427
32506
|
if (!file.endsWith(".py")) continue;
|
|
32428
32507
|
const text4 = await readIfPresent(join15(dir, "handlers", file));
|
|
@@ -32440,6 +32519,11 @@ async function folderFiles(dir) {
|
|
|
32440
32519
|
}
|
|
32441
32520
|
return { ...out, ...await transformFiles(dir) };
|
|
32442
32521
|
}
|
|
32522
|
+
async function generatedUnedited(dir, path3, text4) {
|
|
32523
|
+
if (!(await ownedFiles(dir)).has(path3)) return false;
|
|
32524
|
+
const recorded = (await recordedDigests(dir))[path3];
|
|
32525
|
+
return recorded !== void 0 && recorded === digestOf(text4);
|
|
32526
|
+
}
|
|
32443
32527
|
async function transformFiles(dir) {
|
|
32444
32528
|
const out = {};
|
|
32445
32529
|
for (const file of await readDirIfPresent(join15(dir, "transforms"))) {
|
|
@@ -38304,6 +38388,7 @@ function unreachedFindings(declared, cases, contract, runs) {
|
|
|
38304
38388
|
function builderOwns(name, handlers) {
|
|
38305
38389
|
if (handlers === null) return true;
|
|
38306
38390
|
const declared = handlers[name];
|
|
38391
|
+
if (declared?.role === "source") return typeof declared.transform === "string" && declared.transform !== "";
|
|
38307
38392
|
return declared === void 0 || declared.role === "custom";
|
|
38308
38393
|
}
|
|
38309
38394
|
function neverRan(outcome) {
|
|
@@ -38311,13 +38396,26 @@ function neverRan(outcome) {
|
|
|
38311
38396
|
return first.startsWith("not run:") || first.startsWith("could not run it:");
|
|
38312
38397
|
}
|
|
38313
38398
|
function builderTestFindings(outcomes, handlers) {
|
|
38314
|
-
return outcomes.filter((outcome) => !outcome.ok && !neverRan(outcome) && builderOwns(outcome.handler, handlers)).map((outcome) =>
|
|
38315
|
-
|
|
38316
|
-
|
|
38317
|
-
|
|
38318
|
-
|
|
38319
|
-
|
|
38320
|
-
|
|
38399
|
+
return outcomes.filter((outcome) => !outcome.ok && !neverRan(outcome) && builderOwns(outcome.handler, handlers)).map((outcome) => {
|
|
38400
|
+
const message = `the case "${outcome.name}" fails: ${(outcome.problems[0] ?? "it failed").replace(/\s+/g, " ").trim()}`;
|
|
38401
|
+
const transform = handlers?.[outcome.handler]?.role === "source" ? handlers[outcome.handler]?.transform : void 0;
|
|
38402
|
+
if (transform !== void 0) {
|
|
38403
|
+
return {
|
|
38404
|
+
code: "builder-test-failure",
|
|
38405
|
+
where: transform,
|
|
38406
|
+
message,
|
|
38407
|
+
fix: `fix ${transform} (the transform source "${outcome.handler}" runs: yours, carried into the compiled handler), or its row in contract.json data.sources, or the case in tests.json if the case is what is wrong; compile again after.`,
|
|
38408
|
+
see: SEE.handlers
|
|
38409
|
+
};
|
|
38410
|
+
}
|
|
38411
|
+
return {
|
|
38412
|
+
code: "builder-test-failure",
|
|
38413
|
+
where: `handlers/${outcome.handler}.py`,
|
|
38414
|
+
message,
|
|
38415
|
+
fix: `fix handlers/${outcome.handler}.py (a custom handler: yours, and the compiler never rewrites it), or the case in tests.json if the case is what is wrong.`,
|
|
38416
|
+
see: SEE.handlers
|
|
38417
|
+
};
|
|
38418
|
+
});
|
|
38321
38419
|
}
|
|
38322
38420
|
function customFindings(runs) {
|
|
38323
38421
|
const out = [];
|
|
@@ -39017,9 +39115,14 @@ function formatFindings(findings) {
|
|
|
39017
39115
|
const n = findings.length;
|
|
39018
39116
|
const warnings = findings.filter((finding) => finding.severity === "warning").length;
|
|
39019
39117
|
const handlers = findings.some(
|
|
39020
|
-
(finding) => finding.code === "builder-test-failure" || finding.code === "payload-key-unproduced"
|
|
39118
|
+
(finding) => finding.code === "builder-test-failure" && !finding.where.startsWith("transforms/") || finding.code === "payload-key-unproduced"
|
|
39021
39119
|
);
|
|
39022
|
-
const
|
|
39120
|
+
const transforms = findings.some((finding) => finding.code === "builder-test-failure" && finding.where.startsWith("transforms/"));
|
|
39121
|
+
const yours = [
|
|
39122
|
+
...handlers ? ["custom handlers: the handlers/*.py named"] : [],
|
|
39123
|
+
...transforms ? ["transforms: the transforms/*.py named"] : []
|
|
39124
|
+
];
|
|
39125
|
+
const where2 = yours.length > 0 ? `contract.json (${yours.join("; ")})` : "contract.json";
|
|
39023
39126
|
const counted = warnings === 0 ? "" : ` (${String(warnings)} of them ${warnings === 1 ? "a warning" : "warnings"}, which --strict does not count)`;
|
|
39024
39127
|
out += n === 1 ? `1 finding${counted}: fix it in ${where2} and push again.
|
|
39025
39128
|
` : `${String(n)} findings${counted}: fix them in ${where2} and push again.
|
|
@@ -39816,12 +39919,24 @@ async function readSeed(dir) {
|
|
|
39816
39919
|
async function handlerOwnership(dir, pushed) {
|
|
39817
39920
|
try {
|
|
39818
39921
|
const local = JSON.parse(await readFile13(join18(dir, "contract.json"), "utf8"));
|
|
39819
|
-
const
|
|
39820
|
-
if (
|
|
39922
|
+
const owned = ownershipOf(local);
|
|
39923
|
+
if (owned !== null) return owned;
|
|
39821
39924
|
} catch {
|
|
39822
39925
|
}
|
|
39823
|
-
|
|
39824
|
-
|
|
39926
|
+
return pushed === null ? null : ownershipOf(pushed);
|
|
39927
|
+
}
|
|
39928
|
+
function ownershipOf(contract) {
|
|
39929
|
+
const handlers = contract.data?.app?.handlers;
|
|
39930
|
+
const sources = contract.data?.sources;
|
|
39931
|
+
const hasHandlers = typeof handlers === "object" && handlers !== null;
|
|
39932
|
+
const hasSources = typeof sources === "object" && sources !== null;
|
|
39933
|
+
if (!hasHandlers && !hasSources) return null;
|
|
39934
|
+
const out = {};
|
|
39935
|
+
for (const [name, row] of Object.entries(hasSources ? sources : {})) {
|
|
39936
|
+
const transform = row?.transform;
|
|
39937
|
+
out[name] = typeof transform === "string" && transform !== "" ? { role: "source", transform } : { role: "source" };
|
|
39938
|
+
}
|
|
39939
|
+
return { ...out, ...hasHandlers ? handlers : {} };
|
|
39825
39940
|
}
|
|
39826
39941
|
function findingsNotChecked(factsRead, contract) {
|
|
39827
39942
|
if (!factsRead) {
|