@datarails-ai/dr-appspace-cli 0.12.78 → 0.12.79
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 +411 -366
- 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.79",
|
|
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-10T15:24:10.013Z";
|
|
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>");
|
|
@@ -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) {
|
|
@@ -17495,7 +17540,7 @@ function measuredSummary(row) {
|
|
|
17495
17540
|
];
|
|
17496
17541
|
}
|
|
17497
17542
|
const body = ["def handle(ctx, payload):", " del payload", ' table = ctx.data.table(HANDLER["table"])', " answer = {}", ...loop, " return answer"].join("\n");
|
|
17498
|
-
const
|
|
17543
|
+
const constants3 = [assignment("MEASURES", measures, Object.keys(measures))];
|
|
17499
17544
|
if (kinds.length === 0) {
|
|
17500
17545
|
return {
|
|
17501
17546
|
docstring: `Answer each tile on the page with a count of the events of ${row.table}.
|
|
@@ -17507,7 +17552,7 @@ wrote it \u2014 so none counts an event of a row this caller may not see.
|
|
|
17507
17552
|
|
|
17508
17553
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17509
17554
|
contract, not this file.`,
|
|
17510
|
-
constants:
|
|
17555
|
+
constants: constants3,
|
|
17511
17556
|
body
|
|
17512
17557
|
};
|
|
17513
17558
|
}
|
|
@@ -17521,7 +17566,7 @@ may not see. \`$today\` and its siblings are UTC. An average over no rows is
|
|
|
17521
17566
|
None, which a stat shows as a dash.
|
|
17522
17567
|
|
|
17523
17568
|
` + (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:
|
|
17569
|
+
constants: constants3,
|
|
17525
17570
|
body
|
|
17526
17571
|
};
|
|
17527
17572
|
}
|
|
@@ -17690,8 +17735,8 @@ function notOwnLines(row, id, verb, indent2) {
|
|
|
17690
17735
|
function singletonSave(row, table) {
|
|
17691
17736
|
const enums = enumsOf(row, table);
|
|
17692
17737
|
const refs = refsOf(row, table);
|
|
17693
|
-
const
|
|
17694
|
-
if (Object.keys(refs).length > 0)
|
|
17738
|
+
const constants3 = Object.keys(enums).length > 0 ? [assignment("ENUMS", enums, Object.keys(enums))] : [];
|
|
17739
|
+
if (Object.keys(refs).length > 0) constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
17695
17740
|
return {
|
|
17696
17741
|
docstring: `Save the ${singular(row.table)}: the table holds one row, so there is no id to send.
|
|
17697
17742
|
|
|
@@ -17703,7 +17748,7 @@ rather than written.
|
|
|
17703
17748
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17704
17749
|
contract, not this file.`,
|
|
17705
17750
|
imports: Object.keys(refs).length > 0 ? ["import uuid"] : [],
|
|
17706
|
-
constants:
|
|
17751
|
+
constants: constants3,
|
|
17707
17752
|
body: [
|
|
17708
17753
|
"def handle(ctx, payload):",
|
|
17709
17754
|
...collectRow(row, enums),
|
|
@@ -17983,8 +18028,8 @@ contract, not this file.`,
|
|
|
17983
18028
|
const enums = enumsOf(row, table);
|
|
17984
18029
|
const refs = refsOf(row, table);
|
|
17985
18030
|
const guarded = named5(row.guard);
|
|
17986
|
-
const
|
|
17987
|
-
if (Object.keys(refs).length > 0)
|
|
18031
|
+
const constants3 = Object.keys(enums).length > 0 ? [assignment("ENUMS", enums, Object.keys(enums))] : [];
|
|
18032
|
+
if (Object.keys(refs).length > 0) constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
17988
18033
|
const guardDoc = guarded ? `
|
|
17989
18034
|
|
|
17990
18035
|
\`guard\` holds an edit to one state: only a row that is still ${row.guard} may be
|
|
@@ -18001,7 +18046,7 @@ is a column anyone may set.${guardDoc}
|
|
|
18001
18046
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
18002
18047
|
contract, not this file.`,
|
|
18003
18048
|
imports: Object.keys(refs).length > 0 || guarded ? ["import uuid"] : [],
|
|
18004
|
-
constants:
|
|
18049
|
+
constants: constants3,
|
|
18005
18050
|
body: [
|
|
18006
18051
|
"def handle(ctx, payload):",
|
|
18007
18052
|
...collectRow(row, enums),
|
|
@@ -18040,9 +18085,9 @@ contract, not this file.`,
|
|
|
18040
18085
|
submit: (name, row, table, model) => {
|
|
18041
18086
|
const enums = enumsOf(row, table);
|
|
18042
18087
|
const decimals = decimalsOf(row, table);
|
|
18043
|
-
const
|
|
18044
|
-
if (Object.keys(enums).length > 0)
|
|
18045
|
-
if (decimals.length > 0)
|
|
18088
|
+
const constants3 = [];
|
|
18089
|
+
if (Object.keys(enums).length > 0) constants3.push(assignment("ENUMS", enums, Object.keys(enums)));
|
|
18090
|
+
if (decimals.length > 0) constants3.push(`DECIMALS = ${pyLiteral(decimals)}`);
|
|
18046
18091
|
const lines = ["def handle(ctx, payload):", ...collectRow(row, enums)];
|
|
18047
18092
|
if (decimals.length > 0) {
|
|
18048
18093
|
lines.push(
|
|
@@ -18056,17 +18101,17 @@ contract, not this file.`,
|
|
|
18056
18101
|
}
|
|
18057
18102
|
const refs = refsOf(row, table);
|
|
18058
18103
|
if (Object.keys(refs).length > 0) {
|
|
18059
|
-
|
|
18104
|
+
constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
18060
18105
|
lines.push(...refLines());
|
|
18061
18106
|
}
|
|
18062
18107
|
const parent = linkedParent(row, model);
|
|
18063
18108
|
if (parent !== null) {
|
|
18064
|
-
|
|
18109
|
+
constants3.push(`PARENT = ${pyString(parent)}`);
|
|
18065
18110
|
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
18111
|
lines.push(' row[HANDLER["by"]] = parent_id');
|
|
18067
18112
|
}
|
|
18068
18113
|
if (isPlainObject8(row.requires)) {
|
|
18069
|
-
|
|
18114
|
+
constants3.push(...requiresConstants(row, model));
|
|
18070
18115
|
lines.push(...requiresLines(row, "saved"));
|
|
18071
18116
|
}
|
|
18072
18117
|
if (isPlainObject8(row.fixed) && Object.keys(row.fixed).length > 0) lines.push(' row.update(HANDLER["fixed"])');
|
|
@@ -18085,7 +18130,7 @@ browser could choose is a status anyone can choose.${linkDoc}${requiresDoc(row)}
|
|
|
18085
18130
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
18086
18131
|
contract, not this file.`,
|
|
18087
18132
|
imports: [...parent !== null || Object.keys(refs).length > 0 ? ["import uuid"] : [], ...decimals.length > 0 ? ["from decimal import Decimal, InvalidOperation"] : []],
|
|
18088
|
-
constants:
|
|
18133
|
+
constants: constants3,
|
|
18089
18134
|
body: lines.join("\n")
|
|
18090
18135
|
};
|
|
18091
18136
|
},
|
|
@@ -18472,9 +18517,9 @@ function nodeLines(uid, contract, page, elements, tree, model, depth) {
|
|
|
18472
18517
|
const lede = named5(header.summary) ? `<p>${text2(header.summary)}</p>` : "";
|
|
18473
18518
|
const actions = Array.isArray(header.actions) && header.actions.length > 0 ? ` data-dr-header-actions="${attr2(JSON.stringify(header.actions))}"` : "";
|
|
18474
18519
|
const from = named5(header.title_from) ? ` data-dr-title-from="${attr2(header.title_from)}"` : "";
|
|
18475
|
-
const
|
|
18476
|
-
if (kids.length === 0) return [`${
|
|
18477
|
-
return [
|
|
18520
|
+
const open3 = `${pad}<header data-dr-kit="header"${gridAttrs(element)}${actions}${from}><h1>${text2(heading)}</h1>${lede}`;
|
|
18521
|
+
if (kids.length === 0) return [`${open3}</header>`];
|
|
18522
|
+
return [open3, ...kids.flatMap((child) => nodeLines(child, contract, page, elements, tree, model, depth + 1)), `${pad}</header>`];
|
|
18478
18523
|
}
|
|
18479
18524
|
case "nav": {
|
|
18480
18525
|
const entries = (contract.pages ?? []).map((one) => {
|
|
@@ -21550,11 +21595,11 @@ function clone4(value) {
|
|
|
21550
21595
|
}
|
|
21551
21596
|
|
|
21552
21597
|
// src/commands/appspace/contract.ts
|
|
21553
|
-
import { mkdir as mkdir2, readFile as
|
|
21598
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
21554
21599
|
import { join as join6 } from "path";
|
|
21555
21600
|
|
|
21556
21601
|
// src/commands/appspace/_folder.ts
|
|
21557
|
-
import { readFile as
|
|
21602
|
+
import { readFile as readFile2, readdir, stat, writeFile as writeFile2 } from "fs/promises";
|
|
21558
21603
|
import { join as join5 } from "path";
|
|
21559
21604
|
|
|
21560
21605
|
// src/commands/appspace/_handlerNames.ts
|
|
@@ -21589,7 +21634,7 @@ function handlerFileProblem(file) {
|
|
|
21589
21634
|
// src/commands/appspace/_folder.ts
|
|
21590
21635
|
async function readIfPresent(path3) {
|
|
21591
21636
|
try {
|
|
21592
|
-
return await
|
|
21637
|
+
return await readFile2(path3, "utf8");
|
|
21593
21638
|
} catch {
|
|
21594
21639
|
return void 0;
|
|
21595
21640
|
}
|
|
@@ -21618,7 +21663,7 @@ async function readUiTree(uiDir) {
|
|
|
21618
21663
|
continue;
|
|
21619
21664
|
}
|
|
21620
21665
|
if (!entry.isFile()) continue;
|
|
21621
|
-
out.push({ path: `${prefix}${name}`, bytes: await
|
|
21666
|
+
out.push({ path: `${prefix}${name}`, bytes: await readFile2(full) });
|
|
21622
21667
|
}
|
|
21623
21668
|
};
|
|
21624
21669
|
await walk5(uiDir, "");
|
|
@@ -21671,7 +21716,7 @@ async function readHandlers(handlersDir, state) {
|
|
|
21671
21716
|
const method = recorded?.[name];
|
|
21672
21717
|
handlers[name] = {
|
|
21673
21718
|
http: typeof method === "string" && method !== "" ? method : "POST",
|
|
21674
|
-
code: await
|
|
21719
|
+
code: await readFile2(join5(handlersDir, file), "utf8")
|
|
21675
21720
|
};
|
|
21676
21721
|
}
|
|
21677
21722
|
return handlers;
|
|
@@ -21738,7 +21783,7 @@ async function readLib(libDir) {
|
|
|
21738
21783
|
`);
|
|
21739
21784
|
continue;
|
|
21740
21785
|
}
|
|
21741
|
-
lib[name] = await
|
|
21786
|
+
lib[name] = await readFile2(full, "utf8");
|
|
21742
21787
|
}
|
|
21743
21788
|
return lib;
|
|
21744
21789
|
}
|
|
@@ -21822,7 +21867,7 @@ async function extractContract(dir) {
|
|
|
21822
21867
|
}
|
|
21823
21868
|
async function readModelIfPresent(dir) {
|
|
21824
21869
|
try {
|
|
21825
|
-
return await
|
|
21870
|
+
return await readFile3(join6(dir, "data_model.json"), "utf8");
|
|
21826
21871
|
} catch {
|
|
21827
21872
|
return void 0;
|
|
21828
21873
|
}
|
|
@@ -21884,7 +21929,7 @@ ${summarise(contract)}
|
|
|
21884
21929
|
}
|
|
21885
21930
|
|
|
21886
21931
|
// src/commands/appspace/liveness.ts
|
|
21887
|
-
import { readFile as
|
|
21932
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
21888
21933
|
import { join as join7 } from "path";
|
|
21889
21934
|
|
|
21890
21935
|
// ../flows/insights-builder/kit/checks/rules/liveness.mjs
|
|
@@ -22050,7 +22095,7 @@ async function runLiveness(dir, appId, whole, client, only) {
|
|
|
22050
22095
|
}
|
|
22051
22096
|
let code;
|
|
22052
22097
|
try {
|
|
22053
|
-
code = await
|
|
22098
|
+
code = await readFile4(join7(dir, handler.file), "utf8");
|
|
22054
22099
|
} catch {
|
|
22055
22100
|
return unchecked(
|
|
22056
22101
|
`${handler.file} is not in this folder, so no handler was run`
|
|
@@ -22232,7 +22277,7 @@ function render2(result, declared) {
|
|
|
22232
22277
|
|
|
22233
22278
|
// src/commands/appspace/preview.ts
|
|
22234
22279
|
import { spawnSync } from "child_process";
|
|
22235
|
-
import { readFile as
|
|
22280
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
22236
22281
|
import { tmpdir } from "os";
|
|
22237
22282
|
var lintTransform2 = lintTransform;
|
|
22238
22283
|
var FORBIDDEN_CALLS2 = FORBIDDEN_CALLS;
|
|
@@ -22596,7 +22641,7 @@ function registerPreviewCommand(parent) {
|
|
|
22596
22641
|
).option("--payload <json>", 'The request to serve (default: {"op": "load"}).')
|
|
22597
22642
|
)
|
|
22598
22643
|
).action(async (file, opts) => {
|
|
22599
|
-
const text4 = await
|
|
22644
|
+
const text4 = await readFile5(file, "utf8").catch(() => {
|
|
22600
22645
|
throw new Error(`cannot read ${file}`);
|
|
22601
22646
|
});
|
|
22602
22647
|
let document;
|
|
@@ -22751,7 +22796,7 @@ async function previewOne(document, file, opts, shared = {}) {
|
|
|
22751
22796
|
}
|
|
22752
22797
|
|
|
22753
22798
|
// src/commands/appspace/push.ts
|
|
22754
|
-
import { readFile as
|
|
22799
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
22755
22800
|
import { join as join8 } from "path";
|
|
22756
22801
|
import { gunzipSync, gzipSync } from "zlib";
|
|
22757
22802
|
|
|
@@ -24549,7 +24594,7 @@ async function pushBody(dir, opts) {
|
|
|
24549
24594
|
handlers,
|
|
24550
24595
|
frontend_bundle: ui?.field === "frontend_bundle" ? ui.files : null,
|
|
24551
24596
|
publish: opts.publish === true,
|
|
24552
|
-
seed: (opts.seed ?? "") === "" ? null : JSON.parse(await
|
|
24597
|
+
seed: (opts.seed ?? "") === "" ? null : JSON.parse(await readFile6(opts.seed, "utf8"))
|
|
24553
24598
|
};
|
|
24554
24599
|
if (ui?.field === "frontend_bundle_gz") {
|
|
24555
24600
|
body["frontend_bundle_gz"] = ui.files;
|
|
@@ -24706,13 +24751,13 @@ async function pushFolder(dir, opts) {
|
|
|
24706
24751
|
}
|
|
24707
24752
|
|
|
24708
24753
|
// src/commands/appspace/get.ts
|
|
24709
|
-
import { lstat, mkdtemp, mkdir as mkdir4, readFile as
|
|
24754
|
+
import { lstat, mkdtemp, mkdir as mkdir4, readFile as readFile8, rm as rm3, writeFile as writeFile5 } from "fs/promises";
|
|
24710
24755
|
import { tmpdir as tmpdir2 } from "os";
|
|
24711
24756
|
import { dirname as dirname3, join as join10 } from "path";
|
|
24712
24757
|
|
|
24713
24758
|
// src/commands/appspace/generate/report.ts
|
|
24714
24759
|
import { createHash as createHash3 } from "crypto";
|
|
24715
|
-
import { mkdir as mkdir3, readFile as
|
|
24760
|
+
import { mkdir as mkdir3, readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
|
|
24716
24761
|
import { join as join9 } from "path";
|
|
24717
24762
|
function reportPath(dir) {
|
|
24718
24763
|
return join9(dir, ".appspace", "compile.json");
|
|
@@ -24753,7 +24798,7 @@ async function writeReport(dir, report) {
|
|
|
24753
24798
|
}
|
|
24754
24799
|
async function ownedFiles(dir) {
|
|
24755
24800
|
try {
|
|
24756
|
-
const parsed2 = JSON.parse(await
|
|
24801
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24757
24802
|
if (!Array.isArray(parsed2.files)) return /* @__PURE__ */ new Set();
|
|
24758
24803
|
return new Set(parsed2.files.map(String));
|
|
24759
24804
|
} catch {
|
|
@@ -24762,7 +24807,7 @@ async function ownedFiles(dir) {
|
|
|
24762
24807
|
}
|
|
24763
24808
|
async function recordedRenderer(dir) {
|
|
24764
24809
|
try {
|
|
24765
|
-
const parsed2 = JSON.parse(await
|
|
24810
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24766
24811
|
if (parsed2.kind !== "dashboard") return null;
|
|
24767
24812
|
return parsed2.renderer === "runtime" || parsed2.renderer === "widgets" ? parsed2.renderer : null;
|
|
24768
24813
|
} catch {
|
|
@@ -24774,7 +24819,7 @@ function digestOf(text4) {
|
|
|
24774
24819
|
}
|
|
24775
24820
|
async function recordedDigests(dir) {
|
|
24776
24821
|
try {
|
|
24777
|
-
const parsed2 = JSON.parse(await
|
|
24822
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24778
24823
|
const held = parsed2.digests;
|
|
24779
24824
|
if (typeof held !== "object" || held === null || Array.isArray(held)) return {};
|
|
24780
24825
|
return Object.fromEntries(Object.entries(held).filter((entry) => typeof entry[1] === "string"));
|
|
@@ -24785,7 +24830,7 @@ async function recordedDigests(dir) {
|
|
|
24785
24830
|
async function recordAsInput(dir, path3) {
|
|
24786
24831
|
let parsed2;
|
|
24787
24832
|
try {
|
|
24788
|
-
parsed2 = JSON.parse(await
|
|
24833
|
+
parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24789
24834
|
} catch {
|
|
24790
24835
|
return;
|
|
24791
24836
|
}
|
|
@@ -24823,7 +24868,7 @@ async function unpushedInputs(dir, pkg) {
|
|
|
24823
24868
|
const out = await unpushedLib(dir, pkg);
|
|
24824
24869
|
let inputs = [];
|
|
24825
24870
|
try {
|
|
24826
|
-
const parsed2 = JSON.parse(await
|
|
24871
|
+
const parsed2 = JSON.parse(await readFile8(reportPath(dir), "utf8"));
|
|
24827
24872
|
if (Array.isArray(parsed2.inputs)) inputs = parsed2.inputs.map(String);
|
|
24828
24873
|
} catch {
|
|
24829
24874
|
return out;
|
|
@@ -24857,9 +24902,9 @@ async function unpushedLib(dir, pkg) {
|
|
|
24857
24902
|
async function writePackage(dir, appId, pkg) {
|
|
24858
24903
|
await mkdir4(dir, { recursive: true });
|
|
24859
24904
|
await Promise.all([
|
|
24860
|
-
|
|
24861
|
-
|
|
24862
|
-
|
|
24905
|
+
rm3(join10(dir, "data_model.json"), { force: true }),
|
|
24906
|
+
rm3(join10(dir, "handlers"), { recursive: true, force: true }),
|
|
24907
|
+
rm3(join10(dir, "ui"), { recursive: true, force: true })
|
|
24863
24908
|
]);
|
|
24864
24909
|
const connected = pkg.connect_tables ?? {};
|
|
24865
24910
|
const manifestOut = Object.keys(connected).length > 0 ? { ...pkg.manifest, connect_tables: connected } : pkg.manifest;
|
|
@@ -24898,7 +24943,7 @@ async function writePackage(dir, appId, pkg) {
|
|
|
24898
24943
|
}
|
|
24899
24944
|
}
|
|
24900
24945
|
for (const file of await readDirIfPresent(libDir)) {
|
|
24901
|
-
if (file.endsWith(".py")) await
|
|
24946
|
+
if (file.endsWith(".py")) await rm3(join10(libDir, file), { force: true });
|
|
24902
24947
|
}
|
|
24903
24948
|
for (const [name, code] of Object.entries(pkg.lib)) {
|
|
24904
24949
|
await mkdir4(libDir, { recursive: true });
|
|
@@ -24982,7 +25027,7 @@ async function writeOwnedFiles(dir, document, { force = false } = {}) {
|
|
|
24982
25027
|
}
|
|
24983
25028
|
async function isDashboardFolder(dir) {
|
|
24984
25029
|
try {
|
|
24985
|
-
const manifest = JSON.parse(await
|
|
25030
|
+
const manifest = JSON.parse(await readFile8(join10(dir, "manifest.json"), "utf8"));
|
|
24986
25031
|
return manifest["kind"] === "dashboard";
|
|
24987
25032
|
} catch {
|
|
24988
25033
|
return false;
|
|
@@ -24992,7 +25037,7 @@ var OWNED_TEXT_PATH = /^transforms\/[a-z][a-z0-9_]*\.py$/;
|
|
|
24992
25037
|
async function restoreOwnedFiles(dir, contractWritten, { force }) {
|
|
24993
25038
|
let stated2 = [];
|
|
24994
25039
|
if (contractWritten) {
|
|
24995
|
-
const doc = JSON.parse(await
|
|
25040
|
+
const doc = JSON.parse(await readFile8(join10(dir, "contract.json"), "utf8"));
|
|
24996
25041
|
if (Array.isArray(doc["owned"])) stated2 = doc["owned"];
|
|
24997
25042
|
}
|
|
24998
25043
|
const known = new Set(
|
|
@@ -25044,7 +25089,7 @@ async function pullInto(client, appId, dir, {
|
|
|
25044
25089
|
if (err instanceof AppSpaceHttpError && err.status === 404) return null;
|
|
25045
25090
|
throw err;
|
|
25046
25091
|
}
|
|
25047
|
-
await
|
|
25092
|
+
await rm3(join10(dir, "contract.json"), { force: true });
|
|
25048
25093
|
await writePackage(dir, appId, pkg);
|
|
25049
25094
|
const read = await readStoredContract(client, appId, pkg.code_version);
|
|
25050
25095
|
if ("document" in read) {
|
|
@@ -25121,9 +25166,9 @@ function registerGetCommand(parent) {
|
|
|
25121
25166
|
}
|
|
25122
25167
|
|
|
25123
25168
|
// src/commands/appspace/packageCheck.ts
|
|
25124
|
-
import { cp, mkdir as mkdir5, mkdtemp as mkdtemp2, readdir as readdir2, rm as
|
|
25169
|
+
import { cp, mkdir as mkdir5, mkdtemp as mkdtemp2, readdir as readdir2, rm as rm4, writeFile as writeFile6 } from "fs/promises";
|
|
25125
25170
|
import { tmpdir as tmpdir3 } from "os";
|
|
25126
|
-
import { dirname as dirname4, join as join11, resolve as
|
|
25171
|
+
import { dirname as dirname4, join as join11, resolve as resolve6, sep as sep2 } from "path";
|
|
25127
25172
|
var WHAT = "package";
|
|
25128
25173
|
async function checkPackage(dir, files, contract, opts, online, pendingMetricKeys = []) {
|
|
25129
25174
|
const badName = await handlerNameProblems(dir, files);
|
|
@@ -25175,7 +25220,7 @@ async function checkPackage(dir, files, contract, opts, online, pendingMetricKey
|
|
|
25175
25220
|
client.cleanup();
|
|
25176
25221
|
}
|
|
25177
25222
|
} finally {
|
|
25178
|
-
await
|
|
25223
|
+
await rm4(scratch, { recursive: true, force: true });
|
|
25179
25224
|
}
|
|
25180
25225
|
}
|
|
25181
25226
|
async function handlerNameProblems(dir, files) {
|
|
@@ -25351,9 +25396,9 @@ async function stage(dir, scratch, files) {
|
|
|
25351
25396
|
recursive: true,
|
|
25352
25397
|
filter: (source) => !/[\\/](node_modules|\.git)$/.test(source)
|
|
25353
25398
|
});
|
|
25354
|
-
const root =
|
|
25399
|
+
const root = resolve6(scratch);
|
|
25355
25400
|
for (const [path3, text4] of Object.entries(files)) {
|
|
25356
|
-
const full =
|
|
25401
|
+
const full = resolve6(root, path3);
|
|
25357
25402
|
if (!full.startsWith(root + sep2)) {
|
|
25358
25403
|
return `the package names a path outside its folder (${JSON.stringify(path3)})`;
|
|
25359
25404
|
}
|
|
@@ -25537,7 +25582,7 @@ function isPlainObject10(value) {
|
|
|
25537
25582
|
|
|
25538
25583
|
// ../flows/insights-builder/kit/checks/verify.mjs
|
|
25539
25584
|
import { readFileSync as readFileSync3 } from "fs";
|
|
25540
|
-
import { dirname as dirname5, join as join12, resolve as
|
|
25585
|
+
import { dirname as dirname5, join as join12, resolve as resolve8 } from "path";
|
|
25541
25586
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
25542
25587
|
|
|
25543
25588
|
// ../flows/insights-builder/kit/checks/lib/executable.mjs
|
|
@@ -26421,10 +26466,10 @@ function checkControl(el, boxes, where2) {
|
|
|
26421
26466
|
}
|
|
26422
26467
|
function controlBoxes(text4) {
|
|
26423
26468
|
const boxes = [];
|
|
26424
|
-
const
|
|
26469
|
+
const open3 = new RegExp(`<([a-zA-Z][\\w-]*)([^>]*\\b${KIT_MARK}\\s*=\\s*["'](?:${[...CONTROL_BOXES].join("|")})["'][^>]*)>`, "g");
|
|
26425
26470
|
let match;
|
|
26426
|
-
while ((match =
|
|
26427
|
-
boxes.push([lineAt(text4, match.index), lineAt(text4, closingTag(text4, match[1].toLowerCase(),
|
|
26471
|
+
while ((match = open3.exec(text4)) !== null) {
|
|
26472
|
+
boxes.push([lineAt(text4, match.index), lineAt(text4, closingTag(text4, match[1].toLowerCase(), open3.lastIndex))]);
|
|
26428
26473
|
}
|
|
26429
26474
|
return boxes;
|
|
26430
26475
|
}
|
|
@@ -26736,7 +26781,7 @@ function checkTheme(app) {
|
|
|
26736
26781
|
const overrides = rootTokens(file.text);
|
|
26737
26782
|
if (overrides.size === 0) return { violations };
|
|
26738
26783
|
for (const theme of themesInUse(app)) {
|
|
26739
|
-
const ground = rgbOf2(overrides.has("--dr-surface") ?
|
|
26784
|
+
const ground = rgbOf2(overrides.has("--dr-surface") ? resolve7("--dr-surface", overrides) : THEME_SURFACES[theme]);
|
|
26740
26785
|
if (!ground) {
|
|
26741
26786
|
const surface = overrides.get("--dr-surface");
|
|
26742
26787
|
violations.push({
|
|
@@ -26749,7 +26794,7 @@ function checkTheme(app) {
|
|
|
26749
26794
|
for (const [token, { line: line2 }] of overrides) {
|
|
26750
26795
|
const rule = FLOORS.get(token);
|
|
26751
26796
|
if (!rule) continue;
|
|
26752
|
-
const value =
|
|
26797
|
+
const value = resolve7(token, overrides);
|
|
26753
26798
|
if (value === null) continue;
|
|
26754
26799
|
const series = /^--dr-chart-(\d+)$/.exec(token);
|
|
26755
26800
|
if (series && isPlatformChartColour(Number(series[1]), value)) continue;
|
|
@@ -26797,12 +26842,12 @@ function themesInUse(app) {
|
|
|
26797
26842
|
}
|
|
26798
26843
|
return found.size ? [...found].sort() : ["default"];
|
|
26799
26844
|
}
|
|
26800
|
-
function
|
|
26845
|
+
function resolve7(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
26801
26846
|
const entry = overrides.get(token);
|
|
26802
26847
|
if (!entry || seen.has(token)) return null;
|
|
26803
26848
|
seen.add(token);
|
|
26804
26849
|
const hit = /^var\(\s*(--[a-z0-9-]+)/.exec(entry.value);
|
|
26805
|
-
return hit ?
|
|
26850
|
+
return hit ? resolve7(hit[1], overrides, seen) : entry.value;
|
|
26806
26851
|
}
|
|
26807
26852
|
function rootTokens(css) {
|
|
26808
26853
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -26881,7 +26926,7 @@ function kitFromDisk() {
|
|
|
26881
26926
|
}
|
|
26882
26927
|
function verify({ app: appRef, catalog, agent, describe: describe7, load }, { extractContract: extractContract2 = extract, kit } = {}) {
|
|
26883
26928
|
const KIT = kit ?? kitFromDisk();
|
|
26884
|
-
const app = loadApp(
|
|
26929
|
+
const app = loadApp(resolve8(appRef.dir));
|
|
26885
26930
|
let contract = null;
|
|
26886
26931
|
let contractError = null;
|
|
26887
26932
|
try {
|
|
@@ -26958,7 +27003,7 @@ function compareRules(a, b) {
|
|
|
26958
27003
|
return 0;
|
|
26959
27004
|
}
|
|
26960
27005
|
var SELF = fileURLToPath3(import.meta.url);
|
|
26961
|
-
if (SELF.endsWith("verify.mjs") && process.argv[1] &&
|
|
27006
|
+
if (SELF.endsWith("verify.mjs") && process.argv[1] && resolve8(process.argv[1]) === SELF) {
|
|
26962
27007
|
let raw = "";
|
|
26963
27008
|
process.stdin.setEncoding("utf8");
|
|
26964
27009
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
@@ -26976,16 +27021,16 @@ if (SELF.endsWith("verify.mjs") && process.argv[1] && resolve7(process.argv[1])
|
|
|
26976
27021
|
|
|
26977
27022
|
// ../flows/appspace-builder/kit/checks/verify.mjs
|
|
26978
27023
|
import { readFileSync as readFileSync5 } from "fs";
|
|
26979
|
-
import { dirname as dirname6, join as join14, resolve as
|
|
27024
|
+
import { dirname as dirname6, join as join14, resolve as resolve13 } from "path";
|
|
26980
27025
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
26981
27026
|
|
|
26982
27027
|
// ../flows/appspace-builder/kit/contract/extract.mjs
|
|
26983
|
-
import { resolve as
|
|
27028
|
+
import { resolve as resolve10 } from "path";
|
|
26984
27029
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
26985
27030
|
|
|
26986
27031
|
// ../flows/appspace-builder/kit/checks/lib/app.mjs
|
|
26987
27032
|
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
|
|
27033
|
+
import { join as join13, relative as relative2, resolve as resolve9, sep as sep3 } from "path";
|
|
26989
27034
|
var DATA_MODEL_PATH2 = "data_model.json";
|
|
26990
27035
|
var UI_PREFIX3 = "ui/";
|
|
26991
27036
|
var PAGE_PATH4 = /\.html?$/i;
|
|
@@ -27018,8 +27063,8 @@ function loadApp2(dir) {
|
|
|
27018
27063
|
}
|
|
27019
27064
|
function readHandlerSource2(dir, file) {
|
|
27020
27065
|
if (!file) return "";
|
|
27021
|
-
const root =
|
|
27022
|
-
const full =
|
|
27066
|
+
const root = resolve9(dir);
|
|
27067
|
+
const full = resolve9(root, file);
|
|
27023
27068
|
if (full !== root && !full.startsWith(root + sep3)) return "";
|
|
27024
27069
|
if (!existsSync2(full) || !statSync2(full).isFile()) return "";
|
|
27025
27070
|
return readFileSync4(full, "utf8");
|
|
@@ -27384,9 +27429,9 @@ function groupByObject2(text4, pairs) {
|
|
|
27384
27429
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
27385
27430
|
const pair = pairs.get(i);
|
|
27386
27431
|
if (pair !== void 0 && stack.length > 0) {
|
|
27387
|
-
const
|
|
27388
|
-
if (!byObject.has(
|
|
27389
|
-
byObject.get(
|
|
27432
|
+
const open3 = stack[stack.length - 1];
|
|
27433
|
+
if (!byObject.has(open3)) byObject.set(open3, []);
|
|
27434
|
+
byObject.get(open3).push(pair);
|
|
27390
27435
|
}
|
|
27391
27436
|
i = endOfString2(text4, i);
|
|
27392
27437
|
previous = '"';
|
|
@@ -28415,15 +28460,15 @@ function readPage2(app, page, spec, elements, problems) {
|
|
|
28415
28460
|
}
|
|
28416
28461
|
const bands = significant.filter((entry) => entry.type === "region" && entry.role === BAND_ROLE2);
|
|
28417
28462
|
const banded = bands.map((entry, index) => sectionOf2(entry.node, page.text, index));
|
|
28418
|
-
let
|
|
28463
|
+
let open3 = null;
|
|
28419
28464
|
let next = 0;
|
|
28420
28465
|
for (const entry of significant) {
|
|
28421
28466
|
if (next < bands.length && entry === bands[next]) {
|
|
28422
|
-
|
|
28467
|
+
open3 = banded[next].id;
|
|
28423
28468
|
next += 1;
|
|
28424
28469
|
continue;
|
|
28425
28470
|
}
|
|
28426
|
-
if (
|
|
28471
|
+
if (open3 !== null) elements[uids.get(entry.node.index)].section = open3;
|
|
28427
28472
|
}
|
|
28428
28473
|
const wrappers = tree.nodes.filter((node) => node.attrs[SECTION_ATTR2] !== void 0);
|
|
28429
28474
|
const wrapped = wrappers.map((node, index) => wrappedSectionOf2(tree, node, page.text, index));
|
|
@@ -29525,14 +29570,14 @@ function canonical4(value) {
|
|
|
29525
29570
|
return value;
|
|
29526
29571
|
}
|
|
29527
29572
|
var ENTRY2 = fileURLToPath4(import.meta.url);
|
|
29528
|
-
if (process.argv[1] &&
|
|
29573
|
+
if (process.argv[1] && resolve10(process.argv[1]) === ENTRY2 && ENTRY2.endsWith("extract.mjs")) {
|
|
29529
29574
|
let raw = "";
|
|
29530
29575
|
process.stdin.setEncoding("utf8");
|
|
29531
29576
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
29532
29577
|
process.stdin.on("end", () => {
|
|
29533
29578
|
try {
|
|
29534
29579
|
const input = JSON.parse(raw);
|
|
29535
|
-
const app = loadApp2(
|
|
29580
|
+
const app = loadApp2(resolve10(input.app.dir));
|
|
29536
29581
|
process.stdout.write(JSON.stringify(extract2(app, { describe: input.describe })));
|
|
29537
29582
|
} catch (e) {
|
|
29538
29583
|
process.stderr.write(`contract: ${e instanceof AppLoadError2 ? e.message : e.stack ?? e}
|
|
@@ -29583,7 +29628,7 @@ function check3(instance, node, at, root, problems, ctx) {
|
|
|
29583
29628
|
const start = problems.length;
|
|
29584
29629
|
const hint = describe4(node, ctx);
|
|
29585
29630
|
if (typeof node.$ref === "string") {
|
|
29586
|
-
const target =
|
|
29631
|
+
const target = resolve11(node.$ref, root);
|
|
29587
29632
|
if (target === null) {
|
|
29588
29633
|
problems.push(problem5(at, "the schema names a reference it cannot resolve"));
|
|
29589
29634
|
return;
|
|
@@ -29681,7 +29726,7 @@ function shapes3(branches, root) {
|
|
|
29681
29726
|
const named13 = branches.map((branch) => {
|
|
29682
29727
|
let node = branch;
|
|
29683
29728
|
for (let hops = 0; isObject6(node) && typeof node.$ref === "string" && hops < 8; hops += 1) {
|
|
29684
|
-
const target =
|
|
29729
|
+
const target = resolve11(node.$ref, root);
|
|
29685
29730
|
if (target === null) break;
|
|
29686
29731
|
node = target;
|
|
29687
29732
|
}
|
|
@@ -29743,7 +29788,7 @@ function same3(a, b) {
|
|
|
29743
29788
|
if (typeof a === "boolean" || typeof b === "boolean") return a === b;
|
|
29744
29789
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
29745
29790
|
}
|
|
29746
|
-
function
|
|
29791
|
+
function resolve11(ref, root) {
|
|
29747
29792
|
if (!ref.startsWith("#/")) return null;
|
|
29748
29793
|
let node = root;
|
|
29749
29794
|
for (const token of ref.slice(2).split("/")) {
|
|
@@ -29881,8 +29926,8 @@ function stringEnd2(text4, i) {
|
|
|
29881
29926
|
return Math.min(j + 1, text4.length);
|
|
29882
29927
|
}
|
|
29883
29928
|
function closeOf2(text4, i) {
|
|
29884
|
-
const
|
|
29885
|
-
const close = { "{": "}", "(": ")", "[": "]" }[
|
|
29929
|
+
const open3 = text4[i];
|
|
29930
|
+
const close = { "{": "}", "(": ")", "[": "]" }[open3];
|
|
29886
29931
|
let depth = 0;
|
|
29887
29932
|
for (let j = i; j < text4.length; j++) {
|
|
29888
29933
|
const ch = text4[j];
|
|
@@ -31349,10 +31394,10 @@ function railReachProblems2(contract) {
|
|
|
31349
31394
|
const pages = new Map((Array.isArray(contract?.pages) ? contract.pages : []).filter((page) => named10(page?.path)).map((page) => [page.path, page]));
|
|
31350
31395
|
const openers = (page) => Array.isArray(page?.roles) && page.roles.filter(named10).length > 0 ? page.roles.filter(named10) : null;
|
|
31351
31396
|
const canOpen = (name, page) => {
|
|
31352
|
-
const
|
|
31353
|
-
if (
|
|
31397
|
+
const open3 = openers(page);
|
|
31398
|
+
if (open3 === null) return true;
|
|
31354
31399
|
const role = declared.get(name);
|
|
31355
|
-
return
|
|
31400
|
+
return open3.includes(name) || (role?.sees ?? []).some((seen) => open3.includes(seen));
|
|
31356
31401
|
};
|
|
31357
31402
|
for (const key of ["entries", "footer"]) {
|
|
31358
31403
|
for (const [index, entry] of (Array.isArray(rail[key]) ? rail[key] : []).entries()) {
|
|
@@ -31638,7 +31683,7 @@ function checkTheme2(app) {
|
|
|
31638
31683
|
const overrides = rootTokens2(file.text);
|
|
31639
31684
|
if (overrides.size === 0) return { violations };
|
|
31640
31685
|
for (const theme of themesInUse2(app)) {
|
|
31641
|
-
const ground = rgbOf3(overrides.has("--dr-surface") ?
|
|
31686
|
+
const ground = rgbOf3(overrides.has("--dr-surface") ? resolve12("--dr-surface", overrides) : THEME_SURFACES2[theme]);
|
|
31642
31687
|
if (!ground) {
|
|
31643
31688
|
const surface = overrides.get("--dr-surface");
|
|
31644
31689
|
violations.push({
|
|
@@ -31651,7 +31696,7 @@ function checkTheme2(app) {
|
|
|
31651
31696
|
for (const [token, { line: line2 }] of overrides) {
|
|
31652
31697
|
const rule = FLOORS2.get(token);
|
|
31653
31698
|
if (!rule) continue;
|
|
31654
|
-
const value =
|
|
31699
|
+
const value = resolve12(token, overrides);
|
|
31655
31700
|
if (value === null) continue;
|
|
31656
31701
|
const series = /^--dr-chart-(\d+)$/.exec(token);
|
|
31657
31702
|
if (series && isPlatformChartColour2(Number(series[1]), value)) continue;
|
|
@@ -31699,12 +31744,12 @@ function themesInUse2(app) {
|
|
|
31699
31744
|
}
|
|
31700
31745
|
return found.size ? [...found].sort() : ["default"];
|
|
31701
31746
|
}
|
|
31702
|
-
function
|
|
31747
|
+
function resolve12(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
31703
31748
|
const entry = overrides.get(token);
|
|
31704
31749
|
if (!entry || seen.has(token)) return null;
|
|
31705
31750
|
seen.add(token);
|
|
31706
31751
|
const hit = /^var\(\s*(--[a-z0-9-]+)/.exec(entry.value);
|
|
31707
|
-
return hit ?
|
|
31752
|
+
return hit ? resolve12(hit[1], overrides, seen) : entry.value;
|
|
31708
31753
|
}
|
|
31709
31754
|
function rootTokens2(css) {
|
|
31710
31755
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -31947,10 +31992,10 @@ function handlerLiteral(source) {
|
|
|
31947
31992
|
const limit = /["']limit["']\s*:\s*(\d+)/.exec(body)?.[1];
|
|
31948
31993
|
return { table, limit: limit === void 0 ? null : Number(limit) };
|
|
31949
31994
|
}
|
|
31950
|
-
function argumentsFrom(source, from,
|
|
31995
|
+
function argumentsFrom(source, from, open3 = "(", close = ")") {
|
|
31951
31996
|
let depth = 1;
|
|
31952
31997
|
for (let i = from; i < source.length; i++) {
|
|
31953
|
-
if (source[i] ===
|
|
31998
|
+
if (source[i] === open3) depth++;
|
|
31954
31999
|
else if (source[i] === close && --depth === 0) return source.slice(from, i);
|
|
31955
32000
|
}
|
|
31956
32001
|
return source.slice(from);
|
|
@@ -32161,8 +32206,8 @@ function navLinks2(html, { owned = false, from } = {}) {
|
|
|
32161
32206
|
const regions = [];
|
|
32162
32207
|
if (owned) regions.push(text4);
|
|
32163
32208
|
else {
|
|
32164
|
-
for (const
|
|
32165
|
-
const rest = text4.slice(
|
|
32209
|
+
for (const open3 of text4.matchAll(NAV_OPEN2)) {
|
|
32210
|
+
const rest = text4.slice(open3.index + open3[0].length);
|
|
32166
32211
|
const end = rest.search(NAV_CLOSE2);
|
|
32167
32212
|
regions.push(end === -1 ? rest : rest.slice(0, end));
|
|
32168
32213
|
}
|
|
@@ -32587,24 +32632,24 @@ function sourceRoles2(contract, name, known = /* @__PURE__ */ new Set()) {
|
|
|
32587
32632
|
const pages = new Map(pagesOf2(contract).map((page) => [page.path, page]));
|
|
32588
32633
|
const union = [];
|
|
32589
32634
|
let readers = 0;
|
|
32590
|
-
let
|
|
32635
|
+
let open3 = false;
|
|
32591
32636
|
for (const element of Object.values(elements)) {
|
|
32592
32637
|
const props = isPlainObject17(element?.props) ? element.props : {};
|
|
32593
32638
|
const reads = [props.source, ...Array.isArray(props.declares?.reads) ? props.declares.reads : []];
|
|
32594
32639
|
if (!reads.includes(name)) continue;
|
|
32595
32640
|
readers += 1;
|
|
32596
32641
|
const roles = pageRoles2(pages.get(element.page));
|
|
32597
|
-
if (roles.length === 0)
|
|
32642
|
+
if (roles.length === 0) open3 = true;
|
|
32598
32643
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
32599
32644
|
}
|
|
32600
32645
|
for (const page of pagesOf2(contract)) {
|
|
32601
32646
|
if (page.owned !== true || readers === 0 || known.has(page.path)) continue;
|
|
32602
32647
|
const roles = pageRoles2(page);
|
|
32603
|
-
if (roles.length === 0)
|
|
32648
|
+
if (roles.length === 0) open3 = true;
|
|
32604
32649
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
32605
32650
|
}
|
|
32606
32651
|
if (stated2.length > 0) return { roles: stated2, inherited: false, readers };
|
|
32607
|
-
if (readers === 0 ||
|
|
32652
|
+
if (readers === 0 || open3) return { roles: [], inherited: true, readers };
|
|
32608
32653
|
const order2 = roleModel2(contract).names;
|
|
32609
32654
|
return { roles: union.sort((a, b) => order2.indexOf(a) - order2.indexOf(b)), inherited: true, readers };
|
|
32610
32655
|
}
|
|
@@ -32681,7 +32726,7 @@ function kitFromDisk2() {
|
|
|
32681
32726
|
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
32727
|
function verify2({ app: appRef }, { extractContract: extractContract2 = extract2, kit } = {}) {
|
|
32683
32728
|
const KIT = kit ?? kitFromDisk2();
|
|
32684
|
-
const app = loadApp2(
|
|
32729
|
+
const app = loadApp2(resolve13(appRef.dir));
|
|
32685
32730
|
let contract = null;
|
|
32686
32731
|
let contractError = null;
|
|
32687
32732
|
try {
|
|
@@ -32756,7 +32801,7 @@ function compareRules2(a, b) {
|
|
|
32756
32801
|
return 0;
|
|
32757
32802
|
}
|
|
32758
32803
|
var SELF2 = fileURLToPath5(import.meta.url);
|
|
32759
|
-
if (SELF2.endsWith("verify.mjs") && process.argv[1] &&
|
|
32804
|
+
if (SELF2.endsWith("verify.mjs") && process.argv[1] && resolve13(process.argv[1]) === SELF2) {
|
|
32760
32805
|
let raw = "";
|
|
32761
32806
|
process.stdin.setEncoding("utf8");
|
|
32762
32807
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
@@ -33113,14 +33158,14 @@ async function runCompile(dir, opts) {
|
|
|
33113
33158
|
const state = await readIfPresent(join15(dir, ".appspace.json"));
|
|
33114
33159
|
if (state !== void 0) await writeFile7(join15(target, ".appspace.json"), state);
|
|
33115
33160
|
} else {
|
|
33116
|
-
for (const path3 of plan.orphaned) await
|
|
33161
|
+
for (const path3 of plan.orphaned) await rm5(join15(dir, path3), { force: true });
|
|
33117
33162
|
report.files = plan.owned;
|
|
33118
33163
|
report.digests = Object.fromEntries(plan.owned.map((path3) => [path3, digestOf(built.files[path3] ?? "")]));
|
|
33119
33164
|
report.inputs = plan.inputs;
|
|
33120
33165
|
}
|
|
33121
33166
|
return await afterWrite(dir, target, kind, contract, built, report, kit, skipped, opts, metricsPlan);
|
|
33122
33167
|
} finally {
|
|
33123
|
-
if (check5) await
|
|
33168
|
+
if (check5) await rm5(target, { recursive: true, force: true });
|
|
33124
33169
|
}
|
|
33125
33170
|
}
|
|
33126
33171
|
async function afterWrite(dir, target, kind, contract, built, report, kit, skipped, opts, metricsPlan = null) {
|
|
@@ -33398,8 +33443,8 @@ function insideFolder(dir, key) {
|
|
|
33398
33443
|
if (key.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
33399
33444
|
return false;
|
|
33400
33445
|
}
|
|
33401
|
-
const root =
|
|
33402
|
-
return
|
|
33446
|
+
const root = resolve14(dir);
|
|
33447
|
+
return resolve14(root, key).startsWith(root + sep4);
|
|
33403
33448
|
}
|
|
33404
33449
|
var AUTHOR_FILES = /* @__PURE__ */ new Set(["seed.json", "tests.json"]);
|
|
33405
33450
|
async function writePlan(dir, kind, contract, files, paths, force) {
|
|
@@ -33877,7 +33922,7 @@ function nothingWritten(report) {
|
|
|
33877
33922
|
async function readNamed(path3) {
|
|
33878
33923
|
let raw;
|
|
33879
33924
|
try {
|
|
33880
|
-
raw = await
|
|
33925
|
+
raw = await readFile9(resolve14(path3), "utf8");
|
|
33881
33926
|
} catch (err) {
|
|
33882
33927
|
throw new Error(`cannot read ${path3} (${err instanceof Error ? err.message.split("\n")[0] : String(err)}).`);
|
|
33883
33928
|
}
|
|
@@ -33949,7 +33994,7 @@ async function compileFolder(dir, kind, contract, kit, overlay = {}) {
|
|
|
33949
33994
|
var COMPILED_PAGE = 'id="dr-contract"';
|
|
33950
33995
|
async function recordPulled(dir, contractWritten) {
|
|
33951
33996
|
const forget = async () => {
|
|
33952
|
-
await
|
|
33997
|
+
await rm5(reportPath(dir), { force: true });
|
|
33953
33998
|
return null;
|
|
33954
33999
|
};
|
|
33955
34000
|
if (!contractWritten) return forget();
|
|
@@ -34402,7 +34447,7 @@ async function runShipOntoLive(dir, opts) {
|
|
|
34402
34447
|
}
|
|
34403
34448
|
const catalogMemo = {};
|
|
34404
34449
|
return landWithRetries(async (createGuarded) => {
|
|
34405
|
-
for (const name of ONTO_LIVE_OWNED) await
|
|
34450
|
+
for (const name of ONTO_LIVE_OWNED) await rm5(join15(dir, name), { recursive: true, force: true });
|
|
34406
34451
|
const client = await connect(opts);
|
|
34407
34452
|
let pulled;
|
|
34408
34453
|
try {
|
|
@@ -34484,7 +34529,7 @@ async function claimFolder(dir) {
|
|
|
34484
34529
|
}
|
|
34485
34530
|
async function lostRaceOf(dir) {
|
|
34486
34531
|
try {
|
|
34487
|
-
const report = JSON.parse(await
|
|
34532
|
+
const report = JSON.parse(await readFile9(reportPath(dir), "utf8"));
|
|
34488
34533
|
if (report.failure === "concurrent-publish") return { race: "publish", current: null };
|
|
34489
34534
|
if (report.failure === "stale-revision") return { race: "stale", current: report.stale?.current ?? null };
|
|
34490
34535
|
return null;
|
|
@@ -34575,10 +34620,10 @@ var EJECTED_DOCSTRING = 'Ejected with app-space eject: this file is yours now, a
|
|
|
34575
34620
|
function authorsDocstring(body) {
|
|
34576
34621
|
return body.replace(/Generated by [^\n]*compile[\s\S]*?not this file\./, EJECTED_DOCSTRING);
|
|
34577
34622
|
}
|
|
34578
|
-
function literalEnd2(text4,
|
|
34623
|
+
function literalEnd2(text4, open3) {
|
|
34579
34624
|
let depth = 0;
|
|
34580
34625
|
let quote = null;
|
|
34581
|
-
for (let i =
|
|
34626
|
+
for (let i = open3; i < text4.length; i++) {
|
|
34582
34627
|
const c = text4[i];
|
|
34583
34628
|
if (quote !== null) {
|
|
34584
34629
|
if (c === "\\") i++;
|
|
@@ -34969,8 +35014,8 @@ function registerLogsCommand(parent) {
|
|
|
34969
35014
|
}
|
|
34970
35015
|
|
|
34971
35016
|
// src/commands/appspace/migrate.ts
|
|
34972
|
-
import { constants } from "fs";
|
|
34973
|
-
import { access, lstat as lstat2, readFile as
|
|
35017
|
+
import { constants as constants2 } from "fs";
|
|
35018
|
+
import { access, lstat as lstat2, readFile as readFile10, realpath, rename as rename2, rm as rm6, writeFile as writeFile9 } from "fs/promises";
|
|
34974
35019
|
import { basename as basename2, dirname as dirname9, join as join17, sep as sep5 } from "path";
|
|
34975
35020
|
var MIGRATE_ROUTE = "/apps/migrate-preview";
|
|
34976
35021
|
var RUNTIMES_NOW = [1];
|
|
@@ -35173,12 +35218,12 @@ function valueEnd(text4, i) {
|
|
|
35173
35218
|
if (n === i) throw new NotJson();
|
|
35174
35219
|
return n;
|
|
35175
35220
|
}
|
|
35176
|
-
function containerOf(text4,
|
|
35177
|
-
const object = text4[
|
|
35221
|
+
function containerOf(text4, open3) {
|
|
35222
|
+
const object = text4[open3] === "{";
|
|
35178
35223
|
const closer = object ? "}" : "]";
|
|
35179
35224
|
const members = [];
|
|
35180
|
-
let i = skipSpace(text4,
|
|
35181
|
-
if (text4[i] === closer) return { open:
|
|
35225
|
+
let i = skipSpace(text4, open3 + 1);
|
|
35226
|
+
if (text4[i] === closer) return { open: open3, close: i, members };
|
|
35182
35227
|
for (; ; ) {
|
|
35183
35228
|
let key = null;
|
|
35184
35229
|
const start = i;
|
|
@@ -35197,7 +35242,7 @@ function containerOf(text4, open2) {
|
|
|
35197
35242
|
i = skipSpace(text4, i + 1);
|
|
35198
35243
|
continue;
|
|
35199
35244
|
}
|
|
35200
|
-
if (text4[i] === closer) return { open:
|
|
35245
|
+
if (text4[i] === closer) return { open: open3, close: i, members };
|
|
35201
35246
|
throw new NotJson();
|
|
35202
35247
|
}
|
|
35203
35248
|
}
|
|
@@ -35359,7 +35404,7 @@ async function runMigrate(dir, opts) {
|
|
|
35359
35404
|
const { manifest } = await readManifest(dir).catch((err) => {
|
|
35360
35405
|
throw new MigrateRefused(err instanceof Error ? err.message : String(err));
|
|
35361
35406
|
});
|
|
35362
|
-
const manifestSent = await
|
|
35407
|
+
const manifestSent = await readFile10(join17(dir, "manifest.json"), "utf8");
|
|
35363
35408
|
if (canonical5(JSON.parse(manifestSent)) !== canonical5(manifest)) {
|
|
35364
35409
|
throw new MigrateRefused("manifest.json changed while migrate read it. Run migrate again.");
|
|
35365
35410
|
}
|
|
@@ -35391,7 +35436,7 @@ async function runMigrate(dir, opts) {
|
|
|
35391
35436
|
return 0;
|
|
35392
35437
|
}
|
|
35393
35438
|
const files = applyDiff(preview.diff, sent);
|
|
35394
|
-
const manifestNow = await
|
|
35439
|
+
const manifestNow = await readFile10(join17(dir, "manifest.json"), "utf8");
|
|
35395
35440
|
if (manifestNow !== manifestSent) {
|
|
35396
35441
|
throw new MigrateRefused("manifest.json changed since migrate read it. Run migrate again.");
|
|
35397
35442
|
}
|
|
@@ -35498,7 +35543,7 @@ ${written.map((p) => ` ${p}
|
|
|
35498
35543
|
return 1;
|
|
35499
35544
|
}
|
|
35500
35545
|
}
|
|
35501
|
-
var _io = { rename: rename2, writeFile: writeFile9, realpath, rm:
|
|
35546
|
+
var _io = { rename: rename2, writeFile: writeFile9, realpath, rm: rm6 };
|
|
35502
35547
|
async function writable(dir, path3, sent) {
|
|
35503
35548
|
const full = join17(dir, path3);
|
|
35504
35549
|
const parts = path3.split("/");
|
|
@@ -35529,12 +35574,12 @@ async function writable(dir, path3, sent) {
|
|
|
35529
35574
|
throw new MigrateRefused(`${path3} is not a regular file (a link, or another kind); migrate writes only regular files.`);
|
|
35530
35575
|
}
|
|
35531
35576
|
try {
|
|
35532
|
-
await access(full,
|
|
35533
|
-
await access(dirname9(full),
|
|
35577
|
+
await access(full, constants2.W_OK);
|
|
35578
|
+
await access(dirname9(full), constants2.W_OK);
|
|
35534
35579
|
} catch {
|
|
35535
35580
|
throw new MigrateRefused(`${path3} cannot be written (no permission).`);
|
|
35536
35581
|
}
|
|
35537
|
-
const bytes = await
|
|
35582
|
+
const bytes = await readFile10(full);
|
|
35538
35583
|
const text4 = bytes.toString("utf8");
|
|
35539
35584
|
if (!Buffer.from(text4, "utf8").equals(bytes)) {
|
|
35540
35585
|
throw new MigrateRefused(`${path3} is not valid UTF-8; migrate would change bytes it did not mean to.`);
|
|
@@ -35619,12 +35664,12 @@ function registerMigrateCommand(parent) {
|
|
|
35619
35664
|
}
|
|
35620
35665
|
|
|
35621
35666
|
// src/commands/appspace/test.ts
|
|
35622
|
-
import { readFile as
|
|
35623
|
-
import { join as join19, resolve as
|
|
35667
|
+
import { readFile as readFile13 } from "fs/promises";
|
|
35668
|
+
import { join as join19, resolve as resolve17 } from "path";
|
|
35624
35669
|
|
|
35625
35670
|
// src/commands/appspace/_files.ts
|
|
35626
|
-
import { readFile as
|
|
35627
|
-
import { basename as basename3, extname, resolve as
|
|
35671
|
+
import { readFile as readFile11, realpath as realpath2 } from "fs/promises";
|
|
35672
|
+
import { basename as basename3, extname, resolve as resolve15, sep as sep6 } from "path";
|
|
35628
35673
|
|
|
35629
35674
|
// src/commands/appspace/_samplePdf.ts
|
|
35630
35675
|
function pdfString(text4) {
|
|
@@ -35781,11 +35826,11 @@ function readFailure(path3, full, err) {
|
|
|
35781
35826
|
if (code === void 0 || code === "ENOENT") return new Error(`no file at ${path3} (looked for ${full}).`);
|
|
35782
35827
|
return new Error(`could not read ${path3} (${String(code)}).`);
|
|
35783
35828
|
}
|
|
35784
|
-
async function resolveFile(path3, base, { read =
|
|
35829
|
+
async function resolveFile(path3, base, { read = readFile11, confine = false, realpath: real = realpath2 } = {}) {
|
|
35785
35830
|
if (path3 === null) {
|
|
35786
35831
|
return { bytes: sampleInvoiceBytes(), filename: SAMPLE_INVOICE.filename, mimeType: SAMPLE_INVOICE.mimeType };
|
|
35787
35832
|
}
|
|
35788
|
-
const full =
|
|
35833
|
+
const full = resolve15(base, path3);
|
|
35789
35834
|
if (confine) {
|
|
35790
35835
|
let target;
|
|
35791
35836
|
let root;
|
|
@@ -35827,7 +35872,7 @@ function fileColumnsOf(model) {
|
|
|
35827
35872
|
}
|
|
35828
35873
|
async function readFileColumns(dir) {
|
|
35829
35874
|
try {
|
|
35830
|
-
return fileColumnsOf(JSON.parse(await
|
|
35875
|
+
return fileColumnsOf(JSON.parse(await readFile11(resolve15(dir, "data_model.json"), "utf8")));
|
|
35831
35876
|
} catch {
|
|
35832
35877
|
return null;
|
|
35833
35878
|
}
|
|
@@ -37126,13 +37171,13 @@ var defaultBlobReader = async (blob) => {
|
|
|
37126
37171
|
function blobReaderFor(window) {
|
|
37127
37172
|
const ctor = window?.FileReader;
|
|
37128
37173
|
if (typeof ctor !== "function") return defaultBlobReader;
|
|
37129
|
-
return (blob) => new Promise((
|
|
37174
|
+
return (blob) => new Promise((resolve18, reject) => {
|
|
37130
37175
|
const reader = new ctor();
|
|
37131
37176
|
reader.onload = () => {
|
|
37132
37177
|
const result = reader.result;
|
|
37133
|
-
if (result === null || result === void 0)
|
|
37134
|
-
else if (typeof result === "string")
|
|
37135
|
-
else
|
|
37178
|
+
if (result === null || result === void 0) resolve18(Buffer.alloc(0));
|
|
37179
|
+
else if (typeof result === "string") resolve18(Buffer.from(result, "utf8"));
|
|
37180
|
+
else resolve18(Buffer.from(result));
|
|
37136
37181
|
};
|
|
37137
37182
|
reader.onerror = () => reject(new Error("the attached file could not be read"));
|
|
37138
37183
|
reader.onabort = () => reject(new Error("reading the attached file was aborted"));
|
|
@@ -37419,7 +37464,7 @@ async function loadJsdom() {
|
|
|
37419
37464
|
);
|
|
37420
37465
|
}
|
|
37421
37466
|
}
|
|
37422
|
-
var sleep = (ms) => new Promise((
|
|
37467
|
+
var sleep = (ms) => new Promise((resolve18) => setTimeout(resolve18, ms));
|
|
37423
37468
|
var DRAW_GRACE_MS = 3e3;
|
|
37424
37469
|
async function runUiSmoke(opts) {
|
|
37425
37470
|
const timeoutMs = opts.timeoutMs ?? 15e3;
|
|
@@ -37925,10 +37970,10 @@ async function runUiSmoke(opts) {
|
|
|
37925
37970
|
// src/commands/appspace/_screenshot.ts
|
|
37926
37971
|
import { spawn } from "child_process";
|
|
37927
37972
|
import { existsSync as existsSync3, statSync as statSync3 } from "fs";
|
|
37928
|
-
import { mkdir as mkdir8, mkdtemp as mkdtemp4, readFile as
|
|
37973
|
+
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
37974
|
import { createServer } from "http";
|
|
37930
37975
|
import { tmpdir as tmpdir5 } from "os";
|
|
37931
|
-
import { delimiter, extname as extname2, join as join18, relative as relative3, resolve as
|
|
37976
|
+
import { delimiter, extname as extname2, join as join18, relative as relative3, resolve as resolve16, sep as sep7 } from "path";
|
|
37932
37977
|
|
|
37933
37978
|
// ../tests/vendor/fixtures/widgets/kpi.json
|
|
37934
37979
|
var kpi_default = {
|
|
@@ -39120,8 +39165,8 @@ function contentType(path3) {
|
|
|
39120
39165
|
return TYPES[extname2(path3).toLowerCase()] ?? "application/octet-stream";
|
|
39121
39166
|
}
|
|
39122
39167
|
function inside(root, rel) {
|
|
39123
|
-
const base =
|
|
39124
|
-
const full =
|
|
39168
|
+
const base = resolve16(root);
|
|
39169
|
+
const full = resolve16(base, rel);
|
|
39125
39170
|
return full === base || !full.startsWith(base + sep7) ? null : full;
|
|
39126
39171
|
}
|
|
39127
39172
|
var Shelf = class {
|
|
@@ -39166,7 +39211,7 @@ var Shelf = class {
|
|
|
39166
39211
|
const full = inside(this.source.root, rel);
|
|
39167
39212
|
if (full === null) continue;
|
|
39168
39213
|
try {
|
|
39169
|
-
return { status: 200, type: contentType(full), body: await
|
|
39214
|
+
return { status: 200, type: contentType(full), body: await readFile12(full) };
|
|
39170
39215
|
} catch {
|
|
39171
39216
|
}
|
|
39172
39217
|
}
|
|
@@ -39436,7 +39481,7 @@ async function runChrome(run) {
|
|
|
39436
39481
|
}
|
|
39437
39482
|
} finally {
|
|
39438
39483
|
killGroup(child);
|
|
39439
|
-
await
|
|
39484
|
+
await rm7(profile, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }).catch(() => void 0);
|
|
39440
39485
|
}
|
|
39441
39486
|
if (ok) return { ok, stdout, profile };
|
|
39442
39487
|
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 +39604,7 @@ async function runScreenshots(opts) {
|
|
|
39559
39604
|
for (let attempt = 0; attempt < 2 && now() < pageUntil - 500; attempt++) {
|
|
39560
39605
|
id = nextId++;
|
|
39561
39606
|
stub.register(id, { role });
|
|
39562
|
-
await
|
|
39607
|
+
await rm7(out, { force: true });
|
|
39563
39608
|
result = await runChrome({
|
|
39564
39609
|
chrome: opts.chrome,
|
|
39565
39610
|
url: stub.urlFor(id, entry),
|
|
@@ -39588,7 +39633,7 @@ async function runScreenshots(opts) {
|
|
|
39588
39633
|
shots[index2] = { ...entryOut, error: result.error ?? "no picture" };
|
|
39589
39634
|
return;
|
|
39590
39635
|
}
|
|
39591
|
-
const bytes = await
|
|
39636
|
+
const bytes = await readFile12(out);
|
|
39592
39637
|
if (look && seen === void 0) toLook.push(index2);
|
|
39593
39638
|
shots[index2] = {
|
|
39594
39639
|
...entryOut,
|
|
@@ -39648,7 +39693,7 @@ async function readLocalUi(dir) {
|
|
|
39648
39693
|
for (const one of names) {
|
|
39649
39694
|
const full = join18(folder, one.name);
|
|
39650
39695
|
if (one.isDirectory()) await walk5(full);
|
|
39651
|
-
else if (one.isFile()) out[relative3(root, full).split(sep7).join("/")] = await
|
|
39696
|
+
else if (one.isFile()) out[relative3(root, full).split(sep7).join("/")] = await readFile12(full);
|
|
39652
39697
|
}
|
|
39653
39698
|
};
|
|
39654
39699
|
await walk5(root);
|
|
@@ -41188,13 +41233,13 @@ function roleFindings(contract, held) {
|
|
|
41188
41233
|
};
|
|
41189
41234
|
const visible = /* @__PURE__ */ new Set([held.own, ...held.sees]);
|
|
41190
41235
|
let mine = 0;
|
|
41191
|
-
let
|
|
41236
|
+
let open3 = 0;
|
|
41192
41237
|
const others = [];
|
|
41193
41238
|
let gatedElsewhere = 0;
|
|
41194
41239
|
for (const [uid, element] of Object.entries(elements)) {
|
|
41195
41240
|
if (typeof element.type !== "string" || !COMPONENT_TYPES7.has(element.type)) continue;
|
|
41196
41241
|
const gate = gateOf(uid);
|
|
41197
|
-
if (gate === null)
|
|
41242
|
+
if (gate === null) open3 += 1;
|
|
41198
41243
|
else if (visible.has(gate)) mine += 1;
|
|
41199
41244
|
else {
|
|
41200
41245
|
gatedElsewhere += 1;
|
|
@@ -41208,7 +41253,7 @@ function roleFindings(contract, held) {
|
|
|
41208
41253
|
{
|
|
41209
41254
|
code: "role-sees-nothing",
|
|
41210
41255
|
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(
|
|
41256
|
+
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
41257
|
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
41258
|
see: SEE.roles
|
|
41214
41259
|
}
|
|
@@ -41366,7 +41411,7 @@ function collectRoles(value, previous = []) {
|
|
|
41366
41411
|
}
|
|
41367
41412
|
async function readLocalManifest(dir) {
|
|
41368
41413
|
try {
|
|
41369
|
-
return JSON.parse(await
|
|
41414
|
+
return JSON.parse(await readFile13(join19(dir, "manifest.json"), "utf8"));
|
|
41370
41415
|
} catch {
|
|
41371
41416
|
return null;
|
|
41372
41417
|
}
|
|
@@ -41509,7 +41554,7 @@ async function loadFixtures(dir, explicit) {
|
|
|
41509
41554
|
const path3 = explicit ?? join19(dir, DEFAULT_FIXTURES);
|
|
41510
41555
|
let raw;
|
|
41511
41556
|
try {
|
|
41512
|
-
raw = await
|
|
41557
|
+
raw = await readFile13(path3, "utf8");
|
|
41513
41558
|
} catch {
|
|
41514
41559
|
if (explicit !== void 0) throw new Error(`no fixtures file at ${path3}.`);
|
|
41515
41560
|
return { fixtures: { cases: [], ui: { entry: "index.html" } } };
|
|
@@ -41531,7 +41576,7 @@ async function runHandlerCases(cases, dir, appId, client, roleOf = () => void 0)
|
|
|
41531
41576
|
if (!code.has(kase.handler)) {
|
|
41532
41577
|
code.set(
|
|
41533
41578
|
kase.handler,
|
|
41534
|
-
await
|
|
41579
|
+
await readFile13(join19(dir, "handlers", `${kase.handler}.py`), "utf8").catch(() => null)
|
|
41535
41580
|
);
|
|
41536
41581
|
}
|
|
41537
41582
|
const source = code.get(kase.handler);
|
|
@@ -41786,7 +41831,7 @@ function contractUid(contract, page, component) {
|
|
|
41786
41831
|
}
|
|
41787
41832
|
async function isDashboardFolder2(dir) {
|
|
41788
41833
|
try {
|
|
41789
|
-
const doc = JSON.parse(await
|
|
41834
|
+
const doc = JSON.parse(await readFile13(join19(dir, "contract.json"), "utf8"));
|
|
41790
41835
|
return doc.app?.kind === "dashboard";
|
|
41791
41836
|
} catch {
|
|
41792
41837
|
return false;
|
|
@@ -41987,7 +42032,7 @@ function mergeDomComponents(contract, components, page) {
|
|
|
41987
42032
|
async function writeMergedContract(dir, page, components) {
|
|
41988
42033
|
let contract;
|
|
41989
42034
|
try {
|
|
41990
|
-
contract = JSON.parse(await
|
|
42035
|
+
contract = JSON.parse(await readFile13(contractPath(dir), "utf8"));
|
|
41991
42036
|
} catch {
|
|
41992
42037
|
contract = await extractContract(dir);
|
|
41993
42038
|
}
|
|
@@ -41997,7 +42042,7 @@ async function writeMergedContract(dir, page, components) {
|
|
|
41997
42042
|
async function uiIsStale(dir, entry, stored) {
|
|
41998
42043
|
if (stored === void 0) return false;
|
|
41999
42044
|
try {
|
|
42000
|
-
const local = await
|
|
42045
|
+
const local = await readFile13(join19(dir, "ui", entry));
|
|
42001
42046
|
return !local.equals(Buffer.from(stored, "utf8"));
|
|
42002
42047
|
} catch {
|
|
42003
42048
|
return false;
|
|
@@ -42085,7 +42130,7 @@ function untouchedHandlers(declared, cases, interactions, runs = []) {
|
|
|
42085
42130
|
async function readSeed(dir) {
|
|
42086
42131
|
let parsed2;
|
|
42087
42132
|
try {
|
|
42088
|
-
parsed2 = JSON.parse(await
|
|
42133
|
+
parsed2 = JSON.parse(await readFile13(join19(dir, "seed.json"), "utf8"));
|
|
42089
42134
|
} catch {
|
|
42090
42135
|
return null;
|
|
42091
42136
|
}
|
|
@@ -42101,7 +42146,7 @@ async function readSeed(dir) {
|
|
|
42101
42146
|
}
|
|
42102
42147
|
async function handlerOwnership(dir, pushed) {
|
|
42103
42148
|
try {
|
|
42104
|
-
const local = JSON.parse(await
|
|
42149
|
+
const local = JSON.parse(await readFile13(join19(dir, "contract.json"), "utf8"));
|
|
42105
42150
|
const owned = ownershipOf(local);
|
|
42106
42151
|
if (owned !== null) return owned;
|
|
42107
42152
|
} catch {
|
|
@@ -42429,7 +42474,7 @@ function registerTestCommand(parent) {
|
|
|
42429
42474
|
const files = pushedPages ? store.bundle : await readLocalUi(dir);
|
|
42430
42475
|
const pages = pushedPages ? store.pages : orderPages(Object.keys(files));
|
|
42431
42476
|
const manifest = pushedPages && typeof store.manifest === "object" && store.manifest !== null ? store.manifest : await readLocalManifest(dir);
|
|
42432
|
-
const outDir =
|
|
42477
|
+
const outDir = resolve17(opts.out ?? join19(dir, ".screenshots"));
|
|
42433
42478
|
const index = await runScreenshots({
|
|
42434
42479
|
appId,
|
|
42435
42480
|
pages: choosePages(opts.pages, pages, fixtures.ui.entry).load,
|
|
@@ -42440,7 +42485,7 @@ function registerTestCommand(parent) {
|
|
|
42440
42485
|
allowedByRole: view.allowed,
|
|
42441
42486
|
sources: Object.keys(pushed?.data?.sources ?? {}),
|
|
42442
42487
|
cases: fixtures.cases,
|
|
42443
|
-
shelf: opts.shelf === void 0 ? { kind: "server", baseUrl: client.baseUrl } : { kind: "local", root:
|
|
42488
|
+
shelf: opts.shelf === void 0 ? { kind: "server", baseUrl: client.baseUrl } : { kind: "local", root: resolve17(opts.shelf) },
|
|
42444
42489
|
chrome,
|
|
42445
42490
|
outDir,
|
|
42446
42491
|
width: shotSize.width,
|
|
@@ -42548,12 +42593,12 @@ ${String(failed)} failure(s).
|
|
|
42548
42593
|
}
|
|
42549
42594
|
|
|
42550
42595
|
// src/commands/appspace/try.ts
|
|
42551
|
-
import { readFile as
|
|
42596
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
42552
42597
|
import { join as join20 } from "path";
|
|
42553
42598
|
function collect2(value, previous = []) {
|
|
42554
42599
|
return [...previous, value];
|
|
42555
42600
|
}
|
|
42556
|
-
async function readPayloadOption(raw, read = (path3) =>
|
|
42601
|
+
async function readPayloadOption(raw, read = (path3) => readFile14(path3, "utf8")) {
|
|
42557
42602
|
if (raw.startsWith("@")) {
|
|
42558
42603
|
const path3 = raw.slice(1);
|
|
42559
42604
|
if (path3 === "") throw new Error("--payload @ names no file; write --payload @./payload.json.");
|
|
@@ -42633,7 +42678,7 @@ function registerTryCommand(parent) {
|
|
|
42633
42678
|
).action(async (handler, opts) => {
|
|
42634
42679
|
requirePlainName("handler", handler, "read");
|
|
42635
42680
|
const appId = await readManifestId(opts.dir);
|
|
42636
|
-
const code = await
|
|
42681
|
+
const code = await readFile14(
|
|
42637
42682
|
join20(opts.dir, "handlers", `${handler}.py`),
|
|
42638
42683
|
"utf8"
|
|
42639
42684
|
).catch(() => {
|
|
@@ -43192,7 +43237,7 @@ ${METRIC_ADVICE}
|
|
|
43192
43237
|
// src/commands/appspace/secrets.ts
|
|
43193
43238
|
var SECRET_NAME_RE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
43194
43239
|
function promptHidden(label, input, output) {
|
|
43195
|
-
return new Promise((
|
|
43240
|
+
return new Promise((resolve18, reject) => {
|
|
43196
43241
|
let value = "";
|
|
43197
43242
|
output.write(label);
|
|
43198
43243
|
input.setRawMode?.(true);
|
|
@@ -43204,7 +43249,7 @@ function promptHidden(label, input, output) {
|
|
|
43204
43249
|
input.pause();
|
|
43205
43250
|
output.write("\n");
|
|
43206
43251
|
if (err !== null) reject(err);
|
|
43207
|
-
else
|
|
43252
|
+
else resolve18(value);
|
|
43208
43253
|
};
|
|
43209
43254
|
const onData = (chunk) => {
|
|
43210
43255
|
for (const ch of String(chunk)) {
|
|
@@ -43414,7 +43459,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
43414
43459
|
var REGISTRY = "https://datarails.jfrog.io/artifactory/api/npm/dr-cli-virtual";
|
|
43415
43460
|
var PACKAGE = "@datarails-ai/dr-appspace-cli";
|
|
43416
43461
|
function spawnInherit(command, args) {
|
|
43417
|
-
return new Promise((
|
|
43462
|
+
return new Promise((resolve18) => {
|
|
43418
43463
|
const child = spawn2(command, args, {
|
|
43419
43464
|
stdio: "inherit",
|
|
43420
43465
|
// Windows resolves `npm` as `npm.cmd`; `shell: true` lets cmd.exe do
|
|
@@ -43422,15 +43467,15 @@ function spawnInherit(command, args) {
|
|
|
43422
43467
|
shell: true
|
|
43423
43468
|
});
|
|
43424
43469
|
child.on("close", (code) => {
|
|
43425
|
-
|
|
43470
|
+
resolve18(code ?? 1);
|
|
43426
43471
|
});
|
|
43427
43472
|
child.on("error", () => {
|
|
43428
|
-
|
|
43473
|
+
resolve18(1);
|
|
43429
43474
|
});
|
|
43430
43475
|
});
|
|
43431
43476
|
}
|
|
43432
43477
|
function captureVersion() {
|
|
43433
|
-
return new Promise((
|
|
43478
|
+
return new Promise((resolve18) => {
|
|
43434
43479
|
const child = spawn2("dr-appspace", ["--version"], { shell: true });
|
|
43435
43480
|
let out = "";
|
|
43436
43481
|
child.stdout.on("data", (chunk) => {
|
|
@@ -43438,12 +43483,12 @@ function captureVersion() {
|
|
|
43438
43483
|
});
|
|
43439
43484
|
child.on("close", (code) => {
|
|
43440
43485
|
if (code !== 0) {
|
|
43441
|
-
|
|
43486
|
+
resolve18(null);
|
|
43442
43487
|
return;
|
|
43443
43488
|
}
|
|
43444
|
-
|
|
43489
|
+
resolve18(out.trim());
|
|
43445
43490
|
});
|
|
43446
|
-
child.on("error", () =>
|
|
43491
|
+
child.on("error", () => resolve18(null));
|
|
43447
43492
|
});
|
|
43448
43493
|
}
|
|
43449
43494
|
async function runUpdate() {
|