Migration Guide: v0.x to v1.0.0
This guide helps you migrate from ZoopFlow v0.x pre-release versions to the stable v1.0.0 release.
Breaking Changes
1. Step Definition API
v0.x:
const myStep = {
id: 'my-step',
version: '0.1.0',
execute: async (input, context) => {
// Step logic
}
};v1.0.0:
import { defineStep } from '@zoopflow/core';
const myStep = defineStep({
id: 'my-step',
version: '1.0.0',
input_schema: { /* JSON Schema */ },
output_schema: { /* JSON Schema */ },
execute: async (input, context) => {
// Step logic
}
});2. Flow Definition API
v0.x:
const myFlow = {
id: 'my-flow',
version: '0.1.0',
steps: async (input, context) => {
// Flow logic
}
};v1.0.0:
import { defineFlow } from '@zoopflow/core';
const myFlow = defineFlow({
id: 'my-flow',
version: '1.0.0',
input_schema: { /* JSON Schema */ },
output_schema: { /* JSON Schema */ },
steps: async (input, context) => {
// Flow logic
}
});3. Schema Validation
Schema validation is now required for all steps and flows. The input_schema and output_schema properties are mandatory.
4. Context API
The context API has been updated to provide more functionality:
v0.x:
context.log('info', 'Message');
context.executeStep(step, input);v1.0.0:
context.logger.info('Message');
await context.executeStep(step, input, options);
await context.createCheckpoint(state);
const service = context.getService('serviceName');Step-by-Step Migration Guide
1. Update Dependencies
npm install @zoopflow/core@1.0.02. Update Step Definitions
- Replace step object literals with
defineStepcalls - Add input and output schemas to all steps
- Update step IDs to use the recommended format:
[namespace].[name] - Update step versions to reflect the new API version
3. Update Flow Definitions
- Replace flow object literals with
defineFlowcalls - Add input and output schemas to all flows
- Update flow IDs to use the recommended format:
[namespace].[name] - Update flow versions to reflect the new API version
4. Update Context Usage
- Replace
context.log(level, message)withcontext.logger[level](message) - Update any use of deprecated context methods
5. Update Error Handling
Error handling now follows a more structured approach:
import { defineFlow, FlowError } from '@zoopflow/core';
const myFlow = defineFlow({
// ...
errorHandler: async (error, context) => {
if (error instanceof PaymentError) {
// Handle payment errors
return { success: false, error: 'Payment failed' };
}
// Re-throw other errors
throw error;
}
});Testing Your Migration
After migrating, test your workflows thoroughly to ensure they work as expected with the new API. Pay special attention to:
- Schema validation for inputs and outputs
- Error handling and recovery
- Context method usage
- Step and flow execution
If you encounter issues during migration, refer to the v1.0.0 API Reference or reach out to our support team.