-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobservations.mts
More file actions
99 lines (99 loc) · 3.08 KB
/
observations.mts
File metadata and controls
99 lines (99 loc) · 3.08 KB
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
import util from 'node:util'
export interface Observation<Fields extends readonly string[], Instance extends Record<Fields[number], any>> {
new (...args: any[]): Instance;
fields: Fields;
}
export type AsyncId = number & { _tag: 'AsyncId' }
export class InitObservation {
static readonly fields = [
'type',
'executionAsyncId',
'triggerAsyncId',
'asyncId',
'stack',
]
readonly type: string
readonly executionAsyncId: AsyncId
readonly triggerAsyncId: AsyncId
readonly asyncId: AsyncId
readonly stack: string
constructor(
type: string,
executionAsyncId: AsyncId,
triggerAsyncId: AsyncId,
asyncId: AsyncId,
stack: string,
) {
this.type = type
this.executionAsyncId = executionAsyncId
this.triggerAsyncId = triggerAsyncId
this.asyncId = asyncId
this.stack = stack
}
[util.inspect.custom]() {
return `InitObservation(type=${this.type}, executionAsyncId=${this.executionAsyncId}, triggerAsyncId=${this.triggerAsyncId}, asyncId=${this.asyncId}, stack=${this.stack})`
}
}
export class PromiseResolveObservation {
static readonly fields = ['executionAsyncId', 'triggerAsyncId', 'asyncId', 'inspected']
readonly executionAsyncId: AsyncId
readonly triggerAsyncId: AsyncId
readonly asyncId: AsyncId
readonly inspected: string
constructor(
executionAsyncId: AsyncId,
triggerAsyncId: AsyncId,
asyncId: AsyncId,
inspected: string
) {
this.executionAsyncId = executionAsyncId
this.triggerAsyncId = triggerAsyncId
this.asyncId = asyncId
this.inspected = inspected
}
[util.inspect.custom]() {
return `PromiseResolveObservation(executionAsyncId=${this.executionAsyncId}, triggerAsyncId=${this.triggerAsyncId}, asyncId=${this.asyncId}, inspected=${this.inspected})`
}
}
export class BeforeObservation {
static readonly fields = ['triggerAsyncId', 'asyncId']
readonly triggerAsyncId: AsyncId
readonly asyncId: AsyncId
constructor(
triggerAsyncId: AsyncId,
asyncId: AsyncId
) {
this.triggerAsyncId = triggerAsyncId
this.asyncId = asyncId
}
[util.inspect.custom]() {
return `BeforeObservation(triggerAsyncId=${this.triggerAsyncId}, asyncId=${this.asyncId})`
}
}
export class AfterObservation {
static readonly fields = ['triggerAsyncId', 'asyncId']
readonly triggerAsyncId: AsyncId
readonly asyncId: AsyncId
constructor(
triggerAsyncId: AsyncId,
asyncId: AsyncId
) {
this.triggerAsyncId = triggerAsyncId
this.asyncId = asyncId
}
[util.inspect.custom]() {
return `AfterObservation(triggerAsyncId=${this.triggerAsyncId}, asyncId=${this.asyncId})`
}
}
export class DestroyObservation {
static readonly fields = ['asyncId']
readonly asyncId: AsyncId
constructor(
asyncId: AsyncId
) {
this.asyncId = asyncId
}
[util.inspect.custom]() {
return `DestroyObservation(asyncId=${this.asyncId})`
}
}