Skip to content

chore: add proto for typescript#3903

Merged
chronark merged 2 commits intomainfrom
09-01-chore_add_proto_for_typescript
Sep 18, 2025
Merged

chore: add proto for typescript#3903
chronark merged 2 commits intomainfrom
09-01-chore_add_proto_for_typescript

Conversation

@chronark
Copy link
Collaborator

@chronark chronark commented Sep 1, 2025

What does this PR do?

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • Chores
    • Added an internal package to publish generated TypeScript types and RPC clients.
    • Enabled TypeScript code generation for protobuf and RPC artifacts in the build pipeline.
    • Updated dashboard dependencies to support Connect-based RPC and shared proto types.
    • Introduced TypeScript configuration for the new internal package.
  • New Features
    • Centralized access to generated service types and clients via a single entry point (no UI changes).

@changeset-bot
Copy link

changeset-bot bot commented Sep 1, 2025

⚠️ No Changeset found

Latest commit: fe748f1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Sep 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dashboard Ready Ready Preview Comment Sep 18, 2025 7:43am
engineering Ready Ready Preview Comment Sep 18, 2025 7:43am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 1, 2025

📝 Walkthrough

Walkthrough

Adds TypeScript codegen plugins to buf.gen.yaml, introduces an internal ESM package @unkey/proto with tsconfig and re-exports of generated proto artifacts, and updates the dashboard app package.json to depend on Connect libraries and the workspace @unkey/proto package.

Changes

Cohort / File(s) Summary of Changes
Dashboard dependency updates
apps/dashboard/package.json
Added runtime dependencies: @connectrpc/connect (^2.1.0), @connectrpc/connect-web (^2.1.0), and workspace dependency @unkey/proto (workspace:^).
Buf TS codegen
go/buf.gen.yaml
Appended TypeScript codegen plugins bufbuild/es v1.10.0 and connectrpc/es v1.6.1; outputs written to ../internal/proto/generated with opt: target=ts.
Internal proto package
internal/proto/package.json, internal/proto/tsconfig.json, internal/proto/src/index.ts
New private ESM package @unkey/proto (v0.0.1) with devDeps for Buf/TS tooling and runtime deps @bufbuild/protobuf / @connectrpc/connect; tsconfig includes src/**/* and generated/**/*, outDir ./dist; src/index.ts re-exports generated proto/ctrl/v1/deployment_pb and deployment_connect.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Developer
    participant Buf as buf (codegen)
    participant Gen as Generated (../internal/proto/generated)
    participant ProtoPkg as @unkey/proto
    participant Dashboard as apps/dashboard

    Developer->>Buf: run buf generate (go + TS plugins)
    Buf-->>Gen: write TS artifacts (target=ts)
    Gen->>ProtoPkg: included by package (src/index.ts re-exports)
    Dashboard->>ProtoPkg: import @unkey/proto (workspace)
    Dashboard->>Dashboard: use Connect clients/types
    note right of Buf#cccccc: New TS plugins added\n(bufbuild/es, connectrpc/es)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • mcstepp
  • ogzhanolguncu
  • perkinsjr
  • MichaelUnkey

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is largely an unfilled template: it contains placeholders, no issue number in the "Fixes" line, no selected type-of-change, no concrete "How should this be tested?" steps, and the checklist items are unchecked, so it is incomplete for review. Please update the description with a short summary of the change and motivation, add the relevant issue number in "Fixes #", mark the appropriate type-of-change checkbox, provide concrete test instructions (commands to run, expected results, environment), complete the required checklist items (e.g., run and confirm pnpm build, pnpm fmt, remove console.logs), and include a brief list of key files changed (internal/proto package files, buf.gen additions, tsconfig, and export aggregator).
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "chore: add proto for typescript" is concise and accurately reflects the primary change in the diff (adding TypeScript proto generation, a new internal/proto package, tsconfig, and buf/connect TS codegen), so it gives a reviewer a clear, high-level summary of the change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 09-01-chore_add_proto_for_typescript

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77cbbde and fe748f1.

📒 Files selected for processing (1)
  • apps/dashboard/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Packages / Test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator Author

chronark commented Sep 1, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2025

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/dashboard/package.json (1)

100-101: Duplicate TypeScript versions in deps vs devDeps.

You have typescript in dependencies (^5.7.3) and devDependencies (^5.1.3). Keep a single devDependency and align versions.

   "dependencies": {
-    "typescript": "^5.7.3",
     "usehooks-ts": "^3.1.0",
     "vaul": "^0.9.0",
     "zod": "^3.23.5"
   },
   "devDependencies": {
@@
-    "typescript": "^5.1.3",
+    "typescript": "^5.7.3",
     "vitest": "^1.6.1"
   }

Also applies to: 117-118

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2e3b72d and 77cbbde.

⛔ Files ignored due to path filters (26)
  • internal/proto/generated/proto/ctrl/v1/acme_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/acme_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/build_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/build_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/deployment_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/deployment_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/openapi_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/openapi_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/routing_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/routing_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/service_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/ctrl/v1/service_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/deploy/assetmanagerd/v1/asset_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/deploy/assetmanagerd/v1/asset_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/deploy/billaged/v1/billing_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/deploy/billaged/v1/billing_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/deploy/builderd/v1/builder_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/deploy/builderd/v1/builder_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/metal/vmprovisioner/v1/vmprovisioner_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/metal/vmprovisioner/v1/vmprovisioner_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/metal/vmprovisioner/v1/wip_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/partition/v1/gateway_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/vault/v1/object_pb.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/vault/v1/service_connect.ts is excluded by !**/generated/**
  • internal/proto/generated/proto/vault/v1/service_pb.ts is excluded by !**/generated/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • apps/dashboard/package.json (2 hunks)
  • go/buf.gen.yaml (1 hunks)
  • internal/proto/package.json (1 hunks)
  • internal/proto/src/index.ts (1 hunks)
  • internal/proto/tsconfig.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{js,jsx,ts,tsx}: Use Biome for formatting and linting in TypeScript/JavaScript projects
Prefer named exports over default exports in TypeScript/JavaScript, except for Next.js pages

Files:

  • internal/proto/src/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow strict TypeScript configuration
Use Zod for runtime validation in TypeScript projects

Files:

  • internal/proto/src/index.ts
**/*.{env,js,ts,go}

📄 CodeRabbit inference engine (CLAUDE.md)

All environment variables must follow the format: UNKEY_<SERVICE_NAME>_VARNAME

Files:

  • internal/proto/src/index.ts
🧠 Learnings (3)
📚 Learning: 2025-08-04T07:44:39.438Z
Learnt from: CR
PR: unkeyed/unkey#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-04T07:44:39.438Z
Learning: Applies to **/*.{ts,tsx} : Follow strict TypeScript configuration

Applied to files:

  • internal/proto/tsconfig.json
📚 Learning: 2025-09-01T02:33:43.749Z
Learnt from: imeyer
PR: unkeyed/unkey#3899
File: go/buf.gen.yaml:0-0
Timestamp: 2025-09-01T02:33:43.749Z
Learning: In the unkeyed/unkey repository, buf commands are executed from the `go/` directory where the `buf.yaml` file is located. This means the `out: gen` configuration in `go/buf.gen.yaml` generates files to `go/gen/` relative to the repository root, which aligns with the expected directory structure.

Applied to files:

  • go/buf.gen.yaml
📚 Learning: 2025-09-01T01:57:42.213Z
Learnt from: imeyer
PR: unkeyed/unkey#3899
File: go/proto/metald/v1/metald.proto:5-9
Timestamp: 2025-09-01T01:57:42.213Z
Learning: In the unkeyed/unkey repository, buf is configured to properly resolve metald proto imports like "metald/v1/vm.proto" without needing the full "go/proto/" prefix. The buf lint command `buf lint --path proto/metald` passes successfully with these relative import paths.

Applied to files:

  • go/buf.gen.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Test Packages / Test
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
🔇 Additional comments (1)
internal/proto/package.json (1)

1-22: Unify on Connect v2 and prepare @unkey/proto for v2 codegen

  • Remove @connectrpc/protoc-gen-connect-es per Connect v2 migration (plugin removed) (github.com)
  • Bump RPC codegen/runtime to v2: @bufbuild/protobuf & @bufbuild/protoc-gen-es^2.2.0 (npmjs.com); @connectrpc/connect^2.0.2 (npmjs.com)
  • Point "main" to dist/index.js, "types" to dist/index.d.ts, add "exports" & "files" for proper module resolution
  • Add gen, build & clean scripts; verify cd ../go && buf generate path matches your project layout [verify]

Comment on lines +1 to +3
// Re-export ctrl service types and services
export * from "../generated/proto/ctrl/v1/deployment_pb";
export * from "../generated/proto/ctrl/v1/deployment_connect";
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove v1 connect-generated exports if standardizing on Connect v2.

With v2, services come from the _pb module; there is no _connect file. (github.com, connectrpc.com)

 // Re-export ctrl service types and services
 export * from "../generated/proto/ctrl/v1/deployment_pb";
-export * from "../generated/proto/ctrl/v1/deployment_connect";
🤖 Prompt for AI Agents
In internal/proto/src/index.ts around lines 1 to 3, the file is re-exporting
both the generated protobuf types and the Connect v1 service bindings; when
standardizing on Connect v2 the _connect exports must be removed because v2
exposes services from the _pb modules. Remove the export line for
"../generated/proto/ctrl/v1/deployment_connect" (or replace any usage with the
corresponding symbols from "../generated/proto/ctrl/v1/deployment_pb") so only
the _pb module is re-exported and update any import sites to consume the
v2-style service types from the _pb exports.

@chronark chronark merged commit d0b5c3e into main Sep 18, 2025
18 checks passed
@chronark chronark deleted the 09-01-chore_add_proto_for_typescript branch September 18, 2025 07:44
@coderabbitai coderabbitai bot mentioned this pull request Sep 18, 2025
18 tasks
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