Repository navigation
Detect async schema markers - #6
olstenlarck wants to merge 4 commits into
Conversation
📝 WalkthroughWalkthroughAsync schema markers are detected across input, output, and error schemas. Procedures with detected async schemas now expose Promise results and normalize execution with ChangesAsync schema Promise handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant ZagoraHandler
participant HasAsyncSchema
participant forwardProcedure
Caller->>ZagoraHandler: invoke procedure
ZagoraHandler->>HasAsyncSchema: inspect configured schemas
HasAsyncSchema-->>ZagoraHandler: async state
ZagoraHandler->>forwardProcedure: execute procedure
forwardProcedure-->>ZagoraHandler: result
ZagoraHandler-->>Caller: direct result or Promise<ZagoraResult>
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/index.ts (1)
207-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid erasing the
errors()generic contract withany.Instantiate
Zagorawith the current generic arguments, includingTErrors, instead of suppressing the constructor’s type checking. Confirm the typed construction passes the repository typecheck.As per coding guidelines, don't use any.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/index.ts` at line 207, Update the Zagora instantiation in the surrounding construction flow to preserve the existing generic arguments, including TErrors, instead of casting the result to any. Remove the any cast and ensure the typed constructor call passes the repository typecheck while retaining the errors() contract.Source: Coding guidelines
test/main.test.ts (2)
201-201: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the invalid-input test type-safe.
Use
@ts-expect-errorfor this intentional invalid call so the test also verifies that the public signature rejects numbers.Proposed fix
- const invalidInputResult = outputProcedure(123 as any); + // `@ts-expect-error` -- intentionally exercise runtime input validation + const invalidInputResult = outputProcedure(123);As per coding guidelines, don't use any.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/main.test.ts` at line 201, Update the invalid-input test around outputProcedure to remove the any cast and add a `@ts-expect-error` directive immediately before the intentional numeric call. Preserve the runtime assertion while ensuring TypeScript verifies that outputProcedure rejects numbers.Source: Coding guidelines
3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the Valibot namespace imports with named imports.
Import the Valibot builders used in each test directly and replace the
v.*references with named namespace imports.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/main.test.ts` at line 3, Replace the Valibot namespace imports and v.* usages in test/main.test.ts at lines 3-3 and test/types-testing.test.ts at lines 31-31 with direct named imports for each builder used by the tests; update all references in both files while preserving their existing behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/main.test.ts`:
- Around line 190-223: Extend the test “Valibot async schemas always return
promises” to cover asynchronous validation failures: call outputProcedure with
"bad" and assert the awaited result is a failed outcome, and call errorProcedure
with "fail" and assert the awaited result is also unsuccessful. Keep the
existing invalid-input and success assertions intact.
---
Nitpick comments:
In `@src/index.ts`:
- Line 207: Update the Zagora instantiation in the surrounding construction flow
to preserve the existing generic arguments, including TErrors, instead of
casting the result to any. Remove the any cast and ensure the typed constructor
call passes the repository typecheck while retaining the errors() contract.
In `@test/main.test.ts`:
- Line 201: Update the invalid-input test around outputProcedure to remove the
any cast and add a `@ts-expect-error` directive immediately before the intentional
numeric call. Preserve the runtime assertion while ensuring TypeScript verifies
that outputProcedure rejects numbers.
- Line 3: Replace the Valibot namespace imports and v.* usages in
test/main.test.ts at lines 3-3 and test/types-testing.test.ts at lines 31-31
with direct named imports for each builder used by the tests; update all
references in both files while preserving their existing behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a6a0e999-44d8-477e-8cf0-f78f3e476823
📒 Files selected for processing (5)
README.mdsrc/index.tssrc/types.tstest/main.test.tstest/types-testing.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f87a0d467
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/index.ts (1)
208-208: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid bypassing the
errors()return type withany.Construct the returned
Zagorawith its explicit generic arguments so theTErrorscontract is preserved, instead of asserting the typed builder toany.Proposed fix
- return new Zagora({ + return new Zagora< + THandlerFn, + TContext, + TInputSchema, + TOutputSchema, + TErrors, + TEnvVarsMap, + TCacheAdapter, + TDisableOptions, + TAutoCallable + >({ ...this["~zagora"], errorsMap, - }) as any; + });As per coding guidelines, “Don't use the any type.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/index.ts` at line 208, Remove the `as any` assertion at the returned `Zagora` construction and instantiate it with explicit generic arguments, preserving the `TErrors` contract exposed by `errors()` and maintaining the existing typed builder behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/index.ts`:
- Line 208: Remove the `as any` assertion at the returned `Zagora` construction
and instantiate it with explicit generic arguments, preserving the `TErrors`
contract exposed by `errors()` and maintaining the existing typed builder
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 00c3e8de-c36b-4a7b-a0c5-1d993fe73de2
📒 Files selected for processing (4)
src/index.tssrc/types.tstest/main.test.tstest/types-testing.test.ts
|
the #7 is merged. closing. |
Summary
async: true, including ValibotTesting
Partially #5, will remain open until StandardSchema async is figured out.
Summary by CodeRabbit
New Features
Documentation
awaitwith validators such as Zod.