@speclynx/apidom-parser-adapter-asyncapi-json-2 3.2.0 → 4.0.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/CHANGELOG.md +8 -0
- package/dist/apidom-parser-adapter-asyncapi-json-2.browser.js +24 -20
- package/package.json +6 -6
- package/src/adapter.cjs +0 -53
- package/src/adapter.mjs +0 -45
- package/src/media-types.cjs +0 -10
- package/src/media-types.mjs +0 -7
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.0](https://github.com/speclynx/apidom/compare/v3.2.1...v4.0.0) (2026-03-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @speclynx/apidom-parser-adapter-asyncapi-json-2
|
|
9
|
+
|
|
10
|
+
## [3.2.1](https://github.com/speclynx/apidom/compare/v3.2.0...v3.2.1) (2026-03-09)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @speclynx/apidom-parser-adapter-asyncapi-json-2
|
|
13
|
+
|
|
6
14
|
# [3.2.0](https://github.com/speclynx/apidom/compare/v3.1.0...v3.2.0) (2026-03-08)
|
|
7
15
|
|
|
8
16
|
### Features
|
|
@@ -42240,7 +42240,9 @@ class Path {
|
|
|
42240
42240
|
*
|
|
42241
42241
|
* @example
|
|
42242
42242
|
* // For a path to $.paths['/pets'].get in an OpenAPI document:
|
|
42243
|
+
* ```
|
|
42243
42244
|
* path.getPathKeys(); // => ['paths', '/pets', 'get']
|
|
42245
|
+
* ```
|
|
42244
42246
|
*/
|
|
42245
42247
|
getPathKeys() {
|
|
42246
42248
|
const keys = [];
|
|
@@ -42275,18 +42277,22 @@ class Path {
|
|
|
42275
42277
|
* or Normalized JSONPath like "$['paths']['/pets']['get']['responses']['200']"
|
|
42276
42278
|
*
|
|
42277
42279
|
* @example
|
|
42280
|
+
* ```
|
|
42278
42281
|
* // JSON Pointer examples:
|
|
42279
42282
|
* path.formatPath(); // "" (root)
|
|
42280
42283
|
* path.formatPath(); // "/info"
|
|
42281
42284
|
* path.formatPath(); // "/paths/~1pets/get"
|
|
42282
42285
|
* path.formatPath(); // "/paths/~1users~1{id}/parameters/0"
|
|
42286
|
+
* ```
|
|
42283
42287
|
*
|
|
42284
42288
|
* @example
|
|
42289
|
+
* ```
|
|
42285
42290
|
* // JSONPath examples:
|
|
42286
42291
|
* path.formatPath('jsonpath'); // "$" (root)
|
|
42287
42292
|
* path.formatPath('jsonpath'); // "$['info']"
|
|
42288
42293
|
* path.formatPath('jsonpath'); // "$['paths']['/pets']['get']"
|
|
42289
42294
|
* path.formatPath('jsonpath'); // "$['paths']['/users/{id}']['parameters'][0]"
|
|
42295
|
+
* ```
|
|
42290
42296
|
*/
|
|
42291
42297
|
formatPath(pathFormat = 'jsonpointer') {
|
|
42292
42298
|
const parts = this.getPathKeys();
|
|
@@ -42496,15 +42502,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42496
42502
|
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
|
|
42497
42503
|
|
|
42498
42504
|
/**
|
|
42499
|
-
* Finds all elements
|
|
42505
|
+
* Finds all paths whose elements match the predicate.
|
|
42500
42506
|
* @public
|
|
42501
42507
|
*/
|
|
42502
42508
|
const filter = (element, predicate) => {
|
|
42503
42509
|
const result = [];
|
|
42504
42510
|
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
42505
42511
|
enter(path) {
|
|
42506
|
-
if (predicate(path
|
|
42507
|
-
result.push(path
|
|
42512
|
+
if (predicate(path)) {
|
|
42513
|
+
result.push(path);
|
|
42508
42514
|
}
|
|
42509
42515
|
}
|
|
42510
42516
|
});
|
|
@@ -42530,7 +42536,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42530
42536
|
* @public
|
|
42531
42537
|
*/
|
|
42532
42538
|
/**
|
|
42533
|
-
* Finds the most inner node at the given offset.
|
|
42539
|
+
* Finds the path of the most inner node at the given offset.
|
|
42534
42540
|
* If includeRightBound is set, also finds nodes that end at the given offset.
|
|
42535
42541
|
* @public
|
|
42536
42542
|
*/
|
|
@@ -42555,7 +42561,7 @@ const findAtOffset = (element, options) => {
|
|
|
42555
42561
|
const endOffset = node.endOffset;
|
|
42556
42562
|
const isWithinOffsetRange = offset >= startOffset && (offset < endOffset || includeRightBound && offset <= endOffset);
|
|
42557
42563
|
if (isWithinOffsetRange) {
|
|
42558
|
-
result.push(
|
|
42564
|
+
result.push(path);
|
|
42559
42565
|
return; // push to stack and dive in
|
|
42560
42566
|
}
|
|
42561
42567
|
path.skip(); // skip entire sub-tree
|
|
@@ -42578,15 +42584,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42578
42584
|
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
|
|
42579
42585
|
|
|
42580
42586
|
/**
|
|
42581
|
-
*
|
|
42587
|
+
* Finds first path whose element satisfies the provided predicate.
|
|
42582
42588
|
* @public
|
|
42583
42589
|
*/
|
|
42584
42590
|
const find = (element, predicate) => {
|
|
42585
42591
|
let result;
|
|
42586
42592
|
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
42587
42593
|
enter(path) {
|
|
42588
|
-
if (predicate(path
|
|
42589
|
-
result = path
|
|
42594
|
+
if (predicate(path)) {
|
|
42595
|
+
result = path;
|
|
42590
42596
|
path.stop();
|
|
42591
42597
|
}
|
|
42592
42598
|
}
|
|
@@ -42605,9 +42611,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42605
42611
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
42606
42612
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
42607
42613
|
/* harmony export */ });
|
|
42608
|
-
/* harmony import */ var
|
|
42609
|
-
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(72078);
|
|
42610
|
-
|
|
42614
|
+
/* harmony import */ var _traversal_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72078);
|
|
42611
42615
|
|
|
42612
42616
|
/**
|
|
42613
42617
|
* @public
|
|
@@ -42616,7 +42620,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42616
42620
|
* @public
|
|
42617
42621
|
*/
|
|
42618
42622
|
/**
|
|
42619
|
-
* Executes the callback on this element and all
|
|
42623
|
+
* Executes the callback on this element's path and all descendant paths.
|
|
42620
42624
|
* @public
|
|
42621
42625
|
*/
|
|
42622
42626
|
const forEach = (element, options) => {
|
|
@@ -42624,15 +42628,15 @@ const forEach = (element, options) => {
|
|
|
42624
42628
|
let predicate;
|
|
42625
42629
|
if (typeof options === 'function') {
|
|
42626
42630
|
callback = options;
|
|
42627
|
-
predicate =
|
|
42631
|
+
predicate = () => true;
|
|
42628
42632
|
} else {
|
|
42629
42633
|
callback = options.callback ?? (() => {});
|
|
42630
|
-
predicate = options.predicate ??
|
|
42634
|
+
predicate = options.predicate ?? (() => true);
|
|
42631
42635
|
}
|
|
42632
|
-
(0,
|
|
42636
|
+
(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
|
|
42633
42637
|
enter(path) {
|
|
42634
|
-
if (predicate(path
|
|
42635
|
-
callback(path
|
|
42638
|
+
if (predicate(path)) {
|
|
42639
|
+
callback(path);
|
|
42636
42640
|
}
|
|
42637
42641
|
}
|
|
42638
42642
|
});
|
|
@@ -42681,11 +42685,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42681
42685
|
/* harmony import */ var _filter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(75247);
|
|
42682
42686
|
|
|
42683
42687
|
/**
|
|
42684
|
-
* Complement of filter. Finds all elements NOT
|
|
42688
|
+
* Complement of filter. Finds all paths whose elements do NOT match the predicate.
|
|
42685
42689
|
* @public
|
|
42686
42690
|
*/
|
|
42687
42691
|
const reject = (element, predicate) => {
|
|
42688
|
-
return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element,
|
|
42692
|
+
return (0,_filter_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(element, path => !predicate(path));
|
|
42689
42693
|
};
|
|
42690
42694
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reject);
|
|
42691
42695
|
|
|
@@ -42702,7 +42706,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
42702
42706
|
/* harmony import */ var _find_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44860);
|
|
42703
42707
|
|
|
42704
42708
|
/**
|
|
42705
|
-
* Tests whether at least one element passes the predicate.
|
|
42709
|
+
* Tests whether at least one path's element passes the predicate.
|
|
42706
42710
|
* @public
|
|
42707
42711
|
*/
|
|
42708
42712
|
const some = (element, predicate) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-parser-adapter-asyncapi-json-2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Parser adapter for parsing JSON 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": "
|
|
64
|
-
"@speclynx/apidom-datamodel": "
|
|
65
|
-
"@speclynx/apidom-ns-asyncapi-2": "
|
|
66
|
-
"@speclynx/apidom-parser-adapter-json": "
|
|
63
|
+
"@speclynx/apidom-core": "4.0.0",
|
|
64
|
+
"@speclynx/apidom-datamodel": "4.0.0",
|
|
65
|
+
"@speclynx/apidom-ns-asyncapi-2": "4.0.0",
|
|
66
|
+
"@speclynx/apidom-parser-adapter-json": "4.0.0",
|
|
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": "
|
|
80
|
+
"gitHead": "384ff82a1bb68d015fd6801de641898b4b582876"
|
|
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 _apidomParserAdapterJson = require("@speclynx/apidom-parser-adapter-json");
|
|
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 = /"asyncapi"\s*:\s*"(?<version_json>2\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))"/;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
const detect = async (source, options = {}) => detectionRegExp.test(source) && (await (0, _apidomParserAdapterJson.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, _apidomParserAdapterJson.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 { propOr, omit } from 'ramda';
|
|
2
|
-
import { isNotUndefined } from 'ramda-adjunct';
|
|
3
|
-
import { Namespace } from '@speclynx/apidom-datamodel';
|
|
4
|
-
import { parse as parseJSON, detect as detectJSON } from '@speclynx/apidom-parser-adapter-json';
|
|
5
|
-
import asyncApiNamespacePlugin, { refractAsyncApi2 } from '@speclynx/apidom-ns-asyncapi-2';
|
|
6
|
-
export { default as mediaTypes } from "./media-types.mjs";
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export const detectionRegExp = /"asyncapi"\s*:\s*"(?<version_json>2\.(?:[1-9]\d*|0)\.(?:[1-9]\d*|0))"/;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export const detect = async (source, options = {}) => detectionRegExp.test(source) && (await detectJSON(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 parseJSON(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(asyncApiNamespacePlugin);
|
package/src/media-types.cjs
DELETED
|
@@ -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 jsonMediaTypes = new _apidomNsAsyncapi.AsyncAPIMediaTypes(..._apidomNsAsyncapi.mediaTypes.filterByFormat('generic'), ..._apidomNsAsyncapi.mediaTypes.filterByFormat('json'));
|
|
10
|
-
var _default = exports.default = jsonMediaTypes;
|
package/src/media-types.mjs
DELETED