@amityco/ts-sdk 7.12.1-8bbe30f.0 → 7.12.1-df30e76f.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 +77 -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/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +329 -66
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +306 -44
- package/dist/index.umd.js +3 -3
- 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/roomRepository/api/analytics/AmityRoomAnalytics.d.ts +1 -0
- package/dist/roomRepository/api/analytics/AmityRoomAnalytics.d.ts.map +1 -1
- 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.d.ts
CHANGED
|
@@ -32,4 +32,5 @@ export * as InvitationRepository from './invitationRepository';
|
|
|
32
32
|
export * as LiveReactionRepository from './liveReactionRepository';
|
|
33
33
|
export { GET_WATCHER_URLS } from './utils/linkedObject/streamLinkedObject';
|
|
34
34
|
export * as EventRepository from './eventRepository';
|
|
35
|
+
export * as ProductRepository from './productRepository';
|
|
35
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAE5B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B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AM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -674,6 +674,7 @@ const idResolvers = {
|
|
|
674
674
|
viewer: ({ userId }) => userId,
|
|
675
675
|
event: ({ eventId }) => eventId,
|
|
676
676
|
eventResponse: ({ userId }) => userId,
|
|
677
|
+
product: ({ _id }) => _id,
|
|
677
678
|
};
|
|
678
679
|
/**
|
|
679
680
|
* Retrieve the id resolver matching a domain name
|
|
@@ -733,6 +734,7 @@ const PAYLOAD2MODEL = {
|
|
|
733
734
|
events: 'event',
|
|
734
735
|
viewers: 'viewer',
|
|
735
736
|
eventResponses: 'eventResponse',
|
|
737
|
+
products: 'product',
|
|
736
738
|
};
|
|
737
739
|
/** hidden */
|
|
738
740
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -26155,6 +26157,29 @@ const getShareableLinkConfiguration = async () => {
|
|
|
26155
26157
|
return data;
|
|
26156
26158
|
};
|
|
26157
26159
|
|
|
26160
|
+
/* begin_public_function
|
|
26161
|
+
id: client.getProductCatalogueSetting
|
|
26162
|
+
*/
|
|
26163
|
+
/**
|
|
26164
|
+
* ```js
|
|
26165
|
+
* import { getProductCatalogueSetting } from '@amityco/ts-sdk'
|
|
26166
|
+
* const productCatalogueSetting = await getProductCatalogueSetting()
|
|
26167
|
+
* ```
|
|
26168
|
+
*
|
|
26169
|
+
* Fetches a {@link Amity.ProductCatalogueSetting} object
|
|
26170
|
+
*
|
|
26171
|
+
* @returns A Promise of {@link Amity.ProductCatalogueSetting} object
|
|
26172
|
+
*
|
|
26173
|
+
* @category Client API
|
|
26174
|
+
* @async
|
|
26175
|
+
*/
|
|
26176
|
+
const getProductCatalogueSetting = async () => {
|
|
26177
|
+
const client = getActiveClient();
|
|
26178
|
+
const { data } = await client.http.get(`/api/v3/network-settings/product-catalogue`);
|
|
26179
|
+
return data;
|
|
26180
|
+
};
|
|
26181
|
+
/* end_public_function */
|
|
26182
|
+
|
|
26158
26183
|
/**
|
|
26159
26184
|
* Retrieves a pair of {@link Amity.Tokens} necessary for connection
|
|
26160
26185
|
*
|
|
@@ -26647,7 +26672,7 @@ const getUserUnread = (callback) => {
|
|
|
26647
26672
|
};
|
|
26648
26673
|
};
|
|
26649
26674
|
|
|
26650
|
-
var index$
|
|
26675
|
+
var index$s = /*#__PURE__*/Object.freeze({
|
|
26651
26676
|
__proto__: null,
|
|
26652
26677
|
getActiveClient: getActiveClient,
|
|
26653
26678
|
getActiveUser: getActiveUser,
|
|
@@ -26667,6 +26692,7 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
26667
26692
|
getLinkPreviewMetadata: getLinkPreviewMetadata,
|
|
26668
26693
|
getSocialSettings: getSocialSettings,
|
|
26669
26694
|
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26695
|
+
getProductCatalogueSetting: getProductCatalogueSetting,
|
|
26670
26696
|
loginAsVisitor: loginAsVisitor,
|
|
26671
26697
|
loginAsBot: loginAsBot,
|
|
26672
26698
|
getCurrentUser: getCurrentUser,
|
|
@@ -27867,7 +27893,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27867
27893
|
};
|
|
27868
27894
|
/* end_public_function */
|
|
27869
27895
|
|
|
27870
|
-
var index$
|
|
27896
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
27871
27897
|
__proto__: null,
|
|
27872
27898
|
blockUser: blockUser,
|
|
27873
27899
|
unBlockUser: unBlockUser,
|
|
@@ -28697,7 +28723,7 @@ const getWatchSessionStorage = () => {
|
|
|
28697
28723
|
return storageInstance;
|
|
28698
28724
|
};
|
|
28699
28725
|
|
|
28700
|
-
const privateKey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BP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
|
|
28701
28727
|
/*
|
|
28702
28728
|
* The crypto algorithm used for importing key and signing string
|
|
28703
28729
|
*/
|
|
@@ -28959,6 +28985,7 @@ const waitForNetwork = (maxWaitTime = 60000) => {
|
|
|
28959
28985
|
class AmityRoomAnalytics {
|
|
28960
28986
|
constructor(room) {
|
|
28961
28987
|
this.storage = getWatchSessionStorage();
|
|
28988
|
+
this.client = getActiveClient();
|
|
28962
28989
|
this.room = room;
|
|
28963
28990
|
}
|
|
28964
28991
|
/**
|
|
@@ -28973,7 +29000,7 @@ class AmityRoomAnalytics {
|
|
|
28973
29000
|
throw new ASCApiError('room is not in watchable state', 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
28974
29001
|
}
|
|
28975
29002
|
// Generate session ID with prefix
|
|
28976
|
-
const prefix = this.room.status === 'live' ? '
|
|
29003
|
+
const prefix = this.room.status === 'live' ? 'room_' : 'room_playback_';
|
|
28977
29004
|
const sessionId = prefix + uuid$1.v4();
|
|
28978
29005
|
// Create watch session entity
|
|
28979
29006
|
const session = {
|
|
@@ -29015,23 +29042,23 @@ class AmityRoomAnalytics {
|
|
|
29015
29042
|
syncPendingWatchSessions() {
|
|
29016
29043
|
// Execute with jitter delay (5-30 seconds)
|
|
29017
29044
|
const jitterDelay = getJitterDelay();
|
|
29018
|
-
|
|
29045
|
+
this.client.log('room/RoomAnalytics: syncPendingWatchSessions called, jitter delay:', `${jitterDelay}ms`);
|
|
29019
29046
|
setTimeout(async () => {
|
|
29020
|
-
|
|
29047
|
+
this.client.log('room/RoomAnalytics: Jitter delay completed, starting sync process');
|
|
29021
29048
|
try {
|
|
29022
29049
|
// Reset any SYNCING sessions back to PENDING
|
|
29023
29050
|
const syncingSessions = this.storage.getSyncingSessions();
|
|
29024
|
-
|
|
29051
|
+
this.client.log('room/RoomAnalytics: SYNCING sessions to reset:', syncingSessions.length);
|
|
29025
29052
|
syncingSessions.forEach(session => {
|
|
29026
29053
|
this.storage.updateSession(session.sessionId, { syncState: 'PENDING' });
|
|
29027
29054
|
});
|
|
29028
29055
|
// Wait for network connection (max 60 seconds)
|
|
29029
29056
|
await waitForNetwork(60000);
|
|
29030
|
-
|
|
29057
|
+
this.client.log('room/RoomAnalytics: Network available');
|
|
29031
29058
|
// Sync pending sessions
|
|
29032
|
-
|
|
29059
|
+
this.client.log('room/RoomAnalytics: Calling syncWatchSessions()');
|
|
29033
29060
|
await syncWatchSessions();
|
|
29034
|
-
|
|
29061
|
+
this.client.log('room/RoomAnalytics: syncWatchSessions completed');
|
|
29035
29062
|
}
|
|
29036
29063
|
catch (error) {
|
|
29037
29064
|
// Error is already handled in syncWatchSessions
|
|
@@ -29974,6 +30001,11 @@ const communityLinkedObject = (community) => {
|
|
|
29974
30001
|
} });
|
|
29975
30002
|
};
|
|
29976
30003
|
|
|
30004
|
+
const productTagLinkedObject = (productTag) => {
|
|
30005
|
+
var _a;
|
|
30006
|
+
return Object.assign(Object.assign({}, productTag), { product: (_a = pullFromCache(['product', 'get', productTag.productId])) === null || _a === void 0 ? void 0 : _a.data });
|
|
30007
|
+
};
|
|
30008
|
+
|
|
29977
30009
|
const postLinkedObject = (post) => {
|
|
29978
30010
|
return shallowClone(post, {
|
|
29979
30011
|
childrenPosts: post.children
|
|
@@ -29986,6 +30018,10 @@ const postLinkedObject = (post) => {
|
|
|
29986
30018
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
29987
30019
|
},
|
|
29988
30020
|
},
|
|
30021
|
+
get productTags() {
|
|
30022
|
+
var _a, _b;
|
|
30023
|
+
return (_b = (_a = post.productTags) === null || _a === void 0 ? void 0 : _a.map(productTag => productTagLinkedObject(productTag))) !== null && _b !== void 0 ? _b : [];
|
|
30024
|
+
},
|
|
29989
30025
|
get latestComments() {
|
|
29990
30026
|
if (!post.comments)
|
|
29991
30027
|
return [];
|
|
@@ -31975,9 +32011,9 @@ var AmityUserSearchMatchType;
|
|
|
31975
32011
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
31976
32012
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
31977
32013
|
|
|
31978
|
-
var index$
|
|
32014
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
31979
32015
|
__proto__: null,
|
|
31980
|
-
Relationship: index$
|
|
32016
|
+
Relationship: index$r,
|
|
31981
32017
|
getUserByIds: getUserByIds,
|
|
31982
32018
|
updateUser: updateUser,
|
|
31983
32019
|
flagUser: flagUser,
|
|
@@ -32380,7 +32416,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
32380
32416
|
};
|
|
32381
32417
|
/* end_public_function */
|
|
32382
32418
|
|
|
32383
|
-
var index$
|
|
32419
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
32384
32420
|
__proto__: null,
|
|
32385
32421
|
getFile: getFile,
|
|
32386
32422
|
uploadFile: uploadFile,
|
|
@@ -34192,7 +34228,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
34192
34228
|
};
|
|
34193
34229
|
/* end_public_function */
|
|
34194
34230
|
|
|
34195
|
-
var index$
|
|
34231
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
34196
34232
|
__proto__: null,
|
|
34197
34233
|
addReaction: addReaction,
|
|
34198
34234
|
removeReaction: removeReaction,
|
|
@@ -35964,7 +36000,7 @@ const getMessages = (params, callback, config) => {
|
|
|
35964
36000
|
};
|
|
35965
36001
|
/* end_public_function */
|
|
35966
36002
|
|
|
35967
|
-
var index$
|
|
36003
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
35968
36004
|
__proto__: null,
|
|
35969
36005
|
createMessage: createMessage,
|
|
35970
36006
|
updateMessage: updateMessage,
|
|
@@ -36490,7 +36526,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
36490
36526
|
};
|
|
36491
36527
|
/* end_public_function */
|
|
36492
36528
|
|
|
36493
|
-
var index$
|
|
36529
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
36494
36530
|
__proto__: null,
|
|
36495
36531
|
getSubChannelByIds: getSubChannels$1,
|
|
36496
36532
|
createSubChannel: createSubChannel,
|
|
@@ -37817,7 +37853,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
37817
37853
|
};
|
|
37818
37854
|
/* end_public_function */
|
|
37819
37855
|
|
|
37820
|
-
var index$
|
|
37856
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
37821
37857
|
__proto__: null,
|
|
37822
37858
|
addMembers: addMembers$1,
|
|
37823
37859
|
removeMembers: removeMembers$1,
|
|
@@ -38020,7 +38056,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
38020
38056
|
};
|
|
38021
38057
|
/* end_public_function */
|
|
38022
38058
|
|
|
38023
|
-
var index$
|
|
38059
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
38024
38060
|
__proto__: null,
|
|
38025
38061
|
addRole: addRole,
|
|
38026
38062
|
removeRole: removeRole,
|
|
@@ -38030,10 +38066,10 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
38030
38066
|
unmuteMembers: unmuteMembers
|
|
38031
38067
|
});
|
|
38032
38068
|
|
|
38033
|
-
var index$
|
|
38069
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
38034
38070
|
__proto__: null,
|
|
38035
|
-
Membership: index$
|
|
38036
|
-
Moderation: index$
|
|
38071
|
+
Membership: index$l,
|
|
38072
|
+
Moderation: index$k,
|
|
38037
38073
|
getChannelByIds: getChannelByIds$1,
|
|
38038
38074
|
createChannel: createChannel,
|
|
38039
38075
|
updateChannel: updateChannel,
|
|
@@ -39436,7 +39472,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
39436
39472
|
};
|
|
39437
39473
|
/* end_public_function */
|
|
39438
39474
|
|
|
39439
|
-
var index$
|
|
39475
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
39440
39476
|
__proto__: null,
|
|
39441
39477
|
addMembers: addMembers,
|
|
39442
39478
|
removeMembers: removeMembers,
|
|
@@ -40687,7 +40723,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
40687
40723
|
};
|
|
40688
40724
|
/* end_public_function */
|
|
40689
40725
|
|
|
40690
|
-
var index$
|
|
40726
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
40691
40727
|
__proto__: null,
|
|
40692
40728
|
addRoles: addRoles,
|
|
40693
40729
|
removeRoles: removeRoles,
|
|
@@ -40695,10 +40731,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
40695
40731
|
unbanMembers: unbanMembers
|
|
40696
40732
|
});
|
|
40697
40733
|
|
|
40698
|
-
var index$
|
|
40734
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
40699
40735
|
__proto__: null,
|
|
40700
|
-
Moderation: index$
|
|
40701
|
-
Membership: index$
|
|
40736
|
+
Moderation: index$h,
|
|
40737
|
+
Membership: index$i,
|
|
40702
40738
|
getCommunityByIds: getCommunities$1,
|
|
40703
40739
|
createCommunity: createCommunity,
|
|
40704
40740
|
updateCommunity: updateCommunity,
|
|
@@ -40932,7 +40968,7 @@ const getCategories = (params, callback, config) => {
|
|
|
40932
40968
|
};
|
|
40933
40969
|
/* end_public_function */
|
|
40934
40970
|
|
|
40935
|
-
var index$
|
|
40971
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
40936
40972
|
__proto__: null,
|
|
40937
40973
|
getCategory: getCategory,
|
|
40938
40974
|
getCategories: getCategories
|
|
@@ -41991,7 +42027,7 @@ const getComments = (params, callback, config) => {
|
|
|
41991
42027
|
};
|
|
41992
42028
|
/* end_public_function */
|
|
41993
42029
|
|
|
41994
|
-
var index$
|
|
42030
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
41995
42031
|
__proto__: null,
|
|
41996
42032
|
getCommentByIds: getCommentByIds,
|
|
41997
42033
|
createComment: createComment,
|
|
@@ -42662,7 +42698,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
42662
42698
|
};
|
|
42663
42699
|
/* end_public_function */
|
|
42664
42700
|
|
|
42665
|
-
var index$
|
|
42701
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
42666
42702
|
__proto__: null,
|
|
42667
42703
|
queryGlobalFeed: queryGlobalFeed,
|
|
42668
42704
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -42777,7 +42813,15 @@ const createPost = async (bundle) => {
|
|
|
42777
42813
|
// eslint-disable-next-line no-param-reassign
|
|
42778
42814
|
delete bundle.dataType;
|
|
42779
42815
|
}
|
|
42780
|
-
const {
|
|
42816
|
+
const { attachments } = bundle;
|
|
42817
|
+
const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
|
|
42818
|
+
? attachments.map(attachment => {
|
|
42819
|
+
if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
|
|
42820
|
+
return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
|
|
42821
|
+
return attachment;
|
|
42822
|
+
})
|
|
42823
|
+
: attachments;
|
|
42824
|
+
const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { attachments: processedAttachments }));
|
|
42781
42825
|
fireEvent('post.created', payload);
|
|
42782
42826
|
const data = preparePostPayload(payload);
|
|
42783
42827
|
const cachedAt = client.cache && Date.now();
|
|
@@ -42814,7 +42858,15 @@ const createPost = async (bundle) => {
|
|
|
42814
42858
|
const editPost = async (postId, patch) => {
|
|
42815
42859
|
const client = getActiveClient();
|
|
42816
42860
|
client.log('user/editPost', patch);
|
|
42817
|
-
const {
|
|
42861
|
+
const { attachments } = patch;
|
|
42862
|
+
const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
|
|
42863
|
+
? attachments.map(attachment => {
|
|
42864
|
+
if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
|
|
42865
|
+
return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
|
|
42866
|
+
return attachment;
|
|
42867
|
+
})
|
|
42868
|
+
: attachments;
|
|
42869
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
|
|
42818
42870
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
42819
42871
|
const cachedAt = client.cache && Date.now();
|
|
42820
42872
|
if (client.cache)
|
|
@@ -45458,7 +45510,7 @@ const getRooms = (params, callback, config) => {
|
|
|
45458
45510
|
};
|
|
45459
45511
|
/* end_public_function */
|
|
45460
45512
|
|
|
45461
|
-
var index$
|
|
45513
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
45462
45514
|
__proto__: null,
|
|
45463
45515
|
createRoom: createRoom,
|
|
45464
45516
|
updateRoom: updateRoom,
|
|
@@ -45754,7 +45806,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
|
|
|
45754
45806
|
};
|
|
45755
45807
|
/* end_public_function */
|
|
45756
45808
|
|
|
45757
|
-
var index$
|
|
45809
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
45758
45810
|
__proto__: null,
|
|
45759
45811
|
getPostByIds: getPostByIds,
|
|
45760
45812
|
createPost: createPost,
|
|
@@ -46364,7 +46416,7 @@ const getStreams = (params, callback, config) => {
|
|
|
46364
46416
|
};
|
|
46365
46417
|
};
|
|
46366
46418
|
|
|
46367
|
-
var index$
|
|
46419
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
46368
46420
|
__proto__: null,
|
|
46369
46421
|
createStream: createStream,
|
|
46370
46422
|
updateStream: updateStream,
|
|
@@ -46667,7 +46719,7 @@ const stopHeartbeat = (roomId) => {
|
|
|
46667
46719
|
};
|
|
46668
46720
|
/* end_public_function */
|
|
46669
46721
|
|
|
46670
|
-
var index$
|
|
46722
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
46671
46723
|
__proto__: null,
|
|
46672
46724
|
getRoomOnlineUsers: getRoomOnlineUsers,
|
|
46673
46725
|
getRoomUserCount: getRoomUserCount,
|
|
@@ -46975,7 +47027,7 @@ const getPoll = (pollId, callback) => {
|
|
|
46975
47027
|
};
|
|
46976
47028
|
/* end_public_function */
|
|
46977
47029
|
|
|
46978
|
-
var index$
|
|
47030
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
46979
47031
|
__proto__: null,
|
|
46980
47032
|
createPoll: createPoll,
|
|
46981
47033
|
closePoll: closePoll,
|
|
@@ -47279,7 +47331,7 @@ const getPlayer = async (parameters) => {
|
|
|
47279
47331
|
return video;
|
|
47280
47332
|
};
|
|
47281
47333
|
|
|
47282
|
-
var index$
|
|
47334
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
47283
47335
|
__proto__: null,
|
|
47284
47336
|
getPlayer: getPlayer
|
|
47285
47337
|
});
|
|
@@ -48452,7 +48504,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
48452
48504
|
};
|
|
48453
48505
|
};
|
|
48454
48506
|
|
|
48455
|
-
var index$
|
|
48507
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
48456
48508
|
__proto__: null,
|
|
48457
48509
|
createImageStory: createImageStory,
|
|
48458
48510
|
createVideoStory: createVideoStory,
|
|
@@ -48489,7 +48541,7 @@ const getNetworkAds = async () => {
|
|
|
48489
48541
|
};
|
|
48490
48542
|
};
|
|
48491
48543
|
|
|
48492
|
-
var index$
|
|
48544
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
48493
48545
|
__proto__: null,
|
|
48494
48546
|
getNetworkAds: getNetworkAds
|
|
48495
48547
|
});
|
|
@@ -48880,7 +48932,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
48880
48932
|
};
|
|
48881
48933
|
/* end_public_function */
|
|
48882
48934
|
|
|
48883
|
-
var index$
|
|
48935
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
48884
48936
|
__proto__: null,
|
|
48885
48937
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
48886
48938
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -49178,7 +49230,7 @@ const getInvitations = (params, callback) => {
|
|
|
49178
49230
|
};
|
|
49179
49231
|
};
|
|
49180
49232
|
|
|
49181
|
-
var index$
|
|
49233
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
49182
49234
|
__proto__: null,
|
|
49183
49235
|
cancelInvitation: cancelInvitation,
|
|
49184
49236
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
@@ -49327,7 +49379,7 @@ const getReactions = (postId, callback) => {
|
|
|
49327
49379
|
};
|
|
49328
49380
|
};
|
|
49329
49381
|
|
|
49330
|
-
var index$
|
|
49382
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
49331
49383
|
__proto__: null,
|
|
49332
49384
|
createReaction: createReaction,
|
|
49333
49385
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
@@ -49810,7 +49862,7 @@ const getMyEvents = (params, callback, config) => {
|
|
|
49810
49862
|
};
|
|
49811
49863
|
};
|
|
49812
49864
|
|
|
49813
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
49865
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
49814
49866
|
__proto__: null,
|
|
49815
49867
|
createEvent: createEvent,
|
|
49816
49868
|
updateEvent: updateEvent,
|
|
@@ -49831,4 +49883,214 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
49831
49883
|
getRSVPs: getRSVPs
|
|
49832
49884
|
});
|
|
49833
49885
|
|
|
49834
|
-
|
|
49886
|
+
const getProduct$1 = async (productId) => {
|
|
49887
|
+
const client = getActiveClient();
|
|
49888
|
+
client.log('product/getProduct', productId);
|
|
49889
|
+
isInTombstone('product', productId);
|
|
49890
|
+
let payload;
|
|
49891
|
+
try {
|
|
49892
|
+
const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
|
|
49893
|
+
payload = response.data;
|
|
49894
|
+
}
|
|
49895
|
+
catch (error) {
|
|
49896
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
49897
|
+
pushToTombstone('product', productId);
|
|
49898
|
+
}
|
|
49899
|
+
throw error;
|
|
49900
|
+
}
|
|
49901
|
+
const cachedAt = client.cache && Date.now();
|
|
49902
|
+
if (client.cache)
|
|
49903
|
+
ingestInCache(payload, { cachedAt });
|
|
49904
|
+
const { products } = payload;
|
|
49905
|
+
const result = products.find(product => product.productId === productId);
|
|
49906
|
+
return {
|
|
49907
|
+
data: result,
|
|
49908
|
+
cachedAt,
|
|
49909
|
+
};
|
|
49910
|
+
};
|
|
49911
|
+
getProduct$1.locally = (productId) => {
|
|
49912
|
+
const client = getActiveClient();
|
|
49913
|
+
client.log('product/getProduct.locally', productId);
|
|
49914
|
+
if (!client.cache)
|
|
49915
|
+
return;
|
|
49916
|
+
const cached = pullFromCache(['product', 'get', productId]);
|
|
49917
|
+
if (!cached)
|
|
49918
|
+
return;
|
|
49919
|
+
return {
|
|
49920
|
+
data: cached.data,
|
|
49921
|
+
cachedAt: cached.cachedAt,
|
|
49922
|
+
};
|
|
49923
|
+
};
|
|
49924
|
+
|
|
49925
|
+
/* begin_public_function
|
|
49926
|
+
id: product.get
|
|
49927
|
+
*/
|
|
49928
|
+
/**
|
|
49929
|
+
* ```js
|
|
49930
|
+
* import { ProductRepository } from '@amityco/ts-sdk';
|
|
49931
|
+
*
|
|
49932
|
+
* let product;
|
|
49933
|
+
*
|
|
49934
|
+
* const unsub = ProductRepository.getProduct(productId, response => {
|
|
49935
|
+
* product = response.data;
|
|
49936
|
+
* });
|
|
49937
|
+
* ```
|
|
49938
|
+
*
|
|
49939
|
+
* Observe all mutation on a given {@link Amity.Product}
|
|
49940
|
+
*
|
|
49941
|
+
* @param productId the ID of the product to observe
|
|
49942
|
+
* @param callback the function to call when new data are available
|
|
49943
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
|
|
49944
|
+
*
|
|
49945
|
+
* @category Product Live Object
|
|
49946
|
+
*/
|
|
49947
|
+
const getProduct = (productId, callback) => {
|
|
49948
|
+
const responder = (snapshot) => {
|
|
49949
|
+
callback(snapshot);
|
|
49950
|
+
};
|
|
49951
|
+
return liveObject(productId, responder, 'productId', getProduct$1, []);
|
|
49952
|
+
};
|
|
49953
|
+
/* end_public_function */
|
|
49954
|
+
|
|
49955
|
+
class SearchProductPaginationController extends PaginationController {
|
|
49956
|
+
async getRequest(queryParams, token) {
|
|
49957
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
49958
|
+
const options = token ? { token } : { limit };
|
|
49959
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
|
|
49960
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
49961
|
+
});
|
|
49962
|
+
return queryResponse;
|
|
49963
|
+
}
|
|
49964
|
+
}
|
|
49965
|
+
|
|
49966
|
+
class SearchProductQueryStreamController extends QueryStreamController {
|
|
49967
|
+
constructor(query, cacheKey, notifyChange) {
|
|
49968
|
+
super(query, cacheKey);
|
|
49969
|
+
this.notifyChange = notifyChange;
|
|
49970
|
+
}
|
|
49971
|
+
// eslint-disable-next-line class-methods-use-this
|
|
49972
|
+
saveToMainDB(response) {
|
|
49973
|
+
const client = getActiveClient();
|
|
49974
|
+
const cachedAt = client.cache && Date.now();
|
|
49975
|
+
if (client.cache) {
|
|
49976
|
+
ingestInCache(response, { cachedAt });
|
|
49977
|
+
}
|
|
49978
|
+
}
|
|
49979
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
49980
|
+
var _a, _b;
|
|
49981
|
+
if (refresh) {
|
|
49982
|
+
pushToCache(this.cacheKey, {
|
|
49983
|
+
data: response.products.map(getResolver('product')),
|
|
49984
|
+
});
|
|
49985
|
+
}
|
|
49986
|
+
else {
|
|
49987
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
49988
|
+
const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
49989
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
|
|
49990
|
+
}
|
|
49991
|
+
}
|
|
49992
|
+
}
|
|
49993
|
+
|
|
49994
|
+
class SearchProductLiveCollectionController extends LiveCollectionController {
|
|
49995
|
+
constructor(query, callback) {
|
|
49996
|
+
const queryStreamId = hash(query);
|
|
49997
|
+
const cacheKey = ['products', 'collection', queryStreamId];
|
|
49998
|
+
const paginationController = new SearchProductPaginationController(query);
|
|
49999
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
50000
|
+
this.query = query;
|
|
50001
|
+
this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
|
|
50002
|
+
this.callback = callback.bind(this);
|
|
50003
|
+
this.loadPage({ initial: true });
|
|
50004
|
+
}
|
|
50005
|
+
setup() {
|
|
50006
|
+
var _a;
|
|
50007
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
50008
|
+
if (!collection) {
|
|
50009
|
+
pushToCache(this.cacheKey, {
|
|
50010
|
+
data: [],
|
|
50011
|
+
params: {},
|
|
50012
|
+
});
|
|
50013
|
+
}
|
|
50014
|
+
}
|
|
50015
|
+
async persistModel(queryPayload) {
|
|
50016
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
50017
|
+
}
|
|
50018
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
50019
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
50020
|
+
}
|
|
50021
|
+
// eslint-disable-next-line class-methods-use-this
|
|
50022
|
+
startSubscription() {
|
|
50023
|
+
return [];
|
|
50024
|
+
}
|
|
50025
|
+
notifyChange({ origin, loading, error }) {
|
|
50026
|
+
var _a, _b;
|
|
50027
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
50028
|
+
if (!collection)
|
|
50029
|
+
return;
|
|
50030
|
+
const data = (_b = collection.data
|
|
50031
|
+
.map(id => pullFromCache(['product', 'get', id]))
|
|
50032
|
+
.filter(isNonNullable)
|
|
50033
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
|
|
50034
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
50035
|
+
return;
|
|
50036
|
+
this.callback({
|
|
50037
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
50038
|
+
data,
|
|
50039
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
50040
|
+
loading,
|
|
50041
|
+
error,
|
|
50042
|
+
});
|
|
50043
|
+
}
|
|
50044
|
+
}
|
|
50045
|
+
|
|
50046
|
+
/* begin_public_function
|
|
50047
|
+
id: product.search
|
|
50048
|
+
*/
|
|
50049
|
+
/**
|
|
50050
|
+
* ```js
|
|
50051
|
+
* import { ProductRepository } from '@amityco/ts-sdk'
|
|
50052
|
+
*
|
|
50053
|
+
* let products = []
|
|
50054
|
+
* const unsub = ProductRepository.searchProducts({
|
|
50055
|
+
* keyword: string,
|
|
50056
|
+
* }, response => merge(products, response.data))
|
|
50057
|
+
* ```
|
|
50058
|
+
*
|
|
50059
|
+
* Observe all mutations on a list of {@link Amity.Product}
|
|
50060
|
+
*
|
|
50061
|
+
* @param params.keyword the search keyword
|
|
50062
|
+
* @param params.isActive filter by active status
|
|
50063
|
+
* @param params.isDeleted filter by deleted status
|
|
50064
|
+
* @param params.sortBy sort option
|
|
50065
|
+
* @param params.sortOrder order option
|
|
50066
|
+
* @param callback the function to call when new data are available
|
|
50067
|
+
* @param config
|
|
50068
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
|
|
50069
|
+
*
|
|
50070
|
+
* @category Products Live Collection
|
|
50071
|
+
*/
|
|
50072
|
+
const searchProducts = (params, callback, config) => {
|
|
50073
|
+
const { log, cache } = getActiveClient();
|
|
50074
|
+
if (!cache) {
|
|
50075
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
50076
|
+
}
|
|
50077
|
+
const timestamp = Date.now();
|
|
50078
|
+
log(`searchProducts(tmpid: ${timestamp}) > listen`);
|
|
50079
|
+
const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
|
|
50080
|
+
const disposers = productsLiveCollection.startSubscription();
|
|
50081
|
+
const cacheKey = productsLiveCollection.getCacheKey();
|
|
50082
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
50083
|
+
return () => {
|
|
50084
|
+
log(`searchProducts(tmpid: ${timestamp}) > dispose`);
|
|
50085
|
+
disposers.forEach(fn => fn());
|
|
50086
|
+
};
|
|
50087
|
+
};
|
|
50088
|
+
/* end_public_function */
|
|
50089
|
+
|
|
50090
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
50091
|
+
__proto__: null,
|
|
50092
|
+
getProduct: getProduct,
|
|
50093
|
+
searchProducts: searchProducts
|
|
50094
|
+
});
|
|
50095
|
+
|
|
50096
|
+
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 };
|