@base44-preview/sdk 0.8.10-pr.58.f752ec2 → 0.8.10-pr.62.2685d84

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/client.js CHANGED
@@ -104,11 +104,7 @@ export function createClient(config) {
104
104
  serverUrl,
105
105
  });
106
106
  const userModules = {
107
- entities: createEntitiesModule({
108
- axios: axiosClient,
109
- appId,
110
- getSocket,
111
- }),
107
+ entities: createEntitiesModule(axiosClient, appId),
112
108
  integrations: createIntegrationsModule(axiosClient, appId),
113
109
  auth: userAuthModule,
114
110
  functions: createFunctionsModule(functionsAxiosClient, appId),
@@ -135,11 +131,7 @@ export function createClient(config) {
135
131
  },
136
132
  };
137
133
  const serviceRoleModules = {
138
- entities: createEntitiesModule({
139
- axios: serviceRoleAxiosClient,
140
- appId,
141
- getSocket,
142
- }),
134
+ entities: createEntitiesModule(serviceRoleAxiosClient, appId),
143
135
  integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
144
136
  sso: createSsoModule(serviceRoleAxiosClient, appId, token),
145
137
  connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
4
4
  export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
5
5
  export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
6
6
  export * from "./types.js";
7
- export type { EntitiesModule, EntityHandler, RealtimeEventType, RealtimeEvent, RealtimeCallback, SubscribeOptions, Subscription, } from "./modules/entities.types.js";
7
+ export type { EntitiesModule, EntityHandler, } from "./modules/entities.types.js";
8
8
  export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
9
9
  export type { IntegrationsModule, IntegrationPackage, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
10
  export type { FunctionsModule } from "./modules/functions.types.js";
@@ -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,23 +1,5 @@
1
1
  import { AxiosInstance } from "axios";
2
2
  import { EntitiesModule } from "./entities.types";
3
- import { RoomsSocket } from "../utils/socket-utils";
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;
21
3
  /**
22
4
  * Creates the entities module for the Base44 SDK.
23
5
  *
@@ -25,6 +7,5 @@ export declare function createEntitiesModule(config: EntitiesModuleConfig): Enti
25
7
  * @param appId - Application ID
26
8
  * @returns Entities module with dynamic entity access
27
9
  * @internal
28
- * @deprecated Use the config object overload instead
29
10
  */
30
11
  export declare function createEntitiesModule(axios: AxiosInstance, appId: string): EntitiesModule;
@@ -1,15 +1,12 @@
1
- export function createEntitiesModule(configOrAxios, appIdArg) {
2
- // Handle both old and new signatures for backwards compatibility
3
- const config = "axios" in configOrAxios
4
- ? configOrAxios
5
- : {
6
- axios: configOrAxios,
7
- appId: appIdArg,
8
- getSocket: () => {
9
- throw new Error("Realtime subscriptions are not available. Please update your client configuration.");
10
- },
11
- };
12
- const { axios, appId, getSocket } = config;
1
+ /**
2
+ * Creates the entities module for the Base44 SDK.
3
+ *
4
+ * @param axios - Axios instance
5
+ * @param appId - Application ID
6
+ * @returns Entities module with dynamic entity access
7
+ * @internal
8
+ */
9
+ export function createEntitiesModule(axios, appId) {
13
10
  // Using Proxy to dynamically handle entity names
14
11
  return new Proxy({}, {
15
12
  get(target, entityName) {
@@ -20,59 +17,20 @@ export function createEntitiesModule(configOrAxios, appIdArg) {
20
17
  return undefined;
21
18
  }
22
19
  // Create entity handler
23
- return createEntityHandler(axios, appId, entityName, getSocket);
20
+ return createEntityHandler(axios, appId, entityName);
24
21
  },
25
22
  });
26
23
  }
27
- /**
28
- * Creates a stable hash from a query object for room naming.
29
- * @internal
30
- */
31
- function hashQuery(query) {
32
- const sortedKeys = Object.keys(query).sort();
33
- const normalized = sortedKeys
34
- .map((k) => `${k}:${JSON.stringify(query[k])}`)
35
- .join("|");
36
- // Simple hash function
37
- let hash = 0;
38
- for (let i = 0; i < normalized.length; i++) {
39
- const char = normalized.charCodeAt(i);
40
- hash = (hash << 5) - hash + char;
41
- hash = hash & hash; // Convert to 32bit integer
42
- }
43
- return Math.abs(hash).toString(36);
44
- }
45
- /**
46
- * Parses the realtime message data and extracts event information.
47
- * @internal
48
- */
49
- function parseRealtimeMessage(dataStr) {
50
- var _a;
51
- try {
52
- const parsed = JSON.parse(dataStr);
53
- return {
54
- type: parsed.type,
55
- data: parsed.data,
56
- id: parsed.id || ((_a = parsed.data) === null || _a === void 0 ? void 0 : _a.id),
57
- timestamp: parsed.timestamp || new Date().toISOString(),
58
- previousData: parsed.previousData,
59
- };
60
- }
61
- catch (_b) {
62
- return null;
63
- }
64
- }
65
24
  /**
66
25
  * Creates a handler for a specific entity.
67
26
  *
68
27
  * @param axios - Axios instance
69
28
  * @param appId - Application ID
70
29
  * @param entityName - Entity name
71
- * @param getSocket - Function to get the socket instance
72
30
  * @returns Entity handler with CRUD methods
73
31
  * @internal
74
32
  */
75
- function createEntityHandler(axios, appId, entityName, getSocket) {
33
+ function createEntityHandler(axios, appId, entityName) {
76
34
  const baseURL = `/apps/${appId}/entities/${entityName}`;
77
35
  return {
78
36
  // List entities with optional pagination and sorting
@@ -137,52 +95,5 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
137
95
  },
138
96
  });
139
97
  },
140
- // Subscribe to realtime updates
141
- subscribe(callbackOrIdOrQuery, callbackOrOptions, optionsArg) {
142
- let room;
143
- let callback;
144
- let options;
145
- // Parse overloaded arguments
146
- if (typeof callbackOrIdOrQuery === "function") {
147
- // subscribe(callback, options?)
148
- room = `entities:${appId}:${entityName}`;
149
- callback = callbackOrIdOrQuery;
150
- options = callbackOrOptions;
151
- }
152
- else if (typeof callbackOrIdOrQuery === "string") {
153
- // subscribe(id, callback, options?)
154
- room = `entities:${appId}:${entityName}:${callbackOrIdOrQuery}`;
155
- callback = callbackOrOptions;
156
- options = optionsArg;
157
- }
158
- else {
159
- // subscribe(query, callback, options?)
160
- const queryHash = hashQuery(callbackOrIdOrQuery);
161
- room = `entities:${appId}:${entityName}:query:${queryHash}`;
162
- callback = callbackOrOptions;
163
- options = optionsArg;
164
- }
165
- const eventFilter = options === null || options === void 0 ? void 0 : options.events;
166
- // Get the socket and subscribe to the room
167
- const socket = getSocket();
168
- const unsubscribe = socket.subscribeToRoom(room, {
169
- update_model: (msg) => {
170
- // Only process messages for our room
171
- if (msg.room !== room)
172
- return;
173
- const event = parseRealtimeMessage(msg.data);
174
- if (!event)
175
- return;
176
- // Apply event type filter if specified
177
- if (eventFilter && !eventFilter.includes(event.type)) {
178
- return;
179
- }
180
- callback(event);
181
- },
182
- });
183
- return {
184
- unsubscribe,
185
- };
186
- },
187
98
  };
188
99
  }
@@ -1,40 +1,3 @@
1
- /**
2
- * Event types for realtime entity updates.
3
- */
4
- export type RealtimeEventType = "create" | "update" | "delete";
5
- /**
6
- * Payload received when a realtime event occurs.
7
- */
8
- export interface RealtimeEvent<T = Record<string, any>> {
9
- /** The type of change that occurred */
10
- type: RealtimeEventType;
11
- /** The entity data (new/updated for create/update, previous for delete) */
12
- data: T;
13
- /** The unique identifier of the affected entity */
14
- id: string;
15
- /** ISO 8601 timestamp of when the event occurred */
16
- timestamp: string;
17
- /** For update events, contains the previous data before the change */
18
- previousData?: T;
19
- }
20
- /**
21
- * Callback function invoked when a realtime event occurs.
22
- */
23
- export type RealtimeCallback<T = Record<string, any>> = (event: RealtimeEvent<T>) => void;
24
- /**
25
- * Options for subscribing to realtime updates.
26
- */
27
- export interface SubscribeOptions {
28
- /** Filter events by type. Defaults to all types. */
29
- events?: RealtimeEventType[];
30
- }
31
- /**
32
- * Handle returned from subscribe, used to unsubscribe.
33
- */
34
- export interface Subscription {
35
- /** Stops listening to updates and cleans up the subscription. */
36
- unsubscribe: () => void;
37
- }
38
1
  /**
39
2
  * Entity handler providing CRUD operations for a specific entity type.
40
3
  *
@@ -279,93 +242,6 @@ export interface EntityHandler {
279
242
  * ```
280
243
  */
281
244
  importEntities(file: File): Promise<any>;
282
- /**
283
- * Subscribes to realtime updates for all records of this entity type.
284
- *
285
- * Receives notifications whenever any record is created, updated, or deleted.
286
- *
287
- * @param callback - Function called when an entity changes.
288
- * @param options - Optional configuration for filtering events.
289
- * @returns Subscription handle with an unsubscribe method.
290
- *
291
- * @example
292
- * ```typescript
293
- * // Subscribe to all Task changes
294
- * const subscription = base44.entities.Task.subscribe((event) => {
295
- * console.log(`Task ${event.id} was ${event.type}d:`, event.data);
296
- * });
297
- *
298
- * // Later, unsubscribe
299
- * subscription.unsubscribe();
300
- * ```
301
- *
302
- * @example
303
- * ```typescript
304
- * // Subscribe only to create events
305
- * const subscription = base44.entities.Task.subscribe(
306
- * (event) => console.log("New task:", event.data),
307
- * { events: ["create"] }
308
- * );
309
- * ```
310
- */
311
- subscribe(callback: RealtimeCallback, options?: SubscribeOptions): Subscription;
312
- /**
313
- * Subscribes to realtime updates for a specific entity record.
314
- *
315
- * Receives notifications when the specified record is updated or deleted.
316
- *
317
- * @param id - The unique identifier of the record to watch.
318
- * @param callback - Function called when the entity changes.
319
- * @param options - Optional configuration for filtering events.
320
- * @returns Subscription handle with an unsubscribe method.
321
- *
322
- * @example
323
- * ```typescript
324
- * // Subscribe to a specific task
325
- * const subscription = base44.entities.Task.subscribe("task-123", (event) => {
326
- * if (event.type === "update") {
327
- * console.log("Task updated:", event.data);
328
- * } else if (event.type === "delete") {
329
- * console.log("Task was deleted");
330
- * }
331
- * });
332
- * ```
333
- */
334
- subscribe(id: string, callback: RealtimeCallback, options?: SubscribeOptions): Subscription;
335
- /**
336
- * Subscribes to realtime updates for records matching a query.
337
- *
338
- * Receives notifications for records that match the specified criteria.
339
- * Includes create events when new records match the query, update events
340
- * when matching records change, and delete events when matching records
341
- * are removed.
342
- *
343
- * @param query - Query object with field-value pairs to filter records.
344
- * @param callback - Function called when a matching entity changes.
345
- * @param options - Optional configuration for filtering events.
346
- * @returns Subscription handle with an unsubscribe method.
347
- *
348
- * @example
349
- * ```typescript
350
- * // Subscribe to all completed tasks
351
- * const subscription = base44.entities.Task.subscribe(
352
- * { isCompleted: true },
353
- * (event) => {
354
- * console.log(`Completed task ${event.type}:`, event.data);
355
- * }
356
- * );
357
- * ```
358
- *
359
- * @example
360
- * ```typescript
361
- * // Subscribe to high-priority active tasks
362
- * const subscription = base44.entities.Task.subscribe(
363
- * { priority: "high", status: "active" },
364
- * (event) => console.log("High priority task changed:", event.data)
365
- * );
366
- * ```
367
- */
368
- subscribe(query: Record<string, any>, callback: RealtimeCallback, options?: SubscribeOptions): Subscription;
369
245
  }
370
246
  /**
371
247
  * Entities module for managing app data.
@@ -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.10-pr.58.f752ec2",
3
+ "version": "0.8.10-pr.62.2685d84",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",