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