schemata-validator 0.1.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -0
  3. package/bin/cli.js +5 -0
  4. package/data/classes.json +3748 -0
  5. package/data/properties.json +8274 -0
  6. package/dist/cli.d.ts +4 -0
  7. package/dist/cli.js +24 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/constants.d.ts +46 -0
  10. package/dist/constants.js +47 -0
  11. package/dist/constants.js.map +1 -0
  12. package/dist/format-parsers/html-parser.d.ts +15 -0
  13. package/dist/format-parsers/html-parser.js +32 -0
  14. package/dist/format-parsers/html-parser.js.map +1 -0
  15. package/dist/format-parsers/json-ld-parser.d.ts +34 -0
  16. package/dist/format-parsers/json-ld-parser.js +96 -0
  17. package/dist/format-parsers/json-ld-parser.js.map +1 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.js +3 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/schemata-validator.d.ts +19 -0
  22. package/dist/schemata-validator.js +69 -0
  23. package/dist/schemata-validator.js.map +1 -0
  24. package/dist/types.d.ts +59 -0
  25. package/dist/types.js +2 -0
  26. package/dist/types.js.map +1 -0
  27. package/dist/utils/browse-folders.d.ts +6 -0
  28. package/dist/utils/browse-folders.js +18 -0
  29. package/dist/utils/browse-folders.js.map +1 -0
  30. package/dist/utils/display-cli-flags.d.ts +5 -0
  31. package/dist/utils/display-cli-flags.js +24 -0
  32. package/dist/utils/display-cli-flags.js.map +1 -0
  33. package/dist/utils/display-reporting.d.ts +7 -0
  34. package/dist/utils/display-reporting.js +38 -0
  35. package/dist/utils/display-reporting.js.map +1 -0
  36. package/dist/utils/dry-run-notice.d.ts +4 -0
  37. package/dist/utils/dry-run-notice.js +8 -0
  38. package/dist/utils/dry-run-notice.js.map +1 -0
  39. package/dist/utils/get-file-content.d.ts +6 -0
  40. package/dist/utils/get-file-content.js +10 -0
  41. package/dist/utils/get-file-content.js.map +1 -0
  42. package/dist/utils/get-files-to-validate.d.ts +9 -0
  43. package/dist/utils/get-files-to-validate.js +37 -0
  44. package/dist/utils/get-files-to-validate.js.map +1 -0
  45. package/dist/utils/parse-args.d.ts +7 -0
  46. package/dist/utils/parse-args.js +47 -0
  47. package/dist/utils/parse-args.js.map +1 -0
  48. package/dist/utils/pattern-to-regex.d.ts +6 -0
  49. package/dist/utils/pattern-to-regex.js +15 -0
  50. package/dist/utils/pattern-to-regex.js.map +1 -0
  51. package/dist/utils/prepare-reporting.d.ts +8 -0
  52. package/dist/utils/prepare-reporting.js +22 -0
  53. package/dist/utils/prepare-reporting.js.map +1 -0
  54. package/dist/utils/show-help.d.ts +4 -0
  55. package/dist/utils/show-help.js +13 -0
  56. package/dist/utils/show-help.js.map +1 -0
  57. package/dist/utils/show-version.d.ts +4 -0
  58. package/dist/utils/show-version.js +8 -0
  59. package/dist/utils/show-version.js.map +1 -0
  60. package/dist/validator/schema-graph-validator.d.ts +46 -0
  61. package/dist/validator/schema-graph-validator.js +164 -0
  62. package/dist/validator/schema-graph-validator.js.map +1 -0
  63. package/package.json +60 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Victor Brito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # schemata-validator
2
+
3
+ Check the validity of Schema.org vocabulary used in JSON-LD data
4
+
5
+ ![License: MIT](https://img.shields.io/github/license/webdevbynight/schemata-validator)
6
+ [![ESM-only package](https://img.shields.io/badge/package-ESM--only-ffe536)](https://nodejs.org/api/esm.html)
7
+ [![Conventional Commits 1.0.0](https://img.shields.io/badge/Conventional_Commits-1.0.0-fe5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
8
+ [![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev)
9
+ [![Released with release-change](https://img.shields.io/badge/Released_with-release--change-8d8d8d)](https://github.com/release-change/release-change)
10
+ ![NPM latest version](https://img.shields.io/npm/v/schemata-validator/latest)
11
+ ![Node support](https://img.shields.io/node/v/schemata-validator)
12
+ ![Build status](https://img.shields.io/github/actions/workflow/status/webdevbynight/schemata-validator/run-tests.yml)
13
+
14
+ **schemata-validator** takes JSON-LD and HTML files using JSON-LD data and returns detailed validation results.
15
+
16
+ ## Installation
17
+
18
+ Install package for Node.js:
19
+ ```
20
+ pnpm add --save-dev schemata-validator
21
+ ```
22
+ You can also install it using `npm`:
23
+ ```
24
+ npm install --save-dev schemata-validator
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Options
30
+
31
+ ##### data
32
+
33
+ Type: `array`
34
+
35
+ Specifies which JSON-LD data to be sent to validation. This option takes precedence over the other options.
36
+
37
+ ##### files
38
+
39
+ Type: `array`
40
+ CLI arguments: `-f <space-separated list of files>`, `--files <space-separated list of files>`
41
+
42
+ Specifies which files to be sent to validation. This option takes precedence over the other options.
43
+
44
+ ##### paths
45
+
46
+ Type: `array`
47
+ CLI arguments: `-p <space-separated list of paths>`, `--paths <space-separated list of paths>`
48
+
49
+ Specifies which folders or files to be sent to validation. When omitted, all files are validated (skipping the `node_modules` folder), unless the `exclude` option is specified.
50
+
51
+ ##### exclude
52
+
53
+ Type: `array`
54
+ CLI arguments: `-e <space-separated list of paths>`, `--exclude <space-separated list of paths>`
55
+
56
+ Lists strings to match in paths to skip. When omitted, all files specified by `files` options if defined (all files otherwise) are validated (skipping the `node_modules` folder).
57
+
58
+ ##### dryRun
59
+
60
+ Type: `boolean`
61
+ Default: `false`
62
+ CLI arguments: `-d`, `--dry-run`
63
+
64
+ Bypasses the validation (for usage while building CI).
65
+
66
+ ### CLI
67
+
68
+ schemata-validator can be used as a CLI tool.
69
+
70
+ ```
71
+ schemata-validator [flags]
72
+ ```
73
+
74
+ #### `package.json` scripts
75
+
76
+ You can run `schemata-validator` from the `scripts` section of your `package.json` file.
77
+
78
+ ```json
79
+ {
80
+ "scripts": {
81
+ "one-folder": "schemata-validator --paths docs",
82
+ "one-file": "schemata-validator --files docs/index.html",
83
+ "all-files": "schemata-validator"
84
+ }
85
+ }
86
+ ```
87
+
88
+ #### Examples
89
+
90
+ - `schemata-validator`: validates all HTML files using JSON-LD data in the project;
91
+ - `schemata-validator --paths docs --exclude build tmp`: validates all HTML files using JSON-LD data in the `docs/` folder, except files which have `build` or `tmp` anywhere in their pathname or filename;
92
+ - `schemata-validator --files docs/index.html`: validates only the specified files.
93
+
94
+ ### Application code
95
+
96
+ In addition to the CLI interface, schemata-validator can be imported and called in ESM and TypeScript projects.
97
+
98
+ ```js
99
+ import { SchemataValidator } from "schemata-validator";
100
+
101
+ const jsonld = `{
102
+ "@context": "https://schema.org",
103
+ "@type": "WebPage",
104
+ "name": "Web page title",
105
+ "description": "Web page description"
106
+ }`;
107
+ const options = { data: [jsonld] };
108
+ const validator = new SchemataValidator(options);
109
+ const validate = await validator.validate();
110
+ validator.log(validate); // Outputs the reporting object
111
+ ```
112
+
113
+ ## Get help
114
+
115
+ - [Stack Overflow](https://stackoverflow.com/questions/tagged/schemata-validator)
116
+
117
+ ## Copyright & licence
118
+
119
+ © 2026 Victor Brito — Released under the [MIT licence](./LICENSE).
package/bin/cli.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cli } from "../dist/index.js";
4
+
5
+ await cli();