@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,227 @@
|
|
|
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 { allRequestMethods, RequestMethod } from '../../Message/Enum/RequestMethod.js';
|
|
11
|
+
import { DynamicRoute } from '../Data/DynamicRoute.js';
|
|
12
|
+
import { HttpRoutingData } from '../Data/HttpRoutingData.js';
|
|
13
|
+
import { HttpRoutingInvalidDynamicRouteNameException } from '../Throwable/Exception/HttpRoutingInvalidDynamicRouteNameException.js';
|
|
14
|
+
import { HttpRoutingInvalidRouteNameException } from '../Throwable/Exception/HttpRoutingInvalidRouteNameException.js';
|
|
15
|
+
import { HttpRoutingInvalidRoutePathException } from '../Throwable/Exception/HttpRoutingInvalidRoutePathException.js';
|
|
16
|
+
import { HttpRoutingInvalidRouteRegexException } from '../Throwable/Exception/HttpRoutingInvalidRouteRegexException.js';
|
|
17
|
+
|
|
18
|
+
import type { DynamicRouteContract } from '../Data/Contract/DynamicRouteContract.js';
|
|
19
|
+
import type { RouteContract } from '../Data/Contract/RouteContract.js';
|
|
20
|
+
import type { RouteCollectionContract } from './Contract/RouteCollectionContract.js';
|
|
21
|
+
|
|
22
|
+
export class RouteCollection implements RouteCollectionContract {
|
|
23
|
+
protected routes: Record<string, () => RouteContract | DynamicRouteContract> = {};
|
|
24
|
+
protected paths: Record<string, Record<string, string>> = {};
|
|
25
|
+
protected dynamicPaths: Record<string, Record<string, string>> = {};
|
|
26
|
+
protected regexes: Record<string, Record<string, string>> = {};
|
|
27
|
+
|
|
28
|
+
getData(): HttpRoutingData {
|
|
29
|
+
return new HttpRoutingData(this.routes, this.paths, this.dynamicPaths, this.regexes);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setFromData(data: HttpRoutingData): void {
|
|
33
|
+
this.routes = data.routes;
|
|
34
|
+
this.paths = data.paths as Record<string, Record<string, string>>;
|
|
35
|
+
this.dynamicPaths = data.dynamicPaths as Record<string, Record<string, string>>;
|
|
36
|
+
this.regexes = data.regexes as Record<string, Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
add(route: RouteContract): void {
|
|
40
|
+
this.setRouteToRequestMethods(route);
|
|
41
|
+
|
|
42
|
+
const name = route.getName();
|
|
43
|
+
|
|
44
|
+
this.routes[name] = (): RouteContract => route;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
hasPath(path: string, method: RequestMethod): boolean {
|
|
48
|
+
if (method !== RequestMethod.ANY) {
|
|
49
|
+
return this.paths[method]?.[path] !== undefined || this.dynamicPaths[method]?.[path] !== undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return allRequestMethods().some((m) => this.hasPath(path, m));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getByPath(path: string, method: RequestMethod): RouteContract {
|
|
56
|
+
const route = this.internalGetByPath(path, method);
|
|
57
|
+
|
|
58
|
+
if (route !== null) {
|
|
59
|
+
return route;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new HttpRoutingInvalidRoutePathException(
|
|
63
|
+
`The path '${path}' is not a valid route for the given method '${method}'`,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
hasRegex(regex: string, method: RequestMethod): boolean {
|
|
68
|
+
if (method !== RequestMethod.ANY) {
|
|
69
|
+
return this.regexes[method]?.[regex] !== undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return allRequestMethods().some((m) => this.hasRegex(regex, m));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getByRegex(regex: string, method: RequestMethod): DynamicRouteContract {
|
|
76
|
+
const route = this.internalGetByRegex(regex, method);
|
|
77
|
+
|
|
78
|
+
if (route !== null) {
|
|
79
|
+
return route;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw new HttpRoutingInvalidRouteRegexException(
|
|
83
|
+
`The regex '${regex}' is not a valid route for the given method '${method}'`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
getPaths(method: RequestMethod): Record<string, string> {
|
|
88
|
+
if (method !== RequestMethod.ANY) {
|
|
89
|
+
return this.paths[method] ?? {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return Object.assign(
|
|
93
|
+
{},
|
|
94
|
+
...allRequestMethods().map((m) => this.paths[m] ?? {}),
|
|
95
|
+
...allRequestMethods().map((m) => this.dynamicPaths[m] ?? {}),
|
|
96
|
+
) as Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getRegexes(method: RequestMethod): Record<string, string> {
|
|
100
|
+
if (method !== RequestMethod.ANY) {
|
|
101
|
+
return this.regexes[method] ?? {};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return Object.assign({}, ...allRequestMethods().map((m) => this.regexes[m] ?? {})) as Record<string, string>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
hasName(name: string): boolean {
|
|
108
|
+
return this.routes[name] !== undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getByName(name: string): RouteContract {
|
|
112
|
+
const route = this.routes[name];
|
|
113
|
+
|
|
114
|
+
if (route !== undefined) {
|
|
115
|
+
return route();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
throw new HttpRoutingInvalidRouteNameException(`A route with the name '${name}' does not exist`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getAll(method: RequestMethod): Record<string, RouteContract> {
|
|
122
|
+
const paths = this.getPaths(method);
|
|
123
|
+
|
|
124
|
+
return Object.fromEntries(Object.entries(paths).map(([, name]) => [name, this.getRouteFromName(name)]));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
protected internalGetByPath(path: string, method: RequestMethod): RouteContract | null {
|
|
128
|
+
if (method !== RequestMethod.ANY) {
|
|
129
|
+
const name = this.paths[method]?.[path] ?? this.dynamicPaths[method]?.[path];
|
|
130
|
+
|
|
131
|
+
if (name !== undefined) {
|
|
132
|
+
return this.getRouteFromName(name);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (const m of allRequestMethods()) {
|
|
139
|
+
const route = this.internalGetByPath(path, m);
|
|
140
|
+
|
|
141
|
+
if (route !== null) {
|
|
142
|
+
return route;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
protected internalGetByRegex(regex: string, method: RequestMethod): DynamicRouteContract | null {
|
|
150
|
+
if (method !== RequestMethod.ANY) {
|
|
151
|
+
const name = this.regexes[method]?.[regex];
|
|
152
|
+
|
|
153
|
+
if (name !== undefined) {
|
|
154
|
+
return this.getDynamicRouteFromName(name);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
for (const m of allRequestMethods()) {
|
|
161
|
+
const route = this.internalGetByRegex(regex, m);
|
|
162
|
+
|
|
163
|
+
if (route !== null) {
|
|
164
|
+
return route;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
protected setRouteToRequestMethods(route: RouteContract): void {
|
|
172
|
+
let requestMethods = route.getRequestMethods();
|
|
173
|
+
|
|
174
|
+
if (requestMethods.includes(RequestMethod.ANY)) {
|
|
175
|
+
requestMethods = allRequestMethods();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
for (const method of requestMethods) {
|
|
179
|
+
this.setRouteToRequestMethod(route, method);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
protected setRouteToRequestMethod(route: RouteContract, method: RequestMethod): void {
|
|
184
|
+
if (method === RequestMethod.ANY) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const name = route.getName();
|
|
189
|
+
const path = route.getPath();
|
|
190
|
+
|
|
191
|
+
if (route instanceof DynamicRoute) {
|
|
192
|
+
const regex = route.getRegex();
|
|
193
|
+
|
|
194
|
+
this.dynamicPaths[method] ??= {};
|
|
195
|
+
this.regexes[method] ??= {};
|
|
196
|
+
|
|
197
|
+
this.dynamicPaths[method][path] = name;
|
|
198
|
+
this.regexes[method][regex] = name;
|
|
199
|
+
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this.paths[method] ??= {};
|
|
204
|
+
|
|
205
|
+
this.paths[method][path] = name;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected getRouteFromName(name: string): RouteContract {
|
|
209
|
+
const route = this.routes[name];
|
|
210
|
+
|
|
211
|
+
if (route === undefined) {
|
|
212
|
+
throw new HttpRoutingInvalidRouteNameException(`Invalid name '${name}' provided`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return route();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
protected getDynamicRouteFromName(name: string): DynamicRouteContract {
|
|
219
|
+
const route = this.getRouteFromName(name);
|
|
220
|
+
|
|
221
|
+
if (route instanceof DynamicRoute) {
|
|
222
|
+
return route;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
throw new HttpRoutingInvalidDynamicRouteNameException(`Invalid dynamic route ${name}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { RouteContract } from '../../Data/Contract/RouteContract.js';
|
|
11
|
+
|
|
12
|
+
export interface RouteCollectorContract {
|
|
13
|
+
getRoutes(...classes: Array<new (...args: unknown[]) => unknown>): RouteContract[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 class HttpRoutingServiceId {
|
|
11
|
+
static readonly RouterContract = 'Valkyrja.Http.Routing.Dispatcher.RouterContract' as const;
|
|
12
|
+
static readonly RouteCollectionContract = 'Valkyrja.Http.Routing.Collection.RouteCollectionContract' as const;
|
|
13
|
+
static readonly RouteCollectorContract = 'Valkyrja.Http.Routing.Collector.RouteCollectorContract' as const;
|
|
14
|
+
static readonly MatcherContract = 'Valkyrja.Http.Routing.Matcher.MatcherContract' as const;
|
|
15
|
+
static readonly ProcessorContract = 'Valkyrja.Http.Routing.Processor.ProcessorContract' as const;
|
|
16
|
+
static readonly RoutingResponseFactory = 'Valkyrja.Http.Routing.Factory.RoutingResponseFactoryContract' as const;
|
|
17
|
+
static readonly UrlContract = 'Valkyrja.Http.Routing.Url.UrlContract' as const;
|
|
18
|
+
static readonly RouteContract = 'Valkyrja.Http.Routing.Data.RouteContract' as const;
|
|
19
|
+
static readonly HttpRoutingData = 'Valkyrja.Http.Routing.Data.HttpRoutingData' as const;
|
|
20
|
+
static readonly ListCommand = 'Valkyrja.Http.Routing.Cli.Command.ListCommand' as const;
|
|
21
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
const UUID_PART = '[0-9A-Fa-f]';
|
|
11
|
+
const ULID_VLID_CHARS = '0123456789ABCDEFGHJKMNPQRSTVWXYZabcdefghjkmnpqrstvwxyz';
|
|
12
|
+
|
|
13
|
+
export class Regex {
|
|
14
|
+
static readonly PATH = '\\/';
|
|
15
|
+
static readonly ANY = '.*';
|
|
16
|
+
static readonly NUM = '\\d+';
|
|
17
|
+
|
|
18
|
+
static readonly ID = Regex.NUM;
|
|
19
|
+
|
|
20
|
+
static readonly SLUG = '[a-zA-Z0-9-]+';
|
|
21
|
+
|
|
22
|
+
static readonly UUID = `${UUID_PART}{8}-${UUID_PART}{4}-${UUID_PART}{4}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
23
|
+
static readonly UUID_V1 = `${UUID_PART}{8}-${UUID_PART}{4}-[1]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
24
|
+
static readonly UUID_V3 = `${UUID_PART}{8}-${UUID_PART}{4}-[3]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
25
|
+
static readonly UUID_V4 = `${UUID_PART}{8}-${UUID_PART}{4}-[4]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
26
|
+
static readonly UUID_V5 = `${UUID_PART}{8}-${UUID_PART}{4}-[5]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
27
|
+
static readonly UUID_V6 = `${UUID_PART}{8}-${UUID_PART}{4}-[6]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
28
|
+
static readonly UUID_V7 = `${UUID_PART}{8}-${UUID_PART}{4}-[7]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
29
|
+
static readonly UUID_V8 = `${UUID_PART}{8}-${UUID_PART}{4}-[8]${UUID_PART}{3}-${UUID_PART}{4}-${UUID_PART}{12}`;
|
|
30
|
+
|
|
31
|
+
static readonly ULID = `[0-7][${ULID_VLID_CHARS}]{25}`;
|
|
32
|
+
|
|
33
|
+
static readonly VLID = `[0-7][${ULID_VLID_CHARS}]{12}[1-4][${ULID_VLID_CHARS}]{4}([${ULID_VLID_CHARS}]{4})?([${ULID_VLID_CHARS}]{4})?([${ULID_VLID_CHARS}]{4})?`;
|
|
34
|
+
static readonly VLID_V1 = `[0-7][${ULID_VLID_CHARS}]{12}[1][${ULID_VLID_CHARS}]{12}`;
|
|
35
|
+
static readonly VLID_V2 = `[0-7][${ULID_VLID_CHARS}]{12}[2][${ULID_VLID_CHARS}]{16}`;
|
|
36
|
+
static readonly VLID_V3 = `[0-7][${ULID_VLID_CHARS}]{12}[3][${ULID_VLID_CHARS}]{8}`;
|
|
37
|
+
static readonly VLID_V4 = `[0-7][${ULID_VLID_CHARS}]{12}[4][${ULID_VLID_CHARS}]{4}`;
|
|
38
|
+
|
|
39
|
+
static readonly ALPHA = '[a-zA-Z]+';
|
|
40
|
+
static readonly ALPHA_LOWERCASE = '[a-z]+';
|
|
41
|
+
static readonly ALPHA_UPPERCASE = '[A-Z]+';
|
|
42
|
+
static readonly ALPHA_NUM = '[a-zA-Z0-9]+';
|
|
43
|
+
static readonly ALPHA_NUM_UNDERSCORE = '\\w+';
|
|
44
|
+
|
|
45
|
+
static readonly START = '/^';
|
|
46
|
+
static readonly END = '$/';
|
|
47
|
+
|
|
48
|
+
static readonly START_CAPTURE_GROUP = '(';
|
|
49
|
+
static readonly START_NON_CAPTURE_GROUP = '(?:';
|
|
50
|
+
static readonly END_CAPTURE_GROUP = ')';
|
|
51
|
+
static readonly END_OPTIONAL_CAPTURE_GROUP = ')?';
|
|
52
|
+
static readonly START_OPTIONAL_CAPTURE_GROUP =
|
|
53
|
+
Regex.START_NON_CAPTURE_GROUP + Regex.PATH + Regex.END_OPTIONAL_CAPTURE_GROUP;
|
|
54
|
+
|
|
55
|
+
static readonly START_CAPTURE_GROUP_NAME = '?<';
|
|
56
|
+
static readonly END_CAPTURE_GROUP_NAME = '>';
|
|
57
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { ServerRequestContract } from '../../Message/Request/Contract/ServerRequestContract.js';
|
|
11
|
+
import type { ResponseFactoryContract } from '../../Message/Response/Factory/Contract/ResponseFactoryContract.js';
|
|
12
|
+
|
|
13
|
+
export abstract class Controller {
|
|
14
|
+
constructor(
|
|
15
|
+
protected request: ServerRequestContract,
|
|
16
|
+
protected responseFactory: ResponseFactoryContract,
|
|
17
|
+
) {}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { ParameterContract } from './ParameterContract.js';
|
|
11
|
+
import type { RouteContract } from './RouteContract.js';
|
|
12
|
+
|
|
13
|
+
export interface DynamicRouteContract extends RouteContract {
|
|
14
|
+
getRegex(): string;
|
|
15
|
+
withRegex(regex: string): this;
|
|
16
|
+
getParameters(): ParameterContract[];
|
|
17
|
+
withParameters(...parameters: ParameterContract[]): this;
|
|
18
|
+
withAddedParameters(...parameters: ParameterContract[]): this;
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { Cast } from '../../../../Type/Data/Cast.js';
|
|
11
|
+
|
|
12
|
+
export interface ParameterContract {
|
|
13
|
+
getName(): string;
|
|
14
|
+
withName(name: string): this;
|
|
15
|
+
getRegex(): string;
|
|
16
|
+
withRegex(regex: string): this;
|
|
17
|
+
hasCast(): boolean;
|
|
18
|
+
getCast(): Cast;
|
|
19
|
+
withCast(cast: Cast): this;
|
|
20
|
+
isOptional(): boolean;
|
|
21
|
+
withIsOptional(isOptional: boolean): this;
|
|
22
|
+
shouldCapture(): boolean;
|
|
23
|
+
withShouldCapture(shouldCapture: boolean): this;
|
|
24
|
+
getDefault(): unknown;
|
|
25
|
+
withDefault(defaultValue?: unknown): this;
|
|
26
|
+
getValue(): unknown;
|
|
27
|
+
withValue(value?: unknown): this;
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { ContainerContract } from '../../../../Container/Manager/Contract/ContainerContract.js';
|
|
11
|
+
import type { ResponseContract } from '../../../Message/Response/Contract/ResponseContract.js';
|
|
12
|
+
import type { RequestMethod } from '../../../Message/Enum/RequestMethod.js';
|
|
13
|
+
import type { RouteMatchedMiddlewareContract } from '../../../Middleware/Contract/RouteMatchedMiddlewareContract.js';
|
|
14
|
+
import type { RouteDispatchedMiddlewareContract } from '../../../Middleware/Contract/RouteDispatchedMiddlewareContract.js';
|
|
15
|
+
import type { ThrowableCaughtMiddlewareContract } from '../../../Middleware/Contract/ThrowableCaughtMiddlewareContract.js';
|
|
16
|
+
import type { SendingResponseMiddlewareContract } from '../../../Middleware/Contract/SendingResponseMiddlewareContract.js';
|
|
17
|
+
import type { TerminatedMiddlewareContract } from '../../../Middleware/Contract/TerminatedMiddlewareContract.js';
|
|
18
|
+
import type { RequestStructContract } from '../../../Struct/Request/Contract/RequestStructContract.js';
|
|
19
|
+
import type { ResponseStructContract } from '../../../Struct/Response/Contract/ResponseStructContract.js';
|
|
20
|
+
|
|
21
|
+
export interface RouteContract {
|
|
22
|
+
getPath(): string;
|
|
23
|
+
withPath(path: string): this;
|
|
24
|
+
withAddedPath(path: string): this;
|
|
25
|
+
getName(): string;
|
|
26
|
+
withName(name: string): this;
|
|
27
|
+
withAddedName(name: string): this;
|
|
28
|
+
getHandler(): (container: ContainerContract, route: RouteContract) => ResponseContract;
|
|
29
|
+
withHandler(handler: (container: ContainerContract, route: RouteContract) => ResponseContract): this;
|
|
30
|
+
getRequestMethods(): RequestMethod[];
|
|
31
|
+
hasRequestMethod(requestMethod: RequestMethod): boolean;
|
|
32
|
+
withRequestMethods(...requestMethods: RequestMethod[]): this;
|
|
33
|
+
withAddedRequestMethods(...requestMethods: RequestMethod[]): this;
|
|
34
|
+
getRouteMatchedMiddleware(): Array<new (...args: unknown[]) => RouteMatchedMiddlewareContract>;
|
|
35
|
+
withRouteMatchedMiddleware(...middleware: Array<new (...args: unknown[]) => RouteMatchedMiddlewareContract>): this;
|
|
36
|
+
withAddedRouteMatchedMiddleware(
|
|
37
|
+
...middleware: Array<new (...args: unknown[]) => RouteMatchedMiddlewareContract>
|
|
38
|
+
): this;
|
|
39
|
+
getRouteDispatchedMiddleware(): Array<new (...args: unknown[]) => RouteDispatchedMiddlewareContract>;
|
|
40
|
+
withRouteDispatchedMiddleware(
|
|
41
|
+
...middleware: Array<new (...args: unknown[]) => RouteDispatchedMiddlewareContract>
|
|
42
|
+
): this;
|
|
43
|
+
withAddedRouteDispatchedMiddleware(
|
|
44
|
+
...middleware: Array<new (...args: unknown[]) => RouteDispatchedMiddlewareContract>
|
|
45
|
+
): this;
|
|
46
|
+
getThrowableCaughtMiddleware(): Array<new (...args: unknown[]) => ThrowableCaughtMiddlewareContract>;
|
|
47
|
+
withThrowableCaughtMiddleware(
|
|
48
|
+
...middleware: Array<new (...args: unknown[]) => ThrowableCaughtMiddlewareContract>
|
|
49
|
+
): this;
|
|
50
|
+
withAddedThrowableCaughtMiddleware(
|
|
51
|
+
...middleware: Array<new (...args: unknown[]) => ThrowableCaughtMiddlewareContract>
|
|
52
|
+
): this;
|
|
53
|
+
getSendingResponseMiddleware(): Array<new (...args: unknown[]) => SendingResponseMiddlewareContract>;
|
|
54
|
+
withSendingResponseMiddleware(
|
|
55
|
+
...middleware: Array<new (...args: unknown[]) => SendingResponseMiddlewareContract>
|
|
56
|
+
): this;
|
|
57
|
+
withAddedSendingResponseMiddleware(
|
|
58
|
+
...middleware: Array<new (...args: unknown[]) => SendingResponseMiddlewareContract>
|
|
59
|
+
): this;
|
|
60
|
+
getTerminatedMiddleware(): Array<new (...args: unknown[]) => TerminatedMiddlewareContract>;
|
|
61
|
+
withTerminatedMiddleware(...middleware: Array<new (...args: unknown[]) => TerminatedMiddlewareContract>): this;
|
|
62
|
+
withAddedTerminatedMiddleware(...middleware: Array<new (...args: unknown[]) => TerminatedMiddlewareContract>): this;
|
|
63
|
+
hasRequestStruct(): boolean;
|
|
64
|
+
getRequestStruct(): RequestStructContract;
|
|
65
|
+
withRequestStruct(requestStruct: RequestStructContract): this;
|
|
66
|
+
hasResponseStruct(): boolean;
|
|
67
|
+
getResponseStruct(): ResponseStructContract;
|
|
68
|
+
withResponseStruct(responseStruct: ResponseStructContract): this;
|
|
69
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { RequestMethod } from '../../Message/Enum/RequestMethod.js';
|
|
11
|
+
import { Route } from './Route.js';
|
|
12
|
+
|
|
13
|
+
import type { ContainerContract } from '../../../Container/Manager/Contract/ContainerContract.js';
|
|
14
|
+
import type { ResponseContract } from '../../Message/Response/Contract/ResponseContract.js';
|
|
15
|
+
import type { RouteDispatchedMiddlewareContract } from '../../Middleware/Contract/RouteDispatchedMiddlewareContract.js';
|
|
16
|
+
import type { RouteMatchedMiddlewareContract } from '../../Middleware/Contract/RouteMatchedMiddlewareContract.js';
|
|
17
|
+
import type { SendingResponseMiddlewareContract } from '../../Middleware/Contract/SendingResponseMiddlewareContract.js';
|
|
18
|
+
import type { TerminatedMiddlewareContract } from '../../Middleware/Contract/TerminatedMiddlewareContract.js';
|
|
19
|
+
import type { ThrowableCaughtMiddlewareContract } from '../../Middleware/Contract/ThrowableCaughtMiddlewareContract.js';
|
|
20
|
+
import type { RequestStructContract } from '../../Struct/Request/Contract/RequestStructContract.js';
|
|
21
|
+
import type { ResponseStructContract } from '../../Struct/Response/Contract/ResponseStructContract.js';
|
|
22
|
+
import type { DynamicRouteContract } from './Contract/DynamicRouteContract.js';
|
|
23
|
+
import type { ParameterContract } from './Contract/ParameterContract.js';
|
|
24
|
+
import type { RouteContract } from './Contract/RouteContract.js';
|
|
25
|
+
import { ObjectFactory } from '../../../Type/Object/Factory/ObjectFactory.js';
|
|
26
|
+
|
|
27
|
+
export class DynamicRoute extends Route implements DynamicRouteContract {
|
|
28
|
+
constructor(
|
|
29
|
+
path: string,
|
|
30
|
+
name: string,
|
|
31
|
+
protected regex: string,
|
|
32
|
+
protected parameters: ParameterContract[],
|
|
33
|
+
handler: (container: ContainerContract, route: RouteContract) => ResponseContract,
|
|
34
|
+
requestMethods: RequestMethod[] = [RequestMethod.HEAD, RequestMethod.GET],
|
|
35
|
+
routeMatchedMiddleware: Array<new (...args: unknown[]) => RouteMatchedMiddlewareContract> = [],
|
|
36
|
+
routeDispatchedMiddleware: Array<new (...args: unknown[]) => RouteDispatchedMiddlewareContract> = [],
|
|
37
|
+
throwableCaughtMiddleware: Array<new (...args: unknown[]) => ThrowableCaughtMiddlewareContract> = [],
|
|
38
|
+
sendingResponseMiddleware: Array<new (...args: unknown[]) => SendingResponseMiddlewareContract> = [],
|
|
39
|
+
terminatedMiddleware: Array<new (...args: unknown[]) => TerminatedMiddlewareContract> = [],
|
|
40
|
+
requestStruct: RequestStructContract | null = null,
|
|
41
|
+
responseStruct: ResponseStructContract | null = null,
|
|
42
|
+
) {
|
|
43
|
+
super(
|
|
44
|
+
path,
|
|
45
|
+
name,
|
|
46
|
+
handler,
|
|
47
|
+
requestMethods,
|
|
48
|
+
routeMatchedMiddleware,
|
|
49
|
+
routeDispatchedMiddleware,
|
|
50
|
+
throwableCaughtMiddleware,
|
|
51
|
+
sendingResponseMiddleware,
|
|
52
|
+
terminatedMiddleware,
|
|
53
|
+
requestStruct,
|
|
54
|
+
responseStruct,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getRegex(): string {
|
|
59
|
+
return this.regex;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
withRegex(regex: string): this {
|
|
63
|
+
const clone = ObjectFactory.clone(this);
|
|
64
|
+
clone.regex = regex;
|
|
65
|
+
return clone;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getParameters(): ParameterContract[] {
|
|
69
|
+
return this.parameters;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
withParameters(...parameters: ParameterContract[]): this {
|
|
73
|
+
const clone = ObjectFactory.clone(this);
|
|
74
|
+
clone.parameters = parameters;
|
|
75
|
+
return clone;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
withAddedParameters(...parameters: ParameterContract[]): this {
|
|
79
|
+
const clone = ObjectFactory.clone(this);
|
|
80
|
+
clone.parameters = [...this.parameters, ...parameters];
|
|
81
|
+
return clone;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { DynamicRouteContract } from './Contract/DynamicRouteContract.js';
|
|
11
|
+
import type { RouteContract } from './Contract/RouteContract.js';
|
|
12
|
+
|
|
13
|
+
export type RequestMethodPaths = Partial<Record<string, Record<string, string>>>;
|
|
14
|
+
|
|
15
|
+
export class HttpRoutingData {
|
|
16
|
+
constructor(
|
|
17
|
+
public readonly routes: Record<string, () => RouteContract | DynamicRouteContract> = {},
|
|
18
|
+
public readonly paths: RequestMethodPaths = {},
|
|
19
|
+
public readonly dynamicPaths: RequestMethodPaths = {},
|
|
20
|
+
public readonly regexes: RequestMethodPaths = {},
|
|
21
|
+
) {}
|
|
22
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { Cast } from '../../../Type/Data/Cast.js';
|
|
11
|
+
import { HttpRoutingNoCastException } from '../Throwable/Exception/HttpRoutingNoCastException.js';
|
|
12
|
+
|
|
13
|
+
import type { ParameterContract } from './Contract/ParameterContract.js';
|
|
14
|
+
import { ObjectFactory } from '../../../Type/Object/Factory/ObjectFactory.js';
|
|
15
|
+
|
|
16
|
+
export class Parameter implements ParameterContract {
|
|
17
|
+
constructor(
|
|
18
|
+
protected name: string,
|
|
19
|
+
protected regex: string,
|
|
20
|
+
protected cast: Cast | null = null,
|
|
21
|
+
protected optional: boolean = false,
|
|
22
|
+
protected capture: boolean = true,
|
|
23
|
+
protected defaultValue: unknown = null,
|
|
24
|
+
protected val: unknown = null,
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
getName(): string {
|
|
28
|
+
return this.name;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
withName(name: string): this {
|
|
32
|
+
const clone = ObjectFactory.clone(this);
|
|
33
|
+
clone.name = name;
|
|
34
|
+
return clone;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getRegex(): string {
|
|
38
|
+
return this.regex;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
withRegex(regex: string): this {
|
|
42
|
+
const clone = ObjectFactory.clone(this);
|
|
43
|
+
clone.regex = regex;
|
|
44
|
+
return clone;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
hasCast(): boolean {
|
|
48
|
+
return this.cast !== null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getCast(): Cast {
|
|
52
|
+
if (this.cast === null) {
|
|
53
|
+
throw new HttpRoutingNoCastException('No cast exists');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return this.cast;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
withCast(cast: Cast): this {
|
|
60
|
+
const clone = ObjectFactory.clone(this);
|
|
61
|
+
clone.cast = cast;
|
|
62
|
+
return clone;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
isOptional(): boolean {
|
|
66
|
+
return this.optional;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
withIsOptional(isOptional: boolean): this {
|
|
70
|
+
const clone = ObjectFactory.clone(this);
|
|
71
|
+
clone.optional = isOptional;
|
|
72
|
+
return clone;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
shouldCapture(): boolean {
|
|
76
|
+
return this.capture;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
withShouldCapture(shouldCapture: boolean): this {
|
|
80
|
+
const clone = ObjectFactory.clone(this);
|
|
81
|
+
clone.capture = shouldCapture;
|
|
82
|
+
return clone;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getDefault(): unknown {
|
|
86
|
+
return this.defaultValue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
withDefault(defaultValue: unknown = null): this {
|
|
90
|
+
const clone = ObjectFactory.clone(this);
|
|
91
|
+
clone.defaultValue = defaultValue;
|
|
92
|
+
return clone;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getValue(): unknown {
|
|
96
|
+
return this.val;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
withValue(value: unknown = null): this {
|
|
100
|
+
const clone = ObjectFactory.clone(this);
|
|
101
|
+
clone.val = value;
|
|
102
|
+
return clone;
|
|
103
|
+
}
|
|
104
|
+
}
|