Skip to content

refactor: move form value conversion to core with an injected file converter - #1891

Open
gabrielseco wants to merge 5 commits into
refactor/core-form-helpersfrom
refactor/core-value-conversion
Open

gabrielseco wants to merge 5 commits into
refactor/core-form-helpersfrom
refactor/core-value-conversion

Conversation

@gabrielseco

@gabrielseco gabrielseco commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Moves the form value conversion code into the private core package. The only browser-specific part, reading selected files, is passed in instead of being imported. Behavior and the public API of @remoteoss/remote-flows are unchanged.

Why

Phase 2 of the Angular support plan (#1833). This is the code that turns form values into the shape the API expects and sets a form's initial values, so every framework needs it. Stacked on #1890.

What changed

Toggle details
  • New packages/core/src/form.ts holds the rest of what was in src/components/form/utils.ts: parseFormValuesToAPI, parseSubmitValues, parseJSFToValidate, getInitialValues, getFieldsWithFlatFieldsets, enableAckFields, getMinStartDate, isDateDisabled and their private helpers. The code is moved as it was, with one change below.
  • One change in behavior shape: file uploads were converted through convertFilesToBase64, which uses the browser's FileReader. Core must not use browser APIs, so the three parse functions now take a convertFiles function as a parameter, and the file field uses it. The old fieldTypesTransformations map is no longer exported; its file entry became this parameter.
  • src/components/form/utils.ts is now a thin wrapper: parseFormValuesToAPI, parseSubmitValues and parseJSFToValidate keep their existing names and signatures and pass convertFilesToBase64, and everything else is re-exported from core. No caller changes.
  • Core now depends on date-fns (same pinned version as the root package). Like fast-deep-equal, it stays an external import in the build.
  • vitest.config.ts now also runs tests under packages/*/src and counts them in coverage, so moved code is still measured.
  • New packages/core/src/form.test.ts covers the new seam: the converter receives the selected files and its result is used, and it isn't called when no file is selected. I checked the first test fails when the converter call is removed.
  • Public API: no change. None of the moved functions is exported from src/index.tsx.
  • Checked on a production build: no reference to the core package is left in the built JS or .d.ts files, and core's source has no browser globals.

Screenshots

N/A

Related Resources

Testing

pnpm run type-check and the full vitest suite (133 files) pass locally. The existing tests are unchanged.

  • Tested against the example/ app in a browser
  • Feature flag: N/A

Note

Medium Risk
Large block of form serialization and validation logic moved to a shared package; behavior is intended to stay the same but any subtle regression would affect submissions. File handling now depends on callers passing convertFiles correctly in core.

Overview
Moves JSON Schema Form value parsing, submit shaping, initial-value building, flat fieldsets, acknowledgement helpers, and date utilities from src/components/form/utils.ts into packages/core/src/form.ts, exporting them from @remoteoss/remote-flows-core.

Introduces an injected convertFiles dependency (FileConverter) for file fields so core stays environment-agnostic; parseFormValuesToAPI, parseSubmitValues, and parseJSFToValidate now require it in core, while the app wrapper still calls convertFilesToBase64 so the public API of @remoteoss/remote-flows is unchanged.

Adds date-fns to the core package, extends Vitest to run and cover tests under packages/*/src, and adds form.test.ts asserting the file converter is invoked only when files are present.

Reviewed by Cursor Bugbot for commit 90b5a16. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Metric Current Previous Change Status
Total (gzip) 246.82 kB 246.93 kB -109 B (-0.0%) 🟢
Total (raw) 679.98 kB 679.83 kB +156 B (+0.0%) 🔴
CSS (gzip) 22.03 kB 22.03 kB 0 B (0%) 🟢
CSS (raw) 114.89 kB 114.89 kB 0 B (0%) 🟢

Size Limits

  • ✅ Total gzipped: 246.82 kB / 350 kB (70.5%)
  • ✅ Total raw: 679.98 kB / 850 kB (80.0%)
  • ✅ CSS gzipped: 22.03 kB / 25 kB (88.1%)

Largest Files (Top 5)

  1. index.esm-wIkXrqU6.js - 11.4 kB (0 B (0%))
  2. styles.css - 11.02 kB (0 B (0%))
  3. index.css - 11.02 kB (0 B (0%))
  4. internals-XzyoLxoe.js - 6.14 kB (new)
  5. hooks-Bb_E3Dp6.js - 5.79 kB (new)
View All Files (317 total)
File Size (gzip) Change
index.esm-wIkXrqU6.js 11.4 kB 0 B (0%)
styles.css 11.02 kB 0 B (0%)
index.css 11.02 kB 0 B (0%)
internals-XzyoLxoe.js 6.14 kB new
hooks-Bb_E3Dp6.js 5.79 kB new
index.js 5.65 kB -5 B (-0.1%)
sdk.gen-D_5dqKZ5.js 5.63 kB 0 B (0%)
flows/Onboarding/hooks.js 4.69 kB +10 B (+0.2%)
FieldSetField-C8_6uj78.js 4.56 kB new
EstimationResults-Cauc1GIF.js 3.78 kB new

✅ Bundle size check passed

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-2w32wjqfh-remotecom.vercel.app
Latest Commit:90b5a16

Deployed with vercel-action

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-qii04usd9-remotecom.vercel.app
Latest Commit:90b5a16

Deployed with vercel-action

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage Report

✅ Coverage increased! 🎉

Metric Current Previous Change Status
Lines 90.27% 90.26% 0% ⚪
Statements 90.15% 90.14% 0% ⚪
Functions 89.10% 89.10% 0% ⚪
Branches 81.88% 81.76% +0.12% 🟢

Detailed Breakdown

Lines Coverage
  • Covered: 5879 / 6513
  • Coverage: 90.27%
  • Change: 0% (49 lines)
Statements Coverage
  • Covered: 5949 / 6599
  • Coverage: 90.15%
  • Change: 0% (50 statements)
Functions Coverage
  • Covered: 1562 / 1753
  • Coverage: 89.10%
  • Change: 0% (17 functions)
Branches Coverage
  • Covered: 3646 / 4453
  • Coverage: 81.88%
  • Change: +0.12% (64 branches)

✅ Coverage check passed

@gabrielseco
gabrielseco marked this pull request as ready for review November 6, 2026 08:50

This branch has not been deployed

No deployments
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.

1 participant