@datarails-ai/dr-appspace-cli 0.12.79 → 0.12.80
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 +30 -22
- 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.80",
|
|
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-11T08:31:34.925Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -12757,7 +12757,7 @@ var KEY_SHAPE = {
|
|
|
12757
12757
|
var ROLE_KEYS = {
|
|
12758
12758
|
not_own: {
|
|
12759
12759
|
roles: ["decide", "save", "remove"],
|
|
12760
|
-
why: "not_own refuses the caller's own row, and only a role that acts on one existing row has a row to refuse; a custom handler is written by hand and asks ctx.
|
|
12760
|
+
why: "not_own refuses the caller's own row, and only a role that acts on one existing row has a row to refuse; a custom handler is written by hand and asks ctx.app.tables.table(name).is_own(id) itself"
|
|
12761
12761
|
},
|
|
12762
12762
|
// Required on `decide` (REQUIRED_KEYS), optional on `remove` and on `save`'s
|
|
12763
12763
|
// update: the one state a row may be deleted from or changed in. Anywhere
|
|
@@ -17254,7 +17254,10 @@ function requiresLines(row, verb) {
|
|
|
17254
17254
|
const noun = singular(row.table);
|
|
17255
17255
|
return [
|
|
17256
17256
|
" for column, (target, noun, display, conditions) in REQUIRES.items():",
|
|
17257
|
-
|
|
17257
|
+
// Wrapped as `ruff format` wraps it: with the new name the line is 90 wide.
|
|
17258
|
+
" linked = (",
|
|
17259
|
+
" ctx.app.tables.table(target).get(row[column]) if row.get(column) else None",
|
|
17260
|
+
" )",
|
|
17258
17261
|
" if linked is None:",
|
|
17259
17262
|
" return {",
|
|
17260
17263
|
` "error": f${pyString(`this ${noun} names no {noun} this app can see`)},`,
|
|
@@ -17539,7 +17542,7 @@ function measuredSummary(row) {
|
|
|
17539
17542
|
...answers
|
|
17540
17543
|
];
|
|
17541
17544
|
}
|
|
17542
|
-
const body = ["def handle(ctx, payload):", " del payload", ' table = ctx.
|
|
17545
|
+
const body = ["def handle(ctx, payload):", " del payload", ' table = ctx.app.tables.table(HANDLER["table"])', " answer = {}", ...loop, " return answer"].join("\n");
|
|
17543
17546
|
const constants3 = [assignment("MEASURES", measures, Object.keys(measures))];
|
|
17544
17547
|
if (kinds.length === 0) {
|
|
17545
17548
|
return {
|
|
@@ -17710,7 +17713,7 @@ function groupedBy(row) {
|
|
|
17710
17713
|
function singular(name) {
|
|
17711
17714
|
return String(name).endsWith("s") ? String(name).slice(0, -1) : String(name);
|
|
17712
17715
|
}
|
|
17713
|
-
function queryCall(row, { receiver = 'ctx.
|
|
17716
|
+
function queryCall(row, { receiver = 'ctx.app.tables.table(HANDLER["table"])', indent: indent2 = 4, include = false } = {}) {
|
|
17714
17717
|
const args = [];
|
|
17715
17718
|
if (isPlainObject8(row.where)) args.push('where=HANDLER["where"]');
|
|
17716
17719
|
if (named5(row.order_by)) args.push('order_by=HANDLER["order_by"]');
|
|
@@ -17753,7 +17756,7 @@ contract, not this file.`,
|
|
|
17753
17756
|
"def handle(ctx, payload):",
|
|
17754
17757
|
...collectRow(row, enums),
|
|
17755
17758
|
...Object.keys(refs).length > 0 ? refLines() : [],
|
|
17756
|
-
' return {"row": ctx.
|
|
17759
|
+
' return {"row": ctx.app.tables.table(HANDLER["table"]).save(row)}'
|
|
17757
17760
|
].join("\n")
|
|
17758
17761
|
};
|
|
17759
17762
|
}
|
|
@@ -17788,7 +17791,7 @@ function parentLines(row, parent, { missing, invisible }) {
|
|
|
17788
17791
|
' parent_id = str(uuid.UUID(str(payload.get(HANDLER["by"]))))',
|
|
17789
17792
|
" except ValueError:",
|
|
17790
17793
|
` return ${missing}`,
|
|
17791
|
-
" if ctx.
|
|
17794
|
+
" if ctx.app.tables.table(PARENT).get(parent_id) is None:",
|
|
17792
17795
|
` return ${invisible}`
|
|
17793
17796
|
];
|
|
17794
17797
|
}
|
|
@@ -17817,7 +17820,7 @@ function refLines() {
|
|
|
17817
17820
|
" row[field] = str(uuid.UUID(str(row[field])))",
|
|
17818
17821
|
" except ValueError:",
|
|
17819
17822
|
' return {"error": f"{field} is not a {noun} this app can see"}',
|
|
17820
|
-
" if ctx.
|
|
17823
|
+
" if ctx.app.tables.table(target).get(row[field]) is None:",
|
|
17821
17824
|
' return {"error": f"{field} is not a {noun} this app can see"}'
|
|
17822
17825
|
];
|
|
17823
17826
|
}
|
|
@@ -17846,7 +17849,7 @@ contract, not this file.`,
|
|
|
17846
17849
|
" payload = payload or {}",
|
|
17847
17850
|
...parentLines(row, parent, { missing: '{"rows": []}', invisible: '{"rows": []}' }),
|
|
17848
17851
|
where2,
|
|
17849
|
-
` rows = ctx.
|
|
17852
|
+
` rows = ctx.app.tables.table(HANDLER["table"]).query(
|
|
17850
17853
|
${args.map((arg) => ` ${arg},`).join("\n")}
|
|
17851
17854
|
)`,
|
|
17852
17855
|
' return {"rows": rows}'
|
|
@@ -17884,7 +17887,7 @@ contract, not this file.`,
|
|
|
17884
17887
|
' row_id = payload.get("id")',
|
|
17885
17888
|
" if not row_id:",
|
|
17886
17889
|
' return {"error": "id is required"}',
|
|
17887
|
-
' table = ctx.
|
|
17890
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
17888
17891
|
...guardLines(row, model, "row", 4),
|
|
17889
17892
|
...notOwnLines(row, "row_id", "remove", 4),
|
|
17890
17893
|
" table.delete(row_id)",
|
|
@@ -17914,7 +17917,7 @@ function decideMap(name, row, table, model) {
|
|
|
17914
17917
|
' if not isinstance(decision, str) or decision not in HANDLER["decision"]:',
|
|
17915
17918
|
' return {"error": f"{decision} is not a decision this app makes"}',
|
|
17916
17919
|
' spec = HANDLER["decision"][decision]',
|
|
17917
|
-
' table = ctx.
|
|
17920
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
17918
17921
|
" try:",
|
|
17919
17922
|
' row_id = str(uuid.UUID(str(payload.get("id"))))',
|
|
17920
17923
|
" except ValueError:",
|
|
@@ -18019,7 +18022,10 @@ contract, not this file.`,
|
|
|
18019
18022
|
' row_id = str(uuid.UUID(str(payload.get("id"))))',
|
|
18020
18023
|
" except ValueError:",
|
|
18021
18024
|
' return {"rows": []}',
|
|
18022
|
-
row.limit !== void 0 && row.limit !== null ?
|
|
18025
|
+
row.limit !== void 0 && row.limit !== null ? (
|
|
18026
|
+
// Wrapped as `ruff format` wraps it: with the new name the line is 89 wide.
|
|
18027
|
+
' rows = ctx.app.tables.table(HANDLER["table"]).history(\n row_id, limit=HANDLER["limit"]\n )'
|
|
18028
|
+
) : ' rows = ctx.app.tables.table(HANDLER["table"]).history(row_id)',
|
|
18023
18029
|
' return {"rows": rows}'
|
|
18024
18030
|
].join("\n")
|
|
18025
18031
|
}),
|
|
@@ -18051,7 +18057,7 @@ contract, not this file.`,
|
|
|
18051
18057
|
"def handle(ctx, payload):",
|
|
18052
18058
|
...collectRow(row, enums),
|
|
18053
18059
|
...Object.keys(refs).length > 0 ? refLines() : [],
|
|
18054
|
-
' table = ctx.
|
|
18060
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
18055
18061
|
' row_id = payload.get("id")',
|
|
18056
18062
|
" if row_id:",
|
|
18057
18063
|
...guarded ? guardLines(row, model, "current", 8) : [],
|
|
@@ -18078,7 +18084,7 @@ contract, not this file.`,
|
|
|
18078
18084
|
' return {"error": "id is required"}',
|
|
18079
18085
|
// `is_own` on a row that is not there is False, and `delete` then
|
|
18080
18086
|
// raises NotFound exactly as it does without the guard.
|
|
18081
|
-
...row.not_own === true ? [' table = ctx.
|
|
18087
|
+
...row.not_own === true ? [' table = ctx.app.tables.table(HANDLER["table"])', ...notOwnLines(row, "row_id", "remove", 4), " table.delete(row_id)"] : [' ctx.app.tables.table(HANDLER["table"]).delete(row_id)'],
|
|
18082
18088
|
' return {"removed": row_id}'
|
|
18083
18089
|
].join("\n")
|
|
18084
18090
|
},
|
|
@@ -18115,7 +18121,7 @@ contract, not this file.`,
|
|
|
18115
18121
|
lines.push(...requiresLines(row, "saved"));
|
|
18116
18122
|
}
|
|
18117
18123
|
if (isPlainObject8(row.fixed) && Object.keys(row.fixed).length > 0) lines.push(' row.update(HANDLER["fixed"])');
|
|
18118
|
-
lines.push(' return {"row": ctx.
|
|
18124
|
+
lines.push(' return {"row": ctx.app.tables.table(HANDLER["table"]).insert(row)}');
|
|
18119
18125
|
const linkDoc = parent === null ? "" : `
|
|
18120
18126
|
|
|
18121
18127
|
\`by\` stamps the new ${singular(row.table)} with the ${singular(parent)} the reader opened, and
|
|
@@ -18145,7 +18151,7 @@ contract, not this file.`,
|
|
|
18145
18151
|
' decision = payload.get("decision") or HANDLER["decision"][0]',
|
|
18146
18152
|
' if decision not in HANDLER["decision"]:',
|
|
18147
18153
|
' return {"error": f"{decision} is not a decision this app makes"}',
|
|
18148
|
-
' table = ctx.
|
|
18154
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
18149
18155
|
// Every table's key is a uuid (data_model: "pk must be uuid"), so an id
|
|
18150
18156
|
// that is not one names no row. It is the same miss as a row that is
|
|
18151
18157
|
// not there, and it has to reach the guard as one: `table.get` refuses
|
|
@@ -18201,7 +18207,7 @@ contract, not this file.`,
|
|
|
18201
18207
|
body: [
|
|
18202
18208
|
"def handle(ctx, payload):",
|
|
18203
18209
|
" del payload",
|
|
18204
|
-
' rows = ctx.
|
|
18210
|
+
' rows = ctx.app.tables.table(HANDLER["table"]).aggregate(',
|
|
18205
18211
|
" group_by=GROUP_BY,",
|
|
18206
18212
|
' metrics={"n": "count"},',
|
|
18207
18213
|
" )",
|
|
@@ -31935,6 +31941,9 @@ function checkPage3(app) {
|
|
|
31935
31941
|
|
|
31936
31942
|
// ../flows/appspace-builder/kit/checks/rules/singleton.mjs
|
|
31937
31943
|
var SETTINGS_NAME = /(^|_)(settings?|config|configuration|preferences|prefs)(_|$)/;
|
|
31944
|
+
var TABLE_SURFACE = String.raw`ctx\s*\.\s*(?:data|app\s*\.\s*tables)`;
|
|
31945
|
+
var BOUND_TABLE = new RegExp(String.raw`\b([A-Za-z_]\w*)\s*=\s*${TABLE_SURFACE}\s*\.\s*table\(\s*(?:(["'])([^"'\n]+)\2|HANDLER\[["']table["']\])\s*\)`, "g");
|
|
31946
|
+
var QUERY_CALL = new RegExp(String.raw`(?:${TABLE_SURFACE}\s*\.\s*table\(\s*(?:(["'])([^"'\n]+)\1|HANDLER\[["']table["']\])\s*\)|\b([A-Za-z_]\w*))\s*\.query\(`, "g");
|
|
31938
31947
|
function checkSingletons(app) {
|
|
31939
31948
|
const violations = [];
|
|
31940
31949
|
const tables = app.dataModel && typeof app.dataModel.tables === "object" && app.dataModel.tables !== null ? app.dataModel.tables : {};
|
|
@@ -31946,7 +31955,7 @@ function checkSingletons(app) {
|
|
|
31946
31955
|
violations.push({
|
|
31947
31956
|
rule: "A2.5",
|
|
31948
31957
|
where: `${reader.where}:${reader.line}`,
|
|
31949
|
-
message: `table "${name}" looks like a one-row settings table (handler "${reader.handler}" reads it with limit 1) but does not declare "singleton": true, so a save with no id inserts another row and limit 1 reads whichever row comes first. Declare "singleton": true on "${name}", read it with ctx.
|
|
31958
|
+
message: `table "${name}" looks like a one-row settings table (handler "${reader.handler}" reads it with limit 1) but does not declare "singleton": true, so a save with no id inserts another row and limit 1 reads whichever row comes first. Declare "singleton": true on "${name}", read it with ctx.app.tables.table("${name}").get() and write it with .save(values) (a "save" role does this when compiled)`
|
|
31950
31959
|
});
|
|
31951
31960
|
}
|
|
31952
31961
|
}
|
|
@@ -31970,11 +31979,10 @@ function oneRowReader(handlers, table) {
|
|
|
31970
31979
|
const source = handler.source ?? "";
|
|
31971
31980
|
const literal = handlerLiteral(source);
|
|
31972
31981
|
const aliases = /* @__PURE__ */ new Map();
|
|
31973
|
-
for (const bound of source.matchAll(
|
|
31982
|
+
for (const bound of source.matchAll(BOUND_TABLE)) {
|
|
31974
31983
|
aliases.set(bound[1], bound[3] ?? literal.table);
|
|
31975
31984
|
}
|
|
31976
|
-
const
|
|
31977
|
-
for (const call of source.matchAll(calls)) {
|
|
31985
|
+
for (const call of source.matchAll(QUERY_CALL)) {
|
|
31978
31986
|
const receiver = call[3] !== void 0 ? aliases.get(call[3]) : call[2] ?? literal.table;
|
|
31979
31987
|
if (receiver !== table) continue;
|
|
31980
31988
|
const args = argumentsFrom(source, call.index + call[0].length);
|