Skip to content

Commit 17e97e8

Browse files
authored
AttributeDVOs are to hard to consume by the app (#821)
* fix: make forwardingPeers and forwardingDetails required * test: adapt tests * chore: adapt more tests
1 parent 28182f7 commit 17e97e8

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

packages/runtime/src/dataViews/DataViewExpander.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,17 +1150,17 @@ export class DataViewExpander {
11501150
return await Promise.all(attributesPromise);
11511151
}
11521152

1153-
private async expandForwardingPeers(forwardingDetails: LocalAttributeForwardingDetailsDTO[]): Promise<IdentityDVO[] | undefined> {
1154-
if (forwardingDetails.length === 0) return;
1153+
private async expandForwardingPeers(forwardingDetails: LocalAttributeForwardingDetailsDTO[]): Promise<IdentityDVO[]> {
1154+
if (forwardingDetails.length === 0) return [];
11551155

11561156
const addresses = [...new Set(forwardingDetails.map((detail) => detail.peer.toString()))];
11571157
const promises = addresses.map((address) => this.expandAddress(address));
11581158

11591159
return await Promise.all(promises);
11601160
}
11611161

1162-
private expandForwardingDetails(forwardingDetails: LocalAttributeForwardingDetailsDTO[]): ForwardingDetailsDVO[] | undefined {
1163-
if (forwardingDetails.length === 0) return;
1162+
private expandForwardingDetails(forwardingDetails: LocalAttributeForwardingDetailsDTO[]): ForwardingDetailsDVO[] {
1163+
if (forwardingDetails.length === 0) return [];
11641164

11651165
return forwardingDetails.map((details) => {
11661166
const result: ForwardingDetailsDVO = {

packages/runtime/src/dataViews/consumption/LocalAttributeDVO.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export interface OwnIdentityAttributeDVO extends LocalAttributeDVO {
3131
isOwn: true;
3232
tags?: string[];
3333
isDefault?: true;
34-
forwardingPeers?: IdentityDVO[];
35-
forwardingDetails?: ForwardingDetailsDVO[];
34+
forwardingPeers: IdentityDVO[];
35+
forwardingDetails: ForwardingDetailsDVO[];
3636
}
3737

3838
export interface PeerIdentityAttributeDVO extends LocalAttributeDVO {
@@ -55,8 +55,8 @@ export interface OwnRelationshipAttributeDVO extends LocalAttributeDVO {
5555
sourceReference?: string;
5656
deletionDate?: string;
5757
deletionStatus?: string;
58-
forwardingPeers?: IdentityDVO[];
59-
forwardingDetails?: ForwardingDetailsDVO[];
58+
forwardingPeers: IdentityDVO[];
59+
forwardingDetails: ForwardingDetailsDVO[];
6060
}
6161

6262
export interface PeerRelationshipAttributeDVO extends LocalAttributeDVO {
@@ -69,8 +69,8 @@ export interface PeerRelationshipAttributeDVO extends LocalAttributeDVO {
6969
sourceReference?: string;
7070
deletionDate?: string;
7171
deletionStatus?: string;
72-
forwardingPeers?: IdentityDVO[];
73-
forwardingDetails?: ForwardingDetailsDVO[];
72+
forwardingPeers: IdentityDVO[];
73+
forwardingDetails: ForwardingDetailsDVO[];
7474
}
7575

7676
export interface ThirdPartyRelationshipAttributeDVO extends LocalAttributeDVO {

packages/runtime/test/dataViews/IQLQueryExpanded.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ describe("IQLQueryExpanded", () => {
104104
expect(dvo.tags![0]).toBe("x:default");
105105
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
106106
expect(dvo.isOwn).toBe(true);
107-
expect(dvo.forwardingPeers).toBeUndefined();
108-
expect(dvo.forwardingDetails).toBeUndefined();
107+
expect(dvo.forwardingPeers).toStrictEqual([]);
108+
expect(dvo.forwardingDetails).toStrictEqual([]);
109109
expect(dvo.owner).toStrictEqual(attribute.content.owner);
110110
expect(dvo.renderHints["@type"]).toBe("RenderHints");
111111
expect(dvo.renderHints.technicalType).toBe("String");
@@ -127,8 +127,8 @@ describe("IQLQueryExpanded", () => {
127127
expect(value.value).toBe("anotherGivenName");
128128
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
129129
expect(dvo.isOwn).toBe(true);
130-
expect(dvo.forwardingPeers).toBeUndefined();
131-
expect(dvo.forwardingDetails).toBeUndefined();
130+
expect(dvo.forwardingPeers).toStrictEqual([]);
131+
expect(dvo.forwardingDetails).toStrictEqual([]);
132132
expect(dvo.owner).toStrictEqual(attribute.content.owner);
133133
expect(dvo.renderHints["@type"]).toBe("RenderHints");
134134
expect(dvo.renderHints.technicalType).toBe("String");
@@ -151,8 +151,8 @@ describe("IQLQueryExpanded", () => {
151151
expect(dvo.tags![0]).toBe("x:fake");
152152
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
153153
expect(dvo.isOwn).toBe(true);
154-
expect(dvo.forwardingPeers).toBeUndefined();
155-
expect(dvo.forwardingDetails).toBeUndefined();
154+
expect(dvo.forwardingPeers).toStrictEqual([]);
155+
expect(dvo.forwardingDetails).toStrictEqual([]);
156156
expect(dvo.owner).toStrictEqual(attribute.content.owner);
157157
expect(dvo.renderHints["@type"]).toBe("RenderHints");
158158
expect(dvo.renderHints.technicalType).toBe("String");
@@ -194,8 +194,8 @@ describe("IQLQueryExpanded", () => {
194194
expect(dvo.tags![0]).toBe("x:default");
195195
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
196196
expect(dvo.isOwn).toBe(true);
197-
expect(dvo.forwardingPeers).toBeUndefined();
198-
expect(dvo.forwardingDetails).toBeUndefined();
197+
expect(dvo.forwardingPeers).toStrictEqual([]);
198+
expect(dvo.forwardingDetails).toStrictEqual([]);
199199
expect(dvo.owner).toStrictEqual(attribute.content.owner);
200200
expect(dvo.renderHints["@type"]).toBe("RenderHints");
201201
expect(dvo.renderHints.technicalType).toBe("String");
@@ -237,8 +237,8 @@ describe("IQLQueryExpanded", () => {
237237
expect(dvo.tags![0]).toBe("x:fake");
238238
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
239239
expect(dvo.isOwn).toBe(true);
240-
expect(dvo.forwardingPeers).toBeUndefined();
241-
expect(dvo.forwardingDetails).toBeUndefined();
240+
expect(dvo.forwardingPeers).toStrictEqual([]);
241+
expect(dvo.forwardingDetails).toStrictEqual([]);
242242
expect(dvo.owner).toStrictEqual(attribute.content.owner);
243243
expect(dvo.renderHints["@type"]).toBe("RenderHints");
244244
expect(dvo.renderHints.technicalType).toBe("String");
@@ -277,8 +277,8 @@ describe("IQLQueryExpanded", () => {
277277
expect(dvo.tags![0]).toBe("x:fake");
278278
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
279279
expect(dvo.isOwn).toBe(true);
280-
expect(dvo.forwardingPeers).toBeUndefined();
281-
expect(dvo.forwardingDetails).toBeUndefined();
280+
expect(dvo.forwardingPeers).toStrictEqual([]);
281+
expect(dvo.forwardingDetails).toStrictEqual([]);
282282
expect(dvo.owner).toStrictEqual(attribute.content.owner);
283283
expect(dvo.renderHints["@type"]).toBe("RenderHints");
284284
expect(dvo.renderHints.technicalType).toBe("String");
@@ -301,8 +301,8 @@ describe("IQLQueryExpanded", () => {
301301
expect(dvo.tags![0]).toBe("x:fake");
302302
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
303303
expect(dvo.isOwn).toBe(true);
304-
expect(dvo.forwardingPeers).toBeUndefined();
305-
expect(dvo.forwardingDetails).toBeUndefined();
304+
expect(dvo.forwardingPeers).toStrictEqual([]);
305+
expect(dvo.forwardingDetails).toStrictEqual([]);
306306
expect(dvo.owner).toStrictEqual(attribute.content.owner);
307307
expect(dvo.renderHints["@type"]).toBe("RenderHints");
308308
expect(dvo.renderHints.technicalType).toBe("String");

packages/runtime/test/dataViews/IdentityAttributeQueryExpanded.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ describe("IdentityAttributeQueryExpanded", () => {
8484
expect(dvo.isDefault).toBe(true);
8585
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
8686
expect(dvo.isOwn).toBe(true);
87-
expect(dvo.forwardingPeers).toBeUndefined();
88-
expect(dvo.forwardingDetails).toBeUndefined();
87+
expect(dvo.forwardingPeers).toStrictEqual([]);
88+
expect(dvo.forwardingDetails).toStrictEqual([]);
8989
expect(dvo.owner).toStrictEqual(attribute.content.owner);
9090
expect(dvo.renderHints["@type"]).toBe("RenderHints");
9191
expect(dvo.renderHints.technicalType).toBe("String");
@@ -109,8 +109,8 @@ describe("IdentityAttributeQueryExpanded", () => {
109109
expect(dvo.isDefault).toBeUndefined();
110110
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
111111
expect(dvo.isOwn).toBe(true);
112-
expect(dvo.forwardingPeers).toBeUndefined();
113-
expect(dvo.forwardingDetails).toBeUndefined();
112+
expect(dvo.forwardingPeers).toStrictEqual([]);
113+
expect(dvo.forwardingDetails).toStrictEqual([]);
114114
expect(dvo.owner).toStrictEqual(attribute.content.owner);
115115
expect(dvo.renderHints["@type"]).toBe("RenderHints");
116116
expect(dvo.renderHints.technicalType).toBe("String");

packages/runtime/test/dataViews/OwnIdentityAttributeDVO.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ describe("OwnIdentityAttributeDVO", () => {
7777
expect(value.value).toBe("aGivenName");
7878
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
7979
expect(dvo.isOwn).toBe(true);
80-
expect(dvo.forwardingPeers).toBeUndefined();
81-
expect(dvo.forwardingDetails).toBeUndefined();
80+
expect(dvo.forwardingPeers).toStrictEqual([]);
81+
expect(dvo.forwardingDetails).toStrictEqual([]);
8282
expect(dvo.owner).toStrictEqual(attribute.content.owner);
8383
expect(dvo.renderHints["@type"]).toBe("RenderHints");
8484
expect(dvo.renderHints.technicalType).toBe("String");
@@ -104,8 +104,8 @@ describe("OwnIdentityAttributeDVO", () => {
104104
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
105105
expect(dvo.isOwn).toBe(true);
106106
expect(dvo.isDefault).toBe(attribute.isDefault);
107-
expect(dvo.forwardingPeers).toBeUndefined();
108-
expect(dvo.forwardingDetails).toBeUndefined();
107+
expect(dvo.forwardingPeers).toStrictEqual([]);
108+
expect(dvo.forwardingDetails).toStrictEqual([]);
109109
expect(dvo.owner).toStrictEqual(attribute.content.owner);
110110
expect(dvo.renderHints["@type"]).toBe("RenderHints");
111111
expect(dvo.renderHints.technicalType).toBe("String");
@@ -131,8 +131,8 @@ describe("OwnIdentityAttributeDVO", () => {
131131
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
132132
expect(dvo.isOwn).toBe(true);
133133
expect(dvo.isDefault).toBe(attribute.isDefault);
134-
expect(dvo.forwardingPeers).toBeUndefined();
135-
expect(dvo.forwardingDetails).toBeUndefined();
134+
expect(dvo.forwardingPeers).toStrictEqual([]);
135+
expect(dvo.forwardingDetails).toStrictEqual([]);
136136
expect(dvo.owner).toStrictEqual(attribute.content.owner);
137137
expect(dvo.renderHints["@type"]).toBe("RenderHints");
138138
expect(dvo.renderHints.technicalType).toBe("String");
@@ -163,8 +163,8 @@ describe("OwnIdentityAttributeDVO", () => {
163163
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
164164
expect(dvo.isOwn).toBe(true);
165165
expect(dvo.isDefault).toBe(attribute.isDefault);
166-
expect(dvo.forwardingPeers).toBeUndefined();
167-
expect(dvo.forwardingDetails).toBeUndefined();
166+
expect(dvo.forwardingPeers).toStrictEqual([]);
167+
expect(dvo.forwardingDetails).toStrictEqual([]);
168168
expect(dvo.owner).toStrictEqual(attribute.content.owner);
169169
expect(dvo.renderHints["@type"]).toBe("RenderHints");
170170
expect(dvo.renderHints.technicalType).toBe("String");
@@ -197,7 +197,7 @@ describe("OwnIdentityAttributeDVO", () => {
197197
expect(dvo.createdAt).toStrictEqual(attribute.createdAt);
198198
expect(dvo.isOwn).toBe(true);
199199
expect(dvo.isDefault).toBe(attribute.isDefault);
200-
expect(dvo.forwardingPeers![0].id).toStrictEqual(services2.address);
200+
expect(dvo.forwardingPeers[0].id).toStrictEqual(services2.address);
201201
expect(dvo.forwardingDetails).toStrictEqual([
202202
{
203203
peer: services2.address,

packages/runtime/test/dataViews/OwnRelationshipAttributeDVO.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ describe("OwnRelationshipAttributeDVO", () => {
7272
expect(dvo.sourceReference).toBe(ownRelationshipAttribute.sourceReference);
7373
expect(dvo.deletionStatus).toBe(ownRelationshipAttribute.deletionInfo?.deletionStatus);
7474
expect(dvo.deletionDate).toBe(ownRelationshipAttribute.deletionInfo?.deletionDate);
75-
expect(dvo.forwardingPeers).toBeUndefined();
76-
expect(dvo.forwardingDetails).toBeUndefined();
75+
expect(dvo.forwardingPeers).toStrictEqual([]);
76+
expect(dvo.forwardingDetails).toStrictEqual([]);
7777
expect(dvo.valueType).toBe(ownRelationshipAttribute.content.value["@type"]);
7878
expect(dvo.wasViewedAt).toBeUndefined();
7979
});
@@ -134,7 +134,7 @@ describe("OwnRelationshipAttributeDVO", () => {
134134
expect(dvo.sourceReference).toBe(ownRelationshipAttribute.sourceReference);
135135
expect(dvo.deletionStatus).toBe(ownRelationshipAttribute.deletionInfo?.deletionStatus);
136136
expect(dvo.deletionDate).toBe(ownRelationshipAttribute.deletionInfo?.deletionDate);
137-
expect(dvo.forwardingPeers![0].id).toStrictEqual(services3.address);
137+
expect(dvo.forwardingPeers[0].id).toStrictEqual(services3.address);
138138
expect(dvo.forwardingDetails).toStrictEqual([
139139
{
140140
peer: services3.address,

packages/runtime/test/dataViews/PeerRelationshipAttributeDVO.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ describe("PeerRelationshipAttributeDVO", () => {
7373
expect(dvo.sourceReference).toBe(peerRelationshipAttribute.sourceReference);
7474
expect(dvo.deletionStatus).toBe(peerRelationshipAttribute.deletionInfo?.deletionStatus);
7575
expect(dvo.deletionDate).toBe(peerRelationshipAttribute.deletionInfo?.deletionDate);
76-
expect(dvo.forwardingPeers).toBeUndefined();
77-
expect(dvo.forwardingDetails).toBeUndefined();
76+
expect(dvo.forwardingPeers).toStrictEqual([]);
77+
expect(dvo.forwardingDetails).toStrictEqual([]);
7878
expect(dvo.valueType).toBe(peerRelationshipAttribute.content.value["@type"]);
7979
expect(dvo.wasViewedAt).toBeUndefined();
8080
});
@@ -136,7 +136,7 @@ describe("PeerRelationshipAttributeDVO", () => {
136136
expect(dvo.sourceReference).toBe(peerRelationshipAttribute.sourceReference);
137137
expect(dvo.deletionStatus).toBe(peerRelationshipAttribute.deletionInfo?.deletionStatus);
138138
expect(dvo.deletionDate).toBe(peerRelationshipAttribute.deletionInfo?.deletionDate);
139-
expect(dvo.forwardingPeers![0].id).toStrictEqual(services3.address);
139+
expect(dvo.forwardingPeers[0].id).toStrictEqual(services3.address);
140140
expect(dvo.forwardingDetails).toStrictEqual([
141141
{
142142
peer: services3.address,

0 commit comments

Comments
 (0)