@speclynx/apidom-parser-adapter-asyncapi-yaml-2 3.2.1 → 4.0.1

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,14 @@
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.1](https://github.com/speclynx/apidom/compare/v4.0.0...v4.0.1) (2026-03-11)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-asyncapi-yaml-2
9
+
10
+ # [4.0.0](https://github.com/speclynx/apidom/compare/v3.2.1...v4.0.0) (2026-03-11)
11
+
12
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-asyncapi-yaml-2
13
+
6
14
  ## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
7
15
 
8
16
  **Note:** Version bump only for package @speclynx/apidom-parser-adapter-asyncapi-yaml-2
@@ -54967,7 +54967,9 @@ class Path {
54967
54967
  *
54968
54968
  * @example
54969
54969
  * // For a path to $.paths['/pets'].get in an OpenAPI document:
54970
+ * ```
54970
54971
  * path.getPathKeys(); // => ['paths', '/pets', 'get']
54972
+ * ```
54971
54973
  */
54972
54974
  getPathKeys() {
54973
54975
  const keys = [];
@@ -55002,18 +55004,22 @@ class Path {
55002
55004
  * or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
55003
55005
  *
55004
55006
  * @example
55007
+ * ```
55005
55008
  * // JSON Pointer examples:
55006
55009
  * path.formatPath(); // "" (root)
55007
55010
  * path.formatPath(); // "/info"
55008
55011
  * path.formatPath(); // "/paths/~1pets/get"
55009
55012
  * path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
55013
+ * ```
55010
55014
  *
55011
55015
  * @example
55016
+ * ```
55012
55017
  * // JSONPath examples:
55013
55018
  * path.formatPath('jsonpath'); // "$" (root)
55014
55019
  * path.formatPath('jsonpath'); // "$['info']"
55015
55020
  * path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
55016
55021
  * path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
55022
+ * ```
55017
55023
  */
55018
55024
  formatPath(pathFormat = 'jsonpointer') {
55019
55025
  const parts = this.getPathKeys();
@@ -55223,15 +55229,15 @@ __webpack_require__.r(__webpack_exports__);
55223
55229
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
55224
55230
 
55225
55231
  /**
55226
- * Finds all elements matching the predicate.
55232
+ * Finds all paths whose elements match the predicate.
55227
55233
  * @public
55228
55234
  */
55229
55235
  const filter = (element, predicate) => {
55230
55236
  const result = [];
55231
55237
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
55232
55238
  enter(path) {
55233
- if (predicate(path.node)) {
55234
- result.push(path.node);
55239
+ if (predicate(path)) {
55240
+ result.push(path);
55235
55241
  }
55236
55242
  }
55237
55243
  });
@@ -55257,7 +55263,7 @@ __webpack_require__.r(__webpack_exports__);
55257
55263
  * @public
55258
55264
  */
55259
55265
  /**
55260
- * Finds the most inner node at the given offset.
55266
+ * Finds the path of the most inner node at the given offset.
55261
55267
  * If includeRightBound is set, also finds nodes that end at the given offset.
55262
55268
  * @public
55263
55269
  */
@@ -55282,7 +55288,7 @@ const findAtOffset = (element, options) => {
55282
55288
  const endOffset = node.endOffset;
55283
55289
  const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
55284
55290
  if (isWithinOffsetRange) {
55285
- result.push(node);
55291
+ result.push(path);
55286
55292
  return; // push to stack and dive in
55287
55293
  }
55288
55294
  path.skip(); // skip entire sub-tree
@@ -55305,15 +55311,15 @@ __webpack_require__.r(__webpack_exports__);
55305
55311
  /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
55306
55312
 
55307
55313
  /**
55308
- * Find first element that satisfies the provided predicate.
55314
+ * Finds first path whose element satisfies the provided predicate.
55309
55315
  * @public
55310
55316
  */
55311
55317
  const find = (element, predicate) => {
55312
55318
  let result;
55313
55319
  (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
55314
55320
  enter(path) {
55315
- if (predicate(path.node)) {
55316
- result = path.node;
55321
+ if (predicate(path)) {
55322
+ result = path;
55317
55323
  path.stop();
55318
55324
  }
55319
55325
  }
@@ -55332,9 +55338,7 @@ __webpack_require__.r(__webpack_exports__);
55332
55338
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
55333
55339
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
55334
55340
  /* harmony export */ });
55335
- /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25162);
55336
- /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(72078);
55337
-
55341
+ /* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
55338
55342
 
55339
55343
  /**
55340
55344
  * @public
@@ -55343,7 +55347,7 @@ __webpack_require__.r(__webpack_exports__);
55343
55347
  * @public
55344
55348
  */
55345
55349
  /**
55346
- * Executes the callback on this element and all descendants.
55350
+ * Executes the callback on this element's path and all descendant paths.
55347
55351
  * @public
55348
55352
  */
55349
55353
  const forEach = (element, options) => {
@@ -55351,15 +55355,15 @@ const forEach = (element, options) => {
55351
55355
  let predicate;
55352
55356
  if (typeof options === 'function') {
55353
55357
  callback = options;
55354
- predicate = _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
55358
+ predicate = () => true;
55355
55359
  } else {
55356
55360
  callback = options.callback ?? (() => {});
55357
- predicate = options.predicate ?? _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isElement;
55361
+ predicate = options.predicate ?? (() => true);
55358
55362
  }
55359
- (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_1__.traverse)(element, {
55363
+ (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
55360
55364
  enter(path) {
55361
- if (predicate(path.node)) {
55362
- callback(path.node);
55365
+ if (predicate(path)) {
55366
+ callback(path);
55363
55367
  }
55364
55368
  }
55365
55369
  });
@@ -55408,11 +55412,11 @@ __webpack_require__.r(__webpack_exports__);
55408
55412
  /* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(75247);
55409
55413
 
55410
55414
  /**
55411
- * Complement of filter. Finds all elements NOT matching the predicate.
55415
+ * Complement of filter. Finds all paths whose elements do NOT match the predicate.
55412
55416
  * @public
55413
55417
  */
55414
55418
  const reject = (element, predicate) => {
55415
- return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, el => !predicate(el));
55419
+ return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
55416
55420
  };
55417
55421
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
55418
55422
 
@@ -55429,7 +55433,7 @@ __webpack_require__.r(__webpack_exports__);
55429
55433
  /* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44860);
55430
55434
 
55431
55435
  /**
55432
- * Tests whether at least one element passes the predicate.
55436
+ * Tests whether at least one path's element passes the predicate.
55433
55437
  * @public
55434
55438
  */
55435
55439
  const some = (element, predicate) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speclynx/apidom-parser-adapter-asyncapi-yaml-2",
3
- "version": "3.2.1",
3
+ "version": "4.0.1",
4
4
  "description": "Parser adapter for parsing YAML documents into AsyncAPI 2.x.y namespace.",
5
5
  "keywords": [
6
6
  "apidom",
@@ -60,10 +60,10 @@
60
60
  "license": "Apache-2.0",
61
61
  "dependencies": {
62
62
  "@babel/runtime-corejs3": "^7.28.4",
63
- "@speclynx/apidom-core": "3.2.1",
64
- "@speclynx/apidom-datamodel": "3.2.1",
65
- "@speclynx/apidom-ns-asyncapi-2": "3.2.1",
66
- "@speclynx/apidom-parser-adapter-yaml-1-2": "3.2.1",
63
+ "@speclynx/apidom-core": "4.0.1",
64
+ "@speclynx/apidom-datamodel": "4.0.1",
65
+ "@speclynx/apidom-ns-asyncapi-2": "4.0.1",
66
+ "@speclynx/apidom-parser-adapter-yaml-1-2": "4.0.1",
67
67
  "ramda": "~0.32.0",
68
68
  "ramda-adjunct": "^6.0.0"
69
69
  },
@@ -77,5 +77,5 @@
77
77
  "README.md",
78
78
  "CHANGELOG.md"
79
79
  ],
80
- "gitHead": "83a1e97089ef29134e41ff7cacd351973114ea5b"
80
+ "gitHead": "223132a9b00081ca04842efc2736a491f7876f44"
81
81
  }
package/src/adapter.cjs DELETED
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
5
- exports.__esModule = true;
6
- exports.parse = exports.namespace = exports.mediaTypes = exports.detectionRegExp = exports.detect = void 0;
7
- var _ramda = require("ramda");
8
- var _ramdaAdjunct = require("ramda-adjunct");
9
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
10
- var _apidomParserAdapterYaml = require("@speclynx/apidom-parser-adapter-yaml-1-2");
11
- var _apidomNsAsyncapi = _interopRequireWildcard(require("@speclynx/apidom-ns-asyncapi-2"));
12
- var _mediaTypes = _interopRequireDefault(require("./media-types.cjs"));
13
- exports.mediaTypes = _mediaTypes.default;
14
- /**
15
- * @public
16
- */
17
- const detectionRegExp = exports.detectionRegExp = /(?<YAML>^(["']?)asyncapi\2\s*:\s*(["']?)(?<version_yaml>2\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))\3(?:\s+|$))|(?<JSON>"asyncapi"\s*:\s*"(?<version_json>2\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))")/m;
18
-
19
- /**
20
- * @public
21
- */
22
- const detect = async (source, options = {}) => detectionRegExp.test(source) && (await (0, _apidomParserAdapterYaml.detect)(source, options));
23
-
24
- /**
25
- * @public
26
- */
27
- exports.detect = detect;
28
- /**
29
- * @public
30
- */
31
- const parse = async (source, options = {}) => {
32
- const refractorOpts = (0, _ramda.propOr)({}, 'refractorOpts', options);
33
- const parserOpts = (0, _ramda.omit)(['refractorOpts'], options);
34
- const parseResultElement = await (0, _apidomParserAdapterYaml.parse)(source, parserOpts);
35
- const {
36
- result
37
- } = parseResultElement;
38
- if ((0, _ramdaAdjunct.isNotUndefined)(result)) {
39
- const asyncApiElement = (0, _apidomNsAsyncapi.refractAsyncApi2)(result, {
40
- consume: true,
41
- ...refractorOpts
42
- });
43
- asyncApiElement.classes.push('result');
44
- parseResultElement.replaceResult(asyncApiElement);
45
- }
46
- return parseResultElement;
47
- };
48
-
49
- /**
50
- * @public
51
- */
52
- exports.parse = parse;
53
- const namespace = exports.namespace = new _apidomDatamodel.Namespace().use(_apidomNsAsyncapi.default);
package/src/adapter.mjs DELETED
@@ -1,45 +0,0 @@
1
- import { omit, propOr } from 'ramda';
2
- import { isNotUndefined } from 'ramda-adjunct';
3
- import { Namespace } from '@speclynx/apidom-datamodel';
4
- import { parse as parseYAML, detect as detectYAML } from '@speclynx/apidom-parser-adapter-yaml-1-2';
5
- import asyncApiNamespace, { refractAsyncApi2 } from '@speclynx/apidom-ns-asyncapi-2';
6
- export { default as mediaTypes } from "./media-types.mjs";
7
- /**
8
- * @public
9
- */
10
- export const detectionRegExp = /(?<YAML>^(["']?)asyncapi\2\s*:\s*(["']?)(?<version_yaml>2\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))\3(?:\s+|$))|(?<JSON>"asyncapi"\s*:\s*"(?<version_json>2\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))")/m;
11
-
12
- /**
13
- * @public
14
- */
15
- export const detect = async (source, options = {}) => detectionRegExp.test(source) && (await detectYAML(source, options));
16
-
17
- /**
18
- * @public
19
- */
20
-
21
- /**
22
- * @public
23
- */
24
- export const parse = async (source, options = {}) => {
25
- const refractorOpts = propOr({}, 'refractorOpts', options);
26
- const parserOpts = omit(['refractorOpts'], options);
27
- const parseResultElement = await parseYAML(source, parserOpts);
28
- const {
29
- result
30
- } = parseResultElement;
31
- if (isNotUndefined(result)) {
32
- const asyncApiElement = refractAsyncApi2(result, {
33
- consume: true,
34
- ...refractorOpts
35
- });
36
- asyncApiElement.classes.push('result');
37
- parseResultElement.replaceResult(asyncApiElement);
38
- }
39
- return parseResultElement;
40
- };
41
-
42
- /**
43
- * @public
44
- */
45
- export const namespace = new Namespace().use(asyncApiNamespace);
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _apidomNsAsyncapi = require("@speclynx/apidom-ns-asyncapi-2");
6
- /**
7
- * @public
8
- */
9
- const yamlMediaTypes = new _apidomNsAsyncapi.AsyncAPIMediaTypes(..._apidomNsAsyncapi.mediaTypes.filterByFormat('generic'), ..._apidomNsAsyncapi.mediaTypes.filterByFormat('yaml'));
10
- var _default = exports.default = yamlMediaTypes;
@@ -1,7 +0,0 @@
1
- import { mediaTypes, AsyncAPIMediaTypes } from '@speclynx/apidom-ns-asyncapi-2';
2
-
3
- /**
4
- * @public
5
- */
6
- const yamlMediaTypes = new AsyncAPIMediaTypes(...mediaTypes.filterByFormat('generic'), ...mediaTypes.filterByFormat('yaml'));
7
- export default yamlMediaTypes;