stow-cli 1.0.2 → 1.0.3

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.
Files changed (56) hide show
  1. package/dist/{app-2A2CFVBC.js → app-JPUDM4LJ.js} +1 -1
  2. package/dist/backfill-QZTVNJZM.js +61 -0
  3. package/dist/buckets-JQKZ3PH3.js +63 -0
  4. package/dist/{chunk-ZDVARBCV.js → chunk-ELSDWMEB.js} +8 -2
  5. package/dist/chunk-WAQSCS57.js +38 -0
  6. package/dist/cli.js +508 -15
  7. package/dist/drops-QXGTYB5E.js +39 -0
  8. package/dist/files-OCYICIAM.js +165 -0
  9. package/dist/health-YMZTZUFX.js +52 -0
  10. package/dist/jobs-6JY4SVV5.js +92 -0
  11. package/dist/jobs-OKKGKSIH.js +83 -0
  12. package/dist/maintenance-EZUHQK5Q.js +86 -0
  13. package/dist/profiles-GWLBEEIT.js +50 -0
  14. package/dist/queues-EQX7EJZF.js +51 -0
  15. package/dist/search-2PXM6XQ6.js +108 -0
  16. package/dist/tags-LSVEIIUF.js +46 -0
  17. package/dist/{upload-MI6VFGTC.js → upload-ESYKBYHA.js} +3 -3
  18. package/dist/{whoami-754O5IML.js → whoami-4UYMSRVP.js} +1 -1
  19. package/package.json +1 -1
  20. package/dist/app-2H4TLSN7.js +0 -239
  21. package/dist/app-HYCPA7GA.js +0 -239
  22. package/dist/app-IZGSPZPX.js +0 -239
  23. package/dist/app-UGUM75MC.js +0 -239
  24. package/dist/app-XPOEAZJC.js +0 -239
  25. package/dist/app-YITP5APT.js +0 -233
  26. package/dist/chunk-2AORPTQB.js +0 -23
  27. package/dist/chunk-FEMMZ4YZ.js +0 -125
  28. package/dist/chunk-LYCXXF2T.js +0 -79
  29. package/dist/chunk-MHRMBH4Y.js +0 -36
  30. package/dist/chunk-R5CCBTXZ.js +0 -79
  31. package/dist/chunk-YRHPOFJT.js +0 -115
  32. package/dist/cli.d.ts +0 -1
  33. package/dist/delete-AECEJX5W.js +0 -18
  34. package/dist/delete-KYOZEODD.js +0 -18
  35. package/dist/delete-OLOAJRRO.js +0 -18
  36. package/dist/delete-V4EY4UBG.js +0 -18
  37. package/dist/list-7A3VZA2T.js +0 -97
  38. package/dist/list-DHXVIMRI.js +0 -94
  39. package/dist/list-DJEAKEZJ.js +0 -106
  40. package/dist/list-DQRU6QHO.js +0 -106
  41. package/dist/list-I5A6LTHX.js +0 -106
  42. package/dist/list-KEQPJY7I.js +0 -109
  43. package/dist/list-Z3MPT6MI.js +0 -109
  44. package/dist/open-2YNHG3MA.js +0 -15
  45. package/dist/upload-3NS5O3UL.js +0 -120
  46. package/dist/upload-B2PGW3AN.js +0 -125
  47. package/dist/upload-DQDBDIDI.js +0 -92
  48. package/dist/upload-FGNGNPC3.js +0 -93
  49. package/dist/upload-HKUPWTK2.js +0 -173
  50. package/dist/upload-JDVSJVWK.js +0 -173
  51. package/dist/upload-K4H7ZVRW.js +0 -98
  52. package/dist/whoami-2SLCNVKP.js +0 -27
  53. package/dist/whoami-DOMX3Z5K.js +0 -28
  54. package/dist/whoami-IPMCUEUH.js +0 -27
  55. package/dist/whoami-JSQA2IDN.js +0 -27
  56. package/dist/whoami-RKH5HHPR.js +0 -27
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatBytes
3
- } from "./chunk-ZDVARBCV.js";
3
+ } from "./chunk-ELSDWMEB.js";
4
4
  import {
5
5
  createStow
6
6
  } from "./chunk-JYOMHKFS.js";
@@ -0,0 +1,61 @@
1
+ import {
2
+ adminRequest
3
+ } from "./chunk-WAQSCS57.js";
4
+ import {
5
+ outputJson
6
+ } from "./chunk-ELSDWMEB.js";
7
+ import "./chunk-OZ7QQTIZ.js";
8
+
9
+ // src/commands/admin/backfill.ts
10
+ async function runBackfill(type, options) {
11
+ const parsedLimit = options.limit ? Number.parseInt(options.limit, 10) : null;
12
+ const body = {};
13
+ if (options.bucket) {
14
+ body.bucketId = options.bucket;
15
+ }
16
+ if (parsedLimit && parsedLimit > 0) {
17
+ body.limit = parsedLimit;
18
+ }
19
+ if (options.dryRun) {
20
+ body.dryRun = true;
21
+ }
22
+ const result = await adminRequest({
23
+ method: "POST",
24
+ path: `/api/internal/files/${type}/backfill`,
25
+ body
26
+ });
27
+ if (options.json) {
28
+ outputJson(result);
29
+ return;
30
+ }
31
+ if (result.dryRun) {
32
+ console.log(`[dry run] ${result.remaining} files need ${type} processing`);
33
+ return;
34
+ }
35
+ console.log(`Enqueued: ${result.enqueued ?? 0}`);
36
+ console.log(`Remaining: ${result.remaining}`);
37
+ if (result.errors && result.errors.length > 0) {
38
+ console.error(`
39
+ Errors (${result.errors.length}):`);
40
+ for (const err of result.errors) {
41
+ console.error(` ${err.fileId}: ${err.error}`);
42
+ }
43
+ }
44
+ if (result.nextCursor) {
45
+ console.log("\n(more files available \u2014 run again to continue)");
46
+ }
47
+ }
48
+ async function backfillDimensions(options) {
49
+ await runBackfill("dimensions", options);
50
+ }
51
+ async function backfillColors(options) {
52
+ await runBackfill("colors", options);
53
+ }
54
+ async function backfillEmbeddings(options) {
55
+ await runBackfill("embeddings", options);
56
+ }
57
+ export {
58
+ backfillColors,
59
+ backfillDimensions,
60
+ backfillEmbeddings
61
+ };
@@ -0,0 +1,63 @@
1
+ import {
2
+ formatBytes,
3
+ formatTable
4
+ } from "./chunk-ELSDWMEB.js";
5
+ import {
6
+ createStow
7
+ } from "./chunk-JYOMHKFS.js";
8
+ import "./chunk-OZ7QQTIZ.js";
9
+
10
+ // src/commands/buckets.ts
11
+ async function listBuckets() {
12
+ const stow = createStow();
13
+ const data = await stow.listBuckets();
14
+ if (data.buckets.length === 0) {
15
+ console.log("No buckets yet. Create one with: stow buckets create <name>");
16
+ return;
17
+ }
18
+ const rows = data.buckets.map((b) => [
19
+ b.name,
20
+ b.isPublic ? "public" : "private",
21
+ b.searchable ? "yes" : "no",
22
+ `${b.fileCount ?? 0} files`,
23
+ formatBytes(b.usageBytes ?? 0),
24
+ b.description || ""
25
+ ]);
26
+ console.log(
27
+ formatTable(
28
+ ["Name", "Access", "Search", "Files", "Size", "Description"],
29
+ rows
30
+ )
31
+ );
32
+ }
33
+ async function createBucket(name, options) {
34
+ const stow = createStow();
35
+ const bucket = await stow.createBucket({
36
+ name,
37
+ ...options.description ? { description: options.description } : {},
38
+ ...options.public ? { isPublic: true } : {}
39
+ });
40
+ console.log(`Created bucket: ${bucket.name}`);
41
+ }
42
+ async function renameBucket(name, newName, options) {
43
+ if (!options.yes) {
44
+ console.error(
45
+ "Warning: Renaming a bucket will break any existing URLs using the old name."
46
+ );
47
+ console.error("Use --yes to skip this warning.");
48
+ }
49
+ const stow = createStow();
50
+ const bucket = await stow.renameBucket(name, newName);
51
+ console.log(`Renamed bucket: ${name} \u2192 ${bucket.name}`);
52
+ }
53
+ async function deleteBucket(id) {
54
+ const stow = createStow();
55
+ await stow.deleteBucket(id);
56
+ console.log(`Deleted bucket: ${id}`);
57
+ }
58
+ export {
59
+ createBucket,
60
+ deleteBucket,
61
+ listBuckets,
62
+ renameBucket
63
+ };
@@ -21,13 +21,18 @@ function formatTable(headers, rows) {
21
21
  const pad = (str, width) => str.padEnd(width);
22
22
  const sep = widths.map((w) => "\u2500".repeat(w)).join("\u2500\u2500");
23
23
  const lines = [];
24
- lines.push(headers.map((h, i) => pad(h, widths[i])).join(" "));
24
+ lines.push(headers.map((h, i) => pad(h, widths[i] ?? 0)).join(" "));
25
25
  lines.push(sep);
26
26
  for (const row of rows) {
27
- lines.push(row.map((cell, i) => pad(cell || "", widths[i])).join(" "));
27
+ lines.push(
28
+ row.map((cell, i) => pad(cell || "", widths[i] ?? 0)).join(" ")
29
+ );
28
30
  }
29
31
  return lines.join("\n");
30
32
  }
33
+ function outputJson(data) {
34
+ console.log(JSON.stringify(data, null, 2));
35
+ }
31
36
  function usageBar(used, total, width = 20) {
32
37
  const ratio = Math.min(used / total, 1);
33
38
  const filled = Math.round(ratio * width);
@@ -39,5 +44,6 @@ function usageBar(used, total, width = 20) {
39
44
  export {
40
45
  formatBytes,
41
46
  formatTable,
47
+ outputJson,
42
48
  usageBar
43
49
  };
@@ -0,0 +1,38 @@
1
+ import {
2
+ getBaseUrl
3
+ } from "./chunk-OZ7QQTIZ.js";
4
+
5
+ // src/lib/admin-client.ts
6
+ function getAdminSecret() {
7
+ const secret = process.env.STOW_ADMIN_SECRET;
8
+ if (!secret) {
9
+ console.error("Error: STOW_ADMIN_SECRET environment variable not set");
10
+ console.error("");
11
+ console.error("Set your admin secret:");
12
+ console.error(" export STOW_ADMIN_SECRET=your-secret");
13
+ process.exit(1);
14
+ }
15
+ return secret;
16
+ }
17
+ async function adminRequest(opts) {
18
+ const baseUrl = getBaseUrl();
19
+ const secret = getAdminSecret();
20
+ const res = await fetch(`${baseUrl}${opts.path}`, {
21
+ method: opts.method,
22
+ headers: {
23
+ Authorization: `Bearer ${secret}`,
24
+ ...opts.body ? { "Content-Type": "application/json" } : {}
25
+ },
26
+ ...opts.body ? { body: JSON.stringify(opts.body) } : {}
27
+ });
28
+ if (!res.ok) {
29
+ const body = await res.json().catch(() => ({ error: res.statusText }));
30
+ const message = body.error ?? `HTTP ${res.status}`;
31
+ throw new Error(message);
32
+ }
33
+ return await res.json();
34
+ }
35
+
36
+ export {
37
+ adminRequest
38
+ };