node-firebird 1.1.8 → 1.1.10

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.
package/Roadmap.md ADDED
@@ -0,0 +1,80 @@
1
+ # Node-Firebird Roadmap
2
+
3
+ This document outlines the future development direction for the `node-firebird` library. Our primary goals are to modernize the codebase, implement support for the latest Firebird features, and improve the overall developer experience.
4
+
5
+ ## Protocol Implementation Status
6
+
7
+ The following table summarizes the current and planned implementation status of the Firebird wire protocol for each major version.
8
+
9
+ | Firebird Version | Protocol Versions | Status |
10
+ | :--- | :--- | :--- |
11
+ | 2.5 | 10, 11, 12, 13 | ✅ Implemented |
12
+ | 3.0 | 14, 15 | ❌ Not Implemented |
13
+ | 4.0 | 16, 17 | ❌ Not Implemented |
14
+ | 5.0 | N/A | ❌ Not Implemented |
15
+ | 6.0 | N/A | ❌ Not Implemented |
16
+
17
+ ## Firebird 3 Support
18
+
19
+ Firebird 3 introduced Protocol 13, which brought significant changes focusing on security and performance. While the base protocol is implemented, several key features are still missing. To fully support Firebird 3, we need to implement the following:
20
+
21
+ - **Protocol Versions 14 and 15:** Implement the newer wire protocol versions.
22
+ - **Enhanced Authentication:** Fully support the new authentication mechanisms and plugin architecture.
23
+ - **Wire Protocol Encryption:** Implement support for encrypting all network traffic.
24
+ - **Wire Protocol Compression:** Add support for data compression.
25
+ - **Database Encryption Callback:** Support the new callback mechanism for handling database encryption keys.
26
+ - **Packed (NULL-aware) Row Data:** Implement support for the optimized row format.
27
+ - **Performance Optimizations:**
28
+ - Implement support for the denser data stream and improved prefetch logic.
29
+ - Utilize the new bitmap for transmitting NULL flags to reduce network traffic.
30
+ - **UTF-8 User Identification:** Ensure all user identification is properly handled with UTF-8 encoding.
31
+
32
+ ## Firebird 4 Support
33
+
34
+ Firebird 4 introduced Protocol versions 16 and 17, continuing to build upon the foundation of Firebird 3. Key features to implement include:
35
+
36
+ - **Protocol Versions 16 and 17:** Implement the latest protocol versions to support Firebird 4 features.
37
+
38
+ ## Firebird 5 Support
39
+
40
+ Firebird 5 introduces a host of new SQL features and performance improvements that will require significant client-side implementation:
41
+
42
+ - **Bidirectional Cursors:** Implement support for scrollable cursors for remote database access.
43
+ - **`RETURNING` Multiple Rows:** Enhance DML operations to support returning multiple rows.
44
+ - **`SKIP LOCKED`:** Add support for the `SKIP LOCKED` clause in `SELECT WITH LOCK`, `UPDATE`, and `DELETE` statements.
45
+ - **New Data Types and Functions:** Add support for new built-in functions and packages.
46
+
47
+ ## Firebird 6 and Beyond
48
+
49
+ As Firebird 6 and future versions are released, we will continue to monitor new features and plan for their implementation. Key areas of interest include:
50
+
51
+ - **JSON Support:** Implement client-side support for the new SQL-compliant JSON functions.
52
+ - **Tablespaces:** Add support for tablespaces.
53
+ - **SQL Schemas:** Implement support for SQL schemas.
54
+
55
+ ## Codebase Refactoring
56
+
57
+ The current codebase is functional but could be significantly improved by adopting modern JavaScript and TypeScript features.
58
+
59
+ ### Modern JavaScript Classes
60
+
61
+ The existing codebase is written in a prototype-based style. We plan to refactor the entire library to use modern JavaScript classes (`class` syntax). This will improve readability, maintainability, and make the code easier to understand for new contributors.
62
+
63
+ **Benefits:**
64
+
65
+ - Improved code structure and organization.
66
+ - Easier to reason about inheritance and object-oriented patterns.
67
+ - Better alignment with modern JavaScript best practices.
68
+
69
+ ### TypeScript Rewrite
70
+
71
+ A full rewrite of the library in TypeScript is a long-term goal. This would bring the benefits of static typing, improved developer tooling, and a more robust codebase.
72
+
73
+ **Benefits:**
74
+
75
+ - **Type Safety:** Catch errors at compile-time instead of runtime.
76
+ - **Improved Autocomplete:** Better editor support and developer experience.
77
+ - **Self-documenting Code:** Types make the code easier to understand and use.
78
+ - **Easier Refactoring:** Static analysis makes it easier to refactor code with confidence.
79
+
80
+ We believe these changes will make `node-firebird` a more robust, modern, and developer-friendly library for accessing Firebird databases.
@@ -0,0 +1,38 @@
1
+ function doError(obj, callback) {
2
+ if (callback)
3
+ callback(obj)
4
+ }
5
+
6
+ function isError(obj) {
7
+ return Boolean(
8
+ obj != null && typeof obj === "object" && !Array.isArray(obj) && obj.status
9
+ );
10
+ }
11
+
12
+ function doCallback(obj, callback) {
13
+
14
+ if (!callback)
15
+ return;
16
+
17
+ if (obj instanceof Error) {
18
+ callback(obj);
19
+ return;
20
+ }
21
+
22
+ if (isError(obj)) {
23
+ var error = new Error(obj.message);
24
+ var status = obj.status && obj.status.length && obj.status[0] || {};
25
+ error.gdscode = status.gdscode; // main error gds code
26
+ error.gdsparams = status.params; // parameters (constraint name, table, etc.)
27
+ callback(error);
28
+ return;
29
+ }
30
+
31
+ callback(undefined, obj);
32
+
33
+ }
34
+
35
+ module.exports = {
36
+ doError,
37
+ doCallback
38
+ }
package/lib/index.d.ts CHANGED
@@ -31,14 +31,25 @@ declare module 'node-firebird' {
31
31
 
32
32
  export type Isolation = number[];
33
33
 
34
+ export type TransactionOptions = {
35
+ autoCommit?: boolean;
36
+ autoUndo?: boolean;
37
+ isolation?: Isolation;
38
+ ignoreLimbo?: boolean;
39
+ readOnly?: boolean;
40
+ wait?: boolean;
41
+ waitTimeout?: number;
42
+ };
43
+
34
44
  export interface Database {
35
45
  detach(callback?: SimpleCallback): Database;
36
- transaction(isolation: Isolation, callback: TransactionCallback): Database;
46
+ transaction(options: TransactionOptions|Isolation|TransactionCallback, callback?: TransactionCallback): Database;
37
47
  query(query: string, params: any[], callback: QueryCallback): Database;
38
48
  execute(query: string, params: any[], callback: QueryCallback): Database;
39
49
  sequentially(query: string, params: any[], rowCallback: SequentialCallback, callback: SimpleCallback, asArray?: boolean): Database;
40
50
  drop(callback: SimpleCallback): void;
41
51
  escape(value: any): string;
52
+ attachEvent(callback: any): this;
42
53
  }
43
54
 
44
55
  export interface Transaction {