gigadrive 2.13.0 → 2.14.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.cjs +138 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +138 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ var import_effect31 = require("effect");
|
|
|
32
32
|
// package.json
|
|
33
33
|
var package_default = {
|
|
34
34
|
name: "gigadrive",
|
|
35
|
-
version: "2.
|
|
35
|
+
version: "2.14.0",
|
|
36
36
|
repository: {
|
|
37
37
|
type: "git",
|
|
38
38
|
url: "https://github.com/Gigadrive/sdk.git",
|
|
@@ -3099,6 +3099,26 @@ var formatImageTable = (images) => formatTable([
|
|
|
3099
3099
|
["NAME", "STATUS", "SOURCE", "ID"],
|
|
3100
3100
|
...images.map((image) => [image.name, image.status, imageSource(image), image.id])
|
|
3101
3101
|
]);
|
|
3102
|
+
var formatWebhookTable = (webhooks) => formatTable([
|
|
3103
|
+
["URL", "EVENTS", "STATUS", "ID"],
|
|
3104
|
+
...webhooks.map((webhook) => [
|
|
3105
|
+
webhook.url,
|
|
3106
|
+
webhook.events.join(","),
|
|
3107
|
+
webhook.enabled ? "enabled" : "disabled",
|
|
3108
|
+
webhook.id
|
|
3109
|
+
])
|
|
3110
|
+
]);
|
|
3111
|
+
var formatDeliveryTable = (deliveries) => formatTable([
|
|
3112
|
+
["CREATED", "EVENT", "STATUS", "ATTEMPTS", "RESPONSE", "MICROVM"],
|
|
3113
|
+
...deliveries.map((delivery) => [
|
|
3114
|
+
delivery.createdAt,
|
|
3115
|
+
delivery.eventType,
|
|
3116
|
+
delivery.status,
|
|
3117
|
+
String(delivery.attempts),
|
|
3118
|
+
delivery.lastStatusCode === null ? delivery.lastError ?? "-" : String(delivery.lastStatusCode),
|
|
3119
|
+
delivery.microvmId
|
|
3120
|
+
])
|
|
3121
|
+
]);
|
|
3102
3122
|
var formatBytes = (bytes) => {
|
|
3103
3123
|
if (bytes < 1024) return `${bytes} B`;
|
|
3104
3124
|
const units = ["KiB", "MiB", "GiB", "TiB"];
|
|
@@ -3945,6 +3965,121 @@ var imagesCommand = import_cli12.Command.make("images", {}, () => import_effect2
|
|
|
3945
3965
|
import_cli12.Command.withDescription("Built-in and custom microVM images"),
|
|
3946
3966
|
import_cli12.Command.withSubcommands([imagesListCommand, imagesCreateCommand, imagesRemoveCommand])
|
|
3947
3967
|
);
|
|
3968
|
+
var WEBHOOK_EVENTS = [
|
|
3969
|
+
"microvm.created",
|
|
3970
|
+
"microvm.running",
|
|
3971
|
+
"microvm.paused",
|
|
3972
|
+
"microvm.stopped",
|
|
3973
|
+
"microvm.failed"
|
|
3974
|
+
];
|
|
3975
|
+
var webhookIdArg = import_cli12.Args.text({ name: "webhook-id" }).pipe(import_cli12.Args.withDescription("The webhook ID"));
|
|
3976
|
+
var webhooksListCommand = import_cli12.Command.make(
|
|
3977
|
+
"ls",
|
|
3978
|
+
{ app: appOption6, json: jsonOption2 },
|
|
3979
|
+
({ app, json }) => import_effect24.Effect.gen(function* () {
|
|
3980
|
+
const apiClient = yield* ApiClientService;
|
|
3981
|
+
const applicationId = yield* resolveApplicationId(app);
|
|
3982
|
+
const webhooks = yield* apiClient.request((client) => client.microvms.webhooks.list({ applicationId }));
|
|
3983
|
+
if (json) return yield* import_effect24.Console.log(JSON.stringify(webhooks, null, 2));
|
|
3984
|
+
if (webhooks.length === 0)
|
|
3985
|
+
return yield* import_effect24.Console.log('No webhooks yet. Add one with "gigadrive microvms webhooks add".');
|
|
3986
|
+
for (const line of formatWebhookTable(webhooks)) yield* import_effect24.Console.log(line);
|
|
3987
|
+
}).pipe(reportErrors2("list webhooks"))
|
|
3988
|
+
).pipe(import_cli12.Command.withDescription("List the application's microVM webhooks"));
|
|
3989
|
+
var addWebhook = (flags) => import_effect24.Effect.gen(function* () {
|
|
3990
|
+
const apiClient = yield* ApiClientService;
|
|
3991
|
+
const unknown = flags.events.find((event) => !WEBHOOK_EVENTS.includes(event));
|
|
3992
|
+
if (unknown !== void 0) {
|
|
3993
|
+
return yield* new InvalidMicroVmOptionsError({
|
|
3994
|
+
message: `${unknown} is not a microVM event. Use ${WEBHOOK_EVENTS.join(", ")}.`
|
|
3995
|
+
});
|
|
3996
|
+
}
|
|
3997
|
+
const events = flags.events.length > 0 ? [...new Set(flags.events)] : WEBHOOK_EVENTS;
|
|
3998
|
+
const applicationId = yield* resolveApplicationId(flags.app);
|
|
3999
|
+
const webhook = yield* apiClient.request(
|
|
4000
|
+
(client) => client.microvms.webhooks.create({
|
|
4001
|
+
url: flags.url,
|
|
4002
|
+
events,
|
|
4003
|
+
...import_effect24.Option.isSome(flags.description) ? { description: flags.description.value } : {},
|
|
4004
|
+
...applicationId ? { applicationId } : {}
|
|
4005
|
+
})
|
|
4006
|
+
);
|
|
4007
|
+
if (flags.json) {
|
|
4008
|
+
yield* import_effect24.Console.log(JSON.stringify(webhook, null, 2));
|
|
4009
|
+
} else {
|
|
4010
|
+
yield* import_effect24.Console.log(`Added webhook ${webhook.id} for ${webhook.events.join(", ")}.`);
|
|
4011
|
+
yield* import_effect24.Console.log(`Signing secret (shown only now): ${webhook.secret}`);
|
|
4012
|
+
}
|
|
4013
|
+
return webhook;
|
|
4014
|
+
});
|
|
4015
|
+
var webhooksAddCommand = import_cli12.Command.make(
|
|
4016
|
+
"add",
|
|
4017
|
+
{
|
|
4018
|
+
url: import_cli12.Args.text({ name: "url" }).pipe(import_cli12.Args.withDescription("HTTPS URL on a public host")),
|
|
4019
|
+
events: import_cli12.Options.text("event").pipe(
|
|
4020
|
+
import_cli12.Options.withDescription(`Event to send (repeatable; default: all of ${WEBHOOK_EVENTS.join(", ")})`),
|
|
4021
|
+
import_cli12.Options.repeated
|
|
4022
|
+
),
|
|
4023
|
+
description: import_cli12.Options.text("description").pipe(import_cli12.Options.withDescription("A note for yourself"), import_cli12.Options.optional),
|
|
4024
|
+
app: appOption6,
|
|
4025
|
+
json: jsonOption2
|
|
4026
|
+
},
|
|
4027
|
+
(flags) => addWebhook(flags).pipe(import_effect24.Effect.asVoid, reportErrors2("add the webhook"))
|
|
4028
|
+
).pipe(import_cli12.Command.withDescription("Add an endpoint for microVM lifecycle events and print its signing secret"));
|
|
4029
|
+
var webhooksEnableCommand = (enabled) => import_cli12.Command.make(
|
|
4030
|
+
enabled ? "enable" : "disable",
|
|
4031
|
+
{ webhookId: webhookIdArg },
|
|
4032
|
+
({ webhookId }) => import_effect24.Effect.gen(function* () {
|
|
4033
|
+
const apiClient = yield* ApiClientService;
|
|
4034
|
+
const webhook = yield* apiClient.request((client) => client.microvms.webhooks.update(webhookId, { enabled }));
|
|
4035
|
+
yield* import_effect24.Console.log(`${webhook.url} is ${webhook.enabled ? "enabled" : "disabled"}.`);
|
|
4036
|
+
}).pipe(reportErrors2(enabled ? "enable the webhook" : "disable the webhook"))
|
|
4037
|
+
).pipe(
|
|
4038
|
+
import_cli12.Command.withDescription(
|
|
4039
|
+
enabled ? "Send events to a webhook again" : "Stop sending events to a webhook; waiting retries are held"
|
|
4040
|
+
)
|
|
4041
|
+
);
|
|
4042
|
+
var webhooksSecretCommand = import_cli12.Command.make(
|
|
4043
|
+
"rotate-secret",
|
|
4044
|
+
{ webhookId: webhookIdArg },
|
|
4045
|
+
({ webhookId }) => import_effect24.Effect.gen(function* () {
|
|
4046
|
+
const apiClient = yield* ApiClientService;
|
|
4047
|
+
const webhook = yield* apiClient.request((client) => client.microvms.webhooks.rotateSecret(webhookId));
|
|
4048
|
+
yield* import_effect24.Console.log(`New signing secret (shown only now): ${webhook.secret}`);
|
|
4049
|
+
}).pipe(reportErrors2("replace the signing secret"))
|
|
4050
|
+
).pipe(import_cli12.Command.withDescription("Replace the signing secret; the old one stops signing at once"));
|
|
4051
|
+
var webhooksDeliveriesCommand = import_cli12.Command.make(
|
|
4052
|
+
"deliveries",
|
|
4053
|
+
{ webhookId: webhookIdArg, json: jsonOption2 },
|
|
4054
|
+
({ webhookId, json }) => import_effect24.Effect.gen(function* () {
|
|
4055
|
+
const apiClient = yield* ApiClientService;
|
|
4056
|
+
const deliveries = yield* apiClient.request((client) => client.microvms.webhooks.listDeliveries(webhookId));
|
|
4057
|
+
if (json) return yield* import_effect24.Console.log(JSON.stringify(deliveries, null, 2));
|
|
4058
|
+
if (deliveries.length === 0) return yield* import_effect24.Console.log("Nothing has been sent yet.");
|
|
4059
|
+
for (const line of formatDeliveryTable(deliveries)) yield* import_effect24.Console.log(line);
|
|
4060
|
+
}).pipe(reportErrors2("list the deliveries"))
|
|
4061
|
+
).pipe(import_cli12.Command.withDescription("Show a webhook's 50 most recent deliveries"));
|
|
4062
|
+
var webhooksRemoveCommand = import_cli12.Command.make(
|
|
4063
|
+
"rm",
|
|
4064
|
+
{ webhookId: webhookIdArg },
|
|
4065
|
+
({ webhookId }) => import_effect24.Effect.gen(function* () {
|
|
4066
|
+
const apiClient = yield* ApiClientService;
|
|
4067
|
+
yield* apiClient.request((client) => client.microvms.webhooks.delete(webhookId));
|
|
4068
|
+
yield* import_effect24.Console.log(`Deleted webhook ${webhookId}.`);
|
|
4069
|
+
}).pipe(reportErrors2("delete the webhook"))
|
|
4070
|
+
).pipe(import_cli12.Command.withDescription("Delete a webhook"));
|
|
4071
|
+
var webhooksCommand = import_cli12.Command.make("webhooks", {}, () => import_effect24.Effect.void).pipe(
|
|
4072
|
+
import_cli12.Command.withDescription("Signed HTTPS requests when a microVM is created, starts, pauses, stops or fails"),
|
|
4073
|
+
import_cli12.Command.withSubcommands([
|
|
4074
|
+
webhooksListCommand,
|
|
4075
|
+
webhooksAddCommand,
|
|
4076
|
+
webhooksEnableCommand(true),
|
|
4077
|
+
webhooksEnableCommand(false),
|
|
4078
|
+
webhooksSecretCommand,
|
|
4079
|
+
webhooksDeliveriesCommand,
|
|
4080
|
+
webhooksRemoveCommand
|
|
4081
|
+
])
|
|
4082
|
+
);
|
|
3948
4083
|
var SUBCOMMANDS = [
|
|
3949
4084
|
createCommand,
|
|
3950
4085
|
listCommand2,
|
|
@@ -3957,7 +4092,8 @@ var SUBCOMMANDS = [
|
|
|
3957
4092
|
removeCommand2,
|
|
3958
4093
|
extendCommand,
|
|
3959
4094
|
networkCommand,
|
|
3960
|
-
imagesCommand
|
|
4095
|
+
imagesCommand,
|
|
4096
|
+
webhooksCommand
|
|
3961
4097
|
];
|
|
3962
4098
|
var microvmsCommand = import_cli12.Command.make("microvms", {}, () => import_effect24.Effect.void).pipe(
|
|
3963
4099
|
import_cli12.Command.withDescription("Isolated Linux machines for running code: create, exec, shell, cp, stop"),
|