@apache-arrow/adbc-driver-manager 0.23.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/LICENSE.txt +523 -0
- package/README.md +130 -0
- package/binding.d.ts +71 -0
- package/binding.js +593 -0
- package/dist/error.d.ts +15 -0
- package/dist/error.js +43 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +386 -0
- package/dist/types.d.ts +398 -0
- package/dist/types.js +112 -0
- package/license.hbs +33 -0
- package/package.json +92 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { RecordBatchReader, Table, Schema } from 'apache-arrow';
|
|
2
|
+
/**
|
|
3
|
+
* Bitmask flags controlling how the driver manager resolves a driver name.
|
|
4
|
+
*
|
|
5
|
+
* These values correspond to the `ADBC_LOAD_FLAG_*` constants in the ADBC spec.
|
|
6
|
+
* Flags can be combined with bitwise OR. When `loadFlags` is omitted in
|
|
7
|
+
* `ConnectOptions`, `LoadFlags.Default` is used.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Only search system paths, disallow relative paths
|
|
11
|
+
* const db = new AdbcDatabase({
|
|
12
|
+
* driver: 'sqlite',
|
|
13
|
+
* loadFlags: LoadFlags.SearchSystem,
|
|
14
|
+
* })
|
|
15
|
+
*/
|
|
16
|
+
export declare const LoadFlags: {
|
|
17
|
+
/** Search directory paths in the `ADBC_DRIVER_PATH` environment variable (and the conda environment, if installed via conda). */
|
|
18
|
+
readonly SearchEnv: number;
|
|
19
|
+
/** Search the user configuration directory. */
|
|
20
|
+
readonly SearchUser: number;
|
|
21
|
+
/** Search the system configuration directory. */
|
|
22
|
+
readonly SearchSystem: number;
|
|
23
|
+
/** Allow a relative path to be provided as the driver name. */
|
|
24
|
+
readonly AllowRelativePaths: number;
|
|
25
|
+
/** All defined flags enabled. This is the default when `loadFlags` is omitted. */
|
|
26
|
+
readonly Default: number;
|
|
27
|
+
};
|
|
28
|
+
export type LoadFlags = (typeof LoadFlags)[keyof typeof LoadFlags];
|
|
29
|
+
/**
|
|
30
|
+
* Depth values for the `getObjects` metadata call.
|
|
31
|
+
*
|
|
32
|
+
* These correspond to the `ADBC_OBJECT_DEPTH_*` constants in the ADBC spec.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Retrieve catalogs and schemas only
|
|
36
|
+
* await conn.getObjects({ depth: ObjectDepth.Schemas })
|
|
37
|
+
*/
|
|
38
|
+
export declare const ObjectDepth: {
|
|
39
|
+
/** Catalogs, schemas, tables, and columns (default). */
|
|
40
|
+
readonly All: 0;
|
|
41
|
+
/** Catalogs only. */
|
|
42
|
+
readonly Catalogs: 1;
|
|
43
|
+
/** Catalogs and schemas. */
|
|
44
|
+
readonly Schemas: 2;
|
|
45
|
+
/** Catalogs, schemas, and tables. */
|
|
46
|
+
readonly Tables: 3;
|
|
47
|
+
};
|
|
48
|
+
export type ObjectDepth = (typeof ObjectDepth)[keyof typeof ObjectDepth];
|
|
49
|
+
/**
|
|
50
|
+
* Info codes for the `getInfo` metadata call.
|
|
51
|
+
*
|
|
52
|
+
* These correspond to the `ADBC_INFO_*` constants in the ADBC spec.
|
|
53
|
+
* Pass a subset to `getInfo()` to retrieve only specific metadata fields.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const table = await conn.getInfo([InfoCode.VendorName, InfoCode.DriverVersion])
|
|
57
|
+
*/
|
|
58
|
+
export declare const InfoCode: {
|
|
59
|
+
/** The database vendor/product name (string). */
|
|
60
|
+
readonly VendorName: 0;
|
|
61
|
+
/** The database vendor/product version (string). */
|
|
62
|
+
readonly VendorVersion: 1;
|
|
63
|
+
/** The Arrow library version used by the vendor (string). */
|
|
64
|
+
readonly VendorArrowVersion: 2;
|
|
65
|
+
/** Whether the vendor supports SQL queries (bool). */
|
|
66
|
+
readonly VendorSql: 3;
|
|
67
|
+
/** Whether the vendor supports Substrait queries (bool). */
|
|
68
|
+
readonly VendorSubstrait: 4;
|
|
69
|
+
/** Minimum supported Substrait version, or null (string). */
|
|
70
|
+
readonly VendorSubstraitMinVersion: 5;
|
|
71
|
+
/** Maximum supported Substrait version, or null (string). */
|
|
72
|
+
readonly VendorSubstraitMaxVersion: 6;
|
|
73
|
+
/** The driver name (string). */
|
|
74
|
+
readonly DriverName: 100;
|
|
75
|
+
/** The driver version (string). */
|
|
76
|
+
readonly DriverVersion: 101;
|
|
77
|
+
/** The Arrow library version used by the driver (string). */
|
|
78
|
+
readonly DriverArrowVersion: 102;
|
|
79
|
+
/** The ADBC API version implemented by the driver (int64). Available since ADBC 1.1.0. */
|
|
80
|
+
readonly DriverAdbcVersion: 103;
|
|
81
|
+
};
|
|
82
|
+
export type InfoCode = (typeof InfoCode)[keyof typeof InfoCode];
|
|
83
|
+
/**
|
|
84
|
+
* Options for connecting to a driver/database.
|
|
85
|
+
*
|
|
86
|
+
* These options configure how the ADBC driver is loaded and how the initial connection is established.
|
|
87
|
+
*/
|
|
88
|
+
export interface ConnectOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Driver to load. Accepts any of the following forms:
|
|
91
|
+
* - Short name: `"sqlite"`, `"postgresql"` — the driver manager searches for a matching
|
|
92
|
+
* manifest file (e.g. `sqlite.toml`) in the configured directories, then falls back to
|
|
93
|
+
* `LD_LIBRARY_PATH` / `PATH`.
|
|
94
|
+
* - Absolute path to a shared library: `"/usr/lib/libadbc_driver_sqlite.so"`
|
|
95
|
+
* - Absolute path to a driver manifest `.toml` file (with or without the `.toml` extension).
|
|
96
|
+
* - Relative path (only valid when {@link LoadFlags.AllowRelativePaths} is set).
|
|
97
|
+
* - URI-style string: `"sqlite:file::memory:"`, `"postgresql://user:pass@host/db"` — the
|
|
98
|
+
* driver name is the URI scheme and the remainder is passed as the connection URI.
|
|
99
|
+
* - Connection profile URI: `"profile://my_profile"` — loads a named profile from a
|
|
100
|
+
* `.toml` file found in {@link profileSearchPaths} or the default search directories.
|
|
101
|
+
*/
|
|
102
|
+
driver: string;
|
|
103
|
+
/**
|
|
104
|
+
* Name of the entrypoint function (optional).
|
|
105
|
+
* If not provided, ADBC will attempt to guess the entrypoint symbol name based on the driver name.
|
|
106
|
+
*/
|
|
107
|
+
entrypoint?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Additional directories to search for drivers and driver manifest (`.toml`) files (optional).
|
|
110
|
+
* Searched before the default system and user configuration directories.
|
|
111
|
+
*/
|
|
112
|
+
manifestSearchPaths?: string[];
|
|
113
|
+
/**
|
|
114
|
+
* Additional directories to search for connection profile (`.toml`) files (optional).
|
|
115
|
+
* Searched before the default system and user configuration directories.
|
|
116
|
+
*/
|
|
117
|
+
profileSearchPaths?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Bitmask controlling how the driver name is resolved (optional).
|
|
120
|
+
* Use the {@link LoadFlags} constants to compose a value.
|
|
121
|
+
* Defaults to {@link LoadFlags.Default} (all search locations enabled) when omitted.
|
|
122
|
+
*/
|
|
123
|
+
loadFlags?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Database-specific options.
|
|
126
|
+
* Key-value pairs passed to the driver during database initialization (e.g., "uri", "username").
|
|
127
|
+
*/
|
|
128
|
+
databaseOptions?: Record<string, string>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Ingestion modes for the `ingest` convenience method.
|
|
132
|
+
*
|
|
133
|
+
* These correspond to the `adbc.ingest.mode.*` option values in the ADBC spec.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* await conn.ingest('my_table', data, { mode: IngestMode.Append })
|
|
137
|
+
*/
|
|
138
|
+
export declare const IngestMode: {
|
|
139
|
+
/** Append to an existing table. Fails if the table does not exist. */
|
|
140
|
+
readonly Append: "adbc.ingest.mode.append";
|
|
141
|
+
/** Create a new table and insert. Fails if the table already exists. */
|
|
142
|
+
readonly Create: "adbc.ingest.mode.create";
|
|
143
|
+
/** Create the table if it does not exist, then append. */
|
|
144
|
+
readonly CreateAppend: "adbc.ingest.mode.create_append";
|
|
145
|
+
/** Drop the existing table (if any) and recreate it, then insert. */
|
|
146
|
+
readonly Replace: "adbc.ingest.mode.replace";
|
|
147
|
+
};
|
|
148
|
+
export type IngestMode = (typeof IngestMode)[keyof typeof IngestMode];
|
|
149
|
+
/** Options for the `ingest` convenience method. */
|
|
150
|
+
export interface IngestOptions {
|
|
151
|
+
/**
|
|
152
|
+
* How to handle an existing table.
|
|
153
|
+
* Defaults to {@link IngestMode.Create}.
|
|
154
|
+
*/
|
|
155
|
+
mode?: IngestMode;
|
|
156
|
+
/** The catalog to create/locate the target table in (optional). */
|
|
157
|
+
catalog?: string;
|
|
158
|
+
/** The database schema to create/locate the target table in (optional). */
|
|
159
|
+
dbSchema?: string;
|
|
160
|
+
/** Whether to ingest into a temporary table (optional). */
|
|
161
|
+
temporary?: boolean;
|
|
162
|
+
}
|
|
163
|
+
/** Options for getObjects metadata call. */
|
|
164
|
+
export interface GetObjectsOptions {
|
|
165
|
+
/**
|
|
166
|
+
* The level of depth to retrieve. Use the {@link ObjectDepth} constants.
|
|
167
|
+
* Defaults to {@link ObjectDepth.All} when omitted.
|
|
168
|
+
*/
|
|
169
|
+
depth?: ObjectDepth;
|
|
170
|
+
/** Filter by catalog name pattern. */
|
|
171
|
+
catalog?: string;
|
|
172
|
+
/** Filter by database schema name pattern. */
|
|
173
|
+
dbSchema?: string;
|
|
174
|
+
/** Filter by table name pattern. */
|
|
175
|
+
tableName?: string;
|
|
176
|
+
/** Filter by table type (e.g., ["table", "view"]). */
|
|
177
|
+
tableType?: string[];
|
|
178
|
+
/** Filter by column name pattern. */
|
|
179
|
+
columnName?: string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Represents an ADBC Database.
|
|
183
|
+
*
|
|
184
|
+
* An AdbcDatabase represents a handle to a database. This may be a single file (SQLite),
|
|
185
|
+
* a connection configuration (PostgreSQL), or an in-memory database.
|
|
186
|
+
* It holds state that is shared across multiple connections.
|
|
187
|
+
*/
|
|
188
|
+
export interface AdbcDatabase {
|
|
189
|
+
/**
|
|
190
|
+
* Open a new connection to the database.
|
|
191
|
+
*
|
|
192
|
+
* @returns A Promise resolving to a new AdbcConnection.
|
|
193
|
+
*/
|
|
194
|
+
connect(): Promise<AdbcConnection>;
|
|
195
|
+
/**
|
|
196
|
+
* Release the database resources.
|
|
197
|
+
* After closing, the database object should not be used.
|
|
198
|
+
*/
|
|
199
|
+
close(): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Represents a single connection to a database.
|
|
203
|
+
*
|
|
204
|
+
* An AdbcConnection maintains the state of a connection to the database, such as
|
|
205
|
+
* current transaction state and session options.
|
|
206
|
+
*/
|
|
207
|
+
export interface AdbcConnection {
|
|
208
|
+
/**
|
|
209
|
+
* Create a new statement for executing queries.
|
|
210
|
+
*
|
|
211
|
+
* @returns A Promise resolving to a new AdbcStatement.
|
|
212
|
+
*/
|
|
213
|
+
createStatement(): Promise<AdbcStatement>;
|
|
214
|
+
/**
|
|
215
|
+
* Set an option on the connection.
|
|
216
|
+
*
|
|
217
|
+
* @param key The option name (e.g., "adbc.connection.autocommit").
|
|
218
|
+
* @param value The option value.
|
|
219
|
+
*/
|
|
220
|
+
setOption(key: string, value: string): void;
|
|
221
|
+
/**
|
|
222
|
+
* Toggle autocommit behavior.
|
|
223
|
+
*
|
|
224
|
+
* @param enabled Whether autocommit should be enabled.
|
|
225
|
+
*/
|
|
226
|
+
setAutoCommit(enabled: boolean): void;
|
|
227
|
+
/**
|
|
228
|
+
* Toggle read-only mode.
|
|
229
|
+
*
|
|
230
|
+
* @param enabled Whether the connection should be read-only.
|
|
231
|
+
*/
|
|
232
|
+
setReadOnly(enabled: boolean): void;
|
|
233
|
+
/**
|
|
234
|
+
* Get a hierarchical view of database objects (catalogs, schemas, tables, columns).
|
|
235
|
+
*
|
|
236
|
+
* @param options Filtering options for the metadata query.
|
|
237
|
+
* @returns A Promise resolving to an Apache Arrow Table containing the metadata.
|
|
238
|
+
*/
|
|
239
|
+
getObjects(options?: GetObjectsOptions): Promise<Table>;
|
|
240
|
+
/**
|
|
241
|
+
* Get the Arrow schema for a specific table.
|
|
242
|
+
*
|
|
243
|
+
* @param options An object containing catalog, dbSchema, and tableName.
|
|
244
|
+
* @param options.catalog The catalog name (or undefined).
|
|
245
|
+
* @param options.dbSchema The schema name (or undefined).
|
|
246
|
+
* @param options.tableName The table name.
|
|
247
|
+
* @returns A Promise resolving to the Arrow Schema of the table.
|
|
248
|
+
*/
|
|
249
|
+
getTableSchema(options: {
|
|
250
|
+
catalog?: string;
|
|
251
|
+
dbSchema?: string;
|
|
252
|
+
tableName: string;
|
|
253
|
+
}): Promise<Schema>;
|
|
254
|
+
/**
|
|
255
|
+
* Get a list of table types supported by the database.
|
|
256
|
+
*
|
|
257
|
+
* @returns A Promise resolving to an Apache Arrow Table with a single string column of table types.
|
|
258
|
+
*/
|
|
259
|
+
getTableTypes(): Promise<Table>;
|
|
260
|
+
/**
|
|
261
|
+
* Get metadata about the driver and database.
|
|
262
|
+
*
|
|
263
|
+
* @param infoCodes Optional list of info codes to retrieve. Use the {@link InfoCode} constants.
|
|
264
|
+
* If omitted, all available info is returned.
|
|
265
|
+
* @returns A Promise resolving to an Apache Arrow Table containing the requested metadata info.
|
|
266
|
+
*/
|
|
267
|
+
getInfo(infoCodes?: InfoCode[]): Promise<Table>;
|
|
268
|
+
/**
|
|
269
|
+
* Execute a SQL query and return all results as an Arrow Table.
|
|
270
|
+
*
|
|
271
|
+
* Convenience method that creates a statement, sets the SQL, optionally binds
|
|
272
|
+
* parameters, executes the query, and closes the statement.
|
|
273
|
+
* For large result sets, use {@link queryStream} to avoid loading everything into memory.
|
|
274
|
+
*
|
|
275
|
+
* @param sql The SQL query to execute.
|
|
276
|
+
* @param params Optional Arrow Table to bind as parameters.
|
|
277
|
+
* @returns A Promise resolving to an Apache Arrow Table.
|
|
278
|
+
*/
|
|
279
|
+
query(sql: string, params?: Table): Promise<Table>;
|
|
280
|
+
/**
|
|
281
|
+
* Execute a SQL query and return the results as a RecordBatchReader for streaming.
|
|
282
|
+
*
|
|
283
|
+
* Use this instead of {@link query} when working with large result sets that should
|
|
284
|
+
* not be fully loaded into memory. The reader remains valid after the statement is
|
|
285
|
+
* closed because the underlying iterator holds its own reference to the native resources.
|
|
286
|
+
*
|
|
287
|
+
* @param sql The SQL query to execute.
|
|
288
|
+
* @param params Optional Arrow Table to bind as parameters.
|
|
289
|
+
* @returns A Promise resolving to an Apache Arrow RecordBatchReader.
|
|
290
|
+
*/
|
|
291
|
+
queryStream(sql: string, params?: Table): Promise<RecordBatchReader>;
|
|
292
|
+
/**
|
|
293
|
+
* Ingest Arrow data into a database table.
|
|
294
|
+
*
|
|
295
|
+
* Convenience method that sets the ingestion options, binds the data, and
|
|
296
|
+
* calls executeUpdate. Depending on the driver, this can avoid per-row
|
|
297
|
+
* overhead compared to a prepare-bind-insert loop.
|
|
298
|
+
*
|
|
299
|
+
* @param tableName The target table name.
|
|
300
|
+
* @param data Arrow Table to ingest.
|
|
301
|
+
* @param options Ingestion options (mode, catalog, dbSchema, temporary).
|
|
302
|
+
* @returns A Promise resolving to the number of rows ingested, or -1 if unknown.
|
|
303
|
+
*/
|
|
304
|
+
ingest(tableName: string, data: Table, options?: IngestOptions): Promise<number>;
|
|
305
|
+
/**
|
|
306
|
+
* Ingest Arrow data from a stream into a database table.
|
|
307
|
+
*
|
|
308
|
+
* Unlike {@link ingest}, this method streams data batch-by-batch, avoiding
|
|
309
|
+
* full materialization in memory. Use this for large datasets that should
|
|
310
|
+
* not be buffered entirely.
|
|
311
|
+
*
|
|
312
|
+
* @param tableName The target table name.
|
|
313
|
+
* @param reader Arrow RecordBatchReader to stream.
|
|
314
|
+
* @param options Ingestion options (mode, catalog, dbSchema, temporary).
|
|
315
|
+
* @returns A Promise resolving to the number of rows ingested, or -1 if unknown.
|
|
316
|
+
*/
|
|
317
|
+
ingestStream(tableName: string, reader: RecordBatchReader, options?: IngestOptions): Promise<number>;
|
|
318
|
+
/**
|
|
319
|
+
* Execute a SQL statement (INSERT, UPDATE, DELETE, DDL) and return the row count.
|
|
320
|
+
*
|
|
321
|
+
* Convenience method that creates a statement, sets the SQL, optionally binds
|
|
322
|
+
* parameters, executes the update, and closes the statement.
|
|
323
|
+
*
|
|
324
|
+
* @param sql The SQL statement to execute.
|
|
325
|
+
* @param params Optional Arrow Table to bind as parameters.
|
|
326
|
+
* @returns A Promise resolving to the number of rows affected, or -1 if unknown.
|
|
327
|
+
*/
|
|
328
|
+
execute(sql: string, params?: Table): Promise<number>;
|
|
329
|
+
/**
|
|
330
|
+
* Commit any pending transactions.
|
|
331
|
+
* Only valid if autocommit is disabled.
|
|
332
|
+
*/
|
|
333
|
+
commit(): Promise<void>;
|
|
334
|
+
/**
|
|
335
|
+
* Rollback any pending transactions.
|
|
336
|
+
* Only valid if autocommit is disabled.
|
|
337
|
+
*/
|
|
338
|
+
rollback(): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Close the connection and release resources.
|
|
341
|
+
*/
|
|
342
|
+
close(): Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Represents a query statement.
|
|
346
|
+
*
|
|
347
|
+
* An AdbcStatement is used to execute SQL queries or prepare bulk insertions.
|
|
348
|
+
* State such as the SQL query string or bound parameters is held by the statement.
|
|
349
|
+
*/
|
|
350
|
+
export interface AdbcStatement {
|
|
351
|
+
/**
|
|
352
|
+
* Set the SQL query string.
|
|
353
|
+
*
|
|
354
|
+
* @param query The SQL query to execute.
|
|
355
|
+
*/
|
|
356
|
+
setSqlQuery(query: string): Promise<void>;
|
|
357
|
+
/**
|
|
358
|
+
* Set an option on the statement.
|
|
359
|
+
*
|
|
360
|
+
* @param key The option name (e.g., "adbc.ingest.target_table").
|
|
361
|
+
* @param value The option value.
|
|
362
|
+
*/
|
|
363
|
+
setOption(key: string, value: string): void;
|
|
364
|
+
/**
|
|
365
|
+
* Execute the query and return a stream of results.
|
|
366
|
+
*
|
|
367
|
+
* @returns A Promise resolving to an Apache Arrow RecordBatchReader.
|
|
368
|
+
* The reader must be consumed or closed to release resources.
|
|
369
|
+
*/
|
|
370
|
+
executeQuery(): Promise<RecordBatchReader>;
|
|
371
|
+
/**
|
|
372
|
+
* Execute an update command (e.g., INSERT, UPDATE, DELETE) that returns no data.
|
|
373
|
+
*
|
|
374
|
+
* @returns A Promise resolving to the number of rows affected (if known), or -1.
|
|
375
|
+
*/
|
|
376
|
+
executeUpdate(): Promise<number>;
|
|
377
|
+
/**
|
|
378
|
+
* Bind parameters or data for ingestion.
|
|
379
|
+
*
|
|
380
|
+
* This is used for bulk ingestion or parameterized queries.
|
|
381
|
+
*
|
|
382
|
+
* @param data Arrow Table containing the data to bind.
|
|
383
|
+
*/
|
|
384
|
+
bind(data: Table): Promise<void>;
|
|
385
|
+
/**
|
|
386
|
+
* Bind a stream of data for ingestion or parameterized queries.
|
|
387
|
+
*
|
|
388
|
+
* Streams batches one at a time to the driver, avoiding full
|
|
389
|
+
* materialization of the reader in memory.
|
|
390
|
+
*
|
|
391
|
+
* @param reader Arrow RecordBatchReader to bind.
|
|
392
|
+
*/
|
|
393
|
+
bindStream(reader: RecordBatchReader): Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* Close the statement and release resources.
|
|
396
|
+
*/
|
|
397
|
+
close(): Promise<void>;
|
|
398
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
/**
|
|
18
|
+
* Bitmask flags controlling how the driver manager resolves a driver name.
|
|
19
|
+
*
|
|
20
|
+
* These values correspond to the `ADBC_LOAD_FLAG_*` constants in the ADBC spec.
|
|
21
|
+
* Flags can be combined with bitwise OR. When `loadFlags` is omitted in
|
|
22
|
+
* `ConnectOptions`, `LoadFlags.Default` is used.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Only search system paths, disallow relative paths
|
|
26
|
+
* const db = new AdbcDatabase({
|
|
27
|
+
* driver: 'sqlite',
|
|
28
|
+
* loadFlags: LoadFlags.SearchSystem,
|
|
29
|
+
* })
|
|
30
|
+
*/
|
|
31
|
+
export const LoadFlags = {
|
|
32
|
+
/** Search directory paths in the `ADBC_DRIVER_PATH` environment variable (and the conda environment, if installed via conda). */
|
|
33
|
+
SearchEnv: 1 << 1,
|
|
34
|
+
/** Search the user configuration directory. */
|
|
35
|
+
SearchUser: 1 << 2,
|
|
36
|
+
/** Search the system configuration directory. */
|
|
37
|
+
SearchSystem: 1 << 3,
|
|
38
|
+
/** Allow a relative path to be provided as the driver name. */
|
|
39
|
+
AllowRelativePaths: 1 << 4,
|
|
40
|
+
/** All defined flags enabled. This is the default when `loadFlags` is omitted. */
|
|
41
|
+
Default: (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4),
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Depth values for the `getObjects` metadata call.
|
|
45
|
+
*
|
|
46
|
+
* These correspond to the `ADBC_OBJECT_DEPTH_*` constants in the ADBC spec.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Retrieve catalogs and schemas only
|
|
50
|
+
* await conn.getObjects({ depth: ObjectDepth.Schemas })
|
|
51
|
+
*/
|
|
52
|
+
export const ObjectDepth = {
|
|
53
|
+
/** Catalogs, schemas, tables, and columns (default). */
|
|
54
|
+
All: 0,
|
|
55
|
+
/** Catalogs only. */
|
|
56
|
+
Catalogs: 1,
|
|
57
|
+
/** Catalogs and schemas. */
|
|
58
|
+
Schemas: 2,
|
|
59
|
+
/** Catalogs, schemas, and tables. */
|
|
60
|
+
Tables: 3,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Info codes for the `getInfo` metadata call.
|
|
64
|
+
*
|
|
65
|
+
* These correspond to the `ADBC_INFO_*` constants in the ADBC spec.
|
|
66
|
+
* Pass a subset to `getInfo()` to retrieve only specific metadata fields.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const table = await conn.getInfo([InfoCode.VendorName, InfoCode.DriverVersion])
|
|
70
|
+
*/
|
|
71
|
+
export const InfoCode = {
|
|
72
|
+
/** The database vendor/product name (string). */
|
|
73
|
+
VendorName: 0,
|
|
74
|
+
/** The database vendor/product version (string). */
|
|
75
|
+
VendorVersion: 1,
|
|
76
|
+
/** The Arrow library version used by the vendor (string). */
|
|
77
|
+
VendorArrowVersion: 2,
|
|
78
|
+
/** Whether the vendor supports SQL queries (bool). */
|
|
79
|
+
VendorSql: 3,
|
|
80
|
+
/** Whether the vendor supports Substrait queries (bool). */
|
|
81
|
+
VendorSubstrait: 4,
|
|
82
|
+
/** Minimum supported Substrait version, or null (string). */
|
|
83
|
+
VendorSubstraitMinVersion: 5,
|
|
84
|
+
/** Maximum supported Substrait version, or null (string). */
|
|
85
|
+
VendorSubstraitMaxVersion: 6,
|
|
86
|
+
/** The driver name (string). */
|
|
87
|
+
DriverName: 100,
|
|
88
|
+
/** The driver version (string). */
|
|
89
|
+
DriverVersion: 101,
|
|
90
|
+
/** The Arrow library version used by the driver (string). */
|
|
91
|
+
DriverArrowVersion: 102,
|
|
92
|
+
/** The ADBC API version implemented by the driver (int64). Available since ADBC 1.1.0. */
|
|
93
|
+
DriverAdbcVersion: 103,
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Ingestion modes for the `ingest` convenience method.
|
|
97
|
+
*
|
|
98
|
+
* These correspond to the `adbc.ingest.mode.*` option values in the ADBC spec.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* await conn.ingest('my_table', data, { mode: IngestMode.Append })
|
|
102
|
+
*/
|
|
103
|
+
export const IngestMode = {
|
|
104
|
+
/** Append to an existing table. Fails if the table does not exist. */
|
|
105
|
+
Append: 'adbc.ingest.mode.append',
|
|
106
|
+
/** Create a new table and insert. Fails if the table already exists. */
|
|
107
|
+
Create: 'adbc.ingest.mode.create',
|
|
108
|
+
/** Create the table if it does not exist, then append. */
|
|
109
|
+
CreateAppend: 'adbc.ingest.mode.create_append',
|
|
110
|
+
/** Drop the existing table (if any) and recreate it, then insert. */
|
|
111
|
+
Replace: 'adbc.ingest.mode.replace',
|
|
112
|
+
};
|
package/license.hbs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
--}}
|
|
19
|
+
{{#each licenses}}{{#if first_of_kind}}
|
|
20
|
+
--------------------------------------------------------------------------------
|
|
21
|
+
{{#if (eq id "Apache-2.0")}}
|
|
22
|
+
The following crates are used under the Apache License 2.0 (see above):
|
|
23
|
+
{{else}}
|
|
24
|
+
{{name}} ({{id}})
|
|
25
|
+
|
|
26
|
+
The following crates are used under this license:
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#each used_by}} {{crate.name}} {{crate.version}}{{#if crate.repository}} ({{crate.repository}}){{/if}}
|
|
29
|
+
{{/each}}
|
|
30
|
+
{{#unless (eq id "Apache-2.0")}}
|
|
31
|
+
{{{text}}}
|
|
32
|
+
{{/unless~}}
|
|
33
|
+
{{/if}}{{/each}}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apache-arrow/adbc-driver-manager",
|
|
3
|
+
"version": "0.23.0",
|
|
4
|
+
"description": "Node.js ADBC Driver Manager",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/apache/arrow-adbc.git",
|
|
10
|
+
"directory": "javascript"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"adbc",
|
|
16
|
+
"arrow",
|
|
17
|
+
"database",
|
|
18
|
+
"arrow-adbc"
|
|
19
|
+
],
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"binding.d.ts",
|
|
23
|
+
"binding.js"
|
|
24
|
+
],
|
|
25
|
+
"napi": {
|
|
26
|
+
"binaryName": "adbc-driver-manager",
|
|
27
|
+
"targets": [
|
|
28
|
+
"x86_64-pc-windows-msvc",
|
|
29
|
+
"x86_64-apple-darwin",
|
|
30
|
+
"x86_64-unknown-linux-gnu",
|
|
31
|
+
"aarch64-unknown-linux-gnu",
|
|
32
|
+
"aarch64-apple-darwin"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22.0.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"artifacts": "napi artifacts",
|
|
40
|
+
"build": "napi build --platform --release --esm && mv index.js binding.js && mv index.d.ts binding.d.ts && tsc",
|
|
41
|
+
"build:ci": "napi build --platform --release --esm --js binding.js --dts binding.d.ts",
|
|
42
|
+
"build:debug": "napi build --platform --esm && mv index.js binding.js && mv index.d.ts binding.d.ts && tsc",
|
|
43
|
+
"build:ts": "tsc",
|
|
44
|
+
"build:driver": "../ci/scripts/node_build.sh $(pwd)/build",
|
|
45
|
+
"fix": "prettier . -w && oxlint . --fix",
|
|
46
|
+
"check": "npm run check:js && npm run check:rust",
|
|
47
|
+
"check:js": "prettier --check . && oxlint . && tsc --noEmit",
|
|
48
|
+
"check:rust": "cargo fmt -- --check && cargo clippy -- -D warnings",
|
|
49
|
+
"test": "tsx --test __test__/*.spec.ts",
|
|
50
|
+
"preversion": "napi build --platform --esm && git add .",
|
|
51
|
+
"version": "napi version",
|
|
52
|
+
"prepare": "husky"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@napi-rs/cli": "^3.2.0",
|
|
56
|
+
"@taplo/cli": "^0.7.0",
|
|
57
|
+
"tsx": "^4.0.0",
|
|
58
|
+
"husky": "^9.1.7",
|
|
59
|
+
"lint-staged": "^16.1.6",
|
|
60
|
+
"oxlint": "^1.14.0",
|
|
61
|
+
"prettier": "^3.6.2",
|
|
62
|
+
"typescript": "^5.9.2"
|
|
63
|
+
},
|
|
64
|
+
"lint-staged": {
|
|
65
|
+
"*.@(js|ts|tsx)": [
|
|
66
|
+
"oxlint --fix"
|
|
67
|
+
],
|
|
68
|
+
"*.@(js|ts|tsx|yml|yaml|md|json)": [
|
|
69
|
+
"prettier --write"
|
|
70
|
+
],
|
|
71
|
+
"*.toml": [
|
|
72
|
+
"taplo format"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"prettier": {
|
|
76
|
+
"printWidth": 120,
|
|
77
|
+
"semi": false,
|
|
78
|
+
"trailingComma": "all",
|
|
79
|
+
"singleQuote": true,
|
|
80
|
+
"arrowParens": "always"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"apache-arrow": "^21.1.0"
|
|
84
|
+
},
|
|
85
|
+
"optionalDependencies": {
|
|
86
|
+
"@apache-arrow/adbc-driver-manager-win32-x64-msvc": "0.23.0",
|
|
87
|
+
"@apache-arrow/adbc-driver-manager-darwin-x64": "0.23.0",
|
|
88
|
+
"@apache-arrow/adbc-driver-manager-linux-x64-gnu": "0.23.0",
|
|
89
|
+
"@apache-arrow/adbc-driver-manager-linux-arm64-gnu": "0.23.0",
|
|
90
|
+
"@apache-arrow/adbc-driver-manager-darwin-arm64": "0.23.0"
|
|
91
|
+
}
|
|
92
|
+
}
|