@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 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
  ```
@@ -1,4 +1,3 @@
1
- export declare const VERSION = "1.0.0";
2
1
  export * from "./types";
3
2
  export * from "./services";
4
3
  export { getAuthToken } from "../shared/utils/auth-token";
@@ -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 = exports.VERSION = void 0;
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({ ...settings, enabled: true }),
139
+ body: JSON.stringify({ enabled: true, ...settings }),
134
140
  });
135
141
  return res.json();
136
142
  },
@@ -39,6 +39,7 @@ export interface TelegramStatusResponse {
39
39
  export interface NotificationPreferences {
40
40
  notificationType: string;
41
41
  channels: string[];
42
+ enabled?: boolean;
42
43
  }
43
44
  export interface SendNotificationRequest {
44
45
  userId: string;
@@ -1,4 +1,3 @@
1
- export declare const VERSION = "1.0.0";
2
1
  export * from "./types";
3
2
  export * from "./services";
4
3
  export { getAuthToken } from "../shared/utils/auth-token";
@@ -1,4 +1,3 @@
1
- export const VERSION = "1.0.0";
2
1
  // Export types
3
2
  export * from "./types/index.js";
4
3
  // 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
  /**
@@ -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({ ...settings, enabled: true }),
134
+ body: JSON.stringify({ enabled: true, ...settings }),
129
135
  });
130
136
  return res.json();
131
137
  },
@@ -39,6 +39,7 @@ export interface TelegramStatusResponse {
39
39
  export interface NotificationPreferences {
40
40
  notificationType: string;
41
41
  channels: string[];
42
+ enabled?: boolean;
42
43
  }
43
44
  export interface SendNotificationRequest {
44
45
  userId: string;
@@ -1,4 +1,3 @@
1
- export declare const VERSION = "1.0.0";
2
1
  export * from "./types";
3
2
  export * from "./services";
4
3
  export { getAuthToken } from "../shared/utils/auth-token";
@@ -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
  /**
@@ -39,6 +39,7 @@ export interface TelegramStatusResponse {
39
39
  export interface NotificationPreferences {
40
40
  notificationType: string;
41
41
  channels: string[];
42
+ enabled?: boolean;
42
43
  }
43
44
  export interface SendNotificationRequest {
44
45
  userId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -1,5 +1,3 @@
1
- export const VERSION = "1.0.0";
2
-
3
1
  // Export types
4
2
  export * from "./types";
5
3
 
@@ -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({ ...settings, enabled: true }),
166
+ body: JSON.stringify({ enabled: true, ...settings }),
161
167
  });
162
168
  return res.json();
163
169
  },
@@ -45,6 +45,7 @@ export interface TelegramStatusResponse {
45
45
  export interface NotificationPreferences {
46
46
  notificationType: string;
47
47
  channels: string[];
48
+ enabled?: boolean;
48
49
  }
49
50
 
50
51
  export interface SendNotificationRequest {