@xata.io/pgstream
v0.2.0
Published
TypeScript definitions for [pgstream](https://github.com/xataio/pgstream) - PostgreSQL streaming and data transformation tool.
Readme
@xata.io/pgstream
TypeScript definitions for pgstream - PostgreSQL streaming and data transformation tool.
Installation
npm install @xata.io/pgstreamFeatures
- 🔧 CLI Commands - Complete pgstream CLI commands structure
- 🔄 Transformers - All available data transformation functions
- 🏷️ TypeScript Types - Fully typed definitions with const assertions
- ✅ Validation - Built-in Zod validation schemas
- 🔄 Auto-generated - Automatically updated from the latest pgstream definitions
Usage
CLI Commands
import { Commands } from '@xata.io/pgstream';
// Access pgstream CLI commands
console.log(Commands.commands);
// Example: Get all command names
const commandNames = Commands.commands.map((cmd) => cmd.name);
console.log(commandNames); // ['init', 'send', 'schema-dump', ...]
// Example: Find a specific command
const initCommand = Commands.commands.find((cmd) => cmd.name === 'init');
console.log(initCommand?.flags); // Available flags for init commandData Transformers
import { Transformers } from '@xata.io/pgstream';
// Access available transformers
console.log(Transformers.transformers);
// Example: Get all transformer names
const transformerNames = Transformers.transformers.map((t) => t.name);
console.log(transformerNames); // ['greenmask_boolean', 'greenmask_choice', ...]
// Example: Find transformers by supported type
const stringTransformers = Transformers.transformers.filter((t) => t.supported_types.includes('string'));
console.log(stringTransformers.map((t) => t.name));
// Example: Get transformer parameters
const emailTransformer = Transformers.transformers.find((t) => t.name === 'neosync_email');
console.log(emailTransformer?.parameters); // Available parametersSource URLs
import { PGSTREAM_CLI_DEFINITION_URL, PGSTREAM_TRANSFORMERS_DEFINITION_URL } from '@xata.io/pgstream';
// Get the source URLs for the definitions
console.log(PGSTREAM_CLI_DEFINITION_URL); // CLI definition URL
console.log(PGSTREAM_TRANSFORMERS_DEFINITION_URL); // Transformers definition URLAvailable Transformers
The package includes definitions for various data transformation categories:
Greenmask Transformers
greenmask_boolean- Boolean value transformationgreenmask_choice- Random choice from predefined valuesgreenmask_date- Date value transformationgreenmask_firstname- First name generationgreenmask_float- Floating-point number transformationgreenmask_integer- Integer value transformationgreenmask_string- String value transformationgreenmask_unix_timestamp- Unix timestamp transformationgreenmask_utc_timestamp- UTC timestamp transformationgreenmask_uuid- UUID generation
Neosync Transformers
neosync_email- Email address generationneosync_firstname- First name generationneosync_fullname- Full name generationneosync_lastname- Last name generationneosync_string- String generation
Utility Transformers
json- JSON data transformationliteral_string- Literal string replacementmasking- Data masking with various patternsphone_number- Phone number generationstring- Basic string transformationtemplate- Template-based transformation
CLI Commands
Available pgstream CLI commands:
init- Initialize pgstream with replication slot and schema setupsend- Send data changes to configured destinationsschema-dump- Dump PostgreSQL schema informationschema-load- Load schema into pgstream
Each command includes detailed flag definitions, descriptions, and usage examples.
Development
Generate Definitions
To regenerate the TypeScript definitions from the latest pgstream sources:
pnpm run generateThis will fetch the latest definitions from:
- https://raw.githubusercontent.com/xataio/pgstream/main/cli-definition.json
- https://raw.githubusercontent.com/xataio/pgstream/main/transformers-definition.json
Build
pnpm run buildType Check
pnpm run tscGenerated Files
src/cli-definition.ts- pgstream CLI commands definitionsrc/transformers-definition.ts- pgstream transformers definitionsrc/index.ts- Main exports
Type Safety
All definitions are exported with as const assertions, providing:
- Literal types for string values
- Readonly properties preventing accidental mutations
- IntelliSense support with auto-completion
- Compile-time validation of transformer and command names
// TypeScript will infer exact literal types
type CommandName = (typeof Commands.commands)[number]['name'];
type TransformerName = (typeof Transformers.transformers)[number]['name'];Related
- pgstream - PostgreSQL streaming and transformation tool
- @xata.io/pgroll - PostgreSQL schema migration definitions
License
Apache-2.0
