@swagger-api/apidom-ns-api-design-systems 0.68.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 +292 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/MIT.txt +9 -0
- package/NOTICE +57 -0
- package/README.md +324 -0
- package/cjs/elements/Info.cjs +25 -0
- package/cjs/elements/Main.cjs +44 -0
- package/cjs/elements/Principle.cjs +37 -0
- package/cjs/elements/Requirement.cjs +37 -0
- package/cjs/elements/RequirementLevel.cjs +13 -0
- package/cjs/elements/Scenario.cjs +31 -0
- package/cjs/elements/Standard.cjs +37 -0
- package/cjs/elements/StandardIdentifier.cjs +13 -0
- package/cjs/index.cjs +50 -0
- package/cjs/media-types.cjs +24 -0
- package/cjs/namespace.cjs +39 -0
- package/cjs/predicates.cjs +78 -0
- package/cjs/refractor/index.cjs +48 -0
- package/cjs/refractor/plugins/openapi-3-1/standard-identifier-accessors.cjs +88 -0
- package/cjs/refractor/plugins/openapi-3-1/standard-identifier-selectors.cjs +80 -0
- package/cjs/refractor/registration.cjs +36 -0
- package/cjs/refractor/specification.cjs +122 -0
- package/cjs/refractor/toolbox.cjs +23 -0
- package/cjs/refractor/visitors/FallbackVisitor.cjs +24 -0
- package/cjs/refractor/visitors/SpecificationVisitor.cjs +75 -0
- package/cjs/refractor/visitors/Visitor.cjs +22 -0
- package/cjs/refractor/visitors/api-design-systems/info/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/info/TitleVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/info/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/main/PrinciplesVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/main/ScenariosVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/main/StandardsVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/main/VersionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/main/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/principle/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/principle/IriVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/principle/NameVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/principle/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/requirement/FollowsVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/requirement/ValuesVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/requirement/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/requirement-level/index.cjs +22 -0
- package/cjs/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/scenario/ThenVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/scenario/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/standard/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/standard/IriVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/standard/NameVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/standard/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/standard-identifier/index.cjs +28 -0
- package/cjs/refractor/visitors/generics/FixedFieldsVisitor.cjs +45 -0
- package/cjs/traversal/visitor.cjs +28 -0
- package/cjs/validator/openapi-3-1/accessor.cjs +32 -0
- package/cjs/validator/openapi-3-1/requirement-level.cjs +13 -0
- package/cjs/validator/openapi-3-1/selector.cjs +38 -0
- package/cjs/validator/openapi-3-1/validator.cjs +86 -0
- package/dist/apidom-ns-api-design-systems.browser.js +30558 -0
- package/dist/apidom-ns-api-design-systems.browser.min.js +1 -0
- package/es/elements/Info.js +20 -0
- package/es/elements/Main.js +39 -0
- package/es/elements/Principle.js +32 -0
- package/es/elements/Requirement.js +32 -0
- package/es/elements/RequirementLevel.js +8 -0
- package/es/elements/Scenario.js +26 -0
- package/es/elements/Standard.js +32 -0
- package/es/elements/StandardIdentifier.js +8 -0
- package/es/index.js +12 -0
- package/es/media-types.js +18 -0
- package/es/namespace.js +32 -0
- package/es/predicates.js +65 -0
- package/es/refractor/index.js +43 -0
- package/es/refractor/plugins/openapi-3-1/standard-identifier-accessors.js +83 -0
- package/es/refractor/plugins/openapi-3-1/standard-identifier-selectors.js +75 -0
- package/es/refractor/registration.js +24 -0
- package/es/refractor/specification.js +115 -0
- package/es/refractor/toolbox.js +17 -0
- package/es/refractor/visitors/FallbackVisitor.js +18 -0
- package/es/refractor/visitors/SpecificationVisitor.js +69 -0
- package/es/refractor/visitors/Visitor.js +16 -0
- package/es/refractor/visitors/api-design-systems/info/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/info/TitleVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/info/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/main/PrinciplesVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/main/ScenariosVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/main/StandardsVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/main/VersionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/main/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/principle/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/principle/IriVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/principle/NameVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/principle/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/requirement/FollowsVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/requirement/ValuesVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/requirement/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/requirement-level/index.js +16 -0
- package/es/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/scenario/ThenVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/scenario/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/standard/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/standard/IriVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/standard/NameVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/standard/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/standard-identifier/index.js +22 -0
- package/es/refractor/visitors/generics/FixedFieldsVisitor.js +39 -0
- package/es/traversal/visitor.js +25 -0
- package/es/validator/openapi-3-1/accessor.js +27 -0
- package/es/validator/openapi-3-1/requirement-level.js +7 -0
- package/es/validator/openapi-3-1/selector.js +33 -0
- package/es/validator/openapi-3-1/validator.js +80 -0
- package/package.json +63 -0
- package/types/dist.d.ts +158 -0
package/es/predicates.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createPredicate } from '@swagger-api/apidom-core';
|
|
2
|
+
import MainElement from "./elements/Main.js";
|
|
3
|
+
import InfoElement from "./elements/Info.js";
|
|
4
|
+
import PrincipleElement from "./elements/Principle.js";
|
|
5
|
+
import RequirementElement from "./elements/Requirement.js";
|
|
6
|
+
import RequirementLevelElement from "./elements/RequirementLevel.js";
|
|
7
|
+
import ScenarioElement from "./elements/Scenario.js";
|
|
8
|
+
import StandardElement from "./elements/Standard.js";
|
|
9
|
+
import StandardIdentifierElement from "./elements/StandardIdentifier.js";
|
|
10
|
+
export const isMainElement = createPredicate(({
|
|
11
|
+
hasBasicElementProps,
|
|
12
|
+
isElementType,
|
|
13
|
+
primitiveEq
|
|
14
|
+
}) => {
|
|
15
|
+
return element => element instanceof MainElement || hasBasicElementProps(element) && isElementType('main', element) && primitiveEq('object', element);
|
|
16
|
+
});
|
|
17
|
+
export const isInfoElement = createPredicate(({
|
|
18
|
+
hasBasicElementProps,
|
|
19
|
+
isElementType,
|
|
20
|
+
primitiveEq
|
|
21
|
+
}) => {
|
|
22
|
+
return element => element instanceof InfoElement || hasBasicElementProps(element) && isElementType('info', element) && primitiveEq('object', element);
|
|
23
|
+
});
|
|
24
|
+
export const isPrincipleElement = createPredicate(({
|
|
25
|
+
hasBasicElementProps,
|
|
26
|
+
isElementType,
|
|
27
|
+
primitiveEq
|
|
28
|
+
}) => {
|
|
29
|
+
return element => element instanceof PrincipleElement || hasBasicElementProps(element) && isElementType('principle', element) && primitiveEq('object', element);
|
|
30
|
+
});
|
|
31
|
+
export const isRequirementElement = createPredicate(({
|
|
32
|
+
hasBasicElementProps,
|
|
33
|
+
isElementType,
|
|
34
|
+
primitiveEq
|
|
35
|
+
}) => {
|
|
36
|
+
return element => element instanceof RequirementElement || hasBasicElementProps(element) && isElementType('requirement', element) && primitiveEq('object', element);
|
|
37
|
+
});
|
|
38
|
+
export const isRequirementLevelElement = createPredicate(({
|
|
39
|
+
hasBasicElementProps,
|
|
40
|
+
isElementType,
|
|
41
|
+
primitiveEq
|
|
42
|
+
}) => {
|
|
43
|
+
return element => element instanceof RequirementLevelElement || hasBasicElementProps(element) && isElementType('requirementLevel', element) && primitiveEq('string', element);
|
|
44
|
+
});
|
|
45
|
+
export const isScenarioElement = createPredicate(({
|
|
46
|
+
hasBasicElementProps,
|
|
47
|
+
isElementType,
|
|
48
|
+
primitiveEq
|
|
49
|
+
}) => {
|
|
50
|
+
return element => element instanceof ScenarioElement || hasBasicElementProps(element) && isElementType('scenario', element) && primitiveEq('object', element);
|
|
51
|
+
});
|
|
52
|
+
export const isStandardElement = createPredicate(({
|
|
53
|
+
hasBasicElementProps,
|
|
54
|
+
isElementType,
|
|
55
|
+
primitiveEq
|
|
56
|
+
}) => {
|
|
57
|
+
return element => element instanceof StandardElement || hasBasicElementProps(element) && isElementType('standard', element) && primitiveEq('object', element);
|
|
58
|
+
});
|
|
59
|
+
export const isStandardIdentifierElement = createPredicate(({
|
|
60
|
+
hasBasicElementProps,
|
|
61
|
+
isElementType,
|
|
62
|
+
primitiveEq
|
|
63
|
+
}) => {
|
|
64
|
+
return element => element instanceof StandardIdentifierElement || hasBasicElementProps(element) && isElementType('standardIdentifier', element) && primitiveEq('array', element);
|
|
65
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { visit, dereference, refract as baseRefract, dispatchRefractorPlugins } from '@swagger-api/apidom-core';
|
|
5
|
+
import { invokeArgs } from 'ramda-adjunct';
|
|
6
|
+
import specification from "./specification.js";
|
|
7
|
+
import { keyMap, getNodeType } from "../traversal/visitor.js";
|
|
8
|
+
import createToolbox from "./toolbox.js";
|
|
9
|
+
const refract = (value, {
|
|
10
|
+
specPath = ['visitors', 'document', 'objects', 'Main', '$visitor'],
|
|
11
|
+
plugins = []
|
|
12
|
+
} = {}) => {
|
|
13
|
+
const element = baseRefract(value);
|
|
14
|
+
const resolvedSpec = dereference(specification);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This is where generic ApiDOM becomes semantic (namespace applied).
|
|
18
|
+
* We don't allow consumers to hook into this translation.
|
|
19
|
+
* Though we allow consumers to define their onw plugins on already transformed ApiDOM.
|
|
20
|
+
*/
|
|
21
|
+
const rootVisitor = invokeArgs(specPath, [], resolvedSpec);
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
visit(element, rootVisitor, {
|
|
24
|
+
state: {
|
|
25
|
+
specObj: resolvedSpec
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Running plugins visitors means extra single traversal === performance hit.
|
|
31
|
+
*/
|
|
32
|
+
return dispatchRefractorPlugins(rootVisitor.element, plugins, {
|
|
33
|
+
toolboxCreator: createToolbox,
|
|
34
|
+
visitorOptions: {
|
|
35
|
+
keyMap,
|
|
36
|
+
nodeTypeGetter: getNodeType
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export const createRefractor = specPath => (value, options = {}) => refract(value, _objectSpread(_objectSpread({}, options), {}, {
|
|
41
|
+
specPath
|
|
42
|
+
}));
|
|
43
|
+
export default refract;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { StringElement } from '@swagger-api/apidom-core';
|
|
2
|
+
import { isStringElement, isArrayElement, isObjectElement } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
3
|
+
const plugin = () => () => {
|
|
4
|
+
return {
|
|
5
|
+
visitor: {
|
|
6
|
+
OperationElement(element, ...rest) {
|
|
7
|
+
const [,,, ancestors] = rest;
|
|
8
|
+
const parentPathItem = ancestors[ancestors.length - 2];
|
|
9
|
+
const httpMethod = element.meta.get('http-method').clone();
|
|
10
|
+
httpMethod.content = httpMethod.toValue().toLowerCase();
|
|
11
|
+
const standardIdentifiers = [{
|
|
12
|
+
subject: ['http', 'request', 'url'],
|
|
13
|
+
value: parentPathItem.meta.get('path')
|
|
14
|
+
}, {
|
|
15
|
+
subject: ['http', 'request', 'method'],
|
|
16
|
+
value: httpMethod
|
|
17
|
+
}];
|
|
18
|
+
if (typeof parentPathItem.parameters !== 'undefined' && isArrayElement(parentPathItem.parameters)) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
parentPathItem.parameters.forEach(parameter => {
|
|
21
|
+
var _parameter$in;
|
|
22
|
+
if (isStringElement(parameter.in) && isStringElement(parameter.name) && ((_parameter$in = parameter.in) === null || _parameter$in === void 0 ? void 0 : _parameter$in.toValue()) === 'header') {
|
|
23
|
+
var _parameter$name, _parameter$name2;
|
|
24
|
+
standardIdentifiers.push({
|
|
25
|
+
subject: ['http', 'request', 'header'],
|
|
26
|
+
value: (_parameter$name = parameter.name) === null || _parameter$name === void 0 ? void 0 : _parameter$name.clone()
|
|
27
|
+
});
|
|
28
|
+
standardIdentifiers.push({
|
|
29
|
+
subject: ['http', 'message', 'header'],
|
|
30
|
+
value: (_parameter$name2 = parameter.name) === null || _parameter$name2 === void 0 ? void 0 : _parameter$name2.clone()
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
element.setMetaProperty('ads-a-standard-identifier', standardIdentifiers);
|
|
36
|
+
},
|
|
37
|
+
ParameterElement(element) {
|
|
38
|
+
var _element$in;
|
|
39
|
+
if (isStringElement(element.in) && isStringElement(element.name) && ((_element$in = element.in) === null || _element$in === void 0 ? void 0 : _element$in.toValue()) === 'header') {
|
|
40
|
+
var _element$name, _element$name2;
|
|
41
|
+
element.setMetaProperty('ads-a-standard-identifier', [{
|
|
42
|
+
subject: ['http', 'request', 'header'],
|
|
43
|
+
value: (_element$name = element.name) === null || _element$name === void 0 ? void 0 : _element$name.clone()
|
|
44
|
+
}, {
|
|
45
|
+
subject: ['http', 'message', 'header'],
|
|
46
|
+
value: (_element$name2 = element.name) === null || _element$name2 === void 0 ? void 0 : _element$name2.clone()
|
|
47
|
+
}]);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
RequestBodyElement(element) {
|
|
51
|
+
if (typeof element.contentProp === 'undefined' || !isObjectElement(element.contentProp)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const standardIdentifiers = [];
|
|
55
|
+
element.contentProp.forEach((mediaType, key) => {
|
|
56
|
+
standardIdentifiers.push({
|
|
57
|
+
subject: ['http', 'request', 'header'],
|
|
58
|
+
value: new StringElement('Content-Type', key.meta.clone())
|
|
59
|
+
}, {
|
|
60
|
+
subject: ['http', 'message', 'header'],
|
|
61
|
+
value: new StringElement('Content-Type', key.meta.clone())
|
|
62
|
+
}, {
|
|
63
|
+
subject: ['http', 'request', 'header', 'Content-Type'],
|
|
64
|
+
value: key.clone()
|
|
65
|
+
}, {
|
|
66
|
+
subject: ['http', 'message', 'header', 'Content-Type'],
|
|
67
|
+
value: key.clone()
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
element.setMetaProperty('ads-a-standard-identifier', standardIdentifiers);
|
|
71
|
+
},
|
|
72
|
+
ResponseElement(element) {
|
|
73
|
+
if (!element.meta.hasKey('http-status-code')) return;
|
|
74
|
+
const standardIdentifiers = [{
|
|
75
|
+
subject: ['http', 'response', 'status_code'],
|
|
76
|
+
value: element.meta.get('http-status-code').clone()
|
|
77
|
+
}];
|
|
78
|
+
element.setMetaProperty('ads-a-standard-identifier', standardIdentifiers);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export default plugin;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isStringElement, isObjectElement } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
2
|
+
const plugin = () => () => {
|
|
3
|
+
let operationIdentifiers = [];
|
|
4
|
+
let responseIdentifiers = [];
|
|
5
|
+
return {
|
|
6
|
+
visitor: {
|
|
7
|
+
OperationElement: {
|
|
8
|
+
enter(element, ...rest) {
|
|
9
|
+
var _parentPathItem$param;
|
|
10
|
+
const [,,, ancestors] = rest;
|
|
11
|
+
const parentPathItem = ancestors[ancestors.length - 2];
|
|
12
|
+
operationIdentifiers.push(['http', 'transaction'], ['http', 'request'], ['http', 'request', 'url'], ['http', 'request', 'url', parentPathItem.meta.get('path').toValue()], ['http', 'request', 'method'], ['http', 'request', 'method', element.meta.get('http-method').toValue().toLowerCase()]);
|
|
13
|
+
|
|
14
|
+
// fold PathItem.parameters to Operation.parameters
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
parentPathItem === null || parentPathItem === void 0 ? void 0 : (_parentPathItem$param = parentPathItem.parameters) === null || _parentPathItem$param === void 0 ? void 0 : _parentPathItem$param.forEach(parameter => {
|
|
17
|
+
var _parameter$in;
|
|
18
|
+
if (isStringElement(parameter.in) && isStringElement(parameter.name) && ((_parameter$in = parameter.in) === null || _parameter$in === void 0 ? void 0 : _parameter$in.toValue()) === 'header') {
|
|
19
|
+
var _parameter$name, _parameter$name2;
|
|
20
|
+
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', (_parameter$name = parameter.name) === null || _parameter$name === void 0 ? void 0 : _parameter$name.toValue()], ['http', 'message', 'header'], ['http', 'message', 'header', (_parameter$name2 = parameter.name) === null || _parameter$name2 === void 0 ? void 0 : _parameter$name2.toValue()]);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
leave(element) {
|
|
25
|
+
element.setMetaProperty('ads-s-standard-identifier', operationIdentifiers);
|
|
26
|
+
operationIdentifiers = [];
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
ParameterElement(element) {
|
|
30
|
+
var _element$in;
|
|
31
|
+
if (isStringElement(element.in) && isStringElement(element.name) && ((_element$in = element.in) === null || _element$in === void 0 ? void 0 : _element$in.toValue()) === 'header') {
|
|
32
|
+
var _element$name, _element$name2;
|
|
33
|
+
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', (_element$name = element.name) === null || _element$name === void 0 ? void 0 : _element$name.toValue()], ['http', 'message', 'header'], ['http', 'message', 'header', (_element$name2 = element.name) === null || _element$name2 === void 0 ? void 0 : _element$name2.toValue()]);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
RequestBodyElement(element) {
|
|
37
|
+
if (!isObjectElement(element.contentProp)) return;
|
|
38
|
+
operationIdentifiers.push(['http', 'request', 'body'], ['http', 'message', 'body']);
|
|
39
|
+
if (typeof element.contentProp !== 'undefined' && isObjectElement(element.contentProp)) {
|
|
40
|
+
element.contentProp.forEach(() => {
|
|
41
|
+
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', 'Content-Type'], ['http', 'message', 'header'], ['http', 'message', 'header', 'Content-Type']);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
ResponseElement: {
|
|
46
|
+
enter(element) {
|
|
47
|
+
responseIdentifiers.push(['http', 'response']);
|
|
48
|
+
if (element.meta.hasKey('http-status-code')) {
|
|
49
|
+
const statusCode = String(element.meta.get('http-status-code').toValue());
|
|
50
|
+
const statusCodeAlias = statusCode.startsWith('2') ? 'success' : statusCode.startsWith('3') ? 'redirect' : statusCode.startsWith('4') ? 'client_error' : statusCode.startsWith('5') ? 'sever_error' : 'unknown';
|
|
51
|
+
responseIdentifiers.push(['http', 'response', 'status_code'], ['http', 'response', 'status_code', statusCode], ['http', 'response', 'status_code', statusCodeAlias]);
|
|
52
|
+
}
|
|
53
|
+
if (typeof element.headers !== 'undefined' && isObjectElement(element.headers)) {
|
|
54
|
+
element.headers.forEach((value, key) => {
|
|
55
|
+
const headerName = key.toValue();
|
|
56
|
+
responseIdentifiers.push(['http', 'response', 'header'], ['http', 'response', 'header', headerName], ['http', 'message', 'header', headerName]);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (typeof element.contentProp !== 'undefined' && isObjectElement(element.contentProp)) {
|
|
60
|
+
responseIdentifiers.push(['http', 'response', 'body'], ['http', 'message', 'body']);
|
|
61
|
+
element.contentProp.forEach((value, key) => {
|
|
62
|
+
const headerName = key.toValue();
|
|
63
|
+
responseIdentifiers.push(['http', 'response', 'header'], ['http', 'response', 'header', headerName], ['http', 'message', 'header', headerName]);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
leave(element) {
|
|
68
|
+
element.setMetaProperty('ads-s-standard-identifier', responseIdentifiers);
|
|
69
|
+
responseIdentifiers = [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export default plugin;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRefractor } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* API Design Systems 2021-05-07 specification elements.
|
|
4
|
+
*/
|
|
5
|
+
import MainElement from "../elements/Main.js";
|
|
6
|
+
import InfoElement from "../elements/Info.js";
|
|
7
|
+
import PrincipleElement from "../elements/Principle.js";
|
|
8
|
+
import RequirementElement from "../elements/Requirement.js";
|
|
9
|
+
import RequirementLevelElement from "../elements/RequirementLevel.js";
|
|
10
|
+
import ScenarioElement from "../elements/Scenario.js";
|
|
11
|
+
import StandardElement from "../elements/Standard.js";
|
|
12
|
+
import StandardIdentifierElement from "../elements/StandardIdentifier.js";
|
|
13
|
+
/**
|
|
14
|
+
* API Design Systems 2021-05-07 specification elements.
|
|
15
|
+
*/
|
|
16
|
+
MainElement.refract = createRefractor(['visitors', 'document', 'objects', 'Main', '$visitor']);
|
|
17
|
+
InfoElement.refract = createRefractor(['visitors', 'document', 'objects', 'Info', '$visitor']);
|
|
18
|
+
PrincipleElement.refract = createRefractor(['visitors', 'document', 'objects', 'Principle', '$visitor']);
|
|
19
|
+
RequirementElement.refract = createRefractor(['visitors', 'document', 'objects', 'Requirement', '$visitor']);
|
|
20
|
+
RequirementLevelElement.refract = createRefractor(['visitors', 'document', 'objects', 'RequirementLevel', '$visitor']);
|
|
21
|
+
ScenarioElement.refract = createRefractor(['visitors', 'document', 'objects', 'Scenario', '$visitor']);
|
|
22
|
+
StandardElement.refract = createRefractor(['visitors', 'document', 'objects', 'Standards', '$visitor']);
|
|
23
|
+
StandardIdentifierElement.refract = createRefractor(['visitors', 'document', 'objects', 'StandardIdentifier', '$visitor']);
|
|
24
|
+
export { MainElement, InfoElement, PrincipleElement, RequirementElement, RequirementLevelElement, ScenarioElement, StandardElement, StandardIdentifierElement };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import FallbackVisitor from "./visitors/FallbackVisitor.js";
|
|
2
|
+
/**
|
|
3
|
+
* API Design Systems 2021-05-07 specification elements.
|
|
4
|
+
*/
|
|
5
|
+
import RequirementLevelVisitor from "./visitors/api-design-systems/requirement-level/index.js";
|
|
6
|
+
import StandardIdentifierVisitor from "./visitors/api-design-systems/standard-identifier/index.js";
|
|
7
|
+
import RequirementVisitor from "./visitors/api-design-systems/requirement/index.js";
|
|
8
|
+
import RequirementValuesVisitor from "./visitors/api-design-systems/requirement/ValuesVisitor.js";
|
|
9
|
+
import RequirementFollowsVisitor from "./visitors/api-design-systems/requirement/FollowsVisitor.js";
|
|
10
|
+
import ScenarioVisitor from "./visitors/api-design-systems/scenario/index.js";
|
|
11
|
+
import ScenarioDescriptionVisitor from "./visitors/api-design-systems/scenario/DescriptionVisitor.js";
|
|
12
|
+
import ScenarioThenVisitor from "./visitors/api-design-systems/scenario/ThenVisitor.js";
|
|
13
|
+
import StandardVisitor from "./visitors/api-design-systems/standard/index.js";
|
|
14
|
+
import StandardNameVisitor from "./visitors/api-design-systems/standard/NameVisitor.js";
|
|
15
|
+
import StandardDescriptionVisitor from "./visitors/api-design-systems/standard/DescriptionVisitor.js";
|
|
16
|
+
import StandardIriVisitor from "./visitors/api-design-systems/standard/IriVisitor.js";
|
|
17
|
+
import PrincipleVisitor from "./visitors/api-design-systems/principle/index.js";
|
|
18
|
+
import PrincipleNameVisitor from "./visitors/api-design-systems/principle/NameVisitor.js";
|
|
19
|
+
import PrincipleDescriptionVisitor from "./visitors/api-design-systems/principle/DescriptionVisitor.js";
|
|
20
|
+
import PrincipleIriVisitor from "./visitors/api-design-systems/principle/IriVisitor.js";
|
|
21
|
+
import InfoVisitor from "./visitors/api-design-systems/info/index.js";
|
|
22
|
+
import InfoTitleVisitor from "./visitors/api-design-systems/info/TitleVisitor.js";
|
|
23
|
+
import InfoDescriptionVisitor from "./visitors/api-design-systems/info/DescriptionVisitor.js";
|
|
24
|
+
import MainVisitor from "./visitors/api-design-systems/main/index.js";
|
|
25
|
+
import MainVersionVisitor from "./visitors/api-design-systems/main/VersionVisitor.js";
|
|
26
|
+
import MainPrinciplesVisitor from "./visitors/api-design-systems/main/PrinciplesVisitor.js";
|
|
27
|
+
import MainStandardsVisitor from "./visitors/api-design-systems/main/StandardsVisitor.js";
|
|
28
|
+
import MainScenariosVisitor from "./visitors/api-design-systems/main/ScenariosVisitor.js";
|
|
29
|
+
/**
|
|
30
|
+
* Specification object allows us to have complete control over visitors
|
|
31
|
+
* when traversing the ApiDOM.
|
|
32
|
+
* Specification also allows us to create amended refractors from
|
|
33
|
+
* existing ones by manipulating it.
|
|
34
|
+
*
|
|
35
|
+
* Note: Specification object allows to use absolute internal JSON pointers.
|
|
36
|
+
*/
|
|
37
|
+
const specification = {
|
|
38
|
+
visitors: {
|
|
39
|
+
value: FallbackVisitor,
|
|
40
|
+
document: {
|
|
41
|
+
objects: {
|
|
42
|
+
/**
|
|
43
|
+
* API Design Systems 2021-05-07 specification elements.
|
|
44
|
+
*/
|
|
45
|
+
Main: {
|
|
46
|
+
$visitor: MainVisitor,
|
|
47
|
+
fixedFields: {
|
|
48
|
+
version: MainVersionVisitor,
|
|
49
|
+
info: {
|
|
50
|
+
$ref: '#/visitors/document/objects/Info'
|
|
51
|
+
},
|
|
52
|
+
principles: MainPrinciplesVisitor,
|
|
53
|
+
standards: MainStandardsVisitor,
|
|
54
|
+
scenarios: MainScenariosVisitor
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
Info: {
|
|
58
|
+
$visitor: InfoVisitor,
|
|
59
|
+
fixedFields: {
|
|
60
|
+
title: InfoTitleVisitor,
|
|
61
|
+
description: InfoDescriptionVisitor
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
Principle: {
|
|
65
|
+
$visitor: PrincipleVisitor,
|
|
66
|
+
fixedFields: {
|
|
67
|
+
name: PrincipleNameVisitor,
|
|
68
|
+
description: PrincipleDescriptionVisitor,
|
|
69
|
+
iri: PrincipleIriVisitor,
|
|
70
|
+
level: {
|
|
71
|
+
$ref: '#/visitors/document/objects/RequirementLevel'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
Standard: {
|
|
76
|
+
$visitor: StandardVisitor,
|
|
77
|
+
fixedFields: {
|
|
78
|
+
name: StandardNameVisitor,
|
|
79
|
+
description: StandardDescriptionVisitor,
|
|
80
|
+
level: {
|
|
81
|
+
$ref: '#/visitors/document/objects/RequirementLevel'
|
|
82
|
+
},
|
|
83
|
+
iri: StandardIriVisitor
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
Scenario: {
|
|
87
|
+
$visitor: ScenarioVisitor,
|
|
88
|
+
fixedFields: {
|
|
89
|
+
description: ScenarioDescriptionVisitor,
|
|
90
|
+
when: {
|
|
91
|
+
$ref: '#/visitors/document/objects/StandardIdentifier'
|
|
92
|
+
},
|
|
93
|
+
then: ScenarioThenVisitor
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
Requirement: {
|
|
97
|
+
$visitor: RequirementVisitor,
|
|
98
|
+
fixedFields: {
|
|
99
|
+
subject: {
|
|
100
|
+
$ref: '#/visitors/document/objects/StandardIdentifier'
|
|
101
|
+
},
|
|
102
|
+
level: {
|
|
103
|
+
$ref: '#/visitors/document/objects/RequirementLevel'
|
|
104
|
+
},
|
|
105
|
+
values: RequirementValuesVisitor,
|
|
106
|
+
follows: RequirementFollowsVisitor
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
StandardIdentifier: StandardIdentifierVisitor,
|
|
110
|
+
RequirementLevel: RequirementLevelVisitor
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export default specification;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { createNamespace, isStringElement } from '@swagger-api/apidom-core';
|
|
5
|
+
import * as apiDesignSystemsPredicates from "../predicates.js";
|
|
6
|
+
import apiDesignSystemNamespace from "../namespace.js";
|
|
7
|
+
const createToolbox = () => {
|
|
8
|
+
const namespace = createNamespace(apiDesignSystemNamespace);
|
|
9
|
+
const predicates = _objectSpread(_objectSpread({}, apiDesignSystemsPredicates), {}, {
|
|
10
|
+
isStringElement
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
predicates,
|
|
14
|
+
namespace
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default createToolbox;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { BREAK } from '@swagger-api/apidom-core';
|
|
3
|
+
import Visitor from "./Visitor.js";
|
|
4
|
+
/**
|
|
5
|
+
* This visitor is responsible for falling back to current traversed element
|
|
6
|
+
* Given AsyncApi2Visitor expects ObjectElement to be traversed. If
|
|
7
|
+
* different Element is provided FallBackVisitor is responsible to assigning
|
|
8
|
+
* this Element as current element.
|
|
9
|
+
*/
|
|
10
|
+
const FallbackVisitor = stampit(Visitor, {
|
|
11
|
+
methods: {
|
|
12
|
+
enter(element) {
|
|
13
|
+
this.element = element.clone();
|
|
14
|
+
return BREAK;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export default FallbackVisitor;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import stampit from 'stampit';
|
|
5
|
+
import { pathSatisfies, path, pick, pipe, keys } from 'ramda';
|
|
6
|
+
import { isFunction, isUndefined } from 'ramda-adjunct';
|
|
7
|
+
import { visit } from '@swagger-api/apidom-core';
|
|
8
|
+
import { keyMap, getNodeType } from "../../traversal/visitor.js";
|
|
9
|
+
import Visitor from "./Visitor.js";
|
|
10
|
+
/**
|
|
11
|
+
* This is a base Type for every visitor that does
|
|
12
|
+
* internal look-ups to retrieve other child visitors.
|
|
13
|
+
*/
|
|
14
|
+
const SpecificationVisitor = stampit(Visitor, {
|
|
15
|
+
props: {
|
|
16
|
+
specObj: null
|
|
17
|
+
},
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
init({
|
|
20
|
+
specObj = this.specObj
|
|
21
|
+
}) {
|
|
22
|
+
this.specObj = specObj;
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
retrievePassingOptions() {
|
|
26
|
+
return pick(['namespace', 'specObj'], this);
|
|
27
|
+
},
|
|
28
|
+
retrieveFixedFields(specPath) {
|
|
29
|
+
return pipe(path(['visitors', ...specPath, 'fixedFields']), keys)(this.specObj);
|
|
30
|
+
},
|
|
31
|
+
retrieveVisitor(specPath) {
|
|
32
|
+
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
33
|
+
return path(['visitors', ...specPath], this.specObj);
|
|
34
|
+
}
|
|
35
|
+
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
36
|
+
},
|
|
37
|
+
retrieveVisitorInstance(specPath, options = {}) {
|
|
38
|
+
const passingOpts = this.retrievePassingOptions();
|
|
39
|
+
return this.retrieveVisitor(specPath)(_objectSpread(_objectSpread({}, passingOpts), options));
|
|
40
|
+
},
|
|
41
|
+
toRefractedElement(specPath, element, options = {}) {
|
|
42
|
+
/**
|
|
43
|
+
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
44
|
+
* it by basic node cloning.
|
|
45
|
+
*
|
|
46
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
47
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
48
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
49
|
+
*/
|
|
50
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
51
|
+
const visitorPrototype = Object.getPrototypeOf(visitor);
|
|
52
|
+
if (isUndefined(this.fallbackVisitorPrototype)) {
|
|
53
|
+
this.fallbackVisitorPrototype = Object.getPrototypeOf(this.retrieveVisitorInstance(['value']));
|
|
54
|
+
}
|
|
55
|
+
if (this.fallbackVisitorPrototype === visitorPrototype) {
|
|
56
|
+
return element.clone();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// standard processing continues
|
|
60
|
+
visit(element, visitor, _objectSpread(_objectSpread({
|
|
61
|
+
keyMap
|
|
62
|
+
}, options), {}, {
|
|
63
|
+
nodeTypeGetter: getNodeType
|
|
64
|
+
}));
|
|
65
|
+
return visitor.element;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
export default SpecificationVisitor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { hasElementSourceMap } from '@swagger-api/apidom-core';
|
|
3
|
+
const Visitor = stampit({
|
|
4
|
+
props: {
|
|
5
|
+
element: null
|
|
6
|
+
},
|
|
7
|
+
methods: {
|
|
8
|
+
copyMetaAndAttributes(from, to) {
|
|
9
|
+
// copy sourcemaps
|
|
10
|
+
if (hasElementSourceMap(from)) {
|
|
11
|
+
to.meta.set('sourceMap', from.meta.get('sourceMap'));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export default Visitor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { always } from 'ramda';
|
|
3
|
+
import InfoElement from "../../../../elements/Info.js";
|
|
4
|
+
import FallbackVisitor from "../../FallbackVisitor.js";
|
|
5
|
+
import FixedFieldsVisitor from "../../generics/FixedFieldsVisitor.js";
|
|
6
|
+
const InfoVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
|
|
7
|
+
props: {
|
|
8
|
+
specPath: always(['document', 'objects', 'Info'])
|
|
9
|
+
},
|
|
10
|
+
init() {
|
|
11
|
+
this.element = new InfoElement();
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export default InfoVisitor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { ArrayElement, BREAK } from '@swagger-api/apidom-core';
|
|
3
|
+
import FallbackVisitor from "../../FallbackVisitor.js";
|
|
4
|
+
import SpecificationVisitor from "../../SpecificationVisitor.js";
|
|
5
|
+
const PrinciplesVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
|
|
6
|
+
init() {
|
|
7
|
+
this.element = new ArrayElement();
|
|
8
|
+
this.element.classes.push('main-principles');
|
|
9
|
+
},
|
|
10
|
+
methods: {
|
|
11
|
+
ArrayElement(arrayElement) {
|
|
12
|
+
arrayElement.forEach(item => {
|
|
13
|
+
const specPath = ['document', 'objects', 'Principle'];
|
|
14
|
+
const element = this.toRefractedElement(specPath, item);
|
|
15
|
+
this.element.push(element);
|
|
16
|
+
});
|
|
17
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
18
|
+
return BREAK;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export default PrinciplesVisitor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { ArrayElement, BREAK } from '@swagger-api/apidom-core';
|
|
3
|
+
import FallbackVisitor from "../../FallbackVisitor.js";
|
|
4
|
+
import SpecificationVisitor from "../../SpecificationVisitor.js";
|
|
5
|
+
const ScenariosVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
|
|
6
|
+
init() {
|
|
7
|
+
this.element = new ArrayElement();
|
|
8
|
+
this.element.classes.push('main-scenarios');
|
|
9
|
+
},
|
|
10
|
+
methods: {
|
|
11
|
+
ArrayElement(arrayElement) {
|
|
12
|
+
arrayElement.forEach(item => {
|
|
13
|
+
const specPath = ['document', 'objects', 'Scenario'];
|
|
14
|
+
const element = this.toRefractedElement(specPath, item);
|
|
15
|
+
this.element.push(element);
|
|
16
|
+
});
|
|
17
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
18
|
+
return BREAK;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export default ScenariosVisitor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { ArrayElement, BREAK } from '@swagger-api/apidom-core';
|
|
3
|
+
import FallbackVisitor from "../../FallbackVisitor.js";
|
|
4
|
+
import SpecificationVisitor from "../../SpecificationVisitor.js";
|
|
5
|
+
const StandardsVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
|
|
6
|
+
init() {
|
|
7
|
+
this.element = new ArrayElement();
|
|
8
|
+
this.element.classes.push('main-standards');
|
|
9
|
+
},
|
|
10
|
+
methods: {
|
|
11
|
+
ArrayElement(arrayElement) {
|
|
12
|
+
arrayElement.forEach(item => {
|
|
13
|
+
const specPath = ['document', 'objects', 'Standard'];
|
|
14
|
+
const element = this.toRefractedElement(specPath, item);
|
|
15
|
+
this.element.push(element);
|
|
16
|
+
});
|
|
17
|
+
this.copyMetaAndAttributes(arrayElement, this.element);
|
|
18
|
+
return BREAK;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export default StandardsVisitor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import stampit from 'stampit';
|
|
2
|
+
import { always } from 'ramda';
|
|
3
|
+
import MainElement from "../../../../elements/Main.js";
|
|
4
|
+
import FallbackVisitor from "../../FallbackVisitor.js";
|
|
5
|
+
import FixedFieldsVisitor from "../../generics/FixedFieldsVisitor.js";
|
|
6
|
+
const MainVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
|
|
7
|
+
props: {
|
|
8
|
+
specPath: always(['document', 'objects', 'Main'])
|
|
9
|
+
},
|
|
10
|
+
init() {
|
|
11
|
+
this.element = new MainElement();
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export default MainVisitor;
|