cocoda-sdk 3.6.0 → 3.6.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.
@@ -1,8 +1,7 @@
1
1
  import BaseProvider from "./base-provider.js";
2
2
  import jskos from "jskos-tools";
3
- import * as _ from "../utils/lodash.js";
4
3
  import * as errors from "../errors/index.js";
5
- import * as utils from "../utils/index.js";
4
+ import { concatUrl, deepEqual } from "../utils/index.js";
6
5
  const cache = {};
7
6
  class OccurrencesApiProvider extends BaseProvider {
8
7
  static supports = {
@@ -30,7 +29,7 @@ class OccurrencesApiProvider extends BaseProvider {
30
29
  if (this._occurrencesSupportedSchemes && this._occurrencesSupportedSchemes.length) {
31
30
  } else {
32
31
  try {
33
- const url = utils.concatUrl(this._api.api, "voc");
32
+ const url = concatUrl(this._api.api, "voc");
34
33
  const data = await this.axios({
35
34
  method: "get",
36
35
  url
@@ -56,30 +55,30 @@ class OccurrencesApiProvider extends BaseProvider {
56
55
  async getMappings(config) {
57
56
  const occurrences = await this.getOccurrences(config);
58
57
  const from = config.from;
59
- const fromScheme = _.get(from, "inScheme[0]") || config.fromScheme;
58
+ const fromScheme = from?.inScheme?.[0] || config.fromScheme;
60
59
  const to = config.to;
61
- const toScheme = _.get(to, "inScheme[0]") || config.toScheme;
60
+ const toScheme = to?.inScheme?.[0] || config.toScheme;
62
61
  const mappings = [];
63
62
  for (let occurrence of occurrences) {
64
63
  if (!occurrence) {
65
64
  continue;
66
65
  }
67
66
  let mapping = {};
68
- mapping.from = _.get(occurrence, "memberSet[0]");
67
+ mapping.from = occurrence?.memberSet?.[0];
69
68
  if (mapping.from) {
70
69
  mapping.from = { memberSet: [mapping.from] };
71
70
  } else {
72
71
  mapping.from = null;
73
72
  }
74
- mapping.fromScheme = _.get(occurrence, "memberSet[0].inScheme[0]");
75
- mapping.to = _.get(occurrence, "memberSet[1]");
73
+ mapping.fromScheme = occurrence?.memberSet?.[0]?.inScheme?.[0];
74
+ mapping.to = occurrence?.memberSet?.[1];
76
75
  if (mapping.to) {
77
76
  mapping.to = { memberSet: [mapping.to] };
78
77
  } else {
79
78
  mapping.to = { memberSet: [] };
80
79
  }
81
- mapping.toScheme = _.get(occurrence, "memberSet[1].inScheme[0]");
82
- if (from && jskos.compare(from, _.get(mapping, "to.memberSet[0]")) || to && jskos.compare(to, _.get(mapping, "from.memberSet[0]"))) {
80
+ mapping.toScheme = occurrence?.memberSet?.[1]?.inScheme?.[0];
81
+ if (from && jskos.compare(from, mapping?.to?.memberSet?.[0]) || to && jskos.compare(to, mapping?.from?.memberSet?.[0])) {
83
82
  [mapping.from, mapping.fromScheme, mapping.to, mapping.toScheme] = [mapping.to, mapping.toScheme, mapping.from, mapping.fromScheme];
84
83
  }
85
84
  if (!mapping.fromScheme && fromScheme) {
@@ -109,7 +108,7 @@ class OccurrencesApiProvider extends BaseProvider {
109
108
  let promises = [];
110
109
  concepts = (concepts || []).concat([from, to]).filter((c) => !!c);
111
110
  for (let concept of concepts) {
112
- promises.push(this._occurrencesIsSupported(_.get(concept, "inScheme[0]")).then((supported) => {
111
+ promises.push(this._occurrencesIsSupported(concept?.inScheme?.[0]).then((supported) => {
113
112
  if (supported && concept.uri) {
114
113
  return concept.uri;
115
114
  } else {
@@ -134,7 +133,7 @@ class OccurrencesApiProvider extends BaseProvider {
134
133
  }));
135
134
  }
136
135
  const results = await Promise.all(promises);
137
- let occurrences = _.concat([], ...results);
136
+ let occurrences = results.flat();
138
137
  let existingUris = [];
139
138
  let indexesToDelete = [];
140
139
  for (let i = 0; i < occurrences.length; i += 1) {
@@ -165,9 +164,7 @@ class OccurrencesApiProvider extends BaseProvider {
165
164
  * @param {Object} config passthrough of config parameter for axios request
166
165
  */
167
166
  async _getOccurrences(config) {
168
- let resultsFromCache = this._cache.find((item) => {
169
- return _.isEqual(item.config.params, config.params);
170
- });
167
+ let resultsFromCache = this._cache.find((item) => deepEqual(item.config.params, config.params));
171
168
  if (resultsFromCache) {
172
169
  return resultsFromCache.data;
173
170
  }
@@ -16,7 +16,7 @@ class OlsApiProvider extends BaseProvider {
16
16
  };
17
17
  constructor(config) {
18
18
  super(config);
19
- this.endpoint = config.endpoint;
19
+ this.endpoint = config.endpoint || config.uri;
20
20
  }
21
21
  /**
22
22
  * Used by `registryForScheme` (see src/lib/CocodaSDK.js) to determine a provider config for a concept schceme.
@@ -95,7 +95,7 @@ class OlsApiProvider extends BaseProvider {
95
95
  }
96
96
  if (term["http://www.w3.org/2000/01/rdf-schema#label"]) {
97
97
  concept.prefLabel = {};
98
- concept.prefLabel[lan] = term["http://www.w3.org/2000/01/rdf-schema#label"];
98
+ concept.prefLabel[lan] = term["http://www.w3.org/2000/01/rdf-schema#label"].value || term["http://www.w3.org/2000/01/rdf-schema#label"];
99
99
  }
100
100
  concept.type = [
101
101
  "http://www.w3.org/2004/02/skos/core#Concept",
@@ -261,11 +261,8 @@ class OlsApiProvider extends BaseProvider {
261
261
  async getTop({ scheme }) {
262
262
  const VOCID = await this._getSchemeVOCID(scheme);
263
263
  if (VOCID) {
264
- let url = this._getApiUrl(["ontologies", VOCID, "classes"], { hasDirectParents: "false" });
265
- let response = await this._request(url);
266
- if (response?.elements) {
267
- return Promise.all(response.elements.map((item) => this._termToJSKOS(item)));
268
- }
264
+ let response = await this._paginate(["ontologies", VOCID, "classes"], { hasDirectParents: "false" }, null);
265
+ return Promise.all(response.map((item) => this._termToJSKOS(item)));
269
266
  }
270
267
  return [];
271
268
  }
@@ -281,22 +278,16 @@ class OlsApiProvider extends BaseProvider {
281
278
  async getNarrower({ concept }) {
282
279
  const { VOCID, iri } = await this._splitConcept(concept);
283
280
  if (VOCID && iri) {
284
- let url = this._getApiUrl(["ontologies", VOCID, "classes", iri, "children"]);
285
- let response = await this._request(url);
286
- if (response?.elements) {
287
- return Promise.all(response.elements.map((item) => this._termToJSKOS(item)));
288
- }
281
+ const items = await this._paginate(["ontologies", VOCID, "classes", iri, "children"], {}, 0);
282
+ return Promise.all(items.map((item) => this._termToJSKOS(item)));
289
283
  }
290
284
  return [];
291
285
  }
292
286
  async getAncestors({ concept }) {
293
287
  const { VOCID, iri } = await this._splitConcept(concept);
294
288
  if (VOCID && iri) {
295
- let url = this._getApiUrl(["ontologies", VOCID, "classes", iri, "ancestors"]);
296
- let response = await this._request(url);
297
- if (response?.elements) {
298
- return Promise.all(response.elements.map((item) => this._termToJSKOS(item)));
299
- }
289
+ let response = await this._paginate(["ontologies", VOCID, "classes", iri, "ancestors"], {}, null);
290
+ return Promise.all(response.map((item) => this._termToJSKOS(item)));
300
291
  }
301
292
  return [];
302
293
  }
@@ -1,7 +1,7 @@
1
1
  import BaseProvider from "./base-provider.js";
2
2
  import jskos from "jskos-tools";
3
- import * as _ from "../utils/lodash.js";
4
3
  import * as errors from "../errors/index.js";
4
+ import { deepEqual } from "../utils/index.js";
5
5
  const cache = {};
6
6
  class ReconciliationApiProvider extends BaseProvider {
7
7
  static supports = {
@@ -27,13 +27,13 @@ class ReconciliationApiProvider extends BaseProvider {
27
27
  */
28
28
  async getMappings({ from, to, mode, ...config }) {
29
29
  let schemes = [];
30
- if (_.isArray(this.schemes)) {
30
+ if (Array.isArray(this.schemes)) {
31
31
  schemes = this.schemes;
32
32
  }
33
33
  let swap;
34
34
  let concept;
35
- let fromConceptScheme = _.get(from, "inScheme[0]");
36
- let toConceptScheme = _.get(to, "inScheme[0]");
35
+ let fromConceptScheme = from?.inScheme?.[0];
36
+ let toConceptScheme = to?.inScheme?.[0];
37
37
  let fromScheme;
38
38
  let toScheme;
39
39
  if (!from || jskos.isContainedIn(fromConceptScheme, schemes)) {
@@ -60,11 +60,11 @@ class ReconciliationApiProvider extends BaseProvider {
60
60
  if (!language) {
61
61
  throw new errors.InvalidOrMissingParameterError({ parameter: swap ? "to" : "from", message: "Missing language" });
62
62
  }
63
- let altLabels = _.get(concept, `altLabel.${language}`, []);
64
- if (_.isString(altLabels)) {
63
+ let altLabels = concept?.altLabel?.[language] ?? [];
64
+ if (typeof altLabels === "string") {
65
65
  altLabels = [altLabels];
66
66
  }
67
- let prefLabel = _.get(concept, `prefLabel.${language}`);
67
+ let prefLabel = concept?.prefLabel?.[language];
68
68
  let labels = altLabels.concat([prefLabel]);
69
69
  labels = [prefLabel];
70
70
  let { url, data: results } = await this._getReconciliationResults({ ...config, labels, language });
@@ -82,7 +82,7 @@ class ReconciliationApiProvider extends BaseProvider {
82
82
  }
83
83
  return a.id.length - b.id.length;
84
84
  });
85
- let namespace = _.get(toScheme, "namespace", "");
85
+ let namespace = toScheme?.namespace ?? "";
86
86
  let mappings = results.map((result) => ({
87
87
  fromScheme,
88
88
  from: { memberSet: [concept] },
@@ -120,9 +120,7 @@ class ReconciliationApiProvider extends BaseProvider {
120
120
  */
121
121
  async _getReconciliationResults({ labels, language, ...config }) {
122
122
  labels = labels.sort();
123
- let resultsFromCache = this._cache.find((item) => {
124
- return _.isEqual(item.labels, labels) && item.language == language;
125
- });
123
+ let resultsFromCache = this._cache.find((item) => deepEqual(item.labels, labels) && item.language == language);
126
124
  if (resultsFromCache) {
127
125
  return resultsFromCache;
128
126
  }
@@ -139,7 +137,8 @@ class ReconciliationApiProvider extends BaseProvider {
139
137
  url = url.replace("{language}", language);
140
138
  }
141
139
  const encodedData = `queries=${encodeURIComponent(JSON.stringify(queries))}`;
142
- _.set(config, ["headers", "Content-Type"], "application/x-www-form-urlencoded");
140
+ config.headers ||= {};
141
+ config.headers["Content-Type"] = "application/x-www-form-urlencoded";
143
142
  let data = await this.axios({
144
143
  ...config,
145
144
  method: "post",
@@ -1,5 +1,4 @@
1
1
  import BaseProvider from "./base-provider.js";
2
- import * as _ from "../utils/lodash.js";
3
2
  import * as errors from "../errors/index.js";
4
3
  import jskos from "jskos-tools";
5
4
  import FlexSearch from "flexsearch";
@@ -66,7 +65,7 @@ class SkohubProvider extends BaseProvider {
66
65
  throw new errors.InvalidRequestError({ message: `Tried to load unsupported scheme (${scheme && scheme.uri})` });
67
66
  }
68
67
  const uri = schemeFromList.uri;
69
- uris = _.uniq(uris.concat(jskos.getAllUris(schemeFromList)));
68
+ uris = [...new Set(uris.concat(jskos.getAllUris(schemeFromList)))];
70
69
  let postfix = ".json";
71
70
  if (uri.endsWith("/")) {
72
71
  postfix = "index.json";
@@ -147,7 +146,7 @@ class SkohubProvider extends BaseProvider {
147
146
  return scheme.topConcepts || [];
148
147
  }
149
148
  async getConcepts({ concepts, ...config }) {
150
- if (!_.isArray(concepts)) {
149
+ if (!Array.isArray(concepts)) {
151
150
  concepts = [concepts];
152
151
  }
153
152
  return (await Promise.all(concepts.map(({ uri }) => this._loadConcept({ ...config, uri })))).filter(Boolean);
@@ -1,6 +1,5 @@
1
1
  import BaseProvider from "./base-provider.js";
2
2
  import jskos from "jskos-tools";
3
- import * as _ from "../utils/lodash.js";
4
3
  import * as errors from "../errors/index.js";
5
4
  class SkosmosApiProvider extends BaseProvider {
6
5
  static supports = {
@@ -46,7 +45,7 @@ class SkosmosApiProvider extends BaseProvider {
46
45
  * @private
47
46
  */
48
47
  _getApiUrl(scheme, endpoint, params) {
49
- const VOCID = scheme && scheme.VOCID || _.get(this.schemes.find((s) => jskos.compare(s, scheme)), "VOCID");
48
+ const VOCID = scheme?.VOCID || this.schemes.find((s) => jskos.compare(s, scheme))?.VOCID;
50
49
  if (!VOCID) {
51
50
  throw new errors.InvalidOrMissingParameterError({ parameter: "scheme", message: "Missing scheme or VOCID property on scheme" });
52
51
  }
@@ -62,7 +61,7 @@ class SkosmosApiProvider extends BaseProvider {
62
61
  * @private
63
62
  */
64
63
  _getDataUrl(concept, { addFormatParameter = true } = {}) {
65
- const scheme = _.get(concept, "inScheme[0]");
64
+ const scheme = concept?.inScheme?.[0];
66
65
  if (!concept || !concept.uri) {
67
66
  throw new errors.InvalidOrMissingParameterError({ parameter: "concept", message: "Missing concept URI" });
68
67
  }
@@ -117,29 +116,33 @@ class SkosmosApiProvider extends BaseProvider {
117
116
  concept.inScheme = [scheme];
118
117
  }
119
118
  let prefLabel = skosmosConcept.matchedPrefLabel || skosmosConcept.prefLabel || skosmosConcept.label;
120
- if (_.isString(prefLabel)) {
121
- _.set(concept, `prefLabel.${language}`, prefLabel);
119
+ if (typeof prefLabel === "string") {
120
+ concept.prefLabel ||= {};
121
+ concept.prefLabel[language] = prefLabel;
122
122
  } else {
123
- if (prefLabel && !_.isArray(prefLabel)) {
123
+ if (prefLabel && !Array.isArray(prefLabel)) {
124
124
  prefLabel = [prefLabel];
125
125
  }
126
126
  for (let label of prefLabel || []) {
127
- _.set(concept, `prefLabel.${label.lang}`, label.value);
127
+ concept.prefLabel ||= {};
128
+ concept.prefLabel[label.lang] = label.value;
128
129
  }
129
130
  }
130
131
  let altLabel = skosmosConcept.altLabel;
131
- if (_.isString(altLabel)) {
132
- _.set(concept, `altLabel.${language}`, [altLabel]);
132
+ if (typeof altLabel === "string") {
133
+ concept.altLabel ||= {};
134
+ concept.altLabel[language] = altLabel;
133
135
  } else {
134
- if (altLabel && !_.isArray(altLabel)) {
136
+ if (altLabel && !Array.isArray(altLabel)) {
135
137
  altLabel = [altLabel];
136
138
  }
137
139
  for (let label of altLabel || []) {
138
- if (_.get(concept, `altLabel.${label.lang}`)) {
140
+ if (concept?.altLabel?.[label.lang]) {
139
141
  concept.altLabel[label.lang].push(label.value);
140
- concept.altLabel[label.lang] = _.uniq(concept.altLabel[label.lang]);
142
+ concept.altLabel[label.lang] = [...new Set(concept.altLabel[label.lang])];
141
143
  } else {
142
- _.set(concept, `altLabel.${label.lang}`, [label.value]);
144
+ concept.altLabel ||= {};
145
+ concept.altLabel[label.lang] = [label.value];
143
146
  }
144
147
  }
145
148
  }
@@ -148,17 +151,17 @@ class SkosmosApiProvider extends BaseProvider {
148
151
  concept.notation = [notation.value || notation];
149
152
  }
150
153
  if (skosmosConcept.broader) {
151
- if (!_.isArray(skosmosConcept.broader)) {
154
+ if (!Array.isArray(skosmosConcept.broader)) {
152
155
  skosmosConcept.broader = [skosmosConcept.broader];
153
156
  }
154
- concept.broader = skosmosConcept.broader.map((concept2) => _.isString(concept2) ? { uri: concept2 } : concept2);
157
+ concept.broader = skosmosConcept.broader.map((uri) => typeof uri === "string" ? { uri } : uri);
155
158
  }
156
159
  if (skosmosConcept.hasChildren === true) {
157
160
  concept.narrower = [null];
158
161
  } else if (skosmosConcept.hasChildren === false) {
159
162
  concept.narrower = [];
160
163
  }
161
- if (skosmosConcept.type && !_.isArray(skosmosConcept.type)) {
164
+ if (skosmosConcept.type && !Array.isArray(skosmosConcept.type)) {
162
165
  skosmosConcept.type = [skosmosConcept.type];
163
166
  }
164
167
  concept.type = concept.type || [];
@@ -172,10 +175,36 @@ class SkosmosApiProvider extends BaseProvider {
172
175
  }
173
176
  concept.type.push(type);
174
177
  }
175
- concept.type = _.uniq(concept.type);
178
+ concept.type = [...new Set(concept.type)];
176
179
  if (!concept.type.length) {
177
180
  concept.type = ["http://www.w3.org/2004/02/skos/core#Concept"];
178
181
  }
182
+ const map = {
183
+ "skos:definition": "definition",
184
+ "skos:note": "note",
185
+ "skos:scopeNote": "scopeNote",
186
+ "skos:example": "example",
187
+ "skos:historyNote": "historyNote",
188
+ "skos:editorialNote": "editorialNote",
189
+ "skos:changeNote": "changeNote"
190
+ };
191
+ for (let key in map) {
192
+ if (skosmosConcept[key]) {
193
+ const value = skosmosConcept[key];
194
+ if (value.lang && value.value) {
195
+ concept[map[key]] = {
196
+ [value.lang]: value.value
197
+ };
198
+ } else if (Array.isArray(value)) {
199
+ concept[map[key]] = {};
200
+ for (let val of value) {
201
+ if (val.lang && val.value) {
202
+ concept[map[key]][val.lang] = val.value;
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
179
208
  return concept;
180
209
  }
181
210
  /**
@@ -196,7 +225,8 @@ class SkosmosApiProvider extends BaseProvider {
196
225
  const resultScheme = data.conceptschemes.find((s) => jskos.compare(s, scheme));
197
226
  const label = resultScheme && (resultScheme.prefLabel || resultScheme.label || resultScheme.title);
198
227
  if (label) {
199
- _.set(scheme, `prefLabel.${this._language}`, label);
228
+ scheme.prefLabel ||= {};
229
+ scheme.prefLabel[this._language] = label;
200
230
  }
201
231
  schemes.push(scheme);
202
232
  this._approvedSchemes = this._approvedSchemes || [];
@@ -222,7 +252,8 @@ class SkosmosApiProvider extends BaseProvider {
222
252
  if (!schemeUri) {
223
253
  throw new errors.InvalidOrMissingParameterError({ parameter: "scheme", message: "Missing or unsupported scheme or VOCID property on scheme" });
224
254
  }
225
- _.set(config, "params.scheme", schemeUri);
255
+ config.params ||= {};
256
+ config.params.scheme = schemeUri;
226
257
  const response = await this.axios({
227
258
  ...config,
228
259
  method: "get",
@@ -247,31 +278,31 @@ class SkosmosApiProvider extends BaseProvider {
247
278
  * @returns {Object[]} array of JSKOS concept objects
248
279
  */
249
280
  async getConcepts({ concepts, ...config }) {
250
- if (!_.isArray(concepts)) {
281
+ if (!Array.isArray(concepts)) {
251
282
  concepts = [concepts];
252
283
  }
253
284
  concepts = concepts.map((c) => ({ uri: c.uri, inScheme: c.inScheme }));
254
285
  const newConcepts = [];
255
286
  for (let concept of concepts) {
256
- const url = this._getDataUrl(concept, { addFormatParameter: false });
287
+ if (!concept || !concept.uri) {
288
+ throw new errors.InvalidOrMissingParameterError({ parameter: "concept", message: "Missing concept URI" });
289
+ }
290
+ const params = { uri: concept.uri, format: "application/json" };
291
+ const url = this._getApiUrl(concept?.inScheme?.[0], "/data", params);
257
292
  if (!url) {
258
293
  continue;
259
294
  }
260
295
  const result = await this.axios({
261
296
  ...config,
262
297
  method: "get",
263
- url,
264
- params: {
265
- uri: concept.uri,
266
- format: "application/json"
267
- }
298
+ url
268
299
  });
269
- const resultConcept = result && result.graph && result.graph.find((c) => jskos.compare(c, concept));
300
+ const resultConcept = result?.graph?.find((c) => jskos.compare(c, concept));
270
301
  if (resultConcept) {
271
302
  const newConcept = this._toJskosConcept(resultConcept, { concept, result });
272
303
  for (let type of ["broader", "narrower"]) {
273
304
  let relatives = resultConcept[type] || newConcept[type];
274
- if (relatives && !_.isArray(relatives)) {
305
+ if (relatives && !Array.isArray(relatives)) {
275
306
  relatives = [relatives];
276
307
  }
277
308
  if (!relatives) {
@@ -298,7 +329,8 @@ class SkosmosApiProvider extends BaseProvider {
298
329
  }
299
330
  const scheme = concept.inScheme[0];
300
331
  const url = this._getApiUrl(scheme, "/children");
301
- _.set(config, "params.uri", concept.uri);
332
+ config.params ||= {};
333
+ config.params.uri = concept.uri;
302
334
  const response = await this.axios({
303
335
  ...config,
304
336
  method: "get",
@@ -320,7 +352,8 @@ class SkosmosApiProvider extends BaseProvider {
320
352
  }
321
353
  const scheme = concept.inScheme[0];
322
354
  const url = this._getApiUrl(scheme, "/broaderTransitive");
323
- _.set(config, "params.uri", concept.uri);
355
+ config.params ||= {};
356
+ config.params.uri = concept.uri;
324
357
  const response = await this.axios({
325
358
  ...config,
326
359
  method: "get",
@@ -330,10 +363,10 @@ class SkosmosApiProvider extends BaseProvider {
330
363
  let uri = concept.uri;
331
364
  while (uri) {
332
365
  if (uri != concept.uri) {
333
- const ancestor = _.get(response, `broaderTransitive["${uri}"]`);
366
+ const ancestor = response?.broaderTransitive?.[uri];
334
367
  ancestors = ancestors.concat([ancestor]);
335
368
  }
336
- uri = _.get(response, `broaderTransitive["${uri}"].broader[0]`);
369
+ uri = response?.broaderTransitive?.[uri]?.broader?.[0];
337
370
  }
338
371
  const concepts = ancestors.map((c) => this._toJskosConcept(c, { scheme })).filter((c) => c.uri != concept.uri);
339
372
  return concepts;
@@ -350,10 +383,11 @@ class SkosmosApiProvider extends BaseProvider {
350
383
  */
351
384
  async search({ search, scheme, limit, types = [], ...config }) {
352
385
  const url = this._getApiUrl(scheme, "/search");
353
- _.set(config, "params.query", `${search}*`);
354
- _.set(config, "params.unique", 1);
355
- _.set(config, "params.maxhits", limit || 100);
356
- _.set(config, "params.type", types.join(" "));
386
+ config.params ||= {};
387
+ config.params.query = `${search}*`;
388
+ config.params.unique = 1;
389
+ config.params.maxhits = limit || 100;
390
+ config.params.type = types.join(" ");
357
391
  const response = await this.axios({
358
392
  ...config,
359
393
  method: "get",
@@ -377,7 +411,7 @@ class SkosmosApiProvider extends BaseProvider {
377
411
  method: "get",
378
412
  url
379
413
  });
380
- for (let type of response && response.types || []) {
414
+ for (let type of response?.types || []) {
381
415
  if (type.uri == "http://www.w3.org/2004/02/skos/core#Concept") {
382
416
  continue;
383
417
  }
@@ -167,8 +167,29 @@ const listOfCapabilities = [
167
167
  "annotations",
168
168
  "occurrences"
169
169
  ];
170
+ const deepEqual = (a, b) => {
171
+ if (a === b) {
172
+ return true;
173
+ }
174
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
175
+ return false;
176
+ }
177
+ if (Object.keys(a).length === Object.keys(b).length) {
178
+ for (let key in a) {
179
+ if (!(key in b)) {
180
+ return false;
181
+ }
182
+ if (!deepEqual(a[key], b[key])) {
183
+ return false;
184
+ }
185
+ }
186
+ return true;
187
+ }
188
+ return false;
189
+ };
170
190
  export {
171
191
  concatUrl,
192
+ deepEqual,
172
193
  listOfCapabilities,
173
194
  requestMethods,
174
195
  withCustomProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocoda-sdk",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
4
4
  "description": "SDK for Cocoda",
5
5
  "main": "dist/cjs/index.cjs",
6
6
  "module": "dist/esm/index.js",
@@ -72,7 +72,6 @@
72
72
  "flexsearch": "~0.8.0",
73
73
  "jskos-tools": "^1.0.43",
74
74
  "localforage": "^1.10.0",
75
- "lodash": "^4.17.21",
76
75
  "uuid": "^13.0.0"
77
76
  }
78
77
  }
@@ -1,32 +0,0 @@
1
- import get from "lodash/get.js";
2
- import set from "lodash/set.js";
3
- import uniq from "lodash/uniq.js";
4
- import intersection from "lodash/intersection.js";
5
- import union from "lodash/union.js";
6
- import forOwn from "lodash/forOwn.js";
7
- import isArray from "lodash/isArray.js";
8
- import isObject from "lodash/isObject.js";
9
- import isString from "lodash/isString.js";
10
- import isEmpty from "lodash/isEmpty.js";
11
- import isEqual from "lodash/isEqual.js";
12
- import merge from "lodash/merge.js";
13
- import last from "lodash/last.js";
14
- import omit from "lodash/omit.js";
15
- import concat from "lodash/concat.js";
16
- export {
17
- concat,
18
- forOwn,
19
- get,
20
- intersection,
21
- isArray,
22
- isEmpty,
23
- isEqual,
24
- isObject,
25
- isString,
26
- last,
27
- merge,
28
- omit,
29
- set,
30
- union,
31
- uniq
32
- };