@amityco/ts-sdk 7.26.1-ecb8825d.0 → 7.27.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 (68) hide show
  1. package/dist/@types/core/events.d.ts +0 -4
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/payload.d.ts +0 -21
  4. package/dist/@types/core/payload.d.ts.map +1 -1
  5. package/dist/@types/core/permissions.d.ts +3 -8
  6. package/dist/@types/core/permissions.d.ts.map +1 -1
  7. package/dist/@types/domains/channel.d.ts +0 -5
  8. package/dist/@types/domains/channel.d.ts.map +1 -1
  9. package/dist/@types/domains/content.d.ts +6 -1
  10. package/dist/@types/domains/content.d.ts.map +1 -1
  11. package/dist/@types/index.d.ts +0 -1
  12. package/dist/@types/index.d.ts.map +1 -1
  13. package/dist/cache/utils/index.d.ts.map +1 -1
  14. package/dist/channelRepository/events/index.d.ts +0 -2
  15. package/dist/channelRepository/events/index.d.ts.map +1 -1
  16. package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts +0 -22
  17. package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts.map +1 -1
  18. package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts +0 -22
  19. package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts.map +1 -1
  20. package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
  21. package/dist/channelRepository/observers/getMyMembership.d.ts.map +1 -1
  22. package/dist/channelRepository/utils/index.d.ts +0 -2
  23. package/dist/channelRepository/utils/index.d.ts.map +1 -1
  24. package/dist/core/events.d.ts +3 -3
  25. package/dist/core/events.d.ts.map +1 -1
  26. package/dist/index.cjs.js +170 -564
  27. package/dist/index.esm.js +170 -564
  28. package/dist/index.umd.js +2 -2
  29. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +0 -1
  30. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
  31. package/dist/messageRepository/api/index.d.ts +0 -2
  32. package/dist/messageRepository/api/index.d.ts.map +1 -1
  33. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  34. package/dist/utils/tests/dummy/index.d.ts +0 -1
  35. package/dist/utils/tests/dummy/index.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/dist/@types/domains/pinnedMessage.d.ts +0 -43
  38. package/dist/@types/domains/pinnedMessage.d.ts.map +0 -1
  39. package/dist/channelRepository/events/onChannelMessagePinned.d.ts +0 -24
  40. package/dist/channelRepository/events/onChannelMessagePinned.d.ts.map +0 -1
  41. package/dist/channelRepository/events/onChannelMessageUnpinned.d.ts +0 -21
  42. package/dist/channelRepository/events/onChannelMessageUnpinned.d.ts.map +0 -1
  43. package/dist/channelRepository/events/onChannelPinnedMessageDeleted.d.ts +0 -12
  44. package/dist/channelRepository/events/onChannelPinnedMessageDeleted.d.ts.map +0 -1
  45. package/dist/channelRepository/events/tests/onChannelMemberRoleAdded.test.d.ts +0 -2
  46. package/dist/channelRepository/events/tests/onChannelMemberRoleAdded.test.d.ts.map +0 -1
  47. package/dist/channelRepository/events/tests/onChannelMemberRoleRemoved.test.d.ts +0 -2
  48. package/dist/channelRepository/events/tests/onChannelMemberRoleRemoved.test.d.ts.map +0 -1
  49. package/dist/channelRepository/events/tests/onChannelMessagePinned.test.d.ts +0 -2
  50. package/dist/channelRepository/events/tests/onChannelMessagePinned.test.d.ts.map +0 -1
  51. package/dist/channelRepository/utils/applyChannelRolePayload.d.ts +0 -21
  52. package/dist/channelRepository/utils/applyChannelRolePayload.d.ts.map +0 -1
  53. package/dist/channelRepository/utils/tests/pinnedMessage.test.d.ts +0 -2
  54. package/dist/channelRepository/utils/tests/pinnedMessage.test.d.ts.map +0 -1
  55. package/dist/channelRepository/utils/updatePinnedMessageCache.d.ts +0 -24
  56. package/dist/channelRepository/utils/updatePinnedMessageCache.d.ts.map +0 -1
  57. package/dist/messageRepository/api/pinMessage.d.ts +0 -29
  58. package/dist/messageRepository/api/pinMessage.d.ts.map +0 -1
  59. package/dist/messageRepository/api/tests/pinMessage.test.d.ts +0 -2
  60. package/dist/messageRepository/api/tests/pinMessage.test.d.ts.map +0 -1
  61. package/dist/messageRepository/api/tests/unpinMessage.test.d.ts +0 -2
  62. package/dist/messageRepository/api/tests/unpinMessage.test.d.ts.map +0 -1
  63. package/dist/messageRepository/api/unpinMessage.d.ts +0 -28
  64. package/dist/messageRepository/api/unpinMessage.d.ts.map +0 -1
  65. package/dist/messageRepository/utils/refreshChannelPermissionsForMessage.d.ts +0 -13
  66. package/dist/messageRepository/utils/refreshChannelPermissionsForMessage.d.ts.map +0 -1
  67. package/dist/utils/tests/dummy/pinnedMessage.d.ts +0 -2
  68. package/dist/utils/tests/dummy/pinnedMessage.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -331,8 +331,8 @@ exports.AmityLiveViewerCountMode = void 0;
331
331
 
332
332
  function getVersion() {
333
333
  try {
334
- // the string ''v7.26.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
335
- return 'v7.26.0-cjs';
334
+ // the string ''v7.27.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
335
+ return 'v7.27.0-cjs';
336
336
  }
337
337
  catch (error) {
338
338
  return '__dev__';
@@ -385,7 +385,13 @@ const normalize = (source) => Object.keys(source)
385
385
  * @category Cache
386
386
  * @hidden
387
387
  */
388
- const encodeKey = (key) => JSON.stringify(key, (_, val) => (typeof val === 'object' ? normalize(val) : val));
388
+ const encodeKey = (key) => JSON.stringify(key, (_, val) =>
389
+ // `typeof null` is `'object'`, so a nullish segment would reach normalize()
390
+ // and throw on Object.keys(null) — taking down whichever cache read built
391
+ // the key. Amity.Serializable does not admit null in the first place, so a
392
+ // null here is a payload that broke its own contract: encode it as null and
393
+ // let the miss be a miss.
394
+ val !== null && typeof val === 'object' ? normalize(val) : val);
389
395
  /**
390
396
  * Decodes a string back into a {@link Amity.CacheKey}
391
397
 
@@ -3842,95 +3848,6 @@ const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpd
3842
3848
  channelUsers });
3843
3849
  };
3844
3850
 
3845
- const channelCacheKey = (channel) => [
3846
- 'channel',
3847
- 'get',
3848
- getResolver('channel')(channel),
3849
- ];
3850
- /**
3851
- * Find a cached channel by any of its ids (internal, public, or `channelId`).
3852
- *
3853
- * The channel cache is keyed by the channel internal id (see `idResolvers.channel`), but
3854
- * realtime payloads reference channels by different ids: pin events carry the **public**
3855
- * id, messages carry `channelId`. Try the cheap direct lookup first, then scan.
3856
- */
3857
- const findCachedChannelByAnyId = (id) => {
3858
- var _a, _b, _c;
3859
- if (!id)
3860
- return undefined;
3861
- const direct = (_a = pullFromCache(['channel', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
3862
- if (direct)
3863
- return direct;
3864
- return (_c = (_b = queryCache(['channel', 'get'])) === null || _b === void 0 ? void 0 : _b.find(({ data }) => data.channelInternalId === id || data.channelPublicId === id || data.channelId === id)) === null || _c === void 0 ? void 0 : _c.data;
3865
- };
3866
- /**
3867
- * Resolve the cached channel a `channel.messagePinned` / `channel.messageUnpinned` event
3868
- * refers to. `data.channelId` is the channel public id; a pinned message body (present on
3869
- * `messagePinned` only) also carries the internal id, which is the direct cache key.
3870
- */
3871
- const findCachedChannelForPin = (payload) => {
3872
- var _a, _b;
3873
- return (_b = findCachedChannelByAnyId((_a = payload.pinnedMessage) === null || _a === void 0 ? void 0 : _a.channelId)) !== null && _b !== void 0 ? _b : findCachedChannelByAnyId(payload.channelId);
3874
- };
3875
- /**
3876
- * Write a new pin snapshot (or `null` to clear) on a cached channel and ingest any
3877
- * users delivered with it (the pin author and the message author), so the banner can
3878
- * render a byline without a second fetch.
3879
- *
3880
- * Every `messagePinned` payload is a full snapshot — "this is the pin now" — so the last
3881
- * one received always wins; there is no merging with the previous pin.
3882
- */
3883
- const updatePinnedMessageCache = (channel, pinnedMessage, users) => {
3884
- if (users && users.length > 0) {
3885
- ingestInCache({ users: users.map(convertRawUserToInternalUser) });
3886
- }
3887
- const updated = Object.assign(Object.assign({}, channel), { pinnedMessage });
3888
- pushToCache(channelCacheKey(channel), updated);
3889
- return updated;
3890
- };
3891
-
3892
- /**
3893
- * Applies a `channel.roleAdded` / `channel.roleRemoved` realtime payload to the cache.
3894
- *
3895
- * The event names every member the role request affected together with the
3896
- * roles and channel-scoped permissions each of them is left holding. That is a
3897
- * full state, not a delta, so it is written straight over the cached membership.
3898
- *
3899
- * Members the SDK has not fetched yet are skipped: the payload does not carry
3900
- * enough to build a full {@link Amity.Membership} and the live collections only
3901
- * emit rows that already exist in cache.
3902
- *
3903
- * @param payload the `data` of the realtime event
3904
- * @returns the refreshed channel (when resolvable) and the updated cached memberships
3905
- *
3906
- * @hidden
3907
- */
3908
- const applyChannelRolePayload = (payload) => {
3909
- var _a, _b, _c;
3910
- const { channelId, users = [], channels = [] } = payload;
3911
- const rawChannel = (_a = channels.find(channel => channel.channelId === channelId)) !== null && _a !== void 0 ? _a : channels[0];
3912
- let channel;
3913
- if (rawChannel) {
3914
- const channelKey = ['channel', 'get', getResolver('channel')(rawChannel)];
3915
- // the role event does not touch message previews, keep whatever preview is cached
3916
- const converted = convertFromRaw(rawChannel, { isMessagePreviewUpdated: false });
3917
- upsertInCache(channelKey, converted);
3918
- channel = (_c = (_b = pullFromCache(channelKey)) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : converted;
3919
- }
3920
- const members = [];
3921
- users.forEach(({ userId, roles, permissions }) => {
3922
- var _a, _b, _c;
3923
- const memberKey = ['channelUsers', 'get', getResolver('channelUsers')({ channelId, userId })];
3924
- const cached = (_a = pullFromCache(memberKey)) === null || _a === void 0 ? void 0 : _a.data;
3925
- if (!cached)
3926
- return;
3927
- const updated = Object.assign(Object.assign({}, cached), { roles, permissions });
3928
- pushToCache(memberKey, updated);
3929
- members.push((_c = (_b = pullFromCache(memberKey)) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : updated);
3930
- });
3931
- return { channel, members };
3932
- };
3933
-
3934
3851
  /**
3935
3852
  * ```js
3936
3853
  * import { getSubChannelMarkers } from '@amityco/ts-sdk'
@@ -4116,6 +4033,32 @@ const channelMemberLinkedObject = (channelMember) => {
4116
4033
  } });
4117
4034
  };
4118
4035
 
4036
+ /**
4037
+ *
4038
+ * get current user's membership data
4039
+ *
4040
+ * @returns the {@link Amity.Membership<'channel'>} objects
4041
+ *
4042
+ * @category Channel API
4043
+ * @async
4044
+ */
4045
+ const getMyMembership$1 = (channelId) => {
4046
+ const client = getActiveClient();
4047
+ client.log('channel/getMyMembership.locally');
4048
+ const cacheChannelUser = pullFromCache([
4049
+ 'channelUsers',
4050
+ 'get',
4051
+ `${channelId}#${client.userId}`,
4052
+ ]);
4053
+ if (!cacheChannelUser) {
4054
+ throw new ASCApiError('Item not found!', 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
4055
+ }
4056
+ return {
4057
+ data: cacheChannelUser.data,
4058
+ cachedAt: cacheChannelUser.cachedAt,
4059
+ };
4060
+ };
4061
+
4119
4062
  /**
4120
4063
  * ```js
4121
4064
  * import { isEqual } from '~/utils/isEqual'
@@ -4186,81 +4129,55 @@ function isEqual(x, y) {
4186
4129
  }));
4187
4130
  }
4188
4131
 
4189
- /**
4190
- *
4191
- * get current user's membership data
4192
- *
4193
- * @returns the {@link Amity.Membership<'channel'>} objects
4194
- *
4195
- * @category Channel API
4196
- * @async
4197
- */
4198
- const getMyMembership$1 = (channelId) => {
4199
- const client = getActiveClient();
4200
- client.log('channel/getMyMembership.locally');
4201
- const cacheChannelUser = pullFromCache([
4202
- 'channelUsers',
4203
- 'get',
4204
- `${channelId}#${client.userId}`,
4205
- ]);
4206
- if (!cacheChannelUser) {
4207
- throw new ASCApiError('Item not found!', 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
4208
- }
4209
- return {
4210
- data: cacheChannelUser.data,
4211
- cachedAt: cacheChannelUser.cachedAt,
4212
- };
4213
- };
4214
-
4215
- const callbacks$e = [];
4132
+ const callbacks$c = [];
4216
4133
  let mainDisposer$b = null;
4217
- const dispose$e = (cb) => {
4218
- const index = callbacks$e.indexOf(cb);
4134
+ const dispose$c = (cb) => {
4135
+ const index = callbacks$c.indexOf(cb);
4219
4136
  if (index > -1) {
4220
- callbacks$e.splice(index, 1);
4137
+ callbacks$c.splice(index, 1);
4221
4138
  }
4222
- if (callbacks$e.length === 0) {
4139
+ if (callbacks$c.length === 0) {
4223
4140
  mainDisposer$b === null || mainDisposer$b === void 0 ? void 0 : mainDisposer$b();
4224
4141
  }
4225
4142
  };
4226
4143
  const onChannelCreated = (callback) => {
4227
- if (callbacks$e.length === 0) {
4144
+ if (callbacks$c.length === 0) {
4228
4145
  const client = getActiveClient();
4229
4146
  const filter = async (payload) => {
4230
4147
  const data = await prepareChannelPayload(payload);
4231
4148
  ingestInCache(data);
4232
- callbacks$e.forEach(cb => cb(data.channels[0]));
4149
+ callbacks$c.forEach(cb => cb(data.channels[0]));
4233
4150
  };
4234
4151
  mainDisposer$b = createEventSubscriber(client, 'onChannelCreated', 'channel.created', filter);
4235
4152
  }
4236
- callbacks$e.push(callback);
4237
- return () => dispose$e(callback);
4153
+ callbacks$c.push(callback);
4154
+ return () => dispose$c(callback);
4238
4155
  };
4239
4156
 
4240
- const callbacks$d = [];
4241
- const mainDisposers$2 = [];
4242
- const dispose$d = (cb) => {
4243
- const index = callbacks$d.indexOf(cb);
4157
+ const callbacks$b = [];
4158
+ const mainDisposers = [];
4159
+ const dispose$b = (cb) => {
4160
+ const index = callbacks$b.indexOf(cb);
4244
4161
  if (index > -1) {
4245
- callbacks$d.splice(index, 1);
4162
+ callbacks$b.splice(index, 1);
4246
4163
  }
4247
- if (callbacks$d.length === 0) {
4248
- mainDisposers$2.forEach(fn => fn());
4164
+ if (callbacks$b.length === 0) {
4165
+ mainDisposers.forEach(fn => fn());
4249
4166
  }
4250
4167
  };
4251
4168
  const onChannelUpdated = (callback) => {
4252
4169
  const client = getActiveClient();
4253
- if (callbacks$d.length === 0) {
4170
+ if (callbacks$b.length === 0) {
4254
4171
  const filter = async (payload) => {
4255
4172
  const data = await prepareChannelPayload(payload);
4256
4173
  ingestInCache(data);
4257
- callbacks$d.forEach(cb => cb(data.channels[0]));
4174
+ callbacks$b.forEach(cb => cb(data.channels[0]));
4258
4175
  };
4259
- mainDisposers$2.push(createEventSubscriber(client, 'onChannelUpdated', 'channel.updated', filter));
4260
- mainDisposers$2.push(createEventSubscriber(client, 'onChannelUpdated', 'local.channel.updated', payload => callbacks$d.forEach(cb => cb(payload.channels[0]))));
4176
+ mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'channel.updated', filter));
4177
+ mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'local.channel.updated', payload => callbacks$b.forEach(cb => cb(payload.channels[0]))));
4261
4178
  }
4262
- callbacks$d.push(callback);
4263
- return () => dispose$d(callback);
4179
+ callbacks$b.push(callback);
4180
+ return () => dispose$b(callback);
4264
4181
  };
4265
4182
 
4266
4183
  const addFlagIsDeletedSubChannelUnreadByChannelId = (channelId) => {
@@ -4283,19 +4200,19 @@ const deleteChannelUnreadByChannelId = (channelId) => {
4283
4200
  }
4284
4201
  };
4285
4202
 
4286
- const callbacks$c = [];
4203
+ const callbacks$a = [];
4287
4204
  let mainDisposer$a = null;
4288
- const dispose$c = (cb) => {
4289
- const index = callbacks$c.indexOf(cb);
4205
+ const dispose$a = (cb) => {
4206
+ const index = callbacks$a.indexOf(cb);
4290
4207
  if (index > -1) {
4291
- callbacks$c.splice(index, 1);
4208
+ callbacks$a.splice(index, 1);
4292
4209
  }
4293
- if (callbacks$c.length === 0) {
4210
+ if (callbacks$a.length === 0) {
4294
4211
  mainDisposer$a === null || mainDisposer$a === void 0 ? void 0 : mainDisposer$a();
4295
4212
  }
4296
4213
  };
4297
4214
  const onChannelDeleted = (callback) => {
4298
- if (callbacks$c.length === 0) {
4215
+ if (callbacks$a.length === 0) {
4299
4216
  const client = getActiveClient();
4300
4217
  const filter = async (payload) => {
4301
4218
  const data = await prepareChannelPayload(payload);
@@ -4315,53 +4232,53 @@ const onChannelDeleted = (callback) => {
4315
4232
  }
4316
4233
  });
4317
4234
  ingestInCache(data);
4318
- callbacks$c.forEach(cb => cb(data.channels[0]));
4235
+ callbacks$a.forEach(cb => cb(data.channels[0]));
4319
4236
  };
4320
4237
  mainDisposer$a = createEventSubscriber(client, 'onChannelDeleted', 'channel.deleted', filter);
4321
4238
  }
4322
- callbacks$c.push(callback);
4323
- return () => dispose$c(callback);
4239
+ callbacks$a.push(callback);
4240
+ return () => dispose$a(callback);
4324
4241
  };
4325
4242
 
4326
- const callbacks$b = [];
4243
+ const callbacks$9 = [];
4327
4244
  let mainDisposer$9 = null;
4328
- const dispose$b = (cb) => {
4329
- const index = callbacks$b.indexOf(cb);
4245
+ const dispose$9 = (cb) => {
4246
+ const index = callbacks$9.indexOf(cb);
4330
4247
  if (index > -1) {
4331
- callbacks$b.splice(index, 1);
4248
+ callbacks$9.splice(index, 1);
4332
4249
  }
4333
- if (callbacks$b.length === 0) {
4250
+ if (callbacks$9.length === 0) {
4334
4251
  mainDisposer$9 === null || mainDisposer$9 === void 0 ? void 0 : mainDisposer$9();
4335
4252
  }
4336
4253
  };
4337
4254
  const onChannelJoined = (callback) => {
4338
- if (callbacks$b.length === 0) {
4255
+ if (callbacks$9.length === 0) {
4339
4256
  const client = getActiveClient();
4340
4257
  const filter = async (payload) => {
4341
4258
  const preparedPayload = await prepareChannelPayload(payload);
4342
4259
  const { channels, channelUsers } = preparedPayload;
4343
4260
  ingestInCache(preparedPayload);
4344
- callbacks$b.forEach(cb => cb(channels[0], channelUsers[0]));
4261
+ callbacks$9.forEach(cb => cb(channels[0], channelUsers[0]));
4345
4262
  };
4346
4263
  mainDisposer$9 = createEventSubscriber(client, 'onChannelJoined', 'channel.joined', filter);
4347
4264
  }
4348
- callbacks$b.push(callback);
4349
- return () => dispose$b(callback);
4265
+ callbacks$9.push(callback);
4266
+ return () => dispose$9(callback);
4350
4267
  };
4351
4268
 
4352
- const callbacks$a = [];
4269
+ const callbacks$8 = [];
4353
4270
  let mainDisposer$8 = null;
4354
- const dispose$a = (cb) => {
4355
- const index = callbacks$a.indexOf(cb);
4271
+ const dispose$8 = (cb) => {
4272
+ const index = callbacks$8.indexOf(cb);
4356
4273
  if (index > -1) {
4357
- callbacks$a.splice(index, 1);
4274
+ callbacks$8.splice(index, 1);
4358
4275
  }
4359
- if (callbacks$a.length === 0) {
4276
+ if (callbacks$8.length === 0) {
4360
4277
  mainDisposer$8 === null || mainDisposer$8 === void 0 ? void 0 : mainDisposer$8();
4361
4278
  }
4362
4279
  };
4363
4280
  const onChannelLeft = (callback) => {
4364
- if (callbacks$a.length === 0) {
4281
+ if (callbacks$8.length === 0) {
4365
4282
  const client = getActiveClient();
4366
4283
  const filter = async (payload) => {
4367
4284
  const { userId } = getActiveClient();
@@ -4385,27 +4302,27 @@ const onChannelLeft = (callback) => {
4385
4302
  }
4386
4303
  const { channels, channelUsers } = preparedPayload;
4387
4304
  ingestInCache(preparedPayload);
4388
- callbacks$a.forEach(cb => cb(channels[0], channelUsers[0]));
4305
+ callbacks$8.forEach(cb => cb(channels[0], channelUsers[0]));
4389
4306
  };
4390
4307
  mainDisposer$8 = createEventSubscriber(client, 'onChannelLeft', 'channel.left', filter);
4391
4308
  }
4392
- callbacks$a.push(callback);
4393
- return () => dispose$a(callback);
4309
+ callbacks$8.push(callback);
4310
+ return () => dispose$8(callback);
4394
4311
  };
4395
4312
 
4396
- const callbacks$9 = [];
4313
+ const callbacks$7 = [];
4397
4314
  let mainDisposer$7 = null;
4398
- const dispose$9 = (cb) => {
4399
- const index = callbacks$9.indexOf(cb);
4315
+ const dispose$7 = (cb) => {
4316
+ const index = callbacks$7.indexOf(cb);
4400
4317
  if (index > -1) {
4401
- callbacks$9.splice(index, 1);
4318
+ callbacks$7.splice(index, 1);
4402
4319
  }
4403
- if (callbacks$9.length === 0) {
4320
+ if (callbacks$7.length === 0) {
4404
4321
  mainDisposer$7 === null || mainDisposer$7 === void 0 ? void 0 : mainDisposer$7();
4405
4322
  }
4406
4323
  };
4407
4324
  const onChannelSetMuted = (callback) => {
4408
- if (callbacks$9.length === 0) {
4325
+ if (callbacks$7.length === 0) {
4409
4326
  const client = getActiveClient();
4410
4327
  const filter = async (payload) => {
4411
4328
  var _a;
@@ -4420,124 +4337,24 @@ const onChannelSetMuted = (callback) => {
4420
4337
  payload.channelId,
4421
4338
  ])) === null || _a === void 0 ? void 0 : _a.data;
4422
4339
  if (channel) {
4423
- callbacks$9.forEach(cb => cb(channel));
4340
+ callbacks$7.forEach(cb => cb(channel));
4424
4341
  }
4425
4342
  };
4426
4343
  mainDisposer$7 = createEventSubscriber(client, 'onChannelMute', 'channel.setMuted', filter);
4427
4344
  }
4428
- callbacks$9.push(callback);
4429
- return () => dispose$9(callback);
4430
- };
4431
-
4432
- const callbacks$8 = [];
4433
- let mainDisposer$6 = null;
4434
- const dispose$8 = (cb) => {
4435
- const index = callbacks$8.indexOf(cb);
4436
- if (index > -1) {
4437
- callbacks$8.splice(index, 1);
4438
- }
4439
- if (callbacks$8.length === 0) {
4440
- mainDisposer$6 === null || mainDisposer$6 === void 0 ? void 0 : mainDisposer$6();
4441
- }
4442
- };
4443
- /* begin_public_function
4444
- id: channel.event.message_pinned
4445
- */
4446
- /**
4447
- * ```js
4448
- * import { onChannelMessagePinned } from '@amityco/ts-sdk'
4449
- * const dispose = onChannelMessagePinned(channel => {
4450
- * // channel.pinnedMessage is the new pin
4451
- * })
4452
- * ```
4453
- *
4454
- * Fired when a message is pinned in a channel (the `channel.messagePinned` realtime
4455
- * event). Pinning a different message while one is already pinned emits a single
4456
- * `messagePinned` carrying the replacement — treat every payload as a full snapshot.
4457
- *
4458
- * The updated channel is written to cache before the callback runs, so
4459
- * `ChannelRepository.getChannel` observers see `channel.pinnedMessage` change.
4460
- *
4461
- * @param callback The function to call when the event was fired
4462
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4463
- *
4464
- * @category Channel Events
4465
- */
4466
- const onChannelMessagePinned = (callback) => {
4467
- if (callbacks$8.length === 0) {
4468
- const client = getActiveClient();
4469
- const filter = (payload) => {
4470
- var _a;
4471
- const channel = findCachedChannelForPin(payload);
4472
- if (!channel)
4473
- return;
4474
- const updated = updatePinnedMessageCache(channel, (_a = payload.pinnedMessage) !== null && _a !== void 0 ? _a : null, payload.users);
4475
- callbacks$8.forEach(cb => cb(updated));
4476
- };
4477
- mainDisposer$6 = createEventSubscriber(client, 'onChannelMessagePinned', 'channel.messagePinned', filter);
4478
- }
4479
- callbacks$8.push(callback);
4480
- return () => dispose$8(callback);
4481
- };
4482
- /* end_public_function */
4483
-
4484
- const callbacks$7 = [];
4485
- let mainDisposer$5 = null;
4486
- const dispose$7 = (cb) => {
4487
- const index = callbacks$7.indexOf(cb);
4488
- if (index > -1) {
4489
- callbacks$7.splice(index, 1);
4490
- }
4491
- if (callbacks$7.length === 0) {
4492
- mainDisposer$5 === null || mainDisposer$5 === void 0 ? void 0 : mainDisposer$5();
4493
- }
4494
- };
4495
- /* begin_public_function
4496
- id: channel.event.message_unpinned
4497
- */
4498
- /**
4499
- * ```js
4500
- * import { onChannelMessageUnpinned } from '@amityco/ts-sdk'
4501
- * const dispose = onChannelMessageUnpinned(channel => {
4502
- * // channel.pinnedMessage is now null
4503
- * })
4504
- * ```
4505
- *
4506
- * Fired when a channel's pinned message is removed (the `channel.messageUnpinned`
4507
- * realtime event) — either by an explicit unpin or automatically by the server when the
4508
- * pinned message is deleted or its author is banned from the channel / globally.
4509
- *
4510
- * @param callback The function to call when the event was fired
4511
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4512
- *
4513
- * @category Channel Events
4514
- */
4515
- const onChannelMessageUnpinned = (callback) => {
4516
- if (callbacks$7.length === 0) {
4517
- const client = getActiveClient();
4518
- const filter = (payload) => {
4519
- const channel = findCachedChannelForPin(payload);
4520
- if (!channel)
4521
- return;
4522
- const updated = updatePinnedMessageCache(channel, null);
4523
- callbacks$7.forEach(cb => cb(updated));
4524
- };
4525
- mainDisposer$5 = createEventSubscriber(client, 'onChannelMessageUnpinned', 'channel.messageUnpinned', filter);
4526
- }
4527
4345
  callbacks$7.push(callback);
4528
4346
  return () => dispose$7(callback);
4529
4347
  };
4530
- /* end_public_function */
4531
4348
 
4532
4349
  const callbacks$6 = [];
4533
- let mainDisposer$4 = null;
4350
+ let mainDisposer$6 = null;
4534
4351
  const dispose$6 = (cb) => {
4535
4352
  const index = callbacks$6.indexOf(cb);
4536
4353
  if (index > -1) {
4537
4354
  callbacks$6.splice(index, 1);
4538
4355
  }
4539
4356
  if (callbacks$6.length === 0) {
4540
- mainDisposer$4 === null || mainDisposer$4 === void 0 ? void 0 : mainDisposer$4();
4357
+ mainDisposer$6 === null || mainDisposer$6 === void 0 ? void 0 : mainDisposer$6();
4541
4358
  }
4542
4359
  };
4543
4360
  const onChannelMemberAdded = (callback) => {
@@ -4549,21 +4366,21 @@ const onChannelMemberAdded = (callback) => {
4549
4366
  ingestInCache(preparedPayload);
4550
4367
  callbacks$6.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'member')));
4551
4368
  };
4552
- mainDisposer$4 = createEventSubscriber(client, 'onChannelMemberAdded', 'channel.membersAdded', filter);
4369
+ mainDisposer$6 = createEventSubscriber(client, 'onChannelMemberAdded', 'channel.membersAdded', filter);
4553
4370
  }
4554
4371
  callbacks$6.push(callback);
4555
4372
  return () => dispose$6(callback);
4556
4373
  };
4557
4374
 
4558
4375
  const callbacks$5 = [];
4559
- let mainDisposer$3 = null;
4376
+ let mainDisposer$5 = null;
4560
4377
  const dispose$5 = (cb) => {
4561
4378
  const index = callbacks$5.indexOf(cb);
4562
4379
  if (index > -1) {
4563
4380
  callbacks$5.splice(index, 1);
4564
4381
  }
4565
4382
  if (callbacks$5.length === 0) {
4566
- mainDisposer$3 === null || mainDisposer$3 === void 0 ? void 0 : mainDisposer$3();
4383
+ mainDisposer$5 === null || mainDisposer$5 === void 0 ? void 0 : mainDisposer$5();
4567
4384
  }
4568
4385
  };
4569
4386
  const onChannelMemberRemoved = (callback) => {
@@ -4575,21 +4392,21 @@ const onChannelMemberRemoved = (callback) => {
4575
4392
  ingestInCache(preparedPayload);
4576
4393
  callbacks$5.forEach(cb => cb(channels[0], channelUsers[0]));
4577
4394
  };
4578
- mainDisposer$3 = createEventSubscriber(client, 'onChannelMemberRemoved', 'channel.membersRemoved', filter);
4395
+ mainDisposer$5 = createEventSubscriber(client, 'onChannelMemberRemoved', 'channel.membersRemoved', filter);
4579
4396
  }
4580
4397
  callbacks$5.push(callback);
4581
4398
  return () => dispose$5(callback);
4582
4399
  };
4583
4400
 
4584
4401
  const callbacks$4 = [];
4585
- let mainDisposer$2 = null;
4402
+ let mainDisposer$4 = null;
4586
4403
  const dispose$4 = (cb) => {
4587
4404
  const index = callbacks$4.indexOf(cb);
4588
4405
  if (index > -1) {
4589
4406
  callbacks$4.splice(index, 1);
4590
4407
  }
4591
4408
  if (callbacks$4.length === 0) {
4592
- mainDisposer$2 === null || mainDisposer$2 === void 0 ? void 0 : mainDisposer$2();
4409
+ mainDisposer$4 === null || mainDisposer$4 === void 0 ? void 0 : mainDisposer$4();
4593
4410
  }
4594
4411
  };
4595
4412
  const onChannelMemberBanned = (callback) => {
@@ -4609,20 +4426,20 @@ const onChannelMemberBanned = (callback) => {
4609
4426
  ingestInCache(preparedPayload);
4610
4427
  callbacks$4.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'banned')));
4611
4428
  };
4612
- mainDisposer$2 = createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
4429
+ mainDisposer$4 = createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
4613
4430
  callbacks$4.push(callback);
4614
4431
  return () => dispose$4(callback);
4615
4432
  };
4616
4433
 
4617
4434
  const callbacks$3 = [];
4618
- let mainDisposer$1 = null;
4435
+ let mainDisposer$3 = null;
4619
4436
  const dispose$3 = (cb) => {
4620
4437
  const index = callbacks$3.indexOf(cb);
4621
4438
  if (index > -1) {
4622
4439
  callbacks$3.splice(index, 1);
4623
4440
  }
4624
4441
  if (callbacks$3.length === 0) {
4625
- mainDisposer$1 === null || mainDisposer$1 === void 0 ? void 0 : mainDisposer$1();
4442
+ mainDisposer$3 === null || mainDisposer$3 === void 0 ? void 0 : mainDisposer$3();
4626
4443
  }
4627
4444
  };
4628
4445
  const onChannelMemberUnbanned = (callback) => {
@@ -4634,127 +4451,59 @@ const onChannelMemberUnbanned = (callback) => {
4634
4451
  ingestInCache(preparedPayload);
4635
4452
  callbacks$3.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'none')));
4636
4453
  };
4637
- mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
4454
+ mainDisposer$3 = createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
4638
4455
  }
4639
4456
  callbacks$3.push(callback);
4640
4457
  return () => dispose$3(callback);
4641
4458
  };
4642
4459
 
4643
4460
  const callbacks$2 = [];
4644
- const mainDisposers$1 = [];
4461
+ let mainDisposer$2 = null;
4645
4462
  const dispose$2 = (cb) => {
4646
4463
  const index = callbacks$2.indexOf(cb);
4647
4464
  if (index > -1) {
4648
4465
  callbacks$2.splice(index, 1);
4649
4466
  }
4650
4467
  if (callbacks$2.length === 0) {
4651
- mainDisposers$1.forEach(fn => fn());
4652
- mainDisposers$1.length = 0;
4468
+ mainDisposer$2 === null || mainDisposer$2 === void 0 ? void 0 : mainDisposer$2();
4653
4469
  }
4654
4470
  };
4655
- /* begin_public_function
4656
- id: channel.event.member_role_added
4657
- */
4658
- /**
4659
- * ```js
4660
- * import { onChannelMemberRoleAdded } from '@amityco/ts-sdk'
4661
- * const dispose = onChannelMemberRoleAdded((channel, member) => {
4662
- * // member.roles and member.permissions are the member's resulting state
4663
- * })
4664
- * ```
4665
- *
4666
- * Fired when a role is added to a member of a {@link Amity.Channel}, either by the
4667
- * local `ChannelRepository.Moderation.addRole` call or by the `channel.roleAdded` realtime
4668
- * event coming from any client or the admin console.
4669
- *
4670
- * The realtime event reaches every subscriber of the channel topic (see `getChannelTopic`),
4671
- * not only the actor or the affected members. It carries the affected members' resulting
4672
- * channel roles and channel-scoped permissions, which are written to cache before the
4673
- * callback runs. The callback is invoked once per affected member already held in cache.
4674
- *
4675
- * @param callback The function to call when the event was fired
4676
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4677
- *
4678
- * @category Channel Events
4679
- */
4680
4471
  const onChannelMemberRoleAdded = (callback) => {
4681
4472
  if (callbacks$2.length === 0) {
4682
4473
  const client = getActiveClient();
4683
- const onLocal = async (payload) => {
4474
+ const filter = async (payload) => {
4684
4475
  const { channels, channelUsers } = payload;
4685
4476
  callbacks$2.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
4686
4477
  };
4687
- const onRealtime = (payload) => {
4688
- const { channel, members } = applyChannelRolePayload(payload);
4689
- if (!channel)
4690
- return;
4691
- members.forEach(member => callbacks$2.forEach(cb => cb(channel, member)));
4692
- };
4693
- mainDisposers$1.push(createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', onLocal));
4694
- mainDisposers$1.push(createEventSubscriber(client, 'onChannelMemberRoleAdded', 'channel.roleAdded', onRealtime));
4478
+ mainDisposer$2 = createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', filter);
4695
4479
  }
4696
4480
  callbacks$2.push(callback);
4697
4481
  return () => dispose$2(callback);
4698
4482
  };
4699
- /* end_public_function */
4700
4483
 
4701
4484
  const callbacks$1 = [];
4702
- const mainDisposers = [];
4485
+ let mainDisposer$1 = null;
4703
4486
  const dispose$1 = (cb) => {
4704
4487
  const index = callbacks$1.indexOf(cb);
4705
4488
  if (index > -1) {
4706
4489
  callbacks$1.splice(index, 1);
4707
4490
  }
4708
4491
  if (callbacks$1.length === 0) {
4709
- mainDisposers.forEach(fn => fn());
4710
- mainDisposers.length = 0;
4492
+ mainDisposer$1 === null || mainDisposer$1 === void 0 ? void 0 : mainDisposer$1();
4711
4493
  }
4712
4494
  };
4713
- /* begin_public_function
4714
- id: channel.event.member_role_removed
4715
- */
4716
- /**
4717
- * ```js
4718
- * import { onChannelMemberRoleRemoved } from '@amityco/ts-sdk'
4719
- * const dispose = onChannelMemberRoleRemoved((channel, member) => {
4720
- * // member.roles and member.permissions are the member's resulting state
4721
- * })
4722
- * ```
4723
- *
4724
- * Fired when a role is removed from a member of a {@link Amity.Channel}, either by the
4725
- * local `ChannelRepository.Moderation.removeRole` call or by the `channel.roleRemoved` realtime
4726
- * event coming from any client or the admin console.
4727
- *
4728
- * The realtime event reaches every subscriber of the channel topic (see `getChannelTopic`),
4729
- * not only the actor or the affected members. It carries the affected members' resulting
4730
- * channel roles and channel-scoped permissions, which are written to cache before the
4731
- * callback runs. The callback is invoked once per affected member already held in cache.
4732
- *
4733
- * @param callback The function to call when the event was fired
4734
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4735
- *
4736
- * @category Channel Events
4737
- */
4738
4495
  const onChannelMemberRoleRemoved = (callback) => {
4739
4496
  if (callbacks$1.length === 0) {
4740
4497
  const client = getActiveClient();
4741
- const onLocal = async (payload) => {
4498
+ const filter = async (payload) => {
4742
4499
  const { channels, channelUsers } = payload;
4743
4500
  callbacks$1.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
4744
4501
  };
4745
- const onRealtime = (payload) => {
4746
- const { channel, members } = applyChannelRolePayload(payload);
4747
- if (!channel)
4748
- return;
4749
- members.forEach(member => callbacks$1.forEach(cb => cb(channel, member)));
4750
- };
4751
- mainDisposers.push(createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', onLocal));
4752
- mainDisposers.push(createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'channel.roleRemoved', onRealtime));
4502
+ mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
4753
4503
  }
4754
4504
  callbacks$1.push(callback);
4755
4505
  return () => dispose$1(callback);
4756
4506
  };
4757
- /* end_public_function */
4758
4507
 
4759
4508
  /**
4760
4509
  * Fired when a {@link Amity.Channel} has been archived by the active user.
@@ -4878,8 +4627,6 @@ const getMyMembership = (channelId, callback) => {
4878
4627
  disposers.push(onChannelMemberBanned(realtimeRouter));
4879
4628
  disposers.push(onChannelMemberUnbanned(realtimeRouter));
4880
4629
  disposers.push(onChannelSetUserMuted(realtimeRouter));
4881
- disposers.push(onChannelMemberRoleAdded(realtimeRouter));
4882
- disposers.push(onChannelMemberRoleRemoved(realtimeRouter));
4883
4630
  onFetch();
4884
4631
  return () => {
4885
4632
  disposers.forEach(fn => fn());
@@ -12800,7 +12547,7 @@ const getWatchSessionStorage = () => {
12800
12547
  return storageInstance;
12801
12548
  };
12802
12549
 
12803
- const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6zSsmXZParZm5zY9NZE03ALZhOB9/cz0e3kf/EbpfeL2mW7MApyiUt5i09ycchroOpcWp73ipIxvgigtZyUGFmsQicWhUs28F0D7w4Qfk76yG3nqXeb+BAMhCaIaa/k/aAxhiZG/ygEQWQrcC8gfe+jyicMAQPDEVS9YuUMGsLjIjKuVLZzp2xirQnhc2i2zVNEIvG6soprPOBEMQugzrtX5ECgYEA3b7KAbBIbDl1e4ZSCWhHdHkiWVZHaopsR/LhqDDNhXjWjq3AesgV6k0j9EdziMn/HmmOso0bz99GTV3JZf4A9ztTLumJlkHbdVtlgOqSjrFLj12rH9KXTheyIhWSpUmm8+WB1xasFbqpvJaGo7F3pd2Fqj1XR4mp5BO7c/t7LJ0CgYEA3aouEzXQ9THRKYocdfY69EI1Il1t/d/RSqqd9BxEjxBgxkM13ZiYIn/R4WW/nCUrlmhxG44Aa2Gob4Ahfsui2xKTg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
12550
+ const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
12804
12551
  /*
12805
12552
  * The crypto algorithm used for importing key and signing string
12806
12553
  */
@@ -13281,85 +13028,99 @@ const postLinkedObject = (post) => {
13281
13028
  .filter(Boolean) || []);
13282
13029
  },
13283
13030
  get creator() {
13031
+ // The id is checked for a value, not just for presence: a payload can
13032
+ // carry the field as null, and a null segment in a cache key throws while
13033
+ // being encoded rather than simply missing the cache.
13034
+ if (!post.postedUserId)
13035
+ return undefined;
13284
13036
  const cacheData = pullFromCache(['user', 'get', post.postedUserId]);
13285
13037
  if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13286
- return;
13038
+ return undefined;
13287
13039
  return userLinkedObject(cacheData.data);
13288
13040
  },
13289
13041
  get targetCommunity() {
13290
13042
  var _a;
13043
+ if (!post.targetId)
13044
+ return undefined;
13291
13045
  const communityCache = (_a = pullFromCache([
13292
13046
  'community',
13293
13047
  'get',
13294
13048
  post.targetId,
13295
13049
  ])) === null || _a === void 0 ? void 0 : _a.data;
13296
13050
  if (!communityCache)
13297
- return;
13051
+ return undefined;
13298
13052
  return communityLinkedObject(communityCache);
13299
13053
  },
13300
13054
  getImageInfo() {
13301
13055
  var _a, _b;
13302
- return isAmityImagePost(post)
13303
- ? 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)
13304
- : undefined;
13056
+ if (!isAmityImagePost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.fileId))
13057
+ return undefined;
13058
+ return fileLinkedObject((_b = pullFromCache(['file', 'get', post.data.fileId])) === null || _b === void 0 ? void 0 : _b.data);
13305
13059
  },
13306
13060
  getVideoInfo() {
13307
13061
  var _a, _b, _c;
13308
- return isAmityVideoPost(post)
13309
- ? 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)
13310
- : undefined;
13062
+ const originalFileId = isAmityVideoPost(post) ? (_b = (_a = post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original : undefined;
13063
+ if (!originalFileId)
13064
+ return undefined;
13065
+ return fileLinkedObject((_c = pullFromCache(['file', 'get', originalFileId])) === null || _c === void 0 ? void 0 : _c.data);
13311
13066
  },
13312
13067
  getVideoThumbnailInfo() {
13313
13068
  var _a, _b;
13314
- return isAmityVideoPost(post)
13315
- ? 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)
13316
- : undefined;
13069
+ // `isAmityVideoPost` proves the field is *present* — it tests
13070
+ // `'thumbnailFileId' in post.data` — and presence is not a value. The
13071
+ // server sends the field as null until it has finished transcoding the
13072
+ // video, so a just-published post reaches here with a null id and used to
13073
+ // build the cache key ['file', 'get', null].
13074
+ const thumbnailFileId = isAmityVideoPost(post) ? (_a = post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId : undefined;
13075
+ if (!thumbnailFileId)
13076
+ return undefined;
13077
+ return fileLinkedObject((_b = pullFromCache(['file', 'get', thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data);
13317
13078
  },
13318
13079
  getFileInfo() {
13319
13080
  var _a, _b;
13320
- return isAmityFilePost(post)
13321
- ? (_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
13322
- : undefined;
13081
+ if (!isAmityFilePost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.fileId))
13082
+ return undefined;
13083
+ return (_b = pullFromCache(['file', 'get', post.data.fileId])) === null || _b === void 0 ? void 0 : _b.data;
13323
13084
  },
13324
13085
  getLivestreamInfo() {
13325
13086
  var _a, _b;
13326
- if (!isAmityLivestreamPost(post))
13327
- return;
13087
+ if (!isAmityLivestreamPost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.streamId))
13088
+ return undefined;
13328
13089
  const cache = (_b = pullFromCache([
13329
13090
  'stream',
13330
13091
  'get',
13331
- (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.streamId,
13092
+ post.data.streamId,
13332
13093
  ])) === null || _b === void 0 ? void 0 : _b.data;
13333
13094
  if (!cache)
13334
- return;
13095
+ return undefined;
13335
13096
  return streamLinkedObject(cache);
13336
13097
  },
13337
13098
  getPollInfo() {
13338
13099
  var _a, _b;
13339
- if (!isAmityPollPost(post))
13340
- return;
13341
- const cache = (_b = pullFromCache(['poll', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.pollId])) === null || _b === void 0 ? void 0 : _b.data;
13100
+ if (!isAmityPollPost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.pollId))
13101
+ return undefined;
13102
+ const cache = (_b = pullFromCache(['poll', 'get', post.data.pollId])) === null || _b === void 0 ? void 0 : _b.data;
13342
13103
  if (!cache)
13343
- return;
13104
+ return undefined;
13344
13105
  return pollLinkedObject(cache);
13345
13106
  },
13346
13107
  getClipInfo() {
13347
13108
  var _a, _b;
13348
- return isAmityClipPost(post)
13349
- ? (_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
13350
- : undefined;
13109
+ if (!isAmityClipPost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.fileId))
13110
+ return undefined;
13111
+ return (_b = pullFromCache(['file', 'get', post.data.fileId])) === null || _b === void 0 ? void 0 : _b.data;
13351
13112
  },
13352
13113
  getAudioInfo() {
13353
13114
  var _a, _b;
13354
- return isAmityAudioPost(post)
13355
- ? (_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
13356
- : undefined;
13115
+ if (!isAmityAudioPost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.fileId))
13116
+ return undefined;
13117
+ return (_b = pullFromCache(['file', 'get', post.data.fileId])) === null || _b === void 0 ? void 0 : _b.data;
13357
13118
  },
13358
13119
  getRoomInfo() {
13359
13120
  var _a, _b;
13360
- if (!isAmityRoomPost(post))
13361
- return;
13362
- 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;
13121
+ if (!isAmityRoomPost(post) || !((_a = post.data) === null || _a === void 0 ? void 0 : _a.roomId))
13122
+ return undefined;
13123
+ const room = (_b = pullFromCache(['room', 'get', post.data.roomId])) === null || _b === void 0 ? void 0 : _b.data;
13363
13124
  return room ? roomLinkedObject(room) : undefined;
13364
13125
  },
13365
13126
  getEventInfo() {
@@ -18516,20 +18277,20 @@ const getArchivedChannelIds = async () => {
18516
18277
 
18517
18278
  /**
18518
18279
  * ```js
18519
- * import { onMessageDeleted } from '@amityco/ts-sdk'
18520
- * const dispose = onMessageDeleted(message => {
18280
+ * import { onMessageUpdated } from '@amityco/ts-sdk'
18281
+ * const dispose = onMessageUpdated(message => {
18521
18282
  * // ...
18522
18283
  * })
18523
18284
  * ```
18524
18285
  *
18525
- * Fired when an {@link Amity.Message} was deleted
18286
+ * Fired when an {@link Amity.Message} has been updated
18526
18287
  *
18527
18288
  * @param callback The function to call when the event was fired
18528
18289
  * @returns an {@link Amity.Unsubscriber} function to stop listening
18529
18290
  *
18530
18291
  * @category Message Events
18531
18292
  */
18532
- const onMessageDeleted = (callback) => {
18293
+ const onMessageUpdated = (callback) => {
18533
18294
  const client = getActiveClient();
18534
18295
  const filter = async (rawPayload) => {
18535
18296
  const payload = await prepareMessagePayload(rawPayload);
@@ -18537,48 +18298,30 @@ const onMessageDeleted = (callback) => {
18537
18298
  callback(payload.messages[0]);
18538
18299
  };
18539
18300
  const disposers = [
18540
- createEventSubscriber(client, 'message/onMessageDeleted', 'message.deleted', filter),
18541
- createEventSubscriber(client, 'message/onMessageDeleted', 'local.message.deleted', payload => callback(payload.messages[0])),
18301
+ createEventSubscriber(client, 'onMessageUpdated', 'message.updated', filter),
18302
+ createEventSubscriber(client, 'onMessageUpdated', 'local.message.updated', payload => callback(payload.messages[0])),
18542
18303
  ];
18543
18304
  return () => {
18544
18305
  disposers.forEach(fn => fn());
18545
18306
  };
18546
18307
  };
18547
18308
 
18548
- /**
18549
- * Defensive clear of `channel.pinnedMessage` when the pinned message itself is deleted.
18550
- *
18551
- * The server also emits `channel.messageUnpinned` in this case, but realtime events are
18552
- * fire-and-forget and their order is not guaranteed. Clearing on `message.deleted`
18553
- * (MQTT or local) makes the banner disappear even if the unpin event is lost; the
18554
- * server's own `messageUnpinned` then becomes a no-op.
18555
- *
18556
- * Internal — wired into the `getChannel` live object; not exported publicly.
18557
- */
18558
- const onChannelPinnedMessageDeleted = (callback) => onMessageDeleted(message => {
18559
- var _a;
18560
- const channel = findCachedChannelByAnyId(message.channelId);
18561
- if (!channel || ((_a = channel.pinnedMessage) === null || _a === void 0 ? void 0 : _a.messageId) !== message.messageId)
18562
- return;
18563
- callback(updatePinnedMessageCache(channel, null));
18564
- });
18565
-
18566
18309
  /**
18567
18310
  * ```js
18568
- * import { onMessageUpdated } from '@amityco/ts-sdk'
18569
- * const dispose = onMessageUpdated(message => {
18311
+ * import { onMessageDeleted } from '@amityco/ts-sdk'
18312
+ * const dispose = onMessageDeleted(message => {
18570
18313
  * // ...
18571
18314
  * })
18572
18315
  * ```
18573
18316
  *
18574
- * Fired when an {@link Amity.Message} has been updated
18317
+ * Fired when an {@link Amity.Message} was deleted
18575
18318
  *
18576
18319
  * @param callback The function to call when the event was fired
18577
18320
  * @returns an {@link Amity.Unsubscriber} function to stop listening
18578
18321
  *
18579
18322
  * @category Message Events
18580
18323
  */
18581
- const onMessageUpdated = (callback) => {
18324
+ const onMessageDeleted = (callback) => {
18582
18325
  const client = getActiveClient();
18583
18326
  const filter = async (rawPayload) => {
18584
18327
  const payload = await prepareMessagePayload(rawPayload);
@@ -18586,8 +18329,8 @@ const onMessageUpdated = (callback) => {
18586
18329
  callback(payload.messages[0]);
18587
18330
  };
18588
18331
  const disposers = [
18589
- createEventSubscriber(client, 'onMessageUpdated', 'message.updated', filter),
18590
- createEventSubscriber(client, 'onMessageUpdated', 'local.message.updated', payload => callback(payload.messages[0])),
18332
+ createEventSubscriber(client, 'message/onMessageDeleted', 'message.deleted', filter),
18333
+ createEventSubscriber(client, 'message/onMessageDeleted', 'local.message.deleted', payload => callback(payload.messages[0])),
18591
18334
  ];
18592
18335
  return () => {
18593
18336
  disposers.forEach(fn => fn());
@@ -19168,132 +18911,6 @@ softDeleteMessage.optimistically = (messageId) => {
19168
18911
  };
19169
18912
  /* end_public_function */
19170
18913
 
19171
- /**
19172
- * Fire-and-forget refresh of `channelUsers[...].permissions` for the channel a
19173
- * message belongs to. Used by `pinMessage` / `unpinMessage` on `403` so the next
19174
- * `hasPermission(PIN_MESSAGE).channel(channelId)` reflects a revoked role
19175
- * ([`pinMessage` REQ-010](../../@types/../..) / [`unpinMessage` REQ-008](../../@types/../..)).
19176
- *
19177
- * The API only receives a `messageId`, so the channel is resolved through the
19178
- * local cache: first the message row, then any cached channel whose current pin
19179
- * is that message. When nothing matches the refresh is skipped — the next
19180
- * channel read picks up the fresh permissions anyway.
19181
- */
19182
- const refreshChannelPermissionsForMessage = (messageId) => {
19183
- var _a, _b, _c;
19184
- const cachedMessage = (_a = getMessage$1.locally(messageId)) === null || _a === void 0 ? void 0 : _a.data;
19185
- let channelId = cachedMessage === null || cachedMessage === void 0 ? void 0 : cachedMessage.channelId;
19186
- if (!channelId) {
19187
- channelId = (_c = (_b = queryCache(['channel', 'get'])) === null || _b === void 0 ? void 0 : _b.find(({ data }) => { var _a; return ((_a = data.pinnedMessage) === null || _a === void 0 ? void 0 : _a.messageId) === messageId; })) === null || _c === void 0 ? void 0 : _c.data.channelId;
19188
- }
19189
- if (!channelId)
19190
- return;
19191
- getChannel$1(channelId).catch(() => {
19192
- /* silent per spec; UIKit renders no error toast */
19193
- });
19194
- };
19195
-
19196
- /* begin_public_function
19197
- id: message.pin
19198
- */
19199
- /**
19200
- * ```js
19201
- * import { MessageRepository } from '@amityco/ts-sdk'
19202
- * const channel = await MessageRepository.pinMessage(messageId)
19203
- * console.log(channel.pinnedMessage)
19204
- * ```
19205
- *
19206
- * Pins a {@link Amity.Message} in its livestream (`live`) channel. A channel holds at
19207
- * most one pinned message: pinning a different message replaces the current pin in a
19208
- * single step — no unpin is needed first. Pinning the message that is already pinned is
19209
- * rejected by the server (400).
19210
- *
19211
- * The caller must hold the `PIN_MESSAGE` permission in the channel (or be an admin with
19212
- * `ModerateChannel`). The server also rejects pinning a deleted message, a message whose
19213
- * author is banned from the channel or globally banned, and pinning in any channel type
19214
- * other than `live`. On any error the pin state is left unchanged.
19215
- *
19216
- * The response is the affected channel; it is ingested into cache and fires
19217
- * `local.channel.updated`, so `ChannelRepository.getChannel` observers update without
19218
- * waiting for the `channel.messagePinned` realtime event.
19219
- *
19220
- * @param messageId the **internal** ID of the {@link Amity.Message} to pin
19221
- * @returns the updated {@link Amity.Channel}, with `pinnedMessage` set
19222
- *
19223
- * @category Message API
19224
- * @async
19225
- */
19226
- const pinMessage = async (messageId) => {
19227
- const client = getActiveClient();
19228
- client.log('message/pinMessage', messageId);
19229
- let payload;
19230
- try {
19231
- ({ data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/pin`));
19232
- }
19233
- catch (error) {
19234
- if ((error === null || error === void 0 ? void 0 : error.code) === 400301 /* Amity.ServerError.PERMISSION_DENIED */) {
19235
- refreshChannelPermissionsForMessage(messageId);
19236
- }
19237
- throw error;
19238
- }
19239
- const data = await prepareChannelPayload(payload);
19240
- if (client.cache)
19241
- ingestInCache(data);
19242
- fireEvent('local.channel.updated', data);
19243
- return constructChannelObject(data.channels[0]);
19244
- };
19245
- /* end_public_function */
19246
-
19247
- /* begin_public_function
19248
- id: message.unpin
19249
- */
19250
- /**
19251
- * ```js
19252
- * import { MessageRepository } from '@amityco/ts-sdk'
19253
- * const channel = await MessageRepository.unpinMessage(messageId)
19254
- * console.log(channel.pinnedMessage) // null
19255
- * ```
19256
- *
19257
- * Removes the pin from a {@link Amity.Message}. `messageId` must be the message that is
19258
- * **currently** pinned in its channel; otherwise the server answers 400 — this is
19259
- * deliberate, so a stale client cannot clear a pin that someone else has since replaced.
19260
- * On that error, re-read the channel (or rely on the `channel.messagePinned` event) to
19261
- * get the current pin.
19262
- *
19263
- * The caller must hold the `PIN_MESSAGE` permission in the channel (or be an admin with
19264
- * `ModerateChannel`). Unpinning is allowed regardless of channel type and stream state.
19265
- *
19266
- * The response is the affected channel; it is ingested into cache and fires
19267
- * `local.channel.updated`, so `ChannelRepository.getChannel` observers update without
19268
- * waiting for the `channel.messageUnpinned` realtime event.
19269
- *
19270
- * @param messageId the **internal** ID of the currently pinned {@link Amity.Message}
19271
- * @returns the updated {@link Amity.Channel}, with `pinnedMessage` cleared
19272
- *
19273
- * @category Message API
19274
- * @async
19275
- */
19276
- const unpinMessage = async (messageId) => {
19277
- const client = getActiveClient();
19278
- client.log('message/unpinMessage', messageId);
19279
- let payload;
19280
- try {
19281
- ({ data: payload } = await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}/pin`));
19282
- }
19283
- catch (error) {
19284
- if ((error === null || error === void 0 ? void 0 : error.code) === 400301 /* Amity.ServerError.PERMISSION_DENIED */) {
19285
- refreshChannelPermissionsForMessage(messageId);
19286
- }
19287
- throw error;
19288
- }
19289
- const data = await prepareChannelPayload(payload);
19290
- if (client.cache)
19291
- ingestInCache(data);
19292
- fireEvent('local.channel.updated', data);
19293
- return constructChannelObject(data.channels[0]);
19294
- };
19295
- /* end_public_function */
19296
-
19297
18914
  /**
19298
18915
  * ```js
19299
18916
  * import { MessageRepository } from '@amityco/ts-sdk'
@@ -20197,8 +19814,6 @@ var index$n = /*#__PURE__*/Object.freeze({
20197
19814
  editMessage: editMessage,
20198
19815
  deleteMessage: deleteMessage,
20199
19816
  softDeleteMessage: softDeleteMessage,
20200
- pinMessage: pinMessage,
20201
- unpinMessage: unpinMessage,
20202
19817
  markAsDelivered: markAsDelivered,
20203
19818
  getReadUsers: getReadUsers,
20204
19819
  getDeliveredUsers: getDeliveredUsers,
@@ -20836,9 +20451,6 @@ const getChannel = (channelId, callback) => {
20836
20451
  onChannelMemberBanned,
20837
20452
  onChannelMemberUnbanned,
20838
20453
  onChannelSetMuted,
20839
- onChannelMessagePinned,
20840
- onChannelMessageUnpinned,
20841
- onChannelPinnedMessageDeleted,
20842
20454
  convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
20843
20455
  convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
20844
20456
  convertEventPayload((callback) => {
@@ -22935,8 +22547,6 @@ var index$j = /*#__PURE__*/Object.freeze({
22935
22547
  onChannelJoined: onChannelJoined,
22936
22548
  onChannelLeft: onChannelLeft,
22937
22549
  onChannelSetMuted: onChannelSetMuted,
22938
- onChannelMessagePinned: onChannelMessagePinned,
22939
- onChannelMessageUnpinned: onChannelMessageUnpinned,
22940
22550
  onChannelMemberAdded: onChannelMemberAdded,
22941
22551
  onChannelMemberRemoved: onChannelMemberRemoved,
22942
22552
  onChannelMemberBanned: onChannelMemberBanned,
@@ -22954,11 +22564,7 @@ var index$j = /*#__PURE__*/Object.freeze({
22954
22564
  isUnreadCountSupport: isUnreadCountSupport,
22955
22565
  convertFromRaw: convertFromRaw,
22956
22566
  preUpdateChannelCache: preUpdateChannelCache,
22957
- prepareChannelPayload: prepareChannelPayload,
22958
- findCachedChannelByAnyId: findCachedChannelByAnyId,
22959
- findCachedChannelForPin: findCachedChannelForPin,
22960
- updatePinnedMessageCache: updatePinnedMessageCache,
22961
- applyChannelRolePayload: applyChannelRolePayload
22567
+ prepareChannelPayload: prepareChannelPayload
22962
22568
  });
22963
22569
 
22964
22570
  const saveCommunityUsers = (communities, communityUsers) => {