firebird-wasm 0.1.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 (66) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +120 -0
  3. package/dist/.tsbuildinfo.build +1 -0
  4. package/dist/browser/db-lock.d.ts +92 -0
  5. package/dist/browser/db-lock.d.ts.map +1 -0
  6. package/dist/browser/db-lock.js +163 -0
  7. package/dist/browser/db-lock.js.map +1 -0
  8. package/dist/browser/engine-transport.d.ts +94 -0
  9. package/dist/browser/engine-transport.d.ts.map +1 -0
  10. package/dist/browser/engine-transport.js +217 -0
  11. package/dist/browser/engine-transport.js.map +1 -0
  12. package/dist/browser/field-types.d.ts +19 -0
  13. package/dist/browser/field-types.d.ts.map +1 -0
  14. package/dist/browser/field-types.js +79 -0
  15. package/dist/browser/field-types.js.map +1 -0
  16. package/dist/browser/firebird-browser.d.ts +249 -0
  17. package/dist/browser/firebird-browser.d.ts.map +1 -0
  18. package/dist/browser/firebird-browser.js +401 -0
  19. package/dist/browser/firebird-browser.js.map +1 -0
  20. package/dist/browser/index.d.ts +31 -0
  21. package/dist/browser/index.d.ts.map +1 -0
  22. package/dist/browser/index.js +39 -0
  23. package/dist/browser/index.js.map +1 -0
  24. package/dist/browser/indexeddb-vfs.d.ts +132 -0
  25. package/dist/browser/indexeddb-vfs.d.ts.map +1 -0
  26. package/dist/browser/indexeddb-vfs.js +285 -0
  27. package/dist/browser/indexeddb-vfs.js.map +1 -0
  28. package/dist/browser/params.d.ts +33 -0
  29. package/dist/browser/params.d.ts.map +1 -0
  30. package/dist/browser/params.js +92 -0
  31. package/dist/browser/params.js.map +1 -0
  32. package/dist/browser/sql-script.d.ts +27 -0
  33. package/dist/browser/sql-script.d.ts.map +1 -0
  34. package/dist/browser/sql-script.js +132 -0
  35. package/dist/browser/sql-script.js.map +1 -0
  36. package/dist/browser/worker-entry.d.ts +45 -0
  37. package/dist/browser/worker-entry.d.ts.map +1 -0
  38. package/dist/browser/worker-entry.js +79 -0
  39. package/dist/browser/worker-entry.js.map +1 -0
  40. package/dist/browser/worker-protocol.d.ts +37 -0
  41. package/dist/browser/worker-protocol.d.ts.map +1 -0
  42. package/dist/browser/worker-protocol.js +10 -0
  43. package/dist/browser/worker-protocol.js.map +1 -0
  44. package/dist/browser/worker-transport.d.ts +63 -0
  45. package/dist/browser/worker-transport.d.ts.map +1 -0
  46. package/dist/browser/worker-transport.js +133 -0
  47. package/dist/browser/worker-transport.js.map +1 -0
  48. package/dist/firebird.d.ts +73 -0
  49. package/dist/firebird.d.ts.map +1 -0
  50. package/dist/firebird.js +208 -0
  51. package/dist/firebird.js.map +1 -0
  52. package/dist/index.d.ts +22 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +28 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/types.d.ts +88 -0
  57. package/dist/types.d.ts.map +1 -0
  58. package/dist/types.js +6 -0
  59. package/dist/types.js.map +1 -0
  60. package/dist/wasm/firebird-embedded.js +2 -0
  61. package/dist/wasm/firebird-embedded.wasm +0 -0
  62. package/dist/wasm-loader.d.ts +162 -0
  63. package/dist/wasm-loader.d.ts.map +1 -0
  64. package/dist/wasm-loader.js +103 -0
  65. package/dist/wasm-loader.js.map +1 -0
  66. package/package.json +86 -0
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FirebirdTransaction = exports.FirebirdLite = void 0;
4
+ const node_firebird_driver_native_1 = require("node-firebird-driver-native");
5
+ const node_firebird_driver_1 = require("node-firebird-driver");
6
+ /**
7
+ * FirebirdLite – a PGlite-style wrapper around Firebird Embedded.
8
+ *
9
+ * Provides a simple async API for running SQL against a Firebird database
10
+ * using the Firebird embedded engine (single-process mode).
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const db = new FirebirdLite('/tmp/my-database.fdb');
15
+ * await db.exec('CREATE TABLE t (id INTEGER, name VARCHAR(100))');
16
+ * await db.query('INSERT INTO t VALUES (?, ?)', [1, 'hello']);
17
+ * const result = await db.query('SELECT * FROM t');
18
+ * // { rows: [ { ID: 1, NAME: 'hello' } ], fields: [...] }
19
+ * await db.close();
20
+ * ```
21
+ */
22
+ class FirebirdLite {
23
+ constructor(dbPath, options = {}) {
24
+ this.client = null;
25
+ this.attachment = null;
26
+ this.closed = false;
27
+ this.dbPath = dbPath;
28
+ this.libraryPath = options.libraryPath ?? (0, node_firebird_driver_native_1.getDefaultLibraryFilename)();
29
+ this.connectOptions = {
30
+ username: options.username,
31
+ password: options.password,
32
+ charSetForNONE: options.charset,
33
+ };
34
+ }
35
+ /**
36
+ * Lazily initialize the native client and open (or create) the database.
37
+ */
38
+ async ensureReady() {
39
+ if (this.attachment)
40
+ return;
41
+ if (this.closed) {
42
+ throw new Error('FirebirdLite instance has been closed');
43
+ }
44
+ this.client = (0, node_firebird_driver_native_1.createNativeClient)(this.libraryPath);
45
+ try {
46
+ this.attachment = await this.client.connect(this.dbPath, this.connectOptions);
47
+ }
48
+ catch {
49
+ // Database does not exist yet – create it.
50
+ this.attachment = await this.client.createDatabase(this.dbPath, this.connectOptions);
51
+ }
52
+ }
53
+ /**
54
+ * Execute a DDL or DML statement that does not return rows.
55
+ *
56
+ * The statement is executed in its own auto-committed transaction.
57
+ */
58
+ async exec(sql) {
59
+ await this.ensureReady();
60
+ const attachment = this.attachment;
61
+ const transaction = await attachment.startTransaction();
62
+ try {
63
+ await attachment.execute(transaction, sql);
64
+ await transaction.commit();
65
+ }
66
+ catch (err) {
67
+ await transaction.rollback().catch(() => undefined);
68
+ throw err;
69
+ }
70
+ }
71
+ /**
72
+ * Execute a (parameterised) SQL statement and return the result rows.
73
+ *
74
+ * For SELECT queries the rows are returned as plain objects keyed by the
75
+ * (upper-cased) column name, mirroring the PGlite convention.
76
+ */
77
+ async query(sql, params = [], options = {}) {
78
+ await this.ensureReady();
79
+ const attachment = this.attachment;
80
+ const txOptions = buildTransactionOptions(options);
81
+ const transaction = await attachment.startTransaction(txOptions);
82
+ try {
83
+ const stmt = await attachment.prepare(transaction, sql);
84
+ const columnLabels = await stmt.columnLabels;
85
+ const fields = columnLabels.map((label) => ({
86
+ name: label.toUpperCase(),
87
+ }));
88
+ let rows;
89
+ if (stmt.hasResultSet) {
90
+ const resultSet = await stmt.executeQuery(transaction, params);
91
+ const rawRows = await resultSet.fetch();
92
+ await resultSet.close();
93
+ rows = rawRows.map((cols) => Object.fromEntries(fields.map((f, i) => [f.name, cols[i]])));
94
+ }
95
+ else {
96
+ await stmt.execute(transaction, params);
97
+ rows = [];
98
+ }
99
+ await stmt.dispose();
100
+ await transaction.commit();
101
+ return { rows, fields };
102
+ }
103
+ catch (err) {
104
+ await transaction.rollback().catch(() => undefined);
105
+ throw err;
106
+ }
107
+ }
108
+ /**
109
+ * Run a function inside an explicit transaction.
110
+ *
111
+ * The transaction is automatically committed on success or rolled back on
112
+ * error.
113
+ */
114
+ async transaction(fn, options = {}) {
115
+ await this.ensureReady();
116
+ const attachment = this.attachment;
117
+ const txOptions = buildTransactionOptions(options);
118
+ const transaction = await attachment.startTransaction(txOptions);
119
+ const tx = new FirebirdTransaction(attachment, transaction);
120
+ try {
121
+ const result = await fn(tx);
122
+ await transaction.commit();
123
+ return result;
124
+ }
125
+ catch (err) {
126
+ await transaction.rollback().catch(() => undefined);
127
+ throw err;
128
+ }
129
+ }
130
+ /**
131
+ * Close the database connection and release all resources.
132
+ */
133
+ async close() {
134
+ if (this.closed)
135
+ return;
136
+ this.closed = true;
137
+ if (this.attachment) {
138
+ await this.attachment.disconnect().catch(() => undefined);
139
+ this.attachment = null;
140
+ }
141
+ if (this.client) {
142
+ await this.client.dispose().catch(() => undefined);
143
+ this.client = null;
144
+ }
145
+ }
146
+ }
147
+ exports.FirebirdLite = FirebirdLite;
148
+ /**
149
+ * A handle to an active Firebird transaction, exposed to callers of
150
+ * `FirebirdLite.transaction()`.
151
+ */
152
+ class FirebirdTransaction {
153
+ constructor(attachment, transaction) {
154
+ this.attachment = attachment;
155
+ this.transaction = transaction;
156
+ }
157
+ /**
158
+ * Execute a DDL or DML statement inside this transaction.
159
+ */
160
+ async exec(sql, params = []) {
161
+ if (params.length > 0) {
162
+ const stmt = await this.attachment.prepare(this.transaction, sql);
163
+ try {
164
+ await stmt.execute(this.transaction, params);
165
+ }
166
+ finally {
167
+ await stmt.dispose().catch(() => undefined);
168
+ }
169
+ }
170
+ else {
171
+ await this.attachment.execute(this.transaction, sql);
172
+ }
173
+ }
174
+ /**
175
+ * Execute a SELECT statement inside this transaction and return rows.
176
+ */
177
+ async query(sql, params = []) {
178
+ const stmt = await this.attachment.prepare(this.transaction, sql);
179
+ const columnLabels = await stmt.columnLabels;
180
+ const fields = columnLabels.map((label) => ({
181
+ name: label.toUpperCase(),
182
+ }));
183
+ const resultSet = await stmt.executeQuery(this.transaction, params);
184
+ const rawRows = await resultSet.fetch();
185
+ await resultSet.close();
186
+ await stmt.dispose();
187
+ const rows = rawRows.map((cols) => Object.fromEntries(fields.map((f, i) => [f.name, cols[i]])));
188
+ return { rows, fields };
189
+ }
190
+ }
191
+ exports.FirebirdTransaction = FirebirdTransaction;
192
+ // ---------------------------------------------------------------------------
193
+ // Module-level helpers
194
+ // ---------------------------------------------------------------------------
195
+ function buildTransactionOptions(options) {
196
+ const isolationMap = {
197
+ READ_COMMITTED: node_firebird_driver_1.TransactionIsolation.READ_COMMITTED,
198
+ SNAPSHOT: node_firebird_driver_1.TransactionIsolation.SNAPSHOT,
199
+ SNAPSHOT_TABLE_STABILITY: node_firebird_driver_1.TransactionIsolation.CONSISTENCY,
200
+ };
201
+ return {
202
+ isolation: options.isolationLevel
203
+ ? isolationMap[options.isolationLevel]
204
+ : undefined,
205
+ accessMode: options.readOnly ? 'READ_ONLY' : undefined,
206
+ };
207
+ }
208
+ //# sourceMappingURL=firebird.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebird.js","sourceRoot":"","sources":["../src/firebird.ts"],"names":[],"mappings":";;;AAA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AAE9E,SAAS,uBAAuB,CAC9B,OAA2B;IAE3B,MAAM,YAAY,GAGd;QACF,cAAc,EAAE,2CAAoB,CAAC,cAAc;QACnD,QAAQ,EAAE,2CAAoB,CAAC,QAAQ;QACvC,wBAAwB,EAAE,2CAAoB,CAAC,WAAW;KAC3D,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,cAAc;YAC/B,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC;YACtC,CAAC,CAAC,SAAS;QACb,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * firebird-wasm – Firebird Embedded for Node.js / TypeScript
3
+ *
4
+ * Provides a PGlite-style async API backed by the Firebird embedded engine.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { FirebirdLite } from 'firebird-wasm';
9
+ *
10
+ * const db = new FirebirdLite('/tmp/my-app.fdb');
11
+ * await db.exec('CREATE TABLE items (id INTEGER, name VARCHAR(100))');
12
+ * await db.exec('INSERT INTO items VALUES (1, \'hello\')');
13
+ * const result = await db.query('SELECT * FROM items');
14
+ * console.log(result.rows); // [{ ID: 1, NAME: 'hello' }]
15
+ * await db.close();
16
+ * ```
17
+ */
18
+ export { FirebirdLite, FirebirdTransaction } from './firebird';
19
+ export type { FirebirdLiteOptions, QueryResult, QueryParams, Row, FieldInfo, TransactionOptions, IsolationLevel, } from './types';
20
+ export { loadFirebirdWasm, allocString } from './wasm-loader';
21
+ export type { FirebirdWasmModule, WasmLoadOptions, EmscriptenFS, FbHandle, } from './wasm-loader';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,GAAG,EACH,SAAS,EACT,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,QAAQ,GACT,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * firebird-wasm – Firebird Embedded for Node.js / TypeScript
4
+ *
5
+ * Provides a PGlite-style async API backed by the Firebird embedded engine.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { FirebirdLite } from 'firebird-wasm';
10
+ *
11
+ * const db = new FirebirdLite('/tmp/my-app.fdb');
12
+ * await db.exec('CREATE TABLE items (id INTEGER, name VARCHAR(100))');
13
+ * await db.exec('INSERT INTO items VALUES (1, \'hello\')');
14
+ * const result = await db.query('SELECT * FROM items');
15
+ * console.log(result.rows); // [{ ID: 1, NAME: 'hello' }]
16
+ * await db.close();
17
+ * ```
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.allocString = exports.loadFirebirdWasm = exports.FirebirdTransaction = exports.FirebirdLite = void 0;
21
+ var firebird_1 = require("./firebird");
22
+ Object.defineProperty(exports, "FirebirdLite", { enumerable: true, get: function () { return firebird_1.FirebirdLite; } });
23
+ Object.defineProperty(exports, "FirebirdTransaction", { enumerable: true, get: function () { return firebird_1.FirebirdTransaction; } });
24
+ // WASM loader (available on all platforms)
25
+ var wasm_loader_1 = require("./wasm-loader");
26
+ Object.defineProperty(exports, "loadFirebirdWasm", { enumerable: true, get: function () { return wasm_loader_1.loadFirebirdWasm; } });
27
+ Object.defineProperty(exports, "allocString", { enumerable: true, get: function () { return wasm_loader_1.allocString; } });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,uCAA+D;AAAtD,wGAAA,YAAY,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAW1C,2CAA2C;AAC3C,6CAA8D;AAArD,+GAAA,gBAAgB,OAAA;AAAE,0GAAA,WAAW,OAAA"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * TypeScript types for FirebirdLite
3
+ */
4
+ /**
5
+ * Options for creating a FirebirdLite instance.
6
+ */
7
+ export interface FirebirdLiteOptions {
8
+ /** Path to the Firebird client library. Defaults to the system default. */
9
+ libraryPath?: string;
10
+ /**
11
+ * Character set for `NONE`-charset columns/parameters.
12
+ * Passed as `charSetForNONE` to the underlying driver.
13
+ */
14
+ charset?: string;
15
+ /** Firebird user name. Defaults to 'SYSDBA'. */
16
+ username?: string;
17
+ /** Firebird user password. */
18
+ password?: string;
19
+ }
20
+ /**
21
+ * Result returned from a query execution.
22
+ */
23
+ export interface QueryResult<T = Row> {
24
+ /** Array of result rows. */
25
+ rows: T[];
26
+ /** Column names in the result set (in order). */
27
+ fields: FieldInfo[];
28
+ /** Number of rows affected (for INSERT/UPDATE/DELETE). */
29
+ affectedRows?: number;
30
+ }
31
+ /**
32
+ * Information about a result set column.
33
+ *
34
+ * Everything beyond `name` is optional because the Node.js native driver does
35
+ * not expose it; the WASM backend fills it in.
36
+ */
37
+ export interface FieldInfo {
38
+ /** Column name (alias if provided, otherwise the field name). */
39
+ name: string;
40
+ /**
41
+ * Firebird SQL type code — `SQL_LONG` (496), `SQL_VARYING` (448) and so on.
42
+ *
43
+ * Worth having because the JSON encoding is lossy about types: a
44
+ * `NUMERIC(10,2)` arrives as the string `"20.25"` to preserve its exactness,
45
+ * and without this it is indistinguishable from a `VARCHAR` containing
46
+ * digits.
47
+ */
48
+ type?: number;
49
+ /** A readable form of {@link FieldInfo.type}, e.g. `'NUMERIC'`. */
50
+ typeName?: FirebirdTypeName;
51
+ /** Type-specific subtype; for BLOBs, 1 means text. */
52
+ subType?: number;
53
+ /** Decimal scale. Non-zero means the value is exact and arrives as a string. */
54
+ scale?: number;
55
+ /** Declared length in bytes. */
56
+ length?: number;
57
+ /** Whether the column may be NULL. */
58
+ nullable?: boolean;
59
+ }
60
+ /** Readable names for the Firebird SQL type codes this library reports. */
61
+ export type FirebirdTypeName = 'TEXT' | 'VARYING' | 'SMALLINT' | 'INTEGER' | 'BIGINT' | 'INT128' | 'FLOAT' | 'DOUBLE' | 'DECFLOAT16' | 'DECFLOAT34' | 'NUMERIC' | 'DATE' | 'TIME' | 'TIMESTAMP' | 'TIME_TZ' | 'TIMESTAMP_TZ' | 'BOOLEAN' | 'BLOB' | 'ARRAY' | 'NULL' | 'UNKNOWN';
62
+ /**
63
+ * A single row from a query result, keyed by column name.
64
+ */
65
+ export type Row = Record<string, unknown>;
66
+ /**
67
+ * Parameters passed to a parameterized query.
68
+ */
69
+ export type QueryParams = unknown[];
70
+ /**
71
+ * Transaction isolation level.
72
+ *
73
+ * - `READ_COMMITTED` – reads the latest committed version of each row;
74
+ * other transactions' commits become visible during the transaction.
75
+ * - `SNAPSHOT` – provides a stable, point-in-time view of the database
76
+ * from the moment the transaction started (Firebird's default).
77
+ * - `SNAPSHOT_TABLE_STABILITY` – acquires shared table locks to prevent
78
+ * concurrent writes; mapped to Firebird `CONSISTENCY` isolation.
79
+ */
80
+ export type IsolationLevel = 'READ_COMMITTED' | 'SNAPSHOT' | 'SNAPSHOT_TABLE_STABILITY';
81
+ /**
82
+ * Options for beginning a transaction.
83
+ */
84
+ export interface TransactionOptions {
85
+ isolationLevel?: IsolationLevel;
86
+ readOnly?: boolean;
87
+ }
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB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GAAG,OAAO,EAAE,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,UAAU,GACV,0BAA0B,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * TypeScript types for FirebirdLite
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}