diff --git a/src/clients/libsql.cjs b/src/clients/libsql.cjs index 19d6dca6..e20bb475 100644 --- a/src/clients/libsql.cjs +++ b/src/clients/libsql.cjs @@ -1,14 +1,15 @@ const Sqlite3Client = require('knex/lib/dialects/sqlite3') -class LibSQLClient extends Sqlite3Client { +module.exports = class LibSQLClient extends Sqlite3Client { _driver() { return require('@libsql/sqlite3') } -} -Object.assign(LibSQLClient.prototype, { - dialect: 'libsql', - driverName: 'libsql', -}) + get dialect() { + return 'libsql' + } -module.exports = LibSQLClient + get driverName() { + return 'libsql' + } +} diff --git a/src/connection/index.ts b/src/connection/index.ts index b999167d..37eee0f1 100644 --- a/src/connection/index.ts +++ b/src/connection/index.ts @@ -16,9 +16,8 @@ import type { Logger } from '@adonisjs/core/logger' import { resolveClientNameWithAliases } from 'knex/lib/util/helpers.js' import * as errors from '../errors.js' -import { clientsNames } from '../dialects/index.js' -// @ts-expect-error import LibSQLClient from '../clients/libsql.cjs' +import { clientsNames } from '../dialects/index.js' import { Logger as ConnectionLogger } from './logger.js' import type { ConnectionConfig, ConnectionContract } from '../types/database.js' @@ -156,7 +155,7 @@ export class Connection extends EventEmitter implements ConnectionContract { if (this.config.client === 'libsql') { return { ...this.config, - client: LibSQLClient, + client: LibSQLClient as any, } } diff --git a/test-helpers/index.ts b/test-helpers/index.ts index d586507e..0c3d7981 100644 --- a/test-helpers/index.ts +++ b/test-helpers/index.ts @@ -33,6 +33,7 @@ import { import { BaseSchema } from '../src/schema/main.js' import { Database } from '../src/database/main.js' +import LibSQLClient from '../src/clients/libsql.cjs' import { Adapter } from '../src/orm/adapter/index.js' import { BaseModel } from '../src/orm/base_model/index.js' import { QueryClient } from '../src/query_client/index.js' @@ -43,9 +44,6 @@ import { InsertQueryBuilder } from '../src/database/query_builder/insert.js' import { LucidRow, LucidModel, AdapterContract } from '../src/types/model.js' import { DatabaseQueryBuilder } from '../src/database/query_builder/database.js' -// @ts-expect-error -import LibSQLClient from '../src/clients/libsql.cjs' - dotenv.config() export const APP_ROOT = new URL('./tmp', import.meta.url) export const SQLITE_BASE_PATH = fileURLToPath(APP_ROOT) @@ -159,7 +157,7 @@ export function getKnex(config: knex.Knex.Config): knex.Knex { {}, { ...config, - client: config.client === 'libsql' ? LibSQLClient : config.client, + client: config.client === 'libsql' ? (LibSQLClient as any) : config.client, }, { debug: false } ) diff --git a/test-helpers/tmp/libsql.db b/test-helpers/tmp/libsql.db index 417f413b..dc35f57b 100644 Binary files a/test-helpers/tmp/libsql.db and b/test-helpers/tmp/libsql.db differ diff --git a/tsconfig.json b/tsconfig.json index ad0cc44a..e6fe66f2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "extends": "@adonisjs/tsconfig/tsconfig.package.json", "compilerOptions": { "rootDir": "./", - "outDir": "./build" + "outDir": "./build", + "allowJs": true } }