@depup/base44__sdk 0.8.43-depup.0 → 0.8.44-depup.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.
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/base44__sdk
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@base44/sdk](https://www.npmjs.com/package/@base44/sdk) @ 0.8.43 |
17
- | Processed | 2026-08-18 |
16
+ | Original | [@base44/sdk](https://www.npmjs.com/package/@base44/sdk) @ 0.8.44 |
17
+ | Processed | 2026-08-26 |
18
18
  | Smoke test | passed |
19
19
  | Deps updated | 3 |
20
20
 
@@ -22,9 +22,9 @@ npm install @depup/base44__sdk
22
22
 
23
23
  | Dependency | From | To |
24
24
  |------------|------|-----|
25
- | axios | ^1.18.1 | ^1.19.0 |
25
+ | axios | ^1.18.1 | ^1.20.0 |
26
26
  | partysocket | ^0.0.23 | ^1.3.0 |
27
- | uuid | ^13.0.2 | ^14.0.1 |
27
+ | uuid | ^13.0.2 | ^14.0.2 |
28
28
 
29
29
  ---
30
30
 
package/changes.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "bumped": {
3
3
  "axios": {
4
4
  "from": "^1.18.1",
5
- "to": "^1.19.0"
5
+ "to": "^1.20.0"
6
6
  },
7
7
  "partysocket": {
8
8
  "from": "^0.0.23",
@@ -10,9 +10,9 @@
10
10
  },
11
11
  "uuid": {
12
12
  "from": "^13.0.2",
13
- "to": "^14.0.1"
13
+ "to": "^14.0.2"
14
14
  }
15
15
  },
16
- "timestamp": "2026-08-18T08:10:22.589Z",
16
+ "timestamp": "2026-08-26T16:29:09.789Z",
17
17
  "totalUpdated": 3
18
18
  }
package/dist/index.d.ts CHANGED
@@ -14,6 +14,6 @@ export type { AppLogsModule } from "./modules/app-logs.types.js";
14
14
  export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, } from "./modules/actors.types.js";
15
15
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
16
16
  export { Actor, type Conn } from "./actor.js";
17
- export type { ConnectorsModule, UserConnectorsModule, } from "./modules/connectors.types.js";
17
+ export type { ConnectorsModule, UserConnectorsModule, ConnectorApiRequest, ConnectorApiResponse, ConnectorApiResponsePhase, } from "./modules/connectors.types.js";
18
18
  export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
19
19
  export type { GetAccessTokenOptions, SaveAccessTokenOptions, RemoveAccessTokenOptions, GetLoginUrlOptions, } from "./utils/auth-utils.types.js";
@@ -1,3 +1,11 @@
1
+ const CONNECTOR_API_METHODS = new Set([
2
+ "GET",
3
+ "POST",
4
+ "PUT",
5
+ "PATCH",
6
+ "DELETE",
7
+ "HEAD",
8
+ ]);
1
9
  /**
2
10
  * Creates the Connectors module for the Base44 SDK.
3
11
  *
@@ -17,7 +25,7 @@ export function createConnectorsModule(axios, appId) {
17
25
  if (!integrationType || typeof integrationType !== "string") {
18
26
  throw new Error("Integration type is required and must be a string");
19
27
  }
20
- const response = await axios.get(`/apps/${appId}/external-auth/tokens/${integrationType}`);
28
+ const response = await axios.get(`/apps/${appId}/external-auth/tokens/${encodeURIComponent(integrationType)}`);
21
29
  // @ts-expect-error
22
30
  return response.access_token;
23
31
  },
@@ -26,7 +34,7 @@ export function createConnectorsModule(axios, appId) {
26
34
  if (!integrationType || typeof integrationType !== "string") {
27
35
  throw new Error("Integration type is required and must be a string");
28
36
  }
29
- const response = await axios.get(`/apps/${appId}/external-auth/tokens/${integrationType}`);
37
+ const response = await axios.get(`/apps/${appId}/external-auth/tokens/${encodeURIComponent(integrationType)}`);
30
38
  const data = response;
31
39
  return {
32
40
  accessToken: data.access_token,
@@ -38,7 +46,7 @@ export function createConnectorsModule(axios, appId) {
38
46
  if (!connectorId || typeof connectorId !== "string") {
39
47
  throw new Error("Connector ID is required and must be a string");
40
48
  }
41
- const response = await axios.get(`/apps/${appId}/external-auth/tokens/connectors/${connectorId}`);
49
+ const response = await axios.get(`/apps/${appId}/external-auth/tokens/connectors/${encodeURIComponent(connectorId)}`);
42
50
  const data = response;
43
51
  return {
44
52
  accessToken: data.access_token,
@@ -52,7 +60,7 @@ export function createConnectorsModule(axios, appId) {
52
60
  if (!connectorId || typeof connectorId !== "string") {
53
61
  throw new Error("Connector ID is required and must be a string");
54
62
  }
55
- const response = await axios.get(`/apps/${appId}/app-user-auth/connectors/${connectorId}/token`);
63
+ const response = await axios.get(`/apps/${appId}/app-user-auth/connectors/${encodeURIComponent(connectorId)}/token`);
56
64
  const data = response;
57
65
  return data.access_token;
58
66
  },
@@ -61,13 +69,65 @@ export function createConnectorsModule(axios, appId) {
61
69
  if (!connectorId || typeof connectorId !== "string") {
62
70
  throw new Error("Connector ID is required and must be a string");
63
71
  }
64
- const response = await axios.get(`/apps/${appId}/app-user-auth/connectors/${connectorId}/token`);
72
+ const response = await axios.get(`/apps/${appId}/app-user-auth/connectors/${encodeURIComponent(connectorId)}/token`);
65
73
  const data = response;
66
74
  return {
67
75
  accessToken: data.access_token,
68
76
  connectionConfig: (_a = data.connection_config) !== null && _a !== void 0 ? _a : null,
69
77
  };
70
78
  },
79
+ async callApi(integrationType, request) {
80
+ assertNonEmptyString(integrationType, "Integration type");
81
+ // Encoded so a runtime-built identifier can only ever select a
82
+ // connector, never re-target another route under this token.
83
+ return proxyCall(axios, `/apps/${appId}/connectors/${encodeURIComponent(integrationType)}/call`, request);
84
+ },
85
+ };
86
+ }
87
+ function assertNonEmptyString(value, label) {
88
+ if (!value || typeof value !== "string") {
89
+ throw new Error(`${label} is required and must be a string`);
90
+ }
91
+ }
92
+ /**
93
+ * POST a request to the connector proxy and normalize the response.
94
+ *
95
+ * The proxy reports upstream outcomes in the body rather than as HTTP status, so
96
+ * a provider 4xx/5xx arrives here as a resolved response with `success: false` —
97
+ * only Base44-side failures reject through the axios error interceptor.
98
+ *
99
+ * @internal
100
+ */
101
+ async function proxyCall(axios, url, request) {
102
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
103
+ if (!request || typeof request !== "object") {
104
+ throw new Error("Request is required and must be an object");
105
+ }
106
+ assertNonEmptyString(request.path, "Request path");
107
+ const method = (_a = request.method) !== null && _a !== void 0 ? _a : "GET";
108
+ if (!CONNECTOR_API_METHODS.has(method)) {
109
+ throw new Error("Request method must be one of GET, POST, PUT, PATCH, DELETE, or HEAD");
110
+ }
111
+ const response = await axios.post(url, {
112
+ method,
113
+ // Omitted when unset (undefined or null, since untyped callers write
114
+ // either) so the proxy applies the connector's declared default host.
115
+ ...(request.host == null ? {} : { host: request.host }),
116
+ path: request.path,
117
+ query: (_b = request.query) !== null && _b !== void 0 ? _b : {},
118
+ headers: (_c = request.headers) !== null && _c !== void 0 ? _c : {},
119
+ body: (_d = request.body) !== null && _d !== void 0 ? _d : null,
120
+ });
121
+ const data = response;
122
+ return {
123
+ success: data.success,
124
+ phase: data.phase,
125
+ status: (_e = data.status_code) !== null && _e !== void 0 ? _e : null,
126
+ data: data.data,
127
+ dataBase64: (_f = data.data_base64) !== null && _f !== void 0 ? _f : null,
128
+ contentType: (_g = data.content_type) !== null && _g !== void 0 ? _g : null,
129
+ headers: (_h = data.headers) !== null && _h !== void 0 ? _h : {},
130
+ creditsCharged: (_j = data.credits_charged) !== null && _j !== void 0 ? _j : 0,
71
131
  };
72
132
  }
73
133
  /**
@@ -84,7 +144,7 @@ export function createUserConnectorsModule(axios, appId) {
84
144
  if (!connectorId || typeof connectorId !== "string") {
85
145
  throw new Error("Connector ID is required and must be a string");
86
146
  }
87
- const response = await axios.post(`/apps/${appId}/app-user-auth/connectors/${connectorId}/initiate`);
147
+ const response = await axios.post(`/apps/${appId}/app-user-auth/connectors/${encodeURIComponent(connectorId)}/initiate`);
88
148
  const data = response;
89
149
  return data.redirect_url;
90
150
  },
@@ -92,7 +152,7 @@ export function createUserConnectorsModule(axios, appId) {
92
152
  if (!connectorId || typeof connectorId !== "string") {
93
153
  throw new Error("Connector ID is required and must be a string");
94
154
  }
95
- await axios.delete(`/apps/${appId}/app-user-auth/connectors/${connectorId}`);
155
+ await axios.delete(`/apps/${appId}/app-user-auth/connectors/${encodeURIComponent(connectorId)}`);
96
156
  },
97
157
  };
98
158
  }
@@ -41,6 +41,81 @@ export interface AppUserConnectorConnectionResponse {
41
41
  /** Key-value configuration for the connection, or `null` if the connector does not provide one. */
42
42
  connectionConfig: Record<string, string> | null;
43
43
  }
44
+ /**
45
+ * How far a metered connector call progressed through the Base44 proxy.
46
+ *
47
+ * Only `not_sent` proves that the provider did not execute the request.
48
+ * `timed_out` and `sent_unconfirmed` may have executed upstream, so do not
49
+ * automatically retry non-idempotent requests based on those phases.
50
+ */
51
+ export type ConnectorApiResponsePhase = "not_sent" | "responded" | "timed_out" | "sent_unconfirmed";
52
+ /**
53
+ * A request to forward to a metered connector's API through the Base44 proxy.
54
+ */
55
+ export interface ConnectorApiRequest {
56
+ /** HTTP method for the upstream request. Defaults to `'GET'`. */
57
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
58
+ /**
59
+ * Which of the connector's API hosts to call, by the name it declares.
60
+ * Omit for its default host (the first one declared). Only relevant for
61
+ * connectors that expose more than one host.
62
+ */
63
+ host?: string;
64
+ /**
65
+ * Path relative to the connector's API root, starting with `/`, such as `'/2/tweets'`.
66
+ *
67
+ * Must not be an absolute URL. Query parameters may be included here or passed
68
+ * separately as {@link query}; either way they are forwarded and priced identically.
69
+ */
70
+ path: string;
71
+ /** Query parameters. Merged into the request URL alongside any already present in {@link path}. */
72
+ query?: Record<string, string | number | boolean | Array<string | number>>;
73
+ /** Extra request headers. Only headers the connector explicitly allows are forwarded; the rest are dropped. */
74
+ headers?: Record<string, string>;
75
+ /** JSON request body. Ignored for `GET` and `HEAD`. */
76
+ body?: unknown;
77
+ }
78
+ /**
79
+ * The upstream API's response, as returned by the Base44 connector proxy.
80
+ */
81
+ export interface ConnectorApiResponse<T = unknown> {
82
+ /** `true` only when the upstream API returned a 2xx status. Proxy and upstream errors are `false`. */
83
+ success: boolean;
84
+ /** How far the call progressed. Only `not_sent` proves the provider did not execute it. */
85
+ phase: ConnectorApiResponsePhase;
86
+ /** The upstream HTTP status code, or `null` when no response was received. */
87
+ status: number | null;
88
+ /**
89
+ * The parsed upstream response body, or proxy error details when no response
90
+ * was received. `null` when the response was binary — see {@link dataBase64}.
91
+ */
92
+ data: T | null;
93
+ /**
94
+ * The response body base64-encoded, for the media types the connector declares
95
+ * as binary (images, PDFs). Set instead of {@link data}, never alongside it.
96
+ */
97
+ dataBase64: string | null;
98
+ /** The response media type, set only alongside {@link dataBase64}. */
99
+ contentType: string | null;
100
+ /** The subset of upstream response headers the connector exposes, typically rate-limit counters. */
101
+ headers: Record<string, string>;
102
+ /** Integration credits billed to the workspace for this call. */
103
+ creditsCharged: number;
104
+ }
105
+ /**
106
+ * Raw proxy response shape. Mapped to {@link ConnectorApiResponse} before being returned.
107
+ * @internal
108
+ */
109
+ export interface ConnectorProxyRawResponse {
110
+ success: boolean;
111
+ phase: ConnectorApiResponsePhase;
112
+ status_code: number | null;
113
+ data: unknown;
114
+ data_base64: string | null;
115
+ content_type: string | null;
116
+ headers: Record<string, string>;
117
+ credits_charged: number;
118
+ }
44
119
  /**
45
120
  * Connectors module for managing OAuth tokens for external services.
46
121
  *
@@ -71,6 +146,18 @@ export interface AppUserConnectorConnectionResponse {
71
146
  * 3. In a backend function, call {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()} using the service role client (`base44.asServiceRole.connectors`) with the connector ID to retrieve the app user's token.
72
147
  * 4. Use the returned `accessToken` to call the external service's API directly. Some connectors also return a `connectionConfig` with additional values such as a subdomain for building the API URL.
73
148
  *
149
+ * ## Metered connectors
150
+ *
151
+ * A few [platform connectors](#shared-connectors) are backed by paid third-party APIs that charge Base44 per call. For those, the OAuth token is **not** available to your code — {@linkcode getConnection | getConnection()} rejects with a `403`. Call them with {@linkcode callApi | callApi()} instead: Base44 attaches the credential server-side, forwards the request, and bills your workspace's integration credits for the call.
152
+ *
153
+ * This applies to platform connectors only. A workspace-registered or app user connector runs on **your own** OAuth app, so the provider invoices you directly and there is nothing for Base44 to meter — those keep normal token access via {@linkcode getWorkspaceConnection | getWorkspaceConnection()} and {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()}.
154
+ *
155
+ * Two things to keep in mind when writing against a metered connector:
156
+ *
157
+ * - **Cost varies by endpoint, sometimes sharply.** The same connector can charge two orders of magnitude more for one endpoint than another, so avoid putting an expensive call inside a loop and batch wherever the provider supports it. Each response reports what it actually cost as `creditsCharged`.
158
+ * - **Provider and transport outcomes are returned, not thrown.** A provider `4xx`/`5xx` or a connection failure comes back as `success: false` with its `phase`; authorization, quota, and invalid proxy requests reject the promise.
159
+ * - **Only `phase: 'not_sent'` proves the provider did not execute the request.** A timeout or in-flight failure may have executed upstream, so do not automatically retry a non-idempotent call unless the provider supports an idempotency key.
160
+ *
74
161
  * ## Available connectors
75
162
  *
76
163
  * The connectors below can be used as shared connectors or as app user connectors. For a shared platform connector, pass the integration type string to {@linkcode getConnection | getConnection()}. For a connector you register in Workspace Settings with your own OAuth app, use the connector ID with {@linkcode getWorkspaceConnection | getWorkspaceConnection()} for a shared token, or with {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()} for a per-user token.
@@ -328,6 +415,41 @@ export interface ConnectorsModule {
328
415
  * ```
329
416
  */
330
417
  getCurrentAppUserConnection(connectorId: string): Promise<AppUserConnectorConnectionResponse>;
418
+ /**
419
+ * Calls a [metered connector's](#metered-connectors) API through the Base44 proxy.
420
+ *
421
+ * Use this for a shared platform connector identified by an integration type. Base44 adds the OAuth credential to the outgoing request, forwards it, and bills the workspace for the call, so you never handle the token yourself.
422
+ *
423
+ * @param integrationType - The type of integration, such as `'x'`. See [Available connectors](#available-connectors).
424
+ * @param request - The upstream request to forward. See {@link ConnectorApiRequest}.
425
+ * @returns Promise resolving to a {@link ConnectorApiResponse}. Note that an upstream error is reported in `success` and `status`, not thrown — only Base44-side failures reject.
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * // Post to X
430
+ * const res = await base44.asServiceRole.connectors.callApi('x', {
431
+ * method: 'POST',
432
+ * path: '/2/tweets',
433
+ * body: { text: 'Shipped!' },
434
+ * });
435
+ *
436
+ * if (!res.success) {
437
+ * console.error('X rejected the post', res.status, res.data);
438
+ * }
439
+ * ```
440
+ *
441
+ * @example
442
+ * ```typescript
443
+ * // Read, with query parameters and a look at what the call cost
444
+ * const res = await base44.asServiceRole.connectors.callApi('x', {
445
+ * path: '/2/tweets/search/recent',
446
+ * query: { query: 'base44', max_results: 10 },
447
+ * });
448
+ *
449
+ * console.log(`${res.creditsCharged} credits`, res.data);
450
+ * ```
451
+ */
452
+ callApi<T = unknown>(integrationType: ConnectorIntegrationType, request: ConnectorApiRequest): Promise<ConnectorApiResponse<T>>;
331
453
  }
332
454
  /**
333
455
  * User-scoped connectors module for managing app user OAuth connections.
@@ -185,11 +185,11 @@ export function createAxiosClient({ baseURL, headers = {}, token, interceptRespo
185
185
  }
186
186
  return response.data;
187
187
  }, (error) => {
188
- var _a, _b, _c, _d, _e, _f, _g, _h;
188
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
189
189
  const message = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) ||
190
190
  ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.detail) ||
191
191
  error.message;
192
- const base44Error = new Base44Error(message, (_e = error.response) === null || _e === void 0 ? void 0 : _e.status, (_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code, (_h = error.response) === null || _h === void 0 ? void 0 : _h.data, error);
192
+ const base44Error = new Base44Error(message, (_e = error.response) === null || _e === void 0 ? void 0 : _e.status, (_m = (_h = (_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code) !== null && _h !== void 0 ? _h : (_l = (_k = (_j = error.response) === null || _j === void 0 ? void 0 : _j.headers) === null || _k === void 0 ? void 0 : _k.get) === null || _l === void 0 ? void 0 : _l.call(_k, "x-base44-connector-error")) !== null && _m !== void 0 ? _m : (_p = (_o = error.response) === null || _o === void 0 ? void 0 : _o.headers) === null || _p === void 0 ? void 0 : _p["x-base44-connector-error"], (_q = error.response) === null || _q === void 0 ? void 0 : _q.data, error);
193
193
  // Log errors in development
194
194
  if (process.env.NODE_ENV !== "production") {
195
195
  safeErrorLog("[Base44 SDK Error]", base44Error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/base44__sdk",
3
- "version": "0.8.43-depup.0",
3
+ "version": "0.8.44-depup.0",
4
4
  "description": "JavaScript SDK for Base44 API (with updated dependencies)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,10 +27,10 @@
27
27
  "create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^1.19.0",
30
+ "axios": "^1.20.0",
31
31
  "partysocket": "^1.3.0",
32
32
  "socket.io-client": "^4.8.3",
33
- "uuid": "^14.0.1"
33
+ "uuid": "^14.0.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/hast": "^3.0.4",
@@ -75,7 +75,7 @@
75
75
  "changes": {
76
76
  "axios": {
77
77
  "from": "^1.18.1",
78
- "to": "^1.19.0"
78
+ "to": "^1.20.0"
79
79
  },
80
80
  "partysocket": {
81
81
  "from": "^0.0.23",
@@ -83,13 +83,13 @@
83
83
  },
84
84
  "uuid": {
85
85
  "from": "^13.0.2",
86
- "to": "^14.0.1"
86
+ "to": "^14.0.2"
87
87
  }
88
88
  },
89
89
  "depsUpdated": 3,
90
90
  "originalPackage": "@base44/sdk",
91
- "originalVersion": "0.8.43",
92
- "processedAt": "2026-08-18T08:10:35.872Z",
91
+ "originalVersion": "0.8.44",
92
+ "processedAt": "2026-08-26T16:29:25.763Z",
93
93
  "smokeTest": "passed"
94
94
  }
95
95
  }