@jentic/arazzo-parser 1.0.0-alpha.5 → 1.0.0-alpha.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jentic/arazzo-parser",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "Parser for Arazzo Documents producing SpecLynx ApiDOM data model.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -48,14 +48,15 @@
48
48
  "license": "Apache-2.0",
49
49
  "dependencies": {
50
50
  "@babel/runtime-corejs3": "^7.28.4",
51
- "@speclynx/apidom-datamodel": "2.5.1",
52
- "@speclynx/apidom-error": "2.5.1",
53
- "@speclynx/apidom-ns-arazzo-1": "2.5.1",
54
- "@speclynx/apidom-parser": "2.5.1",
55
- "@speclynx/apidom-parser-adapter-arazzo-json-1": "2.5.1",
56
- "@speclynx/apidom-parser-adapter-arazzo-yaml-1": "2.5.1",
57
- "@speclynx/apidom-reference": "2.5.1",
58
- "ramda-adjunct": "^6.0.0"
51
+ "@speclynx/apidom-core": "2.6.0",
52
+ "@speclynx/apidom-datamodel": "2.6.0",
53
+ "@speclynx/apidom-error": "2.6.0",
54
+ "@speclynx/apidom-ns-arazzo-1": "2.6.0",
55
+ "@speclynx/apidom-parser-adapter-arazzo-json-1": "2.6.0",
56
+ "@speclynx/apidom-parser-adapter-arazzo-yaml-1": "2.6.0",
57
+ "@speclynx/apidom-reference": "2.6.0",
58
+ "ramda-adjunct": "^6.0.0",
59
+ "type-fest": "^5.4.3"
59
60
  },
60
61
  "files": [
61
62
  "src/**/*.mjs",
@@ -67,5 +68,5 @@
67
68
  "README.md",
68
69
  "CHANGELOG.md"
69
70
  ],
70
- "gitHead": "65bd559465321bc72189e7367e5465b2d91565be"
71
+ "gitHead": "dfdeb6d475ae72ac6bbdb0a4532e661419d87d3f"
71
72
  }
package/src/index.cjs CHANGED
@@ -1,150 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
5
3
  exports.__esModule = true;
6
- exports.defaultOptions = void 0;
7
- exports.parse = parse;
8
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
9
- var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
10
- var _apidomParser = _interopRequireWildcard(require("@speclynx/apidom-parser"));
11
- var jsonParserAdapter = _interopRequireWildcard(require("@speclynx/apidom-parser-adapter-arazzo-json-1"));
12
- var yamlParserAdapter = _interopRequireWildcard(require("@speclynx/apidom-parser-adapter-arazzo-yaml-1"));
13
- var _empty = require("@speclynx/apidom-reference/configuration/empty");
14
- var _arazzoJson = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/arazzo-json-1"));
15
- var _arazzoYaml = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/arazzo-yaml-1"));
16
- var _file = _interopRequireDefault(require("@speclynx/apidom-reference/resolve/resolvers/file"));
17
- var _httpAxios = _interopRequireDefault(require("@speclynx/apidom-reference/resolve/resolvers/http-axios"));
18
- var _ramdaAdjunct = require("ramda-adjunct");
19
- var _ParseError = _interopRequireDefault(require("./errors/ParseError.cjs"));
20
- /**
21
- * Default reference options for parsing Arazzo Documents.
22
- * @public
23
- */
24
- const defaultOptions = exports.defaultOptions = {
25
- parse: {
26
- parsers: [new _arazzoJson.default({
27
- allowEmpty: false,
28
- sourceMap: false
29
- }), new _arazzoYaml.default({
30
- allowEmpty: false,
31
- sourceMap: false
32
- })],
33
- parserOpts: {}
34
- },
35
- resolve: {
36
- resolvers: [new _file.default({
37
- fileAllowList: ['*.json', '*.yaml', '*.yml']
38
- }), new _httpAxios.default({
39
- timeout: 5000,
40
- redirects: 5,
41
- withCredentials: false
42
- })],
43
- resolverOpts: {}
44
- }
45
- };
46
- const parser = new _apidomParser.default();
47
- parser.use(jsonParserAdapter);
48
- parser.use(yamlParserAdapter);
49
-
50
- /**
51
- * Parses an Arazzo Document from an object.
52
- * @param source - The Arazzo Document as a plain object
53
- * @param options - Reference options (uses defaultOptions when not provided)
54
- * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
55
- * @public
56
- */
57
-
58
- /**
59
- * Parses an Arazzo Document from a string or URI.
60
- * @param source - The Arazzo Document as string content, or a file system path / HTTP(S) URL
61
- * @param options - Reference options (uses defaultOptions when not provided)
62
- * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
63
- * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
64
- * @public
65
- */
66
-
67
- /**
68
- * Parses an Arazzo Document from a string, object, or URI.
69
- *
70
- * The function handles three types of input:
71
- * 1. Object - directly refracts the object into an Arazzo specification element
72
- * 2. String content - attempts to parse as an inline Arazzo Document (JSON or YAML)
73
- * 3. URI string - treats as a file system path or HTTP(S) URL and resolves the document
74
- *
75
- * @param source - The Arazzo Document as an object, string content, or a file system path / HTTP(S) URL
76
- * @param options - Reference options (uses defaultOptions when not provided)
77
- * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
78
- * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
79
- *
80
- * @example
81
- * Parse from object
82
- * ```typescript
83
- * const result = await parse({ arazzo: '1.0.1', info: {...} });
84
- * ```
85
- *
86
- * @example
87
- * Parse inline JSON
88
- * ```typescript
89
- * const result = await parse('{"arazzo": "1.0.1", "info": {...}}');
90
- * ```
91
- *
92
- * @example
93
- * Parse from file
94
- * ```typescript
95
- * const result = await parse('/path/to/arazzo.json');
96
- * ```
97
- *
98
- * @example
99
- * Parse from URL
100
- * ```typescript
101
- * const result = await parse('https://example.com/arazzo.yaml');
102
- * ```
103
- *
104
- * @example
105
- * Parse with custom options
106
- * ```typescript
107
- * const result = await parse('/path/to/arazzo.json', customOptions);
108
- * ```
109
- * @public
110
- */
111
- async function parse(source, options = {}) {
112
- const mergedOptions = (0, _empty.mergeOptions)(defaultOptions, options);
113
-
114
- // attempt to parse source as plain object
115
- if ((0, _ramdaAdjunct.isPlainObject)(source)) {
116
- if (mergedOptions.parse?.parserOpts?.sourceMap) {
117
- throw new _ParseError.default('sourceMap option is not supported when parsing from object: source maps cannot be inferred from plain objects');
118
- }
119
- const parseResult = new _apidomDatamodel.ParseResultElement();
120
- const element = (0, _apidomNsArazzo.refractArazzoSpecification1)(source);
121
- element.classes.push('result');
122
- parseResult.push(element);
123
- return parseResult;
124
- }
125
-
126
- // next try to parse the source assuming it contains Arazzo Document
127
- try {
128
- return await parser.parse(source, {
129
- sourceMap: mergedOptions.parse?.parserOpts?.sourceMap,
130
- strict: mergedOptions.parse?.parserOpts?.strict
131
- });
132
- } catch (error) {
133
- if (error instanceof _apidomParser.ParserError && error.message !== 'Source did not match any registered parsers') {
134
- throw new _ParseError.default('Failed to parse Arazzo Document', {
135
- cause: error
136
- });
137
- }
138
- }
139
-
140
- // next we assume that source is either file system URI or HTTP(S) URL
141
- try {
142
- const parseResult = await (0, _empty.parse)(source, mergedOptions);
143
- parseResult.meta.set('retrievalURI', source);
144
- return parseResult;
145
- } catch (error) {
146
- throw new _ParseError.default(`Failed to parse Arazzo Document from "${source}"`, {
147
- cause: error
148
- });
149
- }
150
- }
4
+ exports.parseArazzo = exports.defaultOptions = void 0;
5
+ var _parseArazzo = require("./parse-arazzo.cjs");
6
+ exports.parseArazzo = _parseArazzo.parse;
7
+ exports.defaultOptions = _parseArazzo.defaultOptions;
package/src/index.mjs CHANGED
@@ -1,143 +1 @@
1
- import { ParseResultElement } from '@speclynx/apidom-datamodel';
2
- import { refractArazzoSpecification1 } from '@speclynx/apidom-ns-arazzo-1';
3
- import ApiDOMParser, { ParserError } from '@speclynx/apidom-parser';
4
- import * as jsonParserAdapter from '@speclynx/apidom-parser-adapter-arazzo-json-1';
5
- import * as yamlParserAdapter from '@speclynx/apidom-parser-adapter-arazzo-yaml-1';
6
- import { parse as parseURI, mergeOptions } from '@speclynx/apidom-reference/configuration/empty';
7
- import ArazzoJSON1Parser from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
8
- import ArazzoYAML1Parser from '@speclynx/apidom-reference/parse/parsers/arazzo-yaml-1';
9
- import FileResolver from '@speclynx/apidom-reference/resolve/resolvers/file';
10
- import HTTPResolverAxios from '@speclynx/apidom-reference/resolve/resolvers/http-axios';
11
- import { isPlainObject } from 'ramda-adjunct';
12
- import ParseError from "./errors/ParseError.mjs";
13
- /**
14
- * Default reference options for parsing Arazzo Documents.
15
- * @public
16
- */
17
- export const defaultOptions = {
18
- parse: {
19
- parsers: [new ArazzoJSON1Parser({
20
- allowEmpty: false,
21
- sourceMap: false
22
- }), new ArazzoYAML1Parser({
23
- allowEmpty: false,
24
- sourceMap: false
25
- })],
26
- parserOpts: {}
27
- },
28
- resolve: {
29
- resolvers: [new FileResolver({
30
- fileAllowList: ['*.json', '*.yaml', '*.yml']
31
- }), new HTTPResolverAxios({
32
- timeout: 5000,
33
- redirects: 5,
34
- withCredentials: false
35
- })],
36
- resolverOpts: {}
37
- }
38
- };
39
- const parser = new ApiDOMParser();
40
- parser.use(jsonParserAdapter);
41
- parser.use(yamlParserAdapter);
42
-
43
- /**
44
- * Parses an Arazzo Document from an object.
45
- * @param source - The Arazzo Document as a plain object
46
- * @param options - Reference options (uses defaultOptions when not provided)
47
- * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
48
- * @public
49
- */
50
-
51
- /**
52
- * Parses an Arazzo Document from a string or URI.
53
- * @param source - The Arazzo Document as string content, or a file system path / HTTP(S) URL
54
- * @param options - Reference options (uses defaultOptions when not provided)
55
- * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
56
- * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
57
- * @public
58
- */
59
-
60
- /**
61
- * Parses an Arazzo Document from a string, object, or URI.
62
- *
63
- * The function handles three types of input:
64
- * 1. Object - directly refracts the object into an Arazzo specification element
65
- * 2. String content - attempts to parse as an inline Arazzo Document (JSON or YAML)
66
- * 3. URI string - treats as a file system path or HTTP(S) URL and resolves the document
67
- *
68
- * @param source - The Arazzo Document as an object, string content, or a file system path / HTTP(S) URL
69
- * @param options - Reference options (uses defaultOptions when not provided)
70
- * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
71
- * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
72
- *
73
- * @example
74
- * Parse from object
75
- * ```typescript
76
- * const result = await parse({ arazzo: '1.0.1', info: {...} });
77
- * ```
78
- *
79
- * @example
80
- * Parse inline JSON
81
- * ```typescript
82
- * const result = await parse('{"arazzo": "1.0.1", "info": {...}}');
83
- * ```
84
- *
85
- * @example
86
- * Parse from file
87
- * ```typescript
88
- * const result = await parse('/path/to/arazzo.json');
89
- * ```
90
- *
91
- * @example
92
- * Parse from URL
93
- * ```typescript
94
- * const result = await parse('https://example.com/arazzo.yaml');
95
- * ```
96
- *
97
- * @example
98
- * Parse with custom options
99
- * ```typescript
100
- * const result = await parse('/path/to/arazzo.json', customOptions);
101
- * ```
102
- * @public
103
- */
104
- export async function parse(source, options = {}) {
105
- const mergedOptions = mergeOptions(defaultOptions, options);
106
-
107
- // attempt to parse source as plain object
108
- if (isPlainObject(source)) {
109
- if (mergedOptions.parse?.parserOpts?.sourceMap) {
110
- throw new ParseError('sourceMap option is not supported when parsing from object: source maps cannot be inferred from plain objects');
111
- }
112
- const parseResult = new ParseResultElement();
113
- const element = refractArazzoSpecification1(source);
114
- element.classes.push('result');
115
- parseResult.push(element);
116
- return parseResult;
117
- }
118
-
119
- // next try to parse the source assuming it contains Arazzo Document
120
- try {
121
- return await parser.parse(source, {
122
- sourceMap: mergedOptions.parse?.parserOpts?.sourceMap,
123
- strict: mergedOptions.parse?.parserOpts?.strict
124
- });
125
- } catch (error) {
126
- if (error instanceof ParserError && error.message !== 'Source did not match any registered parsers') {
127
- throw new ParseError('Failed to parse Arazzo Document', {
128
- cause: error
129
- });
130
- }
131
- }
132
-
133
- // next we assume that source is either file system URI or HTTP(S) URL
134
- try {
135
- const parseResult = await parseURI(source, mergedOptions);
136
- parseResult.meta.set('retrievalURI', source);
137
- return parseResult;
138
- } catch (error) {
139
- throw new ParseError(`Failed to parse Arazzo Document from "${source}"`, {
140
- cause: error
141
- });
142
- }
143
- }
1
+ export { parse as parseArazzo, defaultOptions } from "./parse-arazzo.mjs";
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
+ exports.__esModule = true;
5
+ exports.defaultOptions = void 0;
6
+ exports.parse = parse;
7
+ var _apidomCore = require("@speclynx/apidom-core");
8
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
9
+ var _empty = require("@speclynx/apidom-reference/configuration/empty");
10
+ var _arazzoJson = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/arazzo-json-1"));
11
+ var _arazzoYaml = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/arazzo-yaml-1"));
12
+ var _openapiJson = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/openapi-json-2"));
13
+ var _openapiYaml = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/openapi-yaml-2"));
14
+ var _openapiJson2 = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/openapi-json-3-0"));
15
+ var _openapiYaml2 = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/openapi-yaml-3-0"));
16
+ var _openapiJson3 = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/openapi-json-3-1"));
17
+ var _openapiYaml3 = _interopRequireDefault(require("@speclynx/apidom-reference/parse/parsers/openapi-yaml-3-1"));
18
+ var _file = _interopRequireDefault(require("@speclynx/apidom-reference/resolve/resolvers/file"));
19
+ var _httpAxios = _interopRequireDefault(require("@speclynx/apidom-reference/resolve/resolvers/http-axios"));
20
+ var _apidomParserAdapterArazzoJson = require("@speclynx/apidom-parser-adapter-arazzo-json-1");
21
+ var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
22
+ var _apidomParserAdapterArazzoYaml = require("@speclynx/apidom-parser-adapter-arazzo-yaml-1");
23
+ var _ramdaAdjunct = require("ramda-adjunct");
24
+ var _ParseError = _interopRequireDefault(require("./errors/ParseError.cjs"));
25
+ var _index = _interopRequireDefault(require("./resolve/resolvers/memory/index.cjs"));
26
+ /**
27
+ * Options for parsing Arazzo Documents.
28
+ * @public
29
+ */
30
+
31
+ /**
32
+ * Default reference options for parsing Arazzo Documents.
33
+ * @public
34
+ */
35
+ const defaultOptions = exports.defaultOptions = {
36
+ parse: {
37
+ parsers: [new _arazzoJson.default({
38
+ allowEmpty: false,
39
+ fileExtensions: ['.json'],
40
+ parseFn: _empty.parse
41
+ }), new _arazzoYaml.default({
42
+ allowEmpty: false,
43
+ fileExtensions: ['.yaml', '.yml'],
44
+ parseFn: _empty.parse
45
+ }), new _openapiJson.default({
46
+ allowEmpty: false,
47
+ fileExtensions: ['.json']
48
+ }), new _openapiYaml.default({
49
+ allowEmpty: false,
50
+ fileExtensions: ['.yaml', '.yml']
51
+ }), new _openapiJson2.default({
52
+ allowEmpty: false,
53
+ fileExtensions: ['.json']
54
+ }), new _openapiYaml2.default({
55
+ allowEmpty: false,
56
+ fileExtensions: ['.yaml', '.yml']
57
+ }), new _openapiJson3.default({
58
+ allowEmpty: false,
59
+ fileExtensions: ['.json']
60
+ }), new _openapiYaml3.default({
61
+ allowEmpty: false,
62
+ fileExtensions: ['.yaml', '.yml']
63
+ })],
64
+ parserOpts: {
65
+ sourceMap: false,
66
+ strict: true,
67
+ sourceDescriptions: false
68
+ }
69
+ },
70
+ resolve: {
71
+ resolvers: [new _index.default(), new _file.default({
72
+ fileAllowList: ['*.json', '*.yaml', '*.yml']
73
+ }), new _httpAxios.default({
74
+ timeout: 5000,
75
+ redirects: 5,
76
+ withCredentials: false
77
+ })],
78
+ resolverOpts: {}
79
+ }
80
+ };
81
+
82
+ /**
83
+ * Parses an Arazzo Document from an object.
84
+ * @param source - The Arazzo Document as a plain object
85
+ * @param options - Reference options (uses defaultOptions when not provided)
86
+ * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
87
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
88
+ * @public
89
+ */
90
+
91
+ /**
92
+ * Parses an Arazzo Document from a string or URI.
93
+ * @param source - The Arazzo Document as string content, or a file system path / HTTP(S) URL
94
+ * @param options - Reference options (uses defaultOptions when not provided)
95
+ * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
96
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
97
+ * @public
98
+ */
99
+
100
+ /**
101
+ * Parses an Arazzo Document from a string, object, or URI.
102
+ *
103
+ * The function handles three types of input:
104
+ * 1. Object - converts to JSON string and parses (source maps supported with `strict: false`)
105
+ * 2. String content - uses Arazzo detection to identify and parse inline JSON or YAML content
106
+ * 3. URI string - if not detected as Arazzo content, treats as file system path or HTTP(S) URL
107
+ *
108
+ * @param source - The Arazzo Document as an object, string content, or a file system path / HTTP(S) URL
109
+ * @param options - Reference options (uses defaultOptions when not provided)
110
+ * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
111
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
112
+ *
113
+ * @example
114
+ * Parse from object
115
+ * ```typescript
116
+ * const result = await parseArazzo({ arazzo: '1.0.1', info: {...} });
117
+ * ```
118
+ *
119
+ * @example
120
+ * Parse inline JSON
121
+ * ```typescript
122
+ * const result = await parseArazzo('{"arazzo": "1.0.1", "info": {...}}');
123
+ * ```
124
+ *
125
+ * @example
126
+ * Parse from file
127
+ * ```typescript
128
+ * const result = await parseArazzo('/path/to/arazzo.json');
129
+ * ```
130
+ *
131
+ * @example
132
+ * Parse from URL
133
+ * ```typescript
134
+ * const result = await parseArazzo('https://example.com/arazzo.yaml');
135
+ * ```
136
+ *
137
+ * @example
138
+ * Parse with custom options
139
+ * ```typescript
140
+ * const result = await parseArazzo('/path/to/arazzo.json', customOptions);
141
+ * ```
142
+ * @public
143
+ */
144
+ async function parse(source, options = {}) {
145
+ let mergedOptions = (0, _empty.mergeOptions)(defaultOptions, options);
146
+ const strict = mergedOptions.parse?.parserOpts?.strict ?? true;
147
+ let sourceProvenance;
148
+ if ((0, _ramdaAdjunct.isPlainObject)(source)) {
149
+ const arazzoDocument = JSON.stringify(source, null, 2);
150
+ mergedOptions = (0, _empty.mergeOptions)(mergedOptions, {
151
+ resolve: {
152
+ resolverOpts: {
153
+ arazzoDocument
154
+ }
155
+ }
156
+ });
157
+ source = 'memory://arazzo.json';
158
+ sourceProvenance = '[object]';
159
+ } else if (await (0, _apidomParserAdapterArazzoJson.detect)(source, {
160
+ strict
161
+ })) {
162
+ mergedOptions = (0, _empty.mergeOptions)(mergedOptions, {
163
+ resolve: {
164
+ resolverOpts: {
165
+ arazzoDocument: source
166
+ }
167
+ }
168
+ });
169
+ source = 'memory://arazzo.json';
170
+ sourceProvenance = '[inline JSON]';
171
+ } else if (await (0, _apidomParserAdapterArazzoYaml.detect)(source, {
172
+ strict
173
+ })) {
174
+ mergedOptions = (0, _empty.mergeOptions)(mergedOptions, {
175
+ resolve: {
176
+ resolverOpts: {
177
+ arazzoDocument: source
178
+ }
179
+ }
180
+ });
181
+ source = 'memory://arazzo.yaml';
182
+ sourceProvenance = '[inline YAML]';
183
+ } else {
184
+ sourceProvenance = source;
185
+ }
186
+
187
+ // next we assume that source is either file system URI or HTTP(S) URL
188
+ try {
189
+ const parseResult = await (0, _empty.parse)(source, mergedOptions);
190
+
191
+ // set retrievalURI metadata for file/URL sources (not for inline content)
192
+ if (!source.startsWith('memory://')) {
193
+ parseResult.meta.set('retrievalURI', source);
194
+ }
195
+
196
+ // validate that the parsed document is an Arazzo specification
197
+ if (!(0, _apidomNsArazzo.isArazzoSpecification1Element)(parseResult.api)) {
198
+ const annotation = new _apidomDatamodel.AnnotationElement('Document is not a valid Arazzo specification. Expected an Arazzo document with "arazzo" version field.', {
199
+ classes: ['error']
200
+ });
201
+ // remove 'api' class so .api returns undefined, but keep parsed result available
202
+ if (parseResult.api) {
203
+ parseResult.api.classes = parseResult.api.classes.filter(cls => (0, _apidomCore.toValue)(cls) !== 'api');
204
+ }
205
+ parseResult.push(annotation);
206
+ }
207
+ return parseResult;
208
+ } catch (error) {
209
+ throw new _ParseError.default(`Failed to parse Arazzo Document from "${sourceProvenance}"`, {
210
+ cause: error
211
+ });
212
+ }
213
+ }