@tsed/platform-response-filter 6.88.1 → 6.92.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.
Files changed (60) hide show
  1. package/lib/{decorators → cjs/decorators}/responseFilter.d.ts +0 -0
  2. package/lib/cjs/decorators/responseFilter.js +23 -0
  3. package/lib/cjs/decorators/responseFilter.js.map +1 -0
  4. package/lib/{domain → cjs/domain}/ResponseFiltersContainer.d.ts +0 -0
  5. package/lib/cjs/domain/ResponseFiltersContainer.js +16 -0
  6. package/lib/cjs/domain/ResponseFiltersContainer.js.map +1 -0
  7. package/lib/{errors → cjs/errors}/TemplateRenderError.d.ts +0 -0
  8. package/lib/cjs/errors/TemplateRenderError.js +23 -0
  9. package/lib/cjs/errors/TemplateRenderError.js.map +1 -0
  10. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  11. package/lib/cjs/index.js +16 -0
  12. package/lib/cjs/index.js.map +1 -0
  13. package/lib/{interfaces → cjs/interfaces}/ResponseFilterMethods.d.ts +0 -0
  14. package/lib/cjs/interfaces/ResponseFilterMethods.js +3 -0
  15. package/lib/cjs/interfaces/ResponseFilterMethods.js.map +1 -0
  16. package/lib/{services → cjs/services}/ConverterService.d.ts +0 -0
  17. package/lib/cjs/services/ConverterService.js +54 -0
  18. package/lib/cjs/services/ConverterService.js.map +1 -0
  19. package/lib/{services → cjs/services}/PlatformResponseFilter.d.ts +0 -0
  20. package/lib/cjs/services/PlatformResponseFilter.js +88 -0
  21. package/lib/cjs/services/PlatformResponseFilter.js.map +1 -0
  22. package/lib/{utils → cjs/utils}/getContentType.d.ts +0 -0
  23. package/lib/cjs/utils/getContentType.js +28 -0
  24. package/lib/cjs/utils/getContentType.js.map +1 -0
  25. package/lib/{utils → cjs/utils}/renderView.d.ts +0 -0
  26. package/lib/cjs/utils/renderView.js +17 -0
  27. package/lib/cjs/utils/renderView.js.map +1 -0
  28. package/lib/esm/decorators/responseFilter.js +19 -0
  29. package/lib/esm/decorators/responseFilter.js.map +1 -0
  30. package/lib/esm/domain/ResponseFiltersContainer.js +12 -0
  31. package/lib/esm/domain/ResponseFiltersContainer.js.map +1 -0
  32. package/lib/esm/errors/TemplateRenderError.js +19 -0
  33. package/lib/esm/errors/TemplateRenderError.js.map +1 -0
  34. package/lib/esm/index.js +13 -0
  35. package/lib/esm/index.js.map +1 -0
  36. package/lib/esm/interfaces/ResponseFilterMethods.js +2 -0
  37. package/lib/esm/interfaces/ResponseFilterMethods.js.map +1 -0
  38. package/lib/esm/services/ConverterService.js +51 -0
  39. package/lib/esm/services/ConverterService.js.map +1 -0
  40. package/lib/esm/services/PlatformResponseFilter.js +85 -0
  41. package/lib/esm/services/PlatformResponseFilter.js.map +1 -0
  42. package/lib/esm/utils/getContentType.js +24 -0
  43. package/lib/esm/utils/getContentType.js.map +1 -0
  44. package/lib/esm/utils/renderView.js +13 -0
  45. package/lib/esm/utils/renderView.js.map +1 -0
  46. package/lib/types/decorators/responseFilter.d.ts +7 -0
  47. package/lib/types/domain/ResponseFiltersContainer.d.ts +14 -0
  48. package/lib/types/errors/TemplateRenderError.d.ts +14 -0
  49. package/lib/types/index.d.ts +8 -0
  50. package/lib/types/interfaces/ResponseFilterMethods.d.ts +15 -0
  51. package/lib/types/services/ConverterService.d.ts +30 -0
  52. package/lib/types/services/PlatformResponseFilter.d.ts +27 -0
  53. package/lib/types/utils/getContentType.d.ts +6 -0
  54. package/lib/types/utils/renderView.d.ts +2 -0
  55. package/package.json +22 -18
  56. package/tsconfig.compile.esm.json +23 -0
  57. package/lib/index.js +0 -275
  58. package/lib/index.js.map +0 -1
  59. package/lib/index.modern.js +0 -269
  60. package/lib/index.modern.js.map +0 -1
@@ -1,269 +0,0 @@
1
- import { registerProvider, Injectable, Configuration, InjectorService, Inject, Constant } from '@tsed/di';
2
- import { nameOf, isObject, isSerializable } from '@tsed/core';
3
- import { InternalServerError } from '@tsed/exceptions';
4
- import { __decorate, __param, __metadata } from 'tslib';
5
- import { serialize, deserialize } from '@tsed/json-mapper';
6
-
7
- /**
8
- * @ignore
9
- */
10
- // tslint:disable-next-line:variable-name
11
- const ResponseFiltersContainer = new Map();
12
- /**
13
- * @ignore
14
- */
15
-
16
- function registerResponseFilter(type, token) {
17
- ResponseFiltersContainer.set(type, token);
18
- }
19
-
20
- /**
21
- * Register a response filter service.
22
- * @param contentTypes
23
- * @decorator
24
- */
25
-
26
- function ResponseFilter(...contentTypes) {
27
- return target => {
28
- contentTypes.forEach(contentType => {
29
- registerResponseFilter(contentType, target);
30
- });
31
- registerProvider({
32
- provide: target,
33
- useClass: target
34
- });
35
- };
36
- }
37
-
38
- /**
39
- * @private
40
- */
41
-
42
- class TemplateRenderError extends InternalServerError {
43
- constructor(target, method, err) {
44
- super(TemplateRenderError.buildMessage(target, method, err));
45
- this.name = "TEMPLATE_RENDER_ERROR";
46
- }
47
- /**
48
- *
49
- * @returns {string}
50
- */
51
-
52
-
53
- static buildMessage(target, method, err) {
54
- return `Template rendering error: ${nameOf(target)}.${String(method)}()\n` + err;
55
- }
56
-
57
- }
58
-
59
- function _extends() {
60
- _extends = Object.assign || function (target) {
61
- for (var i = 1; i < arguments.length; i++) {
62
- var source = arguments[i];
63
-
64
- for (var key in source) {
65
- if (Object.prototype.hasOwnProperty.call(source, key)) {
66
- target[key] = source[key];
67
- }
68
- }
69
- }
70
-
71
- return target;
72
- };
73
-
74
- return _extends.apply(this, arguments);
75
- }
76
-
77
- const ANY_CONTENT_TYPE = "*/*";
78
- /**
79
- * @ignore
80
- */
81
-
82
- function getContentType(data, ctx) {
83
- const {
84
- endpoint,
85
- response
86
- } = ctx;
87
- const {
88
- operation
89
- } = endpoint;
90
- const contentType = response.getContentType() || operation.getContentTypeOf(response.statusCode) || "";
91
-
92
- if (contentType && contentType !== ANY_CONTENT_TYPE) {
93
- if (contentType === "application/json") {
94
- if (isObject(data)) {
95
- return contentType;
96
- }
97
- } else {
98
- return contentType;
99
- }
100
- }
101
-
102
- if (typeof data === "string" && endpoint.view) {
103
- return "text/html";
104
- }
105
- }
106
-
107
- /**
108
- * @deprecated Since 2021-10-03. Use serialize/deserialize functions from @tsed/json-mapper instead
109
- */
110
-
111
- let ConverterService = class ConverterService {
112
- constructor(injectorService, configuration) {
113
- this.injectorService = injectorService;
114
- this._additionalProperties = configuration.get("converter.additionalProperties");
115
- }
116
- /**
117
- * Convert instance to plainObject.
118
- *
119
- * @param obj
120
- * @param options
121
- */
122
-
123
-
124
- serialize(obj, options = {}) {
125
- return serialize(obj, _extends({
126
- useAlias: true,
127
- additionalProperties: this._additionalProperties === "accept"
128
- }, options));
129
- }
130
- /**
131
- * Convert a plainObject to targetType.
132
- *
133
- * ### Options
134
- *
135
- * - `ignoreCallback`: callback called for each object which will be deserialized. The callback can return a boolean to avoid the default converter behavior.
136
- * - `checkRequiredValue`: Disable the required check condition.
137
- *
138
- * @param obj Object source that will be deserialized
139
- * @param options Mapping options
140
- * @returns {any}
141
- */
142
-
143
-
144
- deserialize(obj, options = {}) {
145
- return deserialize(obj, _extends({
146
- useAlias: true,
147
- additionalProperties: this._additionalProperties === "accept"
148
- }, options));
149
- }
150
-
151
- };
152
- ConverterService = __decorate([Injectable(), __param(1, Configuration()), __metadata("design:paramtypes", [InjectorService, Object])], ConverterService);
153
-
154
- async function renderView(data, $ctx) {
155
- const {
156
- response,
157
- endpoint
158
- } = $ctx;
159
-
160
- try {
161
- const {
162
- data: _data
163
- } = $ctx;
164
- const {
165
- path,
166
- options
167
- } = endpoint.view;
168
- return await response.render(path, _extends({}, options, _data, {
169
- $ctx
170
- }));
171
- } catch (err) {
172
- throw new TemplateRenderError(endpoint.targetName, endpoint.propertyKey, err);
173
- }
174
- }
175
-
176
- /**
177
- * @platform
178
- */
179
-
180
- let PlatformResponseFilter = class PlatformResponseFilter {
181
- constructor() {
182
- this.types = new Map();
183
- }
184
-
185
- get contentTypes() {
186
- return [...this.types.keys()];
187
- }
188
-
189
- $onInit() {
190
- ResponseFiltersContainer.forEach((token, type) => {
191
- if (this.responseFilters.includes(token)) {
192
- this.types.set(type, this.injector.get(token));
193
- }
194
- });
195
- }
196
-
197
- getBestContentType(data, ctx) {
198
- const contentType = getContentType(data, ctx);
199
-
200
- if (ctx.request.get("Accept")) {
201
- const bestContentType = ctx.request.accepts([contentType].concat(this.contentTypes).filter(Boolean));
202
-
203
- if (bestContentType) {
204
- return [].concat(bestContentType).filter(type => type !== "*/*")[0];
205
- }
206
- }
207
-
208
- return contentType;
209
- }
210
- /**
211
- * Call filters to transform data
212
- * @param data
213
- * @param ctx
214
- */
215
-
216
-
217
- async transform(data, ctx) {
218
- const {
219
- response
220
- } = ctx;
221
- const bestContentType = this.getBestContentType(data, ctx);
222
- bestContentType && response.contentType(bestContentType);
223
-
224
- if (this.types.has(bestContentType)) {
225
- return this.types.get(bestContentType).transform(data, ctx);
226
- }
227
-
228
- if (this.types.has(ANY_CONTENT_TYPE)) {
229
- return this.types.get(ANY_CONTENT_TYPE).transform(data, ctx);
230
- }
231
-
232
- return data;
233
- }
234
- /**
235
- * Serialize data before calling filters
236
- * @param data
237
- * @param ctx
238
- */
239
-
240
-
241
- async serialize(data, ctx) {
242
- const {
243
- response,
244
- endpoint
245
- } = ctx;
246
-
247
- if (endpoint) {
248
- if (endpoint.view) {
249
- data = await renderView(data, ctx);
250
- } else if (isSerializable(data)) {
251
- data = this.injector.get(ConverterService).serialize(data, _extends({}, endpoint.getResponseOptions(response.statusCode), {
252
- endpoint: true
253
- }));
254
- }
255
- }
256
-
257
- return data;
258
- }
259
-
260
- };
261
-
262
- __decorate([Inject(), __metadata("design:type", InjectorService)], PlatformResponseFilter.prototype, "injector", void 0);
263
-
264
- __decorate([Constant("responseFilters", []), __metadata("design:type", Array)], PlatformResponseFilter.prototype, "responseFilters", void 0);
265
-
266
- PlatformResponseFilter = __decorate([Injectable()], PlatformResponseFilter);
267
-
268
- export { ANY_CONTENT_TYPE, ConverterService, PlatformResponseFilter, ResponseFilter, ResponseFiltersContainer, TemplateRenderError, getContentType, registerResponseFilter, renderView };
269
- //# sourceMappingURL=index.modern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/domain/ResponseFiltersContainer.ts","../src/decorators/responseFilter.ts","../src/errors/TemplateRenderError.ts","../src/utils/getContentType.ts","../src/services/ConverterService.ts","../src/utils/renderView.ts","../src/services/PlatformResponseFilter.ts"],"sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ResponseFilterMethods} from \"../interfaces/ResponseFilterMethods\";\n/**\n * @ignore\n */\nexport type ResponseFilterKey = \"*/*\" | \"application/json\" | \"text/html\" | \"plain/text\" | string;\n/**\n * @ignore\n */\n// tslint:disable-next-line:variable-name\nexport const ResponseFiltersContainer = new Map<ResponseFilterKey, Type<ResponseFilterMethods>>();\n/**\n * @ignore\n */\nexport function registerResponseFilter(type: ResponseFilterKey, token: Type<ResponseFilterMethods>) {\n ResponseFiltersContainer.set(type, token);\n}\n","import {Type} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {registerResponseFilter, ResponseFilterKey} from \"../domain/ResponseFiltersContainer\";\n\n/**\n * Register a response filter service.\n * @param contentTypes\n * @decorator\n */\nexport function ResponseFilter(...contentTypes: ResponseFilterKey[]): ClassDecorator {\n return <T = any>(target: T): void | T => {\n contentTypes.forEach((contentType) => {\n registerResponseFilter(contentType, target as any);\n });\n registerProvider({\n provide: target,\n useClass: (target as unknown) as Type<any>\n });\n };\n}\n","import {nameOf, Type} from \"@tsed/core\";\nimport {InternalServerError} from \"@tsed/exceptions\";\n\n/**\n * @private\n */\nexport class TemplateRenderError extends InternalServerError {\n name = \"TEMPLATE_RENDER_ERROR\";\n\n constructor(target: Type<any> | string, method: string | symbol, err: Error) {\n super(TemplateRenderError.buildMessage(target, method, err));\n }\n\n /**\n *\n * @returns {string}\n */\n static buildMessage(target: Type<any> | string, method: string | symbol, err: Error) {\n return `Template rendering error: ${nameOf(target)}.${String(method)}()\\n` + err;\n }\n}\n","import {isObject} from \"@tsed/core\";\nimport type {BaseContext} from \"@tsed/di\";\nexport const ANY_CONTENT_TYPE = \"*/*\";\n/**\n * @ignore\n */\nexport function getContentType(data: any, ctx: BaseContext) {\n const {endpoint, response} = ctx;\n const {operation} = endpoint;\n\n const contentType = response.getContentType() || operation.getContentTypeOf(response.statusCode) || \"\";\n\n if (contentType && contentType !== ANY_CONTENT_TYPE) {\n if (contentType === \"application/json\") {\n if (isObject(data)) {\n return contentType;\n }\n } else {\n return contentType;\n }\n }\n\n if (typeof data === \"string\" && endpoint.view) {\n return \"text/html\";\n }\n}\n","import {Configuration, Injectable, InjectorService} from \"@tsed/di\";\nimport {deserialize, JsonDeserializerOptions, JsonSerializerOptions, serialize} from \"@tsed/json-mapper\";\n\n/**\n * @deprecated Since 2021-10-03. Use serialize/deserialize functions from @tsed/json-mapper instead\n */\n@Injectable()\nexport class ConverterService {\n private readonly _additionalProperties: string;\n\n constructor(private injectorService: InjectorService, @Configuration() configuration: Configuration) {\n this._additionalProperties = configuration.get<string>(\"converter.additionalProperties\");\n }\n\n /**\n * Convert instance to plainObject.\n *\n * @param obj\n * @param options\n */\n serialize(obj: any, options: JsonSerializerOptions = {}): any {\n return serialize(obj, {\n useAlias: true,\n additionalProperties: this._additionalProperties === \"accept\",\n ...options\n });\n }\n\n /**\n * Convert a plainObject to targetType.\n *\n * ### Options\n *\n * - `ignoreCallback`: callback called for each object which will be deserialized. The callback can return a boolean to avoid the default converter behavior.\n * - `checkRequiredValue`: Disable the required check condition.\n *\n * @param obj Object source that will be deserialized\n * @param options Mapping options\n * @returns {any}\n */\n deserialize(obj: any, options: JsonDeserializerOptions = {}): any {\n return deserialize(obj, {\n useAlias: true,\n additionalProperties: this._additionalProperties === \"accept\",\n ...options\n });\n }\n}\n","import {BaseContext} from \"@tsed/di\";\nimport {TemplateRenderError} from \"../errors/TemplateRenderError\";\n\nexport async function renderView(data: any, $ctx: BaseContext) {\n const {response, endpoint} = $ctx;\n try {\n const {data} = $ctx;\n const {path, options} = endpoint.view;\n\n return await response.render(path, {...options, ...data, $ctx});\n } catch (err) {\n throw new TemplateRenderError(endpoint.targetName, endpoint.propertyKey, err);\n }\n}\n","import {isSerializable, Type} from \"@tsed/core\";\nimport {BaseContext, Constant, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {ResponseFilterKey, ResponseFiltersContainer} from \"../domain/ResponseFiltersContainer\";\nimport {ResponseFilterMethods} from \"../interfaces/ResponseFilterMethods\";\nimport {ANY_CONTENT_TYPE, getContentType} from \"../utils/getContentType\";\nimport {ConverterService} from \"./ConverterService\";\nimport {renderView} from \"../utils/renderView\";\n\n/**\n * @platform\n */\n@Injectable()\nexport class PlatformResponseFilter {\n types: Map<ResponseFilterKey, ResponseFilterMethods> = new Map();\n\n @Inject()\n injector: InjectorService;\n\n @Constant(\"responseFilters\", [])\n protected responseFilters: Type<ResponseFilterMethods>[];\n\n get contentTypes(): ResponseFilterKey[] {\n return [...this.types.keys()];\n }\n\n $onInit() {\n ResponseFiltersContainer.forEach((token, type) => {\n if (this.responseFilters.includes(token)) {\n this.types.set(type, this.injector.get(token)!);\n }\n });\n }\n\n getBestContentType(data: any, ctx: BaseContext) {\n const contentType = getContentType(data, ctx);\n\n if (ctx.request.get(\"Accept\")) {\n const bestContentType = ctx.request.accepts([contentType].concat(this.contentTypes).filter(Boolean));\n\n if (bestContentType) {\n return [].concat(bestContentType as any).filter((type) => type !== \"*/*\")[0];\n }\n }\n\n return contentType;\n }\n /**\n * Call filters to transform data\n * @param data\n * @param ctx\n */\n async transform(data: unknown, ctx: BaseContext) {\n const {response} = ctx;\n const bestContentType = this.getBestContentType(data, ctx);\n\n bestContentType && response.contentType(bestContentType);\n\n if (this.types.has(bestContentType)) {\n return this.types.get(bestContentType)!.transform(data, ctx);\n }\n\n if (this.types.has(ANY_CONTENT_TYPE)) {\n return this.types.get(ANY_CONTENT_TYPE)!.transform(data, ctx);\n }\n\n return data;\n }\n /**\n * Serialize data before calling filters\n * @param data\n * @param ctx\n */\n async serialize(data: unknown, ctx: BaseContext) {\n const {response, endpoint} = ctx;\n\n if (endpoint) {\n if (endpoint.view) {\n data = await renderView(data, ctx);\n } else if (isSerializable(data)) {\n data = this.injector.get<ConverterService>(ConverterService)!.serialize(data, {\n ...endpoint.getResponseOptions(response.statusCode),\n endpoint: true\n });\n }\n }\n\n return data;\n }\n}\n"],"names":["ResponseFiltersContainer","Map","registerResponseFilter","type","token","set","ResponseFilter","contentTypes","target","forEach","contentType","registerProvider","provide","useClass","TemplateRenderError","InternalServerError","constructor","method","err","buildMessage","nameOf","String","ANY_CONTENT_TYPE","getContentType","data","ctx","endpoint","response","operation","getContentTypeOf","statusCode","isObject","view","ConverterService","injectorService","configuration","_additionalProperties","get","serialize","obj","options","useAlias","additionalProperties","deserialize","Injectable","__param","Configuration","InjectorService","renderView","$ctx","path","render","targetName","propertyKey","PlatformResponseFilter","types","keys","$onInit","responseFilters","includes","injector","getBestContentType","request","bestContentType","accepts","concat","filter","Boolean","transform","has","isSerializable","getResponseOptions","__decorate","Inject","Constant"],"mappings":";;;;;;AAMA;;;AAGA;MACaA,wBAAwB,GAAG,IAAIC,GAAJ;AACxC;;;;SAGgBC,uBAAuBC,MAAyBC;AAC9DJ,EAAAA,wBAAwB,CAACK,GAAzB,CAA6BF,IAA7B,EAAmCC,KAAnC;AACD;;ACZD;;;;;;SAKgBE,eAAe,GAAGC;AAChC,SAAiBC,MAAV;AACLD,IAAAA,YAAY,CAACE,OAAb,CAAsBC,WAAD;AACnBR,MAAAA,sBAAsB,CAACQ,WAAD,EAAcF,MAAd,CAAtB;AACD,KAFD;AAGAG,IAAAA,gBAAgB,CAAC;AACfC,MAAAA,OAAO,EAAEJ,MADM;AAEfK,MAAAA,QAAQ,EAAGL;AAFI,KAAD,CAAhB;AAID,GARD;AASD;;AChBD;;;;MAGaM,4BAA4BC;AAGvCC,EAAAA,YAAYR,QAA4BS,QAAyBC;AAC/D,UAAMJ,mBAAmB,CAACK,YAApB,CAAiCX,MAAjC,EAAyCS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