@furystack/entity-sync 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.0] - 2026-02-22
|
|
4
|
+
|
|
5
|
+
### 💥 Breaking Changes
|
|
6
|
+
|
|
7
|
+
### Added `collection-snapshot` variant to `ServerSyncMessage`
|
|
8
|
+
|
|
9
|
+
A new `collection-snapshot` variant has been added to the `ServerSyncMessage` union type. The server now sends a full snapshot (entries + count) whenever a collection changes, instead of individual diff messages. This ensures entries and count are always delivered together as a consistent unit.
|
|
10
|
+
|
|
11
|
+
Consumers that exhaustively match on `ServerSyncMessage.type` (without a `default`) must add a `collection-snapshot` case.
|
|
12
|
+
|
|
13
|
+
**Examples:**
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// ✅ Handle the new collection-snapshot message
|
|
17
|
+
switch (message.type) {
|
|
18
|
+
case 'collection-snapshot':
|
|
19
|
+
console.log(message.data, message.totalCount)
|
|
20
|
+
break
|
|
21
|
+
// ... other cases
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Impact:** Consumers that exhaustively match on `ServerSyncMessage.type` (without a `default`) will get a compile error until the new case is handled.
|
|
26
|
+
|
|
27
|
+
### ✨ Features
|
|
28
|
+
|
|
29
|
+
### Total count support for collection sync messages
|
|
30
|
+
|
|
31
|
+
- Added optional `totalCount` field to `snapshot` and `delta` server messages, reporting the total number of matching entities (ignoring `top`/`skip` pagination)
|
|
32
|
+
- Added `collection-snapshot` message type that delivers a full re-sync (entries + count) when a collection changes
|
|
33
|
+
|
|
3
34
|
## [0.1.1] - 2026-02-19
|
|
4
35
|
|
|
5
36
|
### ⬆️ Dependencies
|
|
@@ -12,6 +12,8 @@ export type ServerSyncMessage = {
|
|
|
12
12
|
primaryKey?: string;
|
|
13
13
|
mode: 'snapshot';
|
|
14
14
|
data: unknown;
|
|
15
|
+
/** Total count of matching entities (ignoring top/skip). Included for collection subscriptions. */
|
|
16
|
+
totalCount?: number;
|
|
15
17
|
version: SyncVersion;
|
|
16
18
|
} | {
|
|
17
19
|
type: 'subscribed';
|
|
@@ -22,6 +24,8 @@ export type ServerSyncMessage = {
|
|
|
22
24
|
primaryKey?: string;
|
|
23
25
|
mode: 'delta';
|
|
24
26
|
changes: SyncChangeEntry[];
|
|
27
|
+
/** Total count of matching entities (ignoring top/skip). Included for collection subscriptions. */
|
|
28
|
+
totalCount?: number;
|
|
25
29
|
version: SyncVersion;
|
|
26
30
|
} | {
|
|
27
31
|
type: 'entity-added';
|
|
@@ -39,6 +43,12 @@ export type ServerSyncMessage = {
|
|
|
39
43
|
subscriptionId: string;
|
|
40
44
|
id: unknown;
|
|
41
45
|
version: SyncVersion;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'collection-snapshot';
|
|
48
|
+
subscriptionId: string;
|
|
49
|
+
data: unknown[];
|
|
50
|
+
totalCount: number;
|
|
51
|
+
version: SyncVersion;
|
|
42
52
|
} | {
|
|
43
53
|
type: 'subscription-error';
|
|
44
54
|
requestId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-sync-message.d.ts","sourceRoot":"","sources":["../src/server-sync-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE,IAAI,EAAE,cAAc,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE,IAAI,EAAE,gBAAgB,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE,IAAI,EAAE,gBAAgB,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,EAAE,OAAO,CAAA;IACX,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE,IAAI,EAAE,oBAAoB,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
1
|
+
{"version":3,"file":"server-sync-message.d.ts","sourceRoot":"","sources":["../src/server-sync-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IAC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AAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
package/package.json
CHANGED
|
@@ -14,6 +14,8 @@ export type ServerSyncMessage =
|
|
|
14
14
|
primaryKey?: string
|
|
15
15
|
mode: 'snapshot'
|
|
16
16
|
data: unknown
|
|
17
|
+
/** Total count of matching entities (ignoring top/skip). Included for collection subscriptions. */
|
|
18
|
+
totalCount?: number
|
|
17
19
|
version: SyncVersion
|
|
18
20
|
}
|
|
19
21
|
| {
|
|
@@ -25,6 +27,8 @@ export type ServerSyncMessage =
|
|
|
25
27
|
primaryKey?: string
|
|
26
28
|
mode: 'delta'
|
|
27
29
|
changes: SyncChangeEntry[]
|
|
30
|
+
/** Total count of matching entities (ignoring top/skip). Included for collection subscriptions. */
|
|
31
|
+
totalCount?: number
|
|
28
32
|
version: SyncVersion
|
|
29
33
|
}
|
|
30
34
|
| {
|
|
@@ -46,6 +50,13 @@ export type ServerSyncMessage =
|
|
|
46
50
|
id: unknown
|
|
47
51
|
version: SyncVersion
|
|
48
52
|
}
|
|
53
|
+
| {
|
|
54
|
+
type: 'collection-snapshot'
|
|
55
|
+
subscriptionId: string
|
|
56
|
+
data: unknown[]
|
|
57
|
+
totalCount: number
|
|
58
|
+
version: SyncVersion
|
|
59
|
+
}
|
|
49
60
|
| {
|
|
50
61
|
type: 'subscription-error'
|
|
51
62
|
requestId: string
|