@kvbox/cli 0.6.12 → 0.6.15
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/kvbox.js +1466 -1225
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -155,7 +155,7 @@ async function spin(message, work, opts = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// src/program.ts
|
|
158
|
-
import { Command as
|
|
158
|
+
import { Command as Command133 } from "commander";
|
|
159
159
|
|
|
160
160
|
// ../shared/src/version.ts
|
|
161
161
|
import { createRequire } from "module";
|
|
@@ -170,7 +170,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// src/version.ts
|
|
173
|
-
var VERSION = versionOf(import.meta.url, true ? "0.6.
|
|
173
|
+
var VERSION = versionOf(import.meta.url, true ? "0.6.15" : void 0);
|
|
174
174
|
|
|
175
175
|
// src/commands/vm/index.ts
|
|
176
176
|
import { Command as Command39 } from "commander";
|
|
@@ -345,10 +345,98 @@ function volumeMountPath(volume2) {
|
|
|
345
345
|
|
|
346
346
|
// src/session.ts
|
|
347
347
|
import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
348
|
-
import { z as
|
|
348
|
+
import { z as z3 } from "zod";
|
|
349
349
|
|
|
350
350
|
// ../shared/src/api.ts
|
|
351
|
+
import { z as z2 } from "zod";
|
|
352
|
+
|
|
353
|
+
// ../shared/src/integrations.ts
|
|
351
354
|
import { z } from "zod";
|
|
355
|
+
var INTEGRATION_IDS = ["github", "claude"];
|
|
356
|
+
var IntegrationIdSchema = z.enum(INTEGRATION_IDS);
|
|
357
|
+
var INTEGRATION_KINDS = ["oauth", "app", "api-key", "subscription"];
|
|
358
|
+
var IntegrationKindSchema = z.enum(INTEGRATION_KINDS);
|
|
359
|
+
var INTEGRATION_STATUSES = ["ok", "needs-reconnect"];
|
|
360
|
+
var IntegrationStatusSchema = z.enum(INTEGRATION_STATUSES);
|
|
361
|
+
var INTEGRATIONS_OFF = "off";
|
|
362
|
+
function parseIntegrationList(text2) {
|
|
363
|
+
const names2 = text2.split(",").map((n) => n.trim().toLowerCase()).filter(Boolean);
|
|
364
|
+
if (names2.length === 0 || names2.length === 1 && names2[0] === INTEGRATIONS_OFF) return [];
|
|
365
|
+
const unknown = names2.filter((n) => !INTEGRATION_IDS.includes(n));
|
|
366
|
+
if (unknown.length > 0) {
|
|
367
|
+
const what = unknown[0] === INTEGRATIONS_OFF ? `${INTEGRATIONS_OFF} goes alone, not in a list` : `unknown integration: ${unknown.join(", ")}`;
|
|
368
|
+
throw new KvboxError(`${what} (the integrations are: ${INTEGRATION_IDS.join(", ")}; ${INTEGRATIONS_OFF} for none)`);
|
|
369
|
+
}
|
|
370
|
+
return INTEGRATION_IDS.filter((id) => names2.includes(id));
|
|
371
|
+
}
|
|
372
|
+
var IntegrationListSchema = z.array(z.string().min(1).max(40)).max(20).transform((list) => [...new Set(list)]);
|
|
373
|
+
var IntegrationCatalogEntrySchema = z.object({
|
|
374
|
+
/** A plain string, like `integration` in a listing row: a reader may be older than the control plane. */
|
|
375
|
+
id: z.string(),
|
|
376
|
+
title: z.string(),
|
|
377
|
+
description: z.string(),
|
|
378
|
+
/**
|
|
379
|
+
* How Connect works: `oauth` sends the browser to the provider's consent screen; `paste` takes a credential
|
|
380
|
+
* the user pastes (Claude Code's). A plain string, like `id`: a released CLI must still read a catalog with a way it does not know.
|
|
381
|
+
*/
|
|
382
|
+
connect: z.string(),
|
|
383
|
+
/** What a user's slug and an org's may hold; an empty list: that kind of slug cannot connect it yet. */
|
|
384
|
+
kinds: z.object({ user: z.array(IntegrationKindSchema), org: z.array(IntegrationKindSchema) }),
|
|
385
|
+
/** Whether this control plane is set up for it (a self-hosted one without a GitHub app is not). */
|
|
386
|
+
available: z.boolean(),
|
|
387
|
+
/** Its guide, as a URL. */
|
|
388
|
+
docs: z.string().optional(),
|
|
389
|
+
/** Where it is connected and disconnected: this control plane's web app, when it has one. */
|
|
390
|
+
page: z.string().optional()
|
|
391
|
+
});
|
|
392
|
+
var IntegrationSchema = z.object({
|
|
393
|
+
/** The slug it belongs to: a user's or an org's. */
|
|
394
|
+
owner: z.string(),
|
|
395
|
+
/**
|
|
396
|
+
* Which one (`github`). A plain string, not the ids above: this is an answer, read by every released CLI
|
|
397
|
+
* and SDK, and one from before a new integration must still read the listing that has it.
|
|
398
|
+
*/
|
|
399
|
+
integration: z.string(),
|
|
400
|
+
connected: z.boolean(),
|
|
401
|
+
/** The rest is null while not connected. */
|
|
402
|
+
kind: IntegrationKindSchema.nullable(),
|
|
403
|
+
/** Whose account, as shown: the GitHub login. Never a secret. */
|
|
404
|
+
account: z.string().nullable(),
|
|
405
|
+
status: IntegrationStatusSchema.nullable(),
|
|
406
|
+
connectedBy: z.string().nullable(),
|
|
407
|
+
connectedAt: z.string().nullable(),
|
|
408
|
+
/** The last time a box was handed the credential (to the minute). */
|
|
409
|
+
lastUsedAt: z.string().nullable(),
|
|
410
|
+
/** Whether the caller may connect or disconnect it: the slug's own user, an org's owners. */
|
|
411
|
+
canManage: z.boolean()
|
|
412
|
+
});
|
|
413
|
+
var IntegrationConnectSchema = z.object({ url: z.string() });
|
|
414
|
+
var IntegrationCompleteRequestSchema = z.object({ code: z.string().min(1), state: z.string().min(1) });
|
|
415
|
+
var ClaudeConnectRequestSchema = z.object({
|
|
416
|
+
credential: z.string().trim().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/, "a Claude Code token or an Anthropic API key has only letters, digits, - and _: paste it again on one line, with nothing inside it")
|
|
417
|
+
});
|
|
418
|
+
var IntegrationIdentitySchema = z.object({ name: z.string(), email: z.string() });
|
|
419
|
+
var CREDENTIAL_REFUSALS = ["off", "not-connected", "needs-reconnect", "unavailable"];
|
|
420
|
+
var CredentialAnswerSchema = z.discriminatedUnion("ok", [
|
|
421
|
+
z.object({
|
|
422
|
+
ok: z.literal(true),
|
|
423
|
+
kind: IntegrationKindSchema,
|
|
424
|
+
token: z.string(),
|
|
425
|
+
/** When the token ends (ISO), for one that does (a GitHub App's hour). */
|
|
426
|
+
expiresAt: z.string().optional(),
|
|
427
|
+
identity: IntegrationIdentitySchema.optional()
|
|
428
|
+
}),
|
|
429
|
+
z.object({
|
|
430
|
+
ok: z.literal(false),
|
|
431
|
+
code: z.enum(CREDENTIAL_REFUSALS),
|
|
432
|
+
message: z.string(),
|
|
433
|
+
/** With `off`: whether the slug has it connected, so the box can say how to turn it on. */
|
|
434
|
+
connected: z.boolean().optional()
|
|
435
|
+
})
|
|
436
|
+
]);
|
|
437
|
+
var HostCredentialRequestSchema = z.object({ owner: z.string().min(1), box: z.string().min(1), integration: IntegrationIdSchema, probe: z.boolean().optional() });
|
|
438
|
+
var ConnectedAnswerSchema = z.object({ connected: z.boolean(), identity: IntegrationIdentitySchema.optional() });
|
|
439
|
+
var GuestRequestSchema = z.object({ op: z.literal("credential"), integration: IntegrationIdSchema });
|
|
352
440
|
|
|
353
441
|
// ../shared/src/sizes.ts
|
|
354
442
|
var SIZES = {
|
|
@@ -368,1073 +456,1096 @@ function parseMib(text2) {
|
|
|
368
456
|
}
|
|
369
457
|
|
|
370
458
|
// ../shared/src/api.ts
|
|
371
|
-
var SizeSchema =
|
|
459
|
+
var SizeSchema = z2.enum(SIZE_NAMES);
|
|
372
460
|
var BOX_SSH_USER = "kvbox";
|
|
373
|
-
var BoxStatusSchema =
|
|
374
|
-
var PortProtoSchema =
|
|
461
|
+
var BoxStatusSchema = z2.enum(["running", "standby", "hibernated", "stopped", "unknown"]);
|
|
462
|
+
var PortProtoSchema = z2.enum(["tcp", "udp"]);
|
|
375
463
|
var MAX_BOX_PORTS = 16;
|
|
376
|
-
var PortForwardSchema =
|
|
377
|
-
guestPort:
|
|
378
|
-
hostPort:
|
|
464
|
+
var PortForwardSchema = z2.object({
|
|
465
|
+
guestPort: z2.number().int().min(1).max(65535),
|
|
466
|
+
hostPort: z2.number().int(),
|
|
379
467
|
proto: PortProtoSchema,
|
|
380
468
|
/** The host's public address; only the control plane fills it in, as for `ssh`. */
|
|
381
|
-
address:
|
|
469
|
+
address: z2.string().optional(),
|
|
382
470
|
/**
|
|
383
471
|
* Closed but kept (#173): nothing reaches the box through it, and the host port stays the box's, so
|
|
384
472
|
* publishing the same box port again opens the same number. Absent: open while the box runs.
|
|
385
473
|
*/
|
|
386
|
-
closed:
|
|
474
|
+
closed: z2.literal(true).optional()
|
|
387
475
|
});
|
|
388
|
-
var PortsRequest =
|
|
389
|
-
ports:
|
|
476
|
+
var PortsRequest = z2.object({
|
|
477
|
+
ports: z2.array(z2.object({ guestPort: z2.number().int().min(1).max(65535), proto: PortProtoSchema.optional() })).min(1).max(MAX_BOX_PORTS),
|
|
390
478
|
/** `DELETE` only (#173): close the ports but keep their host ports for the box (`closed`). */
|
|
391
|
-
keep:
|
|
392
|
-
});
|
|
393
|
-
var BoxPortSchema =
|
|
394
|
-
var BoxLinkSchema =
|
|
395
|
-
var LinkRequest =
|
|
396
|
-
var ClaimSubdomainRequest =
|
|
397
|
-
var SubdomainPortRequest =
|
|
398
|
-
var SubdomainRouteRequest =
|
|
399
|
-
var SubdomainSchema =
|
|
400
|
-
owner:
|
|
401
|
-
box:
|
|
402
|
-
subdomain:
|
|
479
|
+
keep: z2.boolean().optional()
|
|
480
|
+
});
|
|
481
|
+
var BoxPortSchema = z2.number().int().min(1).max(65535);
|
|
482
|
+
var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
|
|
483
|
+
var LinkRequest = z2.object({ from: z2.string().min(1), fromOwner: z2.string().optional(), port: BoxPortSchema });
|
|
484
|
+
var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
|
|
485
|
+
var SubdomainPortRequest = z2.object({ port: BoxPortSchema });
|
|
486
|
+
var SubdomainRouteRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
|
|
487
|
+
var SubdomainSchema = z2.object({
|
|
488
|
+
owner: z2.string(),
|
|
489
|
+
box: z2.string(),
|
|
490
|
+
subdomain: z2.string(),
|
|
403
491
|
port: BoxPortSchema,
|
|
404
|
-
url:
|
|
405
|
-
routes:
|
|
492
|
+
url: z2.string(),
|
|
493
|
+
routes: z2.array(z2.object({ name: z2.string(), port: BoxPortSchema, url: z2.string() }))
|
|
406
494
|
});
|
|
407
|
-
var AddDomainRequest =
|
|
408
|
-
var DomainSchema =
|
|
409
|
-
owner:
|
|
410
|
-
box:
|
|
411
|
-
domain:
|
|
495
|
+
var AddDomainRequest = z2.object({ domain: z2.string(), port: BoxPortSchema.optional() });
|
|
496
|
+
var DomainSchema = z2.object({
|
|
497
|
+
owner: z2.string(),
|
|
498
|
+
box: z2.string(),
|
|
499
|
+
domain: z2.string(),
|
|
412
500
|
port: BoxPortSchema,
|
|
413
|
-
status:
|
|
414
|
-
www:
|
|
415
|
-
url:
|
|
416
|
-
error:
|
|
417
|
-
records:
|
|
418
|
-
createdAt:
|
|
419
|
-
});
|
|
420
|
-
var WakeHookSchema =
|
|
421
|
-
id:
|
|
422
|
-
owner:
|
|
423
|
-
box:
|
|
424
|
-
url:
|
|
425
|
-
createdBy:
|
|
426
|
-
createdAt:
|
|
427
|
-
lastCalledAt:
|
|
428
|
-
});
|
|
429
|
-
var CreatedWakeHookSchema = WakeHookSchema.extend({ secret:
|
|
430
|
-
var WakeHookCallSchema =
|
|
431
|
-
box:
|
|
432
|
-
action:
|
|
433
|
-
reason:
|
|
501
|
+
status: z2.enum(["pending", "live"]),
|
|
502
|
+
www: z2.boolean(),
|
|
503
|
+
url: z2.string(),
|
|
504
|
+
error: z2.string().nullable(),
|
|
505
|
+
records: z2.array(z2.object({ type: z2.enum(["A", "TXT", "CNAME"]), name: z2.string(), value: z2.string() })),
|
|
506
|
+
createdAt: z2.string()
|
|
507
|
+
});
|
|
508
|
+
var WakeHookSchema = z2.object({
|
|
509
|
+
id: z2.string(),
|
|
510
|
+
owner: z2.string(),
|
|
511
|
+
box: z2.string(),
|
|
512
|
+
url: z2.string(),
|
|
513
|
+
createdBy: z2.string().nullable(),
|
|
514
|
+
createdAt: z2.string(),
|
|
515
|
+
lastCalledAt: z2.string().nullable()
|
|
516
|
+
});
|
|
517
|
+
var CreatedWakeHookSchema = WakeHookSchema.extend({ secret: z2.string() });
|
|
518
|
+
var WakeHookCallSchema = z2.object({
|
|
519
|
+
box: z2.string(),
|
|
520
|
+
action: z2.enum(["wake", "resume", "none"]),
|
|
521
|
+
reason: z2.string().optional()
|
|
434
522
|
});
|
|
435
523
|
var BACKUP_STATUSES = ["running", "ready", "failed"];
|
|
436
524
|
var BACKUP_KINDS = ["box", "volume"];
|
|
437
|
-
var BackupSchema =
|
|
438
|
-
id:
|
|
439
|
-
owner:
|
|
440
|
-
box:
|
|
525
|
+
var BackupSchema = z2.object({
|
|
526
|
+
id: z2.string(),
|
|
527
|
+
owner: z2.string(),
|
|
528
|
+
box: z2.string(),
|
|
441
529
|
/**
|
|
442
530
|
* The box it was taken of has been removed (#141): a box called `box` now is another box, which this backup
|
|
443
531
|
* never restores into; `kvbox new <name> --from-backup <id>` makes a box from it. Absent from a control plane
|
|
444
532
|
* before #141.
|
|
445
533
|
*/
|
|
446
|
-
boxRemoved:
|
|
447
|
-
status:
|
|
534
|
+
boxRemoved: z2.boolean().optional(),
|
|
535
|
+
status: z2.enum(BACKUP_STATUSES),
|
|
448
536
|
/** Why it failed; null otherwise. */
|
|
449
|
-
error:
|
|
537
|
+
error: z2.string().nullable(),
|
|
450
538
|
/** The image version the disk stacks on (a restore needs it on the host), and the image (absent: base). */
|
|
451
|
-
base:
|
|
452
|
-
image:
|
|
453
|
-
vcpu:
|
|
454
|
-
memMib:
|
|
539
|
+
base: z2.string().nullable(),
|
|
540
|
+
image: z2.string().optional(),
|
|
541
|
+
vcpu: z2.number().int().nullable(),
|
|
542
|
+
memMib: z2.number().int().nullable(),
|
|
455
543
|
/** The disk's size. */
|
|
456
|
-
diskBytes:
|
|
544
|
+
diskBytes: z2.number().int().nullable(),
|
|
457
545
|
/** What it holds: the slots that are not all zeros. */
|
|
458
|
-
dataBytes:
|
|
546
|
+
dataBytes: z2.number().int().nullable(),
|
|
459
547
|
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
460
|
-
uploadedBytes:
|
|
461
|
-
createdBy:
|
|
462
|
-
createdAt:
|
|
463
|
-
finishedAt:
|
|
464
|
-
});
|
|
465
|
-
var BackupLimitSchema =
|
|
466
|
-
perDay:
|
|
467
|
-
used:
|
|
468
|
-
nextAt:
|
|
469
|
-
});
|
|
470
|
-
var NamedBackupLimitSchema = BackupLimitSchema.extend({ owner:
|
|
471
|
-
var HostBackupRequest =
|
|
472
|
-
var HostBackupManifestSchema =
|
|
473
|
-
id:
|
|
474
|
-
sizeBytes:
|
|
475
|
-
chunks:
|
|
476
|
-
env:
|
|
477
|
-
base:
|
|
478
|
-
image:
|
|
479
|
-
vcpu:
|
|
480
|
-
memMib:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
var
|
|
548
|
+
uploadedBytes: z2.number().int().nullable(),
|
|
549
|
+
createdBy: z2.string().nullable(),
|
|
550
|
+
createdAt: z2.string(),
|
|
551
|
+
finishedAt: z2.string().nullable()
|
|
552
|
+
});
|
|
553
|
+
var BackupLimitSchema = z2.object({
|
|
554
|
+
perDay: z2.number().int(),
|
|
555
|
+
used: z2.number().int(),
|
|
556
|
+
nextAt: z2.string().nullable()
|
|
557
|
+
});
|
|
558
|
+
var NamedBackupLimitSchema = BackupLimitSchema.extend({ owner: z2.string(), name: z2.string() });
|
|
559
|
+
var HostBackupRequest = z2.object({ id: z2.string(), key: z2.string() });
|
|
560
|
+
var HostBackupManifestSchema = z2.object({
|
|
561
|
+
id: z2.string(),
|
|
562
|
+
sizeBytes: z2.number().int(),
|
|
563
|
+
chunks: z2.array(z2.string().nullable()),
|
|
564
|
+
env: z2.string().nullable(),
|
|
565
|
+
base: z2.string(),
|
|
566
|
+
image: z2.string().optional(),
|
|
567
|
+
vcpu: z2.number().int(),
|
|
568
|
+
memMib: z2.number().int(),
|
|
569
|
+
/** The box's integrations (#205), so a box made from the backup has them again. Absent: none, or an older host. */
|
|
570
|
+
integrations: z2.array(z2.string()).optional()
|
|
571
|
+
});
|
|
572
|
+
var HostUploadRequest = z2.object({ key: z2.string(), urls: z2.record(z2.string(), z2.string()), pin: z2.string().optional() });
|
|
573
|
+
var HostUploadResultSchema = z2.object({ chunks: z2.number().int(), bytes: z2.number().int(), sizes: z2.record(z2.string(), z2.number().int()) });
|
|
574
|
+
var HostRestoreRequest = z2.object({
|
|
485
575
|
/** The backup's id: its variables were sealed under it. */
|
|
486
|
-
id:
|
|
487
|
-
key:
|
|
488
|
-
sizeBytes:
|
|
489
|
-
base:
|
|
490
|
-
image:
|
|
491
|
-
env:
|
|
492
|
-
chunks:
|
|
576
|
+
id: z2.string(),
|
|
577
|
+
key: z2.string(),
|
|
578
|
+
sizeBytes: z2.number().int().positive(),
|
|
579
|
+
base: z2.string(),
|
|
580
|
+
image: z2.string().optional(),
|
|
581
|
+
env: z2.string().nullable(),
|
|
582
|
+
chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
|
|
493
583
|
/** The certificate fingerprint of the store the URLs point at (see HostUploadRequest). */
|
|
494
|
-
pin:
|
|
584
|
+
pin: z2.string().optional()
|
|
495
585
|
});
|
|
496
|
-
var VolumeBackupSchema =
|
|
497
|
-
id:
|
|
498
|
-
owner:
|
|
499
|
-
volume:
|
|
500
|
-
status:
|
|
586
|
+
var VolumeBackupSchema = z2.object({
|
|
587
|
+
id: z2.string(),
|
|
588
|
+
owner: z2.string(),
|
|
589
|
+
volume: z2.string(),
|
|
590
|
+
status: z2.enum(BACKUP_STATUSES),
|
|
501
591
|
/** Why it failed; null otherwise. */
|
|
502
|
-
error:
|
|
592
|
+
error: z2.string().nullable(),
|
|
503
593
|
/** The volume's size when taken. */
|
|
504
|
-
diskBytes:
|
|
594
|
+
diskBytes: z2.number().int().nullable(),
|
|
505
595
|
/** What it holds: the slots that are not all zeros. */
|
|
506
|
-
dataBytes:
|
|
596
|
+
dataBytes: z2.number().int().nullable(),
|
|
507
597
|
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
508
|
-
uploadedBytes:
|
|
509
|
-
createdBy:
|
|
510
|
-
createdAt:
|
|
511
|
-
finishedAt:
|
|
598
|
+
uploadedBytes: z2.number().int().nullable(),
|
|
599
|
+
createdBy: z2.string().nullable(),
|
|
600
|
+
createdAt: z2.string(),
|
|
601
|
+
finishedAt: z2.string().nullable()
|
|
512
602
|
});
|
|
513
|
-
var BackupScheduleSchema =
|
|
514
|
-
enabled:
|
|
603
|
+
var BackupScheduleSchema = z2.object({
|
|
604
|
+
enabled: z2.boolean(),
|
|
515
605
|
/** 0-23, UTC. Kept while it is off, so turning it on again keeps the hour. */
|
|
516
|
-
hour:
|
|
517
|
-
nextAt:
|
|
518
|
-
lastAt:
|
|
519
|
-
lastBackup:
|
|
520
|
-
lastError:
|
|
521
|
-
});
|
|
522
|
-
var SetBackupScheduleRequest =
|
|
523
|
-
var HostVolumeBackupManifestSchema =
|
|
524
|
-
var HostVolumeRestoreRequest =
|
|
525
|
-
id:
|
|
526
|
-
key:
|
|
527
|
-
sizeBytes:
|
|
528
|
-
chunks:
|
|
529
|
-
pin:
|
|
530
|
-
});
|
|
531
|
-
var BackupStoreSetupRequest =
|
|
532
|
-
var BackupStoreStatusSchema =
|
|
533
|
-
path:
|
|
534
|
-
bucket:
|
|
535
|
-
accessKey:
|
|
606
|
+
hour: z2.number().int().min(0).max(23),
|
|
607
|
+
nextAt: z2.string().nullable(),
|
|
608
|
+
lastAt: z2.string().nullable(),
|
|
609
|
+
lastBackup: z2.string().nullable(),
|
|
610
|
+
lastError: z2.string().nullable()
|
|
611
|
+
});
|
|
612
|
+
var SetBackupScheduleRequest = z2.object({ enabled: z2.boolean().optional(), hour: z2.number().int().min(0).max(23).optional() });
|
|
613
|
+
var HostVolumeBackupManifestSchema = z2.object({ id: z2.string(), sizeBytes: z2.number().int(), chunks: z2.array(z2.string().nullable()) });
|
|
614
|
+
var HostVolumeRestoreRequest = z2.object({
|
|
615
|
+
id: z2.string(),
|
|
616
|
+
key: z2.string(),
|
|
617
|
+
sizeBytes: z2.number().int().positive(),
|
|
618
|
+
chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
|
|
619
|
+
pin: z2.string().optional()
|
|
620
|
+
});
|
|
621
|
+
var BackupStoreSetupRequest = z2.object({ path: z2.string().min(1), force: z2.boolean().optional(), newStore: z2.boolean().optional() });
|
|
622
|
+
var BackupStoreStatusSchema = z2.object({
|
|
623
|
+
path: z2.string(),
|
|
624
|
+
bucket: z2.string(),
|
|
625
|
+
accessKey: z2.string(),
|
|
536
626
|
/** Whether Garage is running and can store. */
|
|
537
|
-
running:
|
|
627
|
+
running: z2.boolean(),
|
|
538
628
|
/** The filesystem the path is on. */
|
|
539
|
-
totalBytes:
|
|
540
|
-
freeBytes:
|
|
629
|
+
totalBytes: z2.number().int(),
|
|
630
|
+
freeBytes: z2.number().int(),
|
|
541
631
|
/** What the bucket holds, when Garage answers. */
|
|
542
|
-
objects:
|
|
543
|
-
storedBytes:
|
|
632
|
+
objects: z2.number().int().optional(),
|
|
633
|
+
storedBytes: z2.number().int().optional(),
|
|
544
634
|
/** Whether the control plane took the store's registration at setup. */
|
|
545
|
-
registered:
|
|
635
|
+
registered: z2.boolean().optional()
|
|
546
636
|
});
|
|
547
|
-
var BackupStoreRegistration =
|
|
548
|
-
var CloudBackupStoreSchema =
|
|
549
|
-
id:
|
|
637
|
+
var BackupStoreRegistration = z2.object({ bucket: z2.string().min(1), region: z2.string().min(1), accessKey: z2.string().min(1), secretKey: z2.string().min(1) });
|
|
638
|
+
var CloudBackupStoreSchema = z2.object({
|
|
639
|
+
id: z2.string(),
|
|
550
640
|
/** Null while no host serves it (its host left; it comes back when a host registers its key and secret again). */
|
|
551
|
-
host:
|
|
552
|
-
endpoint:
|
|
553
|
-
bucket:
|
|
554
|
-
accessKey:
|
|
555
|
-
createdAt:
|
|
641
|
+
host: z2.string().nullable(),
|
|
642
|
+
endpoint: z2.string().nullable(),
|
|
643
|
+
bucket: z2.string(),
|
|
644
|
+
accessKey: z2.string(),
|
|
645
|
+
createdAt: z2.string(),
|
|
556
646
|
/** The host answered a poll in the last minute and its Garage runs. */
|
|
557
|
-
live:
|
|
647
|
+
live: z2.boolean(),
|
|
558
648
|
/** From the host's last poll; null when it never reported a store. */
|
|
559
|
-
totalBytes:
|
|
560
|
-
freeBytes:
|
|
649
|
+
totalBytes: z2.number().int().nullable(),
|
|
650
|
+
freeBytes: z2.number().int().nullable(),
|
|
561
651
|
/** Ready backups kept here, and what their chunks take (encrypted, compressed). */
|
|
562
|
-
backups:
|
|
563
|
-
storedBytes:
|
|
652
|
+
backups: z2.number().int(),
|
|
653
|
+
storedBytes: z2.number().int(),
|
|
564
654
|
/** How many boxes have a ready backup here (a box and an earlier one of the same name count once), how many volumes (#168) and managed databases (#186). */
|
|
565
|
-
boxes:
|
|
566
|
-
volumes:
|
|
567
|
-
databases:
|
|
655
|
+
boxes: z2.number().int(),
|
|
656
|
+
volumes: z2.number().int(),
|
|
657
|
+
databases: z2.number().int(),
|
|
568
658
|
/** When the newest ready backup kept here finished; null when it keeps none. */
|
|
569
|
-
lastBackupAt:
|
|
659
|
+
lastBackupAt: z2.string().nullable()
|
|
570
660
|
});
|
|
571
|
-
var StoredItemSchema =
|
|
572
|
-
kind:
|
|
573
|
-
owner:
|
|
661
|
+
var StoredItemSchema = z2.object({
|
|
662
|
+
kind: z2.enum(BACKUP_KINDS),
|
|
663
|
+
owner: z2.string(),
|
|
574
664
|
/** The box's or volume's name; a managed database's (#186) for its hidden volume. */
|
|
575
|
-
name:
|
|
665
|
+
name: z2.string(),
|
|
576
666
|
/** The managed database's kind (`postgres`) when the volume is one's (#186); null otherwise. */
|
|
577
|
-
managed:
|
|
667
|
+
managed: z2.string().nullable(),
|
|
578
668
|
/** The host the box (or volume) is on now; null when it is gone (its backups stay). */
|
|
579
|
-
host:
|
|
669
|
+
host: z2.string().nullable(),
|
|
580
670
|
/** It is on the store's own host: losing that host loses it and its backups together. */
|
|
581
|
-
sameHost:
|
|
671
|
+
sameHost: z2.boolean(),
|
|
582
672
|
/** Ready backups kept here, and what they added to the store together (encrypted, compressed). */
|
|
583
|
-
backups:
|
|
584
|
-
uploadedBytes:
|
|
673
|
+
backups: z2.number().int(),
|
|
674
|
+
uploadedBytes: z2.number().int(),
|
|
585
675
|
/** The newest backup sent here, whatever became of it. */
|
|
586
|
-
latest:
|
|
676
|
+
latest: z2.object({ id: z2.string(), status: z2.enum(BACKUP_STATUSES), error: z2.string().nullable(), createdAt: z2.string() })
|
|
587
677
|
});
|
|
588
|
-
var FailedBackupSchema =
|
|
589
|
-
id:
|
|
590
|
-
owner:
|
|
678
|
+
var FailedBackupSchema = z2.object({
|
|
679
|
+
id: z2.string(),
|
|
680
|
+
owner: z2.string(),
|
|
591
681
|
/** What it was a backup of: a box or a volume (#168), and its name; a managed database's (#186) for its hidden volume. */
|
|
592
|
-
kind:
|
|
593
|
-
name:
|
|
682
|
+
kind: z2.enum(BACKUP_KINDS),
|
|
683
|
+
name: z2.string(),
|
|
594
684
|
/** The managed database's kind (`postgres`) when the volume is one's; null otherwise. */
|
|
595
|
-
managed:
|
|
596
|
-
error:
|
|
685
|
+
managed: z2.string().nullable(),
|
|
686
|
+
error: z2.string().nullable(),
|
|
597
687
|
/** The host that took it, and the host of the store it was going to; null when gone, or when it failed before a store was picked. */
|
|
598
|
-
host:
|
|
599
|
-
store:
|
|
600
|
-
createdAt:
|
|
688
|
+
host: z2.string().nullable(),
|
|
689
|
+
store: z2.string().nullable(),
|
|
690
|
+
createdAt: z2.string()
|
|
601
691
|
});
|
|
602
|
-
var MachineSchema =
|
|
692
|
+
var MachineSchema = z2.object({
|
|
603
693
|
/** Host-unique short id (the tap is `kv-<id>`). Missing only on a box made before ids that has not restarted since. */
|
|
604
|
-
id:
|
|
605
|
-
name:
|
|
694
|
+
id: z2.string(),
|
|
695
|
+
name: z2.string(),
|
|
606
696
|
/** Who the box belongs to; names are unique per owner. A bare name is local to the host, `user@control-plane` later. */
|
|
607
|
-
owner:
|
|
608
|
-
ip:
|
|
609
|
-
mac:
|
|
610
|
-
pid:
|
|
611
|
-
vcpu:
|
|
612
|
-
memMib:
|
|
613
|
-
diskBytes:
|
|
697
|
+
owner: z2.string(),
|
|
698
|
+
ip: z2.string(),
|
|
699
|
+
mac: z2.string(),
|
|
700
|
+
pid: z2.number().int().nullable(),
|
|
701
|
+
vcpu: z2.number().int(),
|
|
702
|
+
memMib: z2.number().int(),
|
|
703
|
+
diskBytes: z2.number().int(),
|
|
614
704
|
// the box's own writable disk, as the guest sees it
|
|
615
|
-
diskUsedBytes:
|
|
705
|
+
diskUsedBytes: z2.number().int(),
|
|
616
706
|
// what the box uses of it: the filesystem's own count, like the guest's `df` (#115)
|
|
617
707
|
/** What the disk's sparse file occupies on the host. Grows while the box runs, `kvbox stop` trims it back. Hosts before 0.5.42 do not send it. */
|
|
618
|
-
diskHostBytes:
|
|
619
|
-
base:
|
|
708
|
+
diskHostBytes: z2.number().int().optional(),
|
|
709
|
+
base: z2.string(),
|
|
620
710
|
// version of the image the box's overlay stacks on
|
|
621
711
|
/** The image (#87) when it is not the base one: `postgres`. `base` is then that image's version. */
|
|
622
|
-
image:
|
|
623
|
-
|
|
624
|
-
|
|
712
|
+
image: z2.string().optional(),
|
|
713
|
+
/**
|
|
714
|
+
* A newer version of the box's image on its host, the one `kvbox vm update` moves it onto. Only the control
|
|
715
|
+
* plane fills it in (from the host's last `/capacity`); absent while the box is on the newest one, or the host did not say.
|
|
716
|
+
*/
|
|
717
|
+
latestBase: z2.string().optional(),
|
|
718
|
+
createdAt: z2.string(),
|
|
719
|
+
source: z2.string(),
|
|
625
720
|
// "base", "snapshot:<owner/name>", "fork:<owner/name>" (#79) or "backup:<id>" (#141)
|
|
626
721
|
status: BoxStatusSchema,
|
|
627
722
|
/**
|
|
628
723
|
* Public TCP port on the host that reaches the box's SSH while it runs (#49). Only boxes made
|
|
629
724
|
* through a control plane have one; the control plane adds the host's address for `connect` (#21).
|
|
630
725
|
*/
|
|
631
|
-
sshPort:
|
|
726
|
+
sshPort: z2.number().int().optional(),
|
|
632
727
|
/**
|
|
633
728
|
* Where `ssh` reaches the box from outside: the host's public address and that port (#21). Only
|
|
634
729
|
* the control plane fills it in (a host does not know its own public address); absent for a box
|
|
635
730
|
* whose host reported no port or did not answer.
|
|
636
731
|
*/
|
|
637
|
-
ssh:
|
|
732
|
+
ssh: z2.object({ host: z2.string(), port: z2.number().int(), user: z2.string() }).optional(),
|
|
638
733
|
/** Box ports published on the host (#30). Absent: none. */
|
|
639
|
-
ports:
|
|
734
|
+
ports: z2.array(PortForwardSchema).optional(),
|
|
640
735
|
/** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /machines`. */
|
|
641
|
-
ownerKind:
|
|
736
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
642
737
|
/**
|
|
643
738
|
* The name of the host the box runs on. Only the control plane fills it in, on `GET /machines`: a box
|
|
644
739
|
* links to, and a volume attaches to, only a box on the same host.
|
|
645
740
|
*/
|
|
646
|
-
host:
|
|
741
|
+
host: z2.string().optional(),
|
|
647
742
|
/** The country code of that host (`RO`, `US`), when its admin gave one. Only the control plane fills it in. */
|
|
648
|
-
country:
|
|
743
|
+
country: z2.string().optional(),
|
|
649
744
|
/**
|
|
650
745
|
* The kind of managed service the box runs (`postgres`, `redis`, `storage`). Only an admin's
|
|
651
746
|
* `GET /machines?all=1` lists such boxes, so a host's boxes add up; every other listing hides them.
|
|
652
747
|
*/
|
|
653
|
-
managed:
|
|
748
|
+
managed: z2.string().optional(),
|
|
654
749
|
/** Seconds without network traffic before the host hibernates the box (#47). Absent: never. */
|
|
655
|
-
autoHibernateSec:
|
|
750
|
+
autoHibernateSec: z2.number().int().positive().optional(),
|
|
656
751
|
/** A script inside the box that says it is idle (#102, exit 0): auto-hibernate asks it instead of watching the traffic. */
|
|
657
|
-
idleCheck:
|
|
752
|
+
idleCheck: z2.string().optional(),
|
|
658
753
|
/** Volumes attached to the box (#52), in drive order; each is mounted at `mountPath` while the box runs. Absent: none. */
|
|
659
|
-
volumes:
|
|
754
|
+
volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional(),
|
|
660
755
|
/** Boxes that may reach this one, each on one port (#98). Absent: none. */
|
|
661
|
-
links:
|
|
756
|
+
links: z2.array(BoxLinkSchema).optional(),
|
|
757
|
+
/**
|
|
758
|
+
* The integrations turned on for the box (#205, `github`): names only, the credential is fetched by the box
|
|
759
|
+
* each time it is needed. Absent: none. A host before integrations never sends it.
|
|
760
|
+
*/
|
|
761
|
+
integrations: z2.array(z2.string()).optional(),
|
|
662
762
|
/** How to reach what the box serves, its secrets masked (#87): `postgres://postgres:****@db.kvbox:5432/postgres`. */
|
|
663
|
-
url:
|
|
763
|
+
url: z2.string().optional(),
|
|
664
764
|
/**
|
|
665
765
|
* Only in what `POST /machines` answers, for an image that declares one (#87): how to reach what it
|
|
666
766
|
* serves, e.g. `postgres://postgres:<password>@db.kvbox:5432/postgres`. Holds the box's variables.
|
|
667
767
|
*/
|
|
668
|
-
connect:
|
|
768
|
+
connect: z2.string().optional()
|
|
669
769
|
});
|
|
670
|
-
var VolumeSchema =
|
|
770
|
+
var VolumeSchema = z2.object({
|
|
671
771
|
/** The host's 6-hex volume id (#91): the ledger's key, so a name removed and made again is two volumes. */
|
|
672
|
-
id:
|
|
673
|
-
name:
|
|
674
|
-
owner:
|
|
675
|
-
sizeGib:
|
|
772
|
+
id: z2.string(),
|
|
773
|
+
name: z2.string(),
|
|
774
|
+
owner: z2.string(),
|
|
775
|
+
sizeGib: z2.number().int(),
|
|
676
776
|
/** What the sparse file really occupies on the host. */
|
|
677
|
-
usedBytes:
|
|
678
|
-
attachedTo:
|
|
679
|
-
createdAt:
|
|
777
|
+
usedBytes: z2.number().int(),
|
|
778
|
+
attachedTo: z2.string().nullable(),
|
|
779
|
+
createdAt: z2.string(),
|
|
680
780
|
/** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /volumes`. */
|
|
681
|
-
ownerKind:
|
|
781
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
682
782
|
/** The name of the host the volume lives on; only the control plane fills it in. It attaches only to a box there. */
|
|
683
|
-
host:
|
|
783
|
+
host: z2.string().optional()
|
|
684
784
|
});
|
|
685
785
|
var MAX_VOLUME_GIB = 4096;
|
|
686
786
|
var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
687
787
|
var VOLUME_NAME_RULE = "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit";
|
|
688
|
-
var CreateVolumeRequest =
|
|
689
|
-
name:
|
|
690
|
-
sizeGib:
|
|
788
|
+
var CreateVolumeRequest = z2.object({
|
|
789
|
+
name: z2.string(),
|
|
790
|
+
sizeGib: z2.number().int().min(1).max(MAX_VOLUME_GIB),
|
|
691
791
|
/**
|
|
692
792
|
* Through a control plane (#91): the box this volume is for, so it is made on that box's host; the
|
|
693
793
|
* control plane requires it (a volume attaches only to a box on its own host, so one made for no box
|
|
694
794
|
* could never attach) and the CLI attaches right after. A host ignores it.
|
|
695
795
|
*/
|
|
696
|
-
box:
|
|
796
|
+
box: z2.string().optional()
|
|
697
797
|
});
|
|
698
|
-
var AttachVolumeRequest =
|
|
699
|
-
box:
|
|
798
|
+
var AttachVolumeRequest = z2.object({
|
|
799
|
+
box: z2.string()
|
|
700
800
|
});
|
|
701
|
-
var ResizeVolumeRequest =
|
|
702
|
-
sizeGib:
|
|
801
|
+
var ResizeVolumeRequest = z2.object({
|
|
802
|
+
sizeGib: z2.number().int().min(1).max(MAX_VOLUME_GIB)
|
|
703
803
|
});
|
|
704
|
-
var RunScriptRequest =
|
|
705
|
-
var ScriptOutputSchema =
|
|
804
|
+
var RunScriptRequest = z2.object({ input: z2.unknown().optional() });
|
|
805
|
+
var ScriptOutputSchema = z2.object({ output: z2.unknown() });
|
|
706
806
|
var BOX_RUN_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
707
|
-
var StartRunRequest =
|
|
708
|
-
id:
|
|
709
|
-
command:
|
|
807
|
+
var StartRunRequest = z2.object({
|
|
808
|
+
id: z2.string().regex(BOX_RUN_ID_RE),
|
|
809
|
+
command: z2.string().min(1).max(8192),
|
|
710
810
|
/** The command and everything it started are killed after this long. */
|
|
711
|
-
timeoutSec:
|
|
811
|
+
timeoutSec: z2.number().int().min(1).max(86400),
|
|
712
812
|
/**
|
|
713
813
|
* The caller will read the output back (`exec`, #188): the box's kvbox-agent must know `runOutput`
|
|
714
814
|
* (base v0.16.0+), which the host checks before the command starts, so an older box is `box-outdated`
|
|
715
815
|
* without having run anything.
|
|
716
816
|
*/
|
|
717
|
-
output:
|
|
817
|
+
output: z2.boolean().optional()
|
|
718
818
|
});
|
|
719
|
-
var StartRunAnswerSchema =
|
|
720
|
-
id:
|
|
819
|
+
var StartRunAnswerSchema = z2.object({
|
|
820
|
+
id: z2.string(),
|
|
721
821
|
/** False: a run of this id was already there. */
|
|
722
|
-
started:
|
|
822
|
+
started: z2.boolean(),
|
|
723
823
|
/** The box was asleep and this request woke it. */
|
|
724
|
-
woke:
|
|
824
|
+
woke: z2.boolean()
|
|
725
825
|
});
|
|
726
826
|
var BOX_RUN_STATES = ["running", "exited", "timeout", "unknown"];
|
|
727
|
-
var BoxRunSchema =
|
|
728
|
-
id:
|
|
729
|
-
state:
|
|
827
|
+
var BoxRunSchema = z2.object({
|
|
828
|
+
id: z2.string(),
|
|
829
|
+
state: z2.enum(BOX_RUN_STATES),
|
|
730
830
|
/** With `exited`; 128 + the signal for a command a signal ended. */
|
|
731
|
-
exitCode:
|
|
831
|
+
exitCode: z2.number().int().optional(),
|
|
732
832
|
/**
|
|
733
833
|
* With `exited` and `timeout`: how long the command itself ran, by the box's own clock (base v0.15.1
|
|
734
834
|
* and later). The asker learns of the end seconds late, so its own count is too long.
|
|
735
835
|
*/
|
|
736
|
-
durationMs:
|
|
836
|
+
durationMs: z2.number().int().nonnegative().optional()
|
|
737
837
|
});
|
|
738
|
-
var RunRefusalSchema =
|
|
838
|
+
var RunRefusalSchema = z2.object({ error: z2.string(), code: z2.string().optional() });
|
|
739
839
|
var RUN_OUTPUT_MAX_BYTES = 1 << 20;
|
|
740
840
|
var RUN_STREAMS = ["stdout", "stderr"];
|
|
741
|
-
var RunOutputSchema =
|
|
742
|
-
id:
|
|
743
|
-
stream:
|
|
744
|
-
offset:
|
|
745
|
-
size:
|
|
746
|
-
data:
|
|
841
|
+
var RunOutputSchema = z2.object({
|
|
842
|
+
id: z2.string(),
|
|
843
|
+
stream: z2.enum(RUN_STREAMS),
|
|
844
|
+
offset: z2.number().int().nonnegative(),
|
|
845
|
+
size: z2.number().int().nonnegative(),
|
|
846
|
+
data: z2.string()
|
|
747
847
|
});
|
|
748
848
|
var DEFAULT_EXEC_TIMEOUT_SEC = 600;
|
|
749
|
-
var ExecRequest =
|
|
750
|
-
command:
|
|
849
|
+
var ExecRequest = z2.object({
|
|
850
|
+
command: z2.string().min(1).max(8192),
|
|
751
851
|
/** The command and everything it started are killed after this long (default DEFAULT_EXEC_TIMEOUT_SEC). */
|
|
752
|
-
timeoutSec:
|
|
852
|
+
timeoutSec: z2.number().int().min(1).max(86400).optional()
|
|
753
853
|
});
|
|
754
|
-
var ExecStartSchema =
|
|
755
|
-
id:
|
|
854
|
+
var ExecStartSchema = z2.object({
|
|
855
|
+
id: z2.string(),
|
|
756
856
|
/** The box was asleep and this request woke it. */
|
|
757
|
-
woke:
|
|
857
|
+
woke: z2.boolean()
|
|
758
858
|
});
|
|
759
|
-
var ExecSchema =
|
|
760
|
-
id:
|
|
761
|
-
state:
|
|
859
|
+
var ExecSchema = z2.object({
|
|
860
|
+
id: z2.string(),
|
|
861
|
+
state: z2.enum(BOX_RUN_STATES),
|
|
762
862
|
/** With `exited`; 128 + the signal for a command a signal ended. */
|
|
763
|
-
exitCode:
|
|
863
|
+
exitCode: z2.number().int().optional(),
|
|
764
864
|
/** With `exited` and `timeout`: how long the command itself ran. */
|
|
765
|
-
durationMs:
|
|
766
|
-
stdout:
|
|
767
|
-
stderr:
|
|
768
|
-
stdoutBytes:
|
|
769
|
-
stderrBytes:
|
|
770
|
-
truncated:
|
|
771
|
-
});
|
|
772
|
-
var EnvVarSchema =
|
|
773
|
-
name:
|
|
774
|
-
value:
|
|
775
|
-
secret:
|
|
776
|
-
updatedAt:
|
|
777
|
-
});
|
|
778
|
-
var BoxEnvSchema =
|
|
779
|
-
box:
|
|
780
|
-
vars:
|
|
781
|
-
});
|
|
782
|
-
var BoxEnvChangeSchema =
|
|
783
|
-
box:
|
|
784
|
-
name:
|
|
865
|
+
durationMs: z2.number().int().nonnegative().optional(),
|
|
866
|
+
stdout: z2.string().optional(),
|
|
867
|
+
stderr: z2.string().optional(),
|
|
868
|
+
stdoutBytes: z2.number().int().nonnegative().optional(),
|
|
869
|
+
stderrBytes: z2.number().int().nonnegative().optional(),
|
|
870
|
+
truncated: z2.boolean().optional()
|
|
871
|
+
});
|
|
872
|
+
var EnvVarSchema = z2.object({
|
|
873
|
+
name: z2.string(),
|
|
874
|
+
value: z2.string().optional(),
|
|
875
|
+
secret: z2.boolean(),
|
|
876
|
+
updatedAt: z2.string()
|
|
877
|
+
});
|
|
878
|
+
var BoxEnvSchema = z2.object({
|
|
879
|
+
box: z2.string(),
|
|
880
|
+
vars: z2.array(EnvVarSchema)
|
|
881
|
+
});
|
|
882
|
+
var BoxEnvChangeSchema = z2.object({
|
|
883
|
+
box: z2.string(),
|
|
884
|
+
name: z2.string(),
|
|
785
885
|
/** Whether the box is running now: the change waits for its next start. */
|
|
786
|
-
running:
|
|
886
|
+
running: z2.boolean()
|
|
787
887
|
});
|
|
788
|
-
var SetEnvRequest =
|
|
789
|
-
value:
|
|
790
|
-
secret:
|
|
888
|
+
var SetEnvRequest = z2.object({
|
|
889
|
+
value: z2.string(),
|
|
890
|
+
secret: z2.boolean().optional()
|
|
791
891
|
});
|
|
792
|
-
var EnvChangeSchema =
|
|
793
|
-
owner:
|
|
794
|
-
name:
|
|
795
|
-
boxes:
|
|
892
|
+
var EnvChangeSchema = z2.object({
|
|
893
|
+
owner: z2.string(),
|
|
894
|
+
name: z2.string(),
|
|
895
|
+
boxes: z2.number().int()
|
|
796
896
|
});
|
|
797
|
-
var HostEnvRequest =
|
|
798
|
-
version:
|
|
799
|
-
vars:
|
|
897
|
+
var HostEnvRequest = z2.object({
|
|
898
|
+
version: z2.number().int().min(0),
|
|
899
|
+
vars: z2.array(z2.object({ name: z2.string(), value: z2.string() }))
|
|
800
900
|
});
|
|
801
|
-
var HostEnvVersionsSchema =
|
|
802
|
-
var CreateMachineRequest =
|
|
803
|
-
name:
|
|
901
|
+
var HostEnvVersionsSchema = z2.array(z2.object({ owner: z2.string(), version: z2.number().int() }));
|
|
902
|
+
var CreateMachineRequest = z2.object({
|
|
903
|
+
name: z2.string().optional(),
|
|
804
904
|
/** Ignored over the local socket (the caller is the host owner); the control plane sets it over HTTPS. */
|
|
805
|
-
owner:
|
|
905
|
+
owner: z2.string().optional(),
|
|
806
906
|
size: SizeSchema.optional(),
|
|
807
|
-
from:
|
|
808
|
-
force:
|
|
907
|
+
from: z2.string().optional(),
|
|
908
|
+
force: z2.boolean().optional(),
|
|
809
909
|
/**
|
|
810
910
|
* Extra authorized_keys lines for the box, on top of the host's own key: the control plane sends
|
|
811
911
|
* its SSH CA as one `cert-authority …` line (#51). Written into the box's authorized_keys at every
|
|
812
912
|
* boot (#49); a host older than that ignores them.
|
|
813
913
|
*/
|
|
814
|
-
sshKeys:
|
|
914
|
+
sshKeys: z2.array(z2.string()).optional(),
|
|
815
915
|
/** Seconds without network traffic before the box is hibernated (#47); 0: never. Absent: the host's default. */
|
|
816
|
-
autoHibernateSec:
|
|
916
|
+
autoHibernateSec: z2.number().int().min(0).optional(),
|
|
817
917
|
/**
|
|
818
918
|
* Place the box on the host of this box (#98, `kvbox new --near`), so the two can be linked. Only the
|
|
819
919
|
* control plane reads it; a host has one place to put a box.
|
|
820
920
|
*/
|
|
821
|
-
near:
|
|
921
|
+
near: z2.string().optional(),
|
|
822
922
|
/**
|
|
823
923
|
* Place the box on a host in this country (`kvbox new --country romania`): a code or an English name,
|
|
824
924
|
* `@kvbox/shared/country`. Only the control plane reads it.
|
|
825
925
|
*/
|
|
826
|
-
country:
|
|
926
|
+
country: z2.string().optional(),
|
|
827
927
|
/**
|
|
828
928
|
* Place the box on the host of this name and nowhere else (`kvbox new --host kvbox2`, a hidden flag):
|
|
829
929
|
* an admin's, to try a host out. Only the control plane reads it, and refuses it from anyone else.
|
|
830
930
|
*/
|
|
831
|
-
host:
|
|
931
|
+
host: z2.string().optional(),
|
|
832
932
|
/** The image to boot (#87, `kvbox new --base postgres`). Absent: the base image. */
|
|
833
|
-
image:
|
|
933
|
+
image: z2.string().optional(),
|
|
834
934
|
/** The box's own environment variables (#87, `kvbox new -e NAME=value`), over its owner's. */
|
|
835
|
-
env:
|
|
935
|
+
env: z2.array(z2.object({ name: z2.string(), value: z2.string() })).optional(),
|
|
836
936
|
/**
|
|
837
937
|
* Start the box on this backup's disk (#141, `kvbox new --from-backup <id>`), a removed box's too: its image,
|
|
838
938
|
* version and variables come from the backup, its size too unless given. Only the control plane reads it.
|
|
839
939
|
*/
|
|
840
|
-
fromBackup:
|
|
940
|
+
fromBackup: z2.string().optional(),
|
|
941
|
+
/**
|
|
942
|
+
* The integrations turned on for the box (#205, `kvbox new --integration github`). Absent: none, or with
|
|
943
|
+
* `from` / `fromBackup` the list the snapshot or the backup was taken with.
|
|
944
|
+
*/
|
|
945
|
+
integrations: IntegrationListSchema.optional()
|
|
841
946
|
});
|
|
842
947
|
var HostFromBackupRequest = CreateMachineRequest.omit({ from: true, fromBackup: true, image: true, env: true }).extend({ backup: HostRestoreRequest });
|
|
843
|
-
var ForkMachineRequest =
|
|
844
|
-
name:
|
|
948
|
+
var ForkMachineRequest = z2.object({
|
|
949
|
+
name: z2.string().optional(),
|
|
845
950
|
/**
|
|
846
951
|
* The new box's slug, bare (`acme`): the control plane sends the target of `--org` here; the host
|
|
847
952
|
* qualifies it with the caller's realm. Absent: the source's owner. A CLI leaves it out.
|
|
848
953
|
*/
|
|
849
|
-
owner:
|
|
954
|
+
owner: z2.string().optional(),
|
|
850
955
|
/** A cold fork only: a warm one keeps the source's vCPU and memory. */
|
|
851
956
|
size: SizeSchema.optional(),
|
|
852
|
-
force:
|
|
957
|
+
force: z2.boolean().optional(),
|
|
853
958
|
/** As in CreateMachineRequest: the control plane's CA line for the new box's owner. */
|
|
854
|
-
sshKeys:
|
|
855
|
-
autoHibernateSec:
|
|
959
|
+
sshKeys: z2.array(z2.string()).optional(),
|
|
960
|
+
autoHibernateSec: z2.number().int().min(0).optional()
|
|
856
961
|
});
|
|
857
|
-
var SetSshKeysRequest =
|
|
858
|
-
sshKeys:
|
|
962
|
+
var SetSshKeysRequest = z2.object({
|
|
963
|
+
sshKeys: z2.array(z2.string())
|
|
859
964
|
});
|
|
860
|
-
var RescaleMachineRequest =
|
|
965
|
+
var RescaleMachineRequest = z2.object({
|
|
861
966
|
size: SizeSchema.optional(),
|
|
862
|
-
vcpu:
|
|
863
|
-
memMib:
|
|
864
|
-
diskGib:
|
|
967
|
+
vcpu: z2.number().int().min(1).max(64).optional(),
|
|
968
|
+
memMib: z2.number().int().min(256).optional(),
|
|
969
|
+
diskGib: z2.number().int().min(1).optional(),
|
|
865
970
|
/** Skip the capacity guard when a running box grows (#37). */
|
|
866
|
-
force:
|
|
971
|
+
force: z2.boolean().optional()
|
|
867
972
|
});
|
|
868
|
-
var StartMachineRequest =
|
|
869
|
-
force:
|
|
973
|
+
var StartMachineRequest = z2.object({
|
|
974
|
+
force: z2.boolean().optional()
|
|
870
975
|
});
|
|
871
|
-
var SetMachineRequest =
|
|
976
|
+
var SetMachineRequest = z2.object({
|
|
872
977
|
/** Seconds without network traffic before the box is hibernated (#47); 0: never. */
|
|
873
|
-
autoHibernateSec:
|
|
978
|
+
autoHibernateSec: z2.number().int().min(0).optional(),
|
|
874
979
|
/** The box's idle check (#102): an absolute path to a script inside the box, exit 0 = idle; "": none, back to network traffic. */
|
|
875
|
-
idleCheck:
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
980
|
+
idleCheck: z2.union([z2.literal(""), z2.string().max(255).regex(/^\/[^\0\n]*$/, "an absolute path inside the box")]).optional(),
|
|
981
|
+
/** The box's integrations (#205), the whole list: `[]` turns every one off. Applies at once, in any state. */
|
|
982
|
+
integrations: IntegrationListSchema.optional()
|
|
983
|
+
});
|
|
984
|
+
var SnapshotSchema = z2.object({
|
|
985
|
+
name: z2.string(),
|
|
986
|
+
owner: z2.string(),
|
|
987
|
+
source: z2.string(),
|
|
881
988
|
// the box it was taken from, as owner/name
|
|
882
|
-
base:
|
|
989
|
+
base: z2.string(),
|
|
883
990
|
// version of the image the overlay stacks on; a restore needs the same one
|
|
884
991
|
/** As in MachineSchema: the image when it is not the base one (#87). */
|
|
885
|
-
image:
|
|
886
|
-
vcpu:
|
|
887
|
-
memMib:
|
|
888
|
-
sizeBytes:
|
|
992
|
+
image: z2.string().optional(),
|
|
993
|
+
vcpu: z2.number().int(),
|
|
994
|
+
memMib: z2.number().int(),
|
|
995
|
+
sizeBytes: z2.number().int(),
|
|
889
996
|
// what vmstate + mem + overlay really occupy on the host
|
|
890
|
-
createdAt:
|
|
997
|
+
createdAt: z2.string()
|
|
891
998
|
});
|
|
892
|
-
var CreateSnapshotRequest =
|
|
893
|
-
box:
|
|
894
|
-
name:
|
|
999
|
+
var CreateSnapshotRequest = z2.object({
|
|
1000
|
+
box: z2.string(),
|
|
1001
|
+
name: z2.string(),
|
|
895
1002
|
/** Retake a snapshot under a name that exists (#83): the old one goes only once the new one is complete. */
|
|
896
|
-
replace:
|
|
897
|
-
});
|
|
898
|
-
var DiskCapacitySchema =
|
|
899
|
-
totalGib:
|
|
900
|
-
freeGib:
|
|
901
|
-
volumesGib:
|
|
902
|
-
volumesUsedGib:
|
|
903
|
-
headroomGib:
|
|
904
|
-
});
|
|
905
|
-
var CapacitySchema =
|
|
906
|
-
hostMemMib:
|
|
907
|
-
hostCores:
|
|
908
|
-
reservedMemMib:
|
|
909
|
-
reservedVcpu:
|
|
910
|
-
running:
|
|
1003
|
+
replace: z2.boolean().optional()
|
|
1004
|
+
});
|
|
1005
|
+
var DiskCapacitySchema = z2.object({
|
|
1006
|
+
totalGib: z2.number().int(),
|
|
1007
|
+
freeGib: z2.number().int(),
|
|
1008
|
+
volumesGib: z2.number().int(),
|
|
1009
|
+
volumesUsedGib: z2.number().int(),
|
|
1010
|
+
headroomGib: z2.number().int()
|
|
1011
|
+
});
|
|
1012
|
+
var CapacitySchema = z2.object({
|
|
1013
|
+
hostMemMib: z2.number().int(),
|
|
1014
|
+
hostCores: z2.number().int(),
|
|
1015
|
+
reservedMemMib: z2.number().int(),
|
|
1016
|
+
reservedVcpu: z2.number().int(),
|
|
1017
|
+
running: z2.number().int(),
|
|
911
1018
|
/**
|
|
912
1019
|
* MiB of RAM the host keeps back from its boxes (config.json `memHeadroomMib`). Absent on a kvbox-server
|
|
913
1020
|
* from before the setting, which keeps 2 GB (`OLD_HOST_MEM_HEADROOM_MIB`).
|
|
914
1021
|
*/
|
|
915
|
-
memHeadroomMib:
|
|
1022
|
+
memHeadroomMib: z2.number().int().optional(),
|
|
916
1023
|
/** Absent on a host from before volumes (#91): it cannot take one. */
|
|
917
1024
|
disk: DiskCapacitySchema.optional(),
|
|
918
1025
|
/**
|
|
919
1026
|
* The images a new box can be made from here (#87), with the version `new` uses; the base is `base`.
|
|
920
1027
|
* Absent on a host from before images: it has only the base.
|
|
921
1028
|
*/
|
|
922
|
-
images:
|
|
1029
|
+
images: z2.array(z2.object({ name: z2.string(), version: z2.string() })).optional(),
|
|
923
1030
|
/** kvbox-server's version, so the control plane's host list shows it without a call per host. Older servers omit it. */
|
|
924
|
-
version:
|
|
1031
|
+
version: z2.string().optional(),
|
|
925
1032
|
/** Present on a host set up as a backup store: the disk its Garage keeps chunks on, and whether Garage runs. */
|
|
926
|
-
backupStore:
|
|
1033
|
+
backupStore: z2.object({ totalBytes: z2.number().int(), freeBytes: z2.number().int(), running: z2.boolean() }).optional(),
|
|
927
1034
|
/** True on a kvbox-server that reaches a backup store by its certificate's `pin`; older ones omit it and cannot back up to a store. */
|
|
928
|
-
storeClient:
|
|
1035
|
+
storeClient: z2.boolean().optional(),
|
|
929
1036
|
/** True on a kvbox-server with `POST /machines/from-backup` (#141, `kvbox new --from-backup`); older ones omit it. */
|
|
930
|
-
fromBackup:
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
});
|
|
937
|
-
var
|
|
938
|
-
updatedAt:
|
|
1037
|
+
fromBackup: z2.boolean().optional(),
|
|
1038
|
+
/** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
|
|
1039
|
+
integrations: z2.boolean().optional(),
|
|
1040
|
+
/** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
|
|
1041
|
+
integrationIds: z2.array(z2.string()).optional()
|
|
1042
|
+
});
|
|
1043
|
+
var ImageSchema = z2.object({ name: z2.string(), version: z2.string().nullable() });
|
|
1044
|
+
var ImageIndexSchema = z2.object({
|
|
1045
|
+
updatedAt: z2.string(),
|
|
1046
|
+
images: z2.record(z2.string(), z2.object({ version: z2.string().min(1), minServer: z2.string().min(1).optional() }))
|
|
1047
|
+
});
|
|
1048
|
+
var LatestImagesSchema = z2.object({
|
|
1049
|
+
updatedAt: z2.string().nullable(),
|
|
939
1050
|
images: ImageIndexSchema.shape.images,
|
|
940
|
-
checkedAt:
|
|
941
|
-
});
|
|
942
|
-
var RecoveryReportSchema =
|
|
943
|
-
at:
|
|
944
|
-
booted:
|
|
945
|
-
leftStopped:
|
|
946
|
-
failed:
|
|
947
|
-
});
|
|
948
|
-
var HostUpdateSchema =
|
|
949
|
-
state:
|
|
950
|
-
startedAt:
|
|
951
|
-
finishedAt:
|
|
1051
|
+
checkedAt: z2.string().nullable()
|
|
1052
|
+
});
|
|
1053
|
+
var RecoveryReportSchema = z2.object({
|
|
1054
|
+
at: z2.string(),
|
|
1055
|
+
booted: z2.array(z2.string()),
|
|
1056
|
+
leftStopped: z2.array(z2.string()),
|
|
1057
|
+
failed: z2.array(z2.object({ box: z2.string(), error: z2.string() }))
|
|
1058
|
+
});
|
|
1059
|
+
var HostUpdateSchema = z2.object({
|
|
1060
|
+
state: z2.enum(["running", "done", "failed"]),
|
|
1061
|
+
startedAt: z2.string(),
|
|
1062
|
+
finishedAt: z2.string().nullable(),
|
|
952
1063
|
/** kvbox-server's version when the update started, and when it ended (null while running or when it failed before). */
|
|
953
|
-
from:
|
|
954
|
-
to:
|
|
955
|
-
error:
|
|
956
|
-
needsManual:
|
|
957
|
-
});
|
|
958
|
-
var HealthSchema =
|
|
959
|
-
ok:
|
|
960
|
-
version:
|
|
961
|
-
pid:
|
|
1064
|
+
from: z2.string(),
|
|
1065
|
+
to: z2.string().nullable(),
|
|
1066
|
+
error: z2.string().nullable(),
|
|
1067
|
+
needsManual: z2.array(z2.string())
|
|
1068
|
+
});
|
|
1069
|
+
var HealthSchema = z2.object({
|
|
1070
|
+
ok: z2.literal(true),
|
|
1071
|
+
version: z2.string(),
|
|
1072
|
+
pid: z2.number().int(),
|
|
962
1073
|
/** Base image version new boxes get (null when the host has no usable base image yet). */
|
|
963
|
-
base:
|
|
1074
|
+
base: z2.string().nullable(),
|
|
964
1075
|
/** Owner that boxes made over the local socket get (the Unix user running the server). */
|
|
965
|
-
owner:
|
|
1076
|
+
owner: z2.string(),
|
|
966
1077
|
/** The control plane this host joined (null when none). */
|
|
967
|
-
controlPlane:
|
|
1078
|
+
controlPlane: z2.object({
|
|
968
1079
|
/** Realm name, e.g. kvbox.sh. */
|
|
969
|
-
name:
|
|
970
|
-
url:
|
|
1080
|
+
name: z2.string(),
|
|
1081
|
+
url: z2.string(),
|
|
971
1082
|
/** Where this host answers the control plane. */
|
|
972
|
-
hostUrl:
|
|
1083
|
+
hostUrl: z2.string()
|
|
973
1084
|
}).nullable(),
|
|
974
1085
|
/** The relay this host reaches the internet through (#50); null when it has its own public address. Older servers omit it. */
|
|
975
|
-
relay:
|
|
976
|
-
name:
|
|
1086
|
+
relay: z2.object({
|
|
1087
|
+
name: z2.string(),
|
|
977
1088
|
/** The public IP the relay owns for this host. */
|
|
978
|
-
publicIp:
|
|
1089
|
+
publicIp: z2.string(),
|
|
979
1090
|
/** The relay's WireGuard endpoint the tunnel dials. */
|
|
980
|
-
endpoint:
|
|
1091
|
+
endpoint: z2.string(),
|
|
981
1092
|
/** Times the server redialed the tunnel since it started, because the relay stopped answering. Older servers omit them. */
|
|
982
|
-
restarts:
|
|
983
|
-
lastRestartAt:
|
|
1093
|
+
restarts: z2.number().int().optional(),
|
|
1094
|
+
lastRestartAt: z2.string().nullable().optional()
|
|
984
1095
|
}).nullable().optional(),
|
|
985
1096
|
/** Boxes brought back at the server's last start; null when there were none or it is still at it. Older servers omit it. */
|
|
986
1097
|
recovery: RecoveryReportSchema.nullable().optional(),
|
|
987
1098
|
/** The last self-update; null when none ran. Older servers omit it. */
|
|
988
1099
|
update: HostUpdateSchema.nullable().optional()
|
|
989
1100
|
});
|
|
990
|
-
var MachineUsageSchema =
|
|
991
|
-
name:
|
|
992
|
-
owner:
|
|
1101
|
+
var MachineUsageSchema = z2.object({
|
|
1102
|
+
name: z2.string(),
|
|
1103
|
+
owner: z2.string(),
|
|
993
1104
|
status: BoxStatusSchema,
|
|
994
|
-
window:
|
|
995
|
-
seconds:
|
|
996
|
-
running:
|
|
997
|
-
standby:
|
|
998
|
-
hibernated:
|
|
999
|
-
stopped:
|
|
1105
|
+
window: z2.object({ from: z2.string(), to: z2.string() }),
|
|
1106
|
+
seconds: z2.object({
|
|
1107
|
+
running: z2.number().int(),
|
|
1108
|
+
standby: z2.number().int(),
|
|
1109
|
+
hibernated: z2.number().int(),
|
|
1110
|
+
stopped: z2.number().int()
|
|
1000
1111
|
}),
|
|
1001
|
-
vcpuHours:
|
|
1002
|
-
ramGibHours:
|
|
1003
|
-
diskGibHours:
|
|
1004
|
-
cost:
|
|
1112
|
+
vcpuHours: z2.number(),
|
|
1113
|
+
ramGibHours: z2.number(),
|
|
1114
|
+
diskGibHours: z2.number(),
|
|
1115
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
|
|
1005
1116
|
/** Stops the server did not witness (Firecracker died, host rebooted) and dated to when it noticed. */
|
|
1006
|
-
estimatedStops:
|
|
1007
|
-
historyFrom:
|
|
1117
|
+
estimatedStops: z2.number().int(),
|
|
1118
|
+
historyFrom: z2.string().nullable()
|
|
1008
1119
|
});
|
|
1009
|
-
var GuestStatsSchema =
|
|
1120
|
+
var GuestStatsSchema = z2.object({
|
|
1010
1121
|
/** Load average over 1, 5 and 15 minutes. */
|
|
1011
|
-
load:
|
|
1012
|
-
cpus:
|
|
1013
|
-
memTotalMib:
|
|
1122
|
+
load: z2.tuple([z2.number(), z2.number(), z2.number()]),
|
|
1123
|
+
cpus: z2.number().int(),
|
|
1124
|
+
memTotalMib: z2.number().int(),
|
|
1014
1125
|
/** Total minus available: page cache counts as free. */
|
|
1015
|
-
memUsedMib:
|
|
1126
|
+
memUsedMib: z2.number().int(),
|
|
1016
1127
|
/** The box's root, which is its overlay disk: the box's own writes, not the shared base. */
|
|
1017
|
-
diskTotalBytes:
|
|
1018
|
-
diskUsedBytes:
|
|
1019
|
-
uptimeSec:
|
|
1128
|
+
diskTotalBytes: z2.number().int(),
|
|
1129
|
+
diskUsedBytes: z2.number().int(),
|
|
1130
|
+
uptimeSec: z2.number().int()
|
|
1020
1131
|
});
|
|
1021
|
-
var MachineStatsSchema =
|
|
1022
|
-
name:
|
|
1023
|
-
owner:
|
|
1132
|
+
var MachineStatsSchema = z2.object({
|
|
1133
|
+
name: z2.string(),
|
|
1134
|
+
owner: z2.string(),
|
|
1024
1135
|
stats: GuestStatsSchema.nullable()
|
|
1025
1136
|
});
|
|
1026
|
-
var UsageStatusSchema =
|
|
1137
|
+
var UsageStatusSchema = z2.enum([...BoxStatusSchema.options, "removed"]);
|
|
1027
1138
|
var BoxUsageSchema = MachineUsageSchema.omit({ window: true, status: true }).extend({
|
|
1028
1139
|
/** The host's box id; a name removed and recreated appears twice, with two ids. */
|
|
1029
|
-
id:
|
|
1140
|
+
id: z2.string(),
|
|
1030
1141
|
status: UsageStatusSchema,
|
|
1031
1142
|
/** Through a control plane: whether the owner slug is a user's or an org's (what `kvbox ls` shows). */
|
|
1032
|
-
ownerKind:
|
|
1143
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
1033
1144
|
/**
|
|
1034
1145
|
* Through a control plane: the username that made the box (#60), absent when the box is gone from
|
|
1035
1146
|
* the index (removed), was found by reconcile, or its maker was deleted. The ledger does not record it.
|
|
1036
1147
|
*/
|
|
1037
|
-
createdBy:
|
|
1148
|
+
createdBy: z2.string().optional()
|
|
1038
1149
|
});
|
|
1039
|
-
var VolumeUsageSchema =
|
|
1150
|
+
var VolumeUsageSchema = z2.object({
|
|
1040
1151
|
/** The host's volume id; a name removed and made again appears twice, with two ids. */
|
|
1041
|
-
id:
|
|
1042
|
-
name:
|
|
1043
|
-
owner:
|
|
1044
|
-
ownerKind:
|
|
1152
|
+
id: z2.string(),
|
|
1153
|
+
name: z2.string(),
|
|
1154
|
+
owner: z2.string(),
|
|
1155
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
1045
1156
|
/** The size at the end of the window (or when removed). */
|
|
1046
|
-
sizeGib:
|
|
1047
|
-
status:
|
|
1048
|
-
volumeHours:
|
|
1049
|
-
volumeGibHours:
|
|
1050
|
-
cost:
|
|
1051
|
-
historyFrom:
|
|
1052
|
-
});
|
|
1053
|
-
var CronUsageSchema =
|
|
1054
|
-
id:
|
|
1055
|
-
name:
|
|
1056
|
-
owner:
|
|
1057
|
-
ownerKind:
|
|
1058
|
-
status:
|
|
1059
|
-
hours:
|
|
1060
|
-
cost:
|
|
1157
|
+
sizeGib: z2.number().int(),
|
|
1158
|
+
status: z2.enum(["present", "removed"]),
|
|
1159
|
+
volumeHours: z2.number(),
|
|
1160
|
+
volumeGibHours: z2.number(),
|
|
1161
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
|
|
1162
|
+
historyFrom: z2.string().nullable()
|
|
1163
|
+
});
|
|
1164
|
+
var CronUsageSchema = z2.object({
|
|
1165
|
+
id: z2.string(),
|
|
1166
|
+
name: z2.string(),
|
|
1167
|
+
owner: z2.string(),
|
|
1168
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
1169
|
+
status: z2.enum(["present", "removed"]),
|
|
1170
|
+
hours: z2.number(),
|
|
1171
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
|
|
1061
1172
|
/** When it was made. */
|
|
1062
|
-
historyFrom:
|
|
1063
|
-
});
|
|
1064
|
-
var BackupUsageSchema =
|
|
1065
|
-
id:
|
|
1066
|
-
kind:
|
|
1067
|
-
name:
|
|
1068
|
-
owner:
|
|
1069
|
-
ownerKind:
|
|
1173
|
+
historyFrom: z2.string().nullable()
|
|
1174
|
+
});
|
|
1175
|
+
var BackupUsageSchema = z2.object({
|
|
1176
|
+
id: z2.string(),
|
|
1177
|
+
kind: z2.string(),
|
|
1178
|
+
name: z2.string(),
|
|
1179
|
+
owner: z2.string(),
|
|
1180
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
1070
1181
|
/** How many paid backups turned ready in the window. */
|
|
1071
|
-
count:
|
|
1072
|
-
cost:
|
|
1182
|
+
count: z2.number().int(),
|
|
1183
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() })
|
|
1073
1184
|
});
|
|
1074
|
-
var UsageDayItemSchema =
|
|
1075
|
-
id:
|
|
1076
|
-
name:
|
|
1077
|
-
owner:
|
|
1185
|
+
var UsageDayItemSchema = z2.object({
|
|
1186
|
+
id: z2.string(),
|
|
1187
|
+
name: z2.string(),
|
|
1188
|
+
owner: z2.string(),
|
|
1078
1189
|
/** Removed by the end of the report's window. */
|
|
1079
|
-
removed:
|
|
1080
|
-
cost:
|
|
1190
|
+
removed: z2.boolean(),
|
|
1191
|
+
cost: z2.number()
|
|
1081
1192
|
});
|
|
1082
|
-
var UsageDaySchema =
|
|
1193
|
+
var UsageDaySchema = z2.object({
|
|
1083
1194
|
/** `YYYY-MM-DD`, UTC. */
|
|
1084
|
-
date:
|
|
1085
|
-
from:
|
|
1086
|
-
to:
|
|
1087
|
-
cost:
|
|
1088
|
-
currency:
|
|
1089
|
-
boxes:
|
|
1090
|
-
volumes:
|
|
1195
|
+
date: z2.string(),
|
|
1196
|
+
from: z2.string(),
|
|
1197
|
+
to: z2.string(),
|
|
1198
|
+
cost: z2.number(),
|
|
1199
|
+
currency: z2.string(),
|
|
1200
|
+
boxes: z2.array(UsageDayItemSchema),
|
|
1201
|
+
volumes: z2.array(UsageDayItemSchema),
|
|
1091
1202
|
/** Object storage that existed that day (#182); absent on a day without any. */
|
|
1092
|
-
storage:
|
|
1203
|
+
storage: z2.array(UsageDayItemSchema).optional(),
|
|
1093
1204
|
/** Cron services that existed that day (#190); absent on a day without any. */
|
|
1094
|
-
cron:
|
|
1205
|
+
cron: z2.array(UsageDayItemSchema).optional(),
|
|
1095
1206
|
/** Paid backups that turned ready that day, summed per thing backed up (`id` is `<owner>/<kind>:<name>`); absent on a day without any. */
|
|
1096
|
-
backups:
|
|
1207
|
+
backups: z2.array(UsageDayItemSchema).optional()
|
|
1097
1208
|
});
|
|
1098
|
-
var UsageReportSchema =
|
|
1099
|
-
window:
|
|
1100
|
-
boxes:
|
|
1209
|
+
var UsageReportSchema = z2.object({
|
|
1210
|
+
window: z2.object({ from: z2.string(), to: z2.string() }),
|
|
1211
|
+
boxes: z2.array(BoxUsageSchema),
|
|
1101
1212
|
/** Absent from a side older than #91. */
|
|
1102
|
-
volumes:
|
|
1213
|
+
volumes: z2.array(VolumeUsageSchema).optional(),
|
|
1103
1214
|
/**
|
|
1104
1215
|
* Object storage (#182, control plane only): one row per storage a slug has or had, shaped like a
|
|
1105
1216
|
* volume's. `volumeHours` are the hours it existed, `volumeGibHours` those of the GiB beyond the
|
|
1106
1217
|
* included ones, `sizeGib` its whole size. Absent when there is none.
|
|
1107
1218
|
*/
|
|
1108
|
-
storage:
|
|
1219
|
+
storage: z2.array(VolumeUsageSchema).optional(),
|
|
1109
1220
|
/** Cron services (#190, control plane only): one row per service a slug has or had. Absent when there is none. */
|
|
1110
|
-
cron:
|
|
1221
|
+
cron: z2.array(CronUsageSchema).optional(),
|
|
1111
1222
|
/** Paid backups (control plane only): one row per box, volume or service backed up by hand in the window. Absent when there is none. */
|
|
1112
|
-
backups:
|
|
1223
|
+
backups: z2.array(BackupUsageSchema).optional(),
|
|
1113
1224
|
/** With `?by=day` only, oldest day first. */
|
|
1114
|
-
days:
|
|
1115
|
-
totals:
|
|
1225
|
+
days: z2.array(UsageDaySchema).optional(),
|
|
1226
|
+
totals: z2.object({
|
|
1116
1227
|
seconds: MachineUsageSchema.shape.seconds,
|
|
1117
|
-
vcpuHours:
|
|
1118
|
-
ramGibHours:
|
|
1119
|
-
diskGibHours:
|
|
1120
|
-
volumeHours:
|
|
1121
|
-
volumeGibHours:
|
|
1228
|
+
vcpuHours: z2.number(),
|
|
1229
|
+
ramGibHours: z2.number(),
|
|
1230
|
+
diskGibHours: z2.number(),
|
|
1231
|
+
volumeHours: z2.number().optional(),
|
|
1232
|
+
volumeGibHours: z2.number().optional(),
|
|
1122
1233
|
/** Boxes, volumes, object storage, cron services and paid backups together. */
|
|
1123
|
-
cost:
|
|
1234
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
|
|
1124
1235
|
})
|
|
1125
1236
|
});
|
|
1126
|
-
var UsageEventRowSchema =
|
|
1127
|
-
id:
|
|
1128
|
-
boxId:
|
|
1129
|
-
owner:
|
|
1130
|
-
name:
|
|
1131
|
-
at:
|
|
1132
|
-
state:
|
|
1133
|
-
vcpu:
|
|
1134
|
-
memMib:
|
|
1135
|
-
diskGib:
|
|
1136
|
-
by:
|
|
1137
|
-
});
|
|
1138
|
-
var UsageEventsResponseSchema =
|
|
1139
|
-
ledger:
|
|
1140
|
-
events:
|
|
1141
|
-
next:
|
|
1142
|
-
});
|
|
1143
|
-
var VolumeEventRowSchema =
|
|
1144
|
-
id:
|
|
1145
|
-
volumeId:
|
|
1146
|
-
owner:
|
|
1147
|
-
name:
|
|
1148
|
-
at:
|
|
1149
|
-
sizeGib:
|
|
1150
|
-
by:
|
|
1151
|
-
});
|
|
1152
|
-
var VolumeEventsResponseSchema =
|
|
1153
|
-
ledger:
|
|
1154
|
-
events:
|
|
1155
|
-
next:
|
|
1237
|
+
var UsageEventRowSchema = z2.object({
|
|
1238
|
+
id: z2.number().int(),
|
|
1239
|
+
boxId: z2.string(),
|
|
1240
|
+
owner: z2.string(),
|
|
1241
|
+
name: z2.string(),
|
|
1242
|
+
at: z2.string(),
|
|
1243
|
+
state: z2.enum(["running", "standby", "hibernated", "stopped"]),
|
|
1244
|
+
vcpu: z2.number().int(),
|
|
1245
|
+
memMib: z2.number().int(),
|
|
1246
|
+
diskGib: z2.number().int(),
|
|
1247
|
+
by: z2.string()
|
|
1248
|
+
});
|
|
1249
|
+
var UsageEventsResponseSchema = z2.object({
|
|
1250
|
+
ledger: z2.string().min(1),
|
|
1251
|
+
events: z2.array(UsageEventRowSchema),
|
|
1252
|
+
next: z2.number().int()
|
|
1253
|
+
});
|
|
1254
|
+
var VolumeEventRowSchema = z2.object({
|
|
1255
|
+
id: z2.number().int(),
|
|
1256
|
+
volumeId: z2.string(),
|
|
1257
|
+
owner: z2.string(),
|
|
1258
|
+
name: z2.string(),
|
|
1259
|
+
at: z2.string(),
|
|
1260
|
+
sizeGib: z2.number().int(),
|
|
1261
|
+
by: z2.enum(["create", "resize", "rm"])
|
|
1262
|
+
});
|
|
1263
|
+
var VolumeEventsResponseSchema = z2.object({
|
|
1264
|
+
ledger: z2.string().min(1),
|
|
1265
|
+
events: z2.array(VolumeEventRowSchema),
|
|
1266
|
+
next: z2.number().int()
|
|
1156
1267
|
});
|
|
1157
1268
|
var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated", "storage-outdated", "object-exists", "storage-waking"];
|
|
1158
|
-
var ApiErrorCodeSchema =
|
|
1159
|
-
var ApiErrorSchema =
|
|
1160
|
-
error:
|
|
1269
|
+
var ApiErrorCodeSchema = z2.enum(API_ERROR_CODES);
|
|
1270
|
+
var ApiErrorSchema = z2.object({
|
|
1271
|
+
error: z2.string(),
|
|
1161
1272
|
code: ApiErrorCodeSchema.optional()
|
|
1162
1273
|
});
|
|
1163
1274
|
var DEFAULT_CLOUD_URL = "https://api.kvbox.sh";
|
|
1164
1275
|
var ACTIVATED_BY = ["card", "admin"];
|
|
1165
|
-
var ActivatedBySchema =
|
|
1166
|
-
var CloudUserSchema =
|
|
1276
|
+
var ActivatedBySchema = z2.enum(ACTIVATED_BY);
|
|
1277
|
+
var CloudUserSchema = z2.object({
|
|
1167
1278
|
/** The handle: what hosts file boxes under (`<username>@<control plane>`). Lowercase, no `@` or `/`. */
|
|
1168
|
-
username:
|
|
1279
|
+
username: z2.string(),
|
|
1169
1280
|
/** Display name, free text ("Alexandru Ghiura"). */
|
|
1170
|
-
name:
|
|
1281
|
+
name: z2.string(),
|
|
1171
1282
|
/** Login identity, unique. */
|
|
1172
|
-
email:
|
|
1173
|
-
role:
|
|
1174
|
-
createdAt:
|
|
1283
|
+
email: z2.string(),
|
|
1284
|
+
role: z2.enum(["admin", "user"]),
|
|
1285
|
+
createdAt: z2.string(),
|
|
1175
1286
|
/**
|
|
1176
1287
|
* False until a card is on file or an admin activates the account (#74): then only `/me` and
|
|
1177
1288
|
* `/logout` answer. Admins are never gated. A control plane older than #74 does not send these and
|
|
1178
1289
|
* gates nobody, hence the defaults: a newer CLI must still parse its answers.
|
|
1179
1290
|
*/
|
|
1180
|
-
active:
|
|
1291
|
+
active: z2.boolean().default(true),
|
|
1181
1292
|
activatedBy: ActivatedBySchema.nullable().default(null),
|
|
1182
1293
|
/** When too many wrong passwords locked the account (#161); null when it is not locked. Older control planes omit it. */
|
|
1183
|
-
lockedAt:
|
|
1294
|
+
lockedAt: z2.string().nullable().default(null)
|
|
1184
1295
|
});
|
|
1185
1296
|
var ORG_ROLES = ["owner", "admin", "member"];
|
|
1186
|
-
var OrgRoleSchema =
|
|
1187
|
-
var CloudOrgSchema =
|
|
1188
|
-
slug:
|
|
1297
|
+
var OrgRoleSchema = z2.enum(ORG_ROLES);
|
|
1298
|
+
var CloudOrgSchema = z2.object({
|
|
1299
|
+
slug: z2.string(),
|
|
1189
1300
|
/** Display name; the slug never changes, this may. */
|
|
1190
|
-
name:
|
|
1191
|
-
createdAt:
|
|
1301
|
+
name: z2.string(),
|
|
1302
|
+
createdAt: z2.string(),
|
|
1192
1303
|
/** An org pays for itself (#74): off until it has a card or an admin activates it; its boxes are 402. Defaults as on CloudUser. */
|
|
1193
|
-
active:
|
|
1304
|
+
active: z2.boolean().default(true),
|
|
1194
1305
|
activatedBy: ActivatedBySchema.nullable().default(null)
|
|
1195
1306
|
});
|
|
1196
1307
|
var OrgMembershipSchema = CloudOrgSchema.extend({ role: OrgRoleSchema });
|
|
1197
|
-
var OrgMemberSchema =
|
|
1198
|
-
username:
|
|
1199
|
-
name:
|
|
1308
|
+
var OrgMemberSchema = z2.object({
|
|
1309
|
+
username: z2.string(),
|
|
1310
|
+
name: z2.string(),
|
|
1200
1311
|
role: OrgRoleSchema,
|
|
1201
|
-
addedAt:
|
|
1312
|
+
addedAt: z2.string()
|
|
1202
1313
|
});
|
|
1203
|
-
var OrgDetailSchema = CloudOrgSchema.extend({ members:
|
|
1204
|
-
var CreateOrgRequestSchema =
|
|
1205
|
-
slug:
|
|
1206
|
-
name:
|
|
1314
|
+
var OrgDetailSchema = CloudOrgSchema.extend({ members: z2.array(OrgMemberSchema) });
|
|
1315
|
+
var CreateOrgRequestSchema = z2.object({
|
|
1316
|
+
slug: z2.string().min(1),
|
|
1317
|
+
name: z2.string().min(1)
|
|
1207
1318
|
});
|
|
1208
|
-
var RenameOrgRequestSchema =
|
|
1209
|
-
var AddMemberRequestSchema =
|
|
1210
|
-
username:
|
|
1319
|
+
var RenameOrgRequestSchema = z2.object({ name: z2.string().min(1) });
|
|
1320
|
+
var AddMemberRequestSchema = z2.object({
|
|
1321
|
+
username: z2.string().min(1),
|
|
1211
1322
|
role: OrgRoleSchema.default("member")
|
|
1212
1323
|
});
|
|
1213
|
-
var SetRoleRequestSchema =
|
|
1214
|
-
var MeResponseSchema = CloudUserSchema.extend({ orgs:
|
|
1215
|
-
var BalanceSchema =
|
|
1216
|
-
slug:
|
|
1217
|
-
balance:
|
|
1218
|
-
currency:
|
|
1219
|
-
topUps:
|
|
1220
|
-
spent:
|
|
1324
|
+
var SetRoleRequestSchema = z2.object({ role: OrgRoleSchema });
|
|
1325
|
+
var MeResponseSchema = CloudUserSchema.extend({ orgs: z2.array(OrgMembershipSchema) });
|
|
1326
|
+
var BalanceSchema = z2.object({
|
|
1327
|
+
slug: z2.string(),
|
|
1328
|
+
balance: z2.number(),
|
|
1329
|
+
currency: z2.string(),
|
|
1330
|
+
topUps: z2.number(),
|
|
1331
|
+
spent: z2.number(),
|
|
1221
1332
|
/** The first moment usage counts from: the slug's first top-up or redeemed code; null when it has none. */
|
|
1222
|
-
since:
|
|
1333
|
+
since: z2.string().nullable(),
|
|
1223
1334
|
/** When the slug ran out and its boxes were hibernated (the `sweep-credit` job); null in good standing. Absent from a control plane older than this field. */
|
|
1224
|
-
suspendedAt:
|
|
1335
|
+
suspendedAt: z2.string().nullable().default(null),
|
|
1225
1336
|
/** Promo credit left (#163), already counted in `balance`; 0 with none. Absent from a control plane older than this field. */
|
|
1226
|
-
promo:
|
|
1337
|
+
promo: z2.number().default(0),
|
|
1227
1338
|
/** When the next promo credit expires; null with none left. */
|
|
1228
|
-
promoExpiresAt:
|
|
1339
|
+
promoExpiresAt: z2.string().nullable().default(null)
|
|
1229
1340
|
});
|
|
1230
|
-
var TopUpRequestSchema =
|
|
1231
|
-
slug:
|
|
1341
|
+
var TopUpRequestSchema = z2.object({
|
|
1342
|
+
slug: z2.string().min(1),
|
|
1232
1343
|
/** In the control plane's currency; negative corrects a mistake. */
|
|
1233
|
-
amount:
|
|
1234
|
-
note:
|
|
1235
|
-
});
|
|
1236
|
-
var TopUpSchema =
|
|
1237
|
-
id:
|
|
1238
|
-
slug:
|
|
1239
|
-
amount:
|
|
1240
|
-
currency:
|
|
1344
|
+
amount: z2.number().finite(),
|
|
1345
|
+
note: z2.string().max(200).optional()
|
|
1346
|
+
});
|
|
1347
|
+
var TopUpSchema = z2.object({
|
|
1348
|
+
id: z2.string(),
|
|
1349
|
+
slug: z2.string(),
|
|
1350
|
+
amount: z2.number(),
|
|
1351
|
+
currency: z2.string(),
|
|
1241
1352
|
/** `transfer` (#93): an owner moving credit to an org they own, a negative row on their slug and a positive one on the org's. */
|
|
1242
|
-
source:
|
|
1243
|
-
note:
|
|
1244
|
-
at:
|
|
1353
|
+
source: z2.enum(["admin", "card", "trial", "transfer"]),
|
|
1354
|
+
note: z2.string().nullable(),
|
|
1355
|
+
at: z2.string()
|
|
1245
1356
|
});
|
|
1246
|
-
var CreateCodeRequestSchema =
|
|
1357
|
+
var CreateCodeRequestSchema = z2.object({
|
|
1247
1358
|
/** In the control plane's currency, cents at most. */
|
|
1248
|
-
amount:
|
|
1359
|
+
amount: z2.number().positive().multipleOf(0.01, "amount is in cents at most"),
|
|
1249
1360
|
/** A day (`2026-12-11`, through the end of it, UTC) or an ISO time. The credit is gone then, and so is the code. */
|
|
1250
|
-
expiresAt:
|
|
1251
|
-
note:
|
|
1252
|
-
});
|
|
1253
|
-
var CreditCodeSchema =
|
|
1254
|
-
code:
|
|
1255
|
-
amount:
|
|
1256
|
-
currency:
|
|
1257
|
-
expiresAt:
|
|
1258
|
-
note:
|
|
1259
|
-
status:
|
|
1260
|
-
createdBy:
|
|
1261
|
-
createdAt:
|
|
1361
|
+
expiresAt: z2.string().min(1),
|
|
1362
|
+
note: z2.string().max(200).optional()
|
|
1363
|
+
});
|
|
1364
|
+
var CreditCodeSchema = z2.object({
|
|
1365
|
+
code: z2.string(),
|
|
1366
|
+
amount: z2.number(),
|
|
1367
|
+
currency: z2.string(),
|
|
1368
|
+
expiresAt: z2.string(),
|
|
1369
|
+
note: z2.string().nullable(),
|
|
1370
|
+
status: z2.enum(["unused", "redeemed", "expired", "revoked"]),
|
|
1371
|
+
createdBy: z2.string(),
|
|
1372
|
+
createdAt: z2.string(),
|
|
1262
1373
|
/** Who redeemed it and the slug the credit went to (their own, or an org they own). */
|
|
1263
|
-
redeemedBy:
|
|
1264
|
-
redeemedSlug:
|
|
1265
|
-
redeemedAt:
|
|
1266
|
-
revokedAt:
|
|
1267
|
-
});
|
|
1268
|
-
var RedeemRequestSchema =
|
|
1269
|
-
code:
|
|
1270
|
-
org:
|
|
1271
|
-
});
|
|
1272
|
-
var RedeemResponseSchema =
|
|
1273
|
-
slug:
|
|
1274
|
-
amount:
|
|
1275
|
-
currency:
|
|
1276
|
-
expiresAt:
|
|
1374
|
+
redeemedBy: z2.string().nullable(),
|
|
1375
|
+
redeemedSlug: z2.string().nullable(),
|
|
1376
|
+
redeemedAt: z2.string().nullable(),
|
|
1377
|
+
revokedAt: z2.string().nullable()
|
|
1378
|
+
});
|
|
1379
|
+
var RedeemRequestSchema = z2.object({
|
|
1380
|
+
code: z2.string().min(1).max(64),
|
|
1381
|
+
org: z2.string().min(1).optional()
|
|
1382
|
+
});
|
|
1383
|
+
var RedeemResponseSchema = z2.object({
|
|
1384
|
+
slug: z2.string(),
|
|
1385
|
+
amount: z2.number(),
|
|
1386
|
+
currency: z2.string(),
|
|
1387
|
+
expiresAt: z2.string(),
|
|
1277
1388
|
balance: BalanceSchema,
|
|
1278
1389
|
/** The slug was out of credit and this put it back above zero: it may start boxes again. */
|
|
1279
|
-
reinstated:
|
|
1390
|
+
reinstated: z2.boolean()
|
|
1280
1391
|
});
|
|
1281
1392
|
var TOP_UP_AMOUNTS = [10, 25, 50, 100];
|
|
1282
|
-
var BillingInfoSchema =
|
|
1283
|
-
card:
|
|
1284
|
-
cardInUse:
|
|
1393
|
+
var BillingInfoSchema = z2.object({
|
|
1394
|
+
card: z2.object({ brand: z2.string(), last4: z2.string() }).nullable(),
|
|
1395
|
+
cardInUse: z2.boolean(),
|
|
1285
1396
|
balance: BalanceSchema
|
|
1286
1397
|
});
|
|
1287
|
-
var BillingRedirectSchema =
|
|
1288
|
-
var TopUpCheckoutRequestSchema =
|
|
1289
|
-
amount:
|
|
1398
|
+
var BillingRedirectSchema = z2.object({ url: z2.string() });
|
|
1399
|
+
var TopUpCheckoutRequestSchema = z2.object({
|
|
1400
|
+
amount: z2.literal(TOP_UP_AMOUNTS)
|
|
1290
1401
|
});
|
|
1291
|
-
var TransferRequestSchema =
|
|
1292
|
-
org:
|
|
1293
|
-
amount:
|
|
1402
|
+
var TransferRequestSchema = z2.object({
|
|
1403
|
+
org: z2.string().min(1),
|
|
1404
|
+
amount: z2.number().positive().multipleOf(0.01, "amount is in cents at most")
|
|
1294
1405
|
});
|
|
1295
|
-
var TransferResponseSchema =
|
|
1296
|
-
var LoginRequestSchema =
|
|
1297
|
-
email:
|
|
1298
|
-
password:
|
|
1299
|
-
publicKey:
|
|
1406
|
+
var TransferResponseSchema = z2.object({ from: BalanceSchema, to: BalanceSchema, activated: z2.boolean() });
|
|
1407
|
+
var LoginRequestSchema = z2.object({
|
|
1408
|
+
email: z2.string().min(1),
|
|
1409
|
+
password: z2.string().min(1),
|
|
1410
|
+
publicKey: z2.string().optional()
|
|
1300
1411
|
});
|
|
1301
|
-
var SignupRequestSchema =
|
|
1302
|
-
username:
|
|
1303
|
-
name:
|
|
1304
|
-
email:
|
|
1305
|
-
password:
|
|
1412
|
+
var SignupRequestSchema = z2.object({
|
|
1413
|
+
username: z2.string().min(1),
|
|
1414
|
+
name: z2.string().min(1),
|
|
1415
|
+
email: z2.string().min(1),
|
|
1416
|
+
password: z2.string().min(1)
|
|
1306
1417
|
});
|
|
1307
|
-
var LoginResponseSchema =
|
|
1308
|
-
token:
|
|
1418
|
+
var LoginResponseSchema = z2.object({
|
|
1419
|
+
token: z2.string(),
|
|
1309
1420
|
user: CloudUserSchema,
|
|
1310
|
-
sshCert:
|
|
1311
|
-
sshCertExpires:
|
|
1421
|
+
sshCert: z2.string().optional(),
|
|
1422
|
+
sshCertExpires: z2.string().optional(),
|
|
1312
1423
|
/** Whose boxes the certificate opens: `<slug>@<realm>` for the user and each org they are in (orgs phase 4). */
|
|
1313
|
-
sshCertPrincipals:
|
|
1424
|
+
sshCertPrincipals: z2.array(z2.string()).optional()
|
|
1314
1425
|
});
|
|
1315
1426
|
var DEVICE_LOGIN_PICKUP_SEC = 60;
|
|
1316
|
-
var DeviceLoginRequestSchema =
|
|
1427
|
+
var DeviceLoginRequestSchema = z2.object({
|
|
1317
1428
|
// Capped: anyone may open a login, and the key is stored until it expires (an RSA-16384 key is ~2.8 KB).
|
|
1318
|
-
publicKey:
|
|
1319
|
-
hostname:
|
|
1320
|
-
});
|
|
1321
|
-
var DeviceLoginStartSchema =
|
|
1322
|
-
deviceCode:
|
|
1323
|
-
userCode:
|
|
1324
|
-
verifyUrl:
|
|
1325
|
-
expiresIn:
|
|
1326
|
-
interval:
|
|
1327
|
-
});
|
|
1328
|
-
var DeviceLoginPollRequestSchema =
|
|
1329
|
-
var DeviceLoginPollSchema =
|
|
1330
|
-
|
|
1331
|
-
LoginResponseSchema.extend({ status:
|
|
1429
|
+
publicKey: z2.string().max(16384).optional(),
|
|
1430
|
+
hostname: z2.string().max(255).optional()
|
|
1431
|
+
});
|
|
1432
|
+
var DeviceLoginStartSchema = z2.object({
|
|
1433
|
+
deviceCode: z2.string(),
|
|
1434
|
+
userCode: z2.string(),
|
|
1435
|
+
verifyUrl: z2.string(),
|
|
1436
|
+
expiresIn: z2.number(),
|
|
1437
|
+
interval: z2.number()
|
|
1438
|
+
});
|
|
1439
|
+
var DeviceLoginPollRequestSchema = z2.object({ deviceCode: z2.string().min(1) });
|
|
1440
|
+
var DeviceLoginPollSchema = z2.union([
|
|
1441
|
+
z2.object({ status: z2.enum(["pending", "slow_down", "refused", "expired"]) }),
|
|
1442
|
+
LoginResponseSchema.extend({ status: z2.literal("approved") })
|
|
1332
1443
|
]);
|
|
1333
|
-
var DeviceLoginInfoSchema =
|
|
1334
|
-
userCode:
|
|
1335
|
-
hostname:
|
|
1444
|
+
var DeviceLoginInfoSchema = z2.object({
|
|
1445
|
+
userCode: z2.string(),
|
|
1446
|
+
hostname: z2.string(),
|
|
1336
1447
|
/** The address the request came from; null when the control plane could not tell. */
|
|
1337
|
-
ip:
|
|
1338
|
-
createdAt:
|
|
1339
|
-
expiresAt:
|
|
1448
|
+
ip: z2.string().nullable(),
|
|
1449
|
+
createdAt: z2.string(),
|
|
1450
|
+
expiresAt: z2.string()
|
|
1340
1451
|
});
|
|
1341
1452
|
var DEFAULT_API_KEY_DAYS = 90;
|
|
1342
1453
|
var API_KEY_NAME_RE = /^[a-z0-9][a-z0-9._-]{0,31}$/;
|
|
1343
|
-
var ApiKeySchema =
|
|
1344
|
-
name:
|
|
1345
|
-
createdAt:
|
|
1454
|
+
var ApiKeySchema = z2.object({
|
|
1455
|
+
name: z2.string(),
|
|
1456
|
+
createdAt: z2.string(),
|
|
1346
1457
|
/** Last request made with it (ISO); null: never used. */
|
|
1347
|
-
lastUsedAt:
|
|
1458
|
+
lastUsedAt: z2.string().nullable(),
|
|
1348
1459
|
/** When it stops working (ISO); null: never. */
|
|
1349
|
-
expiresAt:
|
|
1460
|
+
expiresAt: z2.string().nullable()
|
|
1350
1461
|
});
|
|
1351
|
-
var CreateApiKeyRequestSchema =
|
|
1352
|
-
name:
|
|
1353
|
-
expiresAt:
|
|
1462
|
+
var CreateApiKeyRequestSchema = z2.object({
|
|
1463
|
+
name: z2.string().regex(API_KEY_NAME_RE, "a key's name is lowercase letters, digits, '.', '_' or '-' (up to 32 characters)"),
|
|
1464
|
+
expiresAt: z2.iso.datetime({ offset: true }).nullable().optional()
|
|
1354
1465
|
});
|
|
1355
|
-
var CreatedApiKeySchema = ApiKeySchema.extend({ key:
|
|
1356
|
-
var SshCertRequestSchema =
|
|
1357
|
-
publicKey:
|
|
1466
|
+
var CreatedApiKeySchema = ApiKeySchema.extend({ key: z2.string() });
|
|
1467
|
+
var SshCertRequestSchema = z2.object({
|
|
1468
|
+
publicKey: z2.string().min(1)
|
|
1358
1469
|
});
|
|
1359
|
-
var SshCertResponseSchema =
|
|
1360
|
-
cert:
|
|
1361
|
-
expires:
|
|
1362
|
-
principals:
|
|
1470
|
+
var SshCertResponseSchema = z2.object({
|
|
1471
|
+
cert: z2.string(),
|
|
1472
|
+
expires: z2.string(),
|
|
1473
|
+
principals: z2.array(z2.string())
|
|
1363
1474
|
});
|
|
1364
|
-
var SshCaResponseSchema =
|
|
1365
|
-
publicKey:
|
|
1475
|
+
var SshCaResponseSchema = z2.object({
|
|
1476
|
+
publicKey: z2.string(),
|
|
1366
1477
|
/** CAs replaced by `ca rotate` (#55), newest first; a box still holding one of these has not had `kvbox-server trust-ca` run on its host. */
|
|
1367
|
-
retired:
|
|
1478
|
+
retired: z2.array(z2.object({ publicKey: z2.string(), retiredAt: z2.string() })).optional()
|
|
1368
1479
|
});
|
|
1369
|
-
var HostSshCaResponseSchema =
|
|
1370
|
-
publicKey:
|
|
1480
|
+
var HostSshCaResponseSchema = z2.object({
|
|
1481
|
+
publicKey: z2.string()
|
|
1371
1482
|
});
|
|
1372
|
-
var CloudCaSchema =
|
|
1373
|
-
controlPlane:
|
|
1374
|
-
publicKey:
|
|
1375
|
-
fingerprint:
|
|
1483
|
+
var CloudCaSchema = z2.object({
|
|
1484
|
+
controlPlane: z2.string(),
|
|
1485
|
+
publicKey: z2.string(),
|
|
1486
|
+
fingerprint: z2.string()
|
|
1376
1487
|
});
|
|
1377
|
-
var TrustCaRequestSchema =
|
|
1378
|
-
publicKey:
|
|
1488
|
+
var TrustCaRequestSchema = z2.object({
|
|
1489
|
+
publicKey: z2.string().min(1)
|
|
1379
1490
|
});
|
|
1380
|
-
var SshKeysAppliedSchema =
|
|
1381
|
-
var TrustCaReportSchema =
|
|
1382
|
-
publicKey:
|
|
1383
|
-
fingerprint:
|
|
1491
|
+
var SshKeysAppliedSchema = z2.enum(["now", "start", "wake", "resume", "later"]);
|
|
1492
|
+
var TrustCaReportSchema = z2.object({
|
|
1493
|
+
publicKey: z2.string(),
|
|
1494
|
+
fingerprint: z2.string(),
|
|
1384
1495
|
/** The guest trusts the CA now. */
|
|
1385
|
-
updated:
|
|
1496
|
+
updated: z2.array(z2.string()),
|
|
1386
1497
|
/** meta.json has the line; the guest gets it at `when`. */
|
|
1387
|
-
pending:
|
|
1388
|
-
failed:
|
|
1498
|
+
pending: z2.array(z2.object({ box: z2.string(), when: SshKeysAppliedSchema, why: z2.string().optional() })),
|
|
1499
|
+
failed: z2.array(z2.object({ box: z2.string(), error: z2.string() })),
|
|
1389
1500
|
/** Local boxes, untouched: they trust the host's key only. */
|
|
1390
|
-
local:
|
|
1501
|
+
local: z2.number().int(),
|
|
1391
1502
|
/** Cloud boxes made without a CA line (a managed service's, #173), untouched: no certificate opens them. Absent from older servers. */
|
|
1392
|
-
skipped:
|
|
1393
|
-
});
|
|
1394
|
-
var HostJoinRequestSchema =
|
|
1395
|
-
token:
|
|
1396
|
-
name:
|
|
1397
|
-
url:
|
|
1398
|
-
fingerprint:
|
|
1399
|
-
publicAddress:
|
|
1503
|
+
skipped: z2.array(z2.string()).optional()
|
|
1504
|
+
});
|
|
1505
|
+
var HostJoinRequestSchema = z2.object({
|
|
1506
|
+
token: z2.string().min(1),
|
|
1507
|
+
name: z2.string().min(1),
|
|
1508
|
+
url: z2.string().url(),
|
|
1509
|
+
fingerprint: z2.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
|
|
1510
|
+
publicAddress: z2.string().min(1),
|
|
1400
1511
|
/** Where the host is (`kvbox-server join --country`): a code or an English name. */
|
|
1401
|
-
country:
|
|
1402
|
-
});
|
|
1403
|
-
var HostJoinResponseSchema =
|
|
1404
|
-
hostSecret:
|
|
1405
|
-
controlPlane:
|
|
1406
|
-
});
|
|
1407
|
-
var CloudHostSchema =
|
|
1408
|
-
name:
|
|
1409
|
-
url:
|
|
1410
|
-
publicAddress:
|
|
1411
|
-
joinedAt:
|
|
1412
|
-
lastSeenAt:
|
|
1512
|
+
country: z2.string().optional()
|
|
1513
|
+
});
|
|
1514
|
+
var HostJoinResponseSchema = z2.object({
|
|
1515
|
+
hostSecret: z2.string(),
|
|
1516
|
+
controlPlane: z2.object({ name: z2.string() })
|
|
1517
|
+
});
|
|
1518
|
+
var CloudHostSchema = z2.object({
|
|
1519
|
+
name: z2.string(),
|
|
1520
|
+
url: z2.string(),
|
|
1521
|
+
publicAddress: z2.string(),
|
|
1522
|
+
joinedAt: z2.string(),
|
|
1523
|
+
lastSeenAt: z2.string().nullable(),
|
|
1413
1524
|
capacity: CapacitySchema.nullable(),
|
|
1414
1525
|
/** ISO 3166-1 alpha-2 code (`RO`), null when nobody said where the host is. */
|
|
1415
|
-
country:
|
|
1526
|
+
country: z2.string().nullable(),
|
|
1416
1527
|
/** The S3 region a storage made on this host answers to (`ro-west-1`); null: it takes no storage. */
|
|
1417
|
-
region:
|
|
1528
|
+
region: z2.string().nullable(),
|
|
1418
1529
|
/** kvbox-server's version as of the poller's last look (`capacity.version`); null before one, or for a server older than 0.5.45. */
|
|
1419
|
-
version:
|
|
1530
|
+
version: z2.string().nullable()
|
|
1420
1531
|
});
|
|
1421
|
-
var HostInfoSchema =
|
|
1532
|
+
var HostInfoSchema = z2.object({
|
|
1422
1533
|
host: CloudHostSchema,
|
|
1423
1534
|
health: HealthSchema.nullable(),
|
|
1424
|
-
error:
|
|
1535
|
+
error: z2.string().nullable()
|
|
1425
1536
|
});
|
|
1426
|
-
var HostPatchRequest =
|
|
1427
|
-
var CountrySchema =
|
|
1537
|
+
var HostPatchRequest = z2.object({ country: z2.string().nullable().optional(), region: z2.string().nullable().optional() }).refine((b) => b.country !== void 0 || b.region !== void 0, { message: "give country, region or both" });
|
|
1538
|
+
var CountrySchema = z2.object({ code: z2.string(), name: z2.string() });
|
|
1428
1539
|
|
|
1429
1540
|
// src/session.ts
|
|
1430
|
-
var SessionSchema =
|
|
1431
|
-
url:
|
|
1432
|
-
token:
|
|
1433
|
-
user:
|
|
1541
|
+
var SessionSchema = z3.object({
|
|
1542
|
+
url: z3.string(),
|
|
1543
|
+
token: z3.string(),
|
|
1544
|
+
user: z3.string(),
|
|
1434
1545
|
/** When the SSH certificate at paths().sshCert stops being accepted (ISO); absent before the first login with a key. */
|
|
1435
|
-
sshCertExpires:
|
|
1546
|
+
sshCertExpires: z3.string().optional(),
|
|
1436
1547
|
/** Whose boxes that certificate opens (`<slug>@<realm>`, the user and their orgs); absent with `sshCertExpires`. */
|
|
1437
|
-
sshCertPrincipals:
|
|
1548
|
+
sshCertPrincipals: z3.array(z3.string()).optional()
|
|
1438
1549
|
});
|
|
1439
1550
|
async function readSession(p = paths()) {
|
|
1440
1551
|
let text2;
|
|
@@ -1613,7 +1724,7 @@ import { setTimeout as sleep2 } from "timers/promises";
|
|
|
1613
1724
|
import { Agent, request } from "undici";
|
|
1614
1725
|
|
|
1615
1726
|
// ../sdk/src/machines.ts
|
|
1616
|
-
import { z as
|
|
1727
|
+
import { z as z4 } from "zod";
|
|
1617
1728
|
|
|
1618
1729
|
// ../sdk/src/errors.ts
|
|
1619
1730
|
var KvboxSdkError = class extends Error {
|
|
@@ -1725,7 +1836,7 @@ var Machines = class {
|
|
|
1725
1836
|
ports;
|
|
1726
1837
|
/** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
|
|
1727
1838
|
list(opts = {}) {
|
|
1728
|
-
return this.transport.request("GET", `/machines${listQuery(opts)}`,
|
|
1839
|
+
return this.transport.request("GET", `/machines${listQuery(opts)}`, z4.array(MachineSchema), { org: opts.org });
|
|
1729
1840
|
}
|
|
1730
1841
|
/**
|
|
1731
1842
|
* One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
|
|
@@ -1739,7 +1850,7 @@ var Machines = class {
|
|
|
1739
1850
|
async find(name, orgOpt, timeoutMs) {
|
|
1740
1851
|
const slash = name.indexOf("/");
|
|
1741
1852
|
const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
|
|
1742
|
-
const listing = await this.transport.request("GET", "/machines",
|
|
1853
|
+
const listing = await this.transport.request("GET", "/machines", z4.array(MachineSchema), { org, timeoutMs });
|
|
1743
1854
|
const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
|
|
1744
1855
|
if (named.length <= 1) {
|
|
1745
1856
|
if (named[0] !== void 0) return named[0];
|
|
@@ -1764,9 +1875,16 @@ var Machines = class {
|
|
|
1764
1875
|
}
|
|
1765
1876
|
return made;
|
|
1766
1877
|
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Change a box's settings; anything left out stays as it is. `integrations` is the whole list of
|
|
1880
|
+
* integrations turned on for the box (`["github"]`, `[]` for none): it applies at once, with no restart.
|
|
1881
|
+
*/
|
|
1882
|
+
set(name, settings, opts = {}) {
|
|
1883
|
+
return this.transport.request("POST", box(name, "/set"), MachineSchema, { body: settings, org: opts.org });
|
|
1884
|
+
}
|
|
1767
1885
|
/** Remove the box and its disk. */
|
|
1768
1886
|
async remove(name, opts = {}) {
|
|
1769
|
-
await this.transport.request("DELETE", box(name),
|
|
1887
|
+
await this.transport.request("DELETE", box(name), z4.undefined(), { org: opts.org });
|
|
1770
1888
|
}
|
|
1771
1889
|
/** Boot a stopped box. */
|
|
1772
1890
|
start(name, opts = {}) {
|
|
@@ -1916,7 +2034,7 @@ var slugOf2 = (owner) => {
|
|
|
1916
2034
|
};
|
|
1917
2035
|
|
|
1918
2036
|
// ../sdk/src/snapshots.ts
|
|
1919
|
-
import { z as
|
|
2037
|
+
import { z as z5 } from "zod";
|
|
1920
2038
|
var Snapshots = class {
|
|
1921
2039
|
constructor(transport) {
|
|
1922
2040
|
this.transport = transport;
|
|
@@ -1924,19 +2042,19 @@ var Snapshots = class {
|
|
|
1924
2042
|
transport;
|
|
1925
2043
|
/** Every snapshot the caller can read. */
|
|
1926
2044
|
list(opts = {}) {
|
|
1927
|
-
return this.transport.request("GET", `/snapshots${listQuery(opts)}`,
|
|
2045
|
+
return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z5.array(SnapshotSchema), { org: opts.org });
|
|
1928
2046
|
}
|
|
1929
2047
|
/** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
|
|
1930
2048
|
create(req, opts = {}) {
|
|
1931
2049
|
return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
|
|
1932
2050
|
}
|
|
1933
2051
|
async remove(name, opts = {}) {
|
|
1934
|
-
await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
2052
|
+
await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z5.undefined(), { org: opts.org });
|
|
1935
2053
|
}
|
|
1936
2054
|
};
|
|
1937
2055
|
|
|
1938
2056
|
// ../sdk/src/transport.ts
|
|
1939
|
-
import { z as
|
|
2057
|
+
import { z as z6 } from "zod";
|
|
1940
2058
|
var Transport = class {
|
|
1941
2059
|
baseUrl;
|
|
1942
2060
|
org;
|
|
@@ -2010,7 +2128,7 @@ var Transport = class {
|
|
|
2010
2128
|
}
|
|
2011
2129
|
}
|
|
2012
2130
|
};
|
|
2013
|
-
var LooseApiErrorSchema =
|
|
2131
|
+
var LooseApiErrorSchema = z6.object({ error: z6.string(), code: z6.string().optional() });
|
|
2014
2132
|
function safeJson(text2) {
|
|
2015
2133
|
try {
|
|
2016
2134
|
return JSON.parse(text2);
|
|
@@ -2027,8 +2145,21 @@ function errorCode(err) {
|
|
|
2027
2145
|
return void 0;
|
|
2028
2146
|
}
|
|
2029
2147
|
|
|
2148
|
+
// ../sdk/src/integrations.ts
|
|
2149
|
+
import { z as z7 } from "zod";
|
|
2150
|
+
var Integrations = class {
|
|
2151
|
+
constructor(transport) {
|
|
2152
|
+
this.transport = transport;
|
|
2153
|
+
}
|
|
2154
|
+
transport;
|
|
2155
|
+
/** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
|
|
2156
|
+
list(opts = {}) {
|
|
2157
|
+
return this.transport.request("GET", "/integrations", z7.array(IntegrationSchema), { org: opts.org });
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
|
|
2030
2161
|
// ../sdk/src/volumes.ts
|
|
2031
|
-
import { z as
|
|
2162
|
+
import { z as z8 } from "zod";
|
|
2032
2163
|
var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
|
|
2033
2164
|
var Volumes = class {
|
|
2034
2165
|
constructor(transport) {
|
|
@@ -2036,7 +2167,7 @@ var Volumes = class {
|
|
|
2036
2167
|
}
|
|
2037
2168
|
transport;
|
|
2038
2169
|
list(opts = {}) {
|
|
2039
|
-
return this.transport.request("GET", `/volumes${listQuery(opts)}`,
|
|
2170
|
+
return this.transport.request("GET", `/volumes${listQuery(opts)}`, z8.array(VolumeSchema), { org: opts.org });
|
|
2040
2171
|
}
|
|
2041
2172
|
/**
|
|
2042
2173
|
* Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
|
|
@@ -2059,7 +2190,7 @@ var Volumes = class {
|
|
|
2059
2190
|
}
|
|
2060
2191
|
/** Remove the volume and its data; it must be detached first. */
|
|
2061
2192
|
async remove(name, opts = {}) {
|
|
2062
|
-
await this.transport.request("DELETE", volume(name),
|
|
2193
|
+
await this.transport.request("DELETE", volume(name), z8.undefined(), { org: opts.org });
|
|
2063
2194
|
}
|
|
2064
2195
|
};
|
|
2065
2196
|
|
|
@@ -2080,6 +2211,7 @@ var Kvbox = class {
|
|
|
2080
2211
|
machines;
|
|
2081
2212
|
snapshots;
|
|
2082
2213
|
volumes;
|
|
2214
|
+
integrations;
|
|
2083
2215
|
transport;
|
|
2084
2216
|
constructor(opts = {}) {
|
|
2085
2217
|
this.transport = new Transport({
|
|
@@ -2092,6 +2224,7 @@ var Kvbox = class {
|
|
|
2092
2224
|
this.machines = new Machines(this.transport);
|
|
2093
2225
|
this.snapshots = new Snapshots(this.transport);
|
|
2094
2226
|
this.volumes = new Volumes(this.transport);
|
|
2227
|
+
this.integrations = new Integrations(this.transport);
|
|
2095
2228
|
}
|
|
2096
2229
|
/** The API this client talks to, without a trailing slash. */
|
|
2097
2230
|
get baseUrl() {
|
|
@@ -2107,35 +2240,35 @@ var Kvbox = class {
|
|
|
2107
2240
|
};
|
|
2108
2241
|
|
|
2109
2242
|
// src/client.ts
|
|
2110
|
-
import { z as
|
|
2243
|
+
import { z as z13 } from "zod";
|
|
2111
2244
|
|
|
2112
2245
|
// ../shared/src/usage.ts
|
|
2113
|
-
import { z as
|
|
2114
|
-
var PricingSchema =
|
|
2115
|
-
currency:
|
|
2116
|
-
vcpuHour:
|
|
2117
|
-
ramGibHour:
|
|
2118
|
-
diskGibHour:
|
|
2119
|
-
volumeHour:
|
|
2120
|
-
volumeGibHour:
|
|
2121
|
-
diskIncludedGib:
|
|
2246
|
+
import { z as z9 } from "zod";
|
|
2247
|
+
var PricingSchema = z9.object({
|
|
2248
|
+
currency: z9.string().min(1),
|
|
2249
|
+
vcpuHour: z9.number().nonnegative(),
|
|
2250
|
+
ramGibHour: z9.number().nonnegative(),
|
|
2251
|
+
diskGibHour: z9.number().nonnegative(),
|
|
2252
|
+
volumeHour: z9.number().nonnegative().default(0),
|
|
2253
|
+
volumeGibHour: z9.number().nonnegative().default(0),
|
|
2254
|
+
diskIncludedGib: z9.number().int().nonnegative().default(0),
|
|
2122
2255
|
/**
|
|
2123
2256
|
* Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
|
|
2124
2257
|
* hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
|
|
2125
2258
|
* A price list from before object storage charges nothing for it.
|
|
2126
2259
|
*/
|
|
2127
|
-
storageHour:
|
|
2128
|
-
storageGibHour:
|
|
2129
|
-
storageIncludedGib:
|
|
2260
|
+
storageHour: z9.number().nonnegative().default(0),
|
|
2261
|
+
storageGibHour: z9.number().nonnegative().default(0),
|
|
2262
|
+
storageIncludedGib: z9.number().int().nonnegative().default(0),
|
|
2130
2263
|
/** The cron service (#190): an hour of one cron service existing, whatever it holds or fires. A price list from before it charges nothing. */
|
|
2131
|
-
cronHour:
|
|
2264
|
+
cronHour: z9.number().nonnegative().default(0),
|
|
2132
2265
|
/**
|
|
2133
2266
|
* One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
|
|
2134
2267
|
* costs a flat price…"); a failed one and a scheduled one cost nothing. A price list from before it charges nothing.
|
|
2135
2268
|
*/
|
|
2136
|
-
backup:
|
|
2269
|
+
backup: z9.number().nonnegative().default(0)
|
|
2137
2270
|
});
|
|
2138
|
-
var PriceListSchema = PricingSchema.extend({ welcomeCredit:
|
|
2271
|
+
var PriceListSchema = PricingSchema.extend({ welcomeCredit: z9.number().nonnegative() });
|
|
2139
2272
|
var HOUR_MS = 36e5;
|
|
2140
2273
|
var round = (n, places) => Math.round(n * 10 ** places) / 10 ** places;
|
|
2141
2274
|
function costOf(t, pricing) {
|
|
@@ -2163,86 +2296,86 @@ function sumUsage(items, pricing) {
|
|
|
2163
2296
|
var DAY_MS = 24 * HOUR_MS;
|
|
2164
2297
|
|
|
2165
2298
|
// ../shared/src/managed.ts
|
|
2166
|
-
import { z as
|
|
2167
|
-
var PriceSchema =
|
|
2168
|
-
var ManagedCatalogEntrySchema =
|
|
2299
|
+
import { z as z10 } from "zod";
|
|
2300
|
+
var PriceSchema = z10.object({ perMonth: z10.number(), storagePerMonth: z10.number(), currency: z10.string() });
|
|
2301
|
+
var ManagedCatalogEntrySchema = z10.object({
|
|
2169
2302
|
/** The kind, as in `/managed/<kind>`: `postgres`. */
|
|
2170
|
-
kind:
|
|
2303
|
+
kind: z10.string(),
|
|
2171
2304
|
/** The CLI command for it: `pg` (`kvbox pg create …`). */
|
|
2172
|
-
command:
|
|
2173
|
-
title:
|
|
2174
|
-
description:
|
|
2305
|
+
command: z10.string(),
|
|
2306
|
+
title: z10.string(),
|
|
2307
|
+
description: z10.string(),
|
|
2175
2308
|
/** The version a new one runs, as shown: `18`. */
|
|
2176
|
-
version:
|
|
2309
|
+
version: z10.string(),
|
|
2177
2310
|
/** The port a linked box reaches it on. */
|
|
2178
|
-
port:
|
|
2311
|
+
port: z10.number().int(),
|
|
2179
2312
|
/** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
|
|
2180
|
-
publicPort:
|
|
2313
|
+
publicPort: z10.number().int(),
|
|
2181
2314
|
/** Its guide, as a URL. */
|
|
2182
|
-
docs:
|
|
2183
|
-
storage:
|
|
2315
|
+
docs: z10.string().optional(),
|
|
2316
|
+
storage: z10.object({ defaultGib: z10.number().int(), minGib: z10.number().int(), maxGib: z10.number().int() }),
|
|
2184
2317
|
/**
|
|
2185
2318
|
* What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
|
|
2186
2319
|
* flag and a form field each, all optional, `default` in words.
|
|
2187
2320
|
*/
|
|
2188
|
-
options:
|
|
2321
|
+
options: z10.array(z10.object({ name: z10.string(), title: z10.string(), description: z10.string(), default: z10.string() })),
|
|
2189
2322
|
/** A month of it running with the default storage, and each further GB of storage. */
|
|
2190
|
-
price: PriceSchema.extend({ storageGibPerMonth:
|
|
2323
|
+
price: PriceSchema.extend({ storageGibPerMonth: z10.number() }),
|
|
2191
2324
|
/** Whether a host answering now can run it. */
|
|
2192
|
-
available:
|
|
2325
|
+
available: z10.boolean()
|
|
2193
2326
|
});
|
|
2194
|
-
var CreateManagedRequest =
|
|
2195
|
-
name:
|
|
2327
|
+
var CreateManagedRequest = z10.object({
|
|
2328
|
+
name: z10.string(),
|
|
2196
2329
|
/** The kind's own options by name (its catalog entry lists them); the kind checks them. */
|
|
2197
|
-
options:
|
|
2198
|
-
password:
|
|
2199
|
-
storageGib:
|
|
2330
|
+
options: z10.record(z10.string(), z10.string()).optional(),
|
|
2331
|
+
password: z10.string().optional(),
|
|
2332
|
+
storageGib: z10.number().int().optional(),
|
|
2200
2333
|
/** Place it on the host of this box, so the box can be linked to it. */
|
|
2201
|
-
near:
|
|
2334
|
+
near: z10.string().optional(),
|
|
2202
2335
|
/**
|
|
2203
2336
|
* A backup of a database of the same kind and major version, of the same account (#186): the new
|
|
2204
2337
|
* service starts on its data, a removed service's included. Its settings (Postgres: database, user)
|
|
2205
2338
|
* are the backup's; the password is the new one.
|
|
2206
2339
|
*/
|
|
2207
|
-
fromBackup:
|
|
2340
|
+
fromBackup: z10.string().optional()
|
|
2208
2341
|
});
|
|
2209
|
-
var ManagedHealthSchema =
|
|
2342
|
+
var ManagedHealthSchema = z10.object({
|
|
2210
2343
|
/** Its first start has finished: it has set itself up on its storage. */
|
|
2211
|
-
ready:
|
|
2344
|
+
ready: z10.boolean(),
|
|
2212
2345
|
/** It accepts connections. */
|
|
2213
|
-
accepting:
|
|
2214
|
-
version:
|
|
2346
|
+
accepting: z10.boolean(),
|
|
2347
|
+
version: z10.string(),
|
|
2215
2348
|
/** The storage volume: what is used of it and its size. */
|
|
2216
|
-
storageUsedBytes:
|
|
2217
|
-
storageTotalBytes:
|
|
2349
|
+
storageUsedBytes: z10.number().optional(),
|
|
2350
|
+
storageTotalBytes: z10.number().optional(),
|
|
2218
2351
|
/** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
|
|
2219
|
-
facts:
|
|
2352
|
+
facts: z10.array(z10.object({ title: z10.string(), value: z10.string() }))
|
|
2220
2353
|
});
|
|
2221
|
-
var UrlsSchema =
|
|
2222
|
-
var ManagedSchema =
|
|
2223
|
-
kind:
|
|
2224
|
-
name:
|
|
2354
|
+
var UrlsSchema = z10.object({ private: z10.string(), public: z10.string().optional() });
|
|
2355
|
+
var ManagedSchema = z10.object({
|
|
2356
|
+
kind: z10.string(),
|
|
2357
|
+
name: z10.string(),
|
|
2225
2358
|
/** The owning slug, bare. */
|
|
2226
|
-
owner:
|
|
2227
|
-
ownerKind:
|
|
2359
|
+
owner: z10.string(),
|
|
2360
|
+
ownerKind: z10.enum(["user", "org"]),
|
|
2228
2361
|
/** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
|
|
2229
2362
|
status: BoxStatusSchema,
|
|
2230
2363
|
/** The catalog version: `18`. */
|
|
2231
|
-
version:
|
|
2364
|
+
version: z10.string(),
|
|
2232
2365
|
/** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
|
|
2233
|
-
settings:
|
|
2234
|
-
storageGib:
|
|
2366
|
+
settings: z10.record(z10.string(), z10.string()),
|
|
2367
|
+
storageGib: z10.number().int(),
|
|
2235
2368
|
/** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
|
|
2236
|
-
private:
|
|
2369
|
+
private: z10.object({ host: z10.string(), port: z10.number().int() }),
|
|
2237
2370
|
/** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
|
|
2238
|
-
public:
|
|
2371
|
+
public: z10.object({ host: z10.string(), port: z10.number().int() }).nullable(),
|
|
2239
2372
|
/** The boxes linked to it, as the caller would name them. */
|
|
2240
|
-
links:
|
|
2373
|
+
links: z10.array(z10.string()),
|
|
2241
2374
|
/** The name of the host it runs on, for `--near` and links. */
|
|
2242
|
-
host:
|
|
2243
|
-
country:
|
|
2244
|
-
createdBy:
|
|
2245
|
-
createdAt:
|
|
2375
|
+
host: z10.string(),
|
|
2376
|
+
country: z10.string().optional(),
|
|
2377
|
+
createdBy: z10.string().nullable(),
|
|
2378
|
+
createdAt: z10.string(),
|
|
2246
2379
|
/** Connection strings with the password as `****`. */
|
|
2247
2380
|
urls: UrlsSchema,
|
|
2248
2381
|
price: PriceSchema,
|
|
@@ -2251,230 +2384,230 @@ var ManagedSchema = z8.object({
|
|
|
2251
2384
|
/** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
|
|
2252
2385
|
health: ManagedHealthSchema.nullable().optional()
|
|
2253
2386
|
});
|
|
2254
|
-
var ManagedSecretSchema =
|
|
2387
|
+
var ManagedSecretSchema = z10.object({ password: z10.string(), urls: UrlsSchema });
|
|
2255
2388
|
var CreatedManagedSchema = ManagedSchema.extend({
|
|
2256
2389
|
secret: ManagedSecretSchema,
|
|
2257
2390
|
/** The backup it was made from (`fromBackup`), when it was. */
|
|
2258
|
-
fromBackup:
|
|
2259
|
-
});
|
|
2260
|
-
var ResetPasswordRequest =
|
|
2261
|
-
var SetPublicRequest =
|
|
2262
|
-
var ManagedLinkRequest =
|
|
2263
|
-
var GrowManagedRequest =
|
|
2264
|
-
var ManagedBackupSchema =
|
|
2265
|
-
id:
|
|
2266
|
-
owner:
|
|
2267
|
-
kind:
|
|
2268
|
-
name:
|
|
2269
|
-
version:
|
|
2270
|
-
status:
|
|
2391
|
+
fromBackup: z10.string().optional()
|
|
2392
|
+
});
|
|
2393
|
+
var ResetPasswordRequest = z10.object({ password: z10.string().optional() });
|
|
2394
|
+
var SetPublicRequest = z10.object({ on: z10.boolean() });
|
|
2395
|
+
var ManagedLinkRequest = z10.object({ box: z10.string() });
|
|
2396
|
+
var GrowManagedRequest = z10.object({ storageGib: z10.number().int() });
|
|
2397
|
+
var ManagedBackupSchema = z10.object({
|
|
2398
|
+
id: z10.string(),
|
|
2399
|
+
owner: z10.string(),
|
|
2400
|
+
kind: z10.string(),
|
|
2401
|
+
name: z10.string(),
|
|
2402
|
+
version: z10.string(),
|
|
2403
|
+
status: z10.enum(BACKUP_STATUSES),
|
|
2271
2404
|
/** Why it failed; null otherwise. */
|
|
2272
|
-
error:
|
|
2405
|
+
error: z10.string().nullable(),
|
|
2273
2406
|
/** The service's storage when taken. */
|
|
2274
|
-
diskBytes:
|
|
2407
|
+
diskBytes: z10.number().int().nullable(),
|
|
2275
2408
|
/** What it holds: the slots that are not all zeros. */
|
|
2276
|
-
dataBytes:
|
|
2409
|
+
dataBytes: z10.number().int().nullable(),
|
|
2277
2410
|
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
2278
|
-
uploadedBytes:
|
|
2411
|
+
uploadedBytes: z10.number().int().nullable(),
|
|
2279
2412
|
/** Who asked for it; for a scheduled one, the database's creator. */
|
|
2280
|
-
createdBy:
|
|
2413
|
+
createdBy: z10.string().nullable(),
|
|
2281
2414
|
/** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
|
|
2282
|
-
scheduled:
|
|
2283
|
-
createdAt:
|
|
2284
|
-
finishedAt:
|
|
2415
|
+
scheduled: z10.boolean().default(false),
|
|
2416
|
+
createdAt: z10.string(),
|
|
2417
|
+
finishedAt: z10.string().nullable()
|
|
2285
2418
|
});
|
|
2286
2419
|
|
|
2287
2420
|
// ../shared/src/cron.ts
|
|
2288
|
-
import { z as
|
|
2421
|
+
import { z as z11 } from "zod";
|
|
2289
2422
|
var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
|
|
2290
2423
|
var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
|
|
2291
2424
|
var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
|
|
2292
2425
|
var CRON_METHODS = ["GET", "POST"];
|
|
2293
2426
|
var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
|
|
2294
|
-
var CronServiceSchema =
|
|
2295
|
-
owner:
|
|
2296
|
-
ownerKind:
|
|
2297
|
-
name:
|
|
2427
|
+
var CronServiceSchema = z11.object({
|
|
2428
|
+
owner: z11.string(),
|
|
2429
|
+
ownerKind: z11.enum(["user", "org"]),
|
|
2430
|
+
name: z11.string(),
|
|
2298
2431
|
/** Runs kept per trigger. */
|
|
2299
|
-
keepRuns:
|
|
2300
|
-
triggers:
|
|
2301
|
-
createdBy:
|
|
2302
|
-
createdAt:
|
|
2432
|
+
keepRuns: z11.number().int(),
|
|
2433
|
+
triggers: z11.number().int(),
|
|
2434
|
+
createdBy: z11.string().nullable(),
|
|
2435
|
+
createdAt: z11.string(),
|
|
2303
2436
|
/** What it costs while it exists; on the answer to `POST /cron` only. */
|
|
2304
|
-
price:
|
|
2437
|
+
price: z11.object({ perMonth: z11.number(), currency: z11.string() }).optional()
|
|
2305
2438
|
});
|
|
2306
2439
|
var triggerCommon = {
|
|
2307
|
-
id:
|
|
2308
|
-
service:
|
|
2309
|
-
owner:
|
|
2440
|
+
id: z11.string(),
|
|
2441
|
+
service: z11.string(),
|
|
2442
|
+
owner: z11.string(),
|
|
2310
2443
|
/** The box it acts on; a trigger is removed with its box. */
|
|
2311
|
-
box:
|
|
2444
|
+
box: z11.string(),
|
|
2312
2445
|
/** Five fields, `minute hour day-of-month month day-of-week`. */
|
|
2313
|
-
expr:
|
|
2446
|
+
expr: z11.string(),
|
|
2314
2447
|
/** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
|
|
2315
|
-
timezone:
|
|
2448
|
+
timezone: z11.string(),
|
|
2316
2449
|
/** False: paused, it fires again when resumed. */
|
|
2317
|
-
enabled:
|
|
2450
|
+
enabled: z11.boolean(),
|
|
2318
2451
|
/** When it fires next (ISO); null while paused. */
|
|
2319
|
-
nextRunAt:
|
|
2320
|
-
lastRunAt:
|
|
2321
|
-
lastOutcome:
|
|
2322
|
-
createdBy:
|
|
2323
|
-
createdAt:
|
|
2452
|
+
nextRunAt: z11.string().nullable(),
|
|
2453
|
+
lastRunAt: z11.string().nullable(),
|
|
2454
|
+
lastOutcome: z11.enum(CRON_OUTCOMES).nullable(),
|
|
2455
|
+
createdBy: z11.string().nullable(),
|
|
2456
|
+
createdAt: z11.string()
|
|
2324
2457
|
};
|
|
2325
|
-
var CronHttpTriggerSchema =
|
|
2458
|
+
var CronHttpTriggerSchema = z11.object({
|
|
2326
2459
|
...triggerCommon,
|
|
2327
|
-
kind:
|
|
2328
|
-
method:
|
|
2329
|
-
port:
|
|
2460
|
+
kind: z11.literal("http"),
|
|
2461
|
+
method: z11.enum(CRON_METHODS),
|
|
2462
|
+
port: z11.number().int(),
|
|
2330
2463
|
/** Path and query, starting with `/`. */
|
|
2331
|
-
path:
|
|
2464
|
+
path: z11.string()
|
|
2332
2465
|
});
|
|
2333
|
-
var CronCommandTriggerSchema =
|
|
2466
|
+
var CronCommandTriggerSchema = z11.object({
|
|
2334
2467
|
...triggerCommon,
|
|
2335
|
-
kind:
|
|
2468
|
+
kind: z11.literal("command"),
|
|
2336
2469
|
/** Run by a login shell as the box's user, in its home. */
|
|
2337
|
-
command:
|
|
2470
|
+
command: z11.string(),
|
|
2338
2471
|
/** The command is stopped after this long. */
|
|
2339
|
-
timeoutSec:
|
|
2472
|
+
timeoutSec: z11.number().int()
|
|
2340
2473
|
});
|
|
2341
|
-
var CronTriggerSchema =
|
|
2342
|
-
var CronRunSchema =
|
|
2474
|
+
var CronTriggerSchema = z11.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
|
|
2475
|
+
var CronRunSchema = z11.object({
|
|
2343
2476
|
/** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
|
|
2344
|
-
scheduledFor:
|
|
2345
|
-
startedAt:
|
|
2477
|
+
scheduledFor: z11.string(),
|
|
2478
|
+
startedAt: z11.string(),
|
|
2346
2479
|
/** Null while `running`, and for a run that was never sent. */
|
|
2347
|
-
durationMs:
|
|
2480
|
+
durationMs: z11.number().int().nullable(),
|
|
2348
2481
|
/** The box's HTTP status; null when it never answered, and for a command. */
|
|
2349
|
-
status:
|
|
2482
|
+
status: z11.number().int().nullable(),
|
|
2350
2483
|
/** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
|
|
2351
|
-
exitCode:
|
|
2484
|
+
exitCode: z11.number().int().nullable(),
|
|
2352
2485
|
/** The files in the box that hold what a command printed (a shell pattern, `cron-<n>.*`); null for a request and for a command that never started. */
|
|
2353
|
-
output:
|
|
2354
|
-
outcome:
|
|
2486
|
+
output: z11.string().nullable(),
|
|
2487
|
+
outcome: z11.enum(CRON_OUTCOMES),
|
|
2355
2488
|
/** Why it did not end `ok`, in a line. */
|
|
2356
|
-
error:
|
|
2489
|
+
error: z11.string().nullable(),
|
|
2357
2490
|
/** The box was hibernated and this run woke it. */
|
|
2358
|
-
woke:
|
|
2491
|
+
woke: z11.boolean()
|
|
2359
2492
|
});
|
|
2360
|
-
var CronCatalogSchema =
|
|
2361
|
-
price:
|
|
2362
|
-
maxServices:
|
|
2363
|
-
maxTriggers:
|
|
2364
|
-
keepRuns:
|
|
2493
|
+
var CronCatalogSchema = z11.object({
|
|
2494
|
+
price: z11.object({ perMonth: z11.number(), currency: z11.string() }),
|
|
2495
|
+
maxServices: z11.number().int(),
|
|
2496
|
+
maxTriggers: z11.number().int(),
|
|
2497
|
+
keepRuns: z11.number().int(),
|
|
2365
2498
|
/** The shortest time between two runs of one trigger, in seconds. */
|
|
2366
|
-
minIntervalSeconds:
|
|
2499
|
+
minIntervalSeconds: z11.number().int(),
|
|
2367
2500
|
/** How long a box has to answer, in seconds. */
|
|
2368
|
-
timeoutSeconds:
|
|
2501
|
+
timeoutSeconds: z11.number().int(),
|
|
2369
2502
|
/** How long a command may run: unless the trigger says, and at most. */
|
|
2370
|
-
commandTimeoutSeconds:
|
|
2371
|
-
maxCommandTimeoutSeconds:
|
|
2372
|
-
docs:
|
|
2373
|
-
});
|
|
2374
|
-
var CreateCronServiceRequest =
|
|
2375
|
-
var CreateCronTriggerRequest =
|
|
2376
|
-
box:
|
|
2377
|
-
expr:
|
|
2378
|
-
timezone:
|
|
2503
|
+
commandTimeoutSeconds: z11.number().int(),
|
|
2504
|
+
maxCommandTimeoutSeconds: z11.number().int(),
|
|
2505
|
+
docs: z11.string().optional()
|
|
2506
|
+
});
|
|
2507
|
+
var CreateCronServiceRequest = z11.object({ name: z11.string() });
|
|
2508
|
+
var CreateCronTriggerRequest = z11.object({
|
|
2509
|
+
box: z11.string().min(1),
|
|
2510
|
+
expr: z11.string().min(1),
|
|
2511
|
+
timezone: z11.string().optional(),
|
|
2379
2512
|
/** A request: `port`, with `method` and `path`. */
|
|
2380
|
-
method:
|
|
2381
|
-
port:
|
|
2382
|
-
path:
|
|
2513
|
+
method: z11.enum(CRON_METHODS).optional(),
|
|
2514
|
+
port: z11.number().int().min(1).max(65535).optional(),
|
|
2515
|
+
path: z11.string().optional(),
|
|
2383
2516
|
/** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
|
|
2384
|
-
command:
|
|
2385
|
-
timeoutSec:
|
|
2517
|
+
command: z11.string().optional(),
|
|
2518
|
+
timeoutSec: z11.number().int().optional()
|
|
2386
2519
|
});
|
|
2387
|
-
var UpdateCronTriggerRequest =
|
|
2520
|
+
var UpdateCronTriggerRequest = z11.object({ enabled: z11.boolean() });
|
|
2388
2521
|
var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
|
|
2389
2522
|
|
|
2390
2523
|
// ../shared/src/storage.ts
|
|
2391
|
-
import { z as
|
|
2392
|
-
var RegionSchema =
|
|
2524
|
+
import { z as z12 } from "zod";
|
|
2525
|
+
var RegionSchema = z12.object({ name: z12.string(), country: z12.string().nullable() });
|
|
2393
2526
|
var MAX_PUBLIC_BUCKETS = 10;
|
|
2394
2527
|
var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
|
|
2395
|
-
var ObjectStorageSchema =
|
|
2396
|
-
owner:
|
|
2397
|
-
ownerKind:
|
|
2528
|
+
var ObjectStorageSchema = z12.object({
|
|
2529
|
+
owner: z12.string(),
|
|
2530
|
+
ownerKind: z12.enum(["user", "org"]),
|
|
2398
2531
|
/** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
|
|
2399
|
-
endpoint:
|
|
2532
|
+
endpoint: z12.string().nullable(),
|
|
2400
2533
|
/** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
|
|
2401
|
-
region:
|
|
2534
|
+
region: z12.string(),
|
|
2402
2535
|
/** The most it may hold. */
|
|
2403
|
-
sizeGib:
|
|
2536
|
+
sizeGib: z12.number().int(),
|
|
2404
2537
|
/** `running` when it answers; `unknown` while its host is not heard from. */
|
|
2405
2538
|
status: BoxStatusSchema,
|
|
2406
2539
|
/** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
|
|
2407
|
-
usedBytes:
|
|
2408
|
-
totalBytes:
|
|
2540
|
+
usedBytes: z12.number().optional(),
|
|
2541
|
+
totalBytes: z12.number().optional(),
|
|
2409
2542
|
/** With `?live=1`, when the storage answered: what each bucket holds. */
|
|
2410
|
-
bucketUsage:
|
|
2411
|
-
host:
|
|
2412
|
-
country:
|
|
2413
|
-
buckets:
|
|
2414
|
-
price:
|
|
2415
|
-
createdAt:
|
|
2416
|
-
});
|
|
2417
|
-
var BucketSchema =
|
|
2418
|
-
name:
|
|
2419
|
-
owner:
|
|
2420
|
-
ownerKind:
|
|
2421
|
-
endpoint:
|
|
2422
|
-
publicUrl:
|
|
2423
|
-
region:
|
|
2424
|
-
keys:
|
|
2425
|
-
objects:
|
|
2426
|
-
bytes:
|
|
2427
|
-
createdBy:
|
|
2428
|
-
createdAt:
|
|
2429
|
-
});
|
|
2430
|
-
var CreateBucketRequest =
|
|
2431
|
-
name:
|
|
2432
|
-
sizeGib:
|
|
2433
|
-
near:
|
|
2434
|
-
region:
|
|
2435
|
-
});
|
|
2436
|
-
var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated:
|
|
2543
|
+
bucketUsage: z12.array(z12.object({ name: z12.string(), objects: z12.number(), bytes: z12.number() })).optional(),
|
|
2544
|
+
host: z12.string(),
|
|
2545
|
+
country: z12.string().optional(),
|
|
2546
|
+
buckets: z12.number().int(),
|
|
2547
|
+
price: z12.object({ perMonth: z12.number(), currency: z12.string() }),
|
|
2548
|
+
createdAt: z12.string()
|
|
2549
|
+
});
|
|
2550
|
+
var BucketSchema = z12.object({
|
|
2551
|
+
name: z12.string(),
|
|
2552
|
+
owner: z12.string(),
|
|
2553
|
+
ownerKind: z12.enum(["user", "org"]),
|
|
2554
|
+
endpoint: z12.string().nullable(),
|
|
2555
|
+
publicUrl: z12.string().optional(),
|
|
2556
|
+
region: z12.string(),
|
|
2557
|
+
keys: z12.number().int(),
|
|
2558
|
+
objects: z12.number().optional(),
|
|
2559
|
+
bytes: z12.number().optional(),
|
|
2560
|
+
createdBy: z12.string().nullable(),
|
|
2561
|
+
createdAt: z12.string()
|
|
2562
|
+
});
|
|
2563
|
+
var CreateBucketRequest = z12.object({
|
|
2564
|
+
name: z12.string(),
|
|
2565
|
+
sizeGib: z12.number().int().optional(),
|
|
2566
|
+
near: z12.string().optional(),
|
|
2567
|
+
region: z12.string().optional()
|
|
2568
|
+
});
|
|
2569
|
+
var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z12.boolean() });
|
|
2437
2570
|
var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
|
|
2438
|
-
var SetBucketPublicRequest =
|
|
2439
|
-
var BucketKeySchema =
|
|
2440
|
-
id:
|
|
2441
|
-
name:
|
|
2442
|
-
bucket:
|
|
2443
|
-
owner:
|
|
2444
|
-
readOnly:
|
|
2445
|
-
createdBy:
|
|
2446
|
-
createdAt:
|
|
2447
|
-
});
|
|
2448
|
-
var CreateBucketKeyRequest =
|
|
2449
|
-
var CreatedBucketKeySchema = BucketKeySchema.extend({ secret:
|
|
2450
|
-
var GrowStorageRequest =
|
|
2451
|
-
var StorageBackupSchema =
|
|
2452
|
-
id:
|
|
2453
|
-
owner:
|
|
2454
|
-
status:
|
|
2571
|
+
var SetBucketPublicRequest = z12.object({ on: z12.boolean(), sub: z12.string().optional() });
|
|
2572
|
+
var BucketKeySchema = z12.object({
|
|
2573
|
+
id: z12.string(),
|
|
2574
|
+
name: z12.string(),
|
|
2575
|
+
bucket: z12.string(),
|
|
2576
|
+
owner: z12.string(),
|
|
2577
|
+
readOnly: z12.boolean(),
|
|
2578
|
+
createdBy: z12.string().nullable(),
|
|
2579
|
+
createdAt: z12.string()
|
|
2580
|
+
});
|
|
2581
|
+
var CreateBucketKeyRequest = z12.object({ name: z12.string().optional(), readOnly: z12.boolean().optional() });
|
|
2582
|
+
var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z12.string(), endpoint: z12.string().nullable(), region: z12.string() });
|
|
2583
|
+
var GrowStorageRequest = z12.object({ sizeGib: z12.number().int() });
|
|
2584
|
+
var StorageBackupSchema = z12.object({
|
|
2585
|
+
id: z12.string(),
|
|
2586
|
+
owner: z12.string(),
|
|
2587
|
+
status: z12.enum(BACKUP_STATUSES),
|
|
2455
2588
|
/** Why it failed; null otherwise. */
|
|
2456
|
-
error:
|
|
2589
|
+
error: z12.string().nullable(),
|
|
2457
2590
|
/** The storage's volume when taken. */
|
|
2458
|
-
diskBytes:
|
|
2591
|
+
diskBytes: z12.number().int().nullable(),
|
|
2459
2592
|
/** What it holds: the slots that are not all zeros. */
|
|
2460
|
-
dataBytes:
|
|
2593
|
+
dataBytes: z12.number().int().nullable(),
|
|
2461
2594
|
/** What this backup added to the backup store (encrypted, compressed). */
|
|
2462
|
-
uploadedBytes:
|
|
2595
|
+
uploadedBytes: z12.number().int().nullable(),
|
|
2463
2596
|
/** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
|
|
2464
|
-
buckets:
|
|
2465
|
-
keys:
|
|
2466
|
-
createdBy:
|
|
2467
|
-
createdAt:
|
|
2468
|
-
finishedAt:
|
|
2469
|
-
});
|
|
2470
|
-
var RestoredKeySchema =
|
|
2471
|
-
var StorageRestoreSchema =
|
|
2472
|
-
backup:
|
|
2597
|
+
buckets: z12.array(z12.string()),
|
|
2598
|
+
keys: z12.number().int(),
|
|
2599
|
+
createdBy: z12.string().nullable(),
|
|
2600
|
+
createdAt: z12.string(),
|
|
2601
|
+
finishedAt: z12.string().nullable()
|
|
2602
|
+
});
|
|
2603
|
+
var RestoredKeySchema = z12.object({ bucket: z12.string(), id: z12.string(), name: z12.string() });
|
|
2604
|
+
var StorageRestoreSchema = z12.object({
|
|
2605
|
+
backup: z12.string(),
|
|
2473
2606
|
storage: ObjectStorageSchema,
|
|
2474
|
-
buckets:
|
|
2475
|
-
keys:
|
|
2476
|
-
checked:
|
|
2477
|
-
warnings:
|
|
2607
|
+
buckets: z12.object({ kept: z12.array(z12.string()), returned: z12.array(z12.string()), removed: z12.array(z12.string()) }),
|
|
2608
|
+
keys: z12.object({ dropped: z12.array(RestoredKeySchema), revoked: z12.array(RestoredKeySchema) }),
|
|
2609
|
+
checked: z12.boolean(),
|
|
2610
|
+
warnings: z12.array(z12.string())
|
|
2478
2611
|
});
|
|
2479
2612
|
var OBJECT_LIST_MAX = 1e3;
|
|
2480
2613
|
var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
|
|
@@ -2484,56 +2617,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
|
|
|
2484
2617
|
var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
|
|
2485
2618
|
var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
|
|
2486
2619
|
var DELETE_PREFIXES_MAX = 100;
|
|
2487
|
-
var StoredObjectSchema =
|
|
2488
|
-
key:
|
|
2489
|
-
size:
|
|
2490
|
-
etag:
|
|
2620
|
+
var StoredObjectSchema = z12.object({
|
|
2621
|
+
key: z12.string(),
|
|
2622
|
+
size: z12.number(),
|
|
2623
|
+
etag: z12.string(),
|
|
2491
2624
|
/** ISO 8601. */
|
|
2492
|
-
modified:
|
|
2493
|
-
});
|
|
2494
|
-
var ObjectListingSchema =
|
|
2495
|
-
prefix:
|
|
2496
|
-
folders:
|
|
2497
|
-
objects:
|
|
2498
|
-
next:
|
|
2499
|
-
canWrite:
|
|
2500
|
-
});
|
|
2501
|
-
var ObjectInfoSchema = StoredObjectSchema.extend({ contentType:
|
|
2502
|
-
var ObjectCountSchema =
|
|
2503
|
-
var ObjectLinkRequest =
|
|
2504
|
-
key:
|
|
2505
|
-
expiresSec:
|
|
2625
|
+
modified: z12.string()
|
|
2626
|
+
});
|
|
2627
|
+
var ObjectListingSchema = z12.object({
|
|
2628
|
+
prefix: z12.string(),
|
|
2629
|
+
folders: z12.array(z12.string()),
|
|
2630
|
+
objects: z12.array(StoredObjectSchema),
|
|
2631
|
+
next: z12.string().optional(),
|
|
2632
|
+
canWrite: z12.boolean()
|
|
2633
|
+
});
|
|
2634
|
+
var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z12.string() });
|
|
2635
|
+
var ObjectCountSchema = z12.object({ objects: z12.number(), bytes: z12.number(), more: z12.boolean() });
|
|
2636
|
+
var ObjectLinkRequest = z12.object({
|
|
2637
|
+
key: z12.string(),
|
|
2638
|
+
expiresSec: z12.number().int().positive(),
|
|
2506
2639
|
/** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
|
|
2507
|
-
download:
|
|
2640
|
+
download: z12.boolean().optional(),
|
|
2508
2641
|
/**
|
|
2509
2642
|
* Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
|
|
2510
2643
|
* so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
|
|
2511
2644
|
* is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
|
|
2512
2645
|
* Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
|
|
2513
2646
|
*/
|
|
2514
|
-
cached:
|
|
2647
|
+
cached: z12.boolean().optional()
|
|
2515
2648
|
});
|
|
2516
|
-
var ObjectLinkSchema =
|
|
2649
|
+
var ObjectLinkSchema = z12.object({ url: z12.string(), expiresAt: z12.string() });
|
|
2517
2650
|
var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
|
|
2518
|
-
var StartUploadRequest =
|
|
2519
|
-
var UploadPlanSchema =
|
|
2520
|
-
|
|
2521
|
-
|
|
2651
|
+
var StartUploadRequest = z12.object({ key: z12.string(), size: z12.number().int().nonnegative(), contentType: z12.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z12.boolean().optional() });
|
|
2652
|
+
var UploadPlanSchema = z12.discriminatedUnion("kind", [
|
|
2653
|
+
z12.object({ kind: z12.literal("single"), url: z12.string() }),
|
|
2654
|
+
z12.object({ kind: z12.literal("multipart"), uploadId: z12.string(), partSize: z12.number(), urls: z12.array(z12.string()) })
|
|
2522
2655
|
]);
|
|
2523
|
-
var CompleteUploadRequest =
|
|
2524
|
-
key:
|
|
2525
|
-
uploadId:
|
|
2526
|
-
parts:
|
|
2656
|
+
var CompleteUploadRequest = z12.object({
|
|
2657
|
+
key: z12.string(),
|
|
2658
|
+
uploadId: z12.string(),
|
|
2659
|
+
parts: z12.array(z12.object({ part: z12.number().int().positive(), etag: z12.string() })).min(1)
|
|
2527
2660
|
});
|
|
2528
|
-
var AbortUploadRequest =
|
|
2529
|
-
var DeleteObjectsRequest =
|
|
2530
|
-
var DeletedObjectsSchema =
|
|
2531
|
-
deleted:
|
|
2532
|
-
more:
|
|
2533
|
-
errors:
|
|
2661
|
+
var AbortUploadRequest = z12.object({ key: z12.string(), uploadId: z12.string() });
|
|
2662
|
+
var DeleteObjectsRequest = z12.object({ keys: z12.array(z12.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z12.array(z12.string()).max(DELETE_PREFIXES_MAX).optional() });
|
|
2663
|
+
var DeletedObjectsSchema = z12.object({
|
|
2664
|
+
deleted: z12.number(),
|
|
2665
|
+
more: z12.boolean(),
|
|
2666
|
+
errors: z12.array(z12.object({ key: z12.string(), message: z12.string() }))
|
|
2534
2667
|
});
|
|
2535
|
-
var MoveObjectRequest =
|
|
2536
|
-
var CreateFolderRequest =
|
|
2668
|
+
var MoveObjectRequest = z12.object({ from: z12.string(), to: z12.string(), overwrite: z12.boolean().optional() });
|
|
2669
|
+
var CreateFolderRequest = z12.object({ prefix: z12.string() });
|
|
2537
2670
|
|
|
2538
2671
|
// src/kvm.ts
|
|
2539
2672
|
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
@@ -2647,7 +2780,7 @@ var ServerClient = class {
|
|
|
2647
2780
|
startedOnce = false;
|
|
2648
2781
|
async call(method, path, schema, body, org = this.target.kind === "cloud" ? this.target.org : void 0, timeoutMs) {
|
|
2649
2782
|
try {
|
|
2650
|
-
return await this.sdk.request(method, path, schema, { body, org: this.target.kind === "cloud" ? org : void 0, timeoutMs });
|
|
2783
|
+
return await this.sdk.request(method, path, schema, { body, org: this.target.kind === "cloud" ? org ?? void 0 : void 0, timeoutMs });
|
|
2651
2784
|
} catch (err) {
|
|
2652
2785
|
return this.failed(err, () => this.call(method, path, schema, body, org, timeoutMs));
|
|
2653
2786
|
}
|
|
@@ -2703,7 +2836,7 @@ var ServerClient = class {
|
|
|
2703
2836
|
* `all`: every box on the platform (platform admins only, #78).
|
|
2704
2837
|
*/
|
|
2705
2838
|
listMachines(opts = {}) {
|
|
2706
|
-
return this.call("GET", `/machines${allQuery(opts)}`,
|
|
2839
|
+
return this.call("GET", `/machines${allQuery(opts)}`, z13.array(MachineSchema), void 0, opts.org);
|
|
2707
2840
|
}
|
|
2708
2841
|
createMachine(req) {
|
|
2709
2842
|
return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
|
|
@@ -2757,10 +2890,10 @@ var ServerClient = class {
|
|
|
2757
2890
|
}
|
|
2758
2891
|
/** Backups, the control plane's only: a box's disk in object storage. Newest first. */
|
|
2759
2892
|
listBackups() {
|
|
2760
|
-
return this.call("GET", "/backups",
|
|
2893
|
+
return this.call("GET", "/backups", z13.array(BackupSchema));
|
|
2761
2894
|
}
|
|
2762
2895
|
boxBackups(name) {
|
|
2763
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`,
|
|
2896
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z13.array(BackupSchema));
|
|
2764
2897
|
}
|
|
2765
2898
|
boxBackup(name, id) {
|
|
2766
2899
|
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
|
|
@@ -2774,14 +2907,14 @@ var ServerClient = class {
|
|
|
2774
2907
|
* later. Works for a backup whose box, volume or database is gone too.
|
|
2775
2908
|
*/
|
|
2776
2909
|
removeBackup(id) {
|
|
2777
|
-
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`,
|
|
2910
|
+
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z13.undefined());
|
|
2778
2911
|
}
|
|
2779
2912
|
/** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
|
|
2780
2913
|
listVolumeBackups() {
|
|
2781
|
-
return this.call("GET", "/backups?kind=volume",
|
|
2914
|
+
return this.call("GET", "/backups?kind=volume", z13.array(VolumeBackupSchema));
|
|
2782
2915
|
}
|
|
2783
2916
|
volumeBackups(name) {
|
|
2784
|
-
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`,
|
|
2917
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z13.array(VolumeBackupSchema));
|
|
2785
2918
|
}
|
|
2786
2919
|
volumeBackup(name, id) {
|
|
2787
2920
|
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
|
|
@@ -2800,7 +2933,7 @@ var ServerClient = class {
|
|
|
2800
2933
|
}
|
|
2801
2934
|
/** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
|
|
2802
2935
|
boxHooks(name) {
|
|
2803
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`,
|
|
2936
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z13.array(WakeHookSchema));
|
|
2804
2937
|
}
|
|
2805
2938
|
createBoxHook(name) {
|
|
2806
2939
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
|
|
@@ -2828,7 +2961,7 @@ var ServerClient = class {
|
|
|
2828
2961
|
}
|
|
2829
2962
|
/** Every readable box's subdomains, one entry each. */
|
|
2830
2963
|
listSubdomains() {
|
|
2831
|
-
return this.call("GET", "/subdomains",
|
|
2964
|
+
return this.call("GET", "/subdomains", z13.array(SubdomainSchema));
|
|
2832
2965
|
}
|
|
2833
2966
|
/** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
|
|
2834
2967
|
addDomain(name, req) {
|
|
@@ -2839,7 +2972,7 @@ var ServerClient = class {
|
|
|
2839
2972
|
}
|
|
2840
2973
|
/** Every readable box's custom domains. */
|
|
2841
2974
|
listDomains() {
|
|
2842
|
-
return this.call("GET", "/domains",
|
|
2975
|
+
return this.call("GET", "/domains", z13.array(DomainSchema));
|
|
2843
2976
|
}
|
|
2844
2977
|
/** A running box's own load, memory and disk, asked of its guest (#67). */
|
|
2845
2978
|
machineStats(name) {
|
|
@@ -2872,22 +3005,22 @@ var ServerClient = class {
|
|
|
2872
3005
|
return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
|
|
2873
3006
|
}
|
|
2874
3007
|
deleteMachine(name) {
|
|
2875
|
-
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`,
|
|
3008
|
+
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z13.undefined());
|
|
2876
3009
|
}
|
|
2877
3010
|
/** Like `listMachines`, for snapshots. */
|
|
2878
3011
|
listSnapshots(opts = {}) {
|
|
2879
|
-
return this.call("GET", `/snapshots${allQuery(opts)}`,
|
|
3012
|
+
return this.call("GET", `/snapshots${allQuery(opts)}`, z13.array(SnapshotSchema), void 0, opts.org);
|
|
2880
3013
|
}
|
|
2881
3014
|
createSnapshot(req) {
|
|
2882
3015
|
return this.call("POST", "/snapshots", SnapshotSchema, req);
|
|
2883
3016
|
}
|
|
2884
3017
|
deleteSnapshot(name) {
|
|
2885
|
-
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
3018
|
+
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z13.undefined());
|
|
2886
3019
|
}
|
|
2887
3020
|
// ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
|
|
2888
3021
|
/** `org`: that org's list instead of `--org`'s (or the caller's own). */
|
|
2889
3022
|
listEnv(org) {
|
|
2890
|
-
return this.call("GET", "/vars",
|
|
3023
|
+
return this.call("GET", "/vars", z13.array(EnvVarSchema), void 0, org);
|
|
2891
3024
|
}
|
|
2892
3025
|
setEnv(name, req) {
|
|
2893
3026
|
return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
|
|
@@ -2907,13 +3040,13 @@ var ServerClient = class {
|
|
|
2907
3040
|
}
|
|
2908
3041
|
// ---- volumes (#52) ----
|
|
2909
3042
|
listVolumes(opts = {}) {
|
|
2910
|
-
return this.call("GET", `/volumes${allQuery(opts)}`,
|
|
3043
|
+
return this.call("GET", `/volumes${allQuery(opts)}`, z13.array(VolumeSchema), void 0, opts.org);
|
|
2911
3044
|
}
|
|
2912
3045
|
createVolume(req) {
|
|
2913
3046
|
return this.call("POST", "/volumes", VolumeSchema, req);
|
|
2914
3047
|
}
|
|
2915
3048
|
deleteVolume(name) {
|
|
2916
|
-
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`,
|
|
3049
|
+
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z13.undefined());
|
|
2917
3050
|
}
|
|
2918
3051
|
/** Both answer with the box as it is afterwards (restarted when it was running). */
|
|
2919
3052
|
attachVolume(name, req) {
|
|
@@ -2928,7 +3061,7 @@ var ServerClient = class {
|
|
|
2928
3061
|
}
|
|
2929
3062
|
// ---- cron service (#190): the control plane's alone ----
|
|
2930
3063
|
listCronServices(opts = {}) {
|
|
2931
|
-
return this.call("GET", `/cron${allQuery(opts)}`,
|
|
3064
|
+
return this.call("GET", `/cron${allQuery(opts)}`, z13.array(CronServiceSchema), void 0, opts.org);
|
|
2932
3065
|
}
|
|
2933
3066
|
createCronService(name) {
|
|
2934
3067
|
return this.call("POST", "/cron", CronServiceSchema, { name });
|
|
@@ -2937,10 +3070,10 @@ var ServerClient = class {
|
|
|
2937
3070
|
return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
|
|
2938
3071
|
}
|
|
2939
3072
|
deleteCronService(name) {
|
|
2940
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`,
|
|
3073
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z13.undefined());
|
|
2941
3074
|
}
|
|
2942
3075
|
listCronTriggers(service) {
|
|
2943
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`,
|
|
3076
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z13.array(CronTriggerSchema));
|
|
2944
3077
|
}
|
|
2945
3078
|
addCronTrigger(service, req) {
|
|
2946
3079
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
|
|
@@ -2950,18 +3083,18 @@ var ServerClient = class {
|
|
|
2950
3083
|
return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
|
|
2951
3084
|
}
|
|
2952
3085
|
deleteCronTrigger(service, id) {
|
|
2953
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`,
|
|
3086
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z13.undefined());
|
|
2954
3087
|
}
|
|
2955
3088
|
/** Marks it due: kvbox-cron fires it within a few seconds. */
|
|
2956
3089
|
runCronTrigger(service, id) {
|
|
2957
3090
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
|
|
2958
3091
|
}
|
|
2959
3092
|
listCronRuns(service, id, limit) {
|
|
2960
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`,
|
|
3093
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z13.array(CronRunSchema));
|
|
2961
3094
|
}
|
|
2962
3095
|
// ---- object storage (#182): the control plane's alone ----
|
|
2963
3096
|
listBuckets(opts = {}) {
|
|
2964
|
-
return this.call("GET", `/buckets${allQuery(opts)}`,
|
|
3097
|
+
return this.call("GET", `/buckets${allQuery(opts)}`, z13.array(BucketSchema), void 0, opts.org);
|
|
2965
3098
|
}
|
|
2966
3099
|
/** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
|
|
2967
3100
|
createBucket(req) {
|
|
@@ -2975,26 +3108,26 @@ var ServerClient = class {
|
|
|
2975
3108
|
return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
|
|
2976
3109
|
}
|
|
2977
3110
|
deleteBucket(name, force = false) {
|
|
2978
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`,
|
|
3111
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z13.undefined());
|
|
2979
3112
|
}
|
|
2980
3113
|
listBucketKeys(name) {
|
|
2981
|
-
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`,
|
|
3114
|
+
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z13.array(BucketKeySchema));
|
|
2982
3115
|
}
|
|
2983
3116
|
createBucketKey(name, req) {
|
|
2984
3117
|
return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
|
|
2985
3118
|
}
|
|
2986
3119
|
deleteBucketKey(name, id) {
|
|
2987
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`,
|
|
3120
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z13.undefined());
|
|
2988
3121
|
}
|
|
2989
3122
|
listStorage(opts = {}) {
|
|
2990
|
-
return this.call("GET", `/storage${allQuery(opts)}`,
|
|
3123
|
+
return this.call("GET", `/storage${allQuery(opts)}`, z13.array(ObjectStorageSchema), void 0, opts.org);
|
|
2991
3124
|
}
|
|
2992
3125
|
growStorage(sizeGib) {
|
|
2993
3126
|
return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
|
|
2994
3127
|
}
|
|
2995
3128
|
/** Backups of the slug's whole object storage (#186 slice 3), newest first. */
|
|
2996
3129
|
storageBackups() {
|
|
2997
|
-
return this.call("GET", "/storage/backups",
|
|
3130
|
+
return this.call("GET", "/storage/backups", z13.array(StorageBackupSchema));
|
|
2998
3131
|
}
|
|
2999
3132
|
storageBackup(id) {
|
|
3000
3133
|
return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
|
|
@@ -3015,11 +3148,11 @@ var ServerClient = class {
|
|
|
3015
3148
|
return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
|
|
3016
3149
|
}
|
|
3017
3150
|
managedCatalog() {
|
|
3018
|
-
return this.call("GET", "/managed/catalog",
|
|
3151
|
+
return this.call("GET", "/managed/catalog", z13.array(ManagedCatalogEntrySchema));
|
|
3019
3152
|
}
|
|
3020
3153
|
/** One kind's services, or every kind's when `kind` is left out. */
|
|
3021
3154
|
listManaged(kind, opts = {}) {
|
|
3022
|
-
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`,
|
|
3155
|
+
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z13.array(ManagedSchema), void 0, opts.org);
|
|
3023
3156
|
}
|
|
3024
3157
|
/** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
|
|
3025
3158
|
createManaged(kind, req) {
|
|
@@ -3030,7 +3163,7 @@ var ServerClient = class {
|
|
|
3030
3163
|
return this.call("GET", this.managedPath(kind, name), ManagedSchema);
|
|
3031
3164
|
}
|
|
3032
3165
|
deleteManaged(kind, name) {
|
|
3033
|
-
return this.call("DELETE", this.managedPath(kind, name),
|
|
3166
|
+
return this.call("DELETE", this.managedPath(kind, name), z13.undefined());
|
|
3034
3167
|
}
|
|
3035
3168
|
managedPassword(kind, name) {
|
|
3036
3169
|
return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
|
|
@@ -3052,10 +3185,10 @@ var ServerClient = class {
|
|
|
3052
3185
|
}
|
|
3053
3186
|
/** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
|
|
3054
3187
|
listManagedBackups(kind) {
|
|
3055
|
-
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`,
|
|
3188
|
+
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z13.array(ManagedBackupSchema));
|
|
3056
3189
|
}
|
|
3057
3190
|
managedBackups(kind, name) {
|
|
3058
|
-
return this.call("GET", this.managedPath(kind, name, "/backups"),
|
|
3191
|
+
return this.call("GET", this.managedPath(kind, name, "/backups"), z13.array(ManagedBackupSchema));
|
|
3059
3192
|
}
|
|
3060
3193
|
managedBackup(kind, name, id) {
|
|
3061
3194
|
return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
|
|
@@ -3097,24 +3230,36 @@ var ServerClient = class {
|
|
|
3097
3230
|
return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
|
|
3098
3231
|
}
|
|
3099
3232
|
logout() {
|
|
3100
|
-
return this.call("POST", "/logout",
|
|
3233
|
+
return this.call("POST", "/logout", z13.unknown()).then(() => void 0);
|
|
3101
3234
|
}
|
|
3102
3235
|
me() {
|
|
3103
3236
|
return this.call("GET", "/me", MeResponseSchema);
|
|
3104
3237
|
}
|
|
3238
|
+
// ---- Integrations (`kvbox integration ls`, #205) ----
|
|
3239
|
+
/**
|
|
3240
|
+
* What one org has connected (`org`, else the `--org` one), or without either each readable slug; never a
|
|
3241
|
+
* credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
|
|
3242
|
+
*/
|
|
3243
|
+
listIntegrations(org) {
|
|
3244
|
+
return this.call("GET", "/integrations", z13.array(IntegrationSchema), void 0, org);
|
|
3245
|
+
}
|
|
3246
|
+
/** What can be connected on this control plane, and by which kind of slug. */
|
|
3247
|
+
integrationCatalog() {
|
|
3248
|
+
return this.call("GET", "/integrations/catalog", z13.array(IntegrationCatalogEntrySchema), void 0, null);
|
|
3249
|
+
}
|
|
3105
3250
|
// ---- API keys (`kvbox key …`, #189) ----
|
|
3106
3251
|
listApiKeys() {
|
|
3107
|
-
return this.call("GET", "/keys",
|
|
3252
|
+
return this.call("GET", "/keys", z13.array(ApiKeySchema));
|
|
3108
3253
|
}
|
|
3109
3254
|
createApiKey(req) {
|
|
3110
3255
|
return this.call("POST", "/keys", CreatedApiKeySchema, req);
|
|
3111
3256
|
}
|
|
3112
3257
|
deleteApiKey(name) {
|
|
3113
|
-
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`,
|
|
3258
|
+
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z13.unknown()).then(() => void 0);
|
|
3114
3259
|
}
|
|
3115
3260
|
// ---- orgs (`kvbox org …`) ----
|
|
3116
3261
|
listOrgs() {
|
|
3117
|
-
return this.call("GET", "/orgs",
|
|
3262
|
+
return this.call("GET", "/orgs", z13.array(OrgMembershipSchema));
|
|
3118
3263
|
}
|
|
3119
3264
|
createOrg(req) {
|
|
3120
3265
|
return this.call("POST", "/orgs", CloudOrgSchema, req);
|
|
@@ -3123,16 +3268,16 @@ var ServerClient = class {
|
|
|
3123
3268
|
return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
|
|
3124
3269
|
}
|
|
3125
3270
|
deleteOrg(slug) {
|
|
3126
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`,
|
|
3271
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z13.undefined());
|
|
3127
3272
|
}
|
|
3128
3273
|
addMember(slug, req) {
|
|
3129
|
-
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`,
|
|
3274
|
+
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z13.undefined(), req);
|
|
3130
3275
|
}
|
|
3131
3276
|
setRole(slug, username, role) {
|
|
3132
|
-
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
3277
|
+
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.unknown(), { role }).then(() => void 0);
|
|
3133
3278
|
}
|
|
3134
3279
|
removeMember(slug, username) {
|
|
3135
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
3280
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.undefined());
|
|
3136
3281
|
}
|
|
3137
3282
|
/** Sign this machine's key again (#51); the key must be one the user logged in with. */
|
|
3138
3283
|
sshCert(req) {
|
|
@@ -3564,10 +3709,47 @@ function parseDuration(text2) {
|
|
|
3564
3709
|
return sec;
|
|
3565
3710
|
}
|
|
3566
3711
|
|
|
3712
|
+
// src/commands/integration/shared.ts
|
|
3713
|
+
function whereToConnect(catalog, id) {
|
|
3714
|
+
const page = (catalog.find((e) => e.id === id) ?? catalog.find((e) => e.page !== void 0))?.page;
|
|
3715
|
+
return page === void 0 ? "in the web app" : `at ${page}`;
|
|
3716
|
+
}
|
|
3717
|
+
function integrationsKept(asked, box2) {
|
|
3718
|
+
if (asked === void 0) return true;
|
|
3719
|
+
const have = box2.integrations ?? [];
|
|
3720
|
+
return asked.length === have.length && asked.every((id) => have.includes(id));
|
|
3721
|
+
}
|
|
3722
|
+
var integrationsText = (list) => list?.length ? list.join(", ") : "none";
|
|
3723
|
+
function connectable(catalog, id, own) {
|
|
3724
|
+
const entry = catalog.find((e) => e.id === id);
|
|
3725
|
+
return entry === void 0 || entry.kinds[own ? "user" : "org"].length > 0;
|
|
3726
|
+
}
|
|
3727
|
+
var catalogOf = (client) => client.integrationCatalog().catch(() => []);
|
|
3728
|
+
async function noteNotConnected(client, box2, asked) {
|
|
3729
|
+
if (asked.length === 0 || client.target.kind !== "cloud") {
|
|
3730
|
+
if (asked.length > 0) warn(`box ${box2.name}: integrations need the kvbox cloud; a box made on this machine never gets a credential`);
|
|
3731
|
+
return;
|
|
3732
|
+
}
|
|
3733
|
+
const slug = slugOf(box2.owner);
|
|
3734
|
+
const [rows2, catalog] = await Promise.all([client.listIntegrations(null).catch(() => null), catalogOf(client)]);
|
|
3735
|
+
if (rows2 === null) return;
|
|
3736
|
+
for (const id of asked) {
|
|
3737
|
+
const row = rows2.find((r) => r.owner === slug && r.integration === id);
|
|
3738
|
+
if (row === void 0 || row.connected && row.status === "ok") continue;
|
|
3739
|
+
if (!row.connected && !connectable(catalog, id, slug === me(client))) {
|
|
3740
|
+
info(color.dim(` ${id} cannot be connected for an org yet: it is on for this box, which gets nothing from it until ${slug} can connect it`));
|
|
3741
|
+
continue;
|
|
3742
|
+
}
|
|
3743
|
+
const why = row.connected ? `${id} needs to be connected again for ${slug}` : `${id} is not connected for ${slug} yet`;
|
|
3744
|
+
info(color.dim(` ${why}: it is on for this box and works once connected ${whereToConnect(catalog, id)}`));
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3567
3748
|
// src/commands/vm/new.ts
|
|
3568
|
-
var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so the two can be linked (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
3749
|
+
var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so the two can be linked (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--integration <list>", "turn integrations on for the box, e.g. github,claude (connect the account in the web app; off: none)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
3569
3750
|
const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
|
|
3570
3751
|
const env = parseEnvFlags(opts.env);
|
|
3752
|
+
const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
|
|
3571
3753
|
const country = opts.country === void 0 ? void 0 : parseCountry(opts.country);
|
|
3572
3754
|
if (country !== void 0 && opts.from !== void 0) throw new KvboxError("--country cannot be given with --from: a snapshot is restored on its own host");
|
|
3573
3755
|
if (opts.fromBackup !== void 0) {
|
|
@@ -3600,6 +3782,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
|
|
|
3600
3782
|
...country !== void 0 ? { country } : {},
|
|
3601
3783
|
...opts.host !== void 0 ? { host: opts.host } : {},
|
|
3602
3784
|
...autoHibernateSec !== void 0 ? { autoHibernateSec } : {},
|
|
3785
|
+
...integrations !== void 0 ? { integrations } : {},
|
|
3603
3786
|
...opts.force ? { force: true } : {}
|
|
3604
3787
|
}));
|
|
3605
3788
|
if (opts.fromBackup !== void 0 && !box2.source.startsWith("backup:")) {
|
|
@@ -3609,6 +3792,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
|
|
|
3609
3792
|
if (opts.base !== void 0 && opts.base !== "base" && box2.image === void 0) {
|
|
3610
3793
|
warn(`box ${box2.name}: its host runs a kvbox-server too old for images; it booted the base image, not ${opts.base}`);
|
|
3611
3794
|
}
|
|
3795
|
+
if (integrations?.length && !integrationsKept(integrations, box2)) warn(`box ${box2.name}: its host runs a kvbox-server too old for integrations; it has none`);
|
|
3612
3796
|
if (env.length > 0) {
|
|
3613
3797
|
const kept = await keptVars(client, displayName(box2, me(client)), env.map((v) => v.name));
|
|
3614
3798
|
if (kept === "too old") warn(`box ${box2.name}: its host runs a kvbox-server too old for a box's own variables; it has none of the -e ones`);
|
|
@@ -3626,6 +3810,10 @@ var newCommand = new Command("new").description("boot a new box from an image (t
|
|
|
3626
3810
|
else if (opts.fromBackup !== void 0) info(` connect with: kvbox connect ${displayName(box2, user)} (booting on the backup's disk: SSH is up a couple of seconds after)`);
|
|
3627
3811
|
else info(` connect with: kvbox connect ${displayName(box2, user)} (SSH is up a couple of seconds after boot)`);
|
|
3628
3812
|
if (box2.autoHibernateSec) info(` it ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
|
|
3813
|
+
if (box2.integrations?.length) {
|
|
3814
|
+
info(` integrations: ${integrationsText(box2.integrations)}`);
|
|
3815
|
+
await noteNotConnected(client, box2, box2.integrations);
|
|
3816
|
+
}
|
|
3629
3817
|
if (box2.connect !== void 0) {
|
|
3630
3818
|
info(` reach it at: ${box2.connect}`);
|
|
3631
3819
|
info(` from another box once linked: kvbox vm link <box> ${displayName(box2, user)} --port <port>`);
|
|
@@ -3937,6 +4125,9 @@ var lsCommand = new Command6("ls").description("list boxes with status and addre
|
|
|
3937
4125
|
}
|
|
3938
4126
|
if (org !== void 0) info(`boxes of ${org}`);
|
|
3939
4127
|
table(lsRows(boxes, cloud ? { me: me(client), showHost: admin } : void 0));
|
|
4128
|
+
const behind = boxes.filter((b) => b.latestBase !== void 0 && b.managed === void 0);
|
|
4129
|
+
const asleep = behind.some((b) => b.status === "hibernated");
|
|
4130
|
+
if (behind.length > 0) info(color.dim(`${behind.length === 1 ? "1 box runs" : `${behind.length} boxes run`} an older image (\u2192 in BASE): kvbox vm update <box> moves it onto the newer one, its files stay${asleep ? " (a hibernated box first: kvbox wake <box>)" : ""}`));
|
|
3940
4131
|
} finally {
|
|
3941
4132
|
await client.close();
|
|
3942
4133
|
}
|
|
@@ -3952,8 +4143,9 @@ function lsRows(boxes, cloud) {
|
|
|
3952
4143
|
address: addressOf(b),
|
|
3953
4144
|
size: b.status === "unknown" ? "-" : `${shape(b.vcpu, b.memMib, b.diskBytes)} ${color.dim(`(${gbShort(b.diskUsedBytes)} used)`)}`,
|
|
3954
4145
|
created: age(b.createdAt),
|
|
3955
|
-
// An image other than the base one (#87) is named: `postgres v0.1.0
|
|
3956
|
-
|
|
4146
|
+
// An image other than the base one (#87) is named: `postgres v0.1.0`; a newer one on the host follows in yellow: `v0.12.0 → v0.16.0`
|
|
4147
|
+
// (not on a managed service's box, which `vm update` cannot reach).
|
|
4148
|
+
base: b.status === "unknown" || b.base === "" ? "-" : `${b.image !== void 0 ? `${b.image} ${b.base}` : b.base}${b.latestBase === void 0 || b.managed !== void 0 ? "" : color.yellow(` \u2192 ${b.latestBase}`)}`
|
|
3957
4149
|
}));
|
|
3958
4150
|
}
|
|
3959
4151
|
|
|
@@ -4036,8 +4228,10 @@ function getRows(box2, subs, user) {
|
|
|
4036
4228
|
const quiet = box2.idleCheck === void 0 ? "without network traffic" : `idle by ${box2.idleCheck}`;
|
|
4037
4229
|
rows2.push(["auto-hibernate", box2.autoHibernateSec ? `after ${duration(box2.autoHibernateSec)} ${quiet}` : "off"]);
|
|
4038
4230
|
if (!box2.autoHibernateSec && box2.idleCheck !== void 0) rows2.push(["idle check", `${box2.idleCheck} ${color.dim("(used once auto-hibernate is on)")}`]);
|
|
4231
|
+
rows2.push(["integrations", box2.integrations?.length ? box2.integrations.join(", ") : "-"]);
|
|
4039
4232
|
rows2.push(["source", box2.source]);
|
|
4040
|
-
|
|
4233
|
+
const update = box2.latestBase === void 0 ? "" : ` ${color.yellow(`(${box2.latestBase} available: ${box2.status === "hibernated" ? `kvbox wake ${displayName(box2, user)}, then ` : ""}kvbox vm update ${displayName(box2, user)})`)}`;
|
|
4234
|
+
rows2.push(["base", `${box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`}${update}`]);
|
|
4041
4235
|
rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
|
|
4042
4236
|
return rows2;
|
|
4043
4237
|
}
|
|
@@ -4871,14 +5065,16 @@ function runSwap(ep, mib) {
|
|
|
4871
5065
|
}
|
|
4872
5066
|
|
|
4873
5067
|
// src/commands/vm/set.ts
|
|
4874
|
-
var setCommand = new Command32("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
4875
|
-
if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.swap === void 0) {
|
|
4876
|
-
throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check or --swap");
|
|
5068
|
+
var setCommand = new Command32("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --integration github, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--integration <list>", "the integrations turned on for the box, replacing its list, e.g. github,claude (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5069
|
+
if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
|
|
5070
|
+
throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
|
|
4877
5071
|
}
|
|
5072
|
+
const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
|
|
4878
5073
|
const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
|
|
4879
5074
|
const idleCheck = opts.idleCheck === void 0 ? void 0 : parseIdleCheck(opts.idleCheck);
|
|
4880
5075
|
const swapMib = opts.swap === void 0 ? void 0 : parseSwap(opts.swap);
|
|
4881
|
-
const
|
|
5076
|
+
const idleSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
|
|
5077
|
+
const hostSettings = idleSettings || integrations !== void 0;
|
|
4882
5078
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4883
5079
|
try {
|
|
4884
5080
|
const found = pickRef(await boxesFor(client, name), name, me(client));
|
|
@@ -4886,7 +5082,10 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
|
|
|
4886
5082
|
if (swapMib !== void 0 && found.status === "stopped") throw new KvboxError(`box ${name} is stopped; --swap is set up inside the box (kvbox start ${name})`);
|
|
4887
5083
|
let box2 = found;
|
|
4888
5084
|
if (hostSettings) {
|
|
4889
|
-
box2 = await spin(`updating ${name}\u2026`, client.setMachine(displayName(found, me(client)), { ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {}, ...idleCheck !== void 0 ? { idleCheck } : {} }));
|
|
5085
|
+
box2 = await spin(`updating ${name}\u2026`, client.setMachine(displayName(found, me(client)), { ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {}, ...idleCheck !== void 0 ? { idleCheck } : {}, ...integrations !== void 0 ? { integrations } : {} }));
|
|
5086
|
+
if (!integrationsKept(integrations, box2)) {
|
|
5087
|
+
throw new KvboxError(`box ${name}: its host runs a kvbox-server too old for integrations; it needs updating first${idleSettings ? " (the other settings were applied)" : ""}`);
|
|
5088
|
+
}
|
|
4890
5089
|
if (!idleCheckKept(idleCheck, box2)) {
|
|
4891
5090
|
throw new KvboxError(`box ${name}: its host runs a kvbox-server too old for --idle-check; it needs updating first${autoHibernateSec !== void 0 ? " (--auto-hibernate was applied)" : ""}`);
|
|
4892
5091
|
}
|
|
@@ -4896,7 +5095,11 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
|
|
|
4896
5095
|
json(swap === void 0 ? box2 : { ...box2, swap });
|
|
4897
5096
|
return;
|
|
4898
5097
|
}
|
|
4899
|
-
if (
|
|
5098
|
+
if (idleSettings) info(`${color.green("\u2713")} box ${color.bold(name)}: ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
|
|
5099
|
+
if (integrations !== void 0) {
|
|
5100
|
+
info(`${color.green("\u2713")} box ${color.bold(name)}: integrations ${integrationsText(box2.integrations)}${integrations.length > 0 && box2.status !== "running" ? color.dim(` (used once it runs)`) : ""}`);
|
|
5101
|
+
await noteNotConnected(client, box2, integrations);
|
|
5102
|
+
}
|
|
4900
5103
|
if (idleCheck && !box2.autoHibernateSec) info(color.dim(` the idle check is used once auto-hibernate is on: kvbox vm set ${name} --auto-hibernate 10m`));
|
|
4901
5104
|
if (swap) info(`${color.green("\u2713")} box ${color.bold(name)}: ${swapText(swap)}`);
|
|
4902
5105
|
} finally {
|
|
@@ -5403,12 +5606,48 @@ var rmCommand5 = new Command45("rm").alias("remove").description("remove an API
|
|
|
5403
5606
|
// src/commands/key/index.ts
|
|
5404
5607
|
var keyCommand = new Command46("key").aliases(["keys"]).description("API keys: named tokens a program (CI, an agent, the SDK) uses as KVBOX_TOKEN in place of a login").addCommand(createCommand3).addCommand(lsCommand5).addCommand(rmCommand5);
|
|
5405
5608
|
|
|
5609
|
+
// src/commands/integration/index.ts
|
|
5610
|
+
import { Command as Command48 } from "commander";
|
|
5611
|
+
|
|
5612
|
+
// src/commands/integration/ls.ts
|
|
5613
|
+
import { Command as Command47 } from "commander";
|
|
5614
|
+
var lsCommand6 = new Command47("ls").alias("list").description("list the accounts connected for your boxes (GitHub, Claude Code), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5615
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5616
|
+
try {
|
|
5617
|
+
if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
|
|
5618
|
+
const rows2 = await client.listIntegrations();
|
|
5619
|
+
if (opts.json) {
|
|
5620
|
+
json(rows2);
|
|
5621
|
+
return;
|
|
5622
|
+
}
|
|
5623
|
+
const catalog = await catalogOf(client);
|
|
5624
|
+
const open = (r) => r.connected || connectable(catalog, r.integration, r.owner === me(client));
|
|
5625
|
+
table(
|
|
5626
|
+
rows2.map((r) => ({
|
|
5627
|
+
slug: r.owner,
|
|
5628
|
+
integration: r.integration,
|
|
5629
|
+
state: !open(r) ? color.dim("not for orgs yet") : !r.connected ? color.dim("not connected") : r.status === "needs-reconnect" ? color.yellow("connect again") : color.green("connected"),
|
|
5630
|
+
account: r.account ?? "-",
|
|
5631
|
+
connected: r.connectedAt === null ? "-" : age(r.connectedAt),
|
|
5632
|
+
"last used": r.connected ? r.lastUsedAt === null ? "never" : age(r.lastUsedAt) : "-"
|
|
5633
|
+
}))
|
|
5634
|
+
);
|
|
5635
|
+
if (rows2.some((r) => open(r) && (!r.connected || r.status === "needs-reconnect"))) info(color.dim(`connect an account ${whereToConnect(catalog)}`));
|
|
5636
|
+
if (rows2.some((r) => r.connected)) info(color.dim(`turn one on for a box with: kvbox vm set <box> --integration ${rows2.find((r) => r.connected).integration}`));
|
|
5637
|
+
} finally {
|
|
5638
|
+
await client.close();
|
|
5639
|
+
}
|
|
5640
|
+
});
|
|
5641
|
+
|
|
5642
|
+
// src/commands/integration/index.ts
|
|
5643
|
+
var integrationCommand = new Command48("integration").aliases(["integrations"]).description("integrations: accounts (GitHub, Claude Code) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
|
|
5644
|
+
|
|
5406
5645
|
// src/commands/snapshots/index.ts
|
|
5407
|
-
import { Command as
|
|
5646
|
+
import { Command as Command52 } from "commander";
|
|
5408
5647
|
|
|
5409
5648
|
// src/commands/snapshots/ls.ts
|
|
5410
|
-
import { Command as
|
|
5411
|
-
var
|
|
5649
|
+
import { Command as Command49 } from "commander";
|
|
5650
|
+
var lsCommand7 = new Command49("ls").description("list snapshots (yours and your orgs'; --org <slug> for one org)").option("-a, --all", "every snapshot on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5412
5651
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5413
5652
|
try {
|
|
5414
5653
|
const cloud = client.target.kind === "cloud";
|
|
@@ -5439,8 +5678,8 @@ var lsCommand6 = new Command47("ls").description("list snapshots (yours and your
|
|
|
5439
5678
|
});
|
|
5440
5679
|
|
|
5441
5680
|
// src/commands/snapshots/new.ts
|
|
5442
|
-
import { Command as
|
|
5443
|
-
var newCommand2 = new
|
|
5681
|
+
import { Command as Command50 } from "commander";
|
|
5682
|
+
var newCommand2 = new Command50("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--replace", "retake a snapshot that exists under this name; the old one stays until the new one is complete").option("--json", "print the snapshot as JSON").action(async (box2, name, opts, cmd) => {
|
|
5444
5683
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5445
5684
|
try {
|
|
5446
5685
|
const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
|
|
@@ -5453,8 +5692,8 @@ var newCommand2 = new Command48("new").description("freeze a running box (memory
|
|
|
5453
5692
|
});
|
|
5454
5693
|
|
|
5455
5694
|
// src/commands/snapshots/rm.ts
|
|
5456
|
-
import { Command as
|
|
5457
|
-
var rmCommand6 = new
|
|
5695
|
+
import { Command as Command51 } from "commander";
|
|
5696
|
+
var rmCommand6 = new Command51("rm").description("delete a snapshot (boxes made from it are not affected)").argument("<name>", "snapshot name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
5458
5697
|
if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
|
|
5459
5698
|
info("cancelled");
|
|
5460
5699
|
process.exitCode = 1;
|
|
@@ -5470,14 +5709,14 @@ var rmCommand6 = new Command49("rm").description("delete a snapshot (boxes made
|
|
|
5470
5709
|
});
|
|
5471
5710
|
|
|
5472
5711
|
// src/commands/snapshots/index.ts
|
|
5473
|
-
var snapshotsCommand = new
|
|
5712
|
+
var snapshotsCommand = new Command52("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
|
|
5474
5713
|
for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
5475
5714
|
|
|
5476
5715
|
// src/commands/org/index.ts
|
|
5477
|
-
import { Command as
|
|
5716
|
+
import { Command as Command58 } from "commander";
|
|
5478
5717
|
|
|
5479
5718
|
// src/commands/org/ls.ts
|
|
5480
|
-
import { Command as
|
|
5719
|
+
import { Command as Command53 } from "commander";
|
|
5481
5720
|
|
|
5482
5721
|
// src/commands/org/context.ts
|
|
5483
5722
|
var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
|
|
@@ -5497,7 +5736,7 @@ function orgFor(opts, target) {
|
|
|
5497
5736
|
}
|
|
5498
5737
|
|
|
5499
5738
|
// src/commands/org/ls.ts
|
|
5500
|
-
var
|
|
5739
|
+
var lsCommand8 = new Command53("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5501
5740
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5502
5741
|
try {
|
|
5503
5742
|
const orgs = await client.listOrgs();
|
|
@@ -5519,8 +5758,8 @@ function orgRows(orgs) {
|
|
|
5519
5758
|
}
|
|
5520
5759
|
|
|
5521
5760
|
// src/commands/org/members.ts
|
|
5522
|
-
import { Command as
|
|
5523
|
-
var
|
|
5761
|
+
import { Command as Command54, Option as Option4 } from "commander";
|
|
5762
|
+
var lsCommand9 = new Command54("ls").description("list an org's members and their roles").option("-o, --org <slug>", "the org (or --org before the command)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5524
5763
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5525
5764
|
try {
|
|
5526
5765
|
const org = await client.getOrg(orgFor(opts, client.target));
|
|
@@ -5534,7 +5773,7 @@ var lsCommand8 = new Command52("ls").description("list an org's members and thei
|
|
|
5534
5773
|
await client.close();
|
|
5535
5774
|
}
|
|
5536
5775
|
});
|
|
5537
|
-
var addCommand2 = new
|
|
5776
|
+
var addCommand2 = new Command54("add").description("add a user to an org (admins and owners; only an owner can add an owner)").argument("<user>", "their username").addOption(new Option4("-r, --role <role>", "their role").choices(ORG_ROLES).default("member")).option("-o, --org <slug>", "the org (or --org before the command)").action(async (user, opts, cmd) => {
|
|
5538
5777
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5539
5778
|
try {
|
|
5540
5779
|
const slug = orgFor(opts, client.target);
|
|
@@ -5544,7 +5783,7 @@ var addCommand2 = new Command52("add").description("add a user to an org (admins
|
|
|
5544
5783
|
await client.close();
|
|
5545
5784
|
}
|
|
5546
5785
|
});
|
|
5547
|
-
var rmCommand7 = new
|
|
5786
|
+
var rmCommand7 = new Command54("rm").description("remove a member (or leave: remove yourself)").argument("<user>", "their username").option("-o, --org <slug>", "the org (or --org before the command)").option("-y, --yes", "do not ask for confirmation").action(async (user, opts, cmd) => {
|
|
5548
5787
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5549
5788
|
try {
|
|
5550
5789
|
const slug = orgFor(opts, client.target);
|
|
@@ -5560,11 +5799,11 @@ var rmCommand7 = new Command52("rm").description("remove a member (or leave: rem
|
|
|
5560
5799
|
await client.close();
|
|
5561
5800
|
}
|
|
5562
5801
|
});
|
|
5563
|
-
var membersCommand = new
|
|
5802
|
+
var membersCommand = new Command54("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
|
|
5564
5803
|
|
|
5565
5804
|
// src/commands/org/new.ts
|
|
5566
|
-
import { Command as
|
|
5567
|
-
var newCommand3 = new
|
|
5805
|
+
import { Command as Command55 } from "commander";
|
|
5806
|
+
var newCommand3 = new Command55("new").description("create an org; you become its owner (the slug is permanent, the name is not)").argument("<slug>", "the org's slug: lowercase, like a username (acme)").option("-n, --name <name>", "display name (default: the slug)").option("--json", "print the org as JSON").action(async (slug, opts, cmd) => {
|
|
5568
5807
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5569
5808
|
try {
|
|
5570
5809
|
const org = await client.createOrg({ slug, name: opts.name ?? slug });
|
|
@@ -5580,8 +5819,8 @@ var newCommand3 = new Command53("new").description("create an org; you become it
|
|
|
5580
5819
|
});
|
|
5581
5820
|
|
|
5582
5821
|
// src/commands/org/rm.ts
|
|
5583
|
-
import { Command as
|
|
5584
|
-
var rmCommand8 = new
|
|
5822
|
+
import { Command as Command56 } from "commander";
|
|
5823
|
+
var rmCommand8 = new Command56("rm").description("delete an org (owners only; remove its boxes and snapshots first)").argument("<slug>", "the org").option("-y, --yes", "do not ask for confirmation").action(async (slug, opts, cmd) => {
|
|
5585
5824
|
if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
|
|
5586
5825
|
info("cancelled");
|
|
5587
5826
|
process.exitCode = 1;
|
|
@@ -5597,8 +5836,8 @@ var rmCommand8 = new Command54("rm").description("delete an org (owners only; re
|
|
|
5597
5836
|
});
|
|
5598
5837
|
|
|
5599
5838
|
// src/commands/org/role.ts
|
|
5600
|
-
import { Argument, Command as
|
|
5601
|
-
var roleCommand = new
|
|
5839
|
+
import { Argument, Command as Command57 } from "commander";
|
|
5840
|
+
var roleCommand = new Command57("role").description("change a member's role (owners only)").argument("<user>", "their username").addArgument(new Argument("<role>", "owner, admin or member").choices(ORG_ROLES)).option("-o, --org <slug>", "the org (default: the current context)").action(async (user, role, opts, cmd) => {
|
|
5602
5841
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5603
5842
|
try {
|
|
5604
5843
|
const slug = orgFor(opts, client.target);
|
|
@@ -5610,11 +5849,11 @@ var roleCommand = new Command55("role").description("change a member's role (own
|
|
|
5610
5849
|
});
|
|
5611
5850
|
|
|
5612
5851
|
// src/commands/org/index.ts
|
|
5613
|
-
var orgCommand = new
|
|
5852
|
+
var orgCommand = new Command58("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
|
|
5614
5853
|
|
|
5615
5854
|
// src/commands/usage.ts
|
|
5616
|
-
import { Command as
|
|
5617
|
-
var usageCommand2 = new
|
|
5855
|
+
import { Command as Command59 } from "commander";
|
|
5856
|
+
var usageCommand2 = new Command59("usage").description("what your boxes and volumes used this month (or --since/--until): running time, vCPU-h, RAM and disk GiB-h, cost").option("--since <date>", "count from this date, e.g. 2026-10-01 (default: the 1st of this month)").option("--until <date>", "count up to this date (default: now)").option("--org <slug>", "one org's boxes only").option("-a, --all", "every box on the platform (platform admins only)").option("--by-user", "one line per user who made the boxes (e.g. who spent what in --org)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5618
5857
|
for (const [name, value] of [
|
|
5619
5858
|
["since", opts.since],
|
|
5620
5859
|
["until", opts.until]
|
|
@@ -5811,8 +6050,8 @@ function userRows(r) {
|
|
|
5811
6050
|
}
|
|
5812
6051
|
|
|
5813
6052
|
// src/commands/credit.ts
|
|
5814
|
-
import { Command as
|
|
5815
|
-
var creditCommand = new
|
|
6053
|
+
import { Command as Command60 } from "commander";
|
|
6054
|
+
var creditCommand = new Command60("credit").description("the prepaid credit left on your account and on each of your orgs").option("--org <slug>", "one org only").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5816
6055
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5817
6056
|
try {
|
|
5818
6057
|
if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
|
|
@@ -5841,8 +6080,8 @@ function creditRow(b, me2) {
|
|
|
5841
6080
|
}
|
|
5842
6081
|
|
|
5843
6082
|
// src/commands/redeem.ts
|
|
5844
|
-
import { Command as
|
|
5845
|
-
var redeemCommand = new
|
|
6083
|
+
import { Command as Command61 } from "commander";
|
|
6084
|
+
var redeemCommand = new Command61("redeem").description("redeem a promo code for credit, on your account or (--org) an org you own").argument("<code>", "the code, like KV-7F3K-9QXM-2HBD").option("--org <slug>", "give the credit to this org, which you own; it cannot be moved later").option("--json", "print as JSON").action(async (code, opts, cmd) => {
|
|
5846
6085
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5847
6086
|
try {
|
|
5848
6087
|
if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
|
|
@@ -5862,12 +6101,12 @@ var redeemCommand = new Command59("redeem").description("redeem a promo code for
|
|
|
5862
6101
|
// src/commands/deploy/index.ts
|
|
5863
6102
|
import { access as access5, readFile as readFile7 } from "fs/promises";
|
|
5864
6103
|
import { basename as basename2, resolve as resolve3 } from "path";
|
|
5865
|
-
import { Command as
|
|
6104
|
+
import { Command as Command62, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
|
|
5866
6105
|
|
|
5867
6106
|
// src/commands/deploy/config.ts
|
|
5868
6107
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
5869
6108
|
import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
|
|
5870
|
-
import { z as
|
|
6109
|
+
import { z as z14 } from "zod";
|
|
5871
6110
|
|
|
5872
6111
|
// src/commands/deploy/templates/docker.ts
|
|
5873
6112
|
import { readFile as readFile4 } from "fs/promises";
|
|
@@ -6291,21 +6530,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
|
|
|
6291
6530
|
var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
|
|
6292
6531
|
var CONFIG_FILE = "kvbox.json";
|
|
6293
6532
|
var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
6294
|
-
var DeployConfigSchema =
|
|
6295
|
-
template:
|
|
6296
|
-
name:
|
|
6533
|
+
var DeployConfigSchema = z14.object({
|
|
6534
|
+
template: z14.enum(TEMPLATE_IDS),
|
|
6535
|
+
name: z14.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
|
|
6297
6536
|
/** The org whose box it is; absent for the user's own. */
|
|
6298
|
-
org:
|
|
6537
|
+
org: z14.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
|
|
6299
6538
|
/** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
|
|
6300
|
-
subdomain:
|
|
6539
|
+
subdomain: z14.string().check((ctx) => {
|
|
6301
6540
|
const problem = subdomainProblem(ctx.value);
|
|
6302
6541
|
if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
|
|
6303
6542
|
}).optional(),
|
|
6304
|
-
size:
|
|
6543
|
+
size: z14.enum(SIZE_NAMES).optional(),
|
|
6305
6544
|
/** The build output directory, relative to the app; the template's default when absent. */
|
|
6306
|
-
dist:
|
|
6545
|
+
dist: z14.string().optional(),
|
|
6307
6546
|
/** The port a Next.js app or Node server serves; the template's (3000) when absent. */
|
|
6308
|
-
port:
|
|
6547
|
+
port: z14.number().int().min(1).max(65535).optional()
|
|
6309
6548
|
});
|
|
6310
6549
|
var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
|
|
6311
6550
|
var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
|
|
@@ -6317,38 +6556,38 @@ var POSTGRES_PORT = 5432;
|
|
|
6317
6556
|
var POSTGRES_IMAGE = "postgres:17";
|
|
6318
6557
|
var POSTGRES_ENV = "DATABASE_URL";
|
|
6319
6558
|
var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
|
|
6320
|
-
var ServiceSchema =
|
|
6321
|
-
template:
|
|
6559
|
+
var ServiceSchema = z14.strictObject({
|
|
6560
|
+
template: z14.enum([...TEMPLATE_IDS, POSTGRES]),
|
|
6322
6561
|
/** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
|
|
6323
|
-
dir:
|
|
6562
|
+
dir: z14.string().min(1).optional(),
|
|
6324
6563
|
/** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
|
|
6325
|
-
image:
|
|
6564
|
+
image: z14.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
|
|
6326
6565
|
/** The volume (a key of `volumes`) a postgres service keeps its data on. */
|
|
6327
|
-
volume:
|
|
6566
|
+
volume: z14.string().optional(),
|
|
6328
6567
|
/** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
|
|
6329
|
-
env:
|
|
6568
|
+
env: z14.string().optional(),
|
|
6330
6569
|
/** A docker service's build context, relative to kvbox.json, when it is not `dir` (a monorepo built from its root); the Dockerfile stays in `dir`. */
|
|
6331
|
-
context:
|
|
6332
|
-
dist:
|
|
6570
|
+
context: z14.string().min(1).optional(),
|
|
6571
|
+
dist: z14.string().optional(),
|
|
6333
6572
|
/**
|
|
6334
6573
|
* A command run once per deploy in the service's new version (a docker service: in a container of
|
|
6335
6574
|
* the new image; node, nextjs: in the new source, installed and built), with the box's variables,
|
|
6336
6575
|
* before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
|
|
6337
6576
|
*/
|
|
6338
|
-
release:
|
|
6577
|
+
release: z14.string().optional(),
|
|
6339
6578
|
/** The box port of a service with its own server; the template's (3000) when absent. */
|
|
6340
|
-
port:
|
|
6579
|
+
port: z14.number().int().min(1).max(65535).optional(),
|
|
6341
6580
|
/** The URL paths that go to this service, each with everything under it; the prefix is kept. */
|
|
6342
|
-
paths:
|
|
6581
|
+
paths: z14.array(z14.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
|
|
6343
6582
|
});
|
|
6344
|
-
var StackConfigSchema =
|
|
6583
|
+
var StackConfigSchema = z14.strictObject({
|
|
6345
6584
|
name: DeployConfigSchema.shape.name.optional(),
|
|
6346
6585
|
org: DeployConfigSchema.shape.org,
|
|
6347
6586
|
subdomain: DeployConfigSchema.shape.subdomain,
|
|
6348
6587
|
size: DeployConfigSchema.shape.size,
|
|
6349
6588
|
/** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
|
|
6350
|
-
volumes:
|
|
6351
|
-
services:
|
|
6589
|
+
volumes: z14.record(z14.string(), z14.string()).optional(),
|
|
6590
|
+
services: z14.record(z14.string(), ServiceSchema)
|
|
6352
6591
|
});
|
|
6353
6592
|
function volumeGib(text2) {
|
|
6354
6593
|
const mib = parseMib(text2);
|
|
@@ -7127,7 +7366,7 @@ async function readPackageJson(dir) {
|
|
|
7127
7366
|
}
|
|
7128
7367
|
|
|
7129
7368
|
// src/commands/deploy/index.ts
|
|
7130
|
-
var deployCommand = new
|
|
7369
|
+
var deployCommand = new Command62("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("--only <service>", "with several services in kvbox.json: deploy this one only (repeatable)", (v, all) => [...all ?? [], v]).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
|
|
7131
7370
|
const dir = resolve3(dirArg ?? ".");
|
|
7132
7371
|
const pkg = await readPackageJson2(dir);
|
|
7133
7372
|
const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
|
|
@@ -7284,15 +7523,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
|
|
|
7284
7523
|
}
|
|
7285
7524
|
|
|
7286
7525
|
// src/commands/volume/index.ts
|
|
7287
|
-
import { Command as
|
|
7526
|
+
import { Command as Command74 } from "commander";
|
|
7288
7527
|
|
|
7289
7528
|
// src/commands/volume/attach.ts
|
|
7290
|
-
import { Command as
|
|
7529
|
+
import { Command as Command63 } from "commander";
|
|
7291
7530
|
function describeMount(machine, volume2, box2) {
|
|
7292
7531
|
const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
|
|
7293
7532
|
return machine.status === "running" ? ` the box was restarted; the volume is at ${path} inside it` : ` box ${box2} is ${machine.status}; the volume is at ${path} once it runs`;
|
|
7294
7533
|
}
|
|
7295
|
-
var attachCommand = new
|
|
7534
|
+
var attachCommand = new Command63("attach").description("attach a volume to a box at /mnt/<volume> (a running box is restarted to take it)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (picked from a list when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
|
|
7296
7535
|
if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
|
|
7297
7536
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7298
7537
|
try {
|
|
@@ -7311,11 +7550,11 @@ var attachCommand = new Command61("attach").description("attach a volume to a bo
|
|
|
7311
7550
|
});
|
|
7312
7551
|
|
|
7313
7552
|
// src/commands/volume/backup/index.ts
|
|
7314
|
-
import { Command as
|
|
7553
|
+
import { Command as Command68 } from "commander";
|
|
7315
7554
|
|
|
7316
7555
|
// src/commands/volume/backup/create.ts
|
|
7317
|
-
import { Command as
|
|
7318
|
-
var createCommand4 = new
|
|
7556
|
+
import { Command as Command64 } from "commander";
|
|
7557
|
+
var createCommand4 = new Command64("create").description("back up a volume's disk to the kvbox cloud (encrypted)").argument("<volume>", "volume name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (volume2, opts, cmd) => {
|
|
7319
7558
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7320
7559
|
try {
|
|
7321
7560
|
requireCloud3(client);
|
|
@@ -7342,8 +7581,8 @@ var createCommand4 = new Command62("create").description("back up a volume's dis
|
|
|
7342
7581
|
});
|
|
7343
7582
|
|
|
7344
7583
|
// src/commands/volume/backup/ls.ts
|
|
7345
|
-
import { Command as
|
|
7346
|
-
var
|
|
7584
|
+
import { Command as Command65 } from "commander";
|
|
7585
|
+
var lsCommand10 = new Command65("ls").alias("list").description("list volume backups: every volume's, or one volume's").argument("[volume]", "volume name (default: every volume)").option("--json", "print as JSON").action(async (volume2, opts, cmd) => {
|
|
7347
7586
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7348
7587
|
try {
|
|
7349
7588
|
requireCloud3(client);
|
|
@@ -7376,8 +7615,8 @@ var lsCommand9 = new Command63("ls").alias("list").description("list volume back
|
|
|
7376
7615
|
});
|
|
7377
7616
|
|
|
7378
7617
|
// src/commands/volume/backup/restore.ts
|
|
7379
|
-
import { Command as
|
|
7380
|
-
var restoreCommand2 = new
|
|
7618
|
+
import { Command as Command66 } from "commander";
|
|
7619
|
+
var restoreCommand2 = new Command66("restore").description("put a backup back: the volume's data becomes the backup's (a running box holding it restarts)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the volume as JSON").action(async (volume2, id, opts, cmd) => {
|
|
7381
7620
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7382
7621
|
try {
|
|
7383
7622
|
requireCloud3(client);
|
|
@@ -7400,8 +7639,8 @@ var restoreCommand2 = new Command64("restore").description("put a backup back: t
|
|
|
7400
7639
|
});
|
|
7401
7640
|
|
|
7402
7641
|
// src/commands/volume/backup/rm.ts
|
|
7403
|
-
import { Command as
|
|
7404
|
-
var rmCommand9 = new
|
|
7642
|
+
import { Command as Command67 } from "commander";
|
|
7643
|
+
var rmCommand9 = new Command67("rm").alias("remove").description("remove a backup for good (a volume's that is gone too)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").action(async (volume2, id, opts, cmd) => {
|
|
7405
7644
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7406
7645
|
try {
|
|
7407
7646
|
requireCloud3(client);
|
|
@@ -7412,11 +7651,11 @@ var rmCommand9 = new Command65("rm").alias("remove").description("remove a backu
|
|
|
7412
7651
|
});
|
|
7413
7652
|
|
|
7414
7653
|
// src/commands/volume/backup/index.ts
|
|
7415
|
-
var backupCommand2 = new
|
|
7654
|
+
var backupCommand2 = new Command68("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand10).addCommand(restoreCommand2).addCommand(rmCommand9);
|
|
7416
7655
|
for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
7417
7656
|
|
|
7418
7657
|
// src/commands/volume/create.ts
|
|
7419
|
-
import { Command as
|
|
7658
|
+
import { Command as Command69 } from "commander";
|
|
7420
7659
|
function parseGib2(text2, label = "--size") {
|
|
7421
7660
|
const mib = parseMib(text2);
|
|
7422
7661
|
if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
|
|
@@ -7432,7 +7671,7 @@ function sizeProblem(answer) {
|
|
|
7432
7671
|
return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
|
|
7433
7672
|
}
|
|
7434
7673
|
}
|
|
7435
|
-
var createCommand5 = new
|
|
7674
|
+
var createCommand5 = new Command69("create").alias("new").description("create a volume for a box: an empty disk of its own at /mnt/<name> inside it (a running box is restarted)").argument("[name]", "volume name (1-12 chars; the box mounts it at /mnt/<name>; asked for when left out)").option("--size <gb>", "size in GB, like 50 or 50GB (whole GB; it only occupies what is written)").option("--box <box>", "the box it is for: made on that box's host and attached to it (required on kvbox.sh; optional with --local)").option("--json", "print the volume as JSON").action(async (nameArg, opts, cmd) => {
|
|
7436
7675
|
const ask = interactive();
|
|
7437
7676
|
if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
|
|
7438
7677
|
const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
|
|
@@ -7465,8 +7704,8 @@ var createCommand5 = new Command67("create").alias("new").description("create a
|
|
|
7465
7704
|
});
|
|
7466
7705
|
|
|
7467
7706
|
// src/commands/volume/detach.ts
|
|
7468
|
-
import { Command as
|
|
7469
|
-
var detachCommand = new
|
|
7707
|
+
import { Command as Command70 } from "commander";
|
|
7708
|
+
var detachCommand = new Command70("detach").description("detach a volume from a box; its data is kept (a running box is restarted)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (the one the volume is on when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
|
|
7470
7709
|
if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
|
|
7471
7710
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7472
7711
|
try {
|
|
@@ -7491,8 +7730,8 @@ var detachCommand = new Command68("detach").description("detach a volume from a
|
|
|
7491
7730
|
});
|
|
7492
7731
|
|
|
7493
7732
|
// src/commands/volume/grow.ts
|
|
7494
|
-
import { Command as
|
|
7495
|
-
var growCommand = new
|
|
7733
|
+
import { Command as Command71 } from "commander";
|
|
7734
|
+
var growCommand = new Command71("grow").alias("resize").description("make a volume larger (a running box holding it is restarted once)").argument("<volume>", "volume name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the volume as JSON").action(async (name, size, opts, cmd) => {
|
|
7496
7735
|
const sizeGib = parseGib2(size, "size");
|
|
7497
7736
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7498
7737
|
try {
|
|
@@ -7505,8 +7744,8 @@ var growCommand = new Command69("grow").alias("resize").description("make a volu
|
|
|
7505
7744
|
});
|
|
7506
7745
|
|
|
7507
7746
|
// src/commands/volume/ls.ts
|
|
7508
|
-
import { Command as
|
|
7509
|
-
var
|
|
7747
|
+
import { Command as Command72 } from "commander";
|
|
7748
|
+
var lsCommand11 = new Command72("ls").alias("list").description("list volumes: size, what they occupy, which box has them").option("-a, --all", "every volume on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
7510
7749
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7511
7750
|
try {
|
|
7512
7751
|
const cloud = client.target.kind === "cloud";
|
|
@@ -7537,8 +7776,8 @@ var lsCommand10 = new Command70("ls").alias("list").description("list volumes: s
|
|
|
7537
7776
|
});
|
|
7538
7777
|
|
|
7539
7778
|
// src/commands/volume/rm.ts
|
|
7540
|
-
import { Command as
|
|
7541
|
-
var rmCommand10 = new
|
|
7779
|
+
import { Command as Command73 } from "commander";
|
|
7780
|
+
var rmCommand10 = new Command73("rm").alias("remove").description("delete a volume and everything on it (detach it first)").argument("<name>", "volume name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
7542
7781
|
if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
|
|
7543
7782
|
info("cancelled");
|
|
7544
7783
|
process.exitCode = 1;
|
|
@@ -7554,18 +7793,18 @@ var rmCommand10 = new Command71("rm").alias("remove").description("delete a volu
|
|
|
7554
7793
|
});
|
|
7555
7794
|
|
|
7556
7795
|
// src/commands/volume/index.ts
|
|
7557
|
-
var volumeCommand = new
|
|
7796
|
+
var volumeCommand = new Command74("volume").aliases(["volumes", "vol"]).description("disks of their own: create one, attach it to a box at /mnt/<name>, move it to another box later").addCommand(createCommand5).addCommand(lsCommand11).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
|
|
7558
7797
|
for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
7559
7798
|
volumeCommand.addCommand(backupCommand2);
|
|
7560
7799
|
|
|
7561
7800
|
// src/commands/bucket/index.ts
|
|
7562
|
-
import { Command as
|
|
7801
|
+
import { Command as Command90 } from "commander";
|
|
7563
7802
|
|
|
7564
7803
|
// src/commands/bucket/backup/index.ts
|
|
7565
|
-
import { Command as
|
|
7804
|
+
import { Command as Command79 } from "commander";
|
|
7566
7805
|
|
|
7567
7806
|
// src/commands/bucket/backup/create.ts
|
|
7568
|
-
import { Command as
|
|
7807
|
+
import { Command as Command75 } from "commander";
|
|
7569
7808
|
|
|
7570
7809
|
// src/commands/bucket/shared.ts
|
|
7571
7810
|
async function bucketClient(cmd) {
|
|
@@ -7591,7 +7830,7 @@ function printRows(rows2) {
|
|
|
7591
7830
|
}
|
|
7592
7831
|
|
|
7593
7832
|
// src/commands/bucket/backup/create.ts
|
|
7594
|
-
var createCommand6 = new
|
|
7833
|
+
var createCommand6 = new Command75("create").description("back up your object storage (every bucket and key) to the kvbox cloud, encrypted").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (opts, cmd) => {
|
|
7595
7834
|
const client = await bucketClient(cmd);
|
|
7596
7835
|
const ls = "kvbox bucket backup ls";
|
|
7597
7836
|
try {
|
|
@@ -7619,8 +7858,8 @@ var createCommand6 = new Command73("create").description("back up your object st
|
|
|
7619
7858
|
});
|
|
7620
7859
|
|
|
7621
7860
|
// src/commands/bucket/backup/ls.ts
|
|
7622
|
-
import { Command as
|
|
7623
|
-
var
|
|
7861
|
+
import { Command as Command76 } from "commander";
|
|
7862
|
+
var lsCommand12 = new Command76("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
7624
7863
|
const client = await bucketClient(cmd);
|
|
7625
7864
|
try {
|
|
7626
7865
|
const list = await client.storageBackups();
|
|
@@ -7652,8 +7891,8 @@ var lsCommand11 = new Command74("ls").alias("list").description("list the backup
|
|
|
7652
7891
|
});
|
|
7653
7892
|
|
|
7654
7893
|
// src/commands/bucket/backup/restore.ts
|
|
7655
|
-
import { Command as
|
|
7656
|
-
var restoreCommand3 = new
|
|
7894
|
+
import { Command as Command77 } from "commander";
|
|
7895
|
+
var restoreCommand3 = new Command77("restore").description("put a backup back: every bucket and key becomes the backup's (the storage restarts)").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").option("--json", "print what changed as JSON").action(async (id, opts, cmd) => {
|
|
7657
7896
|
const client = await bucketClient(cmd);
|
|
7658
7897
|
try {
|
|
7659
7898
|
const backup = await client.storageBackup(id);
|
|
@@ -7683,8 +7922,8 @@ var restoreCommand3 = new Command75("restore").description("put a backup back: e
|
|
|
7683
7922
|
});
|
|
7684
7923
|
|
|
7685
7924
|
// src/commands/bucket/backup/rm.ts
|
|
7686
|
-
import { Command as
|
|
7687
|
-
var rmCommand11 = new
|
|
7925
|
+
import { Command as Command78 } from "commander";
|
|
7926
|
+
var rmCommand11 = new Command78("rm").alias("remove").description("remove a backup of your object storage for good").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").action(async (id, opts, cmd) => {
|
|
7688
7927
|
const client = await bucketClient(cmd);
|
|
7689
7928
|
try {
|
|
7690
7929
|
const backup = (await client.storageBackups()).find((b) => b.id === id);
|
|
@@ -7703,11 +7942,11 @@ var rmCommand11 = new Command76("rm").alias("remove").description("remove a back
|
|
|
7703
7942
|
});
|
|
7704
7943
|
|
|
7705
7944
|
// src/commands/bucket/backup/index.ts
|
|
7706
|
-
var backupCommand3 = new
|
|
7945
|
+
var backupCommand3 = new Command79("backup").aliases(["backups"]).description("back up your object storage to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand6).addCommand(lsCommand12).addCommand(restoreCommand3).addCommand(rmCommand11);
|
|
7707
7946
|
|
|
7708
7947
|
// src/commands/bucket/create.ts
|
|
7709
|
-
import { Command as
|
|
7710
|
-
var createCommand7 = new
|
|
7948
|
+
import { Command as Command80 } from "commander";
|
|
7949
|
+
var createCommand7 = new Command80("create").description("make a bucket (the first one also makes your object storage)").argument("<name>", "bucket name: 3-63 lowercase letters, digits and '-'").option("--size <GB>", "how much your object storage may hold, when this is your first bucket (default 10)").option("--region <region>", "the S3 region of your object storage (ro-west-1, de-center-1), when this is your first bucket").option("--near <box>", "put the object storage on the host of this box, when this is your first bucket").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
7711
7950
|
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
7712
7951
|
const client = await bucketClient(cmd);
|
|
7713
7952
|
try {
|
|
@@ -7727,8 +7966,8 @@ var createCommand7 = new Command78("create").description("make a bucket (the fir
|
|
|
7727
7966
|
});
|
|
7728
7967
|
|
|
7729
7968
|
// src/commands/bucket/grow.ts
|
|
7730
|
-
import { Command as
|
|
7731
|
-
var growCommand2 = new
|
|
7969
|
+
import { Command as Command81 } from "commander";
|
|
7970
|
+
var growCommand2 = new Command81("grow").description("make your object storage larger (all your buckets share it; it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the object storage as JSON").action(async (size, opts, cmd) => {
|
|
7732
7971
|
const sizeGib = parseGib2(size, "size");
|
|
7733
7972
|
const client = await bucketClient(cmd);
|
|
7734
7973
|
try {
|
|
@@ -7741,8 +7980,8 @@ var growCommand2 = new Command79("grow").description("make your object storage l
|
|
|
7741
7980
|
});
|
|
7742
7981
|
|
|
7743
7982
|
// src/commands/bucket/info.ts
|
|
7744
|
-
import { Command as
|
|
7745
|
-
var infoCommand = new
|
|
7983
|
+
import { Command as Command82 } from "commander";
|
|
7984
|
+
var infoCommand = new Command82("info").description("one bucket: its address, what it holds, how full your object storage is").argument("<name>", "bucket name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
7746
7985
|
const client = await bucketClient(cmd);
|
|
7747
7986
|
try {
|
|
7748
7987
|
const b = await client.getBucket(name);
|
|
@@ -7772,11 +8011,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
|
|
|
7772
8011
|
});
|
|
7773
8012
|
|
|
7774
8013
|
// src/commands/bucket/key/index.ts
|
|
7775
|
-
import { Command as
|
|
8014
|
+
import { Command as Command86 } from "commander";
|
|
7776
8015
|
|
|
7777
8016
|
// src/commands/bucket/key/create.ts
|
|
7778
|
-
import { Command as
|
|
7779
|
-
var createCommand8 = new
|
|
8017
|
+
import { Command as Command83 } from "commander";
|
|
8018
|
+
var createCommand8 = new Command83("create").description("make an access key for a bucket (the secret is shown once)").argument("<bucket>", "bucket name").option("--name <label>", "what to call the key, to tell it from the others").option("--read-only", "the key reads the bucket but cannot write to it").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
|
|
7780
8019
|
const client = await bucketClient(cmd);
|
|
7781
8020
|
try {
|
|
7782
8021
|
const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
|
|
@@ -7799,8 +8038,8 @@ var createCommand8 = new Command81("create").description("make an access key for
|
|
|
7799
8038
|
});
|
|
7800
8039
|
|
|
7801
8040
|
// src/commands/bucket/key/ls.ts
|
|
7802
|
-
import { Command as
|
|
7803
|
-
var
|
|
8041
|
+
import { Command as Command84 } from "commander";
|
|
8042
|
+
var lsCommand13 = new Command84("ls").alias("list").description("list a bucket's access keys (never their secrets)").argument("<bucket>", "bucket name").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
|
|
7804
8043
|
const client = await bucketClient(cmd);
|
|
7805
8044
|
try {
|
|
7806
8045
|
const keys = await client.listBucketKeys(bucket);
|
|
@@ -7819,8 +8058,8 @@ var lsCommand12 = new Command82("ls").alias("list").description("list a bucket's
|
|
|
7819
8058
|
});
|
|
7820
8059
|
|
|
7821
8060
|
// src/commands/bucket/key/rm.ts
|
|
7822
|
-
import { Command as
|
|
7823
|
-
var rmCommand12 = new
|
|
8061
|
+
import { Command as Command85 } from "commander";
|
|
8062
|
+
var rmCommand12 = new Command85("rm").alias("remove").description("delete an access key: whatever uses it stops reaching the bucket").argument("<bucket>", "bucket name").argument("<access-key>", "the access key id (kvbox bucket key ls)").option("-y, --yes", "do not ask for confirmation").action(async (bucket, id, opts, cmd) => {
|
|
7824
8063
|
const client = await bucketClient(cmd);
|
|
7825
8064
|
try {
|
|
7826
8065
|
if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
@@ -7836,11 +8075,11 @@ var rmCommand12 = new Command83("rm").alias("remove").description("delete an acc
|
|
|
7836
8075
|
});
|
|
7837
8076
|
|
|
7838
8077
|
// src/commands/bucket/key/index.ts
|
|
7839
|
-
var keyCommand2 = new
|
|
8078
|
+
var keyCommand2 = new Command86("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
|
|
7840
8079
|
|
|
7841
8080
|
// src/commands/bucket/ls.ts
|
|
7842
|
-
import { Command as
|
|
7843
|
-
var
|
|
8081
|
+
import { Command as Command87 } from "commander";
|
|
8082
|
+
var lsCommand14 = new Command87("ls").alias("list").description("list buckets, and the object storage they are in").option("-a, --all", "every bucket on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
7844
8083
|
const client = await bucketClient(cmd);
|
|
7845
8084
|
try {
|
|
7846
8085
|
const buckets = await client.listBuckets({ all: opts.all });
|
|
@@ -7871,8 +8110,8 @@ var lsCommand13 = new Command85("ls").alias("list").description("list buckets, a
|
|
|
7871
8110
|
});
|
|
7872
8111
|
|
|
7873
8112
|
// src/commands/bucket/public.ts
|
|
7874
|
-
import { Command as
|
|
7875
|
-
var publicCommand = new
|
|
8113
|
+
import { Command as Command88 } from "commander";
|
|
8114
|
+
var publicCommand = new Command88("public").description("let anyone read a bucket's files at its own HTTPS address (on), or make it private again (off)").argument("<name>", "bucket name").argument("<state>", "on (public) or off (private)").option("--sub <name>", "the address to use, <name>.kvbox.app (default: <bucket>-<account>)").option("--json", "print the bucket as JSON").action(async (name, state, opts, cmd) => {
|
|
7876
8115
|
if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
|
|
7877
8116
|
const on = state === "on";
|
|
7878
8117
|
if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
|
|
@@ -7900,8 +8139,8 @@ var publicCommand = new Command86("public").description("let anyone read a bucke
|
|
|
7900
8139
|
});
|
|
7901
8140
|
|
|
7902
8141
|
// src/commands/bucket/rm.ts
|
|
7903
|
-
import { Command as
|
|
7904
|
-
var rmCommand13 = new
|
|
8142
|
+
import { Command as Command89 } from "commander";
|
|
8143
|
+
var rmCommand13 = new Command89("rm").alias("remove").description("delete an empty bucket and its keys (the last one takes your object storage with it)").argument("<name>", "bucket name").option("--force", "your last bucket only: delete it with everything in it").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
7905
8144
|
const client = await bucketClient(cmd);
|
|
7906
8145
|
try {
|
|
7907
8146
|
const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
|
|
@@ -7920,7 +8159,7 @@ var rmCommand13 = new Command87("rm").alias("remove").description("delete an emp
|
|
|
7920
8159
|
});
|
|
7921
8160
|
|
|
7922
8161
|
// src/commands/bucket/index.ts
|
|
7923
|
-
var bucketCommand = new
|
|
8162
|
+
var bucketCommand = new Command90("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand7).addCommand(lsCommand14).addCommand(infoCommand).addCommand(growCommand2).addCommand(publicCommand).addCommand(rmCommand13).addCommand(keyCommand2).addCommand(backupCommand3);
|
|
7924
8163
|
var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
|
|
7925
8164
|
for (const cmd of bucketCommand.commands) {
|
|
7926
8165
|
if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg);
|
|
@@ -7928,10 +8167,10 @@ for (const cmd of bucketCommand.commands) {
|
|
|
7928
8167
|
}
|
|
7929
8168
|
|
|
7930
8169
|
// src/commands/cron/index.ts
|
|
7931
|
-
import { Command as
|
|
8170
|
+
import { Command as Command103 } from "commander";
|
|
7932
8171
|
|
|
7933
8172
|
// src/commands/cron/create.ts
|
|
7934
|
-
import { Command as
|
|
8173
|
+
import { Command as Command91 } from "commander";
|
|
7935
8174
|
|
|
7936
8175
|
// src/commands/cron/shared.ts
|
|
7937
8176
|
async function cronClient(cmd) {
|
|
@@ -7992,7 +8231,7 @@ function printRows2(rows2) {
|
|
|
7992
8231
|
var noTriggers = (service) => info(`cron service ${service} has no triggers yet; add one with: kvbox cron trigger add ${service} <box> "0 6 * * *" --port 3000 (or --run "<command>")`);
|
|
7993
8232
|
|
|
7994
8233
|
// src/commands/cron/create.ts
|
|
7995
|
-
var createCommand9 = new
|
|
8234
|
+
var createCommand9 = new Command91("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
7996
8235
|
const client = await cronClient(cmd);
|
|
7997
8236
|
try {
|
|
7998
8237
|
const service = await client.createCronService(name);
|
|
@@ -8009,8 +8248,8 @@ var createCommand9 = new Command89("create").description("make a cron service: a
|
|
|
8009
8248
|
});
|
|
8010
8249
|
|
|
8011
8250
|
// src/commands/cron/info.ts
|
|
8012
|
-
import { Command as
|
|
8013
|
-
var infoCommand2 = new
|
|
8251
|
+
import { Command as Command92 } from "commander";
|
|
8252
|
+
var infoCommand2 = new Command92("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8014
8253
|
const client = await cronClient(cmd);
|
|
8015
8254
|
try {
|
|
8016
8255
|
const service = await client.getCronService(name);
|
|
@@ -8034,8 +8273,8 @@ var infoCommand2 = new Command90("info").alias("get").description("show a cron s
|
|
|
8034
8273
|
});
|
|
8035
8274
|
|
|
8036
8275
|
// src/commands/cron/ls.ts
|
|
8037
|
-
import { Command as
|
|
8038
|
-
var
|
|
8276
|
+
import { Command as Command93 } from "commander";
|
|
8277
|
+
var lsCommand15 = new Command93("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8039
8278
|
const client = await cronClient(cmd);
|
|
8040
8279
|
try {
|
|
8041
8280
|
const services = await client.listCronServices({ all: opts.all });
|
|
@@ -8055,8 +8294,8 @@ var lsCommand14 = new Command91("ls").alias("list").description("list cron servi
|
|
|
8055
8294
|
});
|
|
8056
8295
|
|
|
8057
8296
|
// src/commands/cron/rm.ts
|
|
8058
|
-
import { Command as
|
|
8059
|
-
var rmCommand14 = new
|
|
8297
|
+
import { Command as Command94 } from "commander";
|
|
8298
|
+
var rmCommand14 = new Command94("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
8060
8299
|
const client = await cronClient(cmd);
|
|
8061
8300
|
try {
|
|
8062
8301
|
if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
|
|
@@ -8072,10 +8311,10 @@ var rmCommand14 = new Command92("rm").alias("remove").description("delete a cron
|
|
|
8072
8311
|
});
|
|
8073
8312
|
|
|
8074
8313
|
// src/commands/cron/trigger/index.ts
|
|
8075
|
-
import { Command as
|
|
8314
|
+
import { Command as Command102 } from "commander";
|
|
8076
8315
|
|
|
8077
8316
|
// src/commands/cron/trigger/add.ts
|
|
8078
|
-
import { Command as
|
|
8317
|
+
import { Command as Command95 } from "commander";
|
|
8079
8318
|
function portOf(value) {
|
|
8080
8319
|
const n = Number(value);
|
|
8081
8320
|
if (!Number.isInteger(n) || n < 1 || n > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
|
|
@@ -8095,7 +8334,7 @@ function timeoutOf(value) {
|
|
|
8095
8334
|
if (sec > MAX_CRON_COMMAND_TIMEOUT_SEC) throw new KvboxError(`--timeout ${value}: a command may run for ${MAX_CRON_COMMAND_TIMEOUT_SEC / 60} minutes at most`);
|
|
8096
8335
|
return sec;
|
|
8097
8336
|
}
|
|
8098
|
-
var addCommand3 = new
|
|
8337
|
+
var addCommand3 = new Command95("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
|
|
8099
8338
|
let action;
|
|
8100
8339
|
if (opts.run !== void 0) {
|
|
8101
8340
|
if (opts.port !== void 0 || opts.path !== void 0 || opts.method !== void 0) throw new KvboxError("a trigger runs a command or calls a port: use --run, or --port with --path and --method, not both");
|
|
@@ -8122,8 +8361,8 @@ var addCommand3 = new Command93("add").description("add a trigger: on a schedule
|
|
|
8122
8361
|
});
|
|
8123
8362
|
|
|
8124
8363
|
// src/commands/cron/trigger/ls.ts
|
|
8125
|
-
import { Command as
|
|
8126
|
-
var
|
|
8364
|
+
import { Command as Command96 } from "commander";
|
|
8365
|
+
var lsCommand16 = new Command96("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
|
|
8127
8366
|
const client = await cronClient(cmd);
|
|
8128
8367
|
try {
|
|
8129
8368
|
const triggers = await client.listCronTriggers(service);
|
|
@@ -8139,8 +8378,8 @@ var lsCommand15 = new Command94("ls").alias("list").description("list a cron ser
|
|
|
8139
8378
|
});
|
|
8140
8379
|
|
|
8141
8380
|
// src/commands/cron/trigger/pause.ts
|
|
8142
|
-
import { Command as
|
|
8143
|
-
var pauseCommand2 = new
|
|
8381
|
+
import { Command as Command97 } from "commander";
|
|
8382
|
+
var pauseCommand2 = new Command97("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8144
8383
|
const client = await cronClient(cmd);
|
|
8145
8384
|
try {
|
|
8146
8385
|
const trigger = await client.setCronTriggerEnabled(service, id, false);
|
|
@@ -8155,8 +8394,8 @@ var pauseCommand2 = new Command95("pause").description("stop a trigger from firi
|
|
|
8155
8394
|
});
|
|
8156
8395
|
|
|
8157
8396
|
// src/commands/cron/trigger/resume.ts
|
|
8158
|
-
import { Command as
|
|
8159
|
-
var resumeCommand2 = new
|
|
8397
|
+
import { Command as Command98 } from "commander";
|
|
8398
|
+
var resumeCommand2 = new Command98("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8160
8399
|
const client = await cronClient(cmd);
|
|
8161
8400
|
try {
|
|
8162
8401
|
const trigger = await client.setCronTriggerEnabled(service, id, true);
|
|
@@ -8171,8 +8410,8 @@ var resumeCommand2 = new Command96("resume").description("let a paused trigger f
|
|
|
8171
8410
|
});
|
|
8172
8411
|
|
|
8173
8412
|
// src/commands/cron/trigger/rm.ts
|
|
8174
|
-
import { Command as
|
|
8175
|
-
var rmCommand15 = new
|
|
8413
|
+
import { Command as Command99 } from "commander";
|
|
8414
|
+
var rmCommand15 = new Command99("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
|
|
8176
8415
|
const client = await cronClient(cmd);
|
|
8177
8416
|
try {
|
|
8178
8417
|
if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
|
|
@@ -8188,8 +8427,8 @@ var rmCommand15 = new Command97("rm").alias("remove").description("delete a trig
|
|
|
8188
8427
|
});
|
|
8189
8428
|
|
|
8190
8429
|
// src/commands/cron/trigger/run.ts
|
|
8191
|
-
import { Command as
|
|
8192
|
-
var runCommand = new
|
|
8430
|
+
import { Command as Command100 } from "commander";
|
|
8431
|
+
var runCommand = new Command100("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8193
8432
|
const client = await cronClient(cmd);
|
|
8194
8433
|
try {
|
|
8195
8434
|
const trigger = await client.runCronTrigger(service, id);
|
|
@@ -8205,13 +8444,13 @@ var runCommand = new Command98("run").description("fire a trigger now, once, bes
|
|
|
8205
8444
|
});
|
|
8206
8445
|
|
|
8207
8446
|
// src/commands/cron/trigger/runs.ts
|
|
8208
|
-
import { Command as
|
|
8447
|
+
import { Command as Command101 } from "commander";
|
|
8209
8448
|
function limitOf(value) {
|
|
8210
8449
|
const n = Number(value);
|
|
8211
8450
|
if (!Number.isInteger(n) || n < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
|
|
8212
8451
|
return n;
|
|
8213
8452
|
}
|
|
8214
|
-
var runsCommand = new
|
|
8453
|
+
var runsCommand = new Command101("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8215
8454
|
const limit = limitOf(opts.limit);
|
|
8216
8455
|
const client = await cronClient(cmd);
|
|
8217
8456
|
try {
|
|
@@ -8241,10 +8480,10 @@ var runsCommand = new Command99("runs").aliases(["logs"]).description("show how
|
|
|
8241
8480
|
});
|
|
8242
8481
|
|
|
8243
8482
|
// src/commands/cron/trigger/index.ts
|
|
8244
|
-
var triggerCommand = new
|
|
8483
|
+
var triggerCommand = new Command102("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand16).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand15);
|
|
8245
8484
|
|
|
8246
8485
|
// src/commands/cron/index.ts
|
|
8247
|
-
var cronCommand = new
|
|
8486
|
+
var cronCommand = new Command103("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand9).addCommand(lsCommand15).addCommand(infoCommand2).addCommand(rmCommand14).addCommand(triggerCommand);
|
|
8248
8487
|
var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
|
|
8249
8488
|
for (const cmd of cronCommand.commands) {
|
|
8250
8489
|
if (cmd === triggerCommand) cmd.commands.forEach(withOrg2);
|
|
@@ -8252,13 +8491,13 @@ for (const cmd of cronCommand.commands) {
|
|
|
8252
8491
|
}
|
|
8253
8492
|
|
|
8254
8493
|
// src/commands/managed/kind.ts
|
|
8255
|
-
import { Command as
|
|
8494
|
+
import { Command as Command122 } from "commander";
|
|
8256
8495
|
|
|
8257
8496
|
// src/commands/managed/backup/index.ts
|
|
8258
|
-
import { Command as
|
|
8497
|
+
import { Command as Command110 } from "commander";
|
|
8259
8498
|
|
|
8260
8499
|
// src/commands/managed/backup/create.ts
|
|
8261
|
-
import { Command as
|
|
8500
|
+
import { Command as Command105 } from "commander";
|
|
8262
8501
|
|
|
8263
8502
|
// src/commands/managed/shared.ts
|
|
8264
8503
|
import "commander";
|
|
@@ -8356,7 +8595,7 @@ function parseStorage(text2, flag) {
|
|
|
8356
8595
|
}
|
|
8357
8596
|
|
|
8358
8597
|
// src/commands/managed/backup/create.ts
|
|
8359
|
-
var createCommand10 = (spec) => new
|
|
8598
|
+
var createCommand10 = (spec) => new Command105("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
|
|
8360
8599
|
const client = await managedClient(cmd);
|
|
8361
8600
|
const ls = `kvbox ${spec.command} backup ls ${name}`;
|
|
8362
8601
|
try {
|
|
@@ -8383,8 +8622,8 @@ var createCommand10 = (spec) => new Command103("create").description("back up a
|
|
|
8383
8622
|
});
|
|
8384
8623
|
|
|
8385
8624
|
// src/commands/managed/backup/ls.ts
|
|
8386
|
-
import { Command as
|
|
8387
|
-
var
|
|
8625
|
+
import { Command as Command106 } from "commander";
|
|
8626
|
+
var lsCommand17 = (spec) => {
|
|
8388
8627
|
const removedOnes = async (err, name, client) => {
|
|
8389
8628
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
8390
8629
|
const gone = (await client.listManagedBackups(spec.kind)).filter((b) => b.name === name || `${b.owner}/${b.name}` === name);
|
|
@@ -8392,7 +8631,7 @@ var lsCommand16 = (spec) => {
|
|
|
8392
8631
|
const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
|
|
8393
8632
|
return own.length > 0 ? own : gone;
|
|
8394
8633
|
};
|
|
8395
|
-
return new
|
|
8634
|
+
return new Command106("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8396
8635
|
const client = await managedClient(cmd);
|
|
8397
8636
|
try {
|
|
8398
8637
|
const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
|
|
@@ -8435,8 +8674,8 @@ var lsCommand16 = (spec) => {
|
|
|
8435
8674
|
};
|
|
8436
8675
|
|
|
8437
8676
|
// src/commands/managed/backup/restore.ts
|
|
8438
|
-
import { Command as
|
|
8439
|
-
var restoreCommand4 = (spec) => new
|
|
8677
|
+
import { Command as Command107 } from "commander";
|
|
8678
|
+
var restoreCommand4 = (spec) => new Command107("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
|
|
8440
8679
|
const client = await managedClient(cmd);
|
|
8441
8680
|
try {
|
|
8442
8681
|
const backup = await client.managedBackup(spec.kind, name, id);
|
|
@@ -8458,8 +8697,8 @@ var restoreCommand4 = (spec) => new Command105("restore").description("put a bac
|
|
|
8458
8697
|
});
|
|
8459
8698
|
|
|
8460
8699
|
// src/commands/managed/backup/rm.ts
|
|
8461
|
-
import { Command as
|
|
8462
|
-
var rmCommand16 = (spec) => new
|
|
8700
|
+
import { Command as Command108 } from "commander";
|
|
8701
|
+
var rmCommand16 = (spec) => new Command108("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
|
|
8463
8702
|
const client = await managedClient(cmd);
|
|
8464
8703
|
try {
|
|
8465
8704
|
await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
|
|
@@ -8469,8 +8708,8 @@ var rmCommand16 = (spec) => new Command106("rm").alias("remove").description("re
|
|
|
8469
8708
|
});
|
|
8470
8709
|
|
|
8471
8710
|
// src/commands/managed/backup/schedule.ts
|
|
8472
|
-
import { Command as
|
|
8473
|
-
var scheduleCommand = (spec) => new
|
|
8711
|
+
import { Command as Command109 } from "commander";
|
|
8712
|
+
var scheduleCommand = (spec) => new Command109("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name").option("--at <hour>", "back it up daily at this hour, 0-23 UTC (turns it on)").option("--off", "stop backing it up on its own").option("--on", "back it up on its own again, at the hour it had").option("--json", "print the schedule as JSON").action(async (name, opts, cmd) => {
|
|
8474
8713
|
if (opts.off && (opts.on || opts.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
|
|
8475
8714
|
const hour = opts.at === void 0 ? void 0 : parseHour(opts.at);
|
|
8476
8715
|
const client = await managedClient(cmd);
|
|
@@ -8500,18 +8739,18 @@ function parseHour(text2) {
|
|
|
8500
8739
|
|
|
8501
8740
|
// src/commands/managed/backup/index.ts
|
|
8502
8741
|
var backupCommand4 = (spec) => {
|
|
8503
|
-
const command = new
|
|
8504
|
-
for (const make of [createCommand10,
|
|
8742
|
+
const command = new Command110("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
|
|
8743
|
+
for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16, scheduleCommand]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
8505
8744
|
return command;
|
|
8506
8745
|
};
|
|
8507
8746
|
|
|
8508
8747
|
// src/commands/managed/create.ts
|
|
8509
|
-
import { Command as
|
|
8748
|
+
import { Command as Command111 } from "commander";
|
|
8510
8749
|
import { setTimeout as sleep5 } from "timers/promises";
|
|
8511
8750
|
var READY_WAIT_MS = 9e4;
|
|
8512
8751
|
var READY_STEP_MS = 2e3;
|
|
8513
8752
|
var createCommand11 = (spec) => {
|
|
8514
|
-
const command = new
|
|
8753
|
+
const command = new Command111("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
|
|
8515
8754
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
8516
8755
|
return command.option("--password <password>", "its password (default: generated)").option("--storage <gb>", `storage for the data in GB (default: ${spec.storageGib}; it can grow later)`).option("--near <box>", "run it on the host of this box, so the box can be linked to it").option("--from-backup <id>", `start it on this backup's data, a removed database's too (kvbox ${spec.command} backup ls)`).option("--json", "print it as JSON, password included").action(async (name, opts, cmd) => {
|
|
8517
8756
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -8560,8 +8799,8 @@ var createCommand11 = (spec) => {
|
|
|
8560
8799
|
};
|
|
8561
8800
|
|
|
8562
8801
|
// src/commands/managed/grow.ts
|
|
8563
|
-
import { Command as
|
|
8564
|
-
var growCommand3 = (spec) => new
|
|
8802
|
+
import { Command as Command112 } from "commander";
|
|
8803
|
+
var growCommand3 = (spec) => new Command112("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
|
|
8565
8804
|
const storageGib = parseStorage(size, "size");
|
|
8566
8805
|
const client = await managedClient(cmd);
|
|
8567
8806
|
try {
|
|
@@ -8574,8 +8813,8 @@ var growCommand3 = (spec) => new Command110("grow").description("give a database
|
|
|
8574
8813
|
});
|
|
8575
8814
|
|
|
8576
8815
|
// src/commands/managed/info.ts
|
|
8577
|
-
import { Command as
|
|
8578
|
-
var infoCommand3 = (spec) => new
|
|
8816
|
+
import { Command as Command113 } from "commander";
|
|
8817
|
+
var infoCommand3 = (spec) => new Command113("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8579
8818
|
const client = await managedClient(cmd);
|
|
8580
8819
|
try {
|
|
8581
8820
|
const m = await client.getManaged(spec.kind, name);
|
|
@@ -8587,8 +8826,8 @@ var infoCommand3 = (spec) => new Command111("info").alias("get").description("sh
|
|
|
8587
8826
|
});
|
|
8588
8827
|
|
|
8589
8828
|
// src/commands/managed/link.ts
|
|
8590
|
-
import { Command as
|
|
8591
|
-
var linkCommand2 = (spec) => new
|
|
8829
|
+
import { Command as Command114 } from "commander";
|
|
8830
|
+
var linkCommand2 = (spec) => new Command114("link").description("let a box reach a database privately (same host)").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
|
|
8592
8831
|
const client = await managedClient(cmd);
|
|
8593
8832
|
try {
|
|
8594
8833
|
const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
|
|
@@ -8604,7 +8843,7 @@ var linkCommand2 = (spec) => new Command112("link").description("let a box reach
|
|
|
8604
8843
|
});
|
|
8605
8844
|
|
|
8606
8845
|
// src/commands/managed/ls.ts
|
|
8607
|
-
import { Command as
|
|
8846
|
+
import { Command as Command115 } from "commander";
|
|
8608
8847
|
function listRows(items, user, kindColumn) {
|
|
8609
8848
|
return items.map((m) => ({
|
|
8610
8849
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -8618,7 +8857,7 @@ function listRows(items, user, kindColumn) {
|
|
|
8618
8857
|
created: age(m.createdAt)
|
|
8619
8858
|
}));
|
|
8620
8859
|
}
|
|
8621
|
-
var
|
|
8860
|
+
var lsCommand18 = (spec) => new Command115("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8622
8861
|
const client = await managedClient(cmd);
|
|
8623
8862
|
try {
|
|
8624
8863
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -8638,8 +8877,8 @@ var lsCommand17 = (spec) => new Command113("ls").alias("list").description(spec
|
|
|
8638
8877
|
});
|
|
8639
8878
|
|
|
8640
8879
|
// src/commands/managed/password.ts
|
|
8641
|
-
import { Command as
|
|
8642
|
-
var passwordCommand = (spec) => new
|
|
8880
|
+
import { Command as Command116 } from "commander";
|
|
8881
|
+
var passwordCommand = (spec) => new Command116("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8643
8882
|
const client = await managedClient(cmd);
|
|
8644
8883
|
try {
|
|
8645
8884
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -8655,8 +8894,8 @@ var passwordCommand = (spec) => new Command114("password").description("show a d
|
|
|
8655
8894
|
});
|
|
8656
8895
|
|
|
8657
8896
|
// src/commands/managed/public.ts
|
|
8658
|
-
import { Command as
|
|
8659
|
-
var publicCommand2 = (spec) => new
|
|
8897
|
+
import { Command as Command117 } from "commander";
|
|
8898
|
+
var publicCommand2 = (spec) => new Command117("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
|
|
8660
8899
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
8661
8900
|
const client = await managedClient(cmd);
|
|
8662
8901
|
try {
|
|
@@ -8677,8 +8916,8 @@ var publicCommand2 = (spec) => new Command115("public").description("open a data
|
|
|
8677
8916
|
});
|
|
8678
8917
|
|
|
8679
8918
|
// src/commands/managed/rm.ts
|
|
8680
|
-
import { Command as
|
|
8681
|
-
var rmCommand17 = (spec) => new
|
|
8919
|
+
import { Command as Command118 } from "commander";
|
|
8920
|
+
var rmCommand17 = (spec) => new Command118("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
8682
8921
|
const client = await managedClient(cmd);
|
|
8683
8922
|
try {
|
|
8684
8923
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -8694,8 +8933,8 @@ var rmCommand17 = (spec) => new Command116("rm").alias("remove").description("de
|
|
|
8694
8933
|
});
|
|
8695
8934
|
|
|
8696
8935
|
// src/commands/managed/start.ts
|
|
8697
|
-
import { Command as
|
|
8698
|
-
var startCommand2 = (spec) => new
|
|
8936
|
+
import { Command as Command119 } from "commander";
|
|
8937
|
+
var startCommand2 = (spec) => new Command119("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8699
8938
|
const client = await managedClient(cmd);
|
|
8700
8939
|
try {
|
|
8701
8940
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -8707,8 +8946,8 @@ var startCommand2 = (spec) => new Command117("start").description("run a stopped
|
|
|
8707
8946
|
});
|
|
8708
8947
|
|
|
8709
8948
|
// src/commands/managed/stop.ts
|
|
8710
|
-
import { Command as
|
|
8711
|
-
var stopCommand2 = (spec) => new
|
|
8949
|
+
import { Command as Command120 } from "commander";
|
|
8950
|
+
var stopCommand2 = (spec) => new Command120("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8712
8951
|
const client = await managedClient(cmd);
|
|
8713
8952
|
try {
|
|
8714
8953
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -8720,8 +8959,8 @@ var stopCommand2 = (spec) => new Command118("stop").description("shut a database
|
|
|
8720
8959
|
});
|
|
8721
8960
|
|
|
8722
8961
|
// src/commands/managed/unlink.ts
|
|
8723
|
-
import { Command as
|
|
8724
|
-
var unlinkCommand2 = (spec) => new
|
|
8962
|
+
import { Command as Command121 } from "commander";
|
|
8963
|
+
var unlinkCommand2 = (spec) => new Command121("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
|
|
8725
8964
|
const client = await managedClient(cmd);
|
|
8726
8965
|
try {
|
|
8727
8966
|
const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
|
|
@@ -8734,8 +8973,8 @@ var unlinkCommand2 = (spec) => new Command119("unlink").description("stop a box
|
|
|
8734
8973
|
|
|
8735
8974
|
// src/commands/managed/kind.ts
|
|
8736
8975
|
function kindCommand(spec, description) {
|
|
8737
|
-
const command = new
|
|
8738
|
-
for (const make of [createCommand11,
|
|
8976
|
+
const command = new Command122(spec.command).aliases(spec.aliases).description(description);
|
|
8977
|
+
for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
|
|
8739
8978
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
8740
8979
|
}
|
|
8741
8980
|
command.addCommand(backupCommand4(spec));
|
|
@@ -8749,14 +8988,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
8749
8988
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
8750
8989
|
|
|
8751
8990
|
// src/commands/managed/index.ts
|
|
8752
|
-
import { Command as
|
|
8753
|
-
var managedCommand = new
|
|
8991
|
+
import { Command as Command123 } from "commander";
|
|
8992
|
+
var managedCommand = new Command123("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand18().option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
8754
8993
|
|
|
8755
8994
|
// src/commands/env/index.ts
|
|
8756
|
-
import { Command as
|
|
8995
|
+
import { Command as Command127 } from "commander";
|
|
8757
8996
|
|
|
8758
8997
|
// src/commands/env/ls.ts
|
|
8759
|
-
import { Command as
|
|
8998
|
+
import { Command as Command124 } from "commander";
|
|
8760
8999
|
|
|
8761
9000
|
// src/commands/env/shared.ts
|
|
8762
9001
|
function requireCloud4(client) {
|
|
@@ -8783,7 +9022,7 @@ function firstBootHint(box2, name) {
|
|
|
8783
9022
|
}
|
|
8784
9023
|
|
|
8785
9024
|
// src/commands/env/ls.ts
|
|
8786
|
-
var
|
|
9025
|
+
var lsCommand19 = new Command124("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8787
9026
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
8788
9027
|
try {
|
|
8789
9028
|
if (opts.box !== void 0) {
|
|
@@ -8822,8 +9061,8 @@ var lsCommand18 = new Command122("ls").alias("list").description("list the varia
|
|
|
8822
9061
|
});
|
|
8823
9062
|
|
|
8824
9063
|
// src/commands/env/rm.ts
|
|
8825
|
-
import { Command as
|
|
8826
|
-
var rmCommand18 = new
|
|
9064
|
+
import { Command as Command125 } from "commander";
|
|
9065
|
+
var rmCommand18 = new Command125("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
|
|
8827
9066
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
8828
9067
|
try {
|
|
8829
9068
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -8860,8 +9099,8 @@ var rmCommand18 = new Command123("rm").alias("remove").description("remove varia
|
|
|
8860
9099
|
});
|
|
8861
9100
|
|
|
8862
9101
|
// src/commands/env/set.ts
|
|
8863
|
-
import { Command as
|
|
8864
|
-
var setCommand2 = new
|
|
9102
|
+
import { Command as Command126 } from "commander";
|
|
9103
|
+
var setCommand2 = new Command126("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
|
|
8865
9104
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
8866
9105
|
try {
|
|
8867
9106
|
const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
|
|
@@ -8898,14 +9137,14 @@ var setCommand2 = new Command124("set").description("add or change a variable; b
|
|
|
8898
9137
|
});
|
|
8899
9138
|
|
|
8900
9139
|
// src/commands/env/index.ts
|
|
8901
|
-
var envCommand = new
|
|
9140
|
+
var envCommand = new Command127("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
|
|
8902
9141
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
8903
9142
|
|
|
8904
9143
|
// src/commands/domain/index.ts
|
|
8905
|
-
import { Command as
|
|
9144
|
+
import { Command as Command131 } from "commander";
|
|
8906
9145
|
|
|
8907
9146
|
// src/commands/domain/add.ts
|
|
8908
|
-
import { Command as
|
|
9147
|
+
import { Command as Command128 } from "commander";
|
|
8909
9148
|
|
|
8910
9149
|
// src/commands/domain/shared.ts
|
|
8911
9150
|
function requireCloud5(client) {
|
|
@@ -8925,7 +9164,7 @@ function hostIn(name, zone) {
|
|
|
8925
9164
|
}
|
|
8926
9165
|
|
|
8927
9166
|
// src/commands/domain/add.ts
|
|
8928
|
-
var addCommand4 = new
|
|
9167
|
+
var addCommand4 = new Command128("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
|
|
8929
9168
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
8930
9169
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
8931
9170
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -8961,8 +9200,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
8961
9200
|
});
|
|
8962
9201
|
|
|
8963
9202
|
// src/commands/domain/ls.ts
|
|
8964
|
-
import { Command as
|
|
8965
|
-
var
|
|
9203
|
+
import { Command as Command129 } from "commander";
|
|
9204
|
+
var lsCommand20 = new Command129("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8966
9205
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
8967
9206
|
try {
|
|
8968
9207
|
requireCloud5(client);
|
|
@@ -8991,8 +9230,8 @@ var lsCommand19 = new Command127("ls").alias("list").description("list your cust
|
|
|
8991
9230
|
});
|
|
8992
9231
|
|
|
8993
9232
|
// src/commands/domain/rm.ts
|
|
8994
|
-
import { Command as
|
|
8995
|
-
var rmCommand19 = new
|
|
9233
|
+
import { Command as Command130 } from "commander";
|
|
9234
|
+
var rmCommand19 = new Command130("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
|
|
8996
9235
|
const domain = domainArg.trim().toLowerCase();
|
|
8997
9236
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
8998
9237
|
try {
|
|
@@ -9013,7 +9252,7 @@ var rmCommand19 = new Command128("rm").alias("remove").description("stop serving
|
|
|
9013
9252
|
});
|
|
9014
9253
|
|
|
9015
9254
|
// src/commands/domain/index.ts
|
|
9016
|
-
var domainCommand = new
|
|
9255
|
+
var domainCommand = new Command131("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
|
|
9017
9256
|
for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
9018
9257
|
|
|
9019
9258
|
// src/commands/update.ts
|
|
@@ -9021,7 +9260,7 @@ import { spawn as spawn8 } from "child_process";
|
|
|
9021
9260
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
9022
9261
|
import { tmpdir } from "os";
|
|
9023
9262
|
import { join as join9 } from "path";
|
|
9024
|
-
import { Command as
|
|
9263
|
+
import { Command as Command132 } from "commander";
|
|
9025
9264
|
|
|
9026
9265
|
// src/update.ts
|
|
9027
9266
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -9140,7 +9379,7 @@ function run2(cmd, args) {
|
|
|
9140
9379
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
9141
9380
|
});
|
|
9142
9381
|
}
|
|
9143
|
-
var selfUpdateCommand = new
|
|
9382
|
+
var selfUpdateCommand = new Command132("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
9144
9383
|
suppressUpdateNotice();
|
|
9145
9384
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
9146
9385
|
let code;
|
|
@@ -9211,6 +9450,7 @@ var HELP_GROUPS = [
|
|
|
9211
9450
|
["managed", "every managed database, whatever its kind"],
|
|
9212
9451
|
["cron", "call a box on a schedule, waking it first if it sleeps"],
|
|
9213
9452
|
["env", "environment variables and secrets every box of yours gets"],
|
|
9453
|
+
["integration", "accounts (GitHub, Claude Code) your boxes use once you turn them on"],
|
|
9214
9454
|
["domain", "serve a box at a domain of your own"]
|
|
9215
9455
|
]
|
|
9216
9456
|
},
|
|
@@ -9268,7 +9508,7 @@ function installRootHelp(program) {
|
|
|
9268
9508
|
|
|
9269
9509
|
// src/program.ts
|
|
9270
9510
|
function buildProgram() {
|
|
9271
|
-
const program = new
|
|
9511
|
+
const program = new Command133("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login and KVBOX_TOKEN").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
|
|
9272
9512
|
program.addCommand(vmCommand);
|
|
9273
9513
|
program.addCommand(snapshotsCommand);
|
|
9274
9514
|
program.addCommand(volumeCommand);
|
|
@@ -9283,6 +9523,7 @@ function buildProgram() {
|
|
|
9283
9523
|
program.addCommand(logoutCommand);
|
|
9284
9524
|
program.addCommand(whoamiCommand);
|
|
9285
9525
|
program.addCommand(keyCommand);
|
|
9526
|
+
program.addCommand(integrationCommand);
|
|
9286
9527
|
program.addCommand(orgCommand);
|
|
9287
9528
|
program.addCommand(usageCommand2);
|
|
9288
9529
|
program.addCommand(creditCommand);
|