@enonic-types/core 8.0.0 → 8.0.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.
Files changed (2) hide show
  1. package/index.d.ts +47 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -358,6 +358,8 @@ export interface MappedResponse {
358
358
  export interface ResponseInterface
359
359
  extends Partial<MappedResponse> {
360
360
  redirect?: string;
361
+ webSocket?: WebSocketResponse;
362
+ sse?: SseResponse;
361
363
  }
362
364
 
363
365
  export interface DefaultResponse
@@ -384,6 +386,31 @@ export type HttpFilterNext<
384
386
  ResponseToJava extends ResponseInterface = DefaultResponse
385
387
  > = (request: RequestToJava) => ResponseToJava;
386
388
 
389
+ export interface WebSocketResponse {
390
+ data?: Record<string, string>;
391
+ subProtocols?: string | string[];
392
+ checkOrigin?: (origin: string) => boolean;
393
+
394
+ /**
395
+ * When `true` (default), the WebSocket is closed with code 1008 when its HTTP session ends — either
396
+ * through logout (invalidation) or idle-timeout expiry. Set to `false` to let the socket outlive the
397
+ * session.
398
+ */
399
+ terminateOnSessionExit?: boolean;
400
+
401
+ /**
402
+ * When `true`, inbound WebSocket messages refresh (access) the HTTP session, keeping it alive.
403
+ * Server-to-client messages never count. Defaults to `false`.
404
+ */
405
+ sessionAccess?: boolean;
406
+
407
+ /**
408
+ * Minimum interval, in milliseconds, between session refreshes when `sessionAccess` is enabled.
409
+ * Defaults to 60000.
410
+ */
411
+ sessionAccessThrottleMs?: number;
412
+ }
413
+
387
414
  export interface WebSocketSession {
388
415
  id: string;
389
416
  params: Record<string, string | string[]>;
@@ -404,6 +431,26 @@ export interface WebSocketEvent<T> {
404
431
 
405
432
  type WebSocketEventHandler<T = Record<string, unknown>> = (event: WebSocketEvent<T>) => void;
406
433
 
434
+ export interface SseResponse<T = Record<string, unknown>> {
435
+ /**
436
+ * Per-connection state, exposed (unchanged) on every {@link SseEvent} fired for this connection. Lets an
437
+ * `sseEvent` handler share setup-time state between the `open` event and the later `close` / `timeout` /
438
+ * `error` events. Defaults to an empty object.
439
+ */
440
+ attributes?: T;
441
+
442
+ /**
443
+ * Client reconnection hint in milliseconds, sent to the browser as the initial `retry:` field. A negative
444
+ * value (the default) is not sent, leaving the client to use its own default.
445
+ */
446
+ retry?: number;
447
+
448
+ /**
449
+ * Async context timeout in milliseconds. A value of zero or less (the default) means no timeout.
450
+ */
451
+ timeout?: number;
452
+ }
453
+
407
454
  export type SseEventType = 'open' | 'close' | 'timeout' | 'error';
408
455
 
409
456
  export interface SseEvent<T = Record<string, unknown>> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/core",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Shared type definition for core libraries.",
5
5
  "types": "index.d.ts",
6
6
  "files": [