@vibiz/cli 0.2.0 → 0.2.1
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/{chunk-GSHNECVT.js → chunk-J4RTAA72.js} +48 -29
- package/dist/src-IAT2AUWC.js +3376 -0
- package/dist/vibiz.js +145 -44
- package/package.json +1 -1
- package/dist/src-2CVAECWM.js +0 -3392
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// packages/sdk/src/client.ts
|
|
4
|
+
function noBodyMessage(status) {
|
|
5
|
+
if (status === 401) return "Not signed in (401): the API key is missing or was revoked.";
|
|
6
|
+
if (status === 404) return "Not found (404): check the API URL and the id.";
|
|
7
|
+
if (status === 413) return "Too large (413): send less at once.";
|
|
8
|
+
if (status === 429) return "Too many requests (429): wait a moment and retry.";
|
|
9
|
+
if (status >= 500) {
|
|
10
|
+
return `The Vibiz API did not answer properly (${status}). It is usually brief: retry in a minute.`;
|
|
11
|
+
}
|
|
12
|
+
return `The request failed with ${status} and no explanation from the API.`;
|
|
13
|
+
}
|
|
4
14
|
var VibizApiError = class extends Error {
|
|
5
15
|
constructor(status, code, message, details) {
|
|
6
16
|
super(message);
|
|
@@ -32,6 +42,7 @@ var Vibiz = class {
|
|
|
32
42
|
if (init.raw) headers["content-type"] = init.contentType ?? "application/octet-stream";
|
|
33
43
|
if (init.idempotencyKey) headers["idempotency-key"] = init.idempotencyKey;
|
|
34
44
|
if (this.options.user) headers["x-vibiz-user"] = endUserHeader(this.options.user);
|
|
45
|
+
if (this.options.client) headers["x-vibiz-client"] = this.options.client;
|
|
35
46
|
return this.fetchImpl(`${this.baseUrl}/v1${path}`, {
|
|
36
47
|
method: init.method ?? "GET",
|
|
37
48
|
headers,
|
|
@@ -44,7 +55,7 @@ var Vibiz = class {
|
|
|
44
55
|
throw new VibizApiError(
|
|
45
56
|
res.status,
|
|
46
57
|
e?.code ?? "http_error",
|
|
47
|
-
e?.message ??
|
|
58
|
+
e?.message ?? noBodyMessage(res.status),
|
|
48
59
|
e?.details
|
|
49
60
|
);
|
|
50
61
|
}
|
|
@@ -63,7 +74,7 @@ var Vibiz = class {
|
|
|
63
74
|
throw new VibizApiError(
|
|
64
75
|
res.status,
|
|
65
76
|
e?.code ?? "http_error",
|
|
66
|
-
e?.message ??
|
|
77
|
+
e?.message ?? noBodyMessage(res.status),
|
|
67
78
|
e?.details
|
|
68
79
|
);
|
|
69
80
|
}
|
|
@@ -104,7 +115,7 @@ var Vibiz = class {
|
|
|
104
115
|
`/projects/${id}/actions/${name}`,
|
|
105
116
|
{ method: "POST", body: { input }, ...opts }
|
|
106
117
|
),
|
|
107
|
-
/** The production env.
|
|
118
|
+
/** The production env. Full-access keys only: a Limited key gets `forbidden` (use `dev`). */
|
|
108
119
|
env: (id) => this.request(`/projects/${id}/env`).then((r) => r.env),
|
|
109
120
|
/** The production env's variable names, without values. Any key. */
|
|
110
121
|
envNames: (id) => this.request(`/projects/${id}/env?names=1`).then((r) => r.names),
|
|
@@ -156,10 +167,10 @@ var Vibiz = class {
|
|
|
156
167
|
/** The app key (`vz_app_…`), per environment. The secret itself only ever travels in the env. */
|
|
157
168
|
appKeys: {
|
|
158
169
|
list: (id) => this.request(`/projects/${id}/app-keys`).then((r) => r.data),
|
|
159
|
-
/** Production's needs
|
|
170
|
+
/** Production's needs a full-access key. The old key works for `grace_seconds` (default 3600). */
|
|
160
171
|
rotate: (id, opts = {}) => this.request(`/projects/${id}/app-keys/rotate`, { method: "POST", body: opts })
|
|
161
172
|
},
|
|
162
|
-
/** Hosts outside Vibiz that receive the env server to server. Connecting needs
|
|
173
|
+
/** Hosts outside Vibiz that receive the env server to server. Connecting needs a full-access key. */
|
|
163
174
|
hosts: {
|
|
164
175
|
list: (id) => this.request(`/projects/${id}/hosts`).then((r) => r.data),
|
|
165
176
|
add: (id, input) => this.request(`/projects/${id}/hosts`, { method: "POST", body: input }),
|
|
@@ -173,7 +184,7 @@ var Vibiz = class {
|
|
|
173
184
|
)
|
|
174
185
|
},
|
|
175
186
|
/**
|
|
176
|
-
* The app's own database. `production` needs
|
|
187
|
+
* The app's own database. `production` needs a full-access key (it holds the
|
|
177
188
|
* app's users' data); agents read `development`, the default for them.
|
|
178
189
|
*/
|
|
179
190
|
database: {
|
|
@@ -188,7 +199,7 @@ var Vibiz = class {
|
|
|
188
199
|
},
|
|
189
200
|
/**
|
|
190
201
|
* How people sign in to the app (docs/SIGN-IN.md). `production` needs an
|
|
191
|
-
*
|
|
202
|
+
* full-access key; agents work on `development`, the default for them.
|
|
192
203
|
*/
|
|
193
204
|
auth: {
|
|
194
205
|
get: (id, env) => this.request(`/projects/${id}/auth/settings${env ? `?env=${env}` : ""}`),
|
|
@@ -214,7 +225,7 @@ var Vibiz = class {
|
|
|
214
225
|
/**
|
|
215
226
|
* The business behind the project (docs/COMPANY.md). `env` defaults like
|
|
216
227
|
* the API: production for owners, development for agents. Production
|
|
217
|
-
* submit, signing, actions and documents need
|
|
228
|
+
* submit, signing, actions and documents need a full-access key.
|
|
218
229
|
*/
|
|
219
230
|
company: {
|
|
220
231
|
get: (id, env) => this.request(`/projects/${id}/company${envQuery(env)}`),
|
|
@@ -233,7 +244,7 @@ var Vibiz = class {
|
|
|
233
244
|
{ method: "DELETE" }
|
|
234
245
|
),
|
|
235
246
|
/**
|
|
236
|
-
* Production files for real and charges the price:
|
|
247
|
+
* Production files for real and charges the price: a full-access key, `confirm: true`,
|
|
237
248
|
* and the `quote.total_cents` and `updated_at` of the draft that was reviewed
|
|
238
249
|
* (a draft or price changed since is refused with a 409, not filed).
|
|
239
250
|
*/
|
|
@@ -242,7 +253,7 @@ var Vibiz = class {
|
|
|
242
253
|
body: input
|
|
243
254
|
}),
|
|
244
255
|
/**
|
|
245
|
-
* Pay a live filing by card instead of from the balance (
|
|
256
|
+
* Pay a live filing by card instead of from the balance (full-access keys): the same
|
|
246
257
|
* body as `submit`; it is filed when the payment arrives (docs/BILLING.md "Company").
|
|
247
258
|
*/
|
|
248
259
|
checkout: (id, input) => this.request(`/projects/${id}/company/checkout?env=production`, {
|
|
@@ -356,7 +367,7 @@ var Vibiz = class {
|
|
|
356
367
|
* Payments (docs/PAYMENTS.md): Vibiz is the merchant, so an app sells from
|
|
357
368
|
* its first call. `env` defaults like the API: production for owners,
|
|
358
369
|
* development for agents. On production, refunds, cancels, withdrawing,
|
|
359
|
-
* payout setup and webhook settings need
|
|
370
|
+
* payout setup and webhook settings need a full-access key.
|
|
360
371
|
*/
|
|
361
372
|
payments: {
|
|
362
373
|
get: (id, env) => this.request(`/projects/${id}/payments${envQuery(env)}`),
|
|
@@ -468,7 +479,7 @@ var Vibiz = class {
|
|
|
468
479
|
* Custom connectors (docs/CONNECTORS.md): any HTTP API from one manifest,
|
|
469
480
|
* called through Vibiz, which holds the key. `env` defaults like the API:
|
|
470
481
|
* production for owners, development for agents. Production keys, and
|
|
471
|
-
* approving an agent's dangerous call, need
|
|
482
|
+
* approving an agent's dangerous call, need a full-access key.
|
|
472
483
|
*/
|
|
473
484
|
connectors: {
|
|
474
485
|
list: (id) => this.request(`/projects/${id}/connectors`).then((r) => r.data),
|
|
@@ -487,7 +498,7 @@ var Vibiz = class {
|
|
|
487
498
|
delete: (id, name) => this.request(`/projects/${id}/connectors/${encodeURIComponent(name)}`, {
|
|
488
499
|
method: "DELETE"
|
|
489
500
|
}),
|
|
490
|
-
/** Set values (`null` removes). Production:
|
|
501
|
+
/** Set values (`null` removes). Production: full-access keys. Values are never read back. */
|
|
491
502
|
setSecrets: (id, name, values, env) => this.request(
|
|
492
503
|
`/projects/${id}/connectors/${encodeURIComponent(name)}/secrets${envQuery(env)}`,
|
|
493
504
|
{ method: "PUT", body: { values } }
|
|
@@ -496,7 +507,7 @@ var Vibiz = class {
|
|
|
496
507
|
`/projects/${id}/connectors/${encodeURIComponent(name)}/check${envQuery(env)}`,
|
|
497
508
|
{ method: "POST", body: {} }
|
|
498
509
|
),
|
|
499
|
-
/** One operation. A dangerous one (or a production write) by
|
|
510
|
+
/** One operation. A dangerous one (or a production write) by a Limited key answers 403 approval_required. */
|
|
500
511
|
call: (id, name, input, opts = {}) => this.request(
|
|
501
512
|
`/projects/${id}/connectors/${encodeURIComponent(name)}/call${envQuery(opts.env)}`,
|
|
502
513
|
{
|
|
@@ -514,12 +525,12 @@ var Vibiz = class {
|
|
|
514
525
|
approval: (id, approvalId) => this.request(
|
|
515
526
|
`/projects/${id}/connectors/approvals/${encodeURIComponent(approvalId)}`
|
|
516
527
|
),
|
|
517
|
-
/**
|
|
528
|
+
/** Full-access keys. */
|
|
518
529
|
approve: (id, approvalId) => this.request(
|
|
519
530
|
`/projects/${id}/connectors/approvals/${encodeURIComponent(approvalId)}/approve`,
|
|
520
531
|
{ method: "POST", body: {} }
|
|
521
532
|
),
|
|
522
|
-
/**
|
|
533
|
+
/** Full-access keys. */
|
|
523
534
|
deny: (id, approvalId) => this.request(
|
|
524
535
|
`/projects/${id}/connectors/approvals/${encodeURIComponent(approvalId)}/deny`,
|
|
525
536
|
{ method: "POST", body: {} }
|
|
@@ -528,7 +539,7 @@ var Vibiz = class {
|
|
|
528
539
|
/**
|
|
529
540
|
* The owner's own domains: served by Vibiz hosting (with HTTPS once DNS
|
|
530
541
|
* points at it) or trusted for a host elsewhere. Adding and removing need
|
|
531
|
-
*
|
|
542
|
+
* a full-access key; any key reads status and asks for a re-check.
|
|
532
543
|
*/
|
|
533
544
|
domains: {
|
|
534
545
|
list: (id) => this.request(`/projects/${id}/domains`),
|
|
@@ -546,8 +557,8 @@ var Vibiz = class {
|
|
|
546
557
|
method: "DELETE"
|
|
547
558
|
}),
|
|
548
559
|
/**
|
|
549
|
-
*
|
|
550
|
-
* project once registered.
|
|
560
|
+
* Full-access keys: buy a domain from the account's credits; it serves on this
|
|
561
|
+
* project once registered. A Limited key answers `owner_only` with the
|
|
551
562
|
* console link to hand the owner.
|
|
552
563
|
*/
|
|
553
564
|
buy: (id, input) => this.request(`/projects/${id}/domains/buy`, { method: "POST", body: input })
|
|
@@ -655,7 +666,7 @@ var Vibiz = class {
|
|
|
655
666
|
return res;
|
|
656
667
|
},
|
|
657
668
|
/**
|
|
658
|
-
* The environment's secret values as `.env` text.
|
|
669
|
+
* The environment's secret values as `.env` text. Full-access keys only; the
|
|
659
670
|
* call itself is the confirmation, so only make it when the person asked.
|
|
660
671
|
*/
|
|
661
672
|
envFile: async (projectId, exportId) => {
|
|
@@ -1036,7 +1047,7 @@ var Vibiz = class {
|
|
|
1036
1047
|
* Your own AI provider keys (docs/AI.md "Your own keys"): calls they can
|
|
1037
1048
|
* serve run only on them (never falling back to Vibiz) and cost 0 here.
|
|
1038
1049
|
* Pass `projectId` for a project's override. Setting and removing need an
|
|
1039
|
-
*
|
|
1050
|
+
* full-access key. Secrets are write-only: no method returns one.
|
|
1040
1051
|
*/
|
|
1041
1052
|
aiKeys = {
|
|
1042
1053
|
list: (opts = {}) => this.request(`${aiKeysBase(opts.projectId)}`),
|
|
@@ -1067,7 +1078,7 @@ var Vibiz = class {
|
|
|
1067
1078
|
/**
|
|
1068
1079
|
* Buying domains (docs: buying a domain): search and quote with any key;
|
|
1069
1080
|
* the domains the account owns, auto-renew, renewals, the transfer code and
|
|
1070
|
-
* the owner details (the registrant, saved once) need
|
|
1081
|
+
* the owner details (the registrant, saved once) need a full-access key.
|
|
1071
1082
|
*/
|
|
1072
1083
|
domains = {
|
|
1073
1084
|
search: (q, opts = {}) => this.request(`/domains/search${qs({ q, project_id: opts.projectId })}`),
|
|
@@ -1090,7 +1101,7 @@ var Vibiz = class {
|
|
|
1090
1101
|
/**
|
|
1091
1102
|
* Email forwarding (docs: email ▸ Forwarding): `hello@<domain>` → the
|
|
1092
1103
|
* owner's inbox, sent "via Vibiz". Anyone reads and verifies; `set` and
|
|
1093
|
-
* `off` need
|
|
1104
|
+
* `off` need a full-access key (an agent gets `owner_only` with a console link
|
|
1094
1105
|
* that has its proposal filled in).
|
|
1095
1106
|
*/
|
|
1096
1107
|
forwarding: {
|
|
@@ -1149,7 +1160,7 @@ var Vibiz = class {
|
|
|
1149
1160
|
method: "PATCH",
|
|
1150
1161
|
body: input
|
|
1151
1162
|
}),
|
|
1152
|
-
/**
|
|
1163
|
+
/** Full-access keys; only from trash or spam. */
|
|
1153
1164
|
delete: (id) => this.request(
|
|
1154
1165
|
`/inbox/threads/${encodeURIComponent(id)}`,
|
|
1155
1166
|
{ method: "DELETE" }
|
|
@@ -1180,7 +1191,7 @@ var Vibiz = class {
|
|
|
1180
1191
|
}),
|
|
1181
1192
|
settings: {
|
|
1182
1193
|
get: () => this.request("/inbox/settings"),
|
|
1183
|
-
/**
|
|
1194
|
+
/** Full-access keys: the new-mail digest. */
|
|
1184
1195
|
update: (input) => this.request("/inbox/settings", { method: "PATCH", body: input })
|
|
1185
1196
|
}
|
|
1186
1197
|
};
|
|
@@ -1190,12 +1201,12 @@ var Vibiz = class {
|
|
|
1190
1201
|
*/
|
|
1191
1202
|
billing = {
|
|
1192
1203
|
get: () => this.request("/billing"),
|
|
1193
|
-
/**
|
|
1204
|
+
/** Full-access keys: auto-recharge and the daily safety cap. */
|
|
1194
1205
|
update: (input) => this.request("/billing", { method: "PATCH", body: input }),
|
|
1195
1206
|
/** A payment page for `amount_cents` (500–100000); hand its `url` to a person. */
|
|
1196
1207
|
checkout: (input) => this.request("/billing/checkout", { method: "POST", body: input }),
|
|
1197
1208
|
checkoutStatus: (id) => this.request(`/billing/checkout/${encodeURIComponent(id)}`),
|
|
1198
|
-
/**
|
|
1209
|
+
/** Full-access keys: a page to save or replace the card. */
|
|
1199
1210
|
saveCard: () => this.request("/billing/card", { method: "POST", body: {} }),
|
|
1200
1211
|
removeCard: () => this.request("/billing/card", { method: "DELETE" }),
|
|
1201
1212
|
ledger: (opts = {}) => this.request(
|
|
@@ -1210,12 +1221,20 @@ var Vibiz = class {
|
|
|
1210
1221
|
/** Named keys, one per teammate or agent, so spend shows per person. */
|
|
1211
1222
|
apiKeys = {
|
|
1212
1223
|
list: () => this.request("/api-keys").then((r) => r.data),
|
|
1213
|
-
/**
|
|
1214
|
-
|
|
1224
|
+
/**
|
|
1225
|
+
* The secret is returned once, here. Full access (`owner`) by default;
|
|
1226
|
+
* `access: 'agent'` makes it Limited (builds and runs, never reads
|
|
1227
|
+
* production secrets nor moves live money). Needs a full-access key.
|
|
1228
|
+
*/
|
|
1215
1229
|
create: (name, opts = {}) => this.request("/api-keys", {
|
|
1216
1230
|
method: "POST",
|
|
1217
1231
|
body: { name, ...opts.access ? { access: opts.access } : {} }
|
|
1218
1232
|
}),
|
|
1233
|
+
/** Full access (`owner`) or Limited (`agent`), afterwards. Needs a full-access key, not this one. */
|
|
1234
|
+
setAccess: (id, access) => this.request(`/api-keys/${encodeURIComponent(id)}`, {
|
|
1235
|
+
method: "PATCH",
|
|
1236
|
+
body: { access }
|
|
1237
|
+
}),
|
|
1219
1238
|
revoke: (id) => this.request(`/api-keys/${id}`, { method: "DELETE" })
|
|
1220
1239
|
};
|
|
1221
1240
|
/** A short-lived link to the hosted usage dashboard (admin scope needs an admin key). */
|