@vibiz/sdk 0.2.1 → 0.2.3

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,4 @@
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, DeploymentFiles, 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, EnvVarInfo, 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, SecretLink, 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
2
  /**
3
3
  * An error status with no Vibiz error body: a proxy, a load balancer or the
4
4
  * network answered instead of the API. Say so, and what to do.
@@ -87,6 +87,32 @@ export declare class Vibiz {
87
87
  console_url?: string;
88
88
  app_key_console_url?: string;
89
89
  }>;
90
+ /**
91
+ * The app's own variables (a third-party key, a setting): write-only.
92
+ * `list` gives names and when they were set, never values; the values
93
+ * reach the app in its env (loadEnv, env pull) and its connected hosts.
94
+ */
95
+ vars: {
96
+ list: (id: string) => Promise<EnvVarInfo[]>;
97
+ /** Production needs a full-access key; a Limited key gets `forbidden` with the console link. */
98
+ set: (id: string, name: string, value: string, environment?: "production" | "development") => Promise<EnvVarInfo>;
99
+ remove: (id: string, name: string, environment?: "production" | "development") => Promise<{
100
+ name: string;
101
+ environment: string;
102
+ deleted: true;
103
+ }>;
104
+ };
105
+ /**
106
+ * The console link where a person types one secret, write-only: hand it
107
+ * over instead of asking for the value in a chat. `kind`: env (the app's
108
+ * own variable, default), connector (a connector's key), ai (a lab key,
109
+ * name e.g. `google`) or host (a host token, name e.g. `vercel`).
110
+ */
111
+ secretLink: (id: string, input: {
112
+ name: string;
113
+ environment?: "production" | "development";
114
+ kind?: "env" | "connector" | "ai" | "host";
115
+ }) => Promise<SecretLink>;
90
116
  /**
91
117
  * The development environment: its own database branch (schema, no
92
118
  * production rows), its own sign-in and AI key. What agents and laptops use.
@@ -570,6 +596,10 @@ export declare class Vibiz {
570
596
  }>;
571
597
  list: (projectId: string) => Promise<Deployment[]>;
572
598
  get: (id: string) => Promise<Deployment>;
599
+ /** The deployment's code as deployed: every file's path, content hash and size. */
600
+ files: (id: string) => Promise<DeploymentFiles>;
601
+ /** One file's bytes, by its path in the deployment. */
602
+ readFile: (id: string, path: string) => Promise<Uint8Array>;
573
603
  promote: (id: string) => Promise<{
574
604
  deployment: Deployment;
575
605
  operation: Operation | null;
@@ -972,6 +1002,26 @@ export declare class Vibiz {
972
1002
  auth_code: string;
973
1003
  next_step: string;
974
1004
  }>;
1005
+ /**
1006
+ * Use a bought domain (or a name under it) on any of the account's
1007
+ * projects: no DNS to set, trusted for sign-in at once. Any key. A name
1008
+ * another project uses answers 409 `in_use` with the move.
1009
+ */
1010
+ use: (domain: string, projectId: string, input?: DomainUseInput) => Promise<DomainUse>;
1011
+ /** Full-access keys: move a name from the project using it to `toProjectId`. */
1012
+ move: (domain: string, toProjectId: string, input?: DomainUseInput & {
1013
+ from_project_id?: string;
1014
+ }) => Promise<DomainUse>;
1015
+ /** A bought name used by an app elsewhere: point it at that host (`null` clears it). */
1016
+ point: (domain: string, input: {
1017
+ name?: string;
1018
+ points_to: string | null;
1019
+ project_id?: string;
1020
+ }) => Promise<DomainUse>;
1021
+ /** Buy for the account: on `project_id` once registered, or none to use later. */
1022
+ buy: (input: DomainBuyInput & {
1023
+ project_id?: string | null;
1024
+ }) => Promise<OwnedDomain>;
975
1025
  owner: () => Promise<DomainOwnerDetails>;
976
1026
  setOwner: (contact: DomainOwnerContact) => Promise<DomainOwnerDetails>;
977
1027
  /**
package/dist/deploy.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Vibiz } from './client.js';
1
+ import { type Vibiz } from './client.js';
2
2
  import type { DeployFile, Deployment } from './types.js';
3
3
  /**
4
4
  * Refuse folders that are clearly not an app: the filesystem root, a home
@@ -23,3 +23,54 @@ export declare function deployDirectory(vibiz: Vibiz, projectId: string, root: s
23
23
  uploaded: number;
24
24
  total: number;
25
25
  }>;
26
+ /** One file of an inline deploy: its path in the app and its content. */
27
+ export interface InlineFile {
28
+ path: string;
29
+ content: string;
30
+ /** `utf8` (default) for text, `base64` for an image or any binary file. */
31
+ encoding?: 'utf8' | 'base64';
32
+ }
33
+ /**
34
+ * What one inline deploy may carry, like other hosts' inline deploys. A
35
+ * bigger app deploys from its folder with the CLI.
36
+ */
37
+ export declare const INLINE_LIMITS: {
38
+ readonly files: 300;
39
+ readonly fileBytes: number;
40
+ readonly totalBytes: number;
41
+ readonly pathChars: 512;
42
+ };
43
+ /**
44
+ * Why a deploy path is refused, or null when it is fine: the same rules as a
45
+ * folder deploy (no env files, keys, dependencies, VCS data or build output),
46
+ * plus what only a typed path can get wrong (absolute, `..`, backslashes).
47
+ */
48
+ export declare function deployPathProblem(path: string): string | null;
49
+ /** `./a/b` → `a/b`; refuses what deployPathProblem refuses. */
50
+ export declare function normalizeDeployPath(path: string, field?: string): string;
51
+ /** The deployment an inline deploy starts from: `live`, `none`, or a deployment id. */
52
+ export type DeployBase = 'live' | 'none' | (string & {});
53
+ export interface DeployFilesResult {
54
+ deployment: Deployment;
55
+ /** The deployment this one started from, or null for a fresh one. */
56
+ base: string | null;
57
+ /** Nothing differed from the base: no new deployment was made, `deployment` is the base. */
58
+ unchanged: boolean;
59
+ uploaded: number;
60
+ total: number;
61
+ added: string[];
62
+ updated: string[];
63
+ deleted: string[];
64
+ }
65
+ /**
66
+ * Deploy file contents rather than a folder: what an agent in a chat (no files
67
+ * on disk) does. With a base (the live deployment by default, when there is
68
+ * one) the new deployment is the base's files, with these files written over
69
+ * them and `deleted` removed, so an edit sends only what changed. Hashes and
70
+ * uploads like deployDirectory: content the server has is not sent again.
71
+ */
72
+ export declare function deployFiles(vibiz: Vibiz, projectId: string, files: InlineFile[], opts?: {
73
+ base?: DeployBase;
74
+ deleted?: string[];
75
+ target?: 'preview' | 'production';
76
+ }): Promise<DeployFilesResult>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { endUserHeader, Vibiz, VibizApiError, type VibizOptions, type WhoAmI } from './client.js';
2
- export { assertDeployableRoot, collectFiles, deployDirectory, type LocalFile } from './deploy.js';
2
+ export { assertDeployableRoot, collectFiles, type DeployBase, type DeployFilesResult, deployDirectory, deployFiles, deployPathProblem, INLINE_LIMITS, type InlineFile, type LocalFile, normalizeDeployPath, } 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
@@ -124,6 +124,30 @@ var Vibiz = class {
124
124
  envLinks: (id) => this.request(
125
125
  `/projects/${id}/env?names=1`
126
126
  ),
127
+ /**
128
+ * The app's own variables (a third-party key, a setting): write-only.
129
+ * `list` gives names and when they were set, never values; the values
130
+ * reach the app in its env (loadEnv, env pull) and its connected hosts.
131
+ */
132
+ vars: {
133
+ list: (id) => this.request(`/projects/${id}/env/vars`).then((r) => r.data),
134
+ /** Production needs a full-access key; a Limited key gets `forbidden` with the console link. */
135
+ set: (id, name, value, environment = "production") => this.request(`/projects/${id}/env/${encodeURIComponent(name)}`, {
136
+ method: "PUT",
137
+ body: { value, environment }
138
+ }),
139
+ remove: (id, name, environment = "production") => this.request(
140
+ `/projects/${id}/env/${encodeURIComponent(name)}?environment=${environment}`,
141
+ { method: "DELETE" }
142
+ )
143
+ },
144
+ /**
145
+ * The console link where a person types one secret, write-only: hand it
146
+ * over instead of asking for the value in a chat. `kind`: env (the app's
147
+ * own variable, default), connector (a connector's key), ai (a lab key,
148
+ * name e.g. `google`) or host (a host token, name e.g. `vercel`).
149
+ */
150
+ secretLink: (id, input) => this.request(`/projects/${id}/secret-link`, { method: "POST", body: input }),
127
151
  /**
128
152
  * The development environment: its own database branch (schema, no
129
153
  * production rows), its own sign-in and AI key. What agents and laptops use.
@@ -687,6 +711,14 @@ var Vibiz = class {
687
711
  (r) => r.data
688
712
  ),
689
713
  get: (id) => this.request(`/deployments/${id}`),
714
+ /** The deployment's code as deployed: every file's path, content hash and size. */
715
+ files: (id) => this.request(`/deployments/${encodeURIComponent(id)}/files`),
716
+ /** One file's bytes, by its path in the deployment. */
717
+ readFile: async (id, path) => {
718
+ const encoded = path.replace(/^\/+/, "").split("/").map(encodeURIComponent).join("/");
719
+ const res = await this.stream(`/deployments/${encodeURIComponent(id)}/files/${encoded}`);
720
+ return new Uint8Array(await res.arrayBuffer());
721
+ },
690
722
  promote: (id) => this.request(
691
723
  `/deployments/${id}/promote`,
692
724
  { method: "POST" }
@@ -1094,6 +1126,27 @@ var Vibiz = class {
1094
1126
  body: input
1095
1127
  }),
1096
1128
  authCode: (domain) => this.request(`/domains/${encodeURIComponent(domain)}/auth-code`, { method: "POST", body: {} }),
1129
+ /**
1130
+ * Use a bought domain (or a name under it) on any of the account's
1131
+ * projects: no DNS to set, trusted for sign-in at once. Any key. A name
1132
+ * another project uses answers 409 `in_use` with the move.
1133
+ */
1134
+ use: (domain, projectId, input = {}) => this.request(`/domains/${encodeURIComponent(domain)}/use`, {
1135
+ method: "POST",
1136
+ body: { project_id: projectId, ...input }
1137
+ }),
1138
+ /** Full-access keys: move a name from the project using it to `toProjectId`. */
1139
+ move: (domain, toProjectId, input = {}) => this.request(`/domains/${encodeURIComponent(domain)}/move`, {
1140
+ method: "POST",
1141
+ body: { to_project_id: toProjectId, ...input }
1142
+ }),
1143
+ /** A bought name used by an app elsewhere: point it at that host (`null` clears it). */
1144
+ point: (domain, input) => this.request(`/domains/${encodeURIComponent(domain)}/point`, {
1145
+ method: "POST",
1146
+ body: input
1147
+ }),
1148
+ /** Buy for the account: on `project_id` once registered, or none to use later. */
1149
+ buy: (input) => this.request("/domains/buy", { method: "POST", body: input }),
1097
1150
  owner: () => this.request("/domains/owner"),
1098
1151
  setOwner: (contact) => this.request("/domains/owner", { method: "PUT", body: { contact } }),
1099
1152
  /**
@@ -1375,6 +1428,167 @@ async function deployDirectory(vibiz, projectId, root, opts = {}) {
1375
1428
  });
1376
1429
  return { deployment, uploaded: uploadedShas.size, total: files.length };
1377
1430
  }
1431
+ var INLINE_LIMITS = {
1432
+ files: 300,
1433
+ fileBytes: 3 * 1024 * 1024,
1434
+ totalBytes: 4 * 1024 * 1024,
1435
+ pathChars: 512
1436
+ };
1437
+ var BIG_APP = "For a bigger app, deploy its folder with the CLI: npx @vibiz/cli deploy";
1438
+ function invalid(message, details = {}) {
1439
+ throw new VibizApiError(400, "invalid_request", message, details);
1440
+ }
1441
+ function deployPathProblem(path) {
1442
+ if (!path) return "is empty";
1443
+ if (path.length > INLINE_LIMITS.pathChars)
1444
+ return `is longer than ${INLINE_LIMITS.pathChars} characters`;
1445
+ if (path.includes("\\")) return "uses a backslash: write paths with forward slashes (src/app.js)";
1446
+ if (path.startsWith("/") || /^[a-z]:/i.test(path))
1447
+ return "is absolute: write it relative to the app root (index.html, src/app.js)";
1448
+ if (/[\u0000-\u001f]/.test(path)) return "has a control character";
1449
+ for (const part of path.split("/")) {
1450
+ if (part === "" || part === ".") return 'has an empty or "." segment';
1451
+ if (part === "..") return 'climbs out of the app with ".."';
1452
+ if (isEnvFile(part))
1453
+ return "is an env file, which is never deployed: set secrets with a console link (vibiz_request_secret) instead";
1454
+ if (isSecretFile(part))
1455
+ return "looks like a credential (a private key or a token file), which is never deployed";
1456
+ if (PRIVATE_DIRS.includes(part)) return `is inside ${part}, a home or config folder`;
1457
+ if (IGNORED.has(part))
1458
+ return part === "vibiz.json" ? "is vibiz.json, the local link to the project, which is never deployed" : `is inside ${part}, which is never deployed (dependencies, VCS data or build output: Vibiz installs and builds the app itself)`;
1459
+ }
1460
+ return null;
1461
+ }
1462
+ function normalizeDeployPath(path, field = "path") {
1463
+ const clean = path.replace(/^(\.\/)+/, "");
1464
+ const problem = deployPathProblem(clean);
1465
+ if (problem)
1466
+ invalid(`The ${field} ${JSON.stringify(path.slice(0, 200))} ${problem}.`, {
1467
+ issues: [{ path: field, message: problem }]
1468
+ });
1469
+ return clean;
1470
+ }
1471
+ function decode(f, i) {
1472
+ const where = `files[${i}] (${f.path})`;
1473
+ if (typeof f.content !== "string") invalid(`${where} has no content: pass content as a string.`);
1474
+ if (f.encoding === "base64") {
1475
+ const b64 = f.content.replace(/\s+/g, "");
1476
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(b64) || b64.length % 4 === 1)
1477
+ invalid(
1478
+ `${where} is not valid base64: send it as base64 without a data: prefix, or as utf8 text.`
1479
+ );
1480
+ return new Uint8Array(Buffer.from(b64, "base64"));
1481
+ }
1482
+ return new Uint8Array(Buffer.from(f.content, "utf8"));
1483
+ }
1484
+ async function deployFiles(vibiz, projectId, files, opts = {}) {
1485
+ const deletedIn = opts.deleted ?? [];
1486
+ if (!files.length && !deletedIn.length)
1487
+ invalid("Nothing to deploy: pass files [{ path, content }] (and deleted, to remove some).");
1488
+ if (files.length > INLINE_LIMITS.files)
1489
+ invalid(
1490
+ `${files.length} files is more than the ${INLINE_LIMITS.files} one call can carry. Send only the files that changed (the live deployment is the base), or split them over several calls with base set to the previous deployment's id. ${BIG_APP}.`,
1491
+ { limit: INLINE_LIMITS.files }
1492
+ );
1493
+ const incoming = /* @__PURE__ */ new Map();
1494
+ let totalBytes = 0;
1495
+ files.forEach((f, i) => {
1496
+ const path = normalizeDeployPath(f.path, `files[${i}].path`);
1497
+ if (incoming.has(path)) invalid(`${path} is in files twice: send each path once.`);
1498
+ const bytes = decode(f, i);
1499
+ if (bytes.byteLength > INLINE_LIMITS.fileBytes)
1500
+ invalid(
1501
+ `${path} is ${(bytes.byteLength / 1048576).toFixed(1)} MiB, over the ${INLINE_LIMITS.fileBytes / 1048576} MiB a file can be in one call. Host big media in the project's Files (vibiz_files import) and link to it. ${BIG_APP}.`,
1502
+ { path, limit_bytes: INLINE_LIMITS.fileBytes }
1503
+ );
1504
+ totalBytes += bytes.byteLength;
1505
+ incoming.set(path, { bytes, sha: createHash("sha1").update(bytes).digest("hex") });
1506
+ });
1507
+ if (totalBytes > INLINE_LIMITS.totalBytes)
1508
+ invalid(
1509
+ `These files add up to ${(totalBytes / 1048576).toFixed(1)} MiB, over the ${INLINE_LIMITS.totalBytes / 1048576} MiB one call can carry. Split them over several calls (each with base set to the previous deployment's id), or move big media to the project's Files. ${BIG_APP}.`,
1510
+ { limit_bytes: INLINE_LIMITS.totalBytes }
1511
+ );
1512
+ const toDelete = /* @__PURE__ */ new Set();
1513
+ for (const [i, p] of deletedIn.entries()) {
1514
+ const path = normalizeDeployPath(p, `deleted[${i}]`);
1515
+ if (incoming.has(path)) invalid(`${path} is both in files and in deleted: pick one.`);
1516
+ toDelete.add(path);
1517
+ }
1518
+ let baseId = null;
1519
+ const choice = opts.base ?? "live";
1520
+ if (choice === "live") {
1521
+ const project = await vibiz.projects.get(projectId);
1522
+ baseId = project.production_deployment_id;
1523
+ if (!baseId && opts.base === "live")
1524
+ invalid(
1525
+ `${projectId} has nothing live yet, so there is no base to edit: send every file of the app with base "none".`
1526
+ );
1527
+ } else if (choice !== "none") {
1528
+ baseId = choice;
1529
+ }
1530
+ let baseFiles = [];
1531
+ if (baseId) {
1532
+ const listed = await vibiz.deployments.files(baseId);
1533
+ if (listed.project_id !== projectId)
1534
+ invalid(
1535
+ `The base ${baseId} belongs to another project (${listed.project_id}): pass a deployment of ${projectId}.`
1536
+ );
1537
+ baseFiles = listed.data;
1538
+ }
1539
+ const manifest = new Map(baseFiles.map((f) => [f.path, f]));
1540
+ const missingDeletes = [...toDelete].filter((p) => !manifest.has(p));
1541
+ if (missingDeletes.length)
1542
+ invalid(
1543
+ `deleted names ${missingDeletes.join(", ")}, which ${missingDeletes.length > 1 ? "are" : "is"} not in ${baseId ? `the base deployment ${baseId}` : "the deployment (there is no base)"}. List its files with vibiz_code list.`,
1544
+ { missing: missingDeletes }
1545
+ );
1546
+ const added = [];
1547
+ const updated = [];
1548
+ for (const p of toDelete) manifest.delete(p);
1549
+ for (const [path, f] of incoming) {
1550
+ const before = manifest.get(path);
1551
+ if (!before) added.push(path);
1552
+ else if (before.sha !== f.sha) updated.push(path);
1553
+ manifest.set(path, { path, sha: f.sha, size: f.bytes.byteLength });
1554
+ }
1555
+ const all = [...manifest.values()].sort((a, b) => a.path.localeCompare(b.path));
1556
+ if (all.length === 0)
1557
+ invalid("That would deploy no files at all: keep at least one (an index.html for a site).");
1558
+ if (baseId && !added.length && !updated.length && !toDelete.size) {
1559
+ return {
1560
+ deployment: await vibiz.deployments.get(baseId),
1561
+ base: baseId,
1562
+ unchanged: true,
1563
+ uploaded: 0,
1564
+ total: all.length,
1565
+ added,
1566
+ updated,
1567
+ deleted: []
1568
+ };
1569
+ }
1570
+ const missing = new Set(await vibiz.files.missing([...incoming.values()].map((f) => f.sha)));
1571
+ const uploaded = /* @__PURE__ */ new Set();
1572
+ for (const f of incoming.values()) {
1573
+ if (!missing.has(f.sha) || uploaded.has(f.sha)) continue;
1574
+ await vibiz.files.upload(f.sha, f.bytes);
1575
+ uploaded.add(f.sha);
1576
+ }
1577
+ const { deployment } = await vibiz.deployments.create(projectId, {
1578
+ files: all,
1579
+ target: opts.target ?? "production"
1580
+ });
1581
+ return {
1582
+ deployment,
1583
+ base: baseId,
1584
+ unchanged: false,
1585
+ uploaded: uploaded.size,
1586
+ total: all.length,
1587
+ added: added.sort(),
1588
+ updated: updated.sort(),
1589
+ deleted: [...toDelete].sort()
1590
+ };
1591
+ }
1378
1592
 
1379
1593
  // packages/sdk/src/env.ts
1380
1594
  import { chmod, readFile as readFile2, writeFile } from "node:fs/promises";
@@ -1445,15 +1659,34 @@ function formatUnits(units) {
1445
1659
  }
1446
1660
  return parts.join(" \xB7 ") || "\u2013";
1447
1661
  }
1662
+
1663
+ // packages/sdk/src/one-key.ts
1664
+ var APP_SDK_VERSION = "0.2.3";
1665
+ var ONE_KEY_GIVES = "database, sign-in, email and inbox, AI models, files, payments, analytics with session replays, web data, social and connectors";
1666
+ function oneKeyMessage(url, host) {
1667
+ const where = host ?? "your host";
1668
+ 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.`;
1669
+ }
1670
+ function connectHostMessage(kind, host) {
1671
+ return `Or connect ${host ?? "the host"} once (vibiz hosts add ${kind ?? "<host>"} <app>) and Vibiz keeps every variable in sync.`;
1672
+ }
1448
1673
  export {
1674
+ APP_SDK_VERSION,
1675
+ INLINE_LIMITS,
1676
+ ONE_KEY_GIVES,
1449
1677
  Vibiz,
1450
1678
  VibizApiError,
1451
1679
  assertDeployableRoot,
1452
1680
  collectFiles,
1681
+ connectHostMessage,
1453
1682
  deployDirectory,
1683
+ deployFiles,
1684
+ deployPathProblem,
1454
1685
  endUserHeader,
1455
1686
  formatUnits,
1456
1687
  formatUsd,
1457
1688
  mergeEnvFile,
1689
+ normalizeDeployPath,
1690
+ oneKeyMessage,
1458
1691
  writeEnvFile
1459
1692
  };
@@ -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.3";
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
  /**
@@ -146,6 +152,8 @@ export interface DomainQuote {
146
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;
155
+ /** A Limited key: the console page that gives it full access. */
156
+ key_url?: string;
149
157
  next_step: string;
150
158
  }
151
159
  /** The legal registrant domains are registered to, saved once per account. */
@@ -174,11 +182,28 @@ export interface DomainOwnerDetails {
174
182
  applies_to: 'new_domains';
175
183
  console_url: string;
176
184
  }
185
+ /** One name of a bought domain in use on one project. */
186
+ export interface OwnedDomainUse {
187
+ project_id: string;
188
+ project_name: string;
189
+ project_slug: string;
190
+ /** The domain itself or a name under it (`app.example.com`). */
191
+ name: string;
192
+ hosting: 'vibiz' | 'elsewhere';
193
+ www_redirect: string | null;
194
+ console_url: string;
195
+ }
177
196
  export interface OwnedDomain {
178
197
  object: 'owned_domain';
179
198
  id: string;
180
199
  domain: string;
200
+ /** The project the domain itself (the apex) serves on, if any. */
181
201
  project_id: string | null;
202
+ /**
203
+ * Every project using it, the domain or any name under it. A bought domain
204
+ * works on any of the account's projects with no DNS to set (`use`).
205
+ */
206
+ used_on: OwnedDomainUse[];
182
207
  /** `registering` until the registry confirms; `failed`: refunded. */
183
208
  status: 'registering' | 'active' | 'expired' | 'failed';
184
209
  /** Renewed from credits about 30 days before `expires_at`. */
@@ -433,6 +458,30 @@ export interface InboxSettings {
433
458
  digest: boolean;
434
459
  console_url: string;
435
460
  }
461
+ /** `use` / `move`: a bought domain on a project, with no DNS to set. */
462
+ export interface DomainUse {
463
+ object: 'domain_use';
464
+ domain: string;
465
+ /** The full name now on the project (`app.example.com`, or the domain itself). */
466
+ name: string;
467
+ project_id: string;
468
+ /** Set by `move`: where it was before. */
469
+ moved_from: {
470
+ project_id: string;
471
+ project_name: string;
472
+ } | null;
473
+ project_domain: Domain | null;
474
+ owned: OwnedDomain;
475
+ next_step: string;
476
+ }
477
+ export interface DomainUseInput {
478
+ /** The domain itself (default), a prefix (`app`) or a full name under it (`app.example.com`). */
479
+ name?: string;
480
+ /** Defaults to `vibiz` when the project has Vibiz hosting, else `elsewhere`. */
481
+ hosting?: 'vibiz' | 'elsewhere';
482
+ /** An app on another host: its address (host name or IP); we write the record. */
483
+ points_to?: string | null;
484
+ }
436
485
  export interface DomainBuyInput {
437
486
  domain: string;
438
487
  years?: number;
@@ -461,6 +510,33 @@ export interface Deployment {
461
510
  created_at: string;
462
511
  ready_at: string | null;
463
512
  }
513
+ /** `GET /v1/deployments/:id/files`: the deployment's code as deployed. */
514
+ export interface DeploymentFiles {
515
+ object: 'list';
516
+ deployment_id: string;
517
+ project_id: string;
518
+ target: 'preview' | 'production';
519
+ data: DeployFile[];
520
+ }
521
+ /** `POST /v1/projects/:id/secret-link`: where a person types one secret. */
522
+ export interface SecretLink {
523
+ object: 'secret_link';
524
+ project_id: string;
525
+ name: string;
526
+ environment: 'production' | 'development';
527
+ kind: 'env' | 'connector' | 'ai' | 'host';
528
+ /** kind env: whether that variable already has a value (saving replaces it). */
529
+ set?: boolean;
530
+ console_url: string;
531
+ }
532
+ /** One of the app's own variables: never its value (write-only). */
533
+ export interface EnvVarInfo {
534
+ object: 'env_var';
535
+ name: string;
536
+ environment: 'production' | 'development';
537
+ set: true;
538
+ updated_at: string;
539
+ }
464
540
  export interface Operation {
465
541
  id: string;
466
542
  object: 'operation';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibiz/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
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",