-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
95 lines (79 loc) · 1.92 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
// #region Hunter Configuration Typings
/**
* Represents the config options to enable logging
* @property `logType` - "json": use when structured logs are needed; "text": use when human-readable format is required
* @property `logDir` - Directory where logs would be saved (directory will be created if doesn't exists)
* @property `maxFileSize` - Maximum size of a single log file (in Mega-Bytes)
*/
export type HunterLogConfig = {
logType?: "json" | "text"
maxFileSizeMB?: number
logDir: string
}
/**
* Represents the configuration options for a hunter, which can be used for reporting.
*/
export type HunterConfig = {
enableRemoteMonitoring?: boolean
includeCodeContext?: boolean
enableSourceMap?: boolean
format?: "html" | "text"
quitOnError?: boolean
cwdFilter?: boolean
appName: string
apiKey: string
email: string
}
// #endregion
// #region Template Typings
export type Stack = {
function: string
column: number
file: string
line: number
}
export type Code = {
isBuggy: boolean
lineNo: number
code: string
}
/**
* Represents an exception or rejection template.
*/
export type ExceptionTemplate = {
errorMessage: string
stack: Stack[]
status: string
app: string
} & ({
code?: Code[]
hasCode: true
} | { hasCode: false })
// #endregion
// #region Request Payloads Typing
type AuthCheckPayload = {
type: "authcheck"
}
type ExceptionPayload = ExceptionTemplate & {
format: "html" | "text"
type: "exception"
}
export type MachineData = {
monitoring: boolean
name: string,
id: string
}
/**
* Represents outgoing request data to the hunter-server
*/
export type RequestPayload = {
machineData: MachineData
email: string
auth: string
} & (ExceptionPayload | AuthCheckPayload);
// #endregion
/**
* Represents loggable data
*/
export type LoggableData = Omit<ExceptionTemplate, "app"> & { config: HunterLogConfig }
export type LogMSGEvent = "logs-monitor-pause" | "logs-monitor-resume";