@streamsy/core 0.11.0 → 0.13.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,197 @@
1
+ import { Array, Context, Effect, Option, Order } from "effect";
2
+ // src/internal/owner-records.ts
3
+ /** The `StorageFault.operation` of an owner store that cannot list its records. */
4
+ const OWNER_RECORDS_LIST_UNSUPPORTED = "records.list.unsupported";
5
+ var OwnerRecords = class extends Context.Service()("@streamsy/core/internal/OwnerRecords") {};
6
+ // src/internal/commit-hooks.ts
7
+ var CommitHooks = class extends Context.Service()("@streamsy/core/internal/CommitHooks") {};
8
+ /** Shared registry for storage boundaries: register in a scope, run in order. */
9
+ const commitHookRegistry = () => {
10
+ const hooks = /* @__PURE__ */ new Set();
11
+ const beforeCommit = (hook) => Effect.acquireRelease(Effect.sync(() => {
12
+ const entry = { hook };
13
+ hooks.add(entry);
14
+ return entry;
15
+ }), (entry) => Effect.sync(() => {
16
+ hooks.delete(entry);
17
+ })).pipe(Effect.asVoid);
18
+ const run = (ids) => ids.size === 0 || hooks.size === 0 ? Effect.void : Effect.forEach([...hooks], (entry) => entry.hook(ids), { discard: true });
19
+ return {
20
+ beforeCommit,
21
+ run
22
+ };
23
+ };
24
+ // src/internal/projection-marks.ts
25
+ var ProjectionMarks = class extends Context.Service()("@streamsy/core/internal/ProjectionMarks") {};
26
+ // src/storage/memory/marks.ts
27
+ /** A private transaction draft of the marks. */
28
+ const copyMarks = (marks) => new Map(Array.map([...marks], ([projection, rows]) => [projection, new Map(rows)]));
29
+ const rowsOf = (marks, projection) => {
30
+ const found = marks.get(projection);
31
+ if (found !== void 0) return found;
32
+ const rows = /* @__PURE__ */ new Map();
33
+ marks.set(projection, rows);
34
+ return rows;
35
+ };
36
+ const byDue = Order.mapInput(Order.Tuple([Order.Number, Order.String]), (mark) => [mark.dueAt, mark.params]);
37
+ const mark = (marks, projection, params) => {
38
+ const rows = rowsOf(marks, projection);
39
+ for (const value of params) {
40
+ const found = rows.get(value);
41
+ rows.set(value, found === void 0 ? {
42
+ params: value,
43
+ seq: 1,
44
+ attempts: 0,
45
+ dueAt: 0,
46
+ stopped: false,
47
+ wakeAt: Option.none(),
48
+ failure: Option.none()
49
+ } : {
50
+ ...found,
51
+ seq: found.seq + 1,
52
+ dueAt: Option.isSome(found.wakeAt) ? 0 : found.dueAt,
53
+ wakeAt: Option.none()
54
+ });
55
+ }
56
+ };
57
+ const nextDue = (marks, projection) => {
58
+ let earliest;
59
+ for (const row of marks.get(projection)?.values() ?? []) if (!row.stopped) earliest = earliest === void 0 ? row.dueAt : Math.min(earliest, row.dueAt);
60
+ return Option.fromUndefinedOr(earliest);
61
+ };
62
+ const due = (marks, projection, now, limit) => Array.sort(Array.filter([...marks.get(projection)?.values() ?? []], (row) => !row.stopped && row.dueAt <= now), byDue).slice(0, limit);
63
+ const read = (marks, projection, params) => {
64
+ const rows = marks.get(projection);
65
+ const found = /* @__PURE__ */ new Map();
66
+ for (const value of params) {
67
+ const row = rows?.get(value);
68
+ if (row !== void 0) found.set(value, row);
69
+ }
70
+ return found;
71
+ };
72
+ const clear = (marks, projection, params, seq) => {
73
+ const rows = marks.get(projection);
74
+ const row = rows?.get(params);
75
+ if (rows === void 0 || row === void 0) return;
76
+ if (row.seq === seq) rows.delete(params);
77
+ else rows.set(params, {
78
+ ...row,
79
+ attempts: 0,
80
+ dueAt: 0,
81
+ stopped: false,
82
+ wakeAt: Option.none(),
83
+ failure: Option.none()
84
+ });
85
+ };
86
+ /** Sleep only the seq that ran; a concurrent write must run before it can sleep. */
87
+ const sleep = (marks, projection, params, seq, wakeAt) => {
88
+ const rows = rowsOf(marks, projection);
89
+ const row = rows.get(params);
90
+ const matching = row === void 0 || row.seq === seq;
91
+ rows.set(params, {
92
+ params,
93
+ seq: row?.seq ?? 1,
94
+ attempts: 0,
95
+ dueAt: matching ? wakeAt : 0,
96
+ wakeAt: matching ? Option.some(wakeAt) : Option.none(),
97
+ stopped: false,
98
+ failure: Option.none()
99
+ });
100
+ };
101
+ const remove = (marks, projection, params) => {
102
+ marks.get(projection)?.delete(params);
103
+ };
104
+ const fail = (marks, projection, params, options) => {
105
+ const rows = rowsOf(marks, projection);
106
+ const found = rows.get(params);
107
+ rows.set(params, {
108
+ params,
109
+ seq: found?.seq ?? 1,
110
+ attempts: options.attempts,
111
+ dueAt: Option.getOrElse(options.dueAt, () => 0),
112
+ stopped: Option.isNone(options.dueAt),
113
+ wakeAt: Option.none(),
114
+ failure: Option.some({
115
+ ...options.failure,
116
+ message: options.failure.message.slice(0, 1e3)
117
+ })
118
+ });
119
+ };
120
+ 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);
121
+ const resume = (marks, projection) => {
122
+ let changed = 0;
123
+ const rows = marks.get(projection);
124
+ if (rows === void 0) return 0;
125
+ for (const [key, row] of rows) {
126
+ if (!row.stopped) continue;
127
+ rows.set(key, {
128
+ ...row,
129
+ dueAt: 0,
130
+ stopped: false
131
+ });
132
+ changed += 1;
133
+ }
134
+ return changed;
135
+ };
136
+ const retry = (marks, projection, params) => {
137
+ let changed = 0;
138
+ const rows = marks.get(projection);
139
+ if (rows === void 0) return 0;
140
+ for (const [key, row] of rows) {
141
+ if (!row.stopped && (row.attempts === 0 || row.dueAt === 0) || params !== void 0 && key !== params) continue;
142
+ rows.set(key, {
143
+ ...row,
144
+ dueAt: 0,
145
+ stopped: false
146
+ });
147
+ changed += 1;
148
+ }
149
+ return changed;
150
+ };
151
+ /** Classify each row once; a failed row at `now` is due, not backing off. */
152
+ const summary = (marks, projection, now) => {
153
+ let fresh = 0;
154
+ let sleeping = 0;
155
+ let retryDue = 0;
156
+ let backingOff = 0;
157
+ let stopped = 0;
158
+ let earliest;
159
+ for (const row of marks.get(projection)?.values() ?? []) {
160
+ if (row.stopped) {
161
+ stopped += 1;
162
+ continue;
163
+ }
164
+ if (Option.isSome(row.wakeAt)) sleeping += 1;
165
+ else if (row.attempts === 0) fresh += 1;
166
+ else if (row.dueAt <= now) retryDue += 1;
167
+ else backingOff += 1;
168
+ earliest = earliest === void 0 ? row.dueAt : Math.min(earliest, row.dueAt);
169
+ }
170
+ return {
171
+ fresh,
172
+ sleeping,
173
+ retryDue,
174
+ backingOff,
175
+ stopped,
176
+ nextDueAt: Option.fromUndefinedOr(earliest)
177
+ };
178
+ };
179
+ /** A new private marks store. Each operation runs synchronously when its Effect executes. */
180
+ const memoryProjectionMarks = () => {
181
+ const table = /* @__PURE__ */ new Map();
182
+ return {
183
+ mark: (projection, params) => Effect.sync(() => mark(table, projection, params)),
184
+ nextDue: (projection) => Effect.sync(() => nextDue(table, projection)),
185
+ summary: (projection, now) => Effect.sync(() => summary(table, projection, now)),
186
+ due: (projection, now, limit) => Effect.sync(() => due(table, projection, now, limit)),
187
+ read: (projection, params) => Effect.sync(() => read(table, projection, params)),
188
+ clear: (projection, params, seq) => Effect.sync(() => clear(table, projection, params, seq)),
189
+ sleep: (projection, params, seq, wakeAt) => Effect.sync(() => sleep(table, projection, params, seq, wakeAt)),
190
+ remove: (projection, params) => Effect.sync(() => remove(table, projection, params)),
191
+ fail: (projection, params, options) => Effect.sync(() => fail(table, projection, params, options)),
192
+ retry: (projection, params) => Effect.sync(() => retry(table, projection, params)),
193
+ resume: (projection) => Effect.sync(() => resume(table, projection)),
194
+ failed: (projection, limit) => Effect.sync(() => failed(table, projection, limit))
195
+ };
196
+ };
197
+ 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, OWNER_RECORDS_LIST_UNSUPPORTED as v, OwnerRecords as y };
@@ -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 };
@@ -1108,9 +1108,16 @@ declare class Storage extends Storage_base {}
1108
1108
  */
1109
1109
  interface OwnerRecordsApi {
1110
1110
  readonly read: (key: string) => Effect.Effect<Option.Option<string>, StorageFault>;
1111
+ /**
1112
+ * A snapshot of the owner's encoded entries whose keys start with this exact prefix.
1113
+ * A store that cannot list fails with operation `OWNER_RECORDS_LIST_UNSUPPORTED`.
1114
+ */
1115
+ readonly list: (prefix: string) => Effect.Effect<ReadonlyArray<readonly [key: string, encoded: string]>, StorageFault>;
1111
1116
  readonly write: (key: string, encoded: string) => Effect.Effect<void, StorageFault>;
1112
1117
  readonly remove: (key: string) => Effect.Effect<void, StorageFault>;
1113
1118
  }
1119
+ /** The `StorageFault.operation` of an owner store that cannot list its records. */
1120
+ declare const OWNER_RECORDS_LIST_UNSUPPORTED = "records.list.unsupported";
1114
1121
  declare const OwnerRecords_base: Context.ServiceClass<OwnerRecords, "@streamsy/core/internal/OwnerRecords", OwnerRecordsApi>;
1115
1122
  declare class OwnerRecords extends OwnerRecords_base {}
1116
1123
  /**
@@ -1139,7 +1146,13 @@ declare const commitHookRegistry: () => {
1139
1146
  beforeCommit: (hook: CommitHook) => Effect.Effect<void, never, Scope.Scope>;
1140
1147
  run: (ids: ReadonlySet<StreamId>) => Effect.Effect<void, SqlError.SqlError>;
1141
1148
  };
1142
- /** One pending mark: a binding whose input has commits that may not have run. */
1149
+ /** Last failed run, retained through marks, retries and resumes. Messages hold at most 1,000 characters. */
1150
+ interface MarkFailure {
1151
+ readonly at: number;
1152
+ readonly reason: Option.Option<string>;
1153
+ readonly message: string;
1154
+ }
1155
+ /** One pending mark: a binding with input work, a retry, or a recorded wake. */
1143
1156
  interface PendingMark {
1144
1157
  /** The binding's canonical params, as `canonicalParams` encodes them. */
1145
1158
  readonly params: string;
@@ -1147,11 +1160,26 @@ interface PendingMark {
1147
1160
  readonly seq: number;
1148
1161
  /** Failed runs since the last success. A mark keeps it. */
1149
1162
  readonly attempts: number;
1150
- /** Epoch ms. 0 means due now. */
1163
+ /** Epoch ms. 0 means due now; ignored while stopped. */
1151
1164
  readonly dueAt: number;
1165
+ /** Recorded wake; when set, equals dueAt and the row has no failure or attempts. */
1166
+ readonly wakeAt: Option.Option<number>;
1167
+ /** Waits until retry or resume. A mark preserves the stop. */
1168
+ readonly stopped: boolean;
1169
+ readonly failure: Option.Option<MarkFailure>;
1170
+ }
1171
+ /** Disjoint counts of one projection's marks at the supplied time. */
1172
+ interface ProjectionMarkSummary {
1173
+ readonly fresh: number;
1174
+ readonly sleeping: number;
1175
+ readonly retryDue: number;
1176
+ readonly backingOff: number;
1177
+ readonly stopped: number;
1178
+ /** Earliest due time across non-stopped marks, including fresh and sleeping marks. */
1179
+ readonly nextDueAt: Option.Option<number>;
1152
1180
  }
1153
1181
  /**
1154
- * Durable pending marks on the storage owner, for attached projections.
1182
+ * Pending marks for attached projections, on a storage owner or in private memory.
1155
1183
  *
1156
1184
  * A mark is keyed by projection id and canonical params. Version and generation
1157
1185
  * are left out, so a deploy that raises the version picks up the old marks.
@@ -1159,26 +1187,42 @@ interface PendingMark {
1159
1187
  interface ProjectionMarksApi {
1160
1188
  /**
1161
1189
  * 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.
1190
+ * `attempts`, `stopped` and `failure`, so a write never resets backoff or a stop.
1191
+ * A sleeping row becomes due now and loses its wake index.
1163
1192
  * Call it inside a commit hook. It joins the transaction and fails like the
1164
1193
  * transaction's own statements.
1165
1194
  */
1166
1195
  readonly mark: (projection: string, params: ReadonlyArray<string>) => Effect.Effect<void, SqlError.SqlError>;
1167
- /** The earliest `dueAt` of the projection's marks. */
1196
+ /** The earliest `dueAt` of the projection's non-stopped marks. */
1168
1197
  readonly nextDue: (projection: string) => Effect.Effect<Option.Option<number>, StorageFault>;
1169
- /** Up to `limit` marks with `dueAt <= now`, earliest first. */
1198
+ /** Five disjoint counts: fresh, sleeping, retry due, backing off and stopped. */
1199
+ readonly summary: (projection: string, now: number) => Effect.Effect<ProjectionMarkSummary, StorageFault>;
1200
+ /** Up to `limit` non-stopped marks with `dueAt <= now`, earliest first. */
1170
1201
  readonly due: (projection: string, now: number, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
1171
1202
  /** The marks of these bindings that exist, keyed by params. */
1172
1203
  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. */
1204
+ /** Delete on a matching `seq`; otherwise keep the row and reset its failure, attempts, dueAt, wakeAt and stop. */
1174
1205
  readonly clear: (projection: string, params: string, seq: number) => Effect.Effect<void, StorageFault>;
1206
+ /** Keep a matching row asleep at wakeAt and reset failure state. A seq mismatch
1207
+ * becomes fresh and due now. An absent row is inserted asleep with seq 1. */
1208
+ readonly sleep: (projection: string, params: string, seq: number, wakeAt: number) => Effect.Effect<void, StorageFault>;
1175
1209
  /** Delete the mark whatever its `seq`. */
1176
1210
  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>;
1211
+ /** Insert or update a failure, preserving seq. Some(dueAt) backs off; None stops. */
1212
+ readonly fail: (projection: string, params: string, options: {
1213
+ readonly attempts: number;
1214
+ readonly failure: MarkFailure;
1215
+ readonly dueAt: Option.Option<number>;
1216
+ }) => Effect.Effect<void, StorageFault>;
1217
+ /** Set failed or stopped marks due now and clear their stop, preserving attempts, seq and failure.
1218
+ * Optionally select one binding. Returns the number changed; already due, non-stopped marks are unchanged.
1219
+ */
1220
+ readonly retry: (projection: string, params?: string) => Effect.Effect<number, StorageFault>;
1221
+ /** Make stopped marks due now, preserving attempts, seq and failure. Returns the number changed. */
1222
+ readonly resume: (projection: string) => Effect.Effect<number, StorageFault>;
1223
+ /** Up to limit marks with attempts > 0, stopped first, then by dueAt and params. */
1224
+ readonly failed: (projection: string, limit: number) => Effect.Effect<ReadonlyArray<PendingMark>, StorageFault>;
1181
1225
  }
1182
1226
  declare const ProjectionMarks_base: Context.ServiceClass<ProjectionMarks, "@streamsy/core/internal/ProjectionMarks", ProjectionMarksApi>;
1183
1227
  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 };
1228
+ export { ReadError as $, CreateResult as A, isRetryableFault as At, CreateConflictReason as B, ProducerPrecondition as C, StreamLifecycle as Ct, StreamsWriter as D, StorageFault as Dt, StreamsReader as E, EncodeFault as Et, AppendBaseError as F, InvalidCreateRequest as G, ForkSourceNotFound as H, AppendConflict as I, InvalidReadRequest as J, InvalidEpochSeq as K, AppendError as L, ReadMessage as M, ReadNextResult as N, Writer as O, StreamsFault as Ot, ReadResult as P, ProtocolError as Q, AppendErrorFor as R, Operations as S, StreamId as St, Reader as T, DecodeFault as Tt, HeadError as U, CreateError as V, InvalidAppendRequest as W, OffsetMismatch as X, NotSupported as Y, ProducerGap as Z, MutationRejected as _, ProducerId as _t, ProjectionMarksApi as a, StreamGone as at, OperationResult as b, StoredMessage as bt, CommitHooksApi as c, AppendCallOptions as ct, OwnerRecords as d, ReadNextOptions as dt, ReadNextError as et, OwnerRecordsApi as f, ReadOptions as ft, MutationApplied as g, Offset as gt, Mutation as h, MessageWindow as ht, ProjectionMarks as i, StreamClosed as it, HeadResult as j, isStreamsFault as jt, AppendResult as k, TransportFault as kt, commitHookRegistry as l, AppendOptions as lt, StorageShape as m, ChangeSnapshot as mt, PendingMark as n, StaleEpoch as nt, CommitHook as o, StreamNotFound as ot, Storage as p, CreateOptions as pt, InvalidForkRequest as q, ProjectionMarkSummary as r, StreamBusy as rt, CommitHooks as s, isProtocolError as st, MarkFailure as t, RemoveError as tt, OWNER_RECORDS_LIST_UNSUPPORTED as u, ProducerOptions as ut, Mutations as v, ProducerState as vt, StorageCapabilities as w, StreamRecord as wt, OperationResults as x, StreamConfig as xt, Operation as y, RecordPatch as yt, CreateConflict 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 StreamsWriter, E as StreamsReader, O as Writer, T as Reader } from "../projection-marks-c7-wvpSn.js";
2
+ import { $ as route_d_exports, J as layer_d_exports, V as streams_d_exports, w as RoutesOptions } from "../index-vnyfaf-e.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 { D as StreamsWriter, E as StreamsReader, kt as TransportFault } from "../projection-marks-c7-wvpSn.js";
2
+ import { D as Group, E as Any, O as Identifiers } from "../index-vnyfaf-e.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 { D as StreamsWriter, E as StreamsReader, St as StreamId, mt as ChangeSnapshot, p as Storage, w as StorageCapabilities } from "../projection-marks-c7-wvpSn.js";
2
+ import { K as MemoryOptions, q as ProtocolOptions } from "../index-vnyfaf-e.js";
3
3
  import { Context, Effect, Layer } from "effect";
4
4
  interface StorageContractOptions {
5
5
  readonly name: string;