Skip to content

feat(vue-colada)!: remove deep ref in input & context options #238

Merged
dinwwwh merged 1 commit intomainfrom
feat-vue-colada-support-callback-input-2
Mar 14, 2025
Merged

feat(vue-colada)!: remove deep ref in input & context options #238
dinwwwh merged 1 commit intomainfrom
feat-vue-colada-support-callback-input-2

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 14, 2025

to match with other options

Summary by CodeRabbit

  • Refactor

    • Simplified value handling by replacing extra reactivity wrappers with direct and function-based inputs for query and mutation configurations.
    • Updated internal processing to streamline how values and contexts are managed.
  • Tests

    • Revised test cases to align with the new, simplified input and context handling.
    • Removed legacy tests related to deep reactive reference unwrapping.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 14, 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 Mar 14, 2025 7:41am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 14, 2025

Walkthrough

This pull request refactors how input and context are handled in the vue‐colada package. Tests and procedure utilities now use direct numeric values and function wrappers instead of Vue’s reactive references. The utilities have been updated to use Vue’s toValue method in place of a custom deep unwrapping function, and related type definitions have been streamlined by replacing MaybeRefDeep with MaybeRefOrGetter. Several tests and utility files for deep unwrapping have been removed.

Changes

File(s) Change Summary
packages/vue-colada/src/procedure-utils.test-d.ts
packages/vue-colada/src/procedure-utils.test.ts
Updated tests to remove reactive ref usage for properties like cursor and batch, and added cases allowing input and context as functions.
packages/vue-colada/src/procedure-utils.ts Replaced unrefDeep with Vue’s toValue in queryOptions and mutationOptions, simplifying value extraction.
packages/vue-colada/src/types.ts Removed the MaybeRefDeep type and updated QueryOptionsIn and MutationOptionsIn to use MaybeRefOrGetter instead.
packages/vue-colada/src/types.test-d.ts
packages/vue-colada/src/utils.test-d.ts
packages/vue-colada/src/utils.test.ts
packages/vue-colada/src/utils.ts
Removed deep unwrapping utilities and their associated tests that validated unrefDeep and nested type behaviors.
packages/vue-colada/tests/e2e.test-d.ts
packages/vue-colada/tests/e2e.test.tsx
Modified the structure of input values for useQuery, including updating property access from reactive references to direct values (e.g., using id.value).

Sequence Diagram(s)

sequenceDiagram
    participant T as Test
    participant PU as ProcedureUtils
    participant TV as toValue
    participant CL as Client

    T->>PU: Call queryOptions({ input, context, ... })
    PU->>TV: Process input via toValue(input)
    TV-->>PU: Return unwrapped input
    PU->>TV: Process context via toValue(context)
    TV-->>PU: Return unwrapped context
    PU->>CL: Invoke client(unwrapped input, { context: unwrapped context })
    CL-->>PU: Return result
    PU-->>T: Send back response
Loading

Possibly related PRs

  • unnoq/orpc#191: Addresses enhancements in mutation context inference, affecting the methods modified in this PR.
  • unnoq/orpc#190: Fixes type conflicts in the return types of query/mutation options, sharing a direct code-level relationship with the current changes.

Poem

I'm a rabbit with hops so light,
Code paths now clearer in the night.
No more refs wrapped in a tricky guise,
Direct values make my spirits rise.
With a carrot of change in every line,
I celebrate this refactor so fine!
🥕🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 ff68fdb and 63dc350.

📒 Files selected for processing (10)
  • packages/vue-colada/src/procedure-utils.test-d.ts (3 hunks)
  • packages/vue-colada/src/procedure-utils.test.ts (2 hunks)
  • packages/vue-colada/src/procedure-utils.ts (2 hunks)
  • packages/vue-colada/src/types.test-d.ts (0 hunks)
  • packages/vue-colada/src/types.ts (1 hunks)
  • packages/vue-colada/src/utils.test-d.ts (0 hunks)
  • packages/vue-colada/src/utils.test.ts (0 hunks)
  • packages/vue-colada/src/utils.ts (0 hunks)
  • packages/vue-colada/tests/e2e.test-d.ts (2 hunks)
  • packages/vue-colada/tests/e2e.test.tsx (1 hunks)
💤 Files with no reviewable changes (4)
  • packages/vue-colada/src/utils.test-d.ts
  • packages/vue-colada/src/utils.test.ts
  • packages/vue-colada/src/utils.ts
  • packages/vue-colada/src/types.test-d.ts
🔇 Additional comments (9)
packages/vue-colada/src/types.ts (1)

4-4: Good refactoring to standardize on Vue's native types

Replacing the custom MaybeRefDeep with Vue's built-in MaybeRefOrGetter type is a great improvement. This simplifies the type system and leverages Vue's own reactivity utilities, making the code more maintainable and aligned with Vue's best practices.

This is a breaking change for consumers who may have been relying on deep unwrapping behavior, but the tradeoff is worthwhile for the improved consistency.

Also applies to: 9-10, 16-16

packages/vue-colada/tests/e2e.test.tsx (1)

21-21: Test properly updated to use explicit ref value access

The test has been correctly updated to access id.value explicitly in the computed function, which aligns with the removal of deep ref unwrapping. This change demonstrates the correct usage pattern with the updated API.

packages/vue-colada/tests/e2e.test-d.ts (1)

3-3: Type test correctly simplified to match new API pattern

Good simplification of the type test by removing the unnecessary ref import and directly using the numeric value instead of wrapping it in a ref. This makes the test clearer and matches the new pattern where deep unwrapping is no longer supported. The test now better demonstrates the intended usage of the API.

Also applies to: 26-26

packages/vue-colada/src/procedure-utils.ts (1)

5-5: Great implementation improvement using Vue's native utilities

Excellent change to replace the custom unrefDeep function with Vue's built-in toValue utility. This:

  1. Simplifies the implementation by leveraging Vue's native functionality
  2. Ensures consistent behavior with Vue's reactivity system
  3. Aligns perfectly with the updated type definitions
  4. Makes the codebase more maintainable by removing custom unwrapping logic

The change is applied consistently throughout the implementation for both queries and mutations.

Also applies to: 37-38, 46-46

packages/vue-colada/src/procedure-utils.test.ts (2)

66-66: Improved context handling with top-level ref

The change from using deep reactivity structure ({ batch: ref(true) }) to a single top-level ref (ref({ batch: true })) aligns with the PR objective of disallowing deep refs in context options. This approach is more consistent with other option patterns in the codebase.


108-108: Consistent pattern for mutation options context

Similar to the queryOptions change, this refactors the context parameter to use a top-level ref instead of a deep nested ref structure. This change ensures consistency across both query and mutation options, making the API more predictable.

packages/vue-colada/src/procedure-utils.test-d.ts (3)

66-67: Simplified input structure without deep refs

The removal of nested ref(1) in favor of direct value 1 aligns with the PR goal of disallowing deep refs in input options. This simplifies the reactive structure while maintaining the same functionality.


70-73: Added function getter pattern as an alternative to reactive refs

This new test case demonstrates the more flexible function-returning-object pattern as an alternative to reactive refs. This approach:

  1. Provides better type inference
  2. Allows for dynamic computation without reactive dependencies
  3. Creates a more consistent pattern with other Vue 3 composition API conventions

This is a good addition that shows the recommended alternative to deep refs.


117-125: Added mutationOptions tests for both computed and function patterns

These test cases properly verify that both computed properties and function getters work as expected for providing context to mutation options. This is a good addition that ensures both patterns are supported and documented through tests.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
  • @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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@dinwwwh dinwwwh changed the title feat(vue-colada)!: disallow deep ref in input & context options feat(vue-colada)!: remove deep ref in input & context options Mar 14, 2025
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 14, 2025

Open in Stackblitz

More templates

@orpc/client

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

@orpc/contract

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

@orpc/openapi

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

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@238

@orpc/react-query

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

@orpc/shared

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

@orpc/server

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

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@238

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@238

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@238

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@238

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@238

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 63dc350

@dinwwwh dinwwwh merged commit 15d9202 into main Mar 14, 2025
8 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