Repository navigation
feat(openworkflow): export the backend API and test suite - #893
Merged
Merged
Conversation
Add a documented subpath for people writing their own `Backend`. It exports the `Backend` interface and its param and result types, plus the helpers the built-in backends share for the rules that don't depend on storage: retry on failure, rerun, cancel conflicts, schedule occurrences, pagination, and row and error checks. A custom backend that uses them behaves the same way as the SQLite and Postgres backends. `openworkflow/internal` stays as it is for the CLI and dashboard. The new docs page marks the backend API as experimental before 1.0, so backends should pin the OpenWorkflow versions they support.
…ting Publish `testBackend()`, the suite the SQLite and Postgres backends run, so people can check a custom `Backend` against the same tests. Vitest becomes an optional peer dependency.
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no new actionable issues were found.
|
Contributor
Author
|
Morning; is there more you need from me before we might be able to merge this? |
Contributor
|
ahh, this was buried in my notifications, apologies. I'll get this merged today. @cliftonc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #880
Summary
As discussed in #880, this exposes the Backend API and the backend test suite so backends can be maintained outside this repo. The Drizzle backend will live in a separate
openworkflow-drizzlepackage that builds on both.Changes
openworkflow/backend: theBackendinterface and its param and result types, plus the helpers the built-in backends share for logic that doesn't depend on storage (computeFailedWorkflowRunUpdate,prepareWorkflowRerun,resolveCancelWorkflowRunConflict,nextScheduleOccurrence,isTerminalStatus, the cursor/pagination helpers,toWorkflowRunCounts,requireRow,wrapError). It only re-exports what the SQLite and Postgres backends already import fromcore/.openworkflow/testing:testBackend()andTestBackendOptions.filesre-includesdist/testing/backend.testsuite.*anddist/testing/schedules.testsuite.*, andvitestbecomes an optional peer dependency.testBackend. It says the backend API is experimental before 1.0 and may change in a minor release, so backends should pin the OpenWorkflow versions they support.I added
/backendas a new subpath instead of adding toopenworkflow/internal, sinceinternalis what the CLI and dashboard use and isn't documented. Happy to fold it intointernalif you'd prefer.The two exports are separate commits if you'd like to take only one.
Tested by packing the tarball into a scratch project, typechecking imports from
openworkflow/backend, and runningtestBackendfromopenworkflow/testingagainstBackendSqlite(86 tests pass).npm run cichecks pass locally.