@base44-preview/sdk 0.8.29-pr.176.65ba61b → 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(
|
|
24
|
+
async getConnection(arg) {
|
|
25
25
|
var _a;
|
|
26
|
-
|
|
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(
|
|
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.
|