@usearazzo/validator 1.0.1-alpha.34 → 1.0.1-alpha.36
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/CHANGELOG.md +10 -0
- package/dist/arazzo-validator.browser.js +586 -415
- package/dist/arazzo-validator.browser.min.js +1 -1
- package/package.json +20 -14
- package/types/validator.d.cts +155 -0
- package/types/validator.d.ts +4 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usearazzo/validator",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.36",
|
|
4
4
|
"description": "Validator and linter for Arazzo documents: semantic validation, semantic linting, and opt-in JSON Schema validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arazzo",
|
|
@@ -27,9 +27,14 @@
|
|
|
27
27
|
"unpkg": "./dist/arazzo-validator.browser.min.js",
|
|
28
28
|
"main": "./src/index.cjs",
|
|
29
29
|
"exports": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./types/validator.d.ts",
|
|
32
|
+
"default": "./src/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./types/validator.d.cts",
|
|
36
|
+
"default": "./src/index.cjs"
|
|
37
|
+
}
|
|
33
38
|
},
|
|
34
39
|
"types": "./types/validator.d.ts",
|
|
35
40
|
"scripts": {
|
|
@@ -41,7 +46,8 @@
|
|
|
41
46
|
"lint:fix": "eslint ./ --fix",
|
|
42
47
|
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
|
|
43
48
|
"typescript:check-types": "tsc --noEmit",
|
|
44
|
-
"typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json",
|
|
49
|
+
"typescript:declaration": "tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json && node ../../scripts/declarations-cts.mjs",
|
|
50
|
+
"typescript:check-published-types": "attw --pack . --profile node16 && tsc -p test/types/tsconfig.json",
|
|
45
51
|
"test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha",
|
|
46
52
|
"prepack": "copyfiles -u 2 ../../LICENSE . && copyfiles -u 2 ../../NOTICE .",
|
|
47
53
|
"postpack": "rimraf NOTICE LICENSE"
|
|
@@ -54,26 +60,26 @@
|
|
|
54
60
|
"author": "Vladimir Gorej <vladimir.gorej@gmail.com>",
|
|
55
61
|
"license": "Apache-2.0",
|
|
56
62
|
"dependencies": {
|
|
57
|
-
"@babel/runtime-corejs3": "^8.1.
|
|
58
|
-
"@speclynx/api-languageservice": "^3.0.
|
|
59
|
-
"@speclynx/apidom-error": "^7.1.
|
|
60
|
-
"@speclynx/apidom-ns-arazzo-1": "^7.1.
|
|
61
|
-
"@speclynx/apidom-reference": "^7.1.
|
|
62
|
-
"@usearazzo/parser": "1.0.1-alpha.
|
|
63
|
+
"@babel/runtime-corejs3": "^8.1.3",
|
|
64
|
+
"@speclynx/api-languageservice": "^3.0.6",
|
|
65
|
+
"@speclynx/apidom-error": "^7.1.1",
|
|
66
|
+
"@speclynx/apidom-ns-arazzo-1": "^7.1.1",
|
|
67
|
+
"@speclynx/apidom-reference": "^7.1.1",
|
|
68
|
+
"@usearazzo/parser": "1.0.1-alpha.36",
|
|
63
69
|
"ramda": "^0.32.0",
|
|
64
|
-
"type-fest": "^5.10.0",
|
|
65
70
|
"vscode-languageserver-textdocument": "^1.0.16",
|
|
66
|
-
"vscode-languageserver-types": "=3.18.
|
|
71
|
+
"vscode-languageserver-types": "=3.18.6"
|
|
67
72
|
},
|
|
68
73
|
"files": [
|
|
69
74
|
"src/**/*.mjs",
|
|
70
75
|
"src/**/*.cjs",
|
|
71
76
|
"dist/",
|
|
72
77
|
"types/validator.d.ts",
|
|
78
|
+
"types/validator.d.cts",
|
|
73
79
|
"LICENSE",
|
|
74
80
|
"NOTICE",
|
|
75
81
|
"README.md",
|
|
76
82
|
"CHANGELOG.md"
|
|
77
83
|
],
|
|
78
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "039f55923d0f86676181764b02744affcf5f6da2"
|
|
79
85
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { ApiDOMError } from '@speclynx/apidom-error';
|
|
2
|
+
import { ApiDOMErrorOptions } from '@speclynx/apidom-error';
|
|
3
|
+
import { ApiDOMReferenceResolveOptions } from '@speclynx/apidom-reference/configuration/empty';
|
|
4
|
+
import { Diagnostic } from 'vscode-languageserver-types';
|
|
5
|
+
import { DiagnosticSeverity } from 'vscode-languageserver-types';
|
|
6
|
+
import { LanguageServiceContext } from '@speclynx/api-languageservice';
|
|
7
|
+
import type { PartialOptions } from '@usearazzo/parser';
|
|
8
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Language ID for Arazzo documents used with TextDocument.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const ARAZZO_LANGUAGE_ID = "apidom";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a TextDocument for Arazzo validation.
|
|
19
|
+
*
|
|
20
|
+
* @param uri - The document URI
|
|
21
|
+
* @param content - The document content
|
|
22
|
+
* @returns A TextDocument instance
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function createTextDocument(uri: string, content: string): TextDocument;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Default document version for TextDocument instances.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare const DEFAULT_DOCUMENT_VERSION = 1;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Default resolve options for URI resolution in validateURI.
|
|
36
|
+
*
|
|
37
|
+
* These options control how files and URLs are fetched when validating
|
|
38
|
+
* Arazzo documents from URIs.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare const defaultArazzoResolveOptions: Partial<ApiDOMReferenceResolveOptions> | undefined;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Default language service context for validation.
|
|
46
|
+
*
|
|
47
|
+
* Controls validation behavior: semantic validation, reference validation and
|
|
48
|
+
* semantic linting are enabled, JSON Schema validation is opt-in.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export declare const defaultLanguageServiceContext: Partial<LanguageServiceContext>;
|
|
53
|
+
|
|
54
|
+
export { Diagnostic }
|
|
55
|
+
|
|
56
|
+
export { DiagnosticSeverity }
|
|
57
|
+
|
|
58
|
+
export { LanguageServiceContext }
|
|
59
|
+
|
|
60
|
+
export { TextDocument }
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Validates an Arazzo Document from a TextDocument.
|
|
64
|
+
*
|
|
65
|
+
* This is a lower-level API for advanced use cases such as IDE integrations
|
|
66
|
+
* or when you already have document content in memory.
|
|
67
|
+
*
|
|
68
|
+
* @param textDocument - The TextDocument containing the Arazzo Document content
|
|
69
|
+
* @param context - Optional language service context override (deep merged with defaults)
|
|
70
|
+
* @returns Promise resolving to an array of Diagnostic objects
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* Basic usage
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { validate, TextDocument, DiagnosticSeverity, ARAZZO_LANGUAGE_ID, DEFAULT_DOCUMENT_VERSION } from '@usearazzo/validator';
|
|
76
|
+
*
|
|
77
|
+
* const textDocument = TextDocument.create(
|
|
78
|
+
* 'file:///path/to/arazzo.yaml',
|
|
79
|
+
* ARAZZO_LANGUAGE_ID,
|
|
80
|
+
* DEFAULT_DOCUMENT_VERSION,
|
|
81
|
+
* content
|
|
82
|
+
* );
|
|
83
|
+
* const diagnostics = await validate(textDocument);
|
|
84
|
+
* const errors = diagnostics.filter((d) => d.severity === DiagnosticSeverity.Error);
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* Enable JSON Schema validation (opt-in)
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const diagnostics = await validate(textDocument, {
|
|
91
|
+
* validationContext: { jsonSchemaValidation: true }
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare function validate(textDocument: TextDocument, context?: PartialOptions<LanguageServiceContext>): Promise<Diagnostic[]>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Error thrown by `validateURI` when the document cannot be fetched. Problems
|
|
100
|
+
* found in the document itself are reported as diagnostics, not thrown. The
|
|
101
|
+
* original error is available via the `cause` property.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare class ValidateError extends ApiDOMError {
|
|
105
|
+
constructor(message?: string, options?: ApiDOMErrorOptions);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Validates an Arazzo Document from a URI (file path or HTTP(S) URL).
|
|
110
|
+
*
|
|
111
|
+
* This is the primary API for validation. It fetches the document from the
|
|
112
|
+
* specified URI and performs JSON Schema validation, semantic validation,
|
|
113
|
+
* and linting.
|
|
114
|
+
*
|
|
115
|
+
* @param uri - The file system path or HTTP(S) URL to the Arazzo Document
|
|
116
|
+
* @param context - Optional language service context override (deep merged with defaults)
|
|
117
|
+
* @param resolveOptions - Optional resolve options for fetching the URI
|
|
118
|
+
* @returns Promise resolving to an array of Diagnostic objects
|
|
119
|
+
* @throws ValidateError - When the document cannot be fetched. The original error is available via the `cause` property.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* Validate from file
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { validateURI, DiagnosticSeverity } from '@usearazzo/validator';
|
|
125
|
+
*
|
|
126
|
+
* const diagnostics = await validateURI('/path/to/arazzo.yaml');
|
|
127
|
+
* const errors = diagnostics.filter((d) => d.severity === DiagnosticSeverity.Error);
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* Validate from URL
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const diagnostics = await validateURI('https://example.com/arazzo.yaml');
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* Validate with custom context
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const diagnostics = await validateURI('/path/to/arazzo.yaml', {
|
|
140
|
+
* validationContext: { jsonSchemaValidation: true }
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* Validate with custom resolve options
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const diagnostics = await validateURI('/path/to/arazzo.yaml', {}, {
|
|
148
|
+
* resolverOpts: { timeout: 10000 }
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
export declare function validateURI(uri: string, context?: PartialOptions<LanguageServiceContext>, resolveOptions?: Partial<ApiDOMReferenceResolveOptions>): Promise<Diagnostic[]>;
|
|
154
|
+
|
|
155
|
+
export { }
|
package/types/validator.d.ts
CHANGED
|
@@ -4,9 +4,7 @@ import { ApiDOMReferenceResolveOptions } from '@speclynx/apidom-reference/config
|
|
|
4
4
|
import { Diagnostic } from 'vscode-languageserver-types';
|
|
5
5
|
import { DiagnosticSeverity } from 'vscode-languageserver-types';
|
|
6
6
|
import { LanguageServiceContext } from '@speclynx/api-languageservice';
|
|
7
|
-
import type {
|
|
8
|
-
import { Resolver } from '@speclynx/apidom-reference/configuration/empty';
|
|
9
|
-
import { ResolveStrategy } from '@speclynx/apidom-reference/configuration/empty';
|
|
7
|
+
import type { PartialOptions } from '@usearazzo/parser';
|
|
10
8
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -41,20 +39,7 @@ export declare const DEFAULT_DOCUMENT_VERSION = 1;
|
|
|
41
39
|
*
|
|
42
40
|
* @public
|
|
43
41
|
*/
|
|
44
|
-
export declare const defaultArazzoResolveOptions:
|
|
45
|
-
baseURI?: string | undefined;
|
|
46
|
-
resolvers?: Resolver[] | undefined;
|
|
47
|
-
resolverOpts?: {
|
|
48
|
-
[x: string]: any;
|
|
49
|
-
} | undefined;
|
|
50
|
-
strategies?: ResolveStrategy[] | undefined;
|
|
51
|
-
strategyOpts?: {
|
|
52
|
-
[x: string]: any;
|
|
53
|
-
} | undefined;
|
|
54
|
-
internal?: boolean | undefined;
|
|
55
|
-
external?: boolean | undefined;
|
|
56
|
-
maxDepth?: number | undefined;
|
|
57
|
-
} | undefined;
|
|
42
|
+
export declare const defaultArazzoResolveOptions: Partial<ApiDOMReferenceResolveOptions> | undefined;
|
|
58
43
|
|
|
59
44
|
/**
|
|
60
45
|
* Default language service context for validation.
|
|
@@ -108,7 +93,7 @@ export { TextDocument }
|
|
|
108
93
|
* ```
|
|
109
94
|
* @public
|
|
110
95
|
*/
|
|
111
|
-
export declare function validate(textDocument: TextDocument, context?:
|
|
96
|
+
export declare function validate(textDocument: TextDocument, context?: PartialOptions<LanguageServiceContext>): Promise<Diagnostic[]>;
|
|
112
97
|
|
|
113
98
|
/**
|
|
114
99
|
* Error thrown by `validateURI` when the document cannot be fetched. Problems
|
|
@@ -165,6 +150,6 @@ export declare class ValidateError extends ApiDOMError {
|
|
|
165
150
|
* ```
|
|
166
151
|
* @public
|
|
167
152
|
*/
|
|
168
|
-
export declare function validateURI(uri: string, context?:
|
|
153
|
+
export declare function validateURI(uri: string, context?: PartialOptions<LanguageServiceContext>, resolveOptions?: Partial<ApiDOMReferenceResolveOptions>): Promise<Diagnostic[]>;
|
|
169
154
|
|
|
170
155
|
export { }
|