@datarails-ai/dr-appspace-cli 0.12.90 → 0.12.92
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 +122 -6
- 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.92",
|
|
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-16T16:22:02.840Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -3725,6 +3725,13 @@ function describeEntries(res) {
|
|
|
3725
3725
|
});
|
|
3726
3726
|
return lines.join("\n") + "\n";
|
|
3727
3727
|
}
|
|
3728
|
+
var KNOWN_LIMITS = [
|
|
3729
|
+
"Known limit: a host that echoes request headers back can leak the secret to any handler of the app. Approve only hosts that do not echo headers.",
|
|
3730
|
+
"Known limit: a push to a draft changes the published app's hosts at once, not at publish."
|
|
3731
|
+
];
|
|
3732
|
+
function describeLimits() {
|
|
3733
|
+
return KNOWN_LIMITS.join("\n") + "\n";
|
|
3734
|
+
}
|
|
3728
3735
|
async function askYes(question, output) {
|
|
3729
3736
|
const rl = createInterface({ input: process.stdin, output });
|
|
3730
3737
|
try {
|
|
@@ -3760,6 +3767,8 @@ function registerApproveHostsCommand(parent) {
|
|
|
3760
3767
|
say.write(`About to approve for ${appId}:
|
|
3761
3768
|
`);
|
|
3762
3769
|
say.write(describeEntries({ entries: waiting, pending_hosts: [] }));
|
|
3770
|
+
const limits = opts.yes === true ? process.stderr : say;
|
|
3771
|
+
limits.write(describeLimits());
|
|
3763
3772
|
if (opts.yes !== true) {
|
|
3764
3773
|
if (process.stdin.isTTY !== true) {
|
|
3765
3774
|
throw new Error("pass --yes to approve without a terminal to confirm on");
|
|
@@ -38242,6 +38251,96 @@ function manifestText(raw, merge, before) {
|
|
|
38242
38251
|
);
|
|
38243
38252
|
}
|
|
38244
38253
|
}
|
|
38254
|
+
function drWords(manifest) {
|
|
38255
|
+
const caps = manifest["capabilities"];
|
|
38256
|
+
const dr = isObj5(caps) ? caps["dr"] : void 0;
|
|
38257
|
+
return Array.isArray(dr) ? dr.filter((w) => typeof w === "string") : [];
|
|
38258
|
+
}
|
|
38259
|
+
var CONTRACT_PLACES = ["app", "backend"];
|
|
38260
|
+
function mergeContract(raw, words) {
|
|
38261
|
+
const same5 = { text: raw, added: [], skipped: [] };
|
|
38262
|
+
if (words.length === 0) return same5;
|
|
38263
|
+
const byHand = "add dr to app.capabilities and backend.capabilities by hand";
|
|
38264
|
+
let doc;
|
|
38265
|
+
try {
|
|
38266
|
+
doc = JSON.parse(raw);
|
|
38267
|
+
} catch {
|
|
38268
|
+
return { ...same5, skipped: [`contract.json is not valid JSON; ${byHand}`] };
|
|
38269
|
+
}
|
|
38270
|
+
if (!isObj5(doc)) return { ...same5, skipped: [`contract.json is not an object; ${byHand}`] };
|
|
38271
|
+
if (isObj5(doc["app"]) && doc["app"]["kind"] === "dashboard") {
|
|
38272
|
+
return { ...same5, skipped: ["contract.json is a dashboard contract: the dashboard kit does not take a dr grant, so migrate leaves it as it is"] };
|
|
38273
|
+
}
|
|
38274
|
+
const added = [];
|
|
38275
|
+
const skipped = [];
|
|
38276
|
+
const edits = [];
|
|
38277
|
+
try {
|
|
38278
|
+
const style = styleOf(raw);
|
|
38279
|
+
const root = containerOf(raw, skipSpace(raw, 0));
|
|
38280
|
+
const expected = JSON.parse(raw);
|
|
38281
|
+
for (const place of CONTRACT_PLACES) {
|
|
38282
|
+
const holder = doc[place];
|
|
38283
|
+
if (holder === void 0 && place === "backend") continue;
|
|
38284
|
+
if (!isObj5(holder)) {
|
|
38285
|
+
skipped.push(`contract.json ${place}: it is not an object; ${byHand}`);
|
|
38286
|
+
continue;
|
|
38287
|
+
}
|
|
38288
|
+
const caps = holder["capabilities"];
|
|
38289
|
+
if (caps !== void 0 && !isObj5(caps)) {
|
|
38290
|
+
skipped.push(`contract.json ${place}.capabilities: it is not an object; ${byHand}`);
|
|
38291
|
+
continue;
|
|
38292
|
+
}
|
|
38293
|
+
const dr = isObj5(caps) ? caps["dr"] : void 0;
|
|
38294
|
+
if (dr !== void 0 && !Array.isArray(dr)) {
|
|
38295
|
+
skipped.push(`contract.json ${place}.capabilities.dr: it is not a list; ${byHand}`);
|
|
38296
|
+
continue;
|
|
38297
|
+
}
|
|
38298
|
+
const missing = words.filter((w) => !(dr ?? []).includes(w));
|
|
38299
|
+
if (missing.length === 0) continue;
|
|
38300
|
+
const holderSpan = memberOf(root, place);
|
|
38301
|
+
const holderBox = containerOf(raw, holderSpan.start);
|
|
38302
|
+
const capsSpan = memberOf(holderBox, "capabilities");
|
|
38303
|
+
if (capsSpan === void 0) {
|
|
38304
|
+
const multiline = raw.slice(holderBox.open, holderBox.close).includes("\n");
|
|
38305
|
+
edits.push(insertion(raw, holderBox, [`"capabilities": ${rendered({ dr: missing }, 2, style, multiline)}`], 1, style));
|
|
38306
|
+
} else {
|
|
38307
|
+
const capsBox = containerOf(raw, capsSpan.start);
|
|
38308
|
+
const drSpan = memberOf(capsBox, "dr");
|
|
38309
|
+
if (drSpan === void 0) {
|
|
38310
|
+
const multiline = raw.slice(capsBox.open, capsBox.close).includes("\n");
|
|
38311
|
+
edits.push(insertion(raw, capsBox, [`"dr": ${rendered(missing, 3, style, multiline)}`], 2, style));
|
|
38312
|
+
} else {
|
|
38313
|
+
edits.push(insertion(raw, containerOf(raw, drSpan.start), missing.map((w) => JSON.stringify(w)), 3, style));
|
|
38314
|
+
}
|
|
38315
|
+
}
|
|
38316
|
+
const target = expected[place];
|
|
38317
|
+
const held = isObj5(target["capabilities"]) ? target["capabilities"] : {};
|
|
38318
|
+
target["capabilities"] = { ...held, dr: [...Array.isArray(held["dr"]) ? held["dr"] : [], ...missing] };
|
|
38319
|
+
for (const word of missing) added.push(`contract.json ${place}.capabilities.dr: ${word}`);
|
|
38320
|
+
}
|
|
38321
|
+
if (edits.length === 0) return { ...same5, skipped };
|
|
38322
|
+
let out = raw;
|
|
38323
|
+
for (const edit of [...edits].sort((a, b) => b.at - a.at)) {
|
|
38324
|
+
out = out.slice(0, edit.at) + edit.text + out.slice(edit.at);
|
|
38325
|
+
}
|
|
38326
|
+
if (canonical6(JSON.parse(out)) !== canonical6(expected)) throw new NotJson();
|
|
38327
|
+
return { text: out, added, skipped };
|
|
38328
|
+
} catch (err) {
|
|
38329
|
+
if (!(err instanceof NotJson) && !(err instanceof SyntaxError)) throw err;
|
|
38330
|
+
return { ...same5, skipped: [`migrate could not edit contract.json in its own layout; ${byHand}`] };
|
|
38331
|
+
}
|
|
38332
|
+
}
|
|
38333
|
+
var CONTRACT_POINT = "contract";
|
|
38334
|
+
function contractPoints(merge) {
|
|
38335
|
+
const words = [...new Set(merge.added.map((a) => a.slice(a.lastIndexOf(": ") + 2)))];
|
|
38336
|
+
const places = [...new Set(merge.added.map((a) => a.slice(14, a.indexOf(".", 14))))];
|
|
38337
|
+
return [
|
|
38338
|
+
...merge.added.length === 0 ? [] : [
|
|
38339
|
+
`--write adds dr (${words.join(", ")}) to ${places.map((p) => `${p}.capabilities`).join(" and ")} in contract.json, so the next compile keeps the grant`
|
|
38340
|
+
],
|
|
38341
|
+
...merge.skipped
|
|
38342
|
+
];
|
|
38343
|
+
}
|
|
38245
38344
|
function previewOf(body) {
|
|
38246
38345
|
if (!isObj5(body) || typeof body["diff"] !== "string" || !Array.isArray(body["files"]) || !Array.isArray(body["points"]) || !isObj5(body["manifest"])) {
|
|
38247
38346
|
throw new MigrateRefused("the server answered, but not with a migrate preview.");
|
|
@@ -38306,6 +38405,7 @@ async function runMigrate(dir, opts) {
|
|
|
38306
38405
|
if (canonical6(JSON.parse(manifestSent)) !== canonical6(manifest)) {
|
|
38307
38406
|
throw new MigrateRefused("manifest.json changed while migrate read it. Run migrate again.");
|
|
38308
38407
|
}
|
|
38408
|
+
const contractSent = await readIfPresent(join19(dir, "contract.json"));
|
|
38309
38409
|
const handlers = await readHandlers(join19(dir, "handlers"), await readState(dir));
|
|
38310
38410
|
const lib = await readLib(join19(dir, "lib"));
|
|
38311
38411
|
const sent = {};
|
|
@@ -38323,11 +38423,19 @@ async function runMigrate(dir, opts) {
|
|
|
38323
38423
|
} finally {
|
|
38324
38424
|
client.cleanup();
|
|
38325
38425
|
}
|
|
38426
|
+
const merge = mergeManifest(JSON.parse(manifestSent), preview.manifest);
|
|
38427
|
+
const contractMerge = contractSent === void 0 ? void 0 : mergeContract(contractSent, [.../* @__PURE__ */ new Set([...drWords(merge.manifest), ...drWords(preview.manifest)])]);
|
|
38326
38428
|
if (opts.write !== true) {
|
|
38327
|
-
|
|
38429
|
+
const extra = contractMerge === void 0 ? [] : contractPoints(contractMerge);
|
|
38430
|
+
const shown3 = {
|
|
38431
|
+
...preview,
|
|
38432
|
+
points: [...preview.points, ...extra.map((text4) => ({ kind: CONTRACT_POINT, file: "contract.json", line: null, text: text4 }))],
|
|
38433
|
+
counts: extra.length === 0 ? preview.counts : { ...preview.counts, [CONTRACT_POINT]: extra.length }
|
|
38434
|
+
};
|
|
38435
|
+
if (opts.json === true) printJson({ ...shown3, written: [] });
|
|
38328
38436
|
else {
|
|
38329
|
-
process.stdout.write(renderPreview(
|
|
38330
|
-
if (preview.diff !== "" || Object.keys(preview.manifest).length > 0) {
|
|
38437
|
+
process.stdout.write(renderPreview(shown3));
|
|
38438
|
+
if (preview.diff !== "" || Object.keys(preview.manifest).length > 0 || extra.length > 0) {
|
|
38331
38439
|
process.stdout.write("Dry run: nothing was written. Run again with --write to apply the diff and the manifest additions.\n");
|
|
38332
38440
|
}
|
|
38333
38441
|
}
|
|
@@ -38338,7 +38446,6 @@ async function runMigrate(dir, opts) {
|
|
|
38338
38446
|
if (manifestNow !== manifestSent) {
|
|
38339
38447
|
throw new MigrateRefused("manifest.json changed since migrate read it. Run migrate again.");
|
|
38340
38448
|
}
|
|
38341
|
-
const merge = mergeManifest(JSON.parse(manifestSent), preview.manifest);
|
|
38342
38449
|
const plan = [];
|
|
38343
38450
|
for (const [path3, text4] of Object.entries(files)) {
|
|
38344
38451
|
if (text4 !== sent[path3]) plan.push({ path: path3, old: sent[path3], text: text4 });
|
|
@@ -38350,6 +38457,9 @@ async function runMigrate(dir, opts) {
|
|
|
38350
38457
|
text: manifestText(manifestSent, merge, JSON.parse(manifestSent))
|
|
38351
38458
|
});
|
|
38352
38459
|
}
|
|
38460
|
+
if (contractMerge !== void 0 && contractMerge.added.length > 0) {
|
|
38461
|
+
plan.push({ path: "contract.json", old: contractSent, text: contractMerge.text });
|
|
38462
|
+
}
|
|
38353
38463
|
for (const step of plan) await writable(dir, step.path, step.old);
|
|
38354
38464
|
const written = [];
|
|
38355
38465
|
let check5 = null;
|
|
@@ -38414,6 +38524,8 @@ async function runMigrate(dir, opts) {
|
|
|
38414
38524
|
written,
|
|
38415
38525
|
manifest_added: merge.added,
|
|
38416
38526
|
manifest_skipped: merge.skipped,
|
|
38527
|
+
contract_added: contractMerge?.added ?? [],
|
|
38528
|
+
contract_skipped: contractMerge?.skipped ?? [],
|
|
38417
38529
|
warnings,
|
|
38418
38530
|
check: check5
|
|
38419
38531
|
});
|
|
@@ -38425,8 +38537,12 @@ ${written.map((p) => ` ${p}
|
|
|
38425
38537
|
`).join("")}`
|
|
38426
38538
|
);
|
|
38427
38539
|
for (const line2 of merge.added) process.stdout.write(` added ${line2}
|
|
38540
|
+
`);
|
|
38541
|
+
for (const line2 of contractMerge?.added ?? []) process.stdout.write(` added ${line2}
|
|
38428
38542
|
`);
|
|
38429
38543
|
for (const line2 of merge.skipped) process.stderr.write(`warning: manifest.json ${line2}
|
|
38544
|
+
`);
|
|
38545
|
+
for (const line2 of contractMerge?.skipped ?? []) process.stderr.write(`warning: ${line2}
|
|
38430
38546
|
`);
|
|
38431
38547
|
for (const line2 of warnings) process.stderr.write(`warning: ${line2}
|
|
38432
38548
|
`);
|