@vibiz/cli 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GSHNECVT.js → chunk-OKWUSSLA.js} +85 -30
- package/dist/src-BY7YFVXW.js +3423 -0
- package/dist/vibiz.js +306 -67
- 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 })}`),
|
|
@@ -1085,12 +1096,33 @@ var Vibiz = class {
|
|
|
1085
1096
|
body: input
|
|
1086
1097
|
}),
|
|
1087
1098
|
authCode: (domain) => this.request(`/domains/${encodeURIComponent(domain)}/auth-code`, { method: "POST", body: {} }),
|
|
1099
|
+
/**
|
|
1100
|
+
* Use a bought domain (or a name under it) on any of the account's
|
|
1101
|
+
* projects: no DNS to set, trusted for sign-in at once. Any key. A name
|
|
1102
|
+
* another project uses answers 409 `in_use` with the move.
|
|
1103
|
+
*/
|
|
1104
|
+
use: (domain, projectId, input = {}) => this.request(`/domains/${encodeURIComponent(domain)}/use`, {
|
|
1105
|
+
method: "POST",
|
|
1106
|
+
body: { project_id: projectId, ...input }
|
|
1107
|
+
}),
|
|
1108
|
+
/** Full-access keys: move a name from the project using it to `toProjectId`. */
|
|
1109
|
+
move: (domain, toProjectId, input = {}) => this.request(`/domains/${encodeURIComponent(domain)}/move`, {
|
|
1110
|
+
method: "POST",
|
|
1111
|
+
body: { to_project_id: toProjectId, ...input }
|
|
1112
|
+
}),
|
|
1113
|
+
/** A bought name used by an app elsewhere: point it at that host (`null` clears it). */
|
|
1114
|
+
point: (domain, input) => this.request(`/domains/${encodeURIComponent(domain)}/point`, {
|
|
1115
|
+
method: "POST",
|
|
1116
|
+
body: input
|
|
1117
|
+
}),
|
|
1118
|
+
/** Buy for the account: on `project_id` once registered, or none to use later. */
|
|
1119
|
+
buy: (input) => this.request("/domains/buy", { method: "POST", body: input }),
|
|
1088
1120
|
owner: () => this.request("/domains/owner"),
|
|
1089
1121
|
setOwner: (contact) => this.request("/domains/owner", { method: "PUT", body: { contact } }),
|
|
1090
1122
|
/**
|
|
1091
1123
|
* Email forwarding (docs: email ▸ Forwarding): `hello@<domain>` → the
|
|
1092
1124
|
* owner's inbox, sent "via Vibiz". Anyone reads and verifies; `set` and
|
|
1093
|
-
* `off` need
|
|
1125
|
+
* `off` need a full-access key (an agent gets `owner_only` with a console link
|
|
1094
1126
|
* that has its proposal filled in).
|
|
1095
1127
|
*/
|
|
1096
1128
|
forwarding: {
|
|
@@ -1149,7 +1181,7 @@ var Vibiz = class {
|
|
|
1149
1181
|
method: "PATCH",
|
|
1150
1182
|
body: input
|
|
1151
1183
|
}),
|
|
1152
|
-
/**
|
|
1184
|
+
/** Full-access keys; only from trash or spam. */
|
|
1153
1185
|
delete: (id) => this.request(
|
|
1154
1186
|
`/inbox/threads/${encodeURIComponent(id)}`,
|
|
1155
1187
|
{ method: "DELETE" }
|
|
@@ -1180,7 +1212,7 @@ var Vibiz = class {
|
|
|
1180
1212
|
}),
|
|
1181
1213
|
settings: {
|
|
1182
1214
|
get: () => this.request("/inbox/settings"),
|
|
1183
|
-
/**
|
|
1215
|
+
/** Full-access keys: the new-mail digest. */
|
|
1184
1216
|
update: (input) => this.request("/inbox/settings", { method: "PATCH", body: input })
|
|
1185
1217
|
}
|
|
1186
1218
|
};
|
|
@@ -1190,12 +1222,12 @@ var Vibiz = class {
|
|
|
1190
1222
|
*/
|
|
1191
1223
|
billing = {
|
|
1192
1224
|
get: () => this.request("/billing"),
|
|
1193
|
-
/**
|
|
1225
|
+
/** Full-access keys: auto-recharge and the daily safety cap. */
|
|
1194
1226
|
update: (input) => this.request("/billing", { method: "PATCH", body: input }),
|
|
1195
1227
|
/** A payment page for `amount_cents` (500–100000); hand its `url` to a person. */
|
|
1196
1228
|
checkout: (input) => this.request("/billing/checkout", { method: "POST", body: input }),
|
|
1197
1229
|
checkoutStatus: (id) => this.request(`/billing/checkout/${encodeURIComponent(id)}`),
|
|
1198
|
-
/**
|
|
1230
|
+
/** Full-access keys: a page to save or replace the card. */
|
|
1199
1231
|
saveCard: () => this.request("/billing/card", { method: "POST", body: {} }),
|
|
1200
1232
|
removeCard: () => this.request("/billing/card", { method: "DELETE" }),
|
|
1201
1233
|
ledger: (opts = {}) => this.request(
|
|
@@ -1210,12 +1242,20 @@ var Vibiz = class {
|
|
|
1210
1242
|
/** Named keys, one per teammate or agent, so spend shows per person. */
|
|
1211
1243
|
apiKeys = {
|
|
1212
1244
|
list: () => this.request("/api-keys").then((r) => r.data),
|
|
1213
|
-
/**
|
|
1214
|
-
|
|
1245
|
+
/**
|
|
1246
|
+
* The secret is returned once, here. Full access (`owner`) by default;
|
|
1247
|
+
* `access: 'agent'` makes it Limited (builds and runs, never reads
|
|
1248
|
+
* production secrets nor moves live money). Needs a full-access key.
|
|
1249
|
+
*/
|
|
1215
1250
|
create: (name, opts = {}) => this.request("/api-keys", {
|
|
1216
1251
|
method: "POST",
|
|
1217
1252
|
body: { name, ...opts.access ? { access: opts.access } : {} }
|
|
1218
1253
|
}),
|
|
1254
|
+
/** Full access (`owner`) or Limited (`agent`), afterwards. Needs a full-access key, not this one. */
|
|
1255
|
+
setAccess: (id, access) => this.request(`/api-keys/${encodeURIComponent(id)}`, {
|
|
1256
|
+
method: "PATCH",
|
|
1257
|
+
body: { access }
|
|
1258
|
+
}),
|
|
1219
1259
|
revoke: (id) => this.request(`/api-keys/${id}`, { method: "DELETE" })
|
|
1220
1260
|
};
|
|
1221
1261
|
/** A short-lived link to the hosted usage dashboard (admin scope needs an admin key). */
|
|
@@ -1429,6 +1469,17 @@ function formatUnits(units) {
|
|
|
1429
1469
|
return parts.join(" \xB7 ") || "\u2013";
|
|
1430
1470
|
}
|
|
1431
1471
|
|
|
1472
|
+
// packages/sdk/src/one-key.ts
|
|
1473
|
+
var APP_SDK_VERSION = "0.2.2";
|
|
1474
|
+
var ONE_KEY_GIVES = "database, sign-in, email and inbox, AI models, files, payments, analytics with session replays, web data, social and connectors";
|
|
1475
|
+
function oneKeyMessage(url, host) {
|
|
1476
|
+
const where = host ?? "your host";
|
|
1477
|
+
return `Add one key to ${where} and your app can use everything on Vibiz (${ONE_KEY_GIVES}): copy VIBIZ_APP_KEY here: ${url} , paste it into ${host ? `${host}'s` : "your host's"} production environment variables, and redeploy.`;
|
|
1478
|
+
}
|
|
1479
|
+
function connectHostMessage(kind, host) {
|
|
1480
|
+
return `Or connect ${host ?? "the host"} once (vibiz hosts add ${kind ?? "<host>"} <app>) and Vibiz keeps every variable in sync.`;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1432
1483
|
export {
|
|
1433
1484
|
VibizApiError,
|
|
1434
1485
|
Vibiz,
|
|
@@ -1436,5 +1487,9 @@ export {
|
|
|
1436
1487
|
mergeEnvFile,
|
|
1437
1488
|
writeEnvFile,
|
|
1438
1489
|
formatUsd,
|
|
1439
|
-
formatUnits
|
|
1490
|
+
formatUnits,
|
|
1491
|
+
APP_SDK_VERSION,
|
|
1492
|
+
ONE_KEY_GIVES,
|
|
1493
|
+
oneKeyMessage,
|
|
1494
|
+
connectHostMessage
|
|
1440
1495
|
};
|