wikibase-cli 17.0.4 → 17.0.6
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/bin/wb-sparql.js +1 -1
- package/lib/parse_command_utils.js +13 -11
- package/lib/request.js +5 -1
- package/package.json +2 -2
package/bin/wb-sparql.js
CHANGED
|
@@ -29,7 +29,7 @@ const main = async () => {
|
|
|
29
29
|
// Allow to pass a JS module that exports a function
|
|
30
30
|
// to which is passed the remaining arguments
|
|
31
31
|
// and from which the SPARQL request is generated
|
|
32
|
-
if (extension
|
|
32
|
+
if (extension.endsWith('js')) {
|
|
33
33
|
absoluePath = resolve(process.cwd(), path)
|
|
34
34
|
// or pass the name of one of the wellknown queries
|
|
35
35
|
} else if (wellknownQueries.list.includes(path)) {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
// Normalize prefixed statements GUIDs as returned by SPARQL queries:
|
|
2
|
+
// to the format used by Wikibase API
|
|
3
|
+
// - from: wds:Q1827902-6706334E-D27E-4F4B-B6DA-ABE7544DF11C
|
|
4
|
+
// - to: Q1827902$6706334E-D27E-4F4B-B6DA-ABE7544DF11C
|
|
5
|
+
// Also accept Q1827902-6706334E-D27E-4F4B-B6DA-ABE7544DF11C
|
|
1
6
|
export const parseGuid = guid => {
|
|
2
7
|
guid = guid
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.replace(/("|')/g, '')
|
|
12
|
-
.replace('\\$', '$')
|
|
13
|
-
.trim()
|
|
8
|
+
// Drop prefix
|
|
9
|
+
.replace(/^[a-z]+:/, '')
|
|
10
|
+
.replace(/^([QPLM]\d+(-[FS]\d+)?)-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i, '$1$$$3')
|
|
11
|
+
// Often required when getting guids from the command line, as passing a value with a $
|
|
12
|
+
// can be challenging, and require different quoting strategies
|
|
13
|
+
.replace(/("|')/g, '')
|
|
14
|
+
.replace('\\$', '$')
|
|
15
|
+
.trim()
|
|
14
16
|
return guid
|
|
15
17
|
}
|
package/lib/request.js
CHANGED
|
@@ -60,7 +60,11 @@ async function handleResponse ({ res, url, method }) {
|
|
|
60
60
|
console.error(JSON.stringify({ request: { url, method }, response: { headers } }))
|
|
61
61
|
}
|
|
62
62
|
// When Wikibase crash it doesn't return JSON errors anymore
|
|
63
|
-
|
|
63
|
+
try {
|
|
64
|
+
body = JSON.parse(body)
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.error('could not parse response body as JSON', err, { body })
|
|
67
|
+
}
|
|
64
68
|
const { status: statusCode } = res
|
|
65
69
|
if (statusCode >= 400) {
|
|
66
70
|
throw newError(statusCode, body)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikibase-cli",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.6",
|
|
4
4
|
"description": "A command-line interface to Wikibase",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"chalk": "^5.3.0",
|
|
51
51
|
"commander": "^6.0.0",
|
|
52
|
-
"copy-paste": "^1.5.
|
|
52
|
+
"copy-paste": "^1.5.0",
|
|
53
53
|
"lodash-es": "^4.17.21",
|
|
54
54
|
"mkdirp": "^3.0.1",
|
|
55
55
|
"node-fetch": "^2.6.0",
|