@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,71 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
|
|
10
|
+
describe('with abort controller', given(a_query_for, context => {
|
|
11
|
+
let result1: QueryResult<string>;
|
|
12
|
+
let result2: QueryResult<string>;
|
|
13
|
+
let fetchStub: sinon.SinonStub;
|
|
14
|
+
let firstAbortController: AbortController;
|
|
15
|
+
const mockResponse = {
|
|
16
|
+
data: 'test-result',
|
|
17
|
+
isSuccess: true,
|
|
18
|
+
isAuthorized: true,
|
|
19
|
+
isValid: true,
|
|
20
|
+
hasExceptions: false,
|
|
21
|
+
validationResults: [],
|
|
22
|
+
exceptionMessages: [],
|
|
23
|
+
exceptionStackTrace: '',
|
|
24
|
+
paging: {
|
|
25
|
+
totalItems: 0,
|
|
26
|
+
totalPages: 0,
|
|
27
|
+
page: 0,
|
|
28
|
+
size: 0
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
// Setup fetch mock
|
|
34
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
35
|
+
fetchStub.resolves({
|
|
36
|
+
json: sinon.stub().resolves(mockResponse),
|
|
37
|
+
ok: true,
|
|
38
|
+
status: 200
|
|
39
|
+
} as unknown as Response);
|
|
40
|
+
|
|
41
|
+
context.query.setOrigin('https://api.example.com');
|
|
42
|
+
|
|
43
|
+
// Call perform first time to establish abort controller
|
|
44
|
+
result1 = await context.query.perform({ id: 'test-id-1' });
|
|
45
|
+
firstAbortController = context.query.abortController!;
|
|
46
|
+
|
|
47
|
+
// Call perform second time - should abort the first controller
|
|
48
|
+
result2 = await context.query.perform({ id: 'test-id-2' });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
fetchStub.restore();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should create new abort controller on second call', () => {
|
|
56
|
+
context.query.abortController.should.not.equal(firstAbortController);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should abort first controller when performing second query', () => {
|
|
60
|
+
firstAbortController.signal.aborted.should.be.true;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should return successful results for both calls', () => {
|
|
64
|
+
result1.isSuccess.should.be.true;
|
|
65
|
+
result2.isSuccess.should.be.true;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should call fetch twice', () => {
|
|
69
|
+
fetchStub.should.have.been.calledTwice;
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
@@ -0,0 +1,62 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
|
|
10
|
+
describe('with enumerable query', given(a_query_for, context => {
|
|
11
|
+
let result: QueryResult<string[]>;
|
|
12
|
+
let fetchStub: sinon.SinonStub;
|
|
13
|
+
const mockResponse = {
|
|
14
|
+
data: ['item1', 'item2'],
|
|
15
|
+
isSuccess: true,
|
|
16
|
+
isAuthorized: true,
|
|
17
|
+
isValid: true,
|
|
18
|
+
hasExceptions: false,
|
|
19
|
+
validationResults: [],
|
|
20
|
+
exceptionMessages: [],
|
|
21
|
+
exceptionStackTrace: '',
|
|
22
|
+
paging: {
|
|
23
|
+
totalItems: 0,
|
|
24
|
+
totalPages: 0,
|
|
25
|
+
page: 0,
|
|
26
|
+
size: 0
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
// Setup fetch mock
|
|
32
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
33
|
+
fetchStub.resolves({
|
|
34
|
+
json: sinon.stub().resolves(mockResponse),
|
|
35
|
+
ok: true,
|
|
36
|
+
status: 200
|
|
37
|
+
} as unknown as Response);
|
|
38
|
+
|
|
39
|
+
context.enumerableQuery.setOrigin('https://api.example.com');
|
|
40
|
+
|
|
41
|
+
// Call perform with valid arguments
|
|
42
|
+
result = await context.enumerableQuery.perform({ category: 'test-category' });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
fetchStub.restore();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return successful result', () => {
|
|
50
|
+
result.isSuccess.should.be.true;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should return array data', () => {
|
|
54
|
+
result.data.should.deep.equal(['item1', 'item2']);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should call fetch with correct URL', () => {
|
|
58
|
+
fetchStub.should.have.been.calledOnce;
|
|
59
|
+
const call = fetchStub.getCall(0);
|
|
60
|
+
call.args[0].href.should.equal('https://api.example.com/api/items/test-category');
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
@@ -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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
|
|
10
|
+
describe('with fetch error', given(a_query_for, context => {
|
|
11
|
+
let result: QueryResult<string>;
|
|
12
|
+
let fetchStub: sinon.SinonStub;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
// Setup fetch mock to reject
|
|
16
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
17
|
+
fetchStub.rejects(new Error('Network error'));
|
|
18
|
+
|
|
19
|
+
context.query.setOrigin('https://api.example.com');
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// Call perform with valid arguments - should handle the error and return no success
|
|
23
|
+
result = await context.query.perform({ id: 'test-id' });
|
|
24
|
+
} catch {
|
|
25
|
+
// If QueryFor doesn't handle the error, we'll create a default response
|
|
26
|
+
const noSuccess = { ...QueryResult.noSuccess, data: context.query.defaultValue } as QueryResult<string>;
|
|
27
|
+
result = noSuccess;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
fetchStub.restore();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should return no success result', () => {
|
|
36
|
+
result.isSuccess.should.be.false;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should return default value', () => {
|
|
40
|
+
result.data.should.equal('');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should return result without data', () => {
|
|
44
|
+
result.data.should.equal('');
|
|
45
|
+
result.isSuccess.should.be.false;
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
@@ -0,0 +1,29 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import { QueryResult } from '../../QueryResult';
|
|
7
|
+
|
|
8
|
+
describe('with invalid arguments', given(a_query_for, context => {
|
|
9
|
+
let result: QueryResult<string>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
// Call perform without required arguments
|
|
13
|
+
result = await context.query.perform();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return no success result', () => {
|
|
17
|
+
result.isSuccess.should.be.false;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should return default value', () => {
|
|
21
|
+
result.data.should.equal('');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return result without data', () => {
|
|
25
|
+
// For validation failures, the result doesn't have proper data
|
|
26
|
+
result.data.should.equal('');
|
|
27
|
+
result.isSuccess.should.be.false;
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
@@ -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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
|
|
10
|
+
describe('with json parse error', given(a_query_for, context => {
|
|
11
|
+
let result: QueryResult<string>;
|
|
12
|
+
let fetchStub: sinon.SinonStub;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
// Setup fetch mock with json parse error
|
|
16
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
17
|
+
fetchStub.resolves({
|
|
18
|
+
json: sinon.stub().rejects(new Error('Invalid JSON')),
|
|
19
|
+
ok: true,
|
|
20
|
+
status: 200
|
|
21
|
+
} as unknown as Response);
|
|
22
|
+
|
|
23
|
+
context.query.setOrigin('https://api.example.com');
|
|
24
|
+
|
|
25
|
+
// Call perform with valid arguments
|
|
26
|
+
result = await context.query.perform({ id: 'test-id' });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
fetchStub.restore();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should return no success result', () => {
|
|
34
|
+
result.isSuccess.should.be.false;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should return default value', () => {
|
|
38
|
+
result.data.should.equal('');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should return result without data', () => {
|
|
42
|
+
result.data.should.equal('');
|
|
43
|
+
result.isSuccess.should.be.false;
|
|
44
|
+
});
|
|
45
|
+
}));
|
|
@@ -0,0 +1,62 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
import { Paging } from '../../Paging';
|
|
10
|
+
|
|
11
|
+
describe('with paging', given(a_query_for, context => {
|
|
12
|
+
let result: QueryResult<string>;
|
|
13
|
+
let fetchStub: sinon.SinonStub;
|
|
14
|
+
const mockResponse = {
|
|
15
|
+
data: 'test-result',
|
|
16
|
+
isSuccess: true,
|
|
17
|
+
isAuthorized: true,
|
|
18
|
+
isValid: true,
|
|
19
|
+
hasExceptions: false,
|
|
20
|
+
validationResults: [],
|
|
21
|
+
exceptionMessages: [],
|
|
22
|
+
exceptionStackTrace: '',
|
|
23
|
+
paging: {
|
|
24
|
+
totalItems: 0,
|
|
25
|
+
totalPages: 0,
|
|
26
|
+
page: 0,
|
|
27
|
+
size: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
beforeEach(async () => {
|
|
32
|
+
// Setup fetch mock
|
|
33
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
34
|
+
fetchStub.resolves({
|
|
35
|
+
json: sinon.stub().resolves(mockResponse),
|
|
36
|
+
ok: true,
|
|
37
|
+
status: 200
|
|
38
|
+
} as unknown as Response);
|
|
39
|
+
|
|
40
|
+
context.query.setOrigin('https://api.example.com');
|
|
41
|
+
context.query.paging = new Paging(2, 10); // page 2, 10 items per page
|
|
42
|
+
|
|
43
|
+
// Call perform with valid arguments
|
|
44
|
+
result = await context.query.perform({ id: 'test-id' });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
fetchStub.restore();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should call fetch with URL including paging parameters', () => {
|
|
52
|
+
fetchStub.should.have.been.calledOnce;
|
|
53
|
+
const call = fetchStub.getCall(0);
|
|
54
|
+
const url = call.args[0].href;
|
|
55
|
+
url.should.include('page=2');
|
|
56
|
+
url.should.include('pageSize=10');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return successful result', () => {
|
|
60
|
+
result.isSuccess.should.be.true;
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
@@ -0,0 +1,68 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import * as sinon from 'sinon';
|
|
7
|
+
import { QueryResult } from '../../QueryResult';
|
|
8
|
+
|
|
9
|
+
describe('with parameter descriptor values', given(a_query_for, context => {
|
|
10
|
+
let result: QueryResult<string>;
|
|
11
|
+
let fetchStub: sinon.SinonStub;
|
|
12
|
+
const mockResponse = {
|
|
13
|
+
data: 'test-result',
|
|
14
|
+
isSuccess: true,
|
|
15
|
+
isAuthorized: true,
|
|
16
|
+
isValid: true,
|
|
17
|
+
hasExceptions: false,
|
|
18
|
+
validationResults: [],
|
|
19
|
+
exceptionMessages: [],
|
|
20
|
+
exceptionStackTrace: '',
|
|
21
|
+
paging: {
|
|
22
|
+
totalItems: 0,
|
|
23
|
+
totalPages: 0,
|
|
24
|
+
page: 0,
|
|
25
|
+
size: 0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
31
|
+
fetchStub.resolves({
|
|
32
|
+
json: sinon.stub().resolves(mockResponse),
|
|
33
|
+
ok: true,
|
|
34
|
+
status: 200
|
|
35
|
+
} as unknown as Response);
|
|
36
|
+
|
|
37
|
+
context.queryWithParameterDescriptorValues.setOrigin('https://api.example.com');
|
|
38
|
+
context.queryWithParameterDescriptorValues.setApiBasePath('/api/v1');
|
|
39
|
+
|
|
40
|
+
// Set values on the query instance
|
|
41
|
+
context.queryWithParameterDescriptorValues.filter = 'active';
|
|
42
|
+
context.queryWithParameterDescriptorValues.limit = 10;
|
|
43
|
+
|
|
44
|
+
result = await context.queryWithParameterDescriptorValues.perform();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
fetchStub.restore();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should return successful result', () => {
|
|
52
|
+
result.isSuccess.should.be.true;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should include parameter descriptor values in URL as query string', () => {
|
|
56
|
+
fetchStub.should.have.been.calledOnce;
|
|
57
|
+
const call = fetchStub.getCall(0);
|
|
58
|
+
const url = call.args[0].href;
|
|
59
|
+
url.should.include('filter=active');
|
|
60
|
+
url.should.include('limit=10');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should have query string separator in URL', () => {
|
|
64
|
+
const call = fetchStub.getCall(0);
|
|
65
|
+
const url = call.args[0].href;
|
|
66
|
+
url.should.include('?');
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
@@ -0,0 +1,67 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import * as sinon from 'sinon';
|
|
7
|
+
import { QueryResult } from '../../QueryResult';
|
|
8
|
+
|
|
9
|
+
describe('with partial parameter descriptor values', given(a_query_for, context => {
|
|
10
|
+
let result: QueryResult<string>;
|
|
11
|
+
let fetchStub: sinon.SinonStub;
|
|
12
|
+
const mockResponse = {
|
|
13
|
+
data: 'test-result',
|
|
14
|
+
isSuccess: true,
|
|
15
|
+
isAuthorized: true,
|
|
16
|
+
isValid: true,
|
|
17
|
+
hasExceptions: false,
|
|
18
|
+
validationResults: [],
|
|
19
|
+
exceptionMessages: [],
|
|
20
|
+
exceptionStackTrace: '',
|
|
21
|
+
paging: {
|
|
22
|
+
totalItems: 0,
|
|
23
|
+
totalPages: 0,
|
|
24
|
+
page: 0,
|
|
25
|
+
size: 0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
31
|
+
fetchStub.resolves({
|
|
32
|
+
json: sinon.stub().resolves(mockResponse),
|
|
33
|
+
ok: true,
|
|
34
|
+
status: 200
|
|
35
|
+
} as unknown as Response);
|
|
36
|
+
|
|
37
|
+
context.queryWithParameterDescriptorValues.setOrigin('https://api.example.com');
|
|
38
|
+
context.queryWithParameterDescriptorValues.setApiBasePath('/api/v1');
|
|
39
|
+
|
|
40
|
+
// Only set one parameter value, leave the other undefined
|
|
41
|
+
context.queryWithParameterDescriptorValues.filter = 'active';
|
|
42
|
+
// limit is not set (undefined)
|
|
43
|
+
|
|
44
|
+
result = await context.queryWithParameterDescriptorValues.perform();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
fetchStub.restore();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should return successful result', () => {
|
|
52
|
+
result.isSuccess.should.be.true;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should include only set parameter descriptor values in URL', () => {
|
|
56
|
+
fetchStub.should.have.been.calledOnce;
|
|
57
|
+
const call = fetchStub.getCall(0);
|
|
58
|
+
const url = call.args[0].href;
|
|
59
|
+
url.should.include('filter=active');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should not include undefined parameter descriptor values in URL', () => {
|
|
63
|
+
const call = fetchStub.getCall(0);
|
|
64
|
+
const url = call.args[0].href;
|
|
65
|
+
url.should.not.include('limit=');
|
|
66
|
+
});
|
|
67
|
+
}));
|
|
@@ -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 { a_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
|
|
10
|
+
describe('with query without required parameters', given(a_query_for, context => {
|
|
11
|
+
let result: QueryResult<string>;
|
|
12
|
+
let fetchStub: sinon.SinonStub;
|
|
13
|
+
const mockResponse = {
|
|
14
|
+
data: 'test-result',
|
|
15
|
+
isSuccess: true,
|
|
16
|
+
isAuthorized: true,
|
|
17
|
+
isValid: true,
|
|
18
|
+
hasExceptions: false,
|
|
19
|
+
validationResults: [],
|
|
20
|
+
exceptionMessages: [],
|
|
21
|
+
exceptionStackTrace: '',
|
|
22
|
+
paging: {
|
|
23
|
+
totalItems: 0,
|
|
24
|
+
totalPages: 0,
|
|
25
|
+
page: 0,
|
|
26
|
+
size: 0
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
// Setup fetch mock
|
|
32
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
33
|
+
fetchStub.resolves({
|
|
34
|
+
json: sinon.stub().resolves(mockResponse),
|
|
35
|
+
ok: true,
|
|
36
|
+
status: 200
|
|
37
|
+
} as unknown as Response);
|
|
38
|
+
|
|
39
|
+
context.queryWithoutParams.setOrigin('https://api.example.com');
|
|
40
|
+
|
|
41
|
+
// Call perform without any arguments (which is valid for this query)
|
|
42
|
+
result = await context.queryWithoutParams.perform();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
fetchStub.restore();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return successful result', () => {
|
|
50
|
+
result.isSuccess.should.be.true;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should call fetch with correct URL', () => {
|
|
54
|
+
fetchStub.should.have.been.calledOnce;
|
|
55
|
+
const call = fetchStub.getCall(0);
|
|
56
|
+
call.args[0].href.should.equal('https://api.example.com/api/all');
|
|
57
|
+
});
|
|
58
|
+
}));
|
|
@@ -0,0 +1,71 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
import * as sinon from 'sinon';
|
|
7
|
+
import { QueryResult } from '../../QueryResult';
|
|
8
|
+
import { expect } from 'chai';
|
|
9
|
+
|
|
10
|
+
describe('with route parameters and unused parameters', given(a_query_for, context => {
|
|
11
|
+
let result: QueryResult<string>;
|
|
12
|
+
let fetchStub: sinon.SinonStub;
|
|
13
|
+
const mockResponse = {
|
|
14
|
+
data: 'test-result',
|
|
15
|
+
isSuccess: true,
|
|
16
|
+
isAuthorized: true,
|
|
17
|
+
isValid: true,
|
|
18
|
+
hasExceptions: false,
|
|
19
|
+
validationResults: [],
|
|
20
|
+
exceptionMessages: [],
|
|
21
|
+
exceptionStackTrace: '',
|
|
22
|
+
paging: {
|
|
23
|
+
totalItems: 0,
|
|
24
|
+
totalPages: 0,
|
|
25
|
+
page: 0,
|
|
26
|
+
size: 0
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
32
|
+
fetchStub.resolves({
|
|
33
|
+
json: sinon.stub().resolves(mockResponse),
|
|
34
|
+
ok: true,
|
|
35
|
+
status: 200
|
|
36
|
+
} as unknown as Response);
|
|
37
|
+
|
|
38
|
+
context.query.setOrigin('https://api.example.com');
|
|
39
|
+
context.query.setApiBasePath('/api/v1');
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
result = await context.query.perform({ id: 'test-id', filter: 'active', search: 'query' } as any);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
fetchStub.restore();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return successful result', () => {
|
|
50
|
+
expect(result.isSuccess).to.be.true;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should return correct data', () => {
|
|
54
|
+
expect(result.data).to.equal('test-result');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should include route parameter in path', () => {
|
|
58
|
+
const call = fetchStub.getCall(0);
|
|
59
|
+
call.args[0].href.should.include('/test-id');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should include unused filter parameter in query string', () => {
|
|
63
|
+
const call = fetchStub.getCall(0);
|
|
64
|
+
call.args[0].href.should.include('filter=active');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should include unused search parameter in query string', () => {
|
|
68
|
+
const call = fetchStub.getCall(0);
|
|
69
|
+
call.args[0].href.should.include('search=query');
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
@@ -0,0 +1,99 @@
|
|
|
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_query_for } from '../given/a_query_for';
|
|
5
|
+
import { given } from '../../../given';
|
|
6
|
+
|
|
7
|
+
import * as sinon from 'sinon';
|
|
8
|
+
import { QueryResult } from '../../QueryResult';
|
|
9
|
+
import { Sorting } from '../../Sorting';
|
|
10
|
+
import { SortDirection } from '../../SortDirection';
|
|
11
|
+
|
|
12
|
+
describe('with sorting', given(a_query_for, context => {
|
|
13
|
+
let result: QueryResult<string>;
|
|
14
|
+
let fetchStub: sinon.SinonStub;
|
|
15
|
+
const mockResponse = {
|
|
16
|
+
data: 'test-result',
|
|
17
|
+
isSuccess: true,
|
|
18
|
+
isAuthorized: true,
|
|
19
|
+
isValid: true,
|
|
20
|
+
hasExceptions: false,
|
|
21
|
+
validationResults: [],
|
|
22
|
+
exceptionMessages: [],
|
|
23
|
+
exceptionStackTrace: '',
|
|
24
|
+
paging: {
|
|
25
|
+
totalItems: 0,
|
|
26
|
+
totalPages: 0,
|
|
27
|
+
page: 0,
|
|
28
|
+
size: 0
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
describe('and ascending direction', () => {
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
// Setup fetch mock
|
|
35
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
36
|
+
fetchStub.resolves({
|
|
37
|
+
json: sinon.stub().resolves(mockResponse),
|
|
38
|
+
ok: true,
|
|
39
|
+
status: 200
|
|
40
|
+
} as unknown as Response);
|
|
41
|
+
|
|
42
|
+
context.query.setOrigin('https://api.example.com');
|
|
43
|
+
context.query.sorting = new Sorting('name', SortDirection.ascending);
|
|
44
|
+
|
|
45
|
+
// Call perform with valid arguments
|
|
46
|
+
result = await context.query.perform({ id: 'test-id' });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
fetchStub.restore();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should call fetch with URL including sorting parameters', () => {
|
|
54
|
+
fetchStub.should.have.been.calledOnce;
|
|
55
|
+
const call = fetchStub.getCall(0);
|
|
56
|
+
const url = call.args[0].href;
|
|
57
|
+
url.should.include('sortBy=name');
|
|
58
|
+
url.should.include('sortDirection=asc');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should return successful result', () => {
|
|
62
|
+
result.isSuccess.should.be.true;
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('and descending direction', () => {
|
|
67
|
+
beforeEach(async () => {
|
|
68
|
+
// Setup fetch mock
|
|
69
|
+
fetchStub = sinon.stub(global, 'fetch');
|
|
70
|
+
fetchStub.resolves({
|
|
71
|
+
json: sinon.stub().resolves(mockResponse),
|
|
72
|
+
ok: true,
|
|
73
|
+
status: 200
|
|
74
|
+
} as unknown as Response);
|
|
75
|
+
|
|
76
|
+
context.query.setOrigin('https://api.example.com');
|
|
77
|
+
context.query.sorting = new Sorting('name', SortDirection.descending);
|
|
78
|
+
|
|
79
|
+
// Call perform with valid arguments
|
|
80
|
+
result = await context.query.perform({ id: 'test-id' });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
fetchStub.restore();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should call fetch with URL including sorting parameters', () => {
|
|
88
|
+
fetchStub.should.have.been.calledOnce;
|
|
89
|
+
const call = fetchStub.getCall(0);
|
|
90
|
+
const url = call.args[0].href;
|
|
91
|
+
url.should.include('sortBy=name');
|
|
92
|
+
url.should.include('sortDirection=desc');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should return successful result', () => {
|
|
96
|
+
result.isSuccess.should.be.true;
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}));
|