@streamsy/core 0.13.0 → 0.14.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,371 @@
1
+ import { a as attachOwner } from "./route-internal-DNL0oGTN.js";
2
+ import { Array, Cause, Context, Effect, Exit, Option, Order, Schema, Semaphore } from "effect";
3
+ // src/storage/commit-boundary.ts
4
+ /** The transaction of the storage owner. Every Streamsy storage host provides it. */
5
+ var CommitBoundary = class extends Context.Service()("@streamsy/core/CommitBoundary") {};
6
+ // src/storage/memory/state.ts
7
+ const copyRecord = (record) => ({
8
+ id: record.id,
9
+ currentOffset: record.currentOffset,
10
+ config: { ...record.config },
11
+ lifecycle: { ...record.lifecycle }
12
+ });
13
+ const copyMessage = (message) => ({
14
+ offset: message.offset,
15
+ timestamp: message.timestamp,
16
+ data: new Uint8Array(message.data)
17
+ });
18
+ function patchRecord(record, patch) {
19
+ const config = {
20
+ ...record.config,
21
+ ...patch.config
22
+ };
23
+ const lifecycle = {
24
+ ...record.lifecycle,
25
+ ...patch.lifecycle
26
+ };
27
+ for (const key of patch.clear ?? []) switch (key) {
28
+ case "ttlSeconds":
29
+ delete config.ttlSeconds;
30
+ break;
31
+ case "expiresAt":
32
+ delete config.expiresAt;
33
+ break;
34
+ case "expiresAtMs":
35
+ delete lifecycle.expiresAtMs;
36
+ break;
37
+ case "lastSeq": delete lifecycle.lastSeq;
38
+ }
39
+ return {
40
+ id: record.id,
41
+ currentOffset: patch.currentOffset ?? record.currentOffset,
42
+ config,
43
+ lifecycle
44
+ };
45
+ }
46
+ function indexDeadlines(state) {
47
+ state.deadlines = Array.sort(Array.flatMap([...state.entries.values()], ({ record }) => record.lifecycle.softDeleted || record.lifecycle.expiresAtMs === void 0 ? [] : [{
48
+ at: record.lifecycle.expiresAtMs,
49
+ streamId: record.id
50
+ }]), Order.make((a, b) => {
51
+ const compared = a.at - b.at || a.streamId.localeCompare(b.streamId);
52
+ return compared < 0 ? -1 : compared > 0 ? 1 : 0;
53
+ }));
54
+ }
55
+ /** A private transaction draft; no mutable stream data aliases the committed state. */
56
+ const copyState = (state) => ({
57
+ entries: new Map(Array.map([...state.entries], ([id, entry]) => [id, {
58
+ record: copyRecord(entry.record),
59
+ messages: Array.map(entry.messages, copyMessage),
60
+ producers: new Map(Array.map([...entry.producers], ([producerId, producer]) => [producerId, {
61
+ epoch: producer.epoch,
62
+ lastSeq: producer.lastSeq
63
+ }]))
64
+ }])),
65
+ children: new Map(Array.map([...state.children], ([id, children]) => [id, new Set(children)])),
66
+ deadlines: Array.map(state.deadlines, (deadline) => ({ ...deadline }))
67
+ });
68
+ // src/internal/owner-records.ts
69
+ /** The `StorageFault.operation` of an owner store that cannot list its records. */
70
+ const OWNER_RECORDS_LIST_UNSUPPORTED = "records.list.unsupported";
71
+ var OwnerRecords = class extends Context.Service()("@streamsy/core/internal/OwnerRecords") {};
72
+ // src/internal/commit-hooks.ts
73
+ var CommitHooks = class extends Context.Service()("@streamsy/core/internal/CommitHooks") {};
74
+ /** Shared registry for storage boundaries: register in a scope, run in order. */
75
+ const commitHookRegistry = () => {
76
+ const hooks = /* @__PURE__ */ new Set();
77
+ const beforeCommit = (hook) => Effect.acquireRelease(Effect.sync(() => {
78
+ const entry = { hook };
79
+ hooks.add(entry);
80
+ return entry;
81
+ }), (entry) => Effect.sync(() => {
82
+ hooks.delete(entry);
83
+ })).pipe(Effect.asVoid);
84
+ const run = (ids) => ids.size === 0 || hooks.size === 0 ? Effect.void : Effect.forEach([...hooks], (entry) => entry.hook(ids), { discard: true });
85
+ return {
86
+ beforeCommit,
87
+ run
88
+ };
89
+ };
90
+ // src/internal/projection-marks.ts
91
+ var ProjectionMarks = class extends Context.Service()("@streamsy/core/internal/ProjectionMarks") {};
92
+ // src/storage/memory/marks.ts
93
+ /** A private transaction draft of the marks. */
94
+ const copyMarks = (marks) => new Map(Array.map([...marks], ([projection, rows]) => [projection, new Map(rows)]));
95
+ const rowsOf = (marks, projection) => {
96
+ const found = marks.get(projection);
97
+ if (found !== void 0) return found;
98
+ const rows = /* @__PURE__ */ new Map();
99
+ marks.set(projection, rows);
100
+ return rows;
101
+ };
102
+ const byDue = Order.mapInput(Order.Tuple([Order.Number, Order.String]), (mark) => [mark.dueAt, mark.params]);
103
+ const mark = (marks, projection, params) => {
104
+ const rows = rowsOf(marks, projection);
105
+ for (const value of params) {
106
+ const found = rows.get(value);
107
+ rows.set(value, found === void 0 ? {
108
+ params: value,
109
+ seq: 1,
110
+ attempts: 0,
111
+ dueAt: 0,
112
+ stopped: false,
113
+ wakeAt: Option.none(),
114
+ failure: Option.none()
115
+ } : {
116
+ ...found,
117
+ seq: found.seq + 1,
118
+ dueAt: Option.isSome(found.wakeAt) ? 0 : found.dueAt,
119
+ wakeAt: Option.none()
120
+ });
121
+ }
122
+ };
123
+ const nextDue = (marks, projection) => {
124
+ let earliest;
125
+ for (const row of marks.get(projection)?.values() ?? []) if (!row.stopped) earliest = earliest === void 0 ? row.dueAt : Math.min(earliest, row.dueAt);
126
+ return Option.fromUndefinedOr(earliest);
127
+ };
128
+ const due = (marks, projection, now, limit) => Array.sort(Array.filter([...marks.get(projection)?.values() ?? []], (row) => !row.stopped && row.dueAt <= now), byDue).slice(0, limit);
129
+ const read = (marks, projection, params) => {
130
+ const rows = marks.get(projection);
131
+ const found = /* @__PURE__ */ new Map();
132
+ for (const value of params) {
133
+ const row = rows?.get(value);
134
+ if (row !== void 0) found.set(value, row);
135
+ }
136
+ return found;
137
+ };
138
+ const clear = (marks, projection, params, seq) => {
139
+ const rows = marks.get(projection);
140
+ const row = rows?.get(params);
141
+ if (rows === void 0 || row === void 0) return;
142
+ if (row.seq === seq) rows.delete(params);
143
+ else rows.set(params, {
144
+ ...row,
145
+ attempts: 0,
146
+ dueAt: 0,
147
+ stopped: false,
148
+ wakeAt: Option.none(),
149
+ failure: Option.none()
150
+ });
151
+ };
152
+ /** Sleep only the seq that ran; a concurrent write must run before it can sleep. */
153
+ const sleep = (marks, projection, params, seq, wakeAt) => {
154
+ const rows = rowsOf(marks, projection);
155
+ const row = rows.get(params);
156
+ const matching = row === void 0 || row.seq === seq;
157
+ rows.set(params, {
158
+ params,
159
+ seq: row?.seq ?? 1,
160
+ attempts: 0,
161
+ dueAt: matching ? wakeAt : 0,
162
+ wakeAt: matching ? Option.some(wakeAt) : Option.none(),
163
+ stopped: false,
164
+ failure: Option.none()
165
+ });
166
+ };
167
+ const remove = (marks, projection, params) => {
168
+ marks.get(projection)?.delete(params);
169
+ };
170
+ const fail = (marks, projection, params, options) => {
171
+ const rows = rowsOf(marks, projection);
172
+ const found = rows.get(params);
173
+ rows.set(params, {
174
+ params,
175
+ seq: found?.seq ?? 1,
176
+ attempts: options.attempts,
177
+ dueAt: Option.getOrElse(options.dueAt, () => 0),
178
+ stopped: Option.isNone(options.dueAt),
179
+ wakeAt: Option.none(),
180
+ failure: Option.some({
181
+ ...options.failure,
182
+ message: options.failure.message.slice(0, 1e3)
183
+ })
184
+ });
185
+ };
186
+ 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);
187
+ const resume = (marks, projection) => {
188
+ let changed = 0;
189
+ const rows = marks.get(projection);
190
+ if (rows === void 0) return 0;
191
+ for (const [key, row] of rows) {
192
+ if (!row.stopped) continue;
193
+ rows.set(key, {
194
+ ...row,
195
+ dueAt: 0,
196
+ stopped: false
197
+ });
198
+ changed += 1;
199
+ }
200
+ return changed;
201
+ };
202
+ const retry = (marks, projection, params) => {
203
+ let changed = 0;
204
+ const rows = marks.get(projection);
205
+ if (rows === void 0) return 0;
206
+ for (const [key, row] of rows) {
207
+ if (!row.stopped && (row.attempts === 0 || row.dueAt === 0) || params !== void 0 && key !== params) continue;
208
+ rows.set(key, {
209
+ ...row,
210
+ dueAt: 0,
211
+ stopped: false
212
+ });
213
+ changed += 1;
214
+ }
215
+ return changed;
216
+ };
217
+ /** Classify each row once; a failed row at `now` is due, not backing off. */
218
+ const summary = (marks, projection, now) => {
219
+ let fresh = 0;
220
+ let sleeping = 0;
221
+ let retryDue = 0;
222
+ let backingOff = 0;
223
+ let stopped = 0;
224
+ let earliest;
225
+ for (const row of marks.get(projection)?.values() ?? []) {
226
+ if (row.stopped) {
227
+ stopped += 1;
228
+ continue;
229
+ }
230
+ if (Option.isSome(row.wakeAt)) sleeping += 1;
231
+ else if (row.attempts === 0) fresh += 1;
232
+ else if (row.dueAt <= now) retryDue += 1;
233
+ else backingOff += 1;
234
+ earliest = earliest === void 0 ? row.dueAt : Math.min(earliest, row.dueAt);
235
+ }
236
+ return {
237
+ fresh,
238
+ sleeping,
239
+ retryDue,
240
+ backingOff,
241
+ stopped,
242
+ nextDueAt: Option.fromUndefinedOr(earliest)
243
+ };
244
+ };
245
+ /** A new private marks store. Each operation runs synchronously when its Effect executes. */
246
+ const memoryProjectionMarks = () => {
247
+ const table = /* @__PURE__ */ new Map();
248
+ return {
249
+ mark: (projection, params) => Effect.sync(() => mark(table, projection, params)),
250
+ nextDue: (projection) => Effect.sync(() => nextDue(table, projection)),
251
+ summary: (projection, now) => Effect.sync(() => summary(table, projection, now)),
252
+ due: (projection, now, limit) => Effect.sync(() => due(table, projection, now, limit)),
253
+ read: (projection, params) => Effect.sync(() => read(table, projection, params)),
254
+ clear: (projection, params, seq) => Effect.sync(() => clear(table, projection, params, seq)),
255
+ sleep: (projection, params, seq, wakeAt) => Effect.sync(() => sleep(table, projection, params, seq, wakeAt)),
256
+ remove: (projection, params) => Effect.sync(() => remove(table, projection, params)),
257
+ fail: (projection, params, options) => Effect.sync(() => fail(table, projection, params, options)),
258
+ retry: (projection, params) => Effect.sync(() => retry(table, projection, params)),
259
+ resume: (projection) => Effect.sync(() => resume(table, projection)),
260
+ failed: (projection, limit) => Effect.sync(() => failed(table, projection, limit))
261
+ };
262
+ };
263
+ // src/storage/memory/boundary.ts
264
+ var ActiveDraft = class extends Context.Service()("@streamsy/core/internal/MemoryActiveDraft") {};
265
+ const activeDraft = (owner, reject) => Effect.flatMap(Effect.serviceOption(ActiveDraft), (draft) => Effect.withFiber((fiber) => {
266
+ if (Option.isSome(draft) && (draft.value.owner !== owner || !draft.value.active || draft.value.fiberId !== fiber.id)) return reject();
267
+ return Effect.succeed(draft);
268
+ }));
269
+ var MemoryEnlistFault = class extends Schema.TaggedError()("MemoryEnlistFault", { message: Schema.String }) {};
270
+ const rejectEnlist = () => Effect.fail(new MemoryEnlistFault({ message: "Enlisting requires the active memory owner fiber" }));
271
+ /** Join the memory owner transaction open on this fiber. */
272
+ function enlist(owner, participant) {
273
+ return Effect.flatMap(activeDraft(owner, rejectEnlist), (draft) => {
274
+ if (Option.isNone(draft)) return rejectEnlist();
275
+ draft.value.participants.add(participant);
276
+ return Effect.void;
277
+ });
278
+ }
279
+ const notifyParticipants = (participants, callback) => {
280
+ const defects = [];
281
+ for (const participant of participants) try {
282
+ participant[callback]();
283
+ } catch (defect) {
284
+ defects.push(defect);
285
+ }
286
+ if (defects.length > 0) throw new AggregateError(defects, `Memory participant ${callback} failed`);
287
+ };
288
+ const makeBoundary = (committed, publish) => Effect.gen(function* () {
289
+ const owner = {};
290
+ const lock = yield* Semaphore.make(1);
291
+ let committedRecords = /* @__PURE__ */ new Map();
292
+ let committedMarks = /* @__PURE__ */ new Map();
293
+ const hooks = commitHookRegistry();
294
+ const current = activeDraft(owner, () => Effect.die(/* @__PURE__ */ new Error("Memory boundary requires the active owner fiber")));
295
+ const withTransaction = (body) => Effect.flatMap(current, (ambient) => {
296
+ if (Option.isSome(ambient)) return body;
297
+ return Effect.withFiber((fiber) => Effect.suspend(() => {
298
+ const draft = {
299
+ owner,
300
+ fiberId: fiber.id,
301
+ state: copyState(committed),
302
+ records: new Map(committedRecords),
303
+ marks: copyMarks(committedMarks),
304
+ ids: /* @__PURE__ */ new Set(),
305
+ participants: /* @__PURE__ */ new Set(),
306
+ active: true,
307
+ changed: false
308
+ };
309
+ const withHooks = body.pipe(Effect.tap(() => Effect.orDie(hooks.run(draft.ids))), Effect.provideService(ActiveDraft, draft));
310
+ return Effect.uninterruptibleMask((restore) => Effect.exit(restore(withHooks)).pipe(Effect.flatMap((exit) => {
311
+ if (Exit.isFailure(exit)) return Effect.sync(() => notifyParticipants(Array.reverse(Array.fromIterable(draft.participants)), "onRollback")).pipe(Effect.catchCause((rollback) => Effect.failCause(Cause.combine(exit.cause, rollback))), Effect.andThen(exit));
312
+ return Effect.sync(() => {
313
+ Object.assign(committed, draft.state);
314
+ committedRecords = draft.records;
315
+ committedMarks = draft.marks;
316
+ notifyParticipants(draft.participants, "onCommit");
317
+ }).pipe(Effect.ensuring(Effect.suspend(() => draft.changed ? publish(draft.ids) : Effect.void)), Effect.as(exit.value));
318
+ }), Effect.ensuring(Effect.sync(() => {
319
+ draft.active = false;
320
+ }))));
321
+ }).pipe(Semaphore.withPermit(lock)));
322
+ });
323
+ const access = (f) => Effect.map(current, (draft) => f(Option.isSome(draft) ? draft.value.state : committed));
324
+ const changed = (ids) => Effect.map(current, (draft) => {
325
+ if (Option.isNone(draft)) throw new Error("Memory mutation requires an owner");
326
+ draft.value.changed = true;
327
+ for (const id of ids) draft.value.ids.add(id);
328
+ });
329
+ const boundary = CommitBoundary.of({ withTransaction });
330
+ const records = OwnerRecords.of({
331
+ read: (key) => Effect.map(current, (draft) => Option.fromUndefinedOr((Option.isSome(draft) ? draft.value.records : committedRecords).get(key))),
332
+ list: (prefix) => Effect.map(current, (draft) => Array.filter(Array.fromIterable(Option.isSome(draft) ? draft.value.records : committedRecords), ([key]) => key.startsWith(prefix))),
333
+ remove: (key) => withTransaction(Effect.map(current, (draft) => {
334
+ if (Option.isNone(draft)) throw new Error("Memory record delete requires an owner");
335
+ draft.value.records.delete(key);
336
+ })),
337
+ write: (key, encoded) => withTransaction(Effect.map(current, (draft) => {
338
+ if (Option.isNone(draft)) throw new Error("Memory record write requires an owner");
339
+ draft.value.records.set(key, encoded);
340
+ }))
341
+ });
342
+ const readMarks = (f) => Effect.map(current, (draft) => f(Option.isSome(draft) ? draft.value.marks : committedMarks));
343
+ const writeMarks = (f) => withTransaction(Effect.map(current, (draft) => {
344
+ if (Option.isNone(draft)) throw new Error("Memory mark write requires an owner");
345
+ return f(draft.value.marks);
346
+ }));
347
+ const marks = ProjectionMarks.of({
348
+ mark: (projection, params) => writeMarks((table) => mark(table, projection, params)),
349
+ nextDue: (projection) => readMarks((table) => nextDue(table, projection)),
350
+ summary: (projection, now) => readMarks((table) => summary(table, projection, now)),
351
+ due: (projection, now, limit) => readMarks((table) => due(table, projection, now, limit)),
352
+ read: (projection, params) => readMarks((table) => read(table, projection, params)),
353
+ clear: (projection, params, seq) => writeMarks((table) => clear(table, projection, params, seq)),
354
+ sleep: (projection, params, seq, wakeAt) => writeMarks((table) => sleep(table, projection, params, seq, wakeAt)),
355
+ remove: (projection, params) => writeMarks((table) => remove(table, projection, params)),
356
+ fail: (projection, params, options) => writeMarks((table) => fail(table, projection, params, options)),
357
+ resume: (projection) => writeMarks((table) => resume(table, projection)),
358
+ failed: (projection, limit) => readMarks((table) => failed(table, projection, limit)),
359
+ retry: (projection, params) => writeMarks((table) => retry(table, projection, params))
360
+ });
361
+ return {
362
+ boundary: attachOwner(boundary, owner),
363
+ marks: attachOwner(marks, owner),
364
+ records: attachOwner(records, owner),
365
+ hooks: attachOwner(CommitHooks.of({ beforeCommit: hooks.beforeCommit }), owner),
366
+ withTransaction,
367
+ access,
368
+ changed
369
+ };
370
+ });
371
+ export { CommitHooks as a, OwnerRecords as c, indexDeadlines as d, patchRecord as f, ProjectionMarks as i, copyMessage as l, makeBoundary as n, commitHookRegistry as o, CommitBoundary as p, memoryProjectionMarks as r, OWNER_RECORDS_LIST_UNSUPPORTED as s, enlist as t, copyRecord as u };
@@ -1,2 +1,2 @@
1
- import { C as Access, S as read, T as routes, _ as ShutdownSignalService, a as LIVE_SOCKET_PROTOCOL, b as ReadOptions, c as LiveControlFrame, d as controlFrame, f as isLiveUpgrade, g as ShutdownSignal, h as upgradeRequired, i as LIVE_PONG, l as LiveOpenFrame, m as openFrame, n as HttpLiveMode, nt as HttpOptions, o as LiveBatch, p as nextCursor, r as LIVE_PING, rt as app, s as LiveCloseCode, tt as streamPath, u as closeCodeForStatus, v as layerShutdownSignal, w as RoutesOptions, x as checkReadOptions, y as securityHeaders } from "../index-vnyfaf-e.js";
1
+ import { $ as streamPath, C as Access, S as read, T as routes, _ as ShutdownSignalService, a as LIVE_SOCKET_PROTOCOL, b as ReadOptions, c as LiveControlFrame, d as controlFrame, et as HttpOptions, f as isLiveUpgrade, g as ShutdownSignal, h as upgradeRequired, i as LIVE_PONG, l as LiveOpenFrame, m as openFrame, n as HttpLiveMode, o as LiveBatch, p as nextCursor, r as LIVE_PING, s as LiveCloseCode, tt as app, u as closeCodeForStatus, v as layerShutdownSignal, w as RoutesOptions, x as checkReadOptions, y as securityHeaders } from "../index-BtVxu6VJ.js";
2
2
  export { type Access, type HttpLiveMode, type HttpOptions, LIVE_PING, LIVE_PONG, LIVE_SOCKET_PROTOCOL, type LiveBatch, LiveCloseCode, type LiveControlFrame, type LiveOpenFrame, type ReadOptions, type RoutesOptions, ShutdownSignal, type ShutdownSignalService, app, checkReadOptions, closeCodeForStatus, controlFrame, isLiveUpgrade, layerShutdownSignal, nextCursor, openFrame, read, routes, securityHeaders, streamPath, upgradeRequired };
@@ -1,7 +1,6 @@
1
- import { A as CreateResult, D as StreamsWriter, Dt as StorageFault, E as StreamsReader, Et as EncodeFault, I as AppendConflict, J as InvalidReadRequest, N as ReadNextResult, O as Writer, Ot as StreamsFault, R as AppendErrorFor, St as StreamId, T as Reader, Tt as DecodeFault, U as HeadError, V as CreateError, X as OffsetMismatch, Y as NotSupported, at as StreamGone, ct as AppendCallOptions, d as OwnerRecords, dt as ReadNextOptions, et as ReadNextError, ft as ReadOptions$1, i as ProjectionMarks, it as StreamClosed, j as HeadResult, k as AppendResult, kt as TransportFault, ot as StreamNotFound, p as Storage, pt as CreateOptions, rt as StreamBusy, s as CommitHooks, tt as RemoveError, ut as ProducerOptions } from "./projection-marks-c7-wvpSn.js";
1
+ import { A as Writer, At as StreamsFault, B as AppendErrorFor, D as Reader, Dt as DecodeFault, F as ReadNextResult, G as HeadError, M as CreateResult, N as HeadResult, O as StreamsReader, Ot as EncodeFault, Q as OffsetMismatch, R as AppendConflict, U as CreateError, X as InvalidReadRequest, Z as NotSupported, at as StreamBusy, ct as StreamNotFound, d as OwnerRecords, ft as ProducerOptions, h as Storage, ht as CreateOptions, i as ProjectionMarks, j as AppendResult, jt as TransportFault, k as StreamsWriter, kt as StorageFault, mt as ReadOptions$1, nt as ReadNextError, ot as StreamClosed, p as CommitBoundary, pt as ReadNextOptions, rt as RemoveError, s as CommitHooks, st as StreamGone, ut as AppendCallOptions, wt as StreamId } from "./projection-marks-BEZv8qDJ.js";
2
2
  import { Array, Context, Data, Duration, Effect, Function, Layer, Option, Schedule, Schema, Stream } from "effect";
3
3
  import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
4
- import { SqlError } from "effect/sql";
5
4
  interface HttpOptions {
6
5
  readonly pathPrefix?: string;
7
6
  /** Lifetime of an SSE response. Default 60 seconds. */
@@ -219,19 +218,6 @@ declare function custom$1<RouteParams, A, RD, RE>(options: {
219
218
  }): StreamRoute<RouteParams, A, RD, RE>;
220
219
  declare const ZERO_OFFSET: string & import("effect/Brand").Brand<"Offset">;
221
220
  declare const compare: (a: string, b: string) => number;
222
- interface CommitBoundaryApi {
223
- /**
224
- * Run `body` in the storage owner's transaction. A nested call joins the outer
225
- * transaction (no savepoints), so a failure must escape the outer body to roll back.
226
- * Stream writes, owner records and, on SQL hosts, application SQL in `body` commit
227
- * together. Keep the body on the calling fiber, and do not wait in it for wakes that
228
- * only its own commit publishes. Only SQL hosts fail with `SqlError`.
229
- */
230
- readonly withTransaction: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError.SqlError, R>;
231
- }
232
- declare const CommitBoundary_base: Context.ServiceClass<CommitBoundary, "@streamsy/core/CommitBoundary", CommitBoundaryApi>;
233
- /** The transaction of the storage owner. Every Streamsy storage host provides it. */
234
- declare class CommitBoundary extends CommitBoundary_base {}
235
221
  /** One host-triggered sweep; the host owns scheduling and cancellation. */
236
222
  declare const expireDue: () => Effect.Effect<void, StorageFault, Storage>;
237
223
  declare namespace layer_d_exports {
@@ -785,4 +771,4 @@ type HttpLiveMode = "long-poll" | "sse" | "websocket";
785
771
  declare namespace index_d_exports {
786
772
  export { Access, HttpLiveMode, HttpOptions, LIVE_PING, LIVE_PONG, LIVE_SOCKET_PROTOCOL, LiveBatch, LiveCloseCode, LiveControlFrame, LiveOpenFrame, ReadOptions, RoutesOptions, ShutdownSignal, ShutdownSignalService, app, checkReadOptions, closeCodeForStatus, controlFrame, isLiveUpgrade, layerShutdownSignal, nextCursor, openFrame, read, routes, securityHeaders, streamPath, upgradeRequired };
787
773
  }
788
- export { route_d_exports as $, Batch as A, RemoveFailure as B, Access as C, Group as D, Any as E, Decision as F, streams_d_exports$1 as G, streamsy_d_exports as H, Folded as I, layer_d_exports as J, MemoryOptions as K, FollowFailure as L, CreateFailure as M, DecideSpec as N, Identifiers as O, Decided as P, compare as Q, HeadFailure as R, read as S, routes as T, producer_d_exports as U, streams_d_exports as V, durable_state_d_exports as W, CommitBoundaryApi as X, CommitBoundary as Y, ZERO_OFFSET as Z, ShutdownSignalService as _, LIVE_SOCKET_PROTOCOL as a, ReadOptions as b, LiveControlFrame as c, controlFrame as d, address_d_exports as et, isLiveUpgrade as f, ShutdownSignal as g, upgradeRequired as h, LIVE_PONG as i, Collected as j, AppendFailure as k, LiveOpenFrame as l, openFrame as m, HttpLiveMode as n, HttpOptions as nt, LiveBatch as o, nextCursor as p, ProtocolOptions as q, LIVE_PING as r, app as rt, LiveCloseCode as s, index_d_exports as t, streamPath as tt, closeCodeForStatus as u, layerShutdownSignal as v, RoutesOptions as w, checkReadOptions as x, securityHeaders as y, ReadFailure as z };
774
+ export { streamPath as $, Batch as A, RemoveFailure as B, Access as C, Group as D, Any as E, Decision as F, streams_d_exports$1 as G, streamsy_d_exports as H, Folded as I, layer_d_exports as J, MemoryOptions as K, FollowFailure as L, CreateFailure as M, DecideSpec as N, Identifiers as O, Decided as P, address_d_exports as Q, HeadFailure as R, read as S, routes as T, producer_d_exports as U, streams_d_exports as V, durable_state_d_exports as W, compare as X, ZERO_OFFSET as Y, route_d_exports as Z, ShutdownSignalService as _, LIVE_SOCKET_PROTOCOL as a, ReadOptions as b, LiveControlFrame as c, controlFrame as d, HttpOptions as et, isLiveUpgrade as f, ShutdownSignal as g, upgradeRequired as h, LIVE_PONG as i, Collected as j, AppendFailure as k, LiveOpenFrame as l, openFrame as m, HttpLiveMode as n, LiveBatch as o, nextCursor as p, ProtocolOptions as q, LIVE_PING as r, LiveCloseCode as s, index_d_exports as t, app as tt, closeCodeForStatus as u, layerShutdownSignal as v, RoutesOptions as w, checkReadOptions as x, securityHeaders as y, ReadFailure as z };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as ReadError, A as CreateResult, At as isRetryableFault, B as CreateConflictReason, C as ProducerPrecondition, Ct as StreamLifecycle, Dt as StorageFault, Et as EncodeFault, F as AppendBaseError, G as InvalidCreateRequest, H as ForkSourceNotFound, I as AppendConflict, J as InvalidReadRequest, K as InvalidEpochSeq, L as AppendError, M as ReadMessage, N as ReadNextResult, Ot as StreamsFault, P as ReadResult, Q as ProtocolError, R as AppendErrorFor, S as Operations, St as StreamId, Tt as DecodeFault, U as HeadError, V as CreateError, W as InvalidAppendRequest, X as OffsetMismatch, Y as NotSupported, Z as ProducerGap, _ as MutationRejected, _t as ProducerId, at as StreamGone, b as OperationResult, bt as StoredMessage, ct as AppendCallOptions, dt as ReadNextOptions, et as ReadNextError, ft as ReadOptions, g as MutationApplied, gt as Offset, h as Mutation, ht as MessageWindow, it as StreamClosed, j as HeadResult, jt as isStreamsFault, k as AppendResult, kt as TransportFault, lt as AppendOptions, m as StorageShape, mt as ChangeSnapshot, nt as StaleEpoch, ot as StreamNotFound, p as Storage, pt as CreateOptions, q as InvalidForkRequest, rt as StreamBusy, st as isProtocolError, tt as RemoveError, ut as ProducerOptions, v as Mutations, vt as ProducerState, w as StorageCapabilities, wt as StreamRecord, x as OperationResults, xt as StreamConfig, y as Operation, yt as RecordPatch, z as CreateConflict } from "./projection-marks-c7-wvpSn.js";
2
- import { A as Batch, B as RemoveFailure, F as Decision, G as streams_d_exports, H as streamsy_d_exports, I as Folded, L as FollowFailure, M as CreateFailure, N as DecideSpec, P as Decided, Q as compare, R as HeadFailure, U as producer_d_exports, W as durable_state_d_exports, X as CommitBoundaryApi, Y as CommitBoundary, Z as ZERO_OFFSET, et as address_d_exports, j as Collected, k as AppendFailure, t as index_d_exports, z as ReadFailure } from "./index-vnyfaf-e.js";
1
+ import { $ as ProducerGap, At as StreamsFault, B as AppendErrorFor, C as OperationResults, Ct as StreamConfig, Dt as DecodeFault, E as StorageCapabilities, Et as StreamRecord, F as ReadNextResult, G as HeadError, H as CreateConflictReason, I as ReadResult, J as InvalidEpochSeq, K as InvalidAppendRequest, L as AppendBaseError, M as CreateResult, Mt as isRetryableFault, N as HeadResult, Nt as isStreamsFault, Ot as EncodeFault, P as ReadMessage, Q as OffsetMismatch, R as AppendConflict, S as OperationResult, St as StoredMessage, T as ProducerPrecondition, Tt as StreamLifecycle, U as CreateError, V as CreateConflict, W as ForkSourceNotFound, X as InvalidReadRequest, Y as InvalidForkRequest, Z as NotSupported, _ as Mutation, _t as MessageWindow, at as StreamBusy, b as Mutations, bt as ProducerState, ct as StreamNotFound, dt as AppendOptions, et as ProtocolError, ft as ProducerOptions, g as StorageShape, gt as ChangeSnapshot, h as Storage, ht as CreateOptions, it as StaleEpoch, j as AppendResult, jt as TransportFault, kt as StorageFault, lt as isProtocolError, m as CommitBoundaryApi, mt as ReadOptions, nt as ReadNextError, ot as StreamClosed, p as CommitBoundary, pt as ReadNextOptions, q as InvalidCreateRequest, rt as RemoveError, st as StreamGone, tt as ReadError, ut as AppendCallOptions, v as MutationApplied, vt as Offset, w as Operations, wt as StreamId, x as Operation, xt as RecordPatch, y as MutationRejected, yt as ProducerId, z as AppendError } from "./projection-marks-BEZv8qDJ.js";
2
+ import { A as Batch, B as RemoveFailure, F as Decision, G as streams_d_exports, H as streamsy_d_exports, I as Folded, L as FollowFailure, M as CreateFailure, N as DecideSpec, P as Decided, Q as address_d_exports, R as HeadFailure, U as producer_d_exports, W as durable_state_d_exports, X as compare, Y as ZERO_OFFSET, j as Collected, k as AppendFailure, t as index_d_exports, z as ReadFailure } from "./index-BtVxu6VJ.js";
3
3
  export { AppendBaseError, type AppendCallOptions, AppendConflict, AppendError, AppendErrorFor, type AppendFailure, type AppendOptions, AppendResult, type Batch, ChangeSnapshot, type Collected, CommitBoundary, type CommitBoundaryApi, CreateConflict, CreateConflictReason, CreateError, type CreateFailure, type CreateOptions, CreateResult, type DecideSpec, type Decided, type Decision, DecodeFault, durable_state_d_exports as DurableState, EncodeFault, type Folded, type FollowFailure, ForkSourceNotFound, HeadError, type HeadFailure, type HeadResult, index_d_exports as Http, InvalidAppendRequest, InvalidCreateRequest, InvalidEpochSeq, InvalidForkRequest, InvalidReadRequest, streams_d_exports as MemoryStorage, MessageWindow, Mutation, MutationApplied, MutationRejected, Mutations, NotSupported, Offset, OffsetMismatch, Operation, OperationResult, OperationResults, Operations, producer_d_exports as Producer, ProducerGap, ProducerId, type ProducerOptions, ProducerPrecondition, ProducerState, ProtocolError, ReadError, type ReadFailure, type ReadMessage, ReadNextError, type ReadNextOptions, type ReadNextResult, type ReadOptions, type ReadResult, RecordPatch, RemoveError, type RemoveFailure, StaleEpoch, Storage, StorageCapabilities, StorageFault, type StorageShape, StoredMessage, address_d_exports as StreamAddress, StreamBusy, StreamClosed, StreamConfig, StreamGone, StreamId, StreamLifecycle, StreamNotFound, StreamRecord, StreamsFault, streamsy_d_exports as Streamsy, TransportFault, ZERO_OFFSET, compare, isProtocolError, isRetryableFault, isStreamsFault };
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
2
  import { $ as ProducerState, A as StreamBusy, C as InvalidEpochSeq, D as OffsetMismatch, E as NotSupported, G as StreamsFault, H as DecodeFault, J as isStreamsFault, K as TransportFault, L as Storage, M as StreamGone, N as StreamNotFound, O as ProducerGap, P as isProtocolError, Q as ProducerId, R as ZERO_OFFSET, S as InvalidCreateRequest, T as InvalidReadRequest, U as EncodeFault, W as StorageFault, X as MessageWindow, Y as ChangeSnapshot, Z as Offset, _ as CreateResult, a as custom, at as StreamRecord, b as ForkSourceNotFound, c as state, d as address_exports, et as RecordPatch, f as isControl, g as AppendResult, h as stateControl, it as StreamLifecycle, j as StreamClosed, k as StaleEpoch, m as stateChange, n as bind, nt as StreamConfig, o as group, p as isUpsert, q as isRetryableFault, r as bytes, rt as StreamId, s as json, t as Wildcard, tt as StoredMessage, v as AppendConflict, w as InvalidForkRequest, x as InvalidAppendRequest, y as CreateConflict, z as compare } from "./streamsy-HKC10a_V.js";
3
- import { n as CommitBoundary, t as layer$1 } from "./layer-D4RAoIfM.js";
4
- import { a as MutationRejected, c as OperationResult, d as ProducerPrecondition, i as MutationApplied, l as OperationResults, o as Mutations, r as Mutation, s as Operation, t as layer$2, u as Operations } from "./layer-DjKTdIY5.js";
3
+ import { p as CommitBoundary } from "./boundary-f1biibJ1.js";
4
+ import { a as MutationRejected, c as OperationResult, d as ProducerPrecondition, i as MutationApplied, l as OperationResults, o as Mutations, r as Mutation, s as Operation, t as layer$1, u as Operations } from "./layer-DjKTdIY5.js";
5
+ import { t as layer$2 } from "./layer-J6sV3UXD.js";
5
6
  import { t as http_exports } from "./http-YoA8cUTN.js";
6
7
  import { Array, Data, Effect, Layer, Option, Predicate, Record, Schema, Stream } from "effect";
7
8
  // src/storage/capabilities.ts
@@ -21,10 +22,10 @@ var streams_exports = /* @__PURE__ */ __exportAll({
21
22
  layerProtocol: () => layerProtocol
22
23
  });
23
24
  /** Generic reader and writer over memory storage, for protocol tools. */
24
- const layerProtocol = (options = {}) => layer$2(options).pipe(Layer.provideMerge(layer$1(options)));
25
+ const layerProtocol = (options = {}) => layer$1(options).pipe(Layer.provideMerge(layer$2(options)));
25
26
  function layer(group, options = {}) {
26
- const storage = layer$1(options);
27
- const protocol = layer$2(options).pipe(Layer.provideMerge(storage));
27
+ const storage = layer$2(options);
28
+ const protocol = layer$1(options).pipe(Layer.provideMerge(storage));
28
29
  return bind(protocol, group).pipe(Layer.provideMerge(storage));
29
30
  }
30
31
  // src/toolkit/durable-state.ts
@@ -1,5 +1,5 @@
1
- import { P as ReadResult, a as ProjectionMarksApi, c as CommitHooksApi, d as OwnerRecords, f as OwnerRecordsApi, i as ProjectionMarks, l as commitHookRegistry, n as PendingMark, o as CommitHook, r as ProjectionMarkSummary, s as CommitHooks, t as MarkFailure, u as OWNER_RECORDS_LIST_UNSUPPORTED } from "../projection-marks-c7-wvpSn.js";
2
- import { Context, Effect, Option } from "effect";
1
+ import { I as ReadResult, a as ProjectionMarksApi, c as CommitHooksApi, d as OwnerRecords, f as OwnerRecordsApi, i as ProjectionMarks, l as commitHookRegistry, n as PendingMark, o as CommitHook, r as ProjectionMarkSummary, s as CommitHooks, t as MarkFailure, u as OWNER_RECORDS_LIST_UNSUPPORTED } from "../projection-marks-BEZv8qDJ.js";
2
+ import { Cause, Context, Effect, Option, Schema } from "effect";
3
3
  /** Private bridge: a stream guard dies with this sentinel; the atomic runner translates it. */
4
4
  declare const ForeignOwnerType: unique symbol;
5
5
  declare const ForeignOwner_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
@@ -55,6 +55,24 @@ interface TemplateGrammar<Template extends string = string> {
55
55
  export declare function compileSegments<const Template extends string>(template: Template): TemplateGrammar<Template>;
56
56
  /** A new private marks store. Each operation runs synchronously when its Effect executes. */
57
57
  export declare const memoryProjectionMarks: () => ProjectionMarksApi;
58
+ interface TransactionParticipant {
59
+ /** Runs synchronously after the draft becomes committed, before wakes. Must not throw. */
60
+ readonly onCommit: () => void;
61
+ /**
62
+ * Runs synchronously when the outer transaction rolls back. Must not throw.
63
+ * A throw adds a defect to the transaction's cause. Effect's typed recovery
64
+ * gives defects precedence even when the exit still contains a typed failure.
65
+ */
66
+ readonly onRollback: () => void;
67
+ }
68
+ declare const MemoryEnlistFault_base: Schema.Class<MemoryEnlistFault, Schema.TaggedStruct<"MemoryEnlistFault", {
69
+ readonly message: Schema.String;
70
+ }>, Cause.YieldableError & {
71
+ readonly brand: unique symbol;
72
+ }>;
73
+ declare class MemoryEnlistFault extends MemoryEnlistFault_base {}
74
+ /** Join the memory owner transaction open on this fiber. */
75
+ export declare function enlist(owner: object, participant: TransactionParticipant): Effect.Effect<void, MemoryEnlistFault>;
58
76
  export declare const attachOffsets: <A extends object>(result: A, offsets: ReadonlyArray<string>) => A;
59
77
  export declare const offsetsOf: (result: Pick<ReadResult, "messages">) => ReadonlyArray<string> | undefined;
60
- export { type CommitHook, CommitHooks, type CommitHooksApi, type MarkFailure, OWNER_RECORDS_LIST_UNSUPPORTED, OwnerRecords, type OwnerRecordsApi, type PendingMark, type ProjectionMarkSummary, ProjectionMarks, type ProjectionMarksApi, commitHookRegistry };
78
+ export { type CommitHook, CommitHooks, type CommitHooksApi, type MarkFailure, OWNER_RECORDS_LIST_UNSUPPORTED, OwnerRecords, type OwnerRecordsApi, type PendingMark, type ProjectionMarkSummary, ProjectionMarks, type ProjectionMarksApi, type TransactionParticipant, commitHookRegistry };
@@ -1,6 +1,6 @@
1
+ import { a as CommitHooks, c as OwnerRecords, i as ProjectionMarks, o as commitHookRegistry, r as memoryProjectionMarks, s as OWNER_RECORDS_LIST_UNSUPPORTED, t as enlist } from "../boundary-f1biibJ1.js";
1
2
  import { a as attachOwner, c as isForeignOwner, i as CurrentOwner, l as ownerOf, t as compileSegments } from "../route-internal-DNL0oGTN.js";
2
3
  import { n as offsetsOf, t as attachOffsets } from "../read-offsets-CQ4VkAs8.js";
3
- import { _ as commitHookRegistry, g as CommitHooks, h as ProjectionMarks, s as memoryProjectionMarks, v as OWNER_RECORDS_LIST_UNSUPPORTED, y as OwnerRecords } from "../marks-YTDGyaMN.js";
4
4
  import { Array, Effect } from "effect";
5
5
  // src/internal/limits.ts
6
6
  /**
@@ -26,4 +26,4 @@ const fitKey = (key, limit, readable = key) => {
26
26
  const prefix = Array.join(Array.take(codePoints(readable), limit - DIGEST_LENGTH), "");
27
27
  return Effect.map(sha256Hex(key), (digest) => `${prefix}#${digest}`);
28
28
  };
29
- export { CommitHooks, CurrentOwner, MAX_PRODUCER_ID_LENGTH, OWNER_RECORDS_LIST_UNSUPPORTED, OwnerRecords, ProjectionMarks, attachOffsets, attachOwner, commitHookRegistry, compileSegments, fitKey, isForeignOwner, memoryProjectionMarks, offsetsOf, ownerOf };
29
+ export { CommitHooks, CurrentOwner, MAX_PRODUCER_ID_LENGTH, OWNER_RECORDS_LIST_UNSUPPORTED, OwnerRecords, ProjectionMarks, attachOffsets, attachOwner, commitHookRegistry, compileSegments, enlist, fitKey, isForeignOwner, memoryProjectionMarks, offsetsOf, ownerOf };
@@ -1,73 +1,8 @@
1
1
  import { L as Storage, R as ZERO_OFFSET } from "./streamsy-HKC10a_V.js";
2
+ import { a as CommitHooks, c as OwnerRecords, d as indexDeadlines, f as patchRecord, i as ProjectionMarks, l as copyMessage, n as makeBoundary, p as CommitBoundary, u as copyRecord } from "./boundary-f1biibJ1.js";
2
3
  import { a as MutationRejected, l as OperationResults, o as Mutations, u as Operations } from "./layer-DjKTdIY5.js";
3
4
  import { a as attachOwner, l as ownerOf } from "./route-internal-DNL0oGTN.js";
4
- import { _ as commitHookRegistry, a as failed, c as nextDue, d as resume, f as retry, g as CommitHooks, h as ProjectionMarks, i as fail, l as read, m as summary, n as copyMarks, o as mark, p as sleep, r as due, t as clear, u as remove, y as OwnerRecords } from "./marks-YTDGyaMN.js";
5
- import { Array, Context, Effect, Layer, Option, Order, Predicate, PubSub, Queue, Schedule, Semaphore, Stream } from "effect";
6
- // src/storage/commit-boundary.ts
7
- /** The transaction of the storage owner. Every Streamsy storage host provides it. */
8
- var CommitBoundary = class extends Context.Service()("@streamsy/core/CommitBoundary") {};
9
- // src/storage/memory/state.ts
10
- const copyRecord = (record) => ({
11
- id: record.id,
12
- currentOffset: record.currentOffset,
13
- config: { ...record.config },
14
- lifecycle: { ...record.lifecycle }
15
- });
16
- const copyMessage = (message) => ({
17
- offset: message.offset,
18
- timestamp: message.timestamp,
19
- data: new Uint8Array(message.data)
20
- });
21
- function patchRecord(record, patch) {
22
- const config = {
23
- ...record.config,
24
- ...patch.config
25
- };
26
- const lifecycle = {
27
- ...record.lifecycle,
28
- ...patch.lifecycle
29
- };
30
- for (const key of patch.clear ?? []) switch (key) {
31
- case "ttlSeconds":
32
- delete config.ttlSeconds;
33
- break;
34
- case "expiresAt":
35
- delete config.expiresAt;
36
- break;
37
- case "expiresAtMs":
38
- delete lifecycle.expiresAtMs;
39
- break;
40
- case "lastSeq": delete lifecycle.lastSeq;
41
- }
42
- return {
43
- id: record.id,
44
- currentOffset: patch.currentOffset ?? record.currentOffset,
45
- config,
46
- lifecycle
47
- };
48
- }
49
- function indexDeadlines(state) {
50
- state.deadlines = Array.sort(Array.flatMap([...state.entries.values()], ({ record }) => record.lifecycle.softDeleted || record.lifecycle.expiresAtMs === void 0 ? [] : [{
51
- at: record.lifecycle.expiresAtMs,
52
- streamId: record.id
53
- }]), Order.make((a, b) => {
54
- const compared = a.at - b.at || a.streamId.localeCompare(b.streamId);
55
- return compared < 0 ? -1 : compared > 0 ? 1 : 0;
56
- }));
57
- }
58
- /** A private transaction draft; no mutable stream data aliases the committed state. */
59
- const copyState = (state) => ({
60
- entries: new Map(Array.map([...state.entries], ([id, entry]) => [id, {
61
- record: copyRecord(entry.record),
62
- messages: Array.map(entry.messages, copyMessage),
63
- producers: new Map(Array.map([...entry.producers], ([producerId, producer]) => [producerId, {
64
- epoch: producer.epoch,
65
- lastSeq: producer.lastSeq
66
- }]))
67
- }])),
68
- children: new Map(Array.map([...state.children], ([id, children]) => [id, new Set(children)])),
69
- deadlines: Array.map(state.deadlines, (deadline) => ({ ...deadline }))
70
- });
5
+ import { Array, Context, Effect, Layer, Option, Order, Predicate, PubSub, Queue, Schedule, Stream } from "effect";
71
6
  // src/storage/memory/lineage.ts
72
7
  /** Synchronous port of cascade-reclaim and chained message composition.
73
8
  * Called only inside the memory mutation lock or synchronous read snapshot.
@@ -142,89 +77,6 @@ const createNotifier = Effect.gen(function* () {
142
77
  })
143
78
  };
144
79
  });
145
- // src/storage/memory/boundary.ts
146
- var ActiveDraft = class extends Context.Service()("@streamsy/core/internal/MemoryActiveDraft") {};
147
- const makeBoundary = (committed, publish) => Effect.gen(function* () {
148
- const owner = {};
149
- const lock = yield* Semaphore.make(1);
150
- let committedRecords = /* @__PURE__ */ new Map();
151
- let committedMarks = /* @__PURE__ */ new Map();
152
- const hooks = commitHookRegistry();
153
- const current = Effect.flatMap(Effect.serviceOption(ActiveDraft), (draft) => Effect.withFiber((fiber) => {
154
- if (Option.isSome(draft) && (draft.value.owner !== owner || !draft.value.active || draft.value.fiberId !== fiber.id)) return Effect.die(/* @__PURE__ */ new Error("Memory boundary requires the active owner fiber"));
155
- return Effect.succeed(draft);
156
- }));
157
- const withTransaction = (body) => Effect.flatMap(current, (ambient) => {
158
- if (Option.isSome(ambient)) return body;
159
- return Effect.withFiber((fiber) => Effect.suspend(() => {
160
- const draft = {
161
- owner,
162
- fiberId: fiber.id,
163
- state: copyState(committed),
164
- records: new Map(committedRecords),
165
- marks: copyMarks(committedMarks),
166
- ids: /* @__PURE__ */ new Set(),
167
- active: true,
168
- changed: false
169
- };
170
- const withHooks = body.pipe(Effect.tap(() => Effect.orDie(hooks.run(draft.ids))), Effect.provideService(ActiveDraft, draft));
171
- return Effect.uninterruptibleMask((restore) => restore(withHooks).pipe(Effect.tap(() => Effect.sync(() => {
172
- Object.assign(committed, draft.state);
173
- committedRecords = draft.records;
174
- committedMarks = draft.marks;
175
- }).pipe(Effect.andThen(Effect.suspend(() => draft.changed ? publish(draft.ids) : Effect.void)))), Effect.ensuring(Effect.sync(() => {
176
- draft.active = false;
177
- }))));
178
- }).pipe(Semaphore.withPermit(lock)));
179
- });
180
- const access = (f) => Effect.map(current, (draft) => f(Option.isSome(draft) ? draft.value.state : committed));
181
- const changed = (ids) => Effect.map(current, (draft) => {
182
- if (Option.isNone(draft)) throw new Error("Memory mutation requires an owner");
183
- draft.value.changed = true;
184
- for (const id of ids) draft.value.ids.add(id);
185
- });
186
- const boundary = CommitBoundary.of({ withTransaction });
187
- const records = OwnerRecords.of({
188
- read: (key) => Effect.map(current, (draft) => Option.fromUndefinedOr((Option.isSome(draft) ? draft.value.records : committedRecords).get(key))),
189
- list: (prefix) => Effect.map(current, (draft) => Array.filter(Array.fromIterable(Option.isSome(draft) ? draft.value.records : committedRecords), ([key]) => key.startsWith(prefix))),
190
- remove: (key) => withTransaction(Effect.map(current, (draft) => {
191
- if (Option.isNone(draft)) throw new Error("Memory record delete requires an owner");
192
- draft.value.records.delete(key);
193
- })),
194
- write: (key, encoded) => withTransaction(Effect.map(current, (draft) => {
195
- if (Option.isNone(draft)) throw new Error("Memory record write requires an owner");
196
- draft.value.records.set(key, encoded);
197
- }))
198
- });
199
- const readMarks = (f) => Effect.map(current, (draft) => f(Option.isSome(draft) ? draft.value.marks : committedMarks));
200
- const writeMarks = (f) => withTransaction(Effect.map(current, (draft) => {
201
- if (Option.isNone(draft)) throw new Error("Memory mark write requires an owner");
202
- return f(draft.value.marks);
203
- }));
204
- const marks = ProjectionMarks.of({
205
- mark: (projection, params) => writeMarks((table) => mark(table, projection, params)),
206
- nextDue: (projection) => readMarks((table) => nextDue(table, projection)),
207
- summary: (projection, now) => readMarks((table) => summary(table, projection, now)),
208
- due: (projection, now, limit) => readMarks((table) => due(table, projection, now, limit)),
209
- read: (projection, params) => readMarks((table) => read(table, projection, params)),
210
- clear: (projection, params, seq) => writeMarks((table) => clear(table, projection, params, seq)),
211
- sleep: (projection, params, seq, wakeAt) => writeMarks((table) => sleep(table, projection, params, seq, wakeAt)),
212
- remove: (projection, params) => writeMarks((table) => remove(table, projection, params)),
213
- fail: (projection, params, options) => writeMarks((table) => fail(table, projection, params, options)),
214
- resume: (projection) => writeMarks((table) => resume(table, projection)),
215
- failed: (projection, limit) => readMarks((table) => failed(table, projection, limit)),
216
- retry: (projection, params) => writeMarks((table) => retry(table, projection, params))
217
- });
218
- return {
219
- boundary: attachOwner(boundary, owner),
220
- marks: attachOwner(marks, owner),
221
- records: attachOwner(records, owner),
222
- hooks: attachOwner(CommitHooks.of({ beforeCommit: hooks.beforeCommit }), owner),
223
- withTransaction,
224
- access,
225
- changed
226
- };
227
- });
228
80
  // src/storage/memory/changes.ts
229
81
  function snapshot(state, id) {
230
82
  const record = state.entries.get(id)?.record;
@@ -368,4 +220,4 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
368
220
  });
369
221
  return Context.make(Storage, attachOwner(storage, ownerOf(owner.boundary))).pipe(Context.add(CommitBoundary, owner.boundary), Context.add(OwnerRecords, owner.records), Context.add(CommitHooks, owner.hooks), Context.add(ProjectionMarks, owner.marks));
370
222
  }));
371
- export { CommitBoundary as n, layer as t };
223
+ export { layer as t };
@@ -1102,6 +1102,32 @@ interface StorageShape {
1102
1102
  }
1103
1103
  declare const Storage_base: Context.ServiceClass<Storage, "@streamsy/core/Storage", StorageShape>;
1104
1104
  declare class Storage extends Storage_base {}
1105
+ interface CommitBoundaryApi {
1106
+ /**
1107
+ * Run `body` in the storage owner's transaction. Nested calls on the same owner
1108
+ * join without savepoints, so a failure must escape the outer body to roll back.
1109
+ * Same-owner stream writes and records commit with application SQL on that client.
1110
+ * With two boundaries over one SQL client, only the outer boundary's hooks and
1111
+ * `committed` subscribers see the commit.
1112
+ *
1113
+ * A nested call on another SQL client opens its own transaction, as does a lone
1114
+ * `Storage.mutate` on that client. Its commit comes first and survives an outer
1115
+ * rollback. Use one client per database for nested work. With two clients on
1116
+ * one database, SQLite can wait until it reports a busy lock. Postgres or MySQL
1117
+ * can wait for a row lock that the outer transaction holds.
1118
+ *
1119
+ * Durable Object clients share the driver's transaction, so a second client
1120
+ * joins the first. Using a second object's storage on one fiber is unsupported.
1121
+ * `MemoryStorage` dies when work enters another `MemoryStorage` owner.
1122
+ *
1123
+ * Keep the body on the calling fiber, and do not wait in it for wakes that only
1124
+ * its own commit publishes. Only SQL hosts fail with `SqlError`.
1125
+ */
1126
+ readonly withTransaction: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError.SqlError, R>;
1127
+ }
1128
+ declare const CommitBoundary_base: Context.ServiceClass<CommitBoundary, "@streamsy/core/CommitBoundary", CommitBoundaryApi>;
1129
+ /** The transaction of the storage owner. Every Streamsy storage host provides it. */
1130
+ declare class CommitBoundary extends CommitBoundary_base {}
1105
1131
  /**
1106
1132
  * Encoded records on the storage owner, for the projection checkpoint store.
1107
1133
  * Calls inside `CommitBoundary.withTransaction` join that transaction.
@@ -1181,10 +1207,12 @@ interface ProjectionMarkSummary {
1181
1207
  /**
1182
1208
  * Pending marks for attached projections, on a storage owner or in private memory.
1183
1209
  *
1184
- * A mark is keyed by projection id and canonical params. Version and generation
1185
- * are left out, so a deploy that raises the version picks up the old marks.
1210
+ * A mark is keyed by projection id and canonical params. A deploy that raises the
1211
+ * generation picks up the existing marks.
1186
1212
  */
1187
1213
  interface ProjectionMarksApi {
1214
+ /** Maximum projection id length in Unicode code points, when bounded by storage. */
1215
+ readonly maxProjectionIdLength?: number;
1188
1216
  /**
1189
1217
  * Insert a mark for each binding, or raise its `seq`. A raise keeps
1190
1218
  * `attempts`, `stopped` and `failure`, so a write never resets backoff or a stop.
@@ -1225,4 +1253,4 @@ interface ProjectionMarksApi {
1225
1253
  }
1226
1254
  declare const ProjectionMarks_base: Context.ServiceClass<ProjectionMarks, "@streamsy/core/internal/ProjectionMarks", ProjectionMarksApi>;
1227
1255
  declare class ProjectionMarks extends ProjectionMarks_base {}
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 };
1256
+ export { ProducerGap as $, Writer as A, StreamsFault as At, AppendErrorFor as B, OperationResults as C, StreamConfig as Ct, Reader as D, DecodeFault as Dt, StorageCapabilities as E, StreamRecord as Et, ReadNextResult as F, HeadError as G, CreateConflictReason as H, ReadResult as I, InvalidEpochSeq as J, InvalidAppendRequest as K, AppendBaseError as L, CreateResult as M, isRetryableFault as Mt, HeadResult as N, isStreamsFault as Nt, StreamsReader as O, EncodeFault as Ot, ReadMessage as P, OffsetMismatch as Q, AppendConflict as R, OperationResult as S, StoredMessage as St, ProducerPrecondition as T, StreamLifecycle as Tt, CreateError as U, CreateConflict as V, ForkSourceNotFound as W, InvalidReadRequest as X, InvalidForkRequest as Y, NotSupported as Z, Mutation as _, MessageWindow as _t, ProjectionMarksApi as a, StreamBusy as at, Mutations as b, ProducerState as bt, CommitHooksApi as c, StreamNotFound as ct, OwnerRecords as d, AppendOptions as dt, ProtocolError as et, OwnerRecordsApi as f, ProducerOptions as ft, StorageShape as g, ChangeSnapshot as gt, Storage as h, CreateOptions as ht, ProjectionMarks as i, StaleEpoch as it, AppendResult as j, TransportFault as jt, StreamsWriter as k, StorageFault as kt, commitHookRegistry as l, isProtocolError as lt, CommitBoundaryApi as m, ReadOptions as mt, PendingMark as n, ReadNextError as nt, CommitHook as o, StreamClosed as ot, CommitBoundary as p, ReadNextOptions as pt, InvalidCreateRequest as q, ProjectionMarkSummary as r, RemoveError as rt, CommitHooks as s, StreamGone as st, MarkFailure as t, ReadError as tt, OWNER_RECORDS_LIST_UNSUPPORTED as u, AppendCallOptions as ut, MutationApplied as v, Offset as vt, Operations as w, StreamId as wt, Operation as x, RecordPatch as xt, MutationRejected as y, ProducerId as yt, AppendError as z };
@@ -1,5 +1,5 @@
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";
1
+ import { A as Writer, D as Reader, O as StreamsReader, k as StreamsWriter } from "../projection-marks-BEZv8qDJ.js";
2
+ import { J as layer_d_exports, V as streams_d_exports, Z as route_d_exports, w as RoutesOptions } from "../index-BtVxu6VJ.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,5 +1,5 @@
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";
1
+ import { O as StreamsReader, jt as TransportFault, k as StreamsWriter } from "../projection-marks-BEZv8qDJ.js";
2
+ import { D as Group, E as Any, O as Identifiers } from "../index-BtVxu6VJ.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 { 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";
1
+ import { E as StorageCapabilities, O as StreamsReader, gt as ChangeSnapshot, h as Storage, k as StreamsWriter, wt as StreamId } from "../projection-marks-BEZv8qDJ.js";
2
+ import { K as MemoryOptions, q as ProtocolOptions } from "../index-BtVxu6VJ.js";
3
3
  import { Context, Effect, Layer } from "effect";
4
4
  interface StorageContractOptions {
5
5
  readonly name: string;
@@ -1,7 +1,7 @@
1
1
  import { L as Storage, Q as ProducerId, R as ZERO_OFFSET, V as next, W as StorageFault, rt as StreamId } from "../streamsy-HKC10a_V.js";
2
- import { n as CommitBoundary, t as layer } from "../layer-D4RAoIfM.js";
3
- import { a as MutationRejected, t as layer$1 } from "../layer-DjKTdIY5.js";
4
- import { g as CommitHooks, h as ProjectionMarks, y as OwnerRecords } from "../marks-YTDGyaMN.js";
2
+ import { a as CommitHooks, c as OwnerRecords, i as ProjectionMarks, p as CommitBoundary } from "../boundary-f1biibJ1.js";
3
+ import { a as MutationRejected, t as layer } from "../layer-DjKTdIY5.js";
4
+ import { t as layer$1 } from "../layer-J6sV3UXD.js";
5
5
  import { Array, Cause, Context, Deferred, Effect, Exit, Fiber, Layer, Match, Option, Order, Predicate, PubSub, Queue, Record, Ref, Scope, Stream } from "effect";
6
6
  import { SqlError } from "effect/sql";
7
7
  import { describe, expect, it } from "vitest";
@@ -1299,13 +1299,13 @@ const layerTest = (options = {}) => Layer.effectContext(Effect.gen(function* ()
1299
1299
  })));
1300
1300
  }))
1301
1301
  });
1302
- const context = yield* Layer.build(layer$1(options).pipe(Layer.provide(Layer.succeed(Storage, observed))));
1302
+ const context = yield* Layer.build(layer(options).pipe(Layer.provide(Layer.succeed(Storage, observed))));
1303
1303
  return Context.add(context, StreamsTest, StreamsTest.of({
1304
1304
  storage: observed,
1305
1305
  subscribers: Ref.get(count),
1306
1306
  snapshot: Queue.take(snapshots)
1307
1307
  }));
1308
- })).pipe(Layer.provide(layer(options)));
1308
+ })).pipe(Layer.provide(layer$1(options)));
1309
1309
  // src/testing/expect-failure-tag.ts
1310
1310
  /** An unexpected success stays a failure so the enclosing test cannot pass. */
1311
1311
  const expectFailureTag = (effect, tag) => effect.pipe(Effect.flip, Effect.tap((error) => Effect.sync(() => expect(error._tag).toBe(tag))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamsy/core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Effect-first Durable Streams protocol, storage contract, memory layer and toolkit.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,197 +0,0 @@
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 };