@amityco/ts-sdk 7.0.2-46b4d65.0 → 7.0.3-03c332e.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":"addReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/addReaction.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,WAAW;oBACP,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,QAAQ,OAAO,CAAC;IA4EnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,OAAO,GAAG,SAAS;CAtBrB,CAAC"}
1
+ {"version":3,"file":"addReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/addReaction.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,WAAW;oBACP,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,QAAQ,OAAO,CAAC;IAmFnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,OAAO,GAAG,SAAS;CAtBrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"removeReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/removeReaction.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,cAAc;oBACV,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,QAAQ,OAAO,CAAC;IA+EnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,OAAO,GAAG,SAAS;CAtBrB,CAAC"}
1
+ {"version":3,"file":"removeReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/removeReaction.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,cAAc;oBACV,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,QAAQ,OAAO,CAAC;IAsFnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,eAAe,CAAC,cAAc,CAAC,GAClD,OAAO,GAAG,SAAS;CAtBrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReactionPaginationController.d.ts","sourceRoot":"","sources":["../../../../src/reactionRepository/observers/getReactions/ReactionPaginationController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAIlF,qBAAa,4BAA6B,SAAQ,oBAAoB,CACpE,UAAU,EACV,KAAK,CAAC,sBAAsB,CAC7B;IACO,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;CAoBtF"}
1
+ {"version":3,"file":"ReactionPaginationController.d.ts","sourceRoot":"","sources":["../../../../src/reactionRepository/observers/getReactions/ReactionPaginationController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAKlF,qBAAa,4BAA6B,SAAQ,oBAAoB,CACpE,UAAU,EACV,KAAK,CAAC,sBAAsB,CAC7B;IACO,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;CA2BtF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.0.2-46b4d65.0",
3
+ "version": "7.0.3-03c332e.0",
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",
@@ -31,12 +31,15 @@ export class AnalyticsEventCapturer {
31
31
  }) {
32
32
  const now = new Date();
33
33
 
34
- const getRecentViewedDate = () => {
35
- if (isHighPriority) return this._recentHighPriorityViewed[uniqueId];
36
- return this._recentViewed[uniqueId];
37
- };
38
-
39
- const recentViewedDate = getRecentViewedDate() || new Date(DAY * -1);
34
+ // Get the recent view date (if any)
35
+ const recentViewedDate = isHighPriority
36
+ ? this._recentHighPriorityViewed[uniqueId]
37
+ : this._recentViewed[uniqueId];
38
+
39
+ // If this is the first view, always allow it
40
+ if (!recentViewedDate) {
41
+ return true;
42
+ }
40
43
 
41
44
  const timeDiff = now.getTime() - recentViewedDate.getTime();
42
45
 
@@ -5,6 +5,7 @@ import { upsertInCache, pullFromCache, pushToCache } from '~/cache/api';
5
5
  import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
6
6
  import { dispatchReactable } from '../utils';
7
7
  import { fireEvent } from '~/core/events';
8
+ import { ASCApiError } from '~/core/errors';
8
9
 
9
10
  /* begin_public_function
10
11
  id: reaction.add
@@ -37,6 +38,13 @@ export const addReaction = async (
37
38
  reactionName,
38
39
  });
39
40
 
41
+ if (!['post', 'comment', 'story', 'message'].includes(referenceType))
42
+ throw new ASCApiError(
43
+ 'The reference type is not valid. It should be one of post, comment, story, or message',
44
+ Amity.ServerError.BAD_REQUEST,
45
+ Amity.ErrorLevel.ERROR,
46
+ );
47
+
40
48
  const { data } = await client.http.post<{ addedId: 'string' }>('/api/v2/reactions', {
41
49
  referenceId,
42
50
  referenceType,
@@ -6,6 +6,7 @@ import { UNSYNCED_OBJECT_CACHED_AT_VALUE } from '~/utils/constants';
6
6
 
7
7
  import { dispatchReactable } from '../utils';
8
8
  import { fireEvent } from '~/core/events';
9
+ import { ASCApiError } from '~/core/errors';
9
10
 
10
11
  /* begin_public_function
11
12
  id: reaction.remove
@@ -38,6 +39,13 @@ export const removeReaction = async (
38
39
  reactionName,
39
40
  });
40
41
 
42
+ if (!['post', 'comment', 'story', 'message'].includes(referenceType))
43
+ throw new ASCApiError(
44
+ 'The reference type is not valid. It should be one of post, comment, story, or message',
45
+ Amity.ServerError.BAD_REQUEST,
46
+ Amity.ErrorLevel.ERROR,
47
+ );
48
+
41
49
  const { data } = await client.http.delete<{ removedId: string }>(`/api/v2/reactions`, {
42
50
  data: {
43
51
  referenceId,
@@ -2,6 +2,7 @@ import { getActiveClient } from '~/client';
2
2
  import { PaginationController } from '~/core/liveCollection/PaginationController';
3
3
  import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
4
4
  import { REFERENCE_API_V5 } from '~/reactionRepository/api/constants';
5
+ import { ASCApiError } from '~/core/errors';
5
6
 
6
7
  export class ReactionPaginationController extends PaginationController<
7
8
  'reaction',
@@ -15,6 +16,13 @@ export class ReactionPaginationController extends PaginationController<
15
16
 
16
17
  const path = '/api/v3/reactions';
17
18
 
19
+ if (!['post', 'comment', 'story', 'message'].includes(params.referenceType))
20
+ throw new ASCApiError(
21
+ 'The reference type is not valid. It should be one of post, comment, story, or message',
22
+ Amity.ServerError.BAD_REQUEST,
23
+ Amity.ErrorLevel.ERROR,
24
+ );
25
+
18
26
  const { data: queryResponse } = await this.http.get<Amity.ReactionPayload & Amity.Pagination>(
19
27
  path,
20
28
  {