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

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 +67 -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.85",
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-12T21:51:09.014Z";
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" } },
@@ -8297,6 +8306,7 @@ var contract_schema_default = {
8297
8306
  }
8298
8307
  },
8299
8308
  capabilities: { type: "object" },
8309
+ http: { $ref: "#/$defs/http" },
8300
8310
  data_model: { oneOf: [{ type: "null" }, { $ref: "#/$defs/data_model" }] },
8301
8311
  shell: {
8302
8312
  type: "object",
@@ -8359,6 +8369,8 @@ var contract_schema_default = {
8359
8369
  }
8360
8370
  }
8361
8371
  },
8372
+ http: { type: "object", description: "manifest.http - the outside HTTPS hosts the app may call through ctx.http (DR-59641; docs/appspace/ctx-http.md). OPTIONAL: absent means the app calls no outside host. An app only: a dashboard declares no http. compileApp writes it into manifest.json as it is, and the extractor reads it back. Each entry needs the Owner's approval at push (--approve-hosts). The rules this schema cannot state are compileApp's and the push's (appspace/contract.py validate_http): at most 20 entries, an entry name of lower-case letters, digits and _ that starts with a letter (at most 32 characters), no method twice, header and prefix only with secret, and no transport, cookie or proxy header.", additionalProperties: { $ref: "#/$defs/http_entry" } },
8373
+ http_entry: { type: "object", description: 'One outside host, by the name a handler passes: ctx.http.get("fx", "/v1/rates").', required: ["host", "methods"], additionalProperties: false, properties: { host: { type: "string", maxLength: 253, pattern: "^(?!.*(?:localhost|\\.local|\\.internal|\\.localdomain|\\.svc|\\.home\\.arpa)$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$(?!\\n)", description: "A lower-case DNS name of two labels or more, for example api.example.com. No scheme, path, port or IP address, and not a name that is only internal (localhost, .local, .internal, .localdomain, .svc, .home.arpa)." }, methods: { type: "array", minItems: 1, items: { enum: ["GET", "POST", "PUT", "PATCH", "DELETE"] }, description: "The methods a handler may send to this host. Not empty, no method twice." }, secret: { type: "string", pattern: "^[a-z][a-z0-9_]{0,63}$(?!\\n)", description: "OPTIONAL. The name of an app secret (docs/appspace/app-secrets.md). The platform puts its value in the header. The app never sees the value." }, header: { type: "string", pattern: "^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$(?!\\n)", description: "OPTIONAL, needs secret. The header the secret goes into. Absent means Authorization." }, prefix: { type: "string", maxLength: 64, pattern: "^[ -~]*$(?!\\n)", description: 'OPTIONAL, needs secret. Printable ASCII text before the secret, for example "Bearer ". Absent means no prefix.' } } },
8362
8374
  pin: {
8363
8375
  type: "object",
8364
8376
  required: ["module", "version", "file", "path", "rel", "pages", "order"],
@@ -13518,7 +13530,10 @@ var CLOAK_REVEAL_MS = 3e3;
13518
13530
  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
13531
  var DEFAULT_VERSION = "0.1.0";
13520
13532
  var DEFAULT_API_VERSION = "appspace/v1";
13521
- var RUNTIME_VERSION = 1;
13533
+ var SUPPORTED_RUNTIMES = /* @__PURE__ */ new Set([1, 2]);
13534
+ function runtimeVersion(app) {
13535
+ return Number.isInteger(app?.runtime) ? app.runtime : DEFAULT_RUNTIME;
13536
+ }
13522
13537
  var ROLES = ["list", "inbox", "save", "remove", "submit", "decide", "summary", "history", "custom"];
13523
13538
  var ROLE_SET = new Set(ROLES);
13524
13539
  var REQUIRED_KEYS = {
@@ -15407,6 +15422,14 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
15407
15422
  });
15408
15423
  return { files: {}, problems, contract };
15409
15424
  }
15425
+ if (app.runtime !== void 0 && !SUPPORTED_RUNTIMES.has(app.runtime)) {
15426
+ problems.push({
15427
+ code: "runtime_unknown",
15428
+ pointer: "/app/runtime",
15429
+ 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`
15430
+ });
15431
+ return { files: {}, problems, contract };
15432
+ }
15410
15433
  for (const uid of Object.keys(isPlainObject9(contract.elements) ? contract.elements : {}).sort(natural3)) {
15411
15434
  const element = contract.elements[uid];
15412
15435
  if (element?.type !== "widget" || typeof element.props?.card !== "string" || element.props.card === "") continue;
@@ -18417,7 +18440,7 @@ function manifestOf(contract, app, handlers, names, model, served = [], readers
18417
18440
  // a contract that states none writes the manifest it always did.
18418
18441
  ...typeof app.description === "string" ? { description: app.description } : {},
18419
18442
  version: app.version ?? DEFAULT_VERSION,
18420
- runtime: RUNTIME_VERSION
18443
+ runtime: runtimeVersion(app)
18421
18444
  };
18422
18445
  if (named5(app.nav_label)) manifest.nav = { label: app.nav_label };
18423
18446
  manifest.routes = routesOf2(app, contract.pages ?? []);
@@ -26019,10 +26042,10 @@ var RUNTIME_LIBRARIES = [
26019
26042
  }
26020
26043
  ];
26021
26044
  var MIN_DASHBOARD_RUNTIME = "1.13.0";
26022
- var RUNTIME_VERSION2 = /^vendor\/dr-app-runtime@(\d+\.\d+\.\d+)\/runtime\.js$/;
26045
+ var RUNTIME_VERSION = /^vendor\/dr-app-runtime@(\d+\.\d+\.\d+)\/runtime\.js$/;
26023
26046
  function runtimeBelowMinimum(page) {
26024
26047
  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);
26048
+ 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
26049
  }
26027
26050
  function compareVersions(a, b) {
26028
26051
  const left = a.split(".").map(Number);
@@ -28462,6 +28485,11 @@ function natural4(a, b) {
28462
28485
  // ../flows/appspace-builder/kit/contract/extract.mjs
28463
28486
  var CONTRACT_V2 = 1;
28464
28487
  var GENERATED_BY2 = "dashboard-kit/contract@1";
28488
+ var DEFAULT_RUNTIME2 = 1;
28489
+ function runtimeOf2(manifest) {
28490
+ const value = isPlainObject13(manifest) ? manifest.runtime : void 0;
28491
+ return Number.isInteger(value) ? value : 1;
28492
+ }
28465
28493
  var DASHBOARD_KIND2 = "dashboard";
28466
28494
  var BAND_ROLE2 = "band";
28467
28495
  var GRID_CLASSES2 = /* @__PURE__ */ new Set(["dr-dash", "dr-grid"]);
@@ -28621,6 +28649,9 @@ function appSection2(app, manifest) {
28621
28649
  // called: `name` is the title of the page and `nav.label` is the word
28622
28650
  // that has to fit beside every other app in a sidebar.
28623
28651
  nav_label: typeof nav.label === "string" ? nav.label : null,
28652
+ // The app runtime, only where it is not the compiler's default
28653
+ // (`DEFAULT_RUNTIME`): a recompile then keeps the app's runtime.
28654
+ ...runtimeOf2(manifest) !== DEFAULT_RUNTIME2 ? { runtime: runtimeOf2(manifest) } : {},
28624
28655
  version: manifest.version ?? null,
28625
28656
  api_version: manifest.apiVersion ?? manifest.api_version ?? null,
28626
28657
  routes: routesOf3(manifest),
@@ -36567,7 +36598,7 @@ function targetRuntime(value) {
36567
36598
  const n = /^\d+$/.test(value.trim()) ? Number(value.trim()) : NaN;
36568
36599
  if (n === 2) {
36569
36600
  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."
36601
+ '--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
36602
  );
36572
36603
  }
36573
36604
  if (!RUNTIMES_NOW.includes(n)) {
@@ -37193,7 +37224,7 @@ function registerMigrateCommand(parent) {
37193
37224
  withServerOptions(
37194
37225
  parent.command("migrate [dir]").description(
37195
37226
  "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.")
37227
+ ).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
37228
  )
37198
37229
  ).action(async (dirArg, opts) => {
37199
37230
  const code = await runMigrate(dirArg ?? ".", opts);
@@ -44001,6 +44032,7 @@ function appStarter(values) {
44001
44032
  description: `Raise a ${record2} and follow it until it is done.`,
44002
44033
  nav_label: values.name,
44003
44034
  routes: ["/"],
44035
+ ...values.runtime !== void 0 && values.runtime !== 1 ? { runtime: values.runtime } : {},
44004
44036
  capabilities: { data: ["rw"] },
44005
44037
  data_model: {
44006
44038
  modelVersion: 1,
@@ -44102,6 +44134,24 @@ var STARTER_SUMMARY = {
44102
44134
  // src/commands/appspace/scaffold.ts
44103
44135
  var DEFAULT_KIND = "app";
44104
44136
  var DEFAULT_TABLE = "records";
44137
+ var NEW_APP_RUNTIME = 1;
44138
+ var SCAFFOLD_RUNTIMES = [1, 2];
44139
+ function checkRuntime(value, kind) {
44140
+ const raw = (value ?? String(NEW_APP_RUNTIME)).trim();
44141
+ const runtime = /^[0-9]+$/.test(raw) ? Number(raw) : NaN;
44142
+ if (!SCAFFOLD_RUNTIMES.includes(runtime)) {
44143
+ throw new Error(
44144
+ `${JSON.stringify(raw)} is not a runtime \u2014 write --runtime 1 or --runtime 2.`
44145
+ );
44146
+ }
44147
+ if (kind === "dashboard" && runtime !== 1) {
44148
+ throw new Error(
44149
+ "a dashboard compiles to runtime 1: its compiler writes no runtime. Drop --runtime, or scaffold --kind app."
44150
+ );
44151
+ }
44152
+ return runtime;
44153
+ }
44154
+ 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
44155
  var CONTRACT_FILE = "contract.json";
44106
44156
  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
44157
  var US_SINGULARS = /^(bonus|bus|campus|census|focus|status|surplus|virus)es$/;
@@ -44270,7 +44320,10 @@ function registerScaffoldCommand(parent) {
44270
44320
  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
44321
  "--table <name>",
44272
44322
  `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.")
44323
+ ).option("--record <name>", "One row of it, singular. Default: derived from --table.").option(
44324
+ "--runtime <n>",
44325
+ `The app runtime: 1 or 2. Default: ${String(NEW_APP_RUNTIME)}. A dashboard takes 1 only.`
44326
+ ).option("--force", "Write into a folder that already has files in it.")
44274
44327
  )
44275
44328
  ).action(
44276
44329
  async (nameArg, dirArg, opts) => {
@@ -44283,6 +44336,7 @@ function registerScaffoldCommand(parent) {
44283
44336
  checkName(name);
44284
44337
  const id = (opts.id ?? "").trim() || generateAppId();
44285
44338
  const kind = checkKind2((opts.kind ?? DEFAULT_KIND).trim());
44339
+ const runtime = checkRuntime(opts.runtime, kind);
44286
44340
  const ownsData = kind === "app";
44287
44341
  if (!ownsData && (opts.table !== void 0 || opts.record !== void 0)) {
44288
44342
  throw new Error(
@@ -44294,14 +44348,14 @@ function registerScaffoldCommand(parent) {
44294
44348
  checkNames({ id, table, record: record2 });
44295
44349
  const dir = (dirArg ?? "").trim() || join22(".", id);
44296
44350
  await checkTarget(dir, opts.force === true);
44297
- const contract = starterContract(kind, { id, name, table, record: record2 });
44351
+ const contract = starterContract(kind, { id, name, table, record: record2, runtime });
44298
44352
  const overwritten = opts.force === true ? await existingFiles(dir, [CONTRACT_FILE]) : [];
44299
44353
  const target = join22(dir, CONTRACT_FILE);
44300
44354
  await mkdir9(dirname10(target), { recursive: true });
44301
44355
  await writeFile12(target, `${JSON.stringify(contract, null, 2)}
44302
44356
  `);
44303
44357
  if (opts.json === true) {
44304
- printJson({ id, name, dir, kind, table, record: record2, files: [CONTRACT_FILE], overwritten });
44358
+ printJson({ id, name, dir, kind, runtime, table, record: record2, files: [CONTRACT_FILE], overwritten });
44305
44359
  return;
44306
44360
  }
44307
44361
  const named13 = (opts.server ?? "").trim();
@@ -44319,6 +44373,8 @@ next:
44319
44373
  dr-appspace app-space compile ${shellArg(dir)} --push${server}
44320
44374
  ` + (kind === "dashboard" ? `
44321
44375
  ${METRIC_ADVICE}
44376
+ ` : "") + (runtime === 2 ? `
44377
+ ${RUNTIME_2_ADVICE}
44322
44378
  ` : "")
44323
44379
  );
44324
44380
  }
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.85",
4
4
  "description": "Datarails App Space CLI — build, try, push and publish App Space apps",
5
5
  "type": "module",
6
6
  "engines": {