@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,436 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An authenticated user.
|
|
3
|
+
*/
|
|
4
|
+
export interface User {
|
|
5
|
+
/** Unique user identifier. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** When the user was created. */
|
|
8
|
+
created_date: string;
|
|
9
|
+
/** When the user was last updated. */
|
|
10
|
+
updated_date: string;
|
|
11
|
+
/** User's email address. */
|
|
12
|
+
email: string;
|
|
13
|
+
/** User's full name. */
|
|
14
|
+
full_name: string | null;
|
|
15
|
+
/** Whether the user is disabled. */
|
|
16
|
+
disabled: boolean | null;
|
|
17
|
+
/** Whether the user's email has been verified. */
|
|
18
|
+
is_verified: boolean;
|
|
19
|
+
/** The app ID this user belongs to. */
|
|
20
|
+
app_id: string;
|
|
21
|
+
/** Whether this is a service account. */
|
|
22
|
+
is_service: boolean;
|
|
23
|
+
/** Internal app role.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
_app_role: string;
|
|
27
|
+
/**
|
|
28
|
+
* User's role in the app. Roles are configured in the app settings and determine the user's permissions and access levels.
|
|
29
|
+
*/
|
|
30
|
+
role: string;
|
|
31
|
+
/**
|
|
32
|
+
* Additional custom fields defined in the user schema. Any custom properties added to the user schema in the app will be available here with their configured types and values.
|
|
33
|
+
*/
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Response from login endpoints containing user information and access token.
|
|
38
|
+
*/
|
|
39
|
+
export interface LoginResponse {
|
|
40
|
+
/** JWT access token for authentication. */
|
|
41
|
+
access_token: string;
|
|
42
|
+
/** User information. */
|
|
43
|
+
user: User;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Payload for user registration.
|
|
47
|
+
*/
|
|
48
|
+
export interface RegisterParams {
|
|
49
|
+
/** User's email address. */
|
|
50
|
+
email: string;
|
|
51
|
+
/** User's password. */
|
|
52
|
+
password: string;
|
|
53
|
+
/** Optional {@link https://developers.cloudflare.com/turnstile/ | Cloudflare Turnstile CAPTCHA token} for bot protection. */
|
|
54
|
+
turnstile_token?: string | null;
|
|
55
|
+
/** Optional {@link https://docs.base44.com/Getting-Started/Referral-program | referral code} from an existing user. */
|
|
56
|
+
referral_code?: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parameters for OTP verification.
|
|
60
|
+
*/
|
|
61
|
+
export interface VerifyOtpParams {
|
|
62
|
+
/** User's email address. */
|
|
63
|
+
email: string;
|
|
64
|
+
/** One-time password code received by email. */
|
|
65
|
+
otpCode: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parameters for changing a user's password.
|
|
69
|
+
*/
|
|
70
|
+
export interface ChangePasswordParams {
|
|
71
|
+
/** User ID. */
|
|
72
|
+
userId: string;
|
|
73
|
+
/** Current password for verification. */
|
|
74
|
+
currentPassword: string;
|
|
75
|
+
/** New password to set. */
|
|
76
|
+
newPassword: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parameters for resetting a password with a token.
|
|
80
|
+
*/
|
|
81
|
+
export interface ResetPasswordParams {
|
|
82
|
+
/** Reset token received by email. */
|
|
83
|
+
resetToken: string;
|
|
84
|
+
/** New password to set. */
|
|
85
|
+
newPassword: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration options for the auth module.
|
|
89
|
+
*/
|
|
90
|
+
export interface AuthModuleOptions {
|
|
91
|
+
/** Server URL for API requests. */
|
|
92
|
+
serverUrl: string;
|
|
93
|
+
/** Optional base URL for the app (used for login redirects). */
|
|
94
|
+
appBaseUrl?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
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.
|
|
98
|
+
*
|
|
99
|
+
* This module provides comprehensive authentication functionality including:
|
|
100
|
+
* - Email/password login and registration
|
|
101
|
+
* - Token management
|
|
102
|
+
* - User profile access and updates
|
|
103
|
+
* - Password reset flows
|
|
104
|
+
* - OTP verification
|
|
105
|
+
* - User invitations
|
|
106
|
+
*
|
|
107
|
+
* The auth module is only available in user authentication mode (`base44.auth`).
|
|
108
|
+
*/
|
|
109
|
+
export interface AuthModule {
|
|
110
|
+
/**
|
|
111
|
+
* Gets the current authenticated user's information.
|
|
112
|
+
*
|
|
113
|
+
* @returns Promise resolving to the user's profile data.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Get current user information
|
|
118
|
+
* const user = await base44.auth.me();
|
|
119
|
+
* console.log(`Logged in as: ${user.email}`);
|
|
120
|
+
* console.log(`User ID: ${user.id}`);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
me(): Promise<User>;
|
|
124
|
+
/**
|
|
125
|
+
* Updates the current authenticated user's information.
|
|
126
|
+
*
|
|
127
|
+
* Only the fields included in the data object will be updated.
|
|
128
|
+
* Commonly updated fields include `full_name` and custom profile fields.
|
|
129
|
+
*
|
|
130
|
+
* @param data - Object containing the fields to update.
|
|
131
|
+
* @returns Promise resolving to the updated user data.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* // Update specific fields
|
|
136
|
+
* const updatedUser = await base44.auth.updateMe({
|
|
137
|
+
* full_name: 'John Doe'
|
|
138
|
+
* });
|
|
139
|
+
* console.log(`Updated user: ${updatedUser.full_name}`);
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* // Update custom fields defined in your User entity
|
|
145
|
+
* await base44.auth.updateMe({
|
|
146
|
+
* bio: 'Software developer',
|
|
147
|
+
* phone: '+1234567890',
|
|
148
|
+
* preferences: { theme: 'dark' }
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
updateMe(data: Partial<Omit<User, "id" | "created_date" | "updated_date">>): Promise<User>;
|
|
153
|
+
/**
|
|
154
|
+
* Redirects the user to the app's login page.
|
|
155
|
+
*
|
|
156
|
+
* Redirects with a callback URL to return to after successful authentication. Requires a browser environment and can't be used in the backend.
|
|
157
|
+
*
|
|
158
|
+
* @param nextUrl - URL to redirect to after successful login.
|
|
159
|
+
* @throws {Error} When not in a browser environment.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Redirect to login and come back to current page
|
|
164
|
+
* base44.auth.redirectToLogin(window.location.href);
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* // Redirect to login and then go to the dashboard page
|
|
170
|
+
* base44.auth.redirectToLogin('/dashboard');
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
redirectToLogin(nextUrl: string): void;
|
|
174
|
+
/**
|
|
175
|
+
* Logs out the current user.
|
|
176
|
+
*
|
|
177
|
+
* Removes the authentication token from local storage and Axios headers, then optionally redirects to a URL or reloads the page. Requires a browser environment and can't be used in the backend.
|
|
178
|
+
*
|
|
179
|
+
* @param redirectUrl - Optional URL to redirect to after logout. Reloads the page if not provided.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* // Logout and reload page
|
|
184
|
+
* base44.auth.logout();
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Logout and redirect to login page
|
|
190
|
+
* base44.auth.logout('/login');
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* // Logout and redirect to home
|
|
196
|
+
* base44.auth.logout('/');
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
logout(redirectUrl?: string): void;
|
|
200
|
+
/**
|
|
201
|
+
* Sets the authentication token.
|
|
202
|
+
*
|
|
203
|
+
* Updates the authorization header for API requests and optionally saves the token to local storage for persistence. Saving to local storage requires a browser environment and is automatically skipped in backend environments.
|
|
204
|
+
*
|
|
205
|
+
* @param token - JWT authentication token.
|
|
206
|
+
* @param saveToStorage - Whether to save the token to local storage. Defaults to true.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* // Set token and save to local storage
|
|
211
|
+
* base44.auth.setToken('eyJhbGciOiJIUzI1NiIs...');
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* // Set token without saving to local storage
|
|
217
|
+
* base44.auth.setToken('eyJhbGciOiJIUzI1NiIs...', false);
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
setToken(token: string, saveToStorage?: boolean): void;
|
|
221
|
+
/**
|
|
222
|
+
* Logs in a registered user using email and password.
|
|
223
|
+
*
|
|
224
|
+
* Authenticates a user with email and password credentials. The user must already have a registered account. For new users, use {@linkcode register | register()} first to create an account. On successful login, automatically sets the token for subsequent requests.
|
|
225
|
+
*
|
|
226
|
+
* @param email - User's email address.
|
|
227
|
+
* @param password - User's password.
|
|
228
|
+
* @param turnstileToken - Optional {@link https://developers.cloudflare.com/turnstile/ | Cloudflare Turnstile CAPTCHA token} for bot protection.
|
|
229
|
+
* @returns Promise resolving to login response with access token and user data.
|
|
230
|
+
* @throws Error if the email and password combination is invalid or the user is not registered.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* // Login with email and password
|
|
235
|
+
* try {
|
|
236
|
+
* const { access_token, user } = await base44.auth.loginViaEmailPassword(
|
|
237
|
+
* 'user@example.com',
|
|
238
|
+
* 'securePassword123'
|
|
239
|
+
* );
|
|
240
|
+
* console.log('Login successful!', user);
|
|
241
|
+
* } catch (error) {
|
|
242
|
+
* console.error('Login failed:', error);
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* // With captcha token
|
|
249
|
+
* const response = await base44.auth.loginViaEmailPassword(
|
|
250
|
+
* 'user@example.com',
|
|
251
|
+
* 'securePassword123',
|
|
252
|
+
* 'captcha-token-here'
|
|
253
|
+
* );
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<LoginResponse>;
|
|
257
|
+
/**
|
|
258
|
+
* Checks if the current user is authenticated.
|
|
259
|
+
*
|
|
260
|
+
* @returns Promise resolving to true if authenticated, false otherwise.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Check authentication status
|
|
265
|
+
* const isAuthenticated = await base44.auth.isAuthenticated();
|
|
266
|
+
* if (isAuthenticated) {
|
|
267
|
+
* console.log('User is logged in');
|
|
268
|
+
* } else {
|
|
269
|
+
* // Redirect to login page
|
|
270
|
+
* base44.auth.redirectToLogin(window.location.href);
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
isAuthenticated(): Promise<boolean>;
|
|
275
|
+
/**
|
|
276
|
+
* Invites a user to the app.
|
|
277
|
+
*
|
|
278
|
+
* Sends an invitation email to a potential user with a specific role.
|
|
279
|
+
* Roles are configured in the app settings and determine
|
|
280
|
+
* the user's permissions and access levels.
|
|
281
|
+
*
|
|
282
|
+
* @param userEmail - Email address of the user to invite.
|
|
283
|
+
* @param role - Role to assign to the invited user. Must match a role defined in the app. For example, `'admin'` or `'user'`.
|
|
284
|
+
* @returns Promise that resolves when the invitation is sent successfully. Throws an error if the invitation fails.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* try {
|
|
289
|
+
* await base44.auth.inviteUser('newuser@example.com', 'user');
|
|
290
|
+
* console.log('Invitation sent successfully!');
|
|
291
|
+
* } catch (error) {
|
|
292
|
+
* console.error('Failed to send invitation:', error);
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
inviteUser(userEmail: string, role: string): Promise<any>;
|
|
297
|
+
/**
|
|
298
|
+
* Registers a new user account.
|
|
299
|
+
*
|
|
300
|
+
* Creates a new user account with email and password. After successful registration,
|
|
301
|
+
* use {@linkcode loginViaEmailPassword | loginViaEmailPassword()} to log in the user.
|
|
302
|
+
*
|
|
303
|
+
* @param params - Registration details including email, password, and optional fields.
|
|
304
|
+
* @returns Promise resolving to the registration response.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* // Register a new user
|
|
309
|
+
* await base44.auth.register({
|
|
310
|
+
* email: 'newuser@example.com',
|
|
311
|
+
* password: 'securePassword123',
|
|
312
|
+
* referral_code: 'FRIEND2024'
|
|
313
|
+
* });
|
|
314
|
+
*
|
|
315
|
+
* // Login after registration
|
|
316
|
+
* const { access_token, user } = await base44.auth.loginViaEmailPassword(
|
|
317
|
+
* 'newuser@example.com',
|
|
318
|
+
* 'securePassword123'
|
|
319
|
+
* );
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
register(params: RegisterParams): Promise<any>;
|
|
323
|
+
/**
|
|
324
|
+
* Verifies an OTP (One-time password) code.
|
|
325
|
+
*
|
|
326
|
+
* Validates an OTP code sent to the user's email during registration
|
|
327
|
+
* or authentication.
|
|
328
|
+
*
|
|
329
|
+
* @param params - Object containing email and OTP code.
|
|
330
|
+
* @returns Promise resolving to the verification response if valid.
|
|
331
|
+
* @throws Error if the OTP code is invalid, expired, or verification fails.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* try {
|
|
336
|
+
* await base44.auth.verifyOtp({
|
|
337
|
+
* email: 'user@example.com',
|
|
338
|
+
* otpCode: '123456'
|
|
339
|
+
* });
|
|
340
|
+
* console.log('Email verified successfully!');
|
|
341
|
+
* } catch (error) {
|
|
342
|
+
* console.error('Invalid or expired OTP code');
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
verifyOtp(params: VerifyOtpParams): Promise<any>;
|
|
347
|
+
/**
|
|
348
|
+
* Resends an OTP code to the user's email address.
|
|
349
|
+
*
|
|
350
|
+
* Requests a new OTP code to be sent to the specified email address.
|
|
351
|
+
*
|
|
352
|
+
* @param email - Email address to send the OTP to.
|
|
353
|
+
* @returns Promise resolving when the OTP is sent successfully.
|
|
354
|
+
* @throws Error if the email is invalid or the request fails.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* try {
|
|
359
|
+
* await base44.auth.resendOtp('user@example.com');
|
|
360
|
+
* console.log('OTP resent! Please check your email.');
|
|
361
|
+
* } catch (error) {
|
|
362
|
+
* console.error('Failed to resend OTP:', error);
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
resendOtp(email: string): Promise<any>;
|
|
367
|
+
/**
|
|
368
|
+
* Requests a password reset.
|
|
369
|
+
*
|
|
370
|
+
* Sends a password reset email to the specified email address.
|
|
371
|
+
*
|
|
372
|
+
* @param email - Email address for the account to reset.
|
|
373
|
+
* @returns Promise resolving when the password reset email is sent successfully.
|
|
374
|
+
* @throws Error if the email is invalid or the request fails.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* try {
|
|
379
|
+
* await base44.auth.resetPasswordRequest('user@example.com');
|
|
380
|
+
* console.log('Password reset email sent!');
|
|
381
|
+
* } catch (error) {
|
|
382
|
+
* console.error('Failed to send password reset email:', error);
|
|
383
|
+
* }
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
resetPasswordRequest(email: string): Promise<any>;
|
|
387
|
+
/**
|
|
388
|
+
* Resets password using a reset token.
|
|
389
|
+
*
|
|
390
|
+
* Completes the password reset flow by setting a new password
|
|
391
|
+
* using the token received by email.
|
|
392
|
+
*
|
|
393
|
+
* @param params - Object containing the reset token and new password.
|
|
394
|
+
* @returns Promise resolving when the password is reset successfully.
|
|
395
|
+
* @throws Error if the reset token is invalid, expired, or the request fails.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```typescript
|
|
399
|
+
* try {
|
|
400
|
+
* await base44.auth.resetPassword({
|
|
401
|
+
* resetToken: 'token-from-email',
|
|
402
|
+
* newPassword: 'newSecurePassword456'
|
|
403
|
+
* });
|
|
404
|
+
* console.log('Password reset successful!');
|
|
405
|
+
* } catch (error) {
|
|
406
|
+
* console.error('Failed to reset password:', error);
|
|
407
|
+
* }
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
resetPassword(params: ResetPasswordParams): Promise<any>;
|
|
411
|
+
/**
|
|
412
|
+
* Changes the user's password.
|
|
413
|
+
*
|
|
414
|
+
* Updates the password for an authenticated user by verifying
|
|
415
|
+
* the current password and setting a new one.
|
|
416
|
+
*
|
|
417
|
+
* @param params - Object containing user ID, current password, and new password.
|
|
418
|
+
* @returns Promise resolving when the password is changed successfully.
|
|
419
|
+
* @throws Error if the current password is incorrect or the request fails.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* try {
|
|
424
|
+
* await base44.auth.changePassword({
|
|
425
|
+
* userId: 'user-123',
|
|
426
|
+
* currentPassword: 'oldPassword123',
|
|
427
|
+
* newPassword: 'newSecurePassword456'
|
|
428
|
+
* });
|
|
429
|
+
* console.log('Password changed successfully!');
|
|
430
|
+
* } catch (error) {
|
|
431
|
+
* console.error('Failed to change password:', error);
|
|
432
|
+
* }
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
changePassword(params: ChangePasswordParams): Promise<any>;
|
|
436
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import {
|
|
2
|
+
import { ConnectorsModule } from "./connectors.types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Creates the Connectors module for the Base44 SDK
|
|
4
|
+
* Creates the Connectors module for the Base44 SDK.
|
|
5
|
+
*
|
|
5
6
|
* @param axios - Axios instance (should be service role client)
|
|
6
7
|
* @param appId - Application ID
|
|
7
|
-
* @returns Connectors module
|
|
8
|
+
* @returns Connectors module with methods to retrieve OAuth tokens
|
|
9
|
+
* @internal
|
|
8
10
|
*/
|
|
9
|
-
export declare function createConnectorsModule(axios: AxiosInstance, appId: string):
|
|
10
|
-
/**
|
|
11
|
-
* Retrieve an access token for a given integration type
|
|
12
|
-
* @param integrationType - The integration type to get access token for
|
|
13
|
-
* @returns Access token response
|
|
14
|
-
*/
|
|
15
|
-
getAccessToken(integrationType: ConnectorIntegrationType): Promise<ConnectorAccessTokenResponse>;
|
|
16
|
-
};
|
|
11
|
+
export declare function createConnectorsModule(axios: AxiosInstance, appId: string): ConnectorsModule;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Creates the Connectors module for the Base44 SDK
|
|
2
|
+
* Creates the Connectors module for the Base44 SDK.
|
|
3
|
+
*
|
|
3
4
|
* @param axios - Axios instance (should be service role client)
|
|
4
5
|
* @param appId - Application ID
|
|
5
|
-
* @returns Connectors module
|
|
6
|
+
* @returns Connectors module with methods to retrieve OAuth tokens
|
|
7
|
+
* @internal
|
|
6
8
|
*/
|
|
7
9
|
export function createConnectorsModule(axios, appId) {
|
|
8
10
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @param integrationType - The integration type to get access token for
|
|
12
|
-
* @returns Access token response
|
|
13
|
-
*/
|
|
11
|
+
// Retrieve an OAuth access token for a specific external integration type
|
|
12
|
+
// @ts-expect-error Return type mismatch with interface - implementation returns object, interface expects string
|
|
14
13
|
async getAccessToken(integrationType) {
|
|
15
14
|
if (!integrationType || typeof integrationType !== "string") {
|
|
16
15
|
throw new Error("Integration type is required and must be a string");
|
|
@@ -1,4 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type of external integration/connector, such as `'googlecalendar'`, `'slack'`, or `'github'`.
|
|
3
|
+
*/
|
|
1
4
|
export type ConnectorIntegrationType = string;
|
|
2
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Response from the connectors access token endpoint.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConnectorAccessTokenResponse {
|
|
3
9
|
access_token: string;
|
|
4
|
-
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Connectors module for managing OAuth tokens for external services.
|
|
13
|
+
*
|
|
14
|
+
* This module allows you to retrieve OAuth access tokens for external services
|
|
15
|
+
* that the app has connected to. Use these tokens to make API
|
|
16
|
+
* calls to external services.
|
|
17
|
+
*
|
|
18
|
+
* Unlike the integrations module that provides pre-built functions, connectors give you
|
|
19
|
+
* raw OAuth tokens so you can call external service APIs directly with full control over
|
|
20
|
+
* the API calls you make. This is useful when you need custom API interactions that aren't
|
|
21
|
+
* covered by Base44's pre-built integrations.
|
|
22
|
+
*
|
|
23
|
+
* This module is only available to use with a client in service role authentication mode, which means it can only be used in backend environments.
|
|
24
|
+
*/
|
|
25
|
+
export interface ConnectorsModule {
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves an OAuth access token for a specific external integration type.
|
|
28
|
+
*
|
|
29
|
+
* Returns the OAuth token string for an external service that the app
|
|
30
|
+
* has connected to. You can then use this token to make authenticated API calls
|
|
31
|
+
* to that external service.
|
|
32
|
+
*
|
|
33
|
+
* @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
|
|
34
|
+
* @returns Promise resolving to the access token string.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Google Calendar connection
|
|
39
|
+
* // Get Google Calendar OAuth token and fetch upcoming events
|
|
40
|
+
* const googleToken = await base44.asServiceRole.connectors.getAccessToken('googlecalendar');
|
|
41
|
+
*
|
|
42
|
+
* // Fetch upcoming 10 events
|
|
43
|
+
* const timeMin = new Date().toISOString();
|
|
44
|
+
* const url = `https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=10&orderBy=startTime&singleEvents=true&timeMin=${timeMin}`;
|
|
45
|
+
*
|
|
46
|
+
* const calendarResponse = await fetch(url, {
|
|
47
|
+
* headers: { 'Authorization': `Bearer ${googleToken}` }
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const events = await calendarResponse.json();
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Slack connection
|
|
56
|
+
* // Get Slack OAuth token and list channels
|
|
57
|
+
* const slackToken = await base44.asServiceRole.connectors.getAccessToken('slack');
|
|
58
|
+
*
|
|
59
|
+
* // List all public and private channels
|
|
60
|
+
* const url = 'https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=100';
|
|
61
|
+
*
|
|
62
|
+
* const slackResponse = await fetch(url, {
|
|
63
|
+
* headers: { 'Authorization': `Bearer ${slackToken}` }
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* const data = await slackResponse.json();
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
getAccessToken(integrationType: ConnectorIntegrationType): Promise<string>;
|
|
70
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { EntitiesModule } from "./entities.types";
|
|
2
3
|
/**
|
|
3
|
-
* Creates the entities module for the Base44 SDK
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
* Creates the entities module for the Base44 SDK.
|
|
5
|
+
*
|
|
6
|
+
* @param axios - Axios instance
|
|
7
|
+
* @param appId - Application ID
|
|
8
|
+
* @returns Entities module with dynamic entity access
|
|
9
|
+
* @internal
|
|
7
10
|
*/
|
|
8
|
-
export declare function createEntitiesModule(axios: AxiosInstance, appId: string):
|
|
11
|
+
export declare function createEntitiesModule(axios: AxiosInstance, appId: string): EntitiesModule;
|