@geekmidas/testkit 0.0.5 → 0.0.7
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/dist/Factory-WMhTNZ9S.cjs +56 -0
- package/dist/Factory-z2m01hMj.mjs +50 -0
- package/dist/Factory.cjs +1 -1
- package/dist/Factory.mjs +1 -1
- package/dist/KyselyFactory-Bdq1s1Go.cjs +215 -0
- package/dist/KyselyFactory-ELiHgHVv.mjs +210 -0
- package/dist/KyselyFactory.cjs +3 -3
- package/dist/KyselyFactory.mjs +3 -3
- package/dist/ObjectionFactory-89p-FFEw.mjs +178 -0
- package/dist/ObjectionFactory-C47B03Ot.cjs +183 -0
- package/dist/ObjectionFactory.cjs +2 -2
- package/dist/ObjectionFactory.mjs +2 -2
- package/dist/PostgresKyselyMigrator-Bs31emFd.cjs +87 -0
- package/dist/PostgresKyselyMigrator-ChIpZFYB.mjs +81 -0
- package/dist/PostgresKyselyMigrator.cjs +2 -2
- package/dist/PostgresKyselyMigrator.mjs +2 -2
- package/dist/PostgresMigrator-BtAWdLss.cjs +151 -0
- package/dist/PostgresMigrator-BzqksJcW.mjs +145 -0
- package/dist/PostgresMigrator.cjs +1 -1
- package/dist/PostgresMigrator.mjs +1 -1
- package/dist/VitestKyselyTransactionIsolator-AfxPJEwR.mjs +58 -0
- package/dist/VitestKyselyTransactionIsolator-YWnSJiIH.cjs +63 -0
- package/dist/VitestKyselyTransactionIsolator.cjs +2 -2
- package/dist/VitestKyselyTransactionIsolator.mjs +2 -2
- package/dist/VitestObjectionTransactionIsolator-0uX6DW5G.cjs +66 -0
- package/dist/VitestObjectionTransactionIsolator-BZRYy8iW.mjs +61 -0
- package/dist/VitestObjectionTransactionIsolator.cjs +4 -0
- package/dist/VitestObjectionTransactionIsolator.mjs +4 -0
- package/dist/VitestTransactionIsolator-DcOz0LZF.cjs +129 -0
- package/dist/VitestTransactionIsolator-kFL36T8x.mjs +117 -0
- package/dist/VitestTransactionIsolator.cjs +1 -1
- package/dist/VitestTransactionIsolator.mjs +1 -1
- package/dist/__tests__/Factory.spec.cjs +1 -1
- package/dist/__tests__/Factory.spec.mjs +1 -1
- package/dist/__tests__/KyselyFactory.spec.cjs +41 -40
- package/dist/__tests__/KyselyFactory.spec.mjs +42 -41
- package/dist/__tests__/ObjectionFactory.spec.cjs +3 -3
- package/dist/__tests__/ObjectionFactory.spec.mjs +3 -3
- package/dist/__tests__/PostgresMigrator.spec.cjs +2 -2
- package/dist/__tests__/PostgresMigrator.spec.mjs +2 -2
- package/dist/__tests__/faker.spec.cjs +1 -1
- package/dist/__tests__/faker.spec.mjs +1 -1
- package/dist/__tests__/integration.spec.cjs +11 -8
- package/dist/__tests__/integration.spec.mjs +12 -9
- package/dist/example.cjs +3 -3
- package/dist/example.mjs +3 -3
- package/dist/faker-CxKkEeYi.mjs +227 -0
- package/dist/faker-SMN4ira4.cjs +263 -0
- package/dist/faker.cjs +1 -1
- package/dist/faker.mjs +1 -1
- package/dist/helpers-CKMlwSYT.mjs +47 -0
- package/dist/helpers-H4hO5SZR.cjs +53 -0
- package/dist/helpers.cjs +2 -5
- package/dist/helpers.mjs +2 -4
- package/dist/kysely-B-GOhABm.cjs +72 -0
- package/dist/kysely-CqfoKVXs.mjs +67 -0
- package/dist/kysely.cjs +11 -15
- package/dist/kysely.mjs +9 -15
- package/dist/objection.cjs +86 -3
- package/dist/objection.mjs +83 -3
- package/package.json +2 -2
- package/src/Factory.ts +97 -0
- package/src/KyselyFactory.ts +180 -0
- package/src/ObjectionFactory.ts +145 -3
- package/src/PostgresKyselyMigrator.ts +54 -0
- package/src/PostgresMigrator.ts +90 -0
- package/src/VitestKyselyTransactionIsolator.ts +46 -0
- package/src/VitestObjectionTransactionIsolator.ts +73 -0
- package/src/VitestTransactionIsolator.ts +99 -2
- package/src/__tests__/KyselyFactory.spec.ts +4 -6
- package/src/__tests__/integration.spec.ts +8 -3
- package/src/faker.ts +158 -7
- package/src/helpers.ts +35 -18
- package/src/kysely.ts +66 -1
- package/src/objection.ts +95 -0
- package/dist/Factory-DREHoms3.cjs +0 -15
- package/dist/Factory-DlzMkMzb.mjs +0 -9
- package/dist/KyselyFactory-BX7Kv2uP.cjs +0 -65
- package/dist/KyselyFactory-pOMOFQWE.mjs +0 -60
- package/dist/ObjectionFactory-BlkzSEqo.cjs +0 -41
- package/dist/ObjectionFactory-ChuX8sZN.mjs +0 -36
- package/dist/PostgresKyselyMigrator-D8fm35-s.mjs +0 -27
- package/dist/PostgresKyselyMigrator-JTY2LfwD.cjs +0 -33
- package/dist/PostgresMigrator-Bz-tnjB6.cjs +0 -67
- package/dist/PostgresMigrator-CEoRKTdq.mjs +0 -61
- package/dist/VitestKyselyTransactionIsolator-BS3R-V0I.mjs +0 -12
- package/dist/VitestKyselyTransactionIsolator-DWSTKIe3.cjs +0 -17
- package/dist/VitestTransactionIsolator-BjVXqFs6.mjs +0 -40
- package/dist/VitestTransactionIsolator-Bx2c4OzK.cjs +0 -52
- package/dist/faker-BwaXA_RF.mjs +0 -85
- package/dist/faker-caz-8zt8.cjs +0 -121
- package/dist/helpers-B9Jdk_C7.cjs +0 -31
- package/dist/helpers-DOiGIkaU.mjs +0 -19
- /package/dist/{helpers-DKEBHABj.cjs → helpers-Bnm3Jy9X.cjs} +0 -0
- /package/dist/{helpers-BfuX-cjN.mjs → helpers-CukcFAU9.mjs} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-Bx2c4OzK.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/VitestKyselyTransactionIsolator.ts
|
|
4
|
-
var VitestKyselyTransactionIsolator = class extends require_VitestTransactionIsolator.VitestPostgresTransactionIsolator {
|
|
5
|
-
async transact(conn, level, fn) {
|
|
6
|
-
const isolationLevel = level.toLocaleLowerCase();
|
|
7
|
-
await conn.transaction().setIsolationLevel(isolationLevel).execute(fn);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
Object.defineProperty(exports, 'VitestKyselyTransactionIsolator', {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return VitestKyselyTransactionIsolator;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { test } from "vitest";
|
|
2
|
-
|
|
3
|
-
//#region src/VitestTransactionIsolator.ts
|
|
4
|
-
let IsolationLevel = /* @__PURE__ */ function(IsolationLevel$1) {
|
|
5
|
-
IsolationLevel$1["READ_UNCOMMITTED"] = "READ UNCOMMITTED";
|
|
6
|
-
IsolationLevel$1["READ_COMMITTED"] = "READ COMMITTED";
|
|
7
|
-
IsolationLevel$1["REPEATABLE_READ"] = "REPEATABLE READ";
|
|
8
|
-
IsolationLevel$1["SERIALIZABLE"] = "SERIALIZABLE";
|
|
9
|
-
return IsolationLevel$1;
|
|
10
|
-
}({});
|
|
11
|
-
var VitestPostgresTransactionIsolator = class {
|
|
12
|
-
wrapVitestWithTransaction(conn, setup, level = IsolationLevel.REPEATABLE_READ) {
|
|
13
|
-
return test.extend({ trx: async ({}, use) => {
|
|
14
|
-
class TestRollback extends Error {
|
|
15
|
-
constructor() {
|
|
16
|
-
super("Test rollback");
|
|
17
|
-
this.name = "TestRollback";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
let testError;
|
|
21
|
-
try {
|
|
22
|
-
await this.transact(conn, level, async (transaction) => {
|
|
23
|
-
try {
|
|
24
|
-
await setup?.(transaction);
|
|
25
|
-
await use(transaction);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
testError = error;
|
|
28
|
-
}
|
|
29
|
-
throw new TestRollback();
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
if (!(error instanceof TestRollback)) throw error;
|
|
33
|
-
if (testError) throw testError;
|
|
34
|
-
}
|
|
35
|
-
} });
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
export { IsolationLevel, VitestPostgresTransactionIsolator };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const vitest = require_chunk.__toESM(require("vitest"));
|
|
3
|
-
|
|
4
|
-
//#region src/VitestTransactionIsolator.ts
|
|
5
|
-
let IsolationLevel = /* @__PURE__ */ function(IsolationLevel$1) {
|
|
6
|
-
IsolationLevel$1["READ_UNCOMMITTED"] = "READ UNCOMMITTED";
|
|
7
|
-
IsolationLevel$1["READ_COMMITTED"] = "READ COMMITTED";
|
|
8
|
-
IsolationLevel$1["REPEATABLE_READ"] = "REPEATABLE READ";
|
|
9
|
-
IsolationLevel$1["SERIALIZABLE"] = "SERIALIZABLE";
|
|
10
|
-
return IsolationLevel$1;
|
|
11
|
-
}({});
|
|
12
|
-
var VitestPostgresTransactionIsolator = class {
|
|
13
|
-
wrapVitestWithTransaction(conn, setup, level = IsolationLevel.REPEATABLE_READ) {
|
|
14
|
-
return vitest.test.extend({ trx: async ({}, use) => {
|
|
15
|
-
class TestRollback extends Error {
|
|
16
|
-
constructor() {
|
|
17
|
-
super("Test rollback");
|
|
18
|
-
this.name = "TestRollback";
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
let testError;
|
|
22
|
-
try {
|
|
23
|
-
await this.transact(conn, level, async (transaction) => {
|
|
24
|
-
try {
|
|
25
|
-
await setup?.(transaction);
|
|
26
|
-
await use(transaction);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
testError = error;
|
|
29
|
-
}
|
|
30
|
-
throw new TestRollback();
|
|
31
|
-
});
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (!(error instanceof TestRollback)) throw error;
|
|
34
|
-
if (testError) throw testError;
|
|
35
|
-
}
|
|
36
|
-
} });
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
Object.defineProperty(exports, 'IsolationLevel', {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return IsolationLevel;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, 'VitestPostgresTransactionIsolator', {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function () {
|
|
50
|
-
return VitestPostgresTransactionIsolator;
|
|
51
|
-
}
|
|
52
|
-
});
|
package/dist/faker-BwaXA_RF.mjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { faker } from "@faker-js/faker";
|
|
2
|
-
|
|
3
|
-
//#region src/faker.ts
|
|
4
|
-
/**
|
|
5
|
-
* Atomic counter implementation for thread-safe sequence generation
|
|
6
|
-
*/
|
|
7
|
-
var AtomicCounter = class {
|
|
8
|
-
value;
|
|
9
|
-
constructor(initialValue = 0) {
|
|
10
|
-
this.value = initialValue;
|
|
11
|
-
}
|
|
12
|
-
increment() {
|
|
13
|
-
return ++this.value;
|
|
14
|
-
}
|
|
15
|
-
get() {
|
|
16
|
-
return this.value;
|
|
17
|
-
}
|
|
18
|
-
reset(value = 0) {
|
|
19
|
-
this.value = value;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Sets the `insertedAt` and `updatedAt` to a random date in the past.
|
|
24
|
-
*/
|
|
25
|
-
function timestamps() {
|
|
26
|
-
const createdAt = faker$1.date.past();
|
|
27
|
-
const updatedAt = faker$1.date.between({
|
|
28
|
-
from: createdAt,
|
|
29
|
-
to: /* @__PURE__ */ new Date()
|
|
30
|
-
});
|
|
31
|
-
createdAt.setMilliseconds(0);
|
|
32
|
-
updatedAt.setMilliseconds(0);
|
|
33
|
-
return {
|
|
34
|
-
createdAt,
|
|
35
|
-
updatedAt
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns a reverse domain name identifier.
|
|
40
|
-
*/
|
|
41
|
-
function identifier(suffix) {
|
|
42
|
-
return [
|
|
43
|
-
faker$1.internet.domainSuffix(),
|
|
44
|
-
faker$1.internet.domainWord(),
|
|
45
|
-
suffix ? suffix : faker$1.internet.domainWord() + sequence("identifier")
|
|
46
|
-
].join(".");
|
|
47
|
-
}
|
|
48
|
-
const sequences = /* @__PURE__ */ new Map();
|
|
49
|
-
function sequence(name = "default") {
|
|
50
|
-
if (!sequences.has(name)) sequences.set(name, new AtomicCounter());
|
|
51
|
-
const counter = sequences.get(name);
|
|
52
|
-
return counter.increment();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Resets a sequence counter to a specific value (default: 0)
|
|
56
|
-
*/
|
|
57
|
-
function resetSequence(name = "default", value = 0) {
|
|
58
|
-
if (sequences.has(name)) {
|
|
59
|
-
const counter = sequences.get(name);
|
|
60
|
-
counter.reset(value);
|
|
61
|
-
} else sequences.set(name, new AtomicCounter(value));
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resets all sequence counters
|
|
65
|
-
*/
|
|
66
|
-
function resetAllSequences() {
|
|
67
|
-
sequences.clear();
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Returns a random price number.
|
|
71
|
-
*/
|
|
72
|
-
function price() {
|
|
73
|
-
return +faker$1.commerce.price();
|
|
74
|
-
}
|
|
75
|
-
const faker$1 = Object.freeze(Object.assign({}, faker, {
|
|
76
|
-
timestamps,
|
|
77
|
-
identifier,
|
|
78
|
-
sequence,
|
|
79
|
-
resetSequence,
|
|
80
|
-
resetAllSequences,
|
|
81
|
-
price
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
//#endregion
|
|
85
|
-
export { faker$1 as faker, identifier, resetAllSequences, resetSequence, sequence, timestamps };
|
package/dist/faker-caz-8zt8.cjs
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const __faker_js_faker = require_chunk.__toESM(require("@faker-js/faker"));
|
|
3
|
-
|
|
4
|
-
//#region src/faker.ts
|
|
5
|
-
/**
|
|
6
|
-
* Atomic counter implementation for thread-safe sequence generation
|
|
7
|
-
*/
|
|
8
|
-
var AtomicCounter = class {
|
|
9
|
-
value;
|
|
10
|
-
constructor(initialValue = 0) {
|
|
11
|
-
this.value = initialValue;
|
|
12
|
-
}
|
|
13
|
-
increment() {
|
|
14
|
-
return ++this.value;
|
|
15
|
-
}
|
|
16
|
-
get() {
|
|
17
|
-
return this.value;
|
|
18
|
-
}
|
|
19
|
-
reset(value = 0) {
|
|
20
|
-
this.value = value;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Sets the `insertedAt` and `updatedAt` to a random date in the past.
|
|
25
|
-
*/
|
|
26
|
-
function timestamps() {
|
|
27
|
-
const createdAt = faker.date.past();
|
|
28
|
-
const updatedAt = faker.date.between({
|
|
29
|
-
from: createdAt,
|
|
30
|
-
to: /* @__PURE__ */ new Date()
|
|
31
|
-
});
|
|
32
|
-
createdAt.setMilliseconds(0);
|
|
33
|
-
updatedAt.setMilliseconds(0);
|
|
34
|
-
return {
|
|
35
|
-
createdAt,
|
|
36
|
-
updatedAt
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Returns a reverse domain name identifier.
|
|
41
|
-
*/
|
|
42
|
-
function identifier(suffix) {
|
|
43
|
-
return [
|
|
44
|
-
faker.internet.domainSuffix(),
|
|
45
|
-
faker.internet.domainWord(),
|
|
46
|
-
suffix ? suffix : faker.internet.domainWord() + sequence("identifier")
|
|
47
|
-
].join(".");
|
|
48
|
-
}
|
|
49
|
-
const sequences = /* @__PURE__ */ new Map();
|
|
50
|
-
function sequence(name = "default") {
|
|
51
|
-
if (!sequences.has(name)) sequences.set(name, new AtomicCounter());
|
|
52
|
-
const counter = sequences.get(name);
|
|
53
|
-
return counter.increment();
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Resets a sequence counter to a specific value (default: 0)
|
|
57
|
-
*/
|
|
58
|
-
function resetSequence(name = "default", value = 0) {
|
|
59
|
-
if (sequences.has(name)) {
|
|
60
|
-
const counter = sequences.get(name);
|
|
61
|
-
counter.reset(value);
|
|
62
|
-
} else sequences.set(name, new AtomicCounter(value));
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Resets all sequence counters
|
|
66
|
-
*/
|
|
67
|
-
function resetAllSequences() {
|
|
68
|
-
sequences.clear();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Returns a random price number.
|
|
72
|
-
*/
|
|
73
|
-
function price() {
|
|
74
|
-
return +faker.commerce.price();
|
|
75
|
-
}
|
|
76
|
-
const faker = Object.freeze(Object.assign({}, __faker_js_faker.faker, {
|
|
77
|
-
timestamps,
|
|
78
|
-
identifier,
|
|
79
|
-
sequence,
|
|
80
|
-
resetSequence,
|
|
81
|
-
resetAllSequences,
|
|
82
|
-
price
|
|
83
|
-
}));
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
Object.defineProperty(exports, 'faker', {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function () {
|
|
89
|
-
return faker;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, 'identifier', {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () {
|
|
95
|
-
return identifier;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, 'resetAllSequences', {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return resetAllSequences;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(exports, 'resetSequence', {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function () {
|
|
107
|
-
return resetSequence;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(exports, 'sequence', {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
get: function () {
|
|
113
|
-
return sequence;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(exports, 'timestamps', {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function () {
|
|
119
|
-
return timestamps;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-Bx2c4OzK.cjs');
|
|
3
|
-
const require_VitestKyselyTransactionIsolator = require('./VitestKyselyTransactionIsolator-DWSTKIe3.cjs');
|
|
4
|
-
const kysely = require_chunk.__toESM(require("kysely"));
|
|
5
|
-
const pg = require_chunk.__toESM(require("pg"));
|
|
6
|
-
|
|
7
|
-
//#region src/helpers.ts
|
|
8
|
-
function wrapVitestKyselyTransaction(db, setup, level = require_VitestTransactionIsolator.IsolationLevel.REPEATABLE_READ) {
|
|
9
|
-
const wrapper = new require_VitestKyselyTransactionIsolator.VitestKyselyTransactionIsolator();
|
|
10
|
-
return wrapper.wrapVitestWithTransaction(db, setup, level);
|
|
11
|
-
}
|
|
12
|
-
function createKyselyDb(config) {
|
|
13
|
-
return new kysely.Kysely({
|
|
14
|
-
dialect: new kysely.PostgresDialect({ pool: new pg.default.Pool(config) }),
|
|
15
|
-
plugins: [new kysely.CamelCasePlugin()]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
Object.defineProperty(exports, 'createKyselyDb', {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return createKyselyDb;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, 'wrapVitestKyselyTransaction', {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return wrapVitestKyselyTransaction;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IsolationLevel } from "./VitestTransactionIsolator-BjVXqFs6.mjs";
|
|
2
|
-
import { VitestKyselyTransactionIsolator } from "./VitestKyselyTransactionIsolator-BS3R-V0I.mjs";
|
|
3
|
-
import { CamelCasePlugin, Kysely, PostgresDialect } from "kysely";
|
|
4
|
-
import pg from "pg";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers.ts
|
|
7
|
-
function wrapVitestKyselyTransaction(db, setup, level = IsolationLevel.REPEATABLE_READ) {
|
|
8
|
-
const wrapper = new VitestKyselyTransactionIsolator();
|
|
9
|
-
return wrapper.wrapVitestWithTransaction(db, setup, level);
|
|
10
|
-
}
|
|
11
|
-
function createKyselyDb(config) {
|
|
12
|
-
return new Kysely({
|
|
13
|
-
dialect: new PostgresDialect({ pool: new pg.Pool(config) }),
|
|
14
|
-
plugins: [new CamelCasePlugin()]
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { createKyselyDb, wrapVitestKyselyTransaction };
|
|
File without changes
|
|
File without changes
|