@buildspacestudio/sdk 0.2.2 → 0.4.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.
Files changed (106) hide show
  1. package/README.md +126 -0
  2. package/dist/auth/index.cjs +259 -0
  3. package/dist/auth/index.cjs.map +1 -0
  4. package/dist/auth/index.d.cts +3 -0
  5. package/dist/auth/index.d.ts +3 -5
  6. package/dist/auth/index.js +255 -2
  7. package/dist/auth/index.js.map +1 -1
  8. package/dist/billing/index.cjs +226 -0
  9. package/dist/billing/index.cjs.map +1 -0
  10. package/dist/billing/index.d.cts +60 -0
  11. package/dist/billing/index.d.ts +60 -0
  12. package/dist/billing/index.js +222 -0
  13. package/dist/billing/index.js.map +1 -0
  14. package/dist/client/index.cjs +558 -0
  15. package/dist/client/index.cjs.map +1 -0
  16. package/dist/client/index.d.cts +89 -0
  17. package/dist/client/index.d.ts +12 -7
  18. package/dist/client/index.js +546 -105
  19. package/dist/client/index.js.map +1 -1
  20. package/dist/client-BYUWUiGZ.d.cts +143 -0
  21. package/dist/{auth/client.d.ts → client-ByNR5EZz.d.ts} +7 -5
  22. package/dist/client-D0vypxWb.d.cts +58 -0
  23. package/dist/{auth/client.js → client-D7bqvGJv.d.cts} +27 -30
  24. package/dist/{events/client.d.ts → client-DbGRRMt7.d.ts} +5 -3
  25. package/dist/client-d7kX5WfR.d.ts +143 -0
  26. package/dist/events/index.cjs +131 -0
  27. package/dist/events/index.cjs.map +1 -0
  28. package/dist/events/{server.d.ts → index.d.cts} +7 -4
  29. package/dist/events/index.d.ts +59 -4
  30. package/dist/events/index.js +127 -2
  31. package/dist/events/index.js.map +1 -1
  32. package/dist/http-D2gXpNpr.d.cts +100 -0
  33. package/dist/http-D2gXpNpr.d.ts +100 -0
  34. package/dist/index.cjs +1029 -0
  35. package/dist/index.cjs.map +1 -0
  36. package/dist/index.d.cts +92 -0
  37. package/dist/index.d.ts +21 -15
  38. package/dist/index.js +1010 -106
  39. package/dist/index.js.map +1 -1
  40. package/dist/next/index.cjs +183 -0
  41. package/dist/next/index.cjs.map +1 -0
  42. package/dist/next/index.d.cts +164 -0
  43. package/dist/next/index.d.ts +164 -0
  44. package/dist/next/index.js +172 -0
  45. package/dist/next/index.js.map +1 -0
  46. package/dist/notifications/index.cjs +56 -0
  47. package/dist/notifications/index.cjs.map +1 -0
  48. package/dist/notifications/{server.d.ts → index.d.cts} +8 -6
  49. package/dist/notifications/index.d.ts +79 -3
  50. package/dist/notifications/index.js +53 -1
  51. package/dist/notifications/index.js.map +1 -1
  52. package/dist/react/index.cjs +120 -0
  53. package/dist/react/index.cjs.map +1 -0
  54. package/dist/react/index.d.cts +567 -0
  55. package/dist/react/index.d.ts +567 -0
  56. package/dist/react/index.js +92 -0
  57. package/dist/react/index.js.map +1 -0
  58. package/dist/server-CoPDzSUP.d.cts +117 -0
  59. package/dist/{auth/server.d.ts → server-Suq3tZZC.d.ts} +8 -6
  60. package/dist/storage/index.cjs +213 -0
  61. package/dist/storage/index.cjs.map +1 -0
  62. package/dist/storage/index.d.cts +195 -0
  63. package/dist/storage/index.d.ts +195 -5
  64. package/dist/storage/index.js +209 -2
  65. package/dist/storage/index.js.map +1 -1
  66. package/package.json +124 -16
  67. package/dist/auth/client.d.ts.map +0 -1
  68. package/dist/auth/client.js.map +0 -1
  69. package/dist/auth/index.d.ts.map +0 -1
  70. package/dist/auth/server.d.ts.map +0 -1
  71. package/dist/auth/server.js +0 -148
  72. package/dist/auth/server.js.map +0 -1
  73. package/dist/client/index.d.ts.map +0 -1
  74. package/dist/config.d.ts +0 -40
  75. package/dist/config.d.ts.map +0 -1
  76. package/dist/config.js +0 -27
  77. package/dist/config.js.map +0 -1
  78. package/dist/errors.d.ts +0 -31
  79. package/dist/errors.d.ts.map +0 -1
  80. package/dist/errors.js +0 -30
  81. package/dist/errors.js.map +0 -1
  82. package/dist/events/client.d.ts.map +0 -1
  83. package/dist/events/client.js +0 -97
  84. package/dist/events/client.js.map +0 -1
  85. package/dist/events/index.d.ts.map +0 -1
  86. package/dist/events/server.d.ts.map +0 -1
  87. package/dist/events/server.js +0 -65
  88. package/dist/events/server.js.map +0 -1
  89. package/dist/http.d.ts +0 -39
  90. package/dist/http.d.ts.map +0 -1
  91. package/dist/http.js +0 -74
  92. package/dist/http.js.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/notifications/index.d.ts.map +0 -1
  95. package/dist/notifications/server.d.ts.map +0 -1
  96. package/dist/notifications/server.js +0 -73
  97. package/dist/notifications/server.js.map +0 -1
  98. package/dist/storage/client.d.ts +0 -91
  99. package/dist/storage/client.d.ts.map +0 -1
  100. package/dist/storage/client.js +0 -117
  101. package/dist/storage/client.js.map +0 -1
  102. package/dist/storage/index.d.ts.map +0 -1
  103. package/dist/storage/server.d.ts +0 -104
  104. package/dist/storage/server.d.ts.map +0 -1
  105. package/dist/storage/server.js +0 -104
  106. package/dist/storage/server.js.map +0 -1
@@ -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"}
@@ -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"}
@@ -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;IACH,KAAK,CAAC,MAAM,CAAC,IAAiB,EAAE,IAAmB;QACjD,MAAM,WAAW,GACf,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC;QAEtF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAsC;YAC/E,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,YAAY,EAAE,WAAW;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB;SACF,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE;YAC/D,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;YACxC,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CA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- {"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"}
@@ -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,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M,CAAC;KACtB,CAAC;CAUH"}
@@ -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,SAAS;aAC5B;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,IAAI,CACF,MAAe,EACf,IAA0C;QAE1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,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