@hexaijs/sqlite 0.4.0 → 0.5.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 +26 -30
- package/dist/index.d.ts +2 -17
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -90
- package/dist/index.js.map +1 -1
- package/dist/sqlite-unit-of-work.d.ts +16 -0
- package/dist/sqlite-unit-of-work.d.ts.map +1 -0
- package/dist/sqlite-unit-of-work.js +76 -0
- package/dist/sqlite-unit-of-work.js.map +1 -0
- package/dist/test/index.d.ts +3 -23
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +2 -92
- package/dist/test/index.js.map +1 -1
- package/dist/test/sqlite-repository-for-test.d.ts +19 -0
- package/dist/test/sqlite-repository-for-test.d.ts.map +1 -0
- package/dist/test/sqlite-repository-for-test.js +59 -0
- package/dist/test/sqlite-repository-for-test.js.map +1 -0
- package/dist/test/utils.d.ts +3 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/test/utils.js +5 -0
- package/dist/test/utils.js.map +1 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ npm install @hexaijs/sqlite
|
|
|
28
28
|
**Peer dependencies:**
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
npm install @hexaijs/core
|
|
31
|
+
npm install @hexaijs/core better-sqlite3
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Core Concepts
|
|
@@ -38,15 +38,11 @@ npm install @hexaijs/core sqlite sqlite3
|
|
|
38
38
|
The `SqliteUnitOfWork` implements `UnitOfWork<Database>` from `@hexaijs/core`. It manages transaction lifecycle for a given SQLite database connection.
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
|
-
import
|
|
42
|
-
import sqlite3 from "sqlite3";
|
|
41
|
+
import Database from "better-sqlite3";
|
|
43
42
|
import { SqliteUnitOfWork } from "@hexaijs/sqlite";
|
|
44
43
|
|
|
45
44
|
// Create an in-memory database
|
|
46
|
-
const db =
|
|
47
|
-
filename: ":memory:",
|
|
48
|
-
driver: sqlite3.Database,
|
|
49
|
-
});
|
|
45
|
+
const db = new Database(":memory:");
|
|
50
46
|
|
|
51
47
|
// Create unit of work
|
|
52
48
|
const unitOfWork = new SqliteUnitOfWork(db);
|
|
@@ -61,8 +57,8 @@ Use `scope()` to define a transaction boundary:
|
|
|
61
57
|
```typescript
|
|
62
58
|
const result = await unitOfWork.scope(async () => {
|
|
63
59
|
const db = unitOfWork.getClient();
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
db.prepare("INSERT INTO orders (id, status) VALUES (?, ?)").run(orderId, "pending");
|
|
61
|
+
db.prepare("INSERT INTO order_items (order_id, product_id) VALUES (?, ?)").run(orderId, productId);
|
|
66
62
|
return { orderId };
|
|
67
63
|
});
|
|
68
64
|
// Transaction commits if successful
|
|
@@ -73,7 +69,7 @@ const result = await unitOfWork.scope(async () => {
|
|
|
73
69
|
```typescript
|
|
74
70
|
/** @deprecated Use scope() instead. */
|
|
75
71
|
const result = await unitOfWork.wrap(async (db) => {
|
|
76
|
-
|
|
72
|
+
db.prepare("INSERT INTO orders (id, status) VALUES (?, ?)").run(orderId, "pending");
|
|
77
73
|
return { orderId };
|
|
78
74
|
});
|
|
79
75
|
```
|
|
@@ -84,7 +80,7 @@ If an error is thrown, the transaction rolls back:
|
|
|
84
80
|
try {
|
|
85
81
|
await unitOfWork.scope(async () => {
|
|
86
82
|
const db = unitOfWork.getClient();
|
|
87
|
-
|
|
83
|
+
db.prepare("INSERT INTO orders (id, status) VALUES (?, ?)").run(orderId, "pending");
|
|
88
84
|
throw new Error("Something went wrong");
|
|
89
85
|
});
|
|
90
86
|
} catch (error) {
|
|
@@ -99,7 +95,7 @@ Within a transaction, access the database through `getClient()`:
|
|
|
99
95
|
```typescript
|
|
100
96
|
// Inside a command handler
|
|
101
97
|
const db = ctx.getUnitOfWork().getClient();
|
|
102
|
-
|
|
98
|
+
db.prepare("UPDATE orders SET status = ? WHERE id = ?").run("confirmed", orderId);
|
|
103
99
|
```
|
|
104
100
|
|
|
105
101
|
Note: `getClient()` throws an error if called outside of a `scope()` or `wrap()` call.
|
|
@@ -110,20 +106,20 @@ Register callbacks that execute at specific points in the transaction lifecycle:
|
|
|
110
106
|
|
|
111
107
|
```typescript
|
|
112
108
|
await unitOfWork.scope(async () => {
|
|
113
|
-
unitOfWork.beforeCommit(
|
|
109
|
+
unitOfWork.beforeCommit(() => {
|
|
114
110
|
// Validate before committing
|
|
115
111
|
});
|
|
116
112
|
|
|
117
|
-
unitOfWork.afterCommit(
|
|
113
|
+
unitOfWork.afterCommit(() => {
|
|
118
114
|
// Notify after successful commit
|
|
119
115
|
});
|
|
120
116
|
|
|
121
|
-
unitOfWork.afterRollback(
|
|
117
|
+
unitOfWork.afterRollback(() => {
|
|
122
118
|
// Clean up on failure
|
|
123
119
|
});
|
|
124
120
|
|
|
125
121
|
const db = unitOfWork.getClient();
|
|
126
|
-
|
|
122
|
+
db.prepare("INSERT INTO orders (id, status) VALUES (?, ?)").run(orderId, "pending");
|
|
127
123
|
});
|
|
128
124
|
```
|
|
129
125
|
|
|
@@ -144,11 +140,11 @@ Nested `scope()` calls participate in the same transaction:
|
|
|
144
140
|
```typescript
|
|
145
141
|
await unitOfWork.scope(async () => {
|
|
146
142
|
const db = unitOfWork.getClient();
|
|
147
|
-
|
|
143
|
+
db.prepare("INSERT INTO orders (id) VALUES (?)").run("order-1");
|
|
148
144
|
|
|
149
145
|
await unitOfWork.scope(async () => {
|
|
150
146
|
const db = unitOfWork.getClient();
|
|
151
|
-
|
|
147
|
+
db.prepare("INSERT INTO order_items (order_id) VALUES (?)").run("order-1");
|
|
152
148
|
});
|
|
153
149
|
// Both inserts are in the same transaction
|
|
154
150
|
});
|
|
@@ -161,11 +157,11 @@ If any nested call throws, the entire transaction rolls back:
|
|
|
161
157
|
try {
|
|
162
158
|
await unitOfWork.scope(async () => {
|
|
163
159
|
const db = unitOfWork.getClient();
|
|
164
|
-
|
|
160
|
+
db.prepare("INSERT INTO orders (id) VALUES (?)").run("order-1");
|
|
165
161
|
|
|
166
162
|
await unitOfWork.scope(async () => {
|
|
167
163
|
const db = unitOfWork.getClient();
|
|
168
|
-
|
|
164
|
+
db.prepare("INSERT INTO order_items (order_id) VALUES (?)").run("order-1");
|
|
169
165
|
throw new Error("Nested failure");
|
|
170
166
|
});
|
|
171
167
|
});
|
|
@@ -181,7 +177,7 @@ try {
|
|
|
181
177
|
Use the test utilities for fast, isolated integration tests:
|
|
182
178
|
|
|
183
179
|
```typescript
|
|
184
|
-
import type { Database } from "
|
|
180
|
+
import type { Database } from "better-sqlite3";
|
|
185
181
|
import { SqliteUnitOfWork } from "@hexaijs/sqlite";
|
|
186
182
|
import { getSqliteConnection } from "@hexaijs/sqlite/test";
|
|
187
183
|
|
|
@@ -189,12 +185,12 @@ describe("OrderRepository", () => {
|
|
|
189
185
|
let db: Database;
|
|
190
186
|
let unitOfWork: SqliteUnitOfWork;
|
|
191
187
|
|
|
192
|
-
beforeEach(
|
|
188
|
+
beforeEach(() => {
|
|
193
189
|
// Create fresh in-memory database
|
|
194
|
-
db =
|
|
190
|
+
db = getSqliteConnection();
|
|
195
191
|
|
|
196
192
|
// Create schema
|
|
197
|
-
|
|
193
|
+
db.exec(`
|
|
198
194
|
CREATE TABLE orders (
|
|
199
195
|
id TEXT PRIMARY KEY,
|
|
200
196
|
status TEXT NOT NULL
|
|
@@ -204,17 +200,17 @@ describe("OrderRepository", () => {
|
|
|
204
200
|
unitOfWork = new SqliteUnitOfWork(db);
|
|
205
201
|
});
|
|
206
202
|
|
|
207
|
-
afterEach(
|
|
208
|
-
|
|
203
|
+
afterEach(() => {
|
|
204
|
+
db.close();
|
|
209
205
|
});
|
|
210
206
|
|
|
211
207
|
it("should persist orders", async () => {
|
|
212
208
|
await unitOfWork.scope(async () => {
|
|
213
209
|
const db = unitOfWork.getClient();
|
|
214
|
-
|
|
210
|
+
db.prepare("INSERT INTO orders (id, status) VALUES (?, ?)").run("order-1", "pending");
|
|
215
211
|
});
|
|
216
212
|
|
|
217
|
-
const result =
|
|
213
|
+
const result = db.prepare("SELECT * FROM orders WHERE id = ?").get("order-1") as any;
|
|
218
214
|
expect(result.status).toBe("pending");
|
|
219
215
|
});
|
|
220
216
|
});
|
|
@@ -251,7 +247,7 @@ interface OrderMemento {
|
|
|
251
247
|
}
|
|
252
248
|
|
|
253
249
|
// Create repository
|
|
254
|
-
const db =
|
|
250
|
+
const db = getSqliteConnection();
|
|
255
251
|
const orderRepository = new SqliteRepositoryForTest<Order, OrderMemento>(db, {
|
|
256
252
|
namespace: "orders",
|
|
257
253
|
hydrate: (m) => new Order(new OrderId(m.id), m.status),
|
|
@@ -275,7 +271,7 @@ For scenarios requiring persistence across test runs or debugging:
|
|
|
275
271
|
import { getSqliteConnection } from "@hexaijs/sqlite/test";
|
|
276
272
|
|
|
277
273
|
// File-based database instead of in-memory
|
|
278
|
-
const db =
|
|
274
|
+
const db = getSqliteConnection("./test-database.sqlite");
|
|
279
275
|
```
|
|
280
276
|
|
|
281
277
|
## API Highlights
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare class SqliteUnitOfWork implements UnitOfWork<Database> {
|
|
5
|
-
private db;
|
|
6
|
-
private static transactions;
|
|
7
|
-
constructor(db: Database);
|
|
8
|
-
getClient(): Database;
|
|
9
|
-
beforeCommit(hook: TransactionHook): void;
|
|
10
|
-
afterCommit(hook: TransactionHook): void;
|
|
11
|
-
afterRollback(hook: TransactionHook): void;
|
|
12
|
-
scope<T>(fn: () => Promise<T>): Promise<T>;
|
|
13
|
-
wrap<T>(fn: (client: Database) => Promise<T>): Promise<T>;
|
|
14
|
-
private getRequiredState;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { SqliteUnitOfWork };
|
|
1
|
+
export * from "./sqlite-unit-of-work.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,91 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// src/sqlite-unit-of-work.ts
|
|
4
|
-
var SqliteUnitOfWork = class _SqliteUnitOfWork {
|
|
5
|
-
constructor(db) {
|
|
6
|
-
this.db = db;
|
|
7
|
-
if (!_SqliteUnitOfWork.transactions.has(db)) {
|
|
8
|
-
_SqliteUnitOfWork.transactions.set(db, {
|
|
9
|
-
level: 0,
|
|
10
|
-
aborted: false,
|
|
11
|
-
hooks: new TransactionHooks()
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
static transactions = /* @__PURE__ */ new WeakMap();
|
|
16
|
-
getClient() {
|
|
17
|
-
const current = _SqliteUnitOfWork.transactions.get(this.db);
|
|
18
|
-
if (!current || current.level === 0) {
|
|
19
|
-
throw new Error("No transaction is active");
|
|
20
|
-
}
|
|
21
|
-
return this.db;
|
|
22
|
-
}
|
|
23
|
-
beforeCommit(hook) {
|
|
24
|
-
const current = this.getRequiredState("beforeCommit");
|
|
25
|
-
current.hooks.addBeforeCommit(hook);
|
|
26
|
-
}
|
|
27
|
-
afterCommit(hook) {
|
|
28
|
-
const current = this.getRequiredState("afterCommit");
|
|
29
|
-
current.hooks.addAfterCommit(hook);
|
|
30
|
-
}
|
|
31
|
-
afterRollback(hook) {
|
|
32
|
-
const current = this.getRequiredState("afterRollback");
|
|
33
|
-
current.hooks.addAfterRollback(hook);
|
|
34
|
-
}
|
|
35
|
-
async scope(fn) {
|
|
36
|
-
return this.wrap(fn);
|
|
37
|
-
}
|
|
38
|
-
async wrap(fn) {
|
|
39
|
-
const current = _SqliteUnitOfWork.transactions.get(this.db);
|
|
40
|
-
if (++current.level === 1) {
|
|
41
|
-
await this.db.run("BEGIN TRANSACTION");
|
|
42
|
-
}
|
|
43
|
-
let abortError;
|
|
44
|
-
try {
|
|
45
|
-
return await fn(this.db);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
if (!current.aborted) {
|
|
48
|
-
current.aborted = true;
|
|
49
|
-
}
|
|
50
|
-
abortError = e;
|
|
51
|
-
throw e;
|
|
52
|
-
} finally {
|
|
53
|
-
if (--current.level === 0) {
|
|
54
|
-
const hooks = current.hooks;
|
|
55
|
-
const wasAborted = current.aborted;
|
|
56
|
-
current.hooks = new TransactionHooks();
|
|
57
|
-
current.aborted = false;
|
|
58
|
-
if (wasAborted) {
|
|
59
|
-
await hooks.executeRollback(
|
|
60
|
-
async () => {
|
|
61
|
-
await this.db.run("ROLLBACK");
|
|
62
|
-
},
|
|
63
|
-
abortError
|
|
64
|
-
);
|
|
65
|
-
} else {
|
|
66
|
-
await hooks.executeCommit(
|
|
67
|
-
async () => {
|
|
68
|
-
await this.db.run("COMMIT");
|
|
69
|
-
},
|
|
70
|
-
async () => {
|
|
71
|
-
await this.db.run("ROLLBACK");
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
getRequiredState(hookName) {
|
|
79
|
-
const current = _SqliteUnitOfWork.transactions.get(this.db);
|
|
80
|
-
if (!current || current.level === 0) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
`Cannot register ${hookName} hook outside of a transaction scope`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return current;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export { SqliteUnitOfWork };
|
|
90
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./sqlite-unit-of-work.js";
|
|
91
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Database } from "better-sqlite3";
|
|
2
|
+
import { UnitOfWork } from "@hexaijs/core";
|
|
3
|
+
import type { TransactionHook } from "@hexaijs/core";
|
|
4
|
+
export declare class SqliteUnitOfWork implements UnitOfWork<Database> {
|
|
5
|
+
private db;
|
|
6
|
+
private static transactions;
|
|
7
|
+
constructor(db: Database);
|
|
8
|
+
getClient(): Database;
|
|
9
|
+
beforeCommit(hook: TransactionHook): void;
|
|
10
|
+
afterCommit(hook: TransactionHook): void;
|
|
11
|
+
afterRollback(hook: TransactionHook): void;
|
|
12
|
+
scope<T>(fn: () => Promise<T>): Promise<T>;
|
|
13
|
+
wrap<T>(fn: (client: Database) => Promise<T>): Promise<T>;
|
|
14
|
+
private getRequiredState;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=sqlite-unit-of-work.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-unit-of-work.d.ts","sourceRoot":"","sources":["../src/sqlite-unit-of-work.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAoB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,qBAAa,gBAAiB,YAAW,UAAU,CAAC,QAAQ,CAAC;IAU7C,OAAO,CAAC,EAAE;IATtB,OAAO,CAAC,MAAM,CAAC,YAAY,CAOvB;IAEJ,YAAoB,EAAE,EAAE,QAAQ,EAQ/B;IAED,SAAS,IAAI,QAAQ,CAMpB;IAED,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAGxC;IAED,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAGvC;IAED,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAGzC;IAEK,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE/C;IAEK,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqC9D;IAED,OAAO,CAAC,gBAAgB;CAS3B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TransactionHooks } from "@hexaijs/core";
|
|
2
|
+
export class SqliteUnitOfWork {
|
|
3
|
+
db;
|
|
4
|
+
static transactions = new WeakMap();
|
|
5
|
+
constructor(db) {
|
|
6
|
+
this.db = db;
|
|
7
|
+
if (!SqliteUnitOfWork.transactions.has(db)) {
|
|
8
|
+
SqliteUnitOfWork.transactions.set(db, {
|
|
9
|
+
level: 0,
|
|
10
|
+
aborted: false,
|
|
11
|
+
hooks: new TransactionHooks(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
getClient() {
|
|
16
|
+
const current = SqliteUnitOfWork.transactions.get(this.db);
|
|
17
|
+
if (!current || current.level === 0) {
|
|
18
|
+
throw new Error("No transaction is active");
|
|
19
|
+
}
|
|
20
|
+
return this.db;
|
|
21
|
+
}
|
|
22
|
+
beforeCommit(hook) {
|
|
23
|
+
const current = this.getRequiredState("beforeCommit");
|
|
24
|
+
current.hooks.addBeforeCommit(hook);
|
|
25
|
+
}
|
|
26
|
+
afterCommit(hook) {
|
|
27
|
+
const current = this.getRequiredState("afterCommit");
|
|
28
|
+
current.hooks.addAfterCommit(hook);
|
|
29
|
+
}
|
|
30
|
+
afterRollback(hook) {
|
|
31
|
+
const current = this.getRequiredState("afterRollback");
|
|
32
|
+
current.hooks.addAfterRollback(hook);
|
|
33
|
+
}
|
|
34
|
+
async scope(fn) {
|
|
35
|
+
return this.wrap(fn);
|
|
36
|
+
}
|
|
37
|
+
async wrap(fn) {
|
|
38
|
+
const current = SqliteUnitOfWork.transactions.get(this.db);
|
|
39
|
+
if (++current.level === 1) {
|
|
40
|
+
this.db.exec("BEGIN TRANSACTION");
|
|
41
|
+
}
|
|
42
|
+
let abortError;
|
|
43
|
+
try {
|
|
44
|
+
return await fn(this.db);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (!current.aborted) {
|
|
48
|
+
current.aborted = true;
|
|
49
|
+
}
|
|
50
|
+
abortError = e;
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
if (--current.level === 0) {
|
|
55
|
+
const hooks = current.hooks;
|
|
56
|
+
const wasAborted = current.aborted;
|
|
57
|
+
current.hooks = new TransactionHooks();
|
|
58
|
+
current.aborted = false;
|
|
59
|
+
if (wasAborted) {
|
|
60
|
+
await hooks.executeRollback(async () => { this.db.exec("ROLLBACK"); }, abortError);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
await hooks.executeCommit(async () => { this.db.exec("COMMIT"); }, async () => { this.db.exec("ROLLBACK"); });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getRequiredState(hookName) {
|
|
69
|
+
const current = SqliteUnitOfWork.transactions.get(this.db);
|
|
70
|
+
if (!current || current.level === 0) {
|
|
71
|
+
throw new Error(`Cannot register ${hookName} hook outside of a transaction scope`);
|
|
72
|
+
}
|
|
73
|
+
return current;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=sqlite-unit-of-work.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-unit-of-work.js","sourceRoot":"","sources":["../src/sqlite-unit-of-work.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAc,MAAM,eAAe,CAAC;AAG7D,MAAM,OAAO,gB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I,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAC5C,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEO,gBAAgB,CAAC,QAAgB;QACrC,MAAM,OAAO,GAAG,gBAAgB,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACX,mBAAmB,QAAQ,sCAAsC,CACpE,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
package/dist/test/index.d.ts
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare class SqliteRepositoryForTest<E extends Identifiable<any>, M> implements Repository<E> {
|
|
5
|
-
protected db: Database;
|
|
6
|
-
protected namespace: string;
|
|
7
|
-
protected hydrate: (memento: M) => E;
|
|
8
|
-
protected dehydrate: (entity: E) => M;
|
|
9
|
-
constructor(db: Database, { namespace, hydrate, dehydrate, }: {
|
|
10
|
-
namespace: string;
|
|
11
|
-
hydrate: (memento: M) => E;
|
|
12
|
-
dehydrate: (entity: E) => M;
|
|
13
|
-
});
|
|
14
|
-
get(id: IdOf<E>): Promise<E>;
|
|
15
|
-
add(entity: E): Promise<void>;
|
|
16
|
-
update(entity: E): Promise<void>;
|
|
17
|
-
count(): Promise<number>;
|
|
18
|
-
protected ensureTableExists(): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare function getSqliteConnection(filename?: string): Promise<Database>;
|
|
22
|
-
|
|
23
|
-
export { SqliteRepositoryForTest, getSqliteConnection };
|
|
1
|
+
export * from "./sqlite-repository-for-test.js";
|
|
2
|
+
export * from "./utils.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,YAAY,CAAC"}
|
package/dist/test/index.js
CHANGED
|
@@ -1,93 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// src/test/sqlite-repository-for-test.ts
|
|
4
|
-
var SqliteRepositoryForTest = class {
|
|
5
|
-
constructor(db, {
|
|
6
|
-
namespace,
|
|
7
|
-
hydrate,
|
|
8
|
-
dehydrate
|
|
9
|
-
}) {
|
|
10
|
-
this.db = db;
|
|
11
|
-
this.namespace = namespace;
|
|
12
|
-
this.hydrate = hydrate;
|
|
13
|
-
this.dehydrate = dehydrate;
|
|
14
|
-
}
|
|
15
|
-
namespace;
|
|
16
|
-
hydrate;
|
|
17
|
-
dehydrate;
|
|
18
|
-
async get(id) {
|
|
19
|
-
await this.ensureTableExists();
|
|
20
|
-
const row = await this.db.get(
|
|
21
|
-
`SELECT * FROM ${this.namespace} WHERE id = ?`,
|
|
22
|
-
id.getValue()
|
|
23
|
-
);
|
|
24
|
-
if (!row) {
|
|
25
|
-
throw new ObjectNotFoundError(
|
|
26
|
-
`entity with id '${id.getValue()}' not found`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
return this.hydrate(JSON.parse(row.data));
|
|
30
|
-
}
|
|
31
|
-
async add(entity) {
|
|
32
|
-
await this.ensureTableExists();
|
|
33
|
-
try {
|
|
34
|
-
await this.db.run(
|
|
35
|
-
`INSERT INTO ${this.namespace} (id, data)
|
|
36
|
-
VALUES (?, ?)`,
|
|
37
|
-
entity.getId().getValue(),
|
|
38
|
-
JSON.stringify(this.dehydrate(entity))
|
|
39
|
-
);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
if (e.message.includes("UNIQUE constraint failed")) {
|
|
42
|
-
throw new DuplicateObjectError(
|
|
43
|
-
`entity with id '${entity.getId().getValue()}' already exists`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
throw e;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async update(entity) {
|
|
50
|
-
await this.ensureTableExists();
|
|
51
|
-
const result = await this.db.run(
|
|
52
|
-
`UPDATE ${this.namespace}
|
|
53
|
-
SET data = ?
|
|
54
|
-
WHERE id = ?`,
|
|
55
|
-
JSON.stringify(this.dehydrate(entity)),
|
|
56
|
-
entity.getId().getValue()
|
|
57
|
-
);
|
|
58
|
-
if (result.changes === 0) {
|
|
59
|
-
throw new ObjectNotFoundError(
|
|
60
|
-
`entity with id '${entity.getId().getValue()}' not found`
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async count() {
|
|
65
|
-
await this.ensureTableExists();
|
|
66
|
-
const result = await this.db.get(
|
|
67
|
-
`SELECT COUNT(*) AS count FROM ${this.namespace}`
|
|
68
|
-
);
|
|
69
|
-
return result.count;
|
|
70
|
-
}
|
|
71
|
-
async ensureTableExists() {
|
|
72
|
-
await this.db.run(`
|
|
73
|
-
CREATE TABLE IF NOT EXISTS ${this.namespace} (
|
|
74
|
-
id TEXT NOT NULL PRIMARY KEY UNIQUE,
|
|
75
|
-
data TEXT NOT NULL
|
|
76
|
-
)
|
|
77
|
-
`);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// src/test/utils.ts
|
|
82
|
-
async function getSqliteConnection(filename = ":memory:") {
|
|
83
|
-
const sqlite = await import('sqlite');
|
|
84
|
-
const sqlite3 = await import('sqlite3');
|
|
85
|
-
return await sqlite.open({
|
|
86
|
-
filename,
|
|
87
|
-
driver: sqlite3.default.Database
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export { SqliteRepositoryForTest, getSqliteConnection };
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./sqlite-repository-for-test.js";
|
|
2
|
+
export * from "./utils.js";
|
|
93
3
|
//# sourceMappingURL=index.js.map
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Database } from "better-sqlite3";
|
|
2
|
+
import { Identifiable, IdOf, Repository } from "@hexaijs/core";
|
|
3
|
+
export declare class SqliteRepositoryForTest<E extends Identifiable<any>, M> implements Repository<E> {
|
|
4
|
+
protected db: Database;
|
|
5
|
+
protected namespace: string;
|
|
6
|
+
protected hydrate: (memento: M) => E;
|
|
7
|
+
protected dehydrate: (entity: E) => M;
|
|
8
|
+
constructor(db: Database, { namespace, hydrate, dehydrate }: {
|
|
9
|
+
namespace: string;
|
|
10
|
+
hydrate: (memento: M) => E;
|
|
11
|
+
dehydrate: (entity: E) => M;
|
|
12
|
+
});
|
|
13
|
+
get(id: IdOf<E>): Promise<E>;
|
|
14
|
+
add(entity: E): Promise<void>;
|
|
15
|
+
update(entity: E): Promise<void>;
|
|
16
|
+
count(): Promise<number>;
|
|
17
|
+
protected ensureTableExists(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=sqlite-repository-for-test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-repository-for-test.d.ts","sourceRoot":"","sources":["../../src/test/sqlite-repository-for-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAEH,YAAY,EACZ,IAAI,EAEJ,UAAU,EACb,MAAM,eAAe,CAAC;AAEvB,qBAAa,uBAAuB,CAChC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,EAC3B,CAAC,CACH,YAAW,UAAU,CAAC,CAAC,CAAC;IAMlB,SAAS,CAAC,EAAE,EAAE,QAAQ;IAL1B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACrC,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;IAEtC,YACc,EAAE,EAAE,QAAQ,EACtB,EACI,SAAS,EACT,OAAO,EACP,SAAS,EACZ,EAAE;QACC,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;KAC/B,EAKJ;IAEK,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAajC;IAEK,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBlC;IAEK,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBrC;IAEK,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAQ7B;IAED,SAAS,CAAC,iBAAiB,IAAI,IAAI,CAOlC;CACJ"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DuplicateObjectError, ObjectNotFoundError, } from "@hexaijs/core";
|
|
2
|
+
export class SqliteRepositoryForTest {
|
|
3
|
+
db;
|
|
4
|
+
namespace;
|
|
5
|
+
hydrate;
|
|
6
|
+
dehydrate;
|
|
7
|
+
constructor(db, { namespace, hydrate, dehydrate, }) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
this.namespace = namespace;
|
|
10
|
+
this.hydrate = hydrate;
|
|
11
|
+
this.dehydrate = dehydrate;
|
|
12
|
+
}
|
|
13
|
+
async get(id) {
|
|
14
|
+
this.ensureTableExists();
|
|
15
|
+
const row = this.db.prepare(`SELECT * FROM ${this.namespace} WHERE id = ?`).get(id.getValue());
|
|
16
|
+
if (!row) {
|
|
17
|
+
throw new ObjectNotFoundError(`entity with id '${id.getValue()}' not found`);
|
|
18
|
+
}
|
|
19
|
+
return this.hydrate(JSON.parse(row.data));
|
|
20
|
+
}
|
|
21
|
+
async add(entity) {
|
|
22
|
+
this.ensureTableExists();
|
|
23
|
+
try {
|
|
24
|
+
this.db.prepare(`INSERT INTO ${this.namespace} (id, data)
|
|
25
|
+
VALUES (?, ?)`).run(entity.getId().getValue(), JSON.stringify(this.dehydrate(entity)));
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
if (e.message.includes("UNIQUE constraint failed")) {
|
|
29
|
+
throw new DuplicateObjectError(`entity with id '${entity
|
|
30
|
+
.getId()
|
|
31
|
+
.getValue()}' already exists`);
|
|
32
|
+
}
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async update(entity) {
|
|
37
|
+
this.ensureTableExists();
|
|
38
|
+
const result = this.db.prepare(`UPDATE ${this.namespace}
|
|
39
|
+
SET data = ?
|
|
40
|
+
WHERE id = ?`).run(JSON.stringify(this.dehydrate(entity)), entity.getId().getValue());
|
|
41
|
+
if (result.changes === 0) {
|
|
42
|
+
throw new ObjectNotFoundError(`entity with id '${entity.getId().getValue()}' not found`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async count() {
|
|
46
|
+
this.ensureTableExists();
|
|
47
|
+
const result = this.db.prepare(`SELECT COUNT(*) AS count FROM ${this.namespace}`).get();
|
|
48
|
+
return result.count;
|
|
49
|
+
}
|
|
50
|
+
ensureTableExists() {
|
|
51
|
+
this.db.exec(`
|
|
52
|
+
CREATE TABLE IF NOT EXISTS ${this.namespace} (
|
|
53
|
+
id TEXT NOT NULL PRIMARY KEY UNIQUE,
|
|
54
|
+
data TEXT NOT NULL
|
|
55
|
+
)
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=sqlite-repository-for-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-repository-for-test.js","sourceRoot":"","sources":["../../src/test/sqlite-repository-for-test.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,oBAAoB,EAGpB,mBAAmB,GAEtB,MAAM,eAAe,CAAC;AAEvB,MAAM,OAAO,uBAAuB;IASlB,EAAE;IALN,SAAS,CAAS;IAClB,OAAO,CAAoB;IAC3B,SAAS,CAAmB;IAEtC,YACc,EAAY,EACtB,EACI,SAAS,EACT,OAAO,EACP,SAAS,GAKZ;kBATS,EAAE;QAWZ,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAW;QACjB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CACvB,iBAAiB,IAAI,CAAC,SAAS,eAAe,CACjD,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAiC,CAAC;QACrD,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,MAAM,IAAI,mBAAmB,CACzB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,aAAa,CAChD,CAAC;QACN,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAS;QACf,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,IAAI,CAAC;YACD,IAAI,CAAC,EAAE,CAAC,OAAO,CACX,eAAe,IAAI,CAAC,SAAS;+BACd,CAClB,CAAC,GAAG,CACD,MAAM,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,E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0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,wBAAgB,mBAAmB,CAC/B,QAAQ,SAAa,GACtB,gBAAgB,CAElB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,MAAM,UAAU,mBAAmB,CAC/B,QAAQ,GAAG,UAAU;IAErB,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.5.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"description": "SQLite support for hexai",
|
|
9
9
|
"license": "MIT",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@hexaijs/core": "^0.
|
|
50
|
-
"
|
|
51
|
-
"sqlite3": "^5.1.7"
|
|
49
|
+
"@hexaijs/core": "^0.9.0",
|
|
50
|
+
"better-sqlite3": "^12.5.0"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"
|
|
55
|
-
"sqlite3": "^
|
|
56
|
-
"
|
|
53
|
+
"@typescript/native-preview": "^7.0.0-dev",
|
|
54
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
55
|
+
"better-sqlite3": "^12.5.0",
|
|
56
|
+
"@hexaijs/core": "^0.9.1",
|
|
57
57
|
"@hexaijs/tooling": "0.1.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "vitest run",
|
|
61
|
-
"build": "
|
|
61
|
+
"build": "tsgo -p tsconfig.build.json"
|
|
62
62
|
}
|
|
63
63
|
}
|