Skip to content

rename internal useForm so it is not exposed to user#30

Merged
cobraprojects merged 2 commits into
mainfrom
form-internal-useForm
May 9, 2026
Merged

rename internal useForm so it is not exposed to user#30
cobraprojects merged 2 commits into
mainfrom
form-internal-useForm

Conversation

@cobraprojects
Copy link
Copy Markdown
Owner

@cobraprojects cobraprojects commented May 9, 2026

Summary by CodeRabbit

  • Refactor

    • Reorganized form runtime into a shared internal client surface and updated adapters to consume it.
    • Switched adapter composables/hooks to use the new internal form factory and adjusted runtime wiring for lazy initialization.
    • Updated package exports and build/test resolution to expose the internal client path.
  • Tests

    • Updated tests and package-boundary checks to reflect the new internal client entry.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d49e37e-bbd5-48ed-9788-96ff38a71c48

📥 Commits

Reviewing files that changed from the base of the PR and between 8a6409c and 95b3fe7.

📒 Files selected for processing (3)
  • packages/adapter-nuxt/src/runtime/composables/forms.ts
  • packages/adapter-sveltekit/tests/package.test.ts
  • packages/forms/tests/contracts.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/adapter-sveltekit/tests/package.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/forms/tests/contracts.test.ts

📝 Walkthrough

Walkthrough

The PR refactors the form client API from a public export to an internal export, renaming the factory from useForm to createFormClient across @holo-js/forms and updating all adapters, build entries, config aliases, and tests to consume the internal client.

Changes

Form Client API Refactor to Internal Export

Layer / File(s) Summary
Package Export Contract
packages/forms/package.json, packages/forms/tsup.config.ts, packages/forms/tests/contracts.test.ts
Package exports subpath changed from ./client to ./internal/client; build entry mapping updated; contract tests assert new export exists and old export is removed.
Core Implementation & Types
packages/forms/src/internal/client.ts
Introduces createFormClient as the internal factory, updates internal imports (failure utilities, CSRF), and exports the factory from the internal entrypoint.
Forms Tests & Examples
packages/forms/tests/*, packages/forms/tests/docs-examples.test.ts
Tests and example docs updated to import createFormClient (often aliased as useForm) from src/internal/client; contract tests expanded to assert exports changes.
Next.js Adapter Implementation
packages/adapter-next/src/client.ts
Adapter imports createFormClient from @holo-js/forms/internal/client, re-exports form-related types from the internal module, and calls createFormClient(...) when recreating the client.
Next.js Config & Tests
packages/adapter-next/tsconfig.json, packages/adapter-next/vitest.config.ts, packages/adapter-next/tests/*
TypeScript path and Vitest alias mappings now point to @holo-js/forms/internal/client; tests mock createFormClient and validate bridging, recreation, and instance-preservation behavior.
Nuxt Adapter Implementation
packages/adapter-nuxt/src/runtime/composables/forms.ts, packages/adapter-nuxt/src/runtime/composables/forms.d.ts
Composable switched to create the client with createFormClient inside watchEffect; value-sync helpers refactored to accept getForm callbacks; returned API delegates through currentForm().
Nuxt Config & Tests
packages/adapter-nuxt/tsconfig.json, packages/adapter-nuxt/vitest.config.ts, packages/adapter-nuxt/tests/package.test.ts
TypeScript path and Vitest alias mappings updated to @holo-js/forms/internal/client; d.ts and package boundary test updated accordingly.
SvelteKit Adapter Implementation
packages/adapter-sveltekit/src/client.ts
Form instance creation switched to createFormClient from @holo-js/forms/internal/client; type imports re-aligned.
SvelteKit Config & Tests
packages/adapter-sveltekit/tsconfig.json, packages/adapter-sveltekit/vitest.config.ts, packages/adapter-sveltekit/tests/package.test.ts
TypeScript path and Vitest alias mappings updated to @holo-js/forms/internal/client; package boundary tests updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • cobraprojects/holo-js#21: Prior Nuxt composable refactor touching useForm plumbing and value-sync helpers that relates to the composable changes here.

Poem

🐰 I hopped through code with nimble feet,

Moved factories where internals meet,
Adapters now all call the same,
A hidden client, a shorter name!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: renaming the internal useForm function to createFormClient so it is not exposed in the public API surface.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch form-internal-useForm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cobraprojects
Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/forms/tests/contracts.test.ts (1)

1125-1126: 💤 Low value

LGTM — export surface assertions are correct.

The two new contract assertions precisely encode the intent: ./client must no longer be a public export, and ./internal/client must exist. Because the typed cast already marks exports as optional, if the field were ever absent from package.json, Vitest would throw on toHaveProperty rather than produce a readable failure. In practice this is fine since the field is always present, but the narrower cast exports: Record<string, unknown> (non-optional) would make the intent explicit and surface any regression more clearly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/forms/tests/contracts.test.ts` around lines 1125 - 1126, The test
currently treats packageJson.exports as optional which hides absence of the
exports field; update the type assertion in
packages/forms/tests/contracts.test.ts so that packageJson.exports is typed as a
non-optional Record<string, unknown> (e.g., use "exports: Record<string,
unknown>") instead of an optional type, then keep the existing assertions on
packageJson.exports (expect(...).not.toHaveProperty('./client') and
expect(...).toHaveProperty('./internal/client')) so any regression where exports
is missing fails clearly.
packages/adapter-sveltekit/tests/package.test.ts (1)

21-21: 💤 Low value

Consider adding a negative assertion for the old @holo-js/forms/client path.

The positive check on Line 21 is sufficient for current correctness, but a not.toContain("@holo-js/forms/client") guard (being careful about the substring — @holo-js/forms/client is not a substring of @holo-js/forms/internal/client) would prevent a future regression where the old public path is accidentally re-introduced alongside the internal one.

♻️ Proposed addition
     expect(clientEntry).toContain("@holo-js/forms/internal/client")
+    expect(clientEntry).not.toContain('"@holo-js/forms/client"')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/adapter-sveltekit/tests/package.test.ts` at line 21, Add a negative
assertion to the test that ensures the old public import path is not present:
after the existing positive assertion on clientEntry, add
expect(clientEntry).not.toContain("@holo-js/forms/client") to guard against
accidentally reintroducing the old public path; reference the same test variable
clientEntry in packages/adapter-sveltekit/tests/package.test.ts and make sure
the string is the exact old path (not a substring of
"@holo-js/forms/internal/client").
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/adapter-nuxt/src/runtime/composables/forms.ts`:
- Line 224: The current watchEffect recreates and assigns form.value while also
reading it, causing a reactive dependency loop; instead, inside the watchEffect
create a non-reactive localForm by calling createFormClient(schemaDefinition,
options), pass that localForm to syncValuesFromForm (so syncValuesFromForm does
not read form.value), then assign form.value = localForm once syncing is
complete; update references to use localForm in the effect body and keep
createFormClient only called there (remove reliance on the initially created
shallowRef value) so the effect no longer reads and writes the same reactive
ref.

---

Nitpick comments:
In `@packages/adapter-sveltekit/tests/package.test.ts`:
- Line 21: Add a negative assertion to the test that ensures the old public
import path is not present: after the existing positive assertion on
clientEntry, add expect(clientEntry).not.toContain("@holo-js/forms/client") to
guard against accidentally reintroducing the old public path; reference the same
test variable clientEntry in packages/adapter-sveltekit/tests/package.test.ts
and make sure the string is the exact old path (not a substring of
"@holo-js/forms/internal/client").

In `@packages/forms/tests/contracts.test.ts`:
- Around line 1125-1126: The test currently treats packageJson.exports as
optional which hides absence of the exports field; update the type assertion in
packages/forms/tests/contracts.test.ts so that packageJson.exports is typed as a
non-optional Record<string, unknown> (e.g., use "exports: Record<string,
unknown>") instead of an optional type, then keep the existing assertions on
packageJson.exports (expect(...).not.toHaveProperty('./client') and
expect(...).toHaveProperty('./internal/client')) so any regression where exports
is missing fails clearly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 98a3fd3d-b322-4c58-970b-c383736e87d6

📥 Commits

Reviewing files that changed from the base of the PR and between a29161c and 8a6409c.

📒 Files selected for processing (21)
  • packages/adapter-next/src/client.ts
  • packages/adapter-next/tests/client.test.ts
  • packages/adapter-next/tests/package.test.ts
  • packages/adapter-next/tsconfig.json
  • packages/adapter-next/vitest.config.ts
  • packages/adapter-nuxt/src/runtime/composables/forms.d.ts
  • packages/adapter-nuxt/src/runtime/composables/forms.ts
  • packages/adapter-nuxt/tests/package.test.ts
  • packages/adapter-nuxt/tsconfig.json
  • packages/adapter-nuxt/vitest.config.ts
  • packages/adapter-sveltekit/src/client.ts
  • packages/adapter-sveltekit/tests/package.test.ts
  • packages/adapter-sveltekit/tsconfig.json
  • packages/adapter-sveltekit/vitest.config.ts
  • packages/forms/package.json
  • packages/forms/src/internal/client.ts
  • packages/forms/tests/client.test.ts
  • packages/forms/tests/client.type.test.ts
  • packages/forms/tests/contracts.test.ts
  • packages/forms/tests/docs-examples.test.ts
  • packages/forms/tsup.config.ts

Comment thread packages/adapter-nuxt/src/runtime/composables/forms.ts Outdated
@cobraprojects
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cobraprojects cobraprojects deleted the form-internal-useForm branch May 9, 2026 02:45
@cobraprojects cobraprojects restored the form-internal-useForm branch May 9, 2026 02:46
@cobraprojects cobraprojects reopened this May 9, 2026
@cobraprojects cobraprojects merged commit b476b26 into main May 9, 2026
1 check passed
@cobraprojects cobraprojects deleted the form-internal-useForm branch May 9, 2026 02:46
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