@valkyrjaio/valkyrja 26.0.0
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.md +21 -0
- package/README.md +136 -0
- package/package.json +63 -0
- package/src/Valkyrja/Application/Constant/ApplicationInfo.ts +26 -0
- package/src/Valkyrja/Application/Constant/ApplicationServiceId.ts +16 -0
- package/src/Valkyrja/Application/Data/CliConfig.ts +51 -0
- package/src/Valkyrja/Application/Data/Config.ts +31 -0
- package/src/Valkyrja/Application/Data/Contract/CliConfigContract.ts +27 -0
- package/src/Valkyrja/Application/Data/Contract/ConfigContract.ts +31 -0
- package/src/Valkyrja/Application/Data/Contract/HttpConfigContract.ts +26 -0
- package/src/Valkyrja/Application/Data/HttpConfig.ts +41 -0
- package/src/Valkyrja/Application/Directory/Directory.ts +80 -0
- package/src/Valkyrja/Application/Entry/Abstract/App.ts +117 -0
- package/src/Valkyrja/Application/Entry/Abstract/WorkerHttp.ts +83 -0
- package/src/Valkyrja/Application/Entry/Cli.ts +34 -0
- package/src/Valkyrja/Application/Entry/Http.ts +41 -0
- package/src/Valkyrja/Application/Kernel/ChildApplication.ts +63 -0
- package/src/Valkyrja/Application/Kernel/Contract/ApplicationContract.ts +34 -0
- package/src/Valkyrja/Application/Kernel/Valkyrja.ts +141 -0
- package/src/Valkyrja/Application/Provider/ApplicationComponentProvider.ts +39 -0
- package/src/Valkyrja/Application/Provider/CliApplicationComponentProvider.ts +30 -0
- package/src/Valkyrja/Application/Provider/CliWithHttpApplicationComponentProvider.ts +32 -0
- package/src/Valkyrja/Application/Provider/Contract/ComponentProviderContract.ts +28 -0
- package/src/Valkyrja/Application/Provider/Contract/PublishableComponentProviderContract.ts +20 -0
- package/src/Valkyrja/Application/Provider/HttpApplicationComponentProvider.ts +20 -0
- package/src/Valkyrja/Application/Throwable/Contract/ApplicationThrowable.ts +12 -0
- package/src/Valkyrja/Application/Throwable/Exception/Abstract/ApplicationInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Application/Throwable/Exception/Abstract/ApplicationRuntimeException.ts +14 -0
- package/src/Valkyrja/Cli/Interaction/Argument/Argument.ts +25 -0
- package/src/Valkyrja/Cli/Interaction/Argument/Contract/ArgumentContract.ts +19 -0
- package/src/Valkyrja/Cli/Interaction/Argument/Factory/ArgumentFactory.ts +16 -0
- package/src/Valkyrja/Cli/Interaction/Constant/CliInteractionServiceId.ts +16 -0
- package/src/Valkyrja/Cli/Interaction/Data/CliInteractionConfig.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Data/Contract/CliInteractionConfigContract.ts +20 -0
- package/src/Valkyrja/Cli/Interaction/Enum/BackgroundColor.ts +33 -0
- package/src/Valkyrja/Cli/Interaction/Enum/ExitCode.ts +30 -0
- package/src/Valkyrja/Cli/Interaction/Enum/OptionType.ts +13 -0
- package/src/Valkyrja/Cli/Interaction/Enum/Style.ts +33 -0
- package/src/Valkyrja/Cli/Interaction/Enum/TextColor.ts +33 -0
- package/src/Valkyrja/Cli/Interaction/Format/BackgroundColorFormat.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Format/Contract/FormatContract.ts +21 -0
- package/src/Valkyrja/Cli/Interaction/Format/Format.ts +38 -0
- package/src/Valkyrja/Cli/Interaction/Format/StyleFormat.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Format/TextColorFormat.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/Contract/FormatterContract.ts +22 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/ErrorFormatter.ts +20 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/Formatter.ts +46 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/HighlightedTextFormatter.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/QuestionFormatter.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/SuccessFormatter.ts +20 -0
- package/src/Valkyrja/Cli/Interaction/Formatter/WarningFormatter.ts +20 -0
- package/src/Valkyrja/Cli/Interaction/Input/Contract/InputContract.ts +36 -0
- package/src/Valkyrja/Cli/Interaction/Input/Factory/InputFactory.ts +47 -0
- package/src/Valkyrja/Cli/Interaction/Input/Input.ts +106 -0
- package/src/Valkyrja/Cli/Interaction/Message/Answer.ts +130 -0
- package/src/Valkyrja/Cli/Interaction/Message/Banner.ts +41 -0
- package/src/Valkyrja/Cli/Interaction/Message/Contract/AnswerContract.ts +32 -0
- package/src/Valkyrja/Cli/Interaction/Message/Contract/MessageContract.ts +26 -0
- package/src/Valkyrja/Cli/Interaction/Message/Contract/ProgressContract.ts +23 -0
- package/src/Valkyrja/Cli/Interaction/Message/Contract/QuestionContract.ts +26 -0
- package/src/Valkyrja/Cli/Interaction/Message/ErrorMessage.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Message/Header.ts +111 -0
- package/src/Valkyrja/Cli/Interaction/Message/Message.ts +64 -0
- package/src/Valkyrja/Cli/Interaction/Message/Messages.ts +28 -0
- package/src/Valkyrja/Cli/Interaction/Message/NewLine.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Message/Progress.ts +44 -0
- package/src/Valkyrja/Cli/Interaction/Message/Question.ts +91 -0
- package/src/Valkyrja/Cli/Interaction/Message/SuccessMessage.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Message/WarningMessage.ts +17 -0
- package/src/Valkyrja/Cli/Interaction/Option/Contract/OptionContract.ts +27 -0
- package/src/Valkyrja/Cli/Interaction/Option/Factory/OptionFactory.ts +60 -0
- package/src/Valkyrja/Cli/Interaction/Option/Option.ts +61 -0
- package/src/Valkyrja/Cli/Interaction/Output/Contract/EmptyOutputContract.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Output/Contract/FileOutputContract.ts +21 -0
- package/src/Valkyrja/Cli/Interaction/Output/Contract/OutputContract.ts +41 -0
- package/src/Valkyrja/Cli/Interaction/Output/Contract/PlainOutputContract.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Output/Contract/StreamOutputContract.ts +21 -0
- package/src/Valkyrja/Cli/Interaction/Output/EmptyOutput.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Output/Factory/Contract/OutputFactoryContract.ts +38 -0
- package/src/Valkyrja/Cli/Interaction/Output/Factory/OutputFactory.ts +88 -0
- package/src/Valkyrja/Cli/Interaction/Output/FileOutput.ts +41 -0
- package/src/Valkyrja/Cli/Interaction/Output/Output.ts +163 -0
- package/src/Valkyrja/Cli/Interaction/Output/PlainOutput.ts +18 -0
- package/src/Valkyrja/Cli/Interaction/Output/StreamOutput.ts +41 -0
- package/src/Valkyrja/Cli/Interaction/Provider/CliInteractionComponentProvider.ts +39 -0
- package/src/Valkyrja/Cli/Interaction/Provider/CliInteractionServiceProvider.ts +46 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Contract/CliInteractionThrowable.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/Abstract/CliInteractionInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/Abstract/CliInteractionRuntimeException.ts +14 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/CliInteractionExpectedQuestionOutputException.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/CliInteractionInvalidEmptyValueException.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/CliInteractionInvalidNonEmptyValueException.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/CliInteractionInvalidOptionNameException.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/CliInteractionNoFormatterException.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Throwable/Exception/CliInteractionNoValidationCallableException.ts +12 -0
- package/src/Valkyrja/Cli/Interaction/Writer/Contract/WriterContract.ts +22 -0
- package/src/Valkyrja/Cli/Interaction/Writer/QuestionWriter.ts +86 -0
- package/src/Valkyrja/Cli/Middleware/Constant/CliMiddlewareServiceId.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Contract/ExitedMiddlewareContract.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Contract/InputReceivedMiddlewareContract.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Contract/RouteDispatchedMiddlewareContract.ts +28 -0
- package/src/Valkyrja/Cli/Middleware/Contract/RouteMatchedMiddlewareContract.ts +27 -0
- package/src/Valkyrja/Cli/Middleware/Contract/RouteNotMatchedMiddlewareContract.ts +26 -0
- package/src/Valkyrja/Cli/Middleware/Contract/ThrowableCaughtMiddlewareContract.ts +27 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Abstract/Handler.ts +48 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/ExitedHandlerContract.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/HandlerContract.ts +33 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/InputReceivedHandlerContract.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/RouteDispatchedHandlerContract.ts +23 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/RouteMatchedHandlerContract.ts +23 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/RouteNotMatchedHandlerContract.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Handler/Contract/ThrowableCaughtHandlerContract.ts +22 -0
- package/src/Valkyrja/Cli/Middleware/Handler/ExitedHandler.ts +24 -0
- package/src/Valkyrja/Cli/Middleware/Handler/InputReceivedHandler.ts +24 -0
- package/src/Valkyrja/Cli/Middleware/Handler/RouteDispatchedHandler.ts +25 -0
- package/src/Valkyrja/Cli/Middleware/Handler/RouteMatchedHandler.ts +25 -0
- package/src/Valkyrja/Cli/Middleware/Handler/RouteNotMatchedHandler.ts +24 -0
- package/src/Valkyrja/Cli/Middleware/Handler/ThrowableCaughtHandler.ts +29 -0
- package/src/Valkyrja/Cli/Middleware/Provider/CliMiddlewareComponentProvider.ts +39 -0
- package/src/Valkyrja/Cli/Middleware/Provider/CliMiddlewareServiceProvider.ts +119 -0
- package/src/Valkyrja/Cli/Middleware/Throwable/Contract/CliMiddlewareThrowable.ts +12 -0
- package/src/Valkyrja/Cli/Middleware/Throwable/Exception/Abstract/CliMiddlewareInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Cli/Middleware/Throwable/Exception/Abstract/CliMiddlewareRuntimeException.ts +14 -0
- package/src/Valkyrja/Cli/Routing/Collection/Contract/RouteCollectionContract.ts +26 -0
- package/src/Valkyrja/Cli/Routing/Collection/RouteCollection.ts +60 -0
- package/src/Valkyrja/Cli/Routing/Collector/Contract/RouteCollectorContract.ts +20 -0
- package/src/Valkyrja/Cli/Routing/Constant/CliRoutingServiceId.ts +16 -0
- package/src/Valkyrja/Cli/Routing/Constant/OptionName.ts +17 -0
- package/src/Valkyrja/Cli/Routing/Constant/OptionShortName.ts +17 -0
- package/src/Valkyrja/Cli/Routing/Controller/Controller.ts +18 -0
- package/src/Valkyrja/Cli/Routing/Data/Abstract/Parameter.ts +91 -0
- package/src/Valkyrja/Cli/Routing/Data/ArgumentParameter.ts +99 -0
- package/src/Valkyrja/Cli/Routing/Data/CliRoutingData.ts +14 -0
- package/src/Valkyrja/Cli/Routing/Data/Contract/ArgumentParameterContract.ts +29 -0
- package/src/Valkyrja/Cli/Routing/Data/Contract/CliRoutingConfigContract.ts +18 -0
- package/src/Valkyrja/Cli/Routing/Data/Contract/OptionParameterContract.ts +41 -0
- package/src/Valkyrja/Cli/Routing/Data/Contract/ParameterContract.ts +32 -0
- package/src/Valkyrja/Cli/Routing/Data/Contract/RouteContract.ts +57 -0
- package/src/Valkyrja/Cli/Routing/Data/Option/HelpOptionParameter.ts +30 -0
- package/src/Valkyrja/Cli/Routing/Data/Option/NoInteractionOptionParameter.ts +30 -0
- package/src/Valkyrja/Cli/Routing/Data/Option/QuietOptionParameter.ts +30 -0
- package/src/Valkyrja/Cli/Routing/Data/Option/SilentOptionParameter.ts +30 -0
- package/src/Valkyrja/Cli/Routing/Data/Option/VersionOptionParameter.ts +30 -0
- package/src/Valkyrja/Cli/Routing/Data/OptionParameter.ts +188 -0
- package/src/Valkyrja/Cli/Routing/Data/Route.ts +211 -0
- package/src/Valkyrja/Cli/Routing/Dispatcher/Contract/RouterContract.ts +23 -0
- package/src/Valkyrja/Cli/Routing/Dispatcher/Router.ts +155 -0
- package/src/Valkyrja/Cli/Routing/Enum/ArgumentMode.ts +13 -0
- package/src/Valkyrja/Cli/Routing/Enum/ArgumentValueMode.ts +13 -0
- package/src/Valkyrja/Cli/Routing/Enum/OptionMode.ts +13 -0
- package/src/Valkyrja/Cli/Routing/Enum/OptionValueMode.ts +14 -0
- package/src/Valkyrja/Cli/Routing/Provider/CliRoutingCliRouteProvider.ts +111 -0
- package/src/Valkyrja/Cli/Routing/Provider/CliRoutingComponentProvider.ts +40 -0
- package/src/Valkyrja/Cli/Routing/Provider/CliRoutingServiceProvider.ts +88 -0
- package/src/Valkyrja/Cli/Routing/Provider/Contract/CliRouteProviderContract.ts +20 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Contract/CliRoutingThrowable.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/Abstract/CliRoutingInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/Abstract/CliRoutingRuntimeException.ts +14 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingArgumentValuesValidationException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingInvalidArgumentNameException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingInvalidHelpTextCallableException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingInvalidOptionNameException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingInvalidOptionWithValueException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingInvalidRouteNameException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingNoCastException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingNoHelpTextException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingNoOutputDispatchException.ts +12 -0
- package/src/Valkyrja/Cli/Routing/Throwable/Exception/CliRoutingOptionValuesValidationException.ts +12 -0
- package/src/Valkyrja/Cli/Server/Command/HelpCommand.ts +313 -0
- package/src/Valkyrja/Cli/Server/Command/ListBashCommand.ts +44 -0
- package/src/Valkyrja/Cli/Server/Command/ListCommand.ts +98 -0
- package/src/Valkyrja/Cli/Server/Command/VersionCommand.ts +34 -0
- package/src/Valkyrja/Cli/Server/Constant/CliServerServiceId.ts +28 -0
- package/src/Valkyrja/Cli/Server/Constant/CommandName.ts +16 -0
- package/src/Valkyrja/Cli/Server/Data/Contract/CliHelpCommandConfigContract.ts +20 -0
- package/src/Valkyrja/Cli/Server/Data/Contract/CliNoInteractionConfigContract.ts +19 -0
- package/src/Valkyrja/Cli/Server/Data/Contract/CliQuietInteractionConfigContract.ts +19 -0
- package/src/Valkyrja/Cli/Server/Data/Contract/CliSilentInteractionConfigContract.ts +19 -0
- package/src/Valkyrja/Cli/Server/Data/Contract/CliVersionCommandConfigContract.ts +20 -0
- package/src/Valkyrja/Cli/Server/Handler/Contract/InputHandlerContract.ts +17 -0
- package/src/Valkyrja/Cli/Server/Handler/InputHandler.ts +112 -0
- package/src/Valkyrja/Cli/Server/Middleware/InputReceived/CheckForHelpOptionsMiddleware.ts +30 -0
- package/src/Valkyrja/Cli/Server/Middleware/InputReceived/CheckForVersionOptionsMiddleware.ts +29 -0
- package/src/Valkyrja/Cli/Server/Middleware/InputReceived/CheckGlobalInteractionOptionsMiddleware.ts +52 -0
- package/src/Valkyrja/Cli/Server/Middleware/RouteNotMatched/CheckCommandForTypoMiddleware.ts +119 -0
- package/src/Valkyrja/Cli/Server/Middleware/ThrowableCaught/LogThrowableCaughtMiddleware.ts +32 -0
- package/src/Valkyrja/Cli/Server/Middleware/ThrowableCaught/OutputThrowableCaughtMiddleware.ts +57 -0
- package/src/Valkyrja/Cli/Server/Provider/CliServerComponentProvider.ts +39 -0
- package/src/Valkyrja/Cli/Server/Provider/CliServerServiceProvider.ts +269 -0
- package/src/Valkyrja/Cli/Server/Support/Exiter.ts +32 -0
- package/src/Valkyrja/Cli/Server/Throwable/Contract/CliServerThrowable.ts +12 -0
- package/src/Valkyrja/Cli/Server/Throwable/Exception/Abstract/CliServerInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Cli/Server/Throwable/Exception/Abstract/CliServerRuntimeException.ts +14 -0
- package/src/Valkyrja/Cli/Throwable/Contract/CliThrowable.ts +12 -0
- package/src/Valkyrja/Cli/Throwable/Exception/Abstract/CliInvalidArgumentException.ts +14 -0
- package/src/Valkyrja/Cli/Throwable/Exception/Abstract/CliRuntimeException.ts +14 -0
- package/src/Valkyrja/Container/Constant/ContainerServiceId.ts +13 -0
- package/src/Valkyrja/Container/Data/ContainerData.ts +31 -0
- package/src/Valkyrja/Container/Enum/InvalidReferenceMode.ts +13 -0
- package/src/Valkyrja/Container/Manager/ChildContainer.ts +69 -0
- package/src/Valkyrja/Container/Manager/Container.ts +244 -0
- package/src/Valkyrja/Container/Manager/Contract/ContainerContract.ts +31 -0
- package/src/Valkyrja/Container/Manager/Contract/ProvidersAwareContract.ts +17 -0
- package/src/Valkyrja/Container/Provider/ContainerComponentProvider.ts +39 -0
- package/src/Valkyrja/Container/Provider/ContainerServiceProvider.ts +33 -0
- package/src/Valkyrja/Container/Provider/Contract/ServiceProviderContract.ts +20 -0
- package/src/Valkyrja/Container/Throwable/Contract/ContainerThrowable.ts +12 -0
- package/src/Valkyrja/Container/Throwable/Exception/Abstract/ContainerInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Container/Throwable/Exception/Abstract/ContainerRuntimeException.ts +14 -0
- package/src/Valkyrja/Container/Throwable/Exception/ContainerInvalidPublishCallbackException.ts +12 -0
- package/src/Valkyrja/Container/Throwable/Exception/ContainerInvalidReferenceException.ts +17 -0
- package/src/Valkyrja/Event/Constant/EventServiceId.ts +12 -0
- package/src/Valkyrja/Event/Data/Contract/ListenerContract.ts +25 -0
- package/src/Valkyrja/Event/Data/EventData.ts +15 -0
- package/src/Valkyrja/Event/Provider/Contract/ListenerProviderContract.ts +20 -0
- package/src/Valkyrja/Http/Client/Manager/Contract/ClientContract.ts +15 -0
- package/src/Valkyrja/Http/Client/Manager/LogClient.ts +28 -0
- package/src/Valkyrja/Http/Client/Manager/NullClient.ts +20 -0
- package/src/Valkyrja/Http/Client/Throwable/Contract/HttpClientThrowable.ts +12 -0
- package/src/Valkyrja/Http/Client/Throwable/Exception/Abstract/HttpClientInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Http/Client/Throwable/Exception/Abstract/HttpClientRuntimeException.ts +14 -0
- package/src/Valkyrja/Http/Message/Constant/ContentTypeValue.ts +22 -0
- package/src/Valkyrja/Http/Message/Constant/HeaderName.ts +60 -0
- package/src/Valkyrja/Http/Message/Constant/HeaderValue.ts +12 -0
- package/src/Valkyrja/Http/Message/Constant/HttpMessageServiceId.ts +13 -0
- package/src/Valkyrja/Http/Message/Constant/Port.ts +19 -0
- package/src/Valkyrja/Http/Message/Contract/MessageContract.ts +21 -0
- package/src/Valkyrja/Http/Message/Enum/ProtocolVersion.ts +15 -0
- package/src/Valkyrja/Http/Message/Enum/RequestMethod.ts +35 -0
- package/src/Valkyrja/Http/Message/Enum/SameSite.ts +14 -0
- package/src/Valkyrja/Http/Message/Enum/StatusCode.ts +152 -0
- package/src/Valkyrja/Http/Message/Enum/StatusText.ts +73 -0
- package/src/Valkyrja/Http/Message/File/Collection/Contract/UploadedFileCollectionContract.ts +20 -0
- package/src/Valkyrja/Http/Message/File/Collection/UploadedFileCollection.ts +83 -0
- package/src/Valkyrja/Http/Message/File/Constant/UploadErrorExceptionMessage.ts +20 -0
- package/src/Valkyrja/Http/Message/File/Contract/UploadedFileContract.ts +22 -0
- package/src/Valkyrja/Http/Message/File/Enum/UploadError.ts +19 -0
- package/src/Valkyrja/Http/Message/File/Factory/UploadedFileFactory.ts +34 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Contract/UploadedFileThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/Abstract/UploadedFileInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/Abstract/UploadedFileRuntimeException.ts +15 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileAlreadyMovedException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidDirectoryException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidFilesArrayStructureException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidKeyException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidParamException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidTmpNameException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidUploadErrorException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidUploadedFileException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileInvalidValueException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileMoveFailureException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileUnableToWriteFileException.ts +12 -0
- package/src/Valkyrja/Http/Message/File/Throwable/Exception/UploadedFileUploadErrorException.ts +48 -0
- package/src/Valkyrja/Http/Message/File/UploadedFile.ts +156 -0
- package/src/Valkyrja/Http/Message/Header/Collection/Contract/HeaderCollectionContract.ts +23 -0
- package/src/Valkyrja/Http/Message/Header/Collection/HeaderCollection.ts +117 -0
- package/src/Valkyrja/Http/Message/Header/ContentType.ts +18 -0
- package/src/Valkyrja/Http/Message/Header/Contract/HeaderContract.ts +21 -0
- package/src/Valkyrja/Http/Message/Header/Factory/CookieFactory.ts +35 -0
- package/src/Valkyrja/Http/Message/Header/Factory/HeaderFactory.ts +79 -0
- package/src/Valkyrja/Http/Message/Header/Header.ts +104 -0
- package/src/Valkyrja/Http/Message/Header/Location.ts +18 -0
- package/src/Valkyrja/Http/Message/Header/Referer.ts +18 -0
- package/src/Valkyrja/Http/Message/Header/SetCookie.ts +18 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Contract/HttpHeaderThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/Abstract/HttpHeaderInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/Abstract/HttpHeaderRuntimeException.ts +13 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderInvalidHeaderNameException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderInvalidHeaderParamException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderInvalidNameException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderInvalidValueException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderUnsupportedMethodException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderUnsupportedOffsetSetException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Throwable/Exception/HttpHeaderUnsupportedOffsetUnsetException.ts +12 -0
- package/src/Valkyrja/Http/Message/Header/Value/Component/Component.ts +54 -0
- package/src/Valkyrja/Http/Message/Header/Value/Component/Contract/ComponentContract.ts +16 -0
- package/src/Valkyrja/Http/Message/Header/Value/Contract/CookieContract.ts +35 -0
- package/src/Valkyrja/Http/Message/Header/Value/Contract/ValueContract.ts +17 -0
- package/src/Valkyrja/Http/Message/Header/Value/Cookie.ts +165 -0
- package/src/Valkyrja/Http/Message/Header/Value/Value.ts +56 -0
- package/src/Valkyrja/Http/Message/Param/Abstract/ParamCollection.ts +63 -0
- package/src/Valkyrja/Http/Message/Param/AttributeParamCollection.ts +13 -0
- package/src/Valkyrja/Http/Message/Param/Contract/AttributeParamCollectionContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Param/Contract/CookieParamCollectionContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Param/Contract/ParamCollectionContract.ts +18 -0
- package/src/Valkyrja/Http/Message/Param/Contract/ParsedBodyParamCollectionContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Param/Contract/ParsedJsonParamCollectionContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Param/Contract/QueryParamCollectionContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Param/Contract/ServerParamCollectionContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Param/CookieParamCollection.ts +13 -0
- package/src/Valkyrja/Http/Message/Param/ParsedBodyParamCollection.ts +15 -0
- package/src/Valkyrja/Http/Message/Param/ParsedJsonParamCollection.ts +13 -0
- package/src/Valkyrja/Http/Message/Param/QueryParamCollection.ts +13 -0
- package/src/Valkyrja/Http/Message/Param/ServerParamCollection.ts +15 -0
- package/src/Valkyrja/Http/Message/Provider/HttpMessageServiceProvider.ts +30 -0
- package/src/Valkyrja/Http/Message/Request/Contract/JsonServerRequestContract.ts +16 -0
- package/src/Valkyrja/Http/Message/Request/Contract/RequestContract.ts +21 -0
- package/src/Valkyrja/Http/Message/Request/Contract/ServerRequestContract.ts +32 -0
- package/src/Valkyrja/Http/Message/Request/Factory/RequestFactory.ts +106 -0
- package/src/Valkyrja/Http/Message/Request/JsonServerRequest.ts +76 -0
- package/src/Valkyrja/Http/Message/Request/Request.ts +109 -0
- package/src/Valkyrja/Http/Message/Request/ServerRequest.ts +116 -0
- package/src/Valkyrja/Http/Message/Request/Throwable/Contract/HttpRequestThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/Request/Throwable/Exception/Abstract/HttpRequestInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/Request/Throwable/Exception/Abstract/HttpRequestRuntimeException.ts +13 -0
- package/src/Valkyrja/Http/Message/Request/Throwable/Exception/HttpRequestInvalidMethodException.ts +12 -0
- package/src/Valkyrja/Http/Message/Request/Throwable/Exception/HttpRequestInvalidRequestTargetException.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/Contract/EmptyResponseContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/Contract/HtmlResponseContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/Contract/JsonResponseContract.ts +24 -0
- package/src/Valkyrja/Http/Message/Response/Contract/RedirectResponseContract.ts +26 -0
- package/src/Valkyrja/Http/Message/Response/Contract/ResponseContract.ts +23 -0
- package/src/Valkyrja/Http/Message/Response/Contract/TextResponseContract.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/EmptyResponse.ts +22 -0
- package/src/Valkyrja/Http/Message/Response/Factory/Contract/ResponseFactoryContract.ts +44 -0
- package/src/Valkyrja/Http/Message/Response/Factory/ResponseFactory.ts +64 -0
- package/src/Valkyrja/Http/Message/Response/HtmlResponse.ts +36 -0
- package/src/Valkyrja/Http/Message/Response/JsonResponse.ts +111 -0
- package/src/Valkyrja/Http/Message/Response/RedirectResponse.ts +101 -0
- package/src/Valkyrja/Http/Message/Response/Response.ts +81 -0
- package/src/Valkyrja/Http/Message/Response/TextResponse.ts +44 -0
- package/src/Valkyrja/Http/Message/Response/Throwable/Contract/HttpResponseThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/Throwable/Exception/Abstract/HttpResponseInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/Response/Throwable/Exception/Abstract/HttpResponseRuntimeException.ts +15 -0
- package/src/Valkyrja/Http/Message/Response/Throwable/Exception/HttpRequestInvalidJsonCallbackException.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/Throwable/Exception/HttpRequestInvalidRedirectStatusCodeException.ts +12 -0
- package/src/Valkyrja/Http/Message/Response/XmlResponse.ts +40 -0
- package/src/Valkyrja/Http/Message/Stream/Contract/StreamContract.ts +27 -0
- package/src/Valkyrja/Http/Message/Stream/Enum/Mode.ts +47 -0
- package/src/Valkyrja/Http/Message/Stream/Enum/ModeTranslation.ts +14 -0
- package/src/Valkyrja/Http/Message/Stream/Factory/StreamFactory.ts +83 -0
- package/src/Valkyrja/Http/Message/Stream/Stream.ts +140 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Contract/HttpStreamThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/Abstract/HttpStreamInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/Abstract/HttpStreamRuntimeException.ts +13 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamInvalidLengthException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamInvalidStreamException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamNoStreamAvailableException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamStreamReadException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamStreamSeekException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamStreamTellException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamStreamWriteException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamUnreadableStreamException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamUnseekableStreamException.ts +12 -0
- package/src/Valkyrja/Http/Message/Stream/Throwable/Exception/HttpStreamUnwritableStreamException.ts +12 -0
- package/src/Valkyrja/Http/Message/Throwable/Contract/HttpMessageThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/Throwable/Exception/Abstract/HttpMessageInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/Throwable/Exception/Abstract/HttpMessageRuntimeException.ts +13 -0
- package/src/Valkyrja/Http/Message/Throwable/Exception/HttpNotFoundResponseException.ts +22 -0
- package/src/Valkyrja/Http/Message/Throwable/Exception/HttpRedirectResponseException.ts +42 -0
- package/src/Valkyrja/Http/Message/Throwable/Exception/HttpResponseException.ts +44 -0
- package/src/Valkyrja/Http/Message/Trait/Message.ts +77 -0
- package/src/Valkyrja/Http/Message/Uri/Contract/UriContract.ts +37 -0
- package/src/Valkyrja/Http/Message/Uri/Data/HostPortAccumulator.ts +15 -0
- package/src/Valkyrja/Http/Message/Uri/Enum/Scheme.ts +14 -0
- package/src/Valkyrja/Http/Message/Uri/Factory/UriFactory.ts +152 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Contract/HttpUriThrowable.ts +12 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/Abstract/HttpUriInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/Abstract/HttpUriRuntimeException.ts +13 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/HttpUriInvalidFromStringException.ts +12 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/HttpUriInvalidPathException.ts +12 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/HttpUriInvalidPortException.ts +12 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/HttpUriInvalidQueryException.ts +12 -0
- package/src/Valkyrja/Http/Message/Uri/Throwable/Exception/NoPortExceptionHttpUri.ts +12 -0
- package/src/Valkyrja/Http/Message/Uri/Type/Port.ts +39 -0
- package/src/Valkyrja/Http/Message/Uri/Uri.ts +191 -0
- package/src/Valkyrja/Http/Middleware/Constant/HttpMiddlewareServiceId.ts +24 -0
- package/src/Valkyrja/Http/Middleware/Contract/RequestReceivedMiddlewareContract.ts +19 -0
- package/src/Valkyrja/Http/Middleware/Contract/RouteDispatchedMiddlewareContract.ts +22 -0
- package/src/Valkyrja/Http/Middleware/Contract/RouteMatchedMiddlewareContract.ts +21 -0
- package/src/Valkyrja/Http/Middleware/Contract/RouteNotMatchedMiddlewareContract.ts +20 -0
- package/src/Valkyrja/Http/Middleware/Contract/SendingResponseMiddlewareContract.ts +20 -0
- package/src/Valkyrja/Http/Middleware/Contract/TerminatedMiddlewareContract.ts +16 -0
- package/src/Valkyrja/Http/Middleware/Contract/ThrowableCaughtMiddlewareContract.ts +21 -0
- package/src/Valkyrja/Http/Middleware/Handler/Abstract/Handler.ts +50 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/HandlerContract.ts +29 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/RequestReceivedHandlerContract.ts +17 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/RouteDispatchedHandlerContract.ts +18 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/RouteMatchedHandlerContract.ts +18 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/RouteNotMatchedHandlerContract.ts +17 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/SendingResponseHandlerContract.ts +17 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/TerminatedHandlerContract.ts +17 -0
- package/src/Valkyrja/Http/Middleware/Handler/Contract/ThrowableCaughtHandlerContract.ts +17 -0
- package/src/Valkyrja/Http/Middleware/Handler/RequestReceivedHandler.ts +25 -0
- package/src/Valkyrja/Http/Middleware/Handler/RouteDispatchedHandler.ts +30 -0
- package/src/Valkyrja/Http/Middleware/Handler/RouteMatchedHandler.ts +26 -0
- package/src/Valkyrja/Http/Middleware/Handler/RouteNotMatchedHandler.ts +25 -0
- package/src/Valkyrja/Http/Middleware/Handler/SendingResponseHandler.ts +25 -0
- package/src/Valkyrja/Http/Middleware/Handler/TerminatedHandler.ts +24 -0
- package/src/Valkyrja/Http/Middleware/Handler/ThrowableCaughtHandler.ts +25 -0
- package/src/Valkyrja/Http/Middleware/Throwable/Contract/HttpMiddlewareThrowable.ts +12 -0
- package/src/Valkyrja/Http/Middleware/Throwable/Exception/Abstract/HttpMiddlewareInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Http/Middleware/Throwable/Exception/Abstract/HttpMiddlewareRuntimeException.ts +14 -0
- package/src/Valkyrja/Http/Routing/Cli/Command/Constant/CommandName.ts +12 -0
- package/src/Valkyrja/Http/Routing/Cli/Command/ListCommand.ts +95 -0
- package/src/Valkyrja/Http/Routing/Collection/Contract/RouteCollectionContract.ts +28 -0
- package/src/Valkyrja/Http/Routing/Collection/RouteCollection.ts +227 -0
- package/src/Valkyrja/Http/Routing/Collector/Contract/RouteCollectorContract.ts +14 -0
- package/src/Valkyrja/Http/Routing/Constant/HttpRoutingServiceId.ts +21 -0
- package/src/Valkyrja/Http/Routing/Constant/Regex.ts +57 -0
- package/src/Valkyrja/Http/Routing/Controller/Controller.ts +18 -0
- package/src/Valkyrja/Http/Routing/Data/Contract/DynamicRouteContract.ts +19 -0
- package/src/Valkyrja/Http/Routing/Data/Contract/ParameterContract.ts +28 -0
- package/src/Valkyrja/Http/Routing/Data/Contract/RouteContract.ts +69 -0
- package/src/Valkyrja/Http/Routing/Data/DynamicRoute.ts +83 -0
- package/src/Valkyrja/Http/Routing/Data/HttpRoutingData.ts +22 -0
- package/src/Valkyrja/Http/Routing/Data/Parameter.ts +104 -0
- package/src/Valkyrja/Http/Routing/Data/Route.ts +252 -0
- package/src/Valkyrja/Http/Routing/Dispatcher/Contract/RouterContract.ts +17 -0
- package/src/Valkyrja/Http/Routing/Dispatcher/Router.ts +102 -0
- package/src/Valkyrja/Http/Routing/Factory/Contract/RoutingResponseFactoryContract.ts +21 -0
- package/src/Valkyrja/Http/Routing/Factory/RoutingResponseFactory.ts +33 -0
- package/src/Valkyrja/Http/Routing/Matcher/Contract/MatcherContract.ts +17 -0
- package/src/Valkyrja/Http/Routing/Matcher/Matcher.ts +109 -0
- package/src/Valkyrja/Http/Routing/Processor/Contract/ProcessorContract.ts +14 -0
- package/src/Valkyrja/Http/Routing/Processor/Processor.ts +108 -0
- package/src/Valkyrja/Http/Routing/Provider/Contract/HttpRouteProviderContract.ts +21 -0
- package/src/Valkyrja/Http/Routing/Provider/HttpRoutingCliComponentProvider.ts +39 -0
- package/src/Valkyrja/Http/Routing/Provider/HttpRoutingCliRouteProvider.ts +42 -0
- package/src/Valkyrja/Http/Routing/Throwable/Contract/HttpRoutingThrowable.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/Abstract/HttpRoutingInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/Abstract/HttpRoutingRuntimeException.ts +14 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidDynamicRouteNameException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidMethodTypeException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidParameterRegexException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidRouteNameException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidRouteParameterException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidRoutePathException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingInvalidRouteRegexException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingNoCastException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingNoRequestStructException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Throwable/Exception/HttpRoutingNoResponseStructException.ts +12 -0
- package/src/Valkyrja/Http/Routing/Url/Contract/UrlContract.ts +12 -0
- package/src/Valkyrja/Http/Routing/Url/Url.ts +27 -0
- package/src/Valkyrja/Http/Server/Constant/HttpServerServiceId.ts +14 -0
- package/src/Valkyrja/Http/Server/Handler/Contract/ExceptionResponseRequestHandlerContract.ts +15 -0
- package/src/Valkyrja/Http/Server/Handler/Contract/RequestHandlerContract.ts +20 -0
- package/src/Valkyrja/Http/Server/Handler/RequestHandler.ts +141 -0
- package/src/Valkyrja/Http/Server/Middleware/RequestReceived/RedirectTrailingSlashMiddleware.ts +47 -0
- package/src/Valkyrja/Http/Server/Middleware/RouteMatched/ResponseStructMiddleware.ts +45 -0
- package/src/Valkyrja/Http/Server/Middleware/SendingResponse/NoCacheResponseMiddleware.ts +36 -0
- package/src/Valkyrja/Http/Server/Middleware/ThrowableCaught/LogThrowableCaughtMiddleware.ts +32 -0
- package/src/Valkyrja/Http/Server/Throwable/Contract/HttpServerThrowable.ts +12 -0
- package/src/Valkyrja/Http/Server/Throwable/Exception/Abstract/HttpServerInvalidArgumentException.ts +16 -0
- package/src/Valkyrja/Http/Server/Throwable/Exception/Abstract/HttpServerRuntimeException.ts +14 -0
- package/src/Valkyrja/Http/Struct/Contract/StructContract.ts +13 -0
- package/src/Valkyrja/Http/Struct/Request/Abstract/JsonRequestStruct.ts +33 -0
- package/src/Valkyrja/Http/Struct/Request/Abstract/ParsedBodyRequestStruct.ts +21 -0
- package/src/Valkyrja/Http/Struct/Request/Abstract/QueryRequestStruct.ts +21 -0
- package/src/Valkyrja/Http/Struct/Request/Abstract/RequestStruct.ts +36 -0
- package/src/Valkyrja/Http/Struct/Request/Contract/RequestStructContract.ts +16 -0
- package/src/Valkyrja/Http/Struct/Response/Abstract/ResponseStruct.ts +31 -0
- package/src/Valkyrja/Http/Struct/Response/Contract/ResponseStructContract.ts +14 -0
- package/src/Valkyrja/Http/Struct/Throwable/Contract/HttpStructThrowable.ts +12 -0
- package/src/Valkyrja/Http/Struct/Throwable/Exception/Abstract/HttpStructInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Http/Struct/Throwable/Exception/Abstract/HttpStructRuntimeException.ts +13 -0
- package/src/Valkyrja/Http/Struct/Throwable/Exception/HttpStructJsonServerRequestExpectedException.ts +12 -0
- package/src/Valkyrja/Http/Throwable/Contract/HttpThrowable.ts +12 -0
- package/src/Valkyrja/Http/Throwable/Exception/Abstract/HttpInvalidArgumentException.ts +13 -0
- package/src/Valkyrja/Http/Throwable/Exception/Abstract/HttpRuntimeException.ts +13 -0
- package/src/Valkyrja/Log/Logger/Contract/LoggerContract.ts +22 -0
- package/src/Valkyrja/Throwable/Constant/ThrowableServiceId.ts +12 -0
- package/src/Valkyrja/Throwable/Contract/ValkyrjaThrowable.ts +12 -0
- package/src/Valkyrja/Throwable/Exception/Abstract/ValkyrjaInvalidArgumentException.ts +18 -0
- package/src/Valkyrja/Throwable/Exception/Abstract/ValkyrjaRuntimeException.ts +18 -0
- package/src/Valkyrja/Throwable/Handler/Abstract/ThrowableHandler.ts +22 -0
- package/src/Valkyrja/Throwable/Handler/Contract/ThrowableHandlerContract.ts +18 -0
- package/src/Valkyrja/Type/Data/Cast.ts +16 -0
- package/src/Valkyrja/Type/Object/Factory/ObjectFactory.ts +14 -0
- package/src/Valkyrja/Validation/Constant/ErrorMessage.ts +33 -0
- package/src/Valkyrja/Validation/Rule/Abstract/Rule.ts +30 -0
- package/src/Valkyrja/Validation/Rule/Contract/RuleContract.ts +14 -0
- package/src/Valkyrja/Validation/Rule/Int/GreaterThan.ts +24 -0
- package/src/Valkyrja/Validation/Rule/Int/LessThan.ts +24 -0
- package/src/Valkyrja/Validation/Rule/Is/Email.ts +16 -0
- package/src/Valkyrja/Validation/Rule/Is/Equal.ts +24 -0
- package/src/Valkyrja/Validation/Rule/Is/IsBool.ts +16 -0
- package/src/Valkyrja/Validation/Rule/Is/IsEmpty.ts +16 -0
- package/src/Valkyrja/Validation/Rule/Is/IsNumeric.ts +16 -0
- package/src/Valkyrja/Validation/Rule/Is/IsString.ts +16 -0
- package/src/Valkyrja/Validation/Rule/Is/NotEmpty.ts +16 -0
- package/src/Valkyrja/Validation/Rule/Is/NotEqual.ts +24 -0
- package/src/Valkyrja/Validation/Rule/Is/Required.ts +16 -0
- package/src/Valkyrja/Validation/Rule/String/Alpha.ts +16 -0
- package/src/Valkyrja/Validation/Rule/String/Contains.ts +24 -0
- package/src/Valkyrja/Validation/Rule/String/EndsWith.ts +24 -0
- package/src/Valkyrja/Validation/Rule/String/Lowercase.ts +16 -0
- package/src/Valkyrja/Validation/Rule/String/Max.ts +24 -0
- package/src/Valkyrja/Validation/Rule/String/Min.ts +24 -0
- package/src/Valkyrja/Validation/Rule/String/Regex.ts +24 -0
- package/src/Valkyrja/Validation/Rule/String/StartsWith.ts +24 -0
- package/src/Valkyrja/Validation/Rule/String/Uppercase.ts +16 -0
- package/src/Valkyrja/Validation/Throwable/Contract/ValidationThrowable.ts +12 -0
- package/src/Valkyrja/Validation/Throwable/Exception/Abstract/ValidationInvalidArgumentException.ts +15 -0
- package/src/Valkyrja/Validation/Throwable/Exception/Abstract/ValidationRuntimeException.ts +13 -0
- package/src/Valkyrja/Validation/Throwable/Exception/ValidationRuleFailureException.ts +12 -0
- package/src/Valkyrja/Validation/Validator/Contract/ValidatorContract.ts +18 -0
- package/src/Valkyrja/Validation/Validator/Validator.ts +57 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { OptionName } from '../../Constant/OptionName.js';
|
|
11
|
+
import { OptionShortName } from '../../Constant/OptionShortName.js';
|
|
12
|
+
import { OptionValueMode } from '../../Enum/OptionValueMode.js';
|
|
13
|
+
import { OptionParameter } from '../OptionParameter.js';
|
|
14
|
+
|
|
15
|
+
export class SilentOptionParameter extends OptionParameter {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(
|
|
18
|
+
OptionName.SILENT,
|
|
19
|
+
'All output is suppressed',
|
|
20
|
+
'',
|
|
21
|
+
null,
|
|
22
|
+
'',
|
|
23
|
+
[OptionShortName.SILENT],
|
|
24
|
+
[],
|
|
25
|
+
[],
|
|
26
|
+
undefined,
|
|
27
|
+
OptionValueMode.NONE,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { OptionName } from '../../Constant/OptionName.js';
|
|
11
|
+
import { OptionShortName } from '../../Constant/OptionShortName.js';
|
|
12
|
+
import { OptionValueMode } from '../../Enum/OptionValueMode.js';
|
|
13
|
+
import { OptionParameter } from '../OptionParameter.js';
|
|
14
|
+
|
|
15
|
+
export class VersionOptionParameter extends OptionParameter {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(
|
|
18
|
+
OptionName.VERSION,
|
|
19
|
+
'Application version',
|
|
20
|
+
'',
|
|
21
|
+
null,
|
|
22
|
+
'',
|
|
23
|
+
[OptionShortName.VERSION],
|
|
24
|
+
[],
|
|
25
|
+
[],
|
|
26
|
+
undefined,
|
|
27
|
+
OptionValueMode.NONE,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { OptionContract } from '../../Interaction/Option/Contract/OptionContract.js';
|
|
11
|
+
import type { OptionParameterContract } from './Contract/OptionParameterContract.js';
|
|
12
|
+
import type { Cast } from '../../../Type/Data/Cast.js';
|
|
13
|
+
import { OptionMode } from '../Enum/OptionMode.js';
|
|
14
|
+
import { OptionValueMode } from '../Enum/OptionValueMode.js';
|
|
15
|
+
import { CliRoutingInvalidOptionWithValueException } from '../Throwable/Exception/CliRoutingInvalidOptionWithValueException.js';
|
|
16
|
+
import { CliRoutingOptionValuesValidationException } from '../Throwable/Exception/CliRoutingOptionValuesValidationException.js';
|
|
17
|
+
import { Parameter } from './Abstract/Parameter.js';
|
|
18
|
+
import { ObjectFactory } from '../../../Type/Object/Factory/ObjectFactory.js';
|
|
19
|
+
|
|
20
|
+
export class OptionParameter extends Parameter implements OptionParameterContract {
|
|
21
|
+
constructor(
|
|
22
|
+
name: string,
|
|
23
|
+
description: string,
|
|
24
|
+
protected valueDisplayName: string = '',
|
|
25
|
+
cast: Cast | null = null,
|
|
26
|
+
protected defaultValue: string = '',
|
|
27
|
+
protected shortNames: string[] = [],
|
|
28
|
+
protected validValues: string[] = [],
|
|
29
|
+
protected options: OptionContract[] = [],
|
|
30
|
+
protected mode: OptionMode = OptionMode.OPTIONAL,
|
|
31
|
+
protected valueMode: OptionValueMode = OptionValueMode.DEFAULT,
|
|
32
|
+
) {
|
|
33
|
+
super(name, description, cast);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getShortNames(): string[] {
|
|
37
|
+
return this.shortNames;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
withShortNames(...shortNames: string[]): this {
|
|
41
|
+
const clone = ObjectFactory.clone(this);
|
|
42
|
+
clone.shortNames = shortNames;
|
|
43
|
+
return clone;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
withAddedShortNames(...shortNames: string[]): this {
|
|
47
|
+
const clone = ObjectFactory.clone(this);
|
|
48
|
+
const existing = new Set(clone.shortNames);
|
|
49
|
+
for (const n of shortNames) {
|
|
50
|
+
if (!existing.has(n)) {
|
|
51
|
+
existing.add(n);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
clone.shortNames = [...existing];
|
|
55
|
+
return clone;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getMode(): OptionMode {
|
|
59
|
+
return this.mode;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
withMode(mode: OptionMode): this {
|
|
63
|
+
const clone = ObjectFactory.clone(this);
|
|
64
|
+
clone.mode = mode;
|
|
65
|
+
return clone;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getValueMode(): OptionValueMode {
|
|
69
|
+
return this.valueMode;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
withValueMode(valueMode: OptionValueMode): this {
|
|
73
|
+
const clone = ObjectFactory.clone(this);
|
|
74
|
+
clone.valueMode = valueMode;
|
|
75
|
+
return clone;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
hasValueDisplayName(): boolean {
|
|
79
|
+
return this.valueDisplayName !== '';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getValueDisplayName(): string {
|
|
83
|
+
return this.valueDisplayName;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
withValueDisplayName(valueName: string): this {
|
|
87
|
+
const clone = ObjectFactory.clone(this);
|
|
88
|
+
clone.valueDisplayName = valueName;
|
|
89
|
+
return clone;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getValidValues(): string[] {
|
|
93
|
+
return this.validValues;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
withValidValues(...validValues: string[]): this {
|
|
97
|
+
const clone = ObjectFactory.clone(this);
|
|
98
|
+
clone.validValues = validValues;
|
|
99
|
+
return clone;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
withAddedValidValues(...validValues: string[]): this {
|
|
103
|
+
const clone = ObjectFactory.clone(this);
|
|
104
|
+
const existing = new Set(clone.validValues);
|
|
105
|
+
for (const v of validValues) {
|
|
106
|
+
if (!existing.has(v)) {
|
|
107
|
+
existing.add(v);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
clone.validValues = [...existing];
|
|
111
|
+
return clone;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
hasDefaultValue(): boolean {
|
|
115
|
+
return this.defaultValue !== '';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getDefaultValue(): string {
|
|
119
|
+
return this.defaultValue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
withDefaultValue(defaultValue: string): this {
|
|
123
|
+
const clone = ObjectFactory.clone(this);
|
|
124
|
+
clone.defaultValue = defaultValue;
|
|
125
|
+
return clone;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getOptions(): OptionContract[] {
|
|
129
|
+
return this.options;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
withOptions(...options: OptionContract[]): this {
|
|
133
|
+
const clone = ObjectFactory.clone(this);
|
|
134
|
+
clone.options = [];
|
|
135
|
+
for (const option of options) {
|
|
136
|
+
if (this.valueMode === OptionValueMode.NONE && option.hasValue()) {
|
|
137
|
+
throw new CliRoutingInvalidOptionWithValueException(`${this.name} should have no value`);
|
|
138
|
+
}
|
|
139
|
+
clone.options.push(option);
|
|
140
|
+
}
|
|
141
|
+
return clone;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
withAddedOptions(...options: OptionContract[]): this {
|
|
145
|
+
const clone = ObjectFactory.clone(this);
|
|
146
|
+
clone.options = [...this.options];
|
|
147
|
+
for (const option of options) {
|
|
148
|
+
if (this.valueMode === OptionValueMode.NONE && option.hasValue()) {
|
|
149
|
+
throw new CliRoutingInvalidOptionWithValueException(`${this.name} should have no value`);
|
|
150
|
+
}
|
|
151
|
+
clone.options.push(option);
|
|
152
|
+
}
|
|
153
|
+
return clone;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
getCastValues(): unknown[] {
|
|
157
|
+
return this.getCastValuesForParameters(this.options);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
hasFirstValue(): boolean {
|
|
161
|
+
return this.options.length > 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getFirstValue(): string {
|
|
165
|
+
return this.options[0]?.getValue() ?? '';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
areValuesValid(): boolean {
|
|
169
|
+
let valid = true;
|
|
170
|
+
|
|
171
|
+
if (this.mode === OptionMode.REQUIRED) {
|
|
172
|
+
valid = this.options.length > 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this.valueMode === OptionValueMode.DEFAULT) {
|
|
176
|
+
valid = valid && this.options.length <= 1;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return valid;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
validateValues(): this {
|
|
183
|
+
if (!this.areValuesValid()) {
|
|
184
|
+
throw new CliRoutingOptionValuesValidationException(`${this.name} is invalid`);
|
|
185
|
+
}
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MessageContract } from '../../Interaction/Message/Contract/MessageContract.js';
|
|
11
|
+
import type { OutputContract } from '../../Interaction/Output/Contract/OutputContract.js';
|
|
12
|
+
import type { ContainerContract } from '../../../Container/Manager/Contract/ContainerContract.js';
|
|
13
|
+
import type { ArgumentParameterContract } from './Contract/ArgumentParameterContract.js';
|
|
14
|
+
import type { OptionParameterContract } from './Contract/OptionParameterContract.js';
|
|
15
|
+
import type { RouteContract } from './Contract/RouteContract.js';
|
|
16
|
+
import { CliRoutingInvalidArgumentNameException } from '../Throwable/Exception/CliRoutingInvalidArgumentNameException.js';
|
|
17
|
+
import { CliRoutingInvalidOptionNameException } from '../Throwable/Exception/CliRoutingInvalidOptionNameException.js';
|
|
18
|
+
import { CliRoutingNoHelpTextException } from '../Throwable/Exception/CliRoutingNoHelpTextException.js';
|
|
19
|
+
import { ObjectFactory } from '../../../Type/Object/Factory/ObjectFactory.js';
|
|
20
|
+
|
|
21
|
+
export class Route implements RouteContract {
|
|
22
|
+
constructor(
|
|
23
|
+
protected name: string,
|
|
24
|
+
protected description: string,
|
|
25
|
+
protected handler: (container: ContainerContract, route: RouteContract) => OutputContract,
|
|
26
|
+
protected helpText: (() => MessageContract) | null = null,
|
|
27
|
+
protected routeMatchedMiddleware: string[] = [],
|
|
28
|
+
protected routeDispatchedMiddleware: string[] = [],
|
|
29
|
+
protected throwableCaughtMiddleware: string[] = [],
|
|
30
|
+
protected exitedMiddleware: string[] = [],
|
|
31
|
+
protected arguments_: ArgumentParameterContract[] = [],
|
|
32
|
+
protected options: OptionParameterContract[] = [],
|
|
33
|
+
) {}
|
|
34
|
+
|
|
35
|
+
getName(): string {
|
|
36
|
+
return this.name;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
withName(name: string): this {
|
|
40
|
+
const clone = ObjectFactory.clone(this);
|
|
41
|
+
clone.name = name;
|
|
42
|
+
return clone;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getDescription(): string {
|
|
46
|
+
return this.description;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
withDescription(description: string): this {
|
|
50
|
+
const clone = ObjectFactory.clone(this);
|
|
51
|
+
clone.description = description;
|
|
52
|
+
return clone;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
hasHelpText(): boolean {
|
|
56
|
+
return this.helpText !== null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getHelpText(): () => MessageContract {
|
|
60
|
+
if (this.helpText === null) {
|
|
61
|
+
throw new CliRoutingNoHelpTextException('No help text has been set for this route');
|
|
62
|
+
}
|
|
63
|
+
return this.helpText;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getHelpTextMessage(): MessageContract {
|
|
67
|
+
return this.getHelpText()();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
withHelpText(helpText: () => MessageContract): this {
|
|
71
|
+
const clone = ObjectFactory.clone(this);
|
|
72
|
+
clone.helpText = helpText;
|
|
73
|
+
return clone;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
hasArguments(): boolean {
|
|
77
|
+
return this.arguments_.length > 0;
|
|
78
|
+
}
|
|
79
|
+
getArguments(): ArgumentParameterContract[] {
|
|
80
|
+
return this.arguments_;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
hasArgument(name: string): boolean {
|
|
84
|
+
return this.arguments_.some((a) => a.getName() === name);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
getArgument(name: string): ArgumentParameterContract {
|
|
88
|
+
const found = this.arguments_.find((a) => a.getName() === name);
|
|
89
|
+
if (found === undefined) {
|
|
90
|
+
throw new CliRoutingInvalidArgumentNameException(`The argument \`${name}\` was not found`);
|
|
91
|
+
}
|
|
92
|
+
return found;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
withArguments(...arguments_: ArgumentParameterContract[]): this {
|
|
96
|
+
const clone = ObjectFactory.clone(this);
|
|
97
|
+
clone.arguments_ = arguments_;
|
|
98
|
+
return clone;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
withAddedArguments(...arguments_: ArgumentParameterContract[]): this {
|
|
102
|
+
const clone = ObjectFactory.clone(this);
|
|
103
|
+
clone.arguments_ = [...this.arguments_, ...arguments_];
|
|
104
|
+
return clone;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
hasOptions(): boolean {
|
|
108
|
+
return this.options.length > 0;
|
|
109
|
+
}
|
|
110
|
+
getOptions(): OptionParameterContract[] {
|
|
111
|
+
return this.options;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
hasOption(name: string): boolean {
|
|
115
|
+
return this.options.some((o) => o.getName() === name);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getOption(name: string): OptionParameterContract {
|
|
119
|
+
const found = this.options.find((o) => o.getName() === name);
|
|
120
|
+
if (found === undefined) {
|
|
121
|
+
throw new CliRoutingInvalidOptionNameException(`The option \`${name}\` was not found`);
|
|
122
|
+
}
|
|
123
|
+
return found;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
withOptions(...options: OptionParameterContract[]): this {
|
|
127
|
+
const clone = ObjectFactory.clone(this);
|
|
128
|
+
clone.options = options;
|
|
129
|
+
return clone;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
withAddedOptions(...options: OptionParameterContract[]): this {
|
|
133
|
+
const clone = ObjectFactory.clone(this);
|
|
134
|
+
clone.options = [...this.options, ...options];
|
|
135
|
+
return clone;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
getRouteMatchedMiddleware(): string[] {
|
|
139
|
+
return this.routeMatchedMiddleware;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
withRouteMatchedMiddleware(...middleware: string[]): this {
|
|
143
|
+
const clone = ObjectFactory.clone(this);
|
|
144
|
+
clone.routeMatchedMiddleware = middleware;
|
|
145
|
+
return clone;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
withAddedRouteMatchedMiddleware(...middleware: string[]): this {
|
|
149
|
+
const clone = ObjectFactory.clone(this);
|
|
150
|
+
clone.routeMatchedMiddleware = [...this.routeMatchedMiddleware, ...middleware];
|
|
151
|
+
return clone;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getRouteDispatchedMiddleware(): string[] {
|
|
155
|
+
return this.routeDispatchedMiddleware;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
withRouteDispatchedMiddleware(...middleware: string[]): this {
|
|
159
|
+
const clone = ObjectFactory.clone(this);
|
|
160
|
+
clone.routeDispatchedMiddleware = middleware;
|
|
161
|
+
return clone;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
withAddedRouteDispatchedMiddleware(...middleware: string[]): this {
|
|
165
|
+
const clone = ObjectFactory.clone(this);
|
|
166
|
+
clone.routeDispatchedMiddleware = [...this.routeDispatchedMiddleware, ...middleware];
|
|
167
|
+
return clone;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
getThrowableCaughtMiddleware(): string[] {
|
|
171
|
+
return this.throwableCaughtMiddleware;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
withThrowableCaughtMiddleware(...middleware: string[]): this {
|
|
175
|
+
const clone = ObjectFactory.clone(this);
|
|
176
|
+
clone.throwableCaughtMiddleware = middleware;
|
|
177
|
+
return clone;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
withAddedThrowableCaughtMiddleware(...middleware: string[]): this {
|
|
181
|
+
const clone = ObjectFactory.clone(this);
|
|
182
|
+
clone.throwableCaughtMiddleware = [...this.throwableCaughtMiddleware, ...middleware];
|
|
183
|
+
return clone;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
getExitedMiddleware(): string[] {
|
|
187
|
+
return this.exitedMiddleware;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
withExitedMiddleware(...middleware: string[]): this {
|
|
191
|
+
const clone = ObjectFactory.clone(this);
|
|
192
|
+
clone.exitedMiddleware = middleware;
|
|
193
|
+
return clone;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
withAddedExitedMiddleware(...middleware: string[]): this {
|
|
197
|
+
const clone = ObjectFactory.clone(this);
|
|
198
|
+
clone.exitedMiddleware = [...this.exitedMiddleware, ...middleware];
|
|
199
|
+
return clone;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
getHandler(): (container: ContainerContract, route: RouteContract) => OutputContract {
|
|
203
|
+
return this.handler;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
withHandler(handler: (container: ContainerContract, route: RouteContract) => OutputContract): this {
|
|
207
|
+
const clone = ObjectFactory.clone(this);
|
|
208
|
+
clone.handler = handler;
|
|
209
|
+
return clone;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { InputContract } from '../../../Interaction/Input/Contract/InputContract.js';
|
|
11
|
+
import type { OutputContract } from '../../../Interaction/Output/Contract/OutputContract.js';
|
|
12
|
+
import type { RouteContract } from '../../Data/Contract/RouteContract.js';
|
|
13
|
+
|
|
14
|
+
export interface RouterContract {
|
|
15
|
+
dispatch(input: InputContract): OutputContract;
|
|
16
|
+
dispatchRoute(input: InputContract, route: RouteContract): OutputContract;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export namespace RouterContract {
|
|
20
|
+
export function instanceOf(value: unknown): value is RouterContract {
|
|
21
|
+
return typeof value === 'object' && value !== null && 'dispatch' in value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Container } from '../../../Container/Manager/Container.js';
|
|
11
|
+
import { ExitCode } from '../../Interaction/Enum/ExitCode.js';
|
|
12
|
+
import type { InputContract } from '../../Interaction/Input/Contract/InputContract.js';
|
|
13
|
+
import { Banner } from '../../Interaction/Message/Banner.js';
|
|
14
|
+
import { ErrorMessage } from '../../Interaction/Message/ErrorMessage.js';
|
|
15
|
+
import type { OutputContract } from '../../Interaction/Output/Contract/OutputContract.js';
|
|
16
|
+
import { OutputFactory } from '../../Interaction/Output/Factory/OutputFactory.js';
|
|
17
|
+
import type { OutputFactoryContract } from '../../Interaction/Output/Factory/Contract/OutputFactoryContract.js';
|
|
18
|
+
import { ExitedHandler } from '../../Middleware/Handler/ExitedHandler.js';
|
|
19
|
+
import type { ExitedHandlerContract } from '../../Middleware/Handler/Contract/ExitedHandlerContract.js';
|
|
20
|
+
import { RouteDispatchedHandler } from '../../Middleware/Handler/RouteDispatchedHandler.js';
|
|
21
|
+
import type { RouteDispatchedHandlerContract } from '../../Middleware/Handler/Contract/RouteDispatchedHandlerContract.js';
|
|
22
|
+
import { RouteMatchedHandler } from '../../Middleware/Handler/RouteMatchedHandler.js';
|
|
23
|
+
import type { RouteMatchedHandlerContract } from '../../Middleware/Handler/Contract/RouteMatchedHandlerContract.js';
|
|
24
|
+
import { RouteNotMatchedHandler } from '../../Middleware/Handler/RouteNotMatchedHandler.js';
|
|
25
|
+
import type { RouteNotMatchedHandlerContract } from '../../Middleware/Handler/Contract/RouteNotMatchedHandlerContract.js';
|
|
26
|
+
import { ThrowableCaughtHandler } from '../../Middleware/Handler/ThrowableCaughtHandler.js';
|
|
27
|
+
import type { ThrowableCaughtHandlerContract } from '../../Middleware/Handler/Contract/ThrowableCaughtHandlerContract.js';
|
|
28
|
+
import { RouteCollection } from '../Collection/RouteCollection.js';
|
|
29
|
+
import type { RouteCollectionContract } from '../Collection/Contract/RouteCollectionContract.js';
|
|
30
|
+
import type { ArgumentParameterContract } from '../Data/Contract/ArgumentParameterContract.js';
|
|
31
|
+
import type { OptionParameterContract } from '../Data/Contract/OptionParameterContract.js';
|
|
32
|
+
import type { RouteContract } from '../Data/Contract/RouteContract.js';
|
|
33
|
+
import { ArgumentValueMode } from '../Enum/ArgumentValueMode.js';
|
|
34
|
+
import type { ContainerContract } from '../../../Container/Manager/Contract/ContainerContract.js';
|
|
35
|
+
import { CliRoutingServiceId } from '../Constant/CliRoutingServiceId.js';
|
|
36
|
+
import type { RouterContract } from './Contract/RouterContract.js';
|
|
37
|
+
|
|
38
|
+
export class Router implements RouterContract {
|
|
39
|
+
constructor(
|
|
40
|
+
protected container: ContainerContract = new Container(),
|
|
41
|
+
protected collection: RouteCollectionContract = new RouteCollection(),
|
|
42
|
+
protected outputFactory: OutputFactoryContract = new OutputFactory(),
|
|
43
|
+
protected throwableCaughtHandler: ThrowableCaughtHandlerContract = new ThrowableCaughtHandler(),
|
|
44
|
+
protected routeMatchedHandler: RouteMatchedHandlerContract = new RouteMatchedHandler(),
|
|
45
|
+
protected routeNotMatchedHandler: RouteNotMatchedHandlerContract = new RouteNotMatchedHandler(),
|
|
46
|
+
protected routeDispatchedHandler: RouteDispatchedHandlerContract = new RouteDispatchedHandler(),
|
|
47
|
+
protected exitedHandler: ExitedHandlerContract = new ExitedHandler(),
|
|
48
|
+
) {}
|
|
49
|
+
|
|
50
|
+
dispatch(input: InputContract): OutputContract {
|
|
51
|
+
const matchedRoute = this.attemptToMatchRoute(input);
|
|
52
|
+
|
|
53
|
+
if (!this.isRouteContract(matchedRoute)) {
|
|
54
|
+
return this.routeNotMatchedHandler.routeNotMatched(input, matchedRoute);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return this.dispatchRoute(input, matchedRoute);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
dispatchRoute(input: InputContract, route: RouteContract): OutputContract {
|
|
61
|
+
route = this.addParametersToRoute(input, route);
|
|
62
|
+
|
|
63
|
+
this.routeMatched(route);
|
|
64
|
+
|
|
65
|
+
const routeAfterMiddleware = this.routeMatchedHandler.routeMatched(input, route);
|
|
66
|
+
|
|
67
|
+
if (!this.isRouteContract(routeAfterMiddleware)) {
|
|
68
|
+
return routeAfterMiddleware;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.container.setSingleton<RouteContract>(CliRoutingServiceId.RouteContract, routeAfterMiddleware);
|
|
72
|
+
|
|
73
|
+
const handler = routeAfterMiddleware.getHandler();
|
|
74
|
+
const output = handler(this.container, routeAfterMiddleware);
|
|
75
|
+
|
|
76
|
+
return this.routeDispatchedHandler.routeDispatched(input, output, routeAfterMiddleware);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected attemptToMatchRoute(input: InputContract): RouteContract | OutputContract {
|
|
80
|
+
const commandName = input.getCommandName();
|
|
81
|
+
|
|
82
|
+
if (this.collection.has(commandName)) {
|
|
83
|
+
return this.collection.get(commandName);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const errorText = `Command \`${commandName}\` was not found.`;
|
|
87
|
+
|
|
88
|
+
return this.outputFactory.createOutput(ExitCode.ERROR).withMessages(new Banner(new ErrorMessage(errorText)));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
protected addParametersToRoute(input: InputContract, route: RouteContract): RouteContract {
|
|
92
|
+
route = this.addArgumentsToRoute(input, route);
|
|
93
|
+
|
|
94
|
+
return this.addOptionsToRoute(input, route);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected addArgumentsToRoute(input: InputContract, route: RouteContract): RouteContract {
|
|
98
|
+
const arguments_ = [...input.getArguments()];
|
|
99
|
+
const argumentParameters = route.getArguments();
|
|
100
|
+
const updatedParams: ArgumentParameterContract[] = [];
|
|
101
|
+
|
|
102
|
+
for (let i = 0; i < argumentParameters.length; i++) {
|
|
103
|
+
const param = argumentParameters[i];
|
|
104
|
+
|
|
105
|
+
if (param === undefined) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let paramArguments: typeof arguments_ = [];
|
|
110
|
+
|
|
111
|
+
if (param.getValueMode() === ArgumentValueMode.ARRAY) {
|
|
112
|
+
paramArguments = arguments_.splice(0);
|
|
113
|
+
} else {
|
|
114
|
+
const arg = arguments_[i];
|
|
115
|
+
if (arg !== undefined) {
|
|
116
|
+
paramArguments = [arg];
|
|
117
|
+
arguments_.splice(i, 1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
updatedParams.push(param.withArguments(...paramArguments).validateValues());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return route.withArguments(...updatedParams);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
protected addOptionsToRoute(input: InputContract, route: RouteContract): RouteContract {
|
|
128
|
+
const options = input.getOptions();
|
|
129
|
+
const optionParameters = [...route.getOptions()];
|
|
130
|
+
const updatedParams: OptionParameterContract[] = [];
|
|
131
|
+
|
|
132
|
+
for (const param of optionParameters) {
|
|
133
|
+
const paramOptions = options.filter(
|
|
134
|
+
(opt) => param.getName() === opt.getName() || param.getShortNames().includes(opt.getName()),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
updatedParams.push(param.withOptions(...paramOptions).validateValues());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return route.withOptions(...updatedParams);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
protected routeMatched(route: RouteContract): void {
|
|
144
|
+
this.routeMatchedHandler.add(...route.getRouteMatchedMiddleware());
|
|
145
|
+
this.routeDispatchedHandler.add(...route.getRouteDispatchedMiddleware());
|
|
146
|
+
this.throwableCaughtHandler.add(...route.getThrowableCaughtMiddleware());
|
|
147
|
+
this.exitedHandler.add(...route.getExitedMiddleware());
|
|
148
|
+
|
|
149
|
+
this.container.setSingleton<RouteContract>(CliRoutingServiceId.RouteContract, route);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
protected isRouteContract(value: RouteContract | OutputContract): value is RouteContract {
|
|
153
|
+
return 'getHandler' in value;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export enum ArgumentMode {
|
|
11
|
+
REQUIRED = 'REQUIRED',
|
|
12
|
+
OPTIONAL = 'OPTIONAL',
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export enum ArgumentValueMode {
|
|
11
|
+
DEFAULT = 'DEFAULT',
|
|
12
|
+
ARRAY = 'ARRAY',
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Valkyrja package.
|
|
3
|
+
*
|
|
4
|
+
* (c) Melech Mizrachi <melechmizrachi@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export enum OptionMode {
|
|
11
|
+
REQUIRED = 'REQUIRED',
|
|
12
|
+
OPTIONAL = 'OPTIONAL',
|
|
13
|
+
}
|