@startinblox/core 2.0.5-beta.4 → 2.0.5-beta.5

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.
@@ -1,8 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { l as isUrlOrRelativePath, m as jsonldContextParserExports, o as getRawContext, n as normalizeContext, q as mergeContexts, a as doesResourceContainList, r as requireJsonldContextParser, v as requireErrorCoded, w as requireLink } from "./helpers-Bew5Yvdt.js";
5
- let StoreService, formatAttributesToServerSearchOptions, base_context, hasQueryIndex, sibStore, formatAttributesToServerPaginationOptions, getDefaultExportFromCjs, hasSetLocalData, mergeServerSearchOptions, semantizer;
4
+ import { l as isUrlOrRelativePath, m as jsonldContextParserExports, o as getRawContext, n as normalizeContext, q as mergeContexts, c as doesResourceContainList, r as requireJsonldContextParser, v as requireErrorCoded, w as requireLink } from "./helpers-vZrb1UDN.js";
5
+ let StoreService, formatAttributesToServerSearchOptions, base_context, StoreType, StoreFactory, hasQueryIndex, formatAttributesToServerPaginationOptions, getDefaultExportFromCjs, hasSetLocalData, sibStore, mergeServerSearchOptions, semantizer;
6
6
  let __tla = (async () => {
7
7
  var _a;
8
8
  getDefaultExportFromCjs = function(x) {
@@ -162,118 +162,471 @@ let __tla = (async () => {
162
162
  return false;
163
163
  }
164
164
  }
165
- function mapSourceToDestination(src, opts) {
166
- var _a2, _b, _c, _d, _e, _f, _g, _h;
167
- const vc = src.verifiableCredential;
168
- const cs = vc.credentialSubject;
169
- let catInfo;
170
- let usedKey;
171
- let type;
172
- if (cs["dcat:service"]) {
173
- catInfo = cs["dcat:service"];
174
- usedKey = "service";
175
- type = "tems:Service";
176
- } else if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
177
- catInfo = cs["dcat:dataset"][0];
178
- usedKey = "dataset";
179
- type = "tems:DataOffer";
180
- } else {
181
- throw new Error("Expected either credentialSubject['dcat:service'] or a non-empty array in ['dcat:dataset']");
182
- }
183
- const resourceId = cs["@id"];
184
- const slug = resourceId.split("/").pop() || "unknown";
185
- const serviceId = `${opts.temsServiceBase}${encodeURIComponent(slug)}/`;
186
- const creation_date = vc.issuanceDate;
187
- const update_date = vc.expirationDate;
188
- const name = catInfo["dcterms:title"];
189
- const description = catInfo["rdfs:comment"];
190
- const keywords = catInfo["dcat:keyword"] || [];
191
- const long_description = keywords.length > 0 ? `Keywords: ${keywords.join(", ")}` : "";
192
- const categories = {
193
- "@id": `${serviceId}categories/`,
194
- "@type": "ldp:Container",
195
- "ldp:contains": keywords.map((kw) => ({
196
- "@id": `${opts.temsCategoryBase}${encodeURIComponent(kw)}/`,
197
- "@type": "tems:Category",
198
- name: kw
199
- }))
200
- };
201
- const endpointURL = catInfo["dcat:endpointURL"] || "";
202
- const hasEndpoint = endpointURL.trim().length > 0;
203
- const activation_status = hasEndpoint;
204
- const is_in_app = hasEndpoint;
205
- const is_external = hasEndpoint;
206
- const is_api = hasEndpoint;
207
- const imageUrls = [];
208
- if ((_a2 = catInfo["foaf:thumbnail"]) == null ? void 0 : _a2["rdf:resource"]) {
209
- imageUrls.push(catInfo["foaf:thumbnail"]["rdf:resource"]);
210
- }
211
- if ((_c = (_b = catInfo["dcterms:creator"]) == null ? void 0 : _b["foaf:thumbnail"]) == null ? void 0 : _c["rdf:resource"]) {
212
- imageUrls.push(catInfo["dcterms:creator"]["foaf:thumbnail"]["rdf:resource"]);
213
- }
214
- const images = {
215
- "@id": `${serviceId}images/`,
216
- "@type": "ldp:Container",
217
- "ldp:contains": imageUrls.map((url2) => ({
218
- "@id": `${opts.temsImageBase}${encodeURIComponent(url2.split("/").pop() || "0")}/`,
219
- url: url2,
220
- iframe: false,
221
- name: url2.split("/").pop() || "image",
222
- "@type": "tems:Image"
223
- }))
224
- };
225
- const contact_url = catInfo["dcat:endpointDescription"] || "";
226
- const documentation_url = contact_url || "";
227
- let service_url = catInfo["dcat:endpointURL"] || "";
228
- if (service_url.includes("demo.isan.org")) service_url = new URL(service_url).origin;
229
- let providerRef;
230
- if (usedKey === "service") {
231
- providerRef = ((_d = cs["gax-core:operatedBy"]) == null ? void 0 : _d["@id"]) || "";
232
- } else {
233
- providerRef = ((_e = cs["gax-core:offeredBy"]) == null ? void 0 : _e["@id"]) || "";
234
- }
235
- const providerSlug = providerRef.split(":").pop() + String(Math.random()) || "0";
236
- const providerLogo = ((_g = (_f = catInfo["dcterms:creator"]) == null ? void 0 : _f["foaf:thumbnail"]) == null ? void 0 : _g["rdf:resource"]) || "";
237
- const provider = {
238
- "@id": `${opts.temsProviderBase}${encodeURIComponent(providerSlug)}/`,
239
- "@type": "tems:Provider",
240
- name: ((_h = catInfo["dcterms:creator"]) == null ? void 0 : _h["foaf:name"]) || "",
241
- image: {
242
- "@id": `${opts.temsImageBase}${encodeURIComponent(providerLogo.split("/").pop() || "0")}/`,
243
- "@type": "tems:Image",
244
- iframe: false,
245
- url: providerLogo,
246
- name: providerLogo.split("/").pop() || "provider-logo"
247
- }
248
- };
249
- const data_offers = [];
250
- const dest = {
251
- "@id": serviceId,
252
- creation_date,
253
- update_date,
254
- name,
255
- description,
256
- long_description,
257
- categories,
258
- activation_status,
259
- activation_date: null,
260
- licence: null,
261
- is_in_app,
262
- is_external,
263
- is_api,
264
- images,
265
- release_date: null,
266
- last_update: null,
267
- developper: null,
268
- contact_url,
269
- documentation_url,
270
- url: service_url,
271
- provider,
272
- data_offers,
273
- "@type": type
274
- };
275
- return dest;
165
+ class DataspaceConnectorStore {
166
+ constructor(config) {
167
+ __publicField(this, "cache");
168
+ __publicField(this, "session");
169
+ __publicField(this, "headers");
170
+ __publicField(this, "config");
171
+ __publicField(this, "authToken", null);
172
+ __publicField(this, "contractNegotiations", /* @__PURE__ */ new Map());
173
+ __publicField(this, "transferProcesses", /* @__PURE__ */ new Map());
174
+ var _a2, _b;
175
+ this.validateConfig(config);
176
+ this.config = config;
177
+ this.cache = ((_a2 = config.options) == null ? void 0 : _a2.cacheManager) ?? new InMemoryCacheManager();
178
+ this.session = (_b = config.options) == null ? void 0 : _b.session;
179
+ this.headers = {
180
+ "Content-Type": "application/json",
181
+ Accept: "application/json"
182
+ };
183
+ }
184
+ validateConfig(config) {
185
+ const required = [
186
+ "catalogEndpoint",
187
+ "contractNegotiationEndpoint",
188
+ "transferProcessEndpoint",
189
+ "authMethod"
190
+ ];
191
+ const missing = required.filter((field) => !config[field]);
192
+ if (missing.length > 0) {
193
+ throw new Error(`Missing required configuration: ${missing.join(", ")}`);
194
+ }
195
+ }
196
+ async getData(args) {
197
+ if ("targetType" in args) {
198
+ return await this.getCatalog(args.targetType);
199
+ }
200
+ return await this.get(args.id, args.serverPagination, args.serverSearch);
201
+ }
202
+ async get(id, _serverPagination, _serverSearch) {
203
+ const cached = await this.cache.get(id);
204
+ if (cached) return cached;
205
+ try {
206
+ const resource = await this.fetchThroughDataspace(id);
207
+ if (resource) {
208
+ await this.cacheResource(id, resource);
209
+ }
210
+ return resource;
211
+ } catch (error2) {
212
+ console.error(`Failed to fetch resource ${id}:`, error2);
213
+ return null;
214
+ }
215
+ }
216
+ async getCatalog(counterPartyAddress) {
217
+ await this.ensureAuthenticated();
218
+ const catalogRequest = this.buildV3CatalogRequest(counterPartyAddress);
219
+ console.log("Sending v3 catalog request:", JSON.stringify(catalogRequest, null, 2));
220
+ const response = await this.fetchAuthn(this.config.catalogEndpoint, {
221
+ method: "POST",
222
+ headers: this.headers,
223
+ body: JSON.stringify(catalogRequest)
224
+ });
225
+ if (!response.ok) {
226
+ console.error(`Catalog request failed: ${response.status} ${response.statusText}`);
227
+ const errorText = await response.text();
228
+ console.error("Error response:", errorText);
229
+ return null;
230
+ }
231
+ const catalog = await response.json();
232
+ if (catalog["@id"]) {
233
+ await this.cache.set(catalog["@id"], catalog);
234
+ }
235
+ if (catalog["dcat:dataset"] && Array.isArray(catalog["dcat:dataset"])) {
236
+ for (const dataset2 of catalog["dcat:dataset"]) {
237
+ if (dataset2["@id"]) {
238
+ await this.cache.set(dataset2["@id"], dataset2);
239
+ }
240
+ }
241
+ }
242
+ return catalog;
243
+ }
244
+ async negotiateContract(counterPartyAddress, _offerId, policy, counterPartyId) {
245
+ await this.ensureAuthenticated();
246
+ const negotiationRequest = {
247
+ "@context": {
248
+ "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
249
+ },
250
+ "@type": "ContractRequest",
251
+ counterPartyAddress,
252
+ counterPartyId,
253
+ protocol: "dataspace-protocol-http",
254
+ policy: {
255
+ "@context": "http://www.w3.org/ns/odrl.jsonld",
256
+ "@id": policy["@id"],
257
+ "@type": "Offer",
258
+ assigner: counterPartyId || "provider",
259
+ target: policy.target
260
+ }
261
+ };
262
+ const response = await this.fetchAuthn(this.config.contractNegotiationEndpoint, {
263
+ method: "POST",
264
+ headers: this.headers,
265
+ body: JSON.stringify(negotiationRequest)
266
+ });
267
+ if (!response.ok) {
268
+ const errorText = await response.text();
269
+ console.error(`Contract negotiation failed: ${response.status} ${response.statusText}`, errorText);
270
+ throw new Error(`Contract negotiation failed: ${response.status} ${response.statusText} - ${errorText}`);
271
+ }
272
+ const negotiation = await response.json();
273
+ const negotiationId = negotiation["@id"];
274
+ this.contractNegotiations.set(negotiationId, negotiation);
275
+ return negotiationId;
276
+ }
277
+ initiateNegotiation(counterPartyAddress, assetId, policy, counterPartyId) {
278
+ return this.negotiateContract(counterPartyAddress, assetId, policy, counterPartyId);
279
+ }
280
+ getNegotiationStatus(negotiationId) {
281
+ return this._getNegotiationStatus(negotiationId);
282
+ }
283
+ async initiateTransfer(counterPartyAddress, contractId, dataDestination) {
284
+ await this.ensureAuthenticated();
285
+ const transferRequest = {
286
+ "@context": [
287
+ "https://w3id.org/edc/v0.0.1/ns/",
288
+ "https://w3id.org/dspace/2024/1/context.json"
289
+ ],
290
+ "@type": "https://w3id.org/edc/v0.0.1/ns/TransferRequestMessage",
291
+ counterPartyAddress,
292
+ contractId,
293
+ dataDestination
294
+ };
295
+ const response = await this.fetchAuthn(this.config.transferProcessEndpoint, {
296
+ method: "POST",
297
+ headers: this.headers,
298
+ body: JSON.stringify(transferRequest)
299
+ });
300
+ if (!response.ok) {
301
+ throw new Error(`Transfer initiation failed: ${response.status} ${response.statusText}`);
302
+ }
303
+ const transfer = await response.json();
304
+ const transferId = transfer["@id"];
305
+ this.transferProcesses.set(transferId, transfer);
306
+ return transferId;
307
+ }
308
+ async fetchThroughDataspace(resourceId) {
309
+ try {
310
+ console.log(`Fetching resource through dataspace: ${resourceId}`);
311
+ const catalog = await this.getCatalog();
312
+ if (!catalog) {
313
+ console.error("No catalog available");
314
+ return null;
315
+ }
316
+ console.log("Catalog received:", catalog);
317
+ const dataset2 = this.findDatasetInCatalog(catalog, resourceId);
318
+ if (!dataset2) {
319
+ console.error(`Dataset ${resourceId} not found in catalog`);
320
+ return null;
321
+ }
322
+ console.log("Dataset found:", dataset2);
323
+ return catalog;
324
+ } catch (error2) {
325
+ console.error("Dataspace fetch failed:", error2);
326
+ return null;
327
+ }
328
+ }
329
+ findDatasetInCatalog(catalog, resourceId) {
330
+ const datasets = catalog["dcat:dataset"] || [];
331
+ return datasets.find((dataset2) => {
332
+ var _a2;
333
+ return dataset2["@id"] === resourceId || ((_a2 = dataset2["dcat:distribution"]) == null ? void 0 : _a2.some((dist) => dist["@id"] === resourceId));
334
+ }) || null;
335
+ }
336
+ async _getNegotiationStatus(negotiationId) {
337
+ const response = await this.fetchAuthn(`${this.config.contractNegotiationEndpoint}/${negotiationId}`, {
338
+ method: "GET",
339
+ headers: this.headers
340
+ });
341
+ return response.json();
342
+ }
343
+ async ensureAuthenticated() {
344
+ if (this.authToken && this.headers) return;
345
+ switch (this.config.authMethod) {
346
+ case "edc-api-key":
347
+ if (!this.config.edcApiKey) {
348
+ throw new Error("EDC API key required but not provided. Set edcApiKey in configuration.");
349
+ }
350
+ this.authToken = this.config.edcApiKey;
351
+ this.headers = {
352
+ ...this.headers,
353
+ "X-Api-Key": this.authToken
354
+ };
355
+ break;
356
+ case "bearer":
357
+ if (!this.config.bearerToken) {
358
+ throw new Error("Bearer token required but not provided");
359
+ }
360
+ this.authToken = this.config.bearerToken;
361
+ this.headers = {
362
+ ...this.headers,
363
+ Authorization: `Bearer ${this.authToken}`
364
+ };
365
+ break;
366
+ case "oauth2":
367
+ this.authToken = await this.getOAuth2Token();
368
+ this.headers = {
369
+ ...this.headers,
370
+ Authorization: `Bearer ${this.authToken}`
371
+ };
372
+ break;
373
+ case "delegated":
374
+ if (!this.config.delegatedAuthConfig) {
375
+ throw new Error("Delegated auth config required but not provided");
376
+ }
377
+ this.authToken = await this.getDelegatedAuthToken();
378
+ this.headers = {
379
+ ...this.headers,
380
+ Authorization: `Bearer ${this.authToken}`
381
+ };
382
+ break;
383
+ }
384
+ }
385
+ async getOAuth2Token() {
386
+ if (!this.config.oauth2Config) {
387
+ throw new Error("OAuth2 config required");
388
+ }
389
+ const { tokenEndpoint, clientId, clientSecret, scope } = this.config.oauth2Config;
390
+ const body = new URLSearchParams({
391
+ grant_type: "client_credentials",
392
+ client_id: clientId,
393
+ client_secret: clientSecret
394
+ });
395
+ if (scope) {
396
+ body.append("scope", scope);
397
+ }
398
+ const response = await fetch(tokenEndpoint, {
399
+ method: "POST",
400
+ headers: {
401
+ "Content-Type": "application/x-www-form-urlencoded"
402
+ },
403
+ body
404
+ });
405
+ if (!response.ok) {
406
+ throw new Error(`OAuth2 token request failed: ${response.status}`);
407
+ }
408
+ const data = await response.json();
409
+ return data.access_token;
410
+ }
411
+ async getDelegatedAuthToken() {
412
+ if (!this.config.delegatedAuthConfig) {
413
+ throw new Error("Delegated auth config required");
414
+ }
415
+ const { identityProviderEndpoint, clientId, clientSecret } = this.config.delegatedAuthConfig;
416
+ if (!clientId || !clientSecret) {
417
+ throw new Error("Client ID and secret required for delegated authentication");
418
+ }
419
+ const body = new URLSearchParams({
420
+ grant_type: "client_credentials",
421
+ client_id: clientId,
422
+ client_secret: clientSecret
423
+ });
424
+ const response = await fetch(identityProviderEndpoint, {
425
+ method: "POST",
426
+ headers: {
427
+ "Content-Type": "application/x-www-form-urlencoded"
428
+ },
429
+ body
430
+ });
431
+ if (!response.ok) {
432
+ throw new Error(`Delegated auth token request failed: ${response.status}`);
433
+ }
434
+ const data = await response.json();
435
+ return data.access_token;
436
+ }
437
+ buildV3CatalogRequest(counterPartyAddress) {
438
+ const apiVersion = this.config.apiVersion || "v3";
439
+ if (apiVersion === "v3") {
440
+ return {
441
+ "@context": {
442
+ "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
443
+ edc: "https://w3id.org/edc/v0.0.1/ns/",
444
+ dcat: "https://www.w3.org/ns/dcat#",
445
+ dct: "https://purl.org/dc/terms/",
446
+ odrl: "http://www.w3.org/ns/odrl/2/"
447
+ },
448
+ "@type": "CatalogRequestMessage",
449
+ counterPartyAddress: counterPartyAddress || this.getProtocolEndpoint(),
450
+ protocol: "dataspace-protocol-http"
451
+ };
452
+ }
453
+ return {
454
+ "@context": [
455
+ "https://w3id.org/edc/v0.0.1/ns/",
456
+ "https://w3id.org/dspace/2024/1/context.json"
457
+ ],
458
+ "@type": "https://w3id.org/edc/v0.0.1/ns/CatalogRequestMessage",
459
+ counterPartyAddress: counterPartyAddress || this.config.endpoint || "",
460
+ protocol: "dataspace-protocol-http"
461
+ };
462
+ }
463
+ getProtocolEndpoint() {
464
+ if (this.config.endpoint) {
465
+ const baseUrl = this.config.endpoint.replace("/management", "");
466
+ return `${baseUrl}/protocol`;
467
+ }
468
+ return this.config.endpoint || "";
469
+ }
470
+ async getAssets(querySpec) {
471
+ await this.ensureAuthenticated();
472
+ const apiVersion = this.config.apiVersion || "v3";
473
+ const assetsEndpoint = this.config.assetsEndpoint || this.config.catalogEndpoint.replace("/catalog/request", apiVersion === "v3" ? "/assets/request" : "/assets");
474
+ const requestBody = querySpec || this.buildV3QuerySpec();
475
+ const method = apiVersion === "v3" ? "POST" : "GET";
476
+ const requestOptions = {
477
+ method,
478
+ headers: this.headers
479
+ };
480
+ if (method === "POST") {
481
+ requestOptions.body = JSON.stringify(requestBody);
482
+ }
483
+ const response = await this.fetchAuthn(assetsEndpoint, requestOptions);
484
+ if (!response.ok) {
485
+ console.error(`Assets request failed: ${response.status} ${response.statusText}`);
486
+ const errorText = await response.text();
487
+ console.error("Error response:", errorText);
488
+ return [];
489
+ }
490
+ const assets = await response.json();
491
+ const assetsArray = Array.isArray(assets) ? assets : [];
492
+ for (const asset of assetsArray) {
493
+ if (asset["@id"]) {
494
+ await this.cache.set(asset["@id"], asset);
495
+ }
496
+ }
497
+ return assetsArray;
498
+ }
499
+ async getPolicyDefinitions(querySpec) {
500
+ await this.ensureAuthenticated();
501
+ const apiVersion = this.config.apiVersion || "v3";
502
+ const policiesEndpoint = this.config.policiesEndpoint || this.config.catalogEndpoint.replace("/catalog/request", apiVersion === "v3" ? "/policydefinitions/request" : "/policydefinitions");
503
+ const requestBody = querySpec || this.buildV3QuerySpec();
504
+ const method = apiVersion === "v3" ? "POST" : "GET";
505
+ const requestOptions = {
506
+ method,
507
+ headers: this.headers
508
+ };
509
+ if (method === "POST") {
510
+ requestOptions.body = JSON.stringify(requestBody);
511
+ }
512
+ const response = await this.fetchAuthn(policiesEndpoint, requestOptions);
513
+ if (!response.ok) {
514
+ console.error(`Policy definitions request failed: ${response.status} ${response.statusText}`);
515
+ const errorText = await response.text();
516
+ console.error("Error response:", errorText);
517
+ return [];
518
+ }
519
+ const policies = await response.json();
520
+ const policiesArray = Array.isArray(policies) ? policies : [];
521
+ for (const policy of policiesArray) {
522
+ if (policy["@id"]) {
523
+ await this.cache.set(policy["@id"], policy);
524
+ }
525
+ }
526
+ return policiesArray;
527
+ }
528
+ async getContractDefinitions(querySpec) {
529
+ await this.ensureAuthenticated();
530
+ const apiVersion = this.config.apiVersion || "v3";
531
+ const contractDefsEndpoint = this.config.contractDefinitionsEndpoint || this.config.catalogEndpoint.replace("/catalog/request", apiVersion === "v3" ? "/contractdefinitions/request" : "/contractdefinitions");
532
+ const requestBody = querySpec || this.buildV3QuerySpec();
533
+ const method = apiVersion === "v3" ? "POST" : "GET";
534
+ const requestOptions = {
535
+ method,
536
+ headers: this.headers
537
+ };
538
+ if (method === "POST") {
539
+ requestOptions.body = JSON.stringify(requestBody);
540
+ }
541
+ const response = await this.fetchAuthn(contractDefsEndpoint, requestOptions);
542
+ if (!response.ok) {
543
+ console.error(`Contract definitions request failed: ${response.status} ${response.statusText}`);
544
+ const errorText = await response.text();
545
+ console.error("Error response:", errorText);
546
+ return [];
547
+ }
548
+ const contracts = await response.json();
549
+ const contractsArray = Array.isArray(contracts) ? contracts : [];
550
+ for (const contract of contractsArray) {
551
+ if (contract["@id"]) {
552
+ await this.cache.set(contract["@id"], contract);
553
+ }
554
+ }
555
+ return contractsArray;
556
+ }
557
+ buildV3QuerySpec(offset = 0, limit = 50) {
558
+ return {
559
+ "@context": {
560
+ "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
561
+ edc: "https://w3id.org/edc/v0.0.1/ns/"
562
+ },
563
+ "@type": "QuerySpec",
564
+ offset,
565
+ limit,
566
+ filterExpression: [],
567
+ sortField: null,
568
+ sortOrder: "ASC"
569
+ };
570
+ }
571
+ async fetchAuthn(iri, options) {
572
+ await this.ensureAuthenticated();
573
+ return fetch(iri, {
574
+ ...options,
575
+ headers: {
576
+ ...this.headers,
577
+ ...options.headers
578
+ },
579
+ mode: "cors"
580
+ });
581
+ }
582
+ async post(_resource, _id, _skipFetch) {
583
+ await Promise.resolve();
584
+ throw new Error("POST not implemented for DataspaceConnectorStore");
585
+ }
586
+ async put(_resource, _id, _skipFetch) {
587
+ await Promise.resolve();
588
+ throw new Error("PUT not implemented for DataspaceConnectorStore");
589
+ }
590
+ async patch(_resource, _id, _skipFetch) {
591
+ await Promise.resolve();
592
+ throw new Error("PATCH not implemented for DataspaceConnectorStore");
593
+ }
594
+ delete(_id, _context) {
595
+ throw new Error("DELETE not implemented for DataspaceConnectorStore");
596
+ }
597
+ async clearCache(id) {
598
+ await this.cache.delete(id);
599
+ }
600
+ async cacheResource(key, resourceProxy) {
601
+ await this.cache.set(key, resourceProxy);
602
+ }
603
+ _getLanguage() {
604
+ return localStorage.getItem("language") || "en";
605
+ }
606
+ selectLanguage(selectedLanguageCode) {
607
+ localStorage.setItem("language", selectedLanguageCode);
608
+ }
609
+ subscribeResourceTo(_resourceId, _nestedResourceId) {
610
+ }
611
+ getExpandedPredicate(property, _context) {
612
+ return property;
613
+ }
276
614
  }
615
+ const _DataspaceConnectorStoreAdapter = class _DataspaceConnectorStoreAdapter {
616
+ constructor() {
617
+ }
618
+ static getStoreInstance(cfg) {
619
+ if (!_DataspaceConnectorStoreAdapter.store) {
620
+ if (!cfg) {
621
+ throw new Error("DataspaceConnectorStore configuration is required");
622
+ }
623
+ _DataspaceConnectorStoreAdapter.store = new DataspaceConnectorStore(cfg);
624
+ }
625
+ return _DataspaceConnectorStoreAdapter.store;
626
+ }
627
+ };
628
+ __publicField(_DataspaceConnectorStoreAdapter, "store");
629
+ let DataspaceConnectorStoreAdapter = _DataspaceConnectorStoreAdapter;
277
630
  class FederatedCatalogueAPIWrapper {
278
631
  constructor(options, fcBaseUrl) {
279
632
  __publicField(this, "fcBaseUrl");
@@ -421,7 +774,7 @@ let __tla = (async () => {
421
774
  for (const item in dataset2.items) {
422
775
  const sd = await this.fcApi.getSelfDescriptionByHash(dataset2.items[item].meta.sdHash);
423
776
  if (sd) {
424
- const mappedResource = mapSourceToDestination(sd, {
777
+ const mappedResource = this.mapSourceToDestination(sd, {
425
778
  temsServiceBase: this.cfg.temsServiceBase,
426
779
  temsCategoryBase: this.cfg.temsCategoryBase,
427
780
  temsImageBase: this.cfg.temsImageBase,
@@ -538,6 +891,118 @@ let __tla = (async () => {
538
891
  bubbles: true
539
892
  }));
540
893
  }
894
+ mapSourceToDestination(src, opts) {
895
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
896
+ const vc = src.verifiableCredential;
897
+ const cs = vc.credentialSubject;
898
+ let catInfo;
899
+ let usedKey;
900
+ let type;
901
+ if (cs["dcat:service"]) {
902
+ catInfo = cs["dcat:service"];
903
+ usedKey = "service";
904
+ type = "tems:Service";
905
+ } else if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
906
+ catInfo = cs["dcat:dataset"][0];
907
+ usedKey = "dataset";
908
+ type = "tems:DataOffer";
909
+ } else {
910
+ throw new Error("Expected either credentialSubject['dcat:service'] or a non-empty array in ['dcat:dataset']");
911
+ }
912
+ const resourceId = cs["@id"];
913
+ const slug = resourceId.split("/").pop() || "unknown";
914
+ const serviceId = `${opts.temsServiceBase}${encodeURIComponent(slug)}/`;
915
+ const creation_date = vc.issuanceDate;
916
+ const update_date = vc.expirationDate;
917
+ const name = catInfo["dcterms:title"];
918
+ const description = catInfo["rdfs:comment"];
919
+ const keywords = catInfo["dcat:keyword"] || [];
920
+ const long_description = keywords.length > 0 ? `Keywords: ${keywords.join(", ")}` : "";
921
+ const categories = {
922
+ "@id": `${serviceId}categories/`,
923
+ "@type": "ldp:Container",
924
+ "ldp:contains": keywords.map((kw) => ({
925
+ "@id": `${opts.temsCategoryBase}${encodeURIComponent(kw)}/`,
926
+ "@type": "tems:Category",
927
+ name: kw
928
+ }))
929
+ };
930
+ const endpointURL = catInfo["dcat:endpointURL"] || "";
931
+ const hasEndpoint = endpointURL.trim().length > 0;
932
+ const activation_status = hasEndpoint;
933
+ const is_in_app = hasEndpoint;
934
+ const is_external = hasEndpoint;
935
+ const is_api = hasEndpoint;
936
+ const imageUrls = [];
937
+ if ((_a2 = catInfo["foaf:thumbnail"]) == null ? void 0 : _a2["rdf:resource"]) {
938
+ imageUrls.push(catInfo["foaf:thumbnail"]["rdf:resource"]);
939
+ }
940
+ if ((_c = (_b = catInfo["dcterms:creator"]) == null ? void 0 : _b["foaf:thumbnail"]) == null ? void 0 : _c["rdf:resource"]) {
941
+ imageUrls.push(catInfo["dcterms:creator"]["foaf:thumbnail"]["rdf:resource"]);
942
+ }
943
+ const images = {
944
+ "@id": `${serviceId}images/`,
945
+ "@type": "ldp:Container",
946
+ "ldp:contains": imageUrls.map((url2) => ({
947
+ "@id": `${opts.temsImageBase}${encodeURIComponent(url2.split("/").pop() || "0")}/`,
948
+ url: url2,
949
+ iframe: false,
950
+ name: url2.split("/").pop() || "image",
951
+ "@type": "tems:Image"
952
+ }))
953
+ };
954
+ const contact_url = catInfo["dcat:endpointDescription"] || "";
955
+ const documentation_url = contact_url || "";
956
+ let service_url = catInfo["dcat:endpointURL"] || "";
957
+ if (service_url.includes("demo.isan.org")) service_url = new URL(service_url).origin;
958
+ let providerRef;
959
+ if (usedKey === "service") {
960
+ providerRef = ((_d = cs["gax-core:operatedBy"]) == null ? void 0 : _d["@id"]) || "";
961
+ } else {
962
+ providerRef = ((_e = cs["gax-core:offeredBy"]) == null ? void 0 : _e["@id"]) || "";
963
+ }
964
+ const providerSlug = providerRef.split(":").pop() + String(Math.random()) || "0";
965
+ const providerLogo = ((_g = (_f = catInfo["dcterms:creator"]) == null ? void 0 : _f["foaf:thumbnail"]) == null ? void 0 : _g["rdf:resource"]) || "";
966
+ const provider = {
967
+ "@id": `${opts.temsProviderBase}${encodeURIComponent(providerSlug)}/`,
968
+ "@type": "tems:Provider",
969
+ name: ((_h = catInfo["dcterms:creator"]) == null ? void 0 : _h["foaf:name"]) || "",
970
+ image: {
971
+ "@id": `${opts.temsImageBase}${encodeURIComponent(providerLogo.split("/").pop() || "0")}/`,
972
+ "@type": "tems:Image",
973
+ iframe: false,
974
+ url: providerLogo,
975
+ name: providerLogo.split("/").pop() || "provider-logo"
976
+ }
977
+ };
978
+ const data_offers = [];
979
+ const dest = {
980
+ "@id": serviceId,
981
+ creation_date,
982
+ update_date,
983
+ name,
984
+ description,
985
+ long_description,
986
+ categories,
987
+ activation_status,
988
+ activation_date: null,
989
+ licence: null,
990
+ is_in_app,
991
+ is_external,
992
+ is_api,
993
+ images,
994
+ release_date: null,
995
+ last_update: null,
996
+ developper: null,
997
+ contact_url,
998
+ documentation_url,
999
+ url: service_url,
1000
+ provider,
1001
+ data_offers,
1002
+ "@type": type
1003
+ };
1004
+ return dest;
1005
+ }
541
1006
  }
542
1007
  const _FederatedCatalogueStoreAdapter = class _FederatedCatalogueStoreAdapter {
543
1008
  constructor() {
@@ -27498,7 +27963,7 @@ sh:property [
27498
27963
  this.searchProvider = new SolidIndexingSearchProvider(this.getData.bind(this));
27499
27964
  }
27500
27965
  async initGetter() {
27501
- const { CustomGetter } = await import("./custom-getter-CzhJNcId.js");
27966
+ const { CustomGetter } = await import("./custom-getter-FYE7WERU.js");
27502
27967
  return CustomGetter;
27503
27968
  }
27504
27969
  async getData(id, context2, parentId, localData, forceFetch, serverPagination, serverSearch, headers, bypassLoadingList) {
@@ -27871,12 +28336,12 @@ sh:property [
27871
28336
  hasSetLocalData = function(store2) {
27872
28337
  return "setLocalData" in store2 && typeof store2.setLocalData === "function";
27873
28338
  };
27874
- var StoreType = ((StoreType2) => {
28339
+ StoreType = ((StoreType2) => {
27875
28340
  StoreType2["LDP"] = "ldp";
27876
28341
  StoreType2["FederatedCatalogue"] = "federatedCatalogue";
28342
+ StoreType2["DataspaceConnector"] = "dataspaceConnector";
27877
28343
  return StoreType2;
27878
28344
  })(StoreType || {});
27879
- var StoreFactory;
27880
28345
  ((StoreFactory2) => {
27881
28346
  const registry = /* @__PURE__ */ new Map();
27882
28347
  function register(name, adapter) {
@@ -27892,6 +28357,7 @@ sh:property [
27892
28357
  })(StoreFactory || (StoreFactory = {}));
27893
28358
  StoreFactory.register(StoreType.LDP, LdpStoreAdapter);
27894
28359
  StoreFactory.register(StoreType.FederatedCatalogue, FederatedCatalogueStoreAdapter);
28360
+ StoreFactory.register(StoreType.DataspaceConnector, DataspaceConnectorStoreAdapter);
27895
28361
  StoreService = (_a = class {
27896
28362
  static init(config) {
27897
28363
  if (StoreService.currentStore) {
@@ -31973,11 +32439,13 @@ export {
31973
32439
  __tla,
31974
32440
  formatAttributesToServerSearchOptions as a,
31975
32441
  base_context as b,
31976
- hasQueryIndex as c,
31977
- sibStore as d,
32442
+ StoreType as c,
32443
+ StoreFactory as d,
32444
+ hasQueryIndex as e,
31978
32445
  formatAttributesToServerPaginationOptions as f,
31979
32446
  getDefaultExportFromCjs as g,
31980
32447
  hasSetLocalData as h,
32448
+ sibStore as i,
31981
32449
  mergeServerSearchOptions as m,
31982
32450
  semantizer as s
31983
32451
  };