defuss-db 1.0.3 → 1.1.1
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/README.md +1 -1
- package/dist/client.cjs +10 -0
- package/dist/client.d.cts +5 -0
- package/dist/client.d.mts +5 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.mjs +10 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/server.cjs +20 -1
- package/dist/server.d.cts +10 -0
- package/dist/server.d.mts +10 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.mjs +20 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -147,6 +147,6 @@ All commands are run from the root of the project, from a terminal:
|
|
|
147
147
|
|
|
148
148
|
---
|
|
149
149
|
|
|
150
|
-
<img src="assets/defuss_comic.png" />
|
|
150
|
+
<img src="https://raw.githubusercontent.com/kyr0/defuss/refs/heads/main/assets/defuss_comic.png" />
|
|
151
151
|
|
|
152
152
|
<caption><i><b>Come visit us on defuss island!</b></i></caption>
|
package/dist/client.cjs
CHANGED
|
@@ -20,6 +20,9 @@ class DexieProvider {
|
|
|
20
20
|
* @param options - Dexie-specific configuration options.
|
|
21
21
|
*/
|
|
22
22
|
async connect(options = {}) {
|
|
23
|
+
if (this.db && this.isConnected()) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
23
26
|
const isNode = typeof process !== "undefined" && typeof process.versions === "object" && typeof process.versions.node !== "undefined";
|
|
24
27
|
if (isNode) {
|
|
25
28
|
await import('fake-indexeddb/auto');
|
|
@@ -37,6 +40,13 @@ class DexieProvider {
|
|
|
37
40
|
this.isOpen = false;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the provider is currently connected to the database.
|
|
45
|
+
* @returns True if connected, false otherwise.
|
|
46
|
+
*/
|
|
47
|
+
isConnected() {
|
|
48
|
+
return this.isOpen;
|
|
49
|
+
}
|
|
40
50
|
/**
|
|
41
51
|
* Creates a table if it doesn't exist with dynamic schema support.
|
|
42
52
|
* @param table - The name of the table.
|
package/dist/client.d.cts
CHANGED
|
@@ -23,6 +23,11 @@ declare class DexieProvider implements DefussProvider<DexieOptions> {
|
|
|
23
23
|
* Disconnects from IndexedDB.
|
|
24
24
|
*/
|
|
25
25
|
disconnect(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the provider is currently connected to the database.
|
|
28
|
+
* @returns True if connected, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
isConnected(): boolean;
|
|
26
31
|
/**
|
|
27
32
|
* Creates a table if it doesn't exist with dynamic schema support.
|
|
28
33
|
* @param table - The name of the table.
|
package/dist/client.d.mts
CHANGED
|
@@ -23,6 +23,11 @@ declare class DexieProvider implements DefussProvider<DexieOptions> {
|
|
|
23
23
|
* Disconnects from IndexedDB.
|
|
24
24
|
*/
|
|
25
25
|
disconnect(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the provider is currently connected to the database.
|
|
28
|
+
* @returns True if connected, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
isConnected(): boolean;
|
|
26
31
|
/**
|
|
27
32
|
* Creates a table if it doesn't exist with dynamic schema support.
|
|
28
33
|
* @param table - The name of the table.
|
package/dist/client.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ declare class DexieProvider implements DefussProvider<DexieOptions> {
|
|
|
23
23
|
* Disconnects from IndexedDB.
|
|
24
24
|
*/
|
|
25
25
|
disconnect(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the provider is currently connected to the database.
|
|
28
|
+
* @returns True if connected, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
isConnected(): boolean;
|
|
26
31
|
/**
|
|
27
32
|
* Creates a table if it doesn't exist with dynamic schema support.
|
|
28
33
|
* @param table - The name of the table.
|
package/dist/client.mjs
CHANGED
|
@@ -18,6 +18,9 @@ class DexieProvider {
|
|
|
18
18
|
* @param options - Dexie-specific configuration options.
|
|
19
19
|
*/
|
|
20
20
|
async connect(options = {}) {
|
|
21
|
+
if (this.db && this.isConnected()) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
21
24
|
const isNode = typeof process !== "undefined" && typeof process.versions === "object" && typeof process.versions.node !== "undefined";
|
|
22
25
|
if (isNode) {
|
|
23
26
|
await import('fake-indexeddb/auto');
|
|
@@ -35,6 +38,13 @@ class DexieProvider {
|
|
|
35
38
|
this.isOpen = false;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the provider is currently connected to the database.
|
|
43
|
+
* @returns True if connected, false otherwise.
|
|
44
|
+
*/
|
|
45
|
+
isConnected() {
|
|
46
|
+
return this.isOpen;
|
|
47
|
+
}
|
|
38
48
|
/**
|
|
39
49
|
* Creates a table if it doesn't exist with dynamic schema support.
|
|
40
50
|
* @param table - The name of the table.
|
package/dist/index.d.cts
CHANGED
|
@@ -17,6 +17,11 @@ interface DefussProvider<O> {
|
|
|
17
17
|
* Disconnects from the database.
|
|
18
18
|
*/
|
|
19
19
|
disconnect(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the provider is currently connected to the database.
|
|
22
|
+
* @returns True if connected, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
isConnected(): boolean;
|
|
20
25
|
/**
|
|
21
26
|
* Creates a table if it doesn't exist.
|
|
22
27
|
* @param table - The name of the table.
|
package/dist/index.d.mts
CHANGED
|
@@ -17,6 +17,11 @@ interface DefussProvider<O> {
|
|
|
17
17
|
* Disconnects from the database.
|
|
18
18
|
*/
|
|
19
19
|
disconnect(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the provider is currently connected to the database.
|
|
22
|
+
* @returns True if connected, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
isConnected(): boolean;
|
|
20
25
|
/**
|
|
21
26
|
* Creates a table if it doesn't exist.
|
|
22
27
|
* @param table - The name of the table.
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ interface DefussProvider<O> {
|
|
|
17
17
|
* Disconnects from the database.
|
|
18
18
|
*/
|
|
19
19
|
disconnect(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the provider is currently connected to the database.
|
|
22
|
+
* @returns True if connected, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
isConnected(): boolean;
|
|
20
25
|
/**
|
|
21
26
|
* Creates a table if it doesn't exist.
|
|
22
27
|
* @param table - The name of the table.
|
package/dist/server.cjs
CHANGED
|
@@ -11,6 +11,9 @@ class LibsqlProvider {
|
|
|
11
11
|
* @param config - The libsql connection configuration.
|
|
12
12
|
*/
|
|
13
13
|
async connect(config) {
|
|
14
|
+
if (this.db && this.isConnected()) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
14
17
|
this.db = client.createClient(config);
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
@@ -19,6 +22,13 @@ class LibsqlProvider {
|
|
|
19
22
|
async disconnect() {
|
|
20
23
|
this.db.close();
|
|
21
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the provider is currently connected to the database.
|
|
27
|
+
* @returns True if connected, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
isConnected() {
|
|
30
|
+
return this.db?.closed !== true;
|
|
31
|
+
}
|
|
22
32
|
/**
|
|
23
33
|
* Creates a table if it doesn't exist.
|
|
24
34
|
* Sets up the primary key and any initial structure needed.
|
|
@@ -434,7 +444,9 @@ class MongoProvider {
|
|
|
434
444
|
*/
|
|
435
445
|
async connect(options = {}) {
|
|
436
446
|
try {
|
|
437
|
-
if (this.
|
|
447
|
+
if (this.isConnected()) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
438
450
|
const connectionString = options.connectionString || this.connectionString;
|
|
439
451
|
const { client, db } = await connectToMongo(connectionString);
|
|
440
452
|
this.client = client;
|
|
@@ -467,6 +479,13 @@ class MongoProvider {
|
|
|
467
479
|
}
|
|
468
480
|
}
|
|
469
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Checks if the provider is currently connected to the database.
|
|
484
|
+
* @returns True if connected, false otherwise.
|
|
485
|
+
*/
|
|
486
|
+
isConnected() {
|
|
487
|
+
return !!this.client && !!this.db;
|
|
488
|
+
}
|
|
470
489
|
/**
|
|
471
490
|
* Creates a collection if it doesn't exist.
|
|
472
491
|
*/
|
package/dist/server.d.cts
CHANGED
|
@@ -18,6 +18,11 @@ declare class LibsqlProvider implements DefussProvider<Config> {
|
|
|
18
18
|
* Disconnects from the SQLite database.
|
|
19
19
|
*/
|
|
20
20
|
disconnect(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the provider is currently connected to the database.
|
|
23
|
+
* @returns True if connected, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
isConnected(): boolean;
|
|
21
26
|
/**
|
|
22
27
|
* Creates a table if it doesn't exist.
|
|
23
28
|
* Sets up the primary key and any initial structure needed.
|
|
@@ -169,6 +174,11 @@ declare class MongoProvider implements DefussProvider<MongoProviderOptions> {
|
|
|
169
174
|
* Disconnects from MongoDB.
|
|
170
175
|
*/
|
|
171
176
|
disconnect(): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Checks if the provider is currently connected to the database.
|
|
179
|
+
* @returns True if connected, false otherwise.
|
|
180
|
+
*/
|
|
181
|
+
isConnected(): boolean;
|
|
172
182
|
/**
|
|
173
183
|
* Creates a collection if it doesn't exist.
|
|
174
184
|
*/
|
package/dist/server.d.mts
CHANGED
|
@@ -18,6 +18,11 @@ declare class LibsqlProvider implements DefussProvider<Config> {
|
|
|
18
18
|
* Disconnects from the SQLite database.
|
|
19
19
|
*/
|
|
20
20
|
disconnect(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the provider is currently connected to the database.
|
|
23
|
+
* @returns True if connected, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
isConnected(): boolean;
|
|
21
26
|
/**
|
|
22
27
|
* Creates a table if it doesn't exist.
|
|
23
28
|
* Sets up the primary key and any initial structure needed.
|
|
@@ -169,6 +174,11 @@ declare class MongoProvider implements DefussProvider<MongoProviderOptions> {
|
|
|
169
174
|
* Disconnects from MongoDB.
|
|
170
175
|
*/
|
|
171
176
|
disconnect(): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Checks if the provider is currently connected to the database.
|
|
179
|
+
* @returns True if connected, false otherwise.
|
|
180
|
+
*/
|
|
181
|
+
isConnected(): boolean;
|
|
172
182
|
/**
|
|
173
183
|
* Creates a collection if it doesn't exist.
|
|
174
184
|
*/
|
package/dist/server.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ declare class LibsqlProvider implements DefussProvider<Config> {
|
|
|
18
18
|
* Disconnects from the SQLite database.
|
|
19
19
|
*/
|
|
20
20
|
disconnect(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the provider is currently connected to the database.
|
|
23
|
+
* @returns True if connected, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
isConnected(): boolean;
|
|
21
26
|
/**
|
|
22
27
|
* Creates a table if it doesn't exist.
|
|
23
28
|
* Sets up the primary key and any initial structure needed.
|
|
@@ -169,6 +174,11 @@ declare class MongoProvider implements DefussProvider<MongoProviderOptions> {
|
|
|
169
174
|
* Disconnects from MongoDB.
|
|
170
175
|
*/
|
|
171
176
|
disconnect(): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Checks if the provider is currently connected to the database.
|
|
179
|
+
* @returns True if connected, false otherwise.
|
|
180
|
+
*/
|
|
181
|
+
isConnected(): boolean;
|
|
172
182
|
/**
|
|
173
183
|
* Creates a collection if it doesn't exist.
|
|
174
184
|
*/
|
package/dist/server.mjs
CHANGED
|
@@ -9,6 +9,9 @@ class LibsqlProvider {
|
|
|
9
9
|
* @param config - The libsql connection configuration.
|
|
10
10
|
*/
|
|
11
11
|
async connect(config) {
|
|
12
|
+
if (this.db && this.isConnected()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
12
15
|
this.db = createClient(config);
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
@@ -17,6 +20,13 @@ class LibsqlProvider {
|
|
|
17
20
|
async disconnect() {
|
|
18
21
|
this.db.close();
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the provider is currently connected to the database.
|
|
25
|
+
* @returns True if connected, false otherwise.
|
|
26
|
+
*/
|
|
27
|
+
isConnected() {
|
|
28
|
+
return this.db?.closed !== true;
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
31
|
* Creates a table if it doesn't exist.
|
|
22
32
|
* Sets up the primary key and any initial structure needed.
|
|
@@ -432,7 +442,9 @@ class MongoProvider {
|
|
|
432
442
|
*/
|
|
433
443
|
async connect(options = {}) {
|
|
434
444
|
try {
|
|
435
|
-
if (this.
|
|
445
|
+
if (this.isConnected()) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
436
448
|
const connectionString = options.connectionString || this.connectionString;
|
|
437
449
|
const { client, db } = await connectToMongo(connectionString);
|
|
438
450
|
this.client = client;
|
|
@@ -465,6 +477,13 @@ class MongoProvider {
|
|
|
465
477
|
}
|
|
466
478
|
}
|
|
467
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Checks if the provider is currently connected to the database.
|
|
482
|
+
* @returns True if connected, false otherwise.
|
|
483
|
+
*/
|
|
484
|
+
isConnected() {
|
|
485
|
+
return !!this.client && !!this.db;
|
|
486
|
+
}
|
|
468
487
|
/**
|
|
469
488
|
* Creates a collection if it doesn't exist.
|
|
470
489
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "defuss-db",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@libsql/client": "^0.15.
|
|
66
|
+
"@libsql/client": "^0.15.7",
|
|
67
67
|
"dexie": "^4.0.11",
|
|
68
68
|
"dotenv": "^16.5.0",
|
|
69
69
|
"fake-indexeddb": "^6.0.1",
|
|
@@ -84,6 +84,6 @@
|
|
|
84
84
|
"build": "pkgroll",
|
|
85
85
|
"mongodb:start": "tsx scripts/mongo-start.ts",
|
|
86
86
|
"mongodb:stop": "tsx scripts/mongo-stop.ts",
|
|
87
|
-
"test
|
|
87
|
+
"test": "vitest --run --coverage"
|
|
88
88
|
}
|
|
89
89
|
}
|