@nmshd/runtime 4.2.0 → 4.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.
- package/dist/buildInformation.js +4 -4
- package/dist/useCases/transport/messages/SendMessage.d.ts +4 -1
- package/dist/useCases/transport/messages/SendMessage.d.ts.map +1 -1
- package/dist/useCases/transport/messages/SendMessage.js +34 -1
- package/dist/useCases/transport/messages/SendMessage.js.map +1 -1
- package/lib-web/nmshd.runtime.js +38 -5
- package/lib-web/nmshd.runtime.js.map +1 -1
- package/lib-web/nmshd.runtime.min.js +1 -1
- package/lib-web/nmshd.runtime.min.js.map +1 -1
- package/package.json +1 -1
package/dist/buildInformation.js
CHANGED
|
@@ -7,10 +7,10 @@ const content_1 = require("@nmshd/content");
|
|
|
7
7
|
const crypto_1 = require("@nmshd/crypto");
|
|
8
8
|
const transport_1 = require("@nmshd/transport");
|
|
9
9
|
exports.buildInformation = {
|
|
10
|
-
version: "4.
|
|
11
|
-
build: "
|
|
12
|
-
date: "2024-
|
|
13
|
-
commit: "
|
|
10
|
+
version: "4.3.0",
|
|
11
|
+
build: "37",
|
|
12
|
+
date: "2024-03-05T07:33:44+00:00",
|
|
13
|
+
commit: "4189c922aafef4f9530c86b5deeba13685d2e99b",
|
|
14
14
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.2","@js-soft/logging-abstractions":"^1.0.1","@js-soft/ts-serval":"2.0.10","@js-soft/ts-utils":"^2.3.3","@nmshd/consumption":"3.9.5","@nmshd/content":"2.8.7","@nmshd/crypto":"2.0.6","@nmshd/transport":"2.3.4","ajv":"^8.12.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qrcode":"1.5.3","reflect-metadata":"^0.2.1","ts-simple-nameof":"^1.3.1","typescript-ioc":"3.2.2"},
|
|
15
15
|
libraries: {
|
|
16
16
|
serval: ts_serval_1.buildInformation,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Result } from "@js-soft/ts-utils";
|
|
2
|
+
import { OutgoingRequestsController } from "@nmshd/consumption";
|
|
2
3
|
import { AccountController, FileController, MessageController } from "@nmshd/transport";
|
|
3
4
|
import { MessageDTO } from "../../../types";
|
|
4
5
|
import { AddressString, FileIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common";
|
|
@@ -17,8 +18,10 @@ export declare class SendMessageUseCase extends UseCase<SendMessageRequest, Mess
|
|
|
17
18
|
private readonly messageController;
|
|
18
19
|
private readonly fileController;
|
|
19
20
|
private readonly accountController;
|
|
20
|
-
|
|
21
|
+
private readonly outgoingRequestsController;
|
|
22
|
+
constructor(messageController: MessageController, fileController: FileController, accountController: AccountController, outgoingRequestsController: OutgoingRequestsController, validator: Validator);
|
|
21
23
|
protected executeInternal(request: SendMessageRequest): Promise<Result<MessageDTO>>;
|
|
24
|
+
private validateMessageContent;
|
|
22
25
|
private transformAttachments;
|
|
23
26
|
}
|
|
24
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SendMessage.d.ts","sourceRoot":"","sources":["../../../../src/useCases/transport/messages/SendMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SendMessage.d.ts","sourceRoot":"","sources":["../../../../src/useCases/transport/messages/SendMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAA6B,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGnH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAiB,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGtH,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,OAAO,EAAE,GAAG,CAAC;IAEb,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED,cAAM,SAAU,SAAQ,eAAe,CAAC,kBAAkB,CAAC;gBAC5B,gBAAgB,EAAE,gBAAgB;CAGhE;AAED,qBAAa,kBAAmB,SAAQ,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC;IAE/D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,0BAA0B;gBAH1B,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,0BAA0B,EAAE,0BAA0B,EACvE,SAAS,EAAE,SAAS;cAKhB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAoB3E,sBAAsB;YAuBtB,oBAAoB;CAkBrC"}
|
|
@@ -11,10 +11,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.SendMessageUseCase = void 0;
|
|
19
|
+
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
16
20
|
const ts_utils_1 = require("@js-soft/ts-utils");
|
|
21
|
+
const consumption_1 = require("@nmshd/consumption");
|
|
22
|
+
const content_1 = require("@nmshd/content");
|
|
17
23
|
const transport_1 = require("@nmshd/transport");
|
|
24
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
18
25
|
const typescript_ioc_1 = require("typescript-ioc");
|
|
19
26
|
const common_1 = require("../../common");
|
|
20
27
|
const MessageMapper_1 = require("./MessageMapper");
|
|
@@ -28,13 +35,17 @@ Validator = __decorate([
|
|
|
28
35
|
__metadata("design:paramtypes", [common_1.SchemaRepository])
|
|
29
36
|
], Validator);
|
|
30
37
|
let SendMessageUseCase = class SendMessageUseCase extends common_1.UseCase {
|
|
31
|
-
constructor(messageController, fileController, accountController, validator) {
|
|
38
|
+
constructor(messageController, fileController, accountController, outgoingRequestsController, validator) {
|
|
32
39
|
super(validator);
|
|
33
40
|
this.messageController = messageController;
|
|
34
41
|
this.fileController = fileController;
|
|
35
42
|
this.accountController = accountController;
|
|
43
|
+
this.outgoingRequestsController = outgoingRequestsController;
|
|
36
44
|
}
|
|
37
45
|
async executeInternal(request) {
|
|
46
|
+
const validationError = await this.validateMessageContent(request.content, request.recipients);
|
|
47
|
+
if (validationError)
|
|
48
|
+
return ts_utils_1.Result.fail(validationError);
|
|
38
49
|
const transformAttachmentsResult = await this.transformAttachments(request.attachments);
|
|
39
50
|
if (transformAttachmentsResult.isError) {
|
|
40
51
|
return ts_utils_1.Result.fail(transformAttachmentsResult.error);
|
|
@@ -47,6 +58,26 @@ let SendMessageUseCase = class SendMessageUseCase extends common_1.UseCase {
|
|
|
47
58
|
await this.accountController.syncDatawallet();
|
|
48
59
|
return ts_utils_1.Result.ok(MessageMapper_1.MessageMapper.toMessageDTO(result));
|
|
49
60
|
}
|
|
61
|
+
async validateMessageContent(content, recipients) {
|
|
62
|
+
const transformedContent = ts_serval_1.Serializable.fromUnknown(content);
|
|
63
|
+
if (!(transformedContent instanceof content_1.Request))
|
|
64
|
+
return;
|
|
65
|
+
if (typeof transformedContent.id === "undefined") {
|
|
66
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("The Request must have an id.");
|
|
67
|
+
}
|
|
68
|
+
const localRequest = await this.outgoingRequestsController.getOutgoingRequest(transformedContent.id);
|
|
69
|
+
if (!localRequest)
|
|
70
|
+
return common_1.RuntimeErrors.general.recordNotFound(content_1.Request);
|
|
71
|
+
if (!lodash_1.default.isEqual(transformedContent.toJSON(), localRequest.content.toJSON())) {
|
|
72
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("The sent Request must have the same content as the LocalRequest.");
|
|
73
|
+
}
|
|
74
|
+
if (recipients.length > 1)
|
|
75
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("Only one recipient is allowed for sending Requests.");
|
|
76
|
+
const recipient = transport_1.CoreAddress.from(recipients[0]);
|
|
77
|
+
if (!recipient.equals(localRequest.peer))
|
|
78
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("The recipient does not match the Request's peer.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
50
81
|
async transformAttachments(attachmentsIds) {
|
|
51
82
|
if (!attachmentsIds || attachmentsIds.length === 0) {
|
|
52
83
|
return ts_utils_1.Result.ok([]);
|
|
@@ -68,9 +99,11 @@ exports.SendMessageUseCase = SendMessageUseCase = __decorate([
|
|
|
68
99
|
__param(1, typescript_ioc_1.Inject),
|
|
69
100
|
__param(2, typescript_ioc_1.Inject),
|
|
70
101
|
__param(3, typescript_ioc_1.Inject),
|
|
102
|
+
__param(4, typescript_ioc_1.Inject),
|
|
71
103
|
__metadata("design:paramtypes", [transport_1.MessageController,
|
|
72
104
|
transport_1.FileController,
|
|
73
105
|
transport_1.AccountController,
|
|
106
|
+
consumption_1.OutgoingRequestsController,
|
|
74
107
|
Validator])
|
|
75
108
|
], SendMessageUseCase);
|
|
76
109
|
//# sourceMappingURL=SendMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SendMessage.js","sourceRoot":"","sources":["../../../../src/useCases/transport/messages/SendMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SendMessage.js","sourceRoot":"","sources":["../../../../src/useCases/transport/messages/SendMessage.ts"],"names":[],"mappings":";;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pack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
45718
45718
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
45719
45719
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
45720
45720
|
exports.buildInformation = {
|
|
45721
|
-
version: "4.
|
|
45722
|
-
build: "
|
|
45723
|
-
date: "2024-
|
|
45724
|
-
commit: "
|
|
45721
|
+
version: "4.3.0",
|
|
45722
|
+
build: "37",
|
|
45723
|
+
date: "2024-03-05T07:33:44+00:00",
|
|
45724
|
+
commit: "4189c922aafef4f9530c86b5deeba13685d2e99b",
|
|
45725
45725
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.2","@js-soft/logging-abstractions":"^1.0.1","@js-soft/ts-serval":"2.0.10","@js-soft/ts-utils":"^2.3.3","@nmshd/consumption":"3.9.5","@nmshd/content":"2.8.7","@nmshd/crypto":"2.0.6","@nmshd/transport":"2.3.4","ajv":"^8.12.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.4","qrcode":"1.5.3","reflect-metadata":"^0.2.1","ts-simple-nameof":"^1.3.1","typescript-ioc":"3.2.2"},
|
|
45726
45726
|
libraries: {
|
|
45727
45727
|
serval: ts_serval_1.buildInformation,
|
|
@@ -81080,10 +81080,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
81080
81080
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
81081
81081
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
81082
81082
|
};
|
|
81083
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
81084
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
81085
|
+
};
|
|
81083
81086
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
81084
81087
|
exports.SendMessageUseCase = void 0;
|
|
81088
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
81085
81089
|
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "../../node_modules/@js-soft/ts-utils/dist/index.js");
|
|
81090
|
+
const consumption_1 = __webpack_require__(/*! @nmshd/consumption */ "@nmshd/consumption");
|
|
81091
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
81086
81092
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
81093
|
+
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "../../node_modules/lodash/lodash.js"));
|
|
81087
81094
|
const typescript_ioc_1 = __webpack_require__(/*! typescript-ioc */ "../../node_modules/typescript-ioc/dist/typescript-ioc.js");
|
|
81088
81095
|
const common_1 = __webpack_require__(/*! ../../common */ "./dist/useCases/common/index.js");
|
|
81089
81096
|
const MessageMapper_1 = __webpack_require__(/*! ./MessageMapper */ "./dist/useCases/transport/messages/MessageMapper.js");
|
|
@@ -81097,13 +81104,17 @@ Validator = __decorate([
|
|
|
81097
81104
|
__metadata("design:paramtypes", [common_1.SchemaRepository])
|
|
81098
81105
|
], Validator);
|
|
81099
81106
|
let SendMessageUseCase = class SendMessageUseCase extends common_1.UseCase {
|
|
81100
|
-
constructor(messageController, fileController, accountController, validator) {
|
|
81107
|
+
constructor(messageController, fileController, accountController, outgoingRequestsController, validator) {
|
|
81101
81108
|
super(validator);
|
|
81102
81109
|
this.messageController = messageController;
|
|
81103
81110
|
this.fileController = fileController;
|
|
81104
81111
|
this.accountController = accountController;
|
|
81112
|
+
this.outgoingRequestsController = outgoingRequestsController;
|
|
81105
81113
|
}
|
|
81106
81114
|
async executeInternal(request) {
|
|
81115
|
+
const validationError = await this.validateMessageContent(request.content, request.recipients);
|
|
81116
|
+
if (validationError)
|
|
81117
|
+
return ts_utils_1.Result.fail(validationError);
|
|
81107
81118
|
const transformAttachmentsResult = await this.transformAttachments(request.attachments);
|
|
81108
81119
|
if (transformAttachmentsResult.isError) {
|
|
81109
81120
|
return ts_utils_1.Result.fail(transformAttachmentsResult.error);
|
|
@@ -81116,6 +81127,26 @@ let SendMessageUseCase = class SendMessageUseCase extends common_1.UseCase {
|
|
|
81116
81127
|
await this.accountController.syncDatawallet();
|
|
81117
81128
|
return ts_utils_1.Result.ok(MessageMapper_1.MessageMapper.toMessageDTO(result));
|
|
81118
81129
|
}
|
|
81130
|
+
async validateMessageContent(content, recipients) {
|
|
81131
|
+
const transformedContent = ts_serval_1.Serializable.fromUnknown(content);
|
|
81132
|
+
if (!(transformedContent instanceof content_1.Request))
|
|
81133
|
+
return;
|
|
81134
|
+
if (typeof transformedContent.id === "undefined") {
|
|
81135
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("The Request must have an id.");
|
|
81136
|
+
}
|
|
81137
|
+
const localRequest = await this.outgoingRequestsController.getOutgoingRequest(transformedContent.id);
|
|
81138
|
+
if (!localRequest)
|
|
81139
|
+
return common_1.RuntimeErrors.general.recordNotFound(content_1.Request);
|
|
81140
|
+
if (!lodash_1.default.isEqual(transformedContent.toJSON(), localRequest.content.toJSON())) {
|
|
81141
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("The sent Request must have the same content as the LocalRequest.");
|
|
81142
|
+
}
|
|
81143
|
+
if (recipients.length > 1)
|
|
81144
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("Only one recipient is allowed for sending Requests.");
|
|
81145
|
+
const recipient = transport_1.CoreAddress.from(recipients[0]);
|
|
81146
|
+
if (!recipient.equals(localRequest.peer))
|
|
81147
|
+
return common_1.RuntimeErrors.general.invalidPropertyValue("The recipient does not match the Request's peer.");
|
|
81148
|
+
return;
|
|
81149
|
+
}
|
|
81119
81150
|
async transformAttachments(attachmentsIds) {
|
|
81120
81151
|
if (!attachmentsIds || attachmentsIds.length === 0) {
|
|
81121
81152
|
return ts_utils_1.Result.ok([]);
|
|
@@ -81137,9 +81168,11 @@ exports.SendMessageUseCase = SendMessageUseCase = __decorate([
|
|
|
81137
81168
|
__param(1, typescript_ioc_1.Inject),
|
|
81138
81169
|
__param(2, typescript_ioc_1.Inject),
|
|
81139
81170
|
__param(3, typescript_ioc_1.Inject),
|
|
81171
|
+
__param(4, typescript_ioc_1.Inject),
|
|
81140
81172
|
__metadata("design:paramtypes", [transport_1.MessageController,
|
|
81141
81173
|
transport_1.FileController,
|
|
81142
81174
|
transport_1.AccountController,
|
|
81175
|
+
consumption_1.OutgoingRequestsController,
|
|
81143
81176
|
Validator])
|
|
81144
81177
|
], SendMessageUseCase);
|
|
81145
81178
|
//# sourceMappingURL=SendMessage.js.map
|