@vibiz/sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -2
- package/dist/client.d.ts +751 -0
- package/dist/deploy.d.ts +25 -0
- package/dist/env.d.ts +14 -0
- package/dist/format.d.ts +11 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1015 -0
- package/dist/types.d.ts +1834 -0
- package/package.json +36 -4
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
import type { ActionUsage, AdminMetrics, AiJob, AiModelInfo, AiProviderKey, AiProviderKeyInput, AiProviderKeyList, AiSettings, AnalyticsPeriod, AnalyticsReport, ApiKey, AppKeyInfo, AuthEnvironment, AuthProviderId, AuthProviderInput, AuthSettings, AuthSettingsPatch, Billing, BillingCharge, BillingCheckout, BillingEntry, BillingEntryKind, BillingList, BillingUpdate, ChatChunk, ChatCompletion, ChatRequest, Checkout, CheckoutInput, Company, CompanyAddressFields, CompanyCatalog, CompanyDraft, CompanyEnvironment, CompanyLink, Connector, ConnectorApproval, ConnectorCall, ConnectorCallInput, ConnectorCheck, ConnectorEnvironment, ConnectorImport, ConnectorInput, ConnectorPatch, ConnectorResponse, DashboardLink, DeployFile, Deployment, DevEnvironment, EnvTargetInfo, HostKind, ImageRequest, ImageResult, KeyAccess, LedgerEntry, MetricsReport, Operation, Payment, PaymentPrice, PaymentPriceInput, PaymentProduct, PaymentSubscription, PaymentsAccount, PaymentsEnvironment, PaymentsList, PaymentsSimulation, Project, ReplayDetail, ReplayInsights, ReplayListOptions, ReplayPeriod, ReplayStatus, ReplaySummary, Resource, ResourceType, SendEmailInput, SendEmailOutput, SocialAccount, SocialAccountAnalytics, SocialAdCampaign, SocialAdChange, SocialAdChangeInput, SocialConnectLink, SocialEnvironment, SocialMedia, SocialOverview, SocialPost, SocialPostAnalytics, SocialPostInput, SpeechRequest, Transcription, UsageOptions, UsagePeriod, UsageReport, WebhookDelivery, WebhookEventType, Withdrawal } from './types.js';
|
|
2
|
+
export declare class VibizApiError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly details?: unknown | undefined;
|
|
6
|
+
constructor(status: number, code: string, message: string, details?: unknown | undefined);
|
|
7
|
+
}
|
|
8
|
+
export interface VibizOptions {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
/** Required: the Vibiz API base URL. */
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
/**
|
|
14
|
+
* Your own end user, sent as `X-Vibiz-User` on every call so spend shows per
|
|
15
|
+
* end user (and per-end-user AI budgets apply). A stable pseudonymous id,
|
|
16
|
+
* not an email.
|
|
17
|
+
*/
|
|
18
|
+
user?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The typed client for the Vibiz Stack API. Used by the CLI, by Principia's
|
|
22
|
+
* gateway tools and by anyone building on the API.
|
|
23
|
+
*/
|
|
24
|
+
export declare class Vibiz {
|
|
25
|
+
private readonly options;
|
|
26
|
+
private readonly baseUrl;
|
|
27
|
+
private readonly fetchImpl;
|
|
28
|
+
constructor(options: VibizOptions);
|
|
29
|
+
private send;
|
|
30
|
+
private fail;
|
|
31
|
+
/** A raw response (audio, a stream), failing like `request` on an error status. */
|
|
32
|
+
private stream;
|
|
33
|
+
private request;
|
|
34
|
+
private postAction;
|
|
35
|
+
readonly projects: {
|
|
36
|
+
create: (input: {
|
|
37
|
+
name: string;
|
|
38
|
+
slug?: string;
|
|
39
|
+
resources?: ResourceType[];
|
|
40
|
+
}, opts?: {
|
|
41
|
+
idempotencyKey?: string;
|
|
42
|
+
}) => Promise<{
|
|
43
|
+
project: Project;
|
|
44
|
+
operations: Operation[];
|
|
45
|
+
}>;
|
|
46
|
+
list: () => Promise<Project[]>;
|
|
47
|
+
get: (id: string) => Promise<Project>;
|
|
48
|
+
delete: (id: string) => Promise<{
|
|
49
|
+
project: Project;
|
|
50
|
+
operations: Operation[];
|
|
51
|
+
}>;
|
|
52
|
+
/** Undo a delete within 7 days: data was kept, the site is provisioned again. */
|
|
53
|
+
restore: (id: string) => Promise<{
|
|
54
|
+
project: Project;
|
|
55
|
+
operations: Operation[];
|
|
56
|
+
}>;
|
|
57
|
+
addResource: (id: string, type: ResourceType) => Promise<{
|
|
58
|
+
resource: Resource;
|
|
59
|
+
operations: Operation[];
|
|
60
|
+
}>;
|
|
61
|
+
/** Change a resource's settings (merged), e.g. `('replay', { sample_rate: 0.1 })`. */
|
|
62
|
+
configureResource: (id: string, type: ResourceType, config: Record<string, unknown>) => Promise<Resource>;
|
|
63
|
+
/** Run a project-scoped action, such as `email.send`. */
|
|
64
|
+
runAction: <O = unknown>(id: string, name: string, input: unknown, opts?: {
|
|
65
|
+
idempotencyKey?: string;
|
|
66
|
+
}) => Promise<{
|
|
67
|
+
output: O;
|
|
68
|
+
cost_micro_usd: number | null;
|
|
69
|
+
usage: ActionUsage | null;
|
|
70
|
+
}>;
|
|
71
|
+
/** The production env. Owner keys only: an agent key gets `forbidden` (use `dev`). */
|
|
72
|
+
env: (id: string) => Promise<Record<string, string>>;
|
|
73
|
+
/** The production env's variable names, without values. Any key. */
|
|
74
|
+
envNames: (id: string) => Promise<string[]>;
|
|
75
|
+
/**
|
|
76
|
+
* The development environment: its own database branch (schema, no
|
|
77
|
+
* production rows), its own sign-in and AI key. What agents and laptops use.
|
|
78
|
+
*/
|
|
79
|
+
dev: {
|
|
80
|
+
get: (id: string) => Promise<DevEnvironment>;
|
|
81
|
+
start: (id: string) => Promise<DevEnvironment>;
|
|
82
|
+
env: (id: string) => Promise<Record<string, string>>;
|
|
83
|
+
remove: (id: string) => Promise<{
|
|
84
|
+
status: string;
|
|
85
|
+
}>;
|
|
86
|
+
/** Start it if needed and wait until ready, then return its env. */
|
|
87
|
+
ensure: (id: string, opts?: {
|
|
88
|
+
timeoutMs?: number;
|
|
89
|
+
intervalMs?: number;
|
|
90
|
+
}) => Promise<Record<string, string>>;
|
|
91
|
+
};
|
|
92
|
+
/** The app key (`vz_app_…`), per environment. The secret itself only ever travels in the env. */
|
|
93
|
+
appKeys: {
|
|
94
|
+
list: (id: string) => Promise<AppKeyInfo[]>;
|
|
95
|
+
/** Production's needs an owner key. The old key works for `grace_seconds` (default 3600). */
|
|
96
|
+
rotate: (id: string, opts?: {
|
|
97
|
+
environment?: "production" | "development";
|
|
98
|
+
grace_seconds?: number;
|
|
99
|
+
}) => Promise<AppKeyInfo>;
|
|
100
|
+
};
|
|
101
|
+
/** Hosts outside Vibiz that receive the env server to server. Connecting needs an owner key. */
|
|
102
|
+
hosts: {
|
|
103
|
+
list: (id: string) => Promise<EnvTargetInfo[]>;
|
|
104
|
+
add: (id: string, input: {
|
|
105
|
+
/** `vercel`, `netlify`, `render`, `railway`, `fly`, `heroku`, `cloudflare-workers`, `cloudflare-pages`, `github-actions`. */
|
|
106
|
+
kind: string;
|
|
107
|
+
token: string;
|
|
108
|
+
/** The host's fields (see `hostKinds()`): `{ project }`, `{ site }`, `{ service }`, `{ app }`, `{ repo }`… */
|
|
109
|
+
config?: Record<string, string>;
|
|
110
|
+
project?: string;
|
|
111
|
+
team_id?: string;
|
|
112
|
+
environments?: Array<"production" | "development">;
|
|
113
|
+
}) => Promise<EnvTargetInfo>;
|
|
114
|
+
sync: (id: string) => Promise<EnvTargetInfo[]>;
|
|
115
|
+
remove: (id: string, targetId: string, opts?: {
|
|
116
|
+
keepValues?: boolean;
|
|
117
|
+
}) => Promise<EnvTargetInfo>;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The app's own database. `production` needs an owner key (it holds the
|
|
121
|
+
* app's users' data); agents read `development`, the default for them.
|
|
122
|
+
*/
|
|
123
|
+
database: {
|
|
124
|
+
tables: (id: string, env?: "production" | "development") => Promise<{
|
|
125
|
+
environment: string;
|
|
126
|
+
tables: Array<Record<string, unknown>>;
|
|
127
|
+
}>;
|
|
128
|
+
/** Read-only: one SELECT / WITH / EXPLAIN / SHOW statement, 5 s, 500 rows. */
|
|
129
|
+
query: (id: string, sql: string, env?: "production" | "development") => Promise<{
|
|
130
|
+
columns: string[];
|
|
131
|
+
rows: Record<string, unknown>[];
|
|
132
|
+
row_count: number;
|
|
133
|
+
truncated: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* How people sign in to the app (docs/SIGN-IN.md). `production` needs an
|
|
138
|
+
* owner key; agents work on `development`, the default for them.
|
|
139
|
+
*/
|
|
140
|
+
auth: {
|
|
141
|
+
get: (id: string, env?: AuthEnvironment) => Promise<AuthSettings>;
|
|
142
|
+
update: (id: string, patch: AuthSettingsPatch, env?: AuthEnvironment) => Promise<AuthSettings>;
|
|
143
|
+
/** Turn a social provider on, with shared keys or the customer's own OAuth app. */
|
|
144
|
+
setProvider: (id: string, provider: AuthProviderId, input: AuthProviderInput, env?: AuthEnvironment) => Promise<AuthSettings>;
|
|
145
|
+
removeProvider: (id: string, provider: AuthProviderId, env?: AuthEnvironment) => Promise<AuthSettings>;
|
|
146
|
+
/** Owner only: a test message through the SMTP sender already set. */
|
|
147
|
+
testEmail: (id: string, to: string, env?: AuthEnvironment) => Promise<{
|
|
148
|
+
success: boolean;
|
|
149
|
+
error_message?: string;
|
|
150
|
+
}>;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* The business behind the project (docs/COMPANY.md). `env` defaults like
|
|
154
|
+
* the API: production for owners, development for agents. Production
|
|
155
|
+
* submit, signing, actions and documents need an owner key.
|
|
156
|
+
*/
|
|
157
|
+
company: {
|
|
158
|
+
get: (id: string, env?: CompanyEnvironment) => Promise<Company>;
|
|
159
|
+
/** Create or replace the draft. */
|
|
160
|
+
draft: (id: string, draft: CompanyDraft, env?: CompanyEnvironment) => Promise<Company>;
|
|
161
|
+
/** Change part of the draft: top-level keys replace, `null` clears one. */
|
|
162
|
+
update: (id: string, patch: Partial<CompanyDraft>, env?: CompanyEnvironment) => Promise<Company>;
|
|
163
|
+
remove: (id: string, env?: CompanyEnvironment) => Promise<{
|
|
164
|
+
object: "company";
|
|
165
|
+
id: string;
|
|
166
|
+
deleted: true;
|
|
167
|
+
}>;
|
|
168
|
+
/**
|
|
169
|
+
* Production files for real and charges the price: an owner key, `confirm: true`,
|
|
170
|
+
* and the `quote.total_cents` and `updated_at` of the draft that was reviewed
|
|
171
|
+
* (a draft or price changed since is refused with a 409, not filed).
|
|
172
|
+
*/
|
|
173
|
+
submit: (id: string, input: {
|
|
174
|
+
accept_terms: true;
|
|
175
|
+
confirm?: boolean;
|
|
176
|
+
expected_total_cents?: number;
|
|
177
|
+
expected_updated_at?: string;
|
|
178
|
+
}, env?: CompanyEnvironment) => Promise<Company>;
|
|
179
|
+
/**
|
|
180
|
+
* Pay a live filing by card instead of from the balance (owner keys): the same
|
|
181
|
+
* body as `submit`; it is filed when the payment arrives (docs/BILLING.md "Company").
|
|
182
|
+
*/
|
|
183
|
+
checkout: (id: string, input: {
|
|
184
|
+
accept_terms: true;
|
|
185
|
+
confirm: true;
|
|
186
|
+
expected_total_cents: number;
|
|
187
|
+
expected_updated_at: string;
|
|
188
|
+
}) => Promise<BillingCheckout>;
|
|
189
|
+
/** A fresh signing link; show it to the signer right away, it voids the previous one. */
|
|
190
|
+
sign: (id: string, document: "ss4" | "form_8821", env?: CompanyEnvironment) => Promise<CompanyLink & {
|
|
191
|
+
object: "company_signature";
|
|
192
|
+
document: string;
|
|
193
|
+
}>;
|
|
194
|
+
/** Answer a required action: new names, or the founder's own US address. */
|
|
195
|
+
resolve: (id: string, actionId: string, input: {
|
|
196
|
+
names: Array<{
|
|
197
|
+
name: string;
|
|
198
|
+
ending?: string;
|
|
199
|
+
}>;
|
|
200
|
+
} | {
|
|
201
|
+
address: CompanyAddressFields;
|
|
202
|
+
}, env?: CompanyEnvironment) => Promise<Company>;
|
|
203
|
+
/** A short-lived download link. */
|
|
204
|
+
document: (id: string, documentId: string, env?: CompanyEnvironment) => Promise<CompanyLink & {
|
|
205
|
+
object: "company_document_link";
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
}>;
|
|
209
|
+
refresh: (id: string, env?: CompanyEnvironment) => Promise<Company>;
|
|
210
|
+
/** Development only: complete formation or the EIN at the sandbox. */
|
|
211
|
+
simulate: (id: string, step: "formation" | "ein") => Promise<Company>;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Social (docs/SOCIAL.md): the project's own social and ad accounts. `env`
|
|
215
|
+
* defaults like the API: production for owners, development (a sandbox:
|
|
216
|
+
* nothing is posted or spent) for agents. On production an agent's posts
|
|
217
|
+
* and ad changes wait for the owner (`pending_approval`); an owner sends
|
|
218
|
+
* `confirm: true`.
|
|
219
|
+
*/
|
|
220
|
+
social: {
|
|
221
|
+
get: (id: string, env?: SocialEnvironment) => Promise<SocialOverview>;
|
|
222
|
+
accounts: (id: string, opts?: {
|
|
223
|
+
env?: SocialEnvironment;
|
|
224
|
+
kind?: "social" | "ads";
|
|
225
|
+
platform?: string;
|
|
226
|
+
}) => Promise<{
|
|
227
|
+
object: "list";
|
|
228
|
+
data: SocialAccount[];
|
|
229
|
+
has_more: boolean;
|
|
230
|
+
}>;
|
|
231
|
+
/** A link (1 h) for the owner to open and sign in to the platform. */
|
|
232
|
+
connect: (id: string, platform: string, opts?: {
|
|
233
|
+
ads?: boolean;
|
|
234
|
+
env?: SocialEnvironment;
|
|
235
|
+
}) => Promise<SocialConnectLink>;
|
|
236
|
+
refreshAccounts: (id: string, env?: SocialEnvironment) => Promise<{
|
|
237
|
+
object: "list";
|
|
238
|
+
data: SocialAccount[];
|
|
239
|
+
}>;
|
|
240
|
+
disconnect: (id: string, accountId: string, env?: SocialEnvironment) => Promise<SocialAccount>;
|
|
241
|
+
accountAnalytics: (id: string, accountId: string, opts?: {
|
|
242
|
+
env?: SocialEnvironment;
|
|
243
|
+
from?: string;
|
|
244
|
+
to?: string;
|
|
245
|
+
}) => Promise<SocialAccountAnalytics>;
|
|
246
|
+
/** Upload a file (bytes and their content type) → a URL to post with. */
|
|
247
|
+
upload: (id: string, file: {
|
|
248
|
+
bytes: Uint8Array;
|
|
249
|
+
contentType: string;
|
|
250
|
+
filename?: string;
|
|
251
|
+
}, env?: SocialEnvironment) => Promise<SocialMedia>;
|
|
252
|
+
posts: (id: string, opts?: {
|
|
253
|
+
env?: SocialEnvironment;
|
|
254
|
+
status?: string;
|
|
255
|
+
account?: string;
|
|
256
|
+
platform?: string;
|
|
257
|
+
from?: string;
|
|
258
|
+
to?: string;
|
|
259
|
+
cursor?: string;
|
|
260
|
+
limit?: number;
|
|
261
|
+
}) => Promise<{
|
|
262
|
+
object: "list";
|
|
263
|
+
data: SocialPost[];
|
|
264
|
+
has_more: boolean;
|
|
265
|
+
next_cursor: string | null;
|
|
266
|
+
}>;
|
|
267
|
+
post: (id: string, postId: string, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
268
|
+
create: (id: string, input: SocialPostInput, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
269
|
+
publish: (id: string, postId: string, input?: {
|
|
270
|
+
schedule_at?: string | null;
|
|
271
|
+
timezone?: string | null;
|
|
272
|
+
confirm?: boolean;
|
|
273
|
+
}, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
274
|
+
approve: (id: string, postId: string, input?: {
|
|
275
|
+
schedule_at?: string | null;
|
|
276
|
+
}, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
277
|
+
reject: (id: string, postId: string, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
278
|
+
retry: (id: string, postId: string, input?: {
|
|
279
|
+
confirm?: boolean;
|
|
280
|
+
}, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
281
|
+
refresh: (id: string, postId: string, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
282
|
+
/** Cancel a draft, a waiting or a scheduled post. */
|
|
283
|
+
cancel: (id: string, postId: string, env?: SocialEnvironment) => Promise<SocialPost>;
|
|
284
|
+
postAnalytics: (id: string, postId: string, env?: SocialEnvironment) => Promise<SocialPostAnalytics>;
|
|
285
|
+
campaigns: (id: string, opts?: {
|
|
286
|
+
env?: SocialEnvironment;
|
|
287
|
+
account?: string;
|
|
288
|
+
ad_account?: string;
|
|
289
|
+
from?: string;
|
|
290
|
+
to?: string;
|
|
291
|
+
}) => Promise<{
|
|
292
|
+
object: "list";
|
|
293
|
+
data: SocialAdCampaign[];
|
|
294
|
+
}>;
|
|
295
|
+
adChanges: (id: string, opts?: {
|
|
296
|
+
env?: SocialEnvironment;
|
|
297
|
+
status?: string;
|
|
298
|
+
}) => Promise<{
|
|
299
|
+
object: "list";
|
|
300
|
+
data: SocialAdChange[];
|
|
301
|
+
}>;
|
|
302
|
+
adChange: (id: string, input: SocialAdChangeInput, env?: SocialEnvironment) => Promise<SocialAdChange>;
|
|
303
|
+
approveAdChange: (id: string, changeId: string, env?: SocialEnvironment) => Promise<SocialAdChange>;
|
|
304
|
+
rejectAdChange: (id: string, changeId: string, env?: SocialEnvironment) => Promise<SocialAdChange>;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Payments (docs/PAYMENTS.md): Vibiz is the merchant, so an app sells from
|
|
308
|
+
* its first call. `env` defaults like the API: production for owners,
|
|
309
|
+
* development for agents. On production, refunds, cancels, withdrawing,
|
|
310
|
+
* payout setup and webhook settings need an owner key.
|
|
311
|
+
*/
|
|
312
|
+
payments: {
|
|
313
|
+
get: (id: string, env?: PaymentsEnvironment) => Promise<PaymentsAccount>;
|
|
314
|
+
update: (id: string, patch: {
|
|
315
|
+
statement_descriptor_suffix?: string | null;
|
|
316
|
+
webhook_url?: string | null;
|
|
317
|
+
webhook_events?: WebhookEventType[];
|
|
318
|
+
}, env?: PaymentsEnvironment) => Promise<PaymentsAccount>;
|
|
319
|
+
/** A new signing secret, shown once (also put in the app's env as VIBIZ_WEBHOOK_SECRET). */
|
|
320
|
+
rotateWebhookSecret: (id: string, env?: PaymentsEnvironment) => Promise<{
|
|
321
|
+
object: "webhook_secret";
|
|
322
|
+
secret: string;
|
|
323
|
+
}>;
|
|
324
|
+
deliveries: (id: string, env?: PaymentsEnvironment) => Promise<PaymentsList<WebhookDelivery>>;
|
|
325
|
+
products: {
|
|
326
|
+
list: (id: string, env?: PaymentsEnvironment) => Promise<PaymentsList<PaymentProduct>>;
|
|
327
|
+
create: (id: string, input: {
|
|
328
|
+
name: string;
|
|
329
|
+
description?: string;
|
|
330
|
+
price?: PaymentPriceInput;
|
|
331
|
+
}, env?: PaymentsEnvironment) => Promise<PaymentProduct>;
|
|
332
|
+
get: (id: string, productId: string, env?: PaymentsEnvironment) => Promise<PaymentProduct>;
|
|
333
|
+
update: (id: string, productId: string, patch: {
|
|
334
|
+
name?: string;
|
|
335
|
+
description?: string | null;
|
|
336
|
+
active?: boolean;
|
|
337
|
+
}, env?: PaymentsEnvironment) => Promise<PaymentProduct>;
|
|
338
|
+
/** Archive: kept on record, no longer sold. */
|
|
339
|
+
remove: (id: string, productId: string, env?: PaymentsEnvironment) => Promise<PaymentProduct>;
|
|
340
|
+
addPrice: (id: string, productId: string, price: PaymentPriceInput, env?: PaymentsEnvironment) => Promise<PaymentPrice>;
|
|
341
|
+
updatePrice: (id: string, priceId: string, patch: {
|
|
342
|
+
active?: boolean;
|
|
343
|
+
lookup_key?: string | null;
|
|
344
|
+
}, env?: PaymentsEnvironment) => Promise<PaymentPrice>;
|
|
345
|
+
};
|
|
346
|
+
checkout: (id: string, input: CheckoutInput, env?: PaymentsEnvironment) => Promise<Checkout>;
|
|
347
|
+
list: (id: string, opts?: {
|
|
348
|
+
env?: PaymentsEnvironment;
|
|
349
|
+
cursor?: string;
|
|
350
|
+
limit?: number;
|
|
351
|
+
user?: string;
|
|
352
|
+
}) => Promise<PaymentsList<Payment>>;
|
|
353
|
+
payment: (id: string, paymentId: string, env?: PaymentsEnvironment) => Promise<Payment>;
|
|
354
|
+
/** The balance (available + pending) must cover it: `409 insufficient_balance` otherwise. */
|
|
355
|
+
refund: (id: string, paymentId: string, input?: {
|
|
356
|
+
amount_cents?: number;
|
|
357
|
+
reason?: "requested_by_customer" | "duplicate" | "fraudulent";
|
|
358
|
+
}, env?: PaymentsEnvironment) => Promise<Payment>;
|
|
359
|
+
subscriptions: (id: string, opts?: {
|
|
360
|
+
env?: PaymentsEnvironment;
|
|
361
|
+
user?: string;
|
|
362
|
+
status?: string;
|
|
363
|
+
}) => Promise<PaymentsList<PaymentSubscription>>;
|
|
364
|
+
cancel: (id: string, subscriptionId: string, opts?: {
|
|
365
|
+
at_period_end?: boolean;
|
|
366
|
+
}, env?: PaymentsEnvironment) => Promise<PaymentSubscription>;
|
|
367
|
+
ledger: (id: string, opts?: {
|
|
368
|
+
env?: PaymentsEnvironment;
|
|
369
|
+
cursor?: string;
|
|
370
|
+
limit?: number;
|
|
371
|
+
}) => Promise<PaymentsList<LedgerEntry>>;
|
|
372
|
+
/** For the embedded verification, bank and payout UI (Connect.js). Short-lived. */
|
|
373
|
+
payoutsSession: (id: string, input?: {
|
|
374
|
+
country?: string;
|
|
375
|
+
}, env?: PaymentsEnvironment) => Promise<{
|
|
376
|
+
object: "payouts_session";
|
|
377
|
+
client_secret: string;
|
|
378
|
+
publishable_key: string | null;
|
|
379
|
+
expires_at: string;
|
|
380
|
+
}>;
|
|
381
|
+
/** Default: everything available. */
|
|
382
|
+
withdraw: (id: string, input?: {
|
|
383
|
+
amount_cents?: number;
|
|
384
|
+
}, env?: PaymentsEnvironment) => Promise<Withdrawal>;
|
|
385
|
+
withdrawals: (id: string, env?: PaymentsEnvironment) => Promise<PaymentsList<Withdrawal>>;
|
|
386
|
+
refresh: (id: string, env?: PaymentsEnvironment) => Promise<PaymentsAccount>;
|
|
387
|
+
/** Development only: a real test-mode payment, dispute or refund, or release the hold. */
|
|
388
|
+
simulate: (id: string, input: PaymentsSimulation) => Promise<PaymentsAccount | Payment>;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Custom connectors (docs/CONNECTORS.md): any HTTP API from one manifest,
|
|
392
|
+
* called through Vibiz, which holds the key. `env` defaults like the API:
|
|
393
|
+
* production for owners, development for agents. Production keys, and
|
|
394
|
+
* approving an agent's dangerous call, need an owner key.
|
|
395
|
+
*/
|
|
396
|
+
connectors: {
|
|
397
|
+
list: (id: string) => Promise<Connector[]>;
|
|
398
|
+
get: (id: string, name: string) => Promise<Connector>;
|
|
399
|
+
/** From a manifest, a short form (`operations: ["GET /posts/{id}"]`) or an import's draft. */
|
|
400
|
+
create: (id: string, manifest: ConnectorInput | ConnectorImport["manifest"]) => Promise<Connector>;
|
|
401
|
+
/** Preview an OpenAPI 3 spec (url or the document): nothing is saved. */
|
|
402
|
+
import: (id: string, input: {
|
|
403
|
+
url?: string;
|
|
404
|
+
spec?: unknown;
|
|
405
|
+
name?: string;
|
|
406
|
+
base_url?: string;
|
|
407
|
+
enable?: string[];
|
|
408
|
+
}) => Promise<ConnectorImport>;
|
|
409
|
+
update: (id: string, name: string, patch: ConnectorPatch) => Promise<Connector>;
|
|
410
|
+
delete: (id: string, name: string) => Promise<Connector>;
|
|
411
|
+
/** Set values (`null` removes). Production: owner keys. Values are never read back. */
|
|
412
|
+
setSecrets: (id: string, name: string, values: Record<string, string | null>, env?: ConnectorEnvironment) => Promise<Connector>;
|
|
413
|
+
check: (id: string, name: string, env?: ConnectorEnvironment) => Promise<ConnectorCheck>;
|
|
414
|
+
/** One operation. A dangerous one (or a production write) by an agent key answers 403 approval_required. */
|
|
415
|
+
call: <T = unknown>(id: string, name: string, input: ConnectorCallInput, opts?: {
|
|
416
|
+
env?: ConnectorEnvironment;
|
|
417
|
+
idempotencyKey?: string;
|
|
418
|
+
}) => Promise<ConnectorResponse<T>>;
|
|
419
|
+
calls: (id: string, name: string, opts?: {
|
|
420
|
+
env?: ConnectorEnvironment;
|
|
421
|
+
limit?: number;
|
|
422
|
+
cursor?: string;
|
|
423
|
+
}) => Promise<PaymentsList<ConnectorCall>>;
|
|
424
|
+
approvals: (id: string, opts?: {
|
|
425
|
+
status?: ConnectorApproval["status"];
|
|
426
|
+
}) => Promise<ConnectorApproval[]>;
|
|
427
|
+
approval: (id: string, approvalId: string) => Promise<ConnectorApproval>;
|
|
428
|
+
/** Owner keys. */
|
|
429
|
+
approve: (id: string, approvalId: string) => Promise<ConnectorApproval>;
|
|
430
|
+
/** Owner keys. */
|
|
431
|
+
deny: (id: string, approvalId: string) => Promise<ConnectorApproval>;
|
|
432
|
+
};
|
|
433
|
+
/** Where the app also runs outside Vibiz hosting. Adding and removing need an owner key. */
|
|
434
|
+
domains: {
|
|
435
|
+
list: (id: string) => Promise<string[]>;
|
|
436
|
+
add: (id: string, domain: string) => Promise<string[]>;
|
|
437
|
+
remove: (id: string, domain: string) => Promise<string[]>;
|
|
438
|
+
};
|
|
439
|
+
/** Poll until every resource is ready, or throw on the first failure. */
|
|
440
|
+
waitUntilReady: (id: string, opts?: {
|
|
441
|
+
timeoutMs?: number;
|
|
442
|
+
intervalMs?: number;
|
|
443
|
+
}) => Promise<Project>;
|
|
444
|
+
};
|
|
445
|
+
readonly files: {
|
|
446
|
+
missing: (shas: string[]) => Promise<string[]>;
|
|
447
|
+
upload: (sha: string, bytes: Uint8Array) => Promise<void>;
|
|
448
|
+
};
|
|
449
|
+
readonly deployments: {
|
|
450
|
+
create: (projectId: string, input: {
|
|
451
|
+
files: DeployFile[];
|
|
452
|
+
target?: "preview" | "production";
|
|
453
|
+
}, opts?: {
|
|
454
|
+
idempotencyKey?: string;
|
|
455
|
+
}) => Promise<{
|
|
456
|
+
deployment: Deployment;
|
|
457
|
+
operation: Operation;
|
|
458
|
+
}>;
|
|
459
|
+
list: (projectId: string) => Promise<Deployment[]>;
|
|
460
|
+
get: (id: string) => Promise<Deployment>;
|
|
461
|
+
promote: (id: string) => Promise<{
|
|
462
|
+
deployment: Deployment;
|
|
463
|
+
operation: Operation | null;
|
|
464
|
+
instant: boolean;
|
|
465
|
+
}>;
|
|
466
|
+
waitUntilDone: (id: string, opts?: {
|
|
467
|
+
timeoutMs?: number;
|
|
468
|
+
intervalMs?: number;
|
|
469
|
+
}) => Promise<Deployment>;
|
|
470
|
+
};
|
|
471
|
+
readonly analytics: {
|
|
472
|
+
/** Visitors, pageviews, top pages, sources, countries, events and a timeseries. */
|
|
473
|
+
get: (projectId: string, opts?: {
|
|
474
|
+
period?: AnalyticsPeriod;
|
|
475
|
+
}) => Promise<AnalyticsReport>;
|
|
476
|
+
};
|
|
477
|
+
/** Session replay. Start from `insights`; open single sessions with `get`. */
|
|
478
|
+
readonly replays: {
|
|
479
|
+
/** Rule-based findings over recorded sessions: what broke and where people got stuck. */
|
|
480
|
+
insights: (projectId: string, opts?: {
|
|
481
|
+
period?: ReplayPeriod;
|
|
482
|
+
}) => Promise<ReplayInsights>;
|
|
483
|
+
/** Recorded sessions, most worth watching first. */
|
|
484
|
+
list: (projectId: string, opts?: ReplayListOptions) => Promise<{
|
|
485
|
+
data: ReplaySummary[];
|
|
486
|
+
has_more: boolean;
|
|
487
|
+
next_offset: number | null;
|
|
488
|
+
replay_status: ReplayStatus;
|
|
489
|
+
/** The same list in the web console. */
|
|
490
|
+
console_url?: string;
|
|
491
|
+
}>;
|
|
492
|
+
/** Metadata, signals, completeness and the timeline of notable moments. */
|
|
493
|
+
get: (id: string) => Promise<ReplayDetail>;
|
|
494
|
+
/** The raw rrweb events (masked at the source). Pages with `from_seq` / `max_chunks`. */
|
|
495
|
+
events: (id: string, opts?: {
|
|
496
|
+
from_seq?: number;
|
|
497
|
+
max_chunks?: number;
|
|
498
|
+
time?: "browser" | "server";
|
|
499
|
+
}) => Promise<{
|
|
500
|
+
replay_id: string;
|
|
501
|
+
events: unknown[];
|
|
502
|
+
next_seq: number | null;
|
|
503
|
+
}>;
|
|
504
|
+
/** A link to the hosted player for a person, valid for `expires_in` seconds (default 1 h, max 24 h). */
|
|
505
|
+
share: (id: string, opts?: {
|
|
506
|
+
expires_in?: number;
|
|
507
|
+
}) => Promise<{
|
|
508
|
+
replay_id: string;
|
|
509
|
+
url: string;
|
|
510
|
+
expires_at: string;
|
|
511
|
+
}>;
|
|
512
|
+
delete: (id: string) => Promise<void>;
|
|
513
|
+
};
|
|
514
|
+
readonly operations: {
|
|
515
|
+
get: (id: string) => Promise<Operation>;
|
|
516
|
+
};
|
|
517
|
+
readonly actions: {
|
|
518
|
+
run: <O = unknown>(name: string, input: unknown) => Promise<{
|
|
519
|
+
output: O;
|
|
520
|
+
cost_micro_usd: number | null;
|
|
521
|
+
}>;
|
|
522
|
+
};
|
|
523
|
+
readonly email: {
|
|
524
|
+
/** Send from the project's address (`info@<slug>.vibiz.app` by default). */
|
|
525
|
+
send: (projectId: string, input: SendEmailInput, opts?: {
|
|
526
|
+
idempotencyKey?: string;
|
|
527
|
+
}) => Promise<{
|
|
528
|
+
output: SendEmailOutput;
|
|
529
|
+
cost_micro_usd: number | null;
|
|
530
|
+
usage: ActionUsage | null;
|
|
531
|
+
}>;
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* The AI gateway: chat, images, speech and transcription, metered against
|
|
535
|
+
* the account's (or the project's) spend. Works with the account key or a
|
|
536
|
+
* project AI key (`VIBIZ_AI_API_KEY`). OpenAI's SDK works too: point it at
|
|
537
|
+
* `<api>/v1/ai`.
|
|
538
|
+
*/
|
|
539
|
+
readonly ai: {
|
|
540
|
+
/** One completion. `model` defaults to `vibiz/fast`. */
|
|
541
|
+
chat: (input: ChatRequest, opts?: {
|
|
542
|
+
idempotencyKey?: string;
|
|
543
|
+
}) => Promise<ChatCompletion>;
|
|
544
|
+
/** A streamed completion, chunk by chunk. Breaking out of the loop stops the model. */
|
|
545
|
+
chatStream: (input: ChatRequest) => AsyncIterable<ChatChunk>;
|
|
546
|
+
embed: (input: {
|
|
547
|
+
input: string | string[];
|
|
548
|
+
model?: string;
|
|
549
|
+
dimensions?: number;
|
|
550
|
+
}) => Promise<{
|
|
551
|
+
data: Array<{
|
|
552
|
+
index: number;
|
|
553
|
+
embedding: number[];
|
|
554
|
+
}>;
|
|
555
|
+
cost_micro_usd: number;
|
|
556
|
+
}>;
|
|
557
|
+
image: (input: ImageRequest, opts?: {
|
|
558
|
+
idempotencyKey?: string;
|
|
559
|
+
}) => Promise<ImageResult>;
|
|
560
|
+
/** Text to speech: the audio bytes (mp3 by default). */
|
|
561
|
+
speech: (input: SpeechRequest) => Promise<Uint8Array>;
|
|
562
|
+
/** Speech to text. */
|
|
563
|
+
transcribe: (input: {
|
|
564
|
+
file: Blob | Uint8Array;
|
|
565
|
+
filename?: string;
|
|
566
|
+
model?: string;
|
|
567
|
+
language?: string;
|
|
568
|
+
}) => Promise<Transcription>;
|
|
569
|
+
/**
|
|
570
|
+
* The Vibiz models and the lab models, with prices. `all` adds every
|
|
571
|
+
* language model you can call by id; `q` searches id, name and maker.
|
|
572
|
+
*/
|
|
573
|
+
models: (opts?: {
|
|
574
|
+
all?: boolean;
|
|
575
|
+
q?: string;
|
|
576
|
+
}) => Promise<AiModelInfo[]>;
|
|
577
|
+
jobs: {
|
|
578
|
+
create: (input: {
|
|
579
|
+
type: "image" | "video";
|
|
580
|
+
model?: string;
|
|
581
|
+
input: {
|
|
582
|
+
prompt: string;
|
|
583
|
+
n?: number;
|
|
584
|
+
size?: string;
|
|
585
|
+
aspect_ratio?: "16:9" | "9:16" | "1:1";
|
|
586
|
+
};
|
|
587
|
+
}, opts?: {
|
|
588
|
+
idempotencyKey?: string;
|
|
589
|
+
}) => Promise<AiJob>;
|
|
590
|
+
get: (id: string) => Promise<AiJob>;
|
|
591
|
+
cancel: (id: string) => Promise<AiJob>;
|
|
592
|
+
wait: (id: string, opts?: {
|
|
593
|
+
timeoutMs?: number;
|
|
594
|
+
intervalMs?: number;
|
|
595
|
+
}) => Promise<AiJob>;
|
|
596
|
+
};
|
|
597
|
+
};
|
|
598
|
+
/** A project's AI key and settings (the `ai` resource). Account key only. */
|
|
599
|
+
readonly projectAi: {
|
|
600
|
+
get: (projectId: string) => Promise<AiSettings>;
|
|
601
|
+
update: (projectId: string, patch: Partial<AiSettings["settings"]>) => Promise<AiSettings>;
|
|
602
|
+
/** A new key; the old one keeps working for `graceSeconds` (default 3600). */
|
|
603
|
+
rotateKey: (projectId: string, opts?: {
|
|
604
|
+
graceSeconds?: number;
|
|
605
|
+
}) => Promise<AiSettings & {
|
|
606
|
+
api_key: string;
|
|
607
|
+
}>;
|
|
608
|
+
revokeKey: (projectId: string) => Promise<AiSettings>;
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Your own AI provider keys (docs/AI.md "Your own keys"): calls they can
|
|
612
|
+
* serve run only on them (never falling back to Vibiz) and cost 0 here.
|
|
613
|
+
* Pass `projectId` for a project's override. Setting and removing need an
|
|
614
|
+
* owner key. Secrets are write-only: no method returns one.
|
|
615
|
+
*/
|
|
616
|
+
readonly aiKeys: {
|
|
617
|
+
list: (opts?: {
|
|
618
|
+
projectId?: string;
|
|
619
|
+
}) => Promise<AiProviderKeyList>;
|
|
620
|
+
get: (provider: "google", opts?: {
|
|
621
|
+
projectId?: string;
|
|
622
|
+
}) => Promise<AiProviderKey>;
|
|
623
|
+
/** Checked with a cheap call to the provider first; refused with the reason if it fails. */
|
|
624
|
+
set: (provider: "google", input: AiProviderKeyInput, opts?: {
|
|
625
|
+
projectId?: string;
|
|
626
|
+
}) => Promise<AiProviderKey>;
|
|
627
|
+
/** Which capabilities the key serves; the rest runs on Vibiz. */
|
|
628
|
+
update: (provider: "google", patch: {
|
|
629
|
+
use_for: AiProviderKey["use_for"] & {};
|
|
630
|
+
}, opts?: {
|
|
631
|
+
projectId?: string;
|
|
632
|
+
}) => Promise<AiProviderKey>;
|
|
633
|
+
test: (provider: "google", opts?: {
|
|
634
|
+
projectId?: string;
|
|
635
|
+
}) => Promise<AiProviderKey>;
|
|
636
|
+
remove: (provider: "google", opts?: {
|
|
637
|
+
projectId?: string;
|
|
638
|
+
}) => Promise<AiProviderKey>;
|
|
639
|
+
};
|
|
640
|
+
/** What the account used, what it cost, and how close it is to its limits. */
|
|
641
|
+
readonly usage: {
|
|
642
|
+
get: (opts?: UsageOptions) => Promise<UsageReport>;
|
|
643
|
+
project: (projectId: string, opts?: UsageOptions) => Promise<UsageReport>;
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* The account's own credits (docs/BILLING.md): the balance, the card,
|
|
647
|
+
* auto-recharge and history. A top-up is a hosted page a person pays on.
|
|
648
|
+
*/
|
|
649
|
+
readonly billing: {
|
|
650
|
+
get: () => Promise<Billing>;
|
|
651
|
+
/** Owner keys: auto-recharge and the daily safety cap. */
|
|
652
|
+
update: (input: BillingUpdate) => Promise<Billing>;
|
|
653
|
+
/** A payment page for `amount_cents` (500–100000); hand its `url` to a person. */
|
|
654
|
+
checkout: (input: {
|
|
655
|
+
amount_cents: number;
|
|
656
|
+
save_card?: boolean;
|
|
657
|
+
}) => Promise<BillingCheckout>;
|
|
658
|
+
checkoutStatus: (id: string) => Promise<BillingCheckout>;
|
|
659
|
+
/** Owner keys: a page to save or replace the card. */
|
|
660
|
+
saveCard: () => Promise<BillingCheckout>;
|
|
661
|
+
removeCard: () => Promise<Billing>;
|
|
662
|
+
ledger: (opts?: {
|
|
663
|
+
kind?: BillingEntryKind[];
|
|
664
|
+
cursor?: string;
|
|
665
|
+
limit?: number;
|
|
666
|
+
}) => Promise<BillingList<BillingEntry>>;
|
|
667
|
+
charges: (opts?: {
|
|
668
|
+
status?: string;
|
|
669
|
+
cursor?: string;
|
|
670
|
+
limit?: number;
|
|
671
|
+
}) => Promise<BillingList<BillingCharge>>;
|
|
672
|
+
};
|
|
673
|
+
/** Request counts, error rate and latency by capability. */
|
|
674
|
+
readonly metrics: {
|
|
675
|
+
get: (opts?: {
|
|
676
|
+
period?: UsagePeriod;
|
|
677
|
+
}) => Promise<MetricsReport>;
|
|
678
|
+
};
|
|
679
|
+
/** Named keys, one per teammate or agent, so spend shows per person. */
|
|
680
|
+
readonly apiKeys: {
|
|
681
|
+
list: () => Promise<ApiKey[]>;
|
|
682
|
+
/** The secret is returned once, here. */
|
|
683
|
+
/** `agent` by default: builds and runs, never reads production secrets. Needs an owner key. */
|
|
684
|
+
create: (name: string, opts?: {
|
|
685
|
+
access?: KeyAccess;
|
|
686
|
+
}) => Promise<ApiKey & {
|
|
687
|
+
secret: string;
|
|
688
|
+
}>;
|
|
689
|
+
revoke: (id: string) => Promise<ApiKey>;
|
|
690
|
+
};
|
|
691
|
+
/** A short-lived link to the hosted usage dashboard (admin scope needs an admin key). */
|
|
692
|
+
readonly dashboard: {
|
|
693
|
+
link: (opts?: {
|
|
694
|
+
scope?: "tenant" | "admin";
|
|
695
|
+
expires_in?: number;
|
|
696
|
+
period?: UsagePeriod;
|
|
697
|
+
}) => Promise<DashboardLink>;
|
|
698
|
+
};
|
|
699
|
+
/** The platform view. Admin keys only. */
|
|
700
|
+
readonly admin: {
|
|
701
|
+
metrics: (opts?: {
|
|
702
|
+
period?: UsagePeriod;
|
|
703
|
+
}) => Promise<AdminMetrics>;
|
|
704
|
+
usage: (opts?: UsageOptions & {
|
|
705
|
+
tenant?: string;
|
|
706
|
+
provider?: string;
|
|
707
|
+
}) => Promise<UsageReport>;
|
|
708
|
+
tenantUsage: (tenantId: string, opts?: UsageOptions) => Promise<UsageReport>;
|
|
709
|
+
};
|
|
710
|
+
/** Company formation: what can be formed where, fees, industries, the disclaimer. */
|
|
711
|
+
readonly company: {
|
|
712
|
+
catalog: (env?: CompanyEnvironment) => Promise<CompanyCatalog>;
|
|
713
|
+
};
|
|
714
|
+
/** The hosts Vibiz can connect to, and the fields each asks for. */
|
|
715
|
+
hostKinds(): Promise<HostKind[]>;
|
|
716
|
+
capabilities(): Promise<{
|
|
717
|
+
resources: ResourceType[];
|
|
718
|
+
actions: string[];
|
|
719
|
+
services: string[];
|
|
720
|
+
}>;
|
|
721
|
+
/** The account and key this client acts as. */
|
|
722
|
+
whoami(): Promise<WhoAmI>;
|
|
723
|
+
/** Revoke the key this client uses (`vibiz logout` for a key made by a browser login). */
|
|
724
|
+
logout(): Promise<{
|
|
725
|
+
object: "api_key";
|
|
726
|
+
id: string;
|
|
727
|
+
revoked: true;
|
|
728
|
+
}>;
|
|
729
|
+
}
|
|
730
|
+
export interface WhoAmI {
|
|
731
|
+
object: 'whoami';
|
|
732
|
+
account: {
|
|
733
|
+
id: string;
|
|
734
|
+
name: string;
|
|
735
|
+
};
|
|
736
|
+
key: {
|
|
737
|
+
id: string;
|
|
738
|
+
name: string;
|
|
739
|
+
prefix: string;
|
|
740
|
+
kind: 'key' | 'console';
|
|
741
|
+
access: 'owner' | 'agent';
|
|
742
|
+
created_at: string;
|
|
743
|
+
};
|
|
744
|
+
role: 'tenant' | 'admin';
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Header values must be Latin-1, so an id outside printable ASCII (`用户-7`,
|
|
748
|
+
* Arabic, emoji) is sent as `b64u:` + base64url of its UTF-8. The API decodes
|
|
749
|
+
* both forms.
|
|
750
|
+
*/
|
|
751
|
+
export declare function endUserHeader(user: string): string;
|