api-tuner 0.4.2 → 0.5.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/index.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import * as url from 'node:url';
2
2
  import * as childProcess from 'node:child_process';
3
- import { PassThrough } from 'node:stream';
4
- import { resolve } from 'node:path';
3
+ import { PassThrough, Readable } from 'node:stream';
4
+ import { resolve, dirname } from 'node:path';
5
5
  import { program } from 'commander';
6
6
  import getStream from 'get-stream';
7
+ import mergeStreams from '@sindresorhus/merge-streams';
8
+ import rdf from '@zazuko/env-node';
7
9
  import packageJson from './package.json' with { type: 'json' };
8
10
  import parseTestCase from './lib/parse-test-case.js';
9
11
  import summariseResults from './lib/summarise-results.js';
10
12
  const eyePvmPath = url.fileURLToPath(new URL('eye/lib/eye.pvm', import.meta.url));
13
+ const tuner = rdf.namespace('https://api-tuner.described.at/');
11
14
  program
12
15
  .name('api-tuner')
13
16
  .option('--lib <lib>', 'Specify rules to include in all tests. Can be used multiple times. Make sure to surround globs in quotes to prevent expansion.', (lib, arr) => [...arr, lib], [])
@@ -47,7 +50,6 @@ const levelIcon = {
47
50
  };
48
51
  async function processPath(path) {
49
52
  return new Promise(resolve => {
50
- const testCaseStream = parseTestCase(path, options.baseIri);
51
53
  const eyeProc = childProcess.spawn('swipl', [
52
54
  '-x',
53
55
  eyePvmPath,
@@ -59,7 +61,10 @@ async function processPath(path) {
59
61
  ], {
60
62
  shell: true,
61
63
  });
62
- testCaseStream.pipe(eyeProc.stdin);
64
+ mergeStreams([
65
+ parseTestCase(path, options.baseIri),
66
+ tunerParams({ path }),
67
+ ]).pipe(eyeProc.stdin);
63
68
  const stdout = new PassThrough();
64
69
  const stderr = new PassThrough();
65
70
  eyeProc.on('exit', (code) => {
@@ -73,6 +78,14 @@ async function processPath(path) {
73
78
  eyeProc.stderr.pipe(stderr);
74
79
  });
75
80
  }
81
+ function tunerParams({ path }) {
82
+ const rdfString = rdf.clownface()
83
+ .blankNode()
84
+ .addOut(tuner.scriptPath, dirname(resolve(path)))
85
+ .dataset
86
+ .toCanonical();
87
+ return Readable.from(rdfString);
88
+ }
76
89
  const testSuites = program.args.map(async (path) => {
77
90
  const absolutePath = resolve(process.cwd(), path);
78
91
  const result = await processPath(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-tuner",
3
- "version": "0.4.2",
3
+ "version": "0.5.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
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
- "pre_test": "docker compose up -d",
15
+ "pre_test": "docker compose up -d && docker compose restart && npx wait-on http-get://localhost:1080/ping -t 10s",
16
16
  "_test": "./bin/tuner.sh --base-iri http://localhost:1080/",
17
17
  "test": "npm run _test -- tests/*.n3 tests/**/*.n3",
18
18
  "prepack": "tsc",
@@ -30,6 +30,7 @@
30
30
  "dependencies": {
31
31
  "@changesets/cli": "^2.29.7",
32
32
  "@jeswr/pretty-turtle": "^1.5.0",
33
+ "@sindresorhus/merge-streams": "^4.0.0",
33
34
  "@zazuko/env-node": "^2.1.4",
34
35
  "commander": "^13.1.0",
35
36
  "get-stream": "^9.0.1",
@@ -37,7 +38,7 @@
37
38
  "jsonld": "^8.3.3",
38
39
  "rdf-validate-shacl": "^0.5.6",
39
40
  "replacestream": "^4.0.3",
40
- "tar": "^7.5.1"
41
+ "tar": "^7.5.2"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@rdfjs/types": "^1",
@@ -35,6 +35,9 @@ prefix math: <http://www.w3.org/2000/10/swap/math#>
35
35
  } <= {
36
36
  ?multipartBody!tuner:form!list:length math:greaterThan 0 .
37
37
 
38
+ ({ ?multipartBody tuner:done true } false true) log:ifThenElseIn ?SCOPE .
39
+ true log:becomes { ?multipartBody tuner:done true } .
40
+
38
41
  (
39
42
  ?formField
40
43
  {
package/rules/files.n3 CHANGED
@@ -1,3 +1,4 @@
1
+ PREFIX tuner: <https://api-tuner.described.at/>
1
2
  prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
2
3
  prefix string: <http://www.w3.org/2000/10/swap/string#>
3
4
  prefix log: <http://www.w3.org/2000/10/swap/log#>
@@ -49,5 +50,9 @@ prefix file: <http://www.w3.org/2000/10/swap/file#>
49
50
  ?fileUri string:startsWith "file:" .
50
51
  ( ?fileUri 6 ) string:substring ?relative .
51
52
 
52
- ( "@$(pwd)/" ?relative ) string:concatenation ?ref .
53
+ [
54
+ tuner:scriptPath ?scriptPath
55
+ ] .
56
+
57
+ ( "@'" ?scriptPath "/" ?relative "'" ) string:concatenation ?ref .
53
58
  } .