@base44-preview/sdk 0.8.29-pr.176.30c5ce1 → 0.8.30-pr.160.3afb628

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.
@@ -21,12 +21,25 @@ export function createConnectorsModule(axios, appId) {
21
21
  // @ts-expect-error
22
22
  return response.access_token;
23
23
  },
24
- async getConnection(integrationType) {
24
+ async getConnection(arg) {
25
25
  var _a;
26
- if (!integrationType || typeof integrationType !== "string") {
26
+ let url;
27
+ if (typeof arg === "string") {
28
+ if (!arg) {
29
+ throw new Error("Integration type is required and must be a string");
30
+ }
31
+ url = `/apps/${appId}/external-auth/tokens/${arg}`;
32
+ }
33
+ else if (arg && typeof arg === "object" && typeof arg.connectorId === "string") {
34
+ if (!arg.connectorId) {
35
+ throw new Error("Connector ID is required and must be a string");
36
+ }
37
+ url = `/apps/${appId}/external-auth/tokens/by-connector/${arg.connectorId}`;
38
+ }
39
+ else {
27
40
  throw new Error("Integration type is required and must be a string");
28
41
  }
29
- const response = await axios.get(`/apps/${appId}/external-auth/tokens/${integrationType}`);
42
+ const response = await axios.get(url);
30
43
  const data = response;
31
44
  return {
32
45
  accessToken: data.access_token,
@@ -251,6 +251,34 @@ export interface ConnectorsModule {
251
251
  * ```
252
252
  */
253
253
  getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;
254
+ /**
255
+ * Retrieves the OAuth access token and connection configuration for a **workspace-registered** connector
256
+ * (a connector backed by an OAuth app registered in the workspace, consented to once by the app builder).
257
+ *
258
+ * Use this overload when the app's backend function needs to use a connector identified by its
259
+ * workspace-connector ID rather than a platform integration type. The token returned represents
260
+ * the app builder's consent against the workspace's OAuth app and is shared across all app users
261
+ * of the app — identical semantics to the platform-shared `getConnection(integrationType)` form,
262
+ * differing only in which OAuth app was used to produce the token.
263
+ *
264
+ * @param opts - An object with `connectorId` — the ID of the workspace connector (the `OrganizationConnector` database ID) as surfaced in the builder chat context.
265
+ * @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * // Get the connection for a workspace-registered connector
270
+ * const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getConnection({
271
+ * connectorId: 'abc123def',
272
+ * });
273
+ *
274
+ * const response = await fetch(`https://${connectionConfig?.subdomain}.snowflakecomputing.com/api/v2/statements`, {
275
+ * headers: { Authorization: `Bearer ${accessToken}` },
276
+ * });
277
+ * ```
278
+ */
279
+ getConnection(opts: {
280
+ connectorId: string;
281
+ }): Promise<ConnectorConnectionResponse>;
254
282
  /**
255
283
  * @internal
256
284
  * @deprecated Use {@link getCurrentAppUserConnection} instead.
@@ -69,6 +69,7 @@ export function RoomsSocket({ config }) {
69
69
  disconnect();
70
70
  }
71
71
  function disconnect() {
72
+ clearPendingRoomLeaves();
72
73
  if (socket) {
73
74
  socket.disconnect();
74
75
  }
@@ -104,6 +105,16 @@ export function RoomsSocket({ config }) {
104
105
  clearTimeout(pendingLeave);
105
106
  delete pendingRoomLeaves[room];
106
107
  }
108
+ function clearPendingRoomLeaves() {
109
+ Object.keys(pendingRoomLeaves).forEach((room) => {
110
+ var _a, _b;
111
+ clearTimeout(pendingRoomLeaves[room]);
112
+ delete pendingRoomLeaves[room];
113
+ if (((_b = (_a = roomsToListeners[room]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0) {
114
+ delete roomsToListeners[room];
115
+ }
116
+ });
117
+ }
107
118
  function scheduleRoomLeave(room) {
108
119
  cancelPendingRoomLeave(room);
109
120
  pendingRoomLeaves[room] = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.29-pr.176.30c5ce1",
3
+ "version": "0.8.30-pr.160.3afb628",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",