wikibase-sdk
Advanced tools
Comparing version 8.1.1 to 9.0.0
{ | ||
"name": "wikibase-sdk", | ||
"version": "8.1.1", | ||
"version": "9.0.0", | ||
"type": "module", | ||
"description": "utils functions to query a Wikibase instance and simplify its results", | ||
"main": "lib/wikibase-sdk.js", | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js", | ||
"./wikidata.org": "./dist/wellknown/wikidata.org.js" | ||
}, | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"lib" | ||
"src", | ||
"dist" | ||
], | ||
"directories": { | ||
"lib": "lib", | ||
"lib": "dist", | ||
"doc": "docs", | ||
@@ -18,7 +25,7 @@ "test": "test" | ||
"check-supported-datatypes": "./scripts/check_supported_datatypes", | ||
"lint": "eslint -c .eslintrc lib scripts test", | ||
"lint-fix": "eslint -c .eslintrc lib scripts test --fix", | ||
"minify": "./scripts/minify", | ||
"test": "mocha", | ||
"prepublishOnly": "npm run lint && npm test", | ||
"git-pre-commit": "./scripts/githooks/pre-commit", | ||
"lint": "eslint -c .eslintrc.cjs src scripts tests", | ||
"lint-fix": "eslint -c .eslintrc.cjs src scripts tests --fix", | ||
"test": "./scripts/run_tests", | ||
"prepublishOnly": "npm run lint && npm test && npm run update-dist", | ||
"postpublish": "./scripts/postpublish", | ||
@@ -28,3 +35,3 @@ "update-dist": "./scripts/update_dist", | ||
"update-toc": "./scripts/update_toc", | ||
"update-wikidata-sdk": "./scripts/update_wikidata_sdk" | ||
"watch": "tsc --watch" | ||
}, | ||
@@ -51,23 +58,24 @@ "repository": { | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babelify": "^8.0.0", | ||
"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", | ||
"lodash": "^4.17.15", | ||
"mocha": "^9.1.3", | ||
"should": "^13.2.1", | ||
"tiny-chalk": "^2.0.0", | ||
"uglify-js": "^3.3.25" | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.11.18", | ||
"@types/should": "^13.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.49.0", | ||
"@typescript-eslint/parser": "^5.49.0", | ||
"@vercel/git-hooks": "^1.0.0", | ||
"eslint": "^8.32.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-n": "^15.6.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"lodash-es": "^4.17.21", | ||
"mocha": "^10.2.0", | ||
"should": "^13.2.3", | ||
"tiny-chalk": "^3.0.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
}, | ||
"engines": { | ||
"node": ">= 10.0.0" | ||
"node": ">= 12.0.0" | ||
} | ||
} |
@@ -5,3 +5,3 @@ # wikibase-sdk | ||
This package was primarily developed as `wikidata-sdk` but has now being generalized to support any Wikibase instance: [wikidata.org](https://www.wikidata.org) among others. | ||
This package was primarily developed as `wikidata-sdk` but has now being generalized to support any Wikibase instance, [wikidata.org](https://www.wikidata.org) among others, and was thus renamed `wikibase-sdk`. | ||
@@ -18,3 +18,2 @@ This project received a [Wikimedia Project Grant](https://meta.wikimedia.org/wiki/Grants:Project/WikidataJS). | ||
[![NPM](https://nodei.co/npm/wikibase-sdk.png?stars&downloads&downloadRank)](https://npmjs.com/package/wikibase-sdk/) | ||
[![NPM](https://nodei.co/npm/wikidata-sdk.png?stars&downloads&downloadRank)](https://npmjs.com/package/wikidata-sdk/) | ||
@@ -25,4 +24,3 @@ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
* [wikibase-sdk download stats](https://npm-stat.com/charts.html?package=wikibase-sdk) | ||
* [wikidata-sdk download stats](https://npm-stat.com/charts.html?package=wikidata-sdk) | ||
[download stats](https://npm-stat.com/charts.html?package=wikibase-sdk) | ||
@@ -37,3 +35,4 @@ ## Summary | ||
- [Install](#install) | ||
- [as a module](#as-a-module) | ||
- [as an ES module](#as-an-es-module) | ||
- [as an CommonJS module](#as-an-commonjs-module) | ||
- [download pre-bundled files](#download-pre-bundled-files) | ||
@@ -55,15 +54,16 @@ - [Features](#features) | ||
## Dependencies | ||
This module uses [JavaScript ES6](https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015), which means NodeJS `>= v6.4.0` or not too outdated web browsers. | ||
* A somewhat modern JS runtime: NodeJS `>= v12.0.0` or not too outdated web browsers (see [`Object.fromEntries` browser compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries)) | ||
For older version, you can use ES5 [bundles](#download-pre-bundled-files). | ||
For older JS runtimes, you can use [ES5 bundles from `wikibase-sdk <= v8`](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#download-pre-bundled-files). | ||
## Install | ||
### as a module | ||
Install via npm to be able to use the module with `require` (CommonJS) or `import` (ES6 Modules) | ||
### as an ES module | ||
Install via npm to be able to use the `import` the module. | ||
```sh | ||
npm install wikibase-sdk | ||
``` | ||
Then in your javascript: | ||
```js | ||
const WBK = require('wikibase-sdk') | ||
import { WBK } from 'wikibase-sdk' | ||
const wbk = WBK({ | ||
@@ -76,3 +76,4 @@ instance: 'https://my-wikibase-instan.se', | ||
```js | ||
const WBK = require('wikibase-sdk') | ||
import { WBK } from 'wikibase-sdk' | ||
const wdk = WBK({ | ||
@@ -83,15 +84,11 @@ instance: 'https://www.wikidata.org', | ||
``` | ||
For convenience, and for the sake of retro-compatibility, that same `wdk` object can be obtain directly from the `wikidata-sdk` package: | ||
For convenience, and for the sake of retro-compatibility, that same `wdk` object can be obtain directly from the `wikibase-sdk/wikidata.org` package: | ||
```js | ||
// After having run `npm install wikidata-sdk` | ||
const wdk = require('wikidata-sdk') | ||
import wdk from 'wikibase-sdk/wikidata.org' | ||
``` | ||
and instance-independant helper functions are directly available from the module root: | ||
```js | ||
const { simplify, parse, isEntityId, isPropertyId, ... } = require('wikibase-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')({ | ||
import { WBK } from 'wikibase-sdk' | ||
const wbk = WBK({ | ||
instance: 'https://my-wikibase-instan.se', | ||
@@ -102,19 +99,21 @@ wgScriptPath: '/some_custom_script_path' | ||
### download pre-bundled files | ||
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: | ||
### as an CommonJS module | ||
Importing with CommonJS `require` is not supported anymore in version `>= v9.0.0`, but can still be done by installing an older version: | ||
```sh | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/dist/dist/wikibase-sdk.js | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/dist/dist/wikidata-sdk.js | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/dist/dist/wikibase-sdk.min.js | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/dist/dist/wikidata-sdk.min.js | ||
npm install wikibase-sdk@v8 | ||
``` | ||
then you can import it in your html: | ||
```html | ||
<script src="/path/to/wikibase-sdk.js"></script> | ||
<script>console.log('can access WBK', WBK)</script> | ||
<script src="/path/to/wikidata-sdk.js"></script> | ||
<script>console.log('can access wdk, the wikidata.org bound product of WBK', wdk)</script> | ||
See the [corresponding version documentation](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#as-a-module) | ||
### download pre-bundled files | ||
Pre-bundled files is not supported anymore in version `>= v9.0.0`, but can still be done by pre-bundled files from older versions: | ||
```sh | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikibase-sdk.js | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikidata-sdk.js | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikibase-sdk.min.js | ||
wget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikidata-sdk.min.js | ||
``` | ||
See the [corresponding version documentation](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#download-pre-bundled-files) | ||
## Features | ||
@@ -154,6 +153,6 @@ ### Wikibase API | ||
* `wikibase-sdk` should stay "small" and dependency-free, so that a web application can include it in its bundle without paying a too high cost for it. A consequence is that the lib generates URLs where other libs would integrate doing the request and parsing it's response. But that actually feels quite right to do this way: simply generating the URLs let's users free to handle requests as they like (with callbacks, promises, async/await, whatever!) | ||
* `wikibase-sdk` should stay "small" and dependency-free, so that a web application can include it in its bundle without paying a too high cost for it. A consequence is that the lib generates URLs where other libs would integrate doing the request and parsing it's response. But that actually feels quite right to do this way: simply generating the URLs let's users free to handle requests as they like (with callbacks, promises, async/await, custom request agent, whatever!) | ||
* Therefore, it should focus on providing basic, general helper functions most application working with a Wikibase instance would need. | ||
* Write operations should go into [wikibase-edit](https://github.com/maxlath/wikibase-edit) as it involves working with Wikibase credentials/tokens. | ||
* General command-line interface tools should go to [wikibase-cli](https://github.com/maxlath/wikibase-cli), very specific ones — [`wikidata-filter`, `import-wikidata-dump-to-couchdb`, and alikes](#see-also) — should get their own modules. | ||
* General command-line interface tools should go to [wikibase-cli](https://github.com/maxlath/wikibase-cli), very specific ones — [`wikibase-dump-filter` and alikes](#see-also) — should get their own modules. | ||
@@ -164,5 +163,3 @@ ## See Also | ||
* [wikibase-dump-filter](https://npmjs.com/package/wikibase-dump-filter): Filter and format a newline-delimited JSON stream of Wikibase entities | ||
* [wikidata-subset-search-engine](https://github.com/inventaire/entities-search-engine/tree/wikidata-subset-search-engine): Tools to setup an ElasticSearch instance fed with subsets of Wikidata | ||
* [wikidata-taxonomy](https://github.com/nichtich/wikidata-taxonomy): Command-line tool to extract taxonomies from Wikidata | ||
* [import-wikidata-dump-to-couchdb](https://github.com/maxlath/import-wikidata-dump-to-couchdb): Import a subset or a full Wikidata dump into a CouchDB database | ||
* [Other Wikidata external tools](https://www.wikidata.org/wiki/Wikidata:Tools/External_tools) | ||
@@ -169,0 +166,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
214038
113
6159
Yes
18
165
1