Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .agents/skills/code-generation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Three packages generate TypeScript from the PostgreSQL protobuf definition at `_
|---------|--------|-------------------|
| `@pgsql/utils` | `npm run build:proto` | AST helper functions (`src/`), wrapped helpers (`wrapped.ts`), runtime schema (`runtime-schema.ts`) |
| `@pgsql/traverse` | `npm run build:proto` | Visitor-pattern traversal utilities |
| `@pgsql/transform` | `npm run build:proto` | Multi-version AST transformer utilities |
| `@pgsql/transform-ast` | `npm run build:proto` | Multi-version AST transformer utilities |

Each package has a `scripts/pg-proto-parser.ts` that configures `PgProtoParser` with package-specific options (which features to enable, output paths, type sources).

Expand Down
6 changes: 3 additions & 3 deletions .agents/skills/testing-fixtures/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ packages/deparser/
packages/plpgsql-deparser/
scripts/
make-fixtures.ts # Extracts PL/pgSQL statements -> plpgsql-generated/generated.json
packages/transform/
packages/transform-ast/
scripts/
make-kitchen-sink.ts # Generates transform kitchen-sink tests
test-ast.ts # AST round-trip validation for transform
Expand Down Expand Up @@ -163,7 +163,7 @@ This runs `scripts/make-fixtures.ts` which:
The transform package has its own kitchen-sink and AST test scripts:

```bash
cd packages/transform
cd packages/transform-ast
npm run kitchen-sink # generate transform-specific kitchen-sink tests
npm run test:ast # run AST round-trip validation
```
Expand All @@ -189,7 +189,7 @@ npm run test:ast # run AST round-trip validation
|--------|---------|-------------|
| `fixtures` | `ts-node scripts/make-fixtures.ts` | Extract PL/pgSQL fixtures to `plpgsql-generated/generated.json` |

### `packages/transform`
### `packages/transform-ast`

| Script | Command | Description |
|--------|---------|-------------|
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- plpgsql-parser
- pg-proto-parser
- '@pgsql/quotes'
- '@pgsql/transform'
- '@pgsql/transform-ast'
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A pnpm monorepo for PostgreSQL AST parsing, deparsing, and code generation. All
| `@pgsql/types` | (published from proto-parser codegen) | Core TypeScript type definitions for PostgreSQL AST nodes |
| `@pgsql/utils` | `packages/utils` | Type-safe AST node creation utilities |
| `@pgsql/traverse` | `packages/traverse` | Visitor-pattern AST traversal |
| `@pgsql/transform` | `packages/transform` | Multi-version AST transformer (PG 13-17) |
| `@pgsql/transform-ast` | `packages/transform-ast` | Multi-version AST transformer (PG 13-17) |
| `@pgsql/quotes` | `packages/quotes` | SQL identifier/string quoting and keyword classification |
| `@pgsql/cli` | `packages/pgsql-cli` | CLI tool for parse/deparse operations |
| `pg-proto-parser` | `packages/proto-parser` | Generate TypeScript from PostgreSQL protobuf definitions |
Expand Down Expand Up @@ -79,8 +79,8 @@ Every package supports these scripts:
| `deparser` | `npm run fixtures:sql` | Generate SQL fixtures via native deparse |
| `deparser` | `npm run fixtures:upstream-diff` | Compare upstream (libpg-query) vs our deparser output |
| `plpgsql-deparser` | `npm run fixtures` | Extract PL/pgSQL fixtures |
| `transform` | `npm run kitchen-sink` | Generate transform kitchen-sink tests |
| `transform` | `npm run test:ast` | AST round-trip validation |
| `transform-ast` | `npm run kitchen-sink` | Generate transform kitchen-sink tests |
| `transform-ast` | `npm run test:ast` | AST round-trip validation |
| `parser` | `npm run test:ast` | AST round-trip validation |

### Code Generation Scripts (see code-generation skill)
Expand All @@ -89,7 +89,7 @@ Every package supports these scripts:
|---------|--------|-------------|
| `utils` | `npm run build:proto` | Generate AST helpers from protobuf |
| `traverse` | `npm run build:proto` | Generate traversal utilities from protobuf |
| `transform` | `npm run build:proto` | Generate transformer utilities from protobuf |
| `transform-ast` | `npm run build:proto` | Generate transformer utilities from protobuf |
| `pgsql-types` | `npm run infer` | Infer field metadata from SQL fixtures |
| `pgsql-types` | `npm run generate` | Generate narrowed types from metadata |
| `proto-parser` | `npm run generate:test-utils` | Generate test utilities from protobuf |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ walk(ast, visitor);
| [**@pgsql/cli**](./packages/pgsql-cli) | Unified CLI for all PostgreSQL AST operations | • Parse SQL to AST<br>• Deparse AST to SQL<br>• Generate TypeScript from protobuf<br>• Single tool for all operations |
| [**@pgsql/utils**](./packages/utils) | Type-safe AST node creation utilities | • Programmatic AST construction<br>• Runtime Schema<br>• Seamless integration with types |
| [**pg-proto-parser**](./packages/proto-parser) | PostgreSQL protobuf parser and code generator | • Generate TypeScript interfaces from protobuf<br>• Create enum mappings and utilities<br>• AST helper generation |
| [**@pgsql/transform**](./packages/transform) | Multi-version PostgreSQL AST transformer | • Transform ASTs between PostgreSQL versions (13→17)<br>• Single source of truth deparser pipeline<br>• Backward compatibility for legacy SQL |
| [**@pgsql/transform-ast**](./packages/transform-ast) | Multi-version PostgreSQL AST transformer | • Transform ASTs between PostgreSQL versions (13→17)<br>• Single source of truth deparser pipeline<br>• Backward compatibility for legacy SQL |
| [**@pgsql/traverse**](./packages/traverse) | PostgreSQL AST traversal utilities | • Visitor pattern for traversing PostgreSQL AST nodes<br>• NodePath context with parent/path information<br>• Runtime schema-based precise traversal |

## 🛠️ Development
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @pgsql/transform
# @pgsql/transform-ast

<p align="center" width="100%">
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
Expand All @@ -9,10 +9,10 @@
<img height="20" src="https://github.com/constructive-io/pgsql-parser/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/pgsql-parser/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@pgsql/transform"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/pgsql-parser?filename=packages%2Ftransform%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@pgsql/transform-ast"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/pgsql-parser?filename=packages%2Ftransform-ast%2Fpackage.json"/></a>
</p>

`@pgsql/transform` is a TypeScript library for transforming PostgreSQL ASTs between different PostgreSQL versions. It serves as a crucial component for building a single source of truth deparser that can handle SQL from multiple PostgreSQL versions while maintaining backward compatibility.
`@pgsql/transform-ast` is a TypeScript library for transforming PostgreSQL ASTs between different PostgreSQL versions. It serves as a crucial component for building a single source of truth deparser that can handle SQL from multiple PostgreSQL versions while maintaining backward compatibility.

## Transforming ASTs Between PG Versions

Expand All @@ -35,15 +35,15 @@ This design ensures all transformed ASTs can be reliably deparsed using the late
## Installation

```bash
npm install @pgsql/transform
npm install @pgsql/transform-ast
```

## 🚀 Quick Start

### Multi-Version Transformer

```typescript
import { ASTTransformer } from '@pgsql/transform';
import { ASTTransformer } from '@pgsql/transform-ast';

const transformer = new ASTTransformer();

Expand All @@ -62,7 +62,7 @@ const result = transformer.transform13To17(pg13Ast);
For better performance when you know source and target versions:

```typescript
import { PG13ToPG17Transformer } from '@pgsql/transform';
import { PG13ToPG17Transformer } from '@pgsql/transform-ast';

const transformer = new PG13ToPG17Transformer();
const pg17Ast = transformer.transform(pg13Ast);
Expand All @@ -73,7 +73,7 @@ const pg17Ast = transformer.transform(pg13Ast);
```typescript
import { parse } from '@pgsql/parser';
import { deparse } from 'pgsql-deparser';
import { PG13ToPG17Transformer } from '@pgsql/transform';
import { PG13ToPG17Transformer } from '@pgsql/transform-ast';

// Parse with older version
const pg13Ast = await parse('SELECT * FROM users', { version: 13 });
Expand Down
Loading
Loading