@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,285 @@
|
|
|
1
|
+
import { OpenApi, OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiV3Downgrader } from "./internal/OpenApiV3Downgrader";
|
|
4
|
+
import { OpenApiV3Upgrader } from "./internal/OpenApiV3Upgrader";
|
|
5
|
+
import { OpenApiV3_1Upgrader } from "./internal/OpenApiV3_1Upgrader";
|
|
6
|
+
import { SwaggerV2Downgrader } from "./internal/SwaggerV2Downgrader";
|
|
7
|
+
import { SwaggerV2Upgrader } from "./internal/SwaggerV2Upgrader";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* OpenAPI version converter.
|
|
11
|
+
*
|
|
12
|
+
* `OpenApiConverter` converts between different OpenAPI specification versions:
|
|
13
|
+
* Swagger v2.0, OpenAPI v3.0, OpenAPI v3.1, and typia's emended {@link OpenApi}
|
|
14
|
+
* format. Also converts individual components (schemas, operations, paths).
|
|
15
|
+
*
|
|
16
|
+
* Upgrade path (to emended v3.1):
|
|
17
|
+
*
|
|
18
|
+
* - Swagger v2.0 → emended v3.1
|
|
19
|
+
* - OpenAPI v3.0 → emended v3.1
|
|
20
|
+
* - OpenAPI v3.1 → emended v3.1
|
|
21
|
+
*
|
|
22
|
+
* Downgrade path (from emended v3.1):
|
|
23
|
+
*
|
|
24
|
+
* - Emended v3.1 → Swagger v2.0
|
|
25
|
+
* - Emended v3.1 → OpenAPI v3.0
|
|
26
|
+
*
|
|
27
|
+
* The emended format normalizes ambiguous expressions: dereferences `$ref`,
|
|
28
|
+
* merges `allOf`, converts `nullable` to union types, etc.
|
|
29
|
+
*
|
|
30
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
31
|
+
*/
|
|
32
|
+
export namespace OpenApiConverter {
|
|
33
|
+
/* -----------------------------------------------------------
|
|
34
|
+
DOCUMENTS
|
|
35
|
+
----------------------------------------------------------- */
|
|
36
|
+
/**
|
|
37
|
+
* Upgrade document to typia's emended OpenAPI v3.1 format.
|
|
38
|
+
*
|
|
39
|
+
* @param document Source document (Swagger v2.0, OpenAPI v3.0/v3.1)
|
|
40
|
+
* @returns Emended OpenAPI v3.1 document
|
|
41
|
+
*/
|
|
42
|
+
export function upgradeDocument(
|
|
43
|
+
document:
|
|
44
|
+
| SwaggerV2.IDocument
|
|
45
|
+
| OpenApiV3.IDocument
|
|
46
|
+
| OpenApiV3_1.IDocument
|
|
47
|
+
| OpenApi.IDocument,
|
|
48
|
+
): OpenApi.IDocument {
|
|
49
|
+
if (isUpgraded(document)) return document;
|
|
50
|
+
else if (is_v31(document)) return OpenApiV3_1Upgrader.convert(document);
|
|
51
|
+
else if (is_v30(document)) return OpenApiV3Upgrader.convert(document);
|
|
52
|
+
else if (is_v20(document)) return SwaggerV2Upgrader.convert(document);
|
|
53
|
+
document satisfies never;
|
|
54
|
+
throw new Error("Invalid OpenAPI document");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Downgrade document to Swagger v2.0 format.
|
|
59
|
+
*
|
|
60
|
+
* @param document Source emended OpenAPI document
|
|
61
|
+
* @param version Target version "2.0"
|
|
62
|
+
* @returns Swagger v2.0 document
|
|
63
|
+
*/
|
|
64
|
+
export function downgradeDocument(
|
|
65
|
+
document: OpenApi.IDocument,
|
|
66
|
+
version: "2.0",
|
|
67
|
+
): SwaggerV2.IDocument;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Downgrade document to OpenAPI v3.0 format.
|
|
71
|
+
*
|
|
72
|
+
* @param document Source emended OpenAPI document
|
|
73
|
+
* @param version Target version "3.0"
|
|
74
|
+
* @returns OpenAPI v3.0 document
|
|
75
|
+
*/
|
|
76
|
+
export function downgradeDocument(
|
|
77
|
+
document: OpenApi.IDocument,
|
|
78
|
+
version: "3.0",
|
|
79
|
+
): OpenApiV3.IDocument;
|
|
80
|
+
|
|
81
|
+
/** @internal */
|
|
82
|
+
export function downgradeDocument(
|
|
83
|
+
document: OpenApi.IDocument,
|
|
84
|
+
version: "2.0" | "3.0",
|
|
85
|
+
): SwaggerV2.IDocument | OpenApiV3.IDocument {
|
|
86
|
+
if (version === "2.0") return SwaggerV2Downgrader.downgrade(document);
|
|
87
|
+
else if (version === "3.0") return OpenApiV3Downgrader.downgrade(document);
|
|
88
|
+
version satisfies never;
|
|
89
|
+
throw new Error("Invalid OpenAPI version");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* -----------------------------------------------------------
|
|
93
|
+
COMPONENTS
|
|
94
|
+
----------------------------------------------------------- */
|
|
95
|
+
/**
|
|
96
|
+
* Upgrade components to typia's emended format.
|
|
97
|
+
*
|
|
98
|
+
* @param input Source components (Swagger v2.0, OpenAPI v3.0/v3.1)
|
|
99
|
+
* @returns Emended OpenAPI components
|
|
100
|
+
*/
|
|
101
|
+
export function upgradeComponents(
|
|
102
|
+
input:
|
|
103
|
+
| OpenApiV3_1.IComponents
|
|
104
|
+
| OpenApiV3.IComponents
|
|
105
|
+
| SwaggerV2.IDocument,
|
|
106
|
+
): OpenApi.IComponents {
|
|
107
|
+
if (is_v20(input)) return SwaggerV2Upgrader.convertComponents(input);
|
|
108
|
+
return OpenApiV3_1Upgrader.convertComponents(input);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Downgrade components to Swagger v2.0 definitions.
|
|
113
|
+
*
|
|
114
|
+
* @param input Source emended components
|
|
115
|
+
* @param version Target version "2.0"
|
|
116
|
+
* @returns Swagger v2.0 definitions record
|
|
117
|
+
*/
|
|
118
|
+
export function downgradeComponents(
|
|
119
|
+
input: OpenApi.IComponents,
|
|
120
|
+
version: "2.0",
|
|
121
|
+
): Record<string, SwaggerV2.IJsonSchema>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Downgrade components to OpenAPI v3.0 format.
|
|
125
|
+
*
|
|
126
|
+
* @param input Source emended components
|
|
127
|
+
* @param version Target version "3.0"
|
|
128
|
+
* @returns OpenAPI v3.0 components
|
|
129
|
+
*/
|
|
130
|
+
export function downgradeComponents(
|
|
131
|
+
input: OpenApi.IComponents,
|
|
132
|
+
version: "3.0",
|
|
133
|
+
): OpenApiV3.IComponents;
|
|
134
|
+
|
|
135
|
+
/** @internal */
|
|
136
|
+
export function downgradeComponents(
|
|
137
|
+
input: OpenApi.IComponents,
|
|
138
|
+
version: "2.0" | "3.0",
|
|
139
|
+
): Record<string, SwaggerV2.IJsonSchema> | OpenApiV3.IComponents {
|
|
140
|
+
if (version === "2.0")
|
|
141
|
+
return SwaggerV2Downgrader.downgradeComponents(input).downgraded;
|
|
142
|
+
return OpenApiV3Downgrader.downgradeComponents(input).downgraded;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* -----------------------------------------------------------
|
|
146
|
+
SCHEMAS
|
|
147
|
+
----------------------------------------------------------- */
|
|
148
|
+
/**
|
|
149
|
+
* Upgrade Swagger v2.0 schema to emended format.
|
|
150
|
+
*
|
|
151
|
+
* @param props.definitions Swagger v2.0 definitions
|
|
152
|
+
* @param props.schema Schema to upgrade
|
|
153
|
+
* @returns Emended JSON schema
|
|
154
|
+
*/
|
|
155
|
+
export function upgradeSchema(props: {
|
|
156
|
+
definitions: Record<string, SwaggerV2.IJsonSchema>;
|
|
157
|
+
schema: SwaggerV2.IJsonSchema;
|
|
158
|
+
}): OpenApi.IJsonSchema;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Upgrade OpenAPI v3.0 schema to emended format.
|
|
162
|
+
*
|
|
163
|
+
* @param props.components OpenAPI v3.0 components
|
|
164
|
+
* @param props.schema Schema to upgrade
|
|
165
|
+
* @returns Emended JSON schema
|
|
166
|
+
*/
|
|
167
|
+
export function upgradeSchema(props: {
|
|
168
|
+
components: OpenApiV3.IComponents;
|
|
169
|
+
schema: OpenApiV3.IJsonSchema;
|
|
170
|
+
}): OpenApi.IJsonSchema;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Upgrade OpenAPI v3.1 schema to emended format.
|
|
174
|
+
*
|
|
175
|
+
* @param props.components OpenAPI v3.1 components
|
|
176
|
+
* @param props.schema Schema to upgrade
|
|
177
|
+
* @returns Emended JSON schema
|
|
178
|
+
*/
|
|
179
|
+
export function upgradeSchema(props: {
|
|
180
|
+
components: OpenApiV3_1.IComponents;
|
|
181
|
+
schema: OpenApiV3_1.IJsonSchema;
|
|
182
|
+
}): OpenApi.IJsonSchema;
|
|
183
|
+
|
|
184
|
+
/** @internal */
|
|
185
|
+
export function upgradeSchema(
|
|
186
|
+
props:
|
|
187
|
+
| {
|
|
188
|
+
definitions: Record<string, SwaggerV2.IJsonSchema>;
|
|
189
|
+
schema: SwaggerV2.IJsonSchema;
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
components: OpenApiV3.IComponents;
|
|
193
|
+
schema: OpenApiV3.IJsonSchema;
|
|
194
|
+
}
|
|
195
|
+
| {
|
|
196
|
+
components: OpenApiV3_1.IComponents;
|
|
197
|
+
schema: OpenApiV3_1.IJsonSchema;
|
|
198
|
+
},
|
|
199
|
+
): OpenApi.IJsonSchema {
|
|
200
|
+
if ("definitions" in props)
|
|
201
|
+
return SwaggerV2Upgrader.convertSchema(props.definitions)(props.schema);
|
|
202
|
+
return OpenApiV3_1Upgrader.convertSchema(props.components)(props.schema);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Downgrade schema to Swagger v2.0 format.
|
|
207
|
+
*
|
|
208
|
+
* @param props.components Source emended components
|
|
209
|
+
* @param props.schema Schema to downgrade
|
|
210
|
+
* @param props.version Target version "2.0"
|
|
211
|
+
* @param props.downgraded Target definitions record (mutated)
|
|
212
|
+
* @returns Swagger v2.0 schema
|
|
213
|
+
*/
|
|
214
|
+
export function downgradeSchema(props: {
|
|
215
|
+
components: OpenApi.IComponents;
|
|
216
|
+
schema: OpenApi.IJsonSchema;
|
|
217
|
+
version: "2.0";
|
|
218
|
+
downgraded: Record<string, SwaggerV2.IJsonSchema>;
|
|
219
|
+
}): SwaggerV2.IJsonSchema;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Downgrade schema to OpenAPI v3.0 format.
|
|
223
|
+
*
|
|
224
|
+
* @param props.components Source emended components
|
|
225
|
+
* @param props.schema Schema to downgrade
|
|
226
|
+
* @param props.version Target version "3.0"
|
|
227
|
+
* @param props.downgraded Target components (mutated)
|
|
228
|
+
* @returns OpenAPI v3.0 schema
|
|
229
|
+
*/
|
|
230
|
+
export function downgradeSchema(props: {
|
|
231
|
+
components: OpenApi.IComponents;
|
|
232
|
+
schema: OpenApi.IJsonSchema;
|
|
233
|
+
version: "3.0";
|
|
234
|
+
downgraded: OpenApiV3.IComponents;
|
|
235
|
+
}): OpenApiV3.IJsonSchema;
|
|
236
|
+
|
|
237
|
+
/** @internal */
|
|
238
|
+
export function downgradeSchema<Version extends "2.0" | "3.0">(props: {
|
|
239
|
+
components: OpenApi.IComponents;
|
|
240
|
+
schema: OpenApi.IJsonSchema;
|
|
241
|
+
version: Version;
|
|
242
|
+
downgraded: Version extends "2.0"
|
|
243
|
+
? Record<string, SwaggerV2.IJsonSchema>
|
|
244
|
+
: OpenApiV3.IComponents;
|
|
245
|
+
}): OpenApiV3.IJsonSchema | SwaggerV2.IJsonSchema {
|
|
246
|
+
if (props.version === "2.0")
|
|
247
|
+
return SwaggerV2Downgrader.downgradeSchema({
|
|
248
|
+
original: props.components,
|
|
249
|
+
downgraded: props.downgraded as Record<string, SwaggerV2.IJsonSchema>,
|
|
250
|
+
})(props.schema);
|
|
251
|
+
return OpenApiV3Downgrader.downgradeSchema({
|
|
252
|
+
original: props.components,
|
|
253
|
+
downgraded: props.downgraded,
|
|
254
|
+
})(props.schema);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const is_v20 = (input: unknown): input is SwaggerV2.IDocument =>
|
|
259
|
+
typeof input === "object" &&
|
|
260
|
+
input !== null &&
|
|
261
|
+
"swagger" in input &&
|
|
262
|
+
typeof input.swagger === "string" &&
|
|
263
|
+
input.swagger.startsWith("2.0");
|
|
264
|
+
|
|
265
|
+
const is_v30 = (input: unknown): input is OpenApiV3.IDocument =>
|
|
266
|
+
typeof input === "object" &&
|
|
267
|
+
input !== null &&
|
|
268
|
+
"openapi" in input &&
|
|
269
|
+
typeof input.openapi === "string" &&
|
|
270
|
+
input.openapi.startsWith("3.0");
|
|
271
|
+
|
|
272
|
+
const is_v31 = (input: unknown): input is OpenApiV3_1.IDocument =>
|
|
273
|
+
typeof input === "object" &&
|
|
274
|
+
input !== null &&
|
|
275
|
+
"openapi" in input &&
|
|
276
|
+
typeof input.openapi === "string" &&
|
|
277
|
+
input.openapi.startsWith("3.1");
|
|
278
|
+
|
|
279
|
+
const isUpgraded = (input: unknown): input is OpenApi.IDocument =>
|
|
280
|
+
typeof input === "object" &&
|
|
281
|
+
input !== null &&
|
|
282
|
+
"openapi" in input &&
|
|
283
|
+
typeof input.openapi === "string" &&
|
|
284
|
+
input.openapi.startsWith("3.1") &&
|
|
285
|
+
(input as OpenApi.IDocument)["x-samchon-emended-v4"] === true;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiExclusiveEmender } from "./OpenApiExclusiveEmender";
|
|
4
|
+
|
|
5
|
+
export namespace LlmDescriptionInverter {
|
|
6
|
+
export const numeric = (
|
|
7
|
+
description: string | undefined,
|
|
8
|
+
): Pick<
|
|
9
|
+
OpenApi.IJsonSchema.INumber,
|
|
10
|
+
| "minimum"
|
|
11
|
+
| "maximum"
|
|
12
|
+
| "exclusiveMinimum"
|
|
13
|
+
| "exclusiveMaximum"
|
|
14
|
+
| "multipleOf"
|
|
15
|
+
| "description"
|
|
16
|
+
> => {
|
|
17
|
+
if (description === undefined) return {};
|
|
18
|
+
|
|
19
|
+
const lines: string[] = description.split("\n");
|
|
20
|
+
return OpenApiExclusiveEmender.emend({
|
|
21
|
+
minimum: find({
|
|
22
|
+
type: "number",
|
|
23
|
+
name: "minimum",
|
|
24
|
+
lines,
|
|
25
|
+
}),
|
|
26
|
+
maximum: find({
|
|
27
|
+
type: "number",
|
|
28
|
+
name: "maximum",
|
|
29
|
+
lines,
|
|
30
|
+
}),
|
|
31
|
+
exclusiveMinimum: find({
|
|
32
|
+
type: "number",
|
|
33
|
+
name: "exclusiveMinimum",
|
|
34
|
+
lines,
|
|
35
|
+
}),
|
|
36
|
+
exclusiveMaximum: find({
|
|
37
|
+
type: "number",
|
|
38
|
+
name: "exclusiveMaximum",
|
|
39
|
+
lines,
|
|
40
|
+
}),
|
|
41
|
+
multipleOf: find({
|
|
42
|
+
type: "number",
|
|
43
|
+
name: "multipleOf",
|
|
44
|
+
lines,
|
|
45
|
+
}),
|
|
46
|
+
description: describe(lines, [
|
|
47
|
+
"minimum",
|
|
48
|
+
"maximum",
|
|
49
|
+
"exclusiveMinimum",
|
|
50
|
+
"exclusiveMaximum",
|
|
51
|
+
"multipleOf",
|
|
52
|
+
]),
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const string = (
|
|
57
|
+
description: string | undefined,
|
|
58
|
+
): Pick<
|
|
59
|
+
OpenApi.IJsonSchema.IString,
|
|
60
|
+
| "format"
|
|
61
|
+
| "pattern"
|
|
62
|
+
| "contentMediaType"
|
|
63
|
+
| "minLength"
|
|
64
|
+
| "maxLength"
|
|
65
|
+
| "description"
|
|
66
|
+
> => {
|
|
67
|
+
if (description === undefined) return {};
|
|
68
|
+
|
|
69
|
+
const lines: string[] = description.split("\n");
|
|
70
|
+
return {
|
|
71
|
+
format: find({
|
|
72
|
+
type: "string",
|
|
73
|
+
name: "format",
|
|
74
|
+
lines,
|
|
75
|
+
}),
|
|
76
|
+
pattern: find({
|
|
77
|
+
type: "string",
|
|
78
|
+
name: "pattern",
|
|
79
|
+
lines,
|
|
80
|
+
}),
|
|
81
|
+
contentMediaType: find({
|
|
82
|
+
type: "string",
|
|
83
|
+
name: "contentMediaType",
|
|
84
|
+
lines,
|
|
85
|
+
}),
|
|
86
|
+
minLength: find({
|
|
87
|
+
type: "number",
|
|
88
|
+
name: "minLength",
|
|
89
|
+
lines,
|
|
90
|
+
}),
|
|
91
|
+
maxLength: find({
|
|
92
|
+
type: "number",
|
|
93
|
+
name: "maxLength",
|
|
94
|
+
lines,
|
|
95
|
+
}),
|
|
96
|
+
description: describe(lines, [
|
|
97
|
+
"format",
|
|
98
|
+
"pattern",
|
|
99
|
+
"contentMediaType",
|
|
100
|
+
"minLength",
|
|
101
|
+
"maxLength",
|
|
102
|
+
]),
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const array = (
|
|
107
|
+
description: string | undefined,
|
|
108
|
+
): Pick<
|
|
109
|
+
OpenApi.IJsonSchema.IArray,
|
|
110
|
+
"minItems" | "maxItems" | "uniqueItems" | "description"
|
|
111
|
+
> => {
|
|
112
|
+
if (description === undefined) return {};
|
|
113
|
+
|
|
114
|
+
const lines: string[] = description.split("\n");
|
|
115
|
+
return {
|
|
116
|
+
minItems: find({
|
|
117
|
+
type: "number",
|
|
118
|
+
name: "minItems",
|
|
119
|
+
lines,
|
|
120
|
+
}),
|
|
121
|
+
maxItems: find({
|
|
122
|
+
type: "number",
|
|
123
|
+
name: "maxItems",
|
|
124
|
+
lines,
|
|
125
|
+
}),
|
|
126
|
+
uniqueItems: find({
|
|
127
|
+
type: "boolean",
|
|
128
|
+
name: "uniqueItems",
|
|
129
|
+
lines,
|
|
130
|
+
}),
|
|
131
|
+
description: describe(lines, ["minItems", "maxItems", "uniqueItems"]),
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const find = <Type extends "boolean" | "number" | "string">(props: {
|
|
136
|
+
type: Type;
|
|
137
|
+
name: string;
|
|
138
|
+
lines: string[];
|
|
139
|
+
}):
|
|
140
|
+
| (Type extends "boolean" ? true : Type extends "number" ? number : string)
|
|
141
|
+
| undefined => {
|
|
142
|
+
if (props.type === "boolean")
|
|
143
|
+
return props.lines.some((line) => line.startsWith(`@${props.name}`))
|
|
144
|
+
? (true as any)
|
|
145
|
+
: (undefined as any);
|
|
146
|
+
for (const line of props.lines) {
|
|
147
|
+
if (line.startsWith(`@${props.name} `) === false) continue;
|
|
148
|
+
const value: string = line.replace(`@${props.name} `, "").trim();
|
|
149
|
+
if (props.type === "number")
|
|
150
|
+
return (isNaN(Number(value)) ? undefined : Number(value)) satisfies
|
|
151
|
+
| number
|
|
152
|
+
| undefined as any;
|
|
153
|
+
return value as any;
|
|
154
|
+
}
|
|
155
|
+
return undefined as any;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const describe = (lines: string[], tags: string[]): string | undefined => {
|
|
159
|
+
const ret: string = trimArray(
|
|
160
|
+
lines
|
|
161
|
+
.map((str) => str.trim())
|
|
162
|
+
.filter((str) =>
|
|
163
|
+
tags.every((tag) => str.startsWith(`@${tag}`) === false),
|
|
164
|
+
),
|
|
165
|
+
).join("\n");
|
|
166
|
+
return ret.length === 0 ? undefined : ret;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const trimArray = (array: string[]): string[] => {
|
|
170
|
+
let first: number = 0;
|
|
171
|
+
let last: number = array.length - 1;
|
|
172
|
+
|
|
173
|
+
for (; first < array.length; ++first)
|
|
174
|
+
if (array[first]!.trim().length !== 0) break;
|
|
175
|
+
for (; last >= 0; --last) if (array[last]!.trim().length !== 0) break;
|
|
176
|
+
return array.slice(first, last + 1);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IJsonSchemaTransformError, IResult, OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiTypeChecker } from "../../validators/OpenApiTypeChecker";
|
|
4
|
+
|
|
5
|
+
/** @internal */
|
|
6
|
+
export namespace LlmParametersFinder {
|
|
7
|
+
export const parameters = (props: {
|
|
8
|
+
components: OpenApi.IComponents;
|
|
9
|
+
schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference;
|
|
10
|
+
method: string;
|
|
11
|
+
accessor?: string;
|
|
12
|
+
refAccessor?: string;
|
|
13
|
+
}): IResult<OpenApi.IJsonSchema.IObject, IJsonSchemaTransformError> => {
|
|
14
|
+
const entity: IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =
|
|
15
|
+
OpenApiTypeChecker.unreference(props);
|
|
16
|
+
if (entity.success === false) return entity;
|
|
17
|
+
else if (OpenApiTypeChecker.isObject(entity.value) === false)
|
|
18
|
+
return reportError({
|
|
19
|
+
...props,
|
|
20
|
+
message: "LLM only accepts object type as parameters.",
|
|
21
|
+
});
|
|
22
|
+
else if (!!entity.value.additionalProperties)
|
|
23
|
+
return reportError({
|
|
24
|
+
...props,
|
|
25
|
+
message: "LLM does not allow additional properties on parameters.",
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
success: true,
|
|
29
|
+
value: entity.value,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const reportError = (props: {
|
|
34
|
+
method: string;
|
|
35
|
+
message: string;
|
|
36
|
+
schema: OpenApi.IJsonSchema;
|
|
37
|
+
accessor?: string;
|
|
38
|
+
}): IResult.IFailure<IJsonSchemaTransformError> => ({
|
|
39
|
+
success: false,
|
|
40
|
+
error: {
|
|
41
|
+
method: props.method,
|
|
42
|
+
message: `failed to compose LLM schema.`,
|
|
43
|
+
reasons: [
|
|
44
|
+
{
|
|
45
|
+
schema: props.schema,
|
|
46
|
+
message: props.message,
|
|
47
|
+
accessor: props.accessor ?? "$input.schema",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiExclusiveEmender } from "./OpenApiExclusiveEmender";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiConstraintShifter {
|
|
6
|
+
export const shiftArray = <
|
|
7
|
+
Schema extends Pick<
|
|
8
|
+
OpenApi.IJsonSchema.IArray,
|
|
9
|
+
"description" | "minItems" | "maxItems" | "uniqueItems"
|
|
10
|
+
>,
|
|
11
|
+
>(
|
|
12
|
+
schema: Schema,
|
|
13
|
+
): Omit<Schema, "minItems" | "maxItems" | "uniqueItems"> => {
|
|
14
|
+
const tags: string[] = [];
|
|
15
|
+
if (schema.minItems !== undefined) {
|
|
16
|
+
tags.push(`@minItems ${schema.minItems}`);
|
|
17
|
+
delete schema.minItems;
|
|
18
|
+
}
|
|
19
|
+
if (schema.maxItems !== undefined) {
|
|
20
|
+
tags.push(`@maxItems ${schema.maxItems}`);
|
|
21
|
+
delete schema.maxItems;
|
|
22
|
+
}
|
|
23
|
+
if (schema.uniqueItems !== undefined) {
|
|
24
|
+
if (schema.uniqueItems === true) tags.push(`@uniqueItems`);
|
|
25
|
+
delete schema.uniqueItems;
|
|
26
|
+
}
|
|
27
|
+
schema.description = writeTagWithDescription({
|
|
28
|
+
description: schema.description,
|
|
29
|
+
tags,
|
|
30
|
+
});
|
|
31
|
+
return schema;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const shiftNumeric = <
|
|
35
|
+
Schema extends Pick<
|
|
36
|
+
OpenApi.IJsonSchema.INumber | OpenApi.IJsonSchema.IInteger,
|
|
37
|
+
| "description"
|
|
38
|
+
| "minimum"
|
|
39
|
+
| "maximum"
|
|
40
|
+
| "exclusiveMinimum"
|
|
41
|
+
| "exclusiveMaximum"
|
|
42
|
+
| "multipleOf"
|
|
43
|
+
| "default"
|
|
44
|
+
>,
|
|
45
|
+
>(
|
|
46
|
+
schema: Schema,
|
|
47
|
+
): Omit<
|
|
48
|
+
Schema,
|
|
49
|
+
| "minimum"
|
|
50
|
+
| "maximum"
|
|
51
|
+
| "exclusiveMinimum"
|
|
52
|
+
| "exclusiveMaximum"
|
|
53
|
+
| "multipleOf"
|
|
54
|
+
| "default"
|
|
55
|
+
> => {
|
|
56
|
+
Object.assign(schema, OpenApiExclusiveEmender.emend(schema));
|
|
57
|
+
|
|
58
|
+
const tags: string[] = [];
|
|
59
|
+
if (schema.minimum !== undefined) {
|
|
60
|
+
tags.push(`@minimum ${schema.minimum}`);
|
|
61
|
+
delete schema.minimum;
|
|
62
|
+
}
|
|
63
|
+
if (schema.maximum !== undefined) {
|
|
64
|
+
tags.push(`@maximum ${schema.maximum}`);
|
|
65
|
+
delete schema.maximum;
|
|
66
|
+
}
|
|
67
|
+
if (schema.exclusiveMinimum !== undefined) {
|
|
68
|
+
tags.push(`@exclusiveMinimum ${schema.exclusiveMinimum}`);
|
|
69
|
+
delete schema.exclusiveMinimum;
|
|
70
|
+
}
|
|
71
|
+
if (schema.exclusiveMaximum !== undefined) {
|
|
72
|
+
tags.push(`@exclusiveMaximum ${schema.exclusiveMaximum}`);
|
|
73
|
+
delete schema.exclusiveMaximum;
|
|
74
|
+
}
|
|
75
|
+
if (schema.multipleOf !== undefined) {
|
|
76
|
+
tags.push(`@multipleOf ${schema.multipleOf}`);
|
|
77
|
+
delete schema.multipleOf;
|
|
78
|
+
}
|
|
79
|
+
schema.description = writeTagWithDescription({
|
|
80
|
+
description: schema.description,
|
|
81
|
+
tags,
|
|
82
|
+
});
|
|
83
|
+
if (schema.default !== undefined) {
|
|
84
|
+
tags.push(`@default ${schema.default}`);
|
|
85
|
+
delete schema.default;
|
|
86
|
+
}
|
|
87
|
+
return schema;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const shiftString = <
|
|
91
|
+
Schema extends Pick<
|
|
92
|
+
OpenApi.IJsonSchema.IString,
|
|
93
|
+
| "description"
|
|
94
|
+
| "minLength"
|
|
95
|
+
| "maxLength"
|
|
96
|
+
| "format"
|
|
97
|
+
| "pattern"
|
|
98
|
+
| "contentMediaType"
|
|
99
|
+
| "default"
|
|
100
|
+
>,
|
|
101
|
+
>(
|
|
102
|
+
schema: Schema,
|
|
103
|
+
): Omit<
|
|
104
|
+
Schema,
|
|
105
|
+
| "minLength"
|
|
106
|
+
| "maxLength"
|
|
107
|
+
| "format"
|
|
108
|
+
| "pattern"
|
|
109
|
+
| "contentMediaType"
|
|
110
|
+
| "default"
|
|
111
|
+
> => {
|
|
112
|
+
const tags: string[] = [];
|
|
113
|
+
if (schema.minLength !== undefined) {
|
|
114
|
+
tags.push(`@minLength ${schema.minLength}`);
|
|
115
|
+
delete schema.minLength;
|
|
116
|
+
}
|
|
117
|
+
if (schema.maxLength !== undefined) {
|
|
118
|
+
tags.push(`@maxLength ${schema.maxLength}`);
|
|
119
|
+
delete schema.maxLength;
|
|
120
|
+
}
|
|
121
|
+
if (schema.format !== undefined) {
|
|
122
|
+
tags.push(`@format ${schema.format}`);
|
|
123
|
+
delete schema.format;
|
|
124
|
+
}
|
|
125
|
+
if (schema.pattern !== undefined) {
|
|
126
|
+
tags.push(`@pattern ${schema.pattern}`);
|
|
127
|
+
delete schema.pattern;
|
|
128
|
+
}
|
|
129
|
+
if (schema.contentMediaType !== undefined) {
|
|
130
|
+
tags.push(`@contentMediaType ${schema.contentMediaType}`);
|
|
131
|
+
delete schema.contentMediaType;
|
|
132
|
+
}
|
|
133
|
+
if (schema.default !== undefined) {
|
|
134
|
+
tags.push(`@default ${schema.default}`);
|
|
135
|
+
delete schema.default;
|
|
136
|
+
}
|
|
137
|
+
schema.description = writeTagWithDescription({
|
|
138
|
+
description: schema.description,
|
|
139
|
+
tags,
|
|
140
|
+
});
|
|
141
|
+
return schema;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const writeTagWithDescription = (props: {
|
|
146
|
+
description: string | undefined;
|
|
147
|
+
tags: string[];
|
|
148
|
+
}): string | undefined => {
|
|
149
|
+
if (props.tags.length === 0) return props.description;
|
|
150
|
+
return [
|
|
151
|
+
...(props.description?.length ? [props.description, "\n"] : []),
|
|
152
|
+
...props.tags,
|
|
153
|
+
].join("\n");
|
|
154
|
+
};
|