Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 12
[codex] Use openapi-effect client#431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b2802937d9deb6a603c4e10afed025cb31e30c1e10753f7b466b7611File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,14 @@ | ||
| import type { Effect } from "effect" | ||
| import { Effect, Match } from "effect" | ||
| import { dockerGitOpenApi, renderDockerGitOpenApiFailure } from "./api-http.js" | ||
| import { | ||
| type BaseCreateProjectBody, | ||
| baseCreateProjectBody, | ||
| type CreateProjectRequestDraft, | ||
| optionalProjectResourceFields, | ||
| type OptionalProjectResourceFieldsBody | ||
| } from "./api-project-create-body.js" | ||
| import { CreateProjectAcceptedResponseSchema } from "./api-schema.js" | ||
| import type { CreateProjectAcceptedResponse } from "./api-schema.js" | ||
| import { openApiJsonSchema } from "./openapi-client.js" | ||
| type CreateProjectAcceptedBody = Readonly< | ||
| & BaseCreateProjectBody | ||
| @@ -39,10 +38,42 @@ export const createProjectAcceptedBody = (draft: CreateProjectRequestDraft): Cre | ||
| ...optionalProjectResourceFields(draft) | ||
| }) | ||
| // CHANGE: Publish the async project creation boundary with an explicit Effect signature. | ||
| // WHY: exported web API helpers must expose typed success, error, and requirement channels. | ||
| // QUOTE(ТЗ): "исправь" | ||
| // REF: PR#431 CodeRabbit review 4535473023 | ||
| // SOURCE: n/a | ||
| // FORMAT THEOREM: forall draft d: accepted(d) -> Effect<CreateProjectAcceptedResponse, string, never>. | ||
| // PURITY: SHELL | ||
| // EFFECT: Effect<CreateProjectAcceptedResponse, string, never> | ||
| // INVARIANT: only HTTP 202 is accepted as the asynchronous creation success branch. | ||
| // COMPLEXITY: O(1)/O(1), excluding HTTP transport. | ||
| /** | ||
| * Starts asynchronous project creation through the typed OpenAPI client. | ||
| * | ||
| * @param draft - Validated project creation draft plus optional resource limits. | ||
| * @returns Effect that resolves to the accepted async creation response. | ||
| * | ||
| * @pure false - performs HTTP IO when the returned Effect is executed. | ||
| * @effect Effect<CreateProjectAcceptedResponse, string, never> | ||
| * @invariant HTTP 202 returns the accepted response; HTTP 201 is rejected as a sync branch mismatch. | ||
| * @precondition draft fields were validated by the UI create flow. | ||
| * @postcondition downstream callers observe only accepted async responses or string-rendered failures. | ||
| * @complexity O(1)/O(1), excluding HTTP transport and response body size. | ||
| * @throws Never - failures are represented in the Effect error channel. | ||
| */ | ||
| export const startCreateProject = ( | ||
| draft: CreateProjectRequestDraft | ||
| ): Effect.Effect<CreateProjectAcceptedResponse, string> => | ||
| openApiJsonSchema(CreateProjectAcceptedResponseSchema, (client) => | ||
| client.POST("/projects", { | ||
| body: createProjectAcceptedBody(draft) | ||
| })) | ||
| dockerGitOpenApi.POST("/projects", { | ||
| body: createProjectAcceptedBody(draft) | ||
| }).pipe( | ||
| Effect.mapError(renderDockerGitOpenApiFailure), | ||
| Effect.flatMap((success) => | ||
| Match.value(success).pipe( | ||
| Match.when({ status: 202 }, ({ body }) => Effect.succeed(body)), | ||
| Match.when({ status: 201 }, () => Effect.fail("HTTP 201: unexpected synchronous project creation response")), | ||
| Match.exhaustive | ||
| ) | ||
| ) | ||
| ) | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.