@amityco/ts-sdk 7.11.1-c23e18e.0 → 7.11.1-f97e52ac.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.
Files changed (32) hide show
  1. package/dist/@types/core/events.d.ts +32 -2
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +2 -0
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +13 -0
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/event.d.ts +55 -0
  8. package/dist/@types/domains/event.d.ts.map +1 -0
  9. package/dist/@types/index.d.ts +1 -0
  10. package/dist/@types/index.d.ts.map +1 -1
  11. package/dist/core/events.d.ts +3 -3
  12. package/dist/core/events.d.ts.map +1 -1
  13. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  14. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  15. package/dist/eventRepository/api/index.d.ts +2 -0
  16. package/dist/eventRepository/api/index.d.ts.map +1 -0
  17. package/dist/eventRepository/index.d.ts +2 -0
  18. package/dist/eventRepository/index.d.ts.map +1 -0
  19. package/dist/eventRepository/utils/index.d.ts +2 -0
  20. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  21. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  22. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  23. package/dist/index.cjs.js +137 -50
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.esm.js +117 -31
  27. package/dist/index.umd.js +3 -3
  28. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  29. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  30. package/dist/utils/linkedObject/index.d.ts +1 -0
  31. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  32. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -177,6 +177,24 @@ var FeedSourceEnum;
177
177
  FeedSourceEnum["User"] = "user";
178
178
  })(FeedSourceEnum || (FeedSourceEnum = {}));
179
179
 
180
+ var AmityEventType;
181
+ (function (AmityEventType) {
182
+ AmityEventType["Virtual"] = "virtual";
183
+ AmityEventType["InPerson"] = "in_person";
184
+ })(AmityEventType || (AmityEventType = {}));
185
+ var AmityEventOriginType;
186
+ (function (AmityEventOriginType) {
187
+ AmityEventOriginType["Community"] = "community";
188
+ AmityEventOriginType["User"] = "user";
189
+ })(AmityEventOriginType || (AmityEventOriginType = {}));
190
+ var AmityEventStatus;
191
+ (function (AmityEventStatus) {
192
+ AmityEventStatus["Scheduled"] = "scheduled";
193
+ AmityEventStatus["Live"] = "live";
194
+ AmityEventStatus["Ended"] = "ended";
195
+ AmityEventStatus["Cancelled"] = "cancelled";
196
+ })(AmityEventStatus || (AmityEventStatus = {}));
197
+
180
198
  function getVersion() {
181
199
  try {
182
200
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -26552,7 +26570,7 @@ const getUserUnread = (callback) => {
26552
26570
  };
26553
26571
  };
26554
26572
 
26555
- var index$o = /*#__PURE__*/Object.freeze({
26573
+ var index$p = /*#__PURE__*/Object.freeze({
26556
26574
  __proto__: null,
26557
26575
  getActiveClient: getActiveClient,
26558
26576
  getActiveUser: getActiveUser,
@@ -27771,7 +27789,7 @@ const getMyFollowInfo = (callback) => {
27771
27789
  };
27772
27790
  /* end_public_function */
27773
27791
 
27774
- var index$n = /*#__PURE__*/Object.freeze({
27792
+ var index$o = /*#__PURE__*/Object.freeze({
27775
27793
  __proto__: null,
27776
27794
  blockUser: blockUser,
27777
27795
  unBlockUser: unBlockUser,
@@ -29750,6 +29768,31 @@ const communityLinkedObject = (community) => {
29750
29768
  } });
29751
29769
  };
29752
29770
 
29771
+ const eventLinkedObject = (event) => {
29772
+ return Object.assign(Object.assign({}, event), { get creator() {
29773
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
29774
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29775
+ return;
29776
+ return userLinkedObject(cacheData.data);
29777
+ },
29778
+ get discussionCommunity() {
29779
+ if (!event.communityId)
29780
+ return;
29781
+ const cacheData = pullFromCache(['community', 'get', event.communityId]);
29782
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29783
+ return;
29784
+ return communityLinkedObject(cacheData.data);
29785
+ },
29786
+ get liveStream() {
29787
+ if (!event.livestreamId)
29788
+ return;
29789
+ const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29790
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29791
+ return;
29792
+ return cacheData.data;
29793
+ } });
29794
+ };
29795
+
29753
29796
  const LinkedObject = {
29754
29797
  ad: adLinkedObject,
29755
29798
  comment: commentLinkedObject,
@@ -29768,6 +29811,7 @@ const LinkedObject = {
29768
29811
  invitation: invitationLinkedObject,
29769
29812
  joinRequest: joinRequestLinkedObject,
29770
29813
  channelMember: channelMemberLinkedObject,
29814
+ event: eventLinkedObject,
29771
29815
  };
29772
29816
 
29773
29817
  /* begin_public_function
@@ -30758,9 +30802,9 @@ var AmityUserSearchMatchType;
30758
30802
  AmityUserSearchMatchType["PARTIAL"] = "partial";
30759
30803
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
30760
30804
 
30761
- var index$m = /*#__PURE__*/Object.freeze({
30805
+ var index$n = /*#__PURE__*/Object.freeze({
30762
30806
  __proto__: null,
30763
- Relationship: index$n,
30807
+ Relationship: index$o,
30764
30808
  getUserByIds: getUserByIds,
30765
30809
  updateUser: updateUser,
30766
30810
  flagUser: flagUser,
@@ -31163,7 +31207,7 @@ const uploadAudio = async (formData, onProgress) => {
31163
31207
  };
31164
31208
  /* end_public_function */
31165
31209
 
31166
- var index$l = /*#__PURE__*/Object.freeze({
31210
+ var index$m = /*#__PURE__*/Object.freeze({
31167
31211
  __proto__: null,
31168
31212
  getFile: getFile,
31169
31213
  uploadFile: uploadFile,
@@ -32975,7 +33019,7 @@ const getReactions$1 = (params, callback, config) => {
32975
33019
  };
32976
33020
  /* end_public_function */
32977
33021
 
32978
- var index$k = /*#__PURE__*/Object.freeze({
33022
+ var index$l = /*#__PURE__*/Object.freeze({
32979
33023
  __proto__: null,
32980
33024
  addReaction: addReaction,
32981
33025
  removeReaction: removeReaction,
@@ -34747,7 +34791,7 @@ const getMessages = (params, callback, config) => {
34747
34791
  };
34748
34792
  /* end_public_function */
34749
34793
 
34750
- var index$j = /*#__PURE__*/Object.freeze({
34794
+ var index$k = /*#__PURE__*/Object.freeze({
34751
34795
  __proto__: null,
34752
34796
  createMessage: createMessage,
34753
34797
  updateMessage: updateMessage,
@@ -35273,7 +35317,7 @@ const stopMessageReceiptSync = (subChannelId) => {
35273
35317
  };
35274
35318
  /* end_public_function */
35275
35319
 
35276
- var index$i = /*#__PURE__*/Object.freeze({
35320
+ var index$j = /*#__PURE__*/Object.freeze({
35277
35321
  __proto__: null,
35278
35322
  getSubChannelByIds: getSubChannels$1,
35279
35323
  createSubChannel: createSubChannel,
@@ -36600,7 +36644,7 @@ const searchMembers$1 = (params, callback, config) => {
36600
36644
  };
36601
36645
  /* end_public_function */
36602
36646
 
36603
- var index$h = /*#__PURE__*/Object.freeze({
36647
+ var index$i = /*#__PURE__*/Object.freeze({
36604
36648
  __proto__: null,
36605
36649
  addMembers: addMembers$1,
36606
36650
  removeMembers: removeMembers$1,
@@ -36803,7 +36847,7 @@ const unmuteMembers = async (channelId, userIds) => {
36803
36847
  };
36804
36848
  /* end_public_function */
36805
36849
 
36806
- var index$g = /*#__PURE__*/Object.freeze({
36850
+ var index$h = /*#__PURE__*/Object.freeze({
36807
36851
  __proto__: null,
36808
36852
  addRole: addRole,
36809
36853
  removeRole: removeRole,
@@ -36813,10 +36857,10 @@ var index$g = /*#__PURE__*/Object.freeze({
36813
36857
  unmuteMembers: unmuteMembers
36814
36858
  });
36815
36859
 
36816
- var index$f = /*#__PURE__*/Object.freeze({
36860
+ var index$g = /*#__PURE__*/Object.freeze({
36817
36861
  __proto__: null,
36818
- Membership: index$h,
36819
- Moderation: index$g,
36862
+ Membership: index$i,
36863
+ Moderation: index$h,
36820
36864
  getChannelByIds: getChannelByIds$1,
36821
36865
  createChannel: createChannel,
36822
36866
  updateChannel: updateChannel,
@@ -38219,7 +38263,7 @@ const searchMembers = (params, callback, config) => {
38219
38263
  };
38220
38264
  /* end_public_function */
38221
38265
 
38222
- var index$e = /*#__PURE__*/Object.freeze({
38266
+ var index$f = /*#__PURE__*/Object.freeze({
38223
38267
  __proto__: null,
38224
38268
  addMembers: addMembers,
38225
38269
  removeMembers: removeMembers,
@@ -39470,7 +39514,7 @@ const unbanMembers = async (communityId, userIds) => {
39470
39514
  };
39471
39515
  /* end_public_function */
39472
39516
 
39473
- var index$d = /*#__PURE__*/Object.freeze({
39517
+ var index$e = /*#__PURE__*/Object.freeze({
39474
39518
  __proto__: null,
39475
39519
  addRoles: addRoles,
39476
39520
  removeRoles: removeRoles,
@@ -39478,10 +39522,10 @@ var index$d = /*#__PURE__*/Object.freeze({
39478
39522
  unbanMembers: unbanMembers
39479
39523
  });
39480
39524
 
39481
- var index$c = /*#__PURE__*/Object.freeze({
39525
+ var index$d = /*#__PURE__*/Object.freeze({
39482
39526
  __proto__: null,
39483
- Moderation: index$d,
39484
- Membership: index$e,
39527
+ Moderation: index$e,
39528
+ Membership: index$f,
39485
39529
  getCommunityByIds: getCommunities$1,
39486
39530
  createCommunity: createCommunity,
39487
39531
  updateCommunity: updateCommunity,
@@ -39715,7 +39759,7 @@ const getCategories = (params, callback, config) => {
39715
39759
  };
39716
39760
  /* end_public_function */
39717
39761
 
39718
- var index$b = /*#__PURE__*/Object.freeze({
39762
+ var index$c = /*#__PURE__*/Object.freeze({
39719
39763
  __proto__: null,
39720
39764
  getCategory: getCategory,
39721
39765
  getCategories: getCategories
@@ -40774,7 +40818,7 @@ const getComments = (params, callback, config) => {
40774
40818
  };
40775
40819
  /* end_public_function */
40776
40820
 
40777
- var index$a = /*#__PURE__*/Object.freeze({
40821
+ var index$b = /*#__PURE__*/Object.freeze({
40778
40822
  __proto__: null,
40779
40823
  getCommentByIds: getCommentByIds,
40780
40824
  createComment: createComment,
@@ -41445,7 +41489,7 @@ const getUserFeed = (params, callback, config) => {
41445
41489
  };
41446
41490
  /* end_public_function */
41447
41491
 
41448
- var index$9 = /*#__PURE__*/Object.freeze({
41492
+ var index$a = /*#__PURE__*/Object.freeze({
41449
41493
  __proto__: null,
41450
41494
  queryGlobalFeed: queryGlobalFeed,
41451
41495
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -43126,7 +43170,7 @@ const searchPostsByHashtag = (params, callback, config) => {
43126
43170
  };
43127
43171
  /* end_public_function */
43128
43172
 
43129
- var index$8 = /*#__PURE__*/Object.freeze({
43173
+ var index$9 = /*#__PURE__*/Object.freeze({
43130
43174
  __proto__: null,
43131
43175
  getPostByIds: getPostByIds,
43132
43176
  createPost: createPost,
@@ -43734,7 +43778,7 @@ const getStreams = (params, callback, config) => {
43734
43778
  };
43735
43779
  };
43736
43780
 
43737
- var index$7 = /*#__PURE__*/Object.freeze({
43781
+ var index$8 = /*#__PURE__*/Object.freeze({
43738
43782
  __proto__: null,
43739
43783
  createStream: createStream,
43740
43784
  updateStream: updateStream,
@@ -44052,7 +44096,7 @@ const getPoll = (pollId, callback) => {
44052
44096
  };
44053
44097
  /* end_public_function */
44054
44098
 
44055
- var index$6 = /*#__PURE__*/Object.freeze({
44099
+ var index$7 = /*#__PURE__*/Object.freeze({
44056
44100
  __proto__: null,
44057
44101
  createPoll: createPoll,
44058
44102
  closePoll: closePoll,
@@ -44435,7 +44479,7 @@ const getPlayer = async (parameters) => {
44435
44479
  return video;
44436
44480
  };
44437
44481
 
44438
- var index$5 = /*#__PURE__*/Object.freeze({
44482
+ var index$6 = /*#__PURE__*/Object.freeze({
44439
44483
  __proto__: null,
44440
44484
  getPlayer: getPlayer
44441
44485
  });
@@ -45608,7 +45652,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
45608
45652
  };
45609
45653
  };
45610
45654
 
45611
- var index$4 = /*#__PURE__*/Object.freeze({
45655
+ var index$5 = /*#__PURE__*/Object.freeze({
45612
45656
  __proto__: null,
45613
45657
  createImageStory: createImageStory,
45614
45658
  createVideoStory: createVideoStory,
@@ -45645,7 +45689,7 @@ const getNetworkAds = async () => {
45645
45689
  };
45646
45690
  };
45647
45691
 
45648
- var index$3 = /*#__PURE__*/Object.freeze({
45692
+ var index$4 = /*#__PURE__*/Object.freeze({
45649
45693
  __proto__: null,
45650
45694
  getNetworkAds: getNetworkAds
45651
45695
  });
@@ -46036,7 +46080,7 @@ const markTraySeen = async (lastSeenAt) => {
46036
46080
  };
46037
46081
  /* end_public_function */
46038
46082
 
46039
- var index$2 = /*#__PURE__*/Object.freeze({
46083
+ var index$3 = /*#__PURE__*/Object.freeze({
46040
46084
  __proto__: null,
46041
46085
  getNotificationTraySeen: getNotificationTraySeen,
46042
46086
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46237,7 +46281,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46237
46281
  };
46238
46282
  };
46239
46283
 
46240
- var index$1 = /*#__PURE__*/Object.freeze({
46284
+ var index$2 = /*#__PURE__*/Object.freeze({
46241
46285
  __proto__: null,
46242
46286
  onLocalInvitationCreated: onLocalInvitationCreated,
46243
46287
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -46378,11 +46422,53 @@ const getReactions = (postId, callback) => {
46378
46422
  };
46379
46423
  };
46380
46424
 
46381
- var index = /*#__PURE__*/Object.freeze({
46425
+ var index$1 = /*#__PURE__*/Object.freeze({
46382
46426
  __proto__: null,
46383
46427
  createReaction: createReaction,
46384
46428
  onLiveReactionCreated: onLiveReactionCreated,
46385
46429
  getReactions: getReactions
46386
46430
  });
46387
46431
 
46388
- export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$a as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$c as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, FeedDataTypeEnum, index$9 as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$l as FileRepository, FileType, GET_WATCHER_URLS, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$j as MessageRepository, index$6 as PollRepository, PostContentType, index$8 as PostRepository, PostStructureType, index$k as ReactionRepository, index$4 as StoryRepository, index$7 as StreamRepository, index$i as SubChannelRepository, SubscriptionLevels, index$m 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, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$2 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 };
46432
+ const prepareEventPayload = (rawPayload) => {
46433
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
46434
+ };
46435
+
46436
+ /* begin_public_function
46437
+ id: event.create
46438
+ */
46439
+ /**
46440
+ * ```js
46441
+ * import { createEvent } from '@amityco/ts-sdk'
46442
+ * const created = await createEvent(bundle)
46443
+ * ```
46444
+ *
46445
+ * Creates an {@link Amity.Event}
46446
+ *
46447
+ * @param bundle The data necessary to create a new {@link Amity.Event}
46448
+ * @returns The newly created {@link Amity.Event}
46449
+ *
46450
+ * @category Event API
46451
+ * @async
46452
+ */
46453
+ const createEvent = async (bundle) => {
46454
+ const client = getActiveClient();
46455
+ client.log('event/createEvent', bundle);
46456
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
46457
+ const preparedPayload = prepareEventPayload(payload);
46458
+ const cachedAt = client.cache && Date.now();
46459
+ if (client.cache)
46460
+ ingestInCache(preparedPayload, { cachedAt });
46461
+ fireEvent('event.created', preparedPayload);
46462
+ return {
46463
+ data: eventLinkedObject(preparedPayload.events[0]),
46464
+ cachedAt,
46465
+ };
46466
+ };
46467
+ /* end_public_function */
46468
+
46469
+ var index = /*#__PURE__*/Object.freeze({
46470
+ __proto__: null,
46471
+ createEvent: createEvent
46472
+ });
46473
+
46474
+ export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventStatus, AmityEventType, index$c as CategoryRepository, index$g as ChannelRepository, index$p as Client, index$b as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$d as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$7 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$5 as StoryRepository, index$8 as StreamRepository, index$j as SubChannelRepository, SubscriptionLevels, index$n 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, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 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 };