@buildspacestudio/sdk 0.2.2 → 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
package/dist/http.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type ClientMode, type ResolvedConfig } from "./config";
|
|
2
|
-
import { type BuildspaceService } from "./errors";
|
|
3
|
-
interface RequestOptions {
|
|
4
|
-
body?: unknown;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
keepalive?: boolean;
|
|
7
|
-
method?: string;
|
|
8
|
-
path: string;
|
|
9
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
10
|
-
service: BuildspaceService;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Low-level HTTP transport used internally by all SDK namespaces.
|
|
14
|
-
*
|
|
15
|
-
* Handles authentication headers, API versioning, session tokens,
|
|
16
|
-
* and consistent error mapping to {@link BuildspaceError}.
|
|
17
|
-
*/
|
|
18
|
-
export declare class HttpTransport {
|
|
19
|
-
readonly baseUrl: string;
|
|
20
|
-
readonly fetcher: typeof fetch;
|
|
21
|
-
readonly key: string;
|
|
22
|
-
readonly loginUrl: string;
|
|
23
|
-
readonly mode: ClientMode;
|
|
24
|
-
readonly version: string;
|
|
25
|
-
private sessionToken;
|
|
26
|
-
constructor({ key, resolvedConfig }: {
|
|
27
|
-
key: string;
|
|
28
|
-
resolvedConfig: ResolvedConfig;
|
|
29
|
-
});
|
|
30
|
-
/** Remove the stored session token. */
|
|
31
|
-
clearSession(): void;
|
|
32
|
-
/** Return the current session token, or `null` if none is set. */
|
|
33
|
-
getSessionToken(): string | null;
|
|
34
|
-
/** Store a session token that will be sent as `X-Session-Token` on subsequent requests. */
|
|
35
|
-
setSession(sessionToken: string): void;
|
|
36
|
-
request<T>({ service, path, method, query, body, headers, keepalive, }: RequestOptions): Promise<T>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAkB,MAAM,UAAU,CAAC;AAChF,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnE,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,YAAY,CAAuB;gBAE/B,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,cAAc,CAAA;KAAE;IAUpF,uCAAuC;IACvC,YAAY,IAAI,IAAI;IAIpB,kEAAkE;IAClE,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC,2FAA2F;IAC3F,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAIhC,OAAO,CAAC,CAAC,EAAE,EACf,OAAO,EACP,IAAI,EACJ,MAAc,EACd,KAAK,EACL,IAAI,EACJ,OAAO,EACP,SAAS,GACV,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CA6C/B"}
|
package/dist/http.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { validateApiKey } from "./config";
|
|
2
|
-
import { BuildspaceError } from "./errors";
|
|
3
|
-
/**
|
|
4
|
-
* Low-level HTTP transport used internally by all SDK namespaces.
|
|
5
|
-
*
|
|
6
|
-
* Handles authentication headers, API versioning, session tokens,
|
|
7
|
-
* and consistent error mapping to {@link BuildspaceError}.
|
|
8
|
-
*/
|
|
9
|
-
export class HttpTransport {
|
|
10
|
-
baseUrl;
|
|
11
|
-
fetcher;
|
|
12
|
-
key;
|
|
13
|
-
loginUrl;
|
|
14
|
-
mode;
|
|
15
|
-
version;
|
|
16
|
-
sessionToken = null;
|
|
17
|
-
constructor({ key, resolvedConfig }) {
|
|
18
|
-
validateApiKey({ mode: resolvedConfig.mode, key });
|
|
19
|
-
this.key = key;
|
|
20
|
-
this.mode = resolvedConfig.mode;
|
|
21
|
-
this.baseUrl = resolvedConfig.baseUrl;
|
|
22
|
-
this.loginUrl = resolvedConfig.loginUrl;
|
|
23
|
-
this.version = resolvedConfig.version;
|
|
24
|
-
this.fetcher = resolvedConfig.fetch;
|
|
25
|
-
}
|
|
26
|
-
/** Remove the stored session token. */
|
|
27
|
-
clearSession() {
|
|
28
|
-
this.sessionToken = null;
|
|
29
|
-
}
|
|
30
|
-
/** Return the current session token, or `null` if none is set. */
|
|
31
|
-
getSessionToken() {
|
|
32
|
-
return this.sessionToken;
|
|
33
|
-
}
|
|
34
|
-
/** Store a session token that will be sent as `X-Session-Token` on subsequent requests. */
|
|
35
|
-
setSession(sessionToken) {
|
|
36
|
-
this.sessionToken = sessionToken;
|
|
37
|
-
}
|
|
38
|
-
async request({ service, path, method = "GET", query, body, headers, keepalive, }) {
|
|
39
|
-
const url = new URL(path, this.baseUrl);
|
|
40
|
-
if (query) {
|
|
41
|
-
for (const [key, value] of Object.entries(query)) {
|
|
42
|
-
if (value !== undefined) {
|
|
43
|
-
url.searchParams.set(key, String(value));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const response = await this.fetcher(url.toString(), {
|
|
48
|
-
method,
|
|
49
|
-
keepalive,
|
|
50
|
-
headers: {
|
|
51
|
-
Authorization: `Bearer ${this.key}`,
|
|
52
|
-
"Content-Type": "application/json",
|
|
53
|
-
"X-Buildspace-Version": this.version,
|
|
54
|
-
...(this.sessionToken ? { "X-Session-Token": this.sessionToken } : {}),
|
|
55
|
-
...headers,
|
|
56
|
-
},
|
|
57
|
-
body: body === undefined ? undefined : JSON.stringify(body),
|
|
58
|
-
});
|
|
59
|
-
if (!response.ok) {
|
|
60
|
-
const payload = (await response.json().catch(() => null));
|
|
61
|
-
throw new BuildspaceError({
|
|
62
|
-
service,
|
|
63
|
-
status: response.status,
|
|
64
|
-
code: payload?.code ?? `${service}/http-${response.status}`,
|
|
65
|
-
message: payload?.error ?? payload?.message ?? response.statusText,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
if (response.status === 204) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
return response.json();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,cAAc,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,eAAe,EAA0B,MAAM,UAAU,CAAC;AAYnE;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACf,OAAO,CAAS;IAChB,OAAO,CAAe;IACtB,GAAG,CAAS;IACZ,QAAQ,CAAS;IACjB,IAAI,CAAa;IACjB,OAAO,CAAS;IACjB,YAAY,GAAkB,IAAI,CAAC;IAE3C,YAAY,EAAE,GAAG,EAAE,cAAc,EAAmD;QAClF,cAAc,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,QAAQ,CA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E,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;CAanF"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side notification methods for sending transactional emails.
|
|
3
|
-
*
|
|
4
|
-
* Access via `buildspace.notifications` on the server SDK.
|
|
5
|
-
* **Not available on the client SDK** — calling `buildspace.notifications`
|
|
6
|
-
* on the client throws a `BuildspaceError`.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* // Send a custom email
|
|
11
|
-
* await buildspace.notifications.send({
|
|
12
|
-
* to: "user@example.com",
|
|
13
|
-
* subject: "Welcome!",
|
|
14
|
-
* html: "<h1>You're in!</h1>",
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // Send from a saved template
|
|
18
|
-
* await buildspace.notifications.sendTemplate("welcome-email", {
|
|
19
|
-
* to: "user@example.com",
|
|
20
|
-
* variables: { firstName: "Alex" },
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export class NotificationsServerNamespace {
|
|
25
|
-
transport;
|
|
26
|
-
constructor(transport) {
|
|
27
|
-
this.transport = transport;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Send a custom email with inline HTML content.
|
|
31
|
-
*
|
|
32
|
-
* @param opts - Email content and recipient options.
|
|
33
|
-
* @returns The notification ID and optional provider message ID.
|
|
34
|
-
*/
|
|
35
|
-
send(opts) {
|
|
36
|
-
return this.transport.request({
|
|
37
|
-
service: "notifications",
|
|
38
|
-
path: "/v1/notifications/send",
|
|
39
|
-
method: "POST",
|
|
40
|
-
body: {
|
|
41
|
-
to: opts.to,
|
|
42
|
-
subject: opts.subject,
|
|
43
|
-
html: opts.html,
|
|
44
|
-
text: opts.text,
|
|
45
|
-
reply_to: opts.replyTo,
|
|
46
|
-
metadata: opts.metadata,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Send an email using a pre-configured template.
|
|
52
|
-
*
|
|
53
|
-
* Templates are created in the Buildspace Creator Studio.
|
|
54
|
-
*
|
|
55
|
-
* @param templateSlug - The slug of the template to use, e.g. `"welcome-email"`.
|
|
56
|
-
* @param opts - Recipient and template variable options.
|
|
57
|
-
* @returns The notification ID and optional provider message ID.
|
|
58
|
-
*/
|
|
59
|
-
sendTemplate(templateSlug, opts) {
|
|
60
|
-
return this.transport.request({
|
|
61
|
-
service: "notifications",
|
|
62
|
-
path: "/v1/notifications/send-template",
|
|
63
|
-
method: "POST",
|
|
64
|
-
body: {
|
|
65
|
-
template: templateSlug,
|
|
66
|
-
to: opts.to,
|
|
67
|
-
variables: opts.variables,
|
|
68
|
-
metadata: opts.metadata,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/notifications/server.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,4BAA4B;IACtB,SAAS,CAAgB;IAE1C,YAAY,SAAwB;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,IAAiB;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAa;YACxC,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,wBAAwB;YAC9B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,QAAQ,EAAE,IAAI,CAAC,OAAO;gBACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,CAAC,YAAoB,EAAE,IAAyB;QAC1D,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAa;YACxC,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,iCAAiC;YACvC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,QAAQ,EAAE,YAAY;gBACtB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/storage/client.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { HttpTransport } from "../http";
|
|
2
|
-
import type { StorageObject } from "./server";
|
|
3
|
-
/** Options for uploading a file from the client. */
|
|
4
|
-
export interface UploadOptions {
|
|
5
|
-
/** MIME type override. If omitted, inferred from the `File` object or defaults to `"application/octet-stream"`. */
|
|
6
|
-
contentType?: string;
|
|
7
|
-
/** Storage path/key for the file, e.g. `"avatars/user-123.png"`. */
|
|
8
|
-
path: string;
|
|
9
|
-
}
|
|
10
|
-
/** Result of a successful client-side file upload. */
|
|
11
|
-
export interface UploadResponse {
|
|
12
|
-
/** The resolved storage key. */
|
|
13
|
-
key: string;
|
|
14
|
-
/** File size in bytes. */
|
|
15
|
-
size: number;
|
|
16
|
-
/** Signed download URL for the uploaded file. */
|
|
17
|
-
url: string;
|
|
18
|
-
}
|
|
19
|
-
/** Result of requesting a signed download URL. */
|
|
20
|
-
export interface GetUrlResponse {
|
|
21
|
-
/** URL lifetime in seconds, if applicable. */
|
|
22
|
-
expiresIn?: number;
|
|
23
|
-
/** The storage key of the object. */
|
|
24
|
-
key: string;
|
|
25
|
-
/** The signed download URL. */
|
|
26
|
-
url: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Client-side storage methods for uploading and managing files.
|
|
30
|
-
*
|
|
31
|
-
* Access via `buildspace.storage` on the client SDK.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* // Upload a file (handles signed URL + PUT automatically)
|
|
36
|
-
* const { key, url } = await buildspace.storage.upload(file, {
|
|
37
|
-
* path: "avatars/user-123.png",
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* // Get a download URL for an existing file
|
|
41
|
-
* const { url } = await buildspace.storage.getUrl(key);
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare class StorageClientNamespace {
|
|
45
|
-
private readonly transport;
|
|
46
|
-
constructor(transport: HttpTransport);
|
|
47
|
-
/**
|
|
48
|
-
* Upload a `File` or `Blob` to Buildspace storage.
|
|
49
|
-
*
|
|
50
|
-
* This method handles the full upload flow:
|
|
51
|
-
* 1. Requests a pre-signed upload URL from the API
|
|
52
|
-
* 2. Uploads the file directly to the storage provider
|
|
53
|
-
* 3. Returns a signed download URL for the uploaded file
|
|
54
|
-
*
|
|
55
|
-
* @param file - The file or blob to upload.
|
|
56
|
-
* @param opts - Upload options including the storage path.
|
|
57
|
-
* @returns The storage key, file size, and a signed download URL.
|
|
58
|
-
*
|
|
59
|
-
* @throws {BuildspaceError} If the upload URL request or the direct upload fails.
|
|
60
|
-
*/
|
|
61
|
-
upload(file: File | Blob, opts: UploadOptions): Promise<UploadResponse>;
|
|
62
|
-
/**
|
|
63
|
-
* Get a time-limited signed URL for downloading a stored file.
|
|
64
|
-
*
|
|
65
|
-
* @param key - The storage key of the object.
|
|
66
|
-
* @param opts - Optional settings.
|
|
67
|
-
* @param opts.expiresIn - URL lifetime in seconds.
|
|
68
|
-
*/
|
|
69
|
-
getUrl(key: string, opts?: {
|
|
70
|
-
expiresIn?: number;
|
|
71
|
-
}): Promise<GetUrlResponse>;
|
|
72
|
-
/**
|
|
73
|
-
* List stored objects, optionally filtered by key prefix.
|
|
74
|
-
*
|
|
75
|
-
* @param prefix - Only return objects whose key starts with this prefix.
|
|
76
|
-
* @param opts - Pagination options.
|
|
77
|
-
*/
|
|
78
|
-
list(prefix?: string, opts?: {
|
|
79
|
-
limit?: number;
|
|
80
|
-
offset?: number;
|
|
81
|
-
}): Promise<{
|
|
82
|
-
objects: StorageObject[];
|
|
83
|
-
}>;
|
|
84
|
-
/**
|
|
85
|
-
* Delete a stored object by key.
|
|
86
|
-
*
|
|
87
|
-
* @param key - The storage key of the object to delete.
|
|
88
|
-
*/
|
|
89
|
-
delete(key: string): Promise<void>;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/storage/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,mHAAmH;IACnH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;gBAE9B,SAAS,EAAE,aAAa;IAIpC;;;;;;;;;;;;;OAaG;IACG,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAuC7E;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAW3E;;;;;OAKG;IACH,IAAI,CACF,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC;QAAE,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAYxC;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQzC"}
|
package/dist/storage/client.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { BuildspaceError } from "../errors";
|
|
2
|
-
/**
|
|
3
|
-
* Client-side storage methods for uploading and managing files.
|
|
4
|
-
*
|
|
5
|
-
* Access via `buildspace.storage` on the client SDK.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* // Upload a file (handles signed URL + PUT automatically)
|
|
10
|
-
* const { key, url } = await buildspace.storage.upload(file, {
|
|
11
|
-
* path: "avatars/user-123.png",
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* // Get a download URL for an existing file
|
|
15
|
-
* const { url } = await buildspace.storage.getUrl(key);
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class StorageClientNamespace {
|
|
19
|
-
transport;
|
|
20
|
-
constructor(transport) {
|
|
21
|
-
this.transport = transport;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Upload a `File` or `Blob` to Buildspace storage.
|
|
25
|
-
*
|
|
26
|
-
* This method handles the full upload flow:
|
|
27
|
-
* 1. Requests a pre-signed upload URL from the API
|
|
28
|
-
* 2. Uploads the file directly to the storage provider
|
|
29
|
-
* 3. Returns a signed download URL for the uploaded file
|
|
30
|
-
*
|
|
31
|
-
* @param file - The file or blob to upload.
|
|
32
|
-
* @param opts - Upload options including the storage path.
|
|
33
|
-
* @returns The storage key, file size, and a signed download URL.
|
|
34
|
-
*
|
|
35
|
-
* @throws {BuildspaceError} If the upload URL request or the direct upload fails.
|
|
36
|
-
*/
|
|
37
|
-
async upload(file, opts) {
|
|
38
|
-
const contentType = opts.contentType ?? (file instanceof File ? file.type : "application/octet-stream");
|
|
39
|
-
const signed = await this.transport.request({
|
|
40
|
-
service: "storage",
|
|
41
|
-
path: "/v1/storage/upload",
|
|
42
|
-
method: "POST",
|
|
43
|
-
body: {
|
|
44
|
-
path: opts.path,
|
|
45
|
-
content_type: contentType,
|
|
46
|
-
size: file.size,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
const response = await this.transport.fetcher(signed.upload_url, {
|
|
50
|
-
method: "PUT",
|
|
51
|
-
headers: { "Content-Type": contentType },
|
|
52
|
-
body: file,
|
|
53
|
-
});
|
|
54
|
-
if (!response.ok) {
|
|
55
|
-
throw new BuildspaceError({
|
|
56
|
-
service: "storage",
|
|
57
|
-
status: response.status,
|
|
58
|
-
code: "storage/upload-failed",
|
|
59
|
-
message: `Direct upload failed: ${response.statusText}`,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const { url } = await this.getUrl(signed.key);
|
|
63
|
-
return {
|
|
64
|
-
key: signed.key,
|
|
65
|
-
size: file.size,
|
|
66
|
-
url,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Get a time-limited signed URL for downloading a stored file.
|
|
71
|
-
*
|
|
72
|
-
* @param key - The storage key of the object.
|
|
73
|
-
* @param opts - Optional settings.
|
|
74
|
-
* @param opts.expiresIn - URL lifetime in seconds.
|
|
75
|
-
*/
|
|
76
|
-
getUrl(key, opts) {
|
|
77
|
-
return this.transport.request({
|
|
78
|
-
service: "storage",
|
|
79
|
-
path: "/v1/storage/url",
|
|
80
|
-
query: {
|
|
81
|
-
key,
|
|
82
|
-
expires_in: opts?.expiresIn,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* List stored objects, optionally filtered by key prefix.
|
|
88
|
-
*
|
|
89
|
-
* @param prefix - Only return objects whose key starts with this prefix.
|
|
90
|
-
* @param opts - Pagination options.
|
|
91
|
-
*/
|
|
92
|
-
list(prefix, opts) {
|
|
93
|
-
return this.transport.request({
|
|
94
|
-
service: "storage",
|
|
95
|
-
path: "/v1/storage/objects",
|
|
96
|
-
query: {
|
|
97
|
-
prefix,
|
|
98
|
-
limit: opts?.limit,
|
|
99
|
-
offset: opts?.offset,
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Delete a stored object by key.
|
|
105
|
-
*
|
|
106
|
-
* @param key - The storage key of the object to delete.
|
|
107
|
-
*/
|
|
108
|
-
async delete(key) {
|
|
109
|
-
await this.transport.request({
|
|
110
|
-
service: "storage",
|
|
111
|
-
path: "/v1/storage/object",
|
|
112
|
-
method: "DELETE",
|
|
113
|
-
body: { key },
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/storage/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgC5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,sBAAsB;IAChB,SAAS,CAAgB;IAE1C,YAAY,SAAwB;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;OAaG;IAC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CAAC,OAAO,CAAiB;YAC5C,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE;gBACL,GAAG;gBACH,UAAU,EAAE,IAAI,EAAE,SAAS;aAC5B;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,IAAI,CACF,MAAe,EACf,IAA0C;QAE1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAA+B;YAC1D,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE;gBACL,MAAM;gBACN,KAAK,EAAE,IAAI,EAAE,KAAK;gBAClB,MAAM,EAAE,IAAI,EAAE,MAAM;aACrB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAO;YACjC,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,EAAE,GAAG,EAAE;SACd,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/storage/server.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { HttpTransport } from "../http";
|
|
2
|
-
/** Options for requesting a pre-signed upload URL on the server. */
|
|
3
|
-
export interface ServerUploadOptions {
|
|
4
|
-
/** MIME type of the file, e.g. `"image/png"`. */
|
|
5
|
-
contentType: string;
|
|
6
|
-
/** Storage path/key for the file, e.g. `"avatars/user-123.png"`. */
|
|
7
|
-
key: string;
|
|
8
|
-
/** File size in bytes. */
|
|
9
|
-
size: number;
|
|
10
|
-
}
|
|
11
|
-
/** Metadata for a stored object. */
|
|
12
|
-
export interface StorageObject {
|
|
13
|
-
/** MIME type of the stored file. */
|
|
14
|
-
contentType: string;
|
|
15
|
-
/** ISO 8601 timestamp of when the object was created. */
|
|
16
|
-
createdAt: string;
|
|
17
|
-
/** Unique object identifier. */
|
|
18
|
-
id: string;
|
|
19
|
-
/** Storage key/path of the object. */
|
|
20
|
-
key: string;
|
|
21
|
-
/** File size in bytes. */
|
|
22
|
-
size: number;
|
|
23
|
-
/** ID of the user who uploaded the object, or `null` if uploaded via server key. */
|
|
24
|
-
uploadedBy: string | null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Server-side storage methods for managing file uploads and downloads.
|
|
28
|
-
*
|
|
29
|
-
* Access via `buildspace.storage` on the server SDK.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* // Get a pre-signed upload URL
|
|
34
|
-
* const { upload_url, key } = await buildspace.storage.getUploadUrl({
|
|
35
|
-
* key: "avatars/user-123.png",
|
|
36
|
-
* contentType: "image/png",
|
|
37
|
-
* size: file.size,
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* // Upload directly to the signed URL
|
|
41
|
-
* await fetch(upload_url, { method: "PUT", body: file });
|
|
42
|
-
*
|
|
43
|
-
* // Get a signed download URL
|
|
44
|
-
* const { url } = await buildspace.storage.getSignedUrl(key);
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare class StorageServerNamespace {
|
|
48
|
-
private readonly transport;
|
|
49
|
-
constructor(transport: HttpTransport);
|
|
50
|
-
/**
|
|
51
|
-
* Request a pre-signed URL for direct file upload.
|
|
52
|
-
*
|
|
53
|
-
* @param opts - Upload options including the storage key, content type, and file size.
|
|
54
|
-
* @returns The signed upload URL, the resolved key, and expiry time in seconds.
|
|
55
|
-
*/
|
|
56
|
-
getUploadUrl(opts: ServerUploadOptions): Promise<{
|
|
57
|
-
expires_in: number;
|
|
58
|
-
key: string;
|
|
59
|
-
upload_url: string;
|
|
60
|
-
}>;
|
|
61
|
-
/**
|
|
62
|
-
* Get a time-limited signed URL for downloading a stored file.
|
|
63
|
-
*
|
|
64
|
-
* @param key - The storage key of the object.
|
|
65
|
-
* @param opts - Optional settings.
|
|
66
|
-
* @param opts.expiresIn - URL lifetime in seconds. Uses server default if omitted.
|
|
67
|
-
*/
|
|
68
|
-
getSignedUrl(key: string, opts?: {
|
|
69
|
-
expiresIn?: number;
|
|
70
|
-
}): Promise<{
|
|
71
|
-
expiresIn?: number;
|
|
72
|
-
key: string;
|
|
73
|
-
url: string;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* List stored objects, optionally filtered by key prefix.
|
|
77
|
-
*
|
|
78
|
-
* @param prefix - Only return objects whose key starts with this prefix, e.g. `"avatars/"`.
|
|
79
|
-
* @param opts - Pagination options.
|
|
80
|
-
*/
|
|
81
|
-
list(prefix?: string, opts?: {
|
|
82
|
-
limit?: number;
|
|
83
|
-
offset?: number;
|
|
84
|
-
}): Promise<{
|
|
85
|
-
objects: StorageObject[];
|
|
86
|
-
}>;
|
|
87
|
-
/**
|
|
88
|
-
* Delete a stored object by key.
|
|
89
|
-
*
|
|
90
|
-
* @param key - The storage key of the object to delete.
|
|
91
|
-
*/
|
|
92
|
-
delete(key: string): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* Get current storage usage statistics for the app.
|
|
95
|
-
*
|
|
96
|
-
* @returns Byte counts and object count.
|
|
97
|
-
*/
|
|
98
|
-
getUsage(): Promise<{
|
|
99
|
-
maxStorageBytes: number;
|
|
100
|
-
objectCount: number;
|
|
101
|
-
storageBytes: number;
|
|
102
|
-
}>;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/storage/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,oEAAoE;AACpE,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oCAAoC;AACpC,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;gBAE9B,SAAS,EAAE,aAAa;IAIpC;;;;;OAKG;IACH,YAAY,CACV,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAanE;;;;;;OAMG;IACH,YAAY,CACV,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAW5D;;;;;OAKG;IACH,IAAI,CACF,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC;QAAE,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAYxC;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASxC;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CAUH"}
|
package/dist/storage/server.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side storage methods for managing file uploads and downloads.
|
|
3
|
-
*
|
|
4
|
-
* Access via `buildspace.storage` on the server SDK.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* // Get a pre-signed upload URL
|
|
9
|
-
* const { upload_url, key } = await buildspace.storage.getUploadUrl({
|
|
10
|
-
* key: "avatars/user-123.png",
|
|
11
|
-
* contentType: "image/png",
|
|
12
|
-
* size: file.size,
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* // Upload directly to the signed URL
|
|
16
|
-
* await fetch(upload_url, { method: "PUT", body: file });
|
|
17
|
-
*
|
|
18
|
-
* // Get a signed download URL
|
|
19
|
-
* const { url } = await buildspace.storage.getSignedUrl(key);
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export class StorageServerNamespace {
|
|
23
|
-
transport;
|
|
24
|
-
constructor(transport) {
|
|
25
|
-
this.transport = transport;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Request a pre-signed URL for direct file upload.
|
|
29
|
-
*
|
|
30
|
-
* @param opts - Upload options including the storage key, content type, and file size.
|
|
31
|
-
* @returns The signed upload URL, the resolved key, and expiry time in seconds.
|
|
32
|
-
*/
|
|
33
|
-
getUploadUrl(opts) {
|
|
34
|
-
return this.transport.request({
|
|
35
|
-
service: "storage",
|
|
36
|
-
path: "/v1/storage/upload",
|
|
37
|
-
method: "POST",
|
|
38
|
-
body: {
|
|
39
|
-
path: opts.key,
|
|
40
|
-
content_type: opts.contentType,
|
|
41
|
-
size: opts.size,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get a time-limited signed URL for downloading a stored file.
|
|
47
|
-
*
|
|
48
|
-
* @param key - The storage key of the object.
|
|
49
|
-
* @param opts - Optional settings.
|
|
50
|
-
* @param opts.expiresIn - URL lifetime in seconds. Uses server default if omitted.
|
|
51
|
-
*/
|
|
52
|
-
getSignedUrl(key, opts) {
|
|
53
|
-
return this.transport.request({
|
|
54
|
-
service: "storage",
|
|
55
|
-
path: "/v1/storage/url",
|
|
56
|
-
query: {
|
|
57
|
-
key,
|
|
58
|
-
expires_in: opts?.expiresIn,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* List stored objects, optionally filtered by key prefix.
|
|
64
|
-
*
|
|
65
|
-
* @param prefix - Only return objects whose key starts with this prefix, e.g. `"avatars/"`.
|
|
66
|
-
* @param opts - Pagination options.
|
|
67
|
-
*/
|
|
68
|
-
list(prefix, opts) {
|
|
69
|
-
return this.transport.request({
|
|
70
|
-
service: "storage",
|
|
71
|
-
path: "/v1/storage/objects",
|
|
72
|
-
query: {
|
|
73
|
-
prefix,
|
|
74
|
-
limit: opts?.limit,
|
|
75
|
-
offset: opts?.offset,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Delete a stored object by key.
|
|
81
|
-
*
|
|
82
|
-
* @param key - The storage key of the object to delete.
|
|
83
|
-
*/
|
|
84
|
-
async delete(key) {
|
|
85
|
-
await this.transport.request({
|
|
86
|
-
service: "storage",
|
|
87
|
-
path: "/v1/storage/object",
|
|
88
|
-
method: "DELETE",
|
|
89
|
-
body: { key },
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get current storage usage statistics for the app.
|
|
94
|
-
*
|
|
95
|
-
* @returns Byte counts and object count.
|
|
96
|
-
*/
|
|
97
|
-
getUsage() {
|
|
98
|
-
return this.transport.request({
|
|
99
|
-
service: "storage",
|
|
100
|
-
path: "/v1/storage/usage",
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/storage/server.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,sBAAsB;IAChB,SAAS,CAAgB;IAE1C,YAAY,SAAwB;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,YAAY,CACV,IAAyB;QAEzB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAA0D;YACrF,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI,CAAC,GAAG;gBACd,YAAY,EAAE,IAAI,CAAC,WAAW;gBAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CACV,GAAW,EACX,IAA6B;QAE7B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAmD;YAC9E,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE;gBACL,GAAG;gBACH,UAAU,EAAE,IAAI,EAAE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