@speclynx/apidom-ns-openapi-2 4.0.2 → 4.0.3
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/package.json +8 -9
- package/src/elements/Contact.cjs +33 -0
- package/src/elements/Contact.mjs +30 -0
- package/src/elements/Contact.ts +42 -0
- package/src/elements/Definitions.cjs +15 -0
- package/src/elements/Definitions.mjs +12 -0
- package/src/elements/Definitions.ts +13 -0
- package/src/elements/Example.cjs +15 -0
- package/src/elements/Example.mjs +12 -0
- package/src/elements/Example.ts +13 -0
- package/src/elements/ExternalDocumentation.cjs +27 -0
- package/src/elements/ExternalDocumentation.mjs +24 -0
- package/src/elements/ExternalDocumentation.ts +34 -0
- package/src/elements/Header.cjs +185 -0
- package/src/elements/Header.mjs +182 -0
- package/src/elements/Header.ts +261 -0
- package/src/elements/Headers.cjs +15 -0
- package/src/elements/Headers.mjs +12 -0
- package/src/elements/Headers.ts +13 -0
- package/src/elements/Info.cjs +52 -0
- package/src/elements/Info.mjs +48 -0
- package/src/elements/Info.ts +70 -0
- package/src/elements/Items.cjs +190 -0
- package/src/elements/Items.mjs +187 -0
- package/src/elements/Items.ts +264 -0
- package/src/elements/License.cjs +27 -0
- package/src/elements/License.mjs +24 -0
- package/src/elements/License.ts +34 -0
- package/src/elements/Operation.cjs +78 -0
- package/src/elements/Operation.mjs +74 -0
- package/src/elements/Operation.ts +106 -0
- package/src/elements/Parameter.cjs +230 -0
- package/src/elements/Parameter.mjs +226 -0
- package/src/elements/Parameter.ts +326 -0
- package/src/elements/ParametersDefinitions.cjs +15 -0
- package/src/elements/ParametersDefinitions.mjs +12 -0
- package/src/elements/ParametersDefinitions.ts +13 -0
- package/src/elements/PathItem.cjs +69 -0
- package/src/elements/PathItem.mjs +65 -0
- package/src/elements/PathItem.ts +93 -0
- package/src/elements/Paths.cjs +15 -0
- package/src/elements/Paths.mjs +12 -0
- package/src/elements/Paths.ts +13 -0
- package/src/elements/Reference.cjs +22 -0
- package/src/elements/Reference.mjs +19 -0
- package/src/elements/Reference.ts +27 -0
- package/src/elements/Response.cjs +39 -0
- package/src/elements/Response.mjs +35 -0
- package/src/elements/Response.ts +54 -0
- package/src/elements/Responses.cjs +21 -0
- package/src/elements/Responses.mjs +17 -0
- package/src/elements/Responses.ts +24 -0
- package/src/elements/ResponsesDefinitions.cjs +15 -0
- package/src/elements/ResponsesDefinitions.mjs +12 -0
- package/src/elements/ResponsesDefinitions.ts +13 -0
- package/src/elements/Schema.cjs +151 -0
- package/src/elements/Schema.mjs +147 -0
- package/src/elements/Schema.ts +204 -0
- package/src/elements/Scopes.cjs +15 -0
- package/src/elements/Scopes.mjs +12 -0
- package/src/elements/Scopes.ts +13 -0
- package/src/elements/SecurityDefinitions.cjs +15 -0
- package/src/elements/SecurityDefinitions.mjs +12 -0
- package/src/elements/SecurityDefinitions.ts +13 -0
- package/src/elements/SecurityRequirement.cjs +15 -0
- package/src/elements/SecurityRequirement.mjs +12 -0
- package/src/elements/SecurityRequirement.ts +13 -0
- package/src/elements/SecurityScheme.cjs +63 -0
- package/src/elements/SecurityScheme.mjs +60 -0
- package/src/elements/SecurityScheme.ts +83 -0
- package/src/elements/Swagger.cjs +106 -0
- package/src/elements/Swagger.mjs +102 -0
- package/src/elements/Swagger.ts +149 -0
- package/src/elements/SwaggerVersion.cjs +17 -0
- package/src/elements/SwaggerVersion.mjs +14 -0
- package/src/elements/SwaggerVersion.ts +15 -0
- package/src/elements/Tag.cjs +33 -0
- package/src/elements/Tag.mjs +29 -0
- package/src/elements/Tag.ts +44 -0
- package/src/elements/Xml.cjs +45 -0
- package/src/elements/Xml.mjs +42 -0
- package/src/elements/Xml.ts +59 -0
- package/src/elements/nces/OperationConsumes.cjs +16 -0
- package/src/elements/nces/OperationConsumes.mjs +13 -0
- package/src/elements/nces/OperationConsumes.ts +15 -0
- package/src/elements/nces/OperationParameters.cjs +17 -0
- package/src/elements/nces/OperationParameters.mjs +14 -0
- package/src/elements/nces/OperationParameters.ts +16 -0
- package/src/elements/nces/OperationProduces.cjs +16 -0
- package/src/elements/nces/OperationProduces.mjs +13 -0
- package/src/elements/nces/OperationProduces.ts +15 -0
- package/src/elements/nces/OperationSchemes.cjs +16 -0
- package/src/elements/nces/OperationSchemes.mjs +13 -0
- package/src/elements/nces/OperationSchemes.ts +15 -0
- package/src/elements/nces/OperationSecurity.cjs +17 -0
- package/src/elements/nces/OperationSecurity.mjs +14 -0
- package/src/elements/nces/OperationSecurity.ts +16 -0
- package/src/elements/nces/OperationTags.cjs +17 -0
- package/src/elements/nces/OperationTags.mjs +14 -0
- package/src/elements/nces/OperationTags.ts +16 -0
- package/src/elements/nces/PathItemParameters.cjs +17 -0
- package/src/elements/nces/PathItemParameters.mjs +14 -0
- package/src/elements/nces/PathItemParameters.ts +16 -0
- package/src/elements/nces/SwaggerConsumes.cjs +16 -0
- package/src/elements/nces/SwaggerConsumes.mjs +13 -0
- package/src/elements/nces/SwaggerConsumes.ts +15 -0
- package/src/elements/nces/SwaggerProduces.cjs +16 -0
- package/src/elements/nces/SwaggerProduces.mjs +13 -0
- package/src/elements/nces/SwaggerProduces.ts +15 -0
- package/src/elements/nces/SwaggerSchemes.cjs +16 -0
- package/src/elements/nces/SwaggerSchemes.mjs +13 -0
- package/src/elements/nces/SwaggerSchemes.ts +15 -0
- package/src/elements/nces/SwaggerSecurity.cjs +17 -0
- package/src/elements/nces/SwaggerSecurity.mjs +14 -0
- package/src/elements/nces/SwaggerSecurity.ts +16 -0
- package/src/elements/nces/SwaggerTags.cjs +16 -0
- package/src/elements/nces/SwaggerTags.mjs +13 -0
- package/src/elements/nces/SwaggerTags.ts +15 -0
- package/src/index.cjs +156 -0
- package/src/index.mjs +32 -0
- package/src/index.ts +368 -0
- package/src/media-types.cjs +34 -0
- package/src/media-types.mjs +30 -0
- package/src/media-types.ts +42 -0
- package/src/namespace.cjs +71 -0
- package/src/namespace.mjs +66 -0
- package/src/namespace.ts +70 -0
- package/src/predicates.cjs +193 -0
- package/src/predicates.mjs +161 -0
- package/src/predicates.ts +194 -0
- package/src/refractor/index.cjs +316 -0
- package/src/refractor/index.mjs +283 -0
- package/src/refractor/index.ts +330 -0
- package/src/refractor/inspect.cjs +157 -0
- package/src/refractor/inspect.mjs +126 -0
- package/src/refractor/inspect.ts +181 -0
- package/src/refractor/plugins/replace-empty-element.cjs +366 -0
- package/src/refractor/plugins/replace-empty-element.mjs +358 -0
- package/src/refractor/plugins/replace-empty-element.ts +389 -0
- package/src/refractor/predicates.cjs +26 -0
- package/src/refractor/predicates.mjs +21 -0
- package/src/refractor/predicates.ts +29 -0
- package/src/refractor/specification.cjs +519 -0
- package/src/refractor/specification.mjs +513 -0
- package/src/refractor/specification.ts +444 -0
- package/src/refractor/toolbox.cjs +28 -0
- package/src/refractor/toolbox.mjs +21 -0
- package/src/refractor/toolbox.ts +24 -0
- package/src/refractor/visitors/FallbackVisitor.cjs +24 -0
- package/src/refractor/visitors/FallbackVisitor.mjs +18 -0
- package/src/refractor/visitors/FallbackVisitor.ts +25 -0
- package/src/refractor/visitors/SpecificationExtensionVisitor.cjs +18 -0
- package/src/refractor/visitors/SpecificationExtensionVisitor.mjs +13 -0
- package/src/refractor/visitors/SpecificationExtensionVisitor.ts +22 -0
- package/src/refractor/visitors/SpecificationVisitor.cjs +75 -0
- package/src/refractor/visitors/SpecificationVisitor.mjs +69 -0
- package/src/refractor/visitors/SpecificationVisitor.ts +83 -0
- package/src/refractor/visitors/Visitor.cjs +36 -0
- package/src/refractor/visitors/Visitor.mjs +33 -0
- package/src/refractor/visitors/Visitor.ts +47 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.cjs +42 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.mjs +35 -0
- package/src/refractor/visitors/generics/AlternatingVisitor.ts +45 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.cjs +73 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +66 -0
- package/src/refractor/visitors/generics/FixedFieldsVisitor.ts +109 -0
- package/src/refractor/visitors/generics/MapVisitor.cjs +21 -0
- package/src/refractor/visitors/generics/MapVisitor.mjs +15 -0
- package/src/refractor/visitors/generics/MapVisitor.ts +25 -0
- package/src/refractor/visitors/generics/MixedFieldsVisitor.cjs +67 -0
- package/src/refractor/visitors/generics/MixedFieldsVisitor.mjs +61 -0
- package/src/refractor/visitors/generics/MixedFieldsVisitor.ts +77 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +72 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +66 -0
- package/src/refractor/visitors/generics/PatternedFieldsVisitor.ts +99 -0
- package/src/refractor/visitors/open-api-2/BasePathVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-2/BasePathVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-2/BasePathVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-2/ConsumesVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/ConsumesVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/ConsumesVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/HostVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-2/HostVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-2/HostVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-2/ProducesVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/ProducesVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/ProducesVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/SchemesVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/SchemesVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/SchemesVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/SecurityVisitor.cjs +27 -0
- package/src/refractor/visitors/open-api-2/SecurityVisitor.mjs +22 -0
- package/src/refractor/visitors/open-api-2/SecurityVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-2/SwaggerVisitor.cjs +21 -0
- package/src/refractor/visitors/open-api-2/SwaggerVisitor.mjs +16 -0
- package/src/refractor/visitors/open-api-2/SwaggerVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/TagsVisitor.cjs +27 -0
- package/src/refractor/visitors/open-api-2/TagsVisitor.mjs +22 -0
- package/src/refractor/visitors/open-api-2/TagsVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-2/bases.cjs +72 -0
- package/src/refractor/visitors/open-api-2/bases.mjs +67 -0
- package/src/refractor/visitors/open-api-2/bases.ts +82 -0
- package/src/refractor/visitors/open-api-2/contact/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/contact/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/contact/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/definitions/index.cjs +31 -0
- package/src/refractor/visitors/open-api-2/definitions/index.mjs +26 -0
- package/src/refractor/visitors/open-api-2/definitions/index.ts +48 -0
- package/src/refractor/visitors/open-api-2/example/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/example/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/example/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/external-documentation/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/external-documentation/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/external-documentation/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/header/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/header/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/header/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/headers/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/headers/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/headers/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/index.cjs +21 -0
- package/src/refractor/visitors/open-api-2/index.mjs +16 -0
- package/src/refractor/visitors/open-api-2/index.ts +28 -0
- package/src/refractor/visitors/open-api-2/info/VersionVisitor.cjs +17 -0
- package/src/refractor/visitors/open-api-2/info/VersionVisitor.mjs +12 -0
- package/src/refractor/visitors/open-api-2/info/VersionVisitor.ts +21 -0
- package/src/refractor/visitors/open-api-2/info/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/info/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/info/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/items/index.cjs +22 -0
- package/src/refractor/visitors/open-api-2/items/index.mjs +17 -0
- package/src/refractor/visitors/open-api-2/items/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/license/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/license/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/license/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.ts +44 -0
- package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.cjs +27 -0
- package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.mjs +22 -0
- package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.ts +34 -0
- package/src/refractor/visitors/open-api-2/operation/TagsVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/operation/TagsVisitor.mjs +18 -0
- package/src/refractor/visitors/open-api-2/operation/TagsVisitor.ts +29 -0
- package/src/refractor/visitors/open-api-2/operation/index.cjs +19 -0
- package/src/refractor/visitors/open-api-2/operation/index.mjs +14 -0
- package/src/refractor/visitors/open-api-2/operation/index.ts +24 -0
- package/src/refractor/visitors/open-api-2/parameter/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/parameter/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/parameter/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/parameters-definitions/index.cjs +19 -0
- package/src/refractor/visitors/open-api-2/parameters-definitions/index.mjs +14 -0
- package/src/refractor/visitors/open-api-2/parameters-definitions/index.ts +24 -0
- package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.cjs +32 -0
- package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.mjs +27 -0
- package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.ts +44 -0
- package/src/refractor/visitors/open-api-2/path-item/index.cjs +39 -0
- package/src/refractor/visitors/open-api-2/path-item/index.mjs +34 -0
- package/src/refractor/visitors/open-api-2/path-item/index.ts +48 -0
- package/src/refractor/visitors/open-api-2/paths/index.cjs +37 -0
- package/src/refractor/visitors/open-api-2/paths/index.mjs +32 -0
- package/src/refractor/visitors/open-api-2/paths/index.ts +48 -0
- package/src/refractor/visitors/open-api-2/reference/$RefVisitor.cjs +16 -0
- package/src/refractor/visitors/open-api-2/reference/$RefVisitor.mjs +11 -0
- package/src/refractor/visitors/open-api-2/reference/$RefVisitor.ts +20 -0
- package/src/refractor/visitors/open-api-2/reference/index.cjs +29 -0
- package/src/refractor/visitors/open-api-2/reference/index.mjs +24 -0
- package/src/refractor/visitors/open-api-2/reference/index.ts +38 -0
- package/src/refractor/visitors/open-api-2/response/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/response/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/response/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.cjs +36 -0
- package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.mjs +31 -0
- package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.ts +36 -0
- package/src/refractor/visitors/open-api-2/responses/index.cjs +45 -0
- package/src/refractor/visitors/open-api-2/responses/index.mjs +40 -0
- package/src/refractor/visitors/open-api-2/responses/index.ts +64 -0
- package/src/refractor/visitors/open-api-2/responses-definitions/index.cjs +19 -0
- package/src/refractor/visitors/open-api-2/responses-definitions/index.mjs +14 -0
- package/src/refractor/visitors/open-api-2/responses-definitions/index.ts +24 -0
- package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.cjs +24 -0
- package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.mjs +20 -0
- package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.ts +35 -0
- package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.cjs +26 -0
- package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.mjs +23 -0
- package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.ts +38 -0
- package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.cjs +24 -0
- package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.mjs +20 -0
- package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.ts +35 -0
- package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.cjs +23 -0
- package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.mjs +19 -0
- package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.ts +37 -0
- package/src/refractor/visitors/open-api-2/schema/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/schema/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/schema/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/scopes/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/scopes/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/scopes/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/security-definitions/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/security-definitions/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/security-definitions/index.ts +24 -0
- package/src/refractor/visitors/open-api-2/security-requirement/index.cjs +19 -0
- package/src/refractor/visitors/open-api-2/security-requirement/index.mjs +14 -0
- package/src/refractor/visitors/open-api-2/security-requirement/index.ts +24 -0
- package/src/refractor/visitors/open-api-2/security-scheme/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/security-scheme/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/security-scheme/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/tag/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/tag/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/tag/index.ts +27 -0
- package/src/refractor/visitors/open-api-2/xml/index.cjs +20 -0
- package/src/refractor/visitors/open-api-2/xml/index.mjs +15 -0
- package/src/refractor/visitors/open-api-2/xml/index.ts +27 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _ramda = require("ramda");
|
|
7
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
9
|
+
var _apidomTraverse = require("@speclynx/apidom-traverse");
|
|
10
|
+
var _Visitor = _interopRequireDefault(require("./Visitor.cjs"));
|
|
11
|
+
var _FallbackVisitor = _interopRequireDefault(require("./FallbackVisitor.cjs"));
|
|
12
|
+
/**
|
|
13
|
+
* This is a base Type for every visitor that does
|
|
14
|
+
* internal look-ups to retrieve other child visitors.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
class SpecificationVisitor extends _Visitor.default {
|
|
22
|
+
specObj;
|
|
23
|
+
passingOptionsNames = ['specObj', 'consume'];
|
|
24
|
+
constructor({
|
|
25
|
+
specObj,
|
|
26
|
+
...rest
|
|
27
|
+
}) {
|
|
28
|
+
super({
|
|
29
|
+
...rest
|
|
30
|
+
});
|
|
31
|
+
this.specObj = specObj;
|
|
32
|
+
}
|
|
33
|
+
retrievePassingOptions() {
|
|
34
|
+
return (0, _ramda.pick)(this.passingOptionsNames, this);
|
|
35
|
+
}
|
|
36
|
+
retrieveFixedFields(specPath) {
|
|
37
|
+
const fixedFields = (0, _ramda.path)(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
38
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
39
|
+
return Object.keys(fixedFields);
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
retrieveVisitor(specPath) {
|
|
44
|
+
if ((0, _ramda.pathSatisfies)(_ramdaAdjunct.isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
45
|
+
return (0, _ramda.path)(['visitors', ...specPath], this.specObj);
|
|
46
|
+
}
|
|
47
|
+
return (0, _ramda.path)(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
48
|
+
}
|
|
49
|
+
retrieveVisitorInstance(specPath, options = {}) {
|
|
50
|
+
const passingOpts = this.retrievePassingOptions();
|
|
51
|
+
const VisitorClz = this.retrieveVisitor(specPath);
|
|
52
|
+
const visitorOpts = {
|
|
53
|
+
...passingOpts,
|
|
54
|
+
...options
|
|
55
|
+
};
|
|
56
|
+
return new VisitorClz(visitorOpts);
|
|
57
|
+
}
|
|
58
|
+
toRefractedElement(specPath, element, options = {}) {
|
|
59
|
+
/**
|
|
60
|
+
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
61
|
+
* it by basic node cloning.
|
|
62
|
+
*
|
|
63
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
64
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
65
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
66
|
+
*/
|
|
67
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
68
|
+
if (visitor instanceof _FallbackVisitor.default && visitor?.constructor === _FallbackVisitor.default) {
|
|
69
|
+
return this.consume ? element : (0, _apidomDatamodel.cloneDeep)(element);
|
|
70
|
+
}
|
|
71
|
+
(0, _apidomTraverse.traverse)(element, visitor);
|
|
72
|
+
return visitor.element;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var _default = exports.default = SpecificationVisitor;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { pathSatisfies, path, pick } from 'ramda';
|
|
2
|
+
import { isFunction } from 'ramda-adjunct';
|
|
3
|
+
import { cloneDeep } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { traverse } from '@speclynx/apidom-traverse';
|
|
5
|
+
import Visitor from "./Visitor.mjs";
|
|
6
|
+
import FallbackVisitor from "./FallbackVisitor.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* This is a base Type for every visitor that does
|
|
9
|
+
* internal look-ups to retrieve other child visitors.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class SpecificationVisitor extends Visitor {
|
|
16
|
+
specObj;
|
|
17
|
+
passingOptionsNames = ['specObj', 'consume'];
|
|
18
|
+
constructor({
|
|
19
|
+
specObj,
|
|
20
|
+
...rest
|
|
21
|
+
}) {
|
|
22
|
+
super({
|
|
23
|
+
...rest
|
|
24
|
+
});
|
|
25
|
+
this.specObj = specObj;
|
|
26
|
+
}
|
|
27
|
+
retrievePassingOptions() {
|
|
28
|
+
return pick(this.passingOptionsNames, this);
|
|
29
|
+
}
|
|
30
|
+
retrieveFixedFields(specPath) {
|
|
31
|
+
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
32
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
33
|
+
return Object.keys(fixedFields);
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
retrieveVisitor(specPath) {
|
|
38
|
+
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
39
|
+
return path(['visitors', ...specPath], this.specObj);
|
|
40
|
+
}
|
|
41
|
+
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
42
|
+
}
|
|
43
|
+
retrieveVisitorInstance(specPath, options = {}) {
|
|
44
|
+
const passingOpts = this.retrievePassingOptions();
|
|
45
|
+
const VisitorClz = this.retrieveVisitor(specPath);
|
|
46
|
+
const visitorOpts = {
|
|
47
|
+
...passingOpts,
|
|
48
|
+
...options
|
|
49
|
+
};
|
|
50
|
+
return new VisitorClz(visitorOpts);
|
|
51
|
+
}
|
|
52
|
+
toRefractedElement(specPath, element, options = {}) {
|
|
53
|
+
/**
|
|
54
|
+
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
55
|
+
* it by basic node cloning.
|
|
56
|
+
*
|
|
57
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
58
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
59
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
60
|
+
*/
|
|
61
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
62
|
+
if (visitor instanceof FallbackVisitor && visitor?.constructor === FallbackVisitor) {
|
|
63
|
+
return this.consume ? element : cloneDeep(element);
|
|
64
|
+
}
|
|
65
|
+
traverse(element, visitor);
|
|
66
|
+
return visitor.element;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export default SpecificationVisitor;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { pathSatisfies, path, pick } from 'ramda';
|
|
2
|
+
import { isFunction } from 'ramda-adjunct';
|
|
3
|
+
import { cloneDeep } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { traverse } from '@speclynx/apidom-traverse';
|
|
5
|
+
|
|
6
|
+
import Visitor, { VisitorOptions } from './Visitor.ts';
|
|
7
|
+
import FallbackVisitor from './FallbackVisitor.ts';
|
|
8
|
+
import type specification from '../specification.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This is a base Type for every visitor that does
|
|
12
|
+
* internal look-ups to retrieve other child visitors.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface SpecificationVisitorOptions extends VisitorOptions {
|
|
16
|
+
readonly specObj: typeof specification;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
class SpecificationVisitor extends Visitor {
|
|
23
|
+
protected readonly specObj: typeof specification;
|
|
24
|
+
|
|
25
|
+
protected readonly passingOptionsNames = ['specObj', 'consume'];
|
|
26
|
+
|
|
27
|
+
constructor({ specObj, ...rest }: SpecificationVisitorOptions) {
|
|
28
|
+
super({ ...rest });
|
|
29
|
+
this.specObj = specObj;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
retrievePassingOptions() {
|
|
33
|
+
return pick(this.passingOptionsNames as (keyof this)[], this) as unknown as Record<
|
|
34
|
+
string,
|
|
35
|
+
unknown
|
|
36
|
+
>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
retrieveFixedFields(specPath: string[]) {
|
|
40
|
+
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
41
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
42
|
+
return Object.keys(fixedFields);
|
|
43
|
+
}
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
retrieveVisitor(specPath: string[]) {
|
|
48
|
+
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
49
|
+
return path(['visitors', ...specPath], this.specObj);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return path(['visitors', ...specPath, '$visitor'], this.specObj);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
retrieveVisitorInstance(specPath: string[], options = {}): Visitor {
|
|
56
|
+
const passingOpts = this.retrievePassingOptions();
|
|
57
|
+
const VisitorClz = this.retrieveVisitor(specPath) as typeof Visitor;
|
|
58
|
+
const visitorOpts = { ...passingOpts, ...options };
|
|
59
|
+
|
|
60
|
+
return new VisitorClz(visitorOpts);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
toRefractedElement(specPath: string[], element: any, options = {}) {
|
|
64
|
+
/**
|
|
65
|
+
* This is `Visitor shortcut`: mechanism for short circuiting the traversal and replacing
|
|
66
|
+
* it by basic node cloning.
|
|
67
|
+
*
|
|
68
|
+
* Visiting the element is equivalent to cloning it if the prototype of a visitor
|
|
69
|
+
* is the same as the prototype of FallbackVisitor. If that's the case, we can avoid
|
|
70
|
+
* bootstrapping the traversal cycle for fields that don't require any special visiting.
|
|
71
|
+
*/
|
|
72
|
+
const visitor = this.retrieveVisitorInstance(specPath, options);
|
|
73
|
+
|
|
74
|
+
if (visitor instanceof FallbackVisitor && visitor?.constructor === FallbackVisitor) {
|
|
75
|
+
return this.consume ? element : cloneDeep(element);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
traverse(element, visitor);
|
|
79
|
+
return visitor.element;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default SpecificationVisitor;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@speclynx/apidom-core");
|
|
6
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class Visitor {
|
|
15
|
+
element;
|
|
16
|
+
consume = false;
|
|
17
|
+
consumeSafe = false;
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
Object.assign(this, options);
|
|
20
|
+
}
|
|
21
|
+
copyMetaAndAttributes(from, to) {
|
|
22
|
+
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
23
|
+
to.meta = to.meta.merge(from.meta);
|
|
24
|
+
} else if (!from.isMetaEmpty) {
|
|
25
|
+
to.meta = from.meta.cloneDeep();
|
|
26
|
+
}
|
|
27
|
+
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
28
|
+
to.attributes = (0, _apidomCore.deepmerge)(to.attributes, from.attributes);
|
|
29
|
+
} else if (!from.isAttributesEmpty) {
|
|
30
|
+
to.attributes = (0, _apidomDatamodel.cloneDeep)(from.attributes);
|
|
31
|
+
}
|
|
32
|
+
_apidomDatamodel.SourceMapElement.transfer(from, to);
|
|
33
|
+
_apidomDatamodel.StyleElement.transfer(from, to);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var _default = exports.default = Visitor;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { deepmerge } from '@speclynx/apidom-core';
|
|
2
|
+
import { SourceMapElement, StyleElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class Visitor {
|
|
12
|
+
element;
|
|
13
|
+
consume = false;
|
|
14
|
+
consumeSafe = false;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
Object.assign(this, options);
|
|
17
|
+
}
|
|
18
|
+
copyMetaAndAttributes(from, to) {
|
|
19
|
+
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
20
|
+
to.meta = to.meta.merge(from.meta);
|
|
21
|
+
} else if (!from.isMetaEmpty) {
|
|
22
|
+
to.meta = from.meta.cloneDeep();
|
|
23
|
+
}
|
|
24
|
+
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
25
|
+
to.attributes = deepmerge(to.attributes, from.attributes);
|
|
26
|
+
} else if (!from.isAttributesEmpty) {
|
|
27
|
+
to.attributes = cloneDeep(from.attributes);
|
|
28
|
+
}
|
|
29
|
+
SourceMapElement.transfer(from, to);
|
|
30
|
+
StyleElement.transfer(from, to);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export default Visitor;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { deepmerge } from '@speclynx/apidom-core';
|
|
2
|
+
import {
|
|
3
|
+
Element,
|
|
4
|
+
ObjectElement,
|
|
5
|
+
SourceMapElement,
|
|
6
|
+
StyleElement,
|
|
7
|
+
cloneDeep,
|
|
8
|
+
} from '@speclynx/apidom-datamodel';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface VisitorOptions {
|
|
14
|
+
readonly consume?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
class Visitor {
|
|
21
|
+
public element!: Element;
|
|
22
|
+
|
|
23
|
+
protected readonly consume: boolean = false;
|
|
24
|
+
|
|
25
|
+
protected consumeSafe: boolean = false;
|
|
26
|
+
|
|
27
|
+
constructor(options: VisitorOptions = {}) {
|
|
28
|
+
Object.assign(this, options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public copyMetaAndAttributes(from: Element, to: Element) {
|
|
32
|
+
if (!from.isMetaEmpty && !to.isMetaEmpty) {
|
|
33
|
+
to.meta = to.meta.merge(from.meta);
|
|
34
|
+
} else if (!from.isMetaEmpty) {
|
|
35
|
+
to.meta = from.meta.cloneDeep();
|
|
36
|
+
}
|
|
37
|
+
if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
|
|
38
|
+
to.attributes = deepmerge(to.attributes, from.attributes) as ObjectElement;
|
|
39
|
+
} else if (!from.isAttributesEmpty) {
|
|
40
|
+
to.attributes = cloneDeep(from.attributes);
|
|
41
|
+
}
|
|
42
|
+
SourceMapElement.transfer(from, to);
|
|
43
|
+
StyleElement.transfer(from, to);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Visitor;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _ramda = require("ramda");
|
|
7
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
8
|
+
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
class AlternatingVisitor extends _SpecificationVisitor.default {
|
|
21
|
+
alternator;
|
|
22
|
+
constructor({
|
|
23
|
+
alternator,
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
super({
|
|
27
|
+
...rest
|
|
28
|
+
});
|
|
29
|
+
this.alternator = alternator || [];
|
|
30
|
+
}
|
|
31
|
+
enter(path) {
|
|
32
|
+
const element = path.node;
|
|
33
|
+
const functions = this.alternator.map(({
|
|
34
|
+
predicate,
|
|
35
|
+
specPath
|
|
36
|
+
}) => (0, _ramda.ifElse)(predicate, (0, _ramda.always)(specPath), _ramdaAdjunct.stubUndefined));
|
|
37
|
+
const specPath = (0, _ramdaAdjunct.dispatch)(functions)(element);
|
|
38
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
39
|
+
path.stop();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var _default = exports.default = AlternatingVisitor;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ifElse, always } from 'ramda';
|
|
2
|
+
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
3
|
+
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class AlternatingVisitor extends SpecificationVisitor {
|
|
14
|
+
alternator;
|
|
15
|
+
constructor({
|
|
16
|
+
alternator,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
super({
|
|
20
|
+
...rest
|
|
21
|
+
});
|
|
22
|
+
this.alternator = alternator || [];
|
|
23
|
+
}
|
|
24
|
+
enter(path) {
|
|
25
|
+
const element = path.node;
|
|
26
|
+
const functions = this.alternator.map(({
|
|
27
|
+
predicate,
|
|
28
|
+
specPath
|
|
29
|
+
}) => ifElse(predicate, always(specPath), stubUndefined));
|
|
30
|
+
const specPath = dispatch(functions)(element);
|
|
31
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
32
|
+
path.stop();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default AlternatingVisitor;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ifElse, always } from 'ramda';
|
|
2
|
+
import { dispatch, stubUndefined } from 'ramda-adjunct';
|
|
3
|
+
import { Element } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { Path } from '@speclynx/apidom-traverse';
|
|
5
|
+
|
|
6
|
+
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor.ts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type Alternator = { predicate: (element: unknown) => boolean; specPath: string[] };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface AlternatingVisitorOptions extends SpecificationVisitorOptions {
|
|
17
|
+
readonly alternator?: Alternator[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
class AlternatingVisitor extends SpecificationVisitor {
|
|
24
|
+
protected alternator: Alternator[];
|
|
25
|
+
|
|
26
|
+
constructor({ alternator, ...rest }: AlternatingVisitorOptions) {
|
|
27
|
+
super({ ...rest });
|
|
28
|
+
this.alternator = alternator || [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enter(path: Path<Element>) {
|
|
32
|
+
const element = path.node;
|
|
33
|
+
const functions = this.alternator.map(
|
|
34
|
+
({ predicate, specPath }: { predicate: (element: unknown) => boolean; specPath: string[] }) =>
|
|
35
|
+
ifElse(predicate, always(specPath), stubUndefined),
|
|
36
|
+
);
|
|
37
|
+
const specPath = dispatch(functions)(element);
|
|
38
|
+
|
|
39
|
+
this.element = this.toRefractedElement(specPath, element);
|
|
40
|
+
|
|
41
|
+
path.stop();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default AlternatingVisitor;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
7
|
+
var _apidomCore = require("@speclynx/apidom-core");
|
|
8
|
+
var _SpecificationVisitor = _interopRequireDefault(require("../SpecificationVisitor.cjs"));
|
|
9
|
+
var _predicates = require("../../predicates.cjs");
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
class FixedFieldsVisitor extends _SpecificationVisitor.default {
|
|
22
|
+
specPath;
|
|
23
|
+
ignoredFields;
|
|
24
|
+
canSupportSpecificationExtensions = true;
|
|
25
|
+
specificationExtensionPredicate = _predicates.isSwaggerExtension;
|
|
26
|
+
constructor({
|
|
27
|
+
specPath,
|
|
28
|
+
ignoredFields,
|
|
29
|
+
canSupportSpecificationExtensions,
|
|
30
|
+
specificationExtensionPredicate,
|
|
31
|
+
...rest
|
|
32
|
+
}) {
|
|
33
|
+
super({
|
|
34
|
+
...rest
|
|
35
|
+
});
|
|
36
|
+
this.specPath = specPath;
|
|
37
|
+
this.ignoredFields = ignoredFields || [];
|
|
38
|
+
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
39
|
+
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
40
|
+
}
|
|
41
|
+
if (typeof specificationExtensionPredicate === 'function') {
|
|
42
|
+
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
ObjectElement(path) {
|
|
46
|
+
const objectElement = path.node;
|
|
47
|
+
const specPath = this.specPath(objectElement);
|
|
48
|
+
const fields = this.retrieveFixedFields(specPath);
|
|
49
|
+
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
52
|
+
const keyValue = (0, _apidomCore.toValue)(key);
|
|
53
|
+
if ((0, _apidomDatamodel.isStringElement)(key) && fields.includes(keyValue) && !this.ignoredFields.includes(keyValue)) {
|
|
54
|
+
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', keyValue], value);
|
|
55
|
+
const newMemberElement = new _apidomDatamodel.MemberElement(this.consume ? key : (0, _apidomDatamodel.cloneDeep)(key), fixedFieldElement);
|
|
56
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
57
|
+
this.element.content.push(newMemberElement);
|
|
58
|
+
// consume: release processed generic subtree
|
|
59
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
60
|
+
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
61
|
+
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
62
|
+
this.element.content.push(extensionElement);
|
|
63
|
+
// consume: release processed generic subtree
|
|
64
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
65
|
+
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
66
|
+
this.element.content.push(this.consume ? memberElement : (0, _apidomDatamodel.cloneDeep)(memberElement));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
70
|
+
path.stop();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
var _default = exports.default = FixedFieldsVisitor;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isStringElement, MemberElement, cloneDeep } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
3
|
+
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
4
|
+
import { isSwaggerExtension } from "../../predicates.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class FixedFieldsVisitor extends SpecificationVisitor {
|
|
15
|
+
specPath;
|
|
16
|
+
ignoredFields;
|
|
17
|
+
canSupportSpecificationExtensions = true;
|
|
18
|
+
specificationExtensionPredicate = isSwaggerExtension;
|
|
19
|
+
constructor({
|
|
20
|
+
specPath,
|
|
21
|
+
ignoredFields,
|
|
22
|
+
canSupportSpecificationExtensions,
|
|
23
|
+
specificationExtensionPredicate,
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
super({
|
|
27
|
+
...rest
|
|
28
|
+
});
|
|
29
|
+
this.specPath = specPath;
|
|
30
|
+
this.ignoredFields = ignoredFields || [];
|
|
31
|
+
if (typeof canSupportSpecificationExtensions === 'boolean') {
|
|
32
|
+
this.canSupportSpecificationExtensions = canSupportSpecificationExtensions;
|
|
33
|
+
}
|
|
34
|
+
if (typeof specificationExtensionPredicate === 'function') {
|
|
35
|
+
this.specificationExtensionPredicate = specificationExtensionPredicate;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
ObjectElement(path) {
|
|
39
|
+
const objectElement = path.node;
|
|
40
|
+
const specPath = this.specPath(objectElement);
|
|
41
|
+
const fields = this.retrieveFixedFields(specPath);
|
|
42
|
+
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
objectElement.forEach((value, key, memberElement) => {
|
|
45
|
+
const keyValue = toValue(key);
|
|
46
|
+
if (isStringElement(key) && fields.includes(keyValue) && !this.ignoredFields.includes(keyValue)) {
|
|
47
|
+
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', keyValue], value);
|
|
48
|
+
const newMemberElement = new MemberElement(this.consume ? key : cloneDeep(key), fixedFieldElement);
|
|
49
|
+
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
50
|
+
this.element.content.push(newMemberElement);
|
|
51
|
+
// consume: release processed generic subtree
|
|
52
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
53
|
+
} else if (this.canSupportSpecificationExtensions && this.specificationExtensionPredicate(memberElement)) {
|
|
54
|
+
const extensionElement = this.toRefractedElement(['document', 'extension'], memberElement);
|
|
55
|
+
this.element.content.push(extensionElement);
|
|
56
|
+
// consume: release processed generic subtree
|
|
57
|
+
if (this.consume && this.consumeSafe && !memberElement.isFrozen) memberElement.value = undefined;
|
|
58
|
+
} else if (!this.ignoredFields.includes(keyValue)) {
|
|
59
|
+
this.element.content.push(this.consume ? memberElement : cloneDeep(memberElement));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.copyMetaAndAttributes(objectElement, this.element);
|
|
63
|
+
path.stop();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export default FixedFieldsVisitor;
|