Skip to content

feat(client, server)!: Adapter-Level Plugin Interception#292

Merged
dinwwwh merged 11 commits intomainfrom
feat/client-server/fetch-and-node-plugin
Mar 25, 2025
Merged

feat(client, server)!: Adapter-Level Plugin Interception#292
dinwwwh merged 11 commits intomainfrom
feat/client-server/fetch-and-node-plugin

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 25, 2025

Plugins now have the ability to intercept and modify requests and responses directly at the adapter level

Event Iterator Keep Alive

We move configs for Event Iterator Keep Alive from .handle to handler options (define when creating handler)

Rename internal APIs

  • HandlerPlugin -> StandardHandlerPlugin
  • ClientOptions -> FriendlyClientOptions
  • ClientOptionsOut -> ClientOptions
  • ClientPlugin -> StandardLinkPlugin
  • StandardHandleOptions -> FriendlyStandardHandleOptions

Summary by CodeRabbit

  • Documentation

    • Clarified API descriptions, including keep-alive behavior and headers for improved clarity.
  • Refactor

    • Streamlined internal handler implementations and standardized plugin and configuration interfaces across client and server components.
  • Tests

    • Expanded test coverage for options resolution and plugin initialization, while simplifying scenarios to focus on core functionality.
    • Added new tests for the resolveFriendlyClientOptions and resolveMaybeOptionalOptions functions.
  • Chores

    • Removed deprecated dependencies, updated package versions, and consolidated module exports for a leaner codebase.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 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 25, 2025 1:11pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request applies widespread refactoring and type updates across multiple packages. Documentation for handlers has been updated for clarity, and tests have been streamlined. In the client and server packages, numerous method signatures and type imports have been revised—primarily replacing instances of ClientOptionsOut with ClientOptions (and renaming to FriendlyClientOptions where applicable)—while plugin architectures and handler inheritance structures have been modernized. Several obsolete files and exports have been removed, and dependency versions have been updated in select package.json files.

Changes

File(s) Change Summary
apps/content/docs/openapi/openapi-handler.md
apps/content/docs/rpc-handler.md
Updated documentation: replaced “ping messages” with “ping comments”, removed hyphens from headers, reorganized code snippets, and renamed variables (e.g. resulthandler).
packages/client/src/adapters/fetch/link-fetch-client.ts
packages/client/src/adapters/fetch/rpc-link.ts
packages/client/src/adapters/fetch/types.ts
packages/client/src/adapters/standard/link.ts
packages/client/src/adapters/standard/rpc-link-codec.ts
packages/client/src/adapters/standard/types.ts
packages/client/src/client.ts
packages/client/src/dynamic-link.test.ts
packages/client/src/dynamic-link.ts
Updated type imports and method signatures from ClientOptionsOut to ClientOptions; renamed ClientOptions to FriendlyClientOptions where applicable; modified plugin initialization and test cases accordingly.
packages/client/src/plugins/base.test.ts
packages/client/src/plugins/base.ts
packages/client/src/plugins/index.ts
packages/client/src/plugins/retry.ts
Removed legacy plugin interfaces and composite plugin classes; updated retry plugin to implement the new StandardLinkPlugin interface; removed exports from the base module.
packages/server/** (multiple files in adapters/fetch, adapters/node, adapters/standard, and tests) Refactored handler classes (e.g. OpenAPIHandler, RPCHandler) to extend FetchHandler/NodeHttpHandler instead of implementing custom logic; streamlined and simplified tests; removed obsolete type declarations; updated dependency "light-my-request" to "supertest" in package.json.
packages/shared/** (files in args, array, types, tests) Introduced new utility functions such as toArray and resolveMaybeOptionalOptions; added new tests; removed the MaybeOptionalOptions type, while updating related exports in index.ts.
packages/zod/src/coercer.ts Changed the implementation of ZodSmartCoercionPlugin to implement StandardHandlerPlugin instead of the old HandlerPlugin; updated import statements accordingly.
playgrounds/svelte-kit/package.json Upgraded dependency versions for @sveltejs/vite-plugin-svelte (from ^5.0.0 to ^5.0.3) and typescript (from ^5.0.0 to 5.7.3).

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant R as resolveFriendlyClientOptions
    participant SL as StandardLink
    participant PL as Plugin (if any)
    participant RPC as RPCHandler

    C->>R: Call procedureClient with input & options
    R-->>C: Return resolved FriendlyClientOptions
    C->>SL: Invoke StandardLink.call(options)
    SL->>PL: Iterate & initialize each plugin (if defined)
    SL->>RPC: Delegate call or process request via interceptors
    RPC-->>SL: Return response (e.g., "pong")
    SL-->>C: Return final response
Loading
sequenceDiagram
    participant Req as IncomingRequest
    participant NH as NodeHttpHandler / FetchHandler
    participant SH as StandardHandler
    participant Resp as HTTP Response

    Req->>NH: Send HTTP request
    NH->>SH: Delegate request conversion & handling
    SH->>NH: Return standardized result
    NH->>Resp: Send response with status 200 and content ("pong")
Loading

Poem

I'm a bunny with a joyful code hop,
Skipping through refactors that make errors drop.
Types align and plugins chime in tune,
Each change sings a fresh, new rune.
I nibble on clean code with delight,
Hopping towards a future so bright!
Cheers from this rabbit in a tech-filled night!


📜 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 31e7cca and 83caff2.

📒 Files selected for processing (3)
  • packages/client/src/adapters/standard/rpc-link-codec.ts (6 hunks)
  • packages/client/src/adapters/standard/types.ts (1 hunks)
  • packages/shared/src/args.test.ts (1 hunks)

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 25, 2025

Open in Stackblitz

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@292

@orpc/client

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

@orpc/contract

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

@orpc/openapi

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

@orpc/openapi-client

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

@orpc/react-query

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

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

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

@orpc/standard-server

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

@orpc/standard-server-fetch

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

@orpc/svelte-query

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

@orpc/standard-server-node

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

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@292

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 83caff2

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@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

🧹 Nitpick comments (7)
packages/shared/src/args.test.ts (1)

3-6: Consider adding an empty array test case

The tests cover the main scenarios but miss testing with an empty array input. Since the function would return an empty object for both [undefined] and [], adding a test case for resolveMaybeOptionalOptions([]) would ensure complete coverage.

it('resolveMaybeOptionalOptions', () => {
  expect(resolveMaybeOptionalOptions([{ a: 1 }])).toEqual({ a: 1 })
  expect(resolveMaybeOptionalOptions([undefined])).toEqual({})
+ expect(resolveMaybeOptionalOptions([])).toEqual({})
})
packages/shared/src/args.ts (1)

5-7: Clean implementation for resolving optional parameters.

The resolveMaybeOptionalOptions function provides a convenient way to extract options from the tuple type, handling the case where options might be undefined. The fallback to an empty object ensures that consuming code doesn't have to deal with undefined values.

I do have one minor concern:

Consider adding a more specific type annotation to the empty object fallback:

-  return rest[0] ?? {} as T // 0 only undefined when all fields are optional
+  return rest[0] ?? ({} as T) // 0 only undefined when all fields are optional

This makes the cast more explicit and helps emphasize that the empty object is being cast to type T.

packages/server/src/adapters/node/rpc-handler.test.ts (1)

6-16: Test simplification improves clarity.

The test has been streamlined to focus on core functionality, making it more maintainable. This aligns well with the PR's objective of enhancing clarity and consistency.

Consider adding additional test cases for error conditions to ensure robust handling of edge cases.

packages/openapi/src/adapters/fetch/openapi-handler.test.ts (1)

5-14: Test simplified for better focus on core functionality.

The test effectively verifies the basic functionality of the OpenAPIHandler. Consider expanding test coverage to include:

  1. Different HTTP methods (POST, PUT, DELETE)
  2. Error scenarios (invalid routes, malformed requests)
  3. Different response types (JSON, text, binary)

This would ensure more robust testing of the handler's capabilities.

packages/client/src/adapters/standard/rpc-link-codec.ts (1)

78-78: Consider using the generic class-level type parameter

Using ClientOptions<any> here may reduce type safety. It might be more appropriate to align with the class’s type parameter:

-  async encode(path: readonly string[], input: unknown, options: ClientOptions<any>): Promise<StandardRequest> {
+  async encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest> {
packages/server/src/adapters/standard/handler.ts (1)

62-64: Initializing plugins with init().

Immediate plugin initialization ensures all plugins have an opportunity to configure themselves before request handling begins. Consider adding error handling to safeguard potential plugin failures.

packages/client/src/adapters/standard/types.ts (1)

5-6: Codec method signatures
Changing encode and decode to reference ClientOptions<any> and ClientOptions<T> is part of the global refactor. However, the cast to any for the first method could undermine some type safety. Consider using ClientOptions<T> consistently, unless there are real scenarios requiring flexible context typing.

- encode(path: readonly string[], input: unknown, options: ClientOptions<any>): Promise<StandardRequest>
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62795ca and 31e7cca.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (60)
  • apps/content/docs/openapi/openapi-handler.md (1 hunks)
  • apps/content/docs/rpc-handler.md (2 hunks)
  • packages/client/src/adapters/fetch/link-fetch-client.ts (2 hunks)
  • packages/client/src/adapters/fetch/rpc-link.ts (2 hunks)
  • packages/client/src/adapters/fetch/types.ts (1 hunks)
  • packages/client/src/adapters/standard/link.test.ts (1 hunks)
  • packages/client/src/adapters/standard/link.ts (2 hunks)
  • packages/client/src/adapters/standard/rpc-link-codec.ts (6 hunks)
  • packages/client/src/adapters/standard/types.ts (1 hunks)
  • packages/client/src/client.ts (2 hunks)
  • packages/client/src/dynamic-link.test.ts (2 hunks)
  • packages/client/src/dynamic-link.ts (2 hunks)
  • packages/client/src/plugins/base.test.ts (0 hunks)
  • packages/client/src/plugins/base.ts (0 hunks)
  • packages/client/src/plugins/index.ts (0 hunks)
  • packages/client/src/plugins/retry.ts (5 hunks)
  • packages/client/src/types.ts (2 hunks)
  • packages/client/src/utils.test.ts (2 hunks)
  • packages/client/src/utils.ts (2 hunks)
  • packages/openapi/package.json (0 hunks)
  • packages/openapi/src/adapters/fetch/openapi-handler.test.ts (1 hunks)
  • packages/openapi/src/adapters/fetch/openapi-handler.ts (1 hunks)
  • packages/openapi/src/adapters/node/openapi-handler.test.ts (1 hunks)
  • packages/openapi/src/adapters/node/openapi-handler.ts (1 hunks)
  • packages/server/package.json (1 hunks)
  • packages/server/src/adapters/fetch/handler.test-d.ts (1 hunks)
  • packages/server/src/adapters/fetch/handler.test.ts (1 hunks)
  • packages/server/src/adapters/fetch/handler.ts (1 hunks)
  • packages/server/src/adapters/fetch/index.ts (1 hunks)
  • packages/server/src/adapters/fetch/rpc-handler.test.ts (1 hunks)
  • packages/server/src/adapters/fetch/rpc-handler.ts (1 hunks)
  • packages/server/src/adapters/fetch/types.ts (0 hunks)
  • packages/server/src/adapters/node/handler.test-d.ts (1 hunks)
  • packages/server/src/adapters/node/handler.test.ts (1 hunks)
  • packages/server/src/adapters/node/handler.ts (1 hunks)
  • packages/server/src/adapters/node/index.ts (1 hunks)
  • packages/server/src/adapters/node/rpc-handler.test.ts (1 hunks)
  • packages/server/src/adapters/node/rpc-handler.ts (1 hunks)
  • packages/server/src/adapters/node/types.ts (0 hunks)
  • packages/server/src/adapters/standard/handler.test-d.ts (0 hunks)
  • packages/server/src/adapters/standard/handler.test.ts (4 hunks)
  • packages/server/src/adapters/standard/handler.ts (3 hunks)
  • packages/server/src/adapters/standard/utils.test-d.ts (1 hunks)
  • packages/server/src/adapters/standard/utils.test.ts (1 hunks)
  • packages/server/src/adapters/standard/utils.ts (1 hunks)
  • packages/server/src/plugins/base.test.ts (0 hunks)
  • packages/server/src/plugins/base.ts (0 hunks)
  • packages/server/src/plugins/cors.ts (2 hunks)
  • packages/server/src/plugins/index.ts (0 hunks)
  • packages/server/src/plugins/response-headers.ts (1 hunks)
  • packages/shared/src/args.test-d.ts (1 hunks)
  • packages/shared/src/args.test.ts (1 hunks)
  • packages/shared/src/args.ts (1 hunks)
  • packages/shared/src/array.test.ts (1 hunks)
  • packages/shared/src/array.ts (1 hunks)
  • packages/shared/src/index.ts (1 hunks)
  • packages/shared/src/types.test-d.ts (1 hunks)
  • packages/shared/src/types.ts (0 hunks)
  • packages/zod/src/coercer.ts (2 hunks)
  • playgrounds/svelte-kit/package.json (1 hunks)
💤 Files with no reviewable changes (11)
  • packages/server/src/plugins/index.ts
  • packages/openapi/package.json
  • packages/server/src/plugins/base.ts
  • packages/client/src/plugins/index.ts
  • packages/client/src/plugins/base.test.ts
  • packages/shared/src/types.ts
  • packages/server/src/plugins/base.test.ts
  • packages/server/src/adapters/standard/handler.test-d.ts
  • packages/client/src/plugins/base.ts
  • packages/server/src/adapters/fetch/types.ts
  • packages/server/src/adapters/node/types.ts
🧰 Additional context used
🧬 Code Definitions (25)
packages/client/src/client.ts (2)
packages/client/src/types.ts (3)
  • Client (15-17)
  • InferClientContext (23-23)
  • FriendlyClientOptions (3-5)
packages/client/src/utils.ts (1)
  • resolveFriendlyClientOptions (38-43)
packages/server/src/adapters/node/handler.test-d.ts (2)
packages/server/src/adapters/node/handler.ts (1)
  • NodeHttpHandlerPlugin (10-12)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandlerPlugin (19-21)
packages/client/src/utils.test.ts (1)
packages/client/src/utils.ts (1)
  • resolveFriendlyClientOptions (38-43)
packages/server/src/adapters/standard/handler.test.ts (2)
packages/server/src/plugins/cors.ts (1)
  • init (31-113)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandler (51-138)
packages/server/src/adapters/fetch/handler.test-d.ts (2)
packages/server/src/adapters/fetch/handler.ts (1)
  • FetchHandlerPlugin (10-12)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandlerPlugin (19-21)
packages/shared/src/array.test.ts (1)
packages/shared/src/array.ts (1)
  • toArray (1-3)
packages/shared/src/args.test.ts (1)
packages/shared/src/args.ts (1)
  • resolveMaybeOptionalOptions (5-7)
packages/server/src/adapters/standard/utils.test.ts (1)
packages/server/src/adapters/standard/utils.ts (1)
  • resolveFriendlyStandardHandleOptions (8-13)
packages/client/src/dynamic-link.test.ts (1)
packages/client/src/types.ts (1)
  • ClientOptions (25-27)
packages/server/src/adapters/standard/utils.ts (1)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandleOptions (12-15)
packages/zod/src/coercer.ts (1)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandlerPlugin (19-21)
packages/client/src/utils.ts (1)
packages/client/src/types.ts (3)
  • ClientContext (1-1)
  • FriendlyClientOptions (3-5)
  • ClientOptions (25-27)
packages/shared/src/args.test-d.ts (1)
packages/shared/src/args.ts (1)
  • MaybeOptionalOptions (1-3)
packages/client/src/adapters/fetch/rpc-link.ts (2)
packages/client/src/adapters/standard/link.ts (1)
  • path (44-56)
packages/client/src/types.ts (1)
  • ClientOptions (25-27)
packages/server/src/plugins/cors.ts (1)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandlerPlugin (19-21)
packages/openapi/src/adapters/node/openapi-handler.ts (5)
packages/server/src/adapters/node/handler.ts (2)
  • NodeHttpHandler (24-68)
  • NodeHttpHandlerOptions (14-22)
packages/openapi/src/adapters/standard/openapi-handler.ts (1)
  • StandardOpenAPIHandlerOptions (5-5)
packages/openapi/src/adapters/standard/openapi-matcher.ts (1)
  • StandardOpenAPIMatcher (8-94)
packages/openapi/src/adapters/standard/openapi-codec.ts (1)
  • StandardOpenAPICodec (9-88)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandler (51-138)
packages/server/src/adapters/node/rpc-handler.ts (3)
packages/server/src/adapters/node/handler.ts (2)
  • NodeHttpHandler (24-68)
  • NodeHttpHandlerOptions (14-22)
packages/server/src/adapters/standard/rpc-handler.ts (1)
  • StandardRPCHandlerOptions (5-5)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandler (51-138)
packages/server/src/adapters/node/handler.ts (1)
packages/server/src/adapters/standard/handler.ts (3)
  • StandardHandlerPlugin (19-21)
  • StandardHandleOptions (12-15)
  • StandardHandler (51-138)
packages/server/src/adapters/fetch/handler.ts (4)
packages/server/src/adapters/standard/handler.ts (3)
  • StandardHandlerPlugin (19-21)
  • StandardHandleOptions (12-15)
  • StandardHandler (51-138)
packages/shared/src/array.ts (1)
  • toArray (1-3)
packages/shared/src/args.ts (2)
  • MaybeOptionalOptions (1-3)
  • resolveMaybeOptionalOptions (5-7)
packages/server/src/adapters/standard/utils.ts (2)
  • FriendlyStandardHandleOptions (4-6)
  • resolveFriendlyStandardHandleOptions (8-13)
packages/server/src/plugins/response-headers.ts (1)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandlerPlugin (19-21)
packages/client/src/adapters/standard/link.ts (2)
packages/client/src/types.ts (2)
  • ClientContext (1-1)
  • ClientOptions (25-27)
packages/standard-server/src/types.ts (2)
  • StandardRequest (13-24)
  • StandardLazyResponse (48-59)
packages/openapi/src/adapters/fetch/openapi-handler.ts (3)
packages/server/src/adapters/fetch/handler.ts (2)
  • FetchHandler (25-68)
  • FetchHandlerOptions (19-23)
packages/openapi/src/adapters/standard/openapi-handler.ts (1)
  • StandardOpenAPIHandlerOptions (5-5)
packages/server/src/adapters/standard/handler.ts (1)
  • StandardHandler (51-138)
packages/client/src/adapters/standard/rpc-link-codec.ts (3)
packages/client/src/types.ts (1)
  • ClientOptions (25-27)
packages/client/src/adapters/standard/link.ts (1)
  • path (44-56)
packages/standard-server/src/types.ts (1)
  • StandardRequest (13-24)
packages/client/src/adapters/standard/types.ts (3)
packages/client/src/types.ts (2)
  • ClientContext (1-1)
  • ClientOptions (25-27)
packages/client/src/adapters/standard/link.ts (1)
  • path (44-56)
packages/standard-server/src/types.ts (2)
  • StandardRequest (13-24)
  • StandardLazyResponse (48-59)
packages/client/src/plugins/retry.ts (2)
packages/client/src/types.ts (1)
  • ClientOptions (25-27)
packages/client/src/adapters/standard/link.ts (1)
  • StandardLinkPlugin (9-11)
🔇 Additional comments (131)
packages/zod/src/coercer.ts (3)

2-2: Interface import update for consistency.

The import has been updated to use StandardHandlerPlugin from '@orpc/server/standard' instead of the previous HandlerPlugin. This aligns with the PR objective of renaming internal APIs for clarity and consistency.


31-31: Interface implementation change aligns with renamed type.

The ZodSmartCoercionPlugin class has been updated to implement StandardHandlerPlugin<TContext> instead of HandlerPlugin<TContext>, following the renaming pattern mentioned in the PR objectives. The implementation remains functionally identical, only the interface name has changed.


32-47: Plugin initialization looks good.

The init method maintains the same implementation as before, using StandardHandlerOptions<TContext>. The plugin correctly sets up client interceptors to perform smart coercion of input data based on Zod schemas, which aligns with the adapter-level plugin interception feature mentioned in the PR objectives.

packages/shared/src/array.test.ts (1)

3-8: Well-structured test coverage

The test suite for the toArray function is comprehensive, covering all possible input scenarios: undefined, null, single value, and array. Each test case correctly verifies the expected behavior defined in the implementation.

packages/shared/src/array.ts (1)

1-3: Concise and well-implemented utility function

The toArray function is elegantly implemented using ternary operators to handle all possible input cases: arrays, single values, undefined, and null. The TypeScript generic ensures type safety is maintained throughout the conversion process.

packages/shared/src/index.ts (1)

1-2: Exports correctly added in alphabetical order

The new exports for the args and array modules are appropriately added to the index file in alphabetical order, following the existing pattern of re-exporting all functionality from individual modules.

packages/shared/src/args.test-d.ts (1)

1-22: Well-structured type tests for the MaybeOptionalOptions utility type.

This test file provides thorough validation for the MaybeOptionalOptions type. You've correctly tested both required and optional property scenarios:

  • Test case with required property correctly enforces the presence of the property
  • Test case with optional property correctly handles undefined values
  • Type errors are properly tested with @ts-expect-error annotations

The test coverage effectively ensures that MaybeOptionalOptions functions as intended in both scenarios.

packages/shared/src/args.ts (1)

1-3: Excellent utility type for handling optional parameters based on type emptiness.

The MaybeOptionalOptions type cleverly uses conditional types to determine whether options should be required or optional based on the structure of the options type. This provides a flexible and type-safe way to handle options in functions.

packages/shared/src/types.test-d.ts (1)

1-1: Import statement updated to reflect test focus changes.

The import statement has been updated to only import the types being tested (SetOptional and IntersectPick). This aligns with the removal of the MaybeOptionalOptions test case which has been moved to its own dedicated test file.

packages/server/src/adapters/fetch/index.ts (1)

1-1: LGTM - Handler module export added

This addition aligns well with the PR objectives, exporting the FetchHandler class that now serves as the base for the RPCHandler. This change supports the adapter-level plugin interception feature by exposing the necessary handler class.

packages/server/package.json (1)

85-85:

Details

❓ Verification inconclusive

Dependency switch from light-my-request to supertest

The replacement of light-my-request with supertest for HTTP request testing indicates a transition to a more comprehensive testing framework. This change aligns with the PR's broader restructuring to enhance the testing approach.


🏁 Script executed:

#!/bin/bash
# Verify that tests have been updated to use supertest instead of light-my-request
echo "Checking for any remaining light-my-request usage in test files:"
rg "light-my-request" --type ts "packages/server/src/**/*.test.ts"

Length of output: 278


Test Suite Verification: Confirm Removal of light-my-request

The switch from light-my-request to supertest in the dependency and tests appears conceptually sound. However, the automated search using the file pattern packages/server/src/**/*.test.ts did not locate any test files (resulting in a "No such file or directory" error). This suggests that either the tests reside in a different location or the pattern needs adjustment.

  • Please verify that all test files have been updated to use supertest.
  • Manually check the test suite directories (or run a broader search such as rg "light-my-request" packages/server) to confirm there are no lingering references to light-my-request.
packages/server/src/adapters/node/index.ts (1)

1-1: LGTM - Handler module export added

This addition aligns with the PR objectives, exporting the NodeHttpHandler class that now serves as the base for both the RPCHandler and OpenAPIHandler. This change supports the adapter-level plugin interception feature by exposing the necessary handler infrastructure.

packages/client/src/dynamic-link.test.ts (1)

1-1: Type name update consistent with renaming changes

The rename from ClientOptionsOut to ClientOptions is aligned with the PR objectives, which explicitly mention this renaming for clarity and consistency. This change correctly updates both the import and the type annotation in the test file.

Also applies to: 11-11

playgrounds/svelte-kit/package.json (2)

26-26: Note: TypeScript version pinned to exact version 5.7.3

The change from ^5.0.0 to 5.7.3 removes the caret prefix, which means the project now requires exactly TypeScript 5.7.3 rather than allowing compatible updates. This suggests the codebase may use specific features from this version or might have compatibility issues with other versions.

Make sure to test the code changes with exactly TypeScript 5.7.3 to verify compatibility, and ensure your development environment uses this specific version.


22-22: Version update for Svelte plugin looks good

Minor version update from 5.0.0 to 5.0.3, maintaining compatibility with the caret prefix.

packages/server/src/adapters/standard/utils.test.ts (1)

1-7: Test coverage for resolveFriendlyStandardHandleOptions is comprehensive

The test cases effectively verify all the expected behaviors of the utility function:

  1. Empty input returns an object with empty context
  2. Input with context preserves that context in the output
  3. Additional properties (like prefix) are maintained alongside the context

This aligns well with the function's implementation in utils.ts, which ensures context is always present by defaulting to an empty object when not provided.

packages/server/src/adapters/node/handler.test-d.ts (2)

2-3: Import statements updated for type compatibility testing

Appropriate imports added for the type compatibility tests between NodeHttpHandlerPlugin and StandardHandlerPlugin.


5-10: Type compatibility tests ensure backward compatibility

These tests verify that NodeHttpHandlerPlugin and StandardHandlerPlugin types are compatible in both directions, which is critical for maintaining backward compatibility during the renaming refactoring. This ensures existing code will continue to work with the renamed types.

packages/client/src/utils.test.ts (2)

2-2: Updated import to include the new utility function

Import statement correctly updated to include the new resolveFriendlyClientOptions function alongside the existing safe function.


25-29: Comprehensive test cases for resolveFriendlyClientOptions

The test cases effectively validate that the function:

  1. Adds an empty context object when none is provided
  2. Preserves existing context objects
  3. Maintains other properties like lastEventId while ensuring context exists

This follows the same pattern as the server-side resolveFriendlyStandardHandleOptions function, creating consistency across client and server libraries. This supports the PR's goal of improving API clarity and consistency through renaming.

packages/server/src/adapters/standard/utils.test-d.ts (1)

1-11: Well-written type tests for FriendlyStandardHandleOptions

This new test file validates the behavior of the FriendlyStandardHandleOptions type with different input scenarios. The tests comprehensively check required vs optional context properties, and ensure type safety is maintained.

packages/client/src/adapters/fetch/types.ts (2)

1-1: Updated import to use the renamed ClientOptions type

The import statement has been modified to reflect the type renaming from ClientOptionsOut to ClientOptions as mentioned in the PR objectives.


7-7: Updated parameter type to use ClientOptions

The type of the options parameter in the FetchWithContext interface has been updated from ClientOptionsOut<TClientContext> to ClientOptions<TClientContext>, aligning with the renamed type.

apps/content/docs/openapi/openapi-handler.md (2)

102-102: Clarified terminology: "ping comments" instead of "ping messages"

The description now accurately describes that the keep-alive mechanism sends "ping comments" rather than "ping messages", which better reflects the actual implementation.


105-105: Moved handler instantiation code to maintain consistency

The instantiation of OpenAPIHandler has been moved to a different line for formatting consistency, while preserving the functionality. This aligns with the PR objective of relocating Event Iterator Keep Alive configurations to the handler options.

packages/client/src/adapters/standard/link.test.ts (1)

56-70: Added test case for plugin initialization

This new test case verifies that plugin initialization functions are correctly called when plugins are provided to the StandardLink constructor. The test ensures that each plugin's init method is called exactly once with the correct options object.

This test is essential for validating the adapter-level plugin interception functionality mentioned in the PR objectives.

apps/content/docs/rpc-handler.md (2)

75-75: Header formatting update looks good

The removal of the hyphen in "Event Iterator Keep Alive" improves consistency with other mentions of this feature throughout the documentation.


84-88: LGTM: Configuration location update properly documented

The example correctly shows that Event Iterator Keep Alive settings are now configured during handler creation rather than in the handle method, aligning with the PR's architectural changes.

packages/server/src/adapters/fetch/handler.test-d.ts (2)

1-2: LGTM: Import statements correctly added

The imports for StandardHandlerPlugin and FetchHandlerPlugin enable proper type checking in the tests.


4-9: Good type compatibility testing

This test correctly verifies bidirectional type compatibility between FetchHandlerPlugin and StandardHandlerPlugin, ensuring backward compatibility after the rename from HandlerPlugin to StandardHandlerPlugin.

packages/client/src/client.ts (2)

1-2: LGTM: Updated imports for new type names

The import changes correctly reflect the renaming of ClientOptions to FriendlyClientOptions and addition of the utility function.


17-21: Good implementation of type changes with default value

The function signature update provides a default empty object for options, simplifying the code and properly using the new FriendlyClientOptions type. Using the resolveFriendlyClientOptions utility function ensures consistent context initialization, which is a good refactoring.

packages/openapi/src/adapters/node/openapi-handler.test.ts (2)

1-3: LGTM: Updated imports for simplified test

The imports have been appropriately updated to match the simplified testing approach that focuses on the essential functionality rather than implementation details.


6-16: Good test simplification

The test has been effectively simplified to focus on core functionality, which aligns with the architectural changes where OpenAPIHandler now extends NodeHttpHandler. This approach tests the public API behavior rather than implementation details, which is a good practice.

packages/server/src/adapters/standard/handler.test.ts (4)

126-126: Ensures interceptors property is initialized in client options.

The addition of an empty interceptors array in the createProcedureClient call ensures that the client options object always has this property defined, aligning with changes in the adapter-level plugin interception feature.


186-186: Properly initializes interceptors property in error test case.

Consistent with the changes made in the success case, this ensures the client options for the error test scenario includes the interceptors array property, maintaining uniformity across test cases.


247-247: Adds interceptors property to decode error test case.

This change ensures consistency with the other test cases by adding the interceptors array to the client options, completing the implementation of the adapter-level plugin interception feature throughout all test scenarios.


326-342: Good addition of plugin initialization test.

This new test case verifies that a plugin's init method is called with the correct options when a new StandardHandler is instantiated. This effectively tests the new plugin interception capability at the adapter level.

The test properly validates:

  1. That init is called exactly once
  2. That the options passed to init match the original options object

This validates the critical functionality introduced in this PR.

packages/server/src/adapters/standard/utils.ts (2)

4-6: Well-designed conditional context type with enhanced developer experience.

This type definition elegantly makes the context property optional only when all fields in the generic type T are optional. This improves the developer experience by not requiring an empty context object when it's not needed.

The conditional type is well-implemented using utility types:

  • Omit<StandardHandleOptions<T>, 'context'> removes the original context property
  • The conditional part adds it back, making it optional only when appropriate

8-13: Good implementation of the options resolver function.

This function properly handles the potential absence of a context property by providing a default empty object when needed. The comment on line 11 is particularly helpful in explaining why this approach is taken.

The function maintains type safety while providing a more flexible API, which aligns with the PR's goal of streamlining configuration processes.

packages/client/src/adapters/fetch/rpc-link.ts (2)

1-1: Updated import to use renamed ClientOptions type.

This change correctly implements the renamed type import as stated in the PR objectives, replacing ClientOptionsOut with ClientOptions for better clarity and consistency across the codebase.


22-22: Method signature updated to use ClientOptions.

The call method's parameter type has been correctly updated from ClientOptionsOut<T> to ClientOptions<T>, aligning with the PR's objective to rename types for clarity and consistency throughout the codebase.

packages/server/src/adapters/fetch/rpc-handler.test.ts (3)

5-6: Simplified test approach improves maintainability.

The test has been streamlined to focus on verifying that the RPCHandler works correctly with the new inheritance structure. This simplified approach better aligns with the class's new implementation that extends FetchHandler<T>.


8-10: Direct handler test with proper options structure.

This approach directly tests the handler functionality with a well-formed request and appropriate prefix option. The test properly validates the adapter-level interception capability by ensuring the handler correctly processes the request.


12-13: Clear assertions for response validation.

The test includes appropriate assertions to verify both the response content (contains 'pong') and the HTTP status code (200), providing comprehensive validation of the handler's behavior.

packages/client/src/utils.ts (2)

2-2: Import updates align with new type usage.

The updated imports correctly reflect the types needed for the new utility function while maintaining existing functionality.


38-43: Well-implemented type conversion utility.

This function elegantly handles the conversion from FriendlyClientOptions (where context may be optional) to ClientOptions (where context is required), ensuring type safety while providing a good developer experience.

packages/server/src/adapters/node/rpc-handler.test.ts (1)

1-3: Updated imports reflect simplified test approach.

The imports have been updated to include only what's necessary for the current test implementation.

packages/openapi/src/adapters/fetch/openapi-handler.test.ts (1)

1-1: Import statement updated to use simplified server imports.

The update correctly imports the necessary functionality from '@orpc/server'.

packages/server/src/plugins/cors.ts (2)

2-2: Import updated to include StandardHandlerPlugin.

The import statement has been correctly updated to include the newly implemented interface.


16-16:

Details

✅ Verification successful

Interface implementation updated for consistency.

The CORSPlugin now implements StandardHandlerPlugin<T> instead of HandlerPlugin<T>, which aligns with the PR objective of renaming internal APIs for clarity and consistency.

Ensure that all consumers of the CORSPlugin are updated to work with this interface change if necessary.


🏁 Script executed:

#!/bin/bash
# Let's verify if there are any direct references to HandlerPlugin that might need updating
rg -t ts "HandlerPlugin" --glob "!**/node_modules/**"

Length of output: 3116


Interface update verified: CORSPlugin now correctly implements StandardHandlerPlugin, and consumers appear to be aligned.

  • The file packages/server/src/plugins/cors.ts imports and implements StandardHandlerPlugin<T> as expected.
  • The repository-wide search confirmed that all relevant references now use StandardHandlerPlugin (including in tests and adjacent modules), ensuring consistency with the new internal API naming.
  • No obsolete references to HandlerPlugin<T> were found that would impact consumers of CORSPlugin.
packages/server/src/plugins/response-headers.ts (2)

1-1: Updated imports to reflect the use of StandardHandlerPlugin

The import statement has been updated to import StandardHandlerPlugin from '../adapters/standard' instead of using the previous HandlerPlugin from './base'. This aligns with the PR objective of renaming HandlerPlugin to StandardHandlerPlugin.


7-7: Updated class implementation to use StandardHandlerPlugin

The ResponseHeadersPlugin class now implements StandardHandlerPlugin<T> instead of HandlerPlugin<T>, which aligns with the PR objective of renaming internal APIs for clarity and consistency. The change maintains the same interface behavior with the plugin's init method.

packages/server/src/adapters/node/handler.test.ts (5)

1-18: Well-structured test setup with proper mocking

The test setup properly mocks external dependencies and includes a beforeEach hook to clear mocks between tests, following testing best practices. The mocking approach allows for isolated testing of the NodeHttpHandler class.


20-49: Good test scenario setup with handler options configuration

The test setup creates a handler instance with appropriate options, including the newly relocatable eventIteratorKeepAliveComment configuration and adapter interceptors, which aligns with the PR objective of moving configurations from the .handle method to handler options.


51-96: Comprehensive test for successful request handling

This test case thoroughly verifies that the handler correctly processes matched requests, calls the appropriate functions with expected arguments, and returns the expected result. The assertions validate both the result and the interaction with dependencies.


98-135: Thorough test for unmatched request scenarios

The test case verifies the handler's behavior when a request doesn't match any handler, ensuring that the expected response is returned and that sendStandardResponse is not called. The assertions are comprehensive and validate the proper interaction with dependencies.


137-156: Plugin initialization test validates adapter-level plugin functionality

This test ensures that plugins are properly initialized with the runtime adapter, which is a key part of the "Adapter-Level Plugin Interception" feature described in the PR objectives. The test verifies that the initialization function is called with the correct configuration.

packages/client/src/dynamic-link.ts (3)

2-2: Updated import to use renamed ClientOptions type

The import statement has been updated to use ClientOptions instead of ClientOptionsOut, aligning with the PR objective of renaming internal APIs for clarity and consistency.


11-11: Updated parameter type in linkResolver to use ClientOptions

The parameter type for the linkResolver function has been changed from ClientOptionsOut<TClientContext> to ClientOptions<TClientContext>, maintaining consistency with the type renaming across the codebase.


18-18: Updated call method parameter type to use ClientOptions

The parameter type for the call method has been updated from ClientOptionsOut<TClientContext> to ClientOptions<TClientContext>, completing the consistent type renaming throughout the class implementation.

packages/server/src/adapters/fetch/handler.test.ts (5)

1-16: Well-structured test setup with proper mocking

The test setup properly mocks the necessary dependencies using Vitest's mocking capabilities. The approach preserves the original implementation while allowing for spying on function calls, which is a good testing practice for validating interactions.


18-33: Test scenario setup includes handler options configuration

The test setup creates a handler instance with the appropriate options, including the eventIteratorKeepAliveComment configuration and adapter interceptors. This aligns with the PR objective of moving configurations from the .handle method to handler options.


34-76: Comprehensive test for successful request handling

This test case thoroughly verifies that the FetchHandler correctly processes matched requests, calls the appropriate functions with expected arguments, and returns the expected result. The assertions validate both the result and the interaction with dependencies, including the interceptor.


78-114: Thorough test for unmatched request scenarios

The test case verifies the handler's behavior when a request doesn't match any handler, ensuring that the expected response is returned and that toFetchResponse is not called. The assertions comprehensively validate the proper interaction with dependencies.


116-135: Plugin initialization test validates adapter-level plugin functionality

This test ensures that plugins are properly initialized with the runtime adapter, which is a key part of the "Adapter-Level Plugin Interception" feature described in the PR objectives. The test verifies that the initialization function is called with the correct configuration.

packages/client/src/adapters/standard/rpc-link-codec.ts (5)

2-2: Consistent import statement update

Replacing ClientOptionsOut with ClientOptions in the import is aligned with the newly introduced naming scheme. This change helps maintain consistency across the codebase.


15-15: Refined type usage for url property

Switching to ClientOptions<T> in the parameter tuple reflects the broader refactoring. The typed Value<> signature is correct, and no issues are evident here.


26-26: Refined type usage for maxUrlLength property

Similarly, using ClientOptions<T> harmonizes with the other interface properties. This maintains a clear, uniform approach to the client options.


37-37: Refined type usage for method property

The updated typing is consistent with the rest of the code. No major concerns or improvements needed here.


54-54: Refined type usage for headers property

Adopting ClientOptions<T> is properly aligned with the rest of the refactor. Looks good overall.

packages/server/src/adapters/fetch/handler.ts (7)

1-6: Review of imports and utilities

The newly introduced imports from @orpc/shared and @orpc/standard-server-fetch appear correctly referenced. Usage of NoInfer<> for preserving type inference looks thoughtfully applied.


8-8: Definition of FetchHandleResult

Clearly distinguishes between matched and unmatched scenarios. This makes the return type explicit and improves readability.


10-12: FetchHandlerPlugin interface extension

Providing a initRuntimeAdapter method is a clean approach for plugin-based initialization. This nicely complements the StandardHandlerPlugin definition.


14-18: FetchHandlerInterceptorOptions interface definition

Extends StandardHandleOptions<T> while adding fetch-specific properties like request and toFetchResponseOptions. No concerns here.


19-23: FetchHandlerOptions interface structure

Optional adapterInterceptors and plugins fields provide flexibility for custom interceptors and plugin configurations. This design is nicely extensible.


25-39: Constructor logic in FetchHandler

Initializes plugins and interceptors gracefully. Converting plugin options and interceptors to arrays ensures consistent iteration. This is straightforward and effective.


41-68: Implementation of the handle method

Leverages interceptors for request processing and delegates to the standard handler effectively. The final step uses toFetchResponse if a match is found, preserving a clean, layered design.

packages/client/src/adapters/fetch/link-fetch-client.ts (3)

3-3: Import statement aligned with new naming

Switching from ClientOptionsOut to ClientOptions aligns with the overall refactor across the codebase. Implementation looks consistent.


11-11: Refined options parameter type in LinkFetchClientOptions

Using ClientOptions<T> for the options parameter in the fetch method matches the standardized interface. No issues detected.


26-26: Updated signature in call method

Replacing ClientOptionsOut<T> with ClientOptions<T> maintains consistency with the new type definitions. This is a clear and logical change.

packages/client/src/plugins/retry.ts (5)

2-3: Imports updated for new plugin architecture
These updated imports reflect the shift from ClientPlugin to StandardLinkPlugin and from ClientOptionsOut to ClientOptions. They appear consistent with the broader refactoring.


30-30: Refactor to use ClientOptions
Replacing ClientOptionsOut<ClientRetryPluginContext> with ClientOptions<ClientRetryPluginContext> aligns with the new naming conventions. Please ensure any upstream or downstream usage is updated accordingly.


42-42: Same type refactoring as line 30


52-52: Same type refactoring as line 30


64-64: Class now implements StandardLinkPlugin
Switching from ClientPlugin to StandardLinkPlugin follows the new plugin interface structure. This should unify plugin behavior across the codebase.

packages/server/src/adapters/fetch/rpc-handler.ts (4)

3-4: New imports align with updated handler options
Importing StandardRPCHandlerOptions and FetchHandlerOptions reflects the merged configuration approach for RPC handlers.


7-7: Adopting FetchHandler base class
Replacing a custom or deprecated base handling approach with FetchHandler simplifies maintenance and aligns with the newly standardized architecture.


9-10: Class extends FetchHandler with combined options
The constructor merges FetchHandlerOptions and StandardRPCHandlerOptions via NoInfer, ensuring strong type checking. Verify that all references to the old handler structure have been removed or updated.


16-16: Delegation to StandardHandler
Forwarding requests to the StandardHandler instance fully leverages the new inheritance model. This should minimize duplication and maintain consistent processing logic.

packages/server/src/adapters/node/rpc-handler.ts (4)

3-4: New imports reflect merged Node and standard RPC handler options
Pulling in StandardRPCHandlerOptions and NodeHttpHandlerOptions indicates a unified configuration pattern.


7-7: Inheritance from NodeHttpHandler
Switching to extend NodeHttpHandler unifies behaviors and reduces implementation overhead. This follows the consistent refactoring approach observed in other handlers.


9-10: Combining standard and Node-specific options
Merging StandardRPCHandlerOptions<T> and NodeHttpHandlerOptions<T> in the constructor enforces a clean, single configuration source. Validate that client code references the new signature correctly.


16-16: Relying on StandardHandler for core logic
Passing router, matcher, codec, and combined options ensures a modular, maintainable implementation that delegates the heavy lifting to StandardHandler.

packages/openapi/src/adapters/fetch/openapi-handler.ts (4)

2-2: Looks good.

This new import of FetchHandlerOptions properly sets up the type requirements for handling fetch-specific options.


5-5: Appropriate import for FetchHandler.

Switching to a direct import of FetchHandler indicates the intent to leverage its built-in request-handling logic more effectively.


9-10: Clear extension from FetchHandler.

By extending FetchHandler<T>, you streamline the OpenAPIHandler implementation and reduce duplicate logic. The constructor signature merging StandardOpenAPIHandlerOptions<T> with FetchHandlerOptions<T> is consistent with the intended design.


17-17: Constructor invocation matches inheritance design.

Passing both the StandardHandler instance and the same options to the super constructor properly cascades all configurations. This cleanly unifies OpenAPI-specific and fetch-specific logic.

packages/server/src/adapters/standard/handler.ts (10)

2-2: Importing Interceptor.

Bringing in Interceptor from @orpc/shared is appropriate for advanced request/response interception logic.


9-9: Use of intercept, toArray, and trim.

These shared utilities improve readability and guard against undefined or non-array values.


12-15: Expanded interface for handle options.

Switching from a type alias to an interface clarifies that context is mandatory, and the optional prefix is well-defined.


19-21: Plugin initialization.

Providing an optional init method in StandardHandlerPlugin is a neat way to handle plugin-level setup before requests.


23-25: Refined interceptor options.

StandardHandlerInterceptorOptions now extending StandardHandleOptions ensures that every interceptor call has consistent access to context and request.


28-28: Consistent renaming to StandardHandlerPlugin.

This change aligns well with the rest of the refactoring efforts to name plugins more explicitly.


52-54: Explicit typed arrays for interceptors.

Using Exclude<undefined> enforces that interceptors and plugins are always stored as arrays, preventing repeated null checks.


60-60: NoInfer usage for options.

This pattern preserves inference boundaries correctly when passing StandardHandlerOptions<T> into the constructor.


66-68: Graceful fallback to arrays.

By using toArray, any undefined interceptors become an empty array, avoiding runtime errors.


73-73: Streamlined handle method.

  1. Consolidating interceptors into rootInterceptors and this.interceptors is straightforward for layered interception.
  2. Forwarding request within a combined options object clarifies the flow of data into the intercept chain.
  3. Using clientInterceptors for procedure invocation ensures consistent behavior across different routing paths.

Also applies to: 75-76, 82-82, 98-98

packages/client/src/types.ts (4)

3-3: Renamed to FriendlyClientOptions.

Renaming clarifies these client options are user-friendly and not strictly internal.


9-11: Refined function parameter tuple.

Using FriendlyClientOptions in ClientRest ensures the method signature cleanly supports optional input and context.


25-25: ClientOptions extends FriendlyClientOptions.

Taking on a required context prop in ClientOptions enforces that higher-level usage always includes context.


30-30: Accurate function signature.

Updating call to use ClientOptions<TClientContext> is consistent with the new naming and ensures a strongly typed context.

packages/openapi/src/adapters/node/openapi-handler.ts (2)

2-2: New imports from @orpc/server/node
These imports correctly align with the updated architecture for Node HTTP handling. The references to NodeHttpHandlerOptions and NodeHttpHandler appear consistent with their purpose in orchestrating request handling.

Also applies to: 5-5


9-17: Inherited design for OpenAPIHandler
By extending NodeHttpHandler<T>, this refactor centralizes the HTTP request handling, making OpenAPIHandler lighter and more cohesive. The constructor’s approach of combining StandardOpenAPIHandlerOptions<T> with NodeHttpHandlerOptions<T> is logical. Ensure that no unintended configuration conflicts occur when merging these two option types. Otherwise, the inheritance structure looks maintainable.

packages/server/src/adapters/node/handler.ts (6)

1-7: Imports and type definitions
Introducing NodeHttpRequest, NodeHttpResponse, and SendStandardResponseOptions from @orpc/standard-server-node is consistent with the new Node-based adapter approach. These imports set the stage for building an HTTP handler seamlessly integrated with the standard server logic.


8-8: Simple result type
The NodeHttpHandleResult union type is straightforward for indicating matched vs. unmatched requests. This clarity can help upstream logic quickly determine how to proceed without additional checks.


10-12: NodeHttpHandlerPlugin extension
Introducing initRuntimeAdapter for NodeHttpHandlerPlugin<T> ensures plugins can do last-mile initialization tasks. This design is flexible and aligns with the existing StandardHandlerPlugin. Nice extension of the plugin system.


14-22: NodeHttpHandlerOptions structure
These options incorporate adapterInterceptors and plugins, which provide an extensible interception layer at the adapter level. This approach is well-structured for advanced behavior (e.g., request/response transformations) and fosters consistent patterns across the codebase.


40-67: handle method flow
This method neatly intercepts the request at the adapter level before delegating to standardHandler.handle. It then sends the response if matched. The design fosters consistent interceptor logic while allowing you to refine the request/response as needed. Looks correct and well-structured, with clear responsibilities.


24-38:

Details

❓ Verification inconclusive

Class naming consistency
Defining export class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> { ... } could be confusing if an interface of the same name is also in scope. However, if the interface is purely auto-generated or type-aliased and does not conflict, this might be acceptable. Double-check duplication within the same namespace to avoid overshadowing.

To confirm, please search for any interface named NodeHttpHandler to ensure no overshadowing:


🏁 Script executed:

#!/bin/bash
# Searching for a conflicting interface named NodeHttpHandler throughout the codebase
rg --context 3 "interface NodeHttpHandler<" 

Length of output: 45


Naming Conflict Check – Please Verify Manually
The initial search for interface NodeHttpHandler< didn’t return any results, suggesting that there’s likely no conflicting interface in the repository. However, since the absence of output can sometimes be misleading, I recommend manually verifying that no interface named NodeHttpHandler (with or without generic parameters) is defined elsewhere in the codebase to ensure naming clarity.

packages/client/src/adapters/standard/types.ts (2)

2-2: Importing ClientOptions
Switching to ClientOptions aligns with the revised naming convention and the broader changes replacing ClientOptionsOut. This ensures consistency across the client code.


10-10: Aligning the call method signature
Using ClientOptions<T> removes ambiguity and keeps the call flow strongly typed. This completes the transition away from ClientOptionsOut.

packages/client/src/adapters/standard/link.ts (9)

3-3: Import type renamed from ClientOptionsOut to ClientOptions

This change aligns with the PR objectives, which stated that ClientOptionsOut has been renamed to ClientOptions for clarity and consistency across the codebase.


5-5: Added toArray utility import

Good addition of the toArray utility, which will be used to ensure consistent array handling in the constructor.


9-11: New StandardLinkPlugin interface replaces ClientPlugin

The introduction of StandardLinkPlugin with an optional init method provides a clearer plugin initialization pattern, aligning with the PR objective to rename ClientPlugin to StandardLinkPlugin.


14-14: Updated type reference to ClientOptions

Type signature updated to use ClientOptions<T> instead of ClientOptionsOut<T>, matching the renamed type.


16-16: Plugin type updated to StandardLinkPlugin

Type signature updated to use the newly defined StandardLinkPlugin<T> interface instead of the previous ClientPlugin<T>.


28-30: Improved plugin initialization pattern

Replaced the previous composite plugin approach with a more straightforward plugin initialization pattern. Each plugin's init method is called with the options if it exists, providing a cleaner extension point for plugins.


32-33: Enhanced array initialization with toArray utility

Replaced manual array initialization with the toArray utility function, making the code more robust by ensuring arrays are always returned even when inputs are undefined.


36-36: Updated method signature to use ClientOptions

Method signature updated to use ClientOptions<T> instead of ClientOptionsOut<T>, maintaining type consistency across the API surface.


44-44: Updated private method signature to use ClientOptions

Private method signature updated to use ClientOptions<T> instead of ClientOptionsOut<T>, maintaining internal type consistency.

@dinwwwh dinwwwh merged commit d17ef5e into main Mar 25, 2025
6 of 7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 23, 2025
5 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.

1 participant