rdf-test-suite 2.1.5 → 2.2.0
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 +3 -3
- package/bin/Runner.js +18 -15
- package/index.d.ts +32 -31
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/lib/DocumentLoaderCached.d.ts +2 -2
- package/lib/DocumentLoaderCached.js +1 -0
- package/lib/DocumentLoaderCached.js.map +1 -1
- package/lib/ErrorSkipped.js.map +1 -1
- package/lib/ErrorTest.js.map +1 -1
- package/lib/GeneralizedN3StreamParser.d.ts +1 -1
- package/lib/GeneralizedN3StreamParser.js +14 -7
- package/lib/GeneralizedN3StreamParser.js.map +1 -1
- package/lib/IManifest.d.ts +7 -13
- package/lib/IManifest.js +18 -18
- package/lib/IManifest.js.map +1 -1
- package/lib/ManifestLoader.d.ts +9 -12
- package/lib/ManifestLoader.js +19 -7
- package/lib/ManifestLoader.js.map +1 -1
- package/lib/TestSuiteRunner.d.ts +5 -9
- package/lib/TestSuiteRunner.js +67 -71
- package/lib/TestSuiteRunner.js.map +1 -1
- package/lib/Util.d.ts +11 -17
- package/lib/Util.js +86 -78
- package/lib/Util.js.map +1 -1
- package/lib/prefixes.json +4 -4
- package/lib/testcase/ITestCase.d.ts +7 -8
- package/lib/testcase/ITestCase.js +10 -8
- package/lib/testcase/ITestCase.js.map +1 -1
- package/lib/testcase/ITestCaseHandler.d.ts +3 -3
- package/lib/testcase/ITestCaseHandler.js.map +1 -1
- package/lib/testcase/TestCaseHandlers.js +4 -7
- package/lib/testcase/TestCaseHandlers.js.map +1 -1
- package/lib/testcase/TestCaseMediaTypes.js +24 -24
- package/lib/testcase/TestCaseMediaTypes.js.map +1 -1
- package/lib/testcase/TestCaseUnsupported.d.ts +4 -4
- package/lib/testcase/TestCaseUnsupported.js +2 -2
- package/lib/testcase/TestCaseUnsupported.js.map +1 -1
- package/lib/testcase/rdfsyntax/IParser.d.ts +3 -5
- package/lib/testcase/rdfsyntax/IParser.js.map +1 -1
- package/lib/testcase/rdfsyntax/ISerializer.d.ts +2 -4
- package/lib/testcase/rdfsyntax/ISerializer.js.map +1 -1
- package/lib/testcase/rdfsyntax/ITestCaseFromRdfSyntax.d.ts +2 -2
- package/lib/testcase/rdfsyntax/ITestCaseFromRdfSyntax.js.map +1 -1
- package/lib/testcase/rdfsyntax/ITestCaseRdfSyntax.d.ts +2 -2
- package/lib/testcase/rdfsyntax/ITestCaseRdfSyntax.js.map +1 -1
- package/lib/testcase/rdfsyntax/TestCaseEval.d.ts +8 -8
- package/lib/testcase/rdfsyntax/TestCaseEval.js +4 -4
- package/lib/testcase/rdfsyntax/TestCaseEval.js.map +1 -1
- package/lib/testcase/rdfsyntax/TestCaseSyntax.d.ts +7 -7
- package/lib/testcase/rdfsyntax/TestCaseSyntax.js +3 -3
- package/lib/testcase/rdfsyntax/TestCaseSyntax.js.map +1 -1
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdf.d.ts +7 -7
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdf.js +8 -7
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdf.js.map +1 -1
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdfNegative.d.ts +8 -8
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdfNegative.js +5 -6
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdfNegative.js.map +1 -1
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdSyntax.d.ts +5 -4
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdSyntax.js.map +1 -1
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdf.d.ts +5 -4
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdf.js +6 -3
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdf.js.map +1 -1
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdfNegative.d.ts +5 -5
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdfNegative.js +2 -3
- package/lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdfNegative.js.map +1 -1
- package/lib/testcase/sparql/IQueryEngine.d.ts +11 -16
- package/lib/testcase/sparql/IQueryEngine.js.map +1 -1
- package/lib/testcase/sparql/ITestCaseSparql.d.ts +2 -2
- package/lib/testcase/sparql/ITestCaseSparql.js.map +1 -1
- package/lib/testcase/sparql/IUpdateEngine.d.ts +3 -5
- package/lib/testcase/sparql/IUpdateEngine.js.map +1 -1
- package/lib/testcase/sparql/QueryResultBindings.d.ts +8 -28
- package/lib/testcase/sparql/QueryResultBindings.js +10 -11
- package/lib/testcase/sparql/QueryResultBindings.js.map +1 -1
- package/lib/testcase/sparql/QueryResultBoolean.d.ts +1 -1
- package/lib/testcase/sparql/QueryResultBoolean.js.map +1 -1
- package/lib/testcase/sparql/QueryResultQuads.d.ts +2 -2
- package/lib/testcase/sparql/QueryResultQuads.js.map +1 -1
- package/lib/testcase/sparql/TestCaseCsvResultFormat.d.ts +45 -0
- package/lib/testcase/sparql/TestCaseCsvResultFormat.js +163 -0
- package/lib/testcase/sparql/TestCaseCsvResultFormat.js.map +1 -0
- package/lib/testcase/sparql/TestCaseNegativeSyntax.d.ts +6 -6
- package/lib/testcase/sparql/TestCaseNegativeSyntax.js +3 -3
- package/lib/testcase/sparql/TestCaseNegativeSyntax.js.map +1 -1
- package/lib/testcase/sparql/TestCasePositiveSyntax.d.ts +6 -6
- package/lib/testcase/sparql/TestCasePositiveSyntax.js +2 -3
- package/lib/testcase/sparql/TestCasePositiveSyntax.js.map +1 -1
- package/lib/testcase/sparql/TestCaseQueryEvaluation.d.ts +19 -7
- package/lib/testcase/sparql/TestCaseQueryEvaluation.js +109 -34
- package/lib/testcase/sparql/TestCaseQueryEvaluation.js.map +1 -1
- package/lib/testcase/sparql/TestCaseUpdateEvaluation.d.ts +8 -8
- package/lib/testcase/sparql/TestCaseUpdateEvaluation.js +6 -6
- package/lib/testcase/sparql/TestCaseUpdateEvaluation.js.map +1 -1
- package/package.json +40 -37
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ This properties file can look something like this:
|
|
|
167
167
|
"licenseUri": "http://opensource.org/licenses/MIT",
|
|
168
168
|
"reportUri": null,
|
|
169
169
|
"specificationUris": [
|
|
170
|
-
|
|
170
|
+
"http://www.w3.org/TR/sparql11-query/"
|
|
171
171
|
],
|
|
172
172
|
"version": "1.2.3"
|
|
173
173
|
}
|
|
@@ -297,8 +297,8 @@ $ rdf-test-suite myengine.js https://w3c.github.io/rdf-tests/sparql/sparql11/man
|
|
|
297
297
|
| [SPARQL 1.0 tests](https://w3c.github.io/rdf-tests/sparql/sparql10/) | [SPARQL 1.0](https://www.w3.org/TR/rdf-sparql-query/) | [`IQueryEngine`](https://github.com/rubensworks/rdf-test-suite.js/blob/master/lib/testcase/sparql/IQueryEngine.ts) | https://w3c.github.io/rdf-tests/sparql/sparql10/manifest.ttl |
|
|
298
298
|
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Query](http://www.w3.org/TR/sparql11-query/) | [`IQueryEngine`](https://github.com/rubensworks/rdf-test-suite.js/blob/master/lib/testcase/sparql/IQueryEngine.ts) | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
|
299
299
|
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Update](http://www.w3.org/TR/sparql11-update/) | [`IUpdateEngine`](https://github.com/rubensworks/rdf-test-suite.js/blob/master/lib/testcase/sparql/IUpdateEngine.ts) | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
|
300
|
-
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Results CSV/TSV](http://www.w3.org/TR/sparql11-results-csv-tsv/) |
|
|
301
|
-
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Results JSON](http://www.w3.org/TR/sparql11-results-json/) |
|
|
300
|
+
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Results CSV/TSV](http://www.w3.org/TR/sparql11-results-csv-tsv/) | [`IQueryEngine`](https://github.com/rubensworks/rdf-test-suite.js/blob/master/lib/testcase/sparql/IQueryEngine.ts) | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
|
301
|
+
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Results JSON](http://www.w3.org/TR/sparql11-results-json/) | [`IQueryEngine`](https://github.com/rubensworks/rdf-test-suite.js/blob/master/lib/testcase/sparql/IQueryEngine.ts) | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
|
302
302
|
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Federated Query](http://www.w3.org/TR/sparql11-federated-query/) | ✖ | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
|
303
303
|
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Entailment](http://www.w3.org/TR/sparql11-entailment/) | ✖ | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
|
304
304
|
| [SPARQL 1.1 tests](https://w3c.github.io/rdf-tests/sparql/sparql11/) | [SPARQL 1.1 Service Description](http://www.w3.org/TR/sparql11-service-description/) | ✖ | http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl |
|
package/bin/Runner.js
CHANGED
|
@@ -34,13 +34,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
const
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const Path = __importStar(require("node:path"));
|
|
39
|
+
// eslint-disable-next-line ts/no-require-imports
|
|
38
40
|
const minimist = require("minimist");
|
|
39
41
|
const n3_1 = require("n3");
|
|
40
|
-
const Path = __importStar(require("path"));
|
|
41
42
|
const TestSuiteRunner_1 = require("../lib/TestSuiteRunner");
|
|
42
|
-
// tslint:disable:no-console
|
|
43
|
-
// tslint:disable:no-var-requires
|
|
44
43
|
const args = minimist(process.argv.slice(2));
|
|
45
44
|
if (args._.length < 2) {
|
|
46
45
|
console.error(`sparql-test executes SPARQL test suites
|
|
@@ -72,12 +71,13 @@ Options:
|
|
|
72
71
|
let cachePath = null;
|
|
73
72
|
if (args.c) {
|
|
74
73
|
cachePath = Path.join(process.cwd(), (args.c === true ? '.rdf-test-suite-cache/' : args.c));
|
|
75
|
-
if (!(0,
|
|
76
|
-
(0,
|
|
74
|
+
if (!(0, node_fs_1.existsSync)(cachePath)) {
|
|
75
|
+
(0, node_fs_1.mkdirSync)(cachePath);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
// Import the engine
|
|
80
|
-
|
|
79
|
+
// eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
|
|
80
|
+
const engine = require(`${process.cwd()}/${args._[0]}`);
|
|
81
81
|
const defaultConfig = {
|
|
82
82
|
exitWithStatusCode0: false,
|
|
83
83
|
outputFormat: 'detailed',
|
|
@@ -86,15 +86,15 @@ const defaultConfig = {
|
|
|
86
86
|
const config = {
|
|
87
87
|
cachePath,
|
|
88
88
|
customEngingeOptions: args.i ? JSON.parse(args.i) : {},
|
|
89
|
-
exitWithStatusCode0:
|
|
89
|
+
exitWithStatusCode0: Boolean(args.e) || defaultConfig.exitWithStatusCode0,
|
|
90
90
|
outputFormat: args.o || defaultConfig.outputFormat,
|
|
91
91
|
specification: args.s,
|
|
92
|
-
testRegex: new RegExp(args.t),
|
|
93
|
-
skipRegex: args.skip ? new RegExp(args.skip) : undefined,
|
|
92
|
+
testRegex: new RegExp(args.t, 'u'),
|
|
93
|
+
skipRegex: args.skip ? new RegExp(args.skip, 'u') : undefined,
|
|
94
94
|
timeOutDuration: args.d || defaultConfig.timeOutDuration,
|
|
95
95
|
urlToFileMapping: args.m,
|
|
96
|
-
runRejected:
|
|
97
|
-
explicitApproval:
|
|
96
|
+
runRejected: Boolean(args.r),
|
|
97
|
+
explicitApproval: Boolean(args.a),
|
|
98
98
|
};
|
|
99
99
|
// Fetch the manifest, run the tests, and print them
|
|
100
100
|
const testSuiteRunner = new TestSuiteRunner_1.TestSuiteRunner();
|
|
@@ -106,10 +106,13 @@ testSuiteRunner.runManifest(args._[1], engine, config)
|
|
|
106
106
|
throw new Error(`EARL reporting requires the -p argument to point to an earl-meta.json file.`);
|
|
107
107
|
}
|
|
108
108
|
// Create properties file if it does not exist
|
|
109
|
-
if (!(0,
|
|
110
|
-
|
|
109
|
+
if (!(0, node_fs_1.existsSync)(Path.join(process.cwd(), args.p))) {
|
|
110
|
+
// eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
|
|
111
|
+
(0, node_fs_1.writeFileSync)(Path.join(process.cwd(), args.p), JSON.stringify(testSuiteRunner.packageJsonToEarlProperties(require(Path.join(process.cwd(), 'package.json'))), null, ' '));
|
|
111
112
|
}
|
|
113
|
+
// eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
|
|
112
114
|
testSuiteRunner.resultsToEarl(testResults, require(Path.join(process.cwd(), args.p)), new Date())
|
|
115
|
+
// eslint-disable-next-line ts/no-require-imports
|
|
113
116
|
.pipe(new n3_1.StreamWriter({ format: 'text/turtle', prefixes: require('../lib/prefixes.json') }))
|
|
114
117
|
.pipe(process.stdout)
|
|
115
118
|
.on('end', () => onEnd(testResults));
|
|
@@ -123,7 +126,7 @@ testSuiteRunner.runManifest(args._[1], engine, config)
|
|
|
123
126
|
onEnd(testResults);
|
|
124
127
|
break;
|
|
125
128
|
}
|
|
126
|
-
}).catch(e => {
|
|
129
|
+
}).catch((e) => {
|
|
127
130
|
console.error(e);
|
|
128
131
|
process.exit(1);
|
|
129
132
|
});
|
package/index.d.ts
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
1
|
+
export * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdf';
|
|
2
|
+
export * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdSyntax';
|
|
3
|
+
export * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdf';
|
|
4
|
+
export * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdfNegative';
|
|
5
|
+
export * from './lib/testcase/rdfsyntax/TestCaseEval';
|
|
6
|
+
export * from './lib/testcase/rdfsyntax/TestCaseSyntax';
|
|
7
|
+
export * from './lib/testcase/rdfsyntax/IParser';
|
|
8
|
+
export * from './lib/testcase/rdfsyntax/ISerializer';
|
|
9
|
+
export * from './lib/testcase/rdfsyntax/ITestCaseFromRdfSyntax';
|
|
10
|
+
export * from './lib/testcase/rdfsyntax/ITestCaseRdfSyntax';
|
|
11
|
+
export * from './lib/testcase/sparql/IQueryEngine';
|
|
12
|
+
export * from './lib/testcase/sparql/ITestCaseSparql';
|
|
13
|
+
export * from './lib/testcase/sparql/IUpdateEngine';
|
|
14
|
+
export * from './lib/testcase/sparql/QueryResultBindings';
|
|
15
|
+
export * from './lib/testcase/sparql/QueryResultBoolean';
|
|
16
|
+
export * from './lib/testcase/sparql/QueryResultQuads';
|
|
17
|
+
export * from './lib/testcase/sparql/TestCaseCsvResultFormat';
|
|
18
|
+
export * from './lib/testcase/sparql/TestCaseNegativeSyntax';
|
|
19
|
+
export * from './lib/testcase/sparql/TestCasePositiveSyntax';
|
|
20
|
+
export * from './lib/testcase/sparql/TestCaseQueryEvaluation';
|
|
21
|
+
export * from './lib/testcase/sparql/TestCaseUpdateEvaluation';
|
|
22
|
+
export * from './lib/testcase/ITestCase';
|
|
23
|
+
export * from './lib/testcase/ITestCaseHandler';
|
|
24
|
+
export * from './lib/testcase/TestCaseUnsupported';
|
|
25
|
+
export * from './lib/IManifest';
|
|
26
|
+
export * from './lib/ManifestLoader';
|
|
27
|
+
export * from './lib/TestSuiteRunner';
|
|
28
|
+
export * from './lib/Util';
|
|
29
|
+
export * from './lib/ErrorSkipped';
|
|
30
|
+
export * from './lib/ErrorTest';
|
|
31
|
+
export * from './lib/DocumentLoaderCached';
|
|
32
|
+
export * from './lib/testcase/TestCaseMediaTypes';
|
package/index.js
CHANGED
|
@@ -30,6 +30,7 @@ __exportStar(require("./lib/testcase/sparql/IUpdateEngine"), exports);
|
|
|
30
30
|
__exportStar(require("./lib/testcase/sparql/QueryResultBindings"), exports);
|
|
31
31
|
__exportStar(require("./lib/testcase/sparql/QueryResultBoolean"), exports);
|
|
32
32
|
__exportStar(require("./lib/testcase/sparql/QueryResultQuads"), exports);
|
|
33
|
+
__exportStar(require("./lib/testcase/sparql/TestCaseCsvResultFormat"), exports);
|
|
33
34
|
__exportStar(require("./lib/testcase/sparql/TestCaseNegativeSyntax"), exports);
|
|
34
35
|
__exportStar(require("./lib/testcase/sparql/TestCasePositiveSyntax"), exports);
|
|
35
36
|
__exportStar(require("./lib/testcase/sparql/TestCaseQueryEvaluation"), exports);
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wFAAsE;AACtE,uFAAqE;AACrE,sFAAoE;AACpE,8FAA4E;AAC5E,wEAAsD;AACtD,0EAAwD;AACxD,mEAAiD;AACjD,uEAAqD;AACrD,kFAAgE;AAChE,8EAA4D;AAC5D,qEAAmD;AACnD,wEAAsD;AACtD,sEAAoD;AACpD,4EAA0D;AAC1D,2EAAyD;AACzD,yEAAuD;AACvD,+EAA6D;AAC7D,+EAA6D;AAC7D,gFAA8D;AAC9D,iFAA+D;AAC/D,2DAAyC;AACzC,kEAAgD;AAChD,qEAAmD;AACnD,kDAAgC;AAChC,uDAAqC;AACrC,wDAAsC;AACtC,6CAA2B;AAC3B,qDAAmC;AACnC,kDAAgC;AAChC,6DAA2C;AAC3C,oEAAkD","sourcesContent":["export * from
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wFAAsE;AACtE,uFAAqE;AACrE,sFAAoE;AACpE,8FAA4E;AAC5E,wEAAsD;AACtD,0EAAwD;AACxD,mEAAiD;AACjD,uEAAqD;AACrD,kFAAgE;AAChE,8EAA4D;AAC5D,qEAAmD;AACnD,wEAAsD;AACtD,sEAAoD;AACpD,4EAA0D;AAC1D,2EAAyD;AACzD,yEAAuD;AACvD,gFAA8D;AAC9D,+EAA6D;AAC7D,+EAA6D;AAC7D,gFAA8D;AAC9D,iFAA+D;AAC/D,2DAAyC;AACzC,kEAAgD;AAChD,qEAAmD;AACnD,kDAAgC;AAChC,uDAAqC;AACrC,wDAAsC;AACtC,6CAA2B;AAC3B,qDAAmC;AACnC,kDAAgC;AAChC,6DAA2C;AAC3C,oEAAkD","sourcesContent":["export * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdFromRdf';\nexport * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdSyntax';\nexport * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdf';\nexport * from './lib/testcase/rdfsyntax/jsonld/TestCaseJsonLdToRdfNegative';\nexport * from './lib/testcase/rdfsyntax/TestCaseEval';\nexport * from './lib/testcase/rdfsyntax/TestCaseSyntax';\nexport * from './lib/testcase/rdfsyntax/IParser';\nexport * from './lib/testcase/rdfsyntax/ISerializer';\nexport * from './lib/testcase/rdfsyntax/ITestCaseFromRdfSyntax';\nexport * from './lib/testcase/rdfsyntax/ITestCaseRdfSyntax';\nexport * from './lib/testcase/sparql/IQueryEngine';\nexport * from './lib/testcase/sparql/ITestCaseSparql';\nexport * from './lib/testcase/sparql/IUpdateEngine';\nexport * from './lib/testcase/sparql/QueryResultBindings';\nexport * from './lib/testcase/sparql/QueryResultBoolean';\nexport * from './lib/testcase/sparql/QueryResultQuads';\nexport * from './lib/testcase/sparql/TestCaseCsvResultFormat';\nexport * from './lib/testcase/sparql/TestCaseNegativeSyntax';\nexport * from './lib/testcase/sparql/TestCasePositiveSyntax';\nexport * from './lib/testcase/sparql/TestCaseQueryEvaluation';\nexport * from './lib/testcase/sparql/TestCaseUpdateEvaluation';\nexport * from './lib/testcase/ITestCase';\nexport * from './lib/testcase/ITestCaseHandler';\nexport * from './lib/testcase/TestCaseUnsupported';\nexport * from './lib/IManifest';\nexport * from './lib/ManifestLoader';\nexport * from './lib/TestSuiteRunner';\nexport * from './lib/Util';\nexport * from './lib/ErrorSkipped';\nexport * from './lib/ErrorTest';\nexport * from './lib/DocumentLoaderCached';\nexport * from './lib/testcase/TestCaseMediaTypes';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDocumentLoader, IJsonLdContext } from
|
|
2
|
-
import { IFetchOptions } from
|
|
1
|
+
import type { IDocumentLoader, IJsonLdContext } from 'jsonld-context-parser';
|
|
2
|
+
import type { IFetchOptions } from './Util';
|
|
3
3
|
/**
|
|
4
4
|
* A JSON-LD context document loader that is based on {@link Util#fetchCached}.
|
|
5
5
|
*/
|
|
@@ -21,6 +21,7 @@ class DocumentLoaderCached {
|
|
|
21
21
|
load(url) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const { body } = yield Util_1.Util.fetchCached(url, this.options, { headers: { accept: 'application/ld+json' } });
|
|
24
|
+
// eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
|
|
24
25
|
return JSON.parse(yield require('stream-to-string')(body));
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentLoaderCached.js","sourceRoot":"","sources":["DocumentLoaderCached.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DocumentLoaderCached.js","sourceRoot":"","sources":["DocumentLoaderCached.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,iCAA8B;AAE9B;;GAEG;AACH,MAAa,oBAAoB;IAG/B,YAAmB,OAAsB;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEY,IAAI,CAAC,GAAW;;YAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAI,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,EAAC,CAAC,CAAC;YAC1G,qEAAqE;YACrE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAO,OAAO,CAAC,kBAAkB,CAAmD,CAAC,IAAI,CAAC,CAAmB,CAAC;QAClI,CAAC;KAAA;CACF;AAZD,oDAYC","sourcesContent":["import type { IDocumentLoader, IJsonLdContext } from 'jsonld-context-parser';\nimport type { IFetchOptions } from './Util';\nimport { Util } from './Util';\n\n/**\n * A JSON-LD context document loader that is based on {@link Util#fetchCached}.\n */\nexport class DocumentLoaderCached implements IDocumentLoader {\n private readonly options: IFetchOptions;\n\n public constructor(options: IFetchOptions) {\n this.options = options;\n }\n\n public async load(url: string): Promise<IJsonLdContext> {\n const { body } = await Util.fetchCached(url, this.options, { headers: { accept: 'application/ld+json' }});\n // eslint-disable-next-line ts/no-require-imports, ts/no-var-requires\n return JSON.parse(await (require('stream-to-string') as (s: NodeJS.ReadableStream) => Promise<string>)(body)) as IJsonLdContext;\n }\n}\n"]}
|
package/lib/ErrorSkipped.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSkipped.js","sourceRoot":"","sources":["ErrorSkipped.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"ErrorSkipped.js","sourceRoot":"","sources":["ErrorSkipped.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;IAGrC,YAAmB,OAAgB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;CACF;AAPD,oCAOC","sourcesContent":["/**\n * An error to indicate if a test should be skipped.\n */\nexport class ErrorSkipped extends Error {\n public readonly skipped: boolean;\n\n public constructor(message?: string) {\n super(message);\n this.skipped = true;\n }\n}\n"]}
|
package/lib/ErrorTest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorTest.js","sourceRoot":"","sources":["ErrorTest.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"ErrorTest.js","sourceRoot":"","sources":["ErrorTest.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAK;IAGlC,YAAmB,OAAgB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAPD,8BAOC","sourcesContent":["/**\n * Error to indicate that this is a test failure.\n */\nexport class ErrorTest extends Error {\n public readonly test: boolean;\n\n public constructor(message?: string) {\n super(message);\n this.test = true;\n }\n}\n"]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GeneralizedN3StreamParser = void 0;
|
|
4
|
+
const node_stream_1 = require("node:stream");
|
|
4
5
|
const n3_1 = require("n3");
|
|
5
|
-
const stream_1 = require("stream");
|
|
6
6
|
// Temporarily set format to text/n3 to allow blank node predicates (needed by JSON-LD tests)
|
|
7
7
|
const readPredicateOld = n3_1.Parser.prototype._readPredicate;
|
|
8
|
-
// tslint:disable-next-line:only-arrow-functions
|
|
9
8
|
n3_1.Parser.prototype._readPredicate = function (token) {
|
|
10
9
|
if (this.allowBlankNodePredicates) {
|
|
11
10
|
this._n3Mode = true;
|
|
@@ -18,7 +17,7 @@ n3_1.Parser.prototype._readPredicate = function (token) {
|
|
|
18
17
|
}
|
|
19
18
|
return ret;
|
|
20
19
|
};
|
|
21
|
-
class GeneralizedN3StreamParser extends
|
|
20
|
+
class GeneralizedN3StreamParser extends node_stream_1.Transform {
|
|
22
21
|
constructor(options) {
|
|
23
22
|
super({ decodeStrings: true });
|
|
24
23
|
this._readableState.objectMode = true;
|
|
@@ -44,12 +43,20 @@ class GeneralizedN3StreamParser extends stream_1.Transform {
|
|
|
44
43
|
},
|
|
45
44
|
},
|
|
46
45
|
// Handle quads by pushing them down the pipeline
|
|
47
|
-
(error, quad) => error && this.emit('error', error) || quad && this.push(quad),
|
|
46
|
+
(error, quad) => (error && this.emit('error', error)) || (quad && this.push(quad)),
|
|
48
47
|
// Emit prefixes through the `prefix` event
|
|
49
|
-
(prefix, uri) => {
|
|
48
|
+
(prefix, uri) => {
|
|
49
|
+
this.emit('prefix', prefix, uri);
|
|
50
|
+
});
|
|
50
51
|
// Implement Transform methods through parser callbacks
|
|
51
|
-
this._transform = (chunk, encoding, done) => {
|
|
52
|
-
|
|
52
|
+
this._transform = (chunk, encoding, done) => {
|
|
53
|
+
onData(chunk);
|
|
54
|
+
done();
|
|
55
|
+
};
|
|
56
|
+
this._flush = (done) => {
|
|
57
|
+
onEnd();
|
|
58
|
+
done();
|
|
59
|
+
};
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
exports.GeneralizedN3StreamParser = GeneralizedN3StreamParser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneralizedN3StreamParser.js","sourceRoot":"","sources":["GeneralizedN3StreamParser.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"GeneralizedN3StreamParser.js","sourceRoot":"","sources":["GeneralizedN3StreamParser.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,2BAA4B;AAE5B,6FAA6F;AAC7F,MAAM,gBAAgB,GAAU,WAAM,CAAC,SAAU,CAAC,cAAc,CAAC;AAC1D,WAAM,CAAC,SAAU,CAAC,cAAc,GAAG,UAAS,KAAU;IAC3D,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IACD,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/C,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAa,yBAA0B,SAAQ,uBAAS;IACtD,YAAY,OAAY;QACtB,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAExB,IAAK,CAAC,cAAc,CAAC,UAAU,GAA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} from 'node:stream';\nimport { Parser } from 'n3';\n\n// Temporarily set format to text/n3 to allow blank node predicates (needed by JSON-LD tests)\nconst readPredicateOld = (<any> Parser.prototype)._readPredicate;\n(<any> Parser.prototype)._readPredicate = function(token: any) {\n if (this.allowBlankNodePredicates) {\n this._n3Mode = true;\n this._quantified = {};\n }\n const ret = readPredicateOld.call(this, token);\n if (this.allowBlankNodePredicates) {\n this._n3Mode = false;\n delete this._quantified;\n }\n return ret;\n};\n\nexport class GeneralizedN3StreamParser extends Transform {\n constructor(options: any) {\n super({ decodeStrings: true });\n\n (<any> this)._readableState.objectMode = true;\n\n // Set up parser\n const parser: any = new Parser(options);\n parser.allowBlankNodePredicates = true;\n // This is a workaround to resolve the RDF* syntax issue seen in\n // https://github.com/rubensworks/rdf-test-suite.js/pull/78#issue-1307275029\n parser._supportsRDFStar = true;\n\n let onData: any;\n let onEnd: any;\n // Pass dummy stream to obtain `data` and `end` callbacks\n parser.parse(\n {\n on: (event: any, callback: any) => {\n switch (event) {\n case 'data':\n onData = callback;\n break;\n case 'end':\n onEnd = callback;\n break;\n }\n },\n },\n // Handle quads by pushing them down the pipeline\n (error: any, quad: any) => (error && this.emit('error', error)) || (quad && this.push(quad)),\n // Emit prefixes through the `prefix` event\n (prefix: any, uri: any) => {\n this.emit('prefix', prefix, uri);\n },\n );\n\n // Implement Transform methods through parser callbacks\n this._transform = (chunk, encoding, done) => {\n onData(chunk);\n done();\n };\n this._flush = (done) => {\n onEnd();\n done();\n };\n }\n}\n"]}
|
package/lib/IManifest.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RdfObjectLoader, Resource } from
|
|
2
|
-
import { ITestCase } from
|
|
3
|
-
import { ITestCaseHandler } from
|
|
4
|
-
import { IFetchOptions } from
|
|
1
|
+
import type { RdfObjectLoader, Resource } from 'rdf-object';
|
|
2
|
+
import type { ITestCase } from './testcase/ITestCase';
|
|
3
|
+
import type { ITestCaseHandler } from './testcase/ITestCaseHandler';
|
|
4
|
+
import type { IFetchOptions } from './Util';
|
|
5
5
|
/**
|
|
6
6
|
* A manifest data holder.
|
|
7
7
|
*/
|
|
@@ -11,9 +11,7 @@ export interface IManifest {
|
|
|
11
11
|
comment?: string;
|
|
12
12
|
subManifests?: IManifest[];
|
|
13
13
|
testEntries?: ITestCase<any>[];
|
|
14
|
-
specifications?:
|
|
15
|
-
[uri: string]: IManifest;
|
|
16
|
-
};
|
|
14
|
+
specifications?: Record<string, IManifest>;
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* Create a manifest object from a resource.
|
|
@@ -22,9 +20,7 @@ export interface IManifest {
|
|
|
22
20
|
* @param {Resource} resource A resource.
|
|
23
21
|
* @return {Promise<IManifest>} A promise resolving to a manifest object.
|
|
24
22
|
*/
|
|
25
|
-
export declare function manifestFromResource(testCaseHandlers:
|
|
26
|
-
[uri: string]: ITestCaseHandler<ITestCase<any>>;
|
|
27
|
-
}, options: IFetchOptions, resource: Resource, objectLoader: RdfObjectLoader): Promise<IManifest>;
|
|
23
|
+
export declare function manifestFromResource(testCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>>, options: IFetchOptions, resource: Resource, objectLoader: RdfObjectLoader): Promise<IManifest>;
|
|
28
24
|
/**
|
|
29
25
|
* Create a manifest object from a specification resource.
|
|
30
26
|
* @param {{[uri: string]: ITestCaseHandler<ITestCase<any>>}} testCaseHandlers Handlers for constructing test cases.
|
|
@@ -32,6 +28,4 @@ export declare function manifestFromResource(testCaseHandlers: {
|
|
|
32
28
|
* @param {Resource} resource A resource.
|
|
33
29
|
* @return {Promise<IManifest>} A promise resolving to a manifest object.
|
|
34
30
|
*/
|
|
35
|
-
export declare function manifestFromSpecificationResource(testCaseHandlers:
|
|
36
|
-
[uri: string]: ITestCaseHandler<ITestCase<any>>;
|
|
37
|
-
}, options: IFetchOptions, resource: Resource, objectLoader: RdfObjectLoader): Promise<IManifest>;
|
|
31
|
+
export declare function manifestFromSpecificationResource(testCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>>, options: IFetchOptions, resource: Resource, objectLoader: RdfObjectLoader): Promise<IManifest>;
|
package/lib/IManifest.js
CHANGED
|
@@ -26,23 +26,25 @@ function manifestFromResource(testCaseHandlers, options, resource, objectLoader)
|
|
|
26
26
|
return {
|
|
27
27
|
comment: resource.property.comment ? resource.property.comment.value : null,
|
|
28
28
|
label: resource.property.label ? resource.property.label.value : null,
|
|
29
|
-
specifications: resource.property.specifications ?
|
|
30
|
-
.
|
|
31
|
-
|
|
29
|
+
specifications: resource.property.specifications ?
|
|
30
|
+
yield Util_1.Util.promiseValues(Object.assign.apply({}, yield Promise.all(resource.property.specifications.list
|
|
31
|
+
.map((specificationResource) => ({ [specificationResource.term.value]: manifestFromSpecificationResource(testCaseHandlers, options, specificationResource, objectLoader) }))))) :
|
|
32
|
+
null,
|
|
33
|
+
subManifests: yield Promise.all(
|
|
32
34
|
// This is here because of the way the rdf-star test suite is published
|
|
33
35
|
// @see https://github.com/rubensworks/rdf-test-suite.js/pull/78/files#r1026326410
|
|
34
|
-
((resource.properties.include.length > 0 || !objectLoader)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.properties.include.
|
|
38
|
-
testEntries: (yield Promise.all(
|
|
36
|
+
((resource.properties.include.length > 0 || !objectLoader) ?
|
|
37
|
+
resource :
|
|
38
|
+
((_b = (_a = objectLoader.resources) === null || _a === void 0 ? void 0 : _a[resource.value.slice(0, resource.value.lastIndexOf('.')).replace(/\/manifest$/u, '#manifest')]) !== null && _b !== void 0 ? _b : resource))
|
|
39
|
+
.properties.include.flatMap((includeList) => includeList.list.map(res => manifestFromResource(testCaseHandlers, options, res, objectLoader)))),
|
|
40
|
+
testEntries: (yield Promise.all(
|
|
39
41
|
// This is here because of the way the rdf-star test suite is published
|
|
40
42
|
// @see https://github.com/rubensworks/rdf-test-suite.js/pull/78/files#r1026326410
|
|
41
43
|
((resource.properties.entries.length > 0 || !objectLoader) ?
|
|
42
44
|
resource :
|
|
43
|
-
((_d = (_c = objectLoader.resources) === null || _c === void 0 ? void 0 : _c[resource.value.slice(0, resource.value.lastIndexOf('.')).replace(/\/manifest
|
|
44
|
-
.map(
|
|
45
|
-
.filter(
|
|
45
|
+
((_d = (_c = objectLoader.resources) === null || _c === void 0 ? void 0 : _c[resource.value.slice(0, resource.value.lastIndexOf('.')).replace(/\/manifest$/u, '#manifest')]) !== null && _d !== void 0 ? _d : resource)).properties.entries.flatMap((entryList) => (entryList.list || [entryList])
|
|
46
|
+
.map(res => (0, ITestCase_1.testCaseFromResource)(testCaseHandlers, options, res, true)))))
|
|
47
|
+
.filter(Boolean)
|
|
46
48
|
.flat(),
|
|
47
49
|
uri: resource.value,
|
|
48
50
|
};
|
|
@@ -67,13 +69,11 @@ function manifestFromSpecificationResource(testCaseHandlers, options, resource,
|
|
|
67
69
|
uri: resource.value,
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
}
|
|
72
|
+
return {
|
|
73
|
+
comment: resource.property.comment ? resource.property.comment.value : null,
|
|
74
|
+
label: resource.property.label ? resource.property.label.value : null,
|
|
75
|
+
uri: resource.value,
|
|
76
|
+
};
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
//# sourceMappingURL=IManifest.js.map
|
package/lib/IManifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IManifest.js","sourceRoot":"","sources":["IManifest.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"IManifest.js","sourceRoot":"","sources":["IManifest.ts"],"names":[],"mappings":";;;;;;;;;;;AA0BA,oDA0CC;AASD,8EAgBC;AA3FD,oDAA4D;AAG5D,iCAA8B;AAc9B;;;;;;GAMG;AACH,SAAsB,oBAAoB,CAAC,gBAAkE,EAAE,OAAsB,EAAE,QAAkB,EAAE,YAA6B;;;QACtL,OAAO;Y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IAAI;iBAC7F,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;YAC7F,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;gBAC3E,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;gBACrE,YAAY;gBACZ,GAAG,EAAE,QAAQ,CAAC,KAAK;aACpB,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YAC3E,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACrE,GAAG,EAAE,QAAQ,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;CAAA","sourcesContent":["import type { RdfObjectLoader, Resource } from 'rdf-object';\nimport type { ITestCase } from './testcase/ITestCase';\nimport { testCaseFromResource } from './testcase/ITestCase';\nimport type { ITestCaseHandler } from './testcase/ITestCaseHandler';\nimport type { IFetchOptions } from './Util';\nimport { Util } from './Util';\n\n/**\n * A manifest data holder.\n */\nexport interface IManifest {\n uri: string;\n label?: string;\n comment?: string;\n subManifests?: IManifest[];\n testEntries?: ITestCase<any>[];\n specifications?: Record<string, IManifest>;\n}\n\n/**\n * Create a manifest object from a resource.\n * @param {{[uri: string]: ITestCaseHandler<ITestCase<any>>}} testCaseHandlers Handlers for constructing test cases.\n * @param {IFetchOptions} options The fetch options.\n * @param {Resource} resource A resource.\n * @return {Promise<IManifest>} A promise resolving to a manifest object.\n */\nexport async function manifestFromResource(testCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>>, options: IFetchOptions, resource: Resource, objectLoader: RdfObjectLoader): Promise<IManifest> {\n return {\n comment: resource.property.comment ? resource.property.comment.value : null,\n label: resource.property.label ? resource.property.label.value : null,\n specifications: resource.property.specifications ?\n await Util.promiseValues<IManifest>(\n Object.assign.apply({}, <any> await Promise.all(\n resource.property.specifications.list\n .map((specificationResource: Resource) =>\n ({ [specificationResource.term.value]:\n manifestFromSpecificationResource(testCaseHandlers, options, specificationResource, objectLoader) })),\n )),\n ) :\n null,\n subManifests: await Promise.all<IManifest>(\n // This is here because of the way the rdf-star test suite is published\n // @see https://github.com/rubensworks/rdf-test-suite.js/pull/78/files#r1026326410\n (<any> ((resource.properties.include.length > 0 || !objectLoader) ?\n resource :\n (objectLoader.resources?.[resource.value.slice(0, resource.value.lastIndexOf('.')).replace(/\\/manifest$/u, '#manifest')] ?? resource)\n )\n .properties.include.flatMap(\n (includeList: Resource) => includeList.list.map(res => manifestFromResource(testCaseHandlers, options, res, objectLoader)),\n )\n ),\n ),\n testEntries: (await Promise.all<ITestCase<any>>(\n // This is here because of the way the rdf-star test suite is published\n // @see https://github.com/rubensworks/rdf-test-suite.js/pull/78/files#r1026326410\n (<any> (\n (resource.properties.entries.length > 0 || !objectLoader) ?\n resource :\n (objectLoader.resources?.[resource.value.slice(0, resource.value.lastIndexOf('.')).replace(/\\/manifest$/u, '#manifest')] ?? resource)\n ).properties.entries.flatMap(\n (entryList: Resource) => (entryList.list || [ entryList ])\n .map(res => testCaseFromResource(testCaseHandlers, options, res, true)),\n )),\n ))\n .filter(Boolean)\n .flat(),\n uri: resource.value,\n };\n}\n\n/**\n * Create a manifest object from a specification resource.\n * @param {{[uri: string]: ITestCaseHandler<ITestCase<any>>}} testCaseHandlers Handlers for constructing test cases.\n * @param {IFetchOptions} options The fetch options.\n * @param {Resource} resource A resource.\n * @return {Promise<IManifest>} A promise resolving to a manifest object.\n */\nexport async function manifestFromSpecificationResource(testCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>>, options: IFetchOptions, resource: Resource, objectLoader: RdfObjectLoader): Promise<IManifest> {\n if (resource.property.conformanceRequirements) {\n const subManifests = await Promise.all<IManifest>(resource.property.conformanceRequirements.list\n .map(resource => manifestFromResource(testCaseHandlers, options, resource, objectLoader)));\n return {\n comment: resource.property.comment ? resource.property.comment.value : null,\n label: resource.property.label ? resource.property.label.value : null,\n subManifests,\n uri: resource.value,\n };\n }\n return {\n comment: resource.property.comment ? resource.property.comment.value : null,\n label: resource.property.label ? resource.property.label.value : null,\n uri: resource.value,\n };\n}\n"]}
|
package/lib/ManifestLoader.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { Resource } from 'rdf-object';
|
|
2
|
+
import { RdfObjectLoader } from 'rdf-object';
|
|
3
|
+
import type { IManifest } from './IManifest';
|
|
4
|
+
import type { ITestCase } from './testcase/ITestCase';
|
|
5
|
+
import type { ITestCaseHandler } from './testcase/ITestCaseHandler';
|
|
6
|
+
import type { IFetchOptions } from './Util';
|
|
6
7
|
/**
|
|
7
8
|
* A ManifestLoader loads test suites from URLs.
|
|
8
9
|
*/
|
|
9
10
|
export declare class ManifestLoader {
|
|
10
|
-
static readonly
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
static readonly LOADER_CONTEXT: any;
|
|
11
|
+
static readonly defaultTestCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>>;
|
|
12
|
+
static readonly loaderContext: Record<string, unknown>;
|
|
14
13
|
private readonly testCaseHandlers;
|
|
15
14
|
constructor(args?: IManifestLoaderArgs);
|
|
16
15
|
/**
|
|
@@ -23,7 +22,5 @@ export declare class ManifestLoader {
|
|
|
23
22
|
protected import(objectLoader: RdfObjectLoader, urlInitial: string, options?: IFetchOptions): Promise<Resource>;
|
|
24
23
|
}
|
|
25
24
|
export interface IManifestLoaderArgs {
|
|
26
|
-
testCaseHandlers?:
|
|
27
|
-
[uri: string]: ITestCaseHandler<ITestCase<any>>;
|
|
28
|
-
};
|
|
25
|
+
testCaseHandlers?: Record<string, ITestCaseHandler<ITestCase<any>>>;
|
|
29
26
|
}
|
package/lib/ManifestLoader.js
CHANGED
|
@@ -22,7 +22,7 @@ class ManifestLoader {
|
|
|
22
22
|
if (!args) {
|
|
23
23
|
args = {};
|
|
24
24
|
}
|
|
25
|
-
this.testCaseHandlers = args.testCaseHandlers || ManifestLoader.
|
|
25
|
+
this.testCaseHandlers = args.testCaseHandlers || ManifestLoader.defaultTestCaseHandlers;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Load the manifest from the given URL.
|
|
@@ -32,7 +32,7 @@ class ManifestLoader {
|
|
|
32
32
|
*/
|
|
33
33
|
from(url, options) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const objectLoader = new rdf_object_1.RdfObjectLoader({ context: ManifestLoader.
|
|
35
|
+
const objectLoader = new rdf_object_1.RdfObjectLoader({ context: ManifestLoader.loaderContext });
|
|
36
36
|
const manifest = yield this.import(objectLoader, url, options);
|
|
37
37
|
return (0, IManifest_1.manifestFromResource)(this.testCaseHandlers, options, manifest, objectLoader);
|
|
38
38
|
});
|
|
@@ -46,7 +46,12 @@ class ManifestLoader {
|
|
|
46
46
|
// Import all sub-manifests
|
|
47
47
|
let manifest =
|
|
48
48
|
// First try the same URL as the document URL
|
|
49
|
-
(_b = (_a = objectLoader.resources[url]) !== null && _a !== void 0 ? _a :
|
|
49
|
+
(_b = (_a = objectLoader.resources[url]) !== null && _a !== void 0 ? _a :
|
|
50
|
+
// Also try extension-less manifest URL (needed for RDFa test suite)
|
|
51
|
+
objectLoader.resources[url.slice(0, url.lastIndexOf('.'))]) !== null && _b !== void 0 ? _b :
|
|
52
|
+
// Also try extension-less and with the last '/' replaced with a '#' (needed for RDFstar test suite)
|
|
53
|
+
// @see https://github.com/w3c/rdf-star/issues/269
|
|
54
|
+
objectLoader.resources[url.slice(0, url.lastIndexOf('.')).replace(/\/manifest$/u, '#manifest')];
|
|
50
55
|
if (!manifest) {
|
|
51
56
|
throw new Error(`Could not find a resource ${url} in the document at ${url}`);
|
|
52
57
|
}
|
|
@@ -59,15 +64,22 @@ class ManifestLoader {
|
|
|
59
64
|
includeJobs.push(this.import(objectLoader, include.value, options));
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
|
-
|
|
67
|
+
yield Promise.all(includeJobs);
|
|
63
68
|
manifest =
|
|
64
69
|
// First try the same URL as the document URL
|
|
65
|
-
(_d = (_c = objectLoader.resources[url]) !== null && _c !== void 0 ? _c :
|
|
70
|
+
(_d = (_c = objectLoader.resources[url]) !== null && _c !== void 0 ? _c :
|
|
71
|
+
// Also try extension-less manifest URL (needed for RDFa test suite)
|
|
72
|
+
objectLoader.resources[url.slice(0, url.lastIndexOf('.'))]) !== null && _d !== void 0 ? _d :
|
|
73
|
+
// Also try extension-less and with the last '/' replaced with a '#' (needed for RDFstar test suite)
|
|
74
|
+
// @see https://github.com/w3c/rdf-star/issues/269
|
|
75
|
+
objectLoader.resources[url.slice(0, url.lastIndexOf('.')).replace(/\/manifest$/u, '#manifest')];
|
|
66
76
|
return manifest;
|
|
67
77
|
});
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
exports.ManifestLoader = ManifestLoader;
|
|
71
|
-
|
|
72
|
-
ManifestLoader.
|
|
81
|
+
// eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
|
|
82
|
+
ManifestLoader.defaultTestCaseHandlers = require('./testcase/TestCaseHandlers');
|
|
83
|
+
// eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
|
|
84
|
+
ManifestLoader.loaderContext = require('./context-manifest.json');
|
|
73
85
|
//# sourceMappingURL=ManifestLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["ManifestLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["ManifestLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2CAA6C;AAC7C,2CAA0C;AAE1C,2CAAmD;AAInD,iCAA8B;AAE9B;;GAEG;AACH,MAAa,cAAc;IASzB,YAAmB,IAA0B;QAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,IAAI,cAAc,CAAC,uBAAuB,CAAC;IAC1F,CAAC;IAED;;;;;OAKG;IACU,IAAI,CAAC,GAAW,EAAE,OAAuB;;YACpD,MAAM,YAAY,GAAG,IAAI,4BAAe,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC;YACpF,MAAM,QAAQ,GAAa,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;YACzE,OAAO,IAAA,gCAAoB,EAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QACtF,CAAC;KAAA;IAEe,MAAM,CAAC,YAA6B,EAAE,UAAkB,EAAE,OAAuB;;;YAC/F,MAAM,CAAE,GAAG,EAAE,MAAM,CAAE,GAAG,MAAM,WAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACjE,kCAAkC;YAClC,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAElC,2BAA2B;YAC3B,IAAI,QAAQ;YACV,6CAA6C;YAC7C,MAAA,MAAA,YAAY,CAAC,SAAS,CAAC,G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CAAC;gBAC1D,oGAAoG;gBACpG,kDAAkD;gBAClD,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC;YAElG,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;;AApEH,wCAqEC;AApEC,qEAAqE;AAC9C,sCAAuB,GAAqD,OAAO,CAAC,6BAA6B,CAAqD,CAAC;AAE9L,qEAAqE;AAC9C,4BAAa,GAA4B,OAAO,CAAC,yBAAyB,CAA4B,CAAC","sourcesContent":["import type { Resource } from 'rdf-object';\nimport { RdfObjectLoader } from 'rdf-object';\nimport { termToString } from 'rdf-string';\nimport type { IManifest } from './IManifest';\nimport { manifestFromResource } from './IManifest';\nimport type { ITestCase } from './testcase/ITestCase';\nimport type { ITestCaseHandler } from './testcase/ITestCaseHandler';\nimport type { IFetchOptions } from './Util';\nimport { Util } from './Util';\n\n/**\n * A ManifestLoader loads test suites from URLs.\n */\nexport class ManifestLoader {\n // eslint-disable-next-line ts/no-require-imports, ts/no-var-requires\n public static readonly defaultTestCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>> = require('./testcase/TestCaseHandlers') as Record<string, ITestCaseHandler<ITestCase<any>>>;\n\n // eslint-disable-next-line ts/no-require-imports, ts/no-var-requires\n public static readonly loaderContext: Record<string, unknown> = require('./context-manifest.json') as Record<string, unknown>;\n\n private readonly testCaseHandlers: Record<string, ITestCaseHandler<ITestCase<any>>>;\n\n public constructor(args?: IManifestLoaderArgs) {\n if (!args) {\n args = {};\n }\n this.testCaseHandlers = args.testCaseHandlers || ManifestLoader.defaultTestCaseHandlers;\n }\n\n /**\n * Load the manifest from the given URL.\n * @param {string} url The URL of a manifest.\n * @param {IFetchOptions} options The fetch options.\n * @return {Promise<IManifest>} A promise that resolves to a manifest object.\n */\n public async from(url: string, options?: IFetchOptions): Promise<IManifest> {\n const objectLoader = new RdfObjectLoader({ context: ManifestLoader.loaderContext });\n const manifest: Resource = await this.import(objectLoader, url, options);\n return manifestFromResource(this.testCaseHandlers, options, manifest, objectLoader);\n }\n\n protected async import(objectLoader: RdfObjectLoader, urlInitial: string, options?: IFetchOptions): Promise<Resource> {\n const [ url, parsed ] = await Util.fetchRdf(urlInitial, options);\n // Dereference the URL and load it\n await objectLoader.import(parsed);\n\n // Import all sub-manifests\n let manifest: Resource =\n // First try the same URL as the document URL\n objectLoader.resources[url] ??\n // Also try extension-less manifest URL (needed for RDFa test suite)\n objectLoader.resources[url.slice(0, url.lastIndexOf('.'))] ??\n // Also try extension-less and with the last '/' replaced with a '#' (needed for RDFstar test suite)\n // @see https://github.com/w3c/rdf-star/issues/269\n objectLoader.resources[url.slice(0, url.lastIndexOf('.')).replace(/\\/manifest$/u, '#manifest')];\n\n if (!manifest) {\n throw new Error(`Could not find a resource ${url} in the document at ${url}`);\n }\n const includeJobs: Promise<any>[] = [];\n for (const includeList of manifest.properties.include) {\n for (const include of includeList.list) {\n if (include.term.termType !== 'NamedNode') {\n throw new Error(`Found invalid manifest term ${termToString(include.term)} when parsing ${url}`);\n }\n includeJobs.push(this.import(objectLoader, include.value, options));\n }\n }\n\n await Promise.all(includeJobs);\n\n manifest =\n // First try the same URL as the document URL\n objectLoader.resources[url] ??\n // Also try extension-less manifest URL (needed for RDFa test suite)\n objectLoader.resources[url.slice(0, url.lastIndexOf('.'))] ??\n // Also try extension-less and with the last '/' replaced with a '#' (needed for RDFstar test suite)\n // @see https://github.com/w3c/rdf-star/issues/269\n objectLoader.resources[url.slice(0, url.lastIndexOf('.')).replace(/\\/manifest$/u, '#manifest')];\n\n return manifest;\n }\n}\n\nexport interface IManifestLoaderArgs {\n testCaseHandlers?: Record<string, ITestCaseHandler<ITestCase<any>>>;\n}\n"]}
|