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 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
- - [Methods for cocoda-sdk instance](#methods-for-cocoda-sdk-instance)
21
- - [Registry Methods - General](#registry-methods---general)
22
- - [Registry Methods - Concept Schemes](#registry-methods---concept-schemes)
23
- - [Registry Methods - Concepts](#registry-methods---concepts)
24
- - [Registry Methods - Concordances](#registry-methods---concordances)
25
- - [Registry Methods - Mappings](#registry-methods---mappings)
26
- - [Registry Methods - Annotations](#registry-methods---annotations)
27
- - [Registry Methods - Various](#registry-methods---various)
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 are also providing a browser bundle: https://cdn.jsdelivr.net/npm/cocoda-sdk@2/dist/cocoda-sdk.js (~51K gzipped, ~155K not gzipped) It will be available under the global name `CDK` and contain the listed members below (in particular the default instance `CDK.cdk`).
38
+ We also provide a browser bundle <https://cdn.jsdelivr.net/npm/cocoda-sdk@2/dist/cocoda-sdk.js>
40
39
 
41
40
  [![](https://data.jsdelivr.com/v1/package/npm/cocoda-sdk/badge?style=rounded)](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 CustomProvider from "./custom-provider.js"
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
- It is then possible to use that provider via cocoda-sdk as well. (See also: Example under [`examples/custom-provider.js`](https://github.com/gbv/cocoda-sdk/blob/master/examples/custom-provider.js).)
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/master/views/api.ejs). This is merely an example on how to use `login-client`.
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
- ### Methods for cocoda-sdk instance
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
- ### Registry Methods - General
291
+ ## RegistryMethods
301
292
 
302
- #### `registry.init`
293
+ ### General
294
+
295
+ #### init
303
296
  - [BaseProvider - init](https://gbv.github.io/cocoda-sdk/BaseProvider.html#init)
304
297
 
305
- #### `registry.isAuthorizedFor`
298
+ #### isAuthorizedFor
306
299
  - [BaseProvider - isAuthorizedFor](https://gbv.github.io/cocoda-sdk/BaseProvider.html#isAuthorizedFor)
307
300
 
308
- #### `registry.supportsScheme`
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
- #### `registry.setAuth`
305
+ #### setAuth
313
306
  - [BaseProvider - setAuth](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setAuth)
314
307
 
315
- #### `registry.setRetryConfig`
308
+ #### setRetryConfig
316
309
  - [BaseProvider - setRetryConfig](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setRetryConfig)
317
310
 
318
- #### `registry.getCancelTokenSource`
311
+ #### getCancelTokenSource
319
312
  - [BaseProvider - getCancelTokenSource](https://gbv.github.io/cocoda-sdk/BaseProvider.html#getCancelTokenSource)
320
313
 
321
- ### Registry Methods - Concept Schemes
314
+ ### Concept Schemes
322
315
 
323
- #### `registry.getSchemes`
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
- #### `registry.vocSearch`
320
+ #### vocSearch
328
321
  - [ConceptApiProvider - vocSearch](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSearch)
329
322
 
330
- #### `registry.vocSuggest`
323
+ #### vocSuggest
331
324
  - [ConceptApiProvider - vocSuggest](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSuggest)
332
325
 
333
- ### Registry Methods - Concepts
326
+ ### Concepts
334
327
 
335
- #### `registry.getTop`
328
+ #### getTop
336
329
  - [ConceptApiProvider - getTop](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getTop)
337
330
 
338
- #### `registry.getConcepts`
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
- #### `registry.getNarrower`
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
- #### `registry.getAncestors`
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
- #### `registry.search`
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
- #### `registry.suggest`
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
- ### Registry Methods - Concordances
351
+ ### Concordances
359
352
 
360
- #### `registry.getConcordances`
353
+ #### getConcordances
361
354
  - [MappingsApiProvider - getConcordances](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getConcordances)
362
355
 
363
- #### `registry.postConcordance`
356
+ #### postConcordance
364
357
  - [MappingsApiProvider - postConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postConcordance)
365
358
 
366
- #### `registry.putConcordance`
359
+ #### putConcordance
367
360
  - [MappingsApiProvider - putConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putConcordance)
368
361
 
369
- #### `registry.patchConcordance`
362
+ #### patchConcordance
370
363
  - [MappingsApiProvider - patchConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchConcordance)
371
364
 
372
- #### `registry.deleteConcordance`
365
+ #### deleteConcordance
373
366
  - [MappingsApiProvider - deleteConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteConcordance)
374
367
 
375
- ### Registry Methods - Mappings
368
+ ### Mappings
376
369
 
377
- #### `registry.getMappings`
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
- #### `registry.getMapping`
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
- #### `registry.postMapping`
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
- #### `registry.postMappings`
385
+ #### postMappings
393
386
  - [BaseProvider - postMappings](https://gbv.github.io/cocoda-sdk/BaseProvider.html#postMappings)
394
387
 
395
- #### `registry.putMapping`
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
- #### `registry.patchMapping`
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
- #### `registry.deleteMapping`
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
- #### `registry.deleteMappings`
400
+ #### deleteMappings
408
401
  - [BaseProvider - deleteMappings](https://gbv.github.io/cocoda-sdk/BaseProvider.html#deleteMappings)
409
402
 
410
- ### Registry Methods - Annotations
403
+ ### Annotations
411
404
 
412
- #### `registry.getAnnotations`
405
+ #### getAnnotations
413
406
  - [MappingsApiProvider - getAnnotations](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getAnnotations)
414
407
 
415
- #### `registry.postAnnotation`
408
+ #### postAnnotation
416
409
  - [MappingsApiProvider - postAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postAnnotation)
417
410
 
418
- #### `registry.putAnnotation`
411
+ #### putAnnotation
419
412
  - [MappingsApiProvider - putAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putAnnotation)
420
413
 
421
- #### `registry.patchAnnotation`
414
+ #### patchAnnotation
422
415
  - [MappingsApiProvider - patchAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchAnnotation)
423
416
 
424
- #### `registry.deleteAnnotation`
417
+ #### deleteAnnotation
425
418
  - [MappingsApiProvider - deleteAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteAnnotation)
426
419
 
427
- ### Registry Methods - Various
420
+ ### Occurrences
428
421
 
429
- #### `registry.getOccurrences`
422
+ #### getOccurrences
430
423
  - [OccurrencesApiProvider - getOccurrences](https://gbv.github.io/cocoda-sdk/OccurrencesApiProvider.html#getOccurrences)
431
424
 
432
- #### `registry.getTypes`
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 `master`
470
+ - Switch to `main`
476
471
  - Merge changes from `dev`
477
- - Push `master` with tags
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