@datarails-ai/dr-appspace-cli 0.12.83 → 0.12.84

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 +64 -11
  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.83",
16
+ version: "0.12.84",
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-12T16:48:03.735Z";
60
+ var BUILD_TIME = "2026-11-12T20:49:18.849Z";
61
61
  function formatBuildTime(iso) {
62
62
  if (iso === "") return "";
63
63
  const d = new Date(iso);
@@ -6689,6 +6689,11 @@ function natural2(a, b) {
6689
6689
  // ../flows/insights-builder/kit/contract/extract.mjs
6690
6690
  var CONTRACT_V = 1;
6691
6691
  var GENERATED_BY = "dashboard-kit/contract@1";
6692
+ var DEFAULT_RUNTIME = 1;
6693
+ function runtimeOf(manifest) {
6694
+ const value = isPlainObject2(manifest) ? manifest.runtime : void 0;
6695
+ return Number.isInteger(value) ? value : 1;
6696
+ }
6692
6697
  var KIT_REGIONS = /* @__PURE__ */ new Set(["header", "asof", "refresh", "theme", "nav", "filters", "controls", "band"]);
6693
6698
  var DASHBOARD_KIND = "dashboard";
6694
6699
  var BAND_ROLE = "band";
@@ -6851,6 +6856,9 @@ function appSection(app, manifest) {
6851
6856
  // called: `name` is the title of the page and `nav.label` is the word
6852
6857
  // that has to fit beside every other app in a sidebar.
6853
6858
  nav_label: typeof nav.label === "string" ? nav.label : null,
6859
+ // The app runtime, only where it is not the compiler's default
6860
+ // (`DEFAULT_RUNTIME`): a recompile then keeps the app's runtime.
6861
+ ...runtimeOf(manifest) !== DEFAULT_RUNTIME ? { runtime: runtimeOf(manifest) } : {},
6854
6862
  version: manifest.version ?? null,
6855
6863
  api_version: manifest.apiVersion ?? manifest.api_version ?? null,
6856
6864
  routes: routesOf(manifest),
@@ -8281,6 +8289,7 @@ var contract_schema_default = {
8281
8289
  kind: { type: ["string", "null"], description: "dashboard, app, or absent" },
8282
8290
  renderer: { const: "runtime", description: "a dashboard only (Phase 2b): runtime means compileApp writes the page and dr-app-runtime renders it, over the same SPEC handler; absent means the dr-widgets page compile.mjs writes. Until compileApp writes one, compile.mjs refuses it (renderer_not_compilable)" },
8283
8291
  nav_label: { type: ["string", "null"], description: "manifest.nav.label - what the app is called in the nav, which is not always manifest.name. OPTIONAL: a contract written before this key existed omits it." },
8292
+ runtime: { enum: [1, 2], description: "manifest.runtime - the app runtime contract version (DR-58160). OPTIONAL: absent means the compiler's default (1). Runtime 2 has no ctx.data, ctx.state or ctx.financeos, and its push refuses them, a network library, a thread or a subprocess, and a file write. An app only: a dashboard's compiler writes no runtime." },
8284
8293
  version: { type: ["string", "null"] },
8285
8294
  api_version: { type: ["string", "null"] },
8286
8295
  routes: { type: "array", items: { type: "string" } },
@@ -13518,7 +13527,10 @@ var CLOAK_REVEAL_MS = 3e3;
13518
13527
  var CLOAK = `<style data-dr-cloak>main[data-dr-app]{visibility:hidden;animation:dr-reveal 0s linear ${CLOAK_REVEAL_MS}ms forwards}html[data-dr-app-runtime] main[data-dr-app]{visibility:visible;animation:none}main[data-dr-app]:has(>[data-dr-portal]){visibility:visible;animation:none}@keyframes dr-reveal{to{visibility:visible}}</style><noscript><style>main[data-dr-app]{visibility:visible;animation:none}</style></noscript>`;
13519
13528
  var DEFAULT_VERSION = "0.1.0";
13520
13529
  var DEFAULT_API_VERSION = "appspace/v1";
13521
- var RUNTIME_VERSION = 1;
13530
+ var SUPPORTED_RUNTIMES = /* @__PURE__ */ new Set([1, 2]);
13531
+ function runtimeVersion(app) {
13532
+ return Number.isInteger(app?.runtime) ? app.runtime : DEFAULT_RUNTIME;
13533
+ }
13522
13534
  var ROLES = ["list", "inbox", "save", "remove", "submit", "decide", "summary", "history", "custom"];
13523
13535
  var ROLE_SET = new Set(ROLES);
13524
13536
  var REQUIRED_KEYS = {
@@ -15407,6 +15419,14 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
15407
15419
  });
15408
15420
  return { files: {}, problems, contract };
15409
15421
  }
15422
+ if (app.runtime !== void 0 && !SUPPORTED_RUNTIMES.has(app.runtime)) {
15423
+ problems.push({
15424
+ code: "runtime_unknown",
15425
+ pointer: "/app/runtime",
15426
+ message: `app.runtime is ${JSON.stringify(app.runtime)}; App Space runs runtime ${[...SUPPORTED_RUNTIMES].join(" or ")}, and absent means ${DEFAULT_RUNTIME}. Set one of those, or remove it`
15427
+ });
15428
+ return { files: {}, problems, contract };
15429
+ }
15410
15430
  for (const uid of Object.keys(isPlainObject9(contract.elements) ? contract.elements : {}).sort(natural3)) {
15411
15431
  const element = contract.elements[uid];
15412
15432
  if (element?.type !== "widget" || typeof element.props?.card !== "string" || element.props.card === "") continue;
@@ -18417,7 +18437,7 @@ function manifestOf(contract, app, handlers, names, model, served = [], readers
18417
18437
  // a contract that states none writes the manifest it always did.
18418
18438
  ...typeof app.description === "string" ? { description: app.description } : {},
18419
18439
  version: app.version ?? DEFAULT_VERSION,
18420
- runtime: RUNTIME_VERSION
18440
+ runtime: runtimeVersion(app)
18421
18441
  };
18422
18442
  if (named5(app.nav_label)) manifest.nav = { label: app.nav_label };
18423
18443
  manifest.routes = routesOf2(app, contract.pages ?? []);
@@ -26019,10 +26039,10 @@ var RUNTIME_LIBRARIES = [
26019
26039
  }
26020
26040
  ];
26021
26041
  var MIN_DASHBOARD_RUNTIME = "1.13.0";
26022
- var RUNTIME_VERSION2 = /^vendor\/dr-app-runtime@(\d+\.\d+\.\d+)\/runtime\.js$/;
26042
+ var RUNTIME_VERSION = /^vendor\/dr-app-runtime@(\d+\.\d+\.\d+)\/runtime\.js$/;
26023
26043
  function runtimeBelowMinimum(page) {
26024
26044
  const { elements } = parseHtml(page.text);
26025
- return elements.filter((el) => el.tag === "script" && el.attrs.src !== void 0).map((el) => RUNTIME_VERSION2.exec(resolveFromPlatformRoot(page.path, el.attrs.src) ?? "")?.[1]).filter((version) => version !== void 0 && compareVersions(version, MIN_DASHBOARD_RUNTIME) < 0);
26045
+ return elements.filter((el) => el.tag === "script" && el.attrs.src !== void 0).map((el) => RUNTIME_VERSION.exec(resolveFromPlatformRoot(page.path, el.attrs.src) ?? "")?.[1]).filter((version) => version !== void 0 && compareVersions(version, MIN_DASHBOARD_RUNTIME) < 0);
26026
26046
  }
26027
26047
  function compareVersions(a, b) {
26028
26048
  const left = a.split(".").map(Number);
@@ -28462,6 +28482,11 @@ function natural4(a, b) {
28462
28482
  // ../flows/appspace-builder/kit/contract/extract.mjs
28463
28483
  var CONTRACT_V2 = 1;
28464
28484
  var GENERATED_BY2 = "dashboard-kit/contract@1";
28485
+ var DEFAULT_RUNTIME2 = 1;
28486
+ function runtimeOf2(manifest) {
28487
+ const value = isPlainObject13(manifest) ? manifest.runtime : void 0;
28488
+ return Number.isInteger(value) ? value : 1;
28489
+ }
28465
28490
  var DASHBOARD_KIND2 = "dashboard";
28466
28491
  var BAND_ROLE2 = "band";
28467
28492
  var GRID_CLASSES2 = /* @__PURE__ */ new Set(["dr-dash", "dr-grid"]);
@@ -28621,6 +28646,9 @@ function appSection2(app, manifest) {
28621
28646
  // called: `name` is the title of the page and `nav.label` is the word
28622
28647
  // that has to fit beside every other app in a sidebar.
28623
28648
  nav_label: typeof nav.label === "string" ? nav.label : null,
28649
+ // The app runtime, only where it is not the compiler's default
28650
+ // (`DEFAULT_RUNTIME`): a recompile then keeps the app's runtime.
28651
+ ...runtimeOf2(manifest) !== DEFAULT_RUNTIME2 ? { runtime: runtimeOf2(manifest) } : {},
28624
28652
  version: manifest.version ?? null,
28625
28653
  api_version: manifest.apiVersion ?? manifest.api_version ?? null,
28626
28654
  routes: routesOf3(manifest),
@@ -36567,7 +36595,7 @@ function targetRuntime(value) {
36567
36595
  const n = /^\d+$/.test(value.trim()) ? Number(value.trim()) : NaN;
36568
36596
  if (n === 2) {
36569
36597
  throw new MigrateRefused(
36570
- "--to-runtime 2 is not available: runtime 2 (no ctx.data, ctx.state or ctx.financeos) is proposed (DR-58160) and the platform runs runtime 1 only, so the server cannot migrate to it. Run migrate with no --to-runtime: it moves the names inside runtime 1."
36598
+ '--to-runtime 2 is not available: migrate moves the names inside runtime 1 and never writes "runtime". Run migrate with no --to-runtime. When no open point is left, set "runtime": 2 in manifest.json and push: a runtime 2 push (DR-58160) refuses ctx.data, ctx.state and ctx.financeos.'
36571
36599
  );
36572
36600
  }
36573
36601
  if (!RUNTIMES_NOW.includes(n)) {
@@ -37193,7 +37221,7 @@ function registerMigrateCommand(parent) {
37193
37221
  withServerOptions(
37194
37222
  parent.command("migrate [dir]").description(
37195
37223
  "Move a folder to the new ctx names (ctx.app.tables, ctx.app.state, ctx.dr): a dry run that prints the diff, or --write."
37196
- ).option("--write", "Apply the diff to the files and add the manifest additions, then run the package check.").option("--to-runtime <n>", "The runtime to move to. Only 1 today: runtime 2 is proposed (DR-58160).").option("--no-check", "With --write: do not run the package check after the write.")
37224
+ ).option("--write", "Apply the diff to the files and add the manifest additions, then run the package check.").option("--to-runtime <n>", 'The runtime to move to. Only 1: set "runtime": 2 by hand (DR-58160).').option("--no-check", "With --write: do not run the package check after the write.")
37197
37225
  )
37198
37226
  ).action(async (dirArg, opts) => {
37199
37227
  const code = await runMigrate(dirArg ?? ".", opts);
@@ -44001,6 +44029,7 @@ function appStarter(values) {
44001
44029
  description: `Raise a ${record2} and follow it until it is done.`,
44002
44030
  nav_label: values.name,
44003
44031
  routes: ["/"],
44032
+ ...values.runtime !== void 0 && values.runtime !== 1 ? { runtime: values.runtime } : {},
44004
44033
  capabilities: { data: ["rw"] },
44005
44034
  data_model: {
44006
44035
  modelVersion: 1,
@@ -44102,6 +44131,24 @@ var STARTER_SUMMARY = {
44102
44131
  // src/commands/appspace/scaffold.ts
44103
44132
  var DEFAULT_KIND = "app";
44104
44133
  var DEFAULT_TABLE = "records";
44134
+ var NEW_APP_RUNTIME = 1;
44135
+ var SCAFFOLD_RUNTIMES = [1, 2];
44136
+ function checkRuntime(value, kind) {
44137
+ const raw = (value ?? String(NEW_APP_RUNTIME)).trim();
44138
+ const runtime = /^[0-9]+$/.test(raw) ? Number(raw) : NaN;
44139
+ if (!SCAFFOLD_RUNTIMES.includes(runtime)) {
44140
+ throw new Error(
44141
+ `${JSON.stringify(raw)} is not a runtime \u2014 write --runtime 1 or --runtime 2.`
44142
+ );
44143
+ }
44144
+ if (kind === "dashboard" && runtime !== 1) {
44145
+ throw new Error(
44146
+ "a dashboard compiles to runtime 1: its compiler writes no runtime. Drop --runtime, or scaffold --kind app."
44147
+ );
44148
+ }
44149
+ return runtime;
44150
+ }
44151
+ var RUNTIME_2_ADVICE = "Runtime 2: handler code uses ctx.app.tables, ctx.app.state and ctx.dr only, and a push refuses ctx.data, ctx.state, ctx.financeos, a network library, a thread or a subprocess, and a file write. A server before runtime 2 refuses the push.";
44105
44152
  var CONTRACT_FILE = "contract.json";
44106
44153
  var METRIC_ADVICE = "The card sources name metric 42, which is a placeholder: only the tenant knows its own metric ids. Research them and replace `source` on every widget \u2014 `compile --check -s <server>` reports them as unknown until you do.";
44107
44154
  var US_SINGULARS = /^(bonus|bus|campus|census|focus|status|surplus|virus)es$/;
@@ -44270,7 +44317,10 @@ function registerScaffoldCommand(parent) {
44270
44317
  parent.command("scaffold [name] [dir]").description("Write a starter contract.json into a folder, ready to compile.").option("--id <app-id>", "The app id. Default: a fresh one.").option("--kind <kind>", `dashboard or app. Default: ${DEFAULT_KIND}. ${kindList()}.`, DEFAULT_KIND).option(
44271
44318
  "--table <name>",
44272
44319
  `The table an app owns. Default: ${DEFAULT_TABLE}. A dashboard owns none.`
44273
- ).option("--record <name>", "One row of it, singular. Default: derived from --table.").option("--force", "Write into a folder that already has files in it.")
44320
+ ).option("--record <name>", "One row of it, singular. Default: derived from --table.").option(
44321
+ "--runtime <n>",
44322
+ `The app runtime: 1 or 2. Default: ${String(NEW_APP_RUNTIME)}. A dashboard takes 1 only.`
44323
+ ).option("--force", "Write into a folder that already has files in it.")
44274
44324
  )
44275
44325
  ).action(
44276
44326
  async (nameArg, dirArg, opts) => {
@@ -44283,6 +44333,7 @@ function registerScaffoldCommand(parent) {
44283
44333
  checkName(name);
44284
44334
  const id = (opts.id ?? "").trim() || generateAppId();
44285
44335
  const kind = checkKind2((opts.kind ?? DEFAULT_KIND).trim());
44336
+ const runtime = checkRuntime(opts.runtime, kind);
44286
44337
  const ownsData = kind === "app";
44287
44338
  if (!ownsData && (opts.table !== void 0 || opts.record !== void 0)) {
44288
44339
  throw new Error(
@@ -44294,14 +44345,14 @@ function registerScaffoldCommand(parent) {
44294
44345
  checkNames({ id, table, record: record2 });
44295
44346
  const dir = (dirArg ?? "").trim() || join22(".", id);
44296
44347
  await checkTarget(dir, opts.force === true);
44297
- const contract = starterContract(kind, { id, name, table, record: record2 });
44348
+ const contract = starterContract(kind, { id, name, table, record: record2, runtime });
44298
44349
  const overwritten = opts.force === true ? await existingFiles(dir, [CONTRACT_FILE]) : [];
44299
44350
  const target = join22(dir, CONTRACT_FILE);
44300
44351
  await mkdir9(dirname10(target), { recursive: true });
44301
44352
  await writeFile12(target, `${JSON.stringify(contract, null, 2)}
44302
44353
  `);
44303
44354
  if (opts.json === true) {
44304
- printJson({ id, name, dir, kind, table, record: record2, files: [CONTRACT_FILE], overwritten });
44355
+ printJson({ id, name, dir, kind, runtime, table, record: record2, files: [CONTRACT_FILE], overwritten });
44305
44356
  return;
44306
44357
  }
44307
44358
  const named13 = (opts.server ?? "").trim();
@@ -44319,6 +44370,8 @@ next:
44319
44370
  dr-appspace app-space compile ${shellArg(dir)} --push${server}
44320
44371
  ` + (kind === "dashboard" ? `
44321
44372
  ${METRIC_ADVICE}
44373
+ ` : "") + (runtime === 2 ? `
44374
+ ${RUNTIME_2_ADVICE}
44322
44375
  ` : "")
44323
44376
  );
44324
44377
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarails-ai/dr-appspace-cli",
3
- "version": "0.12.83",
3
+ "version": "0.12.84",
4
4
  "description": "Datarails App Space CLI — build, try, push and publish App Space apps",
5
5
  "type": "module",
6
6
  "engines": {