@speclynx/apidom-reference 2.6.0 → 2.7.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +60 -33
  3. package/dist/apidom-reference.browser.js +79395 -79177
  4. package/dist/apidom-reference.browser.min.js +1 -1
  5. package/package.json +25 -25
  6. package/src/bundle/index.cjs +1 -1
  7. package/src/bundle/index.mjs +1 -1
  8. package/src/configuration/saturated.cjs +2 -4
  9. package/src/configuration/saturated.mjs +3 -5
  10. package/src/dereference/index.cjs +1 -1
  11. package/src/dereference/index.mjs +1 -1
  12. package/src/dereference/strategies/arazzo-1/index.cjs +10 -0
  13. package/src/dereference/strategies/arazzo-1/index.mjs +10 -0
  14. package/src/dereference/strategies/arazzo-1/source-description.cjs +179 -0
  15. package/src/dereference/strategies/arazzo-1/source-description.mjs +172 -0
  16. package/src/dereference/strategies/openapi-3-0/visitor.cjs +3 -3
  17. package/src/dereference/strategies/openapi-3-0/visitor.mjs +3 -3
  18. package/src/dereference/strategies/openapi-3-1/visitor.cjs +3 -3
  19. package/src/dereference/strategies/openapi-3-1/visitor.mjs +3 -3
  20. package/src/errors/InvalidJsonSchema$anchorError.cjs +1 -1
  21. package/src/errors/InvalidJsonSchema$anchorError.mjs +1 -1
  22. package/src/errors/UnmatchedParserError.cjs +11 -0
  23. package/src/errors/UnmatchedParserError.mjs +6 -0
  24. package/src/index.cjs +3 -1
  25. package/src/index.mjs +1 -0
  26. package/src/parse/index.cjs +3 -3
  27. package/src/parse/index.mjs +3 -3
  28. package/src/parse/parsers/arazzo-json-1/index.cjs +1 -4
  29. package/src/parse/parsers/arazzo-json-1/index.mjs +1 -4
  30. package/src/parse/parsers/arazzo-json-1/source-description.cjs +14 -19
  31. package/src/parse/parsers/arazzo-json-1/source-description.mjs +14 -20
  32. package/src/parse/parsers/arazzo-yaml-1/index.cjs +1 -4
  33. package/src/parse/parsers/arazzo-yaml-1/index.mjs +1 -4
  34. package/src/resolve/index.cjs +2 -2
  35. package/src/resolve/index.mjs +2 -2
  36. package/src/resolve/resolvers/file/index-browser.cjs +1 -1
  37. package/src/resolve/resolvers/file/index-browser.mjs +1 -1
  38. package/src/resolve/strategies/apidom/index.cjs +1 -1
  39. package/src/resolve/strategies/apidom/index.mjs +1 -1
  40. package/src/resolve/strategies/asyncapi-2/index.cjs +1 -1
  41. package/src/resolve/strategies/asyncapi-2/index.mjs +1 -1
  42. package/src/resolve/strategies/openapi-2/index.cjs +1 -1
  43. package/src/resolve/strategies/openapi-2/index.mjs +1 -1
  44. package/src/resolve/strategies/openapi-3-0/index.cjs +1 -1
  45. package/src/resolve/strategies/openapi-3-0/index.mjs +1 -1
  46. package/src/resolve/strategies/openapi-3-1/index.cjs +1 -1
  47. package/src/resolve/strategies/openapi-3-1/index.mjs +1 -1
  48. package/src/resolve/util.cjs +1 -1
  49. package/src/resolve/util.mjs +1 -1
  50. package/types/apidom-reference.d.ts +6 -0
  51. package/types/dereference/strategies/arazzo-1/source-description.d.ts +8 -0
  52. package/types/errors/UnmatchedParserError.d.ts +7 -0
  53. package/types/index.d.ts +1 -0
  54. package/types/parse/parsers/arazzo-json-1/index.d.ts +0 -3
  55. package/types/parse/parsers/arazzo-json-1/source-description.d.ts +1 -6
  56. package/types/parse/parsers/arazzo-yaml-1/index.d.ts +0 -3
@@ -31,7 +31,7 @@ class OpenAPI3_0ResolveStrategy extends _ResolveStrategy.default {
31
31
  async resolve(file, options) {
32
32
  const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'openapi-3-0');
33
33
  if (dereferenceStrategy === undefined) {
34
- throw new _UnmatchedDereferenceStrategyError.default('"openapi-3-0" dereference strategy is not available.');
34
+ throw new _UnmatchedDereferenceStrategyError.default(`"openapi-3-0" resolve strategy requires "openapi-3-0" dereference strategy to be configured for file "${file.uri}"`);
35
35
  }
36
36
  const refSet = new _ReferenceSet.default();
37
37
  const mergedOptions = (0, _util.merge)(options, {
@@ -25,7 +25,7 @@ class OpenAPI3_0ResolveStrategy extends ResolveStrategy {
25
25
  async resolve(file, options) {
26
26
  const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'openapi-3-0');
27
27
  if (dereferenceStrategy === undefined) {
28
- throw new UnmatchedDereferenceStrategyError('"openapi-3-0" dereference strategy is not available.');
28
+ throw new UnmatchedDereferenceStrategyError(`"openapi-3-0" resolve strategy requires "openapi-3-0" dereference strategy to be configured for file "${file.uri}"`);
29
29
  }
30
30
  const refSet = new ReferenceSet();
31
31
  const mergedOptions = mergeOptions(options, {
@@ -31,7 +31,7 @@ class OpenAPI3_1ResolveStrategy extends _ResolveStrategy.default {
31
31
  async resolve(file, options) {
32
32
  const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'openapi-3-1');
33
33
  if (dereferenceStrategy === undefined) {
34
- throw new _UnmatchedDereferenceStrategyError.default('"openapi-3-1" dereference strategy is not available.');
34
+ throw new _UnmatchedDereferenceStrategyError.default(`"openapi-3-1" resolve strategy requires "openapi-3-1" dereference strategy to be configured for file "${file.uri}"`);
35
35
  }
36
36
  const refSet = new _ReferenceSet.default();
37
37
  const mergedOptions = (0, _util.merge)(options, {
@@ -25,7 +25,7 @@ class OpenAPI3_1ResolveStrategy extends ResolveStrategy {
25
25
  async resolve(file, options) {
26
26
  const dereferenceStrategy = options.dereference.strategies.find(strategy => strategy.name === 'openapi-3-1');
27
27
  if (dereferenceStrategy === undefined) {
28
- throw new UnmatchedDereferenceStrategyError('"openapi-3-1" dereference strategy is not available.');
28
+ throw new UnmatchedDereferenceStrategyError(`"openapi-3-1" resolve strategy requires "openapi-3-1" dereference strategy to be configured for file "${file.uri}"`);
29
29
  }
30
30
  const refSet = new ReferenceSet();
31
31
  const mergedOptions = mergeOptions(options, {
@@ -21,7 +21,7 @@ const readFile = async (file, options) => {
21
21
 
22
22
  // we couldn't find any resolver for this File
23
23
  if ((0, _ramda.isEmpty)(resolvers)) {
24
- throw new _UnmatchedResolverError.default(file.uri);
24
+ throw new _UnmatchedResolverError.default(`Could not find a resolver that can read the file "${file.uri}"`);
25
25
  }
26
26
  try {
27
27
  const {
@@ -15,7 +15,7 @@ export const readFile = async (file, options) => {
15
15
 
16
16
  // we couldn't find any resolver for this File
17
17
  if (isEmpty(resolvers)) {
18
- throw new UnmatchedResolverError(file.uri);
18
+ throw new UnmatchedResolverError(`Could not find a resolver that can read the file "${file.uri}"`);
19
19
  }
20
20
  try {
21
21
  const {
@@ -533,6 +533,12 @@ export declare class UnmatchedBundleStrategyError extends BundleError {
533
533
  export declare class UnmatchedDereferenceStrategyError extends DereferenceError {
534
534
  }
535
535
 
536
+ /**
537
+ * @public
538
+ */
539
+ export declare class UnmatchedParserError extends ParserError {
540
+ }
541
+
536
542
  /**
537
543
  * @public
538
544
  */
@@ -0,0 +1,8 @@
1
+ import { ParseResultElement } from '@speclynx/apidom-datamodel';
2
+ import Reference from '../../../Reference.ts';
3
+ import type { ReferenceOptions } from '../../../options/index.ts';
4
+ /**
5
+ * Dereferences source descriptions from an Arazzo document.
6
+ * @public
7
+ */
8
+ export declare function dereferenceSourceDescriptions(parseResult: ParseResultElement, reference: Reference, options: ReferenceOptions): Promise<ParseResultElement[]>;
@@ -0,0 +1,7 @@
1
+ import ParserError from './ParserError.ts';
2
+ /**
3
+ * @public
4
+ */
5
+ declare class UnmatchedParserError extends ParserError {
6
+ }
7
+ export default UnmatchedParserError;
package/types/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export { default as ResolverError } from './errors/ResolverError.ts';
45
45
  export { default as UnmatchedDereferenceStrategyError } from './errors/UnmatchedDereferenceStrategyError.ts';
46
46
  export { default as UnmatchedResolveStrategyError } from './errors/UnmatchedResolveStrategyError.ts';
47
47
  export { default as UnmatchedResolverError } from './errors/UnmatchedResolverError.ts';
48
+ export { default as UnmatchedParserError } from './errors/UnmatchedParserError.ts';
48
49
  /**
49
50
  * @public
50
51
  */
@@ -2,21 +2,18 @@ import { ParseResultElement } from '@speclynx/apidom-datamodel';
2
2
  import Parser, { ParserOptions } from '../Parser.ts';
3
3
  import File from '../../../File.ts';
4
4
  import type { ReferenceOptions } from '../../../options/index.ts';
5
- import type ParseFn from '../../index.ts';
6
5
  export type { default as Parser, ParserOptions } from '../Parser.ts';
7
6
  export type { default as File, FileOptions } from '../../../File.ts';
8
7
  /**
9
8
  * @public
10
9
  */
11
10
  export interface ArazzoJSON1ParserOptions extends Omit<ParserOptions, 'name'> {
12
- readonly parseFn?: typeof ParseFn;
13
11
  }
14
12
  /**
15
13
  * @public
16
14
  */
17
15
  declare class ArazzoJSON1Parser extends Parser {
18
16
  refractorOpts: object;
19
- parseFn?: typeof ParseFn;
20
17
  constructor(options?: ArazzoJSON1ParserOptions);
21
18
  canParse(file: File): Promise<boolean>;
22
19
  parse(file: File, options?: ReferenceOptions): Promise<ParseResultElement>;
@@ -1,13 +1,8 @@
1
1
  import { Element, ParseResultElement } from '@speclynx/apidom-datamodel';
2
2
  import File from '../../../File.ts';
3
3
  import type { ReferenceOptions } from '../../../options/index.ts';
4
- import type ParseFn from '../../index.ts';
5
4
  /**
6
5
  * Shared function for parsing source descriptions.
7
- * Call with `.call(this, ...)` where `this` has `name` and `parseFn` properties.
8
6
  * @public
9
7
  */
10
- export declare function parseSourceDescriptions(this: {
11
- name: string;
12
- parseFn?: typeof ParseFn;
13
- }, api: Element | undefined, file: File, options: ReferenceOptions): Promise<ParseResultElement[]>;
8
+ export declare function parseSourceDescriptions(parserName: string, api: Element | undefined, file: File, options: ReferenceOptions): Promise<ParseResultElement[]>;
@@ -2,21 +2,18 @@ import { ParseResultElement } from '@speclynx/apidom-datamodel';
2
2
  import Parser, { ParserOptions } from '../Parser.ts';
3
3
  import File from '../../../File.ts';
4
4
  import type { ReferenceOptions } from '../../../options/index.ts';
5
- import type ParseFn from '../../index.ts';
6
5
  export type { default as Parser, ParserOptions } from '../Parser.ts';
7
6
  export type { default as File, FileOptions } from '../../../File.ts';
8
7
  /**
9
8
  * @public
10
9
  */
11
10
  export interface ArazzoYAML1ParserOptions extends Omit<ParserOptions, 'name'> {
12
- readonly parseFn?: typeof ParseFn;
13
11
  }
14
12
  /**
15
13
  * @public
16
14
  */
17
15
  declare class ArazzoYAML1Parser extends Parser {
18
16
  refractorOpts: object;
19
- parseFn?: typeof ParseFn;
20
17
  constructor(options?: ArazzoYAML1ParserOptions);
21
18
  canParse(file: File): Promise<boolean>;
22
19
  parse(file: File, options?: ReferenceOptions): Promise<ParseResultElement>;