@jeffusion/bungee-types 5.14.1 → 5.15.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/sse-log.d.ts +1 -1
- package/dist/sse-log.js +4 -1
- package/package.json +1 -1
package/dist/sse-log.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export interface SSELogMessage {
|
|
|
3
3
|
data: unknown;
|
|
4
4
|
}
|
|
5
5
|
/** Format a log copy only. reserve accounts for additional parsing allocations. */
|
|
6
|
-
export declare function formatSSELog(body: unknown, contentType?: string, reserve?: (bytes: number) => void, requestAccept?: string): unknown;
|
|
6
|
+
export declare function formatSSELog(body: unknown, contentType?: string, reserve?: (bytes: number) => void, requestAccept?: string, parsedMessages?: SSELogMessage[]): unknown;
|
package/dist/sse-log.js
CHANGED
|
@@ -34,7 +34,7 @@ function isNegotiatedSSE(body, accept) {
|
|
|
34
34
|
return hasData;
|
|
35
35
|
}
|
|
36
36
|
/** Format a log copy only. reserve accounts for additional parsing allocations. */
|
|
37
|
-
export function formatSSELog(body, contentType = '', reserve, requestAccept = '') {
|
|
37
|
+
export function formatSSELog(body, contentType = '', reserve, requestAccept = '', parsedMessages) {
|
|
38
38
|
// Historical structured logs are projected on read, without rewriting their files.
|
|
39
39
|
if (body && typeof body === 'object' && !Array.isArray(body)
|
|
40
40
|
&& 'kind' in body && body.kind === 'sse_messages' && 'messages' in body && Array.isArray(body.messages)) {
|
|
@@ -52,6 +52,9 @@ export function formatSSELog(body, contentType = '', reserve, requestAccept = ''
|
|
|
52
52
|
if (!/^text\/event-stream(?:\s*;|$)/i.test(media)
|
|
53
53
|
&& (media || !isNegotiatedSSE(body, requestAccept)))
|
|
54
54
|
return body;
|
|
55
|
+
// A trusted gateway cache avoids parsing the same data again; classification above still wins.
|
|
56
|
+
if (parsedMessages !== undefined)
|
|
57
|
+
return parsedMessages;
|
|
55
58
|
const messages = [];
|
|
56
59
|
let event = '';
|
|
57
60
|
let data = [];
|