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
3 changes: 3 additions & 0 deletions bun.lock

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@
"url": "https://github.com/ProverCoderAI/docker-git/issues"
},
"homepage": "https://github.com/ProverCoderAI/docker-git#readme",
"license": "MIT"
"license": "MIT",
"patchedDependencies": {
"@prover-coder-ai/openapi-effect@1.0.27": "patches/@prover-coder-ai%2Fopenapi-effect@1.0.27.patch"
}
}
2 changes: 1 addition & 1 deletion packages/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ RUN set -eu; \
FROM controller-base AS workspace-deps

COPY package.json bun.lock bunfig.toml tsconfig.base.json tsconfig.json ./
COPY patches ./patches
RUN mkdir -p packages/api packages/app packages/auth-oauth packages/container packages/docker-git-session-sync packages/lib packages/openapi packages/terminal
COPY packages/api/package.json ./packages/api/package.json
COPY packages/app/package.json ./packages/app/package.json
Expand Down Expand Up @@ -108,7 +109,6 @@ RUN set -eu; \

FROM workspace-deps AS workspace-static

COPY patches ./patches
COPY scripts ./scripts
COPY packages/container ./packages/container
COPY packages/auth-oauth ./packages/auth-oauth
Expand Down
72 changes: 72 additions & 0 deletions packages/app/tests/docker-git/openapi-effect-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createClient } from "@prover-coder-ai/docker-git-openapi"
import type { ApiFailure } from "@prover-coder-ai/docker-git-openapi"
import { Effect } from "effect"
import * as fc from "fast-check"
import { afterEach, vi } from "vitest"

import type { JsonValue } from "../../src/shared/json-schema.js"
import { renderDockerGitOpenApiFailure } from "../../src/web/api-http.js"
Expand Down Expand Up @@ -95,6 +96,11 @@ const assertOpenApiClientProperty = <PropertyArgs>(property: fc.IAsyncProperty<P
try: () => fc.assert(property, { numRuns: 25 })
})

afterEach(() => {
vi.restoreAllMocks()
vi.unstubAllGlobals()
})

describe("docker-git OpenAPI Effect client", () => {
it.effect("executes typed GET requests directly through openapi-effect", () =>
Effect.gen(function*(_) {
Expand Down Expand Up @@ -223,4 +229,70 @@ describe("docker-git OpenAPI Effect client", () => {
expect(requests[0]?.method).toBe("POST")
expect(new URL(requests[0]?.url ?? "").pathname).toBe("/projects/down-all")
}))

it.effect("falls back to getRandomValues when randomUUID is unavailable", () =>
Effect.gen(function*(_) {
const requests: Array<CapturedRequest> = []
const capturedIds: Array<string> = []
vi.stubGlobal("crypto", {
getRandomValues: (values: Uint8Array): Uint8Array => {
values.set([0x10, 0x32, 0x54, 0x76, 0x98])
return values
}
})

const api = createClient({
baseUrl: "https://docker-git.example.test",
fetch: createMockFetch(
requests,
createJsonResponse(200, {
cwd: "/workspace",
ok: true,
projectsRoot: "/workspace/projects",
revision: null
})
)
})
api.use({
onRequest: ({ id }) => {
capturedIds.push(id)
}
})

const success = yield* _(api.GET("/health"))

expect(success.status).toBe(200)
expect(capturedIds).toEqual(["103254769"])
expect(requests).toHaveLength(1)
}))

it.effect("falls back to a clock-based request id when Web Crypto is missing", () =>
Effect.gen(function*(_) {
const capturedIds: Array<string> = []
vi.stubGlobal("crypto", undefined)
vi.spyOn(Date, "now").mockReturnValue(0x1234567)

const api = createClient({
baseUrl: "https://docker-git.example.test",
fetch: createMockFetch(
[],
createJsonResponse(200, {
cwd: "/workspace",
ok: true,
projectsRoot: "/workspace/projects",
revision: null
})
)
})
api.use({
onRequest: ({ id }) => {
capturedIds.push(id)
}
})

const success = yield* _(api.GET("/health"))

expect(success.status).toBe(200)
expect(capturedIds).toEqual(["123456700"])
}))
})
8 changes: 8 additions & 0 deletions patches/@prover-coder-ai%2Fopenapi-effect@1.0.27.patch

Large diffs are not rendered by default.

Loading