node-firebird-driver 3.2.2 → 3.3.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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/impl/attachment.d.ts +4 -4
  3. package/dist/lib/impl/attachment.js +8 -6
  4. package/dist/lib/impl/attachment.js.map +1 -1
  5. package/dist/lib/impl/blob.js.map +1 -1
  6. package/dist/lib/impl/client.js +3 -2
  7. package/dist/lib/impl/client.js.map +1 -1
  8. package/dist/lib/impl/date-time.js +2 -1
  9. package/dist/lib/impl/date-time.js.map +1 -1
  10. package/dist/lib/impl/events.js +2 -1
  11. package/dist/lib/impl/events.js.map +1 -1
  12. package/dist/lib/impl/fb-util.d.ts +2 -1
  13. package/dist/lib/impl/fb-util.js +100 -81
  14. package/dist/lib/impl/fb-util.js.map +1 -1
  15. package/dist/lib/impl/resultset.js +11 -5
  16. package/dist/lib/impl/resultset.js.map +1 -1
  17. package/dist/lib/impl/statement.js +4 -2
  18. package/dist/lib/impl/statement.js.map +1 -1
  19. package/dist/lib/impl/time-zones.js +5 -3
  20. package/dist/lib/impl/time-zones.js.map +1 -1
  21. package/dist/lib/impl/transaction.js +2 -1
  22. package/dist/lib/impl/transaction.js.map +1 -1
  23. package/dist/lib/index.d.ts +8 -1
  24. package/dist/lib/index.js +7 -1
  25. package/dist/lib/index.js.map +1 -1
  26. package/dist/test/tests.js +176 -68
  27. package/dist/test/tests.js.map +1 -1
  28. package/package.json +6 -5
  29. package/src/lib/impl/attachment.ts +290 -253
  30. package/src/lib/impl/blob.ts +37 -35
  31. package/src/lib/impl/client.ts +60 -61
  32. package/src/lib/impl/date-time.ts +33 -33
  33. package/src/lib/impl/events.ts +17 -18
  34. package/src/lib/impl/fb-util.ts +552 -448
  35. package/src/lib/impl/resultset.ts +94 -86
  36. package/src/lib/impl/statement.ts +154 -127
  37. package/src/lib/impl/time-zones.ts +643 -641
  38. package/src/lib/impl/transaction.ts +37 -38
  39. package/src/lib/index.ts +325 -285
  40. package/src/test/tests.ts +996 -860
  41. package/tsconfig.json +7 -13
@@ -2,41 +2,43 @@ import { AbstractAttachment } from './attachment';
2
2
 
3
3
  import { Blob, BlobSeekWhence, BlobStream } from '..';
4
4
 
5
-
6
5
  /** AbstractBlobStream implementation. */
7
6
  export abstract class AbstractBlobStream extends BlobStream {
8
- protected constructor(blob: Blob, public attachment: AbstractAttachment) {
9
- super(blob);
10
- }
11
-
12
- get length(): Promise<number> {
13
- return this.internalGetLength();
14
- }
15
-
16
- async close(): Promise<void> {
17
- return await this.internalClose();
18
- }
19
-
20
- async cancel(): Promise<void> {
21
- return await this.internalCancel();
22
- }
23
-
24
- async seek(offset: number, whence?: BlobSeekWhence): Promise<number> {
25
- return await this.internalSeek(offset, whence);
26
- }
27
-
28
- async read(buffer: Buffer): Promise<number> {
29
- return await this.internalRead(buffer);
30
- }
31
-
32
- async write(buffer: Buffer): Promise<void> {
33
- return await this.internalWrite(buffer);
34
- }
35
-
36
- protected abstract internalGetLength(): Promise<number>;
37
- protected abstract internalClose(): Promise<void>;
38
- protected abstract internalCancel(): Promise<void>;
39
- protected abstract internalSeek(offset: number, whence?: BlobSeekWhence): Promise<number>;
40
- protected abstract internalRead(buffer: Buffer): Promise<number>;
41
- protected abstract internalWrite(buffer: Buffer): Promise<void>;
7
+ protected constructor(
8
+ blob: Blob,
9
+ public attachment: AbstractAttachment,
10
+ ) {
11
+ super(blob);
12
+ }
13
+
14
+ get length(): Promise<number> {
15
+ return this.internalGetLength();
16
+ }
17
+
18
+ async close(): Promise<void> {
19
+ return await this.internalClose();
20
+ }
21
+
22
+ async cancel(): Promise<void> {
23
+ return await this.internalCancel();
24
+ }
25
+
26
+ async seek(offset: number, whence?: BlobSeekWhence): Promise<number> {
27
+ return await this.internalSeek(offset, whence);
28
+ }
29
+
30
+ async read(buffer: Buffer): Promise<number> {
31
+ return await this.internalRead(buffer);
32
+ }
33
+
34
+ async write(buffer: Buffer): Promise<void> {
35
+ return await this.internalWrite(buffer);
36
+ }
37
+
38
+ protected abstract internalGetLength(): Promise<number>;
39
+ protected abstract internalClose(): Promise<void>;
40
+ protected abstract internalCancel(): Promise<void>;
41
+ protected abstract internalSeek(offset: number, whence?: BlobSeekWhence): Promise<number>;
42
+ protected abstract internalRead(buffer: Buffer): Promise<number>;
43
+ protected abstract internalWrite(buffer: Buffer): Promise<void>;
42
44
  }
@@ -1,87 +1,86 @@
1
1
  import { AbstractAttachment } from './attachment';
2
2
 
3
3
  import {
4
- Client,
5
- ConnectOptions,
6
- CreateDatabaseOptions,
7
- ExecuteOptions,
8
- ExecuteQueryOptions,
9
- FetchOptions,
10
- PrepareOptions,
11
- TransactionOptions
4
+ Client,
5
+ ConnectOptions,
6
+ CreateDatabaseOptions,
7
+ ExecuteOptions,
8
+ ExecuteQueryOptions,
9
+ FetchOptions,
10
+ PrepareOptions,
11
+ TransactionOptions,
12
12
  } from '..';
13
13
 
14
-
15
14
  /** AbstractClient implementation. */
16
15
  export abstract class AbstractClient implements Client {
17
- connected = true;
18
- attachments = new Set<AbstractAttachment>();
16
+ connected = true;
17
+ attachments = new Set<AbstractAttachment>();
19
18
 
20
- /** Default connect options. */
21
- defaultConnectOptions: ConnectOptions;
19
+ /** Default connect options. */
20
+ defaultConnectOptions: ConnectOptions;
22
21
 
23
- /** Set default create database options. */
24
- defaultCreateDatabaseOptions: CreateDatabaseOptions;
22
+ /** Set default create database options. */
23
+ defaultCreateDatabaseOptions: CreateDatabaseOptions;
25
24
 
26
- /** Default transaction options. */
27
- defaultTransactionOptions: TransactionOptions;
25
+ /** Default transaction options. */
26
+ defaultTransactionOptions: TransactionOptions;
28
27
 
29
- /** Default query's prepare options. */
30
- defaultPrepareOptions: PrepareOptions;
28
+ /** Default query's prepare options. */
29
+ defaultPrepareOptions: PrepareOptions;
31
30
 
32
- /** Default query's execute options. */
33
- defaultExecuteOptions: ExecuteOptions;
31
+ /** Default query's execute options. */
32
+ defaultExecuteOptions: ExecuteOptions;
34
33
 
35
- /** Default query's executeQuery options. */
36
- defaultExecuteQueryOptions: ExecuteQueryOptions;
34
+ /** Default query's executeQuery options. */
35
+ defaultExecuteQueryOptions: ExecuteQueryOptions;
37
36
 
38
- /** Default result set's fetch options. */
39
- defaultFetchOptions: FetchOptions;
37
+ /** Default result set's fetch options. */
38
+ defaultFetchOptions: FetchOptions;
40
39
 
41
- /** Disposes this client's resources. */
42
- async dispose(): Promise<void> {
43
- this.check();
40
+ /** Disposes this client's resources. */
41
+ async dispose(): Promise<void> {
42
+ this.check();
44
43
 
45
- try {
46
- await Promise.all(Array.from(this.attachments).map(attachment => attachment.disconnect()));
47
- }
48
- finally {
49
- this.attachments.clear();
50
- }
44
+ try {
45
+ await Promise.all(Array.from(this.attachments).map((attachment) => attachment.disconnect()));
46
+ } finally {
47
+ this.attachments.clear();
48
+ }
51
49
 
52
- await this.internalDispose();
50
+ await this.internalDispose();
53
51
 
54
- this.connected = false;
55
- }
52
+ this.connected = false;
53
+ }
56
54
 
57
- /** Connects to a database. */
58
- async connect(uri: string, options?: ConnectOptions): Promise<AbstractAttachment> {
59
- this.check();
55
+ /** Connects to a database. */
56
+ async connect(uri: string, options?: ConnectOptions): Promise<AbstractAttachment> {
57
+ this.check();
60
58
 
61
- const attachment = await this.internalConnect(uri, options || this.defaultConnectOptions);
62
- this.attachments.add(attachment);
63
- return attachment;
64
- }
59
+ const attachment = await this.internalConnect(uri, options || this.defaultConnectOptions);
60
+ this.attachments.add(attachment);
61
+ return attachment;
62
+ }
65
63
 
66
- /** Creates a database. */
67
- async createDatabase(uri: string, options?: CreateDatabaseOptions): Promise<AbstractAttachment> {
68
- this.check();
64
+ /** Creates a database. */
65
+ async createDatabase(uri: string, options?: CreateDatabaseOptions): Promise<AbstractAttachment> {
66
+ this.check();
69
67
 
70
- const attachment = await this.internalCreateDatabase(uri, options || this.defaultCreateDatabaseOptions);
71
- this.attachments.add(attachment);
72
- return attachment;
73
- }
68
+ const attachment = await this.internalCreateDatabase(uri, options || this.defaultCreateDatabaseOptions);
69
+ this.attachments.add(attachment);
70
+ return attachment;
71
+ }
74
72
 
75
- get isValid(): boolean {
76
- return !!this.connected;
77
- }
73
+ get isValid(): boolean {
74
+ return !!this.connected;
75
+ }
78
76
 
79
- private check() {
80
- if (!this.isValid)
81
- throw new Error('Client is already disposed.');
82
- }
77
+ private check() {
78
+ if (!this.isValid) {
79
+ throw new Error('Client is already disposed.');
80
+ }
81
+ }
83
82
 
84
- protected abstract internalDispose(): Promise<void>;
85
- protected abstract internalConnect(uri: string, options?: ConnectOptions): Promise<AbstractAttachment>;
86
- protected abstract internalCreateDatabase(uri: string, options?: CreateDatabaseOptions): Promise<AbstractAttachment>;
83
+ protected abstract internalDispose(): Promise<void>;
84
+ protected abstract internalConnect(uri: string, options?: ConnectOptions): Promise<AbstractAttachment>;
85
+ protected abstract internalCreateDatabase(uri: string, options?: CreateDatabaseOptions): Promise<AbstractAttachment>;
87
86
  }
@@ -25,55 +25,55 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
25
 
26
26
  /** Decode a date. */
27
27
  export function decodeDate(date: number) {
28
- let nday = date + 678882;
29
- const century = Math.trunc((4 * nday - 1) / 146097);
30
- nday = 4 * nday - 1 - 146097 * century;
31
- let day = Math.trunc(nday / 4);
28
+ let nday = date + 678882;
29
+ const century = Math.trunc((4 * nday - 1) / 146097);
30
+ nday = 4 * nday - 1 - 146097 * century;
31
+ let day = Math.trunc(nday / 4);
32
32
 
33
- nday = Math.trunc((4 * day + 3) / 1461);
34
- day = 4 * day + 3 - 1461 * nday;
35
- day = Math.trunc((day + 4) / 4);
33
+ nday = Math.trunc((4 * day + 3) / 1461);
34
+ day = 4 * day + 3 - 1461 * nday;
35
+ day = Math.trunc((day + 4) / 4);
36
36
 
37
- let month = Math.trunc((5 * day - 3) / 153);
38
- day = 5 * day - 3 - 153 * month;
39
- day = Math.trunc((day + 5) / 5);
40
- let year = 100 * century + nday;
37
+ let month = Math.trunc((5 * day - 3) / 153);
38
+ day = 5 * day - 3 - 153 * month;
39
+ day = Math.trunc((day + 5) / 5);
40
+ let year = 100 * century + nday;
41
41
 
42
- if (month < 10)
43
- month += 3;
44
- else {
45
- month -= 9;
46
- year += 1;
47
- }
42
+ if (month < 10) {
43
+ month += 3;
44
+ } else {
45
+ month -= 9;
46
+ year += 1;
47
+ }
48
48
 
49
- return { year, month, day };
49
+ return { year, month, day };
50
50
  }
51
51
 
52
52
  /** Encode a date. */
53
53
  export function encodeDate(year: number, month: number, day: number): number {
54
- const i = month + 9;
55
- let jy = year + Math.trunc(i / 12) - 1;
56
- const jm = i % 12;
57
- const c = Math.trunc(jy / 100);
58
- jy -= 100 * c;
59
- const j = Math.trunc((146097 * c) / 4) + Math.trunc((1461 * jy) / 4) + Math.trunc((153 * jm + 2) / 5) + day - 678882;
54
+ const i = month + 9;
55
+ let jy = year + Math.trunc(i / 12) - 1;
56
+ const jm = i % 12;
57
+ const c = Math.trunc(jy / 100);
58
+ jy -= 100 * c;
59
+ const j = Math.trunc((146097 * c) / 4) + Math.trunc((1461 * jy) / 4) + Math.trunc((153 * jm + 2) / 5) + day - 678882;
60
60
 
61
- return j;
61
+ return j;
62
62
  }
63
63
 
64
64
  /** Descode a time. */
65
65
  export function decodeTime(time: number) {
66
- let seconds = Math.trunc(time / 10000);
67
- let minutes = Math.trunc(seconds / 60);
68
- const hours = Math.trunc(minutes / 60);
69
- minutes = minutes % 60;
70
- seconds = seconds % 60;
71
- const fractions = time % 10000;
66
+ let seconds = Math.trunc(time / 10000);
67
+ let minutes = Math.trunc(seconds / 60);
68
+ const hours = Math.trunc(minutes / 60);
69
+ minutes = minutes % 60;
70
+ seconds = seconds % 60;
71
+ const fractions = time % 10000;
72
72
 
73
- return { hours, minutes, seconds, fractions };
73
+ return { hours, minutes, seconds, fractions };
74
74
  }
75
75
 
76
76
  /** Encode a time. */
77
77
  export function encodeTime(hours: number, minutes: number, seconds: number, fractions: number): number {
78
- return (hours * 3600 + minutes * 60 + seconds) * 10000 + fractions;
78
+ return (hours * 3600 + minutes * 60 + seconds) * 10000 + fractions;
79
79
  }
@@ -2,30 +2,29 @@ import { AbstractAttachment } from './attachment';
2
2
 
3
3
  import { Events } from '..';
4
4
 
5
-
6
5
  /** AbstractStatement implementation. */
7
6
  export abstract class AbstractEvents implements Events {
8
- protected constructor(public attachment?: AbstractAttachment) {
9
- }
7
+ protected constructor(public attachment?: AbstractAttachment) {}
10
8
 
11
- /** Cancel this events' resources. */
12
- async cancel(): Promise<void> {
13
- this.check();
9
+ /** Cancel this events' resources. */
10
+ async cancel(): Promise<void> {
11
+ this.check();
14
12
 
15
- await this.internalCancel();
13
+ await this.internalCancel();
16
14
 
17
- this.attachment?.events.delete(this);
18
- this.attachment = undefined;
19
- }
15
+ this.attachment?.events.delete(this);
16
+ this.attachment = undefined;
17
+ }
20
18
 
21
- get isValid(): boolean {
22
- return !!this.attachment;
23
- }
19
+ get isValid(): boolean {
20
+ return !!this.attachment;
21
+ }
24
22
 
25
- private check() {
26
- if (!this.isValid)
27
- throw new Error('Events are already cancelled.');
28
- }
23
+ private check() {
24
+ if (!this.isValid) {
25
+ throw new Error('Events are already cancelled.');
26
+ }
27
+ }
29
28
 
30
- protected abstract internalCancel(): Promise<void>;
29
+ protected abstract internalCancel(): Promise<void>;
31
30
  }