Skip to content

fix: support include keyword in thrift ts generation #178

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

Merged
merged 10 commits into from
Jan 8, 2025

Conversation

ken-zlai
Copy link
Contributor

@ken-zlai ken-zlai commented Jan 7, 2025

Summary

This PR removes the thrift-typescript package and its usage, as Thrift supports TypeScript generation natively. Using Thrift's built-in TypeScript support simplifies our workflow and eliminates the need for the additional dependency, as well as out of the box support for the include keyword.

Changes

  • Removed thrift-typescript packages from the project.
  • Replaced the existing setup with Thrift's native TypeScript generation.
  • Updated the Thrift configuration and build process to align with the new approach.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

Based on the comprehensive changes, here are the release notes:

  • Code Generation

    • Replaced Thrift-based code generation with a new approach
    • Introduced new TypeScript declaration files for API, common, observability, and orchestration types
    • Removed previous Thrift-generated TypeScript files
  • Dependency Management

    • Removed Thrift-related dependencies from package.json
    • Updated code generation script to use a custom shell script
  • Development Workflow

    • Updated ESLint configuration to ignore generated type files
    • Simplified type generation process

Copy link

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces a comprehensive refactoring of the frontend's Thrift-related type definitions and code generation process. The changes involve removing multiple Thrift-generated TypeScript files, introducing new type declaration files, and modifying the code generation script to use a shell-based approach instead of direct Thrift TypeScript generation.

Changes

File Change Summary
.github/workflows/test_frontend.yaml Updated workflow configuration with double quotes and added Thrift compiler installation step
frontend/package.json Replaced Thrift-related dependencies and modified codegen script to use shell script
frontend/scripts/codegen.sh New shell script for generating TypeScript definitions
frontend/src/lib/types/codegen/ Removed multiple Thrift-generated files, added new type declaration and implementation files
frontend/eslint.config.js Added src/lib/types/codegen to ignored paths in ESLint config

Possibly related PRs

Poem

🧩 Thrift types dancing away,
Shell scripts take the lead today
Codegen's new melodic tune
Refactoring under the coder's moon! 🌙

Warning

Review ran into problems

🔥 Problems

GitHub Actions: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 4539829 and 0cd2112.

📒 Files selected for processing (1)
  • frontend/eslint.config.js (1 hunks)
🔇 Additional comments (1)
frontend/eslint.config.js (1)

40-40: LGTM! Verify the path exists.

✅ Verification successful

✓ Path verified: src/lib/types/codegen exists and is correctly ignored

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the ignored path exists
fd --type directory "codegen$" src/lib/types/

Length of output: 149


Script:

#!/bin/bash
# Search for relevant directories
echo "=== Types directories ==="
fd --type directory "types$"
echo -e "\n=== Codegen directories ==="
fd --type directory "codegen$"
echo -e "\n=== Frontend structure ==="
ls -la frontend/src 2>/dev/null || echo "frontend/src not found"

Length of output: 789


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@ken-zlai ken-zlai marked this pull request as ready for review January 7, 2025 21:22
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: 5

🧹 Nitpick comments (3)
frontend/src/lib/types/codegen/orchestration_types.d.ts (2)

66-71: Add more detailed JSDoc comments.

The current documentation for TabularData could be more descriptive about the purpose of each field.


108-119: Enhance documentation for NodeConnections.

The multi-pass explanation could benefit from clearer examples of how the hashes are used.

.github/workflows/test_frontend.yaml (1)

36-39: Optimize apt-get commands.

Combine update and install commands to reduce layers and add -qq flag for quieter output.

-          sudo apt-get update
-          sudo apt-get install -y thrift-compiler
+          sudo apt-get update -qq && sudo apt-get install -qq -y thrift-compiler
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between ca25fef and 4539829.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (48)
  • .github/workflows/test_frontend.yaml (4 hunks)
  • frontend/package.json (2 hunks)
  • frontend/scripts/codegen.sh (1 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Accuracy.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Aggregation.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/AggregationPart.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/BootstrapPart.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Cardinality.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/DataField.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/DataKind.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/DataSpec.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Derivation.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/DriftMetric.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/DriftSpec.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/EntitySource.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/EventSource.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/ExternalPart.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/ExternalSource.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/GroupBy.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/GroupByServingInfo.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Join.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/JoinPart.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/JoinSource.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/LabelPart.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/MetaData.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Model.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/ModelType.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Operation.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Query.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Source.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/StagingQuery.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TDataType.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TileDrift.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TileDriftSeries.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TileKey.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TileSeriesKey.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TileSummary.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TileSummarySeries.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/TimeUnit.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/Window.ts (0 hunks)
  • frontend/src/lib/types/codegen/ai/chronon/api/index.ts (0 hunks)
  • frontend/src/lib/types/codegen/api_types.d.ts (1 hunks)
  • frontend/src/lib/types/codegen/common_types.d.ts (1 hunks)
  • frontend/src/lib/types/codegen/common_types.js (1 hunks)
  • frontend/src/lib/types/codegen/observability_types.d.ts (1 hunks)
  • frontend/src/lib/types/codegen/observability_types.js (1 hunks)
  • frontend/src/lib/types/codegen/orchestration_types.d.ts (1 hunks)
  • frontend/src/lib/types/codegen/orchestration_types.js (1 hunks)
💤 Files with no reviewable changes (38)
  • frontend/src/lib/types/codegen/ai/chronon/api/DataKind.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Accuracy.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Cardinality.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/ModelType.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/JoinPart.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/LabelPart.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/DataSpec.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Query.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/DriftMetric.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TDataType.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/GroupBy.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/GroupByServingInfo.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Join.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TileKey.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/StagingQuery.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/AggregationPart.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Derivation.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Operation.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TimeUnit.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/JoinSource.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/EntitySource.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TileSummary.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/EventSource.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Model.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Aggregation.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/MetaData.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/DataField.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/BootstrapPart.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TileDriftSeries.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/ExternalSource.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/ExternalPart.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/DriftSpec.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TileSeriesKey.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Source.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TileDrift.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/TileSummarySeries.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/Window.ts
  • frontend/src/lib/types/codegen/ai/chronon/api/index.ts
✅ Files skipped from review due to trivial changes (2)
  • frontend/src/lib/types/codegen/common_types.d.ts
  • frontend/src/lib/types/codegen/observability_types.d.ts
🧰 Additional context used
🪛 Biome (1.9.4)
frontend/src/lib/types/codegen/common_types.js

[error] 6-6: This variable is used before its declaration.

The variable is declared here:

(lint/correctness/noInvalidUseBeforeDeclaration)


[error] 18-19: A global variable should not be reassigned.

Assigning to a global variable can override essential functionality.

(lint/suspicious/noGlobalAssign)

frontend/src/lib/types/codegen/orchestration_types.js

[error] 565-565: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 577-577: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 676-676: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 689-689: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1060-1060: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1160-1160: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1889-1889: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 6-6: This variable is used before its declaration.

The variable is declared here:

(lint/correctness/noInvalidUseBeforeDeclaration)

frontend/src/lib/types/codegen/observability_types.js

[error] 277-277: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 289-289: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 322-322: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 334-334: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 694-694: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 698-698: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 713-713: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 718-718: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 733-733: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 745-745: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 757-757: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 769-769: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 781-781: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 785-785: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 800-800: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 804-804: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 819-819: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1209-1209: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1221-1221: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1233-1233: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1245-1245: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1257-1257: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1269-1269: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1281-1281: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1293-1293: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1305-1305: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1467-1467: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1479-1479: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1492-1492: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 1510-1510: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 6-6: This variable is used before its declaration.

The variable is declared here:

(lint/correctness/noInvalidUseBeforeDeclaration)

🔇 Additional comments (4)
frontend/src/lib/types/codegen/api_types.d.ts (1)

1-309: LGTM!

The type definitions are comprehensive and correctly structured.

frontend/src/lib/types/codegen/common_types.js (1)

18-19: ⚠️ Potential issue

Avoid Reassigning Global Variables

Declare TimeUnit using const, let, or var to prevent overriding global variables.

Apply this diff:

- TimeUnit = {
+ const TimeUnit = {

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 18-19: A global variable should not be reassigned.

Assigning to a global variable can override essential functionality.

(lint/suspicious/noGlobalAssign)

frontend/src/lib/types/codegen/orchestration_types.js (1)

565-565: ⚠️ Potential issue

Replace hasOwnProperty with Object.hasOwn().

Using hasOwnProperty directly is unsafe as it can be overridden. Use Object.hasOwn() instead.

-if (this.parents.hasOwnProperty(iter8))
+if (Object.hasOwn(this.parents, iter8))

Also applies to: 577-577, 676-676, 689-689, 1060-1060, 1160-1160, 1889-1889

🧰 Tools
🪛 Biome (1.9.4)

[error] 565-565: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)

frontend/package.json (1)

68-68: Consider updating tailwind-variants

Current: 0.3.0, Latest may have improvements.

output.writeFieldBegin('percentiles', Thrift.Type.LIST, 1);
output.writeListBegin(Thrift.Type.DOUBLE, this.percentiles.length);
for (var iter17 in this.percentiles) {
if (this.percentiles.hasOwnProperty(iter17)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use Object.hasOwn() Instead of hasOwnProperty

Replace hasOwnProperty calls with Object.hasOwn() to prevent potential prototype pollution issues.

Apply this diff:

- if (this.percentiles.hasOwnProperty(iter17)) {
+ if (Object.hasOwn(this.percentiles, iter17)) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (this.percentiles.hasOwnProperty(iter17)) {
if (Object.hasOwn(this.percentiles, iter17)) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 277-277: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)

output.writeFieldBegin('histogram', Thrift.Type.MAP, 2);
output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.I64, Thrift.objectLength(this.histogram));
for (var kiter18 in this.histogram) {
if (this.histogram.hasOwnProperty(kiter18)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use Object.hasOwn() Instead of hasOwnProperty

Replace this.histogram.hasOwnProperty(kiter18) with Object.hasOwn(this.histogram, kiter18).

Apply this diff:

- if (this.histogram.hasOwnProperty(kiter18)) {
+ if (Object.hasOwn(this.histogram, kiter18)) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (this.histogram.hasOwnProperty(kiter18)) {
if (Object.hasOwn(this.histogram, kiter18)) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 289-289: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)

//
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
//
if (typeof Int64 === 'undefined' && typeof require === 'function') {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Declare Int64 Before Use

Int64 is used before it is declared. Initialize it before the condition.

Apply this diff:

- if (typeof Int64 === 'undefined' && typeof require === 'function') {
+ var Int64;
+ if (typeof Int64 === 'undefined' && typeof require === 'function') {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (typeof Int64 === 'undefined' && typeof require === 'function') {
var Int64;
if (typeof Int64 === 'undefined' && typeof require === 'function') {
🧰 Tools
🪛 Biome (1.9.4)

[error] 6-6: This variable is used before its declaration.

The variable is declared here:

(lint/correctness/noInvalidUseBeforeDeclaration)

Comment on lines +1 to +10
#!/bin/bash

THRIFT_DIR="../api/thrift"
OUT_DIR="src/lib/types/codegen"

mkdir -p $OUT_DIR

for file in $THRIFT_DIR/*.thrift; do
thrift -r -out $OUT_DIR --gen js:ts "$file"
done
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling and validation.

The script needs:

  1. Error checking for thrift command
  2. Path validation
  3. Exit on error
 #!/bin/bash
+set -euo pipefail
 
 THRIFT_DIR="../api/thrift"
 OUT_DIR="src/lib/types/codegen"
 
+if ! command -v thrift &> /dev/null; then
+    echo "Error: thrift compiler not found"
+    exit 1
+fi
+
+if [ ! -d "$THRIFT_DIR" ]; then
+    echo "Error: Thrift directory not found"
+    exit 1
+fi
+
 mkdir -p $OUT_DIR
 
 for file in $THRIFT_DIR/*.thrift; do
     thrift -r -out $OUT_DIR --gen js:ts "$file"
 done
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
THRIFT_DIR="../api/thrift"
OUT_DIR="src/lib/types/codegen"
mkdir -p $OUT_DIR
for file in $THRIFT_DIR/*.thrift; do
thrift -r -out $OUT_DIR --gen js:ts "$file"
done
#!/bin/bash
set -euo pipefail
THRIFT_DIR="../api/thrift"
OUT_DIR="src/lib/types/codegen"
if ! command -v thrift &> /dev/null; then
echo "Error: thrift compiler not found"
exit 1
fi
if [ ! -d "$THRIFT_DIR" ]; then
echo "Error: Thrift directory not found"
exit 1
fi
mkdir -p $OUT_DIR
for file in $THRIFT_DIR/*.thrift; do
thrift -r -out $OUT_DIR --gen js:ts "$file"
done

@@ -6,7 +6,7 @@
"prepare": "npm run codegen",
"dev": "npm run codegen && vite dev",
"build": "npm run codegen && vite build",
"codegen": "thrift-typescript --target thrift-server --rootDir .. --sourceDir api/thrift --outDir frontend/src/lib/types/codegen api.thrift",
"codegen": "bash scripts/codegen.sh",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Fix codegen script permissions and implementation

  • Script needs executable permissions (chmod +x)
  • Relative paths may break; use $(dirname "$0")/.. for reliable paths
  • Thrift CLI tool dependency needs to be documented
🔗 Analysis chain

Verify codegen shell script existence

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the codegen script exists and is executable
if [ -f "frontend/scripts/codegen.sh" ]; then
    ls -l frontend/scripts/codegen.sh
else
    echo "Error: codegen.sh not found"
    exit 1
fi

Length of output: 152


Script:

#!/bin/bash
# View codegen script content
cat frontend/scripts/codegen.sh

Length of output: 216

@ken-zlai ken-zlai changed the title Ken/thrift ts frontend fix: support include keyword in thrift ts generation Jan 7, 2025
@ken-zlai ken-zlai requested a review from sean-zlai January 7, 2025 22:06
Copy link
Contributor

@sean-zlai sean-zlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. So nice to remove some dependencies (and glob override) and improve compat. Thanks @ken-zlai!

@ken-zlai ken-zlai merged commit 8aede2d into main Jan 8, 2025
4 checks passed
@ken-zlai ken-zlai deleted the ken/thrift-ts-frontend branch January 8, 2025 16:16
tchow-zlai pushed a commit that referenced this pull request Jan 9, 2025
## Summary
This PR removes the `thrift-typescript` package and its usage, as Thrift
supports TypeScript generation natively. Using Thrift's built-in
TypeScript support simplifies our workflow and eliminates the need for
the additional dependency, as well as out of the box support for the
`include` keyword.

### Changes

- Removed `thrift-typescript` packages from the project.
- Replaced the existing setup with Thrift's native TypeScript
generation.
- Updated the Thrift configuration and build process to align with the
new approach.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

Based on the comprehensive changes, here are the release notes:

- **Code Generation**
	- Replaced Thrift-based code generation with a new approach
- Introduced new TypeScript declaration files for API, common,
observability, and orchestration types
	- Removed previous Thrift-generated TypeScript files

- **Dependency Management**
	- Removed Thrift-related dependencies from `package.json`
	- Updated code generation script to use a custom shell script

- **Development Workflow**
	- Updated ESLint configuration to ignore generated type files
	- Simplified type generation process

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Thomas Chow <[email protected]>
kumar-zlai pushed a commit that referenced this pull request Apr 25, 2025
## Summary
This PR removes the `thrift-typescript` package and its usage, as Thrift
supports TypeScript generation natively. Using Thrift's built-in
TypeScript support simplifies our workflow and eliminates the need for
the additional dependency, as well as out of the box support for the
`include` keyword.

### Changes

- Removed `thrift-typescript` packages from the project.
- Replaced the existing setup with Thrift's native TypeScript
generation.
- Updated the Thrift configuration and build process to align with the
new approach.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

Based on the comprehensive changes, here are the release notes:

- **Code Generation**
	- Replaced Thrift-based code generation with a new approach
- Introduced new TypeScript declaration files for API, common,
observability, and orchestration types
	- Removed previous Thrift-generated TypeScript files

- **Dependency Management**
	- Removed Thrift-related dependencies from `package.json`
	- Updated code generation script to use a custom shell script

- **Development Workflow**
	- Updated ESLint configuration to ignore generated type files
	- Simplified type generation process

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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