@buildbase/sdk 0.0.82 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -3
- package/CHANGELOG.md +95 -0
- package/README.md +138 -41
- package/dist/css/styles.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +288 -8
- package/dist/index.mjs +1 -1
- package/dist/mcp/index.cjs +1 -1
- package/dist/mcp/index.d.ts +40 -0
- package/dist/mcp/index.mjs +1 -1
- package/dist/react/chunks/SettingsDialog-DImZc0fo.cjs +2 -0
- package/dist/react/chunks/SettingsDialog-DuqMmX00.mjs +2 -0
- package/dist/react/chunks/{SubscriptionDialog-CuUoM9hd.cjs → SubscriptionDialog-C4I66PXv.cjs} +1 -1
- package/dist/react/chunks/{SubscriptionDialog-ClWD2NgN.mjs → SubscriptionDialog-hXscplmw.mjs} +1 -1
- package/dist/react/chunks/ar-Bv7MJdID.mjs +2 -0
- package/dist/react/chunks/ar-UyL2IcEN.cjs +2 -0
- package/dist/react/chunks/de-BjV4j4L8.mjs +2 -0
- package/dist/react/chunks/de-BpFTP77W.cjs +2 -0
- package/dist/react/chunks/es-BD83AlAI.mjs +2 -0
- package/dist/react/chunks/es-Cg0WHGyt.cjs +2 -0
- package/dist/react/chunks/fr-DC4nKToc.cjs +2 -0
- package/dist/react/chunks/fr-DUSYz0eM.mjs +2 -0
- package/dist/react/chunks/hi-BUaHa-qu.mjs +2 -0
- package/dist/react/chunks/hi-LZW4ZZQj.cjs +2 -0
- package/dist/react/chunks/ja-BYVJft1g.cjs +2 -0
- package/dist/react/chunks/ja-CXjz9Ptf.mjs +2 -0
- package/dist/react/chunks/react-BW__KLHg.mjs +2 -0
- package/dist/react/chunks/react-BoHqKQID.cjs +2 -0
- package/dist/react/chunks/zh-BBVxXvHQ.mjs +2 -0
- package/dist/react/chunks/zh-BtxE6oq5.cjs +2 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.ts +189 -6
- package/dist/react/index.mjs +1 -1
- package/docs/ARCHITECTURE.md +7 -6
- package/docs/ERROR_CODES.md +35 -0
- package/docs/MCP-AND-AGENT-READINESS.md +1 -1
- package/docs/SERVER-CONTENT.md +10 -5
- package/package.json +2 -1
- package/dist/react/chunks/SettingsDialog-B0s01DfC.cjs +0 -2
- package/dist/react/chunks/SettingsDialog-BDzOpoTW.mjs +0 -2
- package/dist/react/chunks/ar-4O9xrkV6.mjs +0 -2
- package/dist/react/chunks/ar-Dcph0Rl-.cjs +0 -2
- package/dist/react/chunks/de-D0wYkKfr.cjs +0 -2
- package/dist/react/chunks/de-ITC4I4gE.mjs +0 -2
- package/dist/react/chunks/es-D4d7IQzB.cjs +0 -2
- package/dist/react/chunks/es-DDUCoxrg.mjs +0 -2
- package/dist/react/chunks/fr-BomsBzOa.cjs +0 -2
- package/dist/react/chunks/fr-BsWwwise.mjs +0 -2
- package/dist/react/chunks/hi-BmpRGcI3.cjs +0 -2
- package/dist/react/chunks/hi-D5uXZGQc.mjs +0 -2
- package/dist/react/chunks/ja-D5amIGZT.cjs +0 -2
- package/dist/react/chunks/ja-DkMcdOxv.mjs +0 -2
- package/dist/react/chunks/react-Cs1KN_wQ.mjs +0 -2
- package/dist/react/chunks/react-DWVzbgNV.cjs +0 -2
- package/dist/react/chunks/zh-BRYcvEMm.cjs +0 -2
- package/dist/react/chunks/zh-C8cgAVXA.mjs +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,18 @@ interface IDocument {
|
|
|
6
6
|
updatedAt: string;
|
|
7
7
|
deleted: boolean;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The data-residency region an organisation's tenant stack runs in.
|
|
11
|
+
*
|
|
12
|
+
* `us` is the default cell, served worldwide from a global edge with US data
|
|
13
|
+
* residency; `eu` is the cell that exists so that EU customer data stays in
|
|
14
|
+
* the EU. The value is informational on the client: what actually decides
|
|
15
|
+
* which cell answers a request is the `serverUrl` the client was given, and
|
|
16
|
+
* on the server the audience the token is bound to. A client that sends an
|
|
17
|
+
* EU organisation's request to the default cell gets a 421 telling it where
|
|
18
|
+
* to go, not a silent cross-region read.
|
|
19
|
+
*/
|
|
20
|
+
type Region = 'us' | 'eu';
|
|
9
21
|
interface IUser extends IDocument {
|
|
10
22
|
_id: string;
|
|
11
23
|
name: string;
|
|
@@ -1119,6 +1131,16 @@ interface ISettings {
|
|
|
1119
1131
|
/** Auto-create workspace on first login */
|
|
1120
1132
|
autoCreateFirst: boolean;
|
|
1121
1133
|
};
|
|
1134
|
+
/**
|
|
1135
|
+
* What the organization lets its users upload (`useUpload`): whether they
|
|
1136
|
+
* may, and how large one file may be. Absent on a server from before
|
|
1137
|
+
* end-user uploads, which has no route to take them: `useUpload` then
|
|
1138
|
+
* reports uploads off.
|
|
1139
|
+
*/
|
|
1140
|
+
uploads?: {
|
|
1141
|
+
enabled: boolean;
|
|
1142
|
+
maxFileBytes: number;
|
|
1143
|
+
};
|
|
1122
1144
|
[key: string]: unknown;
|
|
1123
1145
|
}
|
|
1124
1146
|
|
|
@@ -1132,6 +1154,13 @@ interface IOsConfig {
|
|
|
1132
1154
|
serverUrl: string;
|
|
1133
1155
|
version: ApiVersion;
|
|
1134
1156
|
orgId: string;
|
|
1157
|
+
/**
|
|
1158
|
+
* The organisation's data-residency region, for UI badges and support
|
|
1159
|
+
* tooling. Informational: `serverUrl` is what decides which cell answers,
|
|
1160
|
+
* so a wrong value mislabels a badge and cannot misroute a request.
|
|
1161
|
+
* Undefined until the app passes it.
|
|
1162
|
+
*/
|
|
1163
|
+
region?: Region;
|
|
1135
1164
|
}
|
|
1136
1165
|
/** Lifecycle of the one-time org-settings fetch. */
|
|
1137
1166
|
type SettingsStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
@@ -1264,6 +1293,17 @@ declare abstract class BaseApi {
|
|
|
1264
1293
|
* Gets the same timeout, retry, header-merge, and error-callback handling as fetchResponse.
|
|
1265
1294
|
*/
|
|
1266
1295
|
protected fetchAbsoluteUrl(absoluteUrl: string, init?: RequestInit): Promise<Response>;
|
|
1296
|
+
/**
|
|
1297
|
+
* A request to a URL that is not ours - a signed storage URL, say. Sent with
|
|
1298
|
+
* the configured fetch and nothing else: no session, no custom headers, no
|
|
1299
|
+
* retries, because a signed URL must carry exactly the headers its
|
|
1300
|
+
* signature covers and must not learn the session.
|
|
1301
|
+
*
|
|
1302
|
+
* Bound to `globalThis` like every other call here: a browser's (and a
|
|
1303
|
+
* Worker's) `fetch` throws "Illegal invocation" when called as a method of
|
|
1304
|
+
* this object.
|
|
1305
|
+
*/
|
|
1306
|
+
protected fetchForeign(absoluteUrl: string, init?: RequestInit): Promise<Response>;
|
|
1267
1307
|
/**
|
|
1268
1308
|
* Throw an error from a failed response.
|
|
1269
1309
|
* Tries to parse JSON error body; falls back to status-based message.
|
|
@@ -1706,6 +1746,86 @@ declare class SettingsApi extends BaseApi {
|
|
|
1706
1746
|
getSettings(signal?: AbortSignal): Promise<ISettings>;
|
|
1707
1747
|
}
|
|
1708
1748
|
|
|
1749
|
+
/**
|
|
1750
|
+
* API client for files the signed-in user uploads: a workspace's image, a
|
|
1751
|
+
* profile picture. Session-authed, like every `/public` route.
|
|
1752
|
+
*
|
|
1753
|
+
* Three steps, the same as BuildBase's own console: an intent the server
|
|
1754
|
+
* checks before a byte moves (type, size, the organization's storage), a PUT
|
|
1755
|
+
* of the file straight to storage on the signed URL it answers, and a
|
|
1756
|
+
* complete that checks what landed and answers the stored file. The file
|
|
1757
|
+
* never passes through the API server, and it counts against the
|
|
1758
|
+
* organization's storage from the moment it is stored.
|
|
1759
|
+
*/
|
|
1760
|
+
|
|
1761
|
+
/** What an end user may upload for. */
|
|
1762
|
+
type UploadPurpose = 'workspace-image' | 'profile-image';
|
|
1763
|
+
/** Images only, as the server stores them. */
|
|
1764
|
+
declare const UPLOAD_ACCEPT = "image/png,image/jpeg,image/gif,image/webp,image/svg+xml";
|
|
1765
|
+
/**
|
|
1766
|
+
* The most one end-user file may ever be. The organization can set less, or
|
|
1767
|
+
* turn uploads off: `useUpload` reads both from its settings.
|
|
1768
|
+
*/
|
|
1769
|
+
declare const UPLOAD_MAX_BYTES: number;
|
|
1770
|
+
/** A stored file. `url` is public: it is meant to be shown. */
|
|
1771
|
+
interface IUploadedFile {
|
|
1772
|
+
id: string;
|
|
1773
|
+
name: string;
|
|
1774
|
+
size: number;
|
|
1775
|
+
mimeType: string;
|
|
1776
|
+
url: string;
|
|
1777
|
+
width: number;
|
|
1778
|
+
height: number;
|
|
1779
|
+
}
|
|
1780
|
+
interface UploadOptions {
|
|
1781
|
+
purpose: UploadPurpose;
|
|
1782
|
+
signal?: AbortSignal;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Why an upload did not go through, in terms a screen can translate. The
|
|
1786
|
+
* server's own sentence is English; its `status` and `code` are not.
|
|
1787
|
+
*/
|
|
1788
|
+
type UploadFailure = 'tooLarge' | 'invalid' | 'disabled' | 'userLimit' | 'unavailable' | 'failed';
|
|
1789
|
+
declare function uploadFailureOf(error: unknown): UploadFailure;
|
|
1790
|
+
/**
|
|
1791
|
+
* What the organization lets its users upload, as its public settings say
|
|
1792
|
+
* (`settings.uploads`). A server that does not say has no end-user uploads
|
|
1793
|
+
* (the platform sends `uploads` with the route that takes them), and neither
|
|
1794
|
+
* do settings still loading: uploads are off until the server says otherwise,
|
|
1795
|
+
* so an app never offers an upload that cannot succeed.
|
|
1796
|
+
*/
|
|
1797
|
+
interface UploadPolicy {
|
|
1798
|
+
enabled: boolean;
|
|
1799
|
+
maxFileBytes: number;
|
|
1800
|
+
}
|
|
1801
|
+
declare function uploadPolicyOf(settings: unknown): UploadPolicy;
|
|
1802
|
+
/**
|
|
1803
|
+
* Why a file cannot be uploaded, known before a byte is sent: uploads are
|
|
1804
|
+
* off, or the file is over the organization's limit. Null when it may go.
|
|
1805
|
+
*/
|
|
1806
|
+
declare function preflightUpload(file: {
|
|
1807
|
+
size: number;
|
|
1808
|
+
}, policy: UploadPolicy): UploadFailure | null;
|
|
1809
|
+
/** A byte limit as a person reads it, in their locale: "5 MB", "200 kB". */
|
|
1810
|
+
declare function formatUploadLimit(bytes: number, locale?: string): string;
|
|
1811
|
+
declare class UploadsApi extends BaseApi {
|
|
1812
|
+
constructor(config: Pick<IOsConfig, 'serverUrl' | 'version'> & {
|
|
1813
|
+
sessionId?: string;
|
|
1814
|
+
});
|
|
1815
|
+
/**
|
|
1816
|
+
* Upload one image and answer the stored file. A refusal throws the
|
|
1817
|
+
* server's own sentence with its `status` and `code` - 413
|
|
1818
|
+
* `UPLOAD_TOO_LARGE` for a file over the organization's limit, 403
|
|
1819
|
+
* `UPLOADS_DISABLED` or `USER_UPLOAD_LIMIT`, 429 for too many uploads, 503
|
|
1820
|
+
* `UPLOADS_UNAVAILABLE` when the organization cannot take files right now,
|
|
1821
|
+
* 501 when this server has no direct uploads. `uploadFailureOf` turns any
|
|
1822
|
+
* of them into a reason a screen can translate.
|
|
1823
|
+
*/
|
|
1824
|
+
upload(file: Blob & {
|
|
1825
|
+
name?: string;
|
|
1826
|
+
}, options: UploadOptions): Promise<IUploadedFile>;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1709
1829
|
/**
|
|
1710
1830
|
* API client for user attributes and features.
|
|
1711
1831
|
* Extends BaseApi for shared URL/auth/request handling.
|
|
@@ -2896,19 +3016,21 @@ declare function appPermissionCatalogue(settings?: SettingsLike | null, appPermi
|
|
|
2896
3016
|
|
|
2897
3017
|
/**
|
|
2898
3018
|
* Push notification service worker source code.
|
|
2899
|
-
*
|
|
3019
|
+
* Write this string to your app's `public/` directory in a prebuild step, so
|
|
3020
|
+
* the worker updates whenever the SDK does.
|
|
2900
3021
|
*
|
|
2901
3022
|
* @example
|
|
2902
3023
|
* ```ts
|
|
2903
|
-
* // scripts/
|
|
3024
|
+
* // scripts/write-push-sw.mjs, run as "prebuild" in package.json
|
|
2904
3025
|
* import { PUSH_SERVICE_WORKER_SCRIPT } from '@buildbase/sdk';
|
|
2905
3026
|
* import fs from 'fs';
|
|
2906
3027
|
* fs.writeFileSync('public/push-sw.js', PUSH_SERVICE_WORKER_SCRIPT);
|
|
2907
3028
|
* ```
|
|
2908
3029
|
*
|
|
2909
|
-
*
|
|
3030
|
+
* Do not paste a copy into `public/` by hand: a copy never picks up the
|
|
3031
|
+
* fixes a later SDK release makes to the worker.
|
|
2910
3032
|
*/
|
|
2911
|
-
declare const PUSH_SERVICE_WORKER_SCRIPT = "\n// BuildBase Push Notification Service Worker\n// Place this file in your app's public directory (e.g. public/push-sw.js)\n\nself.addEventListener('push', function(event) {\n if (!event.data) return;\n\n try {\n
|
|
3033
|
+
declare const PUSH_SERVICE_WORKER_SCRIPT = "\n// BuildBase Push Notification Service Worker\n// Place this file in your app's public directory (e.g. public/push-sw.js)\n\nself.addEventListener('push', function(event) {\n if (!event.data) return;\n\n let payload;\n try {\n payload = event.data.json();\n } catch (e) {\n console.error('[PushSW] Push payload is not JSON:', e);\n return;\n }\n if (!payload || typeof payload !== 'object') return;\n\n // i18n exception: service workers run outside the SDK's translation\n // provider, so this last-resort fallback stays English. The server should\n // always send a localized payload.title.\n const title = payload.title || 'Notification';\n // The tracked click URL (/api/push-track/link/...) wins over any url in\n // payload.data, so a click is always counted.\n const data = Object.assign({}, payload.data && typeof payload.data === 'object' ? payload.data : {});\n if (payload.url) data.url = payload.url;\n // A notification with the same tag replaces the earlier one instead of\n // stacking. No tag means every notification is shown on its own.\n const tag = payload.tag ? String(payload.tag) : undefined;\n const actions = Array.isArray(payload.actions)\n ? payload.actions.filter(function(a) {\n return a && typeof a.action === 'string' && typeof a.title === 'string';\n })\n : undefined;\n\n const options = {\n body: payload.body || '',\n icon: payload.icon || undefined,\n badge: payload.badge || payload.icon || undefined,\n image: payload.image || undefined,\n tag: tag,\n // The browser rejects renotify without a tag.\n renotify: tag ? !!payload.renotify : false,\n actions: actions && actions.length ? actions : undefined,\n silent: !!payload.silent,\n requireInteraction: !!payload.requireInteraction,\n timestamp: typeof payload.timestamp === 'number' ? payload.timestamp : undefined,\n dir: payload.dir === 'ltr' || payload.dir === 'rtl' ? payload.dir : 'auto',\n data: data,\n };\n\n event.waitUntil(\n Promise.resolve()\n .then(function() {\n return self.registration.showNotification(title, options);\n })\n .catch(function(e) {\n // A field this browser refuses must not cost the user the\n // notification: show it again with the basics only.\n console.error('[PushSW] Failed to show notification, retrying without rich options:', e);\n return self.registration.showNotification(title, {\n body: options.body,\n icon: options.icon,\n tag: tag,\n data: data,\n });\n })\n );\n});\n\nself.addEventListener('notificationclick', function(event) {\n event.notification.close();\n\n // A click on an action button (event.action is its id) opens the same\n // tracked URL as a click on the notification body.\n const url = event.notification.data && event.notification.data.url;\n if (url) {\n event.waitUntil(\n clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function(clientList) {\n for (let i = 0; i < clientList.length; i++) {\n const client = clientList[i];\n if (client.url === url && 'focus' in client) {\n return client.focus();\n }\n }\n if (clients.openWindow) {\n return clients.openWindow(url);\n }\n })\n );\n }\n});\n";
|
|
2912
3034
|
|
|
2913
3035
|
interface BetaFormData {
|
|
2914
3036
|
name?: string;
|
|
@@ -3354,6 +3476,8 @@ interface SDKMessages {
|
|
|
3354
3476
|
currency: string;
|
|
3355
3477
|
timezone: string;
|
|
3356
3478
|
profileImage: string;
|
|
3479
|
+
changePicture: string;
|
|
3480
|
+
removePicture: string;
|
|
3357
3481
|
success: string;
|
|
3358
3482
|
nameMinLength: string;
|
|
3359
3483
|
save: string;
|
|
@@ -3375,8 +3499,22 @@ interface SDKMessages {
|
|
|
3375
3499
|
success: string;
|
|
3376
3500
|
chooseEmoji: string;
|
|
3377
3501
|
customImageUrl: string;
|
|
3502
|
+
uploadImage: string;
|
|
3503
|
+
chooseImage: string;
|
|
3378
3504
|
updateWorkspace: string;
|
|
3379
3505
|
};
|
|
3506
|
+
uploads: {
|
|
3507
|
+
/** ICU: `{max}` is the organization's per-file limit, e.g. "5 MB". */
|
|
3508
|
+
description: string;
|
|
3509
|
+
uploading: string;
|
|
3510
|
+
/** ICU: `{max}`. */
|
|
3511
|
+
errorTooLarge: string;
|
|
3512
|
+
errorInvalid: string;
|
|
3513
|
+
errorDisabled: string;
|
|
3514
|
+
errorUserLimit: string;
|
|
3515
|
+
errorUnavailable: string;
|
|
3516
|
+
errorFailed: string;
|
|
3517
|
+
};
|
|
3380
3518
|
features: {
|
|
3381
3519
|
title: string;
|
|
3382
3520
|
ownerOnly: string;
|
|
@@ -4271,6 +4409,13 @@ interface AgentReadyConfig {
|
|
|
4271
4409
|
fetchTimeoutMs?: number;
|
|
4272
4410
|
/** Injectable fetch, mainly for testing. Defaults to the global `fetch`. */
|
|
4273
4411
|
fetch?: typeof fetch;
|
|
4412
|
+
/**
|
|
4413
|
+
* Where the platform fetches are cached. Defaults to process memory, which is
|
|
4414
|
+
* this module's long-standing behaviour. Pass a Redis, KV or Upstash-backed
|
|
4415
|
+
* store so every replica shares one copy instead of each fetching its own.
|
|
4416
|
+
* See `DiscoveryCacheStore`.
|
|
4417
|
+
*/
|
|
4418
|
+
cache?: DiscoveryCacheStore;
|
|
4274
4419
|
}
|
|
4275
4420
|
/** A rendered discovery document ready to become an HTTP response. */
|
|
4276
4421
|
interface DiscoveryDocument {
|
|
@@ -4292,6 +4437,35 @@ declare const AI_BOT_USER_AGENTS: readonly string[];
|
|
|
4292
4437
|
* Crypto / Node `crypto`), so output is identical on every runtime.
|
|
4293
4438
|
*/
|
|
4294
4439
|
declare function sha256Digest(content: string): string;
|
|
4440
|
+
/**
|
|
4441
|
+
* Where the two platform fetches below keep what they fetched.
|
|
4442
|
+
*
|
|
4443
|
+
* The default is process memory, which is what this module has always used and
|
|
4444
|
+
* is correct for one process. It is not wrong across replicas, only wasteful:
|
|
4445
|
+
* every pod fetches the same bundle independently, each honours its own TTL,
|
|
4446
|
+
* and `clearAgentReadinessCache()` clears the process it runs in and no other.
|
|
4447
|
+
* Pass a store backed by Redis, Cloudflare KV or Upstash to share one copy, the
|
|
4448
|
+
* same way `@buildbase/sdk/server`'s content client takes a `CacheStore`.
|
|
4449
|
+
*
|
|
4450
|
+
* Values are JSON strings, so a store needs nothing but string get and set.
|
|
4451
|
+
* Every call is wrapped: a store that throws, or takes longer than
|
|
4452
|
+
* `DISCOVERY_CACHE_TIMEOUT_MS` (500 ms), degrades to a cache miss (one extra
|
|
4453
|
+
* platform fetch), never to a failed or hung discovery response.
|
|
4454
|
+
*/
|
|
4455
|
+
interface DiscoveryCacheStore {
|
|
4456
|
+
/** The stored string, or `undefined` for a miss. */
|
|
4457
|
+
get(key: string): Promise<string | undefined> | string | undefined;
|
|
4458
|
+
/** Store `value` for at least `ttlSeconds`. */
|
|
4459
|
+
set(key: string, value: string, ttlSeconds: number): Promise<void> | void;
|
|
4460
|
+
/** Optional: drop one key. `clearAgentReadinessCache()` uses it when present. */
|
|
4461
|
+
delete?(key: string): Promise<void> | void;
|
|
4462
|
+
}
|
|
4463
|
+
/**
|
|
4464
|
+
* How long one store call may take before it counts as failed. A cache that
|
|
4465
|
+
* answers slower than the platform is no cache; without a bound, a hung
|
|
4466
|
+
* Redis would hang every discovery response with it.
|
|
4467
|
+
*/
|
|
4468
|
+
declare const DISCOVERY_CACHE_TIMEOUT_MS = 500;
|
|
4295
4469
|
/**
|
|
4296
4470
|
* Fetch (and cache) an org's agent-readiness bundle from the BuildBase server.
|
|
4297
4471
|
*
|
|
@@ -4300,8 +4474,16 @@ declare function sha256Digest(content: string): string;
|
|
|
4300
4474
|
* simply see the app as not (yet) agent-ready.
|
|
4301
4475
|
*/
|
|
4302
4476
|
declare function fetchAgentReadiness(config: AgentReadyConfig): Promise<AgentReadinessBundle>;
|
|
4303
|
-
/**
|
|
4304
|
-
|
|
4477
|
+
/**
|
|
4478
|
+
* Clear what this module cached.
|
|
4479
|
+
*
|
|
4480
|
+
* Always clears the built-in process-memory store (which is what tests want).
|
|
4481
|
+
* When a custom `cache` store was used, it also deletes the keys this process
|
|
4482
|
+
* wrote through it, if that store implements `delete`; keys written by another
|
|
4483
|
+
* process are not enumerable through the interface, so a shared store stays
|
|
4484
|
+
* the app's to invalidate.
|
|
4485
|
+
*/
|
|
4486
|
+
declare function clearAgentReadinessCache(store?: DiscoveryCacheStore): void;
|
|
4305
4487
|
/**
|
|
4306
4488
|
* The Agent Card served at `/.well-known/agent.json`. A stable, machine-readable
|
|
4307
4489
|
* entry point advertising who this app is and where agents can discover more.
|
|
@@ -4705,6 +4887,16 @@ interface BuildBaseConfig {
|
|
|
4705
4887
|
orgId: string;
|
|
4706
4888
|
/** API version (default: 'v1') */
|
|
4707
4889
|
version?: ApiVersion;
|
|
4890
|
+
/**
|
|
4891
|
+
* The region this client talks to, for logging, metrics and UI badges.
|
|
4892
|
+
*
|
|
4893
|
+
* Informational only. It is never sent on a request and never changes which
|
|
4894
|
+
* cell answers: `serverUrl` decides that, and on the server the real guard
|
|
4895
|
+
* is the audience the token is bound to (`buildbaseAuth({ resource })`).
|
|
4896
|
+
* Setting it wrong mislabels a log line; it cannot route a request to the
|
|
4897
|
+
* wrong region.
|
|
4898
|
+
*/
|
|
4899
|
+
region?: Region;
|
|
4708
4900
|
/**
|
|
4709
4901
|
* Async callback to resolve the current session ID.
|
|
4710
4902
|
* Called automatically before each authenticated API call.
|
|
@@ -5005,6 +5197,11 @@ interface ScopedActions {
|
|
|
5005
5197
|
sessions: SessionActions;
|
|
5006
5198
|
}
|
|
5007
5199
|
interface BuildBaseResult extends ScopedActions {
|
|
5200
|
+
/**
|
|
5201
|
+
* The `region` passed in config, or `undefined` when it was not set.
|
|
5202
|
+
* Informational: see `BuildBaseConfig.region`.
|
|
5203
|
+
*/
|
|
5204
|
+
region?: Region;
|
|
5008
5205
|
/**
|
|
5009
5206
|
* Check authentication. Returns session or null.
|
|
5010
5207
|
* Uses the `getSessionId` callback from config.
|
|
@@ -5048,6 +5245,7 @@ interface BuildBaseResult extends ScopedActions {
|
|
|
5048
5245
|
push: PushApi;
|
|
5049
5246
|
devices: DevicesApi;
|
|
5050
5247
|
sessions: SessionsApi;
|
|
5248
|
+
uploads: UploadsApi;
|
|
5051
5249
|
};
|
|
5052
5250
|
};
|
|
5053
5251
|
}
|
|
@@ -5253,5 +5451,87 @@ declare function buildbaseAuth(options: BuildBaseAuthOptions): {
|
|
|
5253
5451
|
resourceMetadataUrl?: string;
|
|
5254
5452
|
};
|
|
5255
5453
|
|
|
5256
|
-
|
|
5257
|
-
|
|
5454
|
+
/**
|
|
5455
|
+
* Resolve an organisation's regional `serverUrl` from central.
|
|
5456
|
+
*
|
|
5457
|
+
* Who needs this. Most apps serve one organisation and bake its `serverUrl`
|
|
5458
|
+
* into the build, which is why `BuildBase({ serverUrl })` takes it directly.
|
|
5459
|
+
* An app that hosts many organisations cannot: the right cell depends on which
|
|
5460
|
+
* organisation the request is for, and that is only known at runtime.
|
|
5461
|
+
*
|
|
5462
|
+
* Server-side only, deliberately. Resolving in the browser would mean a round
|
|
5463
|
+
* trip before the first API call on every page load, and the answer is not
|
|
5464
|
+
* secret but it is not interesting to a browser either: whatever the client
|
|
5465
|
+
* resolves, the server still has to be given the right URL.
|
|
5466
|
+
*
|
|
5467
|
+
* What it is NOT. This is a convenience, not a security boundary. Nothing here
|
|
5468
|
+
* decides which cell answers: `serverUrl` does, and the real guard is the
|
|
5469
|
+
* audience the token is bound to (`buildbaseAuth({ resource })`). A wrong
|
|
5470
|
+
* answer here produces a 421 from the cell that was asked, which is the signal
|
|
5471
|
+
* to re-resolve, not a cross-region read.
|
|
5472
|
+
*/
|
|
5473
|
+
interface RegionAnswer {
|
|
5474
|
+
orgId: string;
|
|
5475
|
+
region: Region | string;
|
|
5476
|
+
cellId: string;
|
|
5477
|
+
serverUrl: string;
|
|
5478
|
+
}
|
|
5479
|
+
interface ResolveServerUrlOptions {
|
|
5480
|
+
/** The organisation to resolve. */
|
|
5481
|
+
orgId: string;
|
|
5482
|
+
/** Central's base URL, for example `https://central.console.buildbase.app`. */
|
|
5483
|
+
centralUrl: string;
|
|
5484
|
+
/**
|
|
5485
|
+
* The organisation's API key (`<orgId>:<secret>`).
|
|
5486
|
+
*
|
|
5487
|
+
* Without it central answers the DEFAULT cell for every id, known or not, on
|
|
5488
|
+
* purpose: organisation ids are ObjectIds and an endpoint that distinguished
|
|
5489
|
+
* known from unknown would be an enumeration oracle. So an unauthenticated
|
|
5490
|
+
* call does not fail, it quietly returns the wrong cell for an EU
|
|
5491
|
+
* organisation. Pass the key.
|
|
5492
|
+
*/
|
|
5493
|
+
apiKey?: string;
|
|
5494
|
+
/** Request timeout. Default 5000 ms. */
|
|
5495
|
+
timeoutMs?: number;
|
|
5496
|
+
/** Injectable fetch, mainly for testing. */
|
|
5497
|
+
fetch?: typeof fetch;
|
|
5498
|
+
/**
|
|
5499
|
+
* Where to cache answers. Defaults to a process-memory map, which is the
|
|
5500
|
+
* right thing for one process; pass a shared store to let replicas reuse
|
|
5501
|
+
* each other's lookups.
|
|
5502
|
+
*/
|
|
5503
|
+
cache?: ResolveCacheStore;
|
|
5504
|
+
}
|
|
5505
|
+
/** Same shape as the discovery cache: string in, string out. */
|
|
5506
|
+
interface ResolveCacheStore {
|
|
5507
|
+
get(key: string): Promise<string | undefined> | string | undefined;
|
|
5508
|
+
set(key: string, value: string, ttlSeconds: number): Promise<void> | void;
|
|
5509
|
+
delete?(key: string): Promise<void> | void;
|
|
5510
|
+
}
|
|
5511
|
+
/**
|
|
5512
|
+
* Ask central where an organisation lives, with caching.
|
|
5513
|
+
*
|
|
5514
|
+
* Throws on a network or HTTP failure rather than guessing. A silent fallback
|
|
5515
|
+
* to the default cell is the one behaviour that must not be built in here:
|
|
5516
|
+
* for an EU organisation it would mean sending the request to the US, which is
|
|
5517
|
+
* precisely what the cell topology exists to prevent. The caller decides what
|
|
5518
|
+
* to do with the failure.
|
|
5519
|
+
*/
|
|
5520
|
+
declare function resolveServerUrl(options: ResolveServerUrlOptions): Promise<RegionAnswer>;
|
|
5521
|
+
/**
|
|
5522
|
+
* Forget a cached answer.
|
|
5523
|
+
*
|
|
5524
|
+
* Call it on a `421 misdirected_request`: that response is central's previous
|
|
5525
|
+
* answer being proved stale by the cell that received it, usually because the
|
|
5526
|
+
* organisation was migrated. Re-resolving once after a 421 is the documented
|
|
5527
|
+
* recovery; re-resolving in a loop is not, so the caller should retry the
|
|
5528
|
+
* request once and surface the second failure.
|
|
5529
|
+
*/
|
|
5530
|
+
declare function clearResolvedServerUrl(options: {
|
|
5531
|
+
orgId: string;
|
|
5532
|
+
centralUrl: string;
|
|
5533
|
+
cache?: ResolveCacheStore;
|
|
5534
|
+
}): Promise<void>;
|
|
5535
|
+
|
|
5536
|
+
export { AI_BOT_USER_AGENTS, APP_PERMISSION_FALLBACK_GROUP, ApiVersion, AppBridgeError, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, CreditBucketSource, CreditBucketStatus, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, DISCOVERY_CACHE_TIMEOUT_MS, DunningState, EventEmitter, FALLBACK_WORKSPACE_ROLE, INVITATION_ERROR_CODE, InvoiceStatuses, NotificationsApi, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PushApi, SDKEvent, SettingsApi, SubscriptionItemType, SubscriptionStatus, UPLOAD_ACCEPT, UPLOAD_MAX_BYTES, UploadsApi, UserApi, WEBHOOK_EVENTS, WEBHOOK_EVENTS_BY_CATEGORY, WorkspaceApi, actionableInvitations, appPermissionCatalogue, appTokenFailure, appTokenSuccess, bearerChallenge, buildA2AAgentCard, buildAgentCard, buildAgentSkillsIndex, buildApiCatalog, buildAuthMd, buildDiscoveryLinkHeader, buildDnsAidRecords, buildLlmsFullTxt, buildLlmsTxt, buildMcpDiscoveryManifest, buildMcpServerCard, buildProtectedResourceMetadata, buildRobotsTxt, buildSecurityTxt, buildSitemap, buildSkillMd, buildWebBotAuthDirectory, buildbaseAuth, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAgentReadinessCache, clearAuthIntent, clearPendingInvite, clearResolvedServerUrl, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, createSessionRefCrypto, BuildBase as default, eventEmitter, extractBearerToken, fetchAgentReadiness, formatCents, formatMinorAmountIntl, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, formatUploadLimit, getAvailableBillingIntervals, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyDecimals, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, handleAppRevokeRequest, handleAppTokenRequest, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, inviterNameOf, isInvitationActionable, isInvitationError, isInvitationLapsed, isWebhookEvent, isZeroDecimalCurrency, minorAmountToDisplay, mintAgentToken, negotiateMarkdown, parkPendingInvite, parseWebhookEvent, pickDefaultRole, preflightUpload, provideWebMcpTools, readBBParams, readPendingInvite, resendCooldownSeconds, resolveAgentPath, resolveMaxUsers, resolvePermissions, resolveRolePermissions, resolveServerUrl, resolveWellKnown, safeRedirect, saveAuthIntent, sha256Digest, signClientJwt, sortInvitations, uploadFailureOf, uploadPolicyOf, validateInvite, validateRedirectUrl, verifyAppRevokeRequest, verifyAppTokenRequest, verifyClientJwt, verifyWebhookSignature, wantsMarkdown, workspaceIdOf, workspaceNameOf };
|
|
5537
|
+
export type { A2ACardConfig, A2ACardSkill, AgentReadinessBundle, AgentReadyConfig, AgentSkill, ApiCatalogApi, AppRevokeRequestClaims, AppScope, AppTokenRequestClaims, AppTokenResponseBody, AppTokenResult, BBActionType, BBScreenType, BBStatusType, BetaFormData, BetaFormResponse, BillingInterval, BuildBaseAuthOptions, BuildBaseConfig, BuildBaseResult, BuildBaseSession, CheckoutResult, ContentSignals, CreditActions, CreditBucketSourceType, CreditBucketStatusType, CreditTransactionTypeValue, DiscoveryCacheStore, DiscoveryDocument, DnsAidRecord, DunningStateType, EventData, EventType, FeatureActions, FormatQuotaWithPriceOptions, GetCheckoutStripeParams, HandlerResult, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, INotificationItem, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, ISettings, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUploadedFile, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, IUser, IWorkspace, IWorkspaceInvitation, IWorkspaceInvitationPreview, IWorkspaceInvitationStatus, InvitationActions, InvitationError, InvitationErrorCode, InvitationErrorFields, InviteBlockReason, InviteValidation, InvoiceActions, InvoiceStatus, InvoiceStatusType, MaxUsersConfig, McpServerCard, MintAgentTokenOptions, MyNotificationPreferences, NotificationChannelPreference, NotificationCounts, NotificationData, NotificationEvent, NotificationListParams, NotificationPage, NotificationResult, NotificationScope, OnWorkspaceChangeParams, PermissionActions, PermissionContext, PermissionKey, PlanActions, PlanVersionWithPricingVariants, QuotaDisplayValue, QuotaDisplayWithOverage, RedirectValidationOptions, Region, RegionAnswer, ResolveCacheStore, ResolveServerUrlOptions, RobotsConfig, RobotsPolicy, RolePermissionMap, ScopedActions, SessionRefCrypto, SettingsActions, SitemapUrl, SubscriptionActions, SubscriptionItemTypeValue, SubscriptionStatusType, TranslationKey, UploadFailure, UploadOptions, UploadPolicy, UploadPurpose, UsageActions, UserActions, UserCreatedEventData, UserUpdatedEventData, WebMcpTool, WebhookEventName, WorkspaceActions, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceInvitationAcceptedEventData, WorkspaceInvitationDeclinedEventData, WorkspaceInvitationRevokedEventData, WorkspaceInvitationSentEventData, WorkspaceMemberPermissions, WorkspaceNotificationDefault, WorkspacePermissionDefinition, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|