firebird-wasm 0.2.0 → 0.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.
- package/CHANGELOG.md +199 -0
- package/README.md +4 -1
- package/dist/.tsbuildinfo.build +1 -1
- package/dist/browser/engine-transport.d.ts +63 -5
- package/dist/browser/engine-transport.d.ts.map +1 -1
- package/dist/browser/engine-transport.js +290 -8
- package/dist/browser/engine-transport.js.map +1 -1
- package/dist/browser/firebird-browser.d.ts +252 -7
- package/dist/browser/firebird-browser.d.ts.map +1 -1
- package/dist/browser/firebird-browser.js +373 -20
- 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/params.d.ts +30 -3
- package/dist/browser/params.d.ts.map +1 -1
- package/dist/browser/params.js +97 -22
- package/dist/browser/params.js.map +1 -1
- package/dist/browser/shared-transport.d.ts +9 -2
- package/dist/browser/shared-transport.d.ts.map +1 -1
- package/dist/browser/shared-transport.js +33 -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 +9 -2
- package/dist/browser/worker-transport.d.ts.map +1 -1
- package/dist/browser/worker-transport.js +29 -2
- package/dist/browser/worker-transport.js.map +1 -1
- package/dist/firebird.d.ts +69 -5
- package/dist/firebird.d.ts.map +1 -1
- package/dist/firebird.js +187 -49
- 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 +44 -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.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,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,G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AAS,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"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sql-tag.ts – the `` sql`…` `` template tag.
|
|
3
|
+
*
|
|
4
|
+
* Interpolation in a SQL string is the classic injection bug, and the usual
|
|
5
|
+
* advice — "use parameters" — is awkward enough that people don't:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* await db.query('SELECT * FROM items WHERE id = ? AND name = ?', [id, name]);
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* The values sit far from the holes they fill, and adding a condition means
|
|
12
|
+
* editing two places and keeping them in the same order. The tag closes that
|
|
13
|
+
* distance without giving up parameter binding:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* await db.query(sql`SELECT * FROM items WHERE id = ${id} AND name = ${name}`);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Every `${…}` becomes a `?` and its value is bound, so a value can never be
|
|
20
|
+
* read as SQL. That is the whole safety property, and it holds no matter what
|
|
21
|
+
* the value contains — `"'; DROP TABLE items --"` is a five-word string, not a
|
|
22
|
+
* statement.
|
|
23
|
+
*
|
|
24
|
+
* What a tagged template cannot do is parameterise the parts of a statement
|
|
25
|
+
* that are not values: table and column names, `ORDER BY` direction, whole
|
|
26
|
+
* conditions. Those need text, and text is where injection lives again, so the
|
|
27
|
+
* three ways to produce it are named and separate — {@link SqlTag.identifier},
|
|
28
|
+
* {@link SqlTag.join}, and {@link SqlTag.unsafe}. Only the last is a loaded
|
|
29
|
+
* gun, and it says so at the call site.
|
|
30
|
+
*
|
|
31
|
+
* Fragments nest, which is what makes conditional SQL bearable:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const active = onlyActive ? sql`AND active = ${true}` : sql``;
|
|
35
|
+
* await db.query(sql`SELECT * FROM items WHERE owner = ${user} ${active}`);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Placeholders renumber themselves because Firebird's are positional `?`
|
|
39
|
+
* rather than `$1` — splicing a fragment is concatenation on both the text and
|
|
40
|
+
* the parameter list, with no renumbering to get wrong.
|
|
41
|
+
*/
|
|
42
|
+
import type { QueryParams, TransactionOptions } from './types';
|
|
43
|
+
/**
|
|
44
|
+
* A piece of SQL and the values bound to its placeholders.
|
|
45
|
+
*
|
|
46
|
+
* Produced by {@link sql}, accepted anywhere `(sql, params)` is. Both fields
|
|
47
|
+
* are readable, which is what makes a query loggable before it runs.
|
|
48
|
+
*/
|
|
49
|
+
export declare class SqlFragment {
|
|
50
|
+
/** Statement text, with a `?` for every bound value. */
|
|
51
|
+
readonly sql: string;
|
|
52
|
+
/** Values for the placeholders, in order. */
|
|
53
|
+
readonly params: QueryParams;
|
|
54
|
+
constructor(
|
|
55
|
+
/** Statement text, with a `?` for every bound value. */
|
|
56
|
+
sql: string,
|
|
57
|
+
/** Values for the placeholders, in order. */
|
|
58
|
+
params: QueryParams);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* SQL text that is spliced in literally, with nothing bound.
|
|
62
|
+
*
|
|
63
|
+
* There is no way to make this safe in general — that is the point of keeping
|
|
64
|
+
* it a distinct type rather than letting any string through. It exists because
|
|
65
|
+
* identifiers and syntax cannot be parameters.
|
|
66
|
+
*/
|
|
67
|
+
export declare class RawSql {
|
|
68
|
+
readonly sql: string;
|
|
69
|
+
constructor(sql: string);
|
|
70
|
+
}
|
|
71
|
+
/** True if `value` came from {@link sql}. */
|
|
72
|
+
export declare function isSqlFragment(value: unknown): value is SqlFragment;
|
|
73
|
+
/** The shape of {@link sql}: callable as a tag, with helpers hanging off it. */
|
|
74
|
+
export interface SqlTag {
|
|
75
|
+
(strings: TemplateStringsArray, ...values: unknown[]): SqlFragment;
|
|
76
|
+
/**
|
|
77
|
+
* Quote a table or column name so it can be interpolated as text.
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* await db.query(sql`SELECT * FROM ${sql.identifier(table)} WHERE id = ${id}`);
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* The name is quoted verbatim, with any `"` doubled, so it cannot end the
|
|
84
|
+
* quoting and start a statement.
|
|
85
|
+
*
|
|
86
|
+
* **Firebird folds unquoted names to upper case, and quoting turns that
|
|
87
|
+
* off.** A table created as `CREATE TABLE items` is stored as `ITEMS`, and
|
|
88
|
+
* `sql.identifier('items')` produces `"items"`, which will not find it. Pass
|
|
89
|
+
* the name in its stored case — usually upper. This helper deliberately does
|
|
90
|
+
* not upper-case for you: names created *with* quotes keep whatever case
|
|
91
|
+
* they were given, and mangling those would be the worse failure of the two,
|
|
92
|
+
* because it would corrupt a name that was previously correct.
|
|
93
|
+
*/
|
|
94
|
+
identifier(name: string): RawSql;
|
|
95
|
+
/**
|
|
96
|
+
* Join values or fragments with a separator, as one fragment.
|
|
97
|
+
*
|
|
98
|
+
* The `IN` list problem: `WHERE id IN ${ids}` cannot work, because one
|
|
99
|
+
* placeholder binds one value.
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* await db.query(sql`SELECT * FROM items WHERE id IN (${sql.join(ids)})`);
|
|
103
|
+
* // SELECT * FROM items WHERE id IN (?, ?, ?)
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* Elements may be fragments, which is how a list of conditions is built:
|
|
107
|
+
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* sql`WHERE ${sql.join(conditions, ' AND ')}`
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* Note the parentheses above are written by the caller, not added here —
|
|
113
|
+
* `join` has no way to know whether it is filling an `IN` list or an
|
|
114
|
+
* `AND` chain.
|
|
115
|
+
*
|
|
116
|
+
* @throws if `values` is empty. `IN ()` is a syntax error in Firebird and an
|
|
117
|
+
* empty `AND` chain is an empty `WHERE`, so there is no text this could
|
|
118
|
+
* return that is not a bug somewhere later. An empty list usually means
|
|
119
|
+
* the caller wants "match nothing" (`1 = 0`) or "no filter" (`1 = 1`), and
|
|
120
|
+
* only the caller knows which.
|
|
121
|
+
*/
|
|
122
|
+
join(values: readonly unknown[], separator?: string): SqlFragment;
|
|
123
|
+
/**
|
|
124
|
+
* Splice text in literally, escaping nothing.
|
|
125
|
+
*
|
|
126
|
+
* For syntax that cannot be a parameter and is not an identifier — a sort
|
|
127
|
+
* direction, a `FIRST`/`SKIP` clause built by hand.
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* const dir = ascending ? sql.unsafe('ASC') : sql.unsafe('DESC');
|
|
131
|
+
* await db.query(sql`SELECT * FROM items ORDER BY name ${dir}`);
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* Named `unsafe` because it is: anything reaching it from outside the
|
|
135
|
+
* program is an injection. The name is the warning, and it shows up at the
|
|
136
|
+
* call site during review rather than in this file.
|
|
137
|
+
*/
|
|
138
|
+
unsafe(text: string): RawSql;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Build a {@link SqlFragment} from a template literal.
|
|
142
|
+
*
|
|
143
|
+
* See the module comment for what this is for and what it cannot do.
|
|
144
|
+
*/
|
|
145
|
+
export declare const sql: SqlTag;
|
|
146
|
+
/** A statement in the form the backends bind: text plus positional values. */
|
|
147
|
+
export interface Statement {
|
|
148
|
+
sql: string;
|
|
149
|
+
params: QueryParams;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Normalise the two calling conventions into one.
|
|
153
|
+
*
|
|
154
|
+
* `query()` and `exec()` take either a string with its parameters or a
|
|
155
|
+
* fragment carrying its own, and every backend needs the same reduction.
|
|
156
|
+
*
|
|
157
|
+
* @throws if a fragment is given alongside parameters. It reads as though the
|
|
158
|
+
* two combine, and they cannot: the fragment's placeholders are already
|
|
159
|
+
* filled, so the extra values would bind to nothing. Silently ignoring them
|
|
160
|
+
* would run a query the caller did not write.
|
|
161
|
+
*/
|
|
162
|
+
export declare function toStatement(sql: string | SqlFragment, params?: QueryParams): Statement;
|
|
163
|
+
/**
|
|
164
|
+
* Resolve `query()`'s two shapes: `(sql, params, options)` and
|
|
165
|
+
* `(fragment, options)`.
|
|
166
|
+
*
|
|
167
|
+
* A fragment carries its own parameters, so the slot that would have held them
|
|
168
|
+
* is free — and making the caller write `query(fragment, undefined, options)`
|
|
169
|
+
* to reach the third argument would be a poor trade for the tag's ergonomics.
|
|
170
|
+
* The two are told apart by whether the argument is an array, which is
|
|
171
|
+
* unambiguous: parameters are always one, options never are.
|
|
172
|
+
*
|
|
173
|
+
* @throws if a string statement is given a second argument that is not an
|
|
174
|
+
* array. `query('… WHERE id = ?', 5)` reads as though it binds 5, and taking
|
|
175
|
+
* it for transaction options instead would run the statement with no
|
|
176
|
+
* parameters at all — the engine then complains about a placeholder count,
|
|
177
|
+
* naming nothing the caller wrote. TypeScript rules this out; untyped
|
|
178
|
+
* JavaScript, which the browser build is used from, does not.
|
|
179
|
+
*/
|
|
180
|
+
export declare function resolveQueryCall(sql: string | SqlFragment, paramsOrOptions?: QueryParams | TransactionOptions, maybeOptions?: TransactionOptions): {
|
|
181
|
+
statement: Statement;
|
|
182
|
+
options: TransactionOptions;
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=sql-tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-tag.d.ts","sourceRoot":"","sources":["../src/sql-tag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAkB/D;;;;;GAKG;AACH,qBAAa,WAAW;IAEpB,wDAAwD;IACxD,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW;;IAH5B,wDAAwD;IAC/C,GAAG,EAAE,MAAM;IACpB,6CAA6C;IACpC,MAAM,EAAE,WAAW;CAM/B;AAED;;;;;;GAMG;AACH,qBAAa,MAAM;IACL,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM;CAGjC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAMlE;AAcD,gFAAgF;AAChF,MAAM,WAAW,MAAM;IACrB,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;IAEnE;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,IAAI,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAElE;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAkHD;;;;GAIG;AACH,eAAO,MAAM,GAAG,EAAE,MAAyD,CAAC;AAM5E,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,GAAG,WAAW,EACzB,MAAM,GAAE,WAAgB,GACvB,SAAS,CAgCX;AAgBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,WAAW,EACzB,eAAe,GAAE,WAAW,GAAG,kBAAuB,EACtD,YAAY,GAAE,kBAAuB,GACpC;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAoBvD"}
|
package/dist/sql-tag.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* sql-tag.ts – the `` sql`…` `` template tag.
|
|
4
|
+
*
|
|
5
|
+
* Interpolation in a SQL string is the classic injection bug, and the usual
|
|
6
|
+
* advice — "use parameters" — is awkward enough that people don't:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* await db.query('SELECT * FROM items WHERE id = ? AND name = ?', [id, name]);
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The values sit far from the holes they fill, and adding a condition means
|
|
13
|
+
* editing two places and keeping them in the same order. The tag closes that
|
|
14
|
+
* distance without giving up parameter binding:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* await db.query(sql`SELECT * FROM items WHERE id = ${id} AND name = ${name}`);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Every `${…}` becomes a `?` and its value is bound, so a value can never be
|
|
21
|
+
* read as SQL. That is the whole safety property, and it holds no matter what
|
|
22
|
+
* the value contains — `"'; DROP TABLE items --"` is a five-word string, not a
|
|
23
|
+
* statement.
|
|
24
|
+
*
|
|
25
|
+
* What a tagged template cannot do is parameterise the parts of a statement
|
|
26
|
+
* that are not values: table and column names, `ORDER BY` direction, whole
|
|
27
|
+
* conditions. Those need text, and text is where injection lives again, so the
|
|
28
|
+
* three ways to produce it are named and separate — {@link SqlTag.identifier},
|
|
29
|
+
* {@link SqlTag.join}, and {@link SqlTag.unsafe}. Only the last is a loaded
|
|
30
|
+
* gun, and it says so at the call site.
|
|
31
|
+
*
|
|
32
|
+
* Fragments nest, which is what makes conditional SQL bearable:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const active = onlyActive ? sql`AND active = ${true}` : sql``;
|
|
36
|
+
* await db.query(sql`SELECT * FROM items WHERE owner = ${user} ${active}`);
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Placeholders renumber themselves because Firebird's are positional `?`
|
|
40
|
+
* rather than `$1` — splicing a fragment is concatenation on both the text and
|
|
41
|
+
* the parameter list, with no renumbering to get wrong.
|
|
42
|
+
*/
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.sql = exports.RawSql = exports.SqlFragment = void 0;
|
|
45
|
+
exports.isSqlFragment = isSqlFragment;
|
|
46
|
+
exports.toStatement = toStatement;
|
|
47
|
+
exports.resolveQueryCall = resolveQueryCall;
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Fragments
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Brands, registered globally rather than per module instance.
|
|
53
|
+
*
|
|
54
|
+
* `instanceof` would be the obvious check and is wrong here: this package has
|
|
55
|
+
* two entry points, and an application that reaches both — or that ends up
|
|
56
|
+
* with two installed copies — gets two `SqlFragment` classes whose instances
|
|
57
|
+
* fail each other's `instanceof`. A `Symbol.for` key is the same symbol in
|
|
58
|
+
* every copy, so the check survives that.
|
|
59
|
+
*/
|
|
60
|
+
const FRAGMENT = Symbol.for('firebird-wasm.SqlFragment');
|
|
61
|
+
const RAW = Symbol.for('firebird-wasm.RawSql');
|
|
62
|
+
/**
|
|
63
|
+
* A piece of SQL and the values bound to its placeholders.
|
|
64
|
+
*
|
|
65
|
+
* Produced by {@link sql}, accepted anywhere `(sql, params)` is. Both fields
|
|
66
|
+
* are readable, which is what makes a query loggable before it runs.
|
|
67
|
+
*/
|
|
68
|
+
class SqlFragment {
|
|
69
|
+
constructor(
|
|
70
|
+
/** Statement text, with a `?` for every bound value. */
|
|
71
|
+
sql,
|
|
72
|
+
/** Values for the placeholders, in order. */
|
|
73
|
+
params) {
|
|
74
|
+
this.sql = sql;
|
|
75
|
+
this.params = params;
|
|
76
|
+
// Non-enumerable so the brand stays out of spreads, `JSON.stringify` and
|
|
77
|
+
// anything else that walks own keys.
|
|
78
|
+
Object.defineProperty(this, FRAGMENT, { value: true });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.SqlFragment = SqlFragment;
|
|
82
|
+
/**
|
|
83
|
+
* SQL text that is spliced in literally, with nothing bound.
|
|
84
|
+
*
|
|
85
|
+
* There is no way to make this safe in general — that is the point of keeping
|
|
86
|
+
* it a distinct type rather than letting any string through. It exists because
|
|
87
|
+
* identifiers and syntax cannot be parameters.
|
|
88
|
+
*/
|
|
89
|
+
class RawSql {
|
|
90
|
+
constructor(sql) {
|
|
91
|
+
this.sql = sql;
|
|
92
|
+
Object.defineProperty(this, RAW, { value: true });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.RawSql = RawSql;
|
|
96
|
+
/** True if `value` came from {@link sql}. */
|
|
97
|
+
function isSqlFragment(value) {
|
|
98
|
+
return (typeof value === 'object' &&
|
|
99
|
+
value !== null &&
|
|
100
|
+
value[FRAGMENT] === true);
|
|
101
|
+
}
|
|
102
|
+
function isRawSql(value) {
|
|
103
|
+
return (typeof value === 'object' &&
|
|
104
|
+
value !== null &&
|
|
105
|
+
value[RAW] === true);
|
|
106
|
+
}
|
|
107
|
+
function tag(strings, ...values) {
|
|
108
|
+
let text = '';
|
|
109
|
+
const params = [];
|
|
110
|
+
for (let i = 0; i < strings.length; i++) {
|
|
111
|
+
const chunk = strings[i];
|
|
112
|
+
// Cooked strings are `undefined` for an invalid escape sequence — legal in
|
|
113
|
+
// a tagged template since ES2018, where it hands the tag a hole rather
|
|
114
|
+
// than a syntax error. Concatenating it would put the text "undefined"
|
|
115
|
+
// into the statement, which fails later and somewhere else.
|
|
116
|
+
if (chunk === undefined) {
|
|
117
|
+
throw new SyntaxError(`sql\`…\` contains an invalid escape sequence in segment ${i}; ` +
|
|
118
|
+
'use sql.unsafe() if the text is meant to be literal');
|
|
119
|
+
}
|
|
120
|
+
text += chunk;
|
|
121
|
+
if (i < values.length) {
|
|
122
|
+
text += interpolate(values[i], params, i, 'template');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return new SqlFragment(text, params);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Render one `${…}`, appending to `params` when it binds.
|
|
129
|
+
*
|
|
130
|
+
* `where` names the caller, because the two callers fail differently and a
|
|
131
|
+
* message that describes the wrong one sends the reader to the wrong line —
|
|
132
|
+
* see {@link join}.
|
|
133
|
+
*
|
|
134
|
+
* @returns the text this value contributes.
|
|
135
|
+
*/
|
|
136
|
+
function interpolate(value, params, index, where) {
|
|
137
|
+
if (isSqlFragment(value)) {
|
|
138
|
+
// A loop rather than push(...spread): every parameter would otherwise
|
|
139
|
+
// become a separate argument, and a large enough list overflows the call
|
|
140
|
+
// stack with a RangeError that names neither the list nor the limit.
|
|
141
|
+
for (const param of value.params)
|
|
142
|
+
params.push(param);
|
|
143
|
+
return value.sql;
|
|
144
|
+
}
|
|
145
|
+
if (isRawSql(value)) {
|
|
146
|
+
return value.sql;
|
|
147
|
+
}
|
|
148
|
+
if (Array.isArray(value)) {
|
|
149
|
+
// One placeholder binds one value, so an array here is always a mistake —
|
|
150
|
+
// and always the same mistake, which is worth naming precisely. Left to
|
|
151
|
+
// the parameter encoder it surfaces as "unsupported type object" at bind
|
|
152
|
+
// time, which does not suggest the fix.
|
|
153
|
+
throw new TypeError(where === 'join'
|
|
154
|
+
? `Element ${index} passed to sql.join() is an array. sql.join() does ` +
|
|
155
|
+
'not flatten, because a nested list has no unambiguous SQL form — ' +
|
|
156
|
+
'flatten it first, or join the inner lists yourself'
|
|
157
|
+
: `Value ${index} in sql\`…\` is an array, which cannot bind to a ` +
|
|
158
|
+
'single placeholder; use sql.join(values) to expand it into a list');
|
|
159
|
+
}
|
|
160
|
+
params.push(value);
|
|
161
|
+
return '?';
|
|
162
|
+
}
|
|
163
|
+
function identifier(name) {
|
|
164
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
165
|
+
throw new TypeError('sql.identifier() needs a non-empty name');
|
|
166
|
+
}
|
|
167
|
+
if (name.includes('\0')) {
|
|
168
|
+
// Firebird would reject it, but not before the NUL had truncated the
|
|
169
|
+
// statement in whatever handled it first.
|
|
170
|
+
throw new TypeError('sql.identifier() cannot contain a NUL character');
|
|
171
|
+
}
|
|
172
|
+
return new RawSql(`"${name.replace(/"/g, '""')}"`);
|
|
173
|
+
}
|
|
174
|
+
function join(values, separator = ', ') {
|
|
175
|
+
if (values.length === 0) {
|
|
176
|
+
throw new RangeError('sql.join() needs at least one value: an empty list has no valid SQL ' +
|
|
177
|
+
'form (IN () is a syntax error). Guard the empty case with the ' +
|
|
178
|
+
'condition you actually mean — 1 = 0 to match nothing, 1 = 1 to ' +
|
|
179
|
+
'match everything');
|
|
180
|
+
}
|
|
181
|
+
let text = '';
|
|
182
|
+
const params = [];
|
|
183
|
+
values.forEach((value, index) => {
|
|
184
|
+
if (index > 0)
|
|
185
|
+
text += separator;
|
|
186
|
+
text += interpolate(value, params, index, 'join');
|
|
187
|
+
});
|
|
188
|
+
return new SqlFragment(text, params);
|
|
189
|
+
}
|
|
190
|
+
function unsafe(text) {
|
|
191
|
+
if (typeof text !== 'string') {
|
|
192
|
+
throw new TypeError('sql.unsafe() needs a string');
|
|
193
|
+
}
|
|
194
|
+
return new RawSql(text);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Build a {@link SqlFragment} from a template literal.
|
|
198
|
+
*
|
|
199
|
+
* See the module comment for what this is for and what it cannot do.
|
|
200
|
+
*/
|
|
201
|
+
exports.sql = Object.assign(tag, { identifier, join, unsafe });
|
|
202
|
+
/**
|
|
203
|
+
* Normalise the two calling conventions into one.
|
|
204
|
+
*
|
|
205
|
+
* `query()` and `exec()` take either a string with its parameters or a
|
|
206
|
+
* fragment carrying its own, and every backend needs the same reduction.
|
|
207
|
+
*
|
|
208
|
+
* @throws if a fragment is given alongside parameters. It reads as though the
|
|
209
|
+
* two combine, and they cannot: the fragment's placeholders are already
|
|
210
|
+
* filled, so the extra values would bind to nothing. Silently ignoring them
|
|
211
|
+
* would run a query the caller did not write.
|
|
212
|
+
*/
|
|
213
|
+
function toStatement(sql, params = []) {
|
|
214
|
+
if (typeof sql === 'string') {
|
|
215
|
+
return { sql, params };
|
|
216
|
+
}
|
|
217
|
+
if (isSqlFragment(sql)) {
|
|
218
|
+
if (params.length > 0) {
|
|
219
|
+
throw new TypeError('A sql`…` fragment already carries its parameters; passing more would ' +
|
|
220
|
+
'bind them to nothing. Interpolate the values into the template ' +
|
|
221
|
+
'instead');
|
|
222
|
+
}
|
|
223
|
+
return { sql: sql.sql, params: sql.params };
|
|
224
|
+
}
|
|
225
|
+
// Anything else would have been passed through as the statement text, and
|
|
226
|
+
// an object reaches the engine as "[object Object]" — a syntax error that
|
|
227
|
+
// names a token rather than the argument, with the fragment's values
|
|
228
|
+
// silently dropped.
|
|
229
|
+
//
|
|
230
|
+
// The look-alike this catches is not hypothetical. `SqlFragment` is
|
|
231
|
+
// structurally `{ sql, params }`, so a plain object of that shape type-checks
|
|
232
|
+
// against the fragment overload, and the brand is a symbol, which neither
|
|
233
|
+
// `structuredClone` nor `JSON` carries: a fragment built in a Worker and
|
|
234
|
+
// posted to the main thread arrives as exactly such a look-alike.
|
|
235
|
+
throw new TypeError(`Expected a SQL string or a sql\`…\` fragment, got ${describe(sql)}. ` +
|
|
236
|
+
'A fragment does not survive structuredClone or JSON — it carries a ' +
|
|
237
|
+
'symbol brand — so rebuild it on the receiving side rather than sending it');
|
|
238
|
+
}
|
|
239
|
+
/** Name a value for an error message, without dumping its contents. */
|
|
240
|
+
function describe(value) {
|
|
241
|
+
if (value === null)
|
|
242
|
+
return 'null';
|
|
243
|
+
if (Array.isArray(value))
|
|
244
|
+
return 'an array';
|
|
245
|
+
if (typeof value !== 'object')
|
|
246
|
+
return `a ${typeof value}`;
|
|
247
|
+
const name = value.constructor?.name;
|
|
248
|
+
const looksLikeFragment = 'sql' in value && 'params' in value;
|
|
249
|
+
return looksLikeFragment
|
|
250
|
+
? `a { sql, params } object that is not a fragment (${name ?? 'object'})`
|
|
251
|
+
: `a ${name ?? 'object'}`;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Resolve `query()`'s two shapes: `(sql, params, options)` and
|
|
255
|
+
* `(fragment, options)`.
|
|
256
|
+
*
|
|
257
|
+
* A fragment carries its own parameters, so the slot that would have held them
|
|
258
|
+
* is free — and making the caller write `query(fragment, undefined, options)`
|
|
259
|
+
* to reach the third argument would be a poor trade for the tag's ergonomics.
|
|
260
|
+
* The two are told apart by whether the argument is an array, which is
|
|
261
|
+
* unambiguous: parameters are always one, options never are.
|
|
262
|
+
*
|
|
263
|
+
* @throws if a string statement is given a second argument that is not an
|
|
264
|
+
* array. `query('… WHERE id = ?', 5)` reads as though it binds 5, and taking
|
|
265
|
+
* it for transaction options instead would run the statement with no
|
|
266
|
+
* parameters at all — the engine then complains about a placeholder count,
|
|
267
|
+
* naming nothing the caller wrote. TypeScript rules this out; untyped
|
|
268
|
+
* JavaScript, which the browser build is used from, does not.
|
|
269
|
+
*/
|
|
270
|
+
function resolveQueryCall(sql, paramsOrOptions = [], maybeOptions = {}) {
|
|
271
|
+
if (Array.isArray(paramsOrOptions)) {
|
|
272
|
+
return {
|
|
273
|
+
statement: toStatement(sql, paramsOrOptions),
|
|
274
|
+
options: maybeOptions,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (typeof sql === 'string') {
|
|
278
|
+
throw new TypeError(`Expected an array of parameters, got ${describe(paramsOrOptions)}. ` +
|
|
279
|
+
'Transaction options go in the second argument only for a sql`…` ' +
|
|
280
|
+
'fragment, which carries its own parameters');
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
statement: toStatement(sql, []),
|
|
284
|
+
options: paramsOrOptions,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=sql-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-tag.js","sourceRoot":"","sources":["../src/sql-tag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;AAqDH,sCAMC;AAiOD,kCAmCC;AAiCD,4CAwBC;AApXD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AACzD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC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IAAI,QAAQ,IAAK,KAAgB,CAAC;IAC9D,OAAO,iBAAiB;QACtB,CAAC,CAAC,oDAAoD,IAAI,IAAI,QAAQ,GAAG;QACzE,CAAC,CAAC,KAAK,IAAI,IAAI,QAAQ,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,gBAAgB,CAC9B,GAAyB,EACzB,kBAAoD,EAAE,EACtD,eAAmC,EAAE;IAErC,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QACnC,OAAO;YACL,SAAS,EAAE,WAAW,CAAC,GAAG,EAAE,eAAe,CAAC;YAC5C,OAAO,EAAE,YAAY;SACtB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,SAAS,CACjB,wCAAwC,QAAQ,CAAC,eAAe,CAAC,IAAI;YACnE,kEAAkE;YAClE,4CAA4C,CAC/C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;QAC/B,OAAO,EAAE,eAAqC;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* statement-types.ts – names for Firebird's statement-type codes.
|
|
3
|
+
*
|
|
4
|
+
* The engine reports what a statement *is* as one of the `isc_info_sql_stmt_*`
|
|
5
|
+
* constants. A caller asking `describeQuery()` what they have wants the name,
|
|
6
|
+
* not the number — the number is only meaningful next to a copy of
|
|
7
|
+
* `iberror.h`.
|
|
8
|
+
*
|
|
9
|
+
* Shared by both backends rather than per-backend: `node-firebird-driver`'s
|
|
10
|
+
* `StatementType` enum is these same codes, so one table describes what either
|
|
11
|
+
* one reports and the two cannot drift into naming the same statement
|
|
12
|
+
* differently.
|
|
13
|
+
*/
|
|
14
|
+
import type { StatementKind } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Name a statement-type code.
|
|
17
|
+
*
|
|
18
|
+
* An unrecognised code is `'UNKNOWN'` rather than an error: a Firebird release
|
|
19
|
+
* may add one, and a name this library has not learned yet is no reason to
|
|
20
|
+
* fail a description that is otherwise complete.
|
|
21
|
+
*/
|
|
22
|
+
export declare function statementKind(code: number): StatementKind;
|
|
23
|
+
//# sourceMappingURL=statement-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement-types.d.ts","sourceRoot":"","sources":["../src/statement-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAoB7C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAEzD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* statement-types.ts – names for Firebird's statement-type codes.
|
|
4
|
+
*
|
|
5
|
+
* The engine reports what a statement *is* as one of the `isc_info_sql_stmt_*`
|
|
6
|
+
* constants. A caller asking `describeQuery()` what they have wants the name,
|
|
7
|
+
* not the number — the number is only meaningful next to a copy of
|
|
8
|
+
* `iberror.h`.
|
|
9
|
+
*
|
|
10
|
+
* Shared by both backends rather than per-backend: `node-firebird-driver`'s
|
|
11
|
+
* `StatementType` enum is these same codes, so one table describes what either
|
|
12
|
+
* one reports and the two cannot drift into naming the same statement
|
|
13
|
+
* differently.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.statementKind = statementKind;
|
|
17
|
+
// From firebird/impl/consts_pub.h (isc_info_sql_stmt_*).
|
|
18
|
+
const NAMES = {
|
|
19
|
+
1: 'SELECT',
|
|
20
|
+
2: 'INSERT',
|
|
21
|
+
3: 'UPDATE',
|
|
22
|
+
4: 'DELETE',
|
|
23
|
+
5: 'DDL',
|
|
24
|
+
6: 'GET_SEGMENT',
|
|
25
|
+
7: 'PUT_SEGMENT',
|
|
26
|
+
8: 'EXEC_PROCEDURE',
|
|
27
|
+
9: 'START_TRANS',
|
|
28
|
+
10: 'COMMIT',
|
|
29
|
+
11: 'ROLLBACK',
|
|
30
|
+
12: 'SELECT_FOR_UPD',
|
|
31
|
+
13: 'SET_GENERATOR',
|
|
32
|
+
14: 'SAVEPOINT',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Name a statement-type code.
|
|
36
|
+
*
|
|
37
|
+
* An unrecognised code is `'UNKNOWN'` rather than an error: a Firebird release
|
|
38
|
+
* may add one, and a name this library has not learned yet is no reason to
|
|
39
|
+
* fail a description that is otherwise complete.
|
|
40
|
+
*/
|
|
41
|
+
function statementKind(code) {
|
|
42
|
+
return NAMES[code] ?? 'UNKNOWN';
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=statement-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement-types.js","sourceRoot":"","sources":["../src/statement-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AA6BH,sCAEC;AA3BD,yDAAyD;AACzD,MAAM,KAAK,GAAkC;IAC3C,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,gBAAgB;IACnB,CAAC,EAAE,aAAa;IAChB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,UAAU;IACd,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,eAAe;IACnB,EAAE,EAAE,WAAW;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC;AAClC,CAAC"}
|