@livestore/adapter-node 0.4.0-dev.20 → 0.4.0-dev.21

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.
@@ -9,7 +9,8 @@ if (process.execArgv.includes('--inspect')) {
9
9
 
10
10
  import type { SyncOptions } from '@livestore/common'
11
11
  import { LogConfig, UnknownError } from '@livestore/common'
12
- import { Eventlog, LeaderThreadCtx } from '@livestore/common/leader-thread'
12
+ import type { StreamEventsOptions } from '@livestore/common/leader-thread'
13
+ import { Eventlog, LeaderThreadCtx, streamEventsWithSyncState } from '@livestore/common/leader-thread'
13
14
  import type { LiveStoreSchema } from '@livestore/common/schema'
14
15
  import { LiveStoreEvent } from '@livestore/common/schema'
15
16
  import { loadSqlite3Wasm } from '@livestore/sqlite-wasm/load-wasm'
@@ -86,6 +87,20 @@ export const makeWorkerEffect = (options: WorkerOptions) => {
86
87
  const { syncProcessor } = yield* LeaderThreadCtx
87
88
  return syncProcessor.pull({ cursor })
88
89
  }).pipe(Stream.unwrapScoped),
90
+ StreamEvents: (options: WorkerSchema.LeaderWorkerInnerStreamEvents) =>
91
+ LeaderThreadCtx.pipe(
92
+ Effect.map(({ dbEventlog, syncProcessor }) => {
93
+ const { _tag: _ignored, ...payload } = options
94
+ const streamOptions = payload as StreamEventsOptions
95
+ return streamEventsWithSyncState({
96
+ dbEventlog,
97
+ syncState: syncProcessor.syncState,
98
+ options: streamOptions,
99
+ })
100
+ }),
101
+ Stream.unwrapScoped,
102
+ Stream.withSpan('@livestore/adapter-node:worker:StreamEvents'),
103
+ ),
89
104
  Export: () =>
90
105
  Effect.andThen(LeaderThreadCtx, (_) => _.dbState.export()).pipe(
91
106
  UnknownError.mapToUnknownError,
@@ -7,6 +7,7 @@ import {
7
7
  SyncState,
8
8
  UnknownError,
9
9
  } from '@livestore/common'
10
+ import { StreamEventsOptionsFields } from '@livestore/common/leader-thread'
10
11
  import { EventSequenceNumber, LiveStoreEvent } from '@livestore/common/schema'
11
12
  import { Schema, Transferable } from '@livestore/utils/effect'
12
13
 
@@ -111,6 +112,15 @@ export class LeaderWorkerInnerPullStream extends Schema.TaggedRequest<LeaderWork
111
112
  failure: UnknownError,
112
113
  }) {}
113
114
 
115
+ export class LeaderWorkerInnerStreamEvents extends Schema.TaggedRequest<LeaderWorkerInnerStreamEvents>()(
116
+ 'StreamEvents',
117
+ {
118
+ payload: StreamEventsOptionsFields,
119
+ success: LiveStoreEvent.Client.Encoded,
120
+ failure: UnknownError,
121
+ },
122
+ ) {}
123
+
114
124
  export class LeaderWorkerInnerPushToLeader extends Schema.TaggedRequest<LeaderWorkerInnerPushToLeader>()(
115
125
  'PushToLeader',
116
126
  {
@@ -215,6 +225,7 @@ export const LeaderWorkerInnerRequest = Schema.Union(
215
225
  LeaderWorkerInnerInitialMessage,
216
226
  LeaderWorkerInnerBootStatusStream,
217
227
  LeaderWorkerInnerPullStream,
228
+ LeaderWorkerInnerStreamEvents,
218
229
  LeaderWorkerInnerPushToLeader,
219
230
  LeaderWorkerInnerExport,
220
231
  LeaderWorkerInnerGetRecreateSnapshot,