@suprsend/web-sdk 1.2.0 → 1.2.2
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/dist/cdn_bundle.js +1 -1
- package/dist/cjs_bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +6 -8
- package/src/preferences.js +11 -5
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export enum ChannelLevelPreferenceOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
type EmitterEvents = {
|
|
18
|
-
preferences_updated
|
|
18
|
+
preferences_updated: PreferenceData;
|
|
19
19
|
preferences_error: PreferenceErrorData;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -58,7 +58,7 @@ interface PreferenceErrorData {
|
|
|
58
58
|
error_obj?: Error | null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
interface
|
|
61
|
+
interface PreferencesResponse extends PreferenceData, PreferenceErrorData {}
|
|
62
62
|
|
|
63
63
|
interface GetCategoriesResponse extends PreferenceErrorData {
|
|
64
64
|
meta: { count: number; limit: number; offset: number };
|
|
@@ -72,9 +72,7 @@ interface GetOverAllChannelPreferencesResponse extends PreferenceErrorData {
|
|
|
72
72
|
interface Preferences {
|
|
73
73
|
data: PreferenceData;
|
|
74
74
|
|
|
75
|
-
get_preferences(args?: {
|
|
76
|
-
brand_id?: string;
|
|
77
|
-
}): Promise<GetPreferencesResponse>;
|
|
75
|
+
get_preferences(args?: { brand_id?: string }): Promise<PreferencesResponse>;
|
|
78
76
|
|
|
79
77
|
get_categories(args?: {
|
|
80
78
|
brand_id?: string;
|
|
@@ -95,7 +93,7 @@ interface Preferences {
|
|
|
95
93
|
args?: {
|
|
96
94
|
brand_id?: string;
|
|
97
95
|
}
|
|
98
|
-
):
|
|
96
|
+
): PreferencesResponse;
|
|
99
97
|
|
|
100
98
|
update_channel_preference_in_category(
|
|
101
99
|
channel: string,
|
|
@@ -104,12 +102,12 @@ interface Preferences {
|
|
|
104
102
|
args?: {
|
|
105
103
|
brand_id?: string;
|
|
106
104
|
}
|
|
107
|
-
):
|
|
105
|
+
): PreferencesResponse;
|
|
108
106
|
|
|
109
107
|
update_overall_channel_preference(
|
|
110
108
|
channel: string,
|
|
111
109
|
preference: ChannelLevelPreferenceOptions
|
|
112
|
-
):
|
|
110
|
+
): PreferencesResponse;
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
interface User {
|
package/src/preferences.js
CHANGED
|
@@ -154,7 +154,7 @@ class Preferences {
|
|
|
154
154
|
this._emitter.emit("preferences_error", response);
|
|
155
155
|
} else {
|
|
156
156
|
Object.assign(subcategory, response);
|
|
157
|
-
this._emitter.emit("preferences_updated");
|
|
157
|
+
this._emitter.emit("preferences_updated", this.data);
|
|
158
158
|
}
|
|
159
159
|
return response;
|
|
160
160
|
};
|
|
@@ -166,7 +166,7 @@ class Preferences {
|
|
|
166
166
|
this._emitter.emit("preferences_error", response);
|
|
167
167
|
} else {
|
|
168
168
|
await this.get_preferences(this._preference_args);
|
|
169
|
-
this._emitter.emit("preferences_updated");
|
|
169
|
+
this._emitter.emit("preferences_updated", this.data);
|
|
170
170
|
}
|
|
171
171
|
return response;
|
|
172
172
|
};
|
|
@@ -282,7 +282,7 @@ class Preferences {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
if (!data_updated) {
|
|
285
|
-
return;
|
|
285
|
+
return this.data;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
const opt_out_channels = [];
|
|
@@ -304,6 +304,8 @@ class Preferences {
|
|
|
304
304
|
category_data,
|
|
305
305
|
{ brand_id: args?.brand_id }
|
|
306
306
|
);
|
|
307
|
+
|
|
308
|
+
return this.data;
|
|
307
309
|
}
|
|
308
310
|
|
|
309
311
|
update_channel_preference_in_category(
|
|
@@ -391,7 +393,7 @@ class Preferences {
|
|
|
391
393
|
}
|
|
392
394
|
|
|
393
395
|
if (!data_updated) {
|
|
394
|
-
return;
|
|
396
|
+
return this.data;
|
|
395
397
|
}
|
|
396
398
|
|
|
397
399
|
const opt_out_channels = [];
|
|
@@ -413,6 +415,8 @@ class Preferences {
|
|
|
413
415
|
category_data,
|
|
414
416
|
{ brand_id: args?.brand_id }
|
|
415
417
|
);
|
|
418
|
+
|
|
419
|
+
return this.data;
|
|
416
420
|
}
|
|
417
421
|
|
|
418
422
|
update_overall_channel_preference(channel = "", preference = "") {
|
|
@@ -462,12 +466,14 @@ class Preferences {
|
|
|
462
466
|
}
|
|
463
467
|
|
|
464
468
|
if (!data_updated) {
|
|
465
|
-
return;
|
|
469
|
+
return this.data;
|
|
466
470
|
}
|
|
467
471
|
|
|
468
472
|
this._debounced_update_channel_preferences(channel_data.channel, {
|
|
469
473
|
channel_preferences: [channel_data],
|
|
470
474
|
});
|
|
475
|
+
|
|
476
|
+
return this.data;
|
|
471
477
|
}
|
|
472
478
|
}
|
|
473
479
|
|