@bobtail.software/b-durable 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  # `@bobtail.software/b-durable`: Composable, Type-Safe, Durable Workflows for TypeScript
3
3
 
4
- [![npm version](https://badge.fury.io/js/@bobtail.software/b-durable.svg)](https://badge.fury.io/js/@bobtail.software/b-durable)
5
- [![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-yellow.svg)](https://opensource.org/licenses/GPL-3.0)
4
+ ![NPM Version](https://img.shields.io/npm/v/@bobtail.software/b-durable.svg)
5
+ ![License](https://img.shields.io/npm/l/@bobtail.software/eslint-plugin-b-durable.svg)
6
6
 
7
7
  `b-durable` is a powerful system that transforms standard `async` functions into **composable, interactive, durable, and resilient workflows**. It lets you write long-running business logic—spanning hours, days, or months—as simple, linear `async/await` code. The system handles state persistence, orchestration, external events, and crash recovery, allowing you to focus on your business logic.
8
8
 
@@ -172,14 +172,29 @@ async function main() {
172
172
  blockingRedisClient: blockingRedis,
173
173
  });
174
174
 
175
- console.log('Durable system ready. Starting workflow...');
175
+ console.log('Durable system ready. Starting workflows...');
176
176
 
177
- const workflowId = await durableSystem.start(userOnboardingWorkflow, {
178
- userId: `user-${Date.now()}`,
179
- email: 'test.user@example.com',
177
+ // --- Start a workflow with a system-generated ID ---
178
+ const workflowId1 = await durableSystem.start(userOnboardingWorkflow, {
179
+ input: {
180
+ userId: `user-${Date.now()}`,
181
+ email: 'test.user@example.com',
182
+ }
183
+ });
184
+ console.log(`Workflow ${workflowId1} started.`);
185
+
186
+ // --- Start a workflow with a predictable, user-provided ID ---
187
+ const orderId = `order-abc-123`;
188
+ const workflowId2 = await durableSystem.start(userOnboardingWorkflow, {
189
+ workflowId: orderId,
190
+ input: {
191
+ userId: 'user-from-order-123',
192
+ email: 'customer@example.com',
193
+ }
180
194
  });
181
-
182
- console.log(`Workflow ${workflowId} started.`);
195
+ console.log(`Workflow started with predictable ID: ${workflowId2}`);
196
+ // Now you can easily send events using the 'orderId'
197
+ // durableSystem.sendEvent(..., orderId, ...);
183
198
  }
184
199
 
185
200
  main().catch(console.error);