Skip to main content

Migrating between v0

These are all the breaking changes in v0 and how to migrate between them

Breaking Changes 0.39.0

Functions Parameters

All TypeScript functions now use object parameters instead of regular parameters. This change affects channels and client generators across all protocols.

Before:

// Publishing
await jetStreamPublishToSendUserSignedup(message, parameters, js);
await publishToSendUserSignedup(message, parameters, connection);

// Subscribing
const subscriber = await jetStreamPullSubscribeToReceiveUserSignedup(
onDataCallback,
parameters,
js,
config
);

After:

// Publishing
await jetStreamPublishToSendUserSignedup({
message,
parameters,
js
});
await publishToSendUserSignedup({
message,
parameters,
connection
});

// Subscribing
const subscriber = await jetStreamPullSubscribeToReceiveUserSignedup({
onDataCallback,
parameters,
js,
config
});

Breaking Changes 0.55.1

We upgraded the AsyncAPI Modelina dependency to the next version so for the next few versions it will contain breaking changes as we continue to improve the tool.

Breaking Changes 0.61.0

Channels Multi-File Output

The channels generator now outputs one file per protocol instead of a single file with a Protocols object. This change improves tree-shaking, reduces bundle size, and provides better code organization.

Before (v0.60.x and earlier):

// Single file with Protocols object containing all protocols
import { Protocols } from './channels/index';
const { nats } = Protocols;
const { publishToSendUserSignedup, subscribeToReceiveUserSignedup } = nats;

// Or destructure directly
const { nats: { publishToSendUserSignedup } } = Protocols;

After (v0.61.0+):

// Option 1: Import specific functions directly from protocol file
import {
publishToSendUserSignedup,
subscribeToReceiveUserSignedup
} from './channels/nats';

// Option 2: Import the entire protocol as a namespace
import * as nats from './channels/nats';
nats.publishToSendUserSignedup({ ... });

// Option 3: Import from index (protocols are re-exported as namespaces)
import { nats, kafka, mqtt } from './channels/index';
nats.publishToSendUserSignedup({ ... });

New file structure:

outputPath/
├── index.ts # Re-exports all protocol namespaces
├── nats.ts # NATS-specific functions
├── kafka.ts # Kafka-specific functions
├── mqtt.ts # MQTT-specific functions
├── amqp.ts # AMQP-specific functions
├── event_source.ts # EventSource-specific functions
├── http_client.ts # HTTP client-specific functions
└── websocket.ts # WebSocket-specific functions

Migration steps:

  1. Replace import { Protocols } from './channels' with direct imports from protocol files
  2. Remove destructuring of the Protocols object
  3. Update function calls - functions are now standalone exports, not object properties
  4. Optionally use namespace imports (import * as nats from './channels/nats') to keep similar syntax

Breaking Changes 0.64.2

Upgraded node to minimum v22.

Breaking Changes 0.71.0

Library API Type Changes

The GenerationResult and GeneratorResult types have changed to support browser-based generation (playground). This only affects users consuming the library programmatically - CLI users are not affected.

Before (v0.70.x and earlier):

import { runGenerators } from '@the-codegen-project/cli';

const result = await runGenerators(context);

// Accessing results
console.log(result.totalFiles); // number
console.log(result.allFiles); // string[] (absolute paths)
console.log(result.generators[0].filesWritten); // string[] (absolute paths)

After (v0.71.0+):

import { runGenerators } from '@the-codegen-project/cli';

const result = await runGenerators(context);

// Accessing results - now includes file content
console.log(result.files.length); // number (replaces totalFiles)
console.log(result.files); // GeneratedFile[]
console.log(result.generators[0].files); // GeneratedFile[]

// GeneratedFile shape:
interface GeneratedFile {
path: string; // Relative path (e.g., 'src/payloads/User.ts')
content: string; // Full file content
}

Migration steps:

  1. Replace result.totalFiles with result.files.length
  2. Replace result.allFiles with result.files.map(f => f.path)
  3. Replace generator.filesWritten with generator.files.map(f => f.path)
  4. Optionally leverage the new content property for in-memory processing