@nmshd/consumption 3.4.0 → 3.4.2
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/buildInformation.js +4 -4
- package/dist/modules/notifications/NotificationsController.d.ts +4 -1
- package/dist/modules/notifications/NotificationsController.js +24 -5
- package/dist/modules/notifications/NotificationsController.js.map +1 -1
- package/lib-web/nmshd.consumption.js +28 -9
- package/lib-web/nmshd.consumption.js.map +1 -1
- package/lib-web/nmshd.consumption.min.js +1 -1
- package/lib-web/nmshd.consumption.min.js.map +1 -1
- package/package.json +4 -4
package/dist/buildInformation.js
CHANGED
|
@@ -6,10 +6,10 @@ const content_1 = require("@nmshd/content");
|
|
|
6
6
|
const crypto_1 = require("@nmshd/crypto");
|
|
7
7
|
const transport_1 = require("@nmshd/transport");
|
|
8
8
|
exports.buildInformation = {
|
|
9
|
-
version: "3.4.
|
|
10
|
-
build: "
|
|
11
|
-
date: "2023-10-
|
|
12
|
-
commit: "
|
|
9
|
+
version: "3.4.2",
|
|
10
|
+
build: "110",
|
|
11
|
+
date: "2023-10-17T05:41:49+00:00",
|
|
12
|
+
commit: "40d88048ab6ca06125a903f680a965a17b952850",
|
|
13
13
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.1","@nmshd/iql":"^0.0.4","ts-simple-nameof":"^1.3.1"},
|
|
14
14
|
libraries: {
|
|
15
15
|
transport: transport_1.buildInformation,
|
|
@@ -12,9 +12,12 @@ export declare class NotificationsController extends ConsumptionBaseController {
|
|
|
12
12
|
constructor(localNotifications: SynchronizedCollection, processorRegistry: NotificationItemProcessorRegistry, parent: ConsumptionController, eventBus: EventBus, device: {
|
|
13
13
|
id: CoreId;
|
|
14
14
|
});
|
|
15
|
+
getNotifications(query?: any): Promise<LocalNotification[]>;
|
|
16
|
+
getNotification(id: CoreId): Promise<LocalNotification>;
|
|
15
17
|
sent(message: Message): Promise<LocalNotification>;
|
|
16
18
|
received(message: Message): Promise<LocalNotification>;
|
|
17
19
|
private extractNotificationFromMessage;
|
|
18
20
|
processOpenNotifactionsReceivedByCurrentDevice(): Promise<void>;
|
|
19
|
-
|
|
21
|
+
processNotificationById(notificationId: CoreId): Promise<LocalNotification>;
|
|
22
|
+
private process;
|
|
20
23
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationsController = void 0;
|
|
4
4
|
const content_1 = require("@nmshd/content");
|
|
5
|
+
const transport_1 = require("@nmshd/transport");
|
|
5
6
|
const ConsumptionBaseController_1 = require("../../consumption/ConsumptionBaseController");
|
|
6
7
|
const ConsumptionControllerName_1 = require("../../consumption/ConsumptionControllerName");
|
|
7
8
|
const LocalNotification_1 = require("./local/LocalNotification");
|
|
@@ -14,6 +15,17 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
14
15
|
this.eventBus = eventBus;
|
|
15
16
|
this.device = device;
|
|
16
17
|
}
|
|
18
|
+
async getNotifications(query) {
|
|
19
|
+
const notifications = await this.localNotifications.find(query);
|
|
20
|
+
return notifications.map((notification) => LocalNotification_1.LocalNotification.from(notification));
|
|
21
|
+
}
|
|
22
|
+
async getNotification(id) {
|
|
23
|
+
const notification = await this.localNotifications.findOne({ id: id.toString() });
|
|
24
|
+
if (!notification) {
|
|
25
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalNotification_1.LocalNotification, id.toString());
|
|
26
|
+
}
|
|
27
|
+
return LocalNotification_1.LocalNotification.from(notification);
|
|
28
|
+
}
|
|
17
29
|
async sent(message) {
|
|
18
30
|
if (!message.isOwn)
|
|
19
31
|
throw new Error("Cannot send a Notification from a foreign message.");
|
|
@@ -62,12 +74,20 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
62
74
|
isOwn: false,
|
|
63
75
|
status: LocalNotification_1.LocalNotificationStatus.Open
|
|
64
76
|
});
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
await this.process(notification);
|
|
77
|
+
for (const notificationDoc of notifications) {
|
|
78
|
+
const notification = LocalNotification_1.LocalNotification.from(notificationDoc);
|
|
79
|
+
await this.process(notificationDoc, notification);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async processNotificationById(notificationId) {
|
|
83
|
+
const notificationDoc = await this.localNotifications.findOne({ id: notificationId.toString() });
|
|
84
|
+
if (!notificationDoc) {
|
|
85
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalNotification_1.LocalNotification, notificationId.toString());
|
|
68
86
|
}
|
|
87
|
+
const parsed = LocalNotification_1.LocalNotification.from(notificationDoc);
|
|
88
|
+
return await this.process(notificationDoc, parsed);
|
|
69
89
|
}
|
|
70
|
-
async process(notification) {
|
|
90
|
+
async process(oldDoc, notification) {
|
|
71
91
|
if (notification.isOwn)
|
|
72
92
|
throw new Error("Cannot process own notification.");
|
|
73
93
|
if (!notification.receivedByDevice?.equals(this.device.id)) {
|
|
@@ -76,7 +96,6 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
76
96
|
if (![LocalNotification_1.LocalNotificationStatus.Open, LocalNotification_1.LocalNotificationStatus.Error].includes(notification.status)) {
|
|
77
97
|
throw new Error(`Cannot process notification with status ${notification.status}.`);
|
|
78
98
|
}
|
|
79
|
-
const oldDoc = await this.localNotifications.findOne({ id: notification.id.toString() });
|
|
80
99
|
const processedItems = [];
|
|
81
100
|
const events = [];
|
|
82
101
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsController.js","sourceRoot":"","sources":["../../../src/modules/notifications/NotificationsController.ts"],"names":[],"mappings":";;;AACA,4CAA+D;
|
|
1
|
+
{"version":3,"file":"NotificationsController.js","sourceRoot":"","sources":["../../../src/modules/notifications/NotificationsController.ts"],"names":[],"mappings":";;;AACA,4CAA+D;AAC/D,gDAA6G;AAC7G,2FAAuF;AAEvF,2FAAuF;AAEvF,iEAAsF;AACtF,6EAAyE;AAEzE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AAE,CAAC,CAAA;YAE/E,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,OAAO,EAAE,EAAE;gBACzC,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;gBAClE,MAAM,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;aACjC;YAED,YAAY,CAAC,MAAM,GAAG,2CAAuB,CAAC,KAAK,CAAA;YACnD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;YAE1D,OAAO,YAAY,CAAA;SACtB;QAED,YAAY,CAAC,MAAM,GAAG,2CAAuB,CAAC,SAAS,CAAA;QACvD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;QAE1D,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAExD,OAAO,YAAY,CAAA;IACvB,CAAC;CACJ;AAvJD,0DAuJC"}
|
|
@@ -17,10 +17,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
17
17
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
18
18
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
19
19
|
exports.buildInformation = {
|
|
20
|
-
version: "3.4.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2023-10-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "3.4.2",
|
|
21
|
+
build: "110",
|
|
22
|
+
date: "2023-10-17T05:41:49+00:00",
|
|
23
|
+
commit: "40d88048ab6ca06125a903f680a965a17b952850",
|
|
24
24
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.1","@nmshd/iql":"^0.0.4","ts-simple-nameof":"^1.3.1"},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -1804,6 +1804,7 @@ __exportStar(__webpack_require__(/*! ./settings */ "./dist/modules/settings/inde
|
|
|
1804
1804
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1805
1805
|
exports.NotificationsController = void 0;
|
|
1806
1806
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1807
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1807
1808
|
const ConsumptionBaseController_1 = __webpack_require__(/*! ../../consumption/ConsumptionBaseController */ "./dist/consumption/ConsumptionBaseController.js");
|
|
1808
1809
|
const ConsumptionControllerName_1 = __webpack_require__(/*! ../../consumption/ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js");
|
|
1809
1810
|
const LocalNotification_1 = __webpack_require__(/*! ./local/LocalNotification */ "./dist/modules/notifications/local/LocalNotification.js");
|
|
@@ -1816,6 +1817,17 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1816
1817
|
this.eventBus = eventBus;
|
|
1817
1818
|
this.device = device;
|
|
1818
1819
|
}
|
|
1820
|
+
async getNotifications(query) {
|
|
1821
|
+
const notifications = await this.localNotifications.find(query);
|
|
1822
|
+
return notifications.map((notification) => LocalNotification_1.LocalNotification.from(notification));
|
|
1823
|
+
}
|
|
1824
|
+
async getNotification(id) {
|
|
1825
|
+
const notification = await this.localNotifications.findOne({ id: id.toString() });
|
|
1826
|
+
if (!notification) {
|
|
1827
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalNotification_1.LocalNotification, id.toString());
|
|
1828
|
+
}
|
|
1829
|
+
return LocalNotification_1.LocalNotification.from(notification);
|
|
1830
|
+
}
|
|
1819
1831
|
async sent(message) {
|
|
1820
1832
|
if (!message.isOwn)
|
|
1821
1833
|
throw new Error("Cannot send a Notification from a foreign message.");
|
|
@@ -1864,12 +1876,20 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1864
1876
|
isOwn: false,
|
|
1865
1877
|
status: LocalNotification_1.LocalNotificationStatus.Open
|
|
1866
1878
|
});
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1869
|
-
await this.process(notification);
|
|
1879
|
+
for (const notificationDoc of notifications) {
|
|
1880
|
+
const notification = LocalNotification_1.LocalNotification.from(notificationDoc);
|
|
1881
|
+
await this.process(notificationDoc, notification);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
async processNotificationById(notificationId) {
|
|
1885
|
+
const notificationDoc = await this.localNotifications.findOne({ id: notificationId.toString() });
|
|
1886
|
+
if (!notificationDoc) {
|
|
1887
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalNotification_1.LocalNotification, notificationId.toString());
|
|
1870
1888
|
}
|
|
1889
|
+
const parsed = LocalNotification_1.LocalNotification.from(notificationDoc);
|
|
1890
|
+
return await this.process(notificationDoc, parsed);
|
|
1871
1891
|
}
|
|
1872
|
-
async process(notification) {
|
|
1892
|
+
async process(oldDoc, notification) {
|
|
1873
1893
|
if (notification.isOwn)
|
|
1874
1894
|
throw new Error("Cannot process own notification.");
|
|
1875
1895
|
if (!notification.receivedByDevice?.equals(this.device.id)) {
|
|
@@ -1878,7 +1898,6 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1878
1898
|
if (![LocalNotification_1.LocalNotificationStatus.Open, LocalNotification_1.LocalNotificationStatus.Error].includes(notification.status)) {
|
|
1879
1899
|
throw new Error(`Cannot process notification with status ${notification.status}.`);
|
|
1880
1900
|
}
|
|
1881
|
-
const oldDoc = await this.localNotifications.findOne({ id: notification.id.toString() });
|
|
1882
1901
|
const processedItems = [];
|
|
1883
1902
|
const events = [];
|
|
1884
1903
|
try {
|