@flusys/nestjs-shared 7.0.2 → 8.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/classes/api-controller.class.d.ts +4 -4
  2. package/classes/api-service.class.d.ts +7 -7
  3. package/classes/disabled-event-bus.class.d.ts +1 -1
  4. package/classes/domain-event.publisher.d.ts +1 -1
  5. package/classes/event-bus.registry.d.ts +1 -1
  6. package/classes/event-transports/event-transport.registry.d.ts +1 -1
  7. package/classes/event-transports/index.d.ts +2 -2
  8. package/classes/event-transports/kafka-transport.optional.d.ts +1 -1
  9. package/classes/event-transports/memory-transport.d.ts +1 -1
  10. package/classes/event-transports/rabbitmq-transport.optional.d.ts +1 -1
  11. package/classes/hybrid-event-bus.class.d.ts +1 -1
  12. package/classes/index.d.ts +11 -11
  13. package/constants/index.d.ts +2 -2
  14. package/constants/permissions.d.ts +12 -0
  15. package/decorators/api-response.decorator.d.ts +1 -1
  16. package/decorators/current-user.decorator.d.ts +1 -1
  17. package/decorators/index.d.ts +6 -6
  18. package/decorators/require-permission.decorator.d.ts +1 -1
  19. package/dtos/filter-and-pagination.dto.d.ts +1 -1
  20. package/dtos/index.d.ts +6 -6
  21. package/entities/index.d.ts +3 -3
  22. package/enums/index.d.ts +3 -3
  23. package/exceptions/index.d.ts +2 -2
  24. package/fesm/470.js +2713 -0
  25. package/fesm/509.js +793 -0
  26. package/fesm/667.js +606 -0
  27. package/fesm/67.js +808 -0
  28. package/fesm/720.js +914 -0
  29. package/{cjs/classes/event-transports/rabbitmq-transport.optional.js → fesm/chunks/123.js} +78 -55
  30. package/fesm/{classes/event-transports/kafka-transport.optional.js → chunks/37.js} +74 -41
  31. package/fesm/classes/index.js +62 -12
  32. package/fesm/constants/index.js +445 -17
  33. package/fesm/decorators/index.js +341 -6
  34. package/fesm/dtos/index.js +23 -6
  35. package/fesm/entities/index.js +336 -3
  36. package/fesm/enums/index.js +57 -3
  37. package/fesm/exceptions/index.js +280 -2
  38. package/fesm/guards/index.js +1003 -3
  39. package/fesm/index.js +1524 -14
  40. package/fesm/interceptors/index.js +924 -5
  41. package/fesm/interfaces/index.js +57 -11
  42. package/fesm/middlewares/index.js +33 -1
  43. package/fesm/modules/index.js +432 -9
  44. package/fesm/runtime.js +134 -0
  45. package/fesm/utils/index.js +1045 -8
  46. package/filters/global-exception.filter.d.ts +1 -1
  47. package/filters/index.d.ts +1 -1
  48. package/guards/index.d.ts +3 -3
  49. package/guards/jwt-auth.guard.d.ts +1 -1
  50. package/guards/optional-jwt-auth.guard.d.ts +1 -1
  51. package/guards/permission.guard.d.ts +2 -2
  52. package/index.d.ts +14 -14
  53. package/interceptors/delete-empty-id-from-body.interceptor.d.ts +1 -1
  54. package/interceptors/idempotency.interceptor.d.ts +2 -2
  55. package/interceptors/index.d.ts +5 -5
  56. package/interceptors/response-meta.interceptor.d.ts +1 -1
  57. package/interceptors/set-user-field-on-body.interceptor.d.ts +1 -1
  58. package/interceptors/slug.interceptor.d.ts +2 -2
  59. package/interfaces/ai-assistant-adapter.interface.d.ts +1 -1
  60. package/interfaces/api.interface.d.ts +2 -2
  61. package/interfaces/datasource.interface.d.ts +1 -1
  62. package/interfaces/event-manager-adapter.interface.d.ts +2 -2
  63. package/interfaces/index.d.ts +11 -11
  64. package/interfaces/module-config.interface.d.ts +1 -1
  65. package/interfaces/notification-adapter.interface.d.ts +1 -1
  66. package/middlewares/index.d.ts +1 -1
  67. package/middlewares/logger.middleware.d.ts +2 -2
  68. package/modules/cache/cache.module.d.ts +1 -1
  69. package/modules/datasource/index.d.ts +1 -1
  70. package/modules/datasource/multi-tenant-datasource.service.d.ts +4 -4
  71. package/modules/event-bus/event-bus.explorer.d.ts +2 -2
  72. package/modules/event-bus/event-bus.module.d.ts +2 -2
  73. package/modules/event-bus/module-events.provider.d.ts +1 -1
  74. package/modules/index.d.ts +9 -9
  75. package/modules/shared-permission-cache/shared-permission-cache.service.d.ts +3 -3
  76. package/modules/utils/utils.service.d.ts +1 -1
  77. package/package.json +30 -44
  78. package/utils/index.d.ts +8 -8
  79. package/utils/permission-cache-key.util.d.ts +1 -1
  80. package/utils/query-helpers.util.d.ts +2 -2
  81. package/utils/request.util.d.ts +1 -1
  82. package/cjs/classes/api-controller.class.js +0 -728
  83. package/cjs/classes/api-controller.class.spec.js +0 -684
  84. package/cjs/classes/api-service.class.js +0 -631
  85. package/cjs/classes/api-service.class.spec.js +0 -1137
  86. package/cjs/classes/disabled-event-bus.class.js +0 -15
  87. package/cjs/classes/disabled-event-bus.class.spec.js +0 -40
  88. package/cjs/classes/domain-event.publisher.js +0 -76
  89. package/cjs/classes/domain-event.publisher.spec.js +0 -234
  90. package/cjs/classes/event-bus.registry.js +0 -68
  91. package/cjs/classes/event-bus.registry.spec.js +0 -141
  92. package/cjs/classes/event-transports/event-transport.registry.js +0 -41
  93. package/cjs/classes/event-transports/event-transport.registry.spec.js +0 -31
  94. package/cjs/classes/event-transports/index.js +0 -23
  95. package/cjs/classes/event-transports/kafka-transport.optional.js +0 -151
  96. package/cjs/classes/event-transports/kafka-transport.optional.spec.js +0 -198
  97. package/cjs/classes/event-transports/memory-transport.js +0 -53
  98. package/cjs/classes/event-transports/memory-transport.spec.js +0 -57
  99. package/cjs/classes/event-transports/rabbitmq-transport.optional.spec.js +0 -255
  100. package/cjs/classes/handle-custome-db.js +0 -37
  101. package/cjs/classes/handle-custome-db.spec.js +0 -82
  102. package/cjs/classes/hybrid-cache.class.js +0 -96
  103. package/cjs/classes/hybrid-cache.class.spec.js +0 -168
  104. package/cjs/classes/hybrid-event-bus.class.js +0 -281
  105. package/cjs/classes/hybrid-event-bus.class.spec.js +0 -218
  106. package/cjs/classes/index.js +0 -28
  107. package/cjs/classes/winston.logger.class.js +0 -274
  108. package/cjs/classes/winston.logger.class.spec.js +0 -330
  109. package/cjs/constants/index.js +0 -88
  110. package/cjs/constants/message-keys.js +0 -68
  111. package/cjs/constants/permissions.js +0 -297
  112. package/cjs/decorators/api-response.decorator.js +0 -52
  113. package/cjs/decorators/api-response.decorator.spec.js +0 -126
  114. package/cjs/decorators/current-user.decorator.js +0 -16
  115. package/cjs/decorators/current-user.decorator.spec.js +0 -74
  116. package/cjs/decorators/index.js +0 -23
  117. package/cjs/decorators/log-action.decorator.js +0 -149
  118. package/cjs/decorators/log-action.decorator.spec.js +0 -353
  119. package/cjs/decorators/on-domain-event.decorator.js +0 -13
  120. package/cjs/decorators/on-domain-event.decorator.spec.js +0 -50
  121. package/cjs/decorators/public.decorator.js +0 -13
  122. package/cjs/decorators/public.decorator.spec.js +0 -50
  123. package/cjs/decorators/require-permission.decorator.js +0 -32
  124. package/cjs/decorators/require-permission.decorator.spec.js +0 -147
  125. package/cjs/dtos/delete.dto.js +0 -92
  126. package/cjs/dtos/filter-and-pagination.dto.js +0 -164
  127. package/cjs/dtos/get-by-ids.dto.js +0 -65
  128. package/cjs/dtos/identity-response.dto.js +0 -108
  129. package/cjs/dtos/index.js +0 -23
  130. package/cjs/dtos/pagination.dto.js +0 -67
  131. package/cjs/dtos/response-payload.dto.js +0 -369
  132. package/cjs/entities/identity.js +0 -100
  133. package/cjs/entities/index.js +0 -20
  134. package/cjs/entities/raw-type.js +0 -4
  135. package/cjs/entities/user-root.js +0 -189
  136. package/cjs/enums/index.js +0 -20
  137. package/cjs/enums/notification-type.enum.js +0 -17
  138. package/cjs/enums/participant-status.enum.js +0 -17
  139. package/cjs/enums/recurrence-type.enum.js +0 -18
  140. package/cjs/exceptions/base-app.exception.js +0 -151
  141. package/cjs/exceptions/base-app.exception.spec.js +0 -157
  142. package/cjs/exceptions/index.js +0 -19
  143. package/cjs/exceptions/permission.exception.js +0 -56
  144. package/cjs/exceptions/permission.exception.spec.js +0 -82
  145. package/cjs/filters/global-exception.filter.js +0 -279
  146. package/cjs/filters/global-exception.filter.spec.js +0 -440
  147. package/cjs/filters/index.js +0 -18
  148. package/cjs/guards/index.js +0 -20
  149. package/cjs/guards/jwt-auth.guard.js +0 -75
  150. package/cjs/guards/jwt-auth.guard.spec.js +0 -75
  151. package/cjs/guards/optional-jwt-auth.guard.js +0 -67
  152. package/cjs/guards/optional-jwt-auth.guard.spec.js +0 -55
  153. package/cjs/guards/permission.guard.js +0 -179
  154. package/cjs/guards/permission.guard.spec.js +0 -373
  155. package/cjs/index.js +0 -31
  156. package/cjs/interceptors/delete-empty-id-from-body.interceptor.js +0 -40
  157. package/cjs/interceptors/delete-empty-id-from-body.interceptor.spec.js +0 -107
  158. package/cjs/interceptors/idempotency.interceptor.js +0 -96
  159. package/cjs/interceptors/idempotency.interceptor.spec.js +0 -116
  160. package/cjs/interceptors/index.js +0 -22
  161. package/cjs/interceptors/response-meta.interceptor.js +0 -47
  162. package/cjs/interceptors/response-meta.interceptor.spec.js +0 -89
  163. package/cjs/interceptors/set-user-field-on-body.interceptor.js +0 -60
  164. package/cjs/interceptors/set-user-field-on-body.interceptor.spec.js +0 -128
  165. package/cjs/interceptors/slug.interceptor.js +0 -75
  166. package/cjs/interceptors/slug.interceptor.spec.js +0 -110
  167. package/cjs/interfaces/ai-assistant-adapter.interface.js +0 -24
  168. package/cjs/interfaces/api.interface.js +0 -4
  169. package/cjs/interfaces/datasource.interface.js +0 -4
  170. package/cjs/interfaces/event-bus.interface.js +0 -4
  171. package/cjs/interfaces/event-manager-adapter.interface.js +0 -11
  172. package/cjs/interfaces/identity.interface.js +0 -4
  173. package/cjs/interfaces/index.js +0 -28
  174. package/cjs/interfaces/logged-user-info.interface.js +0 -6
  175. package/cjs/interfaces/module-config.interface.js +0 -4
  176. package/cjs/interfaces/notification-adapter.interface.js +0 -11
  177. package/cjs/interfaces/permission-sync-adapter.interface.js +0 -11
  178. package/cjs/interfaces/permission.interface.js +0 -4
  179. package/cjs/middlewares/index.js +0 -18
  180. package/cjs/middlewares/logger.middleware.js +0 -264
  181. package/cjs/middlewares/logger.middleware.spec.js +0 -462
  182. package/cjs/modules/cache/cache.module.js +0 -39
  183. package/cjs/modules/cache/cache.module.spec.js +0 -48
  184. package/cjs/modules/datasource/index.js +0 -18
  185. package/cjs/modules/datasource/multi-tenant-datasource.service.js +0 -222
  186. package/cjs/modules/datasource/multi-tenant-datasource.service.spec.js +0 -381
  187. package/cjs/modules/event-bus/event-bus.explorer.js +0 -124
  188. package/cjs/modules/event-bus/event-bus.explorer.spec.js +0 -189
  189. package/cjs/modules/event-bus/event-bus.integration.spec.js +0 -253
  190. package/cjs/modules/event-bus/event-bus.module.js +0 -94
  191. package/cjs/modules/event-bus/event-bus.module.spec.js +0 -149
  192. package/cjs/modules/event-bus/module-events.provider.js +0 -39
  193. package/cjs/modules/event-bus/module-events.provider.spec.js +0 -56
  194. package/cjs/modules/index.js +0 -26
  195. package/cjs/modules/shared-permission-cache/shared-permission-cache.module.js +0 -32
  196. package/cjs/modules/shared-permission-cache/shared-permission-cache.service.js +0 -101
  197. package/cjs/modules/shared-permission-cache/shared-permission-cache.service.spec.js +0 -165
  198. package/cjs/modules/utils/utils.module.js +0 -32
  199. package/cjs/modules/utils/utils.service.js +0 -76
  200. package/cjs/modules/utils/utils.service.spec.js +0 -169
  201. package/cjs/utils/date-time.util.js +0 -94
  202. package/cjs/utils/date-time.util.spec.js +0 -84
  203. package/cjs/utils/event-pattern.util.js +0 -103
  204. package/cjs/utils/event-pattern.util.spec.js +0 -251
  205. package/cjs/utils/html-sanitizer.util.js +0 -64
  206. package/cjs/utils/html-sanitizer.util.spec.js +0 -76
  207. package/cjs/utils/index.js +0 -25
  208. package/cjs/utils/optional-module.util.js +0 -35
  209. package/cjs/utils/optional-module.util.spec.js +0 -14
  210. package/cjs/utils/permission-cache-key.util.js +0 -31
  211. package/cjs/utils/permission-cache-key.util.spec.js +0 -88
  212. package/cjs/utils/query-helpers.util.js +0 -60
  213. package/cjs/utils/query-helpers.util.spec.js +0 -209
  214. package/cjs/utils/request.util.js +0 -96
  215. package/cjs/utils/request.util.spec.js +0 -249
  216. package/cjs/utils/string.util.js +0 -63
  217. package/cjs/utils/string.util.spec.js +0 -63
  218. package/fesm/classes/api-controller.class.js +0 -718
  219. package/fesm/classes/api-controller.class.spec.js +0 -680
  220. package/fesm/classes/api-service.class.js +0 -621
  221. package/fesm/classes/api-service.class.spec.js +0 -1133
  222. package/fesm/classes/disabled-event-bus.class.js +0 -11
  223. package/fesm/classes/disabled-event-bus.class.spec.js +0 -36
  224. package/fesm/classes/domain-event.publisher.js +0 -63
  225. package/fesm/classes/domain-event.publisher.spec.js +0 -230
  226. package/fesm/classes/event-bus.registry.js +0 -64
  227. package/fesm/classes/event-bus.registry.spec.js +0 -137
  228. package/fesm/classes/event-transports/event-transport.registry.js +0 -35
  229. package/fesm/classes/event-transports/event-transport.registry.spec.js +0 -27
  230. package/fesm/classes/event-transports/index.js +0 -6
  231. package/fesm/classes/event-transports/kafka-transport.optional.spec.js +0 -194
  232. package/fesm/classes/event-transports/memory-transport.js +0 -49
  233. package/fesm/classes/event-transports/memory-transport.spec.js +0 -53
  234. package/fesm/classes/event-transports/rabbitmq-transport.optional.js +0 -174
  235. package/fesm/classes/event-transports/rabbitmq-transport.optional.spec.js +0 -251
  236. package/fesm/classes/handle-custome-db.js +0 -19
  237. package/fesm/classes/handle-custome-db.spec.js +0 -78
  238. package/fesm/classes/hybrid-cache.class.js +0 -81
  239. package/fesm/classes/hybrid-cache.class.spec.js +0 -164
  240. package/fesm/classes/hybrid-event-bus.class.js +0 -237
  241. package/fesm/classes/hybrid-event-bus.class.spec.js +0 -214
  242. package/fesm/classes/winston.logger.class.js +0 -228
  243. package/fesm/classes/winston.logger.class.spec.js +0 -327
  244. package/fesm/constants/message-keys.js +0 -49
  245. package/fesm/constants/permissions.js +0 -208
  246. package/fesm/decorators/api-response.decorator.js +0 -42
  247. package/fesm/decorators/api-response.decorator.spec.js +0 -122
  248. package/fesm/decorators/current-user.decorator.js +0 -18
  249. package/fesm/decorators/current-user.decorator.spec.js +0 -73
  250. package/fesm/decorators/log-action.decorator.js +0 -139
  251. package/fesm/decorators/log-action.decorator.spec.js +0 -349
  252. package/fesm/decorators/on-domain-event.decorator.js +0 -10
  253. package/fesm/decorators/on-domain-event.decorator.spec.js +0 -46
  254. package/fesm/decorators/public.decorator.js +0 -20
  255. package/fesm/decorators/public.decorator.spec.js +0 -46
  256. package/fesm/decorators/require-permission.decorator.js +0 -27
  257. package/fesm/decorators/require-permission.decorator.spec.js +0 -143
  258. package/fesm/dtos/delete.dto.js +0 -82
  259. package/fesm/dtos/filter-and-pagination.dto.js +0 -148
  260. package/fesm/dtos/get-by-ids.dto.js +0 -55
  261. package/fesm/dtos/identity-response.dto.js +0 -98
  262. package/fesm/dtos/pagination.dto.js +0 -57
  263. package/fesm/dtos/response-payload.dto.js +0 -336
  264. package/fesm/entities/identity.js +0 -90
  265. package/fesm/entities/raw-type.js +0 -1
  266. package/fesm/entities/user-root.js +0 -179
  267. package/fesm/enums/notification-type.enum.js +0 -7
  268. package/fesm/enums/participant-status.enum.js +0 -7
  269. package/fesm/enums/recurrence-type.enum.js +0 -8
  270. package/fesm/exceptions/base-app.exception.js +0 -115
  271. package/fesm/exceptions/base-app.exception.spec.js +0 -153
  272. package/fesm/exceptions/permission.exception.js +0 -35
  273. package/fesm/exceptions/permission.exception.spec.js +0 -78
  274. package/fesm/filters/global-exception.filter.js +0 -269
  275. package/fesm/filters/global-exception.filter.spec.js +0 -436
  276. package/fesm/filters/index.js +0 -1
  277. package/fesm/guards/jwt-auth.guard.js +0 -65
  278. package/fesm/guards/jwt-auth.guard.spec.js +0 -71
  279. package/fesm/guards/optional-jwt-auth.guard.js +0 -57
  280. package/fesm/guards/optional-jwt-auth.guard.spec.js +0 -51
  281. package/fesm/guards/permission.guard.js +0 -169
  282. package/fesm/guards/permission.guard.spec.js +0 -369
  283. package/fesm/interceptors/delete-empty-id-from-body.interceptor.js +0 -30
  284. package/fesm/interceptors/delete-empty-id-from-body.interceptor.spec.js +0 -103
  285. package/fesm/interceptors/idempotency.interceptor.js +0 -86
  286. package/fesm/interceptors/idempotency.interceptor.spec.js +0 -112
  287. package/fesm/interceptors/response-meta.interceptor.js +0 -37
  288. package/fesm/interceptors/response-meta.interceptor.spec.js +0 -85
  289. package/fesm/interceptors/set-user-field-on-body.interceptor.js +0 -39
  290. package/fesm/interceptors/set-user-field-on-body.interceptor.spec.js +0 -124
  291. package/fesm/interceptors/slug.interceptor.js +0 -65
  292. package/fesm/interceptors/slug.interceptor.spec.js +0 -106
  293. package/fesm/interfaces/ai-assistant-adapter.interface.js +0 -3
  294. package/fesm/interfaces/api.interface.js +0 -1
  295. package/fesm/interfaces/datasource.interface.js +0 -1
  296. package/fesm/interfaces/event-bus.interface.js +0 -1
  297. package/fesm/interfaces/event-manager-adapter.interface.js +0 -1
  298. package/fesm/interfaces/identity.interface.js +0 -1
  299. package/fesm/interfaces/logged-user-info.interface.js +0 -3
  300. package/fesm/interfaces/module-config.interface.js +0 -5
  301. package/fesm/interfaces/notification-adapter.interface.js +0 -1
  302. package/fesm/interfaces/permission-sync-adapter.interface.js +0 -1
  303. package/fesm/interfaces/permission.interface.js +0 -1
  304. package/fesm/middlewares/logger.middleware.js +0 -235
  305. package/fesm/middlewares/logger.middleware.spec.js +0 -459
  306. package/fesm/modules/cache/cache.module.js +0 -29
  307. package/fesm/modules/cache/cache.module.spec.js +0 -44
  308. package/fesm/modules/datasource/index.js +0 -1
  309. package/fesm/modules/datasource/multi-tenant-datasource.service.js +0 -212
  310. package/fesm/modules/datasource/multi-tenant-datasource.service.spec.js +0 -377
  311. package/fesm/modules/event-bus/event-bus.explorer.js +0 -114
  312. package/fesm/modules/event-bus/event-bus.explorer.spec.js +0 -185
  313. package/fesm/modules/event-bus/event-bus.integration.spec.js +0 -249
  314. package/fesm/modules/event-bus/event-bus.module.js +0 -84
  315. package/fesm/modules/event-bus/event-bus.module.spec.js +0 -145
  316. package/fesm/modules/event-bus/module-events.provider.js +0 -26
  317. package/fesm/modules/event-bus/module-events.provider.spec.js +0 -52
  318. package/fesm/modules/shared-permission-cache/shared-permission-cache.module.js +0 -22
  319. package/fesm/modules/shared-permission-cache/shared-permission-cache.service.js +0 -91
  320. package/fesm/modules/shared-permission-cache/shared-permission-cache.service.spec.js +0 -161
  321. package/fesm/modules/utils/utils.module.js +0 -22
  322. package/fesm/modules/utils/utils.service.js +0 -66
  323. package/fesm/modules/utils/utils.service.spec.js +0 -165
  324. package/fesm/utils/date-time.util.js +0 -70
  325. package/fesm/utils/date-time.util.spec.js +0 -80
  326. package/fesm/utils/event-pattern.util.js +0 -91
  327. package/fesm/utils/event-pattern.util.spec.js +0 -247
  328. package/fesm/utils/html-sanitizer.util.js +0 -69
  329. package/fesm/utils/html-sanitizer.util.spec.js +0 -72
  330. package/fesm/utils/optional-module.util.js +0 -25
  331. package/fesm/utils/optional-module.util.spec.js +0 -10
  332. package/fesm/utils/permission-cache-key.util.js +0 -10
  333. package/fesm/utils/permission-cache-key.util.spec.js +0 -84
  334. package/fesm/utils/query-helpers.util.js +0 -85
  335. package/fesm/utils/query-helpers.util.spec.js +0 -205
  336. package/fesm/utils/request.util.js +0 -81
  337. package/fesm/utils/request.util.spec.js +0 -245
  338. package/fesm/utils/string.util.js +0 -71
  339. package/fesm/utils/string.util.spec.js +0 -59
@@ -1,718 +0,0 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
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
- function _ts_metadata(k, v) {
21
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
- }
23
- function _ts_param(paramIndex, decorator) {
24
- return function(target, key) {
25
- decorator(target, key, paramIndex);
26
- };
27
- }
28
- import { applyDecorators, Body, HttpCode, HttpStatus, Param, Post, Query, UseGuards, UseInterceptors, Version, VERSION_NEUTRAL } from '@nestjs/common';
29
- import { ApiBearerAuth, ApiBody, ApiExcludeEndpoint, ApiHeader, ApiOperation, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger';
30
- import { plainToInstance } from 'class-transformer';
31
- import { ERROR_MESSAGES } from '../constants/message-keys';
32
- import { CurrentUser, Public, RequireAnyPermission, RequirePermission, RequirePermissionLogic } from '../decorators';
33
- import { ApiResponseDto } from '../decorators/api-response.decorator';
34
- import { DeleteDto, FilterAndPaginationDto, GetByIdBodyDto, GetByIdsDto } from '../dtos';
35
- import { BaseAppException, NotFoundException } from '../exceptions';
36
- import { JwtAuthGuard, PermissionGuard } from '../guards';
37
- import { IdempotencyInterceptor, SetCreatedByOnBody, SetDeletedByOnBody, SetUpdateByOnBody, Slug } from '../interceptors';
38
- /**
39
- * Helper to normalize security config
40
- */ function normalizeSecurity(config) {
41
- if (!config) return {
42
- level: 'public'
43
- };
44
- if (typeof config === 'string') return {
45
- level: config
46
- };
47
- return config;
48
- }
49
- /**
50
- * Helper to check if endpoint is enabled
51
- */ function isEndpointEnabled(endpoint, enabledEndpoints) {
52
- if (!enabledEndpoints || enabledEndpoints === 'all') return true;
53
- return enabledEndpoints.includes(endpoint);
54
- }
55
- /**
56
- * Helper to conditionally exclude endpoint from Swagger if disabled
57
- */ function createEndpointDecorators(security, endpoint, enabledEndpoints) {
58
- const decorators = [];
59
- // Add security decorators
60
- decorators.push(createSecurityDecorators(security));
61
- // Exclude from Swagger if endpoint is disabled
62
- if (!isEndpointEnabled(endpoint, enabledEndpoints)) {
63
- decorators.push(ApiExcludeEndpoint());
64
- }
65
- return applyDecorators(...decorators);
66
- }
67
- /**
68
- * Creates security decorators based on configuration
69
- */ function createSecurityDecorators(security) {
70
- const decorators = [];
71
- switch(security.level){
72
- case 'public':
73
- decorators.push(Public());
74
- break;
75
- case 'jwt':
76
- // Apply JWT authentication guard
77
- decorators.push(UseGuards(JwtAuthGuard));
78
- decorators.push(ApiBearerAuth());
79
- break;
80
- case 'permission':
81
- // Apply JWT authentication guard (required for permission checks)
82
- // Apply PermissionGuard to check permissions from cache
83
- decorators.push(UseGuards(JwtAuthGuard, PermissionGuard));
84
- decorators.push(ApiBearerAuth());
85
- // Check for complex logic first
86
- if (security.logic) {
87
- decorators.push(RequirePermissionLogic(security.logic));
88
- } else if (security.permissions && security.permissions.length > 0) {
89
- if (security.operator === 'OR') {
90
- decorators.push(RequireAnyPermission(...security.permissions));
91
- } else {
92
- // AND is default and most secure
93
- decorators.push(RequirePermission(...security.permissions));
94
- }
95
- }
96
- break;
97
- }
98
- return applyDecorators(...decorators);
99
- }
100
- /** Creates an API Controller with standardized CRUD endpoints (POST-only RPC pattern) */ export function createApiController(createDtoClass, updateDtoClass, responseDtoClass, options = {}) {
101
- const excludeExtraneousValues = options.excludeExtraneousValues ?? true;
102
- function toDto(cls, input) {
103
- return plainToInstance(cls, input, {
104
- excludeExtraneousValues
105
- });
106
- }
107
- // Entity name for message keys (defaults to 'item')
108
- const entityName = options.entityName ?? 'item';
109
- // Determine if security is global (applies to all) or per-endpoint
110
- const securityConfig = options.security;
111
- const endpointKeys = [
112
- 'insert',
113
- 'insertMany',
114
- 'getById',
115
- 'getByIds',
116
- 'getAll',
117
- 'bulkUpsert',
118
- 'getByFilter',
119
- 'update',
120
- 'updateMany',
121
- 'delete'
122
- ];
123
- // Global security if:
124
- // 1. It's a string (SecurityLevel)
125
- // 2. It's an object with 'level' property but no endpoint keys
126
- const isGlobalSecurity = typeof securityConfig === 'string' || securityConfig && typeof securityConfig === 'object' && 'level' in securityConfig && !endpointKeys.some((key)=>key in securityConfig);
127
- // Normalize security config for each endpoint
128
- // IMPORTANT: When per-endpoint security is specified, default to 'jwt' for unconfigured endpoints
129
- // to prevent accidentally exposing endpoints without authentication
130
- const defaultSecurity = isGlobalSecurity ? normalizeSecurity(securityConfig) : {
131
- level: 'jwt'
132
- };
133
- const security = {
134
- insert: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.insert),
135
- insertMany: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.insertMany),
136
- getById: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getById),
137
- getByIds: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getByIds),
138
- getAll: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getAll),
139
- getByFilter: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getByFilter),
140
- bulkUpsert: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.bulkUpsert),
141
- update: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.update),
142
- updateMany: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.updateMany),
143
- delete: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.delete)
144
- };
145
- let ApiController = class ApiController {
146
- isEnabled(endpoint) {
147
- if (this.enabledEndpoints === 'all') return true;
148
- return Array.isArray(this.enabledEndpoints) && this.enabledEndpoints.includes(endpoint);
149
- }
150
- async insert(addDto, user) {
151
- if (!this.isEnabled('insert')) {
152
- throw new BaseAppException({
153
- message: `Endpoint 'insert' is disabled`,
154
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
155
- messageVariables: {
156
- endpoint: 'insert'
157
- },
158
- status: HttpStatus.FORBIDDEN
159
- });
160
- }
161
- const entity = await this.service.insert(addDto, user);
162
- const data = toDto(responseDtoClass, entity);
163
- return {
164
- success: true,
165
- message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} created successfully`,
166
- messageKey: `${entityName}.create.success`,
167
- data
168
- };
169
- }
170
- async insertMany(addDto, user) {
171
- if (!this.isEnabled('insertMany')) {
172
- throw new BaseAppException({
173
- message: `Endpoint 'insertMany' is disabled`,
174
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
175
- messageVariables: {
176
- endpoint: 'insertMany'
177
- },
178
- status: HttpStatus.FORBIDDEN
179
- });
180
- }
181
- const entities = await this.service.insertMany(addDto, user);
182
- const data = entities.map((item)=>toDto(responseDtoClass, item));
183
- return {
184
- success: true,
185
- message: `${data.length} ${entityName}s created successfully`,
186
- messageKey: `${entityName}.create.many.success`,
187
- messageVariables: {
188
- count: data.length
189
- },
190
- data,
191
- meta: {
192
- count: data.length,
193
- total: addDto.length,
194
- failed: addDto.length - data.length
195
- }
196
- };
197
- }
198
- async getById(id, body, user) {
199
- if (!this.isEnabled('getById')) {
200
- throw new BaseAppException({
201
- message: `Endpoint 'getById' is disabled`,
202
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
203
- messageVariables: {
204
- endpoint: 'getById'
205
- },
206
- status: HttpStatus.FORBIDDEN
207
- });
208
- }
209
- const entity = await this.service.findById(id, user, body?.select);
210
- const data = toDto(responseDtoClass, entity);
211
- return {
212
- success: true,
213
- message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} retrieved successfully`,
214
- messageKey: `${entityName}.get.success`,
215
- data
216
- };
217
- }
218
- async getByIds(body, user) {
219
- if (!this.isEnabled('getByIds')) {
220
- throw new BaseAppException({
221
- message: `Endpoint 'getByIds' is disabled`,
222
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
223
- messageVariables: {
224
- endpoint: 'getByIds'
225
- },
226
- status: HttpStatus.FORBIDDEN
227
- });
228
- }
229
- const entities = await this.service.findByIds(body.ids, user, body?.select);
230
- const data = entities.map((item)=>toDto(responseDtoClass, item));
231
- return {
232
- success: true,
233
- message: `${data.length} ${entityName}${data.length !== 1 ? 's' : ''} retrieved successfully`,
234
- messageKey: `${entityName}.get.by.ids.success`,
235
- data,
236
- meta: {
237
- total: data.length,
238
- page: 0,
239
- pageSize: data.length,
240
- count: data.length,
241
- totalPages: 1
242
- }
243
- };
244
- }
245
- async update(updateDto, user) {
246
- if (!this.isEnabled('update')) {
247
- throw new BaseAppException({
248
- message: `Endpoint 'update' is disabled`,
249
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
250
- messageVariables: {
251
- endpoint: 'update'
252
- },
253
- status: HttpStatus.FORBIDDEN
254
- });
255
- }
256
- const entity = await this.service.update(updateDto, user);
257
- const data = toDto(responseDtoClass, entity);
258
- return {
259
- success: true,
260
- message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} updated successfully`,
261
- messageKey: `${entityName}.update.success`,
262
- data
263
- };
264
- }
265
- async updateMany(updateDtos, user) {
266
- if (!this.isEnabled('updateMany')) {
267
- throw new BaseAppException({
268
- message: `Endpoint 'updateMany' is disabled`,
269
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
270
- messageVariables: {
271
- endpoint: 'updateMany'
272
- },
273
- status: HttpStatus.FORBIDDEN
274
- });
275
- }
276
- const entities = await this.service.updateMany(updateDtos, user);
277
- const data = entities.map((item)=>toDto(responseDtoClass, item));
278
- return {
279
- success: true,
280
- message: `${data.length} ${entityName}s updated successfully`,
281
- messageKey: `${entityName}.update.many.success`,
282
- messageVariables: {
283
- count: data.length
284
- },
285
- data,
286
- meta: {
287
- count: data.length,
288
- total: updateDtos.length,
289
- failed: updateDtos.length - data.length
290
- }
291
- };
292
- }
293
- async bulkUpsert(dtos, user) {
294
- if (!this.isEnabled('bulkUpsert')) {
295
- throw new BaseAppException({
296
- message: `Endpoint 'bulkUpsert' is disabled`,
297
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
298
- messageVariables: {
299
- endpoint: 'bulkUpsert'
300
- },
301
- status: HttpStatus.FORBIDDEN
302
- });
303
- }
304
- const toInsert = [];
305
- const toUpdate = [];
306
- for (const dto of dtos){
307
- if ('id' in dto && dto.id) {
308
- toUpdate.push(dto);
309
- } else {
310
- toInsert.push(dto);
311
- }
312
- }
313
- const allEntities = await this.service.bulkUpsert(toInsert, toUpdate, user);
314
- const data = allEntities.map((item)=>toDto(responseDtoClass, item));
315
- return {
316
- success: true,
317
- message: `${data.length} ${entityName}s upserted successfully`,
318
- messageKey: `${entityName}.upsert.many.success`,
319
- messageVariables: {
320
- count: data.length
321
- },
322
- data,
323
- meta: {
324
- count: data.length,
325
- total: dtos.length,
326
- failed: dtos.length - data.length
327
- }
328
- };
329
- }
330
- async getByFilter(filter, user) {
331
- if (!this.isEnabled('getByFilter')) {
332
- throw new BaseAppException({
333
- message: `Endpoint 'getByFilter' is disabled`,
334
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
335
- messageVariables: {
336
- endpoint: 'getByFilter'
337
- },
338
- status: HttpStatus.FORBIDDEN
339
- });
340
- }
341
- const result = await this.service.getAll('', {
342
- filter,
343
- pagination: {
344
- currentPage: 0,
345
- pageSize: 1
346
- }
347
- }, user);
348
- if (!result.data || result.data.length === 0) {
349
- throw new NotFoundException(entityName);
350
- }
351
- const entity = result.data[0];
352
- const data = toDto(responseDtoClass, entity);
353
- return {
354
- success: true,
355
- message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} retrieved successfully`,
356
- messageKey: `${entityName}.get.by.filter.success`,
357
- data
358
- };
359
- }
360
- async getAll(filterAndPaginationDto, user, search) {
361
- if (!this.isEnabled('getAll')) {
362
- throw new BaseAppException({
363
- message: `Endpoint 'getAll' is disabled`,
364
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
365
- messageVariables: {
366
- endpoint: 'getAll'
367
- },
368
- status: HttpStatus.FORBIDDEN
369
- });
370
- }
371
- const result = await this.service.getAll(search ?? '', filterAndPaginationDto, user);
372
- const data = result.data.map((item)=>toDto(responseDtoClass, item));
373
- const page = filterAndPaginationDto.pagination?.currentPage ?? 0;
374
- const pageSize = filterAndPaginationDto.pagination?.pageSize ?? data.length;
375
- const totalPages = pageSize > 0 ? Math.ceil(result.total / pageSize) : 1;
376
- return {
377
- success: true,
378
- message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)}s retrieved successfully`,
379
- messageKey: `${entityName}.get.all.success`,
380
- data,
381
- meta: {
382
- total: result.total,
383
- page,
384
- pageSize,
385
- count: data.length,
386
- hasMore: page < totalPages - 1,
387
- totalPages
388
- }
389
- };
390
- }
391
- async delete(deleteDto, user) {
392
- if (!this.isEnabled('delete')) {
393
- throw new BaseAppException({
394
- message: `Endpoint 'delete' is disabled`,
395
- messageKey: ERROR_MESSAGES.ENDPOINT_DISABLED,
396
- messageVariables: {
397
- endpoint: 'delete'
398
- },
399
- status: HttpStatus.FORBIDDEN
400
- });
401
- }
402
- await this.service.delete(deleteDto, user);
403
- const count = Array.isArray(deleteDto.id) ? deleteDto.id.length : 1;
404
- const action = deleteDto.type === 'restore' ? 'restore' : 'delete';
405
- return {
406
- success: true,
407
- message: `${count} ${entityName}${count > 1 ? 's' : ''} ${action}d successfully`,
408
- messageKey: `${entityName}.${action}.success`,
409
- messageVariables: {
410
- count
411
- }
412
- };
413
- }
414
- constructor(service){
415
- _define_property(this, "service", void 0);
416
- _define_property(this, "enabledEndpoints", void 0);
417
- this.service = service;
418
- this.enabledEndpoints = options.enabledEndpoints ?? 'all';
419
- }
420
- };
421
- _ts_decorate([
422
- createEndpointDecorators(security.insert, 'insert', options.enabledEndpoints),
423
- Version(VERSION_NEUTRAL),
424
- Post('insert'),
425
- HttpCode(HttpStatus.CREATED),
426
- ApiOperation({
427
- summary: 'Insert one item',
428
- description: 'Creates a new item. Supports idempotency via X-Idempotency-Key header.'
429
- }),
430
- ApiHeader({
431
- name: 'X-Idempotency-Key',
432
- required: false,
433
- description: 'Unique key to prevent duplicate submissions (recommended for production)'
434
- }),
435
- ApiResponseDto(responseDtoClass),
436
- ApiBody({
437
- type: createDtoClass
438
- }),
439
- UseInterceptors(IdempotencyInterceptor, SetCreatedByOnBody, Slug),
440
- _ts_param(0, Body()),
441
- _ts_param(1, CurrentUser()),
442
- _ts_metadata("design:type", Function),
443
- _ts_metadata("design:paramtypes", [
444
- typeof CreateDtoT === "undefined" ? Object : CreateDtoT,
445
- Object
446
- ]),
447
- _ts_metadata("design:returntype", Promise)
448
- ], ApiController.prototype, "insert", null);
449
- _ts_decorate([
450
- createEndpointDecorators(security.insertMany, 'insertMany', options.enabledEndpoints),
451
- Version(VERSION_NEUTRAL),
452
- Post('insert-many'),
453
- HttpCode(HttpStatus.CREATED),
454
- ApiOperation({
455
- summary: 'Insert multiple items',
456
- description: 'Creates multiple items in a single request. Supports idempotency.'
457
- }),
458
- ApiHeader({
459
- name: 'X-Idempotency-Key',
460
- required: false,
461
- description: 'Unique key to prevent duplicate submissions'
462
- }),
463
- ApiResponseDto(responseDtoClass, true, 'bulk'),
464
- ApiBody({
465
- type: createDtoClass,
466
- isArray: true
467
- }),
468
- UseInterceptors(IdempotencyInterceptor, SetCreatedByOnBody, Slug),
469
- _ts_param(0, Body()),
470
- _ts_param(1, CurrentUser()),
471
- _ts_metadata("design:type", Function),
472
- _ts_metadata("design:paramtypes", [
473
- Array,
474
- Object
475
- ]),
476
- _ts_metadata("design:returntype", Promise)
477
- ], ApiController.prototype, "insertMany", null);
478
- _ts_decorate([
479
- createEndpointDecorators(security.getById, 'getById', options.enabledEndpoints),
480
- Version(VERSION_NEUTRAL),
481
- Post('get/:id'),
482
- HttpCode(HttpStatus.OK),
483
- ApiOperation({
484
- summary: 'Get item by ID',
485
- description: 'Retrieves a single item by ID. Optionally specify fields to select and relations to include.'
486
- }),
487
- ApiParam({
488
- name: 'id',
489
- type: String,
490
- description: 'UUID of the item'
491
- }),
492
- ApiBody({
493
- type: GetByIdBodyDto,
494
- required: false
495
- }),
496
- ApiResponseDto(responseDtoClass),
497
- _ts_param(0, Param('id')),
498
- _ts_param(1, Body()),
499
- _ts_param(2, CurrentUser()),
500
- _ts_metadata("design:type", Function),
501
- _ts_metadata("design:paramtypes", [
502
- String,
503
- typeof GetByIdBodyDto === "undefined" ? Object : GetByIdBodyDto,
504
- Object
505
- ]),
506
- _ts_metadata("design:returntype", Promise)
507
- ], ApiController.prototype, "getById", null);
508
- _ts_decorate([
509
- createEndpointDecorators(security.getByIds, 'getByIds', options.enabledEndpoints),
510
- Version(VERSION_NEUTRAL),
511
- Post('get-by-ids'),
512
- HttpCode(HttpStatus.OK),
513
- ApiOperation({
514
- summary: 'Get items by IDs',
515
- description: 'Retrieves multiple items by their IDs. Optionally specify fields to select.'
516
- }),
517
- ApiBody({
518
- type: GetByIdsDto
519
- }),
520
- ApiResponseDto(responseDtoClass, true, 'list'),
521
- _ts_param(0, Body()),
522
- _ts_param(1, CurrentUser()),
523
- _ts_metadata("design:type", Function),
524
- _ts_metadata("design:paramtypes", [
525
- typeof GetByIdsDto === "undefined" ? Object : GetByIdsDto,
526
- Object
527
- ]),
528
- _ts_metadata("design:returntype", Promise)
529
- ], ApiController.prototype, "getByIds", null);
530
- _ts_decorate([
531
- createEndpointDecorators(security.update, 'update', options.enabledEndpoints),
532
- Version(VERSION_NEUTRAL),
533
- Post('update'),
534
- HttpCode(HttpStatus.OK),
535
- ApiOperation({
536
- summary: 'Update one item',
537
- description: 'Updates an existing item. ID must be included in the body.'
538
- }),
539
- ApiResponseDto(responseDtoClass),
540
- ApiBody({
541
- type: updateDtoClass
542
- }),
543
- UseInterceptors(SetUpdateByOnBody, Slug),
544
- _ts_param(0, Body()),
545
- _ts_param(1, CurrentUser()),
546
- _ts_metadata("design:type", Function),
547
- _ts_metadata("design:paramtypes", [
548
- typeof UpdateDtoT === "undefined" ? Object : UpdateDtoT,
549
- Object
550
- ]),
551
- _ts_metadata("design:returntype", Promise)
552
- ], ApiController.prototype, "update", null);
553
- _ts_decorate([
554
- createEndpointDecorators(security.updateMany, 'updateMany', options.enabledEndpoints),
555
- Version(VERSION_NEUTRAL),
556
- Post('update-many'),
557
- HttpCode(HttpStatus.OK),
558
- ApiOperation({
559
- summary: 'Update multiple items',
560
- description: 'Updates multiple items in a single request. Each item must include an ID.'
561
- }),
562
- ApiResponseDto(responseDtoClass, true, 'bulk'),
563
- ApiBody({
564
- type: updateDtoClass,
565
- isArray: true
566
- }),
567
- UseInterceptors(SetUpdateByOnBody, Slug),
568
- _ts_param(0, Body()),
569
- _ts_param(1, CurrentUser()),
570
- _ts_metadata("design:type", Function),
571
- _ts_metadata("design:paramtypes", [
572
- Array,
573
- Object
574
- ]),
575
- _ts_metadata("design:returntype", Promise)
576
- ], ApiController.prototype, "updateMany", null);
577
- _ts_decorate([
578
- createEndpointDecorators(security.bulkUpsert, 'bulkUpsert', options.enabledEndpoints),
579
- Version(VERSION_NEUTRAL),
580
- Post('bulk-upsert'),
581
- HttpCode(HttpStatus.OK),
582
- ApiOperation({
583
- summary: 'Create or update multiple items',
584
- description: 'Bulk upsert: items without ID are created, items with ID are updated.'
585
- }),
586
- ApiResponseDto(responseDtoClass, true, 'bulk'),
587
- ApiBody({
588
- type: createDtoClass,
589
- isArray: true
590
- }),
591
- UseInterceptors(SetCreatedByOnBody, SetUpdateByOnBody, Slug),
592
- _ts_param(0, Body()),
593
- _ts_param(1, CurrentUser()),
594
- _ts_metadata("design:type", Function),
595
- _ts_metadata("design:paramtypes", [
596
- Array,
597
- Object
598
- ]),
599
- _ts_metadata("design:returntype", Promise)
600
- ], ApiController.prototype, "bulkUpsert", null);
601
- _ts_decorate([
602
- createEndpointDecorators(security.getByFilter, 'getByFilter', options.enabledEndpoints),
603
- Version(VERSION_NEUTRAL),
604
- Post('get-by-filter'),
605
- HttpCode(HttpStatus.OK),
606
- ApiOperation({
607
- summary: 'Get single item by filter',
608
- description: 'Retrieves a single item matching the provided filter criteria. Returns first match if multiple exist.'
609
- }),
610
- ApiBody({
611
- schema: {
612
- type: 'object',
613
- description: 'Filter criteria'
614
- }
615
- }),
616
- ApiResponseDto(responseDtoClass),
617
- _ts_param(0, Body()),
618
- _ts_param(1, CurrentUser()),
619
- _ts_metadata("design:type", Function),
620
- _ts_metadata("design:paramtypes", [
621
- typeof Record === "undefined" ? Object : Record,
622
- Object
623
- ]),
624
- _ts_metadata("design:returntype", Promise)
625
- ], ApiController.prototype, "getByFilter", null);
626
- _ts_decorate([
627
- createEndpointDecorators(security.getAll, 'getAll', options.enabledEndpoints),
628
- Version(VERSION_NEUTRAL),
629
- Post('get-all'),
630
- HttpCode(HttpStatus.OK),
631
- ApiOperation({
632
- summary: 'Get all items with filters and pagination',
633
- description: 'Supports filter, pagination, sort, select, withDeleted, and q (search) params'
634
- }),
635
- ApiQuery({
636
- name: 'q',
637
- required: false,
638
- description: 'Global text search across searchable fields'
639
- }),
640
- ApiBody({
641
- type: FilterAndPaginationDto
642
- }),
643
- ApiResponseDto(responseDtoClass, true, 'list'),
644
- _ts_param(0, Body()),
645
- _ts_param(1, CurrentUser()),
646
- _ts_param(2, Query('q')),
647
- _ts_metadata("design:type", Function),
648
- _ts_metadata("design:paramtypes", [
649
- typeof FilterAndPaginationDto === "undefined" ? Object : FilterAndPaginationDto,
650
- Object,
651
- String
652
- ]),
653
- _ts_metadata("design:returntype", Promise)
654
- ], ApiController.prototype, "getAll", null);
655
- _ts_decorate([
656
- createEndpointDecorators(security.delete, 'delete', options.enabledEndpoints),
657
- Version(VERSION_NEUTRAL),
658
- Post('delete'),
659
- HttpCode(HttpStatus.OK),
660
- ApiOperation({
661
- summary: 'Delete, restore, or permanently remove items',
662
- description: 'Types: delete (soft), restore, permanent. Supports batch IDs.'
663
- }),
664
- ApiResponse({
665
- status: 200,
666
- description: 'Operation completed successfully',
667
- schema: {
668
- example: {
669
- success: true,
670
- message: '3 items deleted successfully'
671
- }
672
- }
673
- }),
674
- ApiBody({
675
- type: DeleteDto,
676
- examples: {
677
- softDelete: {
678
- summary: 'Soft delete',
679
- value: {
680
- id: [
681
- 'uuid-1',
682
- 'uuid-2'
683
- ],
684
- type: 'delete'
685
- }
686
- },
687
- restore: {
688
- summary: 'Restore deleted',
689
- value: {
690
- id: [
691
- 'uuid-1'
692
- ],
693
- type: 'restore'
694
- }
695
- },
696
- permanent: {
697
- summary: 'Permanent delete',
698
- value: {
699
- id: [
700
- 'uuid-1'
701
- ],
702
- type: 'permanent'
703
- }
704
- }
705
- }
706
- }),
707
- UseInterceptors(SetDeletedByOnBody),
708
- _ts_param(0, Body()),
709
- _ts_param(1, CurrentUser()),
710
- _ts_metadata("design:type", Function),
711
- _ts_metadata("design:paramtypes", [
712
- typeof DeleteDto === "undefined" ? Object : DeleteDto,
713
- Object
714
- ]),
715
- _ts_metadata("design:returntype", Promise)
716
- ], ApiController.prototype, "delete", null);
717
- return ApiController;
718
- }