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

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