wikibase-edit
Version:
Edit Wikibase from NodeJS
30 lines (23 loc) • 745 B
text/typescript
import { isEntityId, isItemId, type EntityId } from 'wikibase-sdk'
import { newError } from '../error.js'
export interface MergeEntityParams {
from: EntityId
to: EntityId
}
export function mergeEntity (params) {
const { from, to } = params
if (!isEntityId(from)) throw newError('invalid "from" entity id', params)
if (!isEntityId(to)) throw newError('invalid "to" entity id', params)
if (!isItemId(from)) throw newError('unsupported entity type', params)
if (!isItemId(to)) throw newError('unsupported entity type', params)
return {
action: 'wbmergeitems',
data: { fromid: from, toid: to },
}
}
export interface MergeEntityResponse {
success: 1
redirected: 1
from: { id: EntityId }
to: { id: EntityId }
}