@buildspacestudio/sdk 0.3.0 → 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 (54) hide show
  1. package/README.md +126 -0
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.cts +3 -118
  4. package/dist/auth/index.d.ts +3 -118
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/billing/index.cjs +226 -0
  7. package/dist/billing/index.cjs.map +1 -0
  8. package/dist/billing/index.d.cts +60 -0
  9. package/dist/billing/index.d.ts +60 -0
  10. package/dist/billing/index.js +222 -0
  11. package/dist/billing/index.js.map +1 -0
  12. package/dist/client/index.cjs +130 -0
  13. package/dist/client/index.cjs.map +1 -1
  14. package/dist/client/index.d.cts +7 -3
  15. package/dist/client/index.d.ts +7 -3
  16. package/dist/client/index.js +130 -0
  17. package/dist/client/index.js.map +1 -1
  18. package/dist/client-BYUWUiGZ.d.cts +143 -0
  19. package/dist/{client-BH7LbrKM.d.ts → client-ByNR5EZz.d.ts} +1 -1
  20. package/dist/{client-C67hy1kt.d.cts → client-D0vypxWb.d.cts} +1 -1
  21. package/dist/{client-DqWXAwCr.d.cts → client-D7bqvGJv.d.cts} +1 -1
  22. package/dist/{client-Dlif1JBf.d.ts → client-DbGRRMt7.d.ts} +1 -1
  23. package/dist/client-d7kX5WfR.d.ts +143 -0
  24. package/dist/events/index.d.cts +2 -2
  25. package/dist/events/index.d.ts +2 -2
  26. package/dist/{http-U-zzKmFF.d.cts → http-D2gXpNpr.d.cts} +2 -2
  27. package/dist/{http-U-zzKmFF.d.ts → http-D2gXpNpr.d.ts} +2 -2
  28. package/dist/index.cjs +228 -0
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +13 -8
  31. package/dist/index.d.ts +13 -8
  32. package/dist/index.js +226 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/next/index.cjs +183 -0
  35. package/dist/next/index.cjs.map +1 -0
  36. package/dist/next/index.d.cts +164 -0
  37. package/dist/next/index.d.ts +164 -0
  38. package/dist/next/index.js +172 -0
  39. package/dist/next/index.js.map +1 -0
  40. package/dist/notifications/index.d.cts +1 -1
  41. package/dist/notifications/index.d.ts +1 -1
  42. package/dist/react/index.cjs +120 -0
  43. package/dist/react/index.cjs.map +1 -0
  44. package/dist/react/index.d.cts +567 -0
  45. package/dist/react/index.d.ts +567 -0
  46. package/dist/react/index.js +92 -0
  47. package/dist/react/index.js.map +1 -0
  48. package/dist/server-CoPDzSUP.d.cts +117 -0
  49. package/dist/server-Suq3tZZC.d.ts +117 -0
  50. package/dist/storage/index.cjs.map +1 -1
  51. package/dist/storage/index.d.cts +1 -1
  52. package/dist/storage/index.d.ts +1 -1
  53. package/dist/storage/index.js.map +1 -1
  54. package/package.json +51 -2
@@ -1 +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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EAGA,IAAI,OAAA,GAAkC;AACpC,IAAA,IAAA,CAAK,QAAA,KAAa,IAAI,sBAAA,CAAuB,IAAA,CAAK,SAAS,CAAA;AAC3D,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.js","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"]}
1
+ {"version":3,"sources":["../../src/auth/client.ts","../../src/errors.ts","../../src/billing/shared.ts","../../src/billing/client.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,KAAA,EAAO,IAAA,C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** 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\" | \"billing\" | \"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 interface BillingProduct {\n active: boolean;\n createdAt: string;\n description: string | null;\n id: string;\n name: string;\n}\n\nexport interface BillingPrice {\n active: boolean;\n amountCents: number | null;\n createdAt: string;\n currency: string;\n id: string;\n interval: string | null;\n lookupKey: string | null;\n productId: string;\n productName: string;\n type: \"one_time\" | \"recurring\" | \"metered\";\n}\n\nexport interface CreateServerCheckoutOptions {\n appUserId?: string;\n cancelUrl: string;\n checkoutRequestId?: string;\n lookupKey?: string;\n metadata?: Record<string, string>;\n priceId?: string;\n quantity?: number;\n successUrl: string;\n userId?: string;\n}\n\nexport interface CreateClientCheckoutOptions {\n cancelUrl: string;\n checkoutRequestId?: string;\n lookupKey?: string;\n metadata?: Record<string, string>;\n priceId?: string;\n quantity?: number;\n successUrl: string;\n}\n\nexport interface BillingCheckoutResponse {\n id?: string;\n stripe_checkout_session_id: string;\n url: string;\n}\n\nexport interface BillingPortalResponse {\n url: string;\n}\n\nexport interface BillingSubscriptionResponse {\n subscription: {\n cancelAtPeriodEnd: boolean;\n currentPeriodEnd: string | null;\n id: string;\n status: string;\n } | null;\n}\n\nexport interface BillingEntitlementsResponse {\n active: boolean;\n subscription: { currentPeriodEnd: string | null; id: string; status: string } | null;\n}\n\nexport type BillingMode = \"test\" | \"live\";\n\nexport type BillingConfigStatus = \"disabled\" | \"setup_required\" | \"active\" | \"paused\";\n\nexport interface BillingStatusResponse {\n enabled: boolean;\n mode: BillingMode | null;\n status: BillingConfigStatus | null;\n testMode: boolean;\n}\n\n/**\n * True when the app environment is wired to a Stripe test-mode account.\n *\n * Use this to render a \"Test mode\" banner in your app — payments aren't real\n * charges, and end-buyers should not be expected to enter real card details.\n */\nexport function shouldShowTestBanner(status: BillingStatusResponse): boolean {\n return status.testMode;\n}\n\nexport interface CreateServerPortalSessionOptions {\n appUserId?: string;\n returnUrl: string;\n userId?: string;\n}\n\nexport interface CreateClientPortalSessionOptions {\n returnUrl: string;\n}\n\nexport function billingIdentityQuery(opts?: { appUserId?: string; userId?: string }) {\n return { app_user_id: opts?.appUserId, user_id: opts?.userId };\n}\n\nexport function checkoutRequestBody(\n opts: CreateServerCheckoutOptions | CreateClientCheckoutOptions\n) {\n return {\n app_user_id: \"appUserId\" in opts ? opts.appUserId : undefined,\n cancel_url: opts.cancelUrl,\n checkout_request_id: opts.checkoutRequestId,\n lookup_key: opts.lookupKey,\n metadata: opts.metadata,\n price_id: opts.priceId,\n quantity: opts.quantity,\n success_url: opts.successUrl,\n user_id: \"userId\" in opts ? opts.userId : undefined,\n };\n}\n\nexport function portalRequestBody(\n opts: CreateServerPortalSessionOptions | CreateClientPortalSessionOptions\n) {\n return {\n app_user_id: \"appUserId\" in opts ? opts.appUserId : undefined,\n return_url: opts.returnUrl,\n user_id: \"userId\" in opts ? opts.userId : undefined,\n };\n}\n","import type { HttpTransport } from \"../http\";\nimport {\n type BillingEntitlementsResponse,\n type BillingPortalResponse,\n type BillingPrice,\n type BillingProduct,\n type BillingStatusResponse,\n type BillingSubscriptionResponse,\n type CreateClientCheckoutOptions,\n type CreateClientPortalSessionOptions,\n checkoutRequestBody,\n portalRequestBody,\n} from \"./shared\";\n\nfunction redirectTo(url: string): void {\n const browser = globalThis as typeof globalThis & {\n window?: { location: { href: string } };\n };\n if (!browser.window?.location) {\n throw new Error(\"redirectToCheckout can only be used in a browser environment\");\n }\n browser.window.location.href = url;\n}\n\nexport class BillingClientNamespace {\n private readonly transport: HttpTransport;\n\n constructor(transport: HttpTransport) {\n this.transport = transport;\n }\n\n /**\n * Read whether billing is enabled for the app environment tied to this\n * publishable key, and whether the connected Stripe account is in test or\n * live mode.\n *\n * Render a \"Test mode\" banner in your app whenever `testMode` is true.\n */\n getStatus(): Promise<BillingStatusResponse> {\n return this.transport.request<BillingStatusResponse>({\n service: \"billing\",\n path: \"/v1/billing/status\",\n });\n }\n\n /**\n * List the active billing products for the app environment tied to this\n * publishable key.\n */\n listProducts(): Promise<{ products: BillingProduct[] }> {\n return this.transport.request<{ products: BillingProduct[] }>({\n service: \"billing\",\n path: \"/v1/billing/products\",\n });\n }\n\n /**\n * List the active billing prices for the app environment tied to this\n * publishable key.\n */\n listPrices(): Promise<{ prices: BillingPrice[] }> {\n return this.transport.request<{ prices: BillingPrice[] }>({\n service: \"billing\",\n path: \"/v1/billing/prices\",\n });\n }\n\n /**\n * Create a Checkout Session for the signed-in browser user and redirect to\n * the Stripe-hosted Checkout page.\n *\n * This method depends on a Buildspace session being available through\n * `setSession()` or your app's authenticated request context.\n */\n async redirectToCheckout(opts: CreateClientCheckoutOptions): Promise<void> {\n const checkout = await this.transport.request<{ url: string }>({\n service: \"billing\",\n path: \"/v1/billing/checkout\",\n method: \"POST\",\n body: checkoutRequestBody(opts),\n });\n redirectTo(checkout.url);\n }\n\n /**\n * Open the Stripe-hosted customer portal for the signed-in browser user.\n */\n async redirectToPortal(opts: CreateClientPortalSessionOptions): Promise<void> {\n const portal = await this.transport.request<BillingPortalResponse>({\n service: \"billing\",\n path: \"/v1/billing/portal\",\n method: \"POST\",\n body: portalRequestBody(opts),\n });\n redirectTo(portal.url);\n }\n\n /**\n * Discoverable alias for redirectToPortal — opens the Stripe-hosted customer\n * portal so the signed-in user can manage their subscription, payment method,\n * and invoices.\n */\n manageSubscription(opts: CreateClientPortalSessionOptions): Promise<void> {\n return this.redirectToPortal(opts);\n }\n\n /**\n * Read the current subscription state for the signed-in browser user.\n */\n getSubscription(): Promise<BillingSubscriptionResponse> {\n return this.transport.request<BillingSubscriptionResponse>({\n service: \"billing\",\n path: \"/v1/billing/subscription\",\n });\n }\n\n /**\n * Read the current paid entitlement state for the signed-in browser user.\n */\n getEntitlements(): Promise<BillingEntitlementsResponse> {\n return this.transport.request<BillingEntitlementsResponse>({\n service: \"billing\",\n path: \"/v1/billing/entitlements\",\n });\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 { BillingClientNamespace } from \"../billing\";\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 _billing: BillingClientNamespace | 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 billing: list prices and redirect to Checkout or Portal. */\n get billing(): BillingClientNamespace {\n this._billing ??= new BillingClientNamespace(this.transport);\n return this._billing;\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,143 @@
1
+ import { H as HttpTransport } from './http-D2gXpNpr.cjs';
2
+
3
+ interface BillingProduct {
4
+ active: boolean;
5
+ createdAt: string;
6
+ description: string | null;
7
+ id: string;
8
+ name: string;
9
+ }
10
+ interface BillingPrice {
11
+ active: boolean;
12
+ amountCents: number | null;
13
+ createdAt: string;
14
+ currency: string;
15
+ id: string;
16
+ interval: string | null;
17
+ lookupKey: string | null;
18
+ productId: string;
19
+ productName: string;
20
+ type: "one_time" | "recurring" | "metered";
21
+ }
22
+ interface CreateServerCheckoutOptions {
23
+ appUserId?: string;
24
+ cancelUrl: string;
25
+ checkoutRequestId?: string;
26
+ lookupKey?: string;
27
+ metadata?: Record<string, string>;
28
+ priceId?: string;
29
+ quantity?: number;
30
+ successUrl: string;
31
+ userId?: string;
32
+ }
33
+ interface CreateClientCheckoutOptions {
34
+ cancelUrl: string;
35
+ checkoutRequestId?: string;
36
+ lookupKey?: string;
37
+ metadata?: Record<string, string>;
38
+ priceId?: string;
39
+ quantity?: number;
40
+ successUrl: string;
41
+ }
42
+ interface BillingCheckoutResponse {
43
+ id?: string;
44
+ stripe_checkout_session_id: string;
45
+ url: string;
46
+ }
47
+ interface BillingPortalResponse {
48
+ url: string;
49
+ }
50
+ interface BillingSubscriptionResponse {
51
+ subscription: {
52
+ cancelAtPeriodEnd: boolean;
53
+ currentPeriodEnd: string | null;
54
+ id: string;
55
+ status: string;
56
+ } | null;
57
+ }
58
+ interface BillingEntitlementsResponse {
59
+ active: boolean;
60
+ subscription: {
61
+ currentPeriodEnd: string | null;
62
+ id: string;
63
+ status: string;
64
+ } | null;
65
+ }
66
+ type BillingMode = "test" | "live";
67
+ type BillingConfigStatus = "disabled" | "setup_required" | "active" | "paused";
68
+ interface BillingStatusResponse {
69
+ enabled: boolean;
70
+ mode: BillingMode | null;
71
+ status: BillingConfigStatus | null;
72
+ testMode: boolean;
73
+ }
74
+ /**
75
+ * True when the app environment is wired to a Stripe test-mode account.
76
+ *
77
+ * Use this to render a "Test mode" banner in your app — payments aren't real
78
+ * charges, and end-buyers should not be expected to enter real card details.
79
+ */
80
+ declare function shouldShowTestBanner(status: BillingStatusResponse): boolean;
81
+ interface CreateServerPortalSessionOptions {
82
+ appUserId?: string;
83
+ returnUrl: string;
84
+ userId?: string;
85
+ }
86
+ interface CreateClientPortalSessionOptions {
87
+ returnUrl: string;
88
+ }
89
+
90
+ declare class BillingClientNamespace {
91
+ private readonly transport;
92
+ constructor(transport: HttpTransport);
93
+ /**
94
+ * Read whether billing is enabled for the app environment tied to this
95
+ * publishable key, and whether the connected Stripe account is in test or
96
+ * live mode.
97
+ *
98
+ * Render a "Test mode" banner in your app whenever `testMode` is true.
99
+ */
100
+ getStatus(): Promise<BillingStatusResponse>;
101
+ /**
102
+ * List the active billing products for the app environment tied to this
103
+ * publishable key.
104
+ */
105
+ listProducts(): Promise<{
106
+ products: BillingProduct[];
107
+ }>;
108
+ /**
109
+ * List the active billing prices for the app environment tied to this
110
+ * publishable key.
111
+ */
112
+ listPrices(): Promise<{
113
+ prices: BillingPrice[];
114
+ }>;
115
+ /**
116
+ * Create a Checkout Session for the signed-in browser user and redirect to
117
+ * the Stripe-hosted Checkout page.
118
+ *
119
+ * This method depends on a Buildspace session being available through
120
+ * `setSession()` or your app's authenticated request context.
121
+ */
122
+ redirectToCheckout(opts: CreateClientCheckoutOptions): Promise<void>;
123
+ /**
124
+ * Open the Stripe-hosted customer portal for the signed-in browser user.
125
+ */
126
+ redirectToPortal(opts: CreateClientPortalSessionOptions): Promise<void>;
127
+ /**
128
+ * Discoverable alias for redirectToPortal — opens the Stripe-hosted customer
129
+ * portal so the signed-in user can manage their subscription, payment method,
130
+ * and invoices.
131
+ */
132
+ manageSubscription(opts: CreateClientPortalSessionOptions): Promise<void>;
133
+ /**
134
+ * Read the current subscription state for the signed-in browser user.
135
+ */
136
+ getSubscription(): Promise<BillingSubscriptionResponse>;
137
+ /**
138
+ * Read the current paid entitlement state for the signed-in browser user.
139
+ */
140
+ getEntitlements(): Promise<BillingEntitlementsResponse>;
141
+ }
142
+
143
+ export { BillingClientNamespace as B, type CreateServerCheckoutOptions as C, type BillingCheckoutResponse as a, type BillingEntitlementsResponse as b, type BillingPortalResponse as c, type BillingPrice as d, type BillingProduct as e, type BillingStatusResponse as f, type BillingSubscriptionResponse as g, type CreateServerPortalSessionOptions as h, shouldShowTestBanner as s };
@@ -1,4 +1,4 @@
1
- import { H as HttpTransport } from './http-U-zzKmFF.js';
1
+ import { H as HttpTransport } from './http-D2gXpNpr.js';
2
2
 
3
3
  /** Options for generating a sign-in URL. */
4
4
  interface SignInUrlOptions {
@@ -1,4 +1,4 @@
1
- import { H as HttpTransport } from './http-U-zzKmFF.cjs';
1
+ import { H as HttpTransport } from './http-D2gXpNpr.cjs';
2
2
 
3
3
  /**
4
4
  * Client-side event tracking with automatic batching.
@@ -1,4 +1,4 @@
1
- import { H as HttpTransport } from './http-U-zzKmFF.cjs';
1
+ import { H as HttpTransport } from './http-D2gXpNpr.cjs';
2
2
 
3
3
  /** Options for generating a sign-in URL. */
4
4
  interface SignInUrlOptions {
@@ -1,4 +1,4 @@
1
- import { H as HttpTransport } from './http-U-zzKmFF.js';
1
+ import { H as HttpTransport } from './http-D2gXpNpr.js';
2
2
 
3
3
  /**
4
4
  * Client-side event tracking with automatic batching.
@@ -0,0 +1,143 @@
1
+ import { H as HttpTransport } from './http-D2gXpNpr.js';
2
+
3
+ interface BillingProduct {
4
+ active: boolean;
5
+ createdAt: string;
6
+ description: string | null;
7
+ id: string;
8
+ name: string;
9
+ }
10
+ interface BillingPrice {
11
+ active: boolean;
12
+ amountCents: number | null;
13
+ createdAt: string;
14
+ currency: string;
15
+ id: string;
16
+ interval: string | null;
17
+ lookupKey: string | null;
18
+ productId: string;
19
+ productName: string;
20
+ type: "one_time" | "recurring" | "metered";
21
+ }
22
+ interface CreateServerCheckoutOptions {
23
+ appUserId?: string;
24
+ cancelUrl: string;
25
+ checkoutRequestId?: string;
26
+ lookupKey?: string;
27
+ metadata?: Record<string, string>;
28
+ priceId?: string;
29
+ quantity?: number;
30
+ successUrl: string;
31
+ userId?: string;
32
+ }
33
+ interface CreateClientCheckoutOptions {
34
+ cancelUrl: string;
35
+ checkoutRequestId?: string;
36
+ lookupKey?: string;
37
+ metadata?: Record<string, string>;
38
+ priceId?: string;
39
+ quantity?: number;
40
+ successUrl: string;
41
+ }
42
+ interface BillingCheckoutResponse {
43
+ id?: string;
44
+ stripe_checkout_session_id: string;
45
+ url: string;
46
+ }
47
+ interface BillingPortalResponse {
48
+ url: string;
49
+ }
50
+ interface BillingSubscriptionResponse {
51
+ subscription: {
52
+ cancelAtPeriodEnd: boolean;
53
+ currentPeriodEnd: string | null;
54
+ id: string;
55
+ status: string;
56
+ } | null;
57
+ }
58
+ interface BillingEntitlementsResponse {
59
+ active: boolean;
60
+ subscription: {
61
+ currentPeriodEnd: string | null;
62
+ id: string;
63
+ status: string;
64
+ } | null;
65
+ }
66
+ type BillingMode = "test" | "live";
67
+ type BillingConfigStatus = "disabled" | "setup_required" | "active" | "paused";
68
+ interface BillingStatusResponse {
69
+ enabled: boolean;
70
+ mode: BillingMode | null;
71
+ status: BillingConfigStatus | null;
72
+ testMode: boolean;
73
+ }
74
+ /**
75
+ * True when the app environment is wired to a Stripe test-mode account.
76
+ *
77
+ * Use this to render a "Test mode" banner in your app — payments aren't real
78
+ * charges, and end-buyers should not be expected to enter real card details.
79
+ */
80
+ declare function shouldShowTestBanner(status: BillingStatusResponse): boolean;
81
+ interface CreateServerPortalSessionOptions {
82
+ appUserId?: string;
83
+ returnUrl: string;
84
+ userId?: string;
85
+ }
86
+ interface CreateClientPortalSessionOptions {
87
+ returnUrl: string;
88
+ }
89
+
90
+ declare class BillingClientNamespace {
91
+ private readonly transport;
92
+ constructor(transport: HttpTransport);
93
+ /**
94
+ * Read whether billing is enabled for the app environment tied to this
95
+ * publishable key, and whether the connected Stripe account is in test or
96
+ * live mode.
97
+ *
98
+ * Render a "Test mode" banner in your app whenever `testMode` is true.
99
+ */
100
+ getStatus(): Promise<BillingStatusResponse>;
101
+ /**
102
+ * List the active billing products for the app environment tied to this
103
+ * publishable key.
104
+ */
105
+ listProducts(): Promise<{
106
+ products: BillingProduct[];
107
+ }>;
108
+ /**
109
+ * List the active billing prices for the app environment tied to this
110
+ * publishable key.
111
+ */
112
+ listPrices(): Promise<{
113
+ prices: BillingPrice[];
114
+ }>;
115
+ /**
116
+ * Create a Checkout Session for the signed-in browser user and redirect to
117
+ * the Stripe-hosted Checkout page.
118
+ *
119
+ * This method depends on a Buildspace session being available through
120
+ * `setSession()` or your app's authenticated request context.
121
+ */
122
+ redirectToCheckout(opts: CreateClientCheckoutOptions): Promise<void>;
123
+ /**
124
+ * Open the Stripe-hosted customer portal for the signed-in browser user.
125
+ */
126
+ redirectToPortal(opts: CreateClientPortalSessionOptions): Promise<void>;
127
+ /**
128
+ * Discoverable alias for redirectToPortal — opens the Stripe-hosted customer
129
+ * portal so the signed-in user can manage their subscription, payment method,
130
+ * and invoices.
131
+ */
132
+ manageSubscription(opts: CreateClientPortalSessionOptions): Promise<void>;
133
+ /**
134
+ * Read the current subscription state for the signed-in browser user.
135
+ */
136
+ getSubscription(): Promise<BillingSubscriptionResponse>;
137
+ /**
138
+ * Read the current paid entitlement state for the signed-in browser user.
139
+ */
140
+ getEntitlements(): Promise<BillingEntitlementsResponse>;
141
+ }
142
+
143
+ export { BillingClientNamespace as B, type CreateServerCheckoutOptions as C, type BillingCheckoutResponse as a, type BillingEntitlementsResponse as b, type BillingPortalResponse as c, type BillingPrice as d, type BillingProduct as e, type BillingStatusResponse as f, type BillingSubscriptionResponse as g, type CreateServerPortalSessionOptions as h, shouldShowTestBanner as s };
@@ -1,5 +1,5 @@
1
- export { E as EventsClientNamespace } from '../client-C67hy1kt.cjs';
2
- import { H as HttpTransport } from '../http-U-zzKmFF.cjs';
1
+ export { E as EventsClientNamespace } from '../client-D0vypxWb.cjs';
2
+ import { H as HttpTransport } from '../http-D2gXpNpr.cjs';
3
3
 
4
4
  /** An event to include in a batch tracking call. */
5
5
  interface ServerTrackedEvent {
@@ -1,5 +1,5 @@
1
- export { E as EventsClientNamespace } from '../client-Dlif1JBf.js';
2
- import { H as HttpTransport } from '../http-U-zzKmFF.js';
1
+ export { E as EventsClientNamespace } from '../client-DbGRRMt7.js';
2
+ import { H as HttpTransport } from '../http-D2gXpNpr.js';
3
3
 
4
4
  /** An event to include in a batch tracking call. */
5
5
  interface ServerTrackedEvent {
@@ -31,7 +31,7 @@ interface ResolvedConfig {
31
31
  }
32
32
 
33
33
  /** Services available in the Buildspace platform. */
34
- type BuildspaceService = "auth" | "events" | "notifications" | "storage";
34
+ type BuildspaceService = "auth" | "billing" | "events" | "notifications" | "storage";
35
35
  /**
36
36
  * Error thrown by all Buildspace SDK methods on failure.
37
37
  *
@@ -97,4 +97,4 @@ declare class HttpTransport {
97
97
  request<T>({ service, path, method, query, body, headers, keepalive, }: RequestOptions): Promise<T>;
98
98
  }
99
99
 
100
- export { type BuildspaceConfig as B, HttpTransport as H, type BuildspaceClientConfig as a, BuildspaceError as b, type BuildspaceService as c };
100
+ export { type BuildspaceClientConfig as B, HttpTransport as H, type BuildspaceConfig as a, BuildspaceError as b, type BuildspaceService as c };
@@ -31,7 +31,7 @@ interface ResolvedConfig {
31
31
  }
32
32
 
33
33
  /** Services available in the Buildspace platform. */
34
- type BuildspaceService = "auth" | "events" | "notifications" | "storage";
34
+ type BuildspaceService = "auth" | "billing" | "events" | "notifications" | "storage";
35
35
  /**
36
36
  * Error thrown by all Buildspace SDK methods on failure.
37
37
  *
@@ -97,4 +97,4 @@ declare class HttpTransport {
97
97
  request<T>({ service, path, method, query, body, headers, keepalive, }: RequestOptions): Promise<T>;
98
98
  }
99
99
 
100
- export { type BuildspaceConfig as B, HttpTransport as H, type BuildspaceClientConfig as a, BuildspaceError as b, type BuildspaceService as c };
100
+ export { type BuildspaceClientConfig as B, HttpTransport as H, type BuildspaceConfig as a, BuildspaceError as b, type BuildspaceService as c };