@nmshd/runtime 2.0.0-alpha.10 → 2.0.0-alpha.13
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 +5 -5
- package/dist/dataViews/DataViewExpander.d.ts +15 -21
- package/dist/dataViews/DataViewExpander.js +160 -207
- package/dist/dataViews/DataViewExpander.js.map +1 -1
- package/dist/dataViews/DataViewObject.d.ts +1 -1
- package/dist/dataViews/consumption/ConsumptionAttributeDVO.d.ts +65 -0
- package/dist/dataViews/{content/AttributeDVO.js → consumption/ConsumptionAttributeDVO.js} +1 -1
- package/dist/dataViews/consumption/ConsumptionAttributeDVO.js.map +1 -0
- package/dist/dataViews/consumption/ConsumptionRequestDVO.d.ts +26 -0
- package/dist/dataViews/consumption/{StoredAttributeDVO.js → ConsumptionRequestDVO.js} +1 -1
- package/dist/dataViews/consumption/ConsumptionRequestDVO.js.map +1 -0
- package/dist/dataViews/consumption/index.d.ts +2 -1
- package/dist/dataViews/consumption/index.js +2 -1
- package/dist/dataViews/consumption/index.js.map +1 -1
- package/dist/dataViews/content/RequestDVOs.d.ts +14 -18
- package/dist/dataViews/content/index.d.ts +0 -1
- package/dist/dataViews/content/index.js +0 -1
- package/dist/dataViews/content/index.js.map +1 -1
- package/dist/extensibility/facades/consumption/AttributesFacade.d.ts +4 -10
- package/dist/extensibility/facades/consumption/AttributesFacade.js +6 -24
- package/dist/extensibility/facades/consumption/AttributesFacade.js.map +1 -1
- package/dist/types/consumption/ConsumptionAttributeDTO.d.ts +6 -2
- package/dist/useCases/common/Schemas.d.ts +1 -4
- package/dist/useCases/common/Schemas.js +427 -96
- package/dist/useCases/common/Schemas.js.map +1 -1
- package/dist/useCases/consumption/attributes/AttributeMapper.d.ts +0 -2
- package/dist/useCases/consumption/attributes/AttributeMapper.js +6 -9
- package/dist/useCases/consumption/attributes/AttributeMapper.js.map +1 -1
- package/dist/useCases/consumption/attributes/CreateAttribute.d.ts +6 -6
- package/dist/useCases/consumption/attributes/CreateAttribute.js +13 -9
- package/dist/useCases/consumption/attributes/CreateAttribute.js.map +1 -1
- package/dist/useCases/consumption/attributes/CreateShareAttributeCopy.d.ts +29 -0
- package/dist/useCases/consumption/attributes/{DeleteAttributeByName.js → CreateShareAttributeCopy.js} +23 -18
- package/dist/useCases/consumption/attributes/CreateShareAttributeCopy.js.map +1 -0
- package/dist/useCases/consumption/attributes/DeleteAttribute.d.ts +7 -4
- package/dist/useCases/consumption/attributes/DeleteAttribute.js +10 -7
- package/dist/useCases/consumption/attributes/DeleteAttribute.js.map +1 -1
- package/dist/useCases/consumption/attributes/ExtendedAttributeValue.d.ts +10 -0
- package/dist/{dataViews/consumption/MatchedAttributesDVO.js → useCases/consumption/attributes/ExtendedAttributeValue.js} +1 -1
- package/dist/useCases/consumption/attributes/ExtendedAttributeValue.js.map +1 -0
- package/dist/useCases/consumption/attributes/GetAllValid.js +1 -1
- package/dist/useCases/consumption/attributes/GetAllValid.js.map +1 -1
- package/dist/useCases/consumption/attributes/GetAttribute.d.ts +7 -4
- package/dist/useCases/consumption/attributes/GetAttribute.js +10 -7
- package/dist/useCases/consumption/attributes/GetAttribute.js.map +1 -1
- package/dist/useCases/consumption/attributes/GetAttributes.d.ts +29 -6
- package/dist/useCases/consumption/attributes/GetAttributes.js +108 -12
- package/dist/useCases/consumption/attributes/GetAttributes.js.map +1 -1
- package/dist/useCases/consumption/attributes/SucceedAttribute.d.ts +10 -7
- package/dist/useCases/consumption/attributes/SucceedAttribute.js +14 -10
- package/dist/useCases/consumption/attributes/SucceedAttribute.js.map +1 -1
- package/dist/useCases/consumption/attributes/UpdateAttribute.d.ts +9 -6
- package/dist/useCases/consumption/attributes/UpdateAttribute.js +14 -15
- package/dist/useCases/consumption/attributes/UpdateAttribute.js.map +1 -1
- package/dist/useCases/consumption/attributes/index.d.ts +1 -4
- package/dist/useCases/consumption/attributes/index.js +1 -4
- package/dist/useCases/consumption/attributes/index.js.map +1 -1
- package/dist/useCases/consumption/requests/CompleteIncomingRequest.d.ts +1 -1
- package/dist/useCases/consumption/requests/RequestValidationResultMapper.js +2 -2
- package/dist/useCases/consumption/requests/RequestValidationResultMapper.js.map +1 -1
- package/dist/useCases/transport/challenges/{ValidateChallange.d.ts → ValidateChallenge.d.ts} +0 -0
- package/dist/useCases/transport/challenges/{ValidateChallange.js → ValidateChallenge.js} +1 -1
- package/dist/useCases/transport/challenges/{ValidateChallange.js.map → ValidateChallenge.js.map} +1 -1
- package/dist/useCases/transport/challenges/index.d.ts +1 -1
- package/dist/useCases/transport/challenges/index.js +1 -1
- package/dist/useCases/transport/messages/GetMessages.js +0 -1
- package/dist/useCases/transport/messages/GetMessages.js.map +1 -1
- package/lib-web/nmshd.runtime.js +853 -646
- package/lib-web/nmshd.runtime.js.map +1 -1
- package/lib-web/nmshd.runtime.min.js +3 -3
- package/lib-web/nmshd.runtime.min.js.map +1 -1
- package/package.json +7 -7
- package/dist/dataViews/consumption/MatchedAttributesDVO.d.ts +0 -8
- package/dist/dataViews/consumption/MatchedAttributesDVO.js.map +0 -1
- package/dist/dataViews/consumption/StoredAttributeDVO.d.ts +0 -6
- package/dist/dataViews/consumption/StoredAttributeDVO.js.map +0 -1
- package/dist/dataViews/content/AttributeDVO.d.ts +0 -14
- package/dist/dataViews/content/AttributeDVO.js.map +0 -1
- package/dist/useCases/consumption/attributes/DeleteAttributeByName.d.ts +0 -17
- package/dist/useCases/consumption/attributes/DeleteAttributeByName.js.map +0 -1
- package/dist/useCases/consumption/attributes/GetAttributeByName.d.ts +0 -16
- package/dist/useCases/consumption/attributes/GetAttributeByName.js +0 -47
- package/dist/useCases/consumption/attributes/GetAttributeByName.js.map +0 -1
- package/dist/useCases/consumption/attributes/GetAttributesByNames.d.ts +0 -16
- package/dist/useCases/consumption/attributes/GetAttributesByNames.js +0 -42
- package/dist/useCases/consumption/attributes/GetAttributesByNames.js.map +0 -1
- package/dist/useCases/consumption/attributes/GetHistoryByName.d.ts +0 -16
- package/dist/useCases/consumption/attributes/GetHistoryByName.js +0 -47
- package/dist/useCases/consumption/attributes/GetHistoryByName.js.map +0 -1
package/dist/buildInformation.js
CHANGED
|
@@ -7,11 +7,11 @@ const content_1 = require("@nmshd/content");
|
|
|
7
7
|
const crypto_1 = require("@nmshd/crypto");
|
|
8
8
|
const transport_1 = require("@nmshd/transport");
|
|
9
9
|
exports.buildInformation = {
|
|
10
|
-
version: "2.0.0-alpha.
|
|
11
|
-
build: "
|
|
12
|
-
date: "2022-
|
|
13
|
-
commit: "
|
|
14
|
-
dependencies: {"@js-soft/docdb-querytranslator":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/ts-serval":"2.0.3","@js-soft/ts-utils":"^1.1.2","@nmshd/consumption":"2.0.0-alpha.
|
|
10
|
+
version: "2.0.0-alpha.13",
|
|
11
|
+
build: "60",
|
|
12
|
+
date: "2022-06-01T10:35:04+00:00",
|
|
13
|
+
commit: "0b4c874c72636c43a1a3d8462edfa1948ac167a7",
|
|
14
|
+
dependencies: {"@js-soft/docdb-querytranslator":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/ts-serval":"2.0.3","@js-soft/ts-utils":"^1.1.2","@nmshd/consumption":"2.0.0-alpha.19","@nmshd/content":"2.0.0-alpha.25","@nmshd/crypto":"2.0.1","@nmshd/transport":"2.0.0-alpha.1","ajv":"^8.11.0","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","fluent-ts-validator":"3.0.3","json-stringify-safe":"^5.0.1","luxon":"^2.4.0","qrcode":"1.5.0","reflect-metadata":"0.1.13","ts-simple-nameof":"1.3.1","typescript-ioc":"3.2.2"},
|
|
15
15
|
libraries: {
|
|
16
16
|
serval: ts_serval_1.buildInformation,
|
|
17
17
|
consumption: consumption_1.buildInformation,
|
|
@@ -1,41 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConsumptionController } from "@nmshd/consumption";
|
|
2
|
+
import { IdentityAttributeJSON, IdentityAttributeQueryJSON, RelationshipAttributeJSON, RequestJSON } from "@nmshd/content";
|
|
2
3
|
import { IdentityController } from "@nmshd/transport";
|
|
3
4
|
import { FileDVO, IdentityDVO } from "..";
|
|
4
5
|
import { TransportServices } from "../extensibility";
|
|
5
6
|
import { ConsumptionServices } from "../extensibility/ConsumptionServices";
|
|
6
|
-
import { ConsumptionAttributeDTO, FileDTO, IdentityDTO, MessageDTO, MessageWithAttachmentsDTO, RecipientDTO, RelationshipChangeDTO, RelationshipDTO, RelationshipInfoDTO } from "../types";
|
|
7
|
-
import {
|
|
8
|
-
import { StoredAttributeDVO } from "./consumption/StoredAttributeDVO";
|
|
9
|
-
import { AttributeDVO } from "./content/AttributeDVO";
|
|
7
|
+
import { ConsumptionAttributeDTO, ConsumptionRequestDTO, ConsumptionResponseDTO, FileDTO, IdentityDTO, MessageDTO, MessageWithAttachmentsDTO, RecipientDTO, RelationshipChangeDTO, RelationshipDTO, RelationshipInfoDTO } from "../types";
|
|
8
|
+
import { ConsumptionRequestDVO, ConsumptionResponseDVO, DraftAttributeDVO, IdentityAttributeQueryExpanded, PeerAttributeDVO, RepositoryAttributeDVO, SharedToPeerAttributeDVO } from "./consumption";
|
|
10
9
|
import { MailDVO, RequestMailDVO } from "./content/MailDVOs";
|
|
11
|
-
import {
|
|
10
|
+
import { RequestDVO } from "./content/RequestDVOs";
|
|
12
11
|
import { DataViewObject } from "./DataViewObject";
|
|
13
12
|
import { MessageDVO, RecipientDVO } from "./transport/MessageDVO";
|
|
14
13
|
import { RelationshipChangeDVO, RelationshipDVO } from "./transport/RelationshipDVO";
|
|
15
14
|
export declare class DataViewExpander {
|
|
16
15
|
private readonly transport;
|
|
17
16
|
private readonly consumption;
|
|
17
|
+
private readonly consumptionController;
|
|
18
18
|
private readonly identityController;
|
|
19
|
-
constructor(transport: TransportServices, consumption: ConsumptionServices, identityController: IdentityController);
|
|
19
|
+
constructor(transport: TransportServices, consumption: ConsumptionServices, consumptionController: ConsumptionController, identityController: IdentityController);
|
|
20
20
|
expand(content: any, expectedType?: string): Promise<DataViewObject | DataViewObject[]>;
|
|
21
21
|
expandMessageDTO(message: MessageDTO | MessageWithAttachmentsDTO): Promise<MessageDVO | MailDVO | RequestMailDVO>;
|
|
22
22
|
expandMessageDTOs(messages: MessageDTO[]): Promise<(MessageDVO | MailDVO | RequestMailDVO)[]>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
expandAttribute(attribute: AttributeJSON): AttributeDVO;
|
|
32
|
-
expandAttributes(attributes: AttributeJSON[]): Promise<AttributeDVO[]>;
|
|
33
|
-
expandAttributesChangeRequest(attributesChangeRequest: AttributesChangeRequestJSON): Promise<AttributesChangeRequestDVO>;
|
|
34
|
-
expandAttributesRequest(attributesRequest: AttributesRequestJSON): Promise<AttributesRequestDVO>;
|
|
23
|
+
expandRequest(request: RequestJSON): RequestDVO;
|
|
24
|
+
expandConsumptionRequest(request: ConsumptionRequestDTO): Promise<ConsumptionRequestDVO>;
|
|
25
|
+
expandConsumptionResponse(response: ConsumptionResponseDTO): ConsumptionResponseDVO;
|
|
26
|
+
expandConsumptionAttribute(attribute: ConsumptionAttributeDTO): Promise<RepositoryAttributeDVO | SharedToPeerAttributeDVO | PeerAttributeDVO>;
|
|
27
|
+
expandConsumptionAttributes(attributes: ConsumptionAttributeDTO[]): Promise<(RepositoryAttributeDVO | SharedToPeerAttributeDVO | PeerAttributeDVO)[]>;
|
|
28
|
+
expandIdentityAttributeQuery(query: IdentityAttributeQueryJSON): Promise<IdentityAttributeQueryExpanded>;
|
|
29
|
+
expandAttribute(attribute: IdentityAttributeJSON | RelationshipAttributeJSON): Promise<DraftAttributeDVO>;
|
|
30
|
+
expandAttributes(attributes: (IdentityAttributeJSON | RelationshipAttributeJSON)[]): Promise<DraftAttributeDVO[]>;
|
|
35
31
|
expandSelf(): IdentityDVO;
|
|
36
32
|
expandUnknown(address: string): IdentityDVO;
|
|
37
|
-
expandAttributesShareRequests(requests: AttributesShareRequestJSON[]): Promise<AttributesShareRequestDVO[]>;
|
|
38
|
-
expandAttributesChangeRequests(requests: AttributesChangeRequestJSON[]): Promise<AttributesChangeRequestDVO[]>;
|
|
39
33
|
expandAddress(address: string): Promise<IdentityDVO>;
|
|
40
34
|
expandAddresses(addresses: string[]): Promise<IdentityDVO[]>;
|
|
41
35
|
expandRecipient(recipient: RecipientDTO): Promise<RecipientDVO>;
|
|
@@ -13,6 +13,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DataViewExpander = void 0;
|
|
16
|
+
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
17
|
+
const consumption_1 = require("@nmshd/consumption");
|
|
18
|
+
const content_1 = require("@nmshd/content");
|
|
16
19
|
const transport_1 = require("@nmshd/transport");
|
|
17
20
|
const typescript_ioc_1 = require("typescript-ioc");
|
|
18
21
|
const extensibility_1 = require("../extensibility");
|
|
@@ -22,9 +25,10 @@ const DataViewTranslateable_1 = require("./DataViewTranslateable");
|
|
|
22
25
|
const MessageDVO_1 = require("./transport/MessageDVO");
|
|
23
26
|
const RelationshipDVO_1 = require("./transport/RelationshipDVO");
|
|
24
27
|
let DataViewExpander = class DataViewExpander {
|
|
25
|
-
constructor(transport, consumption, identityController) {
|
|
28
|
+
constructor(transport, consumption, consumptionController, identityController) {
|
|
26
29
|
this.transport = transport;
|
|
27
30
|
this.consumption = consumption;
|
|
31
|
+
this.consumptionController = consumptionController;
|
|
28
32
|
this.identityController = identityController;
|
|
29
33
|
}
|
|
30
34
|
async expand(content, expectedType) {
|
|
@@ -48,31 +52,11 @@ let DataViewExpander = class DataViewExpander {
|
|
|
48
52
|
return await this.expandMessageDTOs(content);
|
|
49
53
|
}
|
|
50
54
|
return await this.expandMessageDTO(content);
|
|
51
|
-
case "AttributesRequest":
|
|
52
|
-
if (content instanceof Array) {
|
|
53
|
-
return await this.expandUnknownRequests(content);
|
|
54
|
-
}
|
|
55
|
-
return await this.expandUnknownRequest(content);
|
|
56
|
-
case "AttributesShareRequest":
|
|
57
|
-
if (content instanceof Array) {
|
|
58
|
-
return await this.expandAttributesShareRequests(content);
|
|
59
|
-
}
|
|
60
|
-
return await this.expandAttributesShareRequest(content);
|
|
61
|
-
case "AttributesChangeRequest":
|
|
62
|
-
if (content instanceof Array) {
|
|
63
|
-
return await this.expandAttributesChangeRequests(content);
|
|
64
|
-
}
|
|
65
|
-
return await this.expandAttributesChangeRequest(content);
|
|
66
55
|
case "Attribute":
|
|
67
56
|
if (content instanceof Array) {
|
|
68
57
|
return await this.expandAttributes(content);
|
|
69
58
|
}
|
|
70
|
-
return this.expandAttribute(content);
|
|
71
|
-
case "AttributeName":
|
|
72
|
-
if (content instanceof Array) {
|
|
73
|
-
return await this.expandAttributeNames(content);
|
|
74
|
-
}
|
|
75
|
-
return await this.expandAttributeName(content);
|
|
59
|
+
return await this.expandAttribute(content);
|
|
76
60
|
case "Address":
|
|
77
61
|
if (content instanceof Array) {
|
|
78
62
|
return await this.expandAddresses(content);
|
|
@@ -102,7 +86,7 @@ let DataViewExpander = class DataViewExpander {
|
|
|
102
86
|
if (content instanceof Array) {
|
|
103
87
|
return await this.expandConsumptionAttributes(content);
|
|
104
88
|
}
|
|
105
|
-
return this.expandConsumptionAttribute(content);
|
|
89
|
+
return await this.expandConsumptionAttribute(content);
|
|
106
90
|
default:
|
|
107
91
|
throw useCases_1.RuntimeErrors.general.notImplemented();
|
|
108
92
|
}
|
|
@@ -180,7 +164,7 @@ let DataViewExpander = class DataViewExpander {
|
|
|
180
164
|
...mailDVO,
|
|
181
165
|
type: "RequestMailDVO",
|
|
182
166
|
name: requestMailContent.subject ? requestMailContent.subject : DataViewTranslateable_1.DataViewTranslateable.consumption.mails.requestMailSubjectFallback,
|
|
183
|
-
requests:
|
|
167
|
+
requests: [],
|
|
184
168
|
requestCount: requestMailContent.requests.length
|
|
185
169
|
};
|
|
186
170
|
return requestMailDVO;
|
|
@@ -193,211 +177,184 @@ let DataViewExpander = class DataViewExpander {
|
|
|
193
177
|
const messagePromises = messages.map((message) => this.expandMessageDTO(message));
|
|
194
178
|
return await Promise.all(messagePromises);
|
|
195
179
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
case "AttributesRequest":
|
|
199
|
-
return await this.expandAttributesRequest(request);
|
|
200
|
-
case "AttributesShareRequest":
|
|
201
|
-
return await this.expandAttributesShareRequest(request);
|
|
202
|
-
case "AttributesChangeRequest":
|
|
203
|
-
return await this.expandAttributesChangeRequest(request);
|
|
204
|
-
}
|
|
180
|
+
expandRequest(request) {
|
|
181
|
+
const id = request.id ? request.id : "";
|
|
205
182
|
return {
|
|
206
|
-
id:
|
|
207
|
-
name: `${request["@type"]} ${
|
|
208
|
-
description: "i18n://dvo.request.unknownType",
|
|
183
|
+
id: id,
|
|
184
|
+
name: `${request["@type"]} ${id}`,
|
|
209
185
|
type: "RequestDVO",
|
|
210
186
|
date: request.expiresAt,
|
|
211
187
|
...request
|
|
212
188
|
};
|
|
213
189
|
}
|
|
214
|
-
|
|
190
|
+
async expandConsumptionRequest(request) {
|
|
215
191
|
return {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
192
|
+
...request,
|
|
193
|
+
id: request.id,
|
|
194
|
+
name: "i18n://dvo.request.name.response",
|
|
195
|
+
type: "ConsumptionRequestDVO",
|
|
196
|
+
date: request.createdAt,
|
|
197
|
+
peer: await this.expandAddress(request.peer),
|
|
198
|
+
response: request.response ? this.expandConsumptionResponse(request.response) : undefined
|
|
221
199
|
};
|
|
222
200
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
201
|
+
expandConsumptionResponse(response) {
|
|
202
|
+
return {
|
|
203
|
+
...response,
|
|
204
|
+
id: "",
|
|
205
|
+
name: "i18n://dvo.request.name.response",
|
|
206
|
+
type: "ConsumptionResponseDVO",
|
|
207
|
+
date: response.createdAt
|
|
208
|
+
};
|
|
226
209
|
}
|
|
227
|
-
async
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
210
|
+
async expandConsumptionAttribute(attribute) {
|
|
211
|
+
const valueType = attribute.content.value["@type"];
|
|
212
|
+
const consumptionAttribute = await this.consumptionController.attributes.getConsumptionAttribute(transport_1.CoreId.from(attribute.id));
|
|
213
|
+
if (!consumptionAttribute) {
|
|
214
|
+
throw new Error("Attribute not found");
|
|
215
|
+
}
|
|
216
|
+
const owner = await this.expandAddress(attribute.content.owner);
|
|
217
|
+
let name = `i18n://dvo.attribute.name.${valueType}`;
|
|
218
|
+
let description = `i18n://dvo.attribute.description.${valueType}`;
|
|
219
|
+
if (consumptionAttribute.content instanceof content_1.RelationshipAttribute) {
|
|
220
|
+
name = "";
|
|
221
|
+
description = "";
|
|
222
|
+
}
|
|
223
|
+
const renderHints = consumptionAttribute.content.value.renderHints.toJSON();
|
|
224
|
+
const valueHints = consumptionAttribute.content.value.valueHints.toJSON();
|
|
225
|
+
if (consumptionAttribute.shareInfo) {
|
|
226
|
+
const peer = await this.expandAddress(consumptionAttribute.shareInfo.peer.toString());
|
|
227
|
+
if (consumptionAttribute.shareInfo.sourceAttribute) {
|
|
228
|
+
// Own Shared Attribute
|
|
229
|
+
return {
|
|
230
|
+
type: "SharedToPeerAttributeDVO",
|
|
231
|
+
id: attribute.id,
|
|
232
|
+
name,
|
|
233
|
+
description,
|
|
234
|
+
content: attribute.content,
|
|
235
|
+
value: attribute.content.value,
|
|
236
|
+
date: attribute.createdAt,
|
|
237
|
+
owner: owner,
|
|
238
|
+
renderHints,
|
|
239
|
+
valueHints,
|
|
240
|
+
isValid: true,
|
|
241
|
+
createdAt: attribute.createdAt,
|
|
242
|
+
isOwn: true,
|
|
243
|
+
peer: peer,
|
|
244
|
+
requestReference: consumptionAttribute.shareInfo.requestReference.toString(),
|
|
245
|
+
sourceAttribute: consumptionAttribute.shareInfo.sourceAttribute.toString()
|
|
246
|
+
};
|
|
239
247
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
// Peer Attribute
|
|
249
|
+
return {
|
|
250
|
+
type: "PeerAttributeDVO",
|
|
251
|
+
id: attribute.id,
|
|
252
|
+
name,
|
|
253
|
+
description,
|
|
254
|
+
content: attribute.content,
|
|
255
|
+
value: attribute.content.value,
|
|
256
|
+
date: attribute.createdAt,
|
|
257
|
+
owner: owner,
|
|
258
|
+
renderHints,
|
|
259
|
+
valueHints,
|
|
260
|
+
isValid: true,
|
|
261
|
+
createdAt: attribute.createdAt,
|
|
262
|
+
isOwn: false,
|
|
263
|
+
peer: peer,
|
|
264
|
+
requestReference: consumptionAttribute.shareInfo.requestReference.toString()
|
|
246
265
|
};
|
|
247
|
-
if (!request.errors) {
|
|
248
|
-
request.errors = [];
|
|
249
|
-
}
|
|
250
|
-
request.errors.push(error);
|
|
251
266
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
code: "warning.dvo.request.AttributeShareRequest.onlyRelationships",
|
|
256
|
-
message: "Not to every recipient of this request exist a relationship."
|
|
257
|
-
};
|
|
258
|
-
if (!request.warnings) {
|
|
259
|
-
request.warnings = [];
|
|
260
|
-
}
|
|
261
|
-
request.warnings.push(warning);
|
|
262
|
-
}
|
|
263
|
-
const attributesObjects = [];
|
|
264
|
-
for (const attributeName of attributesShareRequest.attributes) {
|
|
265
|
-
const attributeDVO = await this.expandAttributeName(attributeName);
|
|
266
|
-
attributesObjects.push(attributeDVO);
|
|
267
|
-
}
|
|
268
|
-
let name;
|
|
269
|
-
if (attributesObjects.length > 1) {
|
|
270
|
-
name = DataViewTranslateable_1.DataViewTranslateable.consumption.requests.attributesShareRequestNamePlural;
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
name = DataViewTranslateable_1.DataViewTranslateable.consumption.requests.attributesShareRequestName;
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
...request,
|
|
277
|
-
name,
|
|
278
|
-
type: "AttributesShareRequestDVO",
|
|
279
|
-
attributes: attributesObjects,
|
|
280
|
-
attributeCount: attributesObjects.length,
|
|
281
|
-
recipients: recipientObjects,
|
|
282
|
-
recipientCount: recipientObjects.length,
|
|
283
|
-
possibleRecipientCount
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
expandConsumptionAttribute(attribute) {
|
|
267
|
+
const sharedToPeerAttributes = await this.consumption.attributes.getAttributes({ query: { shareInfo: { sourceAttribute: attribute.id } } });
|
|
268
|
+
const sharedToPeerDVOs = await this.expandConsumptionAttributes(sharedToPeerAttributes.value);
|
|
269
|
+
// Own Source Attribute
|
|
287
270
|
return {
|
|
288
|
-
type: "
|
|
271
|
+
type: "RepositoryAttributeDVO",
|
|
289
272
|
id: attribute.id,
|
|
290
|
-
name
|
|
273
|
+
name,
|
|
274
|
+
description,
|
|
275
|
+
content: attribute.content,
|
|
291
276
|
value: attribute.content.value,
|
|
292
277
|
date: attribute.createdAt,
|
|
278
|
+
owner: owner,
|
|
279
|
+
renderHints,
|
|
280
|
+
valueHints,
|
|
281
|
+
isValid: true,
|
|
282
|
+
createdAt: attribute.createdAt,
|
|
293
283
|
isOwn: true,
|
|
294
|
-
|
|
295
|
-
sharedItemCount: 0
|
|
284
|
+
sharedWith: sharedToPeerDVOs
|
|
296
285
|
};
|
|
297
286
|
}
|
|
298
287
|
async expandConsumptionAttributes(attributes) {
|
|
299
288
|
const attributesPromise = attributes.map((attribute) => this.expandConsumptionAttribute(attribute));
|
|
300
289
|
return await Promise.all(attributesPromise);
|
|
301
290
|
}
|
|
302
|
-
async
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
291
|
+
async expandIdentityAttributeQuery(query) {
|
|
292
|
+
const queryInstance = content_1.IdentityAttributeQuery.from(query);
|
|
293
|
+
const matchedAttributes = await this.consumptionController.attributes.executeIdentityAttributeQuery({ query: queryInstance });
|
|
294
|
+
const matchedAttributeDTOs = useCases_1.AttributeMapper.toAttributeDTOList(matchedAttributes);
|
|
295
|
+
const matchedAttributeDVOs = await this.expandConsumptionAttributes(matchedAttributeDTOs);
|
|
296
|
+
const valueType = query.valueType;
|
|
297
|
+
const name = `i18n://dvo.attribute.name.${valueType}`;
|
|
298
|
+
const description = `i18n://dvo.attribute.description.${valueType}`;
|
|
299
|
+
const valueTypeClass = ts_serval_1.SerializableBase.getModule(valueType, 1);
|
|
300
|
+
if (!valueTypeClass) {
|
|
301
|
+
throw new Error(`No class implementation found for ${valueType}`);
|
|
302
|
+
}
|
|
303
|
+
let renderHints = {
|
|
304
|
+
"@type": "RenderHints",
|
|
305
|
+
editType: content_1.RenderHintsEditType.InputLike,
|
|
306
|
+
technicalType: content_1.RenderHintsTechnicalType.String
|
|
307
|
+
};
|
|
308
|
+
let valueHints = {
|
|
309
|
+
"@type": "ValueHints",
|
|
310
|
+
max: 200
|
|
311
|
+
};
|
|
312
|
+
if (valueTypeClass.renderHints && valueTypeClass.renderHints instanceof content_1.RenderHints) {
|
|
313
|
+
renderHints = valueTypeClass.renderHints.toJSON();
|
|
307
314
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
bestMatch = matchedAttributes[0];
|
|
315
|
+
if (valueTypeClass.valueHints && valueTypeClass.valueHints instanceof content_1.ValueHints) {
|
|
316
|
+
valueHints = valueTypeClass.valueHints.toJSON();
|
|
311
317
|
}
|
|
312
318
|
return {
|
|
313
|
-
type: "
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
type: "IdentityAttributeQueryExpanded",
|
|
320
|
+
name,
|
|
321
|
+
description,
|
|
322
|
+
valueType,
|
|
323
|
+
validFrom: query.validFrom,
|
|
324
|
+
validTo: query.validTo,
|
|
325
|
+
results: matchedAttributeDVOs,
|
|
326
|
+
renderHints,
|
|
327
|
+
valueHints
|
|
319
328
|
};
|
|
320
329
|
}
|
|
321
|
-
async
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
330
|
+
async expandAttribute(attribute) {
|
|
331
|
+
const attributeInstance = ts_serval_1.Serializable.fromAny(attribute);
|
|
332
|
+
const valueType = attribute.value["@type"];
|
|
333
|
+
let name = `i18n://dvo.attribute.name.${valueType}`;
|
|
334
|
+
let description = `i18n://dvo.attribute.description.${valueType}`;
|
|
335
|
+
const renderHints = attributeInstance.value.renderHints.toJSON();
|
|
336
|
+
const valueHints = attributeInstance.value.valueHints.toJSON();
|
|
337
|
+
if (attributeInstance instanceof content_1.RelationshipAttribute) {
|
|
338
|
+
name = ""; // attributeInstance.value.title;
|
|
339
|
+
description = ""; // attributeInstance.value.description;
|
|
340
|
+
}
|
|
341
|
+
const owner = await this.expandAddress(attribute.owner);
|
|
326
342
|
return {
|
|
327
|
-
type: "
|
|
328
|
-
|
|
329
|
-
name
|
|
330
|
-
|
|
331
|
-
|
|
343
|
+
type: "DraftAttributeDVO",
|
|
344
|
+
content: attribute,
|
|
345
|
+
name,
|
|
346
|
+
description,
|
|
347
|
+
id: "",
|
|
348
|
+
owner: owner,
|
|
349
|
+
renderHints,
|
|
350
|
+
valueHints,
|
|
351
|
+
value: attribute.value
|
|
332
352
|
};
|
|
333
353
|
}
|
|
334
354
|
async expandAttributes(attributes) {
|
|
335
355
|
const attributesPromise = attributes.map((attribute) => this.expandAttribute(attribute));
|
|
336
356
|
return await Promise.all(attributesPromise);
|
|
337
357
|
}
|
|
338
|
-
async expandAttributesChangeRequest(attributesChangeRequest) {
|
|
339
|
-
const request = this.expandRequest(attributesChangeRequest);
|
|
340
|
-
let applyToObject;
|
|
341
|
-
if (attributesChangeRequest.applyTo) {
|
|
342
|
-
applyToObject = await this.expandIdentityForAddress(attributesChangeRequest.applyTo);
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
applyToObject = this.expandSelf();
|
|
346
|
-
}
|
|
347
|
-
let name;
|
|
348
|
-
const attributesObjects = [];
|
|
349
|
-
for (const attribute of attributesChangeRequest.attributes) {
|
|
350
|
-
const attributeDVO = this.expandAttribute(attribute);
|
|
351
|
-
attributesObjects.push(attributeDVO);
|
|
352
|
-
}
|
|
353
|
-
const oldAttributesObjects = await this.expandAttributeNames(attributesObjects.map((item) => item.id));
|
|
354
|
-
if (attributesObjects.length > 1) {
|
|
355
|
-
name = DataViewTranslateable_1.DataViewTranslateable.consumption.requests.attributesChangeRequestNamePlural;
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
name = DataViewTranslateable_1.DataViewTranslateable.consumption.requests.attributesChangeRequestName;
|
|
359
|
-
}
|
|
360
|
-
const changes = [];
|
|
361
|
-
attributesObjects.forEach((attribute, index) => {
|
|
362
|
-
changes.push({
|
|
363
|
-
oldAttribute: oldAttributesObjects[index],
|
|
364
|
-
newAttribute: attribute
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
return {
|
|
368
|
-
...request,
|
|
369
|
-
type: "AttributesChangeRequestDVO",
|
|
370
|
-
name: name,
|
|
371
|
-
newAttributes: attributesObjects,
|
|
372
|
-
newAttributeCount: attributesObjects.length,
|
|
373
|
-
oldAttributes: oldAttributesObjects,
|
|
374
|
-
oldAttributeCount: oldAttributesObjects.length,
|
|
375
|
-
applyTo: applyToObject,
|
|
376
|
-
changes: changes,
|
|
377
|
-
changeCount: changes.length
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
async expandAttributesRequest(attributesRequest) {
|
|
381
|
-
const request = this.expandRequest(attributesRequest);
|
|
382
|
-
let name;
|
|
383
|
-
const attributesObjects = await this.expandAttributeNames(attributesRequest.names);
|
|
384
|
-
if (attributesObjects.length > 1) {
|
|
385
|
-
name = DataViewTranslateable_1.DataViewTranslateable.consumption.requests.attributesChangeRequestNamePlural;
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
name = DataViewTranslateable_1.DataViewTranslateable.consumption.requests.attributesChangeRequestName;
|
|
389
|
-
}
|
|
390
|
-
return {
|
|
391
|
-
...request,
|
|
392
|
-
type: "AttributesRequestDVO",
|
|
393
|
-
names: attributesRequest.names,
|
|
394
|
-
nameCount: attributesRequest.names.length,
|
|
395
|
-
name: name,
|
|
396
|
-
attributes: attributesObjects,
|
|
397
|
-
attributeCount: attributesObjects.length,
|
|
398
|
-
required: attributesRequest.required
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
358
|
expandSelf() {
|
|
402
359
|
const name = "i18n://dvo.identity.self.name";
|
|
403
360
|
const initials = "i18n://dvo.identity.self.initials";
|
|
@@ -416,7 +373,7 @@ let DataViewExpander = class DataViewExpander {
|
|
|
416
373
|
const name = address.substring(3, 9);
|
|
417
374
|
const initials = (name.match(/\b\w/g) ?? []).join("");
|
|
418
375
|
return {
|
|
419
|
-
id:
|
|
376
|
+
id: address,
|
|
420
377
|
type: "IdentityDVO",
|
|
421
378
|
name: name,
|
|
422
379
|
initials: initials,
|
|
@@ -426,14 +383,6 @@ let DataViewExpander = class DataViewExpander {
|
|
|
426
383
|
hasRelationship: false
|
|
427
384
|
};
|
|
428
385
|
}
|
|
429
|
-
async expandAttributesShareRequests(requests) {
|
|
430
|
-
const requestsPromise = requests.map((request) => this.expandAttributesShareRequest(request));
|
|
431
|
-
return await Promise.all(requestsPromise);
|
|
432
|
-
}
|
|
433
|
-
async expandAttributesChangeRequests(requests) {
|
|
434
|
-
const requestsPromise = requests.map((request) => this.expandAttributesChangeRequest(request));
|
|
435
|
-
return await Promise.all(requestsPromise);
|
|
436
|
-
}
|
|
437
386
|
async expandAddress(address) {
|
|
438
387
|
if (this.identityController.isMe(transport_1.CoreAddress.from(address))) {
|
|
439
388
|
return this.expandSelf();
|
|
@@ -553,14 +502,16 @@ let DataViewExpander = class DataViewExpander {
|
|
|
553
502
|
// const relationshipInfo = relationshipInfoResult.value;
|
|
554
503
|
// const name = relationshipInfo.userTitle ? relationshipInfo.userTitle : relationshipInfo.title;
|
|
555
504
|
// let description = relationshipInfo.userDescription ? relationshipInfo.userDescription : relationshipInfo.description;
|
|
556
|
-
const name =
|
|
557
|
-
const description = "";
|
|
505
|
+
const name = relationship.peer.substring(3, 9);
|
|
558
506
|
const initials = (name.match(/\b\w/g) ?? []).join("");
|
|
559
507
|
const relationshipDVO = await this.createRelationshipDVO(relationship);
|
|
508
|
+
const description = relationshipDVO.statusText;
|
|
560
509
|
// TODO: re-enable when we can query relationship info
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
510
|
+
/*
|
|
511
|
+
if (!description) {
|
|
512
|
+
description = relationshipDVO.statusText;
|
|
513
|
+
}
|
|
514
|
+
*/
|
|
564
515
|
return {
|
|
565
516
|
type: "IdentityDVO",
|
|
566
517
|
id: relationship.peer,
|
|
@@ -643,8 +594,10 @@ DataViewExpander = __decorate([
|
|
|
643
594
|
__param(0, typescript_ioc_1.Inject),
|
|
644
595
|
__param(1, typescript_ioc_1.Inject),
|
|
645
596
|
__param(2, typescript_ioc_1.Inject),
|
|
597
|
+
__param(3, typescript_ioc_1.Inject),
|
|
646
598
|
__metadata("design:paramtypes", [extensibility_1.TransportServices,
|
|
647
599
|
ConsumptionServices_1.ConsumptionServices,
|
|
600
|
+
consumption_1.ConsumptionController,
|
|
648
601
|
transport_1.IdentityController])
|
|
649
602
|
], DataViewExpander);
|
|
650
603
|
exports.DataViewExpander = DataViewExpander;
|