Skip to content

Commit 260fca0

Browse files
committed
fix(driver-turso): narrow every override's options from any to DriverOptions (#6402)
1 parent 61282f9 commit 260fca0

1 file changed

Lines changed: 32 additions & 22 deletions

File tree

‎packages/drivers/driver-turso/src/turso-driver.ts‎

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import { SqlDriver, type SqlDriverConfig } from '@objectstack/driver-sql';
2323
import type { DriverQuery } from '@objectstack/spec/contracts';
24+
import type { DriverOptions } from '@objectstack/spec/data';
2425
import type { Client } from '@libsql/client';
2526
import { RemoteTransport } from './remote-transport.js';
2627
import {
@@ -503,13 +504,23 @@ export class TursoDriver extends SqlDriver {
503504
// ===================================
504505
// CRUD (remote mode overrides)
505506
// ===================================
506-
507-
override async find(object: string, query: DriverQuery, options?: any): Promise<any[]> {
507+
//
508+
// [#6402] Every `options` parameter in this file is a {@link DriverOptions},
509+
// matching `SqlDriver` / `IDataDriver` — the two faces of one driver may not
510+
// declare one argument two ways. This was the last `any` axis left in the
511+
// overrides: #5181 (PR #6076), #6075 (PR #6210) and #6212 each narrowed
512+
// `query`, and each deliberately left `options` alone because it is a
513+
// SEPARATE axis whose shape was verbatim-identical across all 17 overrides —
514+
// narrowing one would have read as a verdict on the other sixteen. #6402
515+
// closed all 17 in one sweep, so there is no half-narrowed state to
516+
// interpret. Keep it that way: a new override here declares `DriverOptions`.
517+
518+
override async find(object: string, query: DriverQuery, options?: DriverOptions): Promise<any[]> {
508519
if (this.isRemote) return this.formatRemoteRows(object, await this.remoteTransport!.find(object, this.toRemoteReadQuery(object, query)));
509520
return super.find(object, query, options);
510521
}
511522

512-
override async findOne(object: string, query: DriverQuery, options?: any): Promise<any> {
523+
override async findOne(object: string, query: DriverQuery, options?: DriverOptions): Promise<any> {
513524
if (this.isRemote) return this.formatRemoteRow(object, await this.remoteTransport!.findOne(object, this.toRemoteReadQuery(object, query, { singleRowLookup: true })));
514525
return super.findOne(object, query, options);
515526
}
@@ -520,27 +531,27 @@ export class TursoDriver extends SqlDriver {
520531
// yielding — the opposite of the memory guarantee it was declared for. This
521532
// override went with the base method; page `find()` with `limit`/`offset`.
522533

523-
override async create(object: string, data: Record<string, any>, options?: any): Promise<any> {
534+
override async create(object: string, data: Record<string, any>, options?: DriverOptions): Promise<any> {
524535
if (this.isRemote) return this.formatRemoteRow(object, await this.remoteTransport!.create(object, this.toRemoteWriteForms(object, data)));
525536
return super.create(object, data, options);
526537
}
527538

528-
override async update(object: string, id: string | number, data: Record<string, any>, options?: any): Promise<any> {
539+
override async update(object: string, id: string | number, data: Record<string, any>, options?: DriverOptions): Promise<any> {
529540
if (this.isRemote) return this.formatRemoteRow(object, await this.remoteTransport!.update(object, id, this.toRemoteWriteForms(object, data)));
530541
return super.update(object, id, data, options);
531542
}
532543

533-
override async upsert(object: string, data: Record<string, any>, conflictKeys?: string[], options?: any): Promise<Record<string, any>> {
544+
override async upsert(object: string, data: Record<string, any>, conflictKeys?: string[], options?: DriverOptions): Promise<Record<string, any>> {
534545
if (this.isRemote) return this.formatRemoteRow(object, await this.remoteTransport!.upsert(object, this.toRemoteWriteForms(object, data), conflictKeys));
535546
return super.upsert(object, data, conflictKeys, options);
536547
}
537548

538-
override async delete(object: string, id: string | number, options?: any): Promise<boolean> {
549+
override async delete(object: string, id: string | number, options?: DriverOptions): Promise<boolean> {
539550
if (this.isRemote) return this.remoteTransport!.delete(object, id);
540551
return super.delete(object, id, options);
541552
}
542553

543-
override async count(object: string, query?: DriverQuery, options?: any): Promise<number> {
554+
override async count(object: string, query?: DriverQuery, options?: DriverOptions): Promise<number> {
544555
if (this.isRemote) return this.remoteTransport!.count(object, this.toRemoteQuery(object, query));
545556
return super.count(object, query, options);
546557
}
@@ -550,12 +561,11 @@ export class TursoDriver extends SqlDriver {
550561
* `SqlDriver.aggregate` this forwards to — the two faces of one driver may not
551562
* declare one argument two ways.
552563
*
553-
* `options` is deliberately left `any`: it is a SECOND axis, shared verbatim
554-
* with the four overrides above it, and narrowing one of five mid-file would
555-
* read as a decision about the others. #6210 left the same `options?: any` on
556-
* `count` for the same reason.
564+
* [#6402] `options` is a {@link DriverOptions} for the same reason, closed as
565+
* one sweep across every override in this file rather than one method at a
566+
* time — see the block comment above `find()`.
557567
*/
558-
override async aggregate(object: string, query: DriverQuery, options?: any): Promise<any> {
568+
override async aggregate(object: string, query: DriverQuery, options?: DriverOptions): Promise<any> {
559569
if (this.isRemote) return this.remoteTransport!.aggregate(object, this.toRemoteQuery(object, query));
560570
return super.aggregate(object, query, options);
561571
}
@@ -957,15 +967,15 @@ export class TursoDriver extends SqlDriver {
957967
// Bulk Operations (remote mode overrides)
958968
// ===================================
959969

960-
override async bulkCreate(object: string, data: any[], options?: any): Promise<any> {
970+
override async bulkCreate(object: string, data: any[], options?: DriverOptions): Promise<any> {
961971
if (this.isRemote) {
962972
const formatted = Array.isArray(data) ? data.map((d) => this.toRemoteWriteForms(object, d)) : data;
963973
return this.formatRemoteRows(object, await this.remoteTransport!.bulkCreate(object, formatted));
964974
}
965975
return super.bulkCreate(object, data, options);
966976
}
967977

968-
override async bulkUpdate(object: string, updates: Array<{ id: string | number; data: Record<string, any> }>, options?: any): Promise<Record<string, any>[]> {
978+
override async bulkUpdate(object: string, updates: Array<{ id: string | number; data: Record<string, any> }>, options?: DriverOptions): Promise<Record<string, any>[]> {
969979
if (this.isRemote) {
970980
const formatted = Array.isArray(updates)
971981
? updates.map((u) => ({ ...u, data: this.toRemoteWriteForms(object, u.data) }))
@@ -975,19 +985,19 @@ export class TursoDriver extends SqlDriver {
975985
return super.bulkUpdate(object, updates, options);
976986
}
977987

978-
override async bulkDelete(object: string, ids: Array<string | number>, options?: any): Promise<void> {
988+
override async bulkDelete(object: string, ids: Array<string | number>, options?: DriverOptions): Promise<void> {
979989
if (this.isRemote) return this.remoteTransport!.bulkDelete(object, ids);
980990
return super.bulkDelete(object, ids, options);
981991
}
982992

983-
override async updateMany(object: string, query: DriverQuery, data: any, options?: any): Promise<number> {
993+
override async updateMany(object: string, query: DriverQuery, data: any, options?: DriverOptions): Promise<number> {
984994
if (this.isRemote) {
985995
return this.remoteTransport!.updateMany(object, this.toRemoteQuery(object, query), this.toRemoteWriteForms(object, data));
986996
}
987997
return super.updateMany(object, query, data, options);
988998
}
989999

990-
override async deleteMany(object: string, query: DriverQuery, options?: any): Promise<number> {
1000+
override async deleteMany(object: string, query: DriverQuery, options?: DriverOptions): Promise<number> {
9911001
if (this.isRemote) return this.remoteTransport!.deleteMany(object, this.toRemoteQuery(object, query));
9921002
return super.deleteMany(object, query, options);
9931003
}
@@ -996,7 +1006,7 @@ export class TursoDriver extends SqlDriver {
9961006
// Raw Execution (remote mode override)
9971007
// ===================================
9981008

999-
override async execute(command: any, params?: any[], options?: any): Promise<any> {
1009+
override async execute(command: any, params?: any[], options?: DriverOptions): Promise<any> {
10001010
if (this.isRemote) return this.remoteTransport!.execute(command, params);
10011011
return super.execute(command, params, options);
10021012
}
@@ -1024,7 +1034,7 @@ export class TursoDriver extends SqlDriver {
10241034
// Schema Management (remote mode overrides)
10251035
// ===================================
10261036

1027-
override async syncSchema(object: string, schema: unknown, options?: any): Promise<void> {
1037+
override async syncSchema(object: string, schema: unknown, options?: DriverOptions): Promise<void> {
10281038
if (this.isRemote) {
10291039
await this.remoteTransport!.syncSchema(object, schema);
10301040
// See initObjects(): populate the read-coercion registries for remote mode.
@@ -1084,7 +1094,7 @@ export class TursoDriver extends SqlDriver {
10841094
* In local/replica mode, falls back to sequential `syncSchema()` calls
10851095
* (Knex + better-sqlite3 is already local, so batching has no benefit).
10861096
*/
1087-
async syncSchemasBatch(schemas: Array<{ object: string; schema: unknown }>, options?: any): Promise<void> {
1097+
async syncSchemasBatch(schemas: Array<{ object: string; schema: unknown }>, options?: DriverOptions): Promise<void> {
10881098
if (this.isRemote) {
10891099
return this.remoteTransport!.syncSchemasBatch(schemas);
10901100
}
@@ -1094,7 +1104,7 @@ export class TursoDriver extends SqlDriver {
10941104
}
10951105
}
10961106

1097-
override async dropTable(object: string, options?: any): Promise<void> {
1107+
override async dropTable(object: string, options?: DriverOptions): Promise<void> {
10981108
if (this.isRemote) return this.remoteTransport!.dropTable(object);
10991109
return super.dropTable(object, options);
11001110
}

0 commit comments

Comments
 (0)