-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add map and array steps for parallel processing #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: dfed36c The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
View your CI Pipeline Execution ↗ for commit dfed36c
☁️ Nx Cloud last updated this comment at |
981dc83
to
08a197e
Compare
08a197e
to
a0af828
Compare
a0af828
to
c66f5b6
Compare
c66f5b6
to
436b03d
Compare
436b03d
to
ee33c4a
Compare
ee33c4a
to
2d741f6
Compare
…ow 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.
2d741f6
to
dfed36c
Compare
🔍 Preview Deployment: Website✅ Deployment successful! 🔗 Preview URL: https://pr-207.pgflow.pages.dev 📝 Details:
_Last updated: _ |
🔍 Preview Deployment: Playground✅ Deployment successful! 🔗 Preview URL: https://pr-207--pgflow-demo.netlify.app 📝 Details:
_Last updated: _ |
Merge activity
|
## Summary Adds a new `.array()` method to the Flow class that provides compile-time type safety for array-returning step handlers while maintaining full compatibility with existing functionality. ## Key Features - **Compile-time type enforcement**: TypeScript rejects non-array return types - **Zero runtime overhead**: Pure delegation to existing `.step()` method - **Full feature parity**: Complete support for dependencies, runtime options, and validation - **Semantic clarity**: Clear intent when creating array-producing steps ```ts // Type safety - these will fail at compile time: flow.array({ slug: 'invalid' }, () => 42); // ❌ Error: not an array flow.array({ slug: 'invalid2' }, () => "string"); // ❌ Error: not an array ``` ## Implementation Details - **Pure delegation**: `return this.step(opts, handler);` for maximum code reuse - **Type constraints**: `Array<Json> | Promise<Array<Json>>` return type enforcement - **Utility type reuse**: Leverages existing `StepInput<this, Deps>`, `AwaitedReturn<THandler>`, etc. - **Identical behavior**: Produces the same step definitions as `.step()` for array handlers ## Testing - **169 total tests passing** (162 existing + 7 new integration tests) - **15 type tests** validating compile-time constraints - **27 runtime tests** ensuring behavioral equivalence with `.step()` - **7 integration tests** covering complex real-world scenarios ## Breaking Changes None. This is purely additive functionality that maintains full backward compatibility. ## Related This implements Phase 1 of the array processing roadmap from PLAN.md, laying the foundation for future phases including queue routing and `.map()` method integration.
Summary
Adds a new
.array()
method to the Flow class that provides compile-time type safety for array-returning step handlers while maintaining full compatibility with existing functionality.Key Features
.step()
methodImplementation Details
return this.step(opts, handler);
for maximum code reuseArray<Json> | Promise<Array<Json>>
return type enforcementStepInput<this, Deps>
,AwaitedReturn<THandler>
, etc..step()
for array handlersTesting
.step()
Breaking Changes
None. This is purely additive functionality that maintains full backward compatibility.
Related
This implements Phase 1 of the array processing roadmap from PLAN.md, laying the foundation for future phases including queue routing and
.map()
method integration.