@mikro-orm/libsql 7.0.0-dev.76 → 7.0.0-dev.78

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.
@@ -2,7 +2,6 @@ import { BaseSqliteConnection, type Dictionary } from '@mikro-orm/knex';
2
2
  import { type Options } from 'libsql';
3
3
  import { LibSqlDialect } from './LibSqlDialect.js';
4
4
  export declare class LibSqlConnection extends BaseSqliteConnection {
5
- connect(): Promise<void>;
6
5
  private database;
7
6
  createKyselyDialect(options: Dictionary & Options): LibSqlDialect;
8
7
  loadFile(path: string): Promise<void>;
@@ -1,18 +1,8 @@
1
- import { BaseSqliteConnection, Utils } from '@mikro-orm/knex';
1
+ import { BaseSqliteConnection } from '@mikro-orm/knex';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import Database from 'libsql';
4
4
  import { LibSqlDialect } from './LibSqlDialect.js';
5
- import { dirname } from 'node:path';
6
- import { CompiledQuery } from 'kysely';
7
5
  export class LibSqlConnection extends BaseSqliteConnection {
8
- async connect() {
9
- await super.connect({ simple: true });
10
- const dbName = this.config.get('dbName');
11
- if (dbName && dbName !== ':memory:' && !dirname(dbName).startsWith('libsql:/')) {
12
- Utils.ensureDir(dirname(dbName));
13
- }
14
- await this.client.executeQuery(CompiledQuery.raw('pragma foreign_keys = on'));
15
- }
16
6
  database;
17
7
  createKyselyDialect(options) {
18
8
  const dbName = options.url ?? this.config.get('dbName');
@@ -24,7 +14,7 @@ export class LibSqlConnection extends BaseSqliteConnection {
24
14
  onCreateConnection: this.options.onCreateConnection ?? this.config.get('onCreateConnection'),
25
15
  });
26
16
  }
27
- /* v8 ignore next 4 */
17
+ /* v8 ignore next */
28
18
  async loadFile(path) {
29
19
  await this.ensureConnection();
30
20
  this.database.exec((await readFile(path)).toString());
package/LibSqlDialect.js CHANGED
@@ -36,7 +36,7 @@ class LibSqlConnection {
36
36
  };
37
37
  }
38
38
  const query = sql.trim().toLowerCase();
39
- /* v8 ignore next 5 */
39
+ /* v8 ignore next */
40
40
  if (query.startsWith('select') || ((query.startsWith('insert into') || query.startsWith('update ')) && query.includes(' returning '))) {
41
41
  return {
42
42
  rows: stmt.all(parameters),
@@ -49,10 +49,10 @@ class LibSqlConnection {
49
49
  rows: [],
50
50
  };
51
51
  }
52
- /* v8 ignore start */
53
52
  async *streamQuery(compiledQuery) {
54
53
  const { sql, parameters } = compiledQuery;
55
54
  const stmt = this.db.prepare(sql);
55
+ /* v8 ignore next */
56
56
  if (!sql.toLowerCase().startsWith('select')) {
57
57
  throw new Error('Sqlite driver only supports streaming of select queries');
58
58
  }
@@ -75,14 +75,14 @@ class LibSqlKyselyDriver extends SqliteDriver {
75
75
  async init() {
76
76
  this.db = await this.config.database();
77
77
  this.connection = new LibSqlConnection(this.db);
78
- /* v8 ignore next 3 */
78
+ /* v8 ignore next */
79
79
  if (this.config.onCreateConnection) {
80
80
  await this.config.onCreateConnection(this.connection);
81
81
  }
82
82
  }
83
83
  async acquireConnection() {
84
84
  await this.connectionMutex.lock();
85
- /* v8 ignore next 4 */
85
+ /* v8 ignore next */
86
86
  if (!this.connection.isValid()) {
87
87
  await this.destroy();
88
88
  await this.init();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/libsql",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.76",
4
+ "version": "7.0.0-dev.78",
5
5
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/knex": "7.0.0-dev.76",
53
+ "@mikro-orm/knex": "7.0.0-dev.78",
54
54
  "libsql": "0.5.22",
55
55
  "sqlstring-sqlite": "0.1.1"
56
56
  },
@@ -59,7 +59,7 @@
59
59
  "kysely": "0.28.8"
60
60
  },
61
61
  "peerDependencies": {
62
- "@mikro-orm/core": "7.0.0-dev.76",
62
+ "@mikro-orm/core": "7.0.0-dev.78",
63
63
  "kysely": "*"
64
64
  }
65
65
  }