@base44-preview/sdk 0.8.17-pr.73.e88f2f7 → 0.8.17-pr.75.4ddbc56
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 -130
- package/dist/client.js +0 -3
- package/dist/client.types.d.ts +0 -3
- package/dist/index.d.ts +0 -1
- package/dist/modules/analytics.js +1 -0
- package/package.json +1 -1
- package/dist/modules/mobile.d.ts +0 -16
- package/dist/modules/mobile.js +0 -39
- package/dist/modules/mobile.types.d.ts +0 -86
- package/dist/modules/mobile.types.js +0 -7
package/README.md
CHANGED
|
@@ -13,7 +13,6 @@ The SDK provides access to Base44's functionality through the following modules:
|
|
|
13
13
|
- **[`entities`](https://docs.base44.com/sdk-docs/interfaces/entities)**: Work with your app's data entities using CRUD operations.
|
|
14
14
|
- **[`functions`](https://docs.base44.com/sdk-docs/interfaces/functions)**: Execute backend functions.
|
|
15
15
|
- **[`integrations`](https://docs.base44.com/sdk-docs/type-aliases/integrations)**: Pre-built server-side functions for external services.
|
|
16
|
-
- **[`mobile`](#mobile-native-features)**: Send push notifications and access mobile native capabilities.
|
|
17
16
|
|
|
18
17
|
## Example
|
|
19
18
|
|
|
@@ -38,135 +37,6 @@ await base44.entities.Task.update(newTask.id, {
|
|
|
38
37
|
const tasks = await base44.entities.Task.list();
|
|
39
38
|
```
|
|
40
39
|
|
|
41
|
-
## Mobile Native Features
|
|
42
|
-
|
|
43
|
-
The SDK provides mobile native capabilities through the `mobile` module, allowing you to send push notifications to your app users.
|
|
44
|
-
|
|
45
|
-
### Push Notifications
|
|
46
|
-
|
|
47
|
-
Send push notifications to users on mobile devices:
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
import { base44 } from "@/api/base44Client";
|
|
51
|
-
|
|
52
|
-
// Send a push notification to a user
|
|
53
|
-
await base44.mobile.sendNotification({
|
|
54
|
-
userId: "user_123",
|
|
55
|
-
title: "New Message!",
|
|
56
|
-
content: "You have a new message from John",
|
|
57
|
-
actionLabel: "View Message",
|
|
58
|
-
actionUrl: "/messages/456",
|
|
59
|
-
channels: ["mobile_push"], // Mobile push only
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Send to both mobile push and in-app notifications (default)
|
|
63
|
-
await base44.mobile.sendNotification({
|
|
64
|
-
userId: "user_456",
|
|
65
|
-
title: "Order Shipped",
|
|
66
|
-
content: "Your order #12345 has been shipped and is on its way!",
|
|
67
|
-
actionLabel: "Track Order",
|
|
68
|
-
actionUrl: "/orders/12345",
|
|
69
|
-
});
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Notification Channels
|
|
73
|
-
|
|
74
|
-
The `mobile` module supports two notification channels:
|
|
75
|
-
|
|
76
|
-
- **`mobile_push`**: Sends a push notification to the user's mobile device (iOS/Android)
|
|
77
|
-
- **`in_app`**: Sends an in-app notification visible in the web interface
|
|
78
|
-
|
|
79
|
-
By default, notifications are sent to both channels. You can specify specific channels using the `channels` parameter:
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
// Mobile push only - user will receive push notification on their phone
|
|
83
|
-
await base44.mobile.sendNotification({
|
|
84
|
-
userId: "user_123",
|
|
85
|
-
title: "Time-sensitive alert",
|
|
86
|
-
content: "Your session will expire in 5 minutes",
|
|
87
|
-
channels: ["mobile_push"],
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// In-app only - notification visible only in the web interface
|
|
91
|
-
await base44.mobile.sendNotification({
|
|
92
|
-
userId: "user_789",
|
|
93
|
-
title: "System Update",
|
|
94
|
-
content: "We've updated the dashboard with new features",
|
|
95
|
-
channels: ["in_app"],
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Common Use Cases
|
|
100
|
-
|
|
101
|
-
**Order & Delivery Updates**:
|
|
102
|
-
```typescript
|
|
103
|
-
// Notify user when order is ready
|
|
104
|
-
await base44.mobile.sendNotification({
|
|
105
|
-
userId: order.userId,
|
|
106
|
-
title: "Order Ready for Pickup",
|
|
107
|
-
content: `Your order #${order.id} is ready at ${store.name}`,
|
|
108
|
-
actionLabel: "View Order",
|
|
109
|
-
actionUrl: `/orders/${order.id}`,
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**Chat & Messaging**:
|
|
114
|
-
```typescript
|
|
115
|
-
// Notify user of new messages
|
|
116
|
-
await base44.mobile.sendNotification({
|
|
117
|
-
userId: recipient.id,
|
|
118
|
-
title: `New message from ${sender.name}`,
|
|
119
|
-
content: message.preview,
|
|
120
|
-
actionLabel: "Reply",
|
|
121
|
-
actionUrl: `/chats/${conversation.id}`,
|
|
122
|
-
channels: ["mobile_push"], // Mobile only, avoid duplicate with in-app chat
|
|
123
|
-
});
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Reminders & Events**:
|
|
127
|
-
```typescript
|
|
128
|
-
// Send event reminder
|
|
129
|
-
await base44.mobile.sendNotification({
|
|
130
|
-
userId: attendee.userId,
|
|
131
|
-
title: "Event Starting Soon",
|
|
132
|
-
content: `${event.name} starts in 30 minutes`,
|
|
133
|
-
actionLabel: "View Details",
|
|
134
|
-
actionUrl: `/events/${event.id}`,
|
|
135
|
-
});
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Error Handling
|
|
139
|
-
|
|
140
|
-
The notification API handles errors gracefully:
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
try {
|
|
144
|
-
const result = await base44.mobile.sendNotification({
|
|
145
|
-
userId: "user_123",
|
|
146
|
-
title: "Test Notification",
|
|
147
|
-
content: "This is a test",
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
if (result.success) {
|
|
151
|
-
console.log("Notification sent successfully");
|
|
152
|
-
console.log("Notification ID:", result.notificationId);
|
|
153
|
-
}
|
|
154
|
-
} catch (error) {
|
|
155
|
-
if (error.status === 404) {
|
|
156
|
-
console.error("User not found");
|
|
157
|
-
} else if (error.status === 403) {
|
|
158
|
-
console.error("Not authorized to send notifications");
|
|
159
|
-
} else {
|
|
160
|
-
console.error("Failed to send notification:", error.message);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**Graceful Degradation**:
|
|
166
|
-
- If a user doesn't have mobile push enabled, the notification is still sent to other channels
|
|
167
|
-
- If one channel fails, other channels still receive the notification
|
|
168
|
-
- Notifications are queued and retried automatically for temporary failures
|
|
169
|
-
|
|
170
40
|
## Learn more
|
|
171
41
|
|
|
172
42
|
For complete documentation, guides, and API reference, visit the **[Base44 SDK Documentation](https://docs.base44.com/sdk-getting-started/overview)**.
|
package/dist/client.js
CHANGED
|
@@ -9,7 +9,6 @@ import { createFunctionsModule } from "./modules/functions.js";
|
|
|
9
9
|
import { createAgentsModule } from "./modules/agents.js";
|
|
10
10
|
import { createAppLogsModule } from "./modules/app-logs.js";
|
|
11
11
|
import { createUsersModule } from "./modules/users.js";
|
|
12
|
-
import { createMobileModule } from "./modules/mobile.js";
|
|
13
12
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
14
13
|
import { createAnalyticsModule } from "./modules/analytics.js";
|
|
15
14
|
/**
|
|
@@ -122,7 +121,6 @@ export function createClient(config) {
|
|
|
122
121
|
}),
|
|
123
122
|
appLogs: createAppLogsModule(axiosClient, appId),
|
|
124
123
|
users: createUsersModule(axiosClient, appId),
|
|
125
|
-
mobile: createMobileModule(axiosClient, appId),
|
|
126
124
|
analytics: createAnalyticsModule({
|
|
127
125
|
axiosClient,
|
|
128
126
|
serverUrl,
|
|
@@ -154,7 +152,6 @@ export function createClient(config) {
|
|
|
154
152
|
token,
|
|
155
153
|
}),
|
|
156
154
|
appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
|
|
157
|
-
mobile: createMobileModule(serviceRoleAxiosClient, appId),
|
|
158
155
|
cleanup: () => {
|
|
159
156
|
if (socket) {
|
|
160
157
|
socket.disconnect();
|
package/dist/client.types.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { ConnectorsModule } from "./modules/connectors.types.js";
|
|
|
6
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
|
-
import type { MobileModule } from "./modules/mobile.types.js";
|
|
10
9
|
import type { AnalyticsModule } from "./modules/analytics.types.js";
|
|
11
10
|
/**
|
|
12
11
|
* Options for creating a Base44 client.
|
|
@@ -84,8 +83,6 @@ export interface Base44Client {
|
|
|
84
83
|
agents: AgentsModule;
|
|
85
84
|
/** {@link AppLogsModule | App logs module} for tracking app usage. */
|
|
86
85
|
appLogs: AppLogsModule;
|
|
87
|
-
/** {@link MobileModule | Mobile module} for mobile native capabilities like push notifications. */
|
|
88
|
-
mobile: MobileModule;
|
|
89
86
|
/** {@link AnalyticsModule | Analytics module} for tracking app usage. */
|
|
90
87
|
analytics: AnalyticsModule;
|
|
91
88
|
/** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export type { IntegrationsModule, IntegrationPackage, IntegrationEndpointFunctio
|
|
|
10
10
|
export type { FunctionsModule } from "./modules/functions.types.js";
|
|
11
11
|
export type { AgentsModule, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
|
|
12
12
|
export type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
13
|
-
export type { MobileModule, SendNotificationParams, NotificationResult, NotificationChannel, ChannelResult, } from "./modules/mobile.types.js";
|
|
14
13
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
15
14
|
export type { ConnectorsModule } from "./modules/connectors.types.js";
|
|
16
15
|
export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
|
|
@@ -166,6 +166,7 @@ function startHeartBeatProcessor(track) {
|
|
|
166
166
|
return () => { };
|
|
167
167
|
}
|
|
168
168
|
analyticsSharedState.isHeartBeatProcessing = true;
|
|
169
|
+
track({ eventName: USER_HEARTBEAT_EVENT_NAME });
|
|
169
170
|
const interval = setInterval(() => {
|
|
170
171
|
track({ eventName: USER_HEARTBEAT_EVENT_NAME });
|
|
171
172
|
}, analyticsSharedState.config.heartBeatInterval);
|
package/package.json
CHANGED
package/dist/modules/mobile.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile module for Base44 SDK.
|
|
3
|
-
*
|
|
4
|
-
* Provides mobile native capabilities like push notifications.
|
|
5
|
-
*/
|
|
6
|
-
import { AxiosInstance } from "axios";
|
|
7
|
-
import { MobileModule } from "./mobile.types";
|
|
8
|
-
/**
|
|
9
|
-
* Creates the mobile module for the Base44 SDK.
|
|
10
|
-
*
|
|
11
|
-
* @param axios - Axios instance for API requests
|
|
12
|
-
* @param appId - Application ID
|
|
13
|
-
* @returns Mobile module with native mobile capabilities
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function createMobileModule(axios: AxiosInstance, appId: string): MobileModule;
|
package/dist/modules/mobile.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile module for Base44 SDK.
|
|
3
|
-
*
|
|
4
|
-
* Provides mobile native capabilities like push notifications.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Validates notification parameters against character limits.
|
|
8
|
-
* @param params - Notification parameters to validate
|
|
9
|
-
* @throws Error if any parameter exceeds its limit
|
|
10
|
-
*/
|
|
11
|
-
function validateNotificationParams(params) {
|
|
12
|
-
if (params.title.length > 100) {
|
|
13
|
-
throw new Error(`Title must be 100 characters or less (current: ${params.title.length})`);
|
|
14
|
-
}
|
|
15
|
-
if (params.content.length > 500) {
|
|
16
|
-
throw new Error(`Content must be 500 characters or less (current: ${params.content.length})`);
|
|
17
|
-
}
|
|
18
|
-
if (params.actionLabel && params.actionLabel.length > 50) {
|
|
19
|
-
throw new Error(`Action label must be 50 characters or less (current: ${params.actionLabel.length})`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Creates the mobile module for the Base44 SDK.
|
|
24
|
-
*
|
|
25
|
-
* @param axios - Axios instance for API requests
|
|
26
|
-
* @param appId - Application ID
|
|
27
|
-
* @returns Mobile module with native mobile capabilities
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export function createMobileModule(axios, appId) {
|
|
31
|
-
return {
|
|
32
|
-
async sendNotification(params) {
|
|
33
|
-
// Validate input parameters
|
|
34
|
-
validateNotificationParams(params);
|
|
35
|
-
const response = await axios.post(`/api/apps/${appId}/mobile/notifications`, params);
|
|
36
|
-
return response.data;
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript type definitions for Base44 Mobile SDK.
|
|
3
|
-
*
|
|
4
|
-
* Provides mobile native capabilities like push notifications
|
|
5
|
-
* for apps built with Base44.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Channel type for notifications.
|
|
9
|
-
* - "mobile_push": Send via mobile push notification (Ping service)
|
|
10
|
-
* - "in_app": Send via in-app notification (WebSocket + MongoDB)
|
|
11
|
-
*/
|
|
12
|
-
export type NotificationChannel = "mobile_push" | "in_app";
|
|
13
|
-
/**
|
|
14
|
-
* Parameters for sending a notification to an app user.
|
|
15
|
-
*/
|
|
16
|
-
export interface SendNotificationParams {
|
|
17
|
-
/** App user ID to notify */
|
|
18
|
-
userId: string;
|
|
19
|
-
/** Notification title (max 100 characters) */
|
|
20
|
-
title: string;
|
|
21
|
-
/** Notification content (max 500 characters, supports HTML) */
|
|
22
|
-
content: string;
|
|
23
|
-
/** Optional button text (max 50 characters) */
|
|
24
|
-
actionLabel?: string;
|
|
25
|
-
/** Optional button link */
|
|
26
|
-
actionUrl?: string;
|
|
27
|
-
/** Optional list of channels. If not specified, uses all channels (mobile_push + in_app) */
|
|
28
|
-
channels?: NotificationChannel[];
|
|
29
|
-
/** Optional custom metadata */
|
|
30
|
-
metadata?: Record<string, unknown>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Result from a single notification channel.
|
|
34
|
-
*/
|
|
35
|
-
export interface ChannelResult {
|
|
36
|
-
/** Whether the notification was sent successfully through this channel */
|
|
37
|
-
success: boolean;
|
|
38
|
-
/** Error message if the channel failed */
|
|
39
|
-
error?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Response from sending a notification.
|
|
43
|
-
*/
|
|
44
|
-
export interface NotificationResult {
|
|
45
|
-
/** Overall success status */
|
|
46
|
-
success: boolean;
|
|
47
|
-
/** Notification ID if in_app channel was used */
|
|
48
|
-
notificationId?: string;
|
|
49
|
-
/** Results per channel */
|
|
50
|
-
channels: {
|
|
51
|
-
in_app?: ChannelResult;
|
|
52
|
-
mobile_push?: ChannelResult;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Mobile module interface providing mobile native capabilities.
|
|
57
|
-
*/
|
|
58
|
-
export interface MobileModule {
|
|
59
|
-
/**
|
|
60
|
-
* Send a notification to an app user.
|
|
61
|
-
*
|
|
62
|
-
* @param params - Notification parameters
|
|
63
|
-
* @returns Promise resolving to notification result
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* // Send mobile push notification only
|
|
68
|
-
* await base44.mobile.sendNotification({
|
|
69
|
-
* userId: 'app_user_123',
|
|
70
|
-
* title: 'New Message!',
|
|
71
|
-
* content: 'You have a new message from John',
|
|
72
|
-
* actionLabel: 'View Message',
|
|
73
|
-
* actionUrl: '/messages/456',
|
|
74
|
-
* channels: ['mobile_push']
|
|
75
|
-
* });
|
|
76
|
-
*
|
|
77
|
-
* // Send to both channels (default)
|
|
78
|
-
* await base44.mobile.sendNotification({
|
|
79
|
-
* userId: 'app_user_123',
|
|
80
|
-
* title: 'Order Shipped',
|
|
81
|
-
* content: 'Your order #12345 has been shipped'
|
|
82
|
-
* });
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
sendNotification(params: SendNotificationParams): Promise<NotificationResult>;
|
|
86
|
-
}
|