UNPKG

wikibase-edit

Version:

Edit Wikibase from NodeJS

20 lines 865 B
import { validateGuid, validatePropertyId, validateSnakValue } from '../validate.js'; import { formatClaimValue } from './format_claim_value.js'; import { buildSnak } from './snak.js'; export function setClaim(params, properties, instance) { const { guid, property, value: rawValue } = params; const datatype = properties[property]; validateGuid(guid); validatePropertyId(property); // Format before testing validity to avoid throwing on type errors // that could be recovered const value = formatClaimValue(datatype, rawValue, instance); validateSnakValue(property, datatype, value); const claim = { id: guid, type: 'statement', mainsnak: buildSnak(property, datatype, value, instance), }; return { action: 'wbsetclaim', data: { claim: JSON.stringify(claim) } }; } //# sourceMappingURL=set.js.map