mysql2 3.3.4 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,52 +1,65 @@
1
- import Sequence = require('../sequences/Sequence');
2
- import Query = require('../sequences/Query');
3
- import {OkPacket, FieldPacket, RowDataPacket, ResultSetHeader} from '../packets';
4
- import {Readable} from 'stream';
1
+ import { Sequence } from './Sequence.js';
2
+ import { Query, QueryError, StreamOptions } from '../sequences/Query.js';
3
+ import {
4
+ OkPacket,
5
+ FieldPacket,
6
+ RowDataPacket,
7
+ ResultSetHeader,
8
+ } from '../packets/index.js';
9
+ import { Readable } from 'stream';
5
10
 
6
- declare namespace Prepare {
7
- export class PrepareStatementInfo {
8
- close(): void;
9
- execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
10
- paramaters: any | any[] | { [param: string]: any },
11
- callback?: (
12
- err: Query.QueryError | null,
13
- result: T,
14
- fields: FieldPacket[]
15
- ) => any): Query;
16
- }
11
+ export class PrepareStatementInfo {
12
+ close(): void;
13
+ execute<
14
+ T extends
15
+ | RowDataPacket[][]
16
+ | RowDataPacket[]
17
+ | OkPacket
18
+ | OkPacket[]
19
+ | ResultSetHeader
20
+ >(
21
+ paramaters: any | any[] | { [param: string]: any },
22
+ callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
23
+ ): Query;
17
24
  }
18
25
 
19
26
  declare class Prepare extends Sequence {
20
- /**
21
- * The SQL for a constructed query
22
- */
23
- sql: string;
27
+ /**
28
+ * The SQL for a constructed query
29
+ */
30
+ sql: string;
24
31
 
25
- /**
26
- * Emits a query packet to start the query
27
- */
28
- start(): void;
32
+ /**
33
+ * Emits a query packet to start the query
34
+ */
35
+ start(): void;
29
36
 
30
- /**
31
- * Determines the packet class to use given the first byte of the packet.
32
- *
33
- * @param firstByte The first byte of the packet
34
- * @param parser The packet parser
35
- */
36
- determinePacket(firstByte: number, parser: any): any;
37
+ /**
38
+ * Determines the packet class to use given the first byte of the packet.
39
+ *
40
+ * @param firstByte The first byte of the packet
41
+ * @param parser The packet parser
42
+ */
43
+ determinePacket(firstByte: number, parser: any): any;
37
44
 
38
- /**
39
- * Creates a Readable stream with the given options
40
- *
41
- * @param options The options for the stream.
42
- */
43
- stream(options?: Query.StreamOptions): Readable;
45
+ /**
46
+ * Creates a Readable stream with the given options
47
+ *
48
+ * @param options The options for the stream.
49
+ */
50
+ stream(options?: StreamOptions): Readable;
44
51
 
45
- on(event: string, listener: Function): this;
46
- on(event: 'error', listener: (err: Query.QueryError) => any): this;
47
- on(event: 'fields', listener: (fields: FieldPacket, index: number) => any): this;
48
- on(event: 'result', listener: (result: RowDataPacket | OkPacket, index: number) => any): this;
49
- on(event: 'end', listener: () => any): this;
52
+ on(event: string, listener: (args: []) => void): this;
53
+ on(event: 'error', listener: (err: QueryError) => any): this;
54
+ on(
55
+ event: 'fields',
56
+ listener: (fields: FieldPacket, index: number) => any
57
+ ): this;
58
+ on(
59
+ event: 'result',
60
+ listener: (result: RowDataPacket | OkPacket, index: number) => any
61
+ ): this;
62
+ on(event: 'end', listener: () => any): this;
50
63
  }
51
64
 
52
- export = Prepare;
65
+ export { Prepare };
@@ -1,148 +1,149 @@
1
+ import { Sequence } from './Sequence.js';
2
+ import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
3
+ import { Readable } from 'stream';
4
+
5
+ export interface QueryOptions {
6
+ /**
7
+ * The SQL for the query
8
+ */
9
+ sql: string;
10
+
11
+ /**
12
+ * The values for the query
13
+ */
14
+ values?: any | any[] | { [param: string]: any };
15
+
16
+ /**
17
+ * This overrides the namedPlaceholders option set at the connection level.
18
+ */
19
+ namedPlaceholders?: boolean;
20
+
21
+ /**
22
+ * Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
23
+ * operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout
24
+ * operations through the client. This means that when a timeout is reached, the connection it occurred on will be
25
+ * destroyed and no further operations can be performed.
26
+ */
27
+ timeout?: number;
28
+
29
+ /**
30
+ * Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be
31
+ * nested as tableName_fieldName
32
+ */
33
+ nestTables?: any;
34
+
35
+ /**
36
+ * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
37
+ * to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
38
+ *
39
+ * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
40
+ *
41
+ * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
42
+ *
43
+ * field.string()
44
+ * field.buffer()
45
+ * field.geometry()
46
+ *
47
+ * are aliases for
48
+ *
49
+ * parser.parseLengthCodedString()
50
+ * parser.parseLengthCodedBuffer()
51
+ * parser.parseGeometryValue()
52
+ *
53
+ * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
54
+ */
55
+ typeCast?: any;
56
+
57
+ /**
58
+ * This overrides the same option set at the connection level.
59
+ *
60
+ */
61
+ rowsAsArray?: boolean;
62
+
63
+ /**
64
+ * By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
65
+ */
66
+ infileStreamFactory?: (path: string) => Readable;
67
+ }
68
+
69
+ export interface StreamOptions {
70
+ /**
71
+ * Sets the max buffer size in objects of a stream
72
+ */
73
+ highWaterMark?: number;
1
74
 
2
- import Sequence = require('./Sequence');
3
- import {OkPacket, RowDataPacket, FieldPacket} from '../packets/index';
4
- import {Readable} from 'stream';
5
-
6
- declare namespace Query {
7
-
8
- export interface QueryOptions {
9
- /**
10
- * The SQL for the query
11
- */
12
- sql: string;
13
-
14
- /**
15
- * The values for the query
16
- */
17
- values?: any | any[] | { [param: string]: any };
18
-
19
- /**
20
- * This overrides the namedPlaceholders option set at the connection level.
21
- */
22
- namedPlaceholders?: boolean;
23
-
24
- /**
25
- * Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
26
- * operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout
27
- * operations through the client. This means that when a timeout is reached, the connection it occurred on will be
28
- * destroyed and no further operations can be performed.
29
- */
30
- timeout?: number;
31
-
32
- /**
33
- * Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be
34
- * nested as tableName_fieldName
35
- */
36
- nestTables?: any;
37
-
38
- /**
39
- * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
40
- * to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
41
- *
42
- * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
43
- *
44
- * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
45
- *
46
- * field.string()
47
- * field.buffer()
48
- * field.geometry()
49
- *
50
- * are aliases for
51
- *
52
- * parser.parseLengthCodedString()
53
- * parser.parseLengthCodedBuffer()
54
- * parser.parseGeometryValue()
55
- *
56
- * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
57
- */
58
- typeCast?: any;
59
-
60
- /**
61
- * This overrides the same option set at the connection level.
62
- *
63
- */
64
- rowsAsArray?: boolean
65
-
66
- /**
67
- * By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
68
- */
69
- infileStreamFactory?: (path: string) => Readable;
70
- }
71
-
72
- export interface StreamOptions {
73
- /**
74
- * Sets the max buffer size in objects of a stream
75
- */
76
- highWaterMark?: number;
77
-
78
- /**
79
- * The object mode of the stream (Default: true)
80
- */
81
- objectMode?: any;
82
- }
83
-
84
- export interface QueryError extends NodeJS.ErrnoException {
85
- /**
86
- * Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
87
- * a node.js error (e.g. 'ECONNREFUSED') or an internal error
88
- * (e.g. 'PROTOCOL_CONNECTION_LOST').
89
- */
90
- code: string;
91
-
92
- /**
93
- * The sql state marker
94
- */
95
- sqlStateMarker?: string;
96
-
97
- /**
98
- * The sql state
99
- */
100
- sqlState?: string;
101
-
102
- /**
103
- * The field count
104
- */
105
- fieldCount?: number;
106
-
107
- /**
108
- * Boolean, indicating if this error is terminal to the connection object.
109
- */
110
- fatal: boolean;
111
- }
75
+ /**
76
+ * The object mode of the stream (Default: true)
77
+ */
78
+ objectMode?: any;
112
79
  }
113
80
 
114
- declare class Query extends Sequence {
81
+ export interface QueryError extends NodeJS.ErrnoException {
82
+ /**
83
+ * Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
84
+ * a node.js error (e.g. 'ECONNREFUSED') or an internal error
85
+ * (e.g. 'PROTOCOL_CONNECTION_LOST').
86
+ */
87
+ code: string;
88
+
89
+ /**
90
+ * The sql state marker
91
+ */
92
+ sqlStateMarker?: string;
93
+
94
+ /**
95
+ * The sql state
96
+ */
97
+ sqlState?: string;
98
+
99
+ /**
100
+ * The field count
101
+ */
102
+ fieldCount?: number;
103
+
104
+ /**
105
+ * Boolean, indicating if this error is terminal to the connection object.
106
+ */
107
+ fatal: boolean;
108
+ }
115
109
 
116
- /**
117
- * The SQL for a constructed query
118
- */
119
- sql: string;
120
-
121
- /**
122
- * Emits a query packet to start the query
123
- */
124
- start(): void;
125
-
126
- /**
127
- * Determines the packet class to use given the first byte of the packet.
128
- *
129
- * @param firstByte The first byte of the packet
130
- * @param parser The packet parser
131
- */
132
- determinePacket(firstByte: number, parser: any): any;
133
-
134
- /**
135
- * Creates a Readable stream with the given options
136
- *
137
- * @param options The options for the stream.
138
- */
139
- stream(options?: Query.StreamOptions): Readable;
140
-
141
- on(event: string, listener: Function): this;
142
- on(event: 'error', listener: (err: Query.QueryError) => any): this;
143
- on(event: 'fields', listener: (fields: FieldPacket, index: number) => any): this;
144
- on(event: 'result', listener: (result: RowDataPacket | OkPacket, index: number) => any): this;
145
- on(event: 'end', listener: () => any): this;
110
+ declare class Query extends Sequence {
111
+ /**
112
+ * The SQL for a constructed query
113
+ */
114
+ sql: string;
115
+
116
+ /**
117
+ * Emits a query packet to start the query
118
+ */
119
+ start(): void;
120
+
121
+ /**
122
+ * Determines the packet class to use given the first byte of the packet.
123
+ *
124
+ * @param firstByte The first byte of the packet
125
+ * @param parser The packet parser
126
+ */
127
+ determinePacket(firstByte: number, parser: any): any;
128
+
129
+ /**
130
+ * Creates a Readable stream with the given options
131
+ *
132
+ * @param options The options for the stream.
133
+ */
134
+ stream(options?: StreamOptions): Readable;
135
+
136
+ on(event: string, listener: (args: any[]) => void): this;
137
+ on(event: 'error', listener: (err: QueryError) => any): this;
138
+ on(
139
+ event: 'fields',
140
+ listener: (fields: FieldPacket, index: number) => any
141
+ ): this;
142
+ on(
143
+ event: 'result',
144
+ listener: (result: RowDataPacket | OkPacket, index: number) => any
145
+ ): this;
146
+ on(event: 'end', listener: () => any): this;
146
147
  }
147
148
 
148
- export = Query;
149
+ export { Query };
@@ -1,5 +1,5 @@
1
+ import { EventEmitter } from 'events';
1
2
 
2
- import {EventEmitter} from 'events';
3
+ declare class Sequence extends EventEmitter {}
3
4
 
4
- declare class Sequence extends EventEmitter { }
5
- export = Sequence;
5
+ export { Sequence };