-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.ts
40 lines (35 loc) · 1.33 KB
/
check.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-explicit-any */
export declare namespace Check {
type status = 'pass' | 'fail' | 'warn'
type Status = {
status: status
info?: string
}
namespace Function {
type Sync<T> = (s: T) => Status
type Async<T> = (s: T) => Promise<Status>
}
export type Function<T> = Function.Sync<T> | Function.Async<T>
namespace Suite {
// The actual object type that gets used by invokeCollection
export type withSource<T> = { source: T; suite: Suite<T> }
// Nested Suites have been replaced with any function that returns the following
export type Nested<T> = Promise<withSource<T>>
// Top-Level Suites (Copc, Las, Getter) have been replaced with Collections
export type Collection = (withSource<any> | Nested<any>)[] //withSource<any>[]
// a.k.a Arrays of Suite.withSource<any> (or Promises)
}
export type Suite<T> = {
[id: string]: { function: Check.Function<T>; description: string }
}
export type Parser<S extends object, P> = (source: S) => Suite.Nested<P>
export type Collection = Suite.Collection
export type CollectionFn =
| ((...args: any[]) => Collection)
| ((...args: any[]) => Promise<Collection>)
export type Check = Status & {
id: string
description: string
}
}
export type Check = Check.Check