wikibase-sdk
Advanced tools
Comparing version 7.1.5 to 7.1.6
@@ -11,3 +11,3 @@ const { parse: parseClaim } = require('./parse_claim') | ||
for (let id in claims) { | ||
let propClaims = claims[id] | ||
const propClaims = claims[id] | ||
if (propertyPrefix) { | ||
@@ -14,0 +14,0 @@ id = propertyPrefix + ':' + id |
@@ -88,7 +88,7 @@ module.exports = (input, options = {}) => { | ||
const simplifiedResult = {} | ||
for (let varName of richVars) { | ||
let richVarData = {} | ||
let value = parseValue(result[varName]) | ||
for (const varName of richVars) { | ||
const richVarData = {} | ||
const value = parseValue(result[varName]) | ||
if (value != null) richVarData.value = value | ||
for (let associatedVarName of associatedVars) { | ||
for (const associatedVarName of associatedVars) { | ||
if (associatedVarName.startsWith(varName)) addAssociatedValue(result, varName, associatedVarName, richVarData) | ||
@@ -98,3 +98,3 @@ } | ||
} | ||
for (let varName of standaloneVars) { | ||
for (const varName of standaloneVars) { | ||
simplifiedResult[varName] = parseValue(result[varName]) | ||
@@ -101,0 +101,0 @@ } |
// Generated by 'npm run update-sitelinks-languages' | ||
module.exports = ['aa', 'ab', 'af', 'ak', 'als', 'am', 'ang', 'an', 'ar', 'ast', 'as', 'av', 'ay', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'chr', 'ch', 'co', 'cr', 'csb', 'cs', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'got', 'gu', 'gv', 'ha', 'he', 'hif', 'hi', 'hr', 'hsb', 'ht', 'hu', 'hy', 'ia', 'id', 'ie', 'ik', 'io', 'is', 'it', 'iu', 'ja', 'jbo', 'jv', 'ka', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kw', 'ky', 'la', 'lb', 'li', 'ln', 'lo', 'lt', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mo', 'mr', 'ms', 'mt', 'my', 'nah', 'na', 'nds', 'ne', 'nl', 'nn', 'no', 'oc', 'om', 'or', 'pa', 'pi', 'pl', 'pms', 'pnb', 'ps', 'pt', 'qu', 'rm', 'rn', 'roa_rup', 'ro', 'ru', 'rw', 'sah', 'sa', 'scn', 'sc', 'sd', 'se', 'sg', 'sh', 'simple', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tpi', 'tr', 'ts', 'tt', 'tw', 'ug', 'uk', 'ur', 'uz', 'vec', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'yue', 'za', 'zh_min_nan', 'zh', 'zu', 'ace', 'arc', 'arz', 'bar', 'bat_smg', 'bcl', 'be_x_old', 'bjn', 'bpy', 'bug', 'bxr', 'cbk_zam', 'cdo', 'ce', 'ceb', 'cho', 'chy', 'ckb', 'crh', 'cu', 'diq', 'dsb', 'ee', 'eml', 'ext', 'ff', 'fiu_vro', 'frp', 'frr', 'fur', 'gag', 'gan', 'glk', 'hak', 'haw', 'ho', 'hz', 'ig', 'ii', 'ilo', 'kaa', 'kab', 'kbd', 'kg', 'ki', 'kj', 'koi', 'krc', 'ksh', 'kv', 'lad', 'lbe', 'lez', 'lg', 'lij', 'lmo', 'ltg', 'mai', 'map_bms', 'mdf', 'mhr', 'min', 'mrj', 'mus', 'mwl', 'myv', 'mzn', 'nap', 'nds_nl', 'new', 'ng', 'nov', 'nrm', 'nso', 'nv', 'ny', 'os', 'pag', 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pih', 'pnt', 'rmy', 'roa_tara', 'rue', 'sco', 'srn', 'stq', 'szl', 'tet', 'tum', 'ty', 'tyv', 'udm', 've', 'vep', 'vls', 'war', 'wuu', 'xal', 'xmf', 'zea', 'zh_classical', 'zh_yue', 'lrc', 'gom', 'azb', 'ady', 'jam', 'tcy', 'olo', 'dty', 'atj', 'kbp', 'din', 'gor', 'inh', 'lfn', 'sat', 'shn', 'hyw'] | ||
module.exports = [ 'aa', 'ab', 'af', 'ak', 'als', 'am', 'ang', 'an', 'ar', 'ast', 'as', 'av', 'ay', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'chr', 'ch', 'co', 'cr', 'csb', 'cs', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'got', 'gu', 'gv', 'ha', 'he', 'hif', 'hi', 'hr', 'hsb', 'ht', 'hu', 'hy', 'ia', 'id', 'ie', 'ik', 'io', 'is', 'it', 'iu', 'ja', 'jbo', 'jv', 'ka', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kw', 'ky', 'la', 'lb', 'li', 'ln', 'lo', 'lt', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mo', 'mr', 'ms', 'mt', 'my', 'nah', 'nap', 'na', 'nds', 'ne', 'nl', 'nn', 'no', 'oc', 'om', 'or', 'pa', 'pi', 'pl', 'pms', 'pnb', 'ps', 'pt', 'qu', 'rm', 'rn', 'roa_rup', 'ro', 'ru', 'rw', 'sah', 'sa', 'scn', 'sc', 'sd', 'se', 'sg', 'sh', 'simple', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tpi', 'tr', 'ts', 'tt', 'tw', 'ug', 'uk', 'ur', 'uz', 'vec', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'yue', 'za', 'zh_min_nan', 'zh', 'zu', 'ace', 'arc', 'arz', 'bar', 'bat_smg', 'bcl', 'be_x_old', 'bjn', 'bpy', 'bug', 'bxr', 'cbk_zam', 'cdo', 'ce', 'ceb', 'cho', 'chy', 'ckb', 'crh', 'cu', 'diq', 'dsb', 'ee', 'eml', 'ext', 'ff', 'fiu_vro', 'frp', 'frr', 'fur', 'gag', 'gan', 'glk', 'hak', 'haw', 'ho', 'hz', 'ig', 'ii', 'ilo', 'kaa', 'kab', 'kbd', 'kg', 'ki', 'kj', 'koi', 'krc', 'ksh', 'kv', 'lad', 'lbe', 'lez', 'lg', 'lij', 'lmo', 'ltg', 'mai', 'map_bms', 'mdf', 'mhr', 'min', 'mrj', 'mus', 'mwl', 'myv', 'mzn', 'nds_nl', 'new', 'ng', 'nov', 'nrm', 'nso', 'nv', 'ny', 'os', 'pag', 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pih', 'pnt', 'rmy', 'roa_tara', 'rue', 'sco', 'srn', 'stq', 'szl', 'tet', 'tum', 'ty', 'tyv', 'udm', 've', 'vep', 'vls', 'war', 'wuu', 'xal', 'xmf', 'zea', 'zh_classical', 'zh_yue', 'lrc', 'gom', 'azb', 'ady', 'jam', 'tcy', 'olo', 'dty', 'atj', 'kbp', 'din', 'gor', 'inh', 'lfn', 'sat', 'shn', 'hyw', 'nqo', 'ban' ] |
@@ -21,3 +21,3 @@ const { isPlainObject } = require('../utils/utils') | ||
while (ids.length > 0) { | ||
let group = ids.slice(0, 50) | ||
const group = ids.slice(0, 50) | ||
ids = ids.slice(50) | ||
@@ -24,0 +24,0 @@ groups.push(group) |
module.exports = { | ||
stringify: queryObj => { | ||
var qstring = '' | ||
for (let key in queryObj) { | ||
let value = queryObj[key] | ||
for (const key in queryObj) { | ||
const value = queryObj[key] | ||
if (value) qstring += `&${key}=${value}` | ||
@@ -7,0 +7,0 @@ } |
@@ -8,2 +8,5 @@ const { isPlainObject } = require('./utils/utils') | ||
const rankHelpers = require('../lib/helpers/rank') | ||
const tip = `Tip: if you just want to access functions that don't need an instance or a sparqlEndpoint, | ||
those are also exposed directly on the module object. Exemple: | ||
const { isItemId, simplify } = require('wikibase-sdk')` | ||
@@ -16,19 +19,35 @@ const common = Object.assign({ simplify, parse }, helpers, sitelinksHelpers, rankHelpers) | ||
validateEndpoint('instance', instance) | ||
if (!(instance || sparqlEndpoint)) { | ||
throw new Error(`one of instance or sparqlEndpoint should be set at initialization.\n${tip}`) | ||
} | ||
const instanceRoot = instance | ||
.replace(/\/$/, '') | ||
.replace('/w/api.php', '') | ||
var wikibaseApiFunctions, instanceRoot, instanceApiEndpoint | ||
if (instance) { | ||
validateEndpoint('instance', instance) | ||
const instanceApiEndpoint = `${instanceRoot}/w/api.php` | ||
instanceRoot = instance | ||
.replace(/\/$/, '') | ||
.replace('/w/api.php', '') | ||
const buildUrl = require('./utils/build_url')(instanceApiEndpoint) | ||
instanceApiEndpoint = `${instanceRoot}/w/api.php` | ||
const wikibaseApiFunctions = { | ||
searchEntities: require('./queries/search_entities')(buildUrl), | ||
getEntities: require('./queries/get_entities')(buildUrl), | ||
getManyEntities: require('./queries/get_many_entities')(buildUrl), | ||
getRevisions: require('./queries/get_revisions')(buildUrl), | ||
getEntityRevision: require('./queries/get_entity_revision')(instance), | ||
getEntitiesFromSitelinks: require('./queries/get_entities_from_sitelinks')(buildUrl) | ||
const buildUrl = require('./utils/build_url')(instanceApiEndpoint) | ||
wikibaseApiFunctions = { | ||
searchEntities: require('./queries/search_entities')(buildUrl), | ||
getEntities: require('./queries/get_entities')(buildUrl), | ||
getManyEntities: require('./queries/get_many_entities')(buildUrl), | ||
getRevisions: require('./queries/get_revisions')(buildUrl), | ||
getEntityRevision: require('./queries/get_entity_revision')(instance), | ||
getEntitiesFromSitelinks: require('./queries/get_entities_from_sitelinks')(buildUrl) | ||
} | ||
} else { | ||
wikibaseApiFunctions = { | ||
searchEntities: missingInstance('searchEntities'), | ||
getEntities: missingInstance('getEntities'), | ||
getManyEntities: missingInstance('getManyEntities'), | ||
getRevisions: missingInstance('getRevisions'), | ||
getEntityRevision: missingInstance('getEntityRevision'), | ||
getEntitiesFromSitelinks: missingInstance('getEntitiesFromSitelinks') | ||
} | ||
} | ||
@@ -50,3 +69,3 @@ | ||
return Object.assign({ | ||
const parsedData = { | ||
instance: { | ||
@@ -56,3 +75,5 @@ root: instanceRoot, | ||
} | ||
}, common, wikibaseApiFunctions, wikibaseQueryServiceFunctions) | ||
} | ||
return Object.assign(parsedData, common, wikibaseApiFunctions, wikibaseQueryServiceFunctions) | ||
} | ||
@@ -70,6 +91,9 @@ | ||
const missingSparqlEndpoint = name => () => { | ||
throw new Error(`${name} requires a sparqlEndpoint to be set in configuration object`) | ||
const missingConfig = missingParameter => name => () => { | ||
throw new Error(`${name} requires ${missingParameter} to be set at initialization`) | ||
} | ||
const missingSparqlEndpoint = missingConfig('a sparqlEndpoint') | ||
const missingInstance = missingConfig('an instance') | ||
module.exports = WBK |
{ | ||
"name": "wikibase-sdk", | ||
"version": "7.1.5", | ||
"version": "7.1.6", | ||
"description": "A javascript tool-suite to query wikibase and simplify its results", | ||
@@ -19,3 +19,4 @@ "main": "lib/wikibase-sdk.js", | ||
"check-supported-datatypes": "./scripts/check_supported_datatypes", | ||
"lint": "standard", | ||
"lint": "standardx --verbose", | ||
"lint-fix": "standardx --verbose --fix", | ||
"minify": "./scripts/minify", | ||
@@ -61,3 +62,3 @@ "test": "mocha", | ||
"should": "^13.2.1", | ||
"standard": "^10.0.3", | ||
"standardx": "^5.0.0", | ||
"uglify-js": "^3.3.25", | ||
@@ -70,3 +71,3 @@ "wikidata-cli": "^6.0.8" | ||
"dependencies": {}, | ||
"standard": { | ||
"standardx": { | ||
"ignore": [ | ||
@@ -73,0 +74,0 @@ "dist" |
64773
1027