@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,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IHttpConnection,
|
|
3
|
+
IHttpLlmApplication,
|
|
4
|
+
IHttpLlmController,
|
|
5
|
+
IHttpLlmFunction,
|
|
6
|
+
IHttpMigrateApplication,
|
|
7
|
+
IHttpResponse,
|
|
8
|
+
ILlmFunction,
|
|
9
|
+
OpenApi,
|
|
10
|
+
OpenApiV3,
|
|
11
|
+
OpenApiV3_1,
|
|
12
|
+
SwaggerV2,
|
|
13
|
+
} from "@typia/interface";
|
|
14
|
+
|
|
15
|
+
import { HttpMigration } from "./HttpMigration";
|
|
16
|
+
import { HttpLlmApplicationComposer } from "./internal/HttpLlmApplicationComposer";
|
|
17
|
+
import { HttpLlmFunctionFetcher } from "./internal/HttpLlmFunctionFetcher";
|
|
18
|
+
import { LlmDataMerger } from "./internal/LlmDataMerger";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* LLM function calling utilities for OpenAPI documents.
|
|
22
|
+
*
|
|
23
|
+
* `HttpLlm` converts OpenAPI documents into LLM function calling applications
|
|
24
|
+
* and executes them. Supports all OpenAPI versions (Swagger 2.0, OpenAPI 3.0,
|
|
25
|
+
* 3.1) through automatic conversion to {@link OpenApi} format.
|
|
26
|
+
*
|
|
27
|
+
* Main functions:
|
|
28
|
+
*
|
|
29
|
+
* - {@link controller}: Create {@link IHttpLlmController} from OpenAPI document
|
|
30
|
+
* - {@link application}: Convert OpenAPI document to {@link IHttpLlmApplication}
|
|
31
|
+
* - {@link execute}: Call an LLM function and return the response body
|
|
32
|
+
* - {@link propagate}: Call an LLM function and return full HTTP response
|
|
33
|
+
* - {@link mergeParameters}: Merge LLM-filled and human-filled parameters
|
|
34
|
+
*
|
|
35
|
+
* Typical workflow:
|
|
36
|
+
*
|
|
37
|
+
* 1. Load OpenAPI document (JSON/YAML)
|
|
38
|
+
* 2. Call `HttpLlm.application()` to get function schemas
|
|
39
|
+
* 3. Send function schemas to LLM for function selection
|
|
40
|
+
* 4. Call `HttpLlm.execute()` with LLM's chosen function and arguments
|
|
41
|
+
*
|
|
42
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
43
|
+
*/
|
|
44
|
+
export namespace HttpLlm {
|
|
45
|
+
/* -----------------------------------------------------------
|
|
46
|
+
COMPOSERS
|
|
47
|
+
----------------------------------------------------------- */
|
|
48
|
+
/**
|
|
49
|
+
* Create HTTP LLM controller from OpenAPI document.
|
|
50
|
+
*
|
|
51
|
+
* Composes {@link IHttpLlmController} from OpenAPI document with connection
|
|
52
|
+
* info. The controller can be used with {@link registerMcpControllers} to
|
|
53
|
+
* register all API operations as MCP tools at once.
|
|
54
|
+
*
|
|
55
|
+
* @param props Controller properties
|
|
56
|
+
* @returns HTTP LLM controller
|
|
57
|
+
*/
|
|
58
|
+
export const controller = (props: {
|
|
59
|
+
/** Identifier name of the controller. */
|
|
60
|
+
name: string;
|
|
61
|
+
|
|
62
|
+
/** OpenAPI document to convert. */
|
|
63
|
+
document:
|
|
64
|
+
| OpenApi.IDocument
|
|
65
|
+
| SwaggerV2.IDocument
|
|
66
|
+
| OpenApiV3.IDocument
|
|
67
|
+
| OpenApiV3_1.IDocument;
|
|
68
|
+
|
|
69
|
+
/** Connection to the API server. */
|
|
70
|
+
connection: IHttpConnection;
|
|
71
|
+
|
|
72
|
+
/** LLM schema conversion configuration. */
|
|
73
|
+
config?: Partial<IHttpLlmApplication.IConfig>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Custom executor of the API function.
|
|
77
|
+
*
|
|
78
|
+
* Default executor is {@link HttpLlm.execute} function.
|
|
79
|
+
*/
|
|
80
|
+
execute?: IHttpLlmController["execute"];
|
|
81
|
+
}): IHttpLlmController => ({
|
|
82
|
+
protocol: "http",
|
|
83
|
+
name: props.name,
|
|
84
|
+
application: application({
|
|
85
|
+
document: props.document,
|
|
86
|
+
config: props.config,
|
|
87
|
+
}),
|
|
88
|
+
connection: props.connection,
|
|
89
|
+
execute: props.execute,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Convert OpenAPI document to LLM function calling application.
|
|
94
|
+
*
|
|
95
|
+
* Converts API operations to LLM-callable functions. Use
|
|
96
|
+
* {@link mergeParameters} if `separate` option is configured.
|
|
97
|
+
*
|
|
98
|
+
* @param props Composition properties
|
|
99
|
+
* @returns LLM function calling application
|
|
100
|
+
*/
|
|
101
|
+
export const application = (props: {
|
|
102
|
+
/** OpenAPI document to convert. */
|
|
103
|
+
document:
|
|
104
|
+
| OpenApi.IDocument
|
|
105
|
+
| SwaggerV2.IDocument
|
|
106
|
+
| OpenApiV3.IDocument
|
|
107
|
+
| OpenApiV3_1.IDocument;
|
|
108
|
+
|
|
109
|
+
/** LLM schema conversion configuration. */
|
|
110
|
+
config?: Partial<IHttpLlmApplication.IConfig>;
|
|
111
|
+
}): IHttpLlmApplication => {
|
|
112
|
+
// MIGRATE
|
|
113
|
+
const migrate: IHttpMigrateApplication = HttpMigration.application(
|
|
114
|
+
props.document,
|
|
115
|
+
);
|
|
116
|
+
return HttpLlmApplicationComposer.application({
|
|
117
|
+
migrate,
|
|
118
|
+
config: {
|
|
119
|
+
reference: props.config?.reference ?? true,
|
|
120
|
+
strict: props.config?.strict ?? false,
|
|
121
|
+
separate: props.config?.separate ?? null,
|
|
122
|
+
maxLength: props.config?.maxLength ?? 64,
|
|
123
|
+
equals: props.config?.equals ?? false,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/* -----------------------------------------------------------
|
|
129
|
+
FETCHERS
|
|
130
|
+
----------------------------------------------------------- */
|
|
131
|
+
/** Properties for LLM function call. */
|
|
132
|
+
export interface IFetchProps {
|
|
133
|
+
/** LLM function calling application. */
|
|
134
|
+
application: IHttpLlmApplication;
|
|
135
|
+
|
|
136
|
+
/** Function to call. */
|
|
137
|
+
function: IHttpLlmFunction;
|
|
138
|
+
|
|
139
|
+
/** HTTP connection info. */
|
|
140
|
+
connection: IHttpConnection;
|
|
141
|
+
|
|
142
|
+
/** Function arguments. */
|
|
143
|
+
input: object;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Execute LLM function call.
|
|
148
|
+
*
|
|
149
|
+
* Calls API endpoint and returns response body. Throws {@link HttpError} on
|
|
150
|
+
* non-2xx status.
|
|
151
|
+
*
|
|
152
|
+
* @param props Function call properties
|
|
153
|
+
* @returns Response body
|
|
154
|
+
* @throws HttpError on non-2xx status
|
|
155
|
+
*/
|
|
156
|
+
export const execute = (props: IFetchProps): Promise<unknown> =>
|
|
157
|
+
HttpLlmFunctionFetcher.execute(props);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Propagate LLM function call.
|
|
161
|
+
*
|
|
162
|
+
* Calls API endpoint and returns full response including non-2xx. Use when
|
|
163
|
+
* you need to handle error responses yourself.
|
|
164
|
+
*
|
|
165
|
+
* @param props Function call properties
|
|
166
|
+
* @returns Full HTTP response
|
|
167
|
+
* @throws Error only on connection failure
|
|
168
|
+
*/
|
|
169
|
+
export const propagate = (props: IFetchProps): Promise<IHttpResponse> =>
|
|
170
|
+
HttpLlmFunctionFetcher.propagate(props);
|
|
171
|
+
|
|
172
|
+
/* -----------------------------------------------------------
|
|
173
|
+
MERGERS
|
|
174
|
+
----------------------------------------------------------- */
|
|
175
|
+
/** Properties for parameter merging. */
|
|
176
|
+
export interface IMergeProps {
|
|
177
|
+
/** Target function metadata. */
|
|
178
|
+
function: ILlmFunction;
|
|
179
|
+
|
|
180
|
+
/** LLM-provided arguments. */
|
|
181
|
+
llm: object | null;
|
|
182
|
+
|
|
183
|
+
/** Human-provided arguments. */
|
|
184
|
+
human: object | null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Merge separated parameters.
|
|
189
|
+
*
|
|
190
|
+
* Combines human and LLM parameters when `separate` option was used. Throws
|
|
191
|
+
* error if `separate` was not configured.
|
|
192
|
+
*
|
|
193
|
+
* @param props Merge properties
|
|
194
|
+
* @returns Merged parameters
|
|
195
|
+
*/
|
|
196
|
+
export const mergeParameters = (props: IMergeProps): object =>
|
|
197
|
+
LlmDataMerger.parameters(props);
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Merge two values.
|
|
201
|
+
*
|
|
202
|
+
* Objects are merged at property level. Primitives return `y ?? x`.
|
|
203
|
+
*
|
|
204
|
+
* @param x First value
|
|
205
|
+
* @param y Second value (preferred)
|
|
206
|
+
* @returns Merged value
|
|
207
|
+
*/
|
|
208
|
+
export const mergeValue = (x: unknown, y: unknown): unknown =>
|
|
209
|
+
LlmDataMerger.value(x, y);
|
|
210
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IHttpConnection,
|
|
3
|
+
IHttpMigrateApplication,
|
|
4
|
+
IHttpMigrateRoute,
|
|
5
|
+
IHttpResponse,
|
|
6
|
+
OpenApi,
|
|
7
|
+
OpenApiV3,
|
|
8
|
+
OpenApiV3_1,
|
|
9
|
+
SwaggerV2,
|
|
10
|
+
} from "@typia/interface";
|
|
11
|
+
|
|
12
|
+
import { OpenApiConverter } from "../converters/OpenApiConverter";
|
|
13
|
+
import { HttpMigrateApplicationComposer } from "./internal/HttpMigrateApplicationComposer";
|
|
14
|
+
import { HttpMigrateRouteFetcher } from "./internal/HttpMigrateRouteFetcher";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* OpenAPI to HTTP migration utilities.
|
|
18
|
+
*
|
|
19
|
+
* `HttpMigration` converts OpenAPI documents into executable HTTP routes
|
|
20
|
+
* ({@link IHttpMigrateApplication}). Unlike {@link HttpLlm} which targets LLM
|
|
21
|
+
* function calling, this focuses on SDK/client code generation.
|
|
22
|
+
*
|
|
23
|
+
* Supports all OpenAPI versions (Swagger 2.0, OpenAPI 3.0, 3.1) through
|
|
24
|
+
* automatic conversion to normalized {@link OpenApi} format.
|
|
25
|
+
*
|
|
26
|
+
* Main functions:
|
|
27
|
+
*
|
|
28
|
+
* - {@link application}: Convert OpenAPI document to
|
|
29
|
+
* {@link IHttpMigrateApplication}
|
|
30
|
+
* - {@link execute}: Call a route and return response body
|
|
31
|
+
* - {@link propagate}: Call a route and return full HTTP response (including
|
|
32
|
+
* non-2xx)
|
|
33
|
+
*
|
|
34
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
35
|
+
*/
|
|
36
|
+
export namespace HttpMigration {
|
|
37
|
+
/**
|
|
38
|
+
* Convert OpenAPI document to migration application.
|
|
39
|
+
*
|
|
40
|
+
* @param document OpenAPI document (any version)
|
|
41
|
+
* @returns Migration application with callable routes
|
|
42
|
+
*/
|
|
43
|
+
export const application = (
|
|
44
|
+
document:
|
|
45
|
+
| OpenApi.IDocument
|
|
46
|
+
| SwaggerV2.IDocument
|
|
47
|
+
| OpenApiV3.IDocument
|
|
48
|
+
| OpenApiV3_1.IDocument,
|
|
49
|
+
): IHttpMigrateApplication =>
|
|
50
|
+
HttpMigrateApplicationComposer.compose(
|
|
51
|
+
OpenApiConverter.upgradeDocument(document),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Execute HTTP route.
|
|
56
|
+
*
|
|
57
|
+
* @param props Fetch properties
|
|
58
|
+
* @returns Response body
|
|
59
|
+
* @throws HttpError on non-2xx status
|
|
60
|
+
*/
|
|
61
|
+
export const execute = (props: IFetchProps): Promise<unknown> =>
|
|
62
|
+
HttpMigrateRouteFetcher.execute(props);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Execute HTTP route and return full response.
|
|
66
|
+
*
|
|
67
|
+
* @param props Fetch properties
|
|
68
|
+
* @returns Full HTTP response including non-2xx
|
|
69
|
+
*/
|
|
70
|
+
export const propagate = (props: IFetchProps): Promise<IHttpResponse> =>
|
|
71
|
+
HttpMigrateRouteFetcher.propagate(props);
|
|
72
|
+
|
|
73
|
+
/** Properties for HTTP route execution. */
|
|
74
|
+
export interface IFetchProps {
|
|
75
|
+
/** HTTP connection info. */
|
|
76
|
+
connection: IHttpConnection;
|
|
77
|
+
|
|
78
|
+
/** Route to execute. */
|
|
79
|
+
route: IHttpMigrateRoute;
|
|
80
|
+
|
|
81
|
+
/** Path parameters. */
|
|
82
|
+
parameters:
|
|
83
|
+
| Array<string | number | boolean | bigint | null>
|
|
84
|
+
| Record<string, string | number | boolean | bigint | null>;
|
|
85
|
+
|
|
86
|
+
/** Query parameters. */
|
|
87
|
+
query?: object | undefined;
|
|
88
|
+
|
|
89
|
+
/** Request body. */
|
|
90
|
+
body?: object | undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IHttpLlmApplication,
|
|
3
|
+
IHttpLlmFunction,
|
|
4
|
+
IHttpMigrateApplication,
|
|
5
|
+
IHttpMigrateRoute,
|
|
6
|
+
IJsonSchemaTransformError,
|
|
7
|
+
ILlmSchema,
|
|
8
|
+
IResult,
|
|
9
|
+
OpenApi,
|
|
10
|
+
} from "@typia/interface";
|
|
11
|
+
|
|
12
|
+
import { LlmSchemaConverter } from "../../converters";
|
|
13
|
+
import { OpenApiValidator } from "../../validators/OpenApiValidator";
|
|
14
|
+
|
|
15
|
+
export namespace HttpLlmApplicationComposer {
|
|
16
|
+
export const application = (props: {
|
|
17
|
+
migrate: IHttpMigrateApplication;
|
|
18
|
+
config?: Partial<IHttpLlmApplication.IConfig>;
|
|
19
|
+
}): IHttpLlmApplication => {
|
|
20
|
+
// COMPOSE FUNCTIONS
|
|
21
|
+
const config: IHttpLlmApplication.IConfig = {
|
|
22
|
+
separate: props.config?.separate ?? null,
|
|
23
|
+
maxLength: props.config?.maxLength ?? 64,
|
|
24
|
+
equals: props.config?.equals ?? false,
|
|
25
|
+
reference: props.config?.reference ?? true,
|
|
26
|
+
strict: props.config?.strict ?? false,
|
|
27
|
+
};
|
|
28
|
+
const errors: IHttpLlmApplication.IError[] = props.migrate.errors
|
|
29
|
+
.filter((e) => e.operation()["x-samchon-human"] !== true)
|
|
30
|
+
.map((e) => ({
|
|
31
|
+
method: e.method,
|
|
32
|
+
path: e.path,
|
|
33
|
+
messages: e.messages,
|
|
34
|
+
operation: () => e.operation(),
|
|
35
|
+
route: () => undefined,
|
|
36
|
+
}));
|
|
37
|
+
const functions: IHttpLlmFunction[] = props.migrate.routes
|
|
38
|
+
.filter((e) => e.operation()["x-samchon-human"] !== true)
|
|
39
|
+
.map((route, i) => {
|
|
40
|
+
if (route.method === "head") {
|
|
41
|
+
errors.push({
|
|
42
|
+
method: route.method,
|
|
43
|
+
path: route.path,
|
|
44
|
+
messages: ["HEAD method is not supported in the LLM application."],
|
|
45
|
+
operation: () => route.operation(),
|
|
46
|
+
route: () => route as any as IHttpMigrateRoute,
|
|
47
|
+
});
|
|
48
|
+
return null;
|
|
49
|
+
} else if (
|
|
50
|
+
route.body?.type === "multipart/form-data" ||
|
|
51
|
+
route.success?.type === "multipart/form-data"
|
|
52
|
+
) {
|
|
53
|
+
errors.push({
|
|
54
|
+
method: route.method,
|
|
55
|
+
path: route.path,
|
|
56
|
+
messages: [
|
|
57
|
+
`The "multipart/form-data" content type is not supported in the LLM application.`,
|
|
58
|
+
],
|
|
59
|
+
operation: () => route.operation(),
|
|
60
|
+
route: () => route as any as IHttpMigrateRoute,
|
|
61
|
+
});
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const localErrors: string[] = [];
|
|
65
|
+
const func: IHttpLlmFunction | null = composeFunction({
|
|
66
|
+
components: props.migrate.document().components,
|
|
67
|
+
config,
|
|
68
|
+
route,
|
|
69
|
+
errors: localErrors,
|
|
70
|
+
index: i,
|
|
71
|
+
});
|
|
72
|
+
if (func === null)
|
|
73
|
+
errors.push({
|
|
74
|
+
method: route.method,
|
|
75
|
+
path: route.path,
|
|
76
|
+
messages: localErrors,
|
|
77
|
+
operation: () => route.operation(),
|
|
78
|
+
route: () => route as any as IHttpMigrateRoute,
|
|
79
|
+
});
|
|
80
|
+
return func;
|
|
81
|
+
})
|
|
82
|
+
.filter((v): v is IHttpLlmFunction => v !== null);
|
|
83
|
+
|
|
84
|
+
const app: IHttpLlmApplication = {
|
|
85
|
+
config,
|
|
86
|
+
functions,
|
|
87
|
+
errors,
|
|
88
|
+
};
|
|
89
|
+
shorten(app, props.config?.maxLength ?? 64);
|
|
90
|
+
return app;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const composeFunction = (props: {
|
|
94
|
+
components: OpenApi.IComponents;
|
|
95
|
+
route: IHttpMigrateRoute;
|
|
96
|
+
config: IHttpLlmApplication.IConfig;
|
|
97
|
+
errors: string[];
|
|
98
|
+
index: number;
|
|
99
|
+
}): IHttpLlmFunction | null => {
|
|
100
|
+
// METADATA
|
|
101
|
+
const endpoint: string = `$input.paths[${JSON.stringify(props.route.path)}][${JSON.stringify(props.route.method)}]`;
|
|
102
|
+
const operation: OpenApi.IOperation = props.route.operation();
|
|
103
|
+
const description: [string | undefined, number] = (() => {
|
|
104
|
+
if (!operation.summary?.length || !operation.description?.length)
|
|
105
|
+
return [
|
|
106
|
+
operation.summary || operation.description,
|
|
107
|
+
operation.summary?.length ?? operation.description?.length ?? 0,
|
|
108
|
+
];
|
|
109
|
+
const summary: string = operation.summary.endsWith(".")
|
|
110
|
+
? operation.summary.slice(0, -1)
|
|
111
|
+
: operation.summary;
|
|
112
|
+
const final: string = operation.description.startsWith(summary)
|
|
113
|
+
? operation.description
|
|
114
|
+
: summary + ".\n\n" + operation.description;
|
|
115
|
+
return [final, final.length];
|
|
116
|
+
})();
|
|
117
|
+
if (description[1] > 1_024) {
|
|
118
|
+
props.errors.push(
|
|
119
|
+
`The description of the function is too long (must be equal or less than 1,024 characters, but ${description[1].toLocaleString()} length).`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// FUNCTION NAME
|
|
124
|
+
const name: string = emend(props.route.accessor.join("_"));
|
|
125
|
+
const isNameVariable: boolean = /^[a-zA-Z0-9_-]+$/.test(name);
|
|
126
|
+
const isNameStartsWithNumber: boolean = /^[0-9]/.test(name[0] ?? "");
|
|
127
|
+
if (isNameVariable === false)
|
|
128
|
+
props.errors.push(
|
|
129
|
+
`Elements of path (separated by '/') must be composed with alphabets, numbers, underscores, and hyphens`,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
//----
|
|
133
|
+
// CONSTRUCT SCHEMAS
|
|
134
|
+
//----
|
|
135
|
+
// PARAMETERS
|
|
136
|
+
const parameters: OpenApi.IJsonSchema.IObject = {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: Object.fromEntries([
|
|
139
|
+
...props.route.parameters.map(
|
|
140
|
+
(s) =>
|
|
141
|
+
[
|
|
142
|
+
s.key,
|
|
143
|
+
{
|
|
144
|
+
...s.schema,
|
|
145
|
+
description: s.parameter().description ?? s.schema.description,
|
|
146
|
+
},
|
|
147
|
+
] as const,
|
|
148
|
+
),
|
|
149
|
+
...(props.route.query
|
|
150
|
+
? [
|
|
151
|
+
[
|
|
152
|
+
props.route.query.key,
|
|
153
|
+
{
|
|
154
|
+
...props.route.query.schema,
|
|
155
|
+
title:
|
|
156
|
+
props.route.query.title() ?? props.route.query.schema.title,
|
|
157
|
+
description:
|
|
158
|
+
props.route.query.description() ??
|
|
159
|
+
props.route.query.schema.description,
|
|
160
|
+
},
|
|
161
|
+
] as const,
|
|
162
|
+
]
|
|
163
|
+
: []),
|
|
164
|
+
...(props.route.body
|
|
165
|
+
? [
|
|
166
|
+
[
|
|
167
|
+
props.route.body.key,
|
|
168
|
+
{
|
|
169
|
+
...props.route.body.schema,
|
|
170
|
+
description:
|
|
171
|
+
props.route.body.description() ??
|
|
172
|
+
props.route.body.schema.description,
|
|
173
|
+
},
|
|
174
|
+
] as const,
|
|
175
|
+
]
|
|
176
|
+
: []),
|
|
177
|
+
]),
|
|
178
|
+
};
|
|
179
|
+
parameters.required = Object.keys(parameters.properties ?? {});
|
|
180
|
+
|
|
181
|
+
const llmParameters: IResult<
|
|
182
|
+
ILlmSchema.IParameters,
|
|
183
|
+
IJsonSchemaTransformError
|
|
184
|
+
> = LlmSchemaConverter.parameters({
|
|
185
|
+
config: props.config,
|
|
186
|
+
components: props.components,
|
|
187
|
+
schema: parameters,
|
|
188
|
+
accessor: `${endpoint}.parameters`,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// RETURN VALUE
|
|
192
|
+
const output: IResult<ILlmSchema, IJsonSchemaTransformError> | undefined =
|
|
193
|
+
props.route.success
|
|
194
|
+
? LlmSchemaConverter.schema({
|
|
195
|
+
config: props.config,
|
|
196
|
+
components: props.components,
|
|
197
|
+
schema: props.route.success.schema,
|
|
198
|
+
accessor: `${endpoint}.responses[${JSON.stringify(props.route.success.status)}][${JSON.stringify(props.route.success.type)}].schema`,
|
|
199
|
+
$defs: llmParameters.success ? llmParameters.value.$defs : {},
|
|
200
|
+
})
|
|
201
|
+
: undefined;
|
|
202
|
+
|
|
203
|
+
//----
|
|
204
|
+
// CONVERSION
|
|
205
|
+
//----
|
|
206
|
+
if (
|
|
207
|
+
output?.success === false ||
|
|
208
|
+
llmParameters.success === false ||
|
|
209
|
+
isNameVariable === false ||
|
|
210
|
+
isNameStartsWithNumber === true ||
|
|
211
|
+
description[1] > 1_024
|
|
212
|
+
) {
|
|
213
|
+
if (output?.success === false)
|
|
214
|
+
props.errors.push(
|
|
215
|
+
...output.error.reasons.map((r) => `${r.accessor}: ${r.message}`),
|
|
216
|
+
);
|
|
217
|
+
if (llmParameters.success === false)
|
|
218
|
+
props.errors.push(
|
|
219
|
+
...llmParameters.error.reasons.map((r) => {
|
|
220
|
+
const accessor: string = r.accessor.replace(
|
|
221
|
+
`parameters.properties["body"]`,
|
|
222
|
+
`requestBody.content[${JSON.stringify(props.route.body?.type ?? "application/json")}].schema`,
|
|
223
|
+
);
|
|
224
|
+
return `${accessor}: ${r.message}`;
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
method: props.route.method as "get",
|
|
231
|
+
path: props.route.path,
|
|
232
|
+
name,
|
|
233
|
+
parameters: llmParameters.value,
|
|
234
|
+
separated: props.config.separate
|
|
235
|
+
? LlmSchemaConverter.separate({
|
|
236
|
+
predicate: props.config.separate,
|
|
237
|
+
parameters: llmParameters.value,
|
|
238
|
+
equals: props.config.equals ?? false,
|
|
239
|
+
})
|
|
240
|
+
: undefined,
|
|
241
|
+
output: output?.value,
|
|
242
|
+
description: description[0],
|
|
243
|
+
deprecated: operation.deprecated,
|
|
244
|
+
tags: operation.tags,
|
|
245
|
+
validate: OpenApiValidator.create({
|
|
246
|
+
components: props.components,
|
|
247
|
+
schema: parameters,
|
|
248
|
+
required: true,
|
|
249
|
+
equals: props.config.equals ?? false,
|
|
250
|
+
}),
|
|
251
|
+
route: () => props.route as any,
|
|
252
|
+
operation: () => props.route.operation(),
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export const shorten = (
|
|
257
|
+
app: IHttpLlmApplication,
|
|
258
|
+
limit: number = 64,
|
|
259
|
+
): void => {
|
|
260
|
+
const dictionary: Set<string> = new Set();
|
|
261
|
+
const longFunctions: IHttpLlmFunction[] = [];
|
|
262
|
+
for (const func of app.functions) {
|
|
263
|
+
dictionary.add(func.name);
|
|
264
|
+
if (func.name.length > limit) {
|
|
265
|
+
longFunctions.push(func);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (longFunctions.length === 0) return;
|
|
269
|
+
|
|
270
|
+
let index: number = 0;
|
|
271
|
+
for (const func of longFunctions) {
|
|
272
|
+
let success: boolean = false;
|
|
273
|
+
let rename = (str: string) => {
|
|
274
|
+
dictionary.delete(func.name);
|
|
275
|
+
dictionary.add(str);
|
|
276
|
+
func.name = str;
|
|
277
|
+
success = true;
|
|
278
|
+
};
|
|
279
|
+
for (let i: number = 1; i < func.route().accessor.length; ++i) {
|
|
280
|
+
const shortName: string = func.route().accessor.slice(i).join("_");
|
|
281
|
+
if (shortName.length > limit - 8) continue;
|
|
282
|
+
else if (dictionary.has(shortName) === false) rename(shortName);
|
|
283
|
+
else {
|
|
284
|
+
const newName: string = `_${index}_${shortName}`;
|
|
285
|
+
if (dictionary.has(newName) === true) continue;
|
|
286
|
+
rename(newName);
|
|
287
|
+
++index;
|
|
288
|
+
}
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
if (success === false) rename(randomFormatUuid());
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const randomFormatUuid = (): string =>
|
|
297
|
+
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
298
|
+
const r = (Math.random() * 16) | 0;
|
|
299
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
300
|
+
return v.toString(16);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const emend = (str: string): string => {
|
|
304
|
+
for (const ch of FORBIDDEN) str = str.split(ch).join("_");
|
|
305
|
+
return str;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const FORBIDDEN = ["$", "%", "."];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IHttpMigrateRoute, IHttpResponse } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import type { HttpLlm } from "../HttpLlm";
|
|
4
|
+
import type { HttpMigration } from "../HttpMigration";
|
|
5
|
+
import { HttpMigrateRouteFetcher } from "./HttpMigrateRouteFetcher";
|
|
6
|
+
|
|
7
|
+
export namespace HttpLlmFunctionFetcher {
|
|
8
|
+
export const execute = (props: HttpLlm.IFetchProps): Promise<unknown> =>
|
|
9
|
+
HttpMigrateRouteFetcher.execute(getFetchArguments("execute", props));
|
|
10
|
+
|
|
11
|
+
export const propagate = (
|
|
12
|
+
props: HttpLlm.IFetchProps,
|
|
13
|
+
): Promise<IHttpResponse> =>
|
|
14
|
+
HttpMigrateRouteFetcher.propagate(getFetchArguments("propagate", props));
|
|
15
|
+
|
|
16
|
+
const getFetchArguments = (
|
|
17
|
+
from: string,
|
|
18
|
+
props: HttpLlm.IFetchProps,
|
|
19
|
+
): HttpMigration.IFetchProps => {
|
|
20
|
+
const route: IHttpMigrateRoute = props.function.route();
|
|
21
|
+
const input: Record<string, any> = props.input;
|
|
22
|
+
const valid: boolean = typeof input === "object" && input !== null;
|
|
23
|
+
if (valid === false)
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Error on HttpLlmFunctionFetcher.${from}(): keyworded arguments must be an object`,
|
|
26
|
+
);
|
|
27
|
+
return {
|
|
28
|
+
connection: props.connection,
|
|
29
|
+
route,
|
|
30
|
+
parameters: Object.fromEntries(
|
|
31
|
+
route.parameters.map((p) => [p.key, input[p.key]] as const),
|
|
32
|
+
),
|
|
33
|
+
query: input.query,
|
|
34
|
+
body: input.body,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IHttpMigrateApplication,
|
|
3
|
+
IHttpMigrateRoute,
|
|
4
|
+
OpenApi,
|
|
5
|
+
} from "@typia/interface";
|
|
6
|
+
|
|
7
|
+
import { EndpointUtil } from "../../utils/internal/EndpointUtil";
|
|
8
|
+
import { HttpMigrateRouteAccessor } from "./HttpMigrateRouteAccessor";
|
|
9
|
+
import { HttpMigrateRouteComposer } from "./HttpMigrateRouteComposer";
|
|
10
|
+
|
|
11
|
+
export namespace HttpMigrateApplicationComposer {
|
|
12
|
+
export const compose = (
|
|
13
|
+
document: OpenApi.IDocument,
|
|
14
|
+
): IHttpMigrateApplication => {
|
|
15
|
+
const errors: IHttpMigrateApplication.IError[] = [];
|
|
16
|
+
const entire: Array<IHttpMigrateRoute | null> = Object.entries({
|
|
17
|
+
...(document.paths ?? {}),
|
|
18
|
+
...(document.webhooks ?? {}),
|
|
19
|
+
})
|
|
20
|
+
.map(([path, collection]) =>
|
|
21
|
+
(["head", "get", "post", "put", "patch", "delete"] as const)
|
|
22
|
+
.filter((method) => collection[method] !== undefined)
|
|
23
|
+
.map((method) => {
|
|
24
|
+
const operation: OpenApi.IOperation = collection[method]!;
|
|
25
|
+
const migrated: IHttpMigrateRoute | string[] =
|
|
26
|
+
HttpMigrateRouteComposer.compose({
|
|
27
|
+
document,
|
|
28
|
+
method,
|
|
29
|
+
path,
|
|
30
|
+
emendedPath: EndpointUtil.reJoinWithDecimalParameters(path),
|
|
31
|
+
operation,
|
|
32
|
+
});
|
|
33
|
+
if (Array.isArray(migrated)) {
|
|
34
|
+
errors.push({
|
|
35
|
+
method,
|
|
36
|
+
path,
|
|
37
|
+
operation: () => operation,
|
|
38
|
+
messages: migrated,
|
|
39
|
+
});
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return migrated;
|
|
43
|
+
}),
|
|
44
|
+
)
|
|
45
|
+
.flat();
|
|
46
|
+
const operations: IHttpMigrateRoute[] = entire.filter(
|
|
47
|
+
(o): o is IHttpMigrateRoute => !!o,
|
|
48
|
+
);
|
|
49
|
+
HttpMigrateRouteAccessor.overwrite(operations);
|
|
50
|
+
return {
|
|
51
|
+
document: () => document,
|
|
52
|
+
routes: operations,
|
|
53
|
+
errors,
|
|
54
|
+
} satisfies IHttpMigrateApplication as IHttpMigrateApplication;
|
|
55
|
+
};
|
|
56
|
+
}
|