@datarails-ai/dr-appspace-cli 0.12.63 → 0.12.65
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 +224 -19
- 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.65",
|
|
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-03T14:16:19.239Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -3031,6 +3031,26 @@ async function connect(opts) {
|
|
|
3031
3031
|
}
|
|
3032
3032
|
};
|
|
3033
3033
|
}
|
|
3034
|
+
function identityOf(client) {
|
|
3035
|
+
let claims = null;
|
|
3036
|
+
try {
|
|
3037
|
+
claims = client.claims?.() ?? null;
|
|
3038
|
+
} catch {
|
|
3039
|
+
claims = null;
|
|
3040
|
+
}
|
|
3041
|
+
const claim = (key) => {
|
|
3042
|
+
const held = claims?.[key];
|
|
3043
|
+
return typeof held === "string" || typeof held === "number" ? held : null;
|
|
3044
|
+
};
|
|
3045
|
+
return JSON.stringify([
|
|
3046
|
+
client.serverKey,
|
|
3047
|
+
client.baseUrl,
|
|
3048
|
+
client.host ?? null,
|
|
3049
|
+
client.email ?? null,
|
|
3050
|
+
claim("organization_id"),
|
|
3051
|
+
claim("user_id")
|
|
3052
|
+
]);
|
|
3053
|
+
}
|
|
3034
3054
|
var AppSpaceHttpError = class extends Error {
|
|
3035
3055
|
constructor(message, status, body) {
|
|
3036
3056
|
super(message);
|
|
@@ -3219,9 +3239,9 @@ function isOwnSnapshot(root) {
|
|
|
3219
3239
|
function isSkipped(value) {
|
|
3220
3240
|
return isObject(value) && typeof value["what"] === "string" && typeof value["why"] === "string";
|
|
3221
3241
|
}
|
|
3222
|
-
async function fromInventory(client, { fields = false, tableCap = 40 } = {}) {
|
|
3242
|
+
async function fromInventory(client, { fields = false, tableCap = 40, fresh = false } = {}) {
|
|
3223
3243
|
const fetched_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
3224
|
-
const body = await client.request("/financeos/inventory");
|
|
3244
|
+
const body = await client.request(fresh ? "/financeos/inventory?fresh=1" : "/financeos/inventory");
|
|
3225
3245
|
const said2 = body.dashboard_renderer;
|
|
3226
3246
|
const renderer = said2 === "runtime" || said2 === "widgets" ? { dashboard_renderer: said2 } : {};
|
|
3227
3247
|
if (body.reachable !== true) {
|
|
@@ -3340,6 +3360,10 @@ function checksMetrics(catalog) {
|
|
|
3340
3360
|
function checksTables(catalog) {
|
|
3341
3361
|
return catalog.source !== "none" && catalog.tables.length > 0;
|
|
3342
3362
|
}
|
|
3363
|
+
function skipsNothingMore(next, than) {
|
|
3364
|
+
const skipped = new Set(than.checks_skipped.map((one) => one.what));
|
|
3365
|
+
return next.checks_skipped.every((one) => skipped.has(one.what));
|
|
3366
|
+
}
|
|
3343
3367
|
function findTable(catalog, named13) {
|
|
3344
3368
|
const want = named13.toLowerCase();
|
|
3345
3369
|
return catalog.tables.find(
|
|
@@ -6811,6 +6835,12 @@ function librarySection(handlers) {
|
|
|
6811
6835
|
}
|
|
6812
6836
|
return null;
|
|
6813
6837
|
}
|
|
6838
|
+
function withoutWhatIfPlan(row) {
|
|
6839
|
+
const read = isPlainObject(row.from) && isPlainObject(row.from.financeos) ? row.from.financeos.what_if : null;
|
|
6840
|
+
if (!isPlainObject(read) || read.context !== "@model.plan" || !Object.hasOwn(read, "plan")) return row;
|
|
6841
|
+
const { plan: _plan, ...rest } = read;
|
|
6842
|
+
return { ...row, from: { ...row.from, financeos: { ...row.from.financeos, what_if: rest } } };
|
|
6843
|
+
}
|
|
6814
6844
|
function readSources(handlers) {
|
|
6815
6845
|
const sources = {};
|
|
6816
6846
|
const texts = /* @__PURE__ */ new Map();
|
|
@@ -6821,7 +6851,7 @@ function readSources(handlers) {
|
|
|
6821
6851
|
const table = literals.constant("SOURCES");
|
|
6822
6852
|
if (!isPlainObject(table)) continue;
|
|
6823
6853
|
for (const [name, row] of Object.entries(table)) {
|
|
6824
|
-
if (isPlainObject(row) && sources[name] === void 0) sources[name] = row;
|
|
6854
|
+
if (isPlainObject(row) && sources[name] === void 0) sources[name] = withoutWhatIfPlan(row);
|
|
6825
6855
|
}
|
|
6826
6856
|
const carried = literals.constant("TRANSFORMS");
|
|
6827
6857
|
if (!isPlainObject(carried)) continue;
|
|
@@ -7820,7 +7850,7 @@ var contract_schema_default = {
|
|
|
7820
7850
|
from: {
|
|
7821
7851
|
description: 'one of four spellings: {"financeos": {...}} (the dashboard SPEC source vocabulary; a metric is {"metric": "@<key>"}, a key data.metrics declares, or {"metric_id": <id>}, which ties the app to one company), {"table": "<app table>"}, {"call": "<dotted method>", "args": {...}}, or ["<source>", ...] to compose others (with a transform, or with an expr the platform evaluates)',
|
|
7822
7852
|
oneOf: [
|
|
7823
|
-
{ type: "object", properties: { financeos: { type: "object", properties: { metric: { type: "string", description: 'OPTIONAL. The metric this source reads, as "@<key>": a key data.metrics declares ("@revenue_mom"). `app-space ship` binds the key to the company\'s own metric, so the contract names no metric id; the read parameters beside it (scenario, aggregation_type, period, honors, drill_rows, filterable) are what they are for metric_id, and the two never stand on one source. The compiler refuses the rest (source_metric).' } } } } },
|
|
7853
|
+
{ type: "object", properties: { financeos: { type: "object", properties: { what_if: { type: "object", description: `OPTIONAL, alone in from.financeos (trusted forecast models P2): the metric engine's what-if, {"metric": "@<key>", "context": "@model.plan"}. metric is the declared metric it projects (a calc the drivers move, never a driver); context names the plan data.model declares, which the card states as declared (the engine's what-if takes no context, so it is never claimed as sent). The source maps the drivers it moves in drivers and honours their params; its figures are the engine's evaluation, verbatim (shape kpi or series, no transform, no expr). The compiler refuses the rest (source_what_if).`, properties: { metric: { type: "string" }, context: { const: "@model.plan" } } }, metric: { type: "string", description: 'OPTIONAL. The metric this source reads, as "@<key>": a key data.metrics declares ("@revenue_mom"). `app-space ship` binds the key to the company\'s own metric, so the contract names no metric id; the read parameters beside it (scenario, aggregation_type, period, honors, drill_rows, filterable) are what they are for metric_id, and the two never stand on one source. The compiler refuses the rest (source_metric).' } } } } },
|
|
7824
7854
|
{ type: "array", items: { type: "string" } }
|
|
7825
7855
|
]
|
|
7826
7856
|
},
|
|
@@ -7829,6 +7859,8 @@ var contract_schema_default = {
|
|
|
7829
7859
|
transform: { type: "string", pattern: "^transforms/[a-z][a-z0-9_]*\\.py$" },
|
|
7830
7860
|
period: { type: ["string", "object", "null"], description: `OPTIONAL. The window the source reads. "all": every period, whatever the page sends, honoured or not (not a metric). "ytd", "last12" or "quarter" (a FinanceOS source, table or metric): a rolling window resolved at each request as the page's period presets are, so it ends today; a source that honours period reads the page's window when the page sends one, and this one when it sends none. An object {start, end, grain}: a fixed window, read where the source does not honour period. Absent: year to date, or the page's window where the source honours period.` },
|
|
7831
7861
|
honors: { type: "array", items: { type: "string" } },
|
|
7862
|
+
drivers: { type: "object", description: `OPTIONAL, a what-if source only (from.financeos.what_if): the drivers its page params move, {"@<driver key>": "<param>"} or {"@<driver key>": {"param": "<param>", "months": ["YYYY-MM"]}}, at most 20. Each key is a driver data.metrics declares; each param a slider or number a page declares and the source honours. A param the request carries as a number overrides the driver's baseline and default (or exactly the months listed); a driver whose param is absent keeps its stored values.` },
|
|
7863
|
+
contributions: { type: "boolean", description: "OPTIONAL, a what-if source only: true carries what each overridden driver contributed, the engine's own figures, in meta.source.contributions." },
|
|
7832
7864
|
where: { type: "object" },
|
|
7833
7865
|
order_by: { type: "string" },
|
|
7834
7866
|
limit: { type: "integer" },
|
|
@@ -12402,7 +12434,7 @@ function shapedOf(row) {
|
|
|
12402
12434
|
function declaredKeyOf(row) {
|
|
12403
12435
|
const origin = row.from;
|
|
12404
12436
|
const read = isObject4(origin) && isObject4(origin.financeos) ? origin.financeos : null;
|
|
12405
|
-
const metric = read === null ? null : read.metric;
|
|
12437
|
+
const metric = read === null ? null : isObject4(read.what_if) ? read.what_if.metric : read.metric;
|
|
12406
12438
|
return typeof metric === "string" && /^@[a-z][a-z0-9_]*$/.test(metric) ? metric.slice(1) : null;
|
|
12407
12439
|
}
|
|
12408
12440
|
function yearTotalFinding(card, row, model) {
|
|
@@ -12780,7 +12812,7 @@ var FINANCEOS_SCOPES = {
|
|
|
12780
12812
|
"status:read": ["status", "whoami"],
|
|
12781
12813
|
"tables:read": ["list_tables", "get_table"],
|
|
12782
12814
|
"semantic:read": ["list_semantic_tables", "get_semantic_table", "metric_series"],
|
|
12783
|
-
"metrics:read": ["list_metrics", "get_metric", "metric_series", "metric_series_many"],
|
|
12815
|
+
"metrics:read": ["list_metrics", "get_metric", "metric_series", "metric_series_many", "metric_what_if"],
|
|
12784
12816
|
"filebox:read": ["list_filebox"],
|
|
12785
12817
|
"users:read": ["list_users"],
|
|
12786
12818
|
"pipeline:read": ["data_readiness"],
|
|
@@ -12818,6 +12850,10 @@ function financeosNeeds(row, origin) {
|
|
|
12818
12850
|
return needs;
|
|
12819
12851
|
}
|
|
12820
12852
|
const read = isPlainObject8(row.from.financeos) ? row.from.financeos : {};
|
|
12853
|
+
if (isPlainObject8(read.what_if)) {
|
|
12854
|
+
need("metric_what_if", scopesGranting("commands", "metric_what_if"));
|
|
12855
|
+
return needs;
|
|
12856
|
+
}
|
|
12821
12857
|
const filterable = Array.isArray(row.filterable) && row.filterable.length > 0;
|
|
12822
12858
|
if (readsMetric(read)) {
|
|
12823
12859
|
if (read.drill_rows) need("data_models", scopesGranting("namespaces", "data_models"));
|
|
@@ -13462,6 +13498,10 @@ function metricProblems(metrics, sources) {
|
|
|
13462
13498
|
for (const name of Object.keys(sources ?? {}).sort(natural3)) {
|
|
13463
13499
|
const row = sources[name];
|
|
13464
13500
|
if (!isPlainObject8(row) || originOf(row) !== "financeos" || !isPlainObject8(row.from.financeos)) continue;
|
|
13501
|
+
if (isPlainObject8(row.from.financeos.what_if)) {
|
|
13502
|
+
for (const ref of whatIfRefs(row)) if (declaredKeys.includes(ref.slice(1))) read.add(ref.slice(1));
|
|
13503
|
+
continue;
|
|
13504
|
+
}
|
|
13465
13505
|
const metric = row.from.financeos.metric;
|
|
13466
13506
|
if (metric === void 0 || metric === null) continue;
|
|
13467
13507
|
const pointer2 = `/data/sources/${escapePointer3(name)}/from/financeos/metric`;
|
|
@@ -13638,7 +13678,8 @@ function modelTotalProblems(model, sources) {
|
|
|
13638
13678
|
const lines = isPlainObject8(model) && isPlainObject8(model.lines) ? model.lines : {};
|
|
13639
13679
|
for (const [name, row] of Object.entries(isPlainObject8(sources) ? sources : {})) {
|
|
13640
13680
|
if (!isPlainObject8(row) || row.shape !== "kpi" || row.transform !== void 0 && row.transform !== null && row.transform !== false && row.transform !== "") continue;
|
|
13641
|
-
const
|
|
13681
|
+
const read = isPlainObject8(row.from) && isPlainObject8(row.from.financeos) ? row.from.financeos : null;
|
|
13682
|
+
const metric = read === null ? null : isPlainObject8(read.what_if) ? read.what_if.metric : read.metric;
|
|
13642
13683
|
const line2 = typeof metric === "string" && Object.hasOwn(lines, metric) && isPlainObject8(lines[metric]) ? lines[metric] : null;
|
|
13643
13684
|
const want = line2 !== null && typeof line2.fy === "string" && Object.hasOwn(FY_AGG, line2.fy) ? FY_AGG[line2.fy] : null;
|
|
13644
13685
|
if (want === null) continue;
|
|
@@ -13654,6 +13695,125 @@ function modelTotalProblems(model, sources) {
|
|
|
13654
13695
|
}
|
|
13655
13696
|
return problems;
|
|
13656
13697
|
}
|
|
13698
|
+
var WHAT_IF_MAX_DRIVERS = 20;
|
|
13699
|
+
var WHAT_IF_READ_KEYS = ["metric", "context"];
|
|
13700
|
+
var WHAT_IF_CONTEXT = "@model.plan";
|
|
13701
|
+
var WHAT_IF_SHAPES = ["kpi", "series"];
|
|
13702
|
+
var WHAT_IF_DRIVER_KEYS = ["param", "months"];
|
|
13703
|
+
var WHAT_IF_MONTH_RE = /^\d{4}-(0[1-9]|1[0-2])$/;
|
|
13704
|
+
var WHAT_IF_PARAM_KINDS = /* @__PURE__ */ new Set(["slider", "number"]);
|
|
13705
|
+
function whatIfOf(row) {
|
|
13706
|
+
const read = isPlainObject8(row) && isPlainObject8(row.from) && isPlainObject8(row.from.financeos) ? row.from.financeos : null;
|
|
13707
|
+
return read !== null && Object.hasOwn(read, "what_if") ? read.what_if : null;
|
|
13708
|
+
}
|
|
13709
|
+
function driverParam(target) {
|
|
13710
|
+
const param = isPlainObject8(target) ? target.param : target;
|
|
13711
|
+
return typeof param === "string" && param !== "" ? param : null;
|
|
13712
|
+
}
|
|
13713
|
+
function whatIfRefs(row) {
|
|
13714
|
+
const read = whatIfOf(row);
|
|
13715
|
+
if (!isPlainObject8(read)) return [];
|
|
13716
|
+
const refs = [];
|
|
13717
|
+
if (typeof read.metric === "string" && METRIC_REF_RE.test(read.metric)) refs.push(read.metric);
|
|
13718
|
+
for (const ref of Object.keys(isPlainObject8(row.drivers) ? row.drivers : {})) if (METRIC_REF_RE.test(ref)) refs.push(ref);
|
|
13719
|
+
return refs;
|
|
13720
|
+
}
|
|
13721
|
+
function whatIfProblems(contract) {
|
|
13722
|
+
const problems = [];
|
|
13723
|
+
const sources = isPlainObject8(contract?.data?.sources) ? contract.data.sources : {};
|
|
13724
|
+
const declared = isPlainObject8(contract?.data?.metrics) ? contract.data.metrics : {};
|
|
13725
|
+
const params = /* @__PURE__ */ new Map();
|
|
13726
|
+
for (const page of Array.isArray(contract?.pages) ? contract.pages : []) {
|
|
13727
|
+
for (const param of Array.isArray(page?.params) ? page.params : []) {
|
|
13728
|
+
if (isPlainObject8(param) && typeof param.name === "string" && !params.has(param.name)) params.set(param.name, param.kind);
|
|
13729
|
+
}
|
|
13730
|
+
}
|
|
13731
|
+
const declaredOf = (ref) => {
|
|
13732
|
+
const match = typeof ref === "string" ? METRIC_REF_RE.exec(ref) : null;
|
|
13733
|
+
return match !== null && Object.hasOwn(declared, match[1]) && isPlainObject8(declared[match[1]]) ? declared[match[1]] : null;
|
|
13734
|
+
};
|
|
13735
|
+
for (const name of Object.keys(sources).sort(natural3)) {
|
|
13736
|
+
const row = sources[name];
|
|
13737
|
+
const read = whatIfOf(row);
|
|
13738
|
+
if (read === null) continue;
|
|
13739
|
+
const at = (key) => `/data/sources/${escapePointer3(name)}${key ? `/${key}` : ""}`;
|
|
13740
|
+
const say = (key, message) => problems.push({ code: "source_what_if", pointer: at(key), message: `source "${name}" ${message}` });
|
|
13741
|
+
for (const key of Object.keys(row.from.financeos).sort(natural3)) {
|
|
13742
|
+
if (key !== "what_if") say(`from/financeos/${escapePointer3(key)}`, `states ${key} beside what_if; a what-if reads its result metric and nothing else, so drop ${key}`);
|
|
13743
|
+
}
|
|
13744
|
+
if (!isPlainObject8(read)) {
|
|
13745
|
+
say("from/financeos/what_if", `states what_if ${JSON.stringify(read)}; it is {"metric": "@<key>", "context": "${WHAT_IF_CONTEXT}"}`);
|
|
13746
|
+
continue;
|
|
13747
|
+
}
|
|
13748
|
+
for (const key of Object.keys(read).sort(natural3)) {
|
|
13749
|
+
if (!WHAT_IF_READ_KEYS.includes(key)) say(`from/financeos/what_if/${escapePointer3(key)}`, `states what_if.${key}, which a what-if does not take; it takes ${either3(WHAT_IF_READ_KEYS)}`);
|
|
13750
|
+
}
|
|
13751
|
+
const result = declaredOf(read.metric);
|
|
13752
|
+
if (result === null) {
|
|
13753
|
+
say("from/financeos/what_if/metric", `projects ${JSON.stringify(read.metric ?? null)}, which is not a metric data.metrics declares, written "@<key>"`);
|
|
13754
|
+
} else if (result.kind === "driver") {
|
|
13755
|
+
say("from/financeos/what_if/metric", `projects "${read.metric}", a driver; a what-if projects a metric the drivers move (a calc), so name that metric and map "${read.metric}" in drivers`);
|
|
13756
|
+
}
|
|
13757
|
+
if (read.context !== void 0 && read.context !== WHAT_IF_CONTEXT) {
|
|
13758
|
+
say("from/financeos/what_if/context", `runs under context ${JSON.stringify(read.context)}; the one context a what-if names is "${WHAT_IF_CONTEXT}", the plan data.model declares`);
|
|
13759
|
+
} else if (read.context === WHAT_IF_CONTEXT && !isPlainObject8(contract?.data?.model?.plan)) {
|
|
13760
|
+
say("from/financeos/what_if/context", `runs under "${WHAT_IF_CONTEXT}", and data.model declares no plan; declare data.model.plan ({"module": "forecast", "cycle": "4+8", "year": 2026}), or drop context`);
|
|
13761
|
+
}
|
|
13762
|
+
if (!WHAT_IF_SHAPES.includes(row.shape)) say("shape", `answers in shape ${JSON.stringify(row.shape ?? null)}; a what-if answers ${either3(WHAT_IF_SHAPES)}: the engine's months, or their total`);
|
|
13763
|
+
for (const key of ["transform", "expr"]) {
|
|
13764
|
+
if (row[key] !== void 0 && row[key] !== null) say(key, `states ${key}; a what-if's figures are the engine's own evaluation, verbatim, so no app step stands between them and the card`);
|
|
13765
|
+
}
|
|
13766
|
+
if (row.contributions !== void 0 && typeof row.contributions !== "boolean") say("contributions", `states contributions ${JSON.stringify(row.contributions)}; it is true (the card carries what each driver contributed) or false`);
|
|
13767
|
+
const honors = Array.isArray(row.honors) ? row.honors : [];
|
|
13768
|
+
const mapped = /* @__PURE__ */ new Set();
|
|
13769
|
+
if (!isPlainObject8(row.drivers) || Object.keys(row.drivers).length === 0) {
|
|
13770
|
+
say("drivers", `maps no drivers; a what-if moves at least one driver by a page param ({"@<driver>": "<param>"}) \u2014 a figure nothing moves is a plain metric read (from.financeos.metric)`);
|
|
13771
|
+
} else {
|
|
13772
|
+
const refs = Object.keys(row.drivers);
|
|
13773
|
+
if (refs.length > WHAT_IF_MAX_DRIVERS) say("drivers", `maps ${refs.length} drivers, and Datarails evaluates at most ${WHAT_IF_MAX_DRIVERS} in one what-if`);
|
|
13774
|
+
for (const ref of refs.sort(natural3)) {
|
|
13775
|
+
const pointer2 = `drivers/${escapePointer3(ref)}`;
|
|
13776
|
+
const decl = declaredOf(ref);
|
|
13777
|
+
if (decl === null || decl.kind !== "driver") {
|
|
13778
|
+
say(pointer2, `maps ${JSON.stringify(ref)}, which is not a driver data.metrics declares ("@<key>" of kind driver)${decl !== null ? ` \u2014 it is a ${decl.kind ?? "bound"} metric` : ""}`);
|
|
13779
|
+
}
|
|
13780
|
+
const target = row.drivers[ref];
|
|
13781
|
+
const param = driverParam(target);
|
|
13782
|
+
if (isPlainObject8(target)) {
|
|
13783
|
+
for (const key of Object.keys(target).sort(natural3)) if (!WHAT_IF_DRIVER_KEYS.includes(key)) say(`${pointer2}/${escapePointer3(key)}`, `maps "${ref}" with ${key}, which a driver does not take; it takes ${either3(WHAT_IF_DRIVER_KEYS)}`);
|
|
13784
|
+
const months = target.months;
|
|
13785
|
+
if (months !== void 0 && !(Array.isArray(months) && months.length > 0 && months.every((one) => typeof one === "string" && WHAT_IF_MONTH_RE.test(one)) && new Set(months).size === months.length)) {
|
|
13786
|
+
say(`${pointer2}/months`, `moves "${ref}" in months ${JSON.stringify(months)}; months is a list of distinct months, each "YYYY-MM"`);
|
|
13787
|
+
}
|
|
13788
|
+
}
|
|
13789
|
+
if (param === null) {
|
|
13790
|
+
say(pointer2, `maps "${ref}" to ${JSON.stringify(target ?? null)}; a driver maps to the page param that moves it, "<param>" or {"param": "<param>", "months": ["YYYY-MM"]}`);
|
|
13791
|
+
continue;
|
|
13792
|
+
}
|
|
13793
|
+
mapped.add(param);
|
|
13794
|
+
if (!params.has(param) || !WHAT_IF_PARAM_KINDS.has(params.get(param))) {
|
|
13795
|
+
say(pointer2, `moves "${ref}" by param "${param}", which no page declares as a slider or number; declare it in a page's params`);
|
|
13796
|
+
} else if (!honors.includes(param)) {
|
|
13797
|
+
say("honors", `moves "${ref}" by param "${param}", which it does not honour; add "${param}" to honors`);
|
|
13798
|
+
}
|
|
13799
|
+
}
|
|
13800
|
+
}
|
|
13801
|
+
honors.forEach((one, index) => {
|
|
13802
|
+
if (mapped.size > 0 && !mapped.has(one)) say(`honors/${index}`, `honours ${JSON.stringify(one)}, which no driver maps; a what-if honours the params that move its drivers, and nothing else moves it`);
|
|
13803
|
+
});
|
|
13804
|
+
}
|
|
13805
|
+
return problems;
|
|
13806
|
+
}
|
|
13807
|
+
function withWhatIfPlans(sources, model) {
|
|
13808
|
+
const plan = isPlainObject8(model) && isPlainObject8(model.plan) ? model.plan : null;
|
|
13809
|
+
if (plan === null) return sources;
|
|
13810
|
+
const out = {};
|
|
13811
|
+
for (const [name, row] of Object.entries(sources)) {
|
|
13812
|
+
const read = whatIfOf(row);
|
|
13813
|
+
out[name] = isPlainObject8(read) && read.context === WHAT_IF_CONTEXT ? { ...row, from: { ...row.from, financeos: { ...row.from.financeos, what_if: { ...read, plan: canonical(plan) } } } } : row;
|
|
13814
|
+
}
|
|
13815
|
+
return out;
|
|
13816
|
+
}
|
|
13657
13817
|
function driverParamProblems(contract) {
|
|
13658
13818
|
const problems = [];
|
|
13659
13819
|
const declared = isPlainObject8(contract?.data?.metrics) ? contract.data.metrics : {};
|
|
@@ -14274,7 +14434,8 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
14274
14434
|
// The forecast plan's P1: the planning model, and the params that open on a driver.
|
|
14275
14435
|
...planModelProblems(contract?.data?.model, contract?.data?.metrics),
|
|
14276
14436
|
...modelTotalProblems(contract?.data?.model, stated2),
|
|
14277
|
-
...driverParamProblems(contract)
|
|
14437
|
+
...driverParamProblems(contract),
|
|
14438
|
+
...whatIfProblems(contract)
|
|
14278
14439
|
];
|
|
14279
14440
|
problems.push(...metricFindings.filter((one) => !one.advisory));
|
|
14280
14441
|
const owned = ownedReaders(contract.pages, extra);
|
|
@@ -14407,7 +14568,8 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
14407
14568
|
files[path3] = handlers[name].role === "custom" ? extra[path3] : handlerModule(name, handlers[name], model);
|
|
14408
14569
|
}
|
|
14409
14570
|
const params = paramsTable(contract);
|
|
14410
|
-
|
|
14571
|
+
const carried = withWhatIfPlans(sources, contract?.data?.model);
|
|
14572
|
+
for (const name of served) files[`handlers/${name}.py`] = sourceModule(name, carried, transforms, params);
|
|
14411
14573
|
const theme = isPlainObject8(app.theme) ? app.theme : null;
|
|
14412
14574
|
if (theme !== null) files[THEME_FILE4] = themeCss(theme);
|
|
14413
14575
|
files[PALETTE_FILE] = paletteCss();
|
|
@@ -28639,6 +28801,12 @@ function librarySection2(handlers) {
|
|
|
28639
28801
|
}
|
|
28640
28802
|
return null;
|
|
28641
28803
|
}
|
|
28804
|
+
function withoutWhatIfPlan2(row) {
|
|
28805
|
+
const read = isPlainObject12(row.from) && isPlainObject12(row.from.financeos) ? row.from.financeos.what_if : null;
|
|
28806
|
+
if (!isPlainObject12(read) || read.context !== "@model.plan" || !Object.hasOwn(read, "plan")) return row;
|
|
28807
|
+
const { plan: _plan, ...rest } = read;
|
|
28808
|
+
return { ...row, from: { ...row.from, financeos: { ...row.from.financeos, what_if: rest } } };
|
|
28809
|
+
}
|
|
28642
28810
|
function readSources2(handlers) {
|
|
28643
28811
|
const sources = {};
|
|
28644
28812
|
const texts = /* @__PURE__ */ new Map();
|
|
@@ -28649,7 +28817,7 @@ function readSources2(handlers) {
|
|
|
28649
28817
|
const table = literals.constant("SOURCES");
|
|
28650
28818
|
if (!isPlainObject12(table)) continue;
|
|
28651
28819
|
for (const [name, row] of Object.entries(table)) {
|
|
28652
|
-
if (isPlainObject12(row) && sources[name] === void 0) sources[name] = row;
|
|
28820
|
+
if (isPlainObject12(row) && sources[name] === void 0) sources[name] = withoutWhatIfPlan2(row);
|
|
28653
28821
|
}
|
|
28654
28822
|
const carried = literals.constant("TRANSFORMS");
|
|
28655
28823
|
if (!isPlainObject12(carried)) continue;
|
|
@@ -30217,7 +30385,7 @@ function shapedOf2(row) {
|
|
|
30217
30385
|
function declaredKeyOf2(row) {
|
|
30218
30386
|
const origin = row.from;
|
|
30219
30387
|
const read = isObject7(origin) && isObject7(origin.financeos) ? origin.financeos : null;
|
|
30220
|
-
const metric = read === null ? null : read.metric;
|
|
30388
|
+
const metric = read === null ? null : isObject7(read.what_if) ? read.what_if.metric : read.metric;
|
|
30221
30389
|
return typeof metric === "string" && /^@[a-z][a-z0-9_]*$/.test(metric) ? metric.slice(1) : null;
|
|
30222
30390
|
}
|
|
30223
30391
|
function yearTotalFinding2(card, row, model) {
|
|
@@ -32461,18 +32629,38 @@ async function runCompile(dir, opts) {
|
|
|
32461
32629
|
);
|
|
32462
32630
|
return 1;
|
|
32463
32631
|
}
|
|
32464
|
-
const
|
|
32632
|
+
const memo = opts.catalogMemo;
|
|
32465
32633
|
let catalog;
|
|
32634
|
+
const client = await catalogClient(opts);
|
|
32466
32635
|
try {
|
|
32467
|
-
|
|
32636
|
+
const held = memo?.entry;
|
|
32637
|
+
if (held !== void 0 && client !== null && identityOf(client) === held.who) {
|
|
32638
|
+
catalog = held.catalog;
|
|
32639
|
+
} else {
|
|
32640
|
+
catalog = await resolveCatalog(opts, client);
|
|
32641
|
+
if (memo !== void 0 && client !== null && reusable(catalog)) memo.entry = { catalog, who: identityOf(client) };
|
|
32642
|
+
}
|
|
32468
32643
|
} finally {
|
|
32469
32644
|
client?.cleanup();
|
|
32470
32645
|
}
|
|
32471
|
-
const
|
|
32472
|
-
|
|
32646
|
+
const authored = contract;
|
|
32647
|
+
const decided = decideRenderer(authored, catalog.dashboard_renderer, recorded);
|
|
32648
|
+
contract = withRenderer(authored, decided.renderer);
|
|
32473
32649
|
report.renderer = decided.renderer;
|
|
32474
32650
|
report.renderer_source = decided.source;
|
|
32475
|
-
|
|
32651
|
+
let { problems, skipped, warnings } = validateContract(contract, catalog);
|
|
32652
|
+
if (catalog.source === "inventory" && problems.some((problem6) => problem6.code === "unknown-metric")) {
|
|
32653
|
+
const first = catalog;
|
|
32654
|
+
const reread = await rereadInventory(
|
|
32655
|
+
opts,
|
|
32656
|
+
(next) => skipsNothingMore(next, first) && decideRenderer(authored, next.dashboard_renderer, recorded).renderer === decided.renderer
|
|
32657
|
+
);
|
|
32658
|
+
if (reread !== null) {
|
|
32659
|
+
catalog = reread.catalog;
|
|
32660
|
+
if (memo !== void 0) memo.entry = reread;
|
|
32661
|
+
({ problems, skipped, warnings } = validateContract(contract, catalog));
|
|
32662
|
+
}
|
|
32663
|
+
}
|
|
32476
32664
|
report.validate = {
|
|
32477
32665
|
problems,
|
|
32478
32666
|
checks_skipped: skipped,
|
|
@@ -33516,6 +33704,22 @@ async function resolveCatalog(opts, client, inventoryOpts = {}) {
|
|
|
33516
33704
|
};
|
|
33517
33705
|
}
|
|
33518
33706
|
}
|
|
33707
|
+
function reusable(catalog) {
|
|
33708
|
+
return catalog.source === "inventory" && !catalog.checks_skipped.some((one) => one.what === "sources") && checksMetrics(catalog);
|
|
33709
|
+
}
|
|
33710
|
+
async function rereadInventory(opts, accepts) {
|
|
33711
|
+
let client = null;
|
|
33712
|
+
try {
|
|
33713
|
+
client = await catalogClient(opts);
|
|
33714
|
+
if (client === null) return null;
|
|
33715
|
+
const catalog = await resolveCatalog(opts, client, { fresh: true });
|
|
33716
|
+
return reusable(catalog) && accepts(catalog) ? { catalog, who: identityOf(client) } : null;
|
|
33717
|
+
} catch {
|
|
33718
|
+
return null;
|
|
33719
|
+
} finally {
|
|
33720
|
+
client?.cleanup();
|
|
33721
|
+
}
|
|
33722
|
+
}
|
|
33519
33723
|
function runVerify(dir, kind, appId, kit) {
|
|
33520
33724
|
const verify3 = kind === "dashboard" ? verify : verify2;
|
|
33521
33725
|
const result = verify3({ app: { id: appId, version: null, dir } }, { kit });
|
|
@@ -33840,6 +34044,7 @@ async function runShipOntoLive(dir, opts) {
|
|
|
33840
34044
|
if (!hasServer(opts)) {
|
|
33841
34045
|
return refuse2("needs a server: pass -s <server> (or set DR_APP_SPACE_HOST), or log in so a stored session supplies one.");
|
|
33842
34046
|
}
|
|
34047
|
+
const catalogMemo = {};
|
|
33843
34048
|
return landWithRetries(async (createGuarded) => {
|
|
33844
34049
|
for (const name of ONTO_LIVE_OWNED) await rm4(join15(dir, name), { recursive: true, force: true });
|
|
33845
34050
|
const client = await connect(opts);
|
|
@@ -33874,7 +34079,7 @@ async function runShipOntoLive(dir, opts) {
|
|
|
33874
34079
|
`
|
|
33875
34080
|
);
|
|
33876
34081
|
}
|
|
33877
|
-
const code = await runCompile(dir, { ...opts, check: false, push: true, updateBlock: true, ontoLive: true });
|
|
34082
|
+
const code = await runCompile(dir, { ...opts, check: false, push: true, updateBlock: true, ontoLive: true, catalogMemo });
|
|
33878
34083
|
return { code, lost: code === 3 ? await lostRaceOf(dir) : null, creating: pulled === null };
|
|
33879
34084
|
}, opts);
|
|
33880
34085
|
}
|