This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Brand, Context, Data, Effect, Layer } from "effect"; | |
type FileMetadata = Readonly<{ type: string; size: number }>; | |
export type ValidFile = FileMetadata & Brand.Brand<"ValidFile">; | |
const ValidFile = Brand.nominal<ValidFile>(); | |
class FileTooLargeError extends Data.TaggedError("FileTooLargeError")< | |
Readonly<{ size: number }> | |
> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { setup } from "xstate"; | |
const machine = setup({ | |
types: { | |
context: {} as {}, | |
events: {} as { readonly type: "event"; readonly params: {} }, | |
}, | |
actions: {}, | |
}).createMachine({ | |
id: "machine", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Data, Either } from "effect"; | |
import type { z } from "zod"; | |
export class ZodParseError<In> extends Data.TaggedError("ZodParseError")<{ | |
error: z.ZodError<In>; | |
}> {} | |
export const parseZod = | |
<ReqOut, ReqIn>(schema: z.Schema<ReqOut, z.ZodTypeDef, ReqIn>) => | |
<T>(data: T): Either.Either<ZodParseError<ReqIn>, ReqOut> => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension IOExtension<L, R> on IOEither<L, R> { | |
IOEither<L, R> runSideEffect({ | |
final void Function(L l)? onLeft, | |
final void Function(R r)? onRight, | |
}) => | |
chainFirst( | |
(r) => IOEither<L, void>.fromIO( | |
IO(() => onRight?.call(r)), | |
), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fp_ts | |
import * as O from 'fp-ts/Option'; | |
import * as TE from 'fp-ts/TaskEither'; | |
import { pipe } from 'fp-ts/lib/function'; | |
import { head } from 'fp-ts/lib/Array'; | |
// Supabase | |
import { PostgrestFilterBuilder } from '@supabase/postgrest-js'; | |
import { SupabaseQueryBuilder } from '@supabase/supabase-js/dist/main/lib/SupabaseQueryBuilder'; | |
import { SupabaseClient } from '@supabase/supabase-js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
/// Manage conversion to and from base 64 | |
mixin Base64Mixin { | |
/// Converts a [dynamic] data from plain [String] to base64 | |
String toBase64(dynamic data) => base64.encode(utf8.encode(jsonEncode(data))); | |
/// Converts a [dynamic] data from base64 to plain [String] | |
String fromBase64(dynamic data) => utf8.decode(base64.decode(data as String)); | |
} |