Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wikibase-sdk

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wikibase-sdk - npm Package Compare versions

Comparing version 7.8.0 to 7.9.0

3

CHANGELOG.md
# CHANGELOG
*versions follow [SemVer](http://semver.org)*
## 7.9.0 - 2021-01-29
* [`getEntityIdFromGuid`](https://github.com/maxlath/wikidata-sdk/blob/master/docs/general_helpers.md#getentityidfromguid): added support for hyphenated GUIDs
## 7.8.0 - 2020-10-07

@@ -5,0 +8,0 @@ * Added function aliases:

@@ -21,3 +21,3 @@ const toDateObject = require('./wikibase_time_to_date_object')

if (typeof title !== 'string') return false
var [ namespace, id ] = title.split(':')
let [ namespace, id ] = title.split(':')
if (namespace && id) {

@@ -97,3 +97,3 @@ return isEntityNamespace(namespace) && helpers[`is${namespace}Id`](id)

helpers.getImageUrl = (filename, width) => {
var url = `https://commons.wikimedia.org/wiki/Special:FilePath/${filename}`
let url = `https://commons.wikimedia.org/wiki/Special:FilePath/${filename}`
if (typeof width === 'number') url += `?width=${width}`

@@ -103,4 +103,19 @@ return url

helpers.getEntityIdFromGuid = guid => guid.split('$')[0].toUpperCase()
helpers.getEntityIdFromGuid = guid => {
const parts = guid.split(/[$-]/)
if (parts.length === 6) {
// Examples:
// - q520$BCA8D9DE-B467-473B-943C-6FD0C5B3D02C
// - P6216-a7fd6230-496e-6b47-ca4a-dcec5dbd7f95
return parts[0].toUpperCase()
} else if (parts.length === 7) {
// Examples:
// - L525-S1$66D20252-8CEC-4DB1-8B00-D713CFF42E48
// - L525-F2-52c9b382-02f5-4413-9923-26ade74f5a0d
return parts.slice(0, 2).join('-').toUpperCase()
} else {
throw new Error(`invalid guid: ${guid}`)
}
}
module.exports = helpers

2

lib/helpers/parse_claim.js

@@ -49,3 +49,3 @@ const { wikibaseTimeToISOString, wikibaseTimeToEpochTime, wikibaseTimeToSimpleDay } = require('./helpers')

const time = (datavalue, options) => {
var timeValue
let timeValue
if (typeof options.timeConverter === 'function') {

@@ -52,0 +52,0 @@ timeValue = options.timeConverter(datavalue.value)

@@ -60,3 +60,3 @@ const { parse: parseClaim } = require('./parse_claim')

var value, datatype, datavalue, snaktype, isQualifierSnak, isReferenceSnak
let value, datatype, datavalue, snaktype, isQualifierSnak, isReferenceSnak
if (mainsnak) {

@@ -144,3 +144,3 @@ datatype = mainsnak.datatype

// Legacy interface
var [ entityPrefix, propertyPrefix, keepQualifiers ] = options
const [ entityPrefix, propertyPrefix, keepQualifiers ] = options
return { entityPrefix, propertyPrefix, keepQualifiers }

@@ -147,0 +147,0 @@ }

@@ -21,3 +21,3 @@ module.exports = (input, options = {}) => {

if (!(valueObj)) return
var { datatype } = valueObj
let { datatype } = valueObj
datatype = datatype && datatype.replace('http://www.w3.org/2001/XMLSchema#', '')

@@ -106,3 +106,3 @@ const parser = parsers[valueObj.type] || getDatatypesParsers(datatype)

// ex: propertyType => Type
var shortAssociatedVarName = associatedVarName.split(varName)[1]
let shortAssociatedVarName = associatedVarName.split(varName)[1]
// ex: Type => type

@@ -109,0 +109,0 @@ shortAssociatedVarName = shortAssociatedVarName[0].toLowerCase() + shortAssociatedVarName.slice(1)

@@ -8,3 +8,3 @@ module.exports = wikibaseTime => {

const sign = wikibaseTime[0]
var [ yearMonthDay, withinDay ] = wikibaseTime.slice(1).split('T')
let [ yearMonthDay, withinDay ] = wikibaseTime.slice(1).split('T')

@@ -27,3 +27,3 @@ // Wikidata generates invalid ISO dates to indicate precision

const expandedYearDate = (sign, rest, year) => {
var date
let date
// Using ISO8601 expanded notation for negative years or positive

@@ -30,0 +30,0 @@ // years with more than 4 digits: adding up to 2 leading zeros

@@ -13,3 +13,3 @@ const { forceArray } = require('../utils/utils')

return (property, value, options = {}) => {
var { limit, caseInsensitive, keepProperties } = options
const { limit, caseInsensitive, keepProperties } = options
const valueFn = caseInsensitive ? caseInsensitiveValueQuery : directValueQuery

@@ -19,3 +19,3 @@ const filter = keepProperties ? '' : itemsOnly

// Allow to request values for several properties at once
var properties = forceArray(property)
let properties = forceArray(property)
properties.forEach(validate.propertyId)

@@ -25,3 +25,3 @@ properties = properties.map(prefixifyProperty).join('|')

const valueBlock = getValueBlock(value, valueFn, properties, filter)
var sparql = `SELECT DISTINCT ?subject WHERE { ${valueBlock} }`
let sparql = `SELECT DISTINCT ?subject WHERE { ${valueBlock} }`
if (limit) sparql += ` LIMIT ${limit}`

@@ -28,0 +28,0 @@ return sparqlQuery(sparql)

@@ -6,3 +6,3 @@ const { isPlainObject } = require('../utils/utils')

// Using the variable 'offset' instead of 'continue' as the later is a reserved word
var type, offset
let type, offset

@@ -9,0 +9,0 @@ // polymorphism: arguments can be passed as an object keys

module.exports = {
stringify: queryObj => {
var qstring = ''
let qstring = ''
for (const key in queryObj) {

@@ -5,0 +5,0 @@ const value = queryObj[key]

@@ -14,3 +14,3 @@ const { isPlainObject } = require('./utils/utils')

const WBK = function (config) {
const WBK = config => {
if (!isPlainObject(config)) throw new Error('invalid config')

@@ -23,3 +23,3 @@ const { instance, sparqlEndpoint } = config

var wikibaseApiFunctions, instanceRoot, instanceApiEndpoint
let wikibaseApiFunctions, instanceRoot, instanceApiEndpoint
if (instance) {

@@ -55,3 +55,3 @@ validateEndpoint('instance', instance)

var wikibaseQueryServiceFunctions
let wikibaseQueryServiceFunctions
if (sparqlEndpoint) {

@@ -58,0 +58,0 @@ validateEndpoint('sparqlEndpoint', sparqlEndpoint)

{
"name": "wikibase-sdk",
"version": "7.8.0",
"version": "7.9.0",
"description": "utils functions to query a Wikibase instance and simplify its results",

@@ -18,4 +18,4 @@ "main": "lib/wikibase-sdk.js",

"check-supported-datatypes": "./scripts/check_supported_datatypes",
"lint": "standardx --verbose",
"lint-fix": "standardx --verbose --fix",
"lint": "eslint -c .eslintrc lib scripts test",
"lint-fix": "eslint -c .eslintrc lib scripts test --fix",
"minify": "./scripts/minify",

@@ -54,2 +54,9 @@ "test": "mocha",

"browserify": "^16.2.3",
"eslint": "^7.10.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-arrow": "^1.2.2",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"git-hooks": "^1.1.10",

@@ -66,13 +73,3 @@ "lodash": "^4.17.15",

},
"dependencies": {},
"standardx": {
"ignore": [
"dist"
],
"globals": [
"it",
"describe",
"WBK"
]
}
"dependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc