@livestore/adapter-node 0.4.0-dev.2 → 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.
@@ -1,23 +1,26 @@
1
1
  import './thread-polyfill.ts';
2
2
  import type { SyncOptions } from '@livestore/common';
3
+ import { LogConfig } from '@livestore/common';
3
4
  import type { LiveStoreSchema } from '@livestore/common/schema';
4
- import { Effect } from '@livestore/utils/effect';
5
+ import { Effect, Schema } from '@livestore/utils/effect';
5
6
  import type * as otel from '@opentelemetry/api';
6
7
  import type { TestingOverrides } from './leader-thread-shared.ts';
7
8
  export type WorkerOptions = {
8
9
  schema: LiveStoreSchema;
9
10
  sync?: SyncOptions;
11
+ syncPayloadSchema?: Schema.Schema<any>;
10
12
  otelOptions?: {
11
13
  tracer?: otel.Tracer;
12
14
  /** @default 'livestore-node-leader-thread' */
13
15
  serviceName?: string;
14
16
  };
15
17
  testing?: TestingOverrides;
16
- };
18
+ } & LogConfig.WithLoggerOptions;
17
19
  export declare const getWorkerArgs: () => {
18
20
  readonly clientId: string;
19
21
  readonly storeId: string;
20
22
  readonly sessionId: string;
23
+ readonly extraArgs: Schema.JsonValue | undefined;
21
24
  };
22
25
  export declare const makeWorker: (options: WorkerOptions) => void;
23
26
  export declare const makeWorkerEffect: (options: WorkerOptions) => Effect.Effect<void, import("@effect/platform/WorkerError").WorkerError, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"make-leader-worker.d.ts","sourceRoot":"","sources":["../src/make-leader-worker.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA;AAS7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAI/D,OAAO,EACL,MAAM,EAUP,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,E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AA;IACD,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B,GAAG,SAAS,CAAC,iBAAiB,CAAA;AAE/B,eAAO,MAAM,aAAa;;;;;CAAqE,CAAA;AAE/F,eAAO,MAAM,UAAU,GAAI,SAAS,aAAa,SAEhD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,aAAa,mFAiJtD,CAAA"}
@@ -4,23 +4,25 @@ if (process.execArgv.includes('--inspect')) {
4
4
  inspector.open();
5
5
  inspector.waitForDebugger();
6
6
  }
7
- import { UnexpectedError } from '@livestore/common';
8
- import { Eventlog, LeaderThreadCtx } from '@livestore/common/leader-thread';
7
+ import { LogConfig, UnknownError } from '@livestore/common';
8
+ import { Eventlog, LeaderThreadCtx, streamEventsWithSyncState } from '@livestore/common/leader-thread';
9
9
  import { LiveStoreEvent } from '@livestore/common/schema';
10
10
  import { loadSqlite3Wasm } from '@livestore/sqlite-wasm/load-wasm';
11
11
  import { sqliteDbFactory } from '@livestore/sqlite-wasm/node';
12
- import { Effect, FetchHttpClient, identity, Layer, Logger, LogLevel, OtelTracer, Schema, Stream, WorkerRunner, } from '@livestore/utils/effect';
12
+ import { Effect, FetchHttpClient, Layer, OtelTracer, Schema, Stream, WorkerRunner } from '@livestore/utils/effect';
13
13
  import { PlatformNode } from '@livestore/utils/node';
14
14
  import { makeLeaderThread } from "./leader-thread-shared.js";
15
15
  import * as WorkerSchema from "./worker-schema.js";
16
16
  export const getWorkerArgs = () => Schema.decodeSync(WorkerSchema.WorkerArgv)(process.argv[2]);
17
17
  export const makeWorker = (options) => {
18
- makeWorkerEffect(options).pipe(Effect.provide(Logger.prettyWithThread(options.otelOptions?.serviceName ?? 'livestore-node-leader-thread')), PlatformNode.NodeRuntime.runMain);
18
+ makeWorkerEffect(options).pipe(PlatformNode.NodeRuntime.runMain);
19
19
  };
20
20
  export const makeWorkerEffect = (options) => {
21
21
  const TracingLive = options.otelOptions?.tracer
22
22
  ? Layer.unwrapEffect(Effect.map(OtelTracer.make, Layer.setTracer)).pipe(Layer.provideMerge(Layer.succeed(OtelTracer.OtelTracer, options.otelOptions.tracer)))
23
23
  : undefined;
24
+ // Merge the runtime dependencies once so we can provide them together without chaining Effect.provide.
25
+ const runtimeLayer = Layer.mergeAll(FetchHttpClient.layer, PlatformNode.NodeFileSystem.layer, TracingLive ?? Layer.empty);
24
26
  return WorkerRunner.layerSerialized(WorkerSchema.LeaderWorkerInnerRequest, {
25
27
  InitialMessage: (args) => Effect.gen(function* () {
26
28
  const sqlite3 = yield* Effect.promise(() => loadSqlite3Wasm()).pipe(Effect.withSpan('@livestore/adapter-node:leader-thread:loadSqlite3Wasm'));
@@ -31,9 +33,11 @@ export const makeWorkerEffect = (options) => {
31
33
  schema: options.schema,
32
34
  testing: options.testing,
33
35
  makeSqliteDb,
36
+ syncPayloadEncoded: args.syncPayloadEncoded,
37
+ syncPayloadSchema: options.syncPayloadSchema,
34
38
  });
35
39
  }).pipe(Layer.unwrapScoped),
36
- PushToLeader: ({ batch }) => Effect.andThen(LeaderThreadCtx, (_) => _.syncProcessor.push(batch.map((item) => new LiveStoreEvent.EncodedWithMeta(item)),
40
+ PushToLeader: ({ batch }) => Effect.andThen(LeaderThreadCtx, (_) => _.syncProcessor.push(batch.map((item) => new LiveStoreEvent.Client.EncodedWithMeta(item)),
37
41
  // We'll wait in order to keep back pressure on the client session
38
42
  { waitForProcessing: true })).pipe(Effect.uninterruptible, Effect.withSpan('@livestore/adapter-node:worker:PushToLeader')),
39
43
  BootStatusStream: () => Effect.andThen(LeaderThreadCtx, (_) => Stream.fromQueue(_.bootStatusQueue)).pipe(Stream.unwrap),
@@ -41,16 +45,37 @@ export const makeWorkerEffect = (options) => {
41
45
  const { syncProcessor } = yield* LeaderThreadCtx;
42
46
  return syncProcessor.pull({ cursor });
43
47
  }).pipe(Stream.unwrapScoped),
44
- Export: () => Effect.andThen(LeaderThreadCtx, (_) => _.dbState.export()).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:Export')),
45
- ExportEventlog: () => Effect.andThen(LeaderThreadCtx, (_) => _.dbEventlog.export()).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:ExportEventlog')),
48
+ StreamEvents: (options) => LeaderThreadCtx.pipe(Effect.map(({ dbEventlog, syncProcessor }) => {
49
+ const { _tag: _ignored, ...payload } = options;
50
+ const streamOptions = payload;
51
+ return streamEventsWithSyncState({
52
+ dbEventlog,
53
+ syncState: syncProcessor.syncState,
54
+ options: streamOptions,
55
+ });
56
+ }), Stream.unwrapScoped, Stream.withSpan('@livestore/adapter-node:worker:StreamEvents')),
57
+ Export: () => Effect.andThen(LeaderThreadCtx, (_) => _.dbState.export()).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:Export')),
58
+ ExportEventlog: () => Effect.andThen(LeaderThreadCtx, (_) => _.dbEventlog.export()).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:ExportEventlog')),
46
59
  GetLeaderHead: () => Effect.gen(function* () {
47
60
  const workerCtx = yield* LeaderThreadCtx;
48
61
  return Eventlog.getClientHeadFromDb(workerCtx.dbEventlog);
49
- }).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:GetLeaderHead')),
62
+ }).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:GetLeaderHead')),
50
63
  GetLeaderSyncState: () => Effect.gen(function* () {
51
64
  const workerCtx = yield* LeaderThreadCtx;
52
65
  return yield* workerCtx.syncProcessor.syncState;
53
- }).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:GetLeaderSyncState')),
66
+ }).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:GetLeaderSyncState')),
67
+ SyncStateStream: () => Effect.gen(function* () {
68
+ const workerCtx = yield* LeaderThreadCtx;
69
+ return workerCtx.syncProcessor.syncState.changes;
70
+ }).pipe(Stream.unwrapScoped),
71
+ GetNetworkStatus: () => Effect.gen(function* () {
72
+ const workerCtx = yield* LeaderThreadCtx;
73
+ return yield* workerCtx.networkStatus;
74
+ }).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:GetNetworkStatus')),
75
+ NetworkStatusStream: () => Effect.gen(function* () {
76
+ const workerCtx = yield* LeaderThreadCtx;
77
+ return workerCtx.networkStatus.changes;
78
+ }).pipe(Stream.unwrapScoped),
54
79
  GetRecreateSnapshot: () => Effect.gen(function* () {
55
80
  const workerCtx = yield* LeaderThreadCtx;
56
81
  // const result = yield* Deferred.await(workerCtx.initialSetupDeferred)
@@ -60,8 +85,10 @@ export const makeWorkerEffect = (options) => {
60
85
  // return cachedSnapshot ?? workerCtx.db.export()
61
86
  const snapshot = workerCtx.dbState.export();
62
87
  return { snapshot, migrationsReport: workerCtx.initialState.migrationsReport };
63
- }).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:GetRecreateSnapshot')),
64
- Shutdown: () => Effect.gen(function* () {
88
+ }).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:GetRecreateSnapshot')),
89
+ Shutdown: () =>
90
+ // @effect-diagnostics-next-line unnecessaryEffectGen:off
91
+ Effect.gen(function* () {
65
92
  // const { db, dbEventlog } = yield* LeaderThreadCtx
66
93
  yield* Effect.logDebug('[@livestore/adapter-node:worker] Shutdown');
67
94
  // if (devtools.enabled) {
@@ -72,15 +99,15 @@ export const makeWorkerEffect = (options) => {
72
99
  // Buy some time for Otel to flush
73
100
  // TODO find a cleaner way to do this
74
101
  // yield* Effect.sleep(1000)
75
- }).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:Shutdown')),
76
- ExtraDevtoolsMessage: ({ message }) => Effect.andThen(LeaderThreadCtx, (_) => _.extraIncomingMessagesQueue.offer(message)).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:worker:ExtraDevtoolsMessage')),
102
+ }).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:Shutdown')),
103
+ ExtraDevtoolsMessage: ({ message }) => Effect.andThen(LeaderThreadCtx, (_) => _.extraIncomingMessagesQueue.offer(message)).pipe(UnknownError.mapToUnknownError, Effect.withSpan('@livestore/adapter-node:worker:ExtraDevtoolsMessage')),
77
104
  }).pipe(Layer.provide(PlatformNode.NodeWorkerRunner.layer), WorkerRunner.launch, Effect.scoped, Effect.tapCauseLogPretty, Effect.annotateLogs({
78
105
  thread: options.otelOptions?.serviceName ?? 'livestore-node-leader-thread',
79
106
  processId: process.pid,
80
- }),
107
+ }), LogConfig.withLoggerConfig({ logger: options.logger, logLevel: options.logLevel }, { threadName: options.otelOptions?.serviceName ?? 'livestore-node-leader-thread' }),
81
108
  // TODO bring back with Effect 4 once it's easier to work with replacing loggers.
82
109
  // We basically only want to provide this logger if it's replacing the default logger, not if there's a custom logger already provided.
83
110
  // Effect.provide(Logger.prettyWithThread(options.otelOptions?.serviceName ?? 'livestore-node-leader-thread')),
84
- Effect.provide(FetchHttpClient.layer), Effect.provide(PlatformNode.NodeFileSystem.layer), TracingLive ? Effect.provide(TracingLive) : identity, Logger.withMinimumLogLevel(LogLevel.Debug));
111
+ Effect.provide(runtimeLayer));
85
112
  };
86
113
  //# sourceMappingURL=make-leader-worker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-leader-worker.js","sourceRoot":"","sources":["../src/make-leader-worker.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAEtC,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;IAC3C,SAAS,CAAC,IAAI,EAAE,CAAA;IAChB,SAAS,CAAC,eAAe,EAAE,CAAA;AAC7B,CAAC;AAGD,OAAO,EAAE,eAAe,EAAE,MAA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AqB;YAErB,kCAAkC;YAClC,qCAAqC;YACrC,4BAA4B;QAC9B,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,QAAQ,CAAC,yCAAyC,CAAC,CAAC;QACrG,oBAAoB,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CACpC,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CACtF,YAAY,CAAC,iBAAiB,EAC9B,MAAM,CAAC,QAAQ,CAAC,qDAAqD,CAAC,CACvE;KACJ,CAAC,CAAC,IAAI,CACL,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAClD,YAAY,CAAC,MAAM,EACnB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,YAAY,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,WAAW,IAAI,8BAA8B;QAC1E,SAAS,EAAE,OAAO,CAAC,GAAG;KACvB,CAAC,EACF,SAAS,CAAC,gBAAgB,CACxB,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,EACtD,EAAE,UAAU,EAAE,OAAO,CAAC,WAAW,EAAE,WAAW,IAAI,8BAA8B,EAAE,CACnF;IACD,iFAAiF;IACjF,uIAAuI;IACvI,+GAA+G;IAC/G,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAC7B,CAAA;AACH,CAAC,CAAA"}
@@ -1,9 +1,11 @@
1
- import { Devtools, LeaderAheadError, SyncState, UnexpectedError } from '@livestore/common';
1
+ import { Devtools, LeaderAheadError, SyncState, UnknownError } from '@livestore/common';
2
+ import { EventSequenceNumber } from '@livestore/common/schema';
2
3
  import { Schema } from '@livestore/utils/effect';
3
4
  export declare const WorkerArgv: Schema.transform<Schema.SchemaClass<unknown, string, never>, Schema.Struct<{
4
5
  clientId: typeof Schema.String;
5
6
  storeId: typeof Schema.String;
6
7
  sessionId: typeof Schema.String;
8
+ extraArgs: Schema.UndefinedOr<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
7
9
  }>>;
8
10
  export declare const StorageTypeInMemory: Schema.Struct<{
9
11
  type: Schema.Literal<["in-memory"]>;
@@ -48,7 +50,7 @@ declare const LeaderWorkerOuterInitialMessage_base: Schema.TaggedRequestClass<Le
48
50
  readonly _tag: Schema.tag<"InitialMessage">;
49
51
  } & {
50
52
  port: Schema.Schema<MessagePort, MessagePort, never>;
51
- }, typeof Schema.Void, typeof UnexpectedError>;
53
+ }, typeof Schema.Void, typeof UnknownError>;
52
54
  export declare class LeaderWorkerOuterInitialMessage extends LeaderWorkerOuterInitialMessage_base {
53
55
  }
54
56
  declare const LeaderWorkerOuterRequest_base: typeof LeaderWorkerOuterInitialMessage;
@@ -75,7 +77,7 @@ declare const LeaderWorkerInnerInitialMessage_base: Schema.TaggedRequestClass<Le
75
77
  */
76
78
  baseDirectory: Schema.optional<typeof Schema.String>;
77
79
  }>]>;
78
- syncPayload: Schema.UndefinedOr<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
80
+ syncPayloadEncoded: Schema.UndefinedOr<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
79
81
  devtools: Schema.Union<[Schema.Struct<{
80
82
  enabled: Schema.Literal<[true]>;
81
83
  schemaPath: typeof Schema.String;
@@ -86,7 +88,7 @@ declare const LeaderWorkerInnerInitialMessage_base: Schema.TaggedRequestClass<Le
86
88
  }>, Schema.Struct<{
87
89
  enabled: Schema.Literal<[false]>;
88
90
  }>]>;
89
- }, typeof Schema.Void, typeof UnexpectedError>;
91
+ }, typeof Schema.Void, typeof UnknownError>;
90
92
  export declare class LeaderWorkerInnerInitialMessage extends LeaderWorkerInnerInitialMessage_base {
91
93
  }
92
94
  declare const LeaderWorkerInnerBootStatusStream_base: Schema.TaggedRequestClass<LeaderWorkerInnerBootStatusStream, "BootStatusStream", {
@@ -113,47 +115,110 @@ declare const LeaderWorkerInnerBootStatusStream_base: Schema.TaggedRequestClass<
113
115
  }>;
114
116
  }>, Schema.Struct<{
115
117
  stage: Schema.Literal<["done"]>;
116
- }>]>, typeof UnexpectedError>;
118
+ }>]>, typeof UnknownError>;
117
119
  export declare class LeaderWorkerInnerBootStatusStream extends LeaderWorkerInnerBootStatusStream_base {
118
120
  }
119
121
  declare const LeaderWorkerInnerPullStream_base: Schema.TaggedRequestClass<LeaderWorkerInnerPullStream, "PullStream", {
120
122
  readonly _tag: Schema.tag<"PullStream">;
121
123
  } & {
122
- cursor: Schema.Struct<{
124
+ cursor: Schema.SchemaClass<{
125
+ readonly global: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
126
+ readonly client: number & import("effect/Brand").Brand<"ClientEventSequenceNumber">;
127
+ readonly rebaseGeneration: number;
128
+ }, {
129
+ readonly global: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
130
+ readonly client: number & import("effect/Brand").Brand<"ClientEventSequenceNumber">;
131
+ readonly rebaseGeneration: number;
132
+ }, never>;
133
+ }, Schema.Struct<{
134
+ payload: typeof SyncState.PayloadUpstream;
135
+ }>, typeof UnknownError>;
136
+ export declare class LeaderWorkerInnerPullStream extends LeaderWorkerInnerPullStream_base {
137
+ }
138
+ declare const LeaderWorkerInnerStreamEvents_base: Schema.TaggedRequestClass<LeaderWorkerInnerStreamEvents, "StreamEvents", {
139
+ readonly _tag: Schema.tag<"StreamEvents">;
140
+ } & {
141
+ readonly since: Schema.optional<Schema.Struct<{
142
+ global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
143
+ client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
144
+ rebaseGeneration: typeof Schema.Int;
145
+ }> & {
146
+ make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
147
+ }>;
148
+ readonly until: Schema.optional<Schema.Struct<{
123
149
  global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
124
150
  client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
125
151
  rebaseGeneration: typeof Schema.Int;
152
+ }> & {
153
+ make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
126
154
  }>;
155
+ readonly filter: Schema.optional<Schema.Array$<typeof Schema.String>>;
156
+ readonly clientIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
157
+ readonly sessionIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
158
+ readonly batchSize: Schema.optional<Schema.filter<typeof Schema.Int>>;
159
+ readonly includeClientOnly: Schema.optional<typeof Schema.Boolean>;
127
160
  }, Schema.Struct<{
128
- payload: typeof SyncState.PayloadUpstream;
129
- }>, typeof UnexpectedError>;
130
- export declare class LeaderWorkerInnerPullStream extends LeaderWorkerInnerPullStream_base {
161
+ name: typeof Schema.String;
162
+ args: typeof Schema.Any;
163
+ seqNum: Schema.Struct<{
164
+ global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
165
+ client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
166
+ rebaseGeneration: typeof Schema.Int;
167
+ }> & {
168
+ make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
169
+ };
170
+ parentSeqNum: Schema.Struct<{
171
+ global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
172
+ client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
173
+ rebaseGeneration: typeof Schema.Int;
174
+ }> & {
175
+ make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
176
+ };
177
+ clientId: typeof Schema.String;
178
+ sessionId: typeof Schema.String;
179
+ }>, typeof UnknownError>;
180
+ export declare class LeaderWorkerInnerStreamEvents extends LeaderWorkerInnerStreamEvents_base {
131
181
  }
132
182
  declare const LeaderWorkerInnerPushToLeader_base: Schema.TaggedRequestClass<LeaderWorkerInnerPushToLeader, "PushToLeader", {
133
183
  readonly _tag: Schema.tag<"PushToLeader">;
134
184
  } & {
135
- batch: Schema.Array$<Schema.Struct<{
136
- name: typeof Schema.String;
137
- args: typeof Schema.Any;
138
- seqNum: Schema.Struct<{
139
- global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
140
- client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
141
- rebaseGeneration: typeof Schema.Int;
142
- }>;
143
- parentSeqNum: Schema.Struct<{
144
- global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
145
- client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
146
- rebaseGeneration: typeof Schema.Int;
147
- }>;
148
- clientId: typeof Schema.String;
149
- sessionId: typeof Schema.String;
150
- }>>;
151
- }, typeof Schema.Void, Schema.Union<[typeof UnexpectedError, typeof LeaderAheadError]>>;
185
+ batch: Schema.Array$<Schema.SchemaClass<{
186
+ readonly clientId: string;
187
+ readonly sessionId: string;
188
+ readonly name: string;
189
+ readonly args: any;
190
+ readonly seqNum: {
191
+ readonly global: any;
192
+ readonly client: any;
193
+ readonly rebaseGeneration: number;
194
+ };
195
+ readonly parentSeqNum: {
196
+ readonly global: any;
197
+ readonly client: any;
198
+ readonly rebaseGeneration: number;
199
+ };
200
+ }, {
201
+ readonly clientId: string;
202
+ readonly sessionId: string;
203
+ readonly name: string;
204
+ readonly args: any;
205
+ readonly seqNum: {
206
+ readonly global: any;
207
+ readonly client: any;
208
+ readonly rebaseGeneration: number;
209
+ };
210
+ readonly parentSeqNum: {
211
+ readonly global: any;
212
+ readonly client: any;
213
+ readonly rebaseGeneration: number;
214
+ };
215
+ }, never>>;
216
+ }, Schema.Schema<void, void, never>, Schema.Union<[typeof UnknownError, typeof LeaderAheadError]>>;
152
217
  export declare class LeaderWorkerInnerPushToLeader extends LeaderWorkerInnerPushToLeader_base {
153
218
  }
154
219
  declare const LeaderWorkerInnerExport_base: Schema.TaggedRequestClass<LeaderWorkerInnerExport, "Export", {
155
220
  readonly _tag: Schema.tag<"Export">;
156
- }, Schema.Schema<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>, never>, typeof UnexpectedError>;
221
+ }, Schema.Schema<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>, never>, typeof UnknownError>;
157
222
  export declare class LeaderWorkerInnerExport extends LeaderWorkerInnerExport_base {
158
223
  }
159
224
  declare const LeaderWorkerInnerGetRecreateSnapshot_base: Schema.TaggedRequestClass<LeaderWorkerInnerGetRecreateSnapshot, "GetRecreateSnapshot", {
@@ -169,31 +234,62 @@ declare const LeaderWorkerInnerGetRecreateSnapshot_base: Schema.TaggedRequestCla
169
234
  }>;
170
235
  }>>;
171
236
  }>;
172
- }>, typeof UnexpectedError>;
237
+ }>, typeof UnknownError>;
173
238
  export declare class LeaderWorkerInnerGetRecreateSnapshot extends LeaderWorkerInnerGetRecreateSnapshot_base {
174
239
  }
175
240
  declare const LeaderWorkerInnerExportEventlog_base: Schema.TaggedRequestClass<LeaderWorkerInnerExportEventlog, "ExportEventlog", {
176
241
  readonly _tag: Schema.tag<"ExportEventlog">;
177
- }, Schema.Schema<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>, never>, typeof UnexpectedError>;
242
+ }, Schema.Schema<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>, never>, typeof UnknownError>;
178
243
  export declare class LeaderWorkerInnerExportEventlog extends LeaderWorkerInnerExportEventlog_base {
179
244
  }
180
245
  declare const LeaderWorkerInnerGetLeaderHead_base: Schema.TaggedRequestClass<LeaderWorkerInnerGetLeaderHead, "GetLeaderHead", {
181
246
  readonly _tag: Schema.tag<"GetLeaderHead">;
182
- }, Schema.Struct<{
183
- global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
184
- client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
185
- rebaseGeneration: typeof Schema.Int;
186
- }>, typeof UnexpectedError>;
247
+ }, Schema.SchemaClass<{
248
+ readonly global: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
249
+ readonly client: number & import("effect/Brand").Brand<"ClientEventSequenceNumber">;
250
+ readonly rebaseGeneration: number;
251
+ }, {
252
+ readonly global: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
253
+ readonly client: number & import("effect/Brand").Brand<"ClientEventSequenceNumber">;
254
+ readonly rebaseGeneration: number;
255
+ }, never>, typeof UnknownError>;
187
256
  export declare class LeaderWorkerInnerGetLeaderHead extends LeaderWorkerInnerGetLeaderHead_base {
188
257
  }
189
258
  declare const LeaderWorkerInnerGetLeaderSyncState_base: Schema.TaggedRequestClass<LeaderWorkerInnerGetLeaderSyncState, "GetLeaderSyncState", {
190
259
  readonly _tag: Schema.tag<"GetLeaderSyncState">;
191
- }, typeof SyncState.SyncState, typeof UnexpectedError>;
260
+ }, typeof SyncState.SyncState, typeof UnknownError>;
192
261
  export declare class LeaderWorkerInnerGetLeaderSyncState extends LeaderWorkerInnerGetLeaderSyncState_base {
193
262
  }
263
+ declare const LeaderWorkerInnerSyncStateStream_base: Schema.TaggedRequestClass<LeaderWorkerInnerSyncStateStream, "SyncStateStream", {
264
+ readonly _tag: Schema.tag<"SyncStateStream">;
265
+ }, typeof SyncState.SyncState, typeof UnknownError>;
266
+ export declare class LeaderWorkerInnerSyncStateStream extends LeaderWorkerInnerSyncStateStream_base {
267
+ }
268
+ declare const LeaderWorkerInnerGetNetworkStatus_base: Schema.TaggedRequestClass<LeaderWorkerInnerGetNetworkStatus, "GetNetworkStatus", {
269
+ readonly _tag: Schema.tag<"GetNetworkStatus">;
270
+ }, Schema.Struct<{
271
+ isConnected: typeof Schema.Boolean;
272
+ timestampMs: typeof Schema.Number;
273
+ devtools: Schema.Struct<{
274
+ latchClosed: typeof Schema.Boolean;
275
+ }>;
276
+ }>, typeof UnknownError>;
277
+ export declare class LeaderWorkerInnerGetNetworkStatus extends LeaderWorkerInnerGetNetworkStatus_base {
278
+ }
279
+ declare const LeaderWorkerInnerNetworkStatusStream_base: Schema.TaggedRequestClass<LeaderWorkerInnerNetworkStatusStream, "NetworkStatusStream", {
280
+ readonly _tag: Schema.tag<"NetworkStatusStream">;
281
+ }, Schema.Struct<{
282
+ isConnected: typeof Schema.Boolean;
283
+ timestampMs: typeof Schema.Number;
284
+ devtools: Schema.Struct<{
285
+ latchClosed: typeof Schema.Boolean;
286
+ }>;
287
+ }>, typeof UnknownError>;
288
+ export declare class LeaderWorkerInnerNetworkStatusStream extends LeaderWorkerInnerNetworkStatusStream_base {
289
+ }
194
290
  declare const LeaderWorkerInnerShutdown_base: Schema.TaggedRequestClass<LeaderWorkerInnerShutdown, "Shutdown", {
195
291
  readonly _tag: Schema.tag<"Shutdown">;
196
- }, typeof Schema.Void, typeof UnexpectedError>;
292
+ }, typeof Schema.Void, typeof UnknownError>;
197
293
  export declare class LeaderWorkerInnerShutdown extends LeaderWorkerInnerShutdown_base {
198
294
  }
199
295
  declare const LeaderWorkerInnerExtraDevtoolsMessage_base: Schema.TaggedRequestClass<LeaderWorkerInnerExtraDevtoolsMessage, "ExtraDevtoolsMessage", {
@@ -201,27 +297,28 @@ declare const LeaderWorkerInnerExtraDevtoolsMessage_base: Schema.TaggedRequestCl
201
297
  } & {
202
298
  message: Schema.Union<[typeof Devtools.Leader.SnapshotReq, Schema.TaggedStruct<"LSD.Leader.LoadDatabaseFile.Request", {
203
299
  data: Schema.Schema<Uint8Array<ArrayBuffer>>;
300
+ batchId: Schema.optional<typeof Schema.String>;
204
301
  } & {
205
302
  readonly requestId: typeof Schema.String;
206
- readonly liveStoreVersion: Schema.Literal<["0.4.0-dev.2"]>;
303
+ readonly liveStoreVersion: Schema.Literal<["0.4.0-dev.21"]>;
207
304
  readonly clientId: typeof Schema.String;
208
305
  }>, typeof Devtools.Leader.EventlogReq, Schema.TaggedStruct<"LSD.Leader.ResetAllData.Request", {
209
306
  mode: Schema.Literal<["all-data", "only-app-db"]>;
210
307
  } & {
211
308
  readonly requestId: typeof Schema.String;
212
- readonly liveStoreVersion: Schema.Literal<["0.4.0-dev.2"]>;
309
+ readonly liveStoreVersion: Schema.Literal<["0.4.0-dev.21"]>;
213
310
  readonly clientId: typeof Schema.String;
214
311
  }>, typeof Devtools.Leader.NetworkStatusSubscribe, typeof Devtools.Leader.NetworkStatusUnsubscribe, typeof Devtools.Leader.Disconnect, typeof Devtools.Leader.CommitEventReq, typeof Devtools.Leader.Ping, typeof Devtools.Leader.DatabaseFileInfoReq, typeof Devtools.Leader.SyncHistorySubscribe, typeof Devtools.Leader.SyncHistoryUnsubscribe, typeof Devtools.Leader.SyncingInfoReq, typeof Devtools.Leader.SyncHeadSubscribe, typeof Devtools.Leader.SyncHeadUnsubscribe, Schema.TaggedStruct<"LSD.Leader.SetSyncLatch.Request", {
215
312
  closeLatch: typeof Schema.Boolean;
216
313
  } & {
217
314
  readonly requestId: typeof Schema.String;
218
- readonly liveStoreVersion: Schema.Literal<["0.4.0-dev.2"]>;
315
+ readonly liveStoreVersion: Schema.Literal<["0.4.0-dev.21"]>;
219
316
  readonly clientId: typeof Schema.String;
220
317
  }>]>;
221
- }, typeof Schema.Void, typeof UnexpectedError>;
318
+ }, typeof Schema.Void, typeof UnknownError>;
222
319
  export declare class LeaderWorkerInnerExtraDevtoolsMessage extends LeaderWorkerInnerExtraDevtoolsMessage_base {
223
320
  }
224
- export declare const LeaderWorkerInnerRequest: Schema.Union<[typeof LeaderWorkerInnerInitialMessage, typeof LeaderWorkerInnerBootStatusStream, typeof LeaderWorkerInnerPullStream, typeof LeaderWorkerInnerPushToLeader, typeof LeaderWorkerInnerExport, typeof LeaderWorkerInnerGetRecreateSnapshot, typeof LeaderWorkerInnerExportEventlog, typeof LeaderWorkerInnerGetLeaderHead, typeof LeaderWorkerInnerGetLeaderSyncState, typeof LeaderWorkerInnerShutdown, typeof LeaderWorkerInnerExtraDevtoolsMessage]>;
321
+ export declare const LeaderWorkerInnerRequest: Schema.Union<[typeof LeaderWorkerInnerInitialMessage, typeof LeaderWorkerInnerBootStatusStream, typeof LeaderWorkerInnerPullStream, typeof LeaderWorkerInnerStreamEvents, typeof LeaderWorkerInnerPushToLeader, typeof LeaderWorkerInnerExport, typeof LeaderWorkerInnerGetRecreateSnapshot, typeof LeaderWorkerInnerExportEventlog, typeof LeaderWorkerInnerGetLeaderHead, typeof LeaderWorkerInnerGetLeaderSyncState, typeof LeaderWorkerInnerSyncStateStream, typeof LeaderWorkerInnerGetNetworkStatus, typeof LeaderWorkerInnerNetworkStatusStream, typeof LeaderWorkerInnerShutdown, typeof LeaderWorkerInnerExtraDevtoolsMessage]>;
225
322
  export type LeaderWorkerInnerRequest = typeof LeaderWorkerInnerRequest.Type;
226
323
  export {};
227
324
  //# sourceMappingURL=worker-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-schema.d.ts","sourceRoot":"","sources":["../src/worker-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,gBAAgB,EAAoB,SAAS,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExH,OAAO,EAAE,MAAM,EAAgB,MAAM,yBAAyB,CAAA;AAE9D,eAAO,MAAM,UAAU;;;;GAMtB,CAAA;AAED,eAAO,MAAM,mBAAmB;;IAE9B;;;OAGG;;EAEH,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;AAEjE,eAAO,MAAM,aAAa;;IAExB;;;;OAIG;;EAEH,CAAA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AAkC,SAAQ,sCAOtD;CAAG;;;;;;;;;;;;;;;;AAEJ,qBAAa,2BAA4B,SAAQ,gCAQ/C;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,6BAA8B,SAAQ,kCAOlD;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEJ,qBAAa,6BAA8B,SAAQ,kCASlD;CAAG;;;;AAEJ,qBAAa,uBAAwB,SAAQ,4BAI3C;CAAG;;;;cAOsC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;;;;;;;;;;;AALjF,qBAAa,oCAAqC,SAAQ,yCAUzD;CAAG;;;;AAEJ,qBAAa,+BAAgC,SAAQ,oCAOpD;CAAG;;;;;;;;;;;;AAEJ,qBAAa,8BAA+B,SAAQ,mCAOnD;CAAG;;;;AAEJ,qBAAa,mCAAoC,SAAQ,wCAOxD;CAAG;;;;AAEJ,qBAAa,gCAAiC,SAAQ,qCAOrD;CAAG;;;;;;;;;;AAEJ,qBAAa,iCAAkC,SAAQ,sCAOtD;CAAG;;;;;;;;;;AAEJ,qBAAa,oCAAqC,SAAQ,yCAOzD;CAAG;;;;AAEJ,qBAAa,yBAA0B,SAAQ,8BAI7C;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,qCAAsC,SAAQ,0CAS1D;CAAG;AAEJ,eAAO,MAAM,wBAAwB,0mBAgBpC,CAAA;AACD,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAC,IAAI,CAAA"}
@@ -1,10 +1,12 @@
1
- import { BootStatus, Devtools, LeaderAheadError, MigrationsReport, SyncState, UnexpectedError } from '@livestore/common';
1
+ import { BootStatus, Devtools, LeaderAheadError, MigrationsReport, SyncBackend, SyncState, UnknownError, } from '@livestore/common';
2
+ import { StreamEventsOptionsFields } from '@livestore/common/leader-thread';
2
3
  import { EventSequenceNumber, LiveStoreEvent } from '@livestore/common/schema';
3
4
  import { Schema, Transferable } from '@livestore/utils/effect';
4
5
  export const WorkerArgv = Schema.parseJson(Schema.Struct({
5
6
  clientId: Schema.String,
6
7
  storeId: Schema.String,
7
8
  sessionId: Schema.String,
9
+ extraArgs: Schema.UndefinedOr(Schema.JsonValue),
8
10
  }));
9
11
  export const StorageTypeInMemory = Schema.Struct({
10
12
  type: Schema.Literal('in-memory'),
@@ -34,7 +36,7 @@ export const SyncBackendOptions = Schema.Record({ key: Schema.String, value: Sch
34
36
  export class LeaderWorkerOuterInitialMessage extends Schema.TaggedRequest()('InitialMessage', {
35
37
  payload: { port: Transferable.MessagePort },
36
38
  success: Schema.Void,
37
- failure: UnexpectedError,
39
+ failure: UnknownError,
38
40
  }) {
39
41
  }
40
42
  export class LeaderWorkerOuterRequest extends Schema.Union(LeaderWorkerOuterInitialMessage) {
@@ -44,7 +46,7 @@ export class LeaderWorkerInnerInitialMessage extends Schema.TaggedRequest()('Ini
44
46
  storeId: Schema.String,
45
47
  clientId: Schema.String,
46
48
  storage: StorageType,
47
- syncPayload: Schema.UndefinedOr(Schema.JsonValue),
49
+ syncPayloadEncoded: Schema.UndefinedOr(Schema.JsonValue),
48
50
  devtools: Schema.Union(Schema.Struct({
49
51
  enabled: Schema.Literal(true),
50
52
  schemaPath: Schema.String,
@@ -55,37 +57,43 @@ export class LeaderWorkerInnerInitialMessage extends Schema.TaggedRequest()('Ini
55
57
  }), Schema.Struct({ enabled: Schema.Literal(false) })),
56
58
  },
57
59
  success: Schema.Void,
58
- failure: UnexpectedError,
60
+ failure: UnknownError,
59
61
  }) {
60
62
  }
61
63
  export class LeaderWorkerInnerBootStatusStream extends Schema.TaggedRequest()('BootStatusStream', {
62
64
  payload: {},
63
65
  success: BootStatus,
64
- failure: UnexpectedError,
66
+ failure: UnknownError,
65
67
  }) {
66
68
  }
67
69
  export class LeaderWorkerInnerPullStream extends Schema.TaggedRequest()('PullStream', {
68
70
  payload: {
69
- cursor: EventSequenceNumber.EventSequenceNumber,
71
+ cursor: Schema.typeSchema(EventSequenceNumber.Client.Composite),
70
72
  },
71
73
  success: Schema.Struct({
72
74
  payload: SyncState.PayloadUpstream,
73
75
  }),
74
- failure: UnexpectedError,
76
+ failure: UnknownError,
77
+ }) {
78
+ }
79
+ export class LeaderWorkerInnerStreamEvents extends Schema.TaggedRequest()('StreamEvents', {
80
+ payload: StreamEventsOptionsFields,
81
+ success: LiveStoreEvent.Client.Encoded,
82
+ failure: UnknownError,
75
83
  }) {
76
84
  }
77
85
  export class LeaderWorkerInnerPushToLeader extends Schema.TaggedRequest()('PushToLeader', {
78
86
  payload: {
79
- batch: Schema.Array(LiveStoreEvent.AnyEncoded),
87
+ batch: Schema.Array(Schema.typeSchema(LiveStoreEvent.Client.Encoded)),
80
88
  },
81
89
  success: Schema.Void,
82
- failure: Schema.Union(UnexpectedError, LeaderAheadError),
90
+ failure: Schema.Union(UnknownError, LeaderAheadError),
83
91
  }) {
84
92
  }
85
93
  export class LeaderWorkerInnerExport extends Schema.TaggedRequest()('Export', {
86
94
  payload: {},
87
95
  success: Transferable.Uint8Array,
88
- failure: UnexpectedError,
96
+ failure: UnknownError,
89
97
  }) {
90
98
  }
91
99
  export class LeaderWorkerInnerGetRecreateSnapshot extends Schema.TaggedRequest()('GetRecreateSnapshot', {
@@ -94,31 +102,49 @@ export class LeaderWorkerInnerGetRecreateSnapshot extends Schema.TaggedRequest()
94
102
  snapshot: Transferable.Uint8Array,
95
103
  migrationsReport: MigrationsReport,
96
104
  }),
97
- failure: UnexpectedError,
105
+ failure: UnknownError,
98
106
  }) {
99
107
  }
100
108
  export class LeaderWorkerInnerExportEventlog extends Schema.TaggedRequest()('ExportEventlog', {
101
109
  payload: {},
102
110
  success: Transferable.Uint8Array,
103
- failure: UnexpectedError,
111
+ failure: UnknownError,
104
112
  }) {
105
113
  }
106
114
  export class LeaderWorkerInnerGetLeaderHead extends Schema.TaggedRequest()('GetLeaderHead', {
107
115
  payload: {},
108
- success: EventSequenceNumber.EventSequenceNumber,
109
- failure: UnexpectedError,
116
+ success: Schema.typeSchema(EventSequenceNumber.Client.Composite),
117
+ failure: UnknownError,
110
118
  }) {
111
119
  }
112
120
  export class LeaderWorkerInnerGetLeaderSyncState extends Schema.TaggedRequest()('GetLeaderSyncState', {
113
121
  payload: {},
114
122
  success: SyncState.SyncState,
115
- failure: UnexpectedError,
123
+ failure: UnknownError,
124
+ }) {
125
+ }
126
+ export class LeaderWorkerInnerSyncStateStream extends Schema.TaggedRequest()('SyncStateStream', {
127
+ payload: {},
128
+ success: SyncState.SyncState,
129
+ failure: UnknownError,
130
+ }) {
131
+ }
132
+ export class LeaderWorkerInnerGetNetworkStatus extends Schema.TaggedRequest()('GetNetworkStatus', {
133
+ payload: {},
134
+ success: SyncBackend.NetworkStatus,
135
+ failure: UnknownError,
136
+ }) {
137
+ }
138
+ export class LeaderWorkerInnerNetworkStatusStream extends Schema.TaggedRequest()('NetworkStatusStream', {
139
+ payload: {},
140
+ success: SyncBackend.NetworkStatus,
141
+ failure: UnknownError,
116
142
  }) {
117
143
  }
118
144
  export class LeaderWorkerInnerShutdown extends Schema.TaggedRequest()('Shutdown', {
119
145
  payload: {},
120
146
  success: Schema.Void,
121
- failure: UnexpectedError,
147
+ failure: UnknownError,
122
148
  }) {
123
149
  }
124
150
  export class LeaderWorkerInnerExtraDevtoolsMessage extends Schema.TaggedRequest()('ExtraDevtoolsMessage', {
@@ -126,8 +152,8 @@ export class LeaderWorkerInnerExtraDevtoolsMessage extends Schema.TaggedRequest(
126
152
  message: Devtools.Leader.MessageToApp,
127
153
  },
128
154
  success: Schema.Void,
129
- failure: UnexpectedError,
155
+ failure: UnknownError,
130
156
  }) {
131
157
  }
132
- export const LeaderWorkerInnerRequest = Schema.Union(LeaderWorkerInnerInitialMessage, LeaderWorkerInnerBootStatusStream, LeaderWorkerInnerPullStream, LeaderWorkerInnerPushToLeader, LeaderWorkerInnerExport, LeaderWorkerInnerGetRecreateSnapshot, LeaderWorkerInnerExportEventlog, LeaderWorkerInnerGetLeaderHead, LeaderWorkerInnerGetLeaderSyncState, LeaderWorkerInnerShutdown, LeaderWorkerInnerExtraDevtoolsMessage);
158
+ export const LeaderWorkerInnerRequest = Schema.Union(LeaderWorkerInnerInitialMessage, LeaderWorkerInnerBootStatusStream, LeaderWorkerInnerPullStream, LeaderWorkerInnerStreamEvents, LeaderWorkerInnerPushToLeader, LeaderWorkerInnerExport, LeaderWorkerInnerGetRecreateSnapshot, LeaderWorkerInnerExportEventlog, LeaderWorkerInnerGetLeaderHead, LeaderWorkerInnerGetLeaderSyncState, LeaderWorkerInnerSyncStateStream, LeaderWorkerInnerGetNetworkStatus, LeaderWorkerInnerNetworkStatusStream, LeaderWorkerInnerShutdown, LeaderWorkerInnerExtraDevtoolsMessage);
133
159
  //# sourceMappingURL=worker-schema.js.map