From cbdd93e6ba123c6b98bbf9f4d4c5c8d00e5f7600 Mon Sep 17 00:00:00 2001 From: Szymon Nowakowski Date: Thu, 9 Oct 2025 16:34:10 +0200 Subject: [PATCH] Fix errors --- .../backend/src/services/Authentication.ts | 2 +- packages/common/src/Body.test.ts | 28 +++++++++---------- packages/common/src/Body.ts | 2 +- packages/common/src/Cbor.test.ts | 8 +++--- packages/common/src/Cbor.ts | 8 +++--- packages/common/src/Client.ts | 4 +-- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/backend/src/services/Authentication.ts b/packages/backend/src/services/Authentication.ts index 7baff80..89937e2 100644 --- a/packages/backend/src/services/Authentication.ts +++ b/packages/backend/src/services/Authentication.ts @@ -284,7 +284,7 @@ export const makeAuthorizationUrl = (sessionId: SessionId) => Effect.gen(functio .$call(Database.execute); const url = new URL(config.OAUTH_AUTHORIZATION_ENDPOINT); - url.searchParams.set("client_id", config.CLIENT_ID); + url.searchParams.set("client_id", config.OAUTH_CLIENT_ID); url.searchParams.set("response_type", "code"); url.searchParams.set("redirect_uri", REDIRECT_URI); url.searchParams.set("scope", OAUTH_SCOPE); diff --git a/packages/common/src/Body.test.ts b/packages/common/src/Body.test.ts index 14e4bec..58ceff6 100644 --- a/packages/common/src/Body.test.ts +++ b/packages/common/src/Body.test.ts @@ -60,33 +60,33 @@ describe("blob", () => { }); describe("body", () => { - test.todo("succeeds with none"); - test.todo("succeeds with some"); + test.todo("succeeds with none", () => { }); + test.todo("succeeds with some", () => { }); }); describe("bytes", () => { - test.todo("succeeds"); - test.todo("fails"); - test.todo("dies"); + test.todo("succeeds", () => { }); + test.todo("fails", () => { }); + test.todo("dies", () => { }); }); describe("formData", () => { - test.todo("succeeds"); - test.todo("fails"); - test.todo("dies"); + test.todo("succeeds", () => { }); + test.todo("fails", () => { }); + test.todo("dies", () => { }); }); describe("json", () => { - test.todo("succeeds"); - test.todo("fails"); - test.todo("dies"); + test.todo("succeeds", () => { }); + test.todo("fails", () => { }); + test.todo("dies", () => { }); }); describe("stream", () => { - test.todo("succeeds"); + test.todo("succeeds", () => { }); }); describe("json", () => { - test.todo("succeeds"); - test.todo("dies"); + test.todo("succeeds", () => { }); + test.todo("dies", () => { }); }); diff --git a/packages/common/src/Body.ts b/packages/common/src/Body.ts index dbb5b67..092796b 100644 --- a/packages/common/src/Body.ts +++ b/packages/common/src/Body.ts @@ -28,7 +28,7 @@ export function body(body: { readonly body: ReadableStream | null; } ); } -export function bytes(body: { bytes(): Promise }): Effect.Effect { +export function bytes(body: { bytes(): Promise> }): Effect.Effect, BodyError> { return Effect.tryPromise({ try: () => body.bytes(), catch: (cause) => { diff --git a/packages/common/src/Cbor.test.ts b/packages/common/src/Cbor.test.ts index 8aa2ebe..6951581 100644 --- a/packages/common/src/Cbor.test.ts +++ b/packages/common/src/Cbor.test.ts @@ -40,7 +40,7 @@ describe("decode", () => { z: new Uint8Array([0, 1, 2, 3]), }; - const effect = Cbor.decode(cbor.encode(object)); + const effect = Cbor.decode(cbor.encode(object) as Uint8Array); const exit = await Effect.runPromiseExit(effect); Test.expectSuccess(exit, object); @@ -76,7 +76,7 @@ describe("encodeSchema", () => { Test.expectSuccess(exit, cbor.encode(object)); }); - test.todo("fails"); + test.todo("fails", () => { }); }); describe("decodeSchema", () => { @@ -93,7 +93,7 @@ describe("decodeSchema", () => { z: new Uint8Array([0, 1, 2, 3]), }); - const effect = Cbor.decodeSchema(schema)(cbor.encode(object)); + const effect = Cbor.decodeSchema(schema)(cbor.encode(object) as Uint8Array); const exit = await Effect.runPromiseExit(effect); Test.expectSuccess(exit, object); @@ -109,7 +109,7 @@ describe("decodeSchema", () => { }); test("fails with ParseError", async () => { - const effect = Cbor.decodeSchema(Schema.Number)(cbor.encode("foo")); + const effect = Cbor.decodeSchema(Schema.Number)(cbor.encode("foo") as Uint8Array); const exit = await Effect.runPromiseExit(effect); Test.expectFailureTag(exit, "ParseError"); diff --git a/packages/common/src/Cbor.ts b/packages/common/src/Cbor.ts index abe8700..1d3316b 100644 --- a/packages/common/src/Cbor.ts +++ b/packages/common/src/Cbor.ts @@ -4,14 +4,14 @@ import { Data, Effect, pipe, Schema } from "effect"; export class CborDecodeError extends Data.TaggedError("CborDecodeError")<{ cause: unknown }> { } export class CborEncodeError extends Data.TaggedError("CborEncodeError")<{ cause: unknown }> { } -export function encode(u: unknown): Effect.Effect { +export function encode(u: unknown): Effect.Effect, CborEncodeError> { return Effect.try({ - try: () => cbor.encode(u), + try: () => cbor.encode(u) as Uint8Array, catch: (cause) => new CborEncodeError({ cause }), }); } -export function decode(u: Uint8Array): Effect.Effect { +export function decode(u: Uint8Array): Effect.Effect { return Effect.try({ try: () => cbor.decode(u), catch: (cause) => new CborDecodeError({ cause }), @@ -28,7 +28,7 @@ export const encodeSchema = (schema: Schema.Schema) => { export const decodeSchema = (schema: Schema.Schema) => { const schemaDecoder = Schema.decodeUnknown(schema); - return (u: Uint8Array) => pipe( + return (u: Uint8Array) => pipe( decode(u), Effect.flatMap((u) => schemaDecoder(u)), ); diff --git a/packages/common/src/Client.ts b/packages/common/src/Client.ts index e10b980..6e3124f 100644 --- a/packages/common/src/Client.ts +++ b/packages/common/src/Client.ts @@ -78,7 +78,7 @@ export const decodeBody = (schema: Schema.Schema) => { }; export interface BodyData { - readonly body: null | Uint8Array; + readonly body: null | Uint8Array; readonly headers: { readonly [_: string]: string }; } @@ -100,7 +100,7 @@ export const emptyBody: () => BodyData = constant(Object.freeze({ headers: Object.freeze({}), })); -export const cborBody: (bytes: Uint8Array) => BodyData = (bytes) => Object.freeze({ +export const cborBody: (bytes: Uint8Array) => BodyData = (bytes) => Object.freeze({ body: bytes, headers: Object.freeze({ "Content-Type": "application/cbor",