pg-seed 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +7 -114
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -16,99 +16,9 @@
16
16
  </a>
17
17
  </p>
18
18
 
19
- PostgreSQL seeding utilities for CSV, JSON, and SQL data loading.
19
+ Internal PostgreSQL seeding utilities used by `pgpm` and `pgsql-test`.
20
20
 
21
- > **Looking for pgpm integration?** Use [`pgsql-seed`](https://www.npmjs.com/package/pgsql-seed) instead - it re-exports everything from this package plus adds `deployPgpm`/`loadPgpm` for deploying pgpm packages.
22
-
23
- ## Installation
24
-
25
- ```bash
26
- npm install pg-seed
27
- # or
28
- pnpm add pg-seed
29
- ```
30
-
31
- ## Usage
32
-
33
- ### CSV Loading (COPY protocol)
34
-
35
- ```typescript
36
- import { Client } from 'pg';
37
- import { loadCsv, loadCsvMap, exportCsv } from 'pg-seed';
38
-
39
- const client = new Client();
40
- await client.connect();
41
-
42
- // Load a single CSV file
43
- await loadCsv(client, 'users', './data/users.csv');
44
-
45
- // Load multiple CSV files
46
- await loadCsvMap(client, {
47
- 'users': './data/users.csv',
48
- 'orders': './data/orders.csv'
49
- });
50
-
51
- // Export a table to CSV
52
- await exportCsv(client, 'users', './backup/users.csv');
53
- ```
54
-
55
- ### JSON Insertion
56
-
57
- ```typescript
58
- import { Client } from 'pg';
59
- import { insertJson, insertJsonMap } from 'pg-seed';
60
-
61
- const client = new Client();
62
- await client.connect();
63
-
64
- // Insert rows into a single table
65
- await insertJson(client, 'users', [
66
- { name: 'Alice', email: 'alice@example.com' },
67
- { name: 'Bob', email: 'bob@example.com' }
68
- ]);
69
-
70
- // Insert rows into multiple tables
71
- await insertJsonMap(client, {
72
- 'users': [{ name: 'Alice', email: 'alice@example.com' }],
73
- 'orders': [{ user_id: 1, total: 99.99 }]
74
- });
75
- ```
76
-
77
- ### SQL File Execution
78
-
79
- ```typescript
80
- import { Client } from 'pg';
81
- import { loadSql, loadSqlFiles, execSql } from 'pg-seed';
82
-
83
- const client = new Client();
84
- await client.connect();
85
-
86
- // Execute a single SQL file
87
- await loadSql(client, './migrations/001-schema.sql');
88
-
89
- // Execute multiple SQL files
90
- await loadSqlFiles(client, [
91
- './migrations/001-schema.sql',
92
- './migrations/002-data.sql'
93
- ]);
94
-
95
- // Execute a SQL string with parameters
96
- await execSql(client, 'INSERT INTO users (name) VALUES ($1)', ['Alice']);
97
- ```
98
-
99
- ## Client Compatibility
100
-
101
- All functions accept either a raw `pg.Client`/`pg.PoolClient` or any wrapper object that exposes a `.client` property containing the underlying pg client. This makes it compatible with testing utilities like `PgTestClient`.
102
-
103
- ```typescript
104
- // Works with raw pg.Client
105
- const client = new Client();
106
- await loadCsv(client, 'users', './data/users.csv');
107
-
108
- // Works with wrappers that have a .client property
109
- const testClient = new PgTestClient(config);
110
- await loadCsv(testClient, 'users', './data/users.csv');
111
- ```
21
+ For the public API and documentation, use [`pgsql-seed`](https://www.npmjs.com/package/pgsql-seed).
112
22
 
113
23
  ---
114
24
 
@@ -137,9 +47,14 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
137
47
 
138
48
  ## Related Constructive Tooling
139
49
 
50
+ ### 📦 Package Management
51
+
52
+ * [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
53
+
140
54
  ### 🧪 Testing
141
55
 
142
56
  * [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
57
+ * [pgsql-seed](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-seed): **🌱 PostgreSQL seeding utilities** for CSV, JSON, SQL data loading, and pgpm deployment.
143
58
  * [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
144
59
  * [graphile-test](https://github.com/constructive-io/constructive/tree/main/graphile/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
145
60
  * [pg-query-context](https://github.com/constructive-io/constructive/tree/main/postgres/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.
@@ -153,28 +68,6 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
153
68
  * [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
154
69
  * [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
155
70
 
156
- ### 🚀 API & Dev Tools
157
-
158
- * [@constructive-io/graphql-server](https://github.com/constructive-io/constructive/tree/main/graphql/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
159
- * [@constructive-io/graphql-explorer](https://github.com/constructive-io/constructive/tree/main/graphql/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
160
-
161
- ### 🔁 Streaming & Uploads
162
-
163
- * [etag-hash](https://github.com/constructive-io/constructive/tree/main/streaming/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
164
- * [etag-stream](https://github.com/constructive-io/constructive/tree/main/streaming/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
165
- * [uuid-hash](https://github.com/constructive-io/constructive/tree/main/streaming/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
166
- * [uuid-stream](https://github.com/constructive-io/constructive/tree/main/streaming/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
167
- * [@constructive-io/s3-streamer](https://github.com/constructive-io/constructive/tree/main/streaming/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
168
- * [@constructive-io/upload-names](https://github.com/constructive-io/constructive/tree/main/streaming/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
169
-
170
- ### 🧰 CLI & Codegen
171
-
172
- * [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
173
- * [@constructive-io/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing Constructive projects—supports database scaffolding, migrations, seeding, code generation, and automation.
174
- * [@constructive-io/graphql-codegen](https://github.com/constructive-io/constructive/tree/main/graphql/codegen): **✨ GraphQL code generation** (types, operations, SDK) from schema/endpoint introspection.
175
- * [@constructive-io/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.
176
- * [@constructive-io/graphql-query](https://github.com/constructive-io/constructive/tree/main/graphql/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
177
-
178
71
  ## Credits
179
72
 
180
73
  **🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-seed",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL seeding utilities for CSV, JSON, and SQL data loading",
6
6
  "main": "index.js",
@@ -51,5 +51,5 @@
51
51
  "pg": "^8.16.3",
52
52
  "pg-copy-streams": "^7.0.0"
53
53
  },
54
- "gitHead": "7ac931c063d48e281349b748ba2eb9c9f47ffb06"
54
+ "gitHead": "09721f934b339bd8c55d2e633abaded6d20b0f65"
55
55
  }