@base44-preview/sdk 0.8.17-pr.70.d526c10 → 0.8.17-pr.71.cfa9c83

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.
@@ -83,10 +83,7 @@ export interface Base44Client {
83
83
  agents: AgentsModule;
84
84
  /** {@link AppLogsModule | App logs module} for tracking app usage. */
85
85
  appLogs: AppLogsModule;
86
- /**
87
- * {@link AnalyticsModule | Analytics module} for tracking app usage.
88
- * @internal
89
- */
86
+ /** {@link AnalyticsModule | Analytics module} for tracking app usage. */
90
87
  analytics: AnalyticsModule;
91
88
  /** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
92
89
  cleanup: () => void;
@@ -1,6 +1,8 @@
1
1
  import { getAccessToken } from "../utils/auth-utils.js";
2
2
  export function createAgentsModule({ axios, getSocket, appId, serverUrl, token, }) {
3
3
  const baseURL = `/apps/${appId}/agents`;
4
+ // Track active conversations
5
+ const currentConversations = {};
4
6
  const getConversations = () => {
5
7
  return axios.get(`${baseURL}/conversations`);
6
8
  };
@@ -16,22 +18,39 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
16
18
  return axios.post(`${baseURL}/conversations`, conversation);
17
19
  };
18
20
  const addMessage = async (conversation, message) => {
19
- const room = `/agent-conversations/${conversation.id}`;
20
- const socket = getSocket();
21
- await socket.updateModel(room, {
22
- ...conversation,
23
- messages: [...(conversation.messages || []), message],
24
- });
25
- return axios.post(`${baseURL}/conversations/${conversation.id}/messages`, message);
21
+ return axios.post(`${baseURL}/conversations/v2/${conversation.id}/messages`, message);
26
22
  };
27
23
  const subscribeToConversation = (conversationId, onUpdate) => {
28
24
  const room = `/agent-conversations/${conversationId}`;
29
25
  const socket = getSocket();
26
+ // Store the promise for initial conversation state
27
+ const conversationPromise = getConversation(conversationId).then((conv) => {
28
+ currentConversations[conversationId] = conv;
29
+ return conv;
30
+ });
30
31
  return socket.subscribeToRoom(room, {
31
32
  connect: () => { },
32
- update_model: ({ data: jsonStr }) => {
33
- const conv = JSON.parse(jsonStr);
34
- onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(conv);
33
+ update_model: async ({ data: jsonStr }) => {
34
+ const data = JSON.parse(jsonStr);
35
+ if (data._message) {
36
+ // Wait for initial conversation to be loaded
37
+ await conversationPromise;
38
+ const message = data._message;
39
+ // Update shared conversation state
40
+ const currentConversation = currentConversations[conversationId];
41
+ if (currentConversation) {
42
+ const messages = currentConversation.messages || [];
43
+ const existingIndex = messages.findIndex((m) => m.id === message.id);
44
+ const updatedMessages = existingIndex !== -1
45
+ ? messages.map((m, i) => (i === existingIndex ? message : m))
46
+ : [...messages, message];
47
+ currentConversations[conversationId] = {
48
+ ...currentConversation,
49
+ messages: updatedMessages,
50
+ };
51
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(currentConversations[conversationId]);
52
+ }
53
+ }
35
54
  },
36
55
  });
37
56
  };
@@ -72,7 +72,7 @@ export interface AgentMessageMetadata {
72
72
  export interface AgentConversation {
73
73
  /** Unique identifier for the conversation. */
74
74
  id: string;
75
- /** App ID. */
75
+ /** Application ID. */
76
76
  app_id: string;
77
77
  /** Name of the agent in this conversation. */
78
78
  agent_name: string;
@@ -140,7 +140,7 @@ export interface AgentsModuleConfig {
140
140
  axios: AxiosInstance;
141
141
  /** Function to get WebSocket instance for real-time updates (lazy initialization) */
142
142
  getSocket: () => ReturnType<typeof RoomsSocket>;
143
- /** App ID */
143
+ /** Application ID */
144
144
  appId: string;
145
145
  /** Server URL */
146
146
  serverUrl?: string;
@@ -11,7 +11,9 @@ export interface ConnectorAccessTokenResponse {
11
11
  /**
12
12
  * Connectors module for managing OAuth tokens for external services.
13
13
  *
14
- * This module allows you to retrieve OAuth access tokens for external services that the app has connected to. Connectors are app-scoped. When an app builder connects an integration like Google Calendar or Slack, all users of the app share that same connection.
14
+ * This module allows you to retrieve OAuth access tokens for external services
15
+ * that the app has connected to. Use these tokens to make API
16
+ * calls to external services.
15
17
  *
16
18
  * Unlike the integrations module that provides pre-built functions, connectors give you
17
19
  * raw OAuth tokens so you can call external service APIs directly with full control over
@@ -24,9 +26,9 @@ export interface ConnectorsModule {
24
26
  /**
25
27
  * Retrieves an OAuth access token for a specific external integration type.
26
28
  *
27
- * Returns the OAuth token string for an external service that an app builder
28
- * has connected to. This token represents the connected app builder's account
29
- * and can be used to make authenticated API calls to that external service on behalf of the app.
29
+ * Returns the OAuth token string for an external service that the app
30
+ * has connected to. You can then use this token to make authenticated API calls
31
+ * to that external service.
30
32
  *
31
33
  * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
32
34
  * @returns Promise resolving to the access token string.
@@ -7,13 +7,18 @@ export interface CustomIntegrationCallParams {
7
7
  */
8
8
  payload?: Record<string, any>;
9
9
  /**
10
- * Path parameters to substitute in the URL. For example, `{ owner: "user", repo: "repo" }`.
10
+ * Path parameters to substitute in the URL (e.g., `{ owner: "user", repo: "repo" }`).
11
11
  */
12
12
  pathParams?: Record<string, string>;
13
13
  /**
14
14
  * Query string parameters to append to the URL.
15
15
  */
16
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>;
17
22
  }
18
23
  /**
19
24
  * Response from a custom integration call.
@@ -34,17 +39,60 @@ export interface CustomIntegrationCallResponse {
34
39
  data: any;
35
40
  }
36
41
  /**
37
- * Module for calling custom pre-configured API integrations.
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
+ * );
38
64
  *
39
- * 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.
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
+ * ```
40
88
  */
41
89
  export interface CustomIntegrationsModule {
42
90
  /**
43
91
  * Call a custom integration endpoint.
44
92
  *
45
- * @param slug - The integration's unique identifier, as defined by the workspace admin.
46
- * @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.
47
- * @param params - Optional parameters including payload, pathParams, and queryParams.
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.
48
96
  * @returns Promise resolving to the integration call response.
49
97
  *
50
98
  * @throws {Error} If slug is not provided.
@@ -52,36 +100,6 @@ export interface CustomIntegrationsModule {
52
100
  * @throws {Base44Error} If the integration or operation is not found (404).
53
101
  * @throws {Base44Error} If the external API call fails (502).
54
102
  * @throws {Base44Error} If the request times out (504).
55
- *
56
- * @example
57
- * ```typescript
58
- * // Call a custom CRM integration
59
- * const response = await base44.integrations.custom.call(
60
- * "my-crm",
61
- * "get:/contacts",
62
- * { queryParams: { limit: 10 } }
63
- * );
64
- *
65
- * if (response.success) {
66
- * console.log("Contacts:", response.data);
67
- * }
68
- * ```
69
- *
70
- * @example
71
- * ```typescript
72
- * // Call with path params and request body
73
- * const response = await base44.integrations.custom.call(
74
- * "github",
75
- * "post:/repos/{owner}/{repo}/issues",
76
- * {
77
- * pathParams: { owner: "myorg", repo: "myrepo" },
78
- * payload: {
79
- * title: "Bug report",
80
- * body: "Something is broken"
81
- * }
82
- * }
83
- * );
84
- * ```
85
103
  */
86
104
  call(slug: string, operationId: string, params?: CustomIntegrationCallParams): Promise<CustomIntegrationCallResponse>;
87
105
  }
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * Event types for realtime entity updates.
3
- * @internal
4
3
  */
5
4
  export type RealtimeEventType = "create" | "update" | "delete";
6
5
  /**
7
6
  * Payload received when a realtime event occurs.
8
- * @internal
9
7
  */
10
8
  export interface RealtimeEvent {
11
9
  /** The type of change that occurred */
@@ -19,12 +17,10 @@ export interface RealtimeEvent {
19
17
  }
20
18
  /**
21
19
  * Callback function invoked when a realtime event occurs.
22
- * @internal
23
20
  */
24
21
  export type RealtimeCallback = (event: RealtimeEvent) => void;
25
22
  /**
26
23
  * Function returned from subscribe, call it to unsubscribe.
27
- * @internal
28
24
  */
29
25
  export type Subscription = () => void;
30
26
  /**
@@ -289,7 +285,6 @@ export interface EntityHandler {
289
285
  * // Later, unsubscribe
290
286
  * unsubscribe();
291
287
  * ```
292
- * @internal
293
288
  */
294
289
  subscribe(callback: RealtimeCallback): Subscription;
295
290
  }
@@ -320,28 +320,22 @@ export interface CoreIntegrations {
320
320
  CreateFileSignedUrl(params: CreateFileSignedUrlParams): Promise<CreateFileSignedUrlResult>;
321
321
  }
322
322
  /**
323
- * Integrations module for calling integration methods.
323
+ * Integrations module for calling integration endpoints.
324
324
  *
325
- * This module provides access to integration methods for interacting with external services. Unlike the connectors module that gives you raw OAuth tokens, integrations provide pre-built functions that Base44 executes on your behalf.
325
+ * This module provides access to integration endpoints for interacting with external
326
+ * services. Integrations are organized into packages. Base44 provides built-in integrations
327
+ * in the `Core` package.
326
328
  *
327
- * There are two types of integrations:
329
+ * Unlike the connectors module that gives you raw OAuth tokens, integrations provide
330
+ * pre-built functions that Base44 executes on your behalf.
328
331
  *
329
- * - **Built-in integrations** (`Core`): Pre-built functions provided by Base44 for common tasks such as AI-powered text generation, image creation, file uploads, and email. Access core integration methods using:
330
- * ```
331
- * base44.integrations.Core.FunctionName(params)
332
- * ```
333
- *
334
- * - **Custom integrations** (`custom`): Pre-configured external APIs. Custom integration calls are proxied through Base44's backend, so credentials are never exposed to the frontend. Access custom integration methods using:
335
- * ```
336
- * base44.integrations.custom.call(slug, operationId, params)
337
- * ```
338
- *
339
- * <Info>To call a custom integration, it must be pre-configured by a workspace administrator who imports an OpenAPI specification.</Info>
332
+ * Integration endpoints are accessed dynamically using the pattern:
333
+ * `base44.integrations.PackageName.EndpointName(params)`
340
334
  *
341
335
  * This module is available to use with a client in all authentication modes:
342
336
  *
343
- * - **Anonymous or User authentication** (`base44.integrations`): Integration methods are invoked with the current user's permissions. Anonymous users invoke methods without authentication, while authenticated users invoke methods with their authentication context.
344
- * - **Service role authentication** (`base44.asServiceRole.integrations`): Integration methods are invoked with elevated admin-level permissions. The methods execute with admin authentication context.
337
+ * - **Anonymous or User authentication** (`base44.integrations`): Integration endpoints are invoked with the current user's permissions. Anonymous users invoke endpoints without authentication, while authenticated users invoke endpoints with their authentication context.
338
+ * - **Service role authentication** (`base44.asServiceRole.integrations`): Integration endpoints are invoked with elevated admin-level permissions. The endpoints execute with admin authentication context.
345
339
  */
346
340
  export type IntegrationsModule = {
347
341
  /**
@@ -349,7 +343,22 @@ export type IntegrationsModule = {
349
343
  */
350
344
  Core: CoreIntegrations;
351
345
  /**
352
- * Custom integrations module for calling pre-configured external APIs.
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
+ * ```
353
362
  */
354
363
  custom: CustomIntegrationsModule;
355
364
  } & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.17-pr.70.d526c10",
3
+ "version": "0.8.17-pr.71.cfa9c83",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",