Skip to content

Commit 6ad17de

Browse files
authored
Merge pull request #135 from aml-org/rc/1.4.0
W-12368914: publish 1.4.0 and fix divergence between master <-> develop
2 parents e0a6ff3 + 3a5dbde commit 6ad17de

15 files changed

+981
-17
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ Rego code generation
118118
acv generate PROFILE
119119
```
120120

121+
Compile profile
122+
123+
```shell
124+
acv compile PROFILE
125+
```
126+
121127
# Relation with AMF
122128

123129
AMF is a framework capable of producing semantic graphs in JSON-LD syntax from API specification documents or arbitrary

cmd/commands/compile.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package commands
2+
3+
import (
4+
"fmt"
5+
"github.com/aml-org/amf-custom-validator/cmd/commands/helpers"
6+
"github.com/aml-org/amf-custom-validator/internal/validator"
7+
"os"
8+
)
9+
10+
func Compile() {
11+
helpers.ValidateNArgs(3, "acv compile PROFILE")
12+
13+
profile := helpers.ReadOrPanic(os.Args[2])
14+
15+
_, err := validator.ProcessProfile(string(profile), true, nil)
16+
17+
if err != nil {
18+
panic(err)
19+
}
20+
fmt.Println("Compile Success!")
21+
os.Exit(0)
22+
}

cmd/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ func main() {
1414
commands.Generate()
1515
case "normalize":
1616
commands.Normalize()
17+
case "compile":
18+
commands.Compile()
1719
case "help":
1820
commands.Help()
1921
default:

scripts/ci-browser-local.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cd ../wrappers/js-web
2+
#npm i
3+
npm run build:dist
4+
npm run build:test
5+
npm run test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"@context": {
3+
"definedBy": {
4+
"@id": "http://a.ml/vocabularies/meta#definedBy",
5+
"@type": "@id"
6+
},
7+
"version": "http://a.ml/vocabularies/document#version",
8+
"root": {
9+
"@id": "http://a.ml/vocabularies/document#root",
10+
"@type": "http://www.w3.org/2001/XMLSchema#boolean"
11+
},
12+
"encodes": {
13+
"@id": "http://a.ml/vocabularies/document#encodes",
14+
"@type": "@id"
15+
}
16+
},
17+
"@graph": [
18+
{
19+
"@id": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie",
20+
"@type": [
21+
"http://a.ml/vocabularies/document#Module",
22+
"http://a.ml/vocabularies/document#Document",
23+
"http://a.ml/vocabularies/meta#DialectInstance",
24+
"http://a.ml/vocabularies/document#Fragment",
25+
"http://a.ml/vocabularies/document#Unit"
26+
],
27+
"encodes": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie#/",
28+
"http://a.ml/vocabularies/document#root": true,
29+
"version": "2.0.1",
30+
"definedBy": "http://0.0.0.0:8080/v1/schema/Movie/1.0"
31+
},
32+
{
33+
"@id": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie#/",
34+
"@type": [
35+
"http://0.0.0.0:8080/v1/schema/Movie/1.0#/declarations/MovieNode",
36+
"http://a.ml/vocabularies/meta#DialectDomainElement",
37+
"http://anypoint.com/vocabs/movie#Movie",
38+
"http://a.ml/vocabularies/document#DomainElement"
39+
],
40+
"http://anypoint.com/vocabs/movie#rating": 1.9,
41+
"http://anypoint.com/vocabs/movie#reviewsAmount": 5,
42+
"http://anypoint.com/vocabs/movie#title": "Disaster Movie"
43+
}
44+
]
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
[
2+
{
3+
"@context": {
4+
"actual": {
5+
"@id": "http://a.ml/vocabularies/validation#actual"
6+
},
7+
"argument": {
8+
"@id": "http://a.ml/vocabularies/validation#argument"
9+
},
10+
"column": {
11+
"@id": "http://a.ml/vocabularies/lexical#column"
12+
},
13+
"component": {
14+
"@id": "http://a.ml/vocabularies/validation#component"
15+
},
16+
"condition": {
17+
"@id": "http://a.ml/vocabularies/validation#condition"
18+
},
19+
"conforms": {
20+
"@id": "http://www.w3.org/ns/shacl#conforms"
21+
},
22+
"doc": "http://a.ml/vocabularies/document#",
23+
"end": {
24+
"@id": "http://a.ml/vocabularies/lexical#end"
25+
},
26+
"expected": {
27+
"@id": "http://a.ml/vocabularies/validation#expected"
28+
},
29+
"focusNode": {
30+
"@id": "http://www.w3.org/ns/shacl#focusNode"
31+
},
32+
"lexical": "http://a.ml/vocabularies/lexical#",
33+
"lexicalSchema": "file:///dialects/lexical.yaml#/declarations/",
34+
"line": {
35+
"@id": "http://a.ml/vocabularies/lexical#line"
36+
},
37+
"location": {
38+
"@id": "http://a.ml/vocabularies/validation#location"
39+
},
40+
"meta": "http://a.ml/vocabularies/meta#",
41+
"negated": {
42+
"@id": "http://a.ml/vocabularies/validation#negated"
43+
},
44+
"profileName": {
45+
"@id": "http://a.ml/vocabularies/validation#profileName"
46+
},
47+
"range": {
48+
"@id": "http://a.ml/vocabularies/lexical#range"
49+
},
50+
"reportSchema": "file:///dialects/validation-report.yaml#/declarations/",
51+
"result": {
52+
"@id": "http://www.w3.org/ns/shacl#result"
53+
},
54+
"resultMessage": {
55+
"@id": "http://www.w3.org/ns/shacl#resultMessage"
56+
},
57+
"resultPath": {
58+
"@id": "http://www.w3.org/ns/shacl#resultPath"
59+
},
60+
"resultSeverity": {
61+
"@id": "http://www.w3.org/ns/shacl#resultSeverity"
62+
},
63+
"shacl": "http://www.w3.org/ns/shacl#",
64+
"sourceShapeName": {
65+
"@id": "http://a.ml/vocabularies/validation#sourceShapeName"
66+
},
67+
"start": {
68+
"@id": "http://a.ml/vocabularies/lexical#start"
69+
},
70+
"subResult": {
71+
"@id": "http://a.ml/vocabularies/validation#subResult"
72+
},
73+
"trace": {
74+
"@id": "http://a.ml/vocabularies/validation#trace"
75+
},
76+
"traceValue": {
77+
"@id": "http://www.w3.org/ns/shacl#traceValue"
78+
},
79+
"uri": {
80+
"@id": "http://a.ml/vocabularies/lexical#uri"
81+
},
82+
"validation": "http://a.ml/vocabularies/validation#"
83+
},
84+
"@id": "dialect-instance",
85+
"@type": [
86+
"meta:DialectInstance",
87+
"doc:Document",
88+
"doc:Fragment",
89+
"doc:Module",
90+
"doc:Unit"
91+
],
92+
"doc:encodes": [
93+
{
94+
"@id": "validation-report",
95+
"@type": [
96+
"reportSchema:ReportNode",
97+
"shacl:ValidationReport"
98+
],
99+
"conforms": false,
100+
"profileName": "Movie ratings",
101+
"result": [
102+
{
103+
"@id": "violation_0",
104+
"@type": [
105+
"reportSchema:ValidationResultNode",
106+
"shacl:ValidationResult"
107+
],
108+
"focusNode": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie#/",
109+
"resultMessage": "Movie 'Disaster Movie' has a rating of 1.9 but it does not have at least 10 reviews (actual reviews: 5) to support that rating",
110+
"resultSeverity": "http://www.w3.org/ns/shacl#Violation",
111+
"sourceShapeName": "not-enough-reviews",
112+
"trace": [
113+
{
114+
"@id": "violation_0_0",
115+
"@type": [
116+
"reportSchema:TraceMessageNode",
117+
"validation:TraceMessage"
118+
],
119+
"component": "minimumInclusive",
120+
"resultPath": "http://anypoint.com/vocabs/movie#reviewsAmount",
121+
"traceValue": {
122+
"@id": "violation_0_0_traceValue",
123+
"@type": [
124+
"reportSchema:TraceValueNode",
125+
"validation:TraceValue"
126+
],
127+
"actual": 5,
128+
"condition": ">=",
129+
"expected": 10,
130+
"negated": false
131+
}
132+
},
133+
{
134+
"@id": "violation_0_1",
135+
"@type": [
136+
"reportSchema:TraceMessageNode",
137+
"validation:TraceMessage"
138+
],
139+
"component": "minimumExclusive",
140+
"resultPath": "http://anypoint.com/vocabs/movie#rating",
141+
"traceValue": {
142+
"@id": "violation_0_1_traceValue",
143+
"@type": [
144+
"reportSchema:TraceValueNode",
145+
"validation:TraceValue"
146+
],
147+
"actual": 1.9,
148+
"condition": ">",
149+
"expected": 0,
150+
"negated": true
151+
}
152+
}
153+
]
154+
}
155+
]
156+
}
157+
],
158+
"doc:processingData": [
159+
{
160+
"@id": "processing-data",
161+
"@type": [
162+
"doc:DialectInstanceProcessingData"
163+
],
164+
"doc:sourceSpec": "Validation Report 1.0"
165+
}
166+
]
167+
}
168+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"@context": {
3+
"definedBy": {
4+
"@id": "http://a.ml/vocabularies/meta#definedBy",
5+
"@type": "@id"
6+
},
7+
"version": "http://a.ml/vocabularies/document#version",
8+
"root": {
9+
"@id": "http://a.ml/vocabularies/document#root",
10+
"@type": "http://www.w3.org/2001/XMLSchema#boolean"
11+
},
12+
"encodes": {
13+
"@id": "http://a.ml/vocabularies/document#encodes",
14+
"@type": "@id"
15+
}
16+
},
17+
"@graph": [
18+
{
19+
"@id": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie",
20+
"@type": [
21+
"http://a.ml/vocabularies/document#Module",
22+
"http://a.ml/vocabularies/document#Document",
23+
"http://a.ml/vocabularies/meta#DialectInstance",
24+
"http://a.ml/vocabularies/document#Fragment",
25+
"http://a.ml/vocabularies/document#Unit"
26+
],
27+
"encodes": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie#/",
28+
"http://a.ml/vocabularies/document#root": true,
29+
"version": "2.0.1",
30+
"definedBy": "http://0.0.0.0:8080/v1/schema/Movie/1.0"
31+
},
32+
{
33+
"@id": "http://0.0.0.0:8080/v1/movie/Lionsgate/Disaster+Movie#/",
34+
"@type": [
35+
"http://0.0.0.0:8080/v1/schema/Movie/1.0#/declarations/MovieNode",
36+
"http://a.ml/vocabularies/meta#DialectDomainElement",
37+
"http://anypoint.com/vocabs/movie#Movie",
38+
"http://a.ml/vocabularies/document#DomainElement"
39+
],
40+
"http://anypoint.com/vocabs/movie#rating": 1.9,
41+
"http://anypoint.com/vocabs/movie#reviewsAmount": 500,
42+
"http://anypoint.com/vocabs/movie#title": "Disaster Movie"
43+
}
44+
]
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[
2+
{
3+
"@context": {
4+
"conforms": {
5+
"@id": "http://www.w3.org/ns/shacl#conforms"
6+
},
7+
"doc": "http://a.ml/vocabularies/document#",
8+
"meta": "http://a.ml/vocabularies/meta#",
9+
"reportSchema": "file:///dialects/validation-report.yaml#/declarations/",
10+
"shacl": "http://www.w3.org/ns/shacl#"
11+
},
12+
"@id": "dialect-instance",
13+
"@type": [
14+
"meta:DialectInstance",
15+
"doc:Document",
16+
"doc:Fragment",
17+
"doc:Module",
18+
"doc:Unit"
19+
],
20+
"doc:encodes": [
21+
{
22+
"@id": "validation-report",
23+
"@type": [
24+
"reportSchema:ReportNode",
25+
"shacl:ValidationReport"
26+
],
27+
"conforms": true,
28+
"profileName": "Movie ratings"
29+
}
30+
],
31+
"doc:processingData": [
32+
{
33+
"@id": "processing-data",
34+
"@type": [
35+
"doc:DialectInstanceProcessingData"
36+
],
37+
"doc:sourceSpec": "Validation Report 1.0"
38+
}
39+
]
40+
}
41+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#%Validation Profile 1.0
2+
profile: Movie ratings
3+
prefixes:
4+
movie: http://anypoint.com/vocabs/movie#
5+
violation:
6+
- not-enough-reviews
7+
validations:
8+
not-enough-reviews:
9+
targetClass: movie.Movie
10+
message: "Movie '{{ movie.title }}' has a rating of {{ movie.rating }} but it does not have at least 10 reviews (actual reviews: {{ movie.reviewsAmount }}) to support that rating"
11+
if:
12+
propertyConstraints:
13+
movie.rating:
14+
minExclusive: 0
15+
then:
16+
propertyConstraints:
17+
movie.reviewsAmount:
18+
minInclusive: 10
19+
examples:
20+
valid: |
21+
a: a
22+
b: b
23+
invalid: this is an invalid example

wrappers/js-web/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require("../js/lib/wasm_exec");
1+
require("/lib/wasm_exec_node");
22
let wasm_gz = require("../js/lib/main.wasm.gz")
33
const pako = require("pako");
44
const Buffer = require("buffer").Buffer;
@@ -54,4 +54,4 @@ const exit = function() {
5454

5555
module.exports.initialize = initialize;
5656
module.exports.validate = validateCustomProfile;
57-
module.exports.exit = exit;
57+
module.exports.exit = exit;

0 commit comments

Comments
 (0)