@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
@@ -0,0 +1,89 @@
1
+ import { A as AuthClientNamespace } from '../client-D7bqvGJv.cjs';
2
+ import { B as BuildspaceClientConfig } from '../http-D2gXpNpr.cjs';
3
+ import { B as BillingClientNamespace } from '../client-BYUWUiGZ.cjs';
4
+ import { E as EventsClientNamespace } from '../client-D0vypxWb.cjs';
5
+ import { StorageClientNamespace } from '../storage/index.cjs';
6
+
7
+ /**
8
+ * Buildspace client SDK — use with a publishable key (`bs_pub_*`).
9
+ *
10
+ * Provides client-safe access to auth URL generation, event tracking
11
+ * (with automatic batching), and file uploads. For server-side usage
12
+ * with full API access, use `new Buildspace()` from `@buildspacestudio/sdk`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { createClient } from "@buildspacestudio/sdk/client";
17
+ *
18
+ * const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);
19
+ *
20
+ * // Generate a sign-in URL
21
+ * const url = buildspace.auth.getSignInUrl({
22
+ * redirectUri: "https://yourapp.com/auth/callback",
23
+ * });
24
+ *
25
+ * // Track an event (fire and forget)
26
+ * buildspace.events.track("button.clicked", { label: "upgrade" });
27
+ *
28
+ * // Upload a file
29
+ * const { key, url } = await buildspace.storage.upload(file, {
30
+ * path: "avatars/user-123.png",
31
+ * });
32
+ * ```
33
+ */
34
+ declare class BuildspaceClient {
35
+ private readonly transport;
36
+ private readonly config;
37
+ private _auth;
38
+ private _billing;
39
+ private _events;
40
+ private _storage;
41
+ /**
42
+ * Create a new client SDK instance.
43
+ *
44
+ * @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).
45
+ * @param config - Optional configuration overrides.
46
+ */
47
+ constructor(publishableKey: string, config?: BuildspaceClientConfig);
48
+ /** Client-side auth: sign-in and sign-up URL generation. */
49
+ get auth(): AuthClientNamespace;
50
+ /** Client-side event tracking with automatic batching. */
51
+ get events(): EventsClientNamespace;
52
+ /** Client-side billing: list prices and redirect to Checkout or Portal. */
53
+ get billing(): BillingClientNamespace;
54
+ /** Client-side file storage: uploads, downloads, listing, deletion. */
55
+ get storage(): StorageClientNamespace;
56
+ /**
57
+ * Notifications are server-only and not available on the client SDK.
58
+ *
59
+ * @throws {BuildspaceError} Always throws — use the server SDK for notifications.
60
+ */
61
+ get notifications(): never;
62
+ /** Clear the stored session token. */
63
+ clearSession(): void;
64
+ /**
65
+ * Set a session token that will be sent as `X-Session-Token` on all
66
+ * subsequent API requests.
67
+ *
68
+ * @param sessionToken - The session token to attach to requests.
69
+ */
70
+ setSession(sessionToken: string): void;
71
+ }
72
+ /**
73
+ * Create a Buildspace client SDK instance.
74
+ *
75
+ * Preferred over `new BuildspaceClient()` for a more concise API.
76
+ *
77
+ * @param publishableKey - Your Buildspace publishable key (starts with `bs_pub_`).
78
+ * @param config - Optional configuration overrides.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import { createClient } from "@buildspacestudio/sdk/client";
83
+ *
84
+ * const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);
85
+ * ```
86
+ */
87
+ declare function createClient(publishableKey: string, config?: BuildspaceClientConfig): BuildspaceClient;
88
+
89
+ export { BuildspaceClient, createClient };
@@ -1,7 +1,9 @@
1
- import { AuthClientNamespace } from "../auth";
2
- import { type BuildspaceClientConfig } from "../config";
3
- import { EventsClientNamespace } from "../events";
4
- import { StorageClientNamespace } from "../storage";
1
+ import { A as AuthClientNamespace } from '../client-ByNR5EZz.js';
2
+ import { B as BuildspaceClientConfig } from '../http-D2gXpNpr.js';
3
+ import { B as BillingClientNamespace } from '../client-d7kX5WfR.js';
4
+ import { E as EventsClientNamespace } from '../client-DbGRRMt7.js';
5
+ import { StorageClientNamespace } from '../storage/index.js';
6
+
5
7
  /**
6
8
  * Buildspace client SDK — use with a publishable key (`bs_pub_*`).
7
9
  *
@@ -33,6 +35,7 @@ declare class BuildspaceClient {
33
35
  private readonly transport;
34
36
  private readonly config;
35
37
  private _auth;
38
+ private _billing;
36
39
  private _events;
37
40
  private _storage;
38
41
  /**
@@ -46,6 +49,8 @@ declare class BuildspaceClient {
46
49
  get auth(): AuthClientNamespace;
47
50
  /** Client-side event tracking with automatic batching. */
48
51
  get events(): EventsClientNamespace;
52
+ /** Client-side billing: list prices and redirect to Checkout or Portal. */
53
+ get billing(): BillingClientNamespace;
49
54
  /** Client-side file storage: uploads, downloads, listing, deletion. */
50
55
  get storage(): StorageClientNamespace;
51
56
  /**
@@ -79,6 +84,6 @@ declare class BuildspaceClient {
79
84
  * const buildspace = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_KEY!);
80
85
  * ```
81
86
  */
82
- export declare function createClient(publishableKey: string, config?: BuildspaceClientConfig): BuildspaceClient;
83
- export { BuildspaceClient };
84
- //# sourceMappingURL=index.d.ts.map
87
+ declare function createClient(publishableKey: string, config?: BuildspaceClientConfig): BuildspaceClient;
88
+
89
+ export { BuildspaceClient, createClient };