@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.cjs.js
CHANGED
|
@@ -121,6 +121,7 @@ const SECOND$1 = 1000;
|
|
|
121
121
|
const MINUTE = 60 * SECOND$1;
|
|
122
122
|
const HOUR = 60 * MINUTE;
|
|
123
123
|
const DAY = 24 * HOUR;
|
|
124
|
+
const WEEK = 7 * DAY;
|
|
124
125
|
const YEAR = 365 * DAY;
|
|
125
126
|
const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
|
|
126
127
|
|
|
@@ -543,6 +544,8 @@ const idResolvers = {
|
|
|
543
544
|
advertiser: ({ advertiserId }) => advertiserId,
|
|
544
545
|
pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
|
|
545
546
|
pinTarget: ({ targetId }) => targetId,
|
|
547
|
+
notificationTrayItem: ({ _id }) => _id,
|
|
548
|
+
notificationTraySeen: ({ userId }) => userId,
|
|
546
549
|
};
|
|
547
550
|
/**
|
|
548
551
|
* Retrieve the id resolver matching a domain name
|
|
@@ -594,6 +597,7 @@ const PAYLOAD2MODEL = {
|
|
|
594
597
|
advertisers: 'advertiser',
|
|
595
598
|
pinTargets: 'pinTarget',
|
|
596
599
|
pins: 'pin',
|
|
600
|
+
notificationTrayItems: 'notificationTrayItem',
|
|
597
601
|
};
|
|
598
602
|
/** hidden */
|
|
599
603
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -5530,6 +5534,26 @@ const commentLinkedObject = (comment) => {
|
|
|
5530
5534
|
} });
|
|
5531
5535
|
};
|
|
5532
5536
|
|
|
5537
|
+
function isAmityImagePost(post) {
|
|
5538
|
+
return !!(post.data &&
|
|
5539
|
+
typeof post.data !== 'string' &&
|
|
5540
|
+
'fileId' in post.data &&
|
|
5541
|
+
post.dataType === 'image');
|
|
5542
|
+
}
|
|
5543
|
+
function isAmityFilePost(post) {
|
|
5544
|
+
return !!(post.data &&
|
|
5545
|
+
typeof post.data !== 'string' &&
|
|
5546
|
+
'fileId' in post.data &&
|
|
5547
|
+
post.dataType === 'file');
|
|
5548
|
+
}
|
|
5549
|
+
function isAmityVideoPost(post) {
|
|
5550
|
+
return !!(post.data &&
|
|
5551
|
+
typeof post.data !== 'string' &&
|
|
5552
|
+
'videoFileId' in post.data &&
|
|
5553
|
+
'thumbnailFileId' in post.data &&
|
|
5554
|
+
post.dataType === 'video');
|
|
5555
|
+
}
|
|
5556
|
+
|
|
5533
5557
|
const postLinkedObject = (post) => {
|
|
5534
5558
|
return Object.assign(Object.assign({}, post), { analytics: {
|
|
5535
5559
|
markAsViewed: () => {
|
|
@@ -5558,6 +5582,30 @@ const postLinkedObject = (post) => {
|
|
|
5558
5582
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
5559
5583
|
return;
|
|
5560
5584
|
return userLinkedObject(cacheData.data);
|
|
5585
|
+
},
|
|
5586
|
+
getImageInfo() {
|
|
5587
|
+
var _a, _b;
|
|
5588
|
+
return isAmityImagePost(post)
|
|
5589
|
+
? (_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
|
|
5590
|
+
: undefined;
|
|
5591
|
+
},
|
|
5592
|
+
getVideoInfo() {
|
|
5593
|
+
var _a, _b, _c;
|
|
5594
|
+
return isAmityVideoPost(post)
|
|
5595
|
+
? (_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
|
|
5596
|
+
: undefined;
|
|
5597
|
+
},
|
|
5598
|
+
getVideoThumbnailInfo() {
|
|
5599
|
+
var _a, _b;
|
|
5600
|
+
return isAmityVideoPost(post)
|
|
5601
|
+
? (_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
|
|
5602
|
+
: undefined;
|
|
5603
|
+
},
|
|
5604
|
+
getFileInfo() {
|
|
5605
|
+
var _a, _b;
|
|
5606
|
+
return isAmityFilePost(post)
|
|
5607
|
+
? (_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
|
|
5608
|
+
: undefined;
|
|
5561
5609
|
} });
|
|
5562
5610
|
};
|
|
5563
5611
|
|
|
@@ -6221,6 +6269,14 @@ const pinnedPostLinkedObject = (pinnedPost) => {
|
|
|
6221
6269
|
} });
|
|
6222
6270
|
};
|
|
6223
6271
|
|
|
6272
|
+
const notificationTrayLinkedObject = (noti) => {
|
|
6273
|
+
return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
|
|
6274
|
+
.map(({ _id }) => pullFromCache(['user', 'get', _id]))
|
|
6275
|
+
.filter(isNonNullable)
|
|
6276
|
+
.map(({ data }) => data)
|
|
6277
|
+
.map(user => userLinkedObject(user)) });
|
|
6278
|
+
};
|
|
6279
|
+
|
|
6224
6280
|
const LinkedObject = {
|
|
6225
6281
|
ad: adLinkedObject,
|
|
6226
6282
|
comment: commentLinkedObject,
|
|
@@ -6234,6 +6290,7 @@ const LinkedObject = {
|
|
|
6234
6290
|
reactor: reactorLinkedObject,
|
|
6235
6291
|
channel: channelLinkedObject,
|
|
6236
6292
|
pinnedPost: pinnedPostLinkedObject,
|
|
6293
|
+
notificationTray: notificationTrayLinkedObject,
|
|
6237
6294
|
};
|
|
6238
6295
|
|
|
6239
6296
|
const getChannelMessagePreviewWithUser = (channel) => {
|
|
@@ -10135,7 +10192,7 @@ const getUserUnread = (callback) => {
|
|
|
10135
10192
|
};
|
|
10136
10193
|
};
|
|
10137
10194
|
|
|
10138
|
-
var index$
|
|
10195
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
10139
10196
|
__proto__: null,
|
|
10140
10197
|
getActiveClient: getActiveClient,
|
|
10141
10198
|
getActiveUser: getActiveUser,
|
|
@@ -11342,7 +11399,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
11342
11399
|
};
|
|
11343
11400
|
/* end_public_function */
|
|
11344
11401
|
|
|
11345
|
-
var index$
|
|
11402
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
11346
11403
|
__proto__: null,
|
|
11347
11404
|
blockUser: blockUser,
|
|
11348
11405
|
unBlockUser: unBlockUser,
|
|
@@ -12357,9 +12414,9 @@ var AmityUserSearchMatchType;
|
|
|
12357
12414
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
12358
12415
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
12359
12416
|
|
|
12360
|
-
var index$
|
|
12417
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
12361
12418
|
__proto__: null,
|
|
12362
|
-
Relationship: index$
|
|
12419
|
+
Relationship: index$l,
|
|
12363
12420
|
getUserByIds: getUserByIds,
|
|
12364
12421
|
updateUser: updateUser,
|
|
12365
12422
|
flagUser: flagUser,
|
|
@@ -12588,20 +12645,33 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
12588
12645
|
*
|
|
12589
12646
|
* @param formData The data necessary to create a new {@link Amity.File<'image'>}
|
|
12590
12647
|
* @param onProgress The callback to track the upload progress
|
|
12648
|
+
* @param altText The alt text for the image
|
|
12591
12649
|
* @returns The newly created {@link Amity.File<'image'>}
|
|
12592
12650
|
*
|
|
12593
12651
|
* @category File API
|
|
12594
12652
|
* @async
|
|
12595
12653
|
*/
|
|
12596
|
-
const uploadImage = async (formData, onProgress) => {
|
|
12654
|
+
const uploadImage = async (formData, onProgress, altText) => {
|
|
12597
12655
|
const client = getActiveClient();
|
|
12598
12656
|
client.log('file/uploadImage', formData);
|
|
12599
12657
|
const files = formData.getAll('files');
|
|
12600
|
-
if (
|
|
12601
|
-
|
|
12658
|
+
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
12659
|
+
console.warn('Deprecation Warning: `files` is deprecated, please use `file` instead.');
|
|
12660
|
+
formData.append('preferredFilename', files[0].name);
|
|
12661
|
+
}
|
|
12662
|
+
else {
|
|
12663
|
+
const file = formData.get('file');
|
|
12664
|
+
if (!file) {
|
|
12665
|
+
throw new Error('The formData object must have a `file` or `files` key');
|
|
12666
|
+
}
|
|
12667
|
+
formData.append('preferredFilename', file.name);
|
|
12668
|
+
// alt is for single image
|
|
12669
|
+
if (altText) {
|
|
12670
|
+
formData.append('altText', altText);
|
|
12671
|
+
}
|
|
12672
|
+
}
|
|
12602
12673
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
12603
12674
|
formData.append('accessType', accessType);
|
|
12604
|
-
formData.append('preferredFilename', files[0].name);
|
|
12605
12675
|
const headers = 'getHeaders' in formData
|
|
12606
12676
|
? formData.getHeaders()
|
|
12607
12677
|
: { 'content-type': 'multipart/form-data' };
|
|
@@ -12623,14 +12693,46 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
12623
12693
|
};
|
|
12624
12694
|
/* end_public_function */
|
|
12625
12695
|
|
|
12626
|
-
|
|
12696
|
+
/* begin_public_function
|
|
12697
|
+
id: file.update.altText
|
|
12698
|
+
*/
|
|
12699
|
+
/**
|
|
12700
|
+
* ```js
|
|
12701
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
12702
|
+
* const updated = await FileRepository.updateAltText(fileId, altText)
|
|
12703
|
+
* ```
|
|
12704
|
+
*
|
|
12705
|
+
* Updates an {@link Amity.File<'image'>['altText']}.
|
|
12706
|
+
*
|
|
12707
|
+
* @param fileId The ID of the {@link Amity.File<'image'>} to edit
|
|
12708
|
+
* @param altText The new alt text for the {@link Amity.File<'image'>}
|
|
12709
|
+
* @returns the updated {@link Amity.File<'image'>} object
|
|
12710
|
+
*
|
|
12711
|
+
* @category File API
|
|
12712
|
+
* @async
|
|
12713
|
+
*/
|
|
12714
|
+
const updateAltText = async (fileId, altText) => {
|
|
12715
|
+
const client = getActiveClient();
|
|
12716
|
+
client.log('file/updateAltText', altText);
|
|
12717
|
+
const { data } = await client.http.put(`/api/v3/files/${fileId}`, {
|
|
12718
|
+
altText,
|
|
12719
|
+
});
|
|
12720
|
+
const cachedAt = client.cache && Date.now();
|
|
12721
|
+
if (client.cache)
|
|
12722
|
+
ingestInCache({ files: [data] }, { cachedAt });
|
|
12723
|
+
return true;
|
|
12724
|
+
};
|
|
12725
|
+
/* end_public_function */
|
|
12726
|
+
|
|
12727
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
12627
12728
|
__proto__: null,
|
|
12628
12729
|
getFile: getFile,
|
|
12629
12730
|
uploadFile: uploadFile,
|
|
12630
12731
|
deleteFile: deleteFile,
|
|
12631
12732
|
fileUrlWithSize: fileUrlWithSize,
|
|
12632
12733
|
uploadVideo: uploadVideo,
|
|
12633
|
-
uploadImage: uploadImage
|
|
12734
|
+
uploadImage: uploadImage,
|
|
12735
|
+
updateAltText: updateAltText
|
|
12634
12736
|
});
|
|
12635
12737
|
|
|
12636
12738
|
/**
|
|
@@ -14490,7 +14592,7 @@ const getReactions = (params, callback, config) => {
|
|
|
14490
14592
|
};
|
|
14491
14593
|
/* end_public_function */
|
|
14492
14594
|
|
|
14493
|
-
var index$
|
|
14595
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
14494
14596
|
__proto__: null,
|
|
14495
14597
|
addReaction: addReaction,
|
|
14496
14598
|
removeReaction: removeReaction,
|
|
@@ -16306,7 +16408,7 @@ const getMessages = (params, callback, config) => {
|
|
|
16306
16408
|
};
|
|
16307
16409
|
/* end_public_function */
|
|
16308
16410
|
|
|
16309
|
-
var index$
|
|
16411
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
16310
16412
|
__proto__: null,
|
|
16311
16413
|
createMessage: createMessage,
|
|
16312
16414
|
updateMessage: updateMessage,
|
|
@@ -16832,7 +16934,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
16832
16934
|
};
|
|
16833
16935
|
/* end_public_function */
|
|
16834
16936
|
|
|
16835
|
-
var index$
|
|
16937
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
16836
16938
|
__proto__: null,
|
|
16837
16939
|
getSubChannelByIds: getSubChannels$1,
|
|
16838
16940
|
createSubChannel: createSubChannel,
|
|
@@ -18146,7 +18248,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
18146
18248
|
};
|
|
18147
18249
|
/* end_public_function */
|
|
18148
18250
|
|
|
18149
|
-
var index$
|
|
18251
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
18150
18252
|
__proto__: null,
|
|
18151
18253
|
addMembers: addMembers$1,
|
|
18152
18254
|
removeMembers: removeMembers$1,
|
|
@@ -18349,7 +18451,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
18349
18451
|
};
|
|
18350
18452
|
/* end_public_function */
|
|
18351
18453
|
|
|
18352
|
-
var index$
|
|
18454
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
18353
18455
|
__proto__: null,
|
|
18354
18456
|
addRole: addRole,
|
|
18355
18457
|
removeRole: removeRole,
|
|
@@ -18359,10 +18461,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
18359
18461
|
unmuteMembers: unmuteMembers
|
|
18360
18462
|
});
|
|
18361
18463
|
|
|
18362
|
-
var index$
|
|
18464
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
18363
18465
|
__proto__: null,
|
|
18364
|
-
Membership: index$
|
|
18365
|
-
Moderation: index$
|
|
18466
|
+
Membership: index$f,
|
|
18467
|
+
Moderation: index$e,
|
|
18366
18468
|
getChannelByIds: getChannelByIds$1,
|
|
18367
18469
|
createChannel: createChannel,
|
|
18368
18470
|
updateChannel: updateChannel,
|
|
@@ -19742,7 +19844,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
19742
19844
|
};
|
|
19743
19845
|
/* end_public_function */
|
|
19744
19846
|
|
|
19745
|
-
var index$
|
|
19847
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
19746
19848
|
__proto__: null,
|
|
19747
19849
|
addMembers: addMembers,
|
|
19748
19850
|
removeMembers: removeMembers,
|
|
@@ -20767,7 +20869,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
20767
20869
|
};
|
|
20768
20870
|
/* end_public_function */
|
|
20769
20871
|
|
|
20770
|
-
var index$
|
|
20872
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
20771
20873
|
__proto__: null,
|
|
20772
20874
|
addRoles: addRoles,
|
|
20773
20875
|
removeRoles: removeRoles,
|
|
@@ -20775,10 +20877,10 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
20775
20877
|
unbanMembers: unbanMembers
|
|
20776
20878
|
});
|
|
20777
20879
|
|
|
20778
|
-
var index$
|
|
20880
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
20779
20881
|
__proto__: null,
|
|
20780
|
-
Moderation: index$
|
|
20781
|
-
Membership: index$
|
|
20882
|
+
Moderation: index$b,
|
|
20883
|
+
Membership: index$c,
|
|
20782
20884
|
getCommunityByIds: getCommunities$1,
|
|
20783
20885
|
createCommunity: createCommunity,
|
|
20784
20886
|
updateCommunity: updateCommunity,
|
|
@@ -21011,7 +21113,7 @@ const getCategories = (params, callback, config) => {
|
|
|
21011
21113
|
};
|
|
21012
21114
|
/* end_public_function */
|
|
21013
21115
|
|
|
21014
|
-
var index$
|
|
21116
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
21015
21117
|
__proto__: null,
|
|
21016
21118
|
getCategory: getCategory,
|
|
21017
21119
|
getCategories: getCategories
|
|
@@ -21179,7 +21281,7 @@ getCustomRankingGlobalFeed.locally = (query) => {
|
|
|
21179
21281
|
: undefined;
|
|
21180
21282
|
};
|
|
21181
21283
|
|
|
21182
|
-
var index$
|
|
21284
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
21183
21285
|
__proto__: null,
|
|
21184
21286
|
queryGlobalFeed: queryGlobalFeed,
|
|
21185
21287
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
@@ -22494,7 +22596,7 @@ const getComments = (params, callback, config) => {
|
|
|
22494
22596
|
};
|
|
22495
22597
|
/* end_public_function */
|
|
22496
22598
|
|
|
22497
|
-
var index$
|
|
22599
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
22498
22600
|
__proto__: null,
|
|
22499
22601
|
getCommentByIds: getCommentByIds,
|
|
22500
22602
|
createComment: createComment,
|
|
@@ -23501,7 +23603,7 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
23501
23603
|
};
|
|
23502
23604
|
};
|
|
23503
23605
|
|
|
23504
|
-
var index$
|
|
23606
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
23505
23607
|
__proto__: null,
|
|
23506
23608
|
getPostByIds: getPostByIds,
|
|
23507
23609
|
createPost: createPost,
|
|
@@ -24035,7 +24137,7 @@ const getStreams = (params, callback, config) => {
|
|
|
24035
24137
|
};
|
|
24036
24138
|
};
|
|
24037
24139
|
|
|
24038
|
-
var index$
|
|
24140
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
24039
24141
|
__proto__: null,
|
|
24040
24142
|
createStream: createStream,
|
|
24041
24143
|
updateStream: updateStream,
|
|
@@ -24322,7 +24424,7 @@ const getPoll = (pollId, callback) => {
|
|
|
24322
24424
|
};
|
|
24323
24425
|
/* end_public_function */
|
|
24324
24426
|
|
|
24325
|
-
var index$
|
|
24427
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
24326
24428
|
__proto__: null,
|
|
24327
24429
|
createPoll: createPoll,
|
|
24328
24430
|
closePoll: closePoll,
|
|
@@ -24333,7 +24435,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
24333
24435
|
getPoll: getPoll
|
|
24334
24436
|
});
|
|
24335
24437
|
|
|
24336
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
24438
|
+
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-----";
|
|
24337
24439
|
/*
|
|
24338
24440
|
* The crypto algorithm used for importing key and signing string
|
|
24339
24441
|
*/
|
|
@@ -24693,7 +24795,7 @@ const getPlayer = async (parameters) => {
|
|
|
24693
24795
|
return video;
|
|
24694
24796
|
};
|
|
24695
24797
|
|
|
24696
|
-
var index$
|
|
24798
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
24697
24799
|
__proto__: null,
|
|
24698
24800
|
getPlayer: getPlayer
|
|
24699
24801
|
});
|
|
@@ -25866,7 +25968,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
25866
25968
|
};
|
|
25867
25969
|
};
|
|
25868
25970
|
|
|
25869
|
-
var index$
|
|
25971
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
25870
25972
|
__proto__: null,
|
|
25871
25973
|
createImageStory: createImageStory,
|
|
25872
25974
|
createVideoStory: createVideoStory,
|
|
@@ -25903,7 +26005,7 @@ const getNetworkAds = async () => {
|
|
|
25903
26005
|
};
|
|
25904
26006
|
};
|
|
25905
26007
|
|
|
25906
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
26008
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
25907
26009
|
__proto__: null,
|
|
25908
26010
|
getNetworkAds: getNetworkAds
|
|
25909
26011
|
});
|
|
@@ -25930,31 +26032,404 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
25930
26032
|
return { accessToken: data.accessToken };
|
|
25931
26033
|
};
|
|
25932
26034
|
|
|
26035
|
+
/* begin_public_function
|
|
26036
|
+
id: notificationTray.getNotificationTraySeen
|
|
26037
|
+
*/
|
|
26038
|
+
/**
|
|
26039
|
+
* ```js
|
|
26040
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
26041
|
+
* const notificationTraySeen = await notificationTray.getNotificationTraySeen()
|
|
26042
|
+
* ```
|
|
26043
|
+
*
|
|
26044
|
+
*
|
|
26045
|
+
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
26046
|
+
*
|
|
26047
|
+
* @category NotificationTray API
|
|
26048
|
+
* @async
|
|
26049
|
+
* */
|
|
26050
|
+
const getNotificationTraySeen$1 = async () => {
|
|
26051
|
+
const client = getActiveClient();
|
|
26052
|
+
client.log('notificationTray/getNotificationTraySeen', {});
|
|
26053
|
+
const { data: payload } = await client.http.get(`api/v1/notification-tray/tray/seen`);
|
|
26054
|
+
const cachedAt = client.cache && Date.now();
|
|
26055
|
+
if (client.cache) {
|
|
26056
|
+
const cacheKey = ['notificationTraySeen', 'get', client.userId];
|
|
26057
|
+
pushToCache(cacheKey, {
|
|
26058
|
+
userId: client.userId,
|
|
26059
|
+
lastTraySeenAt: payload.lastTraySeenAt,
|
|
26060
|
+
lastTrayOccuredAt: payload.lastTrayOccurredAt,
|
|
26061
|
+
});
|
|
26062
|
+
}
|
|
26063
|
+
return {
|
|
26064
|
+
data: {
|
|
26065
|
+
userId: client.userId,
|
|
26066
|
+
lastTraySeenAt: payload.lastTraySeenAt,
|
|
26067
|
+
lastTrayOccurredAt: payload.lastTrayOccurredAt,
|
|
26068
|
+
isSeen: payload.lastTraySeenAt > payload.lastTrayOccurredAt,
|
|
26069
|
+
},
|
|
26070
|
+
cachedAt,
|
|
26071
|
+
};
|
|
26072
|
+
};
|
|
26073
|
+
/* end_public_function */
|
|
26074
|
+
/**
|
|
26075
|
+
* ```js
|
|
26076
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
26077
|
+
* const notificationTraySeen = await notificationTray.getNotificationTraySeen.locally()
|
|
26078
|
+
* ```
|
|
26079
|
+
*
|
|
26080
|
+
* Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
|
|
26081
|
+
*
|
|
26082
|
+
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
26083
|
+
*
|
|
26084
|
+
* @category NotificationTray API
|
|
26085
|
+
* @async
|
|
26086
|
+
* */
|
|
26087
|
+
getNotificationTraySeen$1.locally = () => {
|
|
26088
|
+
var _a;
|
|
26089
|
+
const client = getActiveClient();
|
|
26090
|
+
client.log('notificationTray/getNotificationTraySeen.locally', {});
|
|
26091
|
+
if (!client.cache)
|
|
26092
|
+
return;
|
|
26093
|
+
const queryKey = ['notificationTraySeen', 'get'];
|
|
26094
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
26095
|
+
if (!data)
|
|
26096
|
+
return;
|
|
26097
|
+
return { data, cachedAt };
|
|
26098
|
+
};
|
|
26099
|
+
|
|
26100
|
+
/**
|
|
26101
|
+
* ```js
|
|
26102
|
+
* import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
|
|
26103
|
+
* const dispose = onNotificationTraySeenUpdated(data => {
|
|
26104
|
+
* // ...
|
|
26105
|
+
* })
|
|
26106
|
+
* ```
|
|
26107
|
+
*
|
|
26108
|
+
* Fired when an {@link Amity.NotificationTraySeen} has been updated
|
|
26109
|
+
*
|
|
26110
|
+
* @param callback The function to call when the event was fired
|
|
26111
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
26112
|
+
*
|
|
26113
|
+
* @category NotificationTraySeen Events
|
|
26114
|
+
*/
|
|
26115
|
+
const onNotificationTraySeenUpdated = (callback) => {
|
|
26116
|
+
const client = getActiveClient();
|
|
26117
|
+
const disposers = [
|
|
26118
|
+
createEventSubscriber(client, 'onNotificationTraySeenUpdated', 'local.notificationTraySeen.updated', payload => callback(payload)),
|
|
26119
|
+
];
|
|
26120
|
+
return () => {
|
|
26121
|
+
disposers.forEach(fn => fn());
|
|
26122
|
+
};
|
|
26123
|
+
};
|
|
26124
|
+
|
|
26125
|
+
/* begin_public_function
|
|
26126
|
+
id: notificationTray.getNotificationTraySeen
|
|
26127
|
+
*/
|
|
26128
|
+
/**
|
|
26129
|
+
* ```js
|
|
26130
|
+
* import { notificationTray } from '@amityco/ts-sdk';
|
|
26131
|
+
*
|
|
26132
|
+
* let notificationTraySeen;
|
|
26133
|
+
*
|
|
26134
|
+
* const unsubscribe = getNotificationTraySeen(response => {
|
|
26135
|
+
* notificationTraySeen = response.data;
|
|
26136
|
+
* });
|
|
26137
|
+
* ```
|
|
26138
|
+
*
|
|
26139
|
+
* Observe all mutation on a given {@link Amity.NotificationTraySeen}
|
|
26140
|
+
*
|
|
26141
|
+
* @param callback the function to call when new data are available
|
|
26142
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
|
|
26143
|
+
*
|
|
26144
|
+
* @category NotificationTraySeen Live Object
|
|
26145
|
+
*/
|
|
26146
|
+
const getNotificationTraySeen = (callback) => {
|
|
26147
|
+
const { userId } = getActiveUser();
|
|
26148
|
+
return liveObject(userId, callback, 'userId', getNotificationTraySeen$1, [onNotificationTraySeenUpdated], {
|
|
26149
|
+
callbackDataSelector: (data) => {
|
|
26150
|
+
let isSeen = true;
|
|
26151
|
+
if (data === null || data === void 0 ? void 0 : data.lastTrayOccurredAt) {
|
|
26152
|
+
if (!data.lastTraySeenAt) {
|
|
26153
|
+
isSeen = false;
|
|
26154
|
+
}
|
|
26155
|
+
else {
|
|
26156
|
+
isSeen =
|
|
26157
|
+
convertDateStringToTimestamp(data.lastTraySeenAt) >
|
|
26158
|
+
convertDateStringToTimestamp(data.lastTrayOccurredAt);
|
|
26159
|
+
}
|
|
26160
|
+
}
|
|
26161
|
+
return {
|
|
26162
|
+
lastTrayOccurredAt: data === null || data === void 0 ? void 0 : data.lastTrayOccurredAt,
|
|
26163
|
+
lastTraySeenAt: data === null || data === void 0 ? void 0 : data.lastTraySeenAt,
|
|
26164
|
+
isSeen,
|
|
26165
|
+
};
|
|
26166
|
+
},
|
|
26167
|
+
});
|
|
26168
|
+
};
|
|
26169
|
+
/* end_public_function */
|
|
26170
|
+
|
|
26171
|
+
/**
|
|
26172
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
26173
|
+
* TODO: check if querybyIds is supported
|
|
26174
|
+
*/
|
|
26175
|
+
class NotificationTrayItemsPaginationController extends PaginationController {
|
|
26176
|
+
async getRequest(queryParams, token) {
|
|
26177
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
26178
|
+
const options = token ? { token } : { limit };
|
|
26179
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/notification-tray`, {
|
|
26180
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
26181
|
+
});
|
|
26182
|
+
return queryResponse;
|
|
26183
|
+
}
|
|
26184
|
+
}
|
|
26185
|
+
|
|
26186
|
+
class NotificationTrayItemsQuerystreamController extends QueryStreamController {
|
|
26187
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
26188
|
+
super(query, cacheKey);
|
|
26189
|
+
this.notifyChange = notifyChange;
|
|
26190
|
+
this.preparePayload = preparePayload;
|
|
26191
|
+
}
|
|
26192
|
+
async saveToMainDB(response) {
|
|
26193
|
+
const processedPayload = await this.preparePayload(response);
|
|
26194
|
+
const client = getActiveClient();
|
|
26195
|
+
const cachedAt = client.cache && Date.now();
|
|
26196
|
+
if (client.cache) {
|
|
26197
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
26198
|
+
}
|
|
26199
|
+
}
|
|
26200
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
26201
|
+
var _a, _b;
|
|
26202
|
+
if (refresh) {
|
|
26203
|
+
pushToCache(this.cacheKey, {
|
|
26204
|
+
data: response.notificationTrayItems.map(getResolver('notificationTrayItem')),
|
|
26205
|
+
});
|
|
26206
|
+
}
|
|
26207
|
+
else {
|
|
26208
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26209
|
+
const notifications = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26210
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
26211
|
+
...new Set([
|
|
26212
|
+
...notifications,
|
|
26213
|
+
...response.notificationTrayItems.map(getResolver('notificationTrayItem')),
|
|
26214
|
+
]),
|
|
26215
|
+
] }));
|
|
26216
|
+
}
|
|
26217
|
+
}
|
|
26218
|
+
}
|
|
26219
|
+
|
|
26220
|
+
const prepareNotificationTrayItemsPayload = (rawPayload) => {
|
|
26221
|
+
const users = rawPayload.users.map(convertRawUserToInternalUser);
|
|
26222
|
+
return Object.assign(Object.assign({}, rawPayload), { users });
|
|
26223
|
+
};
|
|
26224
|
+
|
|
26225
|
+
class NotificationTrayItemsLiveCollectionController extends LiveCollectionController {
|
|
26226
|
+
constructor(query, callback) {
|
|
26227
|
+
const queryStreamId = hash__default["default"](query);
|
|
26228
|
+
const cacheKey = ['notificationTrayItem', 'collection', queryStreamId];
|
|
26229
|
+
const paginationController = new NotificationTrayItemsPaginationController(query);
|
|
26230
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
26231
|
+
this.query = query;
|
|
26232
|
+
this.queryStreamController = new NotificationTrayItemsQuerystreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareNotificationTrayItemsPayload);
|
|
26233
|
+
this.callback = callback.bind(this);
|
|
26234
|
+
this.loadPage({ initial: true });
|
|
26235
|
+
}
|
|
26236
|
+
setup() {
|
|
26237
|
+
var _a;
|
|
26238
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26239
|
+
if (!collection) {
|
|
26240
|
+
pushToCache(this.cacheKey, {
|
|
26241
|
+
data: [],
|
|
26242
|
+
params: {},
|
|
26243
|
+
});
|
|
26244
|
+
}
|
|
26245
|
+
}
|
|
26246
|
+
async persistModel(queryPayload) {
|
|
26247
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
26248
|
+
}
|
|
26249
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
26250
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
26251
|
+
}
|
|
26252
|
+
// eslint-disable-next-line class-methods-use-this
|
|
26253
|
+
startSubscription() {
|
|
26254
|
+
return [];
|
|
26255
|
+
}
|
|
26256
|
+
notifyChange({ origin, loading, error }) {
|
|
26257
|
+
var _a, _b;
|
|
26258
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26259
|
+
if (!collection)
|
|
26260
|
+
return;
|
|
26261
|
+
const data = ((_b = collection.data
|
|
26262
|
+
.map(id => pullFromCache(['notificationTrayItem', 'get', id]))
|
|
26263
|
+
.filter(isNonNullable)
|
|
26264
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.notificationTray);
|
|
26265
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
26266
|
+
return;
|
|
26267
|
+
this.callback({
|
|
26268
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
26269
|
+
data,
|
|
26270
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
26271
|
+
loading,
|
|
26272
|
+
error,
|
|
26273
|
+
});
|
|
26274
|
+
}
|
|
26275
|
+
}
|
|
26276
|
+
|
|
26277
|
+
/**
|
|
26278
|
+
* Get notification tray items for a notification tray page
|
|
26279
|
+
*
|
|
26280
|
+
* @param params the limit query parameters
|
|
26281
|
+
* @param callback the callback to be called when the notification tray items are updated
|
|
26282
|
+
* @returns items in the notification tray
|
|
26283
|
+
*
|
|
26284
|
+
* @category Notification tray items Live Collection
|
|
26285
|
+
*
|
|
26286
|
+
*/
|
|
26287
|
+
const getNotificationTrayItems = (params, callback, config) => {
|
|
26288
|
+
const { log, cache } = getActiveClient();
|
|
26289
|
+
if (!cache) {
|
|
26290
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
26291
|
+
}
|
|
26292
|
+
const timestamp = Date.now();
|
|
26293
|
+
log(`getNotificationTrayItems(tmpid: ${timestamp}) > listen`);
|
|
26294
|
+
const notiTrayItemsLiveCollection = new NotificationTrayItemsLiveCollectionController(params, callback);
|
|
26295
|
+
const disposers = notiTrayItemsLiveCollection.startSubscription();
|
|
26296
|
+
const cacheKey = notiTrayItemsLiveCollection.getCacheKey();
|
|
26297
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
26298
|
+
return () => {
|
|
26299
|
+
log(`getNotificationTrayItems(tmpid: ${timestamp}) > dispose`);
|
|
26300
|
+
disposers.forEach(fn => fn());
|
|
26301
|
+
};
|
|
26302
|
+
};
|
|
26303
|
+
|
|
26304
|
+
/* begin_public_function
|
|
26305
|
+
id: notificationTrayItem.markSeen
|
|
26306
|
+
*/
|
|
26307
|
+
/**
|
|
26308
|
+
* ```js
|
|
26309
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
26310
|
+
* const updated = await notificationTray.markItemsSeen()
|
|
26311
|
+
* ```
|
|
26312
|
+
*
|
|
26313
|
+
* Updates an {@link Amity.NotificationItemSeen}
|
|
26314
|
+
*
|
|
26315
|
+
* @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
|
|
26316
|
+
* @returns the updated {@link Amity.NotificationItemSeen} object
|
|
26317
|
+
*
|
|
26318
|
+
* @category NotificationItemSeen API
|
|
26319
|
+
* @async
|
|
26320
|
+
*/
|
|
26321
|
+
const markItemsSeen = async (trayItems) => {
|
|
26322
|
+
const client = getActiveClient();
|
|
26323
|
+
client.log('notificationTray/markItemsSeen', {});
|
|
26324
|
+
const { data: payload } = await client.http.post(`api/v1/notification-tray/items/seen`, {
|
|
26325
|
+
trayItems: trayItems.map(item => ({
|
|
26326
|
+
id: item.id,
|
|
26327
|
+
lastSeenAt: item.lastSeenAt,
|
|
26328
|
+
})),
|
|
26329
|
+
});
|
|
26330
|
+
const updatedData = trayItems
|
|
26331
|
+
.map(patchItem => {
|
|
26332
|
+
var _a;
|
|
26333
|
+
const cacheData = (_a = pullFromCache([
|
|
26334
|
+
'notificationTrayItem',
|
|
26335
|
+
'get',
|
|
26336
|
+
patchItem.id,
|
|
26337
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
26338
|
+
if (!cacheData)
|
|
26339
|
+
return;
|
|
26340
|
+
const data = Object.assign(Object.assign({}, cacheData), payload);
|
|
26341
|
+
if (client.cache) {
|
|
26342
|
+
const cachedAt = Date.now();
|
|
26343
|
+
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
|
26344
|
+
}
|
|
26345
|
+
return data;
|
|
26346
|
+
})
|
|
26347
|
+
.filter(Boolean);
|
|
26348
|
+
fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
|
|
26349
|
+
};
|
|
26350
|
+
/* end_public_function */
|
|
26351
|
+
|
|
26352
|
+
/* begin_public_function
|
|
26353
|
+
id: notificationTray.markSeen
|
|
26354
|
+
*/
|
|
26355
|
+
/**
|
|
26356
|
+
* ```js
|
|
26357
|
+
* import { notificationTray } from '@amityco/ts-sdk'
|
|
26358
|
+
* const updated = await notificationTray.markTraySeen({
|
|
26359
|
+
* lastSeenAt: Amity.timestamp,
|
|
26360
|
+
* })
|
|
26361
|
+
* ```
|
|
26362
|
+
*
|
|
26363
|
+
* Updates an {@link Amity.NotificationTraySeen}
|
|
26364
|
+
*
|
|
26365
|
+
* @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
|
|
26366
|
+
* @param lastSeenAt The patch data to apply
|
|
26367
|
+
* @returns the updated {@link Amity.NotificationTraySeen} object
|
|
26368
|
+
*
|
|
26369
|
+
* @category Post API
|
|
26370
|
+
* @async
|
|
26371
|
+
*/
|
|
26372
|
+
const markTraySeen = async (lastSeenAt) => {
|
|
26373
|
+
var _a;
|
|
26374
|
+
const client = getActiveClient();
|
|
26375
|
+
client.log('notificationTray/markTraySeen', {});
|
|
26376
|
+
const { data: payload } = await client.http.post(`api/v1/notification-tray/tray/seen`, {
|
|
26377
|
+
lastSeenAt,
|
|
26378
|
+
});
|
|
26379
|
+
const cacheData = (_a = pullFromCache([
|
|
26380
|
+
'notificationTraySeen',
|
|
26381
|
+
'get',
|
|
26382
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
26383
|
+
const data = {
|
|
26384
|
+
userId: client.userId,
|
|
26385
|
+
lastTraySeenAt: payload.lastSeenAt,
|
|
26386
|
+
};
|
|
26387
|
+
const updateCacheData = Object.assign(Object.assign({}, cacheData), data);
|
|
26388
|
+
const cachedAt = client.cache && Date.now();
|
|
26389
|
+
if (client.cache)
|
|
26390
|
+
pushToCache(['notificationTraySeen', 'get', client.userId], updateCacheData, { cachedAt });
|
|
26391
|
+
fireEvent('local.notificationTraySeen.updated', data);
|
|
26392
|
+
return {
|
|
26393
|
+
data: payload,
|
|
26394
|
+
cachedAt,
|
|
26395
|
+
};
|
|
26396
|
+
};
|
|
26397
|
+
/* end_public_function */
|
|
26398
|
+
|
|
26399
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
26400
|
+
__proto__: null,
|
|
26401
|
+
getNotificationTraySeen: getNotificationTraySeen,
|
|
26402
|
+
getNotificationTrayItems: getNotificationTrayItems,
|
|
26403
|
+
markItemsSeen: markItemsSeen,
|
|
26404
|
+
markTraySeen: markTraySeen,
|
|
26405
|
+
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
26406
|
+
});
|
|
26407
|
+
|
|
25933
26408
|
exports.API_REGIONS = API_REGIONS;
|
|
25934
|
-
exports.AdRepository = index;
|
|
25935
|
-
exports.CategoryRepository = index$
|
|
25936
|
-
exports.ChannelRepository = index$
|
|
25937
|
-
exports.Client = index$
|
|
25938
|
-
exports.CommentRepository = index$
|
|
26409
|
+
exports.AdRepository = index$1;
|
|
26410
|
+
exports.CategoryRepository = index$9;
|
|
26411
|
+
exports.ChannelRepository = index$d;
|
|
26412
|
+
exports.Client = index$m;
|
|
26413
|
+
exports.CommentRepository = index$7;
|
|
25939
26414
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
25940
26415
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
25941
|
-
exports.CommunityRepository = index$
|
|
26416
|
+
exports.CommunityRepository = index$a;
|
|
25942
26417
|
exports.ContentFeedType = ContentFeedType;
|
|
25943
26418
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
25944
|
-
exports.FeedRepository = index$
|
|
25945
|
-
exports.FileRepository = index$
|
|
26419
|
+
exports.FeedRepository = index$8;
|
|
26420
|
+
exports.FileRepository = index$j;
|
|
25946
26421
|
exports.FileType = FileType;
|
|
25947
|
-
exports.LiveStreamPlayer = index$
|
|
26422
|
+
exports.LiveStreamPlayer = index$3;
|
|
25948
26423
|
exports.MessageContentType = MessageContentType;
|
|
25949
|
-
exports.MessageRepository = index$
|
|
25950
|
-
exports.PollRepository = index$
|
|
26424
|
+
exports.MessageRepository = index$h;
|
|
26425
|
+
exports.PollRepository = index$4;
|
|
25951
26426
|
exports.PostContentType = PostContentType;
|
|
25952
|
-
exports.PostRepository = index$
|
|
25953
|
-
exports.ReactionRepository = index$
|
|
25954
|
-
exports.StoryRepository = index$
|
|
25955
|
-
exports.StreamRepository = index$
|
|
25956
|
-
exports.SubChannelRepository = index$
|
|
25957
|
-
exports.UserRepository = index$
|
|
26427
|
+
exports.PostRepository = index$6;
|
|
26428
|
+
exports.ReactionRepository = index$i;
|
|
26429
|
+
exports.StoryRepository = index$2;
|
|
26430
|
+
exports.StreamRepository = index$5;
|
|
26431
|
+
exports.SubChannelRepository = index$g;
|
|
26432
|
+
exports.UserRepository = index$k;
|
|
25958
26433
|
exports.VERSION = VERSION;
|
|
25959
26434
|
exports.VideoResolution = VideoResolution;
|
|
25960
26435
|
exports.VideoSize = VideoSize;
|
|
@@ -26007,6 +26482,7 @@ exports.isPaged = isPaged;
|
|
|
26007
26482
|
exports.isReportedByMe = isReportedByMe;
|
|
26008
26483
|
exports.isSkip = isSkip;
|
|
26009
26484
|
exports.mergeInCache = mergeInCache;
|
|
26485
|
+
exports.notificationTray = index;
|
|
26010
26486
|
exports.onChannelMarkerFetched = onChannelMarkerFetched;
|
|
26011
26487
|
exports.onFeedMarkerFetched = onFeedMarkerFetched;
|
|
26012
26488
|
exports.onFeedMarkerUpdated = onFeedMarkerUpdated;
|