@streamsy/core 0.10.0 → 0.12.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,195 @@
1
+ import { Array, Context, Effect, Option, Order } from "effect";
2
+ // src/internal/owner-records.ts
3
+ var OwnerRecords = class extends Context.Service()("@streamsy/core/internal/OwnerRecords") {};
4
+ // src/internal/commit-hooks.ts
5
+ var CommitHooks = class extends Context.Service()("@streamsy/core/internal/CommitHooks") {};
6
+ /** Shared registry for storage boundaries: register in a scope, run in order. */
7
+ const commitHookRegistry = () => {
8
+ const hooks = /* @__PURE__ */ new Set();
9
+ const beforeCommit = (hook) => Effect.acquireRelease(Effect.sync(() => {
10
+ const entry = { hook };
11
+ hooks.add(entry);
12
+ return entry;
13
+ }), (entry) => Effect.sync(() => {
14
+ hooks.delete(entry);
15
+ })).pipe(Effect.asVoid);
16
+ const run = (ids) => ids.size === 0 || hooks.size === 0 ? Effect.void : Effect.forEach([...hooks], (entry) => entry.hook(ids), { discard: true });
17
+ return {
18
+ beforeCommit,
19
+ run
20
+ };
21
+ };
22
+ // src/internal/projection-marks.ts
23
+ var ProjectionMarks = class extends Context.Service()("@streamsy/core/internal/ProjectionMarks") {};
24
+ // src/storage/memory/marks.ts
25
+ /** A private transaction draft of the marks. */
26
+ const copyMarks = (marks) => new Map(Array.map([...marks], ([projection, rows]) => [projection, new Map(rows)]));
27
+ const rowsOf = (marks, projection) => {
28
+ const found = marks.get(projection);
29
+ if (found !== void 0) return found;
30
+ const rows = /* @__PURE__ */ new Map();
31
+ marks.set(projection, rows);
32
+ return rows;
33
+ };
34
+ const byDue = Order.mapInput(Order.Tuple([Order.Number, Order.String]), (mark) => [mark.dueAt, mark.params]);
35
+ const mark = (marks, projection, params) => {
36
+ const rows = rowsOf(marks, projection);
37
+ for (const value of params) {
38
+ const found = rows.get(value);
39
+ rows.set(value, found === void 0 ? {
40
+ params: value,
41
+ seq: 1,
42
+ attempts: 0,
43
+ dueAt: 0,
44
+ stopped: false,
45
+ wakeAt: Option.none(),
46
+ failure: Option.none()
47
+ } : {
48
+ ...found,
49
+ seq: found.seq + 1,
50
+ dueAt: Option.isSome(found.wakeAt) ? 0 : found.dueAt,
51
+ wakeAt: Option.none()
52
+ });
53
+ }
54
+ };
55
+ const nextDue = (marks, projection) => {
56
+ let earliest;
57
+ for (const row of marks.get(projection)?.values() ?? []) if (!row.stopped) earliest = earliest === void 0 ? row.dueAt : Math.min(earliest, row.dueAt);
58
+ return Option.fromUndefinedOr(earliest);
59
+ };
60
+ const due = (marks, projection, now, limit) => Array.sort(Array.filter([...marks.get(projection)?.values() ?? []], (row) => !row.stopped && row.dueAt <= now), byDue).slice(0, limit);
61
+ const read = (marks, projection, params) => {
62
+ const rows = marks.get(projection);
63
+ const found = /* @__PURE__ */ new Map();
64
+ for (const value of params) {
65
+ const row = rows?.get(value);
66
+ if (row !== void 0) found.set(value, row);
67
+ }
68
+ return found;
69
+ };
70
+ const clear = (marks, projection, params, seq) => {
71
+ const rows = marks.get(projection);
72
+ const row = rows?.get(params);
73
+ if (rows === void 0 || row === void 0) return;
74
+ if (row.seq === seq) rows.delete(params);
75
+ else rows.set(params, {
76
+ ...row,
77
+ attempts: 0,
78
+ dueAt: 0,
79
+ stopped: false,
80
+ wakeAt: Option.none(),
81
+ failure: Option.none()
82
+ });
83
+ };
84
+ /** Sleep only the seq that ran; a concurrent write must run before it can sleep. */
85
+ const sleep = (marks, projection, params, seq, wakeAt) => {
86
+ const rows = rowsOf(marks, projection);
87
+ const row = rows.get(params);
88
+ const matching = row === void 0 || row.seq === seq;
89
+ rows.set(params, {
90
+ params,
91
+ seq: row?.seq ?? 1,
92
+ attempts: 0,
93
+ dueAt: matching ? wakeAt : 0,
94
+ wakeAt: matching ? Option.some(wakeAt) : Option.none(),
95
+ stopped: false,
96
+ failure: Option.none()
97
+ });
98
+ };
99
+ const remove = (marks, projection, params) => {
100
+ marks.get(projection)?.delete(params);
101
+ };
102
+ const fail = (marks, projection, params, options) => {
103
+ const rows = rowsOf(marks, projection);
104
+ const found = rows.get(params);
105
+ rows.set(params, {
106
+ params,
107
+ seq: found?.seq ?? 1,
108
+ attempts: options.attempts,
109
+ dueAt: Option.getOrElse(options.dueAt, () => 0),
110
+ stopped: Option.isNone(options.dueAt),
111
+ wakeAt: Option.none(),
112
+ failure: Option.some({
113
+ ...options.failure,
114
+ message: options.failure.message.slice(0, 1e3)
115
+ })
116
+ });
117
+ };
118
+ const failed = (marks, projection, limit) => Array.sort(Array.filter([...marks.get(projection)?.values() ?? []], (row) => row.attempts > 0), Order.combine(Order.mapInput(Order.Boolean, (row) => !row.stopped), byDue)).slice(0, limit);
119
+ const resume = (marks, projection) => {
120
+ let changed = 0;
121
+ const rows = marks.get(projection);
122
+ if (rows === void 0) return 0;
123
+ for (const [key, row] of rows) {
124
+ if (!row.stopped) continue;
125
+ rows.set(key, {
126
+ ...row,
127
+ dueAt: 0,
128
+ stopped: false
129
+ });
130
+ changed += 1;
131
+ }
132
+ return changed;
133
+ };
134
+ const retry = (marks, projection, params) => {
135
+ let changed = 0;
136
+ const rows = marks.get(projection);
137
+ if (rows === void 0) return 0;
138
+ for (const [key, row] of rows) {
139
+ if (!row.stopped && (row.attempts === 0 || row.dueAt === 0) || params !== void 0 && key !== params) continue;
140
+ rows.set(key, {
141
+ ...row,
142
+ dueAt: 0,
143
+ stopped: false
144
+ });
145
+ changed += 1;
146
+ }
147
+ return changed;
148
+ };
149
+ /** Classify each row once; a failed row at `now` is due, not backing off. */
150
+ const summary = (marks, projection, now) => {
151
+ let fresh = 0;
152
+ let sleeping = 0;
153
+ let retryDue = 0;
154
+ let backingOff = 0;
155
+ let stopped = 0;
156
+ let earliest;
157
+ for (const row of marks.get(projection)?.values() ?? []) {
158
+ if (row.stopped) {
159
+ stopped += 1;
160
+ continue;
161
+ }
162
+ if (Option.isSome(row.wakeAt)) sleeping += 1;
163
+ else if (row.attempts === 0) fresh += 1;
164
+ else if (row.dueAt <= now) retryDue += 1;
165
+ else backingOff += 1;
166
+ earliest = earliest === void 0 ? row.dueAt : Math.min(earliest, row.dueAt);
167
+ }
168
+ return {
169
+ fresh,
170
+ sleeping,
171
+ retryDue,
172
+ backingOff,
173
+ stopped,
174
+ nextDueAt: Option.fromUndefinedOr(earliest)
175
+ };
176
+ };
177
+ /** A new private marks store. Each operation runs synchronously when its Effect executes. */
178
+ const memoryProjectionMarks = () => {
179
+ const table = /* @__PURE__ */ new Map();
180
+ return {
181
+ mark: (projection, params) => Effect.sync(() => mark(table, projection, params)),
182
+ nextDue: (projection) => Effect.sync(() => nextDue(table, projection)),
183
+ summary: (projection, now) => Effect.sync(() => summary(table, projection, now)),
184
+ due: (projection, now, limit) => Effect.sync(() => due(table, projection, now, limit)),
185
+ read: (projection, params) => Effect.sync(() => read(table, projection, params)),
186
+ clear: (projection, params, seq) => Effect.sync(() => clear(table, projection, params, seq)),
187
+ sleep: (projection, params, seq, wakeAt) => Effect.sync(() => sleep(table, projection, params, seq, wakeAt)),
188
+ remove: (projection, params) => Effect.sync(() => remove(table, projection, params)),
189
+ fail: (projection, params, options) => Effect.sync(() => fail(table, projection, params, options)),
190
+ retry: (projection, params) => Effect.sync(() => retry(table, projection, params)),
191
+ resume: (projection) => Effect.sync(() => resume(table, projection)),
192
+ failed: (projection, limit) => Effect.sync(() => failed(table, projection, limit))
193
+ };
194
+ };
195
+ export { commitHookRegistry as _, failed as a, nextDue as c, resume as d, retry as f, CommitHooks as g, ProjectionMarks as h, fail as i, read as l, summary as m, copyMarks as n, mark as o, sleep as p, due as r, memoryProjectionMarks as s, clear as t, remove as u, OwnerRecords as v };
@@ -403,7 +403,7 @@ const readQueryParser = (isValidOffset) => ({ parse(url) {
403
403
  const offset = url.searchParams.get("offset") ?? void 0;
404
404
  const liveParam = url.searchParams.get("live");
405
405
  const cursor = url.searchParams.get("cursor") ?? void 0;
406
- const live = liveParam === "long-poll" || liveParam === "sse" ? liveParam : void 0;
406
+ const live = liveParam === "long-poll" || liveParam === "sse" || liveParam === "websocket" ? liveParam : void 0;
407
407
  if (offset !== void 0 && offset !== "-1" && offset !== "now" && !isValidOffset(offset)) return {
408
408
  ok: false,
409
409
  response: new Response("Invalid offset format", { status: 400 })
@@ -550,6 +550,81 @@ const makeShutdownSignal = Effect.gen(function* () {
550
550
  });
551
551
  /** A fresh signal. Provide it to the routes and call `drain` before they close. */
552
552
  const layerShutdownSignal = Layer.effect(ShutdownSignal, makeShutdownSignal);
553
+ // src/http/live-frames.ts
554
+ /**
555
+ * Frames of `live=websocket`, a Streamsy extension to Durable Streams HTTP.
556
+ *
557
+ * The server sends one `open` text frame, then a binary `data` frame and a
558
+ * `control` text frame for each batch. A `data` frame holds the exact body of
559
+ * a catch-up `GET` for the batch. A `control` frame has the fields of an SSE
560
+ * control event, and a client moves its offset only on `control`.
561
+ */
562
+ const LIVE_SOCKET_PROTOCOL = "streamsy-live.v1";
563
+ /** The only client message. The runtime answers it without running the server. */
564
+ const LIVE_PING = "ping";
565
+ const LIVE_PONG = "pong";
566
+ /** The close codes of `streamsy-live.v1`. */
567
+ const LiveCloseCode = {
568
+ /** The stream closed. A `control` frame with `streamClosed` came first. */
569
+ StreamClosed: 1e3,
570
+ InternalError: 1011,
571
+ /** The server restarted or cannot read the socket's state. Reconnect at once. */
572
+ Restart: 1012,
573
+ /** The socket fell behind the byte cap. Read over HTTP, then reconnect. */
574
+ CatchUpRequired: 4100,
575
+ BadMessage: 4400,
576
+ NotFound: 4404,
577
+ Gone: 4410
578
+ };
579
+ /** The browser socket API hides response headers, so `open` carries the content type. */
580
+ function openFrame(contentType, streamNextOffset) {
581
+ return JSON.stringify({
582
+ type: "open",
583
+ protocol: LIVE_SOCKET_PROTOCOL,
584
+ contentType,
585
+ streamNextOffset
586
+ });
587
+ }
588
+ /** The SSE control rules: no cursor on a closed stream, `upToDate` only while open. */
589
+ function controlFrame(batch) {
590
+ const frame = batch.closed ? {
591
+ type: "control",
592
+ streamNextOffset: batch.nextOffset,
593
+ streamClosed: true
594
+ } : {
595
+ type: "control",
596
+ streamNextOffset: batch.nextOffset,
597
+ streamCursor: batch.cursor
598
+ };
599
+ if (!batch.closed && batch.upToDate) frame.upToDate = true;
600
+ return JSON.stringify(frame);
601
+ }
602
+ /** The cursor a long-poll response would carry after `previous`. */
603
+ const nextCursor = Effect.fn("Http.nextCursor")(function* (previous) {
604
+ const now = yield* Clock.currentTimeMillis;
605
+ const random = yield* Random.next;
606
+ return generateCursor({ now: () => now }, previous, () => random);
607
+ });
608
+ /** The close code for a read that failed with an HTTP status. */
609
+ function closeCodeForStatus(status) {
610
+ if (status === 404) return LiveCloseCode.NotFound;
611
+ if (status === 410) return LiveCloseCode.Gone;
612
+ return LiveCloseCode.InternalError;
613
+ }
614
+ /** A `GET` that asks for `live=websocket` with an `Upgrade: websocket` header. */
615
+ function isLiveUpgrade(request) {
616
+ return request.method === "GET" && request.headers.get("upgrade")?.toLowerCase() === "websocket" && new URL(request.url).searchParams.get("live") === "websocket";
617
+ }
618
+ /** The answer to `live=websocket` from a host or request that cannot upgrade. Clients fall back to long-poll. */
619
+ function upgradeRequired() {
620
+ return new Response("WebSocket upgrade required", {
621
+ status: 426,
622
+ headers: {
623
+ upgrade: "websocket",
624
+ "cache-control": "no-store"
625
+ }
626
+ });
627
+ }
553
628
  // src/http/read.ts
554
629
  const responses$2 = responses_exports;
555
630
  const bodyCodec = message_body_codec_exports;
@@ -601,6 +676,7 @@ const read$1 = Effect.fn("Http.read")(function* (reader, id, url, requestHeaders
601
676
  return new Response(bodyCodec.emptyBodyForContentType(result.contentType), { headers });
602
677
  }
603
678
  if (query.live && !offset) return responses$2.badRequest("offset required for live modes");
679
+ if (query.live === "websocket") return upgradeRequired();
604
680
  const signal = yield* Effect.serviceOption(ShutdownSignal);
605
681
  if (query.live === "sse" && offset) {
606
682
  const meta = yield* reader.head(id);
@@ -795,4 +871,4 @@ function app(options = {}) {
795
871
  return HttpServerResponse.setHeaders(result, securityHeaders);
796
872
  }));
797
873
  }
798
- export { ShutdownSignal as a, streamPath as c, requestUrl as i, securityHeaders as l, checkReadOptions as n, layerShutdownSignal as o, read as r, discardRequestBody as s, app as t };
874
+ export { discardRequestBody as _, LIVE_PING as a, LiveCloseCode as c, isLiveUpgrade as d, nextCursor as f, layerShutdownSignal as g, ShutdownSignal as h, requestUrl as i, closeCodeForStatus as l, upgradeRequired as m, checkReadOptions as n, LIVE_PONG as o, openFrame as p, read as r, LIVE_SOCKET_PROTOCOL as s, app as t, controlFrame as u, streamPath as v, securityHeaders as y };
@@ -1139,7 +1139,13 @@ declare const commitHookRegistry: () => {
1139
1139
  beforeCommit: (hook: CommitHook) => Effect.Effect<void, never, Scope.Scope>;
1140
1140
  run: (ids: ReadonlySet<StreamId>) => Effect.Effect<void, SqlError.SqlError>;
1141
1141
  };
1142
- /** One pending mark: a binding whose input has commits that may not have run. */
1142
+ /** Last failed run, retained through marks, retries and resumes. Messages hold at most 1,000 characters. */
1143
+ interface MarkFailure {
1144
+ readonly at: number;
1145
+ readonly reason: Option.Option<string>;
1146
+ readonly message: string;
1147
+ }
1148
+ /** One pending mark: a binding with input work, a retry, or a recorded wake. */
1143
1149
  interface PendingMark {
1144
1150
  /** The binding's canonical params, as `canonicalParams` encodes them. */
1145
1151
  readonly params: string;
@@ -1147,11 +1153,26 @@ interface PendingMark {
1147
1153
  readonly seq: number;
1148
1154
  /** Failed runs since the last success. A mark keeps it. */
1149
1155
  readonly attempts: number;
1150
- /** Epoch ms. 0 means due now. */
1156
+ /** Epoch ms. 0 means due now; ignored while stopped. */
1151
1157
  readonly dueAt: number;
1158
+ /** Recorded wake; when set, equals dueAt and the row has no failure or attempts. */
1159
+ readonly wakeAt: Option.Option<number>;
1160
+ /** Waits until retry or resume. A mark preserves the stop. */
1161
+ readonly stopped: boolean;
1162
+ readonly failure: Option.Option<MarkFailure>;
1163
+ }
1164
+ /** Disjoint counts of one projection's marks at the supplied time. */
1165
+ interface ProjectionMarkSummary {
1166
+ readonly fresh: number;
1167
+ readonly sleeping: number;
1168
+ readonly retryDue: number;
1169
+ readonly backingOff: number;
1170
+ readonly stopped: number;
1171
+ /** Earliest due time across non-stopped marks, including fresh and sleeping marks. */
1172
+ readonly nextDueAt: Option.Option<number>;
1152
1173
  }
1153
1174
  /**
1154
- * Durable pending marks on the storage owner, for attached projections.
1175
+ * Pending marks for attached projections, on a storage owner or in private memory.
1155
1176
  *
1156
1177
  * A mark is keyed by projection id and canonical params. Version and generation
1157
1178
  * are left out, so a deploy that raises the version picks up the old marks.
@@ -1159,26 +1180,42 @@ interface PendingMark {
1159
1180
  interface ProjectionMarksApi {
1160
1181
  /**
1161
1182
  * Insert a mark for each binding, or raise its `seq`. A raise keeps
1162
- * `attempts` and `dueAt`, so a write does not reset a binding's backoff.
1183
+ * `attempts`, `stopped` and `failure`, so a write never resets backoff or a stop.
1184
+ * A sleeping row becomes due now and loses its wake index.
1163
1185
  * Call it inside a commit hook. It joins the transaction and fails like the
1164
1186
  * transaction's own statements.
1165
1187
  */
1166
1188
  readonly mark: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<void, SqlError.SqlError>;
1167
- /** The earliest `dueAt` of the projection's marks. */
1189
+ /** The earliest `dueAt` of the projection's non-stopped marks. */
1168
1190
  readonly nextDue: (projection: string) => Effect.Effect<Option.Option<number>, StorageFault>;
1169
- /** Up to `limit` marks with `dueAt <= now`, earliest first. */
1191
+ /** Five disjoint counts: fresh, sleeping, retry due, backing off and stopped. */
1192
+ readonly summary: (projection: string, now: number) => Effect.Effect<ProjectionMarkSummary, StorageFault>;
1193
+ /** Up to `limit` non-stopped marks with `dueAt <= now`, earliest first. */
1170
1194
  readonly due: (projection: string, now: number, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
1171
1195
  /** The marks of these bindings that exist, keyed by params. */
1172
1196
  readonly read: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<ReadonlyMap<string, PendingMark>, StorageFault>;
1173
- /** Delete the mark if its `seq` still equals `seq`. A later mark keeps the row. */
1197
+ /** Delete on a matching `seq`; otherwise keep the row and reset its failure, attempts, dueAt, wakeAt and stop. */
1174
1198
  readonly clear: (projection: string, params: string, seq: number) => Effect.Effect<void, StorageFault>;
1199
+ /** Keep a matching row asleep at wakeAt and reset failure state. A seq mismatch
1200
+ * becomes fresh and due now. An absent row is inserted asleep with seq 1. */
1201
+ readonly sleep: (projection: string, params: string, seq: number, wakeAt: number) => Effect.Effect<void, StorageFault>;
1175
1202
  /** Delete the mark whatever its `seq`. */
1176
1203
  readonly remove: (projection: string, params: string) => Effect.Effect<void, StorageFault>;
1177
- /** Set `attempts` and `dueAt`, and insert the mark if it is absent. */
1178
- readonly defer: (projection: string, params: string, attempts: number, dueAt: number) => Effect.Effect<void, StorageFault>;
1179
- /** The number of the projection's marks with at least one failed attempt. */
1180
- readonly deferred: (projection: string) => Effect.Effect<number, StorageFault>;
1204
+ /** Insert or update a failure, preserving seq. Some(dueAt) backs off; None stops. */
1205
+ readonly fail: (projection: string, params: string, options: {
1206
+ readonly attempts: number;
1207
+ readonly failure: MarkFailure;
1208
+ readonly dueAt: Option.Option<number>;
1209
+ }) => Effect.Effect<void, StorageFault>;
1210
+ /** Set failed or stopped marks due now and clear their stop, preserving attempts, seq and failure.
1211
+ * Optionally select one binding. Returns the number changed; already due, non-stopped marks are unchanged.
1212
+ */
1213
+ readonly retry: (projection: string, params?: string) => Effect.Effect<number, StorageFault>;
1214
+ /** Make stopped marks due now, preserving attempts, seq and failure. Returns the number changed. */
1215
+ readonly resume: (projection: string) => Effect.Effect<number, StorageFault>;
1216
+ /** Up to limit marks with attempts > 0, stopped first, then by dueAt and params. */
1217
+ readonly failed: (projection: string, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
1181
1218
  }
1182
1219
  declare const ProjectionMarks_base: Context.ServiceClass<ProjectionMarks, "@streamsy/core/internal/ProjectionMarks", ProjectionMarksApi>;
1183
1220
  declare class ProjectionMarks extends ProjectionMarks_base {}
1184
- export { StaleEpoch as $, ReadNextResult as A, HeadError as B, StreamsReader as C, EncodeFault as Ct, CreateResult as D, isRetryableFault as Dt, AppendResult as E, TransportFault as Et, AppendErrorFor as F, InvalidReadRequest as G, InvalidCreateRequest as H, CreateConflict as I, ProducerGap as J, NotSupported as K, CreateConflictReason as L, AppendBaseError as M, AppendConflict as N, HeadResult as O, isStreamsFault as Ot, AppendError as P, RemoveError as Q, CreateError as R, Reader as S, DecodeFault as St, Writer as T, StreamsFault as Tt, InvalidEpochSeq as U, InvalidAppendRequest as V, InvalidForkRequest as W, ReadError as X, ProtocolError as Y, ReadNextError as Z, OperationResult as _, StoredMessage as _t, CommitHooks as a, AppendCallOptions as at, ProducerPrecondition as b, StreamLifecycle as bt, OwnerRecords as c, ReadNextOptions as ct, StorageShape as d, ChangeSnapshot as dt, StreamBusy as et, Mutation as f, MessageWindow as ft, Operation as g, RecordPatch as gt, Mutations as h, ProducerState as ht, CommitHook as i, isProtocolError as it, ReadResult as j, ReadMessage as k, OwnerRecordsApi as l, ReadOptions as lt, MutationRejected as m, ProducerId as mt, ProjectionMarks as n, StreamGone as nt, CommitHooksApi as o, AppendOptions as ot, MutationApplied as p, Offset as pt, OffsetMismatch as q, ProjectionMarksApi as r, StreamNotFound as rt, commitHookRegistry as s, ProducerOptions as st, PendingMark as t, StreamClosed as tt, Storage as u, CreateOptions as ut, OperationResults as v, StreamConfig as vt, StreamsWriter as w, StorageFault as wt, StorageCapabilities as x, StreamRecord as xt, Operations as y, StreamId as yt, ForkSourceNotFound as z };
1221
+ export { ReadNextError as $, HeadResult as A, isStreamsFault as At, CreateError as B, StorageCapabilities as C, StreamRecord as Ct, Writer as D, StreamsFault as Dt, StreamsWriter as E, StorageFault as Et, AppendConflict as F, InvalidEpochSeq as G, HeadError as H, AppendError as I, NotSupported as J, InvalidForkRequest as K, AppendErrorFor as L, ReadNextResult as M, ReadResult as N, AppendResult as O, TransportFault as Ot, AppendBaseError as P, ReadError as Q, CreateConflict as R, ProducerPrecondition as S, StreamLifecycle as St, StreamsReader as T, EncodeFault as Tt, InvalidAppendRequest as U, ForkSourceNotFound as V, InvalidCreateRequest as W, ProducerGap as X, OffsetMismatch as Y, ProtocolError as Z, Mutations as _, ProducerState as _t, ProjectionMarksApi as a, StreamNotFound as at, OperationResults as b, StreamConfig as bt, CommitHooksApi as c, AppendOptions as ct, OwnerRecordsApi as d, ReadOptions as dt, RemoveError as et, Storage as f, CreateOptions as ft, MutationRejected as g, ProducerId as gt, MutationApplied as h, Offset as ht, ProjectionMarks as i, StreamGone as it, ReadMessage as j, CreateResult as k, isRetryableFault as kt, commitHookRegistry as l, ProducerOptions as lt, Mutation as m, MessageWindow as mt, PendingMark as n, StreamBusy as nt, CommitHook as o, isProtocolError as ot, StorageShape as p, ChangeSnapshot as pt, InvalidReadRequest as q, ProjectionMarkSummary as r, StreamClosed as rt, CommitHooks as s, AppendCallOptions as st, MarkFailure as t, StaleEpoch as tt, OwnerRecords as u, ReadNextOptions as ut, Operation as v, RecordPatch as vt, Reader as w, DecodeFault as wt, Operations as x, StreamId as xt, OperationResult as y, StoredMessage as yt, CreateConflictReason as z };
@@ -1,5 +1,5 @@
1
- import { C as StreamsReader, S as Reader, T as Writer, w as StreamsWriter } from "../projection-marks-Ca0Q-L9H.js";
2
- import { D as streams_d_exports, P as layer_d_exports, u as RoutesOptions, z as route_d_exports } from "../index-B_o4-vX4.js";
1
+ import { D as Writer, E as StreamsWriter, T as StreamsReader, w as Reader } from "../projection-marks-CzlDS-kj.js";
2
+ import { $ as route_d_exports, J as layer_d_exports, V as streams_d_exports, w as RoutesOptions } from "../index-ooCOjS7N.js";
3
3
  import { HttpRouter } from "effect/http";
4
4
  /** Raw protocol route for adapters and wire conformance tests. */
5
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>>;
@@ -1,6 +1,6 @@
1
1
  import { F as StreamsReader, I as StreamsWriter, l as streams_exports, u as route_exports } from "../streamsy-HKC10a_V.js";
2
- import { n as layer_exports } from "../layer-DZOWeK0B.js";
3
- import { t as app } from "../program-B6L8HGca.js";
2
+ import { n as layer_exports } from "../layer-DjKTdIY5.js";
3
+ import { t as app } from "../program-BlfAJNlD.js";
4
4
  import { HttpRouter } from "effect/http";
5
5
  // src/protocol/routes.ts
6
6
  /** Raw protocol route for adapters and wire conformance tests. */
@@ -0,0 +1,11 @@
1
+ // src/internal/read-offsets.ts
2
+ const Metadata = Symbol.for("@streamsy/core/internal/ReadOffsets");
3
+ const attachOffsets = (result, offsets) => Object.defineProperty(result, Metadata, {
4
+ value: offsets,
5
+ enumerable: false
6
+ });
7
+ const offsetsOf = (result) => {
8
+ if (!(Metadata in result)) return void 0;
9
+ return result[Metadata];
10
+ };
11
+ export { offsetsOf as n, attachOffsets as t };
@@ -1,5 +1,5 @@
1
- import { C as StreamsReader, Et as TransportFault, w as StreamsWriter } from "../projection-marks-Ca0Q-L9H.js";
2
- import { f as Any, m as Identifiers, p as Group } from "../index-B_o4-vX4.js";
1
+ import { E as StreamsWriter, Ot as TransportFault, T as StreamsReader } from "../projection-marks-CzlDS-kj.js";
2
+ import { D as Group, E as Any, O as Identifiers } from "../index-ooCOjS7N.js";
3
3
  import { Layer } from "effect";
4
4
  import { HttpClient, HttpClientRequest } from "effect/http";
5
5
  interface Options {
@@ -1,5 +1,5 @@
1
- import { C as StreamsReader, dt as ChangeSnapshot, u as Storage, w as StreamsWriter, x as StorageCapabilities, yt as StreamId } from "../projection-marks-Ca0Q-L9H.js";
2
- import { M as MemoryOptions, N as ProtocolOptions } from "../index-B_o4-vX4.js";
1
+ import { C as StorageCapabilities, E as StreamsWriter, T as StreamsReader, f as Storage, pt as ChangeSnapshot, xt as StreamId } from "../projection-marks-CzlDS-kj.js";
2
+ import { K as MemoryOptions, q as ProtocolOptions } from "../index-ooCOjS7N.js";
3
3
  import { Context, Effect, Layer } from "effect";
4
4
  interface StorageContractOptions {
5
5
  readonly name: string;