Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Bip Bop - Fusion Framework Release #2492

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 2, 2024

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@equinor/[email protected]

Minor Changes

  • #2491 73af73e Thanks @odinr! - Added a new operator capitalizeRequestMethodOperator to ensure that the HTTP method of a given request is in uppercase.

    • Introduced capitalizeRequestMethodOperator which 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' });
  • #2491 73af73e Thanks @odinr! - The HttpClientConfigurator now has by default the capitalizeRequestMethodOperator and requestValidationOperator enabled.

    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 strict mode by setting the strict property to true:

    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 73af73e Thanks @odinr! - Added remove to the ProcessOperators to 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 the remove method, 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 the set method instead of remove and add.

  • #2491 73af73e Thanks @odinr! - New Feature: Enhanced requestValidationOperator

    The requestValidationOperator is a utility function that validates incoming requests against a Zod schema. This function has two options: strict and parse. The strict option allows you to enforce strict validation, while the parse option enables you to return the parsed request object if it passes validation.

    The requestValidationOperator is 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 strict is set to true, the validation will fail if there are additional properties not defined in the schema. If strict is set to false or omitted, additional properties will be allowed and passed through without causing validation errors.
    Parse Option When parse is enabled, the function will return the parsed and potentially transformed request object if it passes validation. If parse is not enabled, the function will not return anything even if the request object is valid.

    To use the new strict and parse options, 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

@equinor/[email protected]

Patch Changes

  • #2493 4839295 Thanks @eikeland! - Updating fusion-wc-person to fix issues when using selectedPerson = null in PersonSelect component.

    Updated the following dependencies

    • @equinor/fusion-wc-person from ^3.0.1 to ^3.0.3 in packages/cli/package.json and packages/react/components/people-resolver/package.json.
  • Updated dependencies [4839295]:

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

  • #2493 4839295 Thanks @eikeland! - Updating fusion-wc-person to fix issues when using selectedPerson = null in PersonSelect component.

    Updated the following dependencies

    • @equinor/fusion-wc-person from ^3.0.1 to ^3.0.3 in packages/cli/package.json and packages/react/components/people-resolver/package.json.
  • Updated dependencies [73af73e]:

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@equinor/[email protected]

Patch Changes

@github-actions github-actions bot requested review from odinr and a team as code owners October 2, 2024 06:45
@github-actions github-actions bot marked this pull request as draft October 2, 2024 06:45
@eikeland eikeland marked this pull request as ready for review October 2, 2024 09:21
@github-actions github-actions bot added 👨🏻‍🍳 cookbooks 👾 React 💾 CLI fusion framework CLI 📚 documentation Improvements or additions to documentation 🧬 Modules labels Oct 2, 2024
Copy link
Contributor Author

github-actions bot commented Oct 2, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 0.41% 1746 / 416453
🔵 Statements 0.41% 1746 / 416453
🔵 Functions 24.16% 216 / 894
🔵 Branches 37.99% 397 / 1045
File CoverageNo changed files found.
Generated in workflow #7823

@odinr odinr merged commit 626d45e into main Oct 2, 2024
7 checks passed
@odinr odinr deleted the changeset-release/main branch October 2, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💾 CLI fusion framework CLI 👨🏻‍🍳 cookbooks 📚 documentation Improvements or additions to documentation 🧬 Modules 👾 React
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants