@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,135 @@
|
|
|
1
|
+
import { IHttpMigrateRoute } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { MapUtil } from "../../utils/MapUtil";
|
|
4
|
+
import { NamingConvention } from "../../utils/NamingConvention";
|
|
5
|
+
import { EndpointUtil } from "../../utils/internal/EndpointUtil";
|
|
6
|
+
|
|
7
|
+
export namespace HttpMigrateRouteAccessor {
|
|
8
|
+
export const overwrite = (routes: IHttpMigrateRoute[]): void => {
|
|
9
|
+
const predefined: Map<string, number> = getPredefinedAccessors(routes);
|
|
10
|
+
const dict: Map<string, IElement> = collect((op) =>
|
|
11
|
+
op.emendedPath
|
|
12
|
+
.split("/")
|
|
13
|
+
.filter((str) => !!str.length && str[0] !== ":")
|
|
14
|
+
.map(EndpointUtil.normalize)
|
|
15
|
+
.map((str) => (NamingConvention.variable(str) ? str : `_${str}`)),
|
|
16
|
+
)(routes) as Map<string, IElement>;
|
|
17
|
+
|
|
18
|
+
for (const props of dict.values())
|
|
19
|
+
props.entries.forEach((entry, i) => {
|
|
20
|
+
entry.alias = EndpointUtil.escapeDuplicate(
|
|
21
|
+
[
|
|
22
|
+
...props.children,
|
|
23
|
+
...props.entries.filter((_, j) => i !== j).map((e) => e.alias),
|
|
24
|
+
].map(EndpointUtil.normalize),
|
|
25
|
+
)(EndpointUtil.normalize(entry.alias));
|
|
26
|
+
|
|
27
|
+
const parameters: { name: string; key: string }[] = [
|
|
28
|
+
...entry.route.parameters,
|
|
29
|
+
...(entry.route.body ? [entry.route.body] : []),
|
|
30
|
+
...(entry.route.headers ? [entry.route.headers] : []),
|
|
31
|
+
...(entry.route.query ? [entry.route.query] : []),
|
|
32
|
+
];
|
|
33
|
+
parameters.forEach(
|
|
34
|
+
(p, i) =>
|
|
35
|
+
(p.key = EndpointUtil.escapeDuplicate([
|
|
36
|
+
"connection",
|
|
37
|
+
entry.alias,
|
|
38
|
+
...parameters.filter((_, j) => i !== j).map((y) => y.key),
|
|
39
|
+
])(p.key)),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const accessor: string[] | undefined =
|
|
43
|
+
entry.route.operation()["x-samchon-accessor"];
|
|
44
|
+
if (accessor !== undefined && predefined.get(accessor.join(".")) === 1)
|
|
45
|
+
entry.route.accessor = accessor;
|
|
46
|
+
else entry.route.accessor = [...props.namespace, entry.alias];
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
for (const x of routes) {
|
|
50
|
+
while (true) {
|
|
51
|
+
const neighbor: IHttpMigrateRoute | undefined = routes.find(
|
|
52
|
+
(y) =>
|
|
53
|
+
y.accessor.length < x.accessor.length &&
|
|
54
|
+
x.accessor
|
|
55
|
+
.slice(0, y.accessor.length)
|
|
56
|
+
.every((v, i) => v === y.accessor[i]),
|
|
57
|
+
);
|
|
58
|
+
if (neighbor === undefined) break;
|
|
59
|
+
x.accessor[neighbor.accessor.length - 1] =
|
|
60
|
+
`_${x.accessor[neighbor.accessor.length - 1]}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const collect =
|
|
66
|
+
(getter: (r: IHttpMigrateRoute) => string[]) =>
|
|
67
|
+
(routes: IHttpMigrateRoute[]): Map<string, IElement> => {
|
|
68
|
+
const dict: Map<string, IElement> = new Map();
|
|
69
|
+
for (const r of routes) {
|
|
70
|
+
const namespace: string[] = getter(r);
|
|
71
|
+
let last: IElement = MapUtil.take(dict, namespace.join("."), () => ({
|
|
72
|
+
namespace,
|
|
73
|
+
children: new Set(),
|
|
74
|
+
entries: [],
|
|
75
|
+
}));
|
|
76
|
+
last.entries.push({
|
|
77
|
+
route: r,
|
|
78
|
+
alias: getName(r),
|
|
79
|
+
});
|
|
80
|
+
namespace.slice(0, -1).forEach((_i, i, array) => {
|
|
81
|
+
const partial: string[] = namespace.slice(0, array.length - i);
|
|
82
|
+
const element: IElement = MapUtil.take(
|
|
83
|
+
dict,
|
|
84
|
+
partial.join("."),
|
|
85
|
+
() => ({
|
|
86
|
+
namespace: partial,
|
|
87
|
+
children: new Set(),
|
|
88
|
+
entries: [],
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
element.children.add(last.namespace.at(-1)!);
|
|
92
|
+
});
|
|
93
|
+
const top: IElement = MapUtil.take(dict, "", () => ({
|
|
94
|
+
namespace: [],
|
|
95
|
+
children: new Set(),
|
|
96
|
+
entries: [],
|
|
97
|
+
}));
|
|
98
|
+
if (namespace.length) top.children.add(namespace[0]!);
|
|
99
|
+
}
|
|
100
|
+
return dict;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const getName = (op: IHttpMigrateRoute): string => {
|
|
104
|
+
const method = op.method === "delete" ? "erase" : op.method;
|
|
105
|
+
if (op.parameters.length === 0) return method;
|
|
106
|
+
return (
|
|
107
|
+
method +
|
|
108
|
+
"By" +
|
|
109
|
+
op.parameters.map((p) => EndpointUtil.capitalize(p.key)).join("And")
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const getPredefinedAccessors = (
|
|
114
|
+
routes: IHttpMigrateRoute[],
|
|
115
|
+
): Map<string, number> => {
|
|
116
|
+
const dict: Map<string, number> = new Map();
|
|
117
|
+
for (const r of routes) {
|
|
118
|
+
const accessor = r.operation()["x-samchon-accessor"]?.join(".");
|
|
119
|
+
if (accessor === undefined) continue;
|
|
120
|
+
else if (dict.has(accessor)) dict.set(accessor, dict.get(accessor)! + 1);
|
|
121
|
+
else dict.set(accessor, 1);
|
|
122
|
+
}
|
|
123
|
+
return dict;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
interface IElement {
|
|
127
|
+
namespace: string[];
|
|
128
|
+
entries: IEntry[];
|
|
129
|
+
children: Set<string>;
|
|
130
|
+
}
|
|
131
|
+
interface IEntry {
|
|
132
|
+
route: IHttpMigrateRoute;
|
|
133
|
+
alias: string;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { NamingConvention } from "../../utils/NamingConvention";
|
|
4
|
+
import { EndpointUtil } from "../../utils/internal/EndpointUtil";
|
|
5
|
+
import { OpenApiTypeChecker } from "../../validators/OpenApiTypeChecker";
|
|
6
|
+
|
|
7
|
+
export namespace HttpMigrateRouteComposer {
|
|
8
|
+
export interface IProps {
|
|
9
|
+
document: OpenApi.IDocument;
|
|
10
|
+
method: "head" | "get" | "post" | "put" | "patch" | "delete";
|
|
11
|
+
path: string;
|
|
12
|
+
emendedPath: string;
|
|
13
|
+
operation: OpenApi.IOperation;
|
|
14
|
+
}
|
|
15
|
+
export const compose = (props: IProps): IHttpMigrateRoute | string[] => {
|
|
16
|
+
//----
|
|
17
|
+
// REQUEST AND RESPONSE BODY
|
|
18
|
+
//----
|
|
19
|
+
const body: false | null | IHttpMigrateRoute.IBody = emplaceBodySchema(
|
|
20
|
+
"request",
|
|
21
|
+
)((schema) =>
|
|
22
|
+
emplaceReference({
|
|
23
|
+
document: props.document,
|
|
24
|
+
name:
|
|
25
|
+
EndpointUtil.pascal(`I/Api/${props.path}`) +
|
|
26
|
+
"." +
|
|
27
|
+
EndpointUtil.pascal(`${props.method}/Body`),
|
|
28
|
+
schema,
|
|
29
|
+
}),
|
|
30
|
+
)(props.operation.requestBody);
|
|
31
|
+
const success: false | null | IHttpMigrateRoute.ISuccess = (() => {
|
|
32
|
+
const body = emplaceBodySchema("response")((schema) =>
|
|
33
|
+
emplaceReference({
|
|
34
|
+
document: props.document,
|
|
35
|
+
name:
|
|
36
|
+
EndpointUtil.pascal(`I/Api/${props.path}`) +
|
|
37
|
+
"." +
|
|
38
|
+
EndpointUtil.pascal(`${props.method}/Response`),
|
|
39
|
+
schema,
|
|
40
|
+
}),
|
|
41
|
+
)(
|
|
42
|
+
props.operation.responses?.["201"] ??
|
|
43
|
+
props.operation.responses?.["200"] ??
|
|
44
|
+
props.operation.responses?.default,
|
|
45
|
+
);
|
|
46
|
+
return body
|
|
47
|
+
? {
|
|
48
|
+
...body,
|
|
49
|
+
status: props.operation.responses?.["201"]
|
|
50
|
+
? "201"
|
|
51
|
+
: props.operation.responses?.["200"]
|
|
52
|
+
? "200"
|
|
53
|
+
: "default",
|
|
54
|
+
}
|
|
55
|
+
: body;
|
|
56
|
+
})();
|
|
57
|
+
|
|
58
|
+
const failures: string[] = [];
|
|
59
|
+
if (body === false)
|
|
60
|
+
failures.push(
|
|
61
|
+
`supports only "application/json", "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain" content type in the request body.`,
|
|
62
|
+
);
|
|
63
|
+
if (success === false)
|
|
64
|
+
failures.push(
|
|
65
|
+
`supports only "application/json", "application/x-www-form-urlencoded" and "text/plain" content type in the response body.`,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
//----
|
|
69
|
+
// HEADERS AND QUERY
|
|
70
|
+
//---
|
|
71
|
+
const [headers, query] = ["header", "query"].map((type) => {
|
|
72
|
+
// FIND TARGET PARAMETERS
|
|
73
|
+
const parameters: OpenApi.IOperation.IParameter[] = (
|
|
74
|
+
props.operation.parameters ?? []
|
|
75
|
+
).filter((p) => p.in === type);
|
|
76
|
+
if (parameters.length === 0) return null;
|
|
77
|
+
|
|
78
|
+
// CHECK PARAMETER TYPES -> TO BE OBJECT
|
|
79
|
+
const objects = parameters
|
|
80
|
+
.map((p) =>
|
|
81
|
+
OpenApiTypeChecker.isObject(p.schema)
|
|
82
|
+
? p.schema
|
|
83
|
+
: OpenApiTypeChecker.isReference(p.schema) &&
|
|
84
|
+
OpenApiTypeChecker.isObject(
|
|
85
|
+
props.document.components.schemas?.[
|
|
86
|
+
p.schema.$ref.replace(`#/components/schemas/`, ``)
|
|
87
|
+
] ?? {},
|
|
88
|
+
)
|
|
89
|
+
? p.schema
|
|
90
|
+
: null!,
|
|
91
|
+
)
|
|
92
|
+
.filter((s) => !!s);
|
|
93
|
+
const primitives = parameters.filter(
|
|
94
|
+
(p) =>
|
|
95
|
+
OpenApiTypeChecker.isBoolean(p.schema) ||
|
|
96
|
+
OpenApiTypeChecker.isInteger(p.schema) ||
|
|
97
|
+
OpenApiTypeChecker.isNumber(p.schema) ||
|
|
98
|
+
OpenApiTypeChecker.isString(p.schema) ||
|
|
99
|
+
OpenApiTypeChecker.isArray(p.schema) ||
|
|
100
|
+
OpenApiTypeChecker.isTuple(p.schema),
|
|
101
|
+
);
|
|
102
|
+
const out = (elem: {
|
|
103
|
+
schema: OpenApi.IJsonSchema;
|
|
104
|
+
title?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
example?: any;
|
|
107
|
+
examples?: Record<string, any>;
|
|
108
|
+
}) =>
|
|
109
|
+
({
|
|
110
|
+
...elem,
|
|
111
|
+
name: type,
|
|
112
|
+
key: type,
|
|
113
|
+
title: () => elem.title,
|
|
114
|
+
description: () => elem.description,
|
|
115
|
+
example: () => elem.example,
|
|
116
|
+
examples: () => elem.examples,
|
|
117
|
+
}) satisfies IHttpMigrateRoute.IHeaders;
|
|
118
|
+
|
|
119
|
+
if (objects.length === 1 && primitives.length === 0)
|
|
120
|
+
return out(parameters[0]!);
|
|
121
|
+
else if (objects.length > 1) {
|
|
122
|
+
failures.push(`${type} typed parameters must be only one object type`);
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// GATHER TO OBJECT TYPE
|
|
127
|
+
const dto: OpenApi.IJsonSchema.IObject | null = objects[0]
|
|
128
|
+
? OpenApiTypeChecker.isObject(objects[0])
|
|
129
|
+
? objects[0]
|
|
130
|
+
: ((props.document.components.schemas ?? {})[
|
|
131
|
+
(objects[0] as OpenApi.IJsonSchema.IReference).$ref.replace(
|
|
132
|
+
`#/components/schemas/`,
|
|
133
|
+
``,
|
|
134
|
+
)
|
|
135
|
+
] as OpenApi.IJsonSchema.IObject)
|
|
136
|
+
: null;
|
|
137
|
+
const entire: OpenApi.IJsonSchema.IObject[] = [
|
|
138
|
+
...objects.map((o) =>
|
|
139
|
+
OpenApiTypeChecker.isObject(o)
|
|
140
|
+
? o
|
|
141
|
+
: (props.document.components.schemas?.[
|
|
142
|
+
o.$ref.replace(`#/components/schemas/`, ``)
|
|
143
|
+
]! as OpenApi.IJsonSchema.IObject),
|
|
144
|
+
),
|
|
145
|
+
{
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: Object.fromEntries([
|
|
148
|
+
...primitives.map((p) => [
|
|
149
|
+
p.name,
|
|
150
|
+
{
|
|
151
|
+
...p.schema,
|
|
152
|
+
description: p.schema.description ?? p.description,
|
|
153
|
+
},
|
|
154
|
+
]),
|
|
155
|
+
...(dto ? Object.entries(dto.properties ?? {}) : []),
|
|
156
|
+
]),
|
|
157
|
+
required: [
|
|
158
|
+
...new Set([
|
|
159
|
+
...primitives.filter((p) => p.required).map((p) => p.name!),
|
|
160
|
+
...(dto?.required ?? []),
|
|
161
|
+
]),
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
return parameters.length === 0
|
|
166
|
+
? null
|
|
167
|
+
: out({
|
|
168
|
+
schema: emplaceReference({
|
|
169
|
+
document: props.document,
|
|
170
|
+
name:
|
|
171
|
+
EndpointUtil.pascal(`I/Api/${props.path}`) +
|
|
172
|
+
"." +
|
|
173
|
+
EndpointUtil.pascal(`${props.method}/${type}`),
|
|
174
|
+
schema: {
|
|
175
|
+
type: "object",
|
|
176
|
+
properties: Object.fromEntries([
|
|
177
|
+
...new Map<string, OpenApi.IJsonSchema>(
|
|
178
|
+
entire
|
|
179
|
+
.map((o) =>
|
|
180
|
+
Object.entries(o.properties ?? {}).map(
|
|
181
|
+
([name, schema]) =>
|
|
182
|
+
[
|
|
183
|
+
name,
|
|
184
|
+
{
|
|
185
|
+
...schema,
|
|
186
|
+
description:
|
|
187
|
+
schema.description ?? schema.description,
|
|
188
|
+
} as OpenApi.IJsonSchema,
|
|
189
|
+
] as const,
|
|
190
|
+
),
|
|
191
|
+
)
|
|
192
|
+
.flat(),
|
|
193
|
+
),
|
|
194
|
+
]),
|
|
195
|
+
required: [
|
|
196
|
+
...new Set(entire.map((o) => o.required ?? []).flat()),
|
|
197
|
+
],
|
|
198
|
+
} satisfies OpenApi.IJsonSchema.IObject,
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
//----
|
|
204
|
+
// PATH PARAMETERS
|
|
205
|
+
//----
|
|
206
|
+
const parameterNames: string[] = EndpointUtil.splitWithNormalization(
|
|
207
|
+
props.emendedPath,
|
|
208
|
+
)
|
|
209
|
+
.filter((str) => str[0] === ":")
|
|
210
|
+
.map((str) => str.substring(1));
|
|
211
|
+
const pathParameters: OpenApi.IOperation.IParameter[] = (
|
|
212
|
+
props.operation.parameters ?? []
|
|
213
|
+
).filter((p) => p.in === "path");
|
|
214
|
+
if (parameterNames.length !== pathParameters.length)
|
|
215
|
+
if (
|
|
216
|
+
pathParameters.length < parameterNames.length &&
|
|
217
|
+
pathParameters.every(
|
|
218
|
+
(p) => p.name !== undefined && parameterNames.includes(p.name),
|
|
219
|
+
)
|
|
220
|
+
) {
|
|
221
|
+
for (const name of parameterNames)
|
|
222
|
+
if (pathParameters.find((p) => p.name === name) === undefined)
|
|
223
|
+
pathParameters.push({
|
|
224
|
+
name,
|
|
225
|
+
in: "path",
|
|
226
|
+
schema: { type: "string" },
|
|
227
|
+
});
|
|
228
|
+
pathParameters.sort(
|
|
229
|
+
(a, b) =>
|
|
230
|
+
parameterNames.indexOf(a.name!) - parameterNames.indexOf(b.name!),
|
|
231
|
+
);
|
|
232
|
+
props.operation.parameters = [
|
|
233
|
+
...pathParameters,
|
|
234
|
+
...(props.operation.parameters ?? []).filter((p) => p.in !== "path"),
|
|
235
|
+
];
|
|
236
|
+
} else
|
|
237
|
+
failures.push(
|
|
238
|
+
"number of path parameters are not matched with its full path.",
|
|
239
|
+
);
|
|
240
|
+
if (failures.length) return failures;
|
|
241
|
+
|
|
242
|
+
const parameters: IHttpMigrateRoute.IParameter[] = (
|
|
243
|
+
props.operation.parameters ?? []
|
|
244
|
+
)
|
|
245
|
+
.filter((p) => p.in === "path")
|
|
246
|
+
.map((p, i) => ({
|
|
247
|
+
// FILL KEY NAME IF NOT EXISTS
|
|
248
|
+
name: parameterNames[i]!,
|
|
249
|
+
key: (() => {
|
|
250
|
+
let key: string = EndpointUtil.normalize(parameterNames[i]!);
|
|
251
|
+
if (NamingConvention.variable(key)) return key;
|
|
252
|
+
while (true) {
|
|
253
|
+
key = "_" + key;
|
|
254
|
+
if (!parameterNames.some((s) => s === key)) return key;
|
|
255
|
+
}
|
|
256
|
+
})(),
|
|
257
|
+
schema: p.schema,
|
|
258
|
+
parameter: () => p,
|
|
259
|
+
}));
|
|
260
|
+
return {
|
|
261
|
+
method: props.method,
|
|
262
|
+
path: props.path,
|
|
263
|
+
emendedPath: props.emendedPath,
|
|
264
|
+
accessor: ["@lazy"],
|
|
265
|
+
parameters: (props.operation.parameters ?? [])
|
|
266
|
+
.filter((p) => p.in === "path")
|
|
267
|
+
.map((p, i) => ({
|
|
268
|
+
// FILL KEY NAME IF NOT EXISTS
|
|
269
|
+
name: parameterNames[i]!,
|
|
270
|
+
key: (() => {
|
|
271
|
+
let key: string = EndpointUtil.normalize(parameterNames[i]!);
|
|
272
|
+
if (NamingConvention.variable(key)) return key;
|
|
273
|
+
while (true) {
|
|
274
|
+
key = "_" + key;
|
|
275
|
+
if (!parameterNames.some((s) => s === key)) return key;
|
|
276
|
+
}
|
|
277
|
+
})(),
|
|
278
|
+
schema: p.schema,
|
|
279
|
+
parameter: () => p,
|
|
280
|
+
})),
|
|
281
|
+
headers: headers || null,
|
|
282
|
+
query: query || null,
|
|
283
|
+
body: body || null,
|
|
284
|
+
success: success || null,
|
|
285
|
+
exceptions: Object.fromEntries(
|
|
286
|
+
Object.entries(props.operation.responses ?? {})
|
|
287
|
+
.filter(
|
|
288
|
+
([key]) => key !== "200" && key !== "201" && key !== "default",
|
|
289
|
+
)
|
|
290
|
+
.map(([status, response]) => [
|
|
291
|
+
status,
|
|
292
|
+
{
|
|
293
|
+
schema: (response.content?.["application/json"]?.schema ??
|
|
294
|
+
{}) satisfies OpenApi.IJsonSchema,
|
|
295
|
+
response: () => response,
|
|
296
|
+
media: () =>
|
|
297
|
+
(response.content?.["application/json"] ??
|
|
298
|
+
{}) satisfies OpenApi.IJsonSchema,
|
|
299
|
+
} satisfies IHttpMigrateRoute.IException,
|
|
300
|
+
]),
|
|
301
|
+
),
|
|
302
|
+
comment: () =>
|
|
303
|
+
writeRouteComment({
|
|
304
|
+
operation: props.operation,
|
|
305
|
+
parameters,
|
|
306
|
+
query: query || null,
|
|
307
|
+
body: body || null,
|
|
308
|
+
}),
|
|
309
|
+
operation: () => props.operation,
|
|
310
|
+
} satisfies IHttpMigrateRoute as IHttpMigrateRoute;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const writeRouteComment = (props: {
|
|
314
|
+
operation: OpenApi.IOperation;
|
|
315
|
+
parameters: IHttpMigrateRoute.IParameter[];
|
|
316
|
+
query: IHttpMigrateRoute.IQuery | null;
|
|
317
|
+
body: IHttpMigrateRoute.IBody | null;
|
|
318
|
+
}): string => {
|
|
319
|
+
// write basic description combining with summary
|
|
320
|
+
let description: string = props.operation.description ?? "";
|
|
321
|
+
if (!!props.operation.summary?.length) {
|
|
322
|
+
const summary: string = props.operation.summary.endsWith(".")
|
|
323
|
+
? props.operation.summary
|
|
324
|
+
: props.operation.summary + ".";
|
|
325
|
+
if (
|
|
326
|
+
!!description.length &&
|
|
327
|
+
!description.startsWith(props.operation.summary)
|
|
328
|
+
)
|
|
329
|
+
description = `${summary}\n\n${description}`;
|
|
330
|
+
}
|
|
331
|
+
description = description
|
|
332
|
+
.split("\n")
|
|
333
|
+
.map((s) => s.trim())
|
|
334
|
+
.join("\n");
|
|
335
|
+
|
|
336
|
+
//----
|
|
337
|
+
// compose jsdoc comment tags
|
|
338
|
+
//----
|
|
339
|
+
const commentTags: string[] = [];
|
|
340
|
+
const add = (text: string) => {
|
|
341
|
+
if (commentTags.every((line) => line !== text)) commentTags.push(text);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
// parameters
|
|
345
|
+
add("@param connection");
|
|
346
|
+
for (const p of props.parameters ?? []) {
|
|
347
|
+
const param = p.parameter();
|
|
348
|
+
if (param.description) {
|
|
349
|
+
const text: string = param.description!;
|
|
350
|
+
add(`@param ${p.name} ${writeIndented(text, p.name.length + 8)}`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (props.body?.description()?.length)
|
|
354
|
+
add(`@param body ${writeIndented(props.body.description()!, 12)}`);
|
|
355
|
+
|
|
356
|
+
// security
|
|
357
|
+
for (const security of props.operation.security ?? [])
|
|
358
|
+
for (const [name, scopes] of Object.entries(security))
|
|
359
|
+
add(`@security ${[name, ...scopes].join("")}`);
|
|
360
|
+
|
|
361
|
+
// categorizing tags
|
|
362
|
+
if (props.operation.tags)
|
|
363
|
+
props.operation.tags.forEach((name) => add(`@tag ${name}`));
|
|
364
|
+
|
|
365
|
+
// deprecated
|
|
366
|
+
if (props.operation.deprecated) add("@deprecated");
|
|
367
|
+
|
|
368
|
+
// plugin properties
|
|
369
|
+
for (const [key, value] of Object.entries(props.operation)) {
|
|
370
|
+
if (key.startsWith("x-") === false) continue;
|
|
371
|
+
else if (
|
|
372
|
+
value !== null &&
|
|
373
|
+
typeof value !== "boolean" &&
|
|
374
|
+
typeof value !== "number" &&
|
|
375
|
+
typeof value !== "string"
|
|
376
|
+
)
|
|
377
|
+
continue;
|
|
378
|
+
add(`@${key} ${value}`);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// finalize description
|
|
382
|
+
description = description.length
|
|
383
|
+
? commentTags.length
|
|
384
|
+
? `${description}\n\n${commentTags.join("\n")}`
|
|
385
|
+
: description
|
|
386
|
+
: commentTags.join("\n");
|
|
387
|
+
description = description.split("*/").join("*\\/");
|
|
388
|
+
return description;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
const writeIndented = (text: string, spaces: number): string =>
|
|
392
|
+
text
|
|
393
|
+
.split("\n")
|
|
394
|
+
.map((s) => s.trim())
|
|
395
|
+
.map((s, i) => (i === 0 ? s : `${" ".repeat(spaces)}${s}`))
|
|
396
|
+
.join("\n");
|
|
397
|
+
|
|
398
|
+
const emplaceBodySchema =
|
|
399
|
+
(from: "request" | "response") =>
|
|
400
|
+
(
|
|
401
|
+
emplacer: (schema: OpenApi.IJsonSchema) => OpenApi.IJsonSchema.IReference,
|
|
402
|
+
) =>
|
|
403
|
+
(meta?: {
|
|
404
|
+
description?: string;
|
|
405
|
+
content?: Partial<Record<string, OpenApi.IOperation.IMediaType>>; // ISwaggerRouteBodyContent;
|
|
406
|
+
"x-nestia-encrypted"?: boolean;
|
|
407
|
+
}): false | null | IHttpMigrateRoute.IBody => {
|
|
408
|
+
if (!meta?.content) return null;
|
|
409
|
+
|
|
410
|
+
const entries: [string, OpenApi.IOperation.IMediaType][] = Object.entries(
|
|
411
|
+
meta.content,
|
|
412
|
+
).filter(([_, v]) => !!v) as [string, OpenApi.IOperation.IMediaType][];
|
|
413
|
+
const json = entries.find((e) =>
|
|
414
|
+
meta["x-nestia-encrypted"] === true
|
|
415
|
+
? e[0].includes("text/plain") || e[0].includes("application/json")
|
|
416
|
+
: e[0].includes("application/json") || e[0].includes("*/*"),
|
|
417
|
+
);
|
|
418
|
+
if (json) {
|
|
419
|
+
const { schema } = json[1];
|
|
420
|
+
return schema || from === "response"
|
|
421
|
+
? {
|
|
422
|
+
type: "application/json",
|
|
423
|
+
name: "body",
|
|
424
|
+
key: "body",
|
|
425
|
+
schema: schema
|
|
426
|
+
? isNotObjectLiteral(schema)
|
|
427
|
+
? schema
|
|
428
|
+
: emplacer(schema)
|
|
429
|
+
: {},
|
|
430
|
+
description: () => meta.description,
|
|
431
|
+
media: () => json[1],
|
|
432
|
+
"x-nestia-encrypted": meta["x-nestia-encrypted"],
|
|
433
|
+
}
|
|
434
|
+
: null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const query = entries.find((e) =>
|
|
438
|
+
e[0].includes("application/x-www-form-urlencoded"),
|
|
439
|
+
);
|
|
440
|
+
if (query) {
|
|
441
|
+
const { schema } = query[1];
|
|
442
|
+
return schema || from === "response"
|
|
443
|
+
? {
|
|
444
|
+
type: "application/x-www-form-urlencoded",
|
|
445
|
+
name: "body",
|
|
446
|
+
key: "body",
|
|
447
|
+
schema: schema
|
|
448
|
+
? isNotObjectLiteral(schema)
|
|
449
|
+
? schema
|
|
450
|
+
: emplacer(schema)
|
|
451
|
+
: {},
|
|
452
|
+
description: () => meta.description,
|
|
453
|
+
media: () => query[1],
|
|
454
|
+
}
|
|
455
|
+
: null;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const text = entries.find((e) => e[0].includes("text/plain"));
|
|
459
|
+
if (text)
|
|
460
|
+
return {
|
|
461
|
+
type: "text/plain",
|
|
462
|
+
name: "body",
|
|
463
|
+
key: "body",
|
|
464
|
+
schema: { type: "string" },
|
|
465
|
+
description: () => meta.description,
|
|
466
|
+
media: () => text[1],
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
if (from === "request") {
|
|
470
|
+
const multipart = entries.find((e) =>
|
|
471
|
+
e[0].includes("multipart/form-data"),
|
|
472
|
+
);
|
|
473
|
+
if (multipart) {
|
|
474
|
+
const { schema } = multipart[1];
|
|
475
|
+
return {
|
|
476
|
+
type: "multipart/form-data",
|
|
477
|
+
name: "body",
|
|
478
|
+
key: "body",
|
|
479
|
+
schema: schema
|
|
480
|
+
? isNotObjectLiteral(schema)
|
|
481
|
+
? schema
|
|
482
|
+
: emplacer(schema)
|
|
483
|
+
: {},
|
|
484
|
+
description: () => meta.description,
|
|
485
|
+
media: () => multipart[1],
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const emplaceReference = (props: {
|
|
493
|
+
document: OpenApi.IDocument;
|
|
494
|
+
name: string;
|
|
495
|
+
schema: OpenApi.IJsonSchema;
|
|
496
|
+
}): OpenApi.IJsonSchema.IReference => {
|
|
497
|
+
props.document.components.schemas ??= {};
|
|
498
|
+
props.document.components.schemas[props.name] = props.schema;
|
|
499
|
+
return {
|
|
500
|
+
$ref: `#/components/schemas/${props.name}`,
|
|
501
|
+
} satisfies OpenApi.IJsonSchema.IReference;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
const isNotObjectLiteral = (schema: OpenApi.IJsonSchema): boolean =>
|
|
505
|
+
OpenApiTypeChecker.isReference(schema) ||
|
|
506
|
+
OpenApiTypeChecker.isBoolean(schema) ||
|
|
507
|
+
OpenApiTypeChecker.isNumber(schema) ||
|
|
508
|
+
OpenApiTypeChecker.isString(schema) ||
|
|
509
|
+
OpenApiTypeChecker.isUnknown(schema) ||
|
|
510
|
+
(OpenApiTypeChecker.isOneOf(schema) &&
|
|
511
|
+
schema.oneOf.every(isNotObjectLiteral)) ||
|
|
512
|
+
(OpenApiTypeChecker.isArray(schema) && isNotObjectLiteral(schema.items));
|
|
513
|
+
}
|