From 5dbd16878546886cae5b56b67de6185bfbae0d07 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Thu, 1 Aug 2024 09:15:33 -0700 Subject: add arg parser --- src/canary/index.ts | 3 ++- src/canary/test.ts | 30 ++++++++++++++++++++++++++++++ src/canary/testable.ts | 24 ------------------------ 3 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 src/canary/test.ts delete mode 100644 src/canary/testable.ts (limited to 'src/canary') diff --git a/src/canary/index.ts b/src/canary/index.ts index 1d42dec..055a256 100644 --- a/src/canary/index.ts +++ b/src/canary/index.ts @@ -1,2 +1,3 @@ export * from "./job"; -export * from "./testable"; +export * from "./test"; +export * from "./email"; diff --git a/src/canary/test.ts b/src/canary/test.ts new file mode 100644 index 0000000..c03fb30 --- /dev/null +++ b/src/canary/test.ts @@ -0,0 +1,30 @@ +import * as TE from "fp-ts/lib/TaskEither"; +import * as O from "fp-ts/lib/Option"; +import type { Job } from "./job"; +import type { D } from "../util"; + +export enum TestType { + EMAIL = "email", + PING = "ping", + HEALTHCHECK = "healthcheck", + DNS = "dns", +} + +export interface Schedule { + every: D.Duration; + jitter: D.Duration; +} + +export interface Test { + name: string; + type: TestType; + job: Job; + schedule: Schedule; +} + +export type Testable = (job: T) => TE.TaskEither; + +export const parseTestType = (testType: string): O.Option => + Object.values(TestType).includes(testType as TestType) + ? O.some(testType as TestType) + : O.none; diff --git a/src/canary/testable.ts b/src/canary/testable.ts deleted file mode 100644 index d79aa99..0000000 --- a/src/canary/testable.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { TaskEither } from "fp-ts/lib/TaskEither"; -import type { Job } from "./job"; -import type { D } from "../util"; - -export enum TestType { - EMAIL = "email", - PING = "ping", - HEALTHCHECK = "healthcheck", - DNS = "dns", -} - -export interface Schedule { - every: D.Duration; - jitter: D.Duration; -} - -export interface Test { - name: string; - type: TestType; - job: Job; - schedule: Schedule; -} - -export type Testable = (job: T) => TaskEither; -- cgit v1.3