vessels 0.2.7 → 0.3.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/dist/index.js +33 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -213,6 +213,31 @@ async function cmdWebhooksToggle(id, active) {
|
|
|
213
213
|
});
|
|
214
214
|
console.log(`Webhook ${data.endpoint.id} ${data.endpoint.active ? "enabled" : "disabled"}.`);
|
|
215
215
|
}
|
|
216
|
+
async function cmdWebhooksUpdate(id, args) {
|
|
217
|
+
const flags = parseFlags(args);
|
|
218
|
+
const updates = {};
|
|
219
|
+
if (flags.url !== void 0) {
|
|
220
|
+
if (!flags.url.startsWith("https://")) {
|
|
221
|
+
console.error("URL must start with https://");
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
updates.url = flags.url;
|
|
225
|
+
}
|
|
226
|
+
if (flags.events !== void 0) {
|
|
227
|
+
updates.events = flags.events.split(/[,\s]+/).filter(Boolean);
|
|
228
|
+
}
|
|
229
|
+
if (!Object.keys(updates).length) {
|
|
230
|
+
console.error("Nothing to update. Pass --url <https://...> and/or --events <a,b>.");
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
const data = await api(`/api/v1/webhooks/${id}`, {
|
|
234
|
+
method: "PATCH",
|
|
235
|
+
body: JSON.stringify(updates)
|
|
236
|
+
});
|
|
237
|
+
console.log(`Webhook ${data.endpoint.id} updated.`);
|
|
238
|
+
console.log(` URL: ${data.endpoint.url}`);
|
|
239
|
+
console.log(` Events: ${data.endpoint.events.join(", ")}`);
|
|
240
|
+
}
|
|
216
241
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
217
242
|
async function resolveVesselId(input) {
|
|
218
243
|
if (UUID_RE.test(input)) return input;
|
|
@@ -387,6 +412,7 @@ Commands:
|
|
|
387
412
|
|
|
388
413
|
vessels webhooks list
|
|
389
414
|
vessels webhooks create --url <https://...> [--events interaction.response,message.user]
|
|
415
|
+
vessels webhooks update <id> [--url <https://...>] [--events interaction.response,message.user]
|
|
390
416
|
vessels webhooks delete <id>
|
|
391
417
|
vessels webhooks enable <id>
|
|
392
418
|
vessels webhooks disable <id>
|
|
@@ -426,6 +452,13 @@ Run: vessels help`);
|
|
|
426
452
|
if (cmd === "webhooks") {
|
|
427
453
|
if (sub === "list" || !sub) return cmdWebhooksList();
|
|
428
454
|
if (sub === "create") return cmdWebhooksCreate(rest);
|
|
455
|
+
if (sub === "update") {
|
|
456
|
+
if (!rest[0]) {
|
|
457
|
+
console.error("Usage: vessels webhooks update <id> [--url <https://...>] [--events <a,b>]");
|
|
458
|
+
process.exit(1);
|
|
459
|
+
}
|
|
460
|
+
return cmdWebhooksUpdate(rest[0], rest.slice(1));
|
|
461
|
+
}
|
|
429
462
|
if (sub === "delete" || sub === "remove") {
|
|
430
463
|
if (!rest[0]) {
|
|
431
464
|
console.error("Usage: vessels webhooks delete <id>");
|