@amityco/ts-sdk 7.12.1-3748bf9.0 → 7.12.1-4d56f961.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/dist/@types/core/model.d.ts +2 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +4 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +3 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/product.d.ts +76 -0
- package/dist/@types/domains/product.d.ts.map +1 -0
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/client/api/getProductCatalogueSetting.d.ts +15 -0
- package/dist/client/api/getProductCatalogueSetting.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +318 -58
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +295 -36
- package/dist/index.umd.js +2 -2
- package/dist/postRepository/api/createPost.d.ts +2 -0
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts +2 -0
- package/dist/postRepository/api/editPost.d.ts.map +1 -1
- package/dist/productRepository/index.d.ts +2 -0
- package/dist/productRepository/index.d.ts.map +1 -0
- package/dist/productRepository/internalApi/getProduct.d.ts +5 -0
- package/dist/productRepository/internalApi/getProduct.d.ts.map +1 -0
- package/dist/productRepository/internalApi/index.d.ts +2 -0
- package/dist/productRepository/internalApi/index.d.ts.map +1 -0
- package/dist/productRepository/observers/getProduct.d.ts +21 -0
- package/dist/productRepository/observers/getProduct.d.ts.map +1 -0
- package/dist/productRepository/observers/index.d.ts +3 -0
- package/dist/productRepository/observers/index.d.ts.map +1 -0
- package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts +15 -0
- package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts.map +1 -0
- package/dist/productRepository/observers/searchProducts/PaginationController.d.ts +5 -0
- package/dist/productRepository/observers/searchProducts/PaginationController.d.ts.map +1 -0
- package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts +8 -0
- package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts.map +1 -0
- package/dist/productRepository/observers/searchProducts.d.ts +25 -0
- package/dist/productRepository/observers/searchProducts.d.ts.map +1 -0
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/productTagLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/productTagLinkedObject.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -733,6 +733,7 @@ const PAYLOAD2MODEL = {
|
|
|
733
733
|
events: 'event',
|
|
734
734
|
viewers: 'viewer',
|
|
735
735
|
eventResponses: 'eventResponse',
|
|
736
|
+
products: 'product',
|
|
736
737
|
};
|
|
737
738
|
/** hidden */
|
|
738
739
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -26155,6 +26156,29 @@ const getShareableLinkConfiguration = async () => {
|
|
|
26155
26156
|
return data;
|
|
26156
26157
|
};
|
|
26157
26158
|
|
|
26159
|
+
/* begin_public_function
|
|
26160
|
+
id: client.getProductCatalogueSetting
|
|
26161
|
+
*/
|
|
26162
|
+
/**
|
|
26163
|
+
* ```js
|
|
26164
|
+
* import { getProductCatalogueSetting } from '@amityco/ts-sdk'
|
|
26165
|
+
* const productCatalogueSetting = await getProductCatalogueSetting()
|
|
26166
|
+
* ```
|
|
26167
|
+
*
|
|
26168
|
+
* Fetches a {@link Amity.ProductCatalogueSetting} object
|
|
26169
|
+
*
|
|
26170
|
+
* @returns A Promise of {@link Amity.ProductCatalogueSetting} object
|
|
26171
|
+
*
|
|
26172
|
+
* @category Client API
|
|
26173
|
+
* @async
|
|
26174
|
+
*/
|
|
26175
|
+
const getProductCatalogueSetting = async () => {
|
|
26176
|
+
const client = getActiveClient();
|
|
26177
|
+
const { data } = await client.http.get(`/api/v3/network-settings/product-catalogue`);
|
|
26178
|
+
return data;
|
|
26179
|
+
};
|
|
26180
|
+
/* end_public_function */
|
|
26181
|
+
|
|
26158
26182
|
/**
|
|
26159
26183
|
* Retrieves a pair of {@link Amity.Tokens} necessary for connection
|
|
26160
26184
|
*
|
|
@@ -26647,7 +26671,7 @@ const getUserUnread = (callback) => {
|
|
|
26647
26671
|
};
|
|
26648
26672
|
};
|
|
26649
26673
|
|
|
26650
|
-
var index$
|
|
26674
|
+
var index$s = /*#__PURE__*/Object.freeze({
|
|
26651
26675
|
__proto__: null,
|
|
26652
26676
|
getActiveClient: getActiveClient,
|
|
26653
26677
|
getActiveUser: getActiveUser,
|
|
@@ -26667,6 +26691,7 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
26667
26691
|
getLinkPreviewMetadata: getLinkPreviewMetadata,
|
|
26668
26692
|
getSocialSettings: getSocialSettings,
|
|
26669
26693
|
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26694
|
+
getProductCatalogueSetting: getProductCatalogueSetting,
|
|
26670
26695
|
loginAsVisitor: loginAsVisitor,
|
|
26671
26696
|
loginAsBot: loginAsBot,
|
|
26672
26697
|
getCurrentUser: getCurrentUser,
|
|
@@ -27867,7 +27892,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27867
27892
|
};
|
|
27868
27893
|
/* end_public_function */
|
|
27869
27894
|
|
|
27870
|
-
var index$
|
|
27895
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
27871
27896
|
__proto__: null,
|
|
27872
27897
|
blockUser: blockUser,
|
|
27873
27898
|
unBlockUser: unBlockUser,
|
|
@@ -29975,6 +30000,11 @@ const communityLinkedObject = (community) => {
|
|
|
29975
30000
|
} });
|
|
29976
30001
|
};
|
|
29977
30002
|
|
|
30003
|
+
const productTagLinkedObject = (productTag) => {
|
|
30004
|
+
var _a;
|
|
30005
|
+
return Object.assign(Object.assign({}, productTag), { product: (_a = pullFromCache(['product', 'get', productTag.productId])) === null || _a === void 0 ? void 0 : _a.data });
|
|
30006
|
+
};
|
|
30007
|
+
|
|
29978
30008
|
const postLinkedObject = (post) => {
|
|
29979
30009
|
return shallowClone(post, {
|
|
29980
30010
|
childrenPosts: post.children
|
|
@@ -29987,6 +30017,9 @@ const postLinkedObject = (post) => {
|
|
|
29987
30017
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
29988
30018
|
},
|
|
29989
30019
|
},
|
|
30020
|
+
get productTags() {
|
|
30021
|
+
return post.productTags.map(productTag => productTagLinkedObject(productTag));
|
|
30022
|
+
},
|
|
29990
30023
|
get latestComments() {
|
|
29991
30024
|
if (!post.comments)
|
|
29992
30025
|
return [];
|
|
@@ -31976,9 +32009,9 @@ var AmityUserSearchMatchType;
|
|
|
31976
32009
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
31977
32010
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
31978
32011
|
|
|
31979
|
-
var index$
|
|
32012
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
31980
32013
|
__proto__: null,
|
|
31981
|
-
Relationship: index$
|
|
32014
|
+
Relationship: index$r,
|
|
31982
32015
|
getUserByIds: getUserByIds,
|
|
31983
32016
|
updateUser: updateUser,
|
|
31984
32017
|
flagUser: flagUser,
|
|
@@ -32381,7 +32414,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
32381
32414
|
};
|
|
32382
32415
|
/* end_public_function */
|
|
32383
32416
|
|
|
32384
|
-
var index$
|
|
32417
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
32385
32418
|
__proto__: null,
|
|
32386
32419
|
getFile: getFile,
|
|
32387
32420
|
uploadFile: uploadFile,
|
|
@@ -34193,7 +34226,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
34193
34226
|
};
|
|
34194
34227
|
/* end_public_function */
|
|
34195
34228
|
|
|
34196
|
-
var index$
|
|
34229
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
34197
34230
|
__proto__: null,
|
|
34198
34231
|
addReaction: addReaction,
|
|
34199
34232
|
removeReaction: removeReaction,
|
|
@@ -35965,7 +35998,7 @@ const getMessages = (params, callback, config) => {
|
|
|
35965
35998
|
};
|
|
35966
35999
|
/* end_public_function */
|
|
35967
36000
|
|
|
35968
|
-
var index$
|
|
36001
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
35969
36002
|
__proto__: null,
|
|
35970
36003
|
createMessage: createMessage,
|
|
35971
36004
|
updateMessage: updateMessage,
|
|
@@ -36491,7 +36524,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
36491
36524
|
};
|
|
36492
36525
|
/* end_public_function */
|
|
36493
36526
|
|
|
36494
|
-
var index$
|
|
36527
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
36495
36528
|
__proto__: null,
|
|
36496
36529
|
getSubChannelByIds: getSubChannels$1,
|
|
36497
36530
|
createSubChannel: createSubChannel,
|
|
@@ -37818,7 +37851,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
37818
37851
|
};
|
|
37819
37852
|
/* end_public_function */
|
|
37820
37853
|
|
|
37821
|
-
var index$
|
|
37854
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
37822
37855
|
__proto__: null,
|
|
37823
37856
|
addMembers: addMembers$1,
|
|
37824
37857
|
removeMembers: removeMembers$1,
|
|
@@ -38021,7 +38054,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
38021
38054
|
};
|
|
38022
38055
|
/* end_public_function */
|
|
38023
38056
|
|
|
38024
|
-
var index$
|
|
38057
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
38025
38058
|
__proto__: null,
|
|
38026
38059
|
addRole: addRole,
|
|
38027
38060
|
removeRole: removeRole,
|
|
@@ -38031,10 +38064,10 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38031
38064
|
unmuteMembers: unmuteMembers
|
|
38032
38065
|
});
|
|
38033
38066
|
|
|
38034
|
-
var index$
|
|
38067
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
38035
38068
|
__proto__: null,
|
|
38036
|
-
Membership: index$
|
|
38037
|
-
Moderation: index$
|
|
38069
|
+
Membership: index$l,
|
|
38070
|
+
Moderation: index$k,
|
|
38038
38071
|
getChannelByIds: getChannelByIds$1,
|
|
38039
38072
|
createChannel: createChannel,
|
|
38040
38073
|
updateChannel: updateChannel,
|
|
@@ -39437,7 +39470,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
39437
39470
|
};
|
|
39438
39471
|
/* end_public_function */
|
|
39439
39472
|
|
|
39440
|
-
var index$
|
|
39473
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
39441
39474
|
__proto__: null,
|
|
39442
39475
|
addMembers: addMembers,
|
|
39443
39476
|
removeMembers: removeMembers,
|
|
@@ -40688,7 +40721,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
40688
40721
|
};
|
|
40689
40722
|
/* end_public_function */
|
|
40690
40723
|
|
|
40691
|
-
var index$
|
|
40724
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
40692
40725
|
__proto__: null,
|
|
40693
40726
|
addRoles: addRoles,
|
|
40694
40727
|
removeRoles: removeRoles,
|
|
@@ -40696,10 +40729,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
40696
40729
|
unbanMembers: unbanMembers
|
|
40697
40730
|
});
|
|
40698
40731
|
|
|
40699
|
-
var index$
|
|
40732
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
40700
40733
|
__proto__: null,
|
|
40701
|
-
Moderation: index$
|
|
40702
|
-
Membership: index$
|
|
40734
|
+
Moderation: index$h,
|
|
40735
|
+
Membership: index$i,
|
|
40703
40736
|
getCommunityByIds: getCommunities$1,
|
|
40704
40737
|
createCommunity: createCommunity,
|
|
40705
40738
|
updateCommunity: updateCommunity,
|
|
@@ -40933,7 +40966,7 @@ const getCategories = (params, callback, config) => {
|
|
|
40933
40966
|
};
|
|
40934
40967
|
/* end_public_function */
|
|
40935
40968
|
|
|
40936
|
-
var index$
|
|
40969
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
40937
40970
|
__proto__: null,
|
|
40938
40971
|
getCategory: getCategory,
|
|
40939
40972
|
getCategories: getCategories
|
|
@@ -41992,7 +42025,7 @@ const getComments = (params, callback, config) => {
|
|
|
41992
42025
|
};
|
|
41993
42026
|
/* end_public_function */
|
|
41994
42027
|
|
|
41995
|
-
var index$
|
|
42028
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
41996
42029
|
__proto__: null,
|
|
41997
42030
|
getCommentByIds: getCommentByIds,
|
|
41998
42031
|
createComment: createComment,
|
|
@@ -42663,7 +42696,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
42663
42696
|
};
|
|
42664
42697
|
/* end_public_function */
|
|
42665
42698
|
|
|
42666
|
-
var index$
|
|
42699
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
42667
42700
|
__proto__: null,
|
|
42668
42701
|
queryGlobalFeed: queryGlobalFeed,
|
|
42669
42702
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -42778,7 +42811,15 @@ const createPost = async (bundle) => {
|
|
|
42778
42811
|
// eslint-disable-next-line no-param-reassign
|
|
42779
42812
|
delete bundle.dataType;
|
|
42780
42813
|
}
|
|
42781
|
-
const {
|
|
42814
|
+
const { attachments } = bundle;
|
|
42815
|
+
const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
|
|
42816
|
+
? attachments.map(attachment => {
|
|
42817
|
+
if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
|
|
42818
|
+
return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
|
|
42819
|
+
return attachment;
|
|
42820
|
+
})
|
|
42821
|
+
: attachments;
|
|
42822
|
+
const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { attachments: processedAttachments }));
|
|
42782
42823
|
fireEvent('post.created', payload);
|
|
42783
42824
|
const data = preparePostPayload(payload);
|
|
42784
42825
|
const cachedAt = client.cache && Date.now();
|
|
@@ -42815,7 +42856,15 @@ const createPost = async (bundle) => {
|
|
|
42815
42856
|
const editPost = async (postId, patch) => {
|
|
42816
42857
|
const client = getActiveClient();
|
|
42817
42858
|
client.log('user/editPost', patch);
|
|
42818
|
-
const {
|
|
42859
|
+
const { attachments } = patch;
|
|
42860
|
+
const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
|
|
42861
|
+
? attachments.map(attachment => {
|
|
42862
|
+
if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
|
|
42863
|
+
return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
|
|
42864
|
+
return attachment;
|
|
42865
|
+
})
|
|
42866
|
+
: attachments;
|
|
42867
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
|
|
42819
42868
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
42820
42869
|
const cachedAt = client.cache && Date.now();
|
|
42821
42870
|
if (client.cache)
|
|
@@ -45459,7 +45508,7 @@ const getRooms = (params, callback, config) => {
|
|
|
45459
45508
|
};
|
|
45460
45509
|
/* end_public_function */
|
|
45461
45510
|
|
|
45462
|
-
var index$
|
|
45511
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
45463
45512
|
__proto__: null,
|
|
45464
45513
|
createRoom: createRoom,
|
|
45465
45514
|
updateRoom: updateRoom,
|
|
@@ -45755,7 +45804,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
|
|
|
45755
45804
|
};
|
|
45756
45805
|
/* end_public_function */
|
|
45757
45806
|
|
|
45758
|
-
var index$
|
|
45807
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
45759
45808
|
__proto__: null,
|
|
45760
45809
|
getPostByIds: getPostByIds,
|
|
45761
45810
|
createPost: createPost,
|
|
@@ -46365,7 +46414,7 @@ const getStreams = (params, callback, config) => {
|
|
|
46365
46414
|
};
|
|
46366
46415
|
};
|
|
46367
46416
|
|
|
46368
|
-
var index$
|
|
46417
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
46369
46418
|
__proto__: null,
|
|
46370
46419
|
createStream: createStream,
|
|
46371
46420
|
updateStream: updateStream,
|
|
@@ -46668,7 +46717,7 @@ const stopHeartbeat = (roomId) => {
|
|
|
46668
46717
|
};
|
|
46669
46718
|
/* end_public_function */
|
|
46670
46719
|
|
|
46671
|
-
var index$
|
|
46720
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
46672
46721
|
__proto__: null,
|
|
46673
46722
|
getRoomOnlineUsers: getRoomOnlineUsers,
|
|
46674
46723
|
getRoomUserCount: getRoomUserCount,
|
|
@@ -46976,7 +47025,7 @@ const getPoll = (pollId, callback) => {
|
|
|
46976
47025
|
};
|
|
46977
47026
|
/* end_public_function */
|
|
46978
47027
|
|
|
46979
|
-
var index$
|
|
47028
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
46980
47029
|
__proto__: null,
|
|
46981
47030
|
createPoll: createPoll,
|
|
46982
47031
|
closePoll: closePoll,
|
|
@@ -47280,7 +47329,7 @@ const getPlayer = async (parameters) => {
|
|
|
47280
47329
|
return video;
|
|
47281
47330
|
};
|
|
47282
47331
|
|
|
47283
|
-
var index$
|
|
47332
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
47284
47333
|
__proto__: null,
|
|
47285
47334
|
getPlayer: getPlayer
|
|
47286
47335
|
});
|
|
@@ -48453,7 +48502,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
48453
48502
|
};
|
|
48454
48503
|
};
|
|
48455
48504
|
|
|
48456
|
-
var index$
|
|
48505
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
48457
48506
|
__proto__: null,
|
|
48458
48507
|
createImageStory: createImageStory,
|
|
48459
48508
|
createVideoStory: createVideoStory,
|
|
@@ -48490,7 +48539,7 @@ const getNetworkAds = async () => {
|
|
|
48490
48539
|
};
|
|
48491
48540
|
};
|
|
48492
48541
|
|
|
48493
|
-
var index$
|
|
48542
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
48494
48543
|
__proto__: null,
|
|
48495
48544
|
getNetworkAds: getNetworkAds
|
|
48496
48545
|
});
|
|
@@ -48881,7 +48930,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
48881
48930
|
};
|
|
48882
48931
|
/* end_public_function */
|
|
48883
48932
|
|
|
48884
|
-
var index$
|
|
48933
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
48885
48934
|
__proto__: null,
|
|
48886
48935
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
48887
48936
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -49179,7 +49228,7 @@ const getInvitations = (params, callback) => {
|
|
|
49179
49228
|
};
|
|
49180
49229
|
};
|
|
49181
49230
|
|
|
49182
|
-
var index$
|
|
49231
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
49183
49232
|
__proto__: null,
|
|
49184
49233
|
cancelInvitation: cancelInvitation,
|
|
49185
49234
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
@@ -49328,7 +49377,7 @@ const getReactions = (postId, callback) => {
|
|
|
49328
49377
|
};
|
|
49329
49378
|
};
|
|
49330
49379
|
|
|
49331
|
-
var index$
|
|
49380
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
49332
49381
|
__proto__: null,
|
|
49333
49382
|
createReaction: createReaction,
|
|
49334
49383
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
@@ -49811,7 +49860,7 @@ const getMyEvents = (params, callback, config) => {
|
|
|
49811
49860
|
};
|
|
49812
49861
|
};
|
|
49813
49862
|
|
|
49814
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
49863
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
49815
49864
|
__proto__: null,
|
|
49816
49865
|
createEvent: createEvent,
|
|
49817
49866
|
updateEvent: updateEvent,
|
|
@@ -49832,4 +49881,214 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
49832
49881
|
getRSVPs: getRSVPs
|
|
49833
49882
|
});
|
|
49834
49883
|
|
|
49835
|
-
|
|
49884
|
+
const getProduct$1 = async (productId) => {
|
|
49885
|
+
const client = getActiveClient();
|
|
49886
|
+
client.log('product/getProduct', productId);
|
|
49887
|
+
isInTombstone('product', productId);
|
|
49888
|
+
let payload;
|
|
49889
|
+
try {
|
|
49890
|
+
const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
|
|
49891
|
+
payload = response.data;
|
|
49892
|
+
}
|
|
49893
|
+
catch (error) {
|
|
49894
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
49895
|
+
pushToTombstone('product', productId);
|
|
49896
|
+
}
|
|
49897
|
+
throw error;
|
|
49898
|
+
}
|
|
49899
|
+
const cachedAt = client.cache && Date.now();
|
|
49900
|
+
if (client.cache)
|
|
49901
|
+
ingestInCache(payload, { cachedAt });
|
|
49902
|
+
const { products } = payload;
|
|
49903
|
+
const result = products.find(product => product.productId === productId);
|
|
49904
|
+
return {
|
|
49905
|
+
data: result,
|
|
49906
|
+
cachedAt,
|
|
49907
|
+
};
|
|
49908
|
+
};
|
|
49909
|
+
getProduct$1.locally = (productId) => {
|
|
49910
|
+
const client = getActiveClient();
|
|
49911
|
+
client.log('product/getProduct.locally', productId);
|
|
49912
|
+
if (!client.cache)
|
|
49913
|
+
return;
|
|
49914
|
+
const cached = pullFromCache(['product', 'get', productId]);
|
|
49915
|
+
if (!cached)
|
|
49916
|
+
return;
|
|
49917
|
+
return {
|
|
49918
|
+
data: cached.data,
|
|
49919
|
+
cachedAt: cached.cachedAt,
|
|
49920
|
+
};
|
|
49921
|
+
};
|
|
49922
|
+
|
|
49923
|
+
/* begin_public_function
|
|
49924
|
+
id: product.get
|
|
49925
|
+
*/
|
|
49926
|
+
/**
|
|
49927
|
+
* ```js
|
|
49928
|
+
* import { ProductRepository } from '@amityco/ts-sdk';
|
|
49929
|
+
*
|
|
49930
|
+
* let product;
|
|
49931
|
+
*
|
|
49932
|
+
* const unsub = ProductRepository.getProduct(productId, response => {
|
|
49933
|
+
* product = response.data;
|
|
49934
|
+
* });
|
|
49935
|
+
* ```
|
|
49936
|
+
*
|
|
49937
|
+
* Observe all mutation on a given {@link Amity.Product}
|
|
49938
|
+
*
|
|
49939
|
+
* @param productId the ID of the product to observe
|
|
49940
|
+
* @param callback the function to call when new data are available
|
|
49941
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
|
|
49942
|
+
*
|
|
49943
|
+
* @category Product Live Object
|
|
49944
|
+
*/
|
|
49945
|
+
const getProduct = (productId, callback) => {
|
|
49946
|
+
const responder = (snapshot) => {
|
|
49947
|
+
callback(snapshot);
|
|
49948
|
+
};
|
|
49949
|
+
return liveObject(productId, responder, 'productId', getProduct$1, []);
|
|
49950
|
+
};
|
|
49951
|
+
/* end_public_function */
|
|
49952
|
+
|
|
49953
|
+
class SearchProductPaginationController extends PaginationController {
|
|
49954
|
+
async getRequest(queryParams, token) {
|
|
49955
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
49956
|
+
const options = token ? { token } : { limit };
|
|
49957
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
|
|
49958
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
49959
|
+
});
|
|
49960
|
+
return queryResponse;
|
|
49961
|
+
}
|
|
49962
|
+
}
|
|
49963
|
+
|
|
49964
|
+
class SearchProductQueryStreamController extends QueryStreamController {
|
|
49965
|
+
constructor(query, cacheKey, notifyChange) {
|
|
49966
|
+
super(query, cacheKey);
|
|
49967
|
+
this.notifyChange = notifyChange;
|
|
49968
|
+
}
|
|
49969
|
+
// eslint-disable-next-line class-methods-use-this
|
|
49970
|
+
saveToMainDB(response) {
|
|
49971
|
+
const client = getActiveClient();
|
|
49972
|
+
const cachedAt = client.cache && Date.now();
|
|
49973
|
+
if (client.cache) {
|
|
49974
|
+
ingestInCache(response, { cachedAt });
|
|
49975
|
+
}
|
|
49976
|
+
}
|
|
49977
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
49978
|
+
var _a, _b;
|
|
49979
|
+
if (refresh) {
|
|
49980
|
+
pushToCache(this.cacheKey, {
|
|
49981
|
+
data: response.products.map(getResolver('product')),
|
|
49982
|
+
});
|
|
49983
|
+
}
|
|
49984
|
+
else {
|
|
49985
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
49986
|
+
const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
49987
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
|
|
49988
|
+
}
|
|
49989
|
+
}
|
|
49990
|
+
}
|
|
49991
|
+
|
|
49992
|
+
class SearchProductLiveCollectionController extends LiveCollectionController {
|
|
49993
|
+
constructor(query, callback) {
|
|
49994
|
+
const queryStreamId = hash(query);
|
|
49995
|
+
const cacheKey = ['products', 'collection', queryStreamId];
|
|
49996
|
+
const paginationController = new SearchProductPaginationController(query);
|
|
49997
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
49998
|
+
this.query = query;
|
|
49999
|
+
this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
|
|
50000
|
+
this.callback = callback.bind(this);
|
|
50001
|
+
this.loadPage({ initial: true });
|
|
50002
|
+
}
|
|
50003
|
+
setup() {
|
|
50004
|
+
var _a;
|
|
50005
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
50006
|
+
if (!collection) {
|
|
50007
|
+
pushToCache(this.cacheKey, {
|
|
50008
|
+
data: [],
|
|
50009
|
+
params: {},
|
|
50010
|
+
});
|
|
50011
|
+
}
|
|
50012
|
+
}
|
|
50013
|
+
async persistModel(queryPayload) {
|
|
50014
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
50015
|
+
}
|
|
50016
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
50017
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
50018
|
+
}
|
|
50019
|
+
// eslint-disable-next-line class-methods-use-this
|
|
50020
|
+
startSubscription() {
|
|
50021
|
+
return [];
|
|
50022
|
+
}
|
|
50023
|
+
notifyChange({ origin, loading, error }) {
|
|
50024
|
+
var _a, _b;
|
|
50025
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
50026
|
+
if (!collection)
|
|
50027
|
+
return;
|
|
50028
|
+
const data = (_b = collection.data
|
|
50029
|
+
.map(id => pullFromCache(['product', 'get', id]))
|
|
50030
|
+
.filter(isNonNullable)
|
|
50031
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
|
|
50032
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
50033
|
+
return;
|
|
50034
|
+
this.callback({
|
|
50035
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
50036
|
+
data,
|
|
50037
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
50038
|
+
loading,
|
|
50039
|
+
error,
|
|
50040
|
+
});
|
|
50041
|
+
}
|
|
50042
|
+
}
|
|
50043
|
+
|
|
50044
|
+
/* begin_public_function
|
|
50045
|
+
id: product.search
|
|
50046
|
+
*/
|
|
50047
|
+
/**
|
|
50048
|
+
* ```js
|
|
50049
|
+
* import { ProductRepository } from '@amityco/ts-sdk'
|
|
50050
|
+
*
|
|
50051
|
+
* let products = []
|
|
50052
|
+
* const unsub = ProductRepository.searchProducts({
|
|
50053
|
+
* keyword: string,
|
|
50054
|
+
* }, response => merge(products, response.data))
|
|
50055
|
+
* ```
|
|
50056
|
+
*
|
|
50057
|
+
* Observe all mutations on a list of {@link Amity.Product}
|
|
50058
|
+
*
|
|
50059
|
+
* @param params.keyword the search keyword
|
|
50060
|
+
* @param params.isActive filter by active status
|
|
50061
|
+
* @param params.isDeleted filter by deleted status
|
|
50062
|
+
* @param params.sortBy sort option
|
|
50063
|
+
* @param params.sortOrder order option
|
|
50064
|
+
* @param callback the function to call when new data are available
|
|
50065
|
+
* @param config
|
|
50066
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
|
|
50067
|
+
*
|
|
50068
|
+
* @category Products Live Collection
|
|
50069
|
+
*/
|
|
50070
|
+
const searchProducts = (params, callback, config) => {
|
|
50071
|
+
const { log, cache } = getActiveClient();
|
|
50072
|
+
if (!cache) {
|
|
50073
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
50074
|
+
}
|
|
50075
|
+
const timestamp = Date.now();
|
|
50076
|
+
log(`searchProducts(tmpid: ${timestamp}) > listen`);
|
|
50077
|
+
const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
|
|
50078
|
+
const disposers = productsLiveCollection.startSubscription();
|
|
50079
|
+
const cacheKey = productsLiveCollection.getCacheKey();
|
|
50080
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
50081
|
+
return () => {
|
|
50082
|
+
log(`searchProducts(tmpid: ${timestamp}) > dispose`);
|
|
50083
|
+
disposers.forEach(fn => fn());
|
|
50084
|
+
};
|
|
50085
|
+
};
|
|
50086
|
+
/* end_public_function */
|
|
50087
|
+
|
|
50088
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
50089
|
+
__proto__: null,
|
|
50090
|
+
getProduct: getProduct,
|
|
50091
|
+
searchProducts: searchProducts
|
|
50092
|
+
});
|
|
50093
|
+
|
|
50094
|
+
export { API_REGIONS, index$5 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$p as FileRepository, FileType, GET_WATCHER_URLS, index$3 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$2 as LiveReactionRepository, index$7 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$n as MessageRepository, index$8 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index as ProductRepository, index$o as ReactionRepository, index$9 as RoomPresenceRepository, index$c as RoomRepository, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, index$q as UserRepository, UserTypeEnum, 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, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$4 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 };
|