@tsed/sse 7.79.3 → 7.80.0

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.
@@ -1,7 +1,7 @@
1
1
  import { StoreSet, useDecorators } from "@tsed/core";
2
2
  import { Use } from "@tsed/platform-middlewares";
3
3
  import { Header, AcceptMime } from "@tsed/schema";
4
- import { EventStreamMiddleware } from "../middlewares/EventStreamMiddleware.js";
4
+ import { EventStreamMiddleware } from "../middlewares/EventStreamMiddleware";
5
5
  export function EventStream(opts = {}) {
6
6
  return useDecorators(StoreSet(EventStreamMiddleware, opts), Use(EventStreamMiddleware), AcceptMime("text/event-stream"), Header("Content-Type", "text/event-stream"));
7
7
  }
@@ -2,7 +2,7 @@ var EventStreamMiddleware_1;
2
2
  import { __decorate, __metadata, __param } from "tslib";
3
3
  import { Context, PlatformContext } from "@tsed/common";
4
4
  import { Middleware } from "@tsed/platform-middlewares";
5
- import { EventStreamContext } from "../domain/EventStreamContext.js";
5
+ import { EventStreamContext } from "../domain/EventStreamContext";
6
6
  let EventStreamMiddleware = EventStreamMiddleware_1 = class EventStreamMiddleware {
7
7
  use($ctx) {
8
8
  const opts = $ctx.endpoint.store.get(EventStreamMiddleware_1, {});
@@ -0,0 +1,5 @@
1
+ export interface EventStreamOpts {
2
+ headers?: Record<string, string>;
3
+ event?: string;
4
+ }
5
+ export declare function EventStream(opts?: EventStreamOpts): any;
@@ -0,0 +1,3 @@
1
+ import type { EventStreamContext } from "../domain/EventStreamContext";
2
+ export type EventStreamCtx = EventStreamContext;
3
+ export declare function EventStreamCtx(): ParameterDecorator;
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { PlatformContext } from "@tsed/common";
4
+ import type { EventEmitter } from "events";
5
+ import type { Observable } from "rxjs";
6
+ import type { EventStreamOpts } from "../decorators/eventStream";
7
+ export type EventStreamContextOptions = {
8
+ $ctx: PlatformContext;
9
+ } & EventStreamOpts;
10
+ export declare class EventStreamContext {
11
+ #private;
12
+ private $ctx;
13
+ private opts;
14
+ private responseFilter;
15
+ constructor({ $ctx, ...opts }: EventStreamContextOptions);
16
+ writeHead(headers?: Record<string, string>): void;
17
+ on(event: string, listener: (...args: any[]) => void): this;
18
+ subscribe(observable: Observable<unknown>): this;
19
+ stream(stream: NodeJS.ReadableStream | EventEmitter): void;
20
+ emit(event: string | undefined, data: unknown): this | undefined;
21
+ write(obj: Record<string, string>): void;
22
+ isDone(): boolean;
23
+ end(): void;
24
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "./decorators/eventStream.js";
5
+ export * from "./decorators/eventStreamCtx.js";
6
+ export * from "./domain/EventStreamContext.js";
7
+ export * from "./interceptors/EventStreamInterceptor.js";
8
+ export * from "./middlewares/EventStreamMiddleware.js";
@@ -0,0 +1,6 @@
1
+ import type { PlatformContext } from "@tsed/common";
2
+ import type { InterceptorContext, InterceptorMethods } from "@tsed/di";
3
+ export declare class EventStreamInterceptor implements InterceptorMethods {
4
+ protected $ctx: PlatformContext;
5
+ intercept(context: InterceptorContext): Promise<unknown>;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ export declare class EventStreamMiddleware {
3
+ use($ctx: PlatformContext): void;
4
+ }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@tsed/sse",
3
- "version": "7.79.3",
4
3
  "description": "Server-sent events package for Ts.ED framework",
4
+ "type": "commonjs",
5
+ "version": "7.80.0",
5
6
  "keywords": [
6
7
  "tsed",
7
8
  "server-sent events",
@@ -14,43 +15,45 @@
14
15
  "module": "./lib/esm/index.js",
15
16
  "typings": "./lib/types/index.d.ts",
16
17
  "exports": {
17
- "types": "./lib/types/index.d.ts",
18
- "import": "./lib/esm/index.js",
19
- "require": "./lib/cjs/index.js",
20
- "default": "./lib/esm/index.js"
18
+ ".": {
19
+ "types": "./lib/types/index.d.ts",
20
+ "import": "./lib/esm/index.js",
21
+ "default": "./lib/cjs/index.js"
22
+ }
21
23
  },
22
24
  "scripts": {
23
25
  "build": "yarn barrels && yarn build:ts",
24
26
  "barrels": "barrels",
25
27
  "start": "ts-node test/app/index.ts",
26
- "test": "jest --runInBand --testTimeout 10000 && jest-coverage-thresholds-bumper",
27
- "build:ts": "tsc --build tsconfig.json && tsc --build tsconfig.esm.json"
28
+ "test": "vitest run",
29
+ "build:ts": "tsc --build tsconfig.json",
30
+ "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
28
31
  },
29
32
  "dependencies": {
30
33
  "tslib": "2.6.1"
31
34
  },
32
35
  "devDependencies": {
33
- "@tsed/barrels": "7.79.3",
34
- "@tsed/common": "7.79.3",
35
- "@tsed/core": "7.79.3",
36
- "@tsed/di": "7.79.3",
37
- "@tsed/json-mapper": "7.79.3",
38
- "@tsed/openspec": "7.79.3",
39
- "@tsed/platform-middlewares": "7.79.3",
40
- "@tsed/schema": "7.79.3",
41
- "@tsed/socketio-testing": "7.79.3",
42
- "@tsed/typescript": "7.79.3",
36
+ "@tsed/barrels": "7.80.0",
37
+ "@tsed/common": "7.80.0",
38
+ "@tsed/core": "7.80.0",
39
+ "@tsed/di": "7.80.0",
40
+ "@tsed/json-mapper": "7.80.0",
41
+ "@tsed/openspec": "7.80.0",
42
+ "@tsed/platform-middlewares": "7.80.0",
43
+ "@tsed/schema": "7.80.0",
44
+ "@tsed/socketio-testing": "7.80.0",
45
+ "@tsed/typescript": "7.80.0",
43
46
  "eslint": "^8.57.0",
44
47
  "express": "^4.19.1",
45
- "jest": "^29.7.0",
46
- "typescript": "4.9.5"
48
+ "typescript": "4.9.5",
49
+ "vitest": "2.0.4"
47
50
  },
48
51
  "peerDependencies": {
49
- "@tsed/di": "7.79.3",
50
- "@tsed/json-mapper": "7.79.3",
52
+ "@tsed/di": "7.80.0",
53
+ "@tsed/json-mapper": "7.80.0",
51
54
  "@tsed/logger": ">=6.7.5",
52
- "@tsed/platform-middlewares": "7.79.3",
53
- "@tsed/schema": "7.79.3"
55
+ "@tsed/platform-middlewares": "7.80.0",
56
+ "@tsed/schema": "7.80.0"
54
57
  },
55
58
  "peerDependenciesMeta": {
56
59
  "@tsed/di": {
@@ -0,0 +1,21 @@
1
+ // @ts-ignore
2
+ import {presets} from "@tsed/vitest/presets";
3
+ import {defineConfig} from "vitest/config";
4
+
5
+ export default defineConfig(
6
+ {
7
+ ...presets,
8
+ test: {
9
+ ...presets.test,
10
+ coverage: {
11
+ ...presets.test.coverage,
12
+ thresholds: {
13
+ statements: 0,
14
+ branches: 0,
15
+ functions: 0,
16
+ lines: 0
17
+ }
18
+ }
19
+ }
20
+ }
21
+ );
package/jest.config.js DELETED
@@ -1,16 +0,0 @@
1
- // For a detailed explanation regarding each configuration property, visit:
2
- // https://jestjs.io/docs/en/configuration.html
3
- const config = require("@tsed/jest-config");
4
-
5
- module.exports = {
6
- ...config,
7
- roots: ["<rootDir>/src"],
8
- coverageThreshold: {
9
- global: {
10
- statements: 0,
11
- branches: 0,
12
- functions: 0,
13
- lines: 0
14
- }
15
- }
16
- };
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/tsconfig.esm.json DELETED
@@ -1,54 +0,0 @@
1
- {
2
- "extends": "@tsed/typescript/tsconfig.node.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "module": "ES2020",
6
- "rootDir": "src",
7
- "outDir": "./lib/esm",
8
- "declaration": true,
9
- "declarationDir": "./lib/types",
10
- "composite": true,
11
- "noEmit": false
12
- },
13
- "include": ["src", "src/**/*.json"],
14
- "exclude": [
15
- "node_modules",
16
- "test",
17
- "lib",
18
- "benchmark",
19
- "coverage",
20
- "spec",
21
- "**/*.benchmark.ts",
22
- "**/*.spec.ts",
23
- "keys",
24
- "jest.config.js",
25
- "**/__mock__/**",
26
- "webpack.config.js"
27
- ],
28
- "references": [
29
- {
30
- "path": "../../di"
31
- },
32
- {
33
- "path": "../../specs/json-mapper"
34
- },
35
- {
36
- "path": "../../platform/platform-middlewares"
37
- },
38
- {
39
- "path": "../../specs/schema"
40
- },
41
- {
42
- "path": "../../platform/common"
43
- },
44
- {
45
- "path": "../../core"
46
- },
47
- {
48
- "path": "../../specs/openspec"
49
- },
50
- {
51
- "path": "../socketio-testing"
52
- }
53
- ]
54
- }