@datarails-ai/dr-appspace-cli 0.12.78 → 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/README.md +6 -2
- package/dist/cli.js +439 -386
- 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);
|
|
@@ -73,6 +73,154 @@ function composeVersion(version, buildTimeIso) {
|
|
|
73
73
|
import { promises as fs } from "fs";
|
|
74
74
|
import * as os from "os";
|
|
75
75
|
import * as path from "path";
|
|
76
|
+
|
|
77
|
+
// src/auth/keyring/credentialsFile.ts
|
|
78
|
+
import { randomBytes } from "crypto";
|
|
79
|
+
import { constants } from "fs";
|
|
80
|
+
import { chmod, mkdir, open, rename, rm, writeFile } from "fs/promises";
|
|
81
|
+
import { homedir } from "os";
|
|
82
|
+
import { dirname, join, resolve } from "path";
|
|
83
|
+
import { z } from "zod";
|
|
84
|
+
var CREDENTIALS_FILE_ENV = "DR_CREDENTIALS_FILE";
|
|
85
|
+
var DEFAULT_CREDENTIALS_FILE = join(homedir(), ".dr", "session.json");
|
|
86
|
+
async function ensureCredentialsDir(dir) {
|
|
87
|
+
await mkdir(dir, { recursive: true, mode: 448 });
|
|
88
|
+
if (isDefaultDir(dir)) await chmod(dir, 448).catch(() => void 0);
|
|
89
|
+
}
|
|
90
|
+
function isDefaultDir(dir) {
|
|
91
|
+
return resolve(dir) === resolve(dirname(DEFAULT_CREDENTIALS_FILE));
|
|
92
|
+
}
|
|
93
|
+
var credentialsFileSchema = z.object({
|
|
94
|
+
access: z.string().min(1).optional(),
|
|
95
|
+
refresh: z.string().min(1).optional(),
|
|
96
|
+
// A user-bound API key, exchanged for `access` on demand. A file may hold
|
|
97
|
+
// only this; `access` then appears after the first exchange.
|
|
98
|
+
apiKey: z.string().min(1).optional(),
|
|
99
|
+
// DR-52657: the NAME of an environment variable holding the API key, for
|
|
100
|
+
// provisioners that must not put the key on disk — an agent sandbox, where
|
|
101
|
+
// the variable's in-sandbox value is an opaque vault placeholder, or a CI
|
|
102
|
+
// runner keeping the key in its secret env. Resolved at exchange time and
|
|
103
|
+
// passed verbatim. Mutually exclusive with `apiKey` (refinement below).
|
|
104
|
+
apiKeyEnvVar: z.string().min(1).optional(),
|
|
105
|
+
// Carried verbatim, judged where it is read. `z.string()` (not validated or
|
|
106
|
+
// `.catch`): a rotation rewrites the whole file from the parsed object, so a
|
|
107
|
+
// value this schema dropped would be deleted silently, and a top-level
|
|
108
|
+
// rejection would fail the WHOLE file and lock the operator out of logout.
|
|
109
|
+
apiKeyExpiresAt: z.string().optional(),
|
|
110
|
+
// Which key minted `access`, as a non-secret fingerprint. Written by the
|
|
111
|
+
// CLI, not a provisioner: a rotation replaces `apiKey` and leaves this
|
|
112
|
+
// naming the old one, which is how the next command knows `access` is not
|
|
113
|
+
// the new key's. `z.string()` for the same lock-out reason as above.
|
|
114
|
+
accessApiKeyFingerprint: z.string().optional(),
|
|
115
|
+
server: z.string().min(1),
|
|
116
|
+
email: z.string().min(1),
|
|
117
|
+
// min(1): an empty string is how a hand-rolled producer spells "no cookie",
|
|
118
|
+
// but it is not the same as absent here — `sessionId: ""` on disk never
|
|
119
|
+
// equals the cookie dropped out of the metadata blob, so `store.touch()`
|
|
120
|
+
// would rewrite live token material after every successful command.
|
|
121
|
+
sessionId: z.string().min(1).optional(),
|
|
122
|
+
csrfToken: z.string().min(1).optional(),
|
|
123
|
+
// Validated, not just typed: `KeyringStore` turns this straight into a Date
|
|
124
|
+
// and later calls `toISOString()` on it, which throws on an Invalid Date.
|
|
125
|
+
// `datetime()` is a regex, so it passes 2026-13-40 — hence the parse check.
|
|
126
|
+
savedAt: z.iso.datetime({ offset: true }).refine((s) => !Number.isNaN(Date.parse(s)), { message: "not a valid date" }).optional()
|
|
127
|
+
}).loose().refine((c) => c.sessionId === void 0 === (c.csrfToken === void 0), {
|
|
128
|
+
message: "sessionId and csrfToken must be provided together",
|
|
129
|
+
path: ["sessionId"]
|
|
130
|
+
}).refine((c) => !(c.apiKey !== void 0 && c.apiKeyEnvVar !== void 0), {
|
|
131
|
+
message: "apiKey and apiKeyEnvVar are mutually exclusive",
|
|
132
|
+
path: ["apiKeyEnvVar"]
|
|
133
|
+
}).refine((c) => c.access !== void 0 || c.apiKey !== void 0 || c.apiKeyEnvVar !== void 0, {
|
|
134
|
+
message: "one of access, apiKey or apiKeyEnvVar is required",
|
|
135
|
+
path: ["access"]
|
|
136
|
+
}).refine(
|
|
137
|
+
(c) => c.apiKey !== void 0 || c.apiKeyEnvVar !== void 0 || c.refresh !== void 0 || c.sessionId !== void 0,
|
|
138
|
+
{
|
|
139
|
+
message: "refresh is required unless an apiKey, apiKeyEnvVar or a session cookie is present",
|
|
140
|
+
path: ["refresh"]
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
function credentialsFilePath() {
|
|
144
|
+
const override = process.env[CREDENTIALS_FILE_ENV];
|
|
145
|
+
return override !== void 0 && override !== "" ? override : DEFAULT_CREDENTIALS_FILE;
|
|
146
|
+
}
|
|
147
|
+
var CredentialFileRefusedError = class extends Error {
|
|
148
|
+
name = "CredentialFileRefusedError";
|
|
149
|
+
};
|
|
150
|
+
async function readCredentialsFile(path3) {
|
|
151
|
+
let raw;
|
|
152
|
+
let handle;
|
|
153
|
+
try {
|
|
154
|
+
handle = await open(path3, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
155
|
+
} catch (err) {
|
|
156
|
+
if (err.code === "ENOENT") return void 0;
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const st = await handle.stat();
|
|
161
|
+
if (!st.isFile()) {
|
|
162
|
+
throw new CredentialFileRefusedError(`credential file ${path3} is not a regular file`);
|
|
163
|
+
}
|
|
164
|
+
refuseUnlessPrivate(path3, st);
|
|
165
|
+
raw = await handle.readFile("utf8");
|
|
166
|
+
} finally {
|
|
167
|
+
await handle.close();
|
|
168
|
+
}
|
|
169
|
+
let parsed2;
|
|
170
|
+
try {
|
|
171
|
+
parsed2 = JSON.parse(raw);
|
|
172
|
+
} catch {
|
|
173
|
+
throw new Error(`credential file ${path3} is not valid JSON`);
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
return credentialsFileSchema.parse(parsed2);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
179
|
+
throw new Error(`credential file ${path3} is malformed: ${reason}`, { cause: err });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function refuseUnlessPrivate(path3, st, platform = process.platform) {
|
|
183
|
+
if (platform === "win32") return;
|
|
184
|
+
const uid = process.getuid?.();
|
|
185
|
+
if (uid !== void 0 && st.uid !== uid) {
|
|
186
|
+
throw new CredentialFileRefusedError(
|
|
187
|
+
`credential file ${path3} is owned by uid ${st.uid}, not by the user running the CLI (uid ${uid}); refusing to use it. Recreate it as this user.`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const mode = st.mode & 511;
|
|
191
|
+
if ((mode & 63) !== 0) {
|
|
192
|
+
throw new CredentialFileRefusedError(
|
|
193
|
+
`credential file ${path3} is accessible by other users (mode ${mode.toString(8).padStart(4, "0")}); refusing to use it. Run \`chmod 600 ${path3}\`.`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async function writeCredentialsFile(path3, creds) {
|
|
198
|
+
await ensureCredentialsDir(dirname(path3));
|
|
199
|
+
let next;
|
|
200
|
+
try {
|
|
201
|
+
next = credentialsFileSchema.parse({
|
|
202
|
+
...creds,
|
|
203
|
+
savedAt: creds.savedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
204
|
+
});
|
|
205
|
+
} catch (err) {
|
|
206
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
207
|
+
throw new Error(`refusing to write an unreadable credential file ${path3}: ${reason}`, {
|
|
208
|
+
cause: err
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const body = JSON.stringify(next, null, 2);
|
|
212
|
+
const tmp = `${path3}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
213
|
+
try {
|
|
214
|
+
await writeFile(tmp, body, { mode: 384, flag: "wx" });
|
|
215
|
+
await chmod(tmp, 384);
|
|
216
|
+
await rename(tmp, path3);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
await rm(tmp, { force: true }).catch(() => void 0);
|
|
219
|
+
throw err;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/auth/versionCheck.ts
|
|
76
224
|
var LATEST_JSON_URL = "";
|
|
77
225
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
78
226
|
var FETCH_TIMEOUT_MS = 4e3;
|
|
@@ -111,8 +259,7 @@ async function readCache() {
|
|
|
111
259
|
}
|
|
112
260
|
async function writeCache(entry) {
|
|
113
261
|
const target = cachePath();
|
|
114
|
-
|
|
115
|
-
await fs.mkdir(dir, { recursive: true });
|
|
262
|
+
await ensureCredentialsDir(path.dirname(target));
|
|
116
263
|
const tmp = `${target}.tmp.${process.pid}`;
|
|
117
264
|
await fs.writeFile(tmp, JSON.stringify(entry), { mode: 384 });
|
|
118
265
|
await fs.rename(tmp, target);
|
|
@@ -734,7 +881,7 @@ function resolveUrl(raw) {
|
|
|
734
881
|
if (known) return known;
|
|
735
882
|
return { key: host, host: normalizedHost };
|
|
736
883
|
}
|
|
737
|
-
function
|
|
884
|
+
function resolve2(input) {
|
|
738
885
|
const trimmed = input.trim();
|
|
739
886
|
if (isLikelyUrl(trimmed)) return resolveUrl(trimmed);
|
|
740
887
|
if (isBareDatarailsHost(trimmed)) return resolveUrl(`https://${trimmed}`);
|
|
@@ -776,12 +923,12 @@ async function requestDeviceCode(host, options) {
|
|
|
776
923
|
interval: typeof obj5.interval === "number" ? obj5.interval : 0
|
|
777
924
|
};
|
|
778
925
|
}
|
|
779
|
-
var defaultSleep = (ms, signal) => new Promise((
|
|
926
|
+
var defaultSleep = (ms, signal) => new Promise((resolve18, reject) => {
|
|
780
927
|
if (signal?.aborted) {
|
|
781
928
|
reject(signal.reason ?? new Error("aborted"));
|
|
782
929
|
return;
|
|
783
930
|
}
|
|
784
|
-
const t = setTimeout(
|
|
931
|
+
const t = setTimeout(resolve18, ms);
|
|
785
932
|
signal?.addEventListener(
|
|
786
933
|
"abort",
|
|
787
934
|
() => {
|
|
@@ -1224,13 +1371,13 @@ async function ensureJwt(store, serverKey, email, opts) {
|
|
|
1224
1371
|
throw new NotLoggedInError(`not logged in: ${serverKey}:${email}`);
|
|
1225
1372
|
}
|
|
1226
1373
|
if (usesApiKey(session)) {
|
|
1227
|
-
const host2 = opts.host ??
|
|
1374
|
+
const host2 = opts.host ?? resolve2(serverKey).host;
|
|
1228
1375
|
return exchangeKeyedSession(store, serverKey, email, session, host2, opts);
|
|
1229
1376
|
}
|
|
1230
1377
|
if (!opts.force && session.jwtAccess !== void 0 && session.jwtAccess !== "" && !jwtExpiringSoon(session, opts.buffer)) {
|
|
1231
1378
|
return session;
|
|
1232
1379
|
}
|
|
1233
|
-
const host = opts.host ??
|
|
1380
|
+
const host = opts.host ?? resolve2(serverKey).host;
|
|
1234
1381
|
if (session.impersonatorEmail !== void 0 && session.impersonatorEmail !== "") {
|
|
1235
1382
|
return recoverImpersonatedJwt(store, serverKey, email, session, host, opts);
|
|
1236
1383
|
}
|
|
@@ -1391,10 +1538,10 @@ async function recoverImpersonatedJwt(store, serverKey, email, session, host, op
|
|
|
1391
1538
|
}
|
|
1392
1539
|
|
|
1393
1540
|
// src/auth/browser.ts
|
|
1394
|
-
import
|
|
1541
|
+
import open2 from "open";
|
|
1395
1542
|
async function openBrowser(url) {
|
|
1396
1543
|
try {
|
|
1397
|
-
await
|
|
1544
|
+
await open2(url);
|
|
1398
1545
|
return { ok: true };
|
|
1399
1546
|
} catch (err) {
|
|
1400
1547
|
const reason = err instanceof Error ? err.message : String(err);
|
|
@@ -1407,19 +1554,19 @@ async function openBrowser(url) {
|
|
|
1407
1554
|
|
|
1408
1555
|
// src/commands/_serverPicker.ts
|
|
1409
1556
|
async function readLine(stdin) {
|
|
1410
|
-
return new Promise((
|
|
1557
|
+
return new Promise((resolve18, reject) => {
|
|
1411
1558
|
let data = "";
|
|
1412
1559
|
const onData = (chunk) => {
|
|
1413
1560
|
data += chunk.toString();
|
|
1414
1561
|
const i = data.indexOf("\n");
|
|
1415
1562
|
if (i >= 0) {
|
|
1416
1563
|
cleanup();
|
|
1417
|
-
|
|
1564
|
+
resolve18(data.slice(0, i + 1));
|
|
1418
1565
|
}
|
|
1419
1566
|
};
|
|
1420
1567
|
const onEnd = () => {
|
|
1421
1568
|
cleanup();
|
|
1422
|
-
|
|
1569
|
+
resolve18(data);
|
|
1423
1570
|
};
|
|
1424
1571
|
const onError = (err) => {
|
|
1425
1572
|
cleanup();
|
|
@@ -1531,7 +1678,7 @@ var AuthorizedClient = class _AuthorizedClient {
|
|
|
1531
1678
|
`not logged in: ${serverKey}:${email} (missing session; re-run dr-appspace login)`
|
|
1532
1679
|
);
|
|
1533
1680
|
}
|
|
1534
|
-
const rawHost = options?.host ??
|
|
1681
|
+
const rawHost = options?.host ?? resolve2(serverKey).host;
|
|
1535
1682
|
const host = rawHost.replace(/\/+$/, "");
|
|
1536
1683
|
const rawAuthHost = options?.authHost ?? rawHost;
|
|
1537
1684
|
const authHost = rawAuthHost.replace(/\/+$/, "");
|
|
@@ -2066,111 +2213,8 @@ function truncate2(s, n) {
|
|
|
2066
2213
|
return s.slice(0, n) + "\u2026";
|
|
2067
2214
|
}
|
|
2068
2215
|
|
|
2069
|
-
// src/auth/keyring/credentialsFile.ts
|
|
2070
|
-
import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
2071
|
-
import { homedir as homedir3 } from "os";
|
|
2072
|
-
import { dirname as dirname2, join as join3 } from "path";
|
|
2073
|
-
import { z } from "zod";
|
|
2074
|
-
var CREDENTIALS_FILE_ENV = "DR_CREDENTIALS_FILE";
|
|
2075
|
-
var DEFAULT_CREDENTIALS_FILE = join3(homedir3(), ".dr", "session.json");
|
|
2076
|
-
var credentialsFileSchema = z.object({
|
|
2077
|
-
access: z.string().min(1).optional(),
|
|
2078
|
-
refresh: z.string().min(1).optional(),
|
|
2079
|
-
// A user-bound API key, exchanged for `access` on demand. A file may hold
|
|
2080
|
-
// only this; `access` then appears after the first exchange.
|
|
2081
|
-
apiKey: z.string().min(1).optional(),
|
|
2082
|
-
// DR-52657: the NAME of an environment variable holding the API key, for
|
|
2083
|
-
// provisioners that must not put the key on disk — an agent sandbox, where
|
|
2084
|
-
// the variable's in-sandbox value is an opaque vault placeholder, or a CI
|
|
2085
|
-
// runner keeping the key in its secret env. Resolved at exchange time and
|
|
2086
|
-
// passed verbatim. Mutually exclusive with `apiKey` (refinement below).
|
|
2087
|
-
apiKeyEnvVar: z.string().min(1).optional(),
|
|
2088
|
-
// Carried verbatim, judged where it is read. `z.string()` (not validated or
|
|
2089
|
-
// `.catch`): a rotation rewrites the whole file from the parsed object, so a
|
|
2090
|
-
// value this schema dropped would be deleted silently, and a top-level
|
|
2091
|
-
// rejection would fail the WHOLE file and lock the operator out of logout.
|
|
2092
|
-
apiKeyExpiresAt: z.string().optional(),
|
|
2093
|
-
// Which key minted `access`, as a non-secret fingerprint. Written by the
|
|
2094
|
-
// CLI, not a provisioner: a rotation replaces `apiKey` and leaves this
|
|
2095
|
-
// naming the old one, which is how the next command knows `access` is not
|
|
2096
|
-
// the new key's. `z.string()` for the same lock-out reason as above.
|
|
2097
|
-
accessApiKeyFingerprint: z.string().optional(),
|
|
2098
|
-
server: z.string().min(1),
|
|
2099
|
-
email: z.string().min(1),
|
|
2100
|
-
// min(1): an empty string is how a hand-rolled producer spells "no cookie",
|
|
2101
|
-
// but it is not the same as absent here — `sessionId: ""` on disk never
|
|
2102
|
-
// equals the cookie dropped out of the metadata blob, so `store.touch()`
|
|
2103
|
-
// would rewrite live token material after every successful command.
|
|
2104
|
-
sessionId: z.string().min(1).optional(),
|
|
2105
|
-
csrfToken: z.string().min(1).optional(),
|
|
2106
|
-
// Validated, not just typed: `KeyringStore` turns this straight into a Date
|
|
2107
|
-
// and later calls `toISOString()` on it, which throws on an Invalid Date.
|
|
2108
|
-
// `datetime()` is a regex, so it passes 2026-13-40 — hence the parse check.
|
|
2109
|
-
savedAt: z.iso.datetime({ offset: true }).refine((s) => !Number.isNaN(Date.parse(s)), { message: "not a valid date" }).optional()
|
|
2110
|
-
}).loose().refine((c) => c.sessionId === void 0 === (c.csrfToken === void 0), {
|
|
2111
|
-
message: "sessionId and csrfToken must be provided together",
|
|
2112
|
-
path: ["sessionId"]
|
|
2113
|
-
}).refine((c) => !(c.apiKey !== void 0 && c.apiKeyEnvVar !== void 0), {
|
|
2114
|
-
message: "apiKey and apiKeyEnvVar are mutually exclusive",
|
|
2115
|
-
path: ["apiKeyEnvVar"]
|
|
2116
|
-
}).refine((c) => c.access !== void 0 || c.apiKey !== void 0 || c.apiKeyEnvVar !== void 0, {
|
|
2117
|
-
message: "one of access, apiKey or apiKeyEnvVar is required",
|
|
2118
|
-
path: ["access"]
|
|
2119
|
-
}).refine(
|
|
2120
|
-
(c) => c.apiKey !== void 0 || c.apiKeyEnvVar !== void 0 || c.refresh !== void 0 || c.sessionId !== void 0,
|
|
2121
|
-
{
|
|
2122
|
-
message: "refresh is required unless an apiKey, apiKeyEnvVar or a session cookie is present",
|
|
2123
|
-
path: ["refresh"]
|
|
2124
|
-
}
|
|
2125
|
-
);
|
|
2126
|
-
function credentialsFilePath() {
|
|
2127
|
-
const override = process.env[CREDENTIALS_FILE_ENV];
|
|
2128
|
-
return override !== void 0 && override !== "" ? override : DEFAULT_CREDENTIALS_FILE;
|
|
2129
|
-
}
|
|
2130
|
-
async function readCredentialsFile(path3) {
|
|
2131
|
-
let raw;
|
|
2132
|
-
try {
|
|
2133
|
-
raw = await readFile(path3, "utf8");
|
|
2134
|
-
} catch (err) {
|
|
2135
|
-
if (err.code === "ENOENT") return void 0;
|
|
2136
|
-
throw err;
|
|
2137
|
-
}
|
|
2138
|
-
let parsed2;
|
|
2139
|
-
try {
|
|
2140
|
-
parsed2 = JSON.parse(raw);
|
|
2141
|
-
} catch {
|
|
2142
|
-
throw new Error(`credential file ${path3} is not valid JSON`);
|
|
2143
|
-
}
|
|
2144
|
-
try {
|
|
2145
|
-
return credentialsFileSchema.parse(parsed2);
|
|
2146
|
-
} catch (err) {
|
|
2147
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
2148
|
-
throw new Error(`credential file ${path3} is malformed: ${reason}`, { cause: err });
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
async function writeCredentialsFile(path3, creds) {
|
|
2152
|
-
await mkdir(dirname2(path3), { recursive: true, mode: 448 });
|
|
2153
|
-
let next;
|
|
2154
|
-
try {
|
|
2155
|
-
next = credentialsFileSchema.parse({
|
|
2156
|
-
...creds,
|
|
2157
|
-
savedAt: creds.savedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
2158
|
-
});
|
|
2159
|
-
} catch (err) {
|
|
2160
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
2161
|
-
throw new Error(`refusing to write an unreadable credential file ${path3}: ${reason}`, {
|
|
2162
|
-
cause: err
|
|
2163
|
-
});
|
|
2164
|
-
}
|
|
2165
|
-
const body = JSON.stringify(next, null, 2);
|
|
2166
|
-
const tmp = `${path3}.${process.pid}.tmp`;
|
|
2167
|
-
await writeFile(tmp, body, { mode: 384 });
|
|
2168
|
-
await chmod(tmp, 384);
|
|
2169
|
-
await rename(tmp, path3);
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
2216
|
// src/auth/keyring/fileBackend.ts
|
|
2173
|
-
import { rm } from "fs/promises";
|
|
2217
|
+
import { rm as rm2 } from "fs/promises";
|
|
2174
2218
|
var INDEX_PREFIX2 = "__index__:";
|
|
2175
2219
|
var FileKeyringBackend = class _FileKeyringBackend {
|
|
2176
2220
|
constructor(path3) {
|
|
@@ -2314,7 +2358,7 @@ var FileKeyringBackend = class _FileKeyringBackend {
|
|
|
2314
2358
|
const creds = await this.load();
|
|
2315
2359
|
if (creds === void 0) return false;
|
|
2316
2360
|
if (_FileKeyringBackend.slotOf(creds, account) !== "meta") return false;
|
|
2317
|
-
await
|
|
2361
|
+
await rm2(this.path, { force: true });
|
|
2318
2362
|
return true;
|
|
2319
2363
|
}
|
|
2320
2364
|
async list() {
|
|
@@ -2379,7 +2423,7 @@ function resolveServer(flag) {
|
|
|
2379
2423
|
throw new Error(`--server is required. Valid: ${keys().join(", ")}`);
|
|
2380
2424
|
}
|
|
2381
2425
|
try {
|
|
2382
|
-
return
|
|
2426
|
+
return resolve2(trimmed).key;
|
|
2383
2427
|
} catch (err) {
|
|
2384
2428
|
if (err instanceof InvalidServerUrlError) throw err;
|
|
2385
2429
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -2405,7 +2449,7 @@ function fileStoreServerKey(creds, serverFlag) {
|
|
|
2405
2449
|
const requested = resolveServer(serverFlag);
|
|
2406
2450
|
let fileKey = creds.server;
|
|
2407
2451
|
try {
|
|
2408
|
-
fileKey =
|
|
2452
|
+
fileKey = resolve2(creds.server).key;
|
|
2409
2453
|
} catch {
|
|
2410
2454
|
}
|
|
2411
2455
|
if (requested !== fileKey) {
|
|
@@ -2463,7 +2507,7 @@ function registerLoginCommand(root) {
|
|
|
2463
2507
|
if (serverKey === "") {
|
|
2464
2508
|
serverKey = await pickServer(process.stdin, process.stderr);
|
|
2465
2509
|
}
|
|
2466
|
-
serverKey =
|
|
2510
|
+
serverKey = resolve2(serverKey).key;
|
|
2467
2511
|
}
|
|
2468
2512
|
let timeoutMs;
|
|
2469
2513
|
if (opts.timeout !== void 0) {
|
|
@@ -2485,7 +2529,7 @@ function registerLoginCommand(root) {
|
|
|
2485
2529
|
}
|
|
2486
2530
|
async function runLogin(cfg) {
|
|
2487
2531
|
await refuseIfProvisionedExternally("log in");
|
|
2488
|
-
const host = cfg.host ??
|
|
2532
|
+
const host = cfg.host ?? resolve2(cfg.serverKey).host;
|
|
2489
2533
|
const timeoutMs = cfg.timeoutMs !== void 0 && cfg.timeoutMs > 0 ? cfg.timeoutMs : DEFAULT_LOGIN_TIMEOUT_MS;
|
|
2490
2534
|
const controller = new AbortController();
|
|
2491
2535
|
const overallTimer = setTimeout(() => controller.abort(), timeoutMs + ABORT_SLACK_MS);
|
|
@@ -2576,7 +2620,7 @@ function registerLogoutCommand(root) {
|
|
|
2576
2620
|
throw new Error("either --server or --all is required");
|
|
2577
2621
|
}
|
|
2578
2622
|
try {
|
|
2579
|
-
serverKey =
|
|
2623
|
+
serverKey = resolve2(flag).key;
|
|
2580
2624
|
} catch (err) {
|
|
2581
2625
|
if (err instanceof InvalidServerUrlError) throw err;
|
|
2582
2626
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -2633,7 +2677,7 @@ async function runLogout(cfg) {
|
|
|
2633
2677
|
`);
|
|
2634
2678
|
return;
|
|
2635
2679
|
}
|
|
2636
|
-
const host =
|
|
2680
|
+
const host = resolve2(cfg.serverKey).host;
|
|
2637
2681
|
try {
|
|
2638
2682
|
await revoker(host, session);
|
|
2639
2683
|
} catch {
|
|
@@ -2735,7 +2779,7 @@ async function runWhoami(cfg) {
|
|
|
2735
2779
|
}
|
|
2736
2780
|
let host = "";
|
|
2737
2781
|
try {
|
|
2738
|
-
host =
|
|
2782
|
+
host = resolve2(cfg.serverKey).host;
|
|
2739
2783
|
} catch {
|
|
2740
2784
|
}
|
|
2741
2785
|
const impersonatorEmail = session.impersonatorEmail !== void 0 && session.impersonatorEmail !== "" ? session.impersonatorEmail : void 0;
|
|
@@ -2845,9 +2889,9 @@ function formatUtc(unix) {
|
|
|
2845
2889
|
}
|
|
2846
2890
|
|
|
2847
2891
|
// src/commands/appspace/compile.ts
|
|
2848
|
-
import { mkdir as mkdir6, mkdtemp as mkdtemp3, readdir as readdir3, readFile as
|
|
2892
|
+
import { mkdir as mkdir6, mkdtemp as mkdtemp3, readdir as readdir3, readFile as readFile9, rm as rm5, writeFile as writeFile7 } from "fs/promises";
|
|
2849
2893
|
import { tmpdir as tmpdir4 } from "os";
|
|
2850
|
-
import { basename, dirname as dirname7, isAbsolute, join as join15, resolve as
|
|
2894
|
+
import { basename, dirname as dirname7, isAbsolute, join as join15, resolve as resolve14, sep as sep4 } from "path";
|
|
2851
2895
|
|
|
2852
2896
|
// src/commands/appspace/_client.ts
|
|
2853
2897
|
function withServerOptions(cmd) {
|
|
@@ -2934,13 +2978,14 @@ async function defaultServerFromSession(opts, err = process.stderr) {
|
|
|
2934
2978
|
let session;
|
|
2935
2979
|
try {
|
|
2936
2980
|
session = await resolveFileStore(void 0);
|
|
2937
|
-
} catch {
|
|
2981
|
+
} catch (err2) {
|
|
2982
|
+
if (err2 instanceof CredentialFileRefusedError) throw err2;
|
|
2938
2983
|
return opts;
|
|
2939
2984
|
}
|
|
2940
2985
|
if (session === void 0) return opts;
|
|
2941
2986
|
let resolved;
|
|
2942
2987
|
try {
|
|
2943
|
-
resolved =
|
|
2988
|
+
resolved = resolve2(session.key);
|
|
2944
2989
|
} catch {
|
|
2945
2990
|
return opts;
|
|
2946
2991
|
}
|
|
@@ -3206,7 +3251,7 @@ function problemHeading(count) {
|
|
|
3206
3251
|
}
|
|
3207
3252
|
|
|
3208
3253
|
// src/commands/appspace/generate/catalog.ts
|
|
3209
|
-
import { readFile
|
|
3254
|
+
import { readFile } from "fs/promises";
|
|
3210
3255
|
import { createHash as createHash2 } from "crypto";
|
|
3211
3256
|
var NO_CATALOG = {
|
|
3212
3257
|
source: "none",
|
|
@@ -3218,7 +3263,7 @@ var NO_CATALOG = {
|
|
|
3218
3263
|
]
|
|
3219
3264
|
};
|
|
3220
3265
|
async function readCatalogFile(path3) {
|
|
3221
|
-
const raw = await
|
|
3266
|
+
const raw = await readFile(path3, "utf8");
|
|
3222
3267
|
let parsed2;
|
|
3223
3268
|
try {
|
|
3224
3269
|
parsed2 = JSON.parse(raw);
|
|
@@ -3734,12 +3779,12 @@ function isObject2(value) {
|
|
|
3734
3779
|
}
|
|
3735
3780
|
|
|
3736
3781
|
// ../flows/insights-builder/kit/contract/extract.mjs
|
|
3737
|
-
import { resolve as
|
|
3782
|
+
import { resolve as resolve4 } from "path";
|
|
3738
3783
|
import { fileURLToPath } from "url";
|
|
3739
3784
|
|
|
3740
3785
|
// ../flows/insights-builder/kit/checks/lib/app.mjs
|
|
3741
3786
|
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
3742
|
-
import { join as join4, relative, resolve as
|
|
3787
|
+
import { join as join4, relative, resolve as resolve3, sep } from "path";
|
|
3743
3788
|
var DATA_MODEL_PATH = "data_model.json";
|
|
3744
3789
|
var UI_PREFIX = "ui/";
|
|
3745
3790
|
var PAGE_PATH = /\.html?$/i;
|
|
@@ -3772,8 +3817,8 @@ function loadApp(dir) {
|
|
|
3772
3817
|
}
|
|
3773
3818
|
function readHandlerSource(dir, file) {
|
|
3774
3819
|
if (!file) return "";
|
|
3775
|
-
const root =
|
|
3776
|
-
const full =
|
|
3820
|
+
const root = resolve3(dir);
|
|
3821
|
+
const full = resolve3(root, file);
|
|
3777
3822
|
if (full !== root && !full.startsWith(root + sep)) return "";
|
|
3778
3823
|
if (!existsSync(full) || !statSync(full).isFile()) return "";
|
|
3779
3824
|
return readFileSync(full, "utf8");
|
|
@@ -4217,9 +4262,9 @@ function groupByObject(text4, pairs) {
|
|
|
4217
4262
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
4218
4263
|
const pair = pairs.get(i);
|
|
4219
4264
|
if (pair !== void 0 && stack.length > 0) {
|
|
4220
|
-
const
|
|
4221
|
-
if (!byObject.has(
|
|
4222
|
-
byObject.get(
|
|
4265
|
+
const open3 = stack[stack.length - 1];
|
|
4266
|
+
if (!byObject.has(open3)) byObject.set(open3, []);
|
|
4267
|
+
byObject.get(open3).push(pair);
|
|
4223
4268
|
}
|
|
4224
4269
|
i = endOfString(text4, i);
|
|
4225
4270
|
previous = '"';
|
|
@@ -4963,8 +5008,8 @@ var CONTEXT = LITERAL_CONTEXT;
|
|
|
4963
5008
|
function findDataLiterals(text4) {
|
|
4964
5009
|
const found = [];
|
|
4965
5010
|
for (let i = 0; i < text4.length; i++) {
|
|
4966
|
-
const
|
|
4967
|
-
if (
|
|
5011
|
+
const open3 = text4[i];
|
|
5012
|
+
if (open3 !== "[" && open3 !== "{") continue;
|
|
4968
5013
|
const close = closingIndex(text4, i);
|
|
4969
5014
|
if (close === -1) continue;
|
|
4970
5015
|
const body = text4.slice(i + 1, close);
|
|
@@ -5054,8 +5099,8 @@ function pyLiteral(value, { indent: indent2 = 0, width = DEFAULT_WIDTH, callable
|
|
|
5054
5099
|
function writeSpec(data, { library = null, name = "SPEC", width = DEFAULT_WIDTH } = {}) {
|
|
5055
5100
|
const problems = [];
|
|
5056
5101
|
const table = tableOf(data);
|
|
5057
|
-
const
|
|
5058
|
-
const hoisted = hoist(table, [],
|
|
5102
|
+
const constants3 = /* @__PURE__ */ new Map();
|
|
5103
|
+
const hoisted = hoist(table, [], constants3, null);
|
|
5059
5104
|
const callables = /* @__PURE__ */ new Set();
|
|
5060
5105
|
let text4 = null;
|
|
5061
5106
|
try {
|
|
@@ -5076,7 +5121,7 @@ function writeSpec(data, { library = null, name = "SPEC", width = DEFAULT_WIDTH
|
|
|
5076
5121
|
});
|
|
5077
5122
|
}
|
|
5078
5123
|
if (unknown.length > 0) return { text: null, imports: [], constants: [], problems };
|
|
5079
|
-
const rows2 = [...
|
|
5124
|
+
const rows2 = [...constants3].map(([constant, held]) => ({
|
|
5080
5125
|
name: constant,
|
|
5081
5126
|
value: held,
|
|
5082
5127
|
text: `${constant} = ${pyLiteral(held, { indent: 0, width, callables, pointer: `/${constant}` })}`
|
|
@@ -5093,11 +5138,11 @@ function writeSpec(data, { library = null, name = "SPEC", width = DEFAULT_WIDTH
|
|
|
5093
5138
|
if (problems.length > 0) return { text: null, imports: [], constants: [], problems };
|
|
5094
5139
|
return { text: text4, imports, constants: rows2, problems };
|
|
5095
5140
|
}
|
|
5096
|
-
function writeModule({ docstring = null, imports = [], constants:
|
|
5141
|
+
function writeModule({ docstring = null, imports = [], constants: constants3 = [], tables = [], body = null } = {}) {
|
|
5097
5142
|
const blocks = [];
|
|
5098
5143
|
if (docstring !== null) blocks.push(asDocstring(docstring));
|
|
5099
5144
|
if (imports.length > 0) blocks.push(imports.join("\n"));
|
|
5100
|
-
if (
|
|
5145
|
+
if (constants3.length > 0) blocks.push(constants3.join("\n"));
|
|
5101
5146
|
for (const table of tables) blocks.push(table.replace(/\n+$/, ""));
|
|
5102
5147
|
if (body !== null) blocks.push(body.replace(/\n+$/, ""));
|
|
5103
5148
|
let text4 = "";
|
|
@@ -5237,34 +5282,34 @@ function pyString(text4) {
|
|
|
5237
5282
|
}
|
|
5238
5283
|
return out + quote;
|
|
5239
5284
|
}
|
|
5240
|
-
function hoist(value, path3,
|
|
5285
|
+
function hoist(value, path3, constants3, key) {
|
|
5241
5286
|
if (Array.isArray(value)) {
|
|
5242
|
-
const next = value.map((item, index) => hoist(item, [...path3, String(index)],
|
|
5243
|
-
return atLiteral(next, path3,
|
|
5287
|
+
const next = value.map((item, index) => hoist(item, [...path3, String(index)], constants3, null));
|
|
5288
|
+
return atLiteral(next, path3, constants3, key);
|
|
5244
5289
|
}
|
|
5245
5290
|
if (isPlainObject(value) && !("$callable" in value) && !("$const" in value)) {
|
|
5246
5291
|
const next = {};
|
|
5247
|
-
for (const [name, held] of Object.entries(value)) next[name] = hoist(held, [...path3, name],
|
|
5248
|
-
return atLiteral(next, path3,
|
|
5292
|
+
for (const [name, held] of Object.entries(value)) next[name] = hoist(held, [...path3, name], constants3, name);
|
|
5293
|
+
return atLiteral(next, path3, constants3, key);
|
|
5249
5294
|
}
|
|
5250
5295
|
return value;
|
|
5251
5296
|
}
|
|
5252
|
-
function atLiteral(value, path3,
|
|
5297
|
+
function atLiteral(value, path3, constants3, key) {
|
|
5253
5298
|
if (path3.length === 0) return value;
|
|
5254
5299
|
if (numbersIn(value) < MIN_NUMBERS) return value;
|
|
5255
5300
|
if (key !== null && LITERAL_CONTEXT.test(`"${key}": `)) return value;
|
|
5256
|
-
return nameNumbers(value, path3,
|
|
5301
|
+
return nameNumbers(value, path3, constants3);
|
|
5257
5302
|
}
|
|
5258
|
-
function nameNumbers(value, path3,
|
|
5303
|
+
function nameNumbers(value, path3, constants3) {
|
|
5259
5304
|
if (typeof value === "number") {
|
|
5260
|
-
const name = constantName(path3,
|
|
5261
|
-
|
|
5305
|
+
const name = constantName(path3, constants3);
|
|
5306
|
+
constants3.set(name, value);
|
|
5262
5307
|
return { $const: name };
|
|
5263
5308
|
}
|
|
5264
|
-
if (Array.isArray(value)) return value.map((item, index) => nameNumbers(item, [...path3, String(index)],
|
|
5309
|
+
if (Array.isArray(value)) return value.map((item, index) => nameNumbers(item, [...path3, String(index)], constants3));
|
|
5265
5310
|
if (isPlainObject(value) && !("$callable" in value) && !("$const" in value)) {
|
|
5266
5311
|
const out = {};
|
|
5267
|
-
for (const [key, held] of Object.entries(value)) out[key] = nameNumbers(held, [...path3, key],
|
|
5312
|
+
for (const [key, held] of Object.entries(value)) out[key] = nameNumbers(held, [...path3, key], constants3);
|
|
5268
5313
|
return out;
|
|
5269
5314
|
}
|
|
5270
5315
|
return value;
|
|
@@ -5278,11 +5323,11 @@ function numbersIn(value) {
|
|
|
5278
5323
|
}
|
|
5279
5324
|
return 0;
|
|
5280
5325
|
}
|
|
5281
|
-
function constantName(path3,
|
|
5326
|
+
function constantName(path3, constants3) {
|
|
5282
5327
|
const base = path3.join("_").replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
5283
5328
|
const start = /^[A-Z_]/.test(base) ? base : `N_${base}`;
|
|
5284
|
-
if (!
|
|
5285
|
-
for (let n = 2; ; n += 1) if (!
|
|
5329
|
+
if (!constants3.has(start)) return start;
|
|
5330
|
+
for (let n = 2; ; n += 1) if (!constants3.has(`${start}_${n}`)) return `${start}_${n}`;
|
|
5286
5331
|
}
|
|
5287
5332
|
function asDocstring(text4) {
|
|
5288
5333
|
const body = String(text4).replace(/\\/g, "\\\\").replace(/"""/g, '\\"\\"\\"').replace(/\s+$/, "");
|
|
@@ -5546,12 +5591,12 @@ function isCalled(tokens, index) {
|
|
|
5546
5591
|
let first = index;
|
|
5547
5592
|
let last = index;
|
|
5548
5593
|
for (; ; ) {
|
|
5549
|
-
const
|
|
5594
|
+
const open3 = significantIndex(tokens, first, -1);
|
|
5550
5595
|
const close = significantIndex(tokens, last, 1);
|
|
5551
|
-
if (
|
|
5552
|
-
if (tokens[
|
|
5553
|
-
if (isSubscript(previousToken(tokens,
|
|
5554
|
-
first =
|
|
5596
|
+
if (open3 === -1 || close === -1) break;
|
|
5597
|
+
if (tokens[open3].type !== "punct" || tokens[open3].value !== "(" || tokens[close].type !== "punct" || tokens[close].value !== ")") break;
|
|
5598
|
+
if (isSubscript(previousToken(tokens, open3))) break;
|
|
5599
|
+
first = open3;
|
|
5555
5600
|
last = close;
|
|
5556
5601
|
}
|
|
5557
5602
|
const after = nextToken(tokens, last);
|
|
@@ -5686,8 +5731,8 @@ function lineOpening(tokens, index) {
|
|
|
5686
5731
|
while (i > 0 && tokens[i - 1].type !== "newline") i -= 1;
|
|
5687
5732
|
return tokens[i] ?? null;
|
|
5688
5733
|
}
|
|
5689
|
-
function signatureProblem(tokens,
|
|
5690
|
-
const entries = parameterEntries(tokens,
|
|
5734
|
+
function signatureProblem(tokens, open3) {
|
|
5735
|
+
const entries = parameterEntries(tokens, open3);
|
|
5691
5736
|
if (entries === null) return null;
|
|
5692
5737
|
let positional = 0;
|
|
5693
5738
|
let required = 0;
|
|
@@ -5720,11 +5765,11 @@ function signatureProblem(tokens, open2) {
|
|
|
5720
5765
|
}
|
|
5721
5766
|
return null;
|
|
5722
5767
|
}
|
|
5723
|
-
function parameterEntries(tokens,
|
|
5768
|
+
function parameterEntries(tokens, open3) {
|
|
5724
5769
|
const entries = [];
|
|
5725
5770
|
let depth = 0;
|
|
5726
5771
|
let entry = [];
|
|
5727
|
-
for (let i =
|
|
5772
|
+
for (let i = open3; i < tokens.length; i += 1) {
|
|
5728
5773
|
const token = tokens[i];
|
|
5729
5774
|
if (token.type === "newline") continue;
|
|
5730
5775
|
if (token.type === "punct" && OPENERS2.includes(token.value)) {
|
|
@@ -6111,15 +6156,15 @@ function readPage(app, page, spec, elements, problems) {
|
|
|
6111
6156
|
}
|
|
6112
6157
|
const bands = significant.filter((entry) => entry.type === "region" && entry.role === BAND_ROLE);
|
|
6113
6158
|
const banded = bands.map((entry, index) => sectionOf(entry.node, page.text, index));
|
|
6114
|
-
let
|
|
6159
|
+
let open3 = null;
|
|
6115
6160
|
let next = 0;
|
|
6116
6161
|
for (const entry of significant) {
|
|
6117
6162
|
if (next < bands.length && entry === bands[next]) {
|
|
6118
|
-
|
|
6163
|
+
open3 = banded[next].id;
|
|
6119
6164
|
next += 1;
|
|
6120
6165
|
continue;
|
|
6121
6166
|
}
|
|
6122
|
-
if (
|
|
6167
|
+
if (open3 !== null) elements[uids.get(entry.node.index)].section = open3;
|
|
6123
6168
|
}
|
|
6124
6169
|
const wrappers = tree.nodes.filter((node) => node.attrs[SECTION_ATTR] !== void 0);
|
|
6125
6170
|
const wrapped = wrappers.map((node, index) => wrappedSectionOf(tree, node, page.text, index));
|
|
@@ -7235,14 +7280,14 @@ function canonical(value) {
|
|
|
7235
7280
|
return value;
|
|
7236
7281
|
}
|
|
7237
7282
|
var ENTRY = fileURLToPath(import.meta.url);
|
|
7238
|
-
if (process.argv[1] &&
|
|
7283
|
+
if (process.argv[1] && resolve4(process.argv[1]) === ENTRY && ENTRY.endsWith("extract.mjs")) {
|
|
7239
7284
|
let raw = "";
|
|
7240
7285
|
process.stdin.setEncoding("utf8");
|
|
7241
7286
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
7242
7287
|
process.stdin.on("end", () => {
|
|
7243
7288
|
try {
|
|
7244
7289
|
const input = JSON.parse(raw);
|
|
7245
|
-
const app = loadApp(
|
|
7290
|
+
const app = loadApp(resolve4(input.app.dir));
|
|
7246
7291
|
process.stdout.write(JSON.stringify(extract(app, { describe: input.describe })));
|
|
7247
7292
|
} catch (e) {
|
|
7248
7293
|
process.stderr.write(`contract: ${e instanceof AppLoadError ? e.message : e.stack ?? e}
|
|
@@ -8564,8 +8609,8 @@ function stringEnd(text4, i) {
|
|
|
8564
8609
|
return Math.min(j + 1, text4.length);
|
|
8565
8610
|
}
|
|
8566
8611
|
function closeOf(text4, i) {
|
|
8567
|
-
const
|
|
8568
|
-
const close = { "{": "}", "(": ")", "[": "]" }[
|
|
8612
|
+
const open3 = text4[i];
|
|
8613
|
+
const close = { "{": "}", "(": ")", "[": "]" }[open3];
|
|
8569
8614
|
let depth = 0;
|
|
8570
8615
|
for (let j = i; j < text4.length; j++) {
|
|
8571
8616
|
const ch = text4[j];
|
|
@@ -9094,7 +9139,7 @@ function check2(instance, node, at, root, problems, ctx) {
|
|
|
9094
9139
|
const start = problems.length;
|
|
9095
9140
|
const hint = describe2(node, ctx);
|
|
9096
9141
|
if (typeof node.$ref === "string") {
|
|
9097
|
-
const target =
|
|
9142
|
+
const target = resolve5(node.$ref, root);
|
|
9098
9143
|
if (target === null) {
|
|
9099
9144
|
problems.push(problem2(at, "the schema names a reference it cannot resolve"));
|
|
9100
9145
|
return;
|
|
@@ -9192,7 +9237,7 @@ function shapes2(branches, root) {
|
|
|
9192
9237
|
const named13 = branches.map((branch) => {
|
|
9193
9238
|
let node = branch;
|
|
9194
9239
|
for (let hops = 0; isObject3(node) && typeof node.$ref === "string" && hops < 8; hops += 1) {
|
|
9195
|
-
const target =
|
|
9240
|
+
const target = resolve5(node.$ref, root);
|
|
9196
9241
|
if (target === null) break;
|
|
9197
9242
|
node = target;
|
|
9198
9243
|
}
|
|
@@ -9254,7 +9299,7 @@ function same2(a, b) {
|
|
|
9254
9299
|
if (typeof a === "boolean" || typeof b === "boolean") return a === b;
|
|
9255
9300
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
9256
9301
|
}
|
|
9257
|
-
function
|
|
9302
|
+
function resolve5(ref, root) {
|
|
9258
9303
|
if (!ref.startsWith("#/")) return null;
|
|
9259
9304
|
let node = root;
|
|
9260
9305
|
for (const token of ref.slice(2).split("/")) {
|
|
@@ -9361,8 +9406,8 @@ function navLinks(html, { owned = false, from } = {}) {
|
|
|
9361
9406
|
const regions = [];
|
|
9362
9407
|
if (owned) regions.push(text4);
|
|
9363
9408
|
else {
|
|
9364
|
-
for (const
|
|
9365
|
-
const rest = text4.slice(
|
|
9409
|
+
for (const open3 of text4.matchAll(NAV_OPEN)) {
|
|
9410
|
+
const rest = text4.slice(open3.index + open3[0].length);
|
|
9366
9411
|
const end = rest.search(NAV_CLOSE);
|
|
9367
9412
|
regions.push(end === -1 ? rest : rest.slice(0, end));
|
|
9368
9413
|
}
|
|
@@ -9795,24 +9840,24 @@ function sourceRoles(contract, name, known = /* @__PURE__ */ new Set()) {
|
|
|
9795
9840
|
const pages = new Map(pagesOf(contract).map((page) => [page.path, page]));
|
|
9796
9841
|
const union = [];
|
|
9797
9842
|
let readers = 0;
|
|
9798
|
-
let
|
|
9843
|
+
let open3 = false;
|
|
9799
9844
|
for (const element of Object.values(elements)) {
|
|
9800
9845
|
const props = isPlainObject3(element?.props) ? element.props : {};
|
|
9801
9846
|
const reads = [props.source, ...Array.isArray(props.declares?.reads) ? props.declares.reads : []];
|
|
9802
9847
|
if (!reads.includes(name)) continue;
|
|
9803
9848
|
readers += 1;
|
|
9804
9849
|
const roles = pageRoles(pages.get(element.page));
|
|
9805
|
-
if (roles.length === 0)
|
|
9850
|
+
if (roles.length === 0) open3 = true;
|
|
9806
9851
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
9807
9852
|
}
|
|
9808
9853
|
for (const page of pagesOf(contract)) {
|
|
9809
9854
|
if (page.owned !== true || readers === 0 || known.has(page.path)) continue;
|
|
9810
9855
|
const roles = pageRoles(page);
|
|
9811
|
-
if (roles.length === 0)
|
|
9856
|
+
if (roles.length === 0) open3 = true;
|
|
9812
9857
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
9813
9858
|
}
|
|
9814
9859
|
if (stated2.length > 0) return { roles: stated2, inherited: false, readers };
|
|
9815
|
-
if (readers === 0 ||
|
|
9860
|
+
if (readers === 0 || open3) return { roles: [], inherited: true, readers };
|
|
9816
9861
|
const order2 = roleModel(contract).names;
|
|
9817
9862
|
return { roles: union.sort((a, b) => order2.indexOf(a) - order2.indexOf(b)), inherited: true, readers };
|
|
9818
9863
|
}
|
|
@@ -10213,10 +10258,10 @@ function railReachProblems(contract) {
|
|
|
10213
10258
|
const pages = new Map((Array.isArray(contract?.pages) ? contract.pages : []).filter((page) => named4(page?.path)).map((page) => [page.path, page]));
|
|
10214
10259
|
const openers = (page) => Array.isArray(page?.roles) && page.roles.filter(named4).length > 0 ? page.roles.filter(named4) : null;
|
|
10215
10260
|
const canOpen = (name, page) => {
|
|
10216
|
-
const
|
|
10217
|
-
if (
|
|
10261
|
+
const open3 = openers(page);
|
|
10262
|
+
if (open3 === null) return true;
|
|
10218
10263
|
const role = declared.get(name);
|
|
10219
|
-
return
|
|
10264
|
+
return open3.includes(name) || (role?.sees ?? []).some((seen) => open3.includes(seen));
|
|
10220
10265
|
};
|
|
10221
10266
|
for (const key of ["entries", "footer"]) {
|
|
10222
10267
|
for (const [index, entry] of (Array.isArray(rail[key]) ? rail[key] : []).entries()) {
|
|
@@ -10975,17 +11020,17 @@ function handlerFile(contract, handlerName, written, library, transforms = {}) {
|
|
|
10975
11020
|
"contract, not this file."
|
|
10976
11021
|
].join("\n");
|
|
10977
11022
|
const imports = ["from appspace import widgets", ...written.imports].sort(natural3);
|
|
10978
|
-
const
|
|
11023
|
+
const constants3 = [];
|
|
10979
11024
|
if (library !== null && typeof library.version === "string") {
|
|
10980
|
-
|
|
10981
|
-
|
|
11025
|
+
constants3.push("# The release of the hook library this table was built against.");
|
|
11026
|
+
constants3.push(`LIBRARY_VERSION = ${pyString2(library.version)}`);
|
|
10982
11027
|
}
|
|
10983
|
-
for (const row of written.constants)
|
|
11028
|
+
for (const row of written.constants) constants3.push(row.text);
|
|
10984
11029
|
const carried = Object.keys(transforms).length > 0;
|
|
10985
11030
|
return writeModule({
|
|
10986
11031
|
docstring,
|
|
10987
11032
|
imports,
|
|
10988
|
-
constants:
|
|
11033
|
+
constants: constants3,
|
|
10989
11034
|
tables: carried ? [written.text, transformsTable(transforms)] : [written.text],
|
|
10990
11035
|
body: [
|
|
10991
11036
|
"def handle(ctx, payload):",
|
|
@@ -11157,8 +11202,8 @@ function controlRow(elements) {
|
|
|
11157
11202
|
parts.push(`data-dr-control="${attr(props.param ?? control.binding ?? "")}"`);
|
|
11158
11203
|
if (props.control_kind) parts.push(`data-dr-control-kind="${attr(props.control_kind)}"`);
|
|
11159
11204
|
const classes = (control.classes ?? []).join(" ");
|
|
11160
|
-
const
|
|
11161
|
-
out.push(` <${control.tag ?? "input"}${
|
|
11205
|
+
const open3 = classes === "" ? "" : ` class="${attr(classes)}"`;
|
|
11206
|
+
out.push(` <${control.tag ?? "input"}${open3} ${parts.join(" ")} />`);
|
|
11162
11207
|
out.push(" </span>");
|
|
11163
11208
|
}
|
|
11164
11209
|
out.push("</div>");
|
|
@@ -12712,7 +12757,7 @@ var KEY_SHAPE = {
|
|
|
12712
12757
|
var ROLE_KEYS = {
|
|
12713
12758
|
not_own: {
|
|
12714
12759
|
roles: ["decide", "save", "remove"],
|
|
12715
|
-
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"
|
|
12716
12761
|
},
|
|
12717
12762
|
// Required on `decide` (REQUIRED_KEYS), optional on `remove` and on `save`'s
|
|
12718
12763
|
// update: the one state a row may be deleted from or changed in. Anywhere
|
|
@@ -14117,7 +14162,7 @@ function tokenValueProblem(value) {
|
|
|
14117
14162
|
if (value.includes("<")) return "holds <, which no CSS value needs";
|
|
14118
14163
|
if (/url\s*\(/i.test(value)) return "holds url(, and a theme loads nothing";
|
|
14119
14164
|
const closing = { ")": "(", "]": "[" };
|
|
14120
|
-
const
|
|
14165
|
+
const open3 = [];
|
|
14121
14166
|
let quote = null;
|
|
14122
14167
|
for (const ch of value) {
|
|
14123
14168
|
if (quote !== null) {
|
|
@@ -14125,11 +14170,11 @@ function tokenValueProblem(value) {
|
|
|
14125
14170
|
continue;
|
|
14126
14171
|
}
|
|
14127
14172
|
if (ch === '"' || ch === "'") quote = ch;
|
|
14128
|
-
else if (ch === "(" || ch === "[")
|
|
14129
|
-
else if (ch in closing &&
|
|
14173
|
+
else if (ch === "(" || ch === "[") open3.push(ch);
|
|
14174
|
+
else if (ch in closing && open3.pop() !== closing[ch]) return "holds an unbalanced bracket";
|
|
14130
14175
|
}
|
|
14131
14176
|
if (quote !== null) return "holds an unbalanced quote";
|
|
14132
|
-
if (
|
|
14177
|
+
if (open3.length > 0) return "holds an unbalanced bracket";
|
|
14133
14178
|
return null;
|
|
14134
14179
|
}
|
|
14135
14180
|
function appIdProblems(app) {
|
|
@@ -17209,7 +17254,10 @@ function requiresLines(row, verb) {
|
|
|
17209
17254
|
const noun = singular(row.table);
|
|
17210
17255
|
return [
|
|
17211
17256
|
" for column, (target, noun, display, conditions) in REQUIRES.items():",
|
|
17212
|
-
|
|
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
|
+
" )",
|
|
17213
17261
|
" if linked is None:",
|
|
17214
17262
|
" return {",
|
|
17215
17263
|
` "error": f${pyString(`this ${noun} names no {noun} this app can see`)},`,
|
|
@@ -17494,8 +17542,8 @@ function measuredSummary(row) {
|
|
|
17494
17542
|
...answers
|
|
17495
17543
|
];
|
|
17496
17544
|
}
|
|
17497
|
-
const body = ["def handle(ctx, payload):", " del payload", ' table = ctx.
|
|
17498
|
-
const
|
|
17545
|
+
const body = ["def handle(ctx, payload):", " del payload", ' table = ctx.app.tables.table(HANDLER["table"])', " answer = {}", ...loop, " return answer"].join("\n");
|
|
17546
|
+
const constants3 = [assignment("MEASURES", measures, Object.keys(measures))];
|
|
17499
17547
|
if (kinds.length === 0) {
|
|
17500
17548
|
return {
|
|
17501
17549
|
docstring: `Answer each tile on the page with a count of the events of ${row.table}.
|
|
@@ -17507,7 +17555,7 @@ wrote it \u2014 so none counts an event of a row this caller may not see.
|
|
|
17507
17555
|
|
|
17508
17556
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17509
17557
|
contract, not this file.`,
|
|
17510
|
-
constants:
|
|
17558
|
+
constants: constants3,
|
|
17511
17559
|
body
|
|
17512
17560
|
};
|
|
17513
17561
|
}
|
|
@@ -17521,7 +17569,7 @@ may not see. \`$today\` and its siblings are UTC. An average over no rows is
|
|
|
17521
17569
|
None, which a stat shows as a dash.
|
|
17522
17570
|
|
|
17523
17571
|
` + (events ? "A count of events is what the platform recorded for rows this caller may\nread \u2014 each event its route stamped with the handler that wrote it.\n\n" : "") + "Generated by dashboard-kit/contract compile from contract.json \u2014 edit the\ncontract, not this file.",
|
|
17524
|
-
constants:
|
|
17572
|
+
constants: constants3,
|
|
17525
17573
|
body
|
|
17526
17574
|
};
|
|
17527
17575
|
}
|
|
@@ -17665,7 +17713,7 @@ function groupedBy(row) {
|
|
|
17665
17713
|
function singular(name) {
|
|
17666
17714
|
return String(name).endsWith("s") ? String(name).slice(0, -1) : String(name);
|
|
17667
17715
|
}
|
|
17668
|
-
function queryCall(row, { receiver = 'ctx.
|
|
17716
|
+
function queryCall(row, { receiver = 'ctx.app.tables.table(HANDLER["table"])', indent: indent2 = 4, include = false } = {}) {
|
|
17669
17717
|
const args = [];
|
|
17670
17718
|
if (isPlainObject8(row.where)) args.push('where=HANDLER["where"]');
|
|
17671
17719
|
if (named5(row.order_by)) args.push('order_by=HANDLER["order_by"]');
|
|
@@ -17690,8 +17738,8 @@ function notOwnLines(row, id, verb, indent2) {
|
|
|
17690
17738
|
function singletonSave(row, table) {
|
|
17691
17739
|
const enums = enumsOf(row, table);
|
|
17692
17740
|
const refs = refsOf(row, table);
|
|
17693
|
-
const
|
|
17694
|
-
if (Object.keys(refs).length > 0)
|
|
17741
|
+
const constants3 = Object.keys(enums).length > 0 ? [assignment("ENUMS", enums, Object.keys(enums))] : [];
|
|
17742
|
+
if (Object.keys(refs).length > 0) constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
17695
17743
|
return {
|
|
17696
17744
|
docstring: `Save the ${singular(row.table)}: the table holds one row, so there is no id to send.
|
|
17697
17745
|
|
|
@@ -17703,12 +17751,12 @@ rather than written.
|
|
|
17703
17751
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17704
17752
|
contract, not this file.`,
|
|
17705
17753
|
imports: Object.keys(refs).length > 0 ? ["import uuid"] : [],
|
|
17706
|
-
constants:
|
|
17754
|
+
constants: constants3,
|
|
17707
17755
|
body: [
|
|
17708
17756
|
"def handle(ctx, payload):",
|
|
17709
17757
|
...collectRow(row, enums),
|
|
17710
17758
|
...Object.keys(refs).length > 0 ? refLines() : [],
|
|
17711
|
-
' return {"row": ctx.
|
|
17759
|
+
' return {"row": ctx.app.tables.table(HANDLER["table"]).save(row)}'
|
|
17712
17760
|
].join("\n")
|
|
17713
17761
|
};
|
|
17714
17762
|
}
|
|
@@ -17743,7 +17791,7 @@ function parentLines(row, parent, { missing, invisible }) {
|
|
|
17743
17791
|
' parent_id = str(uuid.UUID(str(payload.get(HANDLER["by"]))))',
|
|
17744
17792
|
" except ValueError:",
|
|
17745
17793
|
` return ${missing}`,
|
|
17746
|
-
" if ctx.
|
|
17794
|
+
" if ctx.app.tables.table(PARENT).get(parent_id) is None:",
|
|
17747
17795
|
` return ${invisible}`
|
|
17748
17796
|
];
|
|
17749
17797
|
}
|
|
@@ -17772,7 +17820,7 @@ function refLines() {
|
|
|
17772
17820
|
" row[field] = str(uuid.UUID(str(row[field])))",
|
|
17773
17821
|
" except ValueError:",
|
|
17774
17822
|
' return {"error": f"{field} is not a {noun} this app can see"}',
|
|
17775
|
-
" if ctx.
|
|
17823
|
+
" if ctx.app.tables.table(target).get(row[field]) is None:",
|
|
17776
17824
|
' return {"error": f"{field} is not a {noun} this app can see"}'
|
|
17777
17825
|
];
|
|
17778
17826
|
}
|
|
@@ -17801,7 +17849,7 @@ contract, not this file.`,
|
|
|
17801
17849
|
" payload = payload or {}",
|
|
17802
17850
|
...parentLines(row, parent, { missing: '{"rows": []}', invisible: '{"rows": []}' }),
|
|
17803
17851
|
where2,
|
|
17804
|
-
` rows = ctx.
|
|
17852
|
+
` rows = ctx.app.tables.table(HANDLER["table"]).query(
|
|
17805
17853
|
${args.map((arg) => ` ${arg},`).join("\n")}
|
|
17806
17854
|
)`,
|
|
17807
17855
|
' return {"rows": rows}'
|
|
@@ -17839,7 +17887,7 @@ contract, not this file.`,
|
|
|
17839
17887
|
' row_id = payload.get("id")',
|
|
17840
17888
|
" if not row_id:",
|
|
17841
17889
|
' return {"error": "id is required"}',
|
|
17842
|
-
' table = ctx.
|
|
17890
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
17843
17891
|
...guardLines(row, model, "row", 4),
|
|
17844
17892
|
...notOwnLines(row, "row_id", "remove", 4),
|
|
17845
17893
|
" table.delete(row_id)",
|
|
@@ -17869,7 +17917,7 @@ function decideMap(name, row, table, model) {
|
|
|
17869
17917
|
' if not isinstance(decision, str) or decision not in HANDLER["decision"]:',
|
|
17870
17918
|
' return {"error": f"{decision} is not a decision this app makes"}',
|
|
17871
17919
|
' spec = HANDLER["decision"][decision]',
|
|
17872
|
-
' table = ctx.
|
|
17920
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
17873
17921
|
" try:",
|
|
17874
17922
|
' row_id = str(uuid.UUID(str(payload.get("id"))))',
|
|
17875
17923
|
" except ValueError:",
|
|
@@ -17974,7 +18022,10 @@ contract, not this file.`,
|
|
|
17974
18022
|
' row_id = str(uuid.UUID(str(payload.get("id"))))',
|
|
17975
18023
|
" except ValueError:",
|
|
17976
18024
|
' return {"rows": []}',
|
|
17977
|
-
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)',
|
|
17978
18029
|
' return {"rows": rows}'
|
|
17979
18030
|
].join("\n")
|
|
17980
18031
|
}),
|
|
@@ -17983,8 +18034,8 @@ contract, not this file.`,
|
|
|
17983
18034
|
const enums = enumsOf(row, table);
|
|
17984
18035
|
const refs = refsOf(row, table);
|
|
17985
18036
|
const guarded = named5(row.guard);
|
|
17986
|
-
const
|
|
17987
|
-
if (Object.keys(refs).length > 0)
|
|
18037
|
+
const constants3 = Object.keys(enums).length > 0 ? [assignment("ENUMS", enums, Object.keys(enums))] : [];
|
|
18038
|
+
if (Object.keys(refs).length > 0) constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
17988
18039
|
const guardDoc = guarded ? `
|
|
17989
18040
|
|
|
17990
18041
|
\`guard\` holds an edit to one state: only a row that is still ${row.guard} may be
|
|
@@ -18001,12 +18052,12 @@ is a column anyone may set.${guardDoc}
|
|
|
18001
18052
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
18002
18053
|
contract, not this file.`,
|
|
18003
18054
|
imports: Object.keys(refs).length > 0 || guarded ? ["import uuid"] : [],
|
|
18004
|
-
constants:
|
|
18055
|
+
constants: constants3,
|
|
18005
18056
|
body: [
|
|
18006
18057
|
"def handle(ctx, payload):",
|
|
18007
18058
|
...collectRow(row, enums),
|
|
18008
18059
|
...Object.keys(refs).length > 0 ? refLines() : [],
|
|
18009
|
-
' table = ctx.
|
|
18060
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
18010
18061
|
' row_id = payload.get("id")',
|
|
18011
18062
|
" if row_id:",
|
|
18012
18063
|
...guarded ? guardLines(row, model, "current", 8) : [],
|
|
@@ -18033,16 +18084,16 @@ contract, not this file.`,
|
|
|
18033
18084
|
' return {"error": "id is required"}',
|
|
18034
18085
|
// `is_own` on a row that is not there is False, and `delete` then
|
|
18035
18086
|
// raises NotFound exactly as it does without the guard.
|
|
18036
|
-
...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)'],
|
|
18037
18088
|
' return {"removed": row_id}'
|
|
18038
18089
|
].join("\n")
|
|
18039
18090
|
},
|
|
18040
18091
|
submit: (name, row, table, model) => {
|
|
18041
18092
|
const enums = enumsOf(row, table);
|
|
18042
18093
|
const decimals = decimalsOf(row, table);
|
|
18043
|
-
const
|
|
18044
|
-
if (Object.keys(enums).length > 0)
|
|
18045
|
-
if (decimals.length > 0)
|
|
18094
|
+
const constants3 = [];
|
|
18095
|
+
if (Object.keys(enums).length > 0) constants3.push(assignment("ENUMS", enums, Object.keys(enums)));
|
|
18096
|
+
if (decimals.length > 0) constants3.push(`DECIMALS = ${pyLiteral(decimals)}`);
|
|
18046
18097
|
const lines = ["def handle(ctx, payload):", ...collectRow(row, enums)];
|
|
18047
18098
|
if (decimals.length > 0) {
|
|
18048
18099
|
lines.push(
|
|
@@ -18056,21 +18107,21 @@ contract, not this file.`,
|
|
|
18056
18107
|
}
|
|
18057
18108
|
const refs = refsOf(row, table);
|
|
18058
18109
|
if (Object.keys(refs).length > 0) {
|
|
18059
|
-
|
|
18110
|
+
constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
18060
18111
|
lines.push(...refLines());
|
|
18061
18112
|
}
|
|
18062
18113
|
const parent = linkedParent(row, model);
|
|
18063
18114
|
if (parent !== null) {
|
|
18064
|
-
|
|
18115
|
+
constants3.push(`PARENT = ${pyString(parent)}`);
|
|
18065
18116
|
lines.push(...parentLines(row, parent, { missing: `{"error": ${pyString(`${row.by} is required`)}}`, invisible: `{"error": ${pyString(`${row.by} names no ${singular(parent)} this app can see`)}}` }));
|
|
18066
18117
|
lines.push(' row[HANDLER["by"]] = parent_id');
|
|
18067
18118
|
}
|
|
18068
18119
|
if (isPlainObject8(row.requires)) {
|
|
18069
|
-
|
|
18120
|
+
constants3.push(...requiresConstants(row, model));
|
|
18070
18121
|
lines.push(...requiresLines(row, "saved"));
|
|
18071
18122
|
}
|
|
18072
18123
|
if (isPlainObject8(row.fixed) && Object.keys(row.fixed).length > 0) lines.push(' row.update(HANDLER["fixed"])');
|
|
18073
|
-
lines.push(' return {"row": ctx.
|
|
18124
|
+
lines.push(' return {"row": ctx.app.tables.table(HANDLER["table"]).insert(row)}');
|
|
18074
18125
|
const linkDoc = parent === null ? "" : `
|
|
18075
18126
|
|
|
18076
18127
|
\`by\` stamps the new ${singular(row.table)} with the ${singular(parent)} the reader opened, and
|
|
@@ -18085,7 +18136,7 @@ browser could choose is a status anyone can choose.${linkDoc}${requiresDoc(row)}
|
|
|
18085
18136
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
18086
18137
|
contract, not this file.`,
|
|
18087
18138
|
imports: [...parent !== null || Object.keys(refs).length > 0 ? ["import uuid"] : [], ...decimals.length > 0 ? ["from decimal import Decimal, InvalidOperation"] : []],
|
|
18088
|
-
constants:
|
|
18139
|
+
constants: constants3,
|
|
18089
18140
|
body: lines.join("\n")
|
|
18090
18141
|
};
|
|
18091
18142
|
},
|
|
@@ -18100,7 +18151,7 @@ contract, not this file.`,
|
|
|
18100
18151
|
' decision = payload.get("decision") or HANDLER["decision"][0]',
|
|
18101
18152
|
' if decision not in HANDLER["decision"]:',
|
|
18102
18153
|
' return {"error": f"{decision} is not a decision this app makes"}',
|
|
18103
|
-
' table = ctx.
|
|
18154
|
+
' table = ctx.app.tables.table(HANDLER["table"])',
|
|
18104
18155
|
// Every table's key is a uuid (data_model: "pk must be uuid"), so an id
|
|
18105
18156
|
// that is not one names no row. It is the same miss as a row that is
|
|
18106
18157
|
// not there, and it has to reach the guard as one: `table.get` refuses
|
|
@@ -18156,7 +18207,7 @@ contract, not this file.`,
|
|
|
18156
18207
|
body: [
|
|
18157
18208
|
"def handle(ctx, payload):",
|
|
18158
18209
|
" del payload",
|
|
18159
|
-
' rows = ctx.
|
|
18210
|
+
' rows = ctx.app.tables.table(HANDLER["table"]).aggregate(',
|
|
18160
18211
|
" group_by=GROUP_BY,",
|
|
18161
18212
|
' metrics={"n": "count"},',
|
|
18162
18213
|
" )",
|
|
@@ -18472,9 +18523,9 @@ function nodeLines(uid, contract, page, elements, tree, model, depth) {
|
|
|
18472
18523
|
const lede = named5(header.summary) ? `<p>${text2(header.summary)}</p>` : "";
|
|
18473
18524
|
const actions = Array.isArray(header.actions) && header.actions.length > 0 ? ` data-dr-header-actions="${attr2(JSON.stringify(header.actions))}"` : "";
|
|
18474
18525
|
const from = named5(header.title_from) ? ` data-dr-title-from="${attr2(header.title_from)}"` : "";
|
|
18475
|
-
const
|
|
18476
|
-
if (kids.length === 0) return [`${
|
|
18477
|
-
return [
|
|
18526
|
+
const open3 = `${pad}<header data-dr-kit="header"${gridAttrs(element)}${actions}${from}><h1>${text2(heading)}</h1>${lede}`;
|
|
18527
|
+
if (kids.length === 0) return [`${open3}</header>`];
|
|
18528
|
+
return [open3, ...kids.flatMap((child) => nodeLines(child, contract, page, elements, tree, model, depth + 1)), `${pad}</header>`];
|
|
18478
18529
|
}
|
|
18479
18530
|
case "nav": {
|
|
18480
18531
|
const entries = (contract.pages ?? []).map((one) => {
|
|
@@ -21550,11 +21601,11 @@ function clone4(value) {
|
|
|
21550
21601
|
}
|
|
21551
21602
|
|
|
21552
21603
|
// src/commands/appspace/contract.ts
|
|
21553
|
-
import { mkdir as mkdir2, readFile as
|
|
21604
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
21554
21605
|
import { join as join6 } from "path";
|
|
21555
21606
|
|
|
21556
21607
|
// src/commands/appspace/_folder.ts
|
|
21557
|
-
import { readFile as
|
|
21608
|
+
import { readFile as readFile2, readdir, stat, writeFile as writeFile2 } from "fs/promises";
|
|
21558
21609
|
import { join as join5 } from "path";
|
|
21559
21610
|
|
|
21560
21611
|
// src/commands/appspace/_handlerNames.ts
|
|
@@ -21589,7 +21640,7 @@ function handlerFileProblem(file) {
|
|
|
21589
21640
|
// src/commands/appspace/_folder.ts
|
|
21590
21641
|
async function readIfPresent(path3) {
|
|
21591
21642
|
try {
|
|
21592
|
-
return await
|
|
21643
|
+
return await readFile2(path3, "utf8");
|
|
21593
21644
|
} catch {
|
|
21594
21645
|
return void 0;
|
|
21595
21646
|
}
|
|
@@ -21618,7 +21669,7 @@ async function readUiTree(uiDir) {
|
|
|
21618
21669
|
continue;
|
|
21619
21670
|
}
|
|
21620
21671
|
if (!entry.isFile()) continue;
|
|
21621
|
-
out.push({ path: `${prefix}${name}`, bytes: await
|
|
21672
|
+
out.push({ path: `${prefix}${name}`, bytes: await readFile2(full) });
|
|
21622
21673
|
}
|
|
21623
21674
|
};
|
|
21624
21675
|
await walk5(uiDir, "");
|
|
@@ -21671,7 +21722,7 @@ async function readHandlers(handlersDir, state) {
|
|
|
21671
21722
|
const method = recorded?.[name];
|
|
21672
21723
|
handlers[name] = {
|
|
21673
21724
|
http: typeof method === "string" && method !== "" ? method : "POST",
|
|
21674
|
-
code: await
|
|
21725
|
+
code: await readFile2(join5(handlersDir, file), "utf8")
|
|
21675
21726
|
};
|
|
21676
21727
|
}
|
|
21677
21728
|
return handlers;
|
|
@@ -21738,7 +21789,7 @@ async function readLib(libDir) {
|
|
|
21738
21789
|
`);
|
|
21739
21790
|
continue;
|
|
21740
21791
|
}
|
|
21741
|
-
lib[name] = await
|
|
21792
|
+
lib[name] = await readFile2(full, "utf8");
|
|
21742
21793
|
}
|
|
21743
21794
|
return lib;
|
|
21744
21795
|
}
|
|
@@ -21822,7 +21873,7 @@ async function extractContract(dir) {
|
|
|
21822
21873
|
}
|
|
21823
21874
|
async function readModelIfPresent(dir) {
|
|
21824
21875
|
try {
|
|
21825
|
-
return await
|
|
21876
|
+
return await readFile3(join6(dir, "data_model.json"), "utf8");
|
|
21826
21877
|
} catch {
|
|
21827
21878
|
return void 0;
|
|
21828
21879
|
}
|
|
@@ -21884,7 +21935,7 @@ ${summarise(contract)}
|
|
|
21884
21935
|
}
|
|
21885
21936
|
|
|
21886
21937
|
// src/commands/appspace/liveness.ts
|
|
21887
|
-
import { readFile as
|
|
21938
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
21888
21939
|
import { join as join7 } from "path";
|
|
21889
21940
|
|
|
21890
21941
|
// ../flows/insights-builder/kit/checks/rules/liveness.mjs
|
|
@@ -22050,7 +22101,7 @@ async function runLiveness(dir, appId, whole, client, only) {
|
|
|
22050
22101
|
}
|
|
22051
22102
|
let code;
|
|
22052
22103
|
try {
|
|
22053
|
-
code = await
|
|
22104
|
+
code = await readFile4(join7(dir, handler.file), "utf8");
|
|
22054
22105
|
} catch {
|
|
22055
22106
|
return unchecked(
|
|
22056
22107
|
`${handler.file} is not in this folder, so no handler was run`
|
|
@@ -22232,7 +22283,7 @@ function render2(result, declared) {
|
|
|
22232
22283
|
|
|
22233
22284
|
// src/commands/appspace/preview.ts
|
|
22234
22285
|
import { spawnSync } from "child_process";
|
|
22235
|
-
import { readFile as
|
|
22286
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
22236
22287
|
import { tmpdir } from "os";
|
|
22237
22288
|
var lintTransform2 = lintTransform;
|
|
22238
22289
|
var FORBIDDEN_CALLS2 = FORBIDDEN_CALLS;
|
|
@@ -22596,7 +22647,7 @@ function registerPreviewCommand(parent) {
|
|
|
22596
22647
|
).option("--payload <json>", 'The request to serve (default: {"op": "load"}).')
|
|
22597
22648
|
)
|
|
22598
22649
|
).action(async (file, opts) => {
|
|
22599
|
-
const text4 = await
|
|
22650
|
+
const text4 = await readFile5(file, "utf8").catch(() => {
|
|
22600
22651
|
throw new Error(`cannot read ${file}`);
|
|
22601
22652
|
});
|
|
22602
22653
|
let document;
|
|
@@ -22751,7 +22802,7 @@ async function previewOne(document, file, opts, shared = {}) {
|
|
|
22751
22802
|
}
|
|
22752
22803
|
|
|
22753
22804
|
// src/commands/appspace/push.ts
|
|
22754
|
-
import { readFile as
|
|
22805
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
22755
22806
|
import { join as join8 } from "path";
|
|
22756
22807
|
import { gunzipSync, gzipSync } from "zlib";
|
|
22757
22808
|
|
|
@@ -24549,7 +24600,7 @@ async function pushBody(dir, opts) {
|
|
|
24549
24600
|
handlers,
|
|
24550
24601
|
frontend_bundle: ui?.field === "frontend_bundle" ? ui.files : null,
|
|
24551
24602
|
publish: opts.publish === true,
|
|
24552
|
-
seed: (opts.seed ?? "") === "" ? null : JSON.parse(await
|
|
24603
|
+
seed: (opts.seed ?? "") === "" ? null : JSON.parse(await readFile6(opts.seed, "utf8"))
|
|
24553
24604
|
};
|
|
24554
24605
|
if (ui?.field === "frontend_bundle_gz") {
|
|
24555
24606
|
body["frontend_bundle_gz"] = ui.files;
|
|
@@ -24706,13 +24757,13 @@ async function pushFolder(dir, opts) {
|
|
|
24706
24757
|
}
|
|
24707
24758
|
|
|
24708
24759
|
// src/commands/appspace/get.ts
|
|
24709
|
-
import { lstat, mkdtemp, mkdir as mkdir4, readFile as
|
|
24760
|
+
import { lstat, mkdtemp, mkdir as mkdir4, readFile as readFile8, rm as rm3, writeFile as writeFile5 } from "fs/promises";
|
|
24710
24761
|
import { tmpdir as tmpdir2 } from "os";
|
|
24711
24762
|
import { dirname as dirname3, join as join10 } from "path";
|
|
24712
24763
|
|
|
24713
24764
|
// src/commands/appspace/generate/report.ts
|
|
24714
24765
|
import { createHash as createHash3 } from "crypto";
|
|
24715
|
-
import { mkdir as mkdir3, readFile as
|
|
24766
|
+
import { mkdir as mkdir3, readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
|
|
24716
24767
|
import { join as join9 } from "path";
|
|
24717
24768
|
function reportPath(dir) {
|
|
24718
24769
|
return join9(dir, ".appspace", "compile.json");
|
|
@@ -24753,7 +24804,7 @@ async function writeReport(dir, report) {
|
|
|
24753
24804
|
}
|
|
24754
24805
|
async function ownedFiles(dir) {
|
|
24755
24806
|
try {
|
|
24756
|
-
const parsed2 = JSON.parse(await
|
|
24807
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24757
24808
|
if (!Array.isArray(parsed2.files)) return /* @__PURE__ */ new Set();
|
|
24758
24809
|
return new Set(parsed2.files.map(String));
|
|
24759
24810
|
} catch {
|
|
@@ -24762,7 +24813,7 @@ async function ownedFiles(dir) {
|
|
|
24762
24813
|
}
|
|
24763
24814
|
async function recordedRenderer(dir) {
|
|
24764
24815
|
try {
|
|
24765
|
-
const parsed2 = JSON.parse(await
|
|
24816
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24766
24817
|
if (parsed2.kind !== "dashboard") return null;
|
|
24767
24818
|
return parsed2.renderer === "runtime" || parsed2.renderer === "widgets" ? parsed2.renderer : null;
|
|
24768
24819
|
} catch {
|
|
@@ -24774,7 +24825,7 @@ function digestOf(text4) {
|
|
|
24774
24825
|
}
|
|
24775
24826
|
async function recordedDigests(dir) {
|
|
24776
24827
|
try {
|
|
24777
|
-
const parsed2 = JSON.parse(await
|
|
24828
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24778
24829
|
const held = parsed2.digests;
|
|
24779
24830
|
if (typeof held !== "object" || held === null || Array.isArray(held)) return {};
|
|
24780
24831
|
return Object.fromEntries(Object.entries(held).filter((entry) => typeof entry[1] === "string"));
|
|
@@ -24785,7 +24836,7 @@ async function recordedDigests(dir) {
|
|
|
24785
24836
|
async function recordAsInput(dir, path3) {
|
|
24786
24837
|
let parsed2;
|
|
24787
24838
|
try {
|
|
24788
|
-
parsed2 = JSON.parse(await
|
|
24839
|
+
parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24789
24840
|
} catch {
|
|
24790
24841
|
return;
|
|
24791
24842
|
}
|
|
@@ -24823,7 +24874,7 @@ async function unpushedInputs(dir, pkg) {
|
|
|
24823
24874
|
const out = await unpushedLib(dir, pkg);
|
|
24824
24875
|
let inputs = [];
|
|
24825
24876
|
try {
|
|
24826
|
-
const parsed2 = JSON.parse(await
|
|
24877
|
+
const parsed2 = JSON.parse(await readFile8(reportPath(dir), "utf8"));
|
|
24827
24878
|
if (Array.isArray(parsed2.inputs)) inputs = parsed2.inputs.map(String);
|
|
24828
24879
|
} catch {
|
|
24829
24880
|
return out;
|
|
@@ -24857,9 +24908,9 @@ async function unpushedLib(dir, pkg) {
|
|
|
24857
24908
|
async function writePackage(dir, appId, pkg) {
|
|
24858
24909
|
await mkdir4(dir, { recursive: true });
|
|
24859
24910
|
await Promise.all([
|
|
24860
|
-
|
|
24861
|
-
|
|
24862
|
-
|
|
24911
|
+
rm3(join10(dir, "data_model.json"), { force: true }),
|
|
24912
|
+
rm3(join10(dir, "handlers"), { recursive: true, force: true }),
|
|
24913
|
+
rm3(join10(dir, "ui"), { recursive: true, force: true })
|
|
24863
24914
|
]);
|
|
24864
24915
|
const connected = pkg.connect_tables ?? {};
|
|
24865
24916
|
const manifestOut = Object.keys(connected).length > 0 ? { ...pkg.manifest, connect_tables: connected } : pkg.manifest;
|
|
@@ -24898,7 +24949,7 @@ async function writePackage(dir, appId, pkg) {
|
|
|
24898
24949
|
}
|
|
24899
24950
|
}
|
|
24900
24951
|
for (const file of await readDirIfPresent(libDir)) {
|
|
24901
|
-
if (file.endsWith(".py")) await
|
|
24952
|
+
if (file.endsWith(".py")) await rm3(join10(libDir, file), { force: true });
|
|
24902
24953
|
}
|
|
24903
24954
|
for (const [name, code] of Object.entries(pkg.lib)) {
|
|
24904
24955
|
await mkdir4(libDir, { recursive: true });
|
|
@@ -24982,7 +25033,7 @@ async function writeOwnedFiles(dir, document, { force = false } = {}) {
|
|
|
24982
25033
|
}
|
|
24983
25034
|
async function isDashboardFolder(dir) {
|
|
24984
25035
|
try {
|
|
24985
|
-
const manifest = JSON.parse(await
|
|
25036
|
+
const manifest = JSON.parse(await readFile8(join10(dir, "manifest.json"), "utf8"));
|
|
24986
25037
|
return manifest["kind"] === "dashboard";
|
|
24987
25038
|
} catch {
|
|
24988
25039
|
return false;
|
|
@@ -24992,7 +25043,7 @@ var OWNED_TEXT_PATH = /^transforms\/[a-z][a-z0-9_]*\.py$/;
|
|
|
24992
25043
|
async function restoreOwnedFiles(dir, contractWritten, { force }) {
|
|
24993
25044
|
let stated2 = [];
|
|
24994
25045
|
if (contractWritten) {
|
|
24995
|
-
const doc = JSON.parse(await
|
|
25046
|
+
const doc = JSON.parse(await readFile8(join10(dir, "contract.json"), "utf8"));
|
|
24996
25047
|
if (Array.isArray(doc["owned"])) stated2 = doc["owned"];
|
|
24997
25048
|
}
|
|
24998
25049
|
const known = new Set(
|
|
@@ -25044,7 +25095,7 @@ async function pullInto(client, appId, dir, {
|
|
|
25044
25095
|
if (err instanceof AppSpaceHttpError && err.status === 404) return null;
|
|
25045
25096
|
throw err;
|
|
25046
25097
|
}
|
|
25047
|
-
await
|
|
25098
|
+
await rm3(join10(dir, "contract.json"), { force: true });
|
|
25048
25099
|
await writePackage(dir, appId, pkg);
|
|
25049
25100
|
const read = await readStoredContract(client, appId, pkg.code_version);
|
|
25050
25101
|
if ("document" in read) {
|
|
@@ -25121,9 +25172,9 @@ function registerGetCommand(parent) {
|
|
|
25121
25172
|
}
|
|
25122
25173
|
|
|
25123
25174
|
// src/commands/appspace/packageCheck.ts
|
|
25124
|
-
import { cp, mkdir as mkdir5, mkdtemp as mkdtemp2, readdir as readdir2, rm as
|
|
25175
|
+
import { cp, mkdir as mkdir5, mkdtemp as mkdtemp2, readdir as readdir2, rm as rm4, writeFile as writeFile6 } from "fs/promises";
|
|
25125
25176
|
import { tmpdir as tmpdir3 } from "os";
|
|
25126
|
-
import { dirname as dirname4, join as join11, resolve as
|
|
25177
|
+
import { dirname as dirname4, join as join11, resolve as resolve6, sep as sep2 } from "path";
|
|
25127
25178
|
var WHAT = "package";
|
|
25128
25179
|
async function checkPackage(dir, files, contract, opts, online, pendingMetricKeys = []) {
|
|
25129
25180
|
const badName = await handlerNameProblems(dir, files);
|
|
@@ -25175,7 +25226,7 @@ async function checkPackage(dir, files, contract, opts, online, pendingMetricKey
|
|
|
25175
25226
|
client.cleanup();
|
|
25176
25227
|
}
|
|
25177
25228
|
} finally {
|
|
25178
|
-
await
|
|
25229
|
+
await rm4(scratch, { recursive: true, force: true });
|
|
25179
25230
|
}
|
|
25180
25231
|
}
|
|
25181
25232
|
async function handlerNameProblems(dir, files) {
|
|
@@ -25351,9 +25402,9 @@ async function stage(dir, scratch, files) {
|
|
|
25351
25402
|
recursive: true,
|
|
25352
25403
|
filter: (source) => !/[\\/](node_modules|\.git)$/.test(source)
|
|
25353
25404
|
});
|
|
25354
|
-
const root =
|
|
25405
|
+
const root = resolve6(scratch);
|
|
25355
25406
|
for (const [path3, text4] of Object.entries(files)) {
|
|
25356
|
-
const full =
|
|
25407
|
+
const full = resolve6(root, path3);
|
|
25357
25408
|
if (!full.startsWith(root + sep2)) {
|
|
25358
25409
|
return `the package names a path outside its folder (${JSON.stringify(path3)})`;
|
|
25359
25410
|
}
|
|
@@ -25537,7 +25588,7 @@ function isPlainObject10(value) {
|
|
|
25537
25588
|
|
|
25538
25589
|
// ../flows/insights-builder/kit/checks/verify.mjs
|
|
25539
25590
|
import { readFileSync as readFileSync3 } from "fs";
|
|
25540
|
-
import { dirname as dirname5, join as join12, resolve as
|
|
25591
|
+
import { dirname as dirname5, join as join12, resolve as resolve8 } from "path";
|
|
25541
25592
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
25542
25593
|
|
|
25543
25594
|
// ../flows/insights-builder/kit/checks/lib/executable.mjs
|
|
@@ -26421,10 +26472,10 @@ function checkControl(el, boxes, where2) {
|
|
|
26421
26472
|
}
|
|
26422
26473
|
function controlBoxes(text4) {
|
|
26423
26474
|
const boxes = [];
|
|
26424
|
-
const
|
|
26475
|
+
const open3 = new RegExp(`<([a-zA-Z][\\w-]*)([^>]*\\b${KIT_MARK}\\s*=\\s*["'](?:${[...CONTROL_BOXES].join("|")})["'][^>]*)>`, "g");
|
|
26425
26476
|
let match;
|
|
26426
|
-
while ((match =
|
|
26427
|
-
boxes.push([lineAt(text4, match.index), lineAt(text4, closingTag(text4, match[1].toLowerCase(),
|
|
26477
|
+
while ((match = open3.exec(text4)) !== null) {
|
|
26478
|
+
boxes.push([lineAt(text4, match.index), lineAt(text4, closingTag(text4, match[1].toLowerCase(), open3.lastIndex))]);
|
|
26428
26479
|
}
|
|
26429
26480
|
return boxes;
|
|
26430
26481
|
}
|
|
@@ -26736,7 +26787,7 @@ function checkTheme(app) {
|
|
|
26736
26787
|
const overrides = rootTokens(file.text);
|
|
26737
26788
|
if (overrides.size === 0) return { violations };
|
|
26738
26789
|
for (const theme of themesInUse(app)) {
|
|
26739
|
-
const ground = rgbOf2(overrides.has("--dr-surface") ?
|
|
26790
|
+
const ground = rgbOf2(overrides.has("--dr-surface") ? resolve7("--dr-surface", overrides) : THEME_SURFACES[theme]);
|
|
26740
26791
|
if (!ground) {
|
|
26741
26792
|
const surface = overrides.get("--dr-surface");
|
|
26742
26793
|
violations.push({
|
|
@@ -26749,7 +26800,7 @@ function checkTheme(app) {
|
|
|
26749
26800
|
for (const [token, { line: line2 }] of overrides) {
|
|
26750
26801
|
const rule = FLOORS.get(token);
|
|
26751
26802
|
if (!rule) continue;
|
|
26752
|
-
const value =
|
|
26803
|
+
const value = resolve7(token, overrides);
|
|
26753
26804
|
if (value === null) continue;
|
|
26754
26805
|
const series = /^--dr-chart-(\d+)$/.exec(token);
|
|
26755
26806
|
if (series && isPlatformChartColour(Number(series[1]), value)) continue;
|
|
@@ -26797,12 +26848,12 @@ function themesInUse(app) {
|
|
|
26797
26848
|
}
|
|
26798
26849
|
return found.size ? [...found].sort() : ["default"];
|
|
26799
26850
|
}
|
|
26800
|
-
function
|
|
26851
|
+
function resolve7(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
26801
26852
|
const entry = overrides.get(token);
|
|
26802
26853
|
if (!entry || seen.has(token)) return null;
|
|
26803
26854
|
seen.add(token);
|
|
26804
26855
|
const hit = /^var\(\s*(--[a-z0-9-]+)/.exec(entry.value);
|
|
26805
|
-
return hit ?
|
|
26856
|
+
return hit ? resolve7(hit[1], overrides, seen) : entry.value;
|
|
26806
26857
|
}
|
|
26807
26858
|
function rootTokens(css) {
|
|
26808
26859
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -26881,7 +26932,7 @@ function kitFromDisk() {
|
|
|
26881
26932
|
}
|
|
26882
26933
|
function verify({ app: appRef, catalog, agent, describe: describe7, load }, { extractContract: extractContract2 = extract, kit } = {}) {
|
|
26883
26934
|
const KIT = kit ?? kitFromDisk();
|
|
26884
|
-
const app = loadApp(
|
|
26935
|
+
const app = loadApp(resolve8(appRef.dir));
|
|
26885
26936
|
let contract = null;
|
|
26886
26937
|
let contractError = null;
|
|
26887
26938
|
try {
|
|
@@ -26958,7 +27009,7 @@ function compareRules(a, b) {
|
|
|
26958
27009
|
return 0;
|
|
26959
27010
|
}
|
|
26960
27011
|
var SELF = fileURLToPath3(import.meta.url);
|
|
26961
|
-
if (SELF.endsWith("verify.mjs") && process.argv[1] &&
|
|
27012
|
+
if (SELF.endsWith("verify.mjs") && process.argv[1] && resolve8(process.argv[1]) === SELF) {
|
|
26962
27013
|
let raw = "";
|
|
26963
27014
|
process.stdin.setEncoding("utf8");
|
|
26964
27015
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
@@ -26976,16 +27027,16 @@ if (SELF.endsWith("verify.mjs") && process.argv[1] && resolve7(process.argv[1])
|
|
|
26976
27027
|
|
|
26977
27028
|
// ../flows/appspace-builder/kit/checks/verify.mjs
|
|
26978
27029
|
import { readFileSync as readFileSync5 } from "fs";
|
|
26979
|
-
import { dirname as dirname6, join as join14, resolve as
|
|
27030
|
+
import { dirname as dirname6, join as join14, resolve as resolve13 } from "path";
|
|
26980
27031
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
26981
27032
|
|
|
26982
27033
|
// ../flows/appspace-builder/kit/contract/extract.mjs
|
|
26983
|
-
import { resolve as
|
|
27034
|
+
import { resolve as resolve10 } from "path";
|
|
26984
27035
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
26985
27036
|
|
|
26986
27037
|
// ../flows/appspace-builder/kit/checks/lib/app.mjs
|
|
26987
27038
|
import { existsSync as existsSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
26988
|
-
import { join as join13, relative as relative2, resolve as
|
|
27039
|
+
import { join as join13, relative as relative2, resolve as resolve9, sep as sep3 } from "path";
|
|
26989
27040
|
var DATA_MODEL_PATH2 = "data_model.json";
|
|
26990
27041
|
var UI_PREFIX3 = "ui/";
|
|
26991
27042
|
var PAGE_PATH4 = /\.html?$/i;
|
|
@@ -27018,8 +27069,8 @@ function loadApp2(dir) {
|
|
|
27018
27069
|
}
|
|
27019
27070
|
function readHandlerSource2(dir, file) {
|
|
27020
27071
|
if (!file) return "";
|
|
27021
|
-
const root =
|
|
27022
|
-
const full =
|
|
27072
|
+
const root = resolve9(dir);
|
|
27073
|
+
const full = resolve9(root, file);
|
|
27023
27074
|
if (full !== root && !full.startsWith(root + sep3)) return "";
|
|
27024
27075
|
if (!existsSync2(full) || !statSync2(full).isFile()) return "";
|
|
27025
27076
|
return readFileSync4(full, "utf8");
|
|
@@ -27384,9 +27435,9 @@ function groupByObject2(text4, pairs) {
|
|
|
27384
27435
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
27385
27436
|
const pair = pairs.get(i);
|
|
27386
27437
|
if (pair !== void 0 && stack.length > 0) {
|
|
27387
|
-
const
|
|
27388
|
-
if (!byObject.has(
|
|
27389
|
-
byObject.get(
|
|
27438
|
+
const open3 = stack[stack.length - 1];
|
|
27439
|
+
if (!byObject.has(open3)) byObject.set(open3, []);
|
|
27440
|
+
byObject.get(open3).push(pair);
|
|
27390
27441
|
}
|
|
27391
27442
|
i = endOfString2(text4, i);
|
|
27392
27443
|
previous = '"';
|
|
@@ -28415,15 +28466,15 @@ function readPage2(app, page, spec, elements, problems) {
|
|
|
28415
28466
|
}
|
|
28416
28467
|
const bands = significant.filter((entry) => entry.type === "region" && entry.role === BAND_ROLE2);
|
|
28417
28468
|
const banded = bands.map((entry, index) => sectionOf2(entry.node, page.text, index));
|
|
28418
|
-
let
|
|
28469
|
+
let open3 = null;
|
|
28419
28470
|
let next = 0;
|
|
28420
28471
|
for (const entry of significant) {
|
|
28421
28472
|
if (next < bands.length && entry === bands[next]) {
|
|
28422
|
-
|
|
28473
|
+
open3 = banded[next].id;
|
|
28423
28474
|
next += 1;
|
|
28424
28475
|
continue;
|
|
28425
28476
|
}
|
|
28426
|
-
if (
|
|
28477
|
+
if (open3 !== null) elements[uids.get(entry.node.index)].section = open3;
|
|
28427
28478
|
}
|
|
28428
28479
|
const wrappers = tree.nodes.filter((node) => node.attrs[SECTION_ATTR2] !== void 0);
|
|
28429
28480
|
const wrapped = wrappers.map((node, index) => wrappedSectionOf2(tree, node, page.text, index));
|
|
@@ -29525,14 +29576,14 @@ function canonical4(value) {
|
|
|
29525
29576
|
return value;
|
|
29526
29577
|
}
|
|
29527
29578
|
var ENTRY2 = fileURLToPath4(import.meta.url);
|
|
29528
|
-
if (process.argv[1] &&
|
|
29579
|
+
if (process.argv[1] && resolve10(process.argv[1]) === ENTRY2 && ENTRY2.endsWith("extract.mjs")) {
|
|
29529
29580
|
let raw = "";
|
|
29530
29581
|
process.stdin.setEncoding("utf8");
|
|
29531
29582
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
29532
29583
|
process.stdin.on("end", () => {
|
|
29533
29584
|
try {
|
|
29534
29585
|
const input = JSON.parse(raw);
|
|
29535
|
-
const app = loadApp2(
|
|
29586
|
+
const app = loadApp2(resolve10(input.app.dir));
|
|
29536
29587
|
process.stdout.write(JSON.stringify(extract2(app, { describe: input.describe })));
|
|
29537
29588
|
} catch (e) {
|
|
29538
29589
|
process.stderr.write(`contract: ${e instanceof AppLoadError2 ? e.message : e.stack ?? e}
|
|
@@ -29583,7 +29634,7 @@ function check3(instance, node, at, root, problems, ctx) {
|
|
|
29583
29634
|
const start = problems.length;
|
|
29584
29635
|
const hint = describe4(node, ctx);
|
|
29585
29636
|
if (typeof node.$ref === "string") {
|
|
29586
|
-
const target =
|
|
29637
|
+
const target = resolve11(node.$ref, root);
|
|
29587
29638
|
if (target === null) {
|
|
29588
29639
|
problems.push(problem5(at, "the schema names a reference it cannot resolve"));
|
|
29589
29640
|
return;
|
|
@@ -29681,7 +29732,7 @@ function shapes3(branches, root) {
|
|
|
29681
29732
|
const named13 = branches.map((branch) => {
|
|
29682
29733
|
let node = branch;
|
|
29683
29734
|
for (let hops = 0; isObject6(node) && typeof node.$ref === "string" && hops < 8; hops += 1) {
|
|
29684
|
-
const target =
|
|
29735
|
+
const target = resolve11(node.$ref, root);
|
|
29685
29736
|
if (target === null) break;
|
|
29686
29737
|
node = target;
|
|
29687
29738
|
}
|
|
@@ -29743,7 +29794,7 @@ function same3(a, b) {
|
|
|
29743
29794
|
if (typeof a === "boolean" || typeof b === "boolean") return a === b;
|
|
29744
29795
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
29745
29796
|
}
|
|
29746
|
-
function
|
|
29797
|
+
function resolve11(ref, root) {
|
|
29747
29798
|
if (!ref.startsWith("#/")) return null;
|
|
29748
29799
|
let node = root;
|
|
29749
29800
|
for (const token of ref.slice(2).split("/")) {
|
|
@@ -29881,8 +29932,8 @@ function stringEnd2(text4, i) {
|
|
|
29881
29932
|
return Math.min(j + 1, text4.length);
|
|
29882
29933
|
}
|
|
29883
29934
|
function closeOf2(text4, i) {
|
|
29884
|
-
const
|
|
29885
|
-
const close = { "{": "}", "(": ")", "[": "]" }[
|
|
29935
|
+
const open3 = text4[i];
|
|
29936
|
+
const close = { "{": "}", "(": ")", "[": "]" }[open3];
|
|
29886
29937
|
let depth = 0;
|
|
29887
29938
|
for (let j = i; j < text4.length; j++) {
|
|
29888
29939
|
const ch = text4[j];
|
|
@@ -31349,10 +31400,10 @@ function railReachProblems2(contract) {
|
|
|
31349
31400
|
const pages = new Map((Array.isArray(contract?.pages) ? contract.pages : []).filter((page) => named10(page?.path)).map((page) => [page.path, page]));
|
|
31350
31401
|
const openers = (page) => Array.isArray(page?.roles) && page.roles.filter(named10).length > 0 ? page.roles.filter(named10) : null;
|
|
31351
31402
|
const canOpen = (name, page) => {
|
|
31352
|
-
const
|
|
31353
|
-
if (
|
|
31403
|
+
const open3 = openers(page);
|
|
31404
|
+
if (open3 === null) return true;
|
|
31354
31405
|
const role = declared.get(name);
|
|
31355
|
-
return
|
|
31406
|
+
return open3.includes(name) || (role?.sees ?? []).some((seen) => open3.includes(seen));
|
|
31356
31407
|
};
|
|
31357
31408
|
for (const key of ["entries", "footer"]) {
|
|
31358
31409
|
for (const [index, entry] of (Array.isArray(rail[key]) ? rail[key] : []).entries()) {
|
|
@@ -31638,7 +31689,7 @@ function checkTheme2(app) {
|
|
|
31638
31689
|
const overrides = rootTokens2(file.text);
|
|
31639
31690
|
if (overrides.size === 0) return { violations };
|
|
31640
31691
|
for (const theme of themesInUse2(app)) {
|
|
31641
|
-
const ground = rgbOf3(overrides.has("--dr-surface") ?
|
|
31692
|
+
const ground = rgbOf3(overrides.has("--dr-surface") ? resolve12("--dr-surface", overrides) : THEME_SURFACES2[theme]);
|
|
31642
31693
|
if (!ground) {
|
|
31643
31694
|
const surface = overrides.get("--dr-surface");
|
|
31644
31695
|
violations.push({
|
|
@@ -31651,7 +31702,7 @@ function checkTheme2(app) {
|
|
|
31651
31702
|
for (const [token, { line: line2 }] of overrides) {
|
|
31652
31703
|
const rule = FLOORS2.get(token);
|
|
31653
31704
|
if (!rule) continue;
|
|
31654
|
-
const value =
|
|
31705
|
+
const value = resolve12(token, overrides);
|
|
31655
31706
|
if (value === null) continue;
|
|
31656
31707
|
const series = /^--dr-chart-(\d+)$/.exec(token);
|
|
31657
31708
|
if (series && isPlatformChartColour2(Number(series[1]), value)) continue;
|
|
@@ -31699,12 +31750,12 @@ function themesInUse2(app) {
|
|
|
31699
31750
|
}
|
|
31700
31751
|
return found.size ? [...found].sort() : ["default"];
|
|
31701
31752
|
}
|
|
31702
|
-
function
|
|
31753
|
+
function resolve12(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
31703
31754
|
const entry = overrides.get(token);
|
|
31704
31755
|
if (!entry || seen.has(token)) return null;
|
|
31705
31756
|
seen.add(token);
|
|
31706
31757
|
const hit = /^var\(\s*(--[a-z0-9-]+)/.exec(entry.value);
|
|
31707
|
-
return hit ?
|
|
31758
|
+
return hit ? resolve12(hit[1], overrides, seen) : entry.value;
|
|
31708
31759
|
}
|
|
31709
31760
|
function rootTokens2(css) {
|
|
31710
31761
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -31890,6 +31941,9 @@ function checkPage3(app) {
|
|
|
31890
31941
|
|
|
31891
31942
|
// ../flows/appspace-builder/kit/checks/rules/singleton.mjs
|
|
31892
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");
|
|
31893
31947
|
function checkSingletons(app) {
|
|
31894
31948
|
const violations = [];
|
|
31895
31949
|
const tables = app.dataModel && typeof app.dataModel.tables === "object" && app.dataModel.tables !== null ? app.dataModel.tables : {};
|
|
@@ -31901,7 +31955,7 @@ function checkSingletons(app) {
|
|
|
31901
31955
|
violations.push({
|
|
31902
31956
|
rule: "A2.5",
|
|
31903
31957
|
where: `${reader.where}:${reader.line}`,
|
|
31904
|
-
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)`
|
|
31905
31959
|
});
|
|
31906
31960
|
}
|
|
31907
31961
|
}
|
|
@@ -31925,11 +31979,10 @@ function oneRowReader(handlers, table) {
|
|
|
31925
31979
|
const source = handler.source ?? "";
|
|
31926
31980
|
const literal = handlerLiteral(source);
|
|
31927
31981
|
const aliases = /* @__PURE__ */ new Map();
|
|
31928
|
-
for (const bound of source.matchAll(
|
|
31982
|
+
for (const bound of source.matchAll(BOUND_TABLE)) {
|
|
31929
31983
|
aliases.set(bound[1], bound[3] ?? literal.table);
|
|
31930
31984
|
}
|
|
31931
|
-
const
|
|
31932
|
-
for (const call of source.matchAll(calls)) {
|
|
31985
|
+
for (const call of source.matchAll(QUERY_CALL)) {
|
|
31933
31986
|
const receiver = call[3] !== void 0 ? aliases.get(call[3]) : call[2] ?? literal.table;
|
|
31934
31987
|
if (receiver !== table) continue;
|
|
31935
31988
|
const args = argumentsFrom(source, call.index + call[0].length);
|
|
@@ -31947,10 +32000,10 @@ function handlerLiteral(source) {
|
|
|
31947
32000
|
const limit = /["']limit["']\s*:\s*(\d+)/.exec(body)?.[1];
|
|
31948
32001
|
return { table, limit: limit === void 0 ? null : Number(limit) };
|
|
31949
32002
|
}
|
|
31950
|
-
function argumentsFrom(source, from,
|
|
32003
|
+
function argumentsFrom(source, from, open3 = "(", close = ")") {
|
|
31951
32004
|
let depth = 1;
|
|
31952
32005
|
for (let i = from; i < source.length; i++) {
|
|
31953
|
-
if (source[i] ===
|
|
32006
|
+
if (source[i] === open3) depth++;
|
|
31954
32007
|
else if (source[i] === close && --depth === 0) return source.slice(from, i);
|
|
31955
32008
|
}
|
|
31956
32009
|
return source.slice(from);
|
|
@@ -32161,8 +32214,8 @@ function navLinks2(html, { owned = false, from } = {}) {
|
|
|
32161
32214
|
const regions = [];
|
|
32162
32215
|
if (owned) regions.push(text4);
|
|
32163
32216
|
else {
|
|
32164
|
-
for (const
|
|
32165
|
-
const rest = text4.slice(
|
|
32217
|
+
for (const open3 of text4.matchAll(NAV_OPEN2)) {
|
|
32218
|
+
const rest = text4.slice(open3.index + open3[0].length);
|
|
32166
32219
|
const end = rest.search(NAV_CLOSE2);
|
|
32167
32220
|
regions.push(end === -1 ? rest : rest.slice(0, end));
|
|
32168
32221
|
}
|
|
@@ -32587,24 +32640,24 @@ function sourceRoles2(contract, name, known = /* @__PURE__ */ new Set()) {
|
|
|
32587
32640
|
const pages = new Map(pagesOf2(contract).map((page) => [page.path, page]));
|
|
32588
32641
|
const union = [];
|
|
32589
32642
|
let readers = 0;
|
|
32590
|
-
let
|
|
32643
|
+
let open3 = false;
|
|
32591
32644
|
for (const element of Object.values(elements)) {
|
|
32592
32645
|
const props = isPlainObject17(element?.props) ? element.props : {};
|
|
32593
32646
|
const reads = [props.source, ...Array.isArray(props.declares?.reads) ? props.declares.reads : []];
|
|
32594
32647
|
if (!reads.includes(name)) continue;
|
|
32595
32648
|
readers += 1;
|
|
32596
32649
|
const roles = pageRoles2(pages.get(element.page));
|
|
32597
|
-
if (roles.length === 0)
|
|
32650
|
+
if (roles.length === 0) open3 = true;
|
|
32598
32651
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
32599
32652
|
}
|
|
32600
32653
|
for (const page of pagesOf2(contract)) {
|
|
32601
32654
|
if (page.owned !== true || readers === 0 || known.has(page.path)) continue;
|
|
32602
32655
|
const roles = pageRoles2(page);
|
|
32603
|
-
if (roles.length === 0)
|
|
32656
|
+
if (roles.length === 0) open3 = true;
|
|
32604
32657
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
32605
32658
|
}
|
|
32606
32659
|
if (stated2.length > 0) return { roles: stated2, inherited: false, readers };
|
|
32607
|
-
if (readers === 0 ||
|
|
32660
|
+
if (readers === 0 || open3) return { roles: [], inherited: true, readers };
|
|
32608
32661
|
const order2 = roleModel2(contract).names;
|
|
32609
32662
|
return { roles: union.sort((a, b) => order2.indexOf(a) - order2.indexOf(b)), inherited: true, readers };
|
|
32610
32663
|
}
|
|
@@ -32681,7 +32734,7 @@ function kitFromDisk2() {
|
|
|
32681
32734
|
var ADVISORY = /* @__PURE__ */ new Set(["A4.1", "A4.2", "A4.3", "A4.4", "L6", "L7", "L8", "L9", "A1.5", "A1.6", "A2.5", "A2.6", "A3.15", "A3.17", "A3.19", "A3.20", "A3.21", "A3.22", "A3.23", "A3.24", "A3.25", "A3.26", "A3.27", "A3.28", "A3.29"]);
|
|
32682
32735
|
function verify2({ app: appRef }, { extractContract: extractContract2 = extract2, kit } = {}) {
|
|
32683
32736
|
const KIT = kit ?? kitFromDisk2();
|
|
32684
|
-
const app = loadApp2(
|
|
32737
|
+
const app = loadApp2(resolve13(appRef.dir));
|
|
32685
32738
|
let contract = null;
|
|
32686
32739
|
let contractError = null;
|
|
32687
32740
|
try {
|
|
@@ -32756,7 +32809,7 @@ function compareRules2(a, b) {
|
|
|
32756
32809
|
return 0;
|
|
32757
32810
|
}
|
|
32758
32811
|
var SELF2 = fileURLToPath5(import.meta.url);
|
|
32759
|
-
if (SELF2.endsWith("verify.mjs") && process.argv[1] &&
|
|
32812
|
+
if (SELF2.endsWith("verify.mjs") && process.argv[1] && resolve13(process.argv[1]) === SELF2) {
|
|
32760
32813
|
let raw = "";
|
|
32761
32814
|
process.stdin.setEncoding("utf8");
|
|
32762
32815
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
@@ -33113,14 +33166,14 @@ async function runCompile(dir, opts) {
|
|
|
33113
33166
|
const state = await readIfPresent(join15(dir, ".appspace.json"));
|
|
33114
33167
|
if (state !== void 0) await writeFile7(join15(target, ".appspace.json"), state);
|
|
33115
33168
|
} else {
|
|
33116
|
-
for (const path3 of plan.orphaned) await
|
|
33169
|
+
for (const path3 of plan.orphaned) await rm5(join15(dir, path3), { force: true });
|
|
33117
33170
|
report.files = plan.owned;
|
|
33118
33171
|
report.digests = Object.fromEntries(plan.owned.map((path3) => [path3, digestOf(built.files[path3] ?? "")]));
|
|
33119
33172
|
report.inputs = plan.inputs;
|
|
33120
33173
|
}
|
|
33121
33174
|
return await afterWrite(dir, target, kind, contract, built, report, kit, skipped, opts, metricsPlan);
|
|
33122
33175
|
} finally {
|
|
33123
|
-
if (check5) await
|
|
33176
|
+
if (check5) await rm5(target, { recursive: true, force: true });
|
|
33124
33177
|
}
|
|
33125
33178
|
}
|
|
33126
33179
|
async function afterWrite(dir, target, kind, contract, built, report, kit, skipped, opts, metricsPlan = null) {
|
|
@@ -33398,8 +33451,8 @@ function insideFolder(dir, key) {
|
|
|
33398
33451
|
if (key.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
33399
33452
|
return false;
|
|
33400
33453
|
}
|
|
33401
|
-
const root =
|
|
33402
|
-
return
|
|
33454
|
+
const root = resolve14(dir);
|
|
33455
|
+
return resolve14(root, key).startsWith(root + sep4);
|
|
33403
33456
|
}
|
|
33404
33457
|
var AUTHOR_FILES = /* @__PURE__ */ new Set(["seed.json", "tests.json"]);
|
|
33405
33458
|
async function writePlan(dir, kind, contract, files, paths, force) {
|
|
@@ -33877,7 +33930,7 @@ function nothingWritten(report) {
|
|
|
33877
33930
|
async function readNamed(path3) {
|
|
33878
33931
|
let raw;
|
|
33879
33932
|
try {
|
|
33880
|
-
raw = await
|
|
33933
|
+
raw = await readFile9(resolve14(path3), "utf8");
|
|
33881
33934
|
} catch (err) {
|
|
33882
33935
|
throw new Error(`cannot read ${path3} (${err instanceof Error ? err.message.split("\n")[0] : String(err)}).`);
|
|
33883
33936
|
}
|
|
@@ -33949,7 +34002,7 @@ async function compileFolder(dir, kind, contract, kit, overlay = {}) {
|
|
|
33949
34002
|
var COMPILED_PAGE = 'id="dr-contract"';
|
|
33950
34003
|
async function recordPulled(dir, contractWritten) {
|
|
33951
34004
|
const forget = async () => {
|
|
33952
|
-
await
|
|
34005
|
+
await rm5(reportPath(dir), { force: true });
|
|
33953
34006
|
return null;
|
|
33954
34007
|
};
|
|
33955
34008
|
if (!contractWritten) return forget();
|
|
@@ -34402,7 +34455,7 @@ async function runShipOntoLive(dir, opts) {
|
|
|
34402
34455
|
}
|
|
34403
34456
|
const catalogMemo = {};
|
|
34404
34457
|
return landWithRetries(async (createGuarded) => {
|
|
34405
|
-
for (const name of ONTO_LIVE_OWNED) await
|
|
34458
|
+
for (const name of ONTO_LIVE_OWNED) await rm5(join15(dir, name), { recursive: true, force: true });
|
|
34406
34459
|
const client = await connect(opts);
|
|
34407
34460
|
let pulled;
|
|
34408
34461
|
try {
|
|
@@ -34484,7 +34537,7 @@ async function claimFolder(dir) {
|
|
|
34484
34537
|
}
|
|
34485
34538
|
async function lostRaceOf(dir) {
|
|
34486
34539
|
try {
|
|
34487
|
-
const report = JSON.parse(await
|
|
34540
|
+
const report = JSON.parse(await readFile9(reportPath(dir), "utf8"));
|
|
34488
34541
|
if (report.failure === "concurrent-publish") return { race: "publish", current: null };
|
|
34489
34542
|
if (report.failure === "stale-revision") return { race: "stale", current: report.stale?.current ?? null };
|
|
34490
34543
|
return null;
|
|
@@ -34575,10 +34628,10 @@ var EJECTED_DOCSTRING = 'Ejected with app-space eject: this file is yours now, a
|
|
|
34575
34628
|
function authorsDocstring(body) {
|
|
34576
34629
|
return body.replace(/Generated by [^\n]*compile[\s\S]*?not this file\./, EJECTED_DOCSTRING);
|
|
34577
34630
|
}
|
|
34578
|
-
function literalEnd2(text4,
|
|
34631
|
+
function literalEnd2(text4, open3) {
|
|
34579
34632
|
let depth = 0;
|
|
34580
34633
|
let quote = null;
|
|
34581
|
-
for (let i =
|
|
34634
|
+
for (let i = open3; i < text4.length; i++) {
|
|
34582
34635
|
const c = text4[i];
|
|
34583
34636
|
if (quote !== null) {
|
|
34584
34637
|
if (c === "\\") i++;
|
|
@@ -34969,8 +35022,8 @@ function registerLogsCommand(parent) {
|
|
|
34969
35022
|
}
|
|
34970
35023
|
|
|
34971
35024
|
// src/commands/appspace/migrate.ts
|
|
34972
|
-
import { constants } from "fs";
|
|
34973
|
-
import { access, lstat as lstat2, readFile as
|
|
35025
|
+
import { constants as constants2 } from "fs";
|
|
35026
|
+
import { access, lstat as lstat2, readFile as readFile10, realpath, rename as rename2, rm as rm6, writeFile as writeFile9 } from "fs/promises";
|
|
34974
35027
|
import { basename as basename2, dirname as dirname9, join as join17, sep as sep5 } from "path";
|
|
34975
35028
|
var MIGRATE_ROUTE = "/apps/migrate-preview";
|
|
34976
35029
|
var RUNTIMES_NOW = [1];
|
|
@@ -35173,12 +35226,12 @@ function valueEnd(text4, i) {
|
|
|
35173
35226
|
if (n === i) throw new NotJson();
|
|
35174
35227
|
return n;
|
|
35175
35228
|
}
|
|
35176
|
-
function containerOf(text4,
|
|
35177
|
-
const object = text4[
|
|
35229
|
+
function containerOf(text4, open3) {
|
|
35230
|
+
const object = text4[open3] === "{";
|
|
35178
35231
|
const closer = object ? "}" : "]";
|
|
35179
35232
|
const members = [];
|
|
35180
|
-
let i = skipSpace(text4,
|
|
35181
|
-
if (text4[i] === closer) return { open:
|
|
35233
|
+
let i = skipSpace(text4, open3 + 1);
|
|
35234
|
+
if (text4[i] === closer) return { open: open3, close: i, members };
|
|
35182
35235
|
for (; ; ) {
|
|
35183
35236
|
let key = null;
|
|
35184
35237
|
const start = i;
|
|
@@ -35197,7 +35250,7 @@ function containerOf(text4, open2) {
|
|
|
35197
35250
|
i = skipSpace(text4, i + 1);
|
|
35198
35251
|
continue;
|
|
35199
35252
|
}
|
|
35200
|
-
if (text4[i] === closer) return { open:
|
|
35253
|
+
if (text4[i] === closer) return { open: open3, close: i, members };
|
|
35201
35254
|
throw new NotJson();
|
|
35202
35255
|
}
|
|
35203
35256
|
}
|
|
@@ -35359,7 +35412,7 @@ async function runMigrate(dir, opts) {
|
|
|
35359
35412
|
const { manifest } = await readManifest(dir).catch((err) => {
|
|
35360
35413
|
throw new MigrateRefused(err instanceof Error ? err.message : String(err));
|
|
35361
35414
|
});
|
|
35362
|
-
const manifestSent = await
|
|
35415
|
+
const manifestSent = await readFile10(join17(dir, "manifest.json"), "utf8");
|
|
35363
35416
|
if (canonical5(JSON.parse(manifestSent)) !== canonical5(manifest)) {
|
|
35364
35417
|
throw new MigrateRefused("manifest.json changed while migrate read it. Run migrate again.");
|
|
35365
35418
|
}
|
|
@@ -35391,7 +35444,7 @@ async function runMigrate(dir, opts) {
|
|
|
35391
35444
|
return 0;
|
|
35392
35445
|
}
|
|
35393
35446
|
const files = applyDiff(preview.diff, sent);
|
|
35394
|
-
const manifestNow = await
|
|
35447
|
+
const manifestNow = await readFile10(join17(dir, "manifest.json"), "utf8");
|
|
35395
35448
|
if (manifestNow !== manifestSent) {
|
|
35396
35449
|
throw new MigrateRefused("manifest.json changed since migrate read it. Run migrate again.");
|
|
35397
35450
|
}
|
|
@@ -35498,7 +35551,7 @@ ${written.map((p) => ` ${p}
|
|
|
35498
35551
|
return 1;
|
|
35499
35552
|
}
|
|
35500
35553
|
}
|
|
35501
|
-
var _io = { rename: rename2, writeFile: writeFile9, realpath, rm:
|
|
35554
|
+
var _io = { rename: rename2, writeFile: writeFile9, realpath, rm: rm6 };
|
|
35502
35555
|
async function writable(dir, path3, sent) {
|
|
35503
35556
|
const full = join17(dir, path3);
|
|
35504
35557
|
const parts = path3.split("/");
|
|
@@ -35529,12 +35582,12 @@ async function writable(dir, path3, sent) {
|
|
|
35529
35582
|
throw new MigrateRefused(`${path3} is not a regular file (a link, or another kind); migrate writes only regular files.`);
|
|
35530
35583
|
}
|
|
35531
35584
|
try {
|
|
35532
|
-
await access(full,
|
|
35533
|
-
await access(dirname9(full),
|
|
35585
|
+
await access(full, constants2.W_OK);
|
|
35586
|
+
await access(dirname9(full), constants2.W_OK);
|
|
35534
35587
|
} catch {
|
|
35535
35588
|
throw new MigrateRefused(`${path3} cannot be written (no permission).`);
|
|
35536
35589
|
}
|
|
35537
|
-
const bytes = await
|
|
35590
|
+
const bytes = await readFile10(full);
|
|
35538
35591
|
const text4 = bytes.toString("utf8");
|
|
35539
35592
|
if (!Buffer.from(text4, "utf8").equals(bytes)) {
|
|
35540
35593
|
throw new MigrateRefused(`${path3} is not valid UTF-8; migrate would change bytes it did not mean to.`);
|
|
@@ -35619,12 +35672,12 @@ function registerMigrateCommand(parent) {
|
|
|
35619
35672
|
}
|
|
35620
35673
|
|
|
35621
35674
|
// src/commands/appspace/test.ts
|
|
35622
|
-
import { readFile as
|
|
35623
|
-
import { join as join19, resolve as
|
|
35675
|
+
import { readFile as readFile13 } from "fs/promises";
|
|
35676
|
+
import { join as join19, resolve as resolve17 } from "path";
|
|
35624
35677
|
|
|
35625
35678
|
// src/commands/appspace/_files.ts
|
|
35626
|
-
import { readFile as
|
|
35627
|
-
import { basename as basename3, extname, resolve as
|
|
35679
|
+
import { readFile as readFile11, realpath as realpath2 } from "fs/promises";
|
|
35680
|
+
import { basename as basename3, extname, resolve as resolve15, sep as sep6 } from "path";
|
|
35628
35681
|
|
|
35629
35682
|
// src/commands/appspace/_samplePdf.ts
|
|
35630
35683
|
function pdfString(text4) {
|
|
@@ -35781,11 +35834,11 @@ function readFailure(path3, full, err) {
|
|
|
35781
35834
|
if (code === void 0 || code === "ENOENT") return new Error(`no file at ${path3} (looked for ${full}).`);
|
|
35782
35835
|
return new Error(`could not read ${path3} (${String(code)}).`);
|
|
35783
35836
|
}
|
|
35784
|
-
async function resolveFile(path3, base, { read =
|
|
35837
|
+
async function resolveFile(path3, base, { read = readFile11, confine = false, realpath: real = realpath2 } = {}) {
|
|
35785
35838
|
if (path3 === null) {
|
|
35786
35839
|
return { bytes: sampleInvoiceBytes(), filename: SAMPLE_INVOICE.filename, mimeType: SAMPLE_INVOICE.mimeType };
|
|
35787
35840
|
}
|
|
35788
|
-
const full =
|
|
35841
|
+
const full = resolve15(base, path3);
|
|
35789
35842
|
if (confine) {
|
|
35790
35843
|
let target;
|
|
35791
35844
|
let root;
|
|
@@ -35827,7 +35880,7 @@ function fileColumnsOf(model) {
|
|
|
35827
35880
|
}
|
|
35828
35881
|
async function readFileColumns(dir) {
|
|
35829
35882
|
try {
|
|
35830
|
-
return fileColumnsOf(JSON.parse(await
|
|
35883
|
+
return fileColumnsOf(JSON.parse(await readFile11(resolve15(dir, "data_model.json"), "utf8")));
|
|
35831
35884
|
} catch {
|
|
35832
35885
|
return null;
|
|
35833
35886
|
}
|
|
@@ -37126,13 +37179,13 @@ var defaultBlobReader = async (blob) => {
|
|
|
37126
37179
|
function blobReaderFor(window) {
|
|
37127
37180
|
const ctor = window?.FileReader;
|
|
37128
37181
|
if (typeof ctor !== "function") return defaultBlobReader;
|
|
37129
|
-
return (blob) => new Promise((
|
|
37182
|
+
return (blob) => new Promise((resolve18, reject) => {
|
|
37130
37183
|
const reader = new ctor();
|
|
37131
37184
|
reader.onload = () => {
|
|
37132
37185
|
const result = reader.result;
|
|
37133
|
-
if (result === null || result === void 0)
|
|
37134
|
-
else if (typeof result === "string")
|
|
37135
|
-
else
|
|
37186
|
+
if (result === null || result === void 0) resolve18(Buffer.alloc(0));
|
|
37187
|
+
else if (typeof result === "string") resolve18(Buffer.from(result, "utf8"));
|
|
37188
|
+
else resolve18(Buffer.from(result));
|
|
37136
37189
|
};
|
|
37137
37190
|
reader.onerror = () => reject(new Error("the attached file could not be read"));
|
|
37138
37191
|
reader.onabort = () => reject(new Error("reading the attached file was aborted"));
|
|
@@ -37419,7 +37472,7 @@ async function loadJsdom() {
|
|
|
37419
37472
|
);
|
|
37420
37473
|
}
|
|
37421
37474
|
}
|
|
37422
|
-
var sleep = (ms) => new Promise((
|
|
37475
|
+
var sleep = (ms) => new Promise((resolve18) => setTimeout(resolve18, ms));
|
|
37423
37476
|
var DRAW_GRACE_MS = 3e3;
|
|
37424
37477
|
async function runUiSmoke(opts) {
|
|
37425
37478
|
const timeoutMs = opts.timeoutMs ?? 15e3;
|
|
@@ -37925,10 +37978,10 @@ async function runUiSmoke(opts) {
|
|
|
37925
37978
|
// src/commands/appspace/_screenshot.ts
|
|
37926
37979
|
import { spawn } from "child_process";
|
|
37927
37980
|
import { existsSync as existsSync3, statSync as statSync3 } from "fs";
|
|
37928
|
-
import { mkdir as mkdir8, mkdtemp as mkdtemp4, readFile as
|
|
37981
|
+
import { mkdir as mkdir8, mkdtemp as mkdtemp4, readFile as readFile12, readdir as readdir4, rm as rm7, stat as stat2, writeFile as writeFile10 } from "fs/promises";
|
|
37929
37982
|
import { createServer } from "http";
|
|
37930
37983
|
import { tmpdir as tmpdir5 } from "os";
|
|
37931
|
-
import { delimiter, extname as extname2, join as join18, relative as relative3, resolve as
|
|
37984
|
+
import { delimiter, extname as extname2, join as join18, relative as relative3, resolve as resolve16, sep as sep7 } from "path";
|
|
37932
37985
|
|
|
37933
37986
|
// ../tests/vendor/fixtures/widgets/kpi.json
|
|
37934
37987
|
var kpi_default = {
|
|
@@ -39120,8 +39173,8 @@ function contentType(path3) {
|
|
|
39120
39173
|
return TYPES[extname2(path3).toLowerCase()] ?? "application/octet-stream";
|
|
39121
39174
|
}
|
|
39122
39175
|
function inside(root, rel) {
|
|
39123
|
-
const base =
|
|
39124
|
-
const full =
|
|
39176
|
+
const base = resolve16(root);
|
|
39177
|
+
const full = resolve16(base, rel);
|
|
39125
39178
|
return full === base || !full.startsWith(base + sep7) ? null : full;
|
|
39126
39179
|
}
|
|
39127
39180
|
var Shelf = class {
|
|
@@ -39166,7 +39219,7 @@ var Shelf = class {
|
|
|
39166
39219
|
const full = inside(this.source.root, rel);
|
|
39167
39220
|
if (full === null) continue;
|
|
39168
39221
|
try {
|
|
39169
|
-
return { status: 200, type: contentType(full), body: await
|
|
39222
|
+
return { status: 200, type: contentType(full), body: await readFile12(full) };
|
|
39170
39223
|
} catch {
|
|
39171
39224
|
}
|
|
39172
39225
|
}
|
|
@@ -39436,7 +39489,7 @@ async function runChrome(run) {
|
|
|
39436
39489
|
}
|
|
39437
39490
|
} finally {
|
|
39438
39491
|
killGroup(child);
|
|
39439
|
-
await
|
|
39492
|
+
await rm7(profile, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }).catch(() => void 0);
|
|
39440
39493
|
}
|
|
39441
39494
|
if (ok) return { ok, stdout, profile };
|
|
39442
39495
|
const error = spawnError ?? (Date.now() >= deadline ? `timed out after ${String(Math.round(run.timeoutMs / 1e3))}s` : run.out === void 0 ? "Chrome printed no DOM" : "Chrome exited without writing the screenshot");
|
|
@@ -39559,7 +39612,7 @@ async function runScreenshots(opts) {
|
|
|
39559
39612
|
for (let attempt = 0; attempt < 2 && now() < pageUntil - 500; attempt++) {
|
|
39560
39613
|
id = nextId++;
|
|
39561
39614
|
stub.register(id, { role });
|
|
39562
|
-
await
|
|
39615
|
+
await rm7(out, { force: true });
|
|
39563
39616
|
result = await runChrome({
|
|
39564
39617
|
chrome: opts.chrome,
|
|
39565
39618
|
url: stub.urlFor(id, entry),
|
|
@@ -39588,7 +39641,7 @@ async function runScreenshots(opts) {
|
|
|
39588
39641
|
shots[index2] = { ...entryOut, error: result.error ?? "no picture" };
|
|
39589
39642
|
return;
|
|
39590
39643
|
}
|
|
39591
|
-
const bytes = await
|
|
39644
|
+
const bytes = await readFile12(out);
|
|
39592
39645
|
if (look && seen === void 0) toLook.push(index2);
|
|
39593
39646
|
shots[index2] = {
|
|
39594
39647
|
...entryOut,
|
|
@@ -39648,7 +39701,7 @@ async function readLocalUi(dir) {
|
|
|
39648
39701
|
for (const one of names) {
|
|
39649
39702
|
const full = join18(folder, one.name);
|
|
39650
39703
|
if (one.isDirectory()) await walk5(full);
|
|
39651
|
-
else if (one.isFile()) out[relative3(root, full).split(sep7).join("/")] = await
|
|
39704
|
+
else if (one.isFile()) out[relative3(root, full).split(sep7).join("/")] = await readFile12(full);
|
|
39652
39705
|
}
|
|
39653
39706
|
};
|
|
39654
39707
|
await walk5(root);
|
|
@@ -41188,13 +41241,13 @@ function roleFindings(contract, held) {
|
|
|
41188
41241
|
};
|
|
41189
41242
|
const visible = /* @__PURE__ */ new Set([held.own, ...held.sees]);
|
|
41190
41243
|
let mine = 0;
|
|
41191
|
-
let
|
|
41244
|
+
let open3 = 0;
|
|
41192
41245
|
const others = [];
|
|
41193
41246
|
let gatedElsewhere = 0;
|
|
41194
41247
|
for (const [uid, element] of Object.entries(elements)) {
|
|
41195
41248
|
if (typeof element.type !== "string" || !COMPONENT_TYPES7.has(element.type)) continue;
|
|
41196
41249
|
const gate = gateOf(uid);
|
|
41197
|
-
if (gate === null)
|
|
41250
|
+
if (gate === null) open3 += 1;
|
|
41198
41251
|
else if (visible.has(gate)) mine += 1;
|
|
41199
41252
|
else {
|
|
41200
41253
|
gatedElsewhere += 1;
|
|
@@ -41208,7 +41261,7 @@ function roleFindings(contract, held) {
|
|
|
41208
41261
|
{
|
|
41209
41262
|
code: "role-sees-nothing",
|
|
41210
41263
|
where: "backend.roles",
|
|
41211
|
-
message: `you hold ${own2} \u2014 the app's creator holds the last role declared \u2014 and every one of the ${String(gatedElsewhere)} role-gated components is for ${whose}, so opening the app you see none of them (only the ${String(
|
|
41264
|
+
message: `you hold ${own2} \u2014 the app's creator holds the last role declared \u2014 and every one of the ${String(gatedElsewhere)} role-gated components is for ${whose}, so opening the app you see none of them (only the ${String(open3)} ungated)`,
|
|
41212
41265
|
fix: `Declare backend.roles least senior first, the default first and the role these screens are for last, so the creator holds it; if ${own2} really is the most senior, gate those components to it too, or add ${whose} to its sees and to the requiresRole of their handlers.`,
|
|
41213
41266
|
see: SEE.roles
|
|
41214
41267
|
}
|
|
@@ -41366,7 +41419,7 @@ function collectRoles(value, previous = []) {
|
|
|
41366
41419
|
}
|
|
41367
41420
|
async function readLocalManifest(dir) {
|
|
41368
41421
|
try {
|
|
41369
|
-
return JSON.parse(await
|
|
41422
|
+
return JSON.parse(await readFile13(join19(dir, "manifest.json"), "utf8"));
|
|
41370
41423
|
} catch {
|
|
41371
41424
|
return null;
|
|
41372
41425
|
}
|
|
@@ -41509,7 +41562,7 @@ async function loadFixtures(dir, explicit) {
|
|
|
41509
41562
|
const path3 = explicit ?? join19(dir, DEFAULT_FIXTURES);
|
|
41510
41563
|
let raw;
|
|
41511
41564
|
try {
|
|
41512
|
-
raw = await
|
|
41565
|
+
raw = await readFile13(path3, "utf8");
|
|
41513
41566
|
} catch {
|
|
41514
41567
|
if (explicit !== void 0) throw new Error(`no fixtures file at ${path3}.`);
|
|
41515
41568
|
return { fixtures: { cases: [], ui: { entry: "index.html" } } };
|
|
@@ -41531,7 +41584,7 @@ async function runHandlerCases(cases, dir, appId, client, roleOf = () => void 0)
|
|
|
41531
41584
|
if (!code.has(kase.handler)) {
|
|
41532
41585
|
code.set(
|
|
41533
41586
|
kase.handler,
|
|
41534
|
-
await
|
|
41587
|
+
await readFile13(join19(dir, "handlers", `${kase.handler}.py`), "utf8").catch(() => null)
|
|
41535
41588
|
);
|
|
41536
41589
|
}
|
|
41537
41590
|
const source = code.get(kase.handler);
|
|
@@ -41786,7 +41839,7 @@ function contractUid(contract, page, component) {
|
|
|
41786
41839
|
}
|
|
41787
41840
|
async function isDashboardFolder2(dir) {
|
|
41788
41841
|
try {
|
|
41789
|
-
const doc = JSON.parse(await
|
|
41842
|
+
const doc = JSON.parse(await readFile13(join19(dir, "contract.json"), "utf8"));
|
|
41790
41843
|
return doc.app?.kind === "dashboard";
|
|
41791
41844
|
} catch {
|
|
41792
41845
|
return false;
|
|
@@ -41987,7 +42040,7 @@ function mergeDomComponents(contract, components, page) {
|
|
|
41987
42040
|
async function writeMergedContract(dir, page, components) {
|
|
41988
42041
|
let contract;
|
|
41989
42042
|
try {
|
|
41990
|
-
contract = JSON.parse(await
|
|
42043
|
+
contract = JSON.parse(await readFile13(contractPath(dir), "utf8"));
|
|
41991
42044
|
} catch {
|
|
41992
42045
|
contract = await extractContract(dir);
|
|
41993
42046
|
}
|
|
@@ -41997,7 +42050,7 @@ async function writeMergedContract(dir, page, components) {
|
|
|
41997
42050
|
async function uiIsStale(dir, entry, stored) {
|
|
41998
42051
|
if (stored === void 0) return false;
|
|
41999
42052
|
try {
|
|
42000
|
-
const local = await
|
|
42053
|
+
const local = await readFile13(join19(dir, "ui", entry));
|
|
42001
42054
|
return !local.equals(Buffer.from(stored, "utf8"));
|
|
42002
42055
|
} catch {
|
|
42003
42056
|
return false;
|
|
@@ -42085,7 +42138,7 @@ function untouchedHandlers(declared, cases, interactions, runs = []) {
|
|
|
42085
42138
|
async function readSeed(dir) {
|
|
42086
42139
|
let parsed2;
|
|
42087
42140
|
try {
|
|
42088
|
-
parsed2 = JSON.parse(await
|
|
42141
|
+
parsed2 = JSON.parse(await readFile13(join19(dir, "seed.json"), "utf8"));
|
|
42089
42142
|
} catch {
|
|
42090
42143
|
return null;
|
|
42091
42144
|
}
|
|
@@ -42101,7 +42154,7 @@ async function readSeed(dir) {
|
|
|
42101
42154
|
}
|
|
42102
42155
|
async function handlerOwnership(dir, pushed) {
|
|
42103
42156
|
try {
|
|
42104
|
-
const local = JSON.parse(await
|
|
42157
|
+
const local = JSON.parse(await readFile13(join19(dir, "contract.json"), "utf8"));
|
|
42105
42158
|
const owned = ownershipOf(local);
|
|
42106
42159
|
if (owned !== null) return owned;
|
|
42107
42160
|
} catch {
|
|
@@ -42429,7 +42482,7 @@ function registerTestCommand(parent) {
|
|
|
42429
42482
|
const files = pushedPages ? store.bundle : await readLocalUi(dir);
|
|
42430
42483
|
const pages = pushedPages ? store.pages : orderPages(Object.keys(files));
|
|
42431
42484
|
const manifest = pushedPages && typeof store.manifest === "object" && store.manifest !== null ? store.manifest : await readLocalManifest(dir);
|
|
42432
|
-
const outDir =
|
|
42485
|
+
const outDir = resolve17(opts.out ?? join19(dir, ".screenshots"));
|
|
42433
42486
|
const index = await runScreenshots({
|
|
42434
42487
|
appId,
|
|
42435
42488
|
pages: choosePages(opts.pages, pages, fixtures.ui.entry).load,
|
|
@@ -42440,7 +42493,7 @@ function registerTestCommand(parent) {
|
|
|
42440
42493
|
allowedByRole: view.allowed,
|
|
42441
42494
|
sources: Object.keys(pushed?.data?.sources ?? {}),
|
|
42442
42495
|
cases: fixtures.cases,
|
|
42443
|
-
shelf: opts.shelf === void 0 ? { kind: "server", baseUrl: client.baseUrl } : { kind: "local", root:
|
|
42496
|
+
shelf: opts.shelf === void 0 ? { kind: "server", baseUrl: client.baseUrl } : { kind: "local", root: resolve17(opts.shelf) },
|
|
42444
42497
|
chrome,
|
|
42445
42498
|
outDir,
|
|
42446
42499
|
width: shotSize.width,
|
|
@@ -42548,12 +42601,12 @@ ${String(failed)} failure(s).
|
|
|
42548
42601
|
}
|
|
42549
42602
|
|
|
42550
42603
|
// src/commands/appspace/try.ts
|
|
42551
|
-
import { readFile as
|
|
42604
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
42552
42605
|
import { join as join20 } from "path";
|
|
42553
42606
|
function collect2(value, previous = []) {
|
|
42554
42607
|
return [...previous, value];
|
|
42555
42608
|
}
|
|
42556
|
-
async function readPayloadOption(raw, read = (path3) =>
|
|
42609
|
+
async function readPayloadOption(raw, read = (path3) => readFile14(path3, "utf8")) {
|
|
42557
42610
|
if (raw.startsWith("@")) {
|
|
42558
42611
|
const path3 = raw.slice(1);
|
|
42559
42612
|
if (path3 === "") throw new Error("--payload @ names no file; write --payload @./payload.json.");
|
|
@@ -42633,7 +42686,7 @@ function registerTryCommand(parent) {
|
|
|
42633
42686
|
).action(async (handler, opts) => {
|
|
42634
42687
|
requirePlainName("handler", handler, "read");
|
|
42635
42688
|
const appId = await readManifestId(opts.dir);
|
|
42636
|
-
const code = await
|
|
42689
|
+
const code = await readFile14(
|
|
42637
42690
|
join20(opts.dir, "handlers", `${handler}.py`),
|
|
42638
42691
|
"utf8"
|
|
42639
42692
|
).catch(() => {
|
|
@@ -43192,7 +43245,7 @@ ${METRIC_ADVICE}
|
|
|
43192
43245
|
// src/commands/appspace/secrets.ts
|
|
43193
43246
|
var SECRET_NAME_RE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
43194
43247
|
function promptHidden(label, input, output) {
|
|
43195
|
-
return new Promise((
|
|
43248
|
+
return new Promise((resolve18, reject) => {
|
|
43196
43249
|
let value = "";
|
|
43197
43250
|
output.write(label);
|
|
43198
43251
|
input.setRawMode?.(true);
|
|
@@ -43204,7 +43257,7 @@ function promptHidden(label, input, output) {
|
|
|
43204
43257
|
input.pause();
|
|
43205
43258
|
output.write("\n");
|
|
43206
43259
|
if (err !== null) reject(err);
|
|
43207
|
-
else
|
|
43260
|
+
else resolve18(value);
|
|
43208
43261
|
};
|
|
43209
43262
|
const onData = (chunk) => {
|
|
43210
43263
|
for (const ch of String(chunk)) {
|
|
@@ -43414,7 +43467,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
43414
43467
|
var REGISTRY = "https://datarails.jfrog.io/artifactory/api/npm/dr-cli-virtual";
|
|
43415
43468
|
var PACKAGE = "@datarails-ai/dr-appspace-cli";
|
|
43416
43469
|
function spawnInherit(command, args) {
|
|
43417
|
-
return new Promise((
|
|
43470
|
+
return new Promise((resolve18) => {
|
|
43418
43471
|
const child = spawn2(command, args, {
|
|
43419
43472
|
stdio: "inherit",
|
|
43420
43473
|
// Windows resolves `npm` as `npm.cmd`; `shell: true` lets cmd.exe do
|
|
@@ -43422,15 +43475,15 @@ function spawnInherit(command, args) {
|
|
|
43422
43475
|
shell: true
|
|
43423
43476
|
});
|
|
43424
43477
|
child.on("close", (code) => {
|
|
43425
|
-
|
|
43478
|
+
resolve18(code ?? 1);
|
|
43426
43479
|
});
|
|
43427
43480
|
child.on("error", () => {
|
|
43428
|
-
|
|
43481
|
+
resolve18(1);
|
|
43429
43482
|
});
|
|
43430
43483
|
});
|
|
43431
43484
|
}
|
|
43432
43485
|
function captureVersion() {
|
|
43433
|
-
return new Promise((
|
|
43486
|
+
return new Promise((resolve18) => {
|
|
43434
43487
|
const child = spawn2("dr-appspace", ["--version"], { shell: true });
|
|
43435
43488
|
let out = "";
|
|
43436
43489
|
child.stdout.on("data", (chunk) => {
|
|
@@ -43438,12 +43491,12 @@ function captureVersion() {
|
|
|
43438
43491
|
});
|
|
43439
43492
|
child.on("close", (code) => {
|
|
43440
43493
|
if (code !== 0) {
|
|
43441
|
-
|
|
43494
|
+
resolve18(null);
|
|
43442
43495
|
return;
|
|
43443
43496
|
}
|
|
43444
|
-
|
|
43497
|
+
resolve18(out.trim());
|
|
43445
43498
|
});
|
|
43446
|
-
child.on("error", () =>
|
|
43499
|
+
child.on("error", () => resolve18(null));
|
|
43447
43500
|
});
|
|
43448
43501
|
}
|
|
43449
43502
|
async function runUpdate() {
|