delivrie-cli 0.4.0 → 0.4.2
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/cli.js +63 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -90,7 +90,12 @@ Examples
|
|
|
90
90
|
delivrie domains delete <id|name> [--yes]`,
|
|
91
91
|
keys: `Usage:
|
|
92
92
|
delivrie keys list
|
|
93
|
-
delivrie keys create <name> [--sending] [--domain <id|name>] The key is shown once
|
|
93
|
+
delivrie keys create <name> [--sending] [--domain <id|name>] [--inbox <id|address>] The key is shown once; --inbox limits it to one inbox
|
|
94
|
+
delivrie inboxes list [--pod <id|client_id>]
|
|
95
|
+
delivrie inboxes create [username] [--address <addr>] [--name <name>] [--pod <id|client_id>] No address: an instant name@agents.delivrie.io
|
|
96
|
+
delivrie pods list
|
|
97
|
+
delivrie pods create <name> [--client-id <id>] A group of inboxes, e.g. one per customer
|
|
98
|
+
delivrie keys create <name> --pod <id|client_id> A key limited to one pod
|
|
94
99
|
delivrie keys delete <id> [--yes]`,
|
|
95
100
|
webhooks: `Usage:
|
|
96
101
|
delivrie webhooks list
|
|
@@ -398,6 +403,50 @@ export async function run(argv, io = {}) {
|
|
|
398
403
|
}
|
|
399
404
|
throw new UsageError(`Unknown: domains ${sub}. Try delivrie domains --help`);
|
|
400
405
|
}
|
|
406
|
+
case "pods": {
|
|
407
|
+
const api = need();
|
|
408
|
+
if (sub === "list" || !sub) {
|
|
409
|
+
const r = await api.request("GET", "/pods");
|
|
410
|
+
return show(r, () => {
|
|
411
|
+
const rows = listOf(r);
|
|
412
|
+
if (!rows.length)
|
|
413
|
+
return empty("pods");
|
|
414
|
+
print(out.table(rows, [{ label: "ID", get: (k) => k.id }, { label: "NAME", get: (k) => k.name }, { label: "CLIENT ID", get: (k) => k.client_id || out.dim("-") }, { label: "INBOXES", get: (k) => String(k.inbox_count ?? 0) }]));
|
|
415
|
+
}), 0;
|
|
416
|
+
}
|
|
417
|
+
if (sub === "create") {
|
|
418
|
+
const name = need1(rest[0], "pod name");
|
|
419
|
+
const r = await api.request("POST", "/pods", { name, ...(flags["client-id"] ? { client_id: String(flags["client-id"]) } : {}) });
|
|
420
|
+
return show(r, () => print(out.green("✓") + ` Created pod ${out.bold(r.name)} (${r.id}).`)), 0;
|
|
421
|
+
}
|
|
422
|
+
throw new Error(`Unknown pods command: ${sub}. Try: delivrie pods list | create <name>`);
|
|
423
|
+
}
|
|
424
|
+
case "inboxes": {
|
|
425
|
+
const api = need();
|
|
426
|
+
if (sub === "list" || !sub) {
|
|
427
|
+
const r = await api.request("GET", "/inboxes" + (flags.pod ? `?pod=${encodeURIComponent(String(flags.pod))}` : ""));
|
|
428
|
+
return show(r, () => {
|
|
429
|
+
const rows = listOf(r);
|
|
430
|
+
if (!rows.length)
|
|
431
|
+
return empty("inboxes");
|
|
432
|
+
print(out.table(rows, [{ label: "ID", get: (k) => k.id }, { label: "ADDRESS", get: (k) => k.address }, { label: "NAME", get: (k) => k.name }]));
|
|
433
|
+
}), 0;
|
|
434
|
+
}
|
|
435
|
+
if (sub === "create") {
|
|
436
|
+
const body = {};
|
|
437
|
+
if (flags.address)
|
|
438
|
+
body.address = String(flags.address);
|
|
439
|
+
else if (rest[0])
|
|
440
|
+
body.username = rest[0];
|
|
441
|
+
if (flags.name)
|
|
442
|
+
body.name = String(flags.name);
|
|
443
|
+
if (flags.pod)
|
|
444
|
+
body.pod = String(flags.pod);
|
|
445
|
+
const r = await api.request("POST", "/inboxes", body);
|
|
446
|
+
return show(r, () => print(out.green("✓") + ` Created ${out.bold(r.address)} (${r.id}). Mail to it lands in the inbox.`)), 0;
|
|
447
|
+
}
|
|
448
|
+
throw new Error(`Unknown inboxes command: ${sub}. Try: delivrie inboxes list | create [username]`);
|
|
449
|
+
}
|
|
401
450
|
case "keys": {
|
|
402
451
|
const api = need();
|
|
403
452
|
if (sub === "list" || !sub) {
|
|
@@ -414,6 +463,10 @@ export async function run(argv, io = {}) {
|
|
|
414
463
|
const body = { name, permission: flags.sending ? "sending_access" : "full_access" };
|
|
415
464
|
if (flags.domain)
|
|
416
465
|
body.domain_id = await resolveDomain(api, flags.domain);
|
|
466
|
+
if (flags.inbox)
|
|
467
|
+
body.inbox = String(flags.inbox);
|
|
468
|
+
if (flags.pod)
|
|
469
|
+
body.pod = String(flags.pod);
|
|
417
470
|
const r = await api.request("POST", "/api-keys", body);
|
|
418
471
|
return show(r, () => { print(out.green("✓") + ` Created ${out.bold(name)} (${r.id}). Copy it now, it's only shown once:`); print(""); print(" " + out.bold(r.token)); print(""); }), 0;
|
|
419
472
|
}
|
|
@@ -688,9 +741,15 @@ export async function run(argv, io = {}) {
|
|
|
688
741
|
kept.push(s.name);
|
|
689
742
|
continue;
|
|
690
743
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
744
|
+
// Download every file first (8 at a time), so a failed download leaves the installed copy untouched.
|
|
745
|
+
const bodies = new Array(files.length);
|
|
746
|
+
let next = 0;
|
|
747
|
+
await Promise.all(Array.from({ length: Math.min(8, files.length) }, async () => {
|
|
748
|
+
while (next < files.length) {
|
|
749
|
+
const i = next++;
|
|
750
|
+
bodies[i] = [files[i], Buffer.from(await (await get(files[i].url)).arrayBuffer())];
|
|
751
|
+
}
|
|
752
|
+
}));
|
|
694
753
|
// Remove files an older version had that this one doesn't.
|
|
695
754
|
for (const old of entry(s.name)?.files || [])
|
|
696
755
|
if (!files.some((f) => f.path === old))
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.4.
|
|
1
|
+
export const VERSION = "0.4.2";
|
package/package.json
CHANGED