@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,203 @@
|
|
|
1
|
+
import { IHttpConnection, IHttpResponse } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { HttpError } from "../HttpError";
|
|
4
|
+
import type { HttpMigration } from "../HttpMigration";
|
|
5
|
+
|
|
6
|
+
export namespace HttpMigrateRouteFetcher {
|
|
7
|
+
export const execute = async (
|
|
8
|
+
props: HttpMigration.IFetchProps,
|
|
9
|
+
): Promise<unknown> => {
|
|
10
|
+
const result: IHttpResponse = await _Propagate("request", props);
|
|
11
|
+
props.route.success?.media;
|
|
12
|
+
if (result.status !== 200 && result.status !== 201)
|
|
13
|
+
throw new HttpError(
|
|
14
|
+
props.route.method.toUpperCase() as "GET",
|
|
15
|
+
props.route.path,
|
|
16
|
+
result.status,
|
|
17
|
+
result.headers,
|
|
18
|
+
result.body as string,
|
|
19
|
+
);
|
|
20
|
+
return result.body;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const propagate = (
|
|
24
|
+
props: HttpMigration.IFetchProps,
|
|
25
|
+
): Promise<IHttpResponse> => _Propagate("propagate", props);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const _Propagate = async (
|
|
29
|
+
from: string,
|
|
30
|
+
props: HttpMigration.IFetchProps,
|
|
31
|
+
): Promise<IHttpResponse> => {
|
|
32
|
+
// VALIDATE PARAMETERS
|
|
33
|
+
const error = (message: string) =>
|
|
34
|
+
new Error(`Error on MigrateRouteFetcher.${from}(): ${message}`);
|
|
35
|
+
if (Array.isArray(props.parameters)) {
|
|
36
|
+
if (props.route.parameters.length !== props.parameters.length)
|
|
37
|
+
throw error(`number of parameters is not matched.`);
|
|
38
|
+
} else if (
|
|
39
|
+
props.route.parameters.every(
|
|
40
|
+
(p) => (props.parameters as Record<string, any>)[p.key] !== undefined,
|
|
41
|
+
) === false
|
|
42
|
+
)
|
|
43
|
+
throw error(`number of parameters is not matched.`);
|
|
44
|
+
|
|
45
|
+
// VALIDATE QUERY
|
|
46
|
+
if (!!props.route.query !== !!props.query)
|
|
47
|
+
throw error(`query is not matched.`);
|
|
48
|
+
else if (!!props.route.body !== (props.body !== undefined))
|
|
49
|
+
throw error(`body is not matched.`);
|
|
50
|
+
|
|
51
|
+
// INIT REQUEST DATA
|
|
52
|
+
const headers: Record<string, IHttpConnection.HeaderValue | undefined> = {
|
|
53
|
+
...(props.connection.headers ?? {}),
|
|
54
|
+
...(props.route.body?.type &&
|
|
55
|
+
props.route.body.type !== "multipart/form-data"
|
|
56
|
+
? { "Content-Type": props.route.body.type }
|
|
57
|
+
: {}),
|
|
58
|
+
};
|
|
59
|
+
const init: RequestInit = {
|
|
60
|
+
...(props.connection.options ?? {}),
|
|
61
|
+
method: props.route.method.toUpperCase(),
|
|
62
|
+
headers: (() => {
|
|
63
|
+
const output: [string, string][] = [];
|
|
64
|
+
for (const [key, value] of Object.entries(headers))
|
|
65
|
+
if (value === undefined) continue;
|
|
66
|
+
else if (Array.isArray(value))
|
|
67
|
+
for (const v of value) output.push([key, String(v)]);
|
|
68
|
+
else output.push([key, String(value)]);
|
|
69
|
+
return output;
|
|
70
|
+
})(),
|
|
71
|
+
};
|
|
72
|
+
if (props.body !== undefined)
|
|
73
|
+
init.body = (
|
|
74
|
+
props.route.body?.type === "application/x-www-form-urlencoded"
|
|
75
|
+
? requestQueryBody(props.body)
|
|
76
|
+
: props.route.body?.type === "multipart/form-data"
|
|
77
|
+
? requestFormDataBody(props.body)
|
|
78
|
+
: props.route.body?.type === "application/json"
|
|
79
|
+
? JSON.stringify(props.body)
|
|
80
|
+
: props.body
|
|
81
|
+
) as any;
|
|
82
|
+
|
|
83
|
+
// DO REQUEST
|
|
84
|
+
const resolvedPath: string =
|
|
85
|
+
props.connection.host.endsWith("/") === false &&
|
|
86
|
+
props.route.emendedPath.startsWith("/") === false
|
|
87
|
+
? `/${getPath(props)}`
|
|
88
|
+
: getPath(props);
|
|
89
|
+
const url: URL = new URL(`${props.connection.host}${resolvedPath}`);
|
|
90
|
+
|
|
91
|
+
const response: Response = await (props.connection.fetch ?? fetch)(url, init);
|
|
92
|
+
const status: number = response.status;
|
|
93
|
+
const out = (body: unknown): IHttpResponse => ({
|
|
94
|
+
status,
|
|
95
|
+
headers: responseHeaders(response.headers),
|
|
96
|
+
body,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (status === 200 || status === 201) {
|
|
100
|
+
// SUCCESS CASE
|
|
101
|
+
if (props.route.method.toUpperCase() === "HEAD") return out(undefined);
|
|
102
|
+
else if (
|
|
103
|
+
props.route.success === null ||
|
|
104
|
+
props.route.success.type === "text/plain"
|
|
105
|
+
)
|
|
106
|
+
return out(await response.text());
|
|
107
|
+
else if (props.route.success.type === "application/json") {
|
|
108
|
+
const text: string = await response.text();
|
|
109
|
+
return out(text.length ? JSON.parse(text) : undefined);
|
|
110
|
+
} else if (props.route.success.type === "application/x-www-form-urlencoded")
|
|
111
|
+
return out(new URLSearchParams(await response.text()));
|
|
112
|
+
else if (props.route.success.type === "multipart/form-data")
|
|
113
|
+
return out(await response.formData());
|
|
114
|
+
throw error("Unsupported response body type.");
|
|
115
|
+
} else {
|
|
116
|
+
// FAILURE CASE
|
|
117
|
+
const type: string = (
|
|
118
|
+
response.headers.get("content-type") ??
|
|
119
|
+
response.headers.get("Content-Type") ??
|
|
120
|
+
""
|
|
121
|
+
)
|
|
122
|
+
.split(";")[0]!
|
|
123
|
+
.trim();
|
|
124
|
+
if (type === "" || type.startsWith("text/"))
|
|
125
|
+
return out(await response.text());
|
|
126
|
+
else if (type === "application/json") return out(await response.json());
|
|
127
|
+
else if (type === "application/x-www-form-urlencoded")
|
|
128
|
+
return out(new URLSearchParams(await response.text()));
|
|
129
|
+
else if (type === "multipart/form-data")
|
|
130
|
+
return out(await response.formData());
|
|
131
|
+
else if (type === "application/octet-stream")
|
|
132
|
+
return out(await response.blob());
|
|
133
|
+
return out(await response.text());
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const getPath = (
|
|
138
|
+
props: Pick<HttpMigration.IFetchProps, "route" | "parameters" | "query">,
|
|
139
|
+
): string => {
|
|
140
|
+
let path: string = props.route.emendedPath;
|
|
141
|
+
props.route.parameters.forEach((p, i) => {
|
|
142
|
+
path = path.replace(
|
|
143
|
+
`:${p.key}`,
|
|
144
|
+
encodeURIComponent(
|
|
145
|
+
String(
|
|
146
|
+
(Array.isArray(props.parameters)
|
|
147
|
+
? props.parameters[i]
|
|
148
|
+
: props.parameters[p.key]) ?? "null",
|
|
149
|
+
),
|
|
150
|
+
),
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
if (props.route.query) path += getQueryPath(props.query ?? {});
|
|
154
|
+
return path;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const getQueryPath = (query: Record<string, any>): string => {
|
|
158
|
+
const variables = new URLSearchParams();
|
|
159
|
+
for (const [key, value] of Object.entries(query))
|
|
160
|
+
if (undefined === value) continue;
|
|
161
|
+
else if (Array.isArray(value))
|
|
162
|
+
value.forEach((elem: any) => variables.append(key, String(elem)));
|
|
163
|
+
else variables.set(key, String(value));
|
|
164
|
+
return 0 === variables.size ? "" : `?${variables.toString()}`;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const requestQueryBody = (input: any): URLSearchParams => {
|
|
168
|
+
const q: URLSearchParams = new URLSearchParams();
|
|
169
|
+
for (const [key, value] of Object.entries(input))
|
|
170
|
+
if (value === undefined) continue;
|
|
171
|
+
else if (Array.isArray(value))
|
|
172
|
+
value.forEach((elem) => q.append(key, String(elem)));
|
|
173
|
+
else q.set(key, String(value));
|
|
174
|
+
return q;
|
|
175
|
+
};
|
|
176
|
+
const requestFormDataBody = (input: Record<string, any>): FormData => {
|
|
177
|
+
const encoded: FormData = new FormData();
|
|
178
|
+
const append = (key: string) => (value: any) => {
|
|
179
|
+
if (value === undefined) return;
|
|
180
|
+
else if (typeof File === "function" && value instanceof File)
|
|
181
|
+
encoded.append(key, value, value.name);
|
|
182
|
+
else encoded.append(key, value);
|
|
183
|
+
};
|
|
184
|
+
for (const [key, value] of Object.entries(input))
|
|
185
|
+
if (Array.isArray(value)) value.map(append(key));
|
|
186
|
+
else append(key)(value);
|
|
187
|
+
return encoded;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const responseHeaders = (
|
|
191
|
+
headers: Headers,
|
|
192
|
+
): Record<string, string | string[]> => {
|
|
193
|
+
const output: Record<string, string | string[]> = {};
|
|
194
|
+
headers.forEach((value, key) => {
|
|
195
|
+
if (key === "set-cookie") {
|
|
196
|
+
output[key] ??= [];
|
|
197
|
+
(output[key] as string[]).push(
|
|
198
|
+
...value.split(";").map((str) => str.trim()),
|
|
199
|
+
);
|
|
200
|
+
} else output[key] = value;
|
|
201
|
+
});
|
|
202
|
+
return output;
|
|
203
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ILlmFunction } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Data combiner for LLM function call.
|
|
5
|
+
*
|
|
6
|
+
* @author Samchon
|
|
7
|
+
*/
|
|
8
|
+
export namespace LlmDataMerger {
|
|
9
|
+
/** Properties of {@link parameters} function. */
|
|
10
|
+
export interface IProps {
|
|
11
|
+
/** Target function to call. */
|
|
12
|
+
function: ILlmFunction;
|
|
13
|
+
|
|
14
|
+
/** Arguments composed by LLM (Large Language Model). */
|
|
15
|
+
llm: object | null;
|
|
16
|
+
|
|
17
|
+
/** Arguments composed by human. */
|
|
18
|
+
human: object | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Combine LLM and human arguments into one.
|
|
23
|
+
*
|
|
24
|
+
* When you compose {@link IHttpLlmApplication} with
|
|
25
|
+
* {@link IHttpLlmApplication.IConfig.separate} option, then the arguments of
|
|
26
|
+
* the target function would be separated into two parts; LLM (Large Language
|
|
27
|
+
* Model) and human.
|
|
28
|
+
*
|
|
29
|
+
* In that case, you can combine both LLM and human composed arguments into
|
|
30
|
+
* one by utilizing this {@link LlmDataMerger.parameters} function, referencing
|
|
31
|
+
* the target function metadata {@link ILlmFunction.separated}.
|
|
32
|
+
*
|
|
33
|
+
* @param props Properties to combine LLM and human arguments with metadata.
|
|
34
|
+
* @returns Combined arguments
|
|
35
|
+
*/
|
|
36
|
+
export const parameters = (props: IProps): object => {
|
|
37
|
+
const separated = props.function.separated;
|
|
38
|
+
if (separated === undefined)
|
|
39
|
+
throw new Error(
|
|
40
|
+
"Error on LlmDataMerger.parameters(): the function parameters are not separated.",
|
|
41
|
+
);
|
|
42
|
+
return value(props.llm, props.human) as object;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Combine two values into one.
|
|
47
|
+
*
|
|
48
|
+
* If both values are objects, then combines them in the properties level.
|
|
49
|
+
*
|
|
50
|
+
* Otherwise, returns the latter value if it's not null, otherwise the former
|
|
51
|
+
* value
|
|
52
|
+
*
|
|
53
|
+
* - `return (y ?? x)`
|
|
54
|
+
*
|
|
55
|
+
* @param x Value X
|
|
56
|
+
* @param y Value Y
|
|
57
|
+
* @returns Combined value
|
|
58
|
+
*/
|
|
59
|
+
export const value = (x: unknown, y: unknown): unknown =>
|
|
60
|
+
typeof x === "object" && typeof y === "object" && x !== null && y !== null
|
|
61
|
+
? combineObject(x, y)
|
|
62
|
+
: Array.isArray(x) && Array.isArray(y)
|
|
63
|
+
? new Array(Math.max(x.length, y.length))
|
|
64
|
+
.fill(0)
|
|
65
|
+
.map((_, i) => value(x[i], y[i]))
|
|
66
|
+
: (y ?? x);
|
|
67
|
+
|
|
68
|
+
const combineObject = (x: any, y: any): any => {
|
|
69
|
+
const output: any = { ...x };
|
|
70
|
+
for (const [k, v] of Object.entries(y)) output[k] = value(x[k], v);
|
|
71
|
+
return output;
|
|
72
|
+
};
|
|
73
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export namespace ArrayUtil {
|
|
3
|
+
export const has = <T>(array: T[], pred: (elem: T) => boolean): boolean =>
|
|
4
|
+
array.some(pred);
|
|
5
|
+
|
|
6
|
+
export const add = <T>(
|
|
7
|
+
array: T[],
|
|
8
|
+
value: T,
|
|
9
|
+
pred: (x: T, y: T) => boolean = (x, y) => x === y,
|
|
10
|
+
): boolean => {
|
|
11
|
+
if (array.some((elem) => pred(elem, value))) return false;
|
|
12
|
+
array.push(value);
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const set = <Key, T>(
|
|
17
|
+
array: T[],
|
|
18
|
+
value: T,
|
|
19
|
+
key: (elem: T) => Key,
|
|
20
|
+
): void => {
|
|
21
|
+
if (array.some((elem) => key(elem) === key(value))) return;
|
|
22
|
+
array.push(value);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const take = <T>(
|
|
26
|
+
array: T[],
|
|
27
|
+
pred: (elem: T) => boolean,
|
|
28
|
+
init: () => T,
|
|
29
|
+
): T => {
|
|
30
|
+
const index: number = array.findIndex(pred);
|
|
31
|
+
if (index !== -1) return array[index]!;
|
|
32
|
+
|
|
33
|
+
const elem: T = init();
|
|
34
|
+
array.push(elem);
|
|
35
|
+
return elem;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const repeat = <T>(
|
|
39
|
+
count: number,
|
|
40
|
+
closure: (index: number, count: number) => T,
|
|
41
|
+
): T[] => new Array(count).fill("").map((_, index) => closure(index, count));
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export namespace MapUtil {
|
|
3
|
+
export const take = <Key, T>(
|
|
4
|
+
dict: Map<Key, T>,
|
|
5
|
+
key: Key,
|
|
6
|
+
generator: () => T,
|
|
7
|
+
): T => {
|
|
8
|
+
const oldbie: T | undefined = dict.get(key);
|
|
9
|
+
if (oldbie) return oldbie;
|
|
10
|
+
|
|
11
|
+
const value: T = generator();
|
|
12
|
+
dict.set(key, value);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String naming convention converters.
|
|
3
|
+
*
|
|
4
|
+
* `NamingConvention` converts between common code naming conventions:
|
|
5
|
+
* camelCase, PascalCase, and snake_case. Handles edge cases like consecutive
|
|
6
|
+
* uppercase letters (e.g., `XMLParser` → `xml_parser`) and leading
|
|
7
|
+
* underscores.
|
|
8
|
+
*
|
|
9
|
+
* Functions:
|
|
10
|
+
*
|
|
11
|
+
* - {@link camel}: Convert to camelCase (`fooBar`)
|
|
12
|
+
* - {@link pascal}: Convert to PascalCase (`FooBar`)
|
|
13
|
+
* - {@link snake}: Convert to snake_case (`foo_bar`)
|
|
14
|
+
* - {@link variable}: Test if string is valid JavaScript variable name
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
*/
|
|
18
|
+
export namespace NamingConvention {
|
|
19
|
+
/**
|
|
20
|
+
* Convert to camelCase.
|
|
21
|
+
*
|
|
22
|
+
* @param str Input string
|
|
23
|
+
* @returns CamelCase string
|
|
24
|
+
*/
|
|
25
|
+
export function camel(str: string) {
|
|
26
|
+
return unsnake({
|
|
27
|
+
plain: (str) =>
|
|
28
|
+
str.length
|
|
29
|
+
? str === str.toUpperCase()
|
|
30
|
+
? str.toLocaleLowerCase()
|
|
31
|
+
: `${str[0]!.toLowerCase()}${str.substring(1)}`
|
|
32
|
+
: str,
|
|
33
|
+
snake: (str, i) =>
|
|
34
|
+
i === 0 ? str.toLowerCase() : capitalize(str.toLowerCase()),
|
|
35
|
+
})(str);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Convert to PascalCase.
|
|
40
|
+
*
|
|
41
|
+
* @param str Input string
|
|
42
|
+
* @returns PascalCase string
|
|
43
|
+
*/
|
|
44
|
+
export function pascal(str: string) {
|
|
45
|
+
return unsnake({
|
|
46
|
+
plain: (str) =>
|
|
47
|
+
str.length ? `${str[0]!.toUpperCase()}${str.substring(1)}` : str,
|
|
48
|
+
snake: capitalize,
|
|
49
|
+
})(str);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Convert to snake_case.
|
|
54
|
+
*
|
|
55
|
+
* @param str Input string
|
|
56
|
+
* @returns Snake_case string
|
|
57
|
+
*/
|
|
58
|
+
export function snake(str: string): string {
|
|
59
|
+
if (str.length === 0) return str;
|
|
60
|
+
|
|
61
|
+
// PREFIX
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
|
+
let prefix: string = "";
|
|
64
|
+
for (let i: number = 0; i < str.length; i++) {
|
|
65
|
+
if (str[i] === "_") prefix += "_";
|
|
66
|
+
else break;
|
|
67
|
+
}
|
|
68
|
+
if (prefix.length !== 0) str = str.substring(prefix.length);
|
|
69
|
+
|
|
70
|
+
const out = (s: string) => `${prefix}${s}`;
|
|
71
|
+
|
|
72
|
+
// SNAKE CASE
|
|
73
|
+
const items: string[] = str.split("_");
|
|
74
|
+
if (items.length > 1)
|
|
75
|
+
return out(items.map((s) => s.toLowerCase()).join("_"));
|
|
76
|
+
|
|
77
|
+
// CAMEL OR PASCAL CASE
|
|
78
|
+
const indexes: number[] = [];
|
|
79
|
+
for (let i: number = 0; i < str.length; i++) {
|
|
80
|
+
const code: number = str.charCodeAt(i);
|
|
81
|
+
if (65 <= code && code <= 90) indexes.push(i);
|
|
82
|
+
}
|
|
83
|
+
for (let i: number = indexes.length - 1; i > 0; --i) {
|
|
84
|
+
const now: number = indexes[i]!;
|
|
85
|
+
const prev: number = indexes[i - 1]!;
|
|
86
|
+
if (now - prev === 1) indexes.splice(i, 1);
|
|
87
|
+
}
|
|
88
|
+
if (indexes.length !== 0 && indexes[0] === 0) indexes.splice(0, 1);
|
|
89
|
+
if (indexes.length === 0) return str.toLowerCase();
|
|
90
|
+
|
|
91
|
+
let ret: string = "";
|
|
92
|
+
for (let i: number = 0; i < indexes.length; i++) {
|
|
93
|
+
const first: number = i === 0 ? 0 : indexes[i - 1]!;
|
|
94
|
+
const last: number = indexes[i]!;
|
|
95
|
+
|
|
96
|
+
ret += str.substring(first, last).toLowerCase();
|
|
97
|
+
ret += "_";
|
|
98
|
+
}
|
|
99
|
+
ret += str.substring(indexes[indexes.length - 1]!).toLowerCase();
|
|
100
|
+
return out(ret);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Capitalize first character.
|
|
105
|
+
*
|
|
106
|
+
* @param str Input string
|
|
107
|
+
* @returns Capitalized string
|
|
108
|
+
*/
|
|
109
|
+
export const capitalize = (str: string): string =>
|
|
110
|
+
str.length !== 0 ? str[0]!.toUpperCase() + str.slice(1) : str;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Lowercase first character.
|
|
114
|
+
*
|
|
115
|
+
* @param str Input string
|
|
116
|
+
* @returns Localized string
|
|
117
|
+
*/
|
|
118
|
+
export const localize = (str: string) => str[0]!.toLowerCase() + str.slice(1);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Check if string is valid JavaScript variable name.
|
|
122
|
+
*
|
|
123
|
+
* @param str String to check
|
|
124
|
+
* @returns True if valid variable name
|
|
125
|
+
*/
|
|
126
|
+
export const variable = (str: string): boolean =>
|
|
127
|
+
reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Check if string is JavaScript reserved word.
|
|
131
|
+
*
|
|
132
|
+
* @param str String to check
|
|
133
|
+
* @returns True if reserved word
|
|
134
|
+
*/
|
|
135
|
+
export const reserved = (str: string): boolean => RESERVED.has(str);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const RESERVED: Set<string> = new Set([
|
|
139
|
+
"break",
|
|
140
|
+
"case",
|
|
141
|
+
"catch",
|
|
142
|
+
"class",
|
|
143
|
+
"const",
|
|
144
|
+
"continue",
|
|
145
|
+
"debugger",
|
|
146
|
+
"default",
|
|
147
|
+
"delete",
|
|
148
|
+
"do",
|
|
149
|
+
"else",
|
|
150
|
+
"enum",
|
|
151
|
+
"export",
|
|
152
|
+
"extends",
|
|
153
|
+
"false",
|
|
154
|
+
"finally",
|
|
155
|
+
"for",
|
|
156
|
+
"function",
|
|
157
|
+
"if",
|
|
158
|
+
"import",
|
|
159
|
+
"in",
|
|
160
|
+
"instanceof",
|
|
161
|
+
"module",
|
|
162
|
+
"new",
|
|
163
|
+
"null",
|
|
164
|
+
"package",
|
|
165
|
+
"public",
|
|
166
|
+
"private",
|
|
167
|
+
"protected",
|
|
168
|
+
"return",
|
|
169
|
+
"super",
|
|
170
|
+
"switch",
|
|
171
|
+
"this",
|
|
172
|
+
"throw",
|
|
173
|
+
"true",
|
|
174
|
+
"try",
|
|
175
|
+
"typeof",
|
|
176
|
+
"var",
|
|
177
|
+
"void",
|
|
178
|
+
"while",
|
|
179
|
+
"with",
|
|
180
|
+
]);
|
|
181
|
+
|
|
182
|
+
const unsnake =
|
|
183
|
+
(props: {
|
|
184
|
+
plain: (str: string) => string;
|
|
185
|
+
snake: (str: string, index: number) => string;
|
|
186
|
+
}) =>
|
|
187
|
+
(str: string): string => {
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
189
|
+
let prefix: string = "";
|
|
190
|
+
for (let i: number = 0; i < str.length; i++) {
|
|
191
|
+
if (str[i] === "_") prefix += "_";
|
|
192
|
+
else break;
|
|
193
|
+
}
|
|
194
|
+
if (prefix.length !== 0) str = str.substring(prefix.length);
|
|
195
|
+
|
|
196
|
+
const out = (s: string) => `${prefix}${s}`;
|
|
197
|
+
if (str.length === 0) return out("");
|
|
198
|
+
|
|
199
|
+
const items: string[] = str.split("_").filter((s) => s.length !== 0);
|
|
200
|
+
return items.length === 0
|
|
201
|
+
? out("")
|
|
202
|
+
: items.length === 1
|
|
203
|
+
? out(props.plain(items[0]!))
|
|
204
|
+
: out(items.map(props.snake).join(""));
|
|
205
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export class Singleton<T, Args extends any[] = []> {
|
|
3
|
+
private readonly closure_: (...args: Args) => T;
|
|
4
|
+
private value_: T | object;
|
|
5
|
+
|
|
6
|
+
public constructor(closure: (...args: Args) => T) {
|
|
7
|
+
this.closure_ = closure;
|
|
8
|
+
this.value_ = NOT_MOUNTED_YET;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public get(...args: Args): T {
|
|
12
|
+
if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_(...args);
|
|
13
|
+
return this.value_ as T;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const NOT_MOUNTED_YET = {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export namespace StringUtil {
|
|
3
|
+
export const escapeDuplicate = (props: {
|
|
4
|
+
keep: string[];
|
|
5
|
+
input: string;
|
|
6
|
+
escape?: (str: string) => string;
|
|
7
|
+
}): string =>
|
|
8
|
+
props.keep.includes(props.input)
|
|
9
|
+
? escapeDuplicate({
|
|
10
|
+
keep: props.keep,
|
|
11
|
+
input: (props.escape ?? ((str) => `_${str}`))(props.input),
|
|
12
|
+
})
|
|
13
|
+
: props.input;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove common leading whitespace from template literal.
|
|
3
|
+
*
|
|
4
|
+
* Strips leading/trailing blank lines and removes the minimum indentation level
|
|
5
|
+
* from all lines.
|
|
6
|
+
*
|
|
7
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
8
|
+
* @param strings Template literal strings
|
|
9
|
+
* @param values Interpolated values
|
|
10
|
+
* @returns Dedented string
|
|
11
|
+
*/
|
|
12
|
+
export function dedent(
|
|
13
|
+
strings: TemplateStringsArray,
|
|
14
|
+
...values: Array<boolean | number | string>
|
|
15
|
+
): string {
|
|
16
|
+
// Combine all template string parts to understand the full structure
|
|
17
|
+
let combined: string = strings[0]!;
|
|
18
|
+
for (let i = 0; i < values.length; i++) {
|
|
19
|
+
combined += `__PLACEHOLDER_${i}__` + strings[i + 1];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Split into lines
|
|
23
|
+
const lines = combined.split("\n");
|
|
24
|
+
|
|
25
|
+
// Remove leading and trailing empty lines
|
|
26
|
+
while (lines.length > 0 && lines[0]!.trim() === "") {
|
|
27
|
+
lines.shift();
|
|
28
|
+
}
|
|
29
|
+
while (lines.length > 0 && lines[lines.length - 1]!.trim() === "") {
|
|
30
|
+
lines.pop();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (lines.length === 0) return "";
|
|
34
|
+
|
|
35
|
+
// Find minimum indentation from non-empty lines
|
|
36
|
+
const nonEmptyLines = lines.filter((line) => line.trim() !== "");
|
|
37
|
+
const minIndent = Math.min(
|
|
38
|
+
...nonEmptyLines.map((line) => {
|
|
39
|
+
const match = line.match(/^[ \t]*/);
|
|
40
|
+
return match ? match[0].length : 0;
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Remove minimum indentation from all lines
|
|
45
|
+
const dedentedLines = lines.map((line) => {
|
|
46
|
+
if (line.trim() === "") return "";
|
|
47
|
+
return line.slice(minIndent);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Replace placeholders with actual values
|
|
51
|
+
let result = dedentedLines.join("\n");
|
|
52
|
+
for (let i = 0; i < values.length; i++) {
|
|
53
|
+
result = result.replace(`__PLACEHOLDER_${i}__`, String(values[i]));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NamingConvention } from "../NamingConvention";
|
|
2
|
+
|
|
3
|
+
export namespace EndpointUtil {
|
|
4
|
+
export const capitalize = (str: string): string =>
|
|
5
|
+
str.length !== 0 ? str[0]!.toUpperCase() + str.slice(1).toLowerCase() : str;
|
|
6
|
+
|
|
7
|
+
export const pascal = (path: string): string =>
|
|
8
|
+
splitWithNormalization(path)
|
|
9
|
+
.filter((str) => str[0] !== "{")
|
|
10
|
+
.map(NamingConvention.pascal)
|
|
11
|
+
.join("");
|
|
12
|
+
|
|
13
|
+
export const splitWithNormalization = (path: string): string[] =>
|
|
14
|
+
path
|
|
15
|
+
.split("/")
|
|
16
|
+
.map((str) => normalize(str.trim()))
|
|
17
|
+
.filter((str) => !!str.length);
|
|
18
|
+
|
|
19
|
+
export const reJoinWithDecimalParameters = (path: string) => {
|
|
20
|
+
path = path
|
|
21
|
+
.split("/")
|
|
22
|
+
.map((str) =>
|
|
23
|
+
str[0] === "{" && str[str.length - 1] === "}"
|
|
24
|
+
? `:${str.substring(1, str.length - 1)}`
|
|
25
|
+
: str,
|
|
26
|
+
)
|
|
27
|
+
.join("/");
|
|
28
|
+
return `${path.startsWith("/") ? "" : "/"}${path}`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const normalize = (str: string): string => {
|
|
32
|
+
str = str.split(".").join("_").split("-").join("_").trim();
|
|
33
|
+
if (str.length === 0) return str;
|
|
34
|
+
else if (NamingConvention.reserved(str)) return `_${str}`;
|
|
35
|
+
else if (str.length !== 0 && "0" <= str[0]! && str[0]! <= "9")
|
|
36
|
+
str = `_${str}`;
|
|
37
|
+
return str;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const escapeDuplicate =
|
|
41
|
+
(keep: string[]) =>
|
|
42
|
+
(change: string): string =>
|
|
43
|
+
keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
|
|
44
|
+
}
|