api-tuner 0.3.3 → 0.3.4

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/bin/tuner.sh CHANGED
@@ -1,14 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- WORKING_DIR=$(pwd)
4
-
5
- SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
6
- cd "$SCRIPT_DIR" || exit
3
+ SCRIPT_DIR=$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)
7
4
 
8
5
  # find JS entrypoint
9
- tuner=$(node -e "console.log(require.resolve('api-tuner/bin/index.js'))" 2> /dev/null)
10
-
11
- cd "$WORKING_DIR" || exit
6
+ tuner="$SCRIPT_DIR/index.js"
12
7
 
13
8
  # if tsx exists in path
14
9
  if command -v tsx > /dev/null 2>&1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-tuner",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,8 +12,9 @@
12
12
  "postinstall": "([ -d eye ] || npm run download-eye) && eye/install.sh --prefix=eye",
13
13
  "prepare": "husky",
14
14
  "lint": "eslint . --quiet --ignore-path .gitignore",
15
- "pretest": "docker compose up -d",
16
- "test": "./bin/tuner.sh tests/*.n3 tests/**/*.n3 --base-iri http://localhost:1080/",
15
+ "pre_test": "docker compose up -d",
16
+ "_test": "./bin/tuner.sh --base-iri http://localhost:1080/",
17
+ "test": "npm run _test -- tests/*.n3 tests/**/*.n3",
17
18
  "prepack": "tsc",
18
19
  "release": "changeset publish"
19
20
  },
@@ -54,7 +54,7 @@ prefix math: <http://www.w3.org/2000/10/swap/math#>
54
54
  } <= {
55
55
  {
56
56
  ?value log:rawType log:Literal .
57
- ( " -F " ?name "=" ?value ) string:concatenation ?formField .
57
+ ( " -F " ?name "='" ?value "'" ) string:concatenation ?formField .
58
58
  } log:callWithCut true .
59
59
  } .
60
60
 
@@ -0,0 +1,8 @@
1
+ prefix tuner: <https://api-tuner.described.at/>
2
+ prefix string: <http://www.w3.org/2000/10/swap/string#>
3
+
4
+ {
5
+ (?fieldName ?fieldValue) tuner:headerArg ?curlArg .
6
+ } <= {
7
+ ( " -H '" ?fieldName ":" ?fieldValue "'" ) string:concatenation ?curlArg .
8
+ } .
@@ -0,0 +1,8 @@
1
+ prefix tuner: <https://api-tuner.described.at/>
2
+ prefix string: <http://www.w3.org/2000/10/swap/string#>
3
+
4
+ {
5
+ (?name ?value) tuner:queryParamArg ?curlArg .
6
+ } <= {
7
+ ( " --url-query '" ?name "=" ?value "'" ) string:concatenation ?curlArg .
8
+ } .
package/rules/requests.n3 CHANGED
@@ -6,11 +6,7 @@ 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
- (?fieldName ?fieldValue) tuner:headerArg ?curlArg .
11
- } <= {
12
- ( " -H '" ?fieldName ":" ?fieldValue "'" ) string:concatenation ?curlArg .
13
- } .
9
+
14
10
 
15
11
  {
16
12
  ?req tuner:response ?res .
@@ -34,6 +30,15 @@ prefix earl: <http://www.w3.org/ns/earl#>
34
30
  { ?headersArgs log:equalTo "" }
35
31
  ) log:ifThenElseIn [] .
36
32
 
33
+ (
34
+ { ?req tuner:query [] . }
35
+ {
36
+ ( ?queryParam { ?req tuner:query ?queryParam } ?queryParams ) log:collectAllIn [] .
37
+ ( ?queryParams tuner:queryParamArg )!list:map string:concatenation ?queryParamArgs .
38
+ }
39
+ { ?queryParamArgs log:equalTo "" }
40
+ ) log:ifThenElseIn [] .
41
+
37
42
  ?endpointUri log:uri ?endpoint .
38
43
 
39
44
  ( ?method " " ?endpoint )!string:concatenation^tuner:trace .
@@ -55,6 +60,7 @@ prefix earl: <http://www.w3.org/ns/earl#>
55
60
  "curl -s -X " ?method " '" ?endpoint "'"
56
61
  ?headersArgs
57
62
  ?bodyArgs
63
+ ?queryParamArgs
58
64
  " -w @" ( "lib/curl-format.txt"!file:libPath )!string:concatenation
59
65
  " -o " ?responseBodyFile
60
66
  " > " ?responseHeadersFile