@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.
Files changed (111) hide show
  1. package/CHANGELOG.md +292 -0
  2. package/LICENSES/Apache-2.0.txt +202 -0
  3. package/LICENSES/MIT.txt +9 -0
  4. package/NOTICE +57 -0
  5. package/README.md +324 -0
  6. package/cjs/elements/Info.cjs +25 -0
  7. package/cjs/elements/Main.cjs +44 -0
  8. package/cjs/elements/Principle.cjs +37 -0
  9. package/cjs/elements/Requirement.cjs +37 -0
  10. package/cjs/elements/RequirementLevel.cjs +13 -0
  11. package/cjs/elements/Scenario.cjs +31 -0
  12. package/cjs/elements/Standard.cjs +37 -0
  13. package/cjs/elements/StandardIdentifier.cjs +13 -0
  14. package/cjs/index.cjs +50 -0
  15. package/cjs/media-types.cjs +24 -0
  16. package/cjs/namespace.cjs +39 -0
  17. package/cjs/predicates.cjs +78 -0
  18. package/cjs/refractor/index.cjs +48 -0
  19. package/cjs/refractor/plugins/openapi-3-1/standard-identifier-accessors.cjs +88 -0
  20. package/cjs/refractor/plugins/openapi-3-1/standard-identifier-selectors.cjs +80 -0
  21. package/cjs/refractor/registration.cjs +36 -0
  22. package/cjs/refractor/specification.cjs +122 -0
  23. package/cjs/refractor/toolbox.cjs +23 -0
  24. package/cjs/refractor/visitors/FallbackVisitor.cjs +24 -0
  25. package/cjs/refractor/visitors/SpecificationVisitor.cjs +75 -0
  26. package/cjs/refractor/visitors/Visitor.cjs +22 -0
  27. package/cjs/refractor/visitors/api-design-systems/info/DescriptionVisitor.cjs +9 -0
  28. package/cjs/refractor/visitors/api-design-systems/info/TitleVisitor.cjs +9 -0
  29. package/cjs/refractor/visitors/api-design-systems/info/index.cjs +20 -0
  30. package/cjs/refractor/visitors/api-design-systems/main/PrinciplesVisitor.cjs +28 -0
  31. package/cjs/refractor/visitors/api-design-systems/main/ScenariosVisitor.cjs +28 -0
  32. package/cjs/refractor/visitors/api-design-systems/main/StandardsVisitor.cjs +28 -0
  33. package/cjs/refractor/visitors/api-design-systems/main/VersionVisitor.cjs +9 -0
  34. package/cjs/refractor/visitors/api-design-systems/main/index.cjs +20 -0
  35. package/cjs/refractor/visitors/api-design-systems/principle/DescriptionVisitor.cjs +9 -0
  36. package/cjs/refractor/visitors/api-design-systems/principle/IriVisitor.cjs +9 -0
  37. package/cjs/refractor/visitors/api-design-systems/principle/NameVisitor.cjs +9 -0
  38. package/cjs/refractor/visitors/api-design-systems/principle/index.cjs +20 -0
  39. package/cjs/refractor/visitors/api-design-systems/requirement/FollowsVisitor.cjs +9 -0
  40. package/cjs/refractor/visitors/api-design-systems/requirement/ValuesVisitor.cjs +9 -0
  41. package/cjs/refractor/visitors/api-design-systems/requirement/index.cjs +20 -0
  42. package/cjs/refractor/visitors/api-design-systems/requirement-level/index.cjs +22 -0
  43. package/cjs/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.cjs +9 -0
  44. package/cjs/refractor/visitors/api-design-systems/scenario/ThenVisitor.cjs +28 -0
  45. package/cjs/refractor/visitors/api-design-systems/scenario/index.cjs +20 -0
  46. package/cjs/refractor/visitors/api-design-systems/standard/DescriptionVisitor.cjs +9 -0
  47. package/cjs/refractor/visitors/api-design-systems/standard/IriVisitor.cjs +9 -0
  48. package/cjs/refractor/visitors/api-design-systems/standard/NameVisitor.cjs +9 -0
  49. package/cjs/refractor/visitors/api-design-systems/standard/index.cjs +20 -0
  50. package/cjs/refractor/visitors/api-design-systems/standard-identifier/index.cjs +28 -0
  51. package/cjs/refractor/visitors/generics/FixedFieldsVisitor.cjs +45 -0
  52. package/cjs/traversal/visitor.cjs +28 -0
  53. package/cjs/validator/openapi-3-1/accessor.cjs +32 -0
  54. package/cjs/validator/openapi-3-1/requirement-level.cjs +13 -0
  55. package/cjs/validator/openapi-3-1/selector.cjs +38 -0
  56. package/cjs/validator/openapi-3-1/validator.cjs +86 -0
  57. package/dist/apidom-ns-api-design-systems.browser.js +30558 -0
  58. package/dist/apidom-ns-api-design-systems.browser.min.js +1 -0
  59. package/es/elements/Info.js +20 -0
  60. package/es/elements/Main.js +39 -0
  61. package/es/elements/Principle.js +32 -0
  62. package/es/elements/Requirement.js +32 -0
  63. package/es/elements/RequirementLevel.js +8 -0
  64. package/es/elements/Scenario.js +26 -0
  65. package/es/elements/Standard.js +32 -0
  66. package/es/elements/StandardIdentifier.js +8 -0
  67. package/es/index.js +12 -0
  68. package/es/media-types.js +18 -0
  69. package/es/namespace.js +32 -0
  70. package/es/predicates.js +65 -0
  71. package/es/refractor/index.js +43 -0
  72. package/es/refractor/plugins/openapi-3-1/standard-identifier-accessors.js +83 -0
  73. package/es/refractor/plugins/openapi-3-1/standard-identifier-selectors.js +75 -0
  74. package/es/refractor/registration.js +24 -0
  75. package/es/refractor/specification.js +115 -0
  76. package/es/refractor/toolbox.js +17 -0
  77. package/es/refractor/visitors/FallbackVisitor.js +18 -0
  78. package/es/refractor/visitors/SpecificationVisitor.js +69 -0
  79. package/es/refractor/visitors/Visitor.js +16 -0
  80. package/es/refractor/visitors/api-design-systems/info/DescriptionVisitor.js +3 -0
  81. package/es/refractor/visitors/api-design-systems/info/TitleVisitor.js +3 -0
  82. package/es/refractor/visitors/api-design-systems/info/index.js +14 -0
  83. package/es/refractor/visitors/api-design-systems/main/PrinciplesVisitor.js +22 -0
  84. package/es/refractor/visitors/api-design-systems/main/ScenariosVisitor.js +22 -0
  85. package/es/refractor/visitors/api-design-systems/main/StandardsVisitor.js +22 -0
  86. package/es/refractor/visitors/api-design-systems/main/VersionVisitor.js +3 -0
  87. package/es/refractor/visitors/api-design-systems/main/index.js +14 -0
  88. package/es/refractor/visitors/api-design-systems/principle/DescriptionVisitor.js +3 -0
  89. package/es/refractor/visitors/api-design-systems/principle/IriVisitor.js +3 -0
  90. package/es/refractor/visitors/api-design-systems/principle/NameVisitor.js +3 -0
  91. package/es/refractor/visitors/api-design-systems/principle/index.js +14 -0
  92. package/es/refractor/visitors/api-design-systems/requirement/FollowsVisitor.js +3 -0
  93. package/es/refractor/visitors/api-design-systems/requirement/ValuesVisitor.js +3 -0
  94. package/es/refractor/visitors/api-design-systems/requirement/index.js +14 -0
  95. package/es/refractor/visitors/api-design-systems/requirement-level/index.js +16 -0
  96. package/es/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.js +3 -0
  97. package/es/refractor/visitors/api-design-systems/scenario/ThenVisitor.js +22 -0
  98. package/es/refractor/visitors/api-design-systems/scenario/index.js +14 -0
  99. package/es/refractor/visitors/api-design-systems/standard/DescriptionVisitor.js +3 -0
  100. package/es/refractor/visitors/api-design-systems/standard/IriVisitor.js +3 -0
  101. package/es/refractor/visitors/api-design-systems/standard/NameVisitor.js +3 -0
  102. package/es/refractor/visitors/api-design-systems/standard/index.js +14 -0
  103. package/es/refractor/visitors/api-design-systems/standard-identifier/index.js +22 -0
  104. package/es/refractor/visitors/generics/FixedFieldsVisitor.js +39 -0
  105. package/es/traversal/visitor.js +25 -0
  106. package/es/validator/openapi-3-1/accessor.js +27 -0
  107. package/es/validator/openapi-3-1/requirement-level.js +7 -0
  108. package/es/validator/openapi-3-1/selector.js +33 -0
  109. package/es/validator/openapi-3-1/validator.js +80 -0
  110. package/package.json +63 -0
  111. package/types/dist.d.ts +158 -0
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const DescriptionVisitor = FallbackVisitor;
3
+ export default DescriptionVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const IriVisitor = FallbackVisitor;
3
+ export default IriVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const NameVisitor = FallbackVisitor;
3
+ export default NameVisitor;
@@ -0,0 +1,14 @@
1
+ import stampit from 'stampit';
2
+ import { always } from 'ramda';
3
+ import PrincipleElement from "../../../../elements/Principle.js";
4
+ import FallbackVisitor from "../../FallbackVisitor.js";
5
+ import FixedFieldsVisitor from "../../generics/FixedFieldsVisitor.js";
6
+ const PrincipleVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
7
+ props: {
8
+ specPath: always(['document', 'objects', 'Principle'])
9
+ },
10
+ init() {
11
+ this.element = new PrincipleElement();
12
+ }
13
+ });
14
+ export default PrincipleVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const FollowsVisitor = FallbackVisitor;
3
+ export default FollowsVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const ValuesVisitor = FallbackVisitor;
3
+ export default ValuesVisitor;
@@ -0,0 +1,14 @@
1
+ import stampit from 'stampit';
2
+ import { always } from 'ramda';
3
+ import RequirementElement from "../../../../elements/Requirement.js";
4
+ import FallbackVisitor from "../../FallbackVisitor.js";
5
+ import FixedFieldsVisitor from "../../generics/FixedFieldsVisitor.js";
6
+ const RequirementVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
7
+ props: {
8
+ specPath: always(['document', 'objects', 'Requirement'])
9
+ },
10
+ init() {
11
+ this.element = new RequirementElement();
12
+ }
13
+ });
14
+ export default RequirementVisitor;
@@ -0,0 +1,16 @@
1
+ import stampit from 'stampit';
2
+ import { BREAK } from '@swagger-api/apidom-core';
3
+ import FallbackVisitor from "../../FallbackVisitor.js";
4
+ import SpecificationVisitor from "../../SpecificationVisitor.js";
5
+ import RequirementLevelElement from "../../../../elements/RequirementLevel.js";
6
+ const RequirementLevelVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
7
+ methods: {
8
+ StringElement(stringElement) {
9
+ const requirementLevelElement = new RequirementLevelElement(stringElement.toValue());
10
+ this.copyMetaAndAttributes(stringElement, requirementLevelElement);
11
+ this.element = requirementLevelElement;
12
+ return BREAK;
13
+ }
14
+ }
15
+ });
16
+ export default RequirementLevelVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const DescriptionVisitor = FallbackVisitor;
3
+ export default DescriptionVisitor;
@@ -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 ThenVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
6
+ init() {
7
+ this.element = new ArrayElement();
8
+ this.element.classes.push('scenario-then');
9
+ },
10
+ methods: {
11
+ ArrayElement(arrayElement) {
12
+ arrayElement.forEach(item => {
13
+ const specPath = ['document', 'objects', 'Requirement'];
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 ThenVisitor;
@@ -0,0 +1,14 @@
1
+ import stampit from 'stampit';
2
+ import { always } from 'ramda';
3
+ import ScenarioElement from "../../../../elements/Scenario.js";
4
+ import FallbackVisitor from "../../FallbackVisitor.js";
5
+ import FixedFieldsVisitor from "../../generics/FixedFieldsVisitor.js";
6
+ const ScenarioVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
7
+ props: {
8
+ specPath: always(['document', 'objects', 'Scenario'])
9
+ },
10
+ init() {
11
+ this.element = new ScenarioElement();
12
+ }
13
+ });
14
+ export default ScenarioVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const DescriptionVisitor = FallbackVisitor;
3
+ export default DescriptionVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const IriVisitor = FallbackVisitor;
3
+ export default IriVisitor;
@@ -0,0 +1,3 @@
1
+ import FallbackVisitor from "../../FallbackVisitor.js";
2
+ const NameVisitor = FallbackVisitor;
3
+ export default NameVisitor;
@@ -0,0 +1,14 @@
1
+ import stampit from 'stampit';
2
+ import { always } from 'ramda';
3
+ import StandardElement from "../../../../elements/Standard.js";
4
+ import FallbackVisitor from "../../FallbackVisitor.js";
5
+ import FixedFieldsVisitor from "../../generics/FixedFieldsVisitor.js";
6
+ const StandardVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
7
+ props: {
8
+ specPath: always(['document', 'objects', 'Standard'])
9
+ },
10
+ init() {
11
+ this.element = new StandardElement();
12
+ }
13
+ });
14
+ export default StandardVisitor;
@@ -0,0 +1,22 @@
1
+ import stampit from 'stampit';
2
+ import { BREAK } from '@swagger-api/apidom-core';
3
+ import FallbackVisitor from "../../FallbackVisitor.js";
4
+ import SpecificationVisitor from "../../SpecificationVisitor.js";
5
+ import StandardIdentifierElement from "../../../../elements/StandardIdentifier.js";
6
+ const StandardIdentifierVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
7
+ init() {
8
+ this.element = new StandardIdentifierElement();
9
+ },
10
+ methods: {
11
+ ArrayElement(arrayElement) {
12
+ arrayElement.forEach(item => {
13
+ const specPath = ['document', 'objects', 'StandardIdentifier'];
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 StandardIdentifierVisitor;
@@ -0,0 +1,39 @@
1
+ import stampit from 'stampit';
2
+ import { noop } from 'ramda-adjunct';
3
+ import { BREAK, isStringElement, MemberElement } from '@swagger-api/apidom-core';
4
+ import SpecificationVisitor from "../SpecificationVisitor.js";
5
+ const FixedFieldsVisitor = stampit(SpecificationVisitor, {
6
+ props: {
7
+ specPath: noop,
8
+ ignoredFields: []
9
+ },
10
+ init({
11
+ // @ts-ignore
12
+ specPath = this.specPath,
13
+ // @ts-ignore
14
+ ignoredFields = this.ignoredFields
15
+ } = {}) {
16
+ this.specPath = specPath;
17
+ this.ignoredFields = ignoredFields;
18
+ },
19
+ methods: {
20
+ ObjectElement(objectElement) {
21
+ const specPath = this.specPath(objectElement);
22
+ const fields = this.retrieveFixedFields(specPath);
23
+ objectElement.forEach((value, key, memberElement) => {
24
+ if (isStringElement(key) && fields.includes(key.toValue()) && !this.ignoredFields.includes(key.toValue())) {
25
+ const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', key.toValue()], value);
26
+ const newMemberElement = new MemberElement(key.clone(), fixedFieldElement);
27
+ newMemberElement.classes.push('fixed-field');
28
+ this.copyMetaAndAttributes(memberElement, newMemberElement);
29
+ this.element.content.push(newMemberElement);
30
+ } else if (!this.ignoredFields.includes(key.toValue())) {
31
+ this.element.content.push(memberElement.clone());
32
+ }
33
+ });
34
+ this.copyMetaAndAttributes(objectElement, this.element);
35
+ return BREAK;
36
+ }
37
+ }
38
+ });
39
+ export default FixedFieldsVisitor;
@@ -0,0 +1,25 @@
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 { isElement, keyMap as keyMapBase } from '@swagger-api/apidom-core';
5
+
6
+ // getNodeType :: Node -> String
7
+ export const getNodeType = element => {
8
+ if (!isElement(element)) {
9
+ return undefined;
10
+ }
11
+ return `${element.element.charAt(0).toUpperCase() + element.element.slice(1)}Element`;
12
+ };
13
+ export const keyMap = _objectSpread({
14
+ /**
15
+ * API Design Systems 2021-05-07 specification elements.
16
+ */
17
+ MainElement: ['content'],
18
+ InfoElement: ['content'],
19
+ PrincipleElement: ['content'],
20
+ StandardElement: ['content'],
21
+ ScenarioElement: ['content'],
22
+ RequirementElement: ['content'],
23
+ StandardIdentifierElement: ['content'],
24
+ RequirementLevelElement: []
25
+ }, keyMapBase);
@@ -0,0 +1,27 @@
1
+ import { visit, ArrayElement } from '@swagger-api/apidom-core';
2
+ import { getNodeType, keyMap } from '@swagger-api/apidom-ns-openapi-3-1';
3
+ /**
4
+ * This file contains logic for translating Standard Identifier to value.
5
+ */
6
+
7
+ const visitorOptions = {
8
+ keyMap,
9
+ nodeTypeGetter: getNodeType
10
+ };
11
+ const access = (selected, standardIdentifier) => {
12
+ const strStandardIdentifier = String(standardIdentifier.toValue());
13
+ const values = new ArrayElement();
14
+ const visitor = {
15
+ enter(element) {
16
+ if (!element.meta.hasKey('ads-a-standard-identifier')) return;
17
+ element.meta.get('ads-a-standard-identifier').content.filter(accessorMapping => {
18
+ return String(accessorMapping.get('subject').toValue()) === strStandardIdentifier;
19
+ }).forEach(accessorMapping => {
20
+ values.push(accessorMapping.get('value'));
21
+ });
22
+ }
23
+ };
24
+ visit(selected, visitor, visitorOptions);
25
+ return values;
26
+ };
27
+ export default access;
@@ -0,0 +1,7 @@
1
+ export const may = (value, values) => {
2
+ if (value === null) return true;
3
+ return values.includes(value);
4
+ };
5
+ export const must = (value, values) => {
6
+ return values.includes(value);
7
+ };
@@ -0,0 +1,33 @@
1
+ import { includes } from 'ramda';
2
+ import { visit } from '@swagger-api/apidom-core';
3
+ import { getNodeType, keyMap } from '@swagger-api/apidom-ns-openapi-3-1';
4
+ /**
5
+ * This file contains logic for translating Standard Identifier to list of Operation Elements.
6
+ */
7
+
8
+ const visitorOptions = {
9
+ keyMap,
10
+ nodeTypeGetter: getNodeType
11
+ };
12
+ const select = (openAPIElement, standardIdentifier) => {
13
+ const selected = [];
14
+ const visitor = {
15
+ OperationElement(element) {
16
+ if (!element.meta.hasKey('ads-s-standard-identifier')) return;
17
+ const standardIdentifiers = element.meta.get('ads-s-standard-identifier').toValue();
18
+ if (includes(standardIdentifier.toValue(), standardIdentifiers)) {
19
+ selected.push(element);
20
+ }
21
+ },
22
+ ResponseElement(element) {
23
+ if (!element.meta.hasKey('ads-s-standard-identifier')) return;
24
+ const standardIdentifiers = element.meta.get('ads-s-standard-identifier').toValue();
25
+ if (includes(standardIdentifier.toValue(), standardIdentifiers)) {
26
+ selected.push(element);
27
+ }
28
+ }
29
+ };
30
+ visit(openAPIElement, visitor, visitorOptions);
31
+ return selected;
32
+ };
33
+ export default select;
@@ -0,0 +1,80 @@
1
+ import { AnnotationElement, isArrayElement } from '@swagger-api/apidom-core';
2
+ import select from "./selector.js";
3
+ import access from "./accessor.js";
4
+ import { may } from "./requirement-level.js";
5
+ const makeMessage = (value, requirementLevel, standardIdentifier) => {
6
+ const primitiveValue = value.toValue();
7
+ const primitiveStandardIdentifier = JSON.stringify(standardIdentifier.toValue());
8
+ if (requirementLevel.toValue() === 'may') {
9
+ return `"${primitiveValue}" not allowed for subject ${primitiveStandardIdentifier}`;
10
+ }
11
+ throw new Error('Not Implemented');
12
+ };
13
+
14
+ // @ts-ignore
15
+ const makeAnnotation = (message, value, level, standardIdentifier) => {
16
+ const annotation = new AnnotationElement(message);
17
+ annotation.classes.push(level);
18
+ annotation.attributes.set('value', value.clone());
19
+ annotation.attributes.set('standardIdentifier', standardIdentifier.clone());
20
+ return annotation;
21
+ };
22
+ const validateValue = (value, requirement) => {
23
+ const annotations = [];
24
+ const {
25
+ subject
26
+ } = requirement;
27
+ if (typeof requirement.values === 'undefined') return annotations;
28
+ if (requirement.level.toValue() === 'may') {
29
+ const isValid = may(value.toValue(), requirement.values.toValue());
30
+ if (!isValid) {
31
+ const message = makeMessage(value, requirement.level, subject);
32
+ const annotation = makeAnnotation(message, value, 'error', subject);
33
+ annotations.push(annotation);
34
+ }
35
+ }
36
+ return annotations;
37
+ };
38
+ const validateRequirement = (requirement, selected) => {
39
+ const {
40
+ subject
41
+ } = requirement;
42
+ const values = access(selected, subject);
43
+ const annotations = [];
44
+ values.forEach(value => {
45
+ annotations.push(...validateValue(value, requirement));
46
+ });
47
+ return annotations;
48
+ };
49
+ const validateScenario = (scenario, openApiElement) => {
50
+ const annotations = [];
51
+ const {
52
+ when
53
+ } = scenario;
54
+ const selected = select(openApiElement, when);
55
+ const {
56
+ then: requirements
57
+ } = scenario;
58
+ if (typeof requirements === 'undefined') return annotations;
59
+ selected.forEach(item => {
60
+ // @ts-ignore
61
+ requirements.forEach(requirement => {
62
+ annotations.push(...validateRequirement(requirement, item));
63
+ });
64
+ });
65
+ return annotations;
66
+ };
67
+ const validate = (mainElement, openApiElement) => {
68
+ const {
69
+ scenarios
70
+ } = mainElement;
71
+ const annotations = [];
72
+ if (typeof scenarios === 'undefined' || !isArrayElement(scenarios)) return [];
73
+
74
+ // @ts-ignore
75
+ scenarios.forEach(scenario => {
76
+ annotations.push(...validateScenario(scenario, openApiElement));
77
+ });
78
+ return annotations;
79
+ };
80
+ export default validate;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@swagger-api/apidom-ns-api-design-systems",
3
+ "description": "API Design Systems 2021-05-07 namespace for ApiDOM.",
4
+ "version": "0.68.1",
5
+ "publishConfig": {
6
+ "access": "public",
7
+ "registry": "https://registry.npmjs.org"
8
+ },
9
+ "type": "module",
10
+ "sideEffects": [
11
+ "./es/refractor/registration.js",
12
+ "./cjs/refractor/registration.cjs"
13
+ ],
14
+ "unpkg": "./dist/apidom-ns-api-design-systems.browser.min.js",
15
+ "main": "./cjs/index.cjs",
16
+ "exports": {
17
+ "types": "./types/dist.d.ts",
18
+ "import": "./es/index.js",
19
+ "require": "./cjs/index.cjs"
20
+ },
21
+ "types": "./types/dist.d.ts",
22
+ "scripts": {
23
+ "build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
24
+ "build:es": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --root-mode 'upward'",
25
+ "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
26
+ "build:umd:browser": "cross-env BABEL_ENV=browser BROWSERSLIST_ENV=production webpack --config config/webpack/browser.config.js --progress",
27
+ "lint": "eslint ./",
28
+ "lint:fix": "eslint ./ --fix",
29
+ "clean": "rimraf ./es ./cjs ./dist ./types",
30
+ "test": "cross-env NODE_ENV=test BABEL_ENV=cjs mocha",
31
+ "test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 BABEL_ENV=cjs mocha",
32
+ "typescript:check-types": "tsc --noEmit",
33
+ "typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
34
+ "prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
35
+ "postpack": "rimraf NOTICE LICENSES"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/swagger-api/apidom.git"
40
+ },
41
+ "author": "Vladimir Gorej",
42
+ "license": "Apache-2.0",
43
+ "dependencies": {
44
+ "@babel/runtime-corejs3": "^7.20.7",
45
+ "@swagger-api/apidom-core": "^0.68.1",
46
+ "@swagger-api/apidom-ns-openapi-3-1": "^0.68.1",
47
+ "@types/ramda": "=0.28.23",
48
+ "ramda": "=0.28.0",
49
+ "ramda-adjunct": "=3.4.0",
50
+ "stampit": "=4.3.2"
51
+ },
52
+ "files": [
53
+ "cjs/",
54
+ "dist/",
55
+ "es/",
56
+ "types/dist.d.ts",
57
+ "LICENSES",
58
+ "NOTICE",
59
+ "README.md",
60
+ "CHANGELOG.md"
61
+ ],
62
+ "gitHead": "d2bc706671f1b9a593b8f0c5bca8c501ad0e4cff"
63
+ }
@@ -0,0 +1,158 @@
1
+ /// <reference types="@swagger-api/apidom-core/types/minim" />
2
+ import { MediaTypes, NamespacePluginOptions, ObjectElement, Meta, Attributes, StringElement, ArrayElement, AnnotationElement, Element } from '@swagger-api/apidom-core';
3
+ export { isArrayElement, isBooleanElement, isElement, isLinkElement, isMemberElement, isNullElement, isNumberElement, isObjectElement, isRefElement, isStringElement } from '@swagger-api/apidom-core';
4
+ import * as minim from 'minim';
5
+ import { OperationElement, ParameterElement, RequestBodyElement, ResponseElement, OpenApi3_1Element } from '@swagger-api/apidom-ns-openapi-3-1';
6
+
7
+ type Format = 'generic' | 'json' | 'yaml';
8
+ declare class ApiDesignSystemsMediaTypes extends MediaTypes<string> {
9
+ filterByFormat(format?: Format): string[];
10
+ findBy(version?: string, format?: Format): string;
11
+ latest(format?: Format): string;
12
+ }
13
+ declare const mediaTypes: ApiDesignSystemsMediaTypes;
14
+
15
+ declare const apiDesignSystems: {
16
+ namespace: (options: NamespacePluginOptions) => minim.Namespace;
17
+ };
18
+
19
+ declare const plugin$1: () => () => {
20
+ visitor: {
21
+ OperationElement: {
22
+ enter(element: OperationElement, ...rest: any): void;
23
+ leave(element: OperationElement): void;
24
+ };
25
+ ParameterElement(element: ParameterElement): void;
26
+ RequestBodyElement(element: RequestBodyElement): void;
27
+ ResponseElement: {
28
+ enter(element: ResponseElement): void;
29
+ leave(element: ResponseElement): void;
30
+ };
31
+ };
32
+ };
33
+
34
+ declare const plugin: () => () => {
35
+ visitor: {
36
+ OperationElement(element: OperationElement, ...rest: any): void;
37
+ ParameterElement(element: ParameterElement): void;
38
+ RequestBodyElement(element: RequestBodyElement): void;
39
+ ResponseElement(element: ResponseElement): void;
40
+ };
41
+ };
42
+
43
+ declare class Info extends ObjectElement {
44
+ constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes);
45
+ get title(): StringElement | undefined;
46
+ set title(title: StringElement | undefined);
47
+ get description(): StringElement | undefined;
48
+ set description(description: StringElement | undefined);
49
+ }
50
+
51
+ declare class Main extends ObjectElement {
52
+ constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes);
53
+ get version(): StringElement | undefined;
54
+ set version(version: StringElement | undefined);
55
+ get info(): Info | undefined;
56
+ set info(info: Info | undefined);
57
+ get principles(): ArrayElement | undefined;
58
+ set principles(principles: ArrayElement | undefined);
59
+ get standards(): ArrayElement | undefined;
60
+ set standards(standards: ArrayElement | undefined);
61
+ get scenarios(): ArrayElement | undefined;
62
+ set scenarios(scenarios: ArrayElement | undefined);
63
+ }
64
+
65
+ declare const validate: (mainElement: Main, openApiElement: OpenApi3_1Element) => AnnotationElement[];
66
+
67
+ declare const isMainElement: (element: any) => boolean;
68
+ declare const isInfoElement: (element: any) => boolean;
69
+ declare const isPrincipleElement: (element: any) => boolean;
70
+ declare const isRequirementElement: (element: any) => boolean;
71
+ declare const isRequirementLevelElement: (element: any) => boolean;
72
+ declare const isScenarioElement: (element: any) => boolean;
73
+ declare const isStandardElement: (element: any) => boolean;
74
+ declare const isStandardIdentifierElement: (element: any) => boolean;
75
+
76
+ declare const getNodeType: <T extends Element>(element: T) => string | undefined;
77
+ declare const keyMap: {
78
+ ObjectElement: string[];
79
+ ArrayElement: string[];
80
+ MemberElement: string[];
81
+ StringElement: never[];
82
+ BooleanElement: never[];
83
+ NumberElement: never[];
84
+ NullElement: never[];
85
+ RefElement: never[];
86
+ LinkElement: never[];
87
+ Annotation: never[];
88
+ Comment: never[];
89
+ ParseResultElement: string[];
90
+ SourceMap: string[];
91
+ /**
92
+ * API Design Systems 2021-05-07 specification elements.
93
+ */
94
+ MainElement: string[];
95
+ InfoElement: string[];
96
+ PrincipleElement: string[];
97
+ StandardElement: string[];
98
+ ScenarioElement: string[];
99
+ RequirementElement: string[];
100
+ StandardIdentifierElement: string[];
101
+ RequirementLevelElement: never[];
102
+ };
103
+
104
+ declare class RequirementLevel extends StringElement {
105
+ constructor(content?: string, meta?: Meta, attributes?: Attributes);
106
+ }
107
+
108
+ declare class Principle extends ObjectElement {
109
+ constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes);
110
+ get name(): StringElement | undefined;
111
+ set name(name: StringElement | undefined);
112
+ get description(): StringElement | undefined;
113
+ set description(description: StringElement | undefined);
114
+ get iri(): StringElement | undefined;
115
+ set iri(iri: StringElement | undefined);
116
+ get level(): RequirementLevel | undefined;
117
+ set level(level: RequirementLevel | undefined);
118
+ }
119
+
120
+ declare class StandardIdentifier extends ArrayElement {
121
+ constructor(content?: string[], meta?: Meta, attributes?: Attributes);
122
+ }
123
+
124
+ declare class Requirement extends ObjectElement {
125
+ constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes);
126
+ get subject(): StandardIdentifier;
127
+ set subject(subject: StandardIdentifier);
128
+ get level(): RequirementLevel;
129
+ set level(level: RequirementLevel);
130
+ get values(): ArrayElement | undefined;
131
+ set values(values: ArrayElement | undefined);
132
+ get follows(): StringElement | undefined;
133
+ set follows(follows: StringElement | undefined);
134
+ }
135
+
136
+ declare class Scenario extends ObjectElement {
137
+ constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes);
138
+ get description(): StringElement | undefined;
139
+ set description(description: StringElement | undefined);
140
+ get when(): StandardIdentifier;
141
+ set when(when: StandardIdentifier);
142
+ get then(): ArrayElement | undefined;
143
+ set then(then: ArrayElement | undefined);
144
+ }
145
+
146
+ declare class Standard extends ObjectElement {
147
+ constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes);
148
+ get name(): StringElement | undefined;
149
+ set name(name: StringElement | undefined);
150
+ get description(): StringElement | undefined;
151
+ set description(description: StringElement | undefined);
152
+ get iri(): StringElement | undefined;
153
+ set iri(iri: StringElement | undefined);
154
+ get level(): RequirementLevel | undefined;
155
+ set level(level: RequirementLevel | undefined);
156
+ }
157
+
158
+ export { ApiDesignSystemsMediaTypes, Info as InfoElement, Main as MainElement, Principle as PrincipleElement, Requirement as RequirementElement, RequirementLevel as RequirementLevelElement, Scenario as ScenarioElement, Standard as StandardElement, StandardIdentifier as StandardIdentifierElement, apiDesignSystems as default, getNodeType, isInfoElement, isMainElement, isPrincipleElement, isRequirementElement, isRequirementLevelElement, isScenarioElement, isStandardElement, isStandardIdentifierElement, keyMap, mediaTypes, plugin as refractPluginOpenApi3_1StandardIdentifierAccessors, plugin$1 as refractPluginOpenApi3_1StandardIdentifierSelectors, validate as validateOpenAPI3_1 };