ConceptApiProvider

JSKOS Concept API.

This class provides access to concept schemes and their concepts via JSKOS API in JSKOS format. See jskos-server for a JSKOS API reference implementation and DANTE for another API endpoint.

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

{
 "uri": "http://coli-conc.gbv.de/registry/coli-conc-concepts",
 "provider": "ConceptApi",
 "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, schemes, top, concepts, data, narrower, ancestors, types, suggest, search Note that schemes, top, and types can also be provided as arrays.

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

Constructor

new ConceptApiProvider()

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) 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) getAncestors(config) → {Array.<Object>}

Returns ancestor concepts for a concept.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
conceptObject

concept object

Returns:

array of JSKOS concept objects

Type: 
Array.<Object>

getCancelTokenSource() → {Object}

Returns a source for a axios cancel token.

Returns:

axios cancel token source

Type: 
Object

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

Returns details for a list of concepts.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
conceptsArray.<Object>

list of concept objects to load

Returns:

array of JSKOS concept objects

Type: 
Array.<Object>

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

Returns narrower concepts for a concept.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
conceptObject

concept object

Returns:

array of JSKOS concept objects

Type: 
Array.<Object>

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

Returns all concept schemes.

Parameters:
NameTypeDescription
configObject
Returns:

array of JSKOS concept scheme objects

Type: 
Array.<Object>

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

Returns top concepts for a concept scheme.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeDescription
schemeObject

concept scheme object

Returns:

array of JSKOS concept objects

Type: 
Array.<Object>

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

Returns a list of types.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDescription
schemeObject<optional>

concept scheme to load types for

Returns:

array of JSKOS type 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) 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>

Returns search results in JSKOS Format.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDefaultDescription
searchstring

search string

schemeObject<optional>

concept scheme to search in

limitnumber<optional>
100

maximum number of search results (default might be overridden by registry)

offsetnumber<optional>
0

offset

typesArray.<string><optional>
[]

list of type URIs

Returns:

result in JSKOS Format

Type: 
Array

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

(async) suggest(config) → {Array}

Returns suggestion result in OpenSearch Suggest Format.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDefaultDescription
searchstring

search string

schemeObject<optional>

concept scheme to search in

limitnumber<optional>
100

maximum number of search results (default might be overridden by registry)

usestring<optional>
notation,label

which fields to search ("notation", "label" or "notation,label")

typesArray.<string><optional>
[]

list of type URIs

sortstring<optional>
score

sorting parameter

Returns:

result in OpenSearch Suggest Format

Type: 
Array

supportsScheme(scheme) → {boolean}

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

Parameters:
NameTypeDescription
schemeObject
Returns:
Type: 
boolean

(async) vocSearch(config) → {Array}

Returns concept scheme search results in JSKOS Format.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDefaultDescription
searchstring

search string

limitnumber<optional>
100

maximum number of search results (default might be overridden by registry)

offsetnumber<optional>
0

offset

Returns:

result in JSKOS Format

Type: 
Array

(async) vocSuggest(config) → {Array}

Returns concept scheme suggestion result in OpenSearch Suggest Format.

Parameters:
NameTypeDescription
configObject
Properties
NameTypeAttributesDefaultDescription
searchstring

search string

limitnumber<optional>
100

maximum number of search results (default might be overridden by registry)

usestring<optional>
notation,label

which fields to search ("notation", "label" or "notation,label")

sortstring<optional>
score

sorting parameter

Returns:

result in OpenSearch Suggest Format

Type: 
Array

(static) _registryConfigForBartocApiConfig(options) → {Object}

Used by registryForScheme (see src/lib/CocodaSDK.js) to determine a provider config for a concept schceme.

Parameters:
NameTypeDescription
optionsObject
Properties
NameTypeDescription
urlObject

API URL for server

Returns:

provider configuration

Type: 
Object