@streamsy/projection 0.13.0 → 0.15.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ItemOf, S as InputServices, T as Slices, _ as NonRetryable, a as Identity, b as Entry, c as ProjectionKey, d as RoutedStreamRecord, g as InvalidBinding, h as Unit, l as RetirementStatus, m as Range, n as CheckpointStore, r as CheckpointStoreApi, s as Loaded, t as CheckpointRecord, u as RouteRecords, v as NotAttached, w as Slice, x as InputMap, y as ProjectionFault } from "./checkpoint-store-B1199nDD.js";
1
+ import { C as ItemOf, S as InputServices, T as Slices, _ as NonRetryable, a as Identity, b as Entry, c as ProjectionKey, d as RoutedStreamRecord, g as InvalidBinding, h as Unit, l as RetirementStatus, m as Range, n as CheckpointStore, r as CheckpointStoreApi, s as Loaded, t as CheckpointRecord, u as RouteRecords, v as NotAttached, w as Slice, x as InputMap, y as ProjectionFault } from "./checkpoint-store-Cy5myzCL.js";
2
2
  import { Cause, Context, Data, DateTime, Effect, Layer, Option, Pipeable, Schedule, Schema, Semaphore, Stream } from "effect";
3
3
  import { CommitBoundary, Decided, Decision, DurableState, Offset, OffsetMismatch, Storage, StorageFault, StreamAddress, StreamId, StreamsFault, Streamsy } from "@streamsy/core";
4
4
  import { MarkFailure, ProjectionMarkSummary } from "@streamsy/core/internal";
@@ -44,9 +44,9 @@ interface Commit<in Result, in Provides = never, out Requires = never> extends P
44
44
  /** Fence future checkpoint writes, then run cleanup even if the key was already retired. */
45
45
  readonly retire?: (request: RetireRequest) => Effect.Effect<RetirementStatus, ProjectionFault, Requires>;
46
46
  }
47
- interface RetireRequest {
47
+ interface RetireRequest<R = never> {
48
48
  readonly key: ProjectionKey;
49
- readonly cleanup: Effect.Effect<void, ProjectionFault>;
49
+ readonly cleanup: Effect.Effect<void, ProjectionFault, R>;
50
50
  }
51
51
  interface Pending<Result, Provides = never> {
52
52
  readonly key: ProjectionKey;
@@ -95,50 +95,41 @@ declare const make: <Result, Provides = never, Requires = never>(options: Omit<C
95
95
  declare const checkpoint: Commit<Folded<unknown>, never, CheckpointStore>;
96
96
  declare const Transaction_base: Context.ServiceClass<Transaction, "@streamsy/projection/Transaction", {
97
97
  readonly owner: object;
98
- readonly sql: SqlClient.SqlClient;
99
98
  readonly withTransaction: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | ProjectionFault, R>;
100
99
  }>;
101
- /** The SQL transaction and stream owner used by Commit.transaction. */
100
+ /** The storage owner's transaction, used by Commit.transaction. */
102
101
  export declare class Transaction extends Transaction_base {
103
- /**
104
- * The storage owner's SQL transaction, for Commit.transaction. Works over every SQL
105
- * storage host. A memory host has no SqlClient, so this Layer does not fit it.
106
- */
107
- static readonly layer: Layer.Layer<Transaction, never, CommitBoundary | SqlClient.SqlClient>;
108
- }
109
- declare const transaction: Commit<Result$1, SqlClient.SqlClient, CheckpointStore | Transaction>;
110
- /** Clean up binding state in the owner transaction on both forget and retire. */
111
- declare const transactionWithCleanup: (cleanup: (key: ProjectionKey, sql: SqlClient.SqlClient) => Effect.Effect<void, ProjectionFault>) => {
112
- pipe<A>(this: A): A;
113
- pipe<A, B = never>(this: A, ab: (_: A) => B): B;
114
- pipe<A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C;
115
- pipe<A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D;
116
- pipe<A, B = never, C = never, D = never, E = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E): E;
117
- pipe<A, B = never, C = never, D = never, E = never, F = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F): F;
118
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G): G;
119
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H): H;
120
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I): I;
121
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J): J;
122
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K): K;
123
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L): L;
124
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M): M;
125
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N): N;
126
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O): O;
127
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P): P;
128
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never, Q = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P, pq: (_: P) => Q): Q;
129
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never, Q = never, R = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P, pq: (_: P) => Q, qr: (_: Q) => R): R;
130
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never, Q = never, R = never, S = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P, pq: (_: P) => Q, qr: (_: Q) => R, rs: (_: R) => S): S;
131
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never, Q = never, R = never, S = never, T = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P, pq: (_: P) => Q, qr: (_: Q) => R, rs: (_: R) => S, st: (_: S) => T): T;
132
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never, Q = never, R = never, S = never, T = never, U = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P, pq: (_: P) => Q, qr: (_: Q) => R, rs: (_: R) => S, st: (_: S) => T, tu: (_: T) => U): U;
133
- pipe<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never, M = never, N = never, O = never, P = never, Q = never, R = never, S = never, T = never, U = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D, de: (_: D) => E, ef: (_: E) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => L, lm: (_: L) => M, mn: (_: M) => N, no: (_: N) => O, op: (_: O) => P, pq: (_: P) => Q, qr: (_: Q) => R, rs: (_: R) => S, st: (_: S) => T, tu: (_: T) => U): U;
134
- "~@streamsy/projection/Commit": Variance<Result$1, SqlClient.SqlClient, CheckpointStore | Transaction>;
135
- name: string;
136
- guarantee: "exactly-once" | "effectively-once" | "at-least-once";
137
- load: (key: ProjectionKey) => Effect.Effect<Loaded, ProjectionFault, CheckpointStore | Transaction>;
138
- apply: (pending: Pending<Result$1, SqlClient.SqlClient>) => Effect.Effect<void, HandlerFailed | ProjectionFault, CheckpointStore | Transaction>;
139
- remove: (key: ProjectionKey) => Effect.Effect<void, ProjectionFault, CheckpointStore | Transaction>;
140
- retire: (request: RetireRequest) => Effect.Effect<RetirementStatus, ProjectionFault, CheckpointStore | Transaction>;
141
- };
102
+ /** Join the commit boundary on a memory or SQL storage host. */
103
+ static readonly layer: Layer.Layer<Transaction, never, CommitBoundary>;
104
+ }
105
+ declare const TransactionCommitTypeId: unique symbol;
106
+ /** A commit that joins the storage owner's transaction and supplies no handler services. */
107
+ interface TransactionCommit<in Result, out Requires> extends Commit<Result, never, Requires> {
108
+ readonly [TransactionCommitTypeId]: true;
109
+ }
110
+ /**
111
+ * Commit the unit and checkpoint together on a memory or SQL storage host.
112
+ * A SqlClient used by the handler must be the storage owner's client for its
113
+ * statements to join the transaction.
114
+ *
115
+ * On the same client the unit joins the outer transaction without a savepoint.
116
+ * With two boundaries over one client, only the outer boundary's hooks and
117
+ * `committed` subscribers see the commit.
118
+ *
119
+ * On another SQL client the unit opens its own transaction. It commits first and
120
+ * survives an outer rollback. Use one client per database for nested work. With
121
+ * two clients on one database, SQLite can wait until it reports a busy lock.
122
+ * Postgres or MySQL can wait for a row lock that the outer transaction holds.
123
+ *
124
+ * Durable Object clients share the driver's transaction, so a second client
125
+ * joins the first. Using a second object's storage on one fiber is unsupported.
126
+ */
127
+ declare const transaction: TransactionCommit<Result$1, CheckpointStore | Transaction>;
128
+ /**
129
+ * Clean up binding state in the owner's transaction on forget and retire.
130
+ * The boundary follows the same nesting rules as {@link transaction}.
131
+ */
132
+ declare const transactionWithCleanup: <R>(cleanup: (key: ProjectionKey) => Effect.Effect<void, ProjectionFault, R>) => TransactionCommit<Result$1, CheckpointStore | Transaction | R>;
142
133
  declare const producer: Commit<Accumulated<unknown, Readonly<Record<string, never>>> | Emitted<Readonly<Record<string, never>>>, never, CheckpointStore>;
143
134
  declare const atLeastOnce: Commit<void | WakeAt, never, CheckpointStore>;
144
135
  declare const withCompensation: {
@@ -146,7 +137,7 @@ declare const withCompensation: {
146
137
  <Result, P, Q, R>(self: Commit<Result, P, Q>, f: (result: Result, cause: Cause.Cause<ProjectionFault | HandlerFailed>, unit: Unit) => Effect.Effect<void, never, R>): Commit<Result, P, Q | R>;
147
138
  };
148
139
  declare namespace commit_d_exports {
149
- export { Accumulated, Commit, Emitted, Folded, HandlerFailed, OutputBatch, Pending, RetireRequest, TypeId$1 as TypeId, Variance, atLeastOnce, checkpoint, make, producer, transaction, transactionWithCleanup, withCompensation };
140
+ export { Accumulated, Commit, Emitted, Folded, HandlerFailed, OutputBatch, Pending, RetireRequest, TransactionCommit, TypeId$1 as TypeId, Variance, atLeastOnce, checkpoint, make, producer, transaction, transactionWithCleanup, withCompensation };
150
141
  }
151
142
  declare const TypeId: unique symbol;
152
143
  interface PerGeneration<D extends StreamDeclaration, N extends string, By extends string = never> {
@@ -260,7 +251,6 @@ interface Attachable<B, HE = never, HR = never, Params = DecodedParams> {
260
251
  onExhausted?(this: void, unit: Unit<unknown>, failure: RunnerFailure): Effect.Effect<void, HE, HR>;
261
252
  } | undefined;
262
253
  readonly id: string;
263
- readonly version: number;
264
254
  readonly generation: number;
265
255
  readonly params: StreamRoute.ParamCodecs;
266
256
  readonly inputs: Inputs;
@@ -439,7 +429,6 @@ type OutputsWithin<C extends StreamRoute.ParamCodecs, D extends RoutedMap> = { r
439
429
  interface Declaration<Codecs extends StreamRoute.ParamCodecs, Bound, HE = never, HR = never> {
440
430
  readonly retry?: BindingRetry<StreamRoute.Params<Codecs>, HE, HR> | undefined;
441
431
  readonly id: string;
442
- readonly version: number;
443
432
  readonly generation: number;
444
433
  readonly params: Codecs;
445
434
  /** The declared inputs, before `at` binds them. */
@@ -473,7 +462,6 @@ interface BindingRetry<Params, E = never, R = never> {
473
462
  interface Common<C extends StreamRoute.ParamCodecs, I extends Inputs, W = undefined, HE = never, HR = never> {
474
463
  readonly retry?: BindingRetry<StreamRoute.Params<C>, HE, HR>;
475
464
  readonly id: string;
476
- readonly version?: number;
477
465
  readonly generation?: number;
478
466
  readonly params: C;
479
467
  readonly inputs: I & Within<C, I>;
@@ -503,7 +491,6 @@ type WakeOutput<P = any> = StreamDeclaration & StreamRoute.StateRoute<P, Streams
503
491
  interface WakeDefinition<C extends StreamRoute.ParamCodecs, I extends Input, O, W = undefined> {
504
492
  readonly accepted?: W & OneOutputWithin<C, W>;
505
493
  readonly id: string;
506
- readonly version?: number;
507
494
  readonly generation?: number;
508
495
  readonly params: C;
509
496
  /** The one source stream. Its params must be projection params. */
@@ -556,6 +543,14 @@ interface ProcessContext<Prepared = void> {
556
543
  interface OutputsContext<O extends RoutedMap> {
557
544
  readonly outputs: HandlerOutputs<O>;
558
545
  }
546
+ type TransactionBrand = Omit<TransactionCommit<never, never>, keyof Commit<never>>;
547
+ type WithTransactionCommit<D extends {
548
+ readonly at: (...args: never[]) => object;
549
+ }> = Omit<D, "at"> & {
550
+ readonly at: (...args: Parameters<D["at"]>) => ReturnType<D["at"]> & {
551
+ readonly commit: TransactionBrand;
552
+ };
553
+ };
559
554
  /** Run side effects once per unit, including recorded wakes. Return wakeAt(time) to
560
555
  * replace the timer, or void to clear it. Timers require atLeastOnce or transaction.
561
556
  * prepare runs at least once, outside the transaction. */
@@ -564,11 +559,12 @@ declare function process$1<C extends StreamRoute.ParamCodecs, I extends Inputs,
564
559
  readonly prepare?: (batch: Slices<Addresses<I>>, unit: Unit<StreamRoute.Params<C>>) => Effect.Effect<Prepared, PE, PR>;
565
560
  readonly process: (batch: Slices<Addresses<I>>, unit: Unit<StreamRoute.Params<C>>, context: ProcessContext<Prepared>) => Effect.Effect<A, E, R>;
566
561
  }): RunningDeclaration<C, I, E | PE, R, TimerResult<A>, P, Q | PR, never, AcceptedServices<W>, HE, HR>;
567
- declare function process$1<C extends StreamRoute.ParamCodecs, I extends Inputs, const O extends RoutedMap, E = never, R = never, Q = never, Prepared = void, PE = never, PR = never, W extends AcceptedOutput | undefined = undefined, HE = never, HR = never, A = void>(definition: Common<C, I, W, HE, HR> & Committing<AcceptedResult<TimerResult<A>, W>, SqlClient.SqlClient, Q> & {
562
+ declare function process$1<C extends StreamRoute.ParamCodecs, I extends Inputs, const O extends RoutedMap, E = never, R = never, Q = never, Prepared = void, PE = never, PR = never, W extends AcceptedOutput | undefined = undefined, HE = never, HR = never, A = void>(definition: Common<C, I, W, HE, HR> & Committing<AcceptedResult<TimerResult<A>, W>, never, Q> & {
563
+ readonly commit: TransactionBrand;
568
564
  readonly outputs: O & OutputsWithin<C, O>;
569
565
  readonly prepare?: (batch: Slices<Addresses<I>>, unit: Unit<StreamRoute.Params<C>>, context: OutputsContext<O>) => Effect.Effect<Prepared, PE, PR>;
570
566
  readonly process: (batch: Slices<Addresses<I>>, unit: Unit<StreamRoute.Params<C>>, context: ProcessContext<Prepared> & OutputsContext<O>) => Effect.Effect<A, E, R>;
571
- }): OutputDeclaration<C, I, O, E | PE, R, TimerResult<A>, SqlClient.SqlClient, Q | PR, never, AcceptedServices<W>, HE, HR>;
567
+ }): WithTransactionCommit<OutputDeclaration<C, I, O, E | PE, R, TimerResult<A>, never, Q | PR, never, AcceptedServices<W>, HE, HR>>;
572
568
  /** Emit zero or more output items for each input entry, in entry order. */
573
569
  declare function emit<C extends StreamRoute.ParamCodecs, I extends Inputs, const O extends StaticOutputMap, X extends Emits<O>, E = never, R = never, P = never, Q = never, W extends AcceptedOutput | undefined = undefined, HE = never, HR = never>(definition: Common<C, I, W, HE, HR> & Committing<Emitted<NoInfer<O>>, P, Q> & {
574
570
  readonly outputs: O & OutputsWithin<C, O>;
@@ -619,7 +615,7 @@ interface AttachOptions<Params = DecodedParams, E = never, R = never> {
619
615
  /**
620
616
  * Decoded params to consider for startup replay. Defaults to the checkpoint
621
617
  * inventory when it is available. An explicit list uses this declaration's
622
- * id, version and generation to check for existing checkpoints.
618
+ * id and generation to check for existing checkpoints.
623
619
  */
624
620
  readonly bindings?: Effect.Effect<ReadonlyArray<Params>, E, R>;
625
621
  /**
@@ -705,12 +701,13 @@ interface CurrentProjection<Inputs extends InputMap, S, E, R, Q> extends Identit
705
701
  declare const current: <Inputs extends InputMap, S, E, R, Q>(projection: CurrentProjection<Inputs, S, E, R, Q>) => Effect.Effect<Snapshot<S, Inputs>, E | ProjectionFault, Q | R | InputServices<Inputs>>;
706
702
  /**
707
703
  * Lists the decoded params of bindings with live checkpoints in the selected store.
708
- * By default it includes every generation of the declaration's id, across checkpoint
709
- * versions. A generation filter still includes every version at that generation.
704
+ * By default it includes every generation of the declaration's id. The inventory
705
+ * reads every stored version slot, even with a generation filter.
710
706
  * Each binding appears once, in unspecified order.
711
707
  *
712
708
  * Fails with `InvalidBinding` if live params cannot round-trip through the current
713
- * codecs. MySQL owner stores fail because historical hashed keys cannot be decoded.
709
+ * codecs. On MySQL, listing fails while the range contains a legacy hashed key
710
+ * that has yet to be rewritten.
714
711
  */
715
712
  declare const bindings: <C extends Readonly<Record<string, Schema.Codec<unknown, string, never, never>>>>(declaration: Pick<Declaration<C, unknown, never, never>, "id" | "params">, options?: {
716
713
  readonly generation?: number;
@@ -779,23 +776,27 @@ declare class LostRace {
779
776
  constructor(mismatch: OffsetMismatch);
780
777
  }
781
778
  /**
782
- * Deletes a live record and preserves retirement tombstones. Stop the follower first,
779
+ * Deletes a live checkpoint and marks its routed outputs as forgotten so retirement
780
+ * can still find them. Preserves retirement tombstones. Stop the follower first,
783
781
  * or use a new generation.
782
+ * Pass the binding from `declaration.at(params)` for a routed projection. A bare
783
+ * key deletes the checkpoint and leaves the route records live.
784
784
  * Delete stream outputs first, because forgetting restarts their producer sequences.
785
785
  */
786
786
  declare const forget: <R>(projection: ProjectionKey & {
787
787
  readonly commit: Pick<Commit<never, never, R>, "remove">;
788
788
  }) => Effect.Effect<void, ProjectionFault, R>;
789
789
  type StreamMode = "remove" | "close";
790
- interface RetiredOutput {
790
+ interface RetiredStream {
791
+ /** The declared output name, or "@streamsy/accepted". */
792
+ readonly output: string;
791
793
  readonly id: string;
792
794
  readonly result: "removed" | "closed" | "absent" | "shared";
793
795
  }
794
796
  interface Retired {
795
797
  readonly record: RetirementStatus;
796
- readonly outputs: Readonly<Record<string, RetiredOutput>>;
797
- /** Exclusively owned streams opened by each routed output. */
798
- readonly routed?: Readonly<Record<string, ReadonlyArray<RetiredOutput>>>;
798
+ /** Every wrapped output stream, sorted by output name and then stream id. */
799
+ readonly streams: ReadonlyArray<RetiredStream>;
799
800
  }
800
801
  interface Retirable<R, Q> extends ProjectionKey, BoundOutputs<R> {
801
802
  readonly commit: Pick<Commit<never, never, Q>, "retire">;
@@ -806,9 +807,9 @@ declare const retire: <C extends StreamRoute.ParamCodecs, R, Q, HE, HR>(declarat
806
807
  readonly streams?: StreamMode;
807
808
  }) => Effect.Effect<Retired, ProjectionFault, R | Q>;
808
809
  declare namespace projection_d_exports {
809
- export { InputLag, Lag, PerGeneration, Registry, RegistryApi, Retired, RetiredOutput, RoutedHandle, RunnerEvent, RunnerFailure, RunnerStatus, Tails, WakeAt, WakeOutput, attach$1 as attach, bindings, caughtUp, createOutputs, current, decide, each, emit, fold, follow, forget, generationBinding, isPerGeneration, items, key, lag, mapAccum, mapAccumBatch, pass, perGeneration, process$1 as process, read, retire, run, tails, wake, wakeAt };
810
+ export { InputLag, Lag, PerGeneration, Registry, RegistryApi, Retired, RetiredStream, RoutedHandle, RunnerEvent, RunnerFailure, RunnerStatus, Tails, WakeAt, WakeOutput, attach$1 as attach, bindings, caughtUp, createOutputs, current, decide, each, emit, fold, follow, forget, generationBinding, isPerGeneration, items, key$1 as key, lag, mapAccum, mapAccumBatch, pass, perGeneration, process$1 as process, read, retire, run, tails, wake, wakeAt };
810
811
  }
811
- declare const key: (projection: Identity) => ProjectionKey;
812
+ declare const key$1: (projection: Identity) => ProjectionKey;
812
813
  /** Runs each tagged entry in order and discards its success value. */
813
814
  declare const each: <Inputs extends InputMap, E, R, P = Record<string, string>>(handle: (entry: Entry<Inputs>, unit: Unit<P>) => Effect.Effect<unknown, E, R>) => ((batch: Slices<Inputs>, unit: Unit<P>) => Effect.Effect<void, E, R>);
814
815
  declare namespace state_table_d_exports {
@@ -824,7 +825,6 @@ interface ListOptions {
824
825
  /** A State stream bound to its params: a bound projection, plus the row reads and `sync`. */
825
826
  interface Bound<C extends StreamAddress.Collections, R> {
826
827
  readonly id: string;
827
- readonly version: number;
828
828
  readonly generation: number;
829
829
  readonly params: Record<string, string>;
830
830
  /** The State stream, read as stored JSON text. */
@@ -835,7 +835,7 @@ interface Bound<C extends StreamAddress.Collections, R> {
835
835
  readonly commit: typeof transaction;
836
836
  readonly process: (batch: Slices<{
837
837
  readonly state: Streamsy.Address<string, R>;
838
- }>) => Effect.Effect<void, ProjectionFault, Transaction | R>;
838
+ }>) => Effect.Effect<void, ProjectionFault, SqlClient.SqlClient | R>;
839
839
  /** The row of `key`. `value` is undefined when the row is absent. */
840
840
  readonly get: <K extends keyof C & string>(collection: K, key: string) => Effect.Effect<{
841
841
  readonly offset: string;
@@ -858,7 +858,7 @@ interface Bound<C extends StreamAddress.Collections, R> {
858
858
  /** The stream offset that the rows reflect. */
859
859
  readonly offset: () => Effect.Effect<string, SqlError.SqlError, SqlClient.SqlClient>;
860
860
  /** Apply the stream from the head of the table to its tail, in the caller's transaction. */
861
- readonly sync: () => Effect.Effect<void, ProjectionFault, Transaction | R>;
861
+ readonly sync: () => Effect.Effect<void, ProjectionFault, SqlClient.SqlClient | R>;
862
862
  }
863
863
  /** The declaration of a State table. Runners and `attach` take it like any declaration. */
864
864
  interface Declaration$1<Codecs extends StreamRoute.ParamCodecs, C extends StreamAddress.Collections, R> extends Omit<Declaration<Codecs, Bound<C, R>>, "inputs" | "parse"> {
@@ -877,9 +877,9 @@ declare function define<Codecs extends StreamRoute.ParamCodecs, C extends Stream
877
877
  readonly accepted?: W & OneWithin<Codecs, W>;
878
878
  }): Declaration$1<Codecs, C, R | AcceptedServices<W>>;
879
879
  /** Delete cached rows and their applied offset, even if the State stream has been removed. */
880
- declare const clear: <C extends StreamAddress.Collections, R>(table: Bound<C, R>) => Effect.Effect<void, ProjectionFault, Transaction>;
880
+ declare const clear: <C extends StreamAddress.Collections, R>(table: Bound<C, R>) => Effect.Effect<void, ProjectionFault, SqlClient.SqlClient | Transaction>;
881
881
  /** Discard the index and replay the State stream atomically, retaining the binding checkpoint. */
882
- declare const rebuild: <C extends StreamAddress.Collections, R>(table: Bound<C, R>) => Effect.Effect<void, ProjectionFault, R | Transaction>;
882
+ declare const rebuild: <C extends StreamAddress.Collections, R>(table: Bound<C, R>) => Effect.Effect<void, ProjectionFault, R | SqlClient.SqlClient | Transaction>;
883
883
  /** Append a reset to the State stream. The next table run applies it. */
884
884
  declare const reset: <C extends StreamAddress.Collections, R>(table: Bound<C, R>) => Effect.Effect<import("@streamsy/core").AppendResult, Streams.AppendFailure<{}>, R>;
885
885
  declare const FoldByKeyError_base: Schema.Class<FoldByKeyError, Schema.TaggedStruct<"FoldByKeyError", {
@@ -902,7 +902,7 @@ type Output<C extends StreamAddress.Collections, R> = StreamAddress.StateAddress
902
902
  */
903
903
  type Handler<C extends StreamAddress.Collections, O extends string, I extends InputMap, P, E, R, TR> = (batch: Slices<I>, unit: Unit<P>, context: {
904
904
  readonly outputs: Readonly<Record<O, Output<C, TR>>>;
905
- }) => Effect.Effect<void, E | FoldByKeyError | ProjectionFault, R | TR | SqlClient.SqlClient | Transaction | StreamAddress.CollectionsDecodingServices<C> | StreamAddress.CollectionsEncodingServices<C>>;
905
+ }) => Effect.Effect<void, E | FoldByKeyError | ProjectionFault, R | TR | SqlClient.SqlClient | StreamAddress.CollectionsDecodingServices<C> | StreamAddress.CollectionsEncodingServices<C>>;
906
906
  interface Spec<C extends StreamAddress.Collections, K extends keyof C & string, O extends string, A, P, E, R> {
907
907
  readonly output: O;
908
908
  readonly collection: K;