@amityco/ts-sdk 6.17.3-c7279f3.0 → 6.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -83,8 +83,8 @@ const PostContentType = Object.freeze({
83
83
 
84
84
  function getVersion() {
85
85
  try {
86
- // the string ''v6.17.2-esm'' should be replaced by actual value by @rollup/plugin-replace
87
- return 'v6.17.2-esm';
86
+ // the string ''v6.17.3-esm'' should be replaced by actual value by @rollup/plugin-replace
87
+ return 'v6.17.3-esm';
88
88
  }
89
89
  catch (error) {
90
90
  return '__dev__';
@@ -23079,6 +23079,11 @@ const logout = async () => {
23079
23079
  client.userId = undefined;
23080
23080
  client.token = undefined;
23081
23081
  client.http.defaults.headers.common.Authorization = '';
23082
+ client.http.defaults.metadata = {
23083
+ tokenExpiry: '',
23084
+ isGlobalBanned: false,
23085
+ isUserDeleted: false,
23086
+ };
23082
23087
  client.ws.io.opts.query = { token: '' };
23083
23088
  /*
23084
23089
  * Cache should be usable if tokenExpired
@@ -23263,7 +23268,7 @@ async function runMqtt() {
23263
23268
  * @async
23264
23269
  */
23265
23270
  const login = async (params, sessionHandler, config) => {
23266
- var _a, _b, _c;
23271
+ var _a, _b;
23267
23272
  const client = getActiveClient();
23268
23273
  let unsubWatcher;
23269
23274
  client.log('client/api/connectClient', Object.assign({ apiKey: client.apiKey, sessionState: client.sessionState }, params));
@@ -23275,25 +23280,35 @@ const login = async (params, sessionHandler, config) => {
23275
23280
  subscriptions = [];
23276
23281
  }
23277
23282
  // default values
23278
- (_a = params.deviceId) !== null && _a !== void 0 ? _a : (params.deviceId = await getDeviceId());
23283
+ const defaultDeviceId = await getDeviceId();
23279
23284
  try {
23280
- // @ts-ignore: in that particular case, typing can be
23281
- // ignored since we enforce default values just before.
23282
- const { users } = await setClientToken(params);
23285
+ const { users } = await setClientToken(Object.assign(Object.assign({}, params), { displayName: (params === null || params === void 0 ? void 0 : params.displayName) || params.userId, deviceId: (params === null || params === void 0 ? void 0 : params.deviceId) || defaultDeviceId }));
23286
+ const user = users.find(u => u.userId === params.userId);
23287
+ if (user == null) {
23288
+ throw new ASCError(`${params.userId} has not been founded`, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
23289
+ }
23290
+ if (user.isDeleted) {
23291
+ terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
23292
+ return false;
23293
+ }
23294
+ if (user.isGlobalBanned) {
23295
+ terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
23296
+ return false;
23297
+ }
23283
23298
  // FIXME: events are duplicated if connectClient is called few times without disconnectClient
23284
23299
  // wire websocket events to our event emitter
23285
23300
  proxyWebsocketEvents(client.ws, client.emitter);
23286
23301
  client.ws.once('connect', () => {
23287
23302
  client.ws.open();
23288
23303
  });
23289
- client.userId = params.userId;
23304
+ client.userId = user.userId;
23290
23305
  client.sessionHandler = sessionHandler;
23291
23306
  /*
23292
23307
  * Cannot push to subscriptions as watcher needs to continue working even if
23293
23308
  * token expires
23294
23309
  */
23295
- unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.expiresAt, (_c = client.token) === null || _c === void 0 ? void 0 : _c.issuedAt, sessionHandler);
23296
- setActiveUser(users[0]);
23310
+ unsubWatcher = client.accessTokenExpiryWatcher((_a = client.token) === null || _a === void 0 ? void 0 : _a.expiresAt, (_b = client.token) === null || _b === void 0 ? void 0 : _b.issuedAt, sessionHandler);
23311
+ setActiveUser(user);
23297
23312
  }
23298
23313
  catch (error) {
23299
23314
  /*
@@ -35475,60 +35490,6 @@ const updateComment = async (commentId, patch) => {
35475
35490
  };
35476
35491
  /* end_public_function */
35477
35492
 
35478
- const getStoryByStoryId$1 = async (storyId) => {
35479
- const client = getActiveClient();
35480
- client.log('story/getStoryByStoryId', storyId);
35481
- // Get story referenceId from cache
35482
- const cacheReferenceId = pullFromCache([
35483
- "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
35484
- storyId,
35485
- ]);
35486
- if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
35487
- const { data: referenceId } = cacheReferenceId;
35488
- isInTombstone('story', referenceId);
35489
- }
35490
- let data;
35491
- try {
35492
- const response = await client.http.get(`/api/v4/stories/${storyId}`);
35493
- data = response.data;
35494
- }
35495
- catch (error) {
35496
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
35497
- pushToTombstone('story', storyId);
35498
- }
35499
- throw error;
35500
- }
35501
- const cachedAt = client.cache && Date.now();
35502
- if (client.cache) {
35503
- ingestInCache(data, { cachedAt });
35504
- }
35505
- return {
35506
- data: data.stories[0],
35507
- cachedAt,
35508
- };
35509
- };
35510
- getStoryByStoryId$1.locally = (storyId) => {
35511
- const client = getActiveClient();
35512
- client.log('story/getStorybyStoryId', storyId);
35513
- // Get story referenceId from cache
35514
- const cacheReferenceId = pullFromCache([
35515
- "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
35516
- storyId,
35517
- ]);
35518
- if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
35519
- const { data: referenceId } = cacheReferenceId;
35520
- isInTombstone('story', referenceId);
35521
- }
35522
- const cachedAt = client.cache && Date.now();
35523
- const storyCache = pullFromCache(['story', 'get', storyId]);
35524
- if (!storyCache)
35525
- return;
35526
- return {
35527
- data: storyCache.data,
35528
- cachedAt,
35529
- };
35530
- };
35531
-
35532
35493
  /* begin_public_function
35533
35494
  id: comment.soft_delete, comment.hard_delete
35534
35495
  */
@@ -35558,34 +35519,18 @@ const deleteComment = async (commentId, permanent = false) => {
35558
35519
  });
35559
35520
  // to support hard deletion
35560
35521
  const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
35561
- if (comment.data.referenceType === 'story') {
35562
- const story = await getStoryByStoryId$1(comment.data.referenceId);
35563
- fireEvent('local.story.updated', {
35564
- stories: [story.data],
35565
- categories: [],
35566
- comments: [],
35567
- communities: [],
35568
- communityUsers: [],
35569
- files: [],
35570
- users: [],
35571
- });
35572
- }
35573
- else {
35574
- const post = await getPost$1(comment.data.referenceId);
35575
- // @TODO: Need to separate Local / MQTT later
35576
- fireEvent('post.updated', {
35577
- posts: [post.data],
35578
- categories: [],
35579
- comments: [],
35580
- communities: [],
35581
- communityUsers: [],
35582
- feeds: [],
35583
- files: [],
35584
- postChildren: [],
35585
- users: [],
35586
- });
35587
- }
35588
- // @TODO: Need to separate Local / MQTT later
35522
+ const post = await getPost$1(comment.data.referenceId);
35523
+ fireEvent('post.updated', {
35524
+ posts: [post.data],
35525
+ categories: [],
35526
+ comments: [],
35527
+ communities: [],
35528
+ communityUsers: [],
35529
+ feeds: [],
35530
+ files: [],
35531
+ postChildren: [],
35532
+ users: [],
35533
+ });
35589
35534
  fireEvent('comment.deleted', {
35590
35535
  comments: [deleted],
35591
35536
  commentChildren: [],
@@ -36897,7 +36842,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
36897
36842
  getPoll: getPoll
36898
36843
  });
36899
36844
 
36900
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECgg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7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/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-----";
36901
36846
  /*
36902
36847
  * The crypto algorithm used for importing key and signing string
36903
36848
  */
@@ -37299,17 +37244,15 @@ const createOptimisticEvent = ({ payload, formData = undefined, isVideo = false,
37299
37244
  };
37300
37245
 
37301
37246
  // Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
37302
- const convertRawStoryToInternalStory = (rawData, isCreated = false) => {
37247
+ const convertRawStoryToInternalStory = (rawData) => {
37303
37248
  const { storyId, referenceId } = rawData;
37304
- if (!isCreated) {
37305
- if (referenceId)
37306
- return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
37307
- }
37249
+ if (referenceId)
37250
+ return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
37308
37251
  return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
37309
37252
  };
37310
- const convertStoryRawToInternal = (data, isCreated = false) => {
37253
+ const convertStoryRawToInternal = (data) => {
37311
37254
  const { stories } = data;
37312
- const storiesData = stories.map(story => convertRawStoryToInternalStory(story, isCreated));
37255
+ const storiesData = stories.map(convertRawStoryToInternalStory);
37313
37256
  return Object.assign(Object.assign({}, data), { stories: storiesData });
37314
37257
  };
37315
37258
 
@@ -37629,7 +37572,7 @@ const onStoryCreated = (callback) => {
37629
37572
  const client = getActiveClient();
37630
37573
  const filter = async (payload) => {
37631
37574
  // Apply the necessary field for story payload
37632
- const convertPayload = convertStoryRawToInternal(payload, true);
37575
+ const convertPayload = convertStoryRawToInternal(payload);
37633
37576
  ingestInCache(convertPayload);
37634
37577
  callback(convertPayload.stories);
37635
37578
  };
@@ -37785,7 +37728,7 @@ const getActiveStoriesByTarget = (params, callback) => {
37785
37728
  loading: snapshot.loading || false,
37786
37729
  });
37787
37730
  };
37788
- const processNewData = (result, event, initial = false, loading = false, error = false) => {
37731
+ const processNewData = (result, initial = false, loading = false, error = false) => {
37789
37732
  const cached = pullFromCache(cacheKey);
37790
37733
  const data = {
37791
37734
  loading,
@@ -37794,21 +37737,15 @@ const getActiveStoriesByTarget = (params, callback) => {
37794
37737
  data: (cached === null || cached === void 0 ? void 0 : cached.data) || [],
37795
37738
  };
37796
37739
  if (result) {
37797
- if (event === "onDelete" /* Amity.StoryActionType.OnDelete */) {
37798
- const deletedIds = result.map(({ referenceId }) => referenceId);
37799
- data.data = data.data.filter(refId => !deletedIds.includes(refId)) || [];
37800
- }
37801
- else {
37802
- data.data = initial
37803
- ? result.map(getResolver('story'))
37804
- : [...new Set([...data.data, ...result.map(getResolver('story'))])];
37805
- }
37740
+ data.data = initial
37741
+ ? result.map(getResolver('story'))
37742
+ : [...new Set([...data.data, ...result.map(getResolver('story'))])];
37806
37743
  }
37807
37744
  pushToCache(cacheKey, data.data);
37808
37745
  responder(data);
37809
37746
  };
37810
37747
  const realtimeRouter = (event) => (story) => {
37811
- processNewData(story, event);
37748
+ processNewData(story);
37812
37749
  };
37813
37750
  const reloadData = () => (newData) => {
37814
37751
  const cached = pullFromCache(cacheKey);
@@ -37830,17 +37767,71 @@ const getActiveStoriesByTarget = (params, callback) => {
37830
37767
  const onFetch = (initial) => {
37831
37768
  const query = createQuery(getActiveStoriesByTarget$1, params);
37832
37769
  runQuery(query, ({ data: result, error, loading }) => {
37833
- processNewData(result, 'fetch', initial, loading, error);
37770
+ processNewData(result, initial, loading, error);
37834
37771
  });
37835
37772
  };
37836
37773
  onFetch(true);
37837
- disposers.push(onStoryCreated(realtimeRouter("onCreate" /* Amity.StoryActionType.OnCreate */)), onStoryUpdated(realtimeRouter("onUpdate" /* Amity.StoryActionType.OnUpdate */)), onStoryDeleted(realtimeRouter("onDelete" /* Amity.StoryActionType.OnDelete */)), onStoryReactionAdded(realtimeRouter("onReactionAdded" /* Amity.StoryActionType.OnReactionAdded */)), onStoryReactionRemoved(realtimeRouter("onReactionRemoved" /* Amity.StoryActionType.OnReactionRemoved */)), onStoryError(realtimeRouter("onError" /* Amity.StoryActionType.OnError */)), onStoryCreatedLocal(realtimeRouter("onCreate" /* Amity.StoryActionType.OnCreate */)), onStoryUpdatedLocal(realtimeRouter("onUpdate" /* Amity.StoryActionType.OnUpdate */)), onStoryDeletedLocal(realtimeRouter("onDelete" /* Amity.StoryActionType.OnDelete */)), onStoryReactionAddedLocal(realtimeRouter("onReactionAdded" /* Amity.StoryActionType.OnReactionAdded */)), onStoryReactionRemovedLocal(realtimeRouter("onReactionRemoved" /* Amity.StoryActionType.OnReactionRemoved */)), onStoryLocalDataUpdated(reloadData()), () => dropFromCache(cacheKey));
37774
+ disposers.push(onStoryCreated(realtimeRouter()), onStoryUpdated(realtimeRouter()), onStoryDeleted(realtimeRouter()), onStoryReactionAdded(realtimeRouter()), onStoryReactionRemoved(realtimeRouter()), onStoryError(realtimeRouter()), onStoryCreatedLocal(realtimeRouter()), onStoryUpdatedLocal(realtimeRouter()), onStoryDeletedLocal(realtimeRouter()), onStoryReactionAddedLocal(realtimeRouter()), onStoryReactionRemovedLocal(realtimeRouter()), onStoryLocalDataUpdated(reloadData()), () => dropFromCache(cacheKey));
37838
37775
  return () => {
37839
37776
  log(`getActiveStoriesByTarget(tmpid: ${timestamp}) > dispose`);
37840
37777
  disposers.forEach(fn => fn());
37841
37778
  };
37842
37779
  };
37843
37780
 
37781
+ const getStoryByStoryId$1 = async (storyId) => {
37782
+ const client = getActiveClient();
37783
+ client.log('story/getStoryByStoryId', storyId);
37784
+ // Get story referenceId from cache
37785
+ const cacheReferenceId = pullFromCache([
37786
+ "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
37787
+ storyId,
37788
+ ]);
37789
+ if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
37790
+ const { data: referenceId } = cacheReferenceId;
37791
+ isInTombstone('story', referenceId);
37792
+ }
37793
+ let data;
37794
+ try {
37795
+ const response = await client.http.get(`/api/v4/stories/${storyId}`);
37796
+ data = response.data;
37797
+ }
37798
+ catch (error) {
37799
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
37800
+ pushToTombstone('story', storyId);
37801
+ }
37802
+ throw error;
37803
+ }
37804
+ const cachedAt = client.cache && Date.now();
37805
+ if (client.cache) {
37806
+ ingestInCache(data, { cachedAt });
37807
+ }
37808
+ return {
37809
+ data: data.stories[0],
37810
+ cachedAt,
37811
+ };
37812
+ };
37813
+ getStoryByStoryId$1.locally = (storyId) => {
37814
+ const client = getActiveClient();
37815
+ client.log('story/getStorybyStoryId', storyId);
37816
+ // Get story referenceId from cache
37817
+ const cacheReferenceId = pullFromCache([
37818
+ "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
37819
+ storyId,
37820
+ ]);
37821
+ if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
37822
+ const { data: referenceId } = cacheReferenceId;
37823
+ isInTombstone('story', referenceId);
37824
+ }
37825
+ const cachedAt = client.cache && Date.now();
37826
+ const storyCache = pullFromCache(['story', 'get', storyId]);
37827
+ if (!storyCache)
37828
+ return;
37829
+ return {
37830
+ data: storyCache.data,
37831
+ cachedAt,
37832
+ };
37833
+ };
37834
+
37844
37835
  const getSingleItemFromArray = (func) => (callback) => func((result) => callback(result[0]));
37845
37836
  const getStoryByStoryId = (storyId, callback) => {
37846
37837
  return liveObject(storyId, data => {