cocoda-sdk 3.6.0 → 3.6.1

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
@@ -6,7 +6,8 @@
6
6
 
7
7
  > SDK for [Cocoda](https://github.com/gbv/cocoda) and [coli-conc](https://coli-conc.gbv.de/) services
8
8
 
9
- ## Table of Contents <!-- omit in toc -->
9
+ ## Table of Contents
10
+
10
11
  - [Install](#install)
11
12
  - [Usage](#usage)
12
13
  - [Import](#import)
@@ -15,7 +16,7 @@
15
16
  - [Providers](#providers)
16
17
  - [Multiple Instances](#multiple-instances)
17
18
  - [Authenticated Requests](#authenticated-requests)
18
- - [CDK Methods](#cdk-methods)
19
+ - [API](#api)
19
20
  - [General](#general)
20
21
  - [Concept Schemes](#concept-schemes)
21
22
  - [Concepts](#concepts)
@@ -24,10 +25,9 @@
24
25
  - [Annotations](#annotations)
25
26
  - [Occurrences](#occurrences)
26
27
  - [Types](#types)
27
- - [Errors](#errors)
28
+ - [Errors](#errors)
28
29
  - [Maintainers](#maintainers)
29
- - [Publish](#publish)
30
- - [Contribute](#contribute)
30
+ - [Contributing](#contributing)
31
31
  - [License](#license)
32
32
 
33
33
  ## Install
@@ -54,6 +54,7 @@ Since cocoda-sdk is an ES module, we'll use the `import`/`export` syntax in the
54
54
  cocoda-sdk also exports some other members:
55
55
  - `CocodaSDK` - the class that is behind the default instance
56
56
  - `errors` - see [Errors](#errors)
57
+ - `providers` - an object with all provider classes
57
58
  - All individual provider classes - see [Providers](#providers)
58
59
  - Note: You need to append `Provider` to the names, e.g. `LocalMappings` is exported as `LocalMappingsProvider`.
59
60
  - `addAllProviders` - a method that adds all avaiable providers to an instance
@@ -89,6 +90,15 @@ A registry is an individual source of data, for instance a set of concept scheme
89
90
  }
90
91
  ```
91
92
 
93
+ For most providers the configuration should use the BARTOC vocabulary API type URI instead:
94
+
95
+ ```json
96
+ {
97
+ "api": "http://bartoc.org/api-type/skosmos",
98
+ "endpoint": "https://www.loterre.fr/skosmos/905/"
99
+ }
100
+ ```
101
+
92
102
  A list of available providers can be found [below](#providers). Most providers need additional properties to work correctly.
93
103
 
94
104
  #### Endpoint Determination
@@ -116,6 +126,15 @@ const registry = cdk.initializeRegistry({
116
126
  registry.getMappings()
117
127
  ```
118
128
 
129
+ Most Providers can also be initialized with API Type URI from [BARTOC vocabulary API types list](https://bartoc.org/en/node/20002):
130
+
131
+ ```js
132
+ const registry = cdk.initializeRegistry({
133
+ api: "http://bartoc.org/api-type/skosmos",
134
+ endpoint: "https://www.loterre.fr/skosmos/905/"
135
+ })
136
+ ```
137
+
119
138
  It's also possible to directly use Registry classes.
120
139
 
121
140
  #### Using Registries From a Configuration
@@ -282,88 +301,98 @@ You can find more in-depth examples here:
282
301
  - Cocoda is using cocoda-sdk extensively, so other parts of the code might also be helpful. It has gotten pretty big and complex though.
283
302
  - 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`.
284
303
 
285
- ## CDK Methods
304
+ ## API
286
305
 
287
306
  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.
288
307
 
289
308
  Please refer to the [documentation](https://gbv.github.io/cocoda-sdk/CocodaSDK.html) for a list of methods of for cocoda-sdk instances.
290
309
 
291
- ## RegistryMethods
292
-
293
310
  ### General
294
311
 
295
- #### init
296
- - [BaseProvider - init](https://gbv.github.io/cocoda-sdk/BaseProvider.html#init)
312
+ - [init](https://gbv.github.io/cocoda-sdk/BaseProvider.html#init)
297
313
 
298
- #### isAuthorizedFor
299
- - [BaseProvider - isAuthorizedFor](https://gbv.github.io/cocoda-sdk/BaseProvider.html#isAuthorizedFor)
314
+ - [isAuthorizedFor](https://gbv.github.io/cocoda-sdk/BaseProvider.html#isAuthorizedFor)
300
315
 
301
- #### supportsScheme
302
- - [BaseProvider - supportsScheme](https://gbv.github.io/cocoda-sdk/BaseProvider.html#supportsScheme)
303
- - [LabelSearchSuggestionProvider - supportsScheme](https://gbv.github.io/cocoda-sdk/LabelSearchSuggestionProvider.html#supportsScheme)
316
+ - `supportsScheme`. Implemented by:
317
+ - [BaseProvider](https://gbv.github.io/cocoda-sdk/BaseProvider.html#supportsScheme)
318
+ - [LabelSearchSuggestionProvider](https://gbv.github.io/cocoda-sdk/LabelSearchSuggestionProvider.html#supportsScheme)
304
319
 
305
- #### setAuth
306
- - [BaseProvider - setAuth](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setAuth)
320
+ - `setAuth`
321
+ - Implemented by [BaseProvider](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setAuth)
307
322
 
308
- #### setRetryConfig
309
- - [BaseProvider - setRetryConfig](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setRetryConfig)
323
+ - setRetryConfig
324
+ - Implemented by [BaseProvider](https://gbv.github.io/cocoda-sdk/BaseProvider.html#setRetryConfig)
310
325
 
311
- #### getCancelTokenSource
312
- - [BaseProvider - getCancelTokenSource](https://gbv.github.io/cocoda-sdk/BaseProvider.html#getCancelTokenSource)
326
+ - getCancelTokenSource
327
+
328
+ - Implemented by [BaseProvider](https://gbv.github.io/cocoda-sdk/BaseProvider.html#getCancelTokenSource)
313
329
 
314
330
  ### Concept Schemes
315
331
 
316
- #### getSchemes
317
- - [ConceptApiProvider - getSchemes](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getSchemes)
318
- - [SkosmosApiProvider - getSchemes](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getSchemes)
332
+ - `getSchemes`
333
+ - [ConceptApiProvider](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getSchemes)
334
+ - [SkosmosApiProvider](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getSchemes)
335
+ - ...
319
336
 
320
- #### vocSearch
321
- - [ConceptApiProvider - vocSearch](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSearch)
337
+ - `vocSearch`
338
+ - [ConceptApiProvider](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSearch)
339
+ - ...
322
340
 
323
- #### vocSuggest
324
- - [ConceptApiProvider - vocSuggest](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSuggest)
341
+ - `vocSuggest`
342
+ - [ConceptApiProvider](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#vocSuggest)
325
343
 
326
344
  ### Concepts
327
345
 
328
346
  #### getTop
329
347
  - [ConceptApiProvider - getTop](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getTop)
348
+ - ...
330
349
 
331
350
  #### getConcepts
332
351
  - [ConceptApiProvider - getConcepts](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getConcepts)
333
352
  - [SkosmosApiProvider - getConcepts](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getConcepts)
353
+ - ...
334
354
 
335
355
  #### getNarrower
336
356
  - [ConceptApiProvider - getNarrower](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getNarrower)
337
357
  - [SkosmosApiProvider - getNarrower](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getNarrower)
358
+ - ...
338
359
 
339
360
  #### getAncestors
340
361
  - [ConceptApiProvider - getAncestors](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getAncestors)
341
362
  - [SkosmosApiProvider - getAncestors](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getAncestors)
363
+ - ...
342
364
 
343
365
  #### search
344
366
  - [ConceptApiProvider - search](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#search)
345
367
  - [SkosmosApiProvider - search](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#search)
368
+ - ...
346
369
 
347
370
  #### suggest
348
371
  - [ConceptApiProvider - suggest](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#suggest)
349
372
  - [SkosmosApiProvider - suggest](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#suggest)
373
+ - ...
350
374
 
351
375
  ### Concordances
352
376
 
353
377
  #### getConcordances
354
378
  - [MappingsApiProvider - getConcordances](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getConcordances)
379
+ - ...
355
380
 
356
381
  #### postConcordance
357
382
  - [MappingsApiProvider - postConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postConcordance)
383
+ - ...
358
384
 
359
385
  #### putConcordance
360
386
  - [MappingsApiProvider - putConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putConcordance)
387
+ - ...
361
388
 
362
389
  #### patchConcordance
363
390
  - [MappingsApiProvider - patchConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchConcordance)
391
+ - ...
364
392
 
365
393
  #### deleteConcordance
366
394
  - [MappingsApiProvider - deleteConcordance](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteConcordance)
395
+ - ...
367
396
 
368
397
  ### Mappings
369
398
 
@@ -402,37 +431,29 @@ Please refer to the [documentation](https://gbv.github.io/cocoda-sdk/CocodaSDK.h
402
431
 
403
432
  ### Annotations
404
433
 
405
- #### getAnnotations
406
- - [MappingsApiProvider - getAnnotations](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getAnnotations)
407
-
408
- #### postAnnotation
409
- - [MappingsApiProvider - postAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postAnnotation)
410
-
411
- #### putAnnotation
412
- - [MappingsApiProvider - putAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putAnnotation)
413
-
414
- #### patchAnnotation
415
- - [MappingsApiProvider - patchAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchAnnotation)
416
-
417
- #### deleteAnnotation
418
- - [MappingsApiProvider - deleteAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteAnnotation)
434
+ - [getAnnotations](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#getAnnotations)
435
+ - [postAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#postAnnotation)
436
+ - [putAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#putAnnotation)
437
+ - [patchAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#patchAnnotation)
438
+ - [deleteAnnotation](https://gbv.github.io/cocoda-sdk/MappingsApiProvider.html#deleteAnnotation)
419
439
 
420
440
  ### Occurrences
421
441
 
422
- #### getOccurrences
423
- - [OccurrencesApiProvider - getOccurrences](https://gbv.github.io/cocoda-sdk/OccurrencesApiProvider.html#getOccurrences)
442
+ - [getOccurrences](https://gbv.github.io/cocoda-sdk/OccurrencesApiProvider.html#getOccurrences)
424
443
 
425
444
  ### Types
426
445
 
427
- #### getTypes
428
- - [ConceptApiProvider - getTypes](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getTypes)
429
- - [SkosmosApiProvider - getTypes](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getTypes)
446
+ `getTypes({ scheme })` returns a list of [types](https://gbv.github.io/jskos/#resource-and-property-types) for some concept scheme(s). Implemented by:
447
+
448
+ - [ConceptApiProvider](https://gbv.github.io/cocoda-sdk/ConceptApiProvider.html#getTypes)
449
+ - [SkosmosApiProvider](https://gbv.github.io/cocoda-sdk/SkosmosApiProvider.html#getTypes)
450
+ - [OlsApiProvider](https://gbv.github.io/cocoda-sdk/OlsApiProvider.html#getTypes)
451
+ - [LobidApiProvider](https://gbv.github.io/cocoda-sdk/LobidApiProvider.html#getTypes)
430
452
 
431
- ## Errors
432
- cocoda-sdk defines some custom errors.
453
+ ### Errors
454
+ cocoda-sdk defines some custom errors, grouped in exporteable object `errors`:
433
455
 
434
456
  ```js
435
- const { errors } = require("cocoda-sdk") // CommonJS
436
457
  import { errors } from "cocoda-sdk"
437
458
  ```
438
459
 
@@ -449,35 +470,11 @@ The following errors are defined:
449
470
  For details about the errors, refer to the [documentation](https://gbv.github.io/cocoda-sdk/index.html).
450
471
 
451
472
  ## Maintainers
452
- - [@stefandesu](https://github.com/stefandesu)
453
473
  - [@nichtich](https://github.com/nichtich)
454
474
 
455
- ## Publish
456
- Please work on the `dev` branch during development (or better yet, develop in a feature branch and merge into `dev` when ready).
457
-
458
- When a new release is ready (i.e. the features are finished, merged into `dev`, and all tests succeed), run the included release script (replace "patch" with "minor" or "major" if necessary):
459
-
460
- ```bash
461
- npm run release:patch
462
- ```
463
-
464
- This will:
465
- - Run tests and build to make sure everything works
466
- - Switch to `dev`
467
- - Make sure `dev` is up-to-date
468
- - Run `npm version patch` (or "minor"/"major")
469
- - Push changes to `dev`
470
- - Switch to `main`
471
- - Merge changes from `dev`
472
- - Push `main` with tags
473
- - Switch back to `dev`
474
-
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.
476
-
477
- ## Contribute
478
- PRs accepted.
475
+ ## Contributing
479
476
 
480
- Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
477
+ See [CONTRIBUTING.md](CONTRIBUTING.md)
481
478
 
482
479
  ## License
483
480
  MIT Copyright (c) 2021- Verbundzentrale des GBV (VZG)