feat(app): add createClientEffect for zero-boilerplate OpenAPI usage#6
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: ProverCoderAI#5
…boilerplate API usage
- Add createUniversalDispatcher that classifies responses by HTTP status range
(2xx → success channel, non-2xx → error channel) without code generation
- Add createClientEffect<Paths>(options) — zero-boilerplate Effect-based API client
that works with any OpenAPI schema without generated dispatchers or registry setup
- Export new APIs through shell/api-client/index.ts
This enables the user's desired DSL:
const apiClientEffect = createClientEffect<paths>(clientOptions)
apiClientEffect.POST("/api/auth/login", { body: credentials })
INVARIANT: ∀ path, method: path ∈ PathsForMethod<Paths, method> (compile-time)
INVARIANT: ∀ status ∈ [200..299]: success channel; otherwise: error channel (runtime)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…with auth schema - 10 runtime tests: POST /api/auth/login (200, 400, 401, 500), POST /api/auth/logout (204), GET /api/auth/me (200, 401), POST /api/register (201, 409), UnexpectedContentType boundary error - 23 type-level tests: PathsForMethod constraints, literal status preservation, HttpError status unions, ApiFailure union members, RequestOptionsFor body constraints Total tests: 69 → 102 (all passing) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit ab9bf8c.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart 1/3Detected uncommitted changes from previous run. Starting new session to review and commit them. Uncommitted files: Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback. |
…ct with openapi-typescript output - Add ESLint override for openapi.d.ts: disable sonarjs/class-name and max-lines (openapi-typescript generates lowercase interface names per OpenAPI spec convention) - Add openapi.d.ts to jscpd ignore list (generated types have structural repetition by design) - Auto-formatted openapi.d.ts by ESLint dprint (semicolons → ASI, tabs → spaces) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Исправь ошибки линтера Проверь что вот такой код работает: Напиши под него CI/CD проверку |
🔄 Auto-restart 1/3 LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
🤖 AI Work Session Started Starting automated work session at 2026-02-06T13:47:21.397Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
⏳ Usage Limit ReachedThe automated solution draft was interrupted because the Claude usage limit was reached. 📊 Limit Information
🔄 How to ContinueAuto-resume is enabled. The session will automatically resume (with context preserved) when the limit resets. Click to expand execution log (43KB)This session was interrupted due to usage limits. You can resume once the limit resets. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Click to expand solution draft log (48KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
⏰ Auto Resume (on limit reset) Auto-resuming automated work session at 2026-02-06T15:05:55.547Z This session automatically resumed after the usage limit reset, continuing with the previous context preserved. The PR has been converted to draft mode while work is in progress. This is an auto-resumed session. Please wait for the session to finish, and provide your feedback. |
… CI integration test
- Export createClientEffect and createUniversalDispatcher from src/index.ts
so `import { createClientEffect, type ClientOptions } from "openapi-effect"` works
- Add integration test verifying the exact user DSL snippet from issue ProverCoderAI#5:
createClientEffect<paths>(options).POST("/api/auth/login", { body: credentials })
- 5 new tests: POST with body, yield* pattern, error handling, GET, 204 no-content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🔄 Draft log of auto resume (on limit reset)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Note: This session was automatically resumed after a usage limit reset, with the previous context preserved.
|
|
Я не хочу что бы мы писали лишние элементы типо "yield* Effect.either(" |
|
🤖 AI Work Session Started Starting automated work session at 2026-02-07T05:12:55.396Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
⏳ Usage Limit ReachedThe automated solution draft was interrupted because the Claude usage limit was reached. 📊 Limit Information
🔄 How to ContinueAuto-resume is enabled. The session will automatically resume (with context preserved) when the limit resets. Click to expand execution log (43KB)This session was interrupted due to usage limits. You can resume once the limit resets. |
Summary
Implements
createClientEffect<Paths>(options)— a zero-boilerplate Effect-based API client that works with any OpenAPI schema without code generation or dispatcher setup.Fixes #5
The user's desired DSL now works:
Key Changes
createUniversalDispatcher<Responses>()instrict-client.ts: Generic dispatcher that classifies responses by HTTP status range (2xx → success channel, non-2xx → error channel) and parses JSON automatically. No per-operation code generation needed.createClientEffect<Paths>(options)increate-client.ts: Zero-boilerplate client factory that uses the universal dispatcher. UnlikecreateClient, it requires no dispatcher registry or generated code.createClientEffect,createUniversalDispatcher, andClientOptionsexported fromsrc/index.tsso the user's import patternfrom "openapi-effect"works.create-client-effect-integration.test.tsverifies the exact user DSL snippet from issue Мне надо что бы по OpenAPI мы могли использовать openapi-effect библиотеку #5 compiles and produces correct runtime behavior (POST with body, yield* pattern, error handling, GET, 204 no-content).openapi.d.ts(generated by openapi-typescript) to disablesonarjs/class-nameandmax-linesrules that conflict with OpenAPI spec convention. Addedopenapi.d.tsto jscpd ignore list (generated types have structural repetition by design). This was a pre-existing CI failure onmain.Architectural Design
The universal dispatcher handles all common OpenAPI response patterns:
status ∈ [200..299]→ success channel (ApiSuccess)status ∉ [200..299]→ error channel (HttpErrorwith_tag: "HttpError")Content-Type: application/json→ JSON parsed automaticallystatus = 204or empty body →{ contentType: "none", body: undefined }UnexpectedContentTypeboundary errorType safety is enforced at compile time through the existing
PathsForMethod,RequestOptionsFor, andStrictApiClientWithDispatcherstype machinery. The universal dispatcher provides the runtime classification.Mathematical Guarantees
∀ Paths, options: createClientEffect<Paths>(options) → StrictApiClientWithDispatchers<Paths>∀ path, method: path ∈ PathsForMethod<Paths, method>(compile-time)∀ status ∈ [200..299]: response → success channel(runtime)∀ status ∉ [200..299]: response → error channel with HttpError _tag(runtime)∀ error ∈ Failures: ¬throws ∧ Effect.fail(error)Test Plan
pnpm typecheck)pnpm vitest run) — 69 existing + 38 newpnpm lint— 0 errors, 0 warnings)pnpm lint:effect)pnpm build)src/index.ts)🤖 Generated with Claude Code