@amityco/ts-sdk-react-native 7.26.1-6101ded.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.
- package/dist/cache/utils/index.d.ts.map +1 -1
- package/dist/index.cjs.js +48 -3
- package/dist/index.esm.js +48 -3
- package/dist/index.umd.js +1 -1
- package/dist/postRepository/events/parentPost.d.ts +32 -0
- package/dist/postRepository/events/parentPost.d.ts.map +1 -0
- package/dist/postRepository/events/tests/parentPost.test.d.ts +2 -0
- package/dist/postRepository/events/tests/parentPost.test.d.ts.map +1 -0
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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"}
|
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) =>
|
|
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
|
|
|
@@ -16668,6 +16674,39 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
16668
16674
|
return !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName));
|
|
16669
16675
|
};
|
|
16670
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
|
+
|
|
16671
16710
|
const processDeleteChildPost = (payload) => {
|
|
16672
16711
|
var _a;
|
|
16673
16712
|
const post = payload.posts[0];
|
|
@@ -16679,7 +16718,10 @@ const processDeleteChildPost = (payload) => {
|
|
|
16679
16718
|
}
|
|
16680
16719
|
else {
|
|
16681
16720
|
// child post in a parent post
|
|
16682
|
-
const
|
|
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;
|
|
16683
16725
|
if (!parentPost)
|
|
16684
16726
|
return;
|
|
16685
16727
|
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
|
|
@@ -16690,7 +16732,10 @@ const processCreateChildPost = (payload) => {
|
|
|
16690
16732
|
const post = payload.posts[0];
|
|
16691
16733
|
if (!post.parentId)
|
|
16692
16734
|
return;
|
|
16693
|
-
const
|
|
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;
|
|
16694
16739
|
if (!parentPost)
|
|
16695
16740
|
return;
|
|
16696
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) =>
|
|
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
|
|
|
@@ -16649,6 +16655,39 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
16649
16655
|
return !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName));
|
|
16650
16656
|
};
|
|
16651
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
|
+
|
|
16652
16691
|
const processDeleteChildPost = (payload) => {
|
|
16653
16692
|
var _a;
|
|
16654
16693
|
const post = payload.posts[0];
|
|
@@ -16660,7 +16699,10 @@ const processDeleteChildPost = (payload) => {
|
|
|
16660
16699
|
}
|
|
16661
16700
|
else {
|
|
16662
16701
|
// child post in a parent post
|
|
16663
|
-
const
|
|
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;
|
|
16664
16706
|
if (!parentPost)
|
|
16665
16707
|
return;
|
|
16666
16708
|
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
|
|
@@ -16671,7 +16713,10 @@ const processCreateChildPost = (payload) => {
|
|
|
16671
16713
|
const post = payload.posts[0];
|
|
16672
16714
|
if (!post.parentId)
|
|
16673
16715
|
return;
|
|
16674
|
-
const
|
|
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;
|
|
16675
16720
|
if (!parentPost)
|
|
16676
16721
|
return;
|
|
16677
16722
|
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));
|