-
Notifications
You must be signed in to change notification settings - Fork 54
fix: types #304
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: types #304
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
packages/sdk/src/getEntities.ts (1)
52-52
: Approve: Enhanced query control withdont_include_hashed_keys
The addition of the
dont_include_hashed_keys
property to thetoriiQuery
object is a valuable enhancement. It provides more granular control over the query behavior, allowing hashed keys to be included only when specific entity IDs are provided in the query. This change aligns well with the function's purpose and increases its flexibility.However, the boolean logic can be simplified for better readability:
Consider simplifying the boolean expression:
-dont_include_hashed_keys: query.entityIds ? false : true, +dont_include_hashed_keys: !query.entityIds,This change maintains the same logic while making it more concise and easier to understand at a glance.
🧰 Tools
🪛 Biome
[error] 52-52: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/sdk/src/getEntities.ts (1 hunks)
- packages/sdk/src/getEventMessages.ts (1 hunks)
🧰 Additional context used
🪛 Biome
packages/sdk/src/getEntities.ts
[error] 52-52: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
🔇 Additional comments (2)
packages/sdk/src/getEntities.ts (2)
Line range hint
1-51
: LGTM: Addition ofschema
parameter enhances type safetyThe addition of the
schema
parameter of typeT
to thegetEntities
function signature is a positive change. It allows for more type-safe operations within the function, particularly when converting the query to a clause usingconvertQueryToClause(query, schema)
. This modification aligns well with the function's TypeScript generic constraintT extends SchemaType
and enhances the overall type safety of the function.Also applies to: 53-89
🧰 Tools
🪛 Biome
[error] 52-52: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
Line range hint
1-89
: Verify: Impact of changes on function usage and behaviorThe modifications to the
getEntities
function introduce some important changes that may impact its usage and behavior:
- The addition of the
schema
parameter is a breaking change. All existing calls to this function will need to be updated to include the schema argument.- The new
dont_include_hashed_keys
property in the query may alter the results returned by the function, potentially affecting dependent code.To mitigate risks associated with these changes:
- Ensure all calls to
getEntities
across the codebase are updated to include theschema
parameter.- Review and test any code that depends on the results of
getEntities
to verify it handles the potential inclusion/exclusion of hashed keys correctly.- Consider updating the function's documentation to clearly explain the new
schema
parameter and the behavior ofdont_include_hashed_keys
.To help identify potential issues, you can run the following script:
This script will help identify calls to
getEntities
that may need updating and code that processes the results ofgetEntities
, which might be affected by the changes in hashed key handling.🧰 Tools
🪛 Biome
[error] 52-52: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
@@ -49,6 +49,7 @@ export async function getEventMessages<T extends SchemaType>( | |||
limit: limit, | |||
offset: cursor, | |||
clause, | |||
dont_include_hashed_keys: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Update torii.Query
type definition to include dont_include_hashed_keys
The property dont_include_hashed_keys: true
is being used in several instances of getEventMessages
, but it is not defined in the torii.Query
type. This inconsistency can lead to type errors and unexpected behaviors across the codebase.
Action Items:
-
Update Type Definitions:
- Add
dont_include_hashed_keys?: boolean
to thetorii.Query
type to ensure it is recognized across all usages.
- Add
-
Ensure Consistency:
- Verify that all instances of
getEventMessages
either include this property or handle its absence appropriately.
- Verify that all instances of
-
Update Documentation:
- Reflect the addition of
dont_include_hashed_keys
in the JSDoc comments and any relevant documentation to inform users of its purpose and usage.
- Reflect the addition of
-
Review Usage:
- Check for any conditional logic that relies on the presence or absence of
dont_include_hashed_keys
to ensure consistent behavior.
- Check for any conditional logic that relies on the presence or absence of
Category:
🔗 Analysis chain
Update documentation and consider backwards compatibility for dont_include_hashed_keys
The addition of dont_include_hashed_keys: true
to the toriiQuery
object modifies the behavior of the query sent to the Torii client. While this change may improve performance by reducing the amount of data returned, it raises several concerns:
- The function's JSDoc comments don't mention this new behavior, which could lead to confusion for users of the SDK.
- This change might break existing code that expects hashed keys to be present in the query results.
- The type definition for
torii.Query
may need to be updated to include this new property.
To address these issues, consider the following:
- Update the function's JSDoc comments to explain the purpose and impact of
dont_include_hashed_keys
. - Consider making this behavior optional by adding a parameter to the function, allowing users to choose whether to include hashed keys or not.
- Update the
torii.Query
type definition if necessary. - If this is a breaking change, consider versioning the SDK appropriately and documenting the change in the changelog.
To verify the impact of this change, we can search for other usages of getEventMessages
in the codebase:
This will help us understand if other parts of the codebase might be affected by this change.
[/run_scripts]
[/run_scripts]
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for usages of getEventMessages
rg --type typescript 'getEventMessages\(' -A 10
Length of output: 84
Script:
#!/bin/bash
# Search for usages of getEventMessages in TypeScript files using correct file type
rg --type ts 'getEventMessages\(' -A 10
# If the above does not work, search using file extensions directly
rg 'getEventMessages\(' --glob '*.ts' --glob '*.tsx' -A 10
Length of output: 5598
Script:
#!/bin/bash
# Search for the definition of torii.Query type
ast-grep --lang typescript --pattern 'type torii\.Query {$$$}' packages/sdk/src/**/*.ts
# Alternatively, search for interfaces named torii.Query
rg 'interface\s+torii\.Query' --glob '*.ts'
# Check for occurrences of dont_include_hashed_keys in type definitions
rg 'dont_include_hashed_keys' --glob '*.ts'
Length of output: 1374
Summary by CodeRabbit
New Features
getEntities
function with a new required parameter for improved entity fetching control.getEventMessages
function to modify query behavior with a new property for data structure adjustments.Bug Fixes
getEntities
andgetEventMessages
functions.