Repository navigation
refactor: move the invoice flow query and mutation options to core - #1901
Open
gabrielseco wants to merge 7 commits into
Open
gabrielseco wants to merge 7 commits into
gabrielseco wants to merge 7 commits into
Conversation
Contributor
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (314 total)
✅ Bundle size check passed |
Contributor
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
Contributor
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
Contributor
📊 Coverage Report✅ Coverage increased! 🎉
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
This was referenced Nov 5, 2026
…options # Conflicts: # src/common/invoice-schedules/api.ts
…to refactor/core-query-options
…to refactor/core-query-options
The invoice schedule helpers moved to domains/invoice-schedule, so the query options import them from there. The preview payload builder is only used inside core, so it is no longer exported from the package entry.
Add `withClient` and `createClientMutation` so a core options factory becomes a hook in one line. The mutation hook also returns `mutateAsyncOrThrow`, memoized on the stable `mutate`, so flow hooks no longer wrap each mutation themselves. Move the response unwrapping and the "editable schedule" status rule into core selectors next to the queries they read, and use them from the invoice schedule and contractor currencies hooks.
gabrielseco
marked this pull request as ready for review
November 6, 2026 12:16
This branch has not been deployed
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.
Summary
Moves the API calls behind the invoice schedule flow into the private core package as plain option objects that any framework can use. Behavior and the public API of
@remoteoss/remote-flowsare unchanged.Why
Phase 2 of the Angular support plan (#1833). The query keys, request calls and payload building for this flow are the same in every framework, and today the Angular spike rewrites them next to the React hooks. Sharing them means one place to change. Stacked on #1900.
What changed
Toggle details
packages/core/src/api/with three files:employment.ts:employmentOptions(client, employmentId, queryParams?)contractorCurrencies.ts:contractorCurrenciesOptions(client, employmentId)invoiceSchedules.ts:invoiceSchedulesOptions(client, employmentId)and the four mutationscreateInvoiceScheduleMutation,updateInvoiceScheduleMutation,skipInvoiceScheduleMutationandpreviewContractorInvoiceMutation, each takingclient.queryKey,queryFn,retry; ormutationFn), the shapeuseQueryanduseMutationaccept.selectandenabledstay with the caller, as before. Query keys are unchanged, so the React Query cache behaves as it did.queryOptionsandmutationOptionsare not exported by@tanstack/query-core; they only exist in each framework package. So core does not depend on TanStack at all here, and the React side wraps the object withqueryOptions(...)where it needs the typed key. The plan text is updated separately.useEmploymentQuery,useContractorCurrencies,invoiceSchedulesOptions,useCreateInvoiceSchedule,useUpdateInvoiceSchedule,useSkipInvoiceScheduleandusePreviewContractorInvoicenow spread or pass the core options.useOnboardingJsonSchemaVersion.test.tsxreplaces the whole@/src/clientmodule with a few functions, and its employment lookup relied on failing under that mock. Core calls the SDK through its own import, so the lookup got real data and the flow took a different path. I added a mock of the core SDK module to that one file so the lookup fails as before. The test bodies are unchanged. That whole-module mock is a legacy pattern the testing rules discourage; replacing it is a separate cleanup.src/by design.dist, andcheck-exportspasses.Screenshots
N/A
Related Resources
Testing
The same checks CI runs pass locally: the lint command (exit 0),
type-check(both configs), the full vitest suite (135 files, 1732 tests), a production build andcheck-exports.example/app in a browserNote
Medium Risk
Refactors shared React Query wiring and mutation helpers for employment and invoice-schedule flows; intended as behavior-preserving but any mismatch in options or client binding could affect API calls or caching.
Overview
Moves employment, contractor currencies, and invoice-schedule
queryKey/queryFn/mutationFndefinitions intopackages/coreas plain objects, plus selectors for currency lists, currency codes, and the first “editable” invoice schedule. The public@remoteoss/remote-flowshooks keep the same names; they nowwithClient-wrap the core query factories and usecreateClientMutationso the contextClientis injected and callers still getmutateAsyncOrThrowwithout double-wrapping.React invoice-schedule code stops inlining SDK calls and payload builders for those endpoints; onboarding and standalone invoice flows use the mutation hooks’ built-in
mutateAsyncOrThrowdirectly.Exports: core’s
indexnow surfaces the new API helpers and dropsINVOICE_SCHEDULE_STATUSandbuildInvoicePreviewPayloadfrom the package surface (they stay internal to core where needed).Tests: core adds selector unit tests; app adds
createClientMutationtests and mocks@remoteoss/remote-flows-core/client/sdk.genin the onboarding json-schema version test so behavior stays aligned with the old module mock.Reviewed by Cursor Bugbot for commit 0a423f6. Bugbot is set up for automated code reviews on this repo. Configure here.