@streamsy/core 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{create-validation-C_aJJm5u.js → create-validation-NKP81BC0.js} +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +2 -2
- package/dist/{http-BNYNMGuk.js → http-aCMEaxro.js} +2 -2
- package/dist/{index-D-n48qXe.d.ts → index-DIx4D2t0.d.ts} +329 -152
- package/dist/index.d.ts +3 -3
- package/dist/index.js +52 -184
- package/dist/internal/index.d.ts +254 -26
- package/dist/internal/index.js +12 -3
- package/dist/{layer-pomDIajD.js → layer-DTOhxWkw.js} +19 -19
- package/dist/{layer-C-8GAL_W.js → layer-Dv_LBCgD.js} +15 -8
- package/dist/{program-DhW5In9U.js → program-gGLU50A1.js} +11 -9
- package/dist/protocol/index.d.ts +1 -2
- package/dist/protocol/index.js +3 -3
- package/dist/read-message-DP1UpEFl.js +660 -0
- package/dist/remote/index.d.ts +2 -2
- package/dist/remote/index.js +8 -8
- package/dist/{projection-marks-DcO_5VNd.d.ts → storage-xTb82JxJ.d.ts} +301 -462
- package/dist/{streamsy-IBFULoEr.js → streamsy-DiAjZWlT.js} +321 -94
- package/dist/testing/index.d.ts +7 -7
- package/dist/testing/index.js +28 -22
- package/package.json +4 -4
- package/dist/boundary-BTrhL8De.js +0 -371
- package/dist/read-message-CGHhOCMc.js +0 -193
|
@@ -1,6 +1,164 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as StreamsFault, A as ReadResult, D as HeadResult, E as CreateResult, F as ReadOptions$1, G as StreamId, I as StartOffset, M as AppendOptions, N as ProducerOptions, P as ReadNextOptions, Q as StorageFault, S as StorageOwner, T as AppendResult, X as EncodeFault, Y as DecodeFault, Z as InvalidStreamParams, _ as CollectionsEncodingServices, d as StateAddress, et as TransportFault, f as StreamAddress, g as CollectionsEncodedEvent, h as CollectionsDecodingServices, j as AppendCallOptions, k as ReadNextResult, m as Collections, v as CollectionsEvent, x as OwnerId, y as ValidCollections, z as Offset } from "./storage-xTb82JxJ.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
|
+
/** Private pure-policy input, promoted to protocol options in Batch 3. */
|
|
5
|
+
interface CreateOptions {
|
|
6
|
+
readonly contentType?: string;
|
|
7
|
+
readonly ttlSeconds?: number;
|
|
8
|
+
readonly expiresAt?: string;
|
|
9
|
+
readonly closed?: boolean;
|
|
10
|
+
readonly forkedFrom?: string;
|
|
11
|
+
readonly forkOffset?: string;
|
|
12
|
+
readonly forkSubOffset?: number;
|
|
13
|
+
readonly initialData?: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
declare const StreamNotFound_base: Schema.Class<StreamNotFound, Schema.TaggedStruct<"StreamNotFound", {
|
|
16
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
17
|
+
}>, import("effect/Cause").YieldableError>;
|
|
18
|
+
/** Protocol rejections. Optional create reasons reflect the public HTTP wire's loss of detail. */
|
|
19
|
+
declare class StreamNotFound extends StreamNotFound_base {
|
|
20
|
+
get message(): string;
|
|
21
|
+
}
|
|
22
|
+
declare const StreamGone_base: Schema.Class<StreamGone, Schema.TaggedStruct<"StreamGone", {
|
|
23
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
24
|
+
}>, import("effect/Cause").YieldableError>;
|
|
25
|
+
declare class StreamGone extends StreamGone_base {
|
|
26
|
+
get message(): string;
|
|
27
|
+
}
|
|
28
|
+
declare const StreamClosed_base: Schema.Class<StreamClosed, Schema.TaggedStruct<"StreamClosed", {
|
|
29
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
30
|
+
readonly offset: Schema.brand<Schema.String, "Offset">;
|
|
31
|
+
}>, import("effect/Cause").YieldableError>;
|
|
32
|
+
declare class StreamClosed extends StreamClosed_base {
|
|
33
|
+
get message(): string;
|
|
34
|
+
}
|
|
35
|
+
declare const OffsetMismatch_base: Schema.Class<OffsetMismatch, Schema.TaggedStruct<"OffsetMismatch", {
|
|
36
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
37
|
+
readonly expected: Schema.brand<Schema.String, "Offset">;
|
|
38
|
+
readonly actual: Schema.brand<Schema.String, "Offset">;
|
|
39
|
+
}>, import("effect/Cause").YieldableError>;
|
|
40
|
+
declare class OffsetMismatch extends OffsetMismatch_base {
|
|
41
|
+
get message(): string;
|
|
42
|
+
}
|
|
43
|
+
declare const AppendConflict_base: Schema.Class<AppendConflict, Schema.TaggedStruct<"AppendConflict", {
|
|
44
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
45
|
+
/**
|
|
46
|
+
* `sequence` when the `Stream-Seq` does not sort after the last one, `content-type` when the
|
|
47
|
+
* content type differs. Absent when the cause is unknown, for example from a server that does
|
|
48
|
+
* not send `stream-conflict-reason`.
|
|
49
|
+
*/
|
|
50
|
+
readonly reason: Schema.optionalKey<Schema.Literals<readonly ["sequence", "content-type"]>>;
|
|
51
|
+
readonly message: Schema.String;
|
|
52
|
+
}>, import("effect/Cause").YieldableError>;
|
|
53
|
+
declare class AppendConflict extends AppendConflict_base {}
|
|
54
|
+
declare const StreamBusy_base: Schema.Class<StreamBusy, Schema.TaggedStruct<"StreamBusy", {
|
|
55
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
56
|
+
}>, import("effect/Cause").YieldableError>;
|
|
57
|
+
declare class StreamBusy extends StreamBusy_base {
|
|
58
|
+
get message(): string;
|
|
59
|
+
}
|
|
60
|
+
declare const StaleEpoch_base: Schema.Class<StaleEpoch, Schema.TaggedStruct<"StaleEpoch", {
|
|
61
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
62
|
+
readonly currentEpoch: Schema.Finite;
|
|
63
|
+
}>, import("effect/Cause").YieldableError>;
|
|
64
|
+
declare class StaleEpoch extends StaleEpoch_base {
|
|
65
|
+
get message(): string;
|
|
66
|
+
}
|
|
67
|
+
declare const ProducerGap_base: Schema.Class<ProducerGap, Schema.TaggedStruct<"ProducerGap", {
|
|
68
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
69
|
+
readonly expectedSeq: Schema.Finite;
|
|
70
|
+
readonly receivedSeq: Schema.Finite;
|
|
71
|
+
}>, import("effect/Cause").YieldableError>;
|
|
72
|
+
declare class ProducerGap extends ProducerGap_base {
|
|
73
|
+
get message(): string;
|
|
74
|
+
}
|
|
75
|
+
declare const InvalidEpochSeq_base: Schema.Class<InvalidEpochSeq, Schema.TaggedStruct<"InvalidEpochSeq", {
|
|
76
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
77
|
+
}>, import("effect/Cause").YieldableError>;
|
|
78
|
+
declare class InvalidEpochSeq extends InvalidEpochSeq_base {
|
|
79
|
+
get message(): string;
|
|
80
|
+
}
|
|
81
|
+
declare const InvalidAppendRequest_base: Schema.Class<InvalidAppendRequest, Schema.TaggedStruct<"InvalidAppendRequest", {
|
|
82
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
83
|
+
readonly message: Schema.String;
|
|
84
|
+
}>, import("effect/Cause").YieldableError>;
|
|
85
|
+
declare class InvalidAppendRequest extends InvalidAppendRequest_base {}
|
|
86
|
+
declare const InvalidCreateRequest_base: Schema.Class<InvalidCreateRequest, Schema.TaggedStruct<"InvalidCreateRequest", {
|
|
87
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
88
|
+
readonly message: Schema.String;
|
|
89
|
+
}>, import("effect/Cause").YieldableError>;
|
|
90
|
+
declare class InvalidCreateRequest extends InvalidCreateRequest_base {}
|
|
91
|
+
declare const CreateConflict_base: Schema.Class<CreateConflict, Schema.TaggedStruct<"CreateConflict", {
|
|
92
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
93
|
+
readonly reason: Schema.optionalKey<Schema.Literals<readonly ["config-mismatch", "soft-deleted", "fork-content-type", "fork-source-soft-deleted"]>>;
|
|
94
|
+
readonly message: Schema.String;
|
|
95
|
+
}>, import("effect/Cause").YieldableError>;
|
|
96
|
+
declare class CreateConflict extends CreateConflict_base {}
|
|
97
|
+
declare const ForkSourceNotFound_base: Schema.Class<ForkSourceNotFound, Schema.TaggedStruct<"ForkSourceNotFound", {
|
|
98
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
99
|
+
readonly source: Schema.brand<Schema.String, "StreamId">;
|
|
100
|
+
}>, import("effect/Cause").YieldableError>;
|
|
101
|
+
declare class ForkSourceNotFound extends ForkSourceNotFound_base {
|
|
102
|
+
get message(): string;
|
|
103
|
+
}
|
|
104
|
+
declare const InvalidForkRequest_base: Schema.Class<InvalidForkRequest, Schema.TaggedStruct<"InvalidForkRequest", {
|
|
105
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
106
|
+
readonly message: Schema.String;
|
|
107
|
+
}>, import("effect/Cause").YieldableError>;
|
|
108
|
+
declare class InvalidForkRequest extends InvalidForkRequest_base {}
|
|
109
|
+
declare const NotSupported_base: Schema.Class<NotSupported, Schema.TaggedStruct<"NotSupported", {
|
|
110
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
111
|
+
readonly feature: Schema.String;
|
|
112
|
+
}>, import("effect/Cause").YieldableError>;
|
|
113
|
+
declare class NotSupported extends NotSupported_base {
|
|
114
|
+
get message(): string;
|
|
115
|
+
}
|
|
116
|
+
type CreateConflictReason = NonNullable<CreateConflict["reason"]>;
|
|
117
|
+
type HeadError = StreamNotFound | StreamGone;
|
|
118
|
+
declare const InvalidReadRequest_base: Schema.Class<InvalidReadRequest, Schema.TaggedStruct<"InvalidReadRequest", {
|
|
119
|
+
readonly id: Schema.brand<Schema.String, "StreamId">;
|
|
120
|
+
readonly message: Schema.String;
|
|
121
|
+
}>, import("effect/Cause").YieldableError>;
|
|
122
|
+
declare class InvalidReadRequest extends InvalidReadRequest_base {}
|
|
123
|
+
type ReadError = StreamNotFound | StreamGone | InvalidReadRequest;
|
|
124
|
+
type ReadNextError = ReadError | NotSupported;
|
|
125
|
+
type CreateError = CreateConflict | InvalidCreateRequest | ForkSourceNotFound | InvalidForkRequest | NotSupported;
|
|
126
|
+
/**
|
|
127
|
+
* Append rejections that any call can get, whatever its options. The memory and
|
|
128
|
+
* storage hosts never answer `NotSupported`; the remote client does when the server
|
|
129
|
+
* or its own capabilities refuse a feature.
|
|
130
|
+
*/
|
|
131
|
+
type AppendBaseError = StreamNotFound | StreamGone | StreamClosed | StreamBusy | AppendConflict | NotSupported;
|
|
132
|
+
type AppendError = AppendBaseError | InvalidAppendRequest | OffsetMismatch | StaleEpoch | ProducerGap | InvalidEpochSeq;
|
|
133
|
+
/**
|
|
134
|
+
* The append rejections that call options `O` make possible. `OffsetMismatch`
|
|
135
|
+
* needs `expectedOffset`, and the producer rejections need `producer`. An option
|
|
136
|
+
* that may be set counts as set.
|
|
137
|
+
*/
|
|
138
|
+
type AppendErrorFor<O> = AppendBaseError | (true extends MaySet<O, "expectedOffset"> ? OffsetMismatch : never) | (true extends MaySet<O, "producer"> ? StaleEpoch | ProducerGap : never);
|
|
139
|
+
/** Whether options `O` may hold a value for `K`. A union holds it if any member may. */
|
|
140
|
+
type MaySet<O, K extends PropertyKey> = O extends unknown ? K extends keyof O ? [Exclude<O[K], undefined>] extends [never] ? false : true : false : never;
|
|
141
|
+
type RemoveError = StreamNotFound | StreamGone | StreamBusy;
|
|
142
|
+
type ProtocolError = HeadError | ReadNextError | CreateError | AppendError | RemoveError;
|
|
143
|
+
/** The HTTP edge answers every protocol rejection through one mapper, so it needs one guard. */
|
|
144
|
+
declare const isProtocolError: (error: {
|
|
145
|
+
readonly _tag: string;
|
|
146
|
+
}) => error is ProtocolError;
|
|
147
|
+
interface Reader<E = StorageFault> {
|
|
148
|
+
readonly head: (id: StreamId) => Effect.Effect<HeadResult, HeadError | E>;
|
|
149
|
+
readonly read: (id: StreamId, options?: ReadOptions$1) => Effect.Effect<ReadResult, ReadError | E>;
|
|
150
|
+
readonly readNext: (id: StreamId, options: ReadNextOptions) => Effect.Effect<ReadNextResult, ReadNextError | E>;
|
|
151
|
+
}
|
|
152
|
+
interface Writer<E = StorageFault> {
|
|
153
|
+
readonly create: (id: StreamId, options?: CreateOptions) => Effect.Effect<CreateResult, CreateError | E>;
|
|
154
|
+
readonly fork: (id: StreamId, source: StreamId, options?: Omit<CreateOptions, "forkedFrom">) => Effect.Effect<CreateResult, CreateError | E>;
|
|
155
|
+
readonly append: (id: StreamId, options: AppendOptions) => Effect.Effect<AppendResult, AppendError | E>;
|
|
156
|
+
readonly remove: (id: StreamId) => Effect.Effect<void, RemoveError | E>;
|
|
157
|
+
}
|
|
158
|
+
declare const StreamsReader_base: Context.ServiceClass<StreamsReader, "@streamsy/core/StreamsReader", Reader<StorageFault | TransportFault>>;
|
|
159
|
+
declare class StreamsReader extends StreamsReader_base {}
|
|
160
|
+
declare const StreamsWriter_base: Context.ServiceClass<StreamsWriter, "@streamsy/core/StreamsWriter", Writer<StorageFault | TransportFault>>;
|
|
161
|
+
declare class StreamsWriter extends StreamsWriter_base {}
|
|
4
162
|
interface HttpOptions {
|
|
5
163
|
readonly pathPrefix?: string;
|
|
6
164
|
/** Lifetime of an SSE response. Default 60 seconds. */
|
|
@@ -24,7 +182,7 @@ declare const streamPath: (pathPrefix?: string) => {
|
|
|
24
182
|
canonicalizeForkSource: (source: string) => string;
|
|
25
183
|
};
|
|
26
184
|
declare namespace route_d_exports {
|
|
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 };
|
|
185
|
+
export { BytesOptions, ExactTemplateParams, IsSingleton, LiteralTemplate, Matcher, ParamCodecs, Params, ParamsOption, PathSchema, StateRoute, StreamRoute, bytes$1 as bytes, custom$1 as custom, json$1 as json, state$1 as state };
|
|
28
186
|
}
|
|
29
187
|
/**
|
|
30
188
|
* Inert id stream. Constructing a route acquires no service and no resource.
|
|
@@ -42,7 +200,10 @@ interface StreamRoute<RouteParams, A, RD = never, RE = never, Template extends s
|
|
|
42
200
|
readonly match: (id: string) => boolean;
|
|
43
201
|
/** The primitive. `None` when the id does not match or a parameter fails to decode. */
|
|
44
202
|
readonly parse: (id: string) => Option.Option<RouteParams>;
|
|
45
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Build the address. `parse(address(params).id)` must be `Some(params)`. Throws a `RangeError`
|
|
205
|
+
* when a param value cannot form an id; its `cause` is an `InvalidStreamParams`.
|
|
206
|
+
*/
|
|
46
207
|
readonly address: (params: RouteParams) => StreamAddress<A, RD, RE>;
|
|
47
208
|
}
|
|
48
209
|
/** The stream codecs exposed to HTTP path decoding. */
|
|
@@ -67,30 +228,62 @@ interface Matcher {
|
|
|
67
228
|
type ParamCodecs = Readonly<Record<string, Schema.Codec<unknown, string>>>;
|
|
68
229
|
type Params<Codecs extends ParamCodecs> = { readonly [Name in keyof Codecs]: Codecs[Name]["Type"]; };
|
|
69
230
|
type TemplateNames<Template extends string> = Template extends `${string}:${infer Name}/${infer Rest}` ? Name | TemplateNames<Rest> : Template extends `${string}:${infer Name}` ? Name : never;
|
|
70
|
-
/**
|
|
71
|
-
type
|
|
72
|
-
|
|
231
|
+
/** The compile error for a template parameter without a codec: the message names it. */
|
|
232
|
+
type MissingCodecs<Names extends PropertyKey> = { readonly [Name in Names]: "Add a codec for this template parameter to `params`"; };
|
|
233
|
+
/** The compile error for a codec that names no template parameter: the message names it. */
|
|
234
|
+
type ExtraCodecs<Names extends PropertyKey> = { readonly [Name in Names]: "This codec names no `:name` in the template"; };
|
|
235
|
+
/**
|
|
236
|
+
* The compile error for a template whose type is the widened `string`. The parameter
|
|
237
|
+
* check and the choice between `singleton` and `at` both read the template type, so a
|
|
238
|
+
* template must be a string literal. A template literal with a `${number}` or `${string}`
|
|
239
|
+
* hole is accepted: the names in its literal parts are checked at compile time, and a
|
|
240
|
+
* hole whose value adds a `:name` throws a `RangeError` when the route is built.
|
|
241
|
+
*/
|
|
242
|
+
type LiteralTemplate<Template extends string> = string extends Template ? "The template must be a string literal: write it inline, or declare it `as const`" : unknown;
|
|
243
|
+
/**
|
|
244
|
+
* Every `:name` must have a codec, and every codec must appear in the template. A mismatch
|
|
245
|
+
* resolves to a record whose keys are the wrong names and whose values say what to fix.
|
|
246
|
+
*/
|
|
247
|
+
type ExactTemplateParams<Template extends string, Codecs extends ParamCodecs> = string extends Template ? unknown : [Exclude<TemplateNames<Template>, keyof Codecs>] extends [never] ? [Exclude<keyof Codecs, TemplateNames<Template>>] extends [never] ? unknown : ExtraCodecs<Exclude<keyof Codecs, TemplateNames<Template>>> : MissingCodecs<Exclude<TemplateNames<Template>, keyof Codecs>>;
|
|
248
|
+
/**
|
|
249
|
+
* True when the template is known and names no parameter: a singleton stream. A custom
|
|
250
|
+
* route is never a singleton. The template constructors reject a widened `string`
|
|
251
|
+
* template, so the `false` branch for `string` only covers a cast or a custom route.
|
|
252
|
+
*/
|
|
253
|
+
type IsSingleton<Template extends string> = string extends Template ? false : [TemplateNames<Template>] extends [never] ? true : false;
|
|
254
|
+
/**
|
|
255
|
+
* The `params` option of a template route. It is optional for a singleton template and
|
|
256
|
+
* required when the template names a parameter. `params: {}` stays legal on a singleton.
|
|
257
|
+
*/
|
|
258
|
+
type ParamsOption<Template extends string, Codecs extends ParamCodecs> = IsSingleton<Template> extends true ? {
|
|
259
|
+
readonly params?: Codecs & ExactTemplateParams<Template, Codecs>;
|
|
260
|
+
} : {
|
|
73
261
|
readonly params: Codecs & ExactTemplateParams<Template, Codecs>;
|
|
262
|
+
};
|
|
263
|
+
/** The options of `bytes`. A singleton template needs no options, so the argument is optional. */
|
|
264
|
+
type BytesOptions<Template extends string, Codecs extends ParamCodecs> = IsSingleton<Template> extends true ? [options?: ParamsOption<Template, Codecs> & {
|
|
265
|
+
readonly contentType?: string;
|
|
266
|
+
}] : [options: ParamsOption<Template, Codecs> & {
|
|
267
|
+
readonly contentType?: string;
|
|
268
|
+
}];
|
|
269
|
+
declare function json$1<const Template extends string, Codecs extends ParamCodecs = {}, A = never, I = never, RD = never, RE = never>(template: Template & LiteralTemplate<Template>, options: ParamsOption<Template, Codecs> & {
|
|
74
270
|
readonly schema: Schema.Codec<A, I, RD, RE>;
|
|
75
271
|
}): StreamRoute<Params<Codecs>, A, RD, RE, Template> & WithPathSchema<Params<Codecs>>;
|
|
76
|
-
declare function state$1<const Template extends string, Codecs extends ParamCodecs, const C extends Collections>(template: Template
|
|
77
|
-
readonly params: Codecs & ExactTemplateParams<Template, Codecs>;
|
|
272
|
+
declare function state$1<const Template extends string, Codecs extends ParamCodecs = {}, const C extends Collections = {}>(template: Template & LiteralTemplate<Template>, options: ParamsOption<Template, Codecs> & {
|
|
78
273
|
readonly collections: C & ValidCollections<C>;
|
|
79
274
|
readonly strict?: boolean;
|
|
80
275
|
}): StateRoute<Params<Codecs>, C, Template> & WithPathSchema<Params<Codecs>> & WithParamCodecs<Codecs>;
|
|
81
|
-
declare function bytes$1<const Template extends string, Codecs extends ParamCodecs>(template: Template
|
|
82
|
-
readonly params: Codecs & ExactTemplateParams<Template, Codecs>;
|
|
83
|
-
readonly contentType?: string;
|
|
84
|
-
}): StreamRoute<Params<Codecs>, Uint8Array, never, never, Template> & WithPathSchema<Params<Codecs>>;
|
|
276
|
+
declare function bytes$1<const Template extends string, Codecs extends ParamCodecs = {}>(template: Template & LiteralTemplate<Template>, ...[options]: BytesOptions<Template, Codecs>): StreamRoute<Params<Codecs>, Uint8Array, never, never, Template> & WithPathSchema<Params<Codecs>>;
|
|
85
277
|
/** Escape hatch for a grammar a template cannot express, such as a regex stream. */
|
|
86
278
|
declare function custom$1<RouteParams, A, RD, RE>(options: {
|
|
87
279
|
readonly parse: (id: string) => Option.Option<RouteParams>;
|
|
88
280
|
readonly address: (params: RouteParams) => StreamAddress<A, RD, RE>;
|
|
89
281
|
}): StreamRoute<RouteParams, A, RD, RE>;
|
|
90
|
-
declare const ZERO_OFFSET: string & import("effect/Brand").Brand<"Offset">;
|
|
282
|
+
declare const ZERO_OFFSET: string & import("effect/Brand").Brand<"Offset"> & import("effect/Brand").Brand<"StreamsyOffset">;
|
|
283
|
+
/** Lexicographic order. The Durable Streams protocol guarantees it for offsets of one stream. */
|
|
91
284
|
declare const compare: (a: string, b: string) => number;
|
|
92
285
|
/** One host-triggered sweep; the host owns scheduling and cancellation. */
|
|
93
|
-
declare const expireDue: () => Effect.Effect<void, StorageFault,
|
|
286
|
+
declare const expireDue: () => Effect.Effect<void, StorageFault, StorageOwner>;
|
|
94
287
|
declare namespace layer_d_exports {
|
|
95
288
|
export { ProtocolOptions, bind, expireDue, layer$1 as layer };
|
|
96
289
|
}
|
|
@@ -99,7 +292,7 @@ interface ProtocolOptions {
|
|
|
99
292
|
readonly readLimit?: number;
|
|
100
293
|
readonly longPollTimeoutMs?: number;
|
|
101
294
|
}
|
|
102
|
-
declare const layer$1: (options?: ProtocolOptions) => Layer.Layer<StreamsReader | StreamsWriter, never,
|
|
295
|
+
declare const layer$1: (options?: ProtocolOptions) => Layer.Layer<StreamsReader | StreamsWriter, never, StorageOwner>;
|
|
103
296
|
interface MemoryOptions {
|
|
104
297
|
readonly constrained?: boolean;
|
|
105
298
|
readonly pollIntervalMs?: number;
|
|
@@ -110,85 +303,9 @@ declare namespace streams_d_exports$1 {
|
|
|
110
303
|
/** Options for `layer` and `layerProtocol`. */
|
|
111
304
|
interface Options extends MemoryOptions, ProtocolOptions {}
|
|
112
305
|
/** Generic reader and writer over memory storage, for protocol tools. */
|
|
113
|
-
declare const layerProtocol: (options?: Options) => Layer.Layer<
|
|
114
|
-
/** Memory host. Streams and their feeds share the exposed storage
|
|
115
|
-
declare function layer<const Keys extends ReadonlyArray<Any>>(group: Group<Keys>, options?: Options): Layer.Layer<
|
|
116
|
-
declare namespace durable_state_d_exports {
|
|
117
|
-
export { Change, ChangeHeaders, Delete, Entry, Materialized, Rows, Upsert, changes, materialize, materialized, remove$1 as remove, upsert };
|
|
118
|
-
}
|
|
119
|
-
interface ChangeHeaders {
|
|
120
|
-
readonly txid?: string;
|
|
121
|
-
readonly timestamp?: string;
|
|
122
|
-
readonly from?: string;
|
|
123
|
-
}
|
|
124
|
-
type Operation<A, Type extends string> = Data.TaggedEnum<{
|
|
125
|
-
Upsert: {
|
|
126
|
-
readonly type: Type;
|
|
127
|
-
readonly value: A;
|
|
128
|
-
readonly headers?: ChangeHeaders;
|
|
129
|
-
};
|
|
130
|
-
Delete: {
|
|
131
|
-
readonly type: Type;
|
|
132
|
-
readonly key: string | number;
|
|
133
|
-
readonly oldValue?: A;
|
|
134
|
-
readonly headers?: ChangeHeaders;
|
|
135
|
-
};
|
|
136
|
-
}>;
|
|
137
|
-
type Upsert<A, Type extends string = string> = Data.TaggedEnum.Value<Operation<A, Type>, "Upsert">;
|
|
138
|
-
type Delete<A, Type extends string = string> = Data.TaggedEnum.Value<Operation<A, Type>, "Delete">;
|
|
139
|
-
/** A pending change for one of the collections in `C`. */
|
|
140
|
-
type Change<C extends Collections> = { [K in keyof C & string]: Upsert<C[K]["schema"]["Type"], K> | Delete<C[K]["schema"]["Type"], K>; }[keyof C & string];
|
|
141
|
-
/**
|
|
142
|
-
* One entry for `changes`: a pending change, or a State control such as
|
|
143
|
-
* `StreamAddress.reset()`.
|
|
144
|
-
*/
|
|
145
|
-
type Entry<C extends Collections> = Change<C> | StateControl;
|
|
146
|
-
/** Describe an upsert into a collection. The key is read from the value. */
|
|
147
|
-
declare const upsert: <const Type extends string, A>(type: Type, value: A, options?: {
|
|
148
|
-
readonly headers?: ChangeHeaders;
|
|
149
|
-
}) => Upsert<A, Type>;
|
|
150
|
-
/** Describe a delete from a collection by key. An `oldValue` is written as `old_value`. */
|
|
151
|
-
declare const remove$1: <const Type extends string, A = never>(type: Type, key: string | number, options?: {
|
|
152
|
-
readonly oldValue?: A;
|
|
153
|
-
readonly headers?: ChangeHeaders;
|
|
154
|
-
}) => Delete<NoInfer<A>, Type>;
|
|
155
|
-
/**
|
|
156
|
-
* Stamp Durable State changes with their key and headers. With an `offset`, each
|
|
157
|
-
* change gets that offset and a default txid of `<offset>:<index>`. A control
|
|
158
|
-
* entry passes through. It gets the `offset` only when it has none of its own.
|
|
159
|
-
*/
|
|
160
|
-
declare function changes<C extends Collections, RD, RE>(address: StateAddress<C, RD, RE>, options: {
|
|
161
|
-
readonly offset?: string;
|
|
162
|
-
}, entries: Array.NonEmptyReadonlyArray<Entry<C>>): Array.NonEmptyReadonlyArray<CollectionsEvent<C>>;
|
|
163
|
-
declare function changes<C extends Collections, RD, RE>(address: StateAddress<C, RD, RE>, options: {
|
|
164
|
-
readonly offset?: string;
|
|
165
|
-
}, entries: ReadonlyArray<Entry<C>>): ReadonlyArray<CollectionsEvent<C>>;
|
|
166
|
-
/** The rows of one collection, by State key. */
|
|
167
|
-
type Rows<C extends Collections> = { readonly [K in keyof C & string]: ReadonlyMap<string, C[K]["schema"]["Type"]>; };
|
|
168
|
-
/**
|
|
169
|
-
* The materialized state of a Durable State stream: the latest row for each key
|
|
170
|
-
* of each collection. `snapshot` holds the keys seen since an open
|
|
171
|
-
* `snapshot-start`, and is `undefined` outside a snapshot.
|
|
172
|
-
*/
|
|
173
|
-
interface Materialized<C extends Collections> {
|
|
174
|
-
readonly rows: Rows<C>;
|
|
175
|
-
readonly snapshot: ReadonlySet<string> | undefined;
|
|
176
|
-
}
|
|
177
|
-
/** Empty materialized state for the collections of `address`. */
|
|
178
|
-
declare function materialized<C extends Collections>(address: {
|
|
179
|
-
readonly collections: C;
|
|
180
|
-
}): Materialized<C>;
|
|
181
|
-
/**
|
|
182
|
-
* Fold State events into materialized state, with the State protocol rules:
|
|
183
|
-
*
|
|
184
|
-
* - `upsert` sets the row of its key, and `delete` removes it.
|
|
185
|
-
* - `reset` clears every collection.
|
|
186
|
-
* - `snapshot-end` removes each row that no change since `snapshot-start` named.
|
|
187
|
-
* A snapshot may span several calls.
|
|
188
|
-
*
|
|
189
|
-
* The input state is not changed. Only the collections that `events` touch are copied.
|
|
190
|
-
*/
|
|
191
|
-
declare function materialize<C extends Collections>(state: Materialized<C>, events: Iterable<CollectionsEvent<C>>): Materialized<C>;
|
|
306
|
+
declare const layerProtocol: (options?: Options) => Layer.Layer<StorageOwner | StreamsReader | StreamsWriter, never, never>;
|
|
307
|
+
/** Memory host. Streams and their feeds share the exposed storage owner. */
|
|
308
|
+
declare function layer<const Keys extends ReadonlyArray<Any>>(group: Group<Keys>, options?: Options): Layer.Layer<StorageOwner | Host<Group<Keys>>>;
|
|
192
309
|
declare namespace producer_d_exports {
|
|
193
310
|
export { Position, next };
|
|
194
311
|
}
|
|
@@ -219,6 +336,8 @@ type FrontierEvent = CollectionsEvent<FrontierStreamCollections>;
|
|
|
219
336
|
* A client that decodes raw JSON pages uses it in place of a typed service.
|
|
220
337
|
*/
|
|
221
338
|
declare const FrontierMessage: Schema.Codec<FrontierEvent, CollectionsEncodedEvent<FrontierStreamCollections>>;
|
|
339
|
+
/** The options of `frontierStream`. A singleton template needs no options, so the argument is optional. */
|
|
340
|
+
type FrontierStreamOptions<Template extends string, C extends ParamCodecs> = IsSingleton<Template> extends true ? [options?: ParamsOption<Template, C>] : [options: ParamsOption<Template, C>];
|
|
222
341
|
/**
|
|
223
342
|
* Declare a frontier stream: a State stream of `Frontier` rows at a template.
|
|
224
343
|
*
|
|
@@ -228,12 +347,12 @@ declare const FrontierMessage: Schema.Codec<FrontierEvent, CollectionsEncodedEve
|
|
|
228
347
|
* }) {}
|
|
229
348
|
* ```
|
|
230
349
|
*
|
|
350
|
+
* A template without `:name` declares a singleton frontier stream and may omit `params`,
|
|
351
|
+
* and so the whole options argument: `Streamsy.frontierStream<Wake>()("App/Wake", "wake")`.
|
|
231
352
|
* The declaration names no sources. A `Projection.frontier` binding links one
|
|
232
353
|
* source stream to one frontier stream, with params of its own.
|
|
233
354
|
*/
|
|
234
|
-
declare const frontierStream: <Self>() => <const Name extends string, const Template extends string, C extends ParamCodecs>(name: Name, template: Template
|
|
235
|
-
readonly params: C & ExactTemplateParams<Template, C>;
|
|
236
|
-
}) => StateClass<Self, Name, Template, C, {
|
|
355
|
+
declare const frontierStream: <Self>() => <const Name extends string, const Template extends string, C extends ParamCodecs = {}>(name: Name, template: Template & LiteralTemplate<Template>, ...[options]: FrontierStreamOptions<Template, C>) => StateClass<Self, Name, Template, C, {
|
|
237
356
|
readonly stream: {
|
|
238
357
|
readonly schema: Schema.Struct<{
|
|
239
358
|
readonly stream: Schema.String;
|
|
@@ -248,8 +367,10 @@ type FrontierItem = Data.TaggedEnum<{
|
|
|
248
367
|
/** Read `stream` from `from` up to at least `offset`, then save its cursor. */
|
|
249
368
|
Dirty: {
|
|
250
369
|
readonly stream: StreamId;
|
|
251
|
-
|
|
252
|
-
readonly
|
|
370
|
+
/** The saved cursor of `stream`, or `-1`. Pass it as the `offset` of a read. */
|
|
371
|
+
readonly from: StartOffset;
|
|
372
|
+
/** The position the frontier row reports for `stream`. */
|
|
373
|
+
readonly offset: Offset;
|
|
253
374
|
readonly closed: boolean;
|
|
254
375
|
};
|
|
255
376
|
/** The stream was removed. Drop its cursor and its local data. */
|
|
@@ -267,8 +388,8 @@ type FrontierItem = Data.TaggedEnum<{
|
|
|
267
388
|
declare const FrontierItem: Data.TaggedEnum.Constructor<{
|
|
268
389
|
readonly _tag: "Dirty";
|
|
269
390
|
readonly stream: StreamId;
|
|
270
|
-
readonly from:
|
|
271
|
-
readonly offset:
|
|
391
|
+
readonly from: StartOffset;
|
|
392
|
+
readonly offset: Offset;
|
|
272
393
|
readonly closed: boolean;
|
|
273
394
|
} | {
|
|
274
395
|
readonly _tag: "Removed";
|
|
@@ -282,20 +403,20 @@ declare const FrontierItem: Data.TaggedEnum.Constructor<{
|
|
|
282
403
|
/** One batch of frontier actions. Save `offset` as the frontier cursor after every item is handled. */
|
|
283
404
|
interface FrontierBatch {
|
|
284
405
|
readonly items: ReadonlyArray<FrontierItem>;
|
|
285
|
-
readonly offset:
|
|
406
|
+
readonly offset: Offset;
|
|
286
407
|
readonly upToDate: boolean;
|
|
287
408
|
}
|
|
288
409
|
interface FollowFrontierOptions extends Omit<FollowOptions, "offset"> {
|
|
289
410
|
/** The saved frontier stream cursor. Default: `-1`, a cold start. */
|
|
290
|
-
readonly from?:
|
|
411
|
+
readonly from?: StartOffset;
|
|
291
412
|
/** Saved source cursors. Read again for each batch, so the consumer may update the map. */
|
|
292
|
-
readonly cursors: ReadonlyMap<StreamId,
|
|
413
|
+
readonly cursors: ReadonlyMap<StreamId, Offset>;
|
|
293
414
|
}
|
|
294
415
|
/** Follow options for a wait, including a saved frontier stream cursor. */
|
|
295
416
|
type AwaitFrontierOptions = Omit<FollowFrontierOptions, "cursors">;
|
|
296
417
|
interface FrontierActionsOptions {
|
|
297
418
|
/** Saved source cursors. A missing entry starts from `-1`. */
|
|
298
|
-
readonly cursors: ReadonlyMap<StreamId,
|
|
419
|
+
readonly cursors: ReadonlyMap<StreamId, Offset>;
|
|
299
420
|
/** The streams of a snapshot that an earlier batch left open. */
|
|
300
421
|
readonly snapshot?: ReadonlySet<StreamId> | undefined;
|
|
301
422
|
}
|
|
@@ -322,23 +443,19 @@ declare function frontierActions(events: ReadonlyArray<FrontierEvent>, options:
|
|
|
322
443
|
* last; a stop between the two reads the same rows again, and the offset check
|
|
323
444
|
* skips the streams that were already read.
|
|
324
445
|
*/
|
|
325
|
-
declare function followFrontier<
|
|
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
|
-
};
|
|
446
|
+
declare function followFrontier<E, RD, RE>(stream: StreamHandle<FrontierEvent, E, RD, RE>, options: FollowFrontierOptions): Stream.Stream<FrontierBatch, FollowFailure | E, RD>;
|
|
330
447
|
/**
|
|
331
|
-
* Wait until the frontier row for `stream` reaches `offset`. `
|
|
332
|
-
* frontier stream or any State
|
|
333
|
-
* other collections are read and skipped.
|
|
334
|
-
* services. Callers choose their own timeout. Removed source ids
|
|
335
|
-
* reused; a new generation needs a new stream or a State reset. Without
|
|
448
|
+
* Wait until the frontier row for `stream` reaches `offset`. `stream` is the handle of a
|
|
449
|
+
* frontier stream or of any State stream with one `Streamsy.frontier` collection; the
|
|
450
|
+
* other collections are read and skipped. Another stream dies with a `RangeError`. Works
|
|
451
|
+
* with local and remote services. Callers choose their own timeout. Removed source ids
|
|
452
|
+
* must not be reused; a new generation needs a new stream or a State reset. Without
|
|
336
453
|
* `options.from`, each call reads the history from the start.
|
|
337
454
|
*/
|
|
338
|
-
declare const awaitFrontier: <
|
|
455
|
+
declare const awaitFrontier: <C extends Collections, E, RD, RE>(stream: StreamHandle<CollectionsEvent<C>, E, RD, RE>, target: {
|
|
339
456
|
readonly stream: string;
|
|
340
457
|
readonly offset: string;
|
|
341
|
-
}, options?: AwaitFrontierOptions) => Effect.Effect<void, FollowFailure,
|
|
458
|
+
}, options?: AwaitFrontierOptions) => Effect.Effect<void, FollowFailure | E, RD>;
|
|
342
459
|
/** "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
460
|
declare const Frontier: Schema.Struct<{
|
|
344
461
|
readonly stream: Schema.String;
|
|
@@ -370,10 +487,10 @@ declare const token: (address: {
|
|
|
370
487
|
readonly id: string;
|
|
371
488
|
}, appended: Pick<AppendResult, "offset">) => Token;
|
|
372
489
|
declare namespace streamsy_d_exports {
|
|
373
|
-
export { Address, Any,
|
|
490
|
+
export { Address, Any, AwaitFrontierOptions, Bindings, BytesClass, Class, CustomClass, FollowFrontierOptions, ForkableStreamHandle, Frontier, FrontierActions, FrontierActionsOptions, FrontierBatch, FrontierEvent, FrontierItem, FrontierMessage, FrontierStreamCollections, FrontierStreamOptions, Group, Host, JsonClass, Services, StateClass, StreamFamily, StreamHandle, StreamService, Token, Wildcard, awaitFrontier, bytes, custom, followFrontier, frontier, frontierActions, frontierStream, frontierStreamCollections, group, json, state, token };
|
|
374
491
|
}
|
|
375
492
|
declare namespace streams_d_exports {
|
|
376
|
-
export { AppendFailure, AppendItems, Batch, Collected, CreateFailure, DecideSpec, Decided, Decision, Folded, FollowFailure, FollowOptions, HeadFailure, ReadFailure, RemoveFailure, append, collect, create, decide, fold, follow, head,
|
|
493
|
+
export { AppendFailure, AppendItems, Batch, Collected, CreateFailure, DecideSpec, Decided, Decision, Folded, FollowFailure, FollowOptions, HeadFailure, LiveBatch$1 as LiveBatch, ReadFailure, RemoveFailure, append, collect, create, decide, fold, follow, head, read$1 as read, readNext, remove };
|
|
377
494
|
}
|
|
378
495
|
/** Full toolkit failures, including protocol rejections and infrastructure faults. */
|
|
379
496
|
type ReadFailure = StreamNotFound | StreamGone | InvalidReadRequest | StreamsFault | DecodeFault;
|
|
@@ -382,12 +499,25 @@ type AppendFailure<O = AppendCallOptions> = AppendErrorFor<O> | StreamsFault | E
|
|
|
382
499
|
type CreateFailure = CreateError | StreamsFault;
|
|
383
500
|
type HeadFailure = HeadError | StreamsFault;
|
|
384
501
|
type RemoveFailure = RemoveError | StreamsFault;
|
|
502
|
+
/**
|
|
503
|
+
* One page of a read. A batch is the unit of a read because it holds the offset: pass `offset`
|
|
504
|
+
* back to read on after the last item.
|
|
505
|
+
*/
|
|
385
506
|
interface Batch<A> {
|
|
386
507
|
readonly items: ReadonlyArray<A>;
|
|
387
|
-
|
|
508
|
+
/** The position after the last item. Pass it back as `offset` to read on. */
|
|
509
|
+
readonly offset: Offset;
|
|
388
510
|
readonly upToDate: boolean;
|
|
389
511
|
readonly closed: boolean;
|
|
390
512
|
}
|
|
513
|
+
/** Operators for streams of batches. */
|
|
514
|
+
declare const Batch: {
|
|
515
|
+
/**
|
|
516
|
+
* Flatten a stream of batches into its items. The items carry no offset, so keep the batches
|
|
517
|
+
* when you need to resume from where you stopped.
|
|
518
|
+
*/
|
|
519
|
+
items: <A, E, R>(batches: Stream.Stream<Batch<A>, E, R>) => Stream.Stream<A, E, R>;
|
|
520
|
+
};
|
|
391
521
|
declare const create: <A, RD, RE>(address: StreamAddress<A, RD, RE>, options?: Omit<CreateOptions, "contentType"> | undefined) => Effect.Effect<CreateResult, CreateFailure, StreamsWriter>;
|
|
392
522
|
/**
|
|
393
523
|
* The items one append takes. An append carries at least one item, unless it
|
|
@@ -405,12 +535,12 @@ declare function read$1<A, RD, RE>(address: StreamAddress<A, RD, RE>, options?:
|
|
|
405
535
|
/** A folded value and the tail it was read up to. `offset` is this stream's CAS token. */
|
|
406
536
|
interface Folded<S> {
|
|
407
537
|
readonly state: S;
|
|
408
|
-
readonly offset:
|
|
538
|
+
readonly offset: Offset;
|
|
409
539
|
}
|
|
410
540
|
/** Every item read and the tail they were read up to. */
|
|
411
541
|
interface Collected<A> {
|
|
412
542
|
readonly items: ReadonlyArray<A>;
|
|
413
|
-
readonly offset:
|
|
543
|
+
readonly offset: Offset;
|
|
414
544
|
}
|
|
415
545
|
/**
|
|
416
546
|
* Read the stream up to its tail and fold every item into one value. Pass
|
|
@@ -429,7 +559,7 @@ interface Decision<B, A> {
|
|
|
429
559
|
interface Decided<B> {
|
|
430
560
|
readonly value: B;
|
|
431
561
|
/** The new tail after a write, or the tail that was read when there was no write. */
|
|
432
|
-
readonly offset:
|
|
562
|
+
readonly offset: Offset;
|
|
433
563
|
readonly appended: boolean;
|
|
434
564
|
}
|
|
435
565
|
interface DecideSpec<A, S, B, E, R> {
|
|
@@ -442,7 +572,7 @@ interface DecideSpec<A, S, B, E, R> {
|
|
|
442
572
|
* `state`: a retry folds on from the same state after a lost race.
|
|
443
573
|
*/
|
|
444
574
|
readonly decide: (state: S, at: {
|
|
445
|
-
readonly offset:
|
|
575
|
+
readonly offset: Offset;
|
|
446
576
|
}) => Effect.Effect<Decision<B, NoInfer<A>>, E, R>;
|
|
447
577
|
/** Retries after `OffsetMismatch`. Default: `Schedule.recurs(3)`. Nothing else is retried. */
|
|
448
578
|
readonly retry?: Schedule.Schedule<unknown, OffsetMismatch>;
|
|
@@ -470,45 +600,92 @@ interface FollowOptions extends ReadOptions$1 {
|
|
|
470
600
|
* offset, so a restart or network drop yields each item once.
|
|
471
601
|
*/
|
|
472
602
|
declare function follow<A, RD, RE>(address: StreamAddress<A, RD, RE>, options?: FollowOptions): Stream.Stream<Batch<A>, FollowFailure, StreamsReader | RD>;
|
|
473
|
-
|
|
474
|
-
|
|
603
|
+
/** One batch from a live read, with the values the next call needs. */
|
|
604
|
+
interface LiveBatch$1<A> extends Batch<A> {
|
|
605
|
+
/** Send this back as `cursor` on the next `readNext`. */
|
|
606
|
+
readonly cursor: string;
|
|
607
|
+
/** `true` when the wait ended with no messages. */
|
|
608
|
+
readonly timedOut: boolean;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* One live read: the items after `offset` if there are any, or else wait once for some. It
|
|
612
|
+
* decodes like `follow`, so a State reader skips changes to collections it does not declare.
|
|
613
|
+
*/
|
|
614
|
+
declare const readNext: <A, RD, RE>(address: StreamAddress<A, RD, RE>, options: ReadNextOptions) => Effect.Effect<LiveBatch$1<A>, FollowFailure, RD | StreamsReader>;
|
|
475
615
|
declare const head: <A, RD, RE>(address: StreamAddress<A, RD, RE>) => Effect.Effect<HeadResult, HeadFailure, StreamsReader>;
|
|
476
616
|
declare const remove: <A, RD, RE>(address: StreamAddress<A, RD, RE>) => Effect.Effect<void, RemoveFailure, StreamsWriter>;
|
|
477
|
-
/**
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
617
|
+
/**
|
|
618
|
+
* One stream, with named failures for each toolkit call. No method takes params: the handle
|
|
619
|
+
* already names its stream. `E` is `never` for a singleton stream and `InvalidStreamParams`
|
|
620
|
+
* for the handle from `at(params)` of a stream with params.
|
|
621
|
+
*/
|
|
622
|
+
interface StreamHandle<A, E = never, RD = never, RE = never> {
|
|
623
|
+
readonly owner: OwnerId;
|
|
481
624
|
readonly wire: Reader<StreamsFault> & Writer<StreamsFault>;
|
|
482
|
-
|
|
483
|
-
readonly
|
|
484
|
-
readonly
|
|
485
|
-
readonly
|
|
486
|
-
readonly
|
|
487
|
-
readonly
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
readonly
|
|
493
|
-
readonly
|
|
494
|
-
readonly
|
|
625
|
+
/** The address of this stream. Fails with `E` when its params cannot form a stream id. */
|
|
626
|
+
readonly address: Effect.Effect<StreamAddress<A, RD, RE>, E>;
|
|
627
|
+
readonly create: (options?: Omit<CreateOptions, "contentType">) => Effect.Effect<CreateResult, CreateFailure | E>;
|
|
628
|
+
readonly append: <const O extends AppendCallOptions = {}>(items: AppendItems<A, O>, options?: O) => Effect.Effect<AppendResult, AppendFailure<O> | E, RE>;
|
|
629
|
+
readonly read: (options?: ReadOptions$1) => Stream.Stream<Batch<A>, ReadFailure | E, RD>;
|
|
630
|
+
readonly fold: <S>(initial: Function.LazyArg<S>, f: (state: S, item: A) => S, options?: ReadOptions$1) => Effect.Effect<Folded<S>, ReadFailure | E, RD>;
|
|
631
|
+
readonly collect: (options?: ReadOptions$1) => Effect.Effect<Collected<A>, ReadFailure | E, RD>;
|
|
632
|
+
readonly decide: <S, B, E2, R>(spec: DecideSpec<A, S, B, E2, R>) => Effect.Effect<Decided<B>, ReadFailure | AppendFailure<{
|
|
633
|
+
expectedOffset: Offset;
|
|
634
|
+
}> | E | E2, RD | RE | R>;
|
|
635
|
+
readonly follow: (options?: FollowOptions) => Stream.Stream<Batch<A>, FollowFailure | E, RD>;
|
|
636
|
+
readonly readNext: (options: ReadNextOptions) => Effect.Effect<LiveBatch$1<A>, FollowFailure | E, RD>;
|
|
637
|
+
readonly head: () => Effect.Effect<HeadResult, HeadFailure | E>;
|
|
638
|
+
readonly remove: () => Effect.Effect<void, RemoveFailure | E>;
|
|
639
|
+
}
|
|
640
|
+
/** The handle from `at(params)`: one stream of a declaration with params, which can fork. */
|
|
641
|
+
interface ForkableStreamHandle<P, A, RD = never, RE = never> extends StreamHandle<A, InvalidStreamParams, RD, RE> {
|
|
642
|
+
/** Create this stream as a fork of `source`, another stream of the same declaration. */
|
|
643
|
+
readonly fork: (source: P, options?: Omit<CreateOptions, "contentType" | "forkedFrom">) => Effect.Effect<CreateResult, CreateFailure | InvalidStreamParams>;
|
|
495
644
|
}
|
|
645
|
+
/**
|
|
646
|
+
* The service of a stream with params. `at(params)` gives the handle of one stream and never
|
|
647
|
+
* throws: each method of the handle fails with `InvalidStreamParams` when `params` cannot form
|
|
648
|
+
* a stream id.
|
|
649
|
+
*/
|
|
650
|
+
interface StreamFamily<P, A, RD = never, RE = never> {
|
|
651
|
+
readonly owner: OwnerId;
|
|
652
|
+
readonly wire: Reader<StreamsFault> & Writer<StreamsFault>;
|
|
653
|
+
readonly at: (params: P) => ForkableStreamHandle<P, A, RD, RE>;
|
|
654
|
+
}
|
|
655
|
+
/** The service of a stream: a handle for a singleton stream, `at(params)` otherwise. */
|
|
656
|
+
type StreamService<P, A, RD, RE, Template extends string> = IsSingleton<Template> extends true ? StreamHandle<A, never, RD, RE> : StreamFamily<P, A, RD, RE>;
|
|
496
657
|
/** An address names one stream. It holds no data. It is not an Effect `Ref`. */
|
|
497
658
|
type Address<A, R, RD = never, RE = never> = StreamAddress<A, RD, RE> & {
|
|
498
659
|
readonly stream: Context.Key<R, {
|
|
499
|
-
readonly owner:
|
|
660
|
+
readonly owner: OwnerId;
|
|
500
661
|
readonly wire: Reader<StreamsFault> & Writer<StreamsFault>;
|
|
501
662
|
}>;
|
|
502
663
|
};
|
|
503
|
-
|
|
504
|
-
|
|
664
|
+
/** The address type a declaration binds to: its route's address plus the service key. */
|
|
665
|
+
type Bound<Self, P, A, RD, RE, R extends StreamRoute<P, A, RD, RE>> = ReturnType<R["address"]> & Address<A, Self, RD, RE>;
|
|
666
|
+
/**
|
|
667
|
+
* The binding statics of a stream class. A singleton stream has `singleton`, its address.
|
|
668
|
+
* A stream with params has `at(params)` and `resolve(params)`.
|
|
669
|
+
*/
|
|
670
|
+
type Bindings<Self, P, A, RD, RE, R extends StreamRoute<P, A, RD, RE>> = IsSingleton<R["template"]> extends true ? {
|
|
671
|
+
/** The address of this singleton stream. One cached object per declaration. */
|
|
672
|
+
readonly singleton: Bound<Self, P, A, RD, RE, R>;
|
|
673
|
+
} : {
|
|
674
|
+
/**
|
|
675
|
+
* Build the address for `params`. Throws a `RangeError` when a param value cannot form a
|
|
676
|
+
* stream id; its `cause` is the `InvalidStreamParams`. Use `resolve` for request values.
|
|
677
|
+
*/
|
|
678
|
+
readonly at: (params: P) => Bound<Self, P, A, RD, RE, R>;
|
|
679
|
+
/** Build the address for `params`, or fail with `InvalidStreamParams`. Never throws. */
|
|
680
|
+
readonly resolve: (params: P) => Effect.Effect<Bound<Self, P, A, RD, RE, R>, InvalidStreamParams>;
|
|
505
681
|
};
|
|
682
|
+
type Class<Self, Name extends string, P, A, RD, RE, R extends StreamRoute<P, A, RD, RE>> = Context.ServiceClass<Self, `@streamsy/core/Stream/${Name}`, StreamService<P, A, RD, RE, R["template"]>> & R & Bindings<Self, P, A, RD, RE, R>;
|
|
506
683
|
type JsonClass<Self, Name extends string, T extends string, C extends ParamCodecs, A, I, RD, RE> = Class<Self, Name, Params<C>, A, RD, RE, ReturnType<typeof json$1<T, C, A, I, RD, RE>>>;
|
|
507
|
-
declare const json: <Self>() => <const Name extends string, const T extends string, C extends ParamCodecs, A, I, RD, RE>(name: Name, ...args: Parameters<typeof json$1<T, C, A, I, RD, RE>>) => JsonClass<Self, Name, T, C, A, I, RD, RE>;
|
|
508
|
-
type StateClass<Self, Name extends string, T extends string, C extends ParamCodecs, Collections$
|
|
509
|
-
declare const state: <Self>() => <const Name extends string, const T extends string, C extends ParamCodecs, const Collections$
|
|
684
|
+
declare const json: <Self>() => <const Name extends string, const T extends string, C extends ParamCodecs = {}, A = never, I = never, RD = never, RE = never>(name: Name, ...args: Parameters<typeof json$1<T, C, A, I, RD, RE>>) => JsonClass<Self, Name, T, C, A, I, RD, RE>;
|
|
685
|
+
type StateClass<Self, Name extends string, T extends string, C extends ParamCodecs, Collections$2 extends Collections> = Class<Self, Name, Params<C>, CollectionsEvent<Collections$2>, CollectionsDecodingServices<Collections$2>, CollectionsEncodingServices<Collections$2>, ReturnType<typeof state$1<T, C, Collections$2>>>;
|
|
686
|
+
declare const state: <Self>() => <const Name extends string, const T extends string, C extends ParamCodecs = {}, const Collections$1 extends Collections = {}>(name: Name, ...args: Parameters<typeof state$1<T, C, Collections$1>>) => StateClass<Self, Name, T, C, Collections$1>;
|
|
510
687
|
type BytesClass<Self, Name extends string, T extends string, C extends ParamCodecs> = Class<Self, Name, Params<C>, Uint8Array, never, never, ReturnType<typeof bytes$1<T, C>>>;
|
|
511
|
-
declare const bytes: <Self>() => <const Name extends string, const T extends string, C extends ParamCodecs>(name: Name, ...args: Parameters<typeof bytes$1<T, C>>) => BytesClass<Self, Name, T, C>;
|
|
688
|
+
declare const bytes: <Self>() => <const Name extends string, const T extends string, C extends ParamCodecs = {}>(name: Name, ...args: Parameters<typeof bytes$1<T, C>>) => BytesClass<Self, Name, T, C>;
|
|
512
689
|
type CustomClass<Self, Name extends string, P, A, RD, RE> = Class<Self, Name, P, A, RD, RE, ReturnType<typeof custom$1<P, A, RD, RE>>>;
|
|
513
690
|
declare const custom: <Self>() => <const Name extends string, P, A, RD, RE>(name: Name, options: Parameters<typeof custom$1<P, A, RD, RE>>[0]) => CustomClass<Self, Name, P, A, RD, RE>;
|
|
514
691
|
declare const Wildcard_base: Class<Wildcard, "Wildcard", {
|
|
@@ -523,7 +700,7 @@ interface StreamIdentifier {
|
|
|
523
700
|
}
|
|
524
701
|
/** The provider and HTTP boundary need only the wire and the route grammar. */
|
|
525
702
|
interface Any extends Context.Key<StreamIdentifier, {
|
|
526
|
-
readonly owner:
|
|
703
|
+
readonly owner: OwnerId;
|
|
527
704
|
readonly wire: Reader<StreamsFault> & Writer<StreamsFault>;
|
|
528
705
|
}> {
|
|
529
706
|
readonly template: string;
|
|
@@ -656,4 +833,4 @@ type HttpLiveMode = "long-poll" | "sse" | "websocket";
|
|
|
656
833
|
declare namespace index_d_exports {
|
|
657
834
|
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 };
|
|
658
835
|
}
|
|
659
|
-
export { HttpOptions as $, Batch as A,
|
|
836
|
+
export { HttpOptions as $, Batch as A, StreamNotFound as At, ReadFailure as B, Access as C, ReadError as Ct, Group as D, StreamBusy as Dt, Any as E, StaleEpoch as Et, Decision as F, streams_d_exports$1 as G, streams_d_exports as H, Folded as I, layer_d_exports as J, MemoryOptions as K, FollowFailure as L, CreateFailure as M, CreateOptions as Mt, DecideSpec as N, Identifiers as O, StreamClosed as Ot, Decided as P, streamPath as Q, HeadFailure as R, read as S, ProtocolError as St, routes as T, RemoveError as Tt, streamsy_d_exports as U, RemoveFailure as V, producer_d_exports as W, compare as X, ZERO_OFFSET as Y, route_d_exports as Z, ShutdownSignalService as _, InvalidForkRequest as _t, LIVE_SOCKET_PROTOCOL as a, AppendBaseError as at, ReadOptions as b, OffsetMismatch as bt, LiveControlFrame as c, AppendErrorFor as ct, controlFrame as d, CreateError as dt, app as et, isLiveUpgrade as f, ForkSourceNotFound as ft, ShutdownSignal as g, InvalidEpochSeq as gt, upgradeRequired as h, InvalidCreateRequest as ht, LIVE_PONG as i, Writer as it, Collected as j, isProtocolError as jt, AppendFailure as k, StreamGone as kt, LiveOpenFrame as l, CreateConflict as lt, openFrame as m, InvalidAppendRequest as mt, HttpLiveMode as n, StreamsReader as nt, LiveBatch as o, AppendConflict as ot, nextCursor as p, HeadError as pt, ProtocolOptions as q, LIVE_PING as r, StreamsWriter as rt, LiveCloseCode as s, AppendError as st, index_d_exports as t, Reader as tt, closeCodeForStatus as u, CreateConflictReason as ut, layerShutdownSignal as v, InvalidReadRequest as vt, RoutesOptions as w, ReadNextError as wt, checkReadOptions as x, ProducerGap as xt, securityHeaders as y, NotSupported as yt, LiveBatch$1 as z };
|