schemata-validator 0.1.0 → 0.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/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/format-parsers/html-parser.d.ts +45 -0
- package/dist/format-parsers/html-parser.js +168 -0
- package/dist/format-parsers/html-parser.js.map +1 -1
- package/dist/format-parsers/json-ld-parser.d.ts +3 -3
- package/dist/format-parsers/json-ld-parser.js +6 -5
- package/dist/format-parsers/json-ld-parser.js.map +1 -1
- package/dist/types.d.ts +7 -1
- package/dist/utils/display-reporting.js +7 -2
- package/dist/utils/display-reporting.js.map +1 -1
- package/dist/utils/prepare-reporting.js +12 -9
- package/dist/utils/prepare-reporting.js.map +1 -1
- package/dist/validator/schema-graph-validator.d.ts +5 -5
- package/dist/validator/schema-graph-validator.js +53 -23
- package/dist/validator/schema-graph-validator.js.map +1 -1
- package/package.json +7 -4
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -44,4 +44,6 @@ export const AVAILABLE_CLI_FLAGS = {
|
|
|
44
44
|
type: "boolean"
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
+
export const SCHEMA_ORG_URL_PATTERN = /ht{2}ps?:\/{2}schema\.org\/?/;
|
|
48
|
+
export const SCHEMA_ORG_URL_EXTACT_PATTERN = new RegExp(`^${SCHEMA_ORG_URL_PATTERN.source}$`);
|
|
47
49
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE;QACL,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,OAAO;KACd;IACD,KAAK,EAAE;QACL,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,mCAAmC;QAChD,IAAI,EAAE,OAAO;KACd;IACD,OAAO,EAAE;QACP,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,OAAO;KACd;IACD,MAAM,EAAE;QACN,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,SAAS;KAChB;IACD,OAAO,EAAE;QACP,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,qBAAqB;QAClC,IAAI,EAAE,SAAS;KAChB;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM;QACnB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,SAAS;KAChB;CACO,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE;QACL,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,OAAO;KACd;IACD,KAAK,EAAE;QACL,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,mCAAmC;QAChD,IAAI,EAAE,OAAO;KACd;IACD,OAAO,EAAE;QACP,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,OAAO;KACd;IACD,MAAM,EAAE;QACN,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,SAAS;KAChB;IACD,OAAO,EAAE;QACP,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,qBAAqB;QAClC,IAAI,EAAE,SAAS;KAChB;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM;QACnB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,SAAS;KAChB;CACO,CAAC;AACX,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AACrE,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,MAAM,CAAC,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,CAAC"}
|
|
@@ -6,6 +6,51 @@ export declare class HTMLParser {
|
|
|
6
6
|
* @param html - The HTML document.
|
|
7
7
|
*/
|
|
8
8
|
constructor(html: string);
|
|
9
|
+
/**
|
|
10
|
+
* Sets the absolute URI, prepending the fake base URI if the URI is relative.
|
|
11
|
+
* @access private
|
|
12
|
+
* @param uri - The URI to parse.
|
|
13
|
+
* @return The absolute URI if the URI is provided, `undefined` otherwise.
|
|
14
|
+
*/
|
|
15
|
+
private setAbsoluteURI;
|
|
16
|
+
/**
|
|
17
|
+
* Gets nodes having the `itemscope` attribute.
|
|
18
|
+
* @access private
|
|
19
|
+
* @param node - The current node to inspect.
|
|
20
|
+
* @return An array of nodes with microdata item scope.
|
|
21
|
+
*/
|
|
22
|
+
private getNodesWithMicrodataItem;
|
|
23
|
+
/**
|
|
24
|
+
* Get properties from the child nodes.
|
|
25
|
+
* @access private
|
|
26
|
+
* @param childNodes - The child nodes to inspect.
|
|
27
|
+
* @return A map of properties and their values.
|
|
28
|
+
*/
|
|
29
|
+
private getPropertiesFromChildNodes;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts text content from the child nodes.
|
|
32
|
+
* @access private
|
|
33
|
+
* @param nodes - An array of nodes.
|
|
34
|
+
* @returns The text contents, concatenated and trimmed of any leading or trailing whitespace, any consecutive whitespace sequences being replaced by a single space character.
|
|
35
|
+
*/
|
|
36
|
+
private extractTextContent;
|
|
37
|
+
/**
|
|
38
|
+
* Sets the schema value.
|
|
39
|
+
*
|
|
40
|
+
* In case no value is found (e.g.: all the child nodes are elements), a schema node is set.
|
|
41
|
+
* @access private
|
|
42
|
+
* @param node - The node from which to extract the value.
|
|
43
|
+
* @param location - The `itemprop` location.
|
|
44
|
+
* @return The schema value.
|
|
45
|
+
*/
|
|
46
|
+
private setSchemaValue;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the schema node.
|
|
49
|
+
* @access private
|
|
50
|
+
* @param node - The object from the HTML node tree to use as a node.
|
|
51
|
+
* @return The schema node.
|
|
52
|
+
*/
|
|
53
|
+
private setSchemaNode;
|
|
9
54
|
/**
|
|
10
55
|
* Parses the HTML document.
|
|
11
56
|
*
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import * as util from "node:util";
|
|
2
|
+
import { parse as parse5 } from "parse5";
|
|
1
3
|
import { JSONLDParser } from "./json-ld-parser.js";
|
|
4
|
+
import { SCHEMA_ORG_URL_PATTERN } from "../constants.js";
|
|
2
5
|
export class HTMLParser {
|
|
3
6
|
html;
|
|
4
7
|
/**
|
|
@@ -8,6 +11,162 @@ export class HTMLParser {
|
|
|
8
11
|
constructor(html) {
|
|
9
12
|
this.html = html;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Sets the absolute URI, prepending the fake base URI if the URI is relative.
|
|
16
|
+
* @access private
|
|
17
|
+
* @param uri - The URI to parse.
|
|
18
|
+
* @return The absolute URI if the URI is provided, `undefined` otherwise.
|
|
19
|
+
*/
|
|
20
|
+
setAbsoluteURI(uri) {
|
|
21
|
+
if (typeof uri === "string") {
|
|
22
|
+
const fakeBaseURI = "https://example.com";
|
|
23
|
+
return uri.startsWith("http")
|
|
24
|
+
? uri
|
|
25
|
+
: uri.startsWith("/")
|
|
26
|
+
? fakeBaseURI + uri
|
|
27
|
+
: `${fakeBaseURI}/${uri}`;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Gets nodes having the `itemscope` attribute.
|
|
33
|
+
* @access private
|
|
34
|
+
* @param node - The current node to inspect.
|
|
35
|
+
* @return An array of nodes with microdata item scope.
|
|
36
|
+
*/
|
|
37
|
+
getNodesWithMicrodataItem(node) {
|
|
38
|
+
const nodesWithItemScope = [];
|
|
39
|
+
if ("tagName" in node) {
|
|
40
|
+
if ("attrs" in node && node.attrs.some(attr => attr.name === "itemscope")) {
|
|
41
|
+
nodesWithItemScope.push(node);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const { childNodes } = node;
|
|
45
|
+
for (const childNode of childNodes) {
|
|
46
|
+
nodesWithItemScope.push(...this.getNodesWithMicrodataItem(childNode));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return nodesWithItemScope;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get properties from the child nodes.
|
|
54
|
+
* @access private
|
|
55
|
+
* @param childNodes - The child nodes to inspect.
|
|
56
|
+
* @return A map of properties and their values.
|
|
57
|
+
*/
|
|
58
|
+
getPropertiesFromChildNodes(childNodes) {
|
|
59
|
+
const properties = new Map();
|
|
60
|
+
for (const childNode of childNodes) {
|
|
61
|
+
if (!("tagName" in childNode))
|
|
62
|
+
continue;
|
|
63
|
+
const { attrs } = childNode;
|
|
64
|
+
const itemprop = attrs.find(attr => attr.name === "itemprop");
|
|
65
|
+
if (itemprop) {
|
|
66
|
+
const keys = new Set(itemprop.value.split(" "));
|
|
67
|
+
for (const key of keys) {
|
|
68
|
+
const itempropLocation = childNode.sourceCodeLocation?.attrs?.itemprop;
|
|
69
|
+
const location = {
|
|
70
|
+
startLine: itempropLocation?.startLine ?? 0,
|
|
71
|
+
startColumn: itempropLocation?.startCol ?? 0
|
|
72
|
+
};
|
|
73
|
+
const values = properties.get(key) ?? [];
|
|
74
|
+
values.push(this.setSchemaValue(childNode, location));
|
|
75
|
+
properties.set(key, values);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const nestedProperties = this.getPropertiesFromChildNodes(childNode.childNodes);
|
|
80
|
+
for (const [key, values] of nestedProperties) {
|
|
81
|
+
const existingKeys = properties.get(key) ?? [];
|
|
82
|
+
properties.set(key, [...existingKeys, ...values]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return properties;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extracts text content from the child nodes.
|
|
90
|
+
* @access private
|
|
91
|
+
* @param nodes - An array of nodes.
|
|
92
|
+
* @returns The text contents, concatenated and trimmed of any leading or trailing whitespace, any consecutive whitespace sequences being replaced by a single space character.
|
|
93
|
+
*/
|
|
94
|
+
extractTextContent(nodes) {
|
|
95
|
+
return nodes
|
|
96
|
+
.map(node => "value" in node
|
|
97
|
+
? node.value
|
|
98
|
+
: "childNodes" in node &&
|
|
99
|
+
!node.attrs.some(attr => attr.name === "itemscope" || attr.name === "itemtype" || attr.name === "itemprop")
|
|
100
|
+
? this.extractTextContent(node.childNodes)
|
|
101
|
+
: "")
|
|
102
|
+
.join("")
|
|
103
|
+
.replace(/\n+\s+/g, " ")
|
|
104
|
+
.trim();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Sets the schema value.
|
|
108
|
+
*
|
|
109
|
+
* In case no value is found (e.g.: all the child nodes are elements), a schema node is set.
|
|
110
|
+
* @access private
|
|
111
|
+
* @param node - The node from which to extract the value.
|
|
112
|
+
* @param location - The `itemprop` location.
|
|
113
|
+
* @return The schema value.
|
|
114
|
+
*/
|
|
115
|
+
setSchemaValue(node, location) {
|
|
116
|
+
const { attrs, childNodes } = node;
|
|
117
|
+
if (attrs.some(attr => attr.name === "itemscope")) {
|
|
118
|
+
return {
|
|
119
|
+
kind: "node",
|
|
120
|
+
linkLocation: location,
|
|
121
|
+
node: this.setSchemaNode(node)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const value = attrs.some(attr => attr.name === "content")
|
|
125
|
+
? (attrs.find(attr => attr.name === "content")?.value ?? "")
|
|
126
|
+
: childNodes.length
|
|
127
|
+
? this.extractTextContent(childNodes)
|
|
128
|
+
: (this.setAbsoluteURI(attrs.find(attr => attr.name === "src")?.value) ?? "");
|
|
129
|
+
if (value) {
|
|
130
|
+
return {
|
|
131
|
+
kind: "literal",
|
|
132
|
+
location,
|
|
133
|
+
value
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
kind: "node",
|
|
138
|
+
linkLocation: location,
|
|
139
|
+
node: this.setSchemaNode(node, location)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sets the schema node.
|
|
144
|
+
* @access private
|
|
145
|
+
* @param node - The object from the HTML node tree to use as a node.
|
|
146
|
+
* @return The schema node.
|
|
147
|
+
*/
|
|
148
|
+
setSchemaNode(node, fallbackLocation) {
|
|
149
|
+
const { attrs, childNodes } = node;
|
|
150
|
+
const type = attrs.find(attr => attr.name === "itemtype")?.value.replace(SCHEMA_ORG_URL_PATTERN, "") ??
|
|
151
|
+
"Thing";
|
|
152
|
+
const startLine = node.sourceCodeLocation?.attrs?.itemtype?.startLine ?? fallbackLocation?.startLine ?? 0;
|
|
153
|
+
const startColumn = node.sourceCodeLocation?.attrs?.itemtype?.startCol ?? fallbackLocation?.startColumn ?? 0;
|
|
154
|
+
const itemidValue = attrs.find(attr => attr.name === "itemid")?.value.trim();
|
|
155
|
+
const hrefValue = this.setAbsoluteURI(attrs.find(attr => attr.name === "href")?.value);
|
|
156
|
+
const srcValue = this.setAbsoluteURI(attrs.find(attr => attr.name === "src")?.value);
|
|
157
|
+
const id = itemidValue ?? hrefValue ?? srcValue ?? undefined;
|
|
158
|
+
const schemaNode = id ? { type, id } : { type };
|
|
159
|
+
const properties = this.getPropertiesFromChildNodes(childNodes);
|
|
160
|
+
return {
|
|
161
|
+
...schemaNode,
|
|
162
|
+
properties,
|
|
163
|
+
sourceFormat: "microdata",
|
|
164
|
+
location: {
|
|
165
|
+
startLine,
|
|
166
|
+
startColumn
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
11
170
|
/**
|
|
12
171
|
* Parses the HTML document.
|
|
13
172
|
*
|
|
@@ -24,6 +183,15 @@ export class HTMLParser {
|
|
|
24
183
|
if (jsonLD)
|
|
25
184
|
roots.push(...jsonLDParser.parse().roots);
|
|
26
185
|
}
|
|
186
|
+
const htmlTree = parse5(this.html, { sourceCodeLocationInfo: true });
|
|
187
|
+
const [_, rootNode] = htmlTree.childNodes;
|
|
188
|
+
if (rootNode) {
|
|
189
|
+
const nodes = this.getNodesWithMicrodataItem(rootNode);
|
|
190
|
+
roots.push(...nodes.map(node => this.setSchemaNode(node)));
|
|
191
|
+
}
|
|
192
|
+
console.group("HTMLParser");
|
|
193
|
+
console.log(util.inspect(roots, { depth: Number.POSITIVE_INFINITY }));
|
|
194
|
+
console.groupEnd();
|
|
27
195
|
return {
|
|
28
196
|
roots
|
|
29
197
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-parser.js","sourceRoot":"","sources":["../../src/format-parsers/html-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"html-parser.js","sourceRoot":"","sources":["../../src/format-parsers/html-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,OAAO,UAAU;IACJ,IAAI,CAAS;IAE9B;;;OAGG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,GAAuB;QAC5C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG,qBAAqB,CAAC;YAC1C,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;gBAC3B,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;oBACnB,CAAC,CAAC,WAAW,GAAG,GAAG;oBACnB,CAAC,CAAC,GAAG,WAAW,IAAI,GAAG,EAAE,CAAC;QAChC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACK,yBAAyB,CAC/B,IAAwC;QAExC,MAAM,kBAAkB,GAGlB,EAAE,CAAC;QACT,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,CAAC;gBAC1E,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,M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LD;
|
|
4
4
|
/**
|
|
@@ -13,7 +13,7 @@ export declare class JSONLDParser {
|
|
|
13
13
|
* @param parentPath - The JSON-LD path of the parent property.
|
|
14
14
|
* @return The schema value.
|
|
15
15
|
*/
|
|
16
|
-
setSchemaValue
|
|
16
|
+
private setSchemaValue;
|
|
17
17
|
/**
|
|
18
18
|
* Sets the schema node.
|
|
19
19
|
* @param node - The object from the JSON-LD to use as a node.
|
|
@@ -21,7 +21,7 @@ export declare class JSONLDParser {
|
|
|
21
21
|
* @param [parentPath] - The JSON-LD path of the parent property (the string is empty for root nodes).
|
|
22
22
|
* @return The schema node.
|
|
23
23
|
*/
|
|
24
|
-
setSchemaNode
|
|
24
|
+
private setSchemaNode;
|
|
25
25
|
/**
|
|
26
26
|
* Parses the JSON-LD data.
|
|
27
27
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SCHEMA_ORG_URL_EXTACT_PATTERN } from "../constants.js";
|
|
1
2
|
export class JSONLDParser {
|
|
2
3
|
jsonLD;
|
|
3
4
|
/**
|
|
@@ -14,7 +15,7 @@ export class JSONLDParser {
|
|
|
14
15
|
* @param parentPath - The JSON-LD path of the parent property.
|
|
15
16
|
* @return The schema value.
|
|
16
17
|
*/
|
|
17
|
-
setSchemaValue
|
|
18
|
+
setSchemaValue(value, index, parentPath) {
|
|
18
19
|
const parentPathWithIndex = `${parentPath}[${index}]`;
|
|
19
20
|
if (typeof value === "object" && value !== null) {
|
|
20
21
|
if ("@value" in value) {
|
|
@@ -42,7 +43,7 @@ export class JSONLDParser {
|
|
|
42
43
|
},
|
|
43
44
|
value: String(value)
|
|
44
45
|
};
|
|
45
|
-
}
|
|
46
|
+
}
|
|
46
47
|
/**
|
|
47
48
|
* Sets the schema node.
|
|
48
49
|
* @param node - The object from the JSON-LD to use as a node.
|
|
@@ -50,7 +51,7 @@ export class JSONLDParser {
|
|
|
50
51
|
* @param [parentPath] - The JSON-LD path of the parent property (the string is empty for root nodes).
|
|
51
52
|
* @return The schema node.
|
|
52
53
|
*/
|
|
53
|
-
setSchemaNode
|
|
54
|
+
setSchemaNode(node, index, parentPath = "") {
|
|
54
55
|
const nodePath = `${parentPath}[${index}]`;
|
|
55
56
|
const type = typeof node["@type"] === "string" ? node["@type"] : "Thing";
|
|
56
57
|
const id = typeof node["@id"] === "string" ? node["@id"] : undefined;
|
|
@@ -71,7 +72,7 @@ export class JSONLDParser {
|
|
|
71
72
|
jsonLDPath: nodePath
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
|
-
}
|
|
75
|
+
}
|
|
75
76
|
/**
|
|
76
77
|
* Parses the JSON-LD data.
|
|
77
78
|
*
|
|
@@ -85,7 +86,7 @@ export class JSONLDParser {
|
|
|
85
86
|
const nodes = (Array.isArray(parsedJSONLD) ? parsedJSONLD : [parsedJSONLD])
|
|
86
87
|
.filter(node => "@context" in node &&
|
|
87
88
|
typeof node["@context"] === "string" &&
|
|
88
|
-
node["@context"].match(
|
|
89
|
+
node["@context"].match(SCHEMA_ORG_URL_EXTACT_PATTERN))
|
|
89
90
|
.map(node => node);
|
|
90
91
|
const roots = nodes.flatMap((value, index) => this.setSchemaNode(value, index));
|
|
91
92
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-ld-parser.js","sourceRoot":"","sources":["../../src/format-parsers/json-ld-parser.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAY;IACN,MAAM,CAAS;IAEhC;;;OAGG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;
|
|
1
|
+
{"version":3,"file":"json-ld-parser.js","sourceRoot":"","sources":["../../src/format-parsers/json-ld-parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,OAAO,YAAY;IACN,MAAM,CAAS;IAEhC;;;OAGG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MA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AAQ;YACpC,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CACxD;aACA,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAkB,CAAC,CAAC;QACnC,MAAM,KAAK,GAAiB,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9F,OAAO;YACL,KAAK;SACN,CAAC;IACJ,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type SchemataValidatorOptions = {
|
|
|
8
8
|
export type JSONLDData = Record<string, unknown>;
|
|
9
9
|
type SourceLocation = {
|
|
10
10
|
jsonLDPath?: string;
|
|
11
|
+
startLine?: number;
|
|
12
|
+
startColumn?: number;
|
|
11
13
|
};
|
|
12
14
|
type LiteralSchemaValue = {
|
|
13
15
|
kind: "literal";
|
|
@@ -41,8 +43,12 @@ export interface PropertyDefinition extends ClassDefinition {
|
|
|
41
43
|
}
|
|
42
44
|
export type ValidationResult = {
|
|
43
45
|
type: "error" | "warning";
|
|
44
|
-
path: string;
|
|
45
46
|
message: string;
|
|
47
|
+
path?: string;
|
|
48
|
+
location?: {
|
|
49
|
+
line: number;
|
|
50
|
+
column: number;
|
|
51
|
+
};
|
|
46
52
|
};
|
|
47
53
|
interface ValidationReportingCommonProperties {
|
|
48
54
|
resource: string;
|
|
@@ -24,13 +24,18 @@ export const displayReporting = (reporting, timestamp) => {
|
|
|
24
24
|
}
|
|
25
25
|
if (result) {
|
|
26
26
|
for (const reportingMessage of result) {
|
|
27
|
-
const { type, path,
|
|
27
|
+
const { type, message, path, location } = reportingMessage;
|
|
28
28
|
if (type === "error") {
|
|
29
29
|
console.error("\x1b[1;31mError:\x1b[0m", message);
|
|
30
30
|
}
|
|
31
31
|
else
|
|
32
32
|
console.warn("\x1b[1;33mWarning:\x1b[0m", message);
|
|
33
|
-
|
|
33
|
+
if (path)
|
|
34
|
+
console.info(path);
|
|
35
|
+
if (location) {
|
|
36
|
+
const { line, column } = location;
|
|
37
|
+
console.info(`line ${line}, column ${column}`);
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
console.groupEnd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-reporting.js","sourceRoot":"","sources":["../../src/utils/display-reporting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAA8B,EAAE,SAAiB,EAAQ,EAAE;IAC1F,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/C,MAAM,UAAU,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC3D,MAAM,YAAY,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;QAC9C,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACrB,OAAO,CAAC,KAAK,CAAC,IAAI,QAAQ,GAAG,EAAE,IAAI,cAAc,GAAG,EAAE,QAAQ,CAAC,CAAC;IAChE,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CACV,UAAU,YAAY,IAAI,UAAU,IAAI,MAAM,SAAS,EACvD,cAAc,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CACzC,CAAC;IACJ,CAAC;SAAM,CAAC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AAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,UAAU,YAAY,IAAI,UAAU,IAAI,MAAM,SAAS,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,MAAM,gBAAgB,IAAI,MAAM,EAAE,CAAC;YACtC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC;YAC3D,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACrB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;YACpD,CAAC;;gBAAM,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;YAC1D,IAAI,IAAI;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;gBAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,YAAY,MAAM,EAAE,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,QAAQ,EAAE,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -6,17 +6,20 @@ import { cwd } from "node:process";
|
|
|
6
6
|
* @return The prepared reporting.
|
|
7
7
|
*/
|
|
8
8
|
export const prepareReporting = (resource, result) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
9
|
+
const reportedResource = resource.match(/\.html?$/)
|
|
10
|
+
? resource.replace(`${cwd()}/`, "")
|
|
11
|
+
: resource;
|
|
13
12
|
if (result.length) {
|
|
14
|
-
reporting.result = result;
|
|
15
13
|
const hasErrorMessages = result.some(resultItem => resultItem.type === "error");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
return {
|
|
15
|
+
status: hasErrorMessages ? "fail" : "pass",
|
|
16
|
+
resource: reportedResource,
|
|
17
|
+
result
|
|
18
|
+
};
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
status: "pass",
|
|
22
|
+
resource: reportedResource
|
|
23
|
+
};
|
|
21
24
|
};
|
|
22
25
|
//# sourceMappingURL=prepare-reporting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-reporting.js","sourceRoot":"","sources":["../../src/utils/prepare-reporting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAgB,EAChB,MAA0B,EACL,EAAE;IACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"prepare-reporting.js","sourceRoot":"","sources":["../../src/utils/prepare-reporting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAgB,EAChB,MAA0B,EACL,EAAE;IACvB,MAAM,gBAAgB,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;QACjD,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;QACnC,CAAC,CAAC,QAAQ,CAAC;IACb,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;QAChF,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAC1C,QAAQ,EAAE,gBAAgB;YAC1B,MAAM;SACP,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,gBAAgB;KAC3B,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SchemaGraph, ValidationResult } from "../types.js";
|
|
2
2
|
export declare class SchemaGraphValidator {
|
|
3
3
|
private readonly schemaGraph;
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ export declare class SchemaGraphValidator {
|
|
|
11
11
|
* @param type - The type of the class.
|
|
12
12
|
* @return The class definition if it exists, `null` otherwise.
|
|
13
13
|
*/
|
|
14
|
-
getClassDefinition
|
|
14
|
+
private getClassDefinition;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the property definition from the property.
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@ export declare class SchemaGraphValidator {
|
|
|
19
19
|
* @param property - The property.
|
|
20
20
|
* @return The property definition if it exists, `null` otherwise.
|
|
21
21
|
*/
|
|
22
|
-
getPropertyDefinition
|
|
22
|
+
private getPropertyDefinition;
|
|
23
23
|
/**
|
|
24
24
|
* Gets the extended classes from the type.
|
|
25
25
|
* @param type - The type of the class.
|
|
@@ -32,13 +32,13 @@ export declare class SchemaGraphValidator {
|
|
|
32
32
|
* @param schemaValues - The schema values to validate.
|
|
33
33
|
* @return An array of validation reports.
|
|
34
34
|
*/
|
|
35
|
-
validateValues
|
|
35
|
+
private validateValues;
|
|
36
36
|
/**
|
|
37
37
|
* Validates the schema node.
|
|
38
38
|
* @param node - The schema node to validate.
|
|
39
39
|
* @return An array of validation reports.
|
|
40
40
|
*/
|
|
41
|
-
validateNode
|
|
41
|
+
private validateNode;
|
|
42
42
|
/**
|
|
43
43
|
* Validates the schema graph.
|
|
44
44
|
*/
|
|
@@ -69,22 +69,32 @@ export class SchemaGraphValidator {
|
|
|
69
69
|
const propertyDefinition = this.getPropertyDefinition(property);
|
|
70
70
|
for (const schemaValue of schemaValues) {
|
|
71
71
|
const { kind } = schemaValue;
|
|
72
|
-
const
|
|
72
|
+
const location = kind === "node" ? schemaValue.linkLocation : schemaValue.location;
|
|
73
|
+
const { jsonLDPath, startLine: line, startColumn: column } = location;
|
|
74
|
+
const htmlLocation = line && column ? { line, column } : undefined;
|
|
73
75
|
if (propertyDefinition) {
|
|
74
76
|
const { isPending, supersededBy } = propertyDefinition;
|
|
75
77
|
if (supersededBy) {
|
|
76
|
-
|
|
78
|
+
const validationResult = {
|
|
77
79
|
type: "error",
|
|
78
|
-
path: jsonLDPath ?? "",
|
|
79
80
|
message: `The property \`${property}\` has been superseded: use \`${supersededBy}\` instead.`
|
|
80
|
-
}
|
|
81
|
+
};
|
|
82
|
+
if (jsonLDPath)
|
|
83
|
+
validationResult.path = jsonLDPath;
|
|
84
|
+
if (htmlLocation)
|
|
85
|
+
validationResult.location = htmlLocation;
|
|
86
|
+
result.push(validationResult);
|
|
81
87
|
}
|
|
82
88
|
if (isPending) {
|
|
83
|
-
|
|
89
|
+
const validationResult = {
|
|
84
90
|
type: "warning",
|
|
85
|
-
path: jsonLDPath ?? "",
|
|
86
91
|
message: `The property \`${property}\` is part of terms which are not yet part of the Schema.org vocabulary. Pending terms are subject to change and should be used with caution.`
|
|
87
|
-
}
|
|
92
|
+
};
|
|
93
|
+
if (jsonLDPath)
|
|
94
|
+
validationResult.path = jsonLDPath;
|
|
95
|
+
if (htmlLocation)
|
|
96
|
+
validationResult.location = htmlLocation;
|
|
97
|
+
result.push(validationResult);
|
|
88
98
|
}
|
|
89
99
|
if (kind === "node") {
|
|
90
100
|
const { node } = schemaValue;
|
|
@@ -92,21 +102,29 @@ export class SchemaGraphValidator {
|
|
|
92
102
|
const { type: typesInPropertyDefinition } = propertyDefinition;
|
|
93
103
|
const extendsTypes = this.getExtendedClasses(type)?.some(className => typesInPropertyDefinition?.includes(className));
|
|
94
104
|
if (!typesInPropertyDefinition?.includes(type) && !extendsTypes) {
|
|
95
|
-
|
|
105
|
+
const validationResult = {
|
|
96
106
|
type: "error",
|
|
97
|
-
path: jsonLDPath ?? "",
|
|
98
107
|
message: `\`${type}\` is not a valid type for the property \`${property}\`.`
|
|
99
|
-
}
|
|
108
|
+
};
|
|
109
|
+
if (jsonLDPath)
|
|
110
|
+
validationResult.path = jsonLDPath;
|
|
111
|
+
if (htmlLocation)
|
|
112
|
+
validationResult.location = htmlLocation;
|
|
113
|
+
result.push(validationResult);
|
|
100
114
|
}
|
|
101
115
|
result.push(...this.validateNode(node));
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
118
|
else {
|
|
105
|
-
|
|
119
|
+
const validationResult = {
|
|
106
120
|
type: "error",
|
|
107
|
-
path: jsonLDPath ?? "",
|
|
108
121
|
message: `The property \`${property}\` does not exist in the Schema.org vocabulary.`
|
|
109
|
-
}
|
|
122
|
+
};
|
|
123
|
+
if (jsonLDPath)
|
|
124
|
+
validationResult.path = jsonLDPath;
|
|
125
|
+
if (htmlLocation)
|
|
126
|
+
validationResult.location = htmlLocation;
|
|
127
|
+
result.push(validationResult);
|
|
110
128
|
}
|
|
111
129
|
}
|
|
112
130
|
return result;
|
|
@@ -117,35 +135,47 @@ export class SchemaGraphValidator {
|
|
|
117
135
|
* @return An array of validation reports.
|
|
118
136
|
*/
|
|
119
137
|
validateNode(node) {
|
|
120
|
-
const { type, location: { jsonLDPath }, properties } = node;
|
|
138
|
+
const { type, location: { jsonLDPath, startLine: line, startColumn: column }, properties } = node;
|
|
121
139
|
const result = [];
|
|
122
140
|
const classDefinition = this.getClassDefinition(type);
|
|
123
141
|
if (classDefinition) {
|
|
124
142
|
const { isPending, supersededBy } = classDefinition;
|
|
125
143
|
if (supersededBy) {
|
|
126
|
-
|
|
144
|
+
const validationResult = {
|
|
127
145
|
type: "error",
|
|
128
|
-
path: jsonLDPath ?? "",
|
|
129
146
|
message: `The type \`${type}\` has been superseded: use \`${supersededBy}\` instead.`
|
|
130
|
-
}
|
|
147
|
+
};
|
|
148
|
+
if (jsonLDPath)
|
|
149
|
+
validationResult.path = jsonLDPath;
|
|
150
|
+
if (line && column)
|
|
151
|
+
validationResult.location = { line, column };
|
|
152
|
+
result.push(validationResult);
|
|
131
153
|
}
|
|
132
154
|
if (isPending) {
|
|
133
|
-
|
|
155
|
+
const validationResult = {
|
|
134
156
|
type: "warning",
|
|
135
|
-
path: jsonLDPath ?? "",
|
|
136
157
|
message: `The type \`${type}\` is part of terms which are not yet part of the Schema.org vocabulary. Pending terms are subject to change and should be used with caution.`
|
|
137
|
-
}
|
|
158
|
+
};
|
|
159
|
+
if (jsonLDPath)
|
|
160
|
+
validationResult.path = jsonLDPath;
|
|
161
|
+
if (line && column)
|
|
162
|
+
validationResult.location = { line, column };
|
|
163
|
+
result.push(validationResult);
|
|
138
164
|
}
|
|
139
165
|
for (const [property, schemaValues] of properties) {
|
|
140
166
|
result.push(...this.validateValues(property, schemaValues));
|
|
141
167
|
}
|
|
142
168
|
}
|
|
143
169
|
else {
|
|
144
|
-
|
|
170
|
+
const validationResult = {
|
|
145
171
|
type: "error",
|
|
146
|
-
path: jsonLDPath ?? "",
|
|
147
172
|
message: `The type \`${type}\` does not exist in the Schema.org vocabulary.`
|
|
148
|
-
}
|
|
173
|
+
};
|
|
174
|
+
if (jsonLDPath)
|
|
175
|
+
validationResult.path = jsonLDPath;
|
|
176
|
+
if (line && column)
|
|
177
|
+
validationResult.location = { line, column };
|
|
178
|
+
result.push(validationResult);
|
|
149
179
|
}
|
|
150
180
|
return result;
|
|
151
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-graph-validator.js","sourceRoot":"","sources":["../../src/validator/schema-graph-validator.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,UAAU,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE1E,MAAM,OAAO,oBAAoB;IACd,WAAW,CAAc;IAE1C;;;OAGG;IACH,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;OAIG;
|
|
1
|
+
{"version":3,"file":"schema-graph-validator.js","sourceRoot":"","sources":["../../src/validator/schema-graph-validator.ts"],"names":[],"mappings":"AASA,OAAO,OAAO,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,UAAU,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE1E,MAAM,OAAO,oBAAoB;IACd,WAAW,CAAc;IAE1C;;;OAGG;IACH,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACK,kBAAkB,CAAC,IAAY;QACrC,IAAI,IAAI,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC,IAA4B,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACK,qBAAqB,CAAC,QAAgB;QAC5C,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QACnD,IAAI,QAAQ,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC,QAAmC,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,IAAY;QAC7B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;QACrC,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,eAAe,CAAC;YACpD,IAAI,cAAc,EAAE,CAAC;gBACnB,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;oBACvC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;oB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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "schemata-validator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Check the validity of Schema.org vocabulary used in JSON-LD data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json-ld",
|
|
@@ -35,14 +35,17 @@
|
|
|
35
35
|
"npm": ">=10.8.2",
|
|
36
36
|
"pnpm": ">=10.32.1"
|
|
37
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"parse5": "8.0.0"
|
|
40
|
+
},
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"@biomejs/biome": "2.4.
|
|
42
|
+
"@biomejs/biome": "2.4.9",
|
|
40
43
|
"@commitlint/cli": "20.5.0",
|
|
41
44
|
"@commitlint/config-conventional": "20.5.0",
|
|
42
45
|
"@types/node": "24.12.0",
|
|
43
46
|
"husky": "9.1.7",
|
|
44
|
-
"typescript": "
|
|
45
|
-
"vitest": "4.1.
|
|
47
|
+
"typescript": "6.0.2",
|
|
48
|
+
"vitest": "4.1.2"
|
|
46
49
|
},
|
|
47
50
|
"scripts": {
|
|
48
51
|
"biome": "biome check --write .",
|