firebird-wasm 0.2.0 → 0.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.
- package/CHANGELOG.md +168 -0
- package/README.md +4 -1
- package/dist/.tsbuildinfo.build +1 -1
- package/dist/browser/engine-transport.d.ts +56 -5
- package/dist/browser/engine-transport.d.ts.map +1 -1
- package/dist/browser/engine-transport.js +271 -8
- package/dist/browser/engine-transport.js.map +1 -1
- package/dist/browser/firebird-browser.d.ts +228 -7
- package/dist/browser/firebird-browser.d.ts.map +1 -1
- package/dist/browser/firebird-browser.js +334 -26
- package/dist/browser/firebird-browser.js.map +1 -1
- package/dist/browser/index.d.ts +8 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +19 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/opfs-fs.d.ts +72 -0
- package/dist/browser/opfs-fs.d.ts.map +1 -0
- package/dist/browser/opfs-fs.js +249 -0
- package/dist/browser/opfs-fs.js.map +1 -0
- package/dist/browser/shared-transport.d.ts +8 -2
- package/dist/browser/shared-transport.d.ts.map +1 -1
- package/dist/browser/shared-transport.js +29 -2
- package/dist/browser/shared-transport.js.map +1 -1
- package/dist/browser/statement-types.d.ts +18 -0
- package/dist/browser/statement-types.d.ts.map +1 -0
- package/dist/browser/statement-types.js +39 -0
- package/dist/browser/statement-types.js.map +1 -0
- package/dist/browser/value-types.d.ts +173 -0
- package/dist/browser/value-types.d.ts.map +1 -0
- package/dist/browser/value-types.js +222 -0
- package/dist/browser/value-types.js.map +1 -0
- package/dist/browser/worker-entry.d.ts.map +1 -1
- package/dist/browser/worker-entry.js +38 -1
- package/dist/browser/worker-entry.js.map +1 -1
- package/dist/browser/worker-protocol.d.ts +1 -1
- package/dist/browser/worker-protocol.d.ts.map +1 -1
- package/dist/browser/worker-transport.d.ts +8 -2
- package/dist/browser/worker-transport.d.ts.map +1 -1
- package/dist/browser/worker-transport.js +26 -2
- package/dist/browser/worker-transport.js.map +1 -1
- package/dist/firebird.d.ts +58 -5
- package/dist/firebird.d.ts.map +1 -1
- package/dist/firebird.js +161 -52
- package/dist/firebird.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/sql-tag.d.ts +184 -0
- package/dist/sql-tag.d.ts.map +1 -0
- package/dist/sql-tag.js +287 -0
- package/dist/sql-tag.js.map +1 -0
- package/dist/statement-types.d.ts +23 -0
- package/dist/statement-types.d.ts.map +1 -0
- package/dist/statement-types.js +44 -0
- package/dist/statement-types.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm/firebird-embedded.js +1 -1
- package/dist/wasm/firebird-embedded.wasm +0 -0
- package/dist/wasm-loader.d.ts +38 -2
- package/dist/wasm-loader.d.ts.map +1 -1
- package/dist/wasm-loader.js.map +1 -1
- package/package.json +3 -2
package/dist/firebird.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Attachment, Transaction } from 'node-firebird-driver';
|
|
2
|
-
import type { FirebirdLiteOptions, QueryResult, Row, QueryParams, TransactionOptions } from './types';
|
|
2
|
+
import type { ArrayRow, FirebirdLiteOptions, QueryDescription, QueryResult, QueryOptions, Row, QueryParams, RowMode, TransactionOptions } from './types';
|
|
3
|
+
import type { SqlFragment } from './sql-tag';
|
|
4
|
+
/** `QueryOptions` with the array mode pinned, for the overloads below. */
|
|
5
|
+
type ArrayModeOptions = QueryOptions & {
|
|
6
|
+
rowMode: 'array';
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* FirebirdLite – a PGlite-style wrapper around Firebird Embedded.
|
|
5
10
|
*
|
|
@@ -32,15 +37,47 @@ export declare class FirebirdLite {
|
|
|
32
37
|
* Execute a DDL or DML statement that does not return rows.
|
|
33
38
|
*
|
|
34
39
|
* The statement is executed in its own auto-committed transaction.
|
|
40
|
+
*
|
|
41
|
+
* Accepts a `` sql`…` `` fragment in place of a string, in which case its
|
|
42
|
+
* values are bound rather than interpolated.
|
|
35
43
|
*/
|
|
36
|
-
exec(sql: string): Promise<void>;
|
|
44
|
+
exec(sql: string | SqlFragment, params?: QueryParams): Promise<void>;
|
|
37
45
|
/**
|
|
38
46
|
* Execute a (parameterised) SQL statement and return the result rows.
|
|
39
47
|
*
|
|
40
48
|
* For SELECT queries the rows are returned as plain objects keyed by the
|
|
41
49
|
* (upper-cased) column name, mirroring the PGlite convention.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* await db.query('SELECT * FROM items WHERE id = ?', [id]);
|
|
53
|
+
* await db.query(sql`SELECT * FROM items WHERE id = ${id}`);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
query(sql: SqlFragment, options: ArrayModeOptions): Promise<QueryResult<ArrayRow>>;
|
|
57
|
+
query(sql: string | SqlFragment, params: QueryParams | undefined, options: ArrayModeOptions): Promise<QueryResult<ArrayRow>>;
|
|
58
|
+
query<T extends Row = Row>(sql: SqlFragment, options?: QueryOptions): Promise<QueryResult<T>>;
|
|
59
|
+
query<T extends Row = Row>(sql: string, params?: QueryParams, options?: QueryOptions): Promise<QueryResult<T>>;
|
|
60
|
+
query<T extends Row = Row>(sql: string | SqlFragment, params?: QueryParams, options?: QueryOptions): Promise<QueryResult<T>>;
|
|
61
|
+
/**
|
|
62
|
+
* Describe a statement's shape without running it.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* const shape = await db.describeQuery('SELECT id, name FROM items WHERE id = ?');
|
|
66
|
+
* // shape.fields → [{ name: 'ID' }, { name: 'NAME' }]
|
|
67
|
+
* // shape.statementType → 'SELECT'
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* The statement is prepared and disposed, so nothing runs: describing an
|
|
71
|
+
* `INSERT` inserts nothing.
|
|
72
|
+
*
|
|
73
|
+
* **`params` is `undefined` here.** The native driver exposes no input
|
|
74
|
+
* metadata — `Statement` offers `columnLabels`, `hasResultSet` and `type`
|
|
75
|
+
* and nothing about `?` placeholders — and an empty array would claim the
|
|
76
|
+
* statement takes none. `fields` carries names only, for the same reason
|
|
77
|
+
* `FieldInfo` does everywhere on this backend. The WASM backend reports both
|
|
78
|
+
* in full.
|
|
42
79
|
*/
|
|
43
|
-
|
|
80
|
+
describeQuery(sql: string | SqlFragment): Promise<QueryDescription>;
|
|
44
81
|
/**
|
|
45
82
|
* Run a function inside an explicit transaction.
|
|
46
83
|
*
|
|
@@ -60,14 +97,30 @@ export declare class FirebirdLite {
|
|
|
60
97
|
export declare class FirebirdTransaction {
|
|
61
98
|
private readonly attachment;
|
|
62
99
|
private readonly transaction;
|
|
100
|
+
private finished;
|
|
63
101
|
constructor(attachment: Attachment, transaction: Transaction);
|
|
102
|
+
/** Whether this transaction has already been rolled back. */
|
|
103
|
+
get isFinished(): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Roll this transaction back and stop.
|
|
106
|
+
*
|
|
107
|
+
* The enclosing `transaction()` will not commit afterwards. Use this to
|
|
108
|
+
* abandon a transaction deliberately, rather than throwing an error you do
|
|
109
|
+
* not mean — throwing also rolls back, but it propagates to the caller.
|
|
110
|
+
*/
|
|
111
|
+
rollback(): Promise<void>;
|
|
112
|
+
private assertUsable;
|
|
64
113
|
/**
|
|
65
114
|
* Execute a DDL or DML statement inside this transaction.
|
|
66
115
|
*/
|
|
67
|
-
exec(sql: string, params?: QueryParams): Promise<void>;
|
|
116
|
+
exec(sql: string | SqlFragment, params?: QueryParams): Promise<void>;
|
|
68
117
|
/**
|
|
69
118
|
* Execute a SELECT statement inside this transaction and return rows.
|
|
70
119
|
*/
|
|
71
|
-
query
|
|
120
|
+
query(sql: string | SqlFragment, params: QueryParams | undefined, options: ArrayModeOptions): Promise<QueryResult<ArrayRow>>;
|
|
121
|
+
query<T extends Row = Row>(sql: string | SqlFragment, params?: QueryParams, options?: {
|
|
122
|
+
rowMode?: RowMode;
|
|
123
|
+
}): Promise<QueryResult<T>>;
|
|
72
124
|
}
|
|
125
|
+
export {};
|
|
73
126
|
//# sourceMappingURL=firebird.d.ts.map
|
package/dist/firebird.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebird.d.ts","sourceRoot":"","sources":["../src/firebird.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,UAAU,EACV,WAAW,EAEZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,GAAG,EACH,WAAW,EACX,kBAAkB,EAEnB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"firebird.d.ts","sourceRoot":"","sources":["../src/firebird.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,UAAU,EACV,WAAW,EAEZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,GAAG,EACH,WAAW,EACX,OAAO,EACP,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,0EAA0E;AAC1E,KAAK,gBAAgB,GAAG,YAAY,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAoE;IACnG,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB;IAU7D;;OAEG;YACW,WAAW;IAgBzB;;;;;;;OAOG;IACG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G,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAa7B;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAI5B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAJ9B,OAAO,CAAC,QAAQ,CAAS;gBAGN,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW;IAG3C,6DAA6D;IAC7D,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;;;;OAMG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,MAAM,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAe9E;;OAEG;IACG,KAAK,CACT,GAAG,EAAE,MAAM,GAAG,WAAW,EACzB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC3B,KAAK,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAC7B,GAAG,EAAE,MAAM,GAAG,WAAW,EACzB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAyC3B"}
|
package/dist/firebird.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FirebirdTransaction = exports.FirebirdLite = void 0;
|
|
4
4
|
const node_firebird_driver_native_1 = require("node-firebird-driver-native");
|
|
5
5
|
const node_firebird_driver_1 = require("node-firebird-driver");
|
|
6
|
+
const statement_types_1 = require("./statement-types");
|
|
7
|
+
const sql_tag_1 = require("./sql-tag");
|
|
6
8
|
/**
|
|
7
9
|
* FirebirdLite – a PGlite-style wrapper around Firebird Embedded.
|
|
8
10
|
*
|
|
@@ -54,14 +56,64 @@ class FirebirdLite {
|
|
|
54
56
|
* Execute a DDL or DML statement that does not return rows.
|
|
55
57
|
*
|
|
56
58
|
* The statement is executed in its own auto-committed transaction.
|
|
59
|
+
*
|
|
60
|
+
* Accepts a `` sql`…` `` fragment in place of a string, in which case its
|
|
61
|
+
* values are bound rather than interpolated.
|
|
57
62
|
*/
|
|
58
|
-
async exec(sql) {
|
|
63
|
+
async exec(sql, params = []) {
|
|
64
|
+
// Delegated rather than reimplemented: "parameters present → prepare,
|
|
65
|
+
// execute, dispose; otherwise execute directly" is a rule that belongs in
|
|
66
|
+
// one place, and `transaction()` already wraps it in the commit-or-roll-
|
|
67
|
+
// back this needs. Two copies would drift the first time either grows a
|
|
68
|
+
// case.
|
|
69
|
+
await this.transaction((tx) => tx.exec(sql, params));
|
|
70
|
+
}
|
|
71
|
+
async query(sql, paramsOrOptions = [], maybeOptions = {}) {
|
|
59
72
|
await this.ensureReady();
|
|
73
|
+
const { statement, options } = (0, sql_tag_1.resolveQueryCall)(sql, paramsOrOptions, maybeOptions);
|
|
74
|
+
const rowMode = options.rowMode ?? 'object';
|
|
60
75
|
const attachment = this.attachment;
|
|
61
|
-
const
|
|
76
|
+
const txOptions = buildTransactionOptions(options);
|
|
77
|
+
const transaction = await attachment.startTransaction(txOptions);
|
|
62
78
|
try {
|
|
63
|
-
await attachment.
|
|
79
|
+
const stmt = await attachment.prepare(transaction, statement.sql);
|
|
80
|
+
let rows;
|
|
81
|
+
let fields;
|
|
82
|
+
// Disposed in `finally`, not after the fetch: a statement that throws on
|
|
83
|
+
// execute — a lock conflict, an overflow, a wrong parameter count — would
|
|
84
|
+
// otherwise leak its handle, and the retry loop such failures are usually
|
|
85
|
+
// wrapped in leaks one per attempt until the attachment refuses more.
|
|
86
|
+
try {
|
|
87
|
+
const columnLabels = await stmt.columnLabels;
|
|
88
|
+
fields = columnLabels.map((label) => ({ name: label.toUpperCase() }));
|
|
89
|
+
if (stmt.hasResultSet) {
|
|
90
|
+
const resultSet = await stmt.executeQuery(transaction, statement.params);
|
|
91
|
+
// Same reasoning one level down: a failing fetch must still close.
|
|
92
|
+
try {
|
|
93
|
+
const rawRows = await resultSet.fetch();
|
|
94
|
+
// The driver already hands back positional rows, so array mode is
|
|
95
|
+
// the shape that costs nothing — object mode is the one that
|
|
96
|
+
// builds.
|
|
97
|
+
rows = (rowMode === 'array'
|
|
98
|
+
? rawRows
|
|
99
|
+
: rawRows.map((cols) => Object.fromEntries(fields.map((f, i) => [f.name, cols[i]]))));
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
await resultSet.close().catch(() => undefined);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
await stmt.execute(transaction, statement.params);
|
|
107
|
+
rows = [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
await stmt.dispose().catch(() => undefined);
|
|
112
|
+
}
|
|
113
|
+
// After the statement is disposed, as before — the commit is the last
|
|
114
|
+
// thing that happens on the success path.
|
|
64
115
|
await transaction.commit();
|
|
116
|
+
return { rows, fields };
|
|
65
117
|
}
|
|
66
118
|
catch (err) {
|
|
67
119
|
await transaction.rollback().catch(() => undefined);
|
|
@@ -69,40 +121,49 @@ class FirebirdLite {
|
|
|
69
121
|
}
|
|
70
122
|
}
|
|
71
123
|
/**
|
|
72
|
-
*
|
|
124
|
+
* Describe a statement's shape without running it.
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* const shape = await db.describeQuery('SELECT id, name FROM items WHERE id = ?');
|
|
128
|
+
* // shape.fields → [{ name: 'ID' }, { name: 'NAME' }]
|
|
129
|
+
* // shape.statementType → 'SELECT'
|
|
130
|
+
* ```
|
|
73
131
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
132
|
+
* The statement is prepared and disposed, so nothing runs: describing an
|
|
133
|
+
* `INSERT` inserts nothing.
|
|
134
|
+
*
|
|
135
|
+
* **`params` is `undefined` here.** The native driver exposes no input
|
|
136
|
+
* metadata — `Statement` offers `columnLabels`, `hasResultSet` and `type`
|
|
137
|
+
* and nothing about `?` placeholders — and an empty array would claim the
|
|
138
|
+
* statement takes none. `fields` carries names only, for the same reason
|
|
139
|
+
* `FieldInfo` does everywhere on this backend. The WASM backend reports both
|
|
140
|
+
* in full.
|
|
76
141
|
*/
|
|
77
|
-
async
|
|
142
|
+
async describeQuery(sql) {
|
|
78
143
|
await this.ensureReady();
|
|
79
144
|
const attachment = this.attachment;
|
|
80
|
-
const
|
|
81
|
-
const transaction = await attachment.startTransaction(
|
|
145
|
+
const text = (0, sql_tag_1.toStatement)(sql).sql;
|
|
146
|
+
const transaction = await attachment.startTransaction();
|
|
82
147
|
try {
|
|
83
|
-
const stmt = await attachment.prepare(transaction,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
rows = rawRows.map((cols) => Object.fromEntries(fields.map((f, i) => [f.name, cols[i]])));
|
|
148
|
+
const stmt = await attachment.prepare(transaction, text);
|
|
149
|
+
try {
|
|
150
|
+
const columnLabels = await stmt.columnLabels;
|
|
151
|
+
const type = await stmt.type;
|
|
152
|
+
return {
|
|
153
|
+
params: undefined,
|
|
154
|
+
fields: columnLabels.map((label) => ({ name: label.toUpperCase() })),
|
|
155
|
+
statementType: (0, statement_types_1.statementKind)(type),
|
|
156
|
+
hasResultSet: stmt.hasResultSet,
|
|
157
|
+
};
|
|
94
158
|
}
|
|
95
|
-
|
|
96
|
-
await stmt.
|
|
97
|
-
rows = [];
|
|
159
|
+
finally {
|
|
160
|
+
await stmt.dispose().catch(() => undefined);
|
|
98
161
|
}
|
|
99
|
-
await stmt.dispose();
|
|
100
|
-
await transaction.commit();
|
|
101
|
-
return { rows, fields };
|
|
102
162
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
163
|
+
finally {
|
|
164
|
+
// Nothing ran, so there is nothing to commit — but the transaction still
|
|
165
|
+
// has to be finished.
|
|
166
|
+
await transaction.commit().catch(() => undefined);
|
|
106
167
|
}
|
|
107
168
|
}
|
|
108
169
|
/**
|
|
@@ -117,15 +178,24 @@ class FirebirdLite {
|
|
|
117
178
|
const txOptions = buildTransactionOptions(options);
|
|
118
179
|
const transaction = await attachment.startTransaction(txOptions);
|
|
119
180
|
const tx = new FirebirdTransaction(attachment, transaction);
|
|
181
|
+
let result;
|
|
120
182
|
try {
|
|
121
|
-
|
|
122
|
-
await transaction.commit();
|
|
123
|
-
return result;
|
|
183
|
+
result = await fn(tx);
|
|
124
184
|
}
|
|
125
185
|
catch (err) {
|
|
126
|
-
|
|
186
|
+
// The callback may have rolled back before throwing; rolling back twice
|
|
187
|
+
// targets a transaction the driver has already finished with.
|
|
188
|
+
if (!tx.isFinished) {
|
|
189
|
+
await transaction.rollback().catch(() => undefined);
|
|
190
|
+
}
|
|
127
191
|
throw err;
|
|
128
192
|
}
|
|
193
|
+
// A callback that rolled back deliberately must not then be committed.
|
|
194
|
+
if (tx.isFinished) {
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
await transaction.commit();
|
|
198
|
+
return result;
|
|
129
199
|
}
|
|
130
200
|
/**
|
|
131
201
|
* Close the database connection and release all resources.
|
|
@@ -153,39 +223,78 @@ class FirebirdTransaction {
|
|
|
153
223
|
constructor(attachment, transaction) {
|
|
154
224
|
this.attachment = attachment;
|
|
155
225
|
this.transaction = transaction;
|
|
226
|
+
this.finished = false;
|
|
227
|
+
}
|
|
228
|
+
/** Whether this transaction has already been rolled back. */
|
|
229
|
+
get isFinished() {
|
|
230
|
+
return this.finished;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Roll this transaction back and stop.
|
|
234
|
+
*
|
|
235
|
+
* The enclosing `transaction()` will not commit afterwards. Use this to
|
|
236
|
+
* abandon a transaction deliberately, rather than throwing an error you do
|
|
237
|
+
* not mean — throwing also rolls back, but it propagates to the caller.
|
|
238
|
+
*/
|
|
239
|
+
async rollback() {
|
|
240
|
+
if (this.finished)
|
|
241
|
+
return;
|
|
242
|
+
this.finished = true;
|
|
243
|
+
await this.transaction.rollback();
|
|
244
|
+
}
|
|
245
|
+
assertUsable() {
|
|
246
|
+
if (this.finished) {
|
|
247
|
+
throw new Error('Transaction has already been rolled back');
|
|
248
|
+
}
|
|
156
249
|
}
|
|
157
250
|
/**
|
|
158
251
|
* Execute a DDL or DML statement inside this transaction.
|
|
159
252
|
*/
|
|
160
253
|
async exec(sql, params = []) {
|
|
161
|
-
|
|
162
|
-
|
|
254
|
+
this.assertUsable();
|
|
255
|
+
const statement = (0, sql_tag_1.toStatement)(sql, params);
|
|
256
|
+
if (statement.params.length > 0) {
|
|
257
|
+
const stmt = await this.attachment.prepare(this.transaction, statement.sql);
|
|
163
258
|
try {
|
|
164
|
-
await stmt.execute(this.transaction, params);
|
|
259
|
+
await stmt.execute(this.transaction, statement.params);
|
|
165
260
|
}
|
|
166
261
|
finally {
|
|
167
262
|
await stmt.dispose().catch(() => undefined);
|
|
168
263
|
}
|
|
169
264
|
}
|
|
170
265
|
else {
|
|
171
|
-
await this.attachment.execute(this.transaction, sql);
|
|
266
|
+
await this.attachment.execute(this.transaction, statement.sql);
|
|
172
267
|
}
|
|
173
268
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const stmt = await this.attachment.prepare(this.transaction, sql);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
269
|
+
async query(sql, params = [], options = {}) {
|
|
270
|
+
this.assertUsable();
|
|
271
|
+
const statement = (0, sql_tag_1.toStatement)(sql, params);
|
|
272
|
+
const rowMode = options.rowMode ?? 'object';
|
|
273
|
+
const stmt = await this.attachment.prepare(this.transaction, statement.sql);
|
|
274
|
+
// Same leak as FirebirdLite.query had: a statement or result set that
|
|
275
|
+
// throws must still be released. More so here, because a transaction
|
|
276
|
+
// callback that catches its own errors goes on using the same attachment.
|
|
277
|
+
try {
|
|
278
|
+
const columnLabels = await stmt.columnLabels;
|
|
279
|
+
const fields = columnLabels.map((label) => ({
|
|
280
|
+
name: label.toUpperCase(),
|
|
281
|
+
}));
|
|
282
|
+
const resultSet = await stmt.executeQuery(this.transaction, statement.params);
|
|
283
|
+
let rawRows;
|
|
284
|
+
try {
|
|
285
|
+
rawRows = await resultSet.fetch();
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
await resultSet.close().catch(() => undefined);
|
|
289
|
+
}
|
|
290
|
+
const rows = (rowMode === 'array'
|
|
291
|
+
? rawRows
|
|
292
|
+
: rawRows.map((cols) => Object.fromEntries(fields.map((f, i) => [f.name, cols[i]]))));
|
|
293
|
+
return { rows, fields };
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
await stmt.dispose().catch(() => undefined);
|
|
297
|
+
}
|
|
189
298
|
}
|
|
190
299
|
}
|
|
191
300
|
exports.FirebirdTransaction = FirebirdTransaction;
|
package/dist/firebird.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebird.js","sourceRoot":"","sources":["../src/firebird.ts"],"names":[],"mappings":";;;AAAA,6EAGqC;AACrC,+DAE8B;
|
|
1
|
+
{"version":3,"file":"firebird.js","sourceRoot":"","sources":["../src/firebird.ts"],"names":[],"mappings":";;;AAAA,6EAGqC;AACrC,+DAE8B;AAmB9B,uDAAkD;AAClD,uCAA0D;AAM1D;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAY;IAQvB,YAAY,MAAc,EAAE,UAA+B,EAAE;QAJrD,WAAM,GAAkB,IAAI,CAAC;QAC7B,eAAU,GAAsB,IAAI,CAAC;QACrC,WAAM,GAAG,KAAK,CAAC;QAGrB,IAAI,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AAS,CAAC;YACT,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AAvGD,kDAuGC;AAED,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export { FirebirdLite, FirebirdTransaction } from './firebird';
|
|
19
|
-
export
|
|
19
|
+
export { sql, SqlFragment, RawSql, isSqlFragment, toStatement } from './sql-tag';
|
|
20
|
+
export { statementKind } from './statement-types';
|
|
21
|
+
export type { SqlTag, Statement } from './sql-tag';
|
|
22
|
+
export type { FirebirdLiteOptions, QueryResult, QueryParams, Row, FieldInfo, QueryOptions, QueryDescription, StatementKind, RowMode, ArrayRow, TransactionOptions, IsolationLevel, } from './types';
|
|
20
23
|
export { loadFirebirdWasm, allocString } from './wasm-loader';
|
|
21
24
|
export type { FirebirdWasmModule, WasmLoadOptions, EmscriptenFS, FbHandle, } from './wasm-loader';
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AAE/D,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEnD,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,GAAG,EACH,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,QAAQ,EACR,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
CHANGED
|
@@ -17,10 +17,18 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.allocString = exports.loadFirebirdWasm = exports.FirebirdTransaction = exports.FirebirdLite = void 0;
|
|
20
|
+
exports.allocString = exports.loadFirebirdWasm = exports.statementKind = exports.toStatement = exports.isSqlFragment = exports.RawSql = exports.SqlFragment = exports.sql = exports.FirebirdTransaction = exports.FirebirdLite = void 0;
|
|
21
21
|
var firebird_1 = require("./firebird");
|
|
22
22
|
Object.defineProperty(exports, "FirebirdLite", { enumerable: true, get: function () { return firebird_1.FirebirdLite; } });
|
|
23
23
|
Object.defineProperty(exports, "FirebirdTransaction", { enumerable: true, get: function () { return firebird_1.FirebirdTransaction; } });
|
|
24
|
+
var sql_tag_1 = require("./sql-tag");
|
|
25
|
+
Object.defineProperty(exports, "sql", { enumerable: true, get: function () { return sql_tag_1.sql; } });
|
|
26
|
+
Object.defineProperty(exports, "SqlFragment", { enumerable: true, get: function () { return sql_tag_1.SqlFragment; } });
|
|
27
|
+
Object.defineProperty(exports, "RawSql", { enumerable: true, get: function () { return sql_tag_1.RawSql; } });
|
|
28
|
+
Object.defineProperty(exports, "isSqlFragment", { enumerable: true, get: function () { return sql_tag_1.isSqlFragment; } });
|
|
29
|
+
Object.defineProperty(exports, "toStatement", { enumerable: true, get: function () { return sql_tag_1.toStatement; } });
|
|
30
|
+
var statement_types_1 = require("./statement-types");
|
|
31
|
+
Object.defineProperty(exports, "statementKind", { enumerable: true, get: function () { return statement_types_1.statementKind; } });
|
|
24
32
|
// WASM loader (available on all platforms)
|
|
25
33
|
var wasm_loader_1 = require("./wasm-loader");
|
|
26
34
|
Object.defineProperty(exports, "loadFirebirdWasm", { enumerable: true, get: function () { return wasm_loader_1.loadFirebirdWasm; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAE1C,qCAAiF;AAAxE,8FAAA,GAAG,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,iGAAA,MAAM,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,sGAAA,WAAW,OAAA;AAC7D,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AAkBtB,2CAA2C;AAC3C,6CAA8D;AAArD,+GAAA,gBAAgB,OAAA;AAAE,0GAAA,WAAW,OAAA"}
|