Commit cde8af1
feat(electric-db-collection): DNF/active_conditions support (#1270)
* 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>1 parent c314c36 commit cde8af1
9 files changed
Lines changed: 3505 additions & 1649 deletions
File tree
- .changeset
- packages
- electric-db-collection
- src
- tests
- react-db
- solid-db
- vue-db
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
| 24 | + | |
22 | 25 | | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
981 | 987 | | |
982 | 988 | | |
983 | 989 | | |
984 | | - | |
| 990 | + | |
985 | 991 | | |
986 | | - | |
| 992 | + | |
987 | 993 | | |
988 | 994 | | |
989 | 995 | | |
990 | 996 | | |
991 | 997 | | |
992 | 998 | | |
993 | | - | |
| 999 | + | |
994 | 1000 | | |
995 | 1001 | | |
996 | 1002 | | |
| |||
1000 | 1006 | | |
1001 | 1007 | | |
1002 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
1003 | 1014 | | |
1004 | 1015 | | |
1005 | 1016 | | |
| |||
1074 | 1085 | | |
1075 | 1086 | | |
1076 | 1087 | | |
| 1088 | + | |
1077 | 1089 | | |
1078 | 1090 | | |
1079 | 1091 | | |
| |||
1084 | 1096 | | |
1085 | 1097 | | |
1086 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1087 | 1105 | | |
1088 | 1106 | | |
1089 | 1107 | | |
1090 | 1108 | | |
1091 | 1109 | | |
1092 | 1110 | | |
1093 | 1111 | | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1094 | 1117 | | |
1095 | 1118 | | |
1096 | 1119 | | |
| |||
1101 | 1124 | | |
1102 | 1125 | | |
1103 | 1126 | | |
| 1127 | + | |
| 1128 | + | |
1104 | 1129 | | |
1105 | 1130 | | |
1106 | 1131 | | |
| |||
1129 | 1154 | | |
1130 | 1155 | | |
1131 | 1156 | | |
| 1157 | + | |
1132 | 1158 | | |
1133 | 1159 | | |
1134 | 1160 | | |
1135 | 1161 | | |
1136 | | - | |
| 1162 | + | |
1137 | 1163 | | |
1138 | 1164 | | |
1139 | 1165 | | |
1140 | | - | |
| 1166 | + | |
1141 | 1167 | | |
1142 | 1168 | | |
1143 | 1169 | | |
1144 | 1170 | | |
1145 | 1171 | | |
1146 | 1172 | | |
1147 | | - | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
1148 | 1196 | | |
1149 | 1197 | | |
1150 | 1198 | | |
| |||
1153 | 1201 | | |
1154 | 1202 | | |
1155 | 1203 | | |
1156 | | - | |
1157 | 1204 | | |
1158 | 1205 | | |
1159 | 1206 | | |
| |||
1166 | 1213 | | |
1167 | 1214 | | |
1168 | 1215 | | |
1169 | | - | |
| 1216 | + | |
1170 | 1217 | | |
1171 | 1218 | | |
1172 | 1219 | | |
| |||
1204 | 1251 | | |
1205 | 1252 | | |
1206 | 1253 | | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
1207 | 1278 | | |
1208 | 1279 | | |
1209 | 1280 | | |
| |||
1433 | 1504 | | |
1434 | 1505 | | |
1435 | 1506 | | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
1436 | 1512 | | |
1437 | 1513 | | |
1438 | 1514 | | |
| |||
1453 | 1529 | | |
1454 | 1530 | | |
1455 | 1531 | | |
1456 | | - | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
1457 | 1538 | | |
1458 | 1539 | | |
1459 | 1540 | | |
| |||
1496 | 1577 | | |
1497 | 1578 | | |
1498 | 1579 | | |
1499 | | - | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
1500 | 1585 | | |
1501 | 1586 | | |
1502 | 1587 | | |
| |||
1593 | 1678 | | |
1594 | 1679 | | |
1595 | 1680 | | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
1596 | 1689 | | |
1597 | 1690 | | |
1598 | 1691 | | |
| |||
1672 | 1765 | | |
1673 | 1766 | | |
1674 | 1767 | | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
1675 | 1771 | | |
1676 | 1772 | | |
1677 | 1773 | | |
| |||
0 commit comments