UNPKG

wikibase-edit

Version:

Edit Wikibase from NodeJS

24 lines 954 B
import { newError } from './error.js'; import WBK from './get_instance_wikibase_sdk.js'; import { getJson } from './request/get_json.js'; async function getEntity(id, props, config) { const { instance } = config; const url = WBK(instance).getEntities({ ids: id, props }); const headers = { 'user-agent': config.userAgent }; const { entities } = await getJson(url, { headers }); const entity = entities[id]; if (!entity || entity.missing != null) { throw newError('entity not found', { id, props, instance: config.instance }); } return entity; } export async function getEntityClaims(id, config) { const entity = await getEntity(id, 'claims', config); const { statementsKey } = config; return entity[statementsKey]; } export async function getEntitySitelinks(id, config) { const entity = await getEntity(id, 'sitelinks', config); return entity.sitelinks; } //# sourceMappingURL=get_entity.js.map