-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.ts
101 lines (83 loc) · 2.33 KB
/
types.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
type EmitType = 'constant' | 'repeat' | 'once' | 'map' | 'filter' | 'collect' | 'zipLast' | 'combineLatest' | 'reduce'
type IOType = 'webserver' | 'mqtt' | 'hookCall'
interface Transformer {
template: object,
}
interface Filter {
filterTemplate: object
}
interface Transformation {
id: number,
fromTopics: string[],
topicKeyToMessage?: string,
toTopicTemplate: string | object,
emitType: EmitType,
wrapper?: string,
useConstants?: object,
useMetrics?: object,
}
export type TransformationOps = RepeatOps | OnceOps | MapOps | CollectOps | ZipLastOps | CombineLatestOps | ReduceOps
export type AllSupportedOps = FilterOps | TransformationOps
export type AllSupportedConfigs = ConstantDef | AllSupportedOps
export type AllSupportedIOs = MqttIO | HookCallIO | WebserverIO
export interface ConstantDef {
emitType: "constant",
id: number,
name: string,
value: any,
}
export interface RepeatOps extends Transformation, Transformer{
emitType: "repeat",
emitInterval: number,
}
export interface OnceOps extends Transformation, Transformer {
emitType: "once",
emitInterval: number,
}
export interface MapOps extends Transformation, Transformer {
emitType: "map",
}
export interface ReduceOps extends Transformation, Transformer {
emitType: "reduce",
}
export interface FilterOps extends Transformation, Filter {
emitType: "filter",
}
export interface CollectOps extends Transformation, Transformer, Filter {
emitType: "collect",
}
export interface ZipLastOps extends Transformation, Transformer {
emitType: "zipLast",
}
export interface CombineLatestOps extends Transformation, Transformer {
emitType: "combineLatest",
defaultValues?: any[],
}
export interface InputOutput {
id: number,
type: IOType,
topicPrefix?: string,
}
export interface WebserverIO extends InputOutput{
type: "webserver",
port: number,
}
export interface HookCallIO extends InputOutput{
type: "hookCall",
url: string,
headers?: [string, string][],
responseTopic?: string,
}
export interface MqttIO extends InputOutput{
type: "mqtt",
url: string,
user?: string,
password?: string,
clientId?: string,
}
export interface MetricsData {
firstMessageTime: number,
prevMessageTime: number,
lastMessageTime: number,
messageCount: number,
}