@base44-preview/sdk 0.8.4-pr.44.71a0993 → 0.8.4-pr.47.aed2863
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 +74 -2
- package/dist/client.js +2 -0
- package/dist/index.d.ts +0 -1
- package/dist/modules/auth.d.ts +47 -34
- package/dist/modules/auth.js +36 -0
- package/dist/modules/users.d.ts +16 -0
- package/dist/modules/users.js +23 -0
- package/package.json +1 -6
package/dist/client.d.ts
CHANGED
|
@@ -71,7 +71,40 @@ export declare function createClient(config: {
|
|
|
71
71
|
};
|
|
72
72
|
entities: {};
|
|
73
73
|
integrations: {};
|
|
74
|
-
auth:
|
|
74
|
+
auth: {
|
|
75
|
+
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
76
|
+
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
77
|
+
redirectToLogin(nextUrl: string): void;
|
|
78
|
+
logout(redirectUrl?: string): void;
|
|
79
|
+
setToken(token: string, saveToStorage?: boolean): void;
|
|
80
|
+
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
81
|
+
access_token: string;
|
|
82
|
+
user: any;
|
|
83
|
+
}>;
|
|
84
|
+
isAuthenticated(): Promise<boolean>;
|
|
85
|
+
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
86
|
+
register(payload: {
|
|
87
|
+
email: string;
|
|
88
|
+
password: string;
|
|
89
|
+
turnstile_token?: string | null;
|
|
90
|
+
referral_code?: string | null;
|
|
91
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
92
|
+
verifyOtp({ email, otpCode }: {
|
|
93
|
+
email: string;
|
|
94
|
+
otpCode: string;
|
|
95
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
96
|
+
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
97
|
+
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
98
|
+
resetPassword({ resetToken, newPassword, }: {
|
|
99
|
+
resetToken: string;
|
|
100
|
+
newPassword: string;
|
|
101
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
102
|
+
changePassword({ userId, currentPassword, newPassword, }: {
|
|
103
|
+
userId: string;
|
|
104
|
+
currentPassword: string;
|
|
105
|
+
newPassword: string;
|
|
106
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
107
|
+
};
|
|
75
108
|
functions: {
|
|
76
109
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
77
110
|
};
|
|
@@ -92,6 +125,9 @@ export declare function createClient(config: {
|
|
|
92
125
|
fetchLogs(params?: Record<string, any>): Promise<any>;
|
|
93
126
|
getStats(params?: Record<string, any>): Promise<any>;
|
|
94
127
|
};
|
|
128
|
+
users: {
|
|
129
|
+
inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
|
|
130
|
+
};
|
|
95
131
|
cleanup: () => void;
|
|
96
132
|
};
|
|
97
133
|
export declare function createClientFromRequest(request: Request): {
|
|
@@ -142,7 +178,40 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
142
178
|
};
|
|
143
179
|
entities: {};
|
|
144
180
|
integrations: {};
|
|
145
|
-
auth:
|
|
181
|
+
auth: {
|
|
182
|
+
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
183
|
+
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
184
|
+
redirectToLogin(nextUrl: string): void;
|
|
185
|
+
logout(redirectUrl?: string): void;
|
|
186
|
+
setToken(token: string, saveToStorage?: boolean): void;
|
|
187
|
+
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
188
|
+
access_token: string;
|
|
189
|
+
user: any;
|
|
190
|
+
}>;
|
|
191
|
+
isAuthenticated(): Promise<boolean>;
|
|
192
|
+
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
193
|
+
register(payload: {
|
|
194
|
+
email: string;
|
|
195
|
+
password: string;
|
|
196
|
+
turnstile_token?: string | null;
|
|
197
|
+
referral_code?: string | null;
|
|
198
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
199
|
+
verifyOtp({ email, otpCode }: {
|
|
200
|
+
email: string;
|
|
201
|
+
otpCode: string;
|
|
202
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
203
|
+
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
204
|
+
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
205
|
+
resetPassword({ resetToken, newPassword, }: {
|
|
206
|
+
resetToken: string;
|
|
207
|
+
newPassword: string;
|
|
208
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
209
|
+
changePassword({ userId, currentPassword, newPassword, }: {
|
|
210
|
+
userId: string;
|
|
211
|
+
currentPassword: string;
|
|
212
|
+
newPassword: string;
|
|
213
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
214
|
+
};
|
|
146
215
|
functions: {
|
|
147
216
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
148
217
|
};
|
|
@@ -163,5 +232,8 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
163
232
|
fetchLogs(params?: Record<string, any>): Promise<any>;
|
|
164
233
|
getStats(params?: Record<string, any>): Promise<any>;
|
|
165
234
|
};
|
|
235
|
+
users: {
|
|
236
|
+
inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
|
|
237
|
+
};
|
|
166
238
|
cleanup: () => void;
|
|
167
239
|
};
|
package/dist/client.js
CHANGED
|
@@ -8,6 +8,7 @@ import { getAccessToken } from "./utils/auth-utils.js";
|
|
|
8
8
|
import { createFunctionsModule } from "./modules/functions.js";
|
|
9
9
|
import { createAgentsModule } from "./modules/agents.js";
|
|
10
10
|
import { createAppLogsModule } from "./modules/app-logs.js";
|
|
11
|
+
import { createUsersModule } from "./modules/users.js";
|
|
11
12
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
12
13
|
/**
|
|
13
14
|
* Create a Base44 client instance
|
|
@@ -83,6 +84,7 @@ export function createClient(config) {
|
|
|
83
84
|
token,
|
|
84
85
|
}),
|
|
85
86
|
appLogs: createAppLogsModule(axiosClient, appId),
|
|
87
|
+
users: createUsersModule(axiosClient, appId),
|
|
86
88
|
cleanup: () => {
|
|
87
89
|
socket.disconnect();
|
|
88
90
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
|
|
|
4
4
|
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
5
5
|
export type { Base44Client };
|
|
6
6
|
export * from "./types.js";
|
|
7
|
-
export type { AuthMethods } from "./modules/auth.js";
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -1,68 +1,81 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Creates the auth module for the Base44 SDK
|
|
4
|
+
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
5
|
+
* @param {string|number} appId - Application ID
|
|
6
|
+
* @param {string} serverUrl - Server URL
|
|
7
|
+
* @returns {Object} Auth module with authentication methods
|
|
5
8
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
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
|
+
*/
|
|
13
29
|
redirectToLogin(nextUrl: string): void;
|
|
14
30
|
/**
|
|
15
31
|
* Logout the current user
|
|
16
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>}
|
|
17
35
|
*/
|
|
18
36
|
logout(redirectUrl?: string): void;
|
|
19
37
|
/**
|
|
20
38
|
* Set authentication token
|
|
21
|
-
* @param token - Auth token
|
|
22
|
-
* @param saveToStorage - Whether to save the token to localStorage
|
|
39
|
+
* @param {string} token - Auth token
|
|
40
|
+
* @param {boolean} [saveToStorage=true] - Whether to save the token to localStorage
|
|
23
41
|
*/
|
|
24
42
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
25
43
|
/**
|
|
26
44
|
* Login via username and password
|
|
45
|
+
* @param email - User email
|
|
46
|
+
* @param password - User password
|
|
47
|
+
* @param turnstileToken - Optional Turnstile captcha token
|
|
27
48
|
* @returns Login response with access_token and user
|
|
28
49
|
*/
|
|
29
50
|
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
30
51
|
access_token: string;
|
|
31
52
|
user: any;
|
|
32
53
|
}>;
|
|
33
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Verify if the current token is valid
|
|
56
|
+
* @returns {Promise<boolean>} True if token is valid
|
|
57
|
+
*/
|
|
34
58
|
isAuthenticated(): Promise<boolean>;
|
|
35
|
-
inviteUser(userEmail: string, role: string): Promise<any
|
|
59
|
+
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
36
60
|
register(payload: {
|
|
37
61
|
email: string;
|
|
38
62
|
password: string;
|
|
39
63
|
turnstile_token?: string | null;
|
|
40
64
|
referral_code?: string | null;
|
|
41
|
-
}): Promise<any
|
|
42
|
-
verifyOtp(
|
|
65
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
66
|
+
verifyOtp({ email, otpCode }: {
|
|
43
67
|
email: string;
|
|
44
68
|
otpCode: string;
|
|
45
|
-
}): Promise<any
|
|
46
|
-
resendOtp(email: string): Promise<any
|
|
47
|
-
resetPasswordRequest(email: string): Promise<any
|
|
48
|
-
resetPassword(
|
|
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, }: {
|
|
49
73
|
resetToken: string;
|
|
50
74
|
newPassword: string;
|
|
51
|
-
}): Promise<any
|
|
52
|
-
changePassword(
|
|
75
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
76
|
+
changePassword({ userId, currentPassword, newPassword, }: {
|
|
53
77
|
userId: string;
|
|
54
78
|
currentPassword: string;
|
|
55
79
|
newPassword: string;
|
|
56
|
-
}): Promise<any
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Creates the auth module for the Base44 SDK
|
|
60
|
-
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
61
|
-
* @param {string|number} appId - Application ID
|
|
62
|
-
* @param {string} serverUrl - Server URL
|
|
63
|
-
* @returns {Object} Auth module with authentication methods
|
|
64
|
-
*/
|
|
65
|
-
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string, options: {
|
|
66
|
-
serverUrl: string;
|
|
67
|
-
appBaseUrl?: string;
|
|
68
|
-
}): AuthMethods;
|
|
80
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
81
|
+
};
|
package/dist/modules/auth.js
CHANGED
|
@@ -7,12 +7,26 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
9
9
|
return {
|
|
10
|
+
/**
|
|
11
|
+
* Get current user information
|
|
12
|
+
* @returns {Promise<Object>} Current user data
|
|
13
|
+
*/
|
|
10
14
|
async me() {
|
|
11
15
|
return axios.get(`/apps/${appId}/entities/User/me`);
|
|
12
16
|
},
|
|
17
|
+
/**
|
|
18
|
+
* Update current user data
|
|
19
|
+
* @param {Object} data - Updated user data
|
|
20
|
+
* @returns {Promise<Object>} Updated user
|
|
21
|
+
*/
|
|
13
22
|
async updateMe(data) {
|
|
14
23
|
return axios.put(`/apps/${appId}/entities/User/me`, data);
|
|
15
24
|
},
|
|
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
|
+
*/
|
|
16
30
|
redirectToLogin(nextUrl) {
|
|
17
31
|
var _a;
|
|
18
32
|
// This function only works in a browser environment
|
|
@@ -28,6 +42,12 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
28
42
|
// Redirect to the login page
|
|
29
43
|
window.location.href = loginUrl;
|
|
30
44
|
},
|
|
45
|
+
/**
|
|
46
|
+
* Logout the current user
|
|
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
|
+
*/
|
|
31
51
|
logout(redirectUrl) {
|
|
32
52
|
// Remove token from axios headers
|
|
33
53
|
delete axios.defaults.headers.common["Authorization"];
|
|
@@ -52,6 +72,11 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
52
72
|
}
|
|
53
73
|
}
|
|
54
74
|
},
|
|
75
|
+
/**
|
|
76
|
+
* Set authentication token
|
|
77
|
+
* @param {string} token - Auth token
|
|
78
|
+
* @param {boolean} [saveToStorage=true] - Whether to save the token to localStorage
|
|
79
|
+
*/
|
|
55
80
|
setToken(token, saveToStorage = true) {
|
|
56
81
|
if (!token)
|
|
57
82
|
return;
|
|
@@ -72,6 +97,13 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
72
97
|
}
|
|
73
98
|
}
|
|
74
99
|
},
|
|
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
|
+
*/
|
|
75
107
|
async loginViaEmailPassword(email, password, turnstileToken) {
|
|
76
108
|
var _a;
|
|
77
109
|
try {
|
|
@@ -97,6 +129,10 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
97
129
|
throw error;
|
|
98
130
|
}
|
|
99
131
|
},
|
|
132
|
+
/**
|
|
133
|
+
* Verify if the current token is valid
|
|
134
|
+
* @returns {Promise<boolean>} True if token is valid
|
|
135
|
+
*/
|
|
100
136
|
async isAuthenticated() {
|
|
101
137
|
try {
|
|
102
138
|
await this.me();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the users module for the Base44 SDK
|
|
4
|
+
* @param {AxiosInstance} axios - Axios instance
|
|
5
|
+
* @param {string} appId - Application ID
|
|
6
|
+
* @returns {Object} Users module
|
|
7
|
+
*/
|
|
8
|
+
export declare function createUsersModule(axios: AxiosInstance, appId: string): {
|
|
9
|
+
/**
|
|
10
|
+
* Invite a user to the application
|
|
11
|
+
* @param {string} user_email - User's email address
|
|
12
|
+
* @param {'user'|'admin'} role - User's role (user or admin)
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
*/
|
|
15
|
+
inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the users module for the Base44 SDK
|
|
3
|
+
* @param {AxiosInstance} axios - Axios instance
|
|
4
|
+
* @param {string} appId - Application ID
|
|
5
|
+
* @returns {Object} Users module
|
|
6
|
+
*/
|
|
7
|
+
export function createUsersModule(axios, appId) {
|
|
8
|
+
return {
|
|
9
|
+
/**
|
|
10
|
+
* Invite a user to the application
|
|
11
|
+
* @param {string} user_email - User's email address
|
|
12
|
+
* @param {'user'|'admin'} role - User's role (user or admin)
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
*/
|
|
15
|
+
async inviteUser(user_email, role) {
|
|
16
|
+
if (role !== "user" && role !== "admin") {
|
|
17
|
+
throw new Error(`Invalid role: "${role}". Role must be either "user" or "admin".`);
|
|
18
|
+
}
|
|
19
|
+
const response = await axios.post(`/apps/${appId}/users/invite-user`, { user_email, role });
|
|
20
|
+
return response;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.8.4-pr.
|
|
3
|
+
"version": "0.8.4-pr.47.aed2863",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
"test:e2e": "vitest run tests/e2e",
|
|
17
17
|
"test:watch": "vitest",
|
|
18
18
|
"test:coverage": "vitest run --coverage",
|
|
19
|
-
"docs": "npm run docs:generate && npm run docs:process",
|
|
20
|
-
"docs:generate": "typedoc",
|
|
21
|
-
"docs:process": "node scripts/process-docs-for-mintlify.js",
|
|
22
19
|
"prepublishOnly": "npm run build"
|
|
23
20
|
},
|
|
24
21
|
"dependencies": {
|
|
@@ -33,8 +30,6 @@
|
|
|
33
30
|
"dotenv": "^16.3.1",
|
|
34
31
|
"eslint": "^8.54.0",
|
|
35
32
|
"nock": "^13.4.0",
|
|
36
|
-
"typedoc": "^0.25.0",
|
|
37
|
-
"typedoc-plugin-markdown": "^3.17.0",
|
|
38
33
|
"typescript": "^5.3.2",
|
|
39
34
|
"vitest": "^1.0.0"
|
|
40
35
|
},
|