@amityco/ts-sdk-react-native 7.26.1-c29647b8.0 → 7.26.1-fbe5a6dd.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cache/utils/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,eAAO,MAAM,sBAAsB,QAAa,CAAC;AACjD,eAAO,MAAM,cAAc,QAAa,CAAC;AACzC,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAkBnD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,2BAA0B,MACmC,CAAC;AAEpF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,mBAAoC,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,cAAe,GAAG,aAAa,GAAG,KAAG,OAa7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,4BAA6B,GAAG,2BACU,CAAC;AAEhE;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,cAAe,MAAM,WAAW,KAAG,OACS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cache/utils/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,eAAO,MAAM,sBAAsB,QAAa,CAAC;AACjD,eAAO,MAAM,cAAc,QAAa,CAAC;AACzC,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAkBnD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,2BAA0B,MAQ7C,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,mBAAoC,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,cAAe,GAAG,aAAa,GAAG,KAAG,OAa7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,4BAA6B,GAAG,2BACU,CAAC;AAEhE;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,cAAe,MAAM,WAAW,KAAG,OACS,CAAC"}
@@ -5,7 +5,7 @@ export declare const API_REGIONS: {
5
5
  };
6
6
  declare const URLS: {
7
7
  readonly http: "https://apix.{region}.amity.co";
8
- readonly upload: "https://apix.{region}.amity.co";
8
+ readonly upload: "https://upload.{region}.amity.co";
9
9
  readonly mqtt: "wss://sse.{region}.amity.co:443/mqtt";
10
10
  };
11
11
  export declare function computeUrl(type: keyof typeof URLS, region: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/client/utils/endpoints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX,QAAA,MAAM,IAAI;;;;CAKA,CAAC;AAEX,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,OAAO,IAAI,EAAE,MAAM,EAAE,MAAM,UAEjE"}
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/client/utils/endpoints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX,QAAA,MAAM,IAAI;;;;CAIA,CAAC;AAEX,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,OAAO,IAAI,EAAE,MAAM,EAAE,MAAM,UAEjE"}
package/dist/index.cjs.js CHANGED
@@ -399,7 +399,13 @@ const normalize = (source) => Object.keys(source)
399
399
  * @category Cache
400
400
  * @hidden
401
401
  */
402
- const encodeKey = (key) => JSON.stringify(key, (_, val) => (typeof val === 'object' ? normalize(val) : val));
402
+ const encodeKey = (key) => JSON.stringify(key, (_, val) =>
403
+ // `typeof null` is `'object'`, so a nullish segment would reach normalize()
404
+ // and throw on Object.keys(null) — taking down whichever cache read built
405
+ // the key. Amity.Serializable does not admit null in the first place, so a
406
+ // null here is a payload that broke its own contract: encode it as null and
407
+ // let the miss be a miss.
408
+ val !== null && typeof val === 'object' ? normalize(val) : val);
403
409
  /**
404
410
  * Decodes a string back into a {@link Amity.CacheKey}
405
411
 
@@ -1966,8 +1972,7 @@ const API_REGIONS = {
1966
1972
  };
1967
1973
  const URLS = {
1968
1974
  http: 'https://apix.{region}.amity.co',
1969
- // upload: 'https://upload.{region}.amity.co',
1970
- upload: 'https://apix.{region}.amity.co',
1975
+ upload: 'https://upload.{region}.amity.co',
1971
1976
  mqtt: 'wss://sse.{region}.amity.co:443/mqtt',
1972
1977
  };
1973
1978
  function computeUrl(type, region) {
@@ -16669,6 +16674,39 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
16669
16674
  return !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName));
16670
16675
  };
16671
16676
 
16677
+ /**
16678
+ * Resolves the id of the parent post that a child-post payload belongs to.
16679
+ *
16680
+ * `parentId` and `parentPostId` name the same post, but a payload does not
16681
+ * always carry both — and the delete/create child handlers decide *whether* a
16682
+ * post is a child from `parentId` while reading the cache with `parentPostId`.
16683
+ * When only the former is set that read builds `['post', 'get', undefined]`,
16684
+ * which cannot match anything and, when the value is null, breaks key encoding
16685
+ * outright. Reading whichever id is present keeps the decision and the lookup
16686
+ * on the same post.
16687
+ *
16688
+ * @param post the child post payload
16689
+ * @returns the parent post id, or undefined when the payload carries neither
16690
+ *
16691
+ * @category Post Events
16692
+ * @hidden
16693
+ */
16694
+ const resolveParentPostId = (post) => {
16695
+ if (post.parentPostId)
16696
+ return post.parentPostId;
16697
+ if (post.parentId) {
16698
+ // Diagnostic: we do not know yet whether the server actually emits this
16699
+ // shape. If this warning is never seen in practice the fallback can go.
16700
+ console.warn('[AmitySDK] post payload carries `parentId` without `parentPostId` — falling back to `parentId`', {
16701
+ postId: post.postId,
16702
+ parentId: post.parentId,
16703
+ parentPostId: post.parentPostId,
16704
+ });
16705
+ return post.parentId;
16706
+ }
16707
+ return undefined;
16708
+ };
16709
+
16672
16710
  const processDeleteChildPost = (payload) => {
16673
16711
  var _a;
16674
16712
  const post = payload.posts[0];
@@ -16680,7 +16718,10 @@ const processDeleteChildPost = (payload) => {
16680
16718
  }
16681
16719
  else {
16682
16720
  // child post in a parent post
16683
- const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16721
+ const parentPostId = resolveParentPostId(post);
16722
+ if (!parentPostId)
16723
+ return;
16724
+ const parentPost = (_a = pullFromCache(['post', 'get', parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16684
16725
  if (!parentPost)
16685
16726
  return;
16686
16727
  pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
@@ -16691,7 +16732,10 @@ const processCreateChildPost = (payload) => {
16691
16732
  const post = payload.posts[0];
16692
16733
  if (!post.parentId)
16693
16734
  return;
16694
- const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16735
+ const parentPostId = resolveParentPostId(post);
16736
+ if (!parentPostId)
16737
+ return;
16738
+ const parentPost = (_a = pullFromCache(['post', 'get', parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16695
16739
  if (!parentPost)
16696
16740
  return;
16697
16741
  pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));
package/dist/index.esm.js CHANGED
@@ -364,7 +364,13 @@ const normalize = (source) => Object.keys(source)
364
364
  * @category Cache
365
365
  * @hidden
366
366
  */
367
- const encodeKey = (key) => JSON.stringify(key, (_, val) => (typeof val === 'object' ? normalize(val) : val));
367
+ const encodeKey = (key) => JSON.stringify(key, (_, val) =>
368
+ // `typeof null` is `'object'`, so a nullish segment would reach normalize()
369
+ // and throw on Object.keys(null) — taking down whichever cache read built
370
+ // the key. Amity.Serializable does not admit null in the first place, so a
371
+ // null here is a payload that broke its own contract: encode it as null and
372
+ // let the miss be a miss.
373
+ val !== null && typeof val === 'object' ? normalize(val) : val);
368
374
  /**
369
375
  * Decodes a string back into a {@link Amity.CacheKey}
370
376
 
@@ -1931,8 +1937,7 @@ const API_REGIONS = {
1931
1937
  };
1932
1938
  const URLS = {
1933
1939
  http: 'https://apix.{region}.amity.co',
1934
- // upload: 'https://upload.{region}.amity.co',
1935
- upload: 'https://apix.{region}.amity.co',
1940
+ upload: 'https://upload.{region}.amity.co',
1936
1941
  mqtt: 'wss://sse.{region}.amity.co:443/mqtt',
1937
1942
  };
1938
1943
  function computeUrl(type, region) {
@@ -16650,6 +16655,39 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
16650
16655
  return !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName));
16651
16656
  };
16652
16657
 
16658
+ /**
16659
+ * Resolves the id of the parent post that a child-post payload belongs to.
16660
+ *
16661
+ * `parentId` and `parentPostId` name the same post, but a payload does not
16662
+ * always carry both — and the delete/create child handlers decide *whether* a
16663
+ * post is a child from `parentId` while reading the cache with `parentPostId`.
16664
+ * When only the former is set that read builds `['post', 'get', undefined]`,
16665
+ * which cannot match anything and, when the value is null, breaks key encoding
16666
+ * outright. Reading whichever id is present keeps the decision and the lookup
16667
+ * on the same post.
16668
+ *
16669
+ * @param post the child post payload
16670
+ * @returns the parent post id, or undefined when the payload carries neither
16671
+ *
16672
+ * @category Post Events
16673
+ * @hidden
16674
+ */
16675
+ const resolveParentPostId = (post) => {
16676
+ if (post.parentPostId)
16677
+ return post.parentPostId;
16678
+ if (post.parentId) {
16679
+ // Diagnostic: we do not know yet whether the server actually emits this
16680
+ // shape. If this warning is never seen in practice the fallback can go.
16681
+ console.warn('[AmitySDK] post payload carries `parentId` without `parentPostId` — falling back to `parentId`', {
16682
+ postId: post.postId,
16683
+ parentId: post.parentId,
16684
+ parentPostId: post.parentPostId,
16685
+ });
16686
+ return post.parentId;
16687
+ }
16688
+ return undefined;
16689
+ };
16690
+
16653
16691
  const processDeleteChildPost = (payload) => {
16654
16692
  var _a;
16655
16693
  const post = payload.posts[0];
@@ -16661,7 +16699,10 @@ const processDeleteChildPost = (payload) => {
16661
16699
  }
16662
16700
  else {
16663
16701
  // child post in a parent post
16664
- const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16702
+ const parentPostId = resolveParentPostId(post);
16703
+ if (!parentPostId)
16704
+ return;
16705
+ const parentPost = (_a = pullFromCache(['post', 'get', parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16665
16706
  if (!parentPost)
16666
16707
  return;
16667
16708
  pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
@@ -16672,7 +16713,10 @@ const processCreateChildPost = (payload) => {
16672
16713
  const post = payload.posts[0];
16673
16714
  if (!post.parentId)
16674
16715
  return;
16675
- const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16716
+ const parentPostId = resolveParentPostId(post);
16717
+ if (!parentPostId)
16718
+ return;
16719
+ const parentPost = (_a = pullFromCache(['post', 'get', parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
16676
16720
  if (!parentPost)
16677
16721
  return;
16678
16722
  pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));