Skip to content

fix(formulus): use form schema versions instead of calling every form v1.0 #909

Description

@Mishael-2584

The small adventure

Forms evolve. A field team might collect one season with version 1.0 and add a
new question for version 1.1. Formulus already carries a schemaVersion through
its form and observation APIs, but forms loaded from bundle storage are
currently assigned the hard-coded version 1.0.

Help Formulus read the version written by the form author, while keeping old
forms working. Tiny change, important provenance.

Where to start

  • formulus/src/services/FormService.ts
  • formulus/src/services/__tests__/FormService.test.ts
  • formulus/src/components/common/FormCard.tsx
  • formulus/src/webview/FormulusMessageHandlers.ts
  • formulus/AGENTS.md

Look at the FormSpec type and follow where schemaVersion is displayed and
passed across the WebView bridge before changing the loader.

Expected behavior

  • If the root of schema.json contains a non-empty string
    schemaVersion, use it as the FormSpec.schemaVersion.
  • Otherwise, if it contains a non-empty string version, use that value.
  • If neither is present, preserve the current fallback of 1.0 so existing
    bundles continue to load.
  • Values that are missing, blank, or not strings should use the fallback.

If the repository's current form specification says something different when
you begin, stop and ask before changing the precedence. The public form contract
wins over this draft.

What to change

  • Replace the hard-coded assignment in FormService with the behavior above.
  • Add tests for schemaVersion, version, precedence when both exist, and the
    fallback for absent or invalid values.
  • Remove the nearby TODO once the behavior is covered.
  • Keep the change local to loading form metadata; do not redesign the form
    bundle format.

Done when

  • Stored forms report their authored version according to the rules above.
  • Existing schemas without a version still report 1.0.
  • The behavior is covered by unit tests using the existing RNFS mocks.
  • Formulus lint, formatting, and tests pass.

Verify it

From formulus/:

pnpm run lint
pnpm run format:check
pnpm run test --ci --watchAll=false

What you will meet along the way

This issue follows a form from its bundle files into Formulus and toward the
WebView bridge. That is one of ODE's central routes: portable JSON form
definitions become offline observations with enough metadata to make sense
later.

AI tools are welcome, not required

An assistant can help locate every schemaVersion reference or draft table
tests. Please inspect those references yourself and mention in the PR where the
value goes after FormService. Understanding the data's journey matters more
than producing the four-line fix quickly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions