@amityco/ts-sdk-react-native 7.2.0 → 7.3.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.
Files changed (79) hide show
  1. package/dist/@types/core/events.d.ts +4 -0
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +4 -0
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +24 -0
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/ad.d.ts +1 -1
  8. package/dist/@types/domains/ad.d.ts.map +1 -1
  9. package/dist/@types/domains/notification.d.ts +78 -0
  10. package/dist/@types/domains/notification.d.ts.map +1 -0
  11. package/dist/@types/index.d.ts +1 -0
  12. package/dist/@types/index.d.ts.map +1 -1
  13. package/dist/core/events.d.ts +3 -3
  14. package/dist/core/events.d.ts.map +1 -1
  15. package/dist/core/model/idResolvers.d.ts.map +1 -1
  16. package/dist/core/model/index.d.ts.map +1 -1
  17. package/dist/index.cjs.js +433 -46
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.esm.js +416 -30
  21. package/dist/index.umd.js +3 -3
  22. package/dist/notificationTray/api/index.d.ts +3 -0
  23. package/dist/notificationTray/api/index.d.ts.map +1 -0
  24. package/dist/notificationTray/api/markItemsSeen.d.ts +16 -0
  25. package/dist/notificationTray/api/markItemsSeen.d.ts.map +1 -0
  26. package/dist/notificationTray/api/markTraySeen.d.ts +19 -0
  27. package/dist/notificationTray/api/markTraySeen.d.ts.map +1 -0
  28. package/dist/notificationTray/events/index.d.ts +2 -0
  29. package/dist/notificationTray/events/index.d.ts.map +1 -0
  30. package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts +17 -0
  31. package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
  32. package/dist/notificationTray/index.d.ts +4 -0
  33. package/dist/notificationTray/index.d.ts.map +1 -0
  34. package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts +30 -0
  35. package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts.map +1 -0
  36. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
  37. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
  38. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
  39. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
  40. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
  41. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
  42. package/dist/notificationTray/observers/getNotificationTrayItems.d.ts +12 -0
  43. package/dist/notificationTray/observers/getNotificationTrayItems.d.ts.map +1 -0
  44. package/dist/notificationTray/observers/getNotificationTraySeen.d.ts +20 -0
  45. package/dist/notificationTray/observers/getNotificationTraySeen.d.ts.map +1 -0
  46. package/dist/notificationTray/observers/index.d.ts +3 -0
  47. package/dist/notificationTray/observers/index.d.ts.map +1 -0
  48. package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
  49. package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts.map +1 -0
  50. package/dist/utils/linkedObject/index.d.ts +1 -0
  51. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  52. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +2 -0
  53. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -0
  54. package/package.json +1 -1
  55. package/src/@types/core/events.ts +5 -0
  56. package/src/@types/core/model.ts +6 -0
  57. package/src/@types/core/payload.ts +29 -0
  58. package/src/@types/domains/ad.ts +1 -1
  59. package/src/@types/domains/notification.ts +94 -0
  60. package/src/@types/index.ts +1 -0
  61. package/src/core/model/idResolvers.ts +3 -0
  62. package/src/core/model/index.ts +2 -0
  63. package/src/index.ts +2 -0
  64. package/src/notificationTray/api/index.ts +2 -0
  65. package/src/notificationTray/api/markItemsSeen.ts +62 -0
  66. package/src/notificationTray/api/markTraySeen.ts +65 -0
  67. package/src/notificationTray/events/index.ts +1 -0
  68. package/src/notificationTray/events/onNotificationTraySeenUpdated.ts +36 -0
  69. package/src/notificationTray/index.ts +3 -0
  70. package/src/notificationTray/internalApi/getNotificationTraySeen.ts +80 -0
  71. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +96 -0
  72. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
  73. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
  74. package/src/notificationTray/observers/getNotificationTrayItems.ts +44 -0
  75. package/src/notificationTray/observers/getNotificationTraySeen.ts +60 -0
  76. package/src/notificationTray/observers/index.ts +2 -0
  77. package/src/notificationTray/utils/prepareNotificationTrayItemsPayload.ts +12 -0
  78. package/src/utils/linkedObject/index.ts +2 -0
  79. package/src/utils/linkedObject/notificationTrayLinkedObject.ts +19 -0
@@ -0,0 +1,3 @@
1
+ export * from './markItemsSeen';
2
+ export * from './markTraySeen';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * ```js
3
+ * import { notificationTray } from '@amityco/ts-sdk'
4
+ * const updated = await notificationTray.markItemsSeen()
5
+ * ```
6
+ *
7
+ * Updates an {@link Amity.NotificationItemSeen}
8
+ *
9
+ * @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
10
+ * @returns the updated {@link Amity.NotificationItemSeen} object
11
+ *
12
+ * @category NotificationItemSeen API
13
+ * @async
14
+ */
15
+ export declare const markItemsSeen: (trayItems: Amity.QueryNotificationItemSeen[]) => Promise<void>;
16
+ //# sourceMappingURL=markItemsSeen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markItemsSeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/api/markItemsSeen.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,cAAqB,MAAM,yBAAyB,EAAE,kBAuC/E,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * ```js
3
+ * import { notificationTray } from '@amityco/ts-sdk'
4
+ * const updated = await notificationTray.markTraySeen({
5
+ * lastSeenAt: Amity.timestamp,
6
+ * })
7
+ * ```
8
+ *
9
+ * Updates an {@link Amity.NotificationTraySeen}
10
+ *
11
+ * @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
12
+ * @param lastSeenAt The patch data to apply
13
+ * @returns the updated {@link Amity.NotificationTraySeen} object
14
+ *
15
+ * @category Post API
16
+ * @async
17
+ */
18
+ export declare const markTraySeen: (lastSeenAt: Amity.timestamp) => Promise<Amity.Cached<Amity.NotificationTraySeenUpdatedPayload>>;
19
+ //# sourceMappingURL=markTraySeen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/api/markTraySeen.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,eACX,MAAM,SAAS,KAC1B,QAAQ,MAAM,MAAM,CAAC,MAAM,kCAAkC,CAAC,CAqChE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './onNotificationTraySeenUpdated';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ```js
3
+ * import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
4
+ * const dispose = onNotificationTraySeenUpdated(data => {
5
+ * // ...
6
+ * })
7
+ * ```
8
+ *
9
+ * Fired when an {@link Amity.NotificationTraySeen} has been updated
10
+ *
11
+ * @param callback The function to call when the event was fired
12
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
13
+ *
14
+ * @category NotificationTraySeen Events
15
+ */
16
+ export declare const onNotificationTraySeenUpdated: (callback: Amity.Listener<Amity.InternalNotificationTraySeen>) => Amity.Unsubscriber;
17
+ //# sourceMappingURL=onNotificationTraySeenUpdated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onNotificationTraySeenUpdated.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/events/onNotificationTraySeenUpdated.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,aAC9B,MAAM,QAAQ,CAAC,MAAM,4BAA4B,CAAC,KAC3D,MAAM,YAeR,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './observers';
2
+ export * from './api';
3
+ export * from './events';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notificationTray/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * ```js
3
+ * import { notificationTray } from '@amityco/ts-sdk'
4
+ * const notificationTraySeen = await notificationTray.getNotificationTraySeen()
5
+ * ```
6
+ *
7
+ *
8
+ * @returns A page of {@link Amity.NotificationTraySeen} objects
9
+ *
10
+ * @category NotificationTray API
11
+ * @async
12
+ * */
13
+ export declare const getNotificationTraySeen: {
14
+ (): Promise<Amity.Cached<Amity.InternalNotificationTraySeen>>;
15
+ /**
16
+ * ```js
17
+ * import { notificationTray } from '@amityco/ts-sdk'
18
+ * const notificationTraySeen = await notificationTray.getNotificationTraySeen.locally()
19
+ * ```
20
+ *
21
+ * Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
22
+ *
23
+ * @returns A page of {@link Amity.NotificationTraySeen} objects
24
+ *
25
+ * @category NotificationTray API
26
+ * @async
27
+ * */
28
+ locally(): Amity.Cached<Amity.InternalNotificationTraySeen> | undefined;
29
+ };
30
+ //# sourceMappingURL=getNotificationTraySeen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/internalApi/getNotificationTraySeen.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,uBAAuB;QAAa,QAC/C,MAAM,MAAM,CAAC,MAAM,4BAA4B,CAAC,CACjD;IA+BD;;;;;;;;;;;;SAYK;eAED,MAAM,MAAM,CAAC,MAAM,4BAA4B,CAAC,GAChD,SAAS;CAlBZ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { NotificationTrayItemsPaginationController } from './NotificationTrayItemsPaginationController';
2
+ import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
3
+ export declare class NotificationTrayItemsLiveCollectionController extends LiveCollectionController<'notificationTrayItem', Amity.NotificationTrayItemLiveCollection, Amity.NotificationTrayItem, NotificationTrayItemsPaginationController> {
4
+ private queryStreamController;
5
+ private query;
6
+ constructor(query: Amity.NotificationTrayItemLiveCollection, callback: Amity.LiveCollectionCallback<Amity.NotificationTrayItem>);
7
+ protected setup(): void;
8
+ protected persistModel(queryPayload: Amity.NotificationTrayPayload & Amity.Pagination): Promise<void>;
9
+ protected persistQueryStream({ response, direction, refresh, }: Amity.LiveCollectionPersistQueryStreamParams<'notificationTrayItem'>): void;
10
+ startSubscription(): Amity.Unsubscriber[];
11
+ notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams): void;
12
+ }
13
+ //# sourceMappingURL=NotificationTrayItemsLiveCollectionController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationTrayItemsLiveCollectionController.d.ts","sourceRoot":"","sources":["../../../../src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yCAAyC,EAAE,MAAM,6CAA6C,CAAC;AAExG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAK1F,qBAAa,6CAA8C,SAAQ,wBAAwB,CACzF,sBAAsB,EACtB,KAAK,CAAC,kCAAkC,EACxC,KAAK,CAAC,oBAAoB,EAC1B,yCAAyC,CAC1C;IACC,OAAO,CAAC,qBAAqB,CAA6C;IAE1E,OAAO,CAAC,KAAK,CAA2C;gBAGtD,KAAK,EAAE,KAAK,CAAC,kCAAkC,EAC/C,QAAQ,EAAE,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAoBpE,SAAS,CAAC,KAAK;cAYC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,uBAAuB,GAAG,KAAK,CAAC,UAAU;IAI3F,SAAS,CAAC,kBAAkB,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,OAAO,GACR,EAAE,KAAK,CAAC,sCAAsC,CAAC,sBAAsB,CAAC;IAKvE,iBAAiB;IAIjB,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,0BAA0B;CAyB1E"}
@@ -0,0 +1,9 @@
1
+ import { PaginationController } from '~/core/liveCollection/PaginationController';
2
+ /**
3
+ * TODO: handle cache receive cache option, and cache policy
4
+ * TODO: check if querybyIds is supported
5
+ */
6
+ export declare class NotificationTrayItemsPaginationController extends PaginationController<'notificationTrayItem', Amity.NotificationTrayItemLiveCollection> {
7
+ getRequest(queryParams: Amity.NotificationTrayItemLiveCollection, token: string | undefined): Promise<Amity.NotificationTrayPayload & Amity.Pagination>;
8
+ }
9
+ //# sourceMappingURL=NotificationTrayItemsPaginationController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationTrayItemsPaginationController.d.ts","sourceRoot":"","sources":["../../../../src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAGlF;;;GAGG;AACH,qBAAa,yCAA0C,SAAQ,oBAAoB,CACjF,sBAAsB,EACtB,KAAK,CAAC,kCAAkC,CACzC;IACO,UAAU,CACd,WAAW,EAAE,KAAK,CAAC,kCAAkC,EACrD,KAAK,EAAE,MAAM,GAAG,SAAS;CAiB5B"}
@@ -0,0 +1,9 @@
1
+ import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
2
+ export declare class NotificationTrayItemsQuerystreamController extends QueryStreamController<Amity.NotificationTrayPayload, Amity.NotificationTrayItemLiveCollection> {
3
+ private notifyChange;
4
+ private preparePayload;
5
+ constructor(query: Amity.NotificationTrayItemLiveCollection, cacheKey: string[], notifyChange: (params: Amity.LiveCollectionNotifyParams) => void, preparePayload: (response: Amity.NotificationTrayPayload) => Amity.ProcessedNotificationTrayPayload);
6
+ saveToMainDB(response: Amity.NotificationTrayPayload): Promise<void>;
7
+ appendToQueryStream(response: Amity.NotificationTrayPayload & Partial<Amity.Pagination>, direction: Amity.LiveCollectionPageDirection, refresh?: boolean): void;
8
+ }
9
+ //# sourceMappingURL=NotificationTrayItemsQuerystreamController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationTrayItemsQuerystreamController.d.ts","sourceRoot":"","sources":["../../../../src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAMpF,qBAAa,0CAA2C,SAAQ,qBAAqB,CACnF,KAAK,CAAC,uBAAuB,EAC7B,KAAK,CAAC,kCAAkC,CACzC;IACC,OAAO,CAAC,YAAY,CAAqD;IAEzE,OAAO,CAAC,cAAc,CAEsB;gBAG1C,KAAK,EAAE,KAAK,CAAC,kCAAkC,EAC/C,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,0BAA0B,KAAK,IAAI,EAChE,cAAc,EAAE,CACd,QAAQ,EAAE,KAAK,CAAC,uBAAuB,KACpC,KAAK,CAAC,gCAAgC;IAOvC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,uBAAuB;IAW1D,mBAAmB,CACjB,QAAQ,EAAE,KAAK,CAAC,uBAAuB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EACnE,SAAS,EAAE,KAAK,CAAC,2BAA2B,EAC5C,OAAO,UAAQ;CAwBlB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Get notification tray items for a notification tray page
3
+ *
4
+ * @param params the limit query parameters
5
+ * @param callback the callback to be called when the notification tray items are updated
6
+ * @returns items in the notification tray
7
+ *
8
+ * @category Notification tray items Live Collection
9
+ *
10
+ */
11
+ export declare const getNotificationTrayItems: (params: Amity.LiveCollectionParams<Amity.NotificationTrayItemLiveCollection>, callback: Amity.LiveCollectionCallback<Amity.NotificationTrayItem>, config?: Amity.LiveCollectionConfig) => () => void;
12
+ //# sourceMappingURL=getNotificationTrayItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNotificationTrayItems.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/observers/getNotificationTrayItems.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,WAC3B,MAAM,oBAAoB,CAAC,MAAM,kCAAkC,CAAC,YAClE,MAAM,sBAAsB,CAAC,MAAM,oBAAoB,CAAC,WACzD,MAAM,oBAAoB,eAyBpC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ```js
3
+ * import { notificationTray } from '@amityco/ts-sdk';
4
+ *
5
+ * let notificationTraySeen;
6
+ *
7
+ * const unsubscribe = getNotificationTraySeen(response => {
8
+ * notificationTraySeen = response.data;
9
+ * });
10
+ * ```
11
+ *
12
+ * Observe all mutation on a given {@link Amity.NotificationTraySeen}
13
+ *
14
+ * @param callback the function to call when new data are available
15
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
16
+ *
17
+ * @category NotificationTraySeen Live Object
18
+ */
19
+ export declare const getNotificationTraySeen: (callback: Amity.LiveObjectCallback<Amity.NotificationTraySeen>) => Amity.Unsubscriber;
20
+ //# sourceMappingURL=getNotificationTraySeen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/observers/getNotificationTraySeen.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,aACxB,MAAM,kBAAkB,CAAC,MAAM,oBAAoB,CAAC,KAC7D,MAAM,YA6BR,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './getNotificationTraySeen';
2
+ export * from './getNotificationTrayItems';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const prepareNotificationTrayItemsPayload: (rawPayload: Amity.NotificationTrayPayload) => Amity.ProcessedNotificationTrayPayload;
2
+ //# sourceMappingURL=prepareNotificationTrayItemsPayload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareNotificationTrayItemsPayload.d.ts","sourceRoot":"","sources":["../../../src/notificationTray/utils/prepareNotificationTrayItemsPayload.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mCAAmC,eAClC,MAAM,uBAAuB,KACxC,MAAM,gCAOR,CAAC"}
@@ -11,5 +11,6 @@ export declare const LinkedObject: {
11
11
  reactor: (reactor: Amity.InternalReactor) => Amity.Reactor;
12
12
  channel: (channel: Amity.InternalChannel<any>) => Amity.Channel<any>;
13
13
  pinnedPost: (pinnedPost: Amity.RawPin) => Amity.PinnedPost;
14
+ notificationTray: (noti: Amity.RawNotificationTrayItem) => Amity.NotificationTrayItem;
14
15
  };
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAaxB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAcxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const notificationTrayLinkedObject: (noti: Amity.InternalNotificationTrayItem) => Amity.NotificationTrayItem;
2
+ //# sourceMappingURL=notificationTrayLinkedObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationTrayLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/notificationTrayLinkedObject.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,4BAA4B,SACjC,MAAM,4BAA4B,KACvC,MAAM,oBAWR,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk-react-native",
3
- "version": "7.2.0",
3
+ "version": "7.3.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",
@@ -256,6 +256,11 @@ declare global {
256
256
  'local.story.error': Amity.StoryPayload;
257
257
  'local.story.reload': { referenceIds: Amity.Story['referenceId'][] };
258
258
 
259
+ 'local.notificationTraySeen.updated': Amity.InternalNotificationTraySeen;
260
+ 'local.notificationTrayItem.updated': {
261
+ notificationTrayItems: Amity.InternalNotificationTrayItem[];
262
+ };
263
+
259
264
  sessionStateChange: Amity.SessionStates;
260
265
  // used by accessTokenExpiryWatcher
261
266
  tokenExpired: Amity.SessionStates.TOKEN_EXPIRED;
@@ -57,6 +57,9 @@ declare global {
57
57
 
58
58
  pinTarget: Amity.InternalPinTarget;
59
59
  pin: Amity.InternalPin;
60
+
61
+ notificationTrayItem: Amity.InternalNotificationTrayItem;
62
+ notificationTraySeen: Amity.InternalNotificationTraySeen;
60
63
  };
61
64
 
62
65
  type Model = ValueOf<Models>;
@@ -118,6 +121,9 @@ declare global {
118
121
 
119
122
  pinTarget: Pick<Amity.InternalPinTarget, 'targetId'>;
120
123
  pin: Pick<Amity.InternalPin, 'placement' | 'referenceId'>;
124
+
125
+ notificationTrayItem: Pick<Amity.InternalNotificationTrayItem, '_id'>;
126
+ notificationTraySeen: Pick<Amity.InternalNotificationTraySeen, 'userId'>;
121
127
  };
122
128
  }
123
129
  }
@@ -26,6 +26,7 @@ declare global {
26
26
  blockUser: Amity.BlockedUserPayload;
27
27
  semanticSearchPost: Amity.SemanticSearchPostPayload;
28
28
  semanticSearchCommunity: Amity.SemanticSearchCommunityPayload;
29
+ notificationTrayItem: Amity.NotificationTrayPayload;
29
30
  };
30
31
 
31
32
  type UserPayload = {
@@ -378,6 +379,34 @@ declare global {
378
379
  reactions: Amity.InternalReactor[];
379
380
  } & Amity.StoryPayload;
380
381
 
382
+ type NotificationTrayPayload = {
383
+ notificationTrayItems: Amity.RawNotificationTrayItem[];
384
+ users: Amity.RawUser[];
385
+ files?: Amity.File[];
386
+ };
387
+
388
+ type ProcessedNotificationTrayPayload = Omit<
389
+ NotificationTrayPayload,
390
+ 'notificationTrayItems' | 'users'
391
+ > & {
392
+ notificationTrayItems: Amity.InternalNotificationTrayItem[];
393
+ users: Amity.InternalUser[];
394
+ files?: Amity.File[];
395
+ };
396
+
397
+ type NotificationTraySeenPayload = {
398
+ lastTraySeenAt: Amity.timestamp;
399
+ lastTrayOccurredAt: Amity.timestamp;
400
+ };
401
+
402
+ type NotificationTraySeenUpdatedPayload = {
403
+ lastSeenAt: Amity.timestamp;
404
+ };
405
+
406
+ type NotificationItemSeenPayload = {
407
+ trayItems: { id: string; lastSeenAt: Amity.timestamp }[];
408
+ };
409
+
381
410
  /**
382
411
  * Items that extend from `Amity.PostPayload`
383
412
  * - communities: `Amity.RawCommunity` -> `Amity.Community` (Added Marker Service related props)
@@ -31,7 +31,7 @@ declare global {
31
31
  image9_16: string;
32
32
  callToAction: string;
33
33
  callToActionUrl: string;
34
- targets: Amity.AdTarget;
34
+ target: Amity.AdTarget;
35
35
  startAt: Amity.timestamp;
36
36
  endAt?: Amity.timestamp;
37
37
  createdAt: Amity.timestamp;
@@ -0,0 +1,94 @@
1
+ export {};
2
+
3
+ declare global {
4
+ namespace Amity {
5
+ const enum TrayItemCategoryType {
6
+ POST_MENTION = 'mention_in_post',
7
+ COMMENT_MENTION = 'mention_in_comment',
8
+ REPLY_MENTION = 'mention_in_reply',
9
+ POLL_MENTION = 'mention_in_poll',
10
+ POST_REACT = 'reaction_on_post',
11
+ COMMENT_REACT = 'reaction_on_comment',
12
+ REPLY_REACT = 'reaction_on_reply',
13
+ }
14
+
15
+ const enum TrayAction {
16
+ POST = 'post',
17
+ POLL = 'poll',
18
+ COMMENT = 'comment',
19
+ REACTION = 'reaction',
20
+ MENTION = 'mention',
21
+ REPLY = 'reply',
22
+ }
23
+
24
+ type RawNotificationTrayItem = {
25
+ _id: string;
26
+ lastSeenAt: Amity.timestamp;
27
+ lastOccurredAt: Amity.timestamp;
28
+ actors: {
29
+ _id: string;
30
+ publicId: string;
31
+ lastActedAt: Amity.timestamp;
32
+ }[];
33
+ actorsCount: number;
34
+ trayItemCategory?: TrayItemCategoryType;
35
+ targetId: string;
36
+ targetType: string;
37
+ referenceId?: string;
38
+ referenceType?: string;
39
+ actionType: TrayAction;
40
+ actionReferenceId?: string;
41
+ parentId?: string;
42
+ text: string;
43
+ templatedText: string;
44
+ daySegment: Amity.timestamp;
45
+ };
46
+
47
+ type InternalNotificationTrayItem = RawNotificationTrayItem;
48
+
49
+ type QueryNotificationTrayItem = {
50
+ token?: Amity.Token;
51
+ limit?: Amity.PageLimit['limit'];
52
+ };
53
+
54
+ type NotificationTrayItemLiveCollection = Amity.LiveCollectionParams<
55
+ Omit<QueryNotificationTrayItem, 'limit'>
56
+ >;
57
+
58
+ type NotificationTrayItemLiveCollectionCache = Amity.LiveCollectionCache<
59
+ Amity.InternalNotificationTrayItem['_id'],
60
+ Pick<QueryNotificationTrayItem, 'limit'>
61
+ >;
62
+
63
+ type NotificationTrayItem = Amity.InternalNotificationTrayItem & {
64
+ isSeen: boolean;
65
+ isRecent: boolean;
66
+ users: Amity.User[];
67
+ };
68
+
69
+ type RawNotificationTraySeen = {
70
+ lastTraySeenAt: Amity.timestamp;
71
+ lastTrayOccurredAt: Amity.timestamp;
72
+ };
73
+
74
+ type RawNotificationTraySeenUpdated = {
75
+ lastTraySeenAt: Amity.timestamp;
76
+ };
77
+
78
+ type InternalNotificationTraySeen = RawNotificationTraySeen & {
79
+ userId: string;
80
+ isSeen: boolean;
81
+ };
82
+
83
+ type NotificationTraySeen = RawNotificationTraySeen & { isSeen: boolean };
84
+
85
+ type RawNotificationItemSeen = {
86
+ lastSeenAt: Amity.timestamp;
87
+ };
88
+
89
+ type QueryNotificationItemSeen = {
90
+ id: string;
91
+ lastSeenAt: Amity.timestamp;
92
+ };
93
+ }
94
+ }
@@ -37,3 +37,4 @@ export * from './domains/message';
37
37
  export * from './domains/post';
38
38
  export * from './domains/story';
39
39
  export * from './domains/ad';
40
+ export * from './domains/notification';
@@ -61,6 +61,9 @@ const idResolvers: Resolvers = {
61
61
 
62
62
  pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
63
63
  pinTarget: ({ targetId }) => targetId,
64
+
65
+ notificationTrayItem: ({ _id }) => _id,
66
+ notificationTraySeen: ({ userId }) => userId,
64
67
  };
65
68
 
66
69
  /**
@@ -52,6 +52,8 @@ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = {
52
52
 
53
53
  pinTargets: 'pinTarget',
54
54
  pins: 'pin',
55
+
56
+ notificationTrayItems: 'notificationTrayItem',
55
57
  };
56
58
 
57
59
  /** hidden */
package/src/index.ts CHANGED
@@ -49,3 +49,5 @@ export * as AdRepository from './adRepository';
49
49
 
50
50
  // // external apis
51
51
  export * from './external/api';
52
+
53
+ export * as notificationTray from './notificationTray';
@@ -0,0 +1,2 @@
1
+ export * from './markItemsSeen';
2
+ export * from './markTraySeen';
@@ -0,0 +1,62 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { fireEvent } from '~/core/events';
3
+ import { pullFromCache, pushToCache } from '~/cache/api';
4
+
5
+ /* begin_public_function
6
+ id: notificationTrayItem.markSeen
7
+ */
8
+ /**
9
+ * ```js
10
+ * import { notificationTray } from '@amityco/ts-sdk'
11
+ * const updated = await notificationTray.markItemsSeen()
12
+ * ```
13
+ *
14
+ * Updates an {@link Amity.NotificationItemSeen}
15
+ *
16
+ * @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
17
+ * @returns the updated {@link Amity.NotificationItemSeen} object
18
+ *
19
+ * @category NotificationItemSeen API
20
+ * @async
21
+ */
22
+ export const markItemsSeen = async (trayItems: Amity.QueryNotificationItemSeen[]) => {
23
+ const client = getActiveClient();
24
+ client.log('notificationTray/markItemsSeen', {});
25
+
26
+ const { data: payload } = await client.http.post<Amity.NotificationItemSeenPayload>(
27
+ `api/v1/notification-tray/items/seen`,
28
+ {
29
+ trayItems: trayItems.map(item => ({
30
+ id: item.id,
31
+ lastSeenAt: item.lastSeenAt,
32
+ })),
33
+ },
34
+ );
35
+
36
+ const updatedData = payload.trayItems
37
+ .map(patchItem => {
38
+ const cacheData = pullFromCache<Amity.InternalNotificationTrayItem>([
39
+ 'notificationTrayItem',
40
+ 'get',
41
+ patchItem.id,
42
+ ])?.data;
43
+
44
+ if (!cacheData) return;
45
+
46
+ const data = {
47
+ ...cacheData,
48
+ lastSeenAt: patchItem.lastSeenAt,
49
+ };
50
+
51
+ if (client.cache) {
52
+ const cachedAt = Date.now();
53
+ pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
54
+ }
55
+
56
+ return data;
57
+ })
58
+ .filter(Boolean) as Amity.InternalNotificationTrayItem[];
59
+
60
+ fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
61
+ };
62
+ /* end_public_function */
@@ -0,0 +1,65 @@
1
+ import { getActiveClient } from '~/client/api';
2
+ import { fireEvent } from '~/core/events';
3
+ import { pullFromCache, pushToCache } from '~/cache/api';
4
+
5
+ /* begin_public_function
6
+ id: notificationTray.markSeen
7
+ */
8
+ /**
9
+ * ```js
10
+ * import { notificationTray } from '@amityco/ts-sdk'
11
+ * const updated = await notificationTray.markTraySeen({
12
+ * lastSeenAt: Amity.timestamp,
13
+ * })
14
+ * ```
15
+ *
16
+ * Updates an {@link Amity.NotificationTraySeen}
17
+ *
18
+ * @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
19
+ * @param lastSeenAt The patch data to apply
20
+ * @returns the updated {@link Amity.NotificationTraySeen} object
21
+ *
22
+ * @category Post API
23
+ * @async
24
+ */
25
+ export const markTraySeen = async (
26
+ lastSeenAt: Amity.timestamp,
27
+ ): Promise<Amity.Cached<Amity.NotificationTraySeenUpdatedPayload>> => {
28
+ const client = getActiveClient();
29
+ client.log('notificationTray/markTraySeen', {});
30
+
31
+ const { data: payload } = await client.http.post<Amity.NotificationTraySeenUpdatedPayload>(
32
+ `api/v1/notification-tray/tray/seen`,
33
+ {
34
+ lastSeenAt,
35
+ },
36
+ );
37
+
38
+ const cacheData = pullFromCache<Amity.InternalNotificationTraySeen>([
39
+ 'notificationTraySeen',
40
+ 'get',
41
+ ])?.data;
42
+
43
+ const data = {
44
+ userId: client.userId!,
45
+ lastTraySeenAt: payload.lastSeenAt,
46
+ } as Amity.InternalNotificationTraySeen;
47
+
48
+ const updateCacheData = {
49
+ ...cacheData,
50
+ ...data,
51
+ };
52
+
53
+ const cachedAt = client.cache && Date.now();
54
+
55
+ if (client.cache)
56
+ pushToCache(['notificationTraySeen', 'get', client.userId!], updateCacheData, { cachedAt });
57
+
58
+ fireEvent('local.notificationTraySeen.updated', data);
59
+
60
+ return {
61
+ data: payload,
62
+ cachedAt,
63
+ };
64
+ };
65
+ /* end_public_function */
@@ -0,0 +1 @@
1
+ export * from './onNotificationTraySeenUpdated';