@skmtc/core 0.39.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
package/esm/dsl/CustomValue.js
CHANGED
|
@@ -50,6 +50,14 @@ export class CustomValue extends SnippetBase {
|
|
|
50
50
|
isRef() {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
|
+
/** Always `false`: this value has no `readOnly`. */
|
|
54
|
+
isReadOnly() {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/** Always `false`: this value has no `writeOnly`. */
|
|
58
|
+
isWriteOnly() {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
53
61
|
/**
|
|
54
62
|
* Resolves this custom value.
|
|
55
63
|
*
|
package/esm/dsl/Definition.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { GenerateContextType } from '../context/generateTypes.js';
|
|
|
2
2
|
import type { IdentifierBase } from './IdentifierBase.js';
|
|
3
3
|
import { SnippetBase } from './SnippetBase.js';
|
|
4
4
|
import type { GeneratedValue } from './GeneratedValue.js';
|
|
5
|
+
import type { PendingDefinition } from './PendingDefinition.js';
|
|
5
6
|
/**
|
|
6
7
|
* Constructor arguments for {@link DefinitionBase}.
|
|
7
8
|
*
|
|
@@ -35,6 +36,15 @@ export declare abstract class DefinitionBase<V extends GeneratedValue = Generate
|
|
|
35
36
|
identifier: IdentifierBase;
|
|
36
37
|
/** The generated value content */
|
|
37
38
|
value: V;
|
|
39
|
+
/**
|
|
40
|
+
* The models this Definition's model reached while its projection was
|
|
41
|
+
* being constructed that were pending then: the models further up the
|
|
42
|
+
* stack it refers back to, directly or through the models it refers to.
|
|
43
|
+
* A reference to this model is inside a cycle while one of them is still
|
|
44
|
+
* pending. Set by the `ModelDriver`; `undefined` for a Definition it did
|
|
45
|
+
* not construct.
|
|
46
|
+
*/
|
|
47
|
+
reaches: ReadonlySet<PendingDefinition> | undefined;
|
|
38
48
|
constructor({ context, identifier, value }: DefinitionBaseArgs<V>);
|
|
39
49
|
/** Renders the definition's code. Implemented by the concrete subclass. */
|
|
40
50
|
abstract toString(): string;
|
package/esm/dsl/Definition.js
CHANGED
|
@@ -31,6 +31,20 @@ export class DefinitionBase extends SnippetBase {
|
|
|
31
31
|
writable: true,
|
|
32
32
|
value: void 0
|
|
33
33
|
});
|
|
34
|
+
/**
|
|
35
|
+
* The models this Definition's model reached while its projection was
|
|
36
|
+
* being constructed that were pending then: the models further up the
|
|
37
|
+
* stack it refers back to, directly or through the models it refers to.
|
|
38
|
+
* A reference to this model is inside a cycle while one of them is still
|
|
39
|
+
* pending. Set by the `ModelDriver`; `undefined` for a Definition it did
|
|
40
|
+
* not construct.
|
|
41
|
+
*/
|
|
42
|
+
Object.defineProperty(this, "reaches", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
34
48
|
this.value = value;
|
|
35
49
|
this.identifier = identifier;
|
|
36
50
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IdentifierBase } from './IdentifierBase.js';
|
|
2
|
+
import type { GeneratorKey } from './GeneratorKeys.js';
|
|
3
|
+
type PendingDefinitionArgs = {
|
|
4
|
+
identifier: IdentifierBase;
|
|
5
|
+
exportPath: string;
|
|
6
|
+
generatorKey: GeneratorKey;
|
|
7
|
+
options: unknown;
|
|
8
|
+
projection: unknown;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A model whose projection is being constructed. The `ModelDriver` pushes it
|
|
12
|
+
* onto the context's `pendingStack` before it runs the projection's
|
|
13
|
+
* constructor, and pops it however the constructor ends, so the stack holds
|
|
14
|
+
* exactly the models under construction. The model's File does not see it:
|
|
15
|
+
* the Driver adds the Definition when the constructor returns.
|
|
16
|
+
*
|
|
17
|
+
* A reference to the model from inside that constructor (a cycle: the model
|
|
18
|
+
* refers to itself, or to a model that refers back to it) finds this entry,
|
|
19
|
+
* not a cache miss. `toModelRef` returns it suspended: the reference gets the
|
|
20
|
+
* model's identity, which is all a reference by name needs, and no value,
|
|
21
|
+
* which does not exist yet. A second projection for the model is never
|
|
22
|
+
* constructed.
|
|
23
|
+
*/
|
|
24
|
+
export declare class PendingDefinition {
|
|
25
|
+
identifier: IdentifierBase;
|
|
26
|
+
/** The file the Definition will go to, normalized. */
|
|
27
|
+
exportPath: string;
|
|
28
|
+
/** The key the Definition will carry: the identity check runs on the entry too. */
|
|
29
|
+
generatorKey: GeneratorKey;
|
|
30
|
+
/** The caller's options the projection is constructed with: identity, like the key. */
|
|
31
|
+
options: unknown;
|
|
32
|
+
/** The projection class being constructed: another class under this name and file is a clash. */
|
|
33
|
+
projection: unknown;
|
|
34
|
+
/** How many references found the model under construction: references back to it. */
|
|
35
|
+
backReferences: number;
|
|
36
|
+
/** True while the projection's constructor runs; false once it returned, however it returned. */
|
|
37
|
+
pending: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The models this model's construction reached while they were under
|
|
40
|
+
* construction: the targets of its references back, and what the models it
|
|
41
|
+
* refers to reached. When the constructor returns, the Driver hands the set
|
|
42
|
+
* to the Definition (`DefinitionBase.reaches`).
|
|
43
|
+
*/
|
|
44
|
+
reaches: Set<PendingDefinition>;
|
|
45
|
+
constructor({ identifier, exportPath, generatorKey, options, projection }: PendingDefinitionArgs);
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model whose projection is being constructed. The `ModelDriver` pushes it
|
|
3
|
+
* onto the context's `pendingStack` before it runs the projection's
|
|
4
|
+
* constructor, and pops it however the constructor ends, so the stack holds
|
|
5
|
+
* exactly the models under construction. The model's File does not see it:
|
|
6
|
+
* the Driver adds the Definition when the constructor returns.
|
|
7
|
+
*
|
|
8
|
+
* A reference to the model from inside that constructor (a cycle: the model
|
|
9
|
+
* refers to itself, or to a model that refers back to it) finds this entry,
|
|
10
|
+
* not a cache miss. `toModelRef` returns it suspended: the reference gets the
|
|
11
|
+
* model's identity, which is all a reference by name needs, and no value,
|
|
12
|
+
* which does not exist yet. A second projection for the model is never
|
|
13
|
+
* constructed.
|
|
14
|
+
*/
|
|
15
|
+
export class PendingDefinition {
|
|
16
|
+
constructor({ identifier, exportPath, generatorKey, options, projection }) {
|
|
17
|
+
Object.defineProperty(this, "identifier", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
/** The file the Definition will go to, normalized. */
|
|
24
|
+
Object.defineProperty(this, "exportPath", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
/** The key the Definition will carry: the identity check runs on the entry too. */
|
|
31
|
+
Object.defineProperty(this, "generatorKey", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
/** The caller's options the projection is constructed with: identity, like the key. */
|
|
38
|
+
Object.defineProperty(this, "options", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: void 0
|
|
43
|
+
});
|
|
44
|
+
/** The projection class being constructed: another class under this name and file is a clash. */
|
|
45
|
+
Object.defineProperty(this, "projection", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
/** How many references found the model under construction: references back to it. */
|
|
52
|
+
Object.defineProperty(this, "backReferences", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: 0
|
|
57
|
+
});
|
|
58
|
+
/** True while the projection's constructor runs; false once it returned, however it returned. */
|
|
59
|
+
Object.defineProperty(this, "pending", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: true
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* The models this model's construction reached while they were under
|
|
67
|
+
* construction: the targets of its references back, and what the models it
|
|
68
|
+
* refers to reached. When the constructor returns, the Driver hands the set
|
|
69
|
+
* to the Definition (`DefinitionBase.reaches`).
|
|
70
|
+
*/
|
|
71
|
+
Object.defineProperty(this, "reaches", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: new Set()
|
|
76
|
+
});
|
|
77
|
+
this.identifier = identifier;
|
|
78
|
+
this.exportPath = exportPath;
|
|
79
|
+
this.generatorKey = generatorKey;
|
|
80
|
+
this.options = options;
|
|
81
|
+
this.projection = projection;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -36,7 +36,11 @@ export declare class ModelDriver<V extends GeneratedValue, EnrichmentType, Proje
|
|
|
36
36
|
variant: string;
|
|
37
37
|
/** The caller's options, as passed to `insertModel`. */
|
|
38
38
|
options: ProjectionOptions;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @param settings - The model's content settings, when the caller has
|
|
41
|
+
* already built them with the same `args` (`toModelRef` does).
|
|
42
|
+
*/
|
|
43
|
+
constructor(args: CreateModelArgs<V, EnrichmentType, ProjectionOptions>, settings?: ContentSettings<EnrichmentType>);
|
|
40
44
|
private apply;
|
|
41
45
|
/**
|
|
42
46
|
* Ensure the file at `path` exists, creating it on first write through
|
|
@@ -45,7 +49,57 @@ export declare class ModelDriver<V extends GeneratedValue, EnrichmentType, Proje
|
|
|
45
49
|
* cache-hit path). Returns the normalized path.
|
|
46
50
|
*/
|
|
47
51
|
private ensureFile;
|
|
52
|
+
/** The code File at `path`, created through the projection's language on first use. */
|
|
53
|
+
private ensureCodeFile;
|
|
48
54
|
private getDefinition;
|
|
49
55
|
private affirmDefinition;
|
|
50
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether anything referred back to the model of `settings` while its
|
|
59
|
+
* projection was being constructed: the model is recursive, on its own or in
|
|
60
|
+
* a cycle with others. Call it from the projection's constructor, after the
|
|
61
|
+
* value is built, while the model is still pending.
|
|
62
|
+
*/
|
|
63
|
+
export declare const isReferencedBack: ({ context, settings }: IsReferencedBackArgs) => boolean;
|
|
64
|
+
type IsReferencedBackArgs = {
|
|
65
|
+
context: GenerateContextType;
|
|
66
|
+
settings: {
|
|
67
|
+
identifier: {
|
|
68
|
+
name: string;
|
|
69
|
+
};
|
|
70
|
+
exportPath: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* What a ref snippet gets for a reference to a model: `suspended` when the
|
|
75
|
+
* model is pending (a back-reference, which the snippet renders deferred,
|
|
76
|
+
* e.g. `z.lazy(() => Name)`: the value does not exist yet), else the
|
|
77
|
+
* Definition the Driver constructed or found.
|
|
78
|
+
*/
|
|
79
|
+
export type ModelRef<V extends GeneratedValue, EnrichmentType> = {
|
|
80
|
+
suspended: true;
|
|
81
|
+
settings: ContentSettings<EnrichmentType>;
|
|
82
|
+
} | {
|
|
83
|
+
suspended: false;
|
|
84
|
+
settings: ContentSettings<EnrichmentType>;
|
|
85
|
+
definition: GeneratedDefinition<V>;
|
|
86
|
+
/**
|
|
87
|
+
* The model reached a model that is still pending, so this reference is
|
|
88
|
+
* inside a cycle. Every reference inside a cycle must be deferred where
|
|
89
|
+
* the target language reads the value when the module loads (zod's
|
|
90
|
+
* `z.lazy`): any model of the cycle can be the first one loaded.
|
|
91
|
+
*/
|
|
92
|
+
inCycle: boolean;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Reference a model from a ref snippet. A pending model (its projection is
|
|
96
|
+
* being constructed further up the stack) is a back-reference: its marker
|
|
97
|
+
* counts it, so its projection can tell that it is recursive
|
|
98
|
+
* ({@link isReferencedBack}), and its import is stitched into
|
|
99
|
+
* `destinationPath` as for any reference. The import matters when the
|
|
100
|
+
* back-reference crosses files: in a cycle of two or more models, the model
|
|
101
|
+
* that refers back lives in another file. Any other model goes through the
|
|
102
|
+
* {@link ModelDriver}.
|
|
103
|
+
*/
|
|
104
|
+
export declare const toModelRef: <V extends GeneratedValue, EnrichmentType, ProjectionOptions = undefined>(args: CreateModelArgs<V, EnrichmentType, ProjectionOptions>) => ModelRef<V, EnrichmentType>;
|
|
51
105
|
export {};
|
|
@@ -3,6 +3,8 @@ import { toModelGeneratorKey } from '../GeneratorKeys.js';
|
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
4
4
|
import { readProjectionOptions, toValueOptions } from '../../types/ProjectionOptions.js';
|
|
5
5
|
import isEqual from 'lodash-es/isEqual.js';
|
|
6
|
+
import { CodeFileBase } from '../CodeFileBase.js';
|
|
7
|
+
import { PendingDefinition } from '../PendingDefinition.js';
|
|
6
8
|
/**
|
|
7
9
|
* Driver for the model insertion lifecycle.
|
|
8
10
|
*
|
|
@@ -13,7 +15,11 @@ import isEqual from 'lodash-es/isEqual.js';
|
|
|
13
15
|
* from the projection's `exportPath`.
|
|
14
16
|
*/
|
|
15
17
|
export class ModelDriver {
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @param settings - The model's content settings, when the caller has
|
|
20
|
+
* already built them with the same `args` (`toModelRef` does).
|
|
21
|
+
*/
|
|
22
|
+
constructor(args, settings = toModelSettings(args)) {
|
|
17
23
|
Object.defineProperty(this, "context", {
|
|
18
24
|
enumerable: true,
|
|
19
25
|
configurable: true,
|
|
@@ -84,38 +90,19 @@ export class ModelDriver {
|
|
|
84
90
|
this.noExport = noExport;
|
|
85
91
|
this.variant = variant;
|
|
86
92
|
this.options = readProjectionOptions(args);
|
|
87
|
-
this.
|
|
88
|
-
assertPeerVariantExists({
|
|
89
|
-
context,
|
|
90
|
-
generatorId: projection.id,
|
|
91
|
-
refName,
|
|
92
|
-
variant
|
|
93
|
-
});
|
|
94
|
-
assertPeerSupported({ context, projection, refName, variant });
|
|
95
|
-
this.settings = this.context.toModelContentSettings({
|
|
96
|
-
refName,
|
|
97
|
-
projection,
|
|
98
|
-
variant,
|
|
99
|
-
options: this.options
|
|
100
|
-
});
|
|
93
|
+
this.settings = settings;
|
|
101
94
|
this.definition = this.apply({ destinationPath });
|
|
102
|
-
this.context.modelDepth[`${projection.id}:${refName}`] = 0;
|
|
103
95
|
}
|
|
104
96
|
apply({ destinationPath } = {}) {
|
|
105
97
|
const { identifier, exportPath } = this.settings;
|
|
106
98
|
const definition = this.getDefinition({ identifier, exportPath });
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.context.register({
|
|
115
|
-
imports: [this.projection.lang.toImport({ identifier, module: exportPath })],
|
|
116
|
-
destinationPath
|
|
117
|
-
});
|
|
118
|
-
}
|
|
99
|
+
stitchModelImport({
|
|
100
|
+
context: this.context,
|
|
101
|
+
lang: this.projection.lang,
|
|
102
|
+
identifier,
|
|
103
|
+
exportPath,
|
|
104
|
+
destinationPath
|
|
105
|
+
});
|
|
119
106
|
return definition;
|
|
120
107
|
}
|
|
121
108
|
/**
|
|
@@ -125,39 +112,78 @@ export class ModelDriver {
|
|
|
125
112
|
* cache-hit path). Returns the normalized path.
|
|
126
113
|
*/
|
|
127
114
|
ensureFile(path) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
return ensureFile({ context: this.context, lang: this.projection.lang, path });
|
|
116
|
+
}
|
|
117
|
+
/** The code File at `path`, created through the projection's language on first use. */
|
|
118
|
+
ensureCodeFile(path) {
|
|
119
|
+
const file = this.context.getFile(this.ensureFile(path));
|
|
120
|
+
if (!(file instanceof CodeFileBase)) {
|
|
121
|
+
throw new Error(`File at '${path}' is not a code file: a model Definition cannot go there.`);
|
|
131
122
|
}
|
|
132
|
-
return
|
|
123
|
+
return file;
|
|
133
124
|
}
|
|
134
125
|
getDefinition({ identifier, exportPath }) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
126
|
+
const generatorKey = toModelGeneratorKey({
|
|
127
|
+
generatorId: this.projection.id,
|
|
128
|
+
refName: this.refName,
|
|
129
|
+
variant: this.settings.variant
|
|
138
130
|
});
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
const pending = findPending({ context: this.context, name: identifier.name, exportPath });
|
|
132
|
+
if (pending !== undefined) {
|
|
133
|
+
assertSamePending({
|
|
134
|
+
pending,
|
|
135
|
+
name: identifier.name,
|
|
136
|
+
exportPath,
|
|
137
|
+
generatorKey,
|
|
138
|
+
options: this.options,
|
|
139
|
+
projection: this.projection
|
|
140
|
+
});
|
|
141
|
+
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.`);
|
|
141
142
|
}
|
|
142
|
-
const
|
|
143
|
+
const found = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
144
|
+
if (found !== undefined) {
|
|
145
|
+
if (this.affirmDefinition(found, exportPath)) {
|
|
146
|
+
return found;
|
|
147
|
+
}
|
|
148
|
+
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.`);
|
|
149
|
+
}
|
|
150
|
+
// While the constructor runs, the model is on the context's pending
|
|
151
|
+
// stack: an insert of it from inside the constructor (a cycle) finds it
|
|
152
|
+
// there, not a cache miss.
|
|
153
|
+
const marker = new PendingDefinition({
|
|
154
|
+
identifier,
|
|
155
|
+
exportPath: normalizeWorkspacePath(exportPath),
|
|
156
|
+
generatorKey,
|
|
157
|
+
options: this.options,
|
|
158
|
+
projection: this.projection
|
|
159
|
+
});
|
|
160
|
+
const value = whilePending({ context: this.context, marker }, () => new this.projection({
|
|
143
161
|
refName: this.refName,
|
|
144
162
|
context: this.context,
|
|
145
163
|
settings: this.settings,
|
|
146
164
|
destinationPath: this.settings.exportPath,
|
|
147
165
|
rootRef: this.rootRef,
|
|
148
166
|
options: this.options
|
|
149
|
-
});
|
|
167
|
+
}));
|
|
150
168
|
const definition = this.projection.lang.toDefinition({
|
|
151
169
|
context: this.context,
|
|
152
170
|
identifier,
|
|
153
171
|
value,
|
|
154
172
|
noExport: this.noExport
|
|
155
173
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
174
|
+
definition.reaches = marker.reaches;
|
|
175
|
+
// Added once the constructor returned, so the Definition renders after
|
|
176
|
+
// the models it refers to, and a constructor that throws adds no file.
|
|
177
|
+
const taken = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
178
|
+
if (taken !== undefined) {
|
|
179
|
+
assertSameKey({
|
|
180
|
+
name: identifier.name,
|
|
181
|
+
exportPath,
|
|
182
|
+
cachedKey: taken.generatorKey,
|
|
183
|
+
generatorKey
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
this.ensureCodeFile(exportPath).addDefinition(definition);
|
|
161
187
|
return definition;
|
|
162
188
|
}
|
|
163
189
|
affirmDefinition(definition, exportPath) {
|
|
@@ -169,21 +195,172 @@ export class ModelDriver {
|
|
|
169
195
|
refName: this.refName,
|
|
170
196
|
variant: this.settings.variant
|
|
171
197
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
198
|
+
assertSameKey({
|
|
199
|
+
name: definition.identifier.name,
|
|
200
|
+
exportPath,
|
|
201
|
+
cachedKey: definition.generatorKey,
|
|
202
|
+
generatorKey: currentKey
|
|
203
|
+
});
|
|
175
204
|
if (!(definition.value instanceof this.projection)) {
|
|
176
205
|
return false;
|
|
177
206
|
}
|
|
178
207
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
179
208
|
// is checked against the options its value was built with.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
209
|
+
assertSameOptions({
|
|
210
|
+
name: definition.identifier.name,
|
|
211
|
+
exportPath,
|
|
212
|
+
cachedOptions: toValueOptions(definition.value),
|
|
213
|
+
options: this.options
|
|
214
|
+
});
|
|
184
215
|
return true;
|
|
185
216
|
}
|
|
186
217
|
}
|
|
218
|
+
/** Two generators, subjects or variants that claim one name in one file collide: `Registered definition mismatch`. */
|
|
219
|
+
const assertSameKey = ({ name, exportPath, cachedKey, generatorKey }) => {
|
|
220
|
+
if (cachedKey !== generatorKey) {
|
|
221
|
+
throw new Error(`Registered definition mismatch: '${name}' in file '${exportPath}'. Cached key '${cachedKey}' does not match new key '${generatorKey}'`);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
/** One name in one file built with other caller options collides too: options are identity. */
|
|
225
|
+
const assertSameOptions = ({ name, exportPath, cachedOptions, options }) => {
|
|
226
|
+
if (!isEqual(cachedOptions, options)) {
|
|
227
|
+
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.`);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
/** Run `construct` with `marker` on top of the context's pending stack, popped however `construct` ends. */
|
|
231
|
+
const whilePending = ({ context, marker }, construct) => {
|
|
232
|
+
context.pendingStack.push(marker);
|
|
233
|
+
try {
|
|
234
|
+
return construct();
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
context.pendingStack.pop();
|
|
238
|
+
marker.pending = false;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* The model under construction named `name` in `exportPath`, if any. The
|
|
243
|
+
* pending stack holds exactly the models whose constructors are running, so
|
|
244
|
+
* the search is as long as the chain of models being built.
|
|
245
|
+
*/
|
|
246
|
+
const findPending = ({ context, name, exportPath }) => {
|
|
247
|
+
const path = normalizeWorkspacePath(exportPath);
|
|
248
|
+
return context.pendingStack.find(pending => pending.identifier.name === name && pending.exportPath === path);
|
|
249
|
+
};
|
|
250
|
+
/** A model under construction is this model only with the same key, projection class and options. */
|
|
251
|
+
const assertSamePending = ({ pending, name, exportPath, generatorKey, options, projection }) => {
|
|
252
|
+
assertSameKey({ name, exportPath, cachedKey: pending.generatorKey, generatorKey });
|
|
253
|
+
if (pending.projection !== projection) {
|
|
254
|
+
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.`);
|
|
255
|
+
}
|
|
256
|
+
assertSameOptions({ name, exportPath, cachedOptions: pending.options, options });
|
|
257
|
+
};
|
|
258
|
+
/** Ensure the file at `path` exists, creating it through `lang` on first write. Returns the normalized path. */
|
|
259
|
+
const ensureFile = ({ context, lang, path }) => {
|
|
260
|
+
const normalizedPath = normalizeWorkspacePath(path);
|
|
261
|
+
if (!context.getFile(normalizedPath)) {
|
|
262
|
+
context.addFile(lang.createFile({ path: normalizedPath, settings: context.settings }));
|
|
263
|
+
}
|
|
264
|
+
return normalizedPath;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Import a model's identifier from its export path into `destinationPath`,
|
|
268
|
+
* unless the two are one file. The language builds the import object
|
|
269
|
+
* (`toImport`) and creates the destination file on first write; the engine
|
|
270
|
+
* stores it via the pure-data `context.register`.
|
|
271
|
+
*/
|
|
272
|
+
const stitchModelImport = ({ context, lang, identifier, exportPath, destinationPath }) => {
|
|
273
|
+
if (!destinationPath ||
|
|
274
|
+
normalizeWorkspacePath(exportPath) === normalizeWorkspacePath(destinationPath)) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
ensureFile({ context, lang, path: destinationPath });
|
|
278
|
+
context.register({
|
|
279
|
+
imports: [lang.toImport({ identifier, module: exportPath })],
|
|
280
|
+
destinationPath
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
/** The models `definition`'s construction reached that are still pending. */
|
|
284
|
+
const toOpenReaches = (definition) => [...(definition.reaches ?? [])].filter(reached => reached.pending);
|
|
285
|
+
/**
|
|
286
|
+
* Whether anything referred back to the model of `settings` while its
|
|
287
|
+
* projection was being constructed: the model is recursive, on its own or in
|
|
288
|
+
* a cycle with others. Call it from the projection's constructor, after the
|
|
289
|
+
* value is built, while the model is still pending.
|
|
290
|
+
*/
|
|
291
|
+
export const isReferencedBack = ({ context, settings }) => {
|
|
292
|
+
const pending = findPending({
|
|
293
|
+
context,
|
|
294
|
+
name: settings.identifier.name,
|
|
295
|
+
exportPath: settings.exportPath
|
|
296
|
+
});
|
|
297
|
+
return pending !== undefined && pending.backReferences > 0;
|
|
298
|
+
};
|
|
299
|
+
/** A model's content settings, once the peer is known to have the variant and to support the model. */
|
|
300
|
+
const toModelSettings = (args) => {
|
|
301
|
+
const { context, projection, refName, variant = DEFAULT_VARIANT } = args;
|
|
302
|
+
assertPeerVariantExists({ context, generatorId: projection.id, refName, variant });
|
|
303
|
+
assertPeerSupported({ context, projection, refName, variant });
|
|
304
|
+
return context.toModelContentSettings({
|
|
305
|
+
refName,
|
|
306
|
+
projection,
|
|
307
|
+
variant,
|
|
308
|
+
options: readProjectionOptions(args)
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Reference a model from a ref snippet. A pending model (its projection is
|
|
313
|
+
* being constructed further up the stack) is a back-reference: its marker
|
|
314
|
+
* counts it, so its projection can tell that it is recursive
|
|
315
|
+
* ({@link isReferencedBack}), and its import is stitched into
|
|
316
|
+
* `destinationPath` as for any reference. The import matters when the
|
|
317
|
+
* back-reference crosses files: in a cycle of two or more models, the model
|
|
318
|
+
* that refers back lives in another file. Any other model goes through the
|
|
319
|
+
* {@link ModelDriver}.
|
|
320
|
+
*/
|
|
321
|
+
export const toModelRef = (args) => {
|
|
322
|
+
const { context, projection, refName, destinationPath, variant = DEFAULT_VARIANT } = args;
|
|
323
|
+
const settings = toModelSettings(args);
|
|
324
|
+
const pending = findPending({
|
|
325
|
+
context,
|
|
326
|
+
name: settings.identifier.name,
|
|
327
|
+
exportPath: settings.exportPath
|
|
328
|
+
});
|
|
329
|
+
if (pending !== undefined) {
|
|
330
|
+
assertSamePending({
|
|
331
|
+
pending,
|
|
332
|
+
name: settings.identifier.name,
|
|
333
|
+
exportPath: settings.exportPath,
|
|
334
|
+
generatorKey: toModelGeneratorKey({ generatorId: projection.id, refName, variant }),
|
|
335
|
+
options: readProjectionOptions(args),
|
|
336
|
+
projection
|
|
337
|
+
});
|
|
338
|
+
pending.backReferences++;
|
|
339
|
+
// The model whose constructor is running reached a pending model.
|
|
340
|
+
context.pendingStack.at(-1)?.reaches.add(pending);
|
|
341
|
+
stitchModelImport({
|
|
342
|
+
context,
|
|
343
|
+
lang: projection.lang,
|
|
344
|
+
identifier: settings.identifier,
|
|
345
|
+
exportPath: settings.exportPath,
|
|
346
|
+
destinationPath
|
|
347
|
+
});
|
|
348
|
+
return { suspended: true, settings };
|
|
349
|
+
}
|
|
350
|
+
const driver = new ModelDriver(args, settings);
|
|
351
|
+
// What the model reached that is still pending, the source reaches too:
|
|
352
|
+
// through this reference. Constructed now or found in the cache, the
|
|
353
|
+
// Definition carries what its construction reached.
|
|
354
|
+
const open = toOpenReaches(driver.definition);
|
|
355
|
+
const source = context.pendingStack.at(-1);
|
|
356
|
+
open.forEach(reached => source?.reaches.add(reached));
|
|
357
|
+
return {
|
|
358
|
+
suspended: false,
|
|
359
|
+
settings: driver.settings,
|
|
360
|
+
definition: driver.definition,
|
|
361
|
+
inCycle: open.length > 0
|
|
362
|
+
};
|
|
363
|
+
};
|
|
187
364
|
/**
|
|
188
365
|
* Guard the peer-variant-mismatch invariant for model insertions.
|
|
189
366
|
*
|
|
@@ -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
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @param args.isSupported - Optional capability gate; a model whose predicate
|
|
16
16
|
* returns `false` is recorded `notSupported` and its `transform` is skipped.
|
|
17
17
|
* Resolve the schema inside the predicate when needed
|
|
18
|
-
* (`context.resolveSchemaRefOnce(refName
|
|
18
|
+
* (`context.resolveSchemaRefOnce(refName)`). Defaults to supporting every model.
|
|
19
19
|
* @param args.toPreviewModule - Optional function to generate preview modules
|
|
20
20
|
* @param args.toEnrichmentSchema - Optional function to provide enrichment validation
|
|
21
21
|
* @param args.toEnrichmentRequest - Optional function to request enrichments
|
package/esm/dsl/model/types.d.ts
CHANGED
|
@@ -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 = {
|
|
@@ -125,10 +125,7 @@ export class GqlOperationDriver {
|
|
|
125
125
|
return normalizedPath;
|
|
126
126
|
}
|
|
127
127
|
getDefinition({ identifier, exportPath }) {
|
|
128
|
-
const cachedDefinition = this.context.findDefinition({
|
|
129
|
-
name: identifier.name,
|
|
130
|
-
exportPath
|
|
131
|
-
});
|
|
128
|
+
const cachedDefinition = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
132
129
|
if (this.affirmDefinition(cachedDefinition, exportPath)) {
|
|
133
130
|
return cachedDefinition;
|
|
134
131
|
}
|
|
@@ -118,10 +118,7 @@ export class WebhookDriver {
|
|
|
118
118
|
return normalizedPath;
|
|
119
119
|
}
|
|
120
120
|
getDefinition({ identifier, exportPath }) {
|
|
121
|
-
const cachedDefinition = this.context.findDefinition({
|
|
122
|
-
name: identifier.name,
|
|
123
|
-
exportPath
|
|
124
|
-
});
|
|
121
|
+
const cachedDefinition = this.context.findDefinition({ name: identifier.name, exportPath });
|
|
125
122
|
if (this.affirmDefinition(cachedDefinition, exportPath)) {
|
|
126
123
|
return cachedDefinition;
|
|
127
124
|
}
|