@furystack/entity-sync 0.1.1 → 1.0.1

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,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.1] - 2026-02-22
4
+
5
+ ### ⬆️ Dependencies
6
+
7
+ - Updated `@furystack/core` dependency
8
+
9
+ ## [1.0.0] - 2026-02-22
10
+
11
+ ### 💥 Breaking Changes
12
+
13
+ ### Added `collection-snapshot` variant to `ServerSyncMessage`
14
+
15
+ 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.
16
+
17
+ Consumers that exhaustively match on `ServerSyncMessage.type` (without a `default`) must add a `collection-snapshot` case.
18
+
19
+ **Examples:**
20
+
21
+ ```typescript
22
+ // ✅ Handle the new collection-snapshot message
23
+ switch (message.type) {
24
+ case 'collection-snapshot':
25
+ console.log(message.data, message.totalCount)
26
+ break
27
+ // ... other cases
28
+ }
29
+ ```
30
+
31
+ **Impact:** Consumers that exhaustively match on `ServerSyncMessage.type` (without a `default`) will get a compile error until the new case is handled.
32
+
33
+ ### ✨ Features
34
+
35
+ ### Total count support for collection sync messages
36
+
37
+ - Added optional `totalCount` field to `snapshot` and `delta` server messages, reporting the total number of matching entities (ignoring `top`/`skip` pagination)
38
+ - Added `collection-snapshot` message type that delivers a full re-sync (entries + count) when a collection changes
39
+
3
40
  ## [0.1.1] - 2026-02-19
4
41
 
5
42
  ### ⬆️ 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;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,OAAO,CAAA;IACb,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,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,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,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,qBAAqB,CAAA;IAC3B,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE,IAAI,EAAE,oBAAoB,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furystack/entity-sync",
3
- "version": "0.1.1",
3
+ "version": "1.0.1",
4
4
  "description": "Shared protocol types for FuryStack entity synchronization",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "homepage": "https://github.com/furystack/furystack",
39
39
  "dependencies": {
40
- "@furystack/core": "^15.1.0"
40
+ "@furystack/core": "^15.2.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "typescript": "^5.9.3"
@@ -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