@typia/utils 12.0.0-dev.20260225
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/LICENSE +21 -0
- package/README.md +79 -0
- package/lib/converters/LlmSchemaConverter.d.ts +102 -0
- package/lib/converters/LlmSchemaConverter.js +652 -0
- package/lib/converters/LlmSchemaConverter.js.map +1 -0
- package/lib/converters/LlmSchemaConverter.mjs +771 -0
- package/lib/converters/LlmSchemaConverter.mjs.map +1 -0
- package/lib/converters/OpenApiConverter.d.ts +135 -0
- package/lib/converters/OpenApiConverter.js +130 -0
- package/lib/converters/OpenApiConverter.js.map +1 -0
- package/lib/converters/OpenApiConverter.mjs +128 -0
- package/lib/converters/OpenApiConverter.mjs.map +1 -0
- package/lib/converters/index.d.ts +2 -0
- package/lib/converters/index.js +21 -0
- package/lib/converters/index.js.map +1 -0
- package/lib/converters/index.mjs +4 -0
- package/lib/converters/index.mjs.map +1 -0
- package/lib/converters/internal/LlmDescriptionInverter.d.ts +6 -0
- package/lib/converters/internal/LlmDescriptionInverter.js +141 -0
- package/lib/converters/internal/LlmDescriptionInverter.js.map +1 -0
- package/lib/converters/internal/LlmDescriptionInverter.mjs +141 -0
- package/lib/converters/internal/LlmDescriptionInverter.mjs.map +1 -0
- package/lib/converters/internal/LlmParametersComposer.d.ts +1 -0
- package/lib/converters/internal/LlmParametersComposer.js +39 -0
- package/lib/converters/internal/LlmParametersComposer.js.map +1 -0
- package/lib/converters/internal/LlmParametersComposer.mjs +42 -0
- package/lib/converters/internal/LlmParametersComposer.mjs.map +1 -0
- package/lib/converters/internal/OpenApiConstraintShifter.d.ts +6 -0
- package/lib/converters/internal/OpenApiConstraintShifter.js +103 -0
- package/lib/converters/internal/OpenApiConstraintShifter.js.map +1 -0
- package/lib/converters/internal/OpenApiConstraintShifter.mjs +102 -0
- package/lib/converters/internal/OpenApiConstraintShifter.mjs.map +1 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.d.ts +4 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.js +32 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.js.map +1 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.mjs +35 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.mjs.map +1 -0
- package/lib/converters/internal/OpenApiV3Downgrader.d.ts +10 -0
- package/lib/converters/internal/OpenApiV3Downgrader.js +214 -0
- package/lib/converters/internal/OpenApiV3Downgrader.js.map +1 -0
- package/lib/converters/internal/OpenApiV3Downgrader.mjs +279 -0
- package/lib/converters/internal/OpenApiV3Downgrader.mjs.map +1 -0
- package/lib/converters/internal/OpenApiV3Upgrader.d.ts +6 -0
- package/lib/converters/internal/OpenApiV3Upgrader.js +285 -0
- package/lib/converters/internal/OpenApiV3Upgrader.js.map +1 -0
- package/lib/converters/internal/OpenApiV3Upgrader.mjs +349 -0
- package/lib/converters/internal/OpenApiV3Upgrader.mjs.map +1 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.d.ts +6 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.js +405 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.js.map +1 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.mjs +545 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.mjs.map +1 -0
- package/lib/converters/internal/SwaggerV2Downgrader.d.ts +10 -0
- package/lib/converters/internal/SwaggerV2Downgrader.js +294 -0
- package/lib/converters/internal/SwaggerV2Downgrader.js.map +1 -0
- package/lib/converters/internal/SwaggerV2Downgrader.mjs +332 -0
- package/lib/converters/internal/SwaggerV2Downgrader.mjs.map +1 -0
- package/lib/converters/internal/SwaggerV2Upgrader.d.ts +6 -0
- package/lib/converters/internal/SwaggerV2Upgrader.js +357 -0
- package/lib/converters/internal/SwaggerV2Upgrader.js.map +1 -0
- package/lib/converters/internal/SwaggerV2Upgrader.mjs +403 -0
- package/lib/converters/internal/SwaggerV2Upgrader.mjs.map +1 -0
- package/lib/http/HttpError.d.ts +61 -0
- package/lib/http/HttpError.js +70 -0
- package/lib/http/HttpError.js.map +1 -0
- package/lib/http/HttpError.mjs +76 -0
- package/lib/http/HttpError.mjs.map +1 -0
- package/lib/http/HttpLlm.d.ts +130 -0
- package/lib/http/HttpLlm.js +124 -0
- package/lib/http/HttpLlm.js.map +1 -0
- package/lib/http/HttpLlm.mjs +123 -0
- package/lib/http/HttpLlm.mjs.map +1 -0
- package/lib/http/HttpMigration.d.ts +58 -0
- package/lib/http/HttpMigration.js +52 -0
- package/lib/http/HttpMigration.js.map +1 -0
- package/lib/http/HttpMigration.mjs +52 -0
- package/lib/http/HttpMigration.mjs.map +1 -0
- package/lib/http/index.d.ts +3 -0
- package/lib/http/index.js +20 -0
- package/lib/http/index.js.map +1 -0
- package/lib/http/index.mjs +4 -0
- package/lib/http/index.mjs.map +1 -0
- package/lib/http/internal/HttpLlmApplicationComposer.d.ts +8 -0
- package/lib/http/internal/HttpLlmApplicationComposer.js +254 -0
- package/lib/http/internal/HttpLlmApplicationComposer.js.map +1 -0
- package/lib/http/internal/HttpLlmApplicationComposer.mjs +256 -0
- package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.d.ts +6 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.js +24 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.js.map +1 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.mjs +24 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.d.ts +4 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.js +45 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.js.map +1 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.mjs +47 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.d.ts +4 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.js +107 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.js.map +1 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.mjs +106 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateRouteComposer.d.ts +11 -0
- package/lib/http/internal/HttpMigrateRouteComposer.js +398 -0
- package/lib/http/internal/HttpMigrateRouteComposer.js.map +1 -0
- package/lib/http/internal/HttpMigrateRouteComposer.mjs +392 -0
- package/lib/http/internal/HttpMigrateRouteComposer.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.d.ts +6 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.js +179 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.js.map +1 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.mjs +174 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.mjs.map +1 -0
- package/lib/http/internal/LlmDataMerger.d.ts +48 -0
- package/lib/http/internal/LlmDataMerger.js +60 -0
- package/lib/http/internal/LlmDataMerger.js.map +1 -0
- package/lib/http/internal/LlmDataMerger.mjs +59 -0
- package/lib/http/internal/LlmDataMerger.mjs.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +20 -0
- package/lib/index.mjs.map +1 -0
- package/lib/utils/ArrayUtil.d.ts +1 -0
- package/lib/utils/ArrayUtil.js +29 -0
- package/lib/utils/ArrayUtil.js.map +1 -0
- package/lib/utils/ArrayUtil.mjs +28 -0
- package/lib/utils/ArrayUtil.mjs.map +1 -0
- package/lib/utils/MapUtil.d.ts +1 -0
- package/lib/utils/MapUtil.js +16 -0
- package/lib/utils/MapUtil.js.map +1 -0
- package/lib/utils/MapUtil.mjs +15 -0
- package/lib/utils/MapUtil.mjs.map +1 -0
- package/lib/utils/NamingConvention.d.ts +68 -0
- package/lib/utils/NamingConvention.js +199 -0
- package/lib/utils/NamingConvention.js.map +1 -0
- package/lib/utils/NamingConvention.mjs +198 -0
- package/lib/utils/NamingConvention.mjs.map +1 -0
- package/lib/utils/Singleton.d.ts +1 -0
- package/lib/utils/Singleton.js +18 -0
- package/lib/utils/Singleton.js.map +1 -0
- package/lib/utils/Singleton.mjs +18 -0
- package/lib/utils/Singleton.mjs.map +1 -0
- package/lib/utils/StringUtil.d.ts +1 -0
- package/lib/utils/StringUtil.js +17 -0
- package/lib/utils/StringUtil.js.map +1 -0
- package/lib/utils/StringUtil.mjs +13 -0
- package/lib/utils/StringUtil.mjs.map +1 -0
- package/lib/utils/dedent.d.ts +12 -0
- package/lib/utils/dedent.js +51 -0
- package/lib/utils/dedent.js.map +1 -0
- package/lib/utils/dedent.mjs +50 -0
- package/lib/utils/dedent.mjs.map +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.js +24 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/index.mjs +8 -0
- package/lib/utils/index.mjs.map +1 -0
- package/lib/utils/internal/EndpointUtil.d.ts +8 -0
- package/lib/utils/internal/EndpointUtil.js +37 -0
- package/lib/utils/internal/EndpointUtil.js.map +1 -0
- package/lib/utils/internal/EndpointUtil.mjs +37 -0
- package/lib/utils/internal/EndpointUtil.mjs.map +1 -0
- package/lib/utils/internal/JsonDescriptor.d.ts +10 -0
- package/lib/utils/internal/JsonDescriptor.js +58 -0
- package/lib/utils/internal/JsonDescriptor.js.map +1 -0
- package/lib/utils/internal/JsonDescriptor.mjs +48 -0
- package/lib/utils/internal/JsonDescriptor.mjs.map +1 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.d.ts +1 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.js +520 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.js.map +1 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.mjs +584 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.mjs.map +1 -0
- package/lib/utils/stringifyValidationFailure.d.ts +25 -0
- package/lib/utils/stringifyValidationFailure.js +326 -0
- package/lib/utils/stringifyValidationFailure.js.map +1 -0
- package/lib/utils/stringifyValidationFailure.mjs +325 -0
- package/lib/utils/stringifyValidationFailure.mjs.map +1 -0
- package/lib/validators/LlmTypeChecker.d.ts +117 -0
- package/lib/validators/LlmTypeChecker.js +309 -0
- package/lib/validators/LlmTypeChecker.js.map +1 -0
- package/lib/validators/LlmTypeChecker.mjs +300 -0
- package/lib/validators/LlmTypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiTypeChecker.d.ts +211 -0
- package/lib/validators/OpenApiTypeChecker.js +207 -0
- package/lib/validators/OpenApiTypeChecker.js.map +1 -0
- package/lib/validators/OpenApiTypeChecker.mjs +218 -0
- package/lib/validators/OpenApiTypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiV3TypeChecker.d.ts +26 -0
- package/lib/validators/OpenApiV3TypeChecker.js +30 -0
- package/lib/validators/OpenApiV3TypeChecker.js.map +1 -0
- package/lib/validators/OpenApiV3TypeChecker.mjs +29 -0
- package/lib/validators/OpenApiV3TypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiV3_1TypeChecker.d.ts +29 -0
- package/lib/validators/OpenApiV3_1TypeChecker.js +34 -0
- package/lib/validators/OpenApiV3_1TypeChecker.js.map +1 -0
- package/lib/validators/OpenApiV3_1TypeChecker.mjs +33 -0
- package/lib/validators/OpenApiV3_1TypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiValidator.d.ts +36 -0
- package/lib/validators/OpenApiValidator.js +71 -0
- package/lib/validators/OpenApiValidator.js.map +1 -0
- package/lib/validators/OpenApiValidator.mjs +75 -0
- package/lib/validators/OpenApiValidator.mjs.map +1 -0
- package/lib/validators/SwaggerV2TypeChecker.d.ts +27 -0
- package/lib/validators/SwaggerV2TypeChecker.js +31 -0
- package/lib/validators/SwaggerV2TypeChecker.js.map +1 -0
- package/lib/validators/SwaggerV2TypeChecker.mjs +30 -0
- package/lib/validators/SwaggerV2TypeChecker.mjs.map +1 -0
- package/lib/validators/functional/_isBigintString.d.ts +1 -0
- package/lib/validators/functional/_isBigintString.js +14 -0
- package/lib/validators/functional/_isBigintString.js.map +1 -0
- package/lib/validators/functional/_isBigintString.mjs +12 -0
- package/lib/validators/functional/_isBigintString.mjs.map +1 -0
- package/lib/validators/functional/_isFormatByte.d.ts +1 -0
- package/lib/validators/functional/_isFormatByte.js +10 -0
- package/lib/validators/functional/_isFormatByte.js.map +1 -0
- package/lib/validators/functional/_isFormatByte.mjs +8 -0
- package/lib/validators/functional/_isFormatByte.mjs.map +1 -0
- package/lib/validators/functional/_isFormatDate.d.ts +1 -0
- package/lib/validators/functional/_isFormatDate.js +7 -0
- package/lib/validators/functional/_isFormatDate.js.map +1 -0
- package/lib/validators/functional/_isFormatDate.mjs +5 -0
- package/lib/validators/functional/_isFormatDate.mjs.map +1 -0
- package/lib/validators/functional/_isFormatDateTime.d.ts +1 -0
- package/lib/validators/functional/_isFormatDateTime.js +7 -0
- package/lib/validators/functional/_isFormatDateTime.js.map +1 -0
- package/lib/validators/functional/_isFormatDateTime.mjs +5 -0
- package/lib/validators/functional/_isFormatDateTime.mjs.map +1 -0
- package/lib/validators/functional/_isFormatDuration.d.ts +1 -0
- package/lib/validators/functional/_isFormatDuration.js +7 -0
- package/lib/validators/functional/_isFormatDuration.js.map +1 -0
- package/lib/validators/functional/_isFormatDuration.mjs +5 -0
- package/lib/validators/functional/_isFormatDuration.mjs.map +1 -0
- package/lib/validators/functional/_isFormatEmail.d.ts +1 -0
- package/lib/validators/functional/_isFormatEmail.js +7 -0
- package/lib/validators/functional/_isFormatEmail.js.map +1 -0
- package/lib/validators/functional/_isFormatEmail.mjs +5 -0
- package/lib/validators/functional/_isFormatEmail.mjs.map +1 -0
- package/lib/validators/functional/_isFormatHostname.d.ts +1 -0
- package/lib/validators/functional/_isFormatHostname.js +7 -0
- package/lib/validators/functional/_isFormatHostname.js.map +1 -0
- package/lib/validators/functional/_isFormatHostname.mjs +5 -0
- package/lib/validators/functional/_isFormatHostname.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIdnEmail.d.ts +1 -0
- package/lib/validators/functional/_isFormatIdnEmail.js +7 -0
- package/lib/validators/functional/_isFormatIdnEmail.js.map +1 -0
- package/lib/validators/functional/_isFormatIdnEmail.mjs +5 -0
- package/lib/validators/functional/_isFormatIdnEmail.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIdnHostname.d.ts +1 -0
- package/lib/validators/functional/_isFormatIdnHostname.js +7 -0
- package/lib/validators/functional/_isFormatIdnHostname.js.map +1 -0
- package/lib/validators/functional/_isFormatIdnHostname.mjs +5 -0
- package/lib/validators/functional/_isFormatIdnHostname.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIpv4.d.ts +1 -0
- package/lib/validators/functional/_isFormatIpv4.js +7 -0
- package/lib/validators/functional/_isFormatIpv4.js.map +1 -0
- package/lib/validators/functional/_isFormatIpv4.mjs +5 -0
- package/lib/validators/functional/_isFormatIpv4.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIpv6.d.ts +1 -0
- package/lib/validators/functional/_isFormatIpv6.js +7 -0
- package/lib/validators/functional/_isFormatIpv6.js.map +1 -0
- package/lib/validators/functional/_isFormatIpv6.mjs +5 -0
- package/lib/validators/functional/_isFormatIpv6.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIri.d.ts +1 -0
- package/lib/validators/functional/_isFormatIri.js +7 -0
- package/lib/validators/functional/_isFormatIri.js.map +1 -0
- package/lib/validators/functional/_isFormatIri.mjs +5 -0
- package/lib/validators/functional/_isFormatIri.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIriReference.d.ts +1 -0
- package/lib/validators/functional/_isFormatIriReference.js +7 -0
- package/lib/validators/functional/_isFormatIriReference.js.map +1 -0
- package/lib/validators/functional/_isFormatIriReference.mjs +5 -0
- package/lib/validators/functional/_isFormatIriReference.mjs.map +1 -0
- package/lib/validators/functional/_isFormatJsonPointer.d.ts +1 -0
- package/lib/validators/functional/_isFormatJsonPointer.js +7 -0
- package/lib/validators/functional/_isFormatJsonPointer.js.map +1 -0
- package/lib/validators/functional/_isFormatJsonPointer.mjs +5 -0
- package/lib/validators/functional/_isFormatJsonPointer.mjs.map +1 -0
- package/lib/validators/functional/_isFormatPassword.d.ts +1 -0
- package/lib/validators/functional/_isFormatPassword.js +6 -0
- package/lib/validators/functional/_isFormatPassword.js.map +1 -0
- package/lib/validators/functional/_isFormatPassword.mjs +4 -0
- package/lib/validators/functional/_isFormatPassword.mjs.map +1 -0
- package/lib/validators/functional/_isFormatRegex.d.ts +1 -0
- package/lib/validators/functional/_isFormatRegex.js +14 -0
- package/lib/validators/functional/_isFormatRegex.js.map +1 -0
- package/lib/validators/functional/_isFormatRegex.mjs +12 -0
- package/lib/validators/functional/_isFormatRegex.mjs.map +1 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.d.ts +1 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.js +7 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.js.map +1 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs +5 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs.map +1 -0
- package/lib/validators/functional/_isFormatTime.d.ts +1 -0
- package/lib/validators/functional/_isFormatTime.js +7 -0
- package/lib/validators/functional/_isFormatTime.js.map +1 -0
- package/lib/validators/functional/_isFormatTime.mjs +5 -0
- package/lib/validators/functional/_isFormatTime.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUri.d.ts +1 -0
- package/lib/validators/functional/_isFormatUri.js +8 -0
- package/lib/validators/functional/_isFormatUri.js.map +1 -0
- package/lib/validators/functional/_isFormatUri.mjs +6 -0
- package/lib/validators/functional/_isFormatUri.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUriReference.d.ts +1 -0
- package/lib/validators/functional/_isFormatUriReference.js +7 -0
- package/lib/validators/functional/_isFormatUriReference.js.map +1 -0
- package/lib/validators/functional/_isFormatUriReference.mjs +5 -0
- package/lib/validators/functional/_isFormatUriReference.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUriTemplate.d.ts +1 -0
- package/lib/validators/functional/_isFormatUriTemplate.js +7 -0
- package/lib/validators/functional/_isFormatUriTemplate.js.map +1 -0
- package/lib/validators/functional/_isFormatUriTemplate.mjs +5 -0
- package/lib/validators/functional/_isFormatUriTemplate.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUrl.d.ts +1 -0
- package/lib/validators/functional/_isFormatUrl.js +7 -0
- package/lib/validators/functional/_isFormatUrl.js.map +1 -0
- package/lib/validators/functional/_isFormatUrl.mjs +5 -0
- package/lib/validators/functional/_isFormatUrl.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUuid.d.ts +1 -0
- package/lib/validators/functional/_isFormatUuid.js +7 -0
- package/lib/validators/functional/_isFormatUuid.js.map +1 -0
- package/lib/validators/functional/_isFormatUuid.mjs +5 -0
- package/lib/validators/functional/_isFormatUuid.mjs.map +1 -0
- package/lib/validators/functional/_isUniqueItems.d.ts +1 -0
- package/lib/validators/functional/_isUniqueItems.js +140 -0
- package/lib/validators/functional/_isUniqueItems.js.map +1 -0
- package/lib/validators/functional/_isUniqueItems.mjs +138 -0
- package/lib/validators/functional/_isUniqueItems.mjs.map +1 -0
- package/lib/validators/index.d.ts +2 -0
- package/lib/validators/index.js +27 -0
- package/lib/validators/index.js.map +1 -0
- package/lib/validators/index.mjs +7 -0
- package/lib/validators/index.mjs.map +1 -0
- package/lib/validators/internal/IOpenApiValidatorContext.d.ts +14 -0
- package/lib/validators/internal/IOpenApiValidatorContext.js +3 -0
- package/lib/validators/internal/IOpenApiValidatorContext.js.map +1 -0
- package/lib/validators/internal/IOpenApiValidatorContext.mjs +2 -0
- package/lib/validators/internal/IOpenApiValidatorContext.mjs.map +1 -0
- package/lib/validators/internal/OpenApiArrayValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiArrayValidator.js +32 -0
- package/lib/validators/internal/OpenApiArrayValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiArrayValidator.mjs +47 -0
- package/lib/validators/internal/OpenApiArrayValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiBooleanValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiBooleanValidator.js +10 -0
- package/lib/validators/internal/OpenApiBooleanValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiBooleanValidator.mjs +9 -0
- package/lib/validators/internal/OpenApiBooleanValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiConstantValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiConstantValidator.js +10 -0
- package/lib/validators/internal/OpenApiConstantValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiConstantValidator.mjs +9 -0
- package/lib/validators/internal/OpenApiConstantValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiIntegerValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiIntegerValidator.js +33 -0
- package/lib/validators/internal/OpenApiIntegerValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiIntegerValidator.mjs +47 -0
- package/lib/validators/internal/OpenApiIntegerValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiNumberValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiNumberValidator.js +33 -0
- package/lib/validators/internal/OpenApiNumberValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiNumberValidator.mjs +47 -0
- package/lib/validators/internal/OpenApiNumberValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiObjectValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiObjectValidator.js +58 -0
- package/lib/validators/internal/OpenApiObjectValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiObjectValidator.mjs +68 -0
- package/lib/validators/internal/OpenApiObjectValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiOneOfValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiOneOfValidator.js +182 -0
- package/lib/validators/internal/OpenApiOneOfValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiOneOfValidator.mjs +206 -0
- package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.d.ts +4 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.js +122 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.js.map +1 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.mjs +121 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.mjs.map +1 -0
- package/lib/validators/internal/OpenApiStationValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiStationValidator.js +63 -0
- package/lib/validators/internal/OpenApiStationValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiStationValidator.mjs +107 -0
- package/lib/validators/internal/OpenApiStationValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiStringValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiStringValidator.js +73 -0
- package/lib/validators/internal/OpenApiStringValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiStringValidator.mjs +85 -0
- package/lib/validators/internal/OpenApiStringValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiTupleValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiTupleValidator.js +31 -0
- package/lib/validators/internal/OpenApiTupleValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiTupleValidator.mjs +46 -0
- package/lib/validators/internal/OpenApiTupleValidator.mjs.map +1 -0
- package/package.json +91 -0
- package/src/converters/LlmSchemaConverter.ts +924 -0
- package/src/converters/OpenApiConverter.ts +285 -0
- package/src/converters/index.ts +5 -0
- package/src/converters/internal/LlmDescriptionInverter.ts +178 -0
- package/src/converters/internal/LlmParametersComposer.ts +52 -0
- package/src/converters/internal/OpenApiConstraintShifter.ts +154 -0
- package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -0
- package/src/converters/internal/OpenApiV3Downgrader.ts +355 -0
- package/src/converters/internal/OpenApiV3Upgrader.ts +470 -0
- package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -0
- package/src/converters/internal/SwaggerV2Downgrader.ts +424 -0
- package/src/converters/internal/SwaggerV2Upgrader.ts +523 -0
- package/src/http/HttpError.ts +107 -0
- package/src/http/HttpLlm.ts +210 -0
- package/src/http/HttpMigration.ts +92 -0
- package/src/http/index.ts +3 -0
- package/src/http/internal/HttpLlmApplicationComposer.ts +308 -0
- package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -0
- package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -0
- package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -0
- package/src/http/internal/HttpMigrateRouteComposer.ts +513 -0
- package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -0
- package/src/http/internal/LlmDataMerger.ts +73 -0
- package/src/index.ts +4 -0
- package/src/utils/ArrayUtil.ts +42 -0
- package/src/utils/MapUtil.ts +15 -0
- package/src/utils/NamingConvention.ts +205 -0
- package/src/utils/Singleton.ts +17 -0
- package/src/utils/StringUtil.ts +14 -0
- package/src/utils/dedent.ts +57 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/internal/EndpointUtil.ts +44 -0
- package/src/utils/internal/JsonDescriptor.ts +70 -0
- package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -0
- package/src/utils/stringifyValidationFailure.ts +415 -0
- package/src/validators/LlmTypeChecker.ts +402 -0
- package/src/validators/OpenApiTypeChecker.ts +297 -0
- package/src/validators/OpenApiV3TypeChecker.ts +70 -0
- package/src/validators/OpenApiV3_1TypeChecker.ts +86 -0
- package/src/validators/OpenApiValidator.ts +94 -0
- package/src/validators/SwaggerV2TypeChecker.ts +71 -0
- package/src/validators/functional/_isBigintString.ts +8 -0
- package/src/validators/functional/_isFormatByte.ts +7 -0
- package/src/validators/functional/_isFormatDate.ts +3 -0
- package/src/validators/functional/_isFormatDateTime.ts +4 -0
- package/src/validators/functional/_isFormatDuration.ts +4 -0
- package/src/validators/functional/_isFormatEmail.ts +4 -0
- package/src/validators/functional/_isFormatHostname.ts +4 -0
- package/src/validators/functional/_isFormatIdnEmail.ts +4 -0
- package/src/validators/functional/_isFormatIdnHostname.ts +4 -0
- package/src/validators/functional/_isFormatIpv4.ts +4 -0
- package/src/validators/functional/_isFormatIpv6.ts +4 -0
- package/src/validators/functional/_isFormatIri.ts +3 -0
- package/src/validators/functional/_isFormatIriReference.ts +4 -0
- package/src/validators/functional/_isFormatJsonPointer.ts +3 -0
- package/src/validators/functional/_isFormatPassword.ts +1 -0
- package/src/validators/functional/_isFormatRegex.ts +8 -0
- package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -0
- package/src/validators/functional/_isFormatTime.ts +4 -0
- package/src/validators/functional/_isFormatUri.ts +6 -0
- package/src/validators/functional/_isFormatUriReference.ts +5 -0
- package/src/validators/functional/_isFormatUriTemplate.ts +4 -0
- package/src/validators/functional/_isFormatUrl.ts +4 -0
- package/src/validators/functional/_isFormatUuid.ts +3 -0
- package/src/validators/functional/_isUniqueItems.ts +159 -0
- package/src/validators/index.ts +14 -0
- package/src/validators/internal/IOpenApiValidatorContext.ts +17 -0
- package/src/validators/internal/OpenApiArrayValidator.ts +49 -0
- package/src/validators/internal/OpenApiBooleanValidator.ts +11 -0
- package/src/validators/internal/OpenApiConstantValidator.ts +11 -0
- package/src/validators/internal/OpenApiIntegerValidator.ts +49 -0
- package/src/validators/internal/OpenApiNumberValidator.ts +48 -0
- package/src/validators/internal/OpenApiObjectValidator.ts +83 -0
- package/src/validators/internal/OpenApiOneOfValidator.ts +309 -0
- package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -0
- package/src/validators/internal/OpenApiStationValidator.ts +115 -0
- package/src/validators/internal/OpenApiStringValidator.ts +88 -0
- package/src/validators/internal/OpenApiTupleValidator.ts +55 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import { IJsonSchemaAttribute, OpenApi, SwaggerV2 } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiTypeChecker } from "../../validators/OpenApiTypeChecker";
|
|
4
|
+
import { SwaggerV2TypeChecker } from "../../validators/SwaggerV2TypeChecker";
|
|
5
|
+
import { OpenApiExclusiveEmender } from "./OpenApiExclusiveEmender";
|
|
6
|
+
|
|
7
|
+
export namespace SwaggerV2Upgrader {
|
|
8
|
+
export const convert = (input: SwaggerV2.IDocument): OpenApi.IDocument => ({
|
|
9
|
+
openapi: "3.1.0",
|
|
10
|
+
info: input.info,
|
|
11
|
+
components: convertComponents(input),
|
|
12
|
+
paths: input.paths
|
|
13
|
+
? Object.fromEntries(
|
|
14
|
+
Object.entries(input.paths)
|
|
15
|
+
.filter(([_, v]) => v !== undefined)
|
|
16
|
+
.map(
|
|
17
|
+
([key, value]) => [key, convertPathItem(input)(value)] as const,
|
|
18
|
+
),
|
|
19
|
+
)
|
|
20
|
+
: undefined,
|
|
21
|
+
servers: input.host
|
|
22
|
+
? [
|
|
23
|
+
{
|
|
24
|
+
url: input.host,
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
: undefined,
|
|
28
|
+
security: input.security,
|
|
29
|
+
tags: input.tags,
|
|
30
|
+
"x-samchon-emended-v4": true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/* -----------------------------------------------------------
|
|
34
|
+
OPERATORS
|
|
35
|
+
----------------------------------------------------------- */
|
|
36
|
+
const convertPathItem =
|
|
37
|
+
(doc: SwaggerV2.IDocument) =>
|
|
38
|
+
(pathItem: SwaggerV2.IPath): OpenApi.IPath => ({
|
|
39
|
+
...(pathItem as any),
|
|
40
|
+
...(pathItem.get
|
|
41
|
+
? { get: convertOperation(doc)(pathItem)(pathItem.get) }
|
|
42
|
+
: undefined),
|
|
43
|
+
...(pathItem.put
|
|
44
|
+
? { put: convertOperation(doc)(pathItem)(pathItem.put) }
|
|
45
|
+
: undefined),
|
|
46
|
+
...(pathItem.post
|
|
47
|
+
? { post: convertOperation(doc)(pathItem)(pathItem.post) }
|
|
48
|
+
: undefined),
|
|
49
|
+
...(pathItem.delete
|
|
50
|
+
? { delete: convertOperation(doc)(pathItem)(pathItem.delete) }
|
|
51
|
+
: undefined),
|
|
52
|
+
...(pathItem.options
|
|
53
|
+
? { options: convertOperation(doc)(pathItem)(pathItem.options) }
|
|
54
|
+
: undefined),
|
|
55
|
+
...(pathItem.head
|
|
56
|
+
? { head: convertOperation(doc)(pathItem)(pathItem.head) }
|
|
57
|
+
: undefined),
|
|
58
|
+
...(pathItem.patch
|
|
59
|
+
? { patch: convertOperation(doc)(pathItem)(pathItem.patch) }
|
|
60
|
+
: undefined),
|
|
61
|
+
...(pathItem.trace
|
|
62
|
+
? { trace: convertOperation(doc)(pathItem)(pathItem.trace) }
|
|
63
|
+
: undefined),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const convertOperation =
|
|
67
|
+
(doc: SwaggerV2.IDocument) =>
|
|
68
|
+
(pathItem: SwaggerV2.IPath) =>
|
|
69
|
+
(input: SwaggerV2.IOperation): OpenApi.IOperation => ({
|
|
70
|
+
...input,
|
|
71
|
+
parameters:
|
|
72
|
+
pathItem.parameters !== undefined || input.parameters !== undefined
|
|
73
|
+
? (
|
|
74
|
+
[...(pathItem.parameters ?? []), ...(input.parameters ?? [])]
|
|
75
|
+
.map((p) =>
|
|
76
|
+
SwaggerV2TypeChecker.isReference(p)
|
|
77
|
+
? doc.parameters?.[p.$ref.split("/").pop() ?? ""]!
|
|
78
|
+
: p,
|
|
79
|
+
)
|
|
80
|
+
.filter(
|
|
81
|
+
(p) =>
|
|
82
|
+
p !== undefined &&
|
|
83
|
+
p.in !== "body" &&
|
|
84
|
+
(p as SwaggerV2.IOperation.IBodyParameter).schema ===
|
|
85
|
+
undefined,
|
|
86
|
+
) as SwaggerV2.IOperation.IGeneralParameter[]
|
|
87
|
+
).map(convertParameter(doc.definitions ?? {}))
|
|
88
|
+
: undefined,
|
|
89
|
+
requestBody: (() => {
|
|
90
|
+
const found: SwaggerV2.IOperation.IBodyParameter | undefined =
|
|
91
|
+
input.parameters?.find((p) => {
|
|
92
|
+
if (SwaggerV2TypeChecker.isReference(p))
|
|
93
|
+
p = doc.parameters?.[p.$ref.split("/").pop() ?? ""]!;
|
|
94
|
+
return (
|
|
95
|
+
(p as SwaggerV2.IOperation.IBodyParameter)?.schema !== undefined
|
|
96
|
+
);
|
|
97
|
+
}) as SwaggerV2.IOperation.IBodyParameter | undefined;
|
|
98
|
+
return found
|
|
99
|
+
? convertRequestBody(doc.definitions ?? {})(found)
|
|
100
|
+
: undefined;
|
|
101
|
+
})(),
|
|
102
|
+
responses: input.responses
|
|
103
|
+
? Object.fromEntries(
|
|
104
|
+
Object.entries(input.responses)
|
|
105
|
+
.filter(([_, v]) => v !== undefined)
|
|
106
|
+
.map(
|
|
107
|
+
([key, value]) => [key, convertResponse(doc)(value)!] as const,
|
|
108
|
+
)
|
|
109
|
+
.filter(([_, v]) => v !== undefined),
|
|
110
|
+
)
|
|
111
|
+
: undefined,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const convertParameter =
|
|
115
|
+
(definitions: Record<string, SwaggerV2.IJsonSchema>) =>
|
|
116
|
+
(
|
|
117
|
+
input: SwaggerV2.IOperation.IGeneralParameter,
|
|
118
|
+
): OpenApi.IOperation.IParameter => ({
|
|
119
|
+
name: input.name,
|
|
120
|
+
in: input.in as any,
|
|
121
|
+
description: input.description,
|
|
122
|
+
schema: convertSchema(definitions)(input),
|
|
123
|
+
required: true,
|
|
124
|
+
});
|
|
125
|
+
const convertRequestBody =
|
|
126
|
+
(definitions: Record<string, SwaggerV2.IJsonSchema>) =>
|
|
127
|
+
(
|
|
128
|
+
input: SwaggerV2.IOperation.IBodyParameter,
|
|
129
|
+
): OpenApi.IOperation.IRequestBody => ({
|
|
130
|
+
description: input.description,
|
|
131
|
+
content: {
|
|
132
|
+
"application/json": {
|
|
133
|
+
schema: convertSchema(definitions)(input.schema),
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const convertResponse =
|
|
139
|
+
(doc: SwaggerV2.IDocument) =>
|
|
140
|
+
(
|
|
141
|
+
input:
|
|
142
|
+
| SwaggerV2.IOperation.IResponse
|
|
143
|
+
| SwaggerV2.IJsonSchema.IReference<`#/definitions/responses/${string}`>,
|
|
144
|
+
): OpenApi.IOperation.IResponse | undefined => {
|
|
145
|
+
if (SwaggerV2TypeChecker.isReference(input)) {
|
|
146
|
+
const found: SwaggerV2.IOperation.IResponse | undefined =
|
|
147
|
+
doc.responses?.[input.$ref.split("/").pop() ?? ""]!;
|
|
148
|
+
if (found === undefined) return undefined;
|
|
149
|
+
input = found;
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
description: input.description,
|
|
153
|
+
content: input.schema
|
|
154
|
+
? {
|
|
155
|
+
"application/json": {
|
|
156
|
+
schema: convertSchema(doc.definitions ?? {})(input.schema),
|
|
157
|
+
example: input.example,
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
: undefined,
|
|
161
|
+
headers: input.headers
|
|
162
|
+
? Object.fromEntries(
|
|
163
|
+
Object.entries(input.headers)
|
|
164
|
+
.filter(([_, v]) => v !== undefined)
|
|
165
|
+
.map(
|
|
166
|
+
([key, value]) =>
|
|
167
|
+
[
|
|
168
|
+
key,
|
|
169
|
+
{
|
|
170
|
+
schema: convertSchema(doc.definitions ?? {})(value),
|
|
171
|
+
in: "header",
|
|
172
|
+
},
|
|
173
|
+
] as const,
|
|
174
|
+
),
|
|
175
|
+
)
|
|
176
|
+
: undefined,
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/* -----------------------------------------------------------
|
|
181
|
+
DEFINITIONS
|
|
182
|
+
----------------------------------------------------------- */
|
|
183
|
+
export const convertComponents = (
|
|
184
|
+
input: SwaggerV2.IDocument,
|
|
185
|
+
): OpenApi.IComponents => ({
|
|
186
|
+
schemas: Object.fromEntries(
|
|
187
|
+
Object.entries(input.definitions ?? {})
|
|
188
|
+
.filter(([_, v]) => v !== undefined)
|
|
189
|
+
.map(([key, value]) => [
|
|
190
|
+
key,
|
|
191
|
+
convertSchema(input.definitions ?? {})(value),
|
|
192
|
+
]),
|
|
193
|
+
),
|
|
194
|
+
securitySchemes: input.securityDefinitions
|
|
195
|
+
? Object.fromEntries(
|
|
196
|
+
Object.entries(input.securityDefinitions)
|
|
197
|
+
.filter(([_, v]) => v !== undefined)
|
|
198
|
+
.map(([key, value]) => [key, convertSecurityScheme(value)])
|
|
199
|
+
.filter(([_, v]) => v !== undefined),
|
|
200
|
+
)
|
|
201
|
+
: undefined,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const convertSecurityScheme = (
|
|
205
|
+
input: SwaggerV2.ISecurityDefinition,
|
|
206
|
+
): OpenApi.ISecurityScheme => {
|
|
207
|
+
if (input.type === "apiKey") return input;
|
|
208
|
+
else if (input.type === "basic")
|
|
209
|
+
return {
|
|
210
|
+
type: "http",
|
|
211
|
+
scheme: "basic",
|
|
212
|
+
description: input.description,
|
|
213
|
+
};
|
|
214
|
+
else if (input.type === "oauth2")
|
|
215
|
+
if (input.flow === "implicit")
|
|
216
|
+
return {
|
|
217
|
+
type: "oauth2",
|
|
218
|
+
description: input.description,
|
|
219
|
+
flows: {
|
|
220
|
+
implicit: {
|
|
221
|
+
authorizationUrl: input.authorizationUrl,
|
|
222
|
+
scopes: input.scopes,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
else if (input.flow === "accessCode")
|
|
227
|
+
return {
|
|
228
|
+
type: "oauth2",
|
|
229
|
+
description: input.description,
|
|
230
|
+
flows: {
|
|
231
|
+
authorizationCode: {
|
|
232
|
+
authorizationUrl: input.authorizationUrl,
|
|
233
|
+
tokenUrl: input.tokenUrl,
|
|
234
|
+
scopes: input.scopes,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
else if (input.flow === "password")
|
|
239
|
+
return {
|
|
240
|
+
type: "oauth2",
|
|
241
|
+
description: input.description,
|
|
242
|
+
flows: {
|
|
243
|
+
password: {
|
|
244
|
+
tokenUrl: input.tokenUrl,
|
|
245
|
+
scopes: input.scopes,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
else if (input.flow === "application")
|
|
250
|
+
return {
|
|
251
|
+
type: "oauth2",
|
|
252
|
+
description: input.description,
|
|
253
|
+
flows: {
|
|
254
|
+
clientCredentials: {
|
|
255
|
+
tokenUrl: input.tokenUrl,
|
|
256
|
+
scopes: input.scopes,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
else return undefined!;
|
|
261
|
+
return undefined!;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const convertSchema =
|
|
265
|
+
(definitions: Record<string, SwaggerV2.IJsonSchema>) =>
|
|
266
|
+
(input: SwaggerV2.IJsonSchema): OpenApi.IJsonSchema => {
|
|
267
|
+
const nullable: { value: boolean; default?: null } = {
|
|
268
|
+
value: false,
|
|
269
|
+
default: undefined,
|
|
270
|
+
};
|
|
271
|
+
const union: OpenApi.IJsonSchema[] = [];
|
|
272
|
+
const attribute: IJsonSchemaAttribute = {
|
|
273
|
+
title: input.title,
|
|
274
|
+
description: input.description,
|
|
275
|
+
deprecated: input.deprecated,
|
|
276
|
+
readOnly: input.readOnly,
|
|
277
|
+
example: input.example,
|
|
278
|
+
examples: input.examples
|
|
279
|
+
? Object.fromEntries(input.examples.map((v, i) => [`v${i}`, v]))
|
|
280
|
+
: undefined,
|
|
281
|
+
...Object.fromEntries(
|
|
282
|
+
Object.entries(input).filter(
|
|
283
|
+
([key, value]) => key.startsWith("x-") && value !== undefined,
|
|
284
|
+
),
|
|
285
|
+
),
|
|
286
|
+
};
|
|
287
|
+
const visit = (schema: SwaggerV2.IJsonSchema): void => {
|
|
288
|
+
// NULLABLE PROPERTY
|
|
289
|
+
if (
|
|
290
|
+
(schema as SwaggerV2.IJsonSchema.__ISignificant<any>)[
|
|
291
|
+
"x-nullable"
|
|
292
|
+
] === true
|
|
293
|
+
) {
|
|
294
|
+
nullable.value ||= true;
|
|
295
|
+
if ((schema as SwaggerV2.IJsonSchema.INumber).default === null)
|
|
296
|
+
nullable.default = null;
|
|
297
|
+
}
|
|
298
|
+
if (
|
|
299
|
+
Array.isArray((schema as SwaggerV2.IJsonSchema.INumber).enum) &&
|
|
300
|
+
(schema as SwaggerV2.IJsonSchema.INumber).enum?.length &&
|
|
301
|
+
(schema as SwaggerV2.IJsonSchema.INumber).enum?.some(
|
|
302
|
+
(e) => e === null,
|
|
303
|
+
)
|
|
304
|
+
)
|
|
305
|
+
nullable.value ||= true;
|
|
306
|
+
// UNION TYPE CASE
|
|
307
|
+
if (SwaggerV2TypeChecker.isAnyOf(schema))
|
|
308
|
+
schema["x-anyOf"].forEach(visit);
|
|
309
|
+
else if (SwaggerV2TypeChecker.isOneOf(schema))
|
|
310
|
+
schema["x-oneOf"].forEach(visit);
|
|
311
|
+
else if (SwaggerV2TypeChecker.isAllOf(schema))
|
|
312
|
+
if (schema.allOf.length === 1) visit(schema.allOf[0]!);
|
|
313
|
+
else union.push(convertAllOfSchema(definitions)(schema));
|
|
314
|
+
// ATOMIC TYPE CASE (CONSIDER ENUM VALUES)
|
|
315
|
+
else if (
|
|
316
|
+
SwaggerV2TypeChecker.isBoolean(schema) ||
|
|
317
|
+
SwaggerV2TypeChecker.isInteger(schema) ||
|
|
318
|
+
SwaggerV2TypeChecker.isNumber(schema) ||
|
|
319
|
+
SwaggerV2TypeChecker.isString(schema)
|
|
320
|
+
)
|
|
321
|
+
if (
|
|
322
|
+
schema.enum?.length &&
|
|
323
|
+
schema.enum.filter((e) => e !== null).length
|
|
324
|
+
)
|
|
325
|
+
union.push(
|
|
326
|
+
...schema.enum
|
|
327
|
+
.filter((v) => v !== null)
|
|
328
|
+
.map((value) => ({ const: value })),
|
|
329
|
+
);
|
|
330
|
+
else if (
|
|
331
|
+
SwaggerV2TypeChecker.isInteger(schema) ||
|
|
332
|
+
SwaggerV2TypeChecker.isNumber(schema)
|
|
333
|
+
)
|
|
334
|
+
union.push(
|
|
335
|
+
OpenApiExclusiveEmender.emend({
|
|
336
|
+
...schema,
|
|
337
|
+
default: (schema.default ?? undefined) satisfies
|
|
338
|
+
| boolean
|
|
339
|
+
| number
|
|
340
|
+
| string
|
|
341
|
+
| undefined as any,
|
|
342
|
+
examples: schema.examples
|
|
343
|
+
? Object.fromEntries(
|
|
344
|
+
schema.examples.map((v, i) => [`v${i}`, v]),
|
|
345
|
+
)
|
|
346
|
+
: undefined,
|
|
347
|
+
exclusiveMinimum:
|
|
348
|
+
typeof schema.exclusiveMinimum === "boolean"
|
|
349
|
+
? schema.exclusiveMinimum === true
|
|
350
|
+
? schema.minimum
|
|
351
|
+
: undefined
|
|
352
|
+
: schema.exclusiveMinimum,
|
|
353
|
+
exclusiveMaximum:
|
|
354
|
+
typeof schema.exclusiveMaximum === "boolean"
|
|
355
|
+
? schema.exclusiveMaximum === true
|
|
356
|
+
? schema.maximum
|
|
357
|
+
: undefined
|
|
358
|
+
: schema.exclusiveMaximum,
|
|
359
|
+
minimum:
|
|
360
|
+
schema.exclusiveMinimum === true ? undefined : schema.minimum,
|
|
361
|
+
maximum:
|
|
362
|
+
schema.exclusiveMaximum === true ? undefined : schema.maximum,
|
|
363
|
+
...{ enum: undefined },
|
|
364
|
+
}),
|
|
365
|
+
);
|
|
366
|
+
else
|
|
367
|
+
union.push({
|
|
368
|
+
...schema,
|
|
369
|
+
default: (schema.default ?? undefined) satisfies
|
|
370
|
+
| boolean
|
|
371
|
+
| number
|
|
372
|
+
| string
|
|
373
|
+
| undefined as any,
|
|
374
|
+
examples: schema.examples
|
|
375
|
+
? Object.fromEntries(
|
|
376
|
+
schema.examples.map((v, i) => [`v${i}`, v]),
|
|
377
|
+
)
|
|
378
|
+
: undefined,
|
|
379
|
+
...{ enum: undefined },
|
|
380
|
+
});
|
|
381
|
+
// INSTANCE TYPE CASE
|
|
382
|
+
else if (SwaggerV2TypeChecker.isArray(schema))
|
|
383
|
+
union.push({
|
|
384
|
+
...schema,
|
|
385
|
+
items: convertSchema(definitions)(schema.items),
|
|
386
|
+
examples: schema.examples
|
|
387
|
+
? Object.fromEntries(schema.examples.map((v, i) => [`v${i}`, v]))
|
|
388
|
+
: undefined,
|
|
389
|
+
});
|
|
390
|
+
else if (SwaggerV2TypeChecker.isObject(schema))
|
|
391
|
+
union.push({
|
|
392
|
+
...schema,
|
|
393
|
+
...{
|
|
394
|
+
properties: schema.properties
|
|
395
|
+
? Object.fromEntries(
|
|
396
|
+
Object.entries(schema.properties)
|
|
397
|
+
.filter(([_, v]) => v !== undefined)
|
|
398
|
+
.map(([key, value]) => [
|
|
399
|
+
key,
|
|
400
|
+
convertSchema(definitions)(value),
|
|
401
|
+
]),
|
|
402
|
+
)
|
|
403
|
+
: {},
|
|
404
|
+
additionalProperties: schema.additionalProperties
|
|
405
|
+
? typeof schema.additionalProperties === "object" &&
|
|
406
|
+
schema.additionalProperties !== null
|
|
407
|
+
? convertSchema(definitions)(schema.additionalProperties)
|
|
408
|
+
: schema.additionalProperties
|
|
409
|
+
: undefined,
|
|
410
|
+
},
|
|
411
|
+
examples: schema.examples
|
|
412
|
+
? Object.fromEntries(schema.examples.map((v, i) => [`v${i}`, v]))
|
|
413
|
+
: undefined,
|
|
414
|
+
required: schema.required ?? [],
|
|
415
|
+
});
|
|
416
|
+
else if (SwaggerV2TypeChecker.isReference(schema))
|
|
417
|
+
union.push({
|
|
418
|
+
...schema,
|
|
419
|
+
$ref: schema.$ref.replace(
|
|
420
|
+
"#/definitions/",
|
|
421
|
+
"#/components/schemas/",
|
|
422
|
+
),
|
|
423
|
+
examples: schema.examples
|
|
424
|
+
? Object.fromEntries(schema.examples.map((v, i) => [`v${i}`, v]))
|
|
425
|
+
: undefined,
|
|
426
|
+
});
|
|
427
|
+
else
|
|
428
|
+
union.push({
|
|
429
|
+
...schema,
|
|
430
|
+
examples: schema.examples
|
|
431
|
+
? Object.fromEntries(schema.examples.map((v, i) => [`v${i}`, v]))
|
|
432
|
+
: undefined,
|
|
433
|
+
});
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
visit(input);
|
|
437
|
+
if (
|
|
438
|
+
nullable.value === true &&
|
|
439
|
+
!union.some((e) => (e as OpenApi.IJsonSchema.INull).type === "null")
|
|
440
|
+
)
|
|
441
|
+
union.push({
|
|
442
|
+
type: "null",
|
|
443
|
+
default: nullable.default,
|
|
444
|
+
});
|
|
445
|
+
if (
|
|
446
|
+
union.length === 2 &&
|
|
447
|
+
union.filter((x) => OpenApiTypeChecker.isNull(x)).length === 1
|
|
448
|
+
) {
|
|
449
|
+
const type: OpenApi.IJsonSchema = union.filter(
|
|
450
|
+
(x) => OpenApiTypeChecker.isNull(x) === false,
|
|
451
|
+
)[0]!;
|
|
452
|
+
for (const key of [
|
|
453
|
+
"title",
|
|
454
|
+
"description",
|
|
455
|
+
"deprecated",
|
|
456
|
+
"example",
|
|
457
|
+
"examples",
|
|
458
|
+
] as const)
|
|
459
|
+
if (type[key] !== undefined) delete type[key];
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
...(union.length === 0
|
|
463
|
+
? { type: undefined }
|
|
464
|
+
: union.length === 1
|
|
465
|
+
? { ...union[0] }
|
|
466
|
+
: { oneOf: union.map((u) => ({ ...u, "x-nullable": undefined })) }),
|
|
467
|
+
...attribute,
|
|
468
|
+
...{ "x-nullable": undefined },
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
const convertAllOfSchema =
|
|
473
|
+
(definitions: Record<string, SwaggerV2.IJsonSchema>) =>
|
|
474
|
+
(input: SwaggerV2.IJsonSchema.IAllOf): OpenApi.IJsonSchema => {
|
|
475
|
+
const objects: Array<SwaggerV2.IJsonSchema.IObject | null> =
|
|
476
|
+
input.allOf.map((schema) => retrieveObject(definitions)(schema));
|
|
477
|
+
if (objects.some((obj) => obj === null))
|
|
478
|
+
return {
|
|
479
|
+
type: undefined,
|
|
480
|
+
...{
|
|
481
|
+
allOf: undefined,
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
return {
|
|
485
|
+
...input,
|
|
486
|
+
type: "object",
|
|
487
|
+
properties: Object.fromEntries(
|
|
488
|
+
objects
|
|
489
|
+
.map((o) => Object.entries(o?.properties ?? {}))
|
|
490
|
+
.flat()
|
|
491
|
+
.map(
|
|
492
|
+
([key, value]) =>
|
|
493
|
+
[key, convertSchema(definitions)(value)] as const,
|
|
494
|
+
),
|
|
495
|
+
),
|
|
496
|
+
...{
|
|
497
|
+
allOf: undefined,
|
|
498
|
+
required: [...new Set(objects.map((o) => o?.required ?? []).flat())],
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const retrieveObject =
|
|
504
|
+
(definitions: Record<string, SwaggerV2.IJsonSchema>) =>
|
|
505
|
+
(
|
|
506
|
+
input: SwaggerV2.IJsonSchema,
|
|
507
|
+
visited: Set<SwaggerV2.IJsonSchema> = new Set(),
|
|
508
|
+
): SwaggerV2.IJsonSchema.IObject | null => {
|
|
509
|
+
if (SwaggerV2TypeChecker.isObject(input))
|
|
510
|
+
return input.properties !== undefined && !input.additionalProperties
|
|
511
|
+
? input
|
|
512
|
+
: null;
|
|
513
|
+
else if (visited.has(input)) return null;
|
|
514
|
+
else visited.add(input);
|
|
515
|
+
|
|
516
|
+
if (SwaggerV2TypeChecker.isReference(input))
|
|
517
|
+
return retrieveObject(definitions)(
|
|
518
|
+
definitions?.[input.$ref.split("/").pop() ?? ""] ?? {},
|
|
519
|
+
visited,
|
|
520
|
+
);
|
|
521
|
+
return null;
|
|
522
|
+
};
|
|
523
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when HTTP request fails with non-2xx status.
|
|
3
|
+
*
|
|
4
|
+
* `HttpError` is thrown by {@link HttpLlm.execute} and
|
|
5
|
+
* {@link HttpMigration.execute} when the server returns a non-2xx status code.
|
|
6
|
+
* Contains the full HTTP context: method, path, status, headers, and response
|
|
7
|
+
* body.
|
|
8
|
+
*
|
|
9
|
+
* The response body is available via {@link message} (raw string) or
|
|
10
|
+
* {@link toJSON} (parsed JSON). For non-throwing behavior, use
|
|
11
|
+
* {@link HttpLlm.propagate} or {@link HttpMigration.propagate} instead.
|
|
12
|
+
*
|
|
13
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
14
|
+
*/
|
|
15
|
+
export class HttpError extends Error {
|
|
16
|
+
/** HTTP method used for the request. */
|
|
17
|
+
public readonly method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD";
|
|
18
|
+
|
|
19
|
+
/** Request path or URL. */
|
|
20
|
+
public readonly path: string;
|
|
21
|
+
|
|
22
|
+
/** HTTP status code from server. */
|
|
23
|
+
public readonly status: number;
|
|
24
|
+
|
|
25
|
+
/** Response headers from server. */
|
|
26
|
+
public readonly headers: Record<string, string | string[]>;
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
private body_: any = NOT_YET;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param method HTTP method
|
|
33
|
+
* @param path Request path or URL
|
|
34
|
+
* @param status HTTP status code
|
|
35
|
+
* @param headers Response headers
|
|
36
|
+
* @param message Error message (response body)
|
|
37
|
+
*/
|
|
38
|
+
public constructor(
|
|
39
|
+
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD",
|
|
40
|
+
path: string,
|
|
41
|
+
status: number,
|
|
42
|
+
headers: Record<string, string | string[]>,
|
|
43
|
+
message: string,
|
|
44
|
+
) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.method = method;
|
|
47
|
+
this.path = path;
|
|
48
|
+
this.status = status;
|
|
49
|
+
this.headers = headers;
|
|
50
|
+
|
|
51
|
+
// INHERITANCE POLYFILL
|
|
52
|
+
const proto: HttpError = new.target.prototype;
|
|
53
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
|
|
54
|
+
else (this as any).__proto__ = proto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Serialize to JSON-compatible object.
|
|
59
|
+
*
|
|
60
|
+
* Lazily parses JSON message body on first call. If parsing fails, returns
|
|
61
|
+
* the original string.
|
|
62
|
+
*
|
|
63
|
+
* @template T Expected response body type
|
|
64
|
+
* @returns Structured HTTP error information
|
|
65
|
+
*/
|
|
66
|
+
public toJSON<T>(): HttpError.IProps<T> {
|
|
67
|
+
if (this.body_ === NOT_YET)
|
|
68
|
+
try {
|
|
69
|
+
this.body_ = JSON.parse(this.message);
|
|
70
|
+
} catch {
|
|
71
|
+
this.body_ = this.message;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
method: this.method,
|
|
75
|
+
path: this.path,
|
|
76
|
+
status: this.status,
|
|
77
|
+
headers: this.headers,
|
|
78
|
+
message: this.body_,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export namespace HttpError {
|
|
83
|
+
/**
|
|
84
|
+
* JSON representation of HttpError.
|
|
85
|
+
*
|
|
86
|
+
* @template T Response body type
|
|
87
|
+
*/
|
|
88
|
+
export interface IProps<T> {
|
|
89
|
+
/** HTTP method. */
|
|
90
|
+
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD";
|
|
91
|
+
|
|
92
|
+
/** Request path or URL. */
|
|
93
|
+
path: string;
|
|
94
|
+
|
|
95
|
+
/** HTTP status code. */
|
|
96
|
+
status: number;
|
|
97
|
+
|
|
98
|
+
/** Response headers. */
|
|
99
|
+
headers: Record<string, string | string[]>;
|
|
100
|
+
|
|
101
|
+
/** Response body (parsed JSON or original string). */
|
|
102
|
+
message: T;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** @internal */
|
|
107
|
+
const NOT_YET = {} as any;
|