@streamsy/core 0.8.0 → 0.10.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.
- package/README.md +1 -1
- package/dist/{create-validation-Dwx1OQAN.js → create-validation-DzLxKiux.js} +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +2 -2
- package/dist/{http-CwDadGy6.js → http-wFQusDU7.js} +2 -2
- package/dist/{index-DzptR3sL.d.ts → index-B_o4-vX4.d.ts} +21 -109
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/internal/index.d.ts +1 -1
- package/dist/{layer-VOzdazlb.js → layer-CwD1bD5X.js} +2 -2
- package/dist/{layer-B1JEYOZb.js → layer-DZOWeK0B.js} +2 -2
- package/dist/{program-DPq8FYrT.js → program-B6L8HGca.js} +1 -1
- package/dist/projection-marks-Ca0Q-L9H.d.ts +1184 -0
- package/dist/protocol/index.d.ts +2 -2
- package/dist/protocol/index.js +3 -3
- package/dist/remote/index.d.ts +2 -2
- package/dist/remote/index.js +2 -2
- package/dist/{streamsy-BWX6z980.js → streamsy-HKC10a_V.js} +1 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +3 -3
- package/package.json +4 -4
- package/dist/projection-marks-OtKtjFLH.d.ts +0 -3024
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import { Context, Data, Effect, Option, PubSub, Schema, Scope, Stream } from "effect";
|
|
2
|
+
import { SqlError } from "effect/sql";
|
|
3
|
+
declare const StorageFault_base: Schema.Class<StorageFault, Schema.TaggedStruct<"StorageFault", {
|
|
4
|
+
readonly operation: Schema.String;
|
|
5
|
+
readonly message: Schema.String;
|
|
6
|
+
readonly retryable: Schema.Boolean;
|
|
7
|
+
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
8
|
+
}>, import("effect/Cause").YieldableError>;
|
|
9
|
+
declare class StorageFault extends StorageFault_base {}
|
|
10
|
+
declare const EncodeFault_base: Schema.Class<EncodeFault, Schema.TaggedStruct<"EncodeFault", {
|
|
11
|
+
readonly message: Schema.String;
|
|
12
|
+
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
13
|
+
}>, import("effect/Cause").YieldableError>;
|
|
14
|
+
declare class EncodeFault extends EncodeFault_base {}
|
|
15
|
+
declare const DecodeFault_base: Schema.Class<DecodeFault, Schema.TaggedStruct<"DecodeFault", {
|
|
16
|
+
readonly message: Schema.String;
|
|
17
|
+
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
18
|
+
}>, import("effect/Cause").YieldableError>;
|
|
19
|
+
declare class DecodeFault extends DecodeFault_base {}
|
|
20
|
+
declare const TransportFault_base: Schema.Class<TransportFault, Schema.TaggedStruct<"TransportFault", {
|
|
21
|
+
readonly operation: Schema.String;
|
|
22
|
+
readonly reason: Schema.Literals<readonly ["request", "response", "decode", "configuration"]>;
|
|
23
|
+
/** HTTP status of the response, when available. */
|
|
24
|
+
readonly status: Schema.optionalKey<Schema.Int>;
|
|
25
|
+
readonly message: Schema.String;
|
|
26
|
+
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
27
|
+
}>, import("effect/Cause").YieldableError>;
|
|
28
|
+
/** Failures of the remote boundary; protocol rejections have their own typed errors. */
|
|
29
|
+
declare class TransportFault extends TransportFault_base {
|
|
30
|
+
/** Failed requests, 429s and 5xx responses can succeed later. */
|
|
31
|
+
get retryable(): boolean;
|
|
32
|
+
}
|
|
33
|
+
declare const StreamsFault: Schema.Union<readonly [typeof StorageFault, typeof TransportFault]>;
|
|
34
|
+
type StreamsFault = typeof StreamsFault.Type;
|
|
35
|
+
/** A storage or transport failure, as opposed to a protocol rejection. */
|
|
36
|
+
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;
|
|
39
|
+
declare const StreamId: Schema.brand<Schema.String, "StreamId">;
|
|
40
|
+
declare const Offset: Schema.brand<Schema.String, "Offset">;
|
|
41
|
+
declare const ProducerId: Schema.brand<Schema.String, "ProducerId">;
|
|
42
|
+
declare const StreamConfig: Schema.Struct<{
|
|
43
|
+
readonly contentType: Schema.String;
|
|
44
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
45
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
46
|
+
readonly createdAt: Schema.Finite;
|
|
47
|
+
}>;
|
|
48
|
+
declare const StreamLifecycle: Schema.Struct<{
|
|
49
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
50
|
+
readonly closed: Schema.Boolean;
|
|
51
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
52
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
53
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
54
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
55
|
+
readonly softDeleted: Schema.Boolean;
|
|
56
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
57
|
+
}>;
|
|
58
|
+
declare const StreamRecord: Schema.Struct<{
|
|
59
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
60
|
+
readonly config: Schema.Struct<{
|
|
61
|
+
readonly contentType: Schema.String;
|
|
62
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
63
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
64
|
+
readonly createdAt: Schema.Finite;
|
|
65
|
+
}>;
|
|
66
|
+
readonly lifecycle: Schema.Struct<{
|
|
67
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
68
|
+
readonly closed: Schema.Boolean;
|
|
69
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
70
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
71
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
72
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
73
|
+
readonly softDeleted: Schema.Boolean;
|
|
74
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
75
|
+
}>;
|
|
76
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
77
|
+
}>;
|
|
78
|
+
declare const StoredMessage: Schema.Struct<{
|
|
79
|
+
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
80
|
+
readonly timestamp: Schema.Finite;
|
|
81
|
+
readonly data: Schema.Uint8Array;
|
|
82
|
+
}>;
|
|
83
|
+
declare const ProducerState: Schema.Struct<{
|
|
84
|
+
readonly epoch: Schema.Finite;
|
|
85
|
+
readonly lastSeq: Schema.Finite;
|
|
86
|
+
}>;
|
|
87
|
+
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">>;
|
|
90
|
+
readonly limit: Schema.optionalKey<Schema.Finite>;
|
|
91
|
+
}>;
|
|
92
|
+
declare const ChangeSnapshot: Schema.Struct<{
|
|
93
|
+
readonly present: Schema.Boolean;
|
|
94
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
95
|
+
readonly closed: Schema.Boolean;
|
|
96
|
+
readonly softDeleted: Schema.Boolean;
|
|
97
|
+
}>;
|
|
98
|
+
type StreamId = typeof StreamId.Type;
|
|
99
|
+
type Offset = typeof Offset.Type;
|
|
100
|
+
type ProducerId = typeof ProducerId.Type;
|
|
101
|
+
interface StreamConfig extends Schema.Schema.Type<typeof StreamConfig> {}
|
|
102
|
+
interface StreamLifecycle extends Schema.Schema.Type<typeof StreamLifecycle> {}
|
|
103
|
+
interface StreamRecord extends Schema.Schema.Type<typeof StreamRecord> {}
|
|
104
|
+
interface StoredMessage extends Schema.Schema.Type<typeof StoredMessage> {}
|
|
105
|
+
interface ProducerState extends Schema.Schema.Type<typeof ProducerState> {}
|
|
106
|
+
interface MessageWindow extends Schema.Schema.Type<typeof MessageWindow> {}
|
|
107
|
+
interface ChangeSnapshot extends Schema.Schema.Type<typeof ChangeSnapshot> {}
|
|
108
|
+
declare const RecordPatch: Schema.Struct<{
|
|
109
|
+
readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
110
|
+
readonly config: Schema.optionalKey<Schema.Struct<{
|
|
111
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
112
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
113
|
+
}>>;
|
|
114
|
+
readonly lifecycle: Schema.optionalKey<Schema.Struct<{
|
|
115
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
116
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
117
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
118
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
119
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
120
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
121
|
+
readonly closed: Schema.optionalKey<Schema.Boolean>;
|
|
122
|
+
readonly softDeleted: Schema.optionalKey<Schema.Boolean>;
|
|
123
|
+
}>>;
|
|
124
|
+
readonly clear: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["ttlSeconds", "expiresAt", "expiresAtMs", "lastSeq"]>>>;
|
|
125
|
+
}>;
|
|
126
|
+
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
|
+
}
|
|
138
|
+
interface ProducerOptions {
|
|
139
|
+
readonly producerId: string;
|
|
140
|
+
readonly producerEpoch: number;
|
|
141
|
+
readonly producerSeq: number;
|
|
142
|
+
}
|
|
143
|
+
interface AppendOptions {
|
|
144
|
+
readonly data: Uint8Array;
|
|
145
|
+
readonly contentType: string;
|
|
146
|
+
readonly seq?: string;
|
|
147
|
+
readonly producer?: ProducerOptions;
|
|
148
|
+
readonly close?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Optimistic-concurrency precondition: append only if the stream's tail
|
|
151
|
+
* offset still equals this offset. On mismatch the append fails with a
|
|
152
|
+
* `conflict`/`expected-offset` result carrying the actual tail, and no
|
|
153
|
+
* state (messages, close flag, producer state) is changed. `ZERO_OFFSET`
|
|
154
|
+
* means "append only if the stream is still empty". Streamsy extension to
|
|
155
|
+
* the Durable Streams protocol.
|
|
156
|
+
*/
|
|
157
|
+
readonly expectedOffset?: string;
|
|
158
|
+
}
|
|
159
|
+
/** Append options for a typed address. The address supplies the body and its content type. */
|
|
160
|
+
type AppendCallOptions = Omit<AppendOptions, "data" | "contentType">;
|
|
161
|
+
interface ReadOptions {
|
|
162
|
+
offset?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Options for one transport-neutral read/wait operation. `readNext` returns
|
|
166
|
+
* available messages immediately or waits once for a stream change, timeout,
|
|
167
|
+
* or cancellation. HTTP live modes decide whether to invoke it once or repeat
|
|
168
|
+
* it; they are intentionally not part of this protocol contract.
|
|
169
|
+
*/
|
|
170
|
+
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
|
+
readonly message: Schema.String;
|
|
205
|
+
}>, import("effect/Cause").YieldableError>;
|
|
206
|
+
declare class AppendConflict extends AppendConflict_base {}
|
|
207
|
+
declare const StreamBusy_base: Schema.Class<StreamBusy, Schema.TaggedStruct<"StreamBusy", {
|
|
208
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
209
|
+
}>, import("effect/Cause").YieldableError>;
|
|
210
|
+
declare class StreamBusy extends StreamBusy_base {
|
|
211
|
+
get message(): string;
|
|
212
|
+
}
|
|
213
|
+
declare const StaleEpoch_base: Schema.Class<StaleEpoch, Schema.TaggedStruct<"StaleEpoch", {
|
|
214
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
215
|
+
readonly currentEpoch: Schema.Finite;
|
|
216
|
+
}>, import("effect/Cause").YieldableError>;
|
|
217
|
+
declare class StaleEpoch extends StaleEpoch_base {
|
|
218
|
+
get message(): string;
|
|
219
|
+
}
|
|
220
|
+
declare const ProducerGap_base: Schema.Class<ProducerGap, Schema.TaggedStruct<"ProducerGap", {
|
|
221
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
222
|
+
readonly expectedSeq: Schema.Finite;
|
|
223
|
+
readonly receivedSeq: Schema.Finite;
|
|
224
|
+
}>, import("effect/Cause").YieldableError>;
|
|
225
|
+
declare class ProducerGap extends ProducerGap_base {
|
|
226
|
+
get message(): string;
|
|
227
|
+
}
|
|
228
|
+
declare const InvalidEpochSeq_base: Schema.Class<InvalidEpochSeq, Schema.TaggedStruct<"InvalidEpochSeq", {
|
|
229
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
230
|
+
}>, import("effect/Cause").YieldableError>;
|
|
231
|
+
declare class InvalidEpochSeq extends InvalidEpochSeq_base {
|
|
232
|
+
get message(): string;
|
|
233
|
+
}
|
|
234
|
+
declare const InvalidAppendRequest_base: Schema.Class<InvalidAppendRequest, Schema.TaggedStruct<"InvalidAppendRequest", {
|
|
235
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
236
|
+
readonly message: Schema.String;
|
|
237
|
+
}>, import("effect/Cause").YieldableError>;
|
|
238
|
+
declare class InvalidAppendRequest extends InvalidAppendRequest_base {}
|
|
239
|
+
declare const InvalidCreateRequest_base: Schema.Class<InvalidCreateRequest, Schema.TaggedStruct<"InvalidCreateRequest", {
|
|
240
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
241
|
+
readonly message: Schema.String;
|
|
242
|
+
}>, import("effect/Cause").YieldableError>;
|
|
243
|
+
declare class InvalidCreateRequest extends InvalidCreateRequest_base {}
|
|
244
|
+
declare const CreateConflict_base: Schema.Class<CreateConflict, Schema.TaggedStruct<"CreateConflict", {
|
|
245
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
246
|
+
readonly reason: Schema.optionalKey<Schema.Literals<readonly ["config-mismatch", "soft-deleted", "fork-content-type", "fork-source-soft-deleted"]>>;
|
|
247
|
+
readonly message: Schema.String;
|
|
248
|
+
}>, import("effect/Cause").YieldableError>;
|
|
249
|
+
declare class CreateConflict extends CreateConflict_base {}
|
|
250
|
+
declare const ForkSourceNotFound_base: Schema.Class<ForkSourceNotFound, Schema.TaggedStruct<"ForkSourceNotFound", {
|
|
251
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
252
|
+
readonly source: Schema.brand<Schema.String, "StreamId">;
|
|
253
|
+
}>, import("effect/Cause").YieldableError>;
|
|
254
|
+
declare class ForkSourceNotFound extends ForkSourceNotFound_base {
|
|
255
|
+
get message(): string;
|
|
256
|
+
}
|
|
257
|
+
declare const InvalidForkRequest_base: Schema.Class<InvalidForkRequest, Schema.TaggedStruct<"InvalidForkRequest", {
|
|
258
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
259
|
+
readonly message: Schema.String;
|
|
260
|
+
}>, import("effect/Cause").YieldableError>;
|
|
261
|
+
declare class InvalidForkRequest extends InvalidForkRequest_base {}
|
|
262
|
+
declare const NotSupported_base: Schema.Class<NotSupported, Schema.TaggedStruct<"NotSupported", {
|
|
263
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
264
|
+
readonly feature: Schema.String;
|
|
265
|
+
}>, import("effect/Cause").YieldableError>;
|
|
266
|
+
declare class NotSupported extends NotSupported_base {
|
|
267
|
+
get message(): string;
|
|
268
|
+
}
|
|
269
|
+
type CreateConflictReason = NonNullable<CreateConflict["reason"]>;
|
|
270
|
+
type HeadError = StreamNotFound | StreamGone;
|
|
271
|
+
declare const InvalidReadRequest_base: Schema.Class<InvalidReadRequest, Schema.TaggedStruct<"InvalidReadRequest", {
|
|
272
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
273
|
+
readonly message: Schema.String;
|
|
274
|
+
}>, import("effect/Cause").YieldableError>;
|
|
275
|
+
declare class InvalidReadRequest extends InvalidReadRequest_base {}
|
|
276
|
+
type ReadError = StreamNotFound | StreamGone | InvalidReadRequest;
|
|
277
|
+
type ReadNextError = ReadError | NotSupported;
|
|
278
|
+
type CreateError = CreateConflict | InvalidCreateRequest | ForkSourceNotFound | InvalidForkRequest | NotSupported;
|
|
279
|
+
/**
|
|
280
|
+
* Append rejections that any call can get, whatever its options. The memory and
|
|
281
|
+
* storage hosts never answer `NotSupported`; the remote client does when the server
|
|
282
|
+
* or its own capabilities refuse a feature.
|
|
283
|
+
*/
|
|
284
|
+
type AppendBaseError = StreamNotFound | StreamGone | StreamClosed | StreamBusy | AppendConflict | NotSupported;
|
|
285
|
+
type AppendError = AppendBaseError | InvalidAppendRequest | OffsetMismatch | StaleEpoch | ProducerGap | InvalidEpochSeq;
|
|
286
|
+
/**
|
|
287
|
+
* The append rejections that call options `O` make possible. `OffsetMismatch`
|
|
288
|
+
* needs `expectedOffset`, and the producer rejections need `producer`. An option
|
|
289
|
+
* that may be set counts as set.
|
|
290
|
+
*/
|
|
291
|
+
type AppendErrorFor<O> = AppendBaseError | (true extends MaySet<O, "expectedOffset"> ? OffsetMismatch : never) | (true extends MaySet<O, "producer"> ? StaleEpoch | ProducerGap : never);
|
|
292
|
+
/** Whether options `O` may hold a value for `K`. A union holds it if any member may. */
|
|
293
|
+
type MaySet<O, K extends PropertyKey> = O extends unknown ? K extends keyof O ? [Exclude<O[K], undefined>] extends [never] ? false : true : false : never;
|
|
294
|
+
type RemoveError = StreamNotFound | StreamGone | StreamBusy;
|
|
295
|
+
type ProtocolError = HeadError | ReadNextError | CreateError | AppendError | RemoveError;
|
|
296
|
+
/** The HTTP edge answers every protocol rejection through one mapper, so it needs one guard. */
|
|
297
|
+
declare const isProtocolError: (error: {
|
|
298
|
+
readonly _tag: string;
|
|
299
|
+
}) => error is ProtocolError;
|
|
300
|
+
/** Payload-only messages exposed by the public protocol; storage owns offsets and timestamps. */
|
|
301
|
+
interface ReadMessage {
|
|
302
|
+
readonly data: Uint8Array;
|
|
303
|
+
}
|
|
304
|
+
type CreateResult = {
|
|
305
|
+
readonly _tag: "Created";
|
|
306
|
+
readonly nextOffset: string;
|
|
307
|
+
readonly contentType: string;
|
|
308
|
+
readonly closed: boolean;
|
|
309
|
+
} | {
|
|
310
|
+
readonly _tag: "Exists";
|
|
311
|
+
readonly nextOffset: string;
|
|
312
|
+
readonly contentType: string;
|
|
313
|
+
readonly closed: boolean;
|
|
314
|
+
};
|
|
315
|
+
type AppendResult = {
|
|
316
|
+
readonly _tag: "Appended";
|
|
317
|
+
/** Tail after this write; an after-exclusive read cursor. */ readonly offset: string;
|
|
318
|
+
readonly producerEpoch?: number;
|
|
319
|
+
readonly producerSeq?: number;
|
|
320
|
+
readonly closed: boolean;
|
|
321
|
+
} | {
|
|
322
|
+
readonly _tag: "Duplicate";
|
|
323
|
+
/** Current tail at acknowledgement, at or after the original write. */ readonly offset: string;
|
|
324
|
+
readonly producerEpoch: number;
|
|
325
|
+
readonly producerSeq: number;
|
|
326
|
+
readonly closed: boolean;
|
|
327
|
+
};
|
|
328
|
+
/** Constructors and matchers for the protocol results above. */
|
|
329
|
+
declare const CreateResult: Data.TaggedEnum.Constructor<CreateResult>;
|
|
330
|
+
declare const AppendResult: Data.TaggedEnum.Constructor<AppendResult>;
|
|
331
|
+
interface ReadResult {
|
|
332
|
+
readonly contentType: string;
|
|
333
|
+
readonly messages: ReadonlyArray<ReadMessage>;
|
|
334
|
+
readonly nextOffset: string;
|
|
335
|
+
readonly upToDate: boolean;
|
|
336
|
+
readonly closed: boolean;
|
|
337
|
+
}
|
|
338
|
+
interface ReadNextResult extends ReadResult {
|
|
339
|
+
readonly cursor: string;
|
|
340
|
+
readonly timedOut: boolean;
|
|
341
|
+
}
|
|
342
|
+
interface HeadResult {
|
|
343
|
+
readonly contentType: string;
|
|
344
|
+
readonly nextOffset: string;
|
|
345
|
+
readonly ttlSeconds?: number;
|
|
346
|
+
readonly expiresAt?: string;
|
|
347
|
+
readonly closed: boolean;
|
|
348
|
+
}
|
|
349
|
+
interface Reader<E = StorageFault> {
|
|
350
|
+
readonly head: (id: StreamId) => Effect.Effect<HeadResult, HeadError | E>;
|
|
351
|
+
readonly read: (id: StreamId, options?: ReadOptions) => Effect.Effect<ReadResult, ReadError | E>;
|
|
352
|
+
readonly readNext: (id: StreamId, options: ReadNextOptions) => Effect.Effect<ReadNextResult, ReadNextError | E>;
|
|
353
|
+
}
|
|
354
|
+
interface Writer<E = StorageFault> {
|
|
355
|
+
readonly create: (id: StreamId, options?: CreateOptions) => Effect.Effect<CreateResult, CreateError | E>;
|
|
356
|
+
readonly fork: (id: StreamId, source: StreamId, options?: Omit<CreateOptions, "forkedFrom">) => Effect.Effect<CreateResult, CreateError | E>;
|
|
357
|
+
readonly append: (id: StreamId, options: AppendOptions) => Effect.Effect<AppendResult, AppendError | E>;
|
|
358
|
+
readonly remove: (id: StreamId) => Effect.Effect<void, RemoveError | E>;
|
|
359
|
+
}
|
|
360
|
+
declare const StreamsReader_base: Context.ServiceClass<StreamsReader, "@streamsy/core/StreamsReader", Reader<StorageFault | TransportFault>>;
|
|
361
|
+
declare class StreamsReader extends StreamsReader_base {}
|
|
362
|
+
declare const StreamsWriter_base: Context.ServiceClass<StreamsWriter, "@streamsy/core/StreamsWriter", Writer<StorageFault | TransportFault>>;
|
|
363
|
+
declare class StreamsWriter extends StreamsWriter_base {}
|
|
364
|
+
declare const StorageCapabilities: Schema.Struct<{
|
|
365
|
+
readonly fork: Schema.Literals<readonly ["none", "copy", "chain"]>;
|
|
366
|
+
readonly atomicScope: Schema.Literals<readonly ["stream", "store"]>;
|
|
367
|
+
readonly wake: Schema.Literals<readonly ["poll", "push"]>;
|
|
368
|
+
readonly expiryIndex: Schema.Literals<readonly ["lazy", "indexed"]>;
|
|
369
|
+
}>;
|
|
370
|
+
interface StorageCapabilities extends Schema.Schema.Type<typeof StorageCapabilities> {}
|
|
371
|
+
declare const ProducerPrecondition: Schema.Struct<{
|
|
372
|
+
readonly producerId: Schema.brand<Schema.String, "ProducerId">;
|
|
373
|
+
readonly expected: Schema.Option<Schema.Struct<{
|
|
374
|
+
readonly epoch: Schema.Finite;
|
|
375
|
+
readonly lastSeq: Schema.Finite;
|
|
376
|
+
}>>;
|
|
377
|
+
readonly next: Schema.Struct<{
|
|
378
|
+
readonly epoch: Schema.Finite;
|
|
379
|
+
readonly lastSeq: Schema.Finite;
|
|
380
|
+
}>;
|
|
381
|
+
}>;
|
|
382
|
+
declare const Operation: Schema.Union<readonly [Schema.TaggedStruct<"Create", {
|
|
383
|
+
readonly record: Schema.Struct<{
|
|
384
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
385
|
+
readonly config: Schema.Struct<{
|
|
386
|
+
readonly contentType: Schema.String;
|
|
387
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
388
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
389
|
+
readonly createdAt: Schema.Finite;
|
|
390
|
+
}>;
|
|
391
|
+
readonly lifecycle: Schema.Struct<{
|
|
392
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
393
|
+
readonly closed: Schema.Boolean;
|
|
394
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
395
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
396
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
397
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
398
|
+
readonly softDeleted: Schema.Boolean;
|
|
399
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
400
|
+
}>;
|
|
401
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
402
|
+
}>;
|
|
403
|
+
readonly initialMessages: Schema.$Array<Schema.Struct<{
|
|
404
|
+
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
405
|
+
readonly timestamp: Schema.Finite;
|
|
406
|
+
readonly data: Schema.Uint8Array;
|
|
407
|
+
}>>;
|
|
408
|
+
readonly forkSource: Schema.optionalKey<Schema.Struct<{
|
|
409
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
410
|
+
readonly liveAtOffset: Schema.brand<Schema.String, "Offset">;
|
|
411
|
+
}>>;
|
|
412
|
+
}>, Schema.TaggedStruct<"Append", {
|
|
413
|
+
readonly streamId: Schema.brand<Schema.String, "StreamId">;
|
|
414
|
+
readonly messages: Schema.$Array<Schema.Struct<{
|
|
415
|
+
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
416
|
+
readonly timestamp: Schema.Finite;
|
|
417
|
+
readonly data: Schema.Uint8Array;
|
|
418
|
+
}>>;
|
|
419
|
+
readonly patch: Schema.Struct<{
|
|
420
|
+
readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
421
|
+
readonly config: Schema.optionalKey<Schema.Struct<{
|
|
422
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
423
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
424
|
+
}>>;
|
|
425
|
+
readonly lifecycle: Schema.optionalKey<Schema.Struct<{
|
|
426
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
427
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
428
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
429
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
430
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
431
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
432
|
+
readonly closed: Schema.optionalKey<Schema.Boolean>;
|
|
433
|
+
readonly softDeleted: Schema.optionalKey<Schema.Boolean>;
|
|
434
|
+
}>>;
|
|
435
|
+
readonly clear: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["ttlSeconds", "expiresAt", "expiresAtMs", "lastSeq"]>>>;
|
|
436
|
+
}>;
|
|
437
|
+
readonly expectedOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
438
|
+
readonly expectedClosed: Schema.optionalKey<Schema.Boolean>;
|
|
439
|
+
readonly producer: Schema.optionalKey<Schema.Struct<{
|
|
440
|
+
readonly producerId: Schema.brand<Schema.String, "ProducerId">;
|
|
441
|
+
readonly expected: Schema.Option<Schema.Struct<{
|
|
442
|
+
readonly epoch: Schema.Finite;
|
|
443
|
+
readonly lastSeq: Schema.Finite;
|
|
444
|
+
}>>;
|
|
445
|
+
readonly next: Schema.Struct<{
|
|
446
|
+
readonly epoch: Schema.Finite;
|
|
447
|
+
readonly lastSeq: Schema.Finite;
|
|
448
|
+
}>;
|
|
449
|
+
}>>;
|
|
450
|
+
}>, Schema.TaggedStruct<"Delete", {
|
|
451
|
+
readonly streamId: Schema.brand<Schema.String, "StreamId">;
|
|
452
|
+
readonly reason: Schema.Literals<readonly ["delete", "expiry"]>;
|
|
453
|
+
readonly expectedExpiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
454
|
+
}>]>;
|
|
455
|
+
declare const Mutation: Schema.Struct<{
|
|
456
|
+
readonly operations: Schema.NonEmptyArray<Schema.Union<readonly [Schema.TaggedStruct<"Create", {
|
|
457
|
+
readonly record: Schema.Struct<{
|
|
458
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
459
|
+
readonly config: Schema.Struct<{
|
|
460
|
+
readonly contentType: Schema.String;
|
|
461
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
462
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
463
|
+
readonly createdAt: Schema.Finite;
|
|
464
|
+
}>;
|
|
465
|
+
readonly lifecycle: Schema.Struct<{
|
|
466
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
467
|
+
readonly closed: Schema.Boolean;
|
|
468
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
469
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
470
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
471
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
472
|
+
readonly softDeleted: Schema.Boolean;
|
|
473
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
474
|
+
}>;
|
|
475
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
476
|
+
}>;
|
|
477
|
+
readonly initialMessages: Schema.$Array<Schema.Struct<{
|
|
478
|
+
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
479
|
+
readonly timestamp: Schema.Finite;
|
|
480
|
+
readonly data: Schema.Uint8Array;
|
|
481
|
+
}>>;
|
|
482
|
+
readonly forkSource: Schema.optionalKey<Schema.Struct<{
|
|
483
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
484
|
+
readonly liveAtOffset: Schema.brand<Schema.String, "Offset">;
|
|
485
|
+
}>>;
|
|
486
|
+
}>, Schema.TaggedStruct<"Append", {
|
|
487
|
+
readonly streamId: Schema.brand<Schema.String, "StreamId">;
|
|
488
|
+
readonly messages: Schema.$Array<Schema.Struct<{
|
|
489
|
+
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
490
|
+
readonly timestamp: Schema.Finite;
|
|
491
|
+
readonly data: Schema.Uint8Array;
|
|
492
|
+
}>>;
|
|
493
|
+
readonly patch: Schema.Struct<{
|
|
494
|
+
readonly currentOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
495
|
+
readonly config: Schema.optionalKey<Schema.Struct<{
|
|
496
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
497
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
498
|
+
}>>;
|
|
499
|
+
readonly lifecycle: Schema.optionalKey<Schema.Struct<{
|
|
500
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
501
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
502
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
503
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
504
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
505
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
506
|
+
readonly closed: Schema.optionalKey<Schema.Boolean>;
|
|
507
|
+
readonly softDeleted: Schema.optionalKey<Schema.Boolean>;
|
|
508
|
+
}>>;
|
|
509
|
+
readonly clear: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["ttlSeconds", "expiresAt", "expiresAtMs", "lastSeq"]>>>;
|
|
510
|
+
}>;
|
|
511
|
+
readonly expectedOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
512
|
+
readonly expectedClosed: Schema.optionalKey<Schema.Boolean>;
|
|
513
|
+
readonly producer: Schema.optionalKey<Schema.Struct<{
|
|
514
|
+
readonly producerId: Schema.brand<Schema.String, "ProducerId">;
|
|
515
|
+
readonly expected: Schema.Option<Schema.Struct<{
|
|
516
|
+
readonly epoch: Schema.Finite;
|
|
517
|
+
readonly lastSeq: Schema.Finite;
|
|
518
|
+
}>>;
|
|
519
|
+
readonly next: Schema.Struct<{
|
|
520
|
+
readonly epoch: Schema.Finite;
|
|
521
|
+
readonly lastSeq: Schema.Finite;
|
|
522
|
+
}>;
|
|
523
|
+
}>>;
|
|
524
|
+
}>, Schema.TaggedStruct<"Delete", {
|
|
525
|
+
readonly streamId: Schema.brand<Schema.String, "StreamId">;
|
|
526
|
+
readonly reason: Schema.Literals<readonly ["delete", "expiry"]>;
|
|
527
|
+
readonly expectedExpiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
528
|
+
}>]>>;
|
|
529
|
+
}>;
|
|
530
|
+
declare const OperationResult: Schema.Union<readonly [Schema.TaggedStruct<"Created", {
|
|
531
|
+
readonly record: Schema.Struct<{
|
|
532
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
533
|
+
readonly config: Schema.Struct<{
|
|
534
|
+
readonly contentType: Schema.String;
|
|
535
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
536
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
537
|
+
readonly createdAt: Schema.Finite;
|
|
538
|
+
}>;
|
|
539
|
+
readonly lifecycle: Schema.Struct<{
|
|
540
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
541
|
+
readonly closed: Schema.Boolean;
|
|
542
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
543
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
544
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
545
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
546
|
+
readonly softDeleted: Schema.Boolean;
|
|
547
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
548
|
+
}>;
|
|
549
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
550
|
+
}>;
|
|
551
|
+
}>, Schema.TaggedStruct<"Appended", {
|
|
552
|
+
readonly record: Schema.Struct<{
|
|
553
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
554
|
+
readonly config: Schema.Struct<{
|
|
555
|
+
readonly contentType: Schema.String;
|
|
556
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
557
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
558
|
+
readonly createdAt: Schema.Finite;
|
|
559
|
+
}>;
|
|
560
|
+
readonly lifecycle: Schema.Struct<{
|
|
561
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
562
|
+
readonly closed: Schema.Boolean;
|
|
563
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
564
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
565
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
566
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
567
|
+
readonly softDeleted: Schema.Boolean;
|
|
568
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
569
|
+
}>;
|
|
570
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
571
|
+
}>;
|
|
572
|
+
}>, Schema.TaggedStruct<"Purged", {
|
|
573
|
+
readonly record: Schema.Struct<{
|
|
574
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
575
|
+
readonly config: Schema.Struct<{
|
|
576
|
+
readonly contentType: Schema.String;
|
|
577
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
578
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
579
|
+
readonly createdAt: Schema.Finite;
|
|
580
|
+
}>;
|
|
581
|
+
readonly lifecycle: Schema.Struct<{
|
|
582
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
583
|
+
readonly closed: Schema.Boolean;
|
|
584
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
585
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
586
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
587
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
588
|
+
readonly softDeleted: Schema.Boolean;
|
|
589
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
590
|
+
}>;
|
|
591
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
592
|
+
}>;
|
|
593
|
+
}>, Schema.TaggedStruct<"SoftDeleted", {
|
|
594
|
+
readonly record: Schema.Struct<{
|
|
595
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
596
|
+
readonly config: Schema.Struct<{
|
|
597
|
+
readonly contentType: Schema.String;
|
|
598
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
599
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
600
|
+
readonly createdAt: Schema.Finite;
|
|
601
|
+
}>;
|
|
602
|
+
readonly lifecycle: Schema.Struct<{
|
|
603
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
604
|
+
readonly closed: Schema.Boolean;
|
|
605
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
606
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
607
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
608
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
609
|
+
readonly softDeleted: Schema.Boolean;
|
|
610
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
611
|
+
}>;
|
|
612
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
613
|
+
}>;
|
|
614
|
+
}>]>;
|
|
615
|
+
/** The success channel of a storage mutation contains only applied operation results. */
|
|
616
|
+
declare const MutationApplied: Schema.TaggedStruct<"Applied", {
|
|
617
|
+
readonly results: Schema.NonEmptyArray<Schema.Union<readonly [Schema.TaggedStruct<"Created", {
|
|
618
|
+
readonly record: Schema.Struct<{
|
|
619
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
620
|
+
readonly config: Schema.Struct<{
|
|
621
|
+
readonly contentType: Schema.String;
|
|
622
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
623
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
624
|
+
readonly createdAt: Schema.Finite;
|
|
625
|
+
}>;
|
|
626
|
+
readonly lifecycle: Schema.Struct<{
|
|
627
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
628
|
+
readonly closed: Schema.Boolean;
|
|
629
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
630
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
631
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
632
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
633
|
+
readonly softDeleted: Schema.Boolean;
|
|
634
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
635
|
+
}>;
|
|
636
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
637
|
+
}>;
|
|
638
|
+
}>, Schema.TaggedStruct<"Appended", {
|
|
639
|
+
readonly record: Schema.Struct<{
|
|
640
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
641
|
+
readonly config: Schema.Struct<{
|
|
642
|
+
readonly contentType: Schema.String;
|
|
643
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
644
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
645
|
+
readonly createdAt: Schema.Finite;
|
|
646
|
+
}>;
|
|
647
|
+
readonly lifecycle: Schema.Struct<{
|
|
648
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
649
|
+
readonly closed: Schema.Boolean;
|
|
650
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
651
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
652
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
653
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
654
|
+
readonly softDeleted: Schema.Boolean;
|
|
655
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
656
|
+
}>;
|
|
657
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
658
|
+
}>;
|
|
659
|
+
}>, Schema.TaggedStruct<"Purged", {
|
|
660
|
+
readonly record: Schema.Struct<{
|
|
661
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
662
|
+
readonly config: Schema.Struct<{
|
|
663
|
+
readonly contentType: Schema.String;
|
|
664
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
665
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
666
|
+
readonly createdAt: Schema.Finite;
|
|
667
|
+
}>;
|
|
668
|
+
readonly lifecycle: Schema.Struct<{
|
|
669
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
670
|
+
readonly closed: Schema.Boolean;
|
|
671
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
672
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
673
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
674
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
675
|
+
readonly softDeleted: Schema.Boolean;
|
|
676
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
677
|
+
}>;
|
|
678
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
679
|
+
}>;
|
|
680
|
+
}>, Schema.TaggedStruct<"SoftDeleted", {
|
|
681
|
+
readonly record: Schema.Struct<{
|
|
682
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
683
|
+
readonly config: Schema.Struct<{
|
|
684
|
+
readonly contentType: Schema.String;
|
|
685
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
686
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
687
|
+
readonly createdAt: Schema.Finite;
|
|
688
|
+
}>;
|
|
689
|
+
readonly lifecycle: Schema.Struct<{
|
|
690
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
691
|
+
readonly closed: Schema.Boolean;
|
|
692
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
693
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
694
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
695
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
696
|
+
readonly softDeleted: Schema.Boolean;
|
|
697
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
698
|
+
}>;
|
|
699
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
700
|
+
}>;
|
|
701
|
+
}>]>>;
|
|
702
|
+
}>;
|
|
703
|
+
declare const MutationRejected_base: Schema.Class<MutationRejected, Schema.TaggedStruct<"MutationRejected", {
|
|
704
|
+
readonly index: Schema.Finite;
|
|
705
|
+
readonly reason: Schema.Literals<readonly ["offset", "closed", "producer", "exists", "not-found", "gone", "fork-source-gone", "expiry-mismatch"]>;
|
|
706
|
+
readonly record: Schema.Option<Schema.Struct<{
|
|
707
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
708
|
+
readonly config: Schema.Struct<{
|
|
709
|
+
readonly contentType: Schema.String;
|
|
710
|
+
readonly ttlSeconds: Schema.optionalKey<Schema.Finite>;
|
|
711
|
+
readonly expiresAt: Schema.optionalKey<Schema.String>;
|
|
712
|
+
readonly createdAt: Schema.Finite;
|
|
713
|
+
}>;
|
|
714
|
+
readonly lifecycle: Schema.Struct<{
|
|
715
|
+
readonly lastSeq: Schema.optionalKey<Schema.String>;
|
|
716
|
+
readonly closed: Schema.Boolean;
|
|
717
|
+
readonly closedAt: Schema.optionalKey<Schema.Finite>;
|
|
718
|
+
readonly forkedFrom: Schema.optionalKey<Schema.brand<Schema.String, "StreamId">>;
|
|
719
|
+
readonly forkOffset: Schema.optionalKey<Schema.brand<Schema.String, "Offset">>;
|
|
720
|
+
readonly forkSubOffset: Schema.optionalKey<Schema.Finite>;
|
|
721
|
+
readonly softDeleted: Schema.Boolean;
|
|
722
|
+
readonly expiresAtMs: Schema.optionalKey<Schema.Finite>;
|
|
723
|
+
}>;
|
|
724
|
+
readonly currentOffset: Schema.brand<Schema.String, "Offset">;
|
|
725
|
+
}>>;
|
|
726
|
+
}>, import("effect/Cause").YieldableError>;
|
|
727
|
+
declare class MutationRejected extends MutationRejected_base {}
|
|
728
|
+
type ProducerPrecondition = typeof ProducerPrecondition.Type;
|
|
729
|
+
type Operation = typeof Operation.Type;
|
|
730
|
+
type Mutation = typeof Mutation.Type;
|
|
731
|
+
type OperationResult = typeof OperationResult.Type;
|
|
732
|
+
type MutationApplied = typeof MutationApplied.Type;
|
|
733
|
+
/**
|
|
734
|
+
* Constructors and matchers for the storage values above. They build plain
|
|
735
|
+
* objects and do not validate; storage decodes at its own boundary.
|
|
736
|
+
*/
|
|
737
|
+
declare const Operations: Data.TaggedEnum.Constructor<{
|
|
738
|
+
readonly _tag: "Create";
|
|
739
|
+
readonly record: {
|
|
740
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
741
|
+
readonly config: {
|
|
742
|
+
readonly contentType: string;
|
|
743
|
+
readonly ttlSeconds?: number | undefined;
|
|
744
|
+
readonly expiresAt?: string | undefined;
|
|
745
|
+
readonly createdAt: number;
|
|
746
|
+
};
|
|
747
|
+
readonly lifecycle: {
|
|
748
|
+
readonly lastSeq?: string | undefined;
|
|
749
|
+
readonly closed: boolean;
|
|
750
|
+
readonly closedAt?: number | undefined;
|
|
751
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
752
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
753
|
+
readonly forkSubOffset?: number | undefined;
|
|
754
|
+
readonly softDeleted: boolean;
|
|
755
|
+
readonly expiresAtMs?: number | undefined;
|
|
756
|
+
};
|
|
757
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
758
|
+
};
|
|
759
|
+
readonly initialMessages: readonly {
|
|
760
|
+
readonly offset: string & import("effect/Brand").Brand<"Offset">;
|
|
761
|
+
readonly timestamp: number;
|
|
762
|
+
readonly data: Uint8Array<ArrayBufferLike>;
|
|
763
|
+
}[];
|
|
764
|
+
readonly forkSource?: {
|
|
765
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
766
|
+
readonly liveAtOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
767
|
+
} | undefined;
|
|
768
|
+
} | {
|
|
769
|
+
readonly _tag: "Append";
|
|
770
|
+
readonly streamId: string & import("effect/Brand").Brand<"StreamId">;
|
|
771
|
+
readonly messages: readonly {
|
|
772
|
+
readonly offset: string & import("effect/Brand").Brand<"Offset">;
|
|
773
|
+
readonly timestamp: number;
|
|
774
|
+
readonly data: Uint8Array<ArrayBufferLike>;
|
|
775
|
+
}[];
|
|
776
|
+
readonly patch: {
|
|
777
|
+
readonly currentOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
778
|
+
readonly config?: {
|
|
779
|
+
readonly ttlSeconds?: number | undefined;
|
|
780
|
+
readonly expiresAt?: string | undefined;
|
|
781
|
+
} | undefined;
|
|
782
|
+
readonly lifecycle?: {
|
|
783
|
+
readonly lastSeq?: string | undefined;
|
|
784
|
+
readonly closedAt?: number | undefined;
|
|
785
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
786
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
787
|
+
readonly forkSubOffset?: number | undefined;
|
|
788
|
+
readonly expiresAtMs?: number | undefined;
|
|
789
|
+
readonly closed?: boolean | undefined;
|
|
790
|
+
readonly softDeleted?: boolean | undefined;
|
|
791
|
+
} | undefined;
|
|
792
|
+
readonly clear?: readonly ("expiresAt" | "expiresAtMs" | "lastSeq" | "ttlSeconds")[] | undefined;
|
|
793
|
+
};
|
|
794
|
+
readonly expectedOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
795
|
+
readonly expectedClosed?: boolean | undefined;
|
|
796
|
+
readonly producer?: {
|
|
797
|
+
readonly producerId: string & import("effect/Brand").Brand<"ProducerId">;
|
|
798
|
+
readonly expected: import("effect/Option").Option<{
|
|
799
|
+
readonly epoch: number;
|
|
800
|
+
readonly lastSeq: number;
|
|
801
|
+
}>;
|
|
802
|
+
readonly next: {
|
|
803
|
+
readonly epoch: number;
|
|
804
|
+
readonly lastSeq: number;
|
|
805
|
+
};
|
|
806
|
+
} | undefined;
|
|
807
|
+
} | {
|
|
808
|
+
readonly _tag: "Delete";
|
|
809
|
+
readonly streamId: string & import("effect/Brand").Brand<"StreamId">;
|
|
810
|
+
readonly reason: "delete" | "expiry";
|
|
811
|
+
readonly expectedExpiresAtMs?: number | undefined;
|
|
812
|
+
}>;
|
|
813
|
+
declare const OperationResults: Data.TaggedEnum.Constructor<{
|
|
814
|
+
readonly _tag: "Created";
|
|
815
|
+
readonly record: {
|
|
816
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
817
|
+
readonly config: {
|
|
818
|
+
readonly contentType: string;
|
|
819
|
+
readonly ttlSeconds?: number | undefined;
|
|
820
|
+
readonly expiresAt?: string | undefined;
|
|
821
|
+
readonly createdAt: number;
|
|
822
|
+
};
|
|
823
|
+
readonly lifecycle: {
|
|
824
|
+
readonly lastSeq?: string | undefined;
|
|
825
|
+
readonly closed: boolean;
|
|
826
|
+
readonly closedAt?: number | undefined;
|
|
827
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
828
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
829
|
+
readonly forkSubOffset?: number | undefined;
|
|
830
|
+
readonly softDeleted: boolean;
|
|
831
|
+
readonly expiresAtMs?: number | undefined;
|
|
832
|
+
};
|
|
833
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
834
|
+
};
|
|
835
|
+
} | {
|
|
836
|
+
readonly _tag: "Appended";
|
|
837
|
+
readonly record: {
|
|
838
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
839
|
+
readonly config: {
|
|
840
|
+
readonly contentType: string;
|
|
841
|
+
readonly ttlSeconds?: number | undefined;
|
|
842
|
+
readonly expiresAt?: string | undefined;
|
|
843
|
+
readonly createdAt: number;
|
|
844
|
+
};
|
|
845
|
+
readonly lifecycle: {
|
|
846
|
+
readonly lastSeq?: string | undefined;
|
|
847
|
+
readonly closed: boolean;
|
|
848
|
+
readonly closedAt?: number | undefined;
|
|
849
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
850
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
851
|
+
readonly forkSubOffset?: number | undefined;
|
|
852
|
+
readonly softDeleted: boolean;
|
|
853
|
+
readonly expiresAtMs?: number | undefined;
|
|
854
|
+
};
|
|
855
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
856
|
+
};
|
|
857
|
+
} | {
|
|
858
|
+
readonly _tag: "Purged";
|
|
859
|
+
readonly record: {
|
|
860
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
861
|
+
readonly config: {
|
|
862
|
+
readonly contentType: string;
|
|
863
|
+
readonly ttlSeconds?: number | undefined;
|
|
864
|
+
readonly expiresAt?: string | undefined;
|
|
865
|
+
readonly createdAt: number;
|
|
866
|
+
};
|
|
867
|
+
readonly lifecycle: {
|
|
868
|
+
readonly lastSeq?: string | undefined;
|
|
869
|
+
readonly closed: boolean;
|
|
870
|
+
readonly closedAt?: number | undefined;
|
|
871
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
872
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
873
|
+
readonly forkSubOffset?: number | undefined;
|
|
874
|
+
readonly softDeleted: boolean;
|
|
875
|
+
readonly expiresAtMs?: number | undefined;
|
|
876
|
+
};
|
|
877
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
878
|
+
};
|
|
879
|
+
} | {
|
|
880
|
+
readonly _tag: "SoftDeleted";
|
|
881
|
+
readonly record: {
|
|
882
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
883
|
+
readonly config: {
|
|
884
|
+
readonly contentType: string;
|
|
885
|
+
readonly ttlSeconds?: number | undefined;
|
|
886
|
+
readonly expiresAt?: string | undefined;
|
|
887
|
+
readonly createdAt: number;
|
|
888
|
+
};
|
|
889
|
+
readonly lifecycle: {
|
|
890
|
+
readonly lastSeq?: string | undefined;
|
|
891
|
+
readonly closed: boolean;
|
|
892
|
+
readonly closedAt?: number | undefined;
|
|
893
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
894
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
895
|
+
readonly forkSubOffset?: number | undefined;
|
|
896
|
+
readonly softDeleted: boolean;
|
|
897
|
+
readonly expiresAtMs?: number | undefined;
|
|
898
|
+
};
|
|
899
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
900
|
+
};
|
|
901
|
+
}>;
|
|
902
|
+
declare const Mutations: Data.TaggedEnum.Constructor<{
|
|
903
|
+
readonly _tag: "Applied";
|
|
904
|
+
readonly results: readonly [{
|
|
905
|
+
readonly _tag: "Created";
|
|
906
|
+
readonly record: {
|
|
907
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
908
|
+
readonly config: {
|
|
909
|
+
readonly contentType: string;
|
|
910
|
+
readonly ttlSeconds?: number | undefined;
|
|
911
|
+
readonly expiresAt?: string | undefined;
|
|
912
|
+
readonly createdAt: number;
|
|
913
|
+
};
|
|
914
|
+
readonly lifecycle: {
|
|
915
|
+
readonly lastSeq?: string | undefined;
|
|
916
|
+
readonly closed: boolean;
|
|
917
|
+
readonly closedAt?: number | undefined;
|
|
918
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
919
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
920
|
+
readonly forkSubOffset?: number | undefined;
|
|
921
|
+
readonly softDeleted: boolean;
|
|
922
|
+
readonly expiresAtMs?: number | undefined;
|
|
923
|
+
};
|
|
924
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
925
|
+
};
|
|
926
|
+
} | {
|
|
927
|
+
readonly _tag: "Appended";
|
|
928
|
+
readonly record: {
|
|
929
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
930
|
+
readonly config: {
|
|
931
|
+
readonly contentType: string;
|
|
932
|
+
readonly ttlSeconds?: number | undefined;
|
|
933
|
+
readonly expiresAt?: string | undefined;
|
|
934
|
+
readonly createdAt: number;
|
|
935
|
+
};
|
|
936
|
+
readonly lifecycle: {
|
|
937
|
+
readonly lastSeq?: string | undefined;
|
|
938
|
+
readonly closed: boolean;
|
|
939
|
+
readonly closedAt?: number | undefined;
|
|
940
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
941
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
942
|
+
readonly forkSubOffset?: number | undefined;
|
|
943
|
+
readonly softDeleted: boolean;
|
|
944
|
+
readonly expiresAtMs?: number | undefined;
|
|
945
|
+
};
|
|
946
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
947
|
+
};
|
|
948
|
+
} | {
|
|
949
|
+
readonly _tag: "Purged";
|
|
950
|
+
readonly record: {
|
|
951
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
952
|
+
readonly config: {
|
|
953
|
+
readonly contentType: string;
|
|
954
|
+
readonly ttlSeconds?: number | undefined;
|
|
955
|
+
readonly expiresAt?: string | undefined;
|
|
956
|
+
readonly createdAt: number;
|
|
957
|
+
};
|
|
958
|
+
readonly lifecycle: {
|
|
959
|
+
readonly lastSeq?: string | undefined;
|
|
960
|
+
readonly closed: boolean;
|
|
961
|
+
readonly closedAt?: number | undefined;
|
|
962
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
963
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
964
|
+
readonly forkSubOffset?: number | undefined;
|
|
965
|
+
readonly softDeleted: boolean;
|
|
966
|
+
readonly expiresAtMs?: number | undefined;
|
|
967
|
+
};
|
|
968
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
969
|
+
};
|
|
970
|
+
} | {
|
|
971
|
+
readonly _tag: "SoftDeleted";
|
|
972
|
+
readonly record: {
|
|
973
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
974
|
+
readonly config: {
|
|
975
|
+
readonly contentType: string;
|
|
976
|
+
readonly ttlSeconds?: number | undefined;
|
|
977
|
+
readonly expiresAt?: string | undefined;
|
|
978
|
+
readonly createdAt: number;
|
|
979
|
+
};
|
|
980
|
+
readonly lifecycle: {
|
|
981
|
+
readonly lastSeq?: string | undefined;
|
|
982
|
+
readonly closed: boolean;
|
|
983
|
+
readonly closedAt?: number | undefined;
|
|
984
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
985
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
986
|
+
readonly forkSubOffset?: number | undefined;
|
|
987
|
+
readonly softDeleted: boolean;
|
|
988
|
+
readonly expiresAtMs?: number | undefined;
|
|
989
|
+
};
|
|
990
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
991
|
+
};
|
|
992
|
+
}, ...({
|
|
993
|
+
readonly _tag: "Created";
|
|
994
|
+
readonly record: {
|
|
995
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
996
|
+
readonly config: {
|
|
997
|
+
readonly contentType: string;
|
|
998
|
+
readonly ttlSeconds?: number | undefined;
|
|
999
|
+
readonly expiresAt?: string | undefined;
|
|
1000
|
+
readonly createdAt: number;
|
|
1001
|
+
};
|
|
1002
|
+
readonly lifecycle: {
|
|
1003
|
+
readonly lastSeq?: string | undefined;
|
|
1004
|
+
readonly closed: boolean;
|
|
1005
|
+
readonly closedAt?: number | undefined;
|
|
1006
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
1007
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
1008
|
+
readonly forkSubOffset?: number | undefined;
|
|
1009
|
+
readonly softDeleted: boolean;
|
|
1010
|
+
readonly expiresAtMs?: number | undefined;
|
|
1011
|
+
};
|
|
1012
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
1013
|
+
};
|
|
1014
|
+
} | {
|
|
1015
|
+
readonly _tag: "Appended";
|
|
1016
|
+
readonly record: {
|
|
1017
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
1018
|
+
readonly config: {
|
|
1019
|
+
readonly contentType: string;
|
|
1020
|
+
readonly ttlSeconds?: number | undefined;
|
|
1021
|
+
readonly expiresAt?: string | undefined;
|
|
1022
|
+
readonly createdAt: number;
|
|
1023
|
+
};
|
|
1024
|
+
readonly lifecycle: {
|
|
1025
|
+
readonly lastSeq?: string | undefined;
|
|
1026
|
+
readonly closed: boolean;
|
|
1027
|
+
readonly closedAt?: number | undefined;
|
|
1028
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
1029
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
1030
|
+
readonly forkSubOffset?: number | undefined;
|
|
1031
|
+
readonly softDeleted: boolean;
|
|
1032
|
+
readonly expiresAtMs?: number | undefined;
|
|
1033
|
+
};
|
|
1034
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
1035
|
+
};
|
|
1036
|
+
} | {
|
|
1037
|
+
readonly _tag: "Purged";
|
|
1038
|
+
readonly record: {
|
|
1039
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
1040
|
+
readonly config: {
|
|
1041
|
+
readonly contentType: string;
|
|
1042
|
+
readonly ttlSeconds?: number | undefined;
|
|
1043
|
+
readonly expiresAt?: string | undefined;
|
|
1044
|
+
readonly createdAt: number;
|
|
1045
|
+
};
|
|
1046
|
+
readonly lifecycle: {
|
|
1047
|
+
readonly lastSeq?: string | undefined;
|
|
1048
|
+
readonly closed: boolean;
|
|
1049
|
+
readonly closedAt?: number | undefined;
|
|
1050
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
1051
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
1052
|
+
readonly forkSubOffset?: number | undefined;
|
|
1053
|
+
readonly softDeleted: boolean;
|
|
1054
|
+
readonly expiresAtMs?: number | undefined;
|
|
1055
|
+
};
|
|
1056
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
1057
|
+
};
|
|
1058
|
+
} | {
|
|
1059
|
+
readonly _tag: "SoftDeleted";
|
|
1060
|
+
readonly record: {
|
|
1061
|
+
readonly id: string & import("effect/Brand").Brand<"StreamId">;
|
|
1062
|
+
readonly config: {
|
|
1063
|
+
readonly contentType: string;
|
|
1064
|
+
readonly ttlSeconds?: number | undefined;
|
|
1065
|
+
readonly expiresAt?: string | undefined;
|
|
1066
|
+
readonly createdAt: number;
|
|
1067
|
+
};
|
|
1068
|
+
readonly lifecycle: {
|
|
1069
|
+
readonly lastSeq?: string | undefined;
|
|
1070
|
+
readonly closed: boolean;
|
|
1071
|
+
readonly closedAt?: number | undefined;
|
|
1072
|
+
readonly forkedFrom?: (string & import("effect/Brand").Brand<"StreamId">) | undefined;
|
|
1073
|
+
readonly forkOffset?: (string & import("effect/Brand").Brand<"Offset">) | undefined;
|
|
1074
|
+
readonly forkSubOffset?: number | undefined;
|
|
1075
|
+
readonly softDeleted: boolean;
|
|
1076
|
+
readonly expiresAtMs?: number | undefined;
|
|
1077
|
+
};
|
|
1078
|
+
readonly currentOffset: string & import("effect/Brand").Brand<"Offset">;
|
|
1079
|
+
};
|
|
1080
|
+
})[]];
|
|
1081
|
+
}>;
|
|
1082
|
+
interface StorageShape {
|
|
1083
|
+
readonly capabilities: StorageCapabilities;
|
|
1084
|
+
readonly record: (id: StreamId) => Effect.Effect<Option.Option<StreamRecord>, StorageFault>;
|
|
1085
|
+
readonly messages: (id: StreamId, window: MessageWindow) => Effect.Effect<ReadonlyArray<StoredMessage>, StorageFault>;
|
|
1086
|
+
readonly producer: (id: StreamId, producerId: ProducerId) => Effect.Effect<Option.Option<ProducerState>, StorageFault>;
|
|
1087
|
+
readonly mutate: (mutation: Mutation) => Effect.Effect<MutationApplied, MutationRejected | StorageFault>;
|
|
1088
|
+
readonly changes: (id: StreamId) => Stream.Stream<ChangeSnapshot, StorageFault>;
|
|
1089
|
+
/**
|
|
1090
|
+
* Subscribe to the stream ids of later local commits. The subscription exists when
|
|
1091
|
+
* this effect returns, so a commit after that point always lands in it. Each item
|
|
1092
|
+
* holds the ids that one commit created, appended to or deleted, after that commit.
|
|
1093
|
+
* A rolled-back mutation reports nothing. In process and best effort: a commit by
|
|
1094
|
+
* another process on the same database does not show, and nothing replays after a
|
|
1095
|
+
* restart. The scope releases the subscription.
|
|
1096
|
+
*/
|
|
1097
|
+
readonly committed: Effect.Effect<PubSub.Subscription<ReadonlyArray<StreamId>>, never, Scope.Scope>;
|
|
1098
|
+
readonly nextExpiry: Effect.Effect<Option.Option<{
|
|
1099
|
+
readonly at: number;
|
|
1100
|
+
readonly streamId: StreamId;
|
|
1101
|
+
}>, StorageFault>;
|
|
1102
|
+
}
|
|
1103
|
+
declare const Storage_base: Context.ServiceClass<Storage, "@streamsy/core/Storage", StorageShape>;
|
|
1104
|
+
declare class Storage extends Storage_base {}
|
|
1105
|
+
/**
|
|
1106
|
+
* Encoded records on the storage owner, for the projection checkpoint store.
|
|
1107
|
+
* Calls inside `CommitBoundary.withTransaction` join that transaction.
|
|
1108
|
+
*/
|
|
1109
|
+
interface OwnerRecordsApi {
|
|
1110
|
+
readonly read: (key: string) => Effect.Effect<Option.Option<string>, StorageFault>;
|
|
1111
|
+
readonly write: (key: string, encoded: string) => Effect.Effect<void, StorageFault>;
|
|
1112
|
+
readonly remove: (key: string) => Effect.Effect<void, StorageFault>;
|
|
1113
|
+
}
|
|
1114
|
+
declare const OwnerRecords_base: Context.ServiceClass<OwnerRecords, "@streamsy/core/internal/OwnerRecords", OwnerRecordsApi>;
|
|
1115
|
+
declare class OwnerRecords extends OwnerRecords_base {}
|
|
1116
|
+
/**
|
|
1117
|
+
* Work that joins an owned transaction just before it commits. It receives the
|
|
1118
|
+
* stream ids that the transaction created, appended to or deleted.
|
|
1119
|
+
*/
|
|
1120
|
+
type CommitHook = (ids: ReadonlySet<StreamId>) => Effect.Effect<void, SqlError.SqlError>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Commit hooks on the storage owner, for the durable projection marks.
|
|
1123
|
+
*
|
|
1124
|
+
* A hook runs inside each later owned transaction that wrote at least one stream
|
|
1125
|
+
* id, after the body and before COMMIT. Statements in the hook join the
|
|
1126
|
+
* transaction, and a hook failure rolls the transaction back. A SQL host treats
|
|
1127
|
+
* a hook failure like a body failure, so a retryable `SqlError` replays the
|
|
1128
|
+
* whole transaction, hook included. The memory host turns a hook failure into a
|
|
1129
|
+
* defect. A hook must not write streams: its ids would not reach other hooks.
|
|
1130
|
+
*/
|
|
1131
|
+
interface CommitHooksApi {
|
|
1132
|
+
/** Register `hook` until the scope closes. */
|
|
1133
|
+
readonly beforeCommit: (hook: CommitHook) => Effect.Effect<void, never, Scope.Scope>;
|
|
1134
|
+
}
|
|
1135
|
+
declare const CommitHooks_base: Context.ServiceClass<CommitHooks, "@streamsy/core/internal/CommitHooks", CommitHooksApi>;
|
|
1136
|
+
declare class CommitHooks extends CommitHooks_base {}
|
|
1137
|
+
/** Shared registry for storage boundaries: register in a scope, run in order. */
|
|
1138
|
+
declare const commitHookRegistry: () => {
|
|
1139
|
+
beforeCommit: (hook: CommitHook) => Effect.Effect<void, never, Scope.Scope>;
|
|
1140
|
+
run: (ids: ReadonlySet<StreamId>) => Effect.Effect<void, SqlError.SqlError>;
|
|
1141
|
+
};
|
|
1142
|
+
/** One pending mark: a binding whose input has commits that may not have run. */
|
|
1143
|
+
interface PendingMark {
|
|
1144
|
+
/** The binding's canonical params, as `canonicalParams` encodes them. */
|
|
1145
|
+
readonly params: string;
|
|
1146
|
+
/** Raised by every mark. A clear only deletes the row when its `seq` still matches. */
|
|
1147
|
+
readonly seq: number;
|
|
1148
|
+
/** Failed runs since the last success. A mark keeps it. */
|
|
1149
|
+
readonly attempts: number;
|
|
1150
|
+
/** Epoch ms. 0 means due now. */
|
|
1151
|
+
readonly dueAt: number;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Durable pending marks on the storage owner, for attached projections.
|
|
1155
|
+
*
|
|
1156
|
+
* A mark is keyed by projection id and canonical params. Version and generation
|
|
1157
|
+
* are left out, so a deploy that raises the version picks up the old marks.
|
|
1158
|
+
*/
|
|
1159
|
+
interface ProjectionMarksApi {
|
|
1160
|
+
/**
|
|
1161
|
+
* Insert a mark for each binding, or raise its `seq`. A raise keeps
|
|
1162
|
+
* `attempts` and `dueAt`, so a write does not reset a binding's backoff.
|
|
1163
|
+
* Call it inside a commit hook. It joins the transaction and fails like the
|
|
1164
|
+
* transaction's own statements.
|
|
1165
|
+
*/
|
|
1166
|
+
readonly mark: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<void, SqlError.SqlError>;
|
|
1167
|
+
/** The earliest `dueAt` of the projection's marks. */
|
|
1168
|
+
readonly nextDue: (projection: string) => Effect.Effect<Option.Option<number>, StorageFault>;
|
|
1169
|
+
/** Up to `limit` marks with `dueAt <= now`, earliest first. */
|
|
1170
|
+
readonly due: (projection: string, now: number, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
|
|
1171
|
+
/** The marks of these bindings that exist, keyed by params. */
|
|
1172
|
+
readonly read: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<ReadonlyMap<string, PendingMark>, StorageFault>;
|
|
1173
|
+
/** Delete the mark if its `seq` still equals `seq`. A later mark keeps the row. */
|
|
1174
|
+
readonly clear: (projection: string, params: string, seq: number) => Effect.Effect<void, StorageFault>;
|
|
1175
|
+
/** Delete the mark whatever its `seq`. */
|
|
1176
|
+
readonly remove: (projection: string, params: string) => Effect.Effect<void, StorageFault>;
|
|
1177
|
+
/** Set `attempts` and `dueAt`, and insert the mark if it is absent. */
|
|
1178
|
+
readonly defer: (projection: string, params: string, attempts: number, dueAt: number) => Effect.Effect<void, StorageFault>;
|
|
1179
|
+
/** The number of the projection's marks with at least one failed attempt. */
|
|
1180
|
+
readonly deferred: (projection: string) => Effect.Effect<number, StorageFault>;
|
|
1181
|
+
}
|
|
1182
|
+
declare const ProjectionMarks_base: Context.ServiceClass<ProjectionMarks, "@streamsy/core/internal/ProjectionMarks", ProjectionMarksApi>;
|
|
1183
|
+
declare class ProjectionMarks extends ProjectionMarks_base {}
|
|
1184
|
+
export { StaleEpoch as $, ReadNextResult as A, HeadError as B, StreamsReader as C, EncodeFault as Ct, CreateResult as D, isRetryableFault as Dt, AppendResult as E, TransportFault as Et, AppendErrorFor as F, InvalidReadRequest as G, InvalidCreateRequest as H, CreateConflict as I, ProducerGap as J, NotSupported as K, CreateConflictReason as L, AppendBaseError as M, AppendConflict as N, HeadResult as O, isStreamsFault as Ot, AppendError as P, RemoveError as Q, CreateError as R, Reader as S, DecodeFault as St, Writer as T, StreamsFault as Tt, InvalidEpochSeq as U, InvalidAppendRequest as V, InvalidForkRequest as W, ReadError as X, ProtocolError as Y, ReadNextError as Z, OperationResult as _, StoredMessage as _t, CommitHooks as a, AppendCallOptions as at, ProducerPrecondition as b, StreamLifecycle as bt, OwnerRecords as c, ReadNextOptions as ct, StorageShape as d, ChangeSnapshot as dt, StreamBusy as et, Mutation as f, MessageWindow as ft, Operation as g, RecordPatch as gt, Mutations as h, ProducerState as ht, CommitHook as i, isProtocolError as it, ReadResult as j, ReadMessage as k, OwnerRecordsApi as l, ReadOptions as lt, MutationRejected as m, ProducerId as mt, ProjectionMarks as n, StreamGone as nt, CommitHooksApi as o, AppendOptions as ot, MutationApplied as p, Offset as pt, OffsetMismatch as q, ProjectionMarksApi as r, StreamNotFound as rt, commitHookRegistry as s, ProducerOptions as st, PendingMark as t, StreamClosed as tt, Storage as u, CreateOptions as ut, OperationResults as v, StreamConfig as vt, StreamsWriter as w, StorageFault as wt, StorageCapabilities as x, StreamRecord as xt, Operations as y, StreamId as yt, ForkSourceNotFound as z };
|