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 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
@@ -88,4 +88,5 @@ for path in "${PATHS[@]}"; do
88
88
  cat "$path" >> "$MERGED"
89
89
  done
90
90
 
91
+ set -o pipefail
91
92
  $eye $ARGS "${SCRIPT_PATH}"/../rules/*.n3 "${MERGED}" | $SUMMARY
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-tuner",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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 ( ?name ?value ) .
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
@@ -24,7 +24,7 @@ prefix file: <http://www.w3.org/2000/10/swap/file#>
24
24
  {
25
25
  ?path file:rm ?iDoNotCare .
26
26
  } <= {
27
- ( "rm " ?path )!string:concatenation!e:exec .
27
+ ( "rm " ?path " 2> /dev/null" )!string:concatenation!e:exec .
28
28
  } .
29
29
 
30
30
  {
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
- ( "Calling " ?method " " ?endpoint )!string:concatenation^tuner:info .
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
- "curl -s -X " ?method " '" ?endpoint "'"
55
- ?headersArgs
56
- ?bodyArgs
57
- " -w @" ( "lib/curl-format.txt"!file:libPath )!string:concatenation
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
- ?command^tuner:trace .
63
- ?command!e:exec .
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
- "node " "lib/merge-curl-output.js"!file:libPath " "
67
- ?responseBodyFile
68
- " > " ?responseFile
69
- )!string:concatenation!e:exec .
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
- ("file://" ?responseFile)!string:concatenation^log:uri log:semantics ?res .
72
- ?res^tuner:trace .
72
+ (
73
+ "node " "lib/merge-curl-output.js"!file:libPath " "
74
+ ?responseBodyFile
75
+ " > " ?responseFile
76
+ )!string:concatenation!e:exec .
73
77
 
74
- ( { ?requestBodyFile log:rawType log:Literal } { ?requestBodyFile!file:rm } true ) log:ifThenElseIn [] .
75
- ?responseHeadersFile!file:rm .
76
- ?responseBodyFile!file:rm .
77
- ?responseFile!file:rm .
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
  } .