@celljs/web 4.1.0 → 4.2.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 (262) hide show
  1. package/README.md +39 -1
  2. package/cell.yml +0 -3
  3. package/esm/browser/module.d.ts +1 -1
  4. package/esm/common/module.d.ts +1 -1
  5. package/esm/common/pipe/index.d.ts +1 -1
  6. package/esm/common/pipe/index.js +1 -1
  7. package/esm/common/pipe/index.js.map +1 -1
  8. package/esm/common/pipe/type-conversion-pipe.d.ts +12 -0
  9. package/esm/common/pipe/type-conversion-pipe.js +43 -0
  10. package/esm/common/pipe/type-conversion-pipe.js.map +1 -0
  11. package/esm/common/pipe/validation-errors.d.ts +11 -2
  12. package/esm/common/pipe/validation-errors.js +2 -0
  13. package/esm/common/pipe/validation-errors.js.map +1 -1
  14. package/esm/node/body/body-middleware.d.ts +4 -6
  15. package/esm/node/body/body-middleware.js +6 -16
  16. package/esm/node/body/body-middleware.js.map +1 -1
  17. package/esm/node/body/body-parser.d.ts +32 -0
  18. package/esm/node/body/body-parser.js +205 -0
  19. package/esm/node/body/body-parser.js.map +1 -0
  20. package/esm/node/body/body-protocol.d.ts +15 -0
  21. package/esm/node/body/form-util.d.ts +15 -0
  22. package/esm/node/body/form-util.js +120 -0
  23. package/esm/node/body/form-util.js.map +1 -0
  24. package/esm/node/body/index.d.ts +2 -0
  25. package/esm/node/body/index.js +2 -0
  26. package/esm/node/body/index.js.map +1 -1
  27. package/esm/node/cookies/cookies-factory.js +2 -6
  28. package/esm/node/cookies/cookies-factory.js.map +1 -1
  29. package/esm/node/cookies/cookies-protocol.d.ts +25 -2
  30. package/esm/node/cookies/cookies.d.ts +17 -0
  31. package/esm/node/cookies/cookies.js +137 -0
  32. package/esm/node/cookies/cookies.js.map +1 -0
  33. package/esm/node/cookies/index.d.ts +1 -0
  34. package/esm/node/cookies/index.js +1 -0
  35. package/esm/node/cookies/index.js.map +1 -1
  36. package/esm/node/cors/cors-middleware.d.ts +11 -3
  37. package/esm/node/cors/cors-middleware.js +108 -14
  38. package/esm/node/cors/cors-middleware.js.map +1 -1
  39. package/esm/node/cors/cors-protocol.d.ts +23 -0
  40. package/esm/node/error/error-handler-provider.js +3 -7
  41. package/esm/node/error/error-handler-provider.js.map +1 -1
  42. package/esm/node/health/health-middleware.js +1 -1
  43. package/esm/node/health/health-middleware.js.map +1 -1
  44. package/esm/node/http/http-protocol.d.ts +29 -5
  45. package/esm/node/http/http-protocol.js.map +1 -1
  46. package/esm/node/http/http-request.d.ts +41 -0
  47. package/esm/node/http/http-request.js +106 -0
  48. package/esm/node/http/http-request.js.map +1 -0
  49. package/esm/node/http/index.d.ts +1 -0
  50. package/esm/node/http/index.js +1 -0
  51. package/esm/node/http/index.js.map +1 -1
  52. package/esm/node/index.d.ts +1 -0
  53. package/esm/node/index.js +1 -0
  54. package/esm/node/index.js.map +1 -1
  55. package/esm/node/matcher/index.d.ts +1 -0
  56. package/esm/node/matcher/index.js +1 -0
  57. package/esm/node/matcher/index.js.map +1 -1
  58. package/esm/node/matcher/path-pattern.d.ts +23 -0
  59. package/esm/node/matcher/path-pattern.js +115 -0
  60. package/esm/node/matcher/path-pattern.js.map +1 -0
  61. package/esm/node/matcher/request-matcher.d.ts +2 -2
  62. package/esm/node/matcher/request-matcher.js +8 -9
  63. package/esm/node/matcher/request-matcher.js.map +1 -1
  64. package/esm/node/module.d.ts +1 -1
  65. package/esm/node/server/http-server.d.ts +13 -0
  66. package/esm/node/server/http-server.js +32 -0
  67. package/esm/node/server/http-server.js.map +1 -0
  68. package/esm/node/server/index.d.ts +1 -0
  69. package/esm/node/server/index.js +2 -0
  70. package/esm/node/server/index.js.map +1 -0
  71. package/esm/node/session/session-manager.js +1 -2
  72. package/esm/node/session/session-manager.js.map +1 -1
  73. package/esm/node/session/session-store.js +1 -2
  74. package/esm/node/session/session-store.js.map +1 -1
  75. package/esm/node/session/session.d.ts +3 -2
  76. package/esm/node/session/session.js +4 -10
  77. package/esm/node/session/session.js.map +1 -1
  78. package/lib/browser/module.d.ts +1 -1
  79. package/lib/common/module.d.ts +1 -1
  80. package/lib/common/pipe/index.d.ts +1 -1
  81. package/lib/common/pipe/index.d.ts.map +1 -1
  82. package/lib/common/pipe/index.js +1 -1
  83. package/lib/common/pipe/index.js.map +1 -1
  84. package/lib/common/pipe/type-conversion-pipe.d.ts +13 -0
  85. package/lib/common/pipe/type-conversion-pipe.d.ts.map +1 -0
  86. package/lib/common/pipe/type-conversion-pipe.js +46 -0
  87. package/lib/common/pipe/type-conversion-pipe.js.map +1 -0
  88. package/lib/common/pipe/type-conversion-pipe.spec.d.ts +2 -0
  89. package/lib/common/pipe/type-conversion-pipe.spec.d.ts.map +1 -0
  90. package/lib/common/pipe/type-conversion-pipe.spec.js +36 -0
  91. package/lib/common/pipe/type-conversion-pipe.spec.js.map +1 -0
  92. package/lib/common/pipe/validation-errors.d.ts +11 -2
  93. package/lib/common/pipe/validation-errors.d.ts.map +1 -1
  94. package/lib/common/pipe/validation-errors.js +2 -0
  95. package/lib/common/pipe/validation-errors.js.map +1 -1
  96. package/lib/node/body/body-middleware.d.ts +4 -6
  97. package/lib/node/body/body-middleware.d.ts.map +1 -1
  98. package/lib/node/body/body-middleware.js +4 -13
  99. package/lib/node/body/body-middleware.js.map +1 -1
  100. package/lib/node/body/body-middleware.spec.js +78 -12
  101. package/lib/node/body/body-middleware.spec.js.map +1 -1
  102. package/lib/node/body/body-parser.d.ts +33 -0
  103. package/lib/node/body/body-parser.d.ts.map +1 -0
  104. package/lib/node/body/body-parser.js +210 -0
  105. package/lib/node/body/body-parser.js.map +1 -0
  106. package/lib/node/body/body-protocol.d.ts +15 -0
  107. package/lib/node/body/body-protocol.d.ts.map +1 -1
  108. package/lib/node/body/form-util.d.ts +16 -0
  109. package/lib/node/body/form-util.d.ts.map +1 -0
  110. package/lib/node/body/form-util.js +123 -0
  111. package/lib/node/body/form-util.js.map +1 -0
  112. package/lib/node/body/form-util.spec.d.ts +2 -0
  113. package/lib/node/body/form-util.spec.d.ts.map +1 -0
  114. package/lib/node/body/form-util.spec.js +44 -0
  115. package/lib/node/body/form-util.spec.js.map +1 -0
  116. package/lib/node/body/index.d.ts +2 -0
  117. package/lib/node/body/index.d.ts.map +1 -1
  118. package/lib/node/body/index.js +2 -0
  119. package/lib/node/body/index.js.map +1 -1
  120. package/lib/node/cookies/cookies-factory.d.ts.map +1 -1
  121. package/lib/node/cookies/cookies-factory.js +2 -9
  122. package/lib/node/cookies/cookies-factory.js.map +1 -1
  123. package/lib/node/cookies/cookies-protocol.d.ts +25 -2
  124. package/lib/node/cookies/cookies-protocol.d.ts.map +1 -1
  125. package/lib/node/cookies/cookies.d.ts +18 -0
  126. package/lib/node/cookies/cookies.d.ts.map +1 -0
  127. package/lib/node/cookies/cookies.js +141 -0
  128. package/lib/node/cookies/cookies.js.map +1 -0
  129. package/lib/node/cookies/cookies.spec.d.ts +2 -0
  130. package/lib/node/cookies/cookies.spec.d.ts.map +1 -0
  131. package/lib/node/cookies/cookies.spec.js +73 -0
  132. package/lib/node/cookies/cookies.spec.js.map +1 -0
  133. package/lib/node/cookies/index.d.ts +1 -0
  134. package/lib/node/cookies/index.d.ts.map +1 -1
  135. package/lib/node/cookies/index.js +1 -0
  136. package/lib/node/cookies/index.js.map +1 -1
  137. package/lib/node/cors/cors-middleware.d.ts +11 -3
  138. package/lib/node/cors/cors-middleware.d.ts.map +1 -1
  139. package/lib/node/cors/cors-middleware.js +106 -15
  140. package/lib/node/cors/cors-middleware.js.map +1 -1
  141. package/lib/node/cors/cors-middleware.spec.d.ts +2 -0
  142. package/lib/node/cors/cors-middleware.spec.d.ts.map +1 -0
  143. package/lib/node/cors/cors-middleware.spec.js +56 -0
  144. package/lib/node/cors/cors-middleware.spec.js.map +1 -0
  145. package/lib/node/cors/cors-protocol.d.ts +23 -0
  146. package/lib/node/cors/cors-protocol.d.ts.map +1 -1
  147. package/lib/node/error/error-handler-provider.d.ts.map +1 -1
  148. package/lib/node/error/error-handler-provider.js +2 -5
  149. package/lib/node/error/error-handler-provider.js.map +1 -1
  150. package/lib/node/health/health-middleware.js +1 -1
  151. package/lib/node/health/health-middleware.js.map +1 -1
  152. package/lib/node/http/http-protocol.d.ts +29 -5
  153. package/lib/node/http/http-protocol.d.ts.map +1 -1
  154. package/lib/node/http/http-protocol.js.map +1 -1
  155. package/lib/node/http/http-request.d.ts +42 -0
  156. package/lib/node/http/http-request.d.ts.map +1 -0
  157. package/lib/node/http/http-request.js +110 -0
  158. package/lib/node/http/http-request.js.map +1 -0
  159. package/lib/node/http/http-request.spec.d.ts +2 -0
  160. package/lib/node/http/http-request.spec.d.ts.map +1 -0
  161. package/lib/node/http/http-request.spec.js +65 -0
  162. package/lib/node/http/http-request.spec.js.map +1 -0
  163. package/lib/node/http/index.d.ts +1 -0
  164. package/lib/node/http/index.d.ts.map +1 -1
  165. package/lib/node/http/index.js +1 -0
  166. package/lib/node/http/index.js.map +1 -1
  167. package/lib/node/index.d.ts +1 -0
  168. package/lib/node/index.d.ts.map +1 -1
  169. package/lib/node/index.js +1 -0
  170. package/lib/node/index.js.map +1 -1
  171. package/lib/node/matcher/index.d.ts +1 -0
  172. package/lib/node/matcher/index.d.ts.map +1 -1
  173. package/lib/node/matcher/index.js +1 -0
  174. package/lib/node/matcher/index.js.map +1 -1
  175. package/lib/node/matcher/path-pattern.d.ts +24 -0
  176. package/lib/node/matcher/path-pattern.d.ts.map +1 -0
  177. package/lib/node/matcher/path-pattern.js +119 -0
  178. package/lib/node/matcher/path-pattern.js.map +1 -0
  179. package/lib/node/matcher/path-pattern.spec.d.ts +2 -0
  180. package/lib/node/matcher/path-pattern.spec.d.ts.map +1 -0
  181. package/lib/node/matcher/path-pattern.spec.js +43 -0
  182. package/lib/node/matcher/path-pattern.spec.js.map +1 -0
  183. package/lib/node/matcher/request-matcher.d.ts +2 -2
  184. package/lib/node/matcher/request-matcher.d.ts.map +1 -1
  185. package/lib/node/matcher/request-matcher.js +8 -12
  186. package/lib/node/matcher/request-matcher.js.map +1 -1
  187. package/lib/node/module.d.ts +1 -1
  188. package/lib/node/server/http-server.d.ts +14 -0
  189. package/lib/node/server/http-server.d.ts.map +1 -0
  190. package/lib/node/server/http-server.js +35 -0
  191. package/lib/node/server/http-server.js.map +1 -0
  192. package/lib/node/server/http-server.spec.d.ts +2 -0
  193. package/lib/node/server/http-server.spec.d.ts.map +1 -0
  194. package/lib/node/server/http-server.spec.js +41 -0
  195. package/lib/node/server/http-server.spec.js.map +1 -0
  196. package/lib/node/server/index.d.ts +2 -0
  197. package/lib/node/server/index.d.ts.map +1 -0
  198. package/lib/node/server/index.js +18 -0
  199. package/lib/node/server/index.js.map +1 -0
  200. package/lib/node/session/session-manager.d.ts.map +1 -1
  201. package/lib/node/session/session-manager.js +1 -2
  202. package/lib/node/session/session-manager.js.map +1 -1
  203. package/lib/node/session/session-store.d.ts.map +1 -1
  204. package/lib/node/session/session-store.js +1 -2
  205. package/lib/node/session/session-store.js.map +1 -1
  206. package/lib/node/session/session.d.ts +3 -2
  207. package/lib/node/session/session.d.ts.map +1 -1
  208. package/lib/node/session/session.js +4 -43
  209. package/lib/node/session/session.js.map +1 -1
  210. package/lib/node/session/session.spec.js +7 -1
  211. package/lib/node/session/session.spec.js.map +1 -1
  212. package/package.json +10 -15
  213. package/src/common/pipe/index.ts +1 -1
  214. package/src/common/pipe/type-conversion-pipe.spec.ts +38 -0
  215. package/src/common/pipe/type-conversion-pipe.ts +36 -0
  216. package/src/common/pipe/validation-errors.ts +11 -2
  217. package/src/node/body/body-middleware.spec.ts +93 -14
  218. package/src/node/body/body-middleware.ts +9 -18
  219. package/src/node/body/body-parser.ts +216 -0
  220. package/src/node/body/body-protocol.ts +15 -0
  221. package/src/node/body/form-util.spec.ts +45 -0
  222. package/src/node/body/form-util.ts +132 -0
  223. package/src/node/body/index.ts +2 -0
  224. package/src/node/cookies/cookies-factory.ts +2 -6
  225. package/src/node/cookies/cookies-protocol.ts +28 -3
  226. package/src/node/cookies/cookies.spec.ts +80 -0
  227. package/src/node/cookies/cookies.ts +138 -0
  228. package/src/node/cookies/index.ts +1 -0
  229. package/src/node/cors/cors-middleware.spec.ts +59 -0
  230. package/src/node/cors/cors-middleware.ts +112 -15
  231. package/src/node/cors/cors-protocol.ts +25 -0
  232. package/src/node/error/error-handler-provider.ts +1 -2
  233. package/src/node/health/health-middleware.ts +1 -1
  234. package/src/node/http/http-protocol.ts +29 -5
  235. package/src/node/http/http-request.spec.ts +68 -0
  236. package/src/node/http/http-request.ts +132 -0
  237. package/src/node/http/index.ts +1 -0
  238. package/src/node/index.ts +1 -0
  239. package/src/node/matcher/index.ts +1 -0
  240. package/src/node/matcher/path-pattern.spec.ts +43 -0
  241. package/src/node/matcher/path-pattern.ts +113 -0
  242. package/src/node/matcher/request-matcher.ts +9 -10
  243. package/src/node/server/http-server.spec.ts +45 -0
  244. package/src/node/server/http-server.ts +35 -0
  245. package/src/node/server/index.ts +1 -0
  246. package/src/node/session/session-manager.ts +1 -2
  247. package/src/node/session/session-store.ts +1 -2
  248. package/src/node/session/session.spec.ts +8 -1
  249. package/src/node/session/session.ts +6 -12
  250. package/esm/common/pipe/pipe-transtorm.d.ts +0 -17
  251. package/esm/common/pipe/pipe-transtorm.js +0 -110
  252. package/esm/common/pipe/pipe-transtorm.js.map +0 -1
  253. package/lib/common/pipe/pipe-transtorm.d.ts +0 -18
  254. package/lib/common/pipe/pipe-transtorm.d.ts.map +0 -1
  255. package/lib/common/pipe/pipe-transtorm.js +0 -113
  256. package/lib/common/pipe/pipe-transtorm.js.map +0 -1
  257. package/lib/common/pipe/pipe-transtorm.spec.d.ts +0 -2
  258. package/lib/common/pipe/pipe-transtorm.spec.d.ts.map +0 -1
  259. package/lib/common/pipe/pipe-transtorm.spec.js +0 -69
  260. package/lib/common/pipe/pipe-transtorm.spec.js.map +0 -1
  261. package/src/common/pipe/pipe-transtorm.spec.ts +0 -62
  262. package/src/common/pipe/pipe-transtorm.ts +0 -113
@@ -1,18 +0,0 @@
1
- import { PipeTransform, ArgumentMetadata } from './pipe-protocol';
2
- export declare class ValidationPipe implements PipeTransform<any> {
3
- protected options: any;
4
- readonly priority = 1000;
5
- transform(value: any, metadata: ArgumentMetadata): Promise<any>;
6
- private toValidate;
7
- private toEmptyIfNil;
8
- private stripProtoKeys;
9
- /**
10
- * Request data: primitives, arrays and plain objects, as parsed from JSON, query strings or RPC
11
- * messages. Objects the framework passes in (request, response, session, cookies, errors) are
12
- * class instances and pass through: converting them would copy them property by property, which
13
- * never ends for the circular request and response.
14
- */
15
- private isData;
16
- private isPrimitive;
17
- }
18
- //# sourceMappingURL=pipe-transtorm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe-transtorm.d.ts","sourceRoot":"","sources":["../../../src/common/pipe/pipe-transtorm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKlE,qBACa,cAAe,YAAW,aAAa,CAAC,GAAG,CAAC;IAGrD,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC;IAEvB,QAAQ,CAAC,QAAQ,QAAQ;IAEZ,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,CAwD3E;IAED,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,cAAc;IAQtB;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,WAAW;CAGtB"}
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ValidationPipe = void 0;
13
- const core_1 = require("@celljs/core");
14
- const pipe_protocol_1 = require("./pipe-protocol");
15
- const validation_errors_1 = require("./validation-errors");
16
- const class_validator_1 = require("class-validator");
17
- const class_transformer_1 = require("class-transformer");
18
- let ValidationPipe = class ValidationPipe {
19
- constructor() {
20
- this.priority = 1000;
21
- }
22
- async transform(value, metadata) {
23
- const opts = this.options || {};
24
- const { argType } = metadata;
25
- if (!argType || !this.isData(value)) {
26
- return value;
27
- }
28
- if (!this.toValidate(metadata)) {
29
- return (0, class_transformer_1.plainToInstance)(argType, value, opts.transformOptions);
30
- }
31
- const originalValue = value;
32
- value = this.toEmptyIfNil(value);
33
- const isNil = value !== originalValue;
34
- const isPrimitive = this.isPrimitive(value);
35
- this.stripProtoKeys(value);
36
- let entity = (0, class_transformer_1.plainToInstance)(argType, value, opts.transformOptions);
37
- const originalEntity = entity;
38
- const isCtorNotEqual = entity.constructor !== argType;
39
- if (isCtorNotEqual && !isPrimitive) {
40
- entity.constructor = argType;
41
- }
42
- else if (isCtorNotEqual) {
43
- // when "entity" is a primitive value, we have to temporarily
44
- // replace the entity to perform the validation against the original
45
- // metatype defined inside the handler
46
- entity = { constructor: argType };
47
- }
48
- const errors = await (0, class_validator_1.validate)(entity, opts.validatorOptions);
49
- if (errors.length > 0) {
50
- throw new validation_errors_1.ValidationErrors(opts.detailedOutputDisabled ? undefined : errors);
51
- }
52
- if (isPrimitive) {
53
- // if the value is a primitive value and the validation process has been successfully completed
54
- // we have to revert the original value passed through the pipe
55
- entity = originalEntity;
56
- }
57
- if (opts.transformEnabled) {
58
- return entity;
59
- }
60
- if (isNil) {
61
- // if the value was originally undefined or null, revert it back
62
- return originalValue;
63
- }
64
- return Object.keys(opts.validatorOptions).length > 0
65
- ? (0, class_transformer_1.instanceToPlain)(entity, opts.transformOptions)
66
- : value;
67
- }
68
- toValidate(metadata) {
69
- const { argType } = metadata;
70
- const types = [String, Boolean, Number, Array, Object];
71
- // eslint-disable-next-line no-null/no-null
72
- return argType !== null && !types.some(t => argType === t);
73
- }
74
- toEmptyIfNil(value) {
75
- // eslint-disable-next-line no-null/no-null
76
- return value === null ? {} : value;
77
- }
78
- stripProtoKeys(value) {
79
- delete value.__proto__;
80
- const keys = Object.keys(value);
81
- keys
82
- .filter(key => typeof value[key] === 'object' && value[key])
83
- .forEach(key => this.stripProtoKeys(value[key]));
84
- }
85
- /**
86
- * Request data: primitives, arrays and plain objects, as parsed from JSON, query strings or RPC
87
- * messages. Objects the framework passes in (request, response, session, cookies, errors) are
88
- * class instances and pass through: converting them would copy them property by property, which
89
- * never ends for the circular request and response.
90
- */
91
- isData(value) {
92
- if (typeof value === 'function') {
93
- return false;
94
- }
95
- if (value === null || typeof value !== 'object' || Array.isArray(value)) {
96
- return true;
97
- }
98
- const proto = Object.getPrototypeOf(value);
99
- return proto === Object.prototype || proto === null;
100
- }
101
- isPrimitive(value) {
102
- return ['number', 'boolean', 'string'].indexOf(typeof value) !== -1;
103
- }
104
- };
105
- exports.ValidationPipe = ValidationPipe;
106
- __decorate([
107
- (0, core_1.Value)('cell.web.validationPipeOptions'),
108
- __metadata("design:type", Object)
109
- ], ValidationPipe.prototype, "options", void 0);
110
- exports.ValidationPipe = ValidationPipe = __decorate([
111
- (0, core_1.Component)(pipe_protocol_1.PipeTransform)
112
- ], ValidationPipe);
113
- //# sourceMappingURL=pipe-transtorm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe-transtorm.js","sourceRoot":"","sources":["../../../src/common/pipe/pipe-transtorm.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAgD;AAChD,mDAAkE;AAClE,2DAAuD;AACvD,qD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../../../src/common/pipe/pipe-transtorm.spec.ts"],"names":[],"mappings":""}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const bun_test_1 = require("bun:test");
13
- const chai_1 = require("chai");
14
- const class_validator_1 = require("class-validator");
15
- const node_http_1 = require("node:http");
16
- const node_net_1 = require("node:net");
17
- const pipe_transtorm_1 = require("./pipe-transtorm");
18
- const validation_errors_1 = require("./validation-errors");
19
- class CreateUser {
20
- }
21
- __decorate([
22
- (0, class_validator_1.IsString)(),
23
- __metadata("design:type", String)
24
- ], CreateUser.prototype, "name", void 0);
25
- class Cookies {
26
- constructor(values) {
27
- this.values = values;
28
- }
29
- get(name) {
30
- return this.values[name];
31
- }
32
- }
33
- function createPipe() {
34
- const pipe = new pipe_transtorm_1.ValidationPipe();
35
- pipe.options = { detailedOutputDisabled: false, transformEnabled: true };
36
- return pipe;
37
- }
38
- (0, bun_test_1.describe)('ValidationPipe', () => {
39
- (0, bun_test_1.it)('passes the request and response through, whatever the parameter type', async () => {
40
- const pipe = createPipe();
41
- const request = new node_http_1.IncomingMessage(new node_net_1.Socket());
42
- const response = new node_http_1.ServerResponse(request);
43
- (0, chai_1.expect)(await pipe.transform(response, { argType: Object })).to.equal(response);
44
- (0, chai_1.expect)(await pipe.transform(response, { argType: node_http_1.ServerResponse })).to.equal(response);
45
- (0, chai_1.expect)(await pipe.transform(request, { argType: Object })).to.equal(request);
46
- });
47
- (0, bun_test_1.it)('keeps other framework objects with their methods', async () => {
48
- const cookies = new Cookies({ token: 'abc' });
49
- const result = await createPipe().transform(cookies, { argType: Object });
50
- (0, chai_1.expect)(result).to.equal(cookies);
51
- (0, chai_1.expect)(result.get('token')).to.equal('abc');
52
- });
53
- (0, bun_test_1.it)('turns request data into the parameter class and validates it', async () => {
54
- const pipe = createPipe();
55
- const user = await pipe.transform({ name: 'Tom' }, { argType: CreateUser });
56
- (0, chai_1.expect)(user).to.be.instanceOf(CreateUser);
57
- (0, chai_1.expect)(user.name).to.equal('Tom');
58
- let error;
59
- await pipe.transform({ name: 1 }, { argType: CreateUser }).catch(e => error = e);
60
- (0, chai_1.expect)(error).to.be.instanceOf(validation_errors_1.ValidationErrors);
61
- });
62
- (0, bun_test_1.it)('converts plain objects, arrays and primitives as before', async () => {
63
- const pipe = createPipe();
64
- (0, chai_1.expect)(await pipe.transform({ a: { b: 1 } }, { argType: Object })).to.deep.equal({ a: { b: 1 } });
65
- (0, chai_1.expect)(await pipe.transform([1, 2], { argType: Array })).to.deep.equal([1, 2]);
66
- (0, chai_1.expect)(await pipe.transform('5', { argType: String })).to.equal('5');
67
- });
68
- });
69
- //# sourceMappingURL=pipe-transtorm.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe-transtorm.spec.js","sourceRoot":"","sources":["../../../src/common/pipe/pipe-transtorm.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAAwC;AACxC,+BAA8B;AAC9B,qDAA2C;AAC3C,yCAA4D;AAC5D,uCAAkC;AAClC,qDAAkD;AAClD,2DAAuD;AAEvD,MAAM,UAAU;CAGf;AADG;IADC,IAAA,0BAAQ,GAAE;;wCACE;AAGjB,MAAM,OAAO;IACT,YAA+B,MAA8B;sBAA9B,MAAM;IAA4B,CAAC;IAElE,GAAG,CAAC,IAAY;Q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AAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAClG,IAAA,aAAM,EAAC,MAAM,IAAI,CAAC,SAAS,CAAC,CAAE,CAAC,EAAE,CAAC,CAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAE,CAAC,EAAE,CAAC,CAAE,CAAC,CAAC;QACnF,IAAA,aAAM,EAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,62 +0,0 @@
1
- import { describe, it } from 'bun:test';
2
- import { expect } from 'chai';
3
- import { IsString } from 'class-validator';
4
- import { IncomingMessage, ServerResponse } from 'node:http';
5
- import { Socket } from 'node:net';
6
- import { ValidationPipe } from './pipe-transtorm';
7
- import { ValidationErrors } from './validation-errors';
8
-
9
- class CreateUser {
10
- @IsString()
11
- name: string;
12
- }
13
-
14
- class Cookies {
15
- constructor(protected readonly values: Record<string, string>) { }
16
-
17
- get(name: string): string | undefined {
18
- return this.values[name];
19
- }
20
- }
21
-
22
- function createPipe(): ValidationPipe {
23
- const pipe = new ValidationPipe();
24
- (pipe as any).options = { detailedOutputDisabled: false, transformEnabled: true };
25
- return pipe;
26
- }
27
-
28
- describe('ValidationPipe', () => {
29
-
30
- it('passes the request and response through, whatever the parameter type', async () => {
31
- const pipe = createPipe();
32
- const request = new IncomingMessage(new Socket());
33
- const response = new ServerResponse(request);
34
- expect(await pipe.transform(response, { argType: Object })).to.equal(response);
35
- expect(await pipe.transform(response, { argType: ServerResponse })).to.equal(response);
36
- expect(await pipe.transform(request, { argType: Object })).to.equal(request);
37
- });
38
-
39
- it('keeps other framework objects with their methods', async () => {
40
- const cookies = new Cookies({ token: 'abc' });
41
- const result = await createPipe().transform(cookies, { argType: Object });
42
- expect(result).to.equal(cookies);
43
- expect(result.get('token')).to.equal('abc');
44
- });
45
-
46
- it('turns request data into the parameter class and validates it', async () => {
47
- const pipe = createPipe();
48
- const user = await pipe.transform({ name: 'Tom' }, { argType: CreateUser });
49
- expect(user).to.be.instanceOf(CreateUser);
50
- expect(user.name).to.equal('Tom');
51
- let error: unknown;
52
- await pipe.transform({ name: 1 }, { argType: CreateUser }).catch(e => error = e);
53
- expect(error).to.be.instanceOf(ValidationErrors);
54
- });
55
-
56
- it('converts plain objects, arrays and primitives as before', async () => {
57
- const pipe = createPipe();
58
- expect(await pipe.transform({ a: { b: 1 } }, { argType: Object })).to.deep.equal({ a: { b: 1 } });
59
- expect(await pipe.transform([ 1, 2 ], { argType: Array })).to.deep.equal([ 1, 2 ]);
60
- expect(await pipe.transform('5', { argType: String })).to.equal('5');
61
- });
62
- });
@@ -1,113 +0,0 @@
1
- import { Component, Value } from '@celljs/core';
2
- import { PipeTransform, ArgumentMetadata } from './pipe-protocol';
3
- import { ValidationErrors } from './validation-errors';
4
- import { validate } from 'class-validator';
5
- import { instanceToPlain, plainToInstance } from 'class-transformer';
6
-
7
- @Component(PipeTransform)
8
- export class ValidationPipe implements PipeTransform<any> {
9
-
10
- @Value('cell.web.validationPipeOptions')
11
- protected options: any;
12
-
13
- readonly priority = 1000;
14
-
15
- public async transform(value: any, metadata: ArgumentMetadata): Promise<any> {
16
- const opts = this.options || {};
17
- const { argType } = metadata;
18
- if (!argType || !this.isData(value)) {
19
- return value;
20
- }
21
- if (!this.toValidate(metadata)) {
22
- return plainToInstance(
23
- argType,
24
- value,
25
- opts.transformOptions,
26
- );
27
- }
28
- const originalValue = value;
29
- value = this.toEmptyIfNil(value);
30
-
31
- const isNil = value !== originalValue;
32
- const isPrimitive = this.isPrimitive(value);
33
- this.stripProtoKeys(value);
34
- let entity = plainToInstance(
35
- argType,
36
- value,
37
- opts.transformOptions,
38
- );
39
-
40
- const originalEntity = entity;
41
- const isCtorNotEqual = entity.constructor !== argType;
42
-
43
- if (isCtorNotEqual && !isPrimitive) {
44
- entity.constructor = argType;
45
- } else if (isCtorNotEqual) {
46
- // when "entity" is a primitive value, we have to temporarily
47
- // replace the entity to perform the validation against the original
48
- // metatype defined inside the handler
49
- entity = { constructor: argType } as any;
50
- }
51
-
52
- const errors = await validate(entity, opts.validatorOptions);
53
- if (errors.length > 0) {
54
- throw new ValidationErrors(opts.detailedOutputDisabled ? undefined : errors);
55
- }
56
- if (isPrimitive) {
57
- // if the value is a primitive value and the validation process has been successfully completed
58
- // we have to revert the original value passed through the pipe
59
- entity = originalEntity;
60
- }
61
- if (opts.transformEnabled) {
62
- return entity;
63
- }
64
- if (isNil) {
65
- // if the value was originally undefined or null, revert it back
66
- return originalValue;
67
- }
68
- return Object.keys(opts.validatorOptions).length > 0
69
- ? instanceToPlain(entity, opts.transformOptions)
70
- : value;
71
- }
72
-
73
- private toValidate(metadata: ArgumentMetadata): boolean {
74
- const { argType } = metadata;
75
- const types = [String, Boolean, Number, Array, Object];
76
- // eslint-disable-next-line no-null/no-null
77
- return argType !== null && !types.some(t => argType === t);
78
- }
79
-
80
- private toEmptyIfNil<T = any, R = any>(value: T): R | {} | undefined {
81
- // eslint-disable-next-line no-null/no-null
82
- return value === null ? {} : value;
83
- }
84
-
85
- private stripProtoKeys(value: Record<string, any>): void {
86
- delete value.__proto__;
87
- const keys = Object.keys(value);
88
- keys
89
- .filter(key => typeof value[key] === 'object' && value[key])
90
- .forEach(key => this.stripProtoKeys(value[key]));
91
- }
92
-
93
- /**
94
- * Request data: primitives, arrays and plain objects, as parsed from JSON, query strings or RPC
95
- * messages. Objects the framework passes in (request, response, session, cookies, errors) are
96
- * class instances and pass through: converting them would copy them property by property, which
97
- * never ends for the circular request and response.
98
- */
99
- private isData(value: unknown): boolean {
100
- if (typeof value === 'function') {
101
- return false;
102
- }
103
- if (value === null || typeof value !== 'object' || Array.isArray(value)) {
104
- return true;
105
- }
106
- const proto = Object.getPrototypeOf(value);
107
- return proto === Object.prototype || proto === null;
108
- }
109
-
110
- private isPrimitive(value: unknown): boolean {
111
- return ['number', 'boolean', 'string'].indexOf(typeof value) !== -1;
112
- }
113
- }