clefbase 1.5.3 → 2.0.1
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/ai.d.ts +369 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +308 -0
- package/dist/ai.js.map +1 -0
- package/dist/app.d.ts +40 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +48 -3
- package/dist/app.js.map +1 -1
- package/dist/cli-src/cli/api.js +14 -14
- package/dist/cli-src/cli/commands/deploy.js +84 -16
- package/dist/cli-src/cli/commands/init.js +616 -18
- package/dist/cli-src/cli/config.js +0 -1
- package/dist/cli-src/cli/index.js +48 -9
- package/dist/cli.js +728 -57
- package/dist/hosting/index.d.ts +8 -98
- package/dist/hosting/index.d.ts.map +1 -1
- package/dist/hosting/index.js +37 -95
- package/dist/hosting/index.js.map +1 -1
- package/dist/index.d.ts +74 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -37
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/hosting/index.d.ts
CHANGED
|
@@ -5,17 +5,12 @@ export interface HostingSite {
|
|
|
5
5
|
id: string;
|
|
6
6
|
dbId: string;
|
|
7
7
|
name: string;
|
|
8
|
-
/** URL-safe slug — globally unique, used for the preview subdomain */
|
|
9
8
|
slug: string;
|
|
10
9
|
description?: string;
|
|
11
10
|
status: HostingStatus;
|
|
12
|
-
/** Auto-provisioned: {slug}.preview.cleforyx.com */
|
|
13
11
|
previewUrl: string;
|
|
14
|
-
/** Optional custom domain the user has configured */
|
|
15
12
|
customDomain?: string;
|
|
16
|
-
/** Cloudflare DNS record ID for the preview subdomain */
|
|
17
13
|
dnsRecordId?: string;
|
|
18
|
-
/** Non-fatal DNS warning set on creation if Cloudflare provisioning failed */
|
|
19
14
|
dnsWarning?: string;
|
|
20
15
|
createdAt: string;
|
|
21
16
|
updatedAt: string;
|
|
@@ -62,40 +57,13 @@ export interface DeployOptions {
|
|
|
62
57
|
/** Called after each batch with progress info. */
|
|
63
58
|
onProgress?: (uploaded: number, total: number) => void;
|
|
64
59
|
}
|
|
65
|
-
export interface DnsStatus {
|
|
66
|
-
preview: {
|
|
67
|
-
exists: boolean;
|
|
68
|
-
isCorrect: boolean;
|
|
69
|
-
isConflict: boolean;
|
|
70
|
-
message: string;
|
|
71
|
-
record?: {
|
|
72
|
-
name: string;
|
|
73
|
-
type: string;
|
|
74
|
-
content: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
customDomain?: {
|
|
78
|
-
domain: string;
|
|
79
|
-
cnameOk: boolean;
|
|
80
|
-
cnameTarget?: string;
|
|
81
|
-
conflict: boolean;
|
|
82
|
-
instructions: {
|
|
83
|
-
type: string;
|
|
84
|
-
name: string;
|
|
85
|
-
content: string;
|
|
86
|
-
note: string;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
previewUrl: string;
|
|
90
|
-
}
|
|
91
60
|
/**
|
|
92
|
-
* A reference to a hosted site.
|
|
61
|
+
* A reference to a hosted site obtained via `hosting.site(siteId)`.
|
|
93
62
|
*
|
|
94
63
|
* @example
|
|
95
64
|
* const site = hosting.site("my-site-id");
|
|
96
|
-
* const result = await site.deployFiles({ "index.html": htmlBuffer
|
|
65
|
+
* const result = await site.deployFiles({ "index.html": htmlBuffer });
|
|
97
66
|
* console.log(`Live at ${result.url}`);
|
|
98
|
-
* console.log(`Preview at ${result.previewUrl}`);
|
|
99
67
|
*/
|
|
100
68
|
export declare class SiteReference {
|
|
101
69
|
private readonly hosting;
|
|
@@ -109,11 +77,8 @@ export declare class SiteReference {
|
|
|
109
77
|
listDeploys(): Promise<HostingDeploy[]>;
|
|
110
78
|
/**
|
|
111
79
|
* Deploy a map of { "filePath": Buffer } to this site.
|
|
112
|
-
* Creates a deploy, uploads all files in batches, then goes live.
|
|
113
80
|
*
|
|
114
81
|
* @example
|
|
115
|
-
* import fs from "fs";
|
|
116
|
-
*
|
|
117
82
|
* const result = await site.deployFiles({
|
|
118
83
|
* "index.html": fs.readFileSync("dist/index.html"),
|
|
119
84
|
* "app.js": fs.readFileSync("dist/app.js"),
|
|
@@ -124,83 +89,28 @@ export declare class SiteReference {
|
|
|
124
89
|
* console.log(`Live at ${result.url}`);
|
|
125
90
|
*/
|
|
126
91
|
deployFiles(files: Record<string, Buffer>, opts?: DeployOptions): Promise<DeployResult>;
|
|
127
|
-
/** Check the DNS status of this site's preview + custom domains. */
|
|
128
|
-
getDnsStatus(): Promise<DnsStatus>;
|
|
129
|
-
/** Re-provision the preview DNS record (e.g. if it was accidentally deleted). */
|
|
130
|
-
reprovisionDns(): Promise<{
|
|
131
|
-
subdomain: string;
|
|
132
|
-
url: string;
|
|
133
|
-
created: boolean;
|
|
134
|
-
}>;
|
|
135
|
-
/** The preview URL for this site ({slug}.preview.cleforyx.com). */
|
|
136
|
-
get previewUrl(): string;
|
|
137
|
-
/**
|
|
138
|
-
* The public URL — custom domain if configured, else preview subdomain.
|
|
139
|
-
* Requires the site metadata; use `(await site.get())?.customDomain` to check.
|
|
140
|
-
*/
|
|
141
|
-
get url(): string;
|
|
142
92
|
}
|
|
143
93
|
/**
|
|
144
|
-
* Hosting service
|
|
94
|
+
* Hosting service — obtained via `getHosting(app)`.
|
|
145
95
|
*
|
|
146
96
|
* @example
|
|
147
97
|
* const hosting = getHosting(app);
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* const site = await hosting.createSite("my-app");
|
|
151
|
-
* console.log(site.previewUrl); // https://my-app.preview.cleforyx.com
|
|
152
|
-
*
|
|
153
|
-
* // Deploy files
|
|
154
|
-
* const result = await hosting.site(site.id).deployFiles(files);
|
|
98
|
+
* const sites = await hosting.listSites();
|
|
99
|
+
* const result = await hosting.site(sites[0].id).deployFiles(files);
|
|
155
100
|
* console.log(result.url);
|
|
156
101
|
*/
|
|
157
102
|
export declare class ClefbaseHosting {
|
|
158
103
|
private readonly http;
|
|
159
|
-
|
|
160
|
-
private readonly serverUrl;
|
|
161
|
-
constructor(http: HttpClient, dbId: string, serverUrl: string);
|
|
104
|
+
constructor(http: HttpClient);
|
|
162
105
|
/** List all sites for this project. */
|
|
163
106
|
listSites(): Promise<HostingSite[]>;
|
|
164
|
-
/**
|
|
165
|
-
|
|
166
|
-
*
|
|
167
|
-
* Site names must be globally unique across the platform.
|
|
168
|
-
* A CNAME record will be automatically provisioned on Cloudflare:
|
|
169
|
-
* {slug}.preview.cleforyx.com → cleforyx.com
|
|
170
|
-
*
|
|
171
|
-
* Throws a 409 ConflictError if the name is already taken.
|
|
172
|
-
*/
|
|
173
|
-
createSite(name: string, description?: string): Promise<HostingSite>;
|
|
174
|
-
/** Update site metadata. Handles DNS rename if name changes. */
|
|
175
|
-
updateSite(siteId: string, patch: Partial<Pick<HostingSite, "name" | "description" | "status" | "customDomain">>): Promise<HostingSite>;
|
|
176
|
-
/**
|
|
177
|
-
* Begin site deletion flow.
|
|
178
|
-
*
|
|
179
|
-
* Pass `confirm: false` (or omit) to get a confirmation prompt with DNS info.
|
|
180
|
-
* Pass `confirm: true` to actually delete. Include `deleteDns: true` to also
|
|
181
|
-
* remove the Cloudflare DNS record.
|
|
182
|
-
*/
|
|
183
|
-
deleteSite(siteId: string, opts?: {
|
|
184
|
-
confirm?: boolean;
|
|
185
|
-
deleteDns?: boolean;
|
|
186
|
-
}): Promise<{
|
|
187
|
-
requiresConfirmation?: boolean;
|
|
188
|
-
dnsRecord?: object;
|
|
189
|
-
message: string;
|
|
190
|
-
deleted?: boolean;
|
|
191
|
-
}>;
|
|
107
|
+
/** Get a single site by ID. Returns null if not found. */
|
|
108
|
+
getSite(siteId: string): Promise<HostingSite | null>;
|
|
192
109
|
/** Return a SiteReference for a specific site ID. */
|
|
193
110
|
site(siteId: string): SiteReference;
|
|
194
|
-
_previewUrl(siteId: string): string;
|
|
195
111
|
_getSite(siteId: string): Promise<HostingSite | null>;
|
|
196
112
|
_getActiveDeploy(siteId: string): Promise<HostingDeploy | null>;
|
|
197
113
|
_listDeploys(siteId: string): Promise<HostingDeploy[]>;
|
|
198
|
-
_getDnsStatus(siteId: string): Promise<DnsStatus>;
|
|
199
|
-
_reprovisionDns(siteId: string): Promise<{
|
|
200
|
-
subdomain: string;
|
|
201
|
-
url: string;
|
|
202
|
-
created: boolean;
|
|
203
|
-
}>;
|
|
204
114
|
_deployFiles(siteId: string, files: Record<string, Buffer>, opts?: DeployOptions): Promise<DeployResult>;
|
|
205
115
|
}
|
|
206
116
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,YAAY,GAAI,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,YAAY,GAAI,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE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AC;IAItD,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,YAAY,CAAC;CA+FzB"}
|
package/dist/hosting/index.js
CHANGED
|
@@ -36,13 +36,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.ClefbaseHosting = exports.SiteReference = void 0;
|
|
37
37
|
// ─── SiteReference ────────────────────────────────────────────────────────────
|
|
38
38
|
/**
|
|
39
|
-
* A reference to a hosted site.
|
|
39
|
+
* A reference to a hosted site obtained via `hosting.site(siteId)`.
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* const site = hosting.site("my-site-id");
|
|
43
|
-
* const result = await site.deployFiles({ "index.html": htmlBuffer
|
|
43
|
+
* const result = await site.deployFiles({ "index.html": htmlBuffer });
|
|
44
44
|
* console.log(`Live at ${result.url}`);
|
|
45
|
-
* console.log(`Preview at ${result.previewUrl}`);
|
|
46
45
|
*/
|
|
47
46
|
class SiteReference {
|
|
48
47
|
constructor(hosting, siteId) {
|
|
@@ -63,11 +62,8 @@ class SiteReference {
|
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* Deploy a map of { "filePath": Buffer } to this site.
|
|
66
|
-
* Creates a deploy, uploads all files in batches, then goes live.
|
|
67
65
|
*
|
|
68
66
|
* @example
|
|
69
|
-
* import fs from "fs";
|
|
70
|
-
*
|
|
71
67
|
* const result = await site.deployFiles({
|
|
72
68
|
* "index.html": fs.readFileSync("dist/index.html"),
|
|
73
69
|
* "app.js": fs.readFileSync("dist/app.js"),
|
|
@@ -80,96 +76,38 @@ class SiteReference {
|
|
|
80
76
|
async deployFiles(files, opts) {
|
|
81
77
|
return this.hosting._deployFiles(this.siteId, files, opts);
|
|
82
78
|
}
|
|
83
|
-
/** Check the DNS status of this site's preview + custom domains. */
|
|
84
|
-
async getDnsStatus() {
|
|
85
|
-
return this.hosting._getDnsStatus(this.siteId);
|
|
86
|
-
}
|
|
87
|
-
/** Re-provision the preview DNS record (e.g. if it was accidentally deleted). */
|
|
88
|
-
async reprovisionDns() {
|
|
89
|
-
return this.hosting._reprovisionDns(this.siteId);
|
|
90
|
-
}
|
|
91
|
-
/** The preview URL for this site ({slug}.preview.cleforyx.com). */
|
|
92
|
-
get previewUrl() {
|
|
93
|
-
return this.hosting._previewUrl(this.siteId);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The public URL — custom domain if configured, else preview subdomain.
|
|
97
|
-
* Requires the site metadata; use `(await site.get())?.customDomain` to check.
|
|
98
|
-
*/
|
|
99
|
-
get url() {
|
|
100
|
-
return this.previewUrl; // SDK doesn't cache site; use DeployResult.url for canonical
|
|
101
|
-
}
|
|
102
79
|
}
|
|
103
80
|
exports.SiteReference = SiteReference;
|
|
104
81
|
// ─── ClefbaseHosting ──────────────────────────────────────────────────────────
|
|
105
82
|
/**
|
|
106
|
-
* Hosting service
|
|
83
|
+
* Hosting service — obtained via `getHosting(app)`.
|
|
107
84
|
*
|
|
108
85
|
* @example
|
|
109
86
|
* const hosting = getHosting(app);
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* const site = await hosting.createSite("my-app");
|
|
113
|
-
* console.log(site.previewUrl); // https://my-app.preview.cleforyx.com
|
|
114
|
-
*
|
|
115
|
-
* // Deploy files
|
|
116
|
-
* const result = await hosting.site(site.id).deployFiles(files);
|
|
87
|
+
* const sites = await hosting.listSites();
|
|
88
|
+
* const result = await hosting.site(sites[0].id).deployFiles(files);
|
|
117
89
|
* console.log(result.url);
|
|
118
90
|
*/
|
|
119
91
|
class ClefbaseHosting {
|
|
120
|
-
constructor(http
|
|
92
|
+
constructor(http) {
|
|
121
93
|
this.http = http;
|
|
122
|
-
this.dbId = dbId;
|
|
123
|
-
this.serverUrl = serverUrl;
|
|
124
94
|
}
|
|
125
95
|
/** List all sites for this project. */
|
|
126
96
|
async listSites() {
|
|
127
|
-
return this.http.get(
|
|
97
|
+
return this.http.get("/sites");
|
|
128
98
|
}
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
* Site names must be globally unique across the platform.
|
|
133
|
-
* A CNAME record will be automatically provisioned on Cloudflare:
|
|
134
|
-
* {slug}.preview.cleforyx.com → cleforyx.com
|
|
135
|
-
*
|
|
136
|
-
* Throws a 409 ConflictError if the name is already taken.
|
|
137
|
-
*/
|
|
138
|
-
async createSite(name, description) {
|
|
139
|
-
return this.http.post(`/databases/${this.dbId}/sites`, { name, description });
|
|
140
|
-
}
|
|
141
|
-
/** Update site metadata. Handles DNS rename if name changes. */
|
|
142
|
-
async updateSite(siteId, patch) {
|
|
143
|
-
return this.http.patch(`/databases/${this.dbId}/sites/${siteId}`, patch);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Begin site deletion flow.
|
|
147
|
-
*
|
|
148
|
-
* Pass `confirm: false` (or omit) to get a confirmation prompt with DNS info.
|
|
149
|
-
* Pass `confirm: true` to actually delete. Include `deleteDns: true` to also
|
|
150
|
-
* remove the Cloudflare DNS record.
|
|
151
|
-
*/
|
|
152
|
-
async deleteSite(siteId, opts) {
|
|
153
|
-
const params = new URLSearchParams();
|
|
154
|
-
if (opts?.confirm)
|
|
155
|
-
params.set("confirm", "true");
|
|
156
|
-
if (opts?.deleteDns)
|
|
157
|
-
params.set("deleteDns", "true");
|
|
158
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
159
|
-
return this.http.delete(`/databases/${this.dbId}/sites/${siteId}${qs}`);
|
|
99
|
+
/** Get a single site by ID. Returns null if not found. */
|
|
100
|
+
async getSite(siteId) {
|
|
101
|
+
return this._getSite(siteId);
|
|
160
102
|
}
|
|
161
103
|
/** Return a SiteReference for a specific site ID. */
|
|
162
104
|
site(siteId) {
|
|
163
105
|
return new SiteReference(this, siteId);
|
|
164
106
|
}
|
|
165
|
-
// ─── Internals
|
|
166
|
-
_previewUrl(siteId) {
|
|
167
|
-
// Falls back to server URL path if site metadata isn't cached
|
|
168
|
-
return `${this.serverUrl.replace(/\/+$/, "")}/hosted/${this.dbId}/${siteId}`;
|
|
169
|
-
}
|
|
107
|
+
// ─── Internals used by SiteReference ──────────────────────────────────────
|
|
170
108
|
async _getSite(siteId) {
|
|
171
109
|
try {
|
|
172
|
-
return await this.http.get(`/
|
|
110
|
+
return await this.http.get(`/sites/${siteId}`);
|
|
173
111
|
}
|
|
174
112
|
catch (err) {
|
|
175
113
|
if (err.status === 404)
|
|
@@ -179,7 +117,7 @@ class ClefbaseHosting {
|
|
|
179
117
|
}
|
|
180
118
|
async _getActiveDeploy(siteId) {
|
|
181
119
|
try {
|
|
182
|
-
const r = await this.http.get(`/
|
|
120
|
+
const r = await this.http.get(`/sites/${siteId}/active`);
|
|
183
121
|
return r.deploy;
|
|
184
122
|
}
|
|
185
123
|
catch (err) {
|
|
@@ -189,19 +127,13 @@ class ClefbaseHosting {
|
|
|
189
127
|
}
|
|
190
128
|
}
|
|
191
129
|
async _listDeploys(siteId) {
|
|
192
|
-
return this.http.get(`/
|
|
193
|
-
}
|
|
194
|
-
async _getDnsStatus(siteId) {
|
|
195
|
-
return this.http.get(`/databases/${this.dbId}/sites/${siteId}/dns`);
|
|
196
|
-
}
|
|
197
|
-
async _reprovisionDns(siteId) {
|
|
198
|
-
return this.http.post(`/databases/${this.dbId}/sites/${siteId}/dns/provision`, {});
|
|
130
|
+
return this.http.get(`/sites/${siteId}/deploys`);
|
|
199
131
|
}
|
|
200
132
|
async _deployFiles(siteId, files, opts = {}) {
|
|
201
133
|
const { entrypoint = "index.html", deployedBy, message, batchSize = 20, onProgress } = opts;
|
|
202
134
|
// 1. Create pending deploy
|
|
203
|
-
const pending = await this.http.post(`/
|
|
204
|
-
// 2.
|
|
135
|
+
const pending = await this.http.post(`/sites/${siteId}/deploys`, { deployedBy, entrypoint });
|
|
136
|
+
// 2. Fetch site for canonical URL — non-fatal
|
|
205
137
|
const siteData = await this._getSite(siteId).catch(() => null);
|
|
206
138
|
const filePaths = Object.keys(files);
|
|
207
139
|
const fileBuffers = Object.values(files);
|
|
@@ -220,27 +152,37 @@ class ClefbaseHosting {
|
|
|
220
152
|
const batchBuffers = fileBuffers.slice(i, i + batchSize);
|
|
221
153
|
try {
|
|
222
154
|
if (hasNativeFormData) {
|
|
155
|
+
// Native FormData (Node 18+ / browsers): the runtime sets Content-Type + boundary.
|
|
223
156
|
const form = new FormData();
|
|
224
157
|
for (let j = 0; j < batchPaths.length; j++) {
|
|
225
158
|
const filename = batchPaths[j].split("/").pop() ?? batchPaths[j];
|
|
226
159
|
const buf = batchBuffers[j];
|
|
227
160
|
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
228
|
-
|
|
229
|
-
form.append("files[]", new File([blob], filename, { type: "application/octet-stream" }));
|
|
161
|
+
form.append("files[]", new File([new Blob([ab])], filename, { type: "application/octet-stream" }));
|
|
230
162
|
form.append("filePaths", batchPaths[j]);
|
|
231
163
|
}
|
|
232
|
-
await this.http.request(`/
|
|
164
|
+
await this.http.request(`/deploys/${pending.id}/files/batch`, {
|
|
165
|
+
method: "POST",
|
|
166
|
+
body: form,
|
|
167
|
+
isFormData: true,
|
|
168
|
+
});
|
|
233
169
|
}
|
|
234
170
|
else {
|
|
171
|
+
// Legacy form-data npm package (Node < 18): must pass getHeaders() explicitly
|
|
172
|
+
// so HttpClient can include the multipart Content-Type + boundary header.
|
|
235
173
|
const form = new FormDataLegacy();
|
|
236
174
|
for (let j = 0; j < batchPaths.length; j++) {
|
|
237
|
-
form.append("files[]", batchBuffers[j], {
|
|
238
|
-
filename: batchPaths[j].split("/").pop() ?? batchPaths[j],
|
|
239
|
-
contentType: "application/octet-stream",
|
|
240
|
-
});
|
|
175
|
+
form.append("files[]", batchBuffers[j], { filename: batchPaths[j].split("/").pop() ?? batchPaths[j], contentType: "application/octet-stream" });
|
|
241
176
|
form.append("filePaths", batchPaths[j]);
|
|
242
177
|
}
|
|
243
|
-
|
|
178
|
+
// FIX: pass form.getHeaders() so the multipart boundary is sent to the server.
|
|
179
|
+
// Without this, the server receives no Content-Type header and rejects the upload.
|
|
180
|
+
await this.http.request(`/deploys/${pending.id}/files/batch`, {
|
|
181
|
+
method: "POST",
|
|
182
|
+
body: form,
|
|
183
|
+
isFormData: true,
|
|
184
|
+
headers: form.getHeaders(),
|
|
185
|
+
});
|
|
244
186
|
}
|
|
245
187
|
uploaded += batchPaths.length;
|
|
246
188
|
}
|
|
@@ -250,16 +192,16 @@ class ClefbaseHosting {
|
|
|
250
192
|
onProgress?.(Math.min(i + batchSize, filePaths.length), filePaths.length);
|
|
251
193
|
}
|
|
252
194
|
// 5. Finalize → go live
|
|
253
|
-
const live = await this.http.post(`/
|
|
195
|
+
const live = await this.http.post(`/deploys/${pending.id}/finalize`, { message: message ?? "Deployed via clefbase SDK" });
|
|
254
196
|
const canonicalUrl = siteData?.customDomain
|
|
255
197
|
? `https://${siteData.customDomain}`
|
|
256
|
-
: siteData?.previewUrl ??
|
|
198
|
+
: siteData?.previewUrl ?? "";
|
|
257
199
|
return {
|
|
258
200
|
deploy: live,
|
|
259
201
|
filesUploaded: uploaded,
|
|
260
202
|
errors,
|
|
261
203
|
url: canonicalUrl,
|
|
262
|
-
previewUrl: siteData?.previewUrl ??
|
|
204
|
+
previewUrl: siteData?.previewUrl ?? "",
|
|
263
205
|
};
|
|
264
206
|
}
|
|
265
207
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hosting/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,iFAAiF;AAEjF;;;;;;;GAOG;AACH,MAAa,aAAa;IACxB,YACmB,OAAwB,EACzB,MA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AAE,IAAI,CAAC,UAAU,EAAE;qBAC3B,CAAC,CAAC;gBACL,CAAC;gBACD,QAAQ,IAAI,UAAU,CAAC,MAAM,CAAC;YAChC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YACxE,CAAC;YAED,UAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC;QAED,wBAAwB;QACxB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAC/B,YAAY,OAAO,CAAC,EAAE,WAAW,EACjC,EAAE,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,CACpD,CAAC;QAEF,MAAM,YAAY,GAAG,QAAQ,EAAE,YAAY;YACzC,CAAC,CAAC,WAAW,QAAQ,CAAC,YAAY,EAAE;YACpC,CAAC,CAAC,QAAQ,EAAE,UAAU,IAAI,EAAE,CAAC;QAE/B,OAAO;YACL,MAAM,EAAS,IAAI;YACnB,aAAa,EAAE,QAAQ;YACvB,MAAM;YACN,GAAG,EAAY,YAAY;YAC3B,UAAU,EAAK,QAAQ,EAAE,UAAU,IAAI,EAAE;SAC1C,CAAC;IACJ,CAAC;CACF;AAhJD,0CAgJC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,58 +4,94 @@
|
|
|
4
4
|
* @example
|
|
5
5
|
* import {
|
|
6
6
|
* initClefbase, getDatabase, getAuth, getStorage, getHosting,
|
|
7
|
-
* getFunctions,
|
|
8
|
-
*
|
|
7
|
+
* getFunctions, getAI,
|
|
8
|
+
* httpsCallable, callFunction, deployFunction, deployFromFile,
|
|
9
|
+
* generateText, generateImage, generateVideo, generateEmbedding,
|
|
10
|
+
* setAuthToken, FunctionsError, AIError, FieldValue,
|
|
9
11
|
* } from "clefbase";
|
|
10
12
|
*
|
|
11
|
-
* const app
|
|
12
|
-
* const fns = getFunctions(app);
|
|
13
|
-
* const auth = getAuth(app);
|
|
13
|
+
* const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
|
|
14
14
|
*
|
|
15
|
-
* // ── Auth
|
|
15
|
+
* // ── Auth ──────────────────────────────────────────────────────────────────
|
|
16
|
+
* const auth = getAuth(app);
|
|
16
17
|
* const { token } = await auth.signIn("alice@example.com", "password123");
|
|
17
|
-
* setAuthToken(app, token); // ctx.auth.uid / email now available in function
|
|
18
18
|
*
|
|
19
|
-
* // ──
|
|
19
|
+
* // ── Database ──────────────────────────────────────────────────────────────
|
|
20
|
+
* const db = getDatabase(app);
|
|
21
|
+
* await db.collection("posts").doc("p1").update({
|
|
22
|
+
* views: FieldValue.increment(1),
|
|
23
|
+
* publishedAt: FieldValue.serverTimestamp(),
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // ── Storage ───────────────────────────────────────────────────────────────
|
|
27
|
+
* const storage = getStorage(app);
|
|
28
|
+
* const url = await storage.ref("avatars/user-123.jpg").getDownloadURL();
|
|
29
|
+
*
|
|
30
|
+
* // ── Functions ─────────────────────────────────────────────────────────────
|
|
31
|
+
* const fns = getFunctions(app);
|
|
20
32
|
* const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
|
|
21
33
|
* const { data } = await greet({ name: "Alice" });
|
|
22
34
|
*
|
|
23
|
-
* // ──
|
|
24
|
-
* const
|
|
35
|
+
* // ── AI — text / code ──────────────────────────────────────────────────────
|
|
36
|
+
* const ai = getAI(app);
|
|
25
37
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* runtime: "node",
|
|
30
|
-
* trigger: { type: "http" },
|
|
31
|
-
* source: `export async function handler(ctx) { return { message: "Hi " + ctx.data.name }; }`,
|
|
38
|
+
* const { content } = await ai.text({
|
|
39
|
+
* model: "claude-sonnet-4-5",
|
|
40
|
+
* prompt: "Explain async/await in JavaScript",
|
|
32
41
|
* });
|
|
33
42
|
*
|
|
34
|
-
* //
|
|
35
|
-
* await
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
43
|
+
* // Multi-turn chat
|
|
44
|
+
* const reply = await ai.text({
|
|
45
|
+
* model: "gemini-2.5-flash",
|
|
46
|
+
* prompt: "Give me a harder example",
|
|
47
|
+
* systemPrompt: "You are a JavaScript tutor.",
|
|
48
|
+
* history: [{ role: "user", content: "Explain closures" }, { role: "assistant", content: "..." }],
|
|
40
49
|
* });
|
|
41
50
|
*
|
|
42
|
-
* // ──
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* }
|
|
51
|
+
* // ── AI — image generation (auto-saved to Storage) ─────────────────────────
|
|
52
|
+
* const { files } = await ai.image({
|
|
53
|
+
* model: "imagen-4.0-generate-001",
|
|
54
|
+
* prompt: "A serene mountain lake at dawn, photorealistic",
|
|
55
|
+
* aspectRatio: "16:9",
|
|
56
|
+
* numberOfImages: 2,
|
|
57
|
+
* outputFolder: "landscapes",
|
|
58
|
+
* });
|
|
59
|
+
* // files[].fullPath → path in project Storage
|
|
60
|
+
* // files[].storageFileId → use with storage.ref() to get the download URL
|
|
50
61
|
*
|
|
51
|
-
* // ──
|
|
52
|
-
* const
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
62
|
+
* // ── AI — video generation (auto-saved to Storage) ─────────────────────────
|
|
63
|
+
* const { status, files: clips } = await ai.video({
|
|
64
|
+
* model: "veo-3.1-generate-preview",
|
|
65
|
+
* prompt: "A slow-motion waterfall in a rainforest",
|
|
66
|
+
* durationSeconds: 8,
|
|
67
|
+
* aspectRatio: "16:9",
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // ── AI — embeddings ───────────────────────────────────────────────────────
|
|
71
|
+
* const { embeddings } = await ai.embedding({
|
|
72
|
+
* model: "gemini-embedding-001",
|
|
73
|
+
* input: ["Hello world", "Semantic search"],
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // ── AI — browse models ────────────────────────────────────────────────────
|
|
77
|
+
* const imageModels = await ai.listModels({ category: "image" });
|
|
78
|
+
* const allModels = await ai.listModels();
|
|
79
|
+
*
|
|
80
|
+
* // ── AI — usage stats ──────────────────────────────────────────────────────
|
|
81
|
+
* const stats = await ai.getStats();
|
|
82
|
+
* const history = await ai.getUsage({ limit: 20 });
|
|
83
|
+
*
|
|
84
|
+
* // ── AI — convenience top-level functions ──────────────────────────────────
|
|
85
|
+
* const { content: code } = await generateText(ai, {
|
|
86
|
+
* model: "claude-sonnet-4-5",
|
|
87
|
+
* prompt: "Write a merge sort in TypeScript",
|
|
88
|
+
* });
|
|
89
|
+
* const { files: imgs } = await generateImage(ai, {
|
|
90
|
+
* model: "imagen-4.0-fast-generate-001",
|
|
91
|
+
* prompt: "A cute cartoon robot",
|
|
56
92
|
* });
|
|
57
93
|
*/
|
|
58
|
-
export { ClefbaseApp, initClefbase, getApp, getDatabase, getAuth, getStorage, getHosting, getFunctions, } from "./app";
|
|
94
|
+
export { ClefbaseApp, initClefbase, getApp, getDatabase, getAuth, getStorage, getHosting, getFunctions, getAI, } from "./app";
|
|
59
95
|
export { Database, CollectionReference, CollectionGroup, DocumentReference, Query, WriteBatch, Transaction, runTransaction, } from "./db";
|
|
60
96
|
export { Auth } from "./auth";
|
|
61
97
|
export type { GoogleButtonOptions } from "./auth";
|
|
@@ -67,6 +103,8 @@ export { ClefbaseHosting, SiteReference } from "./hosting";
|
|
|
67
103
|
export type { HostingSite, HostingDeploy, HostingFile, DeployResult, DeployOptions, HostingStatus, DeployStatus, } from "./hosting";
|
|
68
104
|
export { ClefbaseFunctions, FunctionsError, httpsCallable, callFunction, deployFunction, deleteFunction, listFunctions, getFunctionExecutions, setAuthToken, deployFromFile, } from "./functions";
|
|
69
105
|
export type { FunctionRuntime, FunctionTrigger, FunctionTriggerType, FunctionDef, FunctionExecution, FunctionsConfig, FunctionStats, DeployFunctionOptions, HttpsCallableResult, } from "./functions";
|
|
106
|
+
export { ClefbaseAI, AIError, generateText, generateImage, generateVideo, generateEmbedding, } from "./ai";
|
|
107
|
+
export type { AIModel, AIProvider, AIModelCategory, GenerateTextOptions, GenerateTextResult, GenerateImageOptions, GenerateImageResult, GeneratedMediaFile, GenerateVideoOptions, GenerateVideoResult, GenerateEmbeddingOptions, GenerateEmbeddingResult, AIUsageRecord, AIUsageStats, } from "./ai";
|
|
70
108
|
export { FieldValue, FieldValueSentinel } from "./field_value";
|
|
71
109
|
export type { FieldValueType } from "./field_value";
|
|
72
110
|
export type { ClefbaseConfig, ClefbaseDocument, QueryOptions, QueryResult, FilterOperator, WhereClause, WhereValue, AuthUser, AuthSession, AuthResult, } from "./types";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAGH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,MAAM,EACN,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,GACN,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,GACf,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EA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