@amityco/ts-sdk 7.1.0 → 7.1.1-15835b61.0
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/.env +26 -26
- package/dist/@types/core/events.d.ts +4 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +18 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +74 -0
- package/dist/@types/domains/notification.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +415 -45
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +398 -29
- package/dist/index.umd.js +4 -4
- package/dist/notificationTrayRepository/api/index.d.ts +3 -0
- package/dist/notificationTrayRepository/api/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/api/markNotificationItemsSeen.d.ts +16 -0
- package/dist/notificationTrayRepository/api/markNotificationItemsSeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/api/markNotificationTraySeen.d.ts +19 -0
- package/dist/notificationTrayRepository/api/markNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/events/index.d.ts +2 -0
- package/dist/notificationTrayRepository/events/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/events/onNotificationTraySeenUpdated.d.ts +17 -0
- package/dist/notificationTrayRepository/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
- package/dist/notificationTrayRepository/index.d.ts +4 -0
- package/dist/notificationTrayRepository/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/internalApi/getNotificationTraySeen.d.ts +30 -0
- package/dist/notificationTrayRepository/internalApi/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems.d.ts +12 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTraySeen.d.ts +21 -0
- package/dist/notificationTrayRepository/observers/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/index.d.ts +3 -0
- package/dist/notificationTrayRepository/observers/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
- package/dist/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/core/events.ts +5 -0
- package/src/@types/core/model.ts +6 -0
- package/src/@types/core/payload.ts +25 -0
- package/src/@types/domains/notification.ts +83 -0
- package/src/core/model/idResolvers.ts +3 -0
- package/src/core/model/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/notificationTrayRepository/api/index.ts +2 -0
- package/src/notificationTrayRepository/api/markNotificationItemsSeen.ts +59 -0
- package/src/notificationTrayRepository/api/markNotificationTraySeen.ts +65 -0
- package/src/notificationTrayRepository/events/index.ts +1 -0
- package/src/notificationTrayRepository/events/onNotificationTraySeenUpdated.ts +36 -0
- package/src/notificationTrayRepository/index.ts +3 -0
- package/src/notificationTrayRepository/internalApi/getNotificationTraySeen.ts +80 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +94 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems.ts +44 -0
- package/src/notificationTrayRepository/observers/getNotificationTraySeen.ts +43 -0
- package/src/notificationTrayRepository/observers/index.ts +2 -0
- package/src/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.ts +12 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/notificationTrayLinkedObject.ts +18 -0
package/dist/index.esm.js
CHANGED
|
@@ -527,6 +527,8 @@ const idResolvers = {
|
|
|
527
527
|
advertiser: ({ advertiserId }) => advertiserId,
|
|
528
528
|
pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
|
|
529
529
|
pinTarget: ({ targetId }) => targetId,
|
|
530
|
+
notificationTrayItem: ({ _id }) => _id,
|
|
531
|
+
notificationTraySeen: ({ userId }) => userId,
|
|
530
532
|
};
|
|
531
533
|
/**
|
|
532
534
|
* Retrieve the id resolver matching a domain name
|
|
@@ -578,6 +580,7 @@ const PAYLOAD2MODEL = {
|
|
|
578
580
|
advertisers: 'advertiser',
|
|
579
581
|
pinTargets: 'pinTarget',
|
|
580
582
|
pins: 'pin',
|
|
583
|
+
notificationTrayItems: 'notificationTrayItem',
|
|
581
584
|
};
|
|
582
585
|
/** hidden */
|
|
583
586
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -22085,6 +22088,62 @@ const pinnedPostLinkedObject = (pinnedPost) => {
|
|
|
22085
22088
|
} });
|
|
22086
22089
|
};
|
|
22087
22090
|
|
|
22091
|
+
/* begin_public_function
|
|
22092
|
+
id: notificationTrayItem.markSeen
|
|
22093
|
+
*/
|
|
22094
|
+
/**
|
|
22095
|
+
* ```js
|
|
22096
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
22097
|
+
* const updated = await NotificationTrayRepository.markNotificationItemsSeen()
|
|
22098
|
+
* ```
|
|
22099
|
+
*
|
|
22100
|
+
* Updates an {@link Amity.NotificationItemSeen}
|
|
22101
|
+
*
|
|
22102
|
+
* @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
|
|
22103
|
+
* @returns the updated {@link Amity.NotificationItemSeen} object
|
|
22104
|
+
*
|
|
22105
|
+
* @category NotificationItemSeen API
|
|
22106
|
+
* @async
|
|
22107
|
+
*/
|
|
22108
|
+
const markNotificationItemsSeen = async (patch) => {
|
|
22109
|
+
const client = getActiveClient();
|
|
22110
|
+
client.log('notificationTray/markNotificationItemsSeen', {});
|
|
22111
|
+
const { data: payload } = await client.http.put(`api/v1/notification-tray/items/seen`, {
|
|
22112
|
+
patch,
|
|
22113
|
+
});
|
|
22114
|
+
const updatedData = patch.trayItems
|
|
22115
|
+
.map(patchItem => {
|
|
22116
|
+
var _a;
|
|
22117
|
+
const cacheData = (_a = pullFromCache([
|
|
22118
|
+
'notificationTraySeen',
|
|
22119
|
+
'get',
|
|
22120
|
+
patchItem.id,
|
|
22121
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22122
|
+
if (!cacheData)
|
|
22123
|
+
return;
|
|
22124
|
+
const data = Object.assign(Object.assign({}, cacheData), payload);
|
|
22125
|
+
if (client.cache) {
|
|
22126
|
+
const cachedAt = Date.now();
|
|
22127
|
+
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
|
22128
|
+
}
|
|
22129
|
+
return data;
|
|
22130
|
+
})
|
|
22131
|
+
.filter(Boolean);
|
|
22132
|
+
fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
|
|
22133
|
+
};
|
|
22134
|
+
/* end_public_function */
|
|
22135
|
+
|
|
22136
|
+
const notificationTrayLinkedObject = (noti) => {
|
|
22137
|
+
return Object.assign(Object.assign({}, noti), { markRead: () => markNotificationItemsSeen({
|
|
22138
|
+
trayItems: [
|
|
22139
|
+
{
|
|
22140
|
+
id: noti._id,
|
|
22141
|
+
lastSeenAt: noti.lastSeenAt,
|
|
22142
|
+
},
|
|
22143
|
+
],
|
|
22144
|
+
}) });
|
|
22145
|
+
};
|
|
22146
|
+
|
|
22088
22147
|
const LinkedObject = {
|
|
22089
22148
|
ad: adLinkedObject,
|
|
22090
22149
|
comment: commentLinkedObject,
|
|
@@ -22098,6 +22157,7 @@ const LinkedObject = {
|
|
|
22098
22157
|
reactor: reactorLinkedObject,
|
|
22099
22158
|
channel: channelLinkedObject,
|
|
22100
22159
|
pinnedPost: pinnedPostLinkedObject,
|
|
22160
|
+
notificationTray: notificationTrayLinkedObject,
|
|
22101
22161
|
};
|
|
22102
22162
|
|
|
22103
22163
|
const getChannelMessagePreviewWithUser = (channel) => {
|
|
@@ -25868,7 +25928,7 @@ const getUserUnread = (callback) => {
|
|
|
25868
25928
|
};
|
|
25869
25929
|
};
|
|
25870
25930
|
|
|
25871
|
-
var index$
|
|
25931
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
25872
25932
|
__proto__: null,
|
|
25873
25933
|
getActiveClient: getActiveClient,
|
|
25874
25934
|
getActiveUser: getActiveUser,
|
|
@@ -27075,7 +27135,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27075
27135
|
};
|
|
27076
27136
|
/* end_public_function */
|
|
27077
27137
|
|
|
27078
|
-
var index$
|
|
27138
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
27079
27139
|
__proto__: null,
|
|
27080
27140
|
blockUser: blockUser,
|
|
27081
27141
|
unBlockUser: unBlockUser,
|
|
@@ -28090,9 +28150,9 @@ var AmityUserSearchMatchType;
|
|
|
28090
28150
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
28091
28151
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
28092
28152
|
|
|
28093
|
-
var index$
|
|
28153
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
28094
28154
|
__proto__: null,
|
|
28095
|
-
Relationship: index$
|
|
28155
|
+
Relationship: index$l,
|
|
28096
28156
|
getUserByIds: getUserByIds,
|
|
28097
28157
|
updateUser: updateUser,
|
|
28098
28158
|
flagUser: flagUser,
|
|
@@ -28356,7 +28416,7 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
28356
28416
|
};
|
|
28357
28417
|
/* end_public_function */
|
|
28358
28418
|
|
|
28359
|
-
var index$
|
|
28419
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
28360
28420
|
__proto__: null,
|
|
28361
28421
|
getFile: getFile,
|
|
28362
28422
|
uploadFile: uploadFile,
|
|
@@ -30168,7 +30228,7 @@ const getReactions = (params, callback, config) => {
|
|
|
30168
30228
|
};
|
|
30169
30229
|
/* end_public_function */
|
|
30170
30230
|
|
|
30171
|
-
var index$
|
|
30231
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
30172
30232
|
__proto__: null,
|
|
30173
30233
|
addReaction: addReaction,
|
|
30174
30234
|
removeReaction: removeReaction,
|
|
@@ -31984,7 +32044,7 @@ const getMessages = (params, callback, config) => {
|
|
|
31984
32044
|
};
|
|
31985
32045
|
/* end_public_function */
|
|
31986
32046
|
|
|
31987
|
-
var index$
|
|
32047
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
31988
32048
|
__proto__: null,
|
|
31989
32049
|
createMessage: createMessage,
|
|
31990
32050
|
updateMessage: updateMessage,
|
|
@@ -32510,7 +32570,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
32510
32570
|
};
|
|
32511
32571
|
/* end_public_function */
|
|
32512
32572
|
|
|
32513
|
-
var index$
|
|
32573
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
32514
32574
|
__proto__: null,
|
|
32515
32575
|
getSubChannelByIds: getSubChannels$1,
|
|
32516
32576
|
createSubChannel: createSubChannel,
|
|
@@ -33687,7 +33747,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
33687
33747
|
};
|
|
33688
33748
|
/* end_public_function */
|
|
33689
33749
|
|
|
33690
|
-
var index$
|
|
33750
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
33691
33751
|
__proto__: null,
|
|
33692
33752
|
addMembers: addMembers$1,
|
|
33693
33753
|
removeMembers: removeMembers$1,
|
|
@@ -33890,7 +33950,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
33890
33950
|
};
|
|
33891
33951
|
/* end_public_function */
|
|
33892
33952
|
|
|
33893
|
-
var index$
|
|
33953
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
33894
33954
|
__proto__: null,
|
|
33895
33955
|
addRole: addRole,
|
|
33896
33956
|
removeRole: removeRole,
|
|
@@ -33900,10 +33960,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
33900
33960
|
unmuteMembers: unmuteMembers
|
|
33901
33961
|
});
|
|
33902
33962
|
|
|
33903
|
-
var index$
|
|
33963
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
33904
33964
|
__proto__: null,
|
|
33905
|
-
Membership: index$
|
|
33906
|
-
Moderation: index$
|
|
33965
|
+
Membership: index$f,
|
|
33966
|
+
Moderation: index$e,
|
|
33907
33967
|
getChannelByIds: getChannelByIds$1,
|
|
33908
33968
|
createChannel: createChannel,
|
|
33909
33969
|
updateChannel: updateChannel,
|
|
@@ -35282,7 +35342,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
35282
35342
|
};
|
|
35283
35343
|
/* end_public_function */
|
|
35284
35344
|
|
|
35285
|
-
var index$
|
|
35345
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
35286
35346
|
__proto__: null,
|
|
35287
35347
|
addMembers: addMembers,
|
|
35288
35348
|
removeMembers: removeMembers,
|
|
@@ -36307,7 +36367,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
36307
36367
|
};
|
|
36308
36368
|
/* end_public_function */
|
|
36309
36369
|
|
|
36310
|
-
var index$
|
|
36370
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
36311
36371
|
__proto__: null,
|
|
36312
36372
|
addRoles: addRoles,
|
|
36313
36373
|
removeRoles: removeRoles,
|
|
@@ -36315,10 +36375,10 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
36315
36375
|
unbanMembers: unbanMembers
|
|
36316
36376
|
});
|
|
36317
36377
|
|
|
36318
|
-
var index$
|
|
36378
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
36319
36379
|
__proto__: null,
|
|
36320
|
-
Moderation: index$
|
|
36321
|
-
Membership: index$
|
|
36380
|
+
Moderation: index$b,
|
|
36381
|
+
Membership: index$c,
|
|
36322
36382
|
getCommunityByIds: getCommunities$1,
|
|
36323
36383
|
createCommunity: createCommunity,
|
|
36324
36384
|
updateCommunity: updateCommunity,
|
|
@@ -36551,7 +36611,7 @@ const getCategories = (params, callback, config) => {
|
|
|
36551
36611
|
};
|
|
36552
36612
|
/* end_public_function */
|
|
36553
36613
|
|
|
36554
|
-
var index$
|
|
36614
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
36555
36615
|
__proto__: null,
|
|
36556
36616
|
getCategory: getCategory,
|
|
36557
36617
|
getCategories: getCategories
|
|
@@ -36719,7 +36779,7 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
36719
36779
|
: undefined;
|
|
36720
36780
|
};
|
|
36721
36781
|
|
|
36722
|
-
var index$
|
|
36782
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
36723
36783
|
__proto__: null,
|
|
36724
36784
|
queryGlobalFeed: queryGlobalFeed,
|
|
36725
36785
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
@@ -38034,7 +38094,7 @@ const getComments = (params, callback, config) => {
|
|
|
38034
38094
|
};
|
|
38035
38095
|
/* end_public_function */
|
|
38036
38096
|
|
|
38037
|
-
var index$
|
|
38097
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
38038
38098
|
__proto__: null,
|
|
38039
38099
|
getCommentByIds: getCommentByIds,
|
|
38040
38100
|
createComment: createComment,
|
|
@@ -39041,7 +39101,7 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
39041
39101
|
};
|
|
39042
39102
|
};
|
|
39043
39103
|
|
|
39044
|
-
var index$
|
|
39104
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
39045
39105
|
__proto__: null,
|
|
39046
39106
|
getPostByIds: getPostByIds,
|
|
39047
39107
|
createPost: createPost,
|
|
@@ -39575,7 +39635,7 @@ const getStreams = (params, callback, config) => {
|
|
|
39575
39635
|
};
|
|
39576
39636
|
};
|
|
39577
39637
|
|
|
39578
|
-
var index$
|
|
39638
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
39579
39639
|
__proto__: null,
|
|
39580
39640
|
createStream: createStream,
|
|
39581
39641
|
updateStream: updateStream,
|
|
@@ -39862,7 +39922,7 @@ const getPoll = (pollId, callback) => {
|
|
|
39862
39922
|
};
|
|
39863
39923
|
/* end_public_function */
|
|
39864
39924
|
|
|
39865
|
-
var index$
|
|
39925
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
39866
39926
|
__proto__: null,
|
|
39867
39927
|
createPoll: createPoll,
|
|
39868
39928
|
closePoll: closePoll,
|
|
@@ -39873,7 +39933,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
39873
39933
|
getPoll: getPoll
|
|
39874
39934
|
});
|
|
39875
39935
|
|
|
39876
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
39936
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
39877
39937
|
/*
|
|
39878
39938
|
* The crypto algorithm used for importing key and signing string
|
|
39879
39939
|
*/
|
|
@@ -40233,7 +40293,7 @@ const getPlayer = async (parameters) => {
|
|
|
40233
40293
|
return video;
|
|
40234
40294
|
};
|
|
40235
40295
|
|
|
40236
|
-
var index$
|
|
40296
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
40237
40297
|
__proto__: null,
|
|
40238
40298
|
getPlayer: getPlayer
|
|
40239
40299
|
});
|
|
@@ -41406,7 +41466,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
41406
41466
|
};
|
|
41407
41467
|
};
|
|
41408
41468
|
|
|
41409
|
-
var index$
|
|
41469
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
41410
41470
|
__proto__: null,
|
|
41411
41471
|
createImageStory: createImageStory,
|
|
41412
41472
|
createVideoStory: createVideoStory,
|
|
@@ -41443,7 +41503,7 @@ const getNetworkAds = async () => {
|
|
|
41443
41503
|
};
|
|
41444
41504
|
};
|
|
41445
41505
|
|
|
41446
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
41506
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
41447
41507
|
__proto__: null,
|
|
41448
41508
|
getNetworkAds: getNetworkAds
|
|
41449
41509
|
});
|
|
@@ -41470,4 +41530,313 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
41470
41530
|
return { accessToken: data.accessToken };
|
|
41471
41531
|
};
|
|
41472
41532
|
|
|
41473
|
-
|
|
41533
|
+
/* begin_public_function
|
|
41534
|
+
id: notificationTray.getNotificationTraySeen
|
|
41535
|
+
*/
|
|
41536
|
+
/**
|
|
41537
|
+
* ```js
|
|
41538
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
41539
|
+
* const notificationTraySeen = await NotificationTrayRepository.getNotificationTraySeen()
|
|
41540
|
+
* ```
|
|
41541
|
+
*
|
|
41542
|
+
*
|
|
41543
|
+
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
41544
|
+
*
|
|
41545
|
+
* @category NotificationTray API
|
|
41546
|
+
* @async
|
|
41547
|
+
* */
|
|
41548
|
+
const getNotificationTraySeen$1 = async () => {
|
|
41549
|
+
const client = getActiveClient();
|
|
41550
|
+
client.log('notificationTray/getNotificationTraySeen', {});
|
|
41551
|
+
const { data: payload } = await client.http.get(`api/v1/notification-tray/tray/seen`);
|
|
41552
|
+
const cachedAt = client.cache && Date.now();
|
|
41553
|
+
if (client.cache) {
|
|
41554
|
+
const cacheKey = ['notificationTraySeen', 'get', client.userId];
|
|
41555
|
+
pushToCache(cacheKey, {
|
|
41556
|
+
userId: client.userId,
|
|
41557
|
+
lastTraySeenAt: payload.lastTraySeenAt,
|
|
41558
|
+
lastTrayOccuredAt: payload.lastTrayOccuredAt,
|
|
41559
|
+
});
|
|
41560
|
+
}
|
|
41561
|
+
return {
|
|
41562
|
+
data: {
|
|
41563
|
+
userId: client.userId,
|
|
41564
|
+
lastTraySeenAt: payload.lastTraySeenAt,
|
|
41565
|
+
lastTrayOccuredAt: payload.lastTrayOccuredAt,
|
|
41566
|
+
},
|
|
41567
|
+
cachedAt,
|
|
41568
|
+
};
|
|
41569
|
+
};
|
|
41570
|
+
/* end_public_function */
|
|
41571
|
+
/**
|
|
41572
|
+
* ```js
|
|
41573
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
41574
|
+
* const notificationTraySeen = await NotificationTrayRepository.getNotificationTraySeen.locally()
|
|
41575
|
+
* ```
|
|
41576
|
+
*
|
|
41577
|
+
* Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
|
|
41578
|
+
*
|
|
41579
|
+
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
41580
|
+
*
|
|
41581
|
+
* @category NotificationTray API
|
|
41582
|
+
* @async
|
|
41583
|
+
* */
|
|
41584
|
+
getNotificationTraySeen$1.locally = () => {
|
|
41585
|
+
var _a;
|
|
41586
|
+
const client = getActiveClient();
|
|
41587
|
+
client.log('notificationTray/getNotificationTraySeen.locally', {});
|
|
41588
|
+
if (!client.cache)
|
|
41589
|
+
return;
|
|
41590
|
+
const queryKey = ['notificationTraySeen', 'get'];
|
|
41591
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
41592
|
+
if (!(data === null || data === void 0 ? void 0 : data.notificationTraySeen))
|
|
41593
|
+
return;
|
|
41594
|
+
return { data: data.notificationTraySeen, cachedAt };
|
|
41595
|
+
};
|
|
41596
|
+
|
|
41597
|
+
/**
|
|
41598
|
+
* ```js
|
|
41599
|
+
* import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
|
|
41600
|
+
* const dispose = onNotificationTraySeenUpdated(data => {
|
|
41601
|
+
* // ...
|
|
41602
|
+
* })
|
|
41603
|
+
* ```
|
|
41604
|
+
*
|
|
41605
|
+
* Fired when an {@link Amity.NotificationTraySeen} has been updated
|
|
41606
|
+
*
|
|
41607
|
+
* @param callback The function to call when the event was fired
|
|
41608
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
41609
|
+
*
|
|
41610
|
+
* @category NotificationTraySeen Events
|
|
41611
|
+
*/
|
|
41612
|
+
const onNotificationTraySeenUpdated = (callback) => {
|
|
41613
|
+
const client = getActiveClient();
|
|
41614
|
+
const disposers = [
|
|
41615
|
+
createEventSubscriber(client, 'onNotificationTraySeenUpdated', 'local.notificationTraySeen.updated', payload => callback(payload)),
|
|
41616
|
+
];
|
|
41617
|
+
return () => {
|
|
41618
|
+
disposers.forEach(fn => fn());
|
|
41619
|
+
};
|
|
41620
|
+
};
|
|
41621
|
+
|
|
41622
|
+
/* begin_public_function
|
|
41623
|
+
id: notificationTraySeen.get
|
|
41624
|
+
*/
|
|
41625
|
+
/**
|
|
41626
|
+
* ```js
|
|
41627
|
+
* import { getNotificationTraySeen } from '@amityco/ts-sdk';
|
|
41628
|
+
*
|
|
41629
|
+
* let notificationTraySeen;
|
|
41630
|
+
*
|
|
41631
|
+
* const unsubscribe = getNotificationTraySeen(userId, response => {
|
|
41632
|
+
* notificationTraySeen = response.data;
|
|
41633
|
+
* });
|
|
41634
|
+
* ```
|
|
41635
|
+
*
|
|
41636
|
+
* Observe all mutation on a given {@link Amity.NotificationTraySeen}
|
|
41637
|
+
*
|
|
41638
|
+
* @param userId the ID of the user to observe
|
|
41639
|
+
* @param callback the function to call when new data are available
|
|
41640
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
|
|
41641
|
+
*
|
|
41642
|
+
* @category NotificationTraySeen Live Object
|
|
41643
|
+
*/
|
|
41644
|
+
const getNotificationTraySeen = (callback) => {
|
|
41645
|
+
const responder = (snapshot) => {
|
|
41646
|
+
const { data } = snapshot;
|
|
41647
|
+
callback(Object.assign(Object.assign({}, snapshot), { data }));
|
|
41648
|
+
};
|
|
41649
|
+
const { userId } = getActiveUser();
|
|
41650
|
+
return liveObject(userId, responder, 'userId', getNotificationTraySeen$1, [
|
|
41651
|
+
onNotificationTraySeenUpdated,
|
|
41652
|
+
]);
|
|
41653
|
+
};
|
|
41654
|
+
/* end_public_function */
|
|
41655
|
+
|
|
41656
|
+
/**
|
|
41657
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
41658
|
+
* TODO: check if querybyIds is supported
|
|
41659
|
+
*/
|
|
41660
|
+
class NotificationTrayItemsPaginationController extends PaginationController {
|
|
41661
|
+
async getRequest(queryParams, token) {
|
|
41662
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
41663
|
+
const options = token ? { token } : { limit };
|
|
41664
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/notification-tray`, {
|
|
41665
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
41666
|
+
});
|
|
41667
|
+
return queryResponse;
|
|
41668
|
+
}
|
|
41669
|
+
}
|
|
41670
|
+
|
|
41671
|
+
class NotificationTrayItemsQuerystreamController extends QueryStreamController {
|
|
41672
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
41673
|
+
super(query, cacheKey);
|
|
41674
|
+
this.notifyChange = notifyChange;
|
|
41675
|
+
this.preparePayload = preparePayload;
|
|
41676
|
+
}
|
|
41677
|
+
async saveToMainDB(response) {
|
|
41678
|
+
const processedPayload = await this.preparePayload(response);
|
|
41679
|
+
const client = getActiveClient();
|
|
41680
|
+
const cachedAt = client.cache && Date.now();
|
|
41681
|
+
if (client.cache) {
|
|
41682
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
41683
|
+
}
|
|
41684
|
+
}
|
|
41685
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
41686
|
+
var _a, _b;
|
|
41687
|
+
if (refresh) {
|
|
41688
|
+
pushToCache(this.cacheKey, {
|
|
41689
|
+
data: response.notificationTrayItems.map(getResolver('notificationTrayItem')),
|
|
41690
|
+
});
|
|
41691
|
+
}
|
|
41692
|
+
else {
|
|
41693
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41694
|
+
const notifications = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
41695
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
41696
|
+
...new Set([
|
|
41697
|
+
...notifications,
|
|
41698
|
+
...response.notificationTrayItems.map(getResolver('notificationTrayItem')),
|
|
41699
|
+
]),
|
|
41700
|
+
] }));
|
|
41701
|
+
}
|
|
41702
|
+
}
|
|
41703
|
+
}
|
|
41704
|
+
|
|
41705
|
+
const prepareNotificationTrayItemsPayload = (rawPayload) => {
|
|
41706
|
+
const users = rawPayload.users.map(convertRawUserToInternalUser);
|
|
41707
|
+
return Object.assign(Object.assign({}, rawPayload), { users });
|
|
41708
|
+
};
|
|
41709
|
+
|
|
41710
|
+
class NotificationTrayItemsLiveCollectionController extends LiveCollectionController {
|
|
41711
|
+
constructor(query, callback) {
|
|
41712
|
+
const queryStreamId = hash(query);
|
|
41713
|
+
const cacheKey = ['notificationTrayItem', 'collection', queryStreamId];
|
|
41714
|
+
const paginationController = new NotificationTrayItemsPaginationController(query);
|
|
41715
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
41716
|
+
this.query = query;
|
|
41717
|
+
this.queryStreamController = new NotificationTrayItemsQuerystreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareNotificationTrayItemsPayload);
|
|
41718
|
+
this.callback = callback.bind(this);
|
|
41719
|
+
this.loadPage({ initial: true });
|
|
41720
|
+
}
|
|
41721
|
+
setup() {
|
|
41722
|
+
var _a;
|
|
41723
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41724
|
+
if (!collection) {
|
|
41725
|
+
pushToCache(this.cacheKey, {
|
|
41726
|
+
data: [],
|
|
41727
|
+
params: {},
|
|
41728
|
+
});
|
|
41729
|
+
}
|
|
41730
|
+
}
|
|
41731
|
+
async persistModel(queryPayload) {
|
|
41732
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
41733
|
+
}
|
|
41734
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
41735
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
41736
|
+
}
|
|
41737
|
+
// eslint-disable-next-line class-methods-use-this
|
|
41738
|
+
startSubscription() {
|
|
41739
|
+
return [];
|
|
41740
|
+
}
|
|
41741
|
+
notifyChange({ origin, loading, error }) {
|
|
41742
|
+
var _a, _b;
|
|
41743
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41744
|
+
if (!collection)
|
|
41745
|
+
return;
|
|
41746
|
+
const data = (_b = collection.data
|
|
41747
|
+
.map(id => pullFromCache(['notificationTrayItem', 'get', id]))
|
|
41748
|
+
.filter(isNonNullable)
|
|
41749
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
|
|
41750
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
41751
|
+
return;
|
|
41752
|
+
this.callback({
|
|
41753
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
41754
|
+
data,
|
|
41755
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
41756
|
+
loading,
|
|
41757
|
+
error,
|
|
41758
|
+
});
|
|
41759
|
+
}
|
|
41760
|
+
}
|
|
41761
|
+
|
|
41762
|
+
/**
|
|
41763
|
+
* Get notification tray items for a notification tray page
|
|
41764
|
+
*
|
|
41765
|
+
* @param params the limit query parameters
|
|
41766
|
+
* @param callback the callback to be called when the notification tray items are updated
|
|
41767
|
+
* @returns items in the notification tray
|
|
41768
|
+
*
|
|
41769
|
+
* @category Notification tray items Live Collection
|
|
41770
|
+
*
|
|
41771
|
+
*/
|
|
41772
|
+
const getNotificationTrayItems = (params, callback, config) => {
|
|
41773
|
+
const { log, cache } = getActiveClient();
|
|
41774
|
+
if (!cache) {
|
|
41775
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
41776
|
+
}
|
|
41777
|
+
const timestamp = Date.now();
|
|
41778
|
+
log(`getNotificationTrayItems(tmpid: ${timestamp}) > listen`);
|
|
41779
|
+
const notiTrayItemsLiveCollection = new NotificationTrayItemsLiveCollectionController(params, callback);
|
|
41780
|
+
const disposers = notiTrayItemsLiveCollection.startSubscription();
|
|
41781
|
+
const cacheKey = notiTrayItemsLiveCollection.getCacheKey();
|
|
41782
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
41783
|
+
return () => {
|
|
41784
|
+
log(`getNotificationTrayItems(tmpid: ${timestamp}) > dispose`);
|
|
41785
|
+
disposers.forEach(fn => fn());
|
|
41786
|
+
};
|
|
41787
|
+
};
|
|
41788
|
+
|
|
41789
|
+
/* begin_public_function
|
|
41790
|
+
id: notificationTray.markSeen
|
|
41791
|
+
*/
|
|
41792
|
+
/**
|
|
41793
|
+
* ```js
|
|
41794
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
41795
|
+
* const updated = await NotificationTrayRepository.markNotificationTraySeen({
|
|
41796
|
+
* lastSeenAt: Amity.timestamp,
|
|
41797
|
+
* })
|
|
41798
|
+
* ```
|
|
41799
|
+
*
|
|
41800
|
+
* Updates an {@link Amity.NotificationTraySeen}
|
|
41801
|
+
*
|
|
41802
|
+
* @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
|
|
41803
|
+
* @param lastSeenAt The patch data to apply
|
|
41804
|
+
* @returns the updated {@link Amity.NotificationTraySeen} object
|
|
41805
|
+
*
|
|
41806
|
+
* @category Post API
|
|
41807
|
+
* @async
|
|
41808
|
+
*/
|
|
41809
|
+
const markNotificationTraySeen = async (lastSeenAt) => {
|
|
41810
|
+
var _a;
|
|
41811
|
+
const client = getActiveClient();
|
|
41812
|
+
client.log('notificationTray/markNotificationTraySeen', {});
|
|
41813
|
+
const { data: payload } = await client.http.put(`api/v1/notification-tray/tray/seen`, {
|
|
41814
|
+
lastSeenAt,
|
|
41815
|
+
});
|
|
41816
|
+
const cacheData = (_a = pullFromCache([
|
|
41817
|
+
'notificationTraySeen',
|
|
41818
|
+
'get',
|
|
41819
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
41820
|
+
const data = Object.assign({ userId: client.userId }, payload);
|
|
41821
|
+
const updateCacheData = Object.assign(Object.assign({}, cacheData), data);
|
|
41822
|
+
const cachedAt = client.cache && Date.now();
|
|
41823
|
+
if (client.cache)
|
|
41824
|
+
pushToCache(['notificationTraySeen', 'get', client.userId], updateCacheData, { cachedAt });
|
|
41825
|
+
fireEvent('local.notificationTraySeen.updated', data);
|
|
41826
|
+
return {
|
|
41827
|
+
data: payload,
|
|
41828
|
+
cachedAt,
|
|
41829
|
+
};
|
|
41830
|
+
};
|
|
41831
|
+
/* end_public_function */
|
|
41832
|
+
|
|
41833
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
41834
|
+
__proto__: null,
|
|
41835
|
+
getNotificationTraySeen: getNotificationTraySeen,
|
|
41836
|
+
getNotificationTrayItems: getNotificationTrayItems,
|
|
41837
|
+
markNotificationItemsSeen: markNotificationItemsSeen,
|
|
41838
|
+
markNotificationTraySeen: markNotificationTraySeen,
|
|
41839
|
+
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
41840
|
+
});
|
|
41841
|
+
|
|
41842
|
+
export { API_REGIONS, index$1 as AdRepository, index$9 as CategoryRepository, index$d as ChannelRepository, index$m as Client, index$7 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$a as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$8 as FeedRepository, FileAccessTypeEnum, index$j as FileRepository, FileType, index$3 as LiveStreamPlayer, MessageContentType, index$h as MessageRepository, index as NotificationTrayRepository, index$4 as PollRepository, PostContentType, index$6 as PostRepository, index$i as ReactionRepository, index$2 as StoryRepository, index$5 as StreamRepository, index$g as SubChannelRepository, SubscriptionLevels, index$k as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|