@b3dotfun/sdk 0.0.45 → 0.0.46
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 +8 -1
- package/dist/cjs/notifications/index.d.ts +0 -1
- package/dist/cjs/notifications/index.js +1 -2
- package/dist/cjs/notifications/services/api.d.ts +2 -0
- package/dist/cjs/notifications/services/api.js +7 -1
- package/dist/cjs/notifications/types/index.d.ts +1 -0
- package/dist/esm/notifications/index.d.ts +0 -1
- package/dist/esm/notifications/index.js +0 -1
- package/dist/esm/notifications/services/api.d.ts +2 -0
- package/dist/esm/notifications/services/api.js +7 -1
- package/dist/esm/notifications/types/index.d.ts +1 -0
- package/dist/types/notifications/index.d.ts +0 -1
- package/dist/types/notifications/services/api.d.ts +2 -0
- package/dist/types/notifications/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/notifications/index.ts +0 -2
- package/src/notifications/services/api.ts +7 -1
- package/src/notifications/types/index.ts +1 -0
package/README.md
CHANGED
|
@@ -442,12 +442,19 @@ const { connected, chatId } = await notificationsAPI.checkTelegramStatus();
|
|
|
442
442
|
### App Preferences
|
|
443
443
|
|
|
444
444
|
```typescript
|
|
445
|
-
// Save notification preferences for an app
|
|
445
|
+
// Save notification preferences for an app (enabled by default)
|
|
446
446
|
await notificationsAPI.savePreferences("my-app", {
|
|
447
447
|
notificationType: "transaction",
|
|
448
448
|
channels: ["email", "telegram", "in_app"],
|
|
449
449
|
});
|
|
450
450
|
|
|
451
|
+
// Save disabled preferences
|
|
452
|
+
await notificationsAPI.savePreferences("my-app", {
|
|
453
|
+
notificationType: "transaction",
|
|
454
|
+
channels: ["email", "telegram"],
|
|
455
|
+
enabled: false,
|
|
456
|
+
});
|
|
457
|
+
|
|
451
458
|
// Get app settings
|
|
452
459
|
const settings = await notificationsAPI.getAppSettings("my-app");
|
|
453
460
|
```
|
|
@@ -14,8 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getAuthToken =
|
|
18
|
-
exports.VERSION = "1.0.0";
|
|
17
|
+
exports.getAuthToken = void 0;
|
|
19
18
|
// Export types
|
|
20
19
|
__exportStar(require("./types"), exports);
|
|
21
20
|
// Export services
|
|
@@ -44,6 +44,8 @@ export declare const notificationsAPI: {
|
|
|
44
44
|
checkTelegramStatus(): Promise<TelegramStatusResponse>;
|
|
45
45
|
/**
|
|
46
46
|
* Save notification preferences for an app
|
|
47
|
+
* @param appId - The application ID
|
|
48
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
47
49
|
*/
|
|
48
50
|
savePreferences(appId: string, settings: NotificationPreferences): Promise<any>;
|
|
49
51
|
/**
|
|
@@ -34,6 +34,10 @@ exports.notificationsAPI = {
|
|
|
34
34
|
method: "POST",
|
|
35
35
|
headers: getHeaders(true),
|
|
36
36
|
});
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
const errorBody = await res.text().catch(() => "Could not read error body");
|
|
39
|
+
throw new Error(`API Error: ${res.status} ${res.statusText} - ${errorBody}`);
|
|
40
|
+
}
|
|
37
41
|
return res.json();
|
|
38
42
|
},
|
|
39
43
|
/**
|
|
@@ -125,12 +129,14 @@ exports.notificationsAPI = {
|
|
|
125
129
|
// ===== APP PREFERENCES =====
|
|
126
130
|
/**
|
|
127
131
|
* Save notification preferences for an app
|
|
132
|
+
* @param appId - The application ID
|
|
133
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
128
134
|
*/
|
|
129
135
|
async savePreferences(appId, settings) {
|
|
130
136
|
const res = await fetch(`${apiUrl}/users/me/apps/${appId}/settings`, {
|
|
131
137
|
method: "POST",
|
|
132
138
|
headers: getHeaders(true),
|
|
133
|
-
body: JSON.stringify({
|
|
139
|
+
body: JSON.stringify({ enabled: true, ...settings }),
|
|
134
140
|
});
|
|
135
141
|
return res.json();
|
|
136
142
|
},
|
|
@@ -44,6 +44,8 @@ export declare const notificationsAPI: {
|
|
|
44
44
|
checkTelegramStatus(): Promise<TelegramStatusResponse>;
|
|
45
45
|
/**
|
|
46
46
|
* Save notification preferences for an app
|
|
47
|
+
* @param appId - The application ID
|
|
48
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
47
49
|
*/
|
|
48
50
|
savePreferences(appId: string, settings: NotificationPreferences): Promise<any>;
|
|
49
51
|
/**
|
|
@@ -29,6 +29,10 @@ export const notificationsAPI = {
|
|
|
29
29
|
method: "POST",
|
|
30
30
|
headers: getHeaders(true),
|
|
31
31
|
});
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const errorBody = await res.text().catch(() => "Could not read error body");
|
|
34
|
+
throw new Error(`API Error: ${res.status} ${res.statusText} - ${errorBody}`);
|
|
35
|
+
}
|
|
32
36
|
return res.json();
|
|
33
37
|
},
|
|
34
38
|
/**
|
|
@@ -120,12 +124,14 @@ export const notificationsAPI = {
|
|
|
120
124
|
// ===== APP PREFERENCES =====
|
|
121
125
|
/**
|
|
122
126
|
* Save notification preferences for an app
|
|
127
|
+
* @param appId - The application ID
|
|
128
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
123
129
|
*/
|
|
124
130
|
async savePreferences(appId, settings) {
|
|
125
131
|
const res = await fetch(`${apiUrl}/users/me/apps/${appId}/settings`, {
|
|
126
132
|
method: "POST",
|
|
127
133
|
headers: getHeaders(true),
|
|
128
|
-
body: JSON.stringify({
|
|
134
|
+
body: JSON.stringify({ enabled: true, ...settings }),
|
|
129
135
|
});
|
|
130
136
|
return res.json();
|
|
131
137
|
},
|
|
@@ -44,6 +44,8 @@ export declare const notificationsAPI: {
|
|
|
44
44
|
checkTelegramStatus(): Promise<TelegramStatusResponse>;
|
|
45
45
|
/**
|
|
46
46
|
* Save notification preferences for an app
|
|
47
|
+
* @param appId - The application ID
|
|
48
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
47
49
|
*/
|
|
48
50
|
savePreferences(appId: string, settings: NotificationPreferences): Promise<any>;
|
|
49
51
|
/**
|
package/package.json
CHANGED
|
@@ -46,6 +46,10 @@ export const notificationsAPI = {
|
|
|
46
46
|
method: "POST",
|
|
47
47
|
headers: getHeaders(true),
|
|
48
48
|
});
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
const errorBody = await res.text().catch(() => "Could not read error body");
|
|
51
|
+
throw new Error(`API Error: ${res.status} ${res.statusText} - ${errorBody}`);
|
|
52
|
+
}
|
|
49
53
|
return res.json();
|
|
50
54
|
},
|
|
51
55
|
|
|
@@ -152,12 +156,14 @@ export const notificationsAPI = {
|
|
|
152
156
|
|
|
153
157
|
/**
|
|
154
158
|
* Save notification preferences for an app
|
|
159
|
+
* @param appId - The application ID
|
|
160
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
155
161
|
*/
|
|
156
162
|
async savePreferences(appId: string, settings: NotificationPreferences) {
|
|
157
163
|
const res = await fetch(`${apiUrl}/users/me/apps/${appId}/settings`, {
|
|
158
164
|
method: "POST",
|
|
159
165
|
headers: getHeaders(true),
|
|
160
|
-
body: JSON.stringify({
|
|
166
|
+
body: JSON.stringify({ enabled: true, ...settings }),
|
|
161
167
|
});
|
|
162
168
|
return res.json();
|
|
163
169
|
},
|