@chaos-overlords/server 0.8.0 → 0.8.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.
|
@@ -32,5 +32,15 @@ export interface SseOptions {
|
|
|
32
32
|
* again; the log keeps the events in the meantime, which is the whole point of it being the truth.
|
|
33
33
|
*/
|
|
34
34
|
export declare function createSseResponse(source: EventStreamSource, options: SseOptions): Response;
|
|
35
|
+
/**
|
|
36
|
+
* One frame: the sequence number as its `id`, the contract's single event name, and the validated
|
|
37
|
+
* event as JSON.
|
|
38
|
+
*
|
|
39
|
+
* The name is the one the contract declares rather than the event's own `type`. A frame named after
|
|
40
|
+
* its type is a *named* event, which a stock `EventSource` delivers only to a listener registered
|
|
41
|
+
* for that exact name and never to `onmessage` — so the browser client the contract describes would
|
|
42
|
+
* hold an open stream and see nothing. Both of this repo's clients branch on the `type` inside the
|
|
43
|
+
* payload, which is unaffected.
|
|
44
|
+
*/
|
|
35
45
|
export declare function formatEvent(event: PersistedEvent): string;
|
|
36
46
|
//# sourceMappingURL=createSseResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSseResponse.d.ts","sourceRoot":"","sources":["../../src/sse/createSseResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSseResponse.d.ts","sourceRoot":"","sources":["../../src/sse/createSseResponse.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAG7D,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;IACtD;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;CAC3D;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,WAAW,CAAA;CACpB;AAaD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,GAAG,QAAQ,CA2H1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAIzD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { matchEventSchema, SSE_HEARTBEAT_COMMENT } from '@chaos-overlords/contracts';
|
|
1
|
+
import { MATCH_EVENT_SSE_NAME, matchEventSchema, SSE_HEARTBEAT_COMMENT, } from '@chaos-overlords/contracts';
|
|
2
2
|
import { validateSync } from '@toad-contracts/core';
|
|
3
3
|
const encoder = new TextEncoder();
|
|
4
4
|
/**
|
|
@@ -149,8 +149,19 @@ export function createSseResponse(source, options) {
|
|
|
149
149
|
},
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* One frame: the sequence number as its `id`, the contract's single event name, and the validated
|
|
154
|
+
* event as JSON.
|
|
155
|
+
*
|
|
156
|
+
* The name is the one the contract declares rather than the event's own `type`. A frame named after
|
|
157
|
+
* its type is a *named* event, which a stock `EventSource` delivers only to a listener registered
|
|
158
|
+
* for that exact name and never to `onmessage` — so the browser client the contract describes would
|
|
159
|
+
* hold an open stream and see nothing. Both of this repo's clients branch on the `type` inside the
|
|
160
|
+
* payload, which is unaffected.
|
|
161
|
+
*/
|
|
152
162
|
export function formatEvent(event) {
|
|
153
163
|
const validated = validateSync(matchEventSchema, event);
|
|
154
|
-
|
|
164
|
+
const data = JSON.stringify(validated);
|
|
165
|
+
return `id: ${validated.seq}\nevent: ${MATCH_EVENT_SSE_NAME}\ndata: ${data}\n\n`;
|
|
155
166
|
}
|
|
156
167
|
//# sourceMappingURL=createSseResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSseResponse.js","sourceRoot":"","sources":["../../src/sse/createSseResponse.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createSseResponse.js","sourceRoot":"","sources":["../../src/sse/createSseResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAqBnD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAEjC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAyB,EAAE,OAAmB;IAC9E,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAA;IAC9B,IAAI,QAAQ,GAAyB,IAAI,CAAA;IACzC,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB,IAAI,QAAQ,GAAe,GAAG,EAAE;QAC9B,MAAM,GAAG,IAAI,CAAA;IACf,CAAC,CAAA;IAED,kFAAkF;IAClF,IAAI,MAAM,GAAwB,IAAI,CAAA;IAEtC,MAAM,MAAM,GAAG,IAAI,cAAc,CAC/B;QACE,KAAK,CAAC,UAAU;YACd,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE;gBAC5B,IAAI,CAAC,MAAM;oBAAE,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;YACvD,CAAC,CAAA;YACD,gEAAgE;YAChE,MAAM,WAAW,GAAG,CAAC,UAAuD,EAAE,EAAE,CAC9E,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAC5B,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,CAAC;oBAAE,OAAO,OAAO,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AAI,CAAA;YACb,MAAM,EAAE,EAAE,CAAA;QACZ,CAAC;QACD,oFAAoF;QACpF,MAAM;YACJ,QAAQ,EAAE,CAAA;QACZ,CAAC;KACF,EACD,IAAI,oBAAoB,CAAC,EAAE,aAAa,EAAE,sBAAsB,EAAE,CAAC,CACpE,CAAA;IAED,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE;QAC1B,OAAO,EAAE;YACP,cAAc,EAAE,kCAAkC;YAClD,eAAe,EAAE,wBAAwB;YACzC,UAAU,EAAE,YAAY;YACxB,mBAAmB,EAAE,IAAI;SAC1B;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,KAAqB;IAC/C,MAAM,SAAS,GAAG,YAAY,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;IACtC,OAAO,OAAO,SAAS,CAAC,GAAG,YAAY,oBAAoB,WAAW,IAAI,MAAM,CAAA;AAClF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaos-overlords/server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "The Hono application both runtimes serve: REST intents, the SSE event stream, auth and the error envelope. Takes its ports through a container.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chaos-overlords",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"provenance": true
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@chaos-overlords/bug-reports": "0.8.
|
|
52
|
-
"@chaos-overlords/contracts": "0.8.
|
|
53
|
-
"@chaos-overlords/kernel": "0.8.
|
|
54
|
-
"@toad-contracts/core": "0.
|
|
55
|
-
"@toad-contracts/hono": "0.
|
|
51
|
+
"@chaos-overlords/bug-reports": "0.8.1",
|
|
52
|
+
"@chaos-overlords/contracts": "0.8.1",
|
|
53
|
+
"@chaos-overlords/kernel": "0.8.1",
|
|
54
|
+
"@toad-contracts/core": "1.0.0",
|
|
55
|
+
"@toad-contracts/hono": "1.0.0",
|
|
56
56
|
"hono": "^4.13.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@chaos-overlords/conformance": "0.8.
|
|
59
|
+
"@chaos-overlords/conformance": "0.8.1",
|
|
60
60
|
"typescript": "^5.9.3",
|
|
61
61
|
"vitest": "^4.1.11"
|
|
62
62
|
},
|