api-tuner 0.1.1 → 0.1.3
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 +8 -0
- package/bin/tuner.sh +1 -0
- package/package.json +1 -1
- package/rules/curl-body.n3 +33 -11
- package/rules/files.n3 +1 -1
- package/rules/requests.n3 +35 -28
package/README.md
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
- [SWI Prolog](https://www.swi-prolog.org/Download.html)
|
|
8
8
|
|
|
9
|
+
Follow platform-specific instructions to install locally oor in a docker image.
|
|
10
|
+
|
|
11
|
+
To run `api-tuner` in GitHub workflow, you add this action to your jobs:
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
- uses: fabasoad/setup-prolog-action@v1
|
|
15
|
+
```
|
|
16
|
+
|
|
9
17
|
## Installation
|
|
10
18
|
|
|
11
19
|
`npm i api-tuner`
|
package/bin/tuner.sh
CHANGED
package/package.json
CHANGED
package/rules/curl-body.n3
CHANGED
|
@@ -38,17 +38,8 @@ prefix math: <http://www.w3.org/2000/10/swap/math#>
|
|
|
38
38
|
(
|
|
39
39
|
?formField
|
|
40
40
|
{
|
|
41
|
-
?multipartBody tuner:form
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
{ ?value log:rawType log:Literal }
|
|
45
|
-
{
|
|
46
|
-
( " -F " ?name "=" ?value ) string:concatenation ?formField .
|
|
47
|
-
}
|
|
48
|
-
{
|
|
49
|
-
( " -F " ?name "=" ?value!file:curlFileReference ) string:concatenation ?formField .
|
|
50
|
-
}
|
|
51
|
-
) log:ifThenElseIn [] .
|
|
41
|
+
?multipartBody tuner:form ?list .
|
|
42
|
+
?list </#field> ?formField .
|
|
52
43
|
}
|
|
53
44
|
?formFields
|
|
54
45
|
) log:collectAllIn [] .
|
|
@@ -57,3 +48,34 @@ prefix math: <http://www.w3.org/2000/10/swap/math#>
|
|
|
57
48
|
?formFields!string:concatenation
|
|
58
49
|
) string:concatenation ?curlArgs .
|
|
59
50
|
} .
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
( ?name ?value ) </#field> ?formField .
|
|
54
|
+
} <= {
|
|
55
|
+
{
|
|
56
|
+
?value log:rawType log:Literal .
|
|
57
|
+
( " -F " ?name "=" ?value ) string:concatenation ?formField .
|
|
58
|
+
} log:callWithCut true .
|
|
59
|
+
} .
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
( ?name ?value ) </#field> ?formField .
|
|
63
|
+
} <= {
|
|
64
|
+
( ?name ?value "" ) </#field> ?formField .
|
|
65
|
+
} .
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
( ?name ?value ?type ) </#field> ?formField .
|
|
69
|
+
} <= {
|
|
70
|
+
(
|
|
71
|
+
{ ?type!string:length math:greaterThan 0 }
|
|
72
|
+
{
|
|
73
|
+
( "';type=" ?type "'" ) string:concatenation ?typeParam
|
|
74
|
+
}
|
|
75
|
+
{
|
|
76
|
+
?typeParam log:equalTo "" .
|
|
77
|
+
}
|
|
78
|
+
) log:ifThenElseIn [] .
|
|
79
|
+
|
|
80
|
+
( " -F " ?name "=" ?value!file:curlFileReference ?typeParam ) string:concatenation ?formField .
|
|
81
|
+
} .
|
package/rules/files.n3
CHANGED
package/rules/requests.n3
CHANGED
|
@@ -42,37 +42,44 @@ prefix earl: <http://www.w3.org/ns/earl#>
|
|
|
42
42
|
( ?responseBodyFile ".curl.json" ) string:concatenation ?responseHeadersFile .
|
|
43
43
|
( ?responseBodyFile ".n3" ) string:concatenation ?responseFile .
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(
|
|
48
|
-
{ ?req tuner:body ?body }
|
|
49
|
-
{ ?body </#body> ( ?bodyArgs ?requestBodyFile ) }
|
|
50
|
-
{ ?bodyArgs log:equalTo "" }
|
|
51
|
-
) log:ifThenElseIn [] .
|
|
45
|
+
{
|
|
46
|
+
( "Calling " ?method " " ?endpoint )!string:concatenation^tuner:info .
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
" -o " ?responseBodyFile
|
|
59
|
-
" > " ?responseHeadersFile
|
|
60
|
-
) string:concatenation ?command .
|
|
48
|
+
(
|
|
49
|
+
{ ?req tuner:body ?body }
|
|
50
|
+
{ ?body </#body> ( ?bodyArgs ?requestBodyFile ) }
|
|
51
|
+
{ ?bodyArgs log:equalTo "" }
|
|
52
|
+
) log:ifThenElseIn [] .
|
|
61
53
|
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
(
|
|
55
|
+
"curl -s -X " ?method " '" ?endpoint "'"
|
|
56
|
+
?headersArgs
|
|
57
|
+
?bodyArgs
|
|
58
|
+
" -w @" ( "lib/curl-format.txt"!file:libPath )!string:concatenation
|
|
59
|
+
" -o " ?responseBodyFile
|
|
60
|
+
" > " ?responseHeadersFile
|
|
61
|
+
) string:concatenation ?command .
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
?command^tuner:trace .
|
|
64
|
+
{
|
|
65
|
+
?command!e:exec .
|
|
66
|
+
} log:callWithCleanup {
|
|
67
|
+
{
|
|
68
|
+
( { ?requestBodyFile log:rawType log:Literal } { ?requestBodyFile!file:rm } true ) log:ifThenElseIn [] .
|
|
69
|
+
} log:callWithCleanup true .
|
|
70
|
+
} .
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
(
|
|
73
|
+
"node " "lib/merge-curl-output.js"!file:libPath " "
|
|
74
|
+
?responseBodyFile
|
|
75
|
+
" > " ?responseFile
|
|
76
|
+
)!string:concatenation!e:exec .
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
("file://" ?responseFile)!string:concatenation^log:uri log:semantics ?res .
|
|
79
|
+
?res^tuner:trace .
|
|
80
|
+
} log:callWithCleanup {
|
|
81
|
+
{ ?responseHeadersFile!file:rm } log:callWithCleanup true .
|
|
82
|
+
{ ?responseBodyFile!file:rm } log:callWithCleanup true .
|
|
83
|
+
{ ?responseFile!file:rm } log:callWithCleanup true .
|
|
84
|
+
} .
|
|
78
85
|
} .
|