@diafunc/cli 0.24.0 → 0.26.0
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 +9 -3
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-A6PH2CFB.js → chunk-EJ2LNAYV.js} +2 -2
- package/dist/{chunk-A6PH2CFB.js.map → chunk-EJ2LNAYV.js.map} +1 -1
- package/dist/{chunk-2YKNPNBM.js → chunk-Q5GOPNYM.js} +1328 -544
- package/dist/chunk-Q5GOPNYM.js.map +1 -0
- package/dist/{chunk-FX557IX3.js → chunk-RSOGVUUU.js} +2 -2
- package/dist/src/index.js +2 -2
- package/dist/update-check-4345HWGE.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-2YKNPNBM.js.map +0 -1
- package/dist/update-check-YTIEPB54.js +0 -8
- /package/dist/{chunk-FX557IX3.js.map → chunk-RSOGVUUU.js.map} +0 -0
- /package/dist/{update-check-YTIEPB54.js.map → update-check-4345HWGE.js.map} +0 -0
|
@@ -1,19 +1,182 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EJ2LNAYV.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
|
-
import
|
|
6
|
+
import chalk39 from "chalk";
|
|
7
7
|
|
|
8
8
|
// src/commands/auth/login.ts
|
|
9
9
|
import chalk4 from "chalk";
|
|
10
10
|
|
|
11
11
|
// src/config/store.ts
|
|
12
|
+
import * as fs2 from "fs";
|
|
13
|
+
import * as path2 from "path";
|
|
14
|
+
import * as os2 from "os";
|
|
15
|
+
import * as crypto2 from "crypto";
|
|
16
|
+
|
|
17
|
+
// src/config/lock.ts
|
|
18
|
+
import * as crypto from "crypto";
|
|
12
19
|
import * as fs from "fs";
|
|
13
|
-
import * as path from "path";
|
|
14
20
|
import * as os from "os";
|
|
15
|
-
|
|
16
|
-
var
|
|
21
|
+
import * as path from "path";
|
|
22
|
+
var LockTimeoutError = class extends Error {
|
|
23
|
+
lockPath;
|
|
24
|
+
constructor(lockPath, waitedMs) {
|
|
25
|
+
super(`Timed out after ${Math.round(waitedMs / 1e3)}s waiting for ${lockPath}.`);
|
|
26
|
+
this.name = "LockTimeoutError";
|
|
27
|
+
this.lockPath = lockPath;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var DEFAULT_STALE_MS = 3e4;
|
|
31
|
+
var DEFAULT_WAIT_MS = 25e3;
|
|
32
|
+
var DEFAULT_POLL_MS = 120;
|
|
33
|
+
var held = /* @__PURE__ */ new Map();
|
|
34
|
+
var exitHookInstalled = false;
|
|
35
|
+
function installExitHook() {
|
|
36
|
+
if (exitHookInstalled) return;
|
|
37
|
+
exitHookInstalled = true;
|
|
38
|
+
process.on("exit", () => {
|
|
39
|
+
for (const [lockPath, id] of held) removeIfOwned(lockPath, id);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function processIsAlive(pid) {
|
|
43
|
+
try {
|
|
44
|
+
process.kill(pid, 0);
|
|
45
|
+
return true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return error.code === "EPERM";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function readHolder(lockPath) {
|
|
51
|
+
let raw;
|
|
52
|
+
try {
|
|
53
|
+
raw = fs.readFileSync(lockPath, "utf-8");
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return error.code === "ENOENT" ? "absent" : "unreadable";
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(raw);
|
|
59
|
+
if (typeof parsed.id === "string" && typeof parsed.pid === "number" && typeof parsed.createdAt === "number") {
|
|
60
|
+
return { id: parsed.id, pid: parsed.pid, host: String(parsed.host ?? ""), createdAt: parsed.createdAt };
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return "unreadable";
|
|
65
|
+
}
|
|
66
|
+
function isStale(lockPath, holder, staleMs, isAlive) {
|
|
67
|
+
if (holder === "unreadable") {
|
|
68
|
+
try {
|
|
69
|
+
return Date.now() - fs.statSync(lockPath).mtimeMs > staleMs;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (Date.now() - holder.createdAt > staleMs) return true;
|
|
75
|
+
return holder.host === os.hostname() && !isAlive(holder.pid);
|
|
76
|
+
}
|
|
77
|
+
function removeIfOwned(lockPath, id) {
|
|
78
|
+
const holder = readHolder(lockPath);
|
|
79
|
+
if (holder !== "absent" && holder !== "unreadable" && holder.id === id) {
|
|
80
|
+
try {
|
|
81
|
+
fs.unlinkSync(lockPath);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function tryCreate(lockPath, content) {
|
|
87
|
+
let fd;
|
|
88
|
+
try {
|
|
89
|
+
fd = fs.openSync(lockPath, "wx", 384);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const code = error.code;
|
|
92
|
+
if (code === "EEXIST") return false;
|
|
93
|
+
if (process.platform === "win32" && (code === "EPERM" || code === "EACCES" || code === "EBUSY")) return false;
|
|
94
|
+
if (code === "ENOENT") {
|
|
95
|
+
fs.mkdirSync(path.dirname(lockPath), { recursive: true, mode: 448 });
|
|
96
|
+
return tryCreate(lockPath, content);
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
fs.writeSync(fd, content);
|
|
102
|
+
} finally {
|
|
103
|
+
fs.closeSync(fd);
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function removeStale(lockPath, staleMs, isAlive) {
|
|
108
|
+
const breaker = `${lockPath}.break`;
|
|
109
|
+
if (!tryCreate(breaker, "")) {
|
|
110
|
+
try {
|
|
111
|
+
if (Date.now() - fs.statSync(breaker).mtimeMs > staleMs) fs.unlinkSync(breaker);
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const holder = readHolder(lockPath);
|
|
118
|
+
if (holder !== "absent" && isStale(lockPath, holder, staleMs, isAlive)) {
|
|
119
|
+
try {
|
|
120
|
+
fs.unlinkSync(lockPath);
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
try {
|
|
126
|
+
fs.unlinkSync(breaker);
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function pause(ms) {
|
|
132
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
133
|
+
}
|
|
134
|
+
async function acquireFileLock(lockPath, options = {}) {
|
|
135
|
+
const staleMs = options.staleMs ?? DEFAULT_STALE_MS;
|
|
136
|
+
const waitMs = options.waitMs ?? DEFAULT_WAIT_MS;
|
|
137
|
+
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
138
|
+
const isAlive = options.isAlive ?? processIsAlive;
|
|
139
|
+
const id = crypto.randomUUID();
|
|
140
|
+
const startedAt = Date.now();
|
|
141
|
+
for (; ; ) {
|
|
142
|
+
const content = JSON.stringify({ id, pid: process.pid, host: os.hostname(), createdAt: Date.now() });
|
|
143
|
+
if (tryCreate(lockPath, content)) {
|
|
144
|
+
installExitHook();
|
|
145
|
+
held.set(lockPath, id);
|
|
146
|
+
let released = false;
|
|
147
|
+
return {
|
|
148
|
+
release() {
|
|
149
|
+
if (released) return;
|
|
150
|
+
released = true;
|
|
151
|
+
if (held.get(lockPath) === id) held.delete(lockPath);
|
|
152
|
+
removeIfOwned(lockPath, id);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const waited = Date.now() - startedAt;
|
|
157
|
+
if (waited >= waitMs) throw new LockTimeoutError(lockPath, waited);
|
|
158
|
+
const holder = readHolder(lockPath);
|
|
159
|
+
let free = holder === "absent";
|
|
160
|
+
if (holder !== "absent" && isStale(lockPath, holder, staleMs, isAlive)) {
|
|
161
|
+
removeStale(lockPath, staleMs, isAlive);
|
|
162
|
+
free = true;
|
|
163
|
+
}
|
|
164
|
+
const nap = free ? 1 + 4 * Math.random() : pollMs * (0.25 + 0.75 * Math.random());
|
|
165
|
+
await pause(Math.min(nap, Math.max(1, waitMs - waited)));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function withFileLock(lockPath, work, options = {}) {
|
|
169
|
+
const lock = await acquireFileLock(lockPath, options);
|
|
170
|
+
try {
|
|
171
|
+
return await work();
|
|
172
|
+
} finally {
|
|
173
|
+
lock.release();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/config/store.ts
|
|
178
|
+
var CONFIG_DIR = path2.join(os2.homedir(), ".diafunc");
|
|
179
|
+
var CONFIG_FILE = path2.join(CONFIG_DIR, "config.json");
|
|
17
180
|
var DEFAULT_CONFIG = {
|
|
18
181
|
currentProfile: "default",
|
|
19
182
|
profiles: {
|
|
@@ -24,25 +187,63 @@ var DEFAULT_CONFIG = {
|
|
|
24
187
|
defaults: {}
|
|
25
188
|
};
|
|
26
189
|
function ensureConfigDir() {
|
|
27
|
-
if (!
|
|
28
|
-
|
|
190
|
+
if (!fs2.existsSync(CONFIG_DIR)) {
|
|
191
|
+
fs2.mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
29
192
|
}
|
|
30
193
|
}
|
|
31
194
|
function loadConfig() {
|
|
32
|
-
if (!
|
|
195
|
+
if (!fs2.existsSync(CONFIG_FILE)) {
|
|
33
196
|
return structuredClone(DEFAULT_CONFIG);
|
|
34
197
|
}
|
|
35
|
-
const raw =
|
|
198
|
+
const raw = fs2.readFileSync(CONFIG_FILE, "utf-8");
|
|
36
199
|
return JSON.parse(raw);
|
|
37
200
|
}
|
|
38
201
|
function saveConfig(config) {
|
|
39
202
|
ensureConfigDir();
|
|
40
|
-
const tmp = CONFIG_FILE
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
203
|
+
const tmp = `${CONFIG_FILE}.${process.pid}.${crypto2.randomBytes(4).toString("hex")}.tmp`;
|
|
204
|
+
try {
|
|
205
|
+
fs2.writeFileSync(tmp, JSON.stringify(config, null, 2) + "\n", {
|
|
206
|
+
encoding: "utf-8",
|
|
207
|
+
mode: 384
|
|
208
|
+
});
|
|
209
|
+
renameIntoPlace(tmp, CONFIG_FILE);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
fs2.rmSync(tmp, { force: true });
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function renameIntoPlace(from, to) {
|
|
216
|
+
for (let attempt = 1; ; attempt++) {
|
|
217
|
+
try {
|
|
218
|
+
fs2.renameSync(from, to);
|
|
219
|
+
return;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
const code = error.code ?? "";
|
|
222
|
+
if (attempt >= 10 || !["EPERM", "EACCES", "EBUSY"].includes(code)) throw error;
|
|
223
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20 * attempt);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
var STORE_LOCK_FILE = `${CONFIG_FILE}.lock`;
|
|
228
|
+
async function updateStoredProfile(profileName, change2) {
|
|
229
|
+
return withFileLock(STORE_LOCK_FILE, () => {
|
|
230
|
+
const config = loadConfig();
|
|
231
|
+
const profile = config.profiles[profileName];
|
|
232
|
+
if (!profile) {
|
|
233
|
+
throw new Error(`Profile "${profileName}" not found.`);
|
|
234
|
+
}
|
|
235
|
+
change2(profile);
|
|
236
|
+
saveConfig(config);
|
|
237
|
+
return config;
|
|
238
|
+
}, { waitMs: 5e3 });
|
|
239
|
+
}
|
|
240
|
+
function readStoredProfile(profileName) {
|
|
241
|
+
return loadConfig().profiles[profileName];
|
|
242
|
+
}
|
|
243
|
+
function profileSidecarFile(profileName, suffix) {
|
|
244
|
+
const safe = profileName.replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40);
|
|
245
|
+
const digest = crypto2.createHash("sha256").update(profileName).digest("hex").slice(0, 8);
|
|
246
|
+
return `${CONFIG_FILE}.${safe}-${digest}.${suffix}`;
|
|
46
247
|
}
|
|
47
248
|
function resolveEndpoint(config, profileOverride) {
|
|
48
249
|
const name = profileOverride ?? config.currentProfile;
|
|
@@ -119,13 +320,207 @@ var NetworkError = class extends Error {
|
|
|
119
320
|
}
|
|
120
321
|
};
|
|
121
322
|
|
|
323
|
+
// src/client/sign-in.ts
|
|
324
|
+
import * as crypto3 from "crypto";
|
|
325
|
+
import * as fs3 from "fs";
|
|
326
|
+
var EXPIRY_MARGIN_MS = 3e4;
|
|
327
|
+
var TOKEN_REQUEST_TIMEOUT_MS = 1e4;
|
|
328
|
+
var MAX_RATE_LIMITED_ATTEMPTS = 3;
|
|
329
|
+
var DEFAULT_BACKOFF_MS = 5e3;
|
|
330
|
+
var MIN_BACKOFF_MS = 1e3;
|
|
331
|
+
var MAX_BACKOFF_MS = 12e4;
|
|
332
|
+
var NOTICE_THRESHOLD_MS = 2e3;
|
|
333
|
+
var SignInRefusedError = class extends ApiError {
|
|
334
|
+
constructor(profileName) {
|
|
335
|
+
super(401, `The stored sign-in of profile "${profileName}" is no longer accepted. Run 'diafunc auth login' to sign in again.`);
|
|
336
|
+
this.name = "SignInRefusedError";
|
|
337
|
+
}
|
|
338
|
+
toUserMessage() {
|
|
339
|
+
return this.message;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
function isAuthenticationFailure(error) {
|
|
343
|
+
return error instanceof ApiError && error.status === 401;
|
|
344
|
+
}
|
|
345
|
+
function isTokenExpired(auth) {
|
|
346
|
+
if (!auth) return false;
|
|
347
|
+
if (auth.type === "device-code") {
|
|
348
|
+
return Date.now() >= auth.accessTokenExpiry - EXPIRY_MARGIN_MS;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
function deriveAuthUrl(endpoint) {
|
|
353
|
+
const trimmed = endpoint.replace(/\/+$/, "");
|
|
354
|
+
if (trimmed.includes("://auth.")) {
|
|
355
|
+
return trimmed;
|
|
356
|
+
}
|
|
357
|
+
const url = new URL(trimmed);
|
|
358
|
+
url.hostname = `auth.${url.hostname}`;
|
|
359
|
+
url.pathname = "";
|
|
360
|
+
return url.toString().replace(/\/+$/, "");
|
|
361
|
+
}
|
|
362
|
+
function digestOf(token) {
|
|
363
|
+
return crypto3.createHash("sha256").update(token).digest("hex");
|
|
364
|
+
}
|
|
365
|
+
function retryAfterMs(header, now = Date.now()) {
|
|
366
|
+
let wait = DEFAULT_BACKOFF_MS;
|
|
367
|
+
if (header) {
|
|
368
|
+
const seconds = Number(header.trim());
|
|
369
|
+
if (Number.isFinite(seconds)) {
|
|
370
|
+
wait = seconds * 1e3;
|
|
371
|
+
} else {
|
|
372
|
+
const at = Date.parse(header);
|
|
373
|
+
if (Number.isFinite(at)) wait = at - now;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return Math.min(MAX_BACKOFF_MS, Math.max(MIN_BACKOFF_MS, wait));
|
|
377
|
+
}
|
|
378
|
+
function createSignInRefresher(options = {}) {
|
|
379
|
+
const sleep4 = options.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
380
|
+
const notify = options.notify ?? ((message) => console.error(message));
|
|
381
|
+
const lockOptions = { waitMs: options.lockWaitMs, staleMs: options.lockStaleMs };
|
|
382
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
383
|
+
const notBefore = /* @__PURE__ */ new Map();
|
|
384
|
+
const refused = /* @__PURE__ */ new Set();
|
|
385
|
+
function refusedMarkerFile(profileName) {
|
|
386
|
+
return profileSidecarFile(profileName, "refused");
|
|
387
|
+
}
|
|
388
|
+
function isKnownRefused(profileName, refreshToken) {
|
|
389
|
+
const digest = digestOf(refreshToken);
|
|
390
|
+
if (refused.has(digest)) return true;
|
|
391
|
+
try {
|
|
392
|
+
return fs3.readFileSync(refusedMarkerFile(profileName), "utf-8").trim() === digest;
|
|
393
|
+
} catch {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function rememberRefused(profileName, refreshToken, acrossProcesses) {
|
|
398
|
+
const digest = digestOf(refreshToken);
|
|
399
|
+
refused.add(digest);
|
|
400
|
+
if (!acrossProcesses) return;
|
|
401
|
+
try {
|
|
402
|
+
fs3.writeFileSync(refusedMarkerFile(profileName), digest + "\n", { encoding: "utf-8", mode: 384 });
|
|
403
|
+
} catch {
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function forgetRefused(profileName) {
|
|
407
|
+
fs3.rmSync(refusedMarkerFile(profileName), { force: true });
|
|
408
|
+
}
|
|
409
|
+
async function requestTokens(endpoint, auth) {
|
|
410
|
+
try {
|
|
411
|
+
return await fetch(`${deriveAuthUrl(endpoint)}/token`, {
|
|
412
|
+
method: "POST",
|
|
413
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
414
|
+
body: new URLSearchParams({
|
|
415
|
+
grant_type: "refresh_token",
|
|
416
|
+
refresh_token: auth.refreshToken,
|
|
417
|
+
client_id: auth.clientId
|
|
418
|
+
}).toString(),
|
|
419
|
+
signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
|
|
420
|
+
});
|
|
421
|
+
} catch (error) {
|
|
422
|
+
throw new NetworkError(
|
|
423
|
+
`Could not reach the sign-in service of ${endpoint} to renew the sign-in.`,
|
|
424
|
+
error instanceof Error ? error : void 0
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
async function renewUnderLock(profileName) {
|
|
429
|
+
const profile = readStoredProfile(profileName);
|
|
430
|
+
const stored = profile?.auth;
|
|
431
|
+
if (!profile || !stored) {
|
|
432
|
+
throw new SignInRefusedError(profileName);
|
|
433
|
+
}
|
|
434
|
+
if (stored.type !== "device-code" || !isTokenExpired(stored)) {
|
|
435
|
+
return { kind: "credentials", auth: stored };
|
|
436
|
+
}
|
|
437
|
+
if (isKnownRefused(profileName, stored.refreshToken)) {
|
|
438
|
+
throw new SignInRefusedError(profileName);
|
|
439
|
+
}
|
|
440
|
+
let response;
|
|
441
|
+
try {
|
|
442
|
+
response = await requestTokens(profile.endpoint.replace(/\/+$/, ""), stored);
|
|
443
|
+
} catch (error) {
|
|
444
|
+
notBefore.set(profileName, Date.now() + DEFAULT_BACKOFF_MS);
|
|
445
|
+
throw error;
|
|
446
|
+
}
|
|
447
|
+
if (response.ok) {
|
|
448
|
+
const body = await response.json();
|
|
449
|
+
const renewed = {
|
|
450
|
+
type: "device-code",
|
|
451
|
+
clientId: stored.clientId,
|
|
452
|
+
accessToken: body.access_token,
|
|
453
|
+
refreshToken: body.refresh_token ?? stored.refreshToken,
|
|
454
|
+
accessTokenExpiry: Date.now() + body.expires_in * 1e3
|
|
455
|
+
};
|
|
456
|
+
await updateStoredProfile(profileName, (target) => {
|
|
457
|
+
target.auth = renewed;
|
|
458
|
+
});
|
|
459
|
+
forgetRefused(profileName);
|
|
460
|
+
return { kind: "credentials", auth: renewed };
|
|
461
|
+
}
|
|
462
|
+
if (response.status === 429) {
|
|
463
|
+
return { kind: "rate-limited", retryAfterMs: retryAfterMs(response.headers.get("retry-after")) };
|
|
464
|
+
}
|
|
465
|
+
if (response.status === 400 || response.status === 401) {
|
|
466
|
+
const reason2 = await response.json().then((body) => body.error, () => void 0);
|
|
467
|
+
const current = readStoredProfile(profileName)?.auth;
|
|
468
|
+
if (current && (current.type !== "device-code" || current.refreshToken !== stored.refreshToken)) {
|
|
469
|
+
return { kind: "credentials", auth: current };
|
|
470
|
+
}
|
|
471
|
+
rememberRefused(profileName, stored.refreshToken, reason2 === "invalid_grant");
|
|
472
|
+
throw new SignInRefusedError(profileName);
|
|
473
|
+
}
|
|
474
|
+
notBefore.set(profileName, Date.now() + DEFAULT_BACKOFF_MS);
|
|
475
|
+
throw new ApiError(response.status, `The sign-in service answered ${response.status} while renewing the sign-in.`);
|
|
476
|
+
}
|
|
477
|
+
async function waitOutBackoff(profileName) {
|
|
478
|
+
const wait = (notBefore.get(profileName) ?? 0) - Date.now();
|
|
479
|
+
if (wait <= 0) return;
|
|
480
|
+
if (wait >= NOTICE_THRESHOLD_MS) {
|
|
481
|
+
notify(`The sign-in service asked to wait; renewing the sign-in in ${Math.ceil(wait / 1e3)} s.`);
|
|
482
|
+
}
|
|
483
|
+
await sleep4(wait + Math.floor(Math.random() * 250));
|
|
484
|
+
}
|
|
485
|
+
async function renew(profileName) {
|
|
486
|
+
for (let attempt = 1; ; attempt++) {
|
|
487
|
+
await waitOutBackoff(profileName);
|
|
488
|
+
let outcome;
|
|
489
|
+
try {
|
|
490
|
+
outcome = await withFileLock(profileSidecarFile(profileName, "refresh.lock"), () => renewUnderLock(profileName), lockOptions);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
if (!(error instanceof LockTimeoutError)) throw error;
|
|
493
|
+
const stored = readStoredProfile(profileName)?.auth;
|
|
494
|
+
if (stored && !isTokenExpired(stored)) return stored;
|
|
495
|
+
throw new NetworkError("Another diafunc process is still renewing the sign-in of this profile. Try again in a moment.");
|
|
496
|
+
}
|
|
497
|
+
if (outcome.kind === "credentials") return outcome.auth;
|
|
498
|
+
notBefore.set(profileName, Date.now() + outcome.retryAfterMs);
|
|
499
|
+
if (attempt >= MAX_RATE_LIMITED_ATTEMPTS) {
|
|
500
|
+
throw new ApiError(429, `The sign-in service is limiting requests from this address. Try again in ${Math.ceil(outcome.retryAfterMs / 1e3)} s.`);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
ensureFresh(profileName) {
|
|
506
|
+
let pending = inFlight.get(profileName);
|
|
507
|
+
if (!pending) {
|
|
508
|
+
pending = renew(profileName).finally(() => inFlight.delete(profileName));
|
|
509
|
+
inFlight.set(profileName, pending);
|
|
510
|
+
}
|
|
511
|
+
return pending;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
var sharedSignIn = createSignInRefresher();
|
|
516
|
+
|
|
122
517
|
// src/client/http.ts
|
|
123
518
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
124
519
|
var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
125
520
|
var MAX_ATTEMPTS = 3;
|
|
126
521
|
var RETRYABLE_METHODS = /* @__PURE__ */ new Set(["GET"]);
|
|
127
|
-
function buildUrl(endpoint, service,
|
|
128
|
-
const base = `${endpoint}/api/v1/${service}${
|
|
522
|
+
function buildUrl(endpoint, service, path13, query) {
|
|
523
|
+
const base = `${endpoint}/api/v1/${service}${path13}`;
|
|
129
524
|
const params = new URLSearchParams();
|
|
130
525
|
if (query) {
|
|
131
526
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -147,62 +542,12 @@ function getAuthHeader(auth) {
|
|
|
147
542
|
}
|
|
148
543
|
return void 0;
|
|
149
544
|
}
|
|
150
|
-
function isTokenExpired(auth) {
|
|
151
|
-
if (!auth) return false;
|
|
152
|
-
if (auth.type === "device-code") {
|
|
153
|
-
return Date.now() >= auth.accessTokenExpiry - 3e4;
|
|
154
|
-
}
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
function deriveAuthUrl(endpoint) {
|
|
158
|
-
const trimmed = endpoint.replace(/\/+$/, "");
|
|
159
|
-
if (trimmed.includes("://auth.")) {
|
|
160
|
-
return trimmed;
|
|
161
|
-
}
|
|
162
|
-
const url = new URL(trimmed);
|
|
163
|
-
url.hostname = `auth.${url.hostname}`;
|
|
164
|
-
url.pathname = "";
|
|
165
|
-
return url.toString().replace(/\/+$/, "");
|
|
166
|
-
}
|
|
167
|
-
async function refreshOAuthTokens(endpoint, clientId, refreshToken) {
|
|
168
|
-
const authUrl = deriveAuthUrl(endpoint);
|
|
169
|
-
const response = await fetch(`${authUrl}/token`, {
|
|
170
|
-
method: "POST",
|
|
171
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
172
|
-
body: new URLSearchParams({
|
|
173
|
-
grant_type: "refresh_token",
|
|
174
|
-
refresh_token: refreshToken,
|
|
175
|
-
client_id: clientId
|
|
176
|
-
}).toString()
|
|
177
|
-
});
|
|
178
|
-
if (!response.ok) {
|
|
179
|
-
throw new ApiError(response.status, "OAuth token refresh failed. Please run `diafunc auth login` again.");
|
|
180
|
-
}
|
|
181
|
-
const body = await response.json();
|
|
182
|
-
return {
|
|
183
|
-
accessToken: body.access_token,
|
|
184
|
-
refreshToken: body.refresh_token,
|
|
185
|
-
accessTokenExpiry: Date.now() + body.expires_in * 1e3
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
545
|
async function ensureValidAuth(config, profileOverride) {
|
|
189
546
|
const profileName = profileOverride ?? config.currentProfile;
|
|
190
547
|
const profile = config.profiles[profileName];
|
|
191
548
|
if (!profile?.auth) return void 0;
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
const endpoint = resolveEndpoint(config, profileOverride);
|
|
196
|
-
if (profile.auth.type === "device-code") {
|
|
197
|
-
const refreshed = await refreshOAuthTokens(endpoint, profile.auth.clientId, profile.auth.refreshToken);
|
|
198
|
-
profile.auth = {
|
|
199
|
-
type: "device-code",
|
|
200
|
-
clientId: profile.auth.clientId,
|
|
201
|
-
accessToken: refreshed.accessToken,
|
|
202
|
-
refreshToken: refreshed.refreshToken,
|
|
203
|
-
accessTokenExpiry: refreshed.accessTokenExpiry
|
|
204
|
-
};
|
|
205
|
-
saveConfig(config);
|
|
549
|
+
if (profile.auth.type === "device-code" && isTokenExpired(profile.auth)) {
|
|
550
|
+
profile.auth = await sharedSignIn.ensureFresh(profileName);
|
|
206
551
|
}
|
|
207
552
|
return profile.auth;
|
|
208
553
|
}
|
|
@@ -315,7 +660,7 @@ ${bodyPreview}`));
|
|
|
315
660
|
);
|
|
316
661
|
}
|
|
317
662
|
function delay(ms) {
|
|
318
|
-
return new Promise((
|
|
663
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
319
664
|
}
|
|
320
665
|
return {
|
|
321
666
|
async request(opts) {
|
|
@@ -866,7 +1211,7 @@ function handleError(error) {
|
|
|
866
1211
|
}
|
|
867
1212
|
if (error instanceof ApiError) {
|
|
868
1213
|
failure(error.toUserMessage());
|
|
869
|
-
if (error.status === 401) hint(`Run 'diafunc auth login' to sign in.`);
|
|
1214
|
+
if (error.status === 401 && !(error instanceof SignInRefusedError)) hint(`Run 'diafunc auth login' to sign in.`);
|
|
870
1215
|
if (error.status === 404) hint(`Check the id, or list what exists with the matching 'list' command.`);
|
|
871
1216
|
process.exit(error.status === 401 || error.status === 403 ? EXIT_AUTH : EXIT_FAILURE);
|
|
872
1217
|
}
|
|
@@ -912,7 +1257,7 @@ function registerLoginCommand(parent) {
|
|
|
912
1257
|
}
|
|
913
1258
|
if (options.token) {
|
|
914
1259
|
profile.auth = { type: "api-token", token: options.token };
|
|
915
|
-
|
|
1260
|
+
await storeSignIn(config.currentProfile, profile);
|
|
916
1261
|
const client = createHttpClient();
|
|
917
1262
|
const admin = createAdminService(client);
|
|
918
1263
|
const user = await admin.getMyUser();
|
|
@@ -929,6 +1274,12 @@ function registerLoginCommand(parent) {
|
|
|
929
1274
|
}
|
|
930
1275
|
});
|
|
931
1276
|
}
|
|
1277
|
+
async function storeSignIn(profileName, signedIn) {
|
|
1278
|
+
await updateStoredProfile(profileName, (stored) => {
|
|
1279
|
+
stored.endpoint = signedIn.endpoint;
|
|
1280
|
+
stored.auth = signedIn.auth;
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
932
1283
|
async function deviceCodeLogin(config, profile) {
|
|
933
1284
|
const authUrl = deriveAuthUrl2(profile.endpoint);
|
|
934
1285
|
const deviceResponse = await fetch(`${authUrl}/device_authorization`, {
|
|
@@ -972,7 +1323,7 @@ async function deviceCodeLogin(config, profile) {
|
|
|
972
1323
|
refreshToken: tokens.refresh_token,
|
|
973
1324
|
accessTokenExpiry: Date.now() + (tokens.expires_in || ACCESS_TOKEN_LIFETIME_SECONDS) * 1e3
|
|
974
1325
|
};
|
|
975
|
-
|
|
1326
|
+
await storeSignIn(config.currentProfile, profile);
|
|
976
1327
|
const client = createHttpClient();
|
|
977
1328
|
const admin = createAdminService(client);
|
|
978
1329
|
const user = await admin.getMyUser();
|
|
@@ -1002,7 +1353,7 @@ async function deviceCodeLogin(config, profile) {
|
|
|
1002
1353
|
process.exit(1);
|
|
1003
1354
|
}
|
|
1004
1355
|
function sleep(ms) {
|
|
1005
|
-
return new Promise((
|
|
1356
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
1006
1357
|
}
|
|
1007
1358
|
|
|
1008
1359
|
// src/commands/auth/logout.ts
|
|
@@ -1043,8 +1394,9 @@ function registerLogoutCommand(parent) {
|
|
|
1043
1394
|
} catch {
|
|
1044
1395
|
}
|
|
1045
1396
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1397
|
+
await updateStoredProfile(config.currentProfile, (stored) => {
|
|
1398
|
+
delete stored.auth;
|
|
1399
|
+
});
|
|
1048
1400
|
success(`Logged out from profile "${config.currentProfile}".`);
|
|
1049
1401
|
});
|
|
1050
1402
|
}
|
|
@@ -2008,6 +2360,33 @@ function createStorageService(client) {
|
|
|
2008
2360
|
path: `/entities/revert${entityPath(ref)}/${version}`
|
|
2009
2361
|
});
|
|
2010
2362
|
},
|
|
2363
|
+
/**
|
|
2364
|
+
* Adds tags to an entity and takes others off, in one storage transaction. The platform applies
|
|
2365
|
+
* the removals, then the additions, and counts a tag that is already there (or already gone) as
|
|
2366
|
+
* nothing to do; nothing else of the entity is touched.
|
|
2367
|
+
*
|
|
2368
|
+
* A transaction writes an entity that does not exist yet, so a caller that means to change an
|
|
2369
|
+
* existing one reads it first.
|
|
2370
|
+
*/
|
|
2371
|
+
async changeEntityTags(ref, change2) {
|
|
2372
|
+
const transaction = {
|
|
2373
|
+
projectId: ref.projectId,
|
|
2374
|
+
projectBranch: ref.projectBranch,
|
|
2375
|
+
consistency: "WEAK",
|
|
2376
|
+
entityDeltas: {
|
|
2377
|
+
[`${ref.entityId}/${ref.entityBranch}`]: {
|
|
2378
|
+
...change2.addTags?.length ? { addTags: change2.addTags } : {},
|
|
2379
|
+
...change2.removeTags?.length ? { removeTags: change2.removeTags } : {}
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
};
|
|
2383
|
+
return client.request({
|
|
2384
|
+
method: "POST",
|
|
2385
|
+
service: SERVICE3,
|
|
2386
|
+
path: "/transactions/",
|
|
2387
|
+
body: transaction
|
|
2388
|
+
});
|
|
2389
|
+
},
|
|
2011
2390
|
// --- Entity Sets ---
|
|
2012
2391
|
async searchEntityIds(projectId, projectBranch, body) {
|
|
2013
2392
|
return client.request({
|
|
@@ -2058,14 +2437,14 @@ function createStorageService(client) {
|
|
|
2058
2437
|
});
|
|
2059
2438
|
},
|
|
2060
2439
|
async deleteLink(projectId, projectBranch, sourceEntityId, sourceEntityBranch, linkId, targetEntityId, targetEntityBranch) {
|
|
2061
|
-
let
|
|
2440
|
+
let path13 = `/links/actual/${enc(projectId)}/${enc(projectBranch)}/${enc(sourceEntityId)}/${enc(sourceEntityBranch)}/${enc(linkId)}`;
|
|
2062
2441
|
if (targetEntityId && targetEntityBranch) {
|
|
2063
|
-
|
|
2442
|
+
path13 += `/${enc(targetEntityId)}/${enc(targetEntityBranch)}`;
|
|
2064
2443
|
}
|
|
2065
2444
|
return client.request({
|
|
2066
2445
|
method: "DELETE",
|
|
2067
2446
|
service: SERVICE3,
|
|
2068
|
-
path:
|
|
2447
|
+
path: path13
|
|
2069
2448
|
});
|
|
2070
2449
|
},
|
|
2071
2450
|
// --- Events ---
|
|
@@ -2862,6 +3241,44 @@ function createIndexService(client) {
|
|
|
2862
3241
|
}
|
|
2863
3242
|
});
|
|
2864
3243
|
},
|
|
3244
|
+
/**
|
|
3245
|
+
* The curated tags in their order. Public: no account is needed. With `counts` each also says
|
|
3246
|
+
* how many public projects carry it.
|
|
3247
|
+
*/
|
|
3248
|
+
async getCuratedTags(counts = false) {
|
|
3249
|
+
return client.request({
|
|
3250
|
+
method: "GET",
|
|
3251
|
+
service: SERVICE7,
|
|
3252
|
+
path: "/tags/curated",
|
|
3253
|
+
query: counts ? { counts: true } : void 0
|
|
3254
|
+
});
|
|
3255
|
+
},
|
|
3256
|
+
/** Administrators only. The platform stores the tag in its canonical form. */
|
|
3257
|
+
async createCuratedTag(request) {
|
|
3258
|
+
return client.request({
|
|
3259
|
+
method: "POST",
|
|
3260
|
+
service: SERVICE7,
|
|
3261
|
+
path: "/admin/curated-tags",
|
|
3262
|
+
body: request
|
|
3263
|
+
});
|
|
3264
|
+
},
|
|
3265
|
+
/** Administrators only. A field left out of the request keeps what is stored. */
|
|
3266
|
+
async updateCuratedTag(tag, request) {
|
|
3267
|
+
return client.request({
|
|
3268
|
+
method: "PUT",
|
|
3269
|
+
service: SERVICE7,
|
|
3270
|
+
path: `/admin/curated-tags/${enc5(tag)}`,
|
|
3271
|
+
body: request
|
|
3272
|
+
});
|
|
3273
|
+
},
|
|
3274
|
+
/** Administrators only. Projects that carry the tag keep it; it only stops being curated. */
|
|
3275
|
+
async deleteCuratedTag(tag) {
|
|
3276
|
+
return client.request({
|
|
3277
|
+
method: "DELETE",
|
|
3278
|
+
service: SERVICE7,
|
|
3279
|
+
path: `/admin/curated-tags/${enc5(tag)}`
|
|
3280
|
+
});
|
|
3281
|
+
},
|
|
2865
3282
|
async rebuildAll() {
|
|
2866
3283
|
return client.request({
|
|
2867
3284
|
method: "POST",
|
|
@@ -3102,8 +3519,8 @@ Examples:
|
|
|
3102
3519
|
success(`Profile "${name}" removed.`);
|
|
3103
3520
|
});
|
|
3104
3521
|
}
|
|
3105
|
-
function setNestedValue(obj,
|
|
3106
|
-
const keys =
|
|
3522
|
+
function setNestedValue(obj, path13, value) {
|
|
3523
|
+
const keys = path13.split(".");
|
|
3107
3524
|
let current = obj;
|
|
3108
3525
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
3109
3526
|
const key = keys[i];
|
|
@@ -3114,8 +3531,8 @@ function setNestedValue(obj, path12, value) {
|
|
|
3114
3531
|
}
|
|
3115
3532
|
current[keys[keys.length - 1]] = value;
|
|
3116
3533
|
}
|
|
3117
|
-
function getNestedValue(obj,
|
|
3118
|
-
const keys =
|
|
3534
|
+
function getNestedValue(obj, path13) {
|
|
3535
|
+
const keys = path13.split(".");
|
|
3119
3536
|
let current = obj;
|
|
3120
3537
|
for (const key of keys) {
|
|
3121
3538
|
if (current === null || current === void 0 || typeof current !== "object") {
|
|
@@ -3127,7 +3544,7 @@ function getNestedValue(obj, path12) {
|
|
|
3127
3544
|
}
|
|
3128
3545
|
|
|
3129
3546
|
// src/commands/project/index.ts
|
|
3130
|
-
import
|
|
3547
|
+
import chalk13 from "chalk";
|
|
3131
3548
|
|
|
3132
3549
|
// src/util/references.ts
|
|
3133
3550
|
function parseEntityReference(ref, overrides) {
|
|
@@ -3213,8 +3630,8 @@ function parseProjectReference(ref, overrides) {
|
|
|
3213
3630
|
|
|
3214
3631
|
// src/commands/bundle-helpers.ts
|
|
3215
3632
|
import chalk11 from "chalk";
|
|
3216
|
-
import * as
|
|
3217
|
-
import * as
|
|
3633
|
+
import * as fs4 from "fs";
|
|
3634
|
+
import * as path3 from "path";
|
|
3218
3635
|
|
|
3219
3636
|
// src/output/progress.ts
|
|
3220
3637
|
import chalk10 from "chalk";
|
|
@@ -3344,7 +3761,7 @@ function shift(value, exponent) {
|
|
|
3344
3761
|
// src/commands/bundle-helpers.ts
|
|
3345
3762
|
async function streamResponseToFile(response, outFile) {
|
|
3346
3763
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
3347
|
-
|
|
3764
|
+
fs4.writeFileSync(outFile, buffer);
|
|
3348
3765
|
return buffer.length;
|
|
3349
3766
|
}
|
|
3350
3767
|
function printLossiness(notes) {
|
|
@@ -3395,10 +3812,10 @@ function printImportResult(result) {
|
|
|
3395
3812
|
printLossiness(result.lossinessNotes);
|
|
3396
3813
|
}
|
|
3397
3814
|
async function runBundleImport(storage, projectId, projectBranch, file, options, outputFormat) {
|
|
3398
|
-
const fileBuffer =
|
|
3815
|
+
const fileBuffer = fs4.readFileSync(file);
|
|
3399
3816
|
const blob = new Blob([fileBuffer]);
|
|
3400
3817
|
const formData = new FormData();
|
|
3401
|
-
formData.append("content", blob,
|
|
3818
|
+
formData.append("content", blob, path3.basename(file));
|
|
3402
3819
|
if (options.preview) {
|
|
3403
3820
|
const preview = await storage.previewBundleImport(projectId, projectBranch, formData);
|
|
3404
3821
|
if (outputFormat === "json") {
|
|
@@ -3415,7 +3832,7 @@ async function runBundleImport(storage, projectId, projectBranch, file, options,
|
|
|
3415
3832
|
}
|
|
3416
3833
|
printImportResult(result);
|
|
3417
3834
|
}
|
|
3418
|
-
var sleep2 = (ms) => new Promise((
|
|
3835
|
+
var sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
3419
3836
|
async function pollUntilFinished(storage, projectId, projectBranch, bundleId, intervalMs = 2e3, maxAttempts = 150) {
|
|
3420
3837
|
const status = new Status();
|
|
3421
3838
|
status.start();
|
|
@@ -3488,12 +3905,219 @@ async function projectNames(api, projectIds) {
|
|
|
3488
3905
|
return names;
|
|
3489
3906
|
}
|
|
3490
3907
|
|
|
3491
|
-
// src/commands/
|
|
3908
|
+
// src/commands/entity/tags.ts
|
|
3909
|
+
import chalk12 from "chalk";
|
|
3910
|
+
|
|
3911
|
+
// src/util/tags.ts
|
|
3912
|
+
var NON_SPACING_MARK = new RegExp("^\\p{Mn}$", "u");
|
|
3913
|
+
var LETTER_OR_DIGIT = /^[\p{L}\p{Nd}]$/u;
|
|
3914
|
+
var SPACE_SEPARATOR = /^[\p{Zs}\p{Zl}\p{Zp}]$/u;
|
|
3915
|
+
var NON_BREAKING = /* @__PURE__ */ new Set(["\xA0", "\u2007", "\u202F"]);
|
|
3916
|
+
var CONTROL_WHITESPACE = /^[\t\n\u000B\f\r\u001C-\u001F]$/;
|
|
3917
|
+
function isWhitespace(ch) {
|
|
3918
|
+
return CONTROL_WHITESPACE.test(ch) || SPACE_SEPARATOR.test(ch) && !NON_BREAKING.has(ch);
|
|
3919
|
+
}
|
|
3920
|
+
function normalizeTag(raw) {
|
|
3921
|
+
const decomposed = raw.normalize("NFD");
|
|
3922
|
+
let out = "";
|
|
3923
|
+
let lastWasDash = false;
|
|
3924
|
+
for (let i = 0; i < decomposed.length; i++) {
|
|
3925
|
+
const ch = decomposed[i];
|
|
3926
|
+
if (NON_SPACING_MARK.test(ch)) continue;
|
|
3927
|
+
const lowered = ch.toLowerCase();
|
|
3928
|
+
const lower = lowered.length === 1 ? lowered : ch;
|
|
3929
|
+
if (LETTER_OR_DIGIT.test(lower)) {
|
|
3930
|
+
out += lower;
|
|
3931
|
+
lastWasDash = false;
|
|
3932
|
+
} else if (lower === "-" || lower === "_" || isWhitespace(lower)) {
|
|
3933
|
+
if (out.length > 0 && !lastWasDash) {
|
|
3934
|
+
out += "-";
|
|
3935
|
+
lastWasDash = true;
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
return lastWasDash ? out.slice(0, -1) : out;
|
|
3940
|
+
}
|
|
3941
|
+
var RESERVED_PREFIXES = ["auto-analysis-staging", "staging-run"];
|
|
3942
|
+
function isReservedTag(normalized) {
|
|
3943
|
+
return RESERVED_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
3944
|
+
}
|
|
3945
|
+
var TagError = class extends Error {
|
|
3946
|
+
constructor(message) {
|
|
3947
|
+
super(message);
|
|
3948
|
+
this.name = "TagError";
|
|
3949
|
+
}
|
|
3950
|
+
};
|
|
3951
|
+
function canonicalTags(given) {
|
|
3952
|
+
const tags = [];
|
|
3953
|
+
const renamed = [];
|
|
3954
|
+
for (const typed2 of given.flatMap((entry) => entry.split(",")).map((entry) => entry.trim())) {
|
|
3955
|
+
if (typed2 === "") continue;
|
|
3956
|
+
const tag = normalizeTag(typed2);
|
|
3957
|
+
if (tag === "") {
|
|
3958
|
+
throw new TagError(`"${typed2}" is not a usable tag: a tag needs at least one letter or digit.`);
|
|
3959
|
+
}
|
|
3960
|
+
if (isReservedTag(tag)) {
|
|
3961
|
+
throw new TagError(
|
|
3962
|
+
`"${typed2}" is reserved: tags beginning with ${RESERVED_PREFIXES.map((p) => `"${p}"`).join(" or ")} mark the staging content of an analysis run and are never searchable.`
|
|
3963
|
+
);
|
|
3964
|
+
}
|
|
3965
|
+
if (tag !== typed2) renamed.push([typed2, tag]);
|
|
3966
|
+
if (!tags.includes(tag)) tags.push(tag);
|
|
3967
|
+
}
|
|
3968
|
+
return { tags, renamed };
|
|
3969
|
+
}
|
|
3970
|
+
function planTagChange(operation, current, tags) {
|
|
3971
|
+
const wanted = new Set(tags);
|
|
3972
|
+
let addTags = [];
|
|
3973
|
+
let removeTags = [];
|
|
3974
|
+
if (operation === "add") {
|
|
3975
|
+
addTags = tags.filter((tag) => !current.includes(tag));
|
|
3976
|
+
} else if (operation === "remove") {
|
|
3977
|
+
removeTags = current.filter((stored) => wanted.has(stored) || wanted.has(normalizeTag(stored)));
|
|
3978
|
+
} else {
|
|
3979
|
+
addTags = tags.filter((tag) => !current.includes(tag));
|
|
3980
|
+
removeTags = current.filter((stored) => !wanted.has(stored));
|
|
3981
|
+
}
|
|
3982
|
+
const result = [...current.filter((stored) => !removeTags.includes(stored)), ...addTags];
|
|
3983
|
+
return { addTags, removeTags, result: sortTags(result) };
|
|
3984
|
+
}
|
|
3985
|
+
function sortTags(tags) {
|
|
3986
|
+
return [...tags].sort((a, b) => a.localeCompare(b));
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
// src/commands/entity/tags.ts
|
|
3492
3990
|
function getOutputFormat(cmd) {
|
|
3493
3991
|
const config = loadConfig();
|
|
3494
3992
|
const globalOpts = cmd.optsWithGlobals();
|
|
3495
3993
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
3496
3994
|
}
|
|
3995
|
+
function resolve(target, ref, cmd) {
|
|
3996
|
+
const opts = cmd.optsWithGlobals();
|
|
3997
|
+
const overrides = { project: opts.project, branch: opts.branch };
|
|
3998
|
+
if (target === "entity") return parseEntityReference(ref, overrides);
|
|
3999
|
+
const project = parseProjectReference(ref, overrides);
|
|
4000
|
+
return { ...project, entityId: project.projectId, entityBranch: "main" };
|
|
4001
|
+
}
|
|
4002
|
+
function printTags(result, outputFormat) {
|
|
4003
|
+
if (outputFormat === "json") {
|
|
4004
|
+
format(result, { format: outputFormat });
|
|
4005
|
+
} else if (outputFormat === "table") {
|
|
4006
|
+
format(result.tags.map((tag) => ({ tag })), { format: outputFormat, columns: ["tag"] });
|
|
4007
|
+
} else if (result.tags.length === 0) {
|
|
4008
|
+
empty("tags");
|
|
4009
|
+
} else {
|
|
4010
|
+
console.log(result.tags.join(", "));
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
function describeChange(added, removed) {
|
|
4014
|
+
const parts = [
|
|
4015
|
+
...added.length ? [`added ${added.join(", ")}`] : [],
|
|
4016
|
+
...removed.length ? [`removed ${removed.join(", ")}`] : []
|
|
4017
|
+
];
|
|
4018
|
+
return parts.join("; ");
|
|
4019
|
+
}
|
|
4020
|
+
async function show(target, ref, cmd) {
|
|
4021
|
+
const resolved = resolve(target, ref, cmd);
|
|
4022
|
+
const entity = await createApiClient().storage.getEntity(resolved);
|
|
4023
|
+
printTags({ ...resolved, tags: sortTags(entity.tags ?? []) }, getOutputFormat(cmd));
|
|
4024
|
+
}
|
|
4025
|
+
async function change(target, operation, ref, given, cmd) {
|
|
4026
|
+
const outputFormat = getOutputFormat(cmd);
|
|
4027
|
+
const resolved = resolve(target, ref, cmd);
|
|
4028
|
+
const { tags, renamed } = canonicalTags(Array.isArray(given) ? given : [given]);
|
|
4029
|
+
if (tags.length === 0 && operation !== "set") {
|
|
4030
|
+
usageError("No tags given.", `Name at least one: diafunc ${target} tags ${operation} ${ref} <tag> [<tag>...]`);
|
|
4031
|
+
}
|
|
4032
|
+
for (const [typed2, tag] of renamed) {
|
|
4033
|
+
console.error(chalk12.dim(`"${typed2}" is written as "${tag}", the form tags are searched by.`));
|
|
4034
|
+
}
|
|
4035
|
+
const api = createApiClient();
|
|
4036
|
+
const current = (await api.storage.getEntity(resolved)).tags ?? [];
|
|
4037
|
+
const plan = planTagChange(operation, current, tags);
|
|
4038
|
+
const noun = target === "project" ? `project "${resolved.projectId}"` : `entity "${resolved.entityId}"`;
|
|
4039
|
+
if (plan.addTags.length === 0 && plan.removeTags.length === 0) {
|
|
4040
|
+
if (outputFormat === "human") success(`Tags of ${noun} are already as asked; nothing changed.`);
|
|
4041
|
+
printTags({ ...resolved, tags: sortTags(current), added: [], removed: [] }, outputFormat);
|
|
4042
|
+
return;
|
|
4043
|
+
}
|
|
4044
|
+
await api.storage.changeEntityTags(resolved, { addTags: plan.addTags, removeTags: plan.removeTags });
|
|
4045
|
+
const outcome = { added: plan.addTags, removed: plan.removeTags };
|
|
4046
|
+
if (isDryRun()) {
|
|
4047
|
+
if (outputFormat === "human") console.log(chalk12.dim(`Would leave ${noun} with:`));
|
|
4048
|
+
printTags({ ...resolved, tags: plan.result, ...outcome, dryRun: true }, outputFormat);
|
|
4049
|
+
return;
|
|
4050
|
+
}
|
|
4051
|
+
const stored = (await api.storage.getEntity(resolved)).tags ?? [];
|
|
4052
|
+
if (outputFormat === "human") success(`Tags of ${noun} updated: ${describeChange(plan.addTags, plan.removeTags)}.`);
|
|
4053
|
+
printTags({ ...resolved, tags: sortTags(stored), ...outcome }, outputFormat);
|
|
4054
|
+
}
|
|
4055
|
+
function guarded(run) {
|
|
4056
|
+
return run().catch((error) => {
|
|
4057
|
+
if (error instanceof TagError) usageError(error.message);
|
|
4058
|
+
handleError(error);
|
|
4059
|
+
});
|
|
4060
|
+
}
|
|
4061
|
+
var NORMALISATION = `
|
|
4062
|
+
Tags are written in the form they are searched by: lowercase, accents dropped,
|
|
4063
|
+
spaces and underscores as "-", punctuation removed ("Machine Learning" becomes
|
|
4064
|
+
"machine-learning"). Tags beginning with "auto-analysis-staging" or "staging-run"
|
|
4065
|
+
are reserved for analysis runs and are refused.`;
|
|
4066
|
+
function registerTagCommands(parent, target) {
|
|
4067
|
+
const argName = target === "project" ? "<projectId>" : "<ref>";
|
|
4068
|
+
const argHelp = target === "project" ? "Project ID (or projectId/branch)" : "Entity reference";
|
|
4069
|
+
const example = target === "project" ? "diafunc project tags" : "diafunc entity tags";
|
|
4070
|
+
const sample = target === "project" ? "<projectId>" : "<project>/main/<entity>/main";
|
|
4071
|
+
const tags = parent.command("tags").description(target === "project" ? "Show and change a project's tags, the ones Explore and the search filter by" : "Show and change an entity's tags").addHelpText("after", `${target === "project" ? `
|
|
4072
|
+
A project's tags are the tags of its project entity, so this is 'diafunc entity tags'
|
|
4073
|
+
on <projectId>/main/<projectId>/main. Changing them needs edit access to the project.
|
|
4074
|
+
` : ""}${NORMALISATION}
|
|
4075
|
+
|
|
4076
|
+
Examples:
|
|
4077
|
+
$ ${example} get ${sample}
|
|
4078
|
+
$ ${example} add ${sample} health "Machine Learning"
|
|
4079
|
+
$ ${example} remove ${sample} health
|
|
4080
|
+
$ ${example} set ${sample} energy climate exactly these two
|
|
4081
|
+
$ ${example} set ${sample} "" no tags at all
|
|
4082
|
+
$ diafunc admin curated-tags list the tags Explore offers as data domains
|
|
4083
|
+
`);
|
|
4084
|
+
tags.command("get").description(`Show the tags of ${target === "project" ? "a project" : "an entity"}`).argument(argName, argHelp).addHelpText("after", `
|
|
4085
|
+
Examples:
|
|
4086
|
+
$ ${example} get ${sample}
|
|
4087
|
+
$ ${example} get ${sample} -o json { ..., "tags": ["energy", "health"] }
|
|
4088
|
+
`).action((ref, _options, cmd) => guarded(() => show(target, ref, cmd)));
|
|
4089
|
+
tags.command("add").description("Add tags; one that is already there is left as it is").argument(argName, argHelp).argument("<tags...>", "Tags to add, as separate arguments or comma-separated").addHelpText("after", `${NORMALISATION}
|
|
4090
|
+
|
|
4091
|
+
Examples:
|
|
4092
|
+
$ ${example} add ${sample} health
|
|
4093
|
+
$ ${example} add ${sample} health energy "Machine Learning"
|
|
4094
|
+
$ ${example} add ${sample} health --dry-run print the request, send nothing
|
|
4095
|
+
`).action((ref, given, _options, cmd) => guarded(() => change(target, "add", ref, given, cmd)));
|
|
4096
|
+
tags.command("remove").description("Remove tags; one that is not there is ignored").argument(argName, argHelp).argument("<tags...>", "Tags to remove, as separate arguments or comma-separated").addHelpText("after", `
|
|
4097
|
+
A tag is matched in any spelling of the same tag: "Health" also removes a stored "health".
|
|
4098
|
+
|
|
4099
|
+
Examples:
|
|
4100
|
+
$ ${example} remove ${sample} health
|
|
4101
|
+
$ ${example} remove ${sample} health,energy --dry-run
|
|
4102
|
+
`).action((ref, given, _options, cmd) => guarded(() => change(target, "remove", ref, given, cmd)));
|
|
4103
|
+
tags.command("set").description("Replace the tags: afterwards exactly the given ones are there").argument(argName, argHelp).argument("<tags...>", "The complete tag set, as separate arguments or comma-separated (a single empty string removes every tag)").addHelpText("after", `${NORMALISATION}
|
|
4104
|
+
|
|
4105
|
+
Every tag that is not named is taken off, including ones the platform set itself
|
|
4106
|
+
(an analysis marks what it generates with "auto-analysis", for example).
|
|
4107
|
+
|
|
4108
|
+
Examples:
|
|
4109
|
+
$ ${example} set ${sample} energy climate
|
|
4110
|
+
$ ${example} set ${sample} "" no tags at all
|
|
4111
|
+
$ ${example} set ${sample} energy --dry-run print the request, send nothing
|
|
4112
|
+
`).action((ref, given, _options, cmd) => guarded(() => change(target, "set", ref, given, cmd)));
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
// src/commands/project/index.ts
|
|
4116
|
+
function getOutputFormat2(cmd) {
|
|
4117
|
+
const config = loadConfig();
|
|
4118
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
4119
|
+
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
4120
|
+
}
|
|
3497
4121
|
function getOverrides(cmd) {
|
|
3498
4122
|
const opts = cmd.optsWithGlobals();
|
|
3499
4123
|
return { project: opts.project, branch: opts.branch };
|
|
@@ -3507,7 +4131,7 @@ Examples:
|
|
|
3507
4131
|
$ diafunc search "housing" --type project find a project by name
|
|
3508
4132
|
`).action(async (options, cmd) => {
|
|
3509
4133
|
try {
|
|
3510
|
-
const outputFormat =
|
|
4134
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3511
4135
|
const api = createApiClient();
|
|
3512
4136
|
const projects = options.all ? await api.admin.getAllProjects() : await api.admin.getProjects();
|
|
3513
4137
|
const limit = Number.parseInt(options.limit, 10);
|
|
@@ -3516,7 +4140,7 @@ Examples:
|
|
|
3516
4140
|
try {
|
|
3517
4141
|
names = await projectNames(api, capped.map((p) => p.projectId));
|
|
3518
4142
|
} catch {
|
|
3519
|
-
console.error(
|
|
4143
|
+
console.error(chalk13.dim("Project names are unavailable right now; showing ids."));
|
|
3520
4144
|
}
|
|
3521
4145
|
const rows = capped.map((p) => ({ name: names.get(p.projectId) ?? null, ...p }));
|
|
3522
4146
|
format(rows, {
|
|
@@ -3533,7 +4157,7 @@ Examples:
|
|
|
3533
4157
|
]
|
|
3534
4158
|
});
|
|
3535
4159
|
if (capped.length < projects.length) {
|
|
3536
|
-
console.error(
|
|
4160
|
+
console.error(chalk13.dim(
|
|
3537
4161
|
`
|
|
3538
4162
|
Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
3539
4163
|
));
|
|
@@ -3544,7 +4168,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3544
4168
|
});
|
|
3545
4169
|
project.command("get").description("Get project details").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
3546
4170
|
try {
|
|
3547
|
-
const outputFormat =
|
|
4171
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3548
4172
|
const api = createApiClient();
|
|
3549
4173
|
const p = await api.admin.getProject(projectId);
|
|
3550
4174
|
format(p, { format: outputFormat });
|
|
@@ -3554,7 +4178,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3554
4178
|
});
|
|
3555
4179
|
project.command("create").description("Create a new project").option("--visibility <visibility>", "Project visibility (PRIVATE or PUBLIC)", "PRIVATE").option("--language <language>", "The project's default language for functions (Java, Kotlin, Python, JavaScript, Scala)", DEFAULT_FUNCTION_LANGUAGE).action(async (options, cmd) => {
|
|
3556
4180
|
try {
|
|
3557
|
-
const outputFormat =
|
|
4181
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3558
4182
|
const api = createApiClient();
|
|
3559
4183
|
const p = await api.admin.createProject({
|
|
3560
4184
|
visibility: options.visibility.toUpperCase(),
|
|
@@ -3568,7 +4192,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3568
4192
|
});
|
|
3569
4193
|
if (outputFormat === "human") {
|
|
3570
4194
|
success("Project created.");
|
|
3571
|
-
console.log(` Project ID: ${
|
|
4195
|
+
console.log(` Project ID: ${chalk13.bold(p.projectId)}`);
|
|
3572
4196
|
console.log(` Visibility: ${p.visibility}`);
|
|
3573
4197
|
console.log(` Language: ${p.language}`);
|
|
3574
4198
|
} else {
|
|
@@ -3578,7 +4202,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3578
4202
|
handleError(error);
|
|
3579
4203
|
}
|
|
3580
4204
|
});
|
|
3581
|
-
project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
|
|
4205
|
+
project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").option("--licence <licenceId>", "Licence a public project is published under, an id of the licence catalogue (CC-BY-4.0, CC0-1.0, diafunc-view-only, ...)").option("--data-source-name <name>", "Who published the data the project analyses; an empty value clears it").option("--data-source-url <url>", "Where the data was obtained, an http(s) address; an empty value clears it").action(async (projectId, options) => {
|
|
3582
4206
|
try {
|
|
3583
4207
|
const api = createApiClient();
|
|
3584
4208
|
const current = await api.admin.getProject(projectId);
|
|
@@ -3586,7 +4210,10 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3586
4210
|
...current,
|
|
3587
4211
|
...options.visibility ? { visibility: options.visibility.toUpperCase() } : {},
|
|
3588
4212
|
...options.language ? { language: options.language } : {},
|
|
3589
|
-
...options.active !== void 0 ? { active: options.active === "true" } : {}
|
|
4213
|
+
...options.active !== void 0 ? { active: options.active === "true" } : {},
|
|
4214
|
+
...options.licence ? { licenceId: options.licence } : {},
|
|
4215
|
+
...options.dataSourceName !== void 0 ? { dataSourceName: options.dataSourceName } : {},
|
|
4216
|
+
...options.dataSourceUrl !== void 0 ? { dataSourceUrl: options.dataSourceUrl } : {}
|
|
3590
4217
|
};
|
|
3591
4218
|
await api.admin.updateProject(updated);
|
|
3592
4219
|
success(`Project "${projectId}" updated.`);
|
|
@@ -3596,7 +4223,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3596
4223
|
});
|
|
3597
4224
|
project.command("recent").description("List recently accessed projects").action(async (_options, cmd) => {
|
|
3598
4225
|
try {
|
|
3599
|
-
const outputFormat =
|
|
4226
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3600
4227
|
const api = createApiClient();
|
|
3601
4228
|
const recent = await api.admin.getRecentProjects();
|
|
3602
4229
|
format(recent, {
|
|
@@ -3638,10 +4265,11 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3638
4265
|
handleError(error);
|
|
3639
4266
|
}
|
|
3640
4267
|
});
|
|
4268
|
+
registerTagCommands(project, "project");
|
|
3641
4269
|
const members = project.command("members").description("Manage project members");
|
|
3642
4270
|
members.command("list").description("List project members").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
3643
4271
|
try {
|
|
3644
|
-
const outputFormat =
|
|
4272
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3645
4273
|
const api = createApiClient();
|
|
3646
4274
|
const memberList = await api.admin.getProjectMembers(projectId);
|
|
3647
4275
|
format(memberList, {
|
|
@@ -3690,7 +4318,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3690
4318
|
console.log(`Poll progress: diafunc notebook bundles ${project2}`);
|
|
3691
4319
|
return;
|
|
3692
4320
|
}
|
|
3693
|
-
console.log(
|
|
4321
|
+
console.log(chalk13.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
|
|
3694
4322
|
const job = await pollUntilFinished(api.storage, ref.projectId, ref.projectBranch, bundleId);
|
|
3695
4323
|
const response = await api.storage.getBundleContent(ref.projectId, ref.projectBranch, bundleId, job.filename);
|
|
3696
4324
|
const outFile = options.out ?? "project.dfproj";
|
|
@@ -3702,7 +4330,7 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3702
4330
|
});
|
|
3703
4331
|
project.command("import").description("Import a .dfproj (or any) bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project2, file, options, cmd) => {
|
|
3704
4332
|
try {
|
|
3705
|
-
const outputFormat =
|
|
4333
|
+
const outputFormat = getOutputFormat2(cmd);
|
|
3706
4334
|
const overrides = getOverrides(cmd);
|
|
3707
4335
|
const ref = parseProjectReference(project2, overrides);
|
|
3708
4336
|
const api = createApiClient();
|
|
@@ -3714,25 +4342,25 @@ Showing ${capped.length} of ${projects.length}. Pass --limit 0 to see them all.`
|
|
|
3714
4342
|
}
|
|
3715
4343
|
|
|
3716
4344
|
// src/commands/team/index.ts
|
|
3717
|
-
import
|
|
4345
|
+
import chalk15 from "chalk";
|
|
3718
4346
|
|
|
3719
4347
|
// src/util/confirm.ts
|
|
3720
4348
|
import * as readline from "readline";
|
|
3721
|
-
import
|
|
4349
|
+
import chalk14 from "chalk";
|
|
3722
4350
|
async function confirmDestructive(message, opts = {}) {
|
|
3723
4351
|
if (!process.stdin.isTTY || opts.yes) return;
|
|
3724
4352
|
const expected = opts.resourceId ?? "yes";
|
|
3725
4353
|
const hint2 = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
|
|
3726
|
-
console.log(
|
|
3727
|
-
const answer = await new Promise((
|
|
4354
|
+
console.log(chalk14.yellow(`! ${message}`));
|
|
4355
|
+
const answer = await new Promise((resolve2) => {
|
|
3728
4356
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
3729
4357
|
rl.question(` Type ${hint2} to confirm: `, (ans) => {
|
|
3730
4358
|
rl.close();
|
|
3731
|
-
|
|
4359
|
+
resolve2(ans);
|
|
3732
4360
|
});
|
|
3733
4361
|
});
|
|
3734
4362
|
if (answer.trim() !== expected) {
|
|
3735
|
-
console.log(
|
|
4363
|
+
console.log(chalk14.dim("Aborted."));
|
|
3736
4364
|
process.exit(1);
|
|
3737
4365
|
}
|
|
3738
4366
|
}
|
|
@@ -3740,7 +4368,7 @@ async function confirmDestructive(message, opts = {}) {
|
|
|
3740
4368
|
// src/commands/team/index.ts
|
|
3741
4369
|
var ROLES = ["OWNER", "ADMIN", "MEMBER"];
|
|
3742
4370
|
var INTERVALS = ["MONTHLY", "YEARLY"];
|
|
3743
|
-
function
|
|
4371
|
+
function getOutputFormat3(cmd) {
|
|
3744
4372
|
const config = loadConfig();
|
|
3745
4373
|
const globalOpts = cmd.optsWithGlobals();
|
|
3746
4374
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -3805,7 +4433,7 @@ Examples:
|
|
|
3805
4433
|
const api = createApiClient();
|
|
3806
4434
|
const teams = await api.admin.listMyTeams();
|
|
3807
4435
|
format(teams, {
|
|
3808
|
-
format:
|
|
4436
|
+
format: getOutputFormat3(cmd),
|
|
3809
4437
|
columns: ["id", "name", "planId", "seatCount", "packCount", "renewal"]
|
|
3810
4438
|
});
|
|
3811
4439
|
} catch (error) {
|
|
@@ -3816,7 +4444,7 @@ Examples:
|
|
|
3816
4444
|
try {
|
|
3817
4445
|
const api = createApiClient();
|
|
3818
4446
|
format(await api.admin.getTeam(teamId), {
|
|
3819
|
-
format:
|
|
4447
|
+
format: getOutputFormat3(cmd)
|
|
3820
4448
|
});
|
|
3821
4449
|
} catch (error) {
|
|
3822
4450
|
handleError(error);
|
|
@@ -3826,14 +4454,14 @@ Examples:
|
|
|
3826
4454
|
try {
|
|
3827
4455
|
const api = createApiClient();
|
|
3828
4456
|
await api.admin.setActiveTeam(teamId);
|
|
3829
|
-
success(`Active team set to "${teamId}".`, { format:
|
|
4457
|
+
success(`Active team set to "${teamId}".`, { format: getOutputFormat3(cmd) });
|
|
3830
4458
|
} catch (error) {
|
|
3831
4459
|
handleError(error);
|
|
3832
4460
|
}
|
|
3833
4461
|
});
|
|
3834
4462
|
team.command("usage").description("Show credit usage for a team, broken down by member").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
3835
4463
|
try {
|
|
3836
|
-
const outputFormat =
|
|
4464
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
3837
4465
|
const api = createApiClient();
|
|
3838
4466
|
const usage = await api.admin.getTeamUsage(teamId);
|
|
3839
4467
|
if (outputFormat === "json") {
|
|
@@ -3862,13 +4490,13 @@ Examples:
|
|
|
3862
4490
|
...options.packs !== void 0 ? { packCount: parseCount(options.packs, "pack count") } : {},
|
|
3863
4491
|
...options.currency !== void 0 ? { currency: options.currency.toUpperCase() } : {}
|
|
3864
4492
|
});
|
|
3865
|
-
const outputFormat =
|
|
4493
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
3866
4494
|
if (outputFormat === "json") {
|
|
3867
4495
|
format(session, { format: outputFormat });
|
|
3868
4496
|
return;
|
|
3869
4497
|
}
|
|
3870
4498
|
console.log("Open this URL to complete checkout:");
|
|
3871
|
-
console.log(
|
|
4499
|
+
console.log(chalk15.cyan(session.url));
|
|
3872
4500
|
} catch (error) {
|
|
3873
4501
|
handleError(error);
|
|
3874
4502
|
}
|
|
@@ -3877,13 +4505,13 @@ Examples:
|
|
|
3877
4505
|
try {
|
|
3878
4506
|
const api = createApiClient();
|
|
3879
4507
|
const session = await api.admin.createTeamPortalSession(teamId, options.returnUrl);
|
|
3880
|
-
const outputFormat =
|
|
4508
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
3881
4509
|
if (outputFormat === "json") {
|
|
3882
4510
|
format(session, { format: outputFormat });
|
|
3883
4511
|
return;
|
|
3884
4512
|
}
|
|
3885
4513
|
console.log("Open this URL to manage billing:");
|
|
3886
|
-
console.log(
|
|
4514
|
+
console.log(chalk15.cyan(session.url));
|
|
3887
4515
|
} catch (error) {
|
|
3888
4516
|
handleError(error);
|
|
3889
4517
|
}
|
|
@@ -3898,7 +4526,7 @@ Examples:
|
|
|
3898
4526
|
const response = await api.admin.cancelTeam(teamId);
|
|
3899
4527
|
success(
|
|
3900
4528
|
`Team "${teamId}" cancelled. Access ends ${response.endsAt ?? "at the end of the period"}.`,
|
|
3901
|
-
{ format:
|
|
4529
|
+
{ format: getOutputFormat3(cmd) }
|
|
3902
4530
|
);
|
|
3903
4531
|
} catch (error) {
|
|
3904
4532
|
handleError(error);
|
|
@@ -3912,7 +4540,7 @@ Examples:
|
|
|
3912
4540
|
});
|
|
3913
4541
|
const api = createApiClient();
|
|
3914
4542
|
await api.admin.leaveTeam(teamId);
|
|
3915
|
-
success(`Left team "${teamId}".`, { format:
|
|
4543
|
+
success(`Left team "${teamId}".`, { format: getOutputFormat3(cmd) });
|
|
3916
4544
|
} catch (error) {
|
|
3917
4545
|
handleError(error);
|
|
3918
4546
|
}
|
|
@@ -3931,7 +4559,7 @@ function registerMemberCommands(team) {
|
|
|
3931
4559
|
const all = await api.admin.listTeamMembers(teamId);
|
|
3932
4560
|
const shown = options.all ? all : all.filter((m) => !m.removedAt);
|
|
3933
4561
|
format(shown, {
|
|
3934
|
-
format:
|
|
4562
|
+
format: getOutputFormat3(cmd),
|
|
3935
4563
|
columns: options.all ? ["userId", "name", "email", "role", "joinedAt", "removedAt"] : ["userId", "name", "email", "role", "joinedAt"]
|
|
3936
4564
|
});
|
|
3937
4565
|
} catch (error) {
|
|
@@ -3944,7 +4572,7 @@ function registerMemberCommands(team) {
|
|
|
3944
4572
|
const api = createApiClient();
|
|
3945
4573
|
await api.admin.inviteTeamMember(teamId, email, role);
|
|
3946
4574
|
success(`Invited ${email} to team "${teamId}" as ${role}.`, {
|
|
3947
|
-
format:
|
|
4575
|
+
format: getOutputFormat3(cmd)
|
|
3948
4576
|
});
|
|
3949
4577
|
} catch (error) {
|
|
3950
4578
|
handleError(error);
|
|
@@ -3959,7 +4587,7 @@ function registerMemberCommands(team) {
|
|
|
3959
4587
|
const api = createApiClient();
|
|
3960
4588
|
await api.admin.removeTeamMember(teamId, userId);
|
|
3961
4589
|
success(`Removed ${userId} from team "${teamId}".`, {
|
|
3962
|
-
format:
|
|
4590
|
+
format: getOutputFormat3(cmd)
|
|
3963
4591
|
});
|
|
3964
4592
|
} catch (error) {
|
|
3965
4593
|
handleError(error);
|
|
@@ -3972,7 +4600,7 @@ function registerInvitationCommands(team) {
|
|
|
3972
4600
|
try {
|
|
3973
4601
|
const api = createApiClient();
|
|
3974
4602
|
format(await api.admin.listTeamInvitations(teamId), {
|
|
3975
|
-
format:
|
|
4603
|
+
format: getOutputFormat3(cmd),
|
|
3976
4604
|
columns: ["invitationId", "email", "role", "invitedBy", "expiresAt"]
|
|
3977
4605
|
});
|
|
3978
4606
|
} catch (error) {
|
|
@@ -3988,7 +4616,7 @@ function registerInvitationCommands(team) {
|
|
|
3988
4616
|
const api = createApiClient();
|
|
3989
4617
|
await api.admin.revokeTeamInvitation(teamId, invitationId);
|
|
3990
4618
|
success(`Revoked invitation "${invitationId}".`, {
|
|
3991
|
-
format:
|
|
4619
|
+
format: getOutputFormat3(cmd)
|
|
3992
4620
|
});
|
|
3993
4621
|
} catch (error) {
|
|
3994
4622
|
handleError(error);
|
|
@@ -3999,7 +4627,7 @@ function registerInvitationCommands(team) {
|
|
|
3999
4627
|
const api = createApiClient();
|
|
4000
4628
|
await api.admin.resendTeamInvitation(teamId, invitationId);
|
|
4001
4629
|
success(`Resent invitation "${invitationId}".`, {
|
|
4002
|
-
format:
|
|
4630
|
+
format: getOutputFormat3(cmd)
|
|
4003
4631
|
});
|
|
4004
4632
|
} catch (error) {
|
|
4005
4633
|
handleError(error);
|
|
@@ -4010,7 +4638,7 @@ function registerInvitationCommands(team) {
|
|
|
4010
4638
|
const api = createApiClient();
|
|
4011
4639
|
const member = await api.admin.acceptTeamInvitation(token);
|
|
4012
4640
|
success(`Joined the team as ${member.role}.`, {
|
|
4013
|
-
format:
|
|
4641
|
+
format: getOutputFormat3(cmd)
|
|
4014
4642
|
});
|
|
4015
4643
|
} catch (error) {
|
|
4016
4644
|
handleError(error);
|
|
@@ -4024,7 +4652,7 @@ function registerSeatCommands(team) {
|
|
|
4024
4652
|
const api = createApiClient();
|
|
4025
4653
|
printInvoicePreview(
|
|
4026
4654
|
await api.admin.previewTeamSeatCount(teamId, parseCount(count, "seat count")),
|
|
4027
|
-
|
|
4655
|
+
getOutputFormat3(cmd)
|
|
4028
4656
|
);
|
|
4029
4657
|
} catch (error) {
|
|
4030
4658
|
handleError(error);
|
|
@@ -4038,9 +4666,9 @@ function registerSeatCommands(team) {
|
|
|
4038
4666
|
{ yes: options.yes, resourceId: teamId }
|
|
4039
4667
|
);
|
|
4040
4668
|
const api = createApiClient();
|
|
4041
|
-
const
|
|
4042
|
-
success(`Seats changed from ${
|
|
4043
|
-
format:
|
|
4669
|
+
const change2 = await api.admin.updateTeamSeatCount(teamId, seatCount);
|
|
4670
|
+
success(`Seats changed from ${change2.oldSeatCount} to ${change2.newSeatCount}.`, {
|
|
4671
|
+
format: getOutputFormat3(cmd)
|
|
4044
4672
|
});
|
|
4045
4673
|
} catch (error) {
|
|
4046
4674
|
handleError(error);
|
|
@@ -4054,7 +4682,7 @@ function registerPackCommands(team) {
|
|
|
4054
4682
|
const api = createApiClient();
|
|
4055
4683
|
printInvoicePreview(
|
|
4056
4684
|
await api.admin.previewTeamPackCount(teamId, parseCount(count, "pack count")),
|
|
4057
|
-
|
|
4685
|
+
getOutputFormat3(cmd)
|
|
4058
4686
|
);
|
|
4059
4687
|
} catch (error) {
|
|
4060
4688
|
handleError(error);
|
|
@@ -4068,9 +4696,9 @@ function registerPackCommands(team) {
|
|
|
4068
4696
|
{ yes: options.yes, resourceId: teamId }
|
|
4069
4697
|
);
|
|
4070
4698
|
const api = createApiClient();
|
|
4071
|
-
const
|
|
4072
|
-
success(`Packs changed from ${
|
|
4073
|
-
format:
|
|
4699
|
+
const change2 = await api.admin.updateTeamPackCount(teamId, packCount);
|
|
4700
|
+
success(`Packs changed from ${change2.oldPackCount} to ${change2.newPackCount}.`, {
|
|
4701
|
+
format: getOutputFormat3(cmd)
|
|
4074
4702
|
});
|
|
4075
4703
|
} catch (error) {
|
|
4076
4704
|
handleError(error);
|
|
@@ -4087,7 +4715,7 @@ function registerOwnershipCommands(team) {
|
|
|
4087
4715
|
);
|
|
4088
4716
|
const api = createApiClient();
|
|
4089
4717
|
format(await api.admin.initiateOwnershipTransfer(teamId, userId), {
|
|
4090
|
-
format:
|
|
4718
|
+
format: getOutputFormat3(cmd)
|
|
4091
4719
|
});
|
|
4092
4720
|
} catch (error) {
|
|
4093
4721
|
handleError(error);
|
|
@@ -4097,7 +4725,7 @@ function registerOwnershipCommands(team) {
|
|
|
4097
4725
|
try {
|
|
4098
4726
|
const api = createApiClient();
|
|
4099
4727
|
const pending = await api.admin.getOwnershipTransfer(teamId);
|
|
4100
|
-
const outputFormat =
|
|
4728
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4101
4729
|
if (!pending) {
|
|
4102
4730
|
if (outputFormat === "json") {
|
|
4103
4731
|
format(null, { format: outputFormat });
|
|
@@ -4115,7 +4743,7 @@ function registerOwnershipCommands(team) {
|
|
|
4115
4743
|
try {
|
|
4116
4744
|
const api = createApiClient();
|
|
4117
4745
|
const response = await api.admin.acceptOwnershipTransfer(teamId);
|
|
4118
|
-
const outputFormat =
|
|
4746
|
+
const outputFormat = getOutputFormat3(cmd);
|
|
4119
4747
|
if (outputFormat === "json") {
|
|
4120
4748
|
format(response, { format: outputFormat });
|
|
4121
4749
|
return;
|
|
@@ -4123,7 +4751,7 @@ function registerOwnershipCommands(team) {
|
|
|
4123
4751
|
success(`Ownership transfer ${response.status}.`);
|
|
4124
4752
|
if (response.checkoutUrl) {
|
|
4125
4753
|
console.log("Open this URL to complete the billing handover:");
|
|
4126
|
-
console.log(
|
|
4754
|
+
console.log(chalk15.cyan(response.checkoutUrl));
|
|
4127
4755
|
}
|
|
4128
4756
|
} catch (error) {
|
|
4129
4757
|
handleError(error);
|
|
@@ -4134,7 +4762,7 @@ function registerOwnershipCommands(team) {
|
|
|
4134
4762
|
const api = createApiClient();
|
|
4135
4763
|
await api.admin.cancelOwnershipTransfer(teamId);
|
|
4136
4764
|
success(`Cancelled the ownership transfer for team "${teamId}".`, {
|
|
4137
|
-
format:
|
|
4765
|
+
format: getOutputFormat3(cmd)
|
|
4138
4766
|
});
|
|
4139
4767
|
} catch (error) {
|
|
4140
4768
|
handleError(error);
|
|
@@ -4143,8 +4771,8 @@ function registerOwnershipCommands(team) {
|
|
|
4143
4771
|
}
|
|
4144
4772
|
|
|
4145
4773
|
// src/commands/entity/index.ts
|
|
4146
|
-
import * as
|
|
4147
|
-
function
|
|
4774
|
+
import * as fs5 from "fs";
|
|
4775
|
+
function getOutputFormat4(cmd) {
|
|
4148
4776
|
const config = loadConfig();
|
|
4149
4777
|
const globalOpts = cmd.optsWithGlobals();
|
|
4150
4778
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4162,11 +4790,12 @@ Examples:
|
|
|
4162
4790
|
$ diafunc entity list <projectId>
|
|
4163
4791
|
$ diafunc entity get <project>/main/<entity>/main
|
|
4164
4792
|
$ diafunc entity history <project>/main/<entity>/main
|
|
4793
|
+
$ diafunc entity tags add <project>/main/<entity>/main health
|
|
4165
4794
|
`);
|
|
4166
4795
|
;
|
|
4167
4796
|
entity.command("list").description("List entities in a project (via linked entities from project root)").argument("<projectRef>", "Project reference (projectId or projectId/branch)").action(async (projectRef, _options, cmd) => {
|
|
4168
4797
|
try {
|
|
4169
|
-
const outputFormat =
|
|
4798
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4170
4799
|
const overrides = getOverrides2(cmd);
|
|
4171
4800
|
const ref = parseEntityReference(projectRef + "/" + projectRef, overrides);
|
|
4172
4801
|
const api = createApiClient();
|
|
@@ -4193,7 +4822,7 @@ Examples:
|
|
|
4193
4822
|
});
|
|
4194
4823
|
entity.command("get").description("Get entity metadata").argument("<ref>", "Entity reference").option("--content", "Include content").action(async (ref, options, cmd) => {
|
|
4195
4824
|
try {
|
|
4196
|
-
const outputFormat =
|
|
4825
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4197
4826
|
const overrides = getOverrides2(cmd);
|
|
4198
4827
|
const resolved = parseEntityReference(ref, overrides);
|
|
4199
4828
|
const api = createApiClient();
|
|
@@ -4236,7 +4865,7 @@ Examples:
|
|
|
4236
4865
|
});
|
|
4237
4866
|
entity.command("history").description("Get entity version history").argument("<ref>", "Entity reference").option("--from <version>", "From version").option("--to <version>", "To version").action(async (ref, options, cmd) => {
|
|
4238
4867
|
try {
|
|
4239
|
-
const outputFormat =
|
|
4868
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4240
4869
|
const overrides = getOverrides2(cmd);
|
|
4241
4870
|
const resolved = parseEntityReference(ref, overrides);
|
|
4242
4871
|
const api = createApiClient();
|
|
@@ -4286,6 +4915,7 @@ Examples:
|
|
|
4286
4915
|
handleError(error);
|
|
4287
4916
|
}
|
|
4288
4917
|
});
|
|
4918
|
+
registerTagCommands(entity, "entity");
|
|
4289
4919
|
const content = entity.command("content").description("Manage entity content");
|
|
4290
4920
|
content.command("get").description("Download entity content").argument("<ref>", "Entity reference").option("--out <file>", "Output file (defaults to stdout)").action(async (ref, options, cmd) => {
|
|
4291
4921
|
try {
|
|
@@ -4295,7 +4925,7 @@ Examples:
|
|
|
4295
4925
|
const response = await api.storage.getEntityContent(resolved);
|
|
4296
4926
|
if (options.out) {
|
|
4297
4927
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
4298
|
-
|
|
4928
|
+
fs5.writeFileSync(options.out, buffer);
|
|
4299
4929
|
success(`Content saved to ${options.out}`);
|
|
4300
4930
|
} else {
|
|
4301
4931
|
const text2 = await response.text();
|
|
@@ -4310,7 +4940,7 @@ Examples:
|
|
|
4310
4940
|
const overrides = getOverrides2(cmd);
|
|
4311
4941
|
const resolved = parseEntityReference(ref, overrides);
|
|
4312
4942
|
const api = createApiClient();
|
|
4313
|
-
const fileBuffer =
|
|
4943
|
+
const fileBuffer = fs5.readFileSync(file);
|
|
4314
4944
|
const base64 = fileBuffer.toString("base64");
|
|
4315
4945
|
await api.storage.saveEntityContentBase64(resolved, base64);
|
|
4316
4946
|
success(`Content uploaded from "${file}" to entity "${resolved.entityId}".`);
|
|
@@ -4352,7 +4982,7 @@ Examples:
|
|
|
4352
4982
|
});
|
|
4353
4983
|
entity.command("import").description("Import a .dfset (or any) bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
|
|
4354
4984
|
try {
|
|
4355
|
-
const outputFormat =
|
|
4985
|
+
const outputFormat = getOutputFormat4(cmd);
|
|
4356
4986
|
const overrides = getOverrides2(cmd);
|
|
4357
4987
|
const ref = parseProjectReference(project, overrides);
|
|
4358
4988
|
const api = createApiClient();
|
|
@@ -4364,7 +4994,7 @@ Examples:
|
|
|
4364
4994
|
}
|
|
4365
4995
|
|
|
4366
4996
|
// src/commands/link/index.ts
|
|
4367
|
-
function
|
|
4997
|
+
function getOutputFormat5(cmd) {
|
|
4368
4998
|
const config = loadConfig();
|
|
4369
4999
|
const globalOpts = cmd.optsWithGlobals();
|
|
4370
5000
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4377,7 +5007,7 @@ function registerLinkCommands(program) {
|
|
|
4377
5007
|
const link = program.command("link").description("Manage links between entities");
|
|
4378
5008
|
link.command("list").description("List links for an entity").argument("<ref>", "Source entity reference").option("--direction <dir>", "Link direction: FORWARD or BACKWARD", "FORWARD").action(async (ref, options, cmd) => {
|
|
4379
5009
|
try {
|
|
4380
|
-
const outputFormat =
|
|
5010
|
+
const outputFormat = getOutputFormat5(cmd);
|
|
4381
5011
|
const overrides = getOverrides3(cmd);
|
|
4382
5012
|
const resolved = parseEntityReference(ref, overrides);
|
|
4383
5013
|
const api = createApiClient();
|
|
@@ -4452,7 +5082,7 @@ function registerLinkCommands(program) {
|
|
|
4452
5082
|
}
|
|
4453
5083
|
|
|
4454
5084
|
// src/commands/event/index.ts
|
|
4455
|
-
function
|
|
5085
|
+
function getOutputFormat6(cmd) {
|
|
4456
5086
|
const config = loadConfig();
|
|
4457
5087
|
const globalOpts = cmd.optsWithGlobals();
|
|
4458
5088
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4465,7 +5095,7 @@ function registerEventCommands(program) {
|
|
|
4465
5095
|
const event = program.command("event").description("Manage events");
|
|
4466
5096
|
event.command("list").description("List events for an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
|
|
4467
5097
|
try {
|
|
4468
|
-
const outputFormat =
|
|
5098
|
+
const outputFormat = getOutputFormat6(cmd);
|
|
4469
5099
|
const overrides = getOverrides4(cmd);
|
|
4470
5100
|
const resolved = parseEntityReference(ref, overrides);
|
|
4471
5101
|
const api = createApiClient();
|
|
@@ -4487,7 +5117,7 @@ function registerEventCommands(program) {
|
|
|
4487
5117
|
});
|
|
4488
5118
|
event.command("get").description("Get a specific event").argument("<ref>", "Entity reference").argument("<eventId>", "Event ID").argument("<occurrenceId>", "Occurrence ID").action(async (ref, eventId, occurrenceId, _options, cmd) => {
|
|
4489
5119
|
try {
|
|
4490
|
-
const outputFormat =
|
|
5120
|
+
const outputFormat = getOutputFormat6(cmd);
|
|
4491
5121
|
const overrides = getOverrides4(cmd);
|
|
4492
5122
|
const resolved = parseEntityReference(ref, overrides);
|
|
4493
5123
|
const api = createApiClient();
|
|
@@ -4499,14 +5129,14 @@ function registerEventCommands(program) {
|
|
|
4499
5129
|
});
|
|
4500
5130
|
event.command("create").description("Create one or more events (body from JSON file or stdin)").argument("[file]", "JSON file containing a BareEvent array; defaults to stdin").action(async (file) => {
|
|
4501
5131
|
try {
|
|
4502
|
-
const
|
|
4503
|
-
const body = file ?
|
|
5132
|
+
const fs18 = await import("fs");
|
|
5133
|
+
const body = file ? fs18.readFileSync(file, "utf-8") : await new Promise((resolve2, reject) => {
|
|
4504
5134
|
let data = "";
|
|
4505
5135
|
process.stdin.setEncoding("utf-8");
|
|
4506
5136
|
process.stdin.on("data", (chunk) => {
|
|
4507
5137
|
data += chunk;
|
|
4508
5138
|
});
|
|
4509
|
-
process.stdin.on("end", () =>
|
|
5139
|
+
process.stdin.on("end", () => resolve2(data));
|
|
4510
5140
|
process.stdin.on("error", reject);
|
|
4511
5141
|
});
|
|
4512
5142
|
const events = JSON.parse(body);
|
|
@@ -4548,7 +5178,7 @@ function registerEventCommands(program) {
|
|
|
4548
5178
|
}
|
|
4549
5179
|
|
|
4550
5180
|
// src/commands/branch/index.ts
|
|
4551
|
-
function
|
|
5181
|
+
function getOutputFormat7(cmd) {
|
|
4552
5182
|
const config = loadConfig();
|
|
4553
5183
|
const globalOpts = cmd.optsWithGlobals();
|
|
4554
5184
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4567,7 +5197,7 @@ Examples:
|
|
|
4567
5197
|
;
|
|
4568
5198
|
branch.command("list").description("List branches for a project").argument("[projectId]", "Project ID (uses default if omitted)").action(async (projectId, _options, cmd) => {
|
|
4569
5199
|
try {
|
|
4570
|
-
const outputFormat =
|
|
5200
|
+
const outputFormat = getOutputFormat7(cmd);
|
|
4571
5201
|
const overrides = getOverrides5(cmd);
|
|
4572
5202
|
const config = loadConfig();
|
|
4573
5203
|
const pid = projectId ?? overrides.project ?? config.defaults.project;
|
|
@@ -4649,9 +5279,9 @@ Examples:
|
|
|
4649
5279
|
}
|
|
4650
5280
|
|
|
4651
5281
|
// src/commands/table/index.ts
|
|
4652
|
-
import
|
|
4653
|
-
import * as
|
|
4654
|
-
import * as
|
|
5282
|
+
import chalk16 from "chalk";
|
|
5283
|
+
import * as fs6 from "fs";
|
|
5284
|
+
import * as path4 from "path";
|
|
4655
5285
|
|
|
4656
5286
|
// src/util/table-window.ts
|
|
4657
5287
|
var WINDOW_MAX_ROWS = 100;
|
|
@@ -4803,8 +5433,8 @@ function buildTableEntity(args) {
|
|
|
4803
5433
|
}
|
|
4804
5434
|
|
|
4805
5435
|
// src/commands/table/index.ts
|
|
4806
|
-
import { randomUUID } from "crypto";
|
|
4807
|
-
function
|
|
5436
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
5437
|
+
function getOutputFormat8(cmd) {
|
|
4808
5438
|
const config = loadConfig();
|
|
4809
5439
|
const globalOpts = cmd.optsWithGlobals();
|
|
4810
5440
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -4867,7 +5497,7 @@ Examples:
|
|
|
4867
5497
|
;
|
|
4868
5498
|
table.command("view").description("View table data").argument("<ref>", "Table entity reference").option("--rows <range>", "Rows to show, half-open: 0:10 is the first ten, 6490: runs to the end (default: up to 100)").option("--cols <range>", "Columns to show, half-open: 0:5 is the first five (default: up to 50)").action(async (ref, options, cmd) => {
|
|
4869
5499
|
try {
|
|
4870
|
-
const outputFormat =
|
|
5500
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
4871
5501
|
const overrides = getOverrides6(cmd);
|
|
4872
5502
|
const resolved = parseEntityReference(ref, overrides);
|
|
4873
5503
|
const api = createApiClient();
|
|
@@ -4876,7 +5506,7 @@ Examples:
|
|
|
4876
5506
|
if (outputFormat === "json") {
|
|
4877
5507
|
format({ rows: [], columns: [], cells: [], totalRows, totalColumns, window: null }, { format: outputFormat });
|
|
4878
5508
|
} else {
|
|
4879
|
-
console.log(
|
|
5509
|
+
console.log(chalk16.dim("Empty table."));
|
|
4880
5510
|
}
|
|
4881
5511
|
return;
|
|
4882
5512
|
}
|
|
@@ -4916,7 +5546,7 @@ Examples:
|
|
|
4916
5546
|
}
|
|
4917
5547
|
} else {
|
|
4918
5548
|
format(tableData, { format: outputFormat, columns: colNames.map((name) => ({ key: name, header: name })) });
|
|
4919
|
-
console.log(
|
|
5549
|
+
console.log(chalk16.dim(describeWindow(window, totalRows, totalColumns)));
|
|
4920
5550
|
}
|
|
4921
5551
|
} catch (error) {
|
|
4922
5552
|
handleError(error);
|
|
@@ -4932,9 +5562,9 @@ Examples:
|
|
|
4932
5562
|
$ diafunc table create --notebook <notebookId>
|
|
4933
5563
|
`).action(async (ref, options, cmd) => {
|
|
4934
5564
|
try {
|
|
4935
|
-
const outputFormat =
|
|
5565
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
4936
5566
|
const overrides = getOverrides6(cmd);
|
|
4937
|
-
const resolved = parseEntityReference(ref ??
|
|
5567
|
+
const resolved = parseEntityReference(ref ?? randomUUID2(), overrides);
|
|
4938
5568
|
if (resolved.entityId.includes(".partition.")) {
|
|
4939
5569
|
throw new CliError(`"${resolved.entityId}" contains ".partition.", which names a table's storage blocks.`, {
|
|
4940
5570
|
exitCode: EXIT_USAGE,
|
|
@@ -4969,17 +5599,17 @@ Examples:
|
|
|
4969
5599
|
try {
|
|
4970
5600
|
const overrides = getOverrides6(cmd);
|
|
4971
5601
|
const resolved = parseEntityReference(ref, overrides);
|
|
4972
|
-
if (!
|
|
5602
|
+
if (!fs6.existsSync(file)) {
|
|
4973
5603
|
failure(`File not found: ${file}`);
|
|
4974
5604
|
process.exit(EXIT_USAGE);
|
|
4975
5605
|
}
|
|
4976
5606
|
const api = createApiClient();
|
|
4977
|
-
const fileBuffer =
|
|
5607
|
+
const fileBuffer = fs6.readFileSync(file);
|
|
4978
5608
|
const blob = new Blob([fileBuffer]);
|
|
4979
5609
|
const formData = new FormData();
|
|
4980
|
-
formData.append("content", blob,
|
|
5610
|
+
formData.append("content", blob, path4.basename(file));
|
|
4981
5611
|
const importId = await withStatus(
|
|
4982
|
-
`Uploading ${
|
|
5612
|
+
`Uploading ${path4.basename(file)}`,
|
|
4983
5613
|
() => api.storage.importTable(resolved, formData, options.selection)
|
|
4984
5614
|
).catch((error) => {
|
|
4985
5615
|
if (error instanceof ApiError && error.status === 404) {
|
|
@@ -4996,7 +5626,7 @@ Examples:
|
|
|
4996
5626
|
const startedAt = Date.now();
|
|
4997
5627
|
try {
|
|
4998
5628
|
for (let i = 0; i < maxAttempts; i++) {
|
|
4999
|
-
await new Promise((
|
|
5629
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
5000
5630
|
const imp = await api.storage.getImport(resolved, importId);
|
|
5001
5631
|
if (imp.finished !== null) {
|
|
5002
5632
|
status.stop();
|
|
@@ -5021,7 +5651,7 @@ Examples:
|
|
|
5021
5651
|
});
|
|
5022
5652
|
table.command("import-formats").description("List supported import formats").action(async (_options, cmd) => {
|
|
5023
5653
|
try {
|
|
5024
|
-
const outputFormat =
|
|
5654
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
5025
5655
|
const api = createApiClient();
|
|
5026
5656
|
const response = await api.storage.getSupportedImportFormats();
|
|
5027
5657
|
if (outputFormat === "json") {
|
|
@@ -5099,7 +5729,7 @@ Examples:
|
|
|
5099
5729
|
const response = await api.storage.streamExport(resolved, format2.id, exportOptions);
|
|
5100
5730
|
const outFile = options.out ?? deriveOutFile(resolved.entityId, format2.extension, options.archive, options.compression);
|
|
5101
5731
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
5102
|
-
|
|
5732
|
+
fs6.writeFileSync(outFile, buffer);
|
|
5103
5733
|
success(`Table streamed to ${outFile}`);
|
|
5104
5734
|
} else {
|
|
5105
5735
|
const exportId = await api.storage.exportTable(resolved, format2.id, exportOptions);
|
|
@@ -5112,7 +5742,7 @@ Examples:
|
|
|
5112
5742
|
});
|
|
5113
5743
|
table.command("export-formats").description("List supported export formats").action(async (_options, cmd) => {
|
|
5114
5744
|
try {
|
|
5115
|
-
const outputFormat =
|
|
5745
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
5116
5746
|
const api = createApiClient();
|
|
5117
5747
|
const response = await api.storage.getSupportedExportFormats();
|
|
5118
5748
|
if (outputFormat === "json") {
|
|
@@ -5128,8 +5758,8 @@ Examples:
|
|
|
5128
5758
|
knownLimitations: f.knownLimitations.join(" / ")
|
|
5129
5759
|
}));
|
|
5130
5760
|
format(rows, { format: outputFormat, columns: ["id", "displayName", "category", "extension", "mimeType", "knownLimitations"] });
|
|
5131
|
-
console.log(
|
|
5132
|
-
console.log(
|
|
5761
|
+
console.log(chalk16.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
|
|
5762
|
+
console.log(chalk16.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
|
|
5133
5763
|
} catch (error) {
|
|
5134
5764
|
handleError(error);
|
|
5135
5765
|
}
|
|
@@ -5137,7 +5767,7 @@ Examples:
|
|
|
5137
5767
|
const exportsCmd = table.command("exports").description("Track and download async table exports");
|
|
5138
5768
|
exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
|
|
5139
5769
|
try {
|
|
5140
|
-
const outputFormat =
|
|
5770
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
5141
5771
|
const overrides = getOverrides6(cmd);
|
|
5142
5772
|
const resolved = parseEntityReference(ref, overrides);
|
|
5143
5773
|
const api = createApiClient();
|
|
@@ -5165,7 +5795,7 @@ Examples:
|
|
|
5165
5795
|
});
|
|
5166
5796
|
exportsCmd.command("get").description("Get async export status; download the file once the export has succeeded").argument("<exportId>", "Export ID returned by `table export --async`").requiredOption("--ref <ref>", "Table entity reference").option("--out <file>", "Output file path (defaults to the original export filename)").action(async (exportId, options, cmd) => {
|
|
5167
5797
|
try {
|
|
5168
|
-
const outputFormat =
|
|
5798
|
+
const outputFormat = getOutputFormat8(cmd);
|
|
5169
5799
|
const overrides = getOverrides6(cmd);
|
|
5170
5800
|
const resolved = parseEntityReference(options.ref, overrides);
|
|
5171
5801
|
const api = createApiClient();
|
|
@@ -5181,7 +5811,7 @@ Examples:
|
|
|
5181
5811
|
}
|
|
5182
5812
|
if (exp.finished === null) {
|
|
5183
5813
|
const pct = Math.round((exp.progress ?? 0) * 100);
|
|
5184
|
-
console.log(
|
|
5814
|
+
console.log(chalk16.dim(`Export in progress: ${pct}%. Check again later.`));
|
|
5185
5815
|
return;
|
|
5186
5816
|
}
|
|
5187
5817
|
if (!exp.succeeded) {
|
|
@@ -5192,7 +5822,7 @@ Examples:
|
|
|
5192
5822
|
console.log(`Downloading ${exp.filename} ...`);
|
|
5193
5823
|
const response = await api.storage.downloadExport(resolved, exportId, exp.filename);
|
|
5194
5824
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
5195
|
-
|
|
5825
|
+
fs6.writeFileSync(outFile, buffer);
|
|
5196
5826
|
success(`Export saved to ${outFile}`);
|
|
5197
5827
|
} catch (error) {
|
|
5198
5828
|
handleError(error);
|
|
@@ -5331,10 +5961,10 @@ Examples:
|
|
|
5331
5961
|
}
|
|
5332
5962
|
|
|
5333
5963
|
// src/commands/notebook/index.ts
|
|
5334
|
-
import
|
|
5335
|
-
import * as
|
|
5336
|
-
import * as
|
|
5337
|
-
function
|
|
5964
|
+
import chalk17 from "chalk";
|
|
5965
|
+
import * as fs7 from "fs";
|
|
5966
|
+
import * as path5 from "path";
|
|
5967
|
+
function getOutputFormat9(cmd) {
|
|
5338
5968
|
const config = loadConfig();
|
|
5339
5969
|
const globalOpts = cmd.optsWithGlobals();
|
|
5340
5970
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5366,7 +5996,7 @@ Examples:
|
|
|
5366
5996
|
const response = await api.storage.streamBundle(ref.projectId, ref.projectBranch, request);
|
|
5367
5997
|
const outFile = options.out ?? "notebooks.dfnb";
|
|
5368
5998
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
5369
|
-
|
|
5999
|
+
fs7.writeFileSync(outFile, buffer);
|
|
5370
6000
|
success(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`);
|
|
5371
6001
|
} catch (error) {
|
|
5372
6002
|
handleError(error);
|
|
@@ -5374,23 +6004,23 @@ Examples:
|
|
|
5374
6004
|
});
|
|
5375
6005
|
notebook.command("import").description("Import a .dfnb bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the .dfnb bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
|
|
5376
6006
|
try {
|
|
5377
|
-
const outputFormat =
|
|
6007
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
5378
6008
|
const overrides = getOverrides7(cmd);
|
|
5379
6009
|
const ref = parseProjectReference(project, overrides);
|
|
5380
6010
|
const api = createApiClient();
|
|
5381
|
-
const fileBuffer =
|
|
6011
|
+
const fileBuffer = fs7.readFileSync(file);
|
|
5382
6012
|
const blob = new Blob([fileBuffer]);
|
|
5383
6013
|
const formData = new FormData();
|
|
5384
|
-
formData.append("content", blob,
|
|
6014
|
+
formData.append("content", blob, path5.basename(file));
|
|
5385
6015
|
if (options.preview) {
|
|
5386
6016
|
const preview = await api.storage.previewBundleImport(ref.projectId, ref.projectBranch, formData);
|
|
5387
6017
|
if (outputFormat === "json") {
|
|
5388
6018
|
format(preview, { format: outputFormat });
|
|
5389
6019
|
return;
|
|
5390
6020
|
}
|
|
5391
|
-
console.log(
|
|
6021
|
+
console.log(chalk17.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
|
|
5392
6022
|
if (preview.sourceProjectId) {
|
|
5393
|
-
console.log(
|
|
6023
|
+
console.log(chalk17.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
|
|
5394
6024
|
}
|
|
5395
6025
|
const counts = /* @__PURE__ */ new Map();
|
|
5396
6026
|
for (const e of preview.entities ?? []) {
|
|
@@ -5400,9 +6030,9 @@ Examples:
|
|
|
5400
6030
|
console.log(` ${type}: ${count}`);
|
|
5401
6031
|
}
|
|
5402
6032
|
if (preview.lossinessNotes && preview.lossinessNotes.length > 0) {
|
|
5403
|
-
console.log(
|
|
6033
|
+
console.log(chalk17.yellow("Lossiness:"));
|
|
5404
6034
|
for (const note of preview.lossinessNotes) {
|
|
5405
|
-
console.log(
|
|
6035
|
+
console.log(chalk17.yellow(` - ${note}`));
|
|
5406
6036
|
}
|
|
5407
6037
|
}
|
|
5408
6038
|
return;
|
|
@@ -5420,7 +6050,7 @@ Examples:
|
|
|
5420
6050
|
});
|
|
5421
6051
|
notebook.command("bundles").description("List notebook-bundle export jobs for a project").argument("<project>", "Project reference (projectId or projectId/branch)").action(async (project, _options, cmd) => {
|
|
5422
6052
|
try {
|
|
5423
|
-
const outputFormat =
|
|
6053
|
+
const outputFormat = getOutputFormat9(cmd);
|
|
5424
6054
|
const overrides = getOverrides7(cmd);
|
|
5425
6055
|
const ref = parseProjectReference(project, overrides);
|
|
5426
6056
|
const api = createApiClient();
|
|
@@ -5449,22 +6079,22 @@ Examples:
|
|
|
5449
6079
|
}
|
|
5450
6080
|
|
|
5451
6081
|
// src/commands/function/index.ts
|
|
5452
|
-
import
|
|
5453
|
-
import * as
|
|
5454
|
-
import * as
|
|
5455
|
-
import * as
|
|
6082
|
+
import chalk18 from "chalk";
|
|
6083
|
+
import * as fs8 from "fs";
|
|
6084
|
+
import * as os3 from "os";
|
|
6085
|
+
import * as path6 from "path";
|
|
5456
6086
|
import { spawn } from "child_process";
|
|
5457
|
-
import { randomUUID as
|
|
6087
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
5458
6088
|
|
|
5459
6089
|
// src/util/time-uuid.ts
|
|
5460
|
-
import { randomBytes } from "crypto";
|
|
6090
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
5461
6091
|
var GREGORIAN_OFFSET = 122192928000000000n;
|
|
5462
6092
|
var INTERVALS_PER_MILLI = 10000n;
|
|
5463
6093
|
function createTimeUuidGenerator() {
|
|
5464
|
-
const node =
|
|
6094
|
+
const node = randomBytes2(6);
|
|
5465
6095
|
node[0] |= 1;
|
|
5466
6096
|
const nodeHex = node.toString("hex");
|
|
5467
|
-
let clockSequence =
|
|
6097
|
+
let clockSequence = randomBytes2(2).readUInt16BE(0) & 16383;
|
|
5468
6098
|
let lastTimestamp = 0n;
|
|
5469
6099
|
let intervalsWithinMilli = 0n;
|
|
5470
6100
|
return function generate(now = Date.now()) {
|
|
@@ -5552,7 +6182,7 @@ function buildFunctionEntity(args) {
|
|
|
5552
6182
|
}
|
|
5553
6183
|
|
|
5554
6184
|
// src/commands/function/index.ts
|
|
5555
|
-
function
|
|
6185
|
+
function getOutputFormat10(cmd) {
|
|
5556
6186
|
const config = loadConfig();
|
|
5557
6187
|
const globalOpts = cmd.optsWithGlobals();
|
|
5558
6188
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5582,7 +6212,7 @@ Examples:
|
|
|
5582
6212
|
;
|
|
5583
6213
|
fn.command("call").description("Execute a function").argument("<ref>", "Function entity reference").option("--async", "Execute asynchronously").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
|
|
5584
6214
|
try {
|
|
5585
|
-
const outputFormat =
|
|
6215
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
5586
6216
|
const overrides = getOverrides8(cmd);
|
|
5587
6217
|
const resolved = parseEntityReference(ref, overrides);
|
|
5588
6218
|
const api = createApiClient();
|
|
@@ -5640,7 +6270,7 @@ Examples:
|
|
|
5640
6270
|
const duration = result.completed - result.started;
|
|
5641
6271
|
console.log(` Duration: ${duration}ms`);
|
|
5642
6272
|
} else {
|
|
5643
|
-
console.log(
|
|
6273
|
+
console.log(chalk18.red("Function failed."));
|
|
5644
6274
|
console.log(` Error: ${result.error}`);
|
|
5645
6275
|
if (result.lineNumber > 0) {
|
|
5646
6276
|
console.log(` Line: ${result.lineNumber}, Column: ${result.columnNumber}`);
|
|
@@ -5648,7 +6278,7 @@ Examples:
|
|
|
5648
6278
|
}
|
|
5649
6279
|
if (result.outputs?.length) {
|
|
5650
6280
|
console.log();
|
|
5651
|
-
console.log(
|
|
6281
|
+
console.log(chalk18.bold("Outputs:"));
|
|
5652
6282
|
for (const out of result.outputs) {
|
|
5653
6283
|
console.log(` [${out.type}] ${out.output}`);
|
|
5654
6284
|
}
|
|
@@ -5663,7 +6293,7 @@ Examples:
|
|
|
5663
6293
|
});
|
|
5664
6294
|
fn.command("evaluations").description("List evaluations for a function").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
|
|
5665
6295
|
try {
|
|
5666
|
-
const outputFormat =
|
|
6296
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
5667
6297
|
const overrides = getOverrides8(cmd);
|
|
5668
6298
|
const resolved = parseEntityReference(ref, overrides);
|
|
5669
6299
|
const api = createApiClient();
|
|
@@ -5704,7 +6334,7 @@ Examples:
|
|
|
5704
6334
|
});
|
|
5705
6335
|
fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
|
|
5706
6336
|
try {
|
|
5707
|
-
const outputFormat =
|
|
6337
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
5708
6338
|
const api = createApiClient();
|
|
5709
6339
|
const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
|
|
5710
6340
|
if (outputFormat === "human") {
|
|
@@ -5713,7 +6343,7 @@ Examples:
|
|
|
5713
6343
|
}
|
|
5714
6344
|
for (const out of outputs) {
|
|
5715
6345
|
const time = new Date(out.timestamp).toISOString();
|
|
5716
|
-
console.log(`${
|
|
6346
|
+
console.log(`${chalk18.dim(time)} [${out.type}] ${out.output}`);
|
|
5717
6347
|
}
|
|
5718
6348
|
} else {
|
|
5719
6349
|
format(outputs, { format: outputFormat });
|
|
@@ -5724,7 +6354,7 @@ Examples:
|
|
|
5724
6354
|
});
|
|
5725
6355
|
fn.command("logs").description("Get logs for a function evaluation").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
|
|
5726
6356
|
try {
|
|
5727
|
-
const outputFormat =
|
|
6357
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
5728
6358
|
const overrides = getOverrides8(cmd);
|
|
5729
6359
|
const resolved = parseEntityReference(ref, overrides);
|
|
5730
6360
|
const api = createApiClient();
|
|
@@ -5770,7 +6400,7 @@ Examples:
|
|
|
5770
6400
|
});
|
|
5771
6401
|
fn.command("languages").description("List the languages a function can be written in").action(async (_options, cmd) => {
|
|
5772
6402
|
try {
|
|
5773
|
-
const outputFormat =
|
|
6403
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
5774
6404
|
format(
|
|
5775
6405
|
FUNCTION_LANGUAGES.map((language) => ({
|
|
5776
6406
|
language,
|
|
@@ -5784,7 +6414,7 @@ Examples:
|
|
|
5784
6414
|
});
|
|
5785
6415
|
fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
5786
6416
|
try {
|
|
5787
|
-
const outputFormat =
|
|
6417
|
+
const outputFormat = getOutputFormat10(cmd);
|
|
5788
6418
|
const overrides = getOverrides8(cmd);
|
|
5789
6419
|
const resolved = parseEntityReference(ref, overrides);
|
|
5790
6420
|
const api = createApiClient();
|
|
@@ -5804,7 +6434,7 @@ Examples:
|
|
|
5804
6434
|
const overrides = getOverrides8(cmd);
|
|
5805
6435
|
const resolved = parseEntityReference(ref, overrides);
|
|
5806
6436
|
const api = createApiClient();
|
|
5807
|
-
const sourceCode = options.source ?
|
|
6437
|
+
const sourceCode = options.source ? fs8.readFileSync(options.source, "utf-8") : "";
|
|
5808
6438
|
const entity = buildFunctionEntity({
|
|
5809
6439
|
projectId: resolved.projectId,
|
|
5810
6440
|
projectBranch: resolved.projectBranch,
|
|
@@ -5830,7 +6460,7 @@ Examples:
|
|
|
5830
6460
|
const entity = await api.storage.getEntity(resolved, true);
|
|
5831
6461
|
const sourceCode = decodeFunctionSource(entity);
|
|
5832
6462
|
if (options.out) {
|
|
5833
|
-
|
|
6463
|
+
fs8.writeFileSync(options.out, sourceCode);
|
|
5834
6464
|
success(`Source written to ${options.out}`);
|
|
5835
6465
|
} else {
|
|
5836
6466
|
process.stdout.write(sourceCode);
|
|
@@ -5845,13 +6475,13 @@ Examples:
|
|
|
5845
6475
|
const overrides = getOverrides8(cmd);
|
|
5846
6476
|
const resolved = parseEntityReference(ref, overrides);
|
|
5847
6477
|
const api = createApiClient();
|
|
5848
|
-
const sourceCode = file ?
|
|
6478
|
+
const sourceCode = file ? fs8.readFileSync(file, "utf-8") : await new Promise((resolve2, reject) => {
|
|
5849
6479
|
let data = "";
|
|
5850
6480
|
process.stdin.setEncoding("utf-8");
|
|
5851
6481
|
process.stdin.on("data", (chunk) => {
|
|
5852
6482
|
data += chunk;
|
|
5853
6483
|
});
|
|
5854
|
-
process.stdin.on("end", () =>
|
|
6484
|
+
process.stdin.on("end", () => resolve2(data));
|
|
5855
6485
|
process.stdin.on("error", reject);
|
|
5856
6486
|
});
|
|
5857
6487
|
await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(sourceCode));
|
|
@@ -5869,16 +6499,16 @@ Examples:
|
|
|
5869
6499
|
const currentSource = decodeFunctionSource(entity);
|
|
5870
6500
|
const language = decodeTextAttribute(entity.attributes?.["language"]) ?? "txt";
|
|
5871
6501
|
const ext = extensionFor(language);
|
|
5872
|
-
const tmpFile =
|
|
5873
|
-
|
|
6502
|
+
const tmpFile = path6.join(os3.tmpdir(), `diafunc-${resolved.entityId}-${randomUUID3()}.${ext}`);
|
|
6503
|
+
fs8.writeFileSync(tmpFile, currentSource);
|
|
5874
6504
|
const editor = process.env.VISUAL ?? process.env.EDITOR ?? "vi";
|
|
5875
|
-
await new Promise((
|
|
6505
|
+
await new Promise((resolve2, reject) => {
|
|
5876
6506
|
const child = spawn(editor, [tmpFile], { stdio: "inherit" });
|
|
5877
|
-
child.on("exit", (code) => code === 0 ?
|
|
6507
|
+
child.on("exit", (code) => code === 0 ? resolve2() : reject(new Error(`Editor exited with code ${code}`)));
|
|
5878
6508
|
child.on("error", reject);
|
|
5879
6509
|
});
|
|
5880
|
-
const newSource =
|
|
5881
|
-
|
|
6510
|
+
const newSource = fs8.readFileSync(tmpFile, "utf-8");
|
|
6511
|
+
fs8.unlinkSync(tmpFile);
|
|
5882
6512
|
if (newSource === currentSource) {
|
|
5883
6513
|
empty("changes");
|
|
5884
6514
|
return;
|
|
@@ -5901,7 +6531,7 @@ function extensionFor(language) {
|
|
|
5901
6531
|
}
|
|
5902
6532
|
|
|
5903
6533
|
// src/commands/trigger/index.ts
|
|
5904
|
-
function
|
|
6534
|
+
function getOutputFormat11(cmd) {
|
|
5905
6535
|
const config = loadConfig();
|
|
5906
6536
|
const globalOpts = cmd.optsWithGlobals();
|
|
5907
6537
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -5920,7 +6550,7 @@ Examples:
|
|
|
5920
6550
|
;
|
|
5921
6551
|
trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
5922
6552
|
try {
|
|
5923
|
-
const outputFormat =
|
|
6553
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
5924
6554
|
const overrides = getOverrides9(cmd);
|
|
5925
6555
|
const resolved = parseEntityReference(ref, overrides);
|
|
5926
6556
|
const api = createApiClient();
|
|
@@ -5948,7 +6578,7 @@ Examples:
|
|
|
5948
6578
|
});
|
|
5949
6579
|
trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
|
|
5950
6580
|
try {
|
|
5951
|
-
const outputFormat =
|
|
6581
|
+
const outputFormat = getOutputFormat11(cmd);
|
|
5952
6582
|
const overrides = getOverrides9(cmd);
|
|
5953
6583
|
const resolved = parseEntityReference(ref, overrides);
|
|
5954
6584
|
const api = createApiClient();
|
|
@@ -6032,7 +6662,7 @@ Examples:
|
|
|
6032
6662
|
}
|
|
6033
6663
|
|
|
6034
6664
|
// src/commands/schedule/index.ts
|
|
6035
|
-
function
|
|
6665
|
+
function getOutputFormat12(cmd) {
|
|
6036
6666
|
const config = loadConfig();
|
|
6037
6667
|
const globalOpts = cmd.optsWithGlobals();
|
|
6038
6668
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6045,7 +6675,7 @@ function registerScheduleCommands(program) {
|
|
|
6045
6675
|
const schedule = program.command("schedule").description("Schedule function execution");
|
|
6046
6676
|
schedule.command("call").description("Schedule a function call").argument("<ref>", "Function entity reference").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
|
|
6047
6677
|
try {
|
|
6048
|
-
const outputFormat =
|
|
6678
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
6049
6679
|
const overrides = getOverrides10(cmd);
|
|
6050
6680
|
const resolved = parseEntityReference(ref, overrides);
|
|
6051
6681
|
const api = createApiClient();
|
|
@@ -6114,7 +6744,7 @@ function registerScheduleCommands(program) {
|
|
|
6114
6744
|
});
|
|
6115
6745
|
schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
|
|
6116
6746
|
try {
|
|
6117
|
-
const outputFormat =
|
|
6747
|
+
const outputFormat = getOutputFormat12(cmd);
|
|
6118
6748
|
const overrides = getOverrides10(cmd);
|
|
6119
6749
|
const resolved = parseEntityReference(ref, overrides);
|
|
6120
6750
|
const api = createApiClient();
|
|
@@ -6144,12 +6774,12 @@ function registerScheduleCommands(program) {
|
|
|
6144
6774
|
}
|
|
6145
6775
|
|
|
6146
6776
|
// src/commands/chat/index.ts
|
|
6147
|
-
import
|
|
6148
|
-
import * as
|
|
6149
|
-
import * as
|
|
6777
|
+
import chalk20 from "chalk";
|
|
6778
|
+
import * as fs9 from "fs";
|
|
6779
|
+
import * as path7 from "path";
|
|
6150
6780
|
|
|
6151
6781
|
// src/output/markdown.ts
|
|
6152
|
-
import
|
|
6782
|
+
import chalk19 from "chalk";
|
|
6153
6783
|
var CODE_OPEN = "\0c";
|
|
6154
6784
|
var CODE_CLOSE = "\0";
|
|
6155
6785
|
var MarkdownRenderer = class {
|
|
@@ -6185,25 +6815,25 @@ var MarkdownRenderer = class {
|
|
|
6185
6815
|
if (fence) {
|
|
6186
6816
|
const opening = !this.inFence;
|
|
6187
6817
|
this.inFence = !this.inFence;
|
|
6188
|
-
return opening && fence[1] ? [
|
|
6818
|
+
return opening && fence[1] ? [chalk19.dim(` ${fence[1]}`)] : [];
|
|
6189
6819
|
}
|
|
6190
6820
|
if (this.inFence) {
|
|
6191
|
-
return [
|
|
6821
|
+
return [chalk19.cyan(` ${line}`)];
|
|
6192
6822
|
}
|
|
6193
6823
|
const heading2 = line.match(/^(#{1,6})\s+(.*)$/);
|
|
6194
6824
|
if (heading2) {
|
|
6195
6825
|
const text2 = inline(heading2[2]);
|
|
6196
|
-
return ["", heading2[1].length <= 2 ?
|
|
6826
|
+
return ["", heading2[1].length <= 2 ? chalk19.bold.underline(text2) : chalk19.bold(text2)];
|
|
6197
6827
|
}
|
|
6198
6828
|
if (/^\s*([-*_])\1{2,}\s*$/.test(line)) {
|
|
6199
|
-
return [
|
|
6829
|
+
return [chalk19.dim("\u2500".repeat(Math.min(this.width, 60)))];
|
|
6200
6830
|
}
|
|
6201
6831
|
const quote2 = line.match(/^\s*>\s?(.*)$/);
|
|
6202
|
-
if (quote2) return [
|
|
6832
|
+
if (quote2) return [chalk19.dim(` \u2502 ${inline(quote2[1])}`)];
|
|
6203
6833
|
const bullet = line.match(/^(\s*)[-*+]\s+(.*)$/);
|
|
6204
6834
|
if (bullet) {
|
|
6205
6835
|
return wrapWithIndent(
|
|
6206
|
-
`${bullet[1]}${
|
|
6836
|
+
`${bullet[1]}${chalk19.cyan("\u2022")} ${inline(bullet[2])}`,
|
|
6207
6837
|
bullet[1].length + 2,
|
|
6208
6838
|
this.width
|
|
6209
6839
|
);
|
|
@@ -6211,7 +6841,7 @@ var MarkdownRenderer = class {
|
|
|
6211
6841
|
const numbered = line.match(/^(\s*)(\d+)\.\s+(.*)$/);
|
|
6212
6842
|
if (numbered) {
|
|
6213
6843
|
return wrapWithIndent(
|
|
6214
|
-
`${numbered[1]}${
|
|
6844
|
+
`${numbered[1]}${chalk19.cyan(`${numbered[2]}.`)} ${inline(numbered[3])}`,
|
|
6215
6845
|
numbered[1].length + numbered[2].length + 2,
|
|
6216
6846
|
this.width
|
|
6217
6847
|
);
|
|
@@ -6234,15 +6864,15 @@ function inline(text2) {
|
|
|
6234
6864
|
codeSpans.push(code);
|
|
6235
6865
|
return `${CODE_OPEN}${codeSpans.length - 1}${CODE_CLOSE}`;
|
|
6236
6866
|
});
|
|
6237
|
-
working = working.replace(/\*\*([^*]+)\*\*/g, (_m, t) =>
|
|
6867
|
+
working = working.replace(/\*\*([^*]+)\*\*/g, (_m, t) => chalk19.bold(t)).replace(/__([^_]+)__/g, (_m, t) => chalk19.bold(t)).replace(/(^|[^*])\*([^*\n]+)\*/g, (_m, lead, t) => lead + chalk19.italic(t)).replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, label, url) => `${chalk19.underline(label)} ${chalk19.dim(`(${url})`)}`);
|
|
6238
6868
|
return working.replace(
|
|
6239
6869
|
new RegExp(`${CODE_OPEN}(\\d+)${CODE_CLOSE}`, "g"),
|
|
6240
|
-
(_m, i) =>
|
|
6870
|
+
(_m, i) => chalk19.yellow(codeSpans[Number(i)])
|
|
6241
6871
|
);
|
|
6242
6872
|
}
|
|
6243
6873
|
|
|
6244
6874
|
// src/commands/chat/index.ts
|
|
6245
|
-
function
|
|
6875
|
+
function getOutputFormat13(cmd) {
|
|
6246
6876
|
const config = loadConfig();
|
|
6247
6877
|
const globalOpts = cmd.optsWithGlobals();
|
|
6248
6878
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6250,7 +6880,7 @@ function getOutputFormat12(cmd) {
|
|
|
6250
6880
|
async function streamOneTurn(message, sessionId, projectId, branch, signal) {
|
|
6251
6881
|
const api = createApiClient();
|
|
6252
6882
|
const status = new Status();
|
|
6253
|
-
status.set([` ${
|
|
6883
|
+
status.set([` ${chalk20.magenta(SPINNER)} ${chalk20.dim("thinking")}`]);
|
|
6254
6884
|
status.start();
|
|
6255
6885
|
let response;
|
|
6256
6886
|
try {
|
|
@@ -6327,19 +6957,19 @@ var HELP = [
|
|
|
6327
6957
|
];
|
|
6328
6958
|
async function runChatRepl(options) {
|
|
6329
6959
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
6330
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
6960
|
+
const { getUpdateNotice } = await import("./update-check-4345HWGE.js");
|
|
6331
6961
|
let sessionId = options.session;
|
|
6332
6962
|
let lastReportedSession;
|
|
6333
|
-
console.log(
|
|
6334
|
-
if (options.project) console.log(
|
|
6335
|
-
if (sessionId) console.log(
|
|
6963
|
+
console.log(chalk20.bold("Diafunc chat") + chalk20.dim(" \xB7 /help for commands, /quit to exit"));
|
|
6964
|
+
if (options.project) console.log(chalk20.dim(`Project context: ${options.project}`));
|
|
6965
|
+
if (sessionId) console.log(chalk20.dim(`Continuing session ${sessionId}`));
|
|
6336
6966
|
const notice = await getUpdateNotice();
|
|
6337
|
-
if (notice) console.log(
|
|
6967
|
+
if (notice) console.log(chalk20.dim(notice));
|
|
6338
6968
|
console.log();
|
|
6339
6969
|
for (; ; ) {
|
|
6340
6970
|
let line;
|
|
6341
6971
|
try {
|
|
6342
|
-
line = await promptInput({ message:
|
|
6972
|
+
line = await promptInput({ message: chalk20.cyan.bold("you >") });
|
|
6343
6973
|
} catch {
|
|
6344
6974
|
console.log();
|
|
6345
6975
|
return;
|
|
@@ -6357,27 +6987,27 @@ async function runChatRepl(options) {
|
|
|
6357
6987
|
case "new":
|
|
6358
6988
|
sessionId = void 0;
|
|
6359
6989
|
lastReportedSession = void 0;
|
|
6360
|
-
console.log(
|
|
6990
|
+
console.log(chalk20.dim("Started a new session."));
|
|
6361
6991
|
continue;
|
|
6362
6992
|
case "clear":
|
|
6363
6993
|
console.clear();
|
|
6364
6994
|
continue;
|
|
6365
6995
|
case "session":
|
|
6366
6996
|
if (!arg) {
|
|
6367
|
-
console.log(
|
|
6997
|
+
console.log(chalk20.dim(`Current session: ${sessionId ?? "(new)"}`));
|
|
6368
6998
|
} else {
|
|
6369
6999
|
sessionId = arg;
|
|
6370
7000
|
lastReportedSession = void 0;
|
|
6371
|
-
console.log(
|
|
7001
|
+
console.log(chalk20.dim(`Switched to session ${sessionId}`));
|
|
6372
7002
|
}
|
|
6373
7003
|
continue;
|
|
6374
7004
|
case "help":
|
|
6375
7005
|
case "h":
|
|
6376
7006
|
case "?":
|
|
6377
|
-
for (const l of HELP) console.log(
|
|
7007
|
+
for (const l of HELP) console.log(chalk20.dim(l));
|
|
6378
7008
|
continue;
|
|
6379
7009
|
default:
|
|
6380
|
-
console.log(
|
|
7010
|
+
console.log(chalk20.dim(`Unknown command: /${cmd}. Try /help.`));
|
|
6381
7011
|
continue;
|
|
6382
7012
|
}
|
|
6383
7013
|
}
|
|
@@ -6390,19 +7020,19 @@ async function runChatRepl(options) {
|
|
|
6390
7020
|
sessionId = result.sessionId || sessionId;
|
|
6391
7021
|
console.log();
|
|
6392
7022
|
if (controller.signal.aborted) {
|
|
6393
|
-
console.log(
|
|
7023
|
+
console.log(chalk20.dim(" (cancelled)"));
|
|
6394
7024
|
} else {
|
|
6395
7025
|
const parts = [`${result.input} in / ${result.output} out`];
|
|
6396
7026
|
if (sessionId && sessionId !== lastReportedSession) {
|
|
6397
7027
|
parts.push(`session ${sessionId}`);
|
|
6398
7028
|
lastReportedSession = sessionId;
|
|
6399
7029
|
}
|
|
6400
|
-
console.log(
|
|
7030
|
+
console.log(chalk20.dim(` ${parts.join(" \xB7 ")}`));
|
|
6401
7031
|
}
|
|
6402
7032
|
console.log();
|
|
6403
7033
|
} catch (error) {
|
|
6404
7034
|
if (controller.signal.aborted) {
|
|
6405
|
-
console.log(
|
|
7035
|
+
console.log(chalk20.dim(" (cancelled)"));
|
|
6406
7036
|
console.log();
|
|
6407
7037
|
} else {
|
|
6408
7038
|
failure(`Request failed: ${error.message}`);
|
|
@@ -6434,7 +7064,7 @@ Examples:
|
|
|
6434
7064
|
});
|
|
6435
7065
|
chat.command("send").description("Send a chat message (blocking). Project context: the global --project and --branch").argument("<message>", "Message to send").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
|
|
6436
7066
|
try {
|
|
6437
|
-
const outputFormat =
|
|
7067
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
6438
7068
|
const api = createApiClient();
|
|
6439
7069
|
const context = chatContext(cmd);
|
|
6440
7070
|
const response = await api.language.chat({
|
|
@@ -6446,7 +7076,7 @@ Examples:
|
|
|
6446
7076
|
if (outputFormat === "human") {
|
|
6447
7077
|
console.log(renderMarkdown(response.content));
|
|
6448
7078
|
console.log();
|
|
6449
|
-
console.log(
|
|
7079
|
+
console.log(chalk20.dim(
|
|
6450
7080
|
` session ${response.sessionId} \xB7 ${response.inputTokens} in / ${response.outputTokens} out`
|
|
6451
7081
|
));
|
|
6452
7082
|
} else {
|
|
@@ -6458,7 +7088,7 @@ Examples:
|
|
|
6458
7088
|
});
|
|
6459
7089
|
chat.command("stream").description("Send a chat message (streaming). Project context: the global --project and --branch").argument("<message>", "Message to send").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
|
|
6460
7090
|
try {
|
|
6461
|
-
const outputFormat =
|
|
7091
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
6462
7092
|
const api = createApiClient();
|
|
6463
7093
|
const context = chatContext(cmd);
|
|
6464
7094
|
const response = await api.language.chatStream({
|
|
@@ -6514,7 +7144,7 @@ Examples:
|
|
|
6514
7144
|
sessionId = event.sessionId ?? "";
|
|
6515
7145
|
console.log();
|
|
6516
7146
|
console.log();
|
|
6517
|
-
console.log(
|
|
7147
|
+
console.log(chalk20.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
|
|
6518
7148
|
} else if (event.type === "error") {
|
|
6519
7149
|
failure(`Error: ${event.content}`);
|
|
6520
7150
|
}
|
|
@@ -6530,15 +7160,15 @@ Examples:
|
|
|
6530
7160
|
});
|
|
6531
7161
|
chat.command("upload").description("Upload a file for chat context").argument("<file>", "File to upload").action(async (file) => {
|
|
6532
7162
|
try {
|
|
6533
|
-
if (!
|
|
7163
|
+
if (!fs9.existsSync(file)) {
|
|
6534
7164
|
failure(`File not found: ${file}`);
|
|
6535
7165
|
process.exit(1);
|
|
6536
7166
|
}
|
|
6537
7167
|
const api = createApiClient();
|
|
6538
|
-
const fileBuffer =
|
|
7168
|
+
const fileBuffer = fs9.readFileSync(file);
|
|
6539
7169
|
const blob = new Blob([fileBuffer]);
|
|
6540
7170
|
const formData = new FormData();
|
|
6541
|
-
formData.append("file", blob,
|
|
7171
|
+
formData.append("file", blob, path7.basename(file));
|
|
6542
7172
|
const result = await api.language.upload(formData);
|
|
6543
7173
|
success(`File uploaded: ${result}`);
|
|
6544
7174
|
} catch (error) {
|
|
@@ -6548,7 +7178,7 @@ Examples:
|
|
|
6548
7178
|
const session = chat.command("session").description("Manage chat sessions");
|
|
6549
7179
|
session.command("list").description("List chat sessions").action(async (_options, cmd) => {
|
|
6550
7180
|
try {
|
|
6551
|
-
const outputFormat =
|
|
7181
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
6552
7182
|
const api = createApiClient();
|
|
6553
7183
|
const sessions = await api.language.getSessions();
|
|
6554
7184
|
format(sessions, {
|
|
@@ -6570,15 +7200,15 @@ Examples:
|
|
|
6570
7200
|
});
|
|
6571
7201
|
session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
|
|
6572
7202
|
try {
|
|
6573
|
-
const outputFormat =
|
|
7203
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
6574
7204
|
const api = createApiClient();
|
|
6575
7205
|
const detail2 = await api.language.getSession(sessionId);
|
|
6576
7206
|
if (outputFormat === "human") {
|
|
6577
|
-
console.log(
|
|
7207
|
+
console.log(chalk20.bold(detail2.title) + chalk20.dim(` (${detail2.sessionId})`));
|
|
6578
7208
|
console.log();
|
|
6579
7209
|
for (const msg of detail2.messages) {
|
|
6580
|
-
const role = msg.role === "user" ?
|
|
6581
|
-
console.log(`${role} ${
|
|
7210
|
+
const role = msg.role === "user" ? chalk20.cyan.bold("You") : chalk20.magenta.bold("Diafunc");
|
|
7211
|
+
console.log(`${role} ${chalk20.dim(msg.created)}`);
|
|
6582
7212
|
console.log(msg.content);
|
|
6583
7213
|
console.log();
|
|
6584
7214
|
}
|
|
@@ -6600,7 +7230,7 @@ Examples:
|
|
|
6600
7230
|
});
|
|
6601
7231
|
chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
|
|
6602
7232
|
try {
|
|
6603
|
-
const outputFormat =
|
|
7233
|
+
const outputFormat = getOutputFormat13(cmd);
|
|
6604
7234
|
const api = createApiClient();
|
|
6605
7235
|
const usage = await api.language.getUsage();
|
|
6606
7236
|
format(usage, { format: outputFormat });
|
|
@@ -6611,8 +7241,8 @@ Examples:
|
|
|
6611
7241
|
}
|
|
6612
7242
|
|
|
6613
7243
|
// src/commands/search/index.ts
|
|
6614
|
-
import
|
|
6615
|
-
function
|
|
7244
|
+
import chalk21 from "chalk";
|
|
7245
|
+
function getOutputFormat14(cmd) {
|
|
6616
7246
|
const config = loadConfig();
|
|
6617
7247
|
const globalOpts = cmd.optsWithGlobals();
|
|
6618
7248
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6635,7 +7265,7 @@ whose discovered model has the better quality comes first; inside one project th
|
|
|
6635
7265
|
`).action(async (query, options, cmd) => {
|
|
6636
7266
|
const sort = parseSort(options.sort);
|
|
6637
7267
|
try {
|
|
6638
|
-
const outputFormat =
|
|
7268
|
+
const outputFormat = getOutputFormat14(cmd);
|
|
6639
7269
|
const overrides = cmd.optsWithGlobals();
|
|
6640
7270
|
const config = loadConfig();
|
|
6641
7271
|
const api = createApiClient();
|
|
@@ -6673,7 +7303,7 @@ whose discovered model has the better quality comes first; inside one project th
|
|
|
6673
7303
|
});
|
|
6674
7304
|
}
|
|
6675
7305
|
if (page.nextCursor && isInteractive()) {
|
|
6676
|
-
console.log(
|
|
7306
|
+
console.log(chalk21.dim(`More results available. Raise --limit to see them.`));
|
|
6677
7307
|
}
|
|
6678
7308
|
} catch (error) {
|
|
6679
7309
|
handleError(error);
|
|
@@ -6695,12 +7325,12 @@ function renderResults(items) {
|
|
|
6695
7325
|
for (const item of items) {
|
|
6696
7326
|
const name = item.name || "(unnamed)";
|
|
6697
7327
|
console.log();
|
|
6698
|
-
console.log(`${
|
|
7328
|
+
console.log(`${chalk21.dim(`[${item.contentType}]`)} ${chalk21.bold(name)}${qualityNote(item)}`);
|
|
6699
7329
|
const raw = item.snippetField === "name" ? item.description : item.snippet ?? item.description;
|
|
6700
7330
|
const line = raw ? collapse(raw) : null;
|
|
6701
7331
|
if (line && stripHighlight(line) !== name) console.log(` ${highlight(line)}`);
|
|
6702
7332
|
const ref = item.entityId ? `${item.projectId}/${item.projectBranch}/${item.entityId}/${item.entityBranch ?? "main"}` : item.projectId;
|
|
6703
|
-
console.log(` ${
|
|
7333
|
+
console.log(` ${chalk21.dim(ref)}`);
|
|
6704
7334
|
}
|
|
6705
7335
|
console.log();
|
|
6706
7336
|
}
|
|
@@ -6708,16 +7338,16 @@ function qualityNote(item) {
|
|
|
6708
7338
|
if (item.contentType !== "project" || typeof item.quality !== "number" || !Number.isFinite(item.quality)) {
|
|
6709
7339
|
return "";
|
|
6710
7340
|
}
|
|
6711
|
-
return
|
|
7341
|
+
return chalk21.dim(` quality ${percent(item.quality).trim()}`);
|
|
6712
7342
|
}
|
|
6713
7343
|
var HIGHLIGHT_OPEN = /<mark>/g;
|
|
6714
7344
|
var HIGHLIGHT_CLOSE = /<\/mark>/g;
|
|
6715
7345
|
function highlight(text2) {
|
|
6716
7346
|
const parts = text2.split(HIGHLIGHT_OPEN);
|
|
6717
7347
|
return parts.map((part, i) => {
|
|
6718
|
-
if (i === 0) return
|
|
7348
|
+
if (i === 0) return chalk21.dim(part);
|
|
6719
7349
|
const [marked, ...rest] = part.split(HIGHLIGHT_CLOSE);
|
|
6720
|
-
return
|
|
7350
|
+
return chalk21.bold.cyan(marked) + chalk21.dim(rest.join(""));
|
|
6721
7351
|
}).join("");
|
|
6722
7352
|
}
|
|
6723
7353
|
function stripHighlight(text2) {
|
|
@@ -6730,7 +7360,147 @@ function collapse(text2) {
|
|
|
6730
7360
|
|
|
6731
7361
|
// src/commands/admin/index.ts
|
|
6732
7362
|
import { readFile } from "fs/promises";
|
|
6733
|
-
|
|
7363
|
+
|
|
7364
|
+
// src/commands/admin/curated-tags.ts
|
|
7365
|
+
import chalk22 from "chalk";
|
|
7366
|
+
function getOutputFormat15(cmd) {
|
|
7367
|
+
const config = loadConfig();
|
|
7368
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
7369
|
+
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
7370
|
+
}
|
|
7371
|
+
var COLUMNS = [
|
|
7372
|
+
{ key: "tag" },
|
|
7373
|
+
{ key: "displayName", header: "name" },
|
|
7374
|
+
{ key: "description" },
|
|
7375
|
+
{ key: "sortOrder", header: "order", kind: "number" },
|
|
7376
|
+
{ key: "projectCount", header: "public projects", kind: "number" }
|
|
7377
|
+
];
|
|
7378
|
+
function curatedTagOf(typed2) {
|
|
7379
|
+
const tag = normalizeTag(typed2);
|
|
7380
|
+
if (tag === "") usageError(`"${typed2}" is not a usable tag: a tag needs at least one letter or digit.`);
|
|
7381
|
+
if (tag !== typed2) console.error(chalk22.dim(`"${typed2}" is written as "${tag}", the form tags are searched by.`));
|
|
7382
|
+
return tag;
|
|
7383
|
+
}
|
|
7384
|
+
function parseSortOrder(raw) {
|
|
7385
|
+
if (!/^-?\d+$/.test(raw.trim())) usageError(`Invalid --sort-order "${raw}": a whole number is expected.`);
|
|
7386
|
+
return Number.parseInt(raw, 10);
|
|
7387
|
+
}
|
|
7388
|
+
function registerCuratedTagCommands(admin) {
|
|
7389
|
+
const curated = admin.command("curated-tags").description('The curated tags: the "data domain" filter of Explore').addHelpText("after", `
|
|
7390
|
+
A curated tag gives a tag a name and a place in Explore's data-domain filter; a project
|
|
7391
|
+
appears under it when it carries the tag (see 'diafunc project tags'). Anyone can list
|
|
7392
|
+
them; creating, updating and deleting need a platform administrator.
|
|
7393
|
+
|
|
7394
|
+
Examples:
|
|
7395
|
+
$ diafunc admin curated-tags list
|
|
7396
|
+
$ diafunc admin curated-tags create health --display-name "Health" --sort-order 1
|
|
7397
|
+
$ diafunc admin curated-tags update health --description "Medicine, public health, biology"
|
|
7398
|
+
$ diafunc admin curated-tags delete health
|
|
7399
|
+
`);
|
|
7400
|
+
curated.command("list").description("List the curated tags in their order, with the number of public projects under each").addHelpText("after", `
|
|
7401
|
+
Needs no account. The counts are of public projects only and can be a minute behind.
|
|
7402
|
+
|
|
7403
|
+
Examples:
|
|
7404
|
+
$ diafunc admin curated-tags list
|
|
7405
|
+
$ diafunc admin curated-tags list -o json
|
|
7406
|
+
`).action(async (_options, cmd) => {
|
|
7407
|
+
try {
|
|
7408
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
7409
|
+
const tags = await createApiClient().index.getCuratedTags(true);
|
|
7410
|
+
if (tags.length === 0) {
|
|
7411
|
+
empty("curated tags", { format: outputFormat });
|
|
7412
|
+
return;
|
|
7413
|
+
}
|
|
7414
|
+
format(tags, { format: outputFormat, columns: COLUMNS });
|
|
7415
|
+
} catch (error) {
|
|
7416
|
+
handleError(error);
|
|
7417
|
+
}
|
|
7418
|
+
});
|
|
7419
|
+
curated.command("create").description("Create a curated tag (admin)").argument("<tag>", 'The tag projects carry, stored in its canonical form ("Machine Learning" becomes "machine-learning")').requiredOption("--display-name <name>", "The name Explore shows for it").option("--description <text>", "What belongs under it").option("--sort-order <n>", "Position in the filter, lowest first; tags without one come last").addHelpText("after", `
|
|
7420
|
+
Examples:
|
|
7421
|
+
$ diafunc admin curated-tags create health --display-name "Health" --sort-order 1
|
|
7422
|
+
$ diafunc admin curated-tags create "Machine Learning" --display-name "Machine learning" --dry-run
|
|
7423
|
+
`).action(async (typed2, options, cmd) => {
|
|
7424
|
+
try {
|
|
7425
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
7426
|
+
const tag = curatedTagOf(typed2);
|
|
7427
|
+
if (isReservedTag(tag)) {
|
|
7428
|
+
usageError(`"${tag}" is reserved for the staging content of analysis runs and is never searchable.`);
|
|
7429
|
+
}
|
|
7430
|
+
const displayName = (options.displayName ?? "").trim();
|
|
7431
|
+
if (displayName === "") usageError("--display-name must not be empty.");
|
|
7432
|
+
const request = {
|
|
7433
|
+
tag,
|
|
7434
|
+
displayName,
|
|
7435
|
+
...options.description !== void 0 && options.description.trim() !== "" ? { description: options.description } : {},
|
|
7436
|
+
...options.sortOrder !== void 0 ? { sortOrder: parseSortOrder(options.sortOrder) } : {}
|
|
7437
|
+
};
|
|
7438
|
+
const created = await createApiClient().index.createCuratedTag(request);
|
|
7439
|
+
if (isDryRun()) return;
|
|
7440
|
+
if (outputFormat === "human") {
|
|
7441
|
+
success(`Curated tag "${created.tag}" created.`);
|
|
7442
|
+
} else {
|
|
7443
|
+
format(created, { format: outputFormat });
|
|
7444
|
+
}
|
|
7445
|
+
} catch (error) {
|
|
7446
|
+
handleError(error);
|
|
7447
|
+
}
|
|
7448
|
+
});
|
|
7449
|
+
curated.command("update").description("Change the name, description or position of a curated tag (admin)").argument("<tag>", "The curated tag").option("--display-name <name>", "The name Explore shows for it").option("--description <text>", "What belongs under it; an empty value clears it").option("--sort-order <n>", "Position in the filter, lowest first").addHelpText("after", `
|
|
7450
|
+
Only what is given changes. The tag itself cannot be renamed: delete it and create the new one.
|
|
7451
|
+
|
|
7452
|
+
Examples:
|
|
7453
|
+
$ diafunc admin curated-tags update health --display-name "Health and medicine"
|
|
7454
|
+
$ diafunc admin curated-tags update health --description "" clears the description
|
|
7455
|
+
$ diafunc admin curated-tags update health --sort-order 3 --dry-run
|
|
7456
|
+
`).action(async (typed2, options, cmd) => {
|
|
7457
|
+
try {
|
|
7458
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
7459
|
+
const tag = curatedTagOf(typed2);
|
|
7460
|
+
if (options.displayName === void 0 && options.description === void 0 && options.sortOrder === void 0) {
|
|
7461
|
+
usageError("Nothing to change.", "Pass at least one of --display-name, --description, --sort-order.");
|
|
7462
|
+
}
|
|
7463
|
+
if (options.displayName !== void 0 && options.displayName.trim() === "") {
|
|
7464
|
+
usageError("--display-name must not be empty.");
|
|
7465
|
+
}
|
|
7466
|
+
const request = {
|
|
7467
|
+
...options.displayName !== void 0 ? { displayName: options.displayName.trim() } : {},
|
|
7468
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
7469
|
+
...options.sortOrder !== void 0 ? { sortOrder: parseSortOrder(options.sortOrder) } : {}
|
|
7470
|
+
};
|
|
7471
|
+
const updated = await createApiClient().index.updateCuratedTag(tag, request);
|
|
7472
|
+
if (isDryRun()) return;
|
|
7473
|
+
if (outputFormat === "human") {
|
|
7474
|
+
success(`Curated tag "${tag}" updated.`);
|
|
7475
|
+
} else {
|
|
7476
|
+
format(updated, { format: outputFormat });
|
|
7477
|
+
}
|
|
7478
|
+
} catch (error) {
|
|
7479
|
+
handleError(error);
|
|
7480
|
+
}
|
|
7481
|
+
});
|
|
7482
|
+
curated.command("delete").description("Delete a curated tag (admin); projects that carry the tag keep it").argument("<tag>", "The curated tag").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").addHelpText("after", `
|
|
7483
|
+
Examples:
|
|
7484
|
+
$ diafunc admin curated-tags delete health
|
|
7485
|
+
$ diafunc admin curated-tags delete health --yes --dry-run
|
|
7486
|
+
`).action(async (typed2, options, cmd) => {
|
|
7487
|
+
try {
|
|
7488
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
7489
|
+
const tag = curatedTagOf(typed2);
|
|
7490
|
+
if (!isDryRun()) {
|
|
7491
|
+
await confirmDestructive(`This removes "${tag}" from Explore's data-domain filter.`, { yes: options.yes, resourceId: tag });
|
|
7492
|
+
}
|
|
7493
|
+
await createApiClient().index.deleteCuratedTag(tag);
|
|
7494
|
+
if (isDryRun()) return;
|
|
7495
|
+
success(`Curated tag "${tag}" deleted.`, { format: outputFormat });
|
|
7496
|
+
} catch (error) {
|
|
7497
|
+
handleError(error);
|
|
7498
|
+
}
|
|
7499
|
+
});
|
|
7500
|
+
}
|
|
7501
|
+
|
|
7502
|
+
// src/commands/admin/index.ts
|
|
7503
|
+
function getOutputFormat16(cmd) {
|
|
6734
7504
|
const config = loadConfig();
|
|
6735
7505
|
const globalOpts = cmd.optsWithGlobals();
|
|
6736
7506
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -6740,7 +7510,7 @@ function registerAdminCommands(program) {
|
|
|
6740
7510
|
const users = admin.command("users").description("Manage users");
|
|
6741
7511
|
users.command("list").description("List all users (admin)").action(async (_options, cmd) => {
|
|
6742
7512
|
try {
|
|
6743
|
-
const outputFormat =
|
|
7513
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
6744
7514
|
const api = createApiClient();
|
|
6745
7515
|
const userList = await api.admin.getUsers();
|
|
6746
7516
|
const summary = userList.map((u) => ({
|
|
@@ -6766,7 +7536,7 @@ function registerAdminCommands(program) {
|
|
|
6766
7536
|
});
|
|
6767
7537
|
users.command("get").description("Get current user details").action(async (_options, cmd) => {
|
|
6768
7538
|
try {
|
|
6769
|
-
const outputFormat =
|
|
7539
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
6770
7540
|
const api = createApiClient();
|
|
6771
7541
|
const user = await api.admin.getMyUser();
|
|
6772
7542
|
format(user, { format: outputFormat });
|
|
@@ -6776,7 +7546,7 @@ function registerAdminCommands(program) {
|
|
|
6776
7546
|
});
|
|
6777
7547
|
admin.command("subscription").description("Show current subscription").action(async (_options, cmd) => {
|
|
6778
7548
|
try {
|
|
6779
|
-
const outputFormat =
|
|
7549
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
6780
7550
|
const api = createApiClient();
|
|
6781
7551
|
const sub = await api.admin.getCurrentSubscription();
|
|
6782
7552
|
format(sub, { format: outputFormat });
|
|
@@ -6787,7 +7557,7 @@ function registerAdminCommands(program) {
|
|
|
6787
7557
|
const settings = admin.command("settings").description("Manage settings");
|
|
6788
7558
|
settings.command("get").description("Get current settings").action(async (_options, cmd) => {
|
|
6789
7559
|
try {
|
|
6790
|
-
const outputFormat =
|
|
7560
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
6791
7561
|
const api = createApiClient();
|
|
6792
7562
|
const s = await api.admin.getSettings();
|
|
6793
7563
|
format(s, { format: outputFormat });
|
|
@@ -6807,7 +7577,7 @@ function registerAdminCommands(program) {
|
|
|
6807
7577
|
const platformSettings = admin.command("platform-settings").description("Manage platform-wide settings (admin only)");
|
|
6808
7578
|
platformSettings.command("list").description("Show every platform setting with its default and current override").action(async (_options, cmd) => {
|
|
6809
7579
|
try {
|
|
6810
|
-
const outputFormat =
|
|
7580
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
6811
7581
|
const api = createApiClient();
|
|
6812
7582
|
const settingsList = await api.admin.listPlatformSettings();
|
|
6813
7583
|
format(settingsList, { format: outputFormat });
|
|
@@ -6894,9 +7664,10 @@ function registerAdminCommands(program) {
|
|
|
6894
7664
|
handleError(error);
|
|
6895
7665
|
}
|
|
6896
7666
|
});
|
|
7667
|
+
registerCuratedTagCommands(admin);
|
|
6897
7668
|
admin.command("permissions").description("Show your permissions on a project").argument("<projectId>", "Project ID").action(async (projectId, _options, cmd) => {
|
|
6898
7669
|
try {
|
|
6899
|
-
const outputFormat =
|
|
7670
|
+
const outputFormat = getOutputFormat16(cmd);
|
|
6900
7671
|
const api = createApiClient();
|
|
6901
7672
|
const perm = await api.admin.getPermissions(projectId);
|
|
6902
7673
|
format({ projectId, permission: perm }, { format: outputFormat });
|
|
@@ -6909,7 +7680,7 @@ function registerAdminCommands(program) {
|
|
|
6909
7680
|
contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
|
|
6910
7681
|
try {
|
|
6911
7682
|
const api = createApiClient();
|
|
6912
|
-
format(await api.admin.getTeamContract(teamId), { format:
|
|
7683
|
+
format(await api.admin.getTeamContract(teamId), { format: getOutputFormat16(cmd) });
|
|
6913
7684
|
} catch (error) {
|
|
6914
7685
|
handleError(error);
|
|
6915
7686
|
}
|
|
@@ -6922,7 +7693,7 @@ function registerAdminCommands(program) {
|
|
|
6922
7693
|
{ yes: options.yes, resourceId: teamId }
|
|
6923
7694
|
);
|
|
6924
7695
|
const api = createApiClient();
|
|
6925
|
-
format(await api.admin.issueTeamContract(teamId, request), { format:
|
|
7696
|
+
format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat16(cmd) });
|
|
6926
7697
|
} catch (error) {
|
|
6927
7698
|
handleError(error);
|
|
6928
7699
|
}
|
|
@@ -6930,14 +7701,14 @@ function registerAdminCommands(program) {
|
|
|
6930
7701
|
}
|
|
6931
7702
|
|
|
6932
7703
|
// src/commands/status/summary.ts
|
|
6933
|
-
import
|
|
7704
|
+
import chalk23 from "chalk";
|
|
6934
7705
|
|
|
6935
7706
|
// src/client/services/status.ts
|
|
6936
7707
|
function createStatusService() {
|
|
6937
7708
|
const config = loadConfig();
|
|
6938
7709
|
const endpoint = resolveEndpoint(config);
|
|
6939
|
-
async function fetchJson(
|
|
6940
|
-
const url = `${endpoint}/status/v1${
|
|
7710
|
+
async function fetchJson(path13) {
|
|
7711
|
+
const url = `${endpoint}/status/v1${path13}`;
|
|
6941
7712
|
const response = await fetch(url, {
|
|
6942
7713
|
headers: { "Accept": "application/json" }
|
|
6943
7714
|
});
|
|
@@ -6956,24 +7727,24 @@ function createStatusService() {
|
|
|
6956
7727
|
|
|
6957
7728
|
// src/commands/status/summary.ts
|
|
6958
7729
|
var STATE_COLORS = {
|
|
6959
|
-
UP:
|
|
6960
|
-
DEGRADED:
|
|
6961
|
-
DOWN:
|
|
6962
|
-
UNKNOWN:
|
|
7730
|
+
UP: chalk23.green,
|
|
7731
|
+
DEGRADED: chalk23.yellow,
|
|
7732
|
+
DOWN: chalk23.red,
|
|
7733
|
+
UNKNOWN: chalk23.gray
|
|
6963
7734
|
};
|
|
6964
7735
|
function stateColor(state) {
|
|
6965
|
-
return STATE_COLORS[state] ??
|
|
7736
|
+
return STATE_COLORS[state] ?? chalk23.gray;
|
|
6966
7737
|
}
|
|
6967
7738
|
function stateSymbol(state) {
|
|
6968
7739
|
switch (state) {
|
|
6969
7740
|
case "UP":
|
|
6970
|
-
return
|
|
7741
|
+
return chalk23.green("\u25CF");
|
|
6971
7742
|
case "DEGRADED":
|
|
6972
|
-
return
|
|
7743
|
+
return chalk23.yellow("\u25CF");
|
|
6973
7744
|
case "DOWN":
|
|
6974
|
-
return
|
|
7745
|
+
return chalk23.red("\u25CF");
|
|
6975
7746
|
default:
|
|
6976
|
-
return
|
|
7747
|
+
return chalk23.gray("\u25CB");
|
|
6977
7748
|
}
|
|
6978
7749
|
}
|
|
6979
7750
|
function registerSummaryCommand(parent) {
|
|
@@ -6998,20 +7769,20 @@ function registerSummaryCommand(parent) {
|
|
|
6998
7769
|
const label = stateColor(domain.state)(domain.state.padEnd(10));
|
|
6999
7770
|
console.log(` ${stateSymbol(domain.state)} ${label} ${domain.name}`);
|
|
7000
7771
|
if (domain.componentIds.length > 0) {
|
|
7001
|
-
console.log(` ${
|
|
7772
|
+
console.log(` ${chalk23.dim(domain.componentIds.join(", "))}`);
|
|
7002
7773
|
}
|
|
7003
7774
|
}
|
|
7004
7775
|
console.log();
|
|
7005
7776
|
if (summary.openIncidents > 0) {
|
|
7006
|
-
console.log(
|
|
7777
|
+
console.log(chalk23.yellow(` ${summary.openIncidents} active incident(s)`));
|
|
7007
7778
|
} else {
|
|
7008
|
-
console.log(
|
|
7779
|
+
console.log(chalk23.dim(" No active incidents"));
|
|
7009
7780
|
}
|
|
7010
|
-
console.log(
|
|
7781
|
+
console.log(chalk23.dim(
|
|
7011
7782
|
`
|
|
7012
7783
|
Platform v${version.platformVersion} \xB7 checked ${formatInstant(summary.timestamp)}`
|
|
7013
7784
|
));
|
|
7014
|
-
console.log(
|
|
7785
|
+
console.log(chalk23.dim(` Drill into one with 'diafunc status component <id>'.`));
|
|
7015
7786
|
console.log();
|
|
7016
7787
|
} catch (error) {
|
|
7017
7788
|
handleError(error);
|
|
@@ -7020,17 +7791,17 @@ function registerSummaryCommand(parent) {
|
|
|
7020
7791
|
}
|
|
7021
7792
|
|
|
7022
7793
|
// src/commands/status/component.ts
|
|
7023
|
-
import
|
|
7794
|
+
import chalk24 from "chalk";
|
|
7024
7795
|
function stateSymbol2(state) {
|
|
7025
7796
|
switch (state) {
|
|
7026
7797
|
case "UP":
|
|
7027
|
-
return
|
|
7798
|
+
return chalk24.green("\u25CF");
|
|
7028
7799
|
case "DEGRADED":
|
|
7029
|
-
return
|
|
7800
|
+
return chalk24.yellow("\u25CF");
|
|
7030
7801
|
case "DOWN":
|
|
7031
|
-
return
|
|
7802
|
+
return chalk24.red("\u25CF");
|
|
7032
7803
|
default:
|
|
7033
|
-
return
|
|
7804
|
+
return chalk24.gray("\u25CB");
|
|
7034
7805
|
}
|
|
7035
7806
|
}
|
|
7036
7807
|
function registerComponentCommand(parent) {
|
|
@@ -7055,7 +7826,7 @@ function registerComponentCommand(parent) {
|
|
|
7055
7826
|
return;
|
|
7056
7827
|
}
|
|
7057
7828
|
console.log();
|
|
7058
|
-
console.log(` ${stateSymbol2(match.state)} ${
|
|
7829
|
+
console.log(` ${stateSymbol2(match.state)} ${chalk24.bold(match.id)} ${match.version ? chalk24.dim("v" + match.version) : ""}`);
|
|
7059
7830
|
console.log(` State: ${renderState(match.state)}`);
|
|
7060
7831
|
if (match.lastCheckAt) {
|
|
7061
7832
|
console.log(` Last check: ${formatInstant(match.lastCheckAt)}`);
|
|
@@ -7064,7 +7835,7 @@ function registerComponentCommand(parent) {
|
|
|
7064
7835
|
console.log();
|
|
7065
7836
|
console.log(" Checks:");
|
|
7066
7837
|
for (const check of match.checks) {
|
|
7067
|
-
const cat = check.category ?
|
|
7838
|
+
const cat = check.category ? chalk24.dim(` (${check.category})`) : "";
|
|
7068
7839
|
console.log(` ${stateSymbol2(check.state)} ${check.name}${cat}`);
|
|
7069
7840
|
}
|
|
7070
7841
|
}
|
|
@@ -7076,12 +7847,12 @@ function registerComponentCommand(parent) {
|
|
|
7076
7847
|
}
|
|
7077
7848
|
|
|
7078
7849
|
// src/commands/status/incidents.ts
|
|
7079
|
-
import
|
|
7850
|
+
import chalk25 from "chalk";
|
|
7080
7851
|
var SEVERITY_COLORS = {
|
|
7081
|
-
ERROR:
|
|
7082
|
-
WARNING:
|
|
7083
|
-
INFO:
|
|
7084
|
-
MAINTENANCE:
|
|
7852
|
+
ERROR: chalk25.red,
|
|
7853
|
+
WARNING: chalk25.yellow,
|
|
7854
|
+
INFO: chalk25.blue,
|
|
7855
|
+
MAINTENANCE: chalk25.cyan
|
|
7085
7856
|
};
|
|
7086
7857
|
function registerIncidentsCommand(parent) {
|
|
7087
7858
|
parent.command("incidents").description("List recent incidents").option("-w, --window <window>", "Time window (e.g. 24h, 48h)", "24h").action(async (options, cmd) => {
|
|
@@ -7095,22 +7866,22 @@ function registerIncidentsCommand(parent) {
|
|
|
7095
7866
|
return;
|
|
7096
7867
|
}
|
|
7097
7868
|
if (incidents.length === 0) {
|
|
7098
|
-
console.log(
|
|
7869
|
+
console.log(chalk25.dim(`
|
|
7099
7870
|
No incidents in the last ${options.window}.
|
|
7100
7871
|
`));
|
|
7101
7872
|
return;
|
|
7102
7873
|
}
|
|
7103
7874
|
console.log();
|
|
7104
7875
|
for (const incident of incidents) {
|
|
7105
|
-
const color = SEVERITY_COLORS[incident.severity] ??
|
|
7876
|
+
const color = SEVERITY_COLORS[incident.severity] ?? chalk25.gray;
|
|
7106
7877
|
const severity = color(incident.severity.padEnd(8));
|
|
7107
7878
|
const time = incident.startedAt ? new Date(incident.startedAt).toLocaleString() : "";
|
|
7108
|
-
const resolved = incident.resolvedAt ?
|
|
7879
|
+
const resolved = incident.resolvedAt ? chalk25.green(" [resolved]") : chalk25.yellow(" [open]");
|
|
7109
7880
|
console.log(` ${severity} ${incident.summary}${resolved}`);
|
|
7110
|
-
console.log(
|
|
7881
|
+
console.log(chalk25.dim(` ${time}`));
|
|
7111
7882
|
for (const update of incident.updates) {
|
|
7112
7883
|
const updateTime = new Date(update.at).toLocaleTimeString();
|
|
7113
|
-
console.log(
|
|
7884
|
+
console.log(chalk25.dim(` ${updateTime} ${update.status} ${update.message}`));
|
|
7114
7885
|
}
|
|
7115
7886
|
console.log();
|
|
7116
7887
|
}
|
|
@@ -7135,12 +7906,12 @@ Examples:
|
|
|
7135
7906
|
}
|
|
7136
7907
|
|
|
7137
7908
|
// src/commands/analyze/index.ts
|
|
7138
|
-
import * as
|
|
7139
|
-
import * as
|
|
7909
|
+
import * as fs11 from "fs";
|
|
7910
|
+
import * as path9 from "path";
|
|
7140
7911
|
import { spawn as spawn2 } from "child_process";
|
|
7141
7912
|
|
|
7142
7913
|
// src/commands/analyze/watch-view.ts
|
|
7143
|
-
import
|
|
7914
|
+
import chalk26 from "chalk";
|
|
7144
7915
|
|
|
7145
7916
|
// src/client/types/analysis.ts
|
|
7146
7917
|
var RUN_PHASE_LABELS = {
|
|
@@ -7277,25 +8048,25 @@ function renderWatchBlock(input) {
|
|
|
7277
8048
|
const lines = [];
|
|
7278
8049
|
const step = stepCounter(run);
|
|
7279
8050
|
const headline = [
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
step ?
|
|
8051
|
+
chalk26.cyan(SPINNER),
|
|
8052
|
+
chalk26.bold(phaseLabel(run)),
|
|
8053
|
+
step ? chalk26.dim(step) : null
|
|
7283
8054
|
].filter(Boolean).join(" ");
|
|
7284
8055
|
lines.push(` ${headline}`);
|
|
7285
8056
|
const fraction = overallProgress(run);
|
|
7286
|
-
const elapsed =
|
|
8057
|
+
const elapsed = chalk26.dim(formatDurationPrecise(elapsedMs));
|
|
7287
8058
|
if (fraction === null) {
|
|
7288
|
-
lines.push(` ${
|
|
8059
|
+
lines.push(` ${chalk26.dim("working")} ${elapsed}`);
|
|
7289
8060
|
} else {
|
|
7290
8061
|
const ceiling = remainingCeiling(run, budgetHours);
|
|
7291
8062
|
lines.push(
|
|
7292
|
-
` ${bar(fraction)} ${percent(fraction)} ${elapsed}` + (ceiling !== null ?
|
|
8063
|
+
` ${bar(fraction)} ${percent(fraction)} ${elapsed}` + (ceiling !== null ? chalk26.dim(` \xB7 at most ${formatDurationPrecise(ceiling)} remaining`) : "")
|
|
7293
8064
|
);
|
|
7294
8065
|
}
|
|
7295
8066
|
const detail2 = caption ?? phaseDetail(run);
|
|
7296
|
-
if (detail2) lines.push(` ${
|
|
8067
|
+
if (detail2) lines.push(` ${chalk26.dim(detail2)}`);
|
|
7297
8068
|
if (run.retryAttempts && run.retryAttempts > 0) {
|
|
7298
|
-
lines.push(` ${
|
|
8069
|
+
lines.push(` ${chalk26.yellow("!")} ${chalk26.dim(
|
|
7299
8070
|
`restarted ${run.retryAttempts === 1 ? "once" : `${run.retryAttempts} times`} after an interruption; progress restarts from the beginning`
|
|
7300
8071
|
)}`);
|
|
7301
8072
|
}
|
|
@@ -7303,7 +8074,7 @@ function renderWatchBlock(input) {
|
|
|
7303
8074
|
}
|
|
7304
8075
|
|
|
7305
8076
|
// src/commands/analyze/wizard.ts
|
|
7306
|
-
import
|
|
8077
|
+
import chalk27 from "chalk";
|
|
7307
8078
|
|
|
7308
8079
|
// src/commands/analyze/columns.ts
|
|
7309
8080
|
var MAX_COLUMNS_LISTED = 30;
|
|
@@ -7558,7 +8329,7 @@ async function promptRunFields(prompter, options) {
|
|
|
7558
8329
|
targets = await prompter.checkbox({
|
|
7559
8330
|
message: "Target columns: what should the analysis predict?",
|
|
7560
8331
|
choices: named.map((c) => ({
|
|
7561
|
-
name: c.valueType ? `${c.name} ${
|
|
8332
|
+
name: c.valueType ? `${c.name} ${chalk27.dim(`(${c.valueType})`)}` : c.name,
|
|
7562
8333
|
value: c.name,
|
|
7563
8334
|
checked: preselected.has(c.name)
|
|
7564
8335
|
})),
|
|
@@ -7587,7 +8358,7 @@ async function promptRunFields(prompter, options) {
|
|
|
7587
8358
|
choices: [
|
|
7588
8359
|
{ name: "No segmentation", value: null },
|
|
7589
8360
|
...remaining.map((c) => ({
|
|
7590
|
-
name: c.valueType ? `${c.name} ${
|
|
8361
|
+
name: c.valueType ? `${c.name} ${chalk27.dim(`(${c.valueType})`)}` : c.name,
|
|
7591
8362
|
value: c.name
|
|
7592
8363
|
}))
|
|
7593
8364
|
]
|
|
@@ -7770,7 +8541,7 @@ function whyNoPrompt(outputFormat, noInteractive) {
|
|
|
7770
8541
|
}
|
|
7771
8542
|
|
|
7772
8543
|
// src/commands/analyze/data-import.ts
|
|
7773
|
-
import
|
|
8544
|
+
import chalk28 from "chalk";
|
|
7774
8545
|
|
|
7775
8546
|
// src/commands/analyze/details.ts
|
|
7776
8547
|
function analysisDetails(analysis, endpoint) {
|
|
@@ -7894,19 +8665,19 @@ function constraintsText(analysis) {
|
|
|
7894
8665
|
var IMPORT_POLL_INTERVAL_MS = 2e3;
|
|
7895
8666
|
function renderImportBlock(dataImport, elapsedMs) {
|
|
7896
8667
|
const title = dataImport.state === "STOPPING" ? "Stopping the data import" : "Importing data";
|
|
7897
|
-
const lines = [` ${
|
|
7898
|
-
const elapsed =
|
|
8668
|
+
const lines = [` ${chalk28.cyan(SPINNER)} ${chalk28.bold(title)}`];
|
|
8669
|
+
const elapsed = chalk28.dim(formatDurationPrecise(elapsedMs));
|
|
7899
8670
|
if (dataImport.state === "IMPORTING" && dataImport.progress !== null && dataImport.progress !== void 0) {
|
|
7900
8671
|
lines.push(` ${bar(dataImport.progress)} ${percent(dataImport.progress)} ${elapsed}`);
|
|
7901
8672
|
} else {
|
|
7902
|
-
lines.push(` ${
|
|
8673
|
+
lines.push(` ${chalk28.dim(dataImport.message)} ${elapsed}`);
|
|
7903
8674
|
}
|
|
7904
8675
|
return lines;
|
|
7905
8676
|
}
|
|
7906
8677
|
function sleep3(ms) {
|
|
7907
8678
|
let timer;
|
|
7908
|
-
const done = new Promise((
|
|
7909
|
-
timer = setTimeout(() =>
|
|
8679
|
+
const done = new Promise((resolve2) => {
|
|
8680
|
+
timer = setTimeout(() => resolve2("elapsed"), ms);
|
|
7910
8681
|
});
|
|
7911
8682
|
return { done, cancel: () => clearTimeout(timer) };
|
|
7912
8683
|
}
|
|
@@ -7918,8 +8689,8 @@ async function followImport(ctx, first) {
|
|
|
7918
8689
|
const status = new Status();
|
|
7919
8690
|
let interrupt = () => {
|
|
7920
8691
|
};
|
|
7921
|
-
const interrupted = new Promise((
|
|
7922
|
-
interrupt = () =>
|
|
8692
|
+
const interrupted = new Promise((resolve2) => {
|
|
8693
|
+
interrupt = () => resolve2("interrupted");
|
|
7923
8694
|
});
|
|
7924
8695
|
process.once("SIGINT", interrupt);
|
|
7925
8696
|
if (ctx.live) {
|
|
@@ -7931,10 +8702,10 @@ async function followImport(ctx, first) {
|
|
|
7931
8702
|
try {
|
|
7932
8703
|
for (; ; ) {
|
|
7933
8704
|
if (ctx.live) status.set(renderImportBlock(current, Date.now() - since));
|
|
7934
|
-
const
|
|
7935
|
-
const woke = await Promise.race([
|
|
8705
|
+
const pause2 = sleep3(IMPORT_POLL_INTERVAL_MS);
|
|
8706
|
+
const woke = await Promise.race([pause2.done, interrupted]);
|
|
7936
8707
|
if (woke === "interrupted") {
|
|
7937
|
-
|
|
8708
|
+
pause2.cancel();
|
|
7938
8709
|
status.stop();
|
|
7939
8710
|
warn("Stopped waiting. The import keeps running on the platform.");
|
|
7940
8711
|
hint(`See how far it is with 'diafunc analyze get ${analysisId}'.`);
|
|
@@ -8067,8 +8838,8 @@ async function queueRun(api, analysisId) {
|
|
|
8067
8838
|
}
|
|
8068
8839
|
|
|
8069
8840
|
// src/commands/analyze/sources.ts
|
|
8070
|
-
import * as
|
|
8071
|
-
import * as
|
|
8841
|
+
import * as fs10 from "fs";
|
|
8842
|
+
import * as path8 from "path";
|
|
8072
8843
|
var CAUTIONS = /* @__PURE__ */ new Set([
|
|
8073
8844
|
"UNEVEN_COLUMNS",
|
|
8074
8845
|
"TYPE_CONFLICT",
|
|
@@ -8089,7 +8860,7 @@ function recipeWithChoices(proposal, choices) {
|
|
|
8089
8860
|
return { parts: proposal.parts, originColumn, dropDuplicates, lookups: proposal.lookups ?? [] };
|
|
8090
8861
|
}
|
|
8091
8862
|
function labelOf(file) {
|
|
8092
|
-
return
|
|
8863
|
+
return path8.basename(file, path8.extname(file)).trim().toLowerCase();
|
|
8093
8864
|
}
|
|
8094
8865
|
function otherRowsLabel(proposal) {
|
|
8095
8866
|
const alternative = (proposal.lookups ?? []).find((lookup) => lookup.alternative)?.alternative;
|
|
@@ -8109,7 +8880,7 @@ function recipeWithRowsOf(proposal, rowsOf) {
|
|
|
8109
8880
|
function sourcesAsUploaded(uploaded, asUploaded) {
|
|
8110
8881
|
const chosen = [];
|
|
8111
8882
|
for (const name of asUploaded) {
|
|
8112
|
-
const wanted =
|
|
8883
|
+
const wanted = path8.basename(name).trim().toLowerCase();
|
|
8113
8884
|
const matches = uploaded.filter((source) => {
|
|
8114
8885
|
const fileName = source.fileName.trim().toLowerCase();
|
|
8115
8886
|
return fileName === wanted || labelOf(fileName) === labelOf(wanted);
|
|
@@ -8162,12 +8933,12 @@ function planLines(plan) {
|
|
|
8162
8933
|
}
|
|
8163
8934
|
function multipart(file) {
|
|
8164
8935
|
const formData = new FormData();
|
|
8165
|
-
formData.append("content", new Blob([
|
|
8936
|
+
formData.append("content", new Blob([fs10.readFileSync(file)]), path8.basename(file));
|
|
8166
8937
|
return formData;
|
|
8167
8938
|
}
|
|
8168
8939
|
async function uploadSeveral(api, analysisId, files, choices, human) {
|
|
8169
8940
|
for (const file of files) {
|
|
8170
|
-
if (!
|
|
8941
|
+
if (!fs10.existsSync(file)) {
|
|
8171
8942
|
throw new CliError(`File not found: ${file}`, { exitCode: EXIT_USAGE });
|
|
8172
8943
|
}
|
|
8173
8944
|
}
|
|
@@ -8176,7 +8947,7 @@ async function uploadSeveral(api, analysisId, files, choices, human) {
|
|
|
8176
8947
|
}
|
|
8177
8948
|
const uploaded = [];
|
|
8178
8949
|
for (const file of files) {
|
|
8179
|
-
uploaded.push(await withStatus(`Uploading ${
|
|
8950
|
+
uploaded.push(await withStatus(`Uploading ${path8.basename(file)}`, () => api.analysis.addSource(analysisId, multipart(file))));
|
|
8180
8951
|
}
|
|
8181
8952
|
for (const source of sourcesAsUploaded(uploaded, choices.asUploaded ?? [])) {
|
|
8182
8953
|
await api.analysis.updateSource(analysisId, source.sourceId, { asUploaded: true });
|
|
@@ -8226,7 +8997,7 @@ function openUrl(url) {
|
|
|
8226
8997
|
const args = process.platform === "win32" ? ["/c", "start", '""', url] : [url];
|
|
8227
8998
|
spawn2(cmd, args, { detached: true, stdio: "ignore" }).unref();
|
|
8228
8999
|
}
|
|
8229
|
-
function
|
|
9000
|
+
function getOutputFormat17(cmd) {
|
|
8230
9001
|
const config = loadConfig();
|
|
8231
9002
|
const globalOpts = cmd.optsWithGlobals();
|
|
8232
9003
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -8235,7 +9006,7 @@ function noInteractiveFlag(cmd) {
|
|
|
8235
9006
|
return cmd.optsWithGlobals().interactive === false;
|
|
8236
9007
|
}
|
|
8237
9008
|
function importContext(api, analysisId, cmd, machineReport) {
|
|
8238
|
-
const outputFormat =
|
|
9009
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8239
9010
|
const noInteractive = noInteractiveFlag(cmd);
|
|
8240
9011
|
return {
|
|
8241
9012
|
api,
|
|
@@ -8287,10 +9058,10 @@ function budgetHoursOf(hours) {
|
|
|
8287
9058
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
8288
9059
|
}
|
|
8289
9060
|
function multipartFromFile(file) {
|
|
8290
|
-
const buffer =
|
|
9061
|
+
const buffer = fs11.readFileSync(file);
|
|
8291
9062
|
const blob = new Blob([buffer]);
|
|
8292
9063
|
const formData = new FormData();
|
|
8293
|
-
formData.append("content", blob,
|
|
9064
|
+
formData.append("content", blob, path9.basename(file));
|
|
8294
9065
|
return formData;
|
|
8295
9066
|
}
|
|
8296
9067
|
function reportCommandError(error) {
|
|
@@ -8299,13 +9070,13 @@ function reportCommandError(error) {
|
|
|
8299
9070
|
}
|
|
8300
9071
|
async function runAnalysis(files, options, cmd) {
|
|
8301
9072
|
for (const candidate of files) {
|
|
8302
|
-
if (!
|
|
9073
|
+
if (!fs11.existsSync(candidate)) {
|
|
8303
9074
|
failure(`File not found: ${candidate}`);
|
|
8304
9075
|
process.exit(EXIT_FAILURE);
|
|
8305
9076
|
}
|
|
8306
9077
|
}
|
|
8307
9078
|
const file = files[0];
|
|
8308
|
-
const outputFormat =
|
|
9079
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8309
9080
|
const noInteractive = noInteractiveFlag(cmd);
|
|
8310
9081
|
const interactive = canPrompt(outputFormat, noInteractive);
|
|
8311
9082
|
const api = createApiClient();
|
|
@@ -8329,11 +9100,11 @@ async function runAnalysis(files, options, cmd) {
|
|
|
8329
9100
|
if (!interactive && !targetsGiven) {
|
|
8330
9101
|
usageError(
|
|
8331
9102
|
`Target columns are required, and ${whyNoPrompt(outputFormat, noInteractive)}.`,
|
|
8332
|
-
`Pass --targets <columns> or --preset <id>. The names are the column headers of ${files.length > 1 ? "the files" :
|
|
9103
|
+
`Pass --targets <columns> or --preset <id>. The names are the column headers of ${files.length > 1 ? "the files" : path9.basename(file)}.`
|
|
8333
9104
|
);
|
|
8334
9105
|
}
|
|
8335
9106
|
const prompter = createInquirerPrompter();
|
|
8336
|
-
const fallbackName =
|
|
9107
|
+
const fallbackName = path9.basename(file, path9.extname(file));
|
|
8337
9108
|
const creation = interactive ? await promptCreationFields(prompter, {
|
|
8338
9109
|
name: options.name,
|
|
8339
9110
|
description: options.description,
|
|
@@ -8357,7 +9128,7 @@ async function runAnalysis(files, options, cmd) {
|
|
|
8357
9128
|
};
|
|
8358
9129
|
const created = await withStatus(`Creating analysis "${creation.name}"`, () => api.analysis.create(request));
|
|
8359
9130
|
if (isDryRun()) {
|
|
8360
|
-
hint(`Dry run: nothing was created. A real run would upload ${
|
|
9131
|
+
hint(`Dry run: nothing was created. A real run would upload ${path9.basename(file)}, queue the analysis and follow it.`);
|
|
8361
9132
|
return;
|
|
8362
9133
|
}
|
|
8363
9134
|
detail(`analysisId: ${created.analysisId}`);
|
|
@@ -8408,9 +9179,9 @@ async function runAnalysis(files, options, cmd) {
|
|
|
8408
9179
|
}
|
|
8409
9180
|
function namedColumns(analysisId, columns, interactive, given) {
|
|
8410
9181
|
const names = columns.map((c) => c.name).filter((name) => name && name.length > 0);
|
|
8411
|
-
const read = (
|
|
9182
|
+
const read = (resolve2) => {
|
|
8412
9183
|
try {
|
|
8413
|
-
return
|
|
9184
|
+
return resolve2();
|
|
8414
9185
|
} catch (error) {
|
|
8415
9186
|
if (!(error instanceof CliError)) throw error;
|
|
8416
9187
|
if (!interactive) {
|
|
@@ -8474,11 +9245,12 @@ async function readDepthDefault(api, stored) {
|
|
|
8474
9245
|
}
|
|
8475
9246
|
async function readColumns(api, analysisId) {
|
|
8476
9247
|
for (let attempt = 0; attempt < COLUMN_READ_ATTEMPTS; attempt++) {
|
|
8477
|
-
if (attempt > 0) await new Promise((
|
|
9248
|
+
if (attempt > 0) await new Promise((resolve2) => setTimeout(resolve2, COLUMN_READ_INTERVAL_MS));
|
|
8478
9249
|
try {
|
|
8479
9250
|
const columns = await api.analysis.getColumns(analysisId);
|
|
8480
9251
|
if (columns.length > 0) return columns;
|
|
8481
|
-
} catch {
|
|
9252
|
+
} catch (error) {
|
|
9253
|
+
if (isAuthenticationFailure(error)) throw error;
|
|
8482
9254
|
}
|
|
8483
9255
|
}
|
|
8484
9256
|
warn("Could not read the column names from the uploaded file.");
|
|
@@ -8493,7 +9265,7 @@ async function readPresets(api) {
|
|
|
8493
9265
|
}
|
|
8494
9266
|
async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
|
|
8495
9267
|
const config = loadConfig();
|
|
8496
|
-
const outputFormat =
|
|
9268
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8497
9269
|
const human = outputFormat === "human";
|
|
8498
9270
|
const status = new Status();
|
|
8499
9271
|
const seenOutputs = /* @__PURE__ */ new Set();
|
|
@@ -8503,13 +9275,14 @@ async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
|
|
|
8503
9275
|
if (human) status.start();
|
|
8504
9276
|
try {
|
|
8505
9277
|
for (; ; ) {
|
|
8506
|
-
await new Promise((
|
|
9278
|
+
await new Promise((resolve2) => setTimeout(resolve2, POLL_INTERVAL_MS));
|
|
8507
9279
|
let run = null;
|
|
8508
9280
|
let absent = false;
|
|
8509
9281
|
try {
|
|
8510
9282
|
run = (await api.analysis.getRun(runId)).run;
|
|
8511
9283
|
absent = run === null;
|
|
8512
9284
|
} catch (error) {
|
|
9285
|
+
if (isAuthenticationFailure(error)) throw error;
|
|
8513
9286
|
absent = error instanceof ApiError && error.status === 404;
|
|
8514
9287
|
}
|
|
8515
9288
|
if (!run) {
|
|
@@ -8537,7 +9310,8 @@ async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
|
|
|
8537
9310
|
}
|
|
8538
9311
|
}
|
|
8539
9312
|
}
|
|
8540
|
-
} catch {
|
|
9313
|
+
} catch (error) {
|
|
9314
|
+
if (isAuthenticationFailure(error)) throw error;
|
|
8541
9315
|
}
|
|
8542
9316
|
if (isTerminalState(run.state)) {
|
|
8543
9317
|
status.stop();
|
|
@@ -8615,7 +9389,7 @@ async function printNotebookLink(api, config, analysisId) {
|
|
|
8615
9389
|
}
|
|
8616
9390
|
}
|
|
8617
9391
|
async function listAnalyses(limit, cmd) {
|
|
8618
|
-
const outputFormat =
|
|
9392
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8619
9393
|
const api = createApiClient();
|
|
8620
9394
|
const analyses = await api.analysis.getRecent(limit);
|
|
8621
9395
|
format(analyses.map((a) => ({
|
|
@@ -8645,7 +9419,7 @@ async function listAnalyses(limit, cmd) {
|
|
|
8645
9419
|
});
|
|
8646
9420
|
}
|
|
8647
9421
|
async function getAnalysisDetails(analysisId, options, cmd) {
|
|
8648
|
-
const outputFormat =
|
|
9422
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8649
9423
|
const api = createApiClient();
|
|
8650
9424
|
const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
|
|
8651
9425
|
if (!result.analysis) {
|
|
@@ -8713,7 +9487,7 @@ async function rerunAnalysis(analysisId, cmd) {
|
|
|
8713
9487
|
const analysis = found.analysis;
|
|
8714
9488
|
const missing = missingRunFields(analysis);
|
|
8715
9489
|
if (missing.length > 0) {
|
|
8716
|
-
const outputFormat =
|
|
9490
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8717
9491
|
const noInteractive = noInteractiveFlag(cmd);
|
|
8718
9492
|
if (!canPrompt(outputFormat, noInteractive)) {
|
|
8719
9493
|
const { message, suggestion } = explainMissingRunFields(
|
|
@@ -8774,7 +9548,7 @@ function typedColumns(given) {
|
|
|
8774
9548
|
return entries === void 0 ? null : resolveColumnArguments(entries, []);
|
|
8775
9549
|
}
|
|
8776
9550
|
async function createAnalysis(options, cmd) {
|
|
8777
|
-
const outputFormat =
|
|
9551
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8778
9552
|
const api = createApiClient();
|
|
8779
9553
|
const visibility = parseVisibility(options.visibility);
|
|
8780
9554
|
const request = {
|
|
@@ -8804,7 +9578,7 @@ async function deleteAnalysis(analysisId) {
|
|
|
8804
9578
|
success(`Deleted analysis ${analysisId}.`);
|
|
8805
9579
|
}
|
|
8806
9580
|
async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
|
|
8807
|
-
const outputFormat =
|
|
9581
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8808
9582
|
const api = createApiClient();
|
|
8809
9583
|
const updated = await handler(api, analysisId, value);
|
|
8810
9584
|
if (isDryRun()) {
|
|
@@ -8844,19 +9618,19 @@ function stackChoices(options, files) {
|
|
|
8844
9618
|
}
|
|
8845
9619
|
async function uploadOne(api, analysisId, file, asUploaded, human) {
|
|
8846
9620
|
const uploaded = await withStatus(
|
|
8847
|
-
`Uploading ${
|
|
9621
|
+
`Uploading ${path9.basename(file)}`,
|
|
8848
9622
|
() => api.analysis.uploadDataMultipart(analysisId, multipartFromFile(file))
|
|
8849
9623
|
);
|
|
8850
9624
|
if (isDryRun() || uploaded.dataImport) return uploaded;
|
|
8851
9625
|
if (asUploaded.length > 0) {
|
|
8852
|
-
sourcesAsUploaded([{ fileName:
|
|
9626
|
+
sourcesAsUploaded([{ fileName: path9.basename(file) }], asUploaded);
|
|
8853
9627
|
return uploaded;
|
|
8854
9628
|
}
|
|
8855
9629
|
return await reshapeSingle(api, analysisId, human) ?? uploaded;
|
|
8856
9630
|
}
|
|
8857
9631
|
async function uploadData(analysisId, files, options, cmd) {
|
|
8858
9632
|
const api = createApiClient();
|
|
8859
|
-
const outputFormat =
|
|
9633
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8860
9634
|
const ctx = importContext(api, analysisId, cmd, "none");
|
|
8861
9635
|
const file = files[0];
|
|
8862
9636
|
if (files.length > 1) {
|
|
@@ -8888,7 +9662,7 @@ async function uploadData(analysisId, files, options, cmd) {
|
|
|
8888
9662
|
`For example: diafunc analyze upload ${analysisId} data.csv`
|
|
8889
9663
|
);
|
|
8890
9664
|
}
|
|
8891
|
-
if (!
|
|
9665
|
+
if (!fs11.existsSync(file)) {
|
|
8892
9666
|
throw new CliError(`File not found: ${file}`, { exitCode: EXIT_USAGE });
|
|
8893
9667
|
}
|
|
8894
9668
|
}
|
|
@@ -8906,7 +9680,7 @@ async function uploadData(analysisId, files, options, cmd) {
|
|
|
8906
9680
|
}
|
|
8907
9681
|
}
|
|
8908
9682
|
async function stopDataImport(analysisId, cmd) {
|
|
8909
|
-
const outputFormat =
|
|
9683
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8910
9684
|
const api = createApiClient();
|
|
8911
9685
|
const stopped = await withStatus("Stopping the data import", () => stopImport(api, analysisId));
|
|
8912
9686
|
if (isDryRun()) {
|
|
@@ -8929,7 +9703,7 @@ async function stopDataImport(analysisId, cmd) {
|
|
|
8929
9703
|
warn(stopped.dataImport.message);
|
|
8930
9704
|
}
|
|
8931
9705
|
async function listColumns(analysisId, cmd) {
|
|
8932
|
-
const outputFormat =
|
|
9706
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8933
9707
|
const api = createApiClient();
|
|
8934
9708
|
const columns = await api.analysis.getColumns(analysisId);
|
|
8935
9709
|
if (columns.length === 0) {
|
|
@@ -8940,7 +9714,7 @@ async function listColumns(analysisId, cmd) {
|
|
|
8940
9714
|
format(columns, { format: outputFormat, columns: ["name", "valueType"] });
|
|
8941
9715
|
}
|
|
8942
9716
|
async function listRuns(analysisId, count, cmd) {
|
|
8943
|
-
const outputFormat =
|
|
9717
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8944
9718
|
const api = createApiClient();
|
|
8945
9719
|
const runs = await api.analysis.getRunsForAnalysis(analysisId, count);
|
|
8946
9720
|
format(runs.map((r) => ({
|
|
@@ -8963,7 +9737,7 @@ async function listRuns(analysisId, count, cmd) {
|
|
|
8963
9737
|
});
|
|
8964
9738
|
}
|
|
8965
9739
|
async function cancelRun(runId, cmd) {
|
|
8966
|
-
const outputFormat =
|
|
9740
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8967
9741
|
const api = createApiClient();
|
|
8968
9742
|
const run = await api.analysis.cancelRun(runId);
|
|
8969
9743
|
if (outputFormat === "human") {
|
|
@@ -8977,7 +9751,7 @@ async function cancelRun(runId, cmd) {
|
|
|
8977
9751
|
}
|
|
8978
9752
|
}
|
|
8979
9753
|
async function listPresets(cmd) {
|
|
8980
|
-
const outputFormat =
|
|
9754
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
8981
9755
|
const api = createApiClient();
|
|
8982
9756
|
const presets = await api.analysis.getPresets();
|
|
8983
9757
|
format(presets.map((p) => ({
|
|
@@ -9002,7 +9776,7 @@ async function listPresets(cmd) {
|
|
|
9002
9776
|
});
|
|
9003
9777
|
}
|
|
9004
9778
|
async function getPreset(presetId, cmd) {
|
|
9005
|
-
const outputFormat =
|
|
9779
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9006
9780
|
const api = createApiClient();
|
|
9007
9781
|
const opt = await api.analysis.getPreset(presetId);
|
|
9008
9782
|
if (!opt.preset) {
|
|
@@ -9012,7 +9786,7 @@ async function getPreset(presetId, cmd) {
|
|
|
9012
9786
|
format(opt.preset, { format: outputFormat });
|
|
9013
9787
|
}
|
|
9014
9788
|
async function savePreset(options, cmd) {
|
|
9015
|
-
const outputFormat =
|
|
9789
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9016
9790
|
const api = createApiClient();
|
|
9017
9791
|
const preset = {
|
|
9018
9792
|
presetId: options.id ?? null,
|
|
@@ -9067,7 +9841,7 @@ function triggerChanges(options) {
|
|
|
9067
9841
|
};
|
|
9068
9842
|
}
|
|
9069
9843
|
async function listTriggers(analysisId, cmd) {
|
|
9070
|
-
const outputFormat =
|
|
9844
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9071
9845
|
const api = createApiClient();
|
|
9072
9846
|
const triggers = await api.analysis.listTriggers(analysisId);
|
|
9073
9847
|
format(triggers.map(triggerRow), {
|
|
@@ -9084,7 +9858,7 @@ async function listTriggers(analysisId, cmd) {
|
|
|
9084
9858
|
});
|
|
9085
9859
|
}
|
|
9086
9860
|
async function createTrigger(analysisId, kind, schedule, cmd, refreshFirst = false) {
|
|
9087
|
-
const outputFormat =
|
|
9861
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9088
9862
|
const upper = kind.toUpperCase();
|
|
9089
9863
|
if (upper !== "ONCE" && upper !== "CRON") {
|
|
9090
9864
|
failure(`Invalid kind "${kind}". Use ONCE or CRON.`);
|
|
@@ -9104,7 +9878,7 @@ async function deleteTrigger(triggerId) {
|
|
|
9104
9878
|
success(`Deleted trigger ${triggerId}.`);
|
|
9105
9879
|
}
|
|
9106
9880
|
async function updateTriggerCmd(triggerId, options, cmd) {
|
|
9107
|
-
const outputFormat =
|
|
9881
|
+
const outputFormat = getOutputFormat17(cmd);
|
|
9108
9882
|
const changes = triggerChanges(options);
|
|
9109
9883
|
const api = createApiClient();
|
|
9110
9884
|
const trigger = await api.analysis.updateTrigger(triggerId, changes);
|
|
@@ -9422,7 +10196,7 @@ function registerAnalyzeCommand(program) {
|
|
|
9422
10196
|
// src/commands/public/index.ts
|
|
9423
10197
|
var MIN_LIMIT = 1;
|
|
9424
10198
|
var MAX_LIMIT = 500;
|
|
9425
|
-
function
|
|
10199
|
+
function getOutputFormat18(cmd) {
|
|
9426
10200
|
const config = loadConfig();
|
|
9427
10201
|
const globalOpts = cmd.optsWithGlobals();
|
|
9428
10202
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -9474,7 +10248,7 @@ async function readPublicAnalyses(analysis, options) {
|
|
|
9474
10248
|
}
|
|
9475
10249
|
}
|
|
9476
10250
|
async function listPublicAnalyses(options, cmd) {
|
|
9477
|
-
const outputFormat =
|
|
10251
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
9478
10252
|
const limit = parseLimit(options.limit);
|
|
9479
10253
|
const changedSince = options.changedSince === void 0 ? void 0 : parseChangedSince(options.changedSince);
|
|
9480
10254
|
const api = createApiClient();
|
|
@@ -9516,7 +10290,7 @@ function newestRunRecord(run) {
|
|
|
9516
10290
|
};
|
|
9517
10291
|
}
|
|
9518
10292
|
async function showPublicAnalysis(analysisId, cmd) {
|
|
9519
|
-
const outputFormat =
|
|
10293
|
+
const outputFormat = getOutputFormat18(cmd);
|
|
9520
10294
|
const api = createApiClient();
|
|
9521
10295
|
const result = await api.analysis.get(analysisId);
|
|
9522
10296
|
if (!result?.analysis) {
|
|
@@ -9585,8 +10359,8 @@ Examples:
|
|
|
9585
10359
|
}
|
|
9586
10360
|
|
|
9587
10361
|
// src/commands/data-sources/index.ts
|
|
9588
|
-
import
|
|
9589
|
-
function
|
|
10362
|
+
import chalk29 from "chalk";
|
|
10363
|
+
function getOutputFormat19(cmd) {
|
|
9590
10364
|
const config = loadConfig();
|
|
9591
10365
|
const globalOpts = cmd.optsWithGlobals();
|
|
9592
10366
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -9686,7 +10460,7 @@ function resolveProjectId(cmd) {
|
|
|
9686
10460
|
return resolved;
|
|
9687
10461
|
}
|
|
9688
10462
|
async function listDataSources(projectId, cmd) {
|
|
9689
|
-
const outputFormat =
|
|
10463
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9690
10464
|
const api = createApiClient();
|
|
9691
10465
|
const sources = await api.storage.listDataSources(projectId);
|
|
9692
10466
|
if (outputFormat === "human" && sources.length === 0) {
|
|
@@ -9707,13 +10481,13 @@ async function listDataSources(projectId, cmd) {
|
|
|
9707
10481
|
});
|
|
9708
10482
|
}
|
|
9709
10483
|
async function getDataSource(id, cmd) {
|
|
9710
|
-
const outputFormat =
|
|
10484
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9711
10485
|
const api = createApiClient();
|
|
9712
10486
|
const ds = await api.storage.getDataSource(id);
|
|
9713
10487
|
format(ds, { format: outputFormat });
|
|
9714
10488
|
}
|
|
9715
10489
|
async function showDashboard(projectId, cmd) {
|
|
9716
|
-
const outputFormat =
|
|
10490
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9717
10491
|
const api = createApiClient();
|
|
9718
10492
|
const dashboard = await api.storage.getDataSourceDashboard(projectId);
|
|
9719
10493
|
if (outputFormat !== "human") {
|
|
@@ -9721,7 +10495,7 @@ async function showDashboard(projectId, cmd) {
|
|
|
9721
10495
|
return;
|
|
9722
10496
|
}
|
|
9723
10497
|
const r = dashboard.rollup;
|
|
9724
|
-
let line =
|
|
10498
|
+
let line = chalk29.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
|
|
9725
10499
|
if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
|
|
9726
10500
|
console.log(line);
|
|
9727
10501
|
if (dashboard.sources.length === 0) {
|
|
@@ -9782,14 +10556,14 @@ async function createForAnalysis(api, options, human) {
|
|
|
9782
10556
|
if (human) {
|
|
9783
10557
|
success(`Added ${source.fileName} to analysis ${analysisId} from data source ${source.dataSourceId ?? ""}`.trimEnd());
|
|
9784
10558
|
for (const line of planLines(build.plan)) {
|
|
9785
|
-
console.log(line.caution ?
|
|
10559
|
+
console.log(line.caution ? chalk29.yellow(` ${line.text}`) : chalk29.dim(` ${line.text}`));
|
|
9786
10560
|
}
|
|
9787
|
-
console.log(
|
|
10561
|
+
console.log(chalk29.dim(options.scheduleCron ? ` Refreshes ${humanizeCron(options.scheduleCron)}; each refresh replaces the file and builds the data again.` : " No schedule of its own: refresh it with `data-sources refresh`, or let a trigger fetch it before a run (`analyze triggers create --refresh-first`)."));
|
|
9788
10562
|
}
|
|
9789
10563
|
return { source, build };
|
|
9790
10564
|
}
|
|
9791
10565
|
async function createDataSource(options, cmd) {
|
|
9792
|
-
const outputFormat =
|
|
10566
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9793
10567
|
const target = createTarget(options);
|
|
9794
10568
|
const api = createApiClient();
|
|
9795
10569
|
if (target === "analysis") {
|
|
@@ -9812,14 +10586,14 @@ async function createDataSource(options, cmd) {
|
|
|
9812
10586
|
const ds = await api.storage.createDataSource(request);
|
|
9813
10587
|
if (outputFormat === "human") {
|
|
9814
10588
|
success(`Created data source ${ds.id}`);
|
|
9815
|
-
console.log(
|
|
9816
|
-
if (ds.lastRunError) console.log(
|
|
10589
|
+
console.log(chalk29.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
|
|
10590
|
+
if (ds.lastRunError) console.log(chalk29.dim(` Error: ${ds.lastRunError}`));
|
|
9817
10591
|
} else {
|
|
9818
10592
|
format(ds, { format: outputFormat });
|
|
9819
10593
|
}
|
|
9820
10594
|
}
|
|
9821
10595
|
async function updateDataSource(id, options, cmd) {
|
|
9822
|
-
const outputFormat =
|
|
10596
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9823
10597
|
if (options.name === void 0 && options.type === void 0 && (!options.config || options.config.length === 0) && options.scheduleCron === void 0 && !options.clearSchedule) {
|
|
9824
10598
|
throw new Error("Provide at least one of --name, --type, --config, --schedule-cron, or --clear-schedule.");
|
|
9825
10599
|
}
|
|
@@ -9854,18 +10628,18 @@ async function deleteDataSource(id) {
|
|
|
9854
10628
|
success(`Deleted data source ${id}`);
|
|
9855
10629
|
}
|
|
9856
10630
|
async function refreshDataSource(id, cmd) {
|
|
9857
|
-
const outputFormat =
|
|
10631
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9858
10632
|
const api = createApiClient();
|
|
9859
10633
|
const run = await api.storage.refreshDataSource(id);
|
|
9860
10634
|
if (outputFormat === "human") {
|
|
9861
10635
|
success(`Refresh queued: run ${run.runId}, status ${run.status}.`);
|
|
9862
|
-
if (run.errorMessage) console.log(
|
|
10636
|
+
if (run.errorMessage) console.log(chalk29.red(` Error: ${run.errorMessage}`));
|
|
9863
10637
|
} else {
|
|
9864
10638
|
format(run, { format: outputFormat });
|
|
9865
10639
|
}
|
|
9866
10640
|
}
|
|
9867
10641
|
async function listRuns2(id, limit, cmd) {
|
|
9868
|
-
const outputFormat =
|
|
10642
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9869
10643
|
const api = createApiClient();
|
|
9870
10644
|
const runs = await api.storage.listDataSourceRuns(id, limit);
|
|
9871
10645
|
if (outputFormat === "human" && runs.length === 0) {
|
|
@@ -9887,13 +10661,13 @@ async function listRuns2(id, limit, cmd) {
|
|
|
9887
10661
|
});
|
|
9888
10662
|
}
|
|
9889
10663
|
async function getRun(id, runId, cmd) {
|
|
9890
|
-
const outputFormat =
|
|
10664
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9891
10665
|
const api = createApiClient();
|
|
9892
10666
|
const run = await api.storage.getDataSourceRun(id, runId);
|
|
9893
10667
|
format(run, { format: outputFormat });
|
|
9894
10668
|
}
|
|
9895
10669
|
async function listConnectorTypes(cmd) {
|
|
9896
|
-
const outputFormat =
|
|
10670
|
+
const outputFormat = getOutputFormat19(cmd);
|
|
9897
10671
|
const api = createApiClient();
|
|
9898
10672
|
const types = await api.storage.listDataSourceConnectorTypes();
|
|
9899
10673
|
if (outputFormat === "human") {
|
|
@@ -9986,8 +10760,8 @@ Examples:
|
|
|
9986
10760
|
}
|
|
9987
10761
|
|
|
9988
10762
|
// src/commands/table-exporters/index.ts
|
|
9989
|
-
import
|
|
9990
|
-
function
|
|
10763
|
+
import chalk30 from "chalk";
|
|
10764
|
+
function getOutputFormat20(cmd) {
|
|
9991
10765
|
const config = loadConfig();
|
|
9992
10766
|
const globalOpts = cmd.optsWithGlobals();
|
|
9993
10767
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -9996,7 +10770,7 @@ function registerTableExportersCommands(program) {
|
|
|
9996
10770
|
const exporters = program.command("table-exporters").description("Manage user-defined exporters (UDE); admin only");
|
|
9997
10771
|
exporters.command("list").description("List all registered user-defined exporters").action(async (_options, cmd) => {
|
|
9998
10772
|
try {
|
|
9999
|
-
const outputFormat =
|
|
10773
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
10000
10774
|
const api = createApiClient();
|
|
10001
10775
|
const list = await api.storage.listUserDefinedExporters();
|
|
10002
10776
|
if (outputFormat === "json") {
|
|
@@ -10017,14 +10791,14 @@ function registerTableExportersCommands(program) {
|
|
|
10017
10791
|
format: outputFormat,
|
|
10018
10792
|
columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
|
|
10019
10793
|
});
|
|
10020
|
-
console.log(
|
|
10794
|
+
console.log(chalk30.dim(`${list.length} exporter(s)`));
|
|
10021
10795
|
} catch (error) {
|
|
10022
10796
|
handleError(error);
|
|
10023
10797
|
}
|
|
10024
10798
|
});
|
|
10025
10799
|
exporters.command("get").description("Show a single user-defined exporter by id").argument("<id>", "Exporter id").action(async (id, _options, cmd) => {
|
|
10026
10800
|
try {
|
|
10027
|
-
const outputFormat =
|
|
10801
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
10028
10802
|
const api = createApiClient();
|
|
10029
10803
|
const list = await api.storage.listUserDefinedExporters();
|
|
10030
10804
|
const exporter = list.find((e) => e.id === id);
|
|
@@ -10039,7 +10813,7 @@ function registerTableExportersCommands(program) {
|
|
|
10039
10813
|
});
|
|
10040
10814
|
exporters.command("create").description("Register a new user-defined exporter").requiredOption("--name <name>", 'Display name (e.g. "Acme machine instrument export")').requiredOption("--format <token>", 'Format token used in the dispatch URL (e.g. "acme")').requiredOption("--function-project <id>", "Function entity's project id").requiredOption("--function-entity <id>", "Function entity id").option("--description <text>", "Free-form description").option("--extension <ext>", 'Filename extension (must start with ".")').option("--mime-type <mime>", "MIME type the function produces").option("--function-project-branch <branch>", "Function project branch", "main").option("--function-entity-branch <branch>", "Function entity branch", "main").option("--priority <n>", "Dispatch priority (default 50; > 200 overrides built-ins)", "50").action(async (options, cmd) => {
|
|
10041
10815
|
try {
|
|
10042
|
-
const outputFormat =
|
|
10816
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
10043
10817
|
const api = createApiClient();
|
|
10044
10818
|
const payload = {
|
|
10045
10819
|
name: options.name,
|
|
@@ -10075,9 +10849,9 @@ function registerTableExportersCommands(program) {
|
|
|
10075
10849
|
}
|
|
10076
10850
|
|
|
10077
10851
|
// src/commands/skeleton/index.ts
|
|
10078
|
-
import
|
|
10079
|
-
import * as
|
|
10080
|
-
function
|
|
10852
|
+
import chalk31 from "chalk";
|
|
10853
|
+
import * as fs12 from "fs";
|
|
10854
|
+
function getOutputFormat21(cmd) {
|
|
10081
10855
|
const config = loadConfig();
|
|
10082
10856
|
const globalOpts = cmd.optsWithGlobals();
|
|
10083
10857
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -10100,10 +10874,10 @@ function resolveTemplate(raw) {
|
|
|
10100
10874
|
if (!file) {
|
|
10101
10875
|
throw new Error("--template @ requires a filename after the @, e.g. --template @template.txt");
|
|
10102
10876
|
}
|
|
10103
|
-
if (!
|
|
10877
|
+
if (!fs12.existsSync(file)) {
|
|
10104
10878
|
throw new Error(`Template file not found: ${file}`);
|
|
10105
10879
|
}
|
|
10106
|
-
return
|
|
10880
|
+
return fs12.readFileSync(file, "utf-8").trim();
|
|
10107
10881
|
}
|
|
10108
10882
|
return raw;
|
|
10109
10883
|
}
|
|
@@ -10126,7 +10900,7 @@ function skeletonTableRow(s) {
|
|
|
10126
10900
|
};
|
|
10127
10901
|
}
|
|
10128
10902
|
async function createSkeleton(options, cmd) {
|
|
10129
|
-
const outputFormat =
|
|
10903
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
10130
10904
|
const projectId = resolveProjectId2(cmd);
|
|
10131
10905
|
const template = resolveTemplate(options.template);
|
|
10132
10906
|
const weight = parseWeight(options.weight);
|
|
@@ -10142,16 +10916,16 @@ async function createSkeleton(options, cmd) {
|
|
|
10142
10916
|
const skeleton = await api.storage.createSkeleton(request);
|
|
10143
10917
|
if (outputFormat === "human") {
|
|
10144
10918
|
success(`Created skeleton ${skeleton.id}`);
|
|
10145
|
-
console.log(
|
|
10146
|
-
console.log(
|
|
10147
|
-
console.log(
|
|
10148
|
-
console.log(
|
|
10919
|
+
console.log(chalk31.dim(` name: ${skeleton.name}`));
|
|
10920
|
+
console.log(chalk31.dim(` template: ${skeleton.template}`));
|
|
10921
|
+
console.log(chalk31.dim(` paramCount: ${skeleton.paramCount}`));
|
|
10922
|
+
console.log(chalk31.dim(` weight: ${skeleton.weight}`));
|
|
10149
10923
|
} else {
|
|
10150
10924
|
format(skeleton, { format: outputFormat });
|
|
10151
10925
|
}
|
|
10152
10926
|
}
|
|
10153
10927
|
async function listSkeletons(cmd) {
|
|
10154
|
-
const outputFormat =
|
|
10928
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
10155
10929
|
const projectId = resolveProjectId2(cmd);
|
|
10156
10930
|
const api = createApiClient();
|
|
10157
10931
|
const skeletons = await api.storage.listSkeletons(projectId);
|
|
@@ -10165,13 +10939,13 @@ async function listSkeletons(cmd) {
|
|
|
10165
10939
|
});
|
|
10166
10940
|
}
|
|
10167
10941
|
async function getSkeleton(id, cmd) {
|
|
10168
|
-
const outputFormat =
|
|
10942
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
10169
10943
|
const api = createApiClient();
|
|
10170
10944
|
const skeleton = await api.storage.getSkeleton(id);
|
|
10171
10945
|
format(skeleton, { format: outputFormat });
|
|
10172
10946
|
}
|
|
10173
10947
|
async function updateSkeleton(id, options, cmd) {
|
|
10174
|
-
const outputFormat =
|
|
10948
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
10175
10949
|
if (options.name === void 0 && options.template === void 0 && options.weight === void 0) {
|
|
10176
10950
|
throw new Error("Provide at least one of --name, --template, --weight.");
|
|
10177
10951
|
}
|
|
@@ -10184,10 +10958,10 @@ async function updateSkeleton(id, options, cmd) {
|
|
|
10184
10958
|
const skeleton = await api.storage.updateSkeleton(id, request);
|
|
10185
10959
|
if (outputFormat === "human") {
|
|
10186
10960
|
success(`Updated skeleton ${skeleton.id}`);
|
|
10187
|
-
console.log(
|
|
10188
|
-
console.log(
|
|
10189
|
-
console.log(
|
|
10190
|
-
console.log(
|
|
10961
|
+
console.log(chalk31.dim(` name: ${skeleton.name}`));
|
|
10962
|
+
console.log(chalk31.dim(` template: ${skeleton.template}`));
|
|
10963
|
+
console.log(chalk31.dim(` paramCount: ${skeleton.paramCount}`));
|
|
10964
|
+
console.log(chalk31.dim(` weight: ${skeleton.weight}`));
|
|
10191
10965
|
} else {
|
|
10192
10966
|
format(skeleton, { format: outputFormat });
|
|
10193
10967
|
}
|
|
@@ -10272,17 +11046,21 @@ _diafunc_completions() {
|
|
|
10272
11046
|
fi
|
|
10273
11047
|
;;
|
|
10274
11048
|
project)
|
|
10275
|
-
subcommands="list get create delete lock unlock members"
|
|
11049
|
+
subcommands="list get create delete lock unlock members tags"
|
|
10276
11050
|
if [[ "\${COMP_WORDS[2]}" == "members" ]]; then
|
|
10277
11051
|
COMPREPLY=($(compgen -W "list invite join remove" -- "\${cur}"))
|
|
11052
|
+
elif [[ "\${COMP_WORDS[2]}" == "tags" ]]; then
|
|
11053
|
+
COMPREPLY=($(compgen -W "get add remove set" -- "\${cur}"))
|
|
10278
11054
|
else
|
|
10279
11055
|
COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}"))
|
|
10280
11056
|
fi
|
|
10281
11057
|
;;
|
|
10282
11058
|
entity)
|
|
10283
|
-
subcommands="list get delete history revert rename content"
|
|
11059
|
+
subcommands="list get delete history revert rename content tags"
|
|
10284
11060
|
if [[ "\${COMP_WORDS[2]}" == "content" ]]; then
|
|
10285
11061
|
COMPREPLY=($(compgen -W "get set delete" -- "\${cur}"))
|
|
11062
|
+
elif [[ "\${COMP_WORDS[2]}" == "tags" ]]; then
|
|
11063
|
+
COMPREPLY=($(compgen -W "get add remove set" -- "\${cur}"))
|
|
10286
11064
|
else
|
|
10287
11065
|
COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}"))
|
|
10288
11066
|
fi
|
|
@@ -10333,11 +11111,12 @@ _diafunc_completions() {
|
|
|
10333
11111
|
esac
|
|
10334
11112
|
;;
|
|
10335
11113
|
admin)
|
|
10336
|
-
subcommands="users subscription settings backup"
|
|
11114
|
+
subcommands="users subscription settings backup curated-tags"
|
|
10337
11115
|
case "\${COMP_WORDS[2]}" in
|
|
10338
11116
|
users) COMPREPLY=($(compgen -W "list get" -- "\${cur}")) ;;
|
|
10339
11117
|
settings) COMPREPLY=($(compgen -W "get set" -- "\${cur}")) ;;
|
|
10340
11118
|
backup) COMPREPLY=($(compgen -W "create-full project" -- "\${cur}")) ;;
|
|
11119
|
+
curated-tags) COMPREPLY=($(compgen -W "list create update delete" -- "\${cur}")) ;;
|
|
10341
11120
|
*) COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}")) ;;
|
|
10342
11121
|
esac
|
|
10343
11122
|
;;
|
|
@@ -10411,12 +11190,12 @@ _diafunc() {
|
|
|
10411
11190
|
|
|
10412
11191
|
_diafunc_auth() { _values 'subcommand' login logout status token; }
|
|
10413
11192
|
_diafunc_config() { _values 'subcommand' set get list profile; }
|
|
10414
|
-
_diafunc_project() { _values 'subcommand' list get create delete lock unlock members; }
|
|
11193
|
+
_diafunc_project() { _values 'subcommand' list get create delete lock unlock members tags; }
|
|
10415
11194
|
_diafunc_team() { _values 'subcommand' list get use usage create portal cancel leave members invitations seats packs transfer; }
|
|
10416
|
-
_diafunc_entity() { _values 'subcommand' list get delete history revert rename content; }
|
|
11195
|
+
_diafunc_entity() { _values 'subcommand' list get delete history revert rename content tags; }
|
|
10417
11196
|
_diafunc_table() { _values 'subcommand' view import export row column cell clear; }
|
|
10418
11197
|
_diafunc_chat() { _values 'subcommand' repl send stream upload session usage; }
|
|
10419
|
-
_diafunc_admin() { _values 'subcommand' users subscription settings backup; }
|
|
11198
|
+
_diafunc_admin() { _values 'subcommand' users subscription settings backup curated-tags; }
|
|
10420
11199
|
|
|
10421
11200
|
_diafunc "$@"`;
|
|
10422
11201
|
var FISH_COMPLETION = `# Fish completions for diafunc
|
|
@@ -10459,10 +11238,10 @@ complete -c diafunc -n "__fish_seen_subcommand_from config; and not __fish_seen_
|
|
|
10459
11238
|
complete -c diafunc -n "__fish_seen_subcommand_from profile; and not __fish_seen_subcommand_from add use list remove" -a "add use list remove"
|
|
10460
11239
|
|
|
10461
11240
|
# project
|
|
10462
|
-
complete -c diafunc -n "__fish_seen_subcommand_from project; and not __fish_seen_subcommand_from list get create delete lock unlock members" -a "list get create delete lock unlock members"
|
|
11241
|
+
complete -c diafunc -n "__fish_seen_subcommand_from project; and not __fish_seen_subcommand_from list get create delete lock unlock members tags" -a "list get create delete lock unlock members tags"
|
|
10463
11242
|
|
|
10464
11243
|
# entity
|
|
10465
|
-
complete -c diafunc -n "__fish_seen_subcommand_from entity; and not __fish_seen_subcommand_from list get delete history revert rename content" -a "list get delete history revert rename content"
|
|
11244
|
+
complete -c diafunc -n "__fish_seen_subcommand_from entity; and not __fish_seen_subcommand_from list get delete history revert rename content tags" -a "list get delete history revert rename content tags"
|
|
10466
11245
|
|
|
10467
11246
|
# branch
|
|
10468
11247
|
complete -c diafunc -n "__fish_seen_subcommand_from branch; and not __fish_seen_subcommand_from list create delete merge fork" -a "list create delete merge fork"
|
|
@@ -10483,7 +11262,7 @@ complete -c diafunc -n "__fish_seen_subcommand_from seats packs; and not __fish_
|
|
|
10483
11262
|
complete -c diafunc -n "__fish_seen_subcommand_from transfer; and not __fish_seen_subcommand_from start status accept cancel" -a "start status accept cancel"
|
|
10484
11263
|
|
|
10485
11264
|
# admin
|
|
10486
|
-
complete -c diafunc -n "__fish_seen_subcommand_from admin; and not __fish_seen_subcommand_from users subscription settings backup" -a "users subscription settings backup"
|
|
11265
|
+
complete -c diafunc -n "__fish_seen_subcommand_from admin; and not __fish_seen_subcommand_from users subscription settings backup curated-tags" -a "users subscription settings backup curated-tags"
|
|
10487
11266
|
|
|
10488
11267
|
# analyze accepts files
|
|
10489
11268
|
complete -c diafunc -n "__fish_seen_subcommand_from analyze" -F`;
|
|
@@ -10507,7 +11286,7 @@ function registerCompletionCommand(program) {
|
|
|
10507
11286
|
}
|
|
10508
11287
|
|
|
10509
11288
|
// src/commands/whoami/index.ts
|
|
10510
|
-
import
|
|
11289
|
+
import chalk32 from "chalk";
|
|
10511
11290
|
function registerWhoamiCommand(program) {
|
|
10512
11291
|
program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
|
|
10513
11292
|
try {
|
|
@@ -10517,8 +11296,8 @@ function registerWhoamiCommand(program) {
|
|
|
10517
11296
|
const api = createApiClient();
|
|
10518
11297
|
const user = await api.admin.getMyUser();
|
|
10519
11298
|
if (outputFormat === "human") {
|
|
10520
|
-
console.log(
|
|
10521
|
-
console.log(
|
|
11299
|
+
console.log(chalk32.bold(user.name) + chalk32.dim(` <${user.email}>`));
|
|
11300
|
+
console.log(chalk32.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
|
|
10522
11301
|
} else {
|
|
10523
11302
|
format(user, { format: outputFormat });
|
|
10524
11303
|
}
|
|
@@ -10529,8 +11308,8 @@ function registerWhoamiCommand(program) {
|
|
|
10529
11308
|
}
|
|
10530
11309
|
|
|
10531
11310
|
// src/commands/utilization/index.ts
|
|
10532
|
-
import
|
|
10533
|
-
function
|
|
11311
|
+
import chalk33 from "chalk";
|
|
11312
|
+
function getOutputFormat22(cmd) {
|
|
10534
11313
|
const config = loadConfig();
|
|
10535
11314
|
const globalOpts = cmd.optsWithGlobals();
|
|
10536
11315
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -10546,19 +11325,19 @@ function windowLabel(u) {
|
|
|
10546
11325
|
}
|
|
10547
11326
|
function printUtilizationHuman(u, label) {
|
|
10548
11327
|
const when2 = windowLabel(u);
|
|
10549
|
-
console.log(label ?
|
|
11328
|
+
console.log(label ? chalk33.bold(label) + " " + chalk33.dim(when2) : chalk33.bold(when2));
|
|
10550
11329
|
if (u.types.length === 0) {
|
|
10551
|
-
console.log(
|
|
11330
|
+
console.log(chalk33.dim(" (no usage)"));
|
|
10552
11331
|
return;
|
|
10553
11332
|
}
|
|
10554
11333
|
const types = [...u.types].sort((a, b) => b.credits - a.credits);
|
|
10555
11334
|
const width = Math.max(...types.map((t) => t.type.length));
|
|
10556
11335
|
for (const t of types) {
|
|
10557
|
-
const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${
|
|
10558
|
-
console.log(t.credits === 0 ?
|
|
11336
|
+
const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${chalk33.dim("credits")} ${t.credits.toFixed(2).padStart(10)}`;
|
|
11337
|
+
console.log(t.credits === 0 ? chalk33.dim(line) : line);
|
|
10559
11338
|
}
|
|
10560
11339
|
const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
|
|
10561
|
-
console.log(
|
|
11340
|
+
console.log(chalk33.bold(` ${"Total".padEnd(width)} ${" ".repeat(12)} ${chalk33.dim("credits")} ${total.toFixed(2).padStart(10)}`));
|
|
10562
11341
|
}
|
|
10563
11342
|
function formatDailyHistory(history) {
|
|
10564
11343
|
const spentOn = (u) => u.dailyCredits ?? u.types.reduce((sum, t) => sum + (t.dailyCredits ?? 0), 0);
|
|
@@ -10575,14 +11354,14 @@ function formatDailyHistory(history) {
|
|
|
10575
11354
|
for (const u of history) {
|
|
10576
11355
|
const spent = spentOn(u);
|
|
10577
11356
|
total += spent;
|
|
10578
|
-
const line = `${windowLabel(u).padEnd(width)} ${amount(spent)} ${
|
|
10579
|
-
lines.push(spent > 0 ?
|
|
11357
|
+
const line = `${windowLabel(u).padEnd(width)} ${amount(spent)} ${chalk33.dim("credits")}`;
|
|
11358
|
+
lines.push(spent > 0 ? chalk33.bold(line) : chalk33.dim(line));
|
|
10580
11359
|
for (const t of costly(u)) {
|
|
10581
11360
|
lines.push(` ${t.type.padEnd(width - 2)} ${amount(t.dailyCredits ?? 0)}`);
|
|
10582
11361
|
}
|
|
10583
11362
|
}
|
|
10584
11363
|
lines.push("");
|
|
10585
|
-
lines.push(
|
|
11364
|
+
lines.push(chalk33.bold(`${totalLabel.padEnd(width)} ${amount(total)} ${chalk33.dim("credits")}`));
|
|
10586
11365
|
return lines;
|
|
10587
11366
|
}
|
|
10588
11367
|
function registerUtilizationCommand(program) {
|
|
@@ -10595,7 +11374,7 @@ Examples:
|
|
|
10595
11374
|
`);
|
|
10596
11375
|
util.command("actual", { isDefault: true }).description("Show current utilization (default subcommand)").action(async (_options, cmd) => {
|
|
10597
11376
|
try {
|
|
10598
|
-
const outputFormat =
|
|
11377
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
10599
11378
|
const api = createApiClient();
|
|
10600
11379
|
const utilization = await api.admin.getActualUtilization();
|
|
10601
11380
|
if (outputFormat === "human") {
|
|
@@ -10609,7 +11388,7 @@ Examples:
|
|
|
10609
11388
|
});
|
|
10610
11389
|
util.command("history").description("Show what each day of the billing cycle cost").action(async (_options, cmd) => {
|
|
10611
11390
|
try {
|
|
10612
|
-
const outputFormat =
|
|
11391
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
10613
11392
|
const api = createApiClient();
|
|
10614
11393
|
const history = await api.admin.getUtilizationHistory();
|
|
10615
11394
|
if (outputFormat === "human") {
|
|
@@ -10630,7 +11409,7 @@ Examples:
|
|
|
10630
11409
|
}
|
|
10631
11410
|
|
|
10632
11411
|
// src/commands/entity-branch/index.ts
|
|
10633
|
-
function
|
|
11412
|
+
function getOutputFormat23(cmd) {
|
|
10634
11413
|
const config = loadConfig();
|
|
10635
11414
|
const globalOpts = cmd.optsWithGlobals();
|
|
10636
11415
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -10643,7 +11422,7 @@ function registerEntityBranchCommands(program) {
|
|
|
10643
11422
|
const eb = program.command("entity-branch").description("Manage entity branches (parallel versions of a single entity)");
|
|
10644
11423
|
eb.command("list").description("List branches of an entity").argument("<ref>", "Entity reference (projectId/branch/entityId)").action(async (ref, _options, cmd) => {
|
|
10645
11424
|
try {
|
|
10646
|
-
const outputFormat =
|
|
11425
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
10647
11426
|
const overrides = getOverrides11(cmd);
|
|
10648
11427
|
const resolved = parseEntityReference(ref, overrides);
|
|
10649
11428
|
const api = createApiClient();
|
|
@@ -10695,7 +11474,7 @@ function forReader(subscription) {
|
|
|
10695
11474
|
Object.entries(subscription).filter(([key]) => !BILLING_INTERNALS.has(key))
|
|
10696
11475
|
);
|
|
10697
11476
|
}
|
|
10698
|
-
function
|
|
11477
|
+
function getOutputFormat24(cmd) {
|
|
10699
11478
|
const config = loadConfig();
|
|
10700
11479
|
const globalOpts = cmd.optsWithGlobals();
|
|
10701
11480
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -10709,7 +11488,7 @@ Examples:
|
|
|
10709
11488
|
sub.command("current", { isDefault: true }).description("Show the current subscription").action(async (_options, cmd) => {
|
|
10710
11489
|
try {
|
|
10711
11490
|
const api = createApiClient();
|
|
10712
|
-
const outputFormat =
|
|
11491
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
10713
11492
|
const s = await api.admin.getCurrentSubscription();
|
|
10714
11493
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
10715
11494
|
} catch (error) {
|
|
@@ -10719,7 +11498,7 @@ Examples:
|
|
|
10719
11498
|
sub.command("next").description("Show the next (upcoming) subscription").action(async (_options, cmd) => {
|
|
10720
11499
|
try {
|
|
10721
11500
|
const api = createApiClient();
|
|
10722
|
-
const outputFormat =
|
|
11501
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
10723
11502
|
const s = await api.admin.getNextSubscription();
|
|
10724
11503
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
10725
11504
|
} catch (error) {
|
|
@@ -10730,7 +11509,7 @@ Examples:
|
|
|
10730
11509
|
try {
|
|
10731
11510
|
const api = createApiClient();
|
|
10732
11511
|
const plans = await api.admin.getSubscriptionPlans(subscriptionToken);
|
|
10733
|
-
format(plans, { format:
|
|
11512
|
+
format(plans, { format: getOutputFormat24(cmd) });
|
|
10734
11513
|
} catch (error) {
|
|
10735
11514
|
handleError(error);
|
|
10736
11515
|
}
|
|
@@ -10738,8 +11517,8 @@ Examples:
|
|
|
10738
11517
|
}
|
|
10739
11518
|
|
|
10740
11519
|
// src/commands/invoice/index.ts
|
|
10741
|
-
import * as
|
|
10742
|
-
function
|
|
11520
|
+
import * as fs13 from "fs";
|
|
11521
|
+
function getOutputFormat25(cmd) {
|
|
10743
11522
|
const config = loadConfig();
|
|
10744
11523
|
const globalOpts = cmd.optsWithGlobals();
|
|
10745
11524
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -10756,7 +11535,7 @@ Examples:
|
|
|
10756
11535
|
const api = createApiClient();
|
|
10757
11536
|
const invoices = await api.admin.getInvoices();
|
|
10758
11537
|
format(invoices, {
|
|
10759
|
-
format:
|
|
11538
|
+
format: getOutputFormat25(cmd),
|
|
10760
11539
|
columns: [
|
|
10761
11540
|
{ key: "invoiceNumber", header: "number" },
|
|
10762
11541
|
{ key: "issued", kind: "date" },
|
|
@@ -10776,7 +11555,7 @@ Examples:
|
|
|
10776
11555
|
const response = await api.admin.downloadInvoice(invoiceNumber, fileName);
|
|
10777
11556
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10778
11557
|
const outPath = options.out ?? fileName;
|
|
10779
|
-
|
|
11558
|
+
fs13.writeFileSync(outPath, buffer);
|
|
10780
11559
|
success(`Invoice saved to ${outPath}`);
|
|
10781
11560
|
} catch (error) {
|
|
10782
11561
|
handleError(error);
|
|
@@ -10785,12 +11564,12 @@ Examples:
|
|
|
10785
11564
|
}
|
|
10786
11565
|
|
|
10787
11566
|
// src/commands/shell/index.ts
|
|
10788
|
-
import
|
|
10789
|
-
import * as
|
|
10790
|
-
import * as
|
|
10791
|
-
import * as
|
|
11567
|
+
import chalk34 from "chalk";
|
|
11568
|
+
import * as fs14 from "fs";
|
|
11569
|
+
import * as os4 from "os";
|
|
11570
|
+
import * as path10 from "path";
|
|
10792
11571
|
import { spawn as spawn3 } from "child_process";
|
|
10793
|
-
import { randomUUID as
|
|
11572
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
10794
11573
|
function extensionFor2(language) {
|
|
10795
11574
|
const l = language.toLowerCase();
|
|
10796
11575
|
if (l === "java") return "java";
|
|
@@ -10801,16 +11580,16 @@ function extensionFor2(language) {
|
|
|
10801
11580
|
return "txt";
|
|
10802
11581
|
}
|
|
10803
11582
|
async function openInEditor(initial, ext) {
|
|
10804
|
-
const tmpFile =
|
|
10805
|
-
|
|
11583
|
+
const tmpFile = path10.join(os4.tmpdir(), `diafunc-shell-${randomUUID4()}.${ext}`);
|
|
11584
|
+
fs14.writeFileSync(tmpFile, initial);
|
|
10806
11585
|
const editor = process.env.VISUAL ?? process.env.EDITOR ?? "vi";
|
|
10807
|
-
await new Promise((
|
|
11586
|
+
await new Promise((resolve2, reject) => {
|
|
10808
11587
|
const child = spawn3(editor, [tmpFile], { stdio: "inherit" });
|
|
10809
|
-
child.on("exit", (code) => code === 0 ?
|
|
11588
|
+
child.on("exit", (code) => code === 0 ? resolve2() : reject(new Error(`Editor exited with ${code}`)));
|
|
10810
11589
|
child.on("error", reject);
|
|
10811
11590
|
});
|
|
10812
|
-
const content =
|
|
10813
|
-
|
|
11591
|
+
const content = fs14.readFileSync(tmpFile, "utf-8");
|
|
11592
|
+
fs14.unlinkSync(tmpFile);
|
|
10814
11593
|
return content;
|
|
10815
11594
|
}
|
|
10816
11595
|
function utcNowParts() {
|
|
@@ -10851,21 +11630,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
|
|
|
10851
11630
|
}, false);
|
|
10852
11631
|
if (result.outputs?.length) {
|
|
10853
11632
|
for (const out of result.outputs) {
|
|
10854
|
-
console.log(
|
|
11633
|
+
console.log(chalk34.dim(` [${out.type}]`) + " " + out.output);
|
|
10855
11634
|
}
|
|
10856
11635
|
}
|
|
10857
11636
|
if (result.successful) {
|
|
10858
11637
|
if (result.result) {
|
|
10859
|
-
console.log(
|
|
11638
|
+
console.log(chalk34.green("=>") + " " + result.result);
|
|
10860
11639
|
} else {
|
|
10861
|
-
console.log(
|
|
11640
|
+
console.log(chalk34.dim("=> (no value)"));
|
|
10862
11641
|
}
|
|
10863
11642
|
const duration = result.completed - result.started;
|
|
10864
|
-
console.log(
|
|
11643
|
+
console.log(chalk34.dim(` [${duration}ms \xB7 ${evaluationId}]`));
|
|
10865
11644
|
} else {
|
|
10866
|
-
console.log(
|
|
11645
|
+
console.log(chalk34.red("error: ") + result.error);
|
|
10867
11646
|
if (result.lineNumber > 0) {
|
|
10868
|
-
console.log(
|
|
11647
|
+
console.log(chalk34.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
|
|
10869
11648
|
}
|
|
10870
11649
|
}
|
|
10871
11650
|
}
|
|
@@ -10886,19 +11665,19 @@ function registerShellCommand(program) {
|
|
|
10886
11665
|
});
|
|
10887
11666
|
const api = createApiClient();
|
|
10888
11667
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
10889
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
11668
|
+
const { getUpdateNotice } = await import("./update-check-4345HWGE.js");
|
|
10890
11669
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
10891
|
-
console.log(
|
|
10892
|
-
console.log(
|
|
10893
|
-
console.log(
|
|
11670
|
+
console.log(chalk34.bold("Diafunc shell") + chalk34.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
11671
|
+
console.log(chalk34.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
11672
|
+
console.log(chalk34.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
|
|
10894
11673
|
const notice = await getUpdateNotice();
|
|
10895
|
-
if (notice) console.log(
|
|
11674
|
+
if (notice) console.log(chalk34.dim(notice));
|
|
10896
11675
|
console.log();
|
|
10897
11676
|
let language = resolvedLanguage;
|
|
10898
11677
|
for (; ; ) {
|
|
10899
11678
|
let line;
|
|
10900
11679
|
try {
|
|
10901
|
-
line = await promptInput({ message:
|
|
11680
|
+
line = await promptInput({ message: chalk34.cyan.bold(`${language} >`) });
|
|
10902
11681
|
} catch {
|
|
10903
11682
|
console.log();
|
|
10904
11683
|
return;
|
|
@@ -10916,54 +11695,54 @@ function registerShellCommand(program) {
|
|
|
10916
11695
|
case "help":
|
|
10917
11696
|
case "h":
|
|
10918
11697
|
case "?":
|
|
10919
|
-
console.log(
|
|
10920
|
-
console.log(
|
|
10921
|
-
console.log(
|
|
10922
|
-
console.log(
|
|
11698
|
+
console.log(chalk34.dim(" /edit open $EDITOR for multi-line code"));
|
|
11699
|
+
console.log(chalk34.dim(" /file <path> evaluate the contents of a file"));
|
|
11700
|
+
console.log(chalk34.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
|
|
11701
|
+
console.log(chalk34.dim(" /quit exit the shell"));
|
|
10923
11702
|
continue;
|
|
10924
11703
|
case "lang":
|
|
10925
11704
|
if (arg) language = arg;
|
|
10926
|
-
console.log(
|
|
11705
|
+
console.log(chalk34.dim(`Language: ${language}`));
|
|
10927
11706
|
continue;
|
|
10928
11707
|
case "edit": {
|
|
10929
11708
|
const sourceCode = await openInEditor("", extensionFor2(language));
|
|
10930
11709
|
if (!sourceCode.trim()) {
|
|
10931
|
-
console.log(
|
|
11710
|
+
console.log(chalk34.dim("(empty; not evaluated)"));
|
|
10932
11711
|
continue;
|
|
10933
11712
|
}
|
|
10934
11713
|
try {
|
|
10935
11714
|
await evaluate(api, fnRef, language, sourceCode);
|
|
10936
11715
|
} catch (e) {
|
|
10937
|
-
console.error(
|
|
11716
|
+
console.error(chalk34.red(e.message));
|
|
10938
11717
|
}
|
|
10939
11718
|
continue;
|
|
10940
11719
|
}
|
|
10941
11720
|
case "file": {
|
|
10942
11721
|
if (!arg) {
|
|
10943
|
-
console.log(
|
|
11722
|
+
console.log(chalk34.dim("usage: /file <path>"));
|
|
10944
11723
|
continue;
|
|
10945
11724
|
}
|
|
10946
|
-
if (!
|
|
10947
|
-
console.log(
|
|
11725
|
+
if (!fs14.existsSync(arg)) {
|
|
11726
|
+
console.log(chalk34.red(`file not found: ${arg}`));
|
|
10948
11727
|
continue;
|
|
10949
11728
|
}
|
|
10950
|
-
const sourceCode =
|
|
11729
|
+
const sourceCode = fs14.readFileSync(arg, "utf-8");
|
|
10951
11730
|
try {
|
|
10952
11731
|
await evaluate(api, fnRef, language, sourceCode);
|
|
10953
11732
|
} catch (e) {
|
|
10954
|
-
console.error(
|
|
11733
|
+
console.error(chalk34.red(e.message));
|
|
10955
11734
|
}
|
|
10956
11735
|
continue;
|
|
10957
11736
|
}
|
|
10958
11737
|
default:
|
|
10959
|
-
console.log(
|
|
11738
|
+
console.log(chalk34.dim(`Unknown command: /${cmd2}. Try /help.`));
|
|
10960
11739
|
continue;
|
|
10961
11740
|
}
|
|
10962
11741
|
}
|
|
10963
11742
|
try {
|
|
10964
11743
|
await evaluate(api, fnRef, language, trimmed);
|
|
10965
11744
|
} catch (e) {
|
|
10966
|
-
console.error(
|
|
11745
|
+
console.error(chalk34.red(e.message));
|
|
10967
11746
|
}
|
|
10968
11747
|
}
|
|
10969
11748
|
} catch (error) {
|
|
@@ -10973,19 +11752,19 @@ function registerShellCommand(program) {
|
|
|
10973
11752
|
}
|
|
10974
11753
|
|
|
10975
11754
|
// src/commands/update/index.ts
|
|
10976
|
-
import
|
|
10977
|
-
import * as
|
|
11755
|
+
import chalk35 from "chalk";
|
|
11756
|
+
import * as path11 from "path";
|
|
10978
11757
|
import { spawn as spawn4 } from "child_process";
|
|
10979
11758
|
|
|
10980
11759
|
// src/util/install-method.ts
|
|
10981
|
-
import * as
|
|
11760
|
+
import * as fs15 from "fs";
|
|
10982
11761
|
function detectInstall() {
|
|
10983
11762
|
const exec = process.execPath;
|
|
10984
11763
|
const exe = exec.replace(/\\/g, "/").toLowerCase();
|
|
10985
11764
|
const isNode = exe.endsWith("/node") || exe.endsWith("/node.exe");
|
|
10986
11765
|
return {
|
|
10987
11766
|
method: isNode ? "npm" : "binary",
|
|
10988
|
-
binaryPath: isNode ? exec :
|
|
11767
|
+
binaryPath: isNode ? exec : fs15.realpathSync(exec)
|
|
10989
11768
|
};
|
|
10990
11769
|
}
|
|
10991
11770
|
|
|
@@ -11001,7 +11780,7 @@ async function fetchLatestVersion() {
|
|
|
11001
11780
|
return manifest.version;
|
|
11002
11781
|
}
|
|
11003
11782
|
function runInstaller(installDir) {
|
|
11004
|
-
return new Promise((
|
|
11783
|
+
return new Promise((resolve2, reject) => {
|
|
11005
11784
|
const isWindows = process.platform === "win32";
|
|
11006
11785
|
const cmd = isWindows ? "powershell.exe" : "sh";
|
|
11007
11786
|
const args = isWindows ? ["-NoProfile", "-Command", `& { iwr -useb ${WINDOWS_INSTALLER_URL} | iex }`] : ["-c", `curl -fsSL ${POSIX_INSTALLER_URL} | sh`];
|
|
@@ -11009,7 +11788,7 @@ function runInstaller(installDir) {
|
|
|
11009
11788
|
stdio: "inherit",
|
|
11010
11789
|
env: { ...process.env, DIAFUNC_CLI_INSTALL_DIR: installDir }
|
|
11011
11790
|
});
|
|
11012
|
-
child.on("exit", (code) => code === 0 ?
|
|
11791
|
+
child.on("exit", (code) => code === 0 ? resolve2() : reject(new Error(`Installer exited with code ${code}`)));
|
|
11013
11792
|
child.on("error", reject);
|
|
11014
11793
|
});
|
|
11015
11794
|
}
|
|
@@ -11019,17 +11798,17 @@ function registerUpdateCommand(program) {
|
|
|
11019
11798
|
const install = detectInstall();
|
|
11020
11799
|
const latest = await fetchLatestVersion();
|
|
11021
11800
|
if (latest === package_default.version) {
|
|
11022
|
-
console.log(
|
|
11801
|
+
console.log(chalk35.dim(`diafunc is already at the latest version (${package_default.version}).`));
|
|
11023
11802
|
return;
|
|
11024
11803
|
}
|
|
11025
|
-
console.log(
|
|
11804
|
+
console.log(chalk35.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
|
|
11026
11805
|
if (install.method === "npm") {
|
|
11027
11806
|
console.log();
|
|
11028
11807
|
console.log("Installed via npm. Upgrade with:");
|
|
11029
|
-
console.log(
|
|
11808
|
+
console.log(chalk35.bold(` npm install -g @diafunc/cli@${latest}`));
|
|
11030
11809
|
return;
|
|
11031
11810
|
}
|
|
11032
|
-
const installDir =
|
|
11811
|
+
const installDir = path11.dirname(install.binaryPath);
|
|
11033
11812
|
console.log(`Installing diafunc ${latest} to ${installDir}...`);
|
|
11034
11813
|
console.log();
|
|
11035
11814
|
await runInstaller(installDir);
|
|
@@ -11040,23 +11819,23 @@ function registerUpdateCommand(program) {
|
|
|
11040
11819
|
}
|
|
11041
11820
|
|
|
11042
11821
|
// src/commands/uninstall/index.ts
|
|
11043
|
-
import
|
|
11822
|
+
import chalk36 from "chalk";
|
|
11044
11823
|
import { spawn as spawn5 } from "child_process";
|
|
11045
|
-
import * as
|
|
11046
|
-
import * as
|
|
11047
|
-
import * as
|
|
11824
|
+
import * as fs16 from "fs";
|
|
11825
|
+
import * as os5 from "os";
|
|
11826
|
+
import * as path12 from "path";
|
|
11048
11827
|
function registerUninstallCommand(program) {
|
|
11049
11828
|
program.command("uninstall").description("Remove the CLI binary and (optionally) its config from this machine").option("-y, --yes", "Skip confirmation prompts").option("--purge", "Also remove ~/.diafunc/ (config + credentials) without prompting").action(async (options) => {
|
|
11050
11829
|
try {
|
|
11051
11830
|
const install = detectInstall();
|
|
11052
|
-
const configDir =
|
|
11831
|
+
const configDir = path12.join(os5.homedir(), ".diafunc");
|
|
11053
11832
|
if (install.method === "npm") {
|
|
11054
11833
|
console.log("Installed via npm. Remove with:");
|
|
11055
|
-
console.log(
|
|
11056
|
-
if (
|
|
11834
|
+
console.log(chalk36.bold(" npm uninstall -g @diafunc/cli"));
|
|
11835
|
+
if (fs16.existsSync(configDir)) {
|
|
11057
11836
|
console.log();
|
|
11058
11837
|
console.log(`Config and credentials live at ${configDir}. Remove them manually with:`);
|
|
11059
|
-
console.log(
|
|
11838
|
+
console.log(chalk36.bold(` rm -rf ${configDir}`));
|
|
11060
11839
|
}
|
|
11061
11840
|
return;
|
|
11062
11841
|
}
|
|
@@ -11066,19 +11845,19 @@ function registerUninstallCommand(program) {
|
|
|
11066
11845
|
default: false
|
|
11067
11846
|
});
|
|
11068
11847
|
if (!removeBinary) {
|
|
11069
|
-
console.log(
|
|
11848
|
+
console.log(chalk36.dim("Aborted."));
|
|
11070
11849
|
return;
|
|
11071
11850
|
}
|
|
11072
11851
|
let removeConfig = options.purge ?? false;
|
|
11073
|
-
if (!options.purge && !options.yes &&
|
|
11852
|
+
if (!options.purge && !options.yes && fs16.existsSync(configDir)) {
|
|
11074
11853
|
removeConfig = await confirm({
|
|
11075
11854
|
message: `Also remove ${configDir} (config + credentials)?`,
|
|
11076
11855
|
default: false
|
|
11077
11856
|
});
|
|
11078
11857
|
}
|
|
11079
|
-
if (removeConfig &&
|
|
11080
|
-
|
|
11081
|
-
console.log(
|
|
11858
|
+
if (removeConfig && fs16.existsSync(configDir)) {
|
|
11859
|
+
fs16.rmSync(configDir, { recursive: true, force: true });
|
|
11860
|
+
console.log(chalk36.dim(`Removed ${configDir}`));
|
|
11082
11861
|
}
|
|
11083
11862
|
if (process.platform === "win32") {
|
|
11084
11863
|
const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
|
|
@@ -11088,13 +11867,13 @@ function registerUninstallCommand(program) {
|
|
|
11088
11867
|
windowsHide: true
|
|
11089
11868
|
});
|
|
11090
11869
|
child.unref();
|
|
11091
|
-
console.log(
|
|
11870
|
+
console.log(chalk36.dim(`Removing ${install.binaryPath} on exit...`));
|
|
11092
11871
|
console.log();
|
|
11093
11872
|
console.log("diafunc uninstalled.");
|
|
11094
11873
|
return;
|
|
11095
11874
|
}
|
|
11096
|
-
|
|
11097
|
-
console.log(
|
|
11875
|
+
fs16.rmSync(install.binaryPath, { force: true });
|
|
11876
|
+
console.log(chalk36.dim(`Removed ${install.binaryPath}`));
|
|
11098
11877
|
console.log();
|
|
11099
11878
|
console.log("diafunc uninstalled.");
|
|
11100
11879
|
} catch (error) {
|
|
@@ -11158,7 +11937,7 @@ var DiafuncCommand = class _DiafuncCommand extends Command {
|
|
|
11158
11937
|
};
|
|
11159
11938
|
|
|
11160
11939
|
// src/prompting/fill.ts
|
|
11161
|
-
import
|
|
11940
|
+
import chalk38 from "chalk";
|
|
11162
11941
|
|
|
11163
11942
|
// src/prompting/resolvers.ts
|
|
11164
11943
|
var PROJECT_ROLES = ["OWNER", "ADMIN", "DEVELOPER", "GUEST"];
|
|
@@ -11213,6 +11992,9 @@ var BY_COMMAND = {
|
|
|
11213
11992
|
"notebook export": {
|
|
11214
11993
|
"<notebookIds>": { kind: "entity", form: "id", contentType: "notebook", projectFrom: "project", multiple: true }
|
|
11215
11994
|
},
|
|
11995
|
+
"entity tags set": { "<tags>": TEXT_OR_EMPTY },
|
|
11996
|
+
"project tags set": { "<tags>": TEXT_OR_EMPTY },
|
|
11997
|
+
"admin curated-tags create": { "--display-name": TEXT },
|
|
11216
11998
|
"link delete": { "<linkId>": { kind: "link" } },
|
|
11217
11999
|
"link create": { "<linkId>": TEXT },
|
|
11218
12000
|
"config profile use": { "<name>": { kind: "profile" } },
|
|
@@ -11262,6 +12044,8 @@ var BY_NAME = {
|
|
|
11262
12044
|
value: TEXT_OR_EMPTY,
|
|
11263
12045
|
// Free text: names, messages and ids the reader is creating rather than choosing.
|
|
11264
12046
|
name: TEXT,
|
|
12047
|
+
tag: TEXT,
|
|
12048
|
+
tags: TEXT,
|
|
11265
12049
|
newId: TEXT,
|
|
11266
12050
|
message: TEXT,
|
|
11267
12051
|
query: TEXT,
|
|
@@ -11283,11 +12067,11 @@ var BY_NAME = {
|
|
|
11283
12067
|
function tokenOf(input) {
|
|
11284
12068
|
return input.kind === "option" ? input.flag ?? `--${input.name}` : `<${input.name}>`;
|
|
11285
12069
|
}
|
|
11286
|
-
function specFor(
|
|
11287
|
-
const exact = BY_COMMAND[
|
|
12070
|
+
function specFor(path13, input) {
|
|
12071
|
+
const exact = BY_COMMAND[path13]?.[tokenOf(input)];
|
|
11288
12072
|
if (exact) return exact;
|
|
11289
|
-
const group =
|
|
11290
|
-
const sub =
|
|
12073
|
+
const group = path13.split(" ")[0];
|
|
12074
|
+
const sub = path13.split(" ").slice(0, 2).join(" ");
|
|
11291
12075
|
switch (input.name) {
|
|
11292
12076
|
case "ref":
|
|
11293
12077
|
case "sourceRef":
|
|
@@ -11354,8 +12138,8 @@ function dependencies(spec) {
|
|
|
11354
12138
|
}
|
|
11355
12139
|
|
|
11356
12140
|
// src/prompting/pickers.ts
|
|
11357
|
-
import * as
|
|
11358
|
-
import
|
|
12141
|
+
import * as fs17 from "fs";
|
|
12142
|
+
import chalk37 from "chalk";
|
|
11359
12143
|
var SEARCH_THRESHOLD = 10;
|
|
11360
12144
|
var TYPE_IT = "\0type-it";
|
|
11361
12145
|
async function askFor(spec, input, ctx) {
|
|
@@ -11489,7 +12273,7 @@ async function askFor(spec, input, ctx) {
|
|
|
11489
12273
|
}
|
|
11490
12274
|
case "file":
|
|
11491
12275
|
return typed(ctx, question(input), {
|
|
11492
|
-
validate: (value) =>
|
|
12276
|
+
validate: (value) => fs17.existsSync(value.trim()) || `No file at ${value.trim()}.`
|
|
11493
12277
|
});
|
|
11494
12278
|
case "number":
|
|
11495
12279
|
return typed(ctx, question(input), { validate: numberRule(spec) });
|
|
@@ -11703,7 +12487,7 @@ function typedValue(ctx, message) {
|
|
|
11703
12487
|
return typed(ctx, message);
|
|
11704
12488
|
}
|
|
11705
12489
|
function typeItChoice() {
|
|
11706
|
-
return { name:
|
|
12490
|
+
return { name: chalk37.dim("Type it instead"), value: TYPE_IT };
|
|
11707
12491
|
}
|
|
11708
12492
|
function text(ctx, name) {
|
|
11709
12493
|
const value = ctx.known.get(name);
|
|
@@ -11733,7 +12517,7 @@ function capitalize(value) {
|
|
|
11733
12517
|
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
11734
12518
|
}
|
|
11735
12519
|
function labelled(label, hint2) {
|
|
11736
|
-
return hint2 && hint2 !== label ? `${label} ${
|
|
12520
|
+
return hint2 && hint2 !== label ? `${label} ${chalk37.dim(hint2)}` : label;
|
|
11737
12521
|
}
|
|
11738
12522
|
function numberRule(spec) {
|
|
11739
12523
|
return (raw) => {
|
|
@@ -11779,7 +12563,7 @@ async function fillPendingInputs(actionCommand) {
|
|
|
11779
12563
|
known: knownValues(actionCommand),
|
|
11780
12564
|
globals: actionCommand.optsWithGlobals(),
|
|
11781
12565
|
prefill: /* @__PURE__ */ new Map(),
|
|
11782
|
-
note: (line) => process.stderr.write(
|
|
12566
|
+
note: (line) => process.stderr.write(chalk38.dim(` ${line}
|
|
11783
12567
|
`))
|
|
11784
12568
|
};
|
|
11785
12569
|
for (const item of orderByDependencies(pending)) {
|
|
@@ -11788,7 +12572,7 @@ async function fillPendingInputs(actionCommand) {
|
|
|
11788
12572
|
ctx.known.set(item.input.name, value);
|
|
11789
12573
|
}
|
|
11790
12574
|
const log = env.log ?? ((line) => console.log(line));
|
|
11791
|
-
log(
|
|
12575
|
+
log(chalk38.dim(` Equivalent: ${equivalentCommand(actionCommand)}`));
|
|
11792
12576
|
}
|
|
11793
12577
|
function commandChain(cmd) {
|
|
11794
12578
|
const chain = [];
|
|
@@ -11893,7 +12677,7 @@ function createProgram(environment = {}) {
|
|
|
11893
12677
|
const opts = thisCommand.optsWithGlobals();
|
|
11894
12678
|
if (opts.dryRun) setDryRun(true);
|
|
11895
12679
|
if (opts.verbose) setVerbose(true);
|
|
11896
|
-
if (opts.color === false)
|
|
12680
|
+
if (opts.color === false) chalk39.level = 0;
|
|
11897
12681
|
}).hook("preAction", (_thisCommand, actionCommand) => fillPendingInputs(actionCommand));
|
|
11898
12682
|
program.addHelpText("after", HELP_EPILOGUE);
|
|
11899
12683
|
registerAuthCommands(program);
|
|
@@ -11936,4 +12720,4 @@ export {
|
|
|
11936
12720
|
PromptCancelled,
|
|
11937
12721
|
createProgram
|
|
11938
12722
|
};
|
|
11939
|
-
//# sourceMappingURL=chunk-
|
|
12723
|
+
//# sourceMappingURL=chunk-Q5GOPNYM.js.map
|