Skip to content

Commit 08a197e

Browse files
committed
feat(dsl): add .array() method for type-safe array creation in workflow steps
Implement a new .array() method in the Flow class to enable type-safe, semantic array steps that leverage existing validation and dependency mechanisms. The change includes type constraints to enforce array return types, comprehensive runtime and type tests, and detailed documentation. This enhancement maintains full feature parity with .step() and integrates seamlessly with existing validation utilities, laying the foundation for future phases involving queue routing and advanced type inference. The implementation follows the principle of minimal, non-breaking extension, ensuring zero risk to current functionality and providing immediate compile-time safety benefits.
1 parent 5230a2d commit 08a197e

File tree

7 files changed

+1659
-12
lines changed

7 files changed

+1659
-12
lines changed

.changeset/tricky-sites-stare.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@pgflow/dsl': minor
3+
---
4+
5+
Add `.array()` method for type-safe array step creation
6+
7+
Introduces a new `.array()` method that provides compile-time type safety for array-returning handlers with zero runtime overhead.
8+
9+
- Enforces array return types at compile time
10+
- Pure delegation to existing `.step()` method
11+
- Full support for dependencies and runtime options
12+
- Backward compatible
13+
14+
```typescript
15+
flow.array({ slug: 'items' }, () => [1, 2, 3]); // ✅ Valid
16+
flow.array({ slug: 'invalid' }, () => 42); // ❌ Compile error
17+
```

0 commit comments

Comments
 (0)