@amityco/ts-sdk 0.0.1-beta.32 → 0.0.1-beta.33

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 (50) hide show
  1. package/dist/cache/api/ingestInCache.d.ts +1 -1
  2. package/dist/cache/api/tests/ingestInCache.test.d.ts +2 -0
  3. package/dist/cache/api/tests/ingestInCache.test.d.ts.map +1 -0
  4. package/dist/core/model/idResolvers.d.ts.map +1 -1
  5. package/dist/index.cjs.js +26 -6
  6. package/dist/index.esm.js +26 -6
  7. package/dist/index.umd.js +1 -1
  8. package/dist/reaction/api/addReaction.d.ts.map +1 -1
  9. package/dist/reaction/api/removeReaction.d.ts.map +1 -1
  10. package/dist/utils/tests/dummy/channel.d.ts +6 -0
  11. package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
  12. package/dist/utils/tests/dummy/community.d.ts +4 -0
  13. package/dist/utils/tests/dummy/community.d.ts.map +1 -0
  14. package/dist/utils/tests/dummy/file.d.ts +2 -0
  15. package/dist/utils/tests/dummy/file.d.ts.map +1 -0
  16. package/dist/utils/tests/dummy/follow.d.ts +1 -0
  17. package/dist/utils/tests/dummy/follow.d.ts.map +1 -1
  18. package/dist/utils/tests/dummy/index.d.ts +5 -0
  19. package/dist/utils/tests/dummy/index.d.ts.map +1 -1
  20. package/dist/utils/tests/dummy/message.d.ts +5 -0
  21. package/dist/utils/tests/dummy/message.d.ts.map +1 -1
  22. package/dist/utils/tests/dummy/poll.d.ts +3 -0
  23. package/dist/utils/tests/dummy/poll.d.ts.map +1 -0
  24. package/dist/utils/tests/dummy/post.d.ts +3 -0
  25. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  26. package/dist/utils/tests/dummy/reaction.d.ts +4 -0
  27. package/dist/utils/tests/dummy/reaction.d.ts.map +1 -0
  28. package/dist/utils/tests/dummy/role.d.ts +4 -0
  29. package/dist/utils/tests/dummy/role.d.ts.map +1 -0
  30. package/dist/utils/tests/dummy/user.d.ts +1 -0
  31. package/dist/utils/tests/dummy/user.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/src/cache/api/ingestInCache.ts +2 -2
  34. package/src/cache/api/tests/ingestInCache.test.ts +87 -0
  35. package/src/core/model/idResolvers.ts +1 -1
  36. package/src/reaction/api/addReaction.ts +17 -3
  37. package/src/reaction/api/removeReaction.ts +17 -3
  38. package/src/reaction/api/tests/addReaction.test.ts +42 -6
  39. package/src/reaction/api/tests/removeReaction.test.ts +49 -13
  40. package/src/utils/tests/dummy/channel.ts +9 -1
  41. package/src/utils/tests/dummy/community.ts +44 -0
  42. package/src/utils/tests/dummy/file.ts +20 -0
  43. package/src/utils/tests/dummy/follow.ts +6 -0
  44. package/src/utils/tests/dummy/index.ts +9 -0
  45. package/src/utils/tests/dummy/message.ts +8 -1
  46. package/src/utils/tests/dummy/poll.ts +43 -0
  47. package/src/utils/tests/dummy/post.ts +39 -1
  48. package/src/utils/tests/dummy/reaction.ts +22 -0
  49. package/src/utils/tests/dummy/role.ts +21 -0
  50. package/src/utils/tests/dummy/user.ts +6 -0
@@ -1 +1 @@
1
- {"version":3,"file":"addReaction.d.ts","sourceRoot":"","sources":["../../../src/reaction/api/addReaction.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,WAAW;oBACP,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,QAAQ,OAAO,CAAC;IAiBnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,OAAO,GAAG,SAAS;CArBrB,CAAC"}
1
+ {"version":3,"file":"addReaction.d.ts","sourceRoot":"","sources":["../../../src/reaction/api/addReaction.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,WAAW;oBACP,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,QAAQ,OAAO,CAAC;IA4BnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,OAAO,GAAG,SAAS;CArBrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"removeReaction.d.ts","sourceRoot":"","sources":["../../../src/reaction/api/removeReaction.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,cAAc;oBACV,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,QAAQ,OAAO,CAAC;IAenB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,OAAO,GAAG,SAAS;CArBrB,CAAC"}
1
+ {"version":3,"file":"removeReaction.d.ts","sourceRoot":"","sources":["../../../src/reaction/api/removeReaction.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,cAAc;oBACV,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,QAAQ,OAAO,CAAC;IA0BnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,QAAQ,CAAC,cAAc,CAAC,GAC3C,OAAO,GAAG,SAAS;CArBrB,CAAC"}
@@ -71,4 +71,10 @@ export declare const channelUserQueryResponsePage3: {
71
71
  files: never[];
72
72
  };
73
73
  };
74
+ export declare const channelPayload: {
75
+ channels: Amity.Channel<any>[];
76
+ channelUsers: Amity.Membership<"channel">[];
77
+ users: Amity.User[];
78
+ files: Amity.File<"image">[];
79
+ };
74
80
  //# sourceMappingURL=channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/channel.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAO/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAO/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAK/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAK7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAI7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAO7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAKpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAapD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAGpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAGpD,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAQhC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;CAQrC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;CAQpC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAQzC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAQzC,CAAC"}
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/channel.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAO/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAO/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAK/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAK7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAI7B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAO7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAKpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAapD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAGpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAGpD,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAQhC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;CAQrC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;CAQpC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAQzC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAQzC,CAAC;AAGF,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const community11: Amity.Community;
2
+ export declare const communityUser11: Amity.Membership<'community'>;
3
+ export declare const communityPayload: Amity.CommunityPayload;
4
+ //# sourceMappingURL=community.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/community.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAoB/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAYzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,gBAKpC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const file11: Amity.File<'image'>;
2
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/file.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAmBtC,CAAC"}
@@ -9,4 +9,5 @@ export declare const follows: {
9
9
  page1: Amity.FollowStatus[];
10
10
  page2: Amity.FollowStatus[];
11
11
  };
12
+ export declare const followPayload: Amity.FollowersPayload;
12
13
  //# sourceMappingURL=follow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/follow.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAEF,eAAO,MAAM,OAAO;;;;CAInB,CAAC"}
1
+ {"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/follow.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,YAK5B,CAAC;AAEF,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,gBAIjC,CAAC"}
@@ -4,8 +4,13 @@ export declare const rolesAndPermissions: {
4
4
  permissions: never[];
5
5
  };
6
6
  export * from './user';
7
+ export * from './role';
8
+ export * from './file';
7
9
  export * from './post';
10
+ export * from './poll';
8
11
  export * from './follow';
12
+ export * from './reaction';
9
13
  export * from './channel';
14
+ export * from './community';
10
15
  export * from './message';
11
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,QAA2B,CAAC;AAC7C,eAAO,MAAM,mBAAmB;;;CAAiC,CAAC;AAElE,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,QAA2B,CAAC;AAC7C,eAAO,MAAM,mBAAmB;;;CAAiC,CAAC;AAElE,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAE5B,cAAc,WAAW,CAAC"}
@@ -16,4 +16,9 @@ export declare const messageQueryResponse: {
16
16
  };
17
17
  };
18
18
  };
19
+ export declare const messagePayload: {
20
+ messages: Amity.Message<any>[];
21
+ files: Amity.File<"image">[];
22
+ users: Amity.User[];
23
+ };
19
24
  //# sourceMappingURL=message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/message.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAa7B,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;CAUhC,CAAC"}
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/message.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAa7B,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;CAUhC,CAAC;AAGF,eAAO,MAAM,cAAc;;;;CAI1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const poll11: Amity.Poll;
2
+ export declare const pollPayload: Amity.PollPayload;
3
+ //# sourceMappingURL=poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/poll.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAmC1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,WAG/B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export declare const post11: Amity.Post;
2
+ export declare const comment11: Amity.Comment;
2
3
  export declare const post12: Amity.Post;
3
4
  export declare const post13: Amity.Post;
4
5
  export declare const posts: {
@@ -8,6 +9,8 @@ export declare const posts: {
8
9
  page2: string[];
9
10
  page3: string[];
10
11
  };
12
+ export declare const commentPayload: Amity.CommentPayload;
13
+ export declare const postPayload: Amity.PostPayload;
11
14
  export declare const postQueryResponse: {
12
15
  data: {
13
16
  posts: Amity.Post<any>[];
@@ -1 +1 @@
1
- {"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/post.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAoB1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;CAMjB,CAAC;AAIF,eAAO,MAAM,iBAAiB;;;;;;;;CAQ7B,CAAC"}
1
+ {"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/post.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAoB1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAuB7B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;CAMjB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,cAGlC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,WAM/B,CAAC;AAIF,eAAO,MAAM,iBAAiB;;;;;;;;CAQ7B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const reaction11: Amity.Reaction;
2
+ export declare const reactor11: Amity.Reactor;
3
+ export declare const reactionPayload: Amity.ReactionPayload;
4
+ //# sourceMappingURL=reaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/reaction.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,QAO9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAK7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,eAGnC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const role11: Amity.Role;
2
+ export declare const role12: Amity.Role;
3
+ export declare const rolePayload: Amity.RolePayload;
4
+ //# sourceMappingURL=role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/role.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAO1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAO1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,WAE/B,CAAC"}
@@ -12,4 +12,5 @@ export declare const userQueryResponse: {
12
12
  };
13
13
  };
14
14
  };
15
+ export declare const userPayload: Amity.UserPayload;
15
16
  //# sourceMappingURL=user.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/user.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAQ1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;CAS7B,CAAC"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/user.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAQ1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,IAG1B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;CAS7B,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,WAG/B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "0.0.1-beta.32",
3
+ "version": "0.0.1-beta.33",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -6,7 +6,7 @@ import { upsertInCache } from './upsertInCache';
6
6
  * Ingest a payload (v3) into the cache
7
7
  *
8
8
  * @param payload a "backend v3" payload object
9
- * @param order the order of the keys to process (in case of need)
9
+ * @param options caching options like cachedAt or offline
10
10
  *
11
11
  * @category Cache
12
12
  * @hidden
@@ -20,9 +20,9 @@ export const ingestInCache = (
20
20
  if (!type) return;
21
21
 
22
22
  const resolver = getResolver(type);
23
+
23
24
  models.forEach(model => {
24
25
  upsertInCache(
25
- // eslint-disable @typescript-eslint no-explicit-any
26
26
  [type, 'get', resolver(model as any)], // this 'any' cannot be avoided, sorry.
27
27
  model,
28
28
  options,
@@ -0,0 +1,87 @@
1
+ import { PAYLOAD2MODEL, getResolver } from '~/core/model';
2
+
3
+ import {
4
+ userPayload,
5
+ rolePayload,
6
+ channelPayload,
7
+ messagePayload,
8
+ communityPayload,
9
+ postPayload,
10
+ commentPayload,
11
+ pollPayload,
12
+ reactionPayload,
13
+ followPayload,
14
+ user11,
15
+ } from '~/utils/tests';
16
+
17
+ import { enableCache, disableCache, pullFromCache } from '..';
18
+ import { ingestInCache } from '../ingestInCache';
19
+
20
+ describe('ingestInCache', () => {
21
+ beforeAll(enableCache);
22
+ afterAll(disableCache);
23
+
24
+ const payloads: [keyof Amity.Model, Record<string, Record<string, unknown>[]>][] = [
25
+ ['user', userPayload],
26
+ ['role', rolePayload],
27
+ ['channel', channelPayload],
28
+ ['message', messagePayload],
29
+ ['community', communityPayload],
30
+ ['post', postPayload],
31
+ ['comment', commentPayload],
32
+ ['poll', pollPayload],
33
+ ['reaction', reactionPayload],
34
+ ['follow', followPayload],
35
+ ];
36
+
37
+ test.each(payloads)('it should add %s payload to cache', (model, payload) => {
38
+ ingestInCache(payload);
39
+
40
+ Object.entries(payload).forEach(([k, v]) => {
41
+ const type = PAYLOAD2MODEL[k];
42
+ const resolver = getResolver(type);
43
+
44
+ expect(type).toBeDefined();
45
+
46
+ v.forEach(entity =>
47
+ expect(pullFromCache([type, 'get', resolver(entity as any)])).toBeDefined(),
48
+ );
49
+ });
50
+ });
51
+
52
+ test('it should not update cache if model invalid', () => {
53
+ const invalidPayload = {
54
+ invalids: [{ invalidId: 'invalidId' }],
55
+ users: [user11],
56
+ };
57
+
58
+ ingestInCache(invalidPayload);
59
+
60
+ expect(pullFromCache(['invalid', 'get', 'invalidId'])).toBeUndefined();
61
+ expect(pullFromCache(['user', 'get', user11.userId])).toBeDefined();
62
+ });
63
+ });
64
+
65
+ describe('ingestInCache -> cachedAt', () => {
66
+ beforeAll(enableCache);
67
+ afterAll(disableCache);
68
+
69
+ test('it should update cache if cachedAt is valid', () => {
70
+ const now = Date.now();
71
+ ingestInCache(userPayload, { cachedAt: now });
72
+
73
+ const { data, cachedAt } = pullFromCache(['user', 'get', user11.userId])!;
74
+
75
+ expect(data).toBeDefined();
76
+ expect(cachedAt).toBe(now);
77
+ });
78
+
79
+ test('it should update cache if cachedAt is expired', () => {
80
+ ingestInCache(userPayload, { cachedAt: -1 });
81
+
82
+ const { data, cachedAt } = pullFromCache(['user', 'get', user11.userId])!;
83
+
84
+ expect(data).toBeDefined();
85
+ expect(cachedAt).toBe(-1);
86
+ });
87
+ });
@@ -38,4 +38,4 @@ const idResolvers: Resolvers = {
38
38
  * @param name the domain name for the resolve
39
39
  * @returns an idResolver function for the given domain name
40
40
  */
41
- export const getResolver = <T extends Amity.Domain>(name: T) => idResolvers[name];
41
+ export const getResolver = <T extends Amity.Domain>(name: T): Resolvers[T] => idResolvers[name];
@@ -1,8 +1,9 @@
1
1
  import { getActiveClient } from '~/client/api';
2
2
 
3
- import { upsertInCache, pullFromCache } from '~/cache/api';
3
+ import { upsertInCache, pullFromCache, pushToCache } from '~/cache/api';
4
4
 
5
- import { dispatchReactable, fetchReference } from '../utils';
5
+ import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
6
+ import { dispatchReactable } from '../utils';
6
7
 
7
8
  /**
8
9
  * ```js
@@ -38,6 +39,17 @@ export const addReaction = async (
38
39
  reactionName,
39
40
  });
40
41
 
42
+ if (client.cache) {
43
+ const model = pullFromCache<Amity.Model[Amity.ReactableType]>([
44
+ referenceType,
45
+ 'get',
46
+ referenceId,
47
+ ]);
48
+
49
+ model?.data &&
50
+ pushToCache([referenceType, 'get', referenceId], model.data, { cachedAt: Date.now() });
51
+ }
52
+
41
53
  return true;
42
54
  };
43
55
 
@@ -88,7 +100,9 @@ addReaction.optimistically = (
88
100
  },
89
101
  } as Amity.Model[Amity.ReactableType];
90
102
 
91
- upsertInCache([referenceType, 'get', referenceId], reaction, { cachedAt: -1 });
103
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
104
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
105
+ });
92
106
 
93
107
  dispatchReactable(referenceType, reaction);
94
108
 
@@ -1,8 +1,9 @@
1
1
  import { getActiveClient } from '~/client/api';
2
2
 
3
- import { upsertInCache, pullFromCache } from '~/cache/api';
3
+ import { upsertInCache, pullFromCache, pushToCache } from '~/cache/api';
4
4
 
5
- import { dispatchReactable, fetchReference } from '../utils';
5
+ import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
6
+ import { dispatchReactable } from '../utils';
6
7
 
7
8
  /**
8
9
  * ```js
@@ -36,6 +37,17 @@ export const removeReaction = async (
36
37
  data: { referenceId, referenceType, reactionName },
37
38
  });
38
39
 
40
+ if (client.cache) {
41
+ const model = pullFromCache<Amity.Model[Amity.ReactableType]>([
42
+ referenceType,
43
+ 'get',
44
+ referenceId,
45
+ ]);
46
+
47
+ model?.data &&
48
+ pushToCache([referenceType, 'get', referenceId], model.data, { cachedAt: Date.now() });
49
+ }
50
+
39
51
  return true;
40
52
  };
41
53
 
@@ -86,7 +98,9 @@ removeReaction.optimistically = (
86
98
  },
87
99
  } as Amity.Model[Amity.ReactableType];
88
100
 
89
- upsertInCache([referenceType, 'get', referenceId], reaction, { cachedAt: -1 });
101
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
102
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
103
+ });
90
104
 
91
105
  dispatchReactable(referenceType, reaction);
92
106
 
@@ -1,21 +1,56 @@
1
1
  import { disableCache, enableCache, pullFromCache, pushToCache } from '~/cache/api';
2
+
2
3
  import { onMessageUpdated } from '~/message/events';
3
4
  import { addReaction } from '~/reaction/api';
5
+
4
6
  import { client, message11 as message, pause } from '~/utils/tests';
7
+ import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
8
+
9
+ const cacheKey = ['message', 'get', message.messageId];
5
10
 
6
11
  describe('addReaction', () => {
7
- const cacheKey = ['message', 'get', message.messageId];
12
+ test('it should add a reaction', async () => {
13
+ client.http.post = jest.fn().mockResolvedValue({ data: { addedId: 'reactionId' } });
14
+
15
+ const success = await addReaction('message', message.messageId, 'like');
16
+
17
+ expect(success).toEqual(true);
18
+ });
19
+
20
+ test('it should update cache after adding reaction', async () => {
21
+ enableCache();
22
+
23
+ pushToCache(cacheKey, message);
24
+ client.http.post = jest.fn().mockResolvedValue({ data: { addedId: 'reactionId' } });
8
25
 
26
+ const success = await addReaction('message', message.messageId, 'like');
27
+
28
+ expect(success).toEqual(true);
29
+ expect(pullFromCache(cacheKey)?.cachedAt).toBeDefined();
30
+ expect(pullFromCache(cacheKey)?.cachedAt).not.toBe(UNSYNCED_OBJECT_CACHED_AT_VALUE);
31
+ expect(pullFromCache(cacheKey)?.cachedAt).not.toBe(-1);
32
+
33
+ disableCache();
34
+ });
35
+ });
36
+
37
+ describe('addReaction > optimistically', () => {
9
38
  beforeEach(enableCache);
10
39
 
11
40
  afterEach(disableCache);
12
41
 
13
- test('should optimistically add a reaction', async () => {
42
+ test('it should return undefined if cache disabled', () => {
43
+ disableCache();
44
+
45
+ expect(addReaction.optimistically('message', message.messageId, 'like')).toBeUndefined();
46
+ });
47
+
48
+ test('it should optimistically add a reaction', async () => {
14
49
  const callback = jest.fn();
15
50
  pushToCache(cacheKey, message);
16
51
  onMessageUpdated(callback);
17
52
 
18
- const success = await addReaction.optimistically('message', message.messageId, 'like');
53
+ const success = addReaction.optimistically('message', message.messageId, 'like');
19
54
 
20
55
  expect(success).toEqual(true);
21
56
  expect(pullFromCache(cacheKey)?.data).toMatchObject({
@@ -27,11 +62,12 @@ describe('addReaction', () => {
27
62
  expect(callback).toBeCalledTimes(1);
28
63
  });
29
64
 
30
- test('should add a reaction', async () => {
31
- client.http.post = jest.fn().mockResolvedValue({ data: { addedId: 'reactionId' } });
65
+ test('it should mark optimistic object as unsynced', async () => {
66
+ pushToCache(cacheKey, message);
32
67
 
33
- const success = await addReaction('message', message.messageId, 'like');
68
+ const success = addReaction.optimistically('message', message.messageId, 'like');
34
69
 
35
70
  expect(success).toEqual(true);
71
+ expect(pullFromCache(cacheKey)?.cachedAt).toBe(UNSYNCED_OBJECT_CACHED_AT_VALUE);
36
72
  });
37
73
  });
@@ -1,27 +1,62 @@
1
1
  import { disableCache, enableCache, pullFromCache, pushToCache } from '~/cache/api';
2
+
2
3
  import { onMessageUpdated } from '~/message/events';
3
4
  import { removeReaction } from '~/reaction/api';
4
- import { client, message11 as message, message11, pause } from '~/utils/tests';
5
+
6
+ import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
7
+ import { client, message11, pause } from '~/utils/tests';
8
+
9
+ const message = {
10
+ ...message11,
11
+ myReactions: ['like'],
12
+ reactions: { like: 1 },
13
+ reactionsCount: 1,
14
+ };
15
+ const cacheKey = ['message', 'get', message.messageId];
5
16
 
6
17
  describe('removeReaction', () => {
7
- const message = {
8
- ...message11,
9
- myReactions: ['like'],
10
- reactions: { like: 1 },
11
- reactionsCount: 1,
12
- };
13
- const cacheKey = ['message', 'get', message.messageId];
18
+ test('it should remove a reaction', async () => {
19
+ client.http.delete = jest.fn().mockResolvedValue({ data: { removedId: 'reactionId' } });
14
20
 
21
+ const success = await removeReaction('message', message.messageId, 'like');
22
+
23
+ expect(success).toEqual(true);
24
+ });
25
+
26
+ test('it should update cache after adding reaction', async () => {
27
+ enableCache();
28
+
29
+ pushToCache(cacheKey, message);
30
+ client.http.post = jest.fn().mockResolvedValue({ data: { addedId: 'reactionId' } });
31
+
32
+ const success = await removeReaction('message', message.messageId, 'like');
33
+
34
+ expect(success).toEqual(true);
35
+ expect(pullFromCache(cacheKey)?.cachedAt).toBeDefined();
36
+ expect(pullFromCache(cacheKey)?.cachedAt).not.toBe(UNSYNCED_OBJECT_CACHED_AT_VALUE);
37
+ expect(pullFromCache(cacheKey)?.cachedAt).not.toBe(-1);
38
+
39
+ disableCache();
40
+ });
41
+ });
42
+
43
+ describe('removeReaction > optimistically', () => {
15
44
  beforeEach(enableCache);
16
45
 
17
46
  afterEach(disableCache);
18
47
 
19
- test('should optimistically add a reaction', async () => {
48
+ test('it should return undefined if cache disabled', () => {
49
+ disableCache();
50
+
51
+ expect(removeReaction.optimistically('message', message.messageId, 'like')).toBeUndefined();
52
+ });
53
+
54
+ test('it should optimistically remove a reaction', async () => {
20
55
  const callback = jest.fn();
21
56
  pushToCache(cacheKey, message);
22
57
  onMessageUpdated(callback);
23
58
 
24
- const success = await removeReaction.optimistically('message', message.messageId, 'like');
59
+ const success = removeReaction.optimistically('message', message.messageId, 'like');
25
60
 
26
61
  expect(success).toEqual(true);
27
62
  expect(pullFromCache(cacheKey)?.data).toMatchObject({
@@ -33,11 +68,12 @@ describe('removeReaction', () => {
33
68
  expect(callback).toBeCalledTimes(1);
34
69
  });
35
70
 
36
- test('should add a reaction', async () => {
37
- client.http.delete = jest.fn().mockResolvedValue({ data: { removedId: 'reactionId' } });
71
+ test('it should mark optimistic object as unsynced', async () => {
72
+ pushToCache(cacheKey, message);
38
73
 
39
- const success = await removeReaction('message', message.messageId, 'like');
74
+ const success = removeReaction.optimistically('message', message.messageId, 'like');
40
75
 
41
76
  expect(success).toEqual(true);
77
+ expect(pullFromCache(cacheKey)?.cachedAt).toBe(UNSYNCED_OBJECT_CACHED_AT_VALUE);
42
78
  });
43
79
  });
@@ -1,4 +1,4 @@
1
- import { date, rolesAndPermissions, user11, user12, user13 } from '.';
1
+ import { date, rolesAndPermissions, user11, user12, user13, file11 } from '.';
2
2
 
3
3
  const mockPage = {
4
4
  paging: {
@@ -177,3 +177,11 @@ export const channelUserQueryResponsePage3 = {
177
177
  ...mockPage,
178
178
  },
179
179
  };
180
+
181
+ // for testing ingest in cache
182
+ export const channelPayload = {
183
+ channels: [channel11],
184
+ channelUsers: [channelUser7, channelUser6],
185
+ users: [user11],
186
+ files: [file11],
187
+ };
@@ -0,0 +1,44 @@
1
+ import { file11, user11 } from '.';
2
+
3
+ export const community11: Amity.Community = {
4
+ path: '',
5
+ isOfficial: false,
6
+ isPublic: true,
7
+ postsCount: 7,
8
+ membersCount: 1,
9
+ updatedAt: '2022-10-31T05:06:57.999Z',
10
+ createdAt: '2022-10-31T02:48:34.978Z',
11
+ isDeleted: false,
12
+ displayName: 'HardDelete1',
13
+ tags: [],
14
+ metadata: {},
15
+ hasFlaggedComment: false,
16
+ hasFlaggedPost: true,
17
+ communityId: 'community11',
18
+ channelId: '635f3782064bf304f786707d',
19
+ userId: user11.userId,
20
+ isJoined: false,
21
+ avatarFileId: undefined,
22
+ categoryIds: [],
23
+ };
24
+
25
+ export const communityUser11: Amity.Membership<'community'> = {
26
+ communityMembership: 'member',
27
+ lastActivity: '2022-10-25T11:10:13.048Z',
28
+ updatedAt: '2022-10-25T11:10:13.048Z',
29
+ createdAt: '2022-10-25T11:10:13.048Z',
30
+ muteTimeout: '2022-10-25T11:10:13.048Z',
31
+ isMuted: false,
32
+ isBanned: false,
33
+ userId: 'test',
34
+ communityId: community11.communityId,
35
+ roles: ['channel-moderator', 'community-moderator'],
36
+ permissions: [Amity.Permission.CreateRolePermission],
37
+ };
38
+
39
+ export const communityPayload: Amity.CommunityPayload = {
40
+ communities: [community11],
41
+ communityUsers: [communityUser11],
42
+ files: [file11],
43
+ users: [user11],
44
+ };
@@ -0,0 +1,20 @@
1
+ export const file11: Amity.File<'image'> = {
2
+ fileId: 'file-Id',
3
+ fileUrl: 'https://fileUrl.com/test-file',
4
+ type: 'image',
5
+ createdAt: '2022-10-28T08:01:51.996Z',
6
+ updatedAt: '2022-10-28T08:01:51.996Z',
7
+ attributes: {
8
+ name: 'test.png',
9
+ extension: 'png',
10
+ size: '166904',
11
+ mimeType: 'image/png',
12
+ metadata: {
13
+ height: 966,
14
+ width: 1918,
15
+ isFull: false,
16
+ exif: {},
17
+ gps: {},
18
+ },
19
+ },
20
+ };
@@ -58,3 +58,9 @@ export const follows = {
58
58
  page1: [follow11, follow12, follow13],
59
59
  page2: [follow21, follow22, follow23],
60
60
  };
61
+
62
+ export const followPayload: Amity.FollowersPayload = {
63
+ users: [user11, user12],
64
+ files: [],
65
+ follows: [follow11, follow12],
66
+ };
@@ -2,7 +2,16 @@ export const date = new Date().toISOString();
2
2
  export const rolesAndPermissions = { roles: [], permissions: [] };
3
3
 
4
4
  export * from './user';
5
+ export * from './role';
6
+ export * from './file';
7
+
5
8
  export * from './post';
9
+
10
+ export * from './poll';
6
11
  export * from './follow';
12
+ export * from './reaction';
13
+
7
14
  export * from './channel';
15
+ export * from './community';
16
+
8
17
  export * from './message';