Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Dec 23, 2025

Asymmetric Step Input Pattern for Improved Type Safety and Composition

This PR introduces a significant improvement to the step input pattern across the PgFlow DSL:

  • Root steps now receive flow input directly (no run wrapper)
  • Dependent steps receive only their dependencies (flow input available via context.flowInput)

This change enables better functional composition where subflows can receive typed inputs without the run wrapper that previously blocked type matching. The asymmetric input pattern makes the API more intuitive while maintaining full type safety.

Key Changes:

  • Updated StepInput utility type to implement the asymmetric pattern
  • Modified step handler signatures to use flowInput instead of input.run
  • Added flowInput to the FlowContext interface for dependent steps
  • Updated all tests to use the new pattern
  • Improved type tests to verify the asymmetric behavior

This change is backward compatible at runtime but will require updating handler parameter names in client code. The improved type safety and composability are worth the minor migration effort.

@changeset-bot
Copy link

changeset-bot bot commented Dec 23, 2025

⚠️ No Changeset found

Latest commit: b47e937

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud
Copy link

nx-cloud bot commented Dec 23, 2025

View your CI Pipeline Execution ↗ for commit b47e937

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 3m 57s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 3s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 4s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 2m 37s View ↗
nx run core:pgtap ✅ Succeeded 1m 46s View ↗
nx run client:e2e ✅ Succeeded 1m 9s View ↗
nx run edge-worker:e2e ✅ Succeeded 48s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-23 08:27:25 UTC

- Root steps receive flowInput directly (no run key wrapper)
- Dependent steps receive deps object only, flowInput via context
- Add flowInput to FlowContext type
- Update all type tests and example flows
- Update edge-worker and client packages for compatibility
@jumski jumski force-pushed the 12-23-feat_asymmetric_handler_signatures_for_step_array_methods branch from 86ca44b to b47e937 Compare December 23, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants