cocoda-sdk 3.2.3 → 3.3.0

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.
@@ -32,13 +32,15 @@ __export(src_exports, {
32
32
  LocApiProvider: () => LocApiProvider,
33
33
  LocalMappingsProvider: () => LocalMappingsProvider,
34
34
  MappingsApiProvider: () => MappingsApiProvider,
35
+ MyCoReProvider: () => MyCoReProvider,
35
36
  OccurrencesApiProvider: () => OccurrencesApiProvider,
36
37
  ReconciliationApiProvider: () => ReconciliationApiProvider,
37
38
  SkohubProvider: () => SkohubProvider,
38
39
  SkosmosApiProvider: () => SkosmosApiProvider,
39
40
  addAllProviders: () => addAllProviders,
40
41
  cdk: () => cdk,
41
- errors: () => errors_exports
42
+ errors: () => errors_exports,
43
+ utils: () => utils_exports
42
44
  });
43
45
  module.exports = __toCommonJS(src_exports);
44
46
 
@@ -112,7 +114,7 @@ var import_omit = __toESM(require("lodash/omit.js"), 1);
112
114
  var import_concat = __toESM(require("lodash/concat.js"), 1);
113
115
 
114
116
  // src/lib/CocodaSDK.js
115
- var import_jskos_tools11 = __toESM(require("jskos-tools"), 1);
117
+ var import_jskos_tools12 = __toESM(require("jskos-tools"), 1);
116
118
 
117
119
  // src/providers/index.js
118
120
  var providers_exports = {};
@@ -123,6 +125,7 @@ __export(providers_exports, {
123
125
  LocApiProvider: () => LocApiProvider,
124
126
  LocalMappingsProvider: () => LocalMappingsProvider,
125
127
  MappingsApiProvider: () => MappingsApiProvider,
128
+ MyCoReProvider: () => MyCoReProvider,
126
129
  OccurrencesApiProvider: () => OccurrencesApiProvider,
127
130
  ReconciliationApiProvider: () => ReconciliationApiProvider,
128
131
  SkohubProvider: () => SkohubProvider,
@@ -134,6 +137,13 @@ var import_jskos_tools = __toESM(require("jskos-tools"), 1);
134
137
  var import_axios = __toESM(require("axios"), 1);
135
138
 
136
139
  // src/utils/index.js
140
+ var utils_exports = {};
141
+ __export(utils_exports, {
142
+ concatUrl: () => concatUrl,
143
+ listOfCapabilities: () => listOfCapabilities,
144
+ requestMethods: () => requestMethods,
145
+ withCustomProps: () => withCustomProps
146
+ });
137
147
  var requestMethods = [
138
148
  {
139
149
  method: "getRegistries",
@@ -347,8 +357,8 @@ var BaseProvider = class {
347
357
  }
348
358
  return config;
349
359
  });
350
- this.axios.interceptors.response.use(({ data, headers = {}, config = {} }) => {
351
- data = import_jskos_tools.default.normalize(data);
360
+ this.axios.interceptors.response.use(({ data: data3, headers = {}, config = {} }) => {
361
+ data3 = import_jskos_tools.default.normalize(data3);
352
362
  let url = config.url;
353
363
  if (!url.endsWith("?")) {
354
364
  url += "?";
@@ -356,14 +366,14 @@ var BaseProvider = class {
356
366
  import_forOwn.default(config.params || {}, (value, key) => {
357
367
  url += `${key}=${encodeURIComponent(value)}&`;
358
368
  });
359
- if (import_isArray.default(data) || import_isObject.default(data)) {
369
+ if (import_isArray.default(data3) || import_isObject.default(data3)) {
360
370
  let totalCount = parseInt(headers["x-total-count"]);
361
371
  if (!isNaN(totalCount)) {
362
- data._totalCount = totalCount;
372
+ data3._totalCount = totalCount;
363
373
  }
364
- data._url = url;
374
+ data3._url = url;
365
375
  }
366
- return data;
376
+ return data3;
367
377
  }, (error) => {
368
378
  const count = import_get.default(error, "config._retryCount", 0);
369
379
  const method = import_get.default(error, "config.method");
@@ -592,7 +602,7 @@ var BaseProvider = class {
592
602
  return (await this.getConcepts({ ...config, concepts: [concept] }))[0];
593
603
  };
594
604
  for (let type of ["broader", "narrower", "ancestors"]) {
595
- if (Array.isArray(concept[type]) && !concept[type].includes(null)) {
605
+ if (Array.isArray(concept[type]) && concept[type].length && !concept[type].includes(null)) {
596
606
  concept[type] = this.adjustConcepts(concept[type]);
597
607
  }
598
608
  }
@@ -1391,9 +1401,13 @@ MappingsApiProvider.stored = true;
1391
1401
 
1392
1402
  // src/providers/occurrences-api-provider.js
1393
1403
  var import_jskos_tools4 = __toESM(require("jskos-tools"), 1);
1404
+ var cache = {};
1394
1405
  var OccurrencesApiProvider = class extends BaseProvider {
1406
+ get _cache() {
1407
+ return cache[this.uri];
1408
+ }
1395
1409
  _prepare() {
1396
- this._cache = [];
1410
+ cache[this.uri] = [];
1397
1411
  this._occurrencesSupportedSchemes = [];
1398
1412
  this.has.occurrences = true;
1399
1413
  this.has.mappings = true;
@@ -1406,11 +1420,11 @@ var OccurrencesApiProvider = class extends BaseProvider {
1406
1420
  } else {
1407
1421
  try {
1408
1422
  const url = concatUrl(this._api.api, "voc");
1409
- const data = await this.axios({
1423
+ const data3 = await this.axios({
1410
1424
  method: "get",
1411
1425
  url
1412
1426
  });
1413
- this._occurrencesSupportedSchemes = data || [];
1427
+ this._occurrencesSupportedSchemes = data3 || [];
1414
1428
  } catch (error) {
1415
1429
  }
1416
1430
  }
@@ -1524,19 +1538,19 @@ var OccurrencesApiProvider = class extends BaseProvider {
1524
1538
  if (resultsFromCache) {
1525
1539
  return resultsFromCache.data;
1526
1540
  }
1527
- const data = await this.axios({
1541
+ const data3 = await this.axios({
1528
1542
  ...config,
1529
1543
  method: "get",
1530
1544
  url: this._api.api
1531
1545
  });
1532
1546
  this._cache.push({
1533
1547
  config,
1534
- data
1548
+ data: data3
1535
1549
  });
1536
1550
  if (this._cache.length > 20) {
1537
- this._cache = this._cache.slice(this._cache.length - 20);
1551
+ cache[this.uri] = this._cache.slice(this._cache.length - 20);
1538
1552
  }
1539
- return data;
1553
+ return data3;
1540
1554
  }
1541
1555
  };
1542
1556
  OccurrencesApiProvider.providerName = "OccurrencesApi";
@@ -1836,9 +1850,13 @@ ConceptApiProvider.providerType = "http://bartoc.org/api-type/jskos";
1836
1850
 
1837
1851
  // src/providers/reconciliation-api-provider.js
1838
1852
  var import_jskos_tools6 = __toESM(require("jskos-tools"), 1);
1853
+ var cache2 = {};
1839
1854
  var ReconciliationApiProvider = class extends BaseProvider {
1855
+ get _cache() {
1856
+ return cache2[this.uri];
1857
+ }
1840
1858
  _prepare() {
1841
- this._cache = [];
1859
+ cache2[this.uri] = [];
1842
1860
  this.has.mappings = true;
1843
1861
  listOfCapabilities.filter((c) => !this.has[c]).forEach((c) => {
1844
1862
  this.has[c] = false;
@@ -1950,22 +1968,22 @@ var ReconciliationApiProvider = class extends BaseProvider {
1950
1968
  }
1951
1969
  const encodedData = `queries=${encodeURIComponent(JSON.stringify(queries))}`;
1952
1970
  import_set.default(config, ["headers", "Content-Type"], "application/x-www-form-urlencoded");
1953
- let data = await this.axios({
1971
+ let data3 = await this.axios({
1954
1972
  ...config,
1955
1973
  method: "post",
1956
1974
  url,
1957
1975
  data: encodedData
1958
1976
  });
1959
- data = data || {};
1977
+ data3 = data3 || {};
1960
1978
  let newCacheEntry = {
1961
1979
  labels,
1962
1980
  language,
1963
- data,
1981
+ data: data3,
1964
1982
  url: `${url}${url.includes("?") ? "&" : "?"}${encodedData}`
1965
1983
  };
1966
1984
  this._cache.push(newCacheEntry);
1967
1985
  if (this._cache.length > 20) {
1968
- this._cache = this._cache.slice(this._cache.length - 20);
1986
+ cache2[this.uri] = this._cache.slice(this._cache.length - 20);
1969
1987
  }
1970
1988
  return newCacheEntry;
1971
1989
  }
@@ -2059,7 +2077,7 @@ var LabelSearchSuggestionProvider = class extends BaseProvider {
2059
2077
  if (!registry || registry.has.search === false) {
2060
2078
  return [];
2061
2079
  }
2062
- const data = await registry.search({
2080
+ const data3 = await registry.search({
2063
2081
  ...config,
2064
2082
  search: label,
2065
2083
  scheme: targetScheme,
@@ -2068,9 +2086,9 @@ var LabelSearchSuggestionProvider = class extends BaseProvider {
2068
2086
  if (!this._cache[targetScheme.uri]) {
2069
2087
  this._cache[targetScheme.uri] = {};
2070
2088
  }
2071
- this._cache[targetScheme.uri][label] = data;
2089
+ this._cache[targetScheme.uri][label] = data3;
2072
2090
  this._cache[targetScheme.uri][label]._limit = limit;
2073
- return data;
2091
+ return data3;
2074
2092
  }
2075
2093
  };
2076
2094
  LabelSearchSuggestionProvider.providerName = "LabelSearchSuggestion";
@@ -2141,11 +2159,11 @@ var SkosmosApiProvider = class extends BaseProvider {
2141
2159
  return null;
2142
2160
  }
2143
2161
  const url = this._getApiUrl(scheme, "/");
2144
- const data = await this.axios({
2162
+ const data3 = await this.axios({
2145
2163
  method: "get",
2146
2164
  url
2147
2165
  });
2148
- const resultScheme = data.conceptschemes.find((s) => import_jskos_tools8.default.compare(s, scheme));
2166
+ const resultScheme = data3.conceptschemes.find((s) => import_jskos_tools8.default.compare(s, scheme));
2149
2167
  if (resultScheme) {
2150
2168
  this._approvedSchemes.push({
2151
2169
  uri: resultScheme.uri,
@@ -2236,12 +2254,12 @@ var SkosmosApiProvider = class extends BaseProvider {
2236
2254
  const schemes = [];
2237
2255
  for (let scheme of this.schemes || []) {
2238
2256
  const url = this._getApiUrl(scheme, "/");
2239
- const data = await this.axios({
2257
+ const data3 = await this.axios({
2240
2258
  ...config,
2241
2259
  method: "get",
2242
2260
  url
2243
2261
  });
2244
- const resultScheme = data.conceptschemes.find((s) => import_jskos_tools8.default.compare(s, scheme));
2262
+ const resultScheme = data3.conceptschemes.find((s) => import_jskos_tools8.default.compare(s, scheme));
2245
2263
  const label = resultScheme && (resultScheme.prefLabel || resultScheme.label || resultScheme.title);
2246
2264
  if (label) {
2247
2265
  import_set.default(scheme, `prefLabel.${this._language}`, label);
@@ -2442,28 +2460,28 @@ var supportedSchemes = [
2442
2460
  }
2443
2461
  ];
2444
2462
  var lccUri = `${locUriPrefix}classification`;
2445
- function madsToJskosItem(data) {
2463
+ function madsToJskosItem(data3) {
2446
2464
  const item = {};
2447
- item.uri = data["@id"];
2448
- item.notation = (data["http://www.loc.gov/mads/rdf/v1#code"] || []).map((n) => n["@value"]);
2449
- const prefLabelArray = data["http://www.loc.gov/mads/rdf/v1#authoritativeLabel"] || data["http://www.w3.org/2000/01/rdf-schema#label"] || [];
2465
+ item.uri = data3["@id"];
2466
+ item.notation = (data3["http://www.loc.gov/mads/rdf/v1#code"] || []).map((n) => n["@value"]);
2467
+ const prefLabelArray = data3["http://www.loc.gov/mads/rdf/v1#authoritativeLabel"] || data3["http://www.w3.org/2000/01/rdf-schema#label"] || [];
2450
2468
  if (prefLabelArray.length) {
2451
2469
  item.prefLabel = {};
2452
2470
  item.prefLabel[prefLabelArray[0]["@language"] || "en"] = prefLabelArray[0]["@value"];
2453
2471
  }
2454
- const altLabelArray = data["http://www.w3.org/2004/02/skos/core#altLabel"] || [];
2472
+ const altLabelArray = data3["http://www.w3.org/2004/02/skos/core#altLabel"] || [];
2455
2473
  if (altLabelArray.length) {
2456
2474
  item.altLabel = { en: altLabelArray.map((l) => l["@value"]) };
2457
2475
  }
2458
- for (let definition of data["http://www.w3.org/2000/01/rdf-schema#comment"] || []) {
2476
+ for (let definition of data3["http://www.w3.org/2000/01/rdf-schema#comment"] || []) {
2459
2477
  item.definition = item.definition || {};
2460
2478
  item.definition.en = item.definition.en || [];
2461
2479
  item.definition.en.push(definition["@value"]);
2462
2480
  }
2463
2481
  return item;
2464
2482
  }
2465
- function madsToJskosScheme(data) {
2466
- const scheme = madsToJskosItem(data);
2483
+ function madsToJskosScheme(data3) {
2484
+ const scheme = madsToJskosItem(data3);
2467
2485
  scheme.namespace = scheme.uri + "/";
2468
2486
  scheme.type = ["http://www.w3.org/2004/02/skos/core#ConceptScheme"];
2469
2487
  return scheme;
@@ -2474,16 +2492,16 @@ var schemeNamespaceFilter = (scheme) => (c) => {
2474
2492
  }
2475
2493
  return c.uri.startsWith(scheme.namespace);
2476
2494
  };
2477
- function madsToJskosConcept(data, { scheme }) {
2478
- const concept = madsToJskosItem(data);
2495
+ function madsToJskosConcept(data3, { scheme }) {
2496
+ const concept = madsToJskosItem(data3);
2479
2497
  concept.type = ["http://www.w3.org/2004/02/skos/core#Concept"];
2480
- concept.inScheme = scheme ? [scheme] : (data["http://www.loc.gov/mads/rdf/v1#isMemberOfMADSScheme"] || []).map((s) => supportedSchemes.find((s2) => s2.uri === s["@id"]));
2498
+ concept.inScheme = scheme ? [scheme] : (data3["http://www.loc.gov/mads/rdf/v1#isMemberOfMADSScheme"] || []).map((s) => supportedSchemes.find((s2) => s2.uri === s["@id"]));
2481
2499
  if (!concept.inScheme.length || !concept.inScheme[0]) {
2482
2500
  delete concept.inScheme;
2483
2501
  }
2484
- const narrower = data["http://www.loc.gov/mads/rdf/v1#hasNarrowerAuthority"] || import_jskos_tools9.default.compare(concept.inScheme[0], { uri: lccUri }) && data["http://www.loc.gov/mads/rdf/v1#hasMADSCollectionMember"] || [];
2502
+ const narrower = data3["http://www.loc.gov/mads/rdf/v1#hasNarrowerAuthority"] || import_jskos_tools9.default.compare(concept.inScheme[0], { uri: lccUri }) && data3["http://www.loc.gov/mads/rdf/v1#hasMADSCollectionMember"] || [];
2485
2503
  concept.narrower = narrower.map((n) => ({ uri: n["@id"] })).filter(schemeNamespaceFilter(concept.inScheme && concept.inScheme[0]));
2486
- const broader = data["http://www.loc.gov/mads/rdf/v1#hasBroaderAuthority"] || import_jskos_tools9.default.compare(concept.inScheme[0], { uri: lccUri }) && data["http://www.loc.gov/mads/rdf/v1#isMemberOfMADSCollection"] || [];
2504
+ const broader = data3["http://www.loc.gov/mads/rdf/v1#hasBroaderAuthority"] || import_jskos_tools9.default.compare(concept.inScheme[0], { uri: lccUri }) && data3["http://www.loc.gov/mads/rdf/v1#isMemberOfMADSCollection"] || [];
2487
2505
  concept.broader = broader.map((n) => ({ uri: n["@id"] })).filter(schemeNamespaceFilter(concept.inScheme && concept.inScheme[0]));
2488
2506
  return concept;
2489
2507
  }
@@ -2515,9 +2533,9 @@ var LocApiProvider = class extends BaseProvider {
2515
2533
  supportedSchemes.filter((s) => !this.schemes || !this.schemes.length || this.schemes.find((s2) => import_jskos_tools9.default.compare(s, s2))).map((s) => (0, import_axios2.default)({
2516
2534
  method: "get",
2517
2535
  url: `${s.uri.replace("http:", "https:")}.json`
2518
- }).then(({ status, data }) => {
2536
+ }).then(({ status, data: data3 }) => {
2519
2537
  if (status === 200) {
2520
- let scheme2 = data.find((d) => s.uri === d["@id"]);
2538
+ let scheme2 = data3.find((d) => s.uri === d["@id"]);
2521
2539
  if (scheme2) {
2522
2540
  scheme2 = import_jskos_tools9.default.merge(madsToJskosScheme(scheme2), s);
2523
2541
  scheme2.topConcepts = (scheme2.topConcepts || []).filter((c) => c);
@@ -2541,9 +2559,9 @@ var LocApiProvider = class extends BaseProvider {
2541
2559
  for (let concept of await Promise.all(concepts.map((c) => (0, import_axios2.default)({
2542
2560
  method: "get",
2543
2561
  url: `${c.uri.replace("http:", "https:")}.json`
2544
- }).then(({ status, data }) => {
2562
+ }).then(({ status, data: data3 }) => {
2545
2563
  if (status === 200) {
2546
- let concept2 = data.find((d) => c.uri === d["@id"]);
2564
+ let concept2 = data3.find((d) => c.uri === d["@id"]);
2547
2565
  if (concept2) {
2548
2566
  return madsToJskosConcept(concept2, { scheme: c.inScheme && c.inScheme[0] });
2549
2567
  }
@@ -2577,7 +2595,7 @@ var LocApiProvider = class extends BaseProvider {
2577
2595
  }
2578
2596
  limit = limit || this._jskos.suggestResultLimit || 100;
2579
2597
  offset = offset || 0;
2580
- const { data } = await (0, import_axios2.default)({
2598
+ const { data: data3 } = await (0, import_axios2.default)({
2581
2599
  method: "get",
2582
2600
  url: `${schemeUri}/suggest2`.replace("http:", "https:"),
2583
2601
  params: {
@@ -2587,7 +2605,7 @@ var LocApiProvider = class extends BaseProvider {
2587
2605
  searchtype: "keyword"
2588
2606
  }
2589
2607
  });
2590
- return (data.hits || []).map((d) => ({
2608
+ return (data3.hits || []).map((d) => ({
2591
2609
  uri: d.uri,
2592
2610
  notation: [d.token],
2593
2611
  prefLabel: { en: d.aLabel },
@@ -2609,6 +2627,7 @@ function decodeUnicode(text) {
2609
2627
  }
2610
2628
  );
2611
2629
  }
2630
+ var data = {};
2612
2631
  var SkohubProvider = class extends BaseProvider {
2613
2632
  _prepare() {
2614
2633
  this.has.schemes = true;
@@ -2622,11 +2641,20 @@ var SkohubProvider = class extends BaseProvider {
2622
2641
  listOfCapabilities.filter((c) => !this.has[c]).forEach((c) => {
2623
2642
  this.has[c] = false;
2624
2643
  });
2644
+ data[this.uri] = {
2645
+ index: {},
2646
+ conceptCache: {},
2647
+ schemeCache: {}
2648
+ };
2625
2649
  }
2626
- _setup() {
2627
- this._index = {};
2628
- this._conceptCache = {};
2629
- this._schemeCache = {};
2650
+ get _index() {
2651
+ return data[this.uri] && data[this.uri].index;
2652
+ }
2653
+ get _conceptCache() {
2654
+ return data[this.uri] && data[this.uri].conceptCache;
2655
+ }
2656
+ get _schemeCache() {
2657
+ return data[this.uri] && data[this.uri].schemeCache;
2630
2658
  }
2631
2659
  static _registryConfigForBartocApiConfig({ url, scheme } = {}) {
2632
2660
  if (!url || !scheme) {
@@ -2652,11 +2680,11 @@ var SkohubProvider = class extends BaseProvider {
2652
2680
  if (uri.endsWith("/")) {
2653
2681
  postfix = "index.json";
2654
2682
  }
2655
- const data = await this.axios({ ...config, url: `${uri}${postfix}`, _skipAdditionalParameters: true });
2656
- if (data.id !== uri) {
2683
+ const data3 = await this.axios({ ...config, url: `${uri}${postfix}`, _skipAdditionalParameters: true });
2684
+ if (data3.id !== uri) {
2657
2685
  throw new InvalidRequestError({ message: "Skohub URL did not return expected concept scheme" });
2658
2686
  }
2659
- const { title, preferredNamespaceUri, hasTopConcept, description } = data;
2687
+ const { title, preferredNamespaceUri, hasTopConcept, description } = data3;
2660
2688
  scheme = { uri, identifier: uris.filter((u) => u !== uri) };
2661
2689
  scheme.prefLabel = title;
2662
2690
  Object.keys(scheme.prefLabel || {}).forEach((key) => {
@@ -2684,33 +2712,33 @@ var SkohubProvider = class extends BaseProvider {
2684
2712
  return this._conceptCache[uri];
2685
2713
  }
2686
2714
  try {
2687
- const data = await this.axios({ ...config, url: `${uri}.json`, _skipAdditionalParameters: true });
2688
- if (data.id !== uri) {
2715
+ const data3 = await this.axios({ ...config, url: `${uri}.json`, _skipAdditionalParameters: true });
2716
+ if (data3.id !== uri) {
2689
2717
  throw new InvalidRequestError({ message: "Skohub URL did not return expected concept URI" });
2690
2718
  }
2691
- const concept = this._toJskosConcept(data);
2719
+ const concept = this._toJskosConcept(data3);
2692
2720
  this._conceptCache[uri] = concept;
2693
2721
  return concept;
2694
2722
  } catch (error) {
2695
2723
  return null;
2696
2724
  }
2697
2725
  }
2698
- _toJskosConcept(data) {
2699
- const concept = { uri: data.id };
2700
- concept.prefLabel = data.prefLabel;
2726
+ _toJskosConcept(data3) {
2727
+ const concept = { uri: data3.id };
2728
+ concept.prefLabel = data3.prefLabel;
2701
2729
  Object.keys(concept.prefLabel || {}).forEach((key) => {
2702
2730
  concept.prefLabel[key] = decodeUnicode(concept.prefLabel[key]);
2703
2731
  });
2704
- concept.narrower = (data.narrower || []).map((c) => this._toJskosConcept(c));
2705
- concept.notation = data.notation || [];
2706
- if (data.broader && data.broader.id) {
2707
- concept.broader = [{ uri: data.broader.id }];
2732
+ concept.narrower = (data3.narrower || []).map((c) => this._toJskosConcept(c));
2733
+ concept.notation = data3.notation || [];
2734
+ if (data3.broader && data3.broader.id) {
2735
+ concept.broader = [{ uri: data3.broader.id }];
2708
2736
  }
2709
- if (data.inScheme && data.inScheme.id) {
2710
- concept.inScheme = [{ uri: data.inScheme.id }];
2737
+ if (data3.inScheme && data3.inScheme.id) {
2738
+ concept.inScheme = [{ uri: data3.inScheme.id }];
2711
2739
  }
2712
- if (data.scopeNote) {
2713
- concept.scopeNote = data.scopeNote;
2740
+ if (data3.scopeNote) {
2741
+ concept.scopeNote = data3.scopeNote;
2714
2742
  Object.keys(concept.scopeNote).forEach((key) => {
2715
2743
  concept.scopeNote[key] = [decodeUnicode(concept.scopeNote[key])];
2716
2744
  });
@@ -2782,13 +2810,13 @@ var SkohubProvider = class extends BaseProvider {
2782
2810
  if (scheme.uri.endsWith("/")) {
2783
2811
  postfix = `index${postfix}`;
2784
2812
  }
2785
- const data = await this.axios({ url: `${scheme.uri}${postfix}`, _skipAdditionalParameters: true });
2786
- if (data.length < 100) {
2813
+ const data3 = await this.axios({ url: `${scheme.uri}${postfix}`, _skipAdditionalParameters: true });
2814
+ if (data3.length < 100) {
2787
2815
  this._index[scheme.uri][lang] = null;
2788
2816
  continue;
2789
2817
  }
2790
2818
  index = import_flexsearch.default.create();
2791
- index.import(data);
2819
+ index.import(data3);
2792
2820
  this._index[scheme.uri][lang] = index;
2793
2821
  break;
2794
2822
  } catch (error) {
@@ -2824,6 +2852,217 @@ var SkohubProvider = class extends BaseProvider {
2824
2852
  SkohubProvider.providerName = "Skohub";
2825
2853
  SkohubProvider.providerType = "http://bartoc.org/api-type/skohub";
2826
2854
 
2855
+ // src/providers/mycore-provider.js
2856
+ var import_jskos_tools11 = __toESM(require("jskos-tools"), 1);
2857
+ var import_flexsearch2 = __toESM(require("flexsearch"), 1);
2858
+ var data2 = {};
2859
+ var MyCoReProvider = class extends BaseProvider {
2860
+ _prepare() {
2861
+ this.has.schemes = true;
2862
+ this.has.top = true;
2863
+ this.has.data = true;
2864
+ this.has.concepts = true;
2865
+ this.has.narrower = true;
2866
+ this.has.ancestors = true;
2867
+ this.has.suggest = true;
2868
+ this.has.search = true;
2869
+ listOfCapabilities.filter((c) => !this.has[c]).forEach((c) => {
2870
+ this.has[c] = false;
2871
+ });
2872
+ }
2873
+ _setup() {
2874
+ this._scheme = null;
2875
+ }
2876
+ static _registryConfigForBartocApiConfig({ url, scheme } = {}) {
2877
+ if (!url || !scheme) {
2878
+ return null;
2879
+ }
2880
+ return {
2881
+ api: url
2882
+ };
2883
+ }
2884
+ _schemeInfoToJSKOS(schemeInfo) {
2885
+ const uri = schemeInfo.labels.find((l) => l.lang === "x-uri").text;
2886
+ const prefLabel = {};
2887
+ schemeInfo.labels.filter((l) => !l.lang.startsWith("x-")).forEach((l) => {
2888
+ prefLabel[l.lang] = l.text;
2889
+ });
2890
+ const scheme = {
2891
+ uri,
2892
+ prefLabel
2893
+ };
2894
+ if (schemeInfo.categories && schemeInfo.categories.length) {
2895
+ scheme.topConcepts = [null];
2896
+ }
2897
+ if (schemeInfo.category && schemeInfo.category.length) {
2898
+ scheme.concepts = [null];
2899
+ }
2900
+ return scheme;
2901
+ }
2902
+ _categoryToJSKOS(category, { scheme, broader = [] }) {
2903
+ if (!category || !scheme) {
2904
+ return null;
2905
+ }
2906
+ const id = category.ID;
2907
+ const uri = `${scheme.uri}/${id}`;
2908
+ if (data2[scheme.uri].concepts[uri]) {
2909
+ return data2[scheme.uri].concepts[uri];
2910
+ }
2911
+ const prefLabel = {};
2912
+ category.labels.filter((l) => !l.lang.startsWith("x-") && l.text).forEach((l) => {
2913
+ prefLabel[l.lang] = l.text.replace(`${id} `, "");
2914
+ data2[scheme.uri].searchIndex.add(uri, prefLabel[l.lang]);
2915
+ });
2916
+ const scopeNote = {};
2917
+ category.labels.filter((l) => !l.lang.startsWith("x-") && l.description).forEach((l) => {
2918
+ if (!scopeNote[l.lang]) {
2919
+ scopeNote[l.lang] = [];
2920
+ }
2921
+ scopeNote[l.lang].push(l.description);
2922
+ });
2923
+ data2[scheme.uri].concepts[uri] = {
2924
+ uri,
2925
+ notation: [id],
2926
+ prefLabel,
2927
+ scopeNote,
2928
+ inScheme: [{ uri: scheme.uri }],
2929
+ narrower: (category.categories || []).map((c) => ({ uri: `${scheme.uri}/${c.ID}` })),
2930
+ broader
2931
+ };
2932
+ return data2[scheme.uri].concepts[uri];
2933
+ }
2934
+ _removeNarrower(concept) {
2935
+ if (!concept)
2936
+ return concept;
2937
+ return Object.assign({}, concept, { narrower: concept.narrower && concept.narrower.length ? [null] : [] });
2938
+ }
2939
+ async _loadSchemeData(config) {
2940
+ const schemeInfo = await this.axios({
2941
+ ...config,
2942
+ method: "get",
2943
+ url: this._api.api,
2944
+ _skipAdditionalParameters: true
2945
+ });
2946
+ this._scheme = this._schemeInfoToJSKOS(schemeInfo);
2947
+ const uri = this._scheme.uri;
2948
+ data2[uri] = {
2949
+ schemeInfo,
2950
+ searchIndex: import_flexsearch2.default.create({
2951
+ tokenize: "full"
2952
+ }),
2953
+ concepts: {}
2954
+ };
2955
+ const dealWithCategory = (category, { broader = [] } = {}) => {
2956
+ const concept = this._categoryToJSKOS(category, { scheme: this._scheme, broader });
2957
+ (category.categories || []).forEach((c) => dealWithCategory(c, { broader: [{ uri: concept.uri }] }));
2958
+ };
2959
+ schemeInfo.categories.forEach((category) => dealWithCategory(category));
2960
+ data2[uri].topConcepts = schemeInfo.categories.map((category) => this._categoryToJSKOS(category, { scheme: this._scheme }));
2961
+ }
2962
+ async getSchemes(config = {}) {
2963
+ if (!this._api.api) {
2964
+ throw new MissingApiUrlError();
2965
+ }
2966
+ if (!this._scheme) {
2967
+ if (!this._loadSchemeDataPromise) {
2968
+ this._loadSchemeDataPromise = this._loadSchemeData(config);
2969
+ }
2970
+ await this._loadSchemeDataPromise;
2971
+ }
2972
+ return [this._scheme];
2973
+ }
2974
+ async getTop({ scheme, ...config }) {
2975
+ if (!scheme || !scheme.uri) {
2976
+ throw new InvalidOrMissingParameterError({ parameter: "scheme", message: "Missing scheme URI" });
2977
+ }
2978
+ if (!this._scheme) {
2979
+ await this.getSchemes(config);
2980
+ }
2981
+ if (!import_jskos_tools11.default.compare(scheme, this._scheme)) {
2982
+ throw new InvalidOrMissingParameterError({ parameter: "scheme", message: "Requested vocabulary seems to be unsupported by this API." });
2983
+ }
2984
+ return data2[this._scheme.uri].topConcepts.map(this._removeNarrower);
2985
+ }
2986
+ async getConcepts({ concepts, ...config }) {
2987
+ if (!import_isArray.default(concepts)) {
2988
+ concepts = [concepts];
2989
+ }
2990
+ if (!this._scheme) {
2991
+ await this.getSchemes(config);
2992
+ }
2993
+ return concepts.map((c) => data2[this._scheme.uri].concepts[c.uri]).map(this._removeNarrower);
2994
+ }
2995
+ async getAncestors({ concept, ...config }) {
2996
+ if (!concept || !concept.uri) {
2997
+ throw new InvalidOrMissingParameterError({ parameter: "concept" });
2998
+ }
2999
+ if (concept.ancestors && concept.ancestors[0] !== null) {
3000
+ return concept.ancestors;
3001
+ }
3002
+ if (!this._scheme) {
3003
+ await this.getSchemes(config);
3004
+ }
3005
+ concept = data2[this._scheme.uri].concepts[concept.uri];
3006
+ const broader = concept && concept.broader && concept.broader[0];
3007
+ if (!broader) {
3008
+ return [];
3009
+ }
3010
+ return [broader].concat(await this.getAncestors({ concept: broader, ...config }));
3011
+ }
3012
+ async getNarrower({ concept, ...config }) {
3013
+ if (!concept || !concept.uri) {
3014
+ throw new InvalidOrMissingParameterError({ parameter: "concept" });
3015
+ }
3016
+ if (concept.narrower && concept.narrower[0] !== null) {
3017
+ return concept.narrower;
3018
+ }
3019
+ if (!this._scheme) {
3020
+ await this.getSchemes(config);
3021
+ }
3022
+ concept = data2[this._scheme.uri].concepts[concept.uri];
3023
+ return (concept && concept.narrower || []).map((c) => data2[this._scheme.uri].concepts[c.uri]).map(this._removeNarrower);
3024
+ }
3025
+ async search({ search, scheme, limit = 100 }) {
3026
+ if (!scheme || !scheme.uri) {
3027
+ throw new InvalidOrMissingParameterError({ parameter: "scheme" });
3028
+ }
3029
+ if (!search) {
3030
+ throw new InvalidOrMissingParameterError({ parameter: "search" });
3031
+ }
3032
+ if (!scheme || !scheme.uri) {
3033
+ throw new InvalidOrMissingParameterError({ parameter: "scheme", message: "Missing scheme URI" });
3034
+ }
3035
+ if (!this._scheme) {
3036
+ await this.getSchemes();
3037
+ }
3038
+ if (!import_jskos_tools11.default.compare(scheme, this._scheme)) {
3039
+ throw new InvalidOrMissingParameterError({ parameter: "scheme", message: "Requested vocabulary seems to be unsupported by this API." });
3040
+ }
3041
+ const result = await data2[this._scheme.uri].searchIndex.search(search);
3042
+ return result.map((uri) => data2[this._scheme.uri].concepts[uri]).map(this._removeNarrower).slice(0, limit);
3043
+ }
3044
+ async suggest(config) {
3045
+ config._raw = true;
3046
+ const concepts = await this.search(config);
3047
+ const result = [config.search, [], [], []];
3048
+ for (let concept of concepts) {
3049
+ const notation = import_jskos_tools11.default.notation(concept);
3050
+ const label = import_jskos_tools11.default.prefLabel(concept);
3051
+ result[1].push((notation ? notation + " " : "") + label);
3052
+ result[2].push("");
3053
+ result[3].push(concept.uri);
3054
+ }
3055
+ if (concepts._totalCount != void 0) {
3056
+ result._totalCount = concepts._totalCount;
3057
+ } else {
3058
+ result._totalCount = concepts.length;
3059
+ }
3060
+ return result;
3061
+ }
3062
+ };
3063
+ MyCoReProvider.providerName = "MyCoRe";
3064
+ MyCoReProvider.providerType = "http://bartoc.org/api-type/mycore";
3065
+
2827
3066
  // src/lib/CocodaSDK.js
2828
3067
  var providers = {
2829
3068
  [BaseProvider.providerName]: BaseProvider,
@@ -3009,7 +3248,7 @@ var CocodaSDK = class {
3009
3248
  scheme._registry = registry;
3010
3249
  scheme.__DETAILSLOADED__ = 1;
3011
3250
  scheme.type = scheme.type || ["http://www.w3.org/2004/02/skos/core#ConceptScheme"];
3012
- let otherScheme = schemes.find((s) => import_jskos_tools11.default.compare(s, scheme)), prio, otherPrio, override = false;
3251
+ let otherScheme = schemes.find((s) => import_jskos_tools12.default.compare(s, scheme)), prio, otherPrio, override = false;
3013
3252
  if (otherScheme) {
3014
3253
  prio = this.config.registries.indexOf(registry);
3015
3254
  if (prio != -1) {
@@ -3031,19 +3270,19 @@ var CocodaSDK = class {
3031
3270
  }
3032
3271
  if (!otherScheme || override) {
3033
3272
  if (override) {
3034
- let otherSchemeIndex = schemes.findIndex((s) => import_jskos_tools11.default.compare(s, otherScheme));
3273
+ let otherSchemeIndex = schemes.findIndex((s) => import_jskos_tools12.default.compare(s, otherScheme));
3035
3274
  if (otherSchemeIndex != -1) {
3036
3275
  schemes.splice(otherSchemeIndex, 1);
3037
3276
  }
3038
- scheme = import_jskos_tools11.default.merge(scheme, import_omit.default(otherScheme, ["concepts", "topConcepts"]), { mergeUris: true, skipPaths: ["_registry"] });
3277
+ scheme = import_jskos_tools12.default.merge(scheme, import_omit.default(otherScheme, ["concepts", "topConcepts"]), { mergeUris: true, skipPaths: ["_registry"] });
3039
3278
  }
3040
3279
  scheme._registry = registry;
3041
3280
  schemes.push(scheme);
3042
3281
  } else {
3043
- const index = schemes.findIndex((s) => import_jskos_tools11.default.compare(s, scheme));
3282
+ const index = schemes.findIndex((s) => import_jskos_tools12.default.compare(s, scheme));
3044
3283
  if (index != -1) {
3045
3284
  const otherSchemeRegistry = schemes[index]._registry;
3046
- schemes[index] = import_jskos_tools11.default.merge(schemes[index], import_omit.default(scheme, ["concepts", "topConcepts"]), { mergeUris: true, skipPaths: ["_registry"] });
3285
+ schemes[index] = import_jskos_tools12.default.merge(schemes[index], import_omit.default(scheme, ["concepts", "topConcepts"]), { mergeUris: true, skipPaths: ["_registry"] });
3047
3286
  schemes[index]._registry = otherSchemeRegistry;
3048
3287
  }
3049
3288
  }
@@ -3065,7 +3304,7 @@ var CocodaSDK = class {
3065
3304
  scheme._registry = newRegistry;
3066
3305
  }
3067
3306
  });
3068
- return import_jskos_tools11.default.sortSchemes(schemes.filter(Boolean));
3307
+ return import_jskos_tools12.default.sortSchemes(schemes.filter(Boolean));
3069
3308
  }
3070
3309
  registryForScheme(scheme) {
3071
3310
  let registry = scheme._registry;
@@ -3076,7 +3315,7 @@ var CocodaSDK = class {
3076
3315
  const url = config.url;
3077
3316
  if (registryCache[url]) {
3078
3317
  const registry2 = registryCache[url];
3079
- if (Array.isArray(registry2._jskos.schemes) && !import_jskos_tools11.default.isContainedIn(scheme, registry2._jskos.schemes)) {
3318
+ if (Array.isArray(registry2._jskos.schemes) && !import_jskos_tools12.default.isContainedIn(scheme, registry2._jskos.schemes)) {
3080
3319
  registry2._jskos.schemes.push(scheme);
3081
3320
  }
3082
3321
  return registry2;
@@ -3121,11 +3360,13 @@ function addAllProviders(_cdk) {
3121
3360
  LocApiProvider,
3122
3361
  LocalMappingsProvider,
3123
3362
  MappingsApiProvider,
3363
+ MyCoReProvider,
3124
3364
  OccurrencesApiProvider,
3125
3365
  ReconciliationApiProvider,
3126
3366
  SkohubProvider,
3127
3367
  SkosmosApiProvider,
3128
3368
  addAllProviders,
3129
3369
  cdk,
3130
- errors
3370
+ errors,
3371
+ utils
3131
3372
  });