@cratis/arc 18.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/GetHttpHeaders.ts +7 -0
- package/Globals.ts +14 -0
- package/ICanBeConfigured.ts +33 -0
- package/README.md +65 -0
- package/UrlHelpers.ts +71 -0
- package/commands/Command.ts +209 -0
- package/commands/CommandResult.ts +203 -0
- package/commands/CommandResults.ts +105 -0
- package/commands/CommandValidator.ts +17 -0
- package/commands/ICommand.ts +82 -0
- package/commands/ICommandResult.ts +60 -0
- package/commands/for_Command/CommandWithRouteParams.ts +34 -0
- package/commands/for_Command/SomeCommand.ts +34 -0
- package/commands/for_Command/given/a_command.ts +18 -0
- package/commands/for_Command/when_clearing_the_command.ts +17 -0
- package/commands/for_Command/when_executing/and_command_route_not_found.ts +26 -0
- package/commands/for_Command/when_executing/and_fetch_throws_exception.ts +24 -0
- package/commands/for_Command/when_executing/with_command_properties.ts +40 -0
- package/commands/for_Command/when_executing/with_custom_http_headers.ts +60 -0
- package/commands/for_Command/when_executing/with_microservice_header.ts +55 -0
- package/commands/for_Command/when_executing/with_origin_and_api_base_path.ts +51 -0
- package/commands/for_Command/when_executing/with_route_parameters.ts +58 -0
- package/commands/for_Command/when_executing/with_successful_response.ts +51 -0
- package/commands/for_Command/when_property_changed_value_that_is_different_from_initial_value.ts +16 -0
- package/commands/for_Command/when_property_changed_value_that_is_same_as_initial_value.ts +16 -0
- package/commands/for_Command/when_property_changes_and_initial_value_is_undefined.ts +12 -0
- package/commands/for_Command/when_property_changes_and_there_is_a_callback.ts +15 -0
- package/commands/for_Command/when_property_has_changed_and_we_revert.ts +15 -0
- package/commands/for_Command/when_setting_initial_values_after_property_changed.ts +17 -0
- package/commands/for_Command/when_validating/and_fetch_throws_exception.ts +24 -0
- package/commands/for_Command/when_validating/and_validation_endpoint_not_found.ts +26 -0
- package/commands/for_Command/when_validating/does_not_update_initial_values.ts +39 -0
- package/commands/for_Command/when_validating/with_successful_response.ts +47 -0
- package/commands/for_Command/when_validating/with_validation_errors.ts +45 -0
- package/commands/for_CommandResult/when_chaining_callbacks/and_result_has_exceptions.ts +54 -0
- package/commands/for_CommandResult/when_chaining_callbacks/and_result_is_invalid.ts +53 -0
- package/commands/for_CommandResult/when_chaining_callbacks/and_result_is_successful.ts +42 -0
- package/commands/for_CommandResult/when_chaining_callbacks/and_result_is_unauthorized.ts +43 -0
- package/commands/index.ts +9 -0
- package/deepEqual.ts +23 -0
- package/dist/cjs/GetHttpHeaders.d.ts +2 -0
- package/dist/cjs/GetHttpHeaders.d.ts.map +1 -0
- package/dist/cjs/Globals.d.ts +7 -0
- package/dist/cjs/Globals.d.ts.map +1 -0
- package/dist/cjs/Globals.js +10 -0
- package/dist/cjs/Globals.js.map +1 -0
- package/dist/cjs/ICanBeConfigured.d.ts +8 -0
- package/dist/cjs/ICanBeConfigured.d.ts.map +1 -0
- package/dist/cjs/UrlHelpers.d.ts +9 -0
- package/dist/cjs/UrlHelpers.d.ts.map +1 -0
- package/dist/cjs/UrlHelpers.js +43 -0
- package/dist/cjs/UrlHelpers.js.map +1 -0
- package/dist/cjs/commands/Command.d.ts +41 -0
- package/dist/cjs/commands/Command.d.ts.map +1 -0
- package/dist/cjs/commands/Command.js +151 -0
- package/dist/cjs/commands/Command.js.map +1 -0
- package/dist/cjs/commands/CommandResult.d.ts +48 -0
- package/dist/cjs/commands/CommandResult.d.ts.map +1 -0
- package/dist/cjs/commands/CommandResult.js +95 -0
- package/dist/cjs/commands/CommandResult.js.map +1 -0
- package/dist/cjs/commands/CommandResults.d.ts +23 -0
- package/dist/cjs/commands/CommandResults.d.ts.map +1 -0
- package/dist/cjs/commands/CommandResults.js +72 -0
- package/dist/cjs/commands/CommandResults.js.map +1 -0
- package/dist/cjs/commands/CommandValidator.d.ts +9 -0
- package/dist/cjs/commands/CommandValidator.d.ts.map +1 -0
- package/dist/cjs/commands/CommandValidator.js +10 -0
- package/dist/cjs/commands/CommandValidator.js.map +1 -0
- package/dist/cjs/commands/ICommand.d.ts +18 -0
- package/dist/cjs/commands/ICommand.d.ts.map +1 -0
- package/dist/cjs/commands/ICommandResult.d.ts +15 -0
- package/dist/cjs/commands/ICommandResult.d.ts.map +1 -0
- package/dist/cjs/commands/index.d.ts +7 -0
- package/dist/cjs/commands/index.d.ts.map +1 -0
- package/dist/cjs/commands/index.js +14 -0
- package/dist/cjs/commands/index.js.map +1 -0
- package/dist/cjs/deepEqual.d.ts +2 -0
- package/dist/cjs/deepEqual.d.ts.map +1 -0
- package/dist/cjs/deepEqual.js +22 -0
- package/dist/cjs/deepEqual.js.map +1 -0
- package/dist/cjs/given.d.ts +5 -0
- package/dist/cjs/given.d.ts.map +1 -0
- package/dist/cjs/identity/IIdentity.d.ts +8 -0
- package/dist/cjs/identity/IIdentity.d.ts.map +1 -0
- package/dist/cjs/identity/IIdentityProvider.d.ts +5 -0
- package/dist/cjs/identity/IIdentityProvider.d.ts.map +1 -0
- package/dist/cjs/identity/IIdentityProvider.js +7 -0
- package/dist/cjs/identity/IIdentityProvider.js.map +1 -0
- package/dist/cjs/identity/IdentityProvider.d.ts +14 -0
- package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -0
- package/dist/cjs/identity/IdentityProvider.js +63 -0
- package/dist/cjs/identity/IdentityProvider.js.map +1 -0
- package/dist/cjs/identity/IdentityProviderResult.d.ts +6 -0
- package/dist/cjs/identity/IdentityProviderResult.d.ts.map +1 -0
- package/dist/cjs/identity/index.d.ts +5 -0
- package/dist/cjs/identity/index.d.ts.map +1 -0
- package/dist/cjs/identity/index.js +10 -0
- package/dist/cjs/identity/index.js.map +1 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/joinPaths.d.ts +2 -0
- package/dist/cjs/joinPaths.d.ts.map +1 -0
- package/dist/cjs/joinPaths.js +9 -0
- package/dist/cjs/joinPaths.js.map +1 -0
- package/dist/cjs/queries/IObservableQueryConnection.d.ts +6 -0
- package/dist/cjs/queries/IObservableQueryConnection.d.ts.map +1 -0
- package/dist/cjs/queries/IObservableQueryFor.d.ts +13 -0
- package/dist/cjs/queries/IObservableQueryFor.d.ts.map +1 -0
- package/dist/cjs/queries/IQuery.d.ts +10 -0
- package/dist/cjs/queries/IQuery.d.ts.map +1 -0
- package/dist/cjs/queries/IQueryFor.d.ts +12 -0
- package/dist/cjs/queries/IQueryFor.d.ts.map +1 -0
- package/dist/cjs/queries/IQueryProvider.d.ts +6 -0
- package/dist/cjs/queries/IQueryProvider.d.ts.map +1 -0
- package/dist/cjs/queries/IQueryProvider.js +7 -0
- package/dist/cjs/queries/IQueryProvider.js.map +1 -0
- package/dist/cjs/queries/IQueryResult.d.ts +15 -0
- package/dist/cjs/queries/IQueryResult.d.ts.map +1 -0
- package/dist/cjs/queries/NullObservableQueryConnection.d.ts +9 -0
- package/dist/cjs/queries/NullObservableQueryConnection.d.ts.map +1 -0
- package/dist/cjs/queries/NullObservableQueryConnection.js +18 -0
- package/dist/cjs/queries/NullObservableQueryConnection.js.map +1 -0
- package/dist/cjs/queries/ObservableQueryConnection.d.ts +14 -0
- package/dist/cjs/queries/ObservableQueryConnection.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQueryConnection.js +101 -0
- package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -0
- package/dist/cjs/queries/ObservableQueryFor.d.ts +37 -0
- package/dist/cjs/queries/ObservableQueryFor.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQueryFor.js +176 -0
- package/dist/cjs/queries/ObservableQueryFor.js.map +1 -0
- package/dist/cjs/queries/ObservableQuerySubscription.d.ts +7 -0
- package/dist/cjs/queries/ObservableQuerySubscription.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQuerySubscription.js +17 -0
- package/dist/cjs/queries/ObservableQuerySubscription.js.map +1 -0
- package/dist/cjs/queries/Paging.d.ts +8 -0
- package/dist/cjs/queries/Paging.d.ts.map +1 -0
- package/dist/cjs/queries/Paging.js +17 -0
- package/dist/cjs/queries/Paging.js.map +1 -0
- package/dist/cjs/queries/PagingInfo.d.ts +9 -0
- package/dist/cjs/queries/PagingInfo.d.ts.map +1 -0
- package/dist/cjs/queries/PagingInfo.js +18 -0
- package/dist/cjs/queries/PagingInfo.js.map +1 -0
- package/dist/cjs/queries/QueryFor.d.ts +30 -0
- package/dist/cjs/queries/QueryFor.d.ts.map +1 -0
- package/dist/cjs/queries/QueryFor.js +101 -0
- package/dist/cjs/queries/QueryFor.js.map +1 -0
- package/dist/cjs/queries/QueryProvider.d.ts +13 -0
- package/dist/cjs/queries/QueryProvider.d.ts.map +1 -0
- package/dist/cjs/queries/QueryProvider.js +25 -0
- package/dist/cjs/queries/QueryProvider.js.map +1 -0
- package/dist/cjs/queries/QueryResult.d.ts +44 -0
- package/dist/cjs/queries/QueryResult.d.ts.map +1 -0
- package/dist/cjs/queries/QueryResult.js +95 -0
- package/dist/cjs/queries/QueryResult.js.map +1 -0
- package/dist/cjs/queries/QueryResultWithState.d.ts +22 -0
- package/dist/cjs/queries/QueryResultWithState.d.ts.map +1 -0
- package/dist/cjs/queries/QueryResultWithState.js +46 -0
- package/dist/cjs/queries/QueryResultWithState.js.map +1 -0
- package/dist/cjs/queries/SortDirection.d.ts +6 -0
- package/dist/cjs/queries/SortDirection.d.ts.map +1 -0
- package/dist/cjs/queries/SortDirection.js +9 -0
- package/dist/cjs/queries/SortDirection.js.map +1 -0
- package/dist/cjs/queries/Sorting.d.ts +9 -0
- package/dist/cjs/queries/Sorting.d.ts.map +1 -0
- package/dist/cjs/queries/Sorting.js +19 -0
- package/dist/cjs/queries/Sorting.js.map +1 -0
- package/dist/cjs/queries/SortingActions.d.ts +10 -0
- package/dist/cjs/queries/SortingActions.d.ts.map +1 -0
- package/dist/cjs/queries/SortingActions.js +24 -0
- package/dist/cjs/queries/SortingActions.js.map +1 -0
- package/dist/cjs/queries/SortingActionsForObservableQuery.d.ts +10 -0
- package/dist/cjs/queries/SortingActionsForObservableQuery.d.ts.map +1 -0
- package/dist/cjs/queries/SortingActionsForObservableQuery.js +24 -0
- package/dist/cjs/queries/SortingActionsForObservableQuery.js.map +1 -0
- package/dist/cjs/queries/SortingActionsForQuery.d.ts +10 -0
- package/dist/cjs/queries/SortingActionsForQuery.d.ts.map +1 -0
- package/dist/cjs/queries/SortingActionsForQuery.js +24 -0
- package/dist/cjs/queries/SortingActionsForQuery.js.map +1 -0
- package/dist/cjs/queries/ValidateRequestArguments.d.ts +2 -0
- package/dist/cjs/queries/ValidateRequestArguments.d.ts.map +1 -0
- package/dist/cjs/queries/ValidateRequestArguments.js +29 -0
- package/dist/cjs/queries/ValidateRequestArguments.js.map +1 -0
- package/dist/cjs/queries/index.d.ts +19 -0
- package/dist/cjs/queries/index.d.ts.map +1 -0
- package/dist/cjs/queries/index.js +37 -0
- package/dist/cjs/queries/index.js.map +1 -0
- package/dist/cjs/reflection/IHaveParameters.d.ts +5 -0
- package/dist/cjs/reflection/IHaveParameters.d.ts.map +1 -0
- package/dist/cjs/reflection/ParameterDescriptor.d.ts +7 -0
- package/dist/cjs/reflection/ParameterDescriptor.d.ts.map +1 -0
- package/dist/cjs/reflection/ParameterDescriptor.js +13 -0
- package/dist/cjs/reflection/ParameterDescriptor.js.map +1 -0
- package/dist/cjs/reflection/ParametersHelper.d.ts +5 -0
- package/dist/cjs/reflection/ParametersHelper.d.ts.map +1 -0
- package/dist/cjs/reflection/ParametersHelper.js +17 -0
- package/dist/cjs/reflection/ParametersHelper.js.map +1 -0
- package/dist/cjs/reflection/PropertyDescriptor.d.ts +7 -0
- package/dist/cjs/reflection/PropertyDescriptor.d.ts.map +1 -0
- package/dist/cjs/reflection/PropertyDescriptor.js +13 -0
- package/dist/cjs/reflection/PropertyDescriptor.js.map +1 -0
- package/dist/cjs/reflection/index.d.ts +5 -0
- package/dist/cjs/reflection/index.d.ts.map +1 -0
- package/dist/cjs/reflection/index.js +12 -0
- package/dist/cjs/reflection/index.js.map +1 -0
- package/dist/cjs/validation/ValidationResult.d.ts +9 -0
- package/dist/cjs/validation/ValidationResult.d.ts.map +1 -0
- package/dist/cjs/validation/ValidationResult.js +17 -0
- package/dist/cjs/validation/ValidationResult.js.map +1 -0
- package/dist/cjs/validation/ValidationResultSeverity.d.ts +7 -0
- package/dist/cjs/validation/ValidationResultSeverity.d.ts.map +1 -0
- package/dist/cjs/validation/Validator.d.ts +4 -0
- package/dist/cjs/validation/Validator.d.ts.map +1 -0
- package/dist/cjs/validation/Validator.js +10 -0
- package/dist/cjs/validation/Validator.js.map +1 -0
- package/dist/cjs/validation/index.d.ts +3 -0
- package/dist/cjs/validation/index.d.ts.map +1 -0
- package/dist/cjs/validation/index.js +10 -0
- package/dist/cjs/validation/index.js.map +1 -0
- package/dist/esm/GetHttpHeaders.d.ts +2 -0
- package/dist/esm/GetHttpHeaders.d.ts.map +1 -0
- package/dist/esm/GetHttpHeaders.js +2 -0
- package/dist/esm/GetHttpHeaders.js.map +1 -0
- package/dist/esm/Globals.d.ts +7 -0
- package/dist/esm/Globals.d.ts.map +1 -0
- package/dist/esm/Globals.js +8 -0
- package/dist/esm/Globals.js.map +1 -0
- package/dist/esm/ICanBeConfigured.d.ts +8 -0
- package/dist/esm/ICanBeConfigured.d.ts.map +1 -0
- package/dist/esm/ICanBeConfigured.js +2 -0
- package/dist/esm/ICanBeConfigured.js.map +1 -0
- package/dist/esm/UrlHelpers.d.ts +9 -0
- package/dist/esm/UrlHelpers.d.ts.map +1 -0
- package/dist/esm/UrlHelpers.js +41 -0
- package/dist/esm/UrlHelpers.js.map +1 -0
- package/dist/esm/commands/Command.d.ts +41 -0
- package/dist/esm/commands/Command.d.ts.map +1 -0
- package/dist/esm/commands/Command.js +149 -0
- package/dist/esm/commands/Command.js.map +1 -0
- package/dist/esm/commands/CommandResult.d.ts +48 -0
- package/dist/esm/commands/CommandResult.d.ts.map +1 -0
- package/dist/esm/commands/CommandResult.js +93 -0
- package/dist/esm/commands/CommandResult.js.map +1 -0
- package/dist/esm/commands/CommandResults.d.ts +23 -0
- package/dist/esm/commands/CommandResults.d.ts.map +1 -0
- package/dist/esm/commands/CommandResults.js +70 -0
- package/dist/esm/commands/CommandResults.js.map +1 -0
- package/dist/esm/commands/CommandValidator.d.ts +9 -0
- package/dist/esm/commands/CommandValidator.d.ts.map +1 -0
- package/dist/esm/commands/CommandValidator.js +8 -0
- package/dist/esm/commands/CommandValidator.js.map +1 -0
- package/dist/esm/commands/ICommand.d.ts +18 -0
- package/dist/esm/commands/ICommand.d.ts.map +1 -0
- package/dist/esm/commands/ICommand.js +2 -0
- package/dist/esm/commands/ICommand.js.map +1 -0
- package/dist/esm/commands/ICommandResult.d.ts +15 -0
- package/dist/esm/commands/ICommandResult.d.ts.map +1 -0
- package/dist/esm/commands/ICommandResult.js +2 -0
- package/dist/esm/commands/ICommandResult.js.map +1 -0
- package/dist/esm/commands/index.d.ts +7 -0
- package/dist/esm/commands/index.d.ts.map +1 -0
- package/dist/esm/commands/index.js +5 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/deepEqual.d.ts +2 -0
- package/dist/esm/deepEqual.d.ts.map +1 -0
- package/dist/esm/deepEqual.js +20 -0
- package/dist/esm/deepEqual.js.map +1 -0
- package/dist/esm/given.d.ts +5 -0
- package/dist/esm/given.d.ts.map +1 -0
- package/dist/esm/given.js +7 -0
- package/dist/esm/given.js.map +1 -0
- package/dist/esm/identity/IIdentity.d.ts +8 -0
- package/dist/esm/identity/IIdentity.d.ts.map +1 -0
- package/dist/esm/identity/IIdentity.js +2 -0
- package/dist/esm/identity/IIdentity.js.map +1 -0
- package/dist/esm/identity/IIdentityProvider.d.ts +5 -0
- package/dist/esm/identity/IIdentityProvider.d.ts.map +1 -0
- package/dist/esm/identity/IIdentityProvider.js +5 -0
- package/dist/esm/identity/IIdentityProvider.js.map +1 -0
- package/dist/esm/identity/IdentityProvider.d.ts +14 -0
- package/dist/esm/identity/IdentityProvider.d.ts.map +1 -0
- package/dist/esm/identity/IdentityProvider.js +61 -0
- package/dist/esm/identity/IdentityProvider.js.map +1 -0
- package/dist/esm/identity/IdentityProviderResult.d.ts +6 -0
- package/dist/esm/identity/IdentityProviderResult.d.ts.map +1 -0
- package/dist/esm/identity/IdentityProviderResult.js +2 -0
- package/dist/esm/identity/IdentityProviderResult.js.map +1 -0
- package/dist/esm/identity/index.d.ts +5 -0
- package/dist/esm/identity/index.d.ts.map +1 -0
- package/dist/esm/identity/index.js +3 -0
- package/dist/esm/identity/index.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/joinPaths.d.ts +2 -0
- package/dist/esm/joinPaths.d.ts.map +1 -0
- package/dist/esm/joinPaths.js +7 -0
- package/dist/esm/joinPaths.js.map +1 -0
- package/dist/esm/queries/IObservableQueryConnection.d.ts +6 -0
- package/dist/esm/queries/IObservableQueryConnection.d.ts.map +1 -0
- package/dist/esm/queries/IObservableQueryConnection.js +2 -0
- package/dist/esm/queries/IObservableQueryConnection.js.map +1 -0
- package/dist/esm/queries/IObservableQueryFor.d.ts +13 -0
- package/dist/esm/queries/IObservableQueryFor.d.ts.map +1 -0
- package/dist/esm/queries/IObservableQueryFor.js +2 -0
- package/dist/esm/queries/IObservableQueryFor.js.map +1 -0
- package/dist/esm/queries/IQuery.d.ts +10 -0
- package/dist/esm/queries/IQuery.d.ts.map +1 -0
- package/dist/esm/queries/IQuery.js +2 -0
- package/dist/esm/queries/IQuery.js.map +1 -0
- package/dist/esm/queries/IQueryFor.d.ts +12 -0
- package/dist/esm/queries/IQueryFor.d.ts.map +1 -0
- package/dist/esm/queries/IQueryFor.js +2 -0
- package/dist/esm/queries/IQueryFor.js.map +1 -0
- package/dist/esm/queries/IQueryProvider.d.ts +6 -0
- package/dist/esm/queries/IQueryProvider.d.ts.map +1 -0
- package/dist/esm/queries/IQueryProvider.js +5 -0
- package/dist/esm/queries/IQueryProvider.js.map +1 -0
- package/dist/esm/queries/IQueryResult.d.ts +15 -0
- package/dist/esm/queries/IQueryResult.d.ts.map +1 -0
- package/dist/esm/queries/IQueryResult.js +2 -0
- package/dist/esm/queries/IQueryResult.js.map +1 -0
- package/dist/esm/queries/NullObservableQueryConnection.d.ts +9 -0
- package/dist/esm/queries/NullObservableQueryConnection.d.ts.map +1 -0
- package/dist/esm/queries/NullObservableQueryConnection.js +16 -0
- package/dist/esm/queries/NullObservableQueryConnection.js.map +1 -0
- package/dist/esm/queries/ObservableQueryConnection.d.ts +14 -0
- package/dist/esm/queries/ObservableQueryConnection.d.ts.map +1 -0
- package/dist/esm/queries/ObservableQueryConnection.js +99 -0
- package/dist/esm/queries/ObservableQueryConnection.js.map +1 -0
- package/dist/esm/queries/ObservableQueryFor.d.ts +37 -0
- package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -0
- package/dist/esm/queries/ObservableQueryFor.js +174 -0
- package/dist/esm/queries/ObservableQueryFor.js.map +1 -0
- package/dist/esm/queries/ObservableQuerySubscription.d.ts +7 -0
- package/dist/esm/queries/ObservableQuerySubscription.d.ts.map +1 -0
- package/dist/esm/queries/ObservableQuerySubscription.js +15 -0
- package/dist/esm/queries/ObservableQuerySubscription.js.map +1 -0
- package/dist/esm/queries/Paging.d.ts +8 -0
- package/dist/esm/queries/Paging.d.ts.map +1 -0
- package/dist/esm/queries/Paging.js +15 -0
- package/dist/esm/queries/Paging.js.map +1 -0
- package/dist/esm/queries/PagingInfo.d.ts +9 -0
- package/dist/esm/queries/PagingInfo.d.ts.map +1 -0
- package/dist/esm/queries/PagingInfo.js +16 -0
- package/dist/esm/queries/PagingInfo.js.map +1 -0
- package/dist/esm/queries/QueryFor.d.ts +30 -0
- package/dist/esm/queries/QueryFor.d.ts.map +1 -0
- package/dist/esm/queries/QueryFor.js +99 -0
- package/dist/esm/queries/QueryFor.js.map +1 -0
- package/dist/esm/queries/QueryProvider.d.ts +13 -0
- package/dist/esm/queries/QueryProvider.d.ts.map +1 -0
- package/dist/esm/queries/QueryProvider.js +23 -0
- package/dist/esm/queries/QueryProvider.js.map +1 -0
- package/dist/esm/queries/QueryResult.d.ts +44 -0
- package/dist/esm/queries/QueryResult.d.ts.map +1 -0
- package/dist/esm/queries/QueryResult.js +93 -0
- package/dist/esm/queries/QueryResult.js.map +1 -0
- package/dist/esm/queries/QueryResultWithState.d.ts +22 -0
- package/dist/esm/queries/QueryResultWithState.d.ts.map +1 -0
- package/dist/esm/queries/QueryResultWithState.js +44 -0
- package/dist/esm/queries/QueryResultWithState.js.map +1 -0
- package/dist/esm/queries/SortDirection.d.ts +6 -0
- package/dist/esm/queries/SortDirection.d.ts.map +1 -0
- package/dist/esm/queries/SortDirection.js +9 -0
- package/dist/esm/queries/SortDirection.js.map +1 -0
- package/dist/esm/queries/Sorting.d.ts +9 -0
- package/dist/esm/queries/Sorting.d.ts.map +1 -0
- package/dist/esm/queries/Sorting.js +17 -0
- package/dist/esm/queries/Sorting.js.map +1 -0
- package/dist/esm/queries/SortingActions.d.ts +10 -0
- package/dist/esm/queries/SortingActions.d.ts.map +1 -0
- package/dist/esm/queries/SortingActions.js +22 -0
- package/dist/esm/queries/SortingActions.js.map +1 -0
- package/dist/esm/queries/SortingActionsForObservableQuery.d.ts +10 -0
- package/dist/esm/queries/SortingActionsForObservableQuery.d.ts.map +1 -0
- package/dist/esm/queries/SortingActionsForObservableQuery.js +22 -0
- package/dist/esm/queries/SortingActionsForObservableQuery.js.map +1 -0
- package/dist/esm/queries/SortingActionsForQuery.d.ts +10 -0
- package/dist/esm/queries/SortingActionsForQuery.d.ts.map +1 -0
- package/dist/esm/queries/SortingActionsForQuery.js +22 -0
- package/dist/esm/queries/SortingActionsForQuery.js.map +1 -0
- package/dist/esm/queries/ValidateRequestArguments.d.ts +2 -0
- package/dist/esm/queries/ValidateRequestArguments.d.ts.map +1 -0
- package/dist/esm/queries/ValidateRequestArguments.js +27 -0
- package/dist/esm/queries/ValidateRequestArguments.js.map +1 -0
- package/dist/esm/queries/index.d.ts +19 -0
- package/dist/esm/queries/index.d.ts.map +1 -0
- package/dist/esm/queries/index.js +15 -0
- package/dist/esm/queries/index.js.map +1 -0
- package/dist/esm/reflection/IHaveParameters.d.ts +5 -0
- package/dist/esm/reflection/IHaveParameters.d.ts.map +1 -0
- package/dist/esm/reflection/IHaveParameters.js +2 -0
- package/dist/esm/reflection/IHaveParameters.js.map +1 -0
- package/dist/esm/reflection/ParameterDescriptor.d.ts +7 -0
- package/dist/esm/reflection/ParameterDescriptor.d.ts.map +1 -0
- package/dist/esm/reflection/ParameterDescriptor.js +11 -0
- package/dist/esm/reflection/ParameterDescriptor.js.map +1 -0
- package/dist/esm/reflection/ParametersHelper.d.ts +5 -0
- package/dist/esm/reflection/ParametersHelper.d.ts.map +1 -0
- package/dist/esm/reflection/ParametersHelper.js +15 -0
- package/dist/esm/reflection/ParametersHelper.js.map +1 -0
- package/dist/esm/reflection/PropertyDescriptor.d.ts +7 -0
- package/dist/esm/reflection/PropertyDescriptor.d.ts.map +1 -0
- package/dist/esm/reflection/PropertyDescriptor.js +11 -0
- package/dist/esm/reflection/PropertyDescriptor.js.map +1 -0
- package/dist/esm/reflection/index.d.ts +5 -0
- package/dist/esm/reflection/index.d.ts.map +1 -0
- package/dist/esm/reflection/index.js +4 -0
- package/dist/esm/reflection/index.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/validation/ValidationResult.d.ts +9 -0
- package/dist/esm/validation/ValidationResult.d.ts.map +1 -0
- package/dist/esm/validation/ValidationResult.js +15 -0
- package/dist/esm/validation/ValidationResult.js.map +1 -0
- package/dist/esm/validation/ValidationResultSeverity.d.ts +7 -0
- package/dist/esm/validation/ValidationResultSeverity.d.ts.map +1 -0
- package/dist/esm/validation/ValidationResultSeverity.js +8 -0
- package/dist/esm/validation/ValidationResultSeverity.js.map +1 -0
- package/dist/esm/validation/Validator.d.ts +4 -0
- package/dist/esm/validation/Validator.d.ts.map +1 -0
- package/dist/esm/validation/Validator.js +8 -0
- package/dist/esm/validation/Validator.js.map +1 -0
- package/dist/esm/validation/index.d.ts +3 -0
- package/dist/esm/validation/index.d.ts.map +1 -0
- package/dist/esm/validation/index.js +3 -0
- package/dist/esm/validation/index.js.map +1 -0
- package/for_UrlHelpers/when_building_query_params/with_additional_parameters.ts +23 -0
- package/for_UrlHelpers/when_building_query_params/with_empty_parameters.ts +16 -0
- package/for_UrlHelpers/when_building_query_params/with_null_and_undefined_values.ts +22 -0
- package/for_UrlHelpers/when_building_query_params/with_unused_parameters_only.ts +21 -0
- package/for_UrlHelpers/when_creating_url_from/with_base_path_ending_with_slash.ts +32 -0
- package/for_UrlHelpers/when_creating_url_from/with_empty_origin.ts +45 -0
- package/for_UrlHelpers/when_creating_url_from/with_null_or_undefined_origin.ts +53 -0
- package/for_UrlHelpers/when_creating_url_from/with_relative_route.ts +32 -0
- package/for_UrlHelpers/when_creating_url_from/with_valid_parameters.ts +32 -0
- package/for_UrlHelpers/when_creating_url_from/without_document_object.ts +34 -0
- package/for_UrlHelpers/when_replacing_route_parameters/with_all_parameters_used_in_route.ts +21 -0
- package/for_UrlHelpers/when_replacing_route_parameters/with_no_parameters.ts +19 -0
- package/for_UrlHelpers/when_replacing_route_parameters/with_unused_parameters.ts +23 -0
- package/for_UrlHelpers/when_replacing_route_parameters/with_url_encoded_values.ts +20 -0
- package/given.ts +14 -0
- package/identity/IIdentity.ts +33 -0
- package/identity/IIdentityProvider.ts +16 -0
- package/identity/IdentityProvider.ts +85 -0
- package/identity/IdentityProviderResult.ts +8 -0
- package/identity/index.ts +7 -0
- package/index.ts +21 -0
- package/joinPaths.ts +7 -0
- package/package.json +70 -0
- package/queries/IObservableQueryConnection.ts +21 -0
- package/queries/IObservableQueryFor.ts +38 -0
- package/queries/IQuery.ts +31 -0
- package/queries/IQueryFor.ts +36 -0
- package/queries/IQueryProvider.ts +17 -0
- package/queries/IQueryResult.ts +60 -0
- package/queries/NullObservableQueryConnection.ts +29 -0
- package/queries/ObservableQueryConnection.ts +118 -0
- package/queries/ObservableQueryFor.ts +230 -0
- package/queries/ObservableQuerySubscription.ts +27 -0
- package/queries/Paging.ts +38 -0
- package/queries/PagingInfo.ts +43 -0
- package/queries/QueryFor.ts +138 -0
- package/queries/QueryProvider.ts +36 -0
- package/queries/QueryResult.ts +157 -0
- package/queries/QueryResultWithState.ts +95 -0
- package/queries/SortDirection.ts +22 -0
- package/queries/Sorting.ts +30 -0
- package/queries/SortingActions.ts +36 -0
- package/queries/SortingActionsForObservableQuery.ts +36 -0
- package/queries/SortingActionsForQuery.ts +36 -0
- package/queries/ValidateRequestArguments.ts +36 -0
- package/queries/for_ObservableQueryFor/given/TestQueries.ts +58 -0
- package/queries/for_ObservableQueryFor/given/an_observable_query_for.ts +16 -0
- package/queries/for_ObservableQueryFor/when_constructing.ts +32 -0
- package/queries/for_ObservableQueryFor/when_constructing_enumerable.ts +18 -0
- package/queries/for_ObservableQueryFor/when_disposing.ts +28 -0
- package/queries/for_ObservableQueryFor/when_performing/with_enumerable_query.ts +61 -0
- package/queries/for_ObservableQueryFor/when_performing/with_invalid_arguments.ts +22 -0
- package/queries/for_ObservableQueryFor/when_performing/with_paging.ts +55 -0
- package/queries/for_ObservableQueryFor/when_performing/with_parameter_descriptor_values.ts +68 -0
- package/queries/for_ObservableQueryFor/when_performing/with_partial_parameter_descriptor_values.ts +67 -0
- package/queries/for_ObservableQueryFor/when_performing/with_route_parameters_and_unused_parameters.ts +71 -0
- package/queries/for_ObservableQueryFor/when_performing/with_sorting.ts +56 -0
- package/queries/for_ObservableQueryFor/when_performing/with_valid_arguments.ts +79 -0
- package/queries/for_ObservableQueryFor/when_setting_api_base_path.ts +17 -0
- package/queries/for_ObservableQueryFor/when_setting_microservice.ts +17 -0
- package/queries/for_ObservableQueryFor/when_setting_origin.ts +17 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_enumerable_query.ts +34 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_invalid_arguments.ts +40 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_paging.ts +36 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_sorting.ts +37 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_valid_arguments.ts +35 -0
- package/queries/for_QueryFor/given/TestQueries.ts +72 -0
- package/queries/for_QueryFor/given/a_query_for.ts +18 -0
- package/queries/for_QueryFor/when_constructing.ts +31 -0
- package/queries/for_QueryFor/when_constructing_enumerable.ts +17 -0
- package/queries/for_QueryFor/when_performing/with_abort_controller.ts +71 -0
- package/queries/for_QueryFor/when_performing/with_enumerable_query.ts +62 -0
- package/queries/for_QueryFor/when_performing/with_fetch_error.ts +47 -0
- package/queries/for_QueryFor/when_performing/with_invalid_arguments.ts +29 -0
- package/queries/for_QueryFor/when_performing/with_json_parse_error.ts +45 -0
- package/queries/for_QueryFor/when_performing/with_paging.ts +62 -0
- package/queries/for_QueryFor/when_performing/with_parameter_descriptor_values.ts +68 -0
- package/queries/for_QueryFor/when_performing/with_partial_parameter_descriptor_values.ts +67 -0
- package/queries/for_QueryFor/when_performing/with_query_without_required_parameters.ts +58 -0
- package/queries/for_QueryFor/when_performing/with_route_parameters_and_unused_parameters.ts +71 -0
- package/queries/for_QueryFor/when_performing/with_sorting.ts +99 -0
- package/queries/for_QueryFor/when_performing/with_valid_arguments.ts +87 -0
- package/queries/for_QueryFor/when_setting_api_base_path.ts +19 -0
- package/queries/for_QueryFor/when_setting_microservice.ts +19 -0
- package/queries/for_QueryFor/when_setting_origin.ts +19 -0
- package/queries/for_QueryResult/when_asking_has_data/and_it_an_array_with_items.ts +27 -0
- package/queries/for_QueryResult/when_asking_has_data/and_it_is_defined_instance.ts +27 -0
- package/queries/for_QueryResult/when_asking_has_data/and_it_is_empty_array.ts +27 -0
- package/queries/for_QueryResult/when_asking_has_data/and_it_is_undefined.ts +27 -0
- package/queries/index.ts +21 -0
- package/reflection/IHaveParameters.ts +11 -0
- package/reflection/ParameterDescriptor.ts +17 -0
- package/reflection/ParametersHelper.ts +25 -0
- package/reflection/PropertyDescriptor.ts +17 -0
- package/reflection/index.ts +7 -0
- package/validation/ValidationResult.ts +16 -0
- package/validation/ValidationResultSeverity.ts +28 -0
- package/validation/Validator.ts +15 -0
- package/validation/index.ts +5 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { CommandWithRouteParams } from '../CommandWithRouteParams';
|
|
6
|
+
import { given } from '../../../given';
|
|
7
|
+
|
|
8
|
+
describe("when executing with route parameters", given(class {
|
|
9
|
+
command: CommandWithRouteParams;
|
|
10
|
+
fetchStub: sinon.SinonStub;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
this.command = new CommandWithRouteParams();
|
|
14
|
+
this.command.setOrigin('http://localhost');
|
|
15
|
+
this.command.setApiBasePath('/api');
|
|
16
|
+
this.command.id = '123';
|
|
17
|
+
this.command.name = 'Test Item';
|
|
18
|
+
this.fetchStub = sinon.stub(globalThis, 'fetch');
|
|
19
|
+
}
|
|
20
|
+
}, context => {
|
|
21
|
+
const responseData = {
|
|
22
|
+
correlationId: '12345678-1234-1234-1234-123456789012',
|
|
23
|
+
isSuccess: true,
|
|
24
|
+
isAuthorized: true,
|
|
25
|
+
isValid: true,
|
|
26
|
+
hasExceptions: false,
|
|
27
|
+
validationResults: [],
|
|
28
|
+
exceptionMessages: [],
|
|
29
|
+
exceptionStackTrace: '',
|
|
30
|
+
response: {}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
context.fetchStub.resolves({
|
|
35
|
+
status: 200,
|
|
36
|
+
json: async () => responseData
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await context.command.execute();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
context.fetchStub.restore();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should_replace_route_parameters_in_url", () => {
|
|
47
|
+
const call = context.fetchStub.getCall(0);
|
|
48
|
+
const url = call.args[0];
|
|
49
|
+
url.toString().should.contain('/api/items/123');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should_include_all_properties_in_body", () => {
|
|
53
|
+
const call = context.fetchStub.getCall(0);
|
|
54
|
+
const body = JSON.parse(call.args[1].body);
|
|
55
|
+
body.id.should.equal('123');
|
|
56
|
+
body.name.should.equal('Test Item');
|
|
57
|
+
});
|
|
58
|
+
}));
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_command } from '../given/a_command';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { CommandResult } from '../../CommandResult';
|
|
7
|
+
|
|
8
|
+
describe("when executing with successful response", given(a_command, context => {
|
|
9
|
+
let result: CommandResult<object>;
|
|
10
|
+
const responseData = {
|
|
11
|
+
correlationId: '12345678-1234-1234-1234-123456789012',
|
|
12
|
+
isSuccess: true,
|
|
13
|
+
isAuthorized: true,
|
|
14
|
+
isValid: true,
|
|
15
|
+
hasExceptions: false,
|
|
16
|
+
validationResults: [],
|
|
17
|
+
exceptionMessages: [],
|
|
18
|
+
exceptionStackTrace: '',
|
|
19
|
+
response: { data: 'test' }
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
context.fetchStub.resolves({
|
|
24
|
+
status: 200,
|
|
25
|
+
json: async () => responseData
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
result = await context.command.execute();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
context.fetchStub.restore();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should_call_fetch_with_correct_url", () => context.fetchStub.calledOnce.should.be.true);
|
|
36
|
+
|
|
37
|
+
it("should_call_fetch_with_post_method", () => {
|
|
38
|
+
const call = context.fetchStub.getCall(0);
|
|
39
|
+
call.args[1].method.should.equal('POST');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should_call_fetch_with_json_headers", () => {
|
|
43
|
+
const call = context.fetchStub.getCall(0);
|
|
44
|
+
call.args[1].headers['Content-Type'].should.equal('application/json');
|
|
45
|
+
call.args[1].headers['Accept'].should.equal('application/json');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should_return_command_result", () => (result !== null && result !== undefined).should.be.true);
|
|
49
|
+
|
|
50
|
+
it("should_set_initial_values_from_current_values", () => context.command.hasChanges.should.be.false);
|
|
51
|
+
}));
|
package/commands/for_Command/when_property_changed_value_that_is_different_from_initial_value.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { SomeCommand } from './SomeCommand';
|
|
5
|
+
|
|
6
|
+
describe('when property changed value that is different from initial value', () => {
|
|
7
|
+
const command = new SomeCommand();
|
|
8
|
+
command.setInitialValues({
|
|
9
|
+
someProperty: ''
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
command.someProperty = '42';
|
|
13
|
+
command.propertyChanged('someProperty');
|
|
14
|
+
|
|
15
|
+
it('should have changes', () => command.hasChanges.should.be.true);
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { SomeCommand } from './SomeCommand';
|
|
5
|
+
|
|
6
|
+
describe('when property changed value that is same as initial value', () => {
|
|
7
|
+
const command = new SomeCommand();
|
|
8
|
+
command.setInitialValues({
|
|
9
|
+
someProperty: ''
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
command.someProperty = '';
|
|
13
|
+
command.propertyChanged('someProperty');
|
|
14
|
+
|
|
15
|
+
it('should have no changes', () => command.hasChanges.should.be.false);
|
|
16
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { SomeCommand } from './SomeCommand';
|
|
5
|
+
|
|
6
|
+
describe('when property changes and initial value is undefined', () => {
|
|
7
|
+
const command = new SomeCommand();
|
|
8
|
+
command.someProperty = '42';
|
|
9
|
+
command.propertyChanged('someProperty');
|
|
10
|
+
|
|
11
|
+
it('should have changes', () => command.hasChanges.should.be.true);
|
|
12
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { SomeCommand } from './SomeCommand';
|
|
6
|
+
|
|
7
|
+
describe('when property changes and there is a callback', () => {
|
|
8
|
+
const command = new SomeCommand();
|
|
9
|
+
const callback = sinon.stub();
|
|
10
|
+
command.onPropertyChanged(callback, command);
|
|
11
|
+
|
|
12
|
+
command.propertyChanged('someProperty');
|
|
13
|
+
|
|
14
|
+
it('should call the callback', () => callback.calledWith('someProperty').should.be.true);
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { SomeCommand } from './SomeCommand';
|
|
5
|
+
|
|
6
|
+
describe('when property has changed and we revert', () => {
|
|
7
|
+
const command = new SomeCommand();
|
|
8
|
+
command.setInitialValues({
|
|
9
|
+
someProperty: ''
|
|
10
|
+
});
|
|
11
|
+
command.someProperty = '42';
|
|
12
|
+
command.revertChanges();
|
|
13
|
+
|
|
14
|
+
it('should not have any changes', () => command.hasChanges.should.be.false);
|
|
15
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { SomeCommand } from './SomeCommand';
|
|
5
|
+
|
|
6
|
+
describe('when setting initial values after property changed', () => {
|
|
7
|
+
const command = new SomeCommand();
|
|
8
|
+
command.setInitialValues({
|
|
9
|
+
someProperty: ''
|
|
10
|
+
});
|
|
11
|
+
command.someProperty = '42';
|
|
12
|
+
command.propertyChanged('someProperty');
|
|
13
|
+
|
|
14
|
+
command.setInitialValuesFromCurrentValues();
|
|
15
|
+
|
|
16
|
+
it('should not have any changes', () => command.hasChanges.should.be.false);
|
|
17
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_command } from '../given/a_command';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { CommandResult } from '../../CommandResult';
|
|
7
|
+
|
|
8
|
+
describe("when validating and fetch throws exception", given(a_command, context => {
|
|
9
|
+
let result: CommandResult<object>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
context.fetchStub.rejects(new Error('Network error'));
|
|
13
|
+
|
|
14
|
+
result = await context.command.validate();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
context.fetchStub.restore();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should_return_failed_result", () => result.isSuccess.should.be.false);
|
|
22
|
+
it("should_include_error_message", () => result.exceptionMessages[0].should.contain('Error during validation call'));
|
|
23
|
+
it("should_have_exception_messages", () => (result.exceptionMessages.length > 0).should.be.true);
|
|
24
|
+
}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_command } from '../given/a_command';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { CommandResult } from '../../CommandResult';
|
|
7
|
+
|
|
8
|
+
describe("when validating and validation endpoint not found", given(a_command, context => {
|
|
9
|
+
let result: CommandResult<object>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
context.fetchStub.resolves({
|
|
13
|
+
status: 404,
|
|
14
|
+
json: async () => ({})
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
result = await context.command.validate();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
context.fetchStub.restore();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should_return_failed_result", () => result.isSuccess.should.be.false);
|
|
25
|
+
it("should_have_exception_messages", () => (result.exceptionMessages.length > 0).should.be.true);
|
|
26
|
+
}));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_command } from '../given/a_command';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
describe("when validating does not update initial values", given(a_command, context => {
|
|
8
|
+
const responseData = {
|
|
9
|
+
correlationId: '12345678-1234-1234-1234-123456789012',
|
|
10
|
+
isSuccess: true,
|
|
11
|
+
isAuthorized: true,
|
|
12
|
+
isValid: true,
|
|
13
|
+
hasExceptions: false,
|
|
14
|
+
validationResults: [],
|
|
15
|
+
exceptionMessages: [],
|
|
16
|
+
exceptionStackTrace: '',
|
|
17
|
+
response: {}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
beforeEach(async () => {
|
|
21
|
+
context.command.someProperty = 'initial value';
|
|
22
|
+
context.command.setInitialValues({ someProperty: 'initial value' });
|
|
23
|
+
context.command.someProperty = 'changed value';
|
|
24
|
+
context.command.propertyChanged('someProperty');
|
|
25
|
+
|
|
26
|
+
context.fetchStub.resolves({
|
|
27
|
+
status: 200,
|
|
28
|
+
json: async () => responseData
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await context.command.validate();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
context.fetchStub.restore();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should_still_have_changes_after_validation", () => context.command.hasChanges.should.be.true);
|
|
39
|
+
}));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_command } from '../given/a_command';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { CommandResult } from '../../CommandResult';
|
|
7
|
+
|
|
8
|
+
describe("when validating with successful response", given(a_command, context => {
|
|
9
|
+
let result: CommandResult<object>;
|
|
10
|
+
const responseData = {
|
|
11
|
+
correlationId: '12345678-1234-1234-1234-123456789012',
|
|
12
|
+
isSuccess: true,
|
|
13
|
+
isAuthorized: true,
|
|
14
|
+
isValid: true,
|
|
15
|
+
hasExceptions: false,
|
|
16
|
+
validationResults: [],
|
|
17
|
+
exceptionMessages: [],
|
|
18
|
+
exceptionStackTrace: '',
|
|
19
|
+
response: {}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
context.fetchStub.resolves({
|
|
24
|
+
status: 200,
|
|
25
|
+
json: async () => responseData
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
result = await context.command.validate();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
context.fetchStub.restore();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should_call_fetch_with_validate_route", () => {
|
|
36
|
+
const call = context.fetchStub.getCall(0);
|
|
37
|
+
const url = call.args[0];
|
|
38
|
+
url.toString().should.contain('/validate');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should_call_fetch_with_post_method", () => {
|
|
42
|
+
const call = context.fetchStub.getCall(0);
|
|
43
|
+
call.args[1].method.should.equal('POST');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should_return_command_result", () => (result !== null && result !== undefined).should.be.true);
|
|
47
|
+
}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { a_command } from '../given/a_command';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { CommandResult } from '../../CommandResult';
|
|
7
|
+
|
|
8
|
+
describe("when validating with validation errors", given(a_command, context => {
|
|
9
|
+
let result: CommandResult<object>;
|
|
10
|
+
const responseData = {
|
|
11
|
+
correlationId: '12345678-1234-1234-1234-123456789012',
|
|
12
|
+
isSuccess: false,
|
|
13
|
+
isAuthorized: true,
|
|
14
|
+
isValid: false,
|
|
15
|
+
hasExceptions: false,
|
|
16
|
+
validationResults: [
|
|
17
|
+
{
|
|
18
|
+
severity: 1,
|
|
19
|
+
message: 'Field is required',
|
|
20
|
+
members: ['someProperty'],
|
|
21
|
+
state: {}
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
exceptionMessages: [],
|
|
25
|
+
exceptionStackTrace: '',
|
|
26
|
+
response: {}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
context.fetchStub.resolves({
|
|
31
|
+
status: 200,
|
|
32
|
+
json: async () => responseData
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
result = await context.command.validate();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
context.fetchStub.restore();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should_return_invalid_result", () => result.isValid.should.be.false);
|
|
43
|
+
it("should_not_be_successful", () => result.isSuccess.should.be.false);
|
|
44
|
+
it("should_not_update_initial_values", () => context.command.hasChanges.should.be.false);
|
|
45
|
+
}));
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { CommandResult } from '../../CommandResult';
|
|
5
|
+
|
|
6
|
+
describe('when chaining callbacks and result has exceptions', () => {
|
|
7
|
+
const result = new CommandResult({
|
|
8
|
+
correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
|
|
9
|
+
isSuccess: false,
|
|
10
|
+
isAuthorized: true,
|
|
11
|
+
isValid: true,
|
|
12
|
+
hasExceptions: true,
|
|
13
|
+
validationResults: [],
|
|
14
|
+
exceptionMessages: [
|
|
15
|
+
'Something went wrong',
|
|
16
|
+
'Something is not right'
|
|
17
|
+
],
|
|
18
|
+
exceptionStackTrace: 'Some stack trace',
|
|
19
|
+
response: {}
|
|
20
|
+
}, Object, false);
|
|
21
|
+
|
|
22
|
+
let onSuccessCalled = false;
|
|
23
|
+
let onFailedCalled = false;
|
|
24
|
+
let receivedCommandResultOnFailed: CommandResult<object>;
|
|
25
|
+
let onUnauthorizedCalled = false;
|
|
26
|
+
let onValidationFailureCalled = false;
|
|
27
|
+
let onExceptionCalled = false;
|
|
28
|
+
let receivedMessages: string[] = [];
|
|
29
|
+
let receivedStackTrace: string = '';
|
|
30
|
+
|
|
31
|
+
result
|
|
32
|
+
.onSuccess(() => onSuccessCalled = true)
|
|
33
|
+
.onFailed((commandResult) => {
|
|
34
|
+
onFailedCalled = true;
|
|
35
|
+
receivedCommandResultOnFailed = commandResult;
|
|
36
|
+
})
|
|
37
|
+
.onUnauthorized(() => onUnauthorizedCalled = true)
|
|
38
|
+
.onValidationFailure(() => onValidationFailureCalled = true)
|
|
39
|
+
.onException((messages, stackTrace) => {
|
|
40
|
+
onExceptionCalled = true;
|
|
41
|
+
receivedMessages = messages;
|
|
42
|
+
receivedStackTrace = stackTrace;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should not call the on success callback', () => onSuccessCalled.should.be.false);
|
|
46
|
+
it('should forward the exception messages to the callback', () => receivedMessages.should.equal(result.exceptionMessages));
|
|
47
|
+
it('should forward the exception stack trace to the callback', () => receivedStackTrace.should.equal(result.exceptionStackTrace));
|
|
48
|
+
it('should call the on failed callback', () => onFailedCalled.should.be.true);
|
|
49
|
+
it('should forward the command result to the on failed callback', () => receivedCommandResultOnFailed.should.equal(result));
|
|
50
|
+
it('should not call the on unauthorized callback', () => onUnauthorizedCalled.should.be.false);
|
|
51
|
+
it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.false);
|
|
52
|
+
it('should call the on exception callback', () => onExceptionCalled.should.be.true);
|
|
53
|
+
});
|
|
54
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { ValidationResult } from '../../../validation/ValidationResult';
|
|
5
|
+
import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity';
|
|
6
|
+
import { CommandResult } from '../../CommandResult';
|
|
7
|
+
|
|
8
|
+
describe('when chaining callbacks and result is invalid', () => {
|
|
9
|
+
const result = new CommandResult({
|
|
10
|
+
correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
|
|
11
|
+
isSuccess: false,
|
|
12
|
+
isAuthorized: true,
|
|
13
|
+
isValid: false,
|
|
14
|
+
hasExceptions: false,
|
|
15
|
+
validationResults: [
|
|
16
|
+
new ValidationResult(ValidationResultSeverity.Error, 'Something went wrong', ['someProperty'], 'Something went wrong'),
|
|
17
|
+
new ValidationResult(ValidationResultSeverity.Warning, 'Something is not right', ['someOtherProperty'], 'Something is not right')
|
|
18
|
+
],
|
|
19
|
+
exceptionMessages: [],
|
|
20
|
+
exceptionStackTrace: '',
|
|
21
|
+
response: {}
|
|
22
|
+
}, Object, false);
|
|
23
|
+
|
|
24
|
+
let onSuccessCalled = false;
|
|
25
|
+
let onFailedCalled = false;
|
|
26
|
+
let receivedCommandResultOnFailed: CommandResult<object>;
|
|
27
|
+
let onUnauthorizedCalled = false;
|
|
28
|
+
let onValidationFailureCalled = false;
|
|
29
|
+
let onExceptionCalled = false;
|
|
30
|
+
let receivedValidationResults: ValidationResult[] = [];
|
|
31
|
+
|
|
32
|
+
result
|
|
33
|
+
.onSuccess(() => onSuccessCalled = true)
|
|
34
|
+
.onFailed((commandResult) => {
|
|
35
|
+
onFailedCalled = true;
|
|
36
|
+
receivedCommandResultOnFailed = commandResult;
|
|
37
|
+
})
|
|
38
|
+
.onUnauthorized(() => onUnauthorizedCalled = true)
|
|
39
|
+
.onValidationFailure(validationResults => {
|
|
40
|
+
onValidationFailureCalled = true;
|
|
41
|
+
receivedValidationResults = validationResults;
|
|
42
|
+
})
|
|
43
|
+
.onException(() => onExceptionCalled = true);
|
|
44
|
+
|
|
45
|
+
it('should not call the on success callback', () => onSuccessCalled.should.be.false);
|
|
46
|
+
it('should forward the validation results to the callback', () => receivedValidationResults.should.equal(result.validationResults));
|
|
47
|
+
it('should call the on failed callback', () => onFailedCalled.should.be.true);
|
|
48
|
+
it('should forward the command result to the on failed callback', () => receivedCommandResultOnFailed.should.equal(result));
|
|
49
|
+
it('should not call the on unauthorized callback', () => onUnauthorizedCalled.should.be.false);
|
|
50
|
+
it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.true);
|
|
51
|
+
it('should not call the on exception callback', () => onExceptionCalled.should.be.false);
|
|
52
|
+
});
|
|
53
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { CommandResult } from '../../CommandResult';
|
|
5
|
+
|
|
6
|
+
describe('when chaining callbacks and result is successful', () => {
|
|
7
|
+
const result = new CommandResult<string>({
|
|
8
|
+
correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
|
|
9
|
+
isSuccess: true,
|
|
10
|
+
isAuthorized: true,
|
|
11
|
+
isValid: true,
|
|
12
|
+
hasExceptions: false,
|
|
13
|
+
validationResults: [],
|
|
14
|
+
exceptionMessages: [],
|
|
15
|
+
exceptionStackTrace: '',
|
|
16
|
+
response: 'The ultimate response'
|
|
17
|
+
}, Object, false);
|
|
18
|
+
|
|
19
|
+
let onSuccessCalled = false;
|
|
20
|
+
let onFailedCalled = false;
|
|
21
|
+
let onUnauthorizedCalled = false;
|
|
22
|
+
let onValidationFailureCalled = false;
|
|
23
|
+
let onExceptionCalled = false;
|
|
24
|
+
let receivedResponse: string | null = null;
|
|
25
|
+
|
|
26
|
+
result
|
|
27
|
+
.onSuccess(response => {
|
|
28
|
+
onSuccessCalled = true;
|
|
29
|
+
receivedResponse = response as string;
|
|
30
|
+
})
|
|
31
|
+
.onFailed(() => onFailedCalled = true)
|
|
32
|
+
.onUnauthorized(() => onUnauthorizedCalled = true)
|
|
33
|
+
.onValidationFailure(() => onValidationFailureCalled = true)
|
|
34
|
+
.onException(() => onExceptionCalled = true);
|
|
35
|
+
|
|
36
|
+
it('should call the on success callback', () => onSuccessCalled.should.be.true);
|
|
37
|
+
it('should pass the response to the callback', () => receivedResponse!.should.equal(result.response));
|
|
38
|
+
it('should not call the on failed callback', () => onFailedCalled.should.be.false);
|
|
39
|
+
it('should not call the on unauthorized callback', () => onUnauthorizedCalled.should.be.false);
|
|
40
|
+
it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.false);
|
|
41
|
+
it('should not call the on exception callback', () => onExceptionCalled.should.be.false);
|
|
42
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { CommandResult } from '../../CommandResult';
|
|
5
|
+
|
|
6
|
+
describe('when chaining callbacks and result is unauthorized', () => {
|
|
7
|
+
const result = new CommandResult({
|
|
8
|
+
correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
|
|
9
|
+
isSuccess: false,
|
|
10
|
+
isAuthorized: false,
|
|
11
|
+
isValid: true,
|
|
12
|
+
hasExceptions: false,
|
|
13
|
+
validationResults: [],
|
|
14
|
+
exceptionMessages: [],
|
|
15
|
+
exceptionStackTrace: '',
|
|
16
|
+
response: {}
|
|
17
|
+
}, Object, false);
|
|
18
|
+
|
|
19
|
+
let onSuccessCalled = false;
|
|
20
|
+
let onFailedCalled = false;
|
|
21
|
+
let receivedCommandResultOnFailed: CommandResult<object>;
|
|
22
|
+
let onUnauthorizedCalled = false;
|
|
23
|
+
let onValidationFailureCalled = false;
|
|
24
|
+
let onExceptionCalled = false;
|
|
25
|
+
|
|
26
|
+
result
|
|
27
|
+
.onSuccess(() => onSuccessCalled = true)
|
|
28
|
+
.onFailed((commandResult) => {
|
|
29
|
+
onFailedCalled = true;
|
|
30
|
+
receivedCommandResultOnFailed = commandResult;
|
|
31
|
+
})
|
|
32
|
+
.onUnauthorized(() => onUnauthorizedCalled = true)
|
|
33
|
+
.onValidationFailure(() => onValidationFailureCalled = true)
|
|
34
|
+
.onException(() => onExceptionCalled = true);
|
|
35
|
+
|
|
36
|
+
it('should not the on success callback', () => onSuccessCalled.should.be.false);
|
|
37
|
+
it('should call the on failed callback', () => onFailedCalled.should.be.true);
|
|
38
|
+
it('should forward the command result to the on failed callback', () => receivedCommandResultOnFailed.should.equal(result));
|
|
39
|
+
it('should call the on unauthorized callback', () => onUnauthorizedCalled.should.be.true);
|
|
40
|
+
it('should not call the on validation failure callback', () => onValidationFailureCalled.should.be.false);
|
|
41
|
+
it('should not call the on exception callback', () => onExceptionCalled.should.be.false);
|
|
42
|
+
});
|
|
43
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
export * from './ICommand';
|
|
5
|
+
export * from './Command';
|
|
6
|
+
export * from './ICommandResult';
|
|
7
|
+
export * from './CommandResult';
|
|
8
|
+
export * from './CommandResults';
|
|
9
|
+
export * from './CommandValidator';
|
package/deepEqual.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
export const deepEqual = (obj1, obj2) => {
|
|
5
|
+
if (obj1 === obj2) return true; // Same reference or primitive value
|
|
6
|
+
|
|
7
|
+
if (obj1 == null || obj2 == null || typeof obj1 !== "object" || typeof obj2 !== "object") {
|
|
8
|
+
return false; // Handle null, undefined, or different types
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const keys1 = Object.keys(obj1);
|
|
12
|
+
const keys2 = Object.keys(obj2);
|
|
13
|
+
|
|
14
|
+
if (keys1.length !== keys2.length) {
|
|
15
|
+
return false; // Different number of keys
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const key of keys1) {
|
|
19
|
+
if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return true; // All keys and values match
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetHttpHeaders.d.ts","sourceRoot":"","sources":["../../GetHttpHeaders.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,cAAc,GAAG,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Globals.d.ts","sourceRoot":"","sources":["../../Globals.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,QAAQ;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;CACvC;AAED,eAAO,MAAM,OAAO,EAAE,QAIrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Globals.js","sources":["../../Globals.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport interface IGlobals {\n microservice: string;\n microserviceHttpHeader: string;\n microserviceWSQueryArgument: string;\n}\n\nexport const Globals: IGlobals = {\n microservice: '',\n microserviceHttpHeader: 'x-cratis-microservice',\n microserviceWSQueryArgument: 'x-cratis-microservice'\n};"],"names":[],"mappings":";;AASO,MAAM,OAAO,GAAa;AAC7B,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,sBAAsB,EAAE,uBAAuB;AAC/C,IAAA,2BAA2B,EAAE;;;;;"}
|