@base44/sdk 0.7.6 → 0.7.7

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
@@ -56,7 +56,7 @@ export declare function createClient(config: {
56
56
  }) => Promise<import("./types.js").AgentConversation>;
57
57
  addMessage: (conversation: import("./types.js").AgentConversation, message: import("./types.js").AgentMessage) => Promise<import("./types.js").AgentMessage>;
58
58
  subscribeToConversation: (conversationId: string, onUpdate?: (conversation: import("./types.js").AgentConversation) => void) => () => void;
59
- generateUserWhatsAppLink: (agentName: string) => Promise<import("axios").AxiosResponse<any, any>>;
59
+ getWhatsAppConnectURL: (agentName: string) => string;
60
60
  };
61
61
  cleanup: () => void;
62
62
  };
@@ -109,7 +109,7 @@ export declare function createClient(config: {
109
109
  }) => Promise<import("./types.js").AgentConversation>;
110
110
  addMessage: (conversation: import("./types.js").AgentConversation, message: import("./types.js").AgentMessage) => Promise<import("./types.js").AgentMessage>;
111
111
  subscribeToConversation: (conversationId: string, onUpdate?: (conversation: import("./types.js").AgentConversation) => void) => () => void;
112
- generateUserWhatsAppLink: (agentName: string) => Promise<import("axios").AxiosResponse<any, any>>;
112
+ getWhatsAppConnectURL: (agentName: string) => string;
113
113
  };
114
114
  cleanup: () => void;
115
115
  };
@@ -147,7 +147,7 @@ export declare function createClientFromRequest(request: Request): {
147
147
  }) => Promise<import("./types.js").AgentConversation>;
148
148
  addMessage: (conversation: import("./types.js").AgentConversation, message: import("./types.js").AgentMessage) => Promise<import("./types.js").AgentMessage>;
149
149
  subscribeToConversation: (conversationId: string, onUpdate?: (conversation: import("./types.js").AgentConversation) => void) => () => void;
150
- generateUserWhatsAppLink: (agentName: string) => Promise<import("axios").AxiosResponse<any, any>>;
150
+ getWhatsAppConnectURL: (agentName: string) => string;
151
151
  };
152
152
  cleanup: () => void;
153
153
  };
@@ -200,7 +200,7 @@ export declare function createClientFromRequest(request: Request): {
200
200
  }) => Promise<import("./types.js").AgentConversation>;
201
201
  addMessage: (conversation: import("./types.js").AgentConversation, message: import("./types.js").AgentMessage) => Promise<import("./types.js").AgentMessage>;
202
202
  subscribeToConversation: (conversationId: string, onUpdate?: (conversation: import("./types.js").AgentConversation) => void) => () => void;
203
- generateUserWhatsAppLink: (agentName: string) => Promise<import("axios").AxiosResponse<any, any>>;
203
+ getWhatsAppConnectURL: (agentName: string) => string;
204
204
  };
205
205
  cleanup: () => void;
206
206
  };
package/dist/client.js CHANGED
@@ -90,6 +90,8 @@ export function createClient(config) {
90
90
  axios: axiosClient,
91
91
  socket,
92
92
  appId,
93
+ serverUrl,
94
+ token,
93
95
  }),
94
96
  cleanup: () => {
95
97
  socket.disconnect();
@@ -104,6 +106,8 @@ export function createClient(config) {
104
106
  axios: serviceRoleAxiosClient,
105
107
  socket,
106
108
  appId,
109
+ serverUrl,
110
+ token
107
111
  }),
108
112
  cleanup: () => {
109
113
  socket.disconnect();
@@ -6,8 +6,10 @@ export type AgentsModuleConfig = {
6
6
  axios: AxiosInstance;
7
7
  socket: ReturnType<typeof RoomsSocket>;
8
8
  appId: string;
9
+ serverUrl?: string;
10
+ token?: string;
9
11
  };
10
- export declare function createAgentsModule({ axios, socket, appId, }: AgentsModuleConfig): {
12
+ export declare function createAgentsModule({ axios, socket, appId, serverUrl, token, }: AgentsModuleConfig): {
11
13
  getConversations: () => Promise<AgentConversation[]>;
12
14
  getConversation: (conversationId: string) => Promise<AgentConversation | undefined>;
13
15
  listConversations: (filterParams: ModelFilterParams) => Promise<AgentConversation[]>;
@@ -17,5 +19,5 @@ export declare function createAgentsModule({ axios, socket, appId, }: AgentsModu
17
19
  }) => Promise<AgentConversation>;
18
20
  addMessage: (conversation: AgentConversation, message: AgentMessage) => Promise<AgentMessage>;
19
21
  subscribeToConversation: (conversationId: string, onUpdate?: (conversation: AgentConversation) => void) => () => void;
20
- generateUserWhatsAppLink: (agentName: string) => Promise<import("axios").AxiosResponse<any, any>>;
22
+ getWhatsAppConnectURL: (agentName: string) => string;
21
23
  };
@@ -1,4 +1,5 @@
1
- export function createAgentsModule({ axios, socket, appId, }) {
1
+ import { getAccessToken } from "../utils/auth-utils.js";
2
+ export function createAgentsModule({ axios, socket, appId, serverUrl, token, }) {
2
3
  const baseURL = `/apps/${appId}/agents`;
3
4
  const getConversations = () => {
4
5
  return axios.get(`${baseURL}/conversations`);
@@ -32,8 +33,16 @@ export function createAgentsModule({ axios, socket, appId, }) {
32
33
  },
33
34
  });
34
35
  };
35
- const generateUserWhatsAppLink = (agentName) => {
36
- return axios.post(`/whatsapp/generate-user-link`, { agent_name: agentName });
36
+ const getWhatsAppConnectURL = (agentName) => {
37
+ const baseUrl = `${serverUrl}/whatsapp/${appId}/${encodeURIComponent(agentName)}`;
38
+ const accessToken = token !== null && token !== void 0 ? token : getAccessToken();
39
+ if (accessToken) {
40
+ return `${baseUrl}?token=${accessToken}`;
41
+ }
42
+ else {
43
+ // No token - URL will redirect to login automatically
44
+ return baseUrl;
45
+ }
37
46
  };
38
47
  return {
39
48
  getConversations,
@@ -42,6 +51,6 @@ export function createAgentsModule({ axios, socket, appId, }) {
42
51
  createConversation,
43
52
  addMessage,
44
53
  subscribeToConversation,
45
- generateUserWhatsAppLink,
54
+ getWhatsAppConnectURL,
46
55
  };
47
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44/sdk",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",