@jentic/arazzo-validator 1.0.0-alpha.24 → 1.0.0-alpha.26

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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +4 -5
  3. package/src/cli/formatters/codeframe.cjs +92 -0
  4. package/src/cli/formatters/codeframe.mjs +87 -0
  5. package/src/cli/formatters/github-actions.cjs +47 -0
  6. package/src/cli/formatters/github-actions.mjs +43 -0
  7. package/src/cli/formatters/index.cjs +12 -0
  8. package/src/cli/formatters/index.mjs +4 -0
  9. package/src/cli/formatters/json.cjs +20 -0
  10. package/src/cli/formatters/json.mjs +16 -0
  11. package/src/cli/formatters/stylish.cjs +76 -0
  12. package/src/cli/formatters/stylish.mjs +69 -0
  13. package/src/cli/index.cjs +159 -0
  14. package/src/cli/index.mjs +154 -0
  15. package/src/config/arazzo/arazzo/lint/index.cjs +8 -0
  16. package/src/config/arazzo/arazzo/lint/index.mjs +3 -0
  17. package/src/config/arazzo/arazzo/lint/value--pattern-1-0-X.cjs +30 -0
  18. package/src/config/arazzo/arazzo/lint/value--pattern-1-0-X.mjs +25 -0
  19. package/src/config/arazzo/arazzo/meta.cjs +10 -0
  20. package/src/config/arazzo/arazzo/meta.mjs +5 -0
  21. package/src/config/arazzo/arazzo-specification-1/lint/allowed-fields.cjs +18 -0
  22. package/src/config/arazzo/arazzo-specification-1/lint/allowed-fields.mjs +14 -0
  23. package/src/config/arazzo/arazzo-specification-1/lint/index.cjs +11 -0
  24. package/src/config/arazzo/arazzo-specification-1/lint/index.mjs +6 -0
  25. package/src/config/arazzo/arazzo-specification-1/lint/info--required.cjs +27 -0
  26. package/src/config/arazzo/arazzo-specification-1/lint/info--required.mjs +22 -0
  27. package/src/config/arazzo/arazzo-specification-1/lint/info--type.cjs +21 -0
  28. package/src/config/arazzo/arazzo-specification-1/lint/info--type.mjs +16 -0
  29. package/src/config/arazzo/arazzo-specification-1/lint/required-fields.cjs +44 -0
  30. package/src/config/arazzo/arazzo-specification-1/lint/required-fields.mjs +39 -0
  31. package/src/config/arazzo/arazzo-specification-1/meta.cjs +10 -0
  32. package/src/config/arazzo/arazzo-specification-1/meta.mjs +5 -0
  33. package/src/config/arazzo/config.cjs +23 -0
  34. package/src/config/arazzo/config.mjs +18 -0
  35. package/src/config/arazzo/target-specs.cjs +32 -0
  36. package/src/config/arazzo/target-specs.mjs +28 -0
  37. package/src/config/codes.cjs +17 -0
  38. package/src/config/codes.mjs +13 -0
  39. package/src/config/config.cjs +19 -0
  40. package/src/config/config.mjs +14 -0
  41. package/src/document.cjs +32 -0
  42. package/src/document.mjs +28 -0
  43. package/src/index.cjs +18 -0
  44. package/src/index.mjs +5 -0
  45. package/src/validators/json-schema-provider.cjs +25 -0
  46. package/src/validators/json-schema-provider.mjs +21 -0
  47. package/src/validators/validate-uri.cjs +72 -0
  48. package/src/validators/validate-uri.mjs +67 -0
  49. package/src/validators/validate.cjs +85 -0
  50. package/src/validators/validate.mjs +80 -0
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.formatDiagnostics = formatDiagnostics;
6
+ exports.hasFailures = hasFailures;
7
+ exports.main = main;
8
+ exports.severityMap = void 0;
9
+ var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard"));
10
+ var _nodeFs = require("node:fs");
11
+ var _commander = require("commander");
12
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
13
+ var _validateUri = require("../validators/validate-uri.cjs");
14
+ var _validate = require("../validators/validate.cjs");
15
+ var _document = require("../document.cjs");
16
+ var _index = require("./formatters/index.cjs");
17
+ const severityMap = exports.severityMap = {
18
+ error: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
19
+ warning: _vscodeLanguageserverTypes.DiagnosticSeverity.Warning,
20
+ info: _vscodeLanguageserverTypes.DiagnosticSeverity.Information,
21
+ hint: _vscodeLanguageserverTypes.DiagnosticSeverity.Hint
22
+ };
23
+ function formatDiagnostics(format, filePath, diagnostics, options = {}) {
24
+ switch (format) {
25
+ case 'codeframe':
26
+ return (0, _index.formatCodeframe)(filePath, diagnostics, options);
27
+ case 'json':
28
+ return (0, _index.formatJSON)(filePath, diagnostics, options);
29
+ case 'github-actions':
30
+ return (0, _index.formatGitHubActions)(filePath, diagnostics, options);
31
+ case 'stylish':
32
+ default:
33
+ return (0, _index.formatStylish)(filePath, diagnostics, options);
34
+ }
35
+ }
36
+ function hasFailures(diagnostics, failSeverity) {
37
+ const threshold = severityMap[failSeverity];
38
+ return diagnostics.some(d => d.severity !== undefined && d.severity <= threshold);
39
+ }
40
+ function parseMaxProblems(value) {
41
+ const parsed = Number.parseInt(value, 10);
42
+ if (Number.isNaN(parsed) || parsed < 0) {
43
+ throw new _commander.InvalidArgumentError('Must be a non-negative integer.');
44
+ }
45
+ return parsed;
46
+ }
47
+ async function readStdin() {
48
+ const chunks = [];
49
+ return new Promise((resolve, reject) => {
50
+ process.stdin.on('data', chunk => {
51
+ if (typeof chunk === 'string') {
52
+ chunks.push(Buffer.from(chunk));
53
+ } else {
54
+ chunks.push(chunk);
55
+ }
56
+ });
57
+ process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
58
+ process.stdin.on('error', reject);
59
+ });
60
+ }
61
+ async function runValidation(file, options) {
62
+ let diagnostics;
63
+ let filePath;
64
+ let sourceContent;
65
+ if (options.stdinRetrievalUri) {
66
+ // read from stdin
67
+ sourceContent = await readStdin();
68
+ filePath = options.stdinRetrievalUri;
69
+ const textDocument = (0, _document.createTextDocument)(filePath, sourceContent);
70
+ diagnostics = await (0, _validate.validate)(textDocument);
71
+ } else if (file) {
72
+ // validate file/URL
73
+ filePath = file;
74
+ diagnostics = await (0, _validateUri.validateURI)(file);
75
+ // try to read file content for code snippets (only for local files)
76
+ if (!file.startsWith('http://') && !file.startsWith('https://')) {
77
+ try {
78
+ sourceContent = (0, _nodeFs.readFileSync)(file, 'utf-8');
79
+ } catch {
80
+ // ignore - file might not be readable
81
+ }
82
+ }
83
+ } else {
84
+ throw new Error('No input provided. Specify a file or use --stdin-retrieval-uri');
85
+ }
86
+ return {
87
+ diagnostics,
88
+ filePath,
89
+ sourceContent
90
+ };
91
+ }
92
+ async function main(argv = process.argv) {
93
+ // dynamic import for package.json to get version
94
+ const pkg = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('../../package.json')));
95
+ _commander.program.name('arazzo-validator').description('Validate and lint Arazzo Specification documents').version(pkg.default.version).exitOverride(err => {
96
+ if (err.code === 'commander.invalidArgument') {
97
+ process.exitCode = 2;
98
+ }
99
+ throw err;
100
+ }).argument('[file]', 'File path or URL to validate').option('--stdin-retrieval-uri <uri>', 'Read from stdin, use URI for reference resolution').addOption(new _commander.Option('-f, --format <format>', 'Output format').choices(['stylish', 'codeframe', 'json', 'github-actions']).default('stylish')).option('-o, --output <file>', 'Write output to file instead of stdout').addOption(new _commander.Option('--fail-severity <level>', 'Minimum severity to trigger failure').choices(['error', 'warning', 'info', 'hint']).default('error')).option('--max-problems <n>', 'Limit output to N problems', parseMaxProblems).option('-q, --quiet', 'Suppress output, only return exit code', false).option('-v, --verbose', 'Show additional information', false).action(async (file, opts) => {
101
+ try {
102
+ if (opts.verbose) {
103
+ console.error(`Validating: ${file ?? opts.stdinRetrievalUri ?? 'stdin'}`);
104
+ }
105
+ const startTime = performance.now();
106
+ const {
107
+ diagnostics,
108
+ filePath,
109
+ sourceContent
110
+ } = await runValidation(file, opts);
111
+ const duration = performance.now() - startTime;
112
+ if (opts.verbose) {
113
+ const errorCount = diagnostics.filter(d => d.severity === _vscodeLanguageserverTypes.DiagnosticSeverity.Error).length;
114
+ const warningCount = diagnostics.filter(d => d.severity === _vscodeLanguageserverTypes.DiagnosticSeverity.Warning).length;
115
+ console.error(`Completed in ${(duration / 1000).toFixed(2)}s`);
116
+ console.error(`Found ${diagnostics.length} problems (${errorCount} errors, ${warningCount} warnings)`);
117
+ }
118
+
119
+ // format output
120
+ const output = formatDiagnostics(opts.format, filePath, diagnostics, {
121
+ maxProblems: opts.maxProblems,
122
+ sourceContent
123
+ });
124
+
125
+ // write output
126
+ if (!opts.quiet && output) {
127
+ if (opts.output) {
128
+ (0, _nodeFs.writeFileSync)(opts.output, output);
129
+ if (opts.verbose) {
130
+ console.error(`Output written to ${opts.output}`);
131
+ }
132
+ } else {
133
+ console.log(output);
134
+ }
135
+ }
136
+
137
+ // exit code based on fail severity
138
+ const failed = hasFailures(diagnostics, opts.failSeverity);
139
+ if (failed) {
140
+ process.exitCode = 1;
141
+ } else if (!opts.quiet && (opts.format === 'stylish' || opts.format === 'codeframe')) {
142
+ // show success message for human-readable formats only
143
+ console.log(`No results with a severity of '${opts.failSeverity}' or higher found!`);
144
+ }
145
+ } catch (error) {
146
+ if (error instanceof Error) {
147
+ console.error(`Error: ${error.message}`);
148
+ } else {
149
+ console.error('An unexpected error occurred');
150
+ }
151
+ process.exitCode = 2;
152
+ }
153
+ });
154
+ try {
155
+ await _commander.program.parseAsync(argv);
156
+ } catch {
157
+ // exitOverride throws - error already handled, exit code already set
158
+ }
159
+ }
@@ -0,0 +1,154 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { program, Option, InvalidArgumentError } from 'commander';
3
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
4
+ import { validateURI } from "../validators/validate-uri.mjs";
5
+ import { validate as validateDocument } from "../validators/validate.mjs";
6
+ import { createTextDocument } from "../document.mjs";
7
+ import { formatStylish, formatCodeframe, formatJSON, formatGitHubActions } from "./formatters/index.mjs";
8
+ export const severityMap = {
9
+ error: DiagnosticSeverity.Error,
10
+ warning: DiagnosticSeverity.Warning,
11
+ info: DiagnosticSeverity.Information,
12
+ hint: DiagnosticSeverity.Hint
13
+ };
14
+ export function formatDiagnostics(format, filePath, diagnostics, options = {}) {
15
+ switch (format) {
16
+ case 'codeframe':
17
+ return formatCodeframe(filePath, diagnostics, options);
18
+ case 'json':
19
+ return formatJSON(filePath, diagnostics, options);
20
+ case 'github-actions':
21
+ return formatGitHubActions(filePath, diagnostics, options);
22
+ case 'stylish':
23
+ default:
24
+ return formatStylish(filePath, diagnostics, options);
25
+ }
26
+ }
27
+ export function hasFailures(diagnostics, failSeverity) {
28
+ const threshold = severityMap[failSeverity];
29
+ return diagnostics.some(d => d.severity !== undefined && d.severity <= threshold);
30
+ }
31
+ function parseMaxProblems(value) {
32
+ const parsed = Number.parseInt(value, 10);
33
+ if (Number.isNaN(parsed) || parsed < 0) {
34
+ throw new InvalidArgumentError('Must be a non-negative integer.');
35
+ }
36
+ return parsed;
37
+ }
38
+ async function readStdin() {
39
+ const chunks = [];
40
+ return new Promise((resolve, reject) => {
41
+ process.stdin.on('data', chunk => {
42
+ if (typeof chunk === 'string') {
43
+ chunks.push(Buffer.from(chunk));
44
+ } else {
45
+ chunks.push(chunk);
46
+ }
47
+ });
48
+ process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
49
+ process.stdin.on('error', reject);
50
+ });
51
+ }
52
+ async function runValidation(file, options) {
53
+ let diagnostics;
54
+ let filePath;
55
+ let sourceContent;
56
+ if (options.stdinRetrievalUri) {
57
+ // read from stdin
58
+ sourceContent = await readStdin();
59
+ filePath = options.stdinRetrievalUri;
60
+ const textDocument = createTextDocument(filePath, sourceContent);
61
+ diagnostics = await validateDocument(textDocument);
62
+ } else if (file) {
63
+ // validate file/URL
64
+ filePath = file;
65
+ diagnostics = await validateURI(file);
66
+ // try to read file content for code snippets (only for local files)
67
+ if (!file.startsWith('http://') && !file.startsWith('https://')) {
68
+ try {
69
+ sourceContent = readFileSync(file, 'utf-8');
70
+ } catch {
71
+ // ignore - file might not be readable
72
+ }
73
+ }
74
+ } else {
75
+ throw new Error('No input provided. Specify a file or use --stdin-retrieval-uri');
76
+ }
77
+ return {
78
+ diagnostics,
79
+ filePath,
80
+ sourceContent
81
+ };
82
+ }
83
+ export async function main(argv = process.argv) {
84
+ // dynamic import for package.json to get version
85
+ const pkg = await import('../../package.json', {
86
+ with: {
87
+ type: 'json'
88
+ }
89
+ });
90
+ program.name('arazzo-validator').description('Validate and lint Arazzo Specification documents').version(pkg.default.version).exitOverride(err => {
91
+ if (err.code === 'commander.invalidArgument') {
92
+ process.exitCode = 2;
93
+ }
94
+ throw err;
95
+ }).argument('[file]', 'File path or URL to validate').option('--stdin-retrieval-uri <uri>', 'Read from stdin, use URI for reference resolution').addOption(new Option('-f, --format <format>', 'Output format').choices(['stylish', 'codeframe', 'json', 'github-actions']).default('stylish')).option('-o, --output <file>', 'Write output to file instead of stdout').addOption(new Option('--fail-severity <level>', 'Minimum severity to trigger failure').choices(['error', 'warning', 'info', 'hint']).default('error')).option('--max-problems <n>', 'Limit output to N problems', parseMaxProblems).option('-q, --quiet', 'Suppress output, only return exit code', false).option('-v, --verbose', 'Show additional information', false).action(async (file, opts) => {
96
+ try {
97
+ if (opts.verbose) {
98
+ console.error(`Validating: ${file ?? opts.stdinRetrievalUri ?? 'stdin'}`);
99
+ }
100
+ const startTime = performance.now();
101
+ const {
102
+ diagnostics,
103
+ filePath,
104
+ sourceContent
105
+ } = await runValidation(file, opts);
106
+ const duration = performance.now() - startTime;
107
+ if (opts.verbose) {
108
+ const errorCount = diagnostics.filter(d => d.severity === DiagnosticSeverity.Error).length;
109
+ const warningCount = diagnostics.filter(d => d.severity === DiagnosticSeverity.Warning).length;
110
+ console.error(`Completed in ${(duration / 1000).toFixed(2)}s`);
111
+ console.error(`Found ${diagnostics.length} problems (${errorCount} errors, ${warningCount} warnings)`);
112
+ }
113
+
114
+ // format output
115
+ const output = formatDiagnostics(opts.format, filePath, diagnostics, {
116
+ maxProblems: opts.maxProblems,
117
+ sourceContent
118
+ });
119
+
120
+ // write output
121
+ if (!opts.quiet && output) {
122
+ if (opts.output) {
123
+ writeFileSync(opts.output, output);
124
+ if (opts.verbose) {
125
+ console.error(`Output written to ${opts.output}`);
126
+ }
127
+ } else {
128
+ console.log(output);
129
+ }
130
+ }
131
+
132
+ // exit code based on fail severity
133
+ const failed = hasFailures(diagnostics, opts.failSeverity);
134
+ if (failed) {
135
+ process.exitCode = 1;
136
+ } else if (!opts.quiet && (opts.format === 'stylish' || opts.format === 'codeframe')) {
137
+ // show success message for human-readable formats only
138
+ console.log(`No results with a severity of '${opts.failSeverity}' or higher found!`);
139
+ }
140
+ } catch (error) {
141
+ if (error instanceof Error) {
142
+ console.error(`Error: ${error.message}`);
143
+ } else {
144
+ console.error('An unexpected error occurred');
145
+ }
146
+ process.exitCode = 2;
147
+ }
148
+ });
149
+ try {
150
+ await program.parseAsync(argv);
151
+ } catch {
152
+ // exitOverride throws - error already handled, exit code already set
153
+ }
154
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _valuePattern10X = _interopRequireDefault(require("./value--pattern-1-0-X.cjs"));
7
+ const lints = [_valuePattern10X.default];
8
+ var _default = exports.default = lints;
@@ -0,0 +1,3 @@
1
+ import valuePattern1_0_XLint from "./value--pattern-1-0-X.mjs";
2
+ const lints = [valuePattern1_0_XLint];
3
+ export default lints;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
7
+ var _codes = _interopRequireDefault(require("../../../codes.cjs"));
8
+ var _targetSpecs = require("../../target-specs.cjs");
9
+ const valuePattern1_0_XLint = {
10
+ code: _codes.default.ARAZZO1_ARAZZO_VALUE_PATTERN_1_0_X,
11
+ source: 'apilint',
12
+ message: "'arazzo' value must be one of 1.0.0, 1.0.1",
13
+ severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
14
+ linterFunction: 'apilintValueRegex',
15
+ linterParams: ['1\\.0\\.[01]{1}'],
16
+ marker: 'value',
17
+ data: {
18
+ quickFix: [{
19
+ message: "update to '1.0.0'",
20
+ action: 'updateValue',
21
+ functionParams: ['1.0.0']
22
+ }, {
23
+ message: "update to '1.0.1'",
24
+ action: 'updateValue',
25
+ functionParams: ['1.0.1']
26
+ }]
27
+ },
28
+ targetSpecs: _targetSpecs.Arazzo10X
29
+ };
30
+ var _default = exports.default = valuePattern1_0_XLint;
@@ -0,0 +1,25 @@
1
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
2
+ import ApilintCodes from "../../../codes.mjs";
3
+ import { Arazzo10X } from "../../target-specs.mjs";
4
+ const valuePattern1_0_XLint = {
5
+ code: ApilintCodes.ARAZZO1_ARAZZO_VALUE_PATTERN_1_0_X,
6
+ source: 'apilint',
7
+ message: "'arazzo' value must be one of 1.0.0, 1.0.1",
8
+ severity: DiagnosticSeverity.Error,
9
+ linterFunction: 'apilintValueRegex',
10
+ linterParams: ['1\\.0\\.[01]{1}'],
11
+ marker: 'value',
12
+ data: {
13
+ quickFix: [{
14
+ message: "update to '1.0.0'",
15
+ action: 'updateValue',
16
+ functionParams: ['1.0.0']
17
+ }, {
18
+ message: "update to '1.0.1'",
19
+ action: 'updateValue',
20
+ functionParams: ['1.0.1']
21
+ }]
22
+ },
23
+ targetSpecs: Arazzo10X
24
+ };
25
+ export default valuePattern1_0_XLint;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _index = _interopRequireDefault(require("./lint/index.cjs"));
7
+ const meta = {
8
+ lint: _index.default
9
+ };
10
+ var _default = exports.default = meta;
@@ -0,0 +1,5 @@
1
+ import lint from "./lint/index.mjs";
2
+ const meta = {
3
+ lint
4
+ };
5
+ export default meta;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
6
+ var _apidomLs = require("@speclynx/apidom-ls");
7
+ var _targetSpecs = require("../../target-specs.cjs");
8
+ const allowedFieldsLint = {
9
+ code: _apidomLs.ApilintCodes.NOT_ALLOWED_FIELDS,
10
+ source: 'apilint',
11
+ message: 'Object includes not allowed fields',
12
+ severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
13
+ linterFunction: 'allowedFields',
14
+ linterParams: [['arazzo', 'info', 'sourceDescriptions', 'workflows', 'components'], 'x-'],
15
+ marker: 'key',
16
+ targetSpecs: _targetSpecs.Arazzo1
17
+ };
18
+ var _default = exports.default = allowedFieldsLint;
@@ -0,0 +1,14 @@
1
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
2
+ import { ApilintCodes } from '@speclynx/apidom-ls';
3
+ import { Arazzo1 } from "../../target-specs.mjs";
4
+ const allowedFieldsLint = {
5
+ code: ApilintCodes.NOT_ALLOWED_FIELDS,
6
+ source: 'apilint',
7
+ message: 'Object includes not allowed fields',
8
+ severity: DiagnosticSeverity.Error,
9
+ linterFunction: 'allowedFields',
10
+ linterParams: [['arazzo', 'info', 'sourceDescriptions', 'workflows', 'components'], 'x-'],
11
+ marker: 'key',
12
+ targetSpecs: Arazzo1
13
+ };
14
+ export default allowedFieldsLint;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _allowedFields = _interopRequireDefault(require("./allowed-fields.cjs"));
7
+ var _requiredFields = _interopRequireDefault(require("./required-fields.cjs"));
8
+ var _infoType = _interopRequireDefault(require("./info--type.cjs"));
9
+ var _infoRequired = _interopRequireDefault(require("./info--required.cjs"));
10
+ const lints = [_allowedFields.default, _requiredFields.default, _infoType.default, _infoRequired.default];
11
+ var _default = exports.default = lints;
@@ -0,0 +1,6 @@
1
+ import allowedFieldsLint from "./allowed-fields.mjs";
2
+ import requiredFieldsLint from "./required-fields.mjs";
3
+ import infoTypeLint from "./info--type.mjs";
4
+ import infoRequiredLint from "./info--required.mjs";
5
+ const lints = [allowedFieldsLint, requiredFieldsLint, infoTypeLint, infoRequiredLint];
6
+ export default lints;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
7
+ var _codes = _interopRequireDefault(require("../../../codes.cjs"));
8
+ var _targetSpecs = require("../../target-specs.cjs");
9
+ const infoRequiredLint = {
10
+ code: _codes.default.ARAZZO1_ARAZZO_SPECIFICATION_FIELD_INFO_REQUIRED,
11
+ source: 'apilint',
12
+ message: "should always have an 'info' section",
13
+ severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
14
+ linterFunction: 'hasRequiredField',
15
+ linterParams: ['info'],
16
+ marker: 'key',
17
+ data: {
18
+ quickFix: [{
19
+ message: "add 'info' section",
20
+ action: 'addChild',
21
+ snippetYaml: 'info: \n \n',
22
+ snippetJson: '"info": {\n \n },\n'
23
+ }]
24
+ },
25
+ targetSpecs: _targetSpecs.Arazzo1
26
+ };
27
+ var _default = exports.default = infoRequiredLint;
@@ -0,0 +1,22 @@
1
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
2
+ import ApilintCodes from "../../../codes.mjs";
3
+ import { Arazzo1 } from "../../target-specs.mjs";
4
+ const infoRequiredLint = {
5
+ code: ApilintCodes.ARAZZO1_ARAZZO_SPECIFICATION_FIELD_INFO_REQUIRED,
6
+ source: 'apilint',
7
+ message: "should always have an 'info' section",
8
+ severity: DiagnosticSeverity.Error,
9
+ linterFunction: 'hasRequiredField',
10
+ linterParams: ['info'],
11
+ marker: 'key',
12
+ data: {
13
+ quickFix: [{
14
+ message: "add 'info' section",
15
+ action: 'addChild',
16
+ snippetYaml: 'info: \n \n',
17
+ snippetJson: '"info": {\n \n },\n'
18
+ }]
19
+ },
20
+ targetSpecs: Arazzo1
21
+ };
22
+ export default infoRequiredLint;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
7
+ var _codes = _interopRequireDefault(require("../../../codes.cjs"));
8
+ var _targetSpecs = require("../../target-specs.cjs");
9
+ const infoTypeLint = {
10
+ code: _codes.default.ARAZZO1_ARAZZO_SPECIFICATION_FIELD_INFO_TYPE,
11
+ source: 'apilint',
12
+ message: 'info must be an object',
13
+ severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
14
+ linterFunction: 'apilintElementOrClass',
15
+ linterParams: [['info']],
16
+ marker: 'value',
17
+ target: 'info',
18
+ data: {},
19
+ targetSpecs: _targetSpecs.Arazzo1
20
+ };
21
+ var _default = exports.default = infoTypeLint;
@@ -0,0 +1,16 @@
1
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
2
+ import ApilintCodes from "../../../codes.mjs";
3
+ import { Arazzo1 } from "../../target-specs.mjs";
4
+ const infoTypeLint = {
5
+ code: ApilintCodes.ARAZZO1_ARAZZO_SPECIFICATION_FIELD_INFO_TYPE,
6
+ source: 'apilint',
7
+ message: 'info must be an object',
8
+ severity: DiagnosticSeverity.Error,
9
+ linterFunction: 'apilintElementOrClass',
10
+ linterParams: [['info']],
11
+ marker: 'value',
12
+ target: 'info',
13
+ data: {},
14
+ targetSpecs: Arazzo1
15
+ };
16
+ export default infoTypeLint;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
7
+ var _codes = _interopRequireDefault(require("../../../codes.cjs"));
8
+ var _targetSpecs = require("../../target-specs.cjs");
9
+ const requiredFieldsLint = {
10
+ code: _codes.default.ARAZZO1_ARAZZO_SPECIFICATION_REQUIRED_FIELDS,
11
+ source: 'apilint',
12
+ message: 'Arazzo Specification Object must contain following fields: info, sourceDescriptions, workflows',
13
+ severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
14
+ linterFunction: 'hasRequiredField',
15
+ linterParams: ['info', 'sourceDescriptions', 'workflows'],
16
+ marker: 'key',
17
+ conditions: [{
18
+ targets: [{
19
+ path: 'root'
20
+ }],
21
+ function: 'missingFields',
22
+ params: [['info', 'sourceDescriptions', 'workflows']]
23
+ }],
24
+ data: {
25
+ quickFix: [{
26
+ message: "add 'info' section",
27
+ action: 'addChild',
28
+ snippetYaml: 'info: \n \n',
29
+ snippetJson: '"info": {\n \n },\n'
30
+ }, {
31
+ message: "add 'sourceDescriptions' section",
32
+ action: 'addChild',
33
+ snippetYaml: 'sourceDescriptions:\n - \n',
34
+ snippetJson: '"sourceDescriptions": [\n \n ],\n'
35
+ }, {
36
+ message: "add 'workflows' section",
37
+ action: 'addChild',
38
+ snippetYaml: 'workflows:\n - \n',
39
+ snippetJson: '"workflows": [\n \n ],\n'
40
+ }]
41
+ },
42
+ targetSpecs: _targetSpecs.Arazzo1
43
+ };
44
+ var _default = exports.default = requiredFieldsLint;
@@ -0,0 +1,39 @@
1
+ import { DiagnosticSeverity } from 'vscode-languageserver-types';
2
+ import ApilintCodes from "../../../codes.mjs";
3
+ import { Arazzo1 } from "../../target-specs.mjs";
4
+ const requiredFieldsLint = {
5
+ code: ApilintCodes.ARAZZO1_ARAZZO_SPECIFICATION_REQUIRED_FIELDS,
6
+ source: 'apilint',
7
+ message: 'Arazzo Specification Object must contain following fields: info, sourceDescriptions, workflows',
8
+ severity: DiagnosticSeverity.Error,
9
+ linterFunction: 'hasRequiredField',
10
+ linterParams: ['info', 'sourceDescriptions', 'workflows'],
11
+ marker: 'key',
12
+ conditions: [{
13
+ targets: [{
14
+ path: 'root'
15
+ }],
16
+ function: 'missingFields',
17
+ params: [['info', 'sourceDescriptions', 'workflows']]
18
+ }],
19
+ data: {
20
+ quickFix: [{
21
+ message: "add 'info' section",
22
+ action: 'addChild',
23
+ snippetYaml: 'info: \n \n',
24
+ snippetJson: '"info": {\n \n },\n'
25
+ }, {
26
+ message: "add 'sourceDescriptions' section",
27
+ action: 'addChild',
28
+ snippetYaml: 'sourceDescriptions:\n - \n',
29
+ snippetJson: '"sourceDescriptions": [\n \n ],\n'
30
+ }, {
31
+ message: "add 'workflows' section",
32
+ action: 'addChild',
33
+ snippetYaml: 'workflows:\n - \n',
34
+ snippetJson: '"workflows": [\n \n ],\n'
35
+ }]
36
+ },
37
+ targetSpecs: Arazzo1
38
+ };
39
+ export default requiredFieldsLint;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.default = void 0;
6
+ var _index = _interopRequireDefault(require("./lint/index.cjs"));
7
+ const meta = {
8
+ lint: _index.default
9
+ };
10
+ var _default = exports.default = meta;
@@ -0,0 +1,5 @@
1
+ import lint from "./lint/index.mjs";
2
+ const meta = {
3
+ lint
4
+ };
5
+ export default meta;