@streamsy/core 0.2.1 → 0.4.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.
@@ -0,0 +1,8 @@
1
+ import { _ as StreamsWriter, g as StreamsReader, h as Reader, v as Writer } from "../owner-records-QDlssl__.js";
2
+ import { D as streams_d_exports, P as layer_d_exports, u as RoutesOptions, z as route_d_exports } from "../index-CFv8vZvy.js";
3
+ import { HttpRouter } from "effect/http";
4
+ //#region src/protocol/routes.d.ts
5
+ /** Raw protocol route for adapters and wire conformance tests. */
6
+ export declare const routes: (options?: Omit<RoutesOptions, "access">) => import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", StreamsReader> | HttpRouter.Request<"Requires", StreamsWriter>>;
7
+ //#endregion
8
+ export { layer_d_exports as Protocol, type Reader, route_d_exports as StreamRoute, streams_d_exports as Streams, StreamsReader, StreamsWriter, type Writer };
@@ -0,0 +1,16 @@
1
+ import { A as StreamsReader, j as StreamsWriter, l as streams_exports, u as route_exports } from "../streamsy-OjRubIPC.js";
2
+ import { n as layer_exports } from "../layer-KvknRFUT.js";
3
+ import { t as app } from "../program-DJ8NpHIf.js";
4
+ import { HttpRouter } from "effect/http";
5
+ //#region src/protocol/routes.ts
6
+ /** Raw protocol route for adapters and wire conformance tests. */
7
+ const routes = (options = {}) => {
8
+ const prefix = options.prefix?.replace(/\/$/, "") || "/";
9
+ if (!prefix.startsWith("/") || /[?:#*]/.test(prefix) || prefix.includes("//")) throw new RangeError("HTTP prefix must be an absolute literal path");
10
+ return HttpRouter.add("*", prefix === "/" ? "/*" : `/${prefix.slice(1)}/*`, app({
11
+ ...options,
12
+ pathPrefix: prefix
13
+ }));
14
+ };
15
+ //#endregion
16
+ export { layer_exports as Protocol, route_exports as StreamRoute, streams_exports as Streams, StreamsReader, StreamsWriter, routes };
@@ -0,0 +1,23 @@
1
+ import { _ as StreamsWriter, g as StreamsReader, vt as TransportFault } from "../owner-records-QDlssl__.js";
2
+ import { f as Any, m as Identifiers, p as Group } from "../index-CFv8vZvy.js";
3
+ import { Layer } from "effect";
4
+ import { HttpClient, HttpClientRequest } from "effect/http";
5
+ //#region src/remote/request.d.ts
6
+ interface Options {
7
+ readonly baseUrl: string;
8
+ readonly headers?: Readonly<Record<string, string>>;
9
+ /** Explicit deployment contract, never inferred from a successful append. */
10
+ readonly capabilities?: {
11
+ readonly expectedOffset?: boolean;
12
+ readonly producer?: boolean;
13
+ };
14
+ }
15
+ declare namespace streams_d_exports {
16
+ export { Options, TransportFault, layer, layerProtocol };
17
+ }
18
+ /** Generic reader and writer over HTTP for the protocol tier. HttpClient and the calling fiber own request lifetimes. */
19
+ declare const layerProtocol: (options: Options) => Layer.Layer<StreamsReader | StreamsWriter, TransportFault, HttpClient.HttpClient>;
20
+ /** Remote streams have no local change feed. */
21
+ declare function layer<const Keys extends ReadonlyArray<Any>>(group: Group<Keys>, options: Options): Layer.Layer<Identifiers<Keys>, TransportFault, HttpClient.HttpClient>;
22
+ //#endregion
23
+ export { streams_d_exports as RemoteStreams };
@@ -0,0 +1,428 @@
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.js";
2
+ import { A as StreamsReader, C as ProducerGap, D as StreamGone, E as StreamClosed, O as StreamNotFound, Q as StreamId, S as OffsetMismatch, T as StreamBusy, V as TransportFault, _ as InvalidAppendRequest, b as InvalidReadRequest, f as AppendResult, g as ForkSourceNotFound, h as CreateConflict, j as StreamsWriter, m as AppendConflict, n as bind, p as CreateResult, w as StaleEpoch, x as NotSupported, y as InvalidForkRequest } from "../streamsy-OjRubIPC.js";
3
+ import { Context, DateTime, Effect, Fiber, Layer, Option, Schema, Scope, Stream } from "effect";
4
+ import { HttpClient, HttpClientRequest } from "effect/http";
5
+ //#region src/remote/request.ts
6
+ function requests(options) {
7
+ const base = new URL(options.baseUrl);
8
+ if (!/^https?:$/.test(base.protocol) || base.search || base.hash || base.username || base.password) throw new TypeError("baseUrl must be an HTTP(S) URL without credentials, query or fragment");
9
+ const prefix = base.pathname.replace(/\/$/, "") + "/";
10
+ const url = (id) => {
11
+ if (!id || id.split("/").some((part) => !part || part === "." || part === "..") || /[%?#\\]/.test(id)) throw new TypeError("Stream ID must be a canonical relative path");
12
+ const target = new URL(base);
13
+ target.pathname = prefix + id;
14
+ if (target.pathname !== prefix + id) throw new TypeError("Stream ID must be URL-safe");
15
+ return target.href;
16
+ };
17
+ const make = (method, id, headers = {}) => HttpClientRequest.make(method)(url(id), { headers: {
18
+ ...options.headers,
19
+ ...headers,
20
+ "cache-control": "no-cache"
21
+ } });
22
+ return {
23
+ head: (id) => make("HEAD", id),
24
+ remove: (id) => make("DELETE", id),
25
+ read: (id, input = {}) => {
26
+ const params = { offset: input.offset ?? "-1" };
27
+ return HttpClientRequest.setUrlParams(make("GET", id), params);
28
+ },
29
+ readNext: (id, input) => {
30
+ const params = {
31
+ offset: input.offset,
32
+ live: "long-poll"
33
+ };
34
+ if (input.cursor !== void 0) params.cursor = input.cursor;
35
+ return HttpClientRequest.setUrlParams(make("GET", id), params);
36
+ },
37
+ create: (id, input = {}) => {
38
+ const headers = {};
39
+ if (input.contentType !== void 0) headers["content-type"] = input.contentType;
40
+ if (input.ttlSeconds !== void 0) headers["stream-ttl"] = String(input.ttlSeconds);
41
+ if (input.expiresAt !== void 0) headers["stream-expires-at"] = input.expiresAt;
42
+ if (input.closed) headers["stream-closed"] = "true";
43
+ if (input.forkedFrom !== void 0) headers["stream-forked-from"] = new URL(url(input.forkedFrom)).pathname;
44
+ if (input.forkOffset !== void 0) headers["stream-fork-offset"] = input.forkOffset;
45
+ if (input.forkSubOffset !== void 0) headers["stream-fork-sub-offset"] = String(input.forkSubOffset);
46
+ const request = make("PUT", id, headers);
47
+ return input.initialData === void 0 ? request : HttpClientRequest.bodyUint8Array(request, input.initialData, input.contentType);
48
+ },
49
+ append: (id, input) => {
50
+ const headers = {};
51
+ if (input.seq !== void 0) headers["stream-seq"] = input.seq;
52
+ if (input.expectedOffset !== void 0) headers["stream-expected-offset"] = input.expectedOffset;
53
+ if (input.close) headers["stream-closed"] = "true";
54
+ if (input.producer) {
55
+ headers["producer-id"] = input.producer.producerId;
56
+ headers["producer-epoch"] = String(input.producer.producerEpoch);
57
+ headers["producer-seq"] = String(input.producer.producerSeq);
58
+ }
59
+ return HttpClientRequest.bodyUint8Array(make("POST", id, headers), input.data, input.contentType);
60
+ }
61
+ };
62
+ }
63
+ //#endregion
64
+ //#region src/remote/wire.ts
65
+ /**
66
+ * Standard Durable Streams HTTP response primitives.
67
+ *
68
+ * The transport decodes the public protocol only: status codes, the documented
69
+ * response headers, and the content-type-framed body. Streamsy adds no private
70
+ * media type, response header, or envelope. Where a public response cannot carry
71
+ * a field the direct Layer returns, the decoder reports what the wire has.
72
+ */
73
+ const INTEGER = /^(0|[1-9]\d*)$/;
74
+ const OFFSET = /^\d{16}_\d{16}$/;
75
+ const CONTENT_TYPE = /^[^\s/;]+\/[^\s;]+(?:;.*)?$/;
76
+ const failure = (operation, reason, message, cause, status) => status === void 0 ? new TransportFault({
77
+ operation,
78
+ reason,
79
+ message,
80
+ cause
81
+ }) : new TransportFault({
82
+ operation,
83
+ reason,
84
+ message,
85
+ cause,
86
+ status
87
+ });
88
+ const header = (response, name) => response.headers[name];
89
+ /** `stream-closed` is absent, `true`, or `false`; anything else is a wire fault. */
90
+ const closedHeader = (operation, response) => {
91
+ const value = header(response, "stream-closed");
92
+ if (value === void 0 || value === "true" || value === "false") return Effect.succeed(value === "true");
93
+ return Effect.fail(failure(operation, "response", `Invalid stream-closed header: ${value}`, void 0, response.status));
94
+ };
95
+ const upToDate = (response) => header(response, "stream-up-to-date") === "true";
96
+ /** The protocol emits a cursor only while a live read can be resumed. */
97
+ const cursor = (response) => header(response, "stream-cursor") ?? "";
98
+ const optionalOffset = (operation, response) => {
99
+ const value = header(response, "stream-next-offset");
100
+ if (value === void 0) return Effect.as(Effect.void, void 0);
101
+ if (!OFFSET.test(value)) return Effect.fail(failure(operation, "response", `Invalid stream-next-offset header: ${value}`, void 0, response.status));
102
+ return Effect.succeed(value);
103
+ };
104
+ const offset = (operation, response) => optionalOffset(operation, response).pipe(Effect.filterOrFail((value) => value !== void 0, () => failure(operation, "response", "Missing stream-next-offset header", void 0, response.status)));
105
+ const contentType = (operation, response) => {
106
+ const value = header(response, "content-type");
107
+ if (value === void 0) return Effect.fail(failure(operation, "response", "Missing content-type header", void 0, response.status));
108
+ if (!CONTENT_TYPE.test(value)) return Effect.fail(failure(operation, "response", `Invalid content-type header: ${value}`, void 0, response.status));
109
+ return Effect.succeed(value);
110
+ };
111
+ const integer = (operation, name, value) => {
112
+ if (value === void 0) return Effect.as(Effect.void, void 0);
113
+ if (!INTEGER.test(value)) return Effect.fail(failure(operation, "response", `Invalid ${name} header: ${value}`));
114
+ return Effect.succeed(Number(value));
115
+ };
116
+ const body = (operation, response) => response.stream.pipe(Stream.runCollect, Effect.map((chunks) => {
117
+ const bytes = new Uint8Array(chunks.reduce((size, chunk) => size + chunk.length, 0));
118
+ let position = 0;
119
+ for (const chunk of chunks) {
120
+ bytes.set(chunk, position);
121
+ position += chunk.length;
122
+ }
123
+ return bytes;
124
+ }), Effect.mapError((cause) => failure(operation, "decode", "Cannot read response body", cause, response.status)));
125
+ const text = (operation, bytes) => Effect.try({
126
+ try: () => new TextDecoder("utf-8", { fatal: true }).decode(bytes),
127
+ catch: (cause) => failure(operation, "decode", "Response body is not valid UTF-8", cause)
128
+ });
129
+ const bodyText = (operation, response) => body(operation, response).pipe(Effect.flatMap((bytes) => text(operation, bytes)));
130
+ /** Message for a status the operation has no outcome for, keeping any plain-text detail. */
131
+ const unexpectedWith = (operation, status, detail) => {
132
+ const trimmed = detail.trim();
133
+ return failure(operation, "response", trimmed === "" ? `Unexpected HTTP ${status}` : `Unexpected HTTP ${status}: ${trimmed}`, void 0, status);
134
+ };
135
+ /** Classify an unrecognized status, keeping the host's plain-text detail in the message. */
136
+ const unexpected = (operation, response) => bodyText(operation, response).pipe(Effect.flatMap((detail) => Effect.fail(unexpectedWith(operation, response.status, detail))));
137
+ /**
138
+ * A JSON read body is one JSON array whose elements are the stored messages. The
139
+ * elements decode by value; re-serializing them returns canonical JSON text, not
140
+ * the stored bytes. Text and binary bodies stay a single merged payload.
141
+ */
142
+ const readMessages = (operation, response, bytes) => {
143
+ if (bytes.byteLength === 0) return Effect.succeed([]);
144
+ return contentType(operation, response).pipe(Effect.flatMap((value) => {
145
+ if (value.split(";")[0]?.trim().toLowerCase() === "application/json") return text(operation, bytes).pipe(Effect.flatMap((decoded) => jsonMessages(operation, decoded)));
146
+ return Effect.succeed([{ data: bytes }]);
147
+ }));
148
+ };
149
+ const jsonArray = Schema.fromJsonString(Schema.Array(Schema.Unknown));
150
+ const jsonMessages = (operation, decoded) => Schema.decodeEffect(jsonArray)(decoded).pipe(Effect.mapError((cause) => failure(operation, "decode", "Read body is not a JSON array", cause)), Effect.map((items) => items.map((item) => ({ data: new TextEncoder().encode(JSON.stringify(item)) }))));
151
+ //#endregion
152
+ //#region src/remote/response.ts
153
+ /** Decode standard HTTP successes and fail with the protocol details carried by the wire. */
154
+ const emptyToUndefined = (value) => {
155
+ const trimmed = value.trim();
156
+ return trimmed === "" ? void 0 : trimmed;
157
+ };
158
+ const head = (operation, response, context) => Effect.gen(function* () {
159
+ if (response.status === 404) return yield* new StreamNotFound({ id: context.id });
160
+ if (response.status === 410) return yield* new StreamGone({ id: context.id });
161
+ if (response.status !== 200) return yield* unexpected(operation, response);
162
+ const contentType$2 = yield* contentType(operation, response);
163
+ const nextOffset = yield* offset(operation, response);
164
+ const ttlSeconds = yield* integer(operation, "stream-ttl", header(response, "stream-ttl"));
165
+ const expiresAt = header(response, "stream-expires-at");
166
+ if (expiresAt !== void 0 && Option.isNone(DateTime.make(expiresAt))) return yield* failure(operation, "response", `Invalid stream-expires-at header: ${expiresAt}`, void 0, response.status);
167
+ return {
168
+ contentType: contentType$2,
169
+ nextOffset,
170
+ ttlSeconds,
171
+ expiresAt,
172
+ closed: yield* closedHeader(operation, response)
173
+ };
174
+ });
175
+ const create = (operation, response, context) => Effect.gen(function* () {
176
+ if (response.status === 200 || response.status === 201) {
177
+ const contentType$1 = yield* contentType(operation, response);
178
+ const fields = {
179
+ nextOffset: yield* offset(operation, response),
180
+ contentType: contentType$1,
181
+ closed: yield* closedHeader(operation, response)
182
+ };
183
+ return response.status === 201 ? CreateResult.Created(fields) : CreateResult.Exists(fields);
184
+ }
185
+ if (response.status === 400) {
186
+ const feature = header(response, "stream-not-supported");
187
+ if (feature !== void 0) return yield* new NotSupported({
188
+ id: context.id,
189
+ feature
190
+ });
191
+ const message = emptyToUndefined(yield* bodyText(operation, response));
192
+ return yield* new InvalidForkRequest({
193
+ id: context.id,
194
+ message: message ?? "Invalid fork parameters"
195
+ });
196
+ }
197
+ if (response.status === 404) return yield* new ForkSourceNotFound({
198
+ id: context.id,
199
+ source: context.source ?? context.id
200
+ });
201
+ if (response.status === 409) return yield* new CreateConflict({
202
+ id: context.id,
203
+ message: (yield* bodyText(operation, response)) || "Stream exists with different configuration"
204
+ });
205
+ return yield* unexpected(operation, response);
206
+ });
207
+ const append = (operation, response, context) => Effect.gen(function* () {
208
+ if (response.status === 200 || response.status === 204) {
209
+ const offset$1 = yield* offset(operation, response);
210
+ const producerEpoch = yield* integer(operation, "producer-epoch", header(response, "producer-epoch"));
211
+ const producerSeq = yield* integer(operation, "producer-seq", header(response, "producer-seq"));
212
+ const closed = yield* closedHeader(operation, response);
213
+ if (response.status === 200) return AppendResult.Appended({
214
+ offset: offset$1,
215
+ producerEpoch,
216
+ producerSeq,
217
+ closed
218
+ });
219
+ if (context.producer !== true || producerEpoch === void 0 && producerSeq === void 0) return AppendResult.Appended({
220
+ offset: offset$1,
221
+ closed
222
+ });
223
+ if (producerEpoch === void 0 || producerSeq === void 0) return yield* failure(operation, "response", "Duplicate acknowledgement is missing producer state", void 0, response.status);
224
+ return AppendResult.Duplicate({
225
+ offset: offset$1,
226
+ producerEpoch,
227
+ producerSeq,
228
+ closed
229
+ });
230
+ }
231
+ if (response.status === 404) return yield* new StreamNotFound({ id: context.id });
232
+ if (response.status === 410) return yield* new StreamGone({ id: context.id });
233
+ if (response.status === 503) return yield* new StreamBusy({ id: context.id });
234
+ if (response.status === 403) {
235
+ const currentEpoch = yield* integer(operation, "producer-epoch", header(response, "producer-epoch"));
236
+ if (currentEpoch === void 0) return yield* failure(operation, "response", "Stale epoch response is missing producer-epoch", void 0, response.status);
237
+ return yield* new StaleEpoch({
238
+ id: context.id,
239
+ currentEpoch
240
+ });
241
+ }
242
+ if (response.status === 400) {
243
+ const feature = header(response, "stream-not-supported");
244
+ if (feature !== void 0) return yield* new NotSupported({
245
+ id: context.id,
246
+ feature
247
+ });
248
+ const detail = yield* bodyText(operation, response);
249
+ return yield* new InvalidAppendRequest({
250
+ id: context.id,
251
+ message: detail
252
+ });
253
+ }
254
+ if (response.status === 409) return yield* appendConflict(operation, response, context);
255
+ return yield* unexpected(operation, response);
256
+ });
257
+ const appendConflict = (operation, response, context) => Effect.gen(function* () {
258
+ const expectedSeq = yield* integer(operation, "producer-expected-seq", header(response, "producer-expected-seq"));
259
+ const receivedSeq = yield* integer(operation, "producer-received-seq", header(response, "producer-received-seq"));
260
+ if (expectedSeq !== void 0 && receivedSeq !== void 0) return yield* new ProducerGap({
261
+ id: context.id,
262
+ expectedSeq,
263
+ receivedSeq
264
+ });
265
+ const closed = yield* closedHeader(operation, response);
266
+ const offset = yield* optionalOffset(operation, response);
267
+ if (closed && offset !== void 0) return yield* new StreamClosed({
268
+ id: context.id,
269
+ offset
270
+ });
271
+ if (!closed && offset !== void 0 && context.expectedOffset !== void 0) return yield* new OffsetMismatch({
272
+ id: context.id,
273
+ expected: context.expectedOffset,
274
+ actual: offset
275
+ });
276
+ return yield* new AppendConflict({
277
+ id: context.id,
278
+ message: yield* bodyText(operation, response)
279
+ });
280
+ });
281
+ const read = (operation, response, context) => Effect.gen(function* () {
282
+ if (response.status === 404) return yield* new StreamNotFound({ id: context.id });
283
+ if (response.status === 410) return yield* new StreamGone({ id: context.id });
284
+ if (response.status === 400) return yield* new InvalidReadRequest({
285
+ id: context.id,
286
+ message: yield* bodyText(operation, response)
287
+ });
288
+ if (response.status !== 200) return yield* unexpected(operation, response);
289
+ const nextOffset = yield* offset(operation, response);
290
+ const messages = yield* readBatch(operation, response);
291
+ const closed = yield* closedHeader(operation, response);
292
+ return {
293
+ contentType: yield* contentType(operation, response),
294
+ messages,
295
+ nextOffset,
296
+ upToDate: upToDate(response),
297
+ closed
298
+ };
299
+ });
300
+ const readNext = (operation, response, context) => Effect.gen(function* () {
301
+ if (response.status === 404) return yield* new StreamNotFound({ id: context.id });
302
+ if (response.status === 410) return yield* new StreamGone({ id: context.id });
303
+ if (response.status === 400) {
304
+ const feature = header(response, "stream-not-supported");
305
+ if (feature === void 0) return yield* new InvalidReadRequest({
306
+ id: context.id,
307
+ message: yield* bodyText(operation, response)
308
+ });
309
+ return yield* new NotSupported({
310
+ id: context.id,
311
+ feature
312
+ });
313
+ }
314
+ if (response.status !== 200 && response.status !== 204) return yield* unexpected(operation, response);
315
+ const nextOffset = yield* offset(operation, response);
316
+ const closed = yield* closedHeader(operation, response);
317
+ if (response.status === 204) return {
318
+ contentType: context.contentType ?? (yield* contentType(operation, response)),
319
+ timedOut: true,
320
+ messages: [],
321
+ nextOffset,
322
+ upToDate: upToDate(response),
323
+ cursor: cursor(response),
324
+ closed
325
+ };
326
+ const messages = yield* readBatch(operation, response);
327
+ return {
328
+ contentType: yield* contentType(operation, response),
329
+ messages,
330
+ timedOut: false,
331
+ nextOffset,
332
+ upToDate: upToDate(response),
333
+ cursor: cursor(response),
334
+ closed
335
+ };
336
+ });
337
+ const readBatch = (operation, response) => body(operation, response).pipe(Effect.flatMap((bytes) => readMessages(operation, response, bytes)));
338
+ const remove = (operation, response, context) => Effect.gen(function* () {
339
+ if (response.status === 204) return yield* Effect.void;
340
+ if (response.status === 404) return yield* new StreamNotFound({ id: context.id });
341
+ if (response.status === 410) return yield* new StreamGone({ id: context.id });
342
+ if (response.status === 503) return yield* new StreamBusy({ id: context.id });
343
+ return yield* unexpected(operation, response);
344
+ });
345
+ //#endregion
346
+ //#region src/remote/streams.ts
347
+ var streams_exports = /* @__PURE__ */ __exportAll({
348
+ TransportFault: () => TransportFault,
349
+ layer: () => layer,
350
+ layerProtocol: () => layerProtocol
351
+ });
352
+ /** Generic reader and writer over HTTP for the protocol tier. HttpClient and the calling fiber own request lifetimes. */
353
+ const layerProtocol = (options) => Layer.effectContext(Effect.gen(function* () {
354
+ const client = HttpClient.withScope(yield* HttpClient.HttpClient);
355
+ const owner = yield* Scope.Scope;
356
+ const request = yield* Effect.try({
357
+ try: () => requests(options),
358
+ catch: (cause) => new TransportFault({
359
+ operation: "layer",
360
+ reason: "configuration",
361
+ message: "Invalid remote configuration",
362
+ cause
363
+ })
364
+ });
365
+ const execute = (operation, make, decode) => Effect.gen(function* () {
366
+ const input = yield* Effect.try({
367
+ try: make,
368
+ catch: (cause) => new TransportFault({
369
+ operation,
370
+ reason: "configuration",
371
+ message: "Invalid request",
372
+ cause
373
+ })
374
+ });
375
+ return yield* decode(operation, yield* client.execute(input).pipe(Effect.mapError((cause) => new TransportFault({
376
+ operation,
377
+ reason: "request",
378
+ message: "HTTP request failed",
379
+ cause
380
+ }))));
381
+ }).pipe(Effect.scoped, Effect.forkIn(owner), Effect.flatMap((fiber) => Fiber.join(fiber).pipe(Effect.ensuring(Fiber.interrupt(fiber)))));
382
+ const reader = {
383
+ head: (id) => execute("head", () => request.head(id), (operation, response) => head(operation, response, { id })),
384
+ read: (id, input) => execute("read", () => request.read(id, input), (operation, response) => read(operation, response, { id })),
385
+ readNext: (id, input) => execute("readNext", () => request.readNext(id, input), (operation, response) => Effect.gen(function* () {
386
+ const contentType = response.status === 204 && header(response, "content-type") === void 0 ? (yield* reader.head(id)).contentType : void 0;
387
+ return yield* readNext(operation, response, {
388
+ id,
389
+ contentType
390
+ });
391
+ }))
392
+ };
393
+ return Context.make(StreamsReader, reader).pipe(Context.add(StreamsWriter, {
394
+ create: (id, input) => execute("create", () => request.create(id, input), (operation, response) => create(operation, response, {
395
+ id,
396
+ source: input?.forkedFrom === void 0 ? void 0 : StreamId.make(input.forkedFrom)
397
+ })),
398
+ fork: (id, source, input) => execute("create", () => request.create(id, {
399
+ ...input,
400
+ forkedFrom: source
401
+ }), (operation, response) => create(operation, response, {
402
+ id,
403
+ source
404
+ })),
405
+ append: (id, input) => {
406
+ if (input.expectedOffset !== void 0 && options.capabilities?.expectedOffset !== true) return Effect.fail(new NotSupported({
407
+ id,
408
+ feature: "expected-offset"
409
+ }));
410
+ if (input.producer !== void 0 && options.capabilities?.producer !== true) return Effect.fail(new NotSupported({
411
+ id,
412
+ feature: "producer"
413
+ }));
414
+ return execute("append", () => request.append(id, input), (operation, response) => append(operation, response, {
415
+ id,
416
+ expectedOffset: input.expectedOffset,
417
+ producer: input.producer !== void 0
418
+ }));
419
+ },
420
+ remove: (id) => execute("remove", () => request.remove(id), (operation, response) => remove(operation, response, { id }))
421
+ }));
422
+ }));
423
+ function layer(group, options) {
424
+ const protocol = layerProtocol(options);
425
+ return bind(protocol, group);
426
+ }
427
+ //#endregion
428
+ export { streams_exports as RemoteStreams };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };