pg-codegen 2.1.5 → 2.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-codegen",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "PostgreSQL Codegen",
6
6
  "main": "index.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "keywords": [
34
34
  "codegen",
35
- "graphql",
35
+ "PostgreSQL",
36
36
  "typescript",
37
37
  "launchql",
38
38
  "generator"
@@ -40,12 +40,13 @@
40
40
  "dependencies": {
41
41
  "@babel/generator": "^7.26.3",
42
42
  "@babel/types": "^7.26.3",
43
- "@launchql/types": "^2.1.6",
44
43
  "@launchql/server-utils": "^2.1.8",
44
+ "@launchql/types": "^2.1.6",
45
45
  "pg": "^8.16.0",
46
46
  "pgsql-test": "^2.1.14"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/pg": "^8.15.2"
50
- }
50
+ },
51
+ "gitHead": "df27bf519afe1602d8e7c2ab6fbaf3fc447c158d"
51
52
  }
package/dist/README.md DELETED
@@ -1,144 +0,0 @@
1
- # pg-codegen
2
-
3
- <p align="center" width="100%">
4
- <img height="250" src="https://raw.githubusercontent.com/launchql/launchql/refs/heads/main/assets/outline-logo.svg" />
5
- </p>
6
-
7
- <p align="center" width="100%">
8
- <a href="https://github.com/launchql/launchql/actions/workflows/run-tests.yaml">
9
- <img height="20" src="https://github.com/launchql/launchql/actions/workflows/run-tests.yaml/badge.svg" />
10
- </a>
11
- <a href="https://github.com/launchql/launchql/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12
- <a href="https://www.npmjs.com/package/pg-codegen"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql?filename=packages%2Fcodegen%2Fpackage.json"/></a>
13
- </p>
14
-
15
- Generate fully-typed TypeScript classes and interfaces from a live PostgreSQL schema via introspection.
16
-
17
- > Converts your PostgreSQL tables into idiomatic TypeScript code — fast, predictable, and schema-aware.
18
-
19
- ---
20
-
21
- ## ✨ Features
22
-
23
- 🧠 **Intelligent Introspection**
24
- Pulls schema structure using native SQL introspection — no GraphQL required.
25
-
26
- 🧱 **Interface + Class Output**
27
- Generates matching `interface` + `class` pairs for each table using PascalCase naming.
28
-
29
- 🧹 **Schema-Aware Output**
30
- Writes files into `schemas/<schema>.ts`, grouped and re-exported from an `index.ts`.
31
-
32
- 🔗 **Type Mapping for Postgres Primitives**
33
- Supports `UUID`, `Timestamp`, `Boolean`, `Text`, `Int`, and nullable detection.
34
-
35
- 🪴 **Auto Imports from \_common.ts**
36
- Deduplicates and imports shared scalar types intelligently.
37
-
38
- 🧪 **Snapshot-Ready for Testing**
39
- Babel AST-based output is stable and perfect for inline snapshot tests.
40
-
41
- ## 🛠️ Install
42
-
43
- ```bash
44
- npm install pg-codegen
45
- ```
46
-
47
- ## 🚀 Usage
48
-
49
- ```ts
50
- import { generateCodeTree } from 'pg-codegen';
51
- import getIntrospectionRows from 'pg-codegen/introspect';
52
-
53
- const rows = await getIntrospectionRows({
54
- client: pgClient,
55
- introspectionOptions: {
56
- pgLegacyFunctionsOnly: false,
57
- pgIgnoreRBAC: true
58
- },
59
- namespacesToIntrospect: ['my_schema'],
60
- includeExtensions: false
61
- });
62
-
63
- const output = generateCodeTree(rows, {
64
- includeUUID: true,
65
- includeTimestamps: true
66
- });
67
-
68
- // Example: write output['schemas/my_schema.ts'] to disk
69
- ```
70
-
71
- ## 📟 Example Output
72
-
73
- ```ts
74
- // schemas/_common.ts
75
- export type UUID = string;
76
- export type Timestamp = string;
77
-
78
- // schemas/my_schema.ts
79
- import { UUID, Timestamp } from './_common';
80
-
81
- export interface Users {
82
- id: UUID;
83
- email: string;
84
- created_at: Timestamp;
85
- }
86
-
87
- export class Users implements Users {
88
- id: UUID;
89
- email: string;
90
- created_at: Timestamp;
91
-
92
- constructor(data: Users) {
93
- this.id = data.id;
94
- this.email = data.email;
95
- this.created_at = data.created_at;
96
- }
97
- }
98
- ```
99
-
100
- ## Related LaunchQL Tooling
101
-
102
- ### 🧪 Testing
103
-
104
- * [launchql/pgsql-test](https://github.com/launchql/launchql/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
105
- * [launchql/graphile-test](https://github.com/launchql/launchql/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
106
- * [launchql/pg-query-context](https://github.com/launchql/launchql/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.
107
-
108
- ### 🧠 Parsing & AST
109
-
110
- * [launchql/pgsql-parser](https://github.com/launchql/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
111
- * [launchql/libpg-query-node](https://github.com/launchql/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
112
- * [launchql/pg-proto-parser](https://github.com/launchql/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
113
- * [@pgsql/enums](https://github.com/launchql/pgsql-parser/tree/main/packages/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
114
- * [@pgsql/types](https://github.com/launchql/pgsql-parser/tree/main/packages/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
115
- * [@pgsql/utils](https://github.com/launchql/pgsql-parser/tree/main/packages/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
116
- * [launchql/pg-ast](https://github.com/launchql/launchql/tree/main/packages/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
117
-
118
- ### 🚀 API & Dev Tools
119
-
120
- * [launchql/server](https://github.com/launchql/launchql/tree/main/packages/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
121
- * [launchql/explorer](https://github.com/launchql/launchql/tree/main/packages/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
122
-
123
- ### 🔁 Streaming & Uploads
124
-
125
- * [launchql/s3-streamer](https://github.com/launchql/launchql/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
126
- * [launchql/etag-hash](https://github.com/launchql/launchql/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
127
- * [launchql/etag-stream](https://github.com/launchql/launchql/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
128
- * [launchql/uuid-hash](https://github.com/launchql/launchql/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
129
- * [launchql/uuid-stream](https://github.com/launchql/launchql/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
130
- * [launchql/upload-names](https://github.com/launchql/launchql/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
131
-
132
- ### 🧰 CLI & Codegen
133
-
134
- * [@launchql/cli](https://github.com/launchql/launchql/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation.
135
- * [launchql/launchql-gen](https://github.com/launchql/launchql/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data.
136
- * [@launchql/query-builder](https://github.com/launchql/launchql/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.
137
- * [@launchql/query](https://github.com/launchql/launchql/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
138
-
139
- ## Disclaimer
140
-
141
- AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
142
-
143
- No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
144
-
package/dist/package.json DELETED
@@ -1,51 +0,0 @@
1
- {
2
- "name": "pg-codegen",
3
- "version": "2.1.5",
4
- "author": "Dan Lynch <pyramation@gmail.com>",
5
- "description": "PostgreSQL Codegen",
6
- "main": "index.js",
7
- "module": "esm/index.js",
8
- "types": "index.d.ts",
9
- "homepage": "https://github.com/launchql/launchql",
10
- "license": "MIT",
11
- "publishConfig": {
12
- "access": "public",
13
- "directory": "dist"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "https://github.com/launchql/launchql"
18
- },
19
- "bugs": {
20
- "url": "https://github.com/launchql/launchql/issues"
21
- },
22
- "scripts": {
23
- "copy": "copyfiles -f ../../LICENSE README.md package.json dist",
24
- "clean": "rimraf dist/**",
25
- "prepare": "npm run build",
26
- "build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
27
- "build:dev": "npm run clean; tsc --declarationMap; tsc -p tsconfig.esm.json; npm run copy",
28
- "dev": "ts-node ./src/index.ts",
29
- "lint": "eslint . --fix",
30
- "test": "jest",
31
- "test:watch": "jest --watch"
32
- },
33
- "keywords": [
34
- "codegen",
35
- "graphql",
36
- "typescript",
37
- "launchql",
38
- "generator"
39
- ],
40
- "dependencies": {
41
- "@babel/generator": "^7.26.3",
42
- "@babel/types": "^7.26.3",
43
- "@launchql/types": "^2.1.6",
44
- "@launchql/server-utils": "^2.1.8",
45
- "pg": "^8.16.0",
46
- "pgsql-test": "^2.1.14"
47
- },
48
- "devDependencies": {
49
- "@types/pg": "^8.15.2"
50
- }
51
- }