@rotorsoft/act-http 1.10.24 → 1.11.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/api/errors.d.ts +6 -1
- package/dist/@types/api/errors.d.ts.map +1 -1
- package/dist/@types/sse/broadcast.d.ts +35 -4
- package/dist/@types/sse/broadcast.d.ts.map +1 -1
- package/dist/api/index.cjs +3 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/{chunk-H545LMMV.js → chunk-5KZI37IT.js} +2 -2
- package/dist/{chunk-ZQGGGU4E.js → chunk-FSN52BXM.js} +5 -1
- package/dist/chunk-FSN52BXM.js.map +1 -0
- package/dist/hono/index.cjs +3 -0
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.js +2 -2
- package/dist/sse/index.cjs +0 -4
- package/dist/sse/index.cjs.map +1 -1
- package/dist/sse/index.js +0 -4
- package/dist/sse/index.js.map +1 -1
- package/dist/trpc/index.cjs +3 -0
- package/dist/trpc/index.cjs.map +1 -1
- package/dist/trpc/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-ZQGGGU4E.js.map +0 -1
- /package/dist/{chunk-H545LMMV.js.map → chunk-5KZI37IT.js.map} +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* error parsers.
|
|
6
6
|
*
|
|
7
7
|
* - `error` — the framework error name (`"ValidationError"`,
|
|
8
|
-
* `"
|
|
8
|
+
* `"PreconditionError"`, …). Stable identifier, safe to switch on.
|
|
9
9
|
* - `detail` — the framework's message text. Human-readable; not
|
|
10
10
|
* parsed by clients.
|
|
11
11
|
* - `code` — a machine-readable status code from {@link ERROR_MAP}
|
|
@@ -38,6 +38,11 @@ export declare const ERROR_MAP: {
|
|
|
38
38
|
readonly status: 422;
|
|
39
39
|
readonly code: "VALIDATION";
|
|
40
40
|
};
|
|
41
|
+
readonly PreconditionError: {
|
|
42
|
+
readonly status: 409;
|
|
43
|
+
readonly code: "PRECONDITION";
|
|
44
|
+
};
|
|
45
|
+
/** @deprecated Thrown only by the deprecated `.given` rules. Removed in 2.0. */
|
|
41
46
|
readonly InvariantError: {
|
|
42
47
|
readonly status: 409;
|
|
43
48
|
readonly code: "INVARIANT";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/api/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/api/errors.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS;;iBACD,MAAM,EAAE,GAAG;iBAAE,IAAI,EAAE,YAAY;;;iBAC7B,MAAM,EAAE,GAAG;iBAAE,IAAI,EAAE,cAAc;;IACtD,gFAAgF;;iBAC9D,MAAM,EAAE,GAAG;iBAAE,IAAI,EAAE,WAAW;;;iBAC5B,MAAM,EAAE,GAAG;iBAAE,IAAI,EAAE,aAAa;;;iBAC/B,MAAM,EAAE,GAAG;iBAAE,IAAI,EAAE,eAAe;;;iBAClC,MAAM,EAAE,GAAG;iBAAE,IAAI,EAAE,eAAe;;CACP,CAAC;AAenD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAuB3E"}
|
|
@@ -1,15 +1,46 @@
|
|
|
1
1
|
import { StateCache } from "./state-cache.js";
|
|
2
2
|
import { type BroadcastState, type PatchMessage, type Subscriber } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Server-side broadcast channel for incremental state sync over SSE.
|
|
5
|
+
*
|
|
6
|
+
* Manages per-stream subscriber sets and an LRU state cache. When state
|
|
7
|
+
* changes, forwards domain patches (from event handlers) to all subscribers
|
|
8
|
+
* as version-keyed messages.
|
|
9
|
+
*
|
|
10
|
+
* ## Usage
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const broadcast = new BroadcastChannel<MyState>();
|
|
14
|
+
*
|
|
15
|
+
* // After every app.do():
|
|
16
|
+
* const snaps = await app.do(...);
|
|
17
|
+
* const patches = snaps.map(s => s.patch).filter(Boolean);
|
|
18
|
+
* const state = deriveState(snaps.at(-1));
|
|
19
|
+
* broadcast.publish(streamId, state, patches);
|
|
20
|
+
*
|
|
21
|
+
* // In SSE subscription:
|
|
22
|
+
* const cleanup = broadcast.subscribe(streamId, (msg) => {
|
|
23
|
+
* pending = msg;
|
|
24
|
+
* resolve?.();
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Initial state for reconnects:
|
|
28
|
+
* const cached = broadcast.state(streamId);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ## Version Contract
|
|
32
|
+
*
|
|
33
|
+
* The `_v` field on state MUST be set from `snap.event.version` (the event
|
|
34
|
+
* store's monotonic stream version) BEFORE calling `publish()`. This is the
|
|
35
|
+
* single source of truth for ordering — no separate version counters.
|
|
36
|
+
*/
|
|
3
37
|
export declare class BroadcastChannel<S extends BroadcastState = BroadcastState> {
|
|
4
38
|
private channels;
|
|
5
39
|
private state_cache;
|
|
6
|
-
/**
|
|
7
|
-
* @param options.cacheSize - Max number of stream states kept in the LRU
|
|
8
|
-
* cache (default 50).
|
|
9
|
-
*/
|
|
10
40
|
private on_subscriber_error;
|
|
11
41
|
private on_overlay_miss;
|
|
12
42
|
constructor(options?: {
|
|
43
|
+
/** Max number of stream states kept in the LRU cache (default 50). */
|
|
13
44
|
cacheSize?: number;
|
|
14
45
|
/**
|
|
15
46
|
* Called when overlay-contributed state is lost, on either of the two
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/sse/broadcast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/sse/broadcast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AA0IpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;IACrE,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,mBAAmB,CAA6C;IACxE,OAAO,CAAC,eAAe,CAA6B;IAEpD,YAAY,OAAO,CAAC,EAAE;QACpB,sEAAsE;QACtE,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;;;;;;;;;;;;;WAcG;QACH,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;QAC3C;;;;;WAKG;QACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;QAC/D;;;;WAIG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,EAQA;IAED;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;;;OAOG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,OAAO,CAAC,CAAC,CAAC,EAAO,GACzB,YAAY,CAAC,CAAC,CAAC,CAwCjB;IAED;;;;OAIG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,GACxB,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CA6C7B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CASzD;IAED,kDAAkD;IAClD,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExC;IAED,8EAA8E;IAC9E,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAErC;IAED,4DAA4D;IAC5D,eAAe,CACb,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,GACxB,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAE7B;IAED,oEAAoE;IACpE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7C;IAED,0DAA0D;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAEzC;IAED,+EAA+E;IAC/E,IAAI,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,CAEzB;CACF"}
|
package/dist/api/index.cjs
CHANGED
|
@@ -37,6 +37,8 @@ module.exports = __toCommonJS(api_exports);
|
|
|
37
37
|
var import_act = require("@rotorsoft/act");
|
|
38
38
|
var ERROR_MAP = {
|
|
39
39
|
ValidationError: { status: 422, code: "VALIDATION" },
|
|
40
|
+
PreconditionError: { status: 409, code: "PRECONDITION" },
|
|
41
|
+
/** @deprecated Thrown only by the deprecated `.given` rules. Removed in 2.0. */
|
|
40
42
|
InvariantError: { status: 409, code: "INVARIANT" },
|
|
41
43
|
ConcurrencyError: { status: 412, code: "CONCURRENCY" },
|
|
42
44
|
StreamClosedError: { status: 410, code: "STREAM_CLOSED" },
|
|
@@ -44,6 +46,7 @@ var ERROR_MAP = {
|
|
|
44
46
|
};
|
|
45
47
|
var lookup_known = (err) => {
|
|
46
48
|
if (err instanceof import_act.ValidationError) return { name: "ValidationError" };
|
|
49
|
+
if (err instanceof import_act.PreconditionError) return { name: "PreconditionError" };
|
|
47
50
|
if (err instanceof import_act.InvariantError) return { name: "InvariantError" };
|
|
48
51
|
if (err instanceof import_act.ConcurrencyError) return { name: "ConcurrencyError" };
|
|
49
52
|
if (err instanceof import_act.StreamClosedError) return { name: "StreamClosedError" };
|