pgsql-test 2.4.0 → 2.6.0
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/admin.js +1 -1
- package/connect.d.ts +1 -1
- package/connect.js +3 -3
- package/esm/admin.js +1 -1
- package/esm/connect.js +3 -3
- package/esm/manager.js +2 -2
- package/esm/seed/csv.js +2 -2
- package/esm/seed/index.js +3 -3
- package/esm/seed/launchql.js +11 -12
- package/esm/seed/sqitch.js +9 -5
- package/esm/stream.js +1 -1
- package/manager.js +2 -2
- package/package.json +8 -9
- package/seed/adapters.d.ts +1 -1
- package/seed/csv.d.ts +1 -1
- package/seed/csv.js +2 -2
- package/seed/index.d.ts +3 -3
- package/seed/index.js +2 -2
- package/seed/json.d.ts +1 -1
- package/seed/launchql.js +10 -11
- package/seed/sqitch.js +8 -4
- package/seed/types.d.ts +4 -4
- package/stream.js +1 -1
package/README.md
CHANGED
|
@@ -422,7 +422,7 @@ This works for any Sqitch-compatible module, now accelerated by LaunchQL's deplo
|
|
|
422
422
|
|
|
423
423
|
## 🚀 LaunchQL Seeding
|
|
424
424
|
|
|
425
|
-
If your project uses LaunchQL modules with a precompiled `
|
|
425
|
+
If your project uses LaunchQL modules with a precompiled `launchql.plan`, you can use `pgsql-test` with **zero configuration**. Just call `getConnections()` — and it *just works*:
|
|
426
426
|
|
|
427
427
|
```ts
|
|
428
428
|
import { getConnections } from 'pgsql-test';
|
package/admin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DbAdmin = void 0;
|
|
4
|
+
const logger_1 = require("@launchql/logger");
|
|
4
5
|
const child_process_1 = require("child_process");
|
|
5
6
|
const fs_1 = require("fs");
|
|
6
7
|
const pg_env_1 = require("pg-env");
|
|
7
8
|
const stream_1 = require("./stream");
|
|
8
|
-
const logger_1 = require("@launchql/logger");
|
|
9
9
|
const log = new logger_1.Logger('db-admin');
|
|
10
10
|
class DbAdmin {
|
|
11
11
|
config;
|
package/connect.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DbAdmin } from './admin';
|
|
2
1
|
import { PgTestConnectionOptions } from '@launchql/types';
|
|
3
2
|
import { PgConfig } from 'pg-env';
|
|
3
|
+
import { DbAdmin } from './admin';
|
|
4
4
|
import { PgTestConnector } from './manager';
|
|
5
5
|
import { SeedAdapter } from './seed/types';
|
|
6
6
|
import { PgTestClient } from './test-client';
|
package/connect.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConnections = exports.getPgRootAdmin = void 0;
|
|
4
|
-
const admin_1 = require("./admin");
|
|
5
4
|
const types_1 = require("@launchql/types");
|
|
6
|
-
const pg_env_1 = require("pg-env");
|
|
7
|
-
const manager_1 = require("./manager");
|
|
8
5
|
const crypto_1 = require("crypto");
|
|
9
6
|
const pg_cache_1 = require("pg-cache");
|
|
7
|
+
const pg_env_1 = require("pg-env");
|
|
8
|
+
const admin_1 = require("./admin");
|
|
9
|
+
const manager_1 = require("./manager");
|
|
10
10
|
const seed_1 = require("./seed");
|
|
11
11
|
let manager;
|
|
12
12
|
const getPgRootAdmin = (connOpts = {}) => {
|
package/esm/admin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Logger } from '@launchql/logger';
|
|
1
2
|
import { execSync } from 'child_process';
|
|
2
3
|
import { existsSync } from 'fs';
|
|
3
4
|
import { getPgEnvOptions } from 'pg-env';
|
|
4
5
|
import { streamSql as stream } from './stream';
|
|
5
|
-
import { Logger } from '@launchql/logger';
|
|
6
6
|
const log = new Logger('db-admin');
|
|
7
7
|
export class DbAdmin {
|
|
8
8
|
config;
|
package/esm/connect.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DbAdmin } from './admin';
|
|
2
1
|
import { getConnEnvOptions } from '@launchql/types';
|
|
3
|
-
import { getPgEnvOptions, } from 'pg-env';
|
|
4
|
-
import { PgTestConnector } from './manager';
|
|
5
2
|
import { randomUUID } from 'crypto';
|
|
6
3
|
import { teardownPgPools } from 'pg-cache';
|
|
4
|
+
import { getPgEnvOptions, } from 'pg-env';
|
|
5
|
+
import { DbAdmin } from './admin';
|
|
6
|
+
import { PgTestConnector } from './manager';
|
|
7
7
|
import { seed } from './seed';
|
|
8
8
|
let manager;
|
|
9
9
|
export const getPgRootAdmin = (connOpts = {}) => {
|
package/esm/manager.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Logger } from '@launchql/logger';
|
|
1
2
|
import { Pool } from 'pg';
|
|
2
|
-
import { DbAdmin } from './admin';
|
|
3
3
|
import { getPgEnvOptions } from 'pg-env';
|
|
4
|
+
import { DbAdmin } from './admin';
|
|
4
5
|
import { PgTestClient } from './test-client';
|
|
5
|
-
import { Logger } from '@launchql/logger';
|
|
6
6
|
const log = new Logger('test-connector');
|
|
7
7
|
const SYS_EVENTS = ['SIGTERM'];
|
|
8
8
|
const end = (pool) => {
|
package/esm/seed/csv.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createReadStream, existsSync, createWriteStream } from 'fs';
|
|
2
1
|
import { pipeline } from 'node:stream/promises';
|
|
3
|
-
import { from as copyFrom, to as copyTo } from 'pg-copy-streams';
|
|
4
2
|
import { Logger } from '@launchql/logger';
|
|
3
|
+
import { createReadStream, createWriteStream, existsSync } from 'fs';
|
|
4
|
+
import { from as copyFrom, to as copyTo } from 'pg-copy-streams';
|
|
5
5
|
const log = new Logger('csv');
|
|
6
6
|
export function csv(tables) {
|
|
7
7
|
return {
|
package/esm/seed/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { fn, sqlfile
|
|
1
|
+
import { compose, fn, sqlfile } from './adapters';
|
|
2
2
|
import { csv } from './csv';
|
|
3
3
|
import { json } from './json';
|
|
4
|
-
import { sqitch } from './sqitch';
|
|
5
4
|
import { launchql } from './launchql';
|
|
6
|
-
|
|
5
|
+
import { sqitch } from './sqitch';
|
|
7
6
|
export * from './csv';
|
|
7
|
+
export * from './types';
|
|
8
8
|
export const seed = {
|
|
9
9
|
launchql,
|
|
10
10
|
sqitch,
|
package/esm/seed/launchql.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
+
import { getEnvOptions } from '@launchql/env';
|
|
3
3
|
export function launchql(cwd, cache = false) {
|
|
4
4
|
return {
|
|
5
5
|
async seed(ctx) {
|
|
6
|
-
const proj = new
|
|
6
|
+
const proj = new LaunchQLPackage(cwd ?? ctx.connect.cwd);
|
|
7
7
|
if (!proj.isInModule())
|
|
8
8
|
return;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
9
|
+
await proj.deploy(getEnvOptions({
|
|
10
|
+
pg: ctx.config,
|
|
11
|
+
deployment: {
|
|
12
|
+
fast: true,
|
|
13
|
+
usePlan: true,
|
|
14
|
+
cache
|
|
15
|
+
}
|
|
16
|
+
}), proj.getModuleName());
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
19
|
}
|
package/esm/seed/sqitch.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
+
import { getEnvOptions } from '@launchql/env';
|
|
3
3
|
export function sqitch(cwd) {
|
|
4
4
|
return {
|
|
5
5
|
async seed(ctx) {
|
|
6
|
-
const proj = new
|
|
6
|
+
const proj = new LaunchQLPackage(cwd ?? ctx.connect.cwd);
|
|
7
7
|
if (!proj.isInModule())
|
|
8
8
|
return;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
await proj.deploy(getEnvOptions({
|
|
10
|
+
pg: ctx.config,
|
|
11
|
+
deployment: {
|
|
12
|
+
fast: false
|
|
13
|
+
}
|
|
14
|
+
}), proj.getModuleName(), true);
|
|
11
15
|
}
|
|
12
16
|
};
|
|
13
17
|
}
|
package/esm/stream.js
CHANGED
package/manager.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PgTestConnector = void 0;
|
|
4
|
+
const logger_1 = require("@launchql/logger");
|
|
4
5
|
const pg_1 = require("pg");
|
|
5
|
-
const admin_1 = require("./admin");
|
|
6
6
|
const pg_env_1 = require("pg-env");
|
|
7
|
+
const admin_1 = require("./admin");
|
|
7
8
|
const test_client_1 = require("./test-client");
|
|
8
|
-
const logger_1 = require("@launchql/logger");
|
|
9
9
|
const log = new logger_1.Logger('test-connector');
|
|
10
10
|
const SYS_EVENTS = ['SIGTERM'];
|
|
11
11
|
const end = (pool) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "pgsql-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests — giving developers realistic test coverage without external state pollution",
|
|
6
6
|
"main": "index.js",
|
|
@@ -60,15 +60,14 @@
|
|
|
60
60
|
"@types/pg-copy-streams": "^1.2.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@launchql/core": "^2.
|
|
64
|
-
"@launchql/
|
|
65
|
-
"@launchql/
|
|
66
|
-
"
|
|
67
|
-
"deepmerge": "^4.3.1",
|
|
63
|
+
"@launchql/core": "^2.6.0",
|
|
64
|
+
"@launchql/env": "^2.2.0",
|
|
65
|
+
"@launchql/server-utils": "^2.2.0",
|
|
66
|
+
"@launchql/types": "^2.2.0",
|
|
68
67
|
"pg": "^8.16.0",
|
|
69
|
-
"pg-cache": "^1.0
|
|
68
|
+
"pg-cache": "^1.1.0",
|
|
70
69
|
"pg-copy-streams": "^6.0.6",
|
|
71
|
-
"pg-env": "^1.0
|
|
70
|
+
"pg-env": "^1.1.0"
|
|
72
71
|
},
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "cbf678ed3d22055b7d972468ca7f822b2662e7d0"
|
|
74
73
|
}
|
package/seed/adapters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SeedAdapter, SeedContext } from
|
|
1
|
+
import { SeedAdapter, SeedContext } from './types';
|
|
2
2
|
export declare function sqlfile(files: string[]): SeedAdapter;
|
|
3
3
|
export declare function fn(fn: (ctx: SeedContext) => Promise<void>): SeedAdapter;
|
|
4
4
|
export declare function compose(adapters: SeedAdapter[]): SeedAdapter;
|
package/seed/csv.d.ts
CHANGED
package/seed/csv.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.csv = csv;
|
|
4
4
|
exports.copyCsvIntoTable = copyCsvIntoTable;
|
|
5
5
|
exports.exportTableToCsv = exportTableToCsv;
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
6
|
const promises_1 = require("node:stream/promises");
|
|
8
|
-
const pg_copy_streams_1 = require("pg-copy-streams");
|
|
9
7
|
const logger_1 = require("@launchql/logger");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const pg_copy_streams_1 = require("pg-copy-streams");
|
|
10
10
|
const log = new logger_1.Logger('csv');
|
|
11
11
|
function csv(tables) {
|
|
12
12
|
return {
|
package/seed/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { fn, sqlfile
|
|
1
|
+
import { compose, fn, sqlfile } from './adapters';
|
|
2
2
|
import { csv } from './csv';
|
|
3
3
|
import { json } from './json';
|
|
4
|
-
import { sqitch } from './sqitch';
|
|
5
4
|
import { launchql } from './launchql';
|
|
6
|
-
|
|
5
|
+
import { sqitch } from './sqitch';
|
|
7
6
|
export * from './csv';
|
|
7
|
+
export * from './types';
|
|
8
8
|
export declare const seed: {
|
|
9
9
|
launchql: typeof launchql;
|
|
10
10
|
sqitch: typeof sqitch;
|
package/seed/index.js
CHANGED
|
@@ -18,10 +18,10 @@ exports.seed = void 0;
|
|
|
18
18
|
const adapters_1 = require("./adapters");
|
|
19
19
|
const csv_1 = require("./csv");
|
|
20
20
|
const json_1 = require("./json");
|
|
21
|
-
const sqitch_1 = require("./sqitch");
|
|
22
21
|
const launchql_1 = require("./launchql");
|
|
23
|
-
|
|
22
|
+
const sqitch_1 = require("./sqitch");
|
|
24
23
|
__exportStar(require("./csv"), exports);
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
25
|
exports.seed = {
|
|
26
26
|
launchql: launchql_1.launchql,
|
|
27
27
|
sqitch: sqitch_1.sqitch,
|
package/seed/json.d.ts
CHANGED
package/seed/launchql.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.launchql = launchql;
|
|
4
|
-
const types_1 = require("@launchql/types");
|
|
5
4
|
const core_1 = require("@launchql/core");
|
|
5
|
+
const env_1 = require("@launchql/env");
|
|
6
6
|
function launchql(cwd, cache = false) {
|
|
7
7
|
return {
|
|
8
8
|
async seed(ctx) {
|
|
9
|
-
const proj = new core_1.
|
|
9
|
+
const proj = new core_1.LaunchQLPackage(cwd ?? ctx.connect.cwd);
|
|
10
10
|
if (!proj.isInModule())
|
|
11
11
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
12
|
+
await proj.deploy((0, env_1.getEnvOptions)({
|
|
13
|
+
pg: ctx.config,
|
|
14
|
+
deployment: {
|
|
15
|
+
fast: true,
|
|
16
|
+
usePlan: true,
|
|
17
|
+
cache
|
|
18
|
+
}
|
|
19
|
+
}), proj.getModuleName());
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
22
|
}
|
package/seed/sqitch.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sqitch = sqitch;
|
|
4
|
-
const types_1 = require("@launchql/types");
|
|
5
4
|
const core_1 = require("@launchql/core");
|
|
5
|
+
const env_1 = require("@launchql/env");
|
|
6
6
|
function sqitch(cwd) {
|
|
7
7
|
return {
|
|
8
8
|
async seed(ctx) {
|
|
9
|
-
const proj = new core_1.
|
|
9
|
+
const proj = new core_1.LaunchQLPackage(cwd ?? ctx.connect.cwd);
|
|
10
10
|
if (!proj.isInModule())
|
|
11
11
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
await proj.deploy((0, env_1.getEnvOptions)({
|
|
13
|
+
pg: ctx.config,
|
|
14
|
+
deployment: {
|
|
15
|
+
fast: false
|
|
16
|
+
}
|
|
17
|
+
}), proj.getModuleName(), true);
|
|
14
18
|
}
|
|
15
19
|
};
|
|
16
20
|
}
|
package/seed/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PgTestConnectionOptions } from
|
|
2
|
-
import { PgConfig } from
|
|
3
|
-
import { DbAdmin } from
|
|
4
|
-
import { PgTestClient } from
|
|
1
|
+
import { PgTestConnectionOptions } from '@launchql/types';
|
|
2
|
+
import { PgConfig } from 'pg-env';
|
|
3
|
+
import { DbAdmin } from '../admin';
|
|
4
|
+
import { PgTestClient } from '../test-client';
|
|
5
5
|
export interface SeedContext {
|
|
6
6
|
connect: PgTestConnectionOptions;
|
|
7
7
|
admin: DbAdmin;
|
package/stream.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.streamSql = streamSql;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
-
const stream_1 = require("stream");
|
|
6
5
|
const pg_env_1 = require("pg-env");
|
|
6
|
+
const stream_1 = require("stream");
|
|
7
7
|
function setArgs(config) {
|
|
8
8
|
const args = [
|
|
9
9
|
'-U', config.user,
|