@standardserver/core 0.0.20 → 0.0.21
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/README.md +4 -4
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ Use Event-Stream Helpers when you need explicit SSE encoding, decoding, or metad
|
|
|
200
200
|
|
|
201
201
|
The event-stream entry point exposes:
|
|
202
202
|
|
|
203
|
-
- `
|
|
203
|
+
- `EventMeta` for `id`, `retry`, and `comments`
|
|
204
204
|
- `EventStreamMessage` for complete SSE messages
|
|
205
205
|
- `encodeEventStreamMessage()` and `decodeEventStreamMessage()` for single-message codec operations
|
|
206
206
|
- `EventStreamDecoder` and `EventStreamDecoderStream` for chunked stream decoding
|
|
@@ -277,13 +277,13 @@ The subpath also exports:
|
|
|
277
277
|
|
|
278
278
|
- `EventStreamEncoderError` for invalid outbound SSE messages
|
|
279
279
|
- `EventStreamDecoderError` for incomplete or invalid inbound stream decoding
|
|
280
|
-
- `
|
|
280
|
+
- `ErrorEvent` for wrapping structured event-stream error payloads in an `Error`
|
|
281
281
|
- `assertEventStreamMessageId()`, `assertEventStreamMessageName()`, `assertEventStreamMessageRetry()`, and `assertEventStreamMessageComment()` for low-level validation when building custom SSE tooling
|
|
282
282
|
|
|
283
283
|
```ts
|
|
284
|
-
import {
|
|
284
|
+
import { ErrorEvent } from '@standardserver/core'
|
|
285
285
|
|
|
286
|
-
const error = new
|
|
286
|
+
const error = new ErrorEvent(
|
|
287
287
|
{ code: 'E_STREAM', detail: 'Connection lost' },
|
|
288
288
|
{ message: 'stream error' },
|
|
289
289
|
)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface EventMeta {
|
|
2
2
|
/**
|
|
3
3
|
* Event identifier, sent back by the client as `lastEventId` for reconnection attempts.
|
|
4
4
|
*
|
|
@@ -16,7 +16,7 @@ interface EventStreamMessageMeta {
|
|
|
16
16
|
*/
|
|
17
17
|
comments?: string[] | undefined;
|
|
18
18
|
}
|
|
19
|
-
interface EventStreamMessage extends
|
|
19
|
+
interface EventStreamMessage extends EventMeta {
|
|
20
20
|
/**
|
|
21
21
|
* Event name (e.g., `message`, `error`).
|
|
22
22
|
*/
|
|
@@ -52,26 +52,26 @@ declare class EventStreamEncoderError extends TypeError {
|
|
|
52
52
|
}
|
|
53
53
|
declare class EventStreamDecoderError extends TypeError {
|
|
54
54
|
}
|
|
55
|
-
interface
|
|
55
|
+
interface ErrorEventOptions extends ErrorOptions {
|
|
56
56
|
message?: string;
|
|
57
57
|
}
|
|
58
|
-
declare class
|
|
59
|
-
|
|
60
|
-
constructor(data: unknown, options?:
|
|
58
|
+
declare class ErrorEvent extends Error {
|
|
59
|
+
data: unknown;
|
|
60
|
+
constructor(data: unknown, options?: ErrorEventOptions);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Returns a new iterator *event value* with attached, validated metadata.
|
|
65
65
|
*/
|
|
66
|
-
declare function withEventMeta<T extends object>(container: T, meta:
|
|
66
|
+
declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
|
67
67
|
/**
|
|
68
68
|
* Unwraps an iterator event value and extracts its associated metadata.
|
|
69
69
|
*/
|
|
70
|
-
declare function unwrapEvent<T>(container: T): [data: T, meta:
|
|
70
|
+
declare function unwrapEvent<T>(container: T): [data: T, meta: EventMeta | undefined];
|
|
71
71
|
/**
|
|
72
72
|
* Retrieves metadata attached to a single iterator event value.
|
|
73
73
|
*/
|
|
74
|
-
declare function getEventMeta(container: unknown):
|
|
74
|
+
declare function getEventMeta(container: unknown): EventMeta | undefined;
|
|
75
75
|
|
|
76
76
|
type StandardMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | (string & {});
|
|
77
77
|
type StandardUrl = `/${string}` | `/${string}?${string}` | `/${string}#${string}` | `/${string}?${string}#${string}`;
|
|
@@ -155,5 +155,5 @@ declare function isStandardHeaders(maybe: unknown): maybe is StandardHeaders;
|
|
|
155
155
|
declare function isStandardRequest(maybe: unknown): maybe is StandardRequest;
|
|
156
156
|
declare function isStandardResponse(maybe: unknown): maybe is StandardResponse;
|
|
157
157
|
|
|
158
|
-
export {
|
|
159
|
-
export type {
|
|
158
|
+
export { ErrorEvent, EventStreamDecoder, EventStreamDecoderError, EventStreamDecoderStream, EventStreamEncoderError, assertEventStreamMessageComment, assertEventStreamMessageId, assertEventStreamMessageName, assertEventStreamMessageRetry, decodeEventStreamMessage, encodeEventStreamMessage, encodeEventStreamMessageComments, encodeEventStreamMessageData, flattenStandardHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isStandardHeaders, isStandardMethod, isStandardRequest, isStandardResponse, isStandardUrl, mergeStandardHeaders, parseStandardUrl, unwrapEvent, withEventMeta };
|
|
159
|
+
export type { ErrorEventOptions, EventMeta, EventStreamMessage, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface EventMeta {
|
|
2
2
|
/**
|
|
3
3
|
* Event identifier, sent back by the client as `lastEventId` for reconnection attempts.
|
|
4
4
|
*
|
|
@@ -16,7 +16,7 @@ interface EventStreamMessageMeta {
|
|
|
16
16
|
*/
|
|
17
17
|
comments?: string[] | undefined;
|
|
18
18
|
}
|
|
19
|
-
interface EventStreamMessage extends
|
|
19
|
+
interface EventStreamMessage extends EventMeta {
|
|
20
20
|
/**
|
|
21
21
|
* Event name (e.g., `message`, `error`).
|
|
22
22
|
*/
|
|
@@ -52,26 +52,26 @@ declare class EventStreamEncoderError extends TypeError {
|
|
|
52
52
|
}
|
|
53
53
|
declare class EventStreamDecoderError extends TypeError {
|
|
54
54
|
}
|
|
55
|
-
interface
|
|
55
|
+
interface ErrorEventOptions extends ErrorOptions {
|
|
56
56
|
message?: string;
|
|
57
57
|
}
|
|
58
|
-
declare class
|
|
59
|
-
|
|
60
|
-
constructor(data: unknown, options?:
|
|
58
|
+
declare class ErrorEvent extends Error {
|
|
59
|
+
data: unknown;
|
|
60
|
+
constructor(data: unknown, options?: ErrorEventOptions);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Returns a new iterator *event value* with attached, validated metadata.
|
|
65
65
|
*/
|
|
66
|
-
declare function withEventMeta<T extends object>(container: T, meta:
|
|
66
|
+
declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
|
67
67
|
/**
|
|
68
68
|
* Unwraps an iterator event value and extracts its associated metadata.
|
|
69
69
|
*/
|
|
70
|
-
declare function unwrapEvent<T>(container: T): [data: T, meta:
|
|
70
|
+
declare function unwrapEvent<T>(container: T): [data: T, meta: EventMeta | undefined];
|
|
71
71
|
/**
|
|
72
72
|
* Retrieves metadata attached to a single iterator event value.
|
|
73
73
|
*/
|
|
74
|
-
declare function getEventMeta(container: unknown):
|
|
74
|
+
declare function getEventMeta(container: unknown): EventMeta | undefined;
|
|
75
75
|
|
|
76
76
|
type StandardMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | (string & {});
|
|
77
77
|
type StandardUrl = `/${string}` | `/${string}?${string}` | `/${string}#${string}` | `/${string}?${string}#${string}`;
|
|
@@ -155,5 +155,5 @@ declare function isStandardHeaders(maybe: unknown): maybe is StandardHeaders;
|
|
|
155
155
|
declare function isStandardRequest(maybe: unknown): maybe is StandardRequest;
|
|
156
156
|
declare function isStandardResponse(maybe: unknown): maybe is StandardResponse;
|
|
157
157
|
|
|
158
|
-
export {
|
|
159
|
-
export type {
|
|
158
|
+
export { ErrorEvent, EventStreamDecoder, EventStreamDecoderError, EventStreamDecoderStream, EventStreamEncoderError, assertEventStreamMessageComment, assertEventStreamMessageId, assertEventStreamMessageName, assertEventStreamMessageRetry, decodeEventStreamMessage, encodeEventStreamMessage, encodeEventStreamMessageComments, encodeEventStreamMessageData, flattenStandardHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isStandardHeaders, isStandardMethod, isStandardRequest, isStandardResponse, isStandardUrl, mergeStandardHeaders, parseStandardUrl, unwrapEvent, withEventMeta };
|
|
159
|
+
export type { ErrorEventOptions, EventMeta, EventStreamMessage, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl };
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ class EventStreamEncoderError extends TypeError {
|
|
|
4
4
|
}
|
|
5
5
|
class EventStreamDecoderError extends TypeError {
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class ErrorEvent extends Error {
|
|
8
8
|
constructor(data, options = {}) {
|
|
9
9
|
super(options?.message ?? "Error Event", options);
|
|
10
10
|
this.data = data;
|
|
@@ -292,4 +292,4 @@ function isStandardResponse(maybe) {
|
|
|
292
292
|
return isStandardHeaders(maybe.headers);
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
export {
|
|
295
|
+
export { ErrorEvent, EventStreamDecoder, EventStreamDecoderError, EventStreamDecoderStream, EventStreamEncoderError, assertEventStreamMessageComment, assertEventStreamMessageId, assertEventStreamMessageName, assertEventStreamMessageRetry, decodeEventStreamMessage, encodeEventStreamMessage, encodeEventStreamMessageComments, encodeEventStreamMessageData, flattenStandardHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isStandardHeaders, isStandardMethod, isStandardRequest, isStandardResponse, isStandardUrl, mergeStandardHeaders, parseStandardUrl, unwrapEvent, withEventMeta };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardserver/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.21",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://standardserver.dev",
|
|
7
7
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@standardserver/shared": "0.0.
|
|
25
|
+
"@standardserver/shared": "0.0.21"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "unbuild",
|