Fix errors
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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", () => { });
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ export function body(body: { readonly body: ReadableStream<Uint8Array> | null; }
|
||||
);
|
||||
}
|
||||
|
||||
export function bytes(body: { bytes(): Promise<Uint8Array> }): Effect.Effect<Uint8Array, BodyError> {
|
||||
export function bytes<T extends ArrayBufferLike>(body: { bytes(): Promise<Uint8Array<T>> }): Effect.Effect<Uint8Array<T>, BodyError> {
|
||||
return Effect.tryPromise({
|
||||
try: () => body.bytes(),
|
||||
catch: (cause) => {
|
||||
|
||||
@@ -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<ArrayBuffer>);
|
||||
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<ArrayBuffer>);
|
||||
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<ArrayBuffer>);
|
||||
const exit = await Effect.runPromiseExit(effect);
|
||||
|
||||
Test.expectFailureTag(exit, "ParseError");
|
||||
|
||||
@@ -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<Uint8Array, CborEncodeError> {
|
||||
export function encode(u: unknown): Effect.Effect<Uint8Array<ArrayBuffer>, CborEncodeError> {
|
||||
return Effect.try({
|
||||
try: () => cbor.encode(u),
|
||||
try: () => cbor.encode(u) as Uint8Array<ArrayBuffer>,
|
||||
catch: (cause) => new CborEncodeError({ cause }),
|
||||
});
|
||||
}
|
||||
|
||||
export function decode(u: Uint8Array): Effect.Effect<unknown, CborDecodeError> {
|
||||
export function decode(u: Uint8Array<ArrayBuffer>): Effect.Effect<unknown, CborDecodeError> {
|
||||
return Effect.try({
|
||||
try: () => cbor.decode(u),
|
||||
catch: (cause) => new CborDecodeError({ cause }),
|
||||
@@ -28,7 +28,7 @@ export const encodeSchema = <A, I>(schema: Schema.Schema<A, I>) => {
|
||||
|
||||
export const decodeSchema = <A>(schema: Schema.Schema<A, any>) => {
|
||||
const schemaDecoder = Schema.decodeUnknown(schema);
|
||||
return (u: Uint8Array) => pipe(
|
||||
return (u: Uint8Array<ArrayBuffer>) => pipe(
|
||||
decode(u),
|
||||
Effect.flatMap((u) => schemaDecoder(u)),
|
||||
);
|
||||
|
||||
@@ -78,7 +78,7 @@ export const decodeBody = <A>(schema: Schema.Schema<A, any>) => {
|
||||
};
|
||||
|
||||
export interface BodyData {
|
||||
readonly body: null | Uint8Array;
|
||||
readonly body: null | Uint8Array<ArrayBuffer>;
|
||||
readonly headers: { readonly [_: string]: string };
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export const emptyBody: () => BodyData = constant(Object.freeze<BodyData>({
|
||||
headers: Object.freeze({}),
|
||||
}));
|
||||
|
||||
export const cborBody: (bytes: Uint8Array) => BodyData = (bytes) => Object.freeze<BodyData>({
|
||||
export const cborBody: (bytes: Uint8Array<ArrayBuffer>) => BodyData = (bytes) => Object.freeze<BodyData>({
|
||||
body: bytes,
|
||||
headers: Object.freeze({
|
||||
"Content-Type": "application/cbor",
|
||||
|
||||
Reference in New Issue
Block a user