1
1
export type Mode = 'text' | 'binary'
2
2
3
- export const enum MessageName {
4
- parseComplete = 'parseComplete' ,
5
- bindComplete = 'bindComplete' ,
6
- closeComplete = 'closeComplete' ,
7
- noData = 'noData' ,
8
- portalSuspended = 'portalSuspended' ,
9
- replicationStart = 'replicationStart' ,
10
- emptyQuery = 'emptyQuery' ,
11
- copyDone = 'copyDone' ,
12
- copyData = 'copyData' ,
13
- rowDescription = 'rowDescription' ,
14
- parameterStatus = 'parameterStatus' ,
15
- backendKeyData = 'backendKeyData' ,
16
- notification = 'notification' ,
17
- readyForQuery = 'readyForQuery' ,
18
- commandComplete = 'commandComplete' ,
19
- dataRow = 'dataRow' ,
20
- copyInResponse = 'copyInResponse' ,
21
- copyOutResponse = 'copyOutResponse' ,
22
- authenticationOk = 'authenticationOk' ,
23
- authenticationMD5Password = 'authenticationMD5Password' ,
24
- authenticationCleartextPassword = 'authenticationCleartextPassword' ,
25
- authenticationSASL = 'authenticationSASL' ,
26
- authenticationSASLContinue = 'authenticationSASLContinue' ,
27
- authenticationSASLFinal = 'authenticationSASLFinal' ,
28
- error = 'error' ,
29
- notice = 'notice' ,
30
- }
3
+ export type MessageName =
4
+ | 'parseComplete'
5
+ | 'bindComplete'
6
+ | 'closeComplete'
7
+ | 'noData'
8
+ | 'portalSuspended'
9
+ | 'replicationStart'
10
+ | 'emptyQuery'
11
+ | 'copyDone'
12
+ | 'copyData'
13
+ | 'rowDescription'
14
+ | 'parameterStatus'
15
+ | 'backendKeyData'
16
+ | 'notification'
17
+ | 'readyForQuery'
18
+ | 'commandComplete'
19
+ | 'dataRow'
20
+ | 'copyInResponse'
21
+ | 'copyOutResponse'
22
+ | 'authenticationOk'
23
+ | 'authenticationMD5Password'
24
+ | 'authenticationCleartextPassword'
25
+ | 'authenticationSASL'
26
+ | 'authenticationSASLContinue'
27
+ | 'authenticationSASLFinal'
28
+ | 'error'
29
+ | 'notice'
31
30
32
31
export interface BackendMessage {
33
32
name : MessageName
34
33
length : number
35
34
}
36
35
37
36
export const parseComplete : BackendMessage = {
38
- name : MessageName . parseComplete ,
37
+ name : ' parseComplete' ,
39
38
length : 5 ,
40
39
}
41
40
42
41
export const bindComplete : BackendMessage = {
43
- name : MessageName . bindComplete ,
42
+ name : ' bindComplete' ,
44
43
length : 5 ,
45
44
}
46
45
47
46
export const closeComplete : BackendMessage = {
48
- name : MessageName . closeComplete ,
47
+ name : ' closeComplete' ,
49
48
length : 5 ,
50
49
}
51
50
52
51
export const noData : BackendMessage = {
53
- name : MessageName . noData ,
52
+ name : ' noData' ,
54
53
length : 5 ,
55
54
}
56
55
57
56
export const portalSuspended : BackendMessage = {
58
- name : MessageName . portalSuspended ,
57
+ name : ' portalSuspended' ,
59
58
length : 5 ,
60
59
}
61
60
62
61
export const replicationStart : BackendMessage = {
63
- name : MessageName . replicationStart ,
62
+ name : ' replicationStart' ,
64
63
length : 4 ,
65
64
}
66
65
67
66
export const emptyQuery : BackendMessage = {
68
- name : MessageName . emptyQuery ,
67
+ name : ' emptyQuery' ,
69
68
length : 4 ,
70
69
}
71
70
72
71
export const copyDone : BackendMessage = {
73
- name : MessageName . copyDone ,
72
+ name : ' copyDone' ,
74
73
length : 4 ,
75
74
}
76
75
@@ -117,7 +116,7 @@ export class DatabaseError extends Error implements NoticeOrError {
117
116
}
118
117
119
118
export class CopyDataMessage {
120
- public readonly name = MessageName . copyData
119
+ public readonly name = ' copyData'
121
120
constructor ( public readonly length : number , public readonly chunk : Buffer ) { }
122
121
}
123
122
@@ -146,15 +145,15 @@ export class Field {
146
145
}
147
146
148
147
export class RowDescriptionMessage {
149
- public readonly name : MessageName = MessageName . rowDescription
148
+ public readonly name : MessageName = ' rowDescription'
150
149
public readonly fields : Field [ ]
151
150
constructor ( public readonly length : number , public readonly fieldCount : number ) {
152
151
this . fields = new Array ( this . fieldCount )
153
152
}
154
153
}
155
154
156
155
export class ParameterStatusMessage {
157
- public readonly name : MessageName = MessageName . parameterStatus
156
+ public readonly name : MessageName = ' parameterStatus'
158
157
constructor (
159
158
public readonly length : number ,
160
159
public readonly parameterName : string ,
@@ -163,17 +162,17 @@ export class ParameterStatusMessage {
163
162
}
164
163
165
164
export class AuthenticationMD5Password implements BackendMessage {
166
- public readonly name : MessageName = MessageName . authenticationMD5Password
165
+ public readonly name : MessageName = ' authenticationMD5Password'
167
166
constructor ( public readonly length : number , public readonly salt : Buffer ) { }
168
167
}
169
168
170
169
export class BackendKeyDataMessage {
171
- public readonly name : MessageName = MessageName . backendKeyData
170
+ public readonly name : MessageName = ' backendKeyData'
172
171
constructor ( public readonly length : number , public readonly processID : number , public readonly secretKey : number ) { }
173
172
}
174
173
175
174
export class NotificationResponseMessage {
176
- public readonly name : MessageName = MessageName . notification
175
+ public readonly name : MessageName = ' notification'
177
176
constructor (
178
177
public readonly length : number ,
179
178
public readonly processId : number ,
@@ -183,26 +182,26 @@ export class NotificationResponseMessage {
183
182
}
184
183
185
184
export class ReadyForQueryMessage {
186
- public readonly name : MessageName = MessageName . readyForQuery
185
+ public readonly name : MessageName = ' readyForQuery'
187
186
constructor ( public readonly length : number , public readonly status : string ) { }
188
187
}
189
188
190
189
export class CommandCompleteMessage {
191
- public readonly name : MessageName = MessageName . commandComplete
190
+ public readonly name : MessageName = ' commandComplete'
192
191
constructor ( public readonly length : number , public readonly text : string ) { }
193
192
}
194
193
195
194
export class DataRowMessage {
196
195
public readonly fieldCount : number
197
- public readonly name : MessageName = MessageName . dataRow
196
+ public readonly name : MessageName = ' dataRow'
198
197
constructor ( public length : number , public fields : any [ ] ) {
199
198
this . fieldCount = fields . length
200
199
}
201
200
}
202
201
203
202
export class NoticeMessage implements BackendMessage , NoticeOrError {
204
203
constructor ( public readonly length : number , public readonly message : string | undefined ) { }
205
- public readonly name = MessageName . notice
204
+ public readonly name = ' notice'
206
205
public severity : string | undefined
207
206
public code : string | undefined
208
207
public detail : string | undefined
0 commit comments