Releases: equinor/fusion-framework
@equinor/[email protected]
Minor Changes
-
#2491
73af73eThanks @odinr! - Added a new operatorcapitalizeRequestMethodOperatorto ensure that the HTTP method of a given request is in uppercase.- Introduced
capitalizeRequestMethodOperatorwhich processes an HTTP request object and converts its method to uppercase. - Logs a warning if the HTTP method was converted, providing information about the change and a reference to RFC 7231 Section 4.1.
Example usage:
import { capitalizeRequestMethodOperator } from '@equinor/fusion-query'; const operator = capitalizeRequestMethodOperator(); const request = { method: 'get' }; const updatedRequest = operator(request); console.log(updatedRequest.method); // Outputs: 'GET'
Adding the operator to the
HttpClient:const httpClient = new HttpClient(); httpClient.requestHandler.add('capatalize-method', capitalizeRequestMethodOperator()); // transforms `method` to uppercase and logs a warning. httpClient.get('https://example.com', { method: 'get' });
- Introduced
-
#2491
73af73eThanks @odinr! - TheHttpClientConfiguratornow has by default thecapitalizeRequestMethodOperatorandrequestValidationOperatorenabled.CapitalizeRequestMethodOperator
This operator will capitalize the HTTP method name before sending the request. This is useful when you are using a client that requires the HTTP method to be capitalized. If you want to disable this operator, you can do so by removing it from the
HttpClientConfigurator:httpConfig.defaultHttpRequestHandler.remove('capitalize-method');
[!NOTE]
This operator is enabled by default and will log to the console if the method is not capitalized.RequestValidationOperator
This operator will parse and validate the request before sending it. If the request is invalid, the error will be logged to the console. If you want to disable this operator, you can do so by removing it from the
HttpClientConfigurator:httpConfig.defaultHttpRequestHandler.remove('validate-request');
[!NOTE]
This operator is enabled by default and will log to the console if the request parameters are invalid.If you wish stricter validation, you can enable the
strictmode by setting thestrictproperty totrue:import { requestValidationOperator } from '@equinor/fusion-framework-module-http/operators'; httpConfig.defaultHttpRequestHandler.set( 'validate-request' requestValidationOperator({ strict: true, // will throw error if schema is not valid parse: true // will not allow additional properties }) );
-
#2491
73af73eThanks @odinr! - Addedremoveto theProcessOperatorsto allow for the removal of a specific operator. This is useful for removing operators that are not desired, example default operators included in initial configuration.example:
httpClient.requestHandler.remove('capitalize-method');
[!NOTE]
There are currently no code completion for theremovemethod, so you will need to know the name of the operator you want to remove. We assume this is so low level that if you are removing operators you know what the name of the operator is.[!TIP]
If you only wish to replace the operator with another operator, you can use thesetmethod instead ofremoveandadd. -
#2491
73af73eThanks @odinr! - New Feature: EnhancedrequestValidationOperatorThe
requestValidationOperatoris a utility function that validates incoming requests against a Zod schema. This function has two options:strictandparse. Thestrictoption allows you to enforce strict validation, while theparseoption enables you to return the parsed request object if it passes validation.The
requestValidationOperatoris meant to be used as a request operator in the Fusion API framework. It is a higher-order function that takes a Zod schema as an argument and returns a function that validates incoming requests against that schema.Option Description Usage Strict Validation When strictis set totrue, the validation will fail if there are additional properties not defined in the schema.If strictis set tofalseor omitted, additional properties will be allowed and passed through without causing validation errors.Parse Option When parseis enabled, the function will return the parsed and potentially transformed request object if it passes validation.If parseis not enabled, the function will not return anything even if the request object is valid.To use the new
strictandparseoptions, update your code as follows:Example usage with strict validation:
const operator = requestValidationOperator({ strict: true }); // This will throw an error because of invalid method and extra property. operator({ method: 'post', body: 'foo', extraProperty: 'This should not be here', });
Example usage with parsing enabled:
// Example usage with parsing enabled const operator = requestValidationOperator({ parse: true }); // will return { method: 'GET' } const parsedRequest = operator({ method: 'GET', extraProperty: 'This should not be here', });
Example usage with both strict validation and parsing enabled:
const operator = requestValidationOperator({ strict: true, parse: true }); // will throw an error because of extra property. const parsedStrictRequest = operator({ method: 'GET', extraProperty: 'This should not be here', });
Example usage with the
HttpClient:const httpClient = new HttpClient(); // Add the request validation operator to the HttpClient. httpClient.requestHandler.add('validate-init', requestValidationOperator({ parse: true })); // will throw an error because of invalid method. httpClient.get('https://example.com', { method: 'get' });
@equinor/[email protected]
Patch Changes
-
#2491
73af73eThanks @odinr! - Capatalize http request method verb to uppercase -
Updated dependencies [
73af73e,73af73e,73af73e,73af73e]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
-
#2493
4839295Thanks @eikeland! - Updating fusion-wc-person to fix issues when using selectedPerson = null in PersonSelect component.Updated the following dependencies
@equinor/fusion-wc-personfrom^3.0.1to^3.0.3inpackages/cli/package.jsonandpackages/react/components/people-resolver/package.json.
-
Updated dependencies [
4839295]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
- Updated dependencies [
73af73e,73af73e,73af73e,73af73e]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
- Updated dependencies [
c776845,2644b3d,15152e4]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
-
#2459
15152e4Thanks @odinr! - Update defaultScopes in WidgetConfigurator -
Updated dependencies [
c776845,2644b3d]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
- Updated dependencies [
2644b3d]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
- Updated dependencies [
15152e4,2644b3d]:- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
- Updated dependencies [
2644b3d]:- @equinor/[email protected]
@equinor/[email protected]
Patch Changes
- Updated dependencies [
15152e4]:- @equinor/[email protected]
- @equinor/[email protected]