MappingsApiProvider

JSKOS Mappings API.

This class provides access to concept mappings via JSKOS API in JSKOS format. See jskos-server for a JSKOS API reference implementation

To use it in a registry, specify provider as "MappingsApi" and provide the API base URL as api:

{
 "uri": "http://coli-conc.gbv.de/registry/coli-conc-mappings",
 "provider": "MappingsApi",
 "api": "https://coli-conc.gbv.de/api/"
}

If the /status endpoint can be queried, the remaining API methods will be taken from that. As a fallback, the default endpoints will be appended to api.

Alternatively, you can provide the endpoints separately: status, mappings, concordances, annotations

Additionally, the following JSKOS properties can be provided: prefLabel, notation, definition

Constructor

new MappingsApiProvider()

Extends

Members

(readonly) has :Object

A dictionary with functionality of the registry (e.g. registry.has.schemes).

Type:
  • Object
Inherited From

languages :Array.<string>

A list of RFC 3066 language tags in lowercase in order of priority.

Type:
  • Array.<string>

Methods

(async) deleteAnnotation(config) → {boolean}

Deletes an annotation.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
annotationObject

JSKOS annotation

Returns:

true if deletion was successful

Type: 
boolean

(async) deleteConcordance(config) → {boolean}

Deletes a concordance.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
concordanceObject

JSKOS concordance

Returns:

true if deletion was successful

Type: 
boolean

(async) deleteMapping(config) → {boolean}

Deletes a mapping.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingObject

JSKOS mapping

Returns:

true if deletion was successful

Type: 
boolean

(async) deleteMappings(config) → {Array.<Object>}

DELETEs multiple mappings. Do not override in subclass!

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingsArray

array of mapping objects

Returns:

array of results (true if successful); in case of failure, consult the _errors property on the array at the index of the failed request

Type: 
Array.<Object>

(async) getAnnotations(config) → {Array.<Object>}

Returns a list of annotations.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDescription
targetstring<optional>

target URI

Returns:

array of JSKOS annotation objects

Type: 
Array.<Object>

getCancelTokenSource() → {Object}

Returns a source for a axios cancel token.

Returns:

axios cancel token source

Type: 
Object

(async) getConcordances(config) → {Array.<Object>}

Returns a list of concordances.

Parameters:
NameTypeDescription
configObject
Returns:

array of JSKOS concordance objects

Type: 
Array.<Object>

(async) getMapping(config) → {Object}

Returns a single mapping.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingObject

JSKOS mapping

Returns:

JSKOS mapping object

Type: 
Object

(async) getMappings(config) → {Array.<Object>}

Returns a list of mappings.

Parameters:
NameTypeDescription
configObject

request config with parameters

Returns:

array of JSKOS mapping objects

Type: 
Array.<Object>

(async) init() → {Promise}

Load data about registry via the status endpoint.

Inherited From
Returns:

Promise that resolves when initialization is complete.

Type: 
Promise

isAuthorizedFor(options) → {boolean}

Returns whether a user is authorized for a certain request.

Parameters:
NameTypeDescription
optionsObject
Properties
NameTypeAttributesDescription
typestring

type of item (e.g. mappings)

actionstring

action to be performed (read/create/update/delete)

userObject

user object

crossUserboolean<optional>

whether the request is a crossUser request (i.e. updading/deleting another user's item)

Returns:
Type: 
boolean

(async) patchAnnotation(config) → {Object}

Patches an annotation.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
annotationObject

JSKOS annotation

Returns:

JSKOS annotation object

Type: 
Object

(async) patchConcordance(config) → {Object}

Patches a concordance.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
concordanceObject

JSKOS concordance (or part of concordance)

Returns:

JSKOS concordance object

Type: 
Object

(async) patchMapping(config) → {Object}

Patches a mapping.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingObject

JSKOS mapping (or part of mapping)

Returns:

JSKOS mapping object

Type: 
Object

(async) postAnnotation(config) → {Object}

Creates an annotation.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
annotationObject

JSKOS annotation

Returns:

JSKOS annotation object

Type: 
Object

(async) postConcordance(config) → {Object}

Creates a concordance.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
concordanceObject

JSKOS concordance

Returns:

JSKOS concordance object

Type: 
Object

(async) postMapping(config) → {Object}

Creates a mapping.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingObject

JSKOS mapping

Returns:

JSKOS mapping object

Type: 
Object

(async) postMappings(config) → {Array.<Object>}

POSTs multiple mappings. Do not override in subclass!

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingsArray

array of mapping objects

Returns:

array of created mapping objects; in case of failure, consult the _errors property on the array at the index of the failed request

Type: 
Array.<Object>

(async) putAnnotation(config) → {Object}

Overwrites an annotation.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
annotationObject

JSKOS annotation

Returns:

JSKOS annotation object

Type: 
Object

(async) putConcordance(config) → {Object}

Overwrites a concordance.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
concordanceObject

JSKOS concordance

Returns:

JSKOS concordance object

Type: 
Object

(async) putMapping(config) → {Object}

Overwrites a mapping.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
mappingObject

JSKOS mapping

Returns:

JSKOS mapping object

Type: 
Object

setAuth(options)

Sets authentication credentials.

Parameters:
NameTypeDescription
optionsObject
Properties
NameTypeDescription
keystring

public key of login-server instance the user is authorized for

bearerTokenstring

token that is sent with each request

Inherited From

setRetryConfig(config)

Sets retry configuration.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDefaultDescription
methodsArray.<string><optional>
["get", "head", "options"]

HTTP methods to retry (lowercase)

statusCodesArray.<number><optional>
[401, 403]

status codes to retry

countnumber<optional>
3

maximum number of retries

delaynumber | function<optional>
300*count

a delay in ms or a function that takes the number of current retries and returns a delay in ms

supportsScheme(scheme) → {boolean}

Returns a boolean whether a certain target scheme is supported or not.

Parameters:
NameTypeDescription
schemeObject
Returns:
Type: 
boolean