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

fix: resolve mathjs runtime configuration conflict #68

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

jotanarciso
Copy link
Collaborator

@jotanarciso jotanarciso commented Nov 14, 2024

Error using imports from the root package azion in edge-runtime:

TypeError: The argument to 'typed' at index 1 is not a function (typed), nor an object with signatures as keys and functions as values. data: { index: 1, argument: { number: [Function], 'Complex | BigNumber | Fraction | Unit': [Function: Complex | BigNumber | Fraction | Unit], bigint: [Function: bigint], 'Matrix | Matrix': [Object] }

Solution:

1 - Create an isolated instance of mathjs that has its own scope and does not interfere with the global environment, keeping its configurations encapsulated.

Copy link

Summary of the Pull Request

This pull request introduces two main components:

  1. Azion Client Creation:

    • The createClient function in packages/client/src/index.ts is implemented to facilitate interaction with various Azion services. It constructs a client object that includes methods for interacting with Azion's Edge Storage, SQL, Purge, Domains, Applications, and AI services.
    • The function accepts a configuration object that includes an authentication token and an optional debug mode setting.
    • The client is designed to be flexible, allowing for the use of environment variables for configuration.
  2. Cache Process Configuration Strategy:

    • The CacheProcessConfigStrategy class in packages/config/src/processConfig/strategy/implementations/cacheProcessConfigStrategy.ts is implemented to handle cache configuration strategies.
    • It includes methods to transform configuration data into a manifest format and vice versa, utilizing mathematical expression evaluation for cache settings.

Good Practices

  • Modular Design: The use of separate clients for different services (e.g., Storage, SQL, Purge) promotes modularity and separation of concerns.
  • TypeScript Usage: The use of TypeScript types enhances code readability and helps catch errors during development.
  • Documentation: The code is well-documented with JSDoc comments, providing clear explanations of the functions and their parameters.
  • Mathematical Expression Handling: The evaluateMathExpression function safely evaluates mathematical expressions, ensuring that only valid expressions are processed.

Possible Problems

  • Error Handling: The evaluateMathExpression function throws an error if the expression is not purely mathematical. Consider implementing more robust error handling or logging to provide more context in case of failures.
  • Type Safety: The use of any in several places could be replaced with more specific types to enhance type safety and maintainability.

Suggestions for Improvement

  • Enhanced Error Handling: Implement more descriptive error messages or logging mechanisms to aid in debugging and provide more context when errors occur.
  • Type Refinement: Replace any types with more specific types to improve type safety and code clarity.
  • Unit Testing: Ensure that unit tests are in place to cover the new functionality, particularly for the mathematical expression evaluation and transformation logic.
  • Environment Configuration: Consider adding more detailed instructions or examples for configuring the client using environment variables to aid developers in setup.

Overall, the pull request introduces useful functionality for interacting with Azion services and managing cache configurations, with opportunities for enhancing error handling and type safety.


Powered by Azion Logo Azion AI

@jotanarciso jotanarciso changed the base branch from main to stage November 14, 2024 14:09
@jotanarciso jotanarciso merged commit 04ac164 into stage Nov 14, 2024
2 checks passed
@jotanarciso
Copy link
Collaborator Author

🎉 This PR is included in version 1.11.1-stage.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jotanarciso
Copy link
Collaborator Author

🎉 This PR is included in version 1.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants