@impactor/nest 3.0.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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/index.d.ts +40 -0
  4. package/nx.json +190 -0
  5. package/package.json +102 -0
  6. package/src/configs/app.d.ts +21 -0
  7. package/src/configs/app.js +65 -0
  8. package/src/configs/app.js.map +1 -0
  9. package/src/configs/database.d.ts +2 -0
  10. package/src/configs/database.js +23 -0
  11. package/src/configs/database.js.map +1 -0
  12. package/src/configs/microservice.d.ts +7 -0
  13. package/src/configs/microservice.js +26 -0
  14. package/src/configs/microservice.js.map +1 -0
  15. package/src/configs/multi-queue-rabbitmq-server.d.ts +24 -0
  16. package/src/configs/multi-queue-rabbitmq-server.js +91 -0
  17. package/src/configs/multi-queue-rabbitmq-server.js.map +1 -0
  18. package/src/configs/redis-config.d.ts +5 -0
  19. package/src/configs/redis-config.js +16 -0
  20. package/src/configs/redis-config.js.map +1 -0
  21. package/src/create-app.d.ts +3 -0
  22. package/src/create-app.js +104 -0
  23. package/src/create-app.js.map +1 -0
  24. package/src/create-microservice.d.ts +2 -0
  25. package/src/create-microservice.js +43 -0
  26. package/src/create-microservice.js.map +1 -0
  27. package/src/create-testing-microservice.d.ts +3 -0
  28. package/src/create-testing-microservice.js +30 -0
  29. package/src/create-testing-microservice.js.map +1 -0
  30. package/src/decorators/controller/add-decorators/add-controller-path.d.ts +2 -0
  31. package/src/decorators/controller/add-decorators/add-controller-path.js +22 -0
  32. package/src/decorators/controller/add-decorators/add-controller-path.js.map +1 -0
  33. package/src/decorators/controller/add-decorators/add-controller-tags.d.ts +2 -0
  34. package/src/decorators/controller/add-decorators/add-controller-tags.js +28 -0
  35. package/src/decorators/controller/add-decorators/add-controller-tags.js.map +1 -0
  36. package/src/decorators/controller/add-decorators/add-http-method.d.ts +3 -0
  37. package/src/decorators/controller/add-decorators/add-http-method.js +27 -0
  38. package/src/decorators/controller/add-decorators/add-http-method.js.map +1 -0
  39. package/src/decorators/controller/add-decorators/add-swagger-body.d.ts +3 -0
  40. package/src/decorators/controller/add-decorators/add-swagger-body.js +30 -0
  41. package/src/decorators/controller/add-decorators/add-swagger-body.js.map +1 -0
  42. package/src/decorators/controller/add-decorators/add-swagger-operation.d.ts +3 -0
  43. package/src/decorators/controller/add-decorators/add-swagger-operation.js +21 -0
  44. package/src/decorators/controller/add-decorators/add-swagger-operation.js.map +1 -0
  45. package/src/decorators/controller/add-decorators/add-swagger-params.d.ts +3 -0
  46. package/src/decorators/controller/add-decorators/add-swagger-params.js +50 -0
  47. package/src/decorators/controller/add-decorators/add-swagger-params.js.map +1 -0
  48. package/src/decorators/controller/add-decorators/add-swagger-response.d.ts +3 -0
  49. package/src/decorators/controller/add-decorators/add-swagger-response.js +33 -0
  50. package/src/decorators/controller/add-decorators/add-swagger-response.js.map +1 -0
  51. package/src/decorators/controller/controller.decorator.d.ts +2 -0
  52. package/src/decorators/controller/controller.decorator.js +18 -0
  53. package/src/decorators/controller/controller.decorator.js.map +1 -0
  54. package/src/decorators/controller/controller.factory.d.ts +11 -0
  55. package/src/decorators/controller/controller.factory.js +261 -0
  56. package/src/decorators/controller/controller.factory.js.map +1 -0
  57. package/src/decorators/controller/default-options.d.ts +2 -0
  58. package/src/decorators/controller/default-options.js +181 -0
  59. package/src/decorators/controller/default-options.js.map +1 -0
  60. package/src/decorators/controller/dto/empty.dto.d.ts +2 -0
  61. package/src/decorators/controller/dto/empty.dto.js +18 -0
  62. package/src/decorators/controller/dto/empty.dto.js.map +1 -0
  63. package/src/decorators/controller/dto/update-response.dto.d.ts +3 -0
  64. package/src/decorators/controller/dto/update-response.dto.js +16 -0
  65. package/src/decorators/controller/dto/update-response.dto.js.map +1 -0
  66. package/src/decorators/controller/interceptors/query.interceptor.d.ts +8 -0
  67. package/src/decorators/controller/interceptors/query.interceptor.js +59 -0
  68. package/src/decorators/controller/interceptors/query.interceptor.js.map +1 -0
  69. package/src/decorators/controller/route-handler.d.ts +3 -0
  70. package/src/decorators/controller/route-handler.js +44 -0
  71. package/src/decorators/controller/route-handler.js.map +1 -0
  72. package/src/decorators/controller/route.decorator.d.ts +2 -0
  73. package/src/decorators/controller/route.decorator.js +17 -0
  74. package/src/decorators/controller/route.decorator.js.map +1 -0
  75. package/src/decorators/controller/services/crud-typeorm.service.d.ts +46 -0
  76. package/src/decorators/controller/services/crud-typeorm.service.js +232 -0
  77. package/src/decorators/controller/services/crud-typeorm.service.js.map +1 -0
  78. package/src/decorators/controller/types/index.d.ts +54 -0
  79. package/src/decorators/controller/types/index.js +6 -0
  80. package/src/decorators/controller/types/index.js.map +1 -0
  81. package/src/decorators/controller/utils/merge-options.d.ts +2 -0
  82. package/src/decorators/controller/utils/merge-options.js +37 -0
  83. package/src/decorators/controller/utils/merge-options.js.map +1 -0
  84. package/src/decorators/controller/utils/reflect.d.ts +10 -0
  85. package/src/decorators/controller/utils/reflect.js +86 -0
  86. package/src/decorators/controller/utils/reflect.js.map +1 -0
  87. package/src/decorators/prop.decorator.d.ts +9 -0
  88. package/src/decorators/prop.decorator.js +80 -0
  89. package/src/decorators/prop.decorator.js.map +1 -0
  90. package/src/exceptions/rpc-bad-request.exception.d.ts +4 -0
  91. package/src/exceptions/rpc-bad-request.exception.js +19 -0
  92. package/src/exceptions/rpc-bad-request.exception.js.map +1 -0
  93. package/src/exceptions/rpc-base.exception.d.ts +6 -0
  94. package/src/exceptions/rpc-base.exception.js +22 -0
  95. package/src/exceptions/rpc-base.exception.js.map +1 -0
  96. package/src/exceptions/rpc-conflict.exception.d.ts +4 -0
  97. package/src/exceptions/rpc-conflict.exception.js +19 -0
  98. package/src/exceptions/rpc-conflict.exception.js.map +1 -0
  99. package/src/exceptions/rpc-internal-server-error.exception.d.ts +4 -0
  100. package/src/exceptions/rpc-internal-server-error.exception.js +19 -0
  101. package/src/exceptions/rpc-internal-server-error.exception.js.map +1 -0
  102. package/src/exceptions/rpc-method-not-allowed.exception.d.ts +4 -0
  103. package/src/exceptions/rpc-method-not-allowed.exception.js +19 -0
  104. package/src/exceptions/rpc-method-not-allowed.exception.js.map +1 -0
  105. package/src/exceptions/rpc-not-found.exception.d.ts +4 -0
  106. package/src/exceptions/rpc-not-found.exception.js +19 -0
  107. package/src/exceptions/rpc-not-found.exception.js.map +1 -0
  108. package/src/exceptions/rpc-not-implemented.exception.d.ts +4 -0
  109. package/src/exceptions/rpc-not-implemented.exception.js +19 -0
  110. package/src/exceptions/rpc-not-implemented.exception.js.map +1 -0
  111. package/src/exceptions/rpc-unauthorized.exception.d.ts +4 -0
  112. package/src/exceptions/rpc-unauthorized.exception.js +19 -0
  113. package/src/exceptions/rpc-unauthorized.exception.js.map +1 -0
  114. package/src/filters/error-to-rpc-exception.filter.d.ts +4 -0
  115. package/src/filters/error-to-rpc-exception.filter.js +48 -0
  116. package/src/filters/error-to-rpc-exception.filter.js.map +1 -0
  117. package/src/filters/error-to-ws-exception.filter.d.ts +4 -0
  118. package/src/filters/error-to-ws-exception.filter.js +47 -0
  119. package/src/filters/error-to-ws-exception.filter.js.map +1 -0
  120. package/src/filters/typeorm-exception.filter.d.ts +6 -0
  121. package/src/filters/typeorm-exception.filter.js +44 -0
  122. package/src/filters/typeorm-exception.filter.js.map +1 -0
  123. package/src/filters/ws-exception.filter.d.ts +5 -0
  124. package/src/filters/ws-exception.filter.js +39 -0
  125. package/src/filters/ws-exception.filter.js.map +1 -0
  126. package/src/generate-metadata.d.ts +10 -0
  127. package/src/generate-metadata.js +97 -0
  128. package/src/generate-metadata.js.map +1 -0
  129. package/src/guards/auth.guard.d.ts +14 -0
  130. package/src/guards/auth.guard.js +92 -0
  131. package/src/guards/auth.guard.js.map +1 -0
  132. package/src/modules/basic/basic.controller.d.ts +3 -0
  133. package/src/modules/basic/basic.controller.js +33 -0
  134. package/src/modules/basic/basic.controller.js.map +1 -0
  135. package/src/modules/basic/basic.module.d.ts +2 -0
  136. package/src/modules/basic/basic.module.js +45 -0
  137. package/src/modules/basic/basic.module.js.map +1 -0
  138. package/src/modules/basic/basic.service.d.ts +2 -0
  139. package/src/modules/basic/basic.service.js +24 -0
  140. package/src/modules/basic/basic.service.js.map +1 -0
  141. package/src/nest-swagger-metadata.js +553 -0
  142. package/src/nest-swagger-metadata.js.map +1 -0
  143. package/src/utils/logger.d.ts +2 -0
  144. package/src/utils/logger.js +14 -0
  145. package/src/utils/logger.js.map +1 -0
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get applyDecorators () {
13
+ return applyDecorators;
14
+ },
15
+ get get () {
16
+ return get;
17
+ },
18
+ get getAll () {
19
+ return getAll;
20
+ },
21
+ get getKeys () {
22
+ return getKeys;
23
+ },
24
+ get has () {
25
+ return has;
26
+ },
27
+ get set () {
28
+ return set;
29
+ }
30
+ });
31
+ const _common = require("@nestjs/common");
32
+ function has(property, factory, route) {
33
+ if (route && !route.methodName) {
34
+ throw new Error(`route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`);
35
+ }
36
+ return route ? Reflect.hasMetadata(property, factory.controller.prototype[route.methodName]) : Reflect.hasMetadata(property, factory.controller.prototype) || Reflect.hasMetadata(property, factory.controller);
37
+ }
38
+ function get(property, factory, route) {
39
+ if (route && !route.methodName) {
40
+ throw new Error(`route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`);
41
+ }
42
+ return route ? Reflect.getMetadata(property, factory.controller.prototype[route.methodName]) : Reflect.getMetadata(property, factory.controller.prototype) || Reflect.getMetadata(property, factory.controller);
43
+ }
44
+ function set(property, value, factory, route) {
45
+ if (route && !route.methodName) {
46
+ throw new Error(`route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`);
47
+ }
48
+ return route ? Reflect.defineMetadata(property, value, factory.controller.prototype[route.methodName]) : Reflect.defineMetadata(property, value, factory.controller.prototype);
49
+ }
50
+ function getKeys(factory, route) {
51
+ if (route && !route.methodName) {
52
+ throw new Error(`route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`);
53
+ }
54
+ return route ? Reflect.getMetadataKeys(factory.controller.prototype[route.methodName]) : [
55
+ ...new Set([
56
+ ...Reflect.getMetadataKeys(factory.controller.prototype),
57
+ ...Reflect.getMetadataKeys(factory.controller)
58
+ ])
59
+ ];
60
+ }
61
+ function getAll(factory, route) {
62
+ let keys = getKeys(factory, route);
63
+ let map = {};
64
+ for (let key of keys){
65
+ map[key] = get(key, factory, route);
66
+ }
67
+ return map;
68
+ }
69
+ function applyDecorators(factory) {
70
+ if (factory.decorators?.length) {
71
+ Reflect.decorate(factory.decorators, factory.controller);
72
+ }
73
+ for (let route of factory.options.routes){
74
+ // without reflect-metadata use: `decorator(target, method, descriptor)`
75
+ if (route.decorators?.length) {
76
+ Reflect.decorate(route.decorators, factory.controller.prototype, route.methodName, Reflect.getOwnPropertyDescriptor(factory.controller.prototype, route.methodName));
77
+ if (route.interceptors?.length) {
78
+ Reflect.decorate([
79
+ (0, _common.UseInterceptors)(...route.interceptors)
80
+ ], factory.controller.prototype, route.methodName, Reflect.getOwnPropertyDescriptor(factory.controller.prototype, route.methodName));
81
+ }
82
+ }
83
+ }
84
+ }
85
+
86
+ //# sourceMappingURL=reflect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/decorators/controller/utils/reflect.ts"],"sourcesContent":["import { UseInterceptors } from '@nestjs/common';\nimport { ControllerFactory } from '../controller.factory';\nimport { IRoute } from '../types';\n\n/**\n * Check if the class or a method has a metadata property\n * @param property the metadata property to be checked\n * @param factory the class\n * @param route if provided, the method's metadata is checked, otherwise the class's metadata is checked\n * @returns\n */\nexport function has(\n property: string,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.hasMetadata(\n property,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.hasMetadata(property, factory.controller.prototype) ||\n Reflect.hasMetadata(property, factory.controller);\n}\n\nexport function get(\n property: string,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.getMetadata(\n property,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.getMetadata(property, factory.controller.prototype) ||\n Reflect.getMetadata(property, factory.controller);\n}\n\nexport function set<T extends Object>(\n property: string,\n value: T,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.defineMetadata(\n property,\n value,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.defineMetadata(property, value, factory.controller.prototype);\n}\n\n/**\n * get all metadata keys\n * @param factory\n * @param route\n */\nexport function getKeys(factory: ControllerFactory, route?: IRoute) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.getMetadataKeys(factory.controller.prototype[route.methodName])\n : [\n ...new Set([\n ...Reflect.getMetadataKeys(factory.controller.prototype),\n ...Reflect.getMetadataKeys(factory.controller),\n ]),\n ];\n}\n\n/**\n * get all metadata key-value pairs\n * @param factory\n * @param route\n */\nexport function getAll(factory: ControllerFactory, route?: IRoute) {\n let keys = getKeys(factory, route);\n let map: { [key: string]: unknown } = {};\n\n for (let key of keys) {\n map[key] = get(key, factory, route);\n }\n\n return map;\n}\n\n/**\n * apply the provided decorators to the method\n */\nexport function applyDecorators(factory: ControllerFactory) {\n if (factory.decorators?.length) {\n Reflect.decorate(factory.decorators, factory.controller);\n }\n\n for (let route of factory.options.routes) {\n // without reflect-metadata use: `decorator(target, method, descriptor)`\n if (route.decorators?.length) {\n Reflect.decorate(\n route.decorators,\n factory.controller.prototype,\n route.methodName,\n Reflect.getOwnPropertyDescriptor(\n factory.controller.prototype,\n route.methodName,\n ),\n );\n\n if (route.interceptors?.length) {\n Reflect.decorate(\n [UseInterceptors(...route.interceptors)],\n factory.controller.prototype,\n route.methodName,\n Reflect.getOwnPropertyDescriptor(\n factory.controller.prototype,\n route.methodName,\n ),\n );\n }\n }\n }\n}\n"],"names":["applyDecorators","get","getAll","getKeys","has","set","property","factory","route","methodName","Error","httpMethod","toUpperCase","path","Reflect","hasMetadata","controller","prototype","getMetadata","value","defineMetadata","getMetadataKeys","Set","keys","map","key","decorators","length","decorate","options","routes","getOwnPropertyDescriptor","interceptors","UseInterceptors"],"mappings":";;;;;;;;;;;QAiHgBA;eAAAA;;QAlFAC;eAAAA;;QAoEAC;eAAAA;;QAtBAC;eAAAA;;QAlEAC;eAAAA;;QAwCAC;eAAAA;;;wBAnDgB;AAWzB,SAASD,IACdE,QAAgB,EAChBC,OAA0B,EAC1BC,KAAc;IAEd,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQC,WAAW,CACjBT,UACAC,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IAEhDK,QAAQC,WAAW,CAACT,UAAUC,QAAQS,UAAU,CAACC,SAAS,KACxDH,QAAQC,WAAW,CAACT,UAAUC,QAAQS,UAAU;AACxD;AAEO,SAASf,IACdK,QAAgB,EAChBC,OAA0B,EAC1BC,KAAc;IAEd,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQI,WAAW,CACjBZ,UACAC,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IAEhDK,QAAQI,WAAW,CAACZ,UAAUC,QAAQS,UAAU,CAACC,SAAS,KACxDH,QAAQI,WAAW,CAACZ,UAAUC,QAAQS,UAAU;AACxD;AAEO,SAASX,IACdC,QAAgB,EAChBa,KAAQ,EACRZ,OAA0B,EAC1BC,KAAc;IAEd,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQM,cAAc,CACpBd,UACAa,OACAZ,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IAEhDK,QAAQM,cAAc,CAACd,UAAUa,OAAOZ,QAAQS,UAAU,CAACC,SAAS;AAC1E;AAOO,SAASd,QAAQI,OAA0B,EAAEC,KAAc;IAChE,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQO,eAAe,CAACd,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IACtE;WACK,IAAIa,IAAI;eACNR,QAAQO,eAAe,CAACd,QAAQS,UAAU,CAACC,SAAS;eACpDH,QAAQO,eAAe,CAACd,QAAQS,UAAU;SAC9C;KACF;AACP;AAOO,SAASd,OAAOK,OAA0B,EAAEC,KAAc;IAC/D,IAAIe,OAAOpB,QAAQI,SAASC;IAC5B,IAAIgB,MAAkC,CAAC;IAEvC,KAAK,IAAIC,OAAOF,KAAM;QACpBC,GAAG,CAACC,IAAI,GAAGxB,IAAIwB,KAAKlB,SAASC;IAC/B;IAEA,OAAOgB;AACT;AAKO,SAASxB,gBAAgBO,OAA0B;IACxD,IAAIA,QAAQmB,UAAU,EAAEC,QAAQ;QAC9Bb,QAAQc,QAAQ,CAACrB,QAAQmB,UAAU,EAAEnB,QAAQS,UAAU;IACzD;IAEA,KAAK,IAAIR,SAASD,QAAQsB,OAAO,CAACC,MAAM,CAAE;QACxC,wEAAwE;QACxE,IAAItB,MAAMkB,UAAU,EAAEC,QAAQ;YAC5Bb,QAAQc,QAAQ,CACdpB,MAAMkB,UAAU,EAChBnB,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU,EAChBK,QAAQiB,wBAAwB,CAC9BxB,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU;YAIpB,IAAID,MAAMwB,YAAY,EAAEL,QAAQ;gBAC9Bb,QAAQc,QAAQ,CACd;oBAACK,IAAAA,uBAAe,KAAIzB,MAAMwB,YAAY;iBAAE,EACxCzB,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU,EAChBK,QAAQiB,wBAAwB,CAC9BxB,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU;YAGtB;QACF;IACF;AACF"}
@@ -0,0 +1,9 @@
1
+ import { type PipeTransform, type Type } from '@nestjs/common';
2
+ import { type ApiParamOptions } from '@nestjs/swagger';
3
+ export interface IdParamDecoratorOptions {
4
+ name?: string;
5
+ scope?: 'params' | 'query' | 'body' | 'payload' | 'messageBody';
6
+ }
7
+ export declare function Prop(name: string, scope?: IdParamDecoratorOptions['scope'], pipes?: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
8
+ export declare function Uuid(name?: string, scope?: IdParamDecoratorOptions['scope'], pipes?: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
9
+ export declare function UuidApi(name?: string, scope?: IdParamDecoratorOptions['scope'], apiOptions?: ApiParamOptions): ParameterDecorator;
@@ -0,0 +1,80 @@
1
+ /* eslint unicorn/prevent-abbreviations: 0 */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get Prop () {
13
+ return Prop;
14
+ },
15
+ get Uuid () {
16
+ return Uuid;
17
+ },
18
+ get UuidApi () {
19
+ return UuidApi;
20
+ }
21
+ });
22
+ const _common = require("@nestjs/common");
23
+ const _swagger = require("@nestjs/swagger");
24
+ const _microservices = require("@nestjs/microservices");
25
+ const _websockets = require("@nestjs/websockets");
26
+ function Prop(name, scope = 'params', pipes = []) {
27
+ return (target, propertyKey, parameterIndex)=>{
28
+ if (scope === 'payload') {
29
+ return (0, _microservices.Payload)(name, ...pipes)(target, propertyKey, parameterIndex);
30
+ } else if (scope === 'messageBody') {
31
+ return (0, _websockets.MessageBody)(name, ...pipes)(target, propertyKey, parameterIndex);
32
+ } else if (scope === 'params') {
33
+ return (0, _common.Param)(name, ...pipes)(target, propertyKey, parameterIndex);
34
+ } else if (scope === 'query') {
35
+ return (0, _common.Query)(name, ...pipes)(target, propertyKey, parameterIndex);
36
+ } else if (scope === 'body') {
37
+ return (0, _common.Body)(name, ...pipes)(target, propertyKey, parameterIndex);
38
+ }
39
+ };
40
+ }
41
+ function Uuid(name = 'id', scope = 'params', pipes) {
42
+ return Prop(name, scope, pipes || [
43
+ new _common.ParseUUIDPipe()
44
+ ]);
45
+ }
46
+ function UuidApi(name = 'id', scope = 'params', // TODO: accept options based on the scope's value
47
+ // TODO: allow swapping between scope and apiOptions
48
+ apiOptions) {
49
+ return (target, propertyKey, parameterIndex)=>{
50
+ // TODO: add swagger docs for other scopes
51
+ // TODO: auto detect if the property is optional -> `@Uuid() id?: string`
52
+ if (scope === 'params') {
53
+ (0, _swagger.ApiParam)({
54
+ name,
55
+ type: 'string',
56
+ format: 'uuid',
57
+ example: '4eae7b32-9065-42b0-a025-5cb967011e65',
58
+ ...apiOptions
59
+ })(target.constructor, propertyKey, Object.getOwnPropertyDescriptor(target, propertyKey));
60
+ }
61
+ let IdParamDecorator = (0, _common.createParamDecorator)((opts, ctx)=>{
62
+ let { name = 'id', scope = 'params' } = opts;
63
+ let req = ctx.switchToHttp().getRequest();
64
+ let id = req[scope][name];
65
+ if (!id) throw new _common.BadRequestException(`${name} is required`);
66
+ // Use ParseUUIDPipe to validate the UUID
67
+ let parseUUIDPipe = new _common.ParseUUIDPipe();
68
+ return parseUUIDPipe.transform(id, {
69
+ type: 'param',
70
+ metatype: String
71
+ });
72
+ });
73
+ return IdParamDecorator({
74
+ name,
75
+ scope
76
+ })(target, propertyKey, parameterIndex);
77
+ };
78
+ }
79
+
80
+ //# sourceMappingURL=prop.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/decorators/prop.decorator.ts"],"sourcesContent":["/* eslint unicorn/prevent-abbreviations: 0 */\nimport {\n BadRequestException,\n Body,\n type ExecutionContext,\n Param,\n type PipeTransform,\n Query,\n type Type,\n createParamDecorator,\n} from '@nestjs/common';\nimport { ParseUUIDPipe } from '@nestjs/common';\nimport { ApiParam, type ApiParamOptions } from '@nestjs/swagger';\nimport { Payload } from '@nestjs/microservices';\nimport { MessageBody } from '@nestjs/websockets';\n\nexport interface IdParamDecoratorOptions {\n /**\n * The property that is wanted to be extracted\n */\n name?: string;\n /**\n * The scope to extract the property from\n * @example @Params('id')\n * @example @Payload('id')\n */\n scope?: 'params' | 'query' | 'body' | 'payload' | 'messageBody';\n}\n\n/**\n * a param decorator that extracts a field from the request\n * and validates it using pipes\n * and add the suitable Swagger's docs\n *\n * @param name the field's name\n * @param scope the scope where the prop is defined in\n *\n * @example\n * extract userId from params\n * ```\n * @Get(':userId')\n * findUserById(@Prop('userId') userId: string){\n * this.service.findUserById(userId);\n * }\n * ```\n *\n * @example\n * extract the id from the query string\n * ```\n * @Get()\n * filterByTenant(@Prop('tenantId', 'query') tenantId: string){ ... }\n * ```\n *\n * @example\n * extract the product id from the request's body\n * ```\n * @Post()\n * createOrder(@Prop('productId','body') productId: string){ ... }\n * ```\n *\n * @example\n * manipulate the swagger's docs: make the id optional\n * ```\n * @Get('id')\n * find(@Prop('id', 'params', <any>{ required: false }) id?: string){\n * return id?: this.service.findById(id) : this.service.find()\n * }\n * ```\n *\n * @returns the field value\n * @throws BadRequestException\n */\nexport function Prop(\n name: string,\n scope: IdParamDecoratorOptions['scope'] = 'params',\n pipes: (Type<PipeTransform> | PipeTransform)[] = [],\n): ParameterDecorator {\n return (\n target: Object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ) => {\n if (scope === 'payload') {\n return Payload(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'messageBody') {\n return MessageBody(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'params') {\n return Param(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'query') {\n return Query(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'body') {\n return Body(name, ...pipes)(target, propertyKey, parameterIndex);\n }\n };\n}\n\n/**\n * apply @prop() to extract the id field and validate its value as uuid *\n * to customize the Swagger's docs use uuidApi()\n * @returns the UUID value\n * @throws BadRequestException\n */\nexport function Uuid(\n name = 'id',\n scope: IdParamDecoratorOptions['scope'] = 'params',\n pipes?: (Type<PipeTransform> | PipeTransform)[],\n): ParameterDecorator {\n return Prop(name, scope, pipes || [new ParseUUIDPipe()]);\n}\n\n/**\n * same as Uuid() but can provide additional options for Swagger's docs\n *\n * @example\n * if the prop name is id, it is optional\n * ```\n * @Get('id)\n * findById(@Uuid() id: string){}\n * ```\n *\n * @param name\n * @param scope\n * @param apiOptions additional options for swagger's docs\n * @returns\n */\nexport function UuidApi(\n name = 'id',\n scope: IdParamDecoratorOptions['scope'] = 'params',\n // TODO: accept options based on the scope's value\n // TODO: allow swapping between scope and apiOptions\n apiOptions?: ApiParamOptions,\n): ParameterDecorator {\n return (\n target: Object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ) => {\n // TODO: add swagger docs for other scopes\n // TODO: auto detect if the property is optional -> `@Uuid() id?: string`\n if (scope === 'params') {\n ApiParam({\n name,\n type: 'string',\n format: 'uuid',\n example: '4eae7b32-9065-42b0-a025-5cb967011e65',\n ...apiOptions,\n })(\n target.constructor,\n propertyKey as string,\n Object.getOwnPropertyDescriptor(target, propertyKey!)!,\n );\n }\n\n let IdParamDecorator = createParamDecorator(\n (opts: IdParamDecoratorOptions, ctx: ExecutionContext) => {\n let { name = 'id', scope = 'params' } = opts;\n\n let req = ctx.switchToHttp().getRequest();\n let id = req[scope][name];\n\n if (!id) throw new BadRequestException(`${name} is required`);\n\n // Use ParseUUIDPipe to validate the UUID\n let parseUUIDPipe = new ParseUUIDPipe();\n return parseUUIDPipe.transform(id, {\n type: 'param',\n metatype: String,\n });\n },\n );\n\n return IdParamDecorator({ name, scope })(\n target,\n propertyKey,\n parameterIndex,\n );\n };\n}\n"],"names":["Prop","Uuid","UuidApi","name","scope","pipes","target","propertyKey","parameterIndex","Payload","MessageBody","Param","Query","Body","ParseUUIDPipe","apiOptions","ApiParam","type","format","example","Object","getOwnPropertyDescriptor","IdParamDecorator","createParamDecorator","opts","ctx","req","switchToHttp","getRequest","id","BadRequestException","parseUUIDPipe","transform","metatype","String"],"mappings":"AAAA,2CAA2C;;;;;;;;;;;QAwE3BA;eAAAA;;QA8BAC;eAAAA;;QAuBAC;eAAAA;;;wBAnHT;yBAEwC;+BACvB;4BACI;AA0DrB,SAASF,KACdG,IAAY,EACZC,QAA0C,QAAQ,EAClDC,QAAiD,EAAE;IAEnD,OAAO,CACLC,QACAC,aACAC;QAEA,IAAIJ,UAAU,WAAW;YACvB,OAAOK,IAAAA,sBAAO,EAACN,SAASE,OAAOC,QAAQC,aAAaC;QACtD,OAAO,IAAIJ,UAAU,eAAe;YAClC,OAAOM,IAAAA,uBAAW,EAACP,SAASE,OAAOC,QAAQC,aAAaC;QAC1D,OAAO,IAAIJ,UAAU,UAAU;YAC7B,OAAOO,IAAAA,aAAK,EAACR,SAASE,OAAOC,QAAQC,aAAaC;QACpD,OAAO,IAAIJ,UAAU,SAAS;YAC5B,OAAOQ,IAAAA,aAAK,EAACT,SAASE,OAAOC,QAAQC,aAAaC;QACpD,OAAO,IAAIJ,UAAU,QAAQ;YAC3B,OAAOS,IAAAA,YAAI,EAACV,SAASE,OAAOC,QAAQC,aAAaC;QACnD;IACF;AACF;AAQO,SAASP,KACdE,OAAO,IAAI,EACXC,QAA0C,QAAQ,EAClDC,KAA+C;IAE/C,OAAOL,KAAKG,MAAMC,OAAOC,SAAS;QAAC,IAAIS,qBAAa;KAAG;AACzD;AAiBO,SAASZ,QACdC,OAAO,IAAI,EACXC,QAA0C,QAAQ,EAClD,kDAAkD;AAClD,oDAAoD;AACpDW,UAA4B;IAE5B,OAAO,CACLT,QACAC,aACAC;QAEA,0CAA0C;QAC1C,yEAAyE;QACzE,IAAIJ,UAAU,UAAU;YACtBY,IAAAA,iBAAQ,EAAC;gBACPb;gBACAc,MAAM;gBACNC,QAAQ;gBACRC,SAAS;gBACT,GAAGJ,UAAU;YACf,GACET,OAAO,WAAW,EAClBC,aACAa,OAAOC,wBAAwB,CAACf,QAAQC;QAE5C;QAEA,IAAIe,mBAAmBC,IAAAA,4BAAoB,EACzC,CAACC,MAA+BC;YAC9B,IAAI,EAAEtB,OAAO,IAAI,EAAEC,QAAQ,QAAQ,EAAE,GAAGoB;YAExC,IAAIE,MAAMD,IAAIE,YAAY,GAAGC,UAAU;YACvC,IAAIC,KAAKH,GAAG,CAACtB,MAAM,CAACD,KAAK;YAEzB,IAAI,CAAC0B,IAAI,MAAM,IAAIC,2BAAmB,CAAC,GAAG3B,KAAK,YAAY,CAAC;YAE5D,yCAAyC;YACzC,IAAI4B,gBAAgB,IAAIjB,qBAAa;YACrC,OAAOiB,cAAcC,SAAS,CAACH,IAAI;gBACjCZ,MAAM;gBACNgB,UAAUC;YACZ;QACF;QAGF,OAAOZ,iBAAiB;YAAEnB;YAAMC;QAAM,GACpCE,QACAC,aACAC;IAEJ;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcBadRequestException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcBadRequestException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcBadRequestException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcBadRequestException = class RpcBadRequestException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Bad request'){
15
+ super(message, _common.HttpStatus.BAD_REQUEST);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-bad-request.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-bad-request.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcBadRequestException extends RpcBaseException {\n constructor(message = 'Bad request') {\n super(message, HttpStatus.BAD_REQUEST);\n }\n}\n"],"names":["RpcBadRequestException","RpcBaseException","message","HttpStatus","BAD_REQUEST"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,yBAAN,MAAMA,+BAA+BC,kCAAgB;IAC1D,YAAYC,UAAU,aAAa,CAAE;QACnC,KAAK,CAACA,SAASC,kBAAU,CAACC,WAAW;IACvC;AACF"}
@@ -0,0 +1,6 @@
1
+ import { RpcException } from '@nestjs/microservices';
2
+ import { HttpStatus } from '@nestjs/common';
3
+ export declare class RpcBaseException extends RpcException {
4
+ statusCode: HttpStatus;
5
+ constructor(message: string, statusCode?: HttpStatus);
6
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcBaseException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcBaseException;
9
+ }
10
+ });
11
+ const _microservices = require("@nestjs/microservices");
12
+ const _common = require("@nestjs/common");
13
+ let RpcBaseException = class RpcBaseException extends _microservices.RpcException {
14
+ constructor(message, statusCode = _common.HttpStatus.INTERNAL_SERVER_ERROR){
15
+ super({
16
+ message
17
+ });
18
+ this.statusCode = statusCode;
19
+ }
20
+ };
21
+
22
+ //# sourceMappingURL=rpc-base.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-base.exception.ts"],"sourcesContent":["import { RpcException } from '@nestjs/microservices';\nimport { HttpStatus } from '@nestjs/common';\n\n/**\n * Base Error class for RPC exceptions.\n * This exception resembles the behavior of HTTP exceptions, but for RPC errors.\n */\n// todo: use `RpcException(new BadRequestException(message))` instead of creating custom RPC exceptions\n// https://stackoverflow.com/a/75335979\nexport class RpcBaseException extends RpcException {\n statusCode: HttpStatus;\n\n constructor(\n message: string,\n statusCode: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR,\n ) {\n super({ message });\n this.statusCode = statusCode;\n }\n}\n"],"names":["RpcBaseException","RpcException","message","statusCode","HttpStatus","INTERNAL_SERVER_ERROR"],"mappings":";;;;+BASaA;;;eAAAA;;;+BATgB;wBACF;AAQpB,IAAA,AAAMA,mBAAN,MAAMA,yBAAyBC,2BAAY;IAGhD,YACEC,OAAe,EACfC,aAAyBC,kBAAU,CAACC,qBAAqB,CACzD;QACA,KAAK,CAAC;YAAEH;QAAQ;QAChB,IAAI,CAACC,UAAU,GAAGA;IACpB;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcConflictException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcConflictException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcConflictException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcConflictException = class RpcConflictException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Conflict'){
15
+ super(message, _common.HttpStatus.CONFLICT);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-conflict.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-conflict.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcConflictException extends RpcBaseException {\n constructor(message = 'Conflict') {\n super(message, HttpStatus.CONFLICT);\n }\n}\n"],"names":["RpcConflictException","RpcBaseException","message","HttpStatus","CONFLICT"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,uBAAN,MAAMA,6BAA6BC,kCAAgB;IACxD,YAAYC,UAAU,UAAU,CAAE;QAChC,KAAK,CAACA,SAASC,kBAAU,CAACC,QAAQ;IACpC;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcInternalServerErrorException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcInternalServerErrorException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcInternalServerErrorException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcInternalServerErrorException = class RpcInternalServerErrorException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Internal server error'){
15
+ super(message, _common.HttpStatus.INTERNAL_SERVER_ERROR);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-internal-server-error.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-internal-server-error.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcInternalServerErrorException extends RpcBaseException {\n constructor(message = 'Internal server error') {\n super(message, HttpStatus.INTERNAL_SERVER_ERROR);\n }\n}\n"],"names":["RpcInternalServerErrorException","RpcBaseException","message","HttpStatus","INTERNAL_SERVER_ERROR"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,kCAAN,MAAMA,wCAAwCC,kCAAgB;IACnE,YAAYC,UAAU,uBAAuB,CAAE;QAC7C,KAAK,CAACA,SAASC,kBAAU,CAACC,qBAAqB;IACjD;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcMethodNotAllowedException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcMethodNotAllowedException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcMethodNotAllowedException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcMethodNotAllowedException = class RpcMethodNotAllowedException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Method not allowed'){
15
+ super(message, _common.HttpStatus.METHOD_NOT_ALLOWED);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-method-not-allowed.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-method-not-allowed.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcMethodNotAllowedException extends RpcBaseException {\n constructor(message = 'Method not allowed') {\n super(message, HttpStatus.METHOD_NOT_ALLOWED);\n }\n}\n"],"names":["RpcMethodNotAllowedException","RpcBaseException","message","HttpStatus","METHOD_NOT_ALLOWED"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,+BAAN,MAAMA,qCAAqCC,kCAAgB;IAChE,YAAYC,UAAU,oBAAoB,CAAE;QAC1C,KAAK,CAACA,SAASC,kBAAU,CAACC,kBAAkB;IAC9C;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcNotFoundException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcNotFoundException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcNotFoundException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcNotFoundException = class RpcNotFoundException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Not Found'){
15
+ super(message, _common.HttpStatus.NOT_FOUND);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-not-found.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-not-found.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcNotFoundException extends RpcBaseException {\n constructor(message = 'Not Found') {\n super(message, HttpStatus.NOT_FOUND);\n }\n}\n"],"names":["RpcNotFoundException","RpcBaseException","message","HttpStatus","NOT_FOUND"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,uBAAN,MAAMA,6BAA6BC,kCAAgB;IACxD,YAAYC,UAAU,WAAW,CAAE;QACjC,KAAK,CAACA,SAASC,kBAAU,CAACC,SAAS;IACrC;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcNotImplementedException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcNotImplementedException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcNotImplementedException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcNotImplementedException = class RpcNotImplementedException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Not implemented'){
15
+ super(message, _common.HttpStatus.NOT_IMPLEMENTED);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-not-implemented.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-not-implemented.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcNotImplementedException extends RpcBaseException {\n constructor(message = 'Not implemented') {\n super(message, HttpStatus.NOT_IMPLEMENTED);\n }\n}\n"],"names":["RpcNotImplementedException","RpcBaseException","message","HttpStatus","NOT_IMPLEMENTED"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,6BAAN,MAAMA,mCAAmCC,kCAAgB;IAC9D,YAAYC,UAAU,iBAAiB,CAAE;QACvC,KAAK,CAACA,SAASC,kBAAU,CAACC,eAAe;IAC3C;AACF"}
@@ -0,0 +1,4 @@
1
+ import { RpcBaseException } from './rpc-base.exception';
2
+ export declare class RpcUnauthorizedException extends RpcBaseException {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RpcUnauthorizedException", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RpcUnauthorizedException;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rpcbaseexception = require("./rpc-base.exception");
13
+ let RpcUnauthorizedException = class RpcUnauthorizedException extends _rpcbaseexception.RpcBaseException {
14
+ constructor(message = 'Invalid credentials'){
15
+ super(message, _common.HttpStatus.UNAUTHORIZED);
16
+ }
17
+ };
18
+
19
+ //# sourceMappingURL=rpc-unauthorized.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/exceptions/rpc-unauthorized.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcUnauthorizedException extends RpcBaseException {\n constructor(message = 'Invalid credentials') {\n super(message, HttpStatus.UNAUTHORIZED);\n }\n}\n"],"names":["RpcUnauthorizedException","RpcBaseException","message","HttpStatus","UNAUTHORIZED"],"mappings":";;;;+BAGaA;;;eAAAA;;;wBAHc;kCACM;AAE1B,IAAA,AAAMA,2BAAN,MAAMA,iCAAiCC,kCAAgB;IAC5D,YAAYC,UAAU,qBAAqB,CAAE;QAC3C,KAAK,CAACA,SAASC,kBAAU,CAACC,YAAY;IACxC;AACF"}
@@ -0,0 +1,4 @@
1
+ import { type RpcExceptionFilter } from '@nestjs/common';
2
+ export declare class ErrorToRpcExceptionFilter implements RpcExceptionFilter<Error> {
3
+ catch(exception: Error): import("rxjs").Observable<never>;
4
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ErrorToRpcExceptionFilter", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ErrorToRpcExceptionFilter;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _microservices = require("@nestjs/microservices");
13
+ const _rxjs = require("rxjs");
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ let ErrorToRpcExceptionFilter = class ErrorToRpcExceptionFilter {
21
+ catch(exception) {
22
+ if (process.env.NODE_ENV === 'development') {
23
+ let logger = new _common.Logger('ErrorToRpc');
24
+ logger.debug(exception);
25
+ }
26
+ // HttpException is converted by NestJs into a response object with a statusCode
27
+ // The response object contains the error message and the statusCode,
28
+ // and the exception itself contains the exception name such as NoFoundError
29
+ if (exception instanceof _common.HttpException) {
30
+ let res = exception.getResponse(), error = typeof res === 'string' ? {
31
+ message: res
32
+ } : res;
33
+ return (0, _rxjs.throwError)(()=>({
34
+ ...exception,
35
+ ...error
36
+ }));
37
+ }
38
+ if (exception instanceof _microservices.RpcException) {
39
+ return (0, _rxjs.throwError)(()=>exception);
40
+ }
41
+ return (0, _rxjs.throwError)(()=>new _microservices.RpcException(exception));
42
+ }
43
+ };
44
+ ErrorToRpcExceptionFilter = _ts_decorate([
45
+ (0, _common.Catch)()
46
+ ], ErrorToRpcExceptionFilter);
47
+
48
+ //# sourceMappingURL=error-to-rpc-exception.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/filters/error-to-rpc-exception.filter.ts"],"sourcesContent":["import {\n Catch,\n HttpException,\n Logger,\n type RpcExceptionFilter,\n} from '@nestjs/common';\nimport { RpcException } from '@nestjs/microservices';\nimport { throwError } from 'rxjs';\n\n/**\n * convert Error to RpcException\n */\n@Catch()\nexport class ErrorToRpcExceptionFilter implements RpcExceptionFilter<Error> {\n catch(exception: Error) {\n if (process.env.NODE_ENV === 'development') {\n let logger = new Logger('ErrorToRpc');\n logger.debug(exception);\n }\n\n // HttpException is converted by NestJs into a response object with a statusCode\n // The response object contains the error message and the statusCode,\n // and the exception itself contains the exception name such as NoFoundError\n if (exception instanceof HttpException) {\n let res = exception.getResponse(),\n error = typeof res === 'string' ? { message: res } : res;\n return throwError(() => ({ ...exception, ...error }));\n }\n\n if (exception instanceof RpcException) {\n return throwError(() => exception);\n }\n\n return throwError(() => new RpcException(exception));\n }\n}\n"],"names":["ErrorToRpcExceptionFilter","catch","exception","process","env","NODE_ENV","logger","Logger","debug","HttpException","res","getResponse","error","message","throwError","RpcException"],"mappings":";;;;+BAaaA;;;eAAAA;;;wBARN;+BACsB;sBACF;;;;;;;AAMpB,IAAA,AAAMA,4BAAN,MAAMA;IACXC,MAAMC,SAAgB,EAAE;QACtB,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;YAC1C,IAAIC,SAAS,IAAIC,cAAM,CAAC;YACxBD,OAAOE,KAAK,CAACN;QACf;QAEA,gFAAgF;QAChF,qEAAqE;QACrE,4EAA4E;QAC5E,IAAIA,qBAAqBO,qBAAa,EAAE;YACtC,IAAIC,MAAMR,UAAUS,WAAW,IAC7BC,QAAQ,OAAOF,QAAQ,WAAW;gBAAEG,SAASH;YAAI,IAAIA;YACvD,OAAOI,IAAAA,gBAAU,EAAC,IAAO,CAAA;oBAAE,GAAGZ,SAAS;oBAAE,GAAGU,KAAK;gBAAC,CAAA;QACpD;QAEA,IAAIV,qBAAqBa,2BAAY,EAAE;YACrC,OAAOD,IAAAA,gBAAU,EAAC,IAAMZ;QAC1B;QAEA,OAAOY,IAAAA,gBAAU,EAAC,IAAM,IAAIC,2BAAY,CAACb;IAC3C;AACF"}
@@ -0,0 +1,4 @@
1
+ import { ArgumentsHost, type WsExceptionFilter } from '@nestjs/common';
2
+ export declare class ErrorToWsExceptionFilter implements WsExceptionFilter<Error> {
3
+ catch(exception: Error, host: ArgumentsHost): import("rxjs").Observable<never>;
4
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ErrorToWsExceptionFilter", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ErrorToWsExceptionFilter;
9
+ }
10
+ });
11
+ const _common = require("@nestjs/common");
12
+ const _rxjs = require("rxjs");
13
+ const _websockets = require("@nestjs/websockets");
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ let ErrorToWsExceptionFilter = class ErrorToWsExceptionFilter {
21
+ catch(exception, host) {
22
+ let ctx = host.switchToWs(), client = ctx.getClient(), pattern = ctx.getPattern(), data = ctx.getData();
23
+ client.emit('exception', {
24
+ pattern,
25
+ message: exception.message,
26
+ data
27
+ });
28
+ if (process.env.NODE_ENV === 'development') {
29
+ let logger = new _common.Logger(`WebSocket @${pattern}`);
30
+ logger.debug(`WS Error in ${pattern}`, exception, {
31
+ data
32
+ });
33
+ }
34
+ // todo: this doesn't trigger the next filter, similar to RpcExceptionFilter does,
35
+ // so we need to handle WsException here, i.e. emit 'exception' event here
36
+ // instead of relying on the custom WebSocketExceptionFilter
37
+ if (exception instanceof _websockets.WsException) {
38
+ return (0, _rxjs.throwError)(()=>exception);
39
+ }
40
+ return (0, _rxjs.throwError)(()=>new _websockets.WsException(exception));
41
+ }
42
+ };
43
+ ErrorToWsExceptionFilter = _ts_decorate([
44
+ (0, _common.Catch)()
45
+ ], ErrorToWsExceptionFilter);
46
+
47
+ //# sourceMappingURL=error-to-ws-exception.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/filters/error-to-ws-exception.filter.ts"],"sourcesContent":["import {\n ArgumentsHost,\n Catch,\n Logger,\n type WsExceptionFilter,\n} from '@nestjs/common';\nimport { throwError } from 'rxjs';\nimport { WsException } from '@nestjs/websockets';\n\n/**\n * convert Error to WsException\n */\n@Catch()\nexport class ErrorToWsExceptionFilter implements WsExceptionFilter<Error> {\n catch(exception: Error, host: ArgumentsHost) {\n let ctx = host.switchToWs(),\n client = ctx.getClient(),\n pattern = ctx.getPattern(),\n data = ctx.getData();\n\n client.emit('exception', {\n pattern,\n message: exception.message,\n data,\n });\n\n if (process.env.NODE_ENV === 'development') {\n let logger = new Logger(`WebSocket @${pattern}`);\n logger.debug(`WS Error in ${pattern}`, exception, {\n data,\n });\n }\n\n // todo: this doesn't trigger the next filter, similar to RpcExceptionFilter does,\n // so we need to handle WsException here, i.e. emit 'exception' event here\n // instead of relying on the custom WebSocketExceptionFilter\n if (exception instanceof WsException) {\n return throwError(() => exception);\n }\n\n return throwError(() => new WsException(exception));\n }\n}\n"],"names":["ErrorToWsExceptionFilter","catch","exception","host","ctx","switchToWs","client","getClient","pattern","getPattern","data","getData","emit","message","process","env","NODE_ENV","logger","Logger","debug","WsException","throwError"],"mappings":";;;;+BAaaA;;;eAAAA;;;wBARN;sBACoB;4BACC;;;;;;;AAMrB,IAAA,AAAMA,2BAAN,MAAMA;IACXC,MAAMC,SAAgB,EAAEC,IAAmB,EAAE;QAC3C,IAAIC,MAAMD,KAAKE,UAAU,IACvBC,SAASF,IAAIG,SAAS,IACtBC,UAAUJ,IAAIK,UAAU,IACxBC,OAAON,IAAIO,OAAO;QAEpBL,OAAOM,IAAI,CAAC,aAAa;YACvBJ;YACAK,SAASX,UAAUW,OAAO;YAC1BH;QACF;QAEA,IAAII,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;YAC1C,IAAIC,SAAS,IAAIC,cAAM,CAAC,CAAC,WAAW,EAAEV,SAAS;YAC/CS,OAAOE,KAAK,CAAC,CAAC,YAAY,EAAEX,SAAS,EAAEN,WAAW;gBAChDQ;YACF;QACF;QAEA,kFAAkF;QAClF,0EAA0E;QAC1E,4DAA4D;QAC5D,IAAIR,qBAAqBkB,uBAAW,EAAE;YACpC,OAAOC,IAAAA,gBAAU,EAAC,IAAMnB;QAC1B;QAEA,OAAOmB,IAAAA,gBAAU,EAAC,IAAM,IAAID,uBAAW,CAAClB;IAC1C;AACF"}
@@ -0,0 +1,6 @@
1
+ import { type ArgumentsHost, type ExceptionFilter } from '@nestjs/common';
2
+ import { TypeORMError } from 'typeorm';
3
+ import { Observable } from 'rxjs';
4
+ export declare class TypeORMExceptionFilter implements ExceptionFilter<TypeORMError> {
5
+ catch(exception: TypeORMError, _host: ArgumentsHost): Observable<any>;
6
+ }