New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wikidata-sdk

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wikidata-sdk - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

2

bower.json
{
"name": "wikidata-sdk",
"version": "6.0.0",
"version": "6.0.1",
"homepage": "https://github.com/maxlath/wikidata-sdk",

@@ -5,0 +5,0 @@ "authors": [

@@ -889,2 +889,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.wdk = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -899,10 +901,16 @@

var sign = wikidataTime[0];
var rest = wikidataTime.slice(1);
var date = fullDateData(sign, rest);
if (date.toString() === 'Invalid Date') {
return parseInvalideDate(sign, rest);
} else {
return date;
}
var _wikidataTime$slice$s = wikidataTime.slice(1).split('T'),
_wikidataTime$slice$s2 = _slicedToArray(_wikidataTime$slice$s, 2),
yearMonthDay = _wikidataTime$slice$s2[0],
withinDay = _wikidataTime$slice$s2[1];
// Wikidata generates invalid ISO dates to indicate precision
// ex: +1990-00-00T00:00:00Z to indicate 1990 with year precision
yearMonthDay = yearMonthDay.replace(/-00/g, '-01');
var rest = yearMonthDay + 'T' + withinDay;
return fullDateData(sign, rest);
};

@@ -933,10 +941,2 @@

var parseInvalideDate = function parseInvalideDate(sign, rest) {
// This is probably a date of unsuffisient precision
// such as 1953-00-00T00:00:00Z, thus invalid
// It should at least have a year, so let's fallback to ${year}-01-01
var year = rest.split('T')[0].split('-')[0];
return fullDateData(sign, year);
};
},{}],12:[function(require,module,exports){

@@ -943,0 +943,0 @@ 'use strict';

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).wdk=e()}}(function(){return function s(o,a,u){function l(t,e){if(!a[t]){if(!o[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var n=a[t]={exports:{}};o[t][0].call(n.exports,function(e){return l(o[t][1][e]||e)},n,n.exports,s,o,a,u)}return a[t].exports}for(var c="function"==typeof require&&require,e=0;e<u.length;e++)l(u[e]);return l}({1:[function(e,t,i){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=e("./wikidata_time_to_date_object"),s={isNumericId:function(e){return/^[1-9][0-9]*$/.test(e)},isEntityId:function(e){return/^(Q|P)[1-9][0-9]*$/.test(e)},isItemId:function(e){return/^Q[1-9][0-9]*$/.test(e)},isPropertyId:function(e){return/^P[1-9][0-9]*$/.test(e)},isGuid:function(e){return/^(Q|P|L)\d+\$[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)},getNumericId:function(e){if(!s.isEntityId(e))throw new Error("invalid wikidata id: "+e);return e.replace(/Q|P/,"")}};s.wikidataTimeToDateObject=r;var o=function(e){return function(t){try{return e(t)}catch(e){return(t=t.time||t).replace("-00-00","-01-01")}}};s.wikidataTimeToEpochTime=o(function(e){return r(e).getTime()}),s.wikidataTimeToISOString=o(function(e){return r(e).toISOString()}),s.wikidataTimeToSimpleDay=o(function(e){if("object"===(void 0===e?"undefined":n(e))){var t=e,i=t.time,r=t.precision;e=9===r?i.replace("-01-01T","-00-00T"):10===r?i.replace("-01T","-00T"):i}return e.split("T")[0].replace(/^\+/,"").replace(/^(-?)0+/,"$1").replace(/-00$/,"").replace(/-00$/,"")}),s.getImageUrl=function(e,t){var i="https://commons.wikimedia.org/wiki/Special:FilePath/"+e;return"number"==typeof t&&(i+="?width="+t),i},t.exports=s},{"./wikidata_time_to_date_object":11}],2:[function(e,t,i){"use strict";var r=e("./helpers"),n=r.wikidataTimeToISOString,s=r.wikidataTimeToEpochTime,o=r.wikidataTimeToSimpleDay,a=function(e){return e.value},u=function(e,t){return c(e,t.entityPrefix)},l={item:"Q",lexeme:"L",property:"P"},c=function(e,t){var i=e.value,r=i.id||l[i["entity-type"]]+i["numeric-id"];return"string"==typeof t?t+":"+r:r},f=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"iso";return p[e]},p={iso:n,epoch:s,"simple-day":o,none:function(e){return e.time||e}},m={string:a,commonsMedia:a,url:a,"external-id":a,math:a,monolingualtext:function(e,t){return t.keepRichValues?e.value:e.value.text},"wikibase-item":u,"wikibase-lexeme":u,"wikibase-property":u,time:function(e,t){return f(t.timeConverter)(e.value)},quantity:function(e,t){var i=e.value,r=parseFloat(i.amount);return t.keepRichValues?{amount:parseFloat(i.amount),unit:i.unit.replace("http://www.wikidata.org/entity/",""),upperBound:parseFloat(i.upperBound),lowerBound:parseFloat(i.lowerBound)}:r},"globe-coordinate":function(e){return[e.value.latitude,e.value.longitude]},"geo-shape":a,"tabular-data":a};t.exports={parsers:m,parse:function(t,e,i,r){if(!t)return console.error("invalid claim",r),null;try{return m[t](e,i)}catch(e){throw"parsers[datatype] is not a function"===e.message&&(e.message=t+" claim parser isn't implemented\n Claim id: "+r+"\n Please report to https://github.com/maxlath/wikidata-sdk/issues"),e}}}},{"./helpers":1}],3:[function(e,t,i){"use strict";var r=e("./simplify_entity").simplifyEntity;t.exports={wd:{entities:function(e){var t=(e=e.body||e).entities;return Object.keys(t).forEach(function(e){t[e]=r(t[e])}),t}}}},{"./simplify_entity":5}],4:[function(e,t,i){"use strict";var r=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var i=[],r=!0,n=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done)&&(i.push(o.value),!t||i.length!==t);r=!0);}catch(e){n=!0,s=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw s}}return i}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w=e("./parse_claim").parse,u=e("../utils/utils").uniq,k=function(e){for(var t=arguments.length,i=Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];var n=_(i).propertyPrefix,s={};for(var o in e){var a=e[o];n&&(o=n+":"+o),s[o]=l.apply(void 0,[a].concat(i))}return s},l=function(e){for(var t=arguments.length,i=Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];if(null==e||0===e.length)return[];var n=_(i),s=n.keepNonTruthy,o=n.areSubSnaks;return s||o||(e=c(e)),(e=e.map(function(e){return p.apply(void 0,[e].concat(i))}).filter(f))[0]&&"object"!==a(e[0])?u(e):e},n=function(e,t){var i=t.rank;return e[i]||(e[i]=[]),e[i].push(t),e},c=function(e){var t=e.reduce(n,{});return t.preferred||t.normal||[]},f=function(e){return void 0!==e},p=function(e){for(var t=arguments.length,i=Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];var n,s,o,a,u,l,c=i=_(i),f=c.keepQualifiers,p=c.keepReferences,m=c.keepIds,y=c.keepHashes,d=c.keepTypes,v=e.mainsnak;if(v?(s=v.datatype,o=v.datavalue,a=v.snaktype):(o=e.datavalue,s=e.datatype,a=e.snaktype,e.hash?u=!0:l=!0),o)n=w(s,o,i,e.id);else if("somevalue"===a)n=i.somevalueValue;else{if("novalue"!==a)throw new Error("no datavalue or special snaktype found");n=i.novalueValue}if(u){if(!y&&!d)return n;var h={value:n};return y&&(h.hash=e.hash),d&&(h.type=s),h}if(l)return d?{type:s,value:n}:n;if(!(f||p||m||d))return n;var g={value:n};d&&(g.type=s);var b=j(i);return b.keepHashes=y,f&&(g.qualifiers=k(e.qualifiers,b)),p&&(e.references=e.references||[],g.references=e.references.map(function(e){var t=k(e.snaks,b);return y?{snaks:t,hash:e.hash}:t})),m&&(g.id=e.id),g},_=function(e){if(null==e)return{};if(e[0]&&"object"===a(e[0]))return e[0];var t=r(e,3);return{entityPrefix:t[0],propertyPrefix:t[1],keepQualifiers:t[2]}},j=function(e){return Object.assign({},e,{areSubSnaks:!0})};t.exports={simplifyClaims:k,simplifyPropertyClaims:l,simplifyClaim:p,truthyClaims:function(t){var i={};return Object.keys(t).forEach(function(e){i[e]=c(t[e])}),i},truthyPropertyClaims:c,simplifyQualifiers:function(e,t){return k(e,j(t))},simplifyPropertyQualifiers:function(e,t){return l(e,j(t))},simplifyQualifier:p}},{"../utils/utils":22,"./parse_claim":2}],5:[function(e,t,i){"use strict";var r=e("./simplify_claims").simplifyClaims,n=e("./simplify_text_attributes"),s=e("./simplify_sitelinks"),o=function(e,t){var i={id:e.id,type:e.type,modified:e.modified};return a(e,i,"labels"),a(e,i,"descriptions"),a(e,i,"aliases"),null!=e.claims&&(i.claims=r(e.claims,t)),null!=e.sitelinks&&(i.sitelinks=s(e.sitelinks,t)),i},a=function(e,t,i){null!=e[i]&&(t[i]=n[i](e[i]))};t.exports={simplifyEntity:o,simplifyEntities:function(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},s=n.entityPrefix;return Object.keys(r).reduce(function(e,t){var i=r[t];return s&&(t=s+":"+t),e[t]=o(i,n),e},{})}}},{"./simplify_claims":4,"./simplify_sitelinks":6,"./simplify_text_attributes":8}],6:[function(e,t,i){"use strict";var s=e("./sitelinks_helpers").getSitelinkUrl;t.exports=function(e){var t=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).addUrl;return Object.keys(e).reduce(r(e,t),{})};var r=function(r,n){return function(e,t){var i=r[t].title;return e[t]=n?{title:i,url:s(t,i)}:i,e}}},{"./sitelinks_helpers":9}],7:[function(e,t,i){"use strict";t.exports=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};"string"==typeof e&&(e=JSON.parse(e));var i=e.head.vars,r=e.results.bindings;if(1===i.length&&!0===t.minimize){var n=i[0];return r.map(function(e){return h(e[n])}).filter(function(e){return null!=e})}var s=c(i),o=s.richVars,a=s.standaloneVars;return r.map(y(o,a))};var h=function(e){if(e){var t=e.datatype;return t=t&&t.replace("http://www.w3.org/2001/XMLSchema#",""),(r[e.type]||s(t))(e)}},r={uri:function(e){return u(e.value)},bnode:function(){return null}},n=function(e){return parseFloat(e.value)},s=function(e){return e=e&&e.replace("http://www.w3.org/2001/XMLSchema#",""),o[e]||a},o={decimal:n,integer:n,float:n,double:n,boolean:function(e){return"true"===e.value}},a=function(e){return e.value},u=function(e){return e.startsWith("http://www.wikidata.org/entity/statement/")?l(e):e.replace("http://www.wikidata.org/entity/","").replace("http://www.wikidata.org/prop/direct/","")},l=function(e){var t=(e=e.replace("http://www.wikidata.org/entity/statement/","")).split("-");return t[0]+"$"+t.slice(1).join("-")},c=function(e){return e.reduce(f(e),{richVars:[],standaloneVars:[]})},f=function(r){return function(e,t){if(r.some(m(t)))return e.richVars.push(t),e;if(!p.test(t))return e.standaloneVars.push(t),e;var i=t.replace(p,"$1").replace(/Alt$/,"");return r.includes(i)||e.standaloneVars.push(t),e}},p=/^(\w+)(Label|Description|AltLabel)$/,m=function(t){return function(e){return t+"Label"===e||(t+"Description"===e||t+"AltLabel"===e)}},y=function(d,v){return function(e){var t={},i=!0,r=!1,n=void 0;try{for(var s,o=d[Symbol.iterator]();!(i=(s=o.next()).done);i=!0){var a=s.value,u=h(e[a]);null!=u&&(t[a]={value:u},g(e,a,"label",t[a]),g(e,a,"description",t[a]),g(e,a,"aliases",t[a]))}}catch(e){r=!0,n=e}finally{try{!i&&o.return&&o.return()}finally{if(r)throw n}}var l=!0,c=!1,f=void 0;try{for(var p,m=v[Symbol.iterator]();!(l=(p=m.next()).done);l=!0){var y=p.value;t[y]=h(e[y])}}catch(e){c=!0,f=e}finally{try{!l&&m.return&&m.return()}finally{if(c)throw f}}return t}},g=function(e,t,i,r){var n=e[t+d[i]];null!=n&&(r[i]=n.value)},d={label:"Label",description:"Description",aliases:"AltLabel"}},{}],8:[function(e,t,i){"use strict";var r=function(t){return function(e){return Object.keys(e).reduce(n(e,t),{})}},n=function(r,n){return function(e,t){var i=r[t];return e[t]=n?i.map(s):i.value,e}},s=function(e){return e.value},o=r(!1);t.exports={labels:o,descriptions:o,aliases:r(!0)}},{}],9:[function(e,t,i){"use strict";var a=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var i=[],r=!0,n=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done)&&(i.push(o.value),!t||i.length!==t);r=!0);}catch(e){n=!0,s=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw s}}return i}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},r=e("../utils/utils"),s=r.fixedEncodeURIComponent,o=r.replaceSpaceByUnderscores,u=r.isPlainObject,n=e("./helpers").isPropertyId,l="https://www.wikidata.org/wiki/",c=e("./sitelinks_languages"),f=function(t){return function(e){return"https://"+t+".wikimedia.org/wiki/"+e}},p={commons:f("commons"),mediawiki:function(e){return"https://www.mediawiki.org/wiki/"+e},meta:f("meta"),species:f("species"),wikidata:function(e){return n(e)?l+"Property:"+e:""+l+e}},m=function(e){var t=y[e];if(t)return{lang:"en",project:t};var i=e.split("wik"),r=a(i,3),n=r[0],s=r[1];if(null!=r[2])throw new Error("invalid sitelink: "+e);if(-1===c.indexOf(n))throw new Error("sitelink lang not found: "+n);var o=d[s];if(!o)throw new Error("sitelink project not found: "+o);return{lang:n,project:o}},y={commonswiki:"commons",mediawikiwiki:"mediawiki",metawiki:"meta",specieswiki:"specieswiki",wikidatawiki:"wikidata"},d={i:"wikipedia",isource:"wikisource",iquote:"wikiquote",tionary:"wiktionary",ibooks:"wikibooks",iversity:"wikiversity",ivoyage:"wikivoyage",inews:"wikinews"};t.exports={getSitelinkUrl:function(e,t){if(u(e)&&(t=e.title,e=e.site),!e)throw new Error("missing a site");if(!t)throw new Error("missing a title");var i=e.replace(/wiki$/,""),r=p[i]||p[e];if(r)return r(t);var n=m(e);return"https://"+n.lang+"."+n.project+".org/wiki/"+(t=s(o(t)))},getSitelinkData:m,isSitelinkKey:function(e){try{return m(e),!0}catch(e){return!1}}}},{"../utils/utils":22,"./helpers":1,"./sitelinks_languages":10}],10:[function(e,t,i){"use strict";t.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"]},{}],11:[function(e,t,i){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.exports=function(e){"object"===(void 0===e?"undefined":n(e))&&(e=e.time);var t=e[0],i=e.slice(1),r=s(t,i);return"Invalid Date"===r.toString()?a(t,i):r};var s=function(e,t){return"-"===e?o(t):r(t)},r=function(e){return new Date(e)},o=function(e){var t,i=e.split("-")[0];return t=4===i.length?"-00"+e:5===i.length?"-0"+e:"-"+e,new Date(t)},a=function(e,t){var i=t.split("T")[0].split("-")[0];return s(e,i)}},{}],12:[function(e,t,i){"use strict";var r=t.exports={};r.searchEntities=e("./queries/search_entities"),r.getEntities=e("./queries/get_entities"),r.getManyEntities=e("./queries/get_many_entities"),r.sparqlQuery=e("./queries/sparql_query"),r.getReverseClaims=e("./queries/get_reverse_claims"),r.getRevisions=e("./queries/get_revisions"),r.getEntitiesFromSitelinks=e("./queries/get_entities_from_sitelinks"),r.getWikidataIdsFromSitelinks=r.getEntitiesFromSitelinks,r.parse=e("./helpers/parse_responses");var n=e("./helpers/simplify_claims"),s=e("./helpers/simplify_sparql_results");r.simplify=e("../lib/helpers/simplify_text_attributes");var o=e("../lib/helpers/simplify_entity"),a=o.simplifyEntity,u=o.simplifyEntities;r.simplify.entity=a,r.simplify.entities=u,r.simplify.claim=n.simplifyClaim,r.simplify.propertyClaims=n.simplifyPropertyClaims,r.simplify.claims=n.simplifyClaims,r.simplify.qualifier=n.simplifyQualifier,r.simplify.propertyQualifiers=n.simplifyPropertyQualifiers,r.simplify.qualifiers=n.simplifyQualifiers,r.simplify.sitelinks=e("../lib/helpers/simplify_sitelinks"),r.simplify.sparqlResults=s,r.simplifySparqlResults=e("./helpers/simplify_sparql_results"),Object.assign(r,n),r.getWikidataIdsFromWikipediaTitles=r.getWikidataIdsFromSitelinks;var l=e("../lib/helpers/helpers"),c=e("../lib/helpers/sitelinks_helpers");Object.assign(r,l,c)},{"../lib/helpers/helpers":1,"../lib/helpers/simplify_entity":5,"../lib/helpers/simplify_sitelinks":6,"../lib/helpers/simplify_text_attributes":8,"../lib/helpers/sitelinks_helpers":9,"./helpers/parse_responses":3,"./helpers/simplify_claims":4,"./helpers/simplify_sparql_results":7,"./queries/get_entities":13,"./queries/get_entities_from_sitelinks":14,"./queries/get_many_entities":15,"./queries/get_reverse_claims":16,"./queries/get_revisions":17,"./queries/search_entities":18,"./queries/sparql_query":19}],13:[function(e,t,i){"use strict";var o=e("../utils/build_url"),r=e("../utils/utils"),a=r.isPlainObject,u=r.forceArray,l=r.shortLang;t.exports=function(e,t,i,r){if(a(e)){var n=e;e=n.ids,t=n.languages,i=n.props,r=n.format}if(r=r||"json",!(e&&0<e.length))throw new Error("no id provided");50<(e=u(e)).length&&console.warn("getEntities accepts 50 ids max to match Wikidata API limitations:\n this request won't get all the desired entities.\n You can use getManyEntities instead to generate several request urls\n to work around this limitation");var s={action:"wbgetentities",ids:e.join("|"),format:r};return t&&(t=u(t).map(l),s.languages=t.join("|")),i&&0<i.length&&(s.props=u(i).join("|")),o(s)}},{"../utils/build_url":20,"../utils/utils":22}],14:[function(e,t,i){"use strict";var a=e("../utils/build_url"),r=e("../utils/utils"),u=r.isPlainObject,l=r.forceArray,c=r.shortLang;t.exports=function(e,t,i,r,n){if(u(e)){var s=e;e=s.titles,t=s.sites,i=s.languages,r=s.props,n=s.format}if(n=n||"json",!(e&&0<e.length))throw new Error("no title provided");t&&0<t.length||(t=["enwiki"]),e=l(e),t=l(t).map(f),r=l(r);var o={action:"wbgetentities",titles:e.join("|"),sites:t.join("|"),format:n};return 1===t.length&&1===e.length&&(o.normalize=!0),i&&(i=l(i).map(c),o.languages=i.join("|")),r&&0<r.length&&(o.props=r.join("|")),a(o)};var f=function(e){return 2===e.length?e+"wiki":e}},{"../utils/build_url":20,"../utils/utils":22}],15:[function(e,t,i){"use strict";var s=e("./get_entities"),o=e("../utils/utils").isPlainObject;t.exports=function(e,t,i,r){if(o(e)){var n=e;e=n.ids,t=n.languages,i=n.props,r=n.format}if(!(e instanceof Array))throw new Error("getManyEntities expects an array of ids");return a(e).map(function(e){return s(e,t,i,r)})};var a=function(e){for(var t=[];0<e.length;){var i=e.slice(0,50);e=e.slice(50),t.push(i)}return t}},{"../utils/utils":22,"./get_entities":13}],16:[function(e,t,i){"use strict";var r=e("../helpers/helpers"),a=e("./sparql_query");function u(e){return r.isItemId(e)?e="wd:"+e:"string"==typeof e&&(e="'"+e+"'"),e}function l(e,t,i,r){return"?subject "+e+" "+t+" .\n "+i}function c(e,t,i,r){return"?subject "+e+" ?value .\n FILTER (lcase(?value) = "+t.toLowerCase()+")\n "+i}t.exports=function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=i.limit,n=i.caseInsensitive,s=i.keepProperties?"":"FILTER NOT EXISTS { ?subject rdf:type wikibase:Property . } ",o="SELECT DISTINCT ?subject WHERE { "+function(e,t,i,r){if(!(e instanceof Array))return t(i,u(e),r);return"{ "+e.map(u).map(function(e){return t(i,e,r)}).join("} UNION {")+" }"}(t,n?c:l,e=e instanceof Array?e.map(f).join("|"):f(e),s)+" }";return r&&(o+=" LIMIT "+r),a(o)};var f=function(e){return"wdt:"+e}},{"../helpers/helpers":1,"./sparql_query":19}],17:[function(e,t,i){"use strict";var n=e("../utils/build_url"),s=e("../utils/utils").forceArray;t.exports=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=1===(e=s(e)).length,r={action:"query",prop:"revisions"};return r.titles=e.join("|"),r.format=t.format||"json",i&&(r.rvlimit=t.limit||"max"),i&&t.start&&(r.rvstart=o(t.start)),i&&t.end&&(r.rvend=o(t.end)),n(r)};var o=function(e){return"number"==typeof e&&e<r?e:Math.trunc(new Date(e).getTime()/1e3)},r=new Date("2000-01-01").getTime()},{"../utils/build_url":20,"../utils/utils":22}],18:[function(e,t,i){"use strict";var a=e("../utils/build_url"),u=e("../utils/utils").isPlainObject,l=["item","property","lexeme","form","sense"];t.exports=function(e,t,i,r,n){var s;if(u(e)){var o=e;e=o.search,t=o.language,i=o.limit,r=o.format,n=o.uselang,s=o.type}if(!(e&&0<e.length))throw new Error("search can't be empty");if(t=t||"en",n=n||t,i=i||"20",r=r||"json",s=s||"item",!l.includes(s))throw new Error("invalid type: "+s);return a({action:"wbsearchentities",search:e,language:t,limit:i,format:r,uselang:n,type:s})}},{"../utils/build_url":20,"../utils/utils":22}],19:[function(e,t,i){"use strict";var r=e("../utils/utils").fixedEncodeURIComponent;t.exports=function(e){return"https://query.wikidata.org/sparql?format=json&query="+r(e)}},{"../utils/utils":22}],20:[function(e,t,i){"use strict";var r="undefined"!=typeof location&&"undefined"!=typeof document,n=e(r?"./querystring_lite":"querystring");t.exports=function(e){return r&&(e.origin="*"),"https://www.wikidata.org/w/api.php?"+n.stringify(e)}},{"./querystring_lite":21,querystring:25}],21:[function(e,t,i){"use strict";t.exports={stringify:function(e){var t="";for(var i in e){var r=e[i];r&&(t+="&"+i+"="+r)}return t=t.slice(1),encodeURI?encodeURI(t):t}}},{}],22:[function(e,t,i){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.exports={shortLang:function(e){return e.toLowerCase().split(/[^a-z]/)[0]},forceArray:function(e){return"string"==typeof e&&(e=[e]),e||[]},isPlainObject:function(e){return!(!e||"object"!==(void 0===e?"undefined":r(e))||e instanceof Array)},fixedEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/[!'()*]/g,n)},replaceSpaceByUnderscores:function(e){return e.replace(/\s/g,"_")},uniq:function(e){return Array.from(new Set(e))}};var n=function(e){return"%"+e.charCodeAt(0).toString(16)}},{}],23:[function(e,t,i){"use strict";t.exports=function(e,t,i,r){t=t||"&",i=i||"=";var n={};if("string"!=typeof e||0===e.length)return n;var s=/\+/g;e=e.split(t);var o=1e3;r&&"number"==typeof r.maxKeys&&(o=r.maxKeys);var a,u,l=e.length;0<o&&o<l&&(l=o);for(var c=0;c<l;++c){var f,p,m,y,d=e[c].replace(s,"%20"),v=d.indexOf(i);0<=v?(f=d.substr(0,v),p=d.substr(v+1)):(f=d,p=""),m=decodeURIComponent(f),y=decodeURIComponent(p),a=n,u=m,Object.prototype.hasOwnProperty.call(a,u)?h(n[m])?n[m].push(y):n[m]=[n[m],y]:n[m]=y}return n};var h=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],24:[function(e,t,i){"use strict";var s=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(i,r,n,e){return r=r||"&",n=n||"=",null===i&&(i=void 0),"object"==typeof i?a(u(i),function(e){var t=encodeURIComponent(s(e))+n;return o(i[e])?a(i[e],function(e){return t+encodeURIComponent(s(e))}).join(r):t+encodeURIComponent(s(i[e]))}).join(r):e?encodeURIComponent(s(e))+n+encodeURIComponent(s(i)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function a(e,t){if(e.map)return e.map(t);for(var i=[],r=0;r<e.length;r++)i.push(t(e[r],r));return i}var u=Object.keys||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.push(i);return t}},{}],25:[function(e,t,i){"use strict";i.decode=i.parse=e("./decode"),i.encode=i.stringify=e("./encode")},{"./decode":23,"./encode":24}]},{},[12])(12)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).wdk=e()}}(function(){return function s(o,a,u){function l(t,e){if(!a[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(c)return c(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var n=a[t]={exports:{}};o[t][0].call(n.exports,function(e){return l(o[t][1][e]||e)},n,n.exports,s,o,a,u)}return a[t].exports}for(var c="function"==typeof require&&require,e=0;e<u.length;e++)l(u[e]);return l}({1:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./wikidata_time_to_date_object"),s={isNumericId:function(e){return/^[1-9][0-9]*$/.test(e)},isEntityId:function(e){return/^(Q|P)[1-9][0-9]*$/.test(e)},isItemId:function(e){return/^Q[1-9][0-9]*$/.test(e)},isPropertyId:function(e){return/^P[1-9][0-9]*$/.test(e)},isGuid:function(e){return/^(Q|P|L)\d+\$[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)},getNumericId:function(e){if(!s.isEntityId(e))throw new Error("invalid wikidata id: "+e);return e.replace(/Q|P/,"")}};s.wikidataTimeToDateObject=i;var o=function(e){return function(t){try{return e(t)}catch(e){return(t=t.time||t).replace("-00-00","-01-01")}}};s.wikidataTimeToEpochTime=o(function(e){return i(e).getTime()}),s.wikidataTimeToISOString=o(function(e){return i(e).toISOString()}),s.wikidataTimeToSimpleDay=o(function(e){if("object"===(void 0===e?"undefined":n(e))){var t=e,r=t.time,i=t.precision;e=9===i?r.replace("-01-01T","-00-00T"):10===i?r.replace("-01T","-00T"):r}return e.split("T")[0].replace(/^\+/,"").replace(/^(-?)0+/,"$1").replace(/-00$/,"").replace(/-00$/,"")}),s.getImageUrl=function(e,t){var r="https://commons.wikimedia.org/wiki/Special:FilePath/"+e;return"number"==typeof t&&(r+="?width="+t),r},t.exports=s},{"./wikidata_time_to_date_object":11}],2:[function(e,t,r){"use strict";var i=e("./helpers"),n=i.wikidataTimeToISOString,s=i.wikidataTimeToEpochTime,o=i.wikidataTimeToSimpleDay,a=function(e){return e.value},u=function(e,t){return c(e,t.entityPrefix)},l={item:"Q",lexeme:"L",property:"P"},c=function(e,t){var r=e.value,i=r.id||l[r["entity-type"]]+r["numeric-id"];return"string"==typeof t?t+":"+i:i},f=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"iso";return p[e]},p={iso:n,epoch:s,"simple-day":o,none:function(e){return e.time||e}},m={string:a,commonsMedia:a,url:a,"external-id":a,math:a,monolingualtext:function(e,t){return t.keepRichValues?e.value:e.value.text},"wikibase-item":u,"wikibase-lexeme":u,"wikibase-property":u,time:function(e,t){return f(t.timeConverter)(e.value)},quantity:function(e,t){var r=e.value,i=parseFloat(r.amount);return t.keepRichValues?{amount:parseFloat(r.amount),unit:r.unit.replace("http://www.wikidata.org/entity/",""),upperBound:parseFloat(r.upperBound),lowerBound:parseFloat(r.lowerBound)}:i},"globe-coordinate":function(e){return[e.value.latitude,e.value.longitude]},"geo-shape":a,"tabular-data":a};t.exports={parsers:m,parse:function(t,e,r,i){if(!t)return console.error("invalid claim",i),null;try{return m[t](e,r)}catch(e){throw"parsers[datatype] is not a function"===e.message&&(e.message=t+" claim parser isn't implemented\n Claim id: "+i+"\n Please report to https://github.com/maxlath/wikidata-sdk/issues"),e}}}},{"./helpers":1}],3:[function(e,t,r){"use strict";var i=e("./simplify_entity").simplifyEntity;t.exports={wd:{entities:function(e){var t=(e=e.body||e).entities;return Object.keys(t).forEach(function(e){t[e]=i(t[e])}),t}}}},{"./simplify_entity":5}],4:[function(e,t,r){"use strict";var i=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],i=!0,n=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(i=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);i=!0);}catch(e){n=!0,s=e}finally{try{!i&&a.return&&a.return()}finally{if(n)throw s}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w=e("./parse_claim").parse,u=e("../utils/utils").uniq,k=function(e){for(var t=arguments.length,r=Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];var n=_(r).propertyPrefix,s={};for(var o in e){var a=e[o];n&&(o=n+":"+o),s[o]=l.apply(void 0,[a].concat(r))}return s},l=function(e){for(var t=arguments.length,r=Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];if(null==e||0===e.length)return[];var n=_(r),s=n.keepNonTruthy,o=n.areSubSnaks;return s||o||(e=c(e)),(e=e.map(function(e){return p.apply(void 0,[e].concat(r))}).filter(f))[0]&&"object"!==a(e[0])?u(e):e},n=function(e,t){var r=t.rank;return e[r]||(e[r]=[]),e[r].push(t),e},c=function(e){var t=e.reduce(n,{});return t.preferred||t.normal||[]},f=function(e){return void 0!==e},p=function(e){for(var t=arguments.length,r=Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];var n,s,o,a,u,l,c=r=_(r),f=c.keepQualifiers,p=c.keepReferences,m=c.keepIds,y=c.keepHashes,d=c.keepTypes,v=e.mainsnak;if(v?(s=v.datatype,o=v.datavalue,a=v.snaktype):(o=e.datavalue,s=e.datatype,a=e.snaktype,e.hash?u=!0:l=!0),o)n=w(s,o,r,e.id);else if("somevalue"===a)n=r.somevalueValue;else{if("novalue"!==a)throw new Error("no datavalue or special snaktype found");n=r.novalueValue}if(u){if(!y&&!d)return n;var h={value:n};return y&&(h.hash=e.hash),d&&(h.type=s),h}if(l)return d?{type:s,value:n}:n;if(!(f||p||m||d))return n;var g={value:n};d&&(g.type=s);var b=j(r);return b.keepHashes=y,f&&(g.qualifiers=k(e.qualifiers,b)),p&&(e.references=e.references||[],g.references=e.references.map(function(e){var t=k(e.snaks,b);return y?{snaks:t,hash:e.hash}:t})),m&&(g.id=e.id),g},_=function(e){if(null==e)return{};if(e[0]&&"object"===a(e[0]))return e[0];var t=i(e,3);return{entityPrefix:t[0],propertyPrefix:t[1],keepQualifiers:t[2]}},j=function(e){return Object.assign({},e,{areSubSnaks:!0})};t.exports={simplifyClaims:k,simplifyPropertyClaims:l,simplifyClaim:p,truthyClaims:function(t){var r={};return Object.keys(t).forEach(function(e){r[e]=c(t[e])}),r},truthyPropertyClaims:c,simplifyQualifiers:function(e,t){return k(e,j(t))},simplifyPropertyQualifiers:function(e,t){return l(e,j(t))},simplifyQualifier:p}},{"../utils/utils":22,"./parse_claim":2}],5:[function(e,t,r){"use strict";var i=e("./simplify_claims").simplifyClaims,n=e("./simplify_text_attributes"),s=e("./simplify_sitelinks"),o=function(e,t){var r={id:e.id,type:e.type,modified:e.modified};return a(e,r,"labels"),a(e,r,"descriptions"),a(e,r,"aliases"),null!=e.claims&&(r.claims=i(e.claims,t)),null!=e.sitelinks&&(r.sitelinks=s(e.sitelinks,t)),r},a=function(e,t,r){null!=e[r]&&(t[r]=n[r](e[r]))};t.exports={simplifyEntity:o,simplifyEntities:function(i){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},s=n.entityPrefix;return Object.keys(i).reduce(function(e,t){var r=i[t];return s&&(t=s+":"+t),e[t]=o(r,n),e},{})}}},{"./simplify_claims":4,"./simplify_sitelinks":6,"./simplify_text_attributes":8}],6:[function(e,t,r){"use strict";var s=e("./sitelinks_helpers").getSitelinkUrl;t.exports=function(e){var t=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).addUrl;return Object.keys(e).reduce(i(e,t),{})};var i=function(i,n){return function(e,t){var r=i[t].title;return e[t]=n?{title:r,url:s(t,r)}:r,e}}},{"./sitelinks_helpers":9}],7:[function(e,t,r){"use strict";t.exports=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};"string"==typeof e&&(e=JSON.parse(e));var r=e.head.vars,i=e.results.bindings;if(1===r.length&&!0===t.minimize){var n=r[0];return i.map(function(e){return h(e[n])}).filter(function(e){return null!=e})}var s=c(r),o=s.richVars,a=s.standaloneVars;return i.map(y(o,a))};var h=function(e){if(e){var t=e.datatype;return t=t&&t.replace("http://www.w3.org/2001/XMLSchema#",""),(i[e.type]||s(t))(e)}},i={uri:function(e){return u(e.value)},bnode:function(){return null}},n=function(e){return parseFloat(e.value)},s=function(e){return e=e&&e.replace("http://www.w3.org/2001/XMLSchema#",""),o[e]||a},o={decimal:n,integer:n,float:n,double:n,boolean:function(e){return"true"===e.value}},a=function(e){return e.value},u=function(e){return e.startsWith("http://www.wikidata.org/entity/statement/")?l(e):e.replace("http://www.wikidata.org/entity/","").replace("http://www.wikidata.org/prop/direct/","")},l=function(e){var t=(e=e.replace("http://www.wikidata.org/entity/statement/","")).split("-");return t[0]+"$"+t.slice(1).join("-")},c=function(e){return e.reduce(f(e),{richVars:[],standaloneVars:[]})},f=function(i){return function(e,t){if(i.some(m(t)))return e.richVars.push(t),e;if(!p.test(t))return e.standaloneVars.push(t),e;var r=t.replace(p,"$1").replace(/Alt$/,"");return i.includes(r)||e.standaloneVars.push(t),e}},p=/^(\w+)(Label|Description|AltLabel)$/,m=function(t){return function(e){return t+"Label"===e||(t+"Description"===e||t+"AltLabel"===e)}},y=function(d,v){return function(e){var t={},r=!0,i=!1,n=void 0;try{for(var s,o=d[Symbol.iterator]();!(r=(s=o.next()).done);r=!0){var a=s.value,u=h(e[a]);null!=u&&(t[a]={value:u},g(e,a,"label",t[a]),g(e,a,"description",t[a]),g(e,a,"aliases",t[a]))}}catch(e){i=!0,n=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw n}}var l=!0,c=!1,f=void 0;try{for(var p,m=v[Symbol.iterator]();!(l=(p=m.next()).done);l=!0){var y=p.value;t[y]=h(e[y])}}catch(e){c=!0,f=e}finally{try{!l&&m.return&&m.return()}finally{if(c)throw f}}return t}},g=function(e,t,r,i){var n=e[t+d[r]];null!=n&&(i[r]=n.value)},d={label:"Label",description:"Description",aliases:"AltLabel"}},{}],8:[function(e,t,r){"use strict";var i=function(t){return function(e){return Object.keys(e).reduce(n(e,t),{})}},n=function(i,n){return function(e,t){var r=i[t];return e[t]=n?r.map(s):r.value,e}},s=function(e){return e.value},o=i(!1);t.exports={labels:o,descriptions:o,aliases:i(!0)}},{}],9:[function(e,t,r){"use strict";var a=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],i=!0,n=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(i=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);i=!0);}catch(e){n=!0,s=e}finally{try{!i&&a.return&&a.return()}finally{if(n)throw s}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=e("../utils/utils"),s=i.fixedEncodeURIComponent,o=i.replaceSpaceByUnderscores,u=i.isPlainObject,n=e("./helpers").isPropertyId,l="https://www.wikidata.org/wiki/",c=e("./sitelinks_languages"),f=function(t){return function(e){return"https://"+t+".wikimedia.org/wiki/"+e}},p={commons:f("commons"),mediawiki:function(e){return"https://www.mediawiki.org/wiki/"+e},meta:f("meta"),species:f("species"),wikidata:function(e){return n(e)?l+"Property:"+e:""+l+e}},m=function(e){var t=y[e];if(t)return{lang:"en",project:t};var r=e.split("wik"),i=a(r,3),n=i[0],s=i[1];if(null!=i[2])throw new Error("invalid sitelink: "+e);if(-1===c.indexOf(n))throw new Error("sitelink lang not found: "+n);var o=d[s];if(!o)throw new Error("sitelink project not found: "+o);return{lang:n,project:o}},y={commonswiki:"commons",mediawikiwiki:"mediawiki",metawiki:"meta",specieswiki:"specieswiki",wikidatawiki:"wikidata"},d={i:"wikipedia",isource:"wikisource",iquote:"wikiquote",tionary:"wiktionary",ibooks:"wikibooks",iversity:"wikiversity",ivoyage:"wikivoyage",inews:"wikinews"};t.exports={getSitelinkUrl:function(e,t){if(u(e)&&(t=e.title,e=e.site),!e)throw new Error("missing a site");if(!t)throw new Error("missing a title");var r=e.replace(/wiki$/,""),i=p[r]||p[e];if(i)return i(t);var n=m(e);return"https://"+n.lang+"."+n.project+".org/wiki/"+(t=s(o(t)))},getSitelinkData:m,isSitelinkKey:function(e){try{return m(e),!0}catch(e){return!1}}}},{"../utils/utils":22,"./helpers":1,"./sitelinks_languages":10}],10:[function(e,t,r){"use strict";t.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"]},{}],11:[function(e,t,r){"use strict";var o=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],i=!0,n=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(i=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);i=!0);}catch(e){n=!0,s=e}finally{try{!i&&a.return&&a.return()}finally{if(n)throw s}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.exports=function(e){"object"===(void 0===e?"undefined":a(e))&&(e=e.time);var t=e[0],r=e.slice(1).split("T"),i=o(r,2),n=i[0],s=i[1];return n=n.replace(/-00/g,"-01"),u(t,n+"T"+s)};var u=function(e,t){return"-"===e?n(t):i(t)},i=function(e){return new Date(e)},n=function(e){var t,r=e.split("-")[0];return t=4===r.length?"-00"+e:5===r.length?"-0"+e:"-"+e,new Date(t)}},{}],12:[function(e,t,r){"use strict";var i=t.exports={};i.searchEntities=e("./queries/search_entities"),i.getEntities=e("./queries/get_entities"),i.getManyEntities=e("./queries/get_many_entities"),i.sparqlQuery=e("./queries/sparql_query"),i.getReverseClaims=e("./queries/get_reverse_claims"),i.getRevisions=e("./queries/get_revisions"),i.getEntitiesFromSitelinks=e("./queries/get_entities_from_sitelinks"),i.getWikidataIdsFromSitelinks=i.getEntitiesFromSitelinks,i.parse=e("./helpers/parse_responses");var n=e("./helpers/simplify_claims"),s=e("./helpers/simplify_sparql_results");i.simplify=e("../lib/helpers/simplify_text_attributes");var o=e("../lib/helpers/simplify_entity"),a=o.simplifyEntity,u=o.simplifyEntities;i.simplify.entity=a,i.simplify.entities=u,i.simplify.claim=n.simplifyClaim,i.simplify.propertyClaims=n.simplifyPropertyClaims,i.simplify.claims=n.simplifyClaims,i.simplify.qualifier=n.simplifyQualifier,i.simplify.propertyQualifiers=n.simplifyPropertyQualifiers,i.simplify.qualifiers=n.simplifyQualifiers,i.simplify.sitelinks=e("../lib/helpers/simplify_sitelinks"),i.simplify.sparqlResults=s,i.simplifySparqlResults=e("./helpers/simplify_sparql_results"),Object.assign(i,n),i.getWikidataIdsFromWikipediaTitles=i.getWikidataIdsFromSitelinks;var l=e("../lib/helpers/helpers"),c=e("../lib/helpers/sitelinks_helpers");Object.assign(i,l,c)},{"../lib/helpers/helpers":1,"../lib/helpers/simplify_entity":5,"../lib/helpers/simplify_sitelinks":6,"../lib/helpers/simplify_text_attributes":8,"../lib/helpers/sitelinks_helpers":9,"./helpers/parse_responses":3,"./helpers/simplify_claims":4,"./helpers/simplify_sparql_results":7,"./queries/get_entities":13,"./queries/get_entities_from_sitelinks":14,"./queries/get_many_entities":15,"./queries/get_reverse_claims":16,"./queries/get_revisions":17,"./queries/search_entities":18,"./queries/sparql_query":19}],13:[function(e,t,r){"use strict";var o=e("../utils/build_url"),i=e("../utils/utils"),a=i.isPlainObject,u=i.forceArray,l=i.shortLang;t.exports=function(e,t,r,i){if(a(e)){var n=e;e=n.ids,t=n.languages,r=n.props,i=n.format}if(i=i||"json",!(e&&0<e.length))throw new Error("no id provided");50<(e=u(e)).length&&console.warn("getEntities accepts 50 ids max to match Wikidata API limitations:\n this request won't get all the desired entities.\n You can use getManyEntities instead to generate several request urls\n to work around this limitation");var s={action:"wbgetentities",ids:e.join("|"),format:i};return t&&(t=u(t).map(l),s.languages=t.join("|")),r&&0<r.length&&(s.props=u(r).join("|")),o(s)}},{"../utils/build_url":20,"../utils/utils":22}],14:[function(e,t,r){"use strict";var a=e("../utils/build_url"),i=e("../utils/utils"),u=i.isPlainObject,l=i.forceArray,c=i.shortLang;t.exports=function(e,t,r,i,n){if(u(e)){var s=e;e=s.titles,t=s.sites,r=s.languages,i=s.props,n=s.format}if(n=n||"json",!(e&&0<e.length))throw new Error("no title provided");t&&0<t.length||(t=["enwiki"]),e=l(e),t=l(t).map(f),i=l(i);var o={action:"wbgetentities",titles:e.join("|"),sites:t.join("|"),format:n};return 1===t.length&&1===e.length&&(o.normalize=!0),r&&(r=l(r).map(c),o.languages=r.join("|")),i&&0<i.length&&(o.props=i.join("|")),a(o)};var f=function(e){return 2===e.length?e+"wiki":e}},{"../utils/build_url":20,"../utils/utils":22}],15:[function(e,t,r){"use strict";var s=e("./get_entities"),o=e("../utils/utils").isPlainObject;t.exports=function(e,t,r,i){if(o(e)){var n=e;e=n.ids,t=n.languages,r=n.props,i=n.format}if(!(e instanceof Array))throw new Error("getManyEntities expects an array of ids");return a(e).map(function(e){return s(e,t,r,i)})};var a=function(e){for(var t=[];0<e.length;){var r=e.slice(0,50);e=e.slice(50),t.push(r)}return t}},{"../utils/utils":22,"./get_entities":13}],16:[function(e,t,r){"use strict";var i=e("../helpers/helpers"),a=e("./sparql_query");function u(e){return i.isItemId(e)?e="wd:"+e:"string"==typeof e&&(e="'"+e+"'"),e}function l(e,t,r,i){return"?subject "+e+" "+t+" .\n "+r}function c(e,t,r,i){return"?subject "+e+" ?value .\n FILTER (lcase(?value) = "+t.toLowerCase()+")\n "+r}t.exports=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=r.limit,n=r.caseInsensitive,s=r.keepProperties?"":"FILTER NOT EXISTS { ?subject rdf:type wikibase:Property . } ",o="SELECT DISTINCT ?subject WHERE { "+function(e,t,r,i){if(!(e instanceof Array))return t(r,u(e),i);return"{ "+e.map(u).map(function(e){return t(r,e,i)}).join("} UNION {")+" }"}(t,n?c:l,e=e instanceof Array?e.map(f).join("|"):f(e),s)+" }";return i&&(o+=" LIMIT "+i),a(o)};var f=function(e){return"wdt:"+e}},{"../helpers/helpers":1,"./sparql_query":19}],17:[function(e,t,r){"use strict";var n=e("../utils/build_url"),s=e("../utils/utils").forceArray;t.exports=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=1===(e=s(e)).length,i={action:"query",prop:"revisions"};return i.titles=e.join("|"),i.format=t.format||"json",r&&(i.rvlimit=t.limit||"max"),r&&t.start&&(i.rvstart=o(t.start)),r&&t.end&&(i.rvend=o(t.end)),n(i)};var o=function(e){return"number"==typeof e&&e<i?e:Math.trunc(new Date(e).getTime()/1e3)},i=new Date("2000-01-01").getTime()},{"../utils/build_url":20,"../utils/utils":22}],18:[function(e,t,r){"use strict";var a=e("../utils/build_url"),u=e("../utils/utils").isPlainObject,l=["item","property","lexeme","form","sense"];t.exports=function(e,t,r,i,n){var s;if(u(e)){var o=e;e=o.search,t=o.language,r=o.limit,i=o.format,n=o.uselang,s=o.type}if(!(e&&0<e.length))throw new Error("search can't be empty");if(t=t||"en",n=n||t,r=r||"20",i=i||"json",s=s||"item",!l.includes(s))throw new Error("invalid type: "+s);return a({action:"wbsearchentities",search:e,language:t,limit:r,format:i,uselang:n,type:s})}},{"../utils/build_url":20,"../utils/utils":22}],19:[function(e,t,r){"use strict";var i=e("../utils/utils").fixedEncodeURIComponent;t.exports=function(e){return"https://query.wikidata.org/sparql?format=json&query="+i(e)}},{"../utils/utils":22}],20:[function(e,t,r){"use strict";var i="undefined"!=typeof location&&"undefined"!=typeof document,n=e(i?"./querystring_lite":"querystring");t.exports=function(e){return i&&(e.origin="*"),"https://www.wikidata.org/w/api.php?"+n.stringify(e)}},{"./querystring_lite":21,querystring:25}],21:[function(e,t,r){"use strict";t.exports={stringify:function(e){var t="";for(var r in e){var i=e[r];i&&(t+="&"+r+"="+i)}return t=t.slice(1),encodeURI?encodeURI(t):t}}},{}],22:[function(e,t,r){"use strict";var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.exports={shortLang:function(e){return e.toLowerCase().split(/[^a-z]/)[0]},forceArray:function(e){return"string"==typeof e&&(e=[e]),e||[]},isPlainObject:function(e){return!(!e||"object"!==(void 0===e?"undefined":i(e))||e instanceof Array)},fixedEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/[!'()*]/g,n)},replaceSpaceByUnderscores:function(e){return e.replace(/\s/g,"_")},uniq:function(e){return Array.from(new Set(e))}};var n=function(e){return"%"+e.charCodeAt(0).toString(16)}},{}],23:[function(e,t,r){"use strict";t.exports=function(e,t,r,i){t=t||"&",r=r||"=";var n={};if("string"!=typeof e||0===e.length)return n;var s=/\+/g;e=e.split(t);var o=1e3;i&&"number"==typeof i.maxKeys&&(o=i.maxKeys);var a,u,l=e.length;0<o&&o<l&&(l=o);for(var c=0;c<l;++c){var f,p,m,y,d=e[c].replace(s,"%20"),v=d.indexOf(r);0<=v?(f=d.substr(0,v),p=d.substr(v+1)):(f=d,p=""),m=decodeURIComponent(f),y=decodeURIComponent(p),a=n,u=m,Object.prototype.hasOwnProperty.call(a,u)?h(n[m])?n[m].push(y):n[m]=[n[m],y]:n[m]=y}return n};var h=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],24:[function(e,t,r){"use strict";var s=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(r,i,n,e){return i=i||"&",n=n||"=",null===r&&(r=void 0),"object"==typeof r?a(u(r),function(e){var t=encodeURIComponent(s(e))+n;return o(r[e])?a(r[e],function(e){return t+encodeURIComponent(s(e))}).join(i):t+encodeURIComponent(s(r[e]))}).join(i):e?encodeURIComponent(s(e))+n+encodeURIComponent(s(r)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function a(e,t){if(e.map)return e.map(t);for(var r=[],i=0;i<e.length;i++)r.push(t(e[i],i));return r}var u=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t}},{}],25:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode"),r.encode=r.stringify=e("./encode")},{"./decode":23,"./encode":24}]},{},[12])(12)});

@@ -7,2 +7,3 @@ # Get JSON from a SPARQL query

// request the generated URL with your favorite HTTP request library
request({ method: 'GET', url })
```

@@ -32,1 +33,8 @@ You can then simplify the response using [`wdk.simplifySparqlResults`](simplify_sparql_results.md).

* [Get entities reverse claims](get_entities_reverse_claims.md)
### POST request
If the generated request URL gets too long, you can make a POST request instead
```js
const [ url, body ] = wdk.sparqlQuery(sparql).split('?')
request({ method: 'POST', url, body })
```

@@ -8,10 +8,10 @@ module.exports = function (wikidataTime) {

const sign = wikidataTime[0]
const rest = wikidataTime.slice(1)
const date = fullDateData(sign, rest)
var [ yearMonthDay, withinDay ] = wikidataTime.slice(1).split('T')
if (date.toString() === 'Invalid Date') {
return parseInvalideDate(sign, rest)
} else {
return date
}
// Wikidata generates invalid ISO dates to indicate precision
// ex: +1990-00-00T00:00:00Z to indicate 1990 with year precision
yearMonthDay = yearMonthDay.replace(/-00/g, '-01')
const rest = `${yearMonthDay}T${withinDay}`
return fullDateData(sign, rest)
}

@@ -39,9 +39,1 @@

}
const parseInvalideDate = function (sign, rest) {
// This is probably a date of unsuffisient precision
// such as 1953-00-00T00:00:00Z, thus invalid
// It should at least have a year, so let's fallback to ${year}-01-01
const year = rest.split('T')[0].split('-')[0]
return fullDateData(sign, year)
}
{
"name": "wikidata-sdk",
"version": "6.0.0",
"version": "6.0.1",
"description": "A javascript tool-suite to query Wikidata and simplify its results",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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