@base44-preview/sdk 0.8.18-pr.117.d0ffb77 → 0.8.18-pr.117.f59c49f
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
|
@@ -50,6 +50,8 @@ import { createAnalyticsModule } from "./modules/analytics.js";
|
|
|
50
50
|
*/
|
|
51
51
|
export function createClient(config) {
|
|
52
52
|
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders, } = config;
|
|
53
|
+
// Normalize appBaseUrl to always be a string (empty if not provided or invalid)
|
|
54
|
+
const normalizedAppBaseUrl = typeof appBaseUrl === "string" ? appBaseUrl : "";
|
|
53
55
|
const socketConfig = {
|
|
54
56
|
serverUrl,
|
|
55
57
|
mountPath: "/ws-user-apps/socket.io/",
|
|
@@ -102,7 +104,7 @@ export function createClient(config) {
|
|
|
102
104
|
interceptResponses: false,
|
|
103
105
|
});
|
|
104
106
|
const userAuthModule = createAuthModule(axiosClient, functionsAxiosClient, appId, {
|
|
105
|
-
appBaseUrl,
|
|
107
|
+
appBaseUrl: normalizedAppBaseUrl,
|
|
106
108
|
serverUrl,
|
|
107
109
|
});
|
|
108
110
|
const userModules = {
|
|
@@ -181,7 +181,7 @@ export interface AgentsModuleConfig {
|
|
|
181
181
|
*
|
|
182
182
|
* This module is available to use with a client in all authentication modes:
|
|
183
183
|
*
|
|
184
|
-
* - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions.
|
|
184
|
+
* - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations.
|
|
185
185
|
* - **Service role authentication** (`base44.asServiceRole.agents`): Operations have elevated admin-level permissions. Can access all conversations that the app's admin role has access to.
|
|
186
186
|
*
|
|
187
187
|
*/
|
|
@@ -210,6 +210,8 @@ export interface AgentsModule {
|
|
|
210
210
|
* Retrieves a single conversation using its unique identifier. To retrieve
|
|
211
211
|
* all conversations, use {@linkcode getConversations | getConversations()} To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
|
|
212
212
|
*
|
|
213
|
+
* This function returns the complete stored conversation including full tool call results, even for large responses.
|
|
214
|
+
*
|
|
213
215
|
* @param conversationId - The unique identifier of the conversation.
|
|
214
216
|
* @returns Promise resolving to the conversation, or undefined if not found.
|
|
215
217
|
*
|
|
@@ -308,6 +310,10 @@ export interface AgentsModule {
|
|
|
308
310
|
* Establishes a WebSocket connection to receive instant updates when new
|
|
309
311
|
* messages are added to the conversation. Returns an unsubscribe function
|
|
310
312
|
* to clean up the connection.
|
|
313
|
+
*
|
|
314
|
+
* <Note>
|
|
315
|
+
When receiving messages through this function, tool call data is truncated for efficiency. The `arguments_string` is limited to 500 characters and `results` to 50 characters. The complete tool call data is always saved in storage and can be retrieved by calling {@linkcode getConversation | getConversation()} after the message completes.
|
|
316
|
+
</Note>
|
|
311
317
|
*
|
|
312
318
|
* @param conversationId - The conversation ID to subscribe to.
|
|
313
319
|
* @param onUpdate - Callback function called when the conversation is updated. The callback receives a conversation object with the following properties:
|
package/dist/modules/auth.js
CHANGED
|
@@ -20,7 +20,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
20
20
|
},
|
|
21
21
|
// Redirects the user to the app's login page
|
|
22
22
|
redirectToLogin(nextUrl) {
|
|
23
|
-
var _a;
|
|
24
23
|
// This function only works in a browser environment
|
|
25
24
|
if (typeof window === "undefined") {
|
|
26
25
|
throw new Error("Login method can only be used in a browser environment");
|
|
@@ -30,7 +29,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
30
29
|
? new URL(nextUrl, window.location.origin).toString()
|
|
31
30
|
: window.location.href;
|
|
32
31
|
// Build the login URL
|
|
33
|
-
const loginUrl = `${
|
|
32
|
+
const loginUrl = `${options.appBaseUrl}/login?from_url=${encodeURIComponent(redirectUrl)}`;
|
|
34
33
|
// Redirect to the login page
|
|
35
34
|
window.location.href = loginUrl;
|
|
36
35
|
},
|
|
@@ -40,34 +39,32 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
40
39
|
const redirectUrl = new URL(fromUrl, window.location.origin).toString();
|
|
41
40
|
// Build the provider login URL (google is the default, so no provider path needed)
|
|
42
41
|
const providerPath = provider === "google" ? "" : `/${provider}`;
|
|
43
|
-
const loginUrl = `${options.
|
|
42
|
+
const loginUrl = `${options.appBaseUrl}/api/apps/auth${providerPath}/login?app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
|
|
44
43
|
// Redirect to the provider login page
|
|
45
44
|
window.location.href = loginUrl;
|
|
46
45
|
},
|
|
47
46
|
// Logout the current user
|
|
48
|
-
// Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
|
49
47
|
logout(redirectUrl) {
|
|
50
|
-
// Remove token from axios headers
|
|
48
|
+
// Remove token from axios headers (always do this)
|
|
51
49
|
delete axios.defaults.headers.common["Authorization"];
|
|
52
|
-
//
|
|
53
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
54
|
-
try {
|
|
55
|
-
window.localStorage.removeItem("base44_access_token");
|
|
56
|
-
// Remove "token" that is set by the built-in SDK of platform version 2
|
|
57
|
-
window.localStorage.removeItem("token");
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
console.error("Failed to remove token from localStorage:", e);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Redirect if a URL is provided
|
|
50
|
+
// Only do the rest if in a browser environment
|
|
64
51
|
if (typeof window !== "undefined") {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
// Remove token from localStorage
|
|
53
|
+
if (window.localStorage) {
|
|
54
|
+
try {
|
|
55
|
+
window.localStorage.removeItem("base44_access_token");
|
|
56
|
+
// Remove "token" that is set by the built-in SDK of platform version 2
|
|
57
|
+
window.localStorage.removeItem("token");
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.error("Failed to remove token from localStorage:", e);
|
|
61
|
+
}
|
|
70
62
|
}
|
|
63
|
+
// Determine the from_url parameter
|
|
64
|
+
const fromUrl = redirectUrl || window.location.href;
|
|
65
|
+
// Redirect to server-side logout endpoint to clear HTTP-only cookies
|
|
66
|
+
const logoutUrl = `${options.appBaseUrl}/api/apps/auth/logout?from_url=${encodeURIComponent(fromUrl)}`;
|
|
67
|
+
window.location.href = logoutUrl;
|
|
71
68
|
}
|
|
72
69
|
},
|
|
73
70
|
// Set authentication token
|
|
@@ -90,8 +90,8 @@ export interface ResetPasswordParams {
|
|
|
90
90
|
export interface AuthModuleOptions {
|
|
91
91
|
/** Server URL for API requests. */
|
|
92
92
|
serverUrl: string;
|
|
93
|
-
/**
|
|
94
|
-
appBaseUrl
|
|
93
|
+
/** Base URL for the app (used for login redirects). */
|
|
94
|
+
appBaseUrl: string;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Authentication module for managing user authentication and authorization. The module automatically stores tokens in local storage when available and manages authorization headers for API requests.
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of connector integration types.
|
|
3
|
+
* Augment this interface to enable autocomplete for connector integration types.
|
|
4
|
+
*/
|
|
5
|
+
export interface ConnectorIntegrationTypeRegistry {
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* The type of external integration/connector, such as `'googlecalendar'`, `'slack'`, or `'github'`.
|
|
9
|
+
* Uses registry keys if augmented, otherwise falls back to string.
|
|
3
10
|
*/
|
|
4
|
-
export type ConnectorIntegrationType = string;
|
|
11
|
+
export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry extends never ? string : keyof ConnectorIntegrationTypeRegistry;
|
|
5
12
|
/**
|
|
6
13
|
* Response from the connectors access token endpoint.
|
|
7
14
|
*/
|
|
@@ -95,7 +95,6 @@ export interface EntityTypeRegistry {
|
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Full record type for each entity: schema fields + server-injected fields (id, created_date, etc.).
|
|
98
|
-
* Use for state that holds results of list()/get(), e.g. `useState<EntityRecord['Task']>([])`.
|
|
99
98
|
*/
|
|
100
99
|
export type EntityRecord = {
|
|
101
100
|
[K in keyof EntityTypeRegistry]: EntityTypeRegistry[K] & ServerEntityFields;
|