-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Ts] ♻️ Replace quicktype
by ts-codegen
#39
Conversation
WalkthroughIn this update, key improvements include refined workflows excluding JSON files from the schema directory, transitioning to Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
quicktype
by ts-codegen
quicktype
by ts-codegen
2f47067
to
e01e9e8
Compare
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: 7
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (15)
- .github/workflows/build.yml (1 hunks)
- .github/workflows/publish.yml (1 hunks)
- .github/workflows/update-schema.yml (1 hunks)
- magefiles/build.go (3 hunks)
- magefiles/magefile.go (1 hunks)
- magefiles/schema.go (1 hunks)
- magefiles/utils.go (1 hunks)
- schema/axone-cognitarium.json (1 hunks)
- schema/axone-dataverse.json (1 hunks)
- schema/axone-law-stone.json (1 hunks)
- schema/axone-objectarium.json (1 hunks)
- ts/cognitarium-schema/package.json (1 hunks)
- ts/dataverse-schema/package.json (1 hunks)
- ts/law-stone-schema/package.json (1 hunks)
- ts/objectarium-schema/package.json (1 hunks)
Files not summarized due to errors (2)
- schema/axone-cognitarium.json: Error: Message exceeds token limit
- schema/axone-objectarium.json: Error: Message exceeds token limit
Files skipped from review due to trivial changes (1)
- magefiles/magefile.go
Additional comments not posted (29)
ts/law-stone-schema/package.json (1)
28-28
: Enhanced cleaning process in build scripts.The update to the
clean
script inpackage.json
ensures a more thorough cleanup by removing both thegen-ts
anddist
directories before rebuilding, which is a good practice to prevent potential issues from stale files.ts/dataverse-schema/package.json (1)
28-28
: Enhanced cleaning process in build scripts.Just like in the other schema configurations, updating the
clean
script to remove bothgen-ts
anddist
directories before rebuilding is a good practice to ensure a clean state for builds.ts/cognitarium-schema/package.json (1)
28-28
: Enhanced cleaning process in build scripts.Consistent with other schema configurations, the update to the
clean
script to include bothgen-ts
anddist
directories ensures a clean environment for each build, which is crucial for reliable outputs.
[APROVED]ts/objectarium-schema/package.json (1)
28-28
: Enhanced cleaning process in build scripts.This update to the
clean
script aligns with the changes made across other schema configurations. Removing bothgen-ts
anddist
directories before rebuilding is an effective way to maintain a clean build environment..github/workflows/build.yml (1)
24-24
: Optimized file selection in GitHub workflow.The modification to the
run
command in theset-matrix
job to exclude.json
files from the schema output is a thoughtful change. It likely optimizes the workflow process by focusing on relevant files, especially in the context of transitioning fromquicktype
tots-codegen
.magefiles/build.go (5)
20-20
: Ensure proper dependency management for TypeScript cleaning.The addition of a dependency on the
Clean.Ts
function is appropriate to ensure that TypeScript files are cleaned before rebuilding. This is a good practice to prevent potential issues from stale files.
24-24
: Proper toolchain setup is crucial.It's important to ensure that
ts-codegen
is available before attempting to generate TypeScript types. This change correctly introduces a dependency check which is crucial for build stability.
53-56
: Ensurequicktype
is available for Go type generation.Continuing to use
quicktype
for Go while transitioning TypeScript tots-codegen
is noted. It's critical to ensure thatquicktype
is properly checked before use, as done here.
73-81
: Introduction of TypeScript cleaning logic.Adding a dedicated cleaning function for TypeScript aligns with the overall goal of maintaining clean build environments. This method should effectively handle the removal of old TypeScript builds, ensuring that only fresh builds are processed.
26-34
: Check the implementation ofschemaDestination
for robustness.The use of
schemaDestination
to determine the output directory and schema name is crucial. Ensure that this function handles different schema formats and names correctly to avoid path issues..github/workflows/publish.yml (1)
26-26
: Ensure correct filtering of schemas in GitHub Actions.The modification to the
set-matrix
step to exclude.json
files usingjq
is crucial for correctly setting up the environment for subsequent steps. This change should help in accurately configuring the build matrix by excluding unnecessary files.magefiles/schema.go (1)
64-64
: Optimize rsync command for selective schema synchronization.The addition of specific
--include
and--exclude
flags in thersync
command is a good practice to ensure that only relevant schema files are moved. This should prevent unnecessary file transfers and optimize the build process.magefiles/utils.go (1)
112-126
: Ensure robust installation logic forts-codegen
.The addition of
ensureTsCodegen
function is crucial for the new TypeScript generation toolchain. The function checks ifts-codegen
is installed and installs it if not found. This is essential for build stability and should be carefully monitored for any issues during execution..github/workflows/update-schema.yml (1)
91-91
: Ensure correct filtering of schemas in GitHub Actions.The modification to the
set-matrix
step to exclude.json
files usingjq
is crucial for correctly setting up the environment for subsequent steps. This change should help in accurately configuring the build matrix by excluding unnecessary files.schema/axone-law-stone.json (4)
5-34
: Review of "InstantiateMsg" section:The instantiation message schema is well-defined, with clear descriptions and appropriate data types. The use of
$ref
to reference the "Binary" definition ensures consistency and reusability.
36-57
: Review of "ExecuteMsg" section:The "BreakStone" operation is well-documented, with a clear description of its purpose and the conditions under which it can be executed. The schema correctly enforces the structure of the message with
additionalProperties: false
, ensuring no unintended properties are included.
120-218
: Review of "Responses" section:The responses for different queries are well-structured and include all necessary information. The definitions for "Answer" and "Result" are particularly detailed, providing a comprehensive understanding of what to expect from the contract's responses.
248-250
: Review of contract description and metadata:The overall description provides a thorough overview of the contract's purpose and its operational context. It effectively communicates the contract's functionality and its integration within the broader ecosystem.
schema/axone-dataverse.json (4)
5-57
: Review of "InstantiateMsg" section:The instantiation message schema for the dataverse is comprehensive, with detailed descriptions and appropriate data types. The use of
$ref
to reference definitions like "TripleStoreConfig" ensures consistency and reusability.
149-216
: Review of "ExecuteMsg" section:The execution message types, "SubmitClaims" and "RevokeClaims", are well-documented with clear descriptions of their purposes and the conditions under which they can be executed. The schema correctly enforces the structure of the messages with
additionalProperties: false
, ensuring no unintended properties are included.
263-294
: Review of "Responses" section:The "DataverseResponse" is well-structured and includes all necessary information. The definition for "Addr" is particularly detailed, providing a comprehensive understanding of what to expect from the contract's responses.
296-298
: Review of contract description and metadata:The overall description provides a thorough overview of the contract's purpose and its operational context. It effectively communicates the contract's functionality and its integration within the broader ecosystem.
schema/axone-objectarium.json (3)
399-545
: Ensure comprehensive query capabilities.The
query
section should provide complete and clear information on what can be queried and any limitations or requirements. The current descriptions are good, but ensuring they are exhaustive helps prevent runtime errors and improves usability.
20-27
: Review default configuration for clarity and effectiveness.The default configuration for the bucket includes multiple compression algorithms and a hash algorithm. It's important to verify that these defaults align with the expected use cases and performance requirements of the contract.
64-90
: Validate immutability claim in property description.The description of
BucketConfig
claims that the configuration is immutable once set. This should be enforced in the contract logic, not just stated in the schema.schema/axone-cognitarium.json (4)
6-6
: Ensure consistent use of JSON Schema declaration.The
$schema
declaration is consistently used across different sections (instantiate
,execute
,query
). This is good practice as it ensures that the schema adheres to a specific version of JSON Schema, in this case, Draft 07.Also applies to: 104-104, 686-686
1878-1880
: Review documentation and descriptions.The description at the end of the file provides a comprehensive overview of the smart contract's capabilities. Ensure that this description is kept up-to-date with the actual functionality of the contract as it evolves.
1-1
: Check the JSON format.Ensure that the JSON file is well-formed and valid. This is crucial for parsing and utilizing the schema correctly.
Verification successful
The JSON format is valid.
The
jq
command executed without any errors, confirming that the JSON structure is well-formed and valid.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check JSON format validity. # Test: Validate JSON structure. Expect: No errors. jq empty schema/axone-cognitarium.jsonLength of output: 40
108-191
: Validate conditional structures and references.The
oneOf
structure used in theexecute
section is correctly implemented, allowing different types of execution messages. However, ensure that all referenced definitions (likeBinary
andDataFormat
) are consistent and correctly defined elsewhere in the document.Verification successful
Referenced definitions are correctly implemented.
The
Binary
andDataFormat
definitions are accurately defined and consistent with their usage in theexecute
section of the schema.
Binary
is defined as a string with a detailed description.DataFormat
includes multiple formats likeRDF XML
andTurtle
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify referenced definitions in schema. # Test: Search for definitions of Binary and DataFormat. Expect: Definitions should exist and be consistent. grep -A 20 '"Binary":' schema/axone-cognitarium.json grep -A 20 '"DataFormat":' schema/axone-cognitarium.jsonLength of output: 6252
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: 0
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.
Looks good to me, thanks ! 👌
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.
Perfect 👍
Due to issues encountered with the quicktype library, specifically in relation to the generated
cognitarium
schema type (refer to issue #9), we have decided to switch to the ts-codegen library. ts-codegen has been specifically designed for smart-contract schemas, making it a more suitable choice for our project.This PR removes the usage of quicktype for TypeScript (the removal for Go will be addressed in the upcoming PR #38) and generates new schema types using ts-codegen.
In addition to the switch in libraries, this PR also includes modifications to the package.json file and introduces a cleaning step to generated typescript files.
Summary by CodeRabbit
New Features
axone-law-stone
andaxone-dataverse
contracts.Enhancements
ts-codegen
for improved performance.dist
directories for more thorough cleaning.Bug Fixes
.json
files from specific workflow processes to prevent unnecessary operations.Chores
schema
directory from the review process.