@buildbase/sdk 0.0.83 → 0.0.85
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 +77 -0
- package/README.md +122 -2
- package/dist/css/styles.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +288 -7
- package/dist/index.mjs +1 -1
- package/dist/mcp/index.cjs +1 -1
- package/dist/mcp/index.d.ts +45 -2
- 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-DNuJHptx.cjs → SubscriptionDialog-C4I66PXv.cjs} +1 -1
- package/dist/react/chunks/{SubscriptionDialog-Bs5J1bDH.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 -5
- 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-Bm5N3G9q.cjs +0 -2
- package/dist/react/chunks/SettingsDialog-BzKi7eOI.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-7Ot04crv.mjs +0 -2
- package/dist/react/chunks/react-BwS8YQQF.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;
|
|
@@ -1096,8 +1108,11 @@ interface ISettings {
|
|
|
1096
1108
|
maxWorkspaceUsers: number;
|
|
1097
1109
|
/** Workspace mode: 'personal' (solo) or 'platform' (multi-user, default) */
|
|
1098
1110
|
mode: WorkspaceMode;
|
|
1099
|
-
/**
|
|
1100
|
-
|
|
1111
|
+
/**
|
|
1112
|
+
* Whether users can create workspaces themselves. `false` hides the create
|
|
1113
|
+
* button; auto-create on first sign-in, when on, still runs.
|
|
1114
|
+
*/
|
|
1115
|
+
canCreateWorkspace: boolean;
|
|
1101
1116
|
/** Whether members can invite others. false = disabled, 'admin-only' = restricted */
|
|
1102
1117
|
canInviteMembers: boolean | 'admin-only';
|
|
1103
1118
|
/** Custom role→permission mapping. Overrides SDK defaults when provided by backend. */
|
|
@@ -1119,6 +1134,16 @@ interface ISettings {
|
|
|
1119
1134
|
/** Auto-create workspace on first login */
|
|
1120
1135
|
autoCreateFirst: boolean;
|
|
1121
1136
|
};
|
|
1137
|
+
/**
|
|
1138
|
+
* What the organization lets its users upload (`useUpload`): whether they
|
|
1139
|
+
* may, and how large one file may be. Absent on a server from before
|
|
1140
|
+
* end-user uploads, which has no route to take them: `useUpload` then
|
|
1141
|
+
* reports uploads off.
|
|
1142
|
+
*/
|
|
1143
|
+
uploads?: {
|
|
1144
|
+
enabled: boolean;
|
|
1145
|
+
maxFileBytes: number;
|
|
1146
|
+
};
|
|
1122
1147
|
[key: string]: unknown;
|
|
1123
1148
|
}
|
|
1124
1149
|
|
|
@@ -1132,6 +1157,13 @@ interface IOsConfig {
|
|
|
1132
1157
|
serverUrl: string;
|
|
1133
1158
|
version: ApiVersion;
|
|
1134
1159
|
orgId: string;
|
|
1160
|
+
/**
|
|
1161
|
+
* The organisation's data-residency region, for UI badges and support
|
|
1162
|
+
* tooling. Informational: `serverUrl` is what decides which cell answers,
|
|
1163
|
+
* so a wrong value mislabels a badge and cannot misroute a request.
|
|
1164
|
+
* Undefined until the app passes it.
|
|
1165
|
+
*/
|
|
1166
|
+
region?: Region;
|
|
1135
1167
|
}
|
|
1136
1168
|
/** Lifecycle of the one-time org-settings fetch. */
|
|
1137
1169
|
type SettingsStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
@@ -1264,6 +1296,17 @@ declare abstract class BaseApi {
|
|
|
1264
1296
|
* Gets the same timeout, retry, header-merge, and error-callback handling as fetchResponse.
|
|
1265
1297
|
*/
|
|
1266
1298
|
protected fetchAbsoluteUrl(absoluteUrl: string, init?: RequestInit): Promise<Response>;
|
|
1299
|
+
/**
|
|
1300
|
+
* A request to a URL that is not ours - a signed storage URL, say. Sent with
|
|
1301
|
+
* the configured fetch and nothing else: no session, no custom headers, no
|
|
1302
|
+
* retries, because a signed URL must carry exactly the headers its
|
|
1303
|
+
* signature covers and must not learn the session.
|
|
1304
|
+
*
|
|
1305
|
+
* Bound to `globalThis` like every other call here: a browser's (and a
|
|
1306
|
+
* Worker's) `fetch` throws "Illegal invocation" when called as a method of
|
|
1307
|
+
* this object.
|
|
1308
|
+
*/
|
|
1309
|
+
protected fetchForeign(absoluteUrl: string, init?: RequestInit): Promise<Response>;
|
|
1267
1310
|
/**
|
|
1268
1311
|
* Throw an error from a failed response.
|
|
1269
1312
|
* Tries to parse JSON error body; falls back to status-based message.
|
|
@@ -1706,6 +1749,86 @@ declare class SettingsApi extends BaseApi {
|
|
|
1706
1749
|
getSettings(signal?: AbortSignal): Promise<ISettings>;
|
|
1707
1750
|
}
|
|
1708
1751
|
|
|
1752
|
+
/**
|
|
1753
|
+
* API client for files the signed-in user uploads: a workspace's image, a
|
|
1754
|
+
* profile picture. Session-authed, like every `/public` route.
|
|
1755
|
+
*
|
|
1756
|
+
* Three steps, the same as BuildBase's own console: an intent the server
|
|
1757
|
+
* checks before a byte moves (type, size, the organization's storage), a PUT
|
|
1758
|
+
* of the file straight to storage on the signed URL it answers, and a
|
|
1759
|
+
* complete that checks what landed and answers the stored file. The file
|
|
1760
|
+
* never passes through the API server, and it counts against the
|
|
1761
|
+
* organization's storage from the moment it is stored.
|
|
1762
|
+
*/
|
|
1763
|
+
|
|
1764
|
+
/** What an end user may upload for. */
|
|
1765
|
+
type UploadPurpose = 'workspace-image' | 'profile-image';
|
|
1766
|
+
/** Images only, as the server stores them. */
|
|
1767
|
+
declare const UPLOAD_ACCEPT = "image/png,image/jpeg,image/gif,image/webp,image/svg+xml";
|
|
1768
|
+
/**
|
|
1769
|
+
* The most one end-user file may ever be. The organization can set less, or
|
|
1770
|
+
* turn uploads off: `useUpload` reads both from its settings.
|
|
1771
|
+
*/
|
|
1772
|
+
declare const UPLOAD_MAX_BYTES: number;
|
|
1773
|
+
/** A stored file. `url` is public: it is meant to be shown. */
|
|
1774
|
+
interface IUploadedFile {
|
|
1775
|
+
id: string;
|
|
1776
|
+
name: string;
|
|
1777
|
+
size: number;
|
|
1778
|
+
mimeType: string;
|
|
1779
|
+
url: string;
|
|
1780
|
+
width: number;
|
|
1781
|
+
height: number;
|
|
1782
|
+
}
|
|
1783
|
+
interface UploadOptions {
|
|
1784
|
+
purpose: UploadPurpose;
|
|
1785
|
+
signal?: AbortSignal;
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Why an upload did not go through, in terms a screen can translate. The
|
|
1789
|
+
* server's own sentence is English; its `status` and `code` are not.
|
|
1790
|
+
*/
|
|
1791
|
+
type UploadFailure = 'tooLarge' | 'invalid' | 'disabled' | 'userLimit' | 'unavailable' | 'failed';
|
|
1792
|
+
declare function uploadFailureOf(error: unknown): UploadFailure;
|
|
1793
|
+
/**
|
|
1794
|
+
* What the organization lets its users upload, as its public settings say
|
|
1795
|
+
* (`settings.uploads`). A server that does not say has no end-user uploads
|
|
1796
|
+
* (the platform sends `uploads` with the route that takes them), and neither
|
|
1797
|
+
* do settings still loading: uploads are off until the server says otherwise,
|
|
1798
|
+
* so an app never offers an upload that cannot succeed.
|
|
1799
|
+
*/
|
|
1800
|
+
interface UploadPolicy {
|
|
1801
|
+
enabled: boolean;
|
|
1802
|
+
maxFileBytes: number;
|
|
1803
|
+
}
|
|
1804
|
+
declare function uploadPolicyOf(settings: unknown): UploadPolicy;
|
|
1805
|
+
/**
|
|
1806
|
+
* Why a file cannot be uploaded, known before a byte is sent: uploads are
|
|
1807
|
+
* off, or the file is over the organization's limit. Null when it may go.
|
|
1808
|
+
*/
|
|
1809
|
+
declare function preflightUpload(file: {
|
|
1810
|
+
size: number;
|
|
1811
|
+
}, policy: UploadPolicy): UploadFailure | null;
|
|
1812
|
+
/** A byte limit as a person reads it, in their locale: "5 MB", "200 kB". */
|
|
1813
|
+
declare function formatUploadLimit(bytes: number, locale?: string): string;
|
|
1814
|
+
declare class UploadsApi extends BaseApi {
|
|
1815
|
+
constructor(config: Pick<IOsConfig, 'serverUrl' | 'version'> & {
|
|
1816
|
+
sessionId?: string;
|
|
1817
|
+
});
|
|
1818
|
+
/**
|
|
1819
|
+
* Upload one image and answer the stored file. A refusal throws the
|
|
1820
|
+
* server's own sentence with its `status` and `code` - 413
|
|
1821
|
+
* `UPLOAD_TOO_LARGE` for a file over the organization's limit, 403
|
|
1822
|
+
* `UPLOADS_DISABLED` or `USER_UPLOAD_LIMIT`, 429 for too many uploads, 503
|
|
1823
|
+
* `UPLOADS_UNAVAILABLE` when the organization cannot take files right now,
|
|
1824
|
+
* 501 when this server has no direct uploads. `uploadFailureOf` turns any
|
|
1825
|
+
* of them into a reason a screen can translate.
|
|
1826
|
+
*/
|
|
1827
|
+
upload(file: Blob & {
|
|
1828
|
+
name?: string;
|
|
1829
|
+
}, options: UploadOptions): Promise<IUploadedFile>;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1709
1832
|
/**
|
|
1710
1833
|
* API client for user attributes and features.
|
|
1711
1834
|
* Extends BaseApi for shared URL/auth/request handling.
|
|
@@ -2840,7 +2963,7 @@ interface SettingsLike {
|
|
|
2840
2963
|
permissions?: Record<string, string[]>;
|
|
2841
2964
|
customPermissions?: WorkspacePermissionDefinition[];
|
|
2842
2965
|
canInviteMembers?: boolean | 'admin-only';
|
|
2843
|
-
canCreateWorkspace?: boolean
|
|
2966
|
+
canCreateWorkspace?: boolean;
|
|
2844
2967
|
};
|
|
2845
2968
|
}
|
|
2846
2969
|
interface PermissionContext {
|
|
@@ -3356,6 +3479,8 @@ interface SDKMessages {
|
|
|
3356
3479
|
currency: string;
|
|
3357
3480
|
timezone: string;
|
|
3358
3481
|
profileImage: string;
|
|
3482
|
+
changePicture: string;
|
|
3483
|
+
removePicture: string;
|
|
3359
3484
|
success: string;
|
|
3360
3485
|
nameMinLength: string;
|
|
3361
3486
|
save: string;
|
|
@@ -3377,8 +3502,22 @@ interface SDKMessages {
|
|
|
3377
3502
|
success: string;
|
|
3378
3503
|
chooseEmoji: string;
|
|
3379
3504
|
customImageUrl: string;
|
|
3505
|
+
uploadImage: string;
|
|
3506
|
+
chooseImage: string;
|
|
3380
3507
|
updateWorkspace: string;
|
|
3381
3508
|
};
|
|
3509
|
+
uploads: {
|
|
3510
|
+
/** ICU: `{max}` is the organization's per-file limit, e.g. "5 MB". */
|
|
3511
|
+
description: string;
|
|
3512
|
+
uploading: string;
|
|
3513
|
+
/** ICU: `{max}`. */
|
|
3514
|
+
errorTooLarge: string;
|
|
3515
|
+
errorInvalid: string;
|
|
3516
|
+
errorDisabled: string;
|
|
3517
|
+
errorUserLimit: string;
|
|
3518
|
+
errorUnavailable: string;
|
|
3519
|
+
errorFailed: string;
|
|
3520
|
+
};
|
|
3382
3521
|
features: {
|
|
3383
3522
|
title: string;
|
|
3384
3523
|
ownerOnly: string;
|
|
@@ -4273,6 +4412,13 @@ interface AgentReadyConfig {
|
|
|
4273
4412
|
fetchTimeoutMs?: number;
|
|
4274
4413
|
/** Injectable fetch, mainly for testing. Defaults to the global `fetch`. */
|
|
4275
4414
|
fetch?: typeof fetch;
|
|
4415
|
+
/**
|
|
4416
|
+
* Where the platform fetches are cached. Defaults to process memory, which is
|
|
4417
|
+
* this module's long-standing behaviour. Pass a Redis, KV or Upstash-backed
|
|
4418
|
+
* store so every replica shares one copy instead of each fetching its own.
|
|
4419
|
+
* See `DiscoveryCacheStore`.
|
|
4420
|
+
*/
|
|
4421
|
+
cache?: DiscoveryCacheStore;
|
|
4276
4422
|
}
|
|
4277
4423
|
/** A rendered discovery document ready to become an HTTP response. */
|
|
4278
4424
|
interface DiscoveryDocument {
|
|
@@ -4294,6 +4440,35 @@ declare const AI_BOT_USER_AGENTS: readonly string[];
|
|
|
4294
4440
|
* Crypto / Node `crypto`), so output is identical on every runtime.
|
|
4295
4441
|
*/
|
|
4296
4442
|
declare function sha256Digest(content: string): string;
|
|
4443
|
+
/**
|
|
4444
|
+
* Where the two platform fetches below keep what they fetched.
|
|
4445
|
+
*
|
|
4446
|
+
* The default is process memory, which is what this module has always used and
|
|
4447
|
+
* is correct for one process. It is not wrong across replicas, only wasteful:
|
|
4448
|
+
* every pod fetches the same bundle independently, each honours its own TTL,
|
|
4449
|
+
* and `clearAgentReadinessCache()` clears the process it runs in and no other.
|
|
4450
|
+
* Pass a store backed by Redis, Cloudflare KV or Upstash to share one copy, the
|
|
4451
|
+
* same way `@buildbase/sdk/server`'s content client takes a `CacheStore`.
|
|
4452
|
+
*
|
|
4453
|
+
* Values are JSON strings, so a store needs nothing but string get and set.
|
|
4454
|
+
* Every call is wrapped: a store that throws, or takes longer than
|
|
4455
|
+
* `DISCOVERY_CACHE_TIMEOUT_MS` (500 ms), degrades to a cache miss (one extra
|
|
4456
|
+
* platform fetch), never to a failed or hung discovery response.
|
|
4457
|
+
*/
|
|
4458
|
+
interface DiscoveryCacheStore {
|
|
4459
|
+
/** The stored string, or `undefined` for a miss. */
|
|
4460
|
+
get(key: string): Promise<string | undefined> | string | undefined;
|
|
4461
|
+
/** Store `value` for at least `ttlSeconds`. */
|
|
4462
|
+
set(key: string, value: string, ttlSeconds: number): Promise<void> | void;
|
|
4463
|
+
/** Optional: drop one key. `clearAgentReadinessCache()` uses it when present. */
|
|
4464
|
+
delete?(key: string): Promise<void> | void;
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4467
|
+
* How long one store call may take before it counts as failed. A cache that
|
|
4468
|
+
* answers slower than the platform is no cache; without a bound, a hung
|
|
4469
|
+
* Redis would hang every discovery response with it.
|
|
4470
|
+
*/
|
|
4471
|
+
declare const DISCOVERY_CACHE_TIMEOUT_MS = 500;
|
|
4297
4472
|
/**
|
|
4298
4473
|
* Fetch (and cache) an org's agent-readiness bundle from the BuildBase server.
|
|
4299
4474
|
*
|
|
@@ -4302,8 +4477,16 @@ declare function sha256Digest(content: string): string;
|
|
|
4302
4477
|
* simply see the app as not (yet) agent-ready.
|
|
4303
4478
|
*/
|
|
4304
4479
|
declare function fetchAgentReadiness(config: AgentReadyConfig): Promise<AgentReadinessBundle>;
|
|
4305
|
-
/**
|
|
4306
|
-
|
|
4480
|
+
/**
|
|
4481
|
+
* Clear what this module cached.
|
|
4482
|
+
*
|
|
4483
|
+
* Always clears the built-in process-memory store (which is what tests want).
|
|
4484
|
+
* When a custom `cache` store was used, it also deletes the keys this process
|
|
4485
|
+
* wrote through it, if that store implements `delete`; keys written by another
|
|
4486
|
+
* process are not enumerable through the interface, so a shared store stays
|
|
4487
|
+
* the app's to invalidate.
|
|
4488
|
+
*/
|
|
4489
|
+
declare function clearAgentReadinessCache(store?: DiscoveryCacheStore): void;
|
|
4307
4490
|
/**
|
|
4308
4491
|
* The Agent Card served at `/.well-known/agent.json`. A stable, machine-readable
|
|
4309
4492
|
* entry point advertising who this app is and where agents can discover more.
|
|
@@ -4707,6 +4890,16 @@ interface BuildBaseConfig {
|
|
|
4707
4890
|
orgId: string;
|
|
4708
4891
|
/** API version (default: 'v1') */
|
|
4709
4892
|
version?: ApiVersion;
|
|
4893
|
+
/**
|
|
4894
|
+
* The region this client talks to, for logging, metrics and UI badges.
|
|
4895
|
+
*
|
|
4896
|
+
* Informational only. It is never sent on a request and never changes which
|
|
4897
|
+
* cell answers: `serverUrl` decides that, and on the server the real guard
|
|
4898
|
+
* is the audience the token is bound to (`buildbaseAuth({ resource })`).
|
|
4899
|
+
* Setting it wrong mislabels a log line; it cannot route a request to the
|
|
4900
|
+
* wrong region.
|
|
4901
|
+
*/
|
|
4902
|
+
region?: Region;
|
|
4710
4903
|
/**
|
|
4711
4904
|
* Async callback to resolve the current session ID.
|
|
4712
4905
|
* Called automatically before each authenticated API call.
|
|
@@ -5007,6 +5200,11 @@ interface ScopedActions {
|
|
|
5007
5200
|
sessions: SessionActions;
|
|
5008
5201
|
}
|
|
5009
5202
|
interface BuildBaseResult extends ScopedActions {
|
|
5203
|
+
/**
|
|
5204
|
+
* The `region` passed in config, or `undefined` when it was not set.
|
|
5205
|
+
* Informational: see `BuildBaseConfig.region`.
|
|
5206
|
+
*/
|
|
5207
|
+
region?: Region;
|
|
5010
5208
|
/**
|
|
5011
5209
|
* Check authentication. Returns session or null.
|
|
5012
5210
|
* Uses the `getSessionId` callback from config.
|
|
@@ -5050,6 +5248,7 @@ interface BuildBaseResult extends ScopedActions {
|
|
|
5050
5248
|
push: PushApi;
|
|
5051
5249
|
devices: DevicesApi;
|
|
5052
5250
|
sessions: SessionsApi;
|
|
5251
|
+
uploads: UploadsApi;
|
|
5053
5252
|
};
|
|
5054
5253
|
};
|
|
5055
5254
|
}
|
|
@@ -5255,5 +5454,87 @@ declare function buildbaseAuth(options: BuildBaseAuthOptions): {
|
|
|
5255
5454
|
resourceMetadataUrl?: string;
|
|
5256
5455
|
};
|
|
5257
5456
|
|
|
5258
|
-
|
|
5259
|
-
|
|
5457
|
+
/**
|
|
5458
|
+
* Resolve an organisation's regional `serverUrl` from central.
|
|
5459
|
+
*
|
|
5460
|
+
* Who needs this. Most apps serve one organisation and bake its `serverUrl`
|
|
5461
|
+
* into the build, which is why `BuildBase({ serverUrl })` takes it directly.
|
|
5462
|
+
* An app that hosts many organisations cannot: the right cell depends on which
|
|
5463
|
+
* organisation the request is for, and that is only known at runtime.
|
|
5464
|
+
*
|
|
5465
|
+
* Server-side only, deliberately. Resolving in the browser would mean a round
|
|
5466
|
+
* trip before the first API call on every page load, and the answer is not
|
|
5467
|
+
* secret but it is not interesting to a browser either: whatever the client
|
|
5468
|
+
* resolves, the server still has to be given the right URL.
|
|
5469
|
+
*
|
|
5470
|
+
* What it is NOT. This is a convenience, not a security boundary. Nothing here
|
|
5471
|
+
* decides which cell answers: `serverUrl` does, and the real guard is the
|
|
5472
|
+
* audience the token is bound to (`buildbaseAuth({ resource })`). A wrong
|
|
5473
|
+
* answer here produces a 421 from the cell that was asked, which is the signal
|
|
5474
|
+
* to re-resolve, not a cross-region read.
|
|
5475
|
+
*/
|
|
5476
|
+
interface RegionAnswer {
|
|
5477
|
+
orgId: string;
|
|
5478
|
+
region: Region | string;
|
|
5479
|
+
cellId: string;
|
|
5480
|
+
serverUrl: string;
|
|
5481
|
+
}
|
|
5482
|
+
interface ResolveServerUrlOptions {
|
|
5483
|
+
/** The organisation to resolve. */
|
|
5484
|
+
orgId: string;
|
|
5485
|
+
/** Central's base URL, for example `https://central.console.buildbase.app`. */
|
|
5486
|
+
centralUrl: string;
|
|
5487
|
+
/**
|
|
5488
|
+
* The organisation's API key (`<orgId>:<secret>`).
|
|
5489
|
+
*
|
|
5490
|
+
* Without it central answers the DEFAULT cell for every id, known or not, on
|
|
5491
|
+
* purpose: organisation ids are ObjectIds and an endpoint that distinguished
|
|
5492
|
+
* known from unknown would be an enumeration oracle. So an unauthenticated
|
|
5493
|
+
* call does not fail, it quietly returns the wrong cell for an EU
|
|
5494
|
+
* organisation. Pass the key.
|
|
5495
|
+
*/
|
|
5496
|
+
apiKey?: string;
|
|
5497
|
+
/** Request timeout. Default 5000 ms. */
|
|
5498
|
+
timeoutMs?: number;
|
|
5499
|
+
/** Injectable fetch, mainly for testing. */
|
|
5500
|
+
fetch?: typeof fetch;
|
|
5501
|
+
/**
|
|
5502
|
+
* Where to cache answers. Defaults to a process-memory map, which is the
|
|
5503
|
+
* right thing for one process; pass a shared store to let replicas reuse
|
|
5504
|
+
* each other's lookups.
|
|
5505
|
+
*/
|
|
5506
|
+
cache?: ResolveCacheStore;
|
|
5507
|
+
}
|
|
5508
|
+
/** Same shape as the discovery cache: string in, string out. */
|
|
5509
|
+
interface ResolveCacheStore {
|
|
5510
|
+
get(key: string): Promise<string | undefined> | string | undefined;
|
|
5511
|
+
set(key: string, value: string, ttlSeconds: number): Promise<void> | void;
|
|
5512
|
+
delete?(key: string): Promise<void> | void;
|
|
5513
|
+
}
|
|
5514
|
+
/**
|
|
5515
|
+
* Ask central where an organisation lives, with caching.
|
|
5516
|
+
*
|
|
5517
|
+
* Throws on a network or HTTP failure rather than guessing. A silent fallback
|
|
5518
|
+
* to the default cell is the one behaviour that must not be built in here:
|
|
5519
|
+
* for an EU organisation it would mean sending the request to the US, which is
|
|
5520
|
+
* precisely what the cell topology exists to prevent. The caller decides what
|
|
5521
|
+
* to do with the failure.
|
|
5522
|
+
*/
|
|
5523
|
+
declare function resolveServerUrl(options: ResolveServerUrlOptions): Promise<RegionAnswer>;
|
|
5524
|
+
/**
|
|
5525
|
+
* Forget a cached answer.
|
|
5526
|
+
*
|
|
5527
|
+
* Call it on a `421 misdirected_request`: that response is central's previous
|
|
5528
|
+
* answer being proved stale by the cell that received it, usually because the
|
|
5529
|
+
* organisation was migrated. Re-resolving once after a 421 is the documented
|
|
5530
|
+
* recovery; re-resolving in a loop is not, so the caller should retry the
|
|
5531
|
+
* request once and surface the second failure.
|
|
5532
|
+
*/
|
|
5533
|
+
declare function clearResolvedServerUrl(options: {
|
|
5534
|
+
orgId: string;
|
|
5535
|
+
centralUrl: string;
|
|
5536
|
+
cache?: ResolveCacheStore;
|
|
5537
|
+
}): Promise<void>;
|
|
5538
|
+
|
|
5539
|
+
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 };
|
|
5540
|
+
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 };
|