@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
package/fesm/470.js ADDED
@@ -0,0 +1,2713 @@
1
+ import * as __rspack_external_crypto from "crypto";
2
+ import * as __rspack_external__nestjs_passport_18907953 from "@nestjs/passport";
3
+ import * as __rspack_external_rxjs from "rxjs";
4
+ import * as __rspack_external_rxjs_operators_2eaa0997 from "rxjs/operators";
5
+ export const __rspack_esm_id = 470;
6
+ export const __rspack_esm_ids = [470];
7
+ export const __webpack_modules__ = {
8
+ 504(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
9
+ /* import */ var _flusys_nestjs_core__rspack_import_0 = __webpack_require__(436);
10
+
11
+ function getJsonColumnType() {
12
+ const driver = _flusys_nestjs_core__rspack_import_0.envConfig.getTypeOrmConfig().type;
13
+ if (driver === 'postgres') return 'jsonb';
14
+ if (driver === 'mysql') return 'json';
15
+ return 'simple-json';
16
+ }
17
+ function getCastIntType() {
18
+ const driver = _flusys_nestjs_core__rspack_import_0.envConfig.getTypeOrmConfig().type;
19
+ return driver === 'postgres' ? 'INTEGER' : 'UNSIGNED';
20
+ }
21
+ /**
22
+ * Converts MySQL-style `?` placeholders to PostgreSQL `$1, $2, ...` placeholders.
23
+ * No-op for MySQL/MariaDB.
24
+ */ function buildQuery(sql, dbType) {
25
+ if (dbType !== 'postgres') return sql;
26
+ let index = 0;
27
+ return sql.replace(/\?/g, ()=>`$${++index}`);
28
+ }
29
+
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ Tj: () => (getCastIntType),
32
+ Zq: () => (buildQuery),
33
+ pf: () => (getJsonColumnType)
34
+ });
35
+
36
+
37
+ },
38
+ 405(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
39
+
40
+ // EXPORTS
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ Y7: () => (/* reexport */ permissions/* .ACTION_PERMISSIONS */.Y7),
43
+ Bz: () => (/* reexport */ permissions/* .AI_ASSISTANT_PERMISSIONS */.Bz),
44
+ Gf: () => (/* reexport */ ApiService),
45
+ wA: () => (/* reexport */ permissions/* .BRANCH_PERMISSIONS */.wA),
46
+ aO: () => (/* reexport */ permissions/* .COMPANY_ACTION_PERMISSIONS */.aO),
47
+ t$: () => (/* reexport */ permissions/* .COMPANY_PERMISSIONS */.t$),
48
+ xC: () => (/* reexport */ (/* inlined export .DOMAIN_EVENT_VERSION */1)),
49
+ XI: () => (/* reexport */ disabled_event_bus_class/* .DisabledEventBus */.X),
50
+ V0: () => (/* reexport */ permissions/* .EMAIL_CONFIG_PERMISSIONS */.V0),
51
+ z$: () => (/* reexport */ permissions/* .EMAIL_TEMPLATE_PERMISSIONS */.z$),
52
+ Ub: () => (/* reexport */ permissions/* .EVENT_PERMISSIONS */.Ub),
53
+ qS: () => (/* reexport */ event_bus_registry/* .EventBusRegistry */.q),
54
+ Pm: () => (/* reexport */ event_transport_registry/* .EventTransportRegistry */.P),
55
+ S6: () => (/* reexport */ permissions/* .FILE_PERMISSIONS */.S6),
56
+ wM: () => (/* reexport */ permissions/* .FOLDER_PERMISSIONS */.wM),
57
+ Wc: () => (/* reexport */ permissions/* .FORM_PERMISSIONS */.Wc),
58
+ GT: () => (/* reexport */ permissions/* .FORM_RESULT_PERMISSIONS */.GT),
59
+ lx: () => (/* reexport */ hybrid_cache_class/* .HybridCache */.l),
60
+ Zk: () => (/* reexport */ hybrid_event_bus_class/* .HybridEventBus */.Z),
61
+ Q5: () => (/* reexport */ permissions/* .LANGUAGE_PERMISSIONS */.Q5),
62
+ PS: () => (/* reexport */ memory_transport/* .MemoryTransport */.P),
63
+ rH: () => (/* reexport */ permissions/* .NOTIFICATION_PERMISSIONS */.rH),
64
+ Jj: () => (/* reexport */ permissions/* .PERMISSIONS */.Jj),
65
+ P0: () => (/* reexport */ permissions/* .ROLE_ACTION_PERMISSIONS */.P0),
66
+ mV: () => (/* reexport */ permissions/* .ROLE_PERMISSIONS */.mV),
67
+ l3: () => (/* reexport */ permissions/* .SOCIAL_AUTH_CONFIG_PERMISSIONS */.l3),
68
+ Em: () => (/* reexport */ permissions/* .STORAGE_CONFIG_PERMISSIONS */.Em),
69
+ Y3: () => (/* reexport */ permissions/* .TASK_BOARD_PERMISSIONS */.Y3),
70
+ zd: () => (/* reexport */ permissions/* .TASK_COMMENT_PERMISSIONS */.zd),
71
+ UG: () => (/* reexport */ permissions/* .TASK_LABEL_PERMISSIONS */.UG),
72
+ ON: () => (/* reexport */ permissions/* .TASK_LIST_PERMISSIONS */.ON),
73
+ T: () => (/* reexport */ permissions/* .TASK_PERMISSIONS */.T),
74
+ N3: () => (/* reexport */ permissions/* .TRANSLATION_KEY_PERMISSIONS */.N3),
75
+ fS: () => (/* reexport */ permissions/* .TRANSLATION_PERMISSIONS */.fS),
76
+ UB: () => (/* reexport */ permissions/* .UPLOAD_CONFIG_PERMISSIONS */.UB),
77
+ _X: () => (/* reexport */ permissions/* .USER_ACTION_PERMISSIONS */._X),
78
+ BC: () => (/* reexport */ permissions/* .USER_PERMISSIONS */.BC),
79
+ w7: () => (/* reexport */ permissions/* .USER_ROLE_PERMISSIONS */.w7),
80
+ rv: () => (/* reexport */ buildDomainEvent),
81
+ Zq: () => (/* reexport */ handle_custome_db/* .buildQuery */.Zq),
82
+ RD: () => (/* reexport */ createApiController),
83
+ Xv: () => (/* reexport */ winston_logger_class/* .createModuleLogger */.X),
84
+ Tj: () => (/* reexport */ handle_custome_db/* .getCastIntType */.Tj),
85
+ pf: () => (/* reexport */ handle_custome_db/* .getJsonColumnType */.pf),
86
+ KJ: () => (/* reexport */ winston_logger_class/* .instance */.K),
87
+ wT: () => (/* reexport */ publishDomainEvent)
88
+ });
89
+
90
+ // EXTERNAL MODULE: external "@nestjs/common"
91
+ var common_ = __webpack_require__(157);
92
+ // EXTERNAL MODULE: external "@nestjs/swagger"
93
+ var swagger_ = __webpack_require__(176);
94
+ // EXTERNAL MODULE: external "class-transformer"
95
+ var external_class_transformer_ = __webpack_require__(812);
96
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/message-keys.ts
97
+ var message_keys = __webpack_require__(389);
98
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/index.ts + 4 modules
99
+ var src_decorators = __webpack_require__(523);
100
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/api-response.decorator.ts
101
+ var api_response_decorator = __webpack_require__(997);
102
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/dtos/index.ts + 7 modules
103
+ var src_dtos = __webpack_require__(980);
104
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/exceptions/index.ts
105
+ var exceptions = __webpack_require__(448);
106
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/guards/index.ts + 4 modules
107
+ var guards = __webpack_require__(510);
108
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/interceptors/index.ts + 7 modules
109
+ var interceptors = __webpack_require__(863);
110
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/classes/api-controller.class.ts
111
+ function _ts_decorate(decorators, target, key, desc) {
112
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
113
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
114
+ r = Reflect.decorate(decorators, target, key, desc);
115
+ } else {
116
+ for(var i = decorators.length - 1; i >= 0; i--){
117
+ if (d = decorators[i]) {
118
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
119
+ }
120
+ }
121
+ }
122
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
123
+ }
124
+ function _ts_metadata(metadataKey, metadataValue) {
125
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
126
+ return Reflect.metadata(metadataKey, metadataValue);
127
+ }
128
+ }
129
+ function _ts_param(paramIndex, decorator) {
130
+ return function(target, key) {
131
+ decorator(target, key, paramIndex);
132
+ };
133
+ }
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+ /**
145
+ * Helper to normalize security config
146
+ */ function normalizeSecurity(config) {
147
+ if (!config) return {
148
+ level: 'public'
149
+ };
150
+ if (typeof config === 'string') return {
151
+ level: config
152
+ };
153
+ return config;
154
+ }
155
+ /**
156
+ * Helper to check if endpoint is enabled
157
+ */ function isEndpointEnabled(endpoint, enabledEndpoints) {
158
+ if (!enabledEndpoints || enabledEndpoints === 'all') return true;
159
+ return enabledEndpoints.includes(endpoint);
160
+ }
161
+ /**
162
+ * Helper to conditionally exclude endpoint from Swagger if disabled
163
+ */ function createEndpointDecorators(security, endpoint, enabledEndpoints) {
164
+ const decorators = [];
165
+ // Add security decorators
166
+ decorators.push(createSecurityDecorators(security));
167
+ // Exclude from Swagger if endpoint is disabled
168
+ if (!isEndpointEnabled(endpoint, enabledEndpoints)) {
169
+ decorators.push((0,swagger_.ApiExcludeEndpoint)());
170
+ }
171
+ return (0,common_.applyDecorators)(...decorators);
172
+ }
173
+ /**
174
+ * Creates security decorators based on configuration
175
+ */ function createSecurityDecorators(security) {
176
+ const decorators = [];
177
+ switch(security.level){
178
+ case 'public':
179
+ decorators.push((0,src_decorators/* .Public */.w3)());
180
+ break;
181
+ case 'jwt':
182
+ // Apply JWT authentication guard
183
+ decorators.push((0,common_.UseGuards)(guards/* .JwtAuthGuard */.TD));
184
+ decorators.push((0,swagger_.ApiBearerAuth)());
185
+ break;
186
+ case 'permission':
187
+ // Apply JWT authentication guard (required for permission checks)
188
+ // Apply PermissionGuard to check permissions from cache
189
+ decorators.push((0,common_.UseGuards)(guards/* .JwtAuthGuard */.TD, guards/* .PermissionGuard */.LQ));
190
+ decorators.push((0,swagger_.ApiBearerAuth)());
191
+ // Check for complex logic first
192
+ if (security.logic) {
193
+ decorators.push((0,src_decorators/* .RequirePermissionLogic */.rY)(security.logic));
194
+ } else if (security.permissions && security.permissions.length > 0) {
195
+ if (security.operator === 'OR') {
196
+ decorators.push((0,src_decorators/* .RequireAnyPermission */.Dz)(...security.permissions));
197
+ } else {
198
+ // AND is default and most secure
199
+ decorators.push((0,src_decorators/* .RequirePermission */.Tw)(...security.permissions));
200
+ }
201
+ }
202
+ break;
203
+ }
204
+ return (0,common_.applyDecorators)(...decorators);
205
+ }
206
+ /** Creates an API Controller with standardized CRUD endpoints (POST-only RPC pattern) */ function createApiController(createDtoClass, updateDtoClass, responseDtoClass, options = {}) {
207
+ const excludeExtraneousValues = options.excludeExtraneousValues ?? true;
208
+ function toDto(cls, input) {
209
+ return (0,external_class_transformer_.plainToInstance)(cls, input, {
210
+ excludeExtraneousValues
211
+ });
212
+ }
213
+ // Entity name for message keys (defaults to 'item')
214
+ const entityName = options.entityName ?? 'item';
215
+ // Determine if security is global (applies to all) or per-endpoint
216
+ const securityConfig = options.security;
217
+ const endpointKeys = [
218
+ 'insert',
219
+ 'insertMany',
220
+ 'getById',
221
+ 'getByIds',
222
+ 'getAll',
223
+ 'bulkUpsert',
224
+ 'getByFilter',
225
+ 'update',
226
+ 'updateMany',
227
+ 'delete'
228
+ ];
229
+ // Global security if:
230
+ // 1. It's a string (SecurityLevel)
231
+ // 2. It's an object with 'level' property but no endpoint keys
232
+ const isGlobalSecurity = typeof securityConfig === 'string' || securityConfig && typeof securityConfig === 'object' && 'level' in securityConfig && !endpointKeys.some((key)=>key in securityConfig);
233
+ // Normalize security config for each endpoint
234
+ // IMPORTANT: When per-endpoint security is specified, default to 'jwt' for unconfigured endpoints
235
+ // to prevent accidentally exposing endpoints without authentication
236
+ const defaultSecurity = isGlobalSecurity ? normalizeSecurity(securityConfig) : {
237
+ level: 'jwt'
238
+ };
239
+ const security = {
240
+ insert: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.insert),
241
+ insertMany: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.insertMany),
242
+ getById: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getById),
243
+ getByIds: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getByIds),
244
+ getAll: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getAll),
245
+ getByFilter: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.getByFilter),
246
+ bulkUpsert: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.bulkUpsert),
247
+ update: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.update),
248
+ updateMany: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.updateMany),
249
+ delete: isGlobalSecurity ? defaultSecurity : normalizeSecurity(securityConfig?.delete)
250
+ };
251
+ let ApiController = class ApiController {
252
+ service;
253
+ enabledEndpoints = options.enabledEndpoints ?? 'all';
254
+ constructor(service){
255
+ this.service = service;
256
+ }
257
+ isEnabled(endpoint) {
258
+ if (this.enabledEndpoints === 'all') return true;
259
+ return Array.isArray(this.enabledEndpoints) && this.enabledEndpoints.includes(endpoint);
260
+ }
261
+ async insert(addDto, user) {
262
+ if (!this.isEnabled('insert')) {
263
+ throw new exceptions/* .BaseAppException */.m8({
264
+ message: `Endpoint 'insert' is disabled`,
265
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
266
+ messageVariables: {
267
+ endpoint: 'insert'
268
+ },
269
+ status: common_.HttpStatus.FORBIDDEN
270
+ });
271
+ }
272
+ const entity = await this.service.insert(addDto, user);
273
+ const data = toDto(responseDtoClass, entity);
274
+ return {
275
+ success: true,
276
+ message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} created successfully`,
277
+ messageKey: `${entityName}.create.success`,
278
+ data
279
+ };
280
+ }
281
+ async insertMany(addDto, user) {
282
+ if (!this.isEnabled('insertMany')) {
283
+ throw new exceptions/* .BaseAppException */.m8({
284
+ message: `Endpoint 'insertMany' is disabled`,
285
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
286
+ messageVariables: {
287
+ endpoint: 'insertMany'
288
+ },
289
+ status: common_.HttpStatus.FORBIDDEN
290
+ });
291
+ }
292
+ const entities = await this.service.insertMany(addDto, user);
293
+ const data = entities.map((item)=>toDto(responseDtoClass, item));
294
+ return {
295
+ success: true,
296
+ message: `${data.length} ${entityName}s created successfully`,
297
+ messageKey: `${entityName}.create.many.success`,
298
+ messageVariables: {
299
+ count: data.length
300
+ },
301
+ data,
302
+ meta: {
303
+ count: data.length,
304
+ total: addDto.length,
305
+ failed: addDto.length - data.length
306
+ }
307
+ };
308
+ }
309
+ async getById(id, body, user) {
310
+ if (!this.isEnabled('getById')) {
311
+ throw new exceptions/* .BaseAppException */.m8({
312
+ message: `Endpoint 'getById' is disabled`,
313
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
314
+ messageVariables: {
315
+ endpoint: 'getById'
316
+ },
317
+ status: common_.HttpStatus.FORBIDDEN
318
+ });
319
+ }
320
+ const entity = await this.service.findById(id, user, body?.select);
321
+ const data = toDto(responseDtoClass, entity);
322
+ return {
323
+ success: true,
324
+ message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} retrieved successfully`,
325
+ messageKey: `${entityName}.get.success`,
326
+ data
327
+ };
328
+ }
329
+ async getByIds(body, user) {
330
+ if (!this.isEnabled('getByIds')) {
331
+ throw new exceptions/* .BaseAppException */.m8({
332
+ message: `Endpoint 'getByIds' is disabled`,
333
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
334
+ messageVariables: {
335
+ endpoint: 'getByIds'
336
+ },
337
+ status: common_.HttpStatus.FORBIDDEN
338
+ });
339
+ }
340
+ const entities = await this.service.findByIds(body.ids, user, body?.select);
341
+ const data = entities.map((item)=>toDto(responseDtoClass, item));
342
+ return {
343
+ success: true,
344
+ message: `${data.length} ${entityName}${data.length !== 1 ? 's' : ''} retrieved successfully`,
345
+ messageKey: `${entityName}.get.by.ids.success`,
346
+ data,
347
+ meta: {
348
+ total: data.length,
349
+ page: 0,
350
+ pageSize: data.length,
351
+ count: data.length,
352
+ totalPages: 1
353
+ }
354
+ };
355
+ }
356
+ async update(updateDto, user) {
357
+ if (!this.isEnabled('update')) {
358
+ throw new exceptions/* .BaseAppException */.m8({
359
+ message: `Endpoint 'update' is disabled`,
360
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
361
+ messageVariables: {
362
+ endpoint: 'update'
363
+ },
364
+ status: common_.HttpStatus.FORBIDDEN
365
+ });
366
+ }
367
+ const entity = await this.service.update(updateDto, user);
368
+ const data = toDto(responseDtoClass, entity);
369
+ return {
370
+ success: true,
371
+ message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} updated successfully`,
372
+ messageKey: `${entityName}.update.success`,
373
+ data
374
+ };
375
+ }
376
+ async updateMany(updateDtos, user) {
377
+ if (!this.isEnabled('updateMany')) {
378
+ throw new exceptions/* .BaseAppException */.m8({
379
+ message: `Endpoint 'updateMany' is disabled`,
380
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
381
+ messageVariables: {
382
+ endpoint: 'updateMany'
383
+ },
384
+ status: common_.HttpStatus.FORBIDDEN
385
+ });
386
+ }
387
+ const entities = await this.service.updateMany(updateDtos, user);
388
+ const data = entities.map((item)=>toDto(responseDtoClass, item));
389
+ return {
390
+ success: true,
391
+ message: `${data.length} ${entityName}s updated successfully`,
392
+ messageKey: `${entityName}.update.many.success`,
393
+ messageVariables: {
394
+ count: data.length
395
+ },
396
+ data,
397
+ meta: {
398
+ count: data.length,
399
+ total: updateDtos.length,
400
+ failed: updateDtos.length - data.length
401
+ }
402
+ };
403
+ }
404
+ async bulkUpsert(dtos, user) {
405
+ if (!this.isEnabled('bulkUpsert')) {
406
+ throw new exceptions/* .BaseAppException */.m8({
407
+ message: `Endpoint 'bulkUpsert' is disabled`,
408
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
409
+ messageVariables: {
410
+ endpoint: 'bulkUpsert'
411
+ },
412
+ status: common_.HttpStatus.FORBIDDEN
413
+ });
414
+ }
415
+ const toInsert = [];
416
+ const toUpdate = [];
417
+ for (const dto of dtos){
418
+ if ('id' in dto && dto.id) {
419
+ toUpdate.push(dto);
420
+ } else {
421
+ toInsert.push(dto);
422
+ }
423
+ }
424
+ const allEntities = await this.service.bulkUpsert(toInsert, toUpdate, user);
425
+ const data = allEntities.map((item)=>toDto(responseDtoClass, item));
426
+ return {
427
+ success: true,
428
+ message: `${data.length} ${entityName}s upserted successfully`,
429
+ messageKey: `${entityName}.upsert.many.success`,
430
+ messageVariables: {
431
+ count: data.length
432
+ },
433
+ data,
434
+ meta: {
435
+ count: data.length,
436
+ total: dtos.length,
437
+ failed: dtos.length - data.length
438
+ }
439
+ };
440
+ }
441
+ async getByFilter(filter, user) {
442
+ if (!this.isEnabled('getByFilter')) {
443
+ throw new exceptions/* .BaseAppException */.m8({
444
+ message: `Endpoint 'getByFilter' is disabled`,
445
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
446
+ messageVariables: {
447
+ endpoint: 'getByFilter'
448
+ },
449
+ status: common_.HttpStatus.FORBIDDEN
450
+ });
451
+ }
452
+ const result = await this.service.getAll('', {
453
+ filter,
454
+ pagination: {
455
+ currentPage: 0,
456
+ pageSize: 1
457
+ }
458
+ }, user);
459
+ if (!result.data || result.data.length === 0) {
460
+ throw new exceptions/* .NotFoundException */.X6(entityName);
461
+ }
462
+ const entity = result.data[0];
463
+ const data = toDto(responseDtoClass, entity);
464
+ return {
465
+ success: true,
466
+ message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)} retrieved successfully`,
467
+ messageKey: `${entityName}.get.by.filter.success`,
468
+ data
469
+ };
470
+ }
471
+ async getAll(filterAndPaginationDto, user, search) {
472
+ if (!this.isEnabled('getAll')) {
473
+ throw new exceptions/* .BaseAppException */.m8({
474
+ message: `Endpoint 'getAll' is disabled`,
475
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
476
+ messageVariables: {
477
+ endpoint: 'getAll'
478
+ },
479
+ status: common_.HttpStatus.FORBIDDEN
480
+ });
481
+ }
482
+ const result = await this.service.getAll(search ?? '', filterAndPaginationDto, user);
483
+ const data = result.data.map((item)=>toDto(responseDtoClass, item));
484
+ const page = filterAndPaginationDto.pagination?.currentPage ?? 0;
485
+ const pageSize = filterAndPaginationDto.pagination?.pageSize ?? data.length;
486
+ const totalPages = pageSize > 0 ? Math.ceil(result.total / pageSize) : 1;
487
+ return {
488
+ success: true,
489
+ message: `${entityName.charAt(0).toUpperCase() + entityName.slice(1)}s retrieved successfully`,
490
+ messageKey: `${entityName}.get.all.success`,
491
+ data,
492
+ meta: {
493
+ total: result.total,
494
+ page,
495
+ pageSize,
496
+ count: data.length,
497
+ hasMore: page < totalPages - 1,
498
+ totalPages
499
+ }
500
+ };
501
+ }
502
+ async delete(deleteDto, user) {
503
+ if (!this.isEnabled('delete')) {
504
+ throw new exceptions/* .BaseAppException */.m8({
505
+ message: `Endpoint 'delete' is disabled`,
506
+ messageKey: message_keys/* .ERROR_MESSAGES.ENDPOINT_DISABLED */.UU.ENDPOINT_DISABLED,
507
+ messageVariables: {
508
+ endpoint: 'delete'
509
+ },
510
+ status: common_.HttpStatus.FORBIDDEN
511
+ });
512
+ }
513
+ await this.service.delete(deleteDto, user);
514
+ const count = Array.isArray(deleteDto.id) ? deleteDto.id.length : 1;
515
+ const action = deleteDto.type === 'restore' ? 'restore' : 'delete';
516
+ return {
517
+ success: true,
518
+ message: `${count} ${entityName}${count > 1 ? 's' : ''} ${action}d successfully`,
519
+ messageKey: `${entityName}.${action}.success`,
520
+ messageVariables: {
521
+ count
522
+ }
523
+ };
524
+ }
525
+ };
526
+ _ts_decorate([
527
+ createEndpointDecorators(security.insert, 'insert', options.enabledEndpoints),
528
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
529
+ (0,common_.Post)('insert'),
530
+ (0,common_.HttpCode)(common_.HttpStatus.CREATED),
531
+ (0,swagger_.ApiOperation)({
532
+ summary: 'Insert one item',
533
+ description: 'Creates a new item. Supports idempotency via X-Idempotency-Key header.'
534
+ }),
535
+ (0,swagger_.ApiHeader)({
536
+ name: 'X-Idempotency-Key',
537
+ required: false,
538
+ description: 'Unique key to prevent duplicate submissions (recommended for production)'
539
+ }),
540
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass),
541
+ (0,swagger_.ApiBody)({
542
+ type: createDtoClass
543
+ }),
544
+ (0,common_.UseInterceptors)(interceptors/* .IdempotencyInterceptor */.Bw, interceptors/* .SetCreatedByOnBody */.VS, interceptors/* .Slug */.Mw),
545
+ _ts_param(0, (0,common_.Body)()),
546
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
547
+ _ts_metadata("design:type", Function),
548
+ _ts_metadata("design:paramtypes", [
549
+ typeof CreateDtoT === "undefined" ? Object : CreateDtoT,
550
+ Object
551
+ ]),
552
+ _ts_metadata("design:returntype", Promise)
553
+ ], ApiController.prototype, "insert", null);
554
+ _ts_decorate([
555
+ createEndpointDecorators(security.insertMany, 'insertMany', options.enabledEndpoints),
556
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
557
+ (0,common_.Post)('insert-many'),
558
+ (0,common_.HttpCode)(common_.HttpStatus.CREATED),
559
+ (0,swagger_.ApiOperation)({
560
+ summary: 'Insert multiple items',
561
+ description: 'Creates multiple items in a single request. Supports idempotency.'
562
+ }),
563
+ (0,swagger_.ApiHeader)({
564
+ name: 'X-Idempotency-Key',
565
+ required: false,
566
+ description: 'Unique key to prevent duplicate submissions'
567
+ }),
568
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass, true, 'bulk'),
569
+ (0,swagger_.ApiBody)({
570
+ type: createDtoClass,
571
+ isArray: true
572
+ }),
573
+ (0,common_.UseInterceptors)(interceptors/* .IdempotencyInterceptor */.Bw, interceptors/* .SetCreatedByOnBody */.VS, interceptors/* .Slug */.Mw),
574
+ _ts_param(0, (0,common_.Body)()),
575
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
576
+ _ts_metadata("design:type", Function),
577
+ _ts_metadata("design:paramtypes", [
578
+ Array,
579
+ Object
580
+ ]),
581
+ _ts_metadata("design:returntype", Promise)
582
+ ], ApiController.prototype, "insertMany", null);
583
+ _ts_decorate([
584
+ createEndpointDecorators(security.getById, 'getById', options.enabledEndpoints),
585
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
586
+ (0,common_.Post)('get/:id'),
587
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
588
+ (0,swagger_.ApiOperation)({
589
+ summary: 'Get item by ID',
590
+ description: 'Retrieves a single item by ID. Optionally specify fields to select and relations to include.'
591
+ }),
592
+ (0,swagger_.ApiParam)({
593
+ name: 'id',
594
+ type: String,
595
+ description: 'UUID of the item'
596
+ }),
597
+ (0,swagger_.ApiBody)({
598
+ type: src_dtos/* .GetByIdBodyDto */.a8,
599
+ required: false
600
+ }),
601
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass),
602
+ _ts_param(0, (0,common_.Param)('id')),
603
+ _ts_param(1, (0,common_.Body)()),
604
+ _ts_param(2, (0,src_decorators/* .CurrentUser */.NO)()),
605
+ _ts_metadata("design:type", Function),
606
+ _ts_metadata("design:paramtypes", [
607
+ String,
608
+ typeof src_dtos/* .GetByIdBodyDto */.a8 === "undefined" ? Object : src_dtos/* .GetByIdBodyDto */.a8,
609
+ Object
610
+ ]),
611
+ _ts_metadata("design:returntype", Promise)
612
+ ], ApiController.prototype, "getById", null);
613
+ _ts_decorate([
614
+ createEndpointDecorators(security.getByIds, 'getByIds', options.enabledEndpoints),
615
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
616
+ (0,common_.Post)('get-by-ids'),
617
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
618
+ (0,swagger_.ApiOperation)({
619
+ summary: 'Get items by IDs',
620
+ description: 'Retrieves multiple items by their IDs. Optionally specify fields to select.'
621
+ }),
622
+ (0,swagger_.ApiBody)({
623
+ type: src_dtos/* .GetByIdsDto */.H$
624
+ }),
625
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass, true, 'list'),
626
+ _ts_param(0, (0,common_.Body)()),
627
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
628
+ _ts_metadata("design:type", Function),
629
+ _ts_metadata("design:paramtypes", [
630
+ typeof src_dtos/* .GetByIdsDto */.H$ === "undefined" ? Object : src_dtos/* .GetByIdsDto */.H$,
631
+ Object
632
+ ]),
633
+ _ts_metadata("design:returntype", Promise)
634
+ ], ApiController.prototype, "getByIds", null);
635
+ _ts_decorate([
636
+ createEndpointDecorators(security.update, 'update', options.enabledEndpoints),
637
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
638
+ (0,common_.Post)('update'),
639
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
640
+ (0,swagger_.ApiOperation)({
641
+ summary: 'Update one item',
642
+ description: 'Updates an existing item. ID must be included in the body.'
643
+ }),
644
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass),
645
+ (0,swagger_.ApiBody)({
646
+ type: updateDtoClass
647
+ }),
648
+ (0,common_.UseInterceptors)(interceptors/* .SetUpdateByOnBody */._x, interceptors/* .Slug */.Mw),
649
+ _ts_param(0, (0,common_.Body)()),
650
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
651
+ _ts_metadata("design:type", Function),
652
+ _ts_metadata("design:paramtypes", [
653
+ typeof UpdateDtoT === "undefined" ? Object : UpdateDtoT,
654
+ Object
655
+ ]),
656
+ _ts_metadata("design:returntype", Promise)
657
+ ], ApiController.prototype, "update", null);
658
+ _ts_decorate([
659
+ createEndpointDecorators(security.updateMany, 'updateMany', options.enabledEndpoints),
660
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
661
+ (0,common_.Post)('update-many'),
662
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
663
+ (0,swagger_.ApiOperation)({
664
+ summary: 'Update multiple items',
665
+ description: 'Updates multiple items in a single request. Each item must include an ID.'
666
+ }),
667
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass, true, 'bulk'),
668
+ (0,swagger_.ApiBody)({
669
+ type: updateDtoClass,
670
+ isArray: true
671
+ }),
672
+ (0,common_.UseInterceptors)(interceptors/* .SetUpdateByOnBody */._x, interceptors/* .Slug */.Mw),
673
+ _ts_param(0, (0,common_.Body)()),
674
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
675
+ _ts_metadata("design:type", Function),
676
+ _ts_metadata("design:paramtypes", [
677
+ Array,
678
+ Object
679
+ ]),
680
+ _ts_metadata("design:returntype", Promise)
681
+ ], ApiController.prototype, "updateMany", null);
682
+ _ts_decorate([
683
+ createEndpointDecorators(security.bulkUpsert, 'bulkUpsert', options.enabledEndpoints),
684
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
685
+ (0,common_.Post)('bulk-upsert'),
686
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
687
+ (0,swagger_.ApiOperation)({
688
+ summary: 'Create or update multiple items',
689
+ description: 'Bulk upsert: items without ID are created, items with ID are updated.'
690
+ }),
691
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass, true, 'bulk'),
692
+ (0,swagger_.ApiBody)({
693
+ type: createDtoClass,
694
+ isArray: true
695
+ }),
696
+ (0,common_.UseInterceptors)(interceptors/* .SetCreatedByOnBody */.VS, interceptors/* .SetUpdateByOnBody */._x, interceptors/* .Slug */.Mw),
697
+ _ts_param(0, (0,common_.Body)()),
698
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
699
+ _ts_metadata("design:type", Function),
700
+ _ts_metadata("design:paramtypes", [
701
+ Array,
702
+ Object
703
+ ]),
704
+ _ts_metadata("design:returntype", Promise)
705
+ ], ApiController.prototype, "bulkUpsert", null);
706
+ _ts_decorate([
707
+ createEndpointDecorators(security.getByFilter, 'getByFilter', options.enabledEndpoints),
708
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
709
+ (0,common_.Post)('get-by-filter'),
710
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
711
+ (0,swagger_.ApiOperation)({
712
+ summary: 'Get single item by filter',
713
+ description: 'Retrieves a single item matching the provided filter criteria. Returns first match if multiple exist.'
714
+ }),
715
+ (0,swagger_.ApiBody)({
716
+ schema: {
717
+ type: 'object',
718
+ description: 'Filter criteria'
719
+ }
720
+ }),
721
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass),
722
+ _ts_param(0, (0,common_.Body)()),
723
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
724
+ _ts_metadata("design:type", Function),
725
+ _ts_metadata("design:paramtypes", [
726
+ typeof Record === "undefined" ? Object : Record,
727
+ Object
728
+ ]),
729
+ _ts_metadata("design:returntype", Promise)
730
+ ], ApiController.prototype, "getByFilter", null);
731
+ _ts_decorate([
732
+ createEndpointDecorators(security.getAll, 'getAll', options.enabledEndpoints),
733
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
734
+ (0,common_.Post)('get-all'),
735
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
736
+ (0,swagger_.ApiOperation)({
737
+ summary: 'Get all items with filters and pagination',
738
+ description: 'Supports filter, pagination, sort, select, withDeleted, and q (search) params'
739
+ }),
740
+ (0,swagger_.ApiQuery)({
741
+ name: 'q',
742
+ required: false,
743
+ description: 'Global text search across searchable fields'
744
+ }),
745
+ (0,swagger_.ApiBody)({
746
+ type: src_dtos/* .FilterAndPaginationDto */.x
747
+ }),
748
+ (0,api_response_decorator/* .ApiResponseDto */.x)(responseDtoClass, true, 'list'),
749
+ _ts_param(0, (0,common_.Body)()),
750
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
751
+ _ts_param(2, (0,common_.Query)('q')),
752
+ _ts_metadata("design:type", Function),
753
+ _ts_metadata("design:paramtypes", [
754
+ typeof src_dtos/* .FilterAndPaginationDto */.x === "undefined" ? Object : src_dtos/* .FilterAndPaginationDto */.x,
755
+ Object,
756
+ String
757
+ ]),
758
+ _ts_metadata("design:returntype", Promise)
759
+ ], ApiController.prototype, "getAll", null);
760
+ _ts_decorate([
761
+ createEndpointDecorators(security.delete, 'delete', options.enabledEndpoints),
762
+ (0,common_.Version)(common_.VERSION_NEUTRAL),
763
+ (0,common_.Post)('delete'),
764
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
765
+ (0,swagger_.ApiOperation)({
766
+ summary: 'Delete, restore, or permanently remove items',
767
+ description: 'Types: delete (soft), restore, permanent. Supports batch IDs.'
768
+ }),
769
+ (0,swagger_.ApiResponse)({
770
+ status: 200,
771
+ description: 'Operation completed successfully',
772
+ schema: {
773
+ example: {
774
+ success: true,
775
+ message: '3 items deleted successfully'
776
+ }
777
+ }
778
+ }),
779
+ (0,swagger_.ApiBody)({
780
+ type: src_dtos/* .DeleteDto */.TG,
781
+ examples: {
782
+ softDelete: {
783
+ summary: 'Soft delete',
784
+ value: {
785
+ id: [
786
+ 'uuid-1',
787
+ 'uuid-2'
788
+ ],
789
+ type: 'delete'
790
+ }
791
+ },
792
+ restore: {
793
+ summary: 'Restore deleted',
794
+ value: {
795
+ id: [
796
+ 'uuid-1'
797
+ ],
798
+ type: 'restore'
799
+ }
800
+ },
801
+ permanent: {
802
+ summary: 'Permanent delete',
803
+ value: {
804
+ id: [
805
+ 'uuid-1'
806
+ ],
807
+ type: 'permanent'
808
+ }
809
+ }
810
+ }
811
+ }),
812
+ (0,common_.UseInterceptors)(interceptors/* .SetDeletedByOnBody */.Ul),
813
+ _ts_param(0, (0,common_.Body)()),
814
+ _ts_param(1, (0,src_decorators/* .CurrentUser */.NO)()),
815
+ _ts_metadata("design:type", Function),
816
+ _ts_metadata("design:paramtypes", [
817
+ typeof src_dtos/* .DeleteDto */.TG === "undefined" ? Object : src_dtos/* .DeleteDto */.TG,
818
+ Object
819
+ ]),
820
+ _ts_metadata("design:returntype", Promise)
821
+ ], ApiController.prototype, "delete", null);
822
+ return ApiController;
823
+ }
824
+
825
+ // EXTERNAL MODULE: external "typeorm"
826
+ var external_typeorm_ = __webpack_require__(158);
827
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/log-action.decorator.ts
828
+ var log_action_decorator = __webpack_require__(946);
829
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/modules/utils/utils.service.ts
830
+ var utils_service = __webpack_require__(169);
831
+ // EXTERNAL MODULE: external "crypto"
832
+ var external_crypto_ = __webpack_require__(823);
833
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/middlewares/logger.middleware.ts + 2 modules
834
+ var logger_middleware = __webpack_require__(419);
835
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/utils/event-pattern.util.ts
836
+ var event_pattern_util = __webpack_require__(456);
837
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/event-bus.registry.ts
838
+ var event_bus_registry = __webpack_require__(228);
839
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/classes/domain-event.publisher.ts
840
+
841
+
842
+
843
+
844
+ const DOMAIN_EVENT_VERSION = 1;
845
+ function buildDomainEvent(input) {
846
+ const rows = input.data === undefined ? [] : toArray(input.data);
847
+ const ids = input.ids ?? collectIds(rows);
848
+ return {
849
+ id: (0,external_crypto_.randomUUID)(),
850
+ name: `${input.module}.${input.entity}.${input.action}`,
851
+ module: input.module,
852
+ entity: input.entity,
853
+ action: input.action,
854
+ payload: {
855
+ ids,
856
+ ...rows.length && event_bus_registry/* .EventBusRegistry.shouldIncludePayload */.q.shouldIncludePayload(input.module) ? {
857
+ data: (0,event_pattern_util/* .sanitizeEventPayload */.IN)(rows)
858
+ } : {},
859
+ ...input.metadata ? {
860
+ metadata: (0,event_pattern_util/* .sanitizeEventPayload */.IN)(input.metadata)
861
+ } : {}
862
+ },
863
+ actor: {
864
+ userId: input.user?.id ?? null,
865
+ companyId: input.user?.companyId ?? (0,logger_middleware/* .getCompanyId */.xR)() ?? null,
866
+ tenantId: (0,logger_middleware/* .getTenantId */.EO)() ?? null,
867
+ requestId: (0,logger_middleware/* .getRequestId */.RE)() ?? null
868
+ },
869
+ occurredAt: new Date().toISOString(),
870
+ version: DOMAIN_EVENT_VERSION
871
+ };
872
+ }
873
+ /**
874
+ * Publishes a domain event for an operation that is not plain CRUD - a form
875
+ * submission, a login, a file upload. Honours the publishing module's own
876
+ * `events` config and never throws, so a broker outage cannot break the caller.
877
+ *
878
+ * Supplying `eventBus` chooses which bus to publish on; it never overrides the
879
+ * module's on/off switch, otherwise turning a module's events off would leave
880
+ * every service holding its own bus still publishing.
881
+ */ async function publishDomainEvent(input) {
882
+ const bus = input.eventBus ?? event_bus_registry/* .EventBusRegistry.getBus */.q.getBus();
883
+ if (!bus) return;
884
+ if (!event_bus_registry/* .EventBusRegistry.isEnabled */.q.isEnabled(input.module, input.entity, input.action)) return;
885
+ try {
886
+ await bus.publish(buildDomainEvent(input));
887
+ } catch {
888
+ // Events must never break the operation that produced them
889
+ }
890
+ }
891
+ function toArray(value) {
892
+ return Array.isArray(value) ? value : [
893
+ value
894
+ ];
895
+ }
896
+ function collectIds(rows) {
897
+ return rows.reduce((ids, row)=>{
898
+ const id = row?.id;
899
+ if (id) ids.push(id);
900
+ return ids;
901
+ }, []);
902
+ }
903
+
904
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/hybrid-cache.class.ts + 3 modules
905
+ var hybrid_cache_class = __webpack_require__(375);
906
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/classes/api-service.class.ts
907
+ function api_service_class_ts_decorate(decorators, target, key, desc) {
908
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
909
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
910
+ r = Reflect.decorate(decorators, target, key, desc);
911
+ } else {
912
+ for(var i = decorators.length - 1; i >= 0; i--){
913
+ if (d = decorators[i]) {
914
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
915
+ }
916
+ }
917
+ }
918
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
919
+ }
920
+ function api_service_class_ts_metadata(metadataKey, metadataValue) {
921
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
922
+ return Reflect.metadata(metadataKey, metadataValue);
923
+ }
924
+ }
925
+
926
+
927
+
928
+
929
+
930
+
931
+
932
+
933
+ const DELETE_EVENT_ACTIONS = {
934
+ delete: 'deleted',
935
+ restore: 'restored',
936
+ permanent: 'purged'
937
+ };
938
+ class ApiService {
939
+ entityName;
940
+ cacheManager;
941
+ utilsService;
942
+ _loggerName;
943
+ isCacheable;
944
+ moduleName;
945
+ repository;
946
+ repositoryInitialized = false;
947
+ _entity;
948
+ _dataSourceProvider;
949
+ /**
950
+ * `entity` is the table this service reads and writes. A service whose table
951
+ * depends on runtime config - the company feature, say - passes the ternary
952
+ * here, reading the injected config through the constructor parameter.
953
+ */ constructor(entityName, cacheManager, utilsService, _loggerName, isCacheable = false, moduleName, dataSourceProvider, entity){
954
+ this.entityName = entityName;
955
+ this.cacheManager = cacheManager;
956
+ this.utilsService = utilsService;
957
+ this._loggerName = _loggerName;
958
+ this.isCacheable = isCacheable;
959
+ this.moduleName = moduleName;
960
+ this._dataSourceProvider = dataSourceProvider;
961
+ this._entity = entity;
962
+ }
963
+ getDataSourceProvider() {
964
+ return this._dataSourceProvider;
965
+ }
966
+ async ensureDataSourceRepository() {
967
+ if (!this.repositoryInitialized) {
968
+ const provider = this.getDataSourceProvider();
969
+ this.repository = await provider.getRepository(this._entity);
970
+ this.repositoryInitialized = true;
971
+ }
972
+ }
973
+ async resolveRepositories(entities) {
974
+ const provider = this.getDataSourceProvider();
975
+ const repositories = [];
976
+ for (const entity of entities){
977
+ repositories.push(await provider.getRepository(entity));
978
+ }
979
+ return repositories;
980
+ }
981
+ async insert(dto, user) {
982
+ return this.executeInTransaction('created', async (qr)=>{
983
+ await this.beforeInsertOperation(dto, user, qr);
984
+ const entities = await this.convertRequestDtoToEntity(dto, user);
985
+ const saved = await qr.manager.save(this.repository.target, entities);
986
+ await this.afterInsertOperation(this.ensureArray(saved), dto, user, qr);
987
+ return {
988
+ saved,
989
+ returnFirst: true
990
+ };
991
+ }, user);
992
+ }
993
+ async insertMany(dtos, user) {
994
+ return this.executeInTransaction('created', async (qr)=>{
995
+ await this.beforeInsertOperation(dtos, user, qr);
996
+ const entities = await this.convertRequestDtoToEntity(dtos, user);
997
+ const saved = await qr.manager.save(this.repository.target, entities);
998
+ await this.afterInsertOperation(this.ensureArray(saved), dtos, user, qr);
999
+ return {
1000
+ saved,
1001
+ returnFirst: false
1002
+ };
1003
+ }, user);
1004
+ }
1005
+ async update(dto, user) {
1006
+ return this.executeInTransaction('updated', async (qr)=>{
1007
+ await this.beforeUpdateOperation(dto, user, qr);
1008
+ const entities = await this.convertRequestDtoToEntity(dto, user);
1009
+ const saved = await qr.manager.save(this.repository.target, entities);
1010
+ await this.afterUpdateOperation(this.ensureArray(saved), dto, user, qr);
1011
+ return {
1012
+ saved,
1013
+ returnFirst: true
1014
+ };
1015
+ }, user);
1016
+ }
1017
+ async updateMany(dtos, user) {
1018
+ return this.executeInTransaction('updated', async (qr)=>{
1019
+ await this.beforeUpdateOperation(dtos, user, qr);
1020
+ const entities = await this.convertRequestDtoToEntity(dtos, user);
1021
+ const saved = await qr.manager.save(this.repository.target, entities);
1022
+ await this.afterUpdateOperation(this.ensureArray(saved), dtos, user, qr);
1023
+ return {
1024
+ saved,
1025
+ returnFirst: false
1026
+ };
1027
+ }, user);
1028
+ }
1029
+ async bulkUpsert(toInsert, toUpdate, user) {
1030
+ return this.executeInTransaction(undefined, async (qr)=>{
1031
+ const allResults = [];
1032
+ const eventGroups = [];
1033
+ if (toInsert.length > 0) {
1034
+ await this.beforeInsertOperation(toInsert, user, qr);
1035
+ const insertedEntities = await this.convertRequestDtoToEntity(toInsert, user);
1036
+ const insertedSaved = await qr.manager.save(this.repository.target, insertedEntities);
1037
+ await this.afterInsertOperation(this.ensureArray(insertedSaved), toInsert, user, qr);
1038
+ allResults.push(...this.ensureArray(insertedSaved));
1039
+ eventGroups.push({
1040
+ action: 'created',
1041
+ entities: this.ensureArray(insertedSaved)
1042
+ });
1043
+ }
1044
+ if (toUpdate.length > 0) {
1045
+ await this.beforeUpdateOperation(toUpdate, user, qr);
1046
+ const updatedEntities = await this.convertRequestDtoToEntity(toUpdate, user);
1047
+ const updatedSaved = await qr.manager.save(this.repository.target, updatedEntities);
1048
+ await this.afterUpdateOperation(this.ensureArray(updatedSaved), toUpdate, user, qr);
1049
+ allResults.push(...this.ensureArray(updatedSaved));
1050
+ eventGroups.push({
1051
+ action: 'updated',
1052
+ entities: this.ensureArray(updatedSaved)
1053
+ });
1054
+ }
1055
+ return {
1056
+ saved: allResults,
1057
+ returnFirst: false,
1058
+ eventGroups
1059
+ };
1060
+ }, user);
1061
+ }
1062
+ async findByIds(ids, user, select) {
1063
+ await this.ensureDataSourceRepository();
1064
+ try {
1065
+ const query = this.repository.createQueryBuilder(this.entityName);
1066
+ query.where({
1067
+ id: (0,external_typeorm_.In)(ids)
1068
+ });
1069
+ const selectArray = typeof select === 'string' ? select.split(',').map((s)=>s.trim()) : select;
1070
+ const { query: finalQuery, isRaw } = await this.getSelectQuery(query, user, selectArray);
1071
+ let output;
1072
+ if (isRaw) {
1073
+ output = await finalQuery.getRawMany();
1074
+ } else {
1075
+ output = await finalQuery.getMany();
1076
+ }
1077
+ const result = this.convertEntityListToResponseListDto(output, isRaw);
1078
+ if (!result || !result.length) throw new common_.NotFoundException({
1079
+ message: 'No Data Found',
1080
+ messageKey: message_keys/* .ERROR_MESSAGES.NOT_FOUND */.UU.NOT_FOUND
1081
+ });
1082
+ return result;
1083
+ } catch (error) {
1084
+ if (error instanceof common_.NotFoundException) {
1085
+ throw error;
1086
+ }
1087
+ this.handleError(error);
1088
+ }
1089
+ }
1090
+ async findById(id, user, select) {
1091
+ await this.ensureDataSourceRepository();
1092
+ try {
1093
+ const query = this.repository.createQueryBuilder(this.entityName);
1094
+ query.where({
1095
+ id
1096
+ });
1097
+ const { query: finalQuery, isRaw } = await this.getSelectQuery(query, user, select);
1098
+ let result;
1099
+ let cacheKey = '';
1100
+ if (this.isCacheable) {
1101
+ cacheKey = this.utilsService.getCacheKey(this.entityName, finalQuery.getQueryAndParameters(), id);
1102
+ result = await this.cacheManager.get(cacheKey);
1103
+ }
1104
+ if (!result) {
1105
+ if (isRaw) {
1106
+ const rawOutput = await finalQuery.getRawMany();
1107
+ const convertResult = this.convertEntityListToResponseListDto(rawOutput, isRaw);
1108
+ if (convertResult.length) result = convertResult[0];
1109
+ } else {
1110
+ const singleOutput = await finalQuery.getOne();
1111
+ if (!singleOutput) throw new common_.NotFoundException({
1112
+ message: 'No Data Found',
1113
+ messageKey: message_keys/* .ERROR_MESSAGES.NOT_FOUND */.UU.NOT_FOUND
1114
+ });
1115
+ result = this.convertEntityToResponseDto(singleOutput, false);
1116
+ }
1117
+ if (this.isCacheable) {
1118
+ await this.cacheManager.set(cacheKey, result);
1119
+ await this.utilsService.trackCacheKey(cacheKey, this.entityName, this.cacheManager, id);
1120
+ }
1121
+ }
1122
+ return result;
1123
+ } catch (error) {
1124
+ if (error instanceof common_.NotFoundException) {
1125
+ throw error;
1126
+ }
1127
+ this.handleError(error);
1128
+ }
1129
+ }
1130
+ async getAll(search, filterAndPaginationDto, user) {
1131
+ await this.ensureDataSourceRepository();
1132
+ try {
1133
+ let data;
1134
+ let total;
1135
+ let isRaw = false;
1136
+ let query = this.repository.createQueryBuilder(this.entityName);
1137
+ if (filterAndPaginationDto.filter) {
1138
+ const { query: filterQuery, isRaw: filterIsRaw } = await this.getFilterQuery(query, filterAndPaginationDto.filter, user);
1139
+ query = filterQuery;
1140
+ isRaw = isRaw || filterIsRaw;
1141
+ }
1142
+ if (search) {
1143
+ const { query: searchQuery, isRaw: searchIsRaw } = await this.getGlobalSearchQuery(query, search, user);
1144
+ query = searchQuery;
1145
+ isRaw = isRaw || searchIsRaw;
1146
+ }
1147
+ const { query: selectQuery, isRaw: selectIsRaw } = await this.getSelectQuery(query, user, filterAndPaginationDto.select);
1148
+ query = selectQuery;
1149
+ isRaw = isRaw || selectIsRaw;
1150
+ if (filterAndPaginationDto.sort) {
1151
+ const { query: sortQuery, isRaw: sortIsRaw } = await this.getSortQuery(query, filterAndPaginationDto.sort, user);
1152
+ query = sortQuery;
1153
+ isRaw = isRaw || sortIsRaw;
1154
+ }
1155
+ if (filterAndPaginationDto.withDeleted) query.withDeleted();
1156
+ const { query: extraQuery, isRaw: extraIsRaw } = await this.getExtraManipulateQuery(query, filterAndPaginationDto, user);
1157
+ query = extraQuery;
1158
+ isRaw = isRaw || extraIsRaw;
1159
+ if (filterAndPaginationDto.pagination) {
1160
+ const offset = filterAndPaginationDto.pagination.currentPage * filterAndPaginationDto.pagination.pageSize;
1161
+ const limit = filterAndPaginationDto.pagination.pageSize;
1162
+ if (isRaw) {
1163
+ query.offset(offset).limit(limit);
1164
+ } else {
1165
+ query.skip(offset).take(limit);
1166
+ }
1167
+ }
1168
+ let cacheKey = '';
1169
+ if (this.isCacheable) {
1170
+ cacheKey = this.utilsService.getCacheKey(this.entityName, {
1171
+ raw: isRaw,
1172
+ pagination: filterAndPaginationDto.pagination,
1173
+ query: query.getQueryAndParameters()
1174
+ });
1175
+ const cached = await this.cacheManager.get(cacheKey);
1176
+ if (cached) {
1177
+ return cached;
1178
+ }
1179
+ }
1180
+ if (isRaw) {
1181
+ const rawSubQuery = query.clone().offset(undefined).limit(undefined);
1182
+ rawSubQuery.expressionMap.orderBys = {};
1183
+ rawSubQuery.distinct(true);
1184
+ const countSql = `
1185
+ SELECT COUNT(*) as count
1186
+ FROM (
1187
+ SELECT COUNT(*) as count
1188
+ FROM (${rawSubQuery.getQuery()}) AS subquery
1189
+ GROUP BY subquery.${this.entityName}_id
1190
+ ) AS final
1191
+ `;
1192
+ const parameters = rawSubQuery.getParameters();
1193
+ const orderedValues = [];
1194
+ const isPostgres = this.repository.manager.connection.options.type === 'postgres';
1195
+ let paramIndex = 0;
1196
+ const convertedQuery = countSql.replace(/:(\w+)/g, (_, key)=>{
1197
+ if (!(key in parameters)) {
1198
+ throw new common_.InternalServerErrorException({
1199
+ message: `Missing parameter value for: ${key}`,
1200
+ messageKey: message_keys/* .SYSTEM_MESSAGES.MISSING_PARAMETER */.hg.MISSING_PARAMETER,
1201
+ messageVariables: {
1202
+ key
1203
+ }
1204
+ });
1205
+ }
1206
+ orderedValues.push(parameters[key]);
1207
+ return isPostgres ? `$${++paramIndex}` : '?';
1208
+ });
1209
+ const result = await this.repository.query(convertedQuery, orderedValues);
1210
+ total = Number(result[0]?.count || 0);
1211
+ data = await query.getRawMany();
1212
+ } else {
1213
+ [data, total] = await query.getManyAndCount();
1214
+ }
1215
+ const convertedFinalData = this.convertEntityListToResponseListDto(data, isRaw);
1216
+ const finalResponse = {
1217
+ data: convertedFinalData,
1218
+ total
1219
+ };
1220
+ if (this.isCacheable) {
1221
+ await this.cacheManager.set(cacheKey, finalResponse);
1222
+ await this.utilsService.trackCacheKey(cacheKey, this.entityName, this.cacheManager);
1223
+ }
1224
+ return finalResponse;
1225
+ } catch (error) {
1226
+ this.handleError(error);
1227
+ }
1228
+ }
1229
+ async delete(option, user) {
1230
+ await this.ensureDataSourceRepository();
1231
+ const queryRunner = this.repository.manager.connection.createQueryRunner();
1232
+ await queryRunner.connect();
1233
+ await queryRunner.startTransaction();
1234
+ try {
1235
+ await this.beforeDeleteOperation(option, user, queryRunner);
1236
+ if (option.type === 'delete') {
1237
+ await queryRunner.manager.softDelete(this.repository.target, option.id);
1238
+ await queryRunner.manager.update(this.repository.target, option.id, {
1239
+ deletedById: option['deletedById']
1240
+ });
1241
+ } else if (option.type === 'restore') {
1242
+ await queryRunner.manager.restore(this.repository.target, option.id);
1243
+ await queryRunner.manager.update(this.repository.target, option.id, {
1244
+ deletedById: option['deletedById']
1245
+ });
1246
+ } else {
1247
+ await queryRunner.manager.delete(this.repository.target, option.id);
1248
+ }
1249
+ const ids = (Array.isArray(option.id) ? option.id : [
1250
+ option.id
1251
+ ]).map((id)=>{
1252
+ return {
1253
+ id
1254
+ };
1255
+ });
1256
+ await this.afterDeleteOperation(ids, option, user, queryRunner);
1257
+ await queryRunner.commitTransaction();
1258
+ await Promise.all([
1259
+ this.clearCacheForAll(),
1260
+ this.clearCacheForId(ids)
1261
+ ]);
1262
+ await this.publishLifecycleEvents([
1263
+ {
1264
+ action: DELETE_EVENT_ACTIONS[option.type],
1265
+ entities: ids,
1266
+ idsOnly: true
1267
+ }
1268
+ ], user);
1269
+ return null;
1270
+ } catch (error) {
1271
+ await queryRunner.rollbackTransaction();
1272
+ this.handleError(error);
1273
+ } finally{
1274
+ await queryRunner.release();
1275
+ }
1276
+ }
1277
+ async publishLifecycleEvents(groups, user) {
1278
+ for (const group of groups){
1279
+ if (!group.entities.length) continue;
1280
+ await publishDomainEvent({
1281
+ module: this.moduleName,
1282
+ entity: this.entityName,
1283
+ action: group.action,
1284
+ ids: group.entities.map((entity)=>entity.id),
1285
+ ...group.idsOnly ? {} : {
1286
+ data: group.entities
1287
+ },
1288
+ user
1289
+ });
1290
+ }
1291
+ }
1292
+ /**
1293
+ * Publishes a domain action for this service's entity - anything past plain
1294
+ * CRUD, such as a submission or a state transition.
1295
+ */ async publishDomainAction(action, input = {}) {
1296
+ await publishDomainEvent({
1297
+ ...input,
1298
+ module: this.moduleName,
1299
+ entity: this.entityName,
1300
+ action
1301
+ });
1302
+ }
1303
+ async clearCacheForAll() {
1304
+ await this.utilsService.clearCache(this.entityName, this.cacheManager);
1305
+ }
1306
+ async clearCacheForId(entities) {
1307
+ await Promise.all(entities.map((item)=>this.utilsService.clearCache(this.entityName, this.cacheManager, item.id)));
1308
+ }
1309
+ handleError(error) {
1310
+ if (error instanceof Error) {
1311
+ throw error;
1312
+ }
1313
+ throw new common_.InternalServerErrorException({
1314
+ message: typeof error === 'string' ? error : 'Unknown error',
1315
+ messageKey: message_keys/* .ERROR_MESSAGES.INTERNAL */.UU.INTERNAL
1316
+ });
1317
+ }
1318
+ ensureArray(value) {
1319
+ return Array.isArray(value) ? value : [
1320
+ value
1321
+ ];
1322
+ }
1323
+ /**
1324
+ * `action` is the lifecycle action to publish for the whole batch; an
1325
+ * operation that saves more than one kind of row - a bulk upsert - passes
1326
+ * `undefined` and returns its own `eventGroups` instead.
1327
+ */ async executeInTransaction(action, fn, user) {
1328
+ await this.ensureDataSourceRepository();
1329
+ const qr = this.repository.manager.connection.createQueryRunner();
1330
+ await qr.connect();
1331
+ await qr.startTransaction();
1332
+ try {
1333
+ const { saved, returnFirst, eventGroups } = await fn(qr);
1334
+ await qr.commitTransaction();
1335
+ const savedArray = this.ensureArray(saved);
1336
+ if (this.isCacheable) {
1337
+ await Promise.all([
1338
+ this.clearCacheForAll(),
1339
+ this.clearCacheForId(savedArray)
1340
+ ]);
1341
+ }
1342
+ await this.publishLifecycleEvents(eventGroups ?? (action ? [
1343
+ {
1344
+ action,
1345
+ entities: savedArray
1346
+ }
1347
+ ] : []), user ?? null);
1348
+ if (returnFirst) {
1349
+ return this.convertEntityToResponseDto(savedArray[0], false);
1350
+ }
1351
+ return savedArray.map((e)=>this.convertEntityToResponseDto(e, false));
1352
+ } catch (error) {
1353
+ await qr.rollbackTransaction();
1354
+ this.handleError(error);
1355
+ } finally{
1356
+ await qr.release();
1357
+ }
1358
+ }
1359
+ async beforeInsertOperation(_dto, _user, _queryRunner) {}
1360
+ async afterInsertOperation(_entity, _dto, _user, _queryRunner) {}
1361
+ async beforeUpdateOperation(_dto, _user, _queryRunner) {}
1362
+ async afterUpdateOperation(_entity, _dto, _user, _queryRunner) {}
1363
+ async beforeDeleteOperation(_dto, _user, _queryRunner) {}
1364
+ async afterDeleteOperation(_entity, _dto, _user, _queryRunner) {}
1365
+ async getFilterQuery(query, filter, _user) {
1366
+ Object.entries(filter).forEach(([key, value])=>{
1367
+ query.andWhere(`${this.entityName}.${key} = :value`, {
1368
+ value
1369
+ });
1370
+ });
1371
+ return {
1372
+ query,
1373
+ isRaw: false
1374
+ };
1375
+ }
1376
+ async getSortQuery(query, sort, _user) {
1377
+ Object.entries(sort).forEach(([key, direction])=>{
1378
+ query.addOrderBy(`${this.entityName}.${key}`, direction);
1379
+ });
1380
+ return {
1381
+ query,
1382
+ isRaw: false
1383
+ };
1384
+ }
1385
+ async getSelectQuery(query, _user, select) {
1386
+ if (select && select.length) query.select(select.map((field)=>`${this.entityName}.${field}`));
1387
+ return {
1388
+ query,
1389
+ isRaw: false
1390
+ };
1391
+ }
1392
+ async getGlobalSearchQuery(query, search, _user) {
1393
+ query.andWhere(`${this.entityName}.name LIKE :search`, {
1394
+ search: `%${search}%`
1395
+ });
1396
+ return {
1397
+ query,
1398
+ isRaw: false
1399
+ };
1400
+ }
1401
+ async getExtraManipulateQuery(query, _dto, _user) {
1402
+ return {
1403
+ query,
1404
+ isRaw: false
1405
+ };
1406
+ }
1407
+ async convertRequestDtoToEntity(dto, user) {
1408
+ return Array.isArray(dto) ? await this.convertArrayDtoToEntities(dto, user) : [
1409
+ await this.convertSingleDtoToEntity(dto, user)
1410
+ ];
1411
+ }
1412
+ async convertSingleDtoToEntity(dto, _user) {
1413
+ const d = dto;
1414
+ if (d?.id && d.id !== '0' && d.id !== '') {
1415
+ const existing = await this.repository.findOne({
1416
+ where: {
1417
+ id: d.id
1418
+ }
1419
+ });
1420
+ if (!existing) throw new common_.NotFoundException({
1421
+ message: 'No such entity data found for update! Please, Try Again.',
1422
+ messageKey: message_keys/* .ERROR_MESSAGES.NOT_FOUND */.UU.NOT_FOUND
1423
+ });
1424
+ return Object.assign(existing, d);
1425
+ }
1426
+ delete d.id;
1427
+ return Object.assign(this.repository.create(), d);
1428
+ }
1429
+ async convertArrayDtoToEntities(dtos, user) {
1430
+ return await Promise.all(dtos.map((dto)=>this.convertSingleDtoToEntity(dto, user)));
1431
+ }
1432
+ convertEntityToResponseDto(entity, _isRaw) {
1433
+ return Object.assign({}, entity);
1434
+ }
1435
+ convertEntityListToResponseListDto(entities, _isRaw) {
1436
+ return entities.map((entity)=>this.convertEntityToResponseDto(entity, _isRaw));
1437
+ }
1438
+ }
1439
+ api_service_class_ts_decorate([
1440
+ (0,log_action_decorator/* .LogAction */.J)({
1441
+ action: 'create'
1442
+ }),
1443
+ api_service_class_ts_metadata("design:type", Function),
1444
+ api_service_class_ts_metadata("design:paramtypes", [
1445
+ typeof CreateDtoT === "undefined" ? Object : CreateDtoT,
1446
+ Object
1447
+ ]),
1448
+ api_service_class_ts_metadata("design:returntype", Promise)
1449
+ ], ApiService.prototype, "insert", null);
1450
+ api_service_class_ts_decorate([
1451
+ (0,log_action_decorator/* .LogAction */.J)({
1452
+ action: 'createMany'
1453
+ }),
1454
+ api_service_class_ts_metadata("design:type", Function),
1455
+ api_service_class_ts_metadata("design:paramtypes", [
1456
+ typeof Array === "undefined" ? Object : Array,
1457
+ Object
1458
+ ]),
1459
+ api_service_class_ts_metadata("design:returntype", Promise)
1460
+ ], ApiService.prototype, "insertMany", null);
1461
+ api_service_class_ts_decorate([
1462
+ (0,log_action_decorator/* .LogAction */.J)({
1463
+ action: 'update'
1464
+ }),
1465
+ api_service_class_ts_metadata("design:type", Function),
1466
+ api_service_class_ts_metadata("design:paramtypes", [
1467
+ typeof UpdateDtoT === "undefined" ? Object : UpdateDtoT,
1468
+ Object
1469
+ ]),
1470
+ api_service_class_ts_metadata("design:returntype", Promise)
1471
+ ], ApiService.prototype, "update", null);
1472
+ api_service_class_ts_decorate([
1473
+ (0,log_action_decorator/* .LogAction */.J)({
1474
+ action: 'updateMany'
1475
+ }),
1476
+ api_service_class_ts_metadata("design:type", Function),
1477
+ api_service_class_ts_metadata("design:paramtypes", [
1478
+ Array,
1479
+ Object
1480
+ ]),
1481
+ api_service_class_ts_metadata("design:returntype", Promise)
1482
+ ], ApiService.prototype, "updateMany", null);
1483
+ api_service_class_ts_decorate([
1484
+ (0,log_action_decorator/* .LogAction */.J)({
1485
+ action: 'bulkUpsert'
1486
+ }),
1487
+ api_service_class_ts_metadata("design:type", Function),
1488
+ api_service_class_ts_metadata("design:paramtypes", [
1489
+ Array,
1490
+ Array,
1491
+ Object
1492
+ ]),
1493
+ api_service_class_ts_metadata("design:returntype", Promise)
1494
+ ], ApiService.prototype, "bulkUpsert", null);
1495
+ api_service_class_ts_decorate([
1496
+ (0,log_action_decorator/* .LogAction */.J)({
1497
+ action: 'delete'
1498
+ }),
1499
+ api_service_class_ts_metadata("design:type", Function),
1500
+ api_service_class_ts_metadata("design:paramtypes", [
1501
+ typeof src_dtos/* .DeleteDto */.TG === "undefined" ? Object : src_dtos/* .DeleteDto */.TG,
1502
+ Object
1503
+ ]),
1504
+ api_service_class_ts_metadata("design:returntype", Promise)
1505
+ ], ApiService.prototype, "delete", null);
1506
+ ApiService = api_service_class_ts_decorate([
1507
+ (0,common_.Injectable)({
1508
+ scope: common_.Scope.REQUEST
1509
+ }),
1510
+ api_service_class_ts_metadata("design:type", Function),
1511
+ api_service_class_ts_metadata("design:paramtypes", [
1512
+ String,
1513
+ typeof hybrid_cache_class/* .HybridCache */.l === "undefined" ? Object : hybrid_cache_class/* .HybridCache */.l,
1514
+ typeof utils_service/* .UtilsService */.T === "undefined" ? Object : utils_service/* .UtilsService */.T,
1515
+ String,
1516
+ Boolean,
1517
+ String,
1518
+ typeof IDataSourceProvider === "undefined" ? Object : IDataSourceProvider,
1519
+ typeof EntityTarget === "undefined" ? Object : EntityTarget
1520
+ ])
1521
+ ], ApiService);
1522
+
1523
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/disabled-event-bus.class.ts
1524
+ var disabled_event_bus_class = __webpack_require__(864);
1525
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/event-transports/event-transport.registry.ts
1526
+ var event_transport_registry = __webpack_require__(149);
1527
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/event-transports/memory-transport.ts + 1 modules
1528
+ var memory_transport = __webpack_require__(346);
1529
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/classes/event-transports/index.ts
1530
+
1531
+ // Built-in transport (no external dependencies)
1532
+ // Note: Broker transports are loaded dynamically by HybridEventBus.
1533
+ // Import them directly when registering manually:
1534
+ // - import { RabbitMqTransport } from '@flusys/nestjs-shared/classes/event-transports/rabbitmq-transport.optional';
1535
+ // - import { KafkaTransport } from '@flusys/nestjs-shared/classes/event-transports/kafka-transport.optional';
1536
+
1537
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/handle-custome-db.ts
1538
+ var handle_custome_db = __webpack_require__(504);
1539
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/hybrid-event-bus.class.ts
1540
+ var hybrid_event_bus_class = __webpack_require__(710);
1541
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/winston.logger.class.ts + 5 modules
1542
+ var winston_logger_class = __webpack_require__(245);
1543
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/permissions.ts
1544
+ var permissions = __webpack_require__(975);
1545
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/classes/index.ts
1546
+
1547
+
1548
+
1549
+
1550
+
1551
+
1552
+
1553
+
1554
+
1555
+
1556
+ // Re-export permission constants for convenience
1557
+
1558
+
1559
+
1560
+ },
1561
+ 997(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1562
+ /* import */ var _dtos_index_js__rspack_import_0 = __webpack_require__(980);
1563
+ /* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(157);
1564
+ /* import */ var _nestjs_swagger__rspack_import_2 = __webpack_require__(176);
1565
+
1566
+
1567
+
1568
+ const ApiResponseDto = (dto, isArray = false, arrayType = 'list')=>{
1569
+ let wrapperDto;
1570
+ let metaDto = null;
1571
+ if (!isArray || arrayType === 'single') {
1572
+ wrapperDto = _dtos_index_js__rspack_import_0/* .SingleResponseDto */.f;
1573
+ } else if (arrayType === 'bulk') {
1574
+ wrapperDto = _dtos_index_js__rspack_import_0/* .BulkResponseDto */.jS;
1575
+ metaDto = _dtos_index_js__rspack_import_0/* .BulkMetaDto */.L3;
1576
+ } else {
1577
+ wrapperDto = _dtos_index_js__rspack_import_0/* .ListResponseDto */.TW;
1578
+ metaDto = _dtos_index_js__rspack_import_0/* .PaginationMetaDto */.DD;
1579
+ }
1580
+ return (0,_nestjs_common__rspack_import_1.applyDecorators)((0,_nestjs_swagger__rspack_import_2.ApiExtraModels)(_dtos_index_js__rspack_import_0/* .SingleResponseDto */.f, _dtos_index_js__rspack_import_0/* .ListResponseDto */.TW, _dtos_index_js__rspack_import_0/* .BulkResponseDto */.jS, _dtos_index_js__rspack_import_0/* .PaginationMetaDto */.DD, _dtos_index_js__rspack_import_0/* .BulkMetaDto */.L3, dto), (0,_nestjs_swagger__rspack_import_2.ApiOkResponse)({
1581
+ schema: {
1582
+ allOf: [
1583
+ {
1584
+ $ref: (0,_nestjs_swagger__rspack_import_2.getSchemaPath)(wrapperDto)
1585
+ },
1586
+ {
1587
+ properties: {
1588
+ data: isArray ? {
1589
+ type: 'array',
1590
+ items: {
1591
+ $ref: (0,_nestjs_swagger__rspack_import_2.getSchemaPath)(dto)
1592
+ }
1593
+ } : {
1594
+ $ref: (0,_nestjs_swagger__rspack_import_2.getSchemaPath)(dto)
1595
+ },
1596
+ ...metaDto ? {
1597
+ meta: {
1598
+ $ref: (0,_nestjs_swagger__rspack_import_2.getSchemaPath)(metaDto)
1599
+ }
1600
+ } : {}
1601
+ }
1602
+ }
1603
+ ]
1604
+ }
1605
+ }));
1606
+ };
1607
+
1608
+ __webpack_require__.d(__webpack_exports__, {
1609
+ }, {
1610
+ x: ApiResponseDto
1611
+ });
1612
+
1613
+
1614
+ },
1615
+ 523(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1616
+
1617
+ // EXPORTS
1618
+ __webpack_require__.d(__webpack_exports__, {
1619
+ x_: () => (/* reexport */ api_response_decorator/* .ApiResponseDto */.x),
1620
+ NO: () => (/* reexport */ CurrentUser),
1621
+ Jz: () => (/* reexport */ log_action_decorator/* .LogAction */.J),
1622
+ kd: () => (/* reexport */ OnDomainEvent),
1623
+ w3: () => (/* reexport */ Public),
1624
+ Dz: () => (/* reexport */ RequireAnyPermission),
1625
+ Tw: () => (/* reexport */ RequirePermission),
1626
+ rY: () => (/* reexport */ RequirePermissionLogic)
1627
+ });
1628
+
1629
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/api-response.decorator.ts
1630
+ var api_response_decorator = __webpack_require__(997);
1631
+ // EXTERNAL MODULE: external "@nestjs/common"
1632
+ var common_ = __webpack_require__(157);
1633
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/current-user.decorator.ts
1634
+
1635
+ /**
1636
+ * Parameter decorator that extracts the current user from the request.
1637
+ * Works with any authentication guard that sets request.user
1638
+ *
1639
+ * @example
1640
+ * // Get entire user object
1641
+ * @Get('profile')
1642
+ * getProfile(@CurrentUser() user: User) { }
1643
+ *
1644
+ * // Get specific property
1645
+ * @Get('id')
1646
+ * getId(@CurrentUser('id') userId: string) { }
1647
+ */ const CurrentUser = (0,common_.createParamDecorator)((data, ctx)=>{
1648
+ const request = ctx.switchToHttp().getRequest();
1649
+ const user = request.user;
1650
+ return data ? user?.[data] : user;
1651
+ });
1652
+
1653
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/decorators/log-action.decorator.ts
1654
+ var log_action_decorator = __webpack_require__(946);
1655
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/index.ts
1656
+ var constants = __webpack_require__(43);
1657
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/on-domain-event.decorator.ts
1658
+
1659
+
1660
+ /**
1661
+ * Marks a provider method as a domain event consumer.
1662
+ *
1663
+ * `*` matches one segment, `**` (or `#`) matches the rest:
1664
+ * `@OnDomainEvent('storage.folder.created')`
1665
+ * `@OnDomainEvent('auth.*.updated')`
1666
+ * `@OnDomainEvent('**')`
1667
+ */ const OnDomainEvent = (...patterns)=>(0,common_.SetMetadata)(constants/* .DOMAIN_EVENT_HANDLER_KEY */.PT, patterns);
1668
+
1669
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/public.decorator.ts
1670
+
1671
+
1672
+ /**
1673
+ * Decorator to mark routes as public (skip authentication)
1674
+ *
1675
+ * Use this on controller methods or entire controllers to bypass
1676
+ * JWT authentication guards.
1677
+ *
1678
+ * @example
1679
+ * // Skip auth for a single route
1680
+ * @Public()
1681
+ * @Post('login')
1682
+ * login() { }
1683
+ *
1684
+ * @example
1685
+ * // Skip auth for entire controller
1686
+ * @Public()
1687
+ * @Controller('public')
1688
+ * export class PublicController { }
1689
+ */ const Public = ()=>(0,common_.SetMetadata)(constants/* .IS_PUBLIC_KEY */.jA, true);
1690
+
1691
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/require-permission.decorator.ts
1692
+
1693
+
1694
+ /** Require ALL permissions (AND logic) - most secure pattern */ const RequirePermission = (...permissions)=>(0,common_.SetMetadata)(constants/* .PERMISSIONS_KEY */.N7, {
1695
+ permissions,
1696
+ operator: 'AND'
1697
+ });
1698
+ /** Require ANY permission (OR logic) - use carefully */ const RequireAnyPermission = (...permissions)=>(0,common_.SetMetadata)(constants/* .PERMISSIONS_KEY */.N7, {
1699
+ permissions,
1700
+ operator: 'OR'
1701
+ });
1702
+ /**
1703
+ * Require complex permission logic using ILogicNode tree
1704
+ * @example
1705
+ * // Single permission
1706
+ * @RequirePermissionLogic('users.read')
1707
+ * @example
1708
+ * // Complex: users.read AND (admin OR manager)
1709
+ * @RequirePermissionLogic({
1710
+ * type: 'group', operator: 'AND', children: [
1711
+ * { type: 'action', actionId: 'users.read' },
1712
+ * { type: 'group', operator: 'OR', children: [
1713
+ * { type: 'action', actionId: 'admin' },
1714
+ * { type: 'action', actionId: 'manager' },
1715
+ * ]},
1716
+ * ],
1717
+ * })
1718
+ */ const RequirePermissionLogic = (logic)=>(0,common_.SetMetadata)(constants/* .PERMISSIONS_KEY */.N7, logic);
1719
+
1720
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/decorators/index.ts
1721
+
1722
+
1723
+
1724
+
1725
+
1726
+
1727
+
1728
+
1729
+ },
1730
+ 946(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1731
+ /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
1732
+ /* import */ var _classes_winston_logger_class_js__rspack_import_1 = __webpack_require__(245);
1733
+ /* import */ var _middlewares_logger_middleware_js__rspack_import_2 = __webpack_require__(419);
1734
+
1735
+
1736
+
1737
+ function createLoggerAdapter(className, moduleName) {
1738
+ if (moduleName) {
1739
+ const winstonLogger = (0,_classes_winston_logger_class_js__rspack_import_1/* .createModuleLogger */.X)(moduleName);
1740
+ return {
1741
+ log: (level, message, meta)=>{
1742
+ winstonLogger.log(level, message, {
1743
+ context: className,
1744
+ ...meta
1745
+ });
1746
+ },
1747
+ error: (message, stack, meta)=>{
1748
+ winstonLogger.error(message, {
1749
+ context: className,
1750
+ stack,
1751
+ ...meta
1752
+ });
1753
+ }
1754
+ };
1755
+ }
1756
+ const nestLogger = new _nestjs_common__rspack_import_0.Logger(className);
1757
+ return {
1758
+ log: (level, message, meta)=>{
1759
+ nestLogger[level](message, meta);
1760
+ },
1761
+ error: (message, stack, meta)=>{
1762
+ nestLogger.error(message, stack, meta);
1763
+ }
1764
+ };
1765
+ }
1766
+ function LogAction(options = {}) {
1767
+ return function(target, propertyKey, descriptor) {
1768
+ const originalMethod = descriptor.value;
1769
+ const className = target.constructor.name;
1770
+ const methodName = String(propertyKey);
1771
+ descriptor.value = async function(...args) {
1772
+ const startTime = Date.now();
1773
+ // Resolve module: decorator option > instance property > undefined
1774
+ const moduleName = options.module || this.moduleName;
1775
+ const logger = createLoggerAdapter(className, moduleName);
1776
+ const action = options.action || `${this.entityName || className}.${methodName}`;
1777
+ const logLevel = options.logLevel || 'debug';
1778
+ const context = {
1779
+ requestId: (0,_middlewares_logger_middleware_js__rspack_import_2/* .getRequestId */.RE)(),
1780
+ userId: (0,_middlewares_logger_middleware_js__rspack_import_2/* .getUserId */.F6)(),
1781
+ tenantId: (0,_middlewares_logger_middleware_js__rspack_import_2/* .getTenantId */.EO)(),
1782
+ companyId: (0,_middlewares_logger_middleware_js__rspack_import_2/* .getCompanyId */.xR)(),
1783
+ method: methodName,
1784
+ module: moduleName
1785
+ };
1786
+ const startMessage = `Executing action method "${action}"`;
1787
+ const startContext = options.includeParams ? {
1788
+ ...context,
1789
+ params: sanitizeParams(args)
1790
+ } : context;
1791
+ logger.log(logLevel, startMessage, startContext);
1792
+ try {
1793
+ const result = await originalMethod.apply(this, args);
1794
+ const duration = Date.now() - startTime;
1795
+ const resultType = getResultType(result);
1796
+ const successMessage = `Executed action method "${action}", returned result "${resultType}" in ${duration.toFixed(2)}ms.`;
1797
+ const successContext = options.includeResult && result ? {
1798
+ ...context,
1799
+ duration: `${duration}ms`,
1800
+ resultType,
1801
+ resultPreview: getResultPreview(result)
1802
+ } : {
1803
+ ...context,
1804
+ duration: `${duration}ms`,
1805
+ resultType
1806
+ };
1807
+ logger.log(logLevel, successMessage, successContext);
1808
+ return result;
1809
+ } catch (error) {
1810
+ const duration = Date.now() - startTime;
1811
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
1812
+ logger.error(`Failed action method "${action}" after ${duration.toFixed(2)}ms: ${errorMessage}`, error instanceof Error ? error.stack : undefined, {
1813
+ ...context,
1814
+ duration: `${duration}ms`,
1815
+ error: errorMessage
1816
+ });
1817
+ throw error;
1818
+ }
1819
+ };
1820
+ return descriptor;
1821
+ };
1822
+ }
1823
+ function sanitizeParams(args) {
1824
+ return args.map((arg)=>{
1825
+ if (arg === null || arg === undefined) return arg;
1826
+ if (typeof arg === 'object') {
1827
+ const sanitized = {
1828
+ ...arg
1829
+ };
1830
+ const sensitiveKeys = [
1831
+ 'password',
1832
+ 'secret',
1833
+ 'token',
1834
+ 'apiKey',
1835
+ 'authorization'
1836
+ ];
1837
+ for (const key of Object.keys(sanitized)){
1838
+ if (sensitiveKeys.some((sk)=>key.toLowerCase().includes(sk))) {
1839
+ sanitized[key] = '[REDACTED]';
1840
+ }
1841
+ }
1842
+ return sanitized;
1843
+ }
1844
+ return arg;
1845
+ });
1846
+ }
1847
+ function getResultType(result) {
1848
+ if (result === null) return 'null';
1849
+ if (result === undefined) return 'undefined';
1850
+ if (Array.isArray(result)) return `Array<${result.length} items>`;
1851
+ if (typeof result === 'object') {
1852
+ const name = result.constructor?.name;
1853
+ return name && name !== 'Object' ? name : 'Object';
1854
+ }
1855
+ return typeof result;
1856
+ }
1857
+ function getResultPreview(result) {
1858
+ if (Array.isArray(result)) {
1859
+ return {
1860
+ count: result.length,
1861
+ sample: result.slice(0, 2)
1862
+ };
1863
+ }
1864
+ if (typeof result === 'object' && result !== null) {
1865
+ const keys = Object.keys(result).slice(0, 5);
1866
+ return {
1867
+ keys,
1868
+ hasMore: Object.keys(result).length > 5
1869
+ };
1870
+ }
1871
+ return result;
1872
+ }
1873
+
1874
+ __webpack_require__.d(__webpack_exports__, {
1875
+ J: () => (LogAction)
1876
+ });
1877
+
1878
+
1879
+ },
1880
+ 514(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1881
+ /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
1882
+ /* import */ var _constants_message_keys_js__rspack_import_1 = __webpack_require__(389);
1883
+
1884
+
1885
+ class BaseAppException extends _nestjs_common__rspack_import_0.HttpException {
1886
+ messageKey;
1887
+ messageVariables;
1888
+ errors;
1889
+ metadata;
1890
+ constructor(options){
1891
+ const status = options.status || _nestjs_common__rspack_import_0.HttpStatus.BAD_REQUEST;
1892
+ super({
1893
+ success: false,
1894
+ message: options.message,
1895
+ messageKey: options.messageKey || _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.GENERIC */.UU.GENERIC,
1896
+ messageVariables: options.messageVariables,
1897
+ errors: options.errors
1898
+ }, status);
1899
+ this.messageKey = options.messageKey || _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.GENERIC */.UU.GENERIC;
1900
+ this.messageVariables = options.messageVariables;
1901
+ this.errors = options.errors;
1902
+ this.metadata = options.metadata;
1903
+ }
1904
+ }
1905
+ class NotFoundException extends BaseAppException {
1906
+ constructor(entity, id){
1907
+ super({
1908
+ message: id ? `${entity} with id "${id}" not found` : `${entity} not found`,
1909
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.NOT_FOUND */.UU.NOT_FOUND,
1910
+ status: _nestjs_common__rspack_import_0.HttpStatus.NOT_FOUND,
1911
+ metadata: {
1912
+ entity,
1913
+ id
1914
+ }
1915
+ });
1916
+ }
1917
+ }
1918
+ class ValidationException extends BaseAppException {
1919
+ constructor(errors){
1920
+ super({
1921
+ message: 'Validation failed',
1922
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.VALIDATION */.UU.VALIDATION,
1923
+ status: _nestjs_common__rspack_import_0.HttpStatus.BAD_REQUEST,
1924
+ errors
1925
+ });
1926
+ }
1927
+ }
1928
+ class UnauthorizedException extends BaseAppException {
1929
+ constructor(message = 'Unauthorized access'){
1930
+ super({
1931
+ message,
1932
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.UNAUTHORIZED */.UU.UNAUTHORIZED,
1933
+ status: _nestjs_common__rspack_import_0.HttpStatus.UNAUTHORIZED
1934
+ });
1935
+ }
1936
+ }
1937
+ class ForbiddenException extends BaseAppException {
1938
+ constructor(message = 'Access forbidden'){
1939
+ super({
1940
+ message,
1941
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.FORBIDDEN */.UU.FORBIDDEN,
1942
+ status: _nestjs_common__rspack_import_0.HttpStatus.FORBIDDEN
1943
+ });
1944
+ }
1945
+ }
1946
+ class ConflictException extends BaseAppException {
1947
+ constructor(entity, field){
1948
+ super({
1949
+ message: field ? `${entity} with this ${field} already exists` : `${entity} already exists`,
1950
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.CONFLICT */.UU.CONFLICT,
1951
+ messageVariables: {
1952
+ entity,
1953
+ ...field !== undefined && {
1954
+ field
1955
+ }
1956
+ },
1957
+ status: _nestjs_common__rspack_import_0.HttpStatus.CONFLICT,
1958
+ metadata: {
1959
+ entity,
1960
+ field
1961
+ }
1962
+ });
1963
+ }
1964
+ }
1965
+ class InternalServerException extends BaseAppException {
1966
+ constructor(message = 'Internal server error'){
1967
+ super({
1968
+ message,
1969
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.INTERNAL */.UU.INTERNAL,
1970
+ status: _nestjs_common__rspack_import_0.HttpStatus.INTERNAL_SERVER_ERROR
1971
+ });
1972
+ }
1973
+ }
1974
+ class ServiceUnavailableException extends BaseAppException {
1975
+ constructor(service){
1976
+ super({
1977
+ message: `${service} is temporarily unavailable`,
1978
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.SERVICE_UNAVAILABLE */.UU.SERVICE_UNAVAILABLE,
1979
+ messageVariables: {
1980
+ service
1981
+ },
1982
+ status: _nestjs_common__rspack_import_0.HttpStatus.SERVICE_UNAVAILABLE,
1983
+ metadata: {
1984
+ service
1985
+ }
1986
+ });
1987
+ }
1988
+ }
1989
+
1990
+ __webpack_require__.d(__webpack_exports__, {
1991
+ GI: () => (InternalServerException),
1992
+ X6: () => (NotFoundException),
1993
+ ZT: () => (ForbiddenException),
1994
+ _W: () => (UnauthorizedException),
1995
+ cb: () => (ConflictException),
1996
+ dr: () => (ValidationException),
1997
+ ld: () => (ServiceUnavailableException),
1998
+ m8: () => (BaseAppException)
1999
+ });
2000
+
2001
+
2002
+ },
2003
+ 448(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2004
+ /* import */ var _base_app_exception_js__rspack_import_0 = __webpack_require__(514);
2005
+ /* import */ var _permission_exception_js__rspack_import_1 = __webpack_require__(374);
2006
+
2007
+
2008
+
2009
+ __webpack_require__.d(__webpack_exports__, {
2010
+ GI: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.GI),
2011
+ GS: () => (/* reexport safe */ _permission_exception_js__rspack_import_1.GS),
2012
+ X6: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.X6),
2013
+ ZT: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.ZT),
2014
+ _W: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0._W),
2015
+ cb: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.cb),
2016
+ d$: () => (/* reexport safe */ _permission_exception_js__rspack_import_1.d$),
2017
+ dr: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.dr),
2018
+ ld: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.ld),
2019
+ m8: () => (/* reexport safe */ _base_app_exception_js__rspack_import_0.m8),
2020
+ z8: () => (/* reexport safe */ _permission_exception_js__rspack_import_1.z8)
2021
+ });
2022
+
2023
+
2024
+ },
2025
+ 374(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2026
+ /* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
2027
+ /* import */ var _constants_message_keys_js__rspack_import_1 = __webpack_require__(389);
2028
+
2029
+
2030
+ class PermissionSystemUnavailableException extends _nestjs_common__rspack_import_0.InternalServerErrorException {
2031
+ constructor(){
2032
+ super({
2033
+ success: false,
2034
+ message: 'Permission system temporarily unavailable',
2035
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.PERMISSION_SYSTEM_UNAVAILABLE */.UU.PERMISSION_SYSTEM_UNAVAILABLE
2036
+ });
2037
+ }
2038
+ }
2039
+ class InsufficientPermissionsException extends _nestjs_common__rspack_import_0.ForbiddenException {
2040
+ constructor(missingPermissions, operator = 'AND'){
2041
+ const messageKey = operator === 'OR' ? _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.INSUFFICIENT_PERMISSIONS_OR */.UU.INSUFFICIENT_PERMISSIONS_OR : _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.INSUFFICIENT_PERMISSIONS */.UU.INSUFFICIENT_PERMISSIONS;
2042
+ super({
2043
+ success: false,
2044
+ message: 'Insufficient permissions',
2045
+ messageKey,
2046
+ messageVariables: {
2047
+ permissions: missingPermissions.join(', ')
2048
+ },
2049
+ missingPermissions,
2050
+ operator
2051
+ });
2052
+ }
2053
+ }
2054
+ class NoPermissionsFoundException extends _nestjs_common__rspack_import_0.ForbiddenException {
2055
+ constructor(){
2056
+ super({
2057
+ success: false,
2058
+ message: 'No permissions found',
2059
+ messageKey: _constants_message_keys_js__rspack_import_1/* .ERROR_MESSAGES.NO_PERMISSIONS_FOUND */.UU.NO_PERMISSIONS_FOUND
2060
+ });
2061
+ }
2062
+ }
2063
+
2064
+ __webpack_require__.d(__webpack_exports__, {
2065
+ GS: () => (PermissionSystemUnavailableException),
2066
+ d$: () => (NoPermissionsFoundException),
2067
+ z8: () => (InsufficientPermissionsException)
2068
+ });
2069
+
2070
+
2071
+ },
2072
+ 510(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2073
+
2074
+ // EXPORTS
2075
+ __webpack_require__.d(__webpack_exports__, {
2076
+ TD: () => (/* reexport */ JwtAuthGuard),
2077
+ Zb: () => (/* reexport */ OptionalJwtGuard),
2078
+ LQ: () => (/* reexport */ PermissionGuard)
2079
+ });
2080
+
2081
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/index.ts
2082
+ var constants = __webpack_require__(43);
2083
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/message-keys.ts
2084
+ var message_keys = __webpack_require__(389);
2085
+ // EXTERNAL MODULE: external "@nestjs/common"
2086
+ var common_ = __webpack_require__(157);
2087
+ // EXTERNAL MODULE: external "@nestjs/core"
2088
+ var core_ = __webpack_require__(75);
2089
+ ;// CONCATENATED MODULE: external "@nestjs/passport"
2090
+
2091
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/guards/jwt-auth.guard.ts
2092
+ function _ts_decorate(decorators, target, key, desc) {
2093
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2094
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2095
+ r = Reflect.decorate(decorators, target, key, desc);
2096
+ } else {
2097
+ for(var i = decorators.length - 1; i >= 0; i--){
2098
+ if (d = decorators[i]) {
2099
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2100
+ }
2101
+ }
2102
+ }
2103
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2104
+ }
2105
+ function _ts_metadata(metadataKey, metadataValue) {
2106
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2107
+ return Reflect.metadata(metadataKey, metadataValue);
2108
+ }
2109
+ }
2110
+ function _ts_param(paramIndex, decorator) {
2111
+ return function(target, key) {
2112
+ decorator(target, key, paramIndex);
2113
+ };
2114
+ }
2115
+
2116
+
2117
+
2118
+
2119
+ class JwtAuthGuard extends (0,__rspack_external__nestjs_passport_18907953.AuthGuard)('jwt') {
2120
+ reflector;
2121
+ // NOTE: @Inject(Reflector) required for bundled code - external classes need explicit injection
2122
+ constructor(reflector){
2123
+ super(), this.reflector = reflector;
2124
+ }
2125
+ canActivate(context) {
2126
+ // Check if route is marked as public
2127
+ const isPublic = this.reflector.getAllAndOverride(constants/* .IS_PUBLIC_KEY */.jA, [
2128
+ context.getHandler(),
2129
+ context.getClass()
2130
+ ]);
2131
+ if (isPublic) {
2132
+ return true;
2133
+ }
2134
+ return super.canActivate(context);
2135
+ }
2136
+ handleRequest(err, user) {
2137
+ if (err || !user) {
2138
+ throw err || new common_.UnauthorizedException({
2139
+ message: 'Invalid or expired token',
2140
+ messageKey: message_keys/* .AUTH_MESSAGES.TOKEN_INVALID */.mK.TOKEN_INVALID
2141
+ });
2142
+ }
2143
+ return user;
2144
+ }
2145
+ }
2146
+ JwtAuthGuard = _ts_decorate([
2147
+ (0,common_.Injectable)(),
2148
+ _ts_param(0, (0,common_.Inject)(core_.Reflector)),
2149
+ _ts_metadata("design:type", Function),
2150
+ _ts_metadata("design:paramtypes", [
2151
+ typeof core_.Reflector === "undefined" ? Object : core_.Reflector
2152
+ ])
2153
+ ], JwtAuthGuard);
2154
+
2155
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/guards/optional-jwt-auth.guard.ts
2156
+ function optional_jwt_auth_guard_ts_decorate(decorators, target, key, desc) {
2157
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2158
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2159
+ r = Reflect.decorate(decorators, target, key, desc);
2160
+ } else {
2161
+ for(var i = decorators.length - 1; i >= 0; i--){
2162
+ if (d = decorators[i]) {
2163
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2164
+ }
2165
+ }
2166
+ }
2167
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2168
+ }
2169
+ function optional_jwt_auth_guard_ts_metadata(metadataKey, metadataValue) {
2170
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2171
+ return Reflect.metadata(metadataKey, metadataValue);
2172
+ }
2173
+ }
2174
+ function optional_jwt_auth_guard_ts_param(paramIndex, decorator) {
2175
+ return function(target, key) {
2176
+ decorator(target, key, paramIndex);
2177
+ };
2178
+ }
2179
+
2180
+
2181
+
2182
+
2183
+ class OptionalJwtGuard extends (0,__rspack_external__nestjs_passport_18907953.AuthGuard)('jwt') {
2184
+ reflector;
2185
+ constructor(reflector){
2186
+ super(), this.reflector = reflector;
2187
+ }
2188
+ canActivate(context) {
2189
+ const isPublic = this.reflector.getAllAndOverride(constants/* .IS_PUBLIC_KEY */.jA, [
2190
+ context.getHandler(),
2191
+ context.getClass()
2192
+ ]);
2193
+ if (isPublic) {
2194
+ return true;
2195
+ }
2196
+ return super.canActivate(context);
2197
+ }
2198
+ handleRequest(_err, user) {
2199
+ return user || undefined;
2200
+ }
2201
+ }
2202
+ OptionalJwtGuard = optional_jwt_auth_guard_ts_decorate([
2203
+ (0,common_.Injectable)(),
2204
+ optional_jwt_auth_guard_ts_param(0, (0,common_.Inject)(core_.Reflector)),
2205
+ optional_jwt_auth_guard_ts_metadata("design:type", Function),
2206
+ optional_jwt_auth_guard_ts_metadata("design:paramtypes", [
2207
+ typeof core_.Reflector === "undefined" ? Object : core_.Reflector
2208
+ ])
2209
+ ], OptionalJwtGuard);
2210
+
2211
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/exceptions/permission.exception.ts
2212
+ var permission_exception = __webpack_require__(374);
2213
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/modules/shared-permission-cache/shared-permission-cache.service.ts
2214
+ var shared_permission_cache_service = __webpack_require__(657);
2215
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/guards/permission.guard.ts
2216
+ function permission_guard_ts_decorate(decorators, target, key, desc) {
2217
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2218
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2219
+ r = Reflect.decorate(decorators, target, key, desc);
2220
+ } else {
2221
+ for(var i = decorators.length - 1; i >= 0; i--){
2222
+ if (d = decorators[i]) {
2223
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2224
+ }
2225
+ }
2226
+ }
2227
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2228
+ }
2229
+ function permission_guard_ts_metadata(metadataKey, metadataValue) {
2230
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2231
+ return Reflect.metadata(metadataKey, metadataValue);
2232
+ }
2233
+ }
2234
+ function permission_guard_ts_param(paramIndex, decorator) {
2235
+ return function(target, key) {
2236
+ decorator(target, key, paramIndex);
2237
+ };
2238
+ }
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+ class PermissionGuard {
2245
+ reflector;
2246
+ permissionCacheService;
2247
+ constructor(reflector, permissionCacheService){
2248
+ this.reflector = reflector;
2249
+ this.permissionCacheService = permissionCacheService;
2250
+ }
2251
+ async canActivate(context) {
2252
+ const isPublic = this.reflector.getAllAndOverride(constants/* .IS_PUBLIC_KEY */.jA, [
2253
+ context.getHandler(),
2254
+ context.getClass()
2255
+ ]);
2256
+ if (isPublic) return true;
2257
+ const permissionConfig = this.reflector.getAllAndOverride(constants/* .PERMISSIONS_KEY */.N7, [
2258
+ context.getHandler(),
2259
+ context.getClass()
2260
+ ]);
2261
+ if (!permissionConfig) return true;
2262
+ const request = context.switchToHttp().getRequest();
2263
+ const user = request.user;
2264
+ if (!user) throw new common_.UnauthorizedException({
2265
+ message: 'Authentication required',
2266
+ messageKey: message_keys/* .AUTH_MESSAGES.TOKEN_REQUIRED */.mK.TOKEN_REQUIRED
2267
+ });
2268
+ if (!this.permissionCacheService?.isCacheConfigured()) {
2269
+ throw new permission_exception/* .PermissionSystemUnavailableException */.GS();
2270
+ }
2271
+ const permissionService = this.permissionCacheService;
2272
+ const userPermissions = await permissionService.getPermissions({
2273
+ userId: user.id,
2274
+ companyId: user.companyId,
2275
+ branchId: user.branchId
2276
+ });
2277
+ if (!userPermissions || userPermissions.length === 0) {
2278
+ throw new permission_exception/* .NoPermissionsFoundException */.d$();
2279
+ }
2280
+ const logicNode = this.normalizeToLogicNode(permissionConfig);
2281
+ if (!logicNode) return true;
2282
+ const result = this.evaluateLogicNode(logicNode, userPermissions, permissionService);
2283
+ if (!result.passed) {
2284
+ throw new permission_exception/* .InsufficientPermissionsException */.z8(result.missingPermissions, result.operator);
2285
+ }
2286
+ return true;
2287
+ }
2288
+ normalizeToLogicNode(config) {
2289
+ // string - single permission
2290
+ if (typeof config === 'string') {
2291
+ return config ? {
2292
+ type: 'action',
2293
+ actionId: config
2294
+ } : null;
2295
+ }
2296
+ // string[] - treat as AND of multiple permissions
2297
+ if (Array.isArray(config)) {
2298
+ if (config.length === 0) return null;
2299
+ if (config.length === 1) return {
2300
+ type: 'action',
2301
+ actionId: config[0]
2302
+ };
2303
+ return {
2304
+ type: 'group',
2305
+ operator: 'AND',
2306
+ children: config.map((p)=>({
2307
+ type: 'action',
2308
+ actionId: p
2309
+ }))
2310
+ };
2311
+ }
2312
+ // SimplePermissionConfig - { permissions: string[], operator: 'AND'|'OR' }
2313
+ if ('permissions' in config && Array.isArray(config.permissions)) {
2314
+ const simple = config;
2315
+ if (simple.permissions.length === 0) return null;
2316
+ if (simple.permissions.length === 1) return {
2317
+ type: 'action',
2318
+ actionId: simple.permissions[0]
2319
+ };
2320
+ return {
2321
+ type: 'group',
2322
+ operator: simple.operator || 'AND',
2323
+ children: simple.permissions.map((p)=>({
2324
+ type: 'action',
2325
+ actionId: p
2326
+ }))
2327
+ };
2328
+ }
2329
+ // ILogicNode
2330
+ return config;
2331
+ }
2332
+ evaluateLogicNode(node, userPermissions, permissionService) {
2333
+ if (node.type === 'action') {
2334
+ const passed = permissionService.matchPermission(userPermissions, node.actionId);
2335
+ return {
2336
+ passed,
2337
+ missingPermissions: passed ? [] : [
2338
+ node.actionId
2339
+ ],
2340
+ operator: 'AND'
2341
+ };
2342
+ }
2343
+ // Group node
2344
+ const { operator, children } = node;
2345
+ // SECURITY: Fail-closed - deny access when no children configured
2346
+ if (!children || children.length === 0) {
2347
+ return {
2348
+ passed: false,
2349
+ missingPermissions: [],
2350
+ operator
2351
+ };
2352
+ }
2353
+ const results = [];
2354
+ const missingPermissions = [];
2355
+ for (const child of children){
2356
+ const childResult = this.evaluateLogicNode(child, userPermissions, permissionService);
2357
+ results.push(childResult.passed);
2358
+ if (!childResult.passed) {
2359
+ missingPermissions.push(...childResult.missingPermissions);
2360
+ }
2361
+ }
2362
+ const passed = operator === 'OR' ? results.some((r)=>r) : results.every((r)=>r);
2363
+ return {
2364
+ passed,
2365
+ missingPermissions: passed ? [] : missingPermissions,
2366
+ operator
2367
+ };
2368
+ }
2369
+ }
2370
+ PermissionGuard = permission_guard_ts_decorate([
2371
+ (0,common_.Injectable)(),
2372
+ permission_guard_ts_param(0, (0,common_.Inject)(core_.Reflector)),
2373
+ permission_guard_ts_param(1, (0,common_.Optional)()),
2374
+ permission_guard_ts_param(1, (0,common_.Inject)(shared_permission_cache_service/* .SharedPermissionCacheService */.U)),
2375
+ permission_guard_ts_metadata("design:type", Function),
2376
+ permission_guard_ts_metadata("design:paramtypes", [
2377
+ typeof core_.Reflector === "undefined" ? Object : core_.Reflector,
2378
+ typeof shared_permission_cache_service/* .SharedPermissionCacheService */.U === "undefined" ? Object : shared_permission_cache_service/* .SharedPermissionCacheService */.U
2379
+ ])
2380
+ ], PermissionGuard);
2381
+
2382
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/guards/index.ts
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+ },
2389
+ 863(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2390
+
2391
+ // EXPORTS
2392
+ __webpack_require__.d(__webpack_exports__, {
2393
+ nd: () => (/* reexport */ DeleteEmptyIdFromBodyInterceptor),
2394
+ Bw: () => (/* reexport */ IdempotencyInterceptor),
2395
+ c_: () => (/* reexport */ ResponseMetaInterceptor),
2396
+ VS: () => (/* reexport */ SetCreatedByOnBody),
2397
+ Ul: () => (/* reexport */ SetDeletedByOnBody),
2398
+ _x: () => (/* reexport */ SetUpdateByOnBody),
2399
+ Mw: () => (/* reexport */ Slug),
2400
+ BR: () => (/* reexport */ createSetUserFieldInterceptor)
2401
+ });
2402
+
2403
+ // EXTERNAL MODULE: external "@nestjs/common"
2404
+ var common_ = __webpack_require__(157);
2405
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/interceptors/delete-empty-id-from-body.interceptor.ts
2406
+ function _ts_decorate(decorators, target, key, desc) {
2407
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2408
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2409
+ r = Reflect.decorate(decorators, target, key, desc);
2410
+ } else {
2411
+ for(var i = decorators.length - 1; i >= 0; i--){
2412
+ if (d = decorators[i]) {
2413
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2414
+ }
2415
+ }
2416
+ }
2417
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2418
+ }
2419
+
2420
+ class DeleteEmptyIdFromBodyInterceptor {
2421
+ intercept(context, next) {
2422
+ const request = context.switchToHttp().getRequest();
2423
+ if (Array.isArray(request.body)) {
2424
+ request.body = request.body.map((item)=>{
2425
+ if (!item?.id || item?.id === '' || item?.id === null) {
2426
+ delete item.id;
2427
+ }
2428
+ return item;
2429
+ });
2430
+ } else if (typeof request.body === 'object' && request.body !== null) {
2431
+ const item = request.body;
2432
+ if (!item?.id || item?.id === '' || item?.id === null) {
2433
+ delete item.id;
2434
+ }
2435
+ request.body = item;
2436
+ }
2437
+ return next.handle();
2438
+ }
2439
+ }
2440
+ DeleteEmptyIdFromBodyInterceptor = _ts_decorate([
2441
+ (0,common_.Injectable)()
2442
+ ], DeleteEmptyIdFromBodyInterceptor);
2443
+
2444
+ ;// CONCATENATED MODULE: external "rxjs"
2445
+
2446
+ ;// CONCATENATED MODULE: external "rxjs/operators"
2447
+
2448
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/classes/hybrid-cache.class.ts + 3 modules
2449
+ var hybrid_cache_class = __webpack_require__(375);
2450
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/index.ts
2451
+ var constants = __webpack_require__(43);
2452
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/constants/message-keys.ts
2453
+ var message_keys = __webpack_require__(389);
2454
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/interceptors/idempotency.interceptor.ts
2455
+ function idempotency_interceptor_ts_decorate(decorators, target, key, desc) {
2456
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2457
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2458
+ r = Reflect.decorate(decorators, target, key, desc);
2459
+ } else {
2460
+ for(var i = decorators.length - 1; i >= 0; i--){
2461
+ if (d = decorators[i]) {
2462
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2463
+ }
2464
+ }
2465
+ }
2466
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2467
+ }
2468
+ function _ts_metadata(metadataKey, metadataValue) {
2469
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2470
+ return Reflect.metadata(metadataKey, metadataValue);
2471
+ }
2472
+ }
2473
+ function _ts_param(paramIndex, decorator) {
2474
+ return function(target, key) {
2475
+ decorator(target, key, paramIndex);
2476
+ };
2477
+ }
2478
+
2479
+
2480
+
2481
+
2482
+
2483
+ class IdempotencyInterceptor {
2484
+ cache;
2485
+ CACHE_TTL = 24 * 60 * 60 * 1000;
2486
+ PROCESSING_MARKER = '__PROCESSING__';
2487
+ constructor(cache){
2488
+ this.cache = cache;
2489
+ }
2490
+ async intercept(context, next) {
2491
+ // Skip if no cache available
2492
+ if (!this.cache) {
2493
+ return next.handle();
2494
+ }
2495
+ const request = context.switchToHttp().getRequest();
2496
+ const idempotencyKey = request.headers[constants/* .IDEMPOTENCY_KEY_HEADER */.iH];
2497
+ // Skip if no idempotency key provided
2498
+ if (!idempotencyKey) {
2499
+ return next.handle();
2500
+ }
2501
+ const cacheKey = `${constants/* .IDEMPOTENCY_CACHE_PREFIX */.mg}:${idempotencyKey}`;
2502
+ // Check if request already exists
2503
+ const cached = await this.cache.get(cacheKey);
2504
+ if (cached) {
2505
+ // If still processing, throw conflict
2506
+ if (cached === this.PROCESSING_MARKER) {
2507
+ throw new common_.ConflictException({
2508
+ success: false,
2509
+ message: 'Request is already being processed',
2510
+ messageKey: message_keys/* .SYSTEM_MESSAGES.DUPLICATE_REQUEST */.hg.DUPLICATE_REQUEST
2511
+ });
2512
+ }
2513
+ // Return cached response
2514
+ return (0,__rspack_external_rxjs.of)(cached);
2515
+ }
2516
+ // Mark as processing
2517
+ const cache = this.cache;
2518
+ await cache.set(cacheKey, this.PROCESSING_MARKER, this.CACHE_TTL);
2519
+ // Process request and cache response
2520
+ return next.handle().pipe((0,__rspack_external_rxjs_operators_2eaa0997.tap)(async (response)=>{
2521
+ // Cache the successful response
2522
+ await cache.set(cacheKey, response, this.CACHE_TTL);
2523
+ }));
2524
+ }
2525
+ }
2526
+ IdempotencyInterceptor = idempotency_interceptor_ts_decorate([
2527
+ (0,common_.Injectable)(),
2528
+ _ts_param(0, (0,common_.Optional)()),
2529
+ _ts_param(0, (0,common_.Inject)(constants/* .CACHE_INSTANCE */.zl)),
2530
+ _ts_metadata("design:type", Function),
2531
+ _ts_metadata("design:paramtypes", [
2532
+ typeof hybrid_cache_class/* .HybridCache */.l === "undefined" ? Object : hybrid_cache_class/* .HybridCache */.l
2533
+ ])
2534
+ ], IdempotencyInterceptor);
2535
+
2536
+ // EXTERNAL MODULE: external "crypto"
2537
+ var external_crypto_ = __webpack_require__(823);
2538
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/interceptors/response-meta.interceptor.ts
2539
+ function response_meta_interceptor_ts_decorate(decorators, target, key, desc) {
2540
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2541
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2542
+ r = Reflect.decorate(decorators, target, key, desc);
2543
+ } else {
2544
+ for(var i = decorators.length - 1; i >= 0; i--){
2545
+ if (d = decorators[i]) {
2546
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2547
+ }
2548
+ }
2549
+ }
2550
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2551
+ }
2552
+
2553
+
2554
+
2555
+
2556
+ class ResponseMetaInterceptor {
2557
+ intercept(context, next) {
2558
+ const request = context.switchToHttp().getRequest();
2559
+ const startTime = Date.now();
2560
+ // Generate or use existing request ID
2561
+ const requestId = request.headers[constants/* .REQUEST_ID_HEADER */.kC] || `req_${(0,external_crypto_.randomUUID)().slice(0, 12)}`;
2562
+ // Store request ID for logging
2563
+ request.requestId = requestId;
2564
+ return next.handle().pipe((0,__rspack_external_rxjs_operators_2eaa0997.map)((response)=>{
2565
+ // Only add metadata if response is an object with success field
2566
+ if (response && typeof response === 'object' && 'success' in response) {
2567
+ return {
2568
+ ...response,
2569
+ _meta: {
2570
+ requestId,
2571
+ timestamp: new Date().toISOString(),
2572
+ responseTime: Date.now() - startTime
2573
+ }
2574
+ };
2575
+ }
2576
+ return response;
2577
+ }));
2578
+ }
2579
+ }
2580
+ ResponseMetaInterceptor = response_meta_interceptor_ts_decorate([
2581
+ (0,common_.Injectable)()
2582
+ ], ResponseMetaInterceptor);
2583
+
2584
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/interceptors/set-user-field-on-body.interceptor.ts
2585
+ function set_user_field_on_body_interceptor_ts_decorate(decorators, target, key, desc) {
2586
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2587
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2588
+ r = Reflect.decorate(decorators, target, key, desc);
2589
+ } else {
2590
+ for(var i = decorators.length - 1; i >= 0; i--){
2591
+ if (d = decorators[i]) {
2592
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2593
+ }
2594
+ }
2595
+ }
2596
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2597
+ }
2598
+
2599
+ /**
2600
+ * Factory function to create interceptors that set user ID fields on request body
2601
+ * @param fieldName - The field name to set (e.g., 'createdById', 'updatedById', 'deletedById')
2602
+ */ function createSetUserFieldInterceptor(fieldName) {
2603
+ let SetUserFieldOnBody = class SetUserFieldOnBody {
2604
+ intercept(context, next) {
2605
+ const request = context.switchToHttp().getRequest();
2606
+ const user = request?.user;
2607
+ if (user) {
2608
+ if (Array.isArray(request.body)) {
2609
+ request.body = request.body.map((item)=>({
2610
+ ...item,
2611
+ [fieldName]: user.id
2612
+ }));
2613
+ } else if (typeof request.body === 'object' && request.body !== null) {
2614
+ request.body = {
2615
+ ...request.body,
2616
+ [fieldName]: user.id
2617
+ };
2618
+ }
2619
+ }
2620
+ return next.handle();
2621
+ }
2622
+ };
2623
+ SetUserFieldOnBody = set_user_field_on_body_interceptor_ts_decorate([
2624
+ (0,common_.Injectable)()
2625
+ ], SetUserFieldOnBody);
2626
+ return SetUserFieldOnBody;
2627
+ }
2628
+ /** Sets createdById field on request body from authenticated user */ const SetCreatedByOnBody = createSetUserFieldInterceptor('createdById');
2629
+ /** Sets updatedById field on request body from authenticated user */ const SetUpdateByOnBody = createSetUserFieldInterceptor('updatedById');
2630
+ /** Sets deletedById field on request body from authenticated user */ const SetDeletedByOnBody = createSetUserFieldInterceptor('deletedById');
2631
+
2632
+ // EXTERNAL MODULE: ./projects/nestjs-shared/src/modules/utils/utils.service.ts
2633
+ var utils_service = __webpack_require__(169);
2634
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/interceptors/slug.interceptor.ts
2635
+ function slug_interceptor_ts_decorate(decorators, target, key, desc) {
2636
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2637
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2638
+ r = Reflect.decorate(decorators, target, key, desc);
2639
+ } else {
2640
+ for(var i = decorators.length - 1; i >= 0; i--){
2641
+ if (d = decorators[i]) {
2642
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2643
+ }
2644
+ }
2645
+ }
2646
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2647
+ }
2648
+ function slug_interceptor_ts_metadata(metadataKey, metadataValue) {
2649
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2650
+ return Reflect.metadata(metadataKey, metadataValue);
2651
+ }
2652
+ }
2653
+ function slug_interceptor_ts_param(paramIndex, decorator) {
2654
+ return function(target, key) {
2655
+ decorator(target, key, paramIndex);
2656
+ };
2657
+ }
2658
+
2659
+
2660
+ class Slug {
2661
+ utilsService;
2662
+ constructor(utilsService){
2663
+ this.utilsService = utilsService;
2664
+ }
2665
+ intercept(context, next) {
2666
+ const request = context.switchToHttp().getRequest();
2667
+ if (Array.isArray(request.body)) {
2668
+ request.body = request.body.map((item)=>{
2669
+ // Only generate slug if not provided and name exists
2670
+ if (!item.slug && item?.name) {
2671
+ return {
2672
+ ...item,
2673
+ slug: this.utilsService.transformToSlug(item.name)
2674
+ };
2675
+ }
2676
+ return item;
2677
+ });
2678
+ } else if (!request.body?.slug && request.body?.name) {
2679
+ // Only generate slug if not provided and name exists
2680
+ request.body = {
2681
+ ...request.body,
2682
+ slug: this.utilsService.transformToSlug(request.body.name)
2683
+ };
2684
+ }
2685
+ return next.handle();
2686
+ }
2687
+ }
2688
+ Slug = slug_interceptor_ts_decorate([
2689
+ (0,common_.Injectable)(),
2690
+ slug_interceptor_ts_param(0, (0,common_.Inject)(utils_service/* .UtilsService */.T)),
2691
+ slug_interceptor_ts_metadata("design:type", Function),
2692
+ slug_interceptor_ts_metadata("design:paramtypes", [
2693
+ typeof utils_service/* .UtilsService */.T === "undefined" ? Object : utils_service/* .UtilsService */.T
2694
+ ])
2695
+ ], Slug);
2696
+
2697
+ ;// CONCATENATED MODULE: ./projects/nestjs-shared/src/interceptors/index.ts
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+
2704
+
2705
+ },
2706
+ 823(module) {
2707
+
2708
+ module.exports = __rspack_external_crypto;
2709
+
2710
+
2711
+ },
2712
+
2713
+ };