@amityco/ts-sdk 7.2.0 → 7.2.1-3663404.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 +45 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +1 -20
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +78 -0
- package/dist/@types/domains/notification.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +4 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- 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/fileRepository/api/index.d.ts +1 -0
- package/dist/fileRepository/api/index.d.ts.map +1 -1
- package/dist/fileRepository/api/updateAltText.d.ts +17 -0
- package/dist/fileRepository/api/updateAltText.d.ts.map +1 -0
- package/dist/fileRepository/api/uploadImage.d.ts +2 -1
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
- package/dist/index.cjs.js +526 -50
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +509 -34
- package/dist/index.umd.js +4 -4
- package/dist/notificationTray/api/index.d.ts +3 -0
- package/dist/notificationTray/api/index.d.ts.map +1 -0
- package/dist/notificationTray/api/markItemsSeen.d.ts +16 -0
- package/dist/notificationTray/api/markItemsSeen.d.ts.map +1 -0
- package/dist/notificationTray/api/markTraySeen.d.ts +19 -0
- package/dist/notificationTray/api/markTraySeen.d.ts.map +1 -0
- package/dist/notificationTray/events/index.d.ts +2 -0
- package/dist/notificationTray/events/index.d.ts.map +1 -0
- package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts +17 -0
- package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
- package/dist/notificationTray/index.d.ts +4 -0
- package/dist/notificationTray/index.d.ts.map +1 -0
- package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts +30 -0
- package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems.d.ts +12 -0
- package/dist/notificationTray/observers/getNotificationTrayItems.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTraySeen.d.ts +20 -0
- package/dist/notificationTray/observers/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTray/observers/index.d.ts +3 -0
- package/dist/notificationTray/observers/index.d.ts.map +1 -0
- package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
- package/dist/notificationTray/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/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +4 -0
- package/dist/utils/postTypePredicate.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 +52 -1
- package/src/@types/domains/file.ts +1 -21
- package/src/@types/domains/notification.ts +94 -0
- package/src/@types/domains/post.ts +4 -0
- package/src/@types/index.ts +1 -0
- package/src/core/model/idResolvers.ts +3 -0
- package/src/core/model/index.ts +2 -0
- package/src/fileRepository/api/index.ts +1 -0
- package/src/fileRepository/api/updateAltText.ts +39 -0
- package/src/fileRepository/api/uploadImage.ts +22 -3
- package/src/index.ts +2 -0
- package/src/notificationTray/api/index.ts +2 -0
- package/src/notificationTray/api/markItemsSeen.ts +62 -0
- package/src/notificationTray/api/markTraySeen.ts +65 -0
- package/src/notificationTray/events/index.ts +1 -0
- package/src/notificationTray/events/onNotificationTraySeenUpdated.ts +36 -0
- package/src/notificationTray/index.ts +3 -0
- package/src/notificationTray/internalApi/getNotificationTraySeen.ts +80 -0
- package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +96 -0
- package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
- package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
- package/src/notificationTray/observers/getNotificationTrayItems.ts +44 -0
- package/src/notificationTray/observers/getNotificationTraySeen.ts +60 -0
- package/src/notificationTray/observers/index.ts +2 -0
- package/src/notificationTray/utils/prepareNotificationTrayItemsPayload.ts +12 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/notificationTrayLinkedObject.ts +19 -0
- package/src/utils/linkedObject/postLinkedObject.ts +29 -0
- package/src/utils/postTypePredicate.ts +27 -0
package/dist/index.esm.js
CHANGED
|
@@ -106,6 +106,7 @@ const SECOND$1 = 1000;
|
|
|
106
106
|
const MINUTE = 60 * SECOND$1;
|
|
107
107
|
const HOUR = 60 * MINUTE;
|
|
108
108
|
const DAY = 24 * HOUR;
|
|
109
|
+
const WEEK = 7 * DAY;
|
|
109
110
|
const YEAR = 365 * DAY;
|
|
110
111
|
const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
|
|
111
112
|
|
|
@@ -528,6 +529,8 @@ const idResolvers = {
|
|
|
528
529
|
advertiser: ({ advertiserId }) => advertiserId,
|
|
529
530
|
pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
|
|
530
531
|
pinTarget: ({ targetId }) => targetId,
|
|
532
|
+
notificationTrayItem: ({ _id }) => _id,
|
|
533
|
+
notificationTraySeen: ({ userId }) => userId,
|
|
531
534
|
};
|
|
532
535
|
/**
|
|
533
536
|
* Retrieve the id resolver matching a domain name
|
|
@@ -579,6 +582,7 @@ const PAYLOAD2MODEL = {
|
|
|
579
582
|
advertisers: 'advertiser',
|
|
580
583
|
pinTargets: 'pinTarget',
|
|
581
584
|
pins: 'pin',
|
|
585
|
+
notificationTrayItems: 'notificationTrayItem',
|
|
582
586
|
};
|
|
583
587
|
/** hidden */
|
|
584
588
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -21622,6 +21626,26 @@ const commentLinkedObject = (comment) => {
|
|
|
21622
21626
|
} });
|
|
21623
21627
|
};
|
|
21624
21628
|
|
|
21629
|
+
function isAmityImagePost(post) {
|
|
21630
|
+
return !!(post.data &&
|
|
21631
|
+
typeof post.data !== 'string' &&
|
|
21632
|
+
'fileId' in post.data &&
|
|
21633
|
+
post.dataType === 'image');
|
|
21634
|
+
}
|
|
21635
|
+
function isAmityFilePost(post) {
|
|
21636
|
+
return !!(post.data &&
|
|
21637
|
+
typeof post.data !== 'string' &&
|
|
21638
|
+
'fileId' in post.data &&
|
|
21639
|
+
post.dataType === 'file');
|
|
21640
|
+
}
|
|
21641
|
+
function isAmityVideoPost(post) {
|
|
21642
|
+
return !!(post.data &&
|
|
21643
|
+
typeof post.data !== 'string' &&
|
|
21644
|
+
'videoFileId' in post.data &&
|
|
21645
|
+
'thumbnailFileId' in post.data &&
|
|
21646
|
+
post.dataType === 'video');
|
|
21647
|
+
}
|
|
21648
|
+
|
|
21625
21649
|
const postLinkedObject = (post) => {
|
|
21626
21650
|
return Object.assign(Object.assign({}, post), { analytics: {
|
|
21627
21651
|
markAsViewed: () => {
|
|
@@ -21650,6 +21674,30 @@ const postLinkedObject = (post) => {
|
|
|
21650
21674
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
21651
21675
|
return;
|
|
21652
21676
|
return userLinkedObject(cacheData.data);
|
|
21677
|
+
},
|
|
21678
|
+
getImageInfo() {
|
|
21679
|
+
var _a, _b;
|
|
21680
|
+
return isAmityImagePost(post)
|
|
21681
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
21682
|
+
: undefined;
|
|
21683
|
+
},
|
|
21684
|
+
getVideoInfo() {
|
|
21685
|
+
var _a, _b, _c;
|
|
21686
|
+
return isAmityVideoPost(post)
|
|
21687
|
+
? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
|
|
21688
|
+
: undefined;
|
|
21689
|
+
},
|
|
21690
|
+
getVideoThumbnailInfo() {
|
|
21691
|
+
var _a, _b;
|
|
21692
|
+
return isAmityVideoPost(post)
|
|
21693
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
21694
|
+
: undefined;
|
|
21695
|
+
},
|
|
21696
|
+
getFileInfo() {
|
|
21697
|
+
var _a, _b;
|
|
21698
|
+
return isAmityFilePost(post)
|
|
21699
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
21700
|
+
: undefined;
|
|
21653
21701
|
} });
|
|
21654
21702
|
};
|
|
21655
21703
|
|
|
@@ -22313,6 +22361,14 @@ const pinnedPostLinkedObject = (pinnedPost) => {
|
|
|
22313
22361
|
} });
|
|
22314
22362
|
};
|
|
22315
22363
|
|
|
22364
|
+
const notificationTrayLinkedObject = (noti) => {
|
|
22365
|
+
return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
|
|
22366
|
+
.map(({ _id }) => pullFromCache(['user', 'get', _id]))
|
|
22367
|
+
.filter(isNonNullable)
|
|
22368
|
+
.map(({ data }) => data)
|
|
22369
|
+
.map(user => userLinkedObject(user)) });
|
|
22370
|
+
};
|
|
22371
|
+
|
|
22316
22372
|
const LinkedObject = {
|
|
22317
22373
|
ad: adLinkedObject,
|
|
22318
22374
|
comment: commentLinkedObject,
|
|
@@ -22326,6 +22382,7 @@ const LinkedObject = {
|
|
|
22326
22382
|
reactor: reactorLinkedObject,
|
|
22327
22383
|
channel: channelLinkedObject,
|
|
22328
22384
|
pinnedPost: pinnedPostLinkedObject,
|
|
22385
|
+
notificationTray: notificationTrayLinkedObject,
|
|
22329
22386
|
};
|
|
22330
22387
|
|
|
22331
22388
|
const getChannelMessagePreviewWithUser = (channel) => {
|
|
@@ -26227,7 +26284,7 @@ const getUserUnread = (callback) => {
|
|
|
26227
26284
|
};
|
|
26228
26285
|
};
|
|
26229
26286
|
|
|
26230
|
-
var index$
|
|
26287
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
26231
26288
|
__proto__: null,
|
|
26232
26289
|
getActiveClient: getActiveClient,
|
|
26233
26290
|
getActiveUser: getActiveUser,
|
|
@@ -27434,7 +27491,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27434
27491
|
};
|
|
27435
27492
|
/* end_public_function */
|
|
27436
27493
|
|
|
27437
|
-
var index$
|
|
27494
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
27438
27495
|
__proto__: null,
|
|
27439
27496
|
blockUser: blockUser,
|
|
27440
27497
|
unBlockUser: unBlockUser,
|
|
@@ -28449,9 +28506,9 @@ var AmityUserSearchMatchType;
|
|
|
28449
28506
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
28450
28507
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
28451
28508
|
|
|
28452
|
-
var index$
|
|
28509
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
28453
28510
|
__proto__: null,
|
|
28454
|
-
Relationship: index$
|
|
28511
|
+
Relationship: index$l,
|
|
28455
28512
|
getUserByIds: getUserByIds,
|
|
28456
28513
|
updateUser: updateUser,
|
|
28457
28514
|
flagUser: flagUser,
|
|
@@ -28680,20 +28737,33 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
28680
28737
|
*
|
|
28681
28738
|
* @param formData The data necessary to create a new {@link Amity.File<'image'>}
|
|
28682
28739
|
* @param onProgress The callback to track the upload progress
|
|
28740
|
+
* @param altText The alt text for the image
|
|
28683
28741
|
* @returns The newly created {@link Amity.File<'image'>}
|
|
28684
28742
|
*
|
|
28685
28743
|
* @category File API
|
|
28686
28744
|
* @async
|
|
28687
28745
|
*/
|
|
28688
|
-
const uploadImage = async (formData, onProgress) => {
|
|
28746
|
+
const uploadImage = async (formData, onProgress, altText) => {
|
|
28689
28747
|
const client = getActiveClient();
|
|
28690
28748
|
client.log('file/uploadImage', formData);
|
|
28691
28749
|
const files = formData.getAll('files');
|
|
28692
|
-
if (
|
|
28693
|
-
|
|
28750
|
+
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
28751
|
+
console.warn('Deprecation Warning: `files` is deprecated, please use `file` instead.');
|
|
28752
|
+
formData.append('preferredFilename', files[0].name);
|
|
28753
|
+
}
|
|
28754
|
+
else {
|
|
28755
|
+
const file = formData.get('file');
|
|
28756
|
+
if (!file) {
|
|
28757
|
+
throw new Error('The formData object must have a `file` or `files` key');
|
|
28758
|
+
}
|
|
28759
|
+
formData.append('preferredFilename', file.name);
|
|
28760
|
+
// alt is for single image
|
|
28761
|
+
if (altText) {
|
|
28762
|
+
formData.append('altText', altText);
|
|
28763
|
+
}
|
|
28764
|
+
}
|
|
28694
28765
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
28695
28766
|
formData.append('accessType', accessType);
|
|
28696
|
-
formData.append('preferredFilename', files[0].name);
|
|
28697
28767
|
const headers = 'getHeaders' in formData
|
|
28698
28768
|
? formData.getHeaders()
|
|
28699
28769
|
: { 'content-type': 'multipart/form-data' };
|
|
@@ -28715,14 +28785,46 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
28715
28785
|
};
|
|
28716
28786
|
/* end_public_function */
|
|
28717
28787
|
|
|
28718
|
-
|
|
28788
|
+
/* begin_public_function
|
|
28789
|
+
id: file.update.altText
|
|
28790
|
+
*/
|
|
28791
|
+
/**
|
|
28792
|
+
* ```js
|
|
28793
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
28794
|
+
* const updated = await FileRepository.updateAltText(fileId, altText)
|
|
28795
|
+
* ```
|
|
28796
|
+
*
|
|
28797
|
+
* Updates an {@link Amity.File<'image'>['altText']}.
|
|
28798
|
+
*
|
|
28799
|
+
* @param fileId The ID of the {@link Amity.File<'image'>} to edit
|
|
28800
|
+
* @param altText The new alt text for the {@link Amity.File<'image'>}
|
|
28801
|
+
* @returns the updated {@link Amity.File<'image'>} object
|
|
28802
|
+
*
|
|
28803
|
+
* @category File API
|
|
28804
|
+
* @async
|
|
28805
|
+
*/
|
|
28806
|
+
const updateAltText = async (fileId, altText) => {
|
|
28807
|
+
const client = getActiveClient();
|
|
28808
|
+
client.log('file/updateAltText', altText);
|
|
28809
|
+
const { data } = await client.http.put(`/api/v3/files/${fileId}`, {
|
|
28810
|
+
altText,
|
|
28811
|
+
});
|
|
28812
|
+
const cachedAt = client.cache && Date.now();
|
|
28813
|
+
if (client.cache)
|
|
28814
|
+
ingestInCache({ files: [data] }, { cachedAt });
|
|
28815
|
+
return true;
|
|
28816
|
+
};
|
|
28817
|
+
/* end_public_function */
|
|
28818
|
+
|
|
28819
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
28719
28820
|
__proto__: null,
|
|
28720
28821
|
getFile: getFile,
|
|
28721
28822
|
uploadFile: uploadFile,
|
|
28722
28823
|
deleteFile: deleteFile,
|
|
28723
28824
|
fileUrlWithSize: fileUrlWithSize,
|
|
28724
28825
|
uploadVideo: uploadVideo,
|
|
28725
|
-
uploadImage: uploadImage
|
|
28826
|
+
uploadImage: uploadImage,
|
|
28827
|
+
updateAltText: updateAltText
|
|
28726
28828
|
});
|
|
28727
28829
|
|
|
28728
28830
|
/**
|
|
@@ -30582,7 +30684,7 @@ const getReactions = (params, callback, config) => {
|
|
|
30582
30684
|
};
|
|
30583
30685
|
/* end_public_function */
|
|
30584
30686
|
|
|
30585
|
-
var index$
|
|
30687
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
30586
30688
|
__proto__: null,
|
|
30587
30689
|
addReaction: addReaction,
|
|
30588
30690
|
removeReaction: removeReaction,
|
|
@@ -32398,7 +32500,7 @@ const getMessages = (params, callback, config) => {
|
|
|
32398
32500
|
};
|
|
32399
32501
|
/* end_public_function */
|
|
32400
32502
|
|
|
32401
|
-
var index$
|
|
32503
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
32402
32504
|
__proto__: null,
|
|
32403
32505
|
createMessage: createMessage,
|
|
32404
32506
|
updateMessage: updateMessage,
|
|
@@ -32924,7 +33026,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
32924
33026
|
};
|
|
32925
33027
|
/* end_public_function */
|
|
32926
33028
|
|
|
32927
|
-
var index$
|
|
33029
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
32928
33030
|
__proto__: null,
|
|
32929
33031
|
getSubChannelByIds: getSubChannels$1,
|
|
32930
33032
|
createSubChannel: createSubChannel,
|
|
@@ -34238,7 +34340,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
34238
34340
|
};
|
|
34239
34341
|
/* end_public_function */
|
|
34240
34342
|
|
|
34241
|
-
var index$
|
|
34343
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
34242
34344
|
__proto__: null,
|
|
34243
34345
|
addMembers: addMembers$1,
|
|
34244
34346
|
removeMembers: removeMembers$1,
|
|
@@ -34441,7 +34543,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
34441
34543
|
};
|
|
34442
34544
|
/* end_public_function */
|
|
34443
34545
|
|
|
34444
|
-
var index$
|
|
34546
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
34445
34547
|
__proto__: null,
|
|
34446
34548
|
addRole: addRole,
|
|
34447
34549
|
removeRole: removeRole,
|
|
@@ -34451,10 +34553,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
34451
34553
|
unmuteMembers: unmuteMembers
|
|
34452
34554
|
});
|
|
34453
34555
|
|
|
34454
|
-
var index$
|
|
34556
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
34455
34557
|
__proto__: null,
|
|
34456
|
-
Membership: index$
|
|
34457
|
-
Moderation: index$
|
|
34558
|
+
Membership: index$f,
|
|
34559
|
+
Moderation: index$e,
|
|
34458
34560
|
getChannelByIds: getChannelByIds$1,
|
|
34459
34561
|
createChannel: createChannel,
|
|
34460
34562
|
updateChannel: updateChannel,
|
|
@@ -35834,7 +35936,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
35834
35936
|
};
|
|
35835
35937
|
/* end_public_function */
|
|
35836
35938
|
|
|
35837
|
-
var index$
|
|
35939
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
35838
35940
|
__proto__: null,
|
|
35839
35941
|
addMembers: addMembers,
|
|
35840
35942
|
removeMembers: removeMembers,
|
|
@@ -36859,7 +36961,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
36859
36961
|
};
|
|
36860
36962
|
/* end_public_function */
|
|
36861
36963
|
|
|
36862
|
-
var index$
|
|
36964
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
36863
36965
|
__proto__: null,
|
|
36864
36966
|
addRoles: addRoles,
|
|
36865
36967
|
removeRoles: removeRoles,
|
|
@@ -36867,10 +36969,10 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
36867
36969
|
unbanMembers: unbanMembers
|
|
36868
36970
|
});
|
|
36869
36971
|
|
|
36870
|
-
var index$
|
|
36972
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
36871
36973
|
__proto__: null,
|
|
36872
|
-
Moderation: index$
|
|
36873
|
-
Membership: index$
|
|
36974
|
+
Moderation: index$b,
|
|
36975
|
+
Membership: index$c,
|
|
36874
36976
|
getCommunityByIds: getCommunities$1,
|
|
36875
36977
|
createCommunity: createCommunity,
|
|
36876
36978
|
updateCommunity: updateCommunity,
|
|
@@ -37103,7 +37205,7 @@ const getCategories = (params, callback, config) => {
|
|
|
37103
37205
|
};
|
|
37104
37206
|
/* end_public_function */
|
|
37105
37207
|
|
|
37106
|
-
var index$
|
|
37208
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
37107
37209
|
__proto__: null,
|
|
37108
37210
|
getCategory: getCategory,
|
|
37109
37211
|
getCategories: getCategories
|
|
@@ -37271,7 +37373,7 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
37271
37373
|
: undefined;
|
|
37272
37374
|
};
|
|
37273
37375
|
|
|
37274
|
-
var index$
|
|
37376
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
37275
37377
|
__proto__: null,
|
|
37276
37378
|
queryGlobalFeed: queryGlobalFeed,
|
|
37277
37379
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
@@ -38586,7 +38688,7 @@ const getComments = (params, callback, config) => {
|
|
|
38586
38688
|
};
|
|
38587
38689
|
/* end_public_function */
|
|
38588
38690
|
|
|
38589
|
-
var index$
|
|
38691
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
38590
38692
|
__proto__: null,
|
|
38591
38693
|
getCommentByIds: getCommentByIds,
|
|
38592
38694
|
createComment: createComment,
|
|
@@ -39593,7 +39695,7 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
39593
39695
|
};
|
|
39594
39696
|
};
|
|
39595
39697
|
|
|
39596
|
-
var index$
|
|
39698
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
39597
39699
|
__proto__: null,
|
|
39598
39700
|
getPostByIds: getPostByIds,
|
|
39599
39701
|
createPost: createPost,
|
|
@@ -40127,7 +40229,7 @@ const getStreams = (params, callback, config) => {
|
|
|
40127
40229
|
};
|
|
40128
40230
|
};
|
|
40129
40231
|
|
|
40130
|
-
var index$
|
|
40232
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
40131
40233
|
__proto__: null,
|
|
40132
40234
|
createStream: createStream,
|
|
40133
40235
|
updateStream: updateStream,
|
|
@@ -40414,7 +40516,7 @@ const getPoll = (pollId, callback) => {
|
|
|
40414
40516
|
};
|
|
40415
40517
|
/* end_public_function */
|
|
40416
40518
|
|
|
40417
|
-
var index$
|
|
40519
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
40418
40520
|
__proto__: null,
|
|
40419
40521
|
createPoll: createPoll,
|
|
40420
40522
|
closePoll: closePoll,
|
|
@@ -40425,7 +40527,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
40425
40527
|
getPoll: getPoll
|
|
40426
40528
|
});
|
|
40427
40529
|
|
|
40428
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
40530
|
+
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-----";
|
|
40429
40531
|
/*
|
|
40430
40532
|
* The crypto algorithm used for importing key and signing string
|
|
40431
40533
|
*/
|
|
@@ -40785,7 +40887,7 @@ const getPlayer = async (parameters) => {
|
|
|
40785
40887
|
return video;
|
|
40786
40888
|
};
|
|
40787
40889
|
|
|
40788
|
-
var index$
|
|
40890
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
40789
40891
|
__proto__: null,
|
|
40790
40892
|
getPlayer: getPlayer
|
|
40791
40893
|
});
|
|
@@ -41958,7 +42060,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
41958
42060
|
};
|
|
41959
42061
|
};
|
|
41960
42062
|
|
|
41961
|
-
var index$
|
|
42063
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
41962
42064
|
__proto__: null,
|
|
41963
42065
|
createImageStory: createImageStory,
|
|
41964
42066
|
createVideoStory: createVideoStory,
|
|
@@ -41995,7 +42097,7 @@ const getNetworkAds = async () => {
|
|
|
41995
42097
|
};
|
|
41996
42098
|
};
|
|
41997
42099
|
|
|
41998
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
42100
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
41999
42101
|
__proto__: null,
|
|
42000
42102
|
getNetworkAds: getNetworkAds
|
|
42001
42103
|
});
|
|
@@ -42022,4 +42124,377 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
42022
42124
|
return { accessToken: data.accessToken };
|
|
42023
42125
|
};
|
|
42024
42126
|
|
|
42025
|
-
|
|
42127
|
+
/* begin_public_function
|
|
42128
|
+
id: notificationTray.getNotificationTraySeen
|
|
42129
|
+
*/
|
|
42130
|
+
/**
|
|
42131
|
+
* ```js
|
|
42132
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
42133
|
+
* const notificationTraySeen = await notificationTray.getNotificationTraySeen()
|
|
42134
|
+
* ```
|
|
42135
|
+
*
|
|
42136
|
+
*
|
|
42137
|
+
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
42138
|
+
*
|
|
42139
|
+
* @category NotificationTray API
|
|
42140
|
+
* @async
|
|
42141
|
+
* */
|
|
42142
|
+
const getNotificationTraySeen$1 = async () => {
|
|
42143
|
+
const client = getActiveClient();
|
|
42144
|
+
client.log('notificationTray/getNotificationTraySeen', {});
|
|
42145
|
+
const { data: payload } = await client.http.get(`api/v1/notification-tray/tray/seen`);
|
|
42146
|
+
const cachedAt = client.cache && Date.now();
|
|
42147
|
+
if (client.cache) {
|
|
42148
|
+
const cacheKey = ['notificationTraySeen', 'get', client.userId];
|
|
42149
|
+
pushToCache(cacheKey, {
|
|
42150
|
+
userId: client.userId,
|
|
42151
|
+
lastTraySeenAt: payload.lastTraySeenAt,
|
|
42152
|
+
lastTrayOccuredAt: payload.lastTrayOccurredAt,
|
|
42153
|
+
});
|
|
42154
|
+
}
|
|
42155
|
+
return {
|
|
42156
|
+
data: {
|
|
42157
|
+
userId: client.userId,
|
|
42158
|
+
lastTraySeenAt: payload.lastTraySeenAt,
|
|
42159
|
+
lastTrayOccurredAt: payload.lastTrayOccurredAt,
|
|
42160
|
+
isSeen: payload.lastTraySeenAt > payload.lastTrayOccurredAt,
|
|
42161
|
+
},
|
|
42162
|
+
cachedAt,
|
|
42163
|
+
};
|
|
42164
|
+
};
|
|
42165
|
+
/* end_public_function */
|
|
42166
|
+
/**
|
|
42167
|
+
* ```js
|
|
42168
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
42169
|
+
* const notificationTraySeen = await notificationTray.getNotificationTraySeen.locally()
|
|
42170
|
+
* ```
|
|
42171
|
+
*
|
|
42172
|
+
* Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
|
|
42173
|
+
*
|
|
42174
|
+
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
42175
|
+
*
|
|
42176
|
+
* @category NotificationTray API
|
|
42177
|
+
* @async
|
|
42178
|
+
* */
|
|
42179
|
+
getNotificationTraySeen$1.locally = () => {
|
|
42180
|
+
var _a;
|
|
42181
|
+
const client = getActiveClient();
|
|
42182
|
+
client.log('notificationTray/getNotificationTraySeen.locally', {});
|
|
42183
|
+
if (!client.cache)
|
|
42184
|
+
return;
|
|
42185
|
+
const queryKey = ['notificationTraySeen', 'get'];
|
|
42186
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
42187
|
+
if (!data)
|
|
42188
|
+
return;
|
|
42189
|
+
return { data, cachedAt };
|
|
42190
|
+
};
|
|
42191
|
+
|
|
42192
|
+
/**
|
|
42193
|
+
* ```js
|
|
42194
|
+
* import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
|
|
42195
|
+
* const dispose = onNotificationTraySeenUpdated(data => {
|
|
42196
|
+
* // ...
|
|
42197
|
+
* })
|
|
42198
|
+
* ```
|
|
42199
|
+
*
|
|
42200
|
+
* Fired when an {@link Amity.NotificationTraySeen} has been updated
|
|
42201
|
+
*
|
|
42202
|
+
* @param callback The function to call when the event was fired
|
|
42203
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
42204
|
+
*
|
|
42205
|
+
* @category NotificationTraySeen Events
|
|
42206
|
+
*/
|
|
42207
|
+
const onNotificationTraySeenUpdated = (callback) => {
|
|
42208
|
+
const client = getActiveClient();
|
|
42209
|
+
const disposers = [
|
|
42210
|
+
createEventSubscriber(client, 'onNotificationTraySeenUpdated', 'local.notificationTraySeen.updated', payload => callback(payload)),
|
|
42211
|
+
];
|
|
42212
|
+
return () => {
|
|
42213
|
+
disposers.forEach(fn => fn());
|
|
42214
|
+
};
|
|
42215
|
+
};
|
|
42216
|
+
|
|
42217
|
+
/* begin_public_function
|
|
42218
|
+
id: notificationTray.getNotificationTraySeen
|
|
42219
|
+
*/
|
|
42220
|
+
/**
|
|
42221
|
+
* ```js
|
|
42222
|
+
* import { notificationTray } from '@amityco/ts-sdk';
|
|
42223
|
+
*
|
|
42224
|
+
* let notificationTraySeen;
|
|
42225
|
+
*
|
|
42226
|
+
* const unsubscribe = getNotificationTraySeen(response => {
|
|
42227
|
+
* notificationTraySeen = response.data;
|
|
42228
|
+
* });
|
|
42229
|
+
* ```
|
|
42230
|
+
*
|
|
42231
|
+
* Observe all mutation on a given {@link Amity.NotificationTraySeen}
|
|
42232
|
+
*
|
|
42233
|
+
* @param callback the function to call when new data are available
|
|
42234
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
|
|
42235
|
+
*
|
|
42236
|
+
* @category NotificationTraySeen Live Object
|
|
42237
|
+
*/
|
|
42238
|
+
const getNotificationTraySeen = (callback) => {
|
|
42239
|
+
const { userId } = getActiveUser();
|
|
42240
|
+
return liveObject(userId, callback, 'userId', getNotificationTraySeen$1, [onNotificationTraySeenUpdated], {
|
|
42241
|
+
callbackDataSelector: (data) => {
|
|
42242
|
+
let isSeen = true;
|
|
42243
|
+
if (data === null || data === void 0 ? void 0 : data.lastTrayOccurredAt) {
|
|
42244
|
+
if (!data.lastTraySeenAt) {
|
|
42245
|
+
isSeen = false;
|
|
42246
|
+
}
|
|
42247
|
+
else {
|
|
42248
|
+
isSeen =
|
|
42249
|
+
convertDateStringToTimestamp(data.lastTraySeenAt) >
|
|
42250
|
+
convertDateStringToTimestamp(data.lastTrayOccurredAt);
|
|
42251
|
+
}
|
|
42252
|
+
}
|
|
42253
|
+
return {
|
|
42254
|
+
lastTrayOccurredAt: data === null || data === void 0 ? void 0 : data.lastTrayOccurredAt,
|
|
42255
|
+
lastTraySeenAt: data === null || data === void 0 ? void 0 : data.lastTraySeenAt,
|
|
42256
|
+
isSeen,
|
|
42257
|
+
};
|
|
42258
|
+
},
|
|
42259
|
+
});
|
|
42260
|
+
};
|
|
42261
|
+
/* end_public_function */
|
|
42262
|
+
|
|
42263
|
+
/**
|
|
42264
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
42265
|
+
* TODO: check if querybyIds is supported
|
|
42266
|
+
*/
|
|
42267
|
+
class NotificationTrayItemsPaginationController extends PaginationController {
|
|
42268
|
+
async getRequest(queryParams, token) {
|
|
42269
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
42270
|
+
const options = token ? { token } : { limit };
|
|
42271
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/notification-tray`, {
|
|
42272
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
42273
|
+
});
|
|
42274
|
+
return queryResponse;
|
|
42275
|
+
}
|
|
42276
|
+
}
|
|
42277
|
+
|
|
42278
|
+
class NotificationTrayItemsQuerystreamController extends QueryStreamController {
|
|
42279
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
42280
|
+
super(query, cacheKey);
|
|
42281
|
+
this.notifyChange = notifyChange;
|
|
42282
|
+
this.preparePayload = preparePayload;
|
|
42283
|
+
}
|
|
42284
|
+
async saveToMainDB(response) {
|
|
42285
|
+
const processedPayload = await this.preparePayload(response);
|
|
42286
|
+
const client = getActiveClient();
|
|
42287
|
+
const cachedAt = client.cache && Date.now();
|
|
42288
|
+
if (client.cache) {
|
|
42289
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
42290
|
+
}
|
|
42291
|
+
}
|
|
42292
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
42293
|
+
var _a, _b;
|
|
42294
|
+
if (refresh) {
|
|
42295
|
+
pushToCache(this.cacheKey, {
|
|
42296
|
+
data: response.notificationTrayItems.map(getResolver('notificationTrayItem')),
|
|
42297
|
+
});
|
|
42298
|
+
}
|
|
42299
|
+
else {
|
|
42300
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42301
|
+
const notifications = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
42302
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
42303
|
+
...new Set([
|
|
42304
|
+
...notifications,
|
|
42305
|
+
...response.notificationTrayItems.map(getResolver('notificationTrayItem')),
|
|
42306
|
+
]),
|
|
42307
|
+
] }));
|
|
42308
|
+
}
|
|
42309
|
+
}
|
|
42310
|
+
}
|
|
42311
|
+
|
|
42312
|
+
const prepareNotificationTrayItemsPayload = (rawPayload) => {
|
|
42313
|
+
const users = rawPayload.users.map(convertRawUserToInternalUser);
|
|
42314
|
+
return Object.assign(Object.assign({}, rawPayload), { users });
|
|
42315
|
+
};
|
|
42316
|
+
|
|
42317
|
+
class NotificationTrayItemsLiveCollectionController extends LiveCollectionController {
|
|
42318
|
+
constructor(query, callback) {
|
|
42319
|
+
const queryStreamId = hash(query);
|
|
42320
|
+
const cacheKey = ['notificationTrayItem', 'collection', queryStreamId];
|
|
42321
|
+
const paginationController = new NotificationTrayItemsPaginationController(query);
|
|
42322
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
42323
|
+
this.query = query;
|
|
42324
|
+
this.queryStreamController = new NotificationTrayItemsQuerystreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareNotificationTrayItemsPayload);
|
|
42325
|
+
this.callback = callback.bind(this);
|
|
42326
|
+
this.loadPage({ initial: true });
|
|
42327
|
+
}
|
|
42328
|
+
setup() {
|
|
42329
|
+
var _a;
|
|
42330
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42331
|
+
if (!collection) {
|
|
42332
|
+
pushToCache(this.cacheKey, {
|
|
42333
|
+
data: [],
|
|
42334
|
+
params: {},
|
|
42335
|
+
});
|
|
42336
|
+
}
|
|
42337
|
+
}
|
|
42338
|
+
async persistModel(queryPayload) {
|
|
42339
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
42340
|
+
}
|
|
42341
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
42342
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
42343
|
+
}
|
|
42344
|
+
// eslint-disable-next-line class-methods-use-this
|
|
42345
|
+
startSubscription() {
|
|
42346
|
+
return [];
|
|
42347
|
+
}
|
|
42348
|
+
notifyChange({ origin, loading, error }) {
|
|
42349
|
+
var _a, _b;
|
|
42350
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42351
|
+
if (!collection)
|
|
42352
|
+
return;
|
|
42353
|
+
const data = ((_b = collection.data
|
|
42354
|
+
.map(id => pullFromCache(['notificationTrayItem', 'get', id]))
|
|
42355
|
+
.filter(isNonNullable)
|
|
42356
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.notificationTray);
|
|
42357
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
42358
|
+
return;
|
|
42359
|
+
this.callback({
|
|
42360
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
42361
|
+
data,
|
|
42362
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
42363
|
+
loading,
|
|
42364
|
+
error,
|
|
42365
|
+
});
|
|
42366
|
+
}
|
|
42367
|
+
}
|
|
42368
|
+
|
|
42369
|
+
/**
|
|
42370
|
+
* Get notification tray items for a notification tray page
|
|
42371
|
+
*
|
|
42372
|
+
* @param params the limit query parameters
|
|
42373
|
+
* @param callback the callback to be called when the notification tray items are updated
|
|
42374
|
+
* @returns items in the notification tray
|
|
42375
|
+
*
|
|
42376
|
+
* @category Notification tray items Live Collection
|
|
42377
|
+
*
|
|
42378
|
+
*/
|
|
42379
|
+
const getNotificationTrayItems = (params, callback, config) => {
|
|
42380
|
+
const { log, cache } = getActiveClient();
|
|
42381
|
+
if (!cache) {
|
|
42382
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
42383
|
+
}
|
|
42384
|
+
const timestamp = Date.now();
|
|
42385
|
+
log(`getNotificationTrayItems(tmpid: ${timestamp}) > listen`);
|
|
42386
|
+
const notiTrayItemsLiveCollection = new NotificationTrayItemsLiveCollectionController(params, callback);
|
|
42387
|
+
const disposers = notiTrayItemsLiveCollection.startSubscription();
|
|
42388
|
+
const cacheKey = notiTrayItemsLiveCollection.getCacheKey();
|
|
42389
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
42390
|
+
return () => {
|
|
42391
|
+
log(`getNotificationTrayItems(tmpid: ${timestamp}) > dispose`);
|
|
42392
|
+
disposers.forEach(fn => fn());
|
|
42393
|
+
};
|
|
42394
|
+
};
|
|
42395
|
+
|
|
42396
|
+
/* begin_public_function
|
|
42397
|
+
id: notificationTrayItem.markSeen
|
|
42398
|
+
*/
|
|
42399
|
+
/**
|
|
42400
|
+
* ```js
|
|
42401
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
42402
|
+
* const updated = await notificationTray.markItemsSeen()
|
|
42403
|
+
* ```
|
|
42404
|
+
*
|
|
42405
|
+
* Updates an {@link Amity.NotificationItemSeen}
|
|
42406
|
+
*
|
|
42407
|
+
* @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
|
|
42408
|
+
* @returns the updated {@link Amity.NotificationItemSeen} object
|
|
42409
|
+
*
|
|
42410
|
+
* @category NotificationItemSeen API
|
|
42411
|
+
* @async
|
|
42412
|
+
*/
|
|
42413
|
+
const markItemsSeen = async (trayItems) => {
|
|
42414
|
+
const client = getActiveClient();
|
|
42415
|
+
client.log('notificationTray/markItemsSeen', {});
|
|
42416
|
+
const { data: payload } = await client.http.post(`api/v1/notification-tray/items/seen`, {
|
|
42417
|
+
trayItems: trayItems.map(item => ({
|
|
42418
|
+
id: item.id,
|
|
42419
|
+
lastSeenAt: item.lastSeenAt,
|
|
42420
|
+
})),
|
|
42421
|
+
});
|
|
42422
|
+
const updatedData = trayItems
|
|
42423
|
+
.map(patchItem => {
|
|
42424
|
+
var _a;
|
|
42425
|
+
const cacheData = (_a = pullFromCache([
|
|
42426
|
+
'notificationTrayItem',
|
|
42427
|
+
'get',
|
|
42428
|
+
patchItem.id,
|
|
42429
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
42430
|
+
if (!cacheData)
|
|
42431
|
+
return;
|
|
42432
|
+
const data = Object.assign(Object.assign({}, cacheData), payload);
|
|
42433
|
+
if (client.cache) {
|
|
42434
|
+
const cachedAt = Date.now();
|
|
42435
|
+
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
|
42436
|
+
}
|
|
42437
|
+
return data;
|
|
42438
|
+
})
|
|
42439
|
+
.filter(Boolean);
|
|
42440
|
+
fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
|
|
42441
|
+
};
|
|
42442
|
+
/* end_public_function */
|
|
42443
|
+
|
|
42444
|
+
/* begin_public_function
|
|
42445
|
+
id: notificationTray.markSeen
|
|
42446
|
+
*/
|
|
42447
|
+
/**
|
|
42448
|
+
* ```js
|
|
42449
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
42450
|
+
* const updated = await notificationTray.markTraySeen({
|
|
42451
|
+
* lastSeenAt: Amity.timestamp,
|
|
42452
|
+
* })
|
|
42453
|
+
* ```
|
|
42454
|
+
*
|
|
42455
|
+
* Updates an {@link Amity.NotificationTraySeen}
|
|
42456
|
+
*
|
|
42457
|
+
* @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
|
|
42458
|
+
* @param lastSeenAt The patch data to apply
|
|
42459
|
+
* @returns the updated {@link Amity.NotificationTraySeen} object
|
|
42460
|
+
*
|
|
42461
|
+
* @category Post API
|
|
42462
|
+
* @async
|
|
42463
|
+
*/
|
|
42464
|
+
const markTraySeen = async (lastSeenAt) => {
|
|
42465
|
+
var _a;
|
|
42466
|
+
const client = getActiveClient();
|
|
42467
|
+
client.log('notificationTray/markTraySeen', {});
|
|
42468
|
+
const { data: payload } = await client.http.post(`api/v1/notification-tray/tray/seen`, {
|
|
42469
|
+
lastSeenAt,
|
|
42470
|
+
});
|
|
42471
|
+
const cacheData = (_a = pullFromCache([
|
|
42472
|
+
'notificationTraySeen',
|
|
42473
|
+
'get',
|
|
42474
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
42475
|
+
const data = {
|
|
42476
|
+
userId: client.userId,
|
|
42477
|
+
lastTraySeenAt: payload.lastSeenAt,
|
|
42478
|
+
};
|
|
42479
|
+
const updateCacheData = Object.assign(Object.assign({}, cacheData), data);
|
|
42480
|
+
const cachedAt = client.cache && Date.now();
|
|
42481
|
+
if (client.cache)
|
|
42482
|
+
pushToCache(['notificationTraySeen', 'get', client.userId], updateCacheData, { cachedAt });
|
|
42483
|
+
fireEvent('local.notificationTraySeen.updated', data);
|
|
42484
|
+
return {
|
|
42485
|
+
data: payload,
|
|
42486
|
+
cachedAt,
|
|
42487
|
+
};
|
|
42488
|
+
};
|
|
42489
|
+
/* end_public_function */
|
|
42490
|
+
|
|
42491
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
42492
|
+
__proto__: null,
|
|
42493
|
+
getNotificationTraySeen: getNotificationTraySeen,
|
|
42494
|
+
getNotificationTrayItems: getNotificationTrayItems,
|
|
42495
|
+
markItemsSeen: markItemsSeen,
|
|
42496
|
+
markTraySeen: markTraySeen,
|
|
42497
|
+
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
42498
|
+
});
|
|
42499
|
+
|
|
42500
|
+
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$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, index as notificationTray, 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 };
|