@datarails-ai/dr-appspace-cli 0.12.42 → 0.12.44

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.
Files changed (2) hide show
  1. package/dist/cli.js +86 -17
  2. 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.42",
16
+ version: "0.12.44",
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-10-26T20:49:33.152Z";
60
+ var BUILD_TIME = "2026-10-28T20:53:49.012Z";
61
61
  function formatBuildTime(iso) {
62
62
  if (iso === "") return "";
63
63
  const d = new Date(iso);
@@ -6518,6 +6518,17 @@ function readMount(scripts, problems) {
6518
6518
  }
6519
6519
  return null;
6520
6520
  }
6521
+ function pinsOfPages(pages) {
6522
+ const byPath = /* @__PURE__ */ new Map();
6523
+ for (const page of pages) {
6524
+ for (const pin of pinsOf(page, decodedTree(page.text))) {
6525
+ const found = byPath.get(pin.path);
6526
+ if (found) found.pages.push(page.path);
6527
+ else byPath.set(pin.path, { ...pin, pages: [page.path], order: byPath.size });
6528
+ }
6529
+ }
6530
+ return [...byPath.values()].map((pin) => ({ ...pin, pages: [...new Set(pin.pages)].sort() })).sort((a, b) => a.order - b.order);
6531
+ }
6521
6532
  function pinsOf(page, tree) {
6522
6533
  const pins = [];
6523
6534
  for (const element of tree.nodes) {
@@ -12210,16 +12221,16 @@ function metricFormatProblem(format) {
12210
12221
  }
12211
12222
 
12212
12223
  // ../flows/insights-builder/kit/contract/compileApp.mjs
12213
- var RUNTIME = "dr-app-runtime@1.13.1";
12224
+ var RUNTIME = "dr-app-runtime@1.13.2";
12214
12225
  var UI_KIT2 = "ui-kit/v4";
12215
12226
  var CHARTS = "echarts@5.6.0";
12216
12227
  var FMT = "dr-fmt@2.1.0";
12217
12228
  var TOKENS = "dr-tokens@1.0.0";
12218
- var WIDGETS = "dr-app-widgets@1.6.0";
12229
+ var WIDGETS = "dr-app-widgets@1.6.1";
12219
12230
  var COMPONENTS = "dr-components@1.6.0";
12220
12231
  var CONTROLS = "dr-components-controls@1.2.0";
12221
- var DASHBOARD_RUNTIME = "dr-app-runtime@1.13.1";
12222
- var DASHBOARD_WIDGETS = "dr-app-widgets@1.6.0";
12232
+ var DASHBOARD_RUNTIME = "dr-app-runtime@1.13.2";
12233
+ var DASHBOARD_WIDGETS = "dr-app-widgets@1.6.1";
12223
12234
  var DASHBOARD_BAR = "dr-app-dashboard@1.0.0";
12224
12235
  var ASSISTANT = "dr-insights@1.4.1";
12225
12236
  var MARKDOWN = "dr-md@1.0.0";
@@ -13802,7 +13813,7 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
13802
13813
  const order2 = emittedOrder(contract, elements, pages, tree);
13803
13814
  problems.push(...placementProblems(elements, pages, tree, order2));
13804
13815
  if (problems.length > 0) return { files: {}, problems, contract, warnings };
13805
- const whole = restate(contract, elements, pages, typed, order2);
13816
+ let whole = restate(contract, elements, pages, typed, order2);
13806
13817
  const served = servedSources({ ...elements, ...owned.readers }, sources);
13807
13818
  const transforms = transformTexts2(sources, extra);
13808
13819
  const files = {};
@@ -13818,14 +13829,31 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
13818
13829
  if (theme !== null) files[THEME_FILE4] = themeCss(theme);
13819
13830
  files[PALETTE_FILE] = paletteCss();
13820
13831
  if (pages.some((page) => page.owned !== true && tokensOn(page, elements))) files[BADGES_FILE] = badgesCss();
13821
- for (const page of pages) {
13822
- if (page.owned === true) continue;
13823
- files[page.path] = pageHtml2(whole, page, elements, tree, model, { runtime, uiKit, charts, fmt, appWidgets, appComponents, appControls, theme: theme !== null, extra });
13832
+ const pageOpts = { runtime, uiKit, charts, fmt, appWidgets, appComponents, appControls, theme: theme !== null, extra };
13833
+ const compiled = pages.filter((page) => page.owned !== true);
13834
+ for (const page of compiled) files[page.path] = pageHtml2(whole, page, elements, tree, model, pageOpts);
13835
+ const refreshed = refreshPins(whole, compiled, files);
13836
+ if (refreshed !== whole) {
13837
+ whole = refreshed;
13838
+ for (const page of compiled) files[page.path] = pageHtml2(whole, page, elements, tree, model, pageOpts);
13824
13839
  }
13825
13840
  if (typeof extra["seed.json"] === "string") files["seed.json"] = extra["seed.json"];
13826
13841
  files["tests.json"] = typeof extra["tests.json"] === "string" ? extra["tests.json"] : json(testsOf(handlers, names, sources, served));
13827
13842
  return { files, problems, contract: whole, order: order2, warnings };
13828
13843
  }
13844
+ function refreshPins(contract, compiled, files) {
13845
+ if (!Array.isArray(contract.pins)) return contract;
13846
+ const fresh = pinsOfPages(compiled.map((page) => ({ path: page.path, text: files[page.path] })));
13847
+ const written = new Set(compiled.map((page) => page.path));
13848
+ const kept = contract.pins.map((pin) => ({ ...pin, pages: (Array.isArray(pin.pages) ? pin.pages : []).filter((path3) => !written.has(path3)) })).filter((pin) => pin.pages.length > 0);
13849
+ const merged = fresh.map((pin) => ({ ...pin }));
13850
+ for (const old of kept) {
13851
+ const found = merged.find((pin) => pin.path === old.path);
13852
+ if (found) found.pages = [.../* @__PURE__ */ new Set([...found.pages, ...old.pages])].sort();
13853
+ else merged.push({ ...old, order: merged.length });
13854
+ }
13855
+ return { ...contract, pins: merged };
13856
+ }
13829
13857
  function restate(contract, elements, pages, typed, order2) {
13830
13858
  const data = dropEmptyDashboardData(contract.data);
13831
13859
  const unchanged = elements === typed && pages === contract.pages && data === contract.data;
@@ -21830,6 +21858,7 @@ function catalogRow(raw) {
21830
21858
  format: typeof configuration["format"] === "string" ? configuration["format"] : null,
21831
21859
  base_metrics: (Array.isArray(raw["base_metrics"]) ? raw["base_metrics"] : []).map(idIn).filter((one) => one !== null),
21832
21860
  description: typeof raw["description"] === "string" ? raw["description"] : null,
21861
+ category: typeof raw["category"] === "string" ? raw["category"] : isObj3(raw["category"]) && typeof raw["category"]["name"] === "string" ? raw["category"]["name"] : null,
21833
21862
  status: typeof status["status"] === "string" ? status["status"].toUpperCase() : null,
21834
21863
  created_at: typeof raw["created_at"] === "string" ? raw["created_at"] : null
21835
21864
  };
@@ -21941,6 +21970,9 @@ function rowReuseKey(row, byName) {
21941
21970
  }
21942
21971
  var METRIC_CREATED_FOOTER = "Created by App Space for the app";
21943
21972
  var METRIC_CREATED_CATEGORY = "App Space";
21973
+ function bearsMark(row) {
21974
+ return (row.description ?? "").includes(METRIC_CREATED_FOOTER) || row.category === METRIC_CREATED_CATEGORY;
21975
+ }
21944
21976
  function createdFooter(appName) {
21945
21977
  return `${METRIC_CREATED_FOOTER} "${appName === "" ? "this app" : appName}".`;
21946
21978
  }
@@ -22086,6 +22118,15 @@ async function planMetrics(contract, t, opts) {
22086
22118
  const byName = new Map(catalog.map((row) => [row.name, row]));
22087
22119
  const byId = new Map(catalog.map((row) => [row.id, row]));
22088
22120
  const rowKeys2 = new Map(catalog.map((row) => [row.id, rowReuseKey(row, byName)]));
22121
+ const usageRead = /* @__PURE__ */ new Map();
22122
+ const usageOf = (appId, id) => {
22123
+ let held = usageRead.get(id);
22124
+ if (held === void 0) {
22125
+ held = readUsage(t, appId, id);
22126
+ usageRead.set(id, held);
22127
+ }
22128
+ return held;
22129
+ };
22089
22130
  const plan = {
22090
22131
  server: t.serverKey,
22091
22132
  host: t.host,
@@ -22230,6 +22271,13 @@ async function planMetrics(contract, t, opts) {
22230
22271
  entry.metric_name = hit.name;
22231
22272
  entry.origin = "reused";
22232
22273
  entry.note = hit.name === decl.name ? "the same definition" : `the same definition, named "${hit.name}" in this company (not a clash)`;
22274
+ if (bearsMark(hit) && opts.appId !== null && opts.appId !== "") {
22275
+ const usage = await usageOf(opts.appId, hit.id);
22276
+ if (typeof usage !== "string" && usage.created_by_app_space && usage.created_by_you) {
22277
+ entry.origin = "created";
22278
+ entry.note = `App Space's metric (it made it for you), ${entry.note}`;
22279
+ }
22280
+ }
22233
22281
  continue;
22234
22282
  }
22235
22283
  }
@@ -22256,7 +22304,7 @@ async function planMetrics(contract, t, opts) {
22256
22304
  else if (opts.appId === null || opts.appId === "") why = "the contract names no app id to ask App Space about";
22257
22305
  else if (previous === null) why = "its current definition could not be read in full, so a change could not be recorded";
22258
22306
  else if (entry.reuse_key === null && pendingOperands.length === 0) why = "the contract's definition could not be compared";
22259
- else why = editRefusal(await readUsage(t, opts.appId, named13.id), key, named13);
22307
+ else why = editRefusal(await usageOf(opts.appId, named13.id), key, named13);
22260
22308
  if (why === null) {
22261
22309
  if (!credential.can_write) {
22262
22310
  refuse2("metric_scope", scopeSentence(key, decl.name, credential, "changing"), `would change in place, but ${credential.line}`);
@@ -22625,6 +22673,14 @@ function bindingWarnings(answer) {
22625
22673
  }
22626
22674
  return lines;
22627
22675
  }
22676
+ function bindingUpgrades(answer) {
22677
+ const rows2 = obj2(answer)["upgraded"];
22678
+ return (Array.isArray(rows2) ? rows2 : []).map((one) => {
22679
+ const key = isObj3(one) ? String(one["key"] ?? "?") : String(one);
22680
+ const reason = isObj3(one) && typeof one["reason"] === "string" && one["reason"] !== "" ? one["reason"] : null;
22681
+ return `metric "${key}" is recorded as App Space's metric (created)${reason === null ? "" : `: ${reason}`}`;
22682
+ });
22683
+ }
22628
22684
  function renderPlan(plan) {
22629
22685
  const head = `Metrics on ${plan.server}${plan.org === null ? "" : ` (org ${String(plan.org)})`}${plan.user === null ? "" : `, as ${plan.user}`}:
22630
22686
  `;
@@ -23075,8 +23131,12 @@ async function pushFolder(dir, opts) {
23075
23131
  `
23076
23132
  );
23077
23133
  process.stdout.write(describePostCommit(result));
23078
- for (const line2 of bindingWarnings(result.metric_bindings)) process.stdout.write(`warning: ${line2}
23134
+ if (opts.metricBindings === void 0) {
23135
+ for (const line2 of bindingUpgrades(result.metric_bindings)) process.stdout.write(`note: ${line2}
23136
+ `);
23137
+ for (const line2 of bindingWarnings(result.metric_bindings)) process.stdout.write(`warning: ${line2}
23079
23138
  `);
23139
+ }
23080
23140
  process.stdout.write(describeContract(result.contract));
23081
23141
  process.stdout.write(describeIgnoredName(result.name_ignored));
23082
23142
  process.stdout.write(describeSeeding(result));
@@ -23462,13 +23522,20 @@ async function runGet(appId, opts) {
23462
23522
  function registerGetCommand(parent) {
23463
23523
  withJsonOption(
23464
23524
  withServerOptions(
23465
- parent.command("get <app-id>").description("Write an app into a folder you can edit.").option(
23525
+ parent.command("get <app-id> [dir]").description("Write an app into a folder you can edit.").option(
23466
23526
  "--dir <path>",
23467
- "Where to write it. Defaults to a fresh temporary directory."
23527
+ "Where to write it (the same as the [dir] argument). Defaults to a fresh temporary directory."
23468
23528
  ).option("--force", "Replace files the compile record lists as yours even when they were never pushed.")
23469
23529
  )
23470
- ).action(async (appId, opts) => {
23471
- const code = await runGet(appId, opts);
23530
+ ).action(async (appId, dir, opts) => {
23531
+ const flag = (opts.dir ?? "").trim();
23532
+ if (dir !== void 0 && flag !== "" && flag !== dir) {
23533
+ process.stderr.write(`two folders were named (${dir} and --dir ${flag}). Name one.
23534
+ `);
23535
+ process.exitCode = 1;
23536
+ return;
23537
+ }
23538
+ const code = await runGet(appId, { ...opts, dir: dir ?? opts.dir });
23472
23539
  if (code !== 0) process.exitCode = code;
23473
23540
  });
23474
23541
  }
@@ -30872,7 +30939,7 @@ var kit_default2 = {
30872
30939
  checks: "checks/run.mjs",
30873
30940
  contract: "contract/extract.mjs",
30874
30941
  charts: "echarts@5.6.0",
30875
- appWidgets: "dr-app-widgets@1.6.0",
30942
+ appWidgets: "dr-app-widgets@1.6.1",
30876
30943
  appComponents: "dr-components@1.6.0",
30877
30944
  appControls: "dr-components-controls@1.2.0"
30878
30945
  };
@@ -32285,6 +32352,8 @@ function metricsLines(report) {
32285
32352
  const block = report.metrics;
32286
32353
  if (block === void 0 || block === null) return "";
32287
32354
  let out = "";
32355
+ for (const line2 of bindingUpgrades(block["push"])) out += `note: ${line2}
32356
+ `;
32288
32357
  for (const line2 of bindingWarnings(block["push"])) out += `warning: ${line2}
32289
32358
  `;
32290
32359
  const live = Array.isArray(block["live"]) ? block["live"] : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarails-ai/dr-appspace-cli",
3
- "version": "0.12.42",
3
+ "version": "0.12.44",
4
4
  "description": "Datarails App Space CLI — build, try, push and publish App Space apps",
5
5
  "type": "module",
6
6
  "engines": {