@speclynx/apidom-parser 4.0.3 → 4.0.4

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 CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.0.4](https://github.com/speclynx/apidom/compare/v4.0.3...v4.0.4) (2026-03-12)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **release:** override minimatch 10.2.3 to fix glob pattern regression in lerna publish ([#157](https://github.com/speclynx/apidom/issues/157)) ([c2d65a0](https://github.com/speclynx/apidom/commit/c2d65a06a2187e8563a9dc9db74ba27255450e0b)), closes [lerna/lerna#4305](https://github.com/lerna/lerna/issues/4305) [isaacs/minimatch#284](https://github.com/isaacs/minimatch/issues/284)
11
+
6
12
  ## [4.0.3](https://github.com/speclynx/apidom/compare/v4.0.2...v4.0.3) (2026-03-11)
7
13
 
8
14
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-parser",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Parser consumes parser adapters and provides unified API for parsing.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -59,14 +59,15 @@
59
59
  "license": "Apache-2.0",
60
60
  "dependencies": {
61
61
  "@babel/runtime-corejs3": "^7.28.4",
62
- "@speclynx/apidom-core": "4.0.3",
63
- "@speclynx/apidom-datamodel": "4.0.3",
64
- "@speclynx/apidom-error": "4.0.3",
62
+ "@speclynx/apidom-core": "4.0.4",
63
+ "@speclynx/apidom-datamodel": "4.0.4",
64
+ "@speclynx/apidom-error": "4.0.4",
65
65
  "ramda": "~0.32.0",
66
66
  "ramda-adjunct": "^6.0.0"
67
67
  },
68
68
  "files": [
69
- "src/",
69
+ "src/**/*.mjs",
70
+ "src/**/*.cjs",
70
71
  "dist/",
71
72
  "types/apidom-parser.d.ts",
72
73
  "LICENSES",
@@ -74,5 +75,5 @@
74
75
  "README.md",
75
76
  "CHANGELOG.md"
76
77
  ],
77
- "gitHead": "6ccfa09c02232516215e7de3ead276641957e626"
78
+ "gitHead": "a06f6ef3d37ad5bf860cbbf4b442bfbe3a522cc2"
78
79
  }
@@ -1,31 +0,0 @@
1
- import { ApiDOMStructuredError, ApiDOMErrorOptions } from '@speclynx/apidom-error';
2
-
3
- import type { ApiDOMParserOptions } from '../parser.ts';
4
-
5
- /**
6
- * @public
7
- */
8
- export interface ParserErrorOptions extends ApiDOMErrorOptions {
9
- readonly source: string;
10
- readonly parserOptions: ApiDOMParserOptions;
11
- }
12
-
13
- /**
14
- * @public
15
- */
16
- class ParserError extends ApiDOMStructuredError {
17
- public readonly source!: string;
18
-
19
- public readonly parserOptions!: ApiDOMParserOptions;
20
-
21
- constructor(message?: string, structuredOptions?: ParserErrorOptions) {
22
- super(message, structuredOptions);
23
-
24
- if (typeof structuredOptions !== 'undefined') {
25
- this.source = structuredOptions.source;
26
- this.parserOptions = structuredOptions.parserOptions;
27
- }
28
- }
29
- }
30
-
31
- export default ParserError;
package/src/parser.ts DELETED
@@ -1,163 +0,0 @@
1
- import { head } from 'ramda';
2
- import { isArray, isFunction, isString, isUndefined } from 'ramda-adjunct';
3
- import { Namespace, ParseResultElement } from '@speclynx/apidom-datamodel';
4
- import { MediaTypes } from '@speclynx/apidom-core';
5
-
6
- import ParserError from './errors/ParserError.ts';
7
-
8
- export type { ParserErrorOptions } from './errors/ParserError.ts';
9
- export { ParserError };
10
-
11
- /**
12
- * @public
13
- */
14
- export interface ApiDOMParserOptions {
15
- readonly mediaType?: string;
16
- readonly sourceMap?: boolean;
17
- readonly strict?: boolean;
18
- [key: string]: unknown;
19
- }
20
-
21
- /**
22
- * @public
23
- */
24
- export type Detect = (source: string, options?: ApiDOMParserOptions) => boolean | Promise<boolean>;
25
-
26
- /**
27
- * @public
28
- */
29
- export type Parse = (source: string, options?: ApiDOMParserOptions) => Promise<ParseResultElement>;
30
-
31
- /**
32
- * @public
33
- */
34
- export interface ApiDOMParserAdapter {
35
- detectionRegExp?: RegExp;
36
- detect?: Detect;
37
- mediaTypes?: MediaTypes<string>;
38
- parse: Parse;
39
- namespace: Namespace;
40
- }
41
-
42
- /**
43
- * @public
44
- */
45
- class ApiDOMParser {
46
- private adapters: ApiDOMParserAdapter[] = [];
47
-
48
- protected async detectAdapterCandidates(
49
- source: string,
50
- options: ApiDOMParserOptions = {},
51
- ): Promise<ApiDOMParserAdapter[]> {
52
- const candidates = [];
53
-
54
- for (const adapter of this.adapters) {
55
- if (isFunction(adapter.detect) && (await adapter.detect(source, options))) {
56
- candidates.push(adapter);
57
- }
58
- }
59
-
60
- return candidates;
61
- }
62
-
63
- protected async findAdapter(
64
- source: string,
65
- options: ApiDOMParserOptions = {},
66
- ): Promise<ApiDOMParserAdapter | undefined> {
67
- if (isString(options.mediaType)) {
68
- return this.adapters.find((adapter) => {
69
- if (!isArray(adapter.mediaTypes)) return false;
70
-
71
- return adapter.mediaTypes.includes(options.mediaType!);
72
- });
73
- }
74
-
75
- const candidates = await this.detectAdapterCandidates(source, options);
76
-
77
- return head(candidates);
78
- }
79
-
80
- use(adapter: ApiDOMParserAdapter): this {
81
- this.adapters.push(adapter);
82
- return this;
83
- }
84
-
85
- async findNamespace(
86
- source: string,
87
- options: ApiDOMParserOptions = {},
88
- ): Promise<Namespace | undefined> {
89
- const adapter = await this.findAdapter(source, options);
90
-
91
- return adapter?.namespace;
92
- }
93
-
94
- async findMediaType(source: string): Promise<string | void> {
95
- const adapter = await this.findAdapter(source, {});
96
-
97
- if (typeof adapter === 'undefined') {
98
- return new MediaTypes().unknownMediaType;
99
- }
100
-
101
- if (typeof adapter.mediaTypes === 'undefined') {
102
- return new MediaTypes().unknownMediaType;
103
- }
104
-
105
- if (typeof adapter.detectionRegExp === 'undefined') {
106
- return adapter.mediaTypes.latest();
107
- }
108
-
109
- const { detectionRegExp } = adapter;
110
- const matches = source.match(detectionRegExp);
111
-
112
- if (matches === null) {
113
- return new MediaTypes().unknownMediaType;
114
- }
115
-
116
- const { groups } = matches;
117
- const version = groups?.version || groups?.version_json || groups?.version_yaml;
118
- const format = groups?.version_json ? 'json' : groups?.version_yaml ? 'yaml' : 'generic';
119
-
120
- if (typeof version === 'undefined') {
121
- return adapter.mediaTypes.latest();
122
- }
123
-
124
- // @ts-ignore
125
- return adapter.mediaTypes.findBy(version, format);
126
- }
127
-
128
- async parse(source: string, options: ApiDOMParserOptions = {}): Promise<ParseResultElement> {
129
- let adapter;
130
-
131
- try {
132
- adapter = await this.findAdapter(source, options);
133
- } catch (error: unknown) {
134
- throw new ParserError(
135
- 'Encountered an unexpected error while matching parser adapters against the source.',
136
- {
137
- source,
138
- parserOptions: options,
139
- cause: error,
140
- },
141
- );
142
- }
143
-
144
- if (isUndefined(adapter)) {
145
- throw new ParserError('Source did not match any registered parsers', {
146
- source,
147
- parserOptions: options,
148
- });
149
- }
150
-
151
- try {
152
- return adapter.parse(source, options);
153
- } catch (error: unknown) {
154
- throw new ParserError('Parsing encountered an unexpected error.', {
155
- source,
156
- parserOptions: options,
157
- cause: error,
158
- });
159
- }
160
- }
161
- }
162
-
163
- export default ApiDOMParser;