@startinblox/core 2.0.6-beta.20 → 2.0.6-beta.22

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.
@@ -2,7 +2,7 @@ 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
4
  import { q as mergeContexts, o as getRawContext, n as normalizeContext } from "./helpers-DtCY-jxq.js";
5
- import { S as StoreService } from "./store-D1nUbSMR.js";
5
+ import { S as StoreService } from "./store-CsOvawDq.js";
6
6
  const store = StoreService.getInstance();
7
7
  class CustomGetter {
8
8
  // search attributes to give to server
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
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 { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-D1nUbSMR.js";
4
+ import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-CsOvawDq.js";
5
5
  import { d as defineComponent, n as normalizeContext, u as uniqID, f as fuzzyCompare, a as asyncQuerySelector, i as importInlineCSS, b as importCSS, c as doesResourceContainList, e as findClosingBracketMatchIndex, p as parseFieldsString, g as evalTemplateString, h as compare, j as generalComparator, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-DtCY-jxq.js";
6
- import { __tla as __tla_1 } from "./store-D1nUbSMR.js";
7
- import { A, D } from "./store-D1nUbSMR.js";
6
+ import { __tla as __tla_1 } from "./store-CsOvawDq.js";
7
+ import { A, D } from "./store-CsOvawDq.js";
8
8
  import { k } from "./helpers-DtCY-jxq.js";
9
9
  let index$4, BaseWidgetMixin, index$3, CounterMixin, DspCatalogDisplay, EdcAssetsDisplay, FederationMixin, FilterMixin, GrouperMixin, HighlighterMixin, ListMixin, NextMixin, PaginateMixin, RequiredMixin, Sib, SolidAcChecker, SolidDelete, SolidDisplay, SolidForm, SolidFormSearch, SolidLang, SolidMemberAdd, SolidMemberDelete, SolidMembership, SolidTable, SolidTemplateElement, SolidWidget, SorterMixin, StoreMixin, index$2, index$1, index, TranslationMixin, ValidationMixin, WidgetMixin, b, o$2, newWidgetFactory, D2, o$1, m, widgetFactory;
10
10
  let __tla = Promise.all([
@@ -3750,16 +3750,9 @@ let __tla = (async () => {
3750
3750
  })
3751
3751
  });
3752
3752
  if (!response.ok) {
3753
- const getResponse = await this.fetchAuthn(`${this.config.contractNegotiationEndpoint}?offset=0&limit=1000`, {
3754
- method: "GET",
3755
- headers: this.headers
3756
- });
3757
- if (!getResponse.ok) {
3758
- console.warn(`Failed to fetch contract negotiations: ${getResponse.status} ${getResponse.statusText}`);
3759
- return [];
3760
- }
3761
- const getData = await getResponse.json();
3762
- return Array.isArray(getData) ? getData : getData.items || [];
3753
+ const body = await response.text().catch(() => "");
3754
+ console.warn(`Failed to fetch contract negotiations: ${response.status} ${response.statusText}${body ? ` \u2014 ${body}` : ""}`);
3755
+ return [];
3763
3756
  }
3764
3757
  const data = await response.json();
3765
3758
  return Array.isArray(data) ? data : data.items || [];
@@ -5529,6 +5522,23 @@ let __tla = (async () => {
5529
5522
  const endpointHash = ((_a2 = this.cfg.endpoint) == null ? void 0 : _a2.replace(/[^a-zA-Z0-9]/g, "")) || "unknown";
5530
5523
  return `store://local.fc-${endpointHash}-${containerType}/`;
5531
5524
  }
5525
+ buildOutputContainer(resource, targetType) {
5526
+ const items = resource == null ? void 0 : resource["ldp:contains"];
5527
+ if (!Array.isArray(items)) return resource;
5528
+ const filtered = items.filter((item) => {
5529
+ const name = item == null ? void 0 : item.name;
5530
+ if (!name || String(name).trim().length === 0) return false;
5531
+ if (!targetType) return true;
5532
+ const t = item == null ? void 0 : item["@type"];
5533
+ const last = Array.isArray(t) ? t[t.length - 1] : t;
5534
+ return last === targetType;
5535
+ });
5536
+ if (filtered.length === items.length) return resource;
5537
+ return {
5538
+ ...resource,
5539
+ "ldp:contains": filtered
5540
+ };
5541
+ }
5532
5542
  async getData(args) {
5533
5543
  if (this.isFetching) {
5534
5544
  if (this.pendingGetData) {
@@ -5599,7 +5609,7 @@ let __tla = (async () => {
5599
5609
  const items = (apiList == null ? void 0 : apiList.items) || [];
5600
5610
  if (!Array.isArray(items)) {
5601
5611
  console.warn("[FederatedCatalogueStore] apiList.items is not an array");
5602
- return resource;
5612
+ return this.buildOutputContainer(resource, targetType);
5603
5613
  }
5604
5614
  const apiHashes = new Set(items.map((item) => item.meta.sdHash));
5605
5615
  const newHashes = [];
@@ -5676,13 +5686,13 @@ let __tla = (async () => {
5676
5686
  },
5677
5687
  bubbles: true
5678
5688
  }));
5679
- return resource;
5689
+ return this.buildOutputContainer(resource, targetType);
5680
5690
  } catch (error2) {
5681
5691
  console.error("[FederatedCatalogueStore] Delta update failed, falling back to full fetch:", error2);
5682
5692
  return await this.getFullData(targetType);
5683
5693
  }
5684
5694
  }
5685
- async getFullData(_targetType) {
5695
+ async getFullData(targetType) {
5686
5696
  if (!this.fcApi) {
5687
5697
  console.warn("[FederatedCatalogueStore] API not initialized yet, waiting for auth");
5688
5698
  return await this.initLocalDataSourceContainer();
@@ -5728,7 +5738,7 @@ let __tla = (async () => {
5728
5738
  },
5729
5739
  bubbles: true
5730
5740
  }));
5731
- return resource;
5741
+ return this.buildOutputContainer(resource, targetType);
5732
5742
  }
5733
5743
  async initLocalDataSourceContainer(dataSrc = "", containerType = "default") {
5734
5744
  if (!dataSrc) {
@@ -5852,30 +5862,74 @@ let __tla = (async () => {
5852
5862
  return obj;
5853
5863
  }
5854
5864
  mapSourceToDestination(src, opts) {
5855
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5865
+ var _a2, _b, _c, _d;
5856
5866
  const vc = src.verifiableCredential;
5857
5867
  const cs = vc.credentialSubject;
5868
+ const FOAF_THUMBNAIL_KEYS = [
5869
+ "foaf:thumbnail",
5870
+ "http://xmlns.com/foaf/0.1/thumbnail"
5871
+ ];
5872
+ const FOAF_NAME_KEYS = [
5873
+ "foaf:name",
5874
+ "http://xmlns.com/foaf/0.1/name"
5875
+ ];
5876
+ const DCTERMS_CREATOR_KEYS = [
5877
+ "dcterms:creator",
5878
+ "dct:creator",
5879
+ "http://purl.org/dc/terms/creator"
5880
+ ];
5881
+ const RDF_RESOURCE_KEYS = [
5882
+ "rdf:resource",
5883
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#resource"
5884
+ ];
5885
+ const pickKey = (obj, keys) => {
5886
+ if (!obj) return void 0;
5887
+ for (const k of keys) if (obj[k] !== void 0) return obj[k];
5888
+ return void 0;
5889
+ };
5890
+ const getThumbnailUrl = (obj) => pickKey(pickKey(obj, FOAF_THUMBNAIL_KEYS), RDF_RESOURCE_KEYS) || "";
5891
+ const getCreator = (obj) => pickKey(obj, DCTERMS_CREATOR_KEYS);
5858
5892
  let catInfo;
5859
5893
  let usedKey;
5860
5894
  let type;
5895
+ const datasetBlock = cs["dcat:dataset"] && cs["dcat:dataset"].length > 0 ? cs["dcat:dataset"][0] : void 0;
5896
+ const detectIsDataOffer = (block) => {
5897
+ if (!block || typeof block !== "object") return false;
5898
+ const rawType = block["@type"];
5899
+ const types2 = Array.isArray(rawType) ? rawType : rawType ? [
5900
+ rawType
5901
+ ] : [];
5902
+ const datasetTypeHit = types2.some((t) => typeof t === "string" && (t === "dcat:Dataset" || t === "http://www.w3.org/ns/dcat#Dataset" || t === "tems:DataOffer" || t === "temscore:DataOffer" || t === "http://tems.org/2024/temscore#DataOffer"));
5903
+ if (datasetTypeHit) return true;
5904
+ const kind = block["tc:offeringKind"] || block["temscore:offeringKind"] || block["http://tems.org/2024/temscore#offeringKind"];
5905
+ return typeof kind === "string" && /dataoffer/i.test(kind);
5906
+ };
5861
5907
  if (cs["dcat:service"]) {
5862
5908
  catInfo = cs["dcat:service"];
5863
5909
  usedKey = "service";
5864
- type = "tems:Service";
5865
- } else if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
5866
- const dataset2 = cs["dcat:dataset"][0];
5867
- if (dataset2["dcat:service"]) {
5868
- catInfo = dataset2["dcat:service"];
5910
+ type = detectIsDataOffer(catInfo) ? "tems:DataOffer" : "tems:Service";
5911
+ } else if (datasetBlock) {
5912
+ const nestedDataset = datasetBlock["dcat:dataset"];
5913
+ const firstNestedDataset = Array.isArray(nestedDataset) ? nestedDataset[0] : nestedDataset;
5914
+ if (firstNestedDataset) {
5915
+ catInfo = firstNestedDataset;
5916
+ usedKey = "nested-dataset";
5917
+ type = "tems:DataOffer";
5918
+ } else if (datasetBlock["dcat:service"]) {
5919
+ catInfo = datasetBlock["dcat:service"];
5869
5920
  usedKey = "nested-service";
5870
- type = "tems:Service";
5921
+ type = detectIsDataOffer(catInfo) ? "tems:DataOffer" : "tems:Service";
5871
5922
  } else {
5872
- catInfo = dataset2;
5923
+ catInfo = datasetBlock;
5873
5924
  usedKey = "dataset";
5874
5925
  type = "tems:DataOffer";
5875
5926
  }
5876
5927
  } else {
5877
5928
  throw new Error("Expected either credentialSubject['dcat:service'] or a non-empty array in ['dcat:dataset']");
5878
5929
  }
5930
+ if (!catInfo) {
5931
+ throw new Error(`Could not locate an offering block (used key: ${usedKey}); resolved catInfo is empty`);
5932
+ }
5879
5933
  const resourceId = cs["@id"];
5880
5934
  const slug = resourceId.split("/").pop() || "unknown";
5881
5935
  const serviceId = `${opts.temsServiceBase}${encodeURIComponent(slug)}/`;
@@ -5883,7 +5937,10 @@ let __tla = (async () => {
5883
5937
  const update_date = vc.expirationDate;
5884
5938
  const name = catInfo["dcterms:title"] || catInfo["dct:title"];
5885
5939
  const description = catInfo["rdfs:comment"];
5886
- const keywords = catInfo["dcat:keyword"] || [];
5940
+ const rawKeywords = catInfo["dcat:keyword"];
5941
+ const keywords = Array.isArray(rawKeywords) ? rawKeywords : rawKeywords != null ? [
5942
+ rawKeywords
5943
+ ] : [];
5887
5944
  const long_description = keywords.length > 0 ? `Keywords: ${keywords.join(", ")}` : "";
5888
5945
  const categories = {
5889
5946
  "@id": `${serviceId}categories/`,
@@ -5901,12 +5958,10 @@ let __tla = (async () => {
5901
5958
  const is_external = hasEndpoint;
5902
5959
  const is_api = hasEndpoint;
5903
5960
  const imageUrls = [];
5904
- if ((_a2 = catInfo["foaf:thumbnail"]) == null ? void 0 : _a2["rdf:resource"]) {
5905
- imageUrls.push(catInfo["foaf:thumbnail"]["rdf:resource"]);
5906
- }
5907
- if ((_c = (_b = catInfo["dcterms:creator"]) == null ? void 0 : _b["foaf:thumbnail"]) == null ? void 0 : _c["rdf:resource"]) {
5908
- imageUrls.push(catInfo["dcterms:creator"]["foaf:thumbnail"]["rdf:resource"]);
5909
- }
5961
+ const catThumbnail = getThumbnailUrl(catInfo);
5962
+ if (catThumbnail) imageUrls.push(catThumbnail);
5963
+ const creatorThumbnail = getThumbnailUrl(getCreator(catInfo));
5964
+ if (creatorThumbnail) imageUrls.push(creatorThumbnail);
5910
5965
  const images = {
5911
5966
  "@id": `${serviceId}images/`,
5912
5967
  "@type": "ldp:Container",
@@ -5920,25 +5975,26 @@ let __tla = (async () => {
5920
5975
  };
5921
5976
  const contact_url = catInfo["dcat:endpointDescription"] || "";
5922
5977
  const documentation_url = contact_url || "";
5923
- let service_url = catInfo["dcat:endpointURL"] || "";
5978
+ let service_url = endpointURL;
5924
5979
  if (!service_url) {
5925
5980
  console.warn("[FederatedCatalogueStore] dcat:endpointURL is missing from dcat:service. Available fields:", Object.keys(catInfo));
5926
5981
  }
5927
5982
  if (service_url.includes("demo.isan.org")) service_url = new URL(service_url).origin;
5928
5983
  let providerRef;
5929
5984
  if (usedKey === "service") {
5930
- providerRef = ((_d = cs["gax-core:operatedBy"]) == null ? void 0 : _d["@id"]) || "";
5931
- } else if (usedKey === "nested-service") {
5932
- providerRef = ((_e = cs["gax-core:operatedBy"]) == null ? void 0 : _e["@id"]) || ((_f = cs["gax-core:offeredBy"]) == null ? void 0 : _f["@id"]) || "";
5985
+ providerRef = ((_a2 = cs["gax-core:operatedBy"]) == null ? void 0 : _a2["@id"]) || "";
5986
+ } else if (usedKey === "nested-service" || usedKey === "nested-dataset") {
5987
+ providerRef = ((_b = cs["gax-core:operatedBy"]) == null ? void 0 : _b["@id"]) || ((_c = cs["gax-core:offeredBy"]) == null ? void 0 : _c["@id"]) || "";
5933
5988
  } else {
5934
- providerRef = ((_g = cs["gax-core:offeredBy"]) == null ? void 0 : _g["@id"]) || "";
5989
+ providerRef = ((_d = cs["gax-core:offeredBy"]) == null ? void 0 : _d["@id"]) || "";
5935
5990
  }
5936
5991
  const providerSlug = providerRef.split(":").pop() + String(Math.random()) || "0";
5937
- const providerLogo = ((_i = (_h = catInfo["dcterms:creator"]) == null ? void 0 : _h["foaf:thumbnail"]) == null ? void 0 : _i["rdf:resource"]) || "";
5992
+ const creator = getCreator(catInfo);
5993
+ const providerLogo = getThumbnailUrl(creator);
5938
5994
  const provider = {
5939
5995
  "@id": `${opts.temsProviderBase}${encodeURIComponent(providerSlug)}/`,
5940
5996
  "@type": "tems:Provider",
5941
- name: ((_j = catInfo["dcterms:creator"]) == null ? void 0 : _j["foaf:name"]) || "",
5997
+ name: pickKey(creator, FOAF_NAME_KEYS) || "",
5942
5998
  image: {
5943
5999
  "@id": `${opts.temsImageBase}${encodeURIComponent(providerLogo.split("/").pop() || "0")}/`,
5944
6000
  "@type": "tems:Image",
@@ -32981,7 +33037,8 @@ sh:property [
32981
33037
  acl: "http://www.w3.org/ns/auth/acl#",
32982
33038
  hd: "http://cdn.startinblox.com/owl/ttl/vocab.ttl#",
32983
33039
  sib: "http://cdn.startinblox.com/owl/ttl/vocab.ttl#",
32984
- dcat: "https://www.w3.org/ns/dcat3.jsonld#",
33040
+ dcat: "http://www.w3.org/ns/dcat#",
33041
+ dct: "http://purl.org/dc/terms/",
32985
33042
  tems: "https://cdn.startinblox.com/owl/tems.jsonld#",
32986
33043
  name: "rdfs:label",
32987
33044
  deadline: "xsd:dateTime",
@@ -33060,7 +33117,7 @@ sh:property [
33060
33117
  window.dispatchEvent(event);
33061
33118
  }
33062
33119
  async initGetter() {
33063
- const { CustomGetter } = await import("./custom-getter-Blm6IRrs.js");
33120
+ const { CustomGetter } = await import("./custom-getter-BKuxi53d.js");
33064
33121
  return CustomGetter;
33065
33122
  }
33066
33123
  disconnectedCallback() {
package/dist/store.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s, S, c, b, e, j, h, i } from "./store-D1nUbSMR.js";
1
+ import { s, S, c, b, e, j, h, i } from "./store-CsOvawDq.js";
2
2
  export {
3
3
  s as SEMANTIZER,
4
4
  S as StoreService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "2.0.6-beta.20",
3
+ "version": "2.0.6-beta.22",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",