@base44-preview/sdk 0.8.5-pr.52.f01053f → 0.8.6-pr.48.d625f02
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 +90 -237
- package/dist/client.js +141 -25
- package/dist/client.types.d.ts +131 -0
- package/dist/client.types.js +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.js +2 -3
- package/dist/modules/agents.d.ts +2 -23
- package/dist/modules/agents.js +3 -1
- package/dist/modules/agents.types.d.ts +330 -34
- package/dist/modules/app-logs.d.ts +8 -24
- package/dist/modules/app-logs.js +9 -19
- package/dist/modules/app-logs.types.d.ts +44 -0
- package/dist/modules/app-logs.types.js +1 -0
- package/dist/modules/app.types.d.ts +27 -0
- package/dist/modules/auth.d.ts +10 -78
- package/dist/modules/auth.js +24 -42
- package/dist/modules/auth.types.d.ts +436 -0
- package/dist/modules/auth.types.js +1 -0
- package/dist/modules/connectors.d.ts +6 -11
- package/dist/modules/connectors.js +6 -7
- package/dist/modules/connectors.types.d.ts +68 -2
- package/dist/modules/entities.d.ts +8 -5
- package/dist/modules/entities.js +22 -62
- package/dist/modules/entities.types.d.ts +293 -0
- package/dist/modules/entities.types.js +1 -0
- package/dist/modules/functions.d.ts +8 -7
- package/dist/modules/functions.js +7 -5
- package/dist/modules/functions.types.d.ts +50 -0
- package/dist/modules/functions.types.js +1 -0
- package/dist/modules/integrations.d.ts +8 -5
- package/dist/modules/integrations.js +7 -5
- package/dist/modules/integrations.types.d.ts +352 -0
- package/dist/modules/integrations.types.js +1 -0
- package/dist/modules/sso.d.ts +9 -14
- package/dist/modules/sso.js +9 -12
- package/dist/modules/sso.types.d.ts +44 -0
- package/dist/modules/sso.types.js +1 -0
- package/dist/types.d.ts +65 -2
- package/dist/utils/auth-utils.d.ts +107 -45
- package/dist/utils/auth-utils.js +107 -33
- package/dist/utils/auth-utils.types.d.ts +146 -0
- package/dist/utils/auth-utils.types.js +1 -0
- package/dist/utils/axios-client.d.ts +84 -16
- package/dist/utils/axios-client.js +74 -13
- package/dist/utils/axios-client.types.d.ts +28 -0
- package/dist/utils/axios-client.types.js +1 -0
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.js +1 -2
- package/dist/utils/socket-utils.d.ts +2 -2
- package/package.json +12 -3
- package/dist/utils/app-params.d.ts +0 -13
- package/dist/utils/app-params.js +0 -44
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Logs module for tracking and analyzing app usage.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a method to log user activity. The logs are reflected in the Analytics page in the app dashboard.
|
|
5
|
+
*
|
|
6
|
+
* This module is available to use with a client in all authentication modes.
|
|
7
|
+
*/
|
|
8
|
+
export interface AppLogsModule {
|
|
9
|
+
/**
|
|
10
|
+
* Log user activity in the app.
|
|
11
|
+
*
|
|
12
|
+
* Records when a user visits a specific page or section of the app. Useful for tracking user navigation patterns and popular features. The logs are reflected in the Analytics page in the app dashboard.
|
|
13
|
+
*
|
|
14
|
+
* The specified page name doesn't have to be the name of an actual page in the app, it can be any string you want to use to track the activity.
|
|
15
|
+
*
|
|
16
|
+
* @param pageName - Name of the page or section being visited.
|
|
17
|
+
* @returns Promise that resolves when the log is recorded.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Log page visit or feature usage
|
|
22
|
+
* await base44.appLogs.logUserInApp('home');
|
|
23
|
+
* await base44.appLogs.logUserInApp('features-section');
|
|
24
|
+
* await base44.appLogs.logUserInApp('button-click');
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
logUserInApp(pageName: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch app logs with optional parameters.
|
|
30
|
+
*
|
|
31
|
+
* @param params - Optional query parameters for filtering logs.
|
|
32
|
+
* @returns Promise resolving to the logs data.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
fetchLogs(params?: Record<string, any>): Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* Get app statistics.
|
|
38
|
+
*
|
|
39
|
+
* @param params - Optional query parameters for filtering stats.
|
|
40
|
+
* @returns Promise resolving to the stats data.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
getStats(params?: Record<string, any>): Promise<any>;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
1
4
|
export interface AppMessageContent {
|
|
2
5
|
content?: string;
|
|
3
6
|
file_urls?: string[];
|
|
@@ -5,16 +8,25 @@ export interface AppMessageContent {
|
|
|
5
8
|
additional_message_params?: Record<string, unknown>;
|
|
6
9
|
[key: string]: unknown;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
8
14
|
export interface AppConversationMessage extends AppMessageContent {
|
|
9
15
|
id?: string | null;
|
|
10
16
|
role?: "user" | "assistant" | string;
|
|
11
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
12
21
|
export interface AppConversationLike {
|
|
13
22
|
id?: string | null;
|
|
14
23
|
messages?: AppMessageContent[] | null;
|
|
15
24
|
model?: string;
|
|
16
25
|
functions_fail_silently?: boolean;
|
|
17
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
18
30
|
export interface DenoProjectLike {
|
|
19
31
|
project_id: string;
|
|
20
32
|
project_name: string;
|
|
@@ -24,6 +36,9 @@ export interface DenoProjectLike {
|
|
|
24
36
|
code: string;
|
|
25
37
|
}>;
|
|
26
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
27
42
|
export interface AppLike {
|
|
28
43
|
id?: string;
|
|
29
44
|
conversation?: AppConversationLike | null;
|
|
@@ -80,9 +95,15 @@ export interface AppLike {
|
|
|
80
95
|
app_code_hash?: string;
|
|
81
96
|
has_backend_functions_enabled?: boolean;
|
|
82
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
83
101
|
export interface UserLike {
|
|
84
102
|
id?: string | null;
|
|
85
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
86
107
|
export interface UserEntityLike {
|
|
87
108
|
type: string;
|
|
88
109
|
name: string;
|
|
@@ -104,6 +125,9 @@ export interface UserEntityLike {
|
|
|
104
125
|
};
|
|
105
126
|
required: string[];
|
|
106
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
107
131
|
export interface AuthConfigLike {
|
|
108
132
|
enable_username_password?: boolean;
|
|
109
133
|
enable_google_login?: boolean;
|
|
@@ -112,4 +136,7 @@ export interface AuthConfigLike {
|
|
|
112
136
|
sso_provider_name?: string;
|
|
113
137
|
enable_sso_login?: boolean;
|
|
114
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
115
142
|
export type LoginInfoResponse = Pick<AppLike, "id" | "name" | "slug" | "logo_url" | "user_description" | "updated_date" | "created_date" | "auth_config" | "platform_version">;
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -1,81 +1,13 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { AuthModule, AuthModuleOptions } from "./auth.types";
|
|
2
3
|
/**
|
|
3
|
-
* Creates the auth module for the Base44 SDK
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
4
|
+
* Creates the auth module for the Base44 SDK.
|
|
5
|
+
*
|
|
6
|
+
* @param axios - Axios instance for API requests
|
|
7
|
+
* @param functionsAxiosClient - Axios instance for functions API requests
|
|
8
|
+
* @param appId - Application ID
|
|
9
|
+
* @param options - Configuration options including server URLs
|
|
10
|
+
* @returns Auth module with authentication and user management methods
|
|
11
|
+
* @internal
|
|
8
12
|
*/
|
|
9
|
-
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string, options:
|
|
10
|
-
serverUrl: string;
|
|
11
|
-
appBaseUrl?: string;
|
|
12
|
-
}): {
|
|
13
|
-
/**
|
|
14
|
-
* Get current user information
|
|
15
|
-
* @returns {Promise<Object>} Current user data
|
|
16
|
-
*/
|
|
17
|
-
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
18
|
-
/**
|
|
19
|
-
* Update current user data
|
|
20
|
-
* @param {Object} data - Updated user data
|
|
21
|
-
* @returns {Promise<Object>} Updated user
|
|
22
|
-
*/
|
|
23
|
-
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
24
|
-
/**
|
|
25
|
-
* Redirects the user to the app's login page
|
|
26
|
-
* @param {string} nextUrl - URL to redirect to after successful login
|
|
27
|
-
* @throws {Error} When not in a browser environment
|
|
28
|
-
*/
|
|
29
|
-
redirectToLogin(nextUrl: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Logout the current user
|
|
32
|
-
* Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
|
33
|
-
* @param redirectUrl - Optional URL to redirect to after logout. Reloads the page if not provided
|
|
34
|
-
* @returns {Promise<void>}
|
|
35
|
-
*/
|
|
36
|
-
logout(redirectUrl?: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Set authentication token
|
|
39
|
-
* @param {string} token - Auth token
|
|
40
|
-
* @param {boolean} [saveToStorage=true] - Whether to save the token to localStorage
|
|
41
|
-
*/
|
|
42
|
-
setToken(token: string, saveToStorage?: boolean): void;
|
|
43
|
-
/**
|
|
44
|
-
* Login via username and password
|
|
45
|
-
* @param email - User email
|
|
46
|
-
* @param password - User password
|
|
47
|
-
* @param turnstileToken - Optional Turnstile captcha token
|
|
48
|
-
* @returns Login response with access_token and user
|
|
49
|
-
*/
|
|
50
|
-
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
51
|
-
access_token: string;
|
|
52
|
-
user: any;
|
|
53
|
-
}>;
|
|
54
|
-
/**
|
|
55
|
-
* Verify if the current token is valid
|
|
56
|
-
* @returns {Promise<boolean>} True if token is valid
|
|
57
|
-
*/
|
|
58
|
-
isAuthenticated(): Promise<boolean>;
|
|
59
|
-
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
60
|
-
register(payload: {
|
|
61
|
-
email: string;
|
|
62
|
-
password: string;
|
|
63
|
-
turnstile_token?: string | null;
|
|
64
|
-
referral_code?: string | null;
|
|
65
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
66
|
-
verifyOtp({ email, otpCode }: {
|
|
67
|
-
email: string;
|
|
68
|
-
otpCode: string;
|
|
69
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
70
|
-
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
71
|
-
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
72
|
-
resetPassword({ resetToken, newPassword, }: {
|
|
73
|
-
resetToken: string;
|
|
74
|
-
newPassword: string;
|
|
75
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
76
|
-
changePassword({ userId, currentPassword, newPassword, }: {
|
|
77
|
-
userId: string;
|
|
78
|
-
currentPassword: string;
|
|
79
|
-
newPassword: string;
|
|
80
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
81
|
-
};
|
|
13
|
+
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string, options: AuthModuleOptions): AuthModule;
|
package/dist/modules/auth.js
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Creates the auth module for the Base44 SDK
|
|
3
|
-
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
2
|
+
* Creates the auth module for the Base44 SDK.
|
|
3
|
+
*
|
|
4
|
+
* @param axios - Axios instance for API requests
|
|
5
|
+
* @param functionsAxiosClient - Axios instance for functions API requests
|
|
6
|
+
* @param appId - Application ID
|
|
7
|
+
* @param options - Configuration options including server URLs
|
|
8
|
+
* @returns Auth module with authentication and user management methods
|
|
9
|
+
* @internal
|
|
7
10
|
*/
|
|
8
11
|
export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
9
12
|
return {
|
|
10
|
-
|
|
11
|
-
* Get current user information
|
|
12
|
-
* @returns {Promise<Object>} Current user data
|
|
13
|
-
*/
|
|
13
|
+
// Get current user information
|
|
14
14
|
async me() {
|
|
15
15
|
return axios.get(`/apps/${appId}/entities/User/me`);
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
* Update current user data
|
|
19
|
-
* @param {Object} data - Updated user data
|
|
20
|
-
* @returns {Promise<Object>} Updated user
|
|
21
|
-
*/
|
|
17
|
+
// Update current user data
|
|
22
18
|
async updateMe(data) {
|
|
23
19
|
return axios.put(`/apps/${appId}/entities/User/me`, data);
|
|
24
20
|
},
|
|
25
|
-
|
|
26
|
-
* Redirects the user to the app's login page
|
|
27
|
-
* @param {string} nextUrl - URL to redirect to after successful login
|
|
28
|
-
* @throws {Error} When not in a browser environment
|
|
29
|
-
*/
|
|
21
|
+
// Redirects the user to the app's login page
|
|
30
22
|
redirectToLogin(nextUrl) {
|
|
31
23
|
var _a;
|
|
32
24
|
// This function only works in a browser environment
|
|
@@ -42,12 +34,8 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
42
34
|
// Redirect to the login page
|
|
43
35
|
window.location.href = loginUrl;
|
|
44
36
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
|
48
|
-
* @param redirectUrl - Optional URL to redirect to after logout. Reloads the page if not provided
|
|
49
|
-
* @returns {Promise<void>}
|
|
50
|
-
*/
|
|
37
|
+
// Logout the current user
|
|
38
|
+
// Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
|
51
39
|
logout(redirectUrl) {
|
|
52
40
|
// Remove token from axios headers
|
|
53
41
|
delete axios.defaults.headers.common["Authorization"];
|
|
@@ -72,11 +60,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
72
60
|
}
|
|
73
61
|
}
|
|
74
62
|
},
|
|
75
|
-
|
|
76
|
-
* Set authentication token
|
|
77
|
-
* @param {string} token - Auth token
|
|
78
|
-
* @param {boolean} [saveToStorage=true] - Whether to save the token to localStorage
|
|
79
|
-
*/
|
|
63
|
+
// Set authentication token
|
|
80
64
|
setToken(token, saveToStorage = true) {
|
|
81
65
|
if (!token)
|
|
82
66
|
return;
|
|
@@ -97,13 +81,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
97
81
|
}
|
|
98
82
|
}
|
|
99
83
|
},
|
|
100
|
-
|
|
101
|
-
* Login via username and password
|
|
102
|
-
* @param email - User email
|
|
103
|
-
* @param password - User password
|
|
104
|
-
* @param turnstileToken - Optional Turnstile captcha token
|
|
105
|
-
* @returns Login response with access_token and user
|
|
106
|
-
*/
|
|
84
|
+
// Login using username and password
|
|
107
85
|
async loginViaEmailPassword(email, password, turnstileToken) {
|
|
108
86
|
var _a;
|
|
109
87
|
try {
|
|
@@ -129,10 +107,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
129
107
|
throw error;
|
|
130
108
|
}
|
|
131
109
|
},
|
|
132
|
-
|
|
133
|
-
* Verify if the current token is valid
|
|
134
|
-
* @returns {Promise<boolean>} True if token is valid
|
|
135
|
-
*/
|
|
110
|
+
// Verify if the current token is valid
|
|
136
111
|
async isAuthenticated() {
|
|
137
112
|
try {
|
|
138
113
|
await this.me();
|
|
@@ -142,35 +117,42 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
142
117
|
return false;
|
|
143
118
|
}
|
|
144
119
|
},
|
|
120
|
+
// Invite a user to the app
|
|
145
121
|
inviteUser(userEmail, role) {
|
|
146
122
|
return axios.post(`/apps/${appId}/users/invite-user`, {
|
|
147
123
|
user_email: userEmail,
|
|
148
124
|
role,
|
|
149
125
|
});
|
|
150
126
|
},
|
|
127
|
+
// Register a new user account
|
|
151
128
|
register(payload) {
|
|
152
129
|
return axios.post(`/apps/${appId}/auth/register`, payload);
|
|
153
130
|
},
|
|
131
|
+
// Verify an OTP (One-time password) code
|
|
154
132
|
verifyOtp({ email, otpCode }) {
|
|
155
133
|
return axios.post(`/apps/${appId}/auth/verify-otp`, {
|
|
156
134
|
email,
|
|
157
135
|
otp_code: otpCode,
|
|
158
136
|
});
|
|
159
137
|
},
|
|
138
|
+
// Resend an OTP code to the user's email
|
|
160
139
|
resendOtp(email) {
|
|
161
140
|
return axios.post(`/apps/${appId}/auth/resend-otp`, { email });
|
|
162
141
|
},
|
|
142
|
+
// Request a password reset
|
|
163
143
|
resetPasswordRequest(email) {
|
|
164
144
|
return axios.post(`/apps/${appId}/auth/reset-password-request`, {
|
|
165
145
|
email,
|
|
166
146
|
});
|
|
167
147
|
},
|
|
168
|
-
|
|
148
|
+
// Reset password using a reset token
|
|
149
|
+
resetPassword({ resetToken, newPassword }) {
|
|
169
150
|
return axios.post(`/apps/${appId}/auth/reset-password`, {
|
|
170
151
|
reset_token: resetToken,
|
|
171
152
|
new_password: newPassword,
|
|
172
153
|
});
|
|
173
154
|
},
|
|
155
|
+
// Change the user's password
|
|
174
156
|
changePassword({ userId, currentPassword, newPassword, }) {
|
|
175
157
|
return axios.post(`/apps/${appId}/auth/change-password`, {
|
|
176
158
|
user_id: userId,
|