pgsql-test 2.14.13 → 2.14.15
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/LICENSE +1 -1
- package/README.md +38 -38
- package/esm/utils.js +31 -9
- package/package.json +12 -12
- package/utils.d.ts +8 -1
- package/utils.js +37 -12
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
|
|
4
|
-
Copyright (c) 2025
|
|
4
|
+
Copyright (c) 2025 Constructive <developers@constructive.io>
|
|
5
5
|
Copyright (c) 2020-present, Interweb, Inc.
|
|
6
6
|
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# pgsql-test
|
|
2
2
|
|
|
3
3
|
<p align="center" width="100%">
|
|
4
|
-
<img height="250" src="https://raw.githubusercontent.com/
|
|
4
|
+
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center" width="100%">
|
|
8
|
-
<a href="https://github.com/
|
|
9
|
-
<img height="20" src="https://github.com/
|
|
8
|
+
<a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml">
|
|
9
|
+
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
|
|
10
10
|
</a>
|
|
11
|
-
<a href="https://github.com/
|
|
11
|
+
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE">
|
|
12
12
|
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
|
|
13
13
|
</a>
|
|
14
14
|
<a href="https://www.npmjs.com/package/pgsql-test">
|
|
@@ -35,7 +35,7 @@ npm install pgsql-test
|
|
|
35
35
|
|
|
36
36
|
### Tutorials
|
|
37
37
|
|
|
38
|
-
📚 **[Learn how to test PG with pgsql-test →](https://
|
|
38
|
+
📚 **[Learn how to test PG with pgsql-test →](https://constructive.io/learn/e2e-postgres-testing)**
|
|
39
39
|
|
|
40
40
|
### Using with Supabase
|
|
41
41
|
|
|
@@ -673,71 +673,71 @@ const sanitized = pruneDates(pruneIds(row));
|
|
|
673
673
|
|
|
674
674
|
## Education and Tutorials
|
|
675
675
|
|
|
676
|
-
1. 🚀 [Quickstart: Getting Up and Running](https://
|
|
676
|
+
1. 🚀 [Quickstart: Getting Up and Running](https://constructive.io/learn/quickstart)
|
|
677
677
|
Get started with modular databases in minutes. Install prerequisites and deploy your first module.
|
|
678
678
|
|
|
679
|
-
2. 📦 [Modular PostgreSQL Development with Database Packages](https://
|
|
679
|
+
2. 📦 [Modular PostgreSQL Development with Database Packages](https://constructive.io/learn/modular-postgres)
|
|
680
680
|
Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.
|
|
681
681
|
|
|
682
|
-
3. ✏️ [Authoring Database Changes](https://
|
|
682
|
+
3. ✏️ [Authoring Database Changes](https://constructive.io/learn/authoring-database-changes)
|
|
683
683
|
Master the workflow for adding, organizing, and managing database changes with pgpm.
|
|
684
684
|
|
|
685
|
-
4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://
|
|
685
|
+
4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://constructive.io/learn/e2e-postgres-testing)
|
|
686
686
|
Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
|
|
687
687
|
|
|
688
|
-
5. ⚡ [Supabase Testing](https://
|
|
688
|
+
5. ⚡ [Supabase Testing](https://constructive.io/learn/supabase)
|
|
689
689
|
Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.
|
|
690
690
|
|
|
691
|
-
6. 💧 [Drizzle ORM Testing](https://
|
|
691
|
+
6. 💧 [Drizzle ORM Testing](https://constructive.io/learn/drizzle-testing)
|
|
692
692
|
Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.
|
|
693
693
|
|
|
694
|
-
7. 🔧 [Troubleshooting](https://
|
|
694
|
+
7. 🔧 [Troubleshooting](https://constructive.io/learn/troubleshooting)
|
|
695
695
|
Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
696
696
|
|
|
697
|
-
## Related
|
|
697
|
+
## Related Constructive Tooling
|
|
698
698
|
|
|
699
699
|
### 🧪 Testing
|
|
700
700
|
|
|
701
|
-
* [
|
|
702
|
-
* [
|
|
703
|
-
* [
|
|
704
|
-
* [
|
|
701
|
+
* [pgsql-test](https://github.com/constructive-io/constructive/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
702
|
+
* [supabase-test](https://github.com/constructive-io/constructive/tree/main/packages/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
|
|
703
|
+
* [graphile-test](https://github.com/constructive-io/constructive/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
|
|
704
|
+
* [pg-query-context](https://github.com/constructive-io/constructive/tree/main/packages/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
|
|
705
705
|
|
|
706
706
|
### 🧠 Parsing & AST
|
|
707
707
|
|
|
708
|
-
* [
|
|
709
|
-
* [
|
|
710
|
-
* [
|
|
711
|
-
* [@pgsql/enums](https://
|
|
712
|
-
* [@pgsql/types](https://
|
|
713
|
-
* [@pgsql/utils](https://
|
|
714
|
-
* [
|
|
708
|
+
* [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
|
|
709
|
+
* [libpg-query-node](https://www.npmjs.com/package/libpg-query): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
|
|
710
|
+
* [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
|
|
711
|
+
* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
|
|
712
|
+
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
|
|
713
|
+
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
|
|
714
|
+
* [pg-ast](https://www.npmjs.com/package/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
|
|
715
715
|
|
|
716
716
|
### 🚀 API & Dev Tools
|
|
717
717
|
|
|
718
|
-
* [launchql/server](https://github.com/
|
|
719
|
-
* [launchql/explorer](https://github.com/
|
|
718
|
+
* [launchql/server](https://github.com/constructive-io/constructive/tree/main/packages/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
|
|
719
|
+
* [launchql/explorer](https://github.com/constructive-io/constructive/tree/main/packages/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
|
|
720
720
|
|
|
721
721
|
### 🔁 Streaming & Uploads
|
|
722
722
|
|
|
723
|
-
* [launchql/s3-streamer](https://github.com/
|
|
724
|
-
* [launchql/etag-hash](https://github.com/
|
|
725
|
-
* [launchql/etag-stream](https://github.com/
|
|
726
|
-
* [launchql/uuid-hash](https://github.com/
|
|
727
|
-
* [launchql/uuid-stream](https://github.com/
|
|
728
|
-
* [launchql/upload-names](https://github.com/
|
|
723
|
+
* [launchql/s3-streamer](https://github.com/constructive-io/constructive/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
|
|
724
|
+
* [launchql/etag-hash](https://github.com/constructive-io/constructive/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
|
|
725
|
+
* [launchql/etag-stream](https://github.com/constructive-io/constructive/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
726
|
+
* [launchql/uuid-hash](https://github.com/constructive-io/constructive/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
|
|
727
|
+
* [launchql/uuid-stream](https://github.com/constructive-io/constructive/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
|
|
728
|
+
* [launchql/upload-names](https://github.com/constructive-io/constructive/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
|
|
729
729
|
|
|
730
730
|
### 🧰 CLI & Codegen
|
|
731
731
|
|
|
732
|
-
* [pgpm](https://github.com/
|
|
733
|
-
* [@launchql/cli](https://github.com/
|
|
734
|
-
* [launchql/launchql-gen](https://github.com/
|
|
735
|
-
* [@launchql/query-builder](https://github.com/
|
|
736
|
-
* [@launchql/query](https://github.com/
|
|
732
|
+
* [pgpm](https://github.com/constructive-io/constructive/tree/main/packages/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
733
|
+
* [@launchql/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation.
|
|
734
|
+
* [launchql/launchql-gen](https://github.com/constructive-io/constructive/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data.
|
|
735
|
+
* [@launchql/query-builder](https://github.com/constructive-io/constructive/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
|
|
736
|
+
* [@launchql/query](https://github.com/constructive-io/constructive/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
|
|
737
737
|
|
|
738
738
|
## Credits
|
|
739
739
|
|
|
740
|
-
🛠 Built by
|
|
740
|
+
🛠 Built by Constructive — if you like our tools, please checkout and contribute to [our github ⚛️](https://github.com/constructive-io)
|
|
741
741
|
|
|
742
742
|
|
|
743
743
|
## Disclaimer
|
package/esm/utils.js
CHANGED
|
@@ -45,13 +45,35 @@ export const pruneHashes = (row) => mapValues(row, (v, k) => typeof k === 'strin
|
|
|
45
45
|
v.startsWith('$')
|
|
46
46
|
? '[hash]'
|
|
47
47
|
: v);
|
|
48
|
-
export const
|
|
49
|
-
export const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
export const pruneSchemas = (row) => mapValues(row, (v, k) => typeof v === 'string' && /^zz-/.test(v) ? '[schemahash]' : v);
|
|
49
|
+
export const prunePeoplestamps = (row) => mapValues(row, (v, k) => k.endsWith('_by') && typeof v === 'string' ? '[peoplestamp]' : v);
|
|
50
|
+
export const pruneTokens = (row) => mapValues(row, (v, k) => (k === 'token' || k.endsWith('_token')) && typeof v === 'string'
|
|
51
|
+
? '[token]'
|
|
52
|
+
: v);
|
|
53
|
+
export const composePruners = (...pruners) => (row) => pruners.reduce((acc, pruner) => pruner(acc), row);
|
|
54
|
+
// Default pruners used by prune/snapshot
|
|
55
|
+
export const defaultPruners = [
|
|
56
|
+
pruneTokens,
|
|
57
|
+
prunePeoplestamps,
|
|
58
|
+
pruneDates,
|
|
59
|
+
pruneIdArrays,
|
|
60
|
+
pruneIds,
|
|
61
|
+
pruneUUIDs,
|
|
62
|
+
pruneHashes
|
|
63
|
+
];
|
|
64
|
+
export const prune = composePruners(...defaultPruners);
|
|
65
|
+
// Factory to create a snapshot function with custom pruners
|
|
66
|
+
export const createSnapshot = (pruners) => {
|
|
67
|
+
const pruneFn = composePruners(...pruners);
|
|
68
|
+
const snap = (obj) => {
|
|
69
|
+
if (Array.isArray(obj)) {
|
|
70
|
+
return obj.map(snap);
|
|
71
|
+
}
|
|
72
|
+
else if (obj && typeof obj === 'object') {
|
|
73
|
+
return mapValues(pruneFn(obj), snap);
|
|
74
|
+
}
|
|
75
|
+
return obj;
|
|
76
|
+
};
|
|
77
|
+
return snap;
|
|
57
78
|
};
|
|
79
|
+
export const snapshot = createSnapshot(defaultPruners);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-test",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.15",
|
|
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",
|
|
7
7
|
"module": "esm/index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
9
|
-
"homepage": "https://github.com/
|
|
9
|
+
"homepage": "https://github.com/constructive-io/constructive",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/constructive-io/constructive"
|
|
18
18
|
},
|
|
19
19
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "https://github.com/constructive-io/constructive/issues"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"postgres",
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"makage": "^0.1.8"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@launchql/core": "^2.17.
|
|
64
|
-
"@launchql/env": "^2.5.
|
|
65
|
-
"@launchql/logger": "^1.1.
|
|
66
|
-
"@launchql/server-utils": "^2.6.
|
|
67
|
-
"@launchql/types": "^2.8.
|
|
63
|
+
"@launchql/core": "^2.17.7",
|
|
64
|
+
"@launchql/env": "^2.5.7",
|
|
65
|
+
"@launchql/logger": "^1.1.13",
|
|
66
|
+
"@launchql/server-utils": "^2.6.9",
|
|
67
|
+
"@launchql/types": "^2.8.7",
|
|
68
68
|
"csv-parse": "^6.1.0",
|
|
69
69
|
"pg": "^8.16.0",
|
|
70
|
-
"pg-cache": "^1.4.
|
|
70
|
+
"pg-cache": "^1.4.9",
|
|
71
71
|
"pg-copy-streams": "^7.0.0",
|
|
72
|
-
"pg-env": "^1.1.
|
|
72
|
+
"pg-env": "^1.1.8"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "5a0d7c7502624bd42a214f983fd7ab957e1fb3e3"
|
|
75
75
|
}
|
package/utils.d.ts
CHANGED
|
@@ -4,6 +4,13 @@ export declare const pruneIds: (row: AnyObject) => AnyObject;
|
|
|
4
4
|
export declare const pruneIdArrays: (row: AnyObject) => AnyObject;
|
|
5
5
|
export declare const pruneUUIDs: (row: AnyObject) => AnyObject;
|
|
6
6
|
export declare const pruneHashes: (row: AnyObject) => AnyObject;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const pruneSchemas: (row: AnyObject) => AnyObject;
|
|
8
|
+
export declare const prunePeoplestamps: (row: AnyObject) => AnyObject;
|
|
9
|
+
export declare const pruneTokens: (row: AnyObject) => AnyObject;
|
|
10
|
+
type Pruner = (row: AnyObject) => AnyObject;
|
|
11
|
+
export declare const composePruners: (...pruners: Pruner[]) => Pruner;
|
|
12
|
+
export declare const defaultPruners: Pruner[];
|
|
13
|
+
export declare const prune: Pruner;
|
|
14
|
+
export declare const createSnapshot: (pruners: Pruner[]) => (obj: unknown) => unknown;
|
|
8
15
|
export declare const snapshot: (obj: unknown) => unknown;
|
|
9
16
|
export {};
|
package/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.snapshot = exports.prune = exports.pruneHashes = exports.pruneUUIDs = exports.pruneIdArrays = exports.pruneIds = exports.pruneDates = void 0;
|
|
3
|
+
exports.snapshot = exports.createSnapshot = exports.prune = exports.defaultPruners = exports.composePruners = exports.pruneTokens = exports.prunePeoplestamps = exports.pruneSchemas = exports.pruneHashes = exports.pruneUUIDs = exports.pruneIdArrays = exports.pruneIds = exports.pruneDates = void 0;
|
|
4
4
|
const uuidRegexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
5
|
const idReplacement = (v) => (!v ? v : '[ID]');
|
|
6
6
|
function mapValues(obj, fn) {
|
|
@@ -53,15 +53,40 @@ const pruneHashes = (row) => mapValues(row, (v, k) => typeof k === 'string' &&
|
|
|
53
53
|
? '[hash]'
|
|
54
54
|
: v);
|
|
55
55
|
exports.pruneHashes = pruneHashes;
|
|
56
|
-
const
|
|
57
|
-
exports.
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
const pruneSchemas = (row) => mapValues(row, (v, k) => typeof v === 'string' && /^zz-/.test(v) ? '[schemahash]' : v);
|
|
57
|
+
exports.pruneSchemas = pruneSchemas;
|
|
58
|
+
const prunePeoplestamps = (row) => mapValues(row, (v, k) => k.endsWith('_by') && typeof v === 'string' ? '[peoplestamp]' : v);
|
|
59
|
+
exports.prunePeoplestamps = prunePeoplestamps;
|
|
60
|
+
const pruneTokens = (row) => mapValues(row, (v, k) => (k === 'token' || k.endsWith('_token')) && typeof v === 'string'
|
|
61
|
+
? '[token]'
|
|
62
|
+
: v);
|
|
63
|
+
exports.pruneTokens = pruneTokens;
|
|
64
|
+
const composePruners = (...pruners) => (row) => pruners.reduce((acc, pruner) => pruner(acc), row);
|
|
65
|
+
exports.composePruners = composePruners;
|
|
66
|
+
// Default pruners used by prune/snapshot
|
|
67
|
+
exports.defaultPruners = [
|
|
68
|
+
exports.pruneTokens,
|
|
69
|
+
exports.prunePeoplestamps,
|
|
70
|
+
exports.pruneDates,
|
|
71
|
+
exports.pruneIdArrays,
|
|
72
|
+
exports.pruneIds,
|
|
73
|
+
exports.pruneUUIDs,
|
|
74
|
+
exports.pruneHashes
|
|
75
|
+
];
|
|
76
|
+
exports.prune = (0, exports.composePruners)(...exports.defaultPruners);
|
|
77
|
+
// Factory to create a snapshot function with custom pruners
|
|
78
|
+
const createSnapshot = (pruners) => {
|
|
79
|
+
const pruneFn = (0, exports.composePruners)(...pruners);
|
|
80
|
+
const snap = (obj) => {
|
|
81
|
+
if (Array.isArray(obj)) {
|
|
82
|
+
return obj.map(snap);
|
|
83
|
+
}
|
|
84
|
+
else if (obj && typeof obj === 'object') {
|
|
85
|
+
return mapValues(pruneFn(obj), snap);
|
|
86
|
+
}
|
|
87
|
+
return obj;
|
|
88
|
+
};
|
|
89
|
+
return snap;
|
|
66
90
|
};
|
|
67
|
-
exports.
|
|
91
|
+
exports.createSnapshot = createSnapshot;
|
|
92
|
+
exports.snapshot = (0, exports.createSnapshot)(exports.defaultPruners);
|