@amityco/ts-sdk 7.11.1-8ca038e4.0 → 7.11.1-8ef0bbb7.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 (107) hide show
  1. package/dist/@types/core/events.d.ts +13 -32
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +3 -2
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +4 -15
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/content.d.ts +4 -1
  8. package/dist/@types/domains/content.d.ts.map +1 -1
  9. package/dist/@types/domains/post.d.ts +2 -0
  10. package/dist/@types/domains/post.d.ts.map +1 -1
  11. package/dist/@types/domains/room.d.ts +71 -0
  12. package/dist/@types/domains/room.d.ts.map +1 -0
  13. package/dist/@types/index.d.ts +2 -1
  14. package/dist/@types/index.d.ts.map +1 -1
  15. package/dist/core/events.d.ts +3 -3
  16. package/dist/core/events.d.ts.map +1 -1
  17. package/dist/core/model/idResolvers.d.ts.map +1 -1
  18. package/dist/core/model/index.d.ts.map +1 -1
  19. package/dist/index.cjs.js +935 -318
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.esm.js +746 -129
  23. package/dist/index.umd.js +3 -3
  24. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  25. package/dist/roomRepository/api/createRoom.d.ts +24 -0
  26. package/dist/roomRepository/api/createRoom.d.ts.map +1 -0
  27. package/dist/roomRepository/api/deleteRoom.d.ts +16 -0
  28. package/dist/roomRepository/api/deleteRoom.d.ts.map +1 -0
  29. package/dist/roomRepository/api/getRecordedUrl.d.ts +19 -0
  30. package/dist/roomRepository/api/getRecordedUrl.d.ts.map +1 -0
  31. package/dist/roomRepository/api/getRoomToken.d.ts +16 -0
  32. package/dist/roomRepository/api/getRoomToken.d.ts.map +1 -0
  33. package/dist/roomRepository/api/index.d.ts +7 -0
  34. package/dist/roomRepository/api/index.d.ts.map +1 -0
  35. package/dist/roomRepository/api/stopRoom.d.ts +16 -0
  36. package/dist/roomRepository/api/stopRoom.d.ts.map +1 -0
  37. package/dist/roomRepository/api/updateRoom.d.ts +24 -0
  38. package/dist/roomRepository/api/updateRoom.d.ts.map +1 -0
  39. package/dist/roomRepository/events/index.d.ts +12 -0
  40. package/dist/roomRepository/events/index.d.ts.map +1 -0
  41. package/dist/roomRepository/events/onRoomCreated.d.ts +17 -0
  42. package/dist/roomRepository/events/onRoomCreated.d.ts.map +1 -0
  43. package/dist/roomRepository/events/onRoomDeleted.d.ts +17 -0
  44. package/dist/roomRepository/events/onRoomDeleted.d.ts.map +1 -0
  45. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +17 -0
  46. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -0
  47. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +17 -0
  48. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +1 -0
  49. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +17 -0
  50. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -0
  51. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +17 -0
  52. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -0
  53. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +17 -0
  54. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -0
  55. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +17 -0
  56. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -0
  57. package/dist/roomRepository/events/onRoomStopped.d.ts +17 -0
  58. package/dist/roomRepository/events/onRoomStopped.d.ts.map +1 -0
  59. package/dist/roomRepository/events/onRoomUpdated.d.ts +17 -0
  60. package/dist/roomRepository/events/onRoomUpdated.d.ts.map +1 -0
  61. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +17 -0
  62. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -0
  63. package/dist/roomRepository/index.d.ts +4 -0
  64. package/dist/roomRepository/index.d.ts.map +1 -0
  65. package/dist/roomRepository/internalApi/getRoomById.d.ts +5 -0
  66. package/dist/roomRepository/internalApi/getRoomById.d.ts.map +1 -0
  67. package/dist/roomRepository/internalApi/index.d.ts +2 -0
  68. package/dist/roomRepository/internalApi/index.d.ts.map +1 -0
  69. package/dist/roomRepository/observers/enums.d.ts +10 -0
  70. package/dist/roomRepository/observers/enums.d.ts.map +1 -0
  71. package/dist/roomRepository/observers/getRoom.d.ts +2 -0
  72. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -0
  73. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +14 -0
  74. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +1 -0
  75. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +5 -0
  76. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +1 -0
  77. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +15 -0
  78. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +1 -0
  79. package/dist/roomRepository/observers/getRooms.d.ts +29 -0
  80. package/dist/roomRepository/observers/getRooms.d.ts.map +1 -0
  81. package/dist/roomRepository/observers/index.d.ts +3 -0
  82. package/dist/roomRepository/observers/index.d.ts.map +1 -0
  83. package/dist/roomRepository/observers/utils.d.ts +6 -0
  84. package/dist/roomRepository/observers/utils.d.ts.map +1 -0
  85. package/dist/utils/linkedObject/index.d.ts +0 -1
  86. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  87. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  88. package/dist/utils/postTypePredicate.d.ts +1 -0
  89. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  90. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  91. package/package.json +1 -1
  92. package/dist/@types/domains/event.d.ts +0 -57
  93. package/dist/@types/domains/event.d.ts.map +0 -1
  94. package/dist/eventRepository/api/createEvent.d.ts +0 -16
  95. package/dist/eventRepository/api/createEvent.d.ts.map +0 -1
  96. package/dist/eventRepository/api/index.d.ts +0 -3
  97. package/dist/eventRepository/api/index.d.ts.map +0 -1
  98. package/dist/eventRepository/api/updateEvent.d.ts +0 -17
  99. package/dist/eventRepository/api/updateEvent.d.ts.map +0 -1
  100. package/dist/eventRepository/index.d.ts +0 -2
  101. package/dist/eventRepository/index.d.ts.map +0 -1
  102. package/dist/eventRepository/utils/index.d.ts +0 -2
  103. package/dist/eventRepository/utils/index.d.ts.map +0 -1
  104. package/dist/eventRepository/utils/prepareEventPayload.d.ts +0 -2
  105. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +0 -1
  106. package/dist/utils/linkedObject/eventLinkObject.d.ts +0 -2
  107. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +0 -1
package/dist/index.esm.js CHANGED
@@ -112,6 +112,7 @@ const PostContentType = Object.freeze({
112
112
  POLL: 'poll',
113
113
  CLIP: 'clip',
114
114
  AUDIO: 'audio',
115
+ ROOM: 'room',
115
116
  });
116
117
  const PostStructureType = Object.freeze({
117
118
  TEXT: 'text',
@@ -177,24 +178,6 @@ var FeedSourceEnum;
177
178
  FeedSourceEnum["User"] = "user";
178
179
  })(FeedSourceEnum || (FeedSourceEnum = {}));
179
180
 
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
-
198
181
  function getVersion() {
199
182
  try {
200
183
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -643,6 +626,7 @@ const idResolvers = {
643
626
  notificationTraySeen: ({ userId }) => userId,
644
627
  invitation: ({ _id }) => _id,
645
628
  joinRequest: ({ joinRequestId }) => joinRequestId,
629
+ room: ({ roomId }) => roomId,
646
630
  };
647
631
  /**
648
632
  * Retrieve the id resolver matching a domain name
@@ -698,6 +682,7 @@ const PAYLOAD2MODEL = {
698
682
  notificationTrayItems: 'notificationTrayItem',
699
683
  invitations: 'invitation',
700
684
  joinRequests: 'joinRequest',
685
+ rooms: 'room',
701
686
  };
702
687
  /** hidden */
703
688
  const isOutdated = (prevData, nextData) => {
@@ -28317,6 +28302,12 @@ function isAmityAudioPost(post) {
28317
28302
  'fileId' in post.data &&
28318
28303
  post.dataType === 'audio');
28319
28304
  }
28305
+ function isAmityRoomPost(post) {
28306
+ return !!(post.data &&
28307
+ typeof post.data !== 'string' &&
28308
+ 'roomId' in post.data &&
28309
+ post.dataType === 'room');
28310
+ }
28320
28311
 
28321
28312
  const postLinkedObject = (post) => {
28322
28313
  return shallowClone(post, {
@@ -28411,6 +28402,12 @@ const postLinkedObject = (post) => {
28411
28402
  ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
28412
28403
  : undefined;
28413
28404
  },
28405
+ getRoomInfo() {
28406
+ var _a, _b;
28407
+ if (!isAmityRoomPost(post))
28408
+ return;
28409
+ return (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
28410
+ },
28414
28411
  });
28415
28412
  };
28416
28413
 
@@ -29768,31 +29765,6 @@ const communityLinkedObject = (community) => {
29768
29765
  } });
29769
29766
  };
29770
29767
 
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
-
29796
29768
  const LinkedObject = {
29797
29769
  ad: adLinkedObject,
29798
29770
  comment: commentLinkedObject,
@@ -29811,7 +29783,6 @@ const LinkedObject = {
29811
29783
  invitation: invitationLinkedObject,
29812
29784
  joinRequest: joinRequestLinkedObject,
29813
29785
  channelMember: channelMemberLinkedObject,
29814
- event: eventLinkedObject,
29815
29786
  };
29816
29787
 
29817
29788
  /* begin_public_function
@@ -43796,6 +43767,729 @@ var index$8 = /*#__PURE__*/Object.freeze({
43796
43767
  getStreams: getStreams
43797
43768
  });
43798
43769
 
43770
+ /* begin_public_function
43771
+ id: room.create
43772
+ */
43773
+ /**
43774
+ * ```js
43775
+ * import { createRoom } from '@amityco/ts-sdk'
43776
+ * const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
43777
+ * ```
43778
+ *
43779
+ * Creates an {@link Amity.Room}
43780
+ *
43781
+ * @param bundle The data necessary to create a new {@link Amity.Room}
43782
+ * @returns The newly created {@link Amity.Room}
43783
+ *
43784
+ * @category Room API
43785
+ * @async
43786
+ */
43787
+ const createRoom = async (bundle) => {
43788
+ const client = getActiveClient();
43789
+ client.log('room/createRoom', bundle);
43790
+ const { data } = await client.http.post('/api/v1/rooms', bundle);
43791
+ fireEvent('local.room.created', data);
43792
+ const cachedAt = client.cache && Date.now();
43793
+ // TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
43794
+ if (client.cache)
43795
+ ingestInCache(data, { cachedAt });
43796
+ const { rooms } = data;
43797
+ return {
43798
+ data: rooms[0],
43799
+ cachedAt,
43800
+ };
43801
+ };
43802
+ /* end_public_function */
43803
+
43804
+ /* begin_public_function
43805
+ id: room.update
43806
+ */
43807
+ /**
43808
+ * ```js
43809
+ * import { updateRoom } from '@amityco/ts-sdk'
43810
+ * const updated = await updateRoom('roomId', { title: 'updated title' })
43811
+ * ```
43812
+ *
43813
+ * Updates an {@link Amity.InternalRoom}
43814
+ *
43815
+ * @param roomId The ID of the room to update
43816
+ * @param bundle The data to update the room with
43817
+ * @returns The updated {@link Amity.InternalRoom}
43818
+ *
43819
+ * @category Room API
43820
+ * @async
43821
+ */
43822
+ const updateRoom = async (roomId, bundle) => {
43823
+ const client = getActiveClient();
43824
+ client.log('room/updateRoom', { roomId, bundle });
43825
+ const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
43826
+ fireEvent('local.room.updated', data);
43827
+ const cachedAt = client.cache && Date.now();
43828
+ if (client.cache)
43829
+ ingestInCache(data, { cachedAt });
43830
+ const { rooms } = data;
43831
+ return {
43832
+ data: rooms[0],
43833
+ cachedAt,
43834
+ };
43835
+ };
43836
+ /* end_public_function */
43837
+
43838
+ /* begin_public_function
43839
+ id: room.delete
43840
+ */
43841
+ /**
43842
+ * ```js
43843
+ * import { deleteRoom } from '@amityco/ts-sdk'
43844
+ * const result = await deleteRoom('roomId')
43845
+ * ```
43846
+ *
43847
+ * Deletes an {@link Amity.Room}
43848
+ *
43849
+ * @param roomId The ID of the room to delete
43850
+ * @returns Promise that resolves when the room is deleted
43851
+ *
43852
+ * @category Room API
43853
+ * @async
43854
+ */
43855
+ const deleteRoom = async (roomId) => {
43856
+ const client = getActiveClient();
43857
+ client.log('room/deleteRoom', { roomId });
43858
+ await client.http.delete(`/api/v1/rooms/${roomId}`);
43859
+ fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
43860
+ };
43861
+ /* end_public_function */
43862
+
43863
+ /* begin_public_function
43864
+ id: room.stop
43865
+ */
43866
+ /**
43867
+ * ```js
43868
+ * import { stopRoom } from '@amityco/ts-sdk'
43869
+ * const result = await stopRoom('roomId')
43870
+ * ```
43871
+ *
43872
+ * Stops a room's broadcasting
43873
+ *
43874
+ * @param roomId The ID of the room to stop
43875
+ * @returns The updated room data
43876
+ *
43877
+ * @category Room API
43878
+ * @async
43879
+ */
43880
+ const stopRoom = async (roomId) => {
43881
+ const client = getActiveClient();
43882
+ client.log('room/stopRoom', { roomId });
43883
+ const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
43884
+ fireEvent('local.room.stopped', data);
43885
+ const cachedAt = client.cache && Date.now();
43886
+ if (client.cache)
43887
+ ingestInCache(data, { cachedAt });
43888
+ const { rooms } = data;
43889
+ return {
43890
+ data: rooms[0],
43891
+ cachedAt,
43892
+ };
43893
+ };
43894
+ /* end_public_function */
43895
+
43896
+ /* begin_public_function
43897
+ id: room.getToken
43898
+ */
43899
+ /**
43900
+ * ```js
43901
+ * import { getRoomToken } from '@amityco/ts-sdk'
43902
+ * const token = await getRoomToken('roomId')
43903
+ * ```
43904
+ *
43905
+ * Gets an access token for a room
43906
+ *
43907
+ * @param roomId The ID of the room to get token for
43908
+ * @returns The room access token
43909
+ *
43910
+ * @category Room API
43911
+ * @async
43912
+ */
43913
+ const getRoomToken = async (roomId) => {
43914
+ const client = getActiveClient();
43915
+ client.log('room/getRoomToken', { roomId });
43916
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
43917
+ return data;
43918
+ };
43919
+ /* end_public_function */
43920
+
43921
+ /* begin_public_function
43922
+ id: room.getRecordedUrl
43923
+ */
43924
+ /**
43925
+ * ```js
43926
+ * import { getRecordedUrl } from '@amityco/ts-sdk'
43927
+ * const recordedUrl = await getRecordedUrl('roomId')
43928
+ * ```
43929
+ *
43930
+ * Gets the recorded URL for a room
43931
+ *
43932
+ * @param roomId The ID of the room to get recorded URL for
43933
+ * @returns The recorded URL information
43934
+ *
43935
+ * @category Room API
43936
+ * @async
43937
+ */
43938
+ const getRecordedUrl = async (roomId) => {
43939
+ const client = getActiveClient();
43940
+ client.log('room/getRecordedUrl', { roomId });
43941
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
43942
+ return data;
43943
+ };
43944
+ /* end_public_function */
43945
+
43946
+ /**
43947
+ * ```js
43948
+ * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
43949
+ * const dispose = onRoomStartBroadcasting(room => {
43950
+ * // ...
43951
+ * })
43952
+ * ```
43953
+ *
43954
+ * Fired when a {@link Amity.Room} has started broadcasting
43955
+ *
43956
+ * @param callback The function to call when the event was fired
43957
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
43958
+ *
43959
+ * @category Room Events
43960
+ */
43961
+ const onRoomStartBroadcasting = (callback) => {
43962
+ const client = getActiveClient();
43963
+ const filter = (payload) => {
43964
+ ingestInCache(payload);
43965
+ callback(payload.rooms[0]);
43966
+ };
43967
+ return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
43968
+ };
43969
+
43970
+ /**
43971
+ * ```js
43972
+ * import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
43973
+ * const dispose = onRoomWaitingReconnect(room => {
43974
+ * // ...
43975
+ * })
43976
+ * ```
43977
+ *
43978
+ * Fired when a {@link Amity.Room} is waiting for reconnection
43979
+ *
43980
+ * @param callback The function to call when the event was fired
43981
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
43982
+ *
43983
+ * @category Room Events
43984
+ */
43985
+ const onRoomWaitingReconnect = (callback) => {
43986
+ const client = getActiveClient();
43987
+ const filter = (payload) => {
43988
+ ingestInCache(payload);
43989
+ callback(payload.rooms[0]);
43990
+ };
43991
+ return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
43992
+ };
43993
+
43994
+ /**
43995
+ * ```js
43996
+ * import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
43997
+ * const dispose = onRoomEndBroadcasting(room => {
43998
+ * // ...
43999
+ * })
44000
+ * ```
44001
+ *
44002
+ * Fired when a {@link Amity.Room} has ended broadcasting
44003
+ *
44004
+ * @param callback The function to call when the event was fired
44005
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44006
+ *
44007
+ * @category Room Events
44008
+ */
44009
+ const onRoomEndBroadcasting = (callback) => {
44010
+ const client = getActiveClient();
44011
+ const filter = (payload) => {
44012
+ ingestInCache(payload);
44013
+ callback(payload.rooms[0]);
44014
+ };
44015
+ return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
44016
+ };
44017
+
44018
+ /**
44019
+ * ```js
44020
+ * import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
44021
+ * const dispose = onRoomRecordedAvailable(room => {
44022
+ * // ...
44023
+ * })
44024
+ * ```
44025
+ *
44026
+ * Fired when a {@link Amity.Room} recorded content becomes available
44027
+ *
44028
+ * @param callback The function to call when the event was fired
44029
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44030
+ *
44031
+ * @category Room Events
44032
+ */
44033
+ const onRoomRecordedAvailable = (callback) => {
44034
+ const client = getActiveClient();
44035
+ const filter = (payload) => {
44036
+ ingestInCache(payload);
44037
+ callback(payload.rooms[0]);
44038
+ };
44039
+ return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
44040
+ };
44041
+
44042
+ /**
44043
+ * ```js
44044
+ * import { onRoomParticipantInviting } from '@amityco/ts-sdk'
44045
+ * const dispose = onRoomParticipantInviting(room => {
44046
+ * // ...
44047
+ * })
44048
+ * ```
44049
+ *
44050
+ * Fired when a participant is being invited to a {@link Amity.Room}
44051
+ *
44052
+ * @param callback The function to call when the event was fired
44053
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44054
+ *
44055
+ * @category Room Events
44056
+ */
44057
+ const onRoomParticipantInviting = (callback) => {
44058
+ const client = getActiveClient();
44059
+ const filter = (payload) => {
44060
+ ingestInCache(payload);
44061
+ callback(payload.rooms[0]);
44062
+ };
44063
+ return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
44064
+ };
44065
+
44066
+ /**
44067
+ * ```js
44068
+ * import { onRoomParticipantJoined } from '@amityco/ts-sdk'
44069
+ * const dispose = onRoomParticipantJoined(room => {
44070
+ * // ...
44071
+ * })
44072
+ * ```
44073
+ *
44074
+ * Fired when a participant has joined a {@link Amity.Room}
44075
+ *
44076
+ * @param callback The function to call when the event was fired
44077
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44078
+ *
44079
+ * @category Room Events
44080
+ */
44081
+ const onRoomParticipantJoined = (callback) => {
44082
+ const client = getActiveClient();
44083
+ const filter = (payload) => {
44084
+ ingestInCache(payload);
44085
+ callback(payload.rooms[0]);
44086
+ };
44087
+ return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
44088
+ };
44089
+
44090
+ /**
44091
+ * ```js
44092
+ * import { onRoomParticipantLeft } from '@amityco/ts-sdk'
44093
+ * const dispose = onRoomParticipantLeft(room => {
44094
+ * // ...
44095
+ * })
44096
+ * ```
44097
+ *
44098
+ * Fired when a participant has left a {@link Amity.Room}
44099
+ *
44100
+ * @param callback The function to call when the event was fired
44101
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44102
+ *
44103
+ * @category Room Events
44104
+ */
44105
+ const onRoomParticipantLeft = (callback) => {
44106
+ const client = getActiveClient();
44107
+ const filter = (payload) => {
44108
+ ingestInCache(payload);
44109
+ callback(payload.rooms[0]);
44110
+ };
44111
+ return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
44112
+ };
44113
+
44114
+ /**
44115
+ * ```js
44116
+ * import { onRoomCreated } from '@amityco/ts-sdk'
44117
+ * const dispose = onRoomCreated(room => {
44118
+ * // ...
44119
+ * })
44120
+ * ```
44121
+ *
44122
+ * Fired when a {@link Amity.Room} has been created locally
44123
+ *
44124
+ * @param callback The function to call when the event was fired
44125
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44126
+ *
44127
+ * @category Room Events
44128
+ */
44129
+ const onRoomCreated = (callback) => {
44130
+ const client = getActiveClient();
44131
+ const filter = (payload) => {
44132
+ ingestInCache(payload);
44133
+ callback(payload.rooms[0]);
44134
+ };
44135
+ return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
44136
+ };
44137
+
44138
+ /**
44139
+ * ```js
44140
+ * import { onRoomUpdated } from '@amityco/ts-sdk'
44141
+ * const dispose = onRoomUpdated(room => {
44142
+ * // ...
44143
+ * })
44144
+ * ```
44145
+ *
44146
+ * Fired when a {@link Amity.Room} has been updated locally
44147
+ *
44148
+ * @param callback The function to call when the event was fired
44149
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44150
+ *
44151
+ * @category Room Events
44152
+ */
44153
+ const onRoomUpdated = (callback) => {
44154
+ const client = getActiveClient();
44155
+ const filter = (payload) => {
44156
+ ingestInCache(payload);
44157
+ callback(payload.rooms[0]);
44158
+ };
44159
+ return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
44160
+ };
44161
+
44162
+ /**
44163
+ * ```js
44164
+ * import { onRoomDeleted } from '@amityco/ts-sdk'
44165
+ * const dispose = onRoomDeleted(room => {
44166
+ * // ...
44167
+ * })
44168
+ * ```
44169
+ *
44170
+ * Fired when a {@link Amity.Room} has been deleted locally
44171
+ *
44172
+ * @param callback The function to call when the event was fired
44173
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44174
+ *
44175
+ * @category Room Events
44176
+ */
44177
+ const onRoomDeleted = (callback) => {
44178
+ const client = getActiveClient();
44179
+ const filter = (payload) => {
44180
+ ingestInCache(payload);
44181
+ callback(payload.rooms[0]);
44182
+ };
44183
+ return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
44184
+ };
44185
+
44186
+ /**
44187
+ * ```js
44188
+ * import { onRoomStopped } from '@amityco/ts-sdk'
44189
+ * const dispose = onRoomStopped(room => {
44190
+ * // ...
44191
+ * })
44192
+ * ```
44193
+ *
44194
+ * Fired when a {@link Amity.Room} has been stopped locally
44195
+ *
44196
+ * @param callback The function to call when the event was fired
44197
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44198
+ *
44199
+ * @category Room Events
44200
+ */
44201
+ const onRoomStopped = (callback) => {
44202
+ const client = getActiveClient();
44203
+ const filter = (payload) => {
44204
+ ingestInCache(payload);
44205
+ callback(payload.rooms[0]);
44206
+ };
44207
+ return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
44208
+ };
44209
+
44210
+ const getRoomById = async (roomId) => {
44211
+ const client = getActiveClient();
44212
+ client.log('room/getRoomById', roomId);
44213
+ // Check if room is in tombstone
44214
+ isInTombstone('room', roomId);
44215
+ let data;
44216
+ try {
44217
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44218
+ data = response.data;
44219
+ }
44220
+ catch (error) {
44221
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44222
+ pushToTombstone('room', roomId);
44223
+ }
44224
+ throw error;
44225
+ }
44226
+ const cachedAt = client.cache && Date.now();
44227
+ if (client.cache) {
44228
+ ingestInCache(data, { cachedAt });
44229
+ }
44230
+ return {
44231
+ data: data.rooms[0],
44232
+ cachedAt,
44233
+ };
44234
+ };
44235
+ getRoomById.locally = (roomId) => {
44236
+ const client = getActiveClient();
44237
+ client.log('room/getRoomById.locally', roomId);
44238
+ // Check if room is in tombstone
44239
+ isInTombstone('room', roomId);
44240
+ const cachedAt = client.cache && Date.now();
44241
+ const roomCache = pullFromCache(['room', 'get', roomId]);
44242
+ if (!roomCache)
44243
+ return;
44244
+ return {
44245
+ data: roomCache.data,
44246
+ cachedAt,
44247
+ };
44248
+ };
44249
+
44250
+ const getRoom = (roomId, callback) => {
44251
+ // TODO: add callbackDataSelector if there are linked object fields
44252
+ return liveObject(roomId, callback, '_id', getRoomById, [
44253
+ onRoomEndBroadcasting,
44254
+ onRoomStartBroadcasting,
44255
+ onRoomWaitingReconnect,
44256
+ onRoomRecordedAvailable,
44257
+ ]);
44258
+ };
44259
+
44260
+ class RoomPaginationController extends PaginationController {
44261
+ async getRequest(queryParams, token) {
44262
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
44263
+ const baseOptions = {
44264
+ type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
44265
+ };
44266
+ const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
44267
+ const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
44268
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
44269
+ });
44270
+ return queryResponse;
44271
+ }
44272
+ }
44273
+
44274
+ var EnumRoomActions;
44275
+ (function (EnumRoomActions) {
44276
+ EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
44277
+ EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
44278
+ EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
44279
+ EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
44280
+ EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
44281
+ EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
44282
+ EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
44283
+ })(EnumRoomActions || (EnumRoomActions = {}));
44284
+
44285
+ class RoomQueryStreamController extends QueryStreamController {
44286
+ constructor(query, cacheKey, notifyChange, preparePayload) {
44287
+ super(query, cacheKey);
44288
+ this.notifyChange = notifyChange;
44289
+ this.preparePayload = preparePayload;
44290
+ }
44291
+ async saveToMainDB(response) {
44292
+ const processedPayload = await this.preparePayload(response);
44293
+ const client = getActiveClient();
44294
+ const cachedAt = client.cache && Date.now();
44295
+ if (client.cache) {
44296
+ ingestInCache(processedPayload, { cachedAt });
44297
+ }
44298
+ }
44299
+ appendToQueryStream(response, direction, refresh = false) {
44300
+ var _a, _b;
44301
+ if (refresh) {
44302
+ pushToCache(this.cacheKey, {
44303
+ data: response.rooms.map(getResolver('room')),
44304
+ });
44305
+ }
44306
+ else {
44307
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44308
+ const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
44309
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
44310
+ }
44311
+ }
44312
+ reactor(action) {
44313
+ return (room) => {
44314
+ var _a;
44315
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44316
+ if (!collection)
44317
+ return;
44318
+ if (action === EnumRoomActions.OnRoomDeleted) {
44319
+ collection.data = collection.data.filter(roomId => roomId !== room._id);
44320
+ }
44321
+ if (action === EnumRoomActions.OnRoomCreated) {
44322
+ collection.data = [...new Set([room._id, ...collection.data])];
44323
+ }
44324
+ pushToCache(this.cacheKey, collection);
44325
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
44326
+ };
44327
+ }
44328
+ subscribeRTE(createSubscriber) {
44329
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
44330
+ }
44331
+ }
44332
+
44333
+ // TODO: confirm related events
44334
+ const getRoomSubscription = () => [
44335
+ {
44336
+ fn: onRoomStartBroadcasting,
44337
+ action: EnumRoomActions.OnRoomStartBroadcasting,
44338
+ },
44339
+ {
44340
+ fn: onRoomEndBroadcasting,
44341
+ action: EnumRoomActions.OnRoomEndBroadcasting,
44342
+ },
44343
+ {
44344
+ fn: onRoomRecordedAvailable,
44345
+ action: EnumRoomActions.OnRoomUpdated,
44346
+ },
44347
+ ];
44348
+
44349
+ class RoomLiveCollectionController extends LiveCollectionController {
44350
+ constructor(query, callback) {
44351
+ const queryStreamId = hash(query);
44352
+ const cacheKey = ['rooms', 'collection', queryStreamId];
44353
+ const paginationController = new RoomPaginationController(query);
44354
+ super(paginationController, queryStreamId, cacheKey, callback);
44355
+ this.query = query;
44356
+ this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
44357
+ this.callback = callback.bind(this);
44358
+ this.loadPage({ initial: true });
44359
+ }
44360
+ setup() {
44361
+ var _a;
44362
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44363
+ if (!collection) {
44364
+ pushToCache(this.cacheKey, {
44365
+ data: [],
44366
+ params: {},
44367
+ });
44368
+ }
44369
+ }
44370
+ async persistModel(queryPayload) {
44371
+ await this.queryStreamController.saveToMainDB(queryPayload);
44372
+ }
44373
+ persistQueryStream({ response, direction, refresh, }) {
44374
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
44375
+ }
44376
+ startSubscription() {
44377
+ return this.queryStreamController.subscribeRTE(getRoomSubscription());
44378
+ }
44379
+ notifyChange({ origin, loading, error }) {
44380
+ var _a, _b;
44381
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44382
+ if (!collection)
44383
+ return;
44384
+ const data = this.applyFilter((_b = collection.data
44385
+ .map(id => pullFromCache(['room', 'get', id]))
44386
+ .filter(isNonNullable)
44387
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
44388
+ if (!this.shouldNotify(data) && origin === 'event')
44389
+ return;
44390
+ this.callback({
44391
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
44392
+ data,
44393
+ hasNextPage: !!this.paginationController.getNextToken(),
44394
+ loading,
44395
+ error,
44396
+ });
44397
+ }
44398
+ applyFilter(data) {
44399
+ let rooms = data;
44400
+ if (!this.query.includeDeleted) {
44401
+ rooms = filterByPropEquality(rooms, 'isDeleted', false);
44402
+ }
44403
+ if (this.query.statuses && this.query.statuses.length > 0) {
44404
+ rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
44405
+ }
44406
+ if (this.query.type) {
44407
+ rooms = filterByPropEquality(rooms, 'type', this.query.type);
44408
+ }
44409
+ switch (this.query.sortBy) {
44410
+ case 'firstCreated':
44411
+ rooms = rooms.sort(sortByFirstCreated);
44412
+ break;
44413
+ case 'lastCreated':
44414
+ default:
44415
+ rooms = rooms.sort(sortByLastCreated);
44416
+ break;
44417
+ }
44418
+ return rooms;
44419
+ }
44420
+ }
44421
+
44422
+ /* begin_public_function
44423
+ id: room.get_rooms
44424
+ */
44425
+ /**
44426
+ * ```js
44427
+ * import { RoomRepository } from '@amityco/ts-sdk'
44428
+ *
44429
+ * let rooms = []
44430
+ * const unsub = RoomRepository.getRooms({
44431
+ * type: 'direct_streaming',
44432
+ * statuses: ['live', 'idle'],
44433
+ * sortBy: 'lastCreated',
44434
+ * limit: 20,
44435
+ * includeDeleted: false
44436
+ * }, response => merge(rooms, response.data))
44437
+ * ```
44438
+ *
44439
+ * Observe all mutations on a list of {@link Amity.Room} for a given query
44440
+ *
44441
+ * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
44442
+ * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
44443
+ * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
44444
+ * @param params.limit maximum number of rooms to retrieve per page
44445
+ * @param params.includeDeleted whether to include deleted rooms in the results
44446
+ * @param callback the function to call when new data are available
44447
+ * @param config optional configuration for the live collection
44448
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
44449
+ *
44450
+ * @category Rooms Live Collection
44451
+ */
44452
+ const getRooms = (params, callback, config) => {
44453
+ const { log, cache } = getActiveClient();
44454
+ if (!cache) {
44455
+ console.log(ENABLE_CACHE_MESSAGE);
44456
+ }
44457
+ const timestamp = Date.now();
44458
+ log(`getRooms(tmpid: ${timestamp}) > listen`);
44459
+ const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
44460
+ const disposers = roomsLiveCollection.startSubscription();
44461
+ const cacheKey = roomsLiveCollection.getCacheKey();
44462
+ disposers.push(() => dropFromCache(cacheKey));
44463
+ return () => {
44464
+ log(`getRooms(tmpid: ${timestamp}) > dispose`);
44465
+ disposers.forEach(fn => fn());
44466
+ };
44467
+ };
44468
+ /* end_public_function */
44469
+
44470
+ var index$7 = /*#__PURE__*/Object.freeze({
44471
+ __proto__: null,
44472
+ createRoom: createRoom,
44473
+ updateRoom: updateRoom,
44474
+ deleteRoom: deleteRoom,
44475
+ stopRoom: stopRoom,
44476
+ getRoomToken: getRoomToken,
44477
+ getRecordedUrl: getRecordedUrl,
44478
+ onRoomStartBroadcasting: onRoomStartBroadcasting,
44479
+ onRoomWaitingReconnect: onRoomWaitingReconnect,
44480
+ onRoomEndBroadcasting: onRoomEndBroadcasting,
44481
+ onRoomRecordedAvailable: onRoomRecordedAvailable,
44482
+ onRoomParticipantInviting: onRoomParticipantInviting,
44483
+ onRoomParticipantJoined: onRoomParticipantJoined,
44484
+ onRoomParticipantLeft: onRoomParticipantLeft,
44485
+ onRoomCreated: onRoomCreated,
44486
+ onRoomUpdated: onRoomUpdated,
44487
+ onRoomDeleted: onRoomDeleted,
44488
+ onRoomStopped: onRoomStopped,
44489
+ getRoom: getRoom,
44490
+ getRooms: getRooms
44491
+ });
44492
+
43799
44493
  /* begin_public_function
43800
44494
  id: poll.create
43801
44495
  */
@@ -44096,7 +44790,7 @@ const getPoll = (pollId, callback) => {
44096
44790
  };
44097
44791
  /* end_public_function */
44098
44792
 
44099
- var index$7 = /*#__PURE__*/Object.freeze({
44793
+ var index$6 = /*#__PURE__*/Object.freeze({
44100
44794
  __proto__: null,
44101
44795
  createPoll: createPoll,
44102
44796
  closePoll: closePoll,
@@ -44479,7 +45173,7 @@ const getPlayer = async (parameters) => {
44479
45173
  return video;
44480
45174
  };
44481
45175
 
44482
- var index$6 = /*#__PURE__*/Object.freeze({
45176
+ var index$5 = /*#__PURE__*/Object.freeze({
44483
45177
  __proto__: null,
44484
45178
  getPlayer: getPlayer
44485
45179
  });
@@ -45652,7 +46346,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
45652
46346
  };
45653
46347
  };
45654
46348
 
45655
- var index$5 = /*#__PURE__*/Object.freeze({
46349
+ var index$4 = /*#__PURE__*/Object.freeze({
45656
46350
  __proto__: null,
45657
46351
  createImageStory: createImageStory,
45658
46352
  createVideoStory: createVideoStory,
@@ -45689,7 +46383,7 @@ const getNetworkAds = async () => {
45689
46383
  };
45690
46384
  };
45691
46385
 
45692
- var index$4 = /*#__PURE__*/Object.freeze({
46386
+ var index$3 = /*#__PURE__*/Object.freeze({
45693
46387
  __proto__: null,
45694
46388
  getNetworkAds: getNetworkAds
45695
46389
  });
@@ -46080,7 +46774,7 @@ const markTraySeen = async (lastSeenAt) => {
46080
46774
  };
46081
46775
  /* end_public_function */
46082
46776
 
46083
- var index$3 = /*#__PURE__*/Object.freeze({
46777
+ var index$2 = /*#__PURE__*/Object.freeze({
46084
46778
  __proto__: null,
46085
46779
  getNotificationTraySeen: getNotificationTraySeen,
46086
46780
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46281,7 +46975,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46281
46975
  };
46282
46976
  };
46283
46977
 
46284
- var index$2 = /*#__PURE__*/Object.freeze({
46978
+ var index$1 = /*#__PURE__*/Object.freeze({
46285
46979
  __proto__: null,
46286
46980
  onLocalInvitationCreated: onLocalInvitationCreated,
46287
46981
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -46422,88 +47116,11 @@ const getReactions = (postId, callback) => {
46422
47116
  };
46423
47117
  };
46424
47118
 
46425
- var index$1 = /*#__PURE__*/Object.freeze({
47119
+ var index = /*#__PURE__*/Object.freeze({
46426
47120
  __proto__: null,
46427
47121
  createReaction: createReaction,
46428
47122
  onLiveReactionCreated: onLiveReactionCreated,
46429
47123
  getReactions: getReactions
46430
47124
  });
46431
47125
 
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 { EventRepository } from '@amityco/ts-sdk'
46442
- * const response = await EventRepository.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
- fireEvent('event.created', payload);
46458
- const preparedPayload = prepareEventPayload(payload);
46459
- const cachedAt = client.cache && Date.now();
46460
- if (client.cache)
46461
- ingestInCache(preparedPayload, { cachedAt });
46462
- return {
46463
- data: eventLinkedObject(preparedPayload.events[0]),
46464
- cachedAt,
46465
- };
46466
- };
46467
- /* end_public_function */
46468
-
46469
- /* begin_public_function
46470
- id: event.update
46471
- */
46472
- /**
46473
- * ```js
46474
- * import { EventRepository } from '@amityco/ts-sdk'
46475
- * const response = await EventRepository.updateEvent(eventId, bundle)
46476
- * ```
46477
- *
46478
- * Updates an {@link Amity.Event}
46479
- *
46480
- * @param eventId The ID of the {@link Amity.Event} to edit
46481
- * @param bundle The data necessary to update an existing {@link Amity.Event}
46482
- * @returns the updated {@link Amity.Event}
46483
- *
46484
- * @category Event API
46485
- * @async
46486
- */
46487
- const updateEvent = async (eventId, bundle) => {
46488
- const client = getActiveClient();
46489
- client.log('event/updateEvent', eventId, bundle);
46490
- const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
46491
- fireEvent('event.updated', payload);
46492
- const preparedPayload = prepareEventPayload(payload);
46493
- const cachedAt = client.cache && Date.now();
46494
- if (client.cache)
46495
- ingestInCache(preparedPayload, { cachedAt });
46496
- return {
46497
- data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
46498
- cachedAt,
46499
- };
46500
- };
46501
- /* end_public_function */
46502
-
46503
- var index = /*#__PURE__*/Object.freeze({
46504
- __proto__: null,
46505
- createEvent: createEvent,
46506
- updateEvent: updateEvent
46507
- });
46508
-
46509
- 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 };
47126
+ export { API_REGIONS, index$3 as AdRepository, 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, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m 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$k as MessageRepository, index$6 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$7 as RoomRepository, index$4 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$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 };