@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,402 @@
|
|
|
1
|
+
import { ILlmSchema } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { MapUtil } from "../utils/MapUtil";
|
|
4
|
+
import { OpenApiTypeCheckerBase } from "../utils/internal/OpenApiTypeCheckerBase";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type checker for LLM function calling schema.
|
|
8
|
+
*
|
|
9
|
+
* `LlmTypeChecker` is a type checker of {@link ILlmSchema}, the type schema for
|
|
10
|
+
* LLM (Large Language Model) function calling.
|
|
11
|
+
*
|
|
12
|
+
* This checker provides type guard functions for validating schema types, and
|
|
13
|
+
* operators for traversing and comparing schemas.
|
|
14
|
+
*
|
|
15
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
16
|
+
*/
|
|
17
|
+
export namespace LlmTypeChecker {
|
|
18
|
+
/* -----------------------------------------------------------
|
|
19
|
+
TYPE CHECKERS
|
|
20
|
+
----------------------------------------------------------- */
|
|
21
|
+
/**
|
|
22
|
+
* Test whether the schema is a null type.
|
|
23
|
+
*
|
|
24
|
+
* @param schema Target schema
|
|
25
|
+
* @returns Whether null type or not
|
|
26
|
+
*/
|
|
27
|
+
export const isNull = (schema: ILlmSchema): schema is ILlmSchema.INull =>
|
|
28
|
+
(schema as ILlmSchema.INull).type === "null";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Test whether the schema is an unknown type.
|
|
32
|
+
*
|
|
33
|
+
* @param schema Target schema
|
|
34
|
+
* @returns Whether unknown type or not
|
|
35
|
+
*/
|
|
36
|
+
export const isUnknown = (
|
|
37
|
+
schema: ILlmSchema,
|
|
38
|
+
): schema is ILlmSchema.IUnknown =>
|
|
39
|
+
(schema as ILlmSchema.IUnknown).type === undefined &&
|
|
40
|
+
!isAnyOf(schema) &&
|
|
41
|
+
!isReference(schema);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Test whether the schema is a boolean type.
|
|
45
|
+
*
|
|
46
|
+
* @param schema Target schema
|
|
47
|
+
* @returns Whether boolean type or not
|
|
48
|
+
*/
|
|
49
|
+
export const isBoolean = (
|
|
50
|
+
schema: ILlmSchema,
|
|
51
|
+
): schema is ILlmSchema.IBoolean =>
|
|
52
|
+
(schema as ILlmSchema.IBoolean).type === "boolean";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Test whether the schema is an integer type.
|
|
56
|
+
*
|
|
57
|
+
* @param schema Target schema
|
|
58
|
+
* @returns Whether integer type or not
|
|
59
|
+
*/
|
|
60
|
+
export const isInteger = (
|
|
61
|
+
schema: ILlmSchema,
|
|
62
|
+
): schema is ILlmSchema.IInteger =>
|
|
63
|
+
(schema as ILlmSchema.IInteger).type === "integer";
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Test whether the schema is a number type.
|
|
67
|
+
*
|
|
68
|
+
* @param schema Target schema
|
|
69
|
+
* @returns Whether number type or not
|
|
70
|
+
*/
|
|
71
|
+
export const isNumber = (schema: ILlmSchema): schema is ILlmSchema.INumber =>
|
|
72
|
+
(schema as ILlmSchema.INumber).type === "number";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Test whether the schema is a string type.
|
|
76
|
+
*
|
|
77
|
+
* @param schema Target schema
|
|
78
|
+
* @returns Whether string type or not
|
|
79
|
+
*/
|
|
80
|
+
export const isString = (schema: ILlmSchema): schema is ILlmSchema.IString =>
|
|
81
|
+
(schema as ILlmSchema.IString).type === "string";
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Test whether the schema is an array type.
|
|
85
|
+
*
|
|
86
|
+
* @param schema Target schema
|
|
87
|
+
* @returns Whether array type or not
|
|
88
|
+
*/
|
|
89
|
+
export const isArray = (schema: ILlmSchema): schema is ILlmSchema.IArray =>
|
|
90
|
+
(schema as ILlmSchema.IArray).type === "array" &&
|
|
91
|
+
(schema as ILlmSchema.IArray).items !== undefined;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Test whether the schema is an object type.
|
|
95
|
+
*
|
|
96
|
+
* @param schema Target schema
|
|
97
|
+
* @returns Whether object type or not
|
|
98
|
+
*/
|
|
99
|
+
export const isObject = (schema: ILlmSchema): schema is ILlmSchema.IObject =>
|
|
100
|
+
(schema as ILlmSchema.IObject).type === "object";
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Test whether the schema is a reference type.
|
|
104
|
+
*
|
|
105
|
+
* @param schema Target schema
|
|
106
|
+
* @returns Whether reference type or not
|
|
107
|
+
*/
|
|
108
|
+
export const isReference = (
|
|
109
|
+
schema: ILlmSchema,
|
|
110
|
+
): schema is ILlmSchema.IReference => (schema as any).$ref !== undefined;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Test whether the schema is a union type.
|
|
114
|
+
*
|
|
115
|
+
* @param schema Target schema
|
|
116
|
+
* @returns Whether union type or not
|
|
117
|
+
*/
|
|
118
|
+
export const isAnyOf = (schema: ILlmSchema): schema is ILlmSchema.IAnyOf =>
|
|
119
|
+
(schema as ILlmSchema.IAnyOf).anyOf !== undefined;
|
|
120
|
+
|
|
121
|
+
/* -----------------------------------------------------------
|
|
122
|
+
OPERATORS
|
|
123
|
+
----------------------------------------------------------- */
|
|
124
|
+
/**
|
|
125
|
+
* Visit every nested schemas.
|
|
126
|
+
*
|
|
127
|
+
* Visit every nested schemas of the target, and apply the `props.closure`
|
|
128
|
+
* function.
|
|
129
|
+
*
|
|
130
|
+
* Here is the list of occurring nested visitings:
|
|
131
|
+
*
|
|
132
|
+
* - {@link ILlmSchema.IAnyOf.anyOf}
|
|
133
|
+
* - {@link ILlmSchema.IReference}
|
|
134
|
+
* - {@link ILlmSchema.IObject.properties}
|
|
135
|
+
* - {@link ILlmSchema.IArray.items}
|
|
136
|
+
*
|
|
137
|
+
* @param props Properties for visiting
|
|
138
|
+
*/
|
|
139
|
+
export const visit = (props: {
|
|
140
|
+
closure: (schema: ILlmSchema, accessor: string) => void;
|
|
141
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
142
|
+
schema: ILlmSchema;
|
|
143
|
+
accessor?: string;
|
|
144
|
+
refAccessor?: string;
|
|
145
|
+
}): void => {
|
|
146
|
+
const already: Set<string> = new Set();
|
|
147
|
+
const refAccessor: string = props.refAccessor ?? "$input.$defs";
|
|
148
|
+
const next = (schema: ILlmSchema, accessor: string): void => {
|
|
149
|
+
props.closure(schema, accessor);
|
|
150
|
+
if (LlmTypeChecker.isReference(schema)) {
|
|
151
|
+
const key: string = schema.$ref.split("#/$defs/").pop()!;
|
|
152
|
+
if (already.has(key) === true) return;
|
|
153
|
+
already.add(key);
|
|
154
|
+
const found: ILlmSchema | undefined = props.$defs?.[key];
|
|
155
|
+
if (found !== undefined) next(found, `${refAccessor}[${key}]`);
|
|
156
|
+
} else if (LlmTypeChecker.isAnyOf(schema))
|
|
157
|
+
schema.anyOf.forEach((s, i) => next(s, `${accessor}.anyOf[${i}]`));
|
|
158
|
+
else if (LlmTypeChecker.isObject(schema)) {
|
|
159
|
+
for (const [key, value] of Object.entries(schema.properties))
|
|
160
|
+
next(value, `${accessor}.properties[${JSON.stringify(key)}]`);
|
|
161
|
+
if (
|
|
162
|
+
typeof schema.additionalProperties === "object" &&
|
|
163
|
+
schema.additionalProperties !== null
|
|
164
|
+
)
|
|
165
|
+
next(schema.additionalProperties, `${accessor}.additionalProperties`);
|
|
166
|
+
} else if (LlmTypeChecker.isArray(schema))
|
|
167
|
+
next(schema.items, `${accessor}.items`);
|
|
168
|
+
};
|
|
169
|
+
next(props.schema, props.accessor ?? "$input.schemas");
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Test whether the `x` schema covers the `y` schema.
|
|
174
|
+
*
|
|
175
|
+
* @param props Properties for testing
|
|
176
|
+
* @returns Whether the `x` schema covers the `y` schema
|
|
177
|
+
*/
|
|
178
|
+
export const covers = (props: {
|
|
179
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
180
|
+
x: ILlmSchema;
|
|
181
|
+
y: ILlmSchema;
|
|
182
|
+
}): boolean =>
|
|
183
|
+
coverStation({
|
|
184
|
+
$defs: props.$defs,
|
|
185
|
+
x: props.x,
|
|
186
|
+
y: props.y,
|
|
187
|
+
visited: new Map(),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const coverStation = (p: {
|
|
191
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
192
|
+
visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
|
|
193
|
+
x: ILlmSchema;
|
|
194
|
+
y: ILlmSchema;
|
|
195
|
+
}): boolean => {
|
|
196
|
+
const cache: boolean | undefined = p.visited.get(p.x)?.get(p.y);
|
|
197
|
+
if (cache !== undefined) return cache;
|
|
198
|
+
|
|
199
|
+
// FOR RECURSIVE CASE
|
|
200
|
+
const nested: Map<ILlmSchema, boolean> = MapUtil.take(
|
|
201
|
+
p.visited,
|
|
202
|
+
p.x,
|
|
203
|
+
() => new Map(),
|
|
204
|
+
);
|
|
205
|
+
nested.set(p.y, true);
|
|
206
|
+
|
|
207
|
+
// COMPUTE IT
|
|
208
|
+
const result: boolean = coverSchema(p);
|
|
209
|
+
nested.set(p.y, result);
|
|
210
|
+
return result;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const coverSchema = (p: {
|
|
214
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
215
|
+
visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
|
|
216
|
+
x: ILlmSchema;
|
|
217
|
+
y: ILlmSchema;
|
|
218
|
+
}): boolean => {
|
|
219
|
+
// CHECK EQUALITY
|
|
220
|
+
if (p.x === p.y) return true;
|
|
221
|
+
else if (isReference(p.x) && isReference(p.y) && p.x.$ref === p.y.$ref)
|
|
222
|
+
return true;
|
|
223
|
+
|
|
224
|
+
// COMPARE WITH FLATTENING
|
|
225
|
+
const alpha: ILlmSchema[] = flatSchema(p.$defs, p.x);
|
|
226
|
+
const beta: ILlmSchema[] = flatSchema(p.$defs, p.y);
|
|
227
|
+
if (alpha.some((x) => isUnknown(x))) return true;
|
|
228
|
+
else if (beta.some((x) => isUnknown(x))) return false;
|
|
229
|
+
return beta.every((b) =>
|
|
230
|
+
alpha.some((a) =>
|
|
231
|
+
coverEscapedSchema({
|
|
232
|
+
$defs: p.$defs,
|
|
233
|
+
visited: p.visited,
|
|
234
|
+
x: a,
|
|
235
|
+
y: b,
|
|
236
|
+
}),
|
|
237
|
+
),
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const coverEscapedSchema = (p: {
|
|
242
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
243
|
+
visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
|
|
244
|
+
x: ILlmSchema;
|
|
245
|
+
y: ILlmSchema;
|
|
246
|
+
}): boolean => {
|
|
247
|
+
// CHECK EQUALITY
|
|
248
|
+
if (p.x === p.y) return true;
|
|
249
|
+
else if (isUnknown(p.x)) return true;
|
|
250
|
+
else if (isUnknown(p.y)) return false;
|
|
251
|
+
else if (isNull(p.x)) return isNull(p.y);
|
|
252
|
+
// ATOMIC CASE
|
|
253
|
+
else if (isBoolean(p.x)) return isBoolean(p.y) && coverBoolean(p.x, p.y);
|
|
254
|
+
else if (isInteger(p.x)) return isInteger(p.y) && coverInteger(p.x, p.y);
|
|
255
|
+
else if (isNumber(p.x)) return isNumber(p.y) && coverNumber(p.x, p.y);
|
|
256
|
+
else if (isString(p.x)) return isString(p.y) && coverString(p.x, p.y);
|
|
257
|
+
// INSTANCE CASE
|
|
258
|
+
else if (isArray(p.x))
|
|
259
|
+
return (
|
|
260
|
+
isArray(p.y) &&
|
|
261
|
+
coverArray({
|
|
262
|
+
$defs: p.$defs,
|
|
263
|
+
visited: p.visited,
|
|
264
|
+
x: p.x,
|
|
265
|
+
y: p.y,
|
|
266
|
+
})
|
|
267
|
+
);
|
|
268
|
+
else if (isObject(p.x))
|
|
269
|
+
return (
|
|
270
|
+
isObject(p.y) &&
|
|
271
|
+
coverObject({
|
|
272
|
+
$defs: p.$defs,
|
|
273
|
+
visited: p.visited,
|
|
274
|
+
x: p.x,
|
|
275
|
+
y: p.y,
|
|
276
|
+
})
|
|
277
|
+
);
|
|
278
|
+
else if (isReference(p.x)) return isReference(p.y) && p.x.$ref === p.y.$ref;
|
|
279
|
+
return false;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const coverArray = (p: {
|
|
283
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
284
|
+
visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
|
|
285
|
+
x: ILlmSchema.IArray;
|
|
286
|
+
y: ILlmSchema.IArray;
|
|
287
|
+
}): boolean => {
|
|
288
|
+
if (
|
|
289
|
+
!(
|
|
290
|
+
p.x.minItems === undefined ||
|
|
291
|
+
(p.y.minItems !== undefined && p.x.minItems <= p.y.minItems)
|
|
292
|
+
)
|
|
293
|
+
)
|
|
294
|
+
return false;
|
|
295
|
+
else if (
|
|
296
|
+
!(
|
|
297
|
+
p.x.maxItems === undefined ||
|
|
298
|
+
(p.y.maxItems !== undefined && p.x.maxItems >= p.y.maxItems)
|
|
299
|
+
)
|
|
300
|
+
)
|
|
301
|
+
return false;
|
|
302
|
+
return coverStation({
|
|
303
|
+
$defs: p.$defs,
|
|
304
|
+
visited: p.visited,
|
|
305
|
+
x: p.x.items,
|
|
306
|
+
y: p.y.items,
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const coverObject = (p: {
|
|
311
|
+
$defs?: Record<string, ILlmSchema> | undefined;
|
|
312
|
+
visited: Map<ILlmSchema, Map<ILlmSchema, boolean>>;
|
|
313
|
+
x: ILlmSchema.IObject;
|
|
314
|
+
y: ILlmSchema.IObject;
|
|
315
|
+
}): boolean => {
|
|
316
|
+
if (!p.x.additionalProperties && !!p.y.additionalProperties) return false;
|
|
317
|
+
else if (
|
|
318
|
+
!!p.x.additionalProperties &&
|
|
319
|
+
!!p.y.additionalProperties &&
|
|
320
|
+
((typeof p.x.additionalProperties === "object" &&
|
|
321
|
+
p.y.additionalProperties === true) ||
|
|
322
|
+
(typeof p.x.additionalProperties === "object" &&
|
|
323
|
+
typeof p.y.additionalProperties === "object" &&
|
|
324
|
+
!coverStation({
|
|
325
|
+
$defs: p.$defs,
|
|
326
|
+
visited: p.visited,
|
|
327
|
+
x: p.x.additionalProperties,
|
|
328
|
+
y: p.y.additionalProperties,
|
|
329
|
+
})))
|
|
330
|
+
)
|
|
331
|
+
return false;
|
|
332
|
+
return Object.entries(p.y.properties ?? {}).every(([key, b]) => {
|
|
333
|
+
const a: ILlmSchema | undefined = p.x.properties?.[key];
|
|
334
|
+
if (a === undefined) return false;
|
|
335
|
+
else if (
|
|
336
|
+
(p.x.required?.includes(key) ?? false) === true &&
|
|
337
|
+
(p.y.required?.includes(key) ?? false) === false
|
|
338
|
+
)
|
|
339
|
+
return false;
|
|
340
|
+
return coverStation({
|
|
341
|
+
$defs: p.$defs,
|
|
342
|
+
visited: p.visited,
|
|
343
|
+
x: a,
|
|
344
|
+
y: b,
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const coverBoolean = (
|
|
350
|
+
x: ILlmSchema.IBoolean,
|
|
351
|
+
y: ILlmSchema.IBoolean,
|
|
352
|
+
): boolean => {
|
|
353
|
+
if (!!x.enum?.length)
|
|
354
|
+
return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
|
|
355
|
+
return true;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
const coverInteger = (
|
|
359
|
+
x: ILlmSchema.IInteger,
|
|
360
|
+
y: ILlmSchema.IInteger,
|
|
361
|
+
): boolean => {
|
|
362
|
+
if (!!x.enum?.length)
|
|
363
|
+
return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
|
|
364
|
+
return OpenApiTypeCheckerBase.coverInteger(x, y);
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
const coverNumber = (
|
|
368
|
+
x: ILlmSchema.INumber,
|
|
369
|
+
y: ILlmSchema.IInteger | ILlmSchema.INumber,
|
|
370
|
+
): boolean => {
|
|
371
|
+
if (!!x.enum?.length)
|
|
372
|
+
return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
|
|
373
|
+
return OpenApiTypeCheckerBase.coverNumber(x, y);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
const coverString = (
|
|
377
|
+
x: ILlmSchema.IString,
|
|
378
|
+
y: ILlmSchema.IString,
|
|
379
|
+
): boolean => {
|
|
380
|
+
if (!!x.enum?.length)
|
|
381
|
+
return !!y.enum?.length && y.enum.every((v) => x.enum!.includes(v));
|
|
382
|
+
return OpenApiTypeCheckerBase.coverString(x, y);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const flatSchema = (
|
|
386
|
+
$defs: Record<string, ILlmSchema> | undefined,
|
|
387
|
+
schema: ILlmSchema,
|
|
388
|
+
): ILlmSchema[] => {
|
|
389
|
+
schema = escapeReference($defs, schema);
|
|
390
|
+
if (isAnyOf(schema))
|
|
391
|
+
return schema.anyOf.map((v) => flatSchema($defs, v)).flat();
|
|
392
|
+
return [schema];
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
const escapeReference = (
|
|
396
|
+
$defs: Record<string, ILlmSchema> | undefined,
|
|
397
|
+
schema: ILlmSchema,
|
|
398
|
+
): Exclude<ILlmSchema, ILlmSchema.IReference> =>
|
|
399
|
+
isReference(schema)
|
|
400
|
+
? escapeReference($defs, $defs![schema.$ref.replace("#/$defs/", "")]!)
|
|
401
|
+
: schema;
|
|
402
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { IJsonSchemaTransformError, IResult, OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiTypeCheckerBase } from "../utils/internal/OpenApiTypeCheckerBase";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type checker for emended OpenAPI v3.1 JSON schemas.
|
|
7
|
+
*
|
|
8
|
+
* `OpenApiTypeChecker` provides type guard functions for
|
|
9
|
+
* {@link OpenApi.IJsonSchema} (typia's normalized OpenAPI format). Use these to
|
|
10
|
+
* narrow schema types before accessing type-specific properties.
|
|
11
|
+
*
|
|
12
|
+
* Type checkers:
|
|
13
|
+
*
|
|
14
|
+
* - Primitives: {@link isNull}, {@link isBoolean}, {@link isInteger},
|
|
15
|
+
* {@link isNumber}, {@link isString}
|
|
16
|
+
* - Constants: {@link isConstant}
|
|
17
|
+
* - Collections: {@link isArray}, {@link isTuple}, {@link isObject}
|
|
18
|
+
* - Composition: {@link isOneOf}, {@link isReference}
|
|
19
|
+
* - Special: {@link isUnknown}
|
|
20
|
+
*
|
|
21
|
+
* Also provides schema operations:
|
|
22
|
+
*
|
|
23
|
+
* - {@link visit}: Traverse and transform schemas recursively
|
|
24
|
+
* - {@link covers}: Check if one schema subsumes another
|
|
25
|
+
* - {@link escape}: Unwrap reference schemas
|
|
26
|
+
*
|
|
27
|
+
* For other OpenAPI versions, use {@link OpenApiV3TypeChecker},
|
|
28
|
+
* {@link OpenApiV3_1TypeChecker}, or {@link SwaggerV2TypeChecker}.
|
|
29
|
+
*
|
|
30
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
31
|
+
*/
|
|
32
|
+
export namespace OpenApiTypeChecker {
|
|
33
|
+
/* -----------------------------------------------------------
|
|
34
|
+
TYPE CHECKERS
|
|
35
|
+
----------------------------------------------------------- */
|
|
36
|
+
/**
|
|
37
|
+
* Test whether the schema is a nul type.
|
|
38
|
+
*
|
|
39
|
+
* @param schema Target schema
|
|
40
|
+
* @returns Whether null type or not
|
|
41
|
+
*/
|
|
42
|
+
export const isNull = (
|
|
43
|
+
schema: OpenApi.IJsonSchema,
|
|
44
|
+
): schema is OpenApi.IJsonSchema.INull =>
|
|
45
|
+
OpenApiTypeCheckerBase.isNull(schema);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Test whether the schema is an unknown type.
|
|
49
|
+
*
|
|
50
|
+
* @param schema Target schema
|
|
51
|
+
* @returns Whether unknown type or not
|
|
52
|
+
*/
|
|
53
|
+
export const isUnknown = (
|
|
54
|
+
schema: OpenApi.IJsonSchema,
|
|
55
|
+
): schema is OpenApi.IJsonSchema.IUnknown =>
|
|
56
|
+
OpenApiTypeCheckerBase.isUnknown(schema);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Test whether the schema is a constant type.
|
|
60
|
+
*
|
|
61
|
+
* @param schema Target schema
|
|
62
|
+
* @returns Whether constant type or not
|
|
63
|
+
*/
|
|
64
|
+
export const isConstant = (
|
|
65
|
+
schema: OpenApi.IJsonSchema,
|
|
66
|
+
): schema is OpenApi.IJsonSchema.IConstant =>
|
|
67
|
+
OpenApiTypeCheckerBase.isConstant(schema);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Test whether the schema is a boolean type.
|
|
71
|
+
*
|
|
72
|
+
* @param schema Target schema
|
|
73
|
+
* @returns Whether boolean type or not
|
|
74
|
+
*/
|
|
75
|
+
export const isBoolean = (
|
|
76
|
+
schema: OpenApi.IJsonSchema,
|
|
77
|
+
): schema is OpenApi.IJsonSchema.IBoolean =>
|
|
78
|
+
OpenApiTypeCheckerBase.isBoolean(schema);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Test whether the schema is an integer type.
|
|
82
|
+
*
|
|
83
|
+
* @param schema Target schema
|
|
84
|
+
* @returns Whether integer type or not
|
|
85
|
+
*/
|
|
86
|
+
export const isInteger = (
|
|
87
|
+
schema: OpenApi.IJsonSchema,
|
|
88
|
+
): schema is OpenApi.IJsonSchema.IInteger =>
|
|
89
|
+
OpenApiTypeCheckerBase.isInteger(schema);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Test whether the schema is a number type.
|
|
93
|
+
*
|
|
94
|
+
* @param schema Target schema
|
|
95
|
+
* @returns Whether number type or not
|
|
96
|
+
*/
|
|
97
|
+
export const isNumber = (
|
|
98
|
+
schema: OpenApi.IJsonSchema,
|
|
99
|
+
): schema is OpenApi.IJsonSchema.INumber =>
|
|
100
|
+
OpenApiTypeCheckerBase.isNumber(schema);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Test whether the schema is a string type.
|
|
104
|
+
*
|
|
105
|
+
* @param schema Target schema
|
|
106
|
+
* @returns Whether string type or not
|
|
107
|
+
*/
|
|
108
|
+
export const isString = (
|
|
109
|
+
schema: OpenApi.IJsonSchema,
|
|
110
|
+
): schema is OpenApi.IJsonSchema.IString =>
|
|
111
|
+
OpenApiTypeCheckerBase.isString(schema);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Test whether the schema is an array type.
|
|
115
|
+
*
|
|
116
|
+
* @param schema Target schema
|
|
117
|
+
* @returns Whether array type or not
|
|
118
|
+
*/
|
|
119
|
+
export const isArray = (
|
|
120
|
+
schema: OpenApi.IJsonSchema,
|
|
121
|
+
): schema is OpenApi.IJsonSchema.IArray =>
|
|
122
|
+
OpenApiTypeCheckerBase.isArray(schema);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Test whether the schema is a tuple type.
|
|
126
|
+
*
|
|
127
|
+
* @param schema Target schema
|
|
128
|
+
* @returns Whether tuple type or not
|
|
129
|
+
*/
|
|
130
|
+
export const isTuple = (
|
|
131
|
+
schema: OpenApi.IJsonSchema,
|
|
132
|
+
): schema is OpenApi.IJsonSchema.ITuple =>
|
|
133
|
+
OpenApiTypeCheckerBase.isTuple(schema);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Test whether the schema is an object type.
|
|
137
|
+
*
|
|
138
|
+
* @param schema Target schema
|
|
139
|
+
* @returns Whether object type or not
|
|
140
|
+
*/
|
|
141
|
+
export const isObject = (
|
|
142
|
+
schema: OpenApi.IJsonSchema,
|
|
143
|
+
): schema is OpenApi.IJsonSchema.IObject =>
|
|
144
|
+
OpenApiTypeCheckerBase.isObject(schema);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Test whether the schema is a reference type.
|
|
148
|
+
*
|
|
149
|
+
* @param schema Target schema
|
|
150
|
+
* @returns Whether reference type or not
|
|
151
|
+
*/
|
|
152
|
+
export const isReference = (
|
|
153
|
+
schema: OpenApi.IJsonSchema,
|
|
154
|
+
): schema is OpenApi.IJsonSchema.IReference =>
|
|
155
|
+
OpenApiTypeCheckerBase.isReference(schema);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Test whether the schema is an union type.
|
|
159
|
+
*
|
|
160
|
+
* @param schema Target schema
|
|
161
|
+
* @returns Whether union type or not
|
|
162
|
+
*/
|
|
163
|
+
export const isOneOf = (
|
|
164
|
+
schema: OpenApi.IJsonSchema,
|
|
165
|
+
): schema is OpenApi.IJsonSchema.IOneOf =>
|
|
166
|
+
OpenApiTypeCheckerBase.isOneOf(schema);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Test whether the schema is recursive reference type.
|
|
170
|
+
*
|
|
171
|
+
* Test whether the target schema is a reference type, and test one thing more
|
|
172
|
+
* that the reference is self-recursive or not.
|
|
173
|
+
*
|
|
174
|
+
* @param props Properties for recursive reference test
|
|
175
|
+
* @returns Whether the schema is recursive reference type or not
|
|
176
|
+
*/
|
|
177
|
+
export const isRecursiveReference = (props: {
|
|
178
|
+
components: OpenApi.IComponents;
|
|
179
|
+
schema: OpenApi.IJsonSchema;
|
|
180
|
+
}): boolean =>
|
|
181
|
+
OpenApiTypeCheckerBase.isRecursiveReference({
|
|
182
|
+
prefix: "#/components/schemas/",
|
|
183
|
+
components: props.components,
|
|
184
|
+
schema: props.schema,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/* -----------------------------------------------------------
|
|
188
|
+
OPERATORS
|
|
189
|
+
----------------------------------------------------------- */
|
|
190
|
+
/**
|
|
191
|
+
* Escape from the {@link OpenApi.IJsonSchema.IReference} type.
|
|
192
|
+
*
|
|
193
|
+
* Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the
|
|
194
|
+
* every references to the actual schemas. If the escape is successful, the
|
|
195
|
+
* returned schema never contains any {@link OpenApi.IJsonSchema.IReference}
|
|
196
|
+
* type in its structure.
|
|
197
|
+
*
|
|
198
|
+
* If the schema has a recursive reference, the recursive reference would be
|
|
199
|
+
* repeated as much as the `props.recursive` depth. If you've configured the
|
|
200
|
+
* `props.recursive` as `false` or `0`, it would be failed and return an
|
|
201
|
+
* {@link IJsonSchemaTransformError}. Also, if there's a
|
|
202
|
+
* {@link OpenApi.IJsonSchema.IReference} type which cannot find the matched
|
|
203
|
+
* type in the {@link OpenApi.IComponents.schemas}, it would also be failed and
|
|
204
|
+
* return an {@link IJsonSchemaTransformError} either.
|
|
205
|
+
*
|
|
206
|
+
* @param props Properties for escaping
|
|
207
|
+
* @returns Escaped schema, or error with reason
|
|
208
|
+
*/
|
|
209
|
+
export const escape = (props: {
|
|
210
|
+
components: OpenApi.IComponents;
|
|
211
|
+
schema: OpenApi.IJsonSchema;
|
|
212
|
+
recursive: false | number;
|
|
213
|
+
accessor?: string;
|
|
214
|
+
refAccessor?: string;
|
|
215
|
+
}): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
|
|
216
|
+
OpenApiTypeCheckerBase.escape({
|
|
217
|
+
...props,
|
|
218
|
+
prefix: "#/components/schemas/",
|
|
219
|
+
method: "OpenApiTypeChecker.method",
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Unreference the schema.
|
|
224
|
+
*
|
|
225
|
+
* Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference}
|
|
226
|
+
* type to the actual schema. Different with {@link escape} is, the
|
|
227
|
+
* `unreference` function does not resolve every references in the schema, but
|
|
228
|
+
* resolve only one time.
|
|
229
|
+
*
|
|
230
|
+
* If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find
|
|
231
|
+
* the matched type in the {@link OpenApi.IComponents.schemas}, and you've
|
|
232
|
+
* called this `unreference()` function with the reference, it would also be
|
|
233
|
+
* failed and return an {@link IJsonSchemaTransformError} value.
|
|
234
|
+
*
|
|
235
|
+
* @param props Properties of unreference
|
|
236
|
+
* @returns Unreferenced schema
|
|
237
|
+
*/
|
|
238
|
+
export const unreference = (props: {
|
|
239
|
+
components: OpenApi.IComponents;
|
|
240
|
+
schema: OpenApi.IJsonSchema;
|
|
241
|
+
accessor?: string;
|
|
242
|
+
refAccessor?: string;
|
|
243
|
+
}): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
|
|
244
|
+
OpenApiTypeCheckerBase.unreference({
|
|
245
|
+
...props,
|
|
246
|
+
prefix: "#/components/schemas/",
|
|
247
|
+
method: "OpenApiTypeChecker.unreference",
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Visit every nested schemas.
|
|
252
|
+
*
|
|
253
|
+
* Visit every nested schemas of the target, and apply the `props.closure`
|
|
254
|
+
* function.
|
|
255
|
+
*
|
|
256
|
+
* Here is the list of occurring nested visitings:
|
|
257
|
+
*
|
|
258
|
+
* - {@link OpenApi.IJsonSchema.IOneOf.oneOf}
|
|
259
|
+
* - {@link OpenApi.IJsonSchema.IReference}
|
|
260
|
+
* - {@link OpenApi.IJsonSchema.IObject.properties}
|
|
261
|
+
* - {@link OpenApi.IJsonSchema.IObject.additionalProperties}
|
|
262
|
+
* - {@link OpenApi.IJsonSchema.IArray.items}
|
|
263
|
+
* - {@link OpenApi.IJsonSchema.ITuple.prefixItems}
|
|
264
|
+
* - {@link OpenApi.IJsonSchema.ITuple.additionalItems}
|
|
265
|
+
*
|
|
266
|
+
* @param props Properties for visiting
|
|
267
|
+
*/
|
|
268
|
+
export const visit = (props: {
|
|
269
|
+
closure: (schema: OpenApi.IJsonSchema, accessor: string) => void;
|
|
270
|
+
components: OpenApi.IComponents;
|
|
271
|
+
schema: OpenApi.IJsonSchema;
|
|
272
|
+
accessor?: string;
|
|
273
|
+
refAccessor?: string;
|
|
274
|
+
}): void =>
|
|
275
|
+
OpenApiTypeCheckerBase.visit({
|
|
276
|
+
...props,
|
|
277
|
+
prefix: "#/components/schemas/",
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Test whether the `x` schema covers the `y` schema.
|
|
282
|
+
*
|
|
283
|
+
* @param props Properties for testing
|
|
284
|
+
* @returns Whether the `x` schema covers the `y` schema
|
|
285
|
+
*/
|
|
286
|
+
export const covers = (props: {
|
|
287
|
+
components: OpenApi.IComponents;
|
|
288
|
+
x: OpenApi.IJsonSchema;
|
|
289
|
+
y: OpenApi.IJsonSchema;
|
|
290
|
+
}): boolean =>
|
|
291
|
+
OpenApiTypeCheckerBase.covers({
|
|
292
|
+
prefix: "#/components/schemas/",
|
|
293
|
+
components: props.components,
|
|
294
|
+
x: props.x,
|
|
295
|
+
y: props.y,
|
|
296
|
+
});
|
|
297
|
+
}
|