cocoda-sdk 3.4.13 → 3.6.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.
- package/README.md +83 -88
- package/dist/cjs/index.cjs +857 -66
- package/dist/cocoda-sdk.js +10 -10
- package/dist/cocoda-sdk.js.LICENSES.txt +3 -3
- package/dist/cocoda-sdk.js.map +4 -4
- package/dist/esm/providers/base-provider.js +30 -1
- package/dist/esm/providers/concept-api-provider.js +45 -34
- package/dist/esm/providers/contexts/context_jskos.js +240 -0
- package/dist/esm/providers/contexts/context_mod.js +59 -0
- package/dist/esm/providers/index.js +4 -0
- package/dist/esm/providers/mod-api-provider.js +452 -0
- package/dist/esm/providers/ols-api-provider.js +325 -0
- package/dist/esm/providers/skosmos-api-provider.js +0 -28
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -10,21 +10,20 @@
|
|
|
10
10
|
- [Install](#install)
|
|
11
11
|
- [Usage](#usage)
|
|
12
12
|
- [Import](#import)
|
|
13
|
-
- [v1 Compatibility](#v1-compatibility)
|
|
14
13
|
- [Configuration](#configuration)
|
|
15
14
|
- [Registries](#registries)
|
|
16
15
|
- [Providers](#providers)
|
|
17
16
|
- [Multiple Instances](#multiple-instances)
|
|
18
17
|
- [Authenticated Requests](#authenticated-requests)
|
|
19
|
-
- [Methods](#methods)
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
18
|
+
- [CDK Methods](#cdk-methods)
|
|
19
|
+
- [General](#general)
|
|
20
|
+
- [Concept Schemes](#concept-schemes)
|
|
21
|
+
- [Concepts](#concepts)
|
|
22
|
+
- [Concordances](#concordances)
|
|
23
|
+
- [Mappings](#mappings)
|
|
24
|
+
- [Annotations](#annotations)
|
|
25
|
+
- [Occurrences](#occurrences)
|
|
26
|
+
- [Types](#types)
|
|
28
27
|
- [Errors](#errors)
|
|
29
28
|
- [Maintainers](#maintainers)
|
|
30
29
|
- [Publish](#publish)
|
|
@@ -36,7 +35,7 @@
|
|
|
36
35
|
npm i cocoda-sdk
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
We
|
|
38
|
+
We also provide a browser bundle <https://cdn.jsdelivr.net/npm/cocoda-sdk@2/dist/cocoda-sdk.js>
|
|
40
39
|
|
|
41
40
|
[](https://www.jsdelivr.com/package/npm/cocoda-sdk)
|
|
42
41
|
|
|
@@ -60,31 +59,6 @@ cocoda-sdk also exports some other members:
|
|
|
60
59
|
- `addAllProviders` - a method that adds all avaiable providers to an instance
|
|
61
60
|
- Can be called without parameters to add to the default instance. Useful if you need all providers.
|
|
62
61
|
|
|
63
|
-
### v1 Compatibility
|
|
64
|
-
cocoda-sdk v2 changed how it is exported and therefore it needs to be included differently.
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
// CommonJS
|
|
68
|
-
// Previously: const cdk = require("cocoda-sdk")
|
|
69
|
-
// Now:
|
|
70
|
-
const { cdk } = require("cocoda-sdk")
|
|
71
|
-
// or: const cdk = require("cocoda-sdk").cdk
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
```js
|
|
75
|
-
// ES6
|
|
76
|
-
// Previously: import * as cdk from "cocoda-sdk"
|
|
77
|
-
// Now:
|
|
78
|
-
import { cdk } from "cocoda-sdk"
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
// Browser
|
|
83
|
-
// Previously the default instance was globally available under `cdk`.
|
|
84
|
-
// Now the module is available under `CDK` with `cdk` as one of its members. To easily make previous code compatible:
|
|
85
|
-
const { cdk } = CDK
|
|
86
|
-
```
|
|
87
|
-
|
|
88
62
|
### Configuration
|
|
89
63
|
cocoda-sdk can be configured after import:
|
|
90
64
|
|
|
@@ -142,6 +116,8 @@ const registry = cdk.initializeRegistry({
|
|
|
142
116
|
registry.getMappings()
|
|
143
117
|
```
|
|
144
118
|
|
|
119
|
+
It's also possible to directly use Registry classes.
|
|
120
|
+
|
|
145
121
|
#### Using Registries From a Configuration
|
|
146
122
|
|
|
147
123
|
If you initialize cocoda-sdk with a [configuration](#configuration), it will initialize all included registries automatically. Those registries are then accessible via `cdk.config.registries`. Alternatively, you can retrieve registries by URI:
|
|
@@ -157,12 +133,13 @@ Providers allow access to different types of APIs.
|
|
|
157
133
|
|
|
158
134
|
The following providers are offered in cocoda-sdk by default:
|
|
159
135
|
- `Base` - the base provider that all other providers have to inherit from
|
|
160
|
-
- `ConceptApi` - access to concept schemes and concepts via [jskos-server]
|
|
136
|
+
- `ConceptApi` - access to concept schemes and concepts via JSKOS API ([jskos-server] and compatible implementations)
|
|
161
137
|
- `MappingsApi` - access to concordances, mappings, and annotations via [jskos-server]
|
|
162
138
|
|
|
163
139
|
The following providers are also exported, but have to be added via `cdk.addProvider`:
|
|
164
140
|
- `LocalMappings` - access to local mappings via [localForage](https://github.com/localForage/localForage) (only available in browser)
|
|
165
141
|
- `SkosmosApi` - access to concept schemes and concepts via a [Skosmos](https://github.com/NatLibFi/Skosmos) API
|
|
142
|
+
- `OlsApi`- access to ontologies via Ontology Lookup Service (OLS) API Version 2 (experimental)
|
|
166
143
|
- `LocApi` - access to concept schemes and concepts via the [Library of Congress Linked Data Service](https://id.loc.gov/)
|
|
167
144
|
- **This integration is currently experimental and only supports LCSH and LCNAF.**
|
|
168
145
|
- `Skohub` - access to concept schemes and concepts via a [SkoHub Vocabs](https://blog.lobid.org/2019/09/27/presenting-skohub-vocabs.html)
|
|
@@ -174,6 +151,7 @@ The following providers are also exported, but have to be added via `cdk.addProv
|
|
|
174
151
|
- `ReconciliationApi` - access to mapping suggestions via a [Reconciliation Service API](https://reconciliation-api.github.io/specs/draft/)
|
|
175
152
|
- `OccurrencesApi` - access to concept occurrences via [occurrences-api](https://github.com/gbv/occurrences-api) (will be changed to [occurrences-server](https://github.com/gbv/occurrences-server) in the future)
|
|
176
153
|
- `LabelSearchSuggestion` - access to mapping suggestions using other registries' search endpoints (using [jskos-server])
|
|
154
|
+
- `ModApi` - (experimental) access to concept schemes and concepts via a [MOD](https://github.com/FAIR-IMPACT/MOD) API
|
|
177
155
|
|
|
178
156
|
To add a provider, append `Provider` to its name and import it together with `cdk`:
|
|
179
157
|
|
|
@@ -186,14 +164,28 @@ Note that in the browser bundle, all providers listed above are included and do
|
|
|
186
164
|
|
|
187
165
|
Please refer to each provider's documentation for how exactly to configure that provider: [Documentation](https://gbv.github.io/cocoda-sdk/)
|
|
188
166
|
|
|
167
|
+
#### Custom providers
|
|
168
|
+
|
|
189
169
|
It is also possible to add custom providers that inherit from BaseProvider:
|
|
190
170
|
|
|
191
171
|
```js
|
|
192
|
-
import
|
|
172
|
+
import { cdk, BaseProvider } from "cocoda-sdk"
|
|
173
|
+
|
|
174
|
+
export class CustomProvider extends BaseProvider {
|
|
175
|
+
static providerName = "Dummy"
|
|
176
|
+
// static providerType = "..." // Optional URI from https://bartoc.org/api-type/
|
|
177
|
+
|
|
178
|
+
getConcepts() {
|
|
179
|
+
return [
|
|
180
|
+
{ prefLabel: { en: "Hello!" } },
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
193
185
|
cdk.addProvider(CustomProvider)
|
|
194
186
|
```
|
|
195
187
|
|
|
196
|
-
|
|
188
|
+
See [`examples/custom-provider.js`](https://github.com/gbv/cocoda-sdk/blob/main/examples/custom-provider.js) for an extended example.
|
|
197
189
|
|
|
198
190
|
### Multiple Instances
|
|
199
191
|
|
|
@@ -288,148 +280,151 @@ You can find more in-depth examples here:
|
|
|
288
280
|
- The [Vuex store module for authentication in Cocoda](https://github.com/gbv/cocoda/blob/dev/src/store/modules/auth.js).
|
|
289
281
|
- Even if you're not using Vue.js, this can be helpful.
|
|
290
282
|
- Cocoda is using cocoda-sdk extensively, so other parts of the code might also be helpful. It has gotten pretty big and complex though.
|
|
291
|
-
- The [API page of Login Server](https://github.com/gbv/login-server/blob/
|
|
283
|
+
- The [API page of Login Server](https://github.com/gbv/login-server/blob/main/views/api.ejs). This is merely an example on how to use `login-client`.
|
|
292
284
|
|
|
293
|
-
## Methods
|
|
285
|
+
## CDK Methods
|
|
294
286
|
|
|
295
287
|
A cocoda-sdk instance itself offers only a handful of methods. The actual access to APIs happens through [registries](#registries). The following list of methods assume either an instance of cocoda-sdk (`cdk.someMethod`) or an initialized registry (`registry.someMethod`). Documentation for registry methods is on a per-provider basis. While the API should be the same for a particular methods across providers, the details on how to use it might differ.
|
|
296
288
|
|
|
297
|
-
|
|
298
|
-
Please refer to the [documentation](https://gbv.github.io/cocoda-sdk/CocodaSDK.html).
|
|
289
|
+
Please refer to the [documentation](https://gbv.github.io/cocoda-sdk/CocodaSDK.html) for a list of methods of for cocoda-sdk instances.
|
|
299
290
|
|
|
300
|
-
|
|
291
|
+
## RegistryMethods
|
|
301
292
|
|
|
302
|
-
|
|
293
|
+
### General
|
|
294
|
+
|
|
295
|
+
#### init
|
|
303
296
|
- [BaseProvider - init](https://gbv.github.io/cocoda-sdk/BaseProvider.html#init)
|
|
304
297
|
|
|
305
|
-
####
|
|
298
|
+
#### isAuthorizedFor
|
|
306
299
|
- [BaseProvider - isAuthorizedFor](https://gbv.github.io/cocoda-sdk/BaseProvider.html#isAuthorizedFor)
|
|
307
300
|
|
|
308
|
-
####
|
|
301
|
+
#### supportsScheme
|
|
309
302
|
- [BaseProvider - supportsScheme](https://gbv.github.io/cocoda-sdk/BaseProvider.html#supportsScheme)
|
|
310
303
|
- [LabelSearchSuggestionProvider - supportsScheme](https://gbv.github.io/cocoda-sdk/LabelSearchSuggestionProvider.html#supportsScheme)
|
|
311
304
|
|
|
312
|
-
####
|
|
305
|
+
#### setAuth
|
|
313
306
|
- [BaseProvider - setAuth](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setAuth)
|
|
314
307
|
|
|
315
|
-
####
|
|
308
|
+
#### setRetryConfig
|
|
316
309
|
- [BaseProvider - setRetryConfig](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setRetryConfig)
|
|
317
310
|
|
|
318
|
-
####
|
|
311
|
+
#### getCancelTokenSource
|
|
319
312
|
- [BaseProvider - getCancelTokenSource](https://gbv.github.io/cocoda-sdk/BaseProvider.html#getCancelTokenSource)
|
|
320
313
|
|
|
321
|
-
###
|
|
314
|
+
### Concept Schemes
|
|
322
315
|
|
|
323
|
-
####
|
|
316
|
+
#### getSchemes
|
|
324
317
|
- [ConceptApiProvider - getSchemes](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getSchemes)
|
|
325
318
|
- [SkosmosApiProvider - getSchemes](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getSchemes)
|
|
326
319
|
|
|
327
|
-
####
|
|
320
|
+
#### vocSearch
|
|
328
321
|
- [ConceptApiProvider - vocSearch](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSearch)
|
|
329
322
|
|
|
330
|
-
####
|
|
323
|
+
#### vocSuggest
|
|
331
324
|
- [ConceptApiProvider - vocSuggest](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSuggest)
|
|
332
325
|
|
|
333
|
-
###
|
|
326
|
+
### Concepts
|
|
334
327
|
|
|
335
|
-
####
|
|
328
|
+
#### getTop
|
|
336
329
|
- [ConceptApiProvider - getTop](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getTop)
|
|
337
330
|
|
|
338
|
-
####
|
|
331
|
+
#### getConcepts
|
|
339
332
|
- [ConceptApiProvider - getConcepts](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getConcepts)
|
|
340
333
|
- [SkosmosApiProvider - getConcepts](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getConcepts)
|
|
341
334
|
|
|
342
|
-
####
|
|
335
|
+
#### getNarrower
|
|
343
336
|
- [ConceptApiProvider - getNarrower](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getNarrower)
|
|
344
337
|
- [SkosmosApiProvider - getNarrower](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getNarrower)
|
|
345
338
|
|
|
346
|
-
####
|
|
339
|
+
#### getAncestors
|
|
347
340
|
- [ConceptApiProvider - getAncestors](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getAncestors)
|
|
348
341
|
- [SkosmosApiProvider - getAncestors](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getAncestors)
|
|
349
342
|
|
|
350
|
-
####
|
|
343
|
+
#### search
|
|
351
344
|
- [ConceptApiProvider - search](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#search)
|
|
352
345
|
- [SkosmosApiProvider - search](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#search)
|
|
353
346
|
|
|
354
|
-
####
|
|
347
|
+
#### suggest
|
|
355
348
|
- [ConceptApiProvider - suggest](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#suggest)
|
|
356
349
|
- [SkosmosApiProvider - suggest](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#suggest)
|
|
357
350
|
|
|
358
|
-
###
|
|
351
|
+
### Concordances
|
|
359
352
|
|
|
360
|
-
####
|
|
353
|
+
#### getConcordances
|
|
361
354
|
- [MappingsApiProvider - getConcordances](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getConcordances)
|
|
362
355
|
|
|
363
|
-
####
|
|
356
|
+
#### postConcordance
|
|
364
357
|
- [MappingsApiProvider - postConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postConcordance)
|
|
365
358
|
|
|
366
|
-
####
|
|
359
|
+
#### putConcordance
|
|
367
360
|
- [MappingsApiProvider - putConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putConcordance)
|
|
368
361
|
|
|
369
|
-
####
|
|
362
|
+
#### patchConcordance
|
|
370
363
|
- [MappingsApiProvider - patchConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchConcordance)
|
|
371
364
|
|
|
372
|
-
####
|
|
365
|
+
#### deleteConcordance
|
|
373
366
|
- [MappingsApiProvider - deleteConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteConcordance)
|
|
374
367
|
|
|
375
|
-
###
|
|
368
|
+
### Mappings
|
|
376
369
|
|
|
377
|
-
####
|
|
370
|
+
#### getMappings
|
|
378
371
|
- [MappingsApiProvider - getMappings](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getMappings)
|
|
379
372
|
- [LocalMappingsProvider - getMappings](https://gbv.github.io/cocoda-sdk/LocalMappingsProvider.html#getMappings)
|
|
380
373
|
- [ReconciliationApiProvider - getMappings](https://gbv.github.io/cocoda-sdk/ReconciliationApiProvider.html#getMappings)
|
|
381
374
|
- [LabelSearchSuggestionProvider - getMappings](https://gbv.github.io/cocoda-sdk/LabelSearchSuggestionProvider.html#getMappings)
|
|
382
375
|
- [OccurrencesApiProvider - getMappings](https://gbv.github.io/cocoda-sdk/OccurrencesApiProvider.html#getMappings)
|
|
383
376
|
|
|
384
|
-
####
|
|
377
|
+
#### getMapping
|
|
385
378
|
- [MappingsApiProvider - getMapping](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getMapping)
|
|
386
379
|
- [LocalMappingsProvider - getMapping](https://gbv.github.io/cocoda-sdk/LocalMappingsProvider.html#getMapping)
|
|
387
380
|
|
|
388
|
-
####
|
|
381
|
+
#### postMapping
|
|
389
382
|
- [MappingsApiProvider - postMapping](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postMapping)
|
|
390
383
|
- [LocalMappingsProvider - postMapping](https://gbv.github.io/cocoda-sdk/LocalMappingsProvider.html#postMapping)
|
|
391
384
|
|
|
392
|
-
####
|
|
385
|
+
#### postMappings
|
|
393
386
|
- [BaseProvider - postMappings](https://gbv.github.io/cocoda-sdk/BaseProvider.html#postMappings)
|
|
394
387
|
|
|
395
|
-
####
|
|
388
|
+
#### putMapping
|
|
396
389
|
- [MappingsApiProvider - putMapping](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putMapping)
|
|
397
390
|
- [LocalMappingsProvider - putMapping](https://gbv.github.io/cocoda-sdk/LocalMappingsProvider.html#putMapping)
|
|
398
391
|
|
|
399
|
-
####
|
|
392
|
+
#### patchMapping
|
|
400
393
|
- [MappingsApiProvider - patchMapping](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchMapping)
|
|
401
394
|
- [LocalMappingsProvider - patchMapping](https://gbv.github.io/cocoda-sdk/LocalMappingsProvider.html#patchMapping)
|
|
402
395
|
|
|
403
|
-
####
|
|
396
|
+
#### deleteMapping
|
|
404
397
|
- [MappingsApiProvider - deleteMapping](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteMapping)
|
|
405
398
|
- [LocalMappingsProvider - deleteMapping](https://gbv.github.io/cocoda-sdk/LocalMappingsProvider.html#deleteMapping)
|
|
406
399
|
|
|
407
|
-
####
|
|
400
|
+
#### deleteMappings
|
|
408
401
|
- [BaseProvider - deleteMappings](https://gbv.github.io/cocoda-sdk/BaseProvider.html#deleteMappings)
|
|
409
402
|
|
|
410
|
-
###
|
|
403
|
+
### Annotations
|
|
411
404
|
|
|
412
|
-
####
|
|
405
|
+
#### getAnnotations
|
|
413
406
|
- [MappingsApiProvider - getAnnotations](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getAnnotations)
|
|
414
407
|
|
|
415
|
-
####
|
|
408
|
+
#### postAnnotation
|
|
416
409
|
- [MappingsApiProvider - postAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postAnnotation)
|
|
417
410
|
|
|
418
|
-
####
|
|
411
|
+
#### putAnnotation
|
|
419
412
|
- [MappingsApiProvider - putAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putAnnotation)
|
|
420
413
|
|
|
421
|
-
####
|
|
414
|
+
#### patchAnnotation
|
|
422
415
|
- [MappingsApiProvider - patchAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchAnnotation)
|
|
423
416
|
|
|
424
|
-
####
|
|
417
|
+
#### deleteAnnotation
|
|
425
418
|
- [MappingsApiProvider - deleteAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteAnnotation)
|
|
426
419
|
|
|
427
|
-
###
|
|
420
|
+
### Occurrences
|
|
428
421
|
|
|
429
|
-
####
|
|
422
|
+
#### getOccurrences
|
|
430
423
|
- [OccurrencesApiProvider - getOccurrences](https://gbv.github.io/cocoda-sdk/OccurrencesApiProvider.html#getOccurrences)
|
|
431
424
|
|
|
432
|
-
|
|
425
|
+
### Types
|
|
426
|
+
|
|
427
|
+
#### getTypes
|
|
433
428
|
- [ConceptApiProvider - getTypes](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getTypes)
|
|
434
429
|
- [SkosmosApiProvider - getTypes](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getTypes)
|
|
435
430
|
|
|
@@ -472,9 +467,9 @@ This will:
|
|
|
472
467
|
- Make sure `dev` is up-to-date
|
|
473
468
|
- Run `npm version patch` (or "minor"/"major")
|
|
474
469
|
- Push changes to `dev`
|
|
475
|
-
- Switch to `
|
|
470
|
+
- Switch to `main`
|
|
476
471
|
- Merge changes from `dev`
|
|
477
|
-
- Push `
|
|
472
|
+
- Push `main` with tags
|
|
478
473
|
- Switch back to `dev`
|
|
479
474
|
|
|
480
475
|
After running this, GitHub Actions will automatically publish the new version to npm. It will also create a new GitHub Release draft. Please edit and publish the release manually.
|
|
@@ -485,6 +480,6 @@ PRs accepted.
|
|
|
485
480
|
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
|
|
486
481
|
|
|
487
482
|
## License
|
|
488
|
-
MIT Copyright (c) 2021 Verbundzentrale des GBV (VZG)
|
|
483
|
+
MIT Copyright (c) 2021- Verbundzentrale des GBV (VZG)
|
|
489
484
|
|
|
490
485
|
[jskos-server]: https://github.com/gbv/jskos-server
|