stow-cli 1.0.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-DTW2LNXW.js +249 -0
- package/dist/backfill-G57M2BRA.js +61 -0
- package/dist/buckets-NXIVHPW5.js +63 -0
- package/dist/chunk-5LU25QZK.js +17 -0
- package/dist/chunk-ELSDWMEB.js +49 -0
- package/dist/chunk-QF7PVPWQ.js +38 -0
- package/dist/chunk-TOADDO2F.js +23 -0
- package/dist/cli.js +510 -17
- package/dist/delete-GEX3O7YS.js +14 -0
- package/dist/drops-RD55IDZ4.js +39 -0
- package/dist/files-E662TXUP.js +165 -0
- package/dist/health-6LWM7KAT.js +52 -0
- package/dist/jobs-CLXYKZ3B.js +92 -0
- package/dist/jobs-K3LTNETU.js +83 -0
- package/dist/maintenance-7LOAGG6J.js +86 -0
- package/dist/open-F73Q2OHD.js +15 -0
- package/dist/profiles-C6SCFXS6.js +50 -0
- package/dist/queues-2GJAMMNF.js +51 -0
- package/dist/search-DV4VV62L.js +108 -0
- package/dist/tags-URHK2YH5.js +46 -0
- package/dist/upload-5RIDB2C5.js +92 -0
- package/dist/whoami-5IYRZKWS.js +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatBytes,
|
|
3
|
+
formatTable,
|
|
4
|
+
usageBar
|
|
5
|
+
} from "./chunk-ELSDWMEB.js";
|
|
6
|
+
import {
|
|
7
|
+
createStow
|
|
8
|
+
} from "./chunk-5LU25QZK.js";
|
|
9
|
+
import "./chunk-TOADDO2F.js";
|
|
10
|
+
|
|
11
|
+
// src/commands/drops.ts
|
|
12
|
+
async function listDrops() {
|
|
13
|
+
const stow = createStow();
|
|
14
|
+
const data = await stow.listDrops();
|
|
15
|
+
if (data.drops.length === 0) {
|
|
16
|
+
console.log("No drops yet. Create one with: stow drop <file>");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const rows = data.drops.map((d) => [
|
|
20
|
+
d.filename,
|
|
21
|
+
formatBytes(Number(d.size)),
|
|
22
|
+
d.contentType,
|
|
23
|
+
d.url
|
|
24
|
+
]);
|
|
25
|
+
console.log(formatTable(["Filename", "Size", "Type", "URL"], rows));
|
|
26
|
+
console.log(
|
|
27
|
+
`
|
|
28
|
+
Storage: ${usageBar(data.usage.bytes, data.usage.limit)} ${formatBytes(data.usage.bytes)} / ${formatBytes(data.usage.limit)}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
async function deleteDrop(id) {
|
|
32
|
+
const stow = createStow();
|
|
33
|
+
await stow.deleteDrop(id);
|
|
34
|
+
console.log(`Deleted drop: ${id}`);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
deleteDrop,
|
|
38
|
+
listDrops
|
|
39
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatBytes,
|
|
3
|
+
formatTable,
|
|
4
|
+
outputJson
|
|
5
|
+
} from "./chunk-ELSDWMEB.js";
|
|
6
|
+
import {
|
|
7
|
+
createStow
|
|
8
|
+
} from "./chunk-5LU25QZK.js";
|
|
9
|
+
import {
|
|
10
|
+
getApiKey,
|
|
11
|
+
getBaseUrl
|
|
12
|
+
} from "./chunk-TOADDO2F.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/files.ts
|
|
15
|
+
async function listFiles(bucket, options) {
|
|
16
|
+
const stow = createStow();
|
|
17
|
+
const parsedLimit = options.limit ? Number.parseInt(options.limit, 10) : null;
|
|
18
|
+
const data = await stow.listFiles({
|
|
19
|
+
bucket,
|
|
20
|
+
...options.search ? { prefix: options.search } : {},
|
|
21
|
+
...parsedLimit && Number.isFinite(parsedLimit) && parsedLimit > 0 ? { limit: parsedLimit } : {}
|
|
22
|
+
});
|
|
23
|
+
if (options.json) {
|
|
24
|
+
outputJson(data);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (data.files.length === 0) {
|
|
28
|
+
console.log(`No files in bucket '${bucket}'.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const rows = data.files.map((f) => [
|
|
32
|
+
f.key,
|
|
33
|
+
formatBytes(f.size),
|
|
34
|
+
f.lastModified.split("T")[0] ?? f.lastModified
|
|
35
|
+
]);
|
|
36
|
+
console.log(formatTable(["Key", "Size", "Modified"], rows));
|
|
37
|
+
if (data.nextCursor) {
|
|
38
|
+
console.log("\n(more files available \u2014 use --limit to see more)");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function getFile(bucket, key, options) {
|
|
42
|
+
const stow = createStow();
|
|
43
|
+
const file = await stow.getFile(key, { bucket });
|
|
44
|
+
if (options.json) {
|
|
45
|
+
outputJson(file);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
console.log(
|
|
49
|
+
formatTable(
|
|
50
|
+
["Field", "Value"],
|
|
51
|
+
[
|
|
52
|
+
["Key", file.key],
|
|
53
|
+
["Size", formatBytes(file.size)],
|
|
54
|
+
["Type", file.contentType],
|
|
55
|
+
["Created", file.createdAt],
|
|
56
|
+
["URL", file.url ?? "(private)"],
|
|
57
|
+
[
|
|
58
|
+
"Dimensions",
|
|
59
|
+
file.width && file.height ? `${file.width}\xD7${file.height}` : "\u2014"
|
|
60
|
+
],
|
|
61
|
+
["Duration", file.duration ? `${file.duration}s` : "\u2014"],
|
|
62
|
+
["Embedding", file.embeddingStatus ?? "\u2014"]
|
|
63
|
+
]
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
if (file.metadata && Object.keys(file.metadata).length > 0) {
|
|
67
|
+
console.log("\nMetadata:");
|
|
68
|
+
for (const [k, v] of Object.entries(file.metadata)) {
|
|
69
|
+
console.log(` ${k}: ${v}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function updateFile(bucket, key, options) {
|
|
74
|
+
if (!options.metadata || options.metadata.length === 0) {
|
|
75
|
+
console.error("Error: At least one -m key=value pair is required.");
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const metadata = {};
|
|
79
|
+
for (const pair of options.metadata) {
|
|
80
|
+
const idx = pair.indexOf("=");
|
|
81
|
+
if (idx === -1) {
|
|
82
|
+
console.error(`Error: Invalid metadata format '${pair}'. Use key=value.`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
metadata[pair.slice(0, idx)] = pair.slice(idx + 1);
|
|
86
|
+
}
|
|
87
|
+
const stow = createStow();
|
|
88
|
+
const file = await stow.updateFileMetadata(key, metadata, { bucket });
|
|
89
|
+
if (options.json) {
|
|
90
|
+
outputJson(file);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
console.log(`Updated ${key}`);
|
|
94
|
+
}
|
|
95
|
+
async function enrichFile(bucket, key) {
|
|
96
|
+
const stow = createStow();
|
|
97
|
+
const results = await Promise.allSettled([
|
|
98
|
+
stow.generateTitle(key, { bucket }),
|
|
99
|
+
stow.generateDescription(key, { bucket }),
|
|
100
|
+
stow.generateAltText(key, { bucket })
|
|
101
|
+
]);
|
|
102
|
+
const labels = ["Title", "Description", "Alt text"];
|
|
103
|
+
for (let i = 0; i < results.length; i++) {
|
|
104
|
+
const result = results[i];
|
|
105
|
+
const label = labels[i];
|
|
106
|
+
if (result.status === "fulfilled") {
|
|
107
|
+
console.log(` ${label}: triggered`);
|
|
108
|
+
} else {
|
|
109
|
+
console.error(` ${label}: failed \u2014 ${result.reason}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const succeeded = results.filter((r) => r.status === "fulfilled").length;
|
|
113
|
+
console.log(
|
|
114
|
+
`
|
|
115
|
+
Enriched ${key}: ${succeeded}/${results.length} tasks dispatched`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
async function listMissing(bucket, type, options) {
|
|
119
|
+
const validTypes = ["dimensions", "embeddings", "colors"];
|
|
120
|
+
if (!validTypes.includes(type)) {
|
|
121
|
+
console.error(
|
|
122
|
+
`Error: Invalid type '${type}'. Must be one of: ${validTypes.join(", ")}`
|
|
123
|
+
);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
const parsedLimit = options.limit ? Number.parseInt(options.limit, 10) : null;
|
|
127
|
+
const baseUrl = getBaseUrl();
|
|
128
|
+
const apiKey = getApiKey();
|
|
129
|
+
const params = new URLSearchParams({
|
|
130
|
+
bucket,
|
|
131
|
+
missing: type,
|
|
132
|
+
...parsedLimit && Number.isFinite(parsedLimit) && parsedLimit > 0 ? { limit: String(parsedLimit) } : {}
|
|
133
|
+
});
|
|
134
|
+
const res = await fetch(`${baseUrl}/files?${params}`, {
|
|
135
|
+
headers: { "x-api-key": apiKey }
|
|
136
|
+
});
|
|
137
|
+
if (!res.ok) {
|
|
138
|
+
const body = await res.json().catch(() => ({}));
|
|
139
|
+
throw new Error(body.error ?? `HTTP ${res.status}`);
|
|
140
|
+
}
|
|
141
|
+
const data = await res.json();
|
|
142
|
+
if (options.json) {
|
|
143
|
+
outputJson(data);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (data.files.length === 0) {
|
|
147
|
+
console.log(`No files missing ${type} in bucket '${bucket}'.`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const rows = data.files.map((f) => [
|
|
151
|
+
f.key,
|
|
152
|
+
formatBytes(f.size),
|
|
153
|
+
f.lastModified.split("T")[0] ?? f.lastModified
|
|
154
|
+
]);
|
|
155
|
+
console.log(formatTable(["Key", "Size", "Modified"], rows));
|
|
156
|
+
console.log(`
|
|
157
|
+
${data.files.length} files missing ${type}`);
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
enrichFile,
|
|
161
|
+
getFile,
|
|
162
|
+
listFiles,
|
|
163
|
+
listMissing,
|
|
164
|
+
updateFile
|
|
165
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adminRequest
|
|
3
|
+
} from "./chunk-QF7PVPWQ.js";
|
|
4
|
+
import {
|
|
5
|
+
formatTable,
|
|
6
|
+
outputJson
|
|
7
|
+
} from "./chunk-ELSDWMEB.js";
|
|
8
|
+
import "./chunk-TOADDO2F.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/admin/health.ts
|
|
11
|
+
async function health(options) {
|
|
12
|
+
const result = await adminRequest({
|
|
13
|
+
method: "GET",
|
|
14
|
+
path: "/health"
|
|
15
|
+
});
|
|
16
|
+
if (options.json) {
|
|
17
|
+
outputJson(result);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const statusIcon = result.status === "ok" ? "\u2713" : "\u2717";
|
|
21
|
+
console.log(`${statusIcon} ${result.status} (${result.version})`);
|
|
22
|
+
console.log(` ${result.timestamp}`);
|
|
23
|
+
console.log("\nChecks:");
|
|
24
|
+
for (const [name, status] of Object.entries(result.checks)) {
|
|
25
|
+
const icon = status === "ok" ? "\u2713" : "\u2717";
|
|
26
|
+
console.log(` ${icon} ${name}`);
|
|
27
|
+
}
|
|
28
|
+
if (result.queues) {
|
|
29
|
+
console.log("\nQueues:");
|
|
30
|
+
const rows = [];
|
|
31
|
+
for (const [name, counts] of Object.entries(result.queues)) {
|
|
32
|
+
if (counts === "unavailable") {
|
|
33
|
+
rows.push([name, "\u2014", "\u2014", "\u2014", "\u2014"]);
|
|
34
|
+
} else {
|
|
35
|
+
const c = counts;
|
|
36
|
+
rows.push([
|
|
37
|
+
name,
|
|
38
|
+
String(c.waiting ?? 0),
|
|
39
|
+
String(c.active ?? 0),
|
|
40
|
+
String(c.completed ?? 0),
|
|
41
|
+
String(c.failed ?? 0)
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
console.log(
|
|
46
|
+
formatTable(["Queue", "Waiting", "Active", "Completed", "Failed"], rows)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
health
|
|
52
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatTable,
|
|
3
|
+
outputJson
|
|
4
|
+
} from "./chunk-ELSDWMEB.js";
|
|
5
|
+
import {
|
|
6
|
+
getApiKey,
|
|
7
|
+
getBaseUrl
|
|
8
|
+
} from "./chunk-TOADDO2F.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/jobs.ts
|
|
11
|
+
async function bucketRequest(opts) {
|
|
12
|
+
const baseUrl = getBaseUrl();
|
|
13
|
+
const apiKey = getApiKey();
|
|
14
|
+
const res = await fetch(`${baseUrl}${opts.path}`, {
|
|
15
|
+
method: opts.method,
|
|
16
|
+
headers: {
|
|
17
|
+
"x-api-key": apiKey,
|
|
18
|
+
...opts.body ? { "Content-Type": "application/json" } : {}
|
|
19
|
+
},
|
|
20
|
+
...opts.body ? { body: JSON.stringify(opts.body) } : {}
|
|
21
|
+
});
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
24
|
+
const message = body.error ?? `HTTP ${res.status}`;
|
|
25
|
+
throw new Error(message);
|
|
26
|
+
}
|
|
27
|
+
return await res.json();
|
|
28
|
+
}
|
|
29
|
+
function formatTimestamp(ts) {
|
|
30
|
+
return new Date(ts).toISOString().replace("T", " ").slice(0, 19);
|
|
31
|
+
}
|
|
32
|
+
async function listJobs(bucketId, options) {
|
|
33
|
+
const params = new URLSearchParams();
|
|
34
|
+
if (options.status) {
|
|
35
|
+
params.set("status", options.status);
|
|
36
|
+
}
|
|
37
|
+
if (options.queue) {
|
|
38
|
+
params.set("queue", options.queue);
|
|
39
|
+
}
|
|
40
|
+
if (options.limit) {
|
|
41
|
+
params.set("limit", options.limit);
|
|
42
|
+
}
|
|
43
|
+
const qs = params.toString();
|
|
44
|
+
const path = `/buckets/${bucketId}/jobs${qs ? `?${qs}` : ""}`;
|
|
45
|
+
const result = await bucketRequest({
|
|
46
|
+
method: "GET",
|
|
47
|
+
path
|
|
48
|
+
});
|
|
49
|
+
if (options.json) {
|
|
50
|
+
outputJson(result.jobs);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (result.jobs.length === 0) {
|
|
54
|
+
console.log("No jobs found.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const rows = result.jobs.map((job) => [
|
|
58
|
+
job.jobId,
|
|
59
|
+
job.queueName,
|
|
60
|
+
job.status,
|
|
61
|
+
job.data.fileId.slice(0, 8) + "\u2026",
|
|
62
|
+
formatTimestamp(job.timestamp),
|
|
63
|
+
job.failedReason ? job.failedReason.slice(0, 40) : ""
|
|
64
|
+
]);
|
|
65
|
+
console.log(
|
|
66
|
+
formatTable(["ID", "Queue", "Status", "File", "Created", "Error"], rows)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
async function retryJob(jobId, options) {
|
|
70
|
+
const result = await bucketRequest({
|
|
71
|
+
method: "POST",
|
|
72
|
+
path: `/buckets/${options.bucket}/jobs/${jobId}/retry`,
|
|
73
|
+
body: { queue: options.queue }
|
|
74
|
+
});
|
|
75
|
+
if (result.retried) {
|
|
76
|
+
console.log(`Job ${jobId} retried.`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function deleteJob(jobId, options) {
|
|
80
|
+
const result = await bucketRequest({
|
|
81
|
+
method: "DELETE",
|
|
82
|
+
path: `/buckets/${options.bucket}/jobs/${jobId}?queue=${encodeURIComponent(options.queue)}`
|
|
83
|
+
});
|
|
84
|
+
if (result.deleted) {
|
|
85
|
+
console.log(`Job ${jobId} removed.`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
deleteJob,
|
|
90
|
+
listJobs,
|
|
91
|
+
retryJob
|
|
92
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adminRequest
|
|
3
|
+
} from "./chunk-QF7PVPWQ.js";
|
|
4
|
+
import {
|
|
5
|
+
formatTable,
|
|
6
|
+
outputJson
|
|
7
|
+
} from "./chunk-ELSDWMEB.js";
|
|
8
|
+
import "./chunk-TOADDO2F.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/admin/jobs.ts
|
|
11
|
+
function formatTimestamp(ts) {
|
|
12
|
+
return new Date(ts).toISOString().replace("T", " ").slice(0, 19);
|
|
13
|
+
}
|
|
14
|
+
async function listAdminJobs(options) {
|
|
15
|
+
const params = new URLSearchParams();
|
|
16
|
+
if (options.org) {
|
|
17
|
+
params.set("orgId", options.org);
|
|
18
|
+
}
|
|
19
|
+
if (options.bucket) {
|
|
20
|
+
params.set("bucketId", options.bucket);
|
|
21
|
+
}
|
|
22
|
+
if (options.status) {
|
|
23
|
+
params.set("status", options.status);
|
|
24
|
+
}
|
|
25
|
+
if (options.queue) {
|
|
26
|
+
params.set("queue", options.queue);
|
|
27
|
+
}
|
|
28
|
+
if (options.limit) {
|
|
29
|
+
params.set("limit", options.limit);
|
|
30
|
+
}
|
|
31
|
+
const qs = params.toString();
|
|
32
|
+
const result = await adminRequest({
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: `/admin/jobs${qs ? `?${qs}` : ""}`
|
|
35
|
+
});
|
|
36
|
+
if (options.json) {
|
|
37
|
+
outputJson(result.jobs);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (result.jobs.length === 0) {
|
|
41
|
+
console.log("No jobs found.");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const rows = result.jobs.map((job) => [
|
|
45
|
+
job.jobId,
|
|
46
|
+
job.queueName,
|
|
47
|
+
job.status,
|
|
48
|
+
job.data.fileId.slice(0, 8) + "\u2026",
|
|
49
|
+
job.data.orgId.slice(0, 8) + "\u2026",
|
|
50
|
+
formatTimestamp(job.timestamp),
|
|
51
|
+
job.failedReason ? job.failedReason.slice(0, 40) : ""
|
|
52
|
+
]);
|
|
53
|
+
console.log(
|
|
54
|
+
formatTable(
|
|
55
|
+
["ID", "Queue", "Status", "File", "Org", "Created", "Error"],
|
|
56
|
+
rows
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
async function retryAdminJob(jobId, options) {
|
|
61
|
+
const result = await adminRequest({
|
|
62
|
+
method: "POST",
|
|
63
|
+
path: `/admin/jobs/${jobId}/retry`,
|
|
64
|
+
body: { queue: options.queue }
|
|
65
|
+
});
|
|
66
|
+
if (result.retried) {
|
|
67
|
+
console.log(`Job ${jobId} retried.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function deleteAdminJob(jobId, options) {
|
|
71
|
+
const result = await adminRequest({
|
|
72
|
+
method: "DELETE",
|
|
73
|
+
path: `/admin/jobs/${jobId}?queue=${encodeURIComponent(options.queue)}`
|
|
74
|
+
});
|
|
75
|
+
if (result.deleted) {
|
|
76
|
+
console.log(`Job ${jobId} removed.`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
deleteAdminJob,
|
|
81
|
+
listAdminJobs,
|
|
82
|
+
retryAdminJob
|
|
83
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adminRequest
|
|
3
|
+
} from "./chunk-QF7PVPWQ.js";
|
|
4
|
+
import {
|
|
5
|
+
outputJson
|
|
6
|
+
} from "./chunk-ELSDWMEB.js";
|
|
7
|
+
import "./chunk-TOADDO2F.js";
|
|
8
|
+
|
|
9
|
+
// src/commands/admin/maintenance.ts
|
|
10
|
+
async function cleanupDrops(options) {
|
|
11
|
+
const params = new URLSearchParams();
|
|
12
|
+
if (options.maxAgeHours) {
|
|
13
|
+
params.set("maxAgeHours", options.maxAgeHours);
|
|
14
|
+
}
|
|
15
|
+
if (options.dryRun) {
|
|
16
|
+
params.set("dryRun", "true");
|
|
17
|
+
}
|
|
18
|
+
const qs = params.toString();
|
|
19
|
+
const result = await adminRequest({
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: `/admin/cleanup-drops${qs ? `?${qs}` : ""}`
|
|
22
|
+
});
|
|
23
|
+
if (options.json) {
|
|
24
|
+
outputJson(result);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(
|
|
28
|
+
options.dryRun ? `[dry run] Would clean up ${result.count ?? 0} drops` : `Cleaned up ${result.deleted ?? 0} drops`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
async function purgeEvents(options) {
|
|
32
|
+
const params = new URLSearchParams();
|
|
33
|
+
if (options.dryRun) {
|
|
34
|
+
params.set("dryRun", "true");
|
|
35
|
+
}
|
|
36
|
+
const qs = params.toString();
|
|
37
|
+
const result = await adminRequest({
|
|
38
|
+
method: "POST",
|
|
39
|
+
path: `/admin/purge-events${qs ? `?${qs}` : ""}`
|
|
40
|
+
});
|
|
41
|
+
if (options.json) {
|
|
42
|
+
outputJson(result);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
console.log(
|
|
46
|
+
options.dryRun ? `[dry run] Would purge ${result.count ?? 0} events` : `Purged ${result.deleted ?? 0} events`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
async function reconcileFiles(options) {
|
|
50
|
+
const params = new URLSearchParams({ bucketId: options.bucket });
|
|
51
|
+
if (options.dryRun) {
|
|
52
|
+
params.set("dryRun", "true");
|
|
53
|
+
}
|
|
54
|
+
const result = await adminRequest({
|
|
55
|
+
method: "POST",
|
|
56
|
+
path: `/admin/reconcile-files?${params}`
|
|
57
|
+
});
|
|
58
|
+
if (options.json) {
|
|
59
|
+
outputJson(result);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (options.dryRun) {
|
|
63
|
+
console.log(
|
|
64
|
+
`[dry run] ${result.mismatched ?? 0} files need reconciliation`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
console.log(`Reconciled ${result.reconciled ?? 0} files`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function retrySyncFailures(options) {
|
|
71
|
+
const result = await adminRequest({
|
|
72
|
+
method: "POST",
|
|
73
|
+
path: "/admin/retry-sync-failures"
|
|
74
|
+
});
|
|
75
|
+
if (options.json) {
|
|
76
|
+
outputJson(result);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
console.log(`Retried ${result.retried ?? 0} sync failures`);
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
cleanupDrops,
|
|
83
|
+
purgeEvents,
|
|
84
|
+
reconcileFiles,
|
|
85
|
+
retrySyncFailures
|
|
86
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getBaseUrl
|
|
3
|
+
} from "./chunk-TOADDO2F.js";
|
|
4
|
+
|
|
5
|
+
// src/commands/open.ts
|
|
6
|
+
async function openBucket(bucket) {
|
|
7
|
+
const baseUrl = getBaseUrl();
|
|
8
|
+
const url = `${baseUrl}/dashboard/buckets/${encodeURIComponent(bucket)}`;
|
|
9
|
+
const { default: open } = await import("open");
|
|
10
|
+
await open(url);
|
|
11
|
+
console.log(`Opened: ${url}`);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
openBucket
|
|
15
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatTable,
|
|
3
|
+
outputJson
|
|
4
|
+
} from "./chunk-ELSDWMEB.js";
|
|
5
|
+
import {
|
|
6
|
+
createStow
|
|
7
|
+
} from "./chunk-5LU25QZK.js";
|
|
8
|
+
import "./chunk-TOADDO2F.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/profiles.ts
|
|
11
|
+
async function createProfile(options) {
|
|
12
|
+
const stow = createStow();
|
|
13
|
+
const profile = await stow.profiles.create({
|
|
14
|
+
name: options.name,
|
|
15
|
+
...options.bucket ? { bucketId: options.bucket } : {}
|
|
16
|
+
});
|
|
17
|
+
if (options.json) {
|
|
18
|
+
outputJson(profile);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(`Created profile: ${profile.name} (${profile.id})`);
|
|
22
|
+
}
|
|
23
|
+
async function getProfile(id, options) {
|
|
24
|
+
const stow = createStow();
|
|
25
|
+
const profile = await stow.profiles.get(id);
|
|
26
|
+
if (options.json) {
|
|
27
|
+
outputJson(profile);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
console.log(`Profile: ${profile.name} (${profile.id})`);
|
|
31
|
+
if (profile.clusters && profile.clusters.length > 0) {
|
|
32
|
+
console.log("\nClusters:");
|
|
33
|
+
const rows = profile.clusters.map((c) => [
|
|
34
|
+
String(c.index),
|
|
35
|
+
c.name ?? "(unnamed)",
|
|
36
|
+
String(c.signalCount)
|
|
37
|
+
]);
|
|
38
|
+
console.log(formatTable(["Index", "Name", "Signals"], rows));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function deleteProfile(id) {
|
|
42
|
+
const stow = createStow();
|
|
43
|
+
await stow.profiles.delete(id);
|
|
44
|
+
console.log(`Deleted profile: ${id}`);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
createProfile,
|
|
48
|
+
deleteProfile,
|
|
49
|
+
getProfile
|
|
50
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adminRequest
|
|
3
|
+
} from "./chunk-QF7PVPWQ.js";
|
|
4
|
+
import {
|
|
5
|
+
formatTable,
|
|
6
|
+
outputJson
|
|
7
|
+
} from "./chunk-ELSDWMEB.js";
|
|
8
|
+
import "./chunk-TOADDO2F.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/admin/queues.ts
|
|
11
|
+
async function listQueues(options) {
|
|
12
|
+
const result = await adminRequest({
|
|
13
|
+
method: "GET",
|
|
14
|
+
path: "/admin/queues"
|
|
15
|
+
});
|
|
16
|
+
if (options.json) {
|
|
17
|
+
outputJson(result.queues);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const entries = Object.entries(result.queues);
|
|
21
|
+
if (entries.length === 0) {
|
|
22
|
+
console.log("No queues found.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const rows = entries.map(([name, counts]) => [
|
|
26
|
+
name,
|
|
27
|
+
String(counts.waiting),
|
|
28
|
+
String(counts.active),
|
|
29
|
+
String(counts.completed),
|
|
30
|
+
String(counts.failed)
|
|
31
|
+
]);
|
|
32
|
+
console.log(
|
|
33
|
+
formatTable(["Queue", "Waiting", "Active", "Completed", "Failed"], rows)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
async function cleanQueue(queueName, options) {
|
|
37
|
+
const status = options.failed ? "failed" : "completed";
|
|
38
|
+
const grace = options.grace ? Number(options.grace) : 0;
|
|
39
|
+
const result = await adminRequest({
|
|
40
|
+
method: "POST",
|
|
41
|
+
path: `/admin/queues/${encodeURIComponent(queueName)}/clean`,
|
|
42
|
+
body: { status, grace }
|
|
43
|
+
});
|
|
44
|
+
console.log(
|
|
45
|
+
`Cleaned ${result.cleaned} ${result.status} jobs from ${result.queue}.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
cleanQueue,
|
|
50
|
+
listQueues
|
|
51
|
+
};
|