@streamsy/core 0.16.0 → 0.17.0

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,9 +1,8 @@
1
- import { Context, Data, Effect, Option, PubSub, Schema, Scope, Stream } from "effect";
2
- import { SqlError } from "effect/sql";
1
+ import { Array, Brand, Context, Data, Effect, Option, PubSub, Schema, Scope, Stream } from "effect";
3
2
  declare const StorageFault_base: Schema.Class<StorageFault, Schema.TaggedStruct<"StorageFault", {
4
3
  readonly operation: Schema.String;
5
4
  readonly message: Schema.String;
6
- readonly retryable: Schema.Boolean;
5
+ readonly isRetryable: Schema.Boolean;
7
6
  readonly cause: Schema.optionalKey<Schema.Defect>;
8
7
  }>, import("effect/Cause").YieldableError>;
9
8
  declare class StorageFault extends StorageFault_base {}
@@ -17,6 +16,16 @@ declare const DecodeFault_base: Schema.Class<DecodeFault, Schema.TaggedStruct<"D
17
16
  readonly cause: Schema.optionalKey<Schema.Defect>;
18
17
  }>, import("effect/Cause").YieldableError>;
19
18
  declare class DecodeFault extends DecodeFault_base {}
19
+ declare const InvalidStreamParams_base: Schema.Class<InvalidStreamParams, Schema.TaggedStruct<"InvalidStreamParams", {
20
+ readonly stream: Schema.String;
21
+ readonly parameter: Schema.String;
22
+ readonly message: Schema.String;
23
+ }>, import("effect/Cause").YieldableError>;
24
+ /**
25
+ * A stream param value cannot form a stream id, for example a value that contains `/` or is
26
+ * empty. `stream` is the route template and `parameter` names the param.
27
+ */
28
+ declare class InvalidStreamParams extends InvalidStreamParams_base {}
20
29
  declare const TransportFault_base: Schema.Class<TransportFault, Schema.TaggedStruct<"TransportFault", {
21
30
  readonly operation: Schema.String;
22
31
  readonly reason: Schema.Literals<readonly ["request", "response", "decode", "configuration"]>;
@@ -28,16 +37,25 @@ declare const TransportFault_base: Schema.Class<TransportFault, Schema.TaggedStr
28
37
  /** Failures of the remote boundary; protocol rejections have their own typed errors. */
29
38
  declare class TransportFault extends TransportFault_base {
30
39
  /** Failed requests, 429s and 5xx responses can succeed later. */
31
- get retryable(): boolean;
40
+ get isRetryable(): boolean;
32
41
  }
33
42
  declare const StreamsFault: Schema.Union<readonly [typeof StorageFault, typeof TransportFault]>;
34
43
  type StreamsFault = typeof StreamsFault.Type;
35
44
  /** A storage or transport failure, as opposed to a protocol rejection. */
36
45
  declare const isStreamsFault: <I>(input: I) => input is I & (StorageFault | TransportFault);
37
- /** A storage or transport failure that can succeed later. */
38
- declare const isRetryableFault: (error: unknown) => error is StreamsFault;
46
+ /**
47
+ * True for an error that can succeed later: any error with a boolean `isRetryable` that is
48
+ * `true`, such as a `StorageFault`, a `TransportFault` or a `ProjectionFault`.
49
+ */
50
+ declare const isRetryableFault: (error: unknown) => boolean;
39
51
  declare const StreamId: Schema.brand<Schema.String, "StreamId">;
52
+ /**
53
+ * A position in a stream, as any Durable Streams server issues it. Offsets are opaque: compare
54
+ * them, but do not parse them. The read sentinels `-1` and `now` are not offsets.
55
+ */
40
56
  declare const Offset: Schema.brand<Schema.String, "Offset">;
57
+ /** The offset format that Streamsy storage issues. Every `StreamsyOffset` is an `Offset`. */
58
+ declare const StreamsyOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
41
59
  declare const ProducerId: Schema.brand<Schema.String, "ProducerId">;
42
60
  declare const StreamConfig: Schema.Struct<{
43
61
  readonly contentType: Schema.String;
@@ -50,7 +68,7 @@ declare const StreamLifecycle: Schema.Struct<{
50
68
  readonly closed: Schema.Boolean;
51
69
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
52
70
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
53
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
71
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
54
72
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
55
73
  readonly softDeleted: Schema.Boolean;
56
74
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
@@ -68,15 +86,15 @@ declare const StreamRecord: Schema.Struct<{
68
86
  readonly closed: Schema.Boolean;
69
87
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
70
88
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
71
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
89
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
72
90
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
73
91
  readonly softDeleted: Schema.Boolean;
74
92
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
75
93
  }>;
76
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
94
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
77
95
  }>;
78
96
  declare const StoredMessage: Schema.Struct<{
79
- readonly offset: Schema.brand<Schema.String, "Offset">;
97
+ readonly offset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
80
98
  readonly timestamp: Schema.Finite;
81
99
  readonly data: Schema.Uint8Array;
82
100
  }>;
@@ -85,18 +103,19 @@ declare const ProducerState: Schema.Struct<{
85
103
  readonly lastSeq: Schema.Finite;
86
104
  }>;
87
105
  declare const MessageWindow: Schema.Struct<{
88
- readonly after: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
89
- readonly until: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
106
+ readonly after: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
107
+ readonly until: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
90
108
  readonly limit: Schema.optionalKey<Schema.Finite>;
91
109
  }>;
92
110
  declare const ChangeSnapshot: Schema.Struct<{
93
111
  readonly present: Schema.Boolean;
94
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
112
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
95
113
  readonly closed: Schema.Boolean;
96
114
  readonly softDeleted: Schema.Boolean;
97
115
  }>;
98
116
  type StreamId = typeof StreamId.Type;
99
117
  type Offset = typeof Offset.Type;
118
+ type StreamsyOffset = typeof StreamsyOffset.Type;
100
119
  type ProducerId = typeof ProducerId.Type;
101
120
  interface StreamConfig extends Schema.Schema.Type<typeof StreamConfig> {}
102
121
  interface StreamLifecycle extends Schema.Schema.Type<typeof StreamLifecycle> {}
@@ -106,7 +125,7 @@ interface ProducerState extends Schema.Schema.Type<typeof ProducerState> {}
106
125
  interface MessageWindow extends Schema.Schema.Type<typeof MessageWindow> {}
107
126
  interface ChangeSnapshot extends Schema.Schema.Type<typeof ChangeSnapshot> {}
108
127
  declare const RecordPatch: Schema.Struct<{
109
- readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
128
+ readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
110
129
  readonly config: Schema.optionalKey<Schema.Struct<{
111
130
  readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
112
131
  readonly expiresAt: Schema.optionalKey<Schema.String>;
@@ -115,7 +134,7 @@ declare const RecordPatch: Schema.Struct<{
115
134
  readonly lastSeq: Schema.optionalKey<Schema.String>;
116
135
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
117
136
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
118
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
137
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
119
138
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
120
139
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
121
140
  readonly closed: Schema.optionalKey<Schema.Boolean>;
@@ -124,17 +143,11 @@ declare const RecordPatch: Schema.Struct<{
124
143
  readonly clear: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["ttlSeconds", "expiresAt", "expiresAtMs", "lastSeq"]>>>;
125
144
  }>;
126
145
  interface RecordPatch extends Schema.Schema.Type<typeof RecordPatch> {}
127
- /** Private pure-policy input, promoted to protocol options in Batch 3. */
128
- interface CreateOptions {
129
- readonly contentType?: string;
130
- readonly ttlSeconds?: number;
131
- readonly expiresAt?: string;
132
- readonly closed?: boolean;
133
- readonly forkedFrom?: string;
134
- readonly forkOffset?: string;
135
- readonly forkSubOffset?: number;
136
- readonly initialData?: Uint8Array;
137
- }
146
+ /**
147
+ * Where a read starts: `-1` for the start of the stream, `now` for its current tail, or an
148
+ * `Offset` that an earlier read or write returned.
149
+ */
150
+ type StartOffset = "-1" | "now" | Offset;
138
151
  interface ProducerOptions {
139
152
  readonly producerId: string;
140
153
  readonly producerEpoch: number;
@@ -154,12 +167,12 @@ interface AppendOptions {
154
167
  * means "append only if the stream is still empty". Streamsy extension to
155
168
  * the Durable Streams protocol.
156
169
  */
157
- readonly expectedOffset?: string;
170
+ readonly expectedOffset?: Offset;
158
171
  }
159
172
  /** Append options for a typed address. The address supplies the body and its content type. */
160
173
  type AppendCallOptions = Omit<AppendOptions, "data" | "contentType">;
161
174
  interface ReadOptions {
162
- offset?: string;
175
+ readonly offset?: StartOffset;
163
176
  }
164
177
  /**
165
178
  * Options for one transport-neutral read/wait operation. `readNext` returns
@@ -168,165 +181,35 @@ interface ReadOptions {
168
181
  * it; they are intentionally not part of this protocol contract.
169
182
  */
170
183
  interface ReadNextOptions {
171
- offset: string;
172
- cursor?: string;
173
- }
174
- declare const StreamNotFound_base: Schema.Class<StreamNotFound, Schema.TaggedStruct<"StreamNotFound", {
175
- readonly id: Schema.brand<Schema.String, "StreamId">;
176
- }>, import("effect/Cause").YieldableError>;
177
- /** Protocol rejections. Optional create reasons reflect the public HTTP wire's loss of detail. */
178
- declare class StreamNotFound extends StreamNotFound_base {
179
- get message(): string;
180
- }
181
- declare const StreamGone_base: Schema.Class<StreamGone, Schema.TaggedStruct<"StreamGone", {
182
- readonly id: Schema.brand<Schema.String, "StreamId">;
183
- }>, import("effect/Cause").YieldableError>;
184
- declare class StreamGone extends StreamGone_base {
185
- get message(): string;
186
- }
187
- declare const StreamClosed_base: Schema.Class<StreamClosed, Schema.TaggedStruct<"StreamClosed", {
188
- readonly id: Schema.brand<Schema.String, "StreamId">;
189
- readonly offset: Schema.String;
190
- }>, import("effect/Cause").YieldableError>;
191
- declare class StreamClosed extends StreamClosed_base {
192
- get message(): string;
193
- }
194
- declare const OffsetMismatch_base: Schema.Class<OffsetMismatch, Schema.TaggedStruct<"OffsetMismatch", {
195
- readonly id: Schema.brand<Schema.String, "StreamId">;
196
- readonly expected: Schema.String;
197
- readonly actual: Schema.String;
198
- }>, import("effect/Cause").YieldableError>;
199
- declare class OffsetMismatch extends OffsetMismatch_base {
200
- get message(): string;
201
- }
202
- declare const AppendConflict_base: Schema.Class<AppendConflict, Schema.TaggedStruct<"AppendConflict", {
203
- readonly id: Schema.brand<Schema.String, "StreamId">;
204
- /**
205
- * `sequence` when the `Stream-Seq` does not sort after the last one, `content-type` when the
206
- * content type differs. Absent when the cause is unknown, for example from a server that does
207
- * not send `stream-conflict-reason`.
208
- */
209
- readonly reason: Schema.optionalKey<Schema.Literals<readonly ["sequence", "content-type"]>>;
210
- readonly message: Schema.String;
211
- }>, import("effect/Cause").YieldableError>;
212
- declare class AppendConflict extends AppendConflict_base {}
213
- declare const StreamBusy_base: Schema.Class<StreamBusy, Schema.TaggedStruct<"StreamBusy", {
214
- readonly id: Schema.brand<Schema.String, "StreamId">;
215
- }>, import("effect/Cause").YieldableError>;
216
- declare class StreamBusy extends StreamBusy_base {
217
- get message(): string;
218
- }
219
- declare const StaleEpoch_base: Schema.Class<StaleEpoch, Schema.TaggedStruct<"StaleEpoch", {
220
- readonly id: Schema.brand<Schema.String, "StreamId">;
221
- readonly currentEpoch: Schema.Finite;
222
- }>, import("effect/Cause").YieldableError>;
223
- declare class StaleEpoch extends StaleEpoch_base {
224
- get message(): string;
225
- }
226
- declare const ProducerGap_base: Schema.Class<ProducerGap, Schema.TaggedStruct<"ProducerGap", {
227
- readonly id: Schema.brand<Schema.String, "StreamId">;
228
- readonly expectedSeq: Schema.Finite;
229
- readonly receivedSeq: Schema.Finite;
230
- }>, import("effect/Cause").YieldableError>;
231
- declare class ProducerGap extends ProducerGap_base {
232
- get message(): string;
233
- }
234
- declare const InvalidEpochSeq_base: Schema.Class<InvalidEpochSeq, Schema.TaggedStruct<"InvalidEpochSeq", {
235
- readonly id: Schema.brand<Schema.String, "StreamId">;
236
- }>, import("effect/Cause").YieldableError>;
237
- declare class InvalidEpochSeq extends InvalidEpochSeq_base {
238
- get message(): string;
239
- }
240
- declare const InvalidAppendRequest_base: Schema.Class<InvalidAppendRequest, Schema.TaggedStruct<"InvalidAppendRequest", {
241
- readonly id: Schema.brand<Schema.String, "StreamId">;
242
- readonly message: Schema.String;
243
- }>, import("effect/Cause").YieldableError>;
244
- declare class InvalidAppendRequest extends InvalidAppendRequest_base {}
245
- declare const InvalidCreateRequest_base: Schema.Class<InvalidCreateRequest, Schema.TaggedStruct<"InvalidCreateRequest", {
246
- readonly id: Schema.brand<Schema.String, "StreamId">;
247
- readonly message: Schema.String;
248
- }>, import("effect/Cause").YieldableError>;
249
- declare class InvalidCreateRequest extends InvalidCreateRequest_base {}
250
- declare const CreateConflict_base: Schema.Class<CreateConflict, Schema.TaggedStruct<"CreateConflict", {
251
- readonly id: Schema.brand<Schema.String, "StreamId">;
252
- readonly reason: Schema.optionalKey<Schema.Literals<readonly ["config-mismatch", "soft-deleted", "fork-content-type", "fork-source-soft-deleted"]>>;
253
- readonly message: Schema.String;
254
- }>, import("effect/Cause").YieldableError>;
255
- declare class CreateConflict extends CreateConflict_base {}
256
- declare const ForkSourceNotFound_base: Schema.Class<ForkSourceNotFound, Schema.TaggedStruct<"ForkSourceNotFound", {
257
- readonly id: Schema.brand<Schema.String, "StreamId">;
258
- readonly source: Schema.brand<Schema.String, "StreamId">;
259
- }>, import("effect/Cause").YieldableError>;
260
- declare class ForkSourceNotFound extends ForkSourceNotFound_base {
261
- get message(): string;
184
+ readonly offset: StartOffset;
185
+ readonly cursor?: string;
262
186
  }
263
- declare const InvalidForkRequest_base: Schema.Class<InvalidForkRequest, Schema.TaggedStruct<"InvalidForkRequest", {
264
- readonly id: Schema.brand<Schema.String, "StreamId">;
265
- readonly message: Schema.String;
266
- }>, import("effect/Cause").YieldableError>;
267
- declare class InvalidForkRequest extends InvalidForkRequest_base {}
268
- declare const NotSupported_base: Schema.Class<NotSupported, Schema.TaggedStruct<"NotSupported", {
269
- readonly id: Schema.brand<Schema.String, "StreamId">;
270
- readonly feature: Schema.String;
271
- }>, import("effect/Cause").YieldableError>;
272
- declare class NotSupported extends NotSupported_base {
273
- get message(): string;
274
- }
275
- type CreateConflictReason = NonNullable<CreateConflict["reason"]>;
276
- type HeadError = StreamNotFound | StreamGone;
277
- declare const InvalidReadRequest_base: Schema.Class<InvalidReadRequest, Schema.TaggedStruct<"InvalidReadRequest", {
278
- readonly id: Schema.brand<Schema.String, "StreamId">;
279
- readonly message: Schema.String;
280
- }>, import("effect/Cause").YieldableError>;
281
- declare class InvalidReadRequest extends InvalidReadRequest_base {}
282
- type ReadError = StreamNotFound | StreamGone | InvalidReadRequest;
283
- type ReadNextError = ReadError | NotSupported;
284
- type CreateError = CreateConflict | InvalidCreateRequest | ForkSourceNotFound | InvalidForkRequest | NotSupported;
285
- /**
286
- * Append rejections that any call can get, whatever its options. The memory and
287
- * storage hosts never answer `NotSupported`; the remote client does when the server
288
- * or its own capabilities refuse a feature.
289
- */
290
- type AppendBaseError = StreamNotFound | StreamGone | StreamClosed | StreamBusy | AppendConflict | NotSupported;
291
- type AppendError = AppendBaseError | InvalidAppendRequest | OffsetMismatch | StaleEpoch | ProducerGap | InvalidEpochSeq;
292
- /**
293
- * The append rejections that call options `O` make possible. `OffsetMismatch`
294
- * needs `expectedOffset`, and the producer rejections need `producer`. An option
295
- * that may be set counts as set.
296
- */
297
- type AppendErrorFor<O> = AppendBaseError | (true extends MaySet<O, "expectedOffset"> ? OffsetMismatch : never) | (true extends MaySet<O, "producer"> ? StaleEpoch | ProducerGap : never);
298
- /** Whether options `O` may hold a value for `K`. A union holds it if any member may. */
299
- type MaySet<O, K extends PropertyKey> = O extends unknown ? K extends keyof O ? [Exclude<O[K], undefined>] extends [never] ? false : true : false : never;
300
- type RemoveError = StreamNotFound | StreamGone | StreamBusy;
301
- type ProtocolError = HeadError | ReadNextError | CreateError | AppendError | RemoveError;
302
- /** The HTTP edge answers every protocol rejection through one mapper, so it needs one guard. */
303
- declare const isProtocolError: (error: {
304
- readonly _tag: string;
305
- }) => error is ProtocolError;
306
187
  /** Payload-only messages exposed by the public protocol; storage owns offsets and timestamps. */
307
188
  interface ReadMessage {
308
189
  readonly data: Uint8Array;
309
190
  }
310
191
  type CreateResult = {
311
192
  readonly _tag: "Created";
312
- readonly nextOffset: string;
193
+ /** The tail of the stream; an after-exclusive read cursor. */
194
+ readonly offset: Offset;
313
195
  readonly contentType: string;
314
196
  readonly closed: boolean;
315
197
  } | {
316
198
  readonly _tag: "Exists";
317
- readonly nextOffset: string;
199
+ /** The tail of the stream; an after-exclusive read cursor. */
200
+ readonly offset: Offset;
318
201
  readonly contentType: string;
319
202
  readonly closed: boolean;
320
203
  };
321
204
  type AppendResult = {
322
205
  readonly _tag: "Appended";
323
- /** Tail after this write; an after-exclusive read cursor. */ readonly offset: string;
206
+ /** Tail after this write; an after-exclusive read cursor. */ readonly offset: Offset;
324
207
  readonly producerEpoch?: number;
325
208
  readonly producerSeq?: number;
326
209
  readonly closed: boolean;
327
210
  } | {
328
211
  readonly _tag: "Duplicate";
329
- /** Current tail at acknowledgement, at or after the original write. */ readonly offset: string;
212
+ /** Current tail at acknowledgement, at or after the original write. */ readonly offset: Offset;
330
213
  readonly producerEpoch: number;
331
214
  readonly producerSeq: number;
332
215
  readonly closed: boolean;
@@ -337,7 +220,7 @@ declare const AppendResult: Data.TaggedEnum.Constructor<AppendResult>;
337
220
  interface ReadResult {
338
221
  readonly contentType: string;
339
222
  readonly messages: ReadonlyArray<ReadMessage>;
340
- readonly nextOffset: string;
223
+ readonly nextOffset: Offset;
341
224
  readonly upToDate: boolean;
342
225
  readonly closed: boolean;
343
226
  }
@@ -347,82 +230,116 @@ interface ReadNextResult extends ReadResult {
347
230
  }
348
231
  interface HeadResult {
349
232
  readonly contentType: string;
350
- readonly nextOffset: string;
233
+ /** The tail of the stream; an after-exclusive read cursor. */
234
+ readonly offset: Offset;
351
235
  readonly ttlSeconds?: number;
352
236
  readonly expiresAt?: string;
353
237
  readonly closed: boolean;
354
238
  }
355
- interface Reader<E = StorageFault> {
356
- readonly head: (id: StreamId) => Effect.Effect<HeadResult, HeadError | E>;
357
- readonly read: (id: StreamId, options?: ReadOptions) => Effect.Effect<ReadResult, ReadError | E>;
358
- readonly readNext: (id: StreamId, options: ReadNextOptions) => Effect.Effect<ReadNextResult, ReadNextError | E>;
359
- }
360
- interface Writer<E = StorageFault> {
361
- readonly create: (id: StreamId, options?: CreateOptions) => Effect.Effect<CreateResult, CreateError | E>;
362
- readonly fork: (id: StreamId, source: StreamId, options?: Omit<CreateOptions, "forkedFrom">) => Effect.Effect<CreateResult, CreateError | E>;
363
- readonly append: (id: StreamId, options: AppendOptions) => Effect.Effect<AppendResult, AppendError | E>;
364
- readonly remove: (id: StreamId) => Effect.Effect<void, RemoveError | E>;
239
+ declare const StorageCapabilities: Schema.Struct<{
240
+ readonly fork: Schema.Literals<readonly ["none", "copy", "chain"]>;
241
+ readonly atomicScope: Schema.Literals<readonly ["stream", "store"]>;
242
+ readonly wake: Schema.Literals<readonly ["poll", "push"]>;
243
+ readonly expiryIndex: Schema.Literals<readonly ["lazy", "indexed"]>;
244
+ }>;
245
+ interface StorageCapabilities extends Schema.Schema.Type<typeof StorageCapabilities> {}
246
+ /**
247
+ * The identity of one storage owner. A stream service bound to the owner carries the
248
+ * same value in its `owner` field, so `stream.owner === owner.id` tests ownership.
249
+ */
250
+ type OwnerId = Brand.Branded<string, "@streamsy/core/OwnerId">;
251
+ interface StorageOwnerApi {
252
+ /** Identity. A stream service bound to this owner carries the same value in `owner`. */
253
+ readonly id: OwnerId;
254
+ readonly capabilities: StorageCapabilities;
255
+ /**
256
+ * Run `body` in the owner's transaction. Nested calls on the same owner join
257
+ * without savepoints, so a failure must escape the outer body to roll back.
258
+ * Same-owner stream writes and records commit with application SQL on that client.
259
+ * With two owners over one SQL client, only the outer owner's hooks and
260
+ * `committed` subscribers see the commit.
261
+ *
262
+ * A nested call on another SQL client opens its own transaction, as does a lone
263
+ * stream write on that client. Its commit comes first and survives an outer
264
+ * rollback. Use one client per database for nested work. With two clients on
265
+ * one database, SQLite can wait until it reports a busy lock. Postgres or MySQL
266
+ * can wait for a row lock that the outer transaction holds.
267
+ *
268
+ * Durable Object clients share the driver's transaction, so a second client
269
+ * joins the first. Using a second object's storage on one fiber is unsupported.
270
+ * `MemoryStorage` dies when work enters another `MemoryStorage` owner.
271
+ *
272
+ * Keep the body on the calling fiber, and do not wait in it for wakes that only
273
+ * its own commit publishes. A SQL host fails with `StorageFault` when the
274
+ * transaction or a SQL statement in it fails, with `isRetryable` from the SQL error.
275
+ */
276
+ readonly withTransaction: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | StorageFault, R>;
277
+ /**
278
+ * Subscribe to the stream ids of later local commits. The subscription exists when
279
+ * this effect returns. Each item holds the ids that one commit created, appended to
280
+ * or deleted. In process and best effort. The scope releases the subscription.
281
+ */
282
+ readonly committed: Effect.Effect<PubSub.Subscription<ReadonlyArray<StreamId>>, never, Scope.Scope>;
365
283
  }
366
- declare const StreamsReader_base: Context.ServiceClass<StreamsReader, "@streamsy/core/StreamsReader", Reader<StorageFault | TransportFault>>;
367
- declare class StreamsReader extends StreamsReader_base {}
368
- declare const StreamsWriter_base: Context.ServiceClass<StreamsWriter, "@streamsy/core/StreamsWriter", Writer<StorageFault | TransportFault>>;
369
- declare class StreamsWriter extends StreamsWriter_base {}
370
- declare namespace address_d_exports {
371
- export { Collection, Collections, CollectionsChange, CollectionsDecodingServices, CollectionsEncodedChange, CollectionsEncodedEvent, CollectionsEncodingServices, CollectionsEvent, StateAddress, StateChange, StateControl, StateControlName, StateDelete, StateEvent, StateHeaders, StateKey, StateUpsert, StreamAddress, ValidCollections, bytes, isChange, isControl, isUpsert, json, reset, snapshotEnd, snapshotStart, state, stateChange, stateControl };
284
+ declare const StorageOwner_base: Context.ServiceClass<StorageOwner, "@streamsy/core/StorageOwner", StorageOwnerApi>;
285
+ /** The storage owner of a local host: its identity, its transaction and its commits. */
286
+ declare class StorageOwner extends StorageOwner_base {}
287
+ declare namespace durable_state_d_exports {
288
+ export { Change, ChangeEvent, ChangeHeaders, Collection, Collections, CollectionsChange, CollectionsDecodingServices, CollectionsEncodedChange, CollectionsEncodedEvent, CollectionsEncodingServices, CollectionsEvent, Control, ControlName, Delete, DeleteEvent, Entry, Event, EventHeaders, Key, Materialized, Rows, Upsert, UpsertEvent, ValidCollections, changeCodec, changes, controlCodec, isChange, isControl, isUpsert, materialize, materialized, remove, reset, snapshotEnd, snapshotStart, upsert };
372
289
  }
373
290
  /** Omit `offset` and `txid` rather than setting them to `undefined`. */
374
- interface StateHeaders {
291
+ interface EventHeaders {
375
292
  readonly operation: "upsert" | "delete";
376
293
  readonly offset?: string;
377
294
  readonly txid?: string;
378
295
  readonly timestamp?: string;
379
296
  readonly from?: string;
380
297
  }
381
- interface StateUpsert<A, Type extends string = string> {
298
+ interface UpsertEvent<A, Type extends string = string> {
382
299
  readonly type: Type;
383
300
  readonly key: string;
384
301
  readonly value: A;
385
- readonly headers: StateHeaders & {
302
+ readonly headers: EventHeaders & {
386
303
  readonly operation: "upsert";
387
304
  };
388
305
  }
389
- interface StateDelete<A, Type extends string = string> {
306
+ interface DeleteEvent<A, Type extends string = string> {
390
307
  readonly type: Type;
391
308
  readonly key: string;
392
309
  readonly old_value?: A;
393
- readonly headers: StateHeaders & {
310
+ readonly headers: EventHeaders & {
394
311
  readonly operation: "delete";
395
312
  };
396
313
  }
397
314
  /** A change event consumed by `@durable-streams/state`, narrowed by its `type`. */
398
- type StateChange<A, Type extends string = string> = StateUpsert<A, Type> | StateDelete<A, Type>;
399
- type StateEncodedChange<A, Type extends string = string> = (Omit<StateUpsert<A, Type>, "headers"> & {
400
- readonly headers: Omit<StateHeaders, "operation"> & {
315
+ type ChangeEvent<A, Type extends string = string> = UpsertEvent<A, Type> | DeleteEvent<A, Type>;
316
+ type EncodedChangeEvent<A, Type extends string = string> = (Omit<UpsertEvent<A, Type>, "headers"> & {
317
+ readonly headers: Omit<EventHeaders, "operation"> & {
401
318
  readonly operation: "insert" | "update" | "upsert";
402
319
  };
403
- }) | StateDelete<A, Type>;
320
+ }) | DeleteEvent<A, Type>;
404
321
  /** The control signals of the Durable State protocol (STATE-PROTOCOL.md section 4.2). */
405
- type StateControlName = "snapshot-start" | "snapshot-end" | "reset";
322
+ type ControlName = "snapshot-start" | "snapshot-end" | "reset";
406
323
  /**
407
324
  * A control message of a Durable State stream. It has no `type` or `key`.
408
325
  * `snapshot-start` and `snapshot-end` mark a run of changes that is a complete
409
326
  * snapshot. `reset` tells a reader to clear its materialized state. Omit
410
327
  * `offset` rather than setting it to `undefined`.
411
328
  */
412
- interface StateControl {
329
+ interface Control {
413
330
  readonly headers: {
414
- readonly control: StateControlName;
331
+ readonly control: ControlName;
415
332
  readonly offset?: string;
416
333
  };
417
334
  }
418
335
  /** One item of a Durable State stream: a change of one collection or a control. */
419
- type StateEvent<A, Type extends string = string> = StateChange<A, Type> | StateControl;
336
+ type Event<A, Type extends string = string> = ChangeEvent<A, Type> | Control;
420
337
  /** The value fields that may serve as a Durable State key. */
421
- type StateKey<A> = { [K in keyof A]-?: A[K] extends string | number ? K : never; }[keyof A];
338
+ type Key<A> = { [K in keyof A]-?: A[K] extends string | number ? K : never; }[keyof A];
422
339
  /** One collection of a Durable State stream: its value schema and the value field used as the key. */
423
- interface Collection<A, I, RD, RE, Key extends StateKey<A> = StateKey<A>> {
340
+ interface Collection<A, I, RD, RE, KeyField extends Key<A> = Key<A>> {
424
341
  readonly schema: Schema.Codec<A, I, RD, RE>;
425
- readonly key: Key;
342
+ readonly key: KeyField;
426
343
  }
427
344
  /** Collections keyed by the `type` that names them on the wire. */
428
345
  type Collections = Record<string, Collection<any, any, any, any, any>>;
@@ -430,17 +347,128 @@ type Collections = Record<string, Collection<any, any, any, any, any>>;
430
347
  * Each `key` must name a string or number field of its own collection's value.
431
348
  * A mismatch reports on the `key` property of the offending collection.
432
349
  */
433
- type ValidCollections<C extends Collections> = { readonly [K in keyof C]: C[K]["key"] extends StateKey<C[K]["schema"]["Type"]> ? C[K] : {
434
- readonly key: StateKey<C[K]["schema"]["Type"]>;
350
+ type ValidCollections<C extends Collections> = { readonly [K in keyof C]: C[K]["key"] extends Key<C[K]["schema"]["Type"]> ? C[K] : {
351
+ readonly key: Key<C[K]["schema"]["Type"]>;
435
352
  }; };
436
353
  /** The union of change events across every collection, discriminated by `type`. */
437
- type CollectionsChange<C extends Collections> = { [K in keyof C & string]: StateChange<C[K]["schema"]["Type"], K>; }[keyof C & string];
438
- type CollectionsEncodedChange<C extends Collections> = { [K in keyof C & string]: StateEncodedChange<C[K]["schema"]["Encoded"], K>; }[keyof C & string];
354
+ type CollectionsChange<C extends Collections> = { [K in keyof C & string]: ChangeEvent<C[K]["schema"]["Type"], K>; }[keyof C & string];
355
+ type CollectionsEncodedChange<C extends Collections> = { [K in keyof C & string]: EncodedChangeEvent<C[K]["schema"]["Encoded"], K>; }[keyof C & string];
439
356
  /** The items of a State address: the change events of its collections, plus controls. */
440
- type CollectionsEvent<C extends Collections> = CollectionsChange<C> | StateControl;
441
- type CollectionsEncodedEvent<C extends Collections> = CollectionsEncodedChange<C> | StateControl;
357
+ type CollectionsEvent<C extends Collections> = CollectionsChange<C> | Control;
358
+ type CollectionsEncodedEvent<C extends Collections> = CollectionsEncodedChange<C> | Control;
442
359
  type CollectionsDecodingServices<C extends Collections> = C[keyof C]["schema"]["DecodingServices"];
443
360
  type CollectionsEncodingServices<C extends Collections> = C[keyof C]["schema"]["EncodingServices"];
361
+ /**
362
+ * A codec for the upsert and delete change events of one collection.
363
+ * `StreamAddress.state` composes one of these per collection. Omit optional
364
+ * headers instead of setting them to `undefined`.
365
+ */
366
+ declare function changeCodec<A, I, RD, RE, const Type extends string>(options: {
367
+ readonly schema: Schema.Codec<A, I, RD, RE>;
368
+ readonly type: Type;
369
+ }): Schema.Codec<ChangeEvent<A, Type>, EncodedChangeEvent<I, Type>, RD, RE>;
370
+ /** The codec for a State control message. It needs no services. */
371
+ declare const controlCodec: Schema.Codec<Control>;
372
+ /** True for a control message. A change has `headers.operation` and no `headers.control`. */
373
+ declare const isControl: <E extends Event<unknown>>(event: E) => event is Extract<E, Control>;
374
+ /** True for an upsert or delete change. */
375
+ declare const isChange: <E extends Event<unknown>>(event: E) => event is Exclude<E, Control>;
376
+ /** True for an upsert change, with its value available. */
377
+ declare const isUpsert: <E extends Event<unknown>>(event: E) => event is Extract<E, UpsertEvent<unknown>>;
378
+ /** A `reset` control. A reader should clear its materialized state and apply what follows. */
379
+ declare const reset: (options?: {
380
+ readonly offset?: StartOffset;
381
+ }) => Control;
382
+ /** A `snapshot-start` control. The changes up to `snapshot-end` form a complete snapshot. */
383
+ declare const snapshotStart: (options?: {
384
+ readonly offset?: StartOffset;
385
+ }) => Control;
386
+ /** A `snapshot-end` control. It closes the snapshot that `snapshot-start` opened. */
387
+ declare const snapshotEnd: (options?: {
388
+ readonly offset?: StartOffset;
389
+ }) => Control;
390
+ interface ChangeHeaders {
391
+ readonly txid?: string;
392
+ readonly timestamp?: string;
393
+ readonly from?: string;
394
+ }
395
+ type Operation$1<A, Type extends string> = Data.TaggedEnum<{
396
+ Upsert: {
397
+ readonly type: Type;
398
+ readonly value: A;
399
+ readonly headers?: ChangeHeaders;
400
+ };
401
+ Delete: {
402
+ readonly type: Type;
403
+ readonly key: string | number;
404
+ readonly oldValue?: A;
405
+ readonly headers?: ChangeHeaders;
406
+ };
407
+ }>;
408
+ type Upsert<A, Type extends string = string> = Data.TaggedEnum.Value<Operation$1<A, Type>, "Upsert">;
409
+ type Delete<A, Type extends string = string> = Data.TaggedEnum.Value<Operation$1<A, Type>, "Delete">;
410
+ /** A pending change for one of the collections in `C`. */
411
+ type Change<C extends Collections> = { [K in keyof C & string]: Upsert<C[K]["schema"]["Type"], K> | Delete<C[K]["schema"]["Type"], K>; }[keyof C & string];
412
+ /**
413
+ * One entry for `changes`: a pending change, or a State control such as
414
+ * `DurableState.reset()`.
415
+ */
416
+ type Entry<C extends Collections> = Change<C> | Control;
417
+ /** Describe an upsert into a collection. The key is read from the value. */
418
+ declare const upsert: <const Type extends string, A>(type: Type, value: A, options?: {
419
+ readonly headers?: ChangeHeaders;
420
+ }) => Upsert<A, Type>;
421
+ /** Describe a delete from a collection by key. An `oldValue` is written as `old_value`. */
422
+ declare const remove: <const Type extends string, A = never>(type: Type, key: string | number, options?: {
423
+ readonly oldValue?: A;
424
+ readonly headers?: ChangeHeaders;
425
+ }) => Delete<NoInfer<A>, Type>;
426
+ /**
427
+ * Stamp Durable State changes with their key and headers. `source` gives the
428
+ * collections: a `Streamsy.state` class, a bound State address, or a
429
+ * `StreamAddress.state` address. With an `offset`, each change gets that offset
430
+ * and a default txid of `<offset>:<index>`. A control entry passes through. It
431
+ * gets the `offset` only when it has none of its own.
432
+ */
433
+ declare function changes<C extends Collections>(source: {
434
+ readonly collections: C;
435
+ }, entries: Array.NonEmptyReadonlyArray<Entry<C>>, options?: {
436
+ readonly offset?: StartOffset;
437
+ }): Array.NonEmptyReadonlyArray<CollectionsEvent<C>>;
438
+ declare function changes<C extends Collections>(source: {
439
+ readonly collections: C;
440
+ }, entries: ReadonlyArray<Entry<C>>, options?: {
441
+ readonly offset?: StartOffset;
442
+ }): ReadonlyArray<CollectionsEvent<C>>;
443
+ /** The rows of one collection, by State key. */
444
+ type Rows<C extends Collections> = { readonly [K in keyof C & string]: ReadonlyMap<string, C[K]["schema"]["Type"]>; };
445
+ /**
446
+ * The materialized state of a Durable State stream: the latest row for each key
447
+ * of each collection. `snapshot` holds the keys seen since an open
448
+ * `snapshot-start`, and is `undefined` outside a snapshot.
449
+ */
450
+ interface Materialized<C extends Collections> {
451
+ readonly rows: Rows<C>;
452
+ readonly snapshot: ReadonlySet<string> | undefined;
453
+ }
454
+ /** Empty materialized state for the collections of `address`. */
455
+ declare function materialized<C extends Collections>(address: {
456
+ readonly collections: C;
457
+ }): Materialized<C>;
458
+ /**
459
+ * Fold State events into materialized state, with the State protocol rules:
460
+ *
461
+ * - `upsert` sets the row of its key, and `delete` removes it.
462
+ * - `reset` clears every collection.
463
+ * - `snapshot-end` removes each row that no change since `snapshot-start` named.
464
+ * A snapshot may span several calls.
465
+ *
466
+ * The input state is not changed. Only the collections that `events` touch are copied.
467
+ */
468
+ declare function materialize<C extends Collections>(state: Materialized<C>, events: Iterable<CollectionsEvent<C>>): Materialized<C>;
469
+ declare namespace address_d_exports {
470
+ export { StateAddress, StreamAddress, bytes, json, state };
471
+ }
444
472
  /** Inert identity and codec. Constructing an address acquires no service or resource. */
445
473
  interface StreamAddress<A, RD = never, RE = never> {
446
474
  readonly _tag: "Json" | "Bytes";
@@ -457,35 +485,6 @@ interface StateAddress<C extends Collections, RD = CollectionsDecodingServices<C
457
485
  declare function json<A, I, RD, RE>(id: string, options: {
458
486
  readonly schema: Schema.Codec<A, I, RD, RE>;
459
487
  }): StreamAddress<A, RD, RE>;
460
- /**
461
- * A codec for the upsert and delete change events of one collection.
462
- * `state` composes one of these per collection. Omit optional headers instead
463
- * of setting them to `undefined`.
464
- */
465
- declare function stateChange<A, I, RD, RE, const Type extends string>(options: {
466
- readonly schema: Schema.Codec<A, I, RD, RE>;
467
- readonly type: Type;
468
- }): Schema.Codec<StateChange<A, Type>, StateEncodedChange<I, Type>, RD, RE>;
469
- /** The codec for a State control message. It needs no services. */
470
- declare const stateControl: Schema.Codec<StateControl>;
471
- /** True for a control message. A change has `headers.operation` and no `headers.control`. */
472
- declare const isControl: <E extends StateEvent<unknown>>(event: E) => event is Extract<E, StateControl>;
473
- /** True for an upsert or delete change. */
474
- declare const isChange: <E extends StateEvent<unknown>>(event: E) => event is Exclude<E, StateControl>;
475
- /** True for an upsert change, with its value available. */
476
- declare const isUpsert: <E extends StateEvent<unknown>>(event: E) => event is Extract<E, StateUpsert<unknown>>;
477
- /** A `reset` control. A reader should clear its materialized state and apply what follows. */
478
- declare const reset: (options?: {
479
- readonly offset?: string;
480
- }) => StateControl;
481
- /** A `snapshot-start` control. The changes up to `snapshot-end` form a complete snapshot. */
482
- declare const snapshotStart: (options?: {
483
- readonly offset?: string;
484
- }) => StateControl;
485
- /** A `snapshot-end` control. It closes the snapshot that `snapshot-start` opened. */
486
- declare const snapshotEnd: (options?: {
487
- readonly offset?: string;
488
- }) => StateControl;
489
488
  /**
490
489
  * A stream of Durable State events for several collections. Each record
491
490
  * key is the `type` on the wire; each entry gives the value schema and the value
@@ -501,13 +500,6 @@ declare function state<const C extends Collections>(id: string, options: {
501
500
  declare function bytes(id: string, options?: {
502
501
  readonly contentType?: string;
503
502
  }): StreamAddress<Uint8Array>;
504
- declare const StorageCapabilities: Schema.Struct<{
505
- readonly fork: Schema.Literals<readonly ["none", "copy", "chain"]>;
506
- readonly atomicScope: Schema.Literals<readonly ["stream", "store"]>;
507
- readonly wake: Schema.Literals<readonly ["poll", "push"]>;
508
- readonly expiryIndex: Schema.Literals<readonly ["lazy", "indexed"]>;
509
- }>;
510
- interface StorageCapabilities extends Schema.Schema.Type<typeof StorageCapabilities> {}
511
503
  declare const ProducerPrecondition: Schema.Struct<{
512
504
  readonly producerId: Schema.brand<Schema.String, "ProducerId">;
513
505
  readonly expected: Schema.Option<Schema.Struct<{
@@ -533,31 +525,31 @@ declare const Operation: Schema.Union<readonly [Schema.TaggedStruct<"Create", {
533
525
  readonly closed: Schema.Boolean;
534
526
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
535
527
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
536
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
528
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
537
529
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
538
530
  readonly softDeleted: Schema.Boolean;
539
531
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
540
532
  }>;
541
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
533
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
542
534
  }>;
543
535
  readonly initialMessages: Schema.$Array<Schema.Struct<{
544
- readonly offset: Schema.brand<Schema.String, "Offset">;
536
+ readonly offset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
545
537
  readonly timestamp: Schema.Finite;
546
538
  readonly data: Schema.Uint8Array;
547
539
  }>>;
548
540
  readonly forkSource: Schema.optionalKey<Schema.Struct<{
549
541
  readonly id: Schema.brand<Schema.String, "StreamId">;
550
- readonly liveAtOffset: Schema.brand<Schema.String, "Offset">;
542
+ readonly liveAtOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
551
543
  }>>;
552
544
  }>, Schema.TaggedStruct<"Append", {
553
545
  readonly streamId: Schema.brand<Schema.String, "StreamId">;
554
546
  readonly messages: Schema.$Array<Schema.Struct<{
555
- readonly offset: Schema.brand<Schema.String, "Offset">;
547
+ readonly offset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
556
548
  readonly timestamp: Schema.Finite;
557
549
  readonly data: Schema.Uint8Array;
558
550
  }>>;
559
551
  readonly patch: Schema.Struct<{
560
- readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
552
+ readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
561
553
  readonly config: Schema.optionalKey<Schema.Struct<{
562
554
  readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
563
555
  readonly expiresAt: Schema.optionalKey<Schema.String>;
@@ -566,7 +558,7 @@ declare const Operation: Schema.Union<readonly [Schema.TaggedStruct<"Create", {
566
558
  readonly lastSeq: Schema.optionalKey<Schema.String>;
567
559
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
568
560
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
569
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
561
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
570
562
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
571
563
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
572
564
  readonly closed: Schema.optionalKey<Schema.Boolean>;
@@ -574,7 +566,7 @@ declare const Operation: Schema.Union<readonly [Schema.TaggedStruct<"Create", {
574
566
  }>>;
575
567
  readonly clear: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["ttlSeconds", "expiresAt", "expiresAtMs", "lastSeq"]>>>;
576
568
  }>;
577
- readonly expectedOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
569
+ readonly expectedOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
578
570
  readonly expectedClosed: Schema.optionalKey<Schema.Boolean>;
579
571
  readonly producer: Schema.optionalKey<Schema.Struct<{
580
572
  readonly producerId: Schema.brand<Schema.String, "ProducerId">;
@@ -607,31 +599,31 @@ declare const Mutation: Schema.Struct<{
607
599
  readonly closed: Schema.Boolean;
608
600
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
609
601
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
610
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
602
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
611
603
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
612
604
  readonly softDeleted: Schema.Boolean;
613
605
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
614
606
  }>;
615
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
607
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
616
608
  }>;
617
609
  readonly initialMessages: Schema.$Array<Schema.Struct<{
618
- readonly offset: Schema.brand<Schema.String, "Offset">;
610
+ readonly offset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
619
611
  readonly timestamp: Schema.Finite;
620
612
  readonly data: Schema.Uint8Array;
621
613
  }>>;
622
614
  readonly forkSource: Schema.optionalKey<Schema.Struct<{
623
615
  readonly id: Schema.brand<Schema.String, "StreamId">;
624
- readonly liveAtOffset: Schema.brand<Schema.String, "Offset">;
616
+ readonly liveAtOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
625
617
  }>>;
626
618
  }>, Schema.TaggedStruct<"Append", {
627
619
  readonly streamId: Schema.brand<Schema.String, "StreamId">;
628
620
  readonly messages: Schema.$Array<Schema.Struct<{
629
- readonly offset: Schema.brand<Schema.String, "Offset">;
621
+ readonly offset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
630
622
  readonly timestamp: Schema.Finite;
631
623
  readonly data: Schema.Uint8Array;
632
624
  }>>;
633
625
  readonly patch: Schema.Struct<{
634
- readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
626
+ readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
635
627
  readonly config: Schema.optionalKey<Schema.Struct<{
636
628
  readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
637
629
  readonly expiresAt: Schema.optionalKey<Schema.String>;
@@ -640,7 +632,7 @@ declare const Mutation: Schema.Struct<{
640
632
  readonly lastSeq: Schema.optionalKey<Schema.String>;
641
633
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
642
634
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
643
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
635
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
644
636
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
645
637
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
646
638
  readonly closed: Schema.optionalKey<Schema.Boolean>;
@@ -648,7 +640,7 @@ declare const Mutation: Schema.Struct<{
648
640
  }>>;
649
641
  readonly clear: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["ttlSeconds", "expiresAt", "expiresAtMs", "lastSeq"]>>>;
650
642
  }>;
651
- readonly expectedOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
643
+ readonly expectedOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
652
644
  readonly expectedClosed: Schema.optionalKey<Schema.Boolean>;
653
645
  readonly producer: Schema.optionalKey<Schema.Struct<{
654
646
  readonly producerId: Schema.brand<Schema.String, "ProducerId">;
@@ -681,12 +673,12 @@ declare const OperationResult: Schema.Union<readonly [Schema.TaggedStruct<"Creat
681
673
  readonly closed: Schema.Boolean;
682
674
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
683
675
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
684
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
676
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
685
677
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
686
678
  readonly softDeleted: Schema.Boolean;
687
679
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
688
680
  }>;
689
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
681
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
690
682
  }>;
691
683
  }>, Schema.TaggedStruct<"Appended", {
692
684
  readonly record: Schema.Struct<{
@@ -702,12 +694,12 @@ declare const OperationResult: Schema.Union<readonly [Schema.TaggedStruct<"Creat
702
694
  readonly closed: Schema.Boolean;
703
695
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
704
696
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
705
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
697
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
706
698
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
707
699
  readonly softDeleted: Schema.Boolean;
708
700
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
709
701
  }>;
710
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
702
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
711
703
  }>;
712
704
  }>, Schema.TaggedStruct<"Purged", {
713
705
  readonly record: Schema.Struct<{
@@ -723,12 +715,12 @@ declare const OperationResult: Schema.Union<readonly [Schema.TaggedStruct<"Creat
723
715
  readonly closed: Schema.Boolean;
724
716
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
725
717
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
726
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
718
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
727
719
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
728
720
  readonly softDeleted: Schema.Boolean;
729
721
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
730
722
  }>;
731
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
723
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
732
724
  }>;
733
725
  }>, Schema.TaggedStruct<"SoftDeleted", {
734
726
  readonly record: Schema.Struct<{
@@ -744,12 +736,12 @@ declare const OperationResult: Schema.Union<readonly [Schema.TaggedStruct<"Creat
744
736
  readonly closed: Schema.Boolean;
745
737
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
746
738
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
747
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
739
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
748
740
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
749
741
  readonly softDeleted: Schema.Boolean;
750
742
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
751
743
  }>;
752
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
744
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
753
745
  }>;
754
746
  }>]>;
755
747
  /** The success channel of a storage mutation contains only applied operation results. */
@@ -768,12 +760,12 @@ declare const MutationApplied: Schema.TaggedStruct<"Applied", {
768
760
  readonly closed: Schema.Boolean;
769
761
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
770
762
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
771
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
763
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
772
764
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
773
765
  readonly softDeleted: Schema.Boolean;
774
766
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
775
767
  }>;
776
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
768
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
777
769
  }>;
778
770
  }>, Schema.TaggedStruct<"Appended", {
779
771
  readonly record: Schema.Struct<{
@@ -789,12 +781,12 @@ declare const MutationApplied: Schema.TaggedStruct<"Applied", {
789
781
  readonly closed: Schema.Boolean;
790
782
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
791
783
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
792
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
784
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
793
785
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
794
786
  readonly softDeleted: Schema.Boolean;
795
787
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
796
788
  }>;
797
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
789
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
798
790
  }>;
799
791
  }>, Schema.TaggedStruct<"Purged", {
800
792
  readonly record: Schema.Struct<{
@@ -810,12 +802,12 @@ declare const MutationApplied: Schema.TaggedStruct<"Applied", {
810
802
  readonly closed: Schema.Boolean;
811
803
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
812
804
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
813
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
805
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
814
806
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
815
807
  readonly softDeleted: Schema.Boolean;
816
808
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
817
809
  }>;
818
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
810
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
819
811
  }>;
820
812
  }>, Schema.TaggedStruct<"SoftDeleted", {
821
813
  readonly record: Schema.Struct<{
@@ -831,12 +823,12 @@ declare const MutationApplied: Schema.TaggedStruct<"Applied", {
831
823
  readonly closed: Schema.Boolean;
832
824
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
833
825
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
834
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
826
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
835
827
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
836
828
  readonly softDeleted: Schema.Boolean;
837
829
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
838
830
  }>;
839
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
831
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
840
832
  }>;
841
833
  }>]>>;
842
834
  }>;
@@ -856,12 +848,12 @@ declare const MutationRejected_base: Schema.Class<MutationRejected, Schema.Tagge
856
848
  readonly closed: Schema.Boolean;
857
849
  readonly closedAt: Schema.optionalKey<Schema.Finite>;
858
850
  readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
859
- readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
851
+ readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">>;
860
852
  readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
861
853
  readonly softDeleted: Schema.Boolean;
862
854
  readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
863
855
  }>;
864
- readonly currentOffset: Schema.brand<Schema.String, "Offset">;
856
+ readonly currentOffset: Schema.brand<Schema.brand<Schema.String, "Offset">, "StreamsyOffset">;
865
857
  }>>;
866
858
  }>, import("effect/Cause").YieldableError>;
867
859
  declare class MutationRejected extends MutationRejected_base {}
@@ -889,32 +881,32 @@ declare const Operations: Data.TaggedEnum.Constructor<{
889
881
  readonly closed: boolean;
890
882
  readonly closedAt?: number | undefined;
891
883
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
892
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
884
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
893
885
  readonly forkSubOffset?: number | undefined;
894
886
  readonly softDeleted: boolean;
895
887
  readonly expiresAtMs?: number | undefined;
896
888
  };
897
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
889
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
898
890
  };
899
891
  readonly initialMessages: readonly {
900
- readonly offset: string & import("effect/Brand").Brand<"Offset">;
892
+ readonly offset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
901
893
  readonly timestamp: number;
902
894
  readonly data: Uint8Array<ArrayBufferLike>;
903
895
  }[];
904
896
  readonly forkSource?: {
905
897
  readonly id: string & import("effect/Brand").Brand<"StreamId">;
906
- readonly liveAtOffset: string & import("effect/Brand").Brand<"Offset">;
898
+ readonly liveAtOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
907
899
  } | undefined;
908
900
  } | {
909
901
  readonly _tag: "Append";
910
902
  readonly streamId: string & import("effect/Brand").Brand<"StreamId">;
911
903
  readonly messages: readonly {
912
- readonly offset: string & import("effect/Brand").Brand<"Offset">;
904
+ readonly offset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
913
905
  readonly timestamp: number;
914
906
  readonly data: Uint8Array<ArrayBufferLike>;
915
907
  }[];
916
908
  readonly patch: {
917
- readonly currentOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
909
+ readonly currentOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
918
910
  readonly config?: {
919
911
  readonly ttlSeconds?: number | undefined;
920
912
  readonly expiresAt?: string | undefined;
@@ -923,7 +915,7 @@ declare const Operations: Data.TaggedEnum.Constructor<{
923
915
  readonly lastSeq?: string | undefined;
924
916
  readonly closedAt?: number | undefined;
925
917
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
926
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
918
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
927
919
  readonly forkSubOffset?: number | undefined;
928
920
  readonly expiresAtMs?: number | undefined;
929
921
  readonly closed?: boolean | undefined;
@@ -931,7 +923,7 @@ declare const Operations: Data.TaggedEnum.Constructor<{
931
923
  } | undefined;
932
924
  readonly clear?: readonly ("expiresAt" | "expiresAtMs" | "lastSeq" | "ttlSeconds")[] | undefined;
933
925
  };
934
- readonly expectedOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
926
+ readonly expectedOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
935
927
  readonly expectedClosed?: boolean | undefined;
936
928
  readonly producer?: {
937
929
  readonly producerId: string & import("effect/Brand").Brand<"ProducerId">;
@@ -965,12 +957,12 @@ declare const OperationResults: Data.TaggedEnum.Constructor<{
965
957
  readonly closed: boolean;
966
958
  readonly closedAt?: number | undefined;
967
959
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
968
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
960
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
969
961
  readonly forkSubOffset?: number | undefined;
970
962
  readonly softDeleted: boolean;
971
963
  readonly expiresAtMs?: number | undefined;
972
964
  };
973
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
965
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
974
966
  };
975
967
  } | {
976
968
  readonly _tag: "Appended";
@@ -987,12 +979,12 @@ declare const OperationResults: Data.TaggedEnum.Constructor<{
987
979
  readonly closed: boolean;
988
980
  readonly closedAt?: number | undefined;
989
981
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
990
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
982
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
991
983
  readonly forkSubOffset?: number | undefined;
992
984
  readonly softDeleted: boolean;
993
985
  readonly expiresAtMs?: number | undefined;
994
986
  };
995
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
987
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
996
988
  };
997
989
  } | {
998
990
  readonly _tag: "Purged";
@@ -1009,12 +1001,12 @@ declare const OperationResults: Data.TaggedEnum.Constructor<{
1009
1001
  readonly closed: boolean;
1010
1002
  readonly closedAt?: number | undefined;
1011
1003
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1012
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1004
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1013
1005
  readonly forkSubOffset?: number | undefined;
1014
1006
  readonly softDeleted: boolean;
1015
1007
  readonly expiresAtMs?: number | undefined;
1016
1008
  };
1017
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1009
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1018
1010
  };
1019
1011
  } | {
1020
1012
  readonly _tag: "SoftDeleted";
@@ -1031,12 +1023,12 @@ declare const OperationResults: Data.TaggedEnum.Constructor<{
1031
1023
  readonly closed: boolean;
1032
1024
  readonly closedAt?: number | undefined;
1033
1025
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1034
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1026
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1035
1027
  readonly forkSubOffset?: number | undefined;
1036
1028
  readonly softDeleted: boolean;
1037
1029
  readonly expiresAtMs?: number | undefined;
1038
1030
  };
1039
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1031
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1040
1032
  };
1041
1033
  }>;
1042
1034
  declare const Mutations: Data.TaggedEnum.Constructor<{
@@ -1056,12 +1048,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1056
1048
  readonly closed: boolean;
1057
1049
  readonly closedAt?: number | undefined;
1058
1050
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1059
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1051
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1060
1052
  readonly forkSubOffset?: number | undefined;
1061
1053
  readonly softDeleted: boolean;
1062
1054
  readonly expiresAtMs?: number | undefined;
1063
1055
  };
1064
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1056
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1065
1057
  };
1066
1058
  } | {
1067
1059
  readonly _tag: "Appended";
@@ -1078,12 +1070,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1078
1070
  readonly closed: boolean;
1079
1071
  readonly closedAt?: number | undefined;
1080
1072
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1081
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1073
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1082
1074
  readonly forkSubOffset?: number | undefined;
1083
1075
  readonly softDeleted: boolean;
1084
1076
  readonly expiresAtMs?: number | undefined;
1085
1077
  };
1086
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1078
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1087
1079
  };
1088
1080
  } | {
1089
1081
  readonly _tag: "Purged";
@@ -1100,12 +1092,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1100
1092
  readonly closed: boolean;
1101
1093
  readonly closedAt?: number | undefined;
1102
1094
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1103
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1095
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1104
1096
  readonly forkSubOffset?: number | undefined;
1105
1097
  readonly softDeleted: boolean;
1106
1098
  readonly expiresAtMs?: number | undefined;
1107
1099
  };
1108
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1100
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1109
1101
  };
1110
1102
  } | {
1111
1103
  readonly _tag: "SoftDeleted";
@@ -1122,12 +1114,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1122
1114
  readonly closed: boolean;
1123
1115
  readonly closedAt?: number | undefined;
1124
1116
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1125
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1117
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1126
1118
  readonly forkSubOffset?: number | undefined;
1127
1119
  readonly softDeleted: boolean;
1128
1120
  readonly expiresAtMs?: number | undefined;
1129
1121
  };
1130
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1122
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1131
1123
  };
1132
1124
  }, ...({
1133
1125
  readonly _tag: "Created";
@@ -1144,12 +1136,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1144
1136
  readonly closed: boolean;
1145
1137
  readonly closedAt?: number | undefined;
1146
1138
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1147
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1139
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1148
1140
  readonly forkSubOffset?: number | undefined;
1149
1141
  readonly softDeleted: boolean;
1150
1142
  readonly expiresAtMs?: number | undefined;
1151
1143
  };
1152
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1144
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1153
1145
  };
1154
1146
  } | {
1155
1147
  readonly _tag: "Appended";
@@ -1166,12 +1158,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1166
1158
  readonly closed: boolean;
1167
1159
  readonly closedAt?: number | undefined;
1168
1160
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1169
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1161
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1170
1162
  readonly forkSubOffset?: number | undefined;
1171
1163
  readonly softDeleted: boolean;
1172
1164
  readonly expiresAtMs?: number | undefined;
1173
1165
  };
1174
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1166
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1175
1167
  };
1176
1168
  } | {
1177
1169
  readonly _tag: "Purged";
@@ -1188,12 +1180,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1188
1180
  readonly closed: boolean;
1189
1181
  readonly closedAt?: number | undefined;
1190
1182
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1191
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1183
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1192
1184
  readonly forkSubOffset?: number | undefined;
1193
1185
  readonly softDeleted: boolean;
1194
1186
  readonly expiresAtMs?: number | undefined;
1195
1187
  };
1196
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1188
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1197
1189
  };
1198
1190
  } | {
1199
1191
  readonly _tag: "SoftDeleted";
@@ -1210,12 +1202,12 @@ declare const Mutations: Data.TaggedEnum.Constructor<{
1210
1202
  readonly closed: boolean;
1211
1203
  readonly closedAt?: number | undefined;
1212
1204
  readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
1213
- readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
1205
+ readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">) | undefined;
1214
1206
  readonly forkSubOffset?: number | undefined;
1215
1207
  readonly softDeleted: boolean;
1216
1208
  readonly expiresAtMs?: number | undefined;
1217
1209
  };
1218
- readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
1210
+ readonly currentOffset: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
1219
1211
  };
1220
1212
  })[]];
1221
1213
  }>;
@@ -1240,157 +1232,4 @@ interface StorageShape {
1240
1232
  readonly streamId: StreamId;
1241
1233
  }>, StorageFault>;
1242
1234
  }
1243
- declare const Storage_base: Context.ServiceClass<Storage, "@streamsy/core/Storage", StorageShape>;
1244
- declare class Storage extends Storage_base {}
1245
- interface CommitBoundaryApi {
1246
- /**
1247
- * Run `body` in the storage owner's transaction. Nested calls on the same owner
1248
- * join without savepoints, so a failure must escape the outer body to roll back.
1249
- * Same-owner stream writes and records commit with application SQL on that client.
1250
- * With two boundaries over one SQL client, only the outer boundary's hooks and
1251
- * `committed` subscribers see the commit.
1252
- *
1253
- * A nested call on another SQL client opens its own transaction, as does a lone
1254
- * `Storage.mutate` on that client. Its commit comes first and survives an outer
1255
- * rollback. Use one client per database for nested work. With two clients on
1256
- * one database, SQLite can wait until it reports a busy lock. Postgres or MySQL
1257
- * can wait for a row lock that the outer transaction holds.
1258
- *
1259
- * Durable Object clients share the driver's transaction, so a second client
1260
- * joins the first. Using a second object's storage on one fiber is unsupported.
1261
- * `MemoryStorage` dies when work enters another `MemoryStorage` owner.
1262
- *
1263
- * Keep the body on the calling fiber, and do not wait in it for wakes that only
1264
- * its own commit publishes. Only SQL hosts fail with `SqlError`.
1265
- */
1266
- readonly withTransaction: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError.SqlError, R>;
1267
- }
1268
- declare const CommitBoundary_base: Context.ServiceClass<CommitBoundary, "@streamsy/core/CommitBoundary", CommitBoundaryApi>;
1269
- /** The transaction of the storage owner. Every Streamsy storage host provides it. */
1270
- declare class CommitBoundary extends CommitBoundary_base {}
1271
- /**
1272
- * Encoded records on the storage owner, for the projection checkpoint store.
1273
- * Calls inside `CommitBoundary.withTransaction` join that transaction.
1274
- */
1275
- interface OwnerRecordsApi {
1276
- readonly read: (key: string) => Effect.Effect<Option.Option<string>, StorageFault>;
1277
- /**
1278
- * A snapshot of the owner's encoded entries whose keys start with this exact prefix.
1279
- * A store that cannot list fails with operation `OWNER_RECORDS_LIST_UNSUPPORTED`.
1280
- */
1281
- readonly list: (prefix: string) => Effect.Effect<ReadonlyArray<readonly [key: string, encoded: string]>, StorageFault>;
1282
- readonly write: (key: string, encoded: string) => Effect.Effect<void, StorageFault>;
1283
- readonly remove: (key: string) => Effect.Effect<void, StorageFault>;
1284
- }
1285
- /** The `StorageFault.operation` of an owner store that cannot list its records. */
1286
- declare const OWNER_RECORDS_LIST_UNSUPPORTED = "records.list.unsupported";
1287
- declare const OwnerRecords_base: Context.ServiceClass<OwnerRecords, "@streamsy/core/internal/OwnerRecords", OwnerRecordsApi>;
1288
- declare class OwnerRecords extends OwnerRecords_base {}
1289
- /**
1290
- * Work that joins an owned transaction just before it commits. It receives the
1291
- * stream ids that the transaction created, appended to or deleted.
1292
- */
1293
- type CommitHook = (ids: ReadonlySet<StreamId>) => Effect.Effect<void, SqlError.SqlError>;
1294
- /**
1295
- * Commit hooks on the storage owner, for the durable projection marks.
1296
- *
1297
- * A hook runs inside each later owned transaction that wrote at least one stream
1298
- * id, after the body and before COMMIT. Statements in the hook join the
1299
- * transaction, and a hook failure rolls the transaction back. A SQL host treats
1300
- * a hook failure like a body failure, so a retryable `SqlError` replays the
1301
- * whole transaction, hook included. The memory host turns a hook failure into a
1302
- * defect. A hook must not write streams: its ids would not reach other hooks.
1303
- */
1304
- interface CommitHooksApi {
1305
- /** Register `hook` until the scope closes. */
1306
- readonly beforeCommit: (hook: CommitHook) => Effect.Effect<void, never, Scope.Scope>;
1307
- }
1308
- declare const CommitHooks_base: Context.ServiceClass<CommitHooks, "@streamsy/core/internal/CommitHooks", CommitHooksApi>;
1309
- declare class CommitHooks extends CommitHooks_base {}
1310
- /** Shared registry for storage boundaries: register in a scope, run in order. */
1311
- declare const commitHookRegistry: () => {
1312
- beforeCommit: (hook: CommitHook) => Effect.Effect<void, never, Scope.Scope>;
1313
- run: (ids: ReadonlySet<StreamId>) => Effect.Effect<void, SqlError.SqlError>;
1314
- };
1315
- /** Last failed run, retained through marks, retries and resumes. Messages hold at most 1,000 characters. */
1316
- interface MarkFailure {
1317
- readonly at: number;
1318
- readonly reason: Option.Option<string>;
1319
- readonly message: string;
1320
- }
1321
- /** One pending mark: a binding with input work, a retry, or a recorded wake. */
1322
- interface PendingMark {
1323
- /** The binding's canonical params, as `canonicalParams` encodes them. */
1324
- readonly params: string;
1325
- /** Raised by every mark. A clear only deletes the row when its `seq` still matches. */
1326
- readonly seq: number;
1327
- /** Failed runs since the last success. A mark keeps it. */
1328
- readonly attempts: number;
1329
- /** Epoch ms. 0 means due now; ignored while stopped. */
1330
- readonly dueAt: number;
1331
- /** Recorded wake; when set, equals dueAt and the row has no failure or attempts. */
1332
- readonly wakeAt: Option.Option<number>;
1333
- /** Waits until retry or resume. A mark preserves the stop. */
1334
- readonly stopped: boolean;
1335
- readonly failure: Option.Option<MarkFailure>;
1336
- }
1337
- /** Disjoint counts of one projection's marks at the supplied time. */
1338
- interface ProjectionMarkSummary {
1339
- readonly fresh: number;
1340
- readonly sleeping: number;
1341
- readonly retryDue: number;
1342
- readonly backingOff: number;
1343
- readonly stopped: number;
1344
- /** Earliest due time across non-stopped marks, including fresh and sleeping marks. */
1345
- readonly nextDueAt: Option.Option<number>;
1346
- }
1347
- /**
1348
- * Pending marks for attached projections, on a storage owner or in private memory.
1349
- *
1350
- * A mark is keyed by projection id and canonical params. A deploy that raises the
1351
- * generation picks up the existing marks.
1352
- */
1353
- interface ProjectionMarksApi {
1354
- /** Maximum projection id length in Unicode code points, when bounded by storage. */
1355
- readonly maxProjectionIdLength?: number;
1356
- /**
1357
- * Insert a mark for each binding, or raise its `seq`. A raise keeps
1358
- * `attempts`, `stopped` and `failure`, so a write never resets backoff or a stop.
1359
- * A sleeping row becomes due now and loses its wake index.
1360
- * Call it inside a commit hook. It joins the transaction and fails like the
1361
- * transaction's own statements.
1362
- */
1363
- readonly mark: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<void, SqlError.SqlError>;
1364
- /** The earliest `dueAt` of the projection's non-stopped marks. */
1365
- readonly nextDue: (projection: string) => Effect.Effect<Option.Option<number>, StorageFault>;
1366
- /** Five disjoint counts: fresh, sleeping, retry due, backing off and stopped. */
1367
- readonly summary: (projection: string, now: number) => Effect.Effect<ProjectionMarkSummary, StorageFault>;
1368
- /** Up to `limit` non-stopped marks with `dueAt <= now`, earliest first. */
1369
- readonly due: (projection: string, now: number, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
1370
- /** The marks of these bindings that exist, keyed by params. */
1371
- readonly read: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<ReadonlyMap<string, PendingMark>, StorageFault>;
1372
- /** Delete on a matching `seq`; otherwise keep the row and reset its failure, attempts, dueAt, wakeAt and stop. */
1373
- readonly clear: (projection: string, params: string, seq: number) => Effect.Effect<void, StorageFault>;
1374
- /** Keep a matching row asleep at wakeAt and reset failure state. A seq mismatch
1375
- * becomes fresh and due now. An absent row is inserted asleep with seq 1. */
1376
- readonly sleep: (projection: string, params: string, seq: number, wakeAt: number) => Effect.Effect<void, StorageFault>;
1377
- /** Delete the mark whatever its `seq`. */
1378
- readonly remove: (projection: string, params: string) => Effect.Effect<void, StorageFault>;
1379
- /** Insert or update a failure, preserving seq. Some(dueAt) backs off; None stops. */
1380
- readonly fail: (projection: string, params: string, options: {
1381
- readonly attempts: number;
1382
- readonly failure: MarkFailure;
1383
- readonly dueAt: Option.Option<number>;
1384
- }) => Effect.Effect<void, StorageFault>;
1385
- /** Set failed or stopped marks due now and clear their stop, preserving attempts, seq and failure.
1386
- * Optionally select one binding. Returns the number changed; already due, non-stopped marks are unchanged.
1387
- */
1388
- readonly retry: (projection: string, params?: string) => Effect.Effect<number, StorageFault>;
1389
- /** Make stopped marks due now, preserving attempts, seq and failure. Returns the number changed. */
1390
- readonly resume: (projection: string) => Effect.Effect<number, StorageFault>;
1391
- /** Up to limit marks with attempts > 0, stopped first, then by dueAt and params. */
1392
- readonly failed: (projection: string, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
1393
- }
1394
- declare const ProjectionMarks_base: Context.ServiceClass<ProjectionMarks, "@streamsy/core/internal/ProjectionMarks", ProjectionMarksApi>;
1395
- declare class ProjectionMarks extends ProjectionMarks_base {}
1396
- export { CreateError as $, CollectionsEncodingServices as A, ProducerState as At, Writer as B, StreamsFault as Bt, OperationResults as C, ReadNextOptions as Ct, Collections as D, MessageWindow as Dt, StorageCapabilities as E, ChangeSnapshot as Et, ValidCollections as F, StreamLifecycle as Ft, ReadNextResult as G, CreateResult as H, isRetryableFault as Ht, address_d_exports as I, StreamRecord as It, AppendConflict as J, ReadResult as K, Reader as L, DecodeFault as Lt, StateAddress as M, StoredMessage as Mt, StateControl as N, StreamConfig as Nt, CollectionsDecodingServices as O, Offset as Ot, StreamAddress as P, StreamId as Pt, CreateConflictReason as Q, StreamsReader as R, EncodeFault as Rt, OperationResult as S, ProducerOptions as St, ProducerPrecondition as T, CreateOptions as Tt, HeadResult as U, isStreamsFault as Ut, AppendResult as V, TransportFault as Vt, ReadMessage as W, AppendErrorFor as X, AppendError as Y, CreateConflict as Z, Mutation as _, StreamGone as _t, ProjectionMarksApi as a, InvalidForkRequest as at, Mutations as b, AppendCallOptions as bt, CommitHooksApi as c, OffsetMismatch as ct, OwnerRecords as d, ReadError as dt, ForkSourceNotFound as et, OwnerRecordsApi as f, ReadNextError as ft, StorageShape as g, StreamClosed as gt, Storage as h, StreamBusy as ht, ProjectionMarks as i, InvalidEpochSeq as it, CollectionsEvent as j, RecordPatch as jt, CollectionsEncodedEvent as k, ProducerId as kt, commitHookRegistry as l, ProducerGap as lt, CommitBoundaryApi as m, StaleEpoch as mt, PendingMark as n, InvalidAppendRequest as nt, CommitHook as o, InvalidReadRequest as ot, CommitBoundary as p, RemoveError as pt, AppendBaseError as q, ProjectionMarkSummary as r, InvalidCreateRequest as rt, CommitHooks as s, NotSupported as st, MarkFailure as t, HeadError as tt, OWNER_RECORDS_LIST_UNSUPPORTED as u, ProtocolError as ut, MutationApplied as v, StreamNotFound as vt, Operations as w, ReadOptions as wt, Operation as x, AppendOptions as xt, MutationRejected as y, isProtocolError as yt, StreamsWriter as z, StorageFault as zt };
1235
+ export { StreamsFault as $, ReadResult as A, ProducerId as B, StorageOwnerApi as C, HeadResult as D, CreateResult as E, ReadOptions as F, StreamId as G, RecordPatch as H, StartOffset as I, StreamsyOffset as J, StreamLifecycle as K, ChangeSnapshot as L, AppendOptions as M, ProducerOptions as N, ReadMessage as O, ReadNextOptions as P, StorageFault as Q, MessageWindow as R, StorageOwner as S, AppendResult as T, StoredMessage as U, ProducerState as V, StreamConfig as W, EncodeFault as X, DecodeFault as Y, InvalidStreamParams as Z, CollectionsEncodingServices as _, Mutations as a, durable_state_d_exports as b, OperationResults as c, StateAddress as d, TransportFault as et, StreamAddress as f, CollectionsEncodedEvent as g, CollectionsDecodingServices as h, MutationRejected as i, AppendCallOptions as j, ReadNextResult as k, Operations as l, Collections as m, Mutation as n, isStreamsFault as nt, Operation as o, address_d_exports as p, StreamRecord as q, MutationApplied as r, OperationResult as s, StorageShape as t, isRetryableFault as tt, ProducerPrecondition as u, CollectionsEvent as v, StorageCapabilities as w, OwnerId as x, ValidCollections as y, Offset as z };