cocoda-sdk 3.4.13 → 3.5.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.
|
@@ -185,7 +185,8 @@ class ConceptApiProvider extends BaseProvider {
|
|
|
185
185
|
* @returns {Object[]} array of JSKOS concept objects
|
|
186
186
|
*/
|
|
187
187
|
async getConcepts({ concepts, ...config }) {
|
|
188
|
-
|
|
188
|
+
const url = this._api.concepts || this._api.data;
|
|
189
|
+
if (!url) {
|
|
189
190
|
throw new errors.MissingApiUrlError();
|
|
190
191
|
}
|
|
191
192
|
if (!concepts) {
|
|
@@ -198,7 +199,7 @@ class ConceptApiProvider extends BaseProvider {
|
|
|
198
199
|
return this.axios({
|
|
199
200
|
...config,
|
|
200
201
|
method: "get",
|
|
201
|
-
url
|
|
202
|
+
url,
|
|
202
203
|
params: {
|
|
203
204
|
...this._defaultParams,
|
|
204
205
|
// ? What should the default limit be?
|
|
@@ -216,24 +217,29 @@ class ConceptApiProvider extends BaseProvider {
|
|
|
216
217
|
* @returns {Object[]} array of JSKOS concept objects
|
|
217
218
|
*/
|
|
218
219
|
async getNarrower({ concept, ...config }) {
|
|
219
|
-
if (!this._api.narrower) {
|
|
220
|
-
throw new errors.MissingApiUrlError();
|
|
221
|
-
}
|
|
222
220
|
if (!concept || !concept.uri) {
|
|
223
221
|
throw new errors.InvalidOrMissingParameterError({ parameter: "concept" });
|
|
224
222
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
223
|
+
if (this._api.narrower) {
|
|
224
|
+
return this.axios({
|
|
225
|
+
...config,
|
|
226
|
+
method: "get",
|
|
227
|
+
url: this._api.narrower,
|
|
228
|
+
params: {
|
|
229
|
+
...this._defaultParams,
|
|
230
|
+
// ? What should the default limit be?
|
|
231
|
+
limit: 1e4,
|
|
232
|
+
...config.params || {},
|
|
233
|
+
uri: concept.uri
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
} else {
|
|
237
|
+
const conf2 = { params: {}, ...config };
|
|
238
|
+
conf2.params.properties = "narrower";
|
|
239
|
+
const response = await this.getConcepts({ concepts: [concept], ...conf2 });
|
|
240
|
+
const narrower = response[0]?.narrower || [];
|
|
241
|
+
return narrower.length ? this.getConcepts({ concepts: narrower, ...config }) : [];
|
|
242
|
+
}
|
|
237
243
|
}
|
|
238
244
|
/**
|
|
239
245
|
* Returns ancestor concepts for a concept.
|
|
@@ -243,24 +249,29 @@ class ConceptApiProvider extends BaseProvider {
|
|
|
243
249
|
* @returns {Object[]} array of JSKOS concept objects
|
|
244
250
|
*/
|
|
245
251
|
async getAncestors({ concept, ...config }) {
|
|
246
|
-
if (!this._api.ancestors) {
|
|
247
|
-
throw new errors.MissingApiUrlError();
|
|
248
|
-
}
|
|
249
252
|
if (!concept || !concept.uri) {
|
|
250
253
|
throw new errors.InvalidOrMissingParameterError({ parameter: "concept" });
|
|
251
254
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
255
|
+
if (this._api.ancestors) {
|
|
256
|
+
return this.axios({
|
|
257
|
+
...config,
|
|
258
|
+
method: "get",
|
|
259
|
+
url: this._api.ancestors,
|
|
260
|
+
params: {
|
|
261
|
+
...this._defaultParams,
|
|
262
|
+
// ? What should the default limit be?
|
|
263
|
+
limit: 1e4,
|
|
264
|
+
...config.params || {},
|
|
265
|
+
uri: concept.uri
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
} else {
|
|
269
|
+
const conf2 = { params: {}, ...config };
|
|
270
|
+
conf2.params.properties = "ancestors";
|
|
271
|
+
const response = await this.getConcepts({ concepts: [concept], ...conf2 });
|
|
272
|
+
const ancestors = response[0]?.ancestors || [];
|
|
273
|
+
return ancestors.length ? this.getConcepts({ concepts: ancestors, ...config }) : [];
|
|
274
|
+
}
|
|
264
275
|
}
|
|
265
276
|
/**
|
|
266
277
|
* Returns suggestion result in OpenSearch Suggest Format.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cocoda-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "SDK for Cocoda",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -51,24 +51,24 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"axios-mock-adapter": "^2.1.0",
|
|
53
53
|
"clean-jsdoc-theme": "^4.3.0",
|
|
54
|
-
"esbuild": "~0.
|
|
54
|
+
"esbuild": "~0.27.0",
|
|
55
55
|
"esbuild-plugin-ifdef": "^1.0.1",
|
|
56
|
-
"eslint": "~9.
|
|
57
|
-
"eslint-config-gbv": "~2.
|
|
58
|
-
"glob": "^
|
|
56
|
+
"eslint": "~9.39",
|
|
57
|
+
"eslint-config-gbv": "~2.7",
|
|
58
|
+
"glob": "^13.0.0",
|
|
59
59
|
"husky": "^9.1.7",
|
|
60
60
|
"jsdoc": "^4.0.4",
|
|
61
61
|
"license-checker": "^25.0.1",
|
|
62
|
-
"lint-staged": "^
|
|
62
|
+
"lint-staged": "^16.2.7",
|
|
63
63
|
"mocha": "^11.0.1",
|
|
64
64
|
"yesno": "^0.4.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"axios": "^1.7.9",
|
|
68
|
-
"flexsearch": "~0.
|
|
68
|
+
"flexsearch": "~0.8.0",
|
|
69
69
|
"jskos-tools": "^1.0.43",
|
|
70
70
|
"localforage": "^1.10.0",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
|
-
"uuid": "^
|
|
72
|
+
"uuid": "^13.0.0"
|
|
73
73
|
}
|
|
74
74
|
}
|