@buildspacestudio/sdk 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +259 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/{server.d.ts → index.d.cts} +9 -6
- package/dist/auth/index.d.ts +118 -5
- package/dist/auth/index.js +255 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/client/index.cjs +428 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +85 -0
- package/dist/client/index.d.ts +8 -7
- package/dist/client/index.js +416 -105
- package/dist/client/index.js.map +1 -1
- package/dist/{auth/client.d.ts → client-BH7LbrKM.d.ts} +7 -5
- package/dist/client-C67hy1kt.d.cts +58 -0
- package/dist/{events/client.d.ts → client-Dlif1JBf.d.ts} +5 -3
- package/dist/{auth/client.js → client-DqWXAwCr.d.cts} +27 -30
- package/dist/events/index.cjs +131 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/{server.d.ts → index.d.cts} +7 -4
- package/dist/events/index.d.ts +59 -4
- package/dist/events/index.js +127 -2
- package/dist/events/index.js.map +1 -1
- package/dist/http-U-zzKmFF.d.cts +100 -0
- package/dist/http-U-zzKmFF.d.ts +100 -0
- package/dist/index.cjs +801 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +87 -0
- package/dist/index.d.ts +16 -15
- package/dist/index.js +785 -106
- package/dist/index.js.map +1 -1
- package/dist/notifications/index.cjs +56 -0
- package/dist/notifications/index.cjs.map +1 -0
- package/dist/notifications/{server.d.ts → index.d.cts} +8 -6
- package/dist/notifications/index.d.ts +79 -3
- package/dist/notifications/index.js +53 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/storage/index.cjs +213 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +195 -0
- package/dist/storage/index.d.ts +195 -5
- package/dist/storage/index.js +209 -2
- package/dist/storage/index.js.map +1 -1
- package/package.json +75 -16
- package/dist/auth/client.d.ts.map +0 -1
- package/dist/auth/client.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/server.d.ts.map +0 -1
- package/dist/auth/server.js +0 -148
- package/dist/auth/server.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/config.d.ts +0 -40
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -27
- package/dist/config.js.map +0 -1
- package/dist/errors.d.ts +0 -31
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -30
- package/dist/errors.js.map +0 -1
- package/dist/events/client.d.ts.map +0 -1
- package/dist/events/client.js +0 -97
- package/dist/events/client.js.map +0 -1
- package/dist/events/index.d.ts.map +0 -1
- package/dist/events/server.d.ts.map +0 -1
- package/dist/events/server.js +0 -65
- package/dist/events/server.js.map +0 -1
- package/dist/http.d.ts +0 -39
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -74
- package/dist/http.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/notifications/index.d.ts.map +0 -1
- package/dist/notifications/server.d.ts.map +0 -1
- package/dist/notifications/server.js +0 -73
- package/dist/notifications/server.js.map +0 -1
- package/dist/storage/client.d.ts +0 -91
- package/dist/storage/client.d.ts.map +0 -1
- package/dist/storage/client.js +0 -117
- package/dist/storage/client.js.map +0 -1
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/server.d.ts +0 -104
- package/dist/storage/server.d.ts.map +0 -1
- package/dist/storage/server.js +0 -104
- package/dist/storage/server.js.map +0 -1
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/auth/client.ts
|
|
4
|
+
var AuthClientNamespace = class {
|
|
5
|
+
transport;
|
|
6
|
+
constructor(transport) {
|
|
7
|
+
this.transport = transport;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Build a URL that redirects the user to the Buildspace sign-in page.
|
|
11
|
+
*
|
|
12
|
+
* After the user authenticates, they are redirected back to `redirectUri`
|
|
13
|
+
* with a `?code=` parameter that can be exchanged for tokens via
|
|
14
|
+
* `buildspace.auth.handleCallback()` on the server.
|
|
15
|
+
*
|
|
16
|
+
* @param opts - Sign-in URL options.
|
|
17
|
+
* @returns The full sign-in URL as a string.
|
|
18
|
+
*/
|
|
19
|
+
getSignInUrl(opts) {
|
|
20
|
+
const url = new URL("/sign-in", this.transport.loginUrl);
|
|
21
|
+
if (opts.appSlug) {
|
|
22
|
+
url.searchParams.set("app", opts.appSlug);
|
|
23
|
+
}
|
|
24
|
+
url.searchParams.set("redirect_uri", opts.redirectUri);
|
|
25
|
+
url.searchParams.set("client_id", this.transport.key);
|
|
26
|
+
if (opts.env) {
|
|
27
|
+
url.searchParams.set("env", opts.env);
|
|
28
|
+
}
|
|
29
|
+
return url.toString();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a URL that redirects the user to the Buildspace sign-up page.
|
|
33
|
+
*
|
|
34
|
+
* Works identically to {@link getSignInUrl} but directs the user to the
|
|
35
|
+
* registration flow instead.
|
|
36
|
+
*
|
|
37
|
+
* @param opts - Sign-up URL options.
|
|
38
|
+
* @returns The full sign-up URL as a string.
|
|
39
|
+
*/
|
|
40
|
+
getSignUpUrl(opts) {
|
|
41
|
+
const url = new URL("/sign-up", this.transport.loginUrl);
|
|
42
|
+
if (opts.appSlug) {
|
|
43
|
+
url.searchParams.set("app", opts.appSlug);
|
|
44
|
+
}
|
|
45
|
+
url.searchParams.set("redirect_uri", opts.redirectUri);
|
|
46
|
+
url.searchParams.set("client_id", this.transport.key);
|
|
47
|
+
if (opts.env) {
|
|
48
|
+
url.searchParams.set("env", opts.env);
|
|
49
|
+
}
|
|
50
|
+
return url.toString();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/errors.ts
|
|
55
|
+
var BuildspaceError = class extends Error {
|
|
56
|
+
/** Machine-readable error code, e.g. `"auth/invalid-token"`. */
|
|
57
|
+
code;
|
|
58
|
+
/** Which service produced the error. */
|
|
59
|
+
service;
|
|
60
|
+
/** HTTP status code from the API. */
|
|
61
|
+
status;
|
|
62
|
+
constructor({
|
|
63
|
+
code,
|
|
64
|
+
message,
|
|
65
|
+
service,
|
|
66
|
+
status
|
|
67
|
+
}) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.name = "BuildspaceError";
|
|
70
|
+
this.code = code;
|
|
71
|
+
this.service = service;
|
|
72
|
+
this.status = status;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/config.ts
|
|
77
|
+
var DEFAULT_BASE_URL = "https://api.buildspace.studio";
|
|
78
|
+
var DEFAULT_LOGIN_URL = "https://login.buildspace.studio";
|
|
79
|
+
var DEFAULT_API_VERSION = "2025-06-01";
|
|
80
|
+
function resolveConfig(mode, config = {}) {
|
|
81
|
+
return {
|
|
82
|
+
mode,
|
|
83
|
+
baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
|
|
84
|
+
loginUrl: config.loginUrl ?? DEFAULT_LOGIN_URL,
|
|
85
|
+
version: config.version ?? DEFAULT_API_VERSION,
|
|
86
|
+
fetch: config.fetch ?? fetch
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function formatMode(mode) {
|
|
90
|
+
return mode === "server" ? "server SDK" : "client SDK";
|
|
91
|
+
}
|
|
92
|
+
function validateApiKey({ mode, key }) {
|
|
93
|
+
if (!key) {
|
|
94
|
+
throw new Error(`Missing API key. The ${formatMode(mode)} requires a valid Buildspace key.`);
|
|
95
|
+
}
|
|
96
|
+
if (mode === "server" && !key.startsWith("bs_sec_")) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
"The server SDK requires a secret key (bs_sec_*). Use createClient() from '@buildspacestudio/sdk/client' for browser usage with publishable keys."
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (mode === "client" && !key.startsWith("bs_pub_")) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
"The client SDK requires a publishable key (bs_pub_*). Use new Buildspace() from '@buildspacestudio/sdk' for server usage with secret keys."
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/events/client.ts
|
|
109
|
+
var EventsClientNamespace = class {
|
|
110
|
+
queue = [];
|
|
111
|
+
transport;
|
|
112
|
+
timer = null;
|
|
113
|
+
constructor(transport, config = {}) {
|
|
114
|
+
this.transport = transport;
|
|
115
|
+
const flushInterval = config.flushInterval ?? 5e3;
|
|
116
|
+
this.maxBatchSize = config.maxBatchSize ?? 20;
|
|
117
|
+
this.timer = setInterval(() => {
|
|
118
|
+
this.flush().catch(() => {
|
|
119
|
+
});
|
|
120
|
+
}, flushInterval);
|
|
121
|
+
}
|
|
122
|
+
maxBatchSize;
|
|
123
|
+
/**
|
|
124
|
+
* Queue an event for batched delivery.
|
|
125
|
+
*
|
|
126
|
+
* This method is synchronous and returns immediately. Events are
|
|
127
|
+
* automatically flushed when the batch size is reached or on the
|
|
128
|
+
* configured interval.
|
|
129
|
+
*
|
|
130
|
+
* @param event - Event name, e.g. `"button.clicked"`.
|
|
131
|
+
* @param properties - Arbitrary key-value data to attach.
|
|
132
|
+
* @param actorId - Identifier of the user or entity that triggered the event.
|
|
133
|
+
*/
|
|
134
|
+
track(event, properties, actorId) {
|
|
135
|
+
this.queue.push({
|
|
136
|
+
event,
|
|
137
|
+
properties,
|
|
138
|
+
actor_id: actorId,
|
|
139
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
140
|
+
});
|
|
141
|
+
if (this.queue.length >= this.maxBatchSize) {
|
|
142
|
+
this.flush().catch(() => {
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Send all queued events to the API immediately.
|
|
148
|
+
*
|
|
149
|
+
* If the flush fails, events are re-queued for the next attempt.
|
|
150
|
+
*/
|
|
151
|
+
async flush() {
|
|
152
|
+
if (this.queue.length === 0) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const batch = this.queue.splice(0, this.queue.length);
|
|
156
|
+
try {
|
|
157
|
+
await this.transport.request({
|
|
158
|
+
service: "events",
|
|
159
|
+
path: "/v1/events/batch",
|
|
160
|
+
method: "POST",
|
|
161
|
+
keepalive: true,
|
|
162
|
+
body: { events: batch }
|
|
163
|
+
});
|
|
164
|
+
} catch {
|
|
165
|
+
this.queue.unshift(...batch);
|
|
166
|
+
throw new Error("Failed to flush events batch.");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Stop the automatic flush timer and send any remaining events.
|
|
171
|
+
*
|
|
172
|
+
* Call this during app shutdown or cleanup to ensure no events are lost.
|
|
173
|
+
*/
|
|
174
|
+
async shutdown() {
|
|
175
|
+
if (this.timer) {
|
|
176
|
+
clearInterval(this.timer);
|
|
177
|
+
this.timer = null;
|
|
178
|
+
}
|
|
179
|
+
await this.flush();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/http.ts
|
|
184
|
+
var HttpTransport = class {
|
|
185
|
+
baseUrl;
|
|
186
|
+
fetcher;
|
|
187
|
+
key;
|
|
188
|
+
loginUrl;
|
|
189
|
+
mode;
|
|
190
|
+
version;
|
|
191
|
+
sessionToken = null;
|
|
192
|
+
constructor({ key, resolvedConfig }) {
|
|
193
|
+
validateApiKey({ mode: resolvedConfig.mode, key });
|
|
194
|
+
this.key = key;
|
|
195
|
+
this.mode = resolvedConfig.mode;
|
|
196
|
+
this.baseUrl = resolvedConfig.baseUrl;
|
|
197
|
+
this.loginUrl = resolvedConfig.loginUrl;
|
|
198
|
+
this.version = resolvedConfig.version;
|
|
199
|
+
this.fetcher = resolvedConfig.fetch;
|
|
200
|
+
}
|
|
201
|
+
/** Remove the stored session token. */
|
|
202
|
+
clearSession() {
|
|
203
|
+
this.sessionToken = null;
|
|
204
|
+
}
|
|
205
|
+
/** Return the current session token, or `null` if none is set. */
|
|
206
|
+
getSessionToken() {
|
|
207
|
+
return this.sessionToken;
|
|
208
|
+
}
|
|
209
|
+
/** Store a session token that will be sent as `X-Session-Token` on subsequent requests. */
|
|
210
|
+
setSession(sessionToken) {
|
|
211
|
+
this.sessionToken = sessionToken;
|
|
212
|
+
}
|
|
213
|
+
async request({
|
|
214
|
+
service,
|
|
215
|
+
path,
|
|
216
|
+
method = "GET",
|
|
217
|
+
query,
|
|
218
|
+
body,
|
|
219
|
+
headers,
|
|
220
|
+
keepalive
|
|
221
|
+
}) {
|
|
222
|
+
const url = new URL(path, this.baseUrl);
|
|
223
|
+
if (query) {
|
|
224
|
+
for (const [key, value] of Object.entries(query)) {
|
|
225
|
+
if (value !== void 0) {
|
|
226
|
+
url.searchParams.set(key, String(value));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const response = await this.fetcher(url.toString(), {
|
|
231
|
+
method,
|
|
232
|
+
keepalive,
|
|
233
|
+
headers: {
|
|
234
|
+
Authorization: `Bearer ${this.key}`,
|
|
235
|
+
"Content-Type": "application/json",
|
|
236
|
+
"X-Buildspace-Version": this.version,
|
|
237
|
+
...this.sessionToken ? { "X-Session-Token": this.sessionToken } : {},
|
|
238
|
+
...headers
|
|
239
|
+
},
|
|
240
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
241
|
+
});
|
|
242
|
+
if (!response.ok) {
|
|
243
|
+
const payload = await response.json().catch(() => null);
|
|
244
|
+
throw new BuildspaceError({
|
|
245
|
+
service,
|
|
246
|
+
status: response.status,
|
|
247
|
+
code: payload?.code ?? `${service}/http-${response.status}`,
|
|
248
|
+
message: payload?.error ?? payload?.message ?? response.statusText
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
if (response.status === 204) {
|
|
252
|
+
return void 0;
|
|
253
|
+
}
|
|
254
|
+
return response.json();
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// src/storage/client.ts
|
|
259
|
+
var StorageClientNamespace = class {
|
|
260
|
+
transport;
|
|
261
|
+
constructor(transport) {
|
|
262
|
+
this.transport = transport;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Upload a `File` or `Blob` to Buildspace storage.
|
|
266
|
+
*
|
|
267
|
+
* This method handles the full upload flow:
|
|
268
|
+
* 1. Requests a pre-signed upload URL from the API
|
|
269
|
+
* 2. Uploads the file directly to the storage provider
|
|
270
|
+
* 3. Returns a signed download URL for the uploaded file
|
|
271
|
+
*
|
|
272
|
+
* @param file - The file or blob to upload.
|
|
273
|
+
* @param opts - Upload options including the storage path.
|
|
274
|
+
* @returns The storage key, file size, and a signed download URL.
|
|
275
|
+
*
|
|
276
|
+
* @throws {BuildspaceError} If the upload URL request or the direct upload fails.
|
|
277
|
+
*/
|
|
278
|
+
async upload(file, opts) {
|
|
279
|
+
const contentType = opts.contentType ?? (file instanceof File ? file.type : "application/octet-stream");
|
|
280
|
+
const signed = await this.transport.request({
|
|
281
|
+
service: "storage",
|
|
282
|
+
path: "/v1/storage/upload",
|
|
283
|
+
method: "POST",
|
|
284
|
+
body: {
|
|
285
|
+
path: opts.path,
|
|
286
|
+
content_type: contentType,
|
|
287
|
+
size: file.size
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const response = await this.transport.fetcher(signed.upload_url, {
|
|
291
|
+
method: "PUT",
|
|
292
|
+
headers: { "Content-Type": contentType },
|
|
293
|
+
body: file
|
|
294
|
+
});
|
|
295
|
+
if (!response.ok) {
|
|
296
|
+
throw new BuildspaceError({
|
|
297
|
+
service: "storage",
|
|
298
|
+
status: response.status,
|
|
299
|
+
code: "storage/upload-failed",
|
|
300
|
+
message: `Direct upload failed: ${response.statusText}`
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
const { url } = await this.getUrl(signed.key);
|
|
304
|
+
return {
|
|
305
|
+
key: signed.key,
|
|
306
|
+
size: file.size,
|
|
307
|
+
url
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get a time-limited signed URL for downloading a stored file.
|
|
312
|
+
*
|
|
313
|
+
* @param key - The storage key of the object.
|
|
314
|
+
* @param opts - Optional settings.
|
|
315
|
+
* @param opts.expiresIn - URL lifetime in seconds.
|
|
316
|
+
*/
|
|
317
|
+
getUrl(key, opts) {
|
|
318
|
+
return this.transport.request({
|
|
319
|
+
service: "storage",
|
|
320
|
+
path: "/v1/storage/url",
|
|
321
|
+
query: {
|
|
322
|
+
key,
|
|
323
|
+
expires_in: opts?.expiresIn
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* List stored objects, optionally filtered by key prefix.
|
|
329
|
+
*
|
|
330
|
+
* @param prefix - Only return objects whose key starts with this prefix.
|
|
331
|
+
* @param opts - Pagination options.
|
|
332
|
+
*/
|
|
333
|
+
list(prefix, opts) {
|
|
334
|
+
return this.transport.request({
|
|
335
|
+
service: "storage",
|
|
336
|
+
path: "/v1/storage/objects",
|
|
337
|
+
query: {
|
|
338
|
+
prefix,
|
|
339
|
+
limit: opts?.limit,
|
|
340
|
+
offset: opts?.offset
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Delete a stored object by key.
|
|
346
|
+
*
|
|
347
|
+
* @param key - The storage key of the object to delete.
|
|
348
|
+
*/
|
|
349
|
+
async delete(key) {
|
|
350
|
+
await this.transport.request({
|
|
351
|
+
service: "storage",
|
|
352
|
+
path: "/v1/storage/object",
|
|
353
|
+
method: "DELETE",
|
|
354
|
+
body: { key }
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// src/client/index.ts
|
|
360
|
+
var BuildspaceClient = class {
|
|
361
|
+
transport;
|
|
362
|
+
config;
|
|
363
|
+
_auth = null;
|
|
364
|
+
_events = null;
|
|
365
|
+
_storage = null;
|
|
366
|
+
/**
|
|
367
|
+
* Create a new client SDK instance.
|
|
368
|
+
*
|
|
369
|
+
* @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).
|
|
370
|
+
* @param config - Optional configuration overrides.
|
|
371
|
+
*/
|
|
372
|
+
constructor(publishableKey, config = {}) {
|
|
373
|
+
this.config = config;
|
|
374
|
+
this.transport = new HttpTransport({
|
|
375
|
+
key: publishableKey,
|
|
376
|
+
resolvedConfig: resolveConfig("client", config)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
/** Client-side auth: sign-in and sign-up URL generation. */
|
|
380
|
+
get auth() {
|
|
381
|
+
this._auth ??= new AuthClientNamespace(this.transport);
|
|
382
|
+
return this._auth;
|
|
383
|
+
}
|
|
384
|
+
/** Client-side event tracking with automatic batching. */
|
|
385
|
+
get events() {
|
|
386
|
+
this._events ??= new EventsClientNamespace(this.transport, this.config.events);
|
|
387
|
+
return this._events;
|
|
388
|
+
}
|
|
389
|
+
/** Client-side file storage: uploads, downloads, listing, deletion. */
|
|
390
|
+
get storage() {
|
|
391
|
+
this._storage ??= new StorageClientNamespace(this.transport);
|
|
392
|
+
return this._storage;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Notifications are server-only and not available on the client SDK.
|
|
396
|
+
*
|
|
397
|
+
* @throws {BuildspaceError} Always throws — use the server SDK for notifications.
|
|
398
|
+
*/
|
|
399
|
+
get notifications() {
|
|
400
|
+
throw new BuildspaceError({
|
|
401
|
+
service: "notifications",
|
|
402
|
+
status: 400,
|
|
403
|
+
code: "notifications/server-only",
|
|
404
|
+
message: "Notifications require a secret key. Use the server SDK via new Buildspace() from '@buildspacestudio/sdk'."
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/** Clear the stored session token. */
|
|
408
|
+
clearSession() {
|
|
409
|
+
this.transport.clearSession();
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Set a session token that will be sent as `X-Session-Token` on all
|
|
413
|
+
* subsequent API requests.
|
|
414
|
+
*
|
|
415
|
+
* @param sessionToken - The session token to attach to requests.
|
|
416
|
+
*/
|
|
417
|
+
setSession(sessionToken) {
|
|
418
|
+
this.transport.setSession(sessionToken);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
function createClient(publishableKey, config = {}) {
|
|
422
|
+
return new BuildspaceClient(publishableKey, config);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
exports.BuildspaceClient = BuildspaceClient;
|
|
426
|
+
exports.createClient = createClient;
|
|
427
|
+
//# sourceMappingURL=index.cjs.map
|
|
428
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/client.ts","../../src/errors.ts","../../src/config.ts","../../src/events/client.ts","../../src/http.ts","../../src/storage/client.ts","../../src/client/index.ts"],"names":[],"mappings":";;;AA0CO,IAAM,sBAAN,MAA0B;AAAA,EACd,SAAA;AAAA,EAEjB,YAAY,SAAA,EAA0B;AACpC,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,aAAa,IAAA,EAAgC;AAC3C,IAAA,MAAM,MAAM,IAAI,GAAA,CAAI,UAAA,EAAY,IAAA,CAAK,UAAU,QAAQ,CAAA;AAEvD,IAAA,IAAI,KAAK,OAAA,EAAS;AAChB,MAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,KAAA,EAAO,IAAA,CAAK,OAAO,CAAA;AAAA,IAC1C;AAEA,IAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,cAAA,EAAgB,IAAA,CAAK,WAAW,CAAA;AACrD,IAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,WAAA,EAAa,IAAA,CAAK,UAAU,GAAG,CAAA;AAEpD,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,KA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IAAA,OAAO,IAAA,CAAK,QAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,aAAA,GAAuB;AACzB,IAAA,MAAM,IAAI,eAAA,CAAgB;AAAA,MACxB,OAAA,EAAS,eAAA;AAAA,MACT,MAAA,EAAQ,GAAA;AAAA,MACR,IAAA,EAAM,2BAAA;AAAA,MACN,OAAA,EACE;AAAA,KACH,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,YAAA,GAAqB;AACnB,IAAA,IAAA,CAAK,UAAU,YAAA,EAAa;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,WAAW,YAAA,EAA4B;AACrC,IAAA,IAAA,CAAK,SAAA,CAAU,WAAW,YAAY,CAAA;AAAA,EACxC;AACF;AAiBO,SAAS,YAAA,CACd,cAAA,EACA,MAAA,GAAiC,EAAC,EAChB;AAClB,EAAA,OAAO,IAAI,gBAAA,CAAiB,cAAA,EAAgB,MAAM,CAAA;AACpD","file":"index.cjs","sourcesContent":["import type { HttpTransport } from \"../http\";\n\n/** Options for generating a sign-in URL. */\nexport interface SignInUrlOptions {\n /** App slug to scope the login to a specific creator app. */\n appSlug?: string;\n /** Environment to authenticate against. */\n env?: \"dev\" | \"prod\";\n /** URL to redirect the user to after authentication completes. */\n redirectUri: string;\n}\n\n/** Options for generating a sign-up URL. */\nexport interface SignUpUrlOptions {\n /** App slug to scope the registration to a specific creator app. */\n appSlug?: string;\n /** Environment to authenticate against. */\n env?: \"dev\" | \"prod\";\n /** URL to redirect the user to after registration completes. */\n redirectUri: string;\n}\n\n/**\n * Client-side authentication methods for generating login URLs.\n *\n * Access via `buildspace.auth` on the client SDK, or `buildspace.authClient`\n * on the server SDK when you need to generate URLs from server-side code.\n *\n * @example\n * ```ts\n * import { createClient } from \"@buildspacestudio/sdk/client\";\n *\n * const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);\n *\n * const signInUrl = buildspace.auth.getSignInUrl({\n * redirectUri: \"https://yourapp.com/auth/callback\",\n * });\n *\n * // Use in a link or redirect\n * window.location.href = signInUrl;\n * ```\n */\nexport class AuthClientNamespace {\n private readonly transport: HttpTransport;\n\n constructor(transport: HttpTransport) {\n this.transport = transport;\n }\n\n /**\n * Build a URL that redirects the user to the Buildspace sign-in page.\n *\n * After the user authenticates, they are redirected back to `redirectUri`\n * with a `?code=` parameter that can be exchanged for tokens via\n * `buildspace.auth.handleCallback()` on the server.\n *\n * @param opts - Sign-in URL options.\n * @returns The full sign-in URL as a string.\n */\n getSignInUrl(opts: SignInUrlOptions): string {\n const url = new URL(\"/sign-in\", this.transport.loginUrl);\n\n if (opts.appSlug) {\n url.searchParams.set(\"app\", opts.appSlug);\n }\n\n url.searchParams.set(\"redirect_uri\", opts.redirectUri);\n url.searchParams.set(\"client_id\", this.transport.key);\n\n if (opts.env) {\n url.searchParams.set(\"env\", opts.env);\n }\n\n return url.toString();\n }\n\n /**\n * Build a URL that redirects the user to the Buildspace sign-up page.\n *\n * Works identically to {@link getSignInUrl} but directs the user to the\n * registration flow instead.\n *\n * @param opts - Sign-up URL options.\n * @returns The full sign-up URL as a string.\n */\n getSignUpUrl(opts: SignUpUrlOptions): string {\n const url = new URL(\"/sign-up\", this.transport.loginUrl);\n\n if (opts.appSlug) {\n url.searchParams.set(\"app\", opts.appSlug);\n }\n\n url.searchParams.set(\"redirect_uri\", opts.redirectUri);\n url.searchParams.set(\"client_id\", this.transport.key);\n\n if (opts.env) {\n url.searchParams.set(\"env\", opts.env);\n }\n\n return url.toString();\n }\n}\n","/** Services available in the Buildspace platform. */\nexport type BuildspaceService = \"auth\" | \"events\" | \"notifications\" | \"storage\";\n\n/**\n * Error thrown by all Buildspace SDK methods on failure.\n *\n * @example\n * ```ts\n * try {\n * await buildspace.auth.getSession(token);\n * } catch (err) {\n * if (err instanceof BuildspaceError) {\n * console.error(err.service, err.code, err.status, err.message);\n * }\n * }\n * ```\n */\nexport class BuildspaceError extends Error {\n /** Machine-readable error code, e.g. `\"auth/invalid-token\"`. */\n readonly code: string;\n /** Which service produced the error. */\n readonly service: BuildspaceService;\n /** HTTP status code from the API. */\n readonly status: number;\n\n constructor({\n code,\n message,\n service,\n status,\n }: {\n code: string;\n message: string;\n service: BuildspaceService;\n status: number;\n }) {\n super(message);\n this.name = \"BuildspaceError\";\n this.code = code;\n this.service = service;\n this.status = status;\n }\n}\n","export const DEFAULT_BASE_URL = \"https://api.buildspace.studio\";\nexport const DEFAULT_LOGIN_URL = \"https://login.buildspace.studio\";\nexport const DEFAULT_API_VERSION = \"2025-06-01\";\n\nexport type ClientMode = \"server\" | \"client\";\n\n/** Configuration options for the server SDK (`new Buildspace()`). */\nexport interface BuildspaceConfig {\n /** Base URL of the Buildspace API. Defaults to `\"https://api.buildspace.studio\"`. */\n baseUrl?: string;\n /** Custom `fetch` implementation (useful for testing or edge runtimes). */\n fetch?: typeof fetch;\n /** Base URL of the Buildspace login service. Defaults to `\"https://login.buildspace.studio\"`. */\n loginUrl?: string;\n /** API version string sent via the `X-Buildspace-Version` header. Defaults to `\"2025-06-01\"`. */\n version?: string;\n}\n\n/** Configuration for client-side event batching behavior. */\nexport interface EventsBatchingConfig {\n /** How often queued events are flushed to the API, in milliseconds. Defaults to `5000`. */\n flushInterval?: number;\n /** Maximum number of events to queue before an automatic flush. Defaults to `20`. */\n maxBatchSize?: number;\n}\n\n/** Configuration options for the client SDK (`createClient()`). */\nexport interface BuildspaceClientConfig extends BuildspaceConfig {\n /** Options for client-side event batching. */\n events?: EventsBatchingConfig;\n}\n\nexport interface ResolvedConfig {\n baseUrl: string;\n fetch: typeof fetch;\n loginUrl: string;\n mode: ClientMode;\n version: string;\n}\n\nexport function resolveConfig(mode: ClientMode, config: BuildspaceConfig = {}): ResolvedConfig {\n return {\n mode,\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n loginUrl: config.loginUrl ?? DEFAULT_LOGIN_URL,\n version: config.version ?? DEFAULT_API_VERSION,\n fetch: config.fetch ?? fetch,\n };\n}\n\nfunction formatMode(mode: ClientMode): string {\n return mode === \"server\" ? \"server SDK\" : \"client SDK\";\n}\n\nexport function validateApiKey({ mode, key }: { key: string; mode: ClientMode }): void {\n if (!key) {\n throw new Error(`Missing API key. The ${formatMode(mode)} requires a valid Buildspace key.`);\n }\n\n if (mode === \"server\" && !key.startsWith(\"bs_sec_\")) {\n throw new Error(\n \"The server SDK requires a secret key (bs_sec_*). Use createClient() from '@buildspacestudio/sdk/client' for browser usage with publishable keys.\"\n );\n }\n\n if (mode === \"client\" && !key.startsWith(\"bs_pub_\")) {\n throw new Error(\n \"The client SDK requires a publishable key (bs_pub_*). Use new Buildspace() from '@buildspacestudio/sdk' for server usage with secret keys.\"\n );\n }\n}\n","import type { HttpTransport } from \"../http\";\n\ninterface QueuedEvent {\n actor_id?: string;\n event: string;\n properties?: Record<string, unknown>;\n timestamp: string;\n}\n\n/**\n * Client-side event tracking with automatic batching.\n *\n * Events are queued in memory and flushed to the API in batches,\n * either on a timer or when the batch size limit is reached.\n *\n * Access via `buildspace.events` on the client SDK.\n *\n * @example\n * ```ts\n * // Fire and forget — events are queued automatically\n * buildspace.events.track(\"button.clicked\", { label: \"upgrade\" });\n *\n * // Flush before page unload\n * await buildspace.events.flush();\n *\n * // Graceful shutdown (clears timer, flushes remaining)\n * await buildspace.events.shutdown();\n * ```\n */\nexport class EventsClientNamespace {\n private readonly queue: QueuedEvent[] = [];\n private readonly transport: HttpTransport;\n private timer: ReturnType<typeof setInterval> | null = null;\n\n constructor(\n transport: HttpTransport,\n config: { flushInterval?: number; maxBatchSize?: number } = {}\n ) {\n this.transport = transport;\n const flushInterval = config.flushInterval ?? 5000;\n this.maxBatchSize = config.maxBatchSize ?? 20;\n this.timer = setInterval(() => {\n this.flush().catch(() => {\n // best effort flush for background timer\n });\n }, flushInterval);\n }\n\n private readonly maxBatchSize: number;\n\n /**\n * Queue an event for batched delivery.\n *\n * This method is synchronous and returns immediately. Events are\n * automatically flushed when the batch size is reached or on the\n * configured interval.\n *\n * @param event - Event name, e.g. `\"button.clicked\"`.\n * @param properties - Arbitrary key-value data to attach.\n * @param actorId - Identifier of the user or entity that triggered the event.\n */\n track(event: string, properties?: Record<string, unknown>, actorId?: string): void {\n this.queue.push({\n event,\n properties,\n actor_id: actorId,\n timestamp: new Date().toISOString(),\n });\n\n if (this.queue.length >= this.maxBatchSize) {\n this.flush().catch(() => {\n // best effort flush on max batch size\n });\n }\n }\n\n /**\n * Send all queued events to the API immediately.\n *\n * If the flush fails, events are re-queued for the next attempt.\n */\n async flush(): Promise<void> {\n if (this.queue.length === 0) {\n return;\n }\n\n const batch = this.queue.splice(0, this.queue.length);\n\n try {\n await this.transport.request<void>({\n service: \"events\",\n path: \"/v1/events/batch\",\n method: \"POST\",\n keepalive: true,\n body: { events: batch },\n });\n } catch {\n this.queue.unshift(...batch);\n throw new Error(\"Failed to flush events batch.\");\n }\n }\n\n /**\n * Stop the automatic flush timer and send any remaining events.\n *\n * Call this during app shutdown or cleanup to ensure no events are lost.\n */\n async shutdown(): Promise<void> {\n if (this.timer) {\n clearInterval(this.timer);\n this.timer = null;\n }\n\n await this.flush();\n }\n}\n","import { type ClientMode, type ResolvedConfig, validateApiKey } from \"./config\";\nimport { BuildspaceError, type BuildspaceService } from \"./errors\";\n\ninterface RequestOptions {\n body?: unknown;\n headers?: Record<string, string>;\n keepalive?: boolean;\n method?: string;\n path: string;\n query?: Record<string, string | number | boolean | undefined>;\n service: BuildspaceService;\n}\n\n/**\n * Low-level HTTP transport used internally by all SDK namespaces.\n *\n * Handles authentication headers, API versioning, session tokens,\n * and consistent error mapping to {@link BuildspaceError}.\n */\nexport class HttpTransport {\n readonly baseUrl: string;\n readonly fetcher: typeof fetch;\n readonly key: string;\n readonly loginUrl: string;\n readonly mode: ClientMode;\n readonly version: string;\n private sessionToken: string | null = null;\n\n constructor({ key, resolvedConfig }: { key: string; resolvedConfig: ResolvedConfig }) {\n validateApiKey({ mode: resolvedConfig.mode, key });\n this.key = key;\n this.mode = resolvedConfig.mode;\n this.baseUrl = resolvedConfig.baseUrl;\n this.loginUrl = resolvedConfig.loginUrl;\n this.version = resolvedConfig.version;\n this.fetcher = resolvedConfig.fetch;\n }\n\n /** Remove the stored session token. */\n clearSession(): void {\n this.sessionToken = null;\n }\n\n /** Return the current session token, or `null` if none is set. */\n getSessionToken(): string | null {\n return this.sessionToken;\n }\n\n /** Store a session token that will be sent as `X-Session-Token` on subsequent requests. */\n setSession(sessionToken: string): void {\n this.sessionToken = sessionToken;\n }\n\n async request<T>({\n service,\n path,\n method = \"GET\",\n query,\n body,\n headers,\n keepalive,\n }: RequestOptions): Promise<T> {\n const url = new URL(path, this.baseUrl);\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const response = await this.fetcher(url.toString(), {\n method,\n keepalive,\n headers: {\n Authorization: `Bearer ${this.key}`,\n \"Content-Type\": \"application/json\",\n \"X-Buildspace-Version\": this.version,\n ...(this.sessionToken ? { \"X-Session-Token\": this.sessionToken } : {}),\n ...headers,\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n\n if (!response.ok) {\n const payload = (await response.json().catch(() => null)) as {\n code?: string;\n error?: string;\n message?: string;\n } | null;\n\n throw new BuildspaceError({\n service,\n status: response.status,\n code: payload?.code ?? `${service}/http-${response.status}`,\n message: payload?.error ?? payload?.message ?? response.statusText,\n });\n }\n\n if (response.status === 204) {\n return undefined as T;\n }\n\n return response.json() as Promise<T>;\n }\n}\n","import { BuildspaceError } from \"../errors\";\nimport type { HttpTransport } from \"../http\";\nimport type { StorageObject } from \"./server\";\n\n/** Options for uploading a file from the client. */\nexport interface UploadOptions {\n /** MIME type override. If omitted, inferred from the `File` object or defaults to `\"application/octet-stream\"`. */\n contentType?: string;\n /** Storage path/key for the file, e.g. `\"avatars/user-123.png\"`. */\n path: string;\n}\n\n/** Result of a successful client-side file upload. */\nexport interface UploadResponse {\n /** The resolved storage key. */\n key: string;\n /** File size in bytes. */\n size: number;\n /** Signed download URL for the uploaded file. */\n url: string;\n}\n\n/** Result of requesting a signed download URL. */\nexport interface GetUrlResponse {\n /** URL lifetime in seconds, if applicable. */\n expiresIn?: number;\n /** The storage key of the object. */\n key: string;\n /** The signed download URL. */\n url: string;\n}\n\n/**\n * Client-side storage methods for uploading and managing files.\n *\n * Access via `buildspace.storage` on the client SDK.\n *\n * @example\n * ```ts\n * // Upload a file (handles signed URL + PUT automatically)\n * const { key, url } = await buildspace.storage.upload(file, {\n * path: \"avatars/user-123.png\",\n * });\n *\n * // Get a download URL for an existing file\n * const { url } = await buildspace.storage.getUrl(key);\n * ```\n */\nexport class StorageClientNamespace {\n private readonly transport: HttpTransport;\n\n constructor(transport: HttpTransport) {\n this.transport = transport;\n }\n\n /**\n * Upload a `File` or `Blob` to Buildspace storage.\n *\n * This method handles the full upload flow:\n * 1. Requests a pre-signed upload URL from the API\n * 2. Uploads the file directly to the storage provider\n * 3. Returns a signed download URL for the uploaded file\n *\n * @param file - The file or blob to upload.\n * @param opts - Upload options including the storage path.\n * @returns The storage key, file size, and a signed download URL.\n *\n * @throws {BuildspaceError} If the upload URL request or the direct upload fails.\n */\n async upload(file: File | Blob, opts: UploadOptions): Promise<UploadResponse> {\n const contentType =\n opts.contentType ?? (file instanceof File ? file.type : \"application/octet-stream\");\n\n const signed = await this.transport.request<{ key: string; upload_url: string }>({\n service: \"storage\",\n path: \"/v1/storage/upload\",\n method: \"POST\",\n body: {\n path: opts.path,\n content_type: contentType,\n size: file.size,\n },\n });\n\n const response = await this.transport.fetcher(signed.upload_url, {\n method: \"PUT\",\n headers: { \"Content-Type\": contentType },\n body: file,\n });\n\n if (!response.ok) {\n throw new BuildspaceError({\n service: \"storage\",\n status: response.status,\n code: \"storage/upload-failed\",\n message: `Direct upload failed: ${response.statusText}`,\n });\n }\n\n const { url } = await this.getUrl(signed.key);\n\n return {\n key: signed.key,\n size: file.size,\n url,\n };\n }\n\n /**\n * Get a time-limited signed URL for downloading a stored file.\n *\n * @param key - The storage key of the object.\n * @param opts - Optional settings.\n * @param opts.expiresIn - URL lifetime in seconds.\n */\n getUrl(key: string, opts?: { expiresIn?: number }): Promise<GetUrlResponse> {\n return this.transport.request<GetUrlResponse>({\n service: \"storage\",\n path: \"/v1/storage/url\",\n query: {\n key,\n expires_in: opts?.expiresIn,\n },\n });\n }\n\n /**\n * List stored objects, optionally filtered by key prefix.\n *\n * @param prefix - Only return objects whose key starts with this prefix.\n * @param opts - Pagination options.\n */\n list(\n prefix?: string,\n opts?: { limit?: number; offset?: number }\n ): Promise<{ objects: StorageObject[] }> {\n return this.transport.request<{ objects: StorageObject[] }>({\n service: \"storage\",\n path: \"/v1/storage/objects\",\n query: {\n prefix,\n limit: opts?.limit,\n offset: opts?.offset,\n },\n });\n }\n\n /**\n * Delete a stored object by key.\n *\n * @param key - The storage key of the object to delete.\n */\n async delete(key: string): Promise<void> {\n await this.transport.request<void>({\n service: \"storage\",\n path: \"/v1/storage/object\",\n method: \"DELETE\",\n body: { key },\n });\n }\n}\n","import { AuthClientNamespace } from \"../auth\";\nimport { type BuildspaceClientConfig, resolveConfig } from \"../config\";\nimport { BuildspaceError } from \"../errors\";\nimport { EventsClientNamespace } from \"../events\";\nimport { HttpTransport } from \"../http\";\nimport { StorageClientNamespace } from \"../storage\";\n\n/**\n * Buildspace client SDK — use with a publishable key (`bs_pub_*`).\n *\n * Provides client-safe access to auth URL generation, event tracking\n * (with automatic batching), and file uploads. For server-side usage\n * with full API access, use `new Buildspace()` from `@buildspacestudio/sdk`.\n *\n * @example\n * ```ts\n * import { createClient } from \"@buildspacestudio/sdk/client\";\n *\n * const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);\n *\n * // Generate a sign-in URL\n * const url = buildspace.auth.getSignInUrl({\n * redirectUri: \"https://yourapp.com/auth/callback\",\n * });\n *\n * // Track an event (fire and forget)\n * buildspace.events.track(\"button.clicked\", { label: \"upgrade\" });\n *\n * // Upload a file\n * const { key, url } = await buildspace.storage.upload(file, {\n * path: \"avatars/user-123.png\",\n * });\n * ```\n */\nclass BuildspaceClient {\n private readonly transport: HttpTransport;\n private readonly config: BuildspaceClientConfig;\n private _auth: AuthClientNamespace | null = null;\n private _events: EventsClientNamespace | null = null;\n private _storage: StorageClientNamespace | null = null;\n\n /**\n * Create a new client SDK instance.\n *\n * @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).\n * @param config - Optional configuration overrides.\n */\n constructor(publishableKey: string, config: BuildspaceClientConfig = {}) {\n this.config = config;\n this.transport = new HttpTransport({\n key: publishableKey,\n resolvedConfig: resolveConfig(\"client\", config),\n });\n }\n\n /** Client-side auth: sign-in and sign-up URL generation. */\n get auth(): AuthClientNamespace {\n this._auth ??= new AuthClientNamespace(this.transport);\n return this._auth;\n }\n\n /** Client-side event tracking with automatic batching. */\n get events(): EventsClientNamespace {\n this._events ??= new EventsClientNamespace(this.transport, this.config.events);\n return this._events;\n }\n\n /** Client-side file storage: uploads, downloads, listing, deletion. */\n get storage(): StorageClientNamespace {\n this._storage ??= new StorageClientNamespace(this.transport);\n return this._storage;\n }\n\n /**\n * Notifications are server-only and not available on the client SDK.\n *\n * @throws {BuildspaceError} Always throws — use the server SDK for notifications.\n */\n get notifications(): never {\n throw new BuildspaceError({\n service: \"notifications\",\n status: 400,\n code: \"notifications/server-only\",\n message:\n \"Notifications require a secret key. Use the server SDK via new Buildspace() from '@buildspacestudio/sdk'.\",\n });\n }\n\n /** Clear the stored session token. */\n clearSession(): void {\n this.transport.clearSession();\n }\n\n /**\n * Set a session token that will be sent as `X-Session-Token` on all\n * subsequent API requests.\n *\n * @param sessionToken - The session token to attach to requests.\n */\n setSession(sessionToken: string): void {\n this.transport.setSession(sessionToken);\n }\n}\n\n/**\n * Create a Buildspace client SDK instance.\n *\n * Preferred over `new BuildspaceClient()` for a more concise API.\n *\n * @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).\n * @param config - Optional configuration overrides.\n *\n * @example\n * ```ts\n * import { createClient } from \"@buildspacestudio/sdk/client\";\n *\n * const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);\n * ```\n */\nexport function createClient(\n publishableKey: string,\n config: BuildspaceClientConfig = {}\n): BuildspaceClient {\n return new BuildspaceClient(publishableKey, config);\n}\n\nexport { BuildspaceClient };\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { A as AuthClientNamespace } from '../client-DqWXAwCr.cjs';
|
|
2
|
+
import { a as BuildspaceClientConfig } from '../http-U-zzKmFF.cjs';
|
|
3
|
+
import { E as EventsClientNamespace } from '../client-C67hy1kt.cjs';
|
|
4
|
+
import { StorageClientNamespace } from '../storage/index.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Buildspace client SDK — use with a publishable key (`bs_pub_*`).
|
|
8
|
+
*
|
|
9
|
+
* Provides client-safe access to auth URL generation, event tracking
|
|
10
|
+
* (with automatic batching), and file uploads. For server-side usage
|
|
11
|
+
* with full API access, use `new Buildspace()` from `@buildspacestudio/sdk`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createClient } from "@buildspacestudio/sdk/client";
|
|
16
|
+
*
|
|
17
|
+
* const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);
|
|
18
|
+
*
|
|
19
|
+
* // Generate a sign-in URL
|
|
20
|
+
* const url = buildspace.auth.getSignInUrl({
|
|
21
|
+
* redirectUri: "https://yourapp.com/auth/callback",
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Track an event (fire and forget)
|
|
25
|
+
* buildspace.events.track("button.clicked", { label: "upgrade" });
|
|
26
|
+
*
|
|
27
|
+
* // Upload a file
|
|
28
|
+
* const { key, url } = await buildspace.storage.upload(file, {
|
|
29
|
+
* path: "avatars/user-123.png",
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare class BuildspaceClient {
|
|
34
|
+
private readonly transport;
|
|
35
|
+
private readonly config;
|
|
36
|
+
private _auth;
|
|
37
|
+
private _events;
|
|
38
|
+
private _storage;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new client SDK instance.
|
|
41
|
+
*
|
|
42
|
+
* @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).
|
|
43
|
+
* @param config - Optional configuration overrides.
|
|
44
|
+
*/
|
|
45
|
+
constructor(publishableKey: string, config?: BuildspaceClientConfig);
|
|
46
|
+
/** Client-side auth: sign-in and sign-up URL generation. */
|
|
47
|
+
get auth(): AuthClientNamespace;
|
|
48
|
+
/** Client-side event tracking with automatic batching. */
|
|
49
|
+
get events(): EventsClientNamespace;
|
|
50
|
+
/** Client-side file storage: uploads, downloads, listing, deletion. */
|
|
51
|
+
get storage(): StorageClientNamespace;
|
|
52
|
+
/**
|
|
53
|
+
* Notifications are server-only and not available on the client SDK.
|
|
54
|
+
*
|
|
55
|
+
* @throws {BuildspaceError} Always throws — use the server SDK for notifications.
|
|
56
|
+
*/
|
|
57
|
+
get notifications(): never;
|
|
58
|
+
/** Clear the stored session token. */
|
|
59
|
+
clearSession(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Set a session token that will be sent as `X-Session-Token` on all
|
|
62
|
+
* subsequent API requests.
|
|
63
|
+
*
|
|
64
|
+
* @param sessionToken - The session token to attach to requests.
|
|
65
|
+
*/
|
|
66
|
+
setSession(sessionToken: string): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a Buildspace client SDK instance.
|
|
70
|
+
*
|
|
71
|
+
* Preferred over `new BuildspaceClient()` for a more concise API.
|
|
72
|
+
*
|
|
73
|
+
* @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).
|
|
74
|
+
* @param config - Optional configuration overrides.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { createClient } from "@buildspacestudio/sdk/client";
|
|
79
|
+
*
|
|
80
|
+
* const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
declare function createClient(publishableKey: string, config?: BuildspaceClientConfig): BuildspaceClient;
|
|
84
|
+
|
|
85
|
+
export { BuildspaceClient, createClient };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AuthClientNamespace } from
|
|
2
|
-
import {
|
|
3
|
-
import { EventsClientNamespace } from
|
|
4
|
-
import { StorageClientNamespace } from
|
|
1
|
+
import { A as AuthClientNamespace } from '../client-BH7LbrKM.js';
|
|
2
|
+
import { a as BuildspaceClientConfig } from '../http-U-zzKmFF.js';
|
|
3
|
+
import { E as EventsClientNamespace } from '../client-Dlif1JBf.js';
|
|
4
|
+
import { StorageClientNamespace } from '../storage/index.js';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Buildspace client SDK — use with a publishable key (`bs_pub_*`).
|
|
7
8
|
*
|
|
@@ -79,6 +80,6 @@ declare class BuildspaceClient {
|
|
|
79
80
|
* const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
declare function createClient(publishableKey: string, config?: BuildspaceClientConfig): BuildspaceClient;
|
|
84
|
+
|
|
85
|
+
export { BuildspaceClient, createClient };
|