@amityco/ts-sdk 6.26.3 → 6.27.1-17fb5a6.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/model.d.ts +5 -5
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/domains/ad.d.ts +14 -2
- package/dist/@types/domains/ad.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +4 -1
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/adRepository/api/getNetworkAds.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +2 -2
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +11 -5
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
- package/dist/index.cjs.js +284 -265
- package/dist/index.esm.js +284 -265
- package/dist/index.umd.js +2 -2
- package/dist/messageRepository/api/createMessage.d.ts +7 -25
- package/dist/messageRepository/api/createMessage.d.ts.map +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts +4 -4
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/postRepository/observers/getPost.d.ts.map +1 -1
- package/dist/utils/linkedObject/adLinkedObject.d.ts +1 -1
- package/dist/utils/linkedObject/adLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/model.ts +5 -5
- package/src/@types/domains/ad.ts +17 -6
- package/src/@types/domains/message.ts +6 -1
- package/src/adRepository/api/getNetworkAds.ts +22 -8
- package/src/analytic/service/analytic/AnalyticsEngine.ts +2 -2
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +45 -27
- package/src/core/model/idResolvers.ts +1 -1
- package/src/messageRepository/api/createMessage.ts +83 -98
- package/src/messageRepository/events/onMessageCreated.ts +12 -6
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +26 -24
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +3 -2
- package/src/messageRepository/observers/observeMessages.ts +3 -3
- package/src/messageRepository/utils/prepareMessagePayload.ts +1 -1
- package/src/postRepository/observers/getPost.ts +8 -1
- package/src/utils/linkedObject/adLinkedObject.ts +11 -11
package/dist/index.cjs.js
CHANGED
|
@@ -97,8 +97,8 @@ const PostContentType = Object.freeze({
|
|
|
97
97
|
|
|
98
98
|
function getVersion() {
|
|
99
99
|
try {
|
|
100
|
-
// the string ''v6.
|
|
101
|
-
return 'v6.
|
|
100
|
+
// the string ''v6.27.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
101
|
+
return 'v6.27.0-cjs';
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
104
|
return '__dev__';
|
|
@@ -506,7 +506,7 @@ const idResolvers = {
|
|
|
506
506
|
channel: ({ channelInternalId }) => channelInternalId,
|
|
507
507
|
subChannel: ({ subChannelId }) => subChannelId,
|
|
508
508
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
509
|
-
message: ({ messageId }) => messageId,
|
|
509
|
+
message: ({ messageId, referenceId }) => referenceId !== null && referenceId !== void 0 ? referenceId : messageId,
|
|
510
510
|
messagePreviewChannel: ({ channelId }) => `${channelId}`,
|
|
511
511
|
messagePreviewSubChannel: ({ subChannelId }) => `${subChannelId}`,
|
|
512
512
|
channelUnreadInfo: ({ channelId }) => channelId,
|
|
@@ -4858,12 +4858,12 @@ class AnalyticsEventCapturer {
|
|
|
4858
4858
|
this._throttleStoryTimer = undefined;
|
|
4859
4859
|
this._bufferNewSeenStoryReferenceIds = [];
|
|
4860
4860
|
}
|
|
4861
|
-
isAbleToEnqueue({
|
|
4861
|
+
isAbleToEnqueue({ uniqueId, expireTime, isHighPriority = false, }) {
|
|
4862
4862
|
const now = new Date();
|
|
4863
4863
|
const getRecentViewedDate = () => {
|
|
4864
4864
|
if (isHighPriority)
|
|
4865
|
-
return this._recentHighPriorityViewed[
|
|
4866
|
-
return this._recentViewed[
|
|
4865
|
+
return this._recentHighPriorityViewed[uniqueId];
|
|
4866
|
+
return this._recentViewed[uniqueId];
|
|
4867
4867
|
};
|
|
4868
4868
|
const recentViewedDate = getRecentViewedDate() || new Date(DAY * -1);
|
|
4869
4869
|
const timeDiff = now.getTime() - recentViewedDate.getTime();
|
|
@@ -4873,8 +4873,8 @@ class AnalyticsEventCapturer {
|
|
|
4873
4873
|
}
|
|
4874
4874
|
return true;
|
|
4875
4875
|
}
|
|
4876
|
-
markAs(
|
|
4877
|
-
if (!this.isAbleToEnqueue({
|
|
4876
|
+
markAs({ uniqueId, contentId, contentType, activityType, metadata, }) {
|
|
4877
|
+
if (!this.isAbleToEnqueue({ uniqueId, expireTime: this._expireTime }))
|
|
4878
4878
|
return;
|
|
4879
4879
|
const now = new Date();
|
|
4880
4880
|
const currentData = { event: [] };
|
|
@@ -4888,7 +4888,7 @@ class AnalyticsEventCapturer {
|
|
|
4888
4888
|
currentData.event.shift();
|
|
4889
4889
|
}
|
|
4890
4890
|
const analyticItem = {
|
|
4891
|
-
contentId
|
|
4891
|
+
contentId,
|
|
4892
4892
|
contentType,
|
|
4893
4893
|
activityType,
|
|
4894
4894
|
timestamp: now.toISOString(),
|
|
@@ -4898,10 +4898,15 @@ class AnalyticsEventCapturer {
|
|
|
4898
4898
|
}
|
|
4899
4899
|
currentData.event.push(analyticItem);
|
|
4900
4900
|
upsertInCache(ANALYTIC_CACHE_KEY, currentData);
|
|
4901
|
-
this._recentViewed[
|
|
4901
|
+
this._recentViewed[uniqueId] = now;
|
|
4902
4902
|
}
|
|
4903
4903
|
markPostAsViewed(postId) {
|
|
4904
|
-
this.markAs(
|
|
4904
|
+
this.markAs({
|
|
4905
|
+
uniqueId: postId,
|
|
4906
|
+
contentId: postId,
|
|
4907
|
+
contentType: "post" /* Amity.AnalyticEventContentType.Post */,
|
|
4908
|
+
activityType: "view" /* Amity.AnalyticEventActivityType.View */,
|
|
4909
|
+
});
|
|
4905
4910
|
}
|
|
4906
4911
|
markStory(story, activityType) {
|
|
4907
4912
|
if (!story.expiresAt)
|
|
@@ -4909,7 +4914,7 @@ class AnalyticsEventCapturer {
|
|
|
4909
4914
|
const now = new Date();
|
|
4910
4915
|
const expireTime = new Date(story.expiresAt);
|
|
4911
4916
|
if (!this.isAbleToEnqueue({
|
|
4912
|
-
|
|
4917
|
+
uniqueId: story.storyId,
|
|
4913
4918
|
expireTime: expireTime.getTime(),
|
|
4914
4919
|
isHighPriority: true,
|
|
4915
4920
|
}))
|
|
@@ -4975,13 +4980,27 @@ class AnalyticsEventCapturer {
|
|
|
4975
4980
|
const metadata = {
|
|
4976
4981
|
placement,
|
|
4977
4982
|
};
|
|
4978
|
-
|
|
4983
|
+
const activityType = "view" /* Amity.AnalyticEventActivityType.View */;
|
|
4984
|
+
this.markAs({
|
|
4985
|
+
uniqueId: `${ad.adId}.${activityType}.${placement}`,
|
|
4986
|
+
contentId: ad.adId,
|
|
4987
|
+
contentType: "ad" /* Amity.AnalyticEventContentType.Ad */,
|
|
4988
|
+
activityType,
|
|
4989
|
+
metadata,
|
|
4990
|
+
});
|
|
4979
4991
|
}
|
|
4980
4992
|
markAdAsClicked(ad, placement) {
|
|
4981
4993
|
const metadata = {
|
|
4982
4994
|
placement,
|
|
4983
4995
|
};
|
|
4984
|
-
|
|
4996
|
+
const activityType = "linkClicked" /* Amity.AnalyticEventActivityType.Click */;
|
|
4997
|
+
this.markAs({
|
|
4998
|
+
uniqueId: `${ad.adId}.${activityType}.${placement}`,
|
|
4999
|
+
contentId: ad.adId,
|
|
5000
|
+
contentType: "ad" /* Amity.AnalyticEventContentType.Ad */,
|
|
5001
|
+
activityType,
|
|
5002
|
+
metadata,
|
|
5003
|
+
});
|
|
4985
5004
|
}
|
|
4986
5005
|
}
|
|
4987
5006
|
|
|
@@ -5748,20 +5767,17 @@ const channelLinkedObject = (channel) => {
|
|
|
5748
5767
|
return Object.assign(Object.assign({}, channel), { markAsRead: () => markAsRead(channel.channelInternalId) });
|
|
5749
5768
|
};
|
|
5750
5769
|
|
|
5751
|
-
// import AnalyticsEngine from '~/analytic/service/analytic/AnalyticsEngine';
|
|
5752
5770
|
const adLinkedObject = (ad) => {
|
|
5753
|
-
|
|
5771
|
+
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
5754
5772
|
const { image9_16: image916, image1_1: image11 } = ad, restAds = __rest(ad, ["image9_16", "image1_1"]);
|
|
5755
|
-
return Object.assign(Object.assign({}, restAds), {
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
// },
|
|
5764
|
-
get advertiser() {
|
|
5773
|
+
return Object.assign(Object.assign({}, restAds), { analytics: {
|
|
5774
|
+
markAsSeen: (placement) => {
|
|
5775
|
+
analyticsEngineInstance.markAdAsViewed(ad, placement);
|
|
5776
|
+
},
|
|
5777
|
+
markLinkAsClicked: (placement) => {
|
|
5778
|
+
analyticsEngineInstance.markAdAsClicked(ad, placement);
|
|
5779
|
+
},
|
|
5780
|
+
}, get advertiser() {
|
|
5765
5781
|
var _a, _b;
|
|
5766
5782
|
const advertiserData = (_a = pullFromCache([
|
|
5767
5783
|
'advertiser',
|
|
@@ -6649,7 +6665,7 @@ function convertFromRaw(message, reactors, event) {
|
|
|
6649
6665
|
*
|
|
6650
6666
|
* Check git blame for previous iteration
|
|
6651
6667
|
*/
|
|
6652
|
-
myReactions: myReactions || ((_a = cache === null || cache === void 0 ? void 0 : cache.data.myReactions) !== null && _a !== void 0 ? _a : []), reactionsCount: reactionCount, subChannelId: messageFeedId, uniqueId: cache ? cache.data.uniqueId : messageId, referenceId });
|
|
6668
|
+
myReactions: myReactions || ((_a = cache === null || cache === void 0 ? void 0 : cache.data.myReactions) !== null && _a !== void 0 ? _a : []), reactionsCount: reactionCount, subChannelId: messageFeedId, uniqueId: cache ? cache.data.uniqueId : messageId, referenceId, syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
6653
6669
|
if (mentionedUsers) {
|
|
6654
6670
|
out.mentionees = mentionedUsers.map(mention => {
|
|
6655
6671
|
if (mention.type === 'channel') {
|
|
@@ -8449,9 +8465,12 @@ const onMessageCreatedMqtt = (callback) => {
|
|
|
8449
8465
|
const onMessageCreatedLocal = (callback) => {
|
|
8450
8466
|
const client = getActiveClient();
|
|
8451
8467
|
const disposers = [
|
|
8452
|
-
createEventSubscriber(client, 'message/onMessageCreated', 'local.message.created',
|
|
8453
|
-
|
|
8454
|
-
|
|
8468
|
+
createEventSubscriber(client, 'message/onMessageCreated', 'local.message.created', async (payload) => {
|
|
8469
|
+
ingestInCache(payload);
|
|
8470
|
+
return payload.messages.forEach(message => {
|
|
8471
|
+
callback(message);
|
|
8472
|
+
});
|
|
8473
|
+
}),
|
|
8455
8474
|
];
|
|
8456
8475
|
return () => {
|
|
8457
8476
|
disposers.forEach(fn => fn());
|
|
@@ -14495,9 +14514,40 @@ getMessages$1.locally = (messageIds) => {
|
|
|
14495
14514
|
const getLocalId = () => `LOCAL_${uuid()}`;
|
|
14496
14515
|
// FIXME: temp solution
|
|
14497
14516
|
let uniqueId;
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14517
|
+
const createMessageOptimistic = (bundle) => {
|
|
14518
|
+
var _a, _b;
|
|
14519
|
+
const client = getActiveClient();
|
|
14520
|
+
if (!client.cache)
|
|
14521
|
+
return;
|
|
14522
|
+
/*
|
|
14523
|
+
* When creating messages optimistically a messageId needs to be added by the
|
|
14524
|
+
* client, created a new variable to allow backward compatibility of API
|
|
14525
|
+
*
|
|
14526
|
+
* Updated to handle client requirement to add messageId while uploading
|
|
14527
|
+
* a message with image.
|
|
14528
|
+
* Temporary!
|
|
14529
|
+
*/
|
|
14530
|
+
uniqueId = bundle.referenceId || getLocalId();
|
|
14531
|
+
const bundleWithMessageId = Object.assign({ messageId: uniqueId, uniqueId }, bundle);
|
|
14532
|
+
client.log('message/createMessage.optimistically', bundleWithMessageId);
|
|
14533
|
+
const subChannel = pullFromCache(['subChannel', 'get', bundle.subChannelId]);
|
|
14534
|
+
if (subChannel) {
|
|
14535
|
+
upsertInCache(['subChannel', 'get', bundle.subChannelId], Object.assign(Object.assign({}, subChannel.data), { messageCount: subChannel.data.messageCount + 1 }));
|
|
14536
|
+
if (subChannel.data.channelId === subChannel.data.subChannelId) {
|
|
14537
|
+
const channel = pullFromCache(['channel', 'get', subChannel.data.channelId]);
|
|
14538
|
+
if (channel === null || channel === void 0 ? void 0 : channel.data) {
|
|
14539
|
+
upsertInCache(['channel', 'get', subChannel.data.channelId], Object.assign(Object.assign({}, channel.data), { messageCount: ((_a = channel.data.messageCount) !== null && _a !== void 0 ? _a : 0) + 1 }));
|
|
14540
|
+
}
|
|
14541
|
+
}
|
|
14542
|
+
}
|
|
14543
|
+
// as reused to update created and updated time, which should be the same
|
|
14544
|
+
const createdTime = new Date().toISOString();
|
|
14545
|
+
const message = Object.assign({ creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_b = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime, syncState: "syncing" /* Amity.SyncState.Syncing */, isDeleted: false }, bundleWithMessageId);
|
|
14546
|
+
const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
|
|
14547
|
+
pushToCache(['message', 'get', message.messageId], message, { cachedAt });
|
|
14548
|
+
fireEvent('local.message.created', { messages: [message] });
|
|
14549
|
+
return message;
|
|
14550
|
+
};
|
|
14501
14551
|
/**
|
|
14502
14552
|
* ```js
|
|
14503
14553
|
* import { createMessage, createQuery, runQuery } from '@amityco/ts-sdk'
|
|
@@ -14523,75 +14573,31 @@ let uniqueId;
|
|
|
14523
14573
|
const createMessage = async (bundle) => {
|
|
14524
14574
|
const client = getActiveClient();
|
|
14525
14575
|
client.log('message/createMessage', bundle);
|
|
14576
|
+
const optimisticData = createMessageOptimistic(bundle);
|
|
14526
14577
|
const referenceId = bundle.referenceId || uniqueId || getLocalId();
|
|
14527
14578
|
uniqueId = undefined;
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
}
|
|
14536
|
-
fireEvent('local.message.created', { messages });
|
|
14537
|
-
return {
|
|
14538
|
-
data: LinkedObject.message(messages[0]),
|
|
14539
|
-
cachedAt,
|
|
14540
|
-
};
|
|
14541
|
-
};
|
|
14542
|
-
/**
|
|
14543
|
-
* ```js
|
|
14544
|
-
* import { createMessage } from '@amityco/ts-sdk'
|
|
14545
|
-
*
|
|
14546
|
-
* const created = createMessage.optimistically({
|
|
14547
|
-
* channelId: 'foobar',
|
|
14548
|
-
* data: { text: 'hello world' }
|
|
14549
|
-
* })
|
|
14550
|
-
* ```
|
|
14551
|
-
*
|
|
14552
|
-
* Creates an {@link Amity.Message} in cache
|
|
14553
|
-
*
|
|
14554
|
-
* @param bundle The data necessary to create a new {@link Amity.Message}
|
|
14555
|
-
* @returns The newly created {@link Amity.Message}
|
|
14556
|
-
*
|
|
14557
|
-
* @category Message API
|
|
14558
|
-
*/
|
|
14559
|
-
createMessage.optimistically = (_a) => {
|
|
14560
|
-
var _b, _c;
|
|
14561
|
-
var { referenceId } = _a, bundle = __rest(_a, ["referenceId"]);
|
|
14562
|
-
const client = getActiveClient();
|
|
14563
|
-
if (!client.cache)
|
|
14564
|
-
return;
|
|
14565
|
-
/*
|
|
14566
|
-
* when creating messages optimistically a messageId needs to be added by the
|
|
14567
|
-
* client, created a new variable so as to allow backward compatibility of API
|
|
14568
|
-
*
|
|
14569
|
-
* Updated to handle client requirement to add messageId while uploading
|
|
14570
|
-
* message with image. Temporary!
|
|
14571
|
-
*/
|
|
14572
|
-
uniqueId = referenceId || getLocalId();
|
|
14573
|
-
const bundleWithMessageId = Object.assign({ messageId: uniqueId, uniqueId }, bundle);
|
|
14574
|
-
client.log('message/createMessage.optimistically', bundleWithMessageId);
|
|
14575
|
-
const subChannel = pullFromCache(['subChannel', 'get', bundle.subChannelId]);
|
|
14576
|
-
if (subChannel) {
|
|
14577
|
-
upsertInCache(['subChannel', 'get', bundle.subChannelId], Object.assign(Object.assign({}, subChannel.data), { messageCount: subChannel.data.messageCount + 1 }));
|
|
14578
|
-
if (subChannel.data.channelId === subChannel.data.subChannelId) {
|
|
14579
|
-
const channel = pullFromCache(['channel', 'get', subChannel.data.channelId]);
|
|
14580
|
-
if (channel === null || channel === void 0 ? void 0 : channel.data) {
|
|
14581
|
-
upsertInCache(['channel', 'get', subChannel.data.channelId], Object.assign(Object.assign({}, channel.data), { messageCount: ((_b = channel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1 }));
|
|
14582
|
-
}
|
|
14579
|
+
try {
|
|
14580
|
+
const { data: payload } = await client.http.post('/api/v5/messages', Object.assign(Object.assign({}, convertParams(bundle)), { referenceId }));
|
|
14581
|
+
const data = await prepareMessagePayload(payload);
|
|
14582
|
+
const { messages } = data;
|
|
14583
|
+
const cachedAt = client.cache && Date.now();
|
|
14584
|
+
if (client.cache) {
|
|
14585
|
+
ingestInCache(data, { cachedAt });
|
|
14583
14586
|
}
|
|
14587
|
+
fireEvent('local.message.created', {
|
|
14588
|
+
messages: [Object.assign(Object.assign({}, messages[0]), { syncState: "synced" /* Amity.SyncState.Synced */ })],
|
|
14589
|
+
});
|
|
14590
|
+
return {
|
|
14591
|
+
data: LinkedObject.message(messages[0]),
|
|
14592
|
+
cachedAt,
|
|
14593
|
+
};
|
|
14594
|
+
}
|
|
14595
|
+
catch (e) {
|
|
14596
|
+
fireEvent('local.message.created', {
|
|
14597
|
+
messages: [Object.assign(Object.assign({}, optimisticData), { syncState: "error" /* Amity.SyncState.Error */ })],
|
|
14598
|
+
});
|
|
14599
|
+
throw e;
|
|
14584
14600
|
}
|
|
14585
|
-
// as reused to update created and updated time, which should be the same
|
|
14586
|
-
const createdTime = new Date().toISOString();
|
|
14587
|
-
const message = Object.assign({ creatorId: client.userId, creatorPrivateId: getActiveUser()._id, channelSegment: ((_c = subChannel === null || subChannel === void 0 ? void 0 : subChannel.data.messageCount) !== null && _c !== void 0 ? _c : 0) + 1, childrenNumber: 0, createdAt: createdTime, updatedAt: createdTime }, bundleWithMessageId);
|
|
14588
|
-
const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
|
|
14589
|
-
pushToCache(['message', 'get', message.messageId], message, { cachedAt });
|
|
14590
|
-
fireEvent('local.message.created', { messages: [message] });
|
|
14591
|
-
return {
|
|
14592
|
-
cachedAt,
|
|
14593
|
-
data: LinkedObject.message(message),
|
|
14594
|
-
};
|
|
14595
14601
|
};
|
|
14596
14602
|
/* end_public_function */
|
|
14597
14603
|
|
|
@@ -15304,67 +15310,106 @@ const getMessage$1 = (messageId, callback) => {
|
|
|
15304
15310
|
};
|
|
15305
15311
|
/* end_public_function */
|
|
15306
15312
|
|
|
15307
|
-
class
|
|
15313
|
+
class PaginationNoPageController {
|
|
15308
15314
|
constructor(queryParams) {
|
|
15309
15315
|
const { http } = getActiveClient();
|
|
15310
15316
|
this.queryParams = queryParams;
|
|
15311
15317
|
this.http = http;
|
|
15312
15318
|
}
|
|
15313
|
-
|
|
15314
|
-
|
|
15319
|
+
async onFetch() {
|
|
15320
|
+
const queryResponse = await this.getRequest(this.queryParams);
|
|
15321
|
+
return queryResponse;
|
|
15315
15322
|
}
|
|
15316
|
-
|
|
15317
|
-
|
|
15323
|
+
}
|
|
15324
|
+
|
|
15325
|
+
class LiveCollectionController {
|
|
15326
|
+
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
15327
|
+
this.paginationController = paginationController;
|
|
15328
|
+
this.queryStreamId = queryStreamId;
|
|
15329
|
+
this.cacheKey = cacheKey;
|
|
15330
|
+
this.callback = callback;
|
|
15318
15331
|
}
|
|
15319
|
-
|
|
15320
|
-
|
|
15332
|
+
async refresh() {
|
|
15333
|
+
try {
|
|
15334
|
+
let result;
|
|
15335
|
+
if (this.paginationController instanceof PaginationNoPageController) {
|
|
15336
|
+
result = await this.paginationController.onFetch();
|
|
15337
|
+
}
|
|
15338
|
+
else {
|
|
15339
|
+
result = await this.paginationController.loadFirstPage();
|
|
15340
|
+
}
|
|
15341
|
+
if (!result)
|
|
15342
|
+
return;
|
|
15343
|
+
await this.persistModel(result);
|
|
15344
|
+
this.persistQueryStream({
|
|
15345
|
+
response: result,
|
|
15346
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
15347
|
+
refresh: true,
|
|
15348
|
+
});
|
|
15349
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
15350
|
+
}
|
|
15351
|
+
catch (e) {
|
|
15352
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
15353
|
+
}
|
|
15321
15354
|
}
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
if (direction ===
|
|
15332
|
-
|
|
15333
|
-
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
15334
|
-
if (direction === 'first') {
|
|
15335
|
-
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
15336
|
-
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
15355
|
+
loadPage({ initial = false, direction = "next" /* Amity.LiveCollectionPageDirection.NEXT */, }) {
|
|
15356
|
+
this.setup();
|
|
15357
|
+
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
15358
|
+
if (initial) {
|
|
15359
|
+
this.refresh();
|
|
15360
|
+
}
|
|
15361
|
+
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
15362
|
+
this.loadPrevPage();
|
|
15363
|
+
}
|
|
15364
|
+
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
15365
|
+
this.loadNextPage();
|
|
15337
15366
|
}
|
|
15338
|
-
if (direction === 'prev')
|
|
15339
|
-
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
15340
|
-
if (direction === 'next')
|
|
15341
|
-
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
15342
|
-
return queryResponse;
|
|
15343
15367
|
}
|
|
15344
|
-
|
|
15345
|
-
|
|
15368
|
+
async loadNextPage() {
|
|
15369
|
+
try {
|
|
15370
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
15371
|
+
return;
|
|
15372
|
+
const result = await this.paginationController.loadNextPage();
|
|
15373
|
+
if (!result)
|
|
15374
|
+
return;
|
|
15375
|
+
await this.persistModel(result);
|
|
15376
|
+
this.persistQueryStream({
|
|
15377
|
+
response: result,
|
|
15378
|
+
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
15379
|
+
});
|
|
15380
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
15381
|
+
}
|
|
15382
|
+
catch (e) {
|
|
15383
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
15384
|
+
}
|
|
15346
15385
|
}
|
|
15347
|
-
|
|
15348
|
-
|
|
15386
|
+
async loadPrevPage() {
|
|
15387
|
+
try {
|
|
15388
|
+
if (this.paginationController instanceof PaginationNoPageController)
|
|
15389
|
+
return;
|
|
15390
|
+
const result = await this.paginationController.loadPreviousPage();
|
|
15391
|
+
if (!result)
|
|
15392
|
+
return;
|
|
15393
|
+
await this.persistModel(result);
|
|
15394
|
+
this.persistQueryStream({
|
|
15395
|
+
response: result,
|
|
15396
|
+
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
15397
|
+
});
|
|
15398
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
15399
|
+
}
|
|
15400
|
+
catch (e) {
|
|
15401
|
+
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
15402
|
+
}
|
|
15349
15403
|
}
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
const processedQueryParams = convertQueryParams$1(queryParams);
|
|
15360
|
-
const { data: queryResponse } = await this.http.get(`/api/v5/messages`, {
|
|
15361
|
-
params: Object.assign(Object.assign({}, processedQueryParams), { options: token
|
|
15362
|
-
? {
|
|
15363
|
-
token,
|
|
15364
|
-
}
|
|
15365
|
-
: Object.assign({}, processedQueryParams.options) }),
|
|
15366
|
-
});
|
|
15367
|
-
return queryResponse;
|
|
15404
|
+
shouldNotify(data) {
|
|
15405
|
+
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
15406
|
+
if (isEqual(this.snapshot, newData))
|
|
15407
|
+
return false;
|
|
15408
|
+
this.snapshot = newData;
|
|
15409
|
+
return true;
|
|
15410
|
+
}
|
|
15411
|
+
getCacheKey() {
|
|
15412
|
+
return this.cacheKey;
|
|
15368
15413
|
}
|
|
15369
15414
|
}
|
|
15370
15415
|
|
|
@@ -15412,6 +15457,7 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
15412
15457
|
var _a, _b, _c, _d, _e;
|
|
15413
15458
|
if (action === 'onCreate') {
|
|
15414
15459
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
15460
|
+
const { referenceId } = payload;
|
|
15415
15461
|
if (!collection)
|
|
15416
15462
|
return;
|
|
15417
15463
|
if (this.query.subChannelId !== (payload === null || payload === void 0 ? void 0 : payload.subChannelId) || !collection)
|
|
@@ -15441,10 +15487,10 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
15441
15487
|
return;
|
|
15442
15488
|
if ((!this.query.sortBy || this.query.sortBy === 'segmentDesc') &&
|
|
15443
15489
|
!this.paginationController.getPrevToken()) {
|
|
15444
|
-
collection.data = [...new Set([payload.messageId, ...collection.data])];
|
|
15490
|
+
collection.data = [...new Set([referenceId !== null && referenceId !== void 0 ? referenceId : payload.messageId, ...collection.data])];
|
|
15445
15491
|
}
|
|
15446
15492
|
if (this.query.sortBy === 'segmentAsc' && !this.paginationController.getNextToken()) {
|
|
15447
|
-
collection.data = [...new Set([...collection.data, payload.messageId])];
|
|
15493
|
+
collection.data = [...new Set([...collection.data, referenceId !== null && referenceId !== void 0 ? referenceId : payload.messageId])];
|
|
15448
15494
|
}
|
|
15449
15495
|
pushToCache(this.cacheKey, collection);
|
|
15450
15496
|
}
|
|
@@ -15456,106 +15502,67 @@ class MessageQueryStreamController extends QueryStreamController {
|
|
|
15456
15502
|
}
|
|
15457
15503
|
}
|
|
15458
15504
|
|
|
15459
|
-
class
|
|
15505
|
+
class PaginationController {
|
|
15460
15506
|
constructor(queryParams) {
|
|
15461
15507
|
const { http } = getActiveClient();
|
|
15462
15508
|
this.queryParams = queryParams;
|
|
15463
15509
|
this.http = http;
|
|
15464
15510
|
}
|
|
15465
|
-
|
|
15466
|
-
|
|
15467
|
-
return queryResponse;
|
|
15468
|
-
}
|
|
15469
|
-
}
|
|
15470
|
-
|
|
15471
|
-
class LiveCollectionController {
|
|
15472
|
-
constructor(paginationController, queryStreamId, cacheKey, callback) {
|
|
15473
|
-
this.paginationController = paginationController;
|
|
15474
|
-
this.queryStreamId = queryStreamId;
|
|
15475
|
-
this.cacheKey = cacheKey;
|
|
15476
|
-
this.callback = callback;
|
|
15511
|
+
loadFirstPage() {
|
|
15512
|
+
return this.onFetch("first" /* Amity.LiveCollectionPageDirection.FIRST */);
|
|
15477
15513
|
}
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
let result;
|
|
15481
|
-
if (this.paginationController instanceof PaginationNoPageController) {
|
|
15482
|
-
result = await this.paginationController.onFetch();
|
|
15483
|
-
}
|
|
15484
|
-
else {
|
|
15485
|
-
result = await this.paginationController.loadFirstPage();
|
|
15486
|
-
}
|
|
15487
|
-
if (!result)
|
|
15488
|
-
return;
|
|
15489
|
-
await this.persistModel(result);
|
|
15490
|
-
this.persistQueryStream({
|
|
15491
|
-
response: result,
|
|
15492
|
-
direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */,
|
|
15493
|
-
refresh: true,
|
|
15494
|
-
});
|
|
15495
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
15496
|
-
}
|
|
15497
|
-
catch (e) {
|
|
15498
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
15499
|
-
}
|
|
15514
|
+
loadNextPage() {
|
|
15515
|
+
return this.onFetch("next" /* Amity.LiveCollectionPageDirection.NEXT */);
|
|
15500
15516
|
}
|
|
15501
|
-
|
|
15502
|
-
this.
|
|
15503
|
-
this.notifyChange({ origin: "local" /* Amity.LiveDataOrigin.LOCAL */, loading: true });
|
|
15504
|
-
if (initial) {
|
|
15505
|
-
this.refresh();
|
|
15506
|
-
}
|
|
15507
|
-
else if (direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */) {
|
|
15508
|
-
this.loadPrevPage();
|
|
15509
|
-
}
|
|
15510
|
-
else if (direction === "next" /* Amity.LiveCollectionPageDirection.NEXT */) {
|
|
15511
|
-
this.loadNextPage();
|
|
15512
|
-
}
|
|
15517
|
+
loadPreviousPage() {
|
|
15518
|
+
return this.onFetch("prev" /* Amity.LiveCollectionPageDirection.PREV */);
|
|
15513
15519
|
}
|
|
15514
|
-
async
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
this.
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
15520
|
+
async onFetch(direction = "first" /* Amity.LiveCollectionPageDirection.FIRST */) {
|
|
15521
|
+
var _a, _b, _c, _d;
|
|
15522
|
+
if (direction === 'prev' && !this.previousToken)
|
|
15523
|
+
return;
|
|
15524
|
+
if (direction === 'next' && !this.nextToken)
|
|
15525
|
+
return;
|
|
15526
|
+
let token;
|
|
15527
|
+
if (direction === 'prev')
|
|
15528
|
+
token = this.previousToken;
|
|
15529
|
+
if (direction === 'next')
|
|
15530
|
+
token = this.nextToken;
|
|
15531
|
+
const queryResponse = await this.getRequest(this.queryParams, token);
|
|
15532
|
+
if (direction === 'first') {
|
|
15533
|
+
this.nextToken = (_a = queryResponse.paging) === null || _a === void 0 ? void 0 : _a.next;
|
|
15534
|
+
this.previousToken = (_b = queryResponse.paging) === null || _b === void 0 ? void 0 : _b.previous;
|
|
15530
15535
|
}
|
|
15536
|
+
if (direction === 'prev')
|
|
15537
|
+
this.previousToken = (_c = queryResponse.paging) === null || _c === void 0 ? void 0 : _c.previous;
|
|
15538
|
+
if (direction === 'next')
|
|
15539
|
+
this.nextToken = (_d = queryResponse.paging) === null || _d === void 0 ? void 0 : _d.next;
|
|
15540
|
+
return queryResponse;
|
|
15531
15541
|
}
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
if (this.paginationController instanceof PaginationNoPageController)
|
|
15535
|
-
return;
|
|
15536
|
-
const result = await this.paginationController.loadPreviousPage();
|
|
15537
|
-
if (!result)
|
|
15538
|
-
return;
|
|
15539
|
-
await this.persistModel(result);
|
|
15540
|
-
this.persistQueryStream({
|
|
15541
|
-
response: result,
|
|
15542
|
-
direction: "prev" /* Amity.LiveCollectionPageDirection.PREV */,
|
|
15543
|
-
});
|
|
15544
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false });
|
|
15545
|
-
}
|
|
15546
|
-
catch (e) {
|
|
15547
|
-
this.notifyChange({ origin: "server" /* Amity.LiveDataOrigin.SERVER */, loading: false, error: e });
|
|
15548
|
-
}
|
|
15542
|
+
getNextToken() {
|
|
15543
|
+
return this.nextToken;
|
|
15549
15544
|
}
|
|
15550
|
-
|
|
15551
|
-
|
|
15552
|
-
if (isEqual(this.snapshot, newData))
|
|
15553
|
-
return false;
|
|
15554
|
-
this.snapshot = newData;
|
|
15555
|
-
return true;
|
|
15545
|
+
getPrevToken() {
|
|
15546
|
+
return this.previousToken;
|
|
15556
15547
|
}
|
|
15557
|
-
|
|
15558
|
-
|
|
15548
|
+
}
|
|
15549
|
+
|
|
15550
|
+
/* eslint-disable no-use-before-define */
|
|
15551
|
+
/**
|
|
15552
|
+
* TODO: handle cache receive cache option, and cache policy
|
|
15553
|
+
* TODO: check if querybyIds is supported
|
|
15554
|
+
*/
|
|
15555
|
+
class MessagePaginationController extends PaginationController {
|
|
15556
|
+
async getRequest(queryParams, token) {
|
|
15557
|
+
const processedQueryParams = convertQueryParams$1(queryParams);
|
|
15558
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/messages`, {
|
|
15559
|
+
params: Object.assign(Object.assign({}, processedQueryParams), { options: token
|
|
15560
|
+
? {
|
|
15561
|
+
token,
|
|
15562
|
+
}
|
|
15563
|
+
: Object.assign({}, processedQueryParams.options) }),
|
|
15564
|
+
});
|
|
15565
|
+
return queryResponse;
|
|
15559
15566
|
}
|
|
15560
15567
|
}
|
|
15561
15568
|
|
|
@@ -15570,25 +15577,10 @@ class MessageLiveCollectionController extends LiveCollectionController {
|
|
|
15570
15577
|
this.callback = callback.bind(this);
|
|
15571
15578
|
this.loadPage({ initial: true });
|
|
15572
15579
|
}
|
|
15573
|
-
setup() {
|
|
15574
|
-
var _a;
|
|
15575
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
15576
|
-
if (!collection) {
|
|
15577
|
-
pushToCache(this.cacheKey, {
|
|
15578
|
-
data: [],
|
|
15579
|
-
query: this.query,
|
|
15580
|
-
});
|
|
15581
|
-
}
|
|
15582
|
-
}
|
|
15583
|
-
async persistModel(response) {
|
|
15584
|
-
await this.queryStreamController.saveToMainDB(response);
|
|
15585
|
-
}
|
|
15586
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
15587
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
15588
|
-
}
|
|
15589
15580
|
startSubscription() {
|
|
15590
15581
|
return this.queryStreamController.subscribeRTE([
|
|
15591
15582
|
{ fn: onMessageCreatedMqtt, action: 'onCreate' },
|
|
15583
|
+
{ fn: onMessageCreatedLocal, action: 'onCreate' },
|
|
15592
15584
|
{ fn: onMessageDeleted, action: 'onDelete' },
|
|
15593
15585
|
{ fn: onMessageUpdated, action: 'onUpdate' },
|
|
15594
15586
|
{ fn: onMessageFlagged, action: 'onFlagged' },
|
|
@@ -15665,6 +15657,22 @@ class MessageLiveCollectionController extends LiveCollectionController {
|
|
|
15665
15657
|
});
|
|
15666
15658
|
return messages;
|
|
15667
15659
|
}
|
|
15660
|
+
setup() {
|
|
15661
|
+
var _a;
|
|
15662
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
15663
|
+
if (!collection) {
|
|
15664
|
+
pushToCache(this.cacheKey, {
|
|
15665
|
+
data: [],
|
|
15666
|
+
query: this.query,
|
|
15667
|
+
});
|
|
15668
|
+
}
|
|
15669
|
+
}
|
|
15670
|
+
async persistModel(response) {
|
|
15671
|
+
await this.queryStreamController.saveToMainDB(response);
|
|
15672
|
+
}
|
|
15673
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
15674
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
15675
|
+
}
|
|
15668
15676
|
}
|
|
15669
15677
|
|
|
15670
15678
|
/* eslint-disable no-use-before-define */
|
|
@@ -21874,7 +21882,11 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
21874
21882
|
* @category Post Live Object
|
|
21875
21883
|
*/
|
|
21876
21884
|
const getPost = (postId, callback) => {
|
|
21877
|
-
|
|
21885
|
+
const responder = (snapshot) => {
|
|
21886
|
+
const { data } = snapshot;
|
|
21887
|
+
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
21888
|
+
};
|
|
21889
|
+
return liveObject(postId, responder, 'postId', getPost$1, [
|
|
21878
21890
|
onPostApproved,
|
|
21879
21891
|
onPostDeclined,
|
|
21880
21892
|
(callback) => {
|
|
@@ -23060,7 +23072,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
23060
23072
|
getPoll: getPoll
|
|
23061
23073
|
});
|
|
23062
23074
|
|
|
23063
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
23075
|
+
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-----";
|
|
23064
23076
|
/*
|
|
23065
23077
|
* The crypto algorithm used for importing key and signing string
|
|
23066
23078
|
*/
|
|
@@ -24507,20 +24519,27 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
24507
24519
|
getGlobalStoryTargets: getGlobalStoryTargets
|
|
24508
24520
|
});
|
|
24509
24521
|
|
|
24510
|
-
const
|
|
24511
|
-
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
|
|
24515
|
-
};
|
|
24522
|
+
const convertToInternalAd = (ad) => {
|
|
24523
|
+
return Object.assign(Object.assign({}, ad), { endAt: ad.endAt ? ad.endAt : null });
|
|
24524
|
+
};
|
|
24525
|
+
const convertToInternalAdvertiser = (advertiser) => {
|
|
24526
|
+
return Object.assign({}, advertiser);
|
|
24516
24527
|
};
|
|
24517
24528
|
const getNetworkAds = async () => {
|
|
24518
24529
|
const client = getActiveClient();
|
|
24519
24530
|
const { data } = await client.http.get('/api/v1/ads/me');
|
|
24520
|
-
const
|
|
24521
|
-
|
|
24522
|
-
|
|
24523
|
-
|
|
24531
|
+
const internalAds = data.ads.map(convertToInternalAd);
|
|
24532
|
+
const internalAdvertisers = data.advertisers.map(convertToInternalAdvertiser);
|
|
24533
|
+
ingestInCache({
|
|
24534
|
+
ads: internalAds,
|
|
24535
|
+
advertisers: internalAdvertisers,
|
|
24536
|
+
files: data.files,
|
|
24537
|
+
});
|
|
24538
|
+
pushToCache(['ad', 'setting'], data.settings);
|
|
24539
|
+
return {
|
|
24540
|
+
ads: internalAds.map(LinkedObject.ad),
|
|
24541
|
+
settings: data.settings,
|
|
24542
|
+
};
|
|
24524
24543
|
};
|
|
24525
24544
|
|
|
24526
24545
|
var index = /*#__PURE__*/Object.freeze({
|