@base44/sdk 0.8.10 → 0.8.11

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.
package/dist/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export type { AgentsModule, AgentConversation, AgentMessage, AgentMessageReasoni
12
12
  export type { AppLogsModule } from "./modules/app-logs.types.js";
13
13
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
14
14
  export type { ConnectorsModule } from "./modules/connectors.types.js";
15
+ export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
15
16
  export type { GetAccessTokenOptions, SaveAccessTokenOptions, RemoveAccessTokenOptions, GetLoginUrlOptions, } from "./utils/auth-utils.types.js";
@@ -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,105 @@
1
+ /**
2
+ * Parameters for calling a custom integration endpoint.
3
+ */
4
+ export interface CustomIntegrationCallParams {
5
+ /**
6
+ * Request body payload to send to the external API.
7
+ */
8
+ payload?: Record<string, any>;
9
+ /**
10
+ * Path parameters to substitute in the URL (e.g., `{ owner: "user", repo: "repo" }`).
11
+ */
12
+ pathParams?: Record<string, string>;
13
+ /**
14
+ * Query string parameters to append to the URL.
15
+ */
16
+ queryParams?: Record<string, any>;
17
+ /**
18
+ * Additional headers to send with this specific request.
19
+ * These are merged with the integration's configured headers.
20
+ */
21
+ headers?: Record<string, string>;
22
+ }
23
+ /**
24
+ * Response from a custom integration call.
25
+ */
26
+ export interface CustomIntegrationCallResponse {
27
+ /**
28
+ * Whether the external API returned a 2xx status code.
29
+ */
30
+ success: boolean;
31
+ /**
32
+ * The HTTP status code returned by the external API.
33
+ */
34
+ status_code: number;
35
+ /**
36
+ * The response data from the external API.
37
+ * Can be any JSON-serializable value depending on the external API's response.
38
+ */
39
+ data: any;
40
+ }
41
+ /**
42
+ * Module for calling custom workspace-level API integrations.
43
+ *
44
+ * Custom integrations allow workspace administrators to connect any external API
45
+ * by importing an OpenAPI specification. Apps in the workspace can then call
46
+ * these integrations using this module.
47
+ *
48
+ * Unlike the built-in integrations (like `Core`), custom integrations:
49
+ * - Are defined per-workspace by importing OpenAPI specs
50
+ * - Use a slug-based identifier instead of package names
51
+ * - Proxy requests through Base44's backend (credentials never exposed to frontend)
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * // Call a custom GitHub integration
56
+ * const response = await base44.integrations.custom.call(
57
+ * "github", // integration slug (defined by workspace admin)
58
+ * "listIssues", // operation ID from the OpenAPI spec
59
+ * {
60
+ * pathParams: { owner: "myorg", repo: "myrepo" },
61
+ * queryParams: { state: "open", per_page: 100 }
62
+ * }
63
+ * );
64
+ *
65
+ * if (response.success) {
66
+ * console.log("Issues:", response.data);
67
+ * } else {
68
+ * console.error("API returned error:", response.status_code);
69
+ * }
70
+ * ```
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * // Call with request body payload
75
+ * const response = await base44.integrations.custom.call(
76
+ * "github",
77
+ * "createIssue",
78
+ * {
79
+ * pathParams: { owner: "myorg", repo: "myrepo" },
80
+ * payload: {
81
+ * title: "Bug report",
82
+ * body: "Something is broken",
83
+ * labels: ["bug"]
84
+ * }
85
+ * }
86
+ * );
87
+ * ```
88
+ */
89
+ export interface CustomIntegrationsModule {
90
+ /**
91
+ * Call a custom integration endpoint.
92
+ *
93
+ * @param slug - The integration's unique identifier (slug), as defined by the workspace admin.
94
+ * @param operationId - The operation ID from the OpenAPI spec (e.g., "listIssues", "getUser").
95
+ * @param params - Optional parameters including payload, pathParams, queryParams, and headers.
96
+ * @returns Promise resolving to the integration call response.
97
+ *
98
+ * @throws {Error} If slug is not provided.
99
+ * @throws {Error} If operationId is not provided.
100
+ * @throws {Base44Error} If the integration or operation is not found (404).
101
+ * @throws {Base44Error} If the external API call fails (502).
102
+ * @throws {Base44Error} If the request times out (504).
103
+ */
104
+ call(slug: string, operationId: string, params?: CustomIntegrationCallParams): Promise<CustomIntegrationCallResponse>;
105
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { IntegrationsModule } from "./integrations.types";
2
+ import { IntegrationsModule } from "./integrations.types.js";
3
3
  /**
4
4
  * Creates the integrations module for the Base44 SDK.
5
5
  *
@@ -1,3 +1,4 @@
1
+ import { createCustomIntegrationsModule } from "./custom-integrations.js";
1
2
  /**
2
3
  * Creates the integrations module for the Base44 SDK.
3
4
  *
@@ -7,6 +8,8 @@
7
8
  * @internal
8
9
  */
9
10
  export function createIntegrationsModule(axios, appId) {
11
+ // Create the custom integrations module once
12
+ const customModule = createCustomIntegrationsModule(axios, appId);
10
13
  return new Proxy({}, {
11
14
  get(target, packageName) {
12
15
  // Skip internal properties
@@ -15,6 +18,10 @@ export function createIntegrationsModule(axios, appId) {
15
18
  packageName.startsWith("_")) {
16
19
  return undefined;
17
20
  }
21
+ // Handle 'custom' specially - return the custom integrations module
22
+ if (packageName === "custom") {
23
+ return customModule;
24
+ }
18
25
  // Create a proxy for integration endpoints
19
26
  return new Proxy({}, {
20
27
  get(target, endpointName) {
@@ -1,3 +1,4 @@
1
+ import { CustomIntegrationsModule } from "./custom-integrations.types.js";
1
2
  /**
2
3
  * Function signature for calling an integration endpoint.
3
4
  *
@@ -341,6 +342,25 @@ export type IntegrationsModule = {
341
342
  * Core package containing built-in Base44 integration functions.
342
343
  */
343
344
  Core: CoreIntegrations;
345
+ /**
346
+ * Custom integrations module for calling workspace-level API integrations.
347
+ *
348
+ * Allows calling external APIs that workspace admins have configured
349
+ * by importing OpenAPI specifications.
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * const response = await base44.integrations.custom.call(
354
+ * "github", // integration slug
355
+ * "listIssues", // operation ID
356
+ * {
357
+ * pathParams: { owner: "myorg", repo: "myrepo" },
358
+ * queryParams: { state: "open" }
359
+ * }
360
+ * );
361
+ * ```
362
+ */
363
+ custom: CustomIntegrationsModule;
344
364
  } & {
345
365
  /**
346
366
  * Access to additional integration packages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44/sdk",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",