lookup/kinds#

Classes#

LookupError#

Defined in: editor/src/lookup/kinds.ts:86

A request a service did not answer as asked: unreachable when no answer came, status when the answer’s HTTP status is not 2xx, malformed when its body is not of the service’s form. The message completes a sentence naming the system (“Wikidata could not be searched: ”).

Extends#

  • Error

Constructors#

Constructor#

new LookupError(system, code, status, message, cause?): LookupError

Defined in: editor/src/lookup/kinds.ts:91

Parameters#
system#

string

code#

LookupErrorCode

status#

number | null

message#

string

cause?#

unknown

Returns#

LookupError

Overrides#

Error.constructor

Properties#

code#

readonly code: LookupErrorCode

Defined in: editor/src/lookup/kinds.ts:88

status#

readonly status: number | null

Defined in: editor/src/lookup/kinds.ts:89

system#

readonly system: string

Defined in: editor/src/lookup/kinds.ts:87

Interfaces#

Candidate#

Defined in: editor/src/lookup/kinds.ts:31

A thing a service found.

Properties#

crossReferences#

readonly crossReferences: readonly CrossReference[]

Defined in: editor/src/lookup/kinds.ts:41

The things it is the same as: filled by resolve, empty from search.

description#

readonly description: string | null

Defined in: editor/src/lookup/kinds.ts:37

image#

readonly image: string | null

Defined in: editor/src/lookup/kinds.ts:39

A thumbnail’s URL, for display only; never written to a manifest.

iri#

readonly iri: string

Defined in: editor/src/lookup/kinds.ts:35

Its absolute IRI, as the system’s thing template writes it.

label#

readonly label: string

Defined in: editor/src/lookup/kinds.ts:36

match#

readonly match: boolean

Defined in: editor/src/lookup/kinds.ts:45

Whether a reconciliation service called it a match; false elsewhere.

service#

readonly service: string

Defined in: editor/src/lookup/kinds.ts:43

The service that answered, as a provenance entry’s service names it.

system#

readonly system: string

Defined in: editor/src/lookup/kinds.ts:33

The catalogue system of the thing.


CrossReference#

Defined in: editor/src/lookup/kinds.ts:23

A thing another system names that a looked-up thing is the same as.

Properties#

iri#

readonly iri: string

Defined in: editor/src/lookup/kinds.ts:27

Its IRI, as that thing’s template writes it.

system#

readonly system: string

Defined in: editor/src/lookup/kinds.ts:25

The catalogue system holding the thing.


LookupContext#

Defined in: editor/src/lookup/kinds.ts:107

What every service module reads: how to fetch, in which language, from which catalogue.

Properties#

catalogue#

readonly catalogue: Catalogue

Defined in: editor/src/lookup/kinds.ts:110

fetch#

readonly fetch: {(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Defined in: editor/src/lookup/kinds.ts:108

Call Signature#

(input, init?): Promise<Response>

MDN Reference

Parameters#
input#

RequestInfo | URL

init?#

RequestInit

Returns#

Promise<Response>

Call Signature#

(input, init?): Promise<Response>

MDN Reference

Parameters#
input#

string | Request | URL

init?#

RequestInit

Returns#

Promise<Response>

language#

readonly language: string

Defined in: editor/src/lookup/kinds.ts:109

Type Aliases#

LookupErrorCode#

LookupErrorCode = "unreachable" | "status" | "malformed"

Defined in: editor/src/lookup/kinds.ts:77

Why a request failed (see LookupError).


ValueKind#

ValueKind = "work" | "agent" | "recording" | "release" | "class" | "any"

Defined in: editor/src/lookup/kinds.ts:10

What a value field asks for: the lookup narrows its search by it.

Variables#

GND_FILTERS#

const GND_FILTERS: Readonly<Partial<Record<ValueKind, string>>>

Defined in: editor/src/lookup/kinds.ts:63

The type filter of a GND search per kind; a kind without one is not searched.


MUSICBRAINZ_TYPES#

const MUSICBRAINZ_TYPES: Readonly<Partial<Record<ValueKind, string>>>

Defined in: editor/src/lookup/kinds.ts:69

The MusicBrainz entity type searched per kind; a kind without one is not searched.


VALUE_KINDS#

const VALUE_KINDS: readonly ValueKind[]

Defined in: editor/src/lookup/kinds.ts:13

Every value kind, in the order above.


WIKIDATA_FILTERS#

const WIKIDATA_FILTERS: Readonly<Record<ValueKind, string | null>>

Defined in: editor/src/lookup/kinds.ts:53

The statement filter of a Wikidata search per kind, null for none: works with a composer, humans, musical groups and orchestras, recordings with a performer, albums, and classes (items that are a subclass).

Functions#

answerOf()#

answerOf(system, fetcher, url, init?): Promise<unknown>

Defined in: editor/src/lookup/kinds.ts:154

Fetch url for system and answer its JSON body.

A request aborted through init.signal rejects with the signal’s reason, never with a LookupError, so a caller tells a superseded request from a failed one.

Parameters#

system#

string

fetcher#

{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

url#

string

init?#

RequestInit = {}

Returns#

Promise<unknown>

Throws#

LookupError unreachable without an answer; status for an answer outside 2xx, with the detail of a JSON body where it names one; malformed for a body that is no JSON.


isObject()#

isObject(value): value is object

Defined in: editor/src/lookup/kinds.ts:114

Whether value is a JSON object (not a list).

Parameters#

value#

unknown

Returns#

value is object


malformed()#

malformed(system, what): LookupError

Defined in: editor/src/lookup/kinds.ts:188

The error of an answer that is not of the service’s form: “its answer is ”.

Parameters#

system#

string

what#

string

Returns#

LookupError


memberOf()#

memberOf(value, key): unknown

Defined in: editor/src/lookup/kinds.ts:119

The member key of a JSON object, undefined for anything else.

Parameters#

value#

unknown

key#

string

Returns#

unknown


textOf()#

textOf(value, key): string | undefined

Defined in: editor/src/lookup/kinds.ts:124

The member key of a JSON object if it is a string, else undefined.

Parameters#

value#

unknown

key#

string

Returns#

string | undefined


urlWith()#

urlWith(base, parameters): string

Defined in: editor/src/lookup/kinds.ts:193

A URL with its query parameters in the order given.

Parameters#

base#

string

parameters#

readonly (readonly [string, string])[]

Returns#

string