@geekmidas/testkit 0.0.6 → 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 +10 -10
- package/dist/__tests__/KyselyFactory.spec.mjs +10 -10
- 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 +10 -10
- package/dist/__tests__/integration.spec.mjs +10 -10
- 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 +1 -1
- package/dist/helpers.mjs +1 -1
- package/dist/kysely-B-GOhABm.cjs +72 -0
- package/dist/kysely-CqfoKVXs.mjs +67 -0
- package/dist/kysely.cjs +10 -8
- package/dist/kysely.mjs +9 -9
- 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 +95 -0
- package/src/faker.ts +158 -7
- package/src/helpers.ts +34 -0
- package/src/kysely.ts +63 -0
- 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-D-qpeVKO.mjs +0 -12
- package/dist/VitestKyselyTransactionIsolator-jF6Ohyu_.cjs +0 -17
- package/dist/VitestTransactionIsolator-BK9UsrKt.cjs +0 -53
- package/dist/VitestTransactionIsolator-e-R3p_X8.mjs +0 -41
- package/dist/faker-BwaXA_RF.mjs +0 -85
- package/dist/faker-caz-8zt8.cjs +0 -121
- package/dist/helpers-DN4sJO4i.mjs +0 -13
- package/dist/helpers-DOtYCEvZ.cjs +0 -19
- package/dist/kysely-C1-aHdnU.mjs +0 -11
- package/dist/kysely-DL3C2eM4.cjs +0 -16
- /package/dist/{helpers-B2CfbaTC.cjs → helpers-Bnm3Jy9X.cjs} +0 -0
- /package/dist/{helpers-Rf5F71r9.mjs → helpers-CukcFAU9.mjs} +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { PostgresMigrator } from "./PostgresMigrator-CEoRKTdq.mjs";
|
|
2
|
-
import { Migrator } from "kysely";
|
|
3
|
-
|
|
4
|
-
//#region src/PostgresKyselyMigrator.ts
|
|
5
|
-
const logger = console;
|
|
6
|
-
var PostgresKyselyMigrator = class extends PostgresMigrator {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
super(options.uri);
|
|
9
|
-
this.options = options;
|
|
10
|
-
}
|
|
11
|
-
async migrate() {
|
|
12
|
-
const migrator = new Migrator({
|
|
13
|
-
db: this.options.db,
|
|
14
|
-
provider: this.options.provider
|
|
15
|
-
});
|
|
16
|
-
const migrations = await migrator.migrateToLatest();
|
|
17
|
-
if (migrations.error) {
|
|
18
|
-
logger.error(migrations.error, `Failed to apply migrations`);
|
|
19
|
-
throw migrations.error;
|
|
20
|
-
}
|
|
21
|
-
await this.options.db.destroy();
|
|
22
|
-
logger.log(`Applied ${migrations.results?.length} migrations successfully`);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { PostgresKyselyMigrator };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_PostgresMigrator = require('./PostgresMigrator-Bz-tnjB6.cjs');
|
|
3
|
-
const kysely = require_chunk.__toESM(require("kysely"));
|
|
4
|
-
|
|
5
|
-
//#region src/PostgresKyselyMigrator.ts
|
|
6
|
-
const logger = console;
|
|
7
|
-
var PostgresKyselyMigrator = class extends require_PostgresMigrator.PostgresMigrator {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
super(options.uri);
|
|
10
|
-
this.options = options;
|
|
11
|
-
}
|
|
12
|
-
async migrate() {
|
|
13
|
-
const migrator = new kysely.Migrator({
|
|
14
|
-
db: this.options.db,
|
|
15
|
-
provider: this.options.provider
|
|
16
|
-
});
|
|
17
|
-
const migrations = await migrator.migrateToLatest();
|
|
18
|
-
if (migrations.error) {
|
|
19
|
-
logger.error(migrations.error, `Failed to apply migrations`);
|
|
20
|
-
throw migrations.error;
|
|
21
|
-
}
|
|
22
|
-
await this.options.db.destroy();
|
|
23
|
-
logger.log(`Applied ${migrations.results?.length} migrations successfully`);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
Object.defineProperty(exports, 'PostgresKyselyMigrator', {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return PostgresKyselyMigrator;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const pg = require_chunk.__toESM(require("pg"));
|
|
3
|
-
|
|
4
|
-
//#region src/PostgresMigrator.ts
|
|
5
|
-
async function setupClient(uri) {
|
|
6
|
-
const url = new URL(uri);
|
|
7
|
-
const db = new pg.Client({
|
|
8
|
-
user: url.username,
|
|
9
|
-
password: url.password,
|
|
10
|
-
host: url.hostname,
|
|
11
|
-
port: parseInt(url.port),
|
|
12
|
-
database: "postgres"
|
|
13
|
-
});
|
|
14
|
-
let database = url.pathname.slice(1);
|
|
15
|
-
if (database.includes("?")) database = database.substring(0, database.indexOf("?"));
|
|
16
|
-
return {
|
|
17
|
-
database,
|
|
18
|
-
db
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const logger = console;
|
|
22
|
-
var PostgresMigrator = class PostgresMigrator {
|
|
23
|
-
constructor(uri) {
|
|
24
|
-
this.uri = uri;
|
|
25
|
-
}
|
|
26
|
-
static async create(uri) {
|
|
27
|
-
const { database, db } = await setupClient(uri);
|
|
28
|
-
try {
|
|
29
|
-
await db.connect();
|
|
30
|
-
const result = await db.query(`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`);
|
|
31
|
-
if (result.rowCount === 0) await db.query(`CREATE DATABASE "${database}"`);
|
|
32
|
-
return { alreadyExisted: result.rowCount ? result.rowCount > 0 : false };
|
|
33
|
-
} finally {
|
|
34
|
-
await db.end();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
static async drop(uri) {
|
|
38
|
-
const { database, db } = await setupClient(uri);
|
|
39
|
-
try {
|
|
40
|
-
await db.connect();
|
|
41
|
-
await db.query(`DROP DATABASE "${database}"`);
|
|
42
|
-
} finally {
|
|
43
|
-
await db.end();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async start() {
|
|
47
|
-
const { database, db } = await setupClient(this.uri);
|
|
48
|
-
try {
|
|
49
|
-
await PostgresMigrator.create(this.uri);
|
|
50
|
-
await this.migrate();
|
|
51
|
-
logger.log(`Migrating database: ${database}`);
|
|
52
|
-
} finally {
|
|
53
|
-
await db.end();
|
|
54
|
-
}
|
|
55
|
-
return async () => {
|
|
56
|
-
await PostgresMigrator.drop(this.uri);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
//#endregion
|
|
62
|
-
Object.defineProperty(exports, 'PostgresMigrator', {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function () {
|
|
65
|
-
return PostgresMigrator;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Client } from "pg";
|
|
2
|
-
|
|
3
|
-
//#region src/PostgresMigrator.ts
|
|
4
|
-
async function setupClient(uri) {
|
|
5
|
-
const url = new URL(uri);
|
|
6
|
-
const db = new Client({
|
|
7
|
-
user: url.username,
|
|
8
|
-
password: url.password,
|
|
9
|
-
host: url.hostname,
|
|
10
|
-
port: parseInt(url.port),
|
|
11
|
-
database: "postgres"
|
|
12
|
-
});
|
|
13
|
-
let database = url.pathname.slice(1);
|
|
14
|
-
if (database.includes("?")) database = database.substring(0, database.indexOf("?"));
|
|
15
|
-
return {
|
|
16
|
-
database,
|
|
17
|
-
db
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const logger = console;
|
|
21
|
-
var PostgresMigrator = class PostgresMigrator {
|
|
22
|
-
constructor(uri) {
|
|
23
|
-
this.uri = uri;
|
|
24
|
-
}
|
|
25
|
-
static async create(uri) {
|
|
26
|
-
const { database, db } = await setupClient(uri);
|
|
27
|
-
try {
|
|
28
|
-
await db.connect();
|
|
29
|
-
const result = await db.query(`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`);
|
|
30
|
-
if (result.rowCount === 0) await db.query(`CREATE DATABASE "${database}"`);
|
|
31
|
-
return { alreadyExisted: result.rowCount ? result.rowCount > 0 : false };
|
|
32
|
-
} finally {
|
|
33
|
-
await db.end();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
static async drop(uri) {
|
|
37
|
-
const { database, db } = await setupClient(uri);
|
|
38
|
-
try {
|
|
39
|
-
await db.connect();
|
|
40
|
-
await db.query(`DROP DATABASE "${database}"`);
|
|
41
|
-
} finally {
|
|
42
|
-
await db.end();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async start() {
|
|
46
|
-
const { database, db } = await setupClient(this.uri);
|
|
47
|
-
try {
|
|
48
|
-
await PostgresMigrator.create(this.uri);
|
|
49
|
-
await this.migrate();
|
|
50
|
-
logger.log(`Migrating database: ${database}`);
|
|
51
|
-
} finally {
|
|
52
|
-
await db.end();
|
|
53
|
-
}
|
|
54
|
-
return async () => {
|
|
55
|
-
await PostgresMigrator.drop(this.uri);
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
export { PostgresMigrator };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { VitestPostgresTransactionIsolator } from "./VitestTransactionIsolator-e-R3p_X8.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/VitestKyselyTransactionIsolator.ts
|
|
4
|
-
var VitestKyselyTransactionIsolator = class extends 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
|
-
export { VitestKyselyTransactionIsolator };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-BK9UsrKt.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,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/VitestTransactionIsolator.ts
|
|
3
|
-
let IsolationLevel = /* @__PURE__ */ function(IsolationLevel$1) {
|
|
4
|
-
IsolationLevel$1["READ_UNCOMMITTED"] = "READ UNCOMMITTED";
|
|
5
|
-
IsolationLevel$1["READ_COMMITTED"] = "READ COMMITTED";
|
|
6
|
-
IsolationLevel$1["REPEATABLE_READ"] = "REPEATABLE READ";
|
|
7
|
-
IsolationLevel$1["SERIALIZABLE"] = "SERIALIZABLE";
|
|
8
|
-
return IsolationLevel$1;
|
|
9
|
-
}({});
|
|
10
|
-
var VitestPostgresTransactionIsolator = class {
|
|
11
|
-
constructor(api) {
|
|
12
|
-
this.api = api;
|
|
13
|
-
}
|
|
14
|
-
wrapVitestWithTransaction(conn, setup, level = IsolationLevel.REPEATABLE_READ) {
|
|
15
|
-
return this.api.extend({ trx: async ({}, use) => {
|
|
16
|
-
class TestRollback extends Error {
|
|
17
|
-
constructor() {
|
|
18
|
-
super("Test rollback");
|
|
19
|
-
this.name = "TestRollback";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
let testError;
|
|
23
|
-
try {
|
|
24
|
-
await this.transact(conn, level, async (transaction) => {
|
|
25
|
-
try {
|
|
26
|
-
await setup?.(transaction);
|
|
27
|
-
await use(transaction);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
testError = error;
|
|
30
|
-
}
|
|
31
|
-
throw new TestRollback();
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (!(error instanceof TestRollback)) throw error;
|
|
35
|
-
if (testError) throw testError;
|
|
36
|
-
}
|
|
37
|
-
} });
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
Object.defineProperty(exports, 'IsolationLevel', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return IsolationLevel;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, 'VitestPostgresTransactionIsolator', {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return VitestPostgresTransactionIsolator;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/VitestTransactionIsolator.ts
|
|
2
|
-
let IsolationLevel = /* @__PURE__ */ function(IsolationLevel$1) {
|
|
3
|
-
IsolationLevel$1["READ_UNCOMMITTED"] = "READ UNCOMMITTED";
|
|
4
|
-
IsolationLevel$1["READ_COMMITTED"] = "READ COMMITTED";
|
|
5
|
-
IsolationLevel$1["REPEATABLE_READ"] = "REPEATABLE READ";
|
|
6
|
-
IsolationLevel$1["SERIALIZABLE"] = "SERIALIZABLE";
|
|
7
|
-
return IsolationLevel$1;
|
|
8
|
-
}({});
|
|
9
|
-
var VitestPostgresTransactionIsolator = class {
|
|
10
|
-
constructor(api) {
|
|
11
|
-
this.api = api;
|
|
12
|
-
}
|
|
13
|
-
wrapVitestWithTransaction(conn, setup, level = IsolationLevel.REPEATABLE_READ) {
|
|
14
|
-
return this.api.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
|
-
export { IsolationLevel, VitestPostgresTransactionIsolator };
|
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,13 +0,0 @@
|
|
|
1
|
-
import { CamelCasePlugin, Kysely, PostgresDialect } from "kysely";
|
|
2
|
-
import pg from "pg";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers.ts
|
|
5
|
-
function createKyselyDb(config) {
|
|
6
|
-
return new Kysely({
|
|
7
|
-
dialect: new PostgresDialect({ pool: new pg.Pool(config) }),
|
|
8
|
-
plugins: [new CamelCasePlugin()]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { createKyselyDb };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const kysely = require_chunk.__toESM(require("kysely"));
|
|
3
|
-
const pg = require_chunk.__toESM(require("pg"));
|
|
4
|
-
|
|
5
|
-
//#region src/helpers.ts
|
|
6
|
-
function createKyselyDb(config) {
|
|
7
|
-
return new kysely.Kysely({
|
|
8
|
-
dialect: new kysely.PostgresDialect({ pool: new pg.default.Pool(config) }),
|
|
9
|
-
plugins: [new kysely.CamelCasePlugin()]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
Object.defineProperty(exports, 'createKyselyDb', {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return createKyselyDb;
|
|
18
|
-
}
|
|
19
|
-
});
|
package/dist/kysely-C1-aHdnU.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IsolationLevel } from "./VitestTransactionIsolator-e-R3p_X8.mjs";
|
|
2
|
-
import { VitestKyselyTransactionIsolator } from "./VitestKyselyTransactionIsolator-D-qpeVKO.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/kysely.ts
|
|
5
|
-
function wrapVitestKyselyTransaction(api, db, setup, level = IsolationLevel.REPEATABLE_READ) {
|
|
6
|
-
const wrapper = new VitestKyselyTransactionIsolator(api);
|
|
7
|
-
return wrapper.wrapVitestWithTransaction(db, setup, level);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { wrapVitestKyselyTransaction };
|
package/dist/kysely-DL3C2eM4.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const require_VitestTransactionIsolator = require('./VitestTransactionIsolator-BK9UsrKt.cjs');
|
|
2
|
-
const require_VitestKyselyTransactionIsolator = require('./VitestKyselyTransactionIsolator-jF6Ohyu_.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/kysely.ts
|
|
5
|
-
function wrapVitestKyselyTransaction(api, db, setup, level = require_VitestTransactionIsolator.IsolationLevel.REPEATABLE_READ) {
|
|
6
|
-
const wrapper = new require_VitestKyselyTransactionIsolator.VitestKyselyTransactionIsolator(api);
|
|
7
|
-
return wrapper.wrapVitestWithTransaction(db, setup, level);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
Object.defineProperty(exports, 'wrapVitestKyselyTransaction', {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return wrapVitestKyselyTransaction;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
File without changes
|
|
File without changes
|