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

feat: add some documentation details #290

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

MartianGreed
Copy link
Collaborator

@MartianGreed MartianGreed commented Oct 4, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new TypeScript interfaces and enumerations to enhance the structure and type safety of the Dojo SDK.
    • Added an enumeration Direction with values: None, Up, Down, Left, and Right.
    • Defined interfaces for Moves, DirectionAvailable, Pos, Position, and MockSchemaType for better game state management.
  • Documentation

    • Updated usage examples for initializing the SDK and querying entities to reflect the new schema structure.
    • Clarified the usage of relayUrl in the init function for sending signed messages.

Copy link

coderabbitai bot commented Oct 4, 2024

Walkthrough

This pull request introduces new TypeScript interfaces and an enumeration to the Dojo SDK, enhancing type safety and structure. It includes the Direction enumeration with five values and several interfaces: Moves, DirectionAvailable, Pos, Position, and MockSchemaType. The schema object is updated to incorporate these new models, and usage examples are revised to demonstrate their implementation. Additionally, documentation clarifies the configuration of the relayUrl in the init function for message broadcasting.

Changes

File Path Change Summary
packages/sdk/readme.md Added enumeration Direction and interfaces Moves, DirectionAvailable, Pos, Position, and MockSchemaType. Updated schema object and usage examples to reflect new models. Clarified documentation on relayUrl in the init function.

Possibly related PRs

  • feat: new readme #286: The changes in this PR involve updates to the readme.md file that reflect modifications to the SDK initialization process and schema structure, which are directly related to the new interfaces and enumerations introduced in the main PR.

Poem

In the land of code where rabbits play,
New types and enums hop into the fray.
With Direction to guide, and Moves to explore,
The SDK blooms, like never before!
So let’s code with glee, let our logic run free,
In this wondrous world of TypeScript harmony! 🐇✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (5)
packages/sdk/readme.md (5)

90-125: LGTM! Consider a minor naming consistency improvement.

The newly added Direction enum and interfaces (Moves, DirectionAvailable, Pos, Position, and MockSchemaType) are well-defined and consistent with the expected schema structure. They provide a clear type definition for the Dojo SDK.

For consistency, consider renaming the DirectionAvailable interface to DirectionsAvailable to match the usage in the schema object below (line 140). This will ensure perfect alignment between the interface and the schema definition.


Line range hint 128-150: Update Moves model for consistency with its interface.

The schema object is correctly updated to include the new models under the dojo_starter namespace. However, there's a minor inconsistency in the Moves model:

The Moves model in the schema includes a remaining field (line 134) that is not present in the Moves interface (lines 98-103). To maintain consistency, either:

  1. Add the remaining field to the Moves interface:
interface Moves {
    fieldOrder: string[];
    player: string;
    remaining: number; // Add this line
    last_direction: Direction;
    can_move: boolean;
}
  1. Or remove the remaining field from the schema object:
Moves: {
    fieldOrder: ["player", "last_direction", "can_move"],
    player: "",
    last_direction: Direction.None,
    can_move: false,
},

Please choose the option that best reflects the intended structure of the Moves model.


Line range hint 152-180: LGTM! Consider adding a note about type generation.

The updated SDK initialization example correctly demonstrates how to use the new MockSchemaType interface. This provides a clear guide for developers on how to initialize the SDK with the new schema structure.

To further improve clarity, consider adding a note reminding developers to regenerate their TypeScript types using sozo build --typescript-v2 after making changes to their world schema. This will ensure that the MockSchemaType stays in sync with the actual schema. You could add this note just before the initialization example:

**Note:** Remember to regenerate your TypeScript types using `sozo build --typescript-v2` after making changes to your world schema to keep your `MockSchemaType` up to date.

190-197: LGTM! Consider adjusting the markdown formatting.

The added table of query operators provides a clear and concise overview of the available operators for filtering in queries. This is valuable information for developers using the SDK.

To address the Markdownlint hint and improve consistency with the rest of the document, consider changing the indented code block to a fenced code block. Here's how you can format it:

| Operator | Description              |
| -------- | ------------------------ |
| `$eq`    | Equal to                 |
| `$neq`   | Not equal to             |
| `$gt`    | Greater than             |
| `$gte`   | Greater than or equal to |
| `$lt`    | Less than                |
| `$lte`   | Less than or equal to    |

This change will resolve the Markdownlint warning and maintain consistent formatting throughout the document.

🧰 Tools
🪛 Markdownlint

190-190: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


269-272: LGTM! Consider adding an example configuration.

The added note about the relayUrl is crucial for developers to understand how to properly configure message broadcasting. This information aligns well with the SDK's functionality and helps prevent potential issues.

To further enhance clarity, consider adding a brief example of how to set the relayUrl in the init function. This could be added right after the existing note:

// Example of setting the relayUrl in the init function
const db = await init<MockSchemaType>(
  {
    client: {
      // ... other configuration options
      relayUrl: "/dns4/api.cartridge.gg/tcp/443/x-parity-wss/%2Fx%2Fonchain-dash%2Ftorii%2Fwss",
    },
    // ... rest of the configuration
  },
  schema
);

This example will provide developers with a clear reference on how to properly set the relayUrl in their configuration.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5b3017e and 4b8f93e.

📒 Files selected for processing (1)
  • packages/sdk/readme.md (5 hunks)
🧰 Additional context used
🪛 Markdownlint
packages/sdk/readme.md

190-190: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)

@ponderingdemocritus ponderingdemocritus merged commit 65f9a7b into main Oct 4, 2024
2 of 3 checks passed
@ponderingdemocritus ponderingdemocritus deleted the feat/sdk-readme-naming-conventions branch October 4, 2024 09:28
@coderabbitai coderabbitai bot mentioned this pull request Oct 5, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants