npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quickstatements-to-wikibase-edit

v1.2.1

Published

Convert QuickStatements commands into wikibase-edit format

Downloads

14

Readme

quickstatements-to-wikibase-edit

Tools to convert QuickStatements commands into wikibase-edit format.

:warning: Status: experimental

Supported features

  • add labels, descriptions, aliases, sitelinks
  • add statements with qualifiers and references
  • if a statement with the same value already exist, do not re-add it, but add the new qualifiers and references
  • create items
  • merge items

Missing features

  • remove statement

CLI

Install

# Should make the commands `wb` and `quickstatements-to-wikibase-edit` available from anywhere
npm install --global wikibase-cli quickstatements-to-wikibase-edit
# Make sure your credentials are setup for the target instance (example below with wikidata.org)
wb config credentials https://www.wikidata.org test

Usage

# Should generate edits, creations, and merges NDJSON files, depending on the commands content
quickstatements-to-wikibase-edit ./quickstatement_commands.txt

cat 0ba886b6-edits.ndjson | wb edit-entity --batch --summary 'fixing stuff'
cat 0ba886b6-creations.ndjson | wb create-entity --batch --summary 'fixing stuff'
cat 0ba886b6-merges.ndjson | wb merge-entity --batch --summary 'fixing stuff'

By default, edits will be run with their reconciliation mode set to merge, to mimick QuickStatements behavior. Other reconciliation modes could be used (see wikibase-edit documentation for behavior explainations)

quickstatements-to-wikibase-edit ./quickstatement_commands.txt --reconciliation merge # Default
quickstatements-to-wikibase-edit ./quickstatement_commands.txt --reconciliation skip-on-any-value
quickstatements-to-wikibase-edit ./quickstatement_commands.txt --reconciliation skip-on-value-match
quickstatements-to-wikibase-edit ./quickstatement_commands.txt --reconciliation none

JS

Install

npm install wikibase-edit quickstatements-to-wikibase-edit

Usage

const wbEdit = require('wikibase-edit')({ instance, credentials })
const quickstatementsToWikibaseEdit = require('quickstatements-to-wikibase-edit')

const commands = `
Q4115189	P31	Q1
Q4115189	P373	"Antoni Ignacy Mietelski"
Q1214098	P1476	pl:"Krzyżacy"
CREATE
LAST	Sfrwiki	"Le croissant magnifique!"
LAST	Lfr	"Le croissant magnifique!"
Q340122	Aen	"Cyprjan Kamil Norwid"
MERGE	Q1	Q2
Q340122	Aen	"Cyprian Kamil Norwid|Cypryan Kamil Norvid"
`

const options = {
  // Optionnally set the reconciliation object, see wikibase-edit documentation
  // https://github.com/maxlath/wikibase-edit/blob/main/docs/how_to.md#reconciliation
  reconciliation: {
    mode: 'none' // Default value: merge (mimicking QuickStatements behavior)
  }
}

const { edits, creations, merges } = quickstatementsToWikibaseEdit(commands, options)

for (const edit of edits) {
  await wbEdit.entity.edit(edit)
}

for (const creation of creations) {
  await wbEdit.entity.create(creation)
}

for (const merge of merges) {
  await wbEdit.entity.merge(merge)
}