something
This commit is contained in:
parent
452c41a75a
commit
ad74ff9995
12
index.ts
12
index.ts
|
@ -1,12 +0,0 @@
|
|||
import * as S from "fp-ts/String";
|
||||
import * as M from "fp-ts/Map";
|
||||
import { getMonoid } from "fp-ts/lib/Array";
|
||||
|
||||
enum DurationUnit {
|
||||
MILLISECOND = "ms",
|
||||
SECOND = "sec",
|
||||
MINUTE = "min",
|
||||
HOUR = "hr",
|
||||
}
|
||||
|
||||
const unitMap = M.fromFoldable(S.Ord, getMonoid<String>());
|
|
@ -0,0 +1,9 @@
|
|||
export interface Args {
|
||||
testFile: string;
|
||||
}
|
||||
|
||||
export const parseArgs = (argv: string[]): Args => {
|
||||
const useful = argv.slice(2); // skip bun path and script path
|
||||
|
||||
const flags = useful.map((x, i) => x.startsWith("--") && i);
|
||||
};
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from "imapflow";
|
||||
import * as IO from "fp-ts/lib/IO";
|
||||
import * as T from "fp-ts/lib/Task";
|
||||
import { ConsoleLogger } from "../util/logger";
|
||||
import { ConsoleLogger } from "../util";
|
||||
|
||||
interface ImapClientI {
|
||||
fetchAll: (
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
import * as IO from "fp-ts/IO";
|
||||
import type { Publisher } from "./publisher";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
export interface Config {
|
||||
result_publishers: Publisher[];
|
||||
dns: string[];
|
||||
timeout: string;
|
||||
}
|
||||
|
||||
export const readConfig =
|
||||
(filePath: string): IO.IO<Config> =>
|
||||
() => {
|
||||
const confStr = readFileSync(filePath, "utf-8");
|
||||
return JSON.parse(confStr);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import * as IO from "fp-ts/IO";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
const main: IO.IO<void> = ConsoleLogger.log("Hello, world!");
|
||||
|
||||
main();
|
|
@ -1,4 +1,4 @@
|
|||
import type { Duration, Result } from "../util";
|
||||
import { D } from "../util";
|
||||
|
||||
export enum PublisherType {
|
||||
DISCORD = "discord",
|
||||
|
@ -18,10 +18,6 @@ export type PublisherPost = DiscordPost | NtfyPost;
|
|||
|
||||
export interface Publisher {
|
||||
type: PublisherType;
|
||||
at: Duration;
|
||||
at: D.Duration;
|
||||
post: PublisherPost;
|
||||
}
|
||||
|
||||
export interface ResultPublishable {
|
||||
publish(testResult: Result<boolean, Error>): void;
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export * as D from "./duration";
|
||||
export * from "./logger";
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import * as TE from "fp-ts/lib/TaskEither";
|
||||
import { pipe } from "fp-ts/lib/function";
|
||||
import type { Schedule } from "../canary";
|
||||
|
||||
interface ScheduledJob {
|
||||
id: string;
|
||||
execute: TE.TaskEither<Error, boolean>;
|
||||
at: Date;
|
||||
schedule: Schedule;
|
||||
}
|
||||
|
||||
type SchedulerState = ReadonlyArray<ScheduledJob>;
|
||||
|
||||
export const schedulerLoop =
|
||||
(state: SchedulerState): TE.TaskEither<Error, void> =>
|
||||
() => {
|
||||
const loop = (currentState: SchedulerState): TE.TaskEither<Error, void> =>
|
||||
pipe(
|
||||
executeDueJobs(currentState),
|
||||
delay(1000), // Delay for 1 second
|
||||
map((newState) => loop(newState)),
|
||||
);
|
||||
|
||||
return loop(state)();
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
import { mock, test, expect, beforeEach } from "bun:test";
|
||||
import { mock, test, expect } from "bun:test";
|
||||
import * as TE from "fp-ts/lib/TaskEither";
|
||||
import { perform, type EmailJobDependencies } from "../../src/canary/email";
|
||||
import type {
|
||||
|
|
Loading…
Reference in New Issue