@startinblox/components-ds4go 4.1.0 → 4.1.2
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/index.js +376 -350
- package/package.json +1 -1
- package/src/components/solid-dsp-connector.ts +13 -0
- package/src/components/solid-fact-list.ts +30 -10
package/package.json
CHANGED
|
@@ -77,6 +77,19 @@ export class SolidDspConnector extends OrbitDSPComponent {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
public async getAsset(assetId: string): Promise<Asset | undefined> {
|
|
81
|
+
if (!this.storeService) {
|
|
82
|
+
console.error("Store not initialized. Check connector configuration.");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
return await this.storeService.getAsset(assetId);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error("Failed to get asset:", e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
80
93
|
public async createAsset(assetData: AssetInput) {
|
|
81
94
|
if (!this.storeService) return false;
|
|
82
95
|
|
|
@@ -74,6 +74,8 @@ export class SolidFactList extends OrbitComponent {
|
|
|
74
74
|
return Promise.resolve();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
assetData: Asset[] = [];
|
|
78
|
+
|
|
77
79
|
_getResource = new Task(this, {
|
|
78
80
|
task: async ([objSrc]) => {
|
|
79
81
|
if (
|
|
@@ -95,10 +97,6 @@ export class SolidFactList extends OrbitComponent {
|
|
|
95
97
|
if (participantId) {
|
|
96
98
|
// Load agreements for all negotiations to find consumer/provider relationships
|
|
97
99
|
const allNegotiations = this.dspConnector.instance.negotiations || [];
|
|
98
|
-
const negotiationToAgreementMap = new Map<
|
|
99
|
-
string,
|
|
100
|
-
ContractAgreement
|
|
101
|
-
>();
|
|
102
100
|
|
|
103
101
|
const allAgreements: ContractAgreement[] = [];
|
|
104
102
|
|
|
@@ -109,7 +107,6 @@ export class SolidFactList extends OrbitComponent {
|
|
|
109
107
|
await this.dspConnector?.instance?.loadAgreement(n["@id"]);
|
|
110
108
|
if (agreement) {
|
|
111
109
|
allAgreements.push(agreement);
|
|
112
|
-
negotiationToAgreementMap.set(n["@id"], agreement);
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
}),
|
|
@@ -123,16 +120,36 @@ export class SolidFactList extends OrbitComponent {
|
|
|
123
120
|
},
|
|
124
121
|
);
|
|
125
122
|
|
|
126
|
-
|
|
123
|
+
// Let's get dirty, my connector does not know the asset, so I'll call provider directly
|
|
124
|
+
const assets: Promise<Response>[] = [];
|
|
127
125
|
for (const agreement of consumerAgreements) {
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
|
|
126
|
+
if (
|
|
127
|
+
!this.assetData.find(
|
|
128
|
+
(asset) => asset["@id"] === agreement.assetId,
|
|
129
|
+
)
|
|
130
|
+
) {
|
|
131
|
+
assets.push(
|
|
132
|
+
fetch(
|
|
133
|
+
`https://afp.connector-dev.startinblox.com/management/v3/assets/${agreement.assetId}`,
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const assetResponses = await Promise.all(assets);
|
|
140
|
+
this.assetData = [
|
|
141
|
+
...this.assetData,
|
|
142
|
+
...(await Promise.all(assetResponses.map((r) => r.json()))),
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
const bundles = [];
|
|
146
|
+
for (const asset of this.assetData) {
|
|
131
147
|
const bundleUrl = asset?.dataAddress?.baseUrl;
|
|
132
148
|
if (bundleUrl) {
|
|
133
149
|
bundles.push(this._getProxyValue(bundleUrl));
|
|
134
150
|
}
|
|
135
151
|
}
|
|
152
|
+
|
|
136
153
|
const facts = Array.from(
|
|
137
154
|
new Set(
|
|
138
155
|
(await Promise.all(bundles))
|
|
@@ -158,7 +175,10 @@ export class SolidFactList extends OrbitComponent {
|
|
|
158
175
|
cast: async (c: Resource) =>
|
|
159
176
|
await Promise.all(
|
|
160
177
|
(await c._originalResource?.["ldp:contains"]).map(
|
|
161
|
-
async (c: Category) => ({
|
|
178
|
+
async (c: Category) => ({
|
|
179
|
+
"@id": c["@id"],
|
|
180
|
+
name: formatCase((await c["name"]) || ""),
|
|
181
|
+
}),
|
|
162
182
|
),
|
|
163
183
|
),
|
|
164
184
|
},
|