wikibase-cli 17.0.9 → 18.0.0
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/lib/get_entities_schemas.js +0 -1
- package/lib/get_ttl_entities.js +0 -1
- package/lib/request.js +8 -24
- package/package.json +4 -5
package/lib/get_ttl_entities.js
CHANGED
package/lib/request.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
// Using a custom agent to set keepAlive=true
|
|
2
|
-
// https://nodejs.org/api/http.html#http_class_http_agent
|
|
3
|
-
// https://github.com/bitinn/node-fetch#custom-agent
|
|
4
|
-
import http from 'node:http'
|
|
5
|
-
import https from 'node:https'
|
|
6
|
-
import { pick } from 'lodash-es'
|
|
7
|
-
import fetch from 'node-fetch'
|
|
8
1
|
import { debug } from '#lib/debug'
|
|
9
2
|
import program from './program.js'
|
|
10
3
|
import globalHeaders from './request_headers.js'
|
|
11
4
|
|
|
12
|
-
const httpAgent = new http.Agent({ keepAlive: true })
|
|
13
|
-
const httpsAgent = new https.Agent({ keepAlive: true })
|
|
14
|
-
// Useful to:
|
|
15
|
-
// - accept self-signed certificates
|
|
16
|
-
// - accept certificates that would otherwise generate a UNABLE_TO_VERIFY_LEAF_SIGNATURE error
|
|
17
|
-
const insecureHttpsAgent = new https.Agent({ keepAlive: true, rejectUnauthorized: false })
|
|
18
|
-
const tlsErrorsHosts = new Set([ 'datos.bne.es' ])
|
|
19
|
-
|
|
20
|
-
const agent = ({ host, protocol }) => {
|
|
21
|
-
if (tlsErrorsHosts.has(host)) return protocol === 'http:' ? httpAgent : insecureHttpsAgent
|
|
22
|
-
else return protocol === 'http:' ? httpAgent : httpsAgent
|
|
23
|
-
}
|
|
24
5
|
const buildHeaders = customHeaders => {
|
|
25
6
|
if (customHeaders) return Object.assign({}, globalHeaders, customHeaders)
|
|
26
7
|
else return globalHeaders
|
|
@@ -29,22 +10,23 @@ const buildHeaders = customHeaders => {
|
|
|
29
10
|
function request (url, options) {
|
|
30
11
|
const { method = 'get', headers, body } = options
|
|
31
12
|
debug('request', method.toUpperCase(), url, { headers, body })
|
|
13
|
+
options.keepalive = true
|
|
32
14
|
return fetch(url, options)
|
|
33
15
|
}
|
|
34
16
|
|
|
35
17
|
export const get = async url => {
|
|
36
|
-
const res = await request(url, { headers: globalHeaders
|
|
18
|
+
const res = await request(url, { headers: globalHeaders })
|
|
37
19
|
return handleResponse({ res, url })
|
|
38
20
|
}
|
|
39
21
|
|
|
40
22
|
export const customGet = async ({ url, headers }) => {
|
|
41
|
-
const res = await request(url, { headers: buildHeaders(headers)
|
|
23
|
+
const res = await request(url, { headers: buildHeaders(headers) })
|
|
42
24
|
return handleResponse({ res, url })
|
|
43
25
|
}
|
|
44
26
|
|
|
45
27
|
export const post = async ({ url, body, headers }) => {
|
|
46
28
|
const method = 'post'
|
|
47
|
-
const res = await request(url, { method, body, headers: buildHeaders(headers)
|
|
29
|
+
const res = await request(url, { method, body, headers: buildHeaders(headers) })
|
|
48
30
|
return handleResponse({ res, url, method })
|
|
49
31
|
}
|
|
50
32
|
|
|
@@ -52,10 +34,12 @@ async function handleResponse ({ res, url, method }) {
|
|
|
52
34
|
let body = await res.text()
|
|
53
35
|
const { logResponseHeaders } = program
|
|
54
36
|
if (logResponseHeaders) {
|
|
55
|
-
|
|
37
|
+
const headers = {}
|
|
56
38
|
if (typeof logResponseHeaders === 'string') {
|
|
57
39
|
const headersSubset = logResponseHeaders.split(',')
|
|
58
|
-
|
|
40
|
+
for (const headerName of headersSubset) {
|
|
41
|
+
headers[headerName] = res.headers.get(headerName)?.split(';').map(val => val.trim())
|
|
42
|
+
}
|
|
59
43
|
}
|
|
60
44
|
console.error(JSON.stringify({ request: { url, method }, response: { headers } }))
|
|
61
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikibase-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"description": "A command-line interface to Wikibase",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -52,14 +52,13 @@
|
|
|
52
52
|
"copy-paste": "^1.5.0",
|
|
53
53
|
"lodash-es": "^4.17.21",
|
|
54
54
|
"mkdirp": "^3.0.1",
|
|
55
|
-
"node-fetch": "^2.6.0",
|
|
56
55
|
"open": "^9.1.0",
|
|
57
56
|
"read": "^2.1.0",
|
|
58
57
|
"shell-quote": "^1.8.1",
|
|
59
58
|
"split": "^1.0.1",
|
|
60
59
|
"through": "^2.3.8",
|
|
61
|
-
"wikibase-edit": "^
|
|
62
|
-
"wikibase-sdk": "^10.0.
|
|
60
|
+
"wikibase-edit": "^7.0.2",
|
|
61
|
+
"wikibase-sdk": "^10.0.2",
|
|
63
62
|
"wikidata-lang": "^2.0.11"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
@@ -75,6 +74,6 @@
|
|
|
75
74
|
"should": "^13.2.3"
|
|
76
75
|
},
|
|
77
76
|
"engines": {
|
|
78
|
-
"node": ">=
|
|
77
|
+
"node": ">= 18"
|
|
79
78
|
}
|
|
80
79
|
}
|