Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/api/src/api/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ export const DockerGitApi = HttpApi.make("docker-git")
// CHANGE: derive Swagger/OpenAPI from the Effect HttpApi contract.
// WHY: frontend clients must be generated from one typed REST contract.
// QUOTE(ТЗ): "Надо сделать REST API нормальный на базе Effect и использовать Swagger."
// REF: user-message-2026-06-18-openapi-fetch
// SOURCE: https://openapi-ts.dev/openapi-fetch/
// REF: user-message-2026-06-19-openapi-effect
// SOURCE: https://github.com/ProverCoderAI/openapi-effect
// FORMAT THEOREM: forall endpoint e in DockerGitApi, e is represented in buildDockerGitOpenApi().paths.
// PURITY: CORE
// EFFECT: none
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ const textResponse = (data: string, contentType: string, status = 200) =>
// CHANGE: expose browser-readable Swagger UI for the Effect REST contract.
// WHY: generated clients and humans must inspect the same OpenAPI document.
// QUOTE(ТЗ): "использовать Swagger"
// REF: user-message-2026-06-18-openapi-fetch
// SOURCE: n/a
// REF: user-message-2026-06-19-openapi-effect
Comment thread
coderabbitai[bot] marked this conversation as resolved.
// SOURCE: https://github.com/ProverCoderAI/openapi-effect
// FORMAT THEOREM: docsPath(d) = p -> openApiPath(d) = sibling(p, "openapi.json")
// PURITY: CORE
// EFFECT: none
Expand Down
45 changes: 38 additions & 7 deletions packages/app/src/web/api-create-project.ts
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
Expand Down Expand Up @@ -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
)
)
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading
Loading