@amityco/ts-sdk 7.25.1-dc6ca968.0 → 7.25.1-e54d9d4b.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 (43) hide show
  1. package/dist/@types/core/payload.d.ts +0 -1
  2. package/dist/@types/core/payload.d.ts.map +1 -1
  3. package/dist/@types/domains/client.d.ts +1 -0
  4. package/dist/@types/domains/client.d.ts.map +1 -1
  5. package/dist/@types/domains/content.d.ts +1 -6
  6. package/dist/@types/domains/content.d.ts.map +1 -1
  7. package/dist/@types/domains/file.d.ts +2 -11
  8. package/dist/@types/domains/file.d.ts.map +1 -1
  9. package/dist/@types/domains/liveViewerCount.d.ts +22 -0
  10. package/dist/@types/domains/liveViewerCount.d.ts.map +1 -0
  11. package/dist/@types/domains/post.d.ts +0 -3
  12. package/dist/@types/domains/post.d.ts.map +1 -1
  13. package/dist/@types/index.d.ts +1 -0
  14. package/dist/@types/index.d.ts.map +1 -1
  15. package/dist/client/api/createClient.d.ts.map +1 -1
  16. package/dist/client/api/getLiveViewerCountConfig.d.ts +24 -0
  17. package/dist/client/api/getLiveViewerCountConfig.d.ts.map +1 -0
  18. package/dist/client/api/index.d.ts +1 -0
  19. package/dist/client/api/index.d.ts.map +1 -1
  20. package/dist/fileRepository/api/getFile.d.ts.map +1 -1
  21. package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
  22. package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -1
  23. package/dist/index.cjs.js +61 -125
  24. package/dist/index.esm.js +62 -126
  25. package/dist/index.umd.js +2 -2
  26. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  27. package/dist/postRepository/api/index.d.ts +0 -1
  28. package/dist/postRepository/api/index.d.ts.map +1 -1
  29. package/dist/postRepository/api/tests/integration/setup.d.ts +0 -1
  30. package/dist/postRepository/api/tests/integration/setup.d.ts.map +1 -1
  31. package/dist/utils/linkedObject/index.d.ts +0 -1
  32. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  33. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  34. package/dist/utils/postTypePredicate.d.ts +0 -1
  35. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  36. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  37. package/dist/utils/tests/dummy/file.d.ts.map +1 -1
  38. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/postRepository/api/createEventPost.d.ts +0 -36
  41. package/dist/postRepository/api/createEventPost.d.ts.map +0 -1
  42. package/dist/utils/linkedObject/fileLinkedObject.d.ts +0 -2
  43. package/dist/utils/linkedObject/fileLinkedObject.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -162,7 +162,6 @@ const PostContentType = Object.freeze({
162
162
  CLIP: 'clip',
163
163
  AUDIO: 'audio',
164
164
  ROOM: 'room',
165
- EVENT: 'event',
166
165
  });
167
166
  const PostStructureType = Object.freeze({
168
167
  TEXT: 'text',
@@ -171,7 +170,6 @@ const PostStructureType = Object.freeze({
171
170
  FILE: 'file',
172
171
  AUDIO: 'audio',
173
172
  MIXED: 'mixed',
174
- EVENT: 'event',
175
173
  });
176
174
 
177
175
  exports.InvitationTypeEnum = void 0;
@@ -322,6 +320,13 @@ exports.NotificationRolesFilterTypeEnum = void 0;
322
320
  NotificationRolesFilterTypeEnum["ONLY"] = "only";
323
321
  })(exports.NotificationRolesFilterTypeEnum || (exports.NotificationRolesFilterTypeEnum = {}));
324
322
 
323
+ exports.AmityLiveViewerCountMode = void 0;
324
+ (function (AmityLiveViewerCountMode) {
325
+ AmityLiveViewerCountMode["ALWAYS_SHOW"] = "always";
326
+ AmityLiveViewerCountMode["HIDE_ENTIRELY"] = "hidden";
327
+ AmityLiveViewerCountMode["SHOW_ABOVE_MINIMUM"] = "above-minimum";
328
+ })(exports.AmityLiveViewerCountMode || (exports.AmityLiveViewerCountMode = {}));
329
+
325
330
  function getVersion() {
326
331
  try {
327
332
  // the string ''v7.25.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
@@ -5021,6 +5026,51 @@ const getCoreUserSettings = async () => {
5021
5026
  return data;
5022
5027
  };
5023
5028
 
5029
+ const DEFAULT_CONFIG = {
5030
+ mode: exports.AmityLiveViewerCountMode.ALWAYS_SHOW,
5031
+ threshold: 50,
5032
+ };
5033
+ const isValidMode = (value) => value === exports.AmityLiveViewerCountMode.ALWAYS_SHOW ||
5034
+ value === exports.AmityLiveViewerCountMode.HIDE_ENTIRELY ||
5035
+ value === exports.AmityLiveViewerCountMode.SHOW_ABOVE_MINIMUM;
5036
+ const isValidThreshold = (value) => typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 1000;
5037
+ /**
5038
+ * ```js
5039
+ * import { getLiveViewerCountConfig } from '@amityco/ts-sdk'
5040
+ * const config = await getLiveViewerCountConfig()
5041
+ * ```
5042
+ *
5043
+ * Fetches the network-level {@link Amity.LiveViewerCountConfig} governing
5044
+ * how the live viewer count is displayed to viewers on a livestream.
5045
+ *
5046
+ * Cold-read — no observable, no cache. Call once per livestream mount /
5047
+ * rejoin. Admin-driven config changes take effect on the next join, not
5048
+ * mid-stream.
5049
+ *
5050
+ * On a malformed payload (unknown mode, out-of-range or missing threshold)
5051
+ * the SDK falls open to `{ mode: ALWAYS_SHOW, threshold: 50 }` and logs a
5052
+ * warning. Network errors reject.
5053
+ *
5054
+ * @returns A Promise of {@link Amity.LiveViewerCountConfig}
5055
+ *
5056
+ * @category Client API
5057
+ * @async
5058
+ */
5059
+ /* begin_public_function id: client.getLiveViewerCountConfig */
5060
+ const getLiveViewerCountConfig = async () => {
5061
+ var _a, _b;
5062
+ const client = getActiveClient();
5063
+ const { data } = await client.http.get('/api/v3/network-settings/video-streaming');
5064
+ const mode = (_a = data === null || data === void 0 ? void 0 : data.videoStreaming) === null || _a === void 0 ? void 0 : _a.viewerCountDisplayMode;
5065
+ const threshold = (_b = data === null || data === void 0 ? void 0 : data.videoStreaming) === null || _b === void 0 ? void 0 : _b.viewerCountDisplayMinimum;
5066
+ if (!isValidMode(mode) || !isValidThreshold(threshold)) {
5067
+ client.log('client/getLiveViewerCountConfig', 'malformed videoStreaming settings, falling back to default', { mode, threshold });
5068
+ return DEFAULT_CONFIG;
5069
+ }
5070
+ return { mode, threshold };
5071
+ };
5072
+ /* end_public_function */
5073
+
5024
5074
  /* begin_public_function
5025
5075
  id: client.getProductCatalogueSetting
5026
5076
  */
@@ -8470,6 +8520,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
8470
8520
  getCoreUserSettings,
8471
8521
  getSocialSettings,
8472
8522
  getChatSettings,
8523
+ getLiveViewerCountConfig,
8473
8524
  getVisitorDeviceId: getDeviceId,
8474
8525
  getMessagePreviewSetting: getMessagePreviewSetting$1,
8475
8526
  use: () => setActiveClient(client),
@@ -9561,6 +9612,7 @@ var index$s = /*#__PURE__*/Object.freeze({
9561
9612
  setCurrentUserType: setCurrentUserType,
9562
9613
  setAccessTokenHandler: setAccessTokenHandler,
9563
9614
  getChatSettings: getChatSettings,
9615
+ getLiveViewerCountConfig: getLiveViewerCountConfig,
9564
9616
  getCoreUserSettings: getCoreUserSettings,
9565
9617
  notifications: notifications,
9566
9618
  enableAutoSubscriptions: enableAutoSubscriptions,
@@ -12363,9 +12415,6 @@ function isAmityRoomPost(post) {
12363
12415
  'roomId' in post.data &&
12364
12416
  post.dataType === 'room');
12365
12417
  }
12366
- function isAmityEventPost(post) {
12367
- return post.dataType === 'event' || post.structureType === 'event';
12368
- }
12369
12418
 
12370
12419
  /**
12371
12420
  * ```js
@@ -12905,21 +12954,6 @@ const productTagLinkedObject = (productTag) => {
12905
12954
  return Object.assign(Object.assign({}, productTag), { product: internalProduct ? productLinkedObject(internalProduct) : undefined });
12906
12955
  };
12907
12956
 
12908
- const fileLinkedObject = (file) => {
12909
- var _a, _b, _c;
12910
- if (!file)
12911
- return file;
12912
- if (file.type === 'video') {
12913
- const video = (_b = (_a = file.attributes) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.video;
12914
- return Object.assign(Object.assign({}, file), { getWidth: () => { var _a; return (_a = video === null || video === void 0 ? void 0 : video.width) !== null && _a !== void 0 ? _a : 0; }, getHeight: () => { var _a; return (_a = video === null || video === void 0 ? void 0 : video.height) !== null && _a !== void 0 ? _a : 0; }, getRotation: () => { var _a; return (_a = video === null || video === void 0 ? void 0 : video.rotation) !== null && _a !== void 0 ? _a : 0; } });
12915
- }
12916
- if (file.type === 'image') {
12917
- const metadata = (_c = file.attributes) === null || _c === void 0 ? void 0 : _c.metadata;
12918
- return Object.assign(Object.assign({}, file), { getWidth: () => { var _a; return (_a = metadata === null || metadata === void 0 ? void 0 : metadata.width) !== null && _a !== void 0 ? _a : 0; }, getHeight: () => { var _a; return (_a = metadata === null || metadata === void 0 ? void 0 : metadata.height) !== null && _a !== void 0 ? _a : 0; } });
12919
- }
12920
- return file;
12921
- };
12922
-
12923
12957
  const postLinkedObject = (post) => {
12924
12958
  return shallowClone(post, {
12925
12959
  childrenPosts: post.children
@@ -12977,19 +13011,19 @@ const postLinkedObject = (post) => {
12977
13011
  getImageInfo() {
12978
13012
  var _a, _b;
12979
13013
  return isAmityImagePost(post)
12980
- ? fileLinkedObject((_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)
13014
+ ? (_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
12981
13015
  : undefined;
12982
13016
  },
12983
13017
  getVideoInfo() {
12984
13018
  var _a, _b, _c;
12985
13019
  return isAmityVideoPost(post)
12986
- ? fileLinkedObject((_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data)
13020
+ ? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
12987
13021
  : undefined;
12988
13022
  },
12989
13023
  getVideoThumbnailInfo() {
12990
13024
  var _a, _b;
12991
13025
  return isAmityVideoPost(post)
12992
- ? fileLinkedObject((_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data)
13026
+ ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
12993
13027
  : undefined;
12994
13028
  },
12995
13029
  getFileInfo() {
@@ -13039,57 +13073,6 @@ const postLinkedObject = (post) => {
13039
13073
  const room = (_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;
13040
13074
  return room ? roomLinkedObject(room) : undefined;
13041
13075
  },
13042
- getEventInfo() {
13043
- var _a, _b;
13044
- if (!isAmityEventPost(post))
13045
- return;
13046
- const readEventId = (data) => {
13047
- if (data && typeof data === 'object' && 'eventId' in data) {
13048
- const value = data.eventId;
13049
- return typeof value === 'string' ? value : undefined;
13050
- }
13051
- return undefined;
13052
- };
13053
- const parentEventId = readEventId(post.data);
13054
- const eventId = parentEventId !== null && parentEventId !== void 0 ? parentEventId : (_a = post.children) === null || _a === void 0 ? void 0 : _a.map(childId => { var _a; return (_a = pullFromCache(['post', 'get', childId])) === null || _a === void 0 ? void 0 : _a.data; }).map(child => readEventId(child === null || child === void 0 ? void 0 : child.data)).find(Boolean);
13055
- if (!eventId)
13056
- return;
13057
- const event = (_b = pullFromCache(['event', 'get', eventId])) === null || _b === void 0 ? void 0 : _b.data;
13058
- if (!event)
13059
- return;
13060
- // Inlined event linked-object construction. Calling eventLinkedObject()
13061
- // here would create a static import cycle (eventLinkObject already
13062
- // imports postLinkedObject for its `event.post` getter). Snapshot
13063
- // consumers get the raw event fields plus the getters they need for the
13064
- // in-post event card (creator, targetCommunity, coverImage, room). The
13065
- // full linked-object surface — including RSVP methods and `event.post` —
13066
- // is available via EventRepository.getEvent(eventId).
13067
- return Object.assign(Object.assign({}, event), { get creator() {
13068
- const cacheData = pullFromCache(['user', 'get', event.userId]);
13069
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13070
- return undefined;
13071
- return userLinkedObject(cacheData.data);
13072
- },
13073
- get targetCommunity() {
13074
- var _a;
13075
- if (!event.originId)
13076
- return undefined;
13077
- const cacheData = (_a = pullFromCache([
13078
- 'community',
13079
- 'get',
13080
- event.originId,
13081
- ])) === null || _a === void 0 ? void 0 : _a.data;
13082
- if (!cacheData)
13083
- return undefined;
13084
- return communityLinkedObject(cacheData);
13085
- },
13086
- get coverImage() {
13087
- var _a;
13088
- if (!event.coverImageFileId)
13089
- return undefined;
13090
- return (_a = pullFromCache(['file', 'get', event.coverImageFileId])) === null || _a === void 0 ? void 0 : _a.data;
13091
- } });
13092
- },
13093
13076
  });
13094
13077
  };
13095
13078
 
@@ -13980,7 +13963,6 @@ const eventLinkedObject = (event) => {
13980
13963
  };
13981
13964
 
13982
13965
  const LinkedObject = {
13983
- file: fileLinkedObject,
13984
13966
  ad: adLinkedObject,
13985
13967
  comment: commentLinkedObject,
13986
13968
  post: postLinkedObject,
@@ -15328,7 +15310,7 @@ const getFile = async (fileId) => {
15328
15310
  if (client.cache)
15329
15311
  ingestInCache({ files: [data] }, { cachedAt });
15330
15312
  return {
15331
- data: fileLinkedObject(data),
15313
+ data,
15332
15314
  cachedAt,
15333
15315
  };
15334
15316
  };
@@ -15355,7 +15337,7 @@ getFile.locally = (fileId) => {
15355
15337
  if (!cached)
15356
15338
  return;
15357
15339
  return {
15358
- data: fileLinkedObject(cached.data),
15340
+ data: cached.data,
15359
15341
  cachedAt: cached.cachedAt,
15360
15342
  };
15361
15343
  };
@@ -15492,7 +15474,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
15492
15474
  if (client.cache)
15493
15475
  ingestInCache({ files: data }, { cachedAt });
15494
15476
  return {
15495
- data: data.map(file => fileLinkedObject(file)),
15477
+ data,
15496
15478
  cachedAt,
15497
15479
  };
15498
15480
  };
@@ -15553,7 +15535,7 @@ const uploadImage = async (formData, onProgress, altText) => {
15553
15535
  if (client.cache)
15554
15536
  ingestInCache({ files: data }, { cachedAt });
15555
15537
  return {
15556
- data: data.map(file => fileLinkedObject(file)),
15538
+ data,
15557
15539
  cachedAt,
15558
15540
  };
15559
15541
  };
@@ -28403,51 +28385,6 @@ const createRoomPost = async (bundle) => {
28403
28385
  };
28404
28386
  /* end_public_function */
28405
28387
 
28406
- /* begin_public_function
28407
- id: post.create.event_post
28408
- */
28409
- /**
28410
- * ```js
28411
- * import { PostRepository } from '@amityco/ts-sdk'
28412
- * const created = await PostRepository.createEventPost({
28413
- * targetType: 'community',
28414
- * targetId: 'communityId',
28415
- * data: { eventId: 'eventId123', title: 'Summer Meetup', text: 'Come say hi' }
28416
- * })
28417
- * ```
28418
- *
28419
- * Creates an event {@link Amity.Post} — a post whose content is an event.
28420
- * The parent post carries the author's caption; the referenced event is
28421
- * resolved via `post.getEventInfo()`.
28422
- *
28423
- * `data.eventId` is REQUIRED; `title` and `text` are OPTIONAL — both blank is
28424
- * valid and yields a bare event card.
28425
- *
28426
- * Media attachments and product tags are rejected by the backend with 400.
28427
- *
28428
- * @param bundle The data necessary to create a new event {@link Amity.Post}
28429
- * @returns The newly created {@link Amity.Post}
28430
- *
28431
- * @category Post API
28432
- * @async
28433
- */
28434
- const createEventPost = async (bundle) => {
28435
- const client = getActiveClient();
28436
- client.log('post/createEventPost', bundle);
28437
- const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { dataType: 'event' }));
28438
- fireEvent('post.created', payload);
28439
- const data = preparePostPayload(payload);
28440
- const cachedAt = client.cache && Date.now();
28441
- if (client.cache)
28442
- ingestInCache(data, { cachedAt });
28443
- const { posts } = data;
28444
- return {
28445
- data: LinkedObject.post(posts[0]),
28446
- cachedAt,
28447
- };
28448
- };
28449
- /* end_public_function */
28450
-
28451
28388
  /* begin_public_function
28452
28389
  id: post.pin_product
28453
28390
  */
@@ -31179,7 +31116,6 @@ var index$b = /*#__PURE__*/Object.freeze({
31179
31116
  createAudioPost: createAudioPost,
31180
31117
  createMixedMediaPost: createMixedMediaPost,
31181
31118
  createRoomPost: createRoomPost,
31182
- createEventPost: createEventPost,
31183
31119
  pinProduct: pinProduct,
31184
31120
  unpinProduct: unpinProduct,
31185
31121
  updateProductTags: updateProductTags,
package/dist/index.esm.js CHANGED
@@ -146,7 +146,6 @@ const PostContentType = Object.freeze({
146
146
  CLIP: 'clip',
147
147
  AUDIO: 'audio',
148
148
  ROOM: 'room',
149
- EVENT: 'event',
150
149
  });
151
150
  const PostStructureType = Object.freeze({
152
151
  TEXT: 'text',
@@ -155,7 +154,6 @@ const PostStructureType = Object.freeze({
155
154
  FILE: 'file',
156
155
  AUDIO: 'audio',
157
156
  MIXED: 'mixed',
158
- EVENT: 'event',
159
157
  });
160
158
 
161
159
  var InvitationTypeEnum;
@@ -306,6 +304,13 @@ var NotificationRolesFilterTypeEnum;
306
304
  NotificationRolesFilterTypeEnum["ONLY"] = "only";
307
305
  })(NotificationRolesFilterTypeEnum || (NotificationRolesFilterTypeEnum = {}));
308
306
 
307
+ var AmityLiveViewerCountMode;
308
+ (function (AmityLiveViewerCountMode) {
309
+ AmityLiveViewerCountMode["ALWAYS_SHOW"] = "always";
310
+ AmityLiveViewerCountMode["HIDE_ENTIRELY"] = "hidden";
311
+ AmityLiveViewerCountMode["SHOW_ABOVE_MINIMUM"] = "above-minimum";
312
+ })(AmityLiveViewerCountMode || (AmityLiveViewerCountMode = {}));
313
+
309
314
  function getVersion() {
310
315
  try {
311
316
  // the string ''v7.25.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -5021,6 +5026,51 @@ const getCoreUserSettings = async () => {
5021
5026
  return data;
5022
5027
  };
5023
5028
 
5029
+ const DEFAULT_CONFIG = {
5030
+ mode: AmityLiveViewerCountMode.ALWAYS_SHOW,
5031
+ threshold: 50,
5032
+ };
5033
+ const isValidMode = (value) => value === AmityLiveViewerCountMode.ALWAYS_SHOW ||
5034
+ value === AmityLiveViewerCountMode.HIDE_ENTIRELY ||
5035
+ value === AmityLiveViewerCountMode.SHOW_ABOVE_MINIMUM;
5036
+ const isValidThreshold = (value) => typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 1000;
5037
+ /**
5038
+ * ```js
5039
+ * import { getLiveViewerCountConfig } from '@amityco/ts-sdk'
5040
+ * const config = await getLiveViewerCountConfig()
5041
+ * ```
5042
+ *
5043
+ * Fetches the network-level {@link Amity.LiveViewerCountConfig} governing
5044
+ * how the live viewer count is displayed to viewers on a livestream.
5045
+ *
5046
+ * Cold-read — no observable, no cache. Call once per livestream mount /
5047
+ * rejoin. Admin-driven config changes take effect on the next join, not
5048
+ * mid-stream.
5049
+ *
5050
+ * On a malformed payload (unknown mode, out-of-range or missing threshold)
5051
+ * the SDK falls open to `{ mode: ALWAYS_SHOW, threshold: 50 }` and logs a
5052
+ * warning. Network errors reject.
5053
+ *
5054
+ * @returns A Promise of {@link Amity.LiveViewerCountConfig}
5055
+ *
5056
+ * @category Client API
5057
+ * @async
5058
+ */
5059
+ /* begin_public_function id: client.getLiveViewerCountConfig */
5060
+ const getLiveViewerCountConfig = async () => {
5061
+ var _a, _b;
5062
+ const client = getActiveClient();
5063
+ const { data } = await client.http.get('/api/v3/network-settings/video-streaming');
5064
+ const mode = (_a = data === null || data === void 0 ? void 0 : data.videoStreaming) === null || _a === void 0 ? void 0 : _a.viewerCountDisplayMode;
5065
+ const threshold = (_b = data === null || data === void 0 ? void 0 : data.videoStreaming) === null || _b === void 0 ? void 0 : _b.viewerCountDisplayMinimum;
5066
+ if (!isValidMode(mode) || !isValidThreshold(threshold)) {
5067
+ client.log('client/getLiveViewerCountConfig', 'malformed videoStreaming settings, falling back to default', { mode, threshold });
5068
+ return DEFAULT_CONFIG;
5069
+ }
5070
+ return { mode, threshold };
5071
+ };
5072
+ /* end_public_function */
5073
+
5024
5074
  /* begin_public_function
5025
5075
  id: client.getProductCatalogueSetting
5026
5076
  */
@@ -8470,6 +8520,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
8470
8520
  getCoreUserSettings,
8471
8521
  getSocialSettings,
8472
8522
  getChatSettings,
8523
+ getLiveViewerCountConfig,
8473
8524
  getVisitorDeviceId: getDeviceId,
8474
8525
  getMessagePreviewSetting: getMessagePreviewSetting$1,
8475
8526
  use: () => setActiveClient(client),
@@ -9561,6 +9612,7 @@ var index$s = /*#__PURE__*/Object.freeze({
9561
9612
  setCurrentUserType: setCurrentUserType,
9562
9613
  setAccessTokenHandler: setAccessTokenHandler,
9563
9614
  getChatSettings: getChatSettings,
9615
+ getLiveViewerCountConfig: getLiveViewerCountConfig,
9564
9616
  getCoreUserSettings: getCoreUserSettings,
9565
9617
  notifications: notifications,
9566
9618
  enableAutoSubscriptions: enableAutoSubscriptions,
@@ -12363,9 +12415,6 @@ function isAmityRoomPost(post) {
12363
12415
  'roomId' in post.data &&
12364
12416
  post.dataType === 'room');
12365
12417
  }
12366
- function isAmityEventPost(post) {
12367
- return post.dataType === 'event' || post.structureType === 'event';
12368
- }
12369
12418
 
12370
12419
  /**
12371
12420
  * ```js
@@ -12905,21 +12954,6 @@ const productTagLinkedObject = (productTag) => {
12905
12954
  return Object.assign(Object.assign({}, productTag), { product: internalProduct ? productLinkedObject(internalProduct) : undefined });
12906
12955
  };
12907
12956
 
12908
- const fileLinkedObject = (file) => {
12909
- var _a, _b, _c;
12910
- if (!file)
12911
- return file;
12912
- if (file.type === 'video') {
12913
- const video = (_b = (_a = file.attributes) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.video;
12914
- return Object.assign(Object.assign({}, file), { getWidth: () => { var _a; return (_a = video === null || video === void 0 ? void 0 : video.width) !== null && _a !== void 0 ? _a : 0; }, getHeight: () => { var _a; return (_a = video === null || video === void 0 ? void 0 : video.height) !== null && _a !== void 0 ? _a : 0; }, getRotation: () => { var _a; return (_a = video === null || video === void 0 ? void 0 : video.rotation) !== null && _a !== void 0 ? _a : 0; } });
12915
- }
12916
- if (file.type === 'image') {
12917
- const metadata = (_c = file.attributes) === null || _c === void 0 ? void 0 : _c.metadata;
12918
- return Object.assign(Object.assign({}, file), { getWidth: () => { var _a; return (_a = metadata === null || metadata === void 0 ? void 0 : metadata.width) !== null && _a !== void 0 ? _a : 0; }, getHeight: () => { var _a; return (_a = metadata === null || metadata === void 0 ? void 0 : metadata.height) !== null && _a !== void 0 ? _a : 0; } });
12919
- }
12920
- return file;
12921
- };
12922
-
12923
12957
  const postLinkedObject = (post) => {
12924
12958
  return shallowClone(post, {
12925
12959
  childrenPosts: post.children
@@ -12977,19 +13011,19 @@ const postLinkedObject = (post) => {
12977
13011
  getImageInfo() {
12978
13012
  var _a, _b;
12979
13013
  return isAmityImagePost(post)
12980
- ? fileLinkedObject((_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)
13014
+ ? (_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
12981
13015
  : undefined;
12982
13016
  },
12983
13017
  getVideoInfo() {
12984
13018
  var _a, _b, _c;
12985
13019
  return isAmityVideoPost(post)
12986
- ? fileLinkedObject((_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data)
13020
+ ? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
12987
13021
  : undefined;
12988
13022
  },
12989
13023
  getVideoThumbnailInfo() {
12990
13024
  var _a, _b;
12991
13025
  return isAmityVideoPost(post)
12992
- ? fileLinkedObject((_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data)
13026
+ ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
12993
13027
  : undefined;
12994
13028
  },
12995
13029
  getFileInfo() {
@@ -13039,57 +13073,6 @@ const postLinkedObject = (post) => {
13039
13073
  const room = (_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;
13040
13074
  return room ? roomLinkedObject(room) : undefined;
13041
13075
  },
13042
- getEventInfo() {
13043
- var _a, _b;
13044
- if (!isAmityEventPost(post))
13045
- return;
13046
- const readEventId = (data) => {
13047
- if (data && typeof data === 'object' && 'eventId' in data) {
13048
- const value = data.eventId;
13049
- return typeof value === 'string' ? value : undefined;
13050
- }
13051
- return undefined;
13052
- };
13053
- const parentEventId = readEventId(post.data);
13054
- const eventId = parentEventId !== null && parentEventId !== void 0 ? parentEventId : (_a = post.children) === null || _a === void 0 ? void 0 : _a.map(childId => { var _a; return (_a = pullFromCache(['post', 'get', childId])) === null || _a === void 0 ? void 0 : _a.data; }).map(child => readEventId(child === null || child === void 0 ? void 0 : child.data)).find(Boolean);
13055
- if (!eventId)
13056
- return;
13057
- const event = (_b = pullFromCache(['event', 'get', eventId])) === null || _b === void 0 ? void 0 : _b.data;
13058
- if (!event)
13059
- return;
13060
- // Inlined event linked-object construction. Calling eventLinkedObject()
13061
- // here would create a static import cycle (eventLinkObject already
13062
- // imports postLinkedObject for its `event.post` getter). Snapshot
13063
- // consumers get the raw event fields plus the getters they need for the
13064
- // in-post event card (creator, targetCommunity, coverImage, room). The
13065
- // full linked-object surface — including RSVP methods and `event.post` —
13066
- // is available via EventRepository.getEvent(eventId).
13067
- return Object.assign(Object.assign({}, event), { get creator() {
13068
- const cacheData = pullFromCache(['user', 'get', event.userId]);
13069
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13070
- return undefined;
13071
- return userLinkedObject(cacheData.data);
13072
- },
13073
- get targetCommunity() {
13074
- var _a;
13075
- if (!event.originId)
13076
- return undefined;
13077
- const cacheData = (_a = pullFromCache([
13078
- 'community',
13079
- 'get',
13080
- event.originId,
13081
- ])) === null || _a === void 0 ? void 0 : _a.data;
13082
- if (!cacheData)
13083
- return undefined;
13084
- return communityLinkedObject(cacheData);
13085
- },
13086
- get coverImage() {
13087
- var _a;
13088
- if (!event.coverImageFileId)
13089
- return undefined;
13090
- return (_a = pullFromCache(['file', 'get', event.coverImageFileId])) === null || _a === void 0 ? void 0 : _a.data;
13091
- } });
13092
- },
13093
13076
  });
13094
13077
  };
13095
13078
 
@@ -13980,7 +13963,6 @@ const eventLinkedObject = (event) => {
13980
13963
  };
13981
13964
 
13982
13965
  const LinkedObject = {
13983
- file: fileLinkedObject,
13984
13966
  ad: adLinkedObject,
13985
13967
  comment: commentLinkedObject,
13986
13968
  post: postLinkedObject,
@@ -15328,7 +15310,7 @@ const getFile = async (fileId) => {
15328
15310
  if (client.cache)
15329
15311
  ingestInCache({ files: [data] }, { cachedAt });
15330
15312
  return {
15331
- data: fileLinkedObject(data),
15313
+ data,
15332
15314
  cachedAt,
15333
15315
  };
15334
15316
  };
@@ -15355,7 +15337,7 @@ getFile.locally = (fileId) => {
15355
15337
  if (!cached)
15356
15338
  return;
15357
15339
  return {
15358
- data: fileLinkedObject(cached.data),
15340
+ data: cached.data,
15359
15341
  cachedAt: cached.cachedAt,
15360
15342
  };
15361
15343
  };
@@ -15492,7 +15474,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
15492
15474
  if (client.cache)
15493
15475
  ingestInCache({ files: data }, { cachedAt });
15494
15476
  return {
15495
- data: data.map(file => fileLinkedObject(file)),
15477
+ data,
15496
15478
  cachedAt,
15497
15479
  };
15498
15480
  };
@@ -15553,7 +15535,7 @@ const uploadImage = async (formData, onProgress, altText) => {
15553
15535
  if (client.cache)
15554
15536
  ingestInCache({ files: data }, { cachedAt });
15555
15537
  return {
15556
- data: data.map(file => fileLinkedObject(file)),
15538
+ data,
15557
15539
  cachedAt,
15558
15540
  };
15559
15541
  };
@@ -28403,51 +28385,6 @@ const createRoomPost = async (bundle) => {
28403
28385
  };
28404
28386
  /* end_public_function */
28405
28387
 
28406
- /* begin_public_function
28407
- id: post.create.event_post
28408
- */
28409
- /**
28410
- * ```js
28411
- * import { PostRepository } from '@amityco/ts-sdk'
28412
- * const created = await PostRepository.createEventPost({
28413
- * targetType: 'community',
28414
- * targetId: 'communityId',
28415
- * data: { eventId: 'eventId123', title: 'Summer Meetup', text: 'Come say hi' }
28416
- * })
28417
- * ```
28418
- *
28419
- * Creates an event {@link Amity.Post} — a post whose content is an event.
28420
- * The parent post carries the author's caption; the referenced event is
28421
- * resolved via `post.getEventInfo()`.
28422
- *
28423
- * `data.eventId` is REQUIRED; `title` and `text` are OPTIONAL — both blank is
28424
- * valid and yields a bare event card.
28425
- *
28426
- * Media attachments and product tags are rejected by the backend with 400.
28427
- *
28428
- * @param bundle The data necessary to create a new event {@link Amity.Post}
28429
- * @returns The newly created {@link Amity.Post}
28430
- *
28431
- * @category Post API
28432
- * @async
28433
- */
28434
- const createEventPost = async (bundle) => {
28435
- const client = getActiveClient();
28436
- client.log('post/createEventPost', bundle);
28437
- const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { dataType: 'event' }));
28438
- fireEvent('post.created', payload);
28439
- const data = preparePostPayload(payload);
28440
- const cachedAt = client.cache && Date.now();
28441
- if (client.cache)
28442
- ingestInCache(data, { cachedAt });
28443
- const { posts } = data;
28444
- return {
28445
- data: LinkedObject.post(posts[0]),
28446
- cachedAt,
28447
- };
28448
- };
28449
- /* end_public_function */
28450
-
28451
28388
  /* begin_public_function
28452
28389
  id: post.pin_product
28453
28390
  */
@@ -31179,7 +31116,6 @@ var index$b = /*#__PURE__*/Object.freeze({
31179
31116
  createAudioPost: createAudioPost,
31180
31117
  createMixedMediaPost: createMixedMediaPost,
31181
31118
  createRoomPost: createRoomPost,
31182
- createEventPost: createEventPost,
31183
31119
  pinProduct: pinProduct,
31184
31120
  unpinProduct: unpinProduct,
31185
31121
  updateProductTags: updateProductTags,
@@ -35510,4 +35446,4 @@ class AmityAttachmentProductTags {
35510
35446
  }
35511
35447
  }
35512
35448
 
35513
- export { API_REGIONS, index$5 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmitySharableContentType, AnalyticsSourceTypeEnum, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, 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, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, 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, SearchUsersByEnum, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserReportTypeEnum, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, 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, validateUntilAt, wipeCache };
35449
+ export { API_REGIONS, index$5 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmitySharableContentType, AnalyticsSourceTypeEnum, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, 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, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, 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, SearchUsersByEnum, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserReportTypeEnum, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, 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, validateUntilAt, wipeCache };