@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
|
@@ -3,12 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ModelDriver = void 0;
|
|
6
|
+
exports.toModelRef = exports.isReferencedBack = exports.ModelDriver = void 0;
|
|
7
7
|
const normalizeWorkspacePath_js_1 = require("../../helpers/normalizeWorkspacePath.js");
|
|
8
8
|
const GeneratorKeys_js_1 = require("../GeneratorKeys.js");
|
|
9
9
|
const Variant_js_1 = require("../../types/Variant.js");
|
|
10
10
|
const ProjectionOptions_js_1 = require("../../types/ProjectionOptions.js");
|
|
11
11
|
const isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
|
|
12
|
+
const CodeFileBase_js_1 = require("../CodeFileBase.js");
|
|
13
|
+
const PendingDefinition_js_1 = require("../PendingDefinition.js");
|
|
12
14
|
/**
|
|
13
15
|
* Driver for the model insertion lifecycle.
|
|
14
16
|
*
|
|
@@ -19,7 +21,11 @@ const isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
|
|
|
19
21
|
* from the projection's `exportPath`.
|
|
20
22
|
*/
|
|
21
23
|
class ModelDriver {
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @param settings - The model's content settings, when the caller has
|
|
26
|
+
* already built them with the same `args` (`toModelRef` does).
|
|
27
|
+
*/
|
|
28
|
+
constructor(args, settings = toModelSettings(args)) {
|
|
23
29
|
Object.defineProperty(this, "context", {
|
|
24
30
|
enumerable: true,
|
|
25
31
|
configurable: true,
|
|
@@ -90,38 +96,19 @@ class ModelDriver {
|
|
|
90
96
|
this.noExport = noExport;
|
|
91
97
|
this.variant = variant;
|
|
92
98
|
this.options = (0, ProjectionOptions_js_1.readProjectionOptions)(args);
|
|
93
|
-
this.
|
|
94
|
-
assertPeerVariantExists({
|
|
95
|
-
context,
|
|
96
|
-
generatorId: projection.id,
|
|
97
|
-
refName,
|
|
98
|
-
variant
|
|
99
|
-
});
|
|
100
|
-
assertPeerSupported({ context, projection, refName, variant });
|
|
101
|
-
this.settings = this.context.toModelContentSettings({
|
|
102
|
-
refName,
|
|
103
|
-
projection,
|
|
104
|
-
variant,
|
|
105
|
-
options: this.options
|
|
106
|
-
});
|
|
99
|
+
this.settings = settings;
|
|
107
100
|
this.definition = this.apply({ destinationPath });
|
|
108
|
-
this.context.modelDepth[`${projection.id}:${refName}`] = 0;
|
|
109
101
|
}
|
|
110
102
|
apply({ destinationPath } = {}) {
|
|
111
103
|
const { identifier, exportPath } = this.settings;
|
|
112
104
|
const definition = this.getDefinition({ identifier, exportPath });
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.context.register({
|
|
121
|
-
imports: [this.projection.lang.toImport({ identifier, module: exportPath })],
|
|
122
|
-
destinationPath
|
|
123
|
-
});
|
|
124
|
-
}
|
|
105
|
+
stitchModelImport({
|
|
106
|
+
context: this.context,
|
|
107
|
+
lang: this.projection.lang,
|
|
108
|
+
identifier,
|
|
109
|
+
exportPath,
|
|
110
|
+
destinationPath
|
|
111
|
+
});
|
|
125
112
|
return definition;
|
|
126
113
|
}
|
|
127
114
|
/**
|
|
@@ -131,39 +118,78 @@ class ModelDriver {
|
|
|
131
118
|
* cache-hit path). Returns the normalized path.
|
|
132
119
|
*/
|
|
133
120
|
ensureFile(path) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
121
|
+
return ensureFile({ context: this.context, lang: this.projection.lang, path });
|
|
122
|
+
}
|
|
123
|
+
/** The code File at `path`, created through the projection's language on first use. */
|
|
124
|
+
ensureCodeFile(path) {
|
|
125
|
+
const file = this.context.getFile(this.ensureFile(path));
|
|
126
|
+
if (!(file instanceof CodeFileBase_js_1.CodeFileBase)) {
|
|
127
|
+
throw new Error(`File at '${path}' is not a code file: a model Definition cannot go there.`);
|
|
137
128
|
}
|
|
138
|
-
return
|
|
129
|
+
return file;
|
|
139
130
|
}
|
|
140
131
|
getDefinition({ identifier, exportPath }) {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
const generatorKey = (0, GeneratorKeys_js_1.toModelGeneratorKey)({
|
|
133
|
+
generatorId: this.projection.id,
|
|
134
|
+
refName: this.refName,
|
|
135
|
+
variant: this.settings.variant
|
|
144
136
|
});
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
const pending = findPending({ context: this.context, name: identifier.name, exportPath });
|
|
138
|
+
if (pending !== undefined) {
|
|
139
|
+
assertSamePending({
|
|
140
|
+
pending,
|
|
141
|
+
name: identifier.name,
|
|
142
|
+
exportPath,
|
|
143
|
+
generatorKey,
|
|
144
|
+
options: this.options,
|
|
145
|
+
projection: this.projection
|
|
146
|
+
});
|
|
147
|
+
throw new Error(`'${identifier.name}' in file '${exportPath}' is being constructed further up the stack. A reference back to it goes through toModelRef, which returns it suspended; a second projection would never finish.`);
|
|
147
148
|
}
|
|
148
|
-
const
|
|
149
|
+
const found = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
150
|
+
if (found !== undefined) {
|
|
151
|
+
if (this.affirmDefinition(found, exportPath)) {
|
|
152
|
+
return found;
|
|
153
|
+
}
|
|
154
|
+
throw new Error(`Registered definition mismatch: '${identifier.name}' in file '${exportPath}' was built by another projection class with the same generator key '${generatorKey}'. Two copies of one generator package, or two projection classes under one generator id, claim it.`);
|
|
155
|
+
}
|
|
156
|
+
// While the constructor runs, the model is on the context's pending
|
|
157
|
+
// stack: an insert of it from inside the constructor (a cycle) finds it
|
|
158
|
+
// there, not a cache miss.
|
|
159
|
+
const marker = new PendingDefinition_js_1.PendingDefinition({
|
|
160
|
+
identifier,
|
|
161
|
+
exportPath: (0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(exportPath),
|
|
162
|
+
generatorKey,
|
|
163
|
+
options: this.options,
|
|
164
|
+
projection: this.projection
|
|
165
|
+
});
|
|
166
|
+
const value = whilePending({ context: this.context, marker }, () => new this.projection({
|
|
149
167
|
refName: this.refName,
|
|
150
168
|
context: this.context,
|
|
151
169
|
settings: this.settings,
|
|
152
170
|
destinationPath: this.settings.exportPath,
|
|
153
171
|
rootRef: this.rootRef,
|
|
154
172
|
options: this.options
|
|
155
|
-
});
|
|
173
|
+
}));
|
|
156
174
|
const definition = this.projection.lang.toDefinition({
|
|
157
175
|
context: this.context,
|
|
158
176
|
identifier,
|
|
159
177
|
value,
|
|
160
178
|
noExport: this.noExport
|
|
161
179
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
180
|
+
definition.reaches = marker.reaches;
|
|
181
|
+
// Added once the constructor returned, so the Definition renders after
|
|
182
|
+
// the models it refers to, and a constructor that throws adds no file.
|
|
183
|
+
const taken = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
184
|
+
if (taken !== undefined) {
|
|
185
|
+
assertSameKey({
|
|
186
|
+
name: identifier.name,
|
|
187
|
+
exportPath,
|
|
188
|
+
cachedKey: taken.generatorKey,
|
|
189
|
+
generatorKey
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
this.ensureCodeFile(exportPath).addDefinition(definition);
|
|
167
193
|
return definition;
|
|
168
194
|
}
|
|
169
195
|
affirmDefinition(definition, exportPath) {
|
|
@@ -175,22 +201,175 @@ class ModelDriver {
|
|
|
175
201
|
refName: this.refName,
|
|
176
202
|
variant: this.settings.variant
|
|
177
203
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
204
|
+
assertSameKey({
|
|
205
|
+
name: definition.identifier.name,
|
|
206
|
+
exportPath,
|
|
207
|
+
cachedKey: definition.generatorKey,
|
|
208
|
+
generatorKey: currentKey
|
|
209
|
+
});
|
|
181
210
|
if (!(definition.value instanceof this.projection)) {
|
|
182
211
|
return false;
|
|
183
212
|
}
|
|
184
213
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
185
214
|
// is checked against the options its value was built with.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
assertSameOptions({
|
|
216
|
+
name: definition.identifier.name,
|
|
217
|
+
exportPath,
|
|
218
|
+
cachedOptions: (0, ProjectionOptions_js_1.toValueOptions)(definition.value),
|
|
219
|
+
options: this.options
|
|
220
|
+
});
|
|
190
221
|
return true;
|
|
191
222
|
}
|
|
192
223
|
}
|
|
193
224
|
exports.ModelDriver = ModelDriver;
|
|
225
|
+
/** Two generators, subjects or variants that claim one name in one file collide: `Registered definition mismatch`. */
|
|
226
|
+
const assertSameKey = ({ name, exportPath, cachedKey, generatorKey }) => {
|
|
227
|
+
if (cachedKey !== generatorKey) {
|
|
228
|
+
throw new Error(`Registered definition mismatch: '${name}' in file '${exportPath}'. Cached key '${cachedKey}' does not match new key '${generatorKey}'`);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
/** One name in one file built with other caller options collides too: options are identity. */
|
|
232
|
+
const assertSameOptions = ({ name, exportPath, cachedOptions, options }) => {
|
|
233
|
+
if (!(0, isEqual_js_1.default)(cachedOptions, options)) {
|
|
234
|
+
throw new Error(`Registered definition mismatch: '${name}' in file '${exportPath}'. Cached options ${JSON.stringify(cachedOptions)} do not match new options ${JSON.stringify(options)}. Fold options into toIdentifierName.`);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
/** Run `construct` with `marker` on top of the context's pending stack, popped however `construct` ends. */
|
|
238
|
+
const whilePending = ({ context, marker }, construct) => {
|
|
239
|
+
context.pendingStack.push(marker);
|
|
240
|
+
try {
|
|
241
|
+
return construct();
|
|
242
|
+
}
|
|
243
|
+
finally {
|
|
244
|
+
context.pendingStack.pop();
|
|
245
|
+
marker.pending = false;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* The model under construction named `name` in `exportPath`, if any. The
|
|
250
|
+
* pending stack holds exactly the models whose constructors are running, so
|
|
251
|
+
* the search is as long as the chain of models being built.
|
|
252
|
+
*/
|
|
253
|
+
const findPending = ({ context, name, exportPath }) => {
|
|
254
|
+
const path = (0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(exportPath);
|
|
255
|
+
return context.pendingStack.find(pending => pending.identifier.name === name && pending.exportPath === path);
|
|
256
|
+
};
|
|
257
|
+
/** A model under construction is this model only with the same key, projection class and options. */
|
|
258
|
+
const assertSamePending = ({ pending, name, exportPath, generatorKey, options, projection }) => {
|
|
259
|
+
assertSameKey({ name, exportPath, cachedKey: pending.generatorKey, generatorKey });
|
|
260
|
+
if (pending.projection !== projection) {
|
|
261
|
+
throw new Error(`Registered definition mismatch: '${name}' in file '${exportPath}' is being built by another projection class with the same generator key '${generatorKey}'. Two copies of one generator package, or two projection classes under one generator id, claim it.`);
|
|
262
|
+
}
|
|
263
|
+
assertSameOptions({ name, exportPath, cachedOptions: pending.options, options });
|
|
264
|
+
};
|
|
265
|
+
/** Ensure the file at `path` exists, creating it through `lang` on first write. Returns the normalized path. */
|
|
266
|
+
const ensureFile = ({ context, lang, path }) => {
|
|
267
|
+
const normalizedPath = (0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(path);
|
|
268
|
+
if (!context.getFile(normalizedPath)) {
|
|
269
|
+
context.addFile(lang.createFile({ path: normalizedPath, settings: context.settings }));
|
|
270
|
+
}
|
|
271
|
+
return normalizedPath;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Import a model's identifier from its export path into `destinationPath`,
|
|
275
|
+
* unless the two are one file. The language builds the import object
|
|
276
|
+
* (`toImport`) and creates the destination file on first write; the engine
|
|
277
|
+
* stores it via the pure-data `context.register`.
|
|
278
|
+
*/
|
|
279
|
+
const stitchModelImport = ({ context, lang, identifier, exportPath, destinationPath }) => {
|
|
280
|
+
if (!destinationPath ||
|
|
281
|
+
(0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(exportPath) === (0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(destinationPath)) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
ensureFile({ context, lang, path: destinationPath });
|
|
285
|
+
context.register({
|
|
286
|
+
imports: [lang.toImport({ identifier, module: exportPath })],
|
|
287
|
+
destinationPath
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
/** The models `definition`'s construction reached that are still pending. */
|
|
291
|
+
const toOpenReaches = (definition) => [...(definition.reaches ?? [])].filter(reached => reached.pending);
|
|
292
|
+
/**
|
|
293
|
+
* Whether anything referred back to the model of `settings` while its
|
|
294
|
+
* projection was being constructed: the model is recursive, on its own or in
|
|
295
|
+
* a cycle with others. Call it from the projection's constructor, after the
|
|
296
|
+
* value is built, while the model is still pending.
|
|
297
|
+
*/
|
|
298
|
+
const isReferencedBack = ({ context, settings }) => {
|
|
299
|
+
const pending = findPending({
|
|
300
|
+
context,
|
|
301
|
+
name: settings.identifier.name,
|
|
302
|
+
exportPath: settings.exportPath
|
|
303
|
+
});
|
|
304
|
+
return pending !== undefined && pending.backReferences > 0;
|
|
305
|
+
};
|
|
306
|
+
exports.isReferencedBack = isReferencedBack;
|
|
307
|
+
/** A model's content settings, once the peer is known to have the variant and to support the model. */
|
|
308
|
+
const toModelSettings = (args) => {
|
|
309
|
+
const { context, projection, refName, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
310
|
+
assertPeerVariantExists({ context, generatorId: projection.id, refName, variant });
|
|
311
|
+
assertPeerSupported({ context, projection, refName, variant });
|
|
312
|
+
return context.toModelContentSettings({
|
|
313
|
+
refName,
|
|
314
|
+
projection,
|
|
315
|
+
variant,
|
|
316
|
+
options: (0, ProjectionOptions_js_1.readProjectionOptions)(args)
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Reference a model from a ref snippet. A pending model (its projection is
|
|
321
|
+
* being constructed further up the stack) is a back-reference: its marker
|
|
322
|
+
* counts it, so its projection can tell that it is recursive
|
|
323
|
+
* ({@link isReferencedBack}), and its import is stitched into
|
|
324
|
+
* `destinationPath` as for any reference. The import matters when the
|
|
325
|
+
* back-reference crosses files: in a cycle of two or more models, the model
|
|
326
|
+
* that refers back lives in another file. Any other model goes through the
|
|
327
|
+
* {@link ModelDriver}.
|
|
328
|
+
*/
|
|
329
|
+
const toModelRef = (args) => {
|
|
330
|
+
const { context, projection, refName, destinationPath, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
331
|
+
const settings = toModelSettings(args);
|
|
332
|
+
const pending = findPending({
|
|
333
|
+
context,
|
|
334
|
+
name: settings.identifier.name,
|
|
335
|
+
exportPath: settings.exportPath
|
|
336
|
+
});
|
|
337
|
+
if (pending !== undefined) {
|
|
338
|
+
assertSamePending({
|
|
339
|
+
pending,
|
|
340
|
+
name: settings.identifier.name,
|
|
341
|
+
exportPath: settings.exportPath,
|
|
342
|
+
generatorKey: (0, GeneratorKeys_js_1.toModelGeneratorKey)({ generatorId: projection.id, refName, variant }),
|
|
343
|
+
options: (0, ProjectionOptions_js_1.readProjectionOptions)(args),
|
|
344
|
+
projection
|
|
345
|
+
});
|
|
346
|
+
pending.backReferences++;
|
|
347
|
+
// The model whose constructor is running reached a pending model.
|
|
348
|
+
context.pendingStack.at(-1)?.reaches.add(pending);
|
|
349
|
+
stitchModelImport({
|
|
350
|
+
context,
|
|
351
|
+
lang: projection.lang,
|
|
352
|
+
identifier: settings.identifier,
|
|
353
|
+
exportPath: settings.exportPath,
|
|
354
|
+
destinationPath
|
|
355
|
+
});
|
|
356
|
+
return { suspended: true, settings };
|
|
357
|
+
}
|
|
358
|
+
const driver = new ModelDriver(args, settings);
|
|
359
|
+
// What the model reached that is still pending, the source reaches too:
|
|
360
|
+
// through this reference. Constructed now or found in the cache, the
|
|
361
|
+
// Definition carries what its construction reached.
|
|
362
|
+
const open = toOpenReaches(driver.definition);
|
|
363
|
+
const source = context.pendingStack.at(-1);
|
|
364
|
+
open.forEach(reached => source?.reaches.add(reached));
|
|
365
|
+
return {
|
|
366
|
+
suspended: false,
|
|
367
|
+
settings: driver.settings,
|
|
368
|
+
definition: driver.definition,
|
|
369
|
+
inCycle: open.length > 0
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
exports.toModelRef = toModelRef;
|
|
194
373
|
/**
|
|
195
374
|
* Guard the peer-variant-mismatch invariant for model insertions.
|
|
196
375
|
*
|
|
@@ -45,7 +45,7 @@ export type ModelEntry<EnrichmentType = undefined> = {
|
|
|
45
45
|
* @param args.isSupported - Optional capability gate; a model whose predicate
|
|
46
46
|
* returns `false` is recorded `notSupported` and its `transform` is skipped.
|
|
47
47
|
* Resolve the schema inside the predicate when needed
|
|
48
|
-
* (`context.resolveSchemaRefOnce(refName
|
|
48
|
+
* (`context.resolveSchemaRefOnce(refName)`). Defaults to supporting every model.
|
|
49
49
|
* @param args.toPreviewModule - Optional function to generate preview modules
|
|
50
50
|
* @param args.toEnrichmentSchema - Optional function to provide enrichment validation
|
|
51
51
|
* @param args.toEnrichmentRequest - Optional function to request enrichments
|
|
@@ -18,7 +18,7 @@ exports.toModelEntry = void 0;
|
|
|
18
18
|
* @param args.isSupported - Optional capability gate; a model whose predicate
|
|
19
19
|
* returns `false` is recorded `notSupported` and its `transform` is skipped.
|
|
20
20
|
* Resolve the schema inside the predicate when needed
|
|
21
|
-
* (`context.resolveSchemaRefOnce(refName
|
|
21
|
+
* (`context.resolveSchemaRefOnce(refName)`). Defaults to supporting every model.
|
|
22
22
|
* @param args.toPreviewModule - Optional function to generate preview modules
|
|
23
23
|
* @param args.toEnrichmentSchema - Optional function to provide enrichment validation
|
|
24
24
|
* @param args.toEnrichmentRequest - Optional function to request enrichments
|
|
@@ -46,7 +46,7 @@ export type TransformModelArgs = {
|
|
|
46
46
|
* entry/dispatch boundary. The capability counterpart of
|
|
47
47
|
* {@link TransformModelArgs}: it carries the resolved enrichment umbrella so
|
|
48
48
|
* the predicate can gate on user config, but no schema — the predicate
|
|
49
|
-
* resolves the schema itself (`context.resolveSchemaRefOnce(refName
|
|
49
|
+
* resolves the schema itself (`context.resolveSchemaRefOnce(refName)`)
|
|
50
50
|
* when it needs it, mirroring how `transform` works.
|
|
51
51
|
*/
|
|
52
52
|
export type IsSupportedModelArgs = {
|
|
@@ -131,10 +131,7 @@ class GqlOperationDriver {
|
|
|
131
131
|
return normalizedPath;
|
|
132
132
|
}
|
|
133
133
|
getDefinition({ identifier, exportPath }) {
|
|
134
|
-
const cachedDefinition = this.context.findDefinition({
|
|
135
|
-
name: identifier.name,
|
|
136
|
-
exportPath
|
|
137
|
-
});
|
|
134
|
+
const cachedDefinition = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
138
135
|
if (this.affirmDefinition(cachedDefinition, exportPath)) {
|
|
139
136
|
return cachedDefinition;
|
|
140
137
|
}
|
|
@@ -124,10 +124,7 @@ class WebhookDriver {
|
|
|
124
124
|
return normalizedPath;
|
|
125
125
|
}
|
|
126
126
|
getDefinition({ identifier, exportPath }) {
|
|
127
|
-
const cachedDefinition = this.context.findDefinition({
|
|
128
|
-
name: identifier.name,
|
|
129
|
-
exportPath
|
|
130
|
-
});
|
|
127
|
+
const cachedDefinition = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
131
128
|
if (this.affirmDefinition(cachedDefinition, exportPath)) {
|
|
132
129
|
return cachedDefinition;
|
|
133
130
|
}
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* declares only the fields it reads — keys other generators own are
|
|
19
19
|
* expected, not typos.
|
|
20
20
|
*
|
|
21
|
-
* A wrong-typed value
|
|
22
|
-
*
|
|
23
|
-
* throwing leaf doesn't hide a dropped key.
|
|
21
|
+
* A wrong-typed value throws ({@link parseEnrichmentValue}), naming each
|
|
22
|
+
* wrong value's place in `client.json`. Unknown-key detection runs first,
|
|
23
|
+
* so a throwing leaf doesn't hide a dropped key.
|
|
24
24
|
*
|
|
25
25
|
* @module parseEnrichmentUmbrella
|
|
26
26
|
*/
|
|
@@ -54,9 +54,8 @@ type ParseEnrichmentUmbrellaArgs<EnrichmentType> = {
|
|
|
54
54
|
* umbrella, recording the reads for the consumption audit and reporting
|
|
55
55
|
* schema-dropped keys.
|
|
56
56
|
*
|
|
57
|
-
* @throws on a wrong-typed value
|
|
58
|
-
*
|
|
59
|
-
* continues (fail-open).
|
|
57
|
+
* @throws on a wrong-typed value. The generator's item is recorded as
|
|
58
|
+
* `error`, and the run fails once every generator has run.
|
|
60
59
|
*/
|
|
61
60
|
export declare const parseEnrichmentUmbrella: <EnrichmentType>({ context, generatorId, subjectSegments, schema }: ParseEnrichmentUmbrellaArgs<EnrichmentType>) => EnrichmentType;
|
|
62
61
|
export {};
|
|
@@ -19,59 +19,25 @@
|
|
|
19
19
|
* declares only the fields it reads — keys other generators own are
|
|
20
20
|
* expected, not typos.
|
|
21
21
|
*
|
|
22
|
-
* A wrong-typed value
|
|
23
|
-
*
|
|
24
|
-
* throwing leaf doesn't hide a dropped key.
|
|
22
|
+
* A wrong-typed value throws ({@link parseEnrichmentValue}), naming each
|
|
23
|
+
* wrong value's place in `client.json`. Unknown-key detection runs first,
|
|
24
|
+
* so a throwing leaf doesn't hide a dropped key.
|
|
25
25
|
*
|
|
26
26
|
* @module parseEnrichmentUmbrella
|
|
27
27
|
*/
|
|
28
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
-
if (k2 === undefined) k2 = k;
|
|
30
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(o, k2, desc);
|
|
35
|
-
}) : (function(o, m, k, k2) {
|
|
36
|
-
if (k2 === undefined) k2 = k;
|
|
37
|
-
o[k2] = m[k];
|
|
38
|
-
}));
|
|
39
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
-
}) : function(o, v) {
|
|
42
|
-
o["default"] = v;
|
|
43
|
-
});
|
|
44
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
-
var ownKeys = function(o) {
|
|
46
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
-
var ar = [];
|
|
48
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
-
return ar;
|
|
50
|
-
};
|
|
51
|
-
return ownKeys(o);
|
|
52
|
-
};
|
|
53
|
-
return function (mod) {
|
|
54
|
-
if (mod && mod.__esModule) return mod;
|
|
55
|
-
var result = {};
|
|
56
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
-
__setModuleDefault(result, mod);
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
})();
|
|
61
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
29
|
exports.parseEnrichmentUmbrella = void 0;
|
|
63
|
-
const v = __importStar(require("valibot"));
|
|
64
30
|
const Enrichments_js_1 = require("../types/Enrichments.js");
|
|
65
31
|
const findUnknownKeys_js_1 = require("./findUnknownKeys.js");
|
|
66
32
|
const EnrichmentWarning_js_1 = require("./EnrichmentWarning.js");
|
|
33
|
+
const parseEnrichmentValue_js_1 = require("./parseEnrichmentValue.js");
|
|
67
34
|
/**
|
|
68
35
|
* Assemble and parse one `{ subject, generator, stack }` enrichment
|
|
69
36
|
* umbrella, recording the reads for the consumption audit and reporting
|
|
70
37
|
* schema-dropped keys.
|
|
71
38
|
*
|
|
72
|
-
* @throws on a wrong-typed value
|
|
73
|
-
*
|
|
74
|
-
* continues (fail-open).
|
|
39
|
+
* @throws on a wrong-typed value. The generator's item is recorded as
|
|
40
|
+
* `error`, and the run fails once every generator has run.
|
|
75
41
|
*/
|
|
76
42
|
const parseEnrichmentUmbrella = ({ context, generatorId, subjectSegments, schema }) => {
|
|
77
43
|
const raw = {
|
|
@@ -98,6 +64,22 @@ const parseEnrichmentUmbrella = ({ context, generatorId, subjectSegments, schema
|
|
|
98
64
|
...(suggestion !== undefined ? { suggestion } : {})
|
|
99
65
|
});
|
|
100
66
|
}
|
|
101
|
-
return
|
|
67
|
+
return (0, parseEnrichmentValue_js_1.parseEnrichmentValue)({
|
|
68
|
+
schema,
|
|
69
|
+
value: raw,
|
|
70
|
+
generatorId,
|
|
71
|
+
toRoutingPath: ([scope, ...leafPath]) => {
|
|
72
|
+
switch (scope) {
|
|
73
|
+
case 'subject':
|
|
74
|
+
return [generatorId, ...subjectSegments, ...leafPath];
|
|
75
|
+
case 'generator':
|
|
76
|
+
return [generatorId, Enrichments_js_1.GENERATOR_ENRICHMENT_KEY, ...leafPath];
|
|
77
|
+
case 'stack':
|
|
78
|
+
return [Enrichments_js_1.STACK_ENRICHMENT_KEY, ...leafPath];
|
|
79
|
+
default:
|
|
80
|
+
return [generatorId];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
102
84
|
};
|
|
103
85
|
exports.parseEnrichmentUmbrella = parseEnrichmentUmbrella;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
type ParseEnrichmentValueArgs<EnrichmentType> = {
|
|
3
|
+
schema: v.GenericSchema<EnrichmentType>;
|
|
4
|
+
value: unknown;
|
|
5
|
+
/** The generator whose schema reads `value`; `undefined` for the shared `_stack` bag. */
|
|
6
|
+
generatorId: string | undefined;
|
|
7
|
+
/** The `client.json#settings.enrichments` routing path of the value at `path` inside `value`. */
|
|
8
|
+
toRoutingPath: (path: readonly string[]) => string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* `value` parsed through a generator's enrichment schema. Enrichments are
|
|
12
|
+
* typed configuration, so a value that does not match throws, and the run
|
|
13
|
+
* fails. The message lists every value that does not match, at its place in
|
|
14
|
+
* `client.json`, so the user can fix them all in one pass.
|
|
15
|
+
*/
|
|
16
|
+
export declare const parseEnrichmentValue: <EnrichmentType>({ schema, value, generatorId, toRoutingPath }: ParseEnrichmentValueArgs<EnrichmentType>) => EnrichmentType;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parseEnrichmentValue = void 0;
|
|
37
|
+
const v = __importStar(require("valibot"));
|
|
38
|
+
const EnrichmentWarning_js_1 = require("./EnrichmentWarning.js");
|
|
39
|
+
/**
|
|
40
|
+
* `value` parsed through a generator's enrichment schema. Enrichments are
|
|
41
|
+
* typed configuration, so a value that does not match throws, and the run
|
|
42
|
+
* fails. The message lists every value that does not match, at its place in
|
|
43
|
+
* `client.json`, so the user can fix them all in one pass.
|
|
44
|
+
*/
|
|
45
|
+
const parseEnrichmentValue = ({ schema, value, generatorId, toRoutingPath }) => {
|
|
46
|
+
const result = v.safeParse(schema, value);
|
|
47
|
+
if (result.success) {
|
|
48
|
+
return result.output;
|
|
49
|
+
}
|
|
50
|
+
const lines = result.issues.map(issue => {
|
|
51
|
+
const path = (issue.path ?? []).map(item => String(item.key));
|
|
52
|
+
const at = (0, EnrichmentWarning_js_1.formatEnrichmentPath)(toRoutingPath(path));
|
|
53
|
+
return `- '${at}': ${toFix(issue, generatorId)}`;
|
|
54
|
+
});
|
|
55
|
+
const header = generatorId === undefined
|
|
56
|
+
? 'Stack enrichments do not match the schema a generator reads them with.'
|
|
57
|
+
: `Enrichments for '${generatorId}' do not match its enrichment schema.`;
|
|
58
|
+
throw new Error([`${header} Fix them in client.json (settings.enrichments):`, ...lines].join('\n'));
|
|
59
|
+
};
|
|
60
|
+
exports.parseEnrichmentValue = parseEnrichmentValue;
|
|
61
|
+
/** What to do about one value: a scope the generator does not read takes no value at all. */
|
|
62
|
+
const toFix = (issue, generatorId) => {
|
|
63
|
+
if (issue.expected !== 'undefined') {
|
|
64
|
+
return issue.message;
|
|
65
|
+
}
|
|
66
|
+
return generatorId === undefined
|
|
67
|
+
? 'No generator reads a value here. Remove the value.'
|
|
68
|
+
: `'${generatorId}' reads no enrichments here. Remove the value.`;
|
|
69
|
+
};
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @module readEnrichments
|
|
25
25
|
*/
|
|
26
|
-
import * as v from 'valibot';
|
|
26
|
+
import type * as v from 'valibot';
|
|
27
27
|
import type { ClientSettings } from '../types/Settings.js';
|
|
28
28
|
/**
|
|
29
29
|
* Minimal structural view of the read context. Any `GenerateContext`
|
|
@@ -46,9 +46,9 @@ type EnrichmentReadContext = {
|
|
|
46
46
|
* `v.object({...})` (a missing block then throws); one with all-optional
|
|
47
47
|
* config passes `v.optional(v.object({...}))`.
|
|
48
48
|
*
|
|
49
|
-
* @throws on a malformed block
|
|
50
|
-
* `
|
|
51
|
-
* leaf.
|
|
49
|
+
* @throws on a malformed block, naming each wrong value's place in
|
|
50
|
+
* `client.json`. The item is recorded as `error`, and the run fails once
|
|
51
|
+
* every generator has run, exactly as for a bad subject leaf.
|
|
52
52
|
*/
|
|
53
53
|
export declare const toGeneratorEnrichment: <EnrichmentType>(context: EnrichmentReadContext, generatorId: string, schema: v.GenericSchema<EnrichmentType>) => EnrichmentType;
|
|
54
54
|
/**
|
|
@@ -62,7 +62,7 @@ export declare const toGeneratorEnrichment: <EnrichmentType>(context: Enrichment
|
|
|
62
62
|
* `v.object` ignores unknown keys, so fields other generators consume
|
|
63
63
|
* don't interfere. The return type is inferred from `schema`.
|
|
64
64
|
*
|
|
65
|
-
* @throws on a malformed block
|
|
65
|
+
* @throws on a malformed block, as above.
|
|
66
66
|
*/
|
|
67
67
|
export declare const toStackEnrichment: <EnrichmentType>(context: EnrichmentReadContext, schema: v.GenericSchema<EnrichmentType>) => EnrichmentType;
|
|
68
68
|
export {};
|