@speclynx/apidom-reference 4.15.0 → 4.16.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 +6 -0
- package/README.md +79 -1
- package/dist/apidom-reference.browser.js +1543 -243
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +33 -28
- package/src/bundle/strategies/asyncapi-2/index.cjs +94 -0
- package/src/bundle/strategies/asyncapi-2/index.mjs +81 -0
- package/src/bundle/strategies/asyncapi-2/visitor.cjs +571 -0
- package/src/bundle/strategies/asyncapi-2/visitor.mjs +563 -0
- package/src/configuration/saturated.cjs +11 -10
- package/src/configuration/saturated.mjs +2 -1
- package/types/bundle/strategies/asyncapi-2/index.d.ts +31 -0
- package/types/bundle/strategies/asyncapi-2/visitor.d.ts +116 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-reference",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
4
4
|
"description": "Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apidom",
|
|
@@ -264,6 +264,11 @@
|
|
|
264
264
|
"require": "./src/bundle/strategies/openapi-3-1/index.cjs",
|
|
265
265
|
"types": "./types/bundle/strategies/openapi-3-1/index.d.ts"
|
|
266
266
|
},
|
|
267
|
+
"./bundle/strategies/asyncapi-2": {
|
|
268
|
+
"import": "./src/bundle/strategies/asyncapi-2/index.mjs",
|
|
269
|
+
"require": "./src/bundle/strategies/asyncapi-2/index.cjs",
|
|
270
|
+
"types": "./types/bundle/strategies/asyncapi-2/index.d.ts"
|
|
271
|
+
},
|
|
267
272
|
"./bundle/strategies/arazzo-1": {
|
|
268
273
|
"import": "./src/bundle/strategies/arazzo-1/index.mjs",
|
|
269
274
|
"require": "./src/bundle/strategies/arazzo-1/index.cjs",
|
|
@@ -294,32 +299,32 @@
|
|
|
294
299
|
"license": "Apache-2.0",
|
|
295
300
|
"dependencies": {
|
|
296
301
|
"@babel/runtime-corejs3": "^8.0.0",
|
|
297
|
-
"@speclynx/apidom-core": "4.
|
|
298
|
-
"@speclynx/apidom-datamodel": "4.
|
|
299
|
-
"@speclynx/apidom-error": "4.
|
|
300
|
-
"@speclynx/apidom-json-pointer": "4.
|
|
301
|
-
"@speclynx/apidom-ns-arazzo-1": "4.
|
|
302
|
-
"@speclynx/apidom-ns-asyncapi-2": "4.
|
|
303
|
-
"@speclynx/apidom-ns-json-schema-2020-12": "4.
|
|
304
|
-
"@speclynx/apidom-ns-openapi-2": "4.
|
|
305
|
-
"@speclynx/apidom-ns-openapi-3-0": "4.
|
|
306
|
-
"@speclynx/apidom-ns-openapi-3-1": "4.
|
|
307
|
-
"@speclynx/apidom-ns-overlay-1": "4.
|
|
308
|
-
"@speclynx/apidom-parser-adapter-arazzo-json-1": "4.
|
|
309
|
-
"@speclynx/apidom-parser-adapter-arazzo-yaml-1": "4.
|
|
310
|
-
"@speclynx/apidom-parser-adapter-asyncapi-json-2": "4.
|
|
311
|
-
"@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "4.
|
|
312
|
-
"@speclynx/apidom-parser-adapter-json": "4.
|
|
313
|
-
"@speclynx/apidom-parser-adapter-openapi-json-2": "4.
|
|
314
|
-
"@speclynx/apidom-parser-adapter-openapi-json-3-0": "4.
|
|
315
|
-
"@speclynx/apidom-parser-adapter-openapi-json-3-1": "4.
|
|
316
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-2": "4.
|
|
317
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "4.
|
|
318
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "4.
|
|
319
|
-
"@speclynx/apidom-parser-adapter-overlay-json-1": "4.
|
|
320
|
-
"@speclynx/apidom-parser-adapter-overlay-yaml-1": "4.
|
|
321
|
-
"@speclynx/apidom-parser-adapter-yaml-1-2": "4.
|
|
322
|
-
"@speclynx/apidom-traverse": "4.
|
|
302
|
+
"@speclynx/apidom-core": "4.16.0",
|
|
303
|
+
"@speclynx/apidom-datamodel": "4.16.0",
|
|
304
|
+
"@speclynx/apidom-error": "4.16.0",
|
|
305
|
+
"@speclynx/apidom-json-pointer": "4.16.0",
|
|
306
|
+
"@speclynx/apidom-ns-arazzo-1": "4.16.0",
|
|
307
|
+
"@speclynx/apidom-ns-asyncapi-2": "4.16.0",
|
|
308
|
+
"@speclynx/apidom-ns-json-schema-2020-12": "4.16.0",
|
|
309
|
+
"@speclynx/apidom-ns-openapi-2": "4.16.0",
|
|
310
|
+
"@speclynx/apidom-ns-openapi-3-0": "4.16.0",
|
|
311
|
+
"@speclynx/apidom-ns-openapi-3-1": "4.16.0",
|
|
312
|
+
"@speclynx/apidom-ns-overlay-1": "4.16.0",
|
|
313
|
+
"@speclynx/apidom-parser-adapter-arazzo-json-1": "4.16.0",
|
|
314
|
+
"@speclynx/apidom-parser-adapter-arazzo-yaml-1": "4.16.0",
|
|
315
|
+
"@speclynx/apidom-parser-adapter-asyncapi-json-2": "4.16.0",
|
|
316
|
+
"@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "4.16.0",
|
|
317
|
+
"@speclynx/apidom-parser-adapter-json": "4.16.0",
|
|
318
|
+
"@speclynx/apidom-parser-adapter-openapi-json-2": "4.16.0",
|
|
319
|
+
"@speclynx/apidom-parser-adapter-openapi-json-3-0": "4.16.0",
|
|
320
|
+
"@speclynx/apidom-parser-adapter-openapi-json-3-1": "4.16.0",
|
|
321
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-2": "4.16.0",
|
|
322
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "4.16.0",
|
|
323
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "4.16.0",
|
|
324
|
+
"@speclynx/apidom-parser-adapter-overlay-json-1": "4.16.0",
|
|
325
|
+
"@speclynx/apidom-parser-adapter-overlay-yaml-1": "4.16.0",
|
|
326
|
+
"@speclynx/apidom-parser-adapter-yaml-1-2": "4.16.0",
|
|
327
|
+
"@speclynx/apidom-traverse": "4.16.0",
|
|
323
328
|
"@swaggerexpert/arazzo-runtime-expression": "^2.0.3",
|
|
324
329
|
"axios": "^1.18.0",
|
|
325
330
|
"picomatch": "^4.0.4",
|
|
@@ -341,5 +346,5 @@
|
|
|
341
346
|
"README.md",
|
|
342
347
|
"CHANGELOG.md"
|
|
343
348
|
],
|
|
344
|
-
"gitHead": "
|
|
349
|
+
"gitHead": "252461983339fe06eb64db4e60f8ac8087065f06"
|
|
345
350
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "AsyncAPI2BundleVisitor", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _visitor.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.default = void 0;
|
|
14
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
15
|
+
var _apidomTraverse = require("@speclynx/apidom-traverse");
|
|
16
|
+
var _apidomNsAsyncapi = require("@speclynx/apidom-ns-asyncapi-2");
|
|
17
|
+
var _Reference = _interopRequireDefault(require("../../../Reference.cjs"));
|
|
18
|
+
var _ReferenceSet = _interopRequireDefault(require("../../../ReferenceSet.cjs"));
|
|
19
|
+
var _BundleStrategy = _interopRequireDefault(require("../BundleStrategy.cjs"));
|
|
20
|
+
var _visitor = _interopRequireDefault(require("./visitor.cjs"));
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
class AsyncAPI2BundleStrategy extends _BundleStrategy.default {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
super({
|
|
31
|
+
...(options ?? {}),
|
|
32
|
+
name: 'asyncapi-2'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
canBundle(file) {
|
|
36
|
+
// assert by media type
|
|
37
|
+
if (file.mediaType !== 'text/plain') {
|
|
38
|
+
return _apidomNsAsyncapi.mediaTypes.includes(file.mediaType);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// assert by inspecting ApiDOM
|
|
42
|
+
return (0, _apidomNsAsyncapi.isAsyncApi2Element)(file.parseResult?.result);
|
|
43
|
+
}
|
|
44
|
+
async bundle(file, options) {
|
|
45
|
+
const immutableRefSet = options.bundle.refSet ?? new _ReferenceSet.default();
|
|
46
|
+
const mutableRefSet = new _ReferenceSet.default();
|
|
47
|
+
let refSet = immutableRefSet;
|
|
48
|
+
let reference;
|
|
49
|
+
|
|
50
|
+
// determine the initial reference
|
|
51
|
+
if (!immutableRefSet.has(file.uri)) {
|
|
52
|
+
reference = new _Reference.default({
|
|
53
|
+
uri: file.uri,
|
|
54
|
+
value: file.parseResult
|
|
55
|
+
});
|
|
56
|
+
immutableRefSet.add(reference);
|
|
57
|
+
} else {
|
|
58
|
+
// pre-computed refSet was provided as configuration option
|
|
59
|
+
reference = immutableRefSet.find(ref => ref.uri === file.uri);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Clone refSet due the bundling process being mutable.
|
|
64
|
+
* We don't want to mutate the original refSet and the references.
|
|
65
|
+
*/
|
|
66
|
+
if (options.bundle.immutable) {
|
|
67
|
+
immutableRefSet.refs.map(ref => new _Reference.default({
|
|
68
|
+
...ref,
|
|
69
|
+
value: (0, _apidomDatamodel.cloneDeep)(ref.value)
|
|
70
|
+
})).forEach(ref => mutableRefSet.add(ref));
|
|
71
|
+
reference = mutableRefSet.find(ref => ref.uri === file.uri);
|
|
72
|
+
refSet = mutableRefSet;
|
|
73
|
+
}
|
|
74
|
+
const visitor = new _visitor.default({
|
|
75
|
+
reference: reference,
|
|
76
|
+
options
|
|
77
|
+
});
|
|
78
|
+
await (0, _apidomTraverse.traverseAsync)(refSet.rootRef.value, visitor, {
|
|
79
|
+
mutable: true
|
|
80
|
+
});
|
|
81
|
+
const parseResult = reference.value;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Release all memory if this refSet was not provided as a configuration option.
|
|
85
|
+
* If provided as configuration option, then provider is responsible for cleanup.
|
|
86
|
+
*/
|
|
87
|
+
if (options.bundle.refSet === null) {
|
|
88
|
+
immutableRefSet.clean();
|
|
89
|
+
}
|
|
90
|
+
mutableRefSet.clean();
|
|
91
|
+
return parseResult;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
var _default = exports.default = AsyncAPI2BundleStrategy;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { traverseAsync } from '@speclynx/apidom-traverse';
|
|
3
|
+
import { mediaTypes, isAsyncApi2Element } from '@speclynx/apidom-ns-asyncapi-2';
|
|
4
|
+
import Reference from "../../../Reference.mjs";
|
|
5
|
+
import ReferenceSet from "../../../ReferenceSet.mjs";
|
|
6
|
+
import BundleStrategy from "../BundleStrategy.mjs";
|
|
7
|
+
import AsyncAPI2BundleVisitor from "./visitor.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class AsyncAPI2BundleStrategy extends BundleStrategy {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
super({
|
|
17
|
+
...(options ?? {}),
|
|
18
|
+
name: 'asyncapi-2'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
canBundle(file) {
|
|
22
|
+
// assert by media type
|
|
23
|
+
if (file.mediaType !== 'text/plain') {
|
|
24
|
+
return mediaTypes.includes(file.mediaType);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// assert by inspecting ApiDOM
|
|
28
|
+
return isAsyncApi2Element(file.parseResult?.result);
|
|
29
|
+
}
|
|
30
|
+
async bundle(file, options) {
|
|
31
|
+
const immutableRefSet = options.bundle.refSet ?? new ReferenceSet();
|
|
32
|
+
const mutableRefSet = new ReferenceSet();
|
|
33
|
+
let refSet = immutableRefSet;
|
|
34
|
+
let reference;
|
|
35
|
+
|
|
36
|
+
// determine the initial reference
|
|
37
|
+
if (!immutableRefSet.has(file.uri)) {
|
|
38
|
+
reference = new Reference({
|
|
39
|
+
uri: file.uri,
|
|
40
|
+
value: file.parseResult
|
|
41
|
+
});
|
|
42
|
+
immutableRefSet.add(reference);
|
|
43
|
+
} else {
|
|
44
|
+
// pre-computed refSet was provided as configuration option
|
|
45
|
+
reference = immutableRefSet.find(ref => ref.uri === file.uri);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Clone refSet due the bundling process being mutable.
|
|
50
|
+
* We don't want to mutate the original refSet and the references.
|
|
51
|
+
*/
|
|
52
|
+
if (options.bundle.immutable) {
|
|
53
|
+
immutableRefSet.refs.map(ref => new Reference({
|
|
54
|
+
...ref,
|
|
55
|
+
value: cloneDeep(ref.value)
|
|
56
|
+
})).forEach(ref => mutableRefSet.add(ref));
|
|
57
|
+
reference = mutableRefSet.find(ref => ref.uri === file.uri);
|
|
58
|
+
refSet = mutableRefSet;
|
|
59
|
+
}
|
|
60
|
+
const visitor = new AsyncAPI2BundleVisitor({
|
|
61
|
+
reference: reference,
|
|
62
|
+
options
|
|
63
|
+
});
|
|
64
|
+
await traverseAsync(refSet.rootRef.value, visitor, {
|
|
65
|
+
mutable: true
|
|
66
|
+
});
|
|
67
|
+
const parseResult = reference.value;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Release all memory if this refSet was not provided as a configuration option.
|
|
71
|
+
* If provided as configuration option, then provider is responsible for cleanup.
|
|
72
|
+
*/
|
|
73
|
+
if (options.bundle.refSet === null) {
|
|
74
|
+
immutableRefSet.clean();
|
|
75
|
+
}
|
|
76
|
+
mutableRefSet.clean();
|
|
77
|
+
return parseResult;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export { AsyncAPI2BundleVisitor };
|
|
81
|
+
export default AsyncAPI2BundleStrategy;
|