@lindas/trifid-plugin-ckan 7.0.0 → 7.0.2
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/CHANGELOG.md +30 -1
- package/README.md +114 -114
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/ckan.js +51 -47
- package/src/index.js +1 -1
- package/src/query.js +1 -1
- package/src/xml.js +344 -344
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lindas/trifid-plugin-ckan",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Endpoint for opendata.swiss CKAN harvester",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -38,27 +38,27 @@
|
|
|
38
38
|
"ckan"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@lindas/clownface": "^2.0.4",
|
|
42
|
+
"@lindas/env": "^3.0.1",
|
|
43
|
+
"@lindas/prefixes": "^2.4.0",
|
|
44
|
+
"@lindas/trifid-core": "^7.0.2",
|
|
41
45
|
"@tpluscode/rdf-string": "^1.3.3",
|
|
42
|
-
"@zazuko/env": "^3.0.1",
|
|
43
|
-
"@zazuko/prefixes": "^2.4.0",
|
|
44
46
|
"is-graph-pointer": "^2.2.0",
|
|
45
47
|
"sparql-http-client": "^3.0.1",
|
|
46
|
-
"xmlbuilder2": "^
|
|
48
|
+
"xmlbuilder2": "^4.0.3"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
51
|
+
"@lindas/trifid-handler-fetch": "^7.0.2",
|
|
49
52
|
"@types/node": "^24.7.0",
|
|
50
53
|
"c8": "^10.1.3",
|
|
51
54
|
"chai": "^6.2.0",
|
|
52
55
|
"chai-subset": "^1.6.0",
|
|
53
56
|
"rimraf": "^6.0.1",
|
|
54
|
-
"@lindas/trifid-core": "^7.0.0",
|
|
55
|
-
"@lindas/trifid-handler-fetch": "^7.0.0",
|
|
56
57
|
"typescript": "^5.9.3",
|
|
57
58
|
"xml2js": "^0.6.2",
|
|
58
59
|
"xml2js-xpath": "^0.13.0"
|
|
59
60
|
},
|
|
60
61
|
"publishConfig": {
|
|
61
|
-
"access": "public"
|
|
62
|
-
"provenance": false
|
|
62
|
+
"access": "public"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/ckan.js
CHANGED
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import ParsingClient from 'sparql-http-client/ParsingClient.js'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @property {string}
|
|
13
|
-
* @property {string}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import ParsingClient from 'sparql-http-client/ParsingClient.js'
|
|
4
|
+
import { nodeCompatibleFetch } from '@lindas/trifid-core'
|
|
5
|
+
import { toXML } from './xml.js'
|
|
6
|
+
import { datasetsQuery } from './query.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* API Configuration.
|
|
10
|
+
*
|
|
11
|
+
* @typedef {Object} APIConfig
|
|
12
|
+
* @property {string} endpointUrl The SPARQL endpoint URL.
|
|
13
|
+
* @property {string} user The user for the endpoint.
|
|
14
|
+
* @property {string} password The password for the endpoint.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Fetch datasets.
|
|
19
|
+
*
|
|
20
|
+
* @typedef {(organizationId: import('@rdfjs/types').NamedNode<string>) => Promise<import('@rdfjs/types').DatasetCore<import('@rdfjs/types').Quad, import('@rdfjs/types').Quad>>} FetchDatasets
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create CKAN API.
|
|
25
|
+
*
|
|
26
|
+
* @param {APIConfig} config API configuration.
|
|
27
|
+
* @returns {{ fetchDatasets: FetchDatasets, toXML: (dataset: import('@rdfjs/types').DatasetCore<import('@rdfjs/types').Quad, import('@rdfjs/types').Quad>) => string}}
|
|
28
|
+
*/
|
|
29
|
+
export const createAPI = (config) => {
|
|
30
|
+
const client = new ParsingClient({
|
|
31
|
+
endpointUrl: config.endpointUrl,
|
|
32
|
+
user: config.user,
|
|
33
|
+
password: config.password,
|
|
34
|
+
// Use native fetch wrapper for proper brotli/gzip decompression support
|
|
35
|
+
// (node-fetch has brotli bugs that cause "Decompression failed" errors)
|
|
36
|
+
fetch: nodeCompatibleFetch,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @type {FetchDatasets}
|
|
41
|
+
*/
|
|
42
|
+
const fetchDatasets = async (organizationId) => {
|
|
43
|
+
const query = datasetsQuery(organizationId)
|
|
44
|
+
return await client.query.construct(query.toString())
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
fetchDatasets,
|
|
49
|
+
toXML,
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/index.js
CHANGED