@base44-preview/sdk 0.8.31-pr.195.c0f5839 → 0.8.32-pr.196.8c75df2
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/README.md +0 -3
- package/dist/client.js +0 -2
- package/dist/client.types.d.ts +0 -3
- package/dist/index.d.ts +0 -1
- package/dist/modules/auth.types.d.ts +52 -12
- package/package.json +1 -1
- package/dist/modules/mobile.d.ts +0 -11
- package/dist/modules/mobile.js +0 -47
- package/dist/modules/mobile.types.d.ts +0 -45
- package/dist/modules/mobile.types.js +0 -1
package/README.md
CHANGED
|
@@ -29,7 +29,6 @@ The SDK provides access to Base44's functionality through the following modules:
|
|
|
29
29
|
- **[`entities`](https://docs.base44.com/developers/references/sdk/docs/interfaces/entities)**: Work with your app's data entities using CRUD operations.
|
|
30
30
|
- **[`functions`](https://docs.base44.com/developers/references/sdk/docs/interfaces/functions)**: Execute backend functions.
|
|
31
31
|
- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations.
|
|
32
|
-
- **`mobile`**: Send AppUser mobile push notifications from service-role backend code.
|
|
33
32
|
|
|
34
33
|
## Quickstarts
|
|
35
34
|
|
|
@@ -97,8 +96,6 @@ Deno.serve(async (req) => {
|
|
|
97
96
|
});
|
|
98
97
|
```
|
|
99
98
|
|
|
100
|
-
Service-role-only modules such as `base44.asServiceRole.mobile` are available only in backend functions. Use `base44.asServiceRole.mobile.sendNotification(...)` to send AppUser push notifications from backend code after validating that the caller is allowed to trigger the notification. Do not expose mobile push sending from frontend/client-side code.
|
|
101
|
-
|
|
102
99
|
## Learn more
|
|
103
100
|
|
|
104
101
|
The best way to get started with the JavaScript SDK is to have Base44 build an app for you. Once you have an app, you can explore the generated code and experiment with the SDK to see how it works in practice. You can also ask Base44 to demonstrate specific features of the SDK.
|
package/dist/client.js
CHANGED
|
@@ -10,7 +10,6 @@ import { createAgentsModule } from "./modules/agents.js";
|
|
|
10
10
|
import { createAppLogsModule } from "./modules/app-logs.js";
|
|
11
11
|
import { createUsersModule } from "./modules/users.js";
|
|
12
12
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
13
|
-
import { createMobileModule } from "./modules/mobile.js";
|
|
14
13
|
import { createAnalyticsModule } from "./modules/analytics.js";
|
|
15
14
|
/**
|
|
16
15
|
* Creates a Base44 client.
|
|
@@ -194,7 +193,6 @@ export function createClient(config) {
|
|
|
194
193
|
token,
|
|
195
194
|
}),
|
|
196
195
|
appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
|
|
197
|
-
mobile: createMobileModule(serviceRoleAxiosClient, appId),
|
|
198
196
|
cleanup: () => {
|
|
199
197
|
if (socket) {
|
|
200
198
|
socket.disconnect();
|
package/dist/client.types.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type { FunctionsModule } from "./modules/functions.types.js";
|
|
|
7
7
|
import type { AgentsModule } from "./modules/agents.types.js";
|
|
8
8
|
import type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
9
9
|
import type { AnalyticsModule } from "./modules/analytics.types.js";
|
|
10
|
-
import type { MobileModule } from "./modules/mobile.types.js";
|
|
11
10
|
/**
|
|
12
11
|
* Options for creating a Base44 client.
|
|
13
12
|
*/
|
|
@@ -135,8 +134,6 @@ export interface Base44Client {
|
|
|
135
134
|
functions: FunctionsModule;
|
|
136
135
|
/** {@link IntegrationsModule | Integrations module} with elevated permissions. */
|
|
137
136
|
integrations: IntegrationsModule;
|
|
138
|
-
/** {@link MobileModule | Mobile module} for service-role mobile operations. */
|
|
139
|
-
mobile: MobileModule;
|
|
140
137
|
/** {@link SsoModule | SSO module} for generating SSO tokens.
|
|
141
138
|
* @internal
|
|
142
139
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -13,5 +13,4 @@ export type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
|
13
13
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
14
14
|
export type { ConnectorsModule, UserConnectorsModule, } from "./modules/connectors.types.js";
|
|
15
15
|
export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
|
|
16
|
-
export type { MobileModule, SendNotificationParams, SendNotificationResult, } from "./modules/mobile.types.js";
|
|
17
16
|
export type { GetAccessTokenOptions, SaveAccessTokenOptions, RemoveAccessTokenOptions, GetLoginUrlOptions, } from "./utils/auth-utils.types.js";
|
|
@@ -338,8 +338,10 @@ export interface AuthModule {
|
|
|
338
338
|
/**
|
|
339
339
|
* Registers a new user account.
|
|
340
340
|
*
|
|
341
|
-
* Creates a new user account with email and password.
|
|
342
|
-
*
|
|
341
|
+
* Creates a new user account with email and password. Registration sends an OTP
|
|
342
|
+
* code to the user's email. Pass that code to
|
|
343
|
+
* {@linkcode verifyOtp | verifyOtp()} to complete verification, then log the user
|
|
344
|
+
* in with {@linkcode loginViaEmailPassword | loginViaEmailPassword()}.
|
|
343
345
|
*
|
|
344
346
|
* @param params - Registration details including email, password, and optional fields.
|
|
345
347
|
* @returns Promise resolving to the registration response.
|
|
@@ -353,7 +355,13 @@ export interface AuthModule {
|
|
|
353
355
|
* referral_code: 'FRIEND2024'
|
|
354
356
|
* });
|
|
355
357
|
*
|
|
356
|
-
* //
|
|
358
|
+
* // Verify with the OTP code from the user's email
|
|
359
|
+
* await base44.auth.verifyOtp({
|
|
360
|
+
* email: 'newuser@example.com',
|
|
361
|
+
* otpCode: '123456'
|
|
362
|
+
* });
|
|
363
|
+
*
|
|
364
|
+
* // Log the user in after verification
|
|
357
365
|
* const { access_token, user } = await base44.auth.loginViaEmailPassword(
|
|
358
366
|
* 'newuser@example.com',
|
|
359
367
|
* 'securePassword123'
|
|
@@ -362,17 +370,23 @@ export interface AuthModule {
|
|
|
362
370
|
*/
|
|
363
371
|
register(params: RegisterParams): Promise<any>;
|
|
364
372
|
/**
|
|
365
|
-
* Verifies an OTP (
|
|
373
|
+
* Verifies an OTP (one-time password) code.
|
|
366
374
|
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
375
|
+
* Confirms that the user owns the email address by checking the code sent to
|
|
376
|
+
* their inbox during {@linkcode register | register()}. After a successful
|
|
377
|
+
* call, log the user in with
|
|
378
|
+
* {@linkcode loginViaEmailPassword | loginViaEmailPassword()}. If the code
|
|
379
|
+
* has expired or the user didn't receive it, send a fresh one with
|
|
380
|
+
* {@linkcode resendOtp | resendOtp()}.
|
|
369
381
|
*
|
|
370
|
-
* @param params -
|
|
371
|
-
* @returns Promise resolving to the verification response
|
|
372
|
-
*
|
|
382
|
+
* @param params - The email being verified and the OTP code the user entered.
|
|
383
|
+
* @returns Promise resolving to the verification response, which includes an
|
|
384
|
+
* access token for the now-verified user.
|
|
385
|
+
* @throws Error if the OTP code is invalid or expired.
|
|
373
386
|
*
|
|
374
387
|
* @example
|
|
375
388
|
* ```typescript
|
|
389
|
+
* // Verify the code the user entered from their email
|
|
376
390
|
* try {
|
|
377
391
|
* await base44.auth.verifyOtp({
|
|
378
392
|
* email: 'user@example.com',
|
|
@@ -383,19 +397,45 @@ export interface AuthModule {
|
|
|
383
397
|
* console.error('Invalid or expired OTP code');
|
|
384
398
|
* }
|
|
385
399
|
* ```
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```typescript
|
|
403
|
+
* // Full registration flow
|
|
404
|
+
* await base44.auth.register({
|
|
405
|
+
* email: 'newuser@example.com',
|
|
406
|
+
* password: 'securePassword123'
|
|
407
|
+
* });
|
|
408
|
+
*
|
|
409
|
+
* // The user receives an OTP code by email. Collect it and verify.
|
|
410
|
+
* await base44.auth.verifyOtp({
|
|
411
|
+
* email: 'newuser@example.com',
|
|
412
|
+
* otpCode: '123456'
|
|
413
|
+
* });
|
|
414
|
+
*
|
|
415
|
+
* // Log the user in after verification
|
|
416
|
+
* const { access_token, user } = await base44.auth.loginViaEmailPassword(
|
|
417
|
+
* 'newuser@example.com',
|
|
418
|
+
* 'securePassword123'
|
|
419
|
+
* );
|
|
420
|
+
* ```
|
|
386
421
|
*/
|
|
387
422
|
verifyOtp(params: VerifyOtpParams): Promise<any>;
|
|
388
423
|
/**
|
|
389
424
|
* Resends an OTP code to the user's email address.
|
|
390
425
|
*
|
|
391
|
-
*
|
|
426
|
+
* Call this when the user didn't receive the original code sent by
|
|
427
|
+
* {@linkcode register | register()}, or when the previous code has expired.
|
|
428
|
+
* The new code replaces the previous one. Pass it to
|
|
429
|
+
* {@linkcode verifyOtp | verifyOtp()} to complete verification.
|
|
392
430
|
*
|
|
393
|
-
* @param email - Email address to send the OTP to.
|
|
394
|
-
* @returns Promise resolving
|
|
431
|
+
* @param email - Email address to send the new OTP to.
|
|
432
|
+
* @returns Promise resolving once the new OTP has been sent, with a
|
|
433
|
+
* confirmation message and the new code's expiration window.
|
|
395
434
|
* @throws Error if the email is invalid or the request fails.
|
|
396
435
|
*
|
|
397
436
|
* @example
|
|
398
437
|
* ```typescript
|
|
438
|
+
* // Resend the OTP when the user didn't receive the original
|
|
399
439
|
* try {
|
|
400
440
|
* await base44.auth.resendOtp('user@example.com');
|
|
401
441
|
* console.log('OTP resent! Please check your email.');
|
package/package.json
CHANGED
package/dist/modules/mobile.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from "axios";
|
|
2
|
-
import type { MobileModule } from "./mobile.types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates the service-role mobile module.
|
|
5
|
-
*
|
|
6
|
-
* @param axios - Axios instance (should be service role client)
|
|
7
|
-
* @param appId - Application ID
|
|
8
|
-
* @returns Mobile module with push notification methods
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare function createMobileModule(axios: AxiosInstance, appId: string): MobileModule;
|
package/dist/modules/mobile.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
function validateRequiredString(value, fieldName, maxLength) {
|
|
2
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
3
|
-
throw new Error(`${fieldName} is required and must be a string`);
|
|
4
|
-
}
|
|
5
|
-
if (maxLength !== undefined && value.length > maxLength) {
|
|
6
|
-
throw new Error(`${fieldName} must be at most ${maxLength} characters`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function validateOptionalString(value, fieldName, maxLength) {
|
|
10
|
-
if (value === undefined) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (typeof value !== "string") {
|
|
14
|
-
throw new Error(`${fieldName} must be a string`);
|
|
15
|
-
}
|
|
16
|
-
if (maxLength !== undefined && value.length > maxLength) {
|
|
17
|
-
throw new Error(`${fieldName} must be at most ${maxLength} characters`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates the service-role mobile module.
|
|
22
|
-
*
|
|
23
|
-
* @param axios - Axios instance (should be service role client)
|
|
24
|
-
* @param appId - Application ID
|
|
25
|
-
* @returns Mobile module with push notification methods
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export function createMobileModule(axios, appId) {
|
|
29
|
-
return {
|
|
30
|
-
async sendNotification(params) {
|
|
31
|
-
if (!params || typeof params !== "object") {
|
|
32
|
-
throw new Error("Notification params are required");
|
|
33
|
-
}
|
|
34
|
-
validateRequiredString(params.userId, "userId");
|
|
35
|
-
validateRequiredString(params.title, "title", 100);
|
|
36
|
-
validateRequiredString(params.content, "content", 500);
|
|
37
|
-
validateOptionalString(params.actionLabel, "actionLabel", 50);
|
|
38
|
-
validateOptionalString(params.actionUrl, "actionUrl");
|
|
39
|
-
if (params.metadata !== undefined &&
|
|
40
|
-
(typeof params.metadata !== "object" || Array.isArray(params.metadata))) {
|
|
41
|
-
throw new Error("metadata must be an object");
|
|
42
|
-
}
|
|
43
|
-
const response = await axios.post(`/apps/${appId}/mobile/notifications`, params);
|
|
44
|
-
return response;
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parameters for sending a mobile push notification to an app user.
|
|
3
|
-
*/
|
|
4
|
-
export interface SendNotificationParams {
|
|
5
|
-
/** Target AppUser ID. */
|
|
6
|
-
userId: string;
|
|
7
|
-
/** Notification title. Maximum 100 characters. */
|
|
8
|
-
title: string;
|
|
9
|
-
/** Notification body. Maximum 500 characters. */
|
|
10
|
-
content: string;
|
|
11
|
-
/** Optional action label. Maximum 50 characters. */
|
|
12
|
-
actionLabel?: string;
|
|
13
|
-
/** Optional action URL opened by the notification action. */
|
|
14
|
-
actionUrl?: string;
|
|
15
|
-
/** Optional metadata delivered with the notification event. */
|
|
16
|
-
metadata?: Record<string, unknown>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Result returned after attempting to send a mobile push notification.
|
|
20
|
-
*/
|
|
21
|
-
export interface SendNotificationResult {
|
|
22
|
-
/** Channels that completed successfully. */
|
|
23
|
-
successfulChannels: string[];
|
|
24
|
-
/** Channel errors keyed by channel name. */
|
|
25
|
-
failedChannels: Record<string, string>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Service-role-only mobile module.
|
|
29
|
-
*
|
|
30
|
-
* This module is exposed only as `base44.asServiceRole.mobile` and is intended
|
|
31
|
-
* for Base44-hosted backend functions or validated server-side webhooks. Normal
|
|
32
|
-
* frontend clients do not expose `base44.mobile`.
|
|
33
|
-
*/
|
|
34
|
-
export interface MobileModule {
|
|
35
|
-
/**
|
|
36
|
-
* Sends a push notification to an app user.
|
|
37
|
-
*
|
|
38
|
-
* This method is only available through `base44.asServiceRole.mobile`.
|
|
39
|
-
* Do not call it from generated frontend/client-side app code.
|
|
40
|
-
*
|
|
41
|
-
* @param params - Notification target and content.
|
|
42
|
-
* @returns The notification delivery result.
|
|
43
|
-
*/
|
|
44
|
-
sendNotification(params: SendNotificationParams): Promise<SendNotificationResult>;
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|