Skip to content

feat(typescript-client): add move-in event support#4043

Merged
kevin-dp merged 2 commits intomainfrom
feat/move-in-event-support
Mar 30, 2026
Merged

feat(typescript-client): add move-in event support#4043
kevin-dp merged 2 commits intomainfrom
feat/move-in-event-support

Conversation

@kevin-dp
Copy link
Copy Markdown
Contributor

No description provided.

…Pattern to MovePattern

Extend EventMessage to accept both move-out and move-in events, add
active_conditions to ChangeMessage headers, and rename MoveOutPattern
to MovePattern (with deprecated alias for backwards compat).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@electric-sql/react@4043
npm i https://pkg.pr.new/@electric-sql/client@4043
npm i https://pkg.pr.new/@electric-sql/y-electric@4043

commit: 3bff194

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.67%. Comparing base (9335ae6) to head (3bff194).
⚠️ Report is 18 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4043      +/-   ##
==========================================
+ Coverage   85.78%   88.67%   +2.88%     
==========================================
  Files          51       25      -26     
  Lines        3399     2438     -961     
  Branches      611      613       +2     
==========================================
- Hits         2916     2162     -754     
+ Misses        481      274     -207     
  Partials        2        2              
Flag Coverage Δ
elixir ?
elixir-client ?
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 93.81% <ø> (ø)
packages/y-electric 56.05% <ø> (ø)
typescript 88.67% <ø> (ø)
unit-tests 88.67% <ø> (+2.88%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

kevin-dp added a commit to TanStack/db that referenced this pull request Mar 23, 2026
Switch to the preview package from electric-sql/electric#4043 so that
move-in event types are available without unsafe casts in tests.

NOTE: replace the preview URL with the released version before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kevin-dp added a commit to TanStack/db that referenced this pull request Mar 23, 2026
Switch to the preview package from electric-sql/electric#4043 so that
move-in event types are available without unsafe casts in tests.

NOTE: replace the preview URL with the released version before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kevin-dp kevin-dp requested a review from icehaunter March 24, 2026 08:52
kevin-dp added a commit to TanStack/db that referenced this pull request Mar 30, 2026
Switch to the preview package from electric-sql/electric#4043 so that
move-in event types are available without unsafe casts in tests.

NOTE: replace the preview URL with the released version before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kevin-dp kevin-dp merged commit deb7c32 into main Mar 30, 2026
43 checks passed
@kevin-dp kevin-dp deleted the feat/move-in-event-support branch March 30, 2026 12:17
@github-actions
Copy link
Copy Markdown
Contributor

This PR has been released! 🚀

The following packages include changes from this PR:

  • @electric-sql/client@1.5.14

Thanks for contributing to Electric!

kevin-dp added a commit to TanStack/db that referenced this pull request Mar 31, 2026
* feat(electric-db-collection): add DNF/active_conditions support for arbitrary boolean WHERE clauses

Support the new Electric server wire protocol (PR electric-sql/electric#3791):
- Change tag delimiter from `|` to `/`, replace `_` wildcards with empty
  segments (NON_PARTICIPATING positions)
- Add `active_conditions` header support for DNF visibility evaluation
- Shapes with subquery dependencies use DNF: a row is visible if ANY
  disjunct has ALL its positions satisfied in active_conditions
- Simple shapes (no subquery dependencies) retain existing behavior:
  row deleted when tag set becomes empty
- Derive disjunct_positions once per shape (not per-row like the Elixir
  client) since the DNF structure is fixed by the WHERE clause

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* ci: apply automated fixes

* chore: add changeset for DNF/active_conditions support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(electric-db-collection): add move-in support and rename MoveOutPattern to MovePattern

- Rename MoveOutPattern to MovePattern in tag-index.ts and electric.ts
- Add isMoveInMessage() type guard
- Add processMoveInEvent(): re-activates conditions for matching rows
  (silent operation, no messages emitted to collection)
- Refactor move-out in DNF mode to preserve tag index entries for
  visible rows, so move-in can find them to re-activate positions
- Handle move-in in message loop and progressive mode atomic swap

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(electric-db-collection): add move-in and DNF coverage tests

Add tests ported from the Elixir client's tag_tracker_test.exs:
- Move-in activates correct positions
- Move-out → move-in → move-out full lifecycle cycle
- Deleted rows not resurrected by move-in (tag index cleaned up)
- Orphaned tag index entries don't cause phantom deletes
- Deleted row cleans up ALL tag index entries
- Multiple patterns deactivating same row in one call
- Unit tests for parseTag, rowVisible, and deriveDisjunctPositions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: use preview @electric-sql/client with move-in support

Switch to the preview package from electric-sql/electric#4043 so that
move-in event types are available without unsafe casts in tests.

NOTE: replace the preview URL with the released version before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: apply automated fixes

* Update electric-sql/client version

* Bump electric-sql/client version

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
balegas pushed a commit that referenced this pull request Mar 31, 2026
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
balegas pushed a commit that referenced this pull request Apr 1, 2026
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
balegas pushed a commit that referenced this pull request Apr 2, 2026
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants