@aml-org/amf-custom-validator 1.7.0-SNAPSHOT.112 → 1.7.1
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 +20 -2
- package/lib/main.wasm.gz +0 -0
- package/package.json +1 -1
- package/test/simple.js +28 -0
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ let wasm
|
|
|
7
7
|
let initialized = false
|
|
8
8
|
let go = undefined;
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const validateKernel = function(profile, data, debug) {
|
|
11
11
|
let before = new Date()
|
|
12
12
|
const res = __AMF__validateCustomProfile(profile,data, debug);
|
|
13
13
|
let after = new Date();
|
|
@@ -15,9 +15,26 @@ const run = function(profile, data, debug) {
|
|
|
15
15
|
return res;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
const validateWithReportConfigurationKernel = function(profile, data, debug, reportConfig) {
|
|
19
|
+
let before = new Date()
|
|
20
|
+
const res = __AMF__validateCustomProfileWithConfiguration(profile,data, debug, undefined, reportConfig);
|
|
21
|
+
let after = new Date();
|
|
22
|
+
if (debug) console.log("Elapsed : " + (after - before))
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
const validateCustomProfile = function(profile, data, debug, cb) {
|
|
19
27
|
if (initialized) {
|
|
20
|
-
let res =
|
|
28
|
+
let res = validateKernel(profile, data, debug);
|
|
29
|
+
cb(res,undefined);
|
|
30
|
+
} else {
|
|
31
|
+
cb(undefined,new Error("WASM/GO not initialized"))
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const validateCustomProfileWithReportConfiguration = function(profile, data, debug, reportConfig, cb) {
|
|
36
|
+
if (initialized) {
|
|
37
|
+
let res = validateWithReportConfigurationKernel(profile, data, debug, reportConfig);
|
|
21
38
|
cb(res,undefined);
|
|
22
39
|
} else {
|
|
23
40
|
cb(undefined,new Error("WASM/GO not initialized"))
|
|
@@ -82,6 +99,7 @@ const exit = function() {
|
|
|
82
99
|
|
|
83
100
|
module.exports.initialize = initialize;
|
|
84
101
|
module.exports.validate = validateCustomProfile;
|
|
102
|
+
module.exports.validateWithReportConfiguration = validateCustomProfileWithReportConfiguration;
|
|
85
103
|
module.exports.generateRego = generateRego;
|
|
86
104
|
module.exports.normalizeInput = normalizeInput;
|
|
87
105
|
module.exports.exit = exit;
|
package/lib/main.wasm.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/test/simple.js
CHANGED
|
@@ -93,4 +93,32 @@ describe('validator', () => {
|
|
|
93
93
|
})
|
|
94
94
|
});
|
|
95
95
|
})
|
|
96
|
+
|
|
97
|
+
describe('validate with configuration', () => {
|
|
98
|
+
|
|
99
|
+
it("must match expected report output", (done) => {
|
|
100
|
+
const profile = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/profile.yaml").toString()
|
|
101
|
+
const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/negative.data.jsonld").toString()
|
|
102
|
+
const validator = require(__dirname + "/../index")
|
|
103
|
+
validator.initialize(() => {
|
|
104
|
+
const reportConfig = {
|
|
105
|
+
"IncludeReportCreationTime": false,
|
|
106
|
+
"ReportSchemaIri": "http://a.ml/report",
|
|
107
|
+
"LexicalSchemaIri": "http://a.ml/lexical"
|
|
108
|
+
}
|
|
109
|
+
validator.validateWithReportConfiguration(profile, data, false, reportConfig, (r, err) => {
|
|
110
|
+
if (err) {
|
|
111
|
+
done(err);
|
|
112
|
+
} else {
|
|
113
|
+
let report = JSON.parse(r)
|
|
114
|
+
assert.ok(report[0]["doc:encodes"][0]["dateCreated"] === undefined)
|
|
115
|
+
assert.strictEqual(report[0]["@context"]["reportSchema"], "http://a.ml/report#/declarations/")
|
|
116
|
+
assert.strictEqual(report[0]["@context"]["lexicalSchema"], "http://a.ml/lexical#/declarations/")
|
|
117
|
+
validator.exit();
|
|
118
|
+
done();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
})
|
|
96
124
|
})
|