@amityco/ts-sdk 7.1.1-5d7c3fd0.0 → 7.1.1-611ceb49.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/@types/core/events.d.ts +4 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +18 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +0 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +81 -0
- package/dist/@types/domains/notification.d.ts.map +1 -0
- package/dist/client/api/createClient.d.ts +0 -1
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts +0 -1
- package/dist/client/utils/endpoints.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +425 -60
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +408 -44
- package/dist/index.umd.js +4 -4
- package/dist/notificationTrayRepository/api/index.d.ts +3 -0
- package/dist/notificationTrayRepository/api/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/api/markNotificationItemsSeen.d.ts +16 -0
- package/dist/notificationTrayRepository/api/markNotificationItemsSeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/api/markNotificationTraySeen.d.ts +19 -0
- package/dist/notificationTrayRepository/api/markNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/events/index.d.ts +2 -0
- package/dist/notificationTrayRepository/events/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/events/onNotificationTraySeenUpdated.d.ts +17 -0
- package/dist/notificationTrayRepository/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
- package/dist/notificationTrayRepository/index.d.ts +4 -0
- package/dist/notificationTrayRepository/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/internalApi/getNotificationTraySeen.d.ts +30 -0
- package/dist/notificationTrayRepository/internalApi/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems.d.ts +12 -0
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/getNotificationTraySeen.d.ts +21 -0
- package/dist/notificationTrayRepository/observers/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTrayRepository/observers/index.d.ts +3 -0
- package/dist/notificationTrayRepository/observers/index.d.ts.map +1 -0
- package/dist/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
- package/dist/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/core/events.ts +5 -0
- package/src/@types/core/model.ts +6 -0
- package/src/@types/core/payload.ts +25 -0
- package/src/@types/domains/client.ts +0 -1
- package/src/@types/domains/notification.ts +90 -0
- package/src/client/api/createClient.ts +1 -4
- package/src/client/utils/endpoints.ts +0 -1
- package/src/client/utils/setClientToken.ts +0 -8
- package/src/core/model/idResolvers.ts +3 -0
- package/src/core/model/index.ts +2 -0
- package/src/fileRepository/api/uploadFile.ts +1 -1
- package/src/fileRepository/api/uploadImage.ts +1 -1
- package/src/fileRepository/api/uploadVideo.ts +1 -1
- package/src/index.ts +2 -0
- package/src/notificationTrayRepository/api/index.ts +2 -0
- package/src/notificationTrayRepository/api/markNotificationItemsSeen.ts +59 -0
- package/src/notificationTrayRepository/api/markNotificationTraySeen.ts +65 -0
- package/src/notificationTrayRepository/events/index.ts +1 -0
- package/src/notificationTrayRepository/events/onNotificationTraySeenUpdated.ts +36 -0
- package/src/notificationTrayRepository/index.ts +3 -0
- package/src/notificationTrayRepository/internalApi/getNotificationTraySeen.ts +81 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +96 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
- package/src/notificationTrayRepository/observers/getNotificationTrayItems.ts +44 -0
- package/src/notificationTrayRepository/observers/getNotificationTraySeen.ts +43 -0
- package/src/notificationTrayRepository/observers/index.ts +2 -0
- package/src/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.ts +12 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/notificationTrayLinkedObject.ts +28 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
4
|
+
* const updated = await NotificationTrayRepository.markNotificationItemsSeen()
|
|
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 markNotificationItemsSeen: (patch: Amity.QueryNotificationItemSeen) => Promise<void>;
|
|
16
|
+
//# sourceMappingURL=markNotificationItemsSeen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markNotificationItemsSeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/api/markNotificationItemsSeen.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,UAAiB,MAAM,yBAAyB,kBAoCrF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
4
|
+
* const updated = await NotificationTrayRepository.markNotificationTraySeen({
|
|
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 markNotificationTraySeen: (lastSeenAt: Amity.timestamp) => Promise<Amity.Cached<Amity.NotificationTraySeenUpdatedPayload>>;
|
|
19
|
+
//# sourceMappingURL=markNotificationTraySeen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/api/markNotificationTraySeen.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,eACvB,MAAM,SAAS,KAC1B,QAAQ,MAAM,MAAM,CAAC,MAAM,kCAAkC,CAAC,CAqChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/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/notificationTrayRepository/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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notificationTrayRepository/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 { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
4
|
+
* const notificationTraySeen = await NotificationTrayRepository.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.NotificationTraySeen>>;
|
|
15
|
+
/**
|
|
16
|
+
* ```js
|
|
17
|
+
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
18
|
+
* const notificationTraySeen = await NotificationTrayRepository.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.NotificationTraySeenPayload> | undefined;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=getNotificationTraySeen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/internalApi/getNotificationTraySeen.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,uBAAuB;QAAa,QAC/C,MAAM,MAAM,CAAC,MAAM,oBAAoB,CAAC,CACzC;IA+BD;;;;;;;;;;;;SAYK;eAED,MAAM,MAAM,CAAC,MAAM,2BAA2B,CAAC,GAC/C,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.RawNotificationTrayItem, NotificationTrayItemsPaginationController> {
|
|
4
|
+
private queryStreamController;
|
|
5
|
+
private query;
|
|
6
|
+
constructor(query: Amity.NotificationTrayItemLiveCollection, callback: Amity.LiveCollectionCallback<Amity.RawNotificationTrayItem>);
|
|
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/notificationTrayRepository/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,uBAAuB,EAC7B,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,uBAAuB,CAAC;IAoBvE,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/notificationTrayRepository/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/notificationTrayRepository/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.RawNotificationTrayItem>, config?: Amity.LiveCollectionConfig) => () => void;
|
|
12
|
+
//# sourceMappingURL=getNotificationTrayItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNotificationTrayItems.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/observers/getNotificationTrayItems.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,WAC3B,MAAM,oBAAoB,CAAC,MAAM,kCAAkC,CAAC,YAClE,MAAM,sBAAsB,CAAC,MAAM,uBAAuB,CAAC,WAC5D,MAAM,oBAAoB,eAyBpC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { getNotificationTraySeen } from '@amityco/ts-sdk';
|
|
4
|
+
*
|
|
5
|
+
* let notificationTraySeen;
|
|
6
|
+
*
|
|
7
|
+
* const unsubscribe = getNotificationTraySeen(userId, response => {
|
|
8
|
+
* notificationTraySeen = response.data;
|
|
9
|
+
* });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Observe all mutation on a given {@link Amity.NotificationTraySeen}
|
|
13
|
+
*
|
|
14
|
+
* @param userId the ID of the user to observe
|
|
15
|
+
* @param callback the function to call when new data are available
|
|
16
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
|
|
17
|
+
*
|
|
18
|
+
* @category NotificationTraySeen Live Object
|
|
19
|
+
*/
|
|
20
|
+
export declare const getNotificationTraySeen: (callback: Amity.LiveObjectCallback<Amity.NotificationTraySeenPayload>) => Amity.Unsubscriber;
|
|
21
|
+
//# sourceMappingURL=getNotificationTraySeen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/observers/getNotificationTraySeen.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uBAAuB,aACxB,MAAM,kBAAkB,CAAC,MAAM,2BAA2B,CAAC,KACpE,MAAM,YAYR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareNotificationTrayItemsPayload.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/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":"
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"notificationTrayLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/notificationTrayLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B,SACjC,MAAM,4BAA4B,KACvC,MAAM,oBAmBR,CAAC"}
|
package/package.json
CHANGED
|
@@ -255,6 +255,11 @@ declare global {
|
|
|
255
255
|
'local.story.error': Amity.StoryPayload;
|
|
256
256
|
'local.story.reload': { referenceIds: Amity.Story['referenceId'][] };
|
|
257
257
|
|
|
258
|
+
'local.notificationTraySeen.updated': Amity.InternalNotificationTraySeen;
|
|
259
|
+
'local.notificationTrayItem.updated': {
|
|
260
|
+
notificationTrayItems: Amity.InternalNotificationTrayItem[];
|
|
261
|
+
};
|
|
262
|
+
|
|
258
263
|
sessionStateChange: Amity.SessionStates;
|
|
259
264
|
// used by accessTokenExpiryWatcher
|
|
260
265
|
tokenExpired: Amity.SessionStates.TOKEN_EXPIRED;
|
package/src/@types/core/model.ts
CHANGED
|
@@ -55,6 +55,9 @@ declare global {
|
|
|
55
55
|
|
|
56
56
|
pinTarget: Amity.InternalPinTarget;
|
|
57
57
|
pin: Amity.InternalPin;
|
|
58
|
+
|
|
59
|
+
notificationTrayItem: Amity.InternalNotificationTrayItem;
|
|
60
|
+
notificationTraySeen: Amity.InternalNotificationTraySeen;
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
type Model = ValueOf<Models>;
|
|
@@ -114,6 +117,9 @@ declare global {
|
|
|
114
117
|
|
|
115
118
|
pinTarget: Pick<Amity.InternalPinTarget, 'targetId'>;
|
|
116
119
|
pin: Pick<Amity.InternalPin, 'placement' | 'referenceId'>;
|
|
120
|
+
|
|
121
|
+
notificationTrayItem: Amity.InternalNotificationTrayItem;
|
|
122
|
+
notificationTraySeen: Amity.InternalNotificationTraySeen;
|
|
117
123
|
};
|
|
118
124
|
}
|
|
119
125
|
}
|
|
@@ -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,30 @@ 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
|
+
lastTrayOccuredAt: Amity.timestamp;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
type NotificationTraySeenUpdatedPayload = {
|
|
403
|
+
lastTraySeenAt: Amity.timestamp;
|
|
404
|
+
};
|
|
405
|
+
|
|
381
406
|
/**
|
|
382
407
|
* Items that extend from `Amity.PostPayload`
|
|
383
408
|
* - communities: `Amity.RawCommunity` -> `Amity.Community` (Added Marker Service related props)
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
POST_REACT = 'react_to_post',
|
|
9
|
+
COMMENT_REACT = 'react_to_comment',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const enum TrayAction {
|
|
13
|
+
POST = 'post',
|
|
14
|
+
POLL = 'poll',
|
|
15
|
+
COMMENT = 'comment',
|
|
16
|
+
REACTION = 'reaction',
|
|
17
|
+
MENTION = 'mention',
|
|
18
|
+
REPLY = 'reply',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type RawNotificationTrayItem = {
|
|
22
|
+
_id: string;
|
|
23
|
+
lastSeenAt: Amity.timestamp;
|
|
24
|
+
lastOccuredAt: Amity.timestamp;
|
|
25
|
+
actors: {
|
|
26
|
+
_id: string;
|
|
27
|
+
lastActedAt: Amity.timestamp;
|
|
28
|
+
}[];
|
|
29
|
+
actorsCount: number;
|
|
30
|
+
action: TrayAction;
|
|
31
|
+
trayItemCategory?: TrayItemCategoryType;
|
|
32
|
+
targetId: string;
|
|
33
|
+
targetType: string;
|
|
34
|
+
referenceId?: string;
|
|
35
|
+
referenceType?: string;
|
|
36
|
+
actionReferenceId?: string;
|
|
37
|
+
parentId?: string;
|
|
38
|
+
data: { communityName: string } | { reactionName: string[] };
|
|
39
|
+
text: string;
|
|
40
|
+
templatedText: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type InternalNotificationTrayItem = RawNotificationTrayItem;
|
|
44
|
+
|
|
45
|
+
type QueryNotificationTrayItem = {
|
|
46
|
+
token?: Amity.Token;
|
|
47
|
+
limit?: Amity.PageLimit['limit'];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type NotificationTrayItemLiveCollection = Amity.LiveCollectionParams<
|
|
51
|
+
Omit<QueryNotificationTrayItem, 'limit'>
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
type NotificationTrayItemLiveCollectionCache = Amity.LiveCollectionCache<
|
|
55
|
+
Amity.InternalNotificationTrayItem['_id'],
|
|
56
|
+
Pick<QueryNotificationTrayItem, 'limit'>
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
type NotificationTrayItem = Amity.InternalNotificationTrayItem & {
|
|
60
|
+
markRead: () => void;
|
|
61
|
+
isSeen: boolean;
|
|
62
|
+
isRecent: boolean;
|
|
63
|
+
users: Amity.User[];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type RawNotificationTraySeen = {
|
|
67
|
+
lastTraySeenAt: Amity.timestamp;
|
|
68
|
+
lastTrayOccuredAt: Amity.timestamp;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type RawNotificationTraySeenUpdated = {
|
|
72
|
+
lastTraySeenAt: Amity.timestamp;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type InternalNotificationTraySeen = RawNotificationTraySeen & { userId: string };
|
|
76
|
+
|
|
77
|
+
type NotificationTraySeen = RawNotificationTraySeen & { userId: string; isSeen: boolean };
|
|
78
|
+
|
|
79
|
+
type RawNotificationItemSeen = {
|
|
80
|
+
lastSeenAt: Amity.timestamp;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
type QueryNotificationItemSeen = {
|
|
84
|
+
trayItems: {
|
|
85
|
+
id: string;
|
|
86
|
+
lastSeenAt: Amity.timestamp;
|
|
87
|
+
}[];
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -50,7 +50,7 @@ export const createClient = (
|
|
|
50
50
|
rteEnabled = true,
|
|
51
51
|
}: {
|
|
52
52
|
debugSession?: string;
|
|
53
|
-
apiEndpoint?: { http?: string; mqtt?: string
|
|
53
|
+
apiEndpoint?: { http?: string; mqtt?: string };
|
|
54
54
|
prefixDeviceIdKey?: string;
|
|
55
55
|
rteEnabled?: boolean;
|
|
56
56
|
} = {},
|
|
@@ -63,11 +63,9 @@ export const createClient = (
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
const httpEndpoint = apiEndpoint?.http ?? computeUrl('http', apiRegion);
|
|
66
|
-
const uploadEndpoint = apiEndpoint?.upload ?? computeUrl('upload', apiRegion);
|
|
67
66
|
const mqttEndpoint = apiEndpoint?.mqtt ?? computeUrl('mqtt', apiRegion);
|
|
68
67
|
|
|
69
68
|
const http = createHttpTransport(httpEndpoint);
|
|
70
|
-
const upload = createHttpTransport(uploadEndpoint);
|
|
71
69
|
|
|
72
70
|
let ws;
|
|
73
71
|
let mqtt;
|
|
@@ -105,7 +103,6 @@ export const createClient = (
|
|
|
105
103
|
http,
|
|
106
104
|
ws,
|
|
107
105
|
mqtt,
|
|
108
|
-
upload,
|
|
109
106
|
emitter,
|
|
110
107
|
|
|
111
108
|
/*
|
|
@@ -30,14 +30,6 @@ export const setClientToken = async (params: Parameters<typeof getToken>[0]) =>
|
|
|
30
30
|
isUserDeleted: false,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
client.upload.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
34
|
-
|
|
35
|
-
client.upload.defaults.metadata = {
|
|
36
|
-
tokenExpiry: expiresAt,
|
|
37
|
-
isGlobalBanned: false,
|
|
38
|
-
isUserDeleted: false,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
33
|
// manually setup the token for ws transport
|
|
42
34
|
if (client.ws) client.ws.io.opts.query = { token: accessToken };
|
|
43
35
|
|
|
@@ -59,6 +59,9 @@ const idResolvers: Resolvers = {
|
|
|
59
59
|
|
|
60
60
|
pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
|
|
61
61
|
pinTarget: ({ targetId }) => targetId,
|
|
62
|
+
|
|
63
|
+
notificationTrayItem: ({ _id }) => _id,
|
|
64
|
+
notificationTraySeen: ({ userId }) => userId,
|
|
62
65
|
};
|
|
63
66
|
|
|
64
67
|
/**
|
package/src/core/model/index.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const uploadFile = async <T extends Amity.FileType = any>(
|
|
|
42
42
|
? (formData as any).getHeaders()
|
|
43
43
|
: { 'content-type': 'multipart/form-data' };
|
|
44
44
|
|
|
45
|
-
const { data } = await client.
|
|
45
|
+
const { data } = await client.http.post<Amity.CreateFilePayload<T>>('/api/v4/files', formData, {
|
|
46
46
|
headers,
|
|
47
47
|
onUploadProgress({ loaded, total = 100 }) {
|
|
48
48
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -42,7 +42,7 @@ export const uploadImage = async (
|
|
|
42
42
|
? (formData as any).getHeaders()
|
|
43
43
|
: { 'content-type': 'multipart/form-data' };
|
|
44
44
|
|
|
45
|
-
const { data } = await client.
|
|
45
|
+
const { data } = await client.http.post<Amity.CreateFilePayload<'image'>>(
|
|
46
46
|
'/api/v4/images',
|
|
47
47
|
formData,
|
|
48
48
|
{
|
|
@@ -48,7 +48,7 @@ export const uploadVideo = async (
|
|
|
48
48
|
? (formData as any).getHeaders()
|
|
49
49
|
: { 'content-type': 'multipart/form-data' };
|
|
50
50
|
|
|
51
|
-
const { data } = await client.
|
|
51
|
+
const { data } = await client.http.post<Amity.CreateFilePayload<'video'>>(
|
|
52
52
|
'/api/v4/videos',
|
|
53
53
|
formData,
|
|
54
54
|
{
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
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 { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
11
|
+
* const updated = await NotificationTrayRepository.markNotificationItemsSeen()
|
|
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 markNotificationItemsSeen = async (patch: Amity.QueryNotificationItemSeen) => {
|
|
23
|
+
const client = getActiveClient();
|
|
24
|
+
client.log('notificationTray/markNotificationItemsSeen', {});
|
|
25
|
+
|
|
26
|
+
const { data: payload } = await client.http.put<Amity.RawNotificationTraySeenUpdated>(
|
|
27
|
+
`api/v1/notification-tray/items/seen`,
|
|
28
|
+
{
|
|
29
|
+
patch,
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const updatedData = patch.trayItems
|
|
34
|
+
.map(patchItem => {
|
|
35
|
+
const cacheData = pullFromCache<Amity.InternalNotificationTrayItem>([
|
|
36
|
+
'notificationTraySeen',
|
|
37
|
+
'get',
|
|
38
|
+
patchItem.id,
|
|
39
|
+
])?.data;
|
|
40
|
+
|
|
41
|
+
if (!cacheData) return;
|
|
42
|
+
|
|
43
|
+
const data = {
|
|
44
|
+
...cacheData,
|
|
45
|
+
...payload,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (client.cache) {
|
|
49
|
+
const cachedAt = Date.now();
|
|
50
|
+
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return data;
|
|
54
|
+
})
|
|
55
|
+
.filter(Boolean) as Amity.InternalNotificationTrayItem[];
|
|
56
|
+
|
|
57
|
+
fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
|
|
58
|
+
};
|
|
59
|
+
/* end_public_function */
|