wikibase-sdk
Advanced tools
Comparing version 7.12.0 to 7.13.0
const validate = require('../helpers/validate') | ||
const { isPlainObject } = require('../utils/utils') | ||
module.exports = instance => (id, revision) => { | ||
module.exports = (instance, wgScriptPath) => (id, revision) => { | ||
if (isPlainObject(id)) { | ||
@@ -11,3 +11,3 @@ revision = id.revision | ||
validate.revisionId(revision) | ||
return `${instance}/w/index.php?title=Special:EntityData/${id}.json&revision=${revision}` | ||
return `${instance}/${wgScriptPath}/index.php?title=Special:EntityData/${id}.json&revision=${revision}` | ||
} |
@@ -17,3 +17,6 @@ const { isPlainObject } = require('./utils/utils') | ||
const { instance, sparqlEndpoint } = config | ||
let { wgScriptPath = 'w' } = config | ||
wgScriptPath = wgScriptPath.replace(/^\//, '') | ||
if (!(instance || sparqlEndpoint)) { | ||
@@ -29,5 +32,5 @@ throw new Error(`one of instance or sparqlEndpoint should be set at initialization.\n${tip}`) | ||
.replace(/\/$/, '') | ||
.replace('/w/api.php', '') | ||
.replace(`/${wgScriptPath}/api.php`, '') | ||
instanceApiEndpoint = `${instanceRoot}/w/api.php` | ||
instanceApiEndpoint = `${instanceRoot}/${wgScriptPath}/api.php` | ||
@@ -42,3 +45,3 @@ const buildUrl = require('./utils/build_url')(instanceApiEndpoint) | ||
getRevisions: require('./queries/get_revisions')(buildUrl), | ||
getEntityRevision: require('./queries/get_entity_revision')(instance), | ||
getEntityRevision: require('./queries/get_entity_revision')(instance, wgScriptPath), | ||
getEntitiesFromSitelinks: require('./queries/get_entities_from_sitelinks')(buildUrl) | ||
@@ -45,0 +48,0 @@ } |
{ | ||
"name": "wikibase-sdk", | ||
"version": "7.12.0", | ||
"version": "7.13.0", | ||
"description": "utils functions to query a Wikibase instance and simplify its results", | ||
@@ -5,0 +5,0 @@ "main": "lib/wikibase-sdk.js", |
@@ -52,3 +52,3 @@ # wikibase-sdk | ||
For older version, you can use ES5 [bundles](docs/install.md#bundles). | ||
For older version, you can use ES5 [bundles](#download-pre-bundled-files). | ||
@@ -66,3 +66,3 @@ ## Install | ||
instance: 'https://my-wikibase-instan.se', | ||
sparqlEndpoint: 'https://query.my-wikibase-instan.se/sparql' | ||
sparqlEndpoint: 'https://query.my-wikibase-instan.se/sparql' // Required to use `sparqlQuery` and `getReverseClaims` functions, optional otherwise | ||
}) | ||
@@ -78,3 +78,3 @@ ``` | ||
``` | ||
For convenience, and for the sake of retro-compatibility, that same `wdk` object can be obtain with: | ||
For convenience, and for the sake of retro-compatibility, that same `wdk` object can be obtain directly from the `wikidata-sdk` package: | ||
```js | ||
@@ -89,2 +89,10 @@ // After having run `npm install wikidata-sdk` | ||
By default `wikibase-sdk` assumes that your Wikibase instance has [`$wgScriptPath`](https://www.mediawiki.org/wiki/Manual:$wgScriptPath) set to `/w`, but if that's not the case, you can set it by passing a `wgScriptPath` parameter: | ||
```js | ||
const wbk = require('wikibase-sdk')({ | ||
instance: 'https://my-wikibase-instan.se', | ||
wgScriptPath: '/some_custom_script_path' | ||
}) | ||
``` | ||
### download pre-bundled files | ||
@@ -91,0 +99,0 @@ If you just want to import the lib from an HTML file and don't have a setup that can import with CommonJS or ES6 Modules, you can simply download those pre-bundled files: |
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
1209
170
60789
31