@datarails-ai/dr-appspace-cli 0.12.84 → 0.12.86
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 +156 -3
- 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.86",
|
|
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-14T07:36:42.643Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -6864,10 +6864,21 @@ function appSection(app, manifest) {
|
|
|
6864
6864
|
routes: routesOf(manifest),
|
|
6865
6865
|
handlers,
|
|
6866
6866
|
capabilities: isPlainObject2(manifest.capabilities) ? manifest.capabilities : {},
|
|
6867
|
+
// The outside hosts `ctx.http` may call (DR-59641), as the manifest states
|
|
6868
|
+
// them, and only where it states them: `compileApp.mjs` writes them back.
|
|
6869
|
+
...isPlainObject2(manifest.http) ? { http: httpSection(manifest.http) } : {},
|
|
6867
6870
|
data_model: app.dataModel ? normaliseModel(app.dataModel) : null,
|
|
6868
6871
|
theme: themeSection(app)
|
|
6869
6872
|
};
|
|
6870
6873
|
}
|
|
6874
|
+
var HTTP_OPTIONAL_KEYS = ["secret", "header", "prefix"];
|
|
6875
|
+
function httpSection(http) {
|
|
6876
|
+
const out = {};
|
|
6877
|
+
for (const [name, entry] of Object.entries(http)) {
|
|
6878
|
+
out[name] = isPlainObject2(entry) ? Object.fromEntries(Object.entries(entry).filter(([key, value]) => !(value === null && HTTP_OPTIONAL_KEYS.includes(key)))) : entry;
|
|
6879
|
+
}
|
|
6880
|
+
return out;
|
|
6881
|
+
}
|
|
6871
6882
|
function routesOf(manifest) {
|
|
6872
6883
|
return Array.isArray(manifest.routes) ? manifest.routes.map(String) : [];
|
|
6873
6884
|
}
|
|
@@ -8306,6 +8317,7 @@ var contract_schema_default = {
|
|
|
8306
8317
|
}
|
|
8307
8318
|
},
|
|
8308
8319
|
capabilities: { type: "object" },
|
|
8320
|
+
http: { $ref: "#/$defs/http" },
|
|
8309
8321
|
data_model: { oneOf: [{ type: "null" }, { $ref: "#/$defs/data_model" }] },
|
|
8310
8322
|
shell: {
|
|
8311
8323
|
type: "object",
|
|
@@ -8368,6 +8380,8 @@ var contract_schema_default = {
|
|
|
8368
8380
|
}
|
|
8369
8381
|
}
|
|
8370
8382
|
},
|
|
8383
|
+
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" } },
|
|
8384
|
+
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.' } } },
|
|
8371
8385
|
pin: {
|
|
8372
8386
|
type: "object",
|
|
8373
8387
|
required: ["module", "version", "file", "path", "rel", "pages", "order"],
|
|
@@ -11591,6 +11605,7 @@ function compile(contract, { kit, extra = {} } = {}) {
|
|
|
11591
11605
|
`this compiler writes dashboards; app.kind is ${JSON.stringify(kind)}, and a kind: app contract is compiled by compileApp`
|
|
11592
11606
|
);
|
|
11593
11607
|
}
|
|
11608
|
+
if (source.app?.http !== void 0) return refuse2("http_not_for_dashboards", MANIFEST_FILE, HTTP_NOT_FOR_DASHBOARDS);
|
|
11594
11609
|
if (source.app?.renderer === RUNTIME_RENDERER2) return compileApp(source, { kit, extra });
|
|
11595
11610
|
if (source.app?.renderer !== void 0) {
|
|
11596
11611
|
return refuse2(
|
|
@@ -13531,6 +13546,116 @@ var SUPPORTED_RUNTIMES = /* @__PURE__ */ new Set([1, 2]);
|
|
|
13531
13546
|
function runtimeVersion(app) {
|
|
13532
13547
|
return Number.isInteger(app?.runtime) ? app.runtime : DEFAULT_RUNTIME;
|
|
13533
13548
|
}
|
|
13549
|
+
var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
13550
|
+
var MAX_HTTP_ENTRIES = 20;
|
|
13551
|
+
var HTTP_PREFIX_MAX = 64;
|
|
13552
|
+
var HTTP_NAME_RE = /^[a-z][a-z0-9_]{0,31}$/;
|
|
13553
|
+
var HTTP_SECRET_NAME_RE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
13554
|
+
var HTTP_HEADER_NAME_RE = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/;
|
|
13555
|
+
var HTTP_PRINTABLE_RE = /^[ -~]*$/;
|
|
13556
|
+
var HTTP_ENTRY_KEYS = ["host", "methods", "secret", "header", "prefix"];
|
|
13557
|
+
var HTTP_RESERVED_HEADERS = /* @__PURE__ */ new Set([
|
|
13558
|
+
"host",
|
|
13559
|
+
"cookie",
|
|
13560
|
+
"content-length",
|
|
13561
|
+
"transfer-encoding",
|
|
13562
|
+
"connection",
|
|
13563
|
+
"keep-alive",
|
|
13564
|
+
"te",
|
|
13565
|
+
"trailer",
|
|
13566
|
+
"upgrade",
|
|
13567
|
+
"expect",
|
|
13568
|
+
"forwarded",
|
|
13569
|
+
"x-http-method-override",
|
|
13570
|
+
"x-http-method",
|
|
13571
|
+
"x-method-override",
|
|
13572
|
+
"x-original-url",
|
|
13573
|
+
"x-rewrite-url",
|
|
13574
|
+
"x-real-ip",
|
|
13575
|
+
"x-client-ip"
|
|
13576
|
+
]);
|
|
13577
|
+
var HTTP_RESERVED_HEADER_PREFIXES = ["proxy-", "x-forwarded-"];
|
|
13578
|
+
var HOST_LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
13579
|
+
var TLD_RE = /^(?:[a-z][a-z0-9-]*|xn--[a-z0-9-]+)$/;
|
|
13580
|
+
var INTERNAL_HOST_SUFFIXES = ["localhost", ".local", ".internal", ".localdomain", ".svc", ".cluster.local", ".home.arpa"];
|
|
13581
|
+
var HTTP_DOC = "docs/appspace/ctx-http.md";
|
|
13582
|
+
function httpHostProblem(host) {
|
|
13583
|
+
if (typeof host !== "string" || host === "") return "host must be a DNS name, for example api.example.com";
|
|
13584
|
+
const quoted3 = JSON.stringify(host);
|
|
13585
|
+
if (host.includes("://") || host.includes("/")) return `host ${quoted3} must be a DNS name, not a URL`;
|
|
13586
|
+
if (host.includes(":") || host.startsWith("[")) return `host ${quoted3} must be a DNS name with no port and no IP address`;
|
|
13587
|
+
if (host !== host.toLowerCase()) return `host ${quoted3} must be lower case`;
|
|
13588
|
+
if (host.length > 253 || host.endsWith(".")) return `host ${quoted3} is not a valid DNS name`;
|
|
13589
|
+
const labels = host.split(".");
|
|
13590
|
+
if (labels.length < 2 || !labels.every((label) => HOST_LABEL_RE.test(label))) return `host ${quoted3} is not a valid DNS name of two labels or more`;
|
|
13591
|
+
if (!TLD_RE.test(labels[labels.length - 1])) return `host ${quoted3} must be a DNS name, not an IP address`;
|
|
13592
|
+
if (INTERNAL_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix))) return `host ${quoted3} names an internal network, not a public host`;
|
|
13593
|
+
return null;
|
|
13594
|
+
}
|
|
13595
|
+
function httpHeaderReserved(name) {
|
|
13596
|
+
const key = name.toLowerCase().replace(/_/g, "-");
|
|
13597
|
+
return HTTP_RESERVED_HEADERS.has(key) || HTTP_RESERVED_HEADER_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
13598
|
+
}
|
|
13599
|
+
function httpProblems(http) {
|
|
13600
|
+
const problems = [];
|
|
13601
|
+
const say = (pointer2, message) => problems.push({ code: "http_invalid", pointer: pointer2, message: `${message} (${HTTP_DOC})` });
|
|
13602
|
+
if (!isPlainObject9(http)) {
|
|
13603
|
+
say("/app/http", 'app.http must be an object of named entries, for example {"fx": {"host": "api.example.com", "methods": ["GET"]}}');
|
|
13604
|
+
return problems;
|
|
13605
|
+
}
|
|
13606
|
+
const names = Object.keys(http).sort();
|
|
13607
|
+
if (names.length > MAX_HTTP_ENTRIES) say("/app/http", `app.http declares ${names.length} entries; at most ${MAX_HTTP_ENTRIES} are allowed`);
|
|
13608
|
+
for (const name of names) {
|
|
13609
|
+
const entry = http[name];
|
|
13610
|
+
const at = `/app/http/${escapePointer3(name)}`;
|
|
13611
|
+
const label = `app.http.${name}`;
|
|
13612
|
+
if (!HTTP_NAME_RE.test(name)) {
|
|
13613
|
+
say(at, `the entry name ${JSON.stringify(name)} must be lower case letters, digits and _, start with a letter, at most 32 characters`);
|
|
13614
|
+
continue;
|
|
13615
|
+
}
|
|
13616
|
+
if (!isPlainObject9(entry)) {
|
|
13617
|
+
say(at, `${label} must be an object with host and methods`);
|
|
13618
|
+
continue;
|
|
13619
|
+
}
|
|
13620
|
+
for (const key of Object.keys(entry).filter((one) => !HTTP_ENTRY_KEYS.includes(one)).sort()) {
|
|
13621
|
+
say(`${at}/${escapePointer3(key)}`, `${label}: unknown key ${JSON.stringify(key)}; the keys are ${[...HTTP_ENTRY_KEYS].sort().join(", ")}`);
|
|
13622
|
+
}
|
|
13623
|
+
const host = httpHostProblem(entry.host);
|
|
13624
|
+
if (host !== null) say(`${at}/host`, `${label}: ${host}`);
|
|
13625
|
+
const methods = entry.methods;
|
|
13626
|
+
if (!Array.isArray(methods) || methods.length === 0 || !methods.every((one) => HTTP_METHODS.includes(one))) {
|
|
13627
|
+
say(`${at}/methods`, `${label}.methods must be a non-empty list taken from ${HTTP_METHODS.join(", ")}`);
|
|
13628
|
+
} else if (new Set(methods).size !== methods.length) {
|
|
13629
|
+
say(`${at}/methods`, `${label}.methods lists a method twice`);
|
|
13630
|
+
}
|
|
13631
|
+
const secret = entry.secret ?? null;
|
|
13632
|
+
if (secret !== null && (typeof secret !== "string" || !HTTP_SECRET_NAME_RE.test(secret))) {
|
|
13633
|
+
say(`${at}/secret`, `${label}.secret must be a secret name: lower case letters, digits and _, start with a letter, at most 64 characters`);
|
|
13634
|
+
}
|
|
13635
|
+
for (const key of ["header", "prefix"]) {
|
|
13636
|
+
if (Object.hasOwn(entry, key) && secret === null) say(`${at}/${key}`, `${label}.${key} needs ${label}.secret`);
|
|
13637
|
+
}
|
|
13638
|
+
const header = entry.header ?? null;
|
|
13639
|
+
if (header !== null && (typeof header !== "string" || !HTTP_HEADER_NAME_RE.test(header) || httpHeaderReserved(header))) {
|
|
13640
|
+
say(`${at}/header`, `${label}.header must be an HTTP header name that is not a transport, cookie or proxy header`);
|
|
13641
|
+
}
|
|
13642
|
+
const prefix = entry.prefix ?? null;
|
|
13643
|
+
if (prefix !== null && (typeof prefix !== "string" || prefix.length > HTTP_PREFIX_MAX || !HTTP_PRINTABLE_RE.test(prefix))) {
|
|
13644
|
+
say(`${at}/prefix`, `${label}.prefix must be printable ASCII text of at most ${HTTP_PREFIX_MAX} characters`);
|
|
13645
|
+
}
|
|
13646
|
+
}
|
|
13647
|
+
return problems;
|
|
13648
|
+
}
|
|
13649
|
+
function manifestHttp(http) {
|
|
13650
|
+
const out = {};
|
|
13651
|
+
for (const name of Object.keys(http).sort()) {
|
|
13652
|
+
const entry = {};
|
|
13653
|
+
for (const key of HTTP_ENTRY_KEYS) if (http[name][key] !== void 0) entry[key] = http[name][key];
|
|
13654
|
+
out[name] = entry;
|
|
13655
|
+
}
|
|
13656
|
+
return out;
|
|
13657
|
+
}
|
|
13658
|
+
var HTTP_NOT_FOR_DASHBOARDS = "app.http is for an app; a dashboard declares no http: it shows FinanceOS data and calls no outside host. Remove app.http, or build an app";
|
|
13534
13659
|
var ROLES = ["list", "inbox", "save", "remove", "submit", "decide", "summary", "history", "custom"];
|
|
13535
13660
|
var ROLE_SET = new Set(ROLES);
|
|
13536
13661
|
var REQUIRED_KEYS = {
|
|
@@ -15392,6 +15517,10 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
15392
15517
|
const appWidgets = typeof kit?.appWidgets === "string" && kit.appWidgets !== "" ? kit.appWidgets : WIDGETS;
|
|
15393
15518
|
const appComponents = typeof kit?.appComponents === "string" && kit.appComponents !== "" ? kit.appComponents : COMPONENTS;
|
|
15394
15519
|
const appControls = typeof kit?.appControls === "string" && kit.appControls !== "" ? kit.appControls : CONTROLS;
|
|
15520
|
+
if (app.kind === "dashboard" && app.http !== void 0) {
|
|
15521
|
+
problems.push({ code: "http_not_for_dashboards", pointer: "/app/http", message: HTTP_NOT_FOR_DASHBOARDS });
|
|
15522
|
+
return { files: {}, problems, contract };
|
|
15523
|
+
}
|
|
15395
15524
|
if (app.kind === "dashboard" && app.renderer === RUNTIME_RENDERER2) {
|
|
15396
15525
|
return compileDashboard(contract, { kit, extra, uiKit, charts, fmt, appComponents, appControls });
|
|
15397
15526
|
}
|
|
@@ -15427,6 +15556,13 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
15427
15556
|
});
|
|
15428
15557
|
return { files: {}, problems, contract };
|
|
15429
15558
|
}
|
|
15559
|
+
if (app.http !== void 0) {
|
|
15560
|
+
const httpLines = httpProblems(app.http);
|
|
15561
|
+
if (httpLines.length > 0) {
|
|
15562
|
+
problems.push(...httpLines);
|
|
15563
|
+
return { files: {}, problems, contract };
|
|
15564
|
+
}
|
|
15565
|
+
}
|
|
15430
15566
|
for (const uid of Object.keys(isPlainObject9(contract.elements) ? contract.elements : {}).sort(natural3)) {
|
|
15431
15567
|
const element = contract.elements[uid];
|
|
15432
15568
|
if (element?.type !== "widget" || typeof element.props?.card !== "string" || element.props.card === "") continue;
|
|
@@ -18460,6 +18596,7 @@ function manifestOf(contract, app, handlers, names, model, served = [], readers
|
|
|
18460
18596
|
}
|
|
18461
18597
|
manifest.handlers = Object.fromEntries(Object.keys(manifest.handlers).sort(natural3).map((name) => [name, manifest.handlers[name]]));
|
|
18462
18598
|
manifest.capabilities = isPlainObject9(app.capabilities) && Object.keys(app.capabilities).length > 0 ? app.capabilities : { data: ["rw"] };
|
|
18599
|
+
if (isPlainObject9(app.http)) manifest.http = manifestHttp(app.http);
|
|
18463
18600
|
const { tables } = readTables(contract);
|
|
18464
18601
|
if (tables.length > 0) manifest.sources = { tables };
|
|
18465
18602
|
return manifest;
|
|
@@ -19170,7 +19307,7 @@ function pageHtml2(contract, page, elements, tree, model, { runtime, uiKit, char
|
|
|
19170
19307
|
const app = contract.app ?? {};
|
|
19171
19308
|
const name = named5(app.name) ? app.name : named5(app.id) ? app.id : "";
|
|
19172
19309
|
const title = documentTitle(page, name);
|
|
19173
|
-
const embedded = JSON.stringify(canonical(contract)).replace(/<\//g, "<\\/");
|
|
19310
|
+
const embedded = JSON.stringify(canonical(withoutHttp(contract))).replace(/<\//g, "<\\/");
|
|
19174
19311
|
const bodyAttrs = [' class="dr-app-page"'];
|
|
19175
19312
|
if (named5(page.theme)) bodyAttrs.push(` data-dr-theme="${attr2(page.theme)}"`);
|
|
19176
19313
|
if (named5(page.density)) bodyAttrs.push(` data-dr-density="${attr2(page.density)}"`);
|
|
@@ -19569,6 +19706,11 @@ function stated(value) {
|
|
|
19569
19706
|
function isPlainObject9(value) {
|
|
19570
19707
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19571
19708
|
}
|
|
19709
|
+
function withoutHttp(contract) {
|
|
19710
|
+
if (!isPlainObject9(contract?.app) || !("http" in contract.app)) return contract;
|
|
19711
|
+
const { http, ...app } = contract.app;
|
|
19712
|
+
return { ...contract, app };
|
|
19713
|
+
}
|
|
19572
19714
|
function escapePointer3(key) {
|
|
19573
19715
|
return String(key).replace(/~/g, "~0").replace(/\//g, "~1");
|
|
19574
19716
|
}
|
|
@@ -28654,10 +28796,21 @@ function appSection2(app, manifest) {
|
|
|
28654
28796
|
routes: routesOf3(manifest),
|
|
28655
28797
|
handlers,
|
|
28656
28798
|
capabilities: isPlainObject13(manifest.capabilities) ? manifest.capabilities : {},
|
|
28799
|
+
// The outside hosts `ctx.http` may call (DR-59641), as the manifest states
|
|
28800
|
+
// them, and only where it states them: `compileApp.mjs` writes them back.
|
|
28801
|
+
...isPlainObject13(manifest.http) ? { http: httpSection2(manifest.http) } : {},
|
|
28657
28802
|
data_model: app.dataModel ? normaliseModel2(app.dataModel) : null,
|
|
28658
28803
|
theme: themeSection2(app)
|
|
28659
28804
|
};
|
|
28660
28805
|
}
|
|
28806
|
+
var HTTP_OPTIONAL_KEYS2 = ["secret", "header", "prefix"];
|
|
28807
|
+
function httpSection2(http) {
|
|
28808
|
+
const out = {};
|
|
28809
|
+
for (const [name, entry] of Object.entries(http)) {
|
|
28810
|
+
out[name] = isPlainObject13(entry) ? Object.fromEntries(Object.entries(entry).filter(([key, value]) => !(value === null && HTTP_OPTIONAL_KEYS2.includes(key)))) : entry;
|
|
28811
|
+
}
|
|
28812
|
+
return out;
|
|
28813
|
+
}
|
|
28661
28814
|
function routesOf3(manifest) {
|
|
28662
28815
|
return Array.isArray(manifest.routes) ? manifest.routes.map(String) : [];
|
|
28663
28816
|
}
|