@livestore/sync-cf 0.3.0-dev.27 → 0.3.0-dev.29

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.
@@ -1,4 +1,4 @@
1
- import { MutationEvent } from '@livestore/common/schema'
1
+ import { LiveStoreEvent } from '@livestore/common/schema'
2
2
  import { Schema } from '@livestore/utils/effect'
3
3
 
4
4
  export const PullReq = Schema.TaggedStruct('WSMessage.PullReq', {
@@ -19,7 +19,7 @@ export type SyncMetadata = typeof SyncMetadata.Type
19
19
  export const PullRes = Schema.TaggedStruct('WSMessage.PullRes', {
20
20
  batch: Schema.Array(
21
21
  Schema.Struct({
22
- mutationEventEncoded: MutationEvent.AnyEncodedGlobal,
22
+ eventEncoded: LiveStoreEvent.AnyEncodedGlobal,
23
23
  metadata: Schema.Option(SyncMetadata),
24
24
  }),
25
25
  ),
@@ -31,7 +31,7 @@ export type PullRes = typeof PullRes.Type
31
31
 
32
32
  export const PushReq = Schema.TaggedStruct('WSMessage.PushReq', {
33
33
  requestId: Schema.String,
34
- batch: Schema.Array(MutationEvent.AnyEncodedGlobal),
34
+ batch: Schema.Array(LiveStoreEvent.AnyEncodedGlobal),
35
35
  }).annotations({ title: '@livestore/sync-cf:PushReq' })
36
36
 
37
37
  export type PushReq = typeof PushReq.Type
@@ -83,10 +83,10 @@ export const makeCfSync =
83
83
  pullResponseReceived = true
84
84
 
85
85
  if (stashedPullBatch.length > 0 && msg.remaining === 0) {
86
- const pullResHead = msg.batch.at(-1)?.mutationEventEncoded.id ?? EventId.ROOT.global
86
+ const pullResHead = msg.batch.at(-1)?.eventEncoded.id ?? EventId.ROOT.global
87
87
  // Index where stashed events are greater than pullResHead
88
88
  const newPartialBatchIndex = stashedPullBatch.findIndex(
89
- (batchItem) => batchItem.mutationEventEncoded.id > pullResHead,
89
+ (batchItem) => batchItem.eventEncoded.id > pullResHead,
90
90
  )
91
91
  const batchWithNewStashedEvents =
92
92
  newPartialBatchIndex === -1 ? [] : stashedPullBatch.slice(newPartialBatchIndex)