@base44-preview/sdk 0.8.31-pr.187.875349a → 0.8.31-pr.195.4b28467

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 CHANGED
@@ -29,6 +29,7 @@ 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.
32
33
 
33
34
  ## Quickstarts
34
35
 
@@ -96,6 +97,8 @@ Deno.serve(async (req) => {
96
97
  });
97
98
  ```
98
99
 
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
+
99
102
  ## Learn more
100
103
 
101
104
  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,6 +10,7 @@ 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";
13
14
  import { createAnalyticsModule } from "./modules/analytics.js";
14
15
  /**
15
16
  * Creates a Base44 client.
@@ -193,6 +194,7 @@ export function createClient(config) {
193
194
  token,
194
195
  }),
195
196
  appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
197
+ mobile: createMobileModule(serviceRoleAxiosClient, appId),
196
198
  cleanup: () => {
197
199
  if (socket) {
198
200
  socket.disconnect();
@@ -7,6 +7,7 @@ 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";
10
11
  /**
11
12
  * Options for creating a Base44 client.
12
13
  */
@@ -134,6 +135,8 @@ export interface Base44Client {
134
135
  functions: FunctionsModule;
135
136
  /** {@link IntegrationsModule | Integrations module} with elevated permissions. */
136
137
  integrations: IntegrationsModule;
138
+ /** {@link MobileModule | Mobile module} for service-role mobile operations. */
139
+ mobile: MobileModule;
137
140
  /** {@link SsoModule | SSO module} for generating SSO tokens.
138
141
  * @internal
139
142
  */
package/dist/index.d.ts CHANGED
@@ -13,4 +13,5 @@ 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";
16
17
  export type { GetAccessTokenOptions, SaveAccessTokenOptions, RemoveAccessTokenOptions, GetLoginUrlOptions, } from "./utils/auth-utils.types.js";
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,47 @@
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
+ }
@@ -0,0 +1,45 @@
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
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.31-pr.187.875349a",
3
+ "version": "0.8.31-pr.195.4b28467",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  "@vitest/coverage-istanbul": "^1.0.0",
39
39
  "@vitest/coverage-v8": "^1.0.0",
40
40
  "@vitest/ui": "^1.0.0",
41
- "dotenv": "^17.4.2",
41
+ "dotenv": "^16.3.1",
42
42
  "eslint": "^9.39.2",
43
43
  "eslint-plugin-import": "^2.32.0",
44
44
  "nock": "^13.4.0",