@pgxsinkit/client 0.5.2 → 0.6.0-rc.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"local-tables.d.ts","sourceRoot":"","sources":["../src/local-tables.ts"],"names":[],"mappings":"AAEA,OAAO,EAaL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAgH9B,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAkE,CAAC;AACrF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAkE,CAAC;AACrF,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiF,CAAC;AACtG,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiF,CAAC;AACtG,QAAA,MAAM,cAAc;;;;;;;;;;;;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,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,WAAW,CASvE;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,cAAc,CAY7E"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parse a `Retry-After` header (delta-seconds or HTTP-date, RFC 9110 §10.2.3) into ms, or null when
3
+ * absent/unreadable.
4
+ *
5
+ * Shared by the two clients that honour it: the Event lane's flush loop and the stream reader. Both treat
6
+ * it as a floor under their own backoff, never as a replacement for it.
7
+ */
8
+ export declare function parseRetryAfterMs(headerValue: string | null | undefined, nowMs: number): number | null;
9
+ //# sourceMappingURL=retry-after.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-after.d.ts","sourceRoot":"","sources":["../src/retry-after.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBtG"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAWL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAuB9B,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAE/C,iHAAiH;AACjH,eAAO,MAAM,eAAe,yBAAwB,CAAC;AACrD,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAC/D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AACvE,4EAA4E;AAC5E,eAAO,MAAM,+BAA+B,UAAU,CAAC;A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AgB,4BAA4B,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAyB7G;AA4GD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAkBtG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAmCvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,SAAS,iBAAiB,EACrE,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,GACf,MAAM,CA2BR"}
@@ -1 +1 @@
1
- {"version":3,"file":"store-build.d.ts","sourceRoot":"","sources":["../src/store-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA6B,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAEjH;AAeD,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE3D"}
1
+ {"version":3,"file":"store-build.d.ts","sourceRoot":"","sources":["../src/store-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA6B,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAEjH;AAgBD,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE3D"}
@@ -96,6 +96,7 @@ declare function buildSubscriptionsMetadata(schema: ReturnType<typeof pgSchema>)
96
96
  }>;
97
97
  };
98
98
  dialect: 'pg';
99
+ isAlias: false;
99
100
  }>;
100
101
  declare function buildShapeRowTags(schema: ReturnType<typeof pgSchema>): import("drizzle-orm/pg-core").PgTableWithColumns<{
101
102
  name: "shape_row_tags";
@@ -148,6 +149,7 @@ declare function buildShapeRowTags(schema: ReturnType<typeof pgSchema>): import(
148
149
  }>;
149
150
  };
150
151
  dialect: 'pg';
152
+ isAlias: false;
151
153
  }>;
152
154
  /** The (memoized) metadata-store `pgTable`s for a given metadata schema name. */
153
155
  export declare function getMetadataTables(metadataSchema: string): MetadataTables;
@@ -1 +1 @@
1
- {"version":3,"file":"metadata-tables.d.ts","sourceRoot":"","sources":["../../src/sync/metadata-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAoB,MAAM,qBAAqB,CAAC;AAE/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAQnD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAStE;AAED;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;IAC9E;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CAC7D;AAYD,iBAAS,0BAA0B,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;GAa7D;AAID,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc,CAWxE;AAID;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CASzD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,cAAc,CAEjG"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAC7C,OAAO,EAAE;QAAE,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;CAClC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAC7C,OAAO,EAAE;QAAE,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;CAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgxsinkit/client",
3
- "version": "0.5.2",
3
+ "version": "0.6.0-rc.1",
4
4
  "keywords": [
5
5
  "tanstack-intent"
6
6
  ],
@@ -40,15 +40,14 @@
40
40
  "build": "bun --cwd ../.. run build:public-packages"
41
41
  },
42
42
  "dependencies": {
43
- "@durable-streams/client": "0.2.7",
44
- "@pgxsinkit/contracts": "0.5.2",
45
- "@pgxsinkit/pgwasm": "0.5.2",
46
- "@pgxsinkit/pgwasm-c": "0.5.2",
47
- "@pgxsinkit/pgwasm-pg-dump": "0.5.2"
43
+ "@pgxsinkit/contracts": "0.6.0-rc.1",
44
+ "@pgxsinkit/pgwasm": "0.6.0-rc.1",
45
+ "@pgxsinkit/pgwasm-c": "0.6.0-rc.1",
46
+ "@pgxsinkit/pgwasm-pg-dump": "0.6.0-rc.1"
48
47
  },
49
48
  "peerDependencies": {
50
- "drizzle-orm": "1.0.0-rc.4",
51
- "zod": "^4.6.5"
49
+ "drizzle-orm": "rc",
50
+ "zod": "^4.6.7"
52
51
  },
53
52
  "repository": {
54
53
  "type": "git",
@@ -15,7 +15,7 @@ description: >-
15
15
  metadata:
16
16
  type: core
17
17
  library: "@pgxsinkit/client"
18
- library_version: "0.5.2"
18
+ library_version: "0.6.0-rc.1"
19
19
  source: https://pgxsinkit.github.io/llms-full.txt
20
20
  ---
21
21
 
@@ -15,7 +15,7 @@ description: >-
15
15
  metadata:
16
16
  type: task
17
17
  library: "@pgxsinkit/client"
18
- library_version: "0.5.2"
18
+ library_version: "0.6.0-rc.1"
19
19
  source: https://pgxsinkit.github.io/start/operating-in-production/
20
20
  ---
21
21
 
@@ -40,7 +40,7 @@ latency** (latency is bounded by the read-path echo). Do **not** shorten it to "
40
40
 
41
41
  ## Serve the gateway over HTTP/2 (the connection budget)
42
42
 
43
- `@durable-streams/client` holds **one live long-poll connection open per subscribed stream** (a subject in K
43
+ `@pgxsinkit/client`'s reader holds **one live long-poll connection open per subscribed stream** (a subject in K
44
44
  scopes of a shared shape holds K streams), and browsers cap **HTTP/1.1 at ~6 connections per origin** — so over
45
45
  plain HTTP six streams' long-polls consume every slot and the same-origin **write** request is **Stalled in the
46
46
  browser's connection queue** for a whole long-poll cycle before it is dispatched. This presents as multi-second
@@ -417,9 +417,9 @@ entitlement-propagation latency.
417
417
  **Every `createStreamGate` mount must set `Access-Control-Expose-Headers` from the exported
418
418
  `STREAM_READ_EXPOSED_HEADERS`.** CORS lets script read only a short safelist, and every header durable-streams
419
419
  answers with is outside it, so a cross-origin browser gets a response whose stream headers are simply not there:
420
- `@durable-streams/client` steers its read loop off them, never learns an offset, and re-requests from the start
421
- in a hot loop, with no error raised on either side. It presents as "sync does nothing, and the console is clean".
422
- Mount details: the `deploying` skill.
420
+ the reader cannot make progress and every read fails, naming the missing `Stream-Next-Offset` (releases built
421
+ on `@durable-streams/client` instead hot-loop from the start with no error on either side). Mount details: the
422
+ `deploying` skill.
423
423
 
424
424
  ## Debugging latency: `globalThis.__pgxsinkitDebug`
425
425
 
@@ -488,7 +488,7 @@ a real rollback, route a permanent policy denial to `quarantined` — never mis-
488
488
  - Shortening the convergence interval to chase write latency (no effect; wastes CPU).
489
489
  - Serving many-stream sync over plain HTTP/1.1 and blaming the server for stalled writes.
490
490
  - Mounting the stream edge on the control plane's origin (one cache key for both read surfaces), or omitting
491
- `Access-Control-Expose-Headers` on it — that one hot-loops the client, silently on both sides.
491
+ `Access-Control-Expose-Headers` on it — that one fails every cross-origin read (and hot-loops older clients).
492
492
  - Treating an edge cold start as a toolkit problem, or measuring latency by polling the local store in a loop
493
493
  instead of at the network boundary.
494
494
  - Treating `deferred` as a failure and "cleaning up" the Outbox — it is rollout skew; those rows self-drain.
@@ -0,0 +1,174 @@
1
+ import type { StreamEnvelope } from "@pgxsinkit/contracts";
2
+
3
+ // The wire half of pgxsinkit's stream reader: one read request in the Durable Streams protocol's
4
+ // catch-up and long-poll modes, for JSON streams, and what its answer means. The protocol is
5
+ // PROTOCOL.md at pgxsinkit/durable-streams@a172acc389351cb3db6deb5cd60e3dec11e7ff39: reads §5.6–5.7,
6
+ // offsets §8, JSON mode §9.1, cursors and caching §10.1. Server-sent events (§5.8) are out of scope:
7
+ // pgxsinkit has never read that way. The session built on this — token recovery, backpressure, the end
8
+ // contract — is `stream-source.ts`.
9
+
10
+ /**
11
+ * Every response header the reader reads.
12
+ *
13
+ * A cross-origin browser sees none of them unless the edge names them on
14
+ * `Access-Control-Expose-Headers` (`STREAM_READ_EXPOSED_HEADERS` in `@pgxsinkit/server`, which a unit
15
+ * test holds to this list). The first four steer the read; `retry-after` only refines a backoff.
16
+ */
17
+ export const READ_RESPONSE_HEADERS = [
18
+ "stream-next-offset",
19
+ "stream-up-to-date",
20
+ "stream-cursor",
21
+ "stream-closed",
22
+ "retry-after",
23
+ ] as const;
24
+
25
+ /** Where the next request reads from. */
26
+ export interface ReadPosition {
27
+ offset: string;
28
+ /** The latest `Stream-Cursor`, echoed so a CDN can collapse identical polls (§10.1). */
29
+ cursor: string | null;
30
+ /** Hold the request open at the tail. Set once a live read has been told it is up to date. */
31
+ longPoll: boolean;
32
+ }
33
+
34
+ /**
35
+ * The request URL for a position: `offset`, then `live=long-poll`, then `cursor`, appended to whatever
36
+ * query the stream URL already carries.
37
+ *
38
+ * A catch-up request never says `live`. It stays an ordinary, cacheable read of a fixed range; only the
39
+ * request at the tail asks the server to wait.
40
+ */
41
+ export function readRequestUrl(streamUrl: string, position: ReadPosition): string {
42
+ const url = new URL(streamUrl);
43
+ url.searchParams.set("offset", position.offset);
44
+ if (position.longPoll) url.searchParams.set("live", "long-poll");
45
+ if (position.cursor !== null) url.searchParams.set("cursor", position.cursor);
46
+ return url.toString();
47
+ }
48
+
49
+ /** One successful response, read to the end. */
50
+ export interface ReadResponse {
51
+ envelopes: StreamEnvelope[];
52
+ /** `Stream-Next-Offset`: where the read resumes after this response. */
53
+ offset: string;
54
+ cursor: string | null;
55
+ /** `Stream-Up-To-Date` is present: this response reached the tail as it stood when it was generated. */
56
+ upToDate: boolean;
57
+ /** `Stream-Closed: true`: the tail is final and nothing will ever follow (EOF). */
58
+ closed: boolean;
59
+ }
60
+
61
+ /** A read that failed: a status the reader does not retry, or a response it cannot make sense of. */
62
+ export class StreamReadError extends Error {
63
+ /** The HTTP status, when the failure was one. */
64
+ readonly status: number | undefined;
65
+
66
+ constructor(message: string, status?: number) {
67
+ super(message);
68
+ this.name = "StreamReadError";
69
+ this.status = status;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * What a non-2xx status means for the request that got it.
75
+ *
76
+ * - 401 and 403: the token was refused. The session decides whether a fresh one is worth one retry.
77
+ * - 429 and every 5xx: the server is overloaded, restarting or cold-starting, and the same request can
78
+ * succeed later. Retried with backoff.
79
+ * - Everything else, 404 and 410 included: the request itself is wrong or the stream is gone (never
80
+ * created, or retired), and repeating it cannot change the answer.
81
+ */
82
+ export function classifyStatus(status: number): "token-rejected" | "retry" | "terminal" {
83
+ if (status === 401 || status === 403) return "token-rejected";
84
+ if (status === 429 || status >= 500) return "retry";
85
+ return "terminal";
86
+ }
87
+
88
+ /** The error for a response the reader will not retry, with the server's own reason when it gave one. */
89
+ export async function failedRead(response: Response, url: string): Promise<StreamReadError> {
90
+ const body = (await response.text().catch(() => "")).trim();
91
+ const reason = body.length > 200 ? `${body.slice(0, 200)}…` : body;
92
+ return new StreamReadError(
93
+ `[pgxsinkit] stream read failed: HTTP ${response.status} at ${url}${reason ? `: ${reason}` : ""}`,
94
+ response.status,
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Read a 2xx response: its envelopes and the position after them.
100
+ *
101
+ * Three answers are protocol violations and fail the read rather than being guessed around, because
102
+ * each would otherwise re-ask the same question forever: no `Stream-Next-Offset` (the server MUST send
103
+ * it, so its absence means an edge stripped it, typically a cross-origin mount that does not expose
104
+ * it); a body that is not a JSON array (§9.1.5); and an empty response that neither moved the offset
105
+ * nor reached the tail (the shape a stripped `Stream-Up-To-Date` takes at the tail).
106
+ */
107
+ export async function readResponse(response: Response, url: string, requestedOffset: string): Promise<ReadResponse> {
108
+ const headers = response.headers;
109
+ const offset = headers.get("stream-next-offset");
110
+ if (!offset) {
111
+ throw new StreamReadError(
112
+ `[pgxsinkit] stream response carried no Stream-Next-Offset (${url}). A cross-origin edge must expose ` +
113
+ "the stream-* headers on Access-Control-Expose-Headers (STREAM_READ_EXPOSED_HEADERS).",
114
+ response.status,
115
+ );
116
+ }
117
+
118
+ const body = response.status === 204 ? "" : (await response.text()).trim();
119
+ let envelopes: unknown = [];
120
+ if (body !== "") {
121
+ try {
122
+ envelopes = JSON.parse(body);
123
+ } catch {
124
+ envelopes = null;
125
+ }
126
+ }
127
+ if (!Array.isArray(envelopes)) {
128
+ throw new StreamReadError(`[pgxsinkit] stream response body is not a JSON array (${url})`, response.status);
129
+ }
130
+
131
+ const upToDate = headers.has("stream-up-to-date");
132
+ const closed = headers.get("stream-closed")?.toLowerCase() === "true";
133
+ if (envelopes.length === 0 && offset === requestedOffset && !upToDate && !closed) {
134
+ throw new StreamReadError(
135
+ `[pgxsinkit] stream response neither advanced the offset nor reached the tail (${url}). Is the edge ` +
136
+ "exposing Stream-Up-To-Date (STREAM_READ_EXPOSED_HEADERS)?",
137
+ response.status,
138
+ );
139
+ }
140
+
141
+ return { envelopes: envelopes as StreamEnvelope[], offset, cursor: headers.get("stream-cursor"), upToDate, closed };
142
+ }
143
+
144
+ /**
145
+ * The backoff before retry `attempt` (1-based) of one request: full jitter, a random share of a ceiling
146
+ * that starts at 100 ms and grows 1.3× per attempt up to 60 s, with the server's `Retry-After` as a floor.
147
+ *
148
+ * Jitter spreads a fleet that lost the same edge at the same moment, so its retries do not arrive
149
+ * together. There is no attempt limit: a read waits out an outage or a lost network at one request a
150
+ * minute rather than giving up, and the caller can always close it.
151
+ */
152
+ export function retryDelayMs(attempt: number, retryAfterMs: number | null, random: () => number): number {
153
+ const ceiling = Math.min(100 * 1.3 ** (attempt - 1), 60_000);
154
+ return Math.round(Math.max(retryAfterMs ?? 0, random() * ceiling));
155
+ }
156
+
157
+ /** Wait `ms`, or less if `signal` aborts first. Never rejects: the caller checks the signal afterwards. */
158
+ export function sleep(ms: number, signal: AbortSignal): Promise<void> {
159
+ return new Promise((resolve) => {
160
+ if (signal.aborted) {
161
+ resolve();
162
+ return;
163
+ }
164
+ const onAbort = (): void => {
165
+ clearTimeout(timer);
166
+ resolve();
167
+ };
168
+ const timer = setTimeout(() => {
169
+ signal.removeEventListener("abort", onAbort);
170
+ resolve();
171
+ }, ms);
172
+ signal.addEventListener("abort", onAbort, { once: true });
173
+ });
174
+ }
@@ -42,9 +42,9 @@ export interface ShapeGroupOptions {
42
42
  /**
43
43
  * Run K shape streams as one group.
44
44
  *
45
- * This layer is **ours permanently**, not a bridge to something (ADR-0055 decision 10):
46
- * `@durable-streams/client` reads one stream and has no multi-stream coordinator, so the K-streams
47
- * side of decision 4 has to exist either way. What it deliberately does NOT do is imitate Electric's
45
+ * This layer is **ours permanently**, not a bridge to something (ADR-0055 decision 10): the stream
46
+ * reader ({@link readShapeStream}) reads one stream and has no multi-stream coordinator, so the
47
+ * K-streams side of decision 4 has to exist either way. What it deliberately does NOT do is imitate Electric's
48
48
  * `MultiShapeStream` — it hands back envelopes and per-stream offsets, which is what the native path
49
49
  * actually has, rather than reshaping them into a wire format we no longer speak.
50
50
  *