tempest-db-js 0.7.0 → 0.8.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/dist/index.d.cts CHANGED
@@ -1346,6 +1346,39 @@ declare class NodeSqliteDriver implements SyncDriver {
1346
1346
  iterate(sql: string, params: readonly unknown[]): IterableIterator<Record<string, unknown>>;
1347
1347
  close(): void;
1348
1348
  }
1349
+ /**
1350
+ * SQLite driver backed by the `better-sqlite3` peer dependency.
1351
+ *
1352
+ * Selected with `{ driver: "better-sqlite3" }` or the URL suffix
1353
+ * `sqlite+better-sqlite3://…`; the built-in `node:sqlite` stays the default, so
1354
+ * nothing has to be installed to use SQLite. Pick this one when the service
1355
+ * already runs on better-sqlite3, or needs what it exposes and `node:sqlite`
1356
+ * does not — `pragma()`, loadable extensions, its own WAL helpers.
1357
+ *
1358
+ * Row shape matches {@link NodeSqliteDriver}: plain objects, BLOBs as `Buffer`
1359
+ * (a `Uint8Array` subclass), which is what `coerceRow` already expects.
1360
+ */
1361
+ declare class BetterSqliteDriver implements SyncDriver {
1362
+ private readonly db;
1363
+ /** Prepared-statement cache keyed by SQL text — see {@link NodeSqliteDriver}. */
1364
+ private readonly statements;
1365
+ constructor(database: any);
1366
+ /**
1367
+ * Open a `better-sqlite3` database at the given path (or `":memory:"`).
1368
+ *
1369
+ * @param path The database file, or `":memory:"`.
1370
+ * @param options Passed straight to `new Database()` (`readonly`, `timeout`, …).
1371
+ * @returns A driver over the open handle.
1372
+ * @throws If `better-sqlite3` is not installed — it is an optional peer
1373
+ * dependency, so the error names the package to install.
1374
+ */
1375
+ static open(path: string, options?: Readonly<Record<string, unknown>>): BetterSqliteDriver;
1376
+ /** Return the cached prepared statement for `sql`, preparing it on first use. */
1377
+ private prepare;
1378
+ execute(sql: string, params: readonly unknown[]): DriverResult;
1379
+ iterate(sql: string, params: readonly unknown[]): IterableIterator<Record<string, unknown>>;
1380
+ close(): void;
1381
+ }
1349
1382
  type AnySelect = SelectBuilder<any, any, any>;
1350
1383
  type AnyInsert = InsertBuilder<any, any, any>;
1351
1384
  type GuardedUpdate = UpdateBuilder<any, true, any>;
@@ -1565,7 +1598,22 @@ interface PoolOptions {
1565
1598
  type NoticeLogger = (notice: Record<string, unknown>) => void;
1566
1599
  /** Options shared by both engine flavors. */
1567
1600
  interface EngineOptions {
1568
- /** Override the driver detected from the URL (e.g. `"better-sqlite3"`). */
1601
+ /**
1602
+ * Override the driver detected from the URL.
1603
+ *
1604
+ * SQLite ships two: `"node:sqlite"` (the built-in, default — nothing to
1605
+ * install) and `"better-sqlite3"` (the optional peer dependency). PostgreSQL
1606
+ * runs on `"postgres"` (postgres.js) and MySQL on `"mysql2"`; naming those is
1607
+ * a no-op today, kept so the option means the same thing everywhere.
1608
+ *
1609
+ * A name this dialect does not have throws — passing `{ driver: "sqlite3" }`
1610
+ * is a decision that would otherwise be silently ignored.
1611
+ *
1612
+ * The `+suffix` in the URL (`sqlite+better-sqlite3:///app.db`) selects the same
1613
+ * way, with one difference: a suffix naming a driver from another ecosystem
1614
+ * (`sqlite+aiosqlite`, `postgresql+asyncpg`) is ignored rather than rejected,
1615
+ * so a URL copied from a Python service still connects.
1616
+ */
1569
1617
  readonly driver?: string;
1570
1618
  /** Connection-pool tuning (PostgreSQL only). */
1571
1619
  readonly pool?: PoolOptions;
@@ -2396,4 +2444,4 @@ type InferInsert<C extends ModelClass> = Simplify<{
2396
2444
  [K in Exclude<ColumnKeys<InstanceType<C>>, OptionalInsertKeys<InstanceType<C>>>]: ColValue<InstanceType<C>[K]>;
2397
2445
  }>;
2398
2446
 
2399
- export { ActiveRecord, type ActiveRecordManager, Agg, type AggregateTerm, type AsyncDriver, AsyncEngine, AsyncResult, AsyncSession, BaseDialect, BaseRepository, type BelongsTo, type ColRef, type ColType, Column, type ColumnFlags, type ColumnType, type ColumnTypeKind, type ColumnTypeMeta, type CompiledQuery, type CondNode, type Condition, type DefaultValue, DeleteBuilder, type DeleteNode, type Dialect, type DriverResult, type EngineOptions, type Executable, type ExprNode, Expression, type FkAction, type ForeignKeyOptions, type ForeignKeyRef, type HasMany, type InferInsert, type InferModel, InsertBuilder, type InsertNode, InvalidDatabaseUrl, JoinBuilder, type JoinClause, type JoinNode, type JoinOn, type JoinSelection, type JoinWhereInput, type LockClause, type LockOptions, Model, type ModelClass, MysqlDialect, type NameMap, type NamingStrategy, NoResultError, NodeSqliteDriver, type NoticeLogger, OPERATORS, type OnConflict, type OnConflictOptions, type OnConflictUpdateOptions, type Operator, type OperatorsFor, type OrderTerm, type PaginationFilter, type PaginationResult, Params, type ParsedDatabaseUrl, type PoolOptions, type PortableExpression, PostgresDialect, QueryExecutionError, type QueryLogger, type QueryNode, RecordNotFound, type Relation, type RelationValue, type ReservedAsyncDriver, type Returning, type RowOf, SelectBuilder, type SelectNode, type SortDirection, type Sources, type SqlExpression, SqliteDialect, type Subquery, type SyncDriver, SyncEngine, SyncResult, SyncSession, type TableConstraint, UpdateBuilder, type UpdateNode, ValidationError, type WhereArg, type WhereInput, type WithRelations, type WritePatch, type WriteValues, activeRecord, and, avg, belongsTo, col, column, columnNamesOf, columnPropsOf, columnsOf, count, createEngine, createSyncEngine, dbColumn, del, detectDialect, fn, foreignKey, fromDict, getDialect, hasMany, insert, isCondition, isExpression, isSqlExpression, isSubquery, join, loadRelations, max, min, not, or, parse, parseDatabaseUrl, select, sql, stringify, sum, toAsyncDriver, toCondNode, toDict, toJSON, toSnakeCase, unique, update, val };
2447
+ export { ActiveRecord, type ActiveRecordManager, Agg, type AggregateTerm, type AsyncDriver, AsyncEngine, AsyncResult, AsyncSession, BaseDialect, BaseRepository, type BelongsTo, BetterSqliteDriver, type ColRef, type ColType, Column, type ColumnFlags, type ColumnType, type ColumnTypeKind, type ColumnTypeMeta, type CompiledQuery, type CondNode, type Condition, type DefaultValue, DeleteBuilder, type DeleteNode, type Dialect, type DriverResult, type EngineOptions, type Executable, type ExprNode, Expression, type FkAction, type ForeignKeyOptions, type ForeignKeyRef, type HasMany, type InferInsert, type InferModel, InsertBuilder, type InsertNode, InvalidDatabaseUrl, JoinBuilder, type JoinClause, type JoinNode, type JoinOn, type JoinSelection, type JoinWhereInput, type LockClause, type LockOptions, Model, type ModelClass, MysqlDialect, type NameMap, type NamingStrategy, NoResultError, NodeSqliteDriver, type NoticeLogger, OPERATORS, type OnConflict, type OnConflictOptions, type OnConflictUpdateOptions, type Operator, type OperatorsFor, type OrderTerm, type PaginationFilter, type PaginationResult, Params, type ParsedDatabaseUrl, type PoolOptions, type PortableExpression, PostgresDialect, QueryExecutionError, type QueryLogger, type QueryNode, RecordNotFound, type Relation, type RelationValue, type ReservedAsyncDriver, type Returning, type RowOf, SelectBuilder, type SelectNode, type SortDirection, type Sources, type SqlExpression, SqliteDialect, type Subquery, type SyncDriver, SyncEngine, SyncResult, SyncSession, type TableConstraint, UpdateBuilder, type UpdateNode, ValidationError, type WhereArg, type WhereInput, type WithRelations, type WritePatch, type WriteValues, activeRecord, and, avg, belongsTo, col, column, columnNamesOf, columnPropsOf, columnsOf, count, createEngine, createSyncEngine, dbColumn, del, detectDialect, fn, foreignKey, fromDict, getDialect, hasMany, insert, isCondition, isExpression, isSqlExpression, isSubquery, join, loadRelations, max, min, not, or, parse, parseDatabaseUrl, select, sql, stringify, sum, toAsyncDriver, toCondNode, toDict, toJSON, toSnakeCase, unique, update, val };
package/dist/index.d.ts CHANGED
@@ -1346,6 +1346,39 @@ declare class NodeSqliteDriver implements SyncDriver {
1346
1346
  iterate(sql: string, params: readonly unknown[]): IterableIterator<Record<string, unknown>>;
1347
1347
  close(): void;
1348
1348
  }
1349
+ /**
1350
+ * SQLite driver backed by the `better-sqlite3` peer dependency.
1351
+ *
1352
+ * Selected with `{ driver: "better-sqlite3" }` or the URL suffix
1353
+ * `sqlite+better-sqlite3://…`; the built-in `node:sqlite` stays the default, so
1354
+ * nothing has to be installed to use SQLite. Pick this one when the service
1355
+ * already runs on better-sqlite3, or needs what it exposes and `node:sqlite`
1356
+ * does not — `pragma()`, loadable extensions, its own WAL helpers.
1357
+ *
1358
+ * Row shape matches {@link NodeSqliteDriver}: plain objects, BLOBs as `Buffer`
1359
+ * (a `Uint8Array` subclass), which is what `coerceRow` already expects.
1360
+ */
1361
+ declare class BetterSqliteDriver implements SyncDriver {
1362
+ private readonly db;
1363
+ /** Prepared-statement cache keyed by SQL text — see {@link NodeSqliteDriver}. */
1364
+ private readonly statements;
1365
+ constructor(database: any);
1366
+ /**
1367
+ * Open a `better-sqlite3` database at the given path (or `":memory:"`).
1368
+ *
1369
+ * @param path The database file, or `":memory:"`.
1370
+ * @param options Passed straight to `new Database()` (`readonly`, `timeout`, …).
1371
+ * @returns A driver over the open handle.
1372
+ * @throws If `better-sqlite3` is not installed — it is an optional peer
1373
+ * dependency, so the error names the package to install.
1374
+ */
1375
+ static open(path: string, options?: Readonly<Record<string, unknown>>): BetterSqliteDriver;
1376
+ /** Return the cached prepared statement for `sql`, preparing it on first use. */
1377
+ private prepare;
1378
+ execute(sql: string, params: readonly unknown[]): DriverResult;
1379
+ iterate(sql: string, params: readonly unknown[]): IterableIterator<Record<string, unknown>>;
1380
+ close(): void;
1381
+ }
1349
1382
  type AnySelect = SelectBuilder<any, any, any>;
1350
1383
  type AnyInsert = InsertBuilder<any, any, any>;
1351
1384
  type GuardedUpdate = UpdateBuilder<any, true, any>;
@@ -1565,7 +1598,22 @@ interface PoolOptions {
1565
1598
  type NoticeLogger = (notice: Record<string, unknown>) => void;
1566
1599
  /** Options shared by both engine flavors. */
1567
1600
  interface EngineOptions {
1568
- /** Override the driver detected from the URL (e.g. `"better-sqlite3"`). */
1601
+ /**
1602
+ * Override the driver detected from the URL.
1603
+ *
1604
+ * SQLite ships two: `"node:sqlite"` (the built-in, default — nothing to
1605
+ * install) and `"better-sqlite3"` (the optional peer dependency). PostgreSQL
1606
+ * runs on `"postgres"` (postgres.js) and MySQL on `"mysql2"`; naming those is
1607
+ * a no-op today, kept so the option means the same thing everywhere.
1608
+ *
1609
+ * A name this dialect does not have throws — passing `{ driver: "sqlite3" }`
1610
+ * is a decision that would otherwise be silently ignored.
1611
+ *
1612
+ * The `+suffix` in the URL (`sqlite+better-sqlite3:///app.db`) selects the same
1613
+ * way, with one difference: a suffix naming a driver from another ecosystem
1614
+ * (`sqlite+aiosqlite`, `postgresql+asyncpg`) is ignored rather than rejected,
1615
+ * so a URL copied from a Python service still connects.
1616
+ */
1569
1617
  readonly driver?: string;
1570
1618
  /** Connection-pool tuning (PostgreSQL only). */
1571
1619
  readonly pool?: PoolOptions;
@@ -2396,4 +2444,4 @@ type InferInsert<C extends ModelClass> = Simplify<{
2396
2444
  [K in Exclude<ColumnKeys<InstanceType<C>>, OptionalInsertKeys<InstanceType<C>>>]: ColValue<InstanceType<C>[K]>;
2397
2445
  }>;
2398
2446
 
2399
- export { ActiveRecord, type ActiveRecordManager, Agg, type AggregateTerm, type AsyncDriver, AsyncEngine, AsyncResult, AsyncSession, BaseDialect, BaseRepository, type BelongsTo, type ColRef, type ColType, Column, type ColumnFlags, type ColumnType, type ColumnTypeKind, type ColumnTypeMeta, type CompiledQuery, type CondNode, type Condition, type DefaultValue, DeleteBuilder, type DeleteNode, type Dialect, type DriverResult, type EngineOptions, type Executable, type ExprNode, Expression, type FkAction, type ForeignKeyOptions, type ForeignKeyRef, type HasMany, type InferInsert, type InferModel, InsertBuilder, type InsertNode, InvalidDatabaseUrl, JoinBuilder, type JoinClause, type JoinNode, type JoinOn, type JoinSelection, type JoinWhereInput, type LockClause, type LockOptions, Model, type ModelClass, MysqlDialect, type NameMap, type NamingStrategy, NoResultError, NodeSqliteDriver, type NoticeLogger, OPERATORS, type OnConflict, type OnConflictOptions, type OnConflictUpdateOptions, type Operator, type OperatorsFor, type OrderTerm, type PaginationFilter, type PaginationResult, Params, type ParsedDatabaseUrl, type PoolOptions, type PortableExpression, PostgresDialect, QueryExecutionError, type QueryLogger, type QueryNode, RecordNotFound, type Relation, type RelationValue, type ReservedAsyncDriver, type Returning, type RowOf, SelectBuilder, type SelectNode, type SortDirection, type Sources, type SqlExpression, SqliteDialect, type Subquery, type SyncDriver, SyncEngine, SyncResult, SyncSession, type TableConstraint, UpdateBuilder, type UpdateNode, ValidationError, type WhereArg, type WhereInput, type WithRelations, type WritePatch, type WriteValues, activeRecord, and, avg, belongsTo, col, column, columnNamesOf, columnPropsOf, columnsOf, count, createEngine, createSyncEngine, dbColumn, del, detectDialect, fn, foreignKey, fromDict, getDialect, hasMany, insert, isCondition, isExpression, isSqlExpression, isSubquery, join, loadRelations, max, min, not, or, parse, parseDatabaseUrl, select, sql, stringify, sum, toAsyncDriver, toCondNode, toDict, toJSON, toSnakeCase, unique, update, val };
2447
+ export { ActiveRecord, type ActiveRecordManager, Agg, type AggregateTerm, type AsyncDriver, AsyncEngine, AsyncResult, AsyncSession, BaseDialect, BaseRepository, type BelongsTo, BetterSqliteDriver, type ColRef, type ColType, Column, type ColumnFlags, type ColumnType, type ColumnTypeKind, type ColumnTypeMeta, type CompiledQuery, type CondNode, type Condition, type DefaultValue, DeleteBuilder, type DeleteNode, type Dialect, type DriverResult, type EngineOptions, type Executable, type ExprNode, Expression, type FkAction, type ForeignKeyOptions, type ForeignKeyRef, type HasMany, type InferInsert, type InferModel, InsertBuilder, type InsertNode, InvalidDatabaseUrl, JoinBuilder, type JoinClause, type JoinNode, type JoinOn, type JoinSelection, type JoinWhereInput, type LockClause, type LockOptions, Model, type ModelClass, MysqlDialect, type NameMap, type NamingStrategy, NoResultError, NodeSqliteDriver, type NoticeLogger, OPERATORS, type OnConflict, type OnConflictOptions, type OnConflictUpdateOptions, type Operator, type OperatorsFor, type OrderTerm, type PaginationFilter, type PaginationResult, Params, type ParsedDatabaseUrl, type PoolOptions, type PortableExpression, PostgresDialect, QueryExecutionError, type QueryLogger, type QueryNode, RecordNotFound, type Relation, type RelationValue, type ReservedAsyncDriver, type Returning, type RowOf, SelectBuilder, type SelectNode, type SortDirection, type Sources, type SqlExpression, SqliteDialect, type Subquery, type SyncDriver, SyncEngine, SyncResult, SyncSession, type TableConstraint, UpdateBuilder, type UpdateNode, ValidationError, type WhereArg, type WhereInput, type WithRelations, type WritePatch, type WriteValues, activeRecord, and, avg, belongsTo, col, column, columnNamesOf, columnPropsOf, columnsOf, count, createEngine, createSyncEngine, dbColumn, del, detectDialect, fn, foreignKey, fromDict, getDialect, hasMany, insert, isCondition, isExpression, isSqlExpression, isSubquery, join, loadRelations, max, min, not, or, parse, parseDatabaseUrl, select, sql, stringify, sum, toAsyncDriver, toCondNode, toDict, toJSON, toSnakeCase, unique, update, val };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ActiveRecord, Agg, AsyncEngine, AsyncResult, AsyncSession, BaseDialect, BaseRepository, Column, DeleteBuilder, Expression, InsertBuilder, InvalidDatabaseUrl, JoinBuilder, Model, MysqlDialect, NoResultError, NodeSqliteDriver, OPERATORS, Params, PostgresDialect, QueryExecutionError, RecordNotFound, SelectBuilder, SqliteDialect, SyncEngine, SyncResult, SyncSession, UpdateBuilder, ValidationError, activeRecord, and, avg, belongsTo, col, column, columnNamesOf, columnPropsOf, columnsOf, count, createEngine, createSyncEngine, dbColumn, del, detectDialect, fn, foreignKey, fromDict, getDialect, hasMany, insert, isCondition, isExpression, isSqlExpression, isSubquery, join, loadRelations, max, min, not, or, parse, parseDatabaseUrl, select, sql, stringify, sum, toAsyncDriver, toCondNode, toDict, toJSON, toSnakeCase, unique, update, val } from './chunk-4AWUP7BM.js';
1
+ export { ActiveRecord, Agg, AsyncEngine, AsyncResult, AsyncSession, BaseDialect, BaseRepository, BetterSqliteDriver, Column, DeleteBuilder, Expression, InsertBuilder, InvalidDatabaseUrl, JoinBuilder, Model, MysqlDialect, NoResultError, NodeSqliteDriver, OPERATORS, Params, PostgresDialect, QueryExecutionError, RecordNotFound, SelectBuilder, SqliteDialect, SyncEngine, SyncResult, SyncSession, UpdateBuilder, ValidationError, activeRecord, and, avg, belongsTo, col, column, columnNamesOf, columnPropsOf, columnsOf, count, createEngine, createSyncEngine, dbColumn, del, detectDialect, fn, foreignKey, fromDict, getDialect, hasMany, insert, isCondition, isExpression, isSqlExpression, isSubquery, join, loadRelations, max, min, not, or, parse, parseDatabaseUrl, select, sql, stringify, sum, toAsyncDriver, toCondNode, toDict, toJSON, toSnakeCase, unique, update, val } from './chunk-NH6K5LTX.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map