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

Breaking Changes 0.72.3

OpenAPI Operation Names

The OpenAPI channels and client (http_client) generators previously prepended the HTTP method to the operation name, even when the spec already provided an operationId. This produced a duplicated verb (e.g. an addPet operation with method POST generated postAddPet). The operationId is now used verbatim as the function name, and the method is only used to synthesize a name when no operationId is present.

This renames the generated functions (and their *Context interfaces) for any OpenAPI operation that declares an operationId.

Before (v0.72.2 and earlier):

import { postAddPet, putUpdatePet, getFindPetsByStatusAndCategory } from './channels/http_client';

await postAddPet({ /* ... */ });

After (v0.72.3+):

import { addPet, updatePet, findPetsByStatusAndCategory } from './channels/http_client';

await addPet({ /* ... */ });

Migration steps:

  1. Regenerate your code.
  2. Update call sites to drop the leading HTTP verb from function names that came from an operationId (e.g. postAddPetaddPet).
  3. Update any references to the renamed *Context interfaces (e.g. PostAddPetContextAddPetContext).

Breaking Changes 0.72.6

Generated HTTP Client Uses Native fetch

The generated HTTP client (OpenAPI http_client channels and the http client) no longer imports node-fetch. It now uses the global fetch/Headers built into the runtime. The node-fetch (and @types/node-fetch) dependency is no longer needed. This project already requires Node.js 22, which ships a global fetch.

Before (v0.72.5 and earlier):

// Generated client imported node-fetch
import * as NodeFetch from 'node-fetch';
// package.json needed:
// "node-fetch": "^2.6.7", "@types/node-fetch": "^2.6.11"

After (v0.72.6+):

// Generated client uses the runtime's global fetch — no import, no dependency.
// To use a different HTTP implementation (node-fetch, axios, ...), provide it
// via the makeRequest hook on the client context.

Migration steps:

  1. Regenerate your code.
  2. Remove node-fetch and @types/node-fetch from your project's dependencies if they were only used by the generated client.
  3. Ensure your runtime provides a global fetch (Node.js 18+). If you need a custom HTTP implementation, supply it through the makeRequest hook instead of relying on the default.