@base44-preview/sdk 0.8.29-pr.176.30c5ce1 → 0.8.30-pr.160.0c0f347
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.
|
@@ -33,6 +33,18 @@ export function createConnectorsModule(axios, appId) {
|
|
|
33
33
|
connectionConfig: (_a = data.connection_config) !== null && _a !== void 0 ? _a : null,
|
|
34
34
|
};
|
|
35
35
|
},
|
|
36
|
+
async getWorkspaceConnection(connectorId) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!connectorId || typeof connectorId !== "string") {
|
|
39
|
+
throw new Error("Connector ID is required and must be a string");
|
|
40
|
+
}
|
|
41
|
+
const response = await axios.get(`/apps/${appId}/external-auth/tokens/by-connector/${connectorId}`);
|
|
42
|
+
const data = response;
|
|
43
|
+
return {
|
|
44
|
+
accessToken: data.access_token,
|
|
45
|
+
connectionConfig: (_a = data.connection_config) !== null && _a !== void 0 ? _a : null,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
36
48
|
/**
|
|
37
49
|
* @deprecated Use getCurrentAppUserConnection(connectorId) and use the returned accessToken (and connectionConfig when needed) instead.
|
|
38
50
|
*/
|
|
@@ -251,6 +251,32 @@ 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 method 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 {@link getConnection} form,
|
|
262
|
+
* differing only in which OAuth app was used to produce the token.
|
|
263
|
+
*
|
|
264
|
+
* @param 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.getWorkspaceConnection(
|
|
271
|
+
* '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
|
+
getWorkspaceConnection(connectorId: string): Promise<ConnectorConnectionResponse>;
|
|
254
280
|
/**
|
|
255
281
|
* @internal
|
|
256
282
|
* @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(() => {
|