@skmtc/core 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/context/CoreContext.js +22 -8
- package/esm/context/GenerateContext.d.ts +6 -5
- package/esm/context/GenerateContext.js +112 -38
- package/esm/context/ParseContext.d.ts +18 -1
- package/esm/context/ParseContext.js +102 -3
- package/esm/context/generateTypes.d.ts +33 -4
- package/esm/context/generateTypes.js +4 -0
- package/esm/context/toGenerationFailure.d.ts +21 -0
- package/esm/context/toGenerationFailure.js +38 -0
- package/esm/context/tryParseAt.d.ts +4 -1
- package/esm/context/tryParseAt.js +10 -3
- package/esm/dsl/CustomValue.d.ts +4 -0
- package/esm/dsl/CustomValue.js +8 -0
- package/esm/dsl/Definition.d.ts +10 -0
- package/esm/dsl/Definition.js +14 -0
- package/esm/dsl/PendingDefinition.d.ts +47 -0
- package/esm/dsl/PendingDefinition.js +83 -0
- package/esm/dsl/model/ModelDriver.d.ts +55 -1
- package/esm/dsl/model/ModelDriver.js +228 -51
- package/esm/dsl/model/toModelEntry.d.ts +1 -1
- package/esm/dsl/model/toModelEntry.js +1 -1
- package/esm/dsl/model/types.d.ts +1 -1
- package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/esm/dsl/webhook/WebhookDriver.js +1 -4
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
- package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/esm/enrichments/parseEnrichmentValue.js +32 -0
- package/esm/enrichments/readEnrichments.d.ts +5 -5
- package/esm/enrichments/readEnrichments.js +17 -7
- package/esm/helpers/collateExamples.js +15 -5
- package/esm/helpers/refFns.d.ts +6 -2
- package/esm/helpers/refFns.js +24 -7
- package/esm/mod.d.ts +2 -0
- package/esm/mod.js +2 -0
- package/esm/oas/array/Array.d.ts +19 -0
- package/esm/oas/array/Array.js +47 -0
- package/esm/oas/boolean/Boolean.d.ts +19 -0
- package/esm/oas/boolean/Boolean.js +51 -8
- package/esm/oas/example/Example.d.ts +4 -0
- package/esm/oas/example/Example.js +8 -0
- package/esm/oas/header/Header.d.ts +4 -0
- package/esm/oas/header/Header.js +8 -0
- package/esm/oas/integer/Integer.d.ts +19 -0
- package/esm/oas/integer/Integer.js +49 -0
- package/esm/oas/link/Link.d.ts +4 -0
- package/esm/oas/link/Link.js +8 -0
- package/esm/oas/number/Number.d.ts +19 -0
- package/esm/oas/number/Number.js +49 -0
- package/esm/oas/object/Object.d.ts +19 -0
- package/esm/oas/object/Object.js +68 -18
- package/esm/oas/operation/Operation.d.ts +8 -1
- package/esm/oas/operation/Operation.js +18 -5
- package/esm/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/esm/oas/operation/toEffectiveParameters.js +42 -0
- package/esm/oas/parameter/Parameter.d.ts +4 -0
- package/esm/oas/parameter/Parameter.js +8 -0
- package/esm/oas/ref/DanglingRefError.d.ts +22 -0
- package/esm/oas/ref/DanglingRefError.js +33 -0
- package/esm/oas/ref/Ref.d.ts +152 -25
- package/esm/oas/ref/Ref.js +414 -26
- package/esm/oas/requestBody/RequestBody.d.ts +4 -0
- package/esm/oas/requestBody/RequestBody.js +8 -0
- package/esm/oas/response/Response.d.ts +4 -0
- package/esm/oas/response/Response.js +8 -0
- package/esm/oas/schema/siblings.d.ts +127 -0
- package/esm/oas/schema/siblings.js +250 -0
- package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
- package/esm/oas/string/String.d.ts +19 -0
- package/esm/oas/string/String.js +47 -0
- package/esm/oas/union/Union.d.ts +32 -0
- package/esm/oas/union/Union.js +111 -0
- package/esm/oas/unknown/Unknown.d.ts +18 -0
- package/esm/oas/unknown/Unknown.js +38 -0
- package/esm/oas/void/Void.d.ts +4 -0
- package/esm/oas/void/Void.js +8 -0
- package/esm/oas/webhook/Webhook.d.ts +2 -2
- package/esm/oas/webhook/Webhook.js +4 -5
- package/esm/parse/allOfSystem.d.ts +32 -0
- package/esm/parse/allOfSystem.js +30 -0
- package/esm/parse/anyOfSystem.d.ts +68 -0
- package/esm/parse/anyOfSystem.js +107 -0
- package/esm/parse/securityRequirements.d.ts +6 -0
- package/esm/parse/securityRequirements.js +8 -0
- package/esm/parse/toSiblingKeywords.d.ts +28 -0
- package/esm/parse/toSiblingKeywords.js +109 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
- package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
- package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/esm/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-0/ref/toRefV31.js +6 -3
- package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-1/ref/toRefV31.js +6 -3
- package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-2/ref/toRefV31.js +6 -3
- package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/esm/types/OasBase.d.ts +1 -1
- package/esm/types/Settings.d.ts +44 -0
- package/esm/types/Settings.js +9 -0
- package/package.json +5 -1
- package/script/context/CoreContext.js +22 -8
- package/script/context/GenerateContext.d.ts +6 -5
- package/script/context/GenerateContext.js +112 -38
- package/script/context/ParseContext.d.ts +18 -1
- package/script/context/ParseContext.js +102 -3
- package/script/context/generateTypes.d.ts +33 -4
- package/script/context/generateTypes.js +4 -0
- package/script/context/toGenerationFailure.d.ts +21 -0
- package/script/context/toGenerationFailure.js +43 -0
- package/script/context/tryParseAt.d.ts +4 -1
- package/script/context/tryParseAt.js +10 -3
- package/script/dsl/CustomValue.d.ts +4 -0
- package/script/dsl/CustomValue.js +8 -0
- package/script/dsl/Definition.d.ts +10 -0
- package/script/dsl/Definition.js +14 -0
- package/script/dsl/PendingDefinition.d.ts +47 -0
- package/script/dsl/PendingDefinition.js +87 -0
- package/script/dsl/model/ModelDriver.d.ts +55 -1
- package/script/dsl/model/ModelDriver.js +231 -52
- package/script/dsl/model/toModelEntry.d.ts +1 -1
- package/script/dsl/model/toModelEntry.js +1 -1
- package/script/dsl/model/types.d.ts +1 -1
- package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/script/dsl/webhook/WebhookDriver.js +1 -4
- package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
- package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/script/enrichments/parseEnrichmentValue.js +69 -0
- package/script/enrichments/readEnrichments.d.ts +5 -5
- package/script/enrichments/readEnrichments.js +17 -40
- package/script/helpers/collateExamples.js +15 -5
- package/script/helpers/refFns.d.ts +6 -2
- package/script/helpers/refFns.js +24 -7
- package/script/mod.d.ts +2 -0
- package/script/mod.js +2 -0
- package/script/oas/array/Array.d.ts +19 -0
- package/script/oas/array/Array.js +47 -0
- package/script/oas/boolean/Boolean.d.ts +19 -0
- package/script/oas/boolean/Boolean.js +51 -8
- package/script/oas/example/Example.d.ts +4 -0
- package/script/oas/example/Example.js +8 -0
- package/script/oas/header/Header.d.ts +4 -0
- package/script/oas/header/Header.js +8 -0
- package/script/oas/integer/Integer.d.ts +19 -0
- package/script/oas/integer/Integer.js +49 -0
- package/script/oas/link/Link.d.ts +4 -0
- package/script/oas/link/Link.js +8 -0
- package/script/oas/number/Number.d.ts +19 -0
- package/script/oas/number/Number.js +49 -0
- package/script/oas/object/Object.d.ts +19 -0
- package/script/oas/object/Object.js +68 -18
- package/script/oas/operation/Operation.d.ts +8 -1
- package/script/oas/operation/Operation.js +18 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/script/oas/operation/toEffectiveParameters.js +47 -0
- package/script/oas/parameter/Parameter.d.ts +4 -0
- package/script/oas/parameter/Parameter.js +8 -0
- package/script/oas/ref/DanglingRefError.d.ts +22 -0
- package/script/oas/ref/DanglingRefError.js +37 -0
- package/script/oas/ref/Ref.d.ts +152 -25
- package/script/oas/ref/Ref.js +414 -26
- package/script/oas/requestBody/RequestBody.d.ts +4 -0
- package/script/oas/requestBody/RequestBody.js +8 -0
- package/script/oas/response/Response.d.ts +4 -0
- package/script/oas/response/Response.js +8 -0
- package/script/oas/schema/siblings.d.ts +127 -0
- package/script/oas/schema/siblings.js +305 -0
- package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/script/oas/securitySchemes/SecurityScheme.js +32 -0
- package/script/oas/string/String.d.ts +19 -0
- package/script/oas/string/String.js +47 -0
- package/script/oas/union/Union.d.ts +32 -0
- package/script/oas/union/Union.js +111 -0
- package/script/oas/unknown/Unknown.d.ts +18 -0
- package/script/oas/unknown/Unknown.js +38 -0
- package/script/oas/void/Void.d.ts +4 -0
- package/script/oas/void/Void.js +8 -0
- package/script/oas/webhook/Webhook.d.ts +2 -2
- package/script/oas/webhook/Webhook.js +4 -5
- package/script/parse/allOfSystem.d.ts +32 -0
- package/script/parse/allOfSystem.js +35 -0
- package/script/parse/anyOfSystem.d.ts +68 -0
- package/script/parse/anyOfSystem.js +116 -0
- package/script/parse/securityRequirements.d.ts +6 -0
- package/script/parse/securityRequirements.js +8 -0
- package/script/parse/toSiblingKeywords.d.ts +28 -0
- package/script/parse/toSiblingKeywords.js +146 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
- package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
- package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
- package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/script/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-0/ref/toRefV31.js +6 -3
- package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-1/ref/toRefV31.js +6 -3
- package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-2/ref/toRefV31.js +6 -3
- package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/script/types/OasBase.d.ts +1 -1
- package/script/types/Settings.d.ts +44 -0
- package/script/types/Settings.js +10 -1
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _CoreContext_instances, _CoreContext_phase, _CoreContext_results, _CoreContext_logLines, _CoreContext_phaseName, _CoreContext_parseIssues, _CoreContext_setupLogger, _CoreContext_toLogTrail, _CoreContext_closeFileHandlers, _CoreContext_toRunFailedIssue, _CoreContext_setupParsePhase, _CoreContext_setupGeneratePhase, _CoreContext_setupRenderPhase;
|
|
12
|
+
var _CoreContext_instances, _CoreContext_phase, _CoreContext_results, _CoreContext_logLines, _CoreContext_phaseName, _CoreContext_parseIssues, _CoreContext_enrichmentWarnings, _CoreContext_setupLogger, _CoreContext_toLogTrail, _CoreContext_closeFileHandlers, _CoreContext_toRunFailedIssue, _CoreContext_setupParsePhase, _CoreContext_setupGeneratePhase, _CoreContext_setupRenderPhase;
|
|
13
13
|
import { GenerateContext } from './GenerateContext.js';
|
|
14
14
|
import { toInspection } from '../run/toInspection.js';
|
|
15
15
|
import { RenderContext } from './RenderContext.js';
|
|
@@ -22,6 +22,7 @@ import { ResultsLog } from '../helpers/ResultsLog.js';
|
|
|
22
22
|
import { join } from '../deps/jsr.io/@std/path/1.1.6/join.js';
|
|
23
23
|
import { bold, gray, red, yellow, blue } from '../deps/jsr.io/@std/fmt/1.0.10/colors.js';
|
|
24
24
|
import { toSerializedError } from '../types/SerializedError.js';
|
|
25
|
+
import { GenerationFailure } from './toGenerationFailure.js';
|
|
25
26
|
/**
|
|
26
27
|
* The main orchestration class for the SKMTC transformation pipeline.
|
|
27
28
|
*
|
|
@@ -130,6 +131,16 @@ export class CoreContext {
|
|
|
130
131
|
* render phases replace `#phase`, so a later failure still returns them.
|
|
131
132
|
*/
|
|
132
133
|
_CoreContext_parseIssues.set(this, []
|
|
134
|
+
/**
|
|
135
|
+
* The enrichment warnings of this run, kept so a failure in generate or
|
|
136
|
+
* render still returns them: a misaddressed enrichment is often the cause.
|
|
137
|
+
*/
|
|
138
|
+
);
|
|
139
|
+
/**
|
|
140
|
+
* The enrichment warnings of this run, kept so a failure in generate or
|
|
141
|
+
* render still returns them: a misaddressed enrichment is often the cause.
|
|
142
|
+
*/
|
|
143
|
+
_CoreContext_enrichmentWarnings.set(this, []
|
|
133
144
|
/**
|
|
134
145
|
* Creates a new CoreContext instance.
|
|
135
146
|
*
|
|
@@ -284,7 +295,8 @@ export class CoreContext {
|
|
|
284
295
|
// A throw while the parse context is set up counts as parse.
|
|
285
296
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'parse', "f");
|
|
286
297
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, [], "f");
|
|
287
|
-
|
|
298
|
+
__classPrivateFieldSet(this, _CoreContext_enrichmentWarnings, [], "f");
|
|
299
|
+
const phase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, document, settings);
|
|
288
300
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
289
301
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
290
302
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
@@ -303,6 +315,7 @@ export class CoreContext {
|
|
|
303
315
|
});
|
|
304
316
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
305
317
|
const generated = generatePhase.context.toArtifacts(st);
|
|
318
|
+
__classPrivateFieldSet(this, _CoreContext_enrichmentWarnings, generated.enrichmentWarnings, "f");
|
|
306
319
|
// Opt-in snapshot of the live files graph, taken after generate populates
|
|
307
320
|
// it and before render replaces the phase. Off unless `inspect` is set.
|
|
308
321
|
return {
|
|
@@ -358,7 +371,7 @@ export class CoreContext {
|
|
|
358
371
|
previews: {},
|
|
359
372
|
results: __classPrivateFieldGet(this, _CoreContext_results, "f").toTree(),
|
|
360
373
|
parseIssues: [...priorIssues, fatalIssue],
|
|
361
|
-
enrichmentWarnings:
|
|
374
|
+
enrichmentWarnings: error instanceof GenerationFailure ? error.enrichmentWarnings : __classPrivateFieldGet(this, _CoreContext_enrichmentWarnings, "f"),
|
|
362
375
|
logs: [...__classPrivateFieldGet(this, _CoreContext_logLines, "f").lines]
|
|
363
376
|
};
|
|
364
377
|
}
|
|
@@ -375,7 +388,7 @@ export class CoreContext {
|
|
|
375
388
|
try {
|
|
376
389
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'parse', "f");
|
|
377
390
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, [], "f");
|
|
378
|
-
const phase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, document);
|
|
391
|
+
const phase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, document, settings);
|
|
379
392
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
380
393
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
381
394
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
@@ -421,7 +434,7 @@ export class CoreContext {
|
|
|
421
434
|
try {
|
|
422
435
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'parse', "f");
|
|
423
436
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, [], "f");
|
|
424
|
-
const phase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, document);
|
|
437
|
+
const phase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, document, settings);
|
|
425
438
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
426
439
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
427
440
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
@@ -474,7 +487,7 @@ export class CoreContext {
|
|
|
474
487
|
__classPrivateFieldGet(this, _CoreContext_results, "f").capture(stackTrail, result);
|
|
475
488
|
}
|
|
476
489
|
}
|
|
477
|
-
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_logLines = new WeakMap(), _CoreContext_phaseName = new WeakMap(), _CoreContext_parseIssues = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger({ spanId, logsPath, logLines }) {
|
|
490
|
+
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_logLines = new WeakMap(), _CoreContext_phaseName = new WeakMap(), _CoreContext_parseIssues = new WeakMap(), _CoreContext_enrichmentWarnings = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger({ spanId, logsPath, logLines }) {
|
|
478
491
|
const fileHandlers = logsPath
|
|
479
492
|
? [
|
|
480
493
|
new log.FileHandler('DEBUG', {
|
|
@@ -522,11 +535,12 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
522
535
|
throw new Error(`Unhandled protocol type: ${JSON.stringify(_exhaustive)}`);
|
|
523
536
|
}
|
|
524
537
|
}
|
|
525
|
-
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(input) {
|
|
538
|
+
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(input, settings) {
|
|
526
539
|
const parseContext = new ParseContext({
|
|
527
540
|
input,
|
|
528
541
|
logger: this.logger,
|
|
529
|
-
silent: this.silent
|
|
542
|
+
silent: this.silent,
|
|
543
|
+
system: settings?.system
|
|
530
544
|
});
|
|
531
545
|
return { type: 'parse', context: parseContext };
|
|
532
546
|
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ document, settings, toGeneratorConfigMap, captureChannel }) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DefinitionBase } from '../dsl/Definition.js';
|
|
2
|
+
import type { PendingDefinition } from '../dsl/PendingDefinition.js';
|
|
2
3
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
3
4
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
4
5
|
import type { SkmtcParsedDocument } from '../types/SkmtcDocument.js';
|
|
@@ -6,7 +7,7 @@ import type { SupportedSubjects } from '../types/SupportedSubjects.js';
|
|
|
6
7
|
import type { EnrichmentDefaults } from '../types/EnrichmentDefaults.js';
|
|
7
8
|
import type { BuildModelSettingsArgs, GenerateContextType, GenerateResult, InsertModelOptions, InsertNormalizedModelArgs, InsertNormalizedModelOptions, InsertNormalizedModelReturn, InsertOperationArgs, InsertWebhookArgs, FindDefinitionArgs, ContextRegisterArgs, RegisterJsonArgs, RegisterMarkdownArgs, ToOperationSettingsArgs, ToWebhookSettingsArgs } from './generateTypes.js';
|
|
8
9
|
import type { ClientSettings } from '../types/Settings.js';
|
|
9
|
-
import type
|
|
10
|
+
import { type Method } from '../types/Method.js';
|
|
10
11
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
11
12
|
import type { OasWebhook } from '../oas/webhook/Webhook.js';
|
|
12
13
|
import { type ProjectionOptionsRest } from '../types/ProjectionOptions.js';
|
|
@@ -149,8 +150,8 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
149
150
|
captureCurrentResult: (result: ResultType, stackTrail: StackTrail) => void;
|
|
150
151
|
/** Function that returns the generator configuration map */
|
|
151
152
|
toGeneratorConfigMap: <EnrichmentType = undefined>() => GeneratorsMapContainer<EnrichmentType>;
|
|
152
|
-
/**
|
|
153
|
-
|
|
153
|
+
/** The pending models, outermost first: the last is the model whose projection constructor is running. */
|
|
154
|
+
pendingStack: PendingDefinition[];
|
|
154
155
|
constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel }: ConstructorArgs);
|
|
155
156
|
/**
|
|
156
157
|
* The recording enrichment accessor — the single choke point every
|
|
@@ -327,9 +328,9 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
327
328
|
* Perform one lookup of schema by `refName`.
|
|
328
329
|
* @param refName
|
|
329
330
|
* @returns Matching schema or ref
|
|
330
|
-
* @throws
|
|
331
|
+
* @throws {DanglingRefError} when no schema has that name
|
|
331
332
|
*/
|
|
332
|
-
resolveSchemaRefOnce(refName: RefName
|
|
333
|
+
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
333
334
|
/**
|
|
334
335
|
* Check if definition name `name` in file with path `exportPath`
|
|
335
336
|
* has already been created and registered.
|
|
@@ -9,9 +9,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runOasOperationGenerator, _GenerateContext_runWebhookGenerator, _GenerateContext_runGqlOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
12
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedItems, _GenerateContext_foldedPaths, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runOasOperationGenerator, _GenerateContext_runWebhookGenerator, _GenerateContext_runGqlOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
13
13
|
import { normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
14
14
|
import { applyGeneratedSuffix, DEFAULT_GENERATED_SUFFIX } from '../helpers/applyGeneratedSuffix.js';
|
|
15
|
+
import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
16
|
+
import { isMethod } from '../types/Method.js';
|
|
15
17
|
import { OasOperationDriver } from '../dsl/operation/oas/OasOperationDriver.js';
|
|
16
18
|
import { WebhookDriver } from '../dsl/webhook/WebhookDriver.js';
|
|
17
19
|
import { GqlOperationDriver } from '../dsl/operation/gql/GqlOperationDriver.js';
|
|
@@ -30,6 +32,7 @@ import { MarkdownFile } from '../dsl/MarkdownFile.js';
|
|
|
30
32
|
import invariant from 'tiny-invariant';
|
|
31
33
|
import { EnrichmentAudit, hasVariantEnrichment } from '../enrichments/EnrichmentAudit.js';
|
|
32
34
|
import { toSerializedError } from '../types/SerializedError.js';
|
|
35
|
+
import { GenerationFailure } from './toGenerationFailure.js';
|
|
33
36
|
import { formatEnrichmentPath } from '../enrichments/EnrichmentWarning.js';
|
|
34
37
|
/**
|
|
35
38
|
* The generation context for the second phase of the SKMTC transformation pipeline.
|
|
@@ -83,6 +86,12 @@ export class GenerateContext {
|
|
|
83
86
|
constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel }) {
|
|
84
87
|
_GenerateContext_instances.add(this);
|
|
85
88
|
_GenerateContext_files.set(this, void 0);
|
|
89
|
+
/** Each subject whose generation threw: its trail and the error message. */
|
|
90
|
+
_GenerateContext_failedItems.set(this, []
|
|
91
|
+
/** Each file's path folded (case, Unicode form) → the path: a file system that ignores case sees one file. */
|
|
92
|
+
);
|
|
93
|
+
/** Each file's path folded (case, Unicode form) → the path: a file system that ignores case sees one file. */
|
|
94
|
+
_GenerateContext_foldedPaths.set(this, new Map());
|
|
86
95
|
_GenerateContext_previews.set(this, void 0);
|
|
87
96
|
/**
|
|
88
97
|
* Parsed source document, wrapped in the {@link SkmtcParsedDocument}
|
|
@@ -123,12 +132,12 @@ export class GenerateContext {
|
|
|
123
132
|
writable: true,
|
|
124
133
|
value: void 0
|
|
125
134
|
});
|
|
126
|
-
/**
|
|
127
|
-
Object.defineProperty(this, "
|
|
135
|
+
/** The pending models, outermost first: the last is the model whose projection constructor is running. */
|
|
136
|
+
Object.defineProperty(this, "pendingStack", {
|
|
128
137
|
enumerable: true,
|
|
129
138
|
configurable: true,
|
|
130
139
|
writable: true,
|
|
131
|
-
value:
|
|
140
|
+
value: []
|
|
132
141
|
});
|
|
133
142
|
/**
|
|
134
143
|
* Creates a new GenerateContext instance for the generation phase.
|
|
@@ -152,7 +161,6 @@ export class GenerateContext {
|
|
|
152
161
|
this.settings = settings;
|
|
153
162
|
this.captureCurrentResult = captureCurrentResult;
|
|
154
163
|
this.toGeneratorConfigMap = toGeneratorConfigMap;
|
|
155
|
-
this.modelDepth = {};
|
|
156
164
|
__classPrivateFieldSet(this, _GenerateContext_captureChannel, captureChannel, "f");
|
|
157
165
|
__classPrivateFieldSet(this, _GenerateContext_enrichmentAudit, new EnrichmentAudit(), "f");
|
|
158
166
|
}
|
|
@@ -228,18 +236,15 @@ export class GenerateContext {
|
|
|
228
236
|
// extracted below is applied per-operation in the run* arms.
|
|
229
237
|
// (Whole-generator opt-out is `skip`. A bare-string `include`
|
|
230
238
|
// entry carries no per-operation filter and is a no-op.)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
239
|
+
// skmtc#330: every object entry for this generator, merged, not only the first one.
|
|
240
|
+
const skip = toGeneratorFilter(this.settings?.skip, generatorConfig.id);
|
|
234
241
|
// Extract the per-generator include slice (if any). Same
|
|
235
242
|
// dispatch shape as skip: object entries get matched by key,
|
|
236
243
|
// string entries don't produce a per-op filter (they mean
|
|
237
244
|
// "everything from this generator is included", which is
|
|
238
245
|
// semantically equivalent to "no per-op filter" once the
|
|
239
246
|
// whole-generator gate above has admitted us).
|
|
240
|
-
const include = this.settings?.include
|
|
241
|
-
return typeof entry === 'object' && Boolean(entry[generatorConfig.id]);
|
|
242
|
-
});
|
|
247
|
+
const include = toGeneratorFilter(this.settings?.include, generatorConfig.id);
|
|
243
248
|
switch (generatorConfig.type) {
|
|
244
249
|
case 'oasOperation':
|
|
245
250
|
if (this.document.type !== 'oas') {
|
|
@@ -289,6 +294,13 @@ export class GenerateContext {
|
|
|
289
294
|
generators: generators.map(({ id, type }) => ({ id, type })),
|
|
290
295
|
skippedGeneratorIds: (this.settings?.skip ?? []).filter((entry) => typeof entry === 'string')
|
|
291
296
|
});
|
|
297
|
+
// Generation runs our code over a document parsing has already made
|
|
298
|
+
// safe, so an error here is a bug to fix, not data to tolerate: the run
|
|
299
|
+
// fails, and writes nothing. Every subject that failed is in the log
|
|
300
|
+
// and in the results.
|
|
301
|
+
if (__classPrivateFieldGet(this, _GenerateContext_failedItems, "f").length > 0) {
|
|
302
|
+
throw new GenerationFailure(__classPrivateFieldGet(this, _GenerateContext_failedItems, "f"), enrichmentWarnings);
|
|
303
|
+
}
|
|
292
304
|
return {
|
|
293
305
|
files: __classPrivateFieldGet(this, _GenerateContext_files, "f"),
|
|
294
306
|
previews: __classPrivateFieldGet(this, _GenerateContext_previews, "f"),
|
|
@@ -496,7 +508,16 @@ export class GenerateContext {
|
|
|
496
508
|
if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalizedPath)) {
|
|
497
509
|
throw new Error(`File already exists: ${normalizedPath}`);
|
|
498
510
|
}
|
|
511
|
+
// Two paths that differ only in case are one file on a file system that
|
|
512
|
+
// ignores case, as macOS's and Windows' do by default: writing the
|
|
513
|
+
// second would replace the first without a word.
|
|
514
|
+
const foldedPath = normalizedPath.normalize('NFD').toLowerCase();
|
|
515
|
+
const existingPath = __classPrivateFieldGet(this, _GenerateContext_foldedPaths, "f").get(foldedPath);
|
|
516
|
+
if (existingPath !== undefined) {
|
|
517
|
+
throw new Error(`File '${normalizedPath}' differs from '${existingPath}' only in case. On a file system that ignores case, as macOS's and Windows' do by default, they are one file.`);
|
|
518
|
+
}
|
|
499
519
|
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalizedPath, file);
|
|
520
|
+
__classPrivateFieldGet(this, _GenerateContext_foldedPaths, "f").set(foldedPath, normalizedPath);
|
|
500
521
|
return file;
|
|
501
522
|
}
|
|
502
523
|
/**
|
|
@@ -634,10 +655,7 @@ export class GenerateContext {
|
|
|
634
655
|
// @TODO Using mapped types would help avoid generics casting
|
|
635
656
|
return definition;
|
|
636
657
|
}
|
|
637
|
-
const cachedDefinition = this.findDefinition({
|
|
638
|
-
name: fallbackName,
|
|
639
|
-
exportPath: destinationPath
|
|
640
|
-
});
|
|
658
|
+
const cachedDefinition = this.findDefinition({ name: fallbackName, exportPath: destinationPath });
|
|
641
659
|
// @TODO add check to make sure retrieved definition
|
|
642
660
|
// used same generator and same schema #SKM-47
|
|
643
661
|
if (cachedDefinition) {
|
|
@@ -813,22 +831,36 @@ export class GenerateContext {
|
|
|
813
831
|
* Perform one lookup of schema by `refName`.
|
|
814
832
|
* @param refName
|
|
815
833
|
* @returns Matching schema or ref
|
|
816
|
-
* @throws
|
|
834
|
+
* @throws {DanglingRefError} when no schema has that name
|
|
817
835
|
*/
|
|
818
|
-
resolveSchemaRefOnce(refName
|
|
819
|
-
this.
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
836
|
+
resolveSchemaRefOnce(refName) {
|
|
837
|
+
switch (this.document.type) {
|
|
838
|
+
case 'oas': {
|
|
839
|
+
const component = this.document.value.components?.schemas?.[refName];
|
|
840
|
+
if (!component) {
|
|
841
|
+
throw new DanglingRefError(refName);
|
|
842
|
+
}
|
|
843
|
+
const target = component.resolveOnce();
|
|
844
|
+
// One step, with what the component adds next to its reference
|
|
845
|
+
// (`{ allOf: [{ $ref: Name }], maxLength: 10, nullable: true }`)
|
|
846
|
+
// applied to a copy: the model is the target at this site. When the
|
|
847
|
+
// step is itself a reference, the copy is a reference, and the
|
|
848
|
+
// model's router decides whether it renders inline or by name.
|
|
849
|
+
return component.isRef() && component.hasSiblings() ? target.clone(component) : target;
|
|
850
|
+
}
|
|
851
|
+
case 'gql': {
|
|
852
|
+
const schema = this.document.value.registry.schemas[refName];
|
|
853
|
+
if (!schema) {
|
|
854
|
+
throw new DanglingRefError(refName);
|
|
855
|
+
}
|
|
856
|
+
// GqlRegistry stores OasSchema | OasRef entries: one step, as for OAS.
|
|
857
|
+
return schema.resolveOnce();
|
|
858
|
+
}
|
|
859
|
+
default: {
|
|
860
|
+
const _exhaustive = this.document;
|
|
861
|
+
throw new Error(`Unhandled document type: ${JSON.stringify(_exhaustive)}`);
|
|
862
|
+
}
|
|
830
863
|
}
|
|
831
|
-
return schema;
|
|
832
864
|
}
|
|
833
865
|
/**
|
|
834
866
|
* Check if definition name `name` in file with path `exportPath`
|
|
@@ -853,7 +885,7 @@ export class GenerateContext {
|
|
|
853
885
|
return place?.findDefinitions({ name })?.[0];
|
|
854
886
|
}
|
|
855
887
|
}
|
|
856
|
-
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
888
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
857
889
|
if (!hasVariantEnrichment(block, variant))
|
|
858
890
|
return;
|
|
859
891
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").report({
|
|
@@ -865,6 +897,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
865
897
|
});
|
|
866
898
|
}, _GenerateContext_logError = function _GenerateContext_logError(error) {
|
|
867
899
|
this.logger.error(toSerializedError(error).message, error);
|
|
900
|
+
}, _GenerateContext_failItem = function _GenerateContext_failItem(error, stackTrail) {
|
|
901
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
902
|
+
this.captureCurrentResult('error', stackTrail);
|
|
903
|
+
__classPrivateFieldGet(this, _GenerateContext_failedItems, "f").push({ trail: `${stackTrail}`, message: toSerializedError(error).message });
|
|
868
904
|
}, _GenerateContext_schemaRefNames = function _GenerateContext_schemaRefNames() {
|
|
869
905
|
switch (this.document.type) {
|
|
870
906
|
case 'oas':
|
|
@@ -971,8 +1007,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
971
1007
|
this.captureCurrentResult('success', st);
|
|
972
1008
|
}
|
|
973
1009
|
catch (error) {
|
|
974
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
975
|
-
this.captureCurrentResult('error', st);
|
|
1010
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
976
1011
|
}
|
|
977
1012
|
}));
|
|
978
1013
|
});
|
|
@@ -1052,8 +1087,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1052
1087
|
this.captureCurrentResult('success', st);
|
|
1053
1088
|
}
|
|
1054
1089
|
catch (error) {
|
|
1055
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
1056
|
-
this.captureCurrentResult('error', st);
|
|
1090
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
1057
1091
|
}
|
|
1058
1092
|
}));
|
|
1059
1093
|
});
|
|
@@ -1096,8 +1130,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1096
1130
|
this.captureCurrentResult('success', st);
|
|
1097
1131
|
}
|
|
1098
1132
|
catch (error) {
|
|
1099
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
1100
|
-
this.captureCurrentResult('error', st);
|
|
1133
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
1101
1134
|
}
|
|
1102
1135
|
}));
|
|
1103
1136
|
});
|
|
@@ -1171,8 +1204,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1171
1204
|
this.captureCurrentResult('success', st);
|
|
1172
1205
|
}
|
|
1173
1206
|
catch (error) {
|
|
1174
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
1175
|
-
this.captureCurrentResult('error', st);
|
|
1207
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
1176
1208
|
}
|
|
1177
1209
|
}));
|
|
1178
1210
|
});
|
|
@@ -1330,6 +1362,48 @@ export const toModelSource = ({ refName, generatorId, variant }) => ({
|
|
|
1330
1362
|
refName,
|
|
1331
1363
|
variant
|
|
1332
1364
|
});
|
|
1365
|
+
/** Variants of one subject. `[]` is every variant, so it wins a merge. */
|
|
1366
|
+
const mergeVariants = (a, b) => a.length === 0 || b.length === 0 ? [] : [...new Set([...a, ...b])];
|
|
1367
|
+
/** Whether a filter is operation-shaped: its values are records of methods, not lists of variants. */
|
|
1368
|
+
const isPathsFilter = (filter) => Object.values(filter).every(value => !Array.isArray(value));
|
|
1369
|
+
const mergePathsFilters = (a, b) => Object.entries(b).reduce((merged, [path, methods]) => {
|
|
1370
|
+
const existing = merged[path] ?? {};
|
|
1371
|
+
const combined = Object.entries(methods).reduce((acc, [method, variants]) => {
|
|
1372
|
+
if (!isMethod(method) || variants === undefined) {
|
|
1373
|
+
return acc;
|
|
1374
|
+
}
|
|
1375
|
+
const current = acc[method];
|
|
1376
|
+
return { ...acc, [method]: current === undefined ? variants : mergeVariants(current, variants) };
|
|
1377
|
+
}, { ...existing });
|
|
1378
|
+
return { ...merged, [path]: combined };
|
|
1379
|
+
}, { ...a });
|
|
1380
|
+
const mergeModelsFilters = (a, b) => Object.entries(b).reduce((merged, [refName, variants]) => {
|
|
1381
|
+
const current = merged[refName];
|
|
1382
|
+
return { ...merged, [refName]: current === undefined ? variants : mergeVariants(current, variants) };
|
|
1383
|
+
}, { ...a });
|
|
1384
|
+
/** Two filters of one generator, merged. Filters of two shapes cannot merge: the first stays. */
|
|
1385
|
+
const mergeFilters = (a, b) => {
|
|
1386
|
+
if (isPathsFilter(a) && isPathsFilter(b)) {
|
|
1387
|
+
return mergePathsFilters(a, b);
|
|
1388
|
+
}
|
|
1389
|
+
if (!isPathsFilter(a) && !isPathsFilter(b)) {
|
|
1390
|
+
return mergeModelsFilters(a, b);
|
|
1391
|
+
}
|
|
1392
|
+
return a;
|
|
1393
|
+
};
|
|
1394
|
+
/**
|
|
1395
|
+
* The `skip` or `include` filter of one generator: every object entry that
|
|
1396
|
+
* names it, merged (skmtc#330). Before, only the first entry applied, and a
|
|
1397
|
+
* later one was ignored with no warning. `undefined` when no entry names it.
|
|
1398
|
+
*/
|
|
1399
|
+
const toGeneratorFilter = (entries, generatorId) => {
|
|
1400
|
+
const filters = (entries ?? []).flatMap(entry => {
|
|
1401
|
+
const filter = typeof entry === 'object' ? entry[generatorId] : undefined;
|
|
1402
|
+
return filter === undefined ? [] : [filter];
|
|
1403
|
+
});
|
|
1404
|
+
const [first, ...rest] = filters;
|
|
1405
|
+
return first === undefined ? undefined : { [generatorId]: rest.reduce(mergeFilters, first) };
|
|
1406
|
+
};
|
|
1333
1407
|
const toSkipPaths = (skip, generatorId) => {
|
|
1334
1408
|
const generatorSkip = skip?.[generatorId];
|
|
1335
1409
|
// Operation-shaped entries have records-of-records at the inner
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import "../_dnt.polyfills.js";
|
|
19
19
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
20
20
|
import { type GraphQLSchema } from 'graphql';
|
|
21
|
+
import type { SystemSettings } from '../types/Settings.js';
|
|
21
22
|
import { OasDocument } from '../oas/document/Document.js';
|
|
22
23
|
import { GqlRegistry } from '../gql/registry/GqlRegistry.js';
|
|
23
24
|
import { GqlDocument } from '../gql/document/GqlDocument.js';
|
|
@@ -27,6 +28,8 @@ import { StackTrail } from './StackTrail.js';
|
|
|
27
28
|
import type { SkmtcDocumentInput, SkmtcParsedDocument } from '../types/SkmtcDocument.js';
|
|
28
29
|
import type { GqlParseOptions, LogAtArgs, LogIssueArgs, LogIssueAtArgs, LogIssueNoKeyArgs, LogSkippedValuesArgs } from './parseTypes.js';
|
|
29
30
|
import type { ParseIssue } from './ParseIssue.js';
|
|
31
|
+
import type { OasRef } from '../oas/ref/Ref.js';
|
|
32
|
+
import type { OasRefData } from '../oas/ref/ref-types.js';
|
|
30
33
|
export type { ParseIssue, GqlIssueType } from './ParseIssue.js';
|
|
31
34
|
export type { GqlParseOptions, LogAtArgs, LogIssueArgs, LogIssueAtArgs, LogIssueNoKeyArgs, LogSkippedValuesArgs, ParseContextType, ParseErrorInput, ParseIssueInput, ParseWarningInput } from './parseTypes.js';
|
|
32
35
|
type OasProtocolState = {
|
|
@@ -61,6 +64,8 @@ type ConstructorArgs = {
|
|
|
61
64
|
options?: {
|
|
62
65
|
gql?: GqlParseOptions;
|
|
63
66
|
};
|
|
67
|
+
/** `client.json#settings.system`: how the OpenAPI parsers treat what they cannot read faithfully. */
|
|
68
|
+
system?: SystemSettings;
|
|
64
69
|
};
|
|
65
70
|
export declare class ParseContext {
|
|
66
71
|
#private;
|
|
@@ -75,7 +80,12 @@ export declare class ParseContext {
|
|
|
75
80
|
* `undefined` outside an active `withStackTrail` scope.
|
|
76
81
|
*/
|
|
77
82
|
currentStackTrail: StackTrail | undefined;
|
|
78
|
-
|
|
83
|
+
/**
|
|
84
|
+
* How the OpenAPI parsers treat what they cannot read faithfully
|
|
85
|
+
* (`client.json#settings.system`). Each setting left out is `strict`.
|
|
86
|
+
*/
|
|
87
|
+
system: SystemSettings;
|
|
88
|
+
constructor({ input, logger, silent, options, system }: ConstructorArgs);
|
|
79
89
|
/**
|
|
80
90
|
* OAS-only accessor. Throws when called on a GQL-protocol context —
|
|
81
91
|
* deliberate, because OAS parser code uses this and a misroute is a
|
|
@@ -149,6 +159,13 @@ export declare class ParseContext {
|
|
|
149
159
|
* would use type names or qualified field paths.
|
|
150
160
|
*/
|
|
151
161
|
registerRef(consumer: StackTrail, refKey: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Register an OAS `$ref` at its consumer site, as {@link registerRef}
|
|
164
|
+
* does, under the key {@link toRefKey} gives its `$ref`, and keep the ref
|
|
165
|
+
* with that site, so that once the document is parsed `#checkRefs` can
|
|
166
|
+
* resolve it there.
|
|
167
|
+
*/
|
|
168
|
+
registerOasRef<T extends OasRefData['refType']>(consumer: StackTrail, ref: OasRef<T>): void;
|
|
152
169
|
/**
|
|
153
170
|
* Register an error against a ref key — typically called when the
|
|
154
171
|
* target of a `$ref` (or type reference) fails to parse. `undefined`
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_toRawComponentParameter, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail;
|
|
12
|
+
var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_toRawComponentParameter, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_logDanglingRef;
|
|
13
13
|
/**
|
|
14
14
|
* Unified parse context for both OAS and GraphQL inputs.
|
|
15
15
|
*
|
|
@@ -41,6 +41,20 @@ import { StackTrail } from './StackTrail.js';
|
|
|
41
41
|
import { isPlainObject } from '../parse/isPlainObject.js';
|
|
42
42
|
import { toApplyingBrokenParameter, toNameAndIn } from '../parse/pathParameters.js';
|
|
43
43
|
import { toSerializedError } from '../types/SerializedError.js';
|
|
44
|
+
import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
45
|
+
import { toRefName } from '../helpers/refFns.js';
|
|
46
|
+
/**
|
|
47
|
+
* The key a `$ref`'s consumers and errors are kept under. A
|
|
48
|
+
* `#/components/<bucket>/…` ref is keyed by the name it resolves (`toRefName`
|
|
49
|
+
* unescapes it), which is the key `StackTrail.toStackRef()` gives that
|
|
50
|
+
* component's own errors: `#/components/schemas/Foo%20Bar` is kept under
|
|
51
|
+
* `#/components/schemas/Foo Bar`. Any other `$ref` is its own key.
|
|
52
|
+
*/
|
|
53
|
+
const toRefKey = ($ref) => {
|
|
54
|
+
// The last segment is not empty, so `toRefName` does not throw.
|
|
55
|
+
const bucket = /^#\/components\/([^/]+)\/.*[^/]$/.exec($ref)?.[1];
|
|
56
|
+
return bucket === undefined ? $ref : `#/components/${bucket}/${toRefName($ref)}`;
|
|
57
|
+
};
|
|
44
58
|
/** The stored form of an issue: an error's `cause` as a `SerializedError`. */
|
|
45
59
|
const toParseIssue = (issue) => {
|
|
46
60
|
if (issue.level !== 'error') {
|
|
@@ -60,7 +74,7 @@ const toParseIssue = (issue) => {
|
|
|
60
74
|
}
|
|
61
75
|
};
|
|
62
76
|
export class ParseContext {
|
|
63
|
-
constructor({ input, logger, silent = true, options }) {
|
|
77
|
+
constructor({ input, logger, silent = true, options, system }) {
|
|
64
78
|
_ParseContext_instances.add(this);
|
|
65
79
|
Object.defineProperty(this, "issues", {
|
|
66
80
|
enumerable: true,
|
|
@@ -98,11 +112,25 @@ export class ParseContext {
|
|
|
98
112
|
writable: true,
|
|
99
113
|
value: void 0
|
|
100
114
|
});
|
|
115
|
+
/**
|
|
116
|
+
* How the OpenAPI parsers treat what they cannot read faithfully
|
|
117
|
+
* (`client.json#settings.system`). Each setting left out is `strict`.
|
|
118
|
+
*/
|
|
119
|
+
Object.defineProperty(this, "system", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
configurable: true,
|
|
122
|
+
writable: true,
|
|
123
|
+
value: void 0
|
|
124
|
+
});
|
|
101
125
|
// Universal dependency-ref tracking. Populated by parsers as they
|
|
102
126
|
// encounter references. OAS uses `$ref` strings as keys; GQL would
|
|
103
127
|
// use type names. The maps don't care about the encoding.
|
|
104
128
|
_ParseContext_refConsumers.set(this, new Map());
|
|
105
129
|
_ParseContext_refErrors.set(this, new Map()
|
|
130
|
+
/** Each OAS ref and the place it is written, which `#checkRefs` resolves once the document is parsed. */
|
|
131
|
+
);
|
|
132
|
+
/** Each OAS ref and the place it is written, which `#checkRefs` resolves once the document is parsed. */
|
|
133
|
+
_ParseContext_oasRefs.set(this, []
|
|
106
134
|
/**
|
|
107
135
|
* Frames of the trail `parse()` was called with (`[traceId, spanId,
|
|
108
136
|
* 'parse']` through `toArtifacts`). Every trail built during the walk
|
|
@@ -117,6 +145,7 @@ export class ParseContext {
|
|
|
117
145
|
_ParseContext_rootFrames.set(this, []);
|
|
118
146
|
this.logger = logger;
|
|
119
147
|
this.silent = silent;
|
|
148
|
+
this.system = system ?? {};
|
|
120
149
|
switch (input.type) {
|
|
121
150
|
case 'oas': {
|
|
122
151
|
this.protocol = {
|
|
@@ -251,6 +280,7 @@ export class ParseContext {
|
|
|
251
280
|
throw new Error(`Unhandled OAS dialect: ${JSON.stringify(_exhaustive)}`);
|
|
252
281
|
}
|
|
253
282
|
}
|
|
283
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_checkRefs).call(this);
|
|
254
284
|
this.removeErroredItems();
|
|
255
285
|
return { type: 'oas', value: oasState.oasDocument };
|
|
256
286
|
}
|
|
@@ -350,6 +380,16 @@ export class ParseContext {
|
|
|
350
380
|
__classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [consumer]);
|
|
351
381
|
}
|
|
352
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Register an OAS `$ref` at its consumer site, as {@link registerRef}
|
|
385
|
+
* does, under the key {@link toRefKey} gives its `$ref`, and keep the ref
|
|
386
|
+
* with that site, so that once the document is parsed `#checkRefs` can
|
|
387
|
+
* resolve it there.
|
|
388
|
+
*/
|
|
389
|
+
registerOasRef(consumer, ref) {
|
|
390
|
+
this.registerRef(consumer, toRefKey(ref.$ref));
|
|
391
|
+
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref });
|
|
392
|
+
}
|
|
353
393
|
/**
|
|
354
394
|
* Register an error against a ref key — typically called when the
|
|
355
395
|
* target of a `$ref` (or type reference) fails to parse. `undefined`
|
|
@@ -501,7 +541,7 @@ export class ParseContext {
|
|
|
501
541
|
});
|
|
502
542
|
}
|
|
503
543
|
}
|
|
504
|
-
_ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMap(), _ParseContext_rootFrames = new WeakMap(), _ParseContext_instances = new WeakSet(), _ParseContext_removeComponent = function _ParseContext_removeComponent(refKey) {
|
|
544
|
+
_ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMap(), _ParseContext_oasRefs = new WeakMap(), _ParseContext_rootFrames = new WeakMap(), _ParseContext_instances = new WeakSet(), _ParseContext_removeComponent = function _ParseContext_removeComponent(refKey) {
|
|
505
545
|
if (this.protocol.type !== 'oas') {
|
|
506
546
|
return;
|
|
507
547
|
}
|
|
@@ -614,4 +654,63 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
614
654
|
frames.length >= rootFrames.length &&
|
|
615
655
|
rootFrames.every((frame, index) => frames[index] === frame);
|
|
616
656
|
return startsWithRoot ? new StackTrail(frames.slice(rootFrames.length)) : stackTrail;
|
|
657
|
+
}, _ParseContext_checkRefs = function _ParseContext_checkRefs() {
|
|
658
|
+
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref }) => {
|
|
659
|
+
if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref.$ref))) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
try {
|
|
663
|
+
ref.resolveOnce();
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
if (DanglingRefError.is(error)) {
|
|
667
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDanglingRef).call(this, { consumer, ref, error });
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
this.logIssueNoKey({
|
|
671
|
+
level: 'warning',
|
|
672
|
+
message: `${error instanceof Error ? error.message : String(error)}. It is kept, and resolving it throws.`,
|
|
673
|
+
parent: { $ref: ref.$ref },
|
|
674
|
+
stackTrail: consumer,
|
|
675
|
+
type: 'REF_TYPE_MISMATCH'
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}, _ParseContext_logDanglingRef = function _ParseContext_logDanglingRef({ consumer, ref, error }) {
|
|
681
|
+
const exampleOrLink = ref.refType === 'example' || ref.refType === 'link';
|
|
682
|
+
if (exampleOrLink || this.system.danglingRefs === 'keep') {
|
|
683
|
+
this.logIssueNoKey({
|
|
684
|
+
level: 'warning',
|
|
685
|
+
message: exampleOrLink
|
|
686
|
+
? `${error.message}. It is kept, as a ref to an example or a link is in both system.danglingRefs modes, and resolving it throws DanglingRefError.`
|
|
687
|
+
: `${error.message}. It is kept (system.danglingRefs is keep), and resolving it throws DanglingRefError.`,
|
|
688
|
+
parent: { $ref: ref.$ref },
|
|
689
|
+
stackTrail: consumer,
|
|
690
|
+
type: 'DANGLING_REF'
|
|
691
|
+
});
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
// An error inside a component removes that component, and what uses it
|
|
695
|
+
// (`removeErroredItems`).
|
|
696
|
+
this.logIssueNoKey({
|
|
697
|
+
level: 'error',
|
|
698
|
+
message: `${error.message}, so what holds it is removed (system.danglingRefs is strict).`,
|
|
699
|
+
cause: error,
|
|
700
|
+
parent: { $ref: ref.$ref },
|
|
701
|
+
stackTrail: consumer,
|
|
702
|
+
type: 'DANGLING_REF'
|
|
703
|
+
});
|
|
704
|
+
// What holds the ref outside the components (an operation, a webhook, a
|
|
705
|
+
// path-level parameter) is removed here. Its own location has the
|
|
706
|
+
// DANGLING_REF already; an operation that a path-level parameter applies
|
|
707
|
+
// to gets an INVALID_DEPENDENCY_REF.
|
|
708
|
+
const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
|
|
709
|
+
if (documentTrail.toStackRef() !== undefined) {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
const location = consumer.toString();
|
|
713
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeConsumer).call(this, consumer, documentTrail)
|
|
714
|
+
.filter(removed => removed !== location)
|
|
715
|
+
.forEach(removed => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location: removed, refKey: ref.$ref, rootCause: { error, location } }));
|
|
617
716
|
};
|