api-tuner 0.4.0 → 0.4.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/lib/merge-curl-output.js +6 -10
- package/package.json +1 -1
- package/rules/assertions.n3 +13 -1
- package/rules/requests.n3 +0 -3
package/lib/merge-curl-output.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import { createReadStream } from 'node:fs';
|
|
3
|
+
import { writeFile } from 'node:fs/promises';
|
|
4
|
+
import url from 'node:url';
|
|
3
5
|
// eslint-disable-next-line import/default
|
|
4
6
|
import jsonld from 'jsonld';
|
|
5
7
|
import rdf from '@zazuko/env-node';
|
|
@@ -33,18 +35,12 @@ const ns = rdf.namespace('https://api-tuner.described.at/');
|
|
|
33
35
|
parser = rdf.formats.parsers.get(contentType);
|
|
34
36
|
}
|
|
35
37
|
if (parser) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
response.dataset.add(rdf.quad(quad.subject, quad.predicate, quad.object, bodyGraph));
|
|
40
|
-
}
|
|
41
|
-
response.addOut(ns.body, bodyGraph);
|
|
38
|
+
const body = parser.import(createReadStream(bodyPath));
|
|
39
|
+
await writeFile(`${bodyPath}.nt`, rdf.formats.serializers.get('application/n-triples').import(body));
|
|
40
|
+
response.addOut(ns.body, rdf.namedNode(url.pathToFileURL(`${bodyPath}.nt`).toString()));
|
|
42
41
|
}
|
|
43
42
|
else {
|
|
44
|
-
|
|
45
|
-
if (body) {
|
|
46
|
-
response.addOut(ns.body, body);
|
|
47
|
-
}
|
|
43
|
+
response.addOut(ns.body, bodyPath);
|
|
48
44
|
}
|
|
49
45
|
const headers = Object.entries(headersJson).flatMap(([header, values]) => values.map(value => response.blankNode().addOut(ns('name'), header).addOut(ns.value, value)));
|
|
50
46
|
response.addOut(ns.headers, headers);
|
package/package.json
CHANGED
package/rules/assertions.n3
CHANGED
|
@@ -57,8 +57,20 @@ prefix log: <http://www.w3.org/2000/10/swap/log#>
|
|
|
57
57
|
?res tuner:body ?body .
|
|
58
58
|
} <= {
|
|
59
59
|
?res log:includes {
|
|
60
|
-
[] a tuner:Response ; tuner:body ?
|
|
60
|
+
[] a tuner:Response ; tuner:body ?bodyPath .
|
|
61
61
|
} .
|
|
62
|
+
|
|
63
|
+
(
|
|
64
|
+
{
|
|
65
|
+
?bodyPath log:rawType log:Literal .
|
|
66
|
+
}
|
|
67
|
+
{
|
|
68
|
+
("cat " ?bodyPath)!string:concatenation log:shell ?body .
|
|
69
|
+
}
|
|
70
|
+
{
|
|
71
|
+
?bodyPath log:semantics ?body .
|
|
72
|
+
}
|
|
73
|
+
) log:ifThenElseIn [] .
|
|
62
74
|
} .
|
|
63
75
|
|
|
64
76
|
{
|
package/rules/requests.n3
CHANGED
|
@@ -6,8 +6,6 @@ PREFIX tuner: <https://api-tuner.described.at/>
|
|
|
6
6
|
prefix file: <http://www.w3.org/2000/10/swap/file#>
|
|
7
7
|
prefix earl: <http://www.w3.org/ns/earl#>
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
9
|
{
|
|
12
10
|
?req tuner:response ?res .
|
|
13
11
|
} <= {
|
|
@@ -85,7 +83,6 @@ prefix earl: <http://www.w3.org/ns/earl#>
|
|
|
85
83
|
?res^tuner:trace .
|
|
86
84
|
} log:callWithCleanup {
|
|
87
85
|
{ ?responseHeadersFile!file:rm } log:callWithCleanup true .
|
|
88
|
-
{ ?responseBodyFile!file:rm } log:callWithCleanup true .
|
|
89
86
|
{ ?responseFile!file:rm } log:callWithCleanup true .
|
|
90
87
|
} .
|
|
91
88
|
} .
|