@speclynx/apidom-reference 2.7.0 → 2.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-reference",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -231,29 +231,29 @@
231
231
  "license": "Apache-2.0",
232
232
  "dependencies": {
233
233
  "@babel/runtime-corejs3": "^7.28.4",
234
- "@speclynx/apidom-core": "^2.7.0",
235
- "@speclynx/apidom-datamodel": "^2.7.0",
236
- "@speclynx/apidom-error": "^2.7.0",
237
- "@speclynx/apidom-json-pointer": "^2.7.0",
238
- "@speclynx/apidom-ns-arazzo-1": "^2.7.0",
239
- "@speclynx/apidom-ns-asyncapi-2": "^2.7.0",
240
- "@speclynx/apidom-ns-json-schema-2020-12": "^2.7.0",
241
- "@speclynx/apidom-ns-openapi-2": "^2.7.0",
242
- "@speclynx/apidom-ns-openapi-3-0": "^2.7.0",
243
- "@speclynx/apidom-ns-openapi-3-1": "^2.7.0",
244
- "@speclynx/apidom-parser-adapter-arazzo-json-1": "^2.7.0",
245
- "@speclynx/apidom-parser-adapter-arazzo-yaml-1": "^2.7.0",
246
- "@speclynx/apidom-parser-adapter-asyncapi-json-2": "^2.7.0",
247
- "@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "^2.7.0",
248
- "@speclynx/apidom-parser-adapter-json": "^2.7.0",
249
- "@speclynx/apidom-parser-adapter-openapi-json-2": "^2.7.0",
250
- "@speclynx/apidom-parser-adapter-openapi-json-3-0": "^2.7.0",
251
- "@speclynx/apidom-parser-adapter-openapi-json-3-1": "^2.7.0",
252
- "@speclynx/apidom-parser-adapter-openapi-yaml-2": "^2.7.0",
253
- "@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "^2.7.0",
254
- "@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "^2.7.0",
255
- "@speclynx/apidom-parser-adapter-yaml-1-2": "^2.7.0",
256
- "@speclynx/apidom-traverse": "^2.7.0",
234
+ "@speclynx/apidom-core": "^2.8.0",
235
+ "@speclynx/apidom-datamodel": "^2.8.0",
236
+ "@speclynx/apidom-error": "^2.8.0",
237
+ "@speclynx/apidom-json-pointer": "^2.8.0",
238
+ "@speclynx/apidom-ns-arazzo-1": "^2.8.0",
239
+ "@speclynx/apidom-ns-asyncapi-2": "^2.8.0",
240
+ "@speclynx/apidom-ns-json-schema-2020-12": "^2.8.0",
241
+ "@speclynx/apidom-ns-openapi-2": "^2.8.0",
242
+ "@speclynx/apidom-ns-openapi-3-0": "^2.8.0",
243
+ "@speclynx/apidom-ns-openapi-3-1": "^2.8.0",
244
+ "@speclynx/apidom-parser-adapter-arazzo-json-1": "^2.8.0",
245
+ "@speclynx/apidom-parser-adapter-arazzo-yaml-1": "^2.8.0",
246
+ "@speclynx/apidom-parser-adapter-asyncapi-json-2": "^2.8.0",
247
+ "@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "^2.8.0",
248
+ "@speclynx/apidom-parser-adapter-json": "^2.8.0",
249
+ "@speclynx/apidom-parser-adapter-openapi-json-2": "^2.8.0",
250
+ "@speclynx/apidom-parser-adapter-openapi-json-3-0": "^2.8.0",
251
+ "@speclynx/apidom-parser-adapter-openapi-json-3-1": "^2.8.0",
252
+ "@speclynx/apidom-parser-adapter-openapi-yaml-2": "^2.8.0",
253
+ "@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "^2.8.0",
254
+ "@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "^2.8.0",
255
+ "@speclynx/apidom-parser-adapter-yaml-1-2": "^2.8.0",
256
+ "@speclynx/apidom-traverse": "^2.8.0",
257
257
  "@swaggerexpert/arazzo-runtime-expression": "^2.0.2",
258
258
  "axios": "^1.13.0",
259
259
  "minimatch": "^7.4.6",
@@ -274,5 +274,5 @@
274
274
  "README.md",
275
275
  "CHANGELOG.md"
276
276
  ],
277
- "gitHead": "82ac9430aa882d0a5c63a17f7da8f5c0dcbca737"
277
+ "gitHead": "467e34a8f8a9d56622faf0794e4ef9c1fe86b849"
278
278
  }
@@ -7,7 +7,8 @@ var _ramda = require("ramda");
7
7
  var _apidomParserAdapterArazzoJson = require("@speclynx/apidom-parser-adapter-arazzo-json-1");
8
8
  var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
9
9
  var _Parser = _interopRequireDefault(require("../Parser.cjs"));
10
- var _sourceDescription = require("./source-description.cjs");
10
+ var _sourceDescriptions = require("./source-descriptions.cjs");
11
+ exports.parseSourceDescriptions = _sourceDescriptions.parseSourceDescriptions;
11
12
  /**
12
13
  * @public
13
14
  */
@@ -47,7 +48,7 @@ class ArazzoJSON1Parser extends _Parser.default {
47
48
  const parseResult = await (0, _apidomParserAdapterArazzoJson.parse)(source, parserOpts);
48
49
  const shouldParseSourceDescriptions = options?.parse?.parserOpts?.[this.name]?.sourceDescriptions ?? options?.parse?.parserOpts?.sourceDescriptions;
49
50
  if (shouldParseSourceDescriptions) {
50
- const sourceDescriptions = await (0, _sourceDescription.parseSourceDescriptions)(this.name, parseResult.api, file, options);
51
+ const sourceDescriptions = await (0, _sourceDescriptions.parseSourceDescriptions)(parseResult, file.uri, options, this.name);
51
52
  parseResult.push(...sourceDescriptions);
52
53
  }
53
54
  return parseResult;
@@ -2,7 +2,7 @@ import { pick } from 'ramda';
2
2
  import { parse, mediaTypes as ArazzoJSON1MediaTypes, detect } from '@speclynx/apidom-parser-adapter-arazzo-json-1';
3
3
  import ParserError from "../../../errors/ParserError.mjs";
4
4
  import Parser from "../Parser.mjs";
5
- import { parseSourceDescriptions } from "./source-description.mjs";
5
+ import { parseSourceDescriptions } from "./source-descriptions.mjs";
6
6
  /**
7
7
  * @public
8
8
  */
@@ -41,7 +41,7 @@ class ArazzoJSON1Parser extends Parser {
41
41
  const parseResult = await parse(source, parserOpts);
42
42
  const shouldParseSourceDescriptions = options?.parse?.parserOpts?.[this.name]?.sourceDescriptions ?? options?.parse?.parserOpts?.sourceDescriptions;
43
43
  if (shouldParseSourceDescriptions) {
44
- const sourceDescriptions = await parseSourceDescriptions(this.name, parseResult.api, file, options);
44
+ const sourceDescriptions = await parseSourceDescriptions(parseResult, file.uri, options, this.name);
45
45
  parseResult.push(...sourceDescriptions);
46
46
  }
47
47
  return parseResult;
@@ -52,4 +52,5 @@ class ArazzoJSON1Parser extends Parser {
52
52
  }
53
53
  }
54
54
  }
55
+ export { parseSourceDescriptions } from "./source-descriptions.mjs";
55
56
  export default ArazzoJSON1Parser;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
3
  var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
5
5
  exports.__esModule = true;
6
6
  exports.parseSourceDescriptions = parseSourceDescriptions;
7
7
  var _apidomDatamodel = require("@speclynx/apidom-datamodel");
@@ -10,6 +10,7 @@ var _apidomNsOpenapi = require("@speclynx/apidom-ns-openapi-2");
10
10
  var _apidomNsOpenapi2 = require("@speclynx/apidom-ns-openapi-3-0");
11
11
  var _apidomNsOpenapi3 = require("@speclynx/apidom-ns-openapi-3-1");
12
12
  var _apidomCore = require("@speclynx/apidom-core");
13
+ var _File = _interopRequireDefault(require("../../../File.cjs"));
13
14
  var url = _interopRequireWildcard(require("../../../util/url.cjs"));
14
15
  var _util = require("../../../options/util.cjs");
15
16
  var _index = _interopRequireDefault(require("../../index.cjs"));
@@ -50,7 +51,7 @@ async function parseSourceDescription(sourceDescription, ctx) {
50
51
  }
51
52
  ctx.visitedUrls.add(retrievalURI);
52
53
  try {
53
- const sdParseResult = await (0, _index.default)(retrievalURI, (0, _util.merge)(ctx.options, {
54
+ const sourceDescriptionParseResult = await (0, _index.default)(retrievalURI, (0, _util.merge)(ctx.options, {
54
55
  parse: {
55
56
  mediaType: 'text/plain',
56
57
  // allow parser plugin detection
@@ -63,7 +64,7 @@ async function parseSourceDescription(sourceDescription, ctx) {
63
64
  }
64
65
  }));
65
66
  // merge parsed result into our parse result
66
- for (const item of sdParseResult) {
67
+ for (const item of sourceDescriptionParseResult) {
67
68
  parseResult.push(item);
68
69
  }
69
70
  } catch (error) {
@@ -105,10 +106,40 @@ async function parseSourceDescription(sourceDescription, ctx) {
105
106
  }
106
107
 
107
108
  /**
108
- * Shared function for parsing source descriptions.
109
+ * Parses source descriptions from an Arazzo document's ParseResult.
110
+ *
111
+ * @param parseResult - ParseResult containing an Arazzo specification
112
+ * @param parseResultRetrievalURI - URI from which the parseResult was retrieved
113
+ * @param options - Full ReferenceOptions (caller responsibility to construct)
114
+ * @param parserName - Parser name for options lookup (defaults to 'arazzo-json-1')
115
+ * @returns Array of ParseResultElements. On success, returns one ParseResultElement per
116
+ * source description (each with class 'source-description' and name/type metadata).
117
+ * May return early with a single-element array containing a warning annotation when:
118
+ * - The API is not an Arazzo specification
119
+ * - The sourceDescriptions field is missing or not an array
120
+ * - Maximum parse depth is exceeded (error annotation)
121
+ * Returns an empty array when sourceDescriptions option is disabled or no names match.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * import { options, mergeOptions } from '@speclynx/apidom-reference';
126
+ * import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
127
+ *
128
+ * const fullOptions = mergeOptions(options, {
129
+ * parse: { parserOpts: { sourceDescriptions: true } }
130
+ * });
131
+ * const results = await parseSourceDescriptions(parseResult, uri, fullOptions);
132
+ * ```
133
+ *
109
134
  * @public
110
135
  */
111
- async function parseSourceDescriptions(parserName, api, file, options) {
136
+ async function parseSourceDescriptions(parseResult, parseResultRetrievalURI, options, parserName = 'arazzo-json-1') {
137
+ const {
138
+ api
139
+ } = parseResult;
140
+ const file = new _File.default({
141
+ uri: url.sanitize(url.stripHash(parseResultRetrievalURI))
142
+ });
112
143
  const results = [];
113
144
 
114
145
  /**
@@ -4,6 +4,7 @@ import { isSwaggerElement } from '@speclynx/apidom-ns-openapi-2';
4
4
  import { isOpenApi3_0Element } from '@speclynx/apidom-ns-openapi-3-0';
5
5
  import { isOpenApi3_1Element } from '@speclynx/apidom-ns-openapi-3-1';
6
6
  import { toValue } from '@speclynx/apidom-core';
7
+ import File from "../../../File.mjs";
7
8
  import * as url from "../../../util/url.mjs";
8
9
  import { merge as mergeOptions } from "../../../options/util.mjs";
9
10
  import parse from "../../index.mjs"; // shared key for recursion state (works across JSON/YAML parsers)
@@ -43,7 +44,7 @@ async function parseSourceDescription(sourceDescription, ctx) {
43
44
  }
44
45
  ctx.visitedUrls.add(retrievalURI);
45
46
  try {
46
- const sdParseResult = await parse(retrievalURI, mergeOptions(ctx.options, {
47
+ const sourceDescriptionParseResult = await parse(retrievalURI, mergeOptions(ctx.options, {
47
48
  parse: {
48
49
  mediaType: 'text/plain',
49
50
  // allow parser plugin detection
@@ -56,7 +57,7 @@ async function parseSourceDescription(sourceDescription, ctx) {
56
57
  }
57
58
  }));
58
59
  // merge parsed result into our parse result
59
- for (const item of sdParseResult) {
60
+ for (const item of sourceDescriptionParseResult) {
60
61
  parseResult.push(item);
61
62
  }
62
63
  } catch (error) {
@@ -98,10 +99,40 @@ async function parseSourceDescription(sourceDescription, ctx) {
98
99
  }
99
100
 
100
101
  /**
101
- * Shared function for parsing source descriptions.
102
+ * Parses source descriptions from an Arazzo document's ParseResult.
103
+ *
104
+ * @param parseResult - ParseResult containing an Arazzo specification
105
+ * @param parseResultRetrievalURI - URI from which the parseResult was retrieved
106
+ * @param options - Full ReferenceOptions (caller responsibility to construct)
107
+ * @param parserName - Parser name for options lookup (defaults to 'arazzo-json-1')
108
+ * @returns Array of ParseResultElements. On success, returns one ParseResultElement per
109
+ * source description (each with class 'source-description' and name/type metadata).
110
+ * May return early with a single-element array containing a warning annotation when:
111
+ * - The API is not an Arazzo specification
112
+ * - The sourceDescriptions field is missing or not an array
113
+ * - Maximum parse depth is exceeded (error annotation)
114
+ * Returns an empty array when sourceDescriptions option is disabled or no names match.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * import { options, mergeOptions } from '@speclynx/apidom-reference';
119
+ * import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
120
+ *
121
+ * const fullOptions = mergeOptions(options, {
122
+ * parse: { parserOpts: { sourceDescriptions: true } }
123
+ * });
124
+ * const results = await parseSourceDescriptions(parseResult, uri, fullOptions);
125
+ * ```
126
+ *
102
127
  * @public
103
128
  */
104
- export async function parseSourceDescriptions(parserName, api, file, options) {
129
+ export async function parseSourceDescriptions(parseResult, parseResultRetrievalURI, options, parserName = 'arazzo-json-1') {
130
+ const {
131
+ api
132
+ } = parseResult;
133
+ const file = new File({
134
+ uri: url.sanitize(url.stripHash(parseResultRetrievalURI))
135
+ });
105
136
  const results = [];
106
137
 
107
138
  /**
@@ -7,7 +7,8 @@ var _ramda = require("ramda");
7
7
  var _apidomParserAdapterArazzoYaml = require("@speclynx/apidom-parser-adapter-arazzo-yaml-1");
8
8
  var _ParserError = _interopRequireDefault(require("../../../errors/ParserError.cjs"));
9
9
  var _Parser = _interopRequireDefault(require("../Parser.cjs"));
10
- var _sourceDescription = require("../arazzo-json-1/source-description.cjs");
10
+ var _sourceDescriptions = require("./source-descriptions.cjs");
11
+ exports.parseSourceDescriptions = _sourceDescriptions.parseSourceDescriptions;
11
12
  /**
12
13
  * @public
13
14
  */
@@ -47,7 +48,7 @@ class ArazzoYAML1Parser extends _Parser.default {
47
48
  const parseResult = await (0, _apidomParserAdapterArazzoYaml.parse)(source, parserOpts);
48
49
  const shouldParseSourceDescriptions = options?.parse?.parserOpts?.[this.name]?.sourceDescriptions ?? options?.parse?.parserOpts?.sourceDescriptions;
49
50
  if (shouldParseSourceDescriptions) {
50
- const sourceDescriptions = await (0, _sourceDescription.parseSourceDescriptions)(this.name, parseResult.api, file, options);
51
+ const sourceDescriptions = await (0, _sourceDescriptions.parseSourceDescriptions)(parseResult, file.uri, options, this.name);
51
52
  parseResult.push(...sourceDescriptions);
52
53
  }
53
54
  return parseResult;
@@ -2,7 +2,7 @@ import { pick } from 'ramda';
2
2
  import { parse, mediaTypes as ArazzoYAML1MediaTypes, detect } from '@speclynx/apidom-parser-adapter-arazzo-yaml-1';
3
3
  import ParserError from "../../../errors/ParserError.mjs";
4
4
  import Parser from "../Parser.mjs";
5
- import { parseSourceDescriptions } from "../arazzo-json-1/source-description.mjs";
5
+ import { parseSourceDescriptions } from "./source-descriptions.mjs";
6
6
  /**
7
7
  * @public
8
8
  */
@@ -41,7 +41,7 @@ class ArazzoYAML1Parser extends Parser {
41
41
  const parseResult = await parse(source, parserOpts);
42
42
  const shouldParseSourceDescriptions = options?.parse?.parserOpts?.[this.name]?.sourceDescriptions ?? options?.parse?.parserOpts?.sourceDescriptions;
43
43
  if (shouldParseSourceDescriptions) {
44
- const sourceDescriptions = await parseSourceDescriptions(this.name, parseResult.api, file, options);
44
+ const sourceDescriptions = await parseSourceDescriptions(parseResult, file.uri, options, this.name);
45
45
  parseResult.push(...sourceDescriptions);
46
46
  }
47
47
  return parseResult;
@@ -52,4 +52,5 @@ class ArazzoYAML1Parser extends Parser {
52
52
  }
53
53
  }
54
54
  }
55
+ export { parseSourceDescriptions } from "./source-descriptions.mjs";
55
56
  export default ArazzoYAML1Parser;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.parseSourceDescriptions = void 0;
5
+ var _sourceDescriptions = require("../arazzo-json-1/source-descriptions.cjs");
6
+ /**
7
+ * @public
8
+ */
9
+ const parseSourceDescriptions = (parseResult, parseResultRetrievalURI, options, parserName = 'arazzo-yaml-1') => {
10
+ return (0, _sourceDescriptions.parseSourceDescriptions)(parseResult, parseResultRetrievalURI, options, parserName);
11
+ };
12
+ exports.parseSourceDescriptions = parseSourceDescriptions;
@@ -0,0 +1,7 @@
1
+ import { parseSourceDescriptions as parseSourceDescriptionsBase } from "../arazzo-json-1/source-descriptions.mjs";
2
+ /**
3
+ * @public
4
+ */
5
+ export const parseSourceDescriptions = (parseResult, parseResultRetrievalURI, options, parserName = 'arazzo-yaml-1') => {
6
+ return parseSourceDescriptionsBase(parseResult, parseResultRetrievalURI, options, parserName);
7
+ };
@@ -18,4 +18,5 @@ declare class ArazzoJSON1Parser extends Parser {
18
18
  canParse(file: File): Promise<boolean>;
19
19
  parse(file: File, options?: ReferenceOptions): Promise<ParseResultElement>;
20
20
  }
21
+ export { parseSourceDescriptions } from './source-descriptions.ts';
21
22
  export default ArazzoJSON1Parser;
@@ -0,0 +1,31 @@
1
+ import { ParseResultElement } from '@speclynx/apidom-datamodel';
2
+ import type { ReferenceOptions } from '../../../options/index.ts';
3
+ /**
4
+ * Parses source descriptions from an Arazzo document's ParseResult.
5
+ *
6
+ * @param parseResult - ParseResult containing an Arazzo specification
7
+ * @param parseResultRetrievalURI - URI from which the parseResult was retrieved
8
+ * @param options - Full ReferenceOptions (caller responsibility to construct)
9
+ * @param parserName - Parser name for options lookup (defaults to 'arazzo-json-1')
10
+ * @returns Array of ParseResultElements. On success, returns one ParseResultElement per
11
+ * source description (each with class 'source-description' and name/type metadata).
12
+ * May return early with a single-element array containing a warning annotation when:
13
+ * - The API is not an Arazzo specification
14
+ * - The sourceDescriptions field is missing or not an array
15
+ * - Maximum parse depth is exceeded (error annotation)
16
+ * Returns an empty array when sourceDescriptions option is disabled or no names match.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { options, mergeOptions } from '@speclynx/apidom-reference';
21
+ * import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
22
+ *
23
+ * const fullOptions = mergeOptions(options, {
24
+ * parse: { parserOpts: { sourceDescriptions: true } }
25
+ * });
26
+ * const results = await parseSourceDescriptions(parseResult, uri, fullOptions);
27
+ * ```
28
+ *
29
+ * @public
30
+ */
31
+ export declare function parseSourceDescriptions(parseResult: ParseResultElement, parseResultRetrievalURI: string, options: ReferenceOptions, parserName?: string): Promise<ParseResultElement[]>;
@@ -18,4 +18,5 @@ declare class ArazzoYAML1Parser extends Parser {
18
18
  canParse(file: File): Promise<boolean>;
19
19
  parse(file: File, options?: ReferenceOptions): Promise<ParseResultElement>;
20
20
  }
21
+ export { parseSourceDescriptions } from './source-descriptions.ts';
21
22
  export default ArazzoYAML1Parser;
@@ -0,0 +1,6 @@
1
+ import { ParseResultElement } from '@speclynx/apidom-datamodel';
2
+ import type { ReferenceOptions } from '../../../options/index.ts';
3
+ /**
4
+ * @public
5
+ */
6
+ export declare const parseSourceDescriptions: (parseResult: ParseResultElement, parseResultRetrievalURI: string, options: ReferenceOptions, parserName?: string) => Promise<ParseResultElement[]>;
@@ -1,8 +0,0 @@
1
- import { Element, ParseResultElement } from '@speclynx/apidom-datamodel';
2
- import File from '../../../File.ts';
3
- import type { ReferenceOptions } from '../../../options/index.ts';
4
- /**
5
- * Shared function for parsing source descriptions.
6
- * @public
7
- */
8
- export declare function parseSourceDescriptions(parserName: string, api: Element | undefined, file: File, options: ReferenceOptions): Promise<ParseResultElement[]>;