@streamsy/core 0.15.0 → 0.16.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 +4 -284
- package/dist/{boundary-f1biibJ1.js → boundary-BTrhL8De.js} +1 -1
- package/dist/{create-validation-DzLxKiux.js → create-validation-C_aJJm5u.js} +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +2 -2
- package/dist/{http-YoA8cUTN.js → http-BNYNMGuk.js} +2 -2
- package/dist/{index-BtVxu6VJ.d.ts → index-D-n48qXe.d.ts} +93 -208
- package/dist/index.d.ts +2 -2
- package/dist/index.js +114 -72
- package/dist/internal/index.d.ts +32 -1
- package/dist/internal/index.js +3 -3
- package/dist/{layer-J6sV3UXD.js → layer-C-8GAL_W.js} +4 -4
- package/dist/{layer-DjKTdIY5.js → layer-pomDIajD.js} +5 -3
- package/dist/{program-BlfAJNlD.js → program-DhW5In9U.js} +6 -3
- package/dist/{projection-marks-BEZv8qDJ.d.ts → projection-marks-DcO_5VNd.d.ts} +141 -1
- package/dist/protocol/index.d.ts +2 -2
- package/dist/protocol/index.js +3 -3
- package/dist/read-message-CGHhOCMc.js +193 -0
- package/dist/remote/index.d.ts +5 -3
- package/dist/remote/index.js +155 -25
- package/dist/{streamsy-HKC10a_V.js → streamsy-IBFULoEr.js} +19 -84
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +5 -4
- package/package.json +1 -1
- package/dist/route-internal-DNL0oGTN.js +0 -93
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Writer,
|
|
1
|
+
import { $ as CreateError, A as CollectionsEncodingServices, B as Writer, Bt as StreamsFault, Ct as ReadNextOptions, D as Collections, F as ValidCollections, G as ReadNextResult, H as CreateResult, J as AppendConflict, L as Reader, Lt as DecodeFault, M as StateAddress, N as StateControl, O as CollectionsDecodingServices, P as StreamAddress, Pt as StreamId, R as StreamsReader, Rt as EncodeFault, St as ProducerOptions, Tt as CreateOptions, U as HeadResult, V as AppendResult, Vt as TransportFault, X as AppendErrorFor, _t as StreamGone, bt as AppendCallOptions, ct as OffsetMismatch, d as OwnerRecords, ft as ReadNextError, gt as StreamClosed, h as Storage, ht as StreamBusy, i as ProjectionMarks, j as CollectionsEvent, k as CollectionsEncodedEvent, ot as InvalidReadRequest, p as CommitBoundary, pt as RemoveError, s as CommitHooks, st as NotSupported, tt as HeadError, vt as StreamNotFound, wt as ReadOptions$1, z as StreamsWriter, zt as StorageFault } from "./projection-marks-DcO_5VNd.js";
|
|
2
2
|
import { Array, Context, Data, Duration, Effect, Function, Layer, Option, Schedule, Schema, Stream } from "effect";
|
|
3
3
|
import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
4
4
|
interface HttpOptions {
|
|
@@ -23,136 +23,6 @@ declare const streamPath: (pathPrefix?: string) => {
|
|
|
23
23
|
strip: (pathname: string) => string;
|
|
24
24
|
canonicalizeForkSource: (source: string) => string;
|
|
25
25
|
};
|
|
26
|
-
declare namespace address_d_exports {
|
|
27
|
-
export { Collection, Collections, CollectionsChange, CollectionsDecodingServices, CollectionsEncodedChange, CollectionsEncodedEvent, CollectionsEncodingServices, CollectionsEvent, StateAddress, StateChange, StateControl, StateControlName, StateDelete, StateEvent, StateHeaders, StateKey, StateUpsert, StreamAddress, ValidCollections, bytes$2 as bytes, isChange, isControl, isUpsert, json$2 as json, reset, snapshotEnd, snapshotStart, state$2 as state, stateChange, stateControl };
|
|
28
|
-
}
|
|
29
|
-
/** Omit `offset` and `txid` rather than setting them to `undefined`. */
|
|
30
|
-
interface StateHeaders {
|
|
31
|
-
readonly operation: "upsert" | "delete";
|
|
32
|
-
readonly offset?: string;
|
|
33
|
-
readonly txid?: string;
|
|
34
|
-
readonly timestamp?: string;
|
|
35
|
-
readonly from?: string;
|
|
36
|
-
}
|
|
37
|
-
interface StateUpsert<A, Type extends string = string> {
|
|
38
|
-
readonly type: Type;
|
|
39
|
-
readonly key: string;
|
|
40
|
-
readonly value: A;
|
|
41
|
-
readonly headers: StateHeaders & {
|
|
42
|
-
readonly operation: "upsert";
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
interface StateDelete<A, Type extends string = string> {
|
|
46
|
-
readonly type: Type;
|
|
47
|
-
readonly key: string;
|
|
48
|
-
readonly old_value?: A;
|
|
49
|
-
readonly headers: StateHeaders & {
|
|
50
|
-
readonly operation: "delete";
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/** A change event consumed by `@durable-streams/state`, narrowed by its `type`. */
|
|
54
|
-
type StateChange<A, Type extends string = string> = StateUpsert<A, Type> | StateDelete<A, Type>;
|
|
55
|
-
type StateEncodedChange<A, Type extends string = string> = (Omit<StateUpsert<A, Type>, "headers"> & {
|
|
56
|
-
readonly headers: Omit<StateHeaders, "operation"> & {
|
|
57
|
-
readonly operation: "insert" | "update" | "upsert";
|
|
58
|
-
};
|
|
59
|
-
}) | StateDelete<A, Type>;
|
|
60
|
-
/** The control signals of the Durable State protocol (STATE-PROTOCOL.md section 4.2). */
|
|
61
|
-
type StateControlName = "snapshot-start" | "snapshot-end" | "reset";
|
|
62
|
-
/**
|
|
63
|
-
* A control message of a Durable State stream. It has no `type` or `key`.
|
|
64
|
-
* `snapshot-start` and `snapshot-end` mark a run of changes that is a complete
|
|
65
|
-
* snapshot. `reset` tells a reader to clear its materialized state. Omit
|
|
66
|
-
* `offset` rather than setting it to `undefined`.
|
|
67
|
-
*/
|
|
68
|
-
interface StateControl {
|
|
69
|
-
readonly headers: {
|
|
70
|
-
readonly control: StateControlName;
|
|
71
|
-
readonly offset?: string;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/** One item of a Durable State stream: a change of one collection or a control. */
|
|
75
|
-
type StateEvent<A, Type extends string = string> = StateChange<A, Type> | StateControl;
|
|
76
|
-
/** The value fields that may serve as a Durable State key. */
|
|
77
|
-
type StateKey<A> = { [K in keyof A]-?: A[K] extends string | number ? K : never; }[keyof A];
|
|
78
|
-
/** One collection of a Durable State stream: its value schema and the value field used as the key. */
|
|
79
|
-
interface Collection<A, I, RD, RE, Key extends StateKey<A> = StateKey<A>> {
|
|
80
|
-
readonly schema: Schema.Codec<A, I, RD, RE>;
|
|
81
|
-
readonly key: Key;
|
|
82
|
-
}
|
|
83
|
-
/** Collections keyed by the `type` that names them on the wire. */
|
|
84
|
-
type Collections = Record<string, Collection<any, any, any, any, any>>;
|
|
85
|
-
/**
|
|
86
|
-
* Each `key` must name a string or number field of its own collection's value.
|
|
87
|
-
* A mismatch reports on the `key` property of the offending collection.
|
|
88
|
-
*/
|
|
89
|
-
type ValidCollections<C extends Collections> = { readonly [K in keyof C]: C[K]["key"] extends StateKey<C[K]["schema"]["Type"]> ? C[K] : {
|
|
90
|
-
readonly key: StateKey<C[K]["schema"]["Type"]>;
|
|
91
|
-
}; };
|
|
92
|
-
/** The union of change events across every collection, discriminated by `type`. */
|
|
93
|
-
type CollectionsChange<C extends Collections> = { [K in keyof C & string]: StateChange<C[K]["schema"]["Type"], K>; }[keyof C & string];
|
|
94
|
-
type CollectionsEncodedChange<C extends Collections> = { [K in keyof C & string]: StateEncodedChange<C[K]["schema"]["Encoded"], K>; }[keyof C & string];
|
|
95
|
-
/** The items of a State address: the change events of its collections, plus controls. */
|
|
96
|
-
type CollectionsEvent<C extends Collections> = CollectionsChange<C> | StateControl;
|
|
97
|
-
type CollectionsEncodedEvent<C extends Collections> = CollectionsEncodedChange<C> | StateControl;
|
|
98
|
-
type CollectionsDecodingServices<C extends Collections> = C[keyof C]["schema"]["DecodingServices"];
|
|
99
|
-
type CollectionsEncodingServices<C extends Collections> = C[keyof C]["schema"]["EncodingServices"];
|
|
100
|
-
/** Inert identity and codec. Constructing an address acquires no service or resource. */
|
|
101
|
-
interface StreamAddress<A, RD = never, RE = never> {
|
|
102
|
-
readonly _tag: "Json" | "Bytes";
|
|
103
|
-
readonly id: StreamId;
|
|
104
|
-
readonly contentType: string;
|
|
105
|
-
readonly codec: Schema.Codec<A, string | Uint8Array, RD, RE>;
|
|
106
|
-
}
|
|
107
|
-
/** A JSON address whose items are the change events of its collections and State controls. */
|
|
108
|
-
interface StateAddress<C extends Collections, RD = CollectionsDecodingServices<C>, RE = CollectionsEncodingServices<C>> extends StreamAddress<CollectionsEvent<C>, RD, RE> {
|
|
109
|
-
readonly collections: C;
|
|
110
|
-
}
|
|
111
|
-
declare function json$2<A, I, RD, RE>(id: string, options: {
|
|
112
|
-
readonly schema: Schema.Codec<A, I, RD, RE>;
|
|
113
|
-
}): StreamAddress<A, RD, RE>;
|
|
114
|
-
/**
|
|
115
|
-
* A codec for the upsert and delete change events of one collection.
|
|
116
|
-
* `state` composes one of these per collection. Omit optional headers instead
|
|
117
|
-
* of setting them to `undefined`.
|
|
118
|
-
*/
|
|
119
|
-
declare function stateChange<A, I, RD, RE, const Type extends string>(options: {
|
|
120
|
-
readonly schema: Schema.Codec<A, I, RD, RE>;
|
|
121
|
-
readonly type: Type;
|
|
122
|
-
}): Schema.Codec<StateChange<A, Type>, StateEncodedChange<I, Type>, RD, RE>;
|
|
123
|
-
/** The codec for a State control message. It needs no services. */
|
|
124
|
-
declare const stateControl: Schema.Codec<StateControl>;
|
|
125
|
-
/** True for a control message. A change has `headers.operation` and no `headers.control`. */
|
|
126
|
-
declare const isControl: <E extends StateEvent<unknown>>(event: E) => event is Extract<E, StateControl>;
|
|
127
|
-
/** True for an upsert or delete change. */
|
|
128
|
-
declare const isChange: <E extends StateEvent<unknown>>(event: E) => event is Exclude<E, StateControl>;
|
|
129
|
-
/** True for an upsert change, with its value available. */
|
|
130
|
-
declare const isUpsert: <E extends StateEvent<unknown>>(event: E) => event is Extract<E, StateUpsert<unknown>>;
|
|
131
|
-
/** A `reset` control. A reader should clear its materialized state and apply what follows. */
|
|
132
|
-
declare const reset: (options?: {
|
|
133
|
-
readonly offset?: string;
|
|
134
|
-
}) => StateControl;
|
|
135
|
-
/** A `snapshot-start` control. The changes up to `snapshot-end` form a complete snapshot. */
|
|
136
|
-
declare const snapshotStart: (options?: {
|
|
137
|
-
readonly offset?: string;
|
|
138
|
-
}) => StateControl;
|
|
139
|
-
/** A `snapshot-end` control. It closes the snapshot that `snapshot-start` opened. */
|
|
140
|
-
declare const snapshotEnd: (options?: {
|
|
141
|
-
readonly offset?: string;
|
|
142
|
-
}) => StateControl;
|
|
143
|
-
/**
|
|
144
|
-
* A stream of Durable State events for several collections. Each record
|
|
145
|
-
* key is the `type` on the wire; each entry gives the value schema and the value
|
|
146
|
-
* field that becomes the event `key`. The codec also decodes and encodes the
|
|
147
|
-
* State control messages `snapshot-start`, `snapshot-end` and `reset`.
|
|
148
|
-
*/
|
|
149
|
-
declare function state$2<const C extends Collections>(id: string, options: {
|
|
150
|
-
readonly collections: C & ValidCollections<C>;
|
|
151
|
-
}): StateAddress<C>;
|
|
152
|
-
/** Items from one bytes append are joined into one stored message. */
|
|
153
|
-
declare function bytes$2(id: string, options?: {
|
|
154
|
-
readonly contentType?: string;
|
|
155
|
-
}): StreamAddress<Uint8Array>;
|
|
156
26
|
declare namespace route_d_exports {
|
|
157
27
|
export { ExactTemplateParams, Matcher, ParamCodecs, Params, PathSchema, StateRoute, StreamRoute, bytes$1 as bytes, custom$1 as custom, json$1 as json, state$1 as state };
|
|
158
28
|
}
|
|
@@ -206,6 +76,7 @@ declare function json$1<const Template extends string, Codecs extends ParamCodec
|
|
|
206
76
|
declare function state$1<const Template extends string, Codecs extends ParamCodecs, const C extends Collections>(template: Template, options: {
|
|
207
77
|
readonly params: Codecs & ExactTemplateParams<Template, Codecs>;
|
|
208
78
|
readonly collections: C & ValidCollections<C>;
|
|
79
|
+
readonly strict?: boolean;
|
|
209
80
|
}): StateRoute<Params<Codecs>, C, Template> & WithPathSchema<Params<Codecs>> & WithParamCodecs<Codecs>;
|
|
210
81
|
declare function bytes$1<const Template extends string, Codecs extends ParamCodecs>(template: Template, options: {
|
|
211
82
|
readonly params: Codecs & ExactTemplateParams<Template, Codecs>;
|
|
@@ -324,79 +195,56 @@ declare namespace producer_d_exports {
|
|
|
324
195
|
type Position = ProducerOptions;
|
|
325
196
|
/** Advance only after the caller has acknowledged appended or duplicate. Persist this tuple at the owning edge. */
|
|
326
197
|
declare const next: (position: Position) => Position;
|
|
327
|
-
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
* or accepted in a projection's accepted stream.
|
|
335
|
-
*/
|
|
336
|
-
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
337
|
-
/** Present when the source stream is closed. */
|
|
338
|
-
readonly closed: Schema.optionalKey<Schema.Literal<true>>;
|
|
339
|
-
}>;
|
|
340
|
-
type WakeRow = typeof WakeRow.Type;
|
|
341
|
-
/** The one collection of every wake stream. Its State `type` is `stream`. */
|
|
342
|
-
declare const wakeCollections: {
|
|
198
|
+
/**
|
|
199
|
+
* The one collection of every frontier stream. Its State `type` is `stream`, and each row is a
|
|
200
|
+
* `Frontier`: the source stream id, a position in the source that the row's writer vouches
|
|
201
|
+
* for, and `closed` when the source is closed. The stream holding the row says what is
|
|
202
|
+
* vouched: written in a source frontier stream, or accepted in a projection's frontier stream.
|
|
203
|
+
*/
|
|
204
|
+
declare const frontierStreamCollections: {
|
|
343
205
|
readonly stream: {
|
|
344
206
|
readonly schema: Schema.Struct<{
|
|
345
|
-
|
|
346
|
-
readonly
|
|
347
|
-
/**
|
|
348
|
-
* A position in the source that the row's writer vouches for. The stream
|
|
349
|
-
* holding the row says what is vouched: written in a source wake stream,
|
|
350
|
-
* or accepted in a projection's accepted stream.
|
|
351
|
-
*/
|
|
352
|
-
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
353
|
-
/** Present when the source stream is closed. */
|
|
207
|
+
readonly stream: Schema.String;
|
|
208
|
+
readonly offset: Schema.String;
|
|
354
209
|
readonly closed: Schema.optionalKey<Schema.Literal<true>>;
|
|
355
210
|
}>;
|
|
356
211
|
readonly key: "stream";
|
|
357
212
|
};
|
|
358
213
|
};
|
|
359
|
-
type
|
|
360
|
-
/** One item of a
|
|
361
|
-
type
|
|
214
|
+
type FrontierStreamCollections = typeof frontierStreamCollections;
|
|
215
|
+
/** One item of a frontier stream. */
|
|
216
|
+
type FrontierEvent = CollectionsEvent<FrontierStreamCollections>;
|
|
362
217
|
/**
|
|
363
|
-
* The codec of one
|
|
218
|
+
* The codec of one frontier stream message: a `stream` change or a State control.
|
|
364
219
|
* A client that decodes raw JSON pages uses it in place of a typed service.
|
|
365
220
|
*/
|
|
366
|
-
declare const
|
|
221
|
+
declare const FrontierMessage: Schema.Codec<FrontierEvent, CollectionsEncodedEvent<FrontierStreamCollections>>;
|
|
367
222
|
/**
|
|
368
|
-
* Declare a
|
|
223
|
+
* Declare a frontier stream: a State stream of `Frontier` rows at a template.
|
|
369
224
|
*
|
|
370
225
|
* ```ts
|
|
371
|
-
* class
|
|
226
|
+
* class UserFrontier extends Streamsy.frontierStream<UserFrontier>()("App/UserFrontier", "users/:user/frontier", {
|
|
372
227
|
* params: { user: UserKey },
|
|
373
228
|
* }) {}
|
|
374
229
|
* ```
|
|
375
230
|
*
|
|
376
|
-
* The declaration names no sources. A `Projection.
|
|
377
|
-
* source stream to one
|
|
231
|
+
* The declaration names no sources. A `Projection.frontier` binding links one
|
|
232
|
+
* source stream to one frontier stream, with params of its own.
|
|
378
233
|
*/
|
|
379
|
-
declare const
|
|
234
|
+
declare const frontierStream: <Self>() => <const Name extends string, const Template extends string, C extends ParamCodecs>(name: Name, template: Template, options: {
|
|
380
235
|
readonly params: C & ExactTemplateParams<Template, C>;
|
|
381
236
|
}) => StateClass<Self, Name, Template, C, {
|
|
382
237
|
readonly stream: {
|
|
383
238
|
readonly schema: Schema.Struct<{
|
|
384
|
-
|
|
385
|
-
readonly
|
|
386
|
-
/**
|
|
387
|
-
* A position in the source that the row's writer vouches for. The stream
|
|
388
|
-
* holding the row says what is vouched: written in a source wake stream,
|
|
389
|
-
* or accepted in a projection's accepted stream.
|
|
390
|
-
*/
|
|
391
|
-
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
392
|
-
/** Present when the source stream is closed. */
|
|
239
|
+
readonly stream: Schema.String;
|
|
240
|
+
readonly offset: Schema.String;
|
|
393
241
|
readonly closed: Schema.optionalKey<Schema.Literal<true>>;
|
|
394
242
|
}>;
|
|
395
243
|
readonly key: "stream";
|
|
396
244
|
};
|
|
397
245
|
}>;
|
|
398
|
-
/** One action for a consumer of a
|
|
399
|
-
type
|
|
246
|
+
/** One action for a consumer of a frontier stream. */
|
|
247
|
+
type FrontierItem = Data.TaggedEnum<{
|
|
400
248
|
/** Read `stream` from `from` up to at least `offset`, then save its cursor. */
|
|
401
249
|
Dirty: {
|
|
402
250
|
readonly stream: StreamId;
|
|
@@ -415,8 +263,8 @@ type WakeItem = Data.TaggedEnum<{
|
|
|
415
263
|
readonly streams: ReadonlySet<StreamId>;
|
|
416
264
|
};
|
|
417
265
|
}>;
|
|
418
|
-
/** Constructors and matchers for `
|
|
419
|
-
declare const
|
|
266
|
+
/** Constructors and matchers for `FrontierItem`. */
|
|
267
|
+
declare const FrontierItem: Data.TaggedEnum.Constructor<{
|
|
420
268
|
readonly _tag: "Dirty";
|
|
421
269
|
readonly stream: StreamId;
|
|
422
270
|
readonly from: string;
|
|
@@ -431,62 +279,98 @@ declare const WakeItem: Data.TaggedEnum.Constructor<{
|
|
|
431
279
|
readonly _tag: "Snapshot";
|
|
432
280
|
readonly streams: ReadonlySet<StreamId>;
|
|
433
281
|
}>;
|
|
434
|
-
/** One batch of
|
|
435
|
-
interface
|
|
436
|
-
readonly items: ReadonlyArray<
|
|
282
|
+
/** One batch of frontier actions. Save `offset` as the frontier cursor after every item is handled. */
|
|
283
|
+
interface FrontierBatch {
|
|
284
|
+
readonly items: ReadonlyArray<FrontierItem>;
|
|
437
285
|
readonly offset: string;
|
|
438
286
|
readonly upToDate: boolean;
|
|
439
287
|
}
|
|
440
|
-
interface
|
|
441
|
-
/** The saved
|
|
288
|
+
interface FollowFrontierOptions extends Omit<FollowOptions, "offset"> {
|
|
289
|
+
/** The saved frontier stream cursor. Default: `-1`, a cold start. */
|
|
442
290
|
readonly from?: string;
|
|
443
291
|
/** Saved source cursors. Read again for each batch, so the consumer may update the map. */
|
|
444
292
|
readonly cursors: ReadonlyMap<StreamId, string>;
|
|
445
293
|
}
|
|
446
|
-
/** Follow options for a wait, including a saved
|
|
447
|
-
type
|
|
448
|
-
interface
|
|
294
|
+
/** Follow options for a wait, including a saved frontier stream cursor. */
|
|
295
|
+
type AwaitFrontierOptions = Omit<FollowFrontierOptions, "cursors">;
|
|
296
|
+
interface FrontierActionsOptions {
|
|
449
297
|
/** Saved source cursors. A missing entry starts from `-1`. */
|
|
450
298
|
readonly cursors: ReadonlyMap<StreamId, string>;
|
|
451
299
|
/** The streams of a snapshot that an earlier batch left open. */
|
|
452
300
|
readonly snapshot?: ReadonlySet<StreamId> | undefined;
|
|
453
301
|
}
|
|
454
|
-
/** The actions of one
|
|
455
|
-
interface
|
|
456
|
-
readonly items: ReadonlyArray<
|
|
302
|
+
/** The actions of one frontier batch, and the snapshot state for the next batch. */
|
|
303
|
+
interface FrontierActions {
|
|
304
|
+
readonly items: ReadonlyArray<FrontierItem>;
|
|
457
305
|
/** The streams of a snapshot that is still open. Pass it to the next call. */
|
|
458
306
|
readonly snapshot: ReadonlySet<StreamId> | undefined;
|
|
459
307
|
}
|
|
460
308
|
/**
|
|
461
|
-
* The actions for one batch of
|
|
309
|
+
* The actions for one batch of frontier stream messages. The function is pure: it reads
|
|
462
310
|
* no stream and changes none of its inputs. Rows for one stream collapse to one
|
|
463
311
|
* item; a delete then an upsert of one stream gives `Removed`, then `Dirty` from
|
|
464
312
|
* `-1`. Pass the returned `snapshot` to the call for the next batch.
|
|
465
313
|
*
|
|
466
|
-
* `
|
|
467
|
-
* decodes each page with `
|
|
314
|
+
* `followFrontier` uses it over a typed service. A client with its own HTTP reader
|
|
315
|
+
* decodes each page with `FrontierMessage` and calls it directly.
|
|
468
316
|
*/
|
|
469
|
-
declare function
|
|
317
|
+
declare function frontierActions(events: ReadonlyArray<FrontierEvent>, options: FrontierActionsOptions): FrontierActions;
|
|
470
318
|
/**
|
|
471
|
-
* Follow one
|
|
319
|
+
* Follow one frontier stream and give the actions for each batch: which source
|
|
472
320
|
* streams to read, from which cursor, and which to drop. The helper reads no
|
|
473
|
-
* source stream. Save each source cursor first and the
|
|
321
|
+
* source stream. Save each source cursor first and the frontier cursor (`offset`)
|
|
474
322
|
* last; a stop between the two reads the same rows again, and the offset check
|
|
475
323
|
* skips the streams that were already read.
|
|
476
324
|
*/
|
|
477
|
-
declare function
|
|
325
|
+
declare function followFrontier<Self, P>(declaration: Context.Key<Self, Api<P, FrontierEvent>>, params: P, options: FollowFrontierOptions): Stream.Stream<FrontierBatch, FollowFailure, Self>;
|
|
326
|
+
/** A State class: a service key that also lists its collections. */
|
|
327
|
+
type FrontierSource<Self, P, C extends Collections> = Context.Key<Self, Api<P, CollectionsEvent<C>>> & {
|
|
328
|
+
readonly collections: C;
|
|
329
|
+
};
|
|
478
330
|
/**
|
|
479
|
-
* Wait until
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
331
|
+
* Wait until the frontier row for `stream` reaches `offset`. `declaration` is a
|
|
332
|
+
* frontier stream or any State class with one `Streamsy.frontier` collection; the
|
|
333
|
+
* other collections are read and skipped. Works with local and remote
|
|
334
|
+
* services. Callers choose their own timeout. Removed source ids must not be
|
|
335
|
+
* reused; a new generation needs a new stream or a State reset. Without
|
|
336
|
+
* `options.from`, each call reads the history from the start.
|
|
483
337
|
*/
|
|
484
|
-
declare const
|
|
485
|
-
readonly stream:
|
|
338
|
+
declare const awaitFrontier: <Self, P, C extends Collections>(declaration: FrontierSource<Self, P, C>, params: P, target: {
|
|
339
|
+
readonly stream: string;
|
|
486
340
|
readonly offset: string;
|
|
487
|
-
}, options?:
|
|
341
|
+
}, options?: AwaitFrontierOptions) => Effect.Effect<void, FollowFailure, Self>;
|
|
342
|
+
/** "The stream holding this row reflects `stream` up to `offset`." Offsets of one source are fixed-width strings. `closed` is present when the source is closed. */
|
|
343
|
+
declare const Frontier: Schema.Struct<{
|
|
344
|
+
readonly stream: Schema.String;
|
|
345
|
+
readonly offset: Schema.String;
|
|
346
|
+
readonly closed: Schema.optionalKey<Schema.Literal<true>>;
|
|
347
|
+
}>;
|
|
348
|
+
/** Spread into a State declaration's collections under any name. */
|
|
349
|
+
declare const frontier: {
|
|
350
|
+
readonly schema: Schema.Struct<{
|
|
351
|
+
readonly stream: Schema.String;
|
|
352
|
+
readonly offset: Schema.String;
|
|
353
|
+
readonly closed: Schema.optionalKey<Schema.Literal<true>>;
|
|
354
|
+
}>;
|
|
355
|
+
readonly key: "stream";
|
|
356
|
+
};
|
|
357
|
+
type Frontier = typeof Frontier.Type;
|
|
358
|
+
/**
|
|
359
|
+
* "A reader sees this write once it reflects `stream` up to `offset`." A server answers one after
|
|
360
|
+
* an append. It has the shape of a `Frontier` row, as a separate schema, so a collection declared
|
|
361
|
+
* with `Token` is not taken for a frontier collection.
|
|
362
|
+
*/
|
|
363
|
+
declare const Token: Schema.Struct<{
|
|
364
|
+
readonly stream: Schema.String;
|
|
365
|
+
readonly offset: Schema.String;
|
|
366
|
+
}>;
|
|
367
|
+
type Token = typeof Token.Type;
|
|
368
|
+
/** The token of an append to `address`: its stream id and the tail after the write. */
|
|
369
|
+
declare const token: (address: {
|
|
370
|
+
readonly id: string;
|
|
371
|
+
}, appended: Pick<AppendResult, "offset">) => Token;
|
|
488
372
|
declare namespace streamsy_d_exports {
|
|
489
|
-
export { Address, Any, Api,
|
|
373
|
+
export { Address, Any, Api, AwaitFrontierOptions, BytesClass, Class, CustomClass, FollowFrontierOptions, Frontier, FrontierActions, FrontierActionsOptions, FrontierBatch, FrontierEvent, FrontierItem, FrontierMessage, FrontierStreamCollections, Group, Host, JsonClass, Services, StateClass, Token, Wildcard, awaitFrontier, bytes, custom, followFrontier, frontier, frontierActions, frontierStream, frontierStreamCollections, group, json, state, token };
|
|
490
374
|
}
|
|
491
375
|
declare namespace streams_d_exports {
|
|
492
376
|
export { AppendFailure, AppendItems, Batch, Collected, CreateFailure, DecideSpec, Decided, Decision, Folded, FollowFailure, FollowOptions, HeadFailure, ReadFailure, RemoveFailure, append, collect, create, decide, fold, follow, head, items, read$1 as read, remove, session };
|
|
@@ -516,7 +400,7 @@ type AppendItems<A, O> = O extends {
|
|
|
516
400
|
* Append items to one stream. The error type lists only the rejections that the
|
|
517
401
|
* options make possible; a host that answers another one dies.
|
|
518
402
|
*/
|
|
519
|
-
declare const append: <A, RD, RE, const O extends AppendCallOptions = {}>(address: StreamAddress<A, RD, RE>, items: AppendItems<A
|
|
403
|
+
declare const append: <A, RD, RE, const O extends AppendCallOptions = {}>(address: StreamAddress<A, RD, RE>, items: AppendItems<NoInfer<A>, O>, options?: O | undefined) => Effect.Effect<AppendResult, AppendFailure<O>, RE | StreamsWriter>;
|
|
520
404
|
declare function read$1<A, RD, RE>(address: StreamAddress<A, RD, RE>, options?: ReadOptions$1): Stream.Stream<Batch<A>, ReadFailure, StreamsReader | RD>;
|
|
521
405
|
/** A folded value and the tail it was read up to. `offset` is this stream's CAS token. */
|
|
522
406
|
interface Folded<S> {
|
|
@@ -580,7 +464,8 @@ interface FollowOptions extends ReadOptions$1 {
|
|
|
580
464
|
readonly retry?: Schedule.Schedule<unknown>;
|
|
581
465
|
}
|
|
582
466
|
/**
|
|
583
|
-
* Catch up, then wait one readNext at a time
|
|
467
|
+
* Catch up, then wait one readNext at a time. A page with stored messages
|
|
468
|
+
* advances the reader even when all of its State changes are skipped.
|
|
584
469
|
* A read that fails with a retryable transport or storage fault is retried from the same
|
|
585
470
|
* offset, so a restart or network drop yields each item once.
|
|
586
471
|
*/
|
|
@@ -771,4 +656,4 @@ type HttpLiveMode = "long-poll" | "sse" | "websocket";
|
|
|
771
656
|
declare namespace index_d_exports {
|
|
772
657
|
export { Access, HttpLiveMode, HttpOptions, LIVE_PING, LIVE_PONG, LIVE_SOCKET_PROTOCOL, LiveBatch, LiveCloseCode, LiveControlFrame, LiveOpenFrame, ReadOptions, RoutesOptions, ShutdownSignal, ShutdownSignalService, app, checkReadOptions, closeCodeForStatus, controlFrame, isLiveUpgrade, layerShutdownSignal, nextCursor, openFrame, read, routes, securityHeaders, streamPath, upgradeRequired };
|
|
773
658
|
}
|
|
774
|
-
export {
|
|
659
|
+
export { HttpOptions as $, Batch as A, RemoveFailure as B, Access as C, Group as D, Any as E, Decision as F, streams_d_exports$1 as G, streamsy_d_exports as H, Folded as I, layer_d_exports as J, MemoryOptions as K, FollowFailure as L, CreateFailure as M, DecideSpec as N, Identifiers as O, Decided as P, streamPath as Q, HeadFailure as R, read as S, routes as T, producer_d_exports as U, streams_d_exports as V, durable_state_d_exports as W, compare as X, ZERO_OFFSET as Y, route_d_exports as Z, ShutdownSignalService as _, LIVE_SOCKET_PROTOCOL as a, ReadOptions as b, LiveControlFrame as c, controlFrame as d, app as et, isLiveUpgrade as f, ShutdownSignal as g, upgradeRequired as h, LIVE_PONG as i, Collected as j, AppendFailure as k, LiveOpenFrame as l, openFrame as m, HttpLiveMode as n, LiveBatch as o, nextCursor as p, ProtocolOptions as q, LIVE_PING as r, LiveCloseCode as s, index_d_exports as t, closeCodeForStatus as u, layerShutdownSignal as v, RoutesOptions as w, checkReadOptions as x, securityHeaders as y, ReadFailure as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { A as Batch, B as RemoveFailure, F as Decision, G as streams_d_exports, H as streamsy_d_exports, I as Folded, L as FollowFailure, M as CreateFailure, N as DecideSpec, P as Decided,
|
|
1
|
+
import { $ as CreateError, At as ProducerState, Bt as StreamsFault, C as OperationResults, Ct as ReadNextOptions, Dt as MessageWindow, E as StorageCapabilities, Et as ChangeSnapshot, Ft as StreamLifecycle, G as ReadNextResult, H as CreateResult, Ht as isRetryableFault, I as address_d_exports, It as StreamRecord, J as AppendConflict, K as ReadResult, Lt as DecodeFault, Mt as StoredMessage, Nt as StreamConfig, Ot as Offset, Pt as StreamId, Q as CreateConflictReason, Rt as EncodeFault, S as OperationResult, St as ProducerOptions, T as ProducerPrecondition, Tt as CreateOptions, U as HeadResult, Ut as isStreamsFault, V as AppendResult, Vt as TransportFault, W as ReadMessage, X as AppendErrorFor, Y as AppendError, Z as CreateConflict, _ as Mutation, _t as StreamGone, at as InvalidForkRequest, b as Mutations, bt as AppendCallOptions, ct as OffsetMismatch, dt as ReadError, et as ForkSourceNotFound, ft as ReadNextError, g as StorageShape, gt as StreamClosed, h as Storage, ht as StreamBusy, it as InvalidEpochSeq, jt as RecordPatch, kt as ProducerId, lt as ProducerGap, m as CommitBoundaryApi, mt as StaleEpoch, nt as InvalidAppendRequest, ot as InvalidReadRequest, p as CommitBoundary, pt as RemoveError, q as AppendBaseError, rt as InvalidCreateRequest, st as NotSupported, tt as HeadError, ut as ProtocolError, v as MutationApplied, vt as StreamNotFound, w as Operations, wt as ReadOptions, x as Operation, xt as AppendOptions, y as MutationRejected, yt as isProtocolError, zt as StorageFault } from "./projection-marks-DcO_5VNd.js";
|
|
2
|
+
import { A as Batch, B as RemoveFailure, F as Decision, G as streams_d_exports, H as streamsy_d_exports, I as Folded, L as FollowFailure, M as CreateFailure, N as DecideSpec, P as Decided, R as HeadFailure, U as producer_d_exports, W as durable_state_d_exports, X as compare, Y as ZERO_OFFSET, j as Collected, k as AppendFailure, t as index_d_exports, z as ReadFailure } from "./index-D-n48qXe.js";
|
|
3
3
|
export { AppendBaseError, type AppendCallOptions, AppendConflict, AppendError, AppendErrorFor, type AppendFailure, type AppendOptions, AppendResult, type Batch, ChangeSnapshot, type Collected, CommitBoundary, type CommitBoundaryApi, CreateConflict, CreateConflictReason, CreateError, type CreateFailure, type CreateOptions, CreateResult, type DecideSpec, type Decided, type Decision, DecodeFault, durable_state_d_exports as DurableState, EncodeFault, type Folded, type FollowFailure, ForkSourceNotFound, HeadError, type HeadFailure, type HeadResult, index_d_exports as Http, InvalidAppendRequest, InvalidCreateRequest, InvalidEpochSeq, InvalidForkRequest, InvalidReadRequest, streams_d_exports as MemoryStorage, MessageWindow, Mutation, MutationApplied, MutationRejected, Mutations, NotSupported, Offset, OffsetMismatch, Operation, OperationResult, OperationResults, Operations, producer_d_exports as Producer, ProducerGap, ProducerId, type ProducerOptions, ProducerPrecondition, ProducerState, ProtocolError, ReadError, type ReadFailure, type ReadMessage, ReadNextError, type ReadNextOptions, type ReadNextResult, type ReadOptions, type ReadResult, RecordPatch, RemoveError, type RemoveFailure, StaleEpoch, Storage, StorageCapabilities, StorageFault, type StorageShape, StoredMessage, address_d_exports as StreamAddress, StreamBusy, StreamClosed, StreamConfig, StreamGone, StreamId, StreamLifecycle, StreamNotFound, StreamRecord, StreamsFault, streamsy_d_exports as Streamsy, TransportFault, ZERO_OFFSET, compare, isProtocolError, isRetryableFault, isStreamsFault };
|