@tsed/platform-response-filter 7.79.4 → 7.80.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/lib/types-esm/decorators/responseFilter.d.ts +7 -0
- package/lib/types-esm/domain/ResponseFiltersContainer.d.ts +14 -0
- package/lib/types-esm/errors/TemplateRenderError.d.ts +14 -0
- package/lib/types-esm/index.d.ts +10 -0
- package/lib/types-esm/interfaces/ResponseFilterMethods.d.ts +15 -0
- package/lib/types-esm/services/PlatformResponseFilter.d.ts +29 -0
- package/lib/types-esm/utils/getContentType.d.ts +6 -0
- package/lib/types-esm/utils/renderView.d.ts +2 -0
- package/package.json +24 -21
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -14
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -45
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ResponseFilterMethods } from "../interfaces/ResponseFilterMethods.js";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export type ResponseFilterKey = "*/*" | "application/json" | "text/html" | "plain/text" | string;
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export declare const ResponseFiltersContainer: Map<string, Type<ResponseFilterMethods<unknown>>>;
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerResponseFilter(type: ResponseFilterKey, token: Type<ResponseFilterMethods>): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { InternalServerError } from "@tsed/exceptions";
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export declare class TemplateRenderError extends InternalServerError {
|
|
7
|
+
name: string;
|
|
8
|
+
constructor(target: Type<any> | string, method: string | symbol, err: Error);
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
static buildMessage(target: Type<any> | string, method: string | symbol, err: Error): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by @tsed/barrels.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./decorators/responseFilter.js";
|
|
5
|
+
export * from "./domain/ResponseFiltersContainer.js";
|
|
6
|
+
export * from "./errors/TemplateRenderError.js";
|
|
7
|
+
export * from "./interfaces/ResponseFilterMethods.js";
|
|
8
|
+
export * from "./services/PlatformResponseFilter.js";
|
|
9
|
+
export * from "./utils/getContentType.js";
|
|
10
|
+
export * from "./utils/renderView.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { BaseContext } from "@tsed/di";
|
|
3
|
+
declare global {
|
|
4
|
+
namespace TsED {
|
|
5
|
+
interface Configuration {
|
|
6
|
+
/**
|
|
7
|
+
* A list of response filters must be called before returning a response to the consumer. See more on [Response filters](/docs/response-filter.md).
|
|
8
|
+
*/
|
|
9
|
+
responseFilters: Type<ResponseFilterMethods>[];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface ResponseFilterMethods<T = unknown> {
|
|
14
|
+
transform(data: T, ctx: BaseContext): any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { BaseContext, InjectorService } from "@tsed/di";
|
|
3
|
+
import { ResponseFilterKey } from "../domain/ResponseFiltersContainer.js";
|
|
4
|
+
import { ResponseFilterMethods } from "../interfaces/ResponseFilterMethods.js";
|
|
5
|
+
/**
|
|
6
|
+
* @platform
|
|
7
|
+
*/
|
|
8
|
+
export declare class PlatformResponseFilter {
|
|
9
|
+
protected types: Map<ResponseFilterKey, ResponseFilterMethods>;
|
|
10
|
+
protected injector: InjectorService;
|
|
11
|
+
protected responseFilters: Type<ResponseFilterMethods>[];
|
|
12
|
+
protected additionalProperties: boolean;
|
|
13
|
+
get contentTypes(): ResponseFilterKey[];
|
|
14
|
+
$onInit(): void;
|
|
15
|
+
getBestContentType(data: any, ctx: BaseContext): any;
|
|
16
|
+
/**
|
|
17
|
+
* Call filters to transform data
|
|
18
|
+
* @param data
|
|
19
|
+
* @param ctx
|
|
20
|
+
*/
|
|
21
|
+
transform(data: unknown, ctx: BaseContext): any;
|
|
22
|
+
/**
|
|
23
|
+
* Serialize data before calling filters
|
|
24
|
+
* @param data
|
|
25
|
+
* @param ctx
|
|
26
|
+
*/
|
|
27
|
+
serialize(data: unknown, ctx: BaseContext): Promise<unknown>;
|
|
28
|
+
private getIncludes;
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,44 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-response-filter",
|
|
3
|
-
"version": "7.79.4",
|
|
4
3
|
"description": "Platform response filter module for Ts.ED Framework",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"version": "7.80.1",
|
|
5
6
|
"source": "./src/index.ts",
|
|
6
7
|
"main": "./lib/cjs/index.js",
|
|
7
8
|
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./lib/types/index.d.ts",
|
|
13
|
+
"import": "./lib/esm/index.js",
|
|
14
|
+
"default": "./lib/cjs/index.js"
|
|
15
|
+
}
|
|
14
16
|
},
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "yarn barrels && yarn build:ts",
|
|
17
19
|
"barrels": "barrels",
|
|
18
|
-
"test": "
|
|
19
|
-
"build:ts": "tsc --build tsconfig.json
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"build:ts": "tsc --build tsconfig.json",
|
|
22
|
+
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"tslib": "2.6.1"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"@tsed/barrels": "7.
|
|
26
|
-
"@tsed/core": "7.
|
|
27
|
-
"@tsed/di": "7.
|
|
28
|
-
"@tsed/exceptions": "7.
|
|
29
|
-
"@tsed/json-mapper": "7.
|
|
30
|
-
"@tsed/schema": "7.
|
|
31
|
-
"@tsed/typescript": "7.
|
|
28
|
+
"@tsed/barrels": "7.80.1",
|
|
29
|
+
"@tsed/core": "7.80.1",
|
|
30
|
+
"@tsed/di": "7.80.1",
|
|
31
|
+
"@tsed/exceptions": "7.80.1",
|
|
32
|
+
"@tsed/json-mapper": "7.80.1",
|
|
33
|
+
"@tsed/schema": "7.80.1",
|
|
34
|
+
"@tsed/typescript": "7.80.1",
|
|
32
35
|
"eslint": "^8.57.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
36
|
+
"typescript": "4.9.5",
|
|
37
|
+
"vitest": "2.0.4"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|
|
37
|
-
"@tsed/core": "7.
|
|
38
|
-
"@tsed/di": "7.
|
|
39
|
-
"@tsed/exceptions": "7.
|
|
40
|
-
"@tsed/json-mapper": "7.
|
|
41
|
-
"@tsed/schema": "7.
|
|
40
|
+
"@tsed/core": "7.80.1",
|
|
41
|
+
"@tsed/di": "7.80.1",
|
|
42
|
+
"@tsed/exceptions": "7.80.1",
|
|
43
|
+
"@tsed/json-mapper": "7.80.1",
|
|
44
|
+
"@tsed/schema": "7.80.1"
|
|
42
45
|
},
|
|
43
46
|
"peerDependenciesMeta": {
|
|
44
47
|
"@tsed/core": {
|
|
@@ -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,14 +0,0 @@
|
|
|
1
|
-
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
-
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
...require("@tsed/jest-config"),
|
|
6
|
-
coverageThreshold: {
|
|
7
|
-
global: {
|
|
8
|
-
statements: 100,
|
|
9
|
-
branches: 97.72,
|
|
10
|
-
functions: 100,
|
|
11
|
-
lines: 100
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
package/lib/cjs/package.json
DELETED
package/lib/esm/package.json
DELETED
package/tsconfig.esm.json
DELETED
|
@@ -1,45 +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": "../../core"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"path": "../../di"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "../../specs/exceptions"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"path": "../../specs/json-mapper"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "../../specs/schema"
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|