@nmshd/consumption 2.0.0-beta.3 → 2.0.0-beta.30
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 +14 -13
- 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/CoreErrors.d.ts +23 -0
- 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.d.ts +0 -1
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.js +10 -13
- 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 +41 -32
- 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.d.ts +2 -2
- package/dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js +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 +4 -5
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +43 -33
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -1
- 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 +4 -3
- 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 +8 -10
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js +36 -71
- 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 +1121 -471
- 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 +23 -23
- package/dist/consumption/ConsumptionErrors.d.ts +0 -24
- package/dist/consumption/ConsumptionErrors.js +0 -44
- 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/createAttribute/AcceptCreateAttributeRequestItemParameters.d.ts +0 -7
- package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js +0 -20
- package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.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-beta.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2022-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "2.0.0-beta.30",
|
|
21
|
+
build: "84",
|
|
22
|
+
date: "2022-10-20T11:54:08+00:00",
|
|
23
|
+
commit: "7ef6f5c38ee66eebc8e417df0ee86fd8983bd478",
|
|
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,24 +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([
|
|
120
|
+
[content_1.ShareAttributeRequestItem, modules_1.ShareAttributeRequestItemProcessor],
|
|
123
121
|
[content_1.CreateAttributeRequestItem, modules_1.CreateAttributeRequestItemProcessor],
|
|
124
122
|
[content_1.ReadAttributeRequestItem, modules_1.ReadAttributeRequestItemProcessor],
|
|
125
123
|
[content_1.ProposeAttributeRequestItem, modules_1.ProposeAttributeRequestItemProcessor],
|
|
126
|
-
[content_1.
|
|
124
|
+
[content_1.ConsentRequestItem, modules_1.GenericRequestItemProcessor],
|
|
125
|
+
[content_1.AuthenticationRequestItem, modules_1.GenericRequestItemProcessor],
|
|
126
|
+
[content_1.RegisterAttributeListenerRequestItem, modules_1.RegisterAttributeListenerRequestItemProcessor]
|
|
127
127
|
]);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -144,7 +144,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
144
144
|
exports.ConsumptionControllerName = void 0;
|
|
145
145
|
var ConsumptionControllerName;
|
|
146
146
|
(function (ConsumptionControllerName) {
|
|
147
|
-
ConsumptionControllerName["
|
|
147
|
+
ConsumptionControllerName["AttributesController"] = "AttributesController";
|
|
148
|
+
ConsumptionControllerName["AttributeListenersController"] = "AttributeListenersController";
|
|
148
149
|
ConsumptionControllerName["DraftsController"] = "DraftsController";
|
|
149
150
|
ConsumptionControllerName["RelationshipInfoController"] = "RelationshipInfoController";
|
|
150
151
|
ConsumptionControllerName["SingleRelationshipController"] = "SingleRelationshipController";
|
|
@@ -158,57 +159,20 @@ var ConsumptionControllerName;
|
|
|
158
159
|
|
|
159
160
|
/***/ }),
|
|
160
161
|
|
|
161
|
-
/***/ "./dist/consumption/
|
|
162
|
-
|
|
163
|
-
!*** ./dist/consumption/
|
|
164
|
-
|
|
165
|
-
/***/ ((__unused_webpack_module, exports
|
|
162
|
+
/***/ "./dist/consumption/ConsumptionError.js":
|
|
163
|
+
/*!**********************************************!*\
|
|
164
|
+
!*** ./dist/consumption/ConsumptionError.js ***!
|
|
165
|
+
\**********************************************/
|
|
166
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
166
167
|
|
|
167
168
|
"use strict";
|
|
168
169
|
|
|
169
170
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
170
|
-
exports.
|
|
171
|
-
|
|
172
|
-
class Attributes {
|
|
173
|
-
attributeExists(id) {
|
|
174
|
-
return new transport_1.CoreError("error.consumption.attributes.attributeExists", `Attribute with id '${id}' already exists. Please use succeed instead.`);
|
|
175
|
-
}
|
|
176
|
-
predecessorNotFound(id) {
|
|
177
|
-
return new transport_1.CoreError("error.consumption.attributes.predecessorNotFound", `Attribute with id '${id}' does not exist. Please use create instead.`);
|
|
178
|
-
}
|
|
171
|
+
exports.ConsumptionError = void 0;
|
|
172
|
+
class ConsumptionError extends Error {
|
|
179
173
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return new transport_1.CoreError("error.consumption.requests.requestExists", `Request with id ${id} already exists and can't be created.`);
|
|
183
|
-
}
|
|
184
|
-
unexpectedErrorDuringRequestItemProcessing(error) {
|
|
185
|
-
return new transport_1.CoreError("error.consumption.requests.unexpectedErrorDuringRequestItemProcessing", error instanceof Error ? error.message : "Unknown error: '${JSON.stringify(e)'");
|
|
186
|
-
}
|
|
187
|
-
invalidRequestItem(message) {
|
|
188
|
-
return new transport_1.CoreError("error.consumption.requests.invalidRequestItem", message);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
class RelationshipInfo {
|
|
192
|
-
relationshipInfoExists(relationshipId) {
|
|
193
|
-
return new transport_1.CoreError("error.consumption.relationshipInfos.relationshipInfoExists", `RelationshipInfo for Relationship ${relationshipId} already exists.`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
class Onboarding {
|
|
197
|
-
attributeNotSet(attributeName) {
|
|
198
|
-
return new transport_1.CoreError("error.consumption.onboarding.attributeNotSet", `No attribute with name ${attributeName} set but was required to be shared.`);
|
|
199
|
-
}
|
|
200
|
-
wrongTemplate() {
|
|
201
|
-
return new transport_1.CoreError("error.consumption.onboarding.wrongTemplate", "The given template is in the wrong format.");
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
class ConsumptionErrors {
|
|
205
|
-
}
|
|
206
|
-
exports.ConsumptionErrors = ConsumptionErrors;
|
|
207
|
-
ConsumptionErrors.attributes = new Attributes();
|
|
208
|
-
ConsumptionErrors.requests = new Requests();
|
|
209
|
-
ConsumptionErrors.relationshipInfo = new RelationshipInfo();
|
|
210
|
-
ConsumptionErrors.onboarding = new Onboarding();
|
|
211
|
-
//# sourceMappingURL=ConsumptionErrors.js.map
|
|
174
|
+
exports.ConsumptionError = ConsumptionError;
|
|
175
|
+
//# sourceMappingURL=ConsumptionError.js.map
|
|
212
176
|
|
|
213
177
|
/***/ }),
|
|
214
178
|
|
|
@@ -230,10 +194,68 @@ ConsumptionIds.draft = new transport_1.CoreIdHelper("LCLDRF");
|
|
|
230
194
|
ConsumptionIds.setting = new transport_1.CoreIdHelper("LCLSET");
|
|
231
195
|
ConsumptionIds.attribute = new transport_1.CoreIdHelper("ATT");
|
|
232
196
|
ConsumptionIds.request = new transport_1.CoreIdHelper("REQ");
|
|
197
|
+
ConsumptionIds.attributeListener = new transport_1.CoreIdHelper("ATL");
|
|
233
198
|
//# sourceMappingURL=ConsumptionIds.js.map
|
|
234
199
|
|
|
235
200
|
/***/ }),
|
|
236
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;
|
|
212
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
213
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
214
|
+
class Attributes {
|
|
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.`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
class Requests {
|
|
220
|
+
constructor() {
|
|
221
|
+
this.decideValidation = new Requests._decideValidation();
|
|
222
|
+
}
|
|
223
|
+
unexpectedErrorDuringRequestItemProcessing(error) {
|
|
224
|
+
return new transport_1.CoreError("error.consumption.requests.unexpectedErrorDuringRequestItemProcessing", error instanceof Error ? error.message : `Unknown error: '${JSON.stringify(error)}'`, undefined, undefined, error);
|
|
225
|
+
}
|
|
226
|
+
servalErrorDuringRequestItemProcessing(error) {
|
|
227
|
+
return new transport_1.CoreError("error.consumption.requests.servalErrorDuringRequestItemProcessing", error instanceof Error ? error.message : `Serval error: '${JSON.stringify(error)}'`, undefined, undefined, error);
|
|
228
|
+
}
|
|
229
|
+
invalidRequestItem(message) {
|
|
230
|
+
return new transport_1.CoreError("error.consumption.requests.invalidRequestItem", message);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
Requests._decideValidation = class {
|
|
234
|
+
invalidNumberOfItems(message) {
|
|
235
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.invalidNumberOfItems", message);
|
|
236
|
+
}
|
|
237
|
+
itemAcceptedButParentNotAccepted(message) {
|
|
238
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.itemAcceptedButParentNotAccepted", message);
|
|
239
|
+
}
|
|
240
|
+
mustBeAcceptedItemNotAccepted(message) {
|
|
241
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.mustBeAcceptedItemNotAccepted", message);
|
|
242
|
+
}
|
|
243
|
+
requestItemAnsweredAsRequestItemGroup() {
|
|
244
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.requestItemAnsweredAsRequestItemGroup", "The RequestItem was answered as a RequestItemGroup.");
|
|
245
|
+
}
|
|
246
|
+
requestItemGroupAnsweredAsRequestItem() {
|
|
247
|
+
return new ts_utils_1.ApplicationError("error.consumption.requests.decide.validation.requestItemGroupAnsweredAsRequestItem", "The RequestItemGroup was answered as a RequestItem.");
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
class CoreErrors {
|
|
251
|
+
}
|
|
252
|
+
exports.CoreErrors = CoreErrors;
|
|
253
|
+
CoreErrors.attributes = new Attributes();
|
|
254
|
+
CoreErrors.requests = new Requests();
|
|
255
|
+
//# sourceMappingURL=CoreErrors.js.map
|
|
256
|
+
|
|
257
|
+
/***/ }),
|
|
258
|
+
|
|
237
259
|
/***/ "./dist/consumption/index.js":
|
|
238
260
|
/*!***********************************!*\
|
|
239
261
|
!*** ./dist/consumption/index.js ***!
|
|
@@ -259,8 +281,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
259
281
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
260
282
|
__exportStar(__webpack_require__(/*! ./ConsumptionBaseController */ "./dist/consumption/ConsumptionBaseController.js"), exports);
|
|
261
283
|
__exportStar(__webpack_require__(/*! ./ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js"), exports);
|
|
262
|
-
__exportStar(__webpack_require__(/*! ./
|
|
284
|
+
__exportStar(__webpack_require__(/*! ./ConsumptionError */ "./dist/consumption/ConsumptionError.js"), exports);
|
|
263
285
|
__exportStar(__webpack_require__(/*! ./ConsumptionIds */ "./dist/consumption/ConsumptionIds.js"), exports);
|
|
286
|
+
__exportStar(__webpack_require__(/*! ./CoreErrors */ "./dist/consumption/CoreErrors.js"), exports);
|
|
264
287
|
//# sourceMappingURL=index.js.map
|
|
265
288
|
|
|
266
289
|
/***/ }),
|
|
@@ -296,16 +319,252 @@ __exportStar(__webpack_require__(/*! ./modules */ "./dist/modules/index.js"), ex
|
|
|
296
319
|
|
|
297
320
|
/***/ }),
|
|
298
321
|
|
|
299
|
-
/***/ "./dist/modules/
|
|
300
|
-
|
|
301
|
-
!*** ./dist/modules/
|
|
302
|
-
|
|
322
|
+
/***/ "./dist/modules/attributeListeners/AttributeListenersController.js":
|
|
323
|
+
/*!*************************************************************************!*\
|
|
324
|
+
!*** ./dist/modules/attributeListeners/AttributeListenersController.js ***!
|
|
325
|
+
\*************************************************************************/
|
|
303
326
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
304
327
|
|
|
305
328
|
"use strict";
|
|
306
329
|
|
|
307
330
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
308
|
-
exports.
|
|
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
|
+
\*********************************************************/
|
|
562
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
563
|
+
|
|
564
|
+
"use strict";
|
|
565
|
+
|
|
566
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
567
|
+
exports.AttributesController = void 0;
|
|
309
568
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
310
569
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
311
570
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
@@ -316,9 +575,9 @@ const LocalAttribute_1 = __webpack_require__(/*! ./local/LocalAttribute */ "./di
|
|
|
316
575
|
const LocalAttributeShareInfo_1 = __webpack_require__(/*! ./local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js");
|
|
317
576
|
const QueryTranslator_1 = __webpack_require__(/*! ./local/QueryTranslator */ "./dist/modules/attributes/local/QueryTranslator.js");
|
|
318
577
|
const SucceedLocalAttributeParams_1 = __webpack_require__(/*! ./local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js");
|
|
319
|
-
class
|
|
578
|
+
class AttributesController extends consumption_1.ConsumptionBaseController {
|
|
320
579
|
constructor(parent, eventBus, identity) {
|
|
321
|
-
super(consumption_1.ConsumptionControllerName.
|
|
580
|
+
super(consumption_1.ConsumptionControllerName.AttributesController, parent);
|
|
322
581
|
this.eventBus = eventBus;
|
|
323
582
|
this.identity = identity;
|
|
324
583
|
}
|
|
@@ -384,46 +643,83 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
384
643
|
}
|
|
385
644
|
async getLocalAttributes(query) {
|
|
386
645
|
const attributes = await this.attributes.find(query);
|
|
387
|
-
return
|
|
646
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
388
647
|
}
|
|
389
648
|
async getValidLocalAttributes(query) {
|
|
390
649
|
const attributes = await this.attributes.find(query);
|
|
391
|
-
const items =
|
|
650
|
+
const items = this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
392
651
|
return this.filterCurrent(items);
|
|
393
652
|
}
|
|
394
653
|
async executeRelationshipAttributeQuery(query) {
|
|
395
654
|
const parsedQuery = content_1.RelationshipAttributeQuery.from(query);
|
|
396
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" };
|
|
397
665
|
const attributes = await this.attributes.find(dbQuery);
|
|
398
|
-
|
|
666
|
+
const attribute = attributes.length > 0 ? LocalAttribute_1.LocalAttribute.from(attributes[0]) : undefined;
|
|
667
|
+
return attribute;
|
|
399
668
|
}
|
|
400
669
|
async executeIdentityAttributeQuery(query) {
|
|
401
670
|
const parsedQuery = content_1.IdentityAttributeQuery.from(query);
|
|
402
671
|
const dbQuery = QueryTranslator_1.IdentityAttributeQueryTranslator.translate(parsedQuery);
|
|
672
|
+
dbQuery["content.owner"] = this.identity.address.toString();
|
|
673
|
+
dbQuery["shareInfo"] = { $exists: false };
|
|
403
674
|
const attributes = await this.attributes.find(dbQuery);
|
|
404
|
-
return
|
|
675
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
405
676
|
}
|
|
406
677
|
async createLocalAttribute(params) {
|
|
407
|
-
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
|
+
});
|
|
408
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
|
+
}
|
|
409
689
|
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), localAttribute));
|
|
410
690
|
return localAttribute;
|
|
411
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
|
+
}
|
|
412
705
|
async succeedLocalAttribute(params) {
|
|
413
706
|
const parsedParams = SucceedLocalAttributeParams_1.SucceedLocalAttributeParams.from(params);
|
|
414
|
-
const
|
|
707
|
+
const currentAttributeDoc = await this.attributes.findOne({
|
|
415
708
|
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.succeeds.toString()
|
|
416
709
|
});
|
|
417
|
-
|
|
418
|
-
|
|
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());
|
|
419
716
|
}
|
|
420
717
|
if (!parsedParams.successorContent.validFrom) {
|
|
421
718
|
parsedParams.successorContent.validFrom = transport_1.CoreDate.utc();
|
|
422
719
|
}
|
|
423
720
|
const validFrom = parsedParams.successorContent.validFrom;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
await this.attributes.update(current, currentUpdated);
|
|
721
|
+
currentAttribute.content.validTo = validFrom.subtract(1);
|
|
722
|
+
await this.attributes.update(currentAttributeDoc, currentAttribute);
|
|
427
723
|
const successor = await LocalAttribute_1.LocalAttribute.fromAttribute(parsedParams.successorContent, parsedParams.succeeds);
|
|
428
724
|
await this.attributes.create(successor);
|
|
429
725
|
this.eventBus.publish(new events_1.AttributeSucceededEvent(this.identity.address.toString(), successor));
|
|
@@ -433,7 +729,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
433
729
|
const parsedParams = CreateSharedLocalAttributeCopyParams_1.CreateSharedLocalAttributeCopyParams.from(params);
|
|
434
730
|
const sourceAttribute = await this.getLocalAttribute(parsedParams.sourceAttributeId);
|
|
435
731
|
if (!sourceAttribute) {
|
|
436
|
-
throw
|
|
732
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, parsedParams.sourceAttributeId.toString());
|
|
437
733
|
}
|
|
438
734
|
const shareInfo = LocalAttributeShareInfo_1.LocalAttributeShareInfo.from({
|
|
439
735
|
peer: parsedParams.peer,
|
|
@@ -457,6 +753,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
457
753
|
createdAt: transport_1.CoreDate.utc()
|
|
458
754
|
});
|
|
459
755
|
await this.attributes.create(peerLocalAttribute);
|
|
756
|
+
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), peerLocalAttribute));
|
|
460
757
|
return peerLocalAttribute;
|
|
461
758
|
}
|
|
462
759
|
async updateLocalAttribute(params) {
|
|
@@ -464,7 +761,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
464
761
|
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.id.toString()
|
|
465
762
|
});
|
|
466
763
|
if (!current) {
|
|
467
|
-
throw transport_1.
|
|
764
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, params.id.toString());
|
|
468
765
|
}
|
|
469
766
|
const updatedLocalAttribute = LocalAttribute_1.LocalAttribute.from({
|
|
470
767
|
id: current.id,
|
|
@@ -483,8 +780,8 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
483
780
|
this.eventBus.publish(new events_1.AttributeDeletedEvent(this.identity.address.toString(), attribute));
|
|
484
781
|
}
|
|
485
782
|
}
|
|
486
|
-
exports.
|
|
487
|
-
//# sourceMappingURL=
|
|
783
|
+
exports.AttributesController = AttributesController;
|
|
784
|
+
//# sourceMappingURL=AttributesController.js.map
|
|
488
785
|
|
|
489
786
|
/***/ }),
|
|
490
787
|
|
|
@@ -630,6 +927,42 @@ __exportStar(__webpack_require__(/*! ./SharedAttributeCopyCreatedEvent */ "./dis
|
|
|
630
927
|
|
|
631
928
|
/***/ }),
|
|
632
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
|
+
|
|
633
966
|
/***/ "./dist/modules/attributes/local/CreateLocalAttributeParams.js":
|
|
634
967
|
/*!*********************************************************************!*\
|
|
635
968
|
!*** ./dist/modules/attributes/local/CreateLocalAttributeParams.js ***!
|
|
@@ -651,6 +984,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
651
984
|
exports.CreateLocalAttributeParams = void 0;
|
|
652
985
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
653
986
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
987
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
654
988
|
class CreateLocalAttributeParams extends ts_serval_1.Serializable {
|
|
655
989
|
static from(value) {
|
|
656
990
|
return this.fromAny(value);
|
|
@@ -661,6 +995,11 @@ __decorate([
|
|
|
661
995
|
(0, ts_serval_1.validate)(),
|
|
662
996
|
__metadata("design:type", Object)
|
|
663
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);
|
|
664
1003
|
exports.CreateLocalAttributeParams = CreateLocalAttributeParams;
|
|
665
1004
|
//# sourceMappingURL=CreateLocalAttributeParams.js.map
|
|
666
1005
|
|
|
@@ -809,19 +1148,35 @@ let LocalAttribute = class LocalAttribute extends transport_1.CoreSynchronizable
|
|
|
809
1148
|
isIdentityAttribute() {
|
|
810
1149
|
return this.content instanceof content_1.IdentityAttribute;
|
|
811
1150
|
}
|
|
1151
|
+
isRelationshipAttribute() {
|
|
1152
|
+
return this.content instanceof content_1.RelationshipAttribute;
|
|
1153
|
+
}
|
|
812
1154
|
isOwnedBy(identity) {
|
|
813
1155
|
return this.content.owner.equals(identity);
|
|
814
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
|
+
}
|
|
815
1169
|
static from(value) {
|
|
816
1170
|
return this.fromAny(value);
|
|
817
1171
|
}
|
|
818
|
-
static async fromAttribute(
|
|
1172
|
+
static async fromAttribute(content, succeeds, shareInfo, id, parentId) {
|
|
819
1173
|
return this.from({
|
|
820
1174
|
id: id ?? (await consumption_1.ConsumptionIds.attribute.generate()),
|
|
821
|
-
content: attribute,
|
|
822
1175
|
createdAt: transport_1.CoreDate.utc(),
|
|
823
|
-
|
|
824
|
-
|
|
1176
|
+
content,
|
|
1177
|
+
succeeds,
|
|
1178
|
+
shareInfo,
|
|
1179
|
+
parentId
|
|
825
1180
|
});
|
|
826
1181
|
}
|
|
827
1182
|
};
|
|
@@ -850,6 +1205,11 @@ __decorate([
|
|
|
850
1205
|
(0, ts_serval_1.serialize)(),
|
|
851
1206
|
__metadata("design:type", LocalAttributeShareInfo_1.LocalAttributeShareInfo)
|
|
852
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);
|
|
853
1213
|
LocalAttribute = __decorate([
|
|
854
1214
|
(0, ts_serval_1.type)("LocalAttribute")
|
|
855
1215
|
], LocalAttribute);
|
|
@@ -913,10 +1273,11 @@ exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
|
913
1273
|
"use strict";
|
|
914
1274
|
|
|
915
1275
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
916
|
-
exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
1276
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
917
1277
|
const docdb_querytranslator_1 = __webpack_require__(/*! @js-soft/docdb-querytranslator */ "./node_modules/@js-soft/docdb-querytranslator/dist/index.js");
|
|
918
1278
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
|
|
919
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");
|
|
920
1281
|
class IdentityAttributeQueryTranslator {
|
|
921
1282
|
static translate(query) {
|
|
922
1283
|
return this.translator.parse({ ...query.toJSON(), attributeType: "IdentityAttribute" });
|
|
@@ -945,7 +1306,7 @@ IdentityAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryT
|
|
|
945
1306
|
if (!input)
|
|
946
1307
|
return;
|
|
947
1308
|
if (!Array.isArray(input)) {
|
|
948
|
-
throw new
|
|
1309
|
+
throw new consumption_1.ConsumptionError("Invalid input: 'tags' must be an array");
|
|
949
1310
|
}
|
|
950
1311
|
const inputAsArray = input;
|
|
951
1312
|
query["$or"] = inputAsArray.map((t) => ({
|
|
@@ -985,11 +1346,9 @@ exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTransla
|
|
|
985
1346
|
RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
986
1347
|
whitelist: {
|
|
987
1348
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
988
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.valueType)]: true,
|
|
989
1349
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
990
1350
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
991
1351
|
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
992
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.thirdParty)]: true,
|
|
993
1352
|
attributeType: true
|
|
994
1353
|
},
|
|
995
1354
|
alias: {
|
|
@@ -997,9 +1356,55 @@ RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.Qu
|
|
|
997
1356
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
998
1357
|
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
999
1358
|
],
|
|
1000
|
-
// @type of
|
|
1001
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.
|
|
1002
|
-
|
|
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)}`
|
|
1003
1408
|
],
|
|
1004
1409
|
// @type of attribute
|
|
1005
1410
|
attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
|
|
@@ -1151,12 +1556,12 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1151
1556
|
}
|
|
1152
1557
|
async getDrafts(query) {
|
|
1153
1558
|
const items = await this.drafts.find(query);
|
|
1154
|
-
return
|
|
1559
|
+
return this.parseArray(items, Draft_1.Draft);
|
|
1155
1560
|
}
|
|
1156
1561
|
async createDraft(content, type = "") {
|
|
1157
1562
|
const draft = Draft_1.Draft.from({
|
|
1158
1563
|
id: await consumption_1.ConsumptionIds.draft.generate(),
|
|
1159
|
-
content
|
|
1564
|
+
content,
|
|
1160
1565
|
createdAt: new transport_1.CoreDate(),
|
|
1161
1566
|
lastModifiedAt: new transport_1.CoreDate(),
|
|
1162
1567
|
type: type
|
|
@@ -1167,7 +1572,7 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1167
1572
|
async updateDraft(draft) {
|
|
1168
1573
|
const oldDraft = await this.drafts.read(draft.id.toString());
|
|
1169
1574
|
if (!oldDraft) {
|
|
1170
|
-
throw new
|
|
1575
|
+
throw new consumption_1.ConsumptionError("Draft Not Found");
|
|
1171
1576
|
}
|
|
1172
1577
|
await this.drafts.update(oldDraft, draft);
|
|
1173
1578
|
}
|
|
@@ -1180,6 +1585,35 @@ exports.DraftsController = DraftsController;
|
|
|
1180
1585
|
|
|
1181
1586
|
/***/ }),
|
|
1182
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
|
+
|
|
1183
1617
|
/***/ "./dist/modules/drafts/local/Draft.js":
|
|
1184
1618
|
/*!********************************************!*\
|
|
1185
1619
|
!*** ./dist/modules/drafts/local/Draft.js ***!
|
|
@@ -1283,55 +1717,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1283
1717
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1284
1718
|
};
|
|
1285
1719
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1286
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1287
|
-
__exportStar(__webpack_require__(/*! ./attributes
|
|
1288
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1289
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1290
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1291
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js"), exports);
|
|
1292
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js"), exports);
|
|
1293
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/UpdateLocalAttributeParams */ "./dist/modules/attributes/local/UpdateLocalAttributeParams.js"), exports);
|
|
1294
|
-
__exportStar(__webpack_require__(/*! ./attributes/LocalAttributesController */ "./dist/modules/attributes/LocalAttributesController.js"), exports);
|
|
1295
|
-
__exportStar(__webpack_require__(/*! ./drafts/DraftsController */ "./dist/modules/drafts/DraftsController.js"), exports);
|
|
1296
|
-
__exportStar(__webpack_require__(/*! ./drafts/local/Draft */ "./dist/modules/drafts/local/Draft.js"), exports);
|
|
1297
|
-
__exportStar(__webpack_require__(/*! ./requests/events */ "./dist/modules/requests/events/index.js"), exports);
|
|
1298
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters */ "./dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js"), exports);
|
|
1299
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/complete/CompleteIncomingRequestParameters */ "./dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js"), exports);
|
|
1300
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/AcceptRequestItemParameters */ "./dist/modules/requests/incoming/decide/AcceptRequestItemParameters.js"), exports);
|
|
1301
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/DecideRequestItemGroupParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js"), exports);
|
|
1302
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/DecideRequestItemParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemParameters.js"), exports);
|
|
1303
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/DecideRequestParameters */ "./dist/modules/requests/incoming/decide/DecideRequestParameters.js"), exports);
|
|
1304
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/RejectRequestItemParameters */ "./dist/modules/requests/incoming/decide/RejectRequestItemParameters.js"), exports);
|
|
1305
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/DecideRequestParametersValidator */ "./dist/modules/requests/incoming/DecideRequestParametersValidator.js"), exports);
|
|
1306
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/IncomingRequestsController */ "./dist/modules/requests/incoming/IncomingRequestsController.js"), exports);
|
|
1307
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
|
|
1308
|
-
__exportStar(__webpack_require__(/*! ./requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
|
|
1309
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
|
|
1310
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js"), exports);
|
|
1311
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
|
|
1312
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
|
|
1313
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
|
|
1314
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
|
|
1315
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js"), exports);
|
|
1316
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js"), exports);
|
|
1317
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js"), exports);
|
|
1318
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/RequestItemConstructor */ "./dist/modules/requests/itemProcessors/RequestItemConstructor.js"), exports);
|
|
1319
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js"), exports);
|
|
1320
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters.js"), exports);
|
|
1321
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js"), exports);
|
|
1322
|
-
__exportStar(__webpack_require__(/*! ./requests/itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js"), exports);
|
|
1323
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js"), exports);
|
|
1324
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js"), exports);
|
|
1325
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalRequestStatusLogEntry */ "./dist/modules/requests/local/LocalRequestStatusLogEntry.js"), exports);
|
|
1326
|
-
__exportStar(__webpack_require__(/*! ./requests/local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js"), exports);
|
|
1327
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters */ "./dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js"), exports);
|
|
1328
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters */ "./dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js"), exports);
|
|
1329
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js"), exports);
|
|
1330
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/OutgoingRequestsController */ "./dist/modules/requests/outgoing/OutgoingRequestsController.js"), exports);
|
|
1331
|
-
__exportStar(__webpack_require__(/*! ./requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js"), exports);
|
|
1332
|
-
__exportStar(__webpack_require__(/*! ./settings/local/CreateSettingParameter */ "./dist/modules/settings/local/CreateSettingParameter.js"), exports);
|
|
1333
|
-
__exportStar(__webpack_require__(/*! ./settings/local/Setting */ "./dist/modules/settings/local/Setting.js"), exports);
|
|
1334
|
-
__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);
|
|
1335
1725
|
//# sourceMappingURL=index.js.map
|
|
1336
1726
|
|
|
1337
1727
|
/***/ }),
|
|
@@ -1347,11 +1737,12 @@ __exportStar(__webpack_require__(/*! ./settings/SettingsController */ "./dist/mo
|
|
|
1347
1737
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1348
1738
|
exports.IncomingRequestReceivedEvent = void 0;
|
|
1349
1739
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1740
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1350
1741
|
class IncomingRequestReceivedEvent extends transport_1.TransportDataEvent {
|
|
1351
1742
|
constructor(eventTargetAddress, data) {
|
|
1352
1743
|
super(IncomingRequestReceivedEvent.namespace, eventTargetAddress, data);
|
|
1353
1744
|
if (data.isOwn)
|
|
1354
|
-
throw new
|
|
1745
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an outgoing Request");
|
|
1355
1746
|
}
|
|
1356
1747
|
}
|
|
1357
1748
|
exports.IncomingRequestReceivedEvent = IncomingRequestReceivedEvent;
|
|
@@ -1371,11 +1762,12 @@ IncomingRequestReceivedEvent.namespace = "consumption.incomingRequestReceived";
|
|
|
1371
1762
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1372
1763
|
exports.IncomingRequestStatusChangedEvent = void 0;
|
|
1373
1764
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1765
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1374
1766
|
class IncomingRequestStatusChangedEvent extends transport_1.TransportDataEvent {
|
|
1375
1767
|
constructor(eventTargetAddress, data) {
|
|
1376
1768
|
super(IncomingRequestStatusChangedEvent.namespace, eventTargetAddress, data);
|
|
1377
1769
|
if (data.request.isOwn)
|
|
1378
|
-
throw new
|
|
1770
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an outgoing Request");
|
|
1379
1771
|
}
|
|
1380
1772
|
}
|
|
1381
1773
|
exports.IncomingRequestStatusChangedEvent = IncomingRequestStatusChangedEvent;
|
|
@@ -1395,11 +1787,12 @@ IncomingRequestStatusChangedEvent.namespace = "consumption.incomingRequestStatus
|
|
|
1395
1787
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1396
1788
|
exports.OutgoingRequestCreatedEvent = void 0;
|
|
1397
1789
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1790
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1398
1791
|
class OutgoingRequestCreatedEvent extends transport_1.TransportDataEvent {
|
|
1399
1792
|
constructor(eventTargetAddress, data) {
|
|
1400
1793
|
super(OutgoingRequestCreatedEvent.namespace, eventTargetAddress, data);
|
|
1401
1794
|
if (!data.isOwn)
|
|
1402
|
-
throw new
|
|
1795
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an incoming Request");
|
|
1403
1796
|
}
|
|
1404
1797
|
}
|
|
1405
1798
|
exports.OutgoingRequestCreatedEvent = OutgoingRequestCreatedEvent;
|
|
@@ -1419,11 +1812,12 @@ OutgoingRequestCreatedEvent.namespace = "consumption.outgoingRequestCreated";
|
|
|
1419
1812
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1420
1813
|
exports.OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent = void 0;
|
|
1421
1814
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1815
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1422
1816
|
class OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent extends transport_1.TransportDataEvent {
|
|
1423
1817
|
constructor(eventTargetAddress, data) {
|
|
1424
1818
|
super(OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.namespace, eventTargetAddress, data);
|
|
1425
1819
|
if (!data.isOwn)
|
|
1426
|
-
throw new
|
|
1820
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an incoming Request");
|
|
1427
1821
|
}
|
|
1428
1822
|
}
|
|
1429
1823
|
exports.OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent = OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent;
|
|
@@ -1443,11 +1837,12 @@ OutgoingRequestFromRelationshipCreationChangeCreatedAndCompletedEvent.namespace
|
|
|
1443
1837
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1444
1838
|
exports.OutgoingRequestStatusChangedEvent = void 0;
|
|
1445
1839
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1840
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1446
1841
|
class OutgoingRequestStatusChangedEvent extends transport_1.TransportDataEvent {
|
|
1447
1842
|
constructor(eventTargetAddress, data) {
|
|
1448
1843
|
super(OutgoingRequestStatusChangedEvent.namespace, eventTargetAddress, data);
|
|
1449
1844
|
if (!data.request.isOwn)
|
|
1450
|
-
throw new
|
|
1845
|
+
throw new consumption_1.ConsumptionError("Cannot create this event for an incoming Request");
|
|
1451
1846
|
}
|
|
1452
1847
|
}
|
|
1453
1848
|
exports.OutgoingRequestStatusChangedEvent = OutgoingRequestStatusChangedEvent;
|
|
@@ -1498,19 +1893,19 @@ __exportStar(__webpack_require__(/*! ./OutgoingRequestStatusChangedEvent */ "./d
|
|
|
1498
1893
|
|
|
1499
1894
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1500
1895
|
exports.DecideRequestParametersValidator = void 0;
|
|
1501
|
-
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
1502
1896
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1503
1897
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1898
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1504
1899
|
const ValidationResult_1 = __webpack_require__(/*! ../itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
1505
1900
|
const DecideRequestItemGroupParameters_1 = __webpack_require__(/*! ./decide/DecideRequestItemGroupParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js");
|
|
1506
1901
|
const DecideRequestItemParameters_1 = __webpack_require__(/*! ./decide/DecideRequestItemParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemParameters.js");
|
|
1507
1902
|
class DecideRequestParametersValidator {
|
|
1508
1903
|
validate(params, request) {
|
|
1509
1904
|
if (!request.id.equals(transport_1.CoreId.from(params.requestId))) {
|
|
1510
|
-
|
|
1905
|
+
throw new Error("The response is invalid because the id of the Request does not match the id of the Response.");
|
|
1511
1906
|
}
|
|
1512
1907
|
if (params.items.length !== request.content.items.length) {
|
|
1513
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1908
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.invalidNumberOfItems("Number of items in Request and Response do not match"));
|
|
1514
1909
|
}
|
|
1515
1910
|
const validationResults = request.content.items.map((requestItem, index) => this.checkItemOrGroup(requestItem, params.items[index], params.accept));
|
|
1516
1911
|
return ValidationResult_1.ValidationResult.fromItems(validationResults);
|
|
@@ -1523,36 +1918,33 @@ class DecideRequestParametersValidator {
|
|
|
1523
1918
|
}
|
|
1524
1919
|
checkItem(requestItem, response, isParentAccepted) {
|
|
1525
1920
|
if ((0, DecideRequestItemGroupParameters_1.isDecideRequestItemGroupParametersJSON)(response)) {
|
|
1526
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1921
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.requestItemAnsweredAsRequestItemGroup());
|
|
1527
1922
|
}
|
|
1528
1923
|
if (!isParentAccepted && response.accept) {
|
|
1529
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1924
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.itemAcceptedButParentNotAccepted("The RequestItem was accepted, but the parent was not accepted."));
|
|
1530
1925
|
}
|
|
1531
1926
|
if (isParentAccepted && requestItem.mustBeAccepted && !response.accept) {
|
|
1532
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1927
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.mustBeAcceptedItemNotAccepted("The RequestItem is flagged as 'mustBeAccepted', but it was not accepted."));
|
|
1533
1928
|
}
|
|
1534
1929
|
return ValidationResult_1.ValidationResult.success();
|
|
1535
1930
|
}
|
|
1536
1931
|
checkItemGroup(requestItemGroup, responseItemGroup, isParentAccepted) {
|
|
1537
1932
|
if ((0, DecideRequestItemParameters_1.isDecideRequestItemParametersJSON)(responseItemGroup)) {
|
|
1538
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1933
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.requestItemGroupAnsweredAsRequestItem());
|
|
1539
1934
|
}
|
|
1540
1935
|
if (responseItemGroup.items.length !== requestItemGroup.items.length) {
|
|
1541
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1936
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.invalidNumberOfItems("Number of items in RequestItemGroup and ResponseItemGroup do not match"));
|
|
1542
1937
|
}
|
|
1543
1938
|
const isGroupAccepted = responseItemGroup.items.some((value) => value.accept);
|
|
1544
1939
|
if (!isParentAccepted && isGroupAccepted) {
|
|
1545
|
-
return ValidationResult_1.ValidationResult.error(
|
|
1940
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.decideValidation.itemAcceptedButParentNotAccepted("The RequestItemGroup was accepted, but the parent was not accepted."));
|
|
1546
1941
|
}
|
|
1547
1942
|
if (isParentAccepted && requestItemGroup.mustBeAccepted && !isGroupAccepted) {
|
|
1548
|
-
return ValidationResult_1.ValidationResult.error(
|
|
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."));
|
|
1549
1944
|
}
|
|
1550
1945
|
const validationResults = requestItemGroup.items.map((requestItem, index) => this.checkItem(requestItem, responseItemGroup.items[index], isGroupAccepted));
|
|
1551
1946
|
return ValidationResult_1.ValidationResult.fromItems(validationResults);
|
|
1552
1947
|
}
|
|
1553
|
-
invalidNumberOfItemsError(message) {
|
|
1554
|
-
return new ts_utils_1.ApplicationError("error.requests.decide.validation.invalidNumberOfItems", message);
|
|
1555
|
-
}
|
|
1556
1948
|
}
|
|
1557
1949
|
exports.DecideRequestParametersValidator = DecideRequestParametersValidator;
|
|
1558
1950
|
//# sourceMappingURL=DecideRequestParametersValidator.js.map
|
|
@@ -1569,6 +1961,7 @@ exports.DecideRequestParametersValidator = DecideRequestParametersValidator;
|
|
|
1569
1961
|
|
|
1570
1962
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1571
1963
|
exports.IncomingRequestsController = void 0;
|
|
1964
|
+
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1572
1965
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1573
1966
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1574
1967
|
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
@@ -1617,7 +2010,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1617
2010
|
}
|
|
1618
2011
|
extractInfoFromMessage(message) {
|
|
1619
2012
|
if (message.isOwn)
|
|
1620
|
-
throw new
|
|
2013
|
+
throw new consumption_1.ConsumptionError("Cannot create incoming Request from own Message");
|
|
1621
2014
|
return {
|
|
1622
2015
|
peer: message.cache.createdBy,
|
|
1623
2016
|
source: {
|
|
@@ -1628,7 +2021,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1628
2021
|
}
|
|
1629
2022
|
extractInfoFromRelationshipTemplate(template) {
|
|
1630
2023
|
if (template.isOwn)
|
|
1631
|
-
throw new
|
|
2024
|
+
throw new consumption_1.ConsumptionError("Cannot create incoming Request from own Relationship Template");
|
|
1632
2025
|
return {
|
|
1633
2026
|
peer: template.cache.createdBy,
|
|
1634
2027
|
source: {
|
|
@@ -1721,26 +2114,28 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1721
2114
|
async canDecideItem(params, requestItem, request) {
|
|
1722
2115
|
const processor = this.processorRegistry.getProcessorForItem(requestItem);
|
|
1723
2116
|
try {
|
|
1724
|
-
if (params.accept)
|
|
2117
|
+
if (params.accept)
|
|
1725
2118
|
return await processor.canAccept(requestItem, params, request);
|
|
1726
|
-
}
|
|
1727
2119
|
return await processor.canReject(requestItem, params, request);
|
|
1728
2120
|
}
|
|
1729
2121
|
catch (e) {
|
|
1730
|
-
|
|
2122
|
+
if (e instanceof ts_serval_1.ServalError) {
|
|
2123
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.servalErrorDuringRequestItemProcessing(e));
|
|
2124
|
+
}
|
|
2125
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.unexpectedErrorDuringRequestItemProcessing(e));
|
|
1731
2126
|
}
|
|
1732
2127
|
}
|
|
1733
2128
|
async accept(params) {
|
|
1734
2129
|
const canAccept = await this.canAccept(params);
|
|
1735
2130
|
if (!canAccept.isSuccess()) {
|
|
1736
|
-
throw new
|
|
2131
|
+
throw new consumption_1.ConsumptionError("Cannot accept the Request with the given parameters. Call 'canAccept' to get more information.");
|
|
1737
2132
|
}
|
|
1738
2133
|
return await this.decide({ ...params, accept: true });
|
|
1739
2134
|
}
|
|
1740
2135
|
async reject(params) {
|
|
1741
2136
|
const canReject = await this.canReject(params);
|
|
1742
2137
|
if (!canReject.isSuccess()) {
|
|
1743
|
-
throw new
|
|
2138
|
+
throw new consumption_1.ConsumptionError("Cannot reject the Request with the given parameters. Call 'canReject' to get more information.");
|
|
1744
2139
|
}
|
|
1745
2140
|
return await this.decide({ ...params, accept: false });
|
|
1746
2141
|
}
|
|
@@ -1775,7 +2170,7 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1775
2170
|
}
|
|
1776
2171
|
async decideGroup(groupItemParam, requestItemGroup, request) {
|
|
1777
2172
|
const items = (await this.decideItems(groupItemParam.items, requestItemGroup.items, request));
|
|
1778
|
-
const group = content_1.ResponseItemGroup.from({ items
|
|
2173
|
+
const group = content_1.ResponseItemGroup.from({ items });
|
|
1779
2174
|
return group;
|
|
1780
2175
|
}
|
|
1781
2176
|
async decideItems(params, requestItems, request) {
|
|
@@ -1805,30 +2200,27 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1805
2200
|
if (e instanceof Error) {
|
|
1806
2201
|
details = ` Details: ${e.message}`;
|
|
1807
2202
|
}
|
|
1808
|
-
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}}`);
|
|
1809
2204
|
}
|
|
1810
2205
|
}
|
|
1811
2206
|
async complete(params) {
|
|
1812
2207
|
const parsedParams = CompleteIncomingRequestParameters_1.CompleteIncomingRequestParameters.from(params);
|
|
1813
2208
|
const request = await this.getOrThrow(parsedParams.requestId);
|
|
1814
2209
|
if (request.isOwn) {
|
|
1815
|
-
throw new
|
|
2210
|
+
throw new consumption_1.ConsumptionError("Cannot decide own Request");
|
|
1816
2211
|
}
|
|
1817
2212
|
this.assertRequestStatus(request, LocalRequestStatus_1.LocalRequestStatus.Decided);
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
2213
|
+
const requestIsRejected = request.response.content.result === content_1.ResponseResult.Rejected;
|
|
2214
|
+
const requestIsFromTemplate = request.source.type === "RelationshipTemplate";
|
|
2215
|
+
if (parsedParams.responseSourceObject) {
|
|
2216
|
+
request.response.source = LocalResponse_1.LocalResponseSource.from({
|
|
2217
|
+
type: parsedParams.responseSourceObject instanceof transport_1.Message ? "Message" : "RelationshipChange",
|
|
2218
|
+
reference: parsedParams.responseSourceObject.id
|
|
2219
|
+
});
|
|
1824
2220
|
}
|
|
1825
|
-
else {
|
|
1826
|
-
throw new
|
|
2221
|
+
else if (!requestIsRejected || !requestIsFromTemplate) {
|
|
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");
|
|
1827
2223
|
}
|
|
1828
|
-
request.response.source = LocalResponse_1.LocalResponseSource.from({
|
|
1829
|
-
type: responseSource,
|
|
1830
|
-
reference: parsedParams.responseSourceObject.id
|
|
1831
|
-
});
|
|
1832
2224
|
request.changeStatus(LocalRequestStatus_1.LocalRequestStatus.Completed);
|
|
1833
2225
|
await this.update(request);
|
|
1834
2226
|
this.eventBus.publish(new events_1.IncomingRequestStatusChangedEvent(this.identity.address.toString(), {
|
|
@@ -1839,36 +2231,45 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1839
2231
|
return request;
|
|
1840
2232
|
}
|
|
1841
2233
|
async getIncomingRequests(query) {
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
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);
|
|
1847
2240
|
}
|
|
1848
2241
|
async getIncomingRequest(idIncomingRequest) {
|
|
1849
2242
|
const requestDoc = await this.localRequests.findOne({ id: idIncomingRequest.toString(), isOwn: false });
|
|
1850
|
-
|
|
1851
|
-
|
|
2243
|
+
if (!requestDoc)
|
|
2244
|
+
return;
|
|
2245
|
+
const localRequest = LocalRequest_1.LocalRequest.from(requestDoc);
|
|
2246
|
+
return await this.updateRequestExpiry(localRequest);
|
|
1852
2247
|
}
|
|
1853
2248
|
async getOrThrow(id) {
|
|
1854
2249
|
const request = await this.getIncomingRequest(transport_1.CoreId.from(id));
|
|
1855
2250
|
if (!request) {
|
|
1856
|
-
throw transport_1.
|
|
2251
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, id.toString());
|
|
1857
2252
|
}
|
|
1858
2253
|
return request;
|
|
1859
2254
|
}
|
|
1860
2255
|
async update(request) {
|
|
1861
2256
|
const requestDoc = await this.localRequests.findOne({ id: request.id.toString(), isOwn: false });
|
|
1862
2257
|
if (!requestDoc) {
|
|
1863
|
-
throw transport_1.
|
|
2258
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, request.id.toString());
|
|
1864
2259
|
}
|
|
1865
2260
|
await this.localRequests.update(requestDoc, request);
|
|
1866
2261
|
}
|
|
1867
2262
|
assertRequestStatus(request, ...status) {
|
|
1868
2263
|
if (!status.includes(request.status)) {
|
|
1869
|
-
throw new
|
|
2264
|
+
throw new consumption_1.ConsumptionError(`Local Request has to be in status '${status.join("/")}'.`);
|
|
1870
2265
|
}
|
|
1871
2266
|
}
|
|
2267
|
+
async updateRequestExpiry(request) {
|
|
2268
|
+
const statusUpdated = request.updateStatusBasedOnExpiration();
|
|
2269
|
+
if (statusUpdated)
|
|
2270
|
+
await this.update(request);
|
|
2271
|
+
return request;
|
|
2272
|
+
}
|
|
1872
2273
|
}
|
|
1873
2274
|
exports.IncomingRequestsController = IncomingRequestsController;
|
|
1874
2275
|
//# sourceMappingURL=IncomingRequestsController.js.map
|
|
@@ -1947,7 +2348,7 @@ __decorate([
|
|
|
1947
2348
|
], CompleteIncomingRequestParameters.prototype, "requestId", void 0);
|
|
1948
2349
|
__decorate([
|
|
1949
2350
|
(0, ts_serval_1.serialize)({ unionTypes: [transport_1.Message, transport_1.RelationshipChange] }),
|
|
1950
|
-
(0, ts_serval_1.validate)(),
|
|
2351
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1951
2352
|
__metadata("design:type", Object)
|
|
1952
2353
|
], CompleteIncomingRequestParameters.prototype, "responseSourceObject", void 0);
|
|
1953
2354
|
exports.CompleteIncomingRequestParameters = CompleteIncomingRequestParameters;
|
|
@@ -2160,6 +2561,68 @@ exports.RequireManualDecisionOfIncomingRequestParameters = RequireManualDecision
|
|
|
2160
2561
|
|
|
2161
2562
|
/***/ }),
|
|
2162
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
|
+
|
|
2163
2626
|
/***/ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js":
|
|
2164
2627
|
/*!******************************************************************************!*\
|
|
2165
2628
|
!*** ./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js ***!
|
|
@@ -2270,12 +2733,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
2270
2733
|
/*!******************************************************************************!*\
|
|
2271
2734
|
!*** ./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js ***!
|
|
2272
2735
|
\******************************************************************************/
|
|
2273
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
2736
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2274
2737
|
|
|
2275
2738
|
"use strict";
|
|
2276
2739
|
|
|
2277
2740
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2278
2741
|
exports.RequestItemProcessorRegistry = void 0;
|
|
2742
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
2279
2743
|
class RequestItemProcessorRegistry {
|
|
2280
2744
|
constructor(consumptionController, processors = new Map()) {
|
|
2281
2745
|
this.consumptionController = consumptionController;
|
|
@@ -2283,7 +2747,7 @@ class RequestItemProcessorRegistry {
|
|
|
2283
2747
|
}
|
|
2284
2748
|
registerProcessor(itemConstructor, processorConstructor) {
|
|
2285
2749
|
if (this.processors.has(itemConstructor)) {
|
|
2286
|
-
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.`);
|
|
2287
2751
|
}
|
|
2288
2752
|
this.processors.set(itemConstructor, processorConstructor);
|
|
2289
2753
|
}
|
|
@@ -2293,7 +2757,7 @@ class RequestItemProcessorRegistry {
|
|
|
2293
2757
|
getProcessorForItem(item) {
|
|
2294
2758
|
const constructor = this.processors.get(item.constructor);
|
|
2295
2759
|
if (!constructor) {
|
|
2296
|
-
throw new
|
|
2760
|
+
throw new consumption_1.ConsumptionError(`There was no processor registered for '${item.constructor.name}'.`);
|
|
2297
2761
|
}
|
|
2298
2762
|
return new constructor(this.consumptionController);
|
|
2299
2763
|
}
|
|
@@ -2354,36 +2818,6 @@ exports.ErrorValidationResult = ErrorValidationResult;
|
|
|
2354
2818
|
|
|
2355
2819
|
/***/ }),
|
|
2356
2820
|
|
|
2357
|
-
/***/ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js":
|
|
2358
|
-
/*!************************************************************************************************************!*\
|
|
2359
|
-
!*** ./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js ***!
|
|
2360
|
-
\************************************************************************************************************/
|
|
2361
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2362
|
-
|
|
2363
|
-
"use strict";
|
|
2364
|
-
|
|
2365
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2366
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2367
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2368
|
-
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;
|
|
2369
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2370
|
-
};
|
|
2371
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2372
|
-
exports.AcceptCreateAttributeRequestItemParameters = void 0;
|
|
2373
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2374
|
-
let AcceptCreateAttributeRequestItemParameters = class AcceptCreateAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2375
|
-
static from(value) {
|
|
2376
|
-
return this.fromAny(value);
|
|
2377
|
-
}
|
|
2378
|
-
};
|
|
2379
|
-
AcceptCreateAttributeRequestItemParameters = __decorate([
|
|
2380
|
-
(0, ts_serval_1.type)("AcceptCreateAttributeRequestItemParameters")
|
|
2381
|
-
], AcceptCreateAttributeRequestItemParameters);
|
|
2382
|
-
exports.AcceptCreateAttributeRequestItemParameters = AcceptCreateAttributeRequestItemParameters;
|
|
2383
|
-
//# sourceMappingURL=AcceptCreateAttributeRequestItemParameters.js.map
|
|
2384
|
-
|
|
2385
|
-
/***/ }),
|
|
2386
|
-
|
|
2387
2821
|
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
2388
2822
|
/*!*****************************************************************************************************!*\
|
|
2389
2823
|
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
@@ -2399,54 +2833,64 @@ const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist
|
|
|
2399
2833
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2400
2834
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2401
2835
|
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2402
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
}
|
|
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() === "";
|
|
2407
2840
|
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
content: requestItem.attribute,
|
|
2421
|
-
peer: requestInfo.peer,
|
|
2422
|
-
requestReference: requestInfo.id
|
|
2423
|
-
});
|
|
2424
|
-
return content_1.CreateAttributeAcceptResponseItem.from({
|
|
2425
|
-
attributeId: peerLocalAttribute.id,
|
|
2426
|
-
result: content_1.ResponseItemResult.Accepted
|
|
2427
|
-
});
|
|
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."));
|
|
2848
|
+
}
|
|
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."));
|
|
2428
2853
|
}
|
|
2429
|
-
async
|
|
2430
|
-
if (
|
|
2431
|
-
|
|
2854
|
+
async accept(requestItem, _params, requestInfo) {
|
|
2855
|
+
if (requestItem.attribute.owner.toString() === "") {
|
|
2856
|
+
requestItem.attribute.owner = this.currentIdentityAddress;
|
|
2432
2857
|
}
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
await this.consumptionController.attributes.
|
|
2436
|
-
|
|
2437
|
-
|
|
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({
|
|
2438
2864
|
peer: requestInfo.peer,
|
|
2439
|
-
requestReference: requestInfo.id
|
|
2865
|
+
requestReference: requestInfo.id,
|
|
2866
|
+
sourceAttributeId: repositoryAttribute.id
|
|
2440
2867
|
});
|
|
2441
2868
|
}
|
|
2442
2869
|
else {
|
|
2443
|
-
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2444
|
-
id: responseItem.attributeId,
|
|
2870
|
+
sharedAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2445
2871
|
content: requestItem.attribute,
|
|
2446
2872
|
peer: requestInfo.peer,
|
|
2447
2873
|
requestReference: requestInfo.id
|
|
2448
2874
|
});
|
|
2449
2875
|
}
|
|
2876
|
+
return content_1.CreateAttributeAcceptResponseItem.from({
|
|
2877
|
+
result: content_1.ResponseItemResult.Accepted,
|
|
2878
|
+
attributeId: sharedAttribute.id
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
|
|
2882
|
+
if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
if (requestItem.attribute.owner.toString() === "") {
|
|
2886
|
+
requestItem.attribute.owner = requestInfo.peer;
|
|
2887
|
+
}
|
|
2888
|
+
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2889
|
+
id: responseItem.attributeId,
|
|
2890
|
+
content: requestItem.attribute,
|
|
2891
|
+
peer: requestInfo.peer,
|
|
2892
|
+
requestReference: requestInfo.id
|
|
2893
|
+
});
|
|
2450
2894
|
}
|
|
2451
2895
|
}
|
|
2452
2896
|
exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
|
|
@@ -2478,16 +2922,25 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
|
|
|
2478
2922
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2479
2923
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2480
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");
|
|
2481
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
|
+
}
|
|
2482
2933
|
static from(value) {
|
|
2483
2934
|
return this.fromAny(value);
|
|
2484
2935
|
}
|
|
2485
2936
|
static postFrom(value) {
|
|
2486
|
-
|
|
2487
|
-
|
|
2937
|
+
if (!(value instanceof AcceptProposeAttributeRequestItemParameters_1)) {
|
|
2938
|
+
throw new consumption_1.ConsumptionError("this should never happen");
|
|
2939
|
+
}
|
|
2940
|
+
if (value.attributeId && value.attribute) {
|
|
2488
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)}.`);
|
|
2489
2942
|
}
|
|
2490
|
-
if (!
|
|
2943
|
+
if (!value.attributeId && !value.attribute) {
|
|
2491
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)}.`);
|
|
2492
2945
|
}
|
|
2493
2946
|
return value;
|
|
@@ -2546,7 +2999,7 @@ class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1
|
|
|
2546
2999
|
}
|
|
2547
3000
|
validateAttribute(attribute) {
|
|
2548
3001
|
if (attribute.owner.toString() !== "") {
|
|
2549
|
-
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."));
|
|
2550
3003
|
}
|
|
2551
3004
|
return ValidationResult_1.ValidationResult.success();
|
|
2552
3005
|
}
|
|
@@ -2556,29 +3009,29 @@ class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1
|
|
|
2556
3009
|
return commonQueryValidationResult;
|
|
2557
3010
|
}
|
|
2558
3011
|
if (requestItem.query instanceof content_1.RelationshipAttributeQuery && requestItem.query.owner.toString() !== "") {
|
|
2559
|
-
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."));
|
|
2560
3013
|
}
|
|
2561
3014
|
return ValidationResult_1.ValidationResult.success();
|
|
2562
3015
|
}
|
|
2563
3016
|
async canAccept(_requestItem, params, requestInfo) {
|
|
2564
3017
|
const parsedParams = AcceptProposeAttributeRequestItemParameters_1.AcceptProposeAttributeRequestItemParameters.from(params);
|
|
2565
3018
|
let attribute = parsedParams.attribute;
|
|
2566
|
-
if (parsedParams.
|
|
3019
|
+
if (parsedParams.isWithExistingAttribute()) {
|
|
2567
3020
|
const localAttribute = await this.consumptionController.attributes.getLocalAttribute(parsedParams.attributeId);
|
|
2568
3021
|
if (!localAttribute) {
|
|
2569
|
-
return ValidationResult_1.ValidationResult.error(transport_1.
|
|
3022
|
+
return ValidationResult_1.ValidationResult.error(transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, requestInfo.id.toString()));
|
|
2570
3023
|
}
|
|
2571
3024
|
attribute = localAttribute.content;
|
|
2572
3025
|
}
|
|
2573
3026
|
if (!attribute.owner.equals(this.currentIdentityAddress)) {
|
|
2574
|
-
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."));
|
|
2575
3028
|
}
|
|
2576
3029
|
return ValidationResult_1.ValidationResult.success();
|
|
2577
3030
|
}
|
|
2578
3031
|
async accept(_requestItem, params, requestInfo) {
|
|
2579
3032
|
const parsedParams = AcceptProposeAttributeRequestItemParameters_1.AcceptProposeAttributeRequestItemParameters.from(params);
|
|
2580
3033
|
let sharedLocalAttribute;
|
|
2581
|
-
if (parsedParams.
|
|
3034
|
+
if (parsedParams.isWithExistingAttribute()) {
|
|
2582
3035
|
sharedLocalAttribute = await this.copyExistingAttribute(parsedParams.attributeId, requestInfo);
|
|
2583
3036
|
}
|
|
2584
3037
|
else {
|
|
@@ -2655,6 +3108,7 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
|
|
|
2655
3108
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2656
3109
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2657
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");
|
|
2658
3112
|
let AcceptReadAttributeRequestItemParameters = AcceptReadAttributeRequestItemParameters_1 = class AcceptReadAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2659
3113
|
isWithExistingAttribute() {
|
|
2660
3114
|
return this.existingAttributeId !== undefined;
|
|
@@ -2666,8 +3120,9 @@ let AcceptReadAttributeRequestItemParameters = AcceptReadAttributeRequestItemPar
|
|
|
2666
3120
|
return this.fromAny(value);
|
|
2667
3121
|
}
|
|
2668
3122
|
static postFrom(value) {
|
|
2669
|
-
if (!(value instanceof AcceptReadAttributeRequestItemParameters_1))
|
|
2670
|
-
throw new
|
|
3123
|
+
if (!(value instanceof AcceptReadAttributeRequestItemParameters_1)) {
|
|
3124
|
+
throw new consumption_1.ConsumptionError("this should never happen");
|
|
3125
|
+
}
|
|
2671
3126
|
if (value.existingAttributeId && value.newAttribute) {
|
|
2672
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)}.`);
|
|
2673
3128
|
}
|
|
@@ -2729,10 +3184,11 @@ class ReadAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.Ge
|
|
|
2729
3184
|
if (parsedParams.isWithExistingAttribute()) {
|
|
2730
3185
|
const foundAttribute = await this.consumptionController.attributes.getLocalAttribute(parsedParams.existingAttributeId);
|
|
2731
3186
|
if (!foundAttribute) {
|
|
2732
|
-
return ValidationResult_1.ValidationResult.error(transport_1.
|
|
3187
|
+
return ValidationResult_1.ValidationResult.error(transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, requestInfo.id.toString()));
|
|
2733
3188
|
}
|
|
2734
|
-
|
|
2735
|
-
|
|
3189
|
+
const ownerIsCurrentIdentity = this.accountController.identity.isMe(foundAttribute.content.owner);
|
|
3190
|
+
if (!ownerIsCurrentIdentity) {
|
|
3191
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("The given Attribute belongs to someone else. You can only share own Attributes."));
|
|
2736
3192
|
}
|
|
2737
3193
|
}
|
|
2738
3194
|
return ValidationResult_1.ValidationResult.success();
|
|
@@ -2793,33 +3249,32 @@ exports.ReadAttributeRequestItemProcessor = ReadAttributeRequestItemProcessor;
|
|
|
2793
3249
|
|
|
2794
3250
|
/***/ }),
|
|
2795
3251
|
|
|
2796
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2797
|
-
|
|
2798
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2799
|
-
|
|
2800
|
-
/***/ (
|
|
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__) => {
|
|
2801
3257
|
|
|
2802
3258
|
"use strict";
|
|
2803
3259
|
|
|
2804
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2805
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2806
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2807
|
-
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;
|
|
2808
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2809
|
-
};
|
|
2810
3260
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2811
|
-
exports.
|
|
2812
|
-
const
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
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
|
+
});
|
|
2816
3274
|
}
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
], AcceptShareAttributeRequestItemParameters);
|
|
2821
|
-
exports.AcceptShareAttributeRequestItemParameters = AcceptShareAttributeRequestItemParameters;
|
|
2822
|
-
//# sourceMappingURL=AcceptShareAttributeRequestItemParameters.js.map
|
|
3275
|
+
}
|
|
3276
|
+
exports.RegisterAttributeListenerRequestItemProcessor = RegisterAttributeListenerRequestItemProcessor;
|
|
3277
|
+
//# sourceMappingURL=RegisterAttributeListenerRequestItemProcessor.js.map
|
|
2823
3278
|
|
|
2824
3279
|
/***/ }),
|
|
2825
3280
|
|
|
@@ -2834,91 +3289,56 @@ exports.AcceptShareAttributeRequestItemParameters = AcceptShareAttributeRequestI
|
|
|
2834
3289
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2835
3290
|
exports.ShareAttributeRequestItemProcessor = void 0;
|
|
2836
3291
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2837
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2838
3292
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2839
3293
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2840
3294
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2841
3295
|
class ShareAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
return ValidationResult_1.ValidationResult.error(transport_1.TransportErrors.general.recordNotFound(content_1.Attribute, requestItem.attributeId.toString()));
|
|
2846
|
-
}
|
|
2847
|
-
const attributeOwnerValidationResult = this.validateAttributeOwner(attribute.content, this.currentIdentityAddress, recipient);
|
|
2848
|
-
if (attributeOwnerValidationResult.isError()) {
|
|
2849
|
-
return attributeOwnerValidationResult;
|
|
3296
|
+
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
3297
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
3298
|
+
return this.canCreateWithIdentityAttribute(requestItem);
|
|
2850
3299
|
}
|
|
2851
|
-
return
|
|
3300
|
+
return this.canCreateWithRelationshipAttribute(requestItem.attribute, recipient);
|
|
2852
3301
|
}
|
|
2853
|
-
|
|
2854
|
-
const
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
const attribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.attributeId);
|
|
2859
|
-
if (!attribute) {
|
|
2860
|
-
return false; // Should the containing Request move to Error state?
|
|
2861
|
-
}
|
|
2862
|
-
if (this.validateAttributeOwner(attribute.content, requestInfo.peer, this.currentIdentityAddress).isError()) {
|
|
2863
|
-
return false;
|
|
3302
|
+
canCreateWithIdentityAttribute(requestItem) {
|
|
3303
|
+
const ownerIsEmpty = requestItem.attribute.owner.toString() === "";
|
|
3304
|
+
const ownerIsCurrentIdentity = requestItem.attribute.owner.equals(this.currentIdentityAddress);
|
|
3305
|
+
if (!ownerIsEmpty && !ownerIsCurrentIdentity) {
|
|
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."));
|
|
2864
3307
|
}
|
|
2865
|
-
return
|
|
3308
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2866
3309
|
}
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
if (!attributeOwner.equals(recipient)) {
|
|
2871
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Can only request sharing of identity attributes owned by the recipient."));
|
|
2872
|
-
}
|
|
3310
|
+
canCreateWithRelationshipAttribute(attribute, recipient) {
|
|
3311
|
+
if (attribute.confidentiality === content_1.RelationshipAttributeConfidentiality.Private) {
|
|
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."));
|
|
2873
3313
|
}
|
|
2874
|
-
if (attribute
|
|
2875
|
-
|
|
2876
|
-
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot request sharing of relationship attributes not owned by recipient or sender."));
|
|
2877
|
-
}
|
|
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."));
|
|
2878
3316
|
}
|
|
2879
3317
|
return ValidationResult_1.ValidationResult.success();
|
|
2880
3318
|
}
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
async accept(requestItem, _params, _requestInfo) {
|
|
2885
|
-
const attribute = (await this.consumptionController.attributes.getLocalAttribute(requestItem.attributeId));
|
|
2886
|
-
if (!(await this.isAttributeAlreadyShared(attribute, requestItem.shareWith))) {
|
|
2887
|
-
await this.shareAttribute(attribute, requestItem.shareWith);
|
|
3319
|
+
async accept(requestItem, _params, requestInfo) {
|
|
3320
|
+
if (requestItem.attribute.owner.toString() === "") {
|
|
3321
|
+
requestItem.attribute.owner = requestInfo.peer;
|
|
2888
3322
|
}
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
return ((await this.consumptionController.attributes.getLocalAttributes({
|
|
2894
|
-
"shareInfo.sourceAttribute": attribute.shareInfo.sourceAttribute.toString(),
|
|
2895
|
-
"shareInfo.peer": shareWith.toString()
|
|
2896
|
-
})).length > 0);
|
|
2897
|
-
}
|
|
2898
|
-
return ((await this.consumptionController.attributes.getLocalAttributes({
|
|
2899
|
-
"shareInfo.sourceAttribute": attribute.id.toString(),
|
|
2900
|
-
"shareInfo.peer": shareWith.toString()
|
|
2901
|
-
})).length > 0);
|
|
2902
|
-
}
|
|
2903
|
-
async shareAttribute(attribute, shareWith) {
|
|
2904
|
-
const createAttributeRequestItem = content_1.CreateAttributeRequestItem.from({
|
|
2905
|
-
attribute: attribute.content,
|
|
2906
|
-
mustBeAccepted: true,
|
|
2907
|
-
sourceAttributeId: attribute.id
|
|
2908
|
-
});
|
|
2909
|
-
const createAttributeRequest = await this.consumptionController.outgoingRequests.create({
|
|
2910
|
-
peer: shareWith,
|
|
2911
|
-
content: content_1.Request.from({
|
|
2912
|
-
items: [createAttributeRequestItem]
|
|
2913
|
-
})
|
|
3323
|
+
const localAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
3324
|
+
content: requestItem.attribute,
|
|
3325
|
+
peer: requestInfo.peer,
|
|
3326
|
+
requestReference: requestInfo.id
|
|
2914
3327
|
});
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
3328
|
+
return content_1.ShareAttributeAcceptResponseItem.from({
|
|
3329
|
+
attributeId: localAttribute.id,
|
|
3330
|
+
result: content_1.ResponseItemResult.Accepted
|
|
2918
3331
|
});
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
3332
|
+
}
|
|
3333
|
+
async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
|
|
3334
|
+
if (!(responseItem instanceof content_1.ShareAttributeAcceptResponseItem)) {
|
|
3335
|
+
return;
|
|
3336
|
+
}
|
|
3337
|
+
await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
3338
|
+
attributeId: responseItem.attributeId,
|
|
3339
|
+
sourceAttributeId: requestItem.sourceAttributeId,
|
|
3340
|
+
peer: requestInfo.peer,
|
|
3341
|
+
requestReference: requestInfo.id
|
|
2922
3342
|
});
|
|
2923
3343
|
}
|
|
2924
3344
|
}
|
|
@@ -2940,15 +3360,15 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
2940
3360
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2941
3361
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2942
3362
|
function validateQuery(query, sender, recipient) {
|
|
2943
|
-
if (query instanceof content_1.
|
|
2944
|
-
if (query.thirdParty
|
|
2945
|
-
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."));
|
|
2946
3366
|
}
|
|
2947
|
-
if (query.thirdParty
|
|
2948
|
-
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."));
|
|
2949
3369
|
}
|
|
2950
|
-
if (query.owner.equals(sender)
|
|
2951
|
-
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."));
|
|
2952
3372
|
}
|
|
2953
3373
|
}
|
|
2954
3374
|
return ValidationResult_1.ValidationResult.success();
|
|
@@ -2980,6 +3400,7 @@ exports.LocalRequest = exports.LocalRequestSource = void 0;
|
|
|
2980
3400
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2981
3401
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2982
3402
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3403
|
+
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
2983
3404
|
const LocalRequestStatus_1 = __webpack_require__(/*! ./LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js");
|
|
2984
3405
|
const LocalRequestStatusLogEntry_1 = __webpack_require__(/*! ./LocalRequestStatusLogEntry */ "./dist/modules/requests/local/LocalRequestStatusLogEntry.js");
|
|
2985
3406
|
const LocalResponse_1 = __webpack_require__(/*! ./LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|
|
@@ -3004,6 +3425,8 @@ LocalRequestSource = __decorate([
|
|
|
3004
3425
|
exports.LocalRequestSource = LocalRequestSource;
|
|
3005
3426
|
let LocalRequest = class LocalRequest extends transport_1.CoreSynchronizable {
|
|
3006
3427
|
changeStatus(newStatus) {
|
|
3428
|
+
if (this.status === newStatus)
|
|
3429
|
+
throw new consumption_1.ConsumptionError("cannot change status to the same status");
|
|
3007
3430
|
const logEntry = LocalRequestStatusLogEntry_1.LocalRequestStatusLogEntry.from({
|
|
3008
3431
|
createdAt: transport_1.CoreDate.utc(),
|
|
3009
3432
|
oldStatus: this.status,
|
|
@@ -3014,7 +3437,7 @@ let LocalRequest = class LocalRequest extends transport_1.CoreSynchronizable {
|
|
|
3014
3437
|
}
|
|
3015
3438
|
sent(source) {
|
|
3016
3439
|
if (this.status !== LocalRequestStatus_1.LocalRequestStatus.Draft) {
|
|
3017
|
-
throw new
|
|
3440
|
+
throw new consumption_1.ConsumptionError("Local Request has to be in status 'Draft'.");
|
|
3018
3441
|
}
|
|
3019
3442
|
this.source = source;
|
|
3020
3443
|
this.changeStatus(LocalRequestStatus_1.LocalRequestStatus.Open);
|
|
@@ -3022,6 +3445,20 @@ let LocalRequest = class LocalRequest extends transport_1.CoreSynchronizable {
|
|
|
3022
3445
|
static from(value) {
|
|
3023
3446
|
return this.fromAny(value);
|
|
3024
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
|
+
}
|
|
3025
3462
|
};
|
|
3026
3463
|
__decorate([
|
|
3027
3464
|
(0, ts_serval_1.serialize)(),
|
|
@@ -3089,6 +3526,7 @@ var LocalRequestStatus;
|
|
|
3089
3526
|
LocalRequestStatus["ManualDecisionRequired"] = "ManualDecisionRequired";
|
|
3090
3527
|
LocalRequestStatus["Decided"] = "Decided";
|
|
3091
3528
|
LocalRequestStatus["Completed"] = "Completed";
|
|
3529
|
+
LocalRequestStatus["Expired"] = "Expired";
|
|
3092
3530
|
})(LocalRequestStatus = exports.LocalRequestStatus || (exports.LocalRequestStatus = {}));
|
|
3093
3531
|
//# sourceMappingURL=LocalRequestStatus.js.map
|
|
3094
3532
|
|
|
@@ -3243,6 +3681,7 @@ const LocalRequestStatus_1 = __webpack_require__(/*! ../local/LocalRequestStatus
|
|
|
3243
3681
|
const LocalResponse_1 = __webpack_require__(/*! ../local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|
|
3244
3682
|
const CompleteOutgoingRequestParameters_1 = __webpack_require__(/*! ./completeOutgoingRequest/CompleteOutgoingRequestParameters */ "./dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js");
|
|
3245
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");
|
|
3246
3685
|
const CreateOutgoingRequestParameters_1 = __webpack_require__(/*! ./createOutgoingRequest/CreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js");
|
|
3247
3686
|
const SentOutgoingRequestParameters_1 = __webpack_require__(/*! ./sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js");
|
|
3248
3687
|
class OutgoingRequestsController extends consumption_1.ConsumptionBaseController {
|
|
@@ -3254,7 +3693,7 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3254
3693
|
this.identity = identity;
|
|
3255
3694
|
}
|
|
3256
3695
|
async canCreate(params) {
|
|
3257
|
-
const parsedParams =
|
|
3696
|
+
const parsedParams = CanCreateOutgoingRequestParameters_1.CanCreateOutgoingRequestParameters.from(params);
|
|
3258
3697
|
const innerResults = await this.canCreateItems(parsedParams.content, parsedParams.peer);
|
|
3259
3698
|
const result = ValidationResult_1.ValidationResult.fromItems(innerResults);
|
|
3260
3699
|
return result;
|
|
@@ -3295,16 +3734,13 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3295
3734
|
return request;
|
|
3296
3735
|
}
|
|
3297
3736
|
async _create(id, content, peer) {
|
|
3298
|
-
const canCreateResult = await this.canCreate({
|
|
3299
|
-
content,
|
|
3300
|
-
peer
|
|
3301
|
-
});
|
|
3737
|
+
const canCreateResult = await this.canCreate({ content, peer });
|
|
3302
3738
|
if (canCreateResult.isError()) {
|
|
3303
3739
|
throw canCreateResult.error;
|
|
3304
3740
|
}
|
|
3305
3741
|
const request = LocalRequest_1.LocalRequest.from({
|
|
3306
3742
|
id: id,
|
|
3307
|
-
content
|
|
3743
|
+
content,
|
|
3308
3744
|
createdAt: transport_1.CoreDate.utc(),
|
|
3309
3745
|
isOwn: true,
|
|
3310
3746
|
peer: peer,
|
|
@@ -3317,17 +3753,16 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3317
3753
|
async createFromRelationshipCreationChange(params) {
|
|
3318
3754
|
const parsedParams = CreateOutgoingRequestFromRelationshipCreationChangeParameters_1.CreateOutgoingRequestFromRelationshipCreationChangeParameters.from(params);
|
|
3319
3755
|
const peer = parsedParams.creationChange.request.createdBy;
|
|
3320
|
-
const
|
|
3321
|
-
if (!(
|
|
3322
|
-
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.");
|
|
3323
3759
|
}
|
|
3324
|
-
const receivedResponse =
|
|
3760
|
+
const receivedResponse = requestContent.response;
|
|
3325
3761
|
const id = receivedResponse.requestId;
|
|
3326
3762
|
const templateContent = parsedParams.template.cache.content;
|
|
3327
|
-
if (!(templateContent instanceof content_1.
|
|
3328
|
-
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.");
|
|
3329
3765
|
}
|
|
3330
|
-
// TODO: is this the correct request (=> could be RelationshipTemplateBody#existingRelationshipRequest)
|
|
3331
3766
|
await this._create(id, templateContent.onNewRelationship, peer);
|
|
3332
3767
|
await this._sent(id, parsedParams.template);
|
|
3333
3768
|
const request = await this._complete(id, parsedParams.creationChange, receivedResponse);
|
|
@@ -3358,17 +3793,17 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3358
3793
|
getSourceType(sourceObject) {
|
|
3359
3794
|
if (sourceObject instanceof transport_1.Message) {
|
|
3360
3795
|
if (!sourceObject.isOwn) {
|
|
3361
|
-
throw new
|
|
3796
|
+
throw new consumption_1.ConsumptionError("Cannot create outgoing Request from a peer Message");
|
|
3362
3797
|
}
|
|
3363
3798
|
return "Message";
|
|
3364
3799
|
}
|
|
3365
3800
|
else if (sourceObject instanceof transport_1.RelationshipTemplate) {
|
|
3366
3801
|
if (!sourceObject.isOwn) {
|
|
3367
|
-
throw new
|
|
3802
|
+
throw new consumption_1.ConsumptionError("Cannot create outgoing Request from a peer Relationship Template");
|
|
3368
3803
|
}
|
|
3369
3804
|
return "RelationshipTemplate";
|
|
3370
3805
|
}
|
|
3371
|
-
throw new
|
|
3806
|
+
throw new consumption_1.ConsumptionError("The given sourceObject is not of a valid type. Valid types are 'Message' and 'RelationshipTemplate'.");
|
|
3372
3807
|
}
|
|
3373
3808
|
async complete(params) {
|
|
3374
3809
|
const parsedParams = CompleteOutgoingRequestParameters_1.CompleteOugoingRequestParameters.from(params);
|
|
@@ -3382,7 +3817,13 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3382
3817
|
}
|
|
3383
3818
|
async _complete(requestId, responseSourceObject, receivedResponse) {
|
|
3384
3819
|
const request = await this.getOrThrow(requestId);
|
|
3385
|
-
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
|
+
}
|
|
3386
3827
|
const canComplete = await this.canComplete(request, receivedResponse);
|
|
3387
3828
|
if (canComplete.isError()) {
|
|
3388
3829
|
throw canComplete.error;
|
|
@@ -3396,7 +3837,7 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3396
3837
|
responseSource = "RelationshipChange";
|
|
3397
3838
|
}
|
|
3398
3839
|
else {
|
|
3399
|
-
throw new
|
|
3840
|
+
throw new consumption_1.ConsumptionError("Invalid responseSourceObject");
|
|
3400
3841
|
}
|
|
3401
3842
|
const localResponse = LocalResponse_1.LocalResponse.from({
|
|
3402
3843
|
content: receivedResponse,
|
|
@@ -3452,36 +3893,50 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
3452
3893
|
await processor.applyIncomingResponseItem(responseItem, requestItem, request);
|
|
3453
3894
|
}
|
|
3454
3895
|
async getOutgoingRequests(query) {
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
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);
|
|
3460
3907
|
}
|
|
3461
3908
|
async getOutgoingRequest(id) {
|
|
3462
3909
|
const requestDoc = await this.localRequests.findOne({ id: id.toString(), isOwn: true });
|
|
3463
|
-
|
|
3464
|
-
|
|
3910
|
+
if (!requestDoc)
|
|
3911
|
+
return;
|
|
3912
|
+
const localRequest = LocalRequest_1.LocalRequest.from(requestDoc);
|
|
3913
|
+
return await this.updateRequestExpiry(localRequest);
|
|
3465
3914
|
}
|
|
3466
3915
|
async getOrThrow(id) {
|
|
3467
3916
|
const request = await this.getOutgoingRequest(id);
|
|
3468
3917
|
if (!request) {
|
|
3469
|
-
throw transport_1.
|
|
3918
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, id.toString());
|
|
3470
3919
|
}
|
|
3471
3920
|
return request;
|
|
3472
3921
|
}
|
|
3473
3922
|
async update(request) {
|
|
3474
3923
|
const requestDoc = await this.localRequests.findOne({ id: request.id.toString(), isOwn: true });
|
|
3475
3924
|
if (!requestDoc) {
|
|
3476
|
-
throw transport_1.
|
|
3925
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalRequest_1.LocalRequest, request.id.toString());
|
|
3477
3926
|
}
|
|
3478
3927
|
await this.localRequests.update(requestDoc, request);
|
|
3479
3928
|
}
|
|
3480
3929
|
assertRequestStatus(request, ...status) {
|
|
3481
3930
|
if (!status.includes(request.status)) {
|
|
3482
|
-
throw new
|
|
3931
|
+
throw new consumption_1.ConsumptionError(`Local Request has to be in status '${status.join("/")}'.`);
|
|
3483
3932
|
}
|
|
3484
3933
|
}
|
|
3934
|
+
async updateRequestExpiry(request) {
|
|
3935
|
+
const statusUpdated = request.updateStatusBasedOnExpiration();
|
|
3936
|
+
if (statusUpdated)
|
|
3937
|
+
await this.update(request);
|
|
3938
|
+
return request;
|
|
3939
|
+
}
|
|
3485
3940
|
}
|
|
3486
3941
|
exports.OutgoingRequestsController = OutgoingRequestsController;
|
|
3487
3942
|
//# sourceMappingURL=OutgoingRequestsController.js.map
|
|
@@ -3582,6 +4037,51 @@ exports.CreateOutgoingRequestFromRelationshipCreationChangeParameters = CreateOu
|
|
|
3582
4037
|
|
|
3583
4038
|
/***/ }),
|
|
3584
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
|
+
|
|
3585
4085
|
/***/ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js":
|
|
3586
4086
|
/*!*************************************************************************************************!*\
|
|
3587
4087
|
!*** ./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js ***!
|
|
@@ -3675,12 +4175,22 @@ exports.SentOutgoingRequestParameters = SentOutgoingRequestParameters;
|
|
|
3675
4175
|
/*!*****************************************************!*\
|
|
3676
4176
|
!*** ./dist/modules/settings/SettingsController.js ***!
|
|
3677
4177
|
\*****************************************************/
|
|
3678
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
4178
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3679
4179
|
|
|
3680
4180
|
"use strict";
|
|
3681
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
|
+
};
|
|
3682
4191
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3683
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");
|
|
3684
4194
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3685
4195
|
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
3686
4196
|
const Setting_1 = __webpack_require__(/*! ./local/Setting */ "./dist/modules/settings/local/Setting.js");
|
|
@@ -3699,7 +4209,7 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3699
4209
|
}
|
|
3700
4210
|
async getSettings(query) {
|
|
3701
4211
|
const items = await this.settings.find(query);
|
|
3702
|
-
return
|
|
4212
|
+
return this.parseArray(items, Setting_1.Setting);
|
|
3703
4213
|
}
|
|
3704
4214
|
async createSetting(parameters) {
|
|
3705
4215
|
const setting = Setting_1.Setting.from({
|
|
@@ -3717,20 +4227,55 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3717
4227
|
}
|
|
3718
4228
|
async updateSetting(setting) {
|
|
3719
4229
|
const oldSetting = await this.settings.read(setting.id.toString());
|
|
3720
|
-
if (!oldSetting)
|
|
3721
|
-
throw transport_1.
|
|
3722
|
-
}
|
|
4230
|
+
if (!oldSetting)
|
|
4231
|
+
throw transport_1.CoreErrors.general.recordNotFound(Setting_1.Setting, setting.id.toString());
|
|
3723
4232
|
await this.settings.update(oldSetting, setting);
|
|
3724
4233
|
}
|
|
3725
4234
|
async deleteSetting(setting) {
|
|
3726
4235
|
await this.settings.delete(setting);
|
|
3727
4236
|
}
|
|
3728
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);
|
|
3729
4244
|
exports.SettingsController = SettingsController;
|
|
3730
4245
|
//# sourceMappingURL=SettingsController.js.map
|
|
3731
4246
|
|
|
3732
4247
|
/***/ }),
|
|
3733
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
|
+
|
|
3734
4279
|
/***/ "./dist/modules/settings/local/CreateSettingParameter.js":
|
|
3735
4280
|
/*!***************************************************************!*\
|
|
3736
4281
|
!*** ./dist/modules/settings/local/CreateSettingParameter.js ***!
|
|
@@ -4173,12 +4718,19 @@ __webpack_require__(/*! reflect-metadata */ "./node_modules/reflect-metadata/Ref
|
|
|
4173
4718
|
const EventBus_1 = __webpack_require__(/*! ../EventBus */ "./node_modules/@js-soft/ts-utils/dist/eventBus/EventBus.js");
|
|
4174
4719
|
const SubscriptionTargetInfo_1 = __webpack_require__(/*! ../SubscriptionTargetInfo */ "./node_modules/@js-soft/ts-utils/dist/eventBus/SubscriptionTargetInfo.js");
|
|
4175
4720
|
class EventEmitter2EventBus {
|
|
4721
|
+
errorCallback;
|
|
4176
4722
|
emitter;
|
|
4177
4723
|
listeners = new Map();
|
|
4178
4724
|
nextId = 0;
|
|
4179
4725
|
invocationPromises = [];
|
|
4180
|
-
constructor(
|
|
4181
|
-
this.
|
|
4726
|
+
constructor(errorCallback, eventEmitter2Options) {
|
|
4727
|
+
this.errorCallback = errorCallback;
|
|
4728
|
+
this.emitter = new eventemitter2_1.EventEmitter2({
|
|
4729
|
+
maxListeners: 50,
|
|
4730
|
+
verboseMemoryLeak: true,
|
|
4731
|
+
...eventEmitter2Options,
|
|
4732
|
+
wildcard: true
|
|
4733
|
+
});
|
|
4182
4734
|
}
|
|
4183
4735
|
subscribe(subscriptionTarget, handler) {
|
|
4184
4736
|
return this.registerHandler(subscriptionTarget, handler);
|
|
@@ -4198,7 +4750,7 @@ class EventEmitter2EventBus {
|
|
|
4198
4750
|
}
|
|
4199
4751
|
const invocationPromise = (async () => await handler(event))();
|
|
4200
4752
|
this.invocationPromises.push(invocationPromise);
|
|
4201
|
-
await invocationPromise;
|
|
4753
|
+
await invocationPromise.catch((e) => this.errorCallback(e, subscriptionTargetInfo.namespace));
|
|
4202
4754
|
this.invocationPromises = this.invocationPromises.filter((p) => p !== invocationPromise);
|
|
4203
4755
|
if (isOneTimeHandler)
|
|
4204
4756
|
this.listeners.delete(listenerId);
|
|
@@ -4262,7 +4814,11 @@ exports.EventEmitter2EventBus = EventEmitter2EventBus;
|
|
|
4262
4814
|
|
|
4263
4815
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4264
4816
|
if (k2 === undefined) k2 = k;
|
|
4265
|
-
Object.
|
|
4817
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4818
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4819
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4820
|
+
}
|
|
4821
|
+
Object.defineProperty(o, k2, desc);
|
|
4266
4822
|
}) : (function(o, m, k, k2) {
|
|
4267
4823
|
if (k2 === undefined) k2 = k;
|
|
4268
4824
|
o[k2] = m[k];
|
|
@@ -4331,7 +4887,11 @@ exports.Event = Event;
|
|
|
4331
4887
|
|
|
4332
4888
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4333
4889
|
if (k2 === undefined) k2 = k;
|
|
4334
|
-
Object.
|
|
4890
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4891
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4892
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4893
|
+
}
|
|
4894
|
+
Object.defineProperty(o, k2, desc);
|
|
4335
4895
|
}) : (function(o, m, k, k2) {
|
|
4336
4896
|
if (k2 === undefined) k2 = k;
|
|
4337
4897
|
o[k2] = m[k];
|
|
@@ -4356,7 +4916,11 @@ __exportStar(__webpack_require__(/*! ./Event */ "./node_modules/@js-soft/ts-util
|
|
|
4356
4916
|
|
|
4357
4917
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4358
4918
|
if (k2 === undefined) k2 = k;
|
|
4359
|
-
Object.
|
|
4919
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4920
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4921
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4922
|
+
}
|
|
4923
|
+
Object.defineProperty(o, k2, desc);
|
|
4360
4924
|
}) : (function(o, m, k, k2) {
|
|
4361
4925
|
if (k2 === undefined) k2 = k;
|
|
4362
4926
|
o[k2] = m[k];
|
|
@@ -4381,29 +4945,50 @@ __exportStar(__webpack_require__(/*! ./sleep */ "./node_modules/@js-soft/ts-util
|
|
|
4381
4945
|
/*!*************************************************************!*\
|
|
4382
4946
|
!*** ./node_modules/@js-soft/ts-utils/dist/logDecorator.js ***!
|
|
4383
4947
|
\*************************************************************/
|
|
4384
|
-
/***/ ((__unused_webpack_module, exports)
|
|
4948
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4385
4949
|
|
|
4386
4950
|
"use strict";
|
|
4387
4951
|
|
|
4952
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4953
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4954
|
+
};
|
|
4388
4955
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4389
4956
|
exports.log = void 0;
|
|
4390
|
-
|
|
4391
|
-
function log(
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
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;
|
|
4405
4991
|
};
|
|
4406
|
-
return propertyDesciptor;
|
|
4407
4992
|
}
|
|
4408
4993
|
exports.log = log;
|
|
4409
4994
|
//# sourceMappingURL=logDecorator.js.map
|
|
@@ -4481,6 +5066,9 @@ class ApplicationError extends Error {
|
|
|
4481
5066
|
equals(error) {
|
|
4482
5067
|
return this.code === error.code;
|
|
4483
5068
|
}
|
|
5069
|
+
toString() {
|
|
5070
|
+
return JSON.stringify({ code: this.code, message: this.message, data: this.data }, undefined, 2);
|
|
5071
|
+
}
|
|
4484
5072
|
}
|
|
4485
5073
|
exports.ApplicationError = ApplicationError;
|
|
4486
5074
|
//# sourceMappingURL=ApplicationError.js.map
|
|
@@ -4526,7 +5114,7 @@ class Result {
|
|
|
4526
5114
|
}
|
|
4527
5115
|
get value() {
|
|
4528
5116
|
if (!this.isSuccess) {
|
|
4529
|
-
throw new Error(
|
|
5117
|
+
throw new Error(`Can't get the value of an error result. Use 'error' instead. Root error: \r\n${this.error}`);
|
|
4530
5118
|
}
|
|
4531
5119
|
return this._value;
|
|
4532
5120
|
}
|
|
@@ -4552,7 +5140,11 @@ exports.Result = Result;
|
|
|
4552
5140
|
|
|
4553
5141
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4554
5142
|
if (k2 === undefined) k2 = k;
|
|
4555
|
-
Object.
|
|
5143
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5144
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5145
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
5146
|
+
}
|
|
5147
|
+
Object.defineProperty(o, k2, desc);
|
|
4556
5148
|
}) : (function(o, m, k, k2) {
|
|
4557
5149
|
if (k2 === undefined) k2 = k;
|
|
4558
5150
|
o[k2] = m[k];
|
|
@@ -4694,7 +5286,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
4694
5286
|
var obj = {};
|
|
4695
5287
|
var key;
|
|
4696
5288
|
var len = keys.length;
|
|
4697
|
-
var valuesCount = values ?
|
|
5289
|
+
var valuesCount = values ? values.length : 0;
|
|
4698
5290
|
for (var i = 0; i < len; i++) {
|
|
4699
5291
|
key = keys[i];
|
|
4700
5292
|
obj[key] = i < valuesCount ? values[i] : undefined;
|
|
@@ -6217,6 +6809,43 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
6217
6809
|
}();
|
|
6218
6810
|
|
|
6219
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
|
+
|
|
6220
6849
|
/***/ }),
|
|
6221
6850
|
|
|
6222
6851
|
/***/ "./node_modules/luxon/build/node/luxon.js":
|
|
@@ -8871,7 +9500,8 @@ function clone$1(dur, alts, clear = false) {
|
|
|
8871
9500
|
...(alts.values || {})
|
|
8872
9501
|
},
|
|
8873
9502
|
loc: dur.loc.clone(alts.loc),
|
|
8874
|
-
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
|
|
9503
|
+
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
|
|
9504
|
+
matrix: alts.matrix || dur.matrix
|
|
8875
9505
|
};
|
|
8876
9506
|
return new Duration(conf);
|
|
8877
9507
|
}
|
|
@@ -8910,7 +9540,7 @@ function normalizeValues(matrix, vals) {
|
|
|
8910
9540
|
*
|
|
8911
9541
|
* Here is a brief overview of commonly used methods and getters in Duration:
|
|
8912
9542
|
*
|
|
8913
|
-
* * **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}.
|
|
8914
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.
|
|
8915
9545
|
* * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
|
|
8916
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}.
|
|
@@ -8926,10 +9556,16 @@ class Duration {
|
|
|
8926
9556
|
*/
|
|
8927
9557
|
constructor(config) {
|
|
8928
9558
|
const accurate = config.conversionAccuracy === "longterm" || false;
|
|
9559
|
+
let matrix = accurate ? accurateMatrix : casualMatrix;
|
|
9560
|
+
|
|
9561
|
+
if (config.matrix) {
|
|
9562
|
+
matrix = config.matrix;
|
|
9563
|
+
}
|
|
8929
9564
|
/**
|
|
8930
9565
|
* @access private
|
|
8931
9566
|
*/
|
|
8932
9567
|
|
|
9568
|
+
|
|
8933
9569
|
this.values = config.values;
|
|
8934
9570
|
/**
|
|
8935
9571
|
* @access private
|
|
@@ -8950,7 +9586,7 @@ class Duration {
|
|
|
8950
9586
|
* @access private
|
|
8951
9587
|
*/
|
|
8952
9588
|
|
|
8953
|
-
this.matrix =
|
|
9589
|
+
this.matrix = matrix;
|
|
8954
9590
|
/**
|
|
8955
9591
|
* @access private
|
|
8956
9592
|
*/
|
|
@@ -8989,7 +9625,8 @@ class Duration {
|
|
|
8989
9625
|
* @param {Object} [opts=[]] - options for creating this Duration
|
|
8990
9626
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
8991
9627
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
8992
|
-
* @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
|
|
8993
9630
|
* @return {Duration}
|
|
8994
9631
|
*/
|
|
8995
9632
|
|
|
@@ -9002,7 +9639,8 @@ class Duration {
|
|
|
9002
9639
|
return new Duration({
|
|
9003
9640
|
values: normalizeObject(obj, Duration.normalizeUnit),
|
|
9004
9641
|
loc: Locale.fromObject(opts),
|
|
9005
|
-
conversionAccuracy: opts.conversionAccuracy
|
|
9642
|
+
conversionAccuracy: opts.conversionAccuracy,
|
|
9643
|
+
matrix: opts.matrix
|
|
9006
9644
|
});
|
|
9007
9645
|
}
|
|
9008
9646
|
/**
|
|
@@ -9034,7 +9672,8 @@ class Duration {
|
|
|
9034
9672
|
* @param {Object} opts - options for parsing
|
|
9035
9673
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9036
9674
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9037
|
-
* @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
|
|
9038
9677
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
|
|
9039
9678
|
* @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
|
|
9040
9679
|
* @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
|
|
@@ -9058,7 +9697,8 @@ class Duration {
|
|
|
9058
9697
|
* @param {Object} opts - options for parsing
|
|
9059
9698
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9060
9699
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9061
|
-
* @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
|
|
9062
9702
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Times
|
|
9063
9703
|
* @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
|
|
9064
9704
|
* @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|
@@ -9389,7 +10029,7 @@ class Duration {
|
|
|
9389
10029
|
* Scale this Duration by the specified amount. Return a newly-constructed Duration.
|
|
9390
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.
|
|
9391
10031
|
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
|
|
9392
|
-
* @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 }
|
|
9393
10033
|
* @return {Duration}
|
|
9394
10034
|
*/
|
|
9395
10035
|
|
|
@@ -9447,20 +10087,18 @@ class Duration {
|
|
|
9447
10087
|
reconfigure({
|
|
9448
10088
|
locale,
|
|
9449
10089
|
numberingSystem,
|
|
9450
|
-
conversionAccuracy
|
|
10090
|
+
conversionAccuracy,
|
|
10091
|
+
matrix
|
|
9451
10092
|
} = {}) {
|
|
9452
10093
|
const loc = this.loc.clone({
|
|
9453
10094
|
locale,
|
|
9454
10095
|
numberingSystem
|
|
9455
|
-
})
|
|
9456
|
-
|
|
9457
|
-
loc
|
|
10096
|
+
});
|
|
10097
|
+
const opts = {
|
|
10098
|
+
loc,
|
|
10099
|
+
matrix,
|
|
10100
|
+
conversionAccuracy
|
|
9458
10101
|
};
|
|
9459
|
-
|
|
9460
|
-
if (conversionAccuracy) {
|
|
9461
|
-
opts.conversionAccuracy = conversionAccuracy;
|
|
9462
|
-
}
|
|
9463
|
-
|
|
9464
10102
|
return clone$1(this, opts);
|
|
9465
10103
|
}
|
|
9466
10104
|
/**
|
|
@@ -9734,10 +10372,10 @@ function validateStartEnd(start, end) {
|
|
|
9734
10372
|
*
|
|
9735
10373
|
* Here is a brief overview of the most commonly used methods and getters in Interval:
|
|
9736
10374
|
*
|
|
9737
|
-
* * **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}.
|
|
9738
10376
|
* * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
|
|
9739
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}.
|
|
9740
|
-
* * **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}.
|
|
9741
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}
|
|
9742
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}.
|
|
9743
10381
|
*/
|
|
@@ -10571,7 +11209,7 @@ function dayDiff(earlier, later) {
|
|
|
10571
11209
|
}
|
|
10572
11210
|
|
|
10573
11211
|
function highOrderDiffs(cursor, later, units) {
|
|
10574
|
-
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) => {
|
|
10575
11213
|
const days = dayDiff(a, b);
|
|
10576
11214
|
return (days - days % 7) / 7;
|
|
10577
11215
|
}], ["days", dayDiff]];
|
|
@@ -11178,7 +11816,6 @@ function expandMacroTokens(tokens, locale) {
|
|
|
11178
11816
|
* @private
|
|
11179
11817
|
*/
|
|
11180
11818
|
|
|
11181
|
-
|
|
11182
11819
|
function explainFromTokens(locale, input, format) {
|
|
11183
11820
|
const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
|
|
11184
11821
|
units = tokens.map(t => unitForToken(t, locale)),
|
|
@@ -11774,7 +12411,7 @@ function lastOpts(argList) {
|
|
|
11774
12411
|
*
|
|
11775
12412
|
* Here is a brief overview of the most commonly used functionality it provides:
|
|
11776
12413
|
*
|
|
11777
|
-
* * **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}.
|
|
11778
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},
|
|
11779
12416
|
* {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
|
|
11780
12417
|
* * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
|
|
@@ -12313,6 +12950,19 @@ class DateTime {
|
|
|
12313
12950
|
static parseFormatForOpts(formatOpts, localeOpts = {}) {
|
|
12314
12951
|
const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
|
|
12315
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("");
|
|
12316
12966
|
} // INFO
|
|
12317
12967
|
|
|
12318
12968
|
/**
|
|
@@ -13005,8 +13655,8 @@ class DateTime {
|
|
|
13005
13655
|
* @param {Object} opts - opts to override the configuration options on this DateTime
|
|
13006
13656
|
* @example DateTime.now().toLocaleString(); //=> 4/20/2017
|
|
13007
13657
|
* @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
|
|
13008
|
-
* @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
|
|
13009
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'
|
|
13010
13660
|
* @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
|
|
13011
13661
|
* @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
|
|
13012
13662
|
* @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
|
|
@@ -13043,7 +13693,7 @@ class DateTime {
|
|
|
13043
13693
|
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
|
|
13044
13694
|
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
|
|
13045
13695
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|
13046
|
-
* @param {boolean} [opts.extendedZone=
|
|
13696
|
+
* @param {boolean} [opts.extendedZone=false] - add the time zone format extension
|
|
13047
13697
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
13048
13698
|
* @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
|
|
13049
13699
|
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
|
@@ -13748,7 +14398,7 @@ function friendlyDateTime(dateTimeish) {
|
|
|
13748
14398
|
}
|
|
13749
14399
|
}
|
|
13750
14400
|
|
|
13751
|
-
const VERSION = "3.0.
|
|
14401
|
+
const VERSION = "3.0.4";
|
|
13752
14402
|
|
|
13753
14403
|
exports.DateTime = DateTime;
|
|
13754
14404
|
exports.Duration = Duration;
|