History

Merge remote-tracking branch 'origin/codex/batch20-core-api-boundaries' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit 14237232 parents 33c2bd1 b953a1f2 files · +14 −9Browse files

Unified · Split

2 files
  1. packages/core/api/src/handlers/tools.ts +1 −1
  2. packages/core/api/src/oauth-popup.test.ts +13 −8
packages/core/api/src/handlers/tools.ts+1−1
@@ -35,7 +35,7 @@ export const ToolsHandlers = HttpApiBuilder.group(ExecutorApi, "tools", (handler · 34 unmodified lines
35 const executor = yield* ExecutorService;35 const executor = yield* ExecutorService;
36 const schema = yield* executor.tools.schema(path.toolId);36 const schema = yield* executor.tools.schema(path.toolId);
37 if (schema === null) {37 if (schema === null) {
38 return yield* Effect.fail(new ToolNotFoundError({ toolId: path.toolId }));38 return yield* new ToolNotFoundError({ toolId: path.toolId });
39 }39 }
40 return schema;40 return schema;
41 })),41 })),
packages/core/api/src/oauth-popup.test.ts+13−8
@@ -6,7 +6,7 @@ · 5 unmodified lines
6// ---------------------------------------------------------------------------6// ---------------------------------------------------------------------------
7 7
8import { describe, expect, it } from "@effect/vitest";8import { describe, expect, it } from "@effect/vitest";
9import { Effect } from "effect";9import { Data, Effect, Schema } from "effect";
10 10
11import {11import {
12 OAUTH_POPUP_MESSAGE_TYPE,12 OAUTH_POPUP_MESSAGE_TYPE,
@@ -169,16 +169,21 @@ describe("runOAuthCallback", () => { · 156 unmodified lines
169 });169 });
170 170
171 it("renders a failure popup when completeOAuth fails and uses toErrorMessage", async () => {171 it("renders a failure popup when completeOAuth fails and uses toErrorMessage", async () => {
172 class DomainError {172 class DomainError extends Data.TaggedError("DomainError")<{
173 readonly _tag = "DomainError";173 readonly message: string;
174 constructor(readonly message: string) {}174 }> {}
175 }175 const isDomainError = Schema.is(Schema.Struct({
176 _tag: Schema.Literal("DomainError"),
177 message: Schema.String,
178 }));
176 const html = await Effect.runPromise(179 const html = await Effect.runPromise(
177 runOAuthCallback<GoogleAuth, DomainError, never>({180 runOAuthCallback<GoogleAuth, DomainError, never>({
178 complete: () => Effect.fail(new DomainError("Code expired")),181 complete: () => Effect.fail(new DomainError({ message: "Code expired" })),
179 urlParams: { state: "s1" },182 urlParams: { state: "s1" },
180 toErrorMessage: (error) =>183 toErrorMessage: (error) => {
181 error instanceof DomainError ? error.message : "unknown",184 // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: schema guard narrows the unknown popup callback error to the public test message
185 return isDomainError(error) ? error.message : "unknown";
186 },
182 channelName: "c",187 channelName: "c",
183 }),188 }),
184 );189 );