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(contract)!: stricter implementation for contracts #97

Merged
merged 18 commits into from
Jan 20, 2025

Conversation

unnoq
Copy link
Owner

@unnoq unnoq commented Jan 20, 2025

Summary

This PR enhances the way contracts are defined and implemented by:

  1. Adding route information to contracts.
  2. Enforcing stricter implementation for contracts, ensuring full adherence to the contract's requirements.

Key Changes

  • Previous Behavior:

    • You could manually define a procedure using .input and .output that satisfied the contract requirements. This procedure would then be treated as a valid contract implementation.
    • You can use methods not designed for the contract-first approach without warning.
    • Required magic logic logic under hook to ensure contracts are implemented correctly
  • New Behavior:

    • You must implement a contract explicitly through .contract, ensuring that all requirements specified by the contract are satisfied.
    • If you accidentally use methods not designed for the contract-first approach, TypeScript will catch these errors, giving you confidence that the contract is implemented correctly.
    • Everything wrong when implementing contracts will catch by typescript

Copy link

vercel bot commented Jan 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 1:43pm

@unnoq unnoq changed the title feat(contract)!: strict contract when implement feat(contract)!: stricter implementation for contracts Jan 20, 2025
Copy link

pkg-pr-new bot commented Jan 20, 2025

Open in Stackblitz

More templates

@orpc/client

npm i https://pkg.pr.new/@orpc/client@97

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@97

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@97

@orpc/server

npm i https://pkg.pr.new/@orpc/server@97

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@97

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@97

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@97

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@97

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@97

commit: dfa2a3d

@unnoq unnoq merged commit ed15210 into main Jan 20, 2025
6 checks passed
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.

1 participant