@nmshd/consumption 2.0.0-beta.8 → 2.0.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/consumption/ConsumptionBaseController.d.ts +1 -1
- package/dist/consumption/ConsumptionBaseController.js +2 -3
- package/dist/consumption/ConsumptionBaseController.js.map +1 -1
- package/dist/consumption/ConsumptionController.d.ts +4 -8
- package/dist/consumption/ConsumptionController.js +13 -14
- package/dist/consumption/ConsumptionController.js.map +1 -1
- package/dist/consumption/ConsumptionControllerName.d.ts +2 -1
- package/dist/consumption/ConsumptionControllerName.js +2 -1
- package/dist/consumption/ConsumptionControllerName.js.map +1 -1
- package/dist/consumption/ConsumptionError.d.ts +2 -0
- package/dist/consumption/ConsumptionError.js +7 -0
- package/dist/consumption/ConsumptionError.js.map +1 -0
- package/dist/consumption/ConsumptionIds.d.ts +1 -0
- package/dist/consumption/ConsumptionIds.js +1 -0
- package/dist/consumption/ConsumptionIds.js.map +1 -1
- package/dist/consumption/{ConsumptionErrors.d.ts → CoreErrors.d.ts} +3 -15
- package/dist/consumption/CoreErrors.js +47 -0
- package/dist/consumption/CoreErrors.js.map +1 -0
- package/dist/consumption/index.d.ts +2 -1
- package/dist/consumption/index.js +2 -1
- package/dist/consumption/index.js.map +1 -1
- package/dist/modules/attributeListeners/AttributeListenersController.d.ts +18 -0
- package/dist/modules/attributeListeners/AttributeListenersController.js +44 -0
- package/dist/modules/attributeListeners/AttributeListenersController.js.map +1 -0
- package/dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.d.ts +6 -0
- package/dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js +12 -0
- package/dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js.map +1 -0
- package/dist/modules/attributeListeners/events/index.d.ts +1 -0
- package/dist/modules/attributeListeners/events/index.js +18 -0
- package/dist/modules/attributeListeners/events/index.js.map +1 -0
- package/dist/modules/attributeListeners/index.d.ts +4 -0
- package/dist/modules/attributeListeners/index.js +21 -0
- package/dist/modules/attributeListeners/index.js.map +1 -0
- package/dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.d.ts +12 -0
- package/dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js +35 -0
- package/dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js.map +1 -0
- package/dist/modules/attributeListeners/local/LocalAttributeListener.d.ts +19 -0
- package/dist/modules/attributeListeners/local/LocalAttributeListener.js +46 -0
- package/dist/modules/attributeListeners/local/LocalAttributeListener.js.map +1 -0
- package/dist/modules/attributes/{LocalAttributesController.d.ts → AttributesController.d.ts} +5 -3
- package/dist/modules/attributes/{LocalAttributesController.js → AttributesController.js} +56 -18
- package/dist/modules/attributes/AttributesController.js.map +1 -0
- package/dist/modules/attributes/index.d.ts +9 -0
- package/dist/modules/attributes/index.js +26 -0
- package/dist/modules/attributes/index.js.map +1 -0
- package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.d.ts → CreateAttributeParams.d.ts} +3 -3
- package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.js → CreateAttributeParams.js} +10 -10
- package/dist/modules/attributes/local/CreateAttributeParams.js.map +1 -0
- package/dist/modules/attributes/local/CreateLocalAttributeParams.d.ts +3 -0
- package/dist/modules/attributes/local/CreateLocalAttributeParams.js +6 -0
- package/dist/modules/attributes/local/CreateLocalAttributeParams.js.map +1 -1
- package/dist/modules/attributes/local/CreatePeerLocalAttributeParams.js.map +1 -1
- package/dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js.map +1 -1
- package/dist/modules/attributes/local/LocalAttribute.d.ts +15 -2
- package/dist/modules/attributes/local/LocalAttribute.js +25 -4
- package/dist/modules/attributes/local/LocalAttribute.js.map +1 -1
- package/dist/modules/attributes/local/LocalAttributeShareInfo.js.map +1 -1
- package/dist/modules/attributes/local/QueryTranslator.d.ts +5 -1
- package/dist/modules/attributes/local/QueryTranslator.js +52 -7
- package/dist/modules/attributes/local/QueryTranslator.js.map +1 -1
- package/dist/modules/attributes/local/SucceedLocalAttributeParams.js.map +1 -1
- package/dist/modules/attributes/local/UpdateLocalAttributeParams.js.map +1 -1
- package/dist/modules/drafts/DraftsController.js +3 -3
- package/dist/modules/drafts/DraftsController.js.map +1 -1
- package/dist/modules/drafts/index.d.ts +2 -0
- package/dist/modules/drafts/index.js +19 -0
- package/dist/modules/drafts/index.js.map +1 -0
- package/dist/modules/drafts/local/Draft.js.map +1 -1
- package/dist/modules/index.d.ts +5 -50
- package/dist/modules/index.js +5 -49
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/requests/events/IncomingRequestReceivedEvent.js +2 -1
- package/dist/modules/requests/events/IncomingRequestReceivedEvent.js.map +1 -1
- package/dist/modules/requests/events/IncomingRequestStatusChangedEvent.js +2 -1
- package/dist/modules/requests/events/IncomingRequestStatusChangedEvent.js.map +1 -1
- package/dist/modules/requests/events/OutgoingRequestCreatedEvent.d.ts +1 -1
- package/dist/modules/requests/events/OutgoingRequestCreatedEvent.js +2 -1
- package/dist/modules/requests/events/OutgoingRequestCreatedEvent.js.map +1 -1
- package/dist/modules/requests/events/OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.d.ts +1 -1
- package/dist/modules/requests/events/OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.js +2 -1
- package/dist/modules/requests/events/OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.js.map +1 -1
- package/dist/modules/requests/events/OutgoingRequestStatusChangedEvent.js +2 -1
- package/dist/modules/requests/events/OutgoingRequestStatusChangedEvent.js.map +1 -1
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.js +9 -9
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.js.map +1 -1
- package/dist/modules/requests/incoming/IncomingRequestsController.d.ts +1 -0
- package/dist/modules/requests/incoming/IncomingRequestsController.js +29 -20
- package/dist/modules/requests/incoming/IncomingRequestsController.js.map +1 -1
- package/dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/InternalDecideRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/index.d.ts +36 -0
- package/dist/modules/requests/index.js +52 -0
- package/dist/modules/requests/index.js.map +1 -0
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/IRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js +3 -2
- package/dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js.map +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.d.ts +11 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +70 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -0
- package/dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.d.ts +18 -9
- package/dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js +12 -3
- package/dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js +6 -6
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js +4 -2
- package/dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js +2 -2
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.d.ts +7 -0
- package/dist/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.js +19 -0
- package/dist/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.js.map +1 -0
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.d.ts +4 -4
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js +8 -5
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/utility/validateQuery.d.ts +2 -2
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js +7 -7
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js.map +1 -1
- package/dist/modules/requests/local/LocalRequest.d.ts +2 -0
- package/dist/modules/requests/local/LocalRequest.js +18 -1
- package/dist/modules/requests/local/LocalRequest.js.map +1 -1
- package/dist/modules/requests/local/LocalRequestStatus.d.ts +2 -1
- package/dist/modules/requests/local/LocalRequestStatus.js +1 -0
- package/dist/modules/requests/local/LocalRequestStatus.js.map +1 -1
- package/dist/modules/requests/local/LocalRequestStatusLogEntry.js.map +1 -1
- package/dist/modules/requests/local/LocalResponse.js.map +1 -1
- package/dist/modules/requests/outgoing/OutgoingRequestsController.d.ts +5 -2
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js +45 -28
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js.map +1 -1
- package/dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js.map +1 -1
- package/dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js.map +1 -1
- package/dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.d.ts +13 -0
- package/dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js +35 -0
- package/dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js.map +1 -0
- package/dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.d.ts +4 -3
- package/dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js.map +1 -1
- package/dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js.map +1 -1
- package/dist/modules/settings/SettingsController.js +19 -4
- package/dist/modules/settings/SettingsController.js.map +1 -1
- package/dist/modules/settings/index.d.ts +3 -0
- package/dist/modules/settings/index.js +20 -0
- package/dist/modules/settings/index.js.map +1 -0
- package/dist/modules/settings/local/Setting.js.map +1 -1
- package/lib-web/nmshd.consumption.js +1037 -386
- 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 +20 -20
- package/dist/consumption/ConsumptionErrors.js +0 -71
- package/dist/consumption/ConsumptionErrors.js.map +0 -1
- package/dist/modules/attributes/LocalAttributesController.js.map +0 -1
- package/dist/modules/attributes/local/CreateRelationshipAttributeParams.js.map +0 -1
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.d.ts +0 -7
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js +0 -20
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js.map +0 -1
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.d.ts +0 -11
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js +0 -44
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js.map +0 -1
- package/dist/modules/requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters.d.ts +0 -7
- package/dist/modules/requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters.js +0 -20
- package/dist/modules/requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters.js.map +0 -1
|
@@ -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: "2.0.0
|
|
21
|
-
build: "
|
|
22
|
-
date: "2022-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "2.0.0",
|
|
21
|
+
build: "86",
|
|
22
|
+
date: "2022-10-24T08:29:10+00:00",
|
|
23
|
+
commit: "dcae87f31a2e5eafa046793eb2e8a0d5d09d9269",
|
|
24
24
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.0","ts-simple-nameof":"^1.3.1"},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -58,9 +58,8 @@ class ConsumptionBaseController {
|
|
|
58
58
|
init() {
|
|
59
59
|
return Promise.resolve(this);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return await Promise.all(parsePromises);
|
|
61
|
+
parseArray(values, type) {
|
|
62
|
+
return values.map((v) => type.fromAny(v));
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
exports.ConsumptionBaseController = ConsumptionBaseController;
|
|
@@ -80,12 +79,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
80
79
|
exports.ConsumptionController = void 0;
|
|
81
80
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
82
81
|
const modules_1 = __webpack_require__(/*! ../modules */ "./dist/modules/index.js");
|
|
83
|
-
const LocalAttributesController_1 = __webpack_require__(/*! ../modules/attributes/LocalAttributesController */ "./dist/modules/attributes/LocalAttributesController.js");
|
|
84
|
-
const DraftsController_1 = __webpack_require__(/*! ../modules/drafts/DraftsController */ "./dist/modules/drafts/DraftsController.js");
|
|
85
|
-
const IncomingRequestsController_1 = __webpack_require__(/*! ../modules/requests/incoming/IncomingRequestsController */ "./dist/modules/requests/incoming/IncomingRequestsController.js");
|
|
86
|
-
const RequestItemProcessorRegistry_1 = __webpack_require__(/*! ../modules/requests/itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js");
|
|
87
|
-
const OutgoingRequestsController_1 = __webpack_require__(/*! ../modules/requests/outgoing/OutgoingRequestsController */ "./dist/modules/requests/outgoing/OutgoingRequestsController.js");
|
|
88
|
-
const SettingsController_1 = __webpack_require__(/*! ../modules/settings/SettingsController */ "./dist/modules/settings/SettingsController.js");
|
|
89
82
|
class ConsumptionController {
|
|
90
83
|
constructor(transport, accountController) {
|
|
91
84
|
this.transport = transport;
|
|
@@ -106,26 +99,31 @@ class ConsumptionController {
|
|
|
106
99
|
get settings() {
|
|
107
100
|
return this._settings;
|
|
108
101
|
}
|
|
102
|
+
get attributeListeners() {
|
|
103
|
+
return this._attributeListeners;
|
|
104
|
+
}
|
|
109
105
|
async init(requestItemProcessorOverrides = new Map()) {
|
|
110
|
-
this._attributes = await new
|
|
111
|
-
this._drafts = await new
|
|
112
|
-
const processorRegistry = new
|
|
106
|
+
this._attributes = await new modules_1.AttributesController(this, this.transport.eventBus, this.accountController.identity).init();
|
|
107
|
+
this._drafts = await new modules_1.DraftsController(this).init();
|
|
108
|
+
const processorRegistry = new modules_1.RequestItemProcessorRegistry(this, this.getDefaultProcessors());
|
|
113
109
|
for (const [itemConstructor, processorConstructor] of requestItemProcessorOverrides) {
|
|
114
110
|
processorRegistry.registerOrReplaceProcessor(itemConstructor, processorConstructor);
|
|
115
111
|
}
|
|
116
|
-
this._outgoingRequests = await new
|
|
117
|
-
this._incomingRequests = await new
|
|
118
|
-
this._settings = await new
|
|
112
|
+
this._outgoingRequests = await new modules_1.OutgoingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this, this.transport.eventBus, this.accountController.identity).init();
|
|
113
|
+
this._incomingRequests = await new modules_1.IncomingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this, this.transport.eventBus, this.accountController.identity).init();
|
|
114
|
+
this._settings = await new modules_1.SettingsController(this).init();
|
|
115
|
+
this._attributeListeners = await new modules_1.AttributeListenersController(this, this.transport.eventBus, this.accountController.identity).init();
|
|
119
116
|
return this;
|
|
120
117
|
}
|
|
121
118
|
getDefaultProcessors() {
|
|
122
119
|
return new Map([
|
|
123
120
|
[content_1.ShareAttributeRequestItem, modules_1.ShareAttributeRequestItemProcessor],
|
|
124
|
-
[content_1.
|
|
121
|
+
[content_1.CreateAttributeRequestItem, modules_1.CreateAttributeRequestItemProcessor],
|
|
125
122
|
[content_1.ReadAttributeRequestItem, modules_1.ReadAttributeRequestItemProcessor],
|
|
126
123
|
[content_1.ProposeAttributeRequestItem, modules_1.ProposeAttributeRequestItemProcessor],
|
|
127
124
|
[content_1.ConsentRequestItem, modules_1.GenericRequestItemProcessor],
|
|
128
|
-
[content_1.AuthenticationRequestItem, modules_1.GenericRequestItemProcessor]
|
|
125
|
+
[content_1.AuthenticationRequestItem, modules_1.GenericRequestItemProcessor],
|
|
126
|
+
[content_1.RegisterAttributeListenerRequestItem, modules_1.RegisterAttributeListenerRequestItemProcessor]
|
|
129
127
|
]);
|
|
130
128
|
}
|
|
131
129
|
}
|
|
@@ -146,7 +144,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
146
144
|
exports.ConsumptionControllerName = void 0;
|
|
147
145
|
var ConsumptionControllerName;
|
|
148
146
|
(function (ConsumptionControllerName) {
|
|
149
|
-
ConsumptionControllerName["
|
|
147
|
+
ConsumptionControllerName["AttributesController"] = "AttributesController";
|
|
148
|
+
ConsumptionControllerName["AttributeListenersController"] = "AttributeListenersController";
|
|
150
149
|
ConsumptionControllerName["DraftsController"] = "DraftsController";
|
|
151
150
|
ConsumptionControllerName["RelationshipInfoController"] = "RelationshipInfoController";
|
|
152
151
|
ConsumptionControllerName["SingleRelationshipController"] = "SingleRelationshipController";
|
|
@@ -160,106 +159,100 @@ var ConsumptionControllerName;
|
|
|
160
159
|
|
|
161
160
|
/***/ }),
|
|
162
161
|
|
|
163
|
-
/***/ "./dist/consumption/
|
|
164
|
-
|
|
165
|
-
!*** ./dist/consumption/
|
|
166
|
-
|
|
162
|
+
/***/ "./dist/consumption/ConsumptionError.js":
|
|
163
|
+
/*!**********************************************!*\
|
|
164
|
+
!*** ./dist/consumption/ConsumptionError.js ***!
|
|
165
|
+
\**********************************************/
|
|
166
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
167
|
+
|
|
168
|
+
"use strict";
|
|
169
|
+
|
|
170
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
171
|
+
exports.ConsumptionError = void 0;
|
|
172
|
+
class ConsumptionError extends Error {
|
|
173
|
+
}
|
|
174
|
+
exports.ConsumptionError = ConsumptionError;
|
|
175
|
+
//# sourceMappingURL=ConsumptionError.js.map
|
|
176
|
+
|
|
177
|
+
/***/ }),
|
|
178
|
+
|
|
179
|
+
/***/ "./dist/consumption/ConsumptionIds.js":
|
|
180
|
+
/*!********************************************!*\
|
|
181
|
+
!*** ./dist/consumption/ConsumptionIds.js ***!
|
|
182
|
+
\********************************************/
|
|
167
183
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
168
184
|
|
|
169
185
|
"use strict";
|
|
170
186
|
|
|
171
187
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
172
|
-
exports.
|
|
188
|
+
exports.ConsumptionIds = void 0;
|
|
189
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
190
|
+
class ConsumptionIds {
|
|
191
|
+
}
|
|
192
|
+
exports.ConsumptionIds = ConsumptionIds;
|
|
193
|
+
ConsumptionIds.draft = new transport_1.CoreIdHelper("LCLDRF");
|
|
194
|
+
ConsumptionIds.setting = new transport_1.CoreIdHelper("LCLSET");
|
|
195
|
+
ConsumptionIds.attribute = new transport_1.CoreIdHelper("ATT");
|
|
196
|
+
ConsumptionIds.request = new transport_1.CoreIdHelper("REQ");
|
|
197
|
+
ConsumptionIds.attributeListener = new transport_1.CoreIdHelper("ATL");
|
|
198
|
+
//# sourceMappingURL=ConsumptionIds.js.map
|
|
199
|
+
|
|
200
|
+
/***/ }),
|
|
201
|
+
|
|
202
|
+
/***/ "./dist/consumption/CoreErrors.js":
|
|
203
|
+
/*!****************************************!*\
|
|
204
|
+
!*** ./dist/consumption/CoreErrors.js ***!
|
|
205
|
+
\****************************************/
|
|
206
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
207
|
+
|
|
208
|
+
"use strict";
|
|
209
|
+
|
|
210
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
211
|
+
exports.CoreErrors = void 0;
|
|
173
212
|
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
174
213
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
175
214
|
class Attributes {
|
|
176
|
-
|
|
177
|
-
return new transport_1.CoreError("error.consumption.attributes.
|
|
178
|
-
}
|
|
179
|
-
predecessorNotFound(id) {
|
|
180
|
-
return new transport_1.CoreError("error.consumption.attributes.predecessorNotFound", `Attribute with id '${id}' does not exist. Please use create instead.`);
|
|
215
|
+
cannotSucceedAttributesWithAParent(parentId) {
|
|
216
|
+
return new transport_1.CoreError("error.consumption.attributes.cannotSucceedAttributesWithAParent", `The Attribute you want to succeed has a parent (id: ${parentId.toString()}). You cannot succeed Attributes with a parent. Instead, succeed the parent, which will implicitly succeed all its children.`);
|
|
181
217
|
}
|
|
182
218
|
}
|
|
183
219
|
class Requests {
|
|
184
220
|
constructor() {
|
|
185
221
|
this.decideValidation = new Requests._decideValidation();
|
|
186
222
|
}
|
|
187
|
-
requestExists(id) {
|
|
188
|
-
return new transport_1.CoreError("error.consumption.requests.requestExists", `Request with id ${id} already exists and can't be created.`);
|
|
189
|
-
}
|
|
190
223
|
unexpectedErrorDuringRequestItemProcessing(error) {
|
|
191
|
-
return new transport_1.CoreError("error.consumption.requests.unexpectedErrorDuringRequestItemProcessing", error instanceof Error ? error.message :
|
|
224
|
+
return new transport_1.CoreError("error.consumption.requests.unexpectedErrorDuringRequestItemProcessing", error instanceof Error ? error.message : `Unknown error: '${JSON.stringify(error)}'`, undefined, undefined, error);
|
|
192
225
|
}
|
|
193
226
|
servalErrorDuringRequestItemProcessing(error) {
|
|
194
|
-
return new transport_1.CoreError("error.consumption.requests.servalErrorDuringRequestItemProcessing", error instanceof Error ? error.message :
|
|
227
|
+
return new transport_1.CoreError("error.consumption.requests.servalErrorDuringRequestItemProcessing", error instanceof Error ? error.message : `Serval error: '${JSON.stringify(error)}'`, undefined, undefined, error);
|
|
195
228
|
}
|
|
196
229
|
invalidRequestItem(message) {
|
|
197
230
|
return new transport_1.CoreError("error.consumption.requests.invalidRequestItem", message);
|
|
198
231
|
}
|
|
199
232
|
}
|
|
200
233
|
Requests._decideValidation = class {
|
|
201
|
-
invalidRequestId() {
|
|
202
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.invalidRequestId", "The id of the Request does not match the id of the Response");
|
|
203
|
-
}
|
|
204
234
|
invalidNumberOfItems(message) {
|
|
205
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.invalidNumberOfItems", message);
|
|
235
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.invalidNumberOfItems", message);
|
|
206
236
|
}
|
|
207
237
|
itemAcceptedButParentNotAccepted(message) {
|
|
208
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.itemAcceptedButParentNotAccepted", message);
|
|
238
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.itemAcceptedButParentNotAccepted", message);
|
|
209
239
|
}
|
|
210
240
|
mustBeAcceptedItemNotAccepted(message) {
|
|
211
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.mustBeAcceptedItemNotAccepted", message);
|
|
241
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.mustBeAcceptedItemNotAccepted", message);
|
|
212
242
|
}
|
|
213
243
|
requestItemAnsweredAsRequestItemGroup() {
|
|
214
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.requestItemAnsweredAsRequestItemGroup", "The RequestItem was answered as a RequestItemGroup.");
|
|
244
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.requestItemAnsweredAsRequestItemGroup", "The RequestItem was answered as a RequestItemGroup.");
|
|
215
245
|
}
|
|
216
246
|
requestItemGroupAnsweredAsRequestItem() {
|
|
217
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.requestItemGroupAnsweredAsRequestItem", "The RequestItemGroup was answered as a RequestItem.");
|
|
247
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.requestItemGroupAnsweredAsRequestItem", "The RequestItemGroup was answered as a RequestItem.");
|
|
218
248
|
}
|
|
219
249
|
};
|
|
220
|
-
class
|
|
221
|
-
relationshipInfoExists(relationshipId) {
|
|
222
|
-
return new transport_1.CoreError("error.consumption.relationshipInfos.relationshipInfoExists", `RelationshipInfo for Relationship ${relationshipId} already exists.`);
|
|
223
|
-
}
|
|
250
|
+
class CoreErrors {
|
|
224
251
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
wrongTemplate() {
|
|
230
|
-
return new transport_1.CoreError("error.consumption.onboarding.wrongTemplate", "The given template is in the wrong format.");
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
class ConsumptionErrors {
|
|
234
|
-
}
|
|
235
|
-
exports.ConsumptionErrors = ConsumptionErrors;
|
|
236
|
-
ConsumptionErrors.attributes = new Attributes();
|
|
237
|
-
ConsumptionErrors.requests = new Requests();
|
|
238
|
-
ConsumptionErrors.relationshipInfo = new RelationshipInfo();
|
|
239
|
-
ConsumptionErrors.onboarding = new Onboarding();
|
|
240
|
-
//# sourceMappingURL=ConsumptionErrors.js.map
|
|
241
|
-
|
|
242
|
-
/***/ }),
|
|
243
|
-
|
|
244
|
-
/***/ "./dist/consumption/ConsumptionIds.js":
|
|
245
|
-
/*!********************************************!*\
|
|
246
|
-
!*** ./dist/consumption/ConsumptionIds.js ***!
|
|
247
|
-
\********************************************/
|
|
248
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
249
|
-
|
|
250
|
-
"use strict";
|
|
251
|
-
|
|
252
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
253
|
-
exports.ConsumptionIds = void 0;
|
|
254
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
255
|
-
class ConsumptionIds {
|
|
256
|
-
}
|
|
257
|
-
exports.ConsumptionIds = ConsumptionIds;
|
|
258
|
-
ConsumptionIds.draft = new transport_1.CoreIdHelper("LCLDRF");
|
|
259
|
-
ConsumptionIds.setting = new transport_1.CoreIdHelper("LCLSET");
|
|
260
|
-
ConsumptionIds.attribute = new transport_1.CoreIdHelper("ATT");
|
|
261
|
-
ConsumptionIds.request = new transport_1.CoreIdHelper("REQ");
|
|
262
|
-
//# sourceMappingURL=ConsumptionIds.js.map
|
|
252
|
+
exports.CoreErrors = CoreErrors;
|
|
253
|
+
CoreErrors.attributes = new Attributes();
|
|
254
|
+
CoreErrors.requests = new Requests();
|
|
255
|
+
//# sourceMappingURL=CoreErrors.js.map
|
|
263
256
|
|
|
264
257
|
/***/ }),
|
|
265
258
|
|
|
@@ -288,8 +281,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
288
281
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
289
282
|
__exportStar(__webpack_require__(/*! ./ConsumptionBaseController */ "./dist/consumption/ConsumptionBaseController.js"), exports);
|
|
290
283
|
__exportStar(__webpack_require__(/*! ./ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js"), exports);
|
|
291
|
-
__exportStar(__webpack_require__(/*! ./
|
|
284
|
+
__exportStar(__webpack_require__(/*! ./ConsumptionError */ "./dist/consumption/ConsumptionError.js"), exports);
|
|
292
285
|
__exportStar(__webpack_require__(/*! ./ConsumptionIds */ "./dist/consumption/ConsumptionIds.js"), exports);
|
|
286
|
+
__exportStar(__webpack_require__(/*! ./CoreErrors */ "./dist/consumption/CoreErrors.js"), exports);
|
|
293
287
|
//# sourceMappingURL=index.js.map
|
|
294
288
|
|
|
295
289
|
/***/ }),
|
|
@@ -325,16 +319,252 @@ __exportStar(__webpack_require__(/*! ./modules */ "./dist/modules/index.js"), ex
|
|
|
325
319
|
|
|
326
320
|
/***/ }),
|
|
327
321
|
|
|
328
|
-
/***/ "./dist/modules/
|
|
329
|
-
|
|
330
|
-
!*** ./dist/modules/
|
|
331
|
-
|
|
322
|
+
/***/ "./dist/modules/attributeListeners/AttributeListenersController.js":
|
|
323
|
+
/*!*************************************************************************!*\
|
|
324
|
+
!*** ./dist/modules/attributeListeners/AttributeListenersController.js ***!
|
|
325
|
+
\*************************************************************************/
|
|
326
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
327
|
+
|
|
328
|
+
"use strict";
|
|
329
|
+
|
|
330
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
331
|
+
exports.AttributeListenersController = void 0;
|
|
332
|
+
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
333
|
+
const ConsumptionBaseController_1 = __webpack_require__(/*! ../../consumption/ConsumptionBaseController */ "./dist/consumption/ConsumptionBaseController.js");
|
|
334
|
+
const ConsumptionControllerName_1 = __webpack_require__(/*! ../../consumption/ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js");
|
|
335
|
+
const events_1 = __webpack_require__(/*! ./events */ "./dist/modules/attributeListeners/events/index.js");
|
|
336
|
+
const CreateLocalAttributeListenerParams_1 = __webpack_require__(/*! ./local/CreateLocalAttributeListenerParams */ "./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js");
|
|
337
|
+
const LocalAttributeListener_1 = __webpack_require__(/*! ./local/LocalAttributeListener */ "./dist/modules/attributeListeners/local/LocalAttributeListener.js");
|
|
338
|
+
class AttributeListenersController extends ConsumptionBaseController_1.ConsumptionBaseController {
|
|
339
|
+
constructor(parent, eventBus, identity) {
|
|
340
|
+
super(ConsumptionControllerName_1.ConsumptionControllerName.AttributeListenersController, parent);
|
|
341
|
+
this.eventBus = eventBus;
|
|
342
|
+
this.identity = identity;
|
|
343
|
+
}
|
|
344
|
+
async init() {
|
|
345
|
+
await super.init();
|
|
346
|
+
this.attributeListeners = await this.parent.accountController.getSynchronizedCollection("AttributeListeners");
|
|
347
|
+
return this;
|
|
348
|
+
}
|
|
349
|
+
async getAttributeListeners(query) {
|
|
350
|
+
const items = await this.attributeListeners.find(query);
|
|
351
|
+
return this.parseArray(items, LocalAttributeListener_1.LocalAttributeListener);
|
|
352
|
+
}
|
|
353
|
+
async getAttributeListener(id) {
|
|
354
|
+
const listener = await this.attributeListeners.read(id.toString());
|
|
355
|
+
if (!listener)
|
|
356
|
+
return;
|
|
357
|
+
return LocalAttributeListener_1.LocalAttributeListener.from(listener);
|
|
358
|
+
}
|
|
359
|
+
async createAttributeListener(params) {
|
|
360
|
+
const parsedParams = CreateLocalAttributeListenerParams_1.CreateLocalAttributeListenerParams.from(params);
|
|
361
|
+
const listener = LocalAttributeListener_1.LocalAttributeListener.from({
|
|
362
|
+
id: await consumption_1.ConsumptionIds.attributeListener.generate(),
|
|
363
|
+
query: parsedParams.query,
|
|
364
|
+
peer: parsedParams.peer
|
|
365
|
+
});
|
|
366
|
+
await this.attributeListeners.create(listener);
|
|
367
|
+
this.eventBus.publish(new events_1.AttributeListenerCreatedEvent(this.identity.address.toString(), listener));
|
|
368
|
+
return listener;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
exports.AttributeListenersController = AttributeListenersController;
|
|
372
|
+
//# sourceMappingURL=AttributeListenersController.js.map
|
|
373
|
+
|
|
374
|
+
/***/ }),
|
|
375
|
+
|
|
376
|
+
/***/ "./dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js":
|
|
377
|
+
/*!*********************************************************************************!*\
|
|
378
|
+
!*** ./dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js ***!
|
|
379
|
+
\*********************************************************************************/
|
|
380
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
381
|
+
|
|
382
|
+
"use strict";
|
|
383
|
+
|
|
384
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
385
|
+
exports.AttributeListenerCreatedEvent = void 0;
|
|
386
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
387
|
+
class AttributeListenerCreatedEvent extends transport_1.TransportDataEvent {
|
|
388
|
+
constructor(eventTargetAddress, data) {
|
|
389
|
+
super(AttributeListenerCreatedEvent.namespace, eventTargetAddress, data);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
exports.AttributeListenerCreatedEvent = AttributeListenerCreatedEvent;
|
|
393
|
+
AttributeListenerCreatedEvent.namespace = "consumption.attributeListenerCreated";
|
|
394
|
+
//# sourceMappingURL=AttributeListenerCreatedEvent.js.map
|
|
395
|
+
|
|
396
|
+
/***/ }),
|
|
397
|
+
|
|
398
|
+
/***/ "./dist/modules/attributeListeners/events/index.js":
|
|
399
|
+
/*!*********************************************************!*\
|
|
400
|
+
!*** ./dist/modules/attributeListeners/events/index.js ***!
|
|
401
|
+
\*********************************************************/
|
|
402
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
403
|
+
|
|
404
|
+
"use strict";
|
|
405
|
+
|
|
406
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
407
|
+
if (k2 === undefined) k2 = k;
|
|
408
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
409
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
410
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
411
|
+
}
|
|
412
|
+
Object.defineProperty(o, k2, desc);
|
|
413
|
+
}) : (function(o, m, k, k2) {
|
|
414
|
+
if (k2 === undefined) k2 = k;
|
|
415
|
+
o[k2] = m[k];
|
|
416
|
+
}));
|
|
417
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
418
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
419
|
+
};
|
|
420
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
421
|
+
__exportStar(__webpack_require__(/*! ./AttributeListenerCreatedEvent */ "./dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js"), exports);
|
|
422
|
+
//# sourceMappingURL=index.js.map
|
|
423
|
+
|
|
424
|
+
/***/ }),
|
|
425
|
+
|
|
426
|
+
/***/ "./dist/modules/attributeListeners/index.js":
|
|
427
|
+
/*!**************************************************!*\
|
|
428
|
+
!*** ./dist/modules/attributeListeners/index.js ***!
|
|
429
|
+
\**************************************************/
|
|
430
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
431
|
+
|
|
432
|
+
"use strict";
|
|
433
|
+
|
|
434
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
435
|
+
if (k2 === undefined) k2 = k;
|
|
436
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
437
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
438
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
439
|
+
}
|
|
440
|
+
Object.defineProperty(o, k2, desc);
|
|
441
|
+
}) : (function(o, m, k, k2) {
|
|
442
|
+
if (k2 === undefined) k2 = k;
|
|
443
|
+
o[k2] = m[k];
|
|
444
|
+
}));
|
|
445
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
446
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
447
|
+
};
|
|
448
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
449
|
+
__exportStar(__webpack_require__(/*! ./AttributeListenersController */ "./dist/modules/attributeListeners/AttributeListenersController.js"), exports);
|
|
450
|
+
__exportStar(__webpack_require__(/*! ./events */ "./dist/modules/attributeListeners/events/index.js"), exports);
|
|
451
|
+
__exportStar(__webpack_require__(/*! ./local/CreateLocalAttributeListenerParams */ "./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js"), exports);
|
|
452
|
+
__exportStar(__webpack_require__(/*! ./local/LocalAttributeListener */ "./dist/modules/attributeListeners/local/LocalAttributeListener.js"), exports);
|
|
453
|
+
//# sourceMappingURL=index.js.map
|
|
454
|
+
|
|
455
|
+
/***/ }),
|
|
456
|
+
|
|
457
|
+
/***/ "./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js":
|
|
458
|
+
/*!*************************************************************************************!*\
|
|
459
|
+
!*** ./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js ***!
|
|
460
|
+
\*************************************************************************************/
|
|
461
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
462
|
+
|
|
463
|
+
"use strict";
|
|
464
|
+
|
|
465
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
466
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
467
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
468
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
469
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
470
|
+
};
|
|
471
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
472
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
473
|
+
};
|
|
474
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
475
|
+
exports.CreateLocalAttributeListenerParams = void 0;
|
|
476
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
477
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
478
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
479
|
+
let CreateLocalAttributeListenerParams = class CreateLocalAttributeListenerParams extends ts_serval_1.Serializable {
|
|
480
|
+
static from(value) {
|
|
481
|
+
return this.fromAny(value);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
__decorate([
|
|
485
|
+
(0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttributeQuery, content_1.ThirdPartyRelationshipAttributeQuery] }),
|
|
486
|
+
(0, ts_serval_1.validate)(),
|
|
487
|
+
__metadata("design:type", Object)
|
|
488
|
+
], CreateLocalAttributeListenerParams.prototype, "query", void 0);
|
|
489
|
+
__decorate([
|
|
490
|
+
(0, ts_serval_1.serialize)(),
|
|
491
|
+
(0, ts_serval_1.validate)(),
|
|
492
|
+
__metadata("design:type", transport_1.CoreAddress)
|
|
493
|
+
], CreateLocalAttributeListenerParams.prototype, "peer", void 0);
|
|
494
|
+
CreateLocalAttributeListenerParams = __decorate([
|
|
495
|
+
(0, ts_serval_1.type)("CreateLocalAttributeListenerParams")
|
|
496
|
+
], CreateLocalAttributeListenerParams);
|
|
497
|
+
exports.CreateLocalAttributeListenerParams = CreateLocalAttributeListenerParams;
|
|
498
|
+
//# sourceMappingURL=CreateLocalAttributeListenerParams.js.map
|
|
499
|
+
|
|
500
|
+
/***/ }),
|
|
501
|
+
|
|
502
|
+
/***/ "./dist/modules/attributeListeners/local/LocalAttributeListener.js":
|
|
503
|
+
/*!*************************************************************************!*\
|
|
504
|
+
!*** ./dist/modules/attributeListeners/local/LocalAttributeListener.js ***!
|
|
505
|
+
\*************************************************************************/
|
|
506
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
507
|
+
|
|
508
|
+
"use strict";
|
|
509
|
+
|
|
510
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
511
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
512
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
513
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
514
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
515
|
+
};
|
|
516
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
517
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
518
|
+
};
|
|
519
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
520
|
+
exports.LocalAttributeListener = void 0;
|
|
521
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
522
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
523
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
524
|
+
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
525
|
+
let LocalAttributeListener = class LocalAttributeListener extends transport_1.CoreSynchronizable {
|
|
526
|
+
constructor() {
|
|
527
|
+
super(...arguments);
|
|
528
|
+
this.userdataProperties = [
|
|
529
|
+
(0, ts_simple_nameof_1.nameof)((r) => r.query),
|
|
530
|
+
(0, ts_simple_nameof_1.nameof)((r) => r.peer)
|
|
531
|
+
];
|
|
532
|
+
}
|
|
533
|
+
static from(value) {
|
|
534
|
+
return this.fromAny(value);
|
|
535
|
+
}
|
|
536
|
+
toJSON() {
|
|
537
|
+
return super.toJSON();
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
__decorate([
|
|
541
|
+
(0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttributeQuery, content_1.ThirdPartyRelationshipAttributeQuery] }),
|
|
542
|
+
(0, ts_serval_1.validate)(),
|
|
543
|
+
__metadata("design:type", Object)
|
|
544
|
+
], LocalAttributeListener.prototype, "query", void 0);
|
|
545
|
+
__decorate([
|
|
546
|
+
(0, ts_serval_1.serialize)(),
|
|
547
|
+
(0, ts_serval_1.validate)(),
|
|
548
|
+
__metadata("design:type", transport_1.CoreAddress)
|
|
549
|
+
], LocalAttributeListener.prototype, "peer", void 0);
|
|
550
|
+
LocalAttributeListener = __decorate([
|
|
551
|
+
(0, ts_serval_1.type)("LocalAttributeListener")
|
|
552
|
+
], LocalAttributeListener);
|
|
553
|
+
exports.LocalAttributeListener = LocalAttributeListener;
|
|
554
|
+
//# sourceMappingURL=LocalAttributeListener.js.map
|
|
555
|
+
|
|
556
|
+
/***/ }),
|
|
557
|
+
|
|
558
|
+
/***/ "./dist/modules/attributes/AttributesController.js":
|
|
559
|
+
/*!*********************************************************!*\
|
|
560
|
+
!*** ./dist/modules/attributes/AttributesController.js ***!
|
|
561
|
+
\*********************************************************/
|
|
332
562
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
333
563
|
|
|
334
564
|
"use strict";
|
|
335
565
|
|
|
336
566
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
337
|
-
exports.
|
|
567
|
+
exports.AttributesController = void 0;
|
|
338
568
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
339
569
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
340
570
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
@@ -345,9 +575,9 @@ const LocalAttribute_1 = __webpack_require__(/*! ./local/LocalAttribute */ "./di
|
|
|
345
575
|
const LocalAttributeShareInfo_1 = __webpack_require__(/*! ./local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js");
|
|
346
576
|
const QueryTranslator_1 = __webpack_require__(/*! ./local/QueryTranslator */ "./dist/modules/attributes/local/QueryTranslator.js");
|
|
347
577
|
const SucceedLocalAttributeParams_1 = __webpack_require__(/*! ./local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js");
|
|
348
|
-
class
|
|
578
|
+
class AttributesController extends consumption_1.ConsumptionBaseController {
|
|
349
579
|
constructor(parent, eventBus, identity) {
|
|
350
|
-
super(consumption_1.ConsumptionControllerName.
|
|
580
|
+
super(consumption_1.ConsumptionControllerName.AttributesController, parent);
|
|
351
581
|
this.eventBus = eventBus;
|
|
352
582
|
this.identity = identity;
|
|
353
583
|
}
|
|
@@ -413,46 +643,83 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
413
643
|
}
|
|
414
644
|
async getLocalAttributes(query) {
|
|
415
645
|
const attributes = await this.attributes.find(query);
|
|
416
|
-
return
|
|
646
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
417
647
|
}
|
|
418
648
|
async getValidLocalAttributes(query) {
|
|
419
649
|
const attributes = await this.attributes.find(query);
|
|
420
|
-
const items =
|
|
650
|
+
const items = this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
421
651
|
return this.filterCurrent(items);
|
|
422
652
|
}
|
|
423
653
|
async executeRelationshipAttributeQuery(query) {
|
|
424
654
|
const parsedQuery = content_1.RelationshipAttributeQuery.from(query);
|
|
425
655
|
const dbQuery = QueryTranslator_1.RelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
656
|
+
dbQuery["content.confidentiality"] = { $ne: "private" };
|
|
657
|
+
const attributes = await this.attributes.find(dbQuery);
|
|
658
|
+
const attribute = attributes.length > 0 ? LocalAttribute_1.LocalAttribute.from(attributes[0]) : undefined;
|
|
659
|
+
return attribute;
|
|
660
|
+
}
|
|
661
|
+
async executeThirdPartyRelationshipAttributeQuery(query) {
|
|
662
|
+
const parsedQuery = content_1.ThirdPartyRelationshipAttributeQuery.from(query);
|
|
663
|
+
const dbQuery = QueryTranslator_1.ThirdPartyRelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
664
|
+
dbQuery["content.confidentiality"] = { $ne: "private" };
|
|
426
665
|
const attributes = await this.attributes.find(dbQuery);
|
|
427
|
-
|
|
666
|
+
const attribute = attributes.length > 0 ? LocalAttribute_1.LocalAttribute.from(attributes[0]) : undefined;
|
|
667
|
+
return attribute;
|
|
428
668
|
}
|
|
429
669
|
async executeIdentityAttributeQuery(query) {
|
|
430
670
|
const parsedQuery = content_1.IdentityAttributeQuery.from(query);
|
|
431
671
|
const dbQuery = QueryTranslator_1.IdentityAttributeQueryTranslator.translate(parsedQuery);
|
|
672
|
+
dbQuery["content.owner"] = this.identity.address.toString();
|
|
673
|
+
dbQuery["shareInfo"] = { $exists: false };
|
|
432
674
|
const attributes = await this.attributes.find(dbQuery);
|
|
433
|
-
return
|
|
675
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
434
676
|
}
|
|
435
677
|
async createLocalAttribute(params) {
|
|
436
|
-
const localAttribute =
|
|
678
|
+
const localAttribute = LocalAttribute_1.LocalAttribute.from({
|
|
679
|
+
id: await consumption_1.ConsumptionIds.attribute.generate(),
|
|
680
|
+
createdAt: transport_1.CoreDate.utc(),
|
|
681
|
+
content: params.content,
|
|
682
|
+
parentId: params.parentId
|
|
683
|
+
});
|
|
437
684
|
await this.attributes.create(localAttribute);
|
|
685
|
+
if (localAttribute.content instanceof content_1.IdentityAttribute && // nested Local Attributes should only be created for Identity Attributes
|
|
686
|
+
localAttribute.content.value instanceof content_1.AbstractComplexValue) {
|
|
687
|
+
await this.createLocalAttributesForNestedAttributeValues(localAttribute);
|
|
688
|
+
}
|
|
438
689
|
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), localAttribute));
|
|
439
690
|
return localAttribute;
|
|
440
691
|
}
|
|
692
|
+
async createLocalAttributesForNestedAttributeValues(localAttribute) {
|
|
693
|
+
if (!(localAttribute.content instanceof content_1.IdentityAttribute)) {
|
|
694
|
+
throw new consumption_1.ConsumptionError("Only Identity Attributes are allowed here");
|
|
695
|
+
}
|
|
696
|
+
const nestedAttributeValues = Object.values(localAttribute.content.value).filter((p) => p instanceof content_1.AbstractAttributeValue);
|
|
697
|
+
for (const propertyValue of nestedAttributeValues) {
|
|
698
|
+
const nestedAttribute = content_1.IdentityAttribute.from({
|
|
699
|
+
...localAttribute.content.toJSON(),
|
|
700
|
+
value: propertyValue.toJSON()
|
|
701
|
+
});
|
|
702
|
+
await this.createLocalAttribute({ content: nestedAttribute, parentId: localAttribute.id });
|
|
703
|
+
}
|
|
704
|
+
}
|
|
441
705
|
async succeedLocalAttribute(params) {
|
|
442
706
|
const parsedParams = SucceedLocalAttributeParams_1.SucceedLocalAttributeParams.from(params);
|
|
443
|
-
const
|
|
707
|
+
const currentAttributeDoc = await this.attributes.findOne({
|
|
444
708
|
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.succeeds.toString()
|
|
445
709
|
});
|
|
446
|
-
|
|
447
|
-
|
|
710
|
+
const currentAttribute = LocalAttribute_1.LocalAttribute.from(currentAttributeDoc);
|
|
711
|
+
if (currentAttribute.parentId) {
|
|
712
|
+
throw consumption_1.CoreErrors.attributes.cannotSucceedAttributesWithAParent(parsedParams.succeeds.toString());
|
|
713
|
+
}
|
|
714
|
+
if (!currentAttributeDoc) {
|
|
715
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, parsedParams.succeeds.toString());
|
|
448
716
|
}
|
|
449
717
|
if (!parsedParams.successorContent.validFrom) {
|
|
450
718
|
parsedParams.successorContent.validFrom = transport_1.CoreDate.utc();
|
|
451
719
|
}
|
|
452
720
|
const validFrom = parsedParams.successorContent.validFrom;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
await this.attributes.update(current, currentUpdated);
|
|
721
|
+
currentAttribute.content.validTo = validFrom.subtract(1);
|
|
722
|
+
await this.attributes.update(currentAttributeDoc, currentAttribute);
|
|
456
723
|
const successor = await LocalAttribute_1.LocalAttribute.fromAttribute(parsedParams.successorContent, parsedParams.succeeds);
|
|
457
724
|
await this.attributes.create(successor);
|
|
458
725
|
this.eventBus.publish(new events_1.AttributeSucceededEvent(this.identity.address.toString(), successor));
|
|
@@ -462,7 +729,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
462
729
|
const parsedParams = CreateSharedLocalAttributeCopyParams_1.CreateSharedLocalAttributeCopyParams.from(params);
|
|
463
730
|
const sourceAttribute = await this.getLocalAttribute(parsedParams.sourceAttributeId);
|
|
464
731
|
if (!sourceAttribute) {
|
|
465
|
-
throw
|
|
732
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, parsedParams.sourceAttributeId.toString());
|
|
466
733
|
}
|
|
467
734
|
const shareInfo = LocalAttributeShareInfo_1.LocalAttributeShareInfo.from({
|
|
468
735
|
peer: parsedParams.peer,
|
|
@@ -486,6 +753,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
486
753
|
createdAt: transport_1.CoreDate.utc()
|
|
487
754
|
});
|
|
488
755
|
await this.attributes.create(peerLocalAttribute);
|
|
756
|
+
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), peerLocalAttribute));
|
|
489
757
|
return peerLocalAttribute;
|
|
490
758
|
}
|
|
491
759
|
async updateLocalAttribute(params) {
|
|
@@ -493,7 +761,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
493
761
|
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.id.toString()
|
|
494
762
|
});
|
|
495
763
|
if (!current) {
|
|
496
|
-
throw transport_1.
|
|
764
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, params.id.toString());
|
|
497
765
|
}
|
|
498
766
|
const updatedLocalAttribute = LocalAttribute_1.LocalAttribute.from({
|
|
499
767
|
id: current.id,
|
|
@@ -512,8 +780,8 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
512
780
|
this.eventBus.publish(new events_1.AttributeDeletedEvent(this.identity.address.toString(), attribute));
|
|
513
781
|
}
|
|
514
782
|
}
|
|
515
|
-
exports.
|
|
516
|
-
//# sourceMappingURL=
|
|
783
|
+
exports.AttributesController = AttributesController;
|
|
784
|
+
//# sourceMappingURL=AttributesController.js.map
|
|
517
785
|
|
|
518
786
|
/***/ }),
|
|
519
787
|
|
|
@@ -659,6 +927,42 @@ __exportStar(__webpack_require__(/*! ./SharedAttributeCopyCreatedEvent */ "./dis
|
|
|
659
927
|
|
|
660
928
|
/***/ }),
|
|
661
929
|
|
|
930
|
+
/***/ "./dist/modules/attributes/index.js":
|
|
931
|
+
/*!******************************************!*\
|
|
932
|
+
!*** ./dist/modules/attributes/index.js ***!
|
|
933
|
+
\******************************************/
|
|
934
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
935
|
+
|
|
936
|
+
"use strict";
|
|
937
|
+
|
|
938
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
939
|
+
if (k2 === undefined) k2 = k;
|
|
940
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
941
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
942
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
943
|
+
}
|
|
944
|
+
Object.defineProperty(o, k2, desc);
|
|
945
|
+
}) : (function(o, m, k, k2) {
|
|
946
|
+
if (k2 === undefined) k2 = k;
|
|
947
|
+
o[k2] = m[k];
|
|
948
|
+
}));
|
|
949
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
950
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
951
|
+
};
|
|
952
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
953
|
+
__exportStar(__webpack_require__(/*! ./AttributesController */ "./dist/modules/attributes/AttributesController.js"), exports);
|
|
954
|
+
__exportStar(__webpack_require__(/*! ./events */ "./dist/modules/attributes/events/index.js"), exports);
|
|
955
|
+
__exportStar(__webpack_require__(/*! ./local/CreateLocalAttributeParams */ "./dist/modules/attributes/local/CreateLocalAttributeParams.js"), exports);
|
|
956
|
+
__exportStar(__webpack_require__(/*! ./local/CreatePeerLocalAttributeParams */ "./dist/modules/attributes/local/CreatePeerLocalAttributeParams.js"), exports);
|
|
957
|
+
__exportStar(__webpack_require__(/*! ./local/CreateSharedLocalAttributeCopyParams */ "./dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js"), exports);
|
|
958
|
+
__exportStar(__webpack_require__(/*! ./local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js"), exports);
|
|
959
|
+
__exportStar(__webpack_require__(/*! ./local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js"), exports);
|
|
960
|
+
__exportStar(__webpack_require__(/*! ./local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js"), exports);
|
|
961
|
+
__exportStar(__webpack_require__(/*! ./local/UpdateLocalAttributeParams */ "./dist/modules/attributes/local/UpdateLocalAttributeParams.js"), exports);
|
|
962
|
+
//# sourceMappingURL=index.js.map
|
|
963
|
+
|
|
964
|
+
/***/ }),
|
|
965
|
+
|
|
662
966
|
/***/ "./dist/modules/attributes/local/CreateLocalAttributeParams.js":
|
|
663
967
|
/*!*********************************************************************!*\
|
|
664
968
|
!*** ./dist/modules/attributes/local/CreateLocalAttributeParams.js ***!
|
|
@@ -680,6 +984,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
680
984
|
exports.CreateLocalAttributeParams = void 0;
|
|
681
985
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
682
986
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
987
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
683
988
|
class CreateLocalAttributeParams extends ts_serval_1.Serializable {
|
|
684
989
|
static from(value) {
|
|
685
990
|
return this.fromAny(value);
|
|
@@ -690,6 +995,11 @@ __decorate([
|
|
|
690
995
|
(0, ts_serval_1.validate)(),
|
|
691
996
|
__metadata("design:type", Object)
|
|
692
997
|
], CreateLocalAttributeParams.prototype, "content", void 0);
|
|
998
|
+
__decorate([
|
|
999
|
+
(0, ts_serval_1.serialize)({ optional: true }),
|
|
1000
|
+
(0, ts_serval_1.validate)(),
|
|
1001
|
+
__metadata("design:type", transport_1.CoreId)
|
|
1002
|
+
], CreateLocalAttributeParams.prototype, "parentId", void 0);
|
|
693
1003
|
exports.CreateLocalAttributeParams = CreateLocalAttributeParams;
|
|
694
1004
|
//# sourceMappingURL=CreateLocalAttributeParams.js.map
|
|
695
1005
|
|
|
@@ -838,19 +1148,35 @@ let LocalAttribute = class LocalAttribute extends transport_1.CoreSynchronizable
|
|
|
838
1148
|
isIdentityAttribute() {
|
|
839
1149
|
return this.content instanceof content_1.IdentityAttribute;
|
|
840
1150
|
}
|
|
1151
|
+
isRelationshipAttribute() {
|
|
1152
|
+
return this.content instanceof content_1.RelationshipAttribute;
|
|
1153
|
+
}
|
|
841
1154
|
isOwnedBy(identity) {
|
|
842
1155
|
return this.content.owner.equals(identity);
|
|
843
1156
|
}
|
|
1157
|
+
isRepositoryAttribute() {
|
|
1158
|
+
return this.isIdentityAttribute() && !this.isShared();
|
|
1159
|
+
}
|
|
1160
|
+
isShared() {
|
|
1161
|
+
return this.shareInfo !== undefined;
|
|
1162
|
+
}
|
|
1163
|
+
isSharedWith(address) {
|
|
1164
|
+
if (!this.isShared()) {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
return this.shareInfo.peer === address;
|
|
1168
|
+
}
|
|
844
1169
|
static from(value) {
|
|
845
1170
|
return this.fromAny(value);
|
|
846
1171
|
}
|
|
847
|
-
static async fromAttribute(
|
|
1172
|
+
static async fromAttribute(content, succeeds, shareInfo, id, parentId) {
|
|
848
1173
|
return this.from({
|
|
849
1174
|
id: id ?? (await consumption_1.ConsumptionIds.attribute.generate()),
|
|
850
|
-
content: attribute,
|
|
851
1175
|
createdAt: transport_1.CoreDate.utc(),
|
|
852
|
-
|
|
853
|
-
|
|
1176
|
+
content,
|
|
1177
|
+
succeeds,
|
|
1178
|
+
shareInfo,
|
|
1179
|
+
parentId
|
|
854
1180
|
});
|
|
855
1181
|
}
|
|
856
1182
|
};
|
|
@@ -879,6 +1205,11 @@ __decorate([
|
|
|
879
1205
|
(0, ts_serval_1.serialize)(),
|
|
880
1206
|
__metadata("design:type", LocalAttributeShareInfo_1.LocalAttributeShareInfo)
|
|
881
1207
|
], LocalAttribute.prototype, "shareInfo", void 0);
|
|
1208
|
+
__decorate([
|
|
1209
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1210
|
+
(0, ts_serval_1.serialize)(),
|
|
1211
|
+
__metadata("design:type", transport_1.CoreId)
|
|
1212
|
+
], LocalAttribute.prototype, "parentId", void 0);
|
|
882
1213
|
LocalAttribute = __decorate([
|
|
883
1214
|
(0, ts_serval_1.type)("LocalAttribute")
|
|
884
1215
|
], LocalAttribute);
|
|
@@ -942,10 +1273,11 @@ exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
|
942
1273
|
"use strict";
|
|
943
1274
|
|
|
944
1275
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
945
|
-
exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
1276
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
946
1277
|
const docdb_querytranslator_1 = __webpack_require__(/*! @js-soft/docdb-querytranslator */ "./node_modules/@js-soft/docdb-querytranslator/dist/index.js");
|
|
947
1278
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
|
|
948
1279
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
1280
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
949
1281
|
class IdentityAttributeQueryTranslator {
|
|
950
1282
|
static translate(query) {
|
|
951
1283
|
return this.translator.parse({ ...query.toJSON(), attributeType: "IdentityAttribute" });
|
|
@@ -974,7 +1306,7 @@ IdentityAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryT
|
|
|
974
1306
|
if (!input)
|
|
975
1307
|
return;
|
|
976
1308
|
if (!Array.isArray(input)) {
|
|
977
|
-
throw new
|
|
1309
|
+
throw new consumption_1.ConsumptionError("Invalid input: 'tags' must be an array");
|
|
978
1310
|
}
|
|
979
1311
|
const inputAsArray = input;
|
|
980
1312
|
query["$or"] = inputAsArray.map((t) => ({
|
|
@@ -1014,11 +1346,9 @@ exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTransla
|
|
|
1014
1346
|
RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1015
1347
|
whitelist: {
|
|
1016
1348
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1017
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.valueType)]: true,
|
|
1018
1349
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
1019
1350
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
1020
1351
|
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
1021
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.thirdParty)]: true,
|
|
1022
1352
|
attributeType: true
|
|
1023
1353
|
},
|
|
1024
1354
|
alias: {
|
|
@@ -1026,9 +1356,55 @@ RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.Qu
|
|
|
1026
1356
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
1027
1357
|
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
1028
1358
|
],
|
|
1029
|
-
// @type of
|
|
1030
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.
|
|
1031
|
-
|
|
1359
|
+
// @type of attribute
|
|
1360
|
+
attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
|
|
1361
|
+
// owner
|
|
1362
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: [
|
|
1363
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.owner)}`
|
|
1364
|
+
]
|
|
1365
|
+
},
|
|
1366
|
+
custom: {
|
|
1367
|
+
// validFrom
|
|
1368
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: (query, input) => {
|
|
1369
|
+
if (!input) {
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
const validFromUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
1373
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] = {
|
|
1374
|
+
$gte: validFromUtcString
|
|
1375
|
+
};
|
|
1376
|
+
},
|
|
1377
|
+
// validTo
|
|
1378
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: (query, input) => {
|
|
1379
|
+
if (!input) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
const validToUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
1383
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validTo)}`] = {
|
|
1384
|
+
$lte: validToUtcString
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
class ThirdPartyRelationshipAttributeQueryTranslator {
|
|
1390
|
+
static translate(query) {
|
|
1391
|
+
return this.translator.parse({ ...query.toJSON(), attributeType: "RelationshipAttribute" });
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = ThirdPartyRelationshipAttributeQueryTranslator;
|
|
1395
|
+
ThirdPartyRelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1396
|
+
whitelist: {
|
|
1397
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1398
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
1399
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
1400
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
1401
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.thirdParty)]: true,
|
|
1402
|
+
attributeType: true
|
|
1403
|
+
},
|
|
1404
|
+
alias: {
|
|
1405
|
+
// key
|
|
1406
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
1407
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
1032
1408
|
],
|
|
1033
1409
|
// @type of attribute
|
|
1034
1410
|
attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
|
|
@@ -1180,12 +1556,12 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1180
1556
|
}
|
|
1181
1557
|
async getDrafts(query) {
|
|
1182
1558
|
const items = await this.drafts.find(query);
|
|
1183
|
-
return
|
|
1559
|
+
return this.parseArray(items, Draft_1.Draft);
|
|
1184
1560
|
}
|
|
1185
1561
|
async createDraft(content, type = "") {
|
|
1186
1562
|
const draft = Draft_1.Draft.from({
|
|
1187
1563
|
id: await consumption_1.ConsumptionIds.draft.generate(),
|
|
1188
|
-
content
|
|
1564
|
+
content,
|
|
1189
1565
|
createdAt: new transport_1.CoreDate(),
|
|
1190
1566
|
lastModifiedAt: new transport_1.CoreDate(),
|
|
1191
1567
|
type: type
|
|
@@ -1196,7 +1572,7 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1196
1572
|
async updateDraft(draft) {
|
|
1197
1573
|
const oldDraft = await this.drafts.read(draft.id.toString());
|
|
1198
1574
|
if (!oldDraft) {
|
|
1199
|
-
throw new
|
|
1575
|
+
throw new consumption_1.ConsumptionError("Draft Not Found");
|
|
1200
1576
|
}
|
|
1201
1577
|
await this.drafts.update(oldDraft, draft);
|
|
1202
1578
|
}
|
|
@@ -1209,6 +1585,35 @@ exports.DraftsController = DraftsController;
|
|
|
1209
1585
|
|
|
1210
1586
|
/***/ }),
|
|
1211
1587
|
|
|
1588
|
+
/***/ "./dist/modules/drafts/index.js":
|
|
1589
|
+
/*!**************************************!*\
|
|
1590
|
+
!*** ./dist/modules/drafts/index.js ***!
|
|
1591
|
+
\**************************************/
|
|
1592
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1593
|
+
|
|
1594
|
+
"use strict";
|
|
1595
|
+
|
|
1596
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1597
|
+
if (k2 === undefined) k2 = k;
|
|
1598
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1599
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1600
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
1601
|
+
}
|
|
1602
|
+
Object.defineProperty(o, k2, desc);
|
|
1603
|
+
}) : (function(o, m, k, k2) {
|
|
1604
|
+
if (k2 === undefined) k2 = k;
|
|
1605
|
+
o[k2] = m[k];
|
|
1606
|
+
}));
|
|
1607
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
1608
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1609
|
+
};
|
|
1610
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1611
|
+
__exportStar(__webpack_require__(/*! ./DraftsController */ "./dist/modules/drafts/DraftsController.js"), exports);
|
|
1612
|
+
__exportStar(__webpack_require__(/*! ./local/Draft */ "./dist/modules/drafts/local/Draft.js"), exports);
|
|
1613
|
+
//# sourceMappingURL=index.js.map
|
|
1614
|
+
|
|
1615
|
+
/***/ }),
|
|
1616
|
+
|
|
1212
1617
|
/***/ "./dist/modules/drafts/local/Draft.js":
|
|
1213
1618
|
/*!********************************************!*\
|
|
1214
1619
|
!*** ./dist/modules/drafts/local/Draft.js ***!
|
|
@@ -1312,55 +1717,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1312
1717
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1313
1718
|
};
|
|
1314
1719
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1315
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1316
|
-
__exportStar(__webpack_require__(/*! ./attributes
|
|
1317
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1318
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1319
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1320
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js"), exports);
|
|
1321
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js"), exports);
|
|
1322
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/UpdateLocalAttributeParams */ "./dist/modules/attributes/local/UpdateLocalAttributeParams.js"), exports);
|
|
1323
|
-
__exportStar(__webpack_require__(/*! ./attributes/LocalAttributesController */ "./dist/modules/attributes/LocalAttributesController.js"), exports);
|
|
1324
|
-
__exportStar(__webpack_require__(/*! ./drafts/DraftsController */ "./dist/modules/drafts/DraftsController.js"), exports);
|
|
1325
|
-
__exportStar(__webpack_require__(/*! ./drafts/local/Draft */ "./dist/modules/drafts/local/Draft.js"), exports);
|
|
1326
|
-
__exportStar(__webpack_require__(/*! ./requests/events */ "./dist/modules/requests/events/index.js"), exports);
|
|
1327
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters */ "./dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js"), exports);
|
|
1328
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/complete/CompleteIncomingRequestParameters */ "./dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js"), exports);
|
|
1329
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/AcceptRequestItemParameters */ "./dist/modules/requests/incoming/decide/AcceptRequestItemParameters.js"), exports);
|
|
1330
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/DecideRequestItemGroupParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js"), exports);
|
|
1331
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/DecideRequestItemParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemParameters.js"), exports);
|
|
1332
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/DecideRequestParameters */ "./dist/modules/requests/incoming/decide/DecideRequestParameters.js"), exports);
|
|
1333
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/RejectRequestItemParameters */ "./dist/modules/requests/incoming/decide/RejectRequestItemParameters.js"), exports);
|
|
1334
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/DecideRequestParametersValidator */ "./dist/modules/requests/incoming/DecideRequestParametersValidator.js"), exports);
|
|
1335
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/IncomingRequestsController */ "./dist/modules/requests/incoming/IncomingRequestsController.js"), exports);
|
|
1336
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
|
|
1337
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
|
|
1338
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
|
|
1339
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js"), exports);
|
|
1340
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js"), exports);
|
|
1341
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
|
|
1342
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
|
|
1343
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
|
|
1344
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js"), exports);
|
|
1345
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js"), exports);
|
|
1346
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js"), exports);
|
|
1347
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/RequestItemConstructor */ "./dist/modules/requests/itemProcessors/RequestItemConstructor.js"), exports);
|
|
1348
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js"), exports);
|
|
1349
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters.js"), exports);
|
|
1350
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js"), exports);
|
|
1351
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js"), exports);
|
|
1352
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js"), exports);
|
|
1353
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js"), exports);
|
|
1354
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalRequestStatusLogEntry */ "./dist/modules/requests/local/LocalRequestStatusLogEntry.js"), exports);
|
|
1355
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js"), exports);
|
|
1356
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters */ "./dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js"), exports);
|
|
1357
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters */ "./dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js"), exports);
|
|
1358
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js"), exports);
|
|
1359
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/OutgoingRequestsController */ "./dist/modules/requests/outgoing/OutgoingRequestsController.js"), exports);
|
|
1360
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js"), exports);
|
|
1361
|
-
__exportStar(__webpack_require__(/*! ./settings/local/CreateSettingParameter */ "./dist/modules/settings/local/CreateSettingParameter.js"), exports);
|
|
1362
|
-
__exportStar(__webpack_require__(/*! ./settings/local/Setting */ "./dist/modules/settings/local/Setting.js"), exports);
|
|
1363
|
-
__exportStar(__webpack_require__(/*! ./settings/SettingsController */ "./dist/modules/settings/SettingsController.js"), exports);
|
|
1720
|
+
__exportStar(__webpack_require__(/*! ./attributeListeners */ "./dist/modules/attributeListeners/index.js"), exports);
|
|
1721
|
+
__exportStar(__webpack_require__(/*! ./attributes */ "./dist/modules/attributes/index.js"), exports);
|
|
1722
|
+
__exportStar(__webpack_require__(/*! ./drafts */ "./dist/modules/drafts/index.js"), exports);
|
|
1723
|
+
__exportStar(__webpack_require__(/*! ./requests */ "./dist/modules/requests/index.js"), exports);
|
|
1724
|
+
__exportStar(__webpack_require__(/*! ./settings */ "./dist/modules/settings/index.js"), exports);
|
|
1364
1725
|
//# sourceMappingURL=index.js.map
|
|
1365
1726
|
|
|
1366
1727
|
/***/ }),
|
|
@@ -1376,11 +1737,12 @@ __exportStar(__webpack_require__(/*! ./settings/SettingsController */ "./dist/mo
|
|
|
1376
1737
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1377
1738
|
exports.IncomingRequestReceivedEvent = void 0;
|
|
1378
1739
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1740
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1379
1741
|
class IncomingRequestReceivedEvent extends transport_1.TransportDataEvent {
|
|
1380
1742
|
constructor(eventTargetAddress, data) {
|
|
1381
1743
|
super(IncomingRequestReceivedEvent.namespace, eventTargetAddress, data);
|
|
1382
1744
|
if (data.isOwn)
|
|
1383
|
-
throw new
|
|
1745
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an outgoing Request");
|
|
1384
1746
|
}
|
|
1385
1747
|
}
|
|
1386
1748
|
exports.IncomingRequestReceivedEvent = IncomingRequestReceivedEvent;
|
|
@@ -1400,11 +1762,12 @@ IncomingRequestReceivedEvent.namespace = "consumption.incomingRequestReceived";
|
|
|
1400
1762
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1401
1763
|
exports.IncomingRequestStatusChangedEvent = void 0;
|
|
1402
1764
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1765
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1403
1766
|
class IncomingRequestStatusChangedEvent extends transport_1.TransportDataEvent {
|
|
1404
1767
|
constructor(eventTargetAddress, data) {
|
|
1405
1768
|
super(IncomingRequestStatusChangedEvent.namespace, eventTargetAddress, data);
|
|
1406
1769
|
if (data.request.isOwn)
|
|
1407
|
-
throw new
|
|
1770
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an outgoing Request");
|
|
1408
1771
|
}
|
|
1409
1772
|
}
|
|
1410
1773
|
exports.IncomingRequestStatusChangedEvent = IncomingRequestStatusChangedEvent;
|
|
@@ -1424,11 +1787,12 @@ IncomingRequestStatusChangedEvent.namespace = "consumption.incomingRequestStatus
|
|
|
1424
1787
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1425
1788
|
exports.OutgoingRequestCreatedEvent = void 0;
|
|
1426
1789
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1790
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1427
1791
|
class OutgoingRequestCreatedEvent extends transport_1.TransportDataEvent {
|
|
1428
1792
|
constructor(eventTargetAddress, data) {
|
|
1429
1793
|
super(OutgoingRequestCreatedEvent.namespace, eventTargetAddress, data);
|
|
1430
1794
|
if (!data.isOwn)
|
|
1431
|
-
throw new
|
|
1795
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an incoming Request");
|
|
1432
1796
|
}
|
|
1433
1797
|
}
|
|
1434
1798
|
exports.OutgoingRequestCreatedEvent = OutgoingRequestCreatedEvent;
|
|
@@ -1448,11 +1812,12 @@ OutgoingRequestCreatedEvent.namespace = "consumption.outgoingRequestCreated";
|
|
|
1448
1812
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1449
1813
|
exports.OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent = void 0;
|
|
1450
1814
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1815
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1451
1816
|
class OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent extends transport_1.TransportDataEvent {
|
|
1452
1817
|
constructor(eventTargetAddress, data) {
|
|
1453
1818
|
super(OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.namespace, eventTargetAddress, data);
|
|
1454
1819
|
if (!data.isOwn)
|
|
1455
|
-
throw new
|
|
1820
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an incoming Request");
|
|
1456
1821
|
}
|
|
1457
1822
|
}
|
|
1458
1823
|
exports.OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent = OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent;
|
|
@@ -1472,11 +1837,12 @@ OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.namespace
|
|
|
1472
1837
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1473
1838
|
exports.OutgoingRequestStatusChangedEvent = void 0;
|
|
1474
1839
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1840
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1475
1841
|
class OutgoingRequestStatusChangedEvent extends transport_1.TransportDataEvent {
|
|
1476
1842
|
constructor(eventTargetAddress, data) {
|
|
1477
1843
|
super(OutgoingRequestStatusChangedEvent.namespace, eventTargetAddress, data);
|
|
1478
1844
|
if (!data.request.isOwn)
|
|
1479
|
-
throw new
|
|
1845
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an incoming Request");
|
|
1480
1846
|
}
|
|
1481
1847
|
}
|
|
1482
1848
|
exports.OutgoingRequestStatusChangedEvent = OutgoingRequestStatusChangedEvent;
|
|
@@ -1536,10 +1902,10 @@ const DecideRequestItemParameters_1 = __webpack_require__(/*! ./decide/DecideReq
|
|
|
1536
1902
|
class DecideRequestParametersValidator {
|
|
1537
1903
|
validate(params, request) {
|
|
1538
1904
|
if (!request.id.equals(transport_1.CoreId.from(params.requestId))) {
|
|
1539
|
-
|
|
1905
|
+
throw new Error("The response is invalid because the id of the Request does not match the id of the Response.");
|
|
1540
1906
|
}
|
|
1541
1907
|
if (params.items.length !== request.content.items.length) {
|
|
1542
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1908
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.invalidNumberOfItems("Number of items in Request and Response do not match"));
|
|
1543
1909
|
}
|
|
1544
1910
|
const validationResults = request.content.items.map((requestItem, index) => this.checkItemOrGroup(requestItem, params.items[index], params.accept));
|
|
1545
1911
|
return ValidationResult_1.ValidationResult.fromItems(validationResults);
|
|
@@ -1552,29 +1918,29 @@ class DecideRequestParametersValidator {
|
|
|
1552
1918
|
}
|
|
1553
1919
|
checkItem(requestItem, response, isParentAccepted) {
|
|
1554
1920
|
if ((0, DecideRequestItemGroupParameters_1.isDecideRequestItemGroupParametersJSON)(response)) {
|
|
1555
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1921
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.requestItemAnsweredAsRequestItemGroup());
|
|
1556
1922
|
}
|
|
1557
1923
|
if (!isParentAccepted && response.accept) {
|
|
1558
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1924
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.itemAcceptedButParentNotAccepted("The RequestItem was accepted, but the parent was not accepted."));
|
|
1559
1925
|
}
|
|
1560
1926
|
if (isParentAccepted && requestItem.mustBeAccepted && !response.accept) {
|
|
1561
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1927
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.mustBeAcceptedItemNotAccepted("The RequestItem is flagged as 'mustBeAccepted', but it was not accepted."));
|
|
1562
1928
|
}
|
|
1563
1929
|
return ValidationResult_1.ValidationResult.success();
|
|
1564
1930
|
}
|
|
1565
1931
|
checkItemGroup(requestItemGroup, responseItemGroup, isParentAccepted) {
|
|
1566
1932
|
if ((0, DecideRequestItemParameters_1.isDecideRequestItemParametersJSON)(responseItemGroup)) {
|
|
1567
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1933
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.requestItemGroupAnsweredAsRequestItem());
|
|
1568
1934
|
}
|
|
1569
1935
|
if (responseItemGroup.items.length !== requestItemGroup.items.length) {
|
|
1570
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1936
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.invalidNumberOfItems("Number of items in RequestItemGroup and ResponseItemGroup do not match"));
|
|
1571
1937
|
}
|
|
1572
1938
|
const isGroupAccepted = responseItemGroup.items.some((value) => value.accept);
|
|
1573
1939
|
if (!isParentAccepted && isGroupAccepted) {
|
|
1574
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1940
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.itemAcceptedButParentNotAccepted("The RequestItemGroup was accepted, but the parent was not accepted."));
|
|
1575
1941
|
}
|
|
1576
1942
|
if (isParentAccepted && requestItemGroup.mustBeAccepted && !isGroupAccepted) {
|
|
1577
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
1943
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.mustBeAcceptedItemNotAccepted("The RequestItemGroup is flagged as 'mustBeAccepted', but it was not accepted. Please accept all 'mustBeAccepted' items in this group."));
|
|
1578
1944
|
}
|
|
1579
1945
|
const validationResults = requestItemGroup.items.map((requestItem, index) => this.checkItem(requestItem, responseItemGroup.items[index], isGroupAccepted));
|
|
1580
1946
|
return ValidationResult_1.ValidationResult.fromItems(validationResults);
|
|
@@ -1644,7 +2010,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1644
2010
|
}
|
|
1645
2011
|
extractInfoFromMessage(message) {
|
|
1646
2012
|
if (message.isOwn)
|
|
1647
|
-
throw new
|
|
2013
|
+
throw new consumption_1.ConsumptionError("Cannot create incoming Request from own Message");
|
|
1648
2014
|
return {
|
|
1649
2015
|
peer: message.cache.createdBy,
|
|
1650
2016
|
source: {
|
|
@@ -1655,7 +2021,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1655
2021
|
}
|
|
1656
2022
|
extractInfoFromRelationshipTemplate(template) {
|
|
1657
2023
|
if (template.isOwn)
|
|
1658
|
-
throw new
|
|
2024
|
+
throw new consumption_1.ConsumptionError("Cannot create incoming Request from own Relationship Template");
|
|
1659
2025
|
return {
|
|
1660
2026
|
peer: template.cache.createdBy,
|
|
1661
2027
|
source: {
|
|
@@ -1754,22 +2120,22 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1754
2120
|
}
|
|
1755
2121
|
catch (e) {
|
|
1756
2122
|
if (e instanceof ts_serval_1.ServalError) {
|
|
1757
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
2123
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.servalErrorDuringRequestItemProcessing(e));
|
|
1758
2124
|
}
|
|
1759
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
2125
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.unexpectedErrorDuringRequestItemProcessing(e));
|
|
1760
2126
|
}
|
|
1761
2127
|
}
|
|
1762
2128
|
async accept(params) {
|
|
1763
2129
|
const canAccept = await this.canAccept(params);
|
|
1764
2130
|
if (!canAccept.isSuccess()) {
|
|
1765
|
-
throw new
|
|
2131
|
+
throw new consumption_1.ConsumptionError("Cannot accept the Request with the given parameters. Call 'canAccept' to get more information.");
|
|
1766
2132
|
}
|
|
1767
2133
|
return await this.decide({ ...params, accept: true });
|
|
1768
2134
|
}
|
|
1769
2135
|
async reject(params) {
|
|
1770
2136
|
const canReject = await this.canReject(params);
|
|
1771
2137
|
if (!canReject.isSuccess()) {
|
|
1772
|
-
throw new
|
|
2138
|
+
throw new consumption_1.ConsumptionError("Cannot reject the Request with the given parameters. Call 'canReject' to get more information.");
|
|
1773
2139
|
}
|
|
1774
2140
|
return await this.decide({ ...params, accept: false });
|
|
1775
2141
|
}
|
|
@@ -1804,7 +2170,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1804
2170
|
}
|
|
1805
2171
|
async decideGroup(groupItemParam, requestItemGroup, request) {
|
|
1806
2172
|
const items = (await this.decideItems(groupItemParam.items, requestItemGroup.items, request));
|
|
1807
|
-
const group = content_1.ResponseItemGroup.from({ items
|
|
2173
|
+
const group = content_1.ResponseItemGroup.from({ items });
|
|
1808
2174
|
return group;
|
|
1809
2175
|
}
|
|
1810
2176
|
async decideItems(params, requestItems, request) {
|
|
@@ -1834,14 +2200,14 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1834
2200
|
if (e instanceof Error) {
|
|
1835
2201
|
details = ` Details: ${e.message}`;
|
|
1836
2202
|
}
|
|
1837
|
-
throw new
|
|
2203
|
+
throw new consumption_1.ConsumptionError(`An error occurred while processing a '${requestItem.constructor.name}'. You should contact the developer of this RequestItem.${details}}`);
|
|
1838
2204
|
}
|
|
1839
2205
|
}
|
|
1840
2206
|
async complete(params) {
|
|
1841
2207
|
const parsedParams = CompleteIncomingRequestParameters_1.CompleteIncomingRequestParameters.from(params);
|
|
1842
2208
|
const request = await this.getOrThrow(parsedParams.requestId);
|
|
1843
2209
|
if (request.isOwn) {
|
|
1844
|
-
throw new
|
|
2210
|
+
throw new consumption_1.ConsumptionError("Cannot decide own Request");
|
|
1845
2211
|
}
|
|
1846
2212
|
this.assertRequestStatus(request, LocalRequestStatus_1.LocalRequestStatus.Decided);
|
|
1847
2213
|
const requestIsRejected = request.response.content.result === content_1.ResponseResult.Rejected;
|
|
@@ -1853,7 +2219,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1853
2219
|
});
|
|
1854
2220
|
}
|
|
1855
2221
|
else if (!requestIsRejected || !requestIsFromTemplate) {
|
|
1856
|
-
throw new
|
|
2222
|
+
throw new consumption_1.ConsumptionError("A Request can only be completed without a responseSource if the Request is rejected and the Request is from a Relationship Template");
|
|
1857
2223
|
}
|
|
1858
2224
|
request.changeStatus(LocalRequestStatus_1.LocalRequestStatus.Completed);
|
|
1859
2225
|
await this.update(request);
|
|
@@ -1865,36 +2231,45 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1865
2231
|
return request;
|
|
1866
2232
|
}
|
|
1867
2233
|
async getIncomingRequests(query) {
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2234
|
+
const requestDocs = await this.localRequests.find({
|
|
2235
|
+
...query,
|
|
2236
|
+
isOwn: false
|
|
2237
|
+
});
|
|
2238
|
+
const requestPromises = requestDocs.map((r) => this.updateRequestExpiry(LocalRequest_1.LocalRequest.from(r)));
|
|
2239
|
+
return await Promise.all(requestPromises);
|
|
1873
2240
|
}
|
|
1874
2241
|
async getIncomingRequest(idIncomingRequest) {
|
|
1875
2242
|
const requestDoc = await this.localRequests.findOne({ id: idIncomingRequest.toString(), isOwn: false });
|
|
1876
|
-
|
|
1877
|
-
|
|
2243
|
+
if (!requestDoc)
|
|
2244
|
+
return;
|
|
2245
|
+
const localRequest = LocalRequest_1.LocalRequest.from(requestDoc);
|
|
2246
|
+
return await this.updateRequestExpiry(localRequest);
|
|
1878
2247
|
}
|
|
1879
2248
|
async getOrThrow(id) {
|
|
1880
2249
|
const request = await this.getIncomingRequest(transport_1.CoreId.from(id));
|
|
1881
2250
|
if (!request) {
|
|
1882
|
-
throw transport_1.
|
|
2251
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, id.toString());
|
|
1883
2252
|
}
|
|
1884
2253
|
return request;
|
|
1885
2254
|
}
|
|
1886
2255
|
async update(request) {
|
|
1887
2256
|
const requestDoc = await this.localRequests.findOne({ id: request.id.toString(), isOwn: false });
|
|
1888
2257
|
if (!requestDoc) {
|
|
1889
|
-
throw transport_1.
|
|
2258
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, request.id.toString());
|
|
1890
2259
|
}
|
|
1891
2260
|
await this.localRequests.update(requestDoc, request);
|
|
1892
2261
|
}
|
|
1893
2262
|
assertRequestStatus(request, ...status) {
|
|
1894
2263
|
if (!status.includes(request.status)) {
|
|
1895
|
-
throw new
|
|
2264
|
+
throw new consumption_1.ConsumptionError(`Local Request has to be in status '${status.join("/")}'.`);
|
|
1896
2265
|
}
|
|
1897
2266
|
}
|
|
2267
|
+
async updateRequestExpiry(request) {
|
|
2268
|
+
const statusUpdated = request.updateStatusBasedOnExpiration();
|
|
2269
|
+
if (statusUpdated)
|
|
2270
|
+
await this.update(request);
|
|
2271
|
+
return request;
|
|
2272
|
+
}
|
|
1898
2273
|
}
|
|
1899
2274
|
exports.IncomingRequestsController = IncomingRequestsController;
|
|
1900
2275
|
//# sourceMappingURL=IncomingRequestsController.js.map
|
|
@@ -2186,6 +2561,68 @@ exports.RequireManualDecisionOfIncomingRequestParameters = RequireManualDecision
|
|
|
2186
2561
|
|
|
2187
2562
|
/***/ }),
|
|
2188
2563
|
|
|
2564
|
+
/***/ "./dist/modules/requests/index.js":
|
|
2565
|
+
/*!****************************************!*\
|
|
2566
|
+
!*** ./dist/modules/requests/index.js ***!
|
|
2567
|
+
\****************************************/
|
|
2568
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2569
|
+
|
|
2570
|
+
"use strict";
|
|
2571
|
+
|
|
2572
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2573
|
+
if (k2 === undefined) k2 = k;
|
|
2574
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2575
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2576
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2577
|
+
}
|
|
2578
|
+
Object.defineProperty(o, k2, desc);
|
|
2579
|
+
}) : (function(o, m, k, k2) {
|
|
2580
|
+
if (k2 === undefined) k2 = k;
|
|
2581
|
+
o[k2] = m[k];
|
|
2582
|
+
}));
|
|
2583
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
2584
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2585
|
+
};
|
|
2586
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2587
|
+
__exportStar(__webpack_require__(/*! ./events */ "./dist/modules/requests/events/index.js"), exports);
|
|
2588
|
+
__exportStar(__webpack_require__(/*! ./incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters */ "./dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js"), exports);
|
|
2589
|
+
__exportStar(__webpack_require__(/*! ./incoming/complete/CompleteIncomingRequestParameters */ "./dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js"), exports);
|
|
2590
|
+
__exportStar(__webpack_require__(/*! ./incoming/decide/AcceptRequestItemParameters */ "./dist/modules/requests/incoming/decide/AcceptRequestItemParameters.js"), exports);
|
|
2591
|
+
__exportStar(__webpack_require__(/*! ./incoming/decide/DecideRequestItemGroupParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js"), exports);
|
|
2592
|
+
__exportStar(__webpack_require__(/*! ./incoming/decide/DecideRequestItemParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemParameters.js"), exports);
|
|
2593
|
+
__exportStar(__webpack_require__(/*! ./incoming/decide/DecideRequestParameters */ "./dist/modules/requests/incoming/decide/DecideRequestParameters.js"), exports);
|
|
2594
|
+
__exportStar(__webpack_require__(/*! ./incoming/decide/RejectRequestItemParameters */ "./dist/modules/requests/incoming/decide/RejectRequestItemParameters.js"), exports);
|
|
2595
|
+
__exportStar(__webpack_require__(/*! ./incoming/DecideRequestParametersValidator */ "./dist/modules/requests/incoming/DecideRequestParametersValidator.js"), exports);
|
|
2596
|
+
__exportStar(__webpack_require__(/*! ./incoming/IncomingRequestsController */ "./dist/modules/requests/incoming/IncomingRequestsController.js"), exports);
|
|
2597
|
+
__exportStar(__webpack_require__(/*! ./incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
|
|
2598
|
+
__exportStar(__webpack_require__(/*! ./incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
|
|
2599
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
|
|
2600
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
|
|
2601
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
|
|
2602
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
|
|
2603
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
|
|
2604
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js"), exports);
|
|
2605
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js"), exports);
|
|
2606
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/readAttribute/ReadAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js"), exports);
|
|
2607
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor */ "./dist/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.js"), exports);
|
|
2608
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemConstructor */ "./dist/modules/requests/itemProcessors/RequestItemConstructor.js"), exports);
|
|
2609
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js"), exports);
|
|
2610
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js"), exports);
|
|
2611
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js"), exports);
|
|
2612
|
+
__exportStar(__webpack_require__(/*! ./local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js"), exports);
|
|
2613
|
+
__exportStar(__webpack_require__(/*! ./local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js"), exports);
|
|
2614
|
+
__exportStar(__webpack_require__(/*! ./local/LocalRequestStatusLogEntry */ "./dist/modules/requests/local/LocalRequestStatusLogEntry.js"), exports);
|
|
2615
|
+
__exportStar(__webpack_require__(/*! ./local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js"), exports);
|
|
2616
|
+
__exportStar(__webpack_require__(/*! ./outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters */ "./dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js"), exports);
|
|
2617
|
+
__exportStar(__webpack_require__(/*! ./outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters */ "./dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js"), exports);
|
|
2618
|
+
__exportStar(__webpack_require__(/*! ./outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js"), exports);
|
|
2619
|
+
__exportStar(__webpack_require__(/*! ./outgoing/createOutgoingRequest/CreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js"), exports);
|
|
2620
|
+
__exportStar(__webpack_require__(/*! ./outgoing/OutgoingRequestsController */ "./dist/modules/requests/outgoing/OutgoingRequestsController.js"), exports);
|
|
2621
|
+
__exportStar(__webpack_require__(/*! ./outgoing/sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js"), exports);
|
|
2622
|
+
//# sourceMappingURL=index.js.map
|
|
2623
|
+
|
|
2624
|
+
/***/ }),
|
|
2625
|
+
|
|
2189
2626
|
/***/ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js":
|
|
2190
2627
|
/*!******************************************************************************!*\
|
|
2191
2628
|
!*** ./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js ***!
|
|
@@ -2296,12 +2733,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
2296
2733
|
/*!******************************************************************************!*\
|
|
2297
2734
|
!*** ./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js ***!
|
|
2298
2735
|
\******************************************************************************/
|
|
2299
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
2736
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2300
2737
|
|
|
2301
2738
|
"use strict";
|
|
2302
2739
|
|
|
2303
2740
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2304
2741
|
exports.RequestItemProcessorRegistry = void 0;
|
|
2742
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
2305
2743
|
class RequestItemProcessorRegistry {
|
|
2306
2744
|
constructor(consumptionController, processors = new Map()) {
|
|
2307
2745
|
this.consumptionController = consumptionController;
|
|
@@ -2309,7 +2747,7 @@ class RequestItemProcessorRegistry {
|
|
|
2309
2747
|
}
|
|
2310
2748
|
registerProcessor(itemConstructor, processorConstructor) {
|
|
2311
2749
|
if (this.processors.has(itemConstructor)) {
|
|
2312
|
-
throw new
|
|
2750
|
+
throw new consumption_1.ConsumptionError(`There is already a processor registered for '${itemConstructor.name}''. Use 'replaceProcessorForType' if you want to replace it.`);
|
|
2313
2751
|
}
|
|
2314
2752
|
this.processors.set(itemConstructor, processorConstructor);
|
|
2315
2753
|
}
|
|
@@ -2319,7 +2757,7 @@ class RequestItemProcessorRegistry {
|
|
|
2319
2757
|
getProcessorForItem(item) {
|
|
2320
2758
|
const constructor = this.processors.get(item.constructor);
|
|
2321
2759
|
if (!constructor) {
|
|
2322
|
-
throw new
|
|
2760
|
+
throw new consumption_1.ConsumptionError(`There was no processor registered for '${item.constructor.name}'.`);
|
|
2323
2761
|
}
|
|
2324
2762
|
return new constructor(this.consumptionController);
|
|
2325
2763
|
}
|
|
@@ -2380,76 +2818,72 @@ exports.ErrorValidationResult = ErrorValidationResult;
|
|
|
2380
2818
|
|
|
2381
2819
|
/***/ }),
|
|
2382
2820
|
|
|
2383
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2384
|
-
|
|
2385
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2386
|
-
|
|
2387
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2388
|
-
|
|
2389
|
-
"use strict";
|
|
2390
|
-
|
|
2391
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2392
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2393
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2394
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2395
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2396
|
-
};
|
|
2397
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2398
|
-
exports.AcceptCreateRelationshipAttributeRequestItemParameters = void 0;
|
|
2399
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2400
|
-
let AcceptCreateRelationshipAttributeRequestItemParameters = class AcceptCreateRelationshipAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2401
|
-
static from(value) {
|
|
2402
|
-
return this.fromAny(value);
|
|
2403
|
-
}
|
|
2404
|
-
};
|
|
2405
|
-
AcceptCreateRelationshipAttributeRequestItemParameters = __decorate([
|
|
2406
|
-
(0, ts_serval_1.type)("AcceptCreateRelationshipAttributeRequestItemParameters")
|
|
2407
|
-
], AcceptCreateRelationshipAttributeRequestItemParameters);
|
|
2408
|
-
exports.AcceptCreateRelationshipAttributeRequestItemParameters = AcceptCreateRelationshipAttributeRequestItemParameters;
|
|
2409
|
-
//# sourceMappingURL=AcceptCreateRelationshipAttributeRequestItemParameters.js.map
|
|
2410
|
-
|
|
2411
|
-
/***/ }),
|
|
2412
|
-
|
|
2413
|
-
/***/ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js":
|
|
2414
|
-
/*!*****************************************************************************************************************************!*\
|
|
2415
|
-
!*** ./dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js ***!
|
|
2416
|
-
\*****************************************************************************************************************************/
|
|
2821
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
2822
|
+
/*!*****************************************************************************************************!*\
|
|
2823
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
2824
|
+
\*****************************************************************************************************/
|
|
2417
2825
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2418
2826
|
|
|
2419
2827
|
"use strict";
|
|
2420
2828
|
|
|
2421
2829
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2422
|
-
exports.
|
|
2830
|
+
exports.CreateAttributeRequestItemProcessor = void 0;
|
|
2423
2831
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2424
2832
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2425
2833
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2426
2834
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2427
|
-
class
|
|
2428
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2835
|
+
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2836
|
+
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
2837
|
+
const recipientIsAttributeOwner = requestItem.attribute.owner.equals(recipient);
|
|
2838
|
+
const senderIsAttributeOwner = requestItem.attribute.owner.equals(this.currentIdentityAddress);
|
|
2839
|
+
const ownerIsEmptyString = requestItem.attribute.owner.toString() === "";
|
|
2840
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2841
|
+
if (senderIsAttributeOwner) {
|
|
2842
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("Cannot create own Attributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead."));
|
|
2843
|
+
}
|
|
2844
|
+
if (recipientIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
2845
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2846
|
+
}
|
|
2847
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The owner of the given `attribute` can only be the recipient's address or an empty string. The latter will default to the recipient's address."));
|
|
2432
2848
|
}
|
|
2433
|
-
|
|
2849
|
+
if (recipientIsAttributeOwner || senderIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
2850
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2851
|
+
}
|
|
2852
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The owner of the given 'attribute' can only be the sender's address, the recipient's address or an empty string. The latter will default to the recipient's address."));
|
|
2434
2853
|
}
|
|
2435
2854
|
async accept(requestItem, _params, requestInfo) {
|
|
2436
|
-
requestItem.attribute.owner
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2855
|
+
if (requestItem.attribute.owner.toString() === "") {
|
|
2856
|
+
requestItem.attribute.owner = this.currentIdentityAddress;
|
|
2857
|
+
}
|
|
2858
|
+
let sharedAttribute;
|
|
2859
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2860
|
+
const repositoryAttribute = await this.consumptionController.attributes.createLocalAttribute({
|
|
2861
|
+
content: requestItem.attribute
|
|
2862
|
+
});
|
|
2863
|
+
sharedAttribute = await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2864
|
+
peer: requestInfo.peer,
|
|
2865
|
+
requestReference: requestInfo.id,
|
|
2866
|
+
sourceAttributeId: repositoryAttribute.id
|
|
2867
|
+
});
|
|
2868
|
+
}
|
|
2869
|
+
else {
|
|
2870
|
+
sharedAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2871
|
+
content: requestItem.attribute,
|
|
2872
|
+
peer: requestInfo.peer,
|
|
2873
|
+
requestReference: requestInfo.id
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
return content_1.CreateAttributeAcceptResponseItem.from({
|
|
2443
2877
|
result: content_1.ResponseItemResult.Accepted,
|
|
2444
|
-
attributeId:
|
|
2878
|
+
attributeId: sharedAttribute.id
|
|
2445
2879
|
});
|
|
2446
2880
|
}
|
|
2447
2881
|
async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
|
|
2448
|
-
if (!(responseItem instanceof content_1.
|
|
2882
|
+
if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
|
|
2449
2883
|
return;
|
|
2450
2884
|
}
|
|
2451
2885
|
if (requestItem.attribute.owner.toString() === "") {
|
|
2452
|
-
requestItem.attribute.owner =
|
|
2886
|
+
requestItem.attribute.owner = requestInfo.peer;
|
|
2453
2887
|
}
|
|
2454
2888
|
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2455
2889
|
id: responseItem.attributeId,
|
|
@@ -2459,8 +2893,8 @@ class CreateRelationshipAttributeRequestItemProcessor extends GenericRequestItem
|
|
|
2459
2893
|
});
|
|
2460
2894
|
}
|
|
2461
2895
|
}
|
|
2462
|
-
exports.
|
|
2463
|
-
//# sourceMappingURL=
|
|
2896
|
+
exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
|
|
2897
|
+
//# sourceMappingURL=CreateAttributeRequestItemProcessor.js.map
|
|
2464
2898
|
|
|
2465
2899
|
/***/ }),
|
|
2466
2900
|
|
|
@@ -2488,16 +2922,25 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
|
|
|
2488
2922
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2489
2923
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2490
2924
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
2925
|
+
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2491
2926
|
let AcceptProposeAttributeRequestItemParameters = AcceptProposeAttributeRequestItemParameters_1 = class AcceptProposeAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2927
|
+
isWithExistingAttribute() {
|
|
2928
|
+
return this.attributeId !== undefined;
|
|
2929
|
+
}
|
|
2930
|
+
isWithNewAttribute() {
|
|
2931
|
+
return this.attribute !== undefined;
|
|
2932
|
+
}
|
|
2492
2933
|
static from(value) {
|
|
2493
2934
|
return this.fromAny(value);
|
|
2494
2935
|
}
|
|
2495
2936
|
static postFrom(value) {
|
|
2496
|
-
|
|
2497
|
-
|
|
2937
|
+
if (!(value instanceof AcceptProposeAttributeRequestItemParameters_1)) {
|
|
2938
|
+
throw new consumption_1.ConsumptionError("this should never happen");
|
|
2939
|
+
}
|
|
2940
|
+
if (value.attributeId && value.attribute) {
|
|
2498
2941
|
throw new ts_serval_1.ValidationError(AcceptProposeAttributeRequestItemParameters_1.name, (0, ts_simple_nameof_1.nameof)((x) => x.attribute), `You cannot specify both ${(0, ts_simple_nameof_1.nameof)((x) => x.attribute)} and ${(0, ts_simple_nameof_1.nameof)((x) => x.attributeId)}.`);
|
|
2499
2942
|
}
|
|
2500
|
-
if (!
|
|
2943
|
+
if (!value.attributeId && !value.attribute) {
|
|
2501
2944
|
throw new ts_serval_1.ValidationError(AcceptProposeAttributeRequestItemParameters_1.name, (0, ts_simple_nameof_1.nameof)((x) => x.attribute), `You have to specify either ${(0, ts_simple_nameof_1.nameof)((x) => x.attribute)} or ${(0, ts_simple_nameof_1.nameof)((x) => x.attributeId)}.`);
|
|
2502
2945
|
}
|
|
2503
2946
|
return value;
|
|
@@ -2556,7 +2999,7 @@ class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1
|
|
|
2556
2999
|
}
|
|
2557
3000
|
validateAttribute(attribute) {
|
|
2558
3001
|
if (attribute.owner.toString() !== "") {
|
|
2559
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3002
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The owner of the given `attribute` can only be an empty string. This is because you can only propose Attributes where the recipient of the Request is the owner anyway. And in order to avoid mistakes, the owner will be automatically filled for you."));
|
|
2560
3003
|
}
|
|
2561
3004
|
return ValidationResult_1.ValidationResult.success();
|
|
2562
3005
|
}
|
|
@@ -2566,29 +3009,29 @@ class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1
|
|
|
2566
3009
|
return commonQueryValidationResult;
|
|
2567
3010
|
}
|
|
2568
3011
|
if (requestItem.query instanceof content_1.RelationshipAttributeQuery && requestItem.query.owner.toString() !== "") {
|
|
2569
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3012
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The owner of the given `query` can only be an empty string. This is because you can only propose Attributes where the recipient of the Request is the owner anyway. And in order to avoid mistakes, the owner will be automatically filled for you."));
|
|
2570
3013
|
}
|
|
2571
3014
|
return ValidationResult_1.ValidationResult.success();
|
|
2572
3015
|
}
|
|
2573
3016
|
async canAccept(_requestItem, params, requestInfo) {
|
|
2574
3017
|
const parsedParams = AcceptProposeAttributeRequestItemParameters_1.AcceptProposeAttributeRequestItemParameters.from(params);
|
|
2575
3018
|
let attribute = parsedParams.attribute;
|
|
2576
|
-
if (parsedParams.
|
|
3019
|
+
if (parsedParams.isWithExistingAttribute()) {
|
|
2577
3020
|
const localAttribute = await this.consumptionController.attributes.getLocalAttribute(parsedParams.attributeId);
|
|
2578
3021
|
if (!localAttribute) {
|
|
2579
|
-
return ValidationResult_1.ValidationResult.error(transport_1.
|
|
3022
|
+
return ValidationResult_1.ValidationResult.error(transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, requestInfo.id.toString()));
|
|
2580
3023
|
}
|
|
2581
3024
|
attribute = localAttribute.content;
|
|
2582
3025
|
}
|
|
2583
3026
|
if (!attribute.owner.equals(this.currentIdentityAddress)) {
|
|
2584
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3027
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The given Attribute belongs to someone else. You can only share own Attributes."));
|
|
2585
3028
|
}
|
|
2586
3029
|
return ValidationResult_1.ValidationResult.success();
|
|
2587
3030
|
}
|
|
2588
3031
|
async accept(_requestItem, params, requestInfo) {
|
|
2589
3032
|
const parsedParams = AcceptProposeAttributeRequestItemParameters_1.AcceptProposeAttributeRequestItemParameters.from(params);
|
|
2590
3033
|
let sharedLocalAttribute;
|
|
2591
|
-
if (parsedParams.
|
|
3034
|
+
if (parsedParams.isWithExistingAttribute()) {
|
|
2592
3035
|
sharedLocalAttribute = await this.copyExistingAttribute(parsedParams.attributeId, requestInfo);
|
|
2593
3036
|
}
|
|
2594
3037
|
else {
|
|
@@ -2665,6 +3108,7 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
|
|
|
2665
3108
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2666
3109
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2667
3110
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
3111
|
+
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2668
3112
|
let AcceptReadAttributeRequestItemParameters = AcceptReadAttributeRequestItemParameters_1 = class AcceptReadAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2669
3113
|
isWithExistingAttribute() {
|
|
2670
3114
|
return this.existingAttributeId !== undefined;
|
|
@@ -2676,8 +3120,9 @@ let AcceptReadAttributeRequestItemParameters = AcceptReadAttributeRequestItemPar
|
|
|
2676
3120
|
return this.fromAny(value);
|
|
2677
3121
|
}
|
|
2678
3122
|
static postFrom(value) {
|
|
2679
|
-
if (!(value instanceof AcceptReadAttributeRequestItemParameters_1))
|
|
2680
|
-
throw new
|
|
3123
|
+
if (!(value instanceof AcceptReadAttributeRequestItemParameters_1)) {
|
|
3124
|
+
throw new consumption_1.ConsumptionError("this should never happen");
|
|
3125
|
+
}
|
|
2681
3126
|
if (value.existingAttributeId && value.newAttribute) {
|
|
2682
3127
|
throw new ts_serval_1.ValidationError(AcceptReadAttributeRequestItemParameters_1.name, (0, ts_simple_nameof_1.nameof)((x) => x.newAttribute), `You cannot specify both ${(0, ts_simple_nameof_1.nameof)((x) => x.newAttribute)} and ${(0, ts_simple_nameof_1.nameof)((x) => x.existingAttributeId)}.`);
|
|
2683
3128
|
}
|
|
@@ -2739,11 +3184,11 @@ class ReadAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.Ge
|
|
|
2739
3184
|
if (parsedParams.isWithExistingAttribute()) {
|
|
2740
3185
|
const foundAttribute = await this.consumptionController.attributes.getLocalAttribute(parsedParams.existingAttributeId);
|
|
2741
3186
|
if (!foundAttribute) {
|
|
2742
|
-
return ValidationResult_1.ValidationResult.error(transport_1.
|
|
3187
|
+
return ValidationResult_1.ValidationResult.error(transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, requestInfo.id.toString()));
|
|
2743
3188
|
}
|
|
2744
3189
|
const ownerIsCurrentIdentity = this.accountController.identity.isMe(foundAttribute.content.owner);
|
|
2745
3190
|
if (!ownerIsCurrentIdentity) {
|
|
2746
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3191
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The given Attribute belongs to someone else. You can only share own Attributes."));
|
|
2747
3192
|
}
|
|
2748
3193
|
}
|
|
2749
3194
|
return ValidationResult_1.ValidationResult.success();
|
|
@@ -2804,33 +3249,32 @@ exports.ReadAttributeRequestItemProcessor = ReadAttributeRequestItemProcessor;
|
|
|
2804
3249
|
|
|
2805
3250
|
/***/ }),
|
|
2806
3251
|
|
|
2807
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2808
|
-
|
|
2809
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2810
|
-
|
|
2811
|
-
/***/ (
|
|
3252
|
+
/***/ "./dist/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.js":
|
|
3253
|
+
/*!*************************************************************************************************************************!*\
|
|
3254
|
+
!*** ./dist/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.js ***!
|
|
3255
|
+
\*************************************************************************************************************************/
|
|
3256
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2812
3257
|
|
|
2813
3258
|
"use strict";
|
|
2814
3259
|
|
|
2815
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2816
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2817
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2818
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2819
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2820
|
-
};
|
|
2821
3260
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2822
|
-
exports.
|
|
2823
|
-
const
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
3261
|
+
exports.RegisterAttributeListenerRequestItemProcessor = void 0;
|
|
3262
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3263
|
+
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3264
|
+
class RegisterAttributeListenerRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
3265
|
+
async accept(requestItem, _params, requestInfo) {
|
|
3266
|
+
const listener = await this.consumptionController.attributeListeners.createAttributeListener({
|
|
3267
|
+
peer: requestInfo.peer,
|
|
3268
|
+
query: requestItem.query
|
|
3269
|
+
});
|
|
3270
|
+
return content_1.RegisterAttributeListenerAcceptResponseItem.from({
|
|
3271
|
+
result: content_1.ResponseItemResult.Accepted,
|
|
3272
|
+
listenerId: listener.id.toString()
|
|
3273
|
+
});
|
|
2827
3274
|
}
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
], AcceptShareAttributeRequestItemParameters);
|
|
2832
|
-
exports.AcceptShareAttributeRequestItemParameters = AcceptShareAttributeRequestItemParameters;
|
|
2833
|
-
//# sourceMappingURL=AcceptShareAttributeRequestItemParameters.js.map
|
|
3275
|
+
}
|
|
3276
|
+
exports.RegisterAttributeListenerRequestItemProcessor = RegisterAttributeListenerRequestItemProcessor;
|
|
3277
|
+
//# sourceMappingURL=RegisterAttributeListenerRequestItemProcessor.js.map
|
|
2834
3278
|
|
|
2835
3279
|
/***/ }),
|
|
2836
3280
|
|
|
@@ -2849,23 +3293,26 @@ const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist
|
|
|
2849
3293
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2850
3294
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2851
3295
|
class ShareAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2852
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
3296
|
+
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
2853
3297
|
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2854
3298
|
return this.canCreateWithIdentityAttribute(requestItem);
|
|
2855
3299
|
}
|
|
2856
|
-
return this.canCreateWithRelationshipAttribute(requestItem.attribute);
|
|
3300
|
+
return this.canCreateWithRelationshipAttribute(requestItem.attribute, recipient);
|
|
2857
3301
|
}
|
|
2858
3302
|
canCreateWithIdentityAttribute(requestItem) {
|
|
2859
3303
|
const ownerIsEmpty = requestItem.attribute.owner.toString() === "";
|
|
2860
3304
|
const ownerIsCurrentIdentity = requestItem.attribute.owner.equals(this.currentIdentityAddress);
|
|
2861
3305
|
if (!ownerIsEmpty && !ownerIsCurrentIdentity) {
|
|
2862
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3306
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The owner of the given `attribute` can only be an empty string. This is because you can only send Attributes where the recipient of the Request is the owner anyway. And in order to avoid mistakes, the owner will be automatically filled for you."));
|
|
2863
3307
|
}
|
|
2864
3308
|
return ValidationResult_1.ValidationResult.success();
|
|
2865
3309
|
}
|
|
2866
|
-
canCreateWithRelationshipAttribute(attribute) {
|
|
3310
|
+
canCreateWithRelationshipAttribute(attribute, recipient) {
|
|
2867
3311
|
if (attribute.confidentiality === content_1.RelationshipAttributeConfidentiality.Private) {
|
|
2868
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3312
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The confidentiality of the given `attribute` is private. Therefore you are not allowed to share it."));
|
|
3313
|
+
}
|
|
3314
|
+
if (attribute.owner.equals(recipient)) {
|
|
3315
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("It doesn't make sense to share a RelationshipAttribute with its owner."));
|
|
2869
3316
|
}
|
|
2870
3317
|
return ValidationResult_1.ValidationResult.success();
|
|
2871
3318
|
}
|
|
@@ -2913,15 +3360,15 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
2913
3360
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2914
3361
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2915
3362
|
function validateQuery(query, sender, recipient) {
|
|
2916
|
-
if (query instanceof content_1.
|
|
2917
|
-
if (query.thirdParty
|
|
2918
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3363
|
+
if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
|
|
3364
|
+
if (query.thirdParty.equals(sender)) {
|
|
3365
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party."));
|
|
2919
3366
|
}
|
|
2920
|
-
if (query.thirdParty
|
|
2921
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3367
|
+
if (query.thirdParty.equals(recipient)) {
|
|
3368
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party."));
|
|
2922
3369
|
}
|
|
2923
|
-
if (query.owner.equals(sender)
|
|
2924
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
3370
|
+
if (query.owner.equals(sender)) {
|
|
3371
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("Cannot query own Attributes from a third party."));
|
|
2925
3372
|
}
|
|
2926
3373
|
}
|
|
2927
3374
|
return ValidationResult_1.ValidationResult.success();
|
|
@@ -2953,6 +3400,7 @@ exports.LocalRequest = exports.LocalRequestSource = void 0;
|
|
|
2953
3400
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2954
3401
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2955
3402
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3403
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
2956
3404
|
const LocalRequestStatus_1 = __webpack_require__(/*! ./LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js");
|
|
2957
3405
|
const LocalRequestStatusLogEntry_1 = __webpack_require__(/*! ./LocalRequestStatusLogEntry */ "./dist/modules/requests/local/LocalRequestStatusLogEntry.js");
|
|
2958
3406
|
const LocalResponse_1 = __webpack_require__(/*! ./LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|
|
@@ -2977,6 +3425,8 @@ LocalRequestSource = __decorate([
|
|
|
2977
3425
|
exports.LocalRequestSource = LocalRequestSource;
|
|
2978
3426
|
let LocalRequest = class LocalRequest extends transport_1.CoreSynchronizable {
|
|
2979
3427
|
changeStatus(newStatus) {
|
|
3428
|
+
if (this.status === newStatus)
|
|
3429
|
+
throw new consumption_1.ConsumptionError("cannot change status to the same status");
|
|
2980
3430
|
const logEntry = LocalRequestStatusLogEntry_1.LocalRequestStatusLogEntry.from({
|
|
2981
3431
|
createdAt: transport_1.CoreDate.utc(),
|
|
2982
3432
|
oldStatus: this.status,
|
|
@@ -2987,7 +3437,7 @@ let LocalRequest = class LocalRequest extends transport_1.CoreSynchronizable {
|
|
|
2987
3437
|
}
|
|
2988
3438
|
sent(source) {
|
|
2989
3439
|
if (this.status !== LocalRequestStatus_1.LocalRequestStatus.Draft) {
|
|
2990
|
-
throw new
|
|
3440
|
+
throw new consumption_1.ConsumptionError("Local Request has to be in status 'Draft'.");
|
|
2991
3441
|
}
|
|
2992
3442
|
this.source = source;
|
|
2993
3443
|
this.changeStatus(LocalRequestStatus_1.LocalRequestStatus.Open);
|
|
@@ -2995,6 +3445,20 @@ let LocalRequest = class LocalRequest extends transport_1.CoreSynchronizable {
|
|
|
2995
3445
|
static from(value) {
|
|
2996
3446
|
return this.fromAny(value);
|
|
2997
3447
|
}
|
|
3448
|
+
isExpired(comparisonDate = transport_1.CoreDate.utc()) {
|
|
3449
|
+
if (!this.content.expiresAt)
|
|
3450
|
+
return false;
|
|
3451
|
+
return comparisonDate.isAfter(this.content.expiresAt.add({ seconds: 10 }));
|
|
3452
|
+
}
|
|
3453
|
+
updateStatusBasedOnExpiration(comparisonDate = transport_1.CoreDate.utc()) {
|
|
3454
|
+
if (this.status === LocalRequestStatus_1.LocalRequestStatus.Completed || this.status === LocalRequestStatus_1.LocalRequestStatus.Expired)
|
|
3455
|
+
return false;
|
|
3456
|
+
if (this.isExpired(comparisonDate)) {
|
|
3457
|
+
this.changeStatus(LocalRequestStatus_1.LocalRequestStatus.Expired);
|
|
3458
|
+
return true;
|
|
3459
|
+
}
|
|
3460
|
+
return false;
|
|
3461
|
+
}
|
|
2998
3462
|
};
|
|
2999
3463
|
__decorate([
|
|
3000
3464
|
(0, ts_serval_1.serialize)(),
|
|
@@ -3062,6 +3526,7 @@ var LocalRequestStatus;
|
|
|
3062
3526
|
LocalRequestStatus["ManualDecisionRequired"] = "ManualDecisionRequired";
|
|
3063
3527
|
LocalRequestStatus["Decided"] = "Decided";
|
|
3064
3528
|
LocalRequestStatus["Completed"] = "Completed";
|
|
3529
|
+
LocalRequestStatus["Expired"] = "Expired";
|
|
3065
3530
|
})(LocalRequestStatus = exports.LocalRequestStatus || (exports.LocalRequestStatus = {}));
|
|
3066
3531
|
//# sourceMappingURL=LocalRequestStatus.js.map
|
|
3067
3532
|
|
|
@@ -3216,6 +3681,7 @@ const LocalRequestStatus_1 = __webpack_require__(/*! ../local/LocalRequestStatus
|
|
|
3216
3681
|
const LocalResponse_1 = __webpack_require__(/*! ../local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|
|
3217
3682
|
const CompleteOutgoingRequestParameters_1 = __webpack_require__(/*! ./completeOutgoingRequest/CompleteOutgoingRequestParameters */ "./dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js");
|
|
3218
3683
|
const CreateOutgoingRequestFromRelationshipCreationChangeParameters_1 = __webpack_require__(/*! ./createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters */ "./dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js");
|
|
3684
|
+
const CanCreateOutgoingRequestParameters_1 = __webpack_require__(/*! ./createOutgoingRequest/CanCreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js");
|
|
3219
3685
|
const CreateOutgoingRequestParameters_1 = __webpack_require__(/*! ./createOutgoingRequest/CreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js");
|
|
3220
3686
|
const SentOutgoingRequestParameters_1 = __webpack_require__(/*! ./sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js");
|
|
3221
3687
|
class OutgoingRequestsController extends consumption_1.ConsumptionBaseController {
|
|
@@ -3227,7 +3693,7 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3227
3693
|
this.identity = identity;
|
|
3228
3694
|
}
|
|
3229
3695
|
async canCreate(params) {
|
|
3230
|
-
const parsedParams =
|
|
3696
|
+
const parsedParams = CanCreateOutgoingRequestParameters_1.CanCreateOutgoingRequestParameters.from(params);
|
|
3231
3697
|
const innerResults = await this.canCreateItems(parsedParams.content, parsedParams.peer);
|
|
3232
3698
|
const result = ValidationResult_1.ValidationResult.fromItems(innerResults);
|
|
3233
3699
|
return result;
|
|
@@ -3268,16 +3734,13 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3268
3734
|
return request;
|
|
3269
3735
|
}
|
|
3270
3736
|
async _create(id, content, peer) {
|
|
3271
|
-
const canCreateResult = await this.canCreate({
|
|
3272
|
-
content,
|
|
3273
|
-
peer
|
|
3274
|
-
});
|
|
3737
|
+
const canCreateResult = await this.canCreate({ content, peer });
|
|
3275
3738
|
if (canCreateResult.isError()) {
|
|
3276
3739
|
throw canCreateResult.error;
|
|
3277
3740
|
}
|
|
3278
3741
|
const request = LocalRequest_1.LocalRequest.from({
|
|
3279
3742
|
id: id,
|
|
3280
|
-
content
|
|
3743
|
+
content,
|
|
3281
3744
|
createdAt: transport_1.CoreDate.utc(),
|
|
3282
3745
|
isOwn: true,
|
|
3283
3746
|
peer: peer,
|
|
@@ -3290,17 +3753,16 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3290
3753
|
async createFromRelationshipCreationChange(params) {
|
|
3291
3754
|
const parsedParams = CreateOutgoingRequestFromRelationshipCreationChangeParameters_1.CreateOutgoingRequestFromRelationshipCreationChangeParameters.from(params);
|
|
3292
3755
|
const peer = parsedParams.creationChange.request.createdBy;
|
|
3293
|
-
const
|
|
3294
|
-
if (!(
|
|
3295
|
-
throw new
|
|
3756
|
+
const requestContent = parsedParams.creationChange.request.content;
|
|
3757
|
+
if (!(requestContent instanceof content_1.RelationshipCreationChangeRequestContent)) {
|
|
3758
|
+
throw new consumption_1.ConsumptionError("The content of the request is not supported as it is not type of RelationshipCreationChangeRequestContent.");
|
|
3296
3759
|
}
|
|
3297
|
-
const receivedResponse =
|
|
3760
|
+
const receivedResponse = requestContent.response;
|
|
3298
3761
|
const id = receivedResponse.requestId;
|
|
3299
3762
|
const templateContent = parsedParams.template.cache.content;
|
|
3300
|
-
if (!(templateContent instanceof content_1.
|
|
3301
|
-
throw new
|
|
3763
|
+
if (!(templateContent instanceof content_1.RelationshipTemplateContent)) {
|
|
3764
|
+
throw new consumption_1.ConsumptionError("The content of the template is not supported as it is not type of RelationshipTemplateContent.");
|
|
3302
3765
|
}
|
|
3303
|
-
// TODO: is this the correct request (=> could be RelationshipTemplateBody#existingRelationshipRequest)
|
|
3304
3766
|
await this._create(id, templateContent.onNewRelationship, peer);
|
|
3305
3767
|
await this._sent(id, parsedParams.template);
|
|
3306
3768
|
const request = await this._complete(id, parsedParams.creationChange, receivedResponse);
|
|
@@ -3331,17 +3793,17 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3331
3793
|
getSourceType(sourceObject) {
|
|
3332
3794
|
if (sourceObject instanceof transport_1.Message) {
|
|
3333
3795
|
if (!sourceObject.isOwn) {
|
|
3334
|
-
throw new
|
|
3796
|
+
throw new consumption_1.ConsumptionError("Cannot create outgoing Request from a peer Message");
|
|
3335
3797
|
}
|
|
3336
3798
|
return "Message";
|
|
3337
3799
|
}
|
|
3338
3800
|
else if (sourceObject instanceof transport_1.RelationshipTemplate) {
|
|
3339
3801
|
if (!sourceObject.isOwn) {
|
|
3340
|
-
throw new
|
|
3802
|
+
throw new consumption_1.ConsumptionError("Cannot create outgoing Request from a peer Relationship Template");
|
|
3341
3803
|
}
|
|
3342
3804
|
return "RelationshipTemplate";
|
|
3343
3805
|
}
|
|
3344
|
-
throw new
|
|
3806
|
+
throw new consumption_1.ConsumptionError("The given sourceObject is not of a valid type. Valid types are 'Message' and 'RelationshipTemplate'.");
|
|
3345
3807
|
}
|
|
3346
3808
|
async complete(params) {
|
|
3347
3809
|
const parsedParams = CompleteOutgoingRequestParameters_1.CompleteOugoingRequestParameters.from(params);
|
|
@@ -3355,7 +3817,13 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3355
3817
|
}
|
|
3356
3818
|
async _complete(requestId, responseSourceObject, receivedResponse) {
|
|
3357
3819
|
const request = await this.getOrThrow(requestId);
|
|
3358
|
-
this.assertRequestStatus(request, LocalRequestStatus_1.LocalRequestStatus.Open);
|
|
3820
|
+
this.assertRequestStatus(request, LocalRequestStatus_1.LocalRequestStatus.Open, LocalRequestStatus_1.LocalRequestStatus.Expired);
|
|
3821
|
+
const responseSourceObjectCreationDate = responseSourceObject instanceof transport_1.Message
|
|
3822
|
+
? responseSourceObject.cache.createdAt
|
|
3823
|
+
: responseSourceObject.request.createdAt;
|
|
3824
|
+
if (request.status === LocalRequestStatus_1.LocalRequestStatus.Expired && request.isExpired(responseSourceObjectCreationDate)) {
|
|
3825
|
+
throw new consumption_1.ConsumptionError("Cannot complete an expired request with a response that was created before the expiration date");
|
|
3826
|
+
}
|
|
3359
3827
|
const canComplete = await this.canComplete(request, receivedResponse);
|
|
3360
3828
|
if (canComplete.isError()) {
|
|
3361
3829
|
throw canComplete.error;
|
|
@@ -3369,7 +3837,7 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3369
3837
|
responseSource = "RelationshipChange";
|
|
3370
3838
|
}
|
|
3371
3839
|
else {
|
|
3372
|
-
throw new
|
|
3840
|
+
throw new consumption_1.ConsumptionError("Invalid responseSourceObject");
|
|
3373
3841
|
}
|
|
3374
3842
|
const localResponse = LocalResponse_1.LocalResponse.from({
|
|
3375
3843
|
content: receivedResponse,
|
|
@@ -3425,36 +3893,50 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3425
3893
|
await processor.applyIncomingResponseItem(responseItem, requestItem, request);
|
|
3426
3894
|
}
|
|
3427
3895
|
async getOutgoingRequests(query) {
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3896
|
+
const requestDocs = await this.localRequests.find({
|
|
3897
|
+
...query,
|
|
3898
|
+
isOwn: true
|
|
3899
|
+
});
|
|
3900
|
+
const requestPromises = requestDocs.map((r) => this.updateRequestExpiry(LocalRequest_1.LocalRequest.from(r)));
|
|
3901
|
+
return await Promise.all(requestPromises);
|
|
3902
|
+
}
|
|
3903
|
+
async discardOutgoingRequest(id) {
|
|
3904
|
+
const request = await this.getOrThrow(id);
|
|
3905
|
+
this.assertRequestStatus(request, LocalRequestStatus_1.LocalRequestStatus.Draft);
|
|
3906
|
+
await this.localRequests.delete(request);
|
|
3433
3907
|
}
|
|
3434
3908
|
async getOutgoingRequest(id) {
|
|
3435
3909
|
const requestDoc = await this.localRequests.findOne({ id: id.toString(), isOwn: true });
|
|
3436
|
-
|
|
3437
|
-
|
|
3910
|
+
if (!requestDoc)
|
|
3911
|
+
return;
|
|
3912
|
+
const localRequest = LocalRequest_1.LocalRequest.from(requestDoc);
|
|
3913
|
+
return await this.updateRequestExpiry(localRequest);
|
|
3438
3914
|
}
|
|
3439
3915
|
async getOrThrow(id) {
|
|
3440
3916
|
const request = await this.getOutgoingRequest(id);
|
|
3441
3917
|
if (!request) {
|
|
3442
|
-
throw transport_1.
|
|
3918
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, id.toString());
|
|
3443
3919
|
}
|
|
3444
3920
|
return request;
|
|
3445
3921
|
}
|
|
3446
3922
|
async update(request) {
|
|
3447
3923
|
const requestDoc = await this.localRequests.findOne({ id: request.id.toString(), isOwn: true });
|
|
3448
3924
|
if (!requestDoc) {
|
|
3449
|
-
throw transport_1.
|
|
3925
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, request.id.toString());
|
|
3450
3926
|
}
|
|
3451
3927
|
await this.localRequests.update(requestDoc, request);
|
|
3452
3928
|
}
|
|
3453
3929
|
assertRequestStatus(request, ...status) {
|
|
3454
3930
|
if (!status.includes(request.status)) {
|
|
3455
|
-
throw new
|
|
3931
|
+
throw new consumption_1.ConsumptionError(`Local Request has to be in status '${status.join("/")}'.`);
|
|
3456
3932
|
}
|
|
3457
3933
|
}
|
|
3934
|
+
async updateRequestExpiry(request) {
|
|
3935
|
+
const statusUpdated = request.updateStatusBasedOnExpiration();
|
|
3936
|
+
if (statusUpdated)
|
|
3937
|
+
await this.update(request);
|
|
3938
|
+
return request;
|
|
3939
|
+
}
|
|
3458
3940
|
}
|
|
3459
3941
|
exports.OutgoingRequestsController = OutgoingRequestsController;
|
|
3460
3942
|
//# sourceMappingURL=OutgoingRequestsController.js.map
|
|
@@ -3555,6 +4037,51 @@ exports.CreateOutgoingRequestFromRelationshipCreationChangeParameters = CreateOu
|
|
|
3555
4037
|
|
|
3556
4038
|
/***/ }),
|
|
3557
4039
|
|
|
4040
|
+
/***/ "./dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js":
|
|
4041
|
+
/*!****************************************************************************************************!*\
|
|
4042
|
+
!*** ./dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js ***!
|
|
4043
|
+
\****************************************************************************************************/
|
|
4044
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4045
|
+
|
|
4046
|
+
"use strict";
|
|
4047
|
+
|
|
4048
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4049
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4050
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4051
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4052
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4053
|
+
};
|
|
4054
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4055
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4056
|
+
};
|
|
4057
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4058
|
+
exports.CanCreateOutgoingRequestParameters = void 0;
|
|
4059
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
4060
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
4061
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
4062
|
+
let CanCreateOutgoingRequestParameters = class CanCreateOutgoingRequestParameters extends ts_serval_1.Serializable {
|
|
4063
|
+
static from(value) {
|
|
4064
|
+
return this.fromAny(value);
|
|
4065
|
+
}
|
|
4066
|
+
};
|
|
4067
|
+
__decorate([
|
|
4068
|
+
(0, ts_serval_1.serialize)(),
|
|
4069
|
+
(0, ts_serval_1.validate)(),
|
|
4070
|
+
__metadata("design:type", content_1.Request)
|
|
4071
|
+
], CanCreateOutgoingRequestParameters.prototype, "content", void 0);
|
|
4072
|
+
__decorate([
|
|
4073
|
+
(0, ts_serval_1.serialize)(),
|
|
4074
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
4075
|
+
__metadata("design:type", transport_1.CoreAddress)
|
|
4076
|
+
], CanCreateOutgoingRequestParameters.prototype, "peer", void 0);
|
|
4077
|
+
CanCreateOutgoingRequestParameters = __decorate([
|
|
4078
|
+
(0, ts_serval_1.type)("CanCreateOutgoingRequestParameters")
|
|
4079
|
+
], CanCreateOutgoingRequestParameters);
|
|
4080
|
+
exports.CanCreateOutgoingRequestParameters = CanCreateOutgoingRequestParameters;
|
|
4081
|
+
//# sourceMappingURL=CanCreateOutgoingRequestParameters.js.map
|
|
4082
|
+
|
|
4083
|
+
/***/ }),
|
|
4084
|
+
|
|
3558
4085
|
/***/ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js":
|
|
3559
4086
|
/*!*************************************************************************************************!*\
|
|
3560
4087
|
!*** ./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js ***!
|
|
@@ -3648,12 +4175,22 @@ exports.SentOutgoingRequestParameters = SentOutgoingRequestParameters;
|
|
|
3648
4175
|
/*!*****************************************************!*\
|
|
3649
4176
|
!*** ./dist/modules/settings/SettingsController.js ***!
|
|
3650
4177
|
\*****************************************************/
|
|
3651
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4178
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3652
4179
|
|
|
3653
4180
|
"use strict";
|
|
3654
4181
|
|
|
4182
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4183
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4184
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4185
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4186
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4187
|
+
};
|
|
4188
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
4189
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4190
|
+
};
|
|
3655
4191
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3656
4192
|
exports.SettingsController = void 0;
|
|
4193
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
3657
4194
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3658
4195
|
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
3659
4196
|
const Setting_1 = __webpack_require__(/*! ./local/Setting */ "./dist/modules/settings/local/Setting.js");
|
|
@@ -3672,7 +4209,7 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3672
4209
|
}
|
|
3673
4210
|
async getSettings(query) {
|
|
3674
4211
|
const items = await this.settings.find(query);
|
|
3675
|
-
return
|
|
4212
|
+
return this.parseArray(items, Setting_1.Setting);
|
|
3676
4213
|
}
|
|
3677
4214
|
async createSetting(parameters) {
|
|
3678
4215
|
const setting = Setting_1.Setting.from({
|
|
@@ -3690,20 +4227,55 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3690
4227
|
}
|
|
3691
4228
|
async updateSetting(setting) {
|
|
3692
4229
|
const oldSetting = await this.settings.read(setting.id.toString());
|
|
3693
|
-
if (!oldSetting)
|
|
3694
|
-
throw transport_1.
|
|
3695
|
-
}
|
|
4230
|
+
if (!oldSetting)
|
|
4231
|
+
throw transport_1.CoreErrors.general.recordNotFound(Setting_1.Setting, setting.id.toString());
|
|
3696
4232
|
await this.settings.update(oldSetting, setting);
|
|
3697
4233
|
}
|
|
3698
4234
|
async deleteSetting(setting) {
|
|
3699
4235
|
await this.settings.delete(setting);
|
|
3700
4236
|
}
|
|
3701
4237
|
}
|
|
4238
|
+
__decorate([
|
|
4239
|
+
(0, ts_utils_1.log)(),
|
|
4240
|
+
__metadata("design:type", Function),
|
|
4241
|
+
__metadata("design:paramtypes", [Setting_1.Setting]),
|
|
4242
|
+
__metadata("design:returntype", Promise)
|
|
4243
|
+
], SettingsController.prototype, "updateSetting", null);
|
|
3702
4244
|
exports.SettingsController = SettingsController;
|
|
3703
4245
|
//# sourceMappingURL=SettingsController.js.map
|
|
3704
4246
|
|
|
3705
4247
|
/***/ }),
|
|
3706
4248
|
|
|
4249
|
+
/***/ "./dist/modules/settings/index.js":
|
|
4250
|
+
/*!****************************************!*\
|
|
4251
|
+
!*** ./dist/modules/settings/index.js ***!
|
|
4252
|
+
\****************************************/
|
|
4253
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4254
|
+
|
|
4255
|
+
"use strict";
|
|
4256
|
+
|
|
4257
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4258
|
+
if (k2 === undefined) k2 = k;
|
|
4259
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4260
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4261
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4262
|
+
}
|
|
4263
|
+
Object.defineProperty(o, k2, desc);
|
|
4264
|
+
}) : (function(o, m, k, k2) {
|
|
4265
|
+
if (k2 === undefined) k2 = k;
|
|
4266
|
+
o[k2] = m[k];
|
|
4267
|
+
}));
|
|
4268
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
4269
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4270
|
+
};
|
|
4271
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4272
|
+
__exportStar(__webpack_require__(/*! ./local/CreateSettingParameter */ "./dist/modules/settings/local/CreateSettingParameter.js"), exports);
|
|
4273
|
+
__exportStar(__webpack_require__(/*! ./local/Setting */ "./dist/modules/settings/local/Setting.js"), exports);
|
|
4274
|
+
__exportStar(__webpack_require__(/*! ./SettingsController */ "./dist/modules/settings/SettingsController.js"), exports);
|
|
4275
|
+
//# sourceMappingURL=index.js.map
|
|
4276
|
+
|
|
4277
|
+
/***/ }),
|
|
4278
|
+
|
|
3707
4279
|
/***/ "./dist/modules/settings/local/CreateSettingParameter.js":
|
|
3708
4280
|
/*!***************************************************************!*\
|
|
3709
4281
|
!*** ./dist/modules/settings/local/CreateSettingParameter.js ***!
|
|
@@ -4373,29 +4945,50 @@ __exportStar(__webpack_require__(/*! ./sleep */ "./node_modules/@js-soft/ts-util
|
|
|
4373
4945
|
/*!*************************************************************!*\
|
|
4374
4946
|
!*** ./node_modules/@js-soft/ts-utils/dist/logDecorator.js ***!
|
|
4375
4947
|
\*************************************************************/
|
|
4376
|
-
/***/ ((__unused_webpack_module, exports)
|
|
4948
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4377
4949
|
|
|
4378
4950
|
"use strict";
|
|
4379
4951
|
|
|
4952
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4953
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4954
|
+
};
|
|
4380
4955
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4381
4956
|
exports.log = void 0;
|
|
4382
|
-
|
|
4383
|
-
function log(
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4957
|
+
const json_stringify_safe_1 = __importDefault(__webpack_require__(/*! json-stringify-safe */ "./node_modules/json-stringify-safe/stringify.js"));
|
|
4958
|
+
function log(params) {
|
|
4959
|
+
return function (_target, propertyName, propertyDescriptorDoNotChangeMyNamePlease) {
|
|
4960
|
+
const method = propertyDescriptorDoNotChangeMyNamePlease.value;
|
|
4961
|
+
propertyDescriptorDoNotChangeMyNamePlease.value = function (...args) {
|
|
4962
|
+
const thisT = this;
|
|
4963
|
+
try {
|
|
4964
|
+
if (params?.logParams) {
|
|
4965
|
+
thisT.log.trace(`Calling ${propertyName}(${args.map((a) => (0, json_stringify_safe_1.default)(a)).join(", ")})`);
|
|
4966
|
+
}
|
|
4967
|
+
else {
|
|
4968
|
+
thisT.log.trace(`Calling ${propertyName}`);
|
|
4969
|
+
}
|
|
4970
|
+
const returnValue = method.apply(this, args);
|
|
4971
|
+
if (params?.logReturnValue) {
|
|
4972
|
+
thisT.log.trace(`Returning from ${propertyName} with: ${(0, json_stringify_safe_1.default)(returnValue)}`);
|
|
4973
|
+
}
|
|
4974
|
+
else {
|
|
4975
|
+
thisT.log.trace(`Returning from ${propertyName}`);
|
|
4976
|
+
}
|
|
4977
|
+
return returnValue;
|
|
4978
|
+
}
|
|
4979
|
+
catch (error) {
|
|
4980
|
+
if (error instanceof Error && error.stack) {
|
|
4981
|
+
error.stack = error.stack
|
|
4982
|
+
.split("\n")
|
|
4983
|
+
.filter((s) => !s.includes(".propertyDescriptorDoNotChangeMyNamePlease.value"))
|
|
4984
|
+
.join("\n");
|
|
4985
|
+
}
|
|
4986
|
+
thisT.log.error(`Error in ${propertyName}:`, error);
|
|
4987
|
+
throw error;
|
|
4988
|
+
}
|
|
4989
|
+
};
|
|
4990
|
+
return propertyDescriptorDoNotChangeMyNamePlease;
|
|
4397
4991
|
};
|
|
4398
|
-
return propertyDesciptor;
|
|
4399
4992
|
}
|
|
4400
4993
|
exports.log = log;
|
|
4401
4994
|
//# sourceMappingURL=logDecorator.js.map
|
|
@@ -6216,6 +6809,43 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
6216
6809
|
}();
|
|
6217
6810
|
|
|
6218
6811
|
|
|
6812
|
+
/***/ }),
|
|
6813
|
+
|
|
6814
|
+
/***/ "./node_modules/json-stringify-safe/stringify.js":
|
|
6815
|
+
/*!*******************************************************!*\
|
|
6816
|
+
!*** ./node_modules/json-stringify-safe/stringify.js ***!
|
|
6817
|
+
\*******************************************************/
|
|
6818
|
+
/***/ ((module, exports) => {
|
|
6819
|
+
|
|
6820
|
+
exports = module.exports = stringify
|
|
6821
|
+
exports.getSerialize = serializer
|
|
6822
|
+
|
|
6823
|
+
function stringify(obj, replacer, spaces, cycleReplacer) {
|
|
6824
|
+
return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces)
|
|
6825
|
+
}
|
|
6826
|
+
|
|
6827
|
+
function serializer(replacer, cycleReplacer) {
|
|
6828
|
+
var stack = [], keys = []
|
|
6829
|
+
|
|
6830
|
+
if (cycleReplacer == null) cycleReplacer = function(key, value) {
|
|
6831
|
+
if (stack[0] === value) return "[Circular ~]"
|
|
6832
|
+
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]"
|
|
6833
|
+
}
|
|
6834
|
+
|
|
6835
|
+
return function(key, value) {
|
|
6836
|
+
if (stack.length > 0) {
|
|
6837
|
+
var thisPos = stack.indexOf(this)
|
|
6838
|
+
~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
|
|
6839
|
+
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
|
|
6840
|
+
if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value)
|
|
6841
|
+
}
|
|
6842
|
+
else stack.push(value)
|
|
6843
|
+
|
|
6844
|
+
return replacer == null ? value : replacer.call(this, key, value)
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6847
|
+
|
|
6848
|
+
|
|
6219
6849
|
/***/ }),
|
|
6220
6850
|
|
|
6221
6851
|
/***/ "./node_modules/luxon/build/node/luxon.js":
|
|
@@ -8870,7 +9500,8 @@ function clone$1(dur, alts, clear = false) {
|
|
|
8870
9500
|
...(alts.values || {})
|
|
8871
9501
|
},
|
|
8872
9502
|
loc: dur.loc.clone(alts.loc),
|
|
8873
|
-
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
|
|
9503
|
+
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
|
|
9504
|
+
matrix: alts.matrix || dur.matrix
|
|
8874
9505
|
};
|
|
8875
9506
|
return new Duration(conf);
|
|
8876
9507
|
}
|
|
@@ -8909,7 +9540,7 @@ function normalizeValues(matrix, vals) {
|
|
|
8909
9540
|
*
|
|
8910
9541
|
* Here is a brief overview of commonly used methods and getters in Duration:
|
|
8911
9542
|
*
|
|
8912
|
-
* * **Creation** To create a Duration, use {@link Duration
|
|
9543
|
+
* * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
|
|
8913
9544
|
* * **Unit values** See the {@link Duration#years}, {@link Duration#months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, {@link Duration#seconds}, {@link Duration#milliseconds} accessors.
|
|
8914
9545
|
* * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
|
|
8915
9546
|
* * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, {@link Duration#shiftTo}, and {@link Duration#negate}.
|
|
@@ -8925,10 +9556,16 @@ class Duration {
|
|
|
8925
9556
|
*/
|
|
8926
9557
|
constructor(config) {
|
|
8927
9558
|
const accurate = config.conversionAccuracy === "longterm" || false;
|
|
9559
|
+
let matrix = accurate ? accurateMatrix : casualMatrix;
|
|
9560
|
+
|
|
9561
|
+
if (config.matrix) {
|
|
9562
|
+
matrix = config.matrix;
|
|
9563
|
+
}
|
|
8928
9564
|
/**
|
|
8929
9565
|
* @access private
|
|
8930
9566
|
*/
|
|
8931
9567
|
|
|
9568
|
+
|
|
8932
9569
|
this.values = config.values;
|
|
8933
9570
|
/**
|
|
8934
9571
|
* @access private
|
|
@@ -8949,7 +9586,7 @@ class Duration {
|
|
|
8949
9586
|
* @access private
|
|
8950
9587
|
*/
|
|
8951
9588
|
|
|
8952
|
-
this.matrix =
|
|
9589
|
+
this.matrix = matrix;
|
|
8953
9590
|
/**
|
|
8954
9591
|
* @access private
|
|
8955
9592
|
*/
|
|
@@ -8988,7 +9625,8 @@ class Duration {
|
|
|
8988
9625
|
* @param {Object} [opts=[]] - options for creating this Duration
|
|
8989
9626
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
8990
9627
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
8991
|
-
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|
9628
|
+
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|
9629
|
+
* @param {string} [opts.matrix=Object] - the custom conversion system to use
|
|
8992
9630
|
* @return {Duration}
|
|
8993
9631
|
*/
|
|
8994
9632
|
|
|
@@ -9001,7 +9639,8 @@ class Duration {
|
|
|
9001
9639
|
return new Duration({
|
|
9002
9640
|
values: normalizeObject(obj, Duration.normalizeUnit),
|
|
9003
9641
|
loc: Locale.fromObject(opts),
|
|
9004
|
-
conversionAccuracy: opts.conversionAccuracy
|
|
9642
|
+
conversionAccuracy: opts.conversionAccuracy,
|
|
9643
|
+
matrix: opts.matrix
|
|
9005
9644
|
});
|
|
9006
9645
|
}
|
|
9007
9646
|
/**
|
|
@@ -9033,7 +9672,8 @@ class Duration {
|
|
|
9033
9672
|
* @param {Object} opts - options for parsing
|
|
9034
9673
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9035
9674
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9036
|
-
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|
9675
|
+
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|
9676
|
+
* @param {string} [opts.matrix=Object] - the preset conversion system to use
|
|
9037
9677
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
|
|
9038
9678
|
* @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
|
|
9039
9679
|
* @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
|
|
@@ -9057,7 +9697,8 @@ class Duration {
|
|
|
9057
9697
|
* @param {Object} opts - options for parsing
|
|
9058
9698
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9059
9699
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9060
|
-
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|
9700
|
+
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|
9701
|
+
* @param {string} [opts.matrix=Object] - the conversion system to use
|
|
9061
9702
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Times
|
|
9062
9703
|
* @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
|
|
9063
9704
|
* @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|
@@ -9388,7 +10029,7 @@ class Duration {
|
|
|
9388
10029
|
* Scale this Duration by the specified amount. Return a newly-constructed Duration.
|
|
9389
10030
|
* @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
|
|
9390
10031
|
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
|
|
9391
|
-
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "
|
|
10032
|
+
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
|
|
9392
10033
|
* @return {Duration}
|
|
9393
10034
|
*/
|
|
9394
10035
|
|
|
@@ -9446,20 +10087,18 @@ class Duration {
|
|
|
9446
10087
|
reconfigure({
|
|
9447
10088
|
locale,
|
|
9448
10089
|
numberingSystem,
|
|
9449
|
-
conversionAccuracy
|
|
10090
|
+
conversionAccuracy,
|
|
10091
|
+
matrix
|
|
9450
10092
|
} = {}) {
|
|
9451
10093
|
const loc = this.loc.clone({
|
|
9452
10094
|
locale,
|
|
9453
10095
|
numberingSystem
|
|
9454
|
-
})
|
|
9455
|
-
|
|
9456
|
-
loc
|
|
10096
|
+
});
|
|
10097
|
+
const opts = {
|
|
10098
|
+
loc,
|
|
10099
|
+
matrix,
|
|
10100
|
+
conversionAccuracy
|
|
9457
10101
|
};
|
|
9458
|
-
|
|
9459
|
-
if (conversionAccuracy) {
|
|
9460
|
-
opts.conversionAccuracy = conversionAccuracy;
|
|
9461
|
-
}
|
|
9462
|
-
|
|
9463
10102
|
return clone$1(this, opts);
|
|
9464
10103
|
}
|
|
9465
10104
|
/**
|
|
@@ -9733,10 +10372,10 @@ function validateStartEnd(start, end) {
|
|
|
9733
10372
|
*
|
|
9734
10373
|
* Here is a brief overview of the most commonly used methods and getters in Interval:
|
|
9735
10374
|
*
|
|
9736
|
-
* * **Creation** To create an Interval, use {@link Interval
|
|
10375
|
+
* * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}.
|
|
9737
10376
|
* * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
|
|
9738
10377
|
* * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}.
|
|
9739
|
-
* * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval
|
|
10378
|
+
* * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}.
|
|
9740
10379
|
* * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs}
|
|
9741
10380
|
* * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toISO}, {@link Interval#toISODate}, {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}.
|
|
9742
10381
|
*/
|
|
@@ -10570,7 +11209,7 @@ function dayDiff(earlier, later) {
|
|
|
10570
11209
|
}
|
|
10571
11210
|
|
|
10572
11211
|
function highOrderDiffs(cursor, later, units) {
|
|
10573
|
-
const differs = [["years", (a, b) => b.year - a.year], ["quarters", (a, b) => b.quarter - a.quarter], ["months", (a, b) => b.month - a.month + (b.year - a.year) * 12], ["weeks", (a, b) => {
|
|
11212
|
+
const differs = [["years", (a, b) => b.year - a.year], ["quarters", (a, b) => b.quarter - a.quarter + (b.year - a.year) * 4], ["months", (a, b) => b.month - a.month + (b.year - a.year) * 12], ["weeks", (a, b) => {
|
|
10574
11213
|
const days = dayDiff(a, b);
|
|
10575
11214
|
return (days - days % 7) / 7;
|
|
10576
11215
|
}], ["days", dayDiff]];
|
|
@@ -11177,7 +11816,6 @@ function expandMacroTokens(tokens, locale) {
|
|
|
11177
11816
|
* @private
|
|
11178
11817
|
*/
|
|
11179
11818
|
|
|
11180
|
-
|
|
11181
11819
|
function explainFromTokens(locale, input, format) {
|
|
11182
11820
|
const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
|
|
11183
11821
|
units = tokens.map(t => unitForToken(t, locale)),
|
|
@@ -11773,7 +12411,7 @@ function lastOpts(argList) {
|
|
|
11773
12411
|
*
|
|
11774
12412
|
* Here is a brief overview of the most commonly used functionality it provides:
|
|
11775
12413
|
*
|
|
11776
|
-
* * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime
|
|
12414
|
+
* * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}.
|
|
11777
12415
|
* * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, {@link DateTime#month},
|
|
11778
12416
|
* {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
|
|
11779
12417
|
* * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
|
|
@@ -12312,6 +12950,19 @@ class DateTime {
|
|
|
12312
12950
|
static parseFormatForOpts(formatOpts, localeOpts = {}) {
|
|
12313
12951
|
const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
|
|
12314
12952
|
return !tokenList ? null : tokenList.map(t => t ? t.val : null).join("");
|
|
12953
|
+
}
|
|
12954
|
+
/**
|
|
12955
|
+
* Produce the the fully expanded format token for the locale
|
|
12956
|
+
* Does NOT quote characters, so quoted tokens will not round trip correctly
|
|
12957
|
+
* @param fmt
|
|
12958
|
+
* @param localeOpts
|
|
12959
|
+
* @returns {string}
|
|
12960
|
+
*/
|
|
12961
|
+
|
|
12962
|
+
|
|
12963
|
+
static expandFormat(fmt, localeOpts = {}) {
|
|
12964
|
+
const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
|
|
12965
|
+
return expanded.map(t => t.val).join("");
|
|
12315
12966
|
} // INFO
|
|
12316
12967
|
|
|
12317
12968
|
/**
|
|
@@ -13004,8 +13655,8 @@ class DateTime {
|
|
|
13004
13655
|
* @param {Object} opts - opts to override the configuration options on this DateTime
|
|
13005
13656
|
* @example DateTime.now().toLocaleString(); //=> 4/20/2017
|
|
13006
13657
|
* @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
|
|
13007
|
-
* @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
|
|
13008
13658
|
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
|
|
13659
|
+
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
|
|
13009
13660
|
* @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
|
|
13010
13661
|
* @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
|
|
13011
13662
|
* @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
|
|
@@ -13042,7 +13693,7 @@ class DateTime {
|
|
|
13042
13693
|
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
|
|
13043
13694
|
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
|
|
13044
13695
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|
13045
|
-
* @param {boolean} [opts.extendedZone=
|
|
13696
|
+
* @param {boolean} [opts.extendedZone=false] - add the time zone format extension
|
|
13046
13697
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
13047
13698
|
* @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
|
|
13048
13699
|
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
|
@@ -13747,7 +14398,7 @@ function friendlyDateTime(dateTimeish) {
|
|
|
13747
14398
|
}
|
|
13748
14399
|
}
|
|
13749
14400
|
|
|
13750
|
-
const VERSION = "3.0.
|
|
14401
|
+
const VERSION = "3.0.4";
|
|
13751
14402
|
|
|
13752
14403
|
exports.DateTime = DateTime;
|
|
13753
14404
|
exports.Duration = Duration;
|