@doany-ai/sdk 0.1.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.
Files changed (75) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +60 -0
  3. package/dist/client.d.ts +96 -0
  4. package/dist/client.js +395 -0
  5. package/dist/client.types.d.ts +149 -0
  6. package/dist/client.types.js +1 -0
  7. package/dist/index.d.ts +17 -0
  8. package/dist/index.js +5 -0
  9. package/dist/modules/agents.d.ts +2 -0
  10. package/dist/modules/agents.js +89 -0
  11. package/dist/modules/agents.types.d.ts +397 -0
  12. package/dist/modules/agents.types.js +1 -0
  13. package/dist/modules/ai-gateway.d.ts +2 -0
  14. package/dist/modules/ai-gateway.js +13 -0
  15. package/dist/modules/ai-gateway.types.d.ts +88 -0
  16. package/dist/modules/ai-gateway.types.js +1 -0
  17. package/dist/modules/analytics.d.ts +20 -0
  18. package/dist/modules/analytics.js +284 -0
  19. package/dist/modules/analytics.types.d.ts +122 -0
  20. package/dist/modules/analytics.types.js +1 -0
  21. package/dist/modules/app-logs.d.ts +11 -0
  22. package/dist/modules/app-logs.js +27 -0
  23. package/dist/modules/app-logs.types.d.ts +46 -0
  24. package/dist/modules/app-logs.types.js +1 -0
  25. package/dist/modules/app.types.d.ts +142 -0
  26. package/dist/modules/app.types.js +1 -0
  27. package/dist/modules/auth.d.ts +13 -0
  28. package/dist/modules/auth.js +240 -0
  29. package/dist/modules/auth.types.d.ts +517 -0
  30. package/dist/modules/auth.types.js +1 -0
  31. package/dist/modules/connectors.d.ts +20 -0
  32. package/dist/modules/connectors.js +98 -0
  33. package/dist/modules/connectors.types.d.ts +376 -0
  34. package/dist/modules/connectors.types.js +1 -0
  35. package/dist/modules/custom-integrations.d.ts +11 -0
  36. package/dist/modules/custom-integrations.js +32 -0
  37. package/dist/modules/custom-integrations.types.d.ts +89 -0
  38. package/dist/modules/custom-integrations.types.js +1 -0
  39. package/dist/modules/entities.d.ts +20 -0
  40. package/dist/modules/entities.js +163 -0
  41. package/dist/modules/entities.types.d.ts +702 -0
  42. package/dist/modules/entities.types.js +1 -0
  43. package/dist/modules/functions.d.ts +12 -0
  44. package/dist/modules/functions.js +79 -0
  45. package/dist/modules/functions.types.d.ts +150 -0
  46. package/dist/modules/functions.types.js +1 -0
  47. package/dist/modules/integrations.d.ts +11 -0
  48. package/dist/modules/integrations.js +77 -0
  49. package/dist/modules/integrations.types.d.ts +418 -0
  50. package/dist/modules/integrations.types.js +1 -0
  51. package/dist/modules/sso.d.ts +11 -0
  52. package/dist/modules/sso.js +22 -0
  53. package/dist/modules/sso.types.d.ts +68 -0
  54. package/dist/modules/sso.types.js +1 -0
  55. package/dist/modules/types.d.ts +5 -0
  56. package/dist/modules/types.js +5 -0
  57. package/dist/modules/users.d.ts +16 -0
  58. package/dist/modules/users.js +23 -0
  59. package/dist/types.d.ts +72 -0
  60. package/dist/types.js +1 -0
  61. package/dist/utils/auth-utils.d.ts +117 -0
  62. package/dist/utils/auth-utils.js +189 -0
  63. package/dist/utils/auth-utils.types.d.ts +146 -0
  64. package/dist/utils/auth-utils.types.js +1 -0
  65. package/dist/utils/axios-client.d.ts +100 -0
  66. package/dist/utils/axios-client.js +202 -0
  67. package/dist/utils/axios-client.types.d.ts +28 -0
  68. package/dist/utils/axios-client.types.js +1 -0
  69. package/dist/utils/common.d.ts +4 -0
  70. package/dist/utils/common.js +11 -0
  71. package/dist/utils/sharedInstance.d.ts +1 -0
  72. package/dist/utils/sharedInstance.js +15 -0
  73. package/dist/utils/socket-utils.d.ts +47 -0
  74. package/dist/utils/socket-utils.js +170 -0
  75. package/package.json +54 -0
@@ -0,0 +1,376 @@
1
+ /**
2
+ * Registry of connector integration type names. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`ConnectorIntegrationType`](#connectorintegrationtype) resolves to a union of the keys.
3
+ */
4
+ export interface ConnectorIntegrationTypeRegistry {
5
+ }
6
+ /**
7
+ * Union of all connector integration type names from the [`ConnectorIntegrationTypeRegistry`](#connectorintegrationtyperegistry). Defaults to `string` when no types have been generated.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Using generated connector type names
12
+ * // With generated types, you get autocomplete on integration types
13
+ * const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
14
+ * const token = connection.accessToken;
15
+ * ```
16
+ */
17
+ export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry extends never ? string : keyof ConnectorIntegrationTypeRegistry;
18
+ /**
19
+ * Response from the connectors access token endpoint.
20
+ */
21
+ export interface ConnectorAccessTokenResponse {
22
+ access_token: string;
23
+ integration_type: string;
24
+ connection_config: Record<string, string> | null;
25
+ }
26
+ /**
27
+ * Connection details.
28
+ */
29
+ export interface ConnectorConnectionResponse {
30
+ /** The OAuth access token for the external service. */
31
+ accessToken: string;
32
+ /** Key-value configuration for the connection, or `null` if the connector does not provide one. */
33
+ connectionConfig: Record<string, string> | null;
34
+ }
35
+ /**
36
+ * Connection details for an app user connector.
37
+ */
38
+ export interface AppUserConnectorConnectionResponse {
39
+ /** The OAuth access token for the app user's connection. */
40
+ accessToken: string;
41
+ /** Key-value configuration for the connection, or `null` if the connector does not provide one. */
42
+ connectionConfig: Record<string, string> | null;
43
+ }
44
+ /**
45
+ * Connectors module for managing OAuth tokens for external services.
46
+ *
47
+ * Unlike the {@link IntegrationsModule | integrations} module that provides pre-built functions, connectors give you raw OAuth tokens so you can call external service APIs directly. Use this when you need custom API interactions that the pre-built integrations do not cover.
48
+ *
49
+ * There are two connector types, depending on whether the token is shared across the app or specific to each user:
50
+ *
51
+ * - **[Shared connectors](#shared-connectors):** A single OAuth token shared by all app users. Best for shared service accounts.
52
+ * - **[App user connectors](#app-user-connectors):** Each app user has their own OAuth token. Best for actions that need to happen as the individual user.
53
+ *
54
+ * ## Shared connectors
55
+ *
56
+ * All app users share a single OAuth token. Use this for shared accounts. For example, posting to a company Slack channel or reading from a shared Google Calendar. To use a shared connector:
57
+ *
58
+ * 1. Connect the external service account in the app's Integration settings or using the [`connectors push`](/developers/references/cli/commands/connectors-push) CLI command.
59
+ * 2. In a backend function, call {@linkcode getConnection | getConnection()} using the service role client (`base44.asServiceRole.connectors`) with an [integration type](#available-connectors) string to retrieve the shared OAuth token.
60
+ * 3. 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.
61
+ *
62
+ * ## App user connectors
63
+ *
64
+ * Each signed-in app user has their own OAuth token. Use this when each user needs to act as themselves. For example, sending emails from their Gmail account or posting to their personal LinkedIn. To use an app user connector:
65
+ *
66
+ * 1. Register OAuth credentials for the service in Workspace Settings to get a **connector ID**. This requires workspace admin access.
67
+ * 2. From the frontend, call [connectAppUser()](#connectappuser) with the connector ID to get an authorization URL, then redirect the app user to that URL to complete the OAuth flow.
68
+ * 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.
69
+ * 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.
70
+ *
71
+ * ## Available connectors
72
+ *
73
+ * All connectors listed below support both shared and app user connections. For shared connectors, pass the integration type string to {@linkcode getConnection | getConnection()}. For app user connectors, register the connector in Workspace Settings and use the connector ID with {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()}.
74
+ *
75
+ * | Service | Type identifier |
76
+ * |---|---|
77
+ * | Airtable | `airtable` |
78
+ * | BambooHR | `bamboohr` |
79
+ * | Box | `box` |
80
+ * | Calendly | `calendly` |
81
+ * | ClickUp | `clickup` |
82
+ * | Contentful | `contentful` |
83
+ * | Databricks | `databricks` |
84
+ * | Discord | `discord` |
85
+ * | Dropbox | `dropbox` |
86
+ * | GitHub | `github` |
87
+ * | GitLab | `gitlab` |
88
+ * | Gmail | `gmail` |
89
+ * | Google Ads | `googleads` |
90
+ * | Google Analytics | `google_analytics` |
91
+ * | Google BigQuery | `googlebigquery` |
92
+ * | Google Calendar | `googlecalendar` |
93
+ * | Google Classroom | `google_classroom` |
94
+ * | Google Docs | `googledocs` |
95
+ * | Google Drive | `googledrive` |
96
+ * | Google Meet | `googlemeet` |
97
+ * | Google Search Console | `google_search_console` |
98
+ * | Google Sheets | `googlesheets` |
99
+ * | Google Slides | `googleslides` |
100
+ * | Google Tasks | `googletasks` |
101
+ * | HubSpot | `hubspot` |
102
+ * | Hugging Face | `hugging_face` |
103
+ * | Instagram Business | `instagram` |
104
+ * | Linear | `linear` |
105
+ * | LinkedIn | `linkedin` |
106
+ * | Microsoft Teams | `microsoft_teams` |
107
+ * | Microsoft OneDrive | `one_drive` |
108
+ * | Notion | `notion` |
109
+ * | Outlook | `outlook` |
110
+ * | QuickBooks | `quickbooks` |
111
+ * | Salesforce | `salesforce` |
112
+ * | SharePoint | `share_point` |
113
+ * | Slack User | `slack` |
114
+ * | Slack Bot | `slackbot` |
115
+ * | Snowflake | `snowflake` |
116
+ * | Splitwise | `splitwise` |
117
+ * | Square | `square` |
118
+ * | Supabase | `supabase` |
119
+ * | TikTok | `tiktok` |
120
+ * | Typeform | `typeform` |
121
+ * | Wix | `wix` |
122
+ * | Wrike | `wrike` |
123
+ *
124
+ * See the integration guides for more details:
125
+ *
126
+ * - **Scopes and permissions**: {@link https://docs.base44.com/Integrations/gmail-connector#gmail-scopes-and-permissions | Gmail}, {@link https://docs.base44.com/Integrations/linkedin-connector#linkedin-scopes-and-permissions | LinkedIn}, {@link https://docs.base44.com/Integrations/slack-connector#slack-scopes-and-permissions | Slack}, {@link https://docs.base44.com/Integrations/github-connector#github-scopes-and-permissions | GitHub}
127
+ * - **Slack connector types**: {@link https://docs.base44.com/Integrations/slack-connector#about-the-slack-connectors | About the Slack connectors} explains the difference between `slack` and `slackbot`
128
+ *
129
+ * ## Dynamic Types
130
+ *
131
+ * If you're working in a TypeScript project, you can generate types from your app's connector configurations to get autocomplete on integration type names when calling {@link getConnection}. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
132
+ */
133
+ export interface ConnectorsModule {
134
+ /**
135
+ * Retrieves an OAuth access token for a specific [external integration type](#available-connectors).
136
+ *
137
+ * @deprecated Use {@link getConnection} instead.
138
+ *
139
+ * Returns the OAuth token string for an external service connected to the app.
140
+ * This token represents the connected account and can be used to make authenticated API calls to that external service on behalf of the app.
141
+ *
142
+ * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, `'slackbot'`, `'github'`, or `'discord'`. See [Available connectors](#available-connectors) for the full list.
143
+ * @returns Promise resolving to the access token string.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * // Google Calendar connection
148
+ * // Get Google Calendar OAuth token and fetch upcoming events
149
+ * const googleToken = await base44.asServiceRole.connectors.getAccessToken('googlecalendar');
150
+ *
151
+ * // Fetch upcoming 10 events
152
+ * const timeMin = new Date().toISOString();
153
+ * const url = `https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=10&orderBy=startTime&singleEvents=true&timeMin=${timeMin}`;
154
+ *
155
+ * const response = await fetch(url, {
156
+ * headers: { 'Authorization': `Bearer ${googleToken}` }
157
+ * });
158
+ *
159
+ * const events = await response.json();
160
+ * ```
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * // Slack User connection
165
+ * // Get Slack user token and list channels
166
+ * const slackToken = await base44.asServiceRole.connectors.getAccessToken('slack');
167
+ *
168
+ * // List all public and private channels
169
+ * const url = 'https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=100';
170
+ *
171
+ * const response = await fetch(url, {
172
+ * headers: { 'Authorization': `Bearer ${slackToken}` }
173
+ * });
174
+ *
175
+ * const data = await response.json();
176
+ * ```
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * // Slack Bot connection
181
+ * // Get Slack bot token and post a message with a custom bot identity
182
+ * const botToken = await base44.asServiceRole.connectors.getAccessToken('slackbot');
183
+ *
184
+ * const response = await fetch('https://slack.com/api/chat.postMessage', {
185
+ * method: 'POST',
186
+ * headers: {
187
+ * 'Authorization': `Bearer ${botToken}`,
188
+ * 'Content-Type': 'application/json'
189
+ * },
190
+ * body: JSON.stringify({
191
+ * channel: '#alerts',
192
+ * text: 'Deployment to production completed successfully.',
193
+ * username: 'Deploy Bot',
194
+ * icon_emoji: ':rocket:'
195
+ * })
196
+ * });
197
+ *
198
+ * const result = await response.json();
199
+ * ```
200
+ */
201
+ getAccessToken(integrationType: ConnectorIntegrationType): Promise<string>;
202
+ /**
203
+ * Retrieves the shared OAuth access token and connection configuration for a [shared connector](#shared-connectors) to a specific [external integration type](#available-connectors).
204
+ *
205
+ * Use this when a single shared account is connected and all app users access the same token. For per-user tokens, use [`getCurrentAppUserConnection()`](#getcurrentappuserconnection) instead.
206
+ *
207
+ * Some connectors require connection-specific parameters to build API calls.
208
+ * In such cases, the returned `connectionConfig` is an object with the additional parameters. If there are no extra parameters needed for the connection, the `connectionConfig` is `null`.
209
+ *
210
+ * For example, a service might need a subdomain to construct the API URL in
211
+ * the form of `{subdomain}.example.com`. In such a case the subdomain will be available as a property of the `connectionConfig` object.
212
+ *
213
+ * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, `'slackbot'`, `'github'`, or `'discord'`. See [Available connectors](#available-connectors) for the full list.
214
+ * @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * // Google Calendar connection
219
+ * const { accessToken } = await base44.asServiceRole.connectors.getConnection('googlecalendar');
220
+ *
221
+ * const response = await fetch('https://www.googleapis.com/calendar/v3/users/me/calendarList', {
222
+ * headers: { Authorization: `Bearer ${accessToken}` }
223
+ * });
224
+ *
225
+ * const { items } = await response.json();
226
+ * ```
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * // Slack connection
231
+ * // Get Slack OAuth token and list channels
232
+ * const { accessToken } = await base44.asServiceRole.connectors.getConnection('slack');
233
+ *
234
+ * const url = 'https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=100';
235
+ *
236
+ * const response = await fetch(url, {
237
+ * headers: { Authorization: `Bearer ${accessToken}` }
238
+ * });
239
+ *
240
+ * const data = await response.json();
241
+ * ```
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * // Using connectionConfig
246
+ * // Some connectors return a subdomain or other params needed to build the API URL
247
+ * const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getConnection('myservice');
248
+ *
249
+ * const subdomain = connectionConfig?.subdomain;
250
+ * const response = await fetch(
251
+ * `https://${subdomain}.example.com/api/v1/resources`,
252
+ * { headers: { Authorization: `Bearer ${accessToken}` } }
253
+ * );
254
+ *
255
+ * const data = await response.json();
256
+ * ```
257
+ */
258
+ getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;
259
+ /**
260
+ * Retrieves the OAuth access token and connection configuration for a **workspace-registered** connector
261
+ * (a connector backed by an OAuth app registered in the workspace, consented to once by the app builder).
262
+ *
263
+ * Use this method when the app's backend function needs to use a connector identified by its
264
+ * workspace-connector ID rather than a platform integration type. The token returned represents
265
+ * the app builder's consent against the workspace's OAuth app and is shared across all app users
266
+ * of the app — identical semantics to the platform-shared {@link getConnection} form,
267
+ * differing only in which OAuth app was used to produce the token.
268
+ *
269
+ * @param connectorId - The ID of the workspace connector (the `OrganizationConnector` database ID) as surfaced in the builder chat context.
270
+ * @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * // Get the connection for a workspace-registered connector
275
+ * const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getWorkspaceConnection(
276
+ * 'abc123def',
277
+ * );
278
+ *
279
+ * const response = await fetch(`https://${connectionConfig?.subdomain}.snowflakecomputing.com/api/v2/statements`, {
280
+ * headers: { Authorization: `Bearer ${accessToken}` },
281
+ * });
282
+ * ```
283
+ */
284
+ getWorkspaceConnection(connectorId: string): Promise<ConnectorConnectionResponse>;
285
+ /**
286
+ * @internal
287
+ * @deprecated Use {@link getCurrentAppUserConnection} instead.
288
+ */
289
+ getCurrentAppUserAccessToken(connectorId: string): Promise<string>;
290
+ /**
291
+ * Retrieves the OAuth access token and connection configuration for an [app user connector](#app-user-connectors).
292
+ *
293
+ * The token returned is specific to the app user making the current request. For this to work, the SDK client must know which app user to act on behalf of. Use {@linkcode createClientFromRequest | createClientFromRequest()} in a Base44 backend function to create such a client. It reads the app user's JWT from the incoming request and attaches it automatically so the runtime can resolve the correct user's connection.
294
+ *
295
+ * The connector must be registered in Workspace Settings with OAuth credentials before this method can return a connection. The app user must also have completed the OAuth flow using [connectAppUser()](#connectappuser).
296
+ *
297
+ * @param connectorId - The ID of the app user connector configured in your workspace. This is not the integration type string. You can find it on the connector's settings page in Workspace Settings.
298
+ * @returns Promise resolving to an {@link AppUserConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * // Basic usage
303
+ * const { accessToken } = await base44.asServiceRole.connectors.getCurrentAppUserConnection('abc123def');
304
+ *
305
+ * const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', {
306
+ * headers: { Authorization: `Bearer ${accessToken}` }
307
+ * });
308
+ *
309
+ * const data = await response.json();
310
+ * ```
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * // Using connectionConfig
315
+ * const { accessToken, connectionConfig } = await base44.asServiceRole.connectors.getCurrentAppUserConnection('abc123def');
316
+ *
317
+ * const subdomain = connectionConfig?.subdomain;
318
+ * const response = await fetch(
319
+ * `https://${subdomain}.example.com/api/v1/resources`,
320
+ * { headers: { Authorization: `Bearer ${accessToken}` } }
321
+ * );
322
+ *
323
+ * const data = await response.json();
324
+ * ```
325
+ */
326
+ getCurrentAppUserConnection(connectorId: string): Promise<AppUserConnectorConnectionResponse>;
327
+ }
328
+ /**
329
+ * User-scoped connectors module for managing app user OAuth connections.
330
+ *
331
+ * This module provides methods for app user OAuth flows: initiating an OAuth connection and disconnecting an app user's connection.
332
+ *
333
+ * Unlike {@link ConnectorsModule | ConnectorsModule} which manages app-scoped tokens,
334
+ * this module manages tokens scoped to individual app users. Methods are keyed on
335
+ * the connector ID, not the integration type.
336
+ *
337
+ * Available via `base44.connectors`.
338
+ */
339
+ export interface UserConnectorsModule {
340
+ /**
341
+ * Initiates the OAuth flow for an [app user connector](#app-user-connectors).
342
+ *
343
+ * Returns a redirect URL that the app user should be navigated to in order to
344
+ * authenticate with the external service. The scopes and integration type are
345
+ * derived from the connector configuration in the backend.
346
+ *
347
+ * @param connectorId - The ID of the app user connector configured in your workspace. The AI builder inserts this ID into generated code when it sets up the connector flow. You can also retrieve it from the workspace connectors API.
348
+ * @returns Promise resolving to the redirect URL string.
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * // Start OAuth for the app user
353
+ * const redirectUrl = await base44.connectors.connectAppUser('abc123def');
354
+ *
355
+ * // Redirect the user to the OAuth provider
356
+ * window.location.href = redirectUrl;
357
+ * ```
358
+ */
359
+ connectAppUser(connectorId: string): Promise<string>;
360
+ /**
361
+ * Disconnects an app user's OAuth connection for an [app user connector](#app-user-connectors).
362
+ *
363
+ * Removes the stored OAuth credentials for the currently authenticated app user's
364
+ * connection to the specified connector.
365
+ *
366
+ * @param connectorId - The ID of the app user connector configured in your workspace. The AI builder inserts this ID into generated code when it sets up the connector flow. You can also retrieve it from the workspace connectors API.
367
+ * @returns Promise resolving when the connection has been removed.
368
+ *
369
+ * @example
370
+ * ```typescript
371
+ * // Disconnect the app user's connection
372
+ * await base44.connectors.disconnectAppUser('abc123def');
373
+ * ```
374
+ */
375
+ disconnectAppUser(connectorId: string): Promise<void>;
376
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { CustomIntegrationsModule } from "./custom-integrations.types.js";
3
+ /**
4
+ * Creates the custom integrations module for the Base44 SDK.
5
+ *
6
+ * @param axios - Axios instance for making HTTP requests
7
+ * @param appId - Application ID
8
+ * @returns Custom integrations module with `call()` method
9
+ * @internal
10
+ */
11
+ export declare function createCustomIntegrationsModule(axios: AxiosInstance, appId: string): CustomIntegrationsModule;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Creates the custom integrations module for the Base44 SDK.
3
+ *
4
+ * @param axios - Axios instance for making HTTP requests
5
+ * @param appId - Application ID
6
+ * @returns Custom integrations module with `call()` method
7
+ * @internal
8
+ */
9
+ export function createCustomIntegrationsModule(axios, appId) {
10
+ return {
11
+ async call(slug, operationId, params) {
12
+ // Validate required parameters
13
+ if (!(slug === null || slug === void 0 ? void 0 : slug.trim())) {
14
+ throw new Error("Integration slug is required and cannot be empty");
15
+ }
16
+ if (!(operationId === null || operationId === void 0 ? void 0 : operationId.trim())) {
17
+ throw new Error("Operation ID is required and cannot be empty");
18
+ }
19
+ // Convert camelCase to snake_case for Python backend
20
+ const { pathParams, queryParams, ...rest } = params !== null && params !== void 0 ? params : {};
21
+ const body = {
22
+ ...rest,
23
+ ...(pathParams && { path_params: pathParams }),
24
+ ...(queryParams && { query_params: queryParams }),
25
+ };
26
+ // Make the API call
27
+ const response = await axios.post(`/apps/${appId}/integrations/custom/${slug}/${operationId}`, body);
28
+ // The axios interceptor extracts response.data, so we get the payload directly
29
+ return response;
30
+ },
31
+ };
32
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Parameters for calling a custom integration endpoint.
3
+ * @internal
4
+ */
5
+ export interface CustomIntegrationCallParams {
6
+ /**
7
+ * Request body payload to send to the external API.
8
+ */
9
+ payload?: Record<string, any>;
10
+ /**
11
+ * Path parameters to substitute in the URL. For example, `{ owner: "user", repo: "repo" }`.
12
+ */
13
+ pathParams?: Record<string, string>;
14
+ /**
15
+ * Query string parameters to append to the URL.
16
+ */
17
+ queryParams?: Record<string, any>;
18
+ }
19
+ /**
20
+ * Response from a custom integration call.
21
+ * @internal
22
+ */
23
+ export interface CustomIntegrationCallResponse {
24
+ /**
25
+ * Whether the external API returned a 2xx status code.
26
+ */
27
+ success: boolean;
28
+ /**
29
+ * The HTTP status code returned by the external API.
30
+ */
31
+ status_code: number;
32
+ /**
33
+ * The response data from the external API.
34
+ * Can be any JSON-serializable value depending on the external API's response.
35
+ */
36
+ data: any;
37
+ }
38
+ /**
39
+ * Module for calling custom pre-configured API integrations.
40
+ *
41
+ * Custom integrations allow workspace administrators to connect any external API by importing an OpenAPI specification. Apps in the workspace can then call these integrations using this module.
42
+ */
43
+ export interface CustomIntegrationsModule {
44
+ /**
45
+ * Call a custom integration endpoint.
46
+ *
47
+ * @param slug - The integration's unique identifier, as defined by the workspace admin.
48
+ * @param operationId - The endpoint in `method:path` format. For example, `"get:/contacts"`, or `"post:/users/{id}"`. The method is the HTTP verb in lowercase and the path matches the OpenAPI specification.
49
+ * @param params - Optional parameters including payload, pathParams, and queryParams.
50
+ * @returns Promise resolving to the integration call response.
51
+ *
52
+ * @throws {Error} If slug is not provided.
53
+ * @throws {Error} If operationId is not provided.
54
+ * @throws {Base44Error} If the integration or operation is not found (404).
55
+ * @throws {Base44Error} If the external API call fails (502).
56
+ * @throws {Base44Error} If the request times out (504).
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Call a custom CRM integration
61
+ * const response = await base44.integrations.custom.call(
62
+ * "my-crm",
63
+ * "get:/contacts",
64
+ * { queryParams: { limit: 10 } }
65
+ * );
66
+ *
67
+ * if (response.success) {
68
+ * console.log("Contacts:", response.data);
69
+ * }
70
+ * ```
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * // Call with path params and request body
75
+ * const response = await base44.integrations.custom.call(
76
+ * "github",
77
+ * "post:/repos/{owner}/{repo}/issues",
78
+ * {
79
+ * pathParams: { owner: "myorg", repo: "myrepo" },
80
+ * payload: {
81
+ * title: "Bug report",
82
+ * body: "Something is broken"
83
+ * }
84
+ * }
85
+ * );
86
+ * ```
87
+ */
88
+ call(slug: string, operationId: string, params?: CustomIntegrationCallParams): Promise<CustomIntegrationCallResponse>;
89
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { EntitiesModule } from "./entities.types";
3
+ import { RoomsSocket } from "../utils/socket-utils.js";
4
+ /**
5
+ * Configuration for the entities module.
6
+ * @internal
7
+ */
8
+ export interface EntitiesModuleConfig {
9
+ axios: AxiosInstance;
10
+ appId: string;
11
+ getSocket: () => ReturnType<typeof RoomsSocket>;
12
+ }
13
+ /**
14
+ * Creates the entities module for the Base44 SDK.
15
+ *
16
+ * @param config - Configuration object containing axios, appId, and getSocket
17
+ * @returns Entities module with dynamic entity access
18
+ * @internal
19
+ */
20
+ export declare function createEntitiesModule(config: EntitiesModuleConfig): EntitiesModule;