Skip to content

Commit

Permalink
fix(plugin-wikidata): replace deprecated wikidata-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgw committed Aug 11, 2024
1 parent 1e5f612 commit 32d1527
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
35 changes: 9 additions & 26 deletions packages/plugin-wikidata/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/plugin-wikidata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"@citation-js/date": "^0.5.0",
"@citation-js/name": "^0.4.2",
"wikidata-sdk": "^8.0.0"
"wikibase-sdk": "^8.1.1"
},
"devDependencies": {
"@citation-js/core": "^0.7.14"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-wikidata/src/id.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import wdk from 'wikidata-sdk'
import wdk from './wdk.js'
import config from './config.json'

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-wikidata/src/response.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { simplify } from 'wikidata-sdk'
import wdk from './wdk.js'
import { parse as fetch, parseAsync as fetchAsync } from './api.js'
import { parse as getUrls } from './id.js'

Expand Down Expand Up @@ -163,15 +163,15 @@ function completeResponse (entities, old) {
}

function simplifyEntities (entities) {
const simplified = simplify.entities(entities, SIMPLIFY_OPTS)
const simplified = wdk.simplify.entities(entities, SIMPLIFY_OPTS)
for (const id in entities) {
if (entities[id].missing === '') {
throw new Error(`Entity "${id}" not found`)
}

const claims = entities[id].claims
if (claims.P348) {
simplified[id].claims['P348:all'] = simplify.propertyClaims(claims.P348, {
simplified[id].claims['P348:all'] = wdk.simplify.propertyClaims(claims.P348, {
...SIMPLIFY_OPTS,
keepNonTruthy: true,
keepRank: true
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-wikidata/src/wdk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import WBK from 'wikibase-sdk'

const wdk = WBK({
instance: 'https://www.wikidata.org',
sparqlEndpoint: 'https://query.wikidata.org/sparql'
})

export default wdk

0 comments on commit 32d1527

Please sign in to comment.