@pgpmjs/core 4.4.0 → 4.5.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.
package/README.md CHANGED
@@ -49,9 +49,14 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
49
49
 
50
50
  ## Related Constructive Tooling
51
51
 
52
+ ### 📦 Package Management
53
+
54
+ * [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.
55
+
52
56
  ### 🧪 Testing
53
57
 
54
58
  * [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.
59
+ * [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.
55
60
  * [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.
56
61
  * [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.
57
62
  * [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.
@@ -65,28 +70,6 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
65
70
  * [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
66
71
  * [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
67
72
 
68
- ### 🚀 API & Dev Tools
69
-
70
- * [@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.
71
- * [@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.
72
-
73
- ### 🔁 Streaming & Uploads
74
-
75
- * [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.
76
- * [etag-stream](https://github.com/constructive-io/constructive/tree/main/streaming/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
77
- * [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.
78
- * [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.
79
- * [@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.
80
- * [@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.
81
-
82
- ### 🧰 CLI & Codegen
83
-
84
- * [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.
85
- * [@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.
86
- * [@constructive-io/graphql-codegen](https://github.com/constructive-io/constructive/tree/main/graphql/codegen): **✨ GraphQL code generation** (types, operations, SDK) from schema/endpoint introspection.
87
- * [@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.
88
- * [@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.
89
-
90
73
  ## Credits
91
74
 
92
75
  **🛠 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).**
@@ -24,7 +24,7 @@ const filterStatements = (stmts, extension) => {
24
24
  !stmt.hasOwnProperty('CreateExtensionStmt');
25
25
  });
26
26
  };
27
- export const packageModule = async (packageDir, { usePlan = true, extension = true, pretty = true, functionDelimiter = '$EOFCODE$' } = {}) => {
27
+ export const packageModule = async (packageDir, { usePlan = true, extension = true, pretty = true, functionDelimiter = '$EOFCODE$', outputDiff = false } = {}) => {
28
28
  const resolveFn = usePlan ? resolveWithPlan : resolve;
29
29
  const sql = resolveFn(packageDir);
30
30
  if (!sql?.trim()) {
@@ -43,7 +43,8 @@ export const packageModule = async (packageDir, { usePlan = true, extension = tr
43
43
  functionDelimiter
44
44
  });
45
45
  const tree1 = parsed.stmts;
46
- const tree2 = await parse(finalSql);
46
+ const reparsed = await parse(finalSql);
47
+ const tree2 = filterStatements(reparsed.stmts, extension);
47
48
  const results = {
48
49
  sql: `${topLine}${finalSql}`,
49
50
  };
@@ -61,7 +62,7 @@ export const packageModule = async (packageDir, { usePlan = true, extension = tr
61
62
  throw e;
62
63
  }
63
64
  };
64
- export const writePackage = async ({ version, extension = true, usePlan = true, packageDir, }) => {
65
+ export const writePackage = async ({ version, extension = true, usePlan = true, packageDir, outputDiff = false, }) => {
65
66
  const pkgPath = `${packageDir}/package.json`;
66
67
  const pkg = require(pkgPath);
67
68
  const extname = await getExtensionName(packageDir);
@@ -73,6 +74,7 @@ export const writePackage = async ({ version, extension = true, usePlan = true,
73
74
  const { sql, diff, tree1, tree2 } = await packageModule(packageDir, {
74
75
  extension,
75
76
  usePlan,
77
+ outputDiff,
76
78
  });
77
79
  const outPath = extension ? `${packageDir}/sql` : `${packageDir}/out`;
78
80
  rmSync(outPath, { recursive: true, force: true });
@@ -85,10 +87,14 @@ export const writePackage = async ({ version, extension = true, usePlan = true,
85
87
  writeFileSync(makePath, Makefile.replace(regex, sqlFileName));
86
88
  }
87
89
  if (diff) {
88
- log.warn(`⚠️ SQL diff exists! Review the ${relative(packageDir, outPath)}/ folder.`);
89
- // Uncomment if needed:
90
- // writeFileSync(`${outPath}/orig.${sqlFileName}.tree.json`, tree1);
91
- // writeFileSync(`${outPath}/parsed.${sqlFileName}.tree.json`, tree2);
90
+ if (outputDiff) {
91
+ writeFileSync(`${outPath}/orig.${sqlFileName}.tree.json`, tree1);
92
+ writeFileSync(`${outPath}/parsed.${sqlFileName}.tree.json`, tree2);
93
+ log.warn(`⚠️ AST round-trip diff detected! Diff files written to ${relative(packageDir, outPath)}/`);
94
+ }
95
+ else {
96
+ log.warn(`⚠️ AST round-trip diff detected! Run with --outputDiff to export the AST diff files.`);
97
+ }
92
98
  }
93
99
  const writePath = `${outPath}/${sqlFileName}`;
94
100
  writeFileSync(writePath, sql);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/core",
3
- "version": "4.4.0",
3
+ "version": "4.5.1",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PGPM Package and Migration Tools",
6
6
  "main": "index.js",
@@ -44,7 +44,7 @@
44
44
  "@pgsql/types": "^17.6.2",
45
45
  "@types/pg": "^8.16.0",
46
46
  "copyfiles": "^2.4.1",
47
- "inquirerer": "^4.1.2",
47
+ "inquirerer": "^4.2.0",
48
48
  "makage": "^0.1.9"
49
49
  },
50
50
  "dependencies": {
@@ -52,8 +52,8 @@
52
52
  "@pgpmjs/logger": "^1.3.5",
53
53
  "@pgpmjs/server-utils": "^2.8.11",
54
54
  "@pgpmjs/types": "^2.12.8",
55
- "csv-to-pg": "^3.2.1",
56
- "genomic": "^5.0.3",
55
+ "csv-to-pg": "^3.3.0",
56
+ "genomic": "^5.2.0",
57
57
  "glob": "^13.0.0",
58
58
  "komoji": "^0.7.11",
59
59
  "parse-package-name": "^1.0.0",
@@ -64,5 +64,5 @@
64
64
  "pgsql-parser": "^17.9.5",
65
65
  "yanse": "^0.1.8"
66
66
  },
67
- "gitHead": "bda56442f70c77c98276bc7bab0450308c975df8"
67
+ "gitHead": "6883e3b93da28078483bc6aa25862613ef4405b2"
68
68
  }
@@ -4,16 +4,17 @@ interface PackageModuleOptions {
4
4
  extension?: boolean;
5
5
  pretty?: boolean;
6
6
  functionDelimiter?: string;
7
+ outputDiff?: boolean;
7
8
  }
8
9
  interface WritePackageOptions extends PackageModuleOptions {
9
10
  version: string;
10
11
  packageDir: string;
11
12
  }
12
- export declare const packageModule: (packageDir: string, { usePlan, extension, pretty, functionDelimiter }?: PackageModuleOptions) => Promise<{
13
+ export declare const packageModule: (packageDir: string, { usePlan, extension, pretty, functionDelimiter, outputDiff }?: PackageModuleOptions) => Promise<{
13
14
  sql: string;
14
15
  diff?: boolean;
15
16
  tree1?: string;
16
17
  tree2?: string;
17
18
  }>;
18
- export declare const writePackage: ({ version, extension, usePlan, packageDir, }: WritePackageOptions) => Promise<void>;
19
+ export declare const writePackage: ({ version, extension, usePlan, packageDir, outputDiff, }: WritePackageOptions) => Promise<void>;
19
20
  export {};
@@ -28,7 +28,7 @@ const filterStatements = (stmts, extension) => {
28
28
  !stmt.hasOwnProperty('CreateExtensionStmt');
29
29
  });
30
30
  };
31
- const packageModule = async (packageDir, { usePlan = true, extension = true, pretty = true, functionDelimiter = '$EOFCODE$' } = {}) => {
31
+ const packageModule = async (packageDir, { usePlan = true, extension = true, pretty = true, functionDelimiter = '$EOFCODE$', outputDiff = false } = {}) => {
32
32
  const resolveFn = usePlan ? resolve_1.resolveWithPlan : resolve_1.resolve;
33
33
  const sql = resolveFn(packageDir);
34
34
  if (!sql?.trim()) {
@@ -47,7 +47,8 @@ const packageModule = async (packageDir, { usePlan = true, extension = true, pre
47
47
  functionDelimiter
48
48
  });
49
49
  const tree1 = parsed.stmts;
50
- const tree2 = await (0, pgsql_parser_1.parse)(finalSql);
50
+ const reparsed = await (0, pgsql_parser_1.parse)(finalSql);
51
+ const tree2 = filterStatements(reparsed.stmts, extension);
51
52
  const results = {
52
53
  sql: `${topLine}${finalSql}`,
53
54
  };
@@ -66,7 +67,7 @@ const packageModule = async (packageDir, { usePlan = true, extension = true, pre
66
67
  }
67
68
  };
68
69
  exports.packageModule = packageModule;
69
- const writePackage = async ({ version, extension = true, usePlan = true, packageDir, }) => {
70
+ const writePackage = async ({ version, extension = true, usePlan = true, packageDir, outputDiff = false, }) => {
70
71
  const pkgPath = `${packageDir}/package.json`;
71
72
  const pkg = require(pkgPath);
72
73
  const extname = await (0, files_1.getExtensionName)(packageDir);
@@ -78,6 +79,7 @@ const writePackage = async ({ version, extension = true, usePlan = true, package
78
79
  const { sql, diff, tree1, tree2 } = await (0, exports.packageModule)(packageDir, {
79
80
  extension,
80
81
  usePlan,
82
+ outputDiff,
81
83
  });
82
84
  const outPath = extension ? `${packageDir}/sql` : `${packageDir}/out`;
83
85
  (0, fs_1.rmSync)(outPath, { recursive: true, force: true });
@@ -90,10 +92,14 @@ const writePackage = async ({ version, extension = true, usePlan = true, package
90
92
  (0, fs_1.writeFileSync)(makePath, Makefile.replace(regex, sqlFileName));
91
93
  }
92
94
  if (diff) {
93
- log.warn(`⚠️ SQL diff exists! Review the ${(0, path_1.relative)(packageDir, outPath)}/ folder.`);
94
- // Uncomment if needed:
95
- // writeFileSync(`${outPath}/orig.${sqlFileName}.tree.json`, tree1);
96
- // writeFileSync(`${outPath}/parsed.${sqlFileName}.tree.json`, tree2);
95
+ if (outputDiff) {
96
+ (0, fs_1.writeFileSync)(`${outPath}/orig.${sqlFileName}.tree.json`, tree1);
97
+ (0, fs_1.writeFileSync)(`${outPath}/parsed.${sqlFileName}.tree.json`, tree2);
98
+ log.warn(`⚠️ AST round-trip diff detected! Diff files written to ${(0, path_1.relative)(packageDir, outPath)}/`);
99
+ }
100
+ else {
101
+ log.warn(`⚠️ AST round-trip diff detected! Run with --outputDiff to export the AST diff files.`);
102
+ }
97
103
  }
98
104
  const writePath = `${outPath}/${sqlFileName}`;
99
105
  (0, fs_1.writeFileSync)(writePath, sql);