@base44-preview/sdk 0.8.9-pr.61.ec411f8 → 0.8.10-pr.62.8f72a2c

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,60 @@
1
+ /**
2
+ * Normalizes parameters to snake_case for the API.
3
+ *
4
+ * Supports both camelCase (pathParams) and snake_case (path_params) input,
5
+ * always outputting snake_case for the backend.
6
+ */
7
+ function normalizeParams(params) {
8
+ var _a, _b;
9
+ if (!params) {
10
+ return {};
11
+ }
12
+ const normalized = {};
13
+ // Handle payload
14
+ if (params.payload !== undefined) {
15
+ normalized.payload = params.payload;
16
+ }
17
+ // Handle path_params (support both camelCase and snake_case)
18
+ const pathParams = (_a = params.pathParams) !== null && _a !== void 0 ? _a : params.path_params;
19
+ if (pathParams !== undefined) {
20
+ normalized.path_params = pathParams;
21
+ }
22
+ // Handle query_params (support both camelCase and snake_case)
23
+ const queryParams = (_b = params.queryParams) !== null && _b !== void 0 ? _b : params.query_params;
24
+ if (queryParams !== undefined) {
25
+ normalized.query_params = queryParams;
26
+ }
27
+ // Handle headers
28
+ if (params.headers !== undefined) {
29
+ normalized.headers = params.headers;
30
+ }
31
+ return normalized;
32
+ }
33
+ /**
34
+ * Creates the custom integrations module for the Base44 SDK.
35
+ *
36
+ * @param axios - Axios instance for making HTTP requests
37
+ * @param appId - Application ID
38
+ * @returns Custom integrations module with `call()` method
39
+ * @internal
40
+ */
41
+ export function createCustomIntegrationsModule(axios, appId) {
42
+ return {
43
+ async call(slug, operationId, params) {
44
+ // Validate required parameters
45
+ if (!slug) {
46
+ throw new Error("Integration slug is required");
47
+ }
48
+ if (!operationId) {
49
+ throw new Error("Operation ID is required");
50
+ }
51
+ // Normalize parameters to snake_case
52
+ const normalizedParams = normalizeParams(params);
53
+ // Make the API call
54
+ const response = await axios.post(`/apps/${appId}/integrations/custom/${slug}/${operationId}`, normalizedParams);
55
+ // Return the response data
56
+ // Note: axios interceptor already extracts data from response
57
+ return response;
58
+ },
59
+ };
60
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Parameters for calling a custom integration endpoint.
3
+ *
4
+ * Supports both camelCase and snake_case parameter names for developer convenience.
5
+ * The SDK will normalize to snake_case before sending to the API.
6
+ */
7
+ export interface CustomIntegrationCallParams {
8
+ /**
9
+ * Request body payload to send to the external API.
10
+ */
11
+ payload?: Record<string, any>;
12
+ /**
13
+ * Path parameters to substitute in the URL (e.g., `{ owner: "user", repo: "repo" }`).
14
+ * Can use either `pathParams` (camelCase) or `path_params` (snake_case).
15
+ */
16
+ pathParams?: Record<string, string>;
17
+ /**
18
+ * Path parameters to substitute in the URL (snake_case variant).
19
+ * @see {@link pathParams}
20
+ */
21
+ path_params?: Record<string, string>;
22
+ /**
23
+ * Query string parameters to append to the URL.
24
+ * Can use either `queryParams` (camelCase) or `query_params` (snake_case).
25
+ */
26
+ queryParams?: Record<string, any>;
27
+ /**
28
+ * Query string parameters (snake_case variant).
29
+ * @see {@link queryParams}
30
+ */
31
+ query_params?: Record<string, any>;
32
+ /**
33
+ * Additional headers to send with this specific request.
34
+ * These are merged with the integration's configured headers.
35
+ */
36
+ headers?: Record<string, string>;
37
+ }
38
+ /**
39
+ * Response from a custom integration call.
40
+ */
41
+ export interface CustomIntegrationCallResponse {
42
+ /**
43
+ * Whether the external API returned a 2xx status code.
44
+ */
45
+ success: boolean;
46
+ /**
47
+ * The HTTP status code returned by the external API.
48
+ */
49
+ status_code: number;
50
+ /**
51
+ * The response data from the external API.
52
+ * Can be any JSON-serializable value depending on the external API's response.
53
+ */
54
+ data: any;
55
+ }
56
+ /**
57
+ * Module for calling custom workspace-level API integrations.
58
+ *
59
+ * Custom integrations allow workspace administrators to connect any external API
60
+ * by importing an OpenAPI specification. Apps in the workspace can then call
61
+ * these integrations using this module.
62
+ *
63
+ * Unlike the built-in integrations (like `Core`), custom integrations:
64
+ * - Are defined per-workspace by importing OpenAPI specs
65
+ * - Use a slug-based identifier instead of package names
66
+ * - Proxy requests through Base44's backend (credentials never exposed to frontend)
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // Call a custom GitHub integration
71
+ * const response = await base44.integrations.custom.call(
72
+ * "github", // integration slug (defined by workspace admin)
73
+ * "listIssues", // operation ID from the OpenAPI spec
74
+ * {
75
+ * pathParams: { owner: "myorg", repo: "myrepo" },
76
+ * queryParams: { state: "open", per_page: 100 }
77
+ * }
78
+ * );
79
+ *
80
+ * if (response.success) {
81
+ * console.log("Issues:", response.data);
82
+ * } else {
83
+ * console.error("API returned error:", response.status_code);
84
+ * }
85
+ * ```
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Call with request body payload
90
+ * const response = await base44.integrations.custom.call(
91
+ * "github",
92
+ * "createIssue",
93
+ * {
94
+ * pathParams: { owner: "myorg", repo: "myrepo" },
95
+ * payload: {
96
+ * title: "Bug report",
97
+ * body: "Something is broken",
98
+ * labels: ["bug"]
99
+ * }
100
+ * }
101
+ * );
102
+ * ```
103
+ */
104
+ export interface CustomIntegrationsModule {
105
+ /**
106
+ * Call a custom integration endpoint.
107
+ *
108
+ * @param slug - The integration's unique identifier (slug), as defined by the workspace admin.
109
+ * @param operationId - The operation ID from the OpenAPI spec (e.g., "listIssues", "getUser").
110
+ * @param params - Optional parameters including payload, path params, query params, and headers.
111
+ * @returns Promise resolving to the integration call response.
112
+ *
113
+ * @throws {Error} If slug is not provided.
114
+ * @throws {Error} If operationId is not provided.
115
+ * @throws {Base44Error} If the integration or operation is not found (404).
116
+ * @throws {Base44Error} If the external API call fails (502).
117
+ * @throws {Base44Error} If the request times out (504).
118
+ */
119
+ call(slug: string, operationId: string, params?: CustomIntegrationCallParams): Promise<CustomIntegrationCallResponse>;
120
+ }
@@ -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-preview/sdk",
3
- "version": "0.8.9-pr.61.ec411f8",
3
+ "version": "0.8.10-pr.62.8f72a2c",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",