wikibase-sdk
Advanced tools
Comparing version 7.10.0 to 7.11.0
# CHANGELOG | ||
*versions follow [SemVer](http://semver.org)* | ||
## 7.11.0 - 2021-04-10 | ||
* Added [`simplify.references`](https://github.com/maxlath/wikidata-sdk/blob/master/docs/simplify_claims.md#simplify-references) function | ||
## 7.10.0 - 2021-04-10 | ||
@@ -5,0 +8,0 @@ * Added [`cirrusSearchPages`](https://github.com/maxlath/wikidata-sdk/blob/master/docs/search_entities.md#cirrussearchpages) function |
@@ -120,3 +120,3 @@ const { parse: parseClaim } = require('./parse_claim') | ||
if (keepQualifiers) { | ||
valueObj.qualifiers = simplifyClaims(claim.qualifiers, subSnaksOptions) | ||
valueObj.qualifiers = simplifyQualifiers(claim.qualifiers, subSnaksOptions) | ||
} | ||
@@ -126,7 +126,3 @@ | ||
claim.references = claim.references || [] | ||
valueObj.references = claim.references.map(refRecord => { | ||
const snaks = simplifyClaims(refRecord.snaks, subSnaksOptions) | ||
if (keepHashes) return { snaks, hash: refRecord.hash } | ||
else return snaks | ||
}) | ||
valueObj.references = simplifyReferences(claim.references, subSnaksOptions) | ||
} | ||
@@ -149,15 +145,29 @@ | ||
const simplifyQualifiers = (claims, options) => { | ||
return simplifyClaims(claims, getSubSnakOptions(options)) | ||
const simplifyQualifiers = (qualifiers, options) => { | ||
return simplifyClaims(qualifiers, getSubSnakOptions(options)) | ||
} | ||
const simplifyPropertyQualifiers = (propClaims, options) => { | ||
return simplifyPropertyClaims(propClaims, getSubSnakOptions(options)) | ||
const simplifyPropertyQualifiers = (propertyQualifiers, options) => { | ||
return simplifyPropertyClaims(propertyQualifiers, getSubSnakOptions(options)) | ||
} | ||
// Using a new object so that the original options object isn't modified | ||
const getSubSnakOptions = options => { | ||
return Object.assign({}, options, { areSubSnaks: true }) | ||
const simplifyReferences = (references, options) => { | ||
return references.map(refRecord => { | ||
return simplifyReferenceRecord(refRecord, options) | ||
}) | ||
} | ||
const simplifyReferenceRecord = (refRecord, options) => { | ||
const subSnaksOptions = getSubSnakOptions(options) | ||
const snaks = simplifyClaims(refRecord.snaks, subSnaksOptions) | ||
if (subSnaksOptions.keepHashes) return { snaks, hash: refRecord.hash } | ||
else return snaks | ||
} | ||
const getSubSnakOptions = (options = {}) => { | ||
if (options.areSubSnaks) return options | ||
// Using a new object so that the original options object isn't modified | ||
else return Object.assign({}, options, { areSubSnaks: true }) | ||
} | ||
const keepOptions = [ 'keepQualifiers', 'keepReferences', 'keepIds', 'keepHashes', 'keepTypes', 'keepSnaktypes', 'keepRanks', 'keepRichValues' ] | ||
@@ -180,3 +190,4 @@ | ||
simplifyPropertyQualifiers, | ||
simplifyQualifier: simplifyClaim | ||
simplifyQualifier: simplifyClaim, | ||
simplifyReferences, | ||
} |
@@ -9,3 +9,4 @@ const { labels, descriptions, aliases, lemmas, glosses } = require('./simplify_text_attributes') | ||
simplifyPropertyQualifiers: propertyQualifiers, | ||
simplifyQualifiers: qualifiers | ||
simplifyQualifiers: qualifiers, | ||
simplifyReferences: references, | ||
} = require('./simplify_claims') | ||
@@ -29,2 +30,3 @@ | ||
qualifiers, | ||
references, | ||
sitelinks, | ||
@@ -31,0 +33,0 @@ |
{ | ||
"name": "wikibase-sdk", | ||
"version": "7.10.0", | ||
"version": "7.11.0", | ||
"description": "utils functions to query a Wikibase instance and simplify its results", | ||
@@ -5,0 +5,0 @@ "main": "lib/wikibase-sdk.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75904
1210