cocoda-sdk 3.4.10 → 3.4.12

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.
@@ -915,8 +915,8 @@ var LocalMappingsProvider = class extends BaseProvider {
915
915
  let last2 = import_last.default(this.queue) || Promise.resolve();
916
916
  return new Promise((resolve) => {
917
917
  function defer() {
918
- var res, rej;
919
- var promise2 = new Promise((resolve2, reject) => {
918
+ let res, rej;
919
+ const promise2 = new Promise((resolve2, reject) => {
920
920
  res = resolve2;
921
921
  rej = reject;
922
922
  });
@@ -3625,6 +3625,87 @@ var broaderProps = [
3625
3625
  "broaderTermInstantial",
3626
3626
  "broaderTermPartitive"
3627
3627
  ];
3628
+ var mappingsProps = {
3629
+ sameAs: "http://www.w3.org/2004/02/skos/core#exactMatch",
3630
+ exactMatch: "http://www.w3.org/2004/02/skos/core#exactMatch",
3631
+ closeMatch: "http://www.w3.org/2004/02/skos/core#closeMatch",
3632
+ // See also: https://d-nb.info/standards/elementset/gnd#relatedDdcWithDegreeOfDeterminacy1
3633
+ relatedDdcWithDegreeOfDeterminacy1: "http://www.w3.org/2004/02/skos/core#narrowMatch",
3634
+ relatedDdcWithDegreeOfDeterminacy2: "http://www.w3.org/2004/02/skos/core#narrowMatch",
3635
+ relatedDdcWithDegreeOfDeterminacy3: "http://www.w3.org/2004/02/skos/core#closeMatch",
3636
+ relatedDdcWithDegreeOfDeterminacy4: "http://www.w3.org/2004/02/skos/core#exactMatch"
3637
+ };
3638
+ var mappingSchemes = [
3639
+ // DDC
3640
+ {
3641
+ uri: "http://bartoc.org/en/node/241",
3642
+ // Note: In code, we're rewriting DDC notations to include the version number "e23/" at the end.
3643
+ uriPattern: "http://dewey.info/class/(.+)/"
3644
+ },
3645
+ // RAMEAU
3646
+ {
3647
+ uri: "http://bartoc.org/en/node/18",
3648
+ namespace: "https://data.bnf.fr/ark:/12148/"
3649
+ },
3650
+ // EMBNE
3651
+ {
3652
+ uri: "http://bartoc.org/en/node/20450",
3653
+ namespace: "https://datos.bne.es/resource/"
3654
+ },
3655
+ // Wikidata
3656
+ {
3657
+ uri: "http://bartoc.org/en/node/1940",
3658
+ namespace: "http://www.wikidata.org/entity/"
3659
+ },
3660
+ // TheSoz
3661
+ {
3662
+ uri: "http://bartoc.org/en/node/294",
3663
+ namespace: "http://lod.gesis.org/thesoz/"
3664
+ },
3665
+ // T-PRO
3666
+ {
3667
+ uri: "http://bartoc.org/en/node/20425",
3668
+ namespace: "http://uri.gbv.de/terminology/tpro/"
3669
+ },
3670
+ // VIAF
3671
+ {
3672
+ uri: "http://bartoc.org/en/node/2053",
3673
+ namespace: "http://viaf.org/viaf/"
3674
+ },
3675
+ // Note: The following vocabularies use uriPattern to work around http/https URI confusion.
3676
+ // See also: https://github.com/gbv/cocoda-sdk/issues/66#issuecomment-2273422523
3677
+ // TODO: Adjust this after the issue has been fixed in source.
3678
+ // AGROVOC
3679
+ {
3680
+ uri: "http://bartoc.org/en/node/305",
3681
+ uriPattern: "http?://aims.fao.org/aos/agrovoc/(.+)"
3682
+ },
3683
+ // MeSH
3684
+ {
3685
+ uri: "http://bartoc.org/en/node/391",
3686
+ uriPattern: "http?://id.nlm.nih.gov/mesh/(.+)"
3687
+ },
3688
+ // STW
3689
+ {
3690
+ uri: "http://bartoc.org/en/node/313",
3691
+ uriPattern: "http?://zbw.eu/stw/descriptor/(.+)"
3692
+ },
3693
+ // BNCF
3694
+ {
3695
+ uri: "http://bartoc.org/en/node/443",
3696
+ uriPattern: "https?://purl.org/bncf/tid/(.+)"
3697
+ },
3698
+ // LCSH
3699
+ {
3700
+ uri: "http://bartoc.org/en/node/454",
3701
+ uriPattern: "http?://id.loc.gov/authorities/subjects/(.+)"
3702
+ },
3703
+ // LCNAF
3704
+ {
3705
+ uri: "http://bartoc.org/en/node/18536",
3706
+ uriPattern: "http?://id.loc.gov/authorities/names/(.+)"
3707
+ }
3708
+ ].map((scheme) => new import_jskos_tools11.default.ConceptScheme(scheme));
3628
3709
  function toJSKOS(data3) {
3629
3710
  const concept = {
3630
3711
  uri: data3.id,
@@ -3647,14 +3728,31 @@ function toJSKOS(data3) {
3647
3728
  if (concept.uri) {
3648
3729
  concept.identifier = [concept.uri.replace("https://", "http://")];
3649
3730
  }
3650
- if (data3.sameAs && data3.sameAs.length) {
3651
- concept.mappings = data3.sameAs.map((target) => ({
3652
- from: { memberSet: [{ uri: concept.uri }] },
3653
- fromScheme: { uri: gndJson.uri },
3654
- to: { memberSet: [{ uri: target.id }] },
3655
- toScheme: { uri: target.collection.id },
3656
- type: ["http://www.w3.org/2004/02/skos/core#exactMatch"]
3657
- }));
3731
+ let mappings = [];
3732
+ for (const prop of Object.keys(mappingsProps)) {
3733
+ const type = mappingsProps[prop];
3734
+ if (data3[prop]?.length) {
3735
+ mappings = mappings.concat(data3[prop].map((target) => {
3736
+ const scheme = mappingSchemes.find((s) => s.notationFromUri(target.id));
3737
+ const targetConcept = scheme?.conceptFromUri(target.id);
3738
+ if (!scheme || !targetConcept) {
3739
+ return null;
3740
+ }
3741
+ if (scheme.uri === "http://bartoc.org/en/node/241") {
3742
+ targetConcept.uri += "e23/";
3743
+ }
3744
+ return {
3745
+ from: { memberSet: [{ uri: concept.uri, notation: concept.notation }] },
3746
+ fromScheme: { uri: gndJson.uri },
3747
+ to: { memberSet: [targetConcept] },
3748
+ toScheme: { uri: scheme.uri },
3749
+ type: [type]
3750
+ };
3751
+ }).filter(Boolean));
3752
+ }
3753
+ }
3754
+ if (mappings.length) {
3755
+ concept.mappings = mappings;
3658
3756
  }
3659
3757
  return concept;
3660
3758
  }