@base44-preview/sdk 0.8.20-pr.136.cbfe0f7 → 0.8.20-pr.136.e0d0374

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.
@@ -24,7 +24,7 @@ export interface ConnectorAccessTokenResponse {
24
24
  connection_config: Record<string, string> | null;
25
25
  }
26
26
  /**
27
- * Camel-cased connection details returned by {@linkcode ConnectorsModule.getConnection | getConnection()}.
27
+ * Connection details.
28
28
  */
29
29
  export interface ConnectorConnectionResponse {
30
30
  /** The OAuth access token for the external service. */
@@ -44,7 +44,7 @@ export interface ConnectorConnectionResponse {
44
44
  *
45
45
  * ## Available connectors
46
46
  *
47
- * All connectors work through [`getAccessToken()`](#getaccesstoken). Pass the integration type string and use the returned OAuth token to call the external service's API directly.
47
+ * All connectors work through [`getConnection()`](#getconnection). Pass the integration type string and use the returned OAuth token to call the external service's API directly.
48
48
  *
49
49
  * | Service | Type identifier |
50
50
  * |---|---|
@@ -82,7 +82,7 @@ export interface ConnectorsModule {
82
82
  /**
83
83
  * Retrieves an OAuth access token for a specific [external integration type](#available-connectors).
84
84
  *
85
- * @deprecated Use {@link getConnection} and use the returned `accessToken` (and `connectionConfig` when needed) instead.
85
+ * @deprecated Use {@link getConnection} instead.
86
86
  *
87
87
  * Returns the OAuth token string for an external service that an app builder
88
88
  * has connected to. This token represents the connected app builder's account
@@ -152,36 +152,60 @@ export interface ConnectorsModule {
152
152
  * Retrieves the OAuth access token and connection configuration for a specific external integration type.
153
153
  *
154
154
  * Returns both the OAuth token and any additional connection configuration
155
- * that the connector provides. This is useful when the external service requires
156
- * extra parameters beyond the access token (e.g., a shop domain, account ID, or API base URL).
155
+ * that the connector provides. Some connectors require connection-specific
156
+ * parameters to build API requests. For example, a service might need a
157
+ * subdomain to construct the API URL (`{subdomain}.example.com`), which
158
+ * is available in `connectionConfig`. Most connectors only need the
159
+ * `accessToken`; `connectionConfig` will be `null` when there are no
160
+ * extra parameters.
157
161
  *
158
162
  * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
159
163
  * @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
160
164
  *
161
165
  * @example
162
166
  * ```typescript
163
- * // Basic usage
164
- * const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
165
- * console.log(connection.accessToken);
166
- * console.log(connection.connectionConfig);
167
+ * // Google Calendar connection
168
+ * // Get Google Calendar OAuth token and fetch upcoming events
169
+ * const { accessToken } = await base44.asServiceRole.connectors.getConnection('googlecalendar');
170
+ *
171
+ * const timeMin = new Date().toISOString();
172
+ * const url = `https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=10&orderBy=startTime&singleEvents=true&timeMin=${timeMin}`;
173
+ *
174
+ * const calendarResponse = await fetch(url, {
175
+ * headers: { Authorization: `Bearer ${accessToken}` }
176
+ * });
177
+ *
178
+ * const events = await calendarResponse.json();
167
179
  * ```
168
180
  *
169
181
  * @example
170
182
  * ```typescript
171
- * // Shopify: connectionConfig has subdomain (e.g. "my-store" for my-store.myshopify.com)
172
- * const connection = await base44.asServiceRole.connectors.getConnection('shopify');
173
- * const { accessToken, connectionConfig } = connection;
174
- * const shop = connectionConfig?.subdomain
175
- * ? `https://${connectionConfig.subdomain}.myshopify.com`
176
- * : null;
177
- *
178
- * if (shop) {
179
- * const response = await fetch(
180
- * `${shop}/admin/api/2024-01/products.json?limit=10`,
181
- * { headers: { 'X-Shopify-Access-Token': accessToken } }
182
- * );
183
- * const { products } = await response.json();
184
- * }
183
+ * // Slack connection
184
+ * // Get Slack OAuth token and list channels
185
+ * const { accessToken } = await base44.asServiceRole.connectors.getConnection('slack');
186
+ *
187
+ * const url = 'https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=100';
188
+ *
189
+ * const slackResponse = await fetch(url, {
190
+ * headers: { Authorization: `Bearer ${accessToken}` }
191
+ * });
192
+ *
193
+ * const data = await slackResponse.json();
194
+ * ```
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * // Using connectionConfig
199
+ * // Some connectors return a subdomain or other params needed to build the API URL
200
+ * const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getConnection('myservice');
201
+ *
202
+ * const subdomain = connectionConfig?.subdomain;
203
+ * const response = await fetch(
204
+ * `https://${subdomain}.example.com/api/v1/resources`,
205
+ * { headers: { Authorization: `Bearer ${accessToken}` } }
206
+ * );
207
+ *
208
+ * const data = await response.json();
185
209
  * ```
186
210
  */
187
211
  getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.20-pr.136.cbfe0f7",
3
+ "version": "0.8.20-pr.136.e0d0374",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",