api-tuner 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-tuner",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -4,6 +4,7 @@ PREFIX string: <http://www.w3.org/2000/10/swap/string#>
4
4
  PREFIX log: <http://www.w3.org/2000/10/swap/log#>
5
5
  prefix file: <http://www.w3.org/2000/10/swap/file#>
6
6
  prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
7
+ prefix math: <http://www.w3.org/2000/10/swap/math#>
7
8
 
8
9
  {
9
10
  ?body </#body> ( ?curlArgs ?requestBodyFile ) .
@@ -32,22 +33,13 @@ prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
32
33
  {
33
34
  ?multipartBody </#body> ( ?curlArgs [] ) .
34
35
  } <= {
35
- ?multipartBody!log:rawType list:in ( log:LabeledBlankNode log:UnlabeledBlankNode ) .
36
+ ?multipartBody!tuner:form!list:length math:greaterThan 0 .
36
37
 
37
38
  (
38
39
  ?formField
39
40
  {
40
- ?multipartBody tuner:form ( ?name ?value ) .
41
-
42
- (
43
- { ?value log:rawType log:Literal }
44
- {
45
- ( " -F " ?name "=" ?value ) string:concatenation ?formField .
46
- }
47
- {
48
- ( " -F " ?name "=" ?value!file:curlFileReference ) string:concatenation ?formField .
49
- }
50
- ) log:ifThenElseIn [] .
41
+ ?multipartBody tuner:form ?list .
42
+ ?list </#field> ?formField .
51
43
  }
52
44
  ?formFields
53
45
  ) log:collectAllIn [] .
@@ -56,3 +48,34 @@ prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
56
48
  ?formFields!string:concatenation
57
49
  ) string:concatenation ?curlArgs .
58
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,41 @@ 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
+ ?command!e:exec .
70
65
 
71
- ("file://" ?responseFile)!string:concatenation^log:uri log:semantics ?res .
72
- ?res^tuner:trace .
66
+ (
67
+ "node " "lib/merge-curl-output.js"!file:libPath " "
68
+ ?responseBodyFile
69
+ " > " ?responseFile
70
+ )!string:concatenation!e:exec .
73
71
 
74
- ( { ?requestBodyFile log:rawType log:Literal } { ?requestBodyFile!file:rm } true ) log:ifThenElseIn [] .
75
- ?responseHeadersFile!file:rm .
76
- ?responseBodyFile!file:rm .
77
- ?responseFile!file:rm .
72
+ ("file://" ?responseFile)!string:concatenation^log:uri log:semantics ?res .
73
+ ?res^tuner:trace .
74
+ } log:callWithCleanup {
75
+ {
76
+ ( { ?requestBodyFile log:rawType log:Literal } { ?requestBodyFile!file:rm } true ) log:ifThenElseIn [] .
77
+ } log:callWithCleanup true .
78
+ { ?responseHeadersFile!file:rm } log:callWithCleanup true .
79
+ { ?responseBodyFile!file:rm } log:callWithCleanup true .
80
+ { ?responseFile!file:rm } log:callWithCleanup true .
81
+ } .
78
82
  } .