@datarails-ai/dr-appspace-cli 0.12.77 → 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 +449 -369
- 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()) {
|
|
@@ -10753,7 +10798,7 @@ function compile(contract, { kit, extra = {} } = {}) {
|
|
|
10753
10798
|
for (const page of pages) {
|
|
10754
10799
|
files[page.path] = pageFile(page, { contract: composed, pages, kit, problems });
|
|
10755
10800
|
}
|
|
10756
|
-
return { files, problems: problems.sort(byProblem2), warnings: narrativeOrderWarnings(composed, applied) };
|
|
10801
|
+
return { files, problems: problems.sort(byProblem2), warnings: [...narrativeOrderWarnings(composed, applied), ...undeclaredTableWarnings(composed)] };
|
|
10757
10802
|
}
|
|
10758
10803
|
var RUNTIME_RENDERER2 = "runtime";
|
|
10759
10804
|
function dashboardHandler(composed, handlerName, extra = {}) {
|
|
@@ -10882,6 +10927,8 @@ function manifestFile(contract, handlerName) {
|
|
|
10882
10927
|
handlers: { [handlerName]: { entrypoint: handlerPath(contract, handlerName), http: handlerHttp(contract, handlerName) } },
|
|
10883
10928
|
capabilities: isPlainObject6(app.capabilities) ? app.capabilities : { ...DEFAULT_CAPABILITIES }
|
|
10884
10929
|
};
|
|
10930
|
+
const { tables } = readTables(contract);
|
|
10931
|
+
if (tables.length > 0) manifest.sources = { tables };
|
|
10885
10932
|
return `${JSON.stringify(manifest, null, 2)}
|
|
10886
10933
|
`;
|
|
10887
10934
|
}
|
|
@@ -10973,17 +11020,17 @@ function handlerFile(contract, handlerName, written, library, transforms = {}) {
|
|
|
10973
11020
|
"contract, not this file."
|
|
10974
11021
|
].join("\n");
|
|
10975
11022
|
const imports = ["from appspace import widgets", ...written.imports].sort(natural3);
|
|
10976
|
-
const
|
|
11023
|
+
const constants3 = [];
|
|
10977
11024
|
if (library !== null && typeof library.version === "string") {
|
|
10978
|
-
|
|
10979
|
-
|
|
11025
|
+
constants3.push("# The release of the hook library this table was built against.");
|
|
11026
|
+
constants3.push(`LIBRARY_VERSION = ${pyString2(library.version)}`);
|
|
10980
11027
|
}
|
|
10981
|
-
for (const row of written.constants)
|
|
11028
|
+
for (const row of written.constants) constants3.push(row.text);
|
|
10982
11029
|
const carried = Object.keys(transforms).length > 0;
|
|
10983
11030
|
return writeModule({
|
|
10984
11031
|
docstring,
|
|
10985
11032
|
imports,
|
|
10986
|
-
constants:
|
|
11033
|
+
constants: constants3,
|
|
10987
11034
|
tables: carried ? [written.text, transformsTable(transforms)] : [written.text],
|
|
10988
11035
|
body: [
|
|
10989
11036
|
"def handle(ctx, payload):",
|
|
@@ -11155,8 +11202,8 @@ function controlRow(elements) {
|
|
|
11155
11202
|
parts.push(`data-dr-control="${attr(props.param ?? control.binding ?? "")}"`);
|
|
11156
11203
|
if (props.control_kind) parts.push(`data-dr-control-kind="${attr(props.control_kind)}"`);
|
|
11157
11204
|
const classes = (control.classes ?? []).join(" ");
|
|
11158
|
-
const
|
|
11159
|
-
out.push(` <${control.tag ?? "input"}${
|
|
11205
|
+
const open3 = classes === "" ? "" : ` class="${attr(classes)}"`;
|
|
11206
|
+
out.push(` <${control.tag ?? "input"}${open3} ${parts.join(" ")} />`);
|
|
11160
11207
|
out.push(" </span>");
|
|
11161
11208
|
}
|
|
11162
11209
|
out.push("</div>");
|
|
@@ -11348,7 +11395,7 @@ function compileDashboard(contract, { kit = null, extra = {}, uiKit, charts, fmt
|
|
|
11348
11395
|
files[handlerPath(composed, handlerName)] = handler.text;
|
|
11349
11396
|
const shelf2 = { runtime: DASHBOARD_RUNTIME, widgets: DASHBOARD_WIDGETS, bar: DASHBOARD_BAR, assistant, markdown, uiKit, charts, fmt, appComponents, appControls };
|
|
11350
11397
|
for (const page of whole.pages) files[page.path] = pageHtml(whole, page, elements, tree, shelf2);
|
|
11351
|
-
return { files, problems, contract: whole, order: order2, warnings: [...warnings, ...narrativeOrderWarnings(composed, applied)] };
|
|
11398
|
+
return { files, problems, contract: whole, order: order2, warnings: [...warnings, ...narrativeOrderWarnings(composed, applied), ...undeclaredTableWarnings(composed)] };
|
|
11352
11399
|
}
|
|
11353
11400
|
function isRefusal(problem6) {
|
|
11354
11401
|
return problem6.lossy !== false;
|
|
@@ -12917,6 +12964,37 @@ function sourcesOf(contract) {
|
|
|
12917
12964
|
function readsMetric(read) {
|
|
12918
12965
|
return isPlainObject8(read) && (read.metric_id !== void 0 && read.metric_id !== null || read.metric !== void 0 && read.metric !== null);
|
|
12919
12966
|
}
|
|
12967
|
+
function readTables(contract) {
|
|
12968
|
+
const tables = [];
|
|
12969
|
+
const aliased = [];
|
|
12970
|
+
const walk5 = (node, pointer2) => {
|
|
12971
|
+
if (Array.isArray(node)) {
|
|
12972
|
+
node.forEach((one, index) => walk5(one, `${pointer2}/${index}`));
|
|
12973
|
+
return;
|
|
12974
|
+
}
|
|
12975
|
+
if (!isPlainObject8(node)) return;
|
|
12976
|
+
if ((Object.hasOwn(node, "table_id") || Object.hasOwn(node, "table_alias")) && !readsMetric(node)) {
|
|
12977
|
+
const id = tableIdOf(node.table_id);
|
|
12978
|
+
if (id !== null && !tables.includes(id)) tables.push(id);
|
|
12979
|
+
if (id === null && named5(node.table_alias)) aliased.push(pointer2);
|
|
12980
|
+
return;
|
|
12981
|
+
}
|
|
12982
|
+
for (const key of Object.keys(node).sort(natural3)) walk5(node[key], `${pointer2}/${escapePointer3(key)}`);
|
|
12983
|
+
};
|
|
12984
|
+
walk5(contract?.data, "/data");
|
|
12985
|
+
return { tables, aliased };
|
|
12986
|
+
}
|
|
12987
|
+
function tableIdOf(value) {
|
|
12988
|
+
const id = typeof value === "number" ? value : typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value.trim()) : NaN;
|
|
12989
|
+
return Number.isSafeInteger(id) && id > 0 ? id : null;
|
|
12990
|
+
}
|
|
12991
|
+
function undeclaredTableWarnings(contract) {
|
|
12992
|
+
return readTables(contract).aliased.map((pointer2) => ({
|
|
12993
|
+
code: "table_not_declared",
|
|
12994
|
+
pointer: pointer2,
|
|
12995
|
+
message: `${pointer2} reads its table by table_alias alone, so the manifest cannot list it in sources.tables and sharing this app will not offer a grantee access to it; add the table's numeric table_id beside the alias`
|
|
12996
|
+
}));
|
|
12997
|
+
}
|
|
12920
12998
|
var FINANCEOS_SCOPES = {
|
|
12921
12999
|
commands: {
|
|
12922
13000
|
"status:read": ["status", "whoami"],
|
|
@@ -14084,7 +14162,7 @@ function tokenValueProblem(value) {
|
|
|
14084
14162
|
if (value.includes("<")) return "holds <, which no CSS value needs";
|
|
14085
14163
|
if (/url\s*\(/i.test(value)) return "holds url(, and a theme loads nothing";
|
|
14086
14164
|
const closing = { ")": "(", "]": "[" };
|
|
14087
|
-
const
|
|
14165
|
+
const open3 = [];
|
|
14088
14166
|
let quote = null;
|
|
14089
14167
|
for (const ch of value) {
|
|
14090
14168
|
if (quote !== null) {
|
|
@@ -14092,11 +14170,11 @@ function tokenValueProblem(value) {
|
|
|
14092
14170
|
continue;
|
|
14093
14171
|
}
|
|
14094
14172
|
if (ch === '"' || ch === "'") quote = ch;
|
|
14095
|
-
else if (ch === "(" || ch === "[")
|
|
14096
|
-
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";
|
|
14097
14175
|
}
|
|
14098
14176
|
if (quote !== null) return "holds an unbalanced quote";
|
|
14099
|
-
if (
|
|
14177
|
+
if (open3.length > 0) return "holds an unbalanced bracket";
|
|
14100
14178
|
return null;
|
|
14101
14179
|
}
|
|
14102
14180
|
function appIdProblems(app) {
|
|
@@ -14694,7 +14772,7 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
14694
14772
|
}
|
|
14695
14773
|
if (typeof extra["seed.json"] === "string") files["seed.json"] = extra["seed.json"];
|
|
14696
14774
|
files["tests.json"] = typeof extra["tests.json"] === "string" ? extra["tests.json"] : json(testsOf(handlers, names, sources, served, model));
|
|
14697
|
-
return { files, problems, contract: whole, order: order2, warnings };
|
|
14775
|
+
return { files, problems, contract: whole, order: order2, warnings: [...warnings, ...undeclaredTableWarnings(contract)] };
|
|
14698
14776
|
}
|
|
14699
14777
|
function refreshPins(contract, compiled, files) {
|
|
14700
14778
|
if (!Array.isArray(contract.pins)) return contract;
|
|
@@ -17462,7 +17540,7 @@ function measuredSummary(row) {
|
|
|
17462
17540
|
];
|
|
17463
17541
|
}
|
|
17464
17542
|
const body = ["def handle(ctx, payload):", " del payload", ' table = ctx.data.table(HANDLER["table"])', " answer = {}", ...loop, " return answer"].join("\n");
|
|
17465
|
-
const
|
|
17543
|
+
const constants3 = [assignment("MEASURES", measures, Object.keys(measures))];
|
|
17466
17544
|
if (kinds.length === 0) {
|
|
17467
17545
|
return {
|
|
17468
17546
|
docstring: `Answer each tile on the page with a count of the events of ${row.table}.
|
|
@@ -17474,7 +17552,7 @@ wrote it \u2014 so none counts an event of a row this caller may not see.
|
|
|
17474
17552
|
|
|
17475
17553
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17476
17554
|
contract, not this file.`,
|
|
17477
|
-
constants:
|
|
17555
|
+
constants: constants3,
|
|
17478
17556
|
body
|
|
17479
17557
|
};
|
|
17480
17558
|
}
|
|
@@ -17488,7 +17566,7 @@ may not see. \`$today\` and its siblings are UTC. An average over no rows is
|
|
|
17488
17566
|
None, which a stat shows as a dash.
|
|
17489
17567
|
|
|
17490
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.",
|
|
17491
|
-
constants:
|
|
17569
|
+
constants: constants3,
|
|
17492
17570
|
body
|
|
17493
17571
|
};
|
|
17494
17572
|
}
|
|
@@ -17535,6 +17613,8 @@ function manifestOf(contract, app, handlers, names, model, served = [], readers
|
|
|
17535
17613
|
}
|
|
17536
17614
|
manifest.handlers = Object.fromEntries(Object.keys(manifest.handlers).sort(natural3).map((name) => [name, manifest.handlers[name]]));
|
|
17537
17615
|
manifest.capabilities = isPlainObject8(app.capabilities) && Object.keys(app.capabilities).length > 0 ? app.capabilities : { data: ["rw"] };
|
|
17616
|
+
const { tables } = readTables(contract);
|
|
17617
|
+
if (tables.length > 0) manifest.sources = { tables };
|
|
17538
17618
|
return manifest;
|
|
17539
17619
|
}
|
|
17540
17620
|
function routesOf2(app, pages) {
|
|
@@ -17655,8 +17735,8 @@ function notOwnLines(row, id, verb, indent2) {
|
|
|
17655
17735
|
function singletonSave(row, table) {
|
|
17656
17736
|
const enums = enumsOf(row, table);
|
|
17657
17737
|
const refs = refsOf(row, table);
|
|
17658
|
-
const
|
|
17659
|
-
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)));
|
|
17660
17740
|
return {
|
|
17661
17741
|
docstring: `Save the ${singular(row.table)}: the table holds one row, so there is no id to send.
|
|
17662
17742
|
|
|
@@ -17668,7 +17748,7 @@ rather than written.
|
|
|
17668
17748
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17669
17749
|
contract, not this file.`,
|
|
17670
17750
|
imports: Object.keys(refs).length > 0 ? ["import uuid"] : [],
|
|
17671
|
-
constants:
|
|
17751
|
+
constants: constants3,
|
|
17672
17752
|
body: [
|
|
17673
17753
|
"def handle(ctx, payload):",
|
|
17674
17754
|
...collectRow(row, enums),
|
|
@@ -17948,8 +18028,8 @@ contract, not this file.`,
|
|
|
17948
18028
|
const enums = enumsOf(row, table);
|
|
17949
18029
|
const refs = refsOf(row, table);
|
|
17950
18030
|
const guarded = named5(row.guard);
|
|
17951
|
-
const
|
|
17952
|
-
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)));
|
|
17953
18033
|
const guardDoc = guarded ? `
|
|
17954
18034
|
|
|
17955
18035
|
\`guard\` holds an edit to one state: only a row that is still ${row.guard} may be
|
|
@@ -17966,7 +18046,7 @@ is a column anyone may set.${guardDoc}
|
|
|
17966
18046
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
17967
18047
|
contract, not this file.`,
|
|
17968
18048
|
imports: Object.keys(refs).length > 0 || guarded ? ["import uuid"] : [],
|
|
17969
|
-
constants:
|
|
18049
|
+
constants: constants3,
|
|
17970
18050
|
body: [
|
|
17971
18051
|
"def handle(ctx, payload):",
|
|
17972
18052
|
...collectRow(row, enums),
|
|
@@ -18005,9 +18085,9 @@ contract, not this file.`,
|
|
|
18005
18085
|
submit: (name, row, table, model) => {
|
|
18006
18086
|
const enums = enumsOf(row, table);
|
|
18007
18087
|
const decimals = decimalsOf(row, table);
|
|
18008
|
-
const
|
|
18009
|
-
if (Object.keys(enums).length > 0)
|
|
18010
|
-
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)}`);
|
|
18011
18091
|
const lines = ["def handle(ctx, payload):", ...collectRow(row, enums)];
|
|
18012
18092
|
if (decimals.length > 0) {
|
|
18013
18093
|
lines.push(
|
|
@@ -18021,17 +18101,17 @@ contract, not this file.`,
|
|
|
18021
18101
|
}
|
|
18022
18102
|
const refs = refsOf(row, table);
|
|
18023
18103
|
if (Object.keys(refs).length > 0) {
|
|
18024
|
-
|
|
18104
|
+
constants3.push(assignment("REFS", refs, Object.keys(refs)));
|
|
18025
18105
|
lines.push(...refLines());
|
|
18026
18106
|
}
|
|
18027
18107
|
const parent = linkedParent(row, model);
|
|
18028
18108
|
if (parent !== null) {
|
|
18029
|
-
|
|
18109
|
+
constants3.push(`PARENT = ${pyString(parent)}`);
|
|
18030
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`)}}` }));
|
|
18031
18111
|
lines.push(' row[HANDLER["by"]] = parent_id');
|
|
18032
18112
|
}
|
|
18033
18113
|
if (isPlainObject8(row.requires)) {
|
|
18034
|
-
|
|
18114
|
+
constants3.push(...requiresConstants(row, model));
|
|
18035
18115
|
lines.push(...requiresLines(row, "saved"));
|
|
18036
18116
|
}
|
|
18037
18117
|
if (isPlainObject8(row.fixed) && Object.keys(row.fixed).length > 0) lines.push(' row.update(HANDLER["fixed"])');
|
|
@@ -18050,7 +18130,7 @@ browser could choose is a status anyone can choose.${linkDoc}${requiresDoc(row)}
|
|
|
18050
18130
|
Generated by dashboard-kit/contract compile from contract.json \u2014 edit the
|
|
18051
18131
|
contract, not this file.`,
|
|
18052
18132
|
imports: [...parent !== null || Object.keys(refs).length > 0 ? ["import uuid"] : [], ...decimals.length > 0 ? ["from decimal import Decimal, InvalidOperation"] : []],
|
|
18053
|
-
constants:
|
|
18133
|
+
constants: constants3,
|
|
18054
18134
|
body: lines.join("\n")
|
|
18055
18135
|
};
|
|
18056
18136
|
},
|
|
@@ -18437,9 +18517,9 @@ function nodeLines(uid, contract, page, elements, tree, model, depth) {
|
|
|
18437
18517
|
const lede = named5(header.summary) ? `<p>${text2(header.summary)}</p>` : "";
|
|
18438
18518
|
const actions = Array.isArray(header.actions) && header.actions.length > 0 ? ` data-dr-header-actions="${attr2(JSON.stringify(header.actions))}"` : "";
|
|
18439
18519
|
const from = named5(header.title_from) ? ` data-dr-title-from="${attr2(header.title_from)}"` : "";
|
|
18440
|
-
const
|
|
18441
|
-
if (kids.length === 0) return [`${
|
|
18442
|
-
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>`];
|
|
18443
18523
|
}
|
|
18444
18524
|
case "nav": {
|
|
18445
18525
|
const entries = (contract.pages ?? []).map((one) => {
|
|
@@ -21515,11 +21595,11 @@ function clone4(value) {
|
|
|
21515
21595
|
}
|
|
21516
21596
|
|
|
21517
21597
|
// src/commands/appspace/contract.ts
|
|
21518
|
-
import { mkdir as mkdir2, readFile as
|
|
21598
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
21519
21599
|
import { join as join6 } from "path";
|
|
21520
21600
|
|
|
21521
21601
|
// src/commands/appspace/_folder.ts
|
|
21522
|
-
import { readFile as
|
|
21602
|
+
import { readFile as readFile2, readdir, stat, writeFile as writeFile2 } from "fs/promises";
|
|
21523
21603
|
import { join as join5 } from "path";
|
|
21524
21604
|
|
|
21525
21605
|
// src/commands/appspace/_handlerNames.ts
|
|
@@ -21554,7 +21634,7 @@ function handlerFileProblem(file) {
|
|
|
21554
21634
|
// src/commands/appspace/_folder.ts
|
|
21555
21635
|
async function readIfPresent(path3) {
|
|
21556
21636
|
try {
|
|
21557
|
-
return await
|
|
21637
|
+
return await readFile2(path3, "utf8");
|
|
21558
21638
|
} catch {
|
|
21559
21639
|
return void 0;
|
|
21560
21640
|
}
|
|
@@ -21583,7 +21663,7 @@ async function readUiTree(uiDir) {
|
|
|
21583
21663
|
continue;
|
|
21584
21664
|
}
|
|
21585
21665
|
if (!entry.isFile()) continue;
|
|
21586
|
-
out.push({ path: `${prefix}${name}`, bytes: await
|
|
21666
|
+
out.push({ path: `${prefix}${name}`, bytes: await readFile2(full) });
|
|
21587
21667
|
}
|
|
21588
21668
|
};
|
|
21589
21669
|
await walk5(uiDir, "");
|
|
@@ -21636,7 +21716,7 @@ async function readHandlers(handlersDir, state) {
|
|
|
21636
21716
|
const method = recorded?.[name];
|
|
21637
21717
|
handlers[name] = {
|
|
21638
21718
|
http: typeof method === "string" && method !== "" ? method : "POST",
|
|
21639
|
-
code: await
|
|
21719
|
+
code: await readFile2(join5(handlersDir, file), "utf8")
|
|
21640
21720
|
};
|
|
21641
21721
|
}
|
|
21642
21722
|
return handlers;
|
|
@@ -21703,7 +21783,7 @@ async function readLib(libDir) {
|
|
|
21703
21783
|
`);
|
|
21704
21784
|
continue;
|
|
21705
21785
|
}
|
|
21706
|
-
lib[name] = await
|
|
21786
|
+
lib[name] = await readFile2(full, "utf8");
|
|
21707
21787
|
}
|
|
21708
21788
|
return lib;
|
|
21709
21789
|
}
|
|
@@ -21787,7 +21867,7 @@ async function extractContract(dir) {
|
|
|
21787
21867
|
}
|
|
21788
21868
|
async function readModelIfPresent(dir) {
|
|
21789
21869
|
try {
|
|
21790
|
-
return await
|
|
21870
|
+
return await readFile3(join6(dir, "data_model.json"), "utf8");
|
|
21791
21871
|
} catch {
|
|
21792
21872
|
return void 0;
|
|
21793
21873
|
}
|
|
@@ -21849,7 +21929,7 @@ ${summarise(contract)}
|
|
|
21849
21929
|
}
|
|
21850
21930
|
|
|
21851
21931
|
// src/commands/appspace/liveness.ts
|
|
21852
|
-
import { readFile as
|
|
21932
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
21853
21933
|
import { join as join7 } from "path";
|
|
21854
21934
|
|
|
21855
21935
|
// ../flows/insights-builder/kit/checks/rules/liveness.mjs
|
|
@@ -22015,7 +22095,7 @@ async function runLiveness(dir, appId, whole, client, only) {
|
|
|
22015
22095
|
}
|
|
22016
22096
|
let code;
|
|
22017
22097
|
try {
|
|
22018
|
-
code = await
|
|
22098
|
+
code = await readFile4(join7(dir, handler.file), "utf8");
|
|
22019
22099
|
} catch {
|
|
22020
22100
|
return unchecked(
|
|
22021
22101
|
`${handler.file} is not in this folder, so no handler was run`
|
|
@@ -22197,7 +22277,7 @@ function render2(result, declared) {
|
|
|
22197
22277
|
|
|
22198
22278
|
// src/commands/appspace/preview.ts
|
|
22199
22279
|
import { spawnSync } from "child_process";
|
|
22200
|
-
import { readFile as
|
|
22280
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
22201
22281
|
import { tmpdir } from "os";
|
|
22202
22282
|
var lintTransform2 = lintTransform;
|
|
22203
22283
|
var FORBIDDEN_CALLS2 = FORBIDDEN_CALLS;
|
|
@@ -22561,7 +22641,7 @@ function registerPreviewCommand(parent) {
|
|
|
22561
22641
|
).option("--payload <json>", 'The request to serve (default: {"op": "load"}).')
|
|
22562
22642
|
)
|
|
22563
22643
|
).action(async (file, opts) => {
|
|
22564
|
-
const text4 = await
|
|
22644
|
+
const text4 = await readFile5(file, "utf8").catch(() => {
|
|
22565
22645
|
throw new Error(`cannot read ${file}`);
|
|
22566
22646
|
});
|
|
22567
22647
|
let document;
|
|
@@ -22716,7 +22796,7 @@ async function previewOne(document, file, opts, shared = {}) {
|
|
|
22716
22796
|
}
|
|
22717
22797
|
|
|
22718
22798
|
// src/commands/appspace/push.ts
|
|
22719
|
-
import { readFile as
|
|
22799
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
22720
22800
|
import { join as join8 } from "path";
|
|
22721
22801
|
import { gunzipSync, gzipSync } from "zlib";
|
|
22722
22802
|
|
|
@@ -24514,7 +24594,7 @@ async function pushBody(dir, opts) {
|
|
|
24514
24594
|
handlers,
|
|
24515
24595
|
frontend_bundle: ui?.field === "frontend_bundle" ? ui.files : null,
|
|
24516
24596
|
publish: opts.publish === true,
|
|
24517
|
-
seed: (opts.seed ?? "") === "" ? null : JSON.parse(await
|
|
24597
|
+
seed: (opts.seed ?? "") === "" ? null : JSON.parse(await readFile6(opts.seed, "utf8"))
|
|
24518
24598
|
};
|
|
24519
24599
|
if (ui?.field === "frontend_bundle_gz") {
|
|
24520
24600
|
body["frontend_bundle_gz"] = ui.files;
|
|
@@ -24671,13 +24751,13 @@ async function pushFolder(dir, opts) {
|
|
|
24671
24751
|
}
|
|
24672
24752
|
|
|
24673
24753
|
// src/commands/appspace/get.ts
|
|
24674
|
-
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";
|
|
24675
24755
|
import { tmpdir as tmpdir2 } from "os";
|
|
24676
24756
|
import { dirname as dirname3, join as join10 } from "path";
|
|
24677
24757
|
|
|
24678
24758
|
// src/commands/appspace/generate/report.ts
|
|
24679
24759
|
import { createHash as createHash3 } from "crypto";
|
|
24680
|
-
import { mkdir as mkdir3, readFile as
|
|
24760
|
+
import { mkdir as mkdir3, readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
|
|
24681
24761
|
import { join as join9 } from "path";
|
|
24682
24762
|
function reportPath(dir) {
|
|
24683
24763
|
return join9(dir, ".appspace", "compile.json");
|
|
@@ -24718,7 +24798,7 @@ async function writeReport(dir, report) {
|
|
|
24718
24798
|
}
|
|
24719
24799
|
async function ownedFiles(dir) {
|
|
24720
24800
|
try {
|
|
24721
|
-
const parsed2 = JSON.parse(await
|
|
24801
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24722
24802
|
if (!Array.isArray(parsed2.files)) return /* @__PURE__ */ new Set();
|
|
24723
24803
|
return new Set(parsed2.files.map(String));
|
|
24724
24804
|
} catch {
|
|
@@ -24727,7 +24807,7 @@ async function ownedFiles(dir) {
|
|
|
24727
24807
|
}
|
|
24728
24808
|
async function recordedRenderer(dir) {
|
|
24729
24809
|
try {
|
|
24730
|
-
const parsed2 = JSON.parse(await
|
|
24810
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24731
24811
|
if (parsed2.kind !== "dashboard") return null;
|
|
24732
24812
|
return parsed2.renderer === "runtime" || parsed2.renderer === "widgets" ? parsed2.renderer : null;
|
|
24733
24813
|
} catch {
|
|
@@ -24739,7 +24819,7 @@ function digestOf(text4) {
|
|
|
24739
24819
|
}
|
|
24740
24820
|
async function recordedDigests(dir) {
|
|
24741
24821
|
try {
|
|
24742
|
-
const parsed2 = JSON.parse(await
|
|
24822
|
+
const parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24743
24823
|
const held = parsed2.digests;
|
|
24744
24824
|
if (typeof held !== "object" || held === null || Array.isArray(held)) return {};
|
|
24745
24825
|
return Object.fromEntries(Object.entries(held).filter((entry) => typeof entry[1] === "string"));
|
|
@@ -24750,7 +24830,7 @@ async function recordedDigests(dir) {
|
|
|
24750
24830
|
async function recordAsInput(dir, path3) {
|
|
24751
24831
|
let parsed2;
|
|
24752
24832
|
try {
|
|
24753
|
-
parsed2 = JSON.parse(await
|
|
24833
|
+
parsed2 = JSON.parse(await readFile7(reportPath(dir), "utf8"));
|
|
24754
24834
|
} catch {
|
|
24755
24835
|
return;
|
|
24756
24836
|
}
|
|
@@ -24788,7 +24868,7 @@ async function unpushedInputs(dir, pkg) {
|
|
|
24788
24868
|
const out = await unpushedLib(dir, pkg);
|
|
24789
24869
|
let inputs = [];
|
|
24790
24870
|
try {
|
|
24791
|
-
const parsed2 = JSON.parse(await
|
|
24871
|
+
const parsed2 = JSON.parse(await readFile8(reportPath(dir), "utf8"));
|
|
24792
24872
|
if (Array.isArray(parsed2.inputs)) inputs = parsed2.inputs.map(String);
|
|
24793
24873
|
} catch {
|
|
24794
24874
|
return out;
|
|
@@ -24822,9 +24902,9 @@ async function unpushedLib(dir, pkg) {
|
|
|
24822
24902
|
async function writePackage(dir, appId, pkg) {
|
|
24823
24903
|
await mkdir4(dir, { recursive: true });
|
|
24824
24904
|
await Promise.all([
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
|
|
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 })
|
|
24828
24908
|
]);
|
|
24829
24909
|
const connected = pkg.connect_tables ?? {};
|
|
24830
24910
|
const manifestOut = Object.keys(connected).length > 0 ? { ...pkg.manifest, connect_tables: connected } : pkg.manifest;
|
|
@@ -24863,7 +24943,7 @@ async function writePackage(dir, appId, pkg) {
|
|
|
24863
24943
|
}
|
|
24864
24944
|
}
|
|
24865
24945
|
for (const file of await readDirIfPresent(libDir)) {
|
|
24866
|
-
if (file.endsWith(".py")) await
|
|
24946
|
+
if (file.endsWith(".py")) await rm3(join10(libDir, file), { force: true });
|
|
24867
24947
|
}
|
|
24868
24948
|
for (const [name, code] of Object.entries(pkg.lib)) {
|
|
24869
24949
|
await mkdir4(libDir, { recursive: true });
|
|
@@ -24947,7 +25027,7 @@ async function writeOwnedFiles(dir, document, { force = false } = {}) {
|
|
|
24947
25027
|
}
|
|
24948
25028
|
async function isDashboardFolder(dir) {
|
|
24949
25029
|
try {
|
|
24950
|
-
const manifest = JSON.parse(await
|
|
25030
|
+
const manifest = JSON.parse(await readFile8(join10(dir, "manifest.json"), "utf8"));
|
|
24951
25031
|
return manifest["kind"] === "dashboard";
|
|
24952
25032
|
} catch {
|
|
24953
25033
|
return false;
|
|
@@ -24957,7 +25037,7 @@ var OWNED_TEXT_PATH = /^transforms\/[a-z][a-z0-9_]*\.py$/;
|
|
|
24957
25037
|
async function restoreOwnedFiles(dir, contractWritten, { force }) {
|
|
24958
25038
|
let stated2 = [];
|
|
24959
25039
|
if (contractWritten) {
|
|
24960
|
-
const doc = JSON.parse(await
|
|
25040
|
+
const doc = JSON.parse(await readFile8(join10(dir, "contract.json"), "utf8"));
|
|
24961
25041
|
if (Array.isArray(doc["owned"])) stated2 = doc["owned"];
|
|
24962
25042
|
}
|
|
24963
25043
|
const known = new Set(
|
|
@@ -25009,7 +25089,7 @@ async function pullInto(client, appId, dir, {
|
|
|
25009
25089
|
if (err instanceof AppSpaceHttpError && err.status === 404) return null;
|
|
25010
25090
|
throw err;
|
|
25011
25091
|
}
|
|
25012
|
-
await
|
|
25092
|
+
await rm3(join10(dir, "contract.json"), { force: true });
|
|
25013
25093
|
await writePackage(dir, appId, pkg);
|
|
25014
25094
|
const read = await readStoredContract(client, appId, pkg.code_version);
|
|
25015
25095
|
if ("document" in read) {
|
|
@@ -25086,9 +25166,9 @@ function registerGetCommand(parent) {
|
|
|
25086
25166
|
}
|
|
25087
25167
|
|
|
25088
25168
|
// src/commands/appspace/packageCheck.ts
|
|
25089
|
-
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";
|
|
25090
25170
|
import { tmpdir as tmpdir3 } from "os";
|
|
25091
|
-
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";
|
|
25092
25172
|
var WHAT = "package";
|
|
25093
25173
|
async function checkPackage(dir, files, contract, opts, online, pendingMetricKeys = []) {
|
|
25094
25174
|
const badName = await handlerNameProblems(dir, files);
|
|
@@ -25140,7 +25220,7 @@ async function checkPackage(dir, files, contract, opts, online, pendingMetricKey
|
|
|
25140
25220
|
client.cleanup();
|
|
25141
25221
|
}
|
|
25142
25222
|
} finally {
|
|
25143
|
-
await
|
|
25223
|
+
await rm4(scratch, { recursive: true, force: true });
|
|
25144
25224
|
}
|
|
25145
25225
|
}
|
|
25146
25226
|
async function handlerNameProblems(dir, files) {
|
|
@@ -25316,9 +25396,9 @@ async function stage(dir, scratch, files) {
|
|
|
25316
25396
|
recursive: true,
|
|
25317
25397
|
filter: (source) => !/[\\/](node_modules|\.git)$/.test(source)
|
|
25318
25398
|
});
|
|
25319
|
-
const root =
|
|
25399
|
+
const root = resolve6(scratch);
|
|
25320
25400
|
for (const [path3, text4] of Object.entries(files)) {
|
|
25321
|
-
const full =
|
|
25401
|
+
const full = resolve6(root, path3);
|
|
25322
25402
|
if (!full.startsWith(root + sep2)) {
|
|
25323
25403
|
return `the package names a path outside its folder (${JSON.stringify(path3)})`;
|
|
25324
25404
|
}
|
|
@@ -25502,7 +25582,7 @@ function isPlainObject10(value) {
|
|
|
25502
25582
|
|
|
25503
25583
|
// ../flows/insights-builder/kit/checks/verify.mjs
|
|
25504
25584
|
import { readFileSync as readFileSync3 } from "fs";
|
|
25505
|
-
import { dirname as dirname5, join as join12, resolve as
|
|
25585
|
+
import { dirname as dirname5, join as join12, resolve as resolve8 } from "path";
|
|
25506
25586
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
25507
25587
|
|
|
25508
25588
|
// ../flows/insights-builder/kit/checks/lib/executable.mjs
|
|
@@ -26386,10 +26466,10 @@ function checkControl(el, boxes, where2) {
|
|
|
26386
26466
|
}
|
|
26387
26467
|
function controlBoxes(text4) {
|
|
26388
26468
|
const boxes = [];
|
|
26389
|
-
const
|
|
26469
|
+
const open3 = new RegExp(`<([a-zA-Z][\\w-]*)([^>]*\\b${KIT_MARK}\\s*=\\s*["'](?:${[...CONTROL_BOXES].join("|")})["'][^>]*)>`, "g");
|
|
26390
26470
|
let match;
|
|
26391
|
-
while ((match =
|
|
26392
|
-
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))]);
|
|
26393
26473
|
}
|
|
26394
26474
|
return boxes;
|
|
26395
26475
|
}
|
|
@@ -26701,7 +26781,7 @@ function checkTheme(app) {
|
|
|
26701
26781
|
const overrides = rootTokens(file.text);
|
|
26702
26782
|
if (overrides.size === 0) return { violations };
|
|
26703
26783
|
for (const theme of themesInUse(app)) {
|
|
26704
|
-
const ground = rgbOf2(overrides.has("--dr-surface") ?
|
|
26784
|
+
const ground = rgbOf2(overrides.has("--dr-surface") ? resolve7("--dr-surface", overrides) : THEME_SURFACES[theme]);
|
|
26705
26785
|
if (!ground) {
|
|
26706
26786
|
const surface = overrides.get("--dr-surface");
|
|
26707
26787
|
violations.push({
|
|
@@ -26714,7 +26794,7 @@ function checkTheme(app) {
|
|
|
26714
26794
|
for (const [token, { line: line2 }] of overrides) {
|
|
26715
26795
|
const rule = FLOORS.get(token);
|
|
26716
26796
|
if (!rule) continue;
|
|
26717
|
-
const value =
|
|
26797
|
+
const value = resolve7(token, overrides);
|
|
26718
26798
|
if (value === null) continue;
|
|
26719
26799
|
const series = /^--dr-chart-(\d+)$/.exec(token);
|
|
26720
26800
|
if (series && isPlatformChartColour(Number(series[1]), value)) continue;
|
|
@@ -26762,12 +26842,12 @@ function themesInUse(app) {
|
|
|
26762
26842
|
}
|
|
26763
26843
|
return found.size ? [...found].sort() : ["default"];
|
|
26764
26844
|
}
|
|
26765
|
-
function
|
|
26845
|
+
function resolve7(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
26766
26846
|
const entry = overrides.get(token);
|
|
26767
26847
|
if (!entry || seen.has(token)) return null;
|
|
26768
26848
|
seen.add(token);
|
|
26769
26849
|
const hit = /^var\(\s*(--[a-z0-9-]+)/.exec(entry.value);
|
|
26770
|
-
return hit ?
|
|
26850
|
+
return hit ? resolve7(hit[1], overrides, seen) : entry.value;
|
|
26771
26851
|
}
|
|
26772
26852
|
function rootTokens(css) {
|
|
26773
26853
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -26846,7 +26926,7 @@ function kitFromDisk() {
|
|
|
26846
26926
|
}
|
|
26847
26927
|
function verify({ app: appRef, catalog, agent, describe: describe7, load }, { extractContract: extractContract2 = extract, kit } = {}) {
|
|
26848
26928
|
const KIT = kit ?? kitFromDisk();
|
|
26849
|
-
const app = loadApp(
|
|
26929
|
+
const app = loadApp(resolve8(appRef.dir));
|
|
26850
26930
|
let contract = null;
|
|
26851
26931
|
let contractError = null;
|
|
26852
26932
|
try {
|
|
@@ -26923,7 +27003,7 @@ function compareRules(a, b) {
|
|
|
26923
27003
|
return 0;
|
|
26924
27004
|
}
|
|
26925
27005
|
var SELF = fileURLToPath3(import.meta.url);
|
|
26926
|
-
if (SELF.endsWith("verify.mjs") && process.argv[1] &&
|
|
27006
|
+
if (SELF.endsWith("verify.mjs") && process.argv[1] && resolve8(process.argv[1]) === SELF) {
|
|
26927
27007
|
let raw = "";
|
|
26928
27008
|
process.stdin.setEncoding("utf8");
|
|
26929
27009
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
@@ -26941,16 +27021,16 @@ if (SELF.endsWith("verify.mjs") && process.argv[1] && resolve7(process.argv[1])
|
|
|
26941
27021
|
|
|
26942
27022
|
// ../flows/appspace-builder/kit/checks/verify.mjs
|
|
26943
27023
|
import { readFileSync as readFileSync5 } from "fs";
|
|
26944
|
-
import { dirname as dirname6, join as join14, resolve as
|
|
27024
|
+
import { dirname as dirname6, join as join14, resolve as resolve13 } from "path";
|
|
26945
27025
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
26946
27026
|
|
|
26947
27027
|
// ../flows/appspace-builder/kit/contract/extract.mjs
|
|
26948
|
-
import { resolve as
|
|
27028
|
+
import { resolve as resolve10 } from "path";
|
|
26949
27029
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
26950
27030
|
|
|
26951
27031
|
// ../flows/appspace-builder/kit/checks/lib/app.mjs
|
|
26952
27032
|
import { existsSync as existsSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
26953
|
-
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";
|
|
26954
27034
|
var DATA_MODEL_PATH2 = "data_model.json";
|
|
26955
27035
|
var UI_PREFIX3 = "ui/";
|
|
26956
27036
|
var PAGE_PATH4 = /\.html?$/i;
|
|
@@ -26983,8 +27063,8 @@ function loadApp2(dir) {
|
|
|
26983
27063
|
}
|
|
26984
27064
|
function readHandlerSource2(dir, file) {
|
|
26985
27065
|
if (!file) return "";
|
|
26986
|
-
const root =
|
|
26987
|
-
const full =
|
|
27066
|
+
const root = resolve9(dir);
|
|
27067
|
+
const full = resolve9(root, file);
|
|
26988
27068
|
if (full !== root && !full.startsWith(root + sep3)) return "";
|
|
26989
27069
|
if (!existsSync2(full) || !statSync2(full).isFile()) return "";
|
|
26990
27070
|
return readFileSync4(full, "utf8");
|
|
@@ -27349,9 +27429,9 @@ function groupByObject2(text4, pairs) {
|
|
|
27349
27429
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
27350
27430
|
const pair = pairs.get(i);
|
|
27351
27431
|
if (pair !== void 0 && stack.length > 0) {
|
|
27352
|
-
const
|
|
27353
|
-
if (!byObject.has(
|
|
27354
|
-
byObject.get(
|
|
27432
|
+
const open3 = stack[stack.length - 1];
|
|
27433
|
+
if (!byObject.has(open3)) byObject.set(open3, []);
|
|
27434
|
+
byObject.get(open3).push(pair);
|
|
27355
27435
|
}
|
|
27356
27436
|
i = endOfString2(text4, i);
|
|
27357
27437
|
previous = '"';
|
|
@@ -28380,15 +28460,15 @@ function readPage2(app, page, spec, elements, problems) {
|
|
|
28380
28460
|
}
|
|
28381
28461
|
const bands = significant.filter((entry) => entry.type === "region" && entry.role === BAND_ROLE2);
|
|
28382
28462
|
const banded = bands.map((entry, index) => sectionOf2(entry.node, page.text, index));
|
|
28383
|
-
let
|
|
28463
|
+
let open3 = null;
|
|
28384
28464
|
let next = 0;
|
|
28385
28465
|
for (const entry of significant) {
|
|
28386
28466
|
if (next < bands.length && entry === bands[next]) {
|
|
28387
|
-
|
|
28467
|
+
open3 = banded[next].id;
|
|
28388
28468
|
next += 1;
|
|
28389
28469
|
continue;
|
|
28390
28470
|
}
|
|
28391
|
-
if (
|
|
28471
|
+
if (open3 !== null) elements[uids.get(entry.node.index)].section = open3;
|
|
28392
28472
|
}
|
|
28393
28473
|
const wrappers = tree.nodes.filter((node) => node.attrs[SECTION_ATTR2] !== void 0);
|
|
28394
28474
|
const wrapped = wrappers.map((node, index) => wrappedSectionOf2(tree, node, page.text, index));
|
|
@@ -29490,14 +29570,14 @@ function canonical4(value) {
|
|
|
29490
29570
|
return value;
|
|
29491
29571
|
}
|
|
29492
29572
|
var ENTRY2 = fileURLToPath4(import.meta.url);
|
|
29493
|
-
if (process.argv[1] &&
|
|
29573
|
+
if (process.argv[1] && resolve10(process.argv[1]) === ENTRY2 && ENTRY2.endsWith("extract.mjs")) {
|
|
29494
29574
|
let raw = "";
|
|
29495
29575
|
process.stdin.setEncoding("utf8");
|
|
29496
29576
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
29497
29577
|
process.stdin.on("end", () => {
|
|
29498
29578
|
try {
|
|
29499
29579
|
const input = JSON.parse(raw);
|
|
29500
|
-
const app = loadApp2(
|
|
29580
|
+
const app = loadApp2(resolve10(input.app.dir));
|
|
29501
29581
|
process.stdout.write(JSON.stringify(extract2(app, { describe: input.describe })));
|
|
29502
29582
|
} catch (e) {
|
|
29503
29583
|
process.stderr.write(`contract: ${e instanceof AppLoadError2 ? e.message : e.stack ?? e}
|
|
@@ -29548,7 +29628,7 @@ function check3(instance, node, at, root, problems, ctx) {
|
|
|
29548
29628
|
const start = problems.length;
|
|
29549
29629
|
const hint = describe4(node, ctx);
|
|
29550
29630
|
if (typeof node.$ref === "string") {
|
|
29551
|
-
const target =
|
|
29631
|
+
const target = resolve11(node.$ref, root);
|
|
29552
29632
|
if (target === null) {
|
|
29553
29633
|
problems.push(problem5(at, "the schema names a reference it cannot resolve"));
|
|
29554
29634
|
return;
|
|
@@ -29646,7 +29726,7 @@ function shapes3(branches, root) {
|
|
|
29646
29726
|
const named13 = branches.map((branch) => {
|
|
29647
29727
|
let node = branch;
|
|
29648
29728
|
for (let hops = 0; isObject6(node) && typeof node.$ref === "string" && hops < 8; hops += 1) {
|
|
29649
|
-
const target =
|
|
29729
|
+
const target = resolve11(node.$ref, root);
|
|
29650
29730
|
if (target === null) break;
|
|
29651
29731
|
node = target;
|
|
29652
29732
|
}
|
|
@@ -29708,7 +29788,7 @@ function same3(a, b) {
|
|
|
29708
29788
|
if (typeof a === "boolean" || typeof b === "boolean") return a === b;
|
|
29709
29789
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
29710
29790
|
}
|
|
29711
|
-
function
|
|
29791
|
+
function resolve11(ref, root) {
|
|
29712
29792
|
if (!ref.startsWith("#/")) return null;
|
|
29713
29793
|
let node = root;
|
|
29714
29794
|
for (const token of ref.slice(2).split("/")) {
|
|
@@ -29846,8 +29926,8 @@ function stringEnd2(text4, i) {
|
|
|
29846
29926
|
return Math.min(j + 1, text4.length);
|
|
29847
29927
|
}
|
|
29848
29928
|
function closeOf2(text4, i) {
|
|
29849
|
-
const
|
|
29850
|
-
const close = { "{": "}", "(": ")", "[": "]" }[
|
|
29929
|
+
const open3 = text4[i];
|
|
29930
|
+
const close = { "{": "}", "(": ")", "[": "]" }[open3];
|
|
29851
29931
|
let depth = 0;
|
|
29852
29932
|
for (let j = i; j < text4.length; j++) {
|
|
29853
29933
|
const ch = text4[j];
|
|
@@ -31314,10 +31394,10 @@ function railReachProblems2(contract) {
|
|
|
31314
31394
|
const pages = new Map((Array.isArray(contract?.pages) ? contract.pages : []).filter((page) => named10(page?.path)).map((page) => [page.path, page]));
|
|
31315
31395
|
const openers = (page) => Array.isArray(page?.roles) && page.roles.filter(named10).length > 0 ? page.roles.filter(named10) : null;
|
|
31316
31396
|
const canOpen = (name, page) => {
|
|
31317
|
-
const
|
|
31318
|
-
if (
|
|
31397
|
+
const open3 = openers(page);
|
|
31398
|
+
if (open3 === null) return true;
|
|
31319
31399
|
const role = declared.get(name);
|
|
31320
|
-
return
|
|
31400
|
+
return open3.includes(name) || (role?.sees ?? []).some((seen) => open3.includes(seen));
|
|
31321
31401
|
};
|
|
31322
31402
|
for (const key of ["entries", "footer"]) {
|
|
31323
31403
|
for (const [index, entry] of (Array.isArray(rail[key]) ? rail[key] : []).entries()) {
|
|
@@ -31603,7 +31683,7 @@ function checkTheme2(app) {
|
|
|
31603
31683
|
const overrides = rootTokens2(file.text);
|
|
31604
31684
|
if (overrides.size === 0) return { violations };
|
|
31605
31685
|
for (const theme of themesInUse2(app)) {
|
|
31606
|
-
const ground = rgbOf3(overrides.has("--dr-surface") ?
|
|
31686
|
+
const ground = rgbOf3(overrides.has("--dr-surface") ? resolve12("--dr-surface", overrides) : THEME_SURFACES2[theme]);
|
|
31607
31687
|
if (!ground) {
|
|
31608
31688
|
const surface = overrides.get("--dr-surface");
|
|
31609
31689
|
violations.push({
|
|
@@ -31616,7 +31696,7 @@ function checkTheme2(app) {
|
|
|
31616
31696
|
for (const [token, { line: line2 }] of overrides) {
|
|
31617
31697
|
const rule = FLOORS2.get(token);
|
|
31618
31698
|
if (!rule) continue;
|
|
31619
|
-
const value =
|
|
31699
|
+
const value = resolve12(token, overrides);
|
|
31620
31700
|
if (value === null) continue;
|
|
31621
31701
|
const series = /^--dr-chart-(\d+)$/.exec(token);
|
|
31622
31702
|
if (series && isPlatformChartColour2(Number(series[1]), value)) continue;
|
|
@@ -31664,12 +31744,12 @@ function themesInUse2(app) {
|
|
|
31664
31744
|
}
|
|
31665
31745
|
return found.size ? [...found].sort() : ["default"];
|
|
31666
31746
|
}
|
|
31667
|
-
function
|
|
31747
|
+
function resolve12(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
31668
31748
|
const entry = overrides.get(token);
|
|
31669
31749
|
if (!entry || seen.has(token)) return null;
|
|
31670
31750
|
seen.add(token);
|
|
31671
31751
|
const hit = /^var\(\s*(--[a-z0-9-]+)/.exec(entry.value);
|
|
31672
|
-
return hit ?
|
|
31752
|
+
return hit ? resolve12(hit[1], overrides, seen) : entry.value;
|
|
31673
31753
|
}
|
|
31674
31754
|
function rootTokens2(css) {
|
|
31675
31755
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -31912,10 +31992,10 @@ function handlerLiteral(source) {
|
|
|
31912
31992
|
const limit = /["']limit["']\s*:\s*(\d+)/.exec(body)?.[1];
|
|
31913
31993
|
return { table, limit: limit === void 0 ? null : Number(limit) };
|
|
31914
31994
|
}
|
|
31915
|
-
function argumentsFrom(source, from,
|
|
31995
|
+
function argumentsFrom(source, from, open3 = "(", close = ")") {
|
|
31916
31996
|
let depth = 1;
|
|
31917
31997
|
for (let i = from; i < source.length; i++) {
|
|
31918
|
-
if (source[i] ===
|
|
31998
|
+
if (source[i] === open3) depth++;
|
|
31919
31999
|
else if (source[i] === close && --depth === 0) return source.slice(from, i);
|
|
31920
32000
|
}
|
|
31921
32001
|
return source.slice(from);
|
|
@@ -32126,8 +32206,8 @@ function navLinks2(html, { owned = false, from } = {}) {
|
|
|
32126
32206
|
const regions = [];
|
|
32127
32207
|
if (owned) regions.push(text4);
|
|
32128
32208
|
else {
|
|
32129
|
-
for (const
|
|
32130
|
-
const rest = text4.slice(
|
|
32209
|
+
for (const open3 of text4.matchAll(NAV_OPEN2)) {
|
|
32210
|
+
const rest = text4.slice(open3.index + open3[0].length);
|
|
32131
32211
|
const end = rest.search(NAV_CLOSE2);
|
|
32132
32212
|
regions.push(end === -1 ? rest : rest.slice(0, end));
|
|
32133
32213
|
}
|
|
@@ -32552,24 +32632,24 @@ function sourceRoles2(contract, name, known = /* @__PURE__ */ new Set()) {
|
|
|
32552
32632
|
const pages = new Map(pagesOf2(contract).map((page) => [page.path, page]));
|
|
32553
32633
|
const union = [];
|
|
32554
32634
|
let readers = 0;
|
|
32555
|
-
let
|
|
32635
|
+
let open3 = false;
|
|
32556
32636
|
for (const element of Object.values(elements)) {
|
|
32557
32637
|
const props = isPlainObject17(element?.props) ? element.props : {};
|
|
32558
32638
|
const reads = [props.source, ...Array.isArray(props.declares?.reads) ? props.declares.reads : []];
|
|
32559
32639
|
if (!reads.includes(name)) continue;
|
|
32560
32640
|
readers += 1;
|
|
32561
32641
|
const roles = pageRoles2(pages.get(element.page));
|
|
32562
|
-
if (roles.length === 0)
|
|
32642
|
+
if (roles.length === 0) open3 = true;
|
|
32563
32643
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
32564
32644
|
}
|
|
32565
32645
|
for (const page of pagesOf2(contract)) {
|
|
32566
32646
|
if (page.owned !== true || readers === 0 || known.has(page.path)) continue;
|
|
32567
32647
|
const roles = pageRoles2(page);
|
|
32568
|
-
if (roles.length === 0)
|
|
32648
|
+
if (roles.length === 0) open3 = true;
|
|
32569
32649
|
for (const role of roles) if (!union.includes(role)) union.push(role);
|
|
32570
32650
|
}
|
|
32571
32651
|
if (stated2.length > 0) return { roles: stated2, inherited: false, readers };
|
|
32572
|
-
if (readers === 0 ||
|
|
32652
|
+
if (readers === 0 || open3) return { roles: [], inherited: true, readers };
|
|
32573
32653
|
const order2 = roleModel2(contract).names;
|
|
32574
32654
|
return { roles: union.sort((a, b) => order2.indexOf(a) - order2.indexOf(b)), inherited: true, readers };
|
|
32575
32655
|
}
|
|
@@ -32646,7 +32726,7 @@ function kitFromDisk2() {
|
|
|
32646
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"]);
|
|
32647
32727
|
function verify2({ app: appRef }, { extractContract: extractContract2 = extract2, kit } = {}) {
|
|
32648
32728
|
const KIT = kit ?? kitFromDisk2();
|
|
32649
|
-
const app = loadApp2(
|
|
32729
|
+
const app = loadApp2(resolve13(appRef.dir));
|
|
32650
32730
|
let contract = null;
|
|
32651
32731
|
let contractError = null;
|
|
32652
32732
|
try {
|
|
@@ -32721,7 +32801,7 @@ function compareRules2(a, b) {
|
|
|
32721
32801
|
return 0;
|
|
32722
32802
|
}
|
|
32723
32803
|
var SELF2 = fileURLToPath5(import.meta.url);
|
|
32724
|
-
if (SELF2.endsWith("verify.mjs") && process.argv[1] &&
|
|
32804
|
+
if (SELF2.endsWith("verify.mjs") && process.argv[1] && resolve13(process.argv[1]) === SELF2) {
|
|
32725
32805
|
let raw = "";
|
|
32726
32806
|
process.stdin.setEncoding("utf8");
|
|
32727
32807
|
process.stdin.on("data", (chunk) => raw += chunk);
|
|
@@ -33078,14 +33158,14 @@ async function runCompile(dir, opts) {
|
|
|
33078
33158
|
const state = await readIfPresent(join15(dir, ".appspace.json"));
|
|
33079
33159
|
if (state !== void 0) await writeFile7(join15(target, ".appspace.json"), state);
|
|
33080
33160
|
} else {
|
|
33081
|
-
for (const path3 of plan.orphaned) await
|
|
33161
|
+
for (const path3 of plan.orphaned) await rm5(join15(dir, path3), { force: true });
|
|
33082
33162
|
report.files = plan.owned;
|
|
33083
33163
|
report.digests = Object.fromEntries(plan.owned.map((path3) => [path3, digestOf(built.files[path3] ?? "")]));
|
|
33084
33164
|
report.inputs = plan.inputs;
|
|
33085
33165
|
}
|
|
33086
33166
|
return await afterWrite(dir, target, kind, contract, built, report, kit, skipped, opts, metricsPlan);
|
|
33087
33167
|
} finally {
|
|
33088
|
-
if (check5) await
|
|
33168
|
+
if (check5) await rm5(target, { recursive: true, force: true });
|
|
33089
33169
|
}
|
|
33090
33170
|
}
|
|
33091
33171
|
async function afterWrite(dir, target, kind, contract, built, report, kit, skipped, opts, metricsPlan = null) {
|
|
@@ -33363,8 +33443,8 @@ function insideFolder(dir, key) {
|
|
|
33363
33443
|
if (key.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
33364
33444
|
return false;
|
|
33365
33445
|
}
|
|
33366
|
-
const root =
|
|
33367
|
-
return
|
|
33446
|
+
const root = resolve14(dir);
|
|
33447
|
+
return resolve14(root, key).startsWith(root + sep4);
|
|
33368
33448
|
}
|
|
33369
33449
|
var AUTHOR_FILES = /* @__PURE__ */ new Set(["seed.json", "tests.json"]);
|
|
33370
33450
|
async function writePlan(dir, kind, contract, files, paths, force) {
|
|
@@ -33842,7 +33922,7 @@ function nothingWritten(report) {
|
|
|
33842
33922
|
async function readNamed(path3) {
|
|
33843
33923
|
let raw;
|
|
33844
33924
|
try {
|
|
33845
|
-
raw = await
|
|
33925
|
+
raw = await readFile9(resolve14(path3), "utf8");
|
|
33846
33926
|
} catch (err) {
|
|
33847
33927
|
throw new Error(`cannot read ${path3} (${err instanceof Error ? err.message.split("\n")[0] : String(err)}).`);
|
|
33848
33928
|
}
|
|
@@ -33914,7 +33994,7 @@ async function compileFolder(dir, kind, contract, kit, overlay = {}) {
|
|
|
33914
33994
|
var COMPILED_PAGE = 'id="dr-contract"';
|
|
33915
33995
|
async function recordPulled(dir, contractWritten) {
|
|
33916
33996
|
const forget = async () => {
|
|
33917
|
-
await
|
|
33997
|
+
await rm5(reportPath(dir), { force: true });
|
|
33918
33998
|
return null;
|
|
33919
33999
|
};
|
|
33920
34000
|
if (!contractWritten) return forget();
|
|
@@ -34367,7 +34447,7 @@ async function runShipOntoLive(dir, opts) {
|
|
|
34367
34447
|
}
|
|
34368
34448
|
const catalogMemo = {};
|
|
34369
34449
|
return landWithRetries(async (createGuarded) => {
|
|
34370
|
-
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 });
|
|
34371
34451
|
const client = await connect(opts);
|
|
34372
34452
|
let pulled;
|
|
34373
34453
|
try {
|
|
@@ -34449,7 +34529,7 @@ async function claimFolder(dir) {
|
|
|
34449
34529
|
}
|
|
34450
34530
|
async function lostRaceOf(dir) {
|
|
34451
34531
|
try {
|
|
34452
|
-
const report = JSON.parse(await
|
|
34532
|
+
const report = JSON.parse(await readFile9(reportPath(dir), "utf8"));
|
|
34453
34533
|
if (report.failure === "concurrent-publish") return { race: "publish", current: null };
|
|
34454
34534
|
if (report.failure === "stale-revision") return { race: "stale", current: report.stale?.current ?? null };
|
|
34455
34535
|
return null;
|
|
@@ -34540,10 +34620,10 @@ var EJECTED_DOCSTRING = 'Ejected with app-space eject: this file is yours now, a
|
|
|
34540
34620
|
function authorsDocstring(body) {
|
|
34541
34621
|
return body.replace(/Generated by [^\n]*compile[\s\S]*?not this file\./, EJECTED_DOCSTRING);
|
|
34542
34622
|
}
|
|
34543
|
-
function literalEnd2(text4,
|
|
34623
|
+
function literalEnd2(text4, open3) {
|
|
34544
34624
|
let depth = 0;
|
|
34545
34625
|
let quote = null;
|
|
34546
|
-
for (let i =
|
|
34626
|
+
for (let i = open3; i < text4.length; i++) {
|
|
34547
34627
|
const c = text4[i];
|
|
34548
34628
|
if (quote !== null) {
|
|
34549
34629
|
if (c === "\\") i++;
|
|
@@ -34934,8 +35014,8 @@ function registerLogsCommand(parent) {
|
|
|
34934
35014
|
}
|
|
34935
35015
|
|
|
34936
35016
|
// src/commands/appspace/migrate.ts
|
|
34937
|
-
import { constants } from "fs";
|
|
34938
|
-
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";
|
|
34939
35019
|
import { basename as basename2, dirname as dirname9, join as join17, sep as sep5 } from "path";
|
|
34940
35020
|
var MIGRATE_ROUTE = "/apps/migrate-preview";
|
|
34941
35021
|
var RUNTIMES_NOW = [1];
|
|
@@ -35138,12 +35218,12 @@ function valueEnd(text4, i) {
|
|
|
35138
35218
|
if (n === i) throw new NotJson();
|
|
35139
35219
|
return n;
|
|
35140
35220
|
}
|
|
35141
|
-
function containerOf(text4,
|
|
35142
|
-
const object = text4[
|
|
35221
|
+
function containerOf(text4, open3) {
|
|
35222
|
+
const object = text4[open3] === "{";
|
|
35143
35223
|
const closer = object ? "}" : "]";
|
|
35144
35224
|
const members = [];
|
|
35145
|
-
let i = skipSpace(text4,
|
|
35146
|
-
if (text4[i] === closer) return { open:
|
|
35225
|
+
let i = skipSpace(text4, open3 + 1);
|
|
35226
|
+
if (text4[i] === closer) return { open: open3, close: i, members };
|
|
35147
35227
|
for (; ; ) {
|
|
35148
35228
|
let key = null;
|
|
35149
35229
|
const start = i;
|
|
@@ -35162,7 +35242,7 @@ function containerOf(text4, open2) {
|
|
|
35162
35242
|
i = skipSpace(text4, i + 1);
|
|
35163
35243
|
continue;
|
|
35164
35244
|
}
|
|
35165
|
-
if (text4[i] === closer) return { open:
|
|
35245
|
+
if (text4[i] === closer) return { open: open3, close: i, members };
|
|
35166
35246
|
throw new NotJson();
|
|
35167
35247
|
}
|
|
35168
35248
|
}
|
|
@@ -35324,7 +35404,7 @@ async function runMigrate(dir, opts) {
|
|
|
35324
35404
|
const { manifest } = await readManifest(dir).catch((err) => {
|
|
35325
35405
|
throw new MigrateRefused(err instanceof Error ? err.message : String(err));
|
|
35326
35406
|
});
|
|
35327
|
-
const manifestSent = await
|
|
35407
|
+
const manifestSent = await readFile10(join17(dir, "manifest.json"), "utf8");
|
|
35328
35408
|
if (canonical5(JSON.parse(manifestSent)) !== canonical5(manifest)) {
|
|
35329
35409
|
throw new MigrateRefused("manifest.json changed while migrate read it. Run migrate again.");
|
|
35330
35410
|
}
|
|
@@ -35356,7 +35436,7 @@ async function runMigrate(dir, opts) {
|
|
|
35356
35436
|
return 0;
|
|
35357
35437
|
}
|
|
35358
35438
|
const files = applyDiff(preview.diff, sent);
|
|
35359
|
-
const manifestNow = await
|
|
35439
|
+
const manifestNow = await readFile10(join17(dir, "manifest.json"), "utf8");
|
|
35360
35440
|
if (manifestNow !== manifestSent) {
|
|
35361
35441
|
throw new MigrateRefused("manifest.json changed since migrate read it. Run migrate again.");
|
|
35362
35442
|
}
|
|
@@ -35463,7 +35543,7 @@ ${written.map((p) => ` ${p}
|
|
|
35463
35543
|
return 1;
|
|
35464
35544
|
}
|
|
35465
35545
|
}
|
|
35466
|
-
var _io = { rename: rename2, writeFile: writeFile9, realpath, rm:
|
|
35546
|
+
var _io = { rename: rename2, writeFile: writeFile9, realpath, rm: rm6 };
|
|
35467
35547
|
async function writable(dir, path3, sent) {
|
|
35468
35548
|
const full = join17(dir, path3);
|
|
35469
35549
|
const parts = path3.split("/");
|
|
@@ -35494,12 +35574,12 @@ async function writable(dir, path3, sent) {
|
|
|
35494
35574
|
throw new MigrateRefused(`${path3} is not a regular file (a link, or another kind); migrate writes only regular files.`);
|
|
35495
35575
|
}
|
|
35496
35576
|
try {
|
|
35497
|
-
await access(full,
|
|
35498
|
-
await access(dirname9(full),
|
|
35577
|
+
await access(full, constants2.W_OK);
|
|
35578
|
+
await access(dirname9(full), constants2.W_OK);
|
|
35499
35579
|
} catch {
|
|
35500
35580
|
throw new MigrateRefused(`${path3} cannot be written (no permission).`);
|
|
35501
35581
|
}
|
|
35502
|
-
const bytes = await
|
|
35582
|
+
const bytes = await readFile10(full);
|
|
35503
35583
|
const text4 = bytes.toString("utf8");
|
|
35504
35584
|
if (!Buffer.from(text4, "utf8").equals(bytes)) {
|
|
35505
35585
|
throw new MigrateRefused(`${path3} is not valid UTF-8; migrate would change bytes it did not mean to.`);
|
|
@@ -35584,12 +35664,12 @@ function registerMigrateCommand(parent) {
|
|
|
35584
35664
|
}
|
|
35585
35665
|
|
|
35586
35666
|
// src/commands/appspace/test.ts
|
|
35587
|
-
import { readFile as
|
|
35588
|
-
import { join as join19, resolve as
|
|
35667
|
+
import { readFile as readFile13 } from "fs/promises";
|
|
35668
|
+
import { join as join19, resolve as resolve17 } from "path";
|
|
35589
35669
|
|
|
35590
35670
|
// src/commands/appspace/_files.ts
|
|
35591
|
-
import { readFile as
|
|
35592
|
-
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";
|
|
35593
35673
|
|
|
35594
35674
|
// src/commands/appspace/_samplePdf.ts
|
|
35595
35675
|
function pdfString(text4) {
|
|
@@ -35746,11 +35826,11 @@ function readFailure(path3, full, err) {
|
|
|
35746
35826
|
if (code === void 0 || code === "ENOENT") return new Error(`no file at ${path3} (looked for ${full}).`);
|
|
35747
35827
|
return new Error(`could not read ${path3} (${String(code)}).`);
|
|
35748
35828
|
}
|
|
35749
|
-
async function resolveFile(path3, base, { read =
|
|
35829
|
+
async function resolveFile(path3, base, { read = readFile11, confine = false, realpath: real = realpath2 } = {}) {
|
|
35750
35830
|
if (path3 === null) {
|
|
35751
35831
|
return { bytes: sampleInvoiceBytes(), filename: SAMPLE_INVOICE.filename, mimeType: SAMPLE_INVOICE.mimeType };
|
|
35752
35832
|
}
|
|
35753
|
-
const full =
|
|
35833
|
+
const full = resolve15(base, path3);
|
|
35754
35834
|
if (confine) {
|
|
35755
35835
|
let target;
|
|
35756
35836
|
let root;
|
|
@@ -35792,7 +35872,7 @@ function fileColumnsOf(model) {
|
|
|
35792
35872
|
}
|
|
35793
35873
|
async function readFileColumns(dir) {
|
|
35794
35874
|
try {
|
|
35795
|
-
return fileColumnsOf(JSON.parse(await
|
|
35875
|
+
return fileColumnsOf(JSON.parse(await readFile11(resolve15(dir, "data_model.json"), "utf8")));
|
|
35796
35876
|
} catch {
|
|
35797
35877
|
return null;
|
|
35798
35878
|
}
|
|
@@ -37091,13 +37171,13 @@ var defaultBlobReader = async (blob) => {
|
|
|
37091
37171
|
function blobReaderFor(window) {
|
|
37092
37172
|
const ctor = window?.FileReader;
|
|
37093
37173
|
if (typeof ctor !== "function") return defaultBlobReader;
|
|
37094
|
-
return (blob) => new Promise((
|
|
37174
|
+
return (blob) => new Promise((resolve18, reject) => {
|
|
37095
37175
|
const reader = new ctor();
|
|
37096
37176
|
reader.onload = () => {
|
|
37097
37177
|
const result = reader.result;
|
|
37098
|
-
if (result === null || result === void 0)
|
|
37099
|
-
else if (typeof result === "string")
|
|
37100
|
-
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));
|
|
37101
37181
|
};
|
|
37102
37182
|
reader.onerror = () => reject(new Error("the attached file could not be read"));
|
|
37103
37183
|
reader.onabort = () => reject(new Error("reading the attached file was aborted"));
|
|
@@ -37384,7 +37464,7 @@ async function loadJsdom() {
|
|
|
37384
37464
|
);
|
|
37385
37465
|
}
|
|
37386
37466
|
}
|
|
37387
|
-
var sleep = (ms) => new Promise((
|
|
37467
|
+
var sleep = (ms) => new Promise((resolve18) => setTimeout(resolve18, ms));
|
|
37388
37468
|
var DRAW_GRACE_MS = 3e3;
|
|
37389
37469
|
async function runUiSmoke(opts) {
|
|
37390
37470
|
const timeoutMs = opts.timeoutMs ?? 15e3;
|
|
@@ -37890,10 +37970,10 @@ async function runUiSmoke(opts) {
|
|
|
37890
37970
|
// src/commands/appspace/_screenshot.ts
|
|
37891
37971
|
import { spawn } from "child_process";
|
|
37892
37972
|
import { existsSync as existsSync3, statSync as statSync3 } from "fs";
|
|
37893
|
-
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";
|
|
37894
37974
|
import { createServer } from "http";
|
|
37895
37975
|
import { tmpdir as tmpdir5 } from "os";
|
|
37896
|
-
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";
|
|
37897
37977
|
|
|
37898
37978
|
// ../tests/vendor/fixtures/widgets/kpi.json
|
|
37899
37979
|
var kpi_default = {
|
|
@@ -39085,8 +39165,8 @@ function contentType(path3) {
|
|
|
39085
39165
|
return TYPES[extname2(path3).toLowerCase()] ?? "application/octet-stream";
|
|
39086
39166
|
}
|
|
39087
39167
|
function inside(root, rel) {
|
|
39088
|
-
const base =
|
|
39089
|
-
const full =
|
|
39168
|
+
const base = resolve16(root);
|
|
39169
|
+
const full = resolve16(base, rel);
|
|
39090
39170
|
return full === base || !full.startsWith(base + sep7) ? null : full;
|
|
39091
39171
|
}
|
|
39092
39172
|
var Shelf = class {
|
|
@@ -39131,7 +39211,7 @@ var Shelf = class {
|
|
|
39131
39211
|
const full = inside(this.source.root, rel);
|
|
39132
39212
|
if (full === null) continue;
|
|
39133
39213
|
try {
|
|
39134
|
-
return { status: 200, type: contentType(full), body: await
|
|
39214
|
+
return { status: 200, type: contentType(full), body: await readFile12(full) };
|
|
39135
39215
|
} catch {
|
|
39136
39216
|
}
|
|
39137
39217
|
}
|
|
@@ -39401,7 +39481,7 @@ async function runChrome(run) {
|
|
|
39401
39481
|
}
|
|
39402
39482
|
} finally {
|
|
39403
39483
|
killGroup(child);
|
|
39404
|
-
await
|
|
39484
|
+
await rm7(profile, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }).catch(() => void 0);
|
|
39405
39485
|
}
|
|
39406
39486
|
if (ok) return { ok, stdout, profile };
|
|
39407
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");
|
|
@@ -39524,7 +39604,7 @@ async function runScreenshots(opts) {
|
|
|
39524
39604
|
for (let attempt = 0; attempt < 2 && now() < pageUntil - 500; attempt++) {
|
|
39525
39605
|
id = nextId++;
|
|
39526
39606
|
stub.register(id, { role });
|
|
39527
|
-
await
|
|
39607
|
+
await rm7(out, { force: true });
|
|
39528
39608
|
result = await runChrome({
|
|
39529
39609
|
chrome: opts.chrome,
|
|
39530
39610
|
url: stub.urlFor(id, entry),
|
|
@@ -39553,7 +39633,7 @@ async function runScreenshots(opts) {
|
|
|
39553
39633
|
shots[index2] = { ...entryOut, error: result.error ?? "no picture" };
|
|
39554
39634
|
return;
|
|
39555
39635
|
}
|
|
39556
|
-
const bytes = await
|
|
39636
|
+
const bytes = await readFile12(out);
|
|
39557
39637
|
if (look && seen === void 0) toLook.push(index2);
|
|
39558
39638
|
shots[index2] = {
|
|
39559
39639
|
...entryOut,
|
|
@@ -39613,7 +39693,7 @@ async function readLocalUi(dir) {
|
|
|
39613
39693
|
for (const one of names) {
|
|
39614
39694
|
const full = join18(folder, one.name);
|
|
39615
39695
|
if (one.isDirectory()) await walk5(full);
|
|
39616
|
-
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);
|
|
39617
39697
|
}
|
|
39618
39698
|
};
|
|
39619
39699
|
await walk5(root);
|
|
@@ -41153,13 +41233,13 @@ function roleFindings(contract, held) {
|
|
|
41153
41233
|
};
|
|
41154
41234
|
const visible = /* @__PURE__ */ new Set([held.own, ...held.sees]);
|
|
41155
41235
|
let mine = 0;
|
|
41156
|
-
let
|
|
41236
|
+
let open3 = 0;
|
|
41157
41237
|
const others = [];
|
|
41158
41238
|
let gatedElsewhere = 0;
|
|
41159
41239
|
for (const [uid, element] of Object.entries(elements)) {
|
|
41160
41240
|
if (typeof element.type !== "string" || !COMPONENT_TYPES7.has(element.type)) continue;
|
|
41161
41241
|
const gate = gateOf(uid);
|
|
41162
|
-
if (gate === null)
|
|
41242
|
+
if (gate === null) open3 += 1;
|
|
41163
41243
|
else if (visible.has(gate)) mine += 1;
|
|
41164
41244
|
else {
|
|
41165
41245
|
gatedElsewhere += 1;
|
|
@@ -41173,7 +41253,7 @@ function roleFindings(contract, held) {
|
|
|
41173
41253
|
{
|
|
41174
41254
|
code: "role-sees-nothing",
|
|
41175
41255
|
where: "backend.roles",
|
|
41176
|
-
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)`,
|
|
41177
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.`,
|
|
41178
41258
|
see: SEE.roles
|
|
41179
41259
|
}
|
|
@@ -41331,7 +41411,7 @@ function collectRoles(value, previous = []) {
|
|
|
41331
41411
|
}
|
|
41332
41412
|
async function readLocalManifest(dir) {
|
|
41333
41413
|
try {
|
|
41334
|
-
return JSON.parse(await
|
|
41414
|
+
return JSON.parse(await readFile13(join19(dir, "manifest.json"), "utf8"));
|
|
41335
41415
|
} catch {
|
|
41336
41416
|
return null;
|
|
41337
41417
|
}
|
|
@@ -41474,7 +41554,7 @@ async function loadFixtures(dir, explicit) {
|
|
|
41474
41554
|
const path3 = explicit ?? join19(dir, DEFAULT_FIXTURES);
|
|
41475
41555
|
let raw;
|
|
41476
41556
|
try {
|
|
41477
|
-
raw = await
|
|
41557
|
+
raw = await readFile13(path3, "utf8");
|
|
41478
41558
|
} catch {
|
|
41479
41559
|
if (explicit !== void 0) throw new Error(`no fixtures file at ${path3}.`);
|
|
41480
41560
|
return { fixtures: { cases: [], ui: { entry: "index.html" } } };
|
|
@@ -41496,7 +41576,7 @@ async function runHandlerCases(cases, dir, appId, client, roleOf = () => void 0)
|
|
|
41496
41576
|
if (!code.has(kase.handler)) {
|
|
41497
41577
|
code.set(
|
|
41498
41578
|
kase.handler,
|
|
41499
|
-
await
|
|
41579
|
+
await readFile13(join19(dir, "handlers", `${kase.handler}.py`), "utf8").catch(() => null)
|
|
41500
41580
|
);
|
|
41501
41581
|
}
|
|
41502
41582
|
const source = code.get(kase.handler);
|
|
@@ -41751,7 +41831,7 @@ function contractUid(contract, page, component) {
|
|
|
41751
41831
|
}
|
|
41752
41832
|
async function isDashboardFolder2(dir) {
|
|
41753
41833
|
try {
|
|
41754
|
-
const doc = JSON.parse(await
|
|
41834
|
+
const doc = JSON.parse(await readFile13(join19(dir, "contract.json"), "utf8"));
|
|
41755
41835
|
return doc.app?.kind === "dashboard";
|
|
41756
41836
|
} catch {
|
|
41757
41837
|
return false;
|
|
@@ -41952,7 +42032,7 @@ function mergeDomComponents(contract, components, page) {
|
|
|
41952
42032
|
async function writeMergedContract(dir, page, components) {
|
|
41953
42033
|
let contract;
|
|
41954
42034
|
try {
|
|
41955
|
-
contract = JSON.parse(await
|
|
42035
|
+
contract = JSON.parse(await readFile13(contractPath(dir), "utf8"));
|
|
41956
42036
|
} catch {
|
|
41957
42037
|
contract = await extractContract(dir);
|
|
41958
42038
|
}
|
|
@@ -41962,7 +42042,7 @@ async function writeMergedContract(dir, page, components) {
|
|
|
41962
42042
|
async function uiIsStale(dir, entry, stored) {
|
|
41963
42043
|
if (stored === void 0) return false;
|
|
41964
42044
|
try {
|
|
41965
|
-
const local = await
|
|
42045
|
+
const local = await readFile13(join19(dir, "ui", entry));
|
|
41966
42046
|
return !local.equals(Buffer.from(stored, "utf8"));
|
|
41967
42047
|
} catch {
|
|
41968
42048
|
return false;
|
|
@@ -42050,7 +42130,7 @@ function untouchedHandlers(declared, cases, interactions, runs = []) {
|
|
|
42050
42130
|
async function readSeed(dir) {
|
|
42051
42131
|
let parsed2;
|
|
42052
42132
|
try {
|
|
42053
|
-
parsed2 = JSON.parse(await
|
|
42133
|
+
parsed2 = JSON.parse(await readFile13(join19(dir, "seed.json"), "utf8"));
|
|
42054
42134
|
} catch {
|
|
42055
42135
|
return null;
|
|
42056
42136
|
}
|
|
@@ -42066,7 +42146,7 @@ async function readSeed(dir) {
|
|
|
42066
42146
|
}
|
|
42067
42147
|
async function handlerOwnership(dir, pushed) {
|
|
42068
42148
|
try {
|
|
42069
|
-
const local = JSON.parse(await
|
|
42149
|
+
const local = JSON.parse(await readFile13(join19(dir, "contract.json"), "utf8"));
|
|
42070
42150
|
const owned = ownershipOf(local);
|
|
42071
42151
|
if (owned !== null) return owned;
|
|
42072
42152
|
} catch {
|
|
@@ -42394,7 +42474,7 @@ function registerTestCommand(parent) {
|
|
|
42394
42474
|
const files = pushedPages ? store.bundle : await readLocalUi(dir);
|
|
42395
42475
|
const pages = pushedPages ? store.pages : orderPages(Object.keys(files));
|
|
42396
42476
|
const manifest = pushedPages && typeof store.manifest === "object" && store.manifest !== null ? store.manifest : await readLocalManifest(dir);
|
|
42397
|
-
const outDir =
|
|
42477
|
+
const outDir = resolve17(opts.out ?? join19(dir, ".screenshots"));
|
|
42398
42478
|
const index = await runScreenshots({
|
|
42399
42479
|
appId,
|
|
42400
42480
|
pages: choosePages(opts.pages, pages, fixtures.ui.entry).load,
|
|
@@ -42405,7 +42485,7 @@ function registerTestCommand(parent) {
|
|
|
42405
42485
|
allowedByRole: view.allowed,
|
|
42406
42486
|
sources: Object.keys(pushed?.data?.sources ?? {}),
|
|
42407
42487
|
cases: fixtures.cases,
|
|
42408
|
-
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) },
|
|
42409
42489
|
chrome,
|
|
42410
42490
|
outDir,
|
|
42411
42491
|
width: shotSize.width,
|
|
@@ -42513,12 +42593,12 @@ ${String(failed)} failure(s).
|
|
|
42513
42593
|
}
|
|
42514
42594
|
|
|
42515
42595
|
// src/commands/appspace/try.ts
|
|
42516
|
-
import { readFile as
|
|
42596
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
42517
42597
|
import { join as join20 } from "path";
|
|
42518
42598
|
function collect2(value, previous = []) {
|
|
42519
42599
|
return [...previous, value];
|
|
42520
42600
|
}
|
|
42521
|
-
async function readPayloadOption(raw, read = (path3) =>
|
|
42601
|
+
async function readPayloadOption(raw, read = (path3) => readFile14(path3, "utf8")) {
|
|
42522
42602
|
if (raw.startsWith("@")) {
|
|
42523
42603
|
const path3 = raw.slice(1);
|
|
42524
42604
|
if (path3 === "") throw new Error("--payload @ names no file; write --payload @./payload.json.");
|
|
@@ -42598,7 +42678,7 @@ function registerTryCommand(parent) {
|
|
|
42598
42678
|
).action(async (handler, opts) => {
|
|
42599
42679
|
requirePlainName("handler", handler, "read");
|
|
42600
42680
|
const appId = await readManifestId(opts.dir);
|
|
42601
|
-
const code = await
|
|
42681
|
+
const code = await readFile14(
|
|
42602
42682
|
join20(opts.dir, "handlers", `${handler}.py`),
|
|
42603
42683
|
"utf8"
|
|
42604
42684
|
).catch(() => {
|
|
@@ -43157,7 +43237,7 @@ ${METRIC_ADVICE}
|
|
|
43157
43237
|
// src/commands/appspace/secrets.ts
|
|
43158
43238
|
var SECRET_NAME_RE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
43159
43239
|
function promptHidden(label, input, output) {
|
|
43160
|
-
return new Promise((
|
|
43240
|
+
return new Promise((resolve18, reject) => {
|
|
43161
43241
|
let value = "";
|
|
43162
43242
|
output.write(label);
|
|
43163
43243
|
input.setRawMode?.(true);
|
|
@@ -43169,7 +43249,7 @@ function promptHidden(label, input, output) {
|
|
|
43169
43249
|
input.pause();
|
|
43170
43250
|
output.write("\n");
|
|
43171
43251
|
if (err !== null) reject(err);
|
|
43172
|
-
else
|
|
43252
|
+
else resolve18(value);
|
|
43173
43253
|
};
|
|
43174
43254
|
const onData = (chunk) => {
|
|
43175
43255
|
for (const ch of String(chunk)) {
|
|
@@ -43379,7 +43459,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
43379
43459
|
var REGISTRY = "https://datarails.jfrog.io/artifactory/api/npm/dr-cli-virtual";
|
|
43380
43460
|
var PACKAGE = "@datarails-ai/dr-appspace-cli";
|
|
43381
43461
|
function spawnInherit(command, args) {
|
|
43382
|
-
return new Promise((
|
|
43462
|
+
return new Promise((resolve18) => {
|
|
43383
43463
|
const child = spawn2(command, args, {
|
|
43384
43464
|
stdio: "inherit",
|
|
43385
43465
|
// Windows resolves `npm` as `npm.cmd`; `shell: true` lets cmd.exe do
|
|
@@ -43387,15 +43467,15 @@ function spawnInherit(command, args) {
|
|
|
43387
43467
|
shell: true
|
|
43388
43468
|
});
|
|
43389
43469
|
child.on("close", (code) => {
|
|
43390
|
-
|
|
43470
|
+
resolve18(code ?? 1);
|
|
43391
43471
|
});
|
|
43392
43472
|
child.on("error", () => {
|
|
43393
|
-
|
|
43473
|
+
resolve18(1);
|
|
43394
43474
|
});
|
|
43395
43475
|
});
|
|
43396
43476
|
}
|
|
43397
43477
|
function captureVersion() {
|
|
43398
|
-
return new Promise((
|
|
43478
|
+
return new Promise((resolve18) => {
|
|
43399
43479
|
const child = spawn2("dr-appspace", ["--version"], { shell: true });
|
|
43400
43480
|
let out = "";
|
|
43401
43481
|
child.stdout.on("data", (chunk) => {
|
|
@@ -43403,12 +43483,12 @@ function captureVersion() {
|
|
|
43403
43483
|
});
|
|
43404
43484
|
child.on("close", (code) => {
|
|
43405
43485
|
if (code !== 0) {
|
|
43406
|
-
|
|
43486
|
+
resolve18(null);
|
|
43407
43487
|
return;
|
|
43408
43488
|
}
|
|
43409
|
-
|
|
43489
|
+
resolve18(out.trim());
|
|
43410
43490
|
});
|
|
43411
|
-
child.on("error", () =>
|
|
43491
|
+
child.on("error", () => resolve18(null));
|
|
43412
43492
|
});
|
|
43413
43493
|
}
|
|
43414
43494
|
async function runUpdate() {
|