@livestore/common 0.4.0-dev.20 → 0.4.0-dev.22
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/dist/.tsbuildinfo +1 -1
- package/dist/ClientSessionLeaderThreadProxy.d.ts +10 -0
- package/dist/ClientSessionLeaderThreadProxy.d.ts.map +1 -1
- package/dist/ClientSessionLeaderThreadProxy.js.map +1 -1
- package/dist/adapter-types.d.ts +23 -0
- package/dist/adapter-types.d.ts.map +1 -1
- package/dist/adapter-types.js +27 -1
- package/dist/adapter-types.js.map +1 -1
- package/dist/devtools/devtools-messages-client-session.d.ts +42 -22
- package/dist/devtools/devtools-messages-client-session.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-client-session.js +12 -1
- package/dist/devtools/devtools-messages-client-session.js.map +1 -1
- package/dist/devtools/devtools-messages-common.d.ts +12 -6
- package/dist/devtools/devtools-messages-common.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-common.js +7 -2
- package/dist/devtools/devtools-messages-common.js.map +1 -1
- package/dist/devtools/devtools-messages-leader.d.ts +47 -25
- package/dist/devtools/devtools-messages-leader.d.ts.map +1 -1
- package/dist/devtools/devtools-messages-leader.js +13 -1
- package/dist/devtools/devtools-messages-leader.js.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.d.ts +33 -0
- package/dist/leader-thread/LeaderSyncProcessor.d.ts.map +1 -1
- package/dist/leader-thread/LeaderSyncProcessor.js +12 -12
- package/dist/leader-thread/LeaderSyncProcessor.js.map +1 -1
- package/dist/leader-thread/eventlog.d.ts +6 -1
- package/dist/leader-thread/eventlog.d.ts.map +1 -1
- package/dist/leader-thread/eventlog.js +59 -2
- package/dist/leader-thread/eventlog.js.map +1 -1
- package/dist/leader-thread/leader-worker-devtools.js +38 -6
- package/dist/leader-thread/leader-worker-devtools.js.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.d.ts +4 -2
- package/dist/leader-thread/make-leader-thread-layer.d.ts.map +1 -1
- package/dist/leader-thread/make-leader-thread-layer.js +5 -1
- package/dist/leader-thread/make-leader-thread-layer.js.map +1 -1
- package/dist/leader-thread/materialize-event.d.ts.map +1 -1
- package/dist/leader-thread/materialize-event.js +3 -0
- package/dist/leader-thread/materialize-event.js.map +1 -1
- package/dist/leader-thread/mod.d.ts +1 -0
- package/dist/leader-thread/mod.d.ts.map +1 -1
- package/dist/leader-thread/mod.js +1 -0
- package/dist/leader-thread/mod.js.map +1 -1
- package/dist/leader-thread/stream-events.d.ts +56 -0
- package/dist/leader-thread/stream-events.d.ts.map +1 -0
- package/dist/leader-thread/stream-events.js +166 -0
- package/dist/leader-thread/stream-events.js.map +1 -0
- package/dist/leader-thread/types.d.ts +77 -1
- package/dist/leader-thread/types.d.ts.map +1 -1
- package/dist/leader-thread/types.js +13 -0
- package/dist/leader-thread/types.js.map +1 -1
- package/dist/otel.d.ts +2 -1
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +5 -0
- package/dist/otel.js.map +1 -1
- package/dist/schema/EventDef/define.d.ts +14 -0
- package/dist/schema/EventDef/define.d.ts.map +1 -1
- package/dist/schema/EventDef/define.js +1 -0
- package/dist/schema/EventDef/define.js.map +1 -1
- package/dist/schema/EventDef/deprecated.d.ts +99 -0
- package/dist/schema/EventDef/deprecated.d.ts.map +1 -0
- package/dist/schema/EventDef/deprecated.js +144 -0
- package/dist/schema/EventDef/deprecated.js.map +1 -0
- package/dist/schema/EventDef/deprecated.test.d.ts +2 -0
- package/dist/schema/EventDef/deprecated.test.d.ts.map +1 -0
- package/dist/schema/EventDef/deprecated.test.js +95 -0
- package/dist/schema/EventDef/deprecated.test.js.map +1 -0
- package/dist/schema/EventDef/event-def.d.ts +4 -0
- package/dist/schema/EventDef/event-def.d.ts.map +1 -1
- package/dist/schema/EventDef/mod.d.ts +1 -0
- package/dist/schema/EventDef/mod.d.ts.map +1 -1
- package/dist/schema/EventDef/mod.js +1 -0
- package/dist/schema/EventDef/mod.js.map +1 -1
- package/dist/schema/LiveStoreEvent/client.d.ts +6 -6
- package/dist/schema/state/sqlite/client-document-def.d.ts +1 -0
- package/dist/schema/state/sqlite/client-document-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.js +17 -8
- package/dist/schema/state/sqlite/client-document-def.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.test.js +120 -1
- package/dist/schema/state/sqlite/client-document-def.test.js.map +1 -1
- package/dist/schema/state/sqlite/column-def.test.js +2 -3
- package/dist/schema/state/sqlite/column-def.test.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/api.d.ts +29 -12
- package/dist/schema/state/sqlite/query-builder/api.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.d.ts.map +1 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.js +71 -1
- package/dist/schema/state/sqlite/query-builder/astToSql.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/impl.test.js +109 -1
- package/dist/schema/state/sqlite/query-builder/impl.test.js.map +1 -1
- package/dist/schema/state/sqlite/table-def.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.d.ts.map +1 -1
- package/dist/sync/ClientSessionSyncProcessor.js +6 -2
- package/dist/sync/ClientSessionSyncProcessor.js.map +1 -1
- package/dist/version.d.ts +7 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +8 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -4
- package/src/ClientSessionLeaderThreadProxy.ts +10 -0
- package/src/adapter-types.ts +30 -0
- package/src/devtools/devtools-messages-client-session.ts +12 -0
- package/src/devtools/devtools-messages-common.ts +7 -3
- package/src/devtools/devtools-messages-leader.ts +13 -0
- package/src/leader-thread/LeaderSyncProcessor.ts +116 -42
- package/src/leader-thread/eventlog.ts +80 -4
- package/src/leader-thread/leader-worker-devtools.ts +52 -6
- package/src/leader-thread/make-leader-thread-layer.ts +8 -0
- package/src/leader-thread/materialize-event.ts +4 -0
- package/src/leader-thread/mod.ts +1 -0
- package/src/leader-thread/stream-events.ts +201 -0
- package/src/leader-thread/types.ts +49 -1
- package/src/otel.ts +10 -0
- package/src/schema/EventDef/define.ts +16 -0
- package/src/schema/EventDef/deprecated.test.ts +128 -0
- package/src/schema/EventDef/deprecated.ts +175 -0
- package/src/schema/EventDef/event-def.ts +5 -0
- package/src/schema/EventDef/mod.ts +1 -0
- package/src/schema/state/sqlite/client-document-def.test.ts +140 -2
- package/src/schema/state/sqlite/client-document-def.ts +25 -26
- package/src/schema/state/sqlite/column-def.test.ts +2 -3
- package/src/schema/state/sqlite/db-schema/dsl/mod.ts +10 -16
- package/src/schema/state/sqlite/query-builder/api.ts +31 -4
- package/src/schema/state/sqlite/query-builder/astToSql.ts +81 -1
- package/src/schema/state/sqlite/query-builder/impl.test.ts +141 -1
- package/src/schema/state/sqlite/table-def.ts +9 -8
- package/src/sync/ClientSessionSyncProcessor.ts +26 -13
- package/src/version.ts +9 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Chunk, Effect, Option, Queue, Stream } from '@livestore/utils/effect';
|
|
2
|
+
import { EventSequenceNumber } from "../schema/mod.js";
|
|
3
|
+
import * as Eventlog from "./eventlog.js";
|
|
4
|
+
/**
|
|
5
|
+
* Streams events for leader-thread adapters.
|
|
6
|
+
*
|
|
7
|
+
* Provides a continuous stream from the eventlog as the upstream head advances.
|
|
8
|
+
* When an until event is passed in the stream finalizes upon reaching it.
|
|
9
|
+
*
|
|
10
|
+
* The batch size is set to 100 by default as this was meassured to provide the
|
|
11
|
+
* best performance and 1000 as the upper limit.
|
|
12
|
+
*
|
|
13
|
+
* Adapters that call this helper:
|
|
14
|
+
* - `packages/@livestore/adapter-web/src/in-memory/in-memory-adapter.ts`
|
|
15
|
+
* - `packages/@livestore/adapter-web/src/web-worker/leader-worker/make-leader-worker.ts`
|
|
16
|
+
* - `packages/@livestore/adapter-node/src/client-session/adapter.ts`
|
|
17
|
+
* - `packages/@livestore/adapter-node/src/make-leader-worker.ts`
|
|
18
|
+
* - `packages/@livestore/adapter-cloudflare/src/make-adapter.ts`
|
|
19
|
+
*
|
|
20
|
+
* Each caller resolves dependencies inside the leader scope before invoking this helper,
|
|
21
|
+
* so the stream stays environment-agnostic and does not leak `LeaderThreadCtx` into runtime
|
|
22
|
+
* entry points such as `Store.eventsStream`.
|
|
23
|
+
*
|
|
24
|
+
* Test files:
|
|
25
|
+
* Unit: `tests/package-common/src/leader-thread/stream-events.test.ts`
|
|
26
|
+
* Integration: `packages/@livestore/livestore/src/store/store-eventstream.test.ts`
|
|
27
|
+
* Performance: `tests/perf-eventlog/tests/suites/event-streaming.test.ts`
|
|
28
|
+
*
|
|
29
|
+
* Optimization explorations
|
|
30
|
+
*
|
|
31
|
+
* In order to alleviate the occurence of many small queries when the syncState
|
|
32
|
+
* is sequentially progressing quickly we have explored some time-based batching
|
|
33
|
+
* approaches. It remains to be determined if and when the added complexity of
|
|
34
|
+
* these approaches are worth the benefit. They come with some drawbacks such as
|
|
35
|
+
* degraded time to first event or general performance degredation for larger
|
|
36
|
+
* query steps. These aspects can likely be mitigated with some more work but
|
|
37
|
+
* that is best assessed when we have a final implementation of event streaming
|
|
38
|
+
* with support for session and leader level streams.
|
|
39
|
+
*
|
|
40
|
+
* Fetch plans into a Sink
|
|
41
|
+
* https://gist.github.com/slashv/f1223689f2d1171d2eeb60a2823f4c7c
|
|
42
|
+
*
|
|
43
|
+
* Fetch plans into sink and decompose into windows
|
|
44
|
+
* https://gist.github.com/slashv/a8f55f50121c080937f42e44b4039ac8
|
|
45
|
+
*
|
|
46
|
+
* Mailbox and Latch approach (suggestion by Tim Smart)
|
|
47
|
+
* https://gist.github.com/slashv/d6b12395c85415bf0d3363372a1636c3
|
|
48
|
+
*/
|
|
49
|
+
export const streamEventsWithSyncState = ({ dbEventlog, syncState, options, }) => {
|
|
50
|
+
const initialCursor = options.since ?? EventSequenceNumber.Client.ROOT;
|
|
51
|
+
const batchSize = options.batchSize ?? 100;
|
|
52
|
+
return Stream.unwrapScoped(Effect.gen(function* () {
|
|
53
|
+
/**
|
|
54
|
+
* Single-element Queue allows suspending the event stream until head
|
|
55
|
+
* advances because Queue.take is a suspending effect. SubscriptionRef in
|
|
56
|
+
* comparrison lacks a primitive for suspending a stream until a new value
|
|
57
|
+
* is set and would require polling.
|
|
58
|
+
*
|
|
59
|
+
* The use of a sliding Queue here is useful since it ensures only the
|
|
60
|
+
* lastest head from syncState is the one present on the queue without the
|
|
61
|
+
* need for manual substitution.
|
|
62
|
+
*/
|
|
63
|
+
const headQueue = yield* Queue.sliding(1);
|
|
64
|
+
/**
|
|
65
|
+
* We run a separate fiber which listens to changes in syncState and
|
|
66
|
+
* offer the latest head to the headQueue. Keeping track of the previous
|
|
67
|
+
* value is done to prevent syncState changes unrelated to the
|
|
68
|
+
* upstreamHead triggering empty queries.
|
|
69
|
+
*
|
|
70
|
+
* When we implement support for leader and session level streams
|
|
71
|
+
* this will need to be adapted to support the relevant value from
|
|
72
|
+
* syncState that we are interested in tracking.
|
|
73
|
+
*/
|
|
74
|
+
let prevGlobalHead = -1;
|
|
75
|
+
yield* syncState.changes.pipe(Stream.map((state) => state.upstreamHead), Stream.filter((head) => {
|
|
76
|
+
if (head.global > prevGlobalHead) {
|
|
77
|
+
prevGlobalHead = head.global;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}), Stream.runForEach((head) => Queue.offer(headQueue, head)), Effect.forkScoped);
|
|
82
|
+
return Stream.paginateChunkEffect({ cursor: initialCursor, head: EventSequenceNumber.Client.ROOT }, ({ cursor, head }) => Effect.gen(function* () {
|
|
83
|
+
/**
|
|
84
|
+
* Early check guards agains:
|
|
85
|
+
* since === until : Prevent empty query
|
|
86
|
+
* since > until : Incorrectly inverted interval
|
|
87
|
+
*/
|
|
88
|
+
if (options.until && EventSequenceNumber.Client.isGreaterThanOrEqual(cursor, options.until)) {
|
|
89
|
+
return [Chunk.empty(), Option.none()];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* There are two scenarios where we take the next head from the headQueue:
|
|
93
|
+
*
|
|
94
|
+
* 1. We need to wait for the head to advance
|
|
95
|
+
* The Stream suspends until a new head is available on the headQueue
|
|
96
|
+
*
|
|
97
|
+
* 2. Head has advanced during itteration
|
|
98
|
+
* While itterating towards the lastest head taken from the headQueue
|
|
99
|
+
* in increments of batchSize it's possible the head could have
|
|
100
|
+
* advanced. This leads to a suboptimal amount of queries. Therefor we
|
|
101
|
+
* check if the headQueue is full which tells us that there's a new
|
|
102
|
+
* head available to take. Example:
|
|
103
|
+
*
|
|
104
|
+
* batchSize: 2
|
|
105
|
+
*
|
|
106
|
+
* --> head at: e3
|
|
107
|
+
* First query: e0 -> e2 (two events)
|
|
108
|
+
* --> head advances to: e4
|
|
109
|
+
* Second query: e2 -> e3 (one event but we could have taken 2)
|
|
110
|
+
* --> Take the new head of e4
|
|
111
|
+
* Third query: e3 -> e4 (unnecessary third query)
|
|
112
|
+
*
|
|
113
|
+
*
|
|
114
|
+
* To define the target, which will be used as the temporary until
|
|
115
|
+
* marker for the eventlog query, we select the lowest of three possible values:
|
|
116
|
+
*
|
|
117
|
+
* hardStop: A user supplied until marker
|
|
118
|
+
* current cursor + batchSize: A batchSize step towards the latest head from headQueue
|
|
119
|
+
* nextHead: The latest head from headQueue
|
|
120
|
+
*/
|
|
121
|
+
const waitForHead = EventSequenceNumber.Client.isGreaterThanOrEqual(cursor, head);
|
|
122
|
+
const maybeHead = waitForHead
|
|
123
|
+
? yield* Queue.take(headQueue).pipe(Effect.map(Option.some))
|
|
124
|
+
: yield* Queue.poll(headQueue);
|
|
125
|
+
const nextHead = Option.getOrElse(maybeHead, () => head);
|
|
126
|
+
const hardStop = options.until?.global ?? Number.POSITIVE_INFINITY;
|
|
127
|
+
const target = EventSequenceNumber.Client.Composite.make({
|
|
128
|
+
global: Math.min(hardStop, cursor.global + batchSize, nextHead.global),
|
|
129
|
+
client: EventSequenceNumber.Client.DEFAULT,
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Eventlog.getEventsFromEventlog returns a Chunk from each
|
|
133
|
+
* query which is what we emit at each itteration.
|
|
134
|
+
*/
|
|
135
|
+
const chunk = yield* Eventlog.getEventsFromEventlog({
|
|
136
|
+
dbEventlog,
|
|
137
|
+
options: {
|
|
138
|
+
...options,
|
|
139
|
+
since: cursor,
|
|
140
|
+
until: target,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* We construct the state for the following itteration of the stream
|
|
145
|
+
* loop by setting the current target as the since cursor and pass
|
|
146
|
+
* along the latest head.
|
|
147
|
+
*
|
|
148
|
+
* If we have the reached the user supplied until marker we signal the
|
|
149
|
+
* finalization of the stream by passing Option.none() instead.
|
|
150
|
+
*/
|
|
151
|
+
const reachedUntil = options.until !== undefined && EventSequenceNumber.Client.isGreaterThanOrEqual(target, options.until);
|
|
152
|
+
const nextState = reachedUntil ? Option.none() : Option.some({ cursor: target, head: nextHead });
|
|
153
|
+
const spanAttributes = {
|
|
154
|
+
'livestore.streamEvents.cursor.global': cursor.global,
|
|
155
|
+
'livestore.streamEvents.target.global': target.global,
|
|
156
|
+
'livestore.streamEvents.batchSize': batchSize,
|
|
157
|
+
'livestore.streamEvents.waitedForHead': waitForHead,
|
|
158
|
+
};
|
|
159
|
+
return yield* Effect.succeed([
|
|
160
|
+
chunk,
|
|
161
|
+
nextState,
|
|
162
|
+
]).pipe(Effect.withSpan('@livestore/common:streamEvents:segment', { attributes: spanAttributes }));
|
|
163
|
+
}));
|
|
164
|
+
}));
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=stream-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-events.js","sourceRoot":"","sources":["../../src/leader-thread/stream-events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE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AC,MAAM,CAAC;gBACtE,MAAM,EAAE,mBAAmB,CAAC,MAAM,CAAC,OAAO;aAC3C,CAAC,CAAA;YAEF;;;eAGG;YACH,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC;gBAClD,UAAU;gBACV,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE,MAAM;iBACd;aACF,CAAC,CAAA;YAEF;;;;;;;eAOG;YACH,MAAM,YAAY,GAChB,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,mBAAmB,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;YAEvG,MAAM,SAAS,GAGV,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;YAEnF,MAAM,cAAc,GAAG;gBACrB,sCAAsC,EAAE,MAAM,CAAC,MAAM;gBACrD,sCAAsC,EAAE,MAAM,CAAC,MAAM;gBACrD,kCAAkC,EAAE,SAAS;gBAC7C,sCAAsC,EAAE,WAAW;aACpD,CAAA;YAED,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAiE;gBAC3F,KAAK;gBACL,SAAS;aACV,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,wCAAwC,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC,CAAA;QACpG,CAAC,CAAC,CACL,CAAA;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -4,7 +4,7 @@ import type { MeshNode } from '@livestore/webmesh';
|
|
|
4
4
|
import type { MigrationsReport } from '../defs.ts';
|
|
5
5
|
import type { MaterializeError } from '../errors.ts';
|
|
6
6
|
import type { BootStatus, Devtools, LeaderAheadError, MakeSqliteDb, PersistenceInfo, SqliteDb, SyncBackend, UnknownError } from '../index.ts';
|
|
7
|
-
import
|
|
7
|
+
import { EventSequenceNumber, type LiveStoreEvent, type LiveStoreSchema } from '../schema/mod.ts';
|
|
8
8
|
import type * as SyncState from '../sync/syncstate.ts';
|
|
9
9
|
import type { ShutdownChannel } from './shutdown-channel.ts';
|
|
10
10
|
export type ShutdownState = 'running' | 'shutting-down';
|
|
@@ -98,6 +98,82 @@ export type InitialBlockingSyncContext = {
|
|
|
98
98
|
processed: number;
|
|
99
99
|
}) => Effect.Effect<void>;
|
|
100
100
|
};
|
|
101
|
+
export declare const STREAM_EVENTS_BATCH_SIZE_DEFAULT = 100;
|
|
102
|
+
export declare const STREAM_EVENTS_BATCH_SIZE_MAX = 1000;
|
|
103
|
+
export declare const StreamEventsOptionsFields: {
|
|
104
|
+
readonly since: Schema.optional<Schema.Struct<{
|
|
105
|
+
global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
106
|
+
client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
|
|
107
|
+
rebaseGeneration: typeof Schema.Int;
|
|
108
|
+
}> & {
|
|
109
|
+
make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
|
|
110
|
+
}>;
|
|
111
|
+
readonly until: Schema.optional<Schema.Struct<{
|
|
112
|
+
global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
113
|
+
client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
|
|
114
|
+
rebaseGeneration: typeof Schema.Int;
|
|
115
|
+
}> & {
|
|
116
|
+
make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
|
|
117
|
+
}>;
|
|
118
|
+
readonly filter: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
119
|
+
readonly clientIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
120
|
+
readonly sessionIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
121
|
+
readonly batchSize: Schema.optional<Schema.filter<typeof Schema.Int>>;
|
|
122
|
+
readonly includeClientOnly: Schema.optional<typeof Schema.Boolean>;
|
|
123
|
+
};
|
|
124
|
+
export declare const StreamEventsOptionsSchema: Schema.Struct<{
|
|
125
|
+
readonly since: Schema.optional<Schema.Struct<{
|
|
126
|
+
global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
127
|
+
client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
|
|
128
|
+
rebaseGeneration: typeof Schema.Int;
|
|
129
|
+
}> & {
|
|
130
|
+
make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
|
|
131
|
+
}>;
|
|
132
|
+
readonly until: Schema.optional<Schema.Struct<{
|
|
133
|
+
global: Schema.BrandSchema<number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">, number, never>;
|
|
134
|
+
client: Schema.BrandSchema<number & import("effect/Brand").Brand<"ClientEventSequenceNumber">, number, never>;
|
|
135
|
+
rebaseGeneration: typeof Schema.Int;
|
|
136
|
+
}> & {
|
|
137
|
+
make: (seqNum: EventSequenceNumber.Client.CompositeInput) => EventSequenceNumber.Client.Composite;
|
|
138
|
+
}>;
|
|
139
|
+
readonly filter: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
140
|
+
readonly clientIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
141
|
+
readonly sessionIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
142
|
+
readonly batchSize: Schema.optional<Schema.filter<typeof Schema.Int>>;
|
|
143
|
+
readonly includeClientOnly: Schema.optional<typeof Schema.Boolean>;
|
|
144
|
+
}>;
|
|
145
|
+
export interface StreamEventsOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Only include events after this logical timestamp (exclusive).
|
|
148
|
+
* Defaults to `EventSequenceNumber.Client.ROOT` when omitted.
|
|
149
|
+
*/
|
|
150
|
+
since?: EventSequenceNumber.Client.Composite;
|
|
151
|
+
/**
|
|
152
|
+
* Only include events up to this logical timestamp (inclusive).
|
|
153
|
+
*/
|
|
154
|
+
until?: EventSequenceNumber.Client.Composite;
|
|
155
|
+
/**
|
|
156
|
+
* Only include events of the given names.
|
|
157
|
+
*/
|
|
158
|
+
filter?: ReadonlyArray<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Only include events from specific client identifiers.
|
|
161
|
+
*/
|
|
162
|
+
clientIds?: ReadonlyArray<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Only include events from specific session identifiers.
|
|
165
|
+
*/
|
|
166
|
+
sessionIds?: ReadonlyArray<string>;
|
|
167
|
+
/**
|
|
168
|
+
* Number of events to fetch in each batch when streaming from the eventlog.
|
|
169
|
+
* Defaults to 100.
|
|
170
|
+
*/
|
|
171
|
+
batchSize?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Include client-only events (i.e. events with a positive client sequence number).
|
|
174
|
+
*/
|
|
175
|
+
includeClientOnly?: boolean;
|
|
176
|
+
}
|
|
101
177
|
export interface LeaderSyncProcessor {
|
|
102
178
|
/** Used by client sessions to subscribe to upstream sync state changes */
|
|
103
179
|
pull: (args: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/leader-thread/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,YAAY,EACZ,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;A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AE,OAAO,EAAE,OAAO,SAAS,CAAC,eAAe,CAAC,IAAI,CAAA;KAAE,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAE/G,kEAAkE;IAClE,IAAI,EAAE;IACJ,8EAA8E;IAC9E,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,eAAe,CAAC,EAC3D,OAAO,CAAC,EAAE;QACR;;;;WAIG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAC5B,KACE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;IAE1C,kFAAkF;IAClF,WAAW,EAAE,CAAC,IAAI,EAAE;QAClB,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,OAAO,CAAA;QACnC,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;KAClB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IAEvC,IAAI,EAAE,MAAM,CAAC,MAAM,CACjB;QAAE,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAA;KAAE,EAC3D,YAAY,EACZ,eAAe,GAAG,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,CACtD,CAAA;IACD,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;CAC1D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context, Schema } from '@livestore/utils/effect';
|
|
2
|
+
import { EventSequenceNumber } from "../schema/mod.js";
|
|
2
3
|
export const InitialSyncOptionsSkip = Schema.TaggedStruct('Skip', {});
|
|
3
4
|
export const InitialSyncOptionsBlocking = Schema.TaggedStruct('Blocking', {
|
|
4
5
|
timeout: Schema.Union(Schema.DurationFromMillis, Schema.Number),
|
|
@@ -6,4 +7,16 @@ export const InitialSyncOptionsBlocking = Schema.TaggedStruct('Blocking', {
|
|
|
6
7
|
export const InitialSyncOptions = Schema.Union(InitialSyncOptionsSkip, InitialSyncOptionsBlocking);
|
|
7
8
|
export class LeaderThreadCtx extends Context.Tag('LeaderThreadCtx')() {
|
|
8
9
|
}
|
|
10
|
+
export const STREAM_EVENTS_BATCH_SIZE_DEFAULT = 100;
|
|
11
|
+
export const STREAM_EVENTS_BATCH_SIZE_MAX = 1_000;
|
|
12
|
+
export const StreamEventsOptionsFields = {
|
|
13
|
+
since: Schema.optional(EventSequenceNumber.Client.Composite),
|
|
14
|
+
until: Schema.optional(EventSequenceNumber.Client.Composite),
|
|
15
|
+
filter: Schema.optional(Schema.Array(Schema.String)),
|
|
16
|
+
clientIds: Schema.optional(Schema.Array(Schema.String)),
|
|
17
|
+
sessionIds: Schema.optional(Schema.Array(Schema.String)),
|
|
18
|
+
batchSize: Schema.optional(Schema.Int.pipe(Schema.between(1, STREAM_EVENTS_BATCH_SIZE_MAX))),
|
|
19
|
+
includeClientOnly: Schema.optional(Schema.Boolean),
|
|
20
|
+
};
|
|
21
|
+
export const StreamEventsOptionsSchema = Schema.Struct(StreamEventsOptionsFields);
|
|
9
22
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/leader-thread/types.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/leader-thread/types.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAezD,OAAO,EAAE,mBAAmB,EAA6C,MAAM,kBAAkB,CAAA;AAMjG,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAGrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,YAAY,CAAC,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d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Effect, OtelTracer } from '@livestore/utils/effect';
|
|
1
|
+
import { Effect, Layer, OtelTracer } from '@livestore/utils/effect';
|
|
2
2
|
import * as otel from '@opentelemetry/api';
|
|
3
|
+
export declare const OtelLiveDummy: Layer.Layer<OtelTracer.OtelTracer>;
|
|
3
4
|
export declare const provideOtel: ({ otelTracer, parentSpanContext }: {
|
|
4
5
|
otelTracer?: otel.Tracer;
|
|
5
6
|
parentSpanContext?: otel.Context;
|
package/dist/otel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAY,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAQ3D,CAAA;AAEF,eAAO,MAAM,WAAW,GACrB,mCAAmC;IAAE,UAAU,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAA;CAAE,MACjG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAa/F,CAAA;AAEH,eAAO,MAAM,qBAAqB,GAAI,MAAM,IAAI,CAAC,IAAI,KAAG,MAGvD,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,MAAM,IAAI,CAAC,IAAI,KAAG,mBACF,CAAA"}
|
package/dist/otel.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { makeNoopTracer } from '@livestore/utils';
|
|
2
2
|
import { Effect, identity, Layer, OtelTracer } from '@livestore/utils/effect';
|
|
3
3
|
import * as otel from '@opentelemetry/api';
|
|
4
|
+
export const OtelLiveDummy = Layer.suspend(() => {
|
|
5
|
+
const OtelTracerLive = Layer.succeed(OtelTracer.OtelTracer, makeNoopTracer());
|
|
6
|
+
const TracingLive = Layer.unwrapEffect(Effect.map(OtelTracer.make, Layer.setTracer)).pipe(Layer.provideMerge(OtelTracerLive));
|
|
7
|
+
return TracingLive;
|
|
8
|
+
});
|
|
4
9
|
export const provideOtel = ({ otelTracer, parentSpanContext }) => (effect) => {
|
|
5
10
|
const OtelTracerLive = Layer.succeed(OtelTracer.OtelTracer, otelTracer ?? makeNoopTracer());
|
|
6
11
|
const TracingLive = Layer.unwrapEffect(Effect.map(OtelTracer.make, Layer.setTracer)).pipe(Layer.provideMerge(OtelTracerLive));
|
package/dist/otel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel.js","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,WAAW,GACtB,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAkE,EAAE,EAAE,CACtG,CAAU,MAA8B,EAA0D,EAAE;IAClG,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,IAAI,cAAc,EAAE,CAAC,CAAA;IAE3F,MAAM,WAAW,GAAG,KAAK,C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20 @@ export type DefineEventOptions<TTo, TDerived extends boolean = false> = {
|
|
|
60
60
|
* @default false
|
|
61
61
|
*/
|
|
62
62
|
derived?: TDerived;
|
|
63
|
+
/**
|
|
64
|
+
* Marks the entire event as deprecated with a reason message.
|
|
65
|
+
* When this event is committed, a warning will be logged.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* Events.synced({
|
|
70
|
+
* name: 'v1.TodoRenamed',
|
|
71
|
+
* schema: Schema.Struct({ id: Schema.String, name: Schema.String }),
|
|
72
|
+
* deprecated: "Use 'v1.TodoUpdated' instead",
|
|
73
|
+
* })
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
deprecated?: string;
|
|
63
77
|
};
|
|
64
78
|
/**
|
|
65
79
|
* Creates an event definition with full control over all options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/schema/EventDef/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAElE,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,CAAC,GAAG,EAAE,QAAQ,SAAS,OAAO,GAAG,KAAK,IAAI;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,CACN,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,aAAa,KACxB;QACH,MAAM,CAAC,EAAE;YACP,uCAAuC;YACvC,GAAG,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;YACjC,+BAA+B;YAC/B,KAAK,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;SACpC,CAAA;QACD;;;WAGG;QACH,OA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AAG,CACxB,IAGoE,EAClC,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecation Annotations for Events
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities for marking event fields and entire events as deprecated.
|
|
5
|
+
* When a deprecated field is used or a deprecated event is committed, a warning is logged.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Events } from '@livestore/livestore'
|
|
10
|
+
* import { Schema } from 'effect'
|
|
11
|
+
* import { deprecated } from '@livestore/common/schema'
|
|
12
|
+
*
|
|
13
|
+
* // Field-level deprecation
|
|
14
|
+
* const todoUpdated = Events.synced({
|
|
15
|
+
* name: 'v1.TodoUpdated',
|
|
16
|
+
* schema: Schema.Struct({
|
|
17
|
+
* id: Schema.String,
|
|
18
|
+
* title: Schema.optional(Schema.String).pipe(deprecated("Use 'text' instead")),
|
|
19
|
+
* text: Schema.optional(Schema.String),
|
|
20
|
+
* }),
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* // Event-level deprecation
|
|
24
|
+
* const todoRenamed = Events.synced({
|
|
25
|
+
* name: 'v1.TodoRenamed',
|
|
26
|
+
* schema: Schema.Struct({ id: Schema.String, name: Schema.String }),
|
|
27
|
+
* deprecated: "Use 'v1.TodoUpdated' instead",
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import type { Schema } from '@livestore/utils/effect';
|
|
33
|
+
import { Effect, Option } from '@livestore/utils/effect';
|
|
34
|
+
import type { EventDef } from './event-def.ts';
|
|
35
|
+
/** Symbol used to mark schemas as deprecated. */
|
|
36
|
+
export declare const DeprecatedId: unique symbol;
|
|
37
|
+
/**
|
|
38
|
+
* Marks a schema field as deprecated with a reason message.
|
|
39
|
+
* When an event is committed with a deprecated field that has a value,
|
|
40
|
+
* a warning will be logged.
|
|
41
|
+
*
|
|
42
|
+
* Works with both Schema types and PropertySignatures (from Schema.optional).
|
|
43
|
+
*
|
|
44
|
+
* @param reason - Explanation of why this field is deprecated and what to use instead
|
|
45
|
+
* @returns A function that adds the deprecation annotation to the schema
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const schema = Schema.Struct({
|
|
50
|
+
* oldField: Schema.optional(Schema.String).pipe(deprecated("Use 'newField' instead")),
|
|
51
|
+
* newField: Schema.optional(Schema.String),
|
|
52
|
+
* })
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const deprecated: (reason: string) => <T extends {
|
|
56
|
+
annotations: (annotations: {
|
|
57
|
+
readonly [DeprecatedId]?: string;
|
|
58
|
+
}) => T;
|
|
59
|
+
}>(schema: T) => T;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if a schema has a deprecation annotation.
|
|
62
|
+
*
|
|
63
|
+
* @param schema - The schema to check
|
|
64
|
+
* @returns The deprecation reason if deprecated, None otherwise
|
|
65
|
+
*/
|
|
66
|
+
export declare const getDeprecatedReason: <A, I, R>(schema: Schema.Schema<A, I, R>) => Option.Option<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if a schema is deprecated.
|
|
69
|
+
*
|
|
70
|
+
* @param schema - The schema to check
|
|
71
|
+
* @returns true if the schema is deprecated
|
|
72
|
+
*/
|
|
73
|
+
export declare const isDeprecated: <A, I, R>(schema: Schema.Schema<A, I, R>) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Finds deprecated fields with values in the given event arguments.
|
|
76
|
+
* This walks through a Struct schema and checks each property for deprecation.
|
|
77
|
+
*
|
|
78
|
+
* @param schema - The event schema (expected to be a Struct)
|
|
79
|
+
* @param args - The event arguments
|
|
80
|
+
* @returns Array of objects containing field name and deprecation reason
|
|
81
|
+
*/
|
|
82
|
+
export declare const findDeprecatedFieldsWithValues: (schema: Schema.Schema.All, args: Record<string, unknown>) => Array<{
|
|
83
|
+
field: string;
|
|
84
|
+
reason: string;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Logs deprecation warnings for an event using Effect.logWarning.
|
|
88
|
+
* Checks both event-level and field-level deprecation, with deduplication.
|
|
89
|
+
*
|
|
90
|
+
* @param eventDef - The event definition to check
|
|
91
|
+
* @param args - The event arguments
|
|
92
|
+
* @returns An Effect that logs warnings for any deprecations found
|
|
93
|
+
*/
|
|
94
|
+
export declare const logDeprecationWarnings: (eventDef: EventDef.AnyWithoutFn, args: Record<string, unknown>) => Effect.Effect<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Resets the deprecation warning state. Useful for testing.
|
|
97
|
+
*/
|
|
98
|
+
export declare const resetDeprecationWarnings: () => void;
|
|
99
|
+
//# sourceMappingURL=deprecated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../../src/schema/EventDef/deprecated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAa,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,iDAAiD;AACjD,eAAO,MAAM,YAAY,eAAwD,CAAA;AAEjF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,GACpB,QAAQ,MAAM,MACd,CAAC,SAAS;IAAE,WAAW,EAAE,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,CAAC,CAAA;CAAE,EAAE,QAAQ,CAAC,KAAG,CAClD,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,mBAA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