@base44-preview/sdk 0.7.0-pr.27.96b80f1 → 0.7.0-pr.27.eb342e0

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.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export type CreateClientOptions = {
2
+ onError?: (error: Error) => void;
3
+ };
1
4
  /**
2
5
  * Create a Base44 client instance
3
6
  * @param {Object} config - Client configuration
@@ -14,6 +17,7 @@ export declare function createClient(config: {
14
17
  token?: string;
15
18
  serviceToken?: string;
16
19
  requiresAuth?: boolean;
20
+ options?: CreateClientOptions;
17
21
  }): {
18
22
  /**
19
23
  * Set authentication token for all requests
@@ -39,14 +43,14 @@ export declare function createClient(config: {
39
43
  invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
40
44
  };
41
45
  agents: {
42
- getConversations: () => Promise<import("axios").AxiosResponse<any, any>>;
43
- getConversation: (conversationId: string) => Promise<import("axios").AxiosResponse<any, any>>;
44
- listConversations: (filterParams: any) => Promise<import("axios").AxiosResponse<any, any>>;
45
- createConversation: (conversation: any) => Promise<import("axios").AxiosResponse<any, any>>;
46
- addMessage: (conversation: any, message: any) => Promise<import("axios").AxiosResponse<any, any>>;
46
+ getConversations: () => Promise<import("./modules/agents.types.js").AgentConversation[]>;
47
+ getConversation: (conversationId: string) => Promise<import("./modules/agents.types.js").AgentConversation | undefined>;
48
+ listConversations: (filterParams: any) => Promise<import("./modules/agents.types.js").AgentConversation[]>;
49
+ createConversation: (conversation: any) => Promise<import("./modules/agents.types.js").AgentConversation>;
50
+ addMessage: (conversation: any, message: any) => Promise<import("./modules/agents.types.js").AgentMessage>;
47
51
  subscribeToConversation: (conversationId: string, onUpdate: any) => () => void;
48
- updateConfig: (config: Partial<import("./modules/agents.js").AgentsModuleConfig>) => void;
49
52
  };
53
+ cleanup: () => void;
50
54
  };
51
55
  entities: {};
52
56
  integrations: {};
@@ -66,14 +70,14 @@ export declare function createClient(config: {
66
70
  invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
67
71
  };
68
72
  agents: {
69
- getConversations: () => Promise<import("axios").AxiosResponse<any, any>>;
70
- getConversation: (conversationId: string) => Promise<import("axios").AxiosResponse<any, any>>;
71
- listConversations: (filterParams: any) => Promise<import("axios").AxiosResponse<any, any>>;
72
- createConversation: (conversation: any) => Promise<import("axios").AxiosResponse<any, any>>;
73
- addMessage: (conversation: any, message: any) => Promise<import("axios").AxiosResponse<any, any>>;
73
+ getConversations: () => Promise<import("./modules/agents.types.js").AgentConversation[]>;
74
+ getConversation: (conversationId: string) => Promise<import("./modules/agents.types.js").AgentConversation | undefined>;
75
+ listConversations: (filterParams: any) => Promise<import("./modules/agents.types.js").AgentConversation[]>;
76
+ createConversation: (conversation: any) => Promise<import("./modules/agents.types.js").AgentConversation>;
77
+ addMessage: (conversation: any, message: any) => Promise<import("./modules/agents.types.js").AgentMessage>;
74
78
  subscribeToConversation: (conversationId: string, onUpdate: any) => () => void;
75
- updateConfig: (config: Partial<import("./modules/agents.js").AgentsModuleConfig>) => void;
76
79
  };
80
+ cleanup: () => void;
77
81
  };
78
82
  export declare function createClientFromRequest(request: Request): {
79
83
  /**
@@ -100,14 +104,14 @@ export declare function createClientFromRequest(request: Request): {
100
104
  invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
101
105
  };
102
106
  agents: {
103
- getConversations: () => Promise<import("axios").AxiosResponse<any, any>>;
104
- getConversation: (conversationId: string) => Promise<import("axios").AxiosResponse<any, any>>;
105
- listConversations: (filterParams: any) => Promise<import("axios").AxiosResponse<any, any>>;
106
- createConversation: (conversation: any) => Promise<import("axios").AxiosResponse<any, any>>;
107
- addMessage: (conversation: any, message: any) => Promise<import("axios").AxiosResponse<any, any>>;
107
+ getConversations: () => Promise<import("./modules/agents.types.js").AgentConversation[]>;
108
+ getConversation: (conversationId: string) => Promise<import("./modules/agents.types.js").AgentConversation | undefined>;
109
+ listConversations: (filterParams: any) => Promise<import("./modules/agents.types.js").AgentConversation[]>;
110
+ createConversation: (conversation: any) => Promise<import("./modules/agents.types.js").AgentConversation>;
111
+ addMessage: (conversation: any, message: any) => Promise<import("./modules/agents.types.js").AgentMessage>;
108
112
  subscribeToConversation: (conversationId: string, onUpdate: any) => () => void;
109
- updateConfig: (config: Partial<import("./modules/agents.js").AgentsModuleConfig>) => void;
110
113
  };
114
+ cleanup: () => void;
111
115
  };
112
116
  entities: {};
113
117
  integrations: {};
@@ -127,12 +131,12 @@ export declare function createClientFromRequest(request: Request): {
127
131
  invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
128
132
  };
129
133
  agents: {
130
- getConversations: () => Promise<import("axios").AxiosResponse<any, any>>;
131
- getConversation: (conversationId: string) => Promise<import("axios").AxiosResponse<any, any>>;
132
- listConversations: (filterParams: any) => Promise<import("axios").AxiosResponse<any, any>>;
133
- createConversation: (conversation: any) => Promise<import("axios").AxiosResponse<any, any>>;
134
- addMessage: (conversation: any, message: any) => Promise<import("axios").AxiosResponse<any, any>>;
134
+ getConversations: () => Promise<import("./modules/agents.types.js").AgentConversation[]>;
135
+ getConversation: (conversationId: string) => Promise<import("./modules/agents.types.js").AgentConversation | undefined>;
136
+ listConversations: (filterParams: any) => Promise<import("./modules/agents.types.js").AgentConversation[]>;
137
+ createConversation: (conversation: any) => Promise<import("./modules/agents.types.js").AgentConversation>;
138
+ addMessage: (conversation: any, message: any) => Promise<import("./modules/agents.types.js").AgentMessage>;
135
139
  subscribeToConversation: (conversationId: string, onUpdate: any) => () => void;
136
- updateConfig: (config: Partial<import("./modules/agents.js").AgentsModuleConfig>) => void;
137
140
  };
141
+ cleanup: () => void;
138
142
  };
package/dist/client.js CHANGED
@@ -6,6 +6,7 @@ import { createSsoModule } from "./modules/sso.js";
6
6
  import { getAccessToken } from "./utils/auth-utils.js";
7
7
  import { createFunctionsModule } from "./modules/functions.js";
8
8
  import { createAgentsModule } from "./modules/agents.js";
9
+ import { RoomsSocket } from "./utils/socket-utils.js";
9
10
  /**
10
11
  * Create a Base44 client instance
11
12
  * @param {Object} config - Client configuration
@@ -17,7 +18,17 @@ import { createAgentsModule } from "./modules/agents.js";
17
18
  * @returns {Object} Base44 client instance
18
19
  */
19
20
  export function createClient(config) {
20
- const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, } = config;
21
+ const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, options, } = config;
22
+ const socketConfig = {
23
+ serverUrl,
24
+ mountPath: "/ws-user-apps/socket.io/",
25
+ transports: ["websocket"],
26
+ appId,
27
+ token,
28
+ };
29
+ const socket = RoomsSocket({
30
+ config: socketConfig,
31
+ });
21
32
  const axiosClient = createAxiosClient({
22
33
  baseURL: `${serverUrl}/api`,
23
34
  headers: {
@@ -27,6 +38,7 @@ export function createClient(config) {
27
38
  requiresAuth,
28
39
  appId,
29
40
  serverUrl,
41
+ onError: options === null || options === void 0 ? void 0 : options.onError,
30
42
  });
31
43
  const functionsAxiosClient = createAxiosClient({
32
44
  baseURL: `${serverUrl}/api`,
@@ -38,6 +50,7 @@ export function createClient(config) {
38
50
  appId,
39
51
  serverUrl,
40
52
  interceptResponses: false,
53
+ onError: options === null || options === void 0 ? void 0 : options.onError,
41
54
  });
42
55
  const serviceRoleAxiosClient = createAxiosClient({
43
56
  baseURL: `${serverUrl}/api`,
@@ -47,6 +60,7 @@ export function createClient(config) {
47
60
  token: serviceToken,
48
61
  serverUrl,
49
62
  appId,
63
+ onError: options === null || options === void 0 ? void 0 : options.onError,
50
64
  });
51
65
  const serviceRoleFunctionsAxiosClient = createAxiosClient({
52
66
  baseURL: `${serverUrl}/api`,
@@ -64,10 +78,13 @@ export function createClient(config) {
64
78
  auth: createAuthModule(axiosClient, functionsAxiosClient, appId),
65
79
  functions: createFunctionsModule(functionsAxiosClient, appId),
66
80
  agents: createAgentsModule({
67
- serverUrl,
81
+ axios: axiosClient,
82
+ socket,
68
83
  appId,
69
- token,
70
84
  }),
85
+ cleanup: () => {
86
+ socket.disconnect();
87
+ },
71
88
  };
72
89
  const serviceRoleModules = {
73
90
  entities: createEntitiesModule(serviceRoleAxiosClient, appId),
@@ -75,10 +92,13 @@ export function createClient(config) {
75
92
  sso: createSsoModule(serviceRoleAxiosClient, appId, token),
76
93
  functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
77
94
  agents: createAgentsModule({
78
- serverUrl,
95
+ axios: serviceRoleAxiosClient,
96
+ socket,
79
97
  appId,
80
- token: serviceToken,
81
98
  }),
99
+ cleanup: () => {
100
+ socket.disconnect();
101
+ },
82
102
  };
83
103
  // Always try to get token from localStorage or URL parameters
84
104
  if (typeof window !== "undefined") {
@@ -86,9 +106,6 @@ export function createClient(config) {
86
106
  const accessToken = token || getAccessToken();
87
107
  if (accessToken) {
88
108
  userModules.auth.setToken(accessToken);
89
- userModules.agents.updateConfig({
90
- token: accessToken,
91
- });
92
109
  }
93
110
  }
94
111
  // If authentication is required, verify token and redirect to login if needed
@@ -116,6 +133,9 @@ export function createClient(config) {
116
133
  */
117
134
  setToken(newToken) {
118
135
  userModules.auth.setToken(newToken);
136
+ socket.updateConfig({
137
+ token: newToken,
138
+ });
119
139
  },
120
140
  /**
121
141
  * Get current configuration
@@ -1,14 +1,16 @@
1
+ import { RoomsSocket } from "../utils/socket-utils.js";
2
+ import { AgentConversation, AgentMessage } from "./agents.types.js";
3
+ import { AxiosInstance } from "axios";
1
4
  export type AgentsModuleConfig = {
2
- serverUrl: string;
5
+ axios: AxiosInstance;
6
+ socket: ReturnType<typeof RoomsSocket>;
3
7
  appId: string;
4
- token?: string;
5
8
  };
6
- export declare function createAgentsModule({ appId, serverUrl, token, }: AgentsModuleConfig): {
7
- getConversations: () => Promise<import("axios").AxiosResponse<any, any>>;
8
- getConversation: (conversationId: string) => Promise<import("axios").AxiosResponse<any, any>>;
9
- listConversations: (filterParams: any) => Promise<import("axios").AxiosResponse<any, any>>;
10
- createConversation: (conversation: any) => Promise<import("axios").AxiosResponse<any, any>>;
11
- addMessage: (conversation: any, message: any) => Promise<import("axios").AxiosResponse<any, any>>;
9
+ export declare function createAgentsModule({ axios, socket, appId, }: AgentsModuleConfig): {
10
+ getConversations: () => Promise<AgentConversation[]>;
11
+ getConversation: (conversationId: string) => Promise<AgentConversation | undefined>;
12
+ listConversations: (filterParams: any) => Promise<AgentConversation[]>;
13
+ createConversation: (conversation: any) => Promise<AgentConversation>;
14
+ addMessage: (conversation: any, message: any) => Promise<AgentMessage>;
12
15
  subscribeToConversation: (conversationId: string, onUpdate: any) => () => void;
13
- updateConfig: (config: Partial<AgentsModuleConfig>) => void;
14
16
  };
@@ -1,44 +1,19 @@
1
- import { RoomsSocket } from "../utils/socket-utils";
2
- import { createAxiosClient } from "../utils/axios-client";
3
- export function createAgentsModule({ appId, serverUrl, token, }) {
1
+ export function createAgentsModule({ axios, socket, appId, }) {
4
2
  let currentConversation = null;
5
- const socketConfig = {
6
- serverUrl,
7
- mountPath: "/ws-user-apps/socket.io/",
8
- transports: ["websocket"],
9
- query: {
10
- appId,
11
- token,
12
- },
13
- };
14
- const axiosConfig = {
15
- serverUrl,
16
- appId,
17
- token,
18
- };
19
- let axios = createAgentsAxiosClient({
20
- serverUrl,
21
- appId,
22
- token,
23
- });
24
- const roomSocket = RoomsSocket({
25
- config: socketConfig,
26
- });
27
- const updateConfig = (config) => {
28
- axios = createAgentsAxiosClient({ ...axiosConfig, ...config });
29
- roomSocket.updateConfig({ ...socketConfig, ...config });
30
- };
3
+ const baseURL = `/apps/${appId}/agents`;
31
4
  const getConversations = () => {
32
- return axios.get(`/conversations`);
5
+ return axios.get(`${baseURL}/conversations`);
33
6
  };
34
7
  const getConversation = (conversationId) => {
35
- return axios.get(`/conversations/${conversationId}`);
8
+ return axios.get(`${baseURL}/conversations/${conversationId}`);
36
9
  };
37
10
  const listConversations = (filterParams) => {
38
- return axios.get(`/conversations`, { params: filterParams });
11
+ return axios.get(`${baseURL}/conversations`, {
12
+ params: filterParams,
13
+ });
39
14
  };
40
15
  const createConversation = (conversation) => {
41
- return axios.post(`/conversations`, conversation);
16
+ return axios.post(`${baseURL}/conversations`, conversation);
42
17
  };
43
18
  const addMessage = (conversation, message) => {
44
19
  // this whole trick with current conversation so that we can call the onUpdateModel with the latest messages
@@ -51,14 +26,14 @@ export function createAgentsModule({ appId, serverUrl, token, }) {
51
26
  convLatestMessages = conversation.messages;
52
27
  }
53
28
  conversation.messages = [...convLatestMessages, message];
54
- roomSocket.handlers.update_model({
29
+ socket.handlers.update_model({
55
30
  room: `/agent-conversations/${conversation.id}`,
56
31
  data: JSON.stringify(conversation),
57
32
  });
58
- return axios.post(`/conversations/${conversation.id}/messages`, message);
33
+ return axios.post(`${baseURL}/conversations/${conversation.id}/messages`, message);
59
34
  };
60
35
  const subscribeToConversation = (conversationId, onUpdate) => {
61
- return roomSocket.subscribeToRoom(`/agent-conversations/${conversationId}`, {
36
+ return socket.subscribeToRoom(`/agent-conversations/${conversationId}`, {
62
37
  connect: () => { },
63
38
  update_model: ({ data: jsonStr }) => {
64
39
  const data = JSON.parse(jsonStr);
@@ -76,19 +51,5 @@ export function createAgentsModule({ appId, serverUrl, token, }) {
76
51
  createConversation,
77
52
  addMessage,
78
53
  subscribeToConversation,
79
- updateConfig,
80
54
  };
81
55
  }
82
- function createAgentsAxiosClient({ serverUrl, appId, token, }) {
83
- const axios = createAxiosClient({
84
- baseURL: `${serverUrl}/api/apps/${appId}/agents`,
85
- appId,
86
- serverUrl,
87
- token,
88
- interceptResponses: false,
89
- headers: {
90
- "X-App-Id": String(appId),
91
- },
92
- });
93
- return axios;
94
- }
@@ -0,0 +1,44 @@
1
+ export type AgentConversation = {
2
+ id: string;
3
+ app_id: string;
4
+ agent_name: string;
5
+ created_by_id: string;
6
+ messages: AgentMessage[];
7
+ metadata?: Record<string, any>;
8
+ };
9
+ export type AgentMessage = {
10
+ id: string;
11
+ role: "user" | "assistant" | "system";
12
+ reasoning: {
13
+ start_date: string;
14
+ end_date?: string;
15
+ content: string;
16
+ };
17
+ content?: string | Record<string, any> | null;
18
+ file_urls?: string[] | null;
19
+ tool_calls?: {
20
+ id: string;
21
+ name: string;
22
+ arguments_string: string;
23
+ status: "running" | "success" | "error" | "stopped";
24
+ results?: string | null;
25
+ }[] | null;
26
+ usage: {
27
+ prompt_tokens?: number;
28
+ completion_tokens?: number;
29
+ } | null;
30
+ hidden?: boolean;
31
+ custom_context?: {
32
+ message: string;
33
+ data: Record<string, any>;
34
+ type: string;
35
+ }[] | null;
36
+ model: string | null;
37
+ checkpoint_id: string | null;
38
+ metadata?: {
39
+ created_date: string;
40
+ created_by_email: string;
41
+ created_by_full_name: string | null;
42
+ };
43
+ additional_message_params?: Record<string, any>;
44
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -77,6 +77,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId) {
77
77
  setToken(token, saveToStorage = true) {
78
78
  if (!token)
79
79
  return;
80
+ // handle token change for axios clients
80
81
  axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
81
82
  functionsAxiosClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
82
83
  // Save token to localStorage if requested
@@ -23,7 +23,7 @@ export declare class Base44Error extends Error {
23
23
  * @param {string} options.serverUrl - Server URL (needed for login redirect)
24
24
  * @returns {import('axios').AxiosInstance} Configured axios instance
25
25
  */
26
- export declare function createAxiosClient({ baseURL, headers, token, requiresAuth, appId, serverUrl, interceptResponses, }: {
26
+ export declare function createAxiosClient({ baseURL, headers, token, requiresAuth, appId, serverUrl, interceptResponses, onError, }: {
27
27
  baseURL: string;
28
28
  headers?: Record<string, string>;
29
29
  token?: string;
@@ -31,4 +31,5 @@ export declare function createAxiosClient({ baseURL, headers, token, requiresAut
31
31
  appId: string;
32
32
  serverUrl: string;
33
33
  interceptResponses?: boolean;
34
+ onError?: (error: Error) => void;
34
35
  }): import("axios").AxiosInstance;
@@ -64,7 +64,7 @@ function redirectToLogin(serverUrl, appId) {
64
64
  * @param {string} options.serverUrl - Server URL (needed for login redirect)
65
65
  * @returns {import('axios').AxiosInstance} Configured axios instance
66
66
  */
67
- export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth = false, appId, serverUrl, interceptResponses = true, }) {
67
+ export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth = false, appId, serverUrl, interceptResponses = true, onError, }) {
68
68
  const client = axios.create({
69
69
  baseURL,
70
70
  headers: {
@@ -107,6 +107,7 @@ export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth =
107
107
  redirectToLogin(serverUrl, appId);
108
108
  }, 100);
109
109
  }
110
+ onError === null || onError === void 0 ? void 0 : onError(base44Error);
110
111
  return Promise.reject(base44Error);
111
112
  });
112
113
  }
@@ -3,10 +3,8 @@ export type RoomsSocketConfig = {
3
3
  serverUrl: string;
4
4
  mountPath: string;
5
5
  transports: string[];
6
- query: {
7
- appId: string;
8
- token?: string;
9
- };
6
+ appId: string;
7
+ token?: string;
10
8
  };
11
9
  export type TSocketRoom = string;
12
10
  export type TJsonStr = string;
@@ -17,6 +15,7 @@ type RoomsSocketEventsMap = {
17
15
  room: string;
18
16
  data: TJsonStr;
19
17
  }) => void;
18
+ error: (error: Error) => void;
20
19
  };
21
20
  emit: {
22
21
  join: (room: string) => void;
@@ -28,21 +27,24 @@ type THandler<E extends TEvent> = (...args: Parameters<RoomsSocketEventsMap["lis
28
27
  export declare function RoomsSocket({ config }: {
29
28
  config: RoomsSocketConfig;
30
29
  }): {
31
- socket: Readonly<Socket<{
30
+ socket: Socket<{
32
31
  connect: () => void;
33
32
  update_model: (msg: {
34
33
  room: string;
35
34
  data: TJsonStr;
36
35
  }) => void;
36
+ error: (error: Error) => void;
37
37
  }, {
38
38
  join: (room: string) => void;
39
39
  leave: (room: string) => void;
40
- }>>;
41
- subscribeToRoom: (room: TSocketRoom, handlers: { [k in TEvent]: THandler<k>; }) => () => void;
42
- updateConfig: (config: RoomsSocketConfig) => void;
40
+ }>;
41
+ subscribeToRoom: (room: TSocketRoom, handlers: Partial<{ [k in TEvent]: THandler<k>; }>) => () => void;
42
+ updateConfig: (config: Partial<RoomsSocketConfig>) => void;
43
43
  handlers: {
44
44
  connect: THandler<"connect">;
45
45
  update_model: THandler<"update_model">;
46
+ error: THandler<"error">;
46
47
  };
48
+ disconnect: () => void;
47
49
  };
48
50
  export {};
@@ -1,20 +1,37 @@
1
1
  import { io } from "socket.io-client";
2
+ import { getAccessToken } from "./auth-utils.js";
2
3
  function initializeSocket(config, handlers) {
4
+ var _a;
3
5
  const socket = io(config.serverUrl, {
4
6
  path: config.mountPath,
5
7
  transports: config.transports,
6
- query: config.query,
8
+ query: {
9
+ app_id: config.appId,
10
+ token: (_a = config.token) !== null && _a !== void 0 ? _a : getAccessToken(),
11
+ },
7
12
  });
8
13
  socket.on("connect", () => {
14
+ var _a;
9
15
  console.log("connect", socket.id);
10
- handlers.connect();
16
+ (_a = handlers.connect) === null || _a === void 0 ? void 0 : _a.call(handlers);
11
17
  });
12
18
  socket.on("update_model", (msg) => {
13
- handlers.update_model(msg);
19
+ var _a;
20
+ (_a = handlers.update_model) === null || _a === void 0 ? void 0 : _a.call(handlers, msg);
21
+ });
22
+ socket.on("error", (error) => {
23
+ var _a;
24
+ (_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
25
+ });
26
+ socket.on("connect_error", (error) => {
27
+ var _a;
28
+ console.error("connect_error", error);
29
+ (_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
14
30
  });
15
31
  return socket;
16
32
  }
17
33
  export function RoomsSocket({ config }) {
34
+ let currentConfig = { ...config };
18
35
  const roomsToListeners = {};
19
36
  const handlers = {
20
37
  connect: () => {
@@ -22,7 +39,7 @@ export function RoomsSocket({ config }) {
22
39
  var _a;
23
40
  joinRoom(room);
24
41
  (_a = getListeners(room)) === null || _a === void 0 ? void 0 : _a.forEach(({ connect: connectHandler }) => {
25
- connectHandler();
42
+ connectHandler === null || connectHandler === void 0 ? void 0 : connectHandler();
26
43
  });
27
44
  });
28
45
  },
@@ -30,20 +47,32 @@ export function RoomsSocket({ config }) {
30
47
  var _a;
31
48
  if (roomsToListeners[msg.room]) {
32
49
  (_a = getListeners(msg.room)) === null || _a === void 0 ? void 0 : _a.forEach(({ update_model }) => {
33
- update_model(msg);
50
+ update_model === null || update_model === void 0 ? void 0 : update_model(msg);
34
51
  });
35
52
  }
36
53
  },
54
+ error: (error) => {
55
+ var _a;
56
+ console.error("error", error);
57
+ (_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, error);
58
+ },
37
59
  };
38
60
  let socket = initializeSocket(config, handlers);
39
61
  function cleanup() {
62
+ disconnect();
63
+ }
64
+ function disconnect() {
40
65
  if (socket) {
41
66
  socket.disconnect();
42
67
  }
43
68
  }
44
69
  function updateConfig(config) {
45
70
  cleanup();
46
- socket = initializeSocket(config, handlers);
71
+ currentConfig = {
72
+ ...currentConfig,
73
+ ...config,
74
+ };
75
+ socket = initializeSocket(currentConfig, handlers);
47
76
  }
48
77
  function joinRoom(room) {
49
78
  socket.emit("join", room);
@@ -65,9 +94,10 @@ export function RoomsSocket({ config }) {
65
94
  };
66
95
  };
67
96
  return {
68
- socket: Object.freeze(socket),
97
+ socket,
69
98
  subscribeToRoom,
70
99
  updateConfig,
71
100
  handlers,
101
+ disconnect,
72
102
  };
73
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.7.0-pr.27.96b80f1",
3
+ "version": "0.7.0-pr.27.eb342e0",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",