@vibiz/sdk 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/client.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- import type { ActionInfo, ActionResult, ActionRun, ActionRunList, ActionRunsQuery, ActionUsage, AdminMetrics, AiJob, AiModelInfo, AiProviderKey, AiProviderKeyInput, AiProviderKeyList, AiSettings, AnalyticsPeriod, AnalyticsReport, ApiKey, AppKeyInfo, AuthEnvironment, AuthProviderId, AuthProviderInput, AuthSettings, AuthSettingsPatch, Automation, AutomationEnrollment, AutomationInput, AutomationTrigger, Billing, BillingCharge, BillingCheckout, BillingEntry, BillingEntryKind, BillingList, BillingUpdate, Broadcast, BroadcastInput, BroadcastRecipient, BroadcastReview, BroadcastStatus, ChatChunk, ChatCompletion, ChatRequest, Checkout, CheckoutInput, Company, CompanyAddressFields, CompanyCatalog, CompanyDraft, CompanyEnvironment, CompanyLink, Connector, ConnectorApproval, ConnectorCall, ConnectorCallInput, ConnectorCheck, ConnectorEnvironment, ConnectorImport, ConnectorInput, ConnectorPatch, ConnectorResponse, ContactPropertyValue, ContactStatus, DashboardLink, DeployFile, Deployment, DesignSpec, DevEnvironment, Domain, DomainBuyInput, DomainList, DomainOwnerContact, DomainOwnerDetails, DomainQuote, DomainSearch, EmailContact, EmailContactInput, EmailContactList, EmailContactPatch, EmailForwarding, EmailForwardingLog, EmailForwardingRule, EmailImportInput, EmailImportReport, EmailList, EmailMarketing, EmailMarketingPatch, EmailPage, EmailPreview, EmailSegment, EmailTestResult, EnvTargetInfo, ExportInput, FileEnvironment, FileList, FileListOptions, FileUploadOptions, HostKind, ImageRequest, ImageResult, InboxSettings, KeyAccess, LedgerEntry, Mailbox, MailboxInput, MailDomain, MailFolder, MailReplyInput, MailSendInput, MailThreadDetail, MailThreadList, MailView, MetricsReport, Operation, OwnAccountLink, OwnedDomain, OwnedDomainList, Payment, PaymentPrice, PaymentPriceInput, PaymentProduct, PaymentSubscription, PaymentsAccount, PaymentsEnvironment, PaymentsList, PaymentsSimulation, Project, ProjectExport, ReplayDetail, ReplayInsights, ReplayListOptions, ReplayPeriod, ReplayStatus, ReplaySummary, Resource, ResourceType, SegmentFilter, SendEmailInput, SendEmailOutput, SocialAccount, SocialAccountAnalytics, SocialAdCampaign, SocialAdChange, SocialAdChangeInput, SocialConnectLink, SocialEnvironment, SocialMedia, SocialOverview, SocialPost, SocialPostAnalytics, SocialPostInput, SpeechRequest, Transcription, UsageOptions, UsagePeriod, UsageReport, VibizFile, WebDesignInput, WebhookDelivery, WebhookEventType, Withdrawal } from './types.js';
1
+ import type { ActionInfo, ActionResult, ActionRun, ActionRunList, ActionRunsQuery, ActionUsage, AdminMetrics, AiJob, AiModelInfo, AiProviderKey, AiProviderKeyInput, AiProviderKeyList, AiSettings, AnalyticsPeriod, AnalyticsReport, ApiKey, AppKeyInfo, AuthEnvironment, AuthProviderId, AuthProviderInput, AuthSettings, AuthSettingsPatch, Automation, AutomationEnrollment, AutomationInput, AutomationTrigger, Billing, BillingCharge, BillingCheckout, BillingEntry, BillingEntryKind, BillingList, BillingUpdate, Broadcast, BroadcastInput, BroadcastRecipient, BroadcastReview, BroadcastStatus, ChatChunk, ChatCompletion, ChatRequest, Checkout, CheckoutInput, Company, CompanyAddressFields, CompanyCatalog, CompanyDraft, CompanyEnvironment, CompanyLink, Connector, ConnectorApproval, ConnectorCall, ConnectorCallInput, ConnectorCheck, ConnectorEnvironment, ConnectorImport, ConnectorInput, ConnectorPatch, ConnectorResponse, ContactPropertyValue, ContactStatus, DashboardLink, DeployFile, Deployment, DesignSpec, DevEnvironment, Domain, DomainBuyInput, DomainList, DomainOwnerContact, DomainOwnerDetails, DomainQuote, DomainSearch, DomainUse, DomainUseInput, EmailContact, EmailContactInput, EmailContactList, EmailContactPatch, EmailForwarding, EmailForwardingLog, EmailForwardingRule, EmailImportInput, EmailImportReport, EmailList, EmailMarketing, EmailMarketingPatch, EmailPage, EmailPreview, EmailSegment, EmailTestResult, EnvTargetInfo, ExportInput, FileEnvironment, FileList, FileListOptions, FileUploadOptions, HostKind, ImageRequest, ImageResult, InboxSettings, KeyAccess, LedgerEntry, Mailbox, MailboxInput, MailDomain, MailFolder, MailReplyInput, MailSendInput, MailThreadDetail, MailThreadList, MailView, MetricsReport, Operation, OwnAccountLink, OwnedDomain, OwnedDomainList, Payment, PaymentPrice, PaymentPriceInput, PaymentProduct, PaymentSubscription, PaymentsAccount, PaymentsEnvironment, PaymentsList, PaymentsSimulation, Project, ProjectExport, ReplayDetail, ReplayInsights, ReplayListOptions, ReplayPeriod, ReplayStatus, ReplaySummary, Resource, ResourceType, SegmentFilter, SendEmailInput, SendEmailOutput, SocialAccount, SocialAccountAnalytics, SocialAdCampaign, SocialAdChange, SocialAdChangeInput, SocialConnectLink, SocialEnvironment, SocialMedia, SocialOverview, SocialPost, SocialPostAnalytics, SocialPostInput, SpeechRequest, Transcription, UsageOptions, UsagePeriod, UsageReport, VibizFile, WebDesignInput, WebhookDelivery, WebhookEventType, Withdrawal } from './types.js';
2
+ /**
3
+ * An error status with no Vibiz error body: a proxy, a load balancer or the
4
+ * network answered instead of the API. Say so, and what to do.
5
+ */
6
+ export declare function noBodyMessage(status: number): string;
2
7
  export declare class VibizApiError extends Error {
3
8
  readonly status: number;
4
9
  readonly code: string;
@@ -16,6 +21,8 @@ export interface VibizOptions {
16
21
  * not an email.
17
22
  */
18
23
  user?: string;
24
+ /** Who is calling, sent as `X-Vibiz-Client` (the CLI: `vibiz-cli/<version>`), so the API can ask an old one to update. */
25
+ client?: string;
19
26
  }
20
27
  /**
21
28
  * The typed client for the Vibiz Stack API. Used by the CLI, by Principia's
@@ -67,7 +74,7 @@ export declare class Vibiz {
67
74
  project_id: string;
68
75
  usage: ActionUsage | null;
69
76
  }>;
70
- /** The production env. Owner keys only: an agent key gets `forbidden` (use `dev`). */
77
+ /** The production env. Full-access keys only: a Limited key gets `forbidden` (use `dev`). */
71
78
  env: (id: string) => Promise<Record<string, string>>;
72
79
  /** The production env's variable names, without values. Any key. */
73
80
  envNames: (id: string) => Promise<string[]>;
@@ -100,13 +107,13 @@ export declare class Vibiz {
100
107
  /** The app key (`vz_app_…`), per environment. The secret itself only ever travels in the env. */
101
108
  appKeys: {
102
109
  list: (id: string) => Promise<AppKeyInfo[]>;
103
- /** Production's needs an owner key. The old key works for `grace_seconds` (default 3600). */
110
+ /** Production's needs a full-access key. The old key works for `grace_seconds` (default 3600). */
104
111
  rotate: (id: string, opts?: {
105
112
  environment?: "production" | "development";
106
113
  grace_seconds?: number;
107
114
  }) => Promise<AppKeyInfo>;
108
115
  };
109
- /** Hosts outside Vibiz that receive the env server to server. Connecting needs an owner key. */
116
+ /** Hosts outside Vibiz that receive the env server to server. Connecting needs a full-access key. */
110
117
  hosts: {
111
118
  list: (id: string) => Promise<EnvTargetInfo[]>;
112
119
  add: (id: string, input: {
@@ -125,7 +132,7 @@ export declare class Vibiz {
125
132
  }) => Promise<EnvTargetInfo>;
126
133
  };
127
134
  /**
128
- * The app's own database. `production` needs an owner key (it holds the
135
+ * The app's own database. `production` needs a full-access key (it holds the
129
136
  * app's users' data); agents read `development`, the default for them.
130
137
  */
131
138
  database: {
@@ -143,7 +150,7 @@ export declare class Vibiz {
143
150
  };
144
151
  /**
145
152
  * How people sign in to the app (docs/SIGN-IN.md). `production` needs an
146
- * owner key; agents work on `development`, the default for them.
153
+ * full-access key; agents work on `development`, the default for them.
147
154
  */
148
155
  auth: {
149
156
  get: (id: string, env?: AuthEnvironment) => Promise<AuthSettings>;
@@ -160,7 +167,7 @@ export declare class Vibiz {
160
167
  /**
161
168
  * The business behind the project (docs/COMPANY.md). `env` defaults like
162
169
  * the API: production for owners, development for agents. Production
163
- * submit, signing, actions and documents need an owner key.
170
+ * submit, signing, actions and documents need a full-access key.
164
171
  */
165
172
  company: {
166
173
  get: (id: string, env?: CompanyEnvironment) => Promise<Company>;
@@ -174,7 +181,7 @@ export declare class Vibiz {
174
181
  deleted: true;
175
182
  }>;
176
183
  /**
177
- * Production files for real and charges the price: an owner key, `confirm: true`,
184
+ * Production files for real and charges the price: a full-access key, `confirm: true`,
178
185
  * and the `quote.total_cents` and `updated_at` of the draft that was reviewed
179
186
  * (a draft or price changed since is refused with a 409, not filed).
180
187
  */
@@ -185,7 +192,7 @@ export declare class Vibiz {
185
192
  expected_updated_at?: string;
186
193
  }, env?: CompanyEnvironment) => Promise<Company>;
187
194
  /**
188
- * Pay a live filing by card instead of from the balance (owner keys): the same
195
+ * Pay a live filing by card instead of from the balance (full-access keys): the same
189
196
  * body as `submit`; it is filed when the payment arrives (docs/BILLING.md "Company").
190
197
  */
191
198
  checkout: (id: string, input: {
@@ -318,7 +325,7 @@ export declare class Vibiz {
318
325
  * Payments (docs/PAYMENTS.md): Vibiz is the merchant, so an app sells from
319
326
  * its first call. `env` defaults like the API: production for owners,
320
327
  * development for agents. On production, refunds, cancels, withdrawing,
321
- * payout setup and webhook settings need an owner key.
328
+ * payout setup and webhook settings need a full-access key.
322
329
  */
323
330
  payments: {
324
331
  get: (id: string, env?: PaymentsEnvironment) => Promise<PaymentsAccount>;
@@ -412,7 +419,7 @@ export declare class Vibiz {
412
419
  * Custom connectors (docs/CONNECTORS.md): any HTTP API from one manifest,
413
420
  * called through Vibiz, which holds the key. `env` defaults like the API:
414
421
  * production for owners, development for agents. Production keys, and
415
- * approving an agent's dangerous call, need an owner key.
422
+ * approving an agent's dangerous call, need a full-access key.
416
423
  */
417
424
  connectors: {
418
425
  list: (id: string) => Promise<Connector[]>;
@@ -429,10 +436,10 @@ export declare class Vibiz {
429
436
  }) => Promise<ConnectorImport>;
430
437
  update: (id: string, name: string, patch: ConnectorPatch) => Promise<Connector>;
431
438
  delete: (id: string, name: string) => Promise<Connector>;
432
- /** Set values (`null` removes). Production: owner keys. Values are never read back. */
439
+ /** Set values (`null` removes). Production: full-access keys. Values are never read back. */
433
440
  setSecrets: (id: string, name: string, values: Record<string, string | null>, env?: ConnectorEnvironment) => Promise<Connector>;
434
441
  check: (id: string, name: string, env?: ConnectorEnvironment) => Promise<ConnectorCheck>;
435
- /** One operation. A dangerous one (or a production write) by an agent key answers 403 approval_required. */
442
+ /** One operation. A dangerous one (or a production write) by a Limited key answers 403 approval_required. */
436
443
  call: <T = unknown>(id: string, name: string, input: ConnectorCallInput, opts?: {
437
444
  env?: ConnectorEnvironment;
438
445
  idempotencyKey?: string;
@@ -446,15 +453,15 @@ export declare class Vibiz {
446
453
  status?: ConnectorApproval["status"];
447
454
  }) => Promise<ConnectorApproval[]>;
448
455
  approval: (id: string, approvalId: string) => Promise<ConnectorApproval>;
449
- /** Owner keys. */
456
+ /** Full-access keys. */
450
457
  approve: (id: string, approvalId: string) => Promise<ConnectorApproval>;
451
- /** Owner keys. */
458
+ /** Full-access keys. */
452
459
  deny: (id: string, approvalId: string) => Promise<ConnectorApproval>;
453
460
  };
454
461
  /**
455
462
  * The owner's own domains: served by Vibiz hosting (with HTTPS once DNS
456
463
  * points at it) or trusted for a host elsewhere. Adding and removing need
457
- * an owner key; any key reads status and asks for a re-check.
464
+ * a full-access key; any key reads status and asks for a re-check.
458
465
  */
459
466
  domains: {
460
467
  list: (id: string) => Promise<DomainList>;
@@ -468,8 +475,8 @@ export declare class Vibiz {
468
475
  verify: (id: string, domain: string) => Promise<Domain>;
469
476
  remove: (id: string, domain: string) => Promise<DomainList>;
470
477
  /**
471
- * Owner keys: buy a domain from the account's credits; it serves on this
472
- * project once registered. An agent key answers `owner_only` with the
478
+ * Full-access keys: buy a domain from the account's credits; it serves on this
479
+ * project once registered. A Limited key answers `owner_only` with the
473
480
  * console link to hand the owner.
474
481
  */
475
482
  buy: (id: string, input: DomainBuyInput) => Promise<OwnedDomain>;
@@ -546,7 +553,7 @@ export declare class Vibiz {
546
553
  /** One of its files, from its signed link (no key sent). */
547
554
  download: (url: string) => Promise<Response>;
548
555
  /**
549
- * The environment's secret values as `.env` text. Owner keys only; the
556
+ * The environment's secret values as `.env` text. Full-access keys only; the
550
557
  * call itself is the confirmation, so only make it when the person asked.
551
558
  */
552
559
  envFile: (projectId: string, exportId: string) => Promise<string>;
@@ -906,7 +913,7 @@ export declare class Vibiz {
906
913
  * Your own AI provider keys (docs/AI.md "Your own keys"): calls they can
907
914
  * serve run only on them (never falling back to Vibiz) and cost 0 here.
908
915
  * Pass `projectId` for a project's override. Setting and removing need an
909
- * owner key. Secrets are write-only: no method returns one.
916
+ * full-access key. Secrets are write-only: no method returns one.
910
917
  */
911
918
  readonly aiKeys: {
912
919
  list: (opts?: {
@@ -940,7 +947,7 @@ export declare class Vibiz {
940
947
  /**
941
948
  * Buying domains (docs: buying a domain): search and quote with any key;
942
949
  * the domains the account owns, auto-renew, renewals, the transfer code and
943
- * the owner details (the registrant, saved once) need an owner key.
950
+ * the owner details (the registrant, saved once) need a full-access key.
944
951
  */
945
952
  readonly domains: {
946
953
  search: (q: string, opts?: {
@@ -965,12 +972,32 @@ export declare class Vibiz {
965
972
  auth_code: string;
966
973
  next_step: string;
967
974
  }>;
975
+ /**
976
+ * Use a bought domain (or a name under it) on any of the account's
977
+ * projects: no DNS to set, trusted for sign-in at once. Any key. A name
978
+ * another project uses answers 409 `in_use` with the move.
979
+ */
980
+ use: (domain: string, projectId: string, input?: DomainUseInput) => Promise<DomainUse>;
981
+ /** Full-access keys: move a name from the project using it to `toProjectId`. */
982
+ move: (domain: string, toProjectId: string, input?: DomainUseInput & {
983
+ from_project_id?: string;
984
+ }) => Promise<DomainUse>;
985
+ /** A bought name used by an app elsewhere: point it at that host (`null` clears it). */
986
+ point: (domain: string, input: {
987
+ name?: string;
988
+ points_to: string | null;
989
+ project_id?: string;
990
+ }) => Promise<DomainUse>;
991
+ /** Buy for the account: on `project_id` once registered, or none to use later. */
992
+ buy: (input: DomainBuyInput & {
993
+ project_id?: string | null;
994
+ }) => Promise<OwnedDomain>;
968
995
  owner: () => Promise<DomainOwnerDetails>;
969
996
  setOwner: (contact: DomainOwnerContact) => Promise<DomainOwnerDetails>;
970
997
  /**
971
998
  * Email forwarding (docs: email ▸ Forwarding): `hello@<domain>` → the
972
999
  * owner's inbox, sent "via Vibiz". Anyone reads and verifies; `set` and
973
- * `off` need an owner key (an agent gets `owner_only` with a console link
1000
+ * `off` need a full-access key (an agent gets `owner_only` with a console link
974
1001
  * that has its proposal filled in).
975
1002
  */
976
1003
  forwarding: {
@@ -1034,7 +1061,7 @@ export declare class Vibiz {
1034
1061
  folder?: MailFolder;
1035
1062
  labels?: string[];
1036
1063
  }) => Promise<MailThreadDetail>;
1037
- /** Owner keys; only from trash or spam. */
1064
+ /** Full-access keys; only from trash or spam. */
1038
1065
  delete: (id: string) => Promise<{
1039
1066
  object: "mail_thread";
1040
1067
  id: string;
@@ -1068,7 +1095,7 @@ export declare class Vibiz {
1068
1095
  }>;
1069
1096
  settings: {
1070
1097
  get: () => Promise<InboxSettings>;
1071
- /** Owner keys: the new-mail digest. */
1098
+ /** Full-access keys: the new-mail digest. */
1072
1099
  update: (input: {
1073
1100
  digest?: boolean;
1074
1101
  }) => Promise<InboxSettings>;
@@ -1080,7 +1107,7 @@ export declare class Vibiz {
1080
1107
  */
1081
1108
  readonly billing: {
1082
1109
  get: () => Promise<Billing>;
1083
- /** Owner keys: auto-recharge and the daily safety cap. */
1110
+ /** Full-access keys: auto-recharge and the daily safety cap. */
1084
1111
  update: (input: BillingUpdate) => Promise<Billing>;
1085
1112
  /** A payment page for `amount_cents` (500–100000); hand its `url` to a person. */
1086
1113
  checkout: (input: {
@@ -1088,7 +1115,7 @@ export declare class Vibiz {
1088
1115
  save_card?: boolean;
1089
1116
  }) => Promise<BillingCheckout>;
1090
1117
  checkoutStatus: (id: string) => Promise<BillingCheckout>;
1091
- /** Owner keys: a page to save or replace the card. */
1118
+ /** Full-access keys: a page to save or replace the card. */
1092
1119
  saveCard: () => Promise<BillingCheckout>;
1093
1120
  removeCard: () => Promise<Billing>;
1094
1121
  ledger: (opts?: {
@@ -1111,13 +1138,18 @@ export declare class Vibiz {
1111
1138
  /** Named keys, one per teammate or agent, so spend shows per person. */
1112
1139
  readonly apiKeys: {
1113
1140
  list: () => Promise<ApiKey[]>;
1114
- /** The secret is returned once, here. */
1115
- /** `agent` by default: builds and runs, never reads production secrets. Needs an owner key. */
1141
+ /**
1142
+ * The secret is returned once, here. Full access (`owner`) by default;
1143
+ * `access: 'agent'` makes it Limited (builds and runs, never reads
1144
+ * production secrets nor moves live money). Needs a full-access key.
1145
+ */
1116
1146
  create: (name: string, opts?: {
1117
1147
  access?: KeyAccess;
1118
1148
  }) => Promise<ApiKey & {
1119
1149
  secret: string;
1120
1150
  }>;
1151
+ /** Full access (`owner`) or Limited (`agent`), afterwards. Needs a full-access key, not this one. */
1152
+ setAccess: (id: string, access: KeyAccess) => Promise<ApiKey>;
1121
1153
  revoke: (id: string) => Promise<ApiKey>;
1122
1154
  };
1123
1155
  /** A short-lived link to the hosted usage dashboard (admin scope needs an admin key). */
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export { endUserHeader, Vibiz, VibizApiError, type VibizOptions, type WhoAmI } f
2
2
  export { assertDeployableRoot, collectFiles, deployDirectory, type LocalFile } from './deploy.js';
3
3
  export { mergeEnvFile, writeEnvFile } from './env.js';
4
4
  export { formatUnits, formatUsd } from './format.js';
5
+ export { APP_SDK_VERSION, connectHostMessage, ONE_KEY_GIVES, oneKeyMessage, } from './one-key.js';
5
6
  export type * from './types.js';
package/dist/index.js CHANGED
@@ -1,4 +1,14 @@
1
1
  // packages/sdk/src/client.ts
2
+ function noBodyMessage(status) {
3
+ if (status === 401) return "Not signed in (401): the API key is missing or was revoked.";
4
+ if (status === 404) return "Not found (404): check the API URL and the id.";
5
+ if (status === 413) return "Too large (413): send less at once.";
6
+ if (status === 429) return "Too many requests (429): wait a moment and retry.";
7
+ if (status >= 500) {
8
+ return `The Vibiz API did not answer properly (${status}). It is usually brief: retry in a minute.`;
9
+ }
10
+ return `The request failed with ${status} and no explanation from the API.`;
11
+ }
2
12
  var VibizApiError = class extends Error {
3
13
  constructor(status, code, message, details) {
4
14
  super(message);
@@ -30,6 +40,7 @@ var Vibiz = class {
30
40
  if (init.raw) headers["content-type"] = init.contentType ?? "application/octet-stream";
31
41
  if (init.idempotencyKey) headers["idempotency-key"] = init.idempotencyKey;
32
42
  if (this.options.user) headers["x-vibiz-user"] = endUserHeader(this.options.user);
43
+ if (this.options.client) headers["x-vibiz-client"] = this.options.client;
33
44
  return this.fetchImpl(`${this.baseUrl}/v1${path}`, {
34
45
  method: init.method ?? "GET",
35
46
  headers,
@@ -42,7 +53,7 @@ var Vibiz = class {
42
53
  throw new VibizApiError(
43
54
  res.status,
44
55
  e?.code ?? "http_error",
45
- e?.message ?? `HTTP ${res.status}`,
56
+ e?.message ?? noBodyMessage(res.status),
46
57
  e?.details
47
58
  );
48
59
  }
@@ -61,7 +72,7 @@ var Vibiz = class {
61
72
  throw new VibizApiError(
62
73
  res.status,
63
74
  e?.code ?? "http_error",
64
- e?.message ?? `HTTP ${res.status}`,
75
+ e?.message ?? noBodyMessage(res.status),
65
76
  e?.details
66
77
  );
67
78
  }
@@ -102,7 +113,7 @@ var Vibiz = class {
102
113
  `/projects/${id}/actions/${name}`,
103
114
  { method: "POST", body: { input }, ...opts }
104
115
  ),
105
- /** The production env. Owner keys only: an agent key gets `forbidden` (use `dev`). */
116
+ /** The production env. Full-access keys only: a Limited key gets `forbidden` (use `dev`). */
106
117
  env: (id) => this.request(`/projects/${id}/env`).then((r) => r.env),
107
118
  /** The production env's variable names, without values. Any key. */
108
119
  envNames: (id) => this.request(`/projects/${id}/env?names=1`).then((r) => r.names),
@@ -154,10 +165,10 @@ var Vibiz = class {
154
165
  /** The app key (`vz_app_…`), per environment. The secret itself only ever travels in the env. */
155
166
  appKeys: {
156
167
  list: (id) => this.request(`/projects/${id}/app-keys`).then((r) => r.data),
157
- /** Production's needs an owner key. The old key works for `grace_seconds` (default 3600). */
168
+ /** Production's needs a full-access key. The old key works for `grace_seconds` (default 3600). */
158
169
  rotate: (id, opts = {}) => this.request(`/projects/${id}/app-keys/rotate`, { method: "POST", body: opts })
159
170
  },
160
- /** Hosts outside Vibiz that receive the env server to server. Connecting needs an owner key. */
171
+ /** Hosts outside Vibiz that receive the env server to server. Connecting needs a full-access key. */
161
172
  hosts: {
162
173
  list: (id) => this.request(`/projects/${id}/hosts`).then((r) => r.data),
163
174
  add: (id, input) => this.request(`/projects/${id}/hosts`, { method: "POST", body: input }),
@@ -171,7 +182,7 @@ var Vibiz = class {
171
182
  )
172
183
  },
173
184
  /**
174
- * The app's own database. `production` needs an owner key (it holds the
185
+ * The app's own database. `production` needs a full-access key (it holds the
175
186
  * app's users' data); agents read `development`, the default for them.
176
187
  */
177
188
  database: {
@@ -186,7 +197,7 @@ var Vibiz = class {
186
197
  },
187
198
  /**
188
199
  * How people sign in to the app (docs/SIGN-IN.md). `production` needs an
189
- * owner key; agents work on `development`, the default for them.
200
+ * full-access key; agents work on `development`, the default for them.
190
201
  */
191
202
  auth: {
192
203
  get: (id, env) => this.request(`/projects/${id}/auth/settings${env ? `?env=${env}` : ""}`),
@@ -212,7 +223,7 @@ var Vibiz = class {
212
223
  /**
213
224
  * The business behind the project (docs/COMPANY.md). `env` defaults like
214
225
  * the API: production for owners, development for agents. Production
215
- * submit, signing, actions and documents need an owner key.
226
+ * submit, signing, actions and documents need a full-access key.
216
227
  */
217
228
  company: {
218
229
  get: (id, env) => this.request(`/projects/${id}/company${envQuery(env)}`),
@@ -231,7 +242,7 @@ var Vibiz = class {
231
242
  { method: "DELETE" }
232
243
  ),
233
244
  /**
234
- * Production files for real and charges the price: an owner key, `confirm: true`,
245
+ * Production files for real and charges the price: a full-access key, `confirm: true`,
235
246
  * and the `quote.total_cents` and `updated_at` of the draft that was reviewed
236
247
  * (a draft or price changed since is refused with a 409, not filed).
237
248
  */
@@ -240,7 +251,7 @@ var Vibiz = class {
240
251
  body: input
241
252
  }),
242
253
  /**
243
- * Pay a live filing by card instead of from the balance (owner keys): the same
254
+ * Pay a live filing by card instead of from the balance (full-access keys): the same
244
255
  * body as `submit`; it is filed when the payment arrives (docs/BILLING.md "Company").
245
256
  */
246
257
  checkout: (id, input) => this.request(`/projects/${id}/company/checkout?env=production`, {
@@ -354,7 +365,7 @@ var Vibiz = class {
354
365
  * Payments (docs/PAYMENTS.md): Vibiz is the merchant, so an app sells from
355
366
  * its first call. `env` defaults like the API: production for owners,
356
367
  * development for agents. On production, refunds, cancels, withdrawing,
357
- * payout setup and webhook settings need an owner key.
368
+ * payout setup and webhook settings need a full-access key.
358
369
  */
359
370
  payments: {
360
371
  get: (id, env) => this.request(`/projects/${id}/payments${envQuery(env)}`),
@@ -466,7 +477,7 @@ var Vibiz = class {
466
477
  * Custom connectors (docs/CONNECTORS.md): any HTTP API from one manifest,
467
478
  * called through Vibiz, which holds the key. `env` defaults like the API:
468
479
  * production for owners, development for agents. Production keys, and
469
- * approving an agent's dangerous call, need an owner key.
480
+ * approving an agent's dangerous call, need a full-access key.
470
481
  */
471
482
  connectors: {
472
483
  list: (id) => this.request(`/projects/${id}/connectors`).then((r) => r.data),
@@ -485,7 +496,7 @@ var Vibiz = class {
485
496
  delete: (id, name) => this.request(`/projects/${id}/connectors/${encodeURIComponent(name)}`, {
486
497
  method: "DELETE"
487
498
  }),
488
- /** Set values (`null` removes). Production: owner keys. Values are never read back. */
499
+ /** Set values (`null` removes). Production: full-access keys. Values are never read back. */
489
500
  setSecrets: (id, name, values, env) => this.request(
490
501
  `/projects/${id}/connectors/${encodeURIComponent(name)}/secrets${envQuery(env)}`,
491
502
  { method: "PUT", body: { values } }
@@ -494,7 +505,7 @@ var Vibiz = class {
494
505
  `/projects/${id}/connectors/${encodeURIComponent(name)}/check${envQuery(env)}`,
495
506
  { method: "POST", body: {} }
496
507
  ),
497
- /** One operation. A dangerous one (or a production write) by an agent key answers 403 approval_required. */
508
+ /** One operation. A dangerous one (or a production write) by a Limited key answers 403 approval_required. */
498
509
  call: (id, name, input, opts = {}) => this.request(
499
510
  `/projects/${id}/connectors/${encodeURIComponent(name)}/call${envQuery(opts.env)}`,
500
511
  {
@@ -512,12 +523,12 @@ var Vibiz = class {
512
523
  approval: (id, approvalId) => this.request(
513
524
  `/projects/${id}/connectors/approvals/${encodeURIComponent(approvalId)}`
514
525
  ),
515
- /** Owner keys. */
526
+ /** Full-access keys. */
516
527
  approve: (id, approvalId) => this.request(
517
528
  `/projects/${id}/connectors/approvals/${encodeURIComponent(approvalId)}/approve`,
518
529
  { method: "POST", body: {} }
519
530
  ),
520
- /** Owner keys. */
531
+ /** Full-access keys. */
521
532
  deny: (id, approvalId) => this.request(
522
533
  `/projects/${id}/connectors/approvals/${encodeURIComponent(approvalId)}/deny`,
523
534
  { method: "POST", body: {} }
@@ -526,7 +537,7 @@ var Vibiz = class {
526
537
  /**
527
538
  * The owner's own domains: served by Vibiz hosting (with HTTPS once DNS
528
539
  * points at it) or trusted for a host elsewhere. Adding and removing need
529
- * an owner key; any key reads status and asks for a re-check.
540
+ * a full-access key; any key reads status and asks for a re-check.
530
541
  */
531
542
  domains: {
532
543
  list: (id) => this.request(`/projects/${id}/domains`),
@@ -544,8 +555,8 @@ var Vibiz = class {
544
555
  method: "DELETE"
545
556
  }),
546
557
  /**
547
- * Owner keys: buy a domain from the account's credits; it serves on this
548
- * project once registered. An agent key answers `owner_only` with the
558
+ * Full-access keys: buy a domain from the account's credits; it serves on this
559
+ * project once registered. A Limited key answers `owner_only` with the
549
560
  * console link to hand the owner.
550
561
  */
551
562
  buy: (id, input) => this.request(`/projects/${id}/domains/buy`, { method: "POST", body: input })
@@ -653,7 +664,7 @@ var Vibiz = class {
653
664
  return res;
654
665
  },
655
666
  /**
656
- * The environment's secret values as `.env` text. Owner keys only; the
667
+ * The environment's secret values as `.env` text. Full-access keys only; the
657
668
  * call itself is the confirmation, so only make it when the person asked.
658
669
  */
659
670
  envFile: async (projectId, exportId) => {
@@ -1034,7 +1045,7 @@ var Vibiz = class {
1034
1045
  * Your own AI provider keys (docs/AI.md "Your own keys"): calls they can
1035
1046
  * serve run only on them (never falling back to Vibiz) and cost 0 here.
1036
1047
  * Pass `projectId` for a project's override. Setting and removing need an
1037
- * owner key. Secrets are write-only: no method returns one.
1048
+ * full-access key. Secrets are write-only: no method returns one.
1038
1049
  */
1039
1050
  aiKeys = {
1040
1051
  list: (opts = {}) => this.request(`${aiKeysBase(opts.projectId)}`),
@@ -1065,7 +1076,7 @@ var Vibiz = class {
1065
1076
  /**
1066
1077
  * Buying domains (docs: buying a domain): search and quote with any key;
1067
1078
  * the domains the account owns, auto-renew, renewals, the transfer code and
1068
- * the owner details (the registrant, saved once) need an owner key.
1079
+ * the owner details (the registrant, saved once) need a full-access key.
1069
1080
  */
1070
1081
  domains = {
1071
1082
  search: (q, opts = {}) => this.request(`/domains/search${qs({ q, project_id: opts.projectId })}`),
@@ -1083,12 +1094,33 @@ var Vibiz = class {
1083
1094
  body: input
1084
1095
  }),
1085
1096
  authCode: (domain) => this.request(`/domains/${encodeURIComponent(domain)}/auth-code`, { method: "POST", body: {} }),
1097
+ /**
1098
+ * Use a bought domain (or a name under it) on any of the account's
1099
+ * projects: no DNS to set, trusted for sign-in at once. Any key. A name
1100
+ * another project uses answers 409 `in_use` with the move.
1101
+ */
1102
+ use: (domain, projectId, input = {}) => this.request(`/domains/${encodeURIComponent(domain)}/use`, {
1103
+ method: "POST",
1104
+ body: { project_id: projectId, ...input }
1105
+ }),
1106
+ /** Full-access keys: move a name from the project using it to `toProjectId`. */
1107
+ move: (domain, toProjectId, input = {}) => this.request(`/domains/${encodeURIComponent(domain)}/move`, {
1108
+ method: "POST",
1109
+ body: { to_project_id: toProjectId, ...input }
1110
+ }),
1111
+ /** A bought name used by an app elsewhere: point it at that host (`null` clears it). */
1112
+ point: (domain, input) => this.request(`/domains/${encodeURIComponent(domain)}/point`, {
1113
+ method: "POST",
1114
+ body: input
1115
+ }),
1116
+ /** Buy for the account: on `project_id` once registered, or none to use later. */
1117
+ buy: (input) => this.request("/domains/buy", { method: "POST", body: input }),
1086
1118
  owner: () => this.request("/domains/owner"),
1087
1119
  setOwner: (contact) => this.request("/domains/owner", { method: "PUT", body: { contact } }),
1088
1120
  /**
1089
1121
  * Email forwarding (docs: email ▸ Forwarding): `hello@<domain>` → the
1090
1122
  * owner's inbox, sent "via Vibiz". Anyone reads and verifies; `set` and
1091
- * `off` need an owner key (an agent gets `owner_only` with a console link
1123
+ * `off` need a full-access key (an agent gets `owner_only` with a console link
1092
1124
  * that has its proposal filled in).
1093
1125
  */
1094
1126
  forwarding: {
@@ -1147,7 +1179,7 @@ var Vibiz = class {
1147
1179
  method: "PATCH",
1148
1180
  body: input
1149
1181
  }),
1150
- /** Owner keys; only from trash or spam. */
1182
+ /** Full-access keys; only from trash or spam. */
1151
1183
  delete: (id) => this.request(
1152
1184
  `/inbox/threads/${encodeURIComponent(id)}`,
1153
1185
  { method: "DELETE" }
@@ -1178,7 +1210,7 @@ var Vibiz = class {
1178
1210
  }),
1179
1211
  settings: {
1180
1212
  get: () => this.request("/inbox/settings"),
1181
- /** Owner keys: the new-mail digest. */
1213
+ /** Full-access keys: the new-mail digest. */
1182
1214
  update: (input) => this.request("/inbox/settings", { method: "PATCH", body: input })
1183
1215
  }
1184
1216
  };
@@ -1188,12 +1220,12 @@ var Vibiz = class {
1188
1220
  */
1189
1221
  billing = {
1190
1222
  get: () => this.request("/billing"),
1191
- /** Owner keys: auto-recharge and the daily safety cap. */
1223
+ /** Full-access keys: auto-recharge and the daily safety cap. */
1192
1224
  update: (input) => this.request("/billing", { method: "PATCH", body: input }),
1193
1225
  /** A payment page for `amount_cents` (500–100000); hand its `url` to a person. */
1194
1226
  checkout: (input) => this.request("/billing/checkout", { method: "POST", body: input }),
1195
1227
  checkoutStatus: (id) => this.request(`/billing/checkout/${encodeURIComponent(id)}`),
1196
- /** Owner keys: a page to save or replace the card. */
1228
+ /** Full-access keys: a page to save or replace the card. */
1197
1229
  saveCard: () => this.request("/billing/card", { method: "POST", body: {} }),
1198
1230
  removeCard: () => this.request("/billing/card", { method: "DELETE" }),
1199
1231
  ledger: (opts = {}) => this.request(
@@ -1208,12 +1240,20 @@ var Vibiz = class {
1208
1240
  /** Named keys, one per teammate or agent, so spend shows per person. */
1209
1241
  apiKeys = {
1210
1242
  list: () => this.request("/api-keys").then((r) => r.data),
1211
- /** The secret is returned once, here. */
1212
- /** `agent` by default: builds and runs, never reads production secrets. Needs an owner key. */
1243
+ /**
1244
+ * The secret is returned once, here. Full access (`owner`) by default;
1245
+ * `access: 'agent'` makes it Limited (builds and runs, never reads
1246
+ * production secrets nor moves live money). Needs a full-access key.
1247
+ */
1213
1248
  create: (name, opts = {}) => this.request("/api-keys", {
1214
1249
  method: "POST",
1215
1250
  body: { name, ...opts.access ? { access: opts.access } : {} }
1216
1251
  }),
1252
+ /** Full access (`owner`) or Limited (`agent`), afterwards. Needs a full-access key, not this one. */
1253
+ setAccess: (id, access) => this.request(`/api-keys/${encodeURIComponent(id)}`, {
1254
+ method: "PATCH",
1255
+ body: { access }
1256
+ }),
1217
1257
  revoke: (id) => this.request(`/api-keys/${id}`, { method: "DELETE" })
1218
1258
  };
1219
1259
  /** A short-lived link to the hosted usage dashboard (admin scope needs an admin key). */
@@ -1426,15 +1466,30 @@ function formatUnits(units) {
1426
1466
  }
1427
1467
  return parts.join(" \xB7 ") || "\u2013";
1428
1468
  }
1469
+
1470
+ // packages/sdk/src/one-key.ts
1471
+ var APP_SDK_VERSION = "0.2.2";
1472
+ var ONE_KEY_GIVES = "database, sign-in, email and inbox, AI models, files, payments, analytics with session replays, web data, social and connectors";
1473
+ function oneKeyMessage(url, host) {
1474
+ const where = host ?? "your host";
1475
+ 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.`;
1476
+ }
1477
+ function connectHostMessage(kind, host) {
1478
+ return `Or connect ${host ?? "the host"} once (vibiz hosts add ${kind ?? "<host>"} <app>) and Vibiz keeps every variable in sync.`;
1479
+ }
1429
1480
  export {
1481
+ APP_SDK_VERSION,
1482
+ ONE_KEY_GIVES,
1430
1483
  Vibiz,
1431
1484
  VibizApiError,
1432
1485
  assertDeployableRoot,
1433
1486
  collectFiles,
1487
+ connectHostMessage,
1434
1488
  deployDirectory,
1435
1489
  endUserHeader,
1436
1490
  formatUnits,
1437
1491
  formatUsd,
1438
1492
  mergeEnvFile,
1493
+ oneKeyMessage,
1439
1494
  writeEnvFile
1440
1495
  };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The one-key rule, worded once (docs/KEYS.md). A running app needs one
3
+ * secret, VIBIZ_APP_KEY, and with it reaches everything its project has. The
4
+ * CLI and the MCP server tell a person exactly this, with the console link
5
+ * that opens the key ready to copy (`app_key_console_url` from the API),
6
+ * never directions to find it.
7
+ */
8
+ /**
9
+ * The published `@vibiz/app` that agents pin when they add it to a website
10
+ * (`npm install --save-exact @vibiz/app@<this>`). A test keeps it, the skills
11
+ * and the docs equal to packages/app/package.json.
12
+ */
13
+ export declare const APP_SDK_VERSION = "0.2.2";
14
+ /** Everything one app key reaches. */
15
+ export declare const ONE_KEY_GIVES = "database, sign-in, email and inbox, AI models, files, payments, analytics with session replays, web data, social and connectors";
16
+ /**
17
+ * The sentence for a person who must put the key in a host. `url` is the
18
+ * API's `app_key_console_url`; `host` names their host when it is known.
19
+ */
20
+ export declare function oneKeyMessage(url: string, host?: string): string;
21
+ /** The other way: the owner connects the host once and Vibiz keeps it in sync. */
22
+ export declare function connectHostMessage(kind?: string, host?: string): string;
package/dist/types.d.ts CHANGED
@@ -56,6 +56,12 @@ export interface Domain {
56
56
  project_id: string;
57
57
  /** `vibiz`: Vibiz hosting serves it. `elsewhere`: another host does. */
58
58
  hosting: 'vibiz' | 'elsewhere';
59
+ /** `purchased`: inside a domain this account bought through Vibiz, so there is no DNS to set. */
60
+ source: 'external' | 'purchased';
61
+ /** True for a bought domain: Vibiz sets every DNS record it needs (`records_to_set` stays empty). */
62
+ dns_by_vibiz: boolean;
63
+ /** A bought name used by an app on another host: where we point it in its DNS (null: not set yet). */
64
+ points_to: string | null;
59
65
  /** False: an agent added it; analytics counts it, sign-in waits for `trust_record` or an owner. */
60
66
  trusted_for_sign_in: boolean;
61
67
  /**
@@ -143,7 +149,7 @@ export interface DomainQuote {
143
149
  fields_needed: DomainOwnerField[];
144
150
  };
145
151
  buy_url?: string;
146
- /** This key may buy it directly (an agent key: the owner allowed agents, up to `agent_limit_cents`). */
152
+ /** This key may buy it directly (a Limited key: the owner allowed agents, up to `agent_limit_cents`). */
147
153
  can_buy?: boolean;
148
154
  agent_limit_cents?: number | null;
149
155
  next_step: string;
@@ -174,11 +180,28 @@ export interface DomainOwnerDetails {
174
180
  applies_to: 'new_domains';
175
181
  console_url: string;
176
182
  }
183
+ /** One name of a bought domain in use on one project. */
184
+ export interface OwnedDomainUse {
185
+ project_id: string;
186
+ project_name: string;
187
+ project_slug: string;
188
+ /** The domain itself or a name under it (`app.example.com`). */
189
+ name: string;
190
+ hosting: 'vibiz' | 'elsewhere';
191
+ www_redirect: string | null;
192
+ console_url: string;
193
+ }
177
194
  export interface OwnedDomain {
178
195
  object: 'owned_domain';
179
196
  id: string;
180
197
  domain: string;
198
+ /** The project the domain itself (the apex) serves on, if any. */
181
199
  project_id: string | null;
200
+ /**
201
+ * Every project using it, the domain or any name under it. A bought domain
202
+ * works on any of the account's projects with no DNS to set (`use`).
203
+ */
204
+ used_on: OwnedDomainUse[];
182
205
  /** `registering` until the registry confirms; `failed`: refunded. */
183
206
  status: 'registering' | 'active' | 'expired' | 'failed';
184
207
  /** Renewed from credits about 30 days before `expires_at`. */
@@ -311,7 +334,7 @@ export interface Mailbox {
311
334
  display_name: string | null;
312
335
  signature: string | null;
313
336
  project_id: string | null;
314
- /** Agent keys may read and reply here (the owner decides). */
337
+ /** Limited keys may read and reply here (the owner decides). */
315
338
  agent_access: boolean;
316
339
  daily_send_cap: number;
317
340
  sent_today: number;
@@ -433,6 +456,30 @@ export interface InboxSettings {
433
456
  digest: boolean;
434
457
  console_url: string;
435
458
  }
459
+ /** `use` / `move`: a bought domain on a project, with no DNS to set. */
460
+ export interface DomainUse {
461
+ object: 'domain_use';
462
+ domain: string;
463
+ /** The full name now on the project (`app.example.com`, or the domain itself). */
464
+ name: string;
465
+ project_id: string;
466
+ /** Set by `move`: where it was before. */
467
+ moved_from: {
468
+ project_id: string;
469
+ project_name: string;
470
+ } | null;
471
+ project_domain: Domain | null;
472
+ owned: OwnedDomain;
473
+ next_step: string;
474
+ }
475
+ export interface DomainUseInput {
476
+ /** The domain itself (default), a prefix (`app`) or a full name under it (`app.example.com`). */
477
+ name?: string;
478
+ /** Defaults to `vibiz` when the project has Vibiz hosting, else `elsewhere`. */
479
+ hosting?: 'vibiz' | 'elsewhere';
480
+ /** An app on another host: its address (host name or IP); we write the record. */
481
+ points_to?: string | null;
482
+ }
436
483
  export interface DomainBuyInput {
437
484
  domain: string;
438
485
  years?: number;
@@ -1343,7 +1390,10 @@ export interface MetricsReport {
1343
1390
  capability: string;
1344
1391
  }>;
1345
1392
  }
1346
- /** `owner`: everything. `agent`: builds and runs, never reads production secrets. */
1393
+ /**
1394
+ * `owner` (Full access, the default): everything the account's owner can do.
1395
+ * `agent` (Limited): builds and runs, never reads production secrets nor moves live money.
1396
+ */
1347
1397
  export type KeyAccess = 'owner' | 'agent';
1348
1398
  export interface ApiKey {
1349
1399
  object: 'api_key';
@@ -1521,7 +1571,7 @@ export interface CompanyPerson {
1521
1571
  roles: CompanyRole[];
1522
1572
  responsible_party: boolean;
1523
1573
  has_tax_id: boolean;
1524
- /** Owner keys only; null for agents. */
1574
+ /** Full-access keys only; null for agents. */
1525
1575
  tax_id_last4: string | null;
1526
1576
  }
1527
1577
  export interface CompanyPrice {
@@ -1611,7 +1661,7 @@ export interface CompanyDraft {
1611
1661
  ownership_percent?: number | null;
1612
1662
  roles?: CompanyRole[];
1613
1663
  responsible_party?: boolean;
1614
- /** SSN or ITIN. Owner keys only. Write-only. */
1664
+ /** SSN or ITIN. Full-access keys only. Write-only. */
1615
1665
  tax_id?: string | null;
1616
1666
  /** Keep the stored tax id of the person with this id. */
1617
1667
  id?: string;
@@ -1795,7 +1845,10 @@ export interface PaymentsAccount {
1795
1845
  };
1796
1846
  statement_descriptor: string;
1797
1847
  fees: {
1848
+ /** The Vibiz fee on this project's sales now, in basis points (200 = 2%), set per account. */
1798
1849
  platform_bps: number;
1850
+ /** The Vibiz fee on sales charged on the owner's own account (what connecting it would mean). */
1851
+ own_account_bps: number;
1799
1852
  /** The card fee for most US cards: card_fee_bps / 100 % + card_fee_fixed_cents. */
1800
1853
  card_fee_bps: number;
1801
1854
  card_fee_fixed_cents: number;
@@ -2648,7 +2701,7 @@ export interface ProjectExport {
2648
2701
  export interface ExportInput {
2649
2702
  /** Default: code, database (when there is one) and env_guide. */
2650
2703
  include?: ExportPart[];
2651
- /** Default: production for owner keys, development for agent keys. */
2704
+ /** Default: production for full-access keys, development for Limited keys. */
2652
2705
  env?: 'production' | 'development';
2653
2706
  /** Default: the live deployment. */
2654
2707
  deployment_id?: string;
@@ -3032,7 +3085,7 @@ export interface BroadcastReview {
3032
3085
  estimated_days: number;
3033
3086
  paced: boolean;
3034
3087
  };
3035
- /** Agent keys: the owner's monthly allowance. */
3088
+ /** Limited keys: the owner's monthly allowance. */
3036
3089
  agent?: {
3037
3090
  monthly_limit: number | null;
3038
3091
  used_this_month: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibiz/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Typed client for the Vibiz Stack API: projects, hosting, databases, sign-in, email, AI, payments and more.",
5
5
  "keywords": [
6
6
  "vibiz",