wikibase-cli 16.3.3 → 17.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/wb-add-alias.js +12 -0
- package/bin/wb-add-badge.js +12 -0
- package/bin/wb-add-claim.js +14 -0
- package/bin/wb-add-qualifier.js +14 -0
- package/bin/wb-add-reference.js +14 -0
- package/bin/wb-aliases.js +4 -0
- package/bin/wb-badges.js +18 -0
- package/bin/{wb-claims → wb-claims.js} +19 -14
- package/bin/{wb-config → wb-config.js} +8 -6
- package/bin/{wb-convert → wb-convert.js} +11 -12
- package/bin/wb-create-entity.js +10 -0
- package/bin/{wb-data → wb-data.js} +15 -11
- package/bin/wb-delete-entity.js +10 -0
- package/bin/wb-description.js +4 -0
- package/bin/wb-edit-entity.js +10 -0
- package/bin/{wb-generate-template → wb-generate-template.js} +24 -13
- package/bin/{wb-hub → wb-hub.js} +9 -7
- package/bin/{wb-id → wb-id.js} +14 -11
- package/bin/wb-label.js +4 -0
- package/bin/{wb-lang → wb-lang.js} +8 -8
- package/bin/wb-lemma.js +4 -0
- package/bin/{wb-merge-entity → wb-merge-entity.js} +6 -4
- package/bin/wb-move-claim.js +20 -0
- package/bin/wb-move-qualifier.js +21 -0
- package/bin/{wb-open → wb-open.js} +23 -22
- package/bin/{wb-props → wb-props.js} +8 -9
- package/bin/{wb-query → wb-query.js} +13 -9
- package/bin/wb-remove-alias.js +12 -0
- package/bin/wb-remove-badge.js +12 -0
- package/bin/wb-remove-claim.js +11 -0
- package/bin/wb-remove-description.js +16 -0
- package/bin/wb-remove-label.js +16 -0
- package/bin/wb-remove-qualifier.js +15 -0
- package/bin/wb-remove-reference.js +15 -0
- package/bin/wb-remove-sitelink.js +16 -0
- package/bin/{wb-revisions → wb-revisions.js} +15 -11
- package/bin/{wb-search → wb-search.js} +17 -15
- package/bin/wb-set-alias.js +12 -0
- package/bin/wb-set-description.js +12 -0
- package/bin/wb-set-label.js +12 -0
- package/bin/wb-set-sitelink.js +17 -0
- package/bin/{wb-sparql → wb-sparql.js} +16 -12
- package/bin/{wb-summary → wb-summary.js} +3 -3
- package/bin/{wb-update-claim → wb-update-claim.js} +9 -6
- package/bin/wb-update-qualifier.js +14 -0
- package/bin/wb.js +27 -0
- package/bin/{wd → wd.js} +6 -3
- package/index.js +7 -1
- package/lib/apply_env_and_config_default.js +7 -5
- package/lib/chalk.js +12 -0
- package/lib/command_with_template_custom_help.js +7 -7
- package/lib/common_command_args_parser.js +7 -10
- package/lib/common_errors.js +5 -7
- package/lib/common_options.js +23 -24
- package/lib/config/config.js +10 -5
- package/lib/config/credentials_config.js +7 -6
- package/lib/config/file_operations.js +9 -8
- package/lib/config/file_path.js +11 -8
- package/lib/config/parameters.js +11 -10
- package/lib/convert_ids.js +10 -8
- package/lib/copy.js +2 -2
- package/lib/drop_non_selected_subprops.js +3 -3
- package/lib/edit/assert_credentials.js +3 -3
- package/lib/edit/edit_command.js +19 -19
- package/lib/edit/init_credentials.js +11 -11
- package/lib/edit/parse_batch_line.js +2 -2
- package/lib/edit/parse_object_value.js +6 -5
- package/lib/edit/prompt.js +3 -4
- package/lib/edit/validate_instance_credentials.js +2 -2
- package/lib/entity_attribute_command.js +10 -10
- package/lib/entity_attribute_parser.js +9 -8
- package/lib/entity_data_parser.js +14 -11
- package/lib/errors.js +3 -3
- package/lib/execute_function.js +4 -4
- package/lib/exit_on_missing.js +11 -12
- package/lib/fetch_and_log_entity_revision.js +18 -15
- package/lib/fetch_and_log_guid_data.js +19 -11
- package/lib/fetch_and_log_ids_data.js +17 -16
- package/lib/fetch_and_log_property_claims_data.js +18 -10
- package/lib/fetch_lang_props.js +13 -12
- package/lib/filter_claims_properties.js +4 -4
- package/lib/format_properties_data.js +2 -2
- package/lib/format_statement_element_value.js +3 -3
- package/lib/fs.js +13 -26
- package/lib/generate_describe_sparql_query.js +3 -3
- package/lib/generate_sample_sparql_query.js +1 -1
- package/lib/generate_select_sparql_query.js +2 -2
- package/lib/get_cache_folder_path.js +11 -8
- package/lib/get_claims_texts.js +8 -7
- package/lib/get_entities.js +6 -5
- package/lib/get_entities_by_batches.js +12 -7
- package/lib/get_entities_labels.js +3 -5
- package/lib/get_entities_schemas.js +7 -7
- package/lib/get_folder_path.js +8 -6
- package/lib/get_lang_props.js +17 -16
- package/lib/get_pattern_filter.js +4 -3
- package/lib/get_properties_data.js +5 -5
- package/lib/get_redirected_sitelink_title.js +4 -4
- package/lib/get_sitelink_url.js +9 -8
- package/lib/get_stdin_input.js +1 -1
- package/lib/get_ttl_entities.js +8 -8
- package/lib/global_options_help.js +1 -1
- package/lib/hash_string.js +4 -2
- package/lib/json.js +5 -0
- package/lib/local_lang.js +2 -1
- package/lib/log_claims.js +12 -12
- package/lib/log_command_examples.js +11 -6
- package/lib/log_ndjson.js +1 -1
- package/lib/make_sparql_query.js +29 -25
- package/lib/matching_langs.js +4 -6
- package/lib/minimize_claims.js +3 -5
- package/lib/object_arg_parser.js +12 -17
- package/lib/open.js +7 -7
- package/lib/output.js +37 -35
- package/lib/output_templates.js +41 -31
- package/lib/parse_command_utils.js +14 -15
- package/lib/parse_entity_type.js +2 -2
- package/lib/parse_props.js +7 -4
- package/lib/parse_simplify_options.js +1 -1
- package/lib/path.js +3 -2
- package/lib/pluralize.js +2 -2
- package/lib/polymorphic_command_args_parser.js +11 -9
- package/lib/program.js +9 -9
- package/lib/properties.js +22 -23
- package/lib/queries/all_instances.js +2 -2
- package/lib/queries/all_properties.js +1 -1
- package/lib/read_ids_from_stdin.js +3 -3
- package/lib/request.js +22 -23
- package/lib/request_headers.js +8 -2
- package/lib/reset_properties.js +4 -4
- package/lib/sparql_query_command.js +10 -8
- package/lib/stringify_as_js_function.js +3 -3
- package/lib/summary_parser.js +43 -13
- package/lib/tabularize.js +7 -7
- package/lib/tolerant_id_parser.js +21 -18
- package/lib/types.js +4 -6
- package/lib/utils.js +11 -13
- package/lib/validate.js +2 -0
- package/lib/validate_function_args.js +2 -2
- package/lib/value_parsers.js +2 -2
- package/lib/wbk.js +4 -3
- package/lib/wellknown_queries.js +6 -5
- package/metadata/add-alias.js +6 -4
- package/metadata/add-badge.js +5 -3
- package/metadata/add-claim.js +5 -5
- package/metadata/add-qualifier.js +6 -4
- package/metadata/add-reference.js +6 -4
- package/metadata/aliases.js +6 -4
- package/metadata/badges.js +3 -3
- package/metadata/claims.js +4 -4
- package/metadata/config.js +5 -5
- package/metadata/convert.js +4 -4
- package/metadata/create-entity.js +8 -8
- package/metadata/data.js +4 -4
- package/metadata/delete-entity.js +7 -7
- package/metadata/description.js +6 -4
- package/metadata/edit-entity.js +10 -10
- package/metadata/generate-template.js +4 -4
- package/metadata/hub.js +3 -3
- package/metadata/id.js +4 -4
- package/metadata/label.js +5 -3
- package/metadata/lang.js +4 -4
- package/metadata/lemma.js +6 -4
- package/metadata/merge-entity.js +6 -6
- package/metadata/move-claim.js +6 -4
- package/metadata/move-qualifier.js +6 -4
- package/metadata/open.js +4 -4
- package/metadata/props.js +4 -4
- package/metadata/query.js +3 -3
- package/metadata/remove-alias.js +6 -4
- package/metadata/remove-badge.js +5 -3
- package/metadata/remove-claim.js +6 -4
- package/metadata/remove-description.js +5 -3
- package/metadata/remove-label.js +5 -3
- package/metadata/remove-qualifier.js +6 -4
- package/metadata/remove-reference.js +6 -4
- package/metadata/remove-sitelink.js +5 -3
- package/metadata/revisions.js +4 -4
- package/metadata/search.js +3 -3
- package/metadata/set-alias.js +6 -4
- package/metadata/set-description.js +6 -4
- package/metadata/set-label.js +6 -4
- package/metadata/set-sitelink.js +5 -3
- package/metadata/sparql.js +4 -4
- package/metadata/summary.js +5 -5
- package/metadata/update-claim.js +5 -5
- package/metadata/update-qualifier.js +6 -4
- package/package.json +31 -22
- package/bin/wb +0 -22
- package/bin/wb-add-alias +0 -9
- package/bin/wb-add-badge +0 -9
- package/bin/wb-add-claim +0 -11
- package/bin/wb-add-qualifier +0 -11
- package/bin/wb-add-reference +0 -11
- package/bin/wb-aliases +0 -2
- package/bin/wb-badges +0 -18
- package/bin/wb-create-entity +0 -5
- package/bin/wb-delete-entity +0 -7
- package/bin/wb-description +0 -2
- package/bin/wb-edit-entity +0 -5
- package/bin/wb-label +0 -2
- package/bin/wb-lemma +0 -2
- package/bin/wb-move-claim +0 -17
- package/bin/wb-move-qualifier +0 -18
- package/bin/wb-remove-alias +0 -9
- package/bin/wb-remove-badge +0 -9
- package/bin/wb-remove-claim +0 -8
- package/bin/wb-remove-description +0 -13
- package/bin/wb-remove-label +0 -13
- package/bin/wb-remove-qualifier +0 -12
- package/bin/wb-remove-reference +0 -12
- package/bin/wb-remove-sitelink +0 -13
- package/bin/wb-set-alias +0 -9
- package/bin/wb-set-description +0 -9
- package/bin/wb-set-label +0 -9
- package/bin/wb-set-sitelink +0 -14
- package/bin/wb-update-qualifier +0 -11
- package/lib/valide.js +0 -4
|
@@ -7,30 +7,33 @@
|
|
|
7
7
|
// or https://inventaire.io/entity/wd:Q33977
|
|
8
8
|
// or even azfzafzaQ33977afz
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import { isNumericId } from 'wikibase-sdk'
|
|
11
|
+
import errors_ from './errors.js'
|
|
12
|
+
|
|
13
|
+
const entityIdPattern = /(Q|P|L|M)[1-9][0-9]*/
|
|
13
14
|
const nestedEntityIdPattern = /L[1-9][0-9]*-(F|S)[1-9][0-9]*/
|
|
14
15
|
const entitySchemaIdPattern = /(E)[1-9][0-9]*/
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
export function tolerantIdParserFactory (options = {}) {
|
|
18
|
+
return function tolerantIdParser (input) {
|
|
19
|
+
input = input.toUpperCase()
|
|
20
|
+
const { allowNestedIds = false, allowEntitiesSchemasIds = false } = options
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (allowNestedIds) {
|
|
23
|
+
const nestedEntityIdMatch = input.match(nestedEntityIdPattern)
|
|
24
|
+
if (nestedEntityIdMatch) return nestedEntityIdMatch[0]
|
|
25
|
+
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (allowEntitiesSchemasIds) {
|
|
28
|
+
const entitySchemaIdMatch = input.match(entitySchemaIdPattern)
|
|
29
|
+
if (entitySchemaIdMatch) return entitySchemaIdMatch[0]
|
|
30
|
+
}
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const entityIdMatch = input.match(entityIdPattern)
|
|
33
|
+
if (entityIdMatch) return entityIdMatch[0]
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
if (isNumericId(input)) return `Q${input}`
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
throw errors_.new('invalid id', { input, allowNestedIds, allowEntitiesSchemasIds })
|
|
38
|
+
}
|
|
36
39
|
}
|
package/lib/types.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const isArray = data => data instanceof Array
|
|
2
|
-
const isPlainObject = data => !isArray(data) && typeof data === 'object'
|
|
3
|
-
const isCollection = data => isArray(data) && isPlainObject(data[0])
|
|
4
|
-
const isPositiveIntegerString = str => typeof str === 'string' && /^\d+$/.test(str)
|
|
5
|
-
|
|
6
|
-
module.exports = { isArray, isPlainObject, isCollection, isPositiveIntegerString }
|
|
1
|
+
export const isArray = data => data instanceof Array
|
|
2
|
+
export const isPlainObject = data => !isArray(data) && typeof data === 'object'
|
|
3
|
+
export const isCollection = data => isArray(data) && isPlainObject(data[0])
|
|
4
|
+
export const isPositiveIntegerString = str => typeof str === 'string' && /^\d+$/.test(str)
|
package/lib/utils.js
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import errors_ from './errors.js'
|
|
4
4
|
|
|
5
|
-
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
5
|
+
export const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
6
6
|
|
|
7
|
-
const sum = (a, b) => a + b
|
|
7
|
+
export const sum = (a, b) => a + b
|
|
8
8
|
|
|
9
|
-
const average = values => {
|
|
9
|
+
export const average = values => {
|
|
10
10
|
if (values.length > 0) return values.reduce(sum, 0) / values.length
|
|
11
11
|
else return 0
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const getAbsoluteFilePath = filepath => path.resolve(process.cwd(), filepath)
|
|
14
|
+
export const getAbsoluteFilePath = filepath => path.resolve(process.cwd(), filepath)
|
|
15
15
|
|
|
16
|
-
const isFilePathSync = arg => {
|
|
16
|
+
export const isFilePathSync = arg => {
|
|
17
17
|
const possibleFilePath = getAbsoluteFilePath(arg)
|
|
18
|
-
return
|
|
18
|
+
return existsSync(possibleFilePath)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const isJsonString = str => {
|
|
21
|
+
export const isJsonString = str => {
|
|
22
22
|
if (typeof str !== 'string') return false
|
|
23
23
|
else return (str.trim()[0] === '{' || str.trim()[0] === '[')
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const validateTemplateCommand = ({ commandName, validCommands }) => {
|
|
26
|
+
export const validateTemplateCommand = ({ commandName, validCommands }) => {
|
|
27
27
|
if (!validCommands) return
|
|
28
28
|
if (validCommands && !validCommands.includes(commandName)) {
|
|
29
29
|
throw errors_.exitMessage('wrong command for this template', { commandName, validCommands })
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
module.exports = { wait, average, isFilePathSync, isJsonString, getAbsoluteFilePath, validateTemplateCommand }
|
package/lib/validate.js
ADDED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import errors_ from './errors.js'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default (fn, inputArgs, metadata) => {
|
|
4
4
|
if (typeof fn !== 'function') {
|
|
5
5
|
errors_.bundle('expected a function', { fn, type: typeof fn })
|
|
6
6
|
}
|
package/lib/value_parsers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
string: arg => arg.toString(),
|
|
3
3
|
number: str => parseInt(str),
|
|
4
4
|
boolean: value => {
|
|
@@ -7,5 +7,5 @@ module.exports = {
|
|
|
7
7
|
return value
|
|
8
8
|
},
|
|
9
9
|
lang: str => str.split(/[\W_-]/)[0].toLowerCase(),
|
|
10
|
-
object: obj => obj
|
|
10
|
+
object: obj => obj,
|
|
11
11
|
}
|
package/lib/wbk.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// A wrapper of wikidata SDK to customize the Wikibase instance if requested in config
|
|
2
|
-
|
|
2
|
+
import WBK from 'wikibase-sdk'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default program => {
|
|
5
5
|
const { instance, sparqlEndpoint } = program
|
|
6
|
-
|
|
6
|
+
program.wbk = program.wbk || WBK({ instance, sparqlEndpoint })
|
|
7
|
+
return program.wbk
|
|
7
8
|
}
|
package/lib/wellknown_queries.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { readdirSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { getDirname } from '#lib/fs'
|
|
3
4
|
|
|
4
5
|
const getKeyFromFilename = filename => {
|
|
5
6
|
return filename
|
|
@@ -7,11 +8,11 @@ const getKeyFromFilename = filename => {
|
|
|
7
8
|
.replace('.js', '')
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
const list =
|
|
11
|
+
const list = readdirSync(path.join(getDirname(import.meta.url), '/queries')).map(getKeyFromFilename)
|
|
11
12
|
|
|
12
13
|
const getAbsolutePath = key => {
|
|
13
14
|
const filename = key.replace(/-/g, '_') + '.js'
|
|
14
|
-
return path.join(
|
|
15
|
+
return path.join(getDirname(import.meta.url), 'queries/' + filename)
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
export default { list, getAbsolutePath }
|
package/metadata/add-alias.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'aa',
|
|
3
5
|
args: '<entity> <language> <aliases>',
|
|
4
6
|
description: 'add one or several aliases to the list of aliases of an entity in a given language',
|
|
5
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: 'Q4115189 fr foo', comment: "add 'foo' to the Sandbox entity (Q4115189) French aliases" },
|
|
8
|
-
{ args: 'Q4115189 fr "foo|bar|buzz', comment: "add 'foo', 'bar', and 'buzz' to the Sandbox entity (Q4115189) French aliases" }
|
|
9
|
-
]
|
|
10
|
+
{ args: 'Q4115189 fr "foo|bar|buzz', comment: "add 'foo', 'bar', and 'buzz' to the Sandbox entity (Q4115189) French aliases" },
|
|
11
|
+
],
|
|
10
12
|
}
|
package/metadata/add-badge.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'ab',
|
|
3
5
|
args: '<entity> <site> [badges]',
|
|
4
6
|
description: 'add badges on an existing sitelink, without removing other badges that might already have been set',
|
|
5
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: 'Q4115189 enwikiquote Q17437796,Q17437798', comment: 'Add Q17437796 and Q17437798 badges on Q4115189 enwikiquote sitelink' },
|
|
8
|
-
]
|
|
10
|
+
],
|
|
9
11
|
}
|
package/metadata/add-claim.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
alias: 'ac',
|
|
5
5
|
args: '<entity> <property> <value>',
|
|
6
6
|
description: 'add a claim to an entity',
|
|
7
|
-
options: Object.assign({ rank: true },
|
|
7
|
+
options: Object.assign({ rank: true }, editCommandsOptions),
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: 'Q4115189 P2002 Zorglub', comment: "add the Twitter account (P2002) 'Zorglub' to the Sandbox (Q4115189) entity" }
|
|
10
|
-
]
|
|
9
|
+
{ args: 'Q4115189 P2002 Zorglub', comment: "add the Twitter account (P2002) 'Zorglub' to the Sandbox (Q4115189) entity" },
|
|
10
|
+
],
|
|
11
11
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'aq',
|
|
3
5
|
args: '<claim-guid> <property> <value>',
|
|
4
6
|
description: 'add a qualifier to a claim',
|
|
5
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P155 'Q13406268'", comment: 'entity qualifier' },
|
|
8
10
|
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P1545 'A-123'", comment: 'string qualifier' },
|
|
9
11
|
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P580 '1802-02-26'", comment: 'time qualifier' },
|
|
10
12
|
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P2130 123", comment: 'quantity qualifier' },
|
|
11
13
|
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P2130 '{\"amount\":123,\"unit\":\"Q4916\"}'", comment: 'quantity qualifier with a unit' },
|
|
12
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P3132 \"text=les sanglots long des violons de l'automne&language=fr\"", comment: 'monolingualtext qualifier' }
|
|
13
|
-
]
|
|
14
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P3132 \"text=les sanglots long des violons de l'automne&language=fr\"", comment: 'monolingualtext qualifier' },
|
|
15
|
+
],
|
|
14
16
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'ar',
|
|
3
5
|
args: '<claim-guid> <property> <value>',
|
|
4
6
|
description: 'add a reference to a claim',
|
|
5
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P854 'https://example.org/rise-and-box-of-the-holy-sand-box'", comment: 'add a reference URL (P854) to this claim' },
|
|
8
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P143 Q60856", comment: 'reference the claim as imported from (P143) Wikipedia in Uyghur (Q60856)' }
|
|
9
|
-
]
|
|
10
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P143 Q60856", comment: 'reference the claim as imported from (P143) Wikipedia in Uyghur (Q60856)' },
|
|
11
|
+
],
|
|
10
12
|
}
|
package/metadata/aliases.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { entityAttributeCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'a',
|
|
3
5
|
args: '<entity>',
|
|
4
6
|
description: "display the entity's aliases",
|
|
5
|
-
options:
|
|
7
|
+
options: entityAttributeCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: 'Q123', comment: 'fetch the aliases for the entity Q123' },
|
|
8
|
-
{ args: 'Q123 --lang ja', comment: 'fetch the aliases for the entity Q123 in Japanese' }
|
|
9
|
-
]
|
|
10
|
+
{ args: 'Q123 --lang ja', comment: 'fetch the aliases for the entity Q123 in Japanese' },
|
|
11
|
+
],
|
|
10
12
|
}
|
package/metadata/badges.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
args: '',
|
|
3
3
|
description: 'list sitelink badges available on a Wikibase instance',
|
|
4
4
|
options: {
|
|
@@ -7,10 +7,10 @@ module.exports = {
|
|
|
7
7
|
clipboard: true,
|
|
8
8
|
json: true,
|
|
9
9
|
instance: true,
|
|
10
|
-
sparqlEndpoint: false
|
|
10
|
+
sparqlEndpoint: false,
|
|
11
11
|
},
|
|
12
12
|
examples: [
|
|
13
13
|
{ args: '', comment: 'List badges on the Wikibase instance set in config' },
|
|
14
14
|
{ args: '--instance https://test.wikidata.org', comment: 'List badges on an explicit Wikibase instance' },
|
|
15
|
-
]
|
|
15
|
+
],
|
|
16
16
|
}
|
package/metadata/claims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
alias: 'c',
|
|
3
3
|
args: '<entity> [property]',
|
|
4
4
|
description: 'display the claims of an entity',
|
|
@@ -8,7 +8,7 @@ module.exports = {
|
|
|
8
8
|
clipboard: true,
|
|
9
9
|
json: true,
|
|
10
10
|
instance: true,
|
|
11
|
-
sparqlEndpoint: true
|
|
11
|
+
sparqlEndpoint: true,
|
|
12
12
|
},
|
|
13
13
|
examples: [
|
|
14
14
|
{ args: 'Q2001', comment: 'fetch all claims for the entity Q2001' },
|
|
@@ -16,6 +16,6 @@ module.exports = {
|
|
|
16
16
|
{ args: 'Q2001 --type Url', comment: 'or just the claims from properties of type Url (other possible types: ExternalId, String, WikibaseItem, WikibaseProperty, Time, Monolingualtext, Quantity, CommonsMedia, GlobeCoordinate)' },
|
|
17
17
|
{ args: 'Q2001 library', comment: 'or just the claims from properties with labels matching "library"' },
|
|
18
18
|
{ args: 'Q2001 website', comment: 'or website, etc' },
|
|
19
|
-
{ args: 'Q2001 --lang de', comment: 'fetch all claims for the entity Q2001 with properties labels in German' }
|
|
20
|
-
]
|
|
19
|
+
{ args: 'Q2001 --lang de', comment: 'fetch all claims for the entity Q2001 with properties labels in German' },
|
|
20
|
+
],
|
|
21
21
|
}
|
package/metadata/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { grey } from '#lib/chalk'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
args: '<key> [value]',
|
|
5
5
|
description: 'get and set configuration parameters',
|
|
6
6
|
options: {
|
|
@@ -9,7 +9,7 @@ module.exports = {
|
|
|
9
9
|
clipboard: false,
|
|
10
10
|
json: true,
|
|
11
11
|
instance: false,
|
|
12
|
-
sparqlEndpoint: false
|
|
12
|
+
sparqlEndpoint: false,
|
|
13
13
|
},
|
|
14
14
|
examples: [
|
|
15
15
|
{ args: 'clipboard true', comment: 'always copy results to the clipboard when possible' },
|
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
|
20
20
|
{ args: 'credentials http://localhost:8181 test', comment: 'test the validity of your credentials for an instance' },
|
|
21
21
|
{ args: 'path', comment: 'get configuration path' },
|
|
22
22
|
{ args: 'reset', comment: 'reset configuration' },
|
|
23
|
-
{ args: `--json > config.json.backup\n ${grey('# to restore it, simply override the current config file')}\n cp config.json.backup $(wb config path)`, comment: 'can be used to backup the config' }
|
|
23
|
+
{ args: `--json > config.json.backup\n ${grey('# to restore it, simply override the current config file')}\n cp config.json.backup $(wb config path)`, comment: 'can be used to backup the config' },
|
|
24
24
|
],
|
|
25
|
-
doc: 'https://github.com/maxlath/wikibase-cli/blob/main/docs/config.md#config'
|
|
25
|
+
doc: 'https://github.com/maxlath/wikibase-cli/blob/main/docs/config.md#config',
|
|
26
26
|
}
|
package/metadata/convert.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
args: '',
|
|
3
3
|
description: 'convert batches of external ids to Wikidata ids and vice versa',
|
|
4
4
|
options: {
|
|
@@ -7,11 +7,11 @@ module.exports = {
|
|
|
7
7
|
clipboard: false,
|
|
8
8
|
json: false,
|
|
9
9
|
instance: false,
|
|
10
|
-
sparqlEndpoint: true
|
|
10
|
+
sparqlEndpoint: true,
|
|
11
11
|
},
|
|
12
12
|
examples: [
|
|
13
13
|
{ args: '-p P268 -o 11865344k 11932251d', comment: 'get the Wikidata ids corresponding to those BNF ids' },
|
|
14
14
|
{ args: '-p P268 -s Q45 Q140', comment: 'get the BNF ids corresponding to those Wikidata ids' },
|
|
15
|
-
{ args: '-p P268 -o < ids_list', comment: 'the same but taking the ids from a file' }
|
|
16
|
-
]
|
|
15
|
+
{ args: '-p P268 -o < ids_list', comment: 'the same but taking the ids from a file' },
|
|
16
|
+
],
|
|
17
17
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
alias: 'ce',
|
|
5
5
|
args: '<data>',
|
|
6
6
|
description: 'Create a new entity',
|
|
7
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
9
|
{
|
|
10
10
|
args: "'{\"labels\":{\"en\":\"a label\",\"fr\":\"un label\"},\"descriptions\":{\"en\":\"some description\",\"fr\":\"une description\"},\"claims\":{\"P1775\":[\"Q3576110\",\"Q12206942\"],\"P2002\":\"bulgroz\"}}'",
|
|
11
|
-
comment: 'pass data as JSON'
|
|
11
|
+
comment: 'pass data as JSON',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
args: './new_entity_data.json',
|
|
15
|
-
comment: 'pass data as a JSON file path'
|
|
15
|
+
comment: 'pass data as a JSON file path',
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
args: './new_entity_data.json --instance http://some/wikibase/instance/w/api.php --sparql-endpoint http://some/sparql/endpoint',
|
|
19
|
-
comment: 'in case you use are not editing wikidata.org, make sure to specify the custom Wikibase instance and its SPARQL endpoint, as claims formatting and validation will depend on properties types that are retrieved from the SPARQL endpoint'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
19
|
+
comment: 'in case you use are not editing wikidata.org, make sure to specify the custom Wikibase instance and its SPARQL endpoint, as claims formatting and validation will depend on properties types that are retrieved from the SPARQL endpoint',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
22
|
}
|
package/metadata/data.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
alias: 'd',
|
|
3
3
|
args: '<entity>',
|
|
4
4
|
description: "output the entity's data",
|
|
@@ -8,7 +8,7 @@ module.exports = {
|
|
|
8
8
|
clipboard: false,
|
|
9
9
|
json: false,
|
|
10
10
|
instance: true,
|
|
11
|
-
sparqlEndpoint: false
|
|
11
|
+
sparqlEndpoint: false,
|
|
12
12
|
},
|
|
13
13
|
examples: [
|
|
14
14
|
{ args: 'Q123', comment: "fetch Q123's raw data" },
|
|
@@ -17,6 +17,6 @@ module.exports = {
|
|
|
17
17
|
{ args: '--simplify --keep ids,references,qualifiers,hashes,nontruthy Q123', comment: 'simplified Q123 data, but keep some attributes' },
|
|
18
18
|
{ args: '--simplify --keep all Q123', comment: 'same as above' },
|
|
19
19
|
{ args: 'Q1496 | jd labels.pt', comment: "take advantage of the raw data being output as JSON\n # to pass it to a JSON parsers (here jsondepth a.k.a. jd)\n # and get only the piece of data you're looking for" },
|
|
20
|
-
{ args: '--simplify --keep ids Q123 | jd claims.P138 -j', comment: 'get Q123 P138 claims ids' }
|
|
21
|
-
]
|
|
20
|
+
{ args: '--simplify --keep ids Q123 | jd claims.P138 -j', comment: 'get Q123 P138 claims ids' },
|
|
21
|
+
],
|
|
22
22
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
alias: 'de',
|
|
5
5
|
args: '<id>',
|
|
6
6
|
description: 'Delete an entity',
|
|
7
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
9
|
{
|
|
10
10
|
args: 'Q1',
|
|
11
|
-
comment: 'delete an item'
|
|
11
|
+
comment: 'delete an item',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
args: 'P1',
|
|
15
|
-
comment: 'delete a property'
|
|
16
|
-
}
|
|
17
|
-
]
|
|
15
|
+
comment: 'delete a property',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
18
|
}
|
package/metadata/description.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { entityAttributeCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'desc',
|
|
3
5
|
args: '<entity>',
|
|
4
6
|
description: "display the entity's description",
|
|
5
|
-
options:
|
|
7
|
+
options: entityAttributeCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: 'Q123', comment: 'fetch the description for the entity Q123' },
|
|
8
|
-
{ args: 'Q123 --lang ja', comment: 'fetch the description for the entity Q123 in Japanese' }
|
|
9
|
-
]
|
|
10
|
+
{ args: 'Q123 --lang ja', comment: 'fetch the description for the entity Q123 in Japanese' },
|
|
11
|
+
],
|
|
10
12
|
}
|
package/metadata/edit-entity.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { editCommandsOptions } from '#lib/common_options'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
alias: 'ee',
|
|
5
5
|
args: '<data>',
|
|
6
6
|
description: 'Edit an existing entity',
|
|
7
|
-
options:
|
|
7
|
+
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
9
|
{
|
|
10
10
|
args: "'{\"id\":\"Q4115189\",\"labels\":{\"en\":\"a label\",\"fr\":\"un label\"},\"descriptions\":{\"en\":\"some description\",\"fr\":\"une description\"},\"claims\":{\"P1775\":[\"Q3576110\",\"Q12206942\"],\"P2002\":\"bulgroz\"}}'",
|
|
11
|
-
comment: 'pass data as JSON'
|
|
11
|
+
comment: 'pass data as JSON',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
args: './existing_item_data.json',
|
|
15
|
-
comment: 'pass data as a JSON file path'
|
|
15
|
+
comment: 'pass data as a JSON file path',
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
args: './existing_item_data.js',
|
|
19
|
-
comment: 'pass data from a JS module exporting an object'
|
|
19
|
+
comment: 'pass data from a JS module exporting an object',
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
args: './existing_item_data.js Q123 abc 456',
|
|
23
|
-
comment: 'pass data from a JS module exporting a function (the additional arguments will be passed to the function)'
|
|
23
|
+
comment: 'pass data from a JS module exporting a function (the additional arguments will be passed to the function)',
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
args: './existing_item_data.json --instance http://some/wikibase/instance/w/api.php --sparql-endpoint http://some/sparql/endpoint',
|
|
27
|
-
comment: 'in case you use are not editing wikidata.org, make sure to specify the custom Wikibase instance and its SPARQL endpoint, as claims formatting and validation will depend on properties types that are retrieved from the SPARQL endpoint'
|
|
28
|
-
}
|
|
29
|
-
]
|
|
27
|
+
comment: 'in case you use are not editing wikidata.org, make sure to specify the custom Wikibase instance and its SPARQL endpoint, as claims formatting and validation will depend on properties types that are retrieved from the SPARQL endpoint',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
alias: 'gt',
|
|
3
3
|
args: '<entity>',
|
|
4
4
|
description: "output the pre-formatted item's data optimized for edition with `wd edit-item`",
|
|
@@ -8,13 +8,13 @@ module.exports = {
|
|
|
8
8
|
clipboard: false,
|
|
9
9
|
json: true,
|
|
10
10
|
instance: true,
|
|
11
|
-
sparqlEndpoint: false
|
|
11
|
+
sparqlEndpoint: false,
|
|
12
12
|
},
|
|
13
13
|
examples: [
|
|
14
14
|
{ args: 'Q123', comment: 'get Q123 pre-formatted data' },
|
|
15
15
|
{ args: 'Q123 --props claims,sitelinks', comment: 'only get data required to edit the claims and sitelinks' },
|
|
16
16
|
{ args: 'Q123 --props claims.P31,sitelinks.frwiki', comment: 'only get data required to edit the P31 claims and the frwiki sitelink' },
|
|
17
17
|
{ args: 'Q123 --format js', comment: 'get the template in JS (easier to edit manually than JSON and still compatible with create-entity and edit-entity commands)' },
|
|
18
|
-
{ args: 'Q123 Q124 Q125', comment: 'get several templates at once as NDJSON' }
|
|
19
|
-
]
|
|
18
|
+
{ args: 'Q123 Q124 Q125', comment: 'get several templates at once as NDJSON' },
|
|
19
|
+
],
|
|
20
20
|
}
|
package/metadata/hub.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
alias: 'h',
|
|
3
3
|
args: '<query>',
|
|
4
4
|
description: 'Open a web page using the Hub, see documentation: https://tools.wmflabs.org/hub/',
|
|
@@ -8,12 +8,12 @@ module.exports = {
|
|
|
8
8
|
clipboard: true,
|
|
9
9
|
json: true,
|
|
10
10
|
instance: false,
|
|
11
|
-
sparqlEndpoint: false
|
|
11
|
+
sparqlEndpoint: false,
|
|
12
12
|
},
|
|
13
13
|
examples: [
|
|
14
14
|
{ args: 'viaf:24597135', comment: 'Find the entity having 24597135 as VIAF id' },
|
|
15
15
|
{ args: '--open viaf:24597135 site=inventaire', comment: 'Find the entity having 24597135 as VIAF id and open the corresponding page on inventaire.io' },
|
|
16
16
|
{ args: 'Q3 property=image width=300', comment: 'Get the image illustrating Q3 in 300px' },
|
|
17
17
|
{ args: 'Q3 --url', comment: 'Just return the query URL' },
|
|
18
|
-
]
|
|
18
|
+
],
|
|
19
19
|
}
|
package/metadata/id.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
args: '<title>',
|
|
3
3
|
description: 'get a Wikidata id from a Wikipedia article title',
|
|
4
4
|
options: {
|
|
@@ -7,10 +7,10 @@ module.exports = {
|
|
|
7
7
|
clipboard: true,
|
|
8
8
|
json: false,
|
|
9
9
|
instance: true,
|
|
10
|
-
sparqlEndpoint: false
|
|
10
|
+
sparqlEndpoint: false,
|
|
11
11
|
},
|
|
12
12
|
examples: [
|
|
13
13
|
{ args: 'Cantabria', comment: 'get the Wikidata id corresponding to the article "Cantabria" in Wikipedia' },
|
|
14
|
-
{ args: 'science politique --lang fr', comment: 'get the Wikidata id corresponding to the article "science politique" in the French Wikipedia' }
|
|
15
|
-
]
|
|
14
|
+
{ args: 'science politique --lang fr', comment: 'get the Wikidata id corresponding to the article "science politique" in the French Wikipedia' },
|
|
15
|
+
],
|
|
16
16
|
}
|
package/metadata/label.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { entityAttributeCommandsOptions } from '#lib/common_options'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
2
4
|
alias: 'l',
|
|
3
5
|
args: '<entity>',
|
|
4
6
|
description: "display the entity's label",
|
|
5
|
-
options:
|
|
7
|
+
options: entityAttributeCommandsOptions,
|
|
6
8
|
examples: [
|
|
7
9
|
{ args: 'Q123', comment: 'fetch the label for the entity Q123' },
|
|
8
10
|
{ args: 'Q123 --lang ja', comment: 'fetch the label for the entity Q123 in Japanese' },
|
|
9
11
|
{ args: 'Q1 Q2 Q3 P6', comment: 'fetch labels for several entities' },
|
|
10
|
-
]
|
|
12
|
+
],
|
|
11
13
|
}
|
package/metadata/lang.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
args: '<language code or wikidata id>',
|
|
3
3
|
description: 'identify language code and return associated data',
|
|
4
4
|
options: {
|
|
@@ -7,10 +7,10 @@ module.exports = {
|
|
|
7
7
|
clipboard: true,
|
|
8
8
|
json: true,
|
|
9
9
|
instance: false,
|
|
10
|
-
sparqlEndpoint: false
|
|
10
|
+
sparqlEndpoint: false,
|
|
11
11
|
},
|
|
12
12
|
examples: [
|
|
13
13
|
{ args: 'ak', comment: 'find data associated with the Akan language from its language code' },
|
|
14
|
-
{ args: 'Q28026', comment: 'find data associated with the Akan language from its Wikidata item id' }
|
|
15
|
-
]
|
|
14
|
+
{ args: 'Q28026', comment: 'find data associated with the Akan language from its Wikidata item id' },
|
|
15
|
+
],
|
|
16
16
|
}
|