@vibiz/sdk 0.2.2 → 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 +31 -1
- package/dist/deploy.d.ts +52 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +198 -1
- package/dist/one-key.d.ts +1 -1
- package/dist/types.d.ts +29 -0
- package/package.json +1 -1
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, 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';
|
|
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;
|
package/dist/deploy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
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,5 @@
|
|
|
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
5
|
export { APP_SDK_VERSION, connectHostMessage, ONE_KEY_GIVES, oneKeyMessage, } from './one-key.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" }
|
|
@@ -1396,6 +1428,167 @@ async function deployDirectory(vibiz, projectId, root, opts = {}) {
|
|
|
1396
1428
|
});
|
|
1397
1429
|
return { deployment, uploaded: uploadedShas.size, total: files.length };
|
|
1398
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
|
+
}
|
|
1399
1592
|
|
|
1400
1593
|
// packages/sdk/src/env.ts
|
|
1401
1594
|
import { chmod, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
@@ -1468,7 +1661,7 @@ function formatUnits(units) {
|
|
|
1468
1661
|
}
|
|
1469
1662
|
|
|
1470
1663
|
// packages/sdk/src/one-key.ts
|
|
1471
|
-
var APP_SDK_VERSION = "0.2.
|
|
1664
|
+
var APP_SDK_VERSION = "0.2.3";
|
|
1472
1665
|
var ONE_KEY_GIVES = "database, sign-in, email and inbox, AI models, files, payments, analytics with session replays, web data, social and connectors";
|
|
1473
1666
|
function oneKeyMessage(url, host) {
|
|
1474
1667
|
const where = host ?? "your host";
|
|
@@ -1479,6 +1672,7 @@ function connectHostMessage(kind, host) {
|
|
|
1479
1672
|
}
|
|
1480
1673
|
export {
|
|
1481
1674
|
APP_SDK_VERSION,
|
|
1675
|
+
INLINE_LIMITS,
|
|
1482
1676
|
ONE_KEY_GIVES,
|
|
1483
1677
|
Vibiz,
|
|
1484
1678
|
VibizApiError,
|
|
@@ -1486,10 +1680,13 @@ export {
|
|
|
1486
1680
|
collectFiles,
|
|
1487
1681
|
connectHostMessage,
|
|
1488
1682
|
deployDirectory,
|
|
1683
|
+
deployFiles,
|
|
1684
|
+
deployPathProblem,
|
|
1489
1685
|
endUserHeader,
|
|
1490
1686
|
formatUnits,
|
|
1491
1687
|
formatUsd,
|
|
1492
1688
|
mergeEnvFile,
|
|
1689
|
+
normalizeDeployPath,
|
|
1493
1690
|
oneKeyMessage,
|
|
1494
1691
|
writeEnvFile
|
|
1495
1692
|
};
|
package/dist/one-key.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* (`npm install --save-exact @vibiz/app@<this>`). A test keeps it, the skills
|
|
11
11
|
* and the docs equal to packages/app/package.json.
|
|
12
12
|
*/
|
|
13
|
-
export declare const APP_SDK_VERSION = "0.2.
|
|
13
|
+
export declare const APP_SDK_VERSION = "0.2.3";
|
|
14
14
|
/** Everything one app key reaches. */
|
|
15
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
16
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -152,6 +152,8 @@ export interface DomainQuote {
|
|
|
152
152
|
/** This key may buy it directly (a Limited key: the owner allowed agents, up to `agent_limit_cents`). */
|
|
153
153
|
can_buy?: boolean;
|
|
154
154
|
agent_limit_cents?: number | null;
|
|
155
|
+
/** A Limited key: the console page that gives it full access. */
|
|
156
|
+
key_url?: string;
|
|
155
157
|
next_step: string;
|
|
156
158
|
}
|
|
157
159
|
/** The legal registrant domains are registered to, saved once per account. */
|
|
@@ -508,6 +510,33 @@ export interface Deployment {
|
|
|
508
510
|
created_at: string;
|
|
509
511
|
ready_at: string | null;
|
|
510
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
|
+
}
|
|
511
540
|
export interface Operation {
|
|
512
541
|
id: string;
|
|
513
542
|
object: 'operation';
|