@skmtc/core 0.38.0 → 0.40.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 +5 -4
- package/esm/context/GenerateContext.js +110 -37
- package/esm/context/ParseContext.d.ts +9 -1
- package/esm/context/ParseContext.js +12 -1
- package/esm/context/generateTypes.d.ts +19 -4
- package/esm/context/generateTypes.js +2 -0
- package/esm/context/toGenerationFailure.d.ts +21 -0
- package/esm/context/toGenerationFailure.js +38 -0
- 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/mod.d.ts +1 -0
- package/esm/mod.js +1 -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 +5 -1
- package/esm/oas/operation/Operation.js +17 -5
- package/esm/oas/operation/toEffectiveParameters.d.ts +16 -0
- package/esm/oas/operation/toEffectiveParameters.js +13 -0
- package/esm/oas/parameter/Parameter.d.ts +4 -0
- package/esm/oas/parameter/Parameter.js +8 -0
- package/esm/oas/ref/Ref.d.ts +147 -25
- package/esm/oas/ref/Ref.js +387 -25
- 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 +240 -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 +31 -0
- package/esm/oas/union/Union.js +100 -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 +6 -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/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/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-0/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-1/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-2/ref/toRefV31.js +2 -2
- package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/esm/types/OasBase.d.ts +1 -1
- package/esm/types/Settings.d.ts +34 -0
- package/esm/types/Settings.js +8 -0
- package/package.json +1 -1
- package/script/context/CoreContext.js +22 -8
- package/script/context/GenerateContext.d.ts +5 -4
- package/script/context/GenerateContext.js +110 -37
- package/script/context/ParseContext.d.ts +9 -1
- package/script/context/ParseContext.js +12 -1
- package/script/context/generateTypes.d.ts +19 -4
- package/script/context/generateTypes.js +2 -0
- package/script/context/toGenerationFailure.d.ts +21 -0
- package/script/context/toGenerationFailure.js +43 -0
- 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/mod.d.ts +1 -0
- package/script/mod.js +1 -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 +5 -1
- package/script/oas/operation/Operation.js +17 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +16 -0
- package/script/oas/operation/toEffectiveParameters.js +17 -0
- package/script/oas/parameter/Parameter.d.ts +4 -0
- package/script/oas/parameter/Parameter.js +8 -0
- package/script/oas/ref/Ref.d.ts +147 -25
- package/script/oas/ref/Ref.js +387 -25
- 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 +295 -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 +31 -0
- package/script/oas/union/Union.js +100 -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 +6 -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/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/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-0/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-1/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-2/ref/toRefV31.js +2 -2
- package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/script/types/OasBase.d.ts +1 -1
- package/script/types/Settings.d.ts +34 -0
- package/script/types/Settings.js +9 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { toRefV31 } from '../ref/toRefV31.js';
|
|
2
2
|
import { isRef } from '../../../helpers/refFns.js';
|
|
3
|
+
import { isEmpty } from '../../../helpers/isEmpty.js';
|
|
4
|
+
import { OasUnknown } from '../../../oas/unknown/Unknown.js';
|
|
3
5
|
import { toArray } from '../array/toArray.js';
|
|
4
6
|
import { toObject } from '../object/toObject.js';
|
|
5
7
|
import { toInteger } from '../integer/toInteger.js';
|
|
@@ -9,9 +11,28 @@ import { toString } from '../string/toString.js';
|
|
|
9
11
|
import { toUnknown } from '../unknown/toUnknown.js';
|
|
10
12
|
import { toUnion } from '../union/toUnion.js';
|
|
11
13
|
import { toGetRef } from '../../../helpers/refFns.js';
|
|
14
|
+
import { toSiblingKeywords } from '../../toSiblingKeywords.js';
|
|
15
|
+
import { logAllOfContradictions, toAllOfSystem } from '../../allOfSystem.js';
|
|
16
|
+
import { hasShapeKeyword, isUnknownAnyOf, logMergedUnknownAnyOf, logUnknownAnyOf, withoutUnknownAnyOf } from '../../anyOfSystem.js';
|
|
17
|
+
import { toAdditionalPropertiesV3 } from '../object/toAdditionalPropertiesV3.js';
|
|
12
18
|
import { mergeIntersection } from '../_merge-all-of/merge-intersection.js';
|
|
13
19
|
import { mergeUnion } from '../_merge-all-of/merge-union.js';
|
|
20
|
+
import { isNullOnly } from '../_merge-all-of/nullable-merge.js';
|
|
14
21
|
import { tryParseAt } from '../../../context/tryParseAt.js';
|
|
22
|
+
/**
|
|
23
|
+
* `schema` without the members of its `oneOf` or `anyOf` that are 3.0's way to
|
|
24
|
+
* write null (`{ nullable: true, enum: [null] }`, which Cloudflare writes
|
|
25
|
+
* with `type: object` too), and nullable when it had one, as the 3.1 parser
|
|
26
|
+
* folds `{ type: 'null' }` (`partitionNullMember`). A union of null only is
|
|
27
|
+
* left as it is.
|
|
28
|
+
*/
|
|
29
|
+
const withoutNullMembers = (schema, groupType) => {
|
|
30
|
+
const members = schema[groupType] ?? [];
|
|
31
|
+
const nonNull = members.filter(member => isRef(member) || !isNullOnly(member));
|
|
32
|
+
return nonNull.length === 0 || nonNull.length === members.length
|
|
33
|
+
? schema
|
|
34
|
+
: { ...schema, [groupType]: nonNull, nullable: true };
|
|
35
|
+
};
|
|
15
36
|
export const toSchemasV3 = ({ schemas, stackTrail, context }) => {
|
|
16
37
|
const output = {};
|
|
17
38
|
const entries = Object.entries(schemas);
|
|
@@ -75,11 +96,28 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
75
96
|
}
|
|
76
97
|
// OpenAPI `not` has no faithful TypeScript representation: a generated type
|
|
77
98
|
// that ignored it would *widen* the contract (accepting shapes the schema
|
|
78
|
-
// forbids).
|
|
79
|
-
// is
|
|
80
|
-
//
|
|
99
|
+
// forbids). Under `client.json` `system.not: strict` (the default) the schema
|
|
100
|
+
// is refused rather than emit a type that lies. The throw is isolated by
|
|
101
|
+
// `tryParseAt` into an `INVALID_SCHEMA` issue, and consumers of this schema
|
|
102
|
+
// are pruned via `removeErroredItems` (INVALID_DEPENDENCY_REF).
|
|
103
|
+
//
|
|
104
|
+
// Under `system.not: unknown` the schema parses with its other keywords, and
|
|
105
|
+
// its `not` is kept as an `OasUnknown` that core does not read: a generator
|
|
106
|
+
// can see that the document says "not something".
|
|
81
107
|
if ('not' in schema) {
|
|
82
|
-
|
|
108
|
+
// A test's mock context may have no `system`.
|
|
109
|
+
if (context.system?.not !== 'unknown') {
|
|
110
|
+
throw new Error('Schema uses unsupported "not" keyword');
|
|
111
|
+
}
|
|
112
|
+
const { not: _not, ...keywords } = schema;
|
|
113
|
+
const parsed = toSchemaV3({ schema: keywords, stackTrail, context });
|
|
114
|
+
// Only a one-member `allOf` of a `$ref` parses to a reference, and a
|
|
115
|
+
// reference has no field for a `not`. Fail rather than lose it.
|
|
116
|
+
if (parsed.isRef()) {
|
|
117
|
+
throw new Error('Schema uses "not" next to a one-member allOf reference, which cannot keep it');
|
|
118
|
+
}
|
|
119
|
+
parsed.not = stackTrail.trace('not', notTrail => context.withStackTrail(notTrail, () => new OasUnknown({}, context)));
|
|
120
|
+
return parsed;
|
|
83
121
|
}
|
|
84
122
|
if ('allOf' in schema && Array.isArray(schema.allOf)) {
|
|
85
123
|
return stackTrail.trace('allOf', st => {
|
|
@@ -95,14 +133,40 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
95
133
|
const members = allOf ?? [];
|
|
96
134
|
if (members.length === 1) {
|
|
97
135
|
const [member] = members;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
136
|
+
// Keywords next to the one member say how this site uses the
|
|
137
|
+
// reference, which stays lazy, so a self-reference still ends:
|
|
138
|
+
// `nullable`, `readOnly` and `writeOnly` ride it as use-site flags,
|
|
139
|
+
// and the others are read without the target's type (`siblings`).
|
|
140
|
+
// `resolve()` applies them to a copy of the target at generate time;
|
|
141
|
+
// the ones its type cannot take are left out there. The shared model
|
|
142
|
+
// never changes.
|
|
143
|
+
if (isRef(member)) {
|
|
144
|
+
const { nullable, readOnly, writeOnly, ...keywords } = value;
|
|
145
|
+
const siblings = isEmpty(keywords)
|
|
146
|
+
? undefined
|
|
147
|
+
: toSiblingKeywords({
|
|
148
|
+
keywords,
|
|
149
|
+
properties: stackTrail.trace('properties', propertiesTrail => toOptionalSchemasV3({ schemas: keywords.properties, stackTrail: propertiesTrail, context })),
|
|
150
|
+
additionalProperties: stackTrail.trace('additionalProperties', additionalTrail => toAdditionalPropertiesV3({
|
|
151
|
+
additionalProperties: keywords.additionalProperties,
|
|
152
|
+
stackTrail: additionalTrail,
|
|
153
|
+
context
|
|
154
|
+
})),
|
|
155
|
+
stackTrail,
|
|
156
|
+
context
|
|
157
|
+
});
|
|
158
|
+
if (nullable || readOnly || writeOnly || siblings) {
|
|
159
|
+
return toRefV31({
|
|
160
|
+
ref: member,
|
|
161
|
+
refType: 'schema',
|
|
162
|
+
nullable: nullable || undefined,
|
|
163
|
+
readOnly: readOnly || undefined,
|
|
164
|
+
writeOnly: writeOnly || undefined,
|
|
165
|
+
siblings,
|
|
166
|
+
stackTrail: st,
|
|
167
|
+
context
|
|
168
|
+
});
|
|
169
|
+
}
|
|
106
170
|
}
|
|
107
171
|
return toSchemaV3({
|
|
108
172
|
schema: collapseSingleMember(value, member),
|
|
@@ -110,20 +174,29 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
110
174
|
context
|
|
111
175
|
});
|
|
112
176
|
}
|
|
177
|
+
const system = toAllOfSystem(context);
|
|
113
178
|
const merged = mergeIntersection({
|
|
114
179
|
schema,
|
|
115
|
-
getRef: toGetRef(context.documentObject)
|
|
180
|
+
getRef: toGetRef(context.documentObject),
|
|
181
|
+
system
|
|
116
182
|
});
|
|
183
|
+
logAllOfContradictions({ system, stackTrail, parent: schema, context });
|
|
184
|
+
logMergedUnknownAnyOf({ system, stackTrail, parent: schema, context });
|
|
117
185
|
return toSchemaV3({ schema: merged, stackTrail: st, context });
|
|
118
186
|
});
|
|
119
187
|
}
|
|
120
188
|
if ('oneOf' in schema && Array.isArray(schema.oneOf)) {
|
|
121
189
|
return stackTrail.trace('oneOf', st => {
|
|
190
|
+
const system = toAllOfSystem(context);
|
|
122
191
|
const merged = mergeUnion({
|
|
123
|
-
|
|
192
|
+
// A null member makes the union nullable: `oneOf: [$ref, null]` is a nullable reference.
|
|
193
|
+
schema: withoutNullMembers(schema, 'oneOf'),
|
|
124
194
|
getRef: toGetRef(context.documentObject),
|
|
195
|
+
system,
|
|
125
196
|
groupType: 'oneOf'
|
|
126
197
|
});
|
|
198
|
+
logAllOfContradictions({ system, stackTrail, parent: schema, context });
|
|
199
|
+
logMergedUnknownAnyOf({ system, stackTrail, parent: schema, context });
|
|
127
200
|
if (!('oneOf' in merged) || !Array.isArray(merged.oneOf)) {
|
|
128
201
|
throw new Error('Missing "oneOf" array');
|
|
129
202
|
}
|
|
@@ -161,6 +234,21 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
161
234
|
});
|
|
162
235
|
}
|
|
163
236
|
if ('anyOf' in schema && Array.isArray(schema.anyOf)) {
|
|
237
|
+
// Under `system.anyOf: unknown`, as Cloudflare's `cf` reads it, an `anyOf`
|
|
238
|
+
// of two or more members is any value: the schema parses with its other
|
|
239
|
+
// keywords, so the properties next to it stay, without the members.
|
|
240
|
+
if (isUnknownAnyOf({ members: schema.anyOf, setting: context.system?.anyOf, getRef: toGetRef(context.documentObject) })) {
|
|
241
|
+
logUnknownAnyOf({ stackTrail, parent: schema, context });
|
|
242
|
+
const keywords = withoutUnknownAnyOf({
|
|
243
|
+
schema,
|
|
244
|
+
setting: context.system?.anyOf,
|
|
245
|
+
getRef: toGetRef(context.documentObject)
|
|
246
|
+
});
|
|
247
|
+
// A `default` alone is no type: the parser would guess one from it.
|
|
248
|
+
return hasShapeKeyword(keywords)
|
|
249
|
+
? toSchemaV3({ schema: keywords, stackTrail, context })
|
|
250
|
+
: toUnknown({ value: keywords, stackTrail, context });
|
|
251
|
+
}
|
|
164
252
|
return stackTrail.trace('anyOf', st => {
|
|
165
253
|
// deno-lint-ignore ban-ts-comment
|
|
166
254
|
// @ts-expect-error
|
|
@@ -168,11 +256,15 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
168
256
|
const { anyOf, ...value } = schema;
|
|
169
257
|
return toUnion({ value, members: anyOf, parentType: 'anyOf', stackTrail: st, context });
|
|
170
258
|
}
|
|
259
|
+
const system = toAllOfSystem(context);
|
|
171
260
|
const merged = mergeUnion({
|
|
172
|
-
schema,
|
|
261
|
+
schema: withoutNullMembers(schema, 'anyOf'),
|
|
173
262
|
getRef: toGetRef(context.documentObject),
|
|
263
|
+
system,
|
|
174
264
|
groupType: 'anyOf'
|
|
175
265
|
});
|
|
266
|
+
logAllOfContradictions({ system, stackTrail, parent: schema, context });
|
|
267
|
+
logMergedUnknownAnyOf({ system, stackTrail, parent: schema, context });
|
|
176
268
|
if (!('anyOf' in merged) || !Array.isArray(merged.anyOf)) {
|
|
177
269
|
throw new Error('Missing "anyOf" array');
|
|
178
270
|
}
|
|
@@ -9,6 +9,12 @@ type DecomposeUnionReturn = {
|
|
|
9
9
|
afterExcluded: SchemaObject;
|
|
10
10
|
};
|
|
11
11
|
export declare const decomposeUnion: ({ schema, groupType }: DecomposeUnionArgs) => DecomposeUnionReturn;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Is `key` a union-level key, kept on the union rather than merged into each
|
|
14
|
+
* member? A specification extension (`x-…`) is one too: it says something
|
|
15
|
+
* about the union, as Fern's `x-fern-property-name` renames the property,
|
|
16
|
+
* and `toUnion` keeps it. Merged into each member, it was lost, and each
|
|
17
|
+
* `$ref` member was resolved to merge it.
|
|
18
|
+
*/
|
|
13
19
|
export declare const isUnionLevelKey: (key: string) => boolean;
|
|
14
20
|
export {};
|
|
@@ -56,8 +56,14 @@ const excludedProperties = [
|
|
|
56
56
|
'writeOnly',
|
|
57
57
|
'deprecated'
|
|
58
58
|
];
|
|
59
|
-
/**
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Is `key` a union-level key, kept on the union rather than merged into each
|
|
61
|
+
* member? A specification extension (`x-…`) is one too: it says something
|
|
62
|
+
* about the union, as Fern's `x-fern-property-name` renames the property,
|
|
63
|
+
* and `toUnion` keeps it. Merged into each member, it was lost, and each
|
|
64
|
+
* `$ref` member was resolved to merge it.
|
|
65
|
+
*/
|
|
66
|
+
export const isUnionLevelKey = (key) => excludedProperties.includes(key) || key.startsWith('x-');
|
|
61
67
|
const exclude = (entries) => {
|
|
62
68
|
return entries.reduce((acc, [key, value]) => {
|
|
63
69
|
if (isUnionLevelKey(key)) {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { SchemaObject,
|
|
2
|
-
|
|
3
|
-
export declare const genericMerge: <T>(first: SchemaObject, second: SchemaObject, getRef: GetRefFn, normalize: NormalizeFn, typeCheck?: v.GenericSchema<T>) => SchemaObject;
|
|
1
|
+
import type { SchemaObject, GenericMergeArgs } from './types.js';
|
|
2
|
+
export declare const genericMerge: <T>({ first, second, getRef, normalize, system, typeCheck }: GenericMergeArgs<T>) => SchemaObject;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mergeEnumValues } from './merge-enum-values.js';
|
|
2
2
|
import { mergeProperties } from './merge-properties.js';
|
|
3
3
|
import { mergeRequired } from './merge-required.js';
|
|
4
|
-
export const genericMerge = (first, second, getRef, normalize, typeCheck) => {
|
|
4
|
+
export const genericMerge = ({ first, second, getRef, normalize, system, typeCheck }) => {
|
|
5
5
|
return {
|
|
6
6
|
...first,
|
|
7
7
|
...second,
|
|
8
|
-
...mergeProperties(first, second, getRef, normalize),
|
|
8
|
+
...mergeProperties({ first, second, getRef, normalize, system }),
|
|
9
9
|
...mergeRequired(first, second),
|
|
10
10
|
...mergeEnumValues(first, second, typeCheck)
|
|
11
11
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { MergeArgs } from './types.js';
|
|
2
|
+
import type { ArraySchemaObject, SchemaObject } from './types.js';
|
|
3
|
+
export declare function mergeArrayConstraints({ first, second, getRef, normalize, system }: MergeArgs<ArraySchemaObject | SchemaObject>): SchemaObject;
|
|
@@ -2,10 +2,10 @@ import { mergeSchemasOrRefs } from './merge.js';
|
|
|
2
2
|
import { genericMerge } from './generic-merge.js';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
5
|
-
export function mergeArrayConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeArrayConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
|
-
const merged = genericMerge(first, second, getRef, normalize, v.array(v.any()));
|
|
8
|
-
const items = mergeItems(first, second, getRef, normalize);
|
|
7
|
+
const merged = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.array(v.any()) });
|
|
8
|
+
const items = mergeItems({ first, second, getRef, normalize, system });
|
|
9
9
|
// With no `items` on either side, `items` stays absent (unknown items).
|
|
10
10
|
const result = items === undefined ? merged : { ...merged, type: 'array', items };
|
|
11
11
|
// Merge minItems
|
|
@@ -26,9 +26,9 @@ export function mergeArrayConstraints(first, second, getRef, normalize) {
|
|
|
26
26
|
}
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
|
-
const mergeItems = (first, second, getRef, normalize) => {
|
|
29
|
+
const mergeItems = ({ first, second, getRef, normalize, system }) => {
|
|
30
30
|
if ('items' in first && 'items' in second && first.items && second.items) {
|
|
31
|
-
return mergeSchemasOrRefs(first.items, second.items, getRef, normalize);
|
|
31
|
+
return mergeSchemasOrRefs({ first: first.items, second: second.items, getRef, normalize, system });
|
|
32
32
|
}
|
|
33
33
|
if ('items' in first && first.items) {
|
|
34
34
|
return first.items;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeBooleanConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeBooleanConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { genericMerge } from './generic-merge.js';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
|
-
export function mergeBooleanConstraints(first, second, getRef, normalize) {
|
|
4
|
+
export function mergeBooleanConstraints({ first, second, getRef, normalize, system }) {
|
|
5
5
|
checkTypeConflicts(first, second);
|
|
6
|
-
return genericMerge(first, second, getRef, normalize, v.boolean());
|
|
6
|
+
return genericMerge({ first, second, getRef, normalize, system, typeCheck: v.boolean() });
|
|
7
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeIntegerConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeIntegerConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -2,10 +2,10 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { mergeBounds } from './merge-bounds.js';
|
|
5
|
-
export function mergeIntegerConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeIntegerConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
// First merge enum values if present
|
|
8
|
-
const result = genericMerge(first, second, getRef, normalize, v.number());
|
|
8
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.number() });
|
|
9
9
|
// Then merge other constraints
|
|
10
10
|
result.type = 'integer';
|
|
11
11
|
mergeBounds(result, first, second);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject, MergeSystem } from './types.js';
|
|
2
2
|
type MergeIntersectionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
5
|
normalize: NormalizeFn;
|
|
6
|
+
system: MergeSystem;
|
|
6
7
|
throwOnConflict?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const mergeIntersection: ({ schema, getRef, normalize }: MergeIntersectionArgs) => SchemaOrReference;
|
|
9
|
+
export declare const mergeIntersection: ({ schema, getRef, normalize, system }: MergeIntersectionArgs) => SchemaOrReference;
|
|
9
10
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decomposeIntersection } from './decompose-intersection.js';
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
|
-
export const mergeIntersection = ({ schema, getRef, normalize }) => {
|
|
3
|
+
export const mergeIntersection = ({ schema, getRef, normalize, system }) => {
|
|
4
4
|
const decomposed = decomposeIntersection({ schema });
|
|
5
5
|
if (decomposed.length === 1) {
|
|
6
6
|
return decomposed[0];
|
|
@@ -9,7 +9,7 @@ export const mergeIntersection = ({ schema, getRef, normalize }) => {
|
|
|
9
9
|
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
10
10
|
});
|
|
11
11
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
12
|
-
const merged = mergeSchemasOrRefs(acc, decomposed, getRef, normalize);
|
|
12
|
+
const merged = mergeSchemasOrRefs({ first: acc, second: decomposed, getRef, normalize, system });
|
|
13
13
|
return merged;
|
|
14
14
|
}, {});
|
|
15
15
|
return result;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeNumberConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeNumberConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -2,10 +2,10 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { mergeBounds } from './merge-bounds.js';
|
|
5
|
-
export function mergeNumberConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeNumberConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
// First merge enum values if present
|
|
8
|
-
const result = genericMerge(first, second, getRef, normalize, v.number());
|
|
8
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.number() });
|
|
9
9
|
// Then merge other constraints
|
|
10
10
|
result.type = 'number';
|
|
11
11
|
mergeBounds(result, first, second);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { MergeArgs } from './types.js';
|
|
1
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
3
3
|
type SchemaObject = OpenAPIV3.SchemaObject;
|
|
4
|
-
export declare const mergeObjectConstraints: (first
|
|
4
|
+
export declare const mergeObjectConstraints: ({ first, second, getRef, normalize, system }: MergeArgs<SchemaObject>) => SchemaObject;
|
|
5
5
|
export {};
|
|
@@ -2,14 +2,14 @@ import { mergeSchemasOrRefs } from './merge.js';
|
|
|
2
2
|
import { genericMerge } from './generic-merge.js';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
5
|
-
export const mergeObjectConstraints = (first, second, getRef, normalize) => {
|
|
5
|
+
export const mergeObjectConstraints = ({ first, second, getRef, normalize, system }) => {
|
|
6
6
|
// Check for type conflicts
|
|
7
7
|
checkTypeConflicts(first, second);
|
|
8
|
-
const result = genericMerge(first, second, getRef, normalize, v.record(v.string(), v.any()));
|
|
8
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.record(v.string(), v.any()) });
|
|
9
9
|
if (typeof second.additionalProperties === 'object' &&
|
|
10
10
|
typeof first.additionalProperties === 'object') {
|
|
11
11
|
// If both have additionalProperties as schemas, merge them
|
|
12
|
-
result.additionalProperties = mergeSchemasOrRefs(first.additionalProperties, second.additionalProperties, getRef, normalize);
|
|
12
|
+
result.additionalProperties = mergeSchemasOrRefs({ first: first.additionalProperties, second: second.additionalProperties, getRef, normalize, system });
|
|
13
13
|
}
|
|
14
14
|
else if (second.additionalProperties !== undefined) {
|
|
15
15
|
result.additionalProperties = second.additionalProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SchemaObject,
|
|
2
|
-
export declare const mergeProperties: (first
|
|
1
|
+
import type { SchemaObject, MergeArgs } from './types.js';
|
|
2
|
+
export declare const mergeProperties: ({ first, second, getRef, normalize, system }: MergeArgs<SchemaObject>) => SchemaObject | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
2
|
-
export const mergeProperties = (first, second, getRef, normalize) => {
|
|
2
|
+
export const mergeProperties = ({ first, second, getRef, normalize, system }) => {
|
|
3
3
|
if (containsProperties(first, second)) {
|
|
4
4
|
const properties = { ...first.properties };
|
|
5
5
|
if (!properties) {
|
|
@@ -9,7 +9,7 @@ export const mergeProperties = (first, second, getRef, normalize) => {
|
|
|
9
9
|
}
|
|
10
10
|
for (const key in second.properties) {
|
|
11
11
|
if (key in properties) {
|
|
12
|
-
properties[key] = mergeSchemasOrRefs(properties[key], second.properties[key], getRef, normalize);
|
|
12
|
+
properties[key] = mergeSchemasOrRefs({ first: properties[key], second: second.properties[key], getRef, normalize, system });
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
properties[key] = second.properties[key];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeStringConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeStringConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -2,13 +2,13 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { checkAtLeastOneTypeMatch } from './check-at-least-one-type-match.js';
|
|
5
|
-
export function mergeStringConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeStringConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
if (!checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
8
|
-
return genericMerge(first, second, getRef, normalize);
|
|
8
|
+
return genericMerge({ first, second, getRef, normalize, system });
|
|
9
9
|
}
|
|
10
10
|
// First merge enum values if present
|
|
11
|
-
const result = genericMerge(first, second, getRef, normalize, v.string());
|
|
11
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.string() });
|
|
12
12
|
// Then merge other constraints
|
|
13
13
|
result.type = 'string';
|
|
14
14
|
// Merge minLength
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject, MergeSystem } from './types.js';
|
|
2
2
|
type MergeUnionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
5
|
normalize: NormalizeFn;
|
|
6
|
+
system: MergeSystem;
|
|
6
7
|
groupType: 'oneOf' | 'anyOf';
|
|
7
8
|
};
|
|
8
|
-
export declare const mergeUnion: ({ schema, getRef, normalize, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
9
|
+
export declare const mergeUnion: ({ schema, getRef, normalize, system, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
9
10
|
type MergeCrossProductArgs = {
|
|
10
11
|
first: SchemaObject;
|
|
11
12
|
second: SchemaObject;
|
|
12
13
|
getRef: GetRefFn;
|
|
13
14
|
normalize: NormalizeFn;
|
|
15
|
+
system: MergeSystem;
|
|
14
16
|
groupType: 'oneOf' | 'anyOf';
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The `system` a member's own `allOf` merges under: the `client.json`
|
|
20
|
+
* setting, also in the first pass over a cross product's pairs.
|
|
21
|
+
*/
|
|
22
|
+
export declare const toOwnSystem: (system: MergeSystem) => MergeSystem;
|
|
23
|
+
export declare const mergeCrossProduct: ({ first, second, getRef, normalize, system, groupType }: MergeCrossProductArgs) => SchemaObject;
|
|
17
24
|
/**
|
|
18
25
|
* A `oneOf`/`anyOf` whose every member is null-only (for example
|
|
19
26
|
* `oneOf: [{ type: 'null' }]`) reads as nullable with no other type, not
|
|
@@ -2,7 +2,7 @@ import { decomposeUnion, isUnionLevelKey } from './decompose-union.js';
|
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
3
|
import { crossProduct } from './cross-product.js';
|
|
4
4
|
import { isRef } from '../../../helpers/refFns.js';
|
|
5
|
-
export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
5
|
+
export const mergeUnion = ({ schema, getRef, normalize, system, groupType }) => {
|
|
6
6
|
const { beforeExcluded, decomposed, afterExcluded } = decomposeUnion({ schema, groupType });
|
|
7
7
|
// if (decomposed.length === 1) {
|
|
8
8
|
// console.log('DECOMPOSED', JSON.stringify(decomposed[0], null, 2))
|
|
@@ -23,6 +23,7 @@ export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
|
23
23
|
second: decomposed,
|
|
24
24
|
getRef,
|
|
25
25
|
normalize,
|
|
26
|
+
system,
|
|
26
27
|
groupType
|
|
27
28
|
});
|
|
28
29
|
return merged;
|
|
@@ -34,7 +35,51 @@ export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
|
34
35
|
};
|
|
35
36
|
return output;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The `system` a member's own `allOf` merges under: the `client.json`
|
|
40
|
+
* setting, also in the first pass over a cross product's pairs.
|
|
41
|
+
*/
|
|
42
|
+
export const toOwnSystem = (system) => ({
|
|
43
|
+
...system,
|
|
44
|
+
allOf: system.setting ?? system.allOf,
|
|
45
|
+
setting: undefined
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* The merge of each pair of the cross product whose members do not
|
|
49
|
+
* contradict. Such a pair is no value of the union, so it is left out, as
|
|
50
|
+
* under `strict`. Only when every pair contradicts does `latestWins` merge
|
|
51
|
+
* them again, the later member winning, without duplicates: Cloudflare's
|
|
52
|
+
* collections say `result` is an object or a string, then an array.
|
|
53
|
+
*
|
|
54
|
+
* The first pass is strict between the two members of a pair only. A
|
|
55
|
+
* member's own `allOf` merges under the `client.json` setting
|
|
56
|
+
* ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
|
|
57
|
+
* cross product with no pair that merges fails its pair: the outer pass then
|
|
58
|
+
* leaves the pair out, or lets the later member win.
|
|
59
|
+
*/
|
|
60
|
+
const mergePairs = ({ pairs, merge, system }) => {
|
|
61
|
+
const mergeEach = (pairSystem) => pairs.flatMap(pair => {
|
|
62
|
+
try {
|
|
63
|
+
return [merge(pair, pairSystem)];
|
|
64
|
+
}
|
|
65
|
+
catch (_error) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const strict = mergeEach({ ...system, allOf: 'strict', setting: system.setting ?? system.allOf });
|
|
70
|
+
if (strict.length > 0) {
|
|
71
|
+
return strict;
|
|
72
|
+
}
|
|
73
|
+
if (system.allOf === 'strict' && system.setting === 'latestWins') {
|
|
74
|
+
throw new Error('No pair of the cross product merges');
|
|
75
|
+
}
|
|
76
|
+
if (system.allOf === 'strict') {
|
|
77
|
+
return strict;
|
|
78
|
+
}
|
|
79
|
+
const latest = mergeEach(system).map(item => ({ item, key: JSON.stringify(item) }));
|
|
80
|
+
return latest.filter(({ key }, index) => latest.findIndex(other => other.key === key) === index).map(({ item }) => item);
|
|
81
|
+
};
|
|
82
|
+
export const mergeCrossProduct = ({ first, second, getRef, normalize, system, groupType }) => {
|
|
38
83
|
const firstMembers = Array.isArray(first[groupType]) ? first[groupType] : [first];
|
|
39
84
|
const secondMembers = Array.isArray(second[groupType]) ? second[groupType] : [second];
|
|
40
85
|
// A member that normalizes to `{ nullable: true }`, with at most union-level
|
|
@@ -46,17 +91,11 @@ export const mergeCrossProduct = ({ first, second, getRef, normalize, groupType
|
|
|
46
91
|
isNullableGroup(second, groupType) ||
|
|
47
92
|
firstGroup.length !== firstMembers.length ||
|
|
48
93
|
secondGroup.length !== secondMembers.length;
|
|
49
|
-
const mergedGroup =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
catch (_error) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
.filter(item => item !== undefined);
|
|
94
|
+
const mergedGroup = mergePairs({
|
|
95
|
+
pairs: crossProduct(withGroupSiblings({ schema: first, members: firstGroup, getRef, normalize, system, groupType }), withGroupSiblings({ schema: second, members: secondGroup, getRef, normalize, system, groupType })),
|
|
96
|
+
merge: ([firstItem, secondItem], pairSystem) => mergeSchemasOrRefs({ first: firstItem, second: secondItem, getRef, normalize, system: pairSystem }),
|
|
97
|
+
system
|
|
98
|
+
});
|
|
60
99
|
// A nested group is spread into this one below; its `nullable` carries over.
|
|
61
100
|
const nestedNullable = mergedGroup.some(item => !isRef(item) && Array.isArray(item[groupType]) && item.nullable === true);
|
|
62
101
|
return {
|
|
@@ -78,7 +117,7 @@ export const mergeCrossProduct = ({ first, second, getRef, normalize, groupType
|
|
|
78
117
|
* siblings is dropped, as in the cross product. A schema with no group is
|
|
79
118
|
* its own only member and is returned unchanged.
|
|
80
119
|
*/
|
|
81
|
-
const withGroupSiblings = ({ schema, members, getRef, normalize, groupType }) => {
|
|
120
|
+
const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupType }) => {
|
|
82
121
|
if (!Array.isArray(schema[groupType])) {
|
|
83
122
|
return members;
|
|
84
123
|
}
|
|
@@ -94,7 +133,7 @@ const withGroupSiblings = ({ schema, members, getRef, normalize, groupType }) =>
|
|
|
94
133
|
return member;
|
|
95
134
|
}
|
|
96
135
|
try {
|
|
97
|
-
return mergeSchemasOrRefs(siblingSchema, member, getRef, normalize);
|
|
136
|
+
return mergeSchemasOrRefs({ first: siblingSchema, second: member, getRef, normalize, system });
|
|
98
137
|
}
|
|
99
138
|
catch (_error) {
|
|
100
139
|
return undefined;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { MergeArgs } from './types.js';
|
|
2
|
+
import type { SchemaOrReference } from './types.js';
|
|
3
|
+
export declare const mergeSchemasOrRefs: ({ first: inputFirst, second: inputSecond, getRef, normalize, system }: MergeArgs<SchemaOrReference>) => SchemaOrReference;
|