@intlayer/backend 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/LICENSE +202 -0
  2. package/dist/cjs/controllers/dictionary.controller.cjs +356 -0
  3. package/dist/cjs/controllers/dictionary.controller.cjs.map +1 -0
  4. package/dist/cjs/controllers/oAuth2.controller.cjs +46 -0
  5. package/dist/cjs/controllers/oAuth2.controller.cjs.map +1 -0
  6. package/dist/cjs/controllers/organization.controller.cjs +354 -0
  7. package/dist/cjs/controllers/organization.controller.cjs.map +1 -0
  8. package/dist/cjs/controllers/project.controller.cjs +298 -0
  9. package/dist/cjs/controllers/project.controller.cjs.map +1 -0
  10. package/dist/cjs/controllers/projectAccessKey.controller.cjs +134 -0
  11. package/dist/cjs/controllers/projectAccessKey.controller.cjs.map +1 -0
  12. package/dist/cjs/controllers/sessionAuth.controller.cjs +616 -0
  13. package/dist/cjs/controllers/sessionAuth.controller.cjs.map +1 -0
  14. package/dist/cjs/controllers/user.controller.cjs +197 -0
  15. package/dist/cjs/controllers/user.controller.cjs.map +1 -0
  16. package/dist/cjs/emails/InviteUserEmail.cjs +297 -0
  17. package/dist/cjs/emails/InviteUserEmail.cjs.map +1 -0
  18. package/dist/cjs/emails/PasswordChangeConfirmation.cjs +148 -0
  19. package/dist/cjs/emails/PasswordChangeConfirmation.cjs.map +1 -0
  20. package/dist/cjs/emails/ResetUserPassword.cjs +209 -0
  21. package/dist/cjs/emails/ResetUserPassword.cjs.map +1 -0
  22. package/dist/cjs/emails/ValidateUserEmail.cjs +230 -0
  23. package/dist/cjs/emails/ValidateUserEmail.cjs.map +1 -0
  24. package/dist/cjs/emails/Welcome.cjs +185 -0
  25. package/dist/cjs/emails/Welcome.cjs.map +1 -0
  26. package/dist/cjs/emails/index.cjs +31 -0
  27. package/dist/cjs/emails/index.cjs.map +1 -0
  28. package/dist/cjs/export.cjs +46 -0
  29. package/dist/cjs/export.cjs.map +1 -0
  30. package/dist/cjs/index.cjs +122 -0
  31. package/dist/cjs/index.cjs.map +1 -0
  32. package/dist/cjs/logger/index.cjs +53 -0
  33. package/dist/cjs/logger/index.cjs.map +1 -0
  34. package/dist/cjs/middlewares/admin.middleware.cjs +44 -0
  35. package/dist/cjs/middlewares/admin.middleware.cjs.map +1 -0
  36. package/dist/cjs/middlewares/oAuth2.middleware.cjs +89 -0
  37. package/dist/cjs/middlewares/oAuth2.middleware.cjs.map +1 -0
  38. package/dist/cjs/middlewares/request.middleware.cjs +41 -0
  39. package/dist/cjs/middlewares/request.middleware.cjs.map +1 -0
  40. package/dist/cjs/middlewares/sessionAuth.middleware.cjs +130 -0
  41. package/dist/cjs/middlewares/sessionAuth.middleware.cjs.map +1 -0
  42. package/dist/cjs/models/dictionary.model.cjs +34 -0
  43. package/dist/cjs/models/dictionary.model.cjs.map +1 -0
  44. package/dist/cjs/models/oAuth2.model.cjs +31 -0
  45. package/dist/cjs/models/oAuth2.model.cjs.map +1 -0
  46. package/dist/cjs/models/organization.model.cjs +34 -0
  47. package/dist/cjs/models/organization.model.cjs.map +1 -0
  48. package/dist/cjs/models/project.model.cjs +31 -0
  49. package/dist/cjs/models/project.model.cjs.map +1 -0
  50. package/dist/cjs/models/user.model.cjs +31 -0
  51. package/dist/cjs/models/user.model.cjs.map +1 -0
  52. package/dist/cjs/routes/dictionary.routes.cjs +156 -0
  53. package/dist/cjs/routes/dictionary.routes.cjs.map +1 -0
  54. package/dist/cjs/routes/organization.routes.cjs +132 -0
  55. package/dist/cjs/routes/organization.routes.cjs.map +1 -0
  56. package/dist/cjs/routes/project.routes.cjs +175 -0
  57. package/dist/cjs/routes/project.routes.cjs.map +1 -0
  58. package/dist/cjs/routes/sessionAuth.routes.cjs +147 -0
  59. package/dist/cjs/routes/sessionAuth.routes.cjs.map +1 -0
  60. package/dist/cjs/routes/user.routes.cjs +96 -0
  61. package/dist/cjs/routes/user.routes.cjs.map +1 -0
  62. package/dist/cjs/schemas/dictionary.schema.cjs +69 -0
  63. package/dist/cjs/schemas/dictionary.schema.cjs.map +1 -0
  64. package/dist/cjs/schemas/oAuth2.schema.cjs +55 -0
  65. package/dist/cjs/schemas/oAuth2.schema.cjs.map +1 -0
  66. package/dist/cjs/schemas/organization.schema.cjs +60 -0
  67. package/dist/cjs/schemas/organization.schema.cjs.map +1 -0
  68. package/dist/cjs/schemas/project.schema.cjs +79 -0
  69. package/dist/cjs/schemas/project.schema.cjs.map +1 -0
  70. package/dist/cjs/schemas/user.schema.cjs +112 -0
  71. package/dist/cjs/schemas/user.schema.cjs.map +1 -0
  72. package/dist/cjs/services/dictionary.service.cjs +166 -0
  73. package/dist/cjs/services/dictionary.service.cjs.map +1 -0
  74. package/dist/cjs/services/email.service.cjs +118 -0
  75. package/dist/cjs/services/email.service.cjs.map +1 -0
  76. package/dist/cjs/services/oAuth2.service.cjs +182 -0
  77. package/dist/cjs/services/oAuth2.service.cjs.map +1 -0
  78. package/dist/cjs/services/organization.service.cjs +95 -0
  79. package/dist/cjs/services/organization.service.cjs.map +1 -0
  80. package/dist/cjs/services/project.service.cjs +87 -0
  81. package/dist/cjs/services/project.service.cjs.map +1 -0
  82. package/dist/cjs/services/projectAccessKey.service.cjs +139 -0
  83. package/dist/cjs/services/projectAccessKey.service.cjs.map +1 -0
  84. package/dist/cjs/services/sessionAuth.service.cjs +386 -0
  85. package/dist/cjs/services/sessionAuth.service.cjs.map +1 -0
  86. package/dist/cjs/services/user.service.cjs +155 -0
  87. package/dist/cjs/services/user.service.cjs.map +1 -0
  88. package/dist/cjs/types/Routes.cjs +17 -0
  89. package/dist/cjs/types/Routes.cjs.map +1 -0
  90. package/dist/cjs/types/dictionary.types.cjs +17 -0
  91. package/dist/cjs/types/dictionary.types.cjs.map +1 -0
  92. package/dist/cjs/types/organization.types.cjs +17 -0
  93. package/dist/cjs/types/organization.types.cjs.map +1 -0
  94. package/dist/cjs/types/project.types.cjs +17 -0
  95. package/dist/cjs/types/project.types.cjs.map +1 -0
  96. package/dist/cjs/types/session.types.cjs +17 -0
  97. package/dist/cjs/types/session.types.cjs.map +1 -0
  98. package/dist/cjs/types/user.types.cjs +17 -0
  99. package/dist/cjs/types/user.types.cjs.map +1 -0
  100. package/dist/cjs/utils/CSRF.cjs +47 -0
  101. package/dist/cjs/utils/CSRF.cjs.map +1 -0
  102. package/dist/cjs/utils/accessControl.cjs +121 -0
  103. package/dist/cjs/utils/accessControl.cjs.map +1 -0
  104. package/dist/cjs/utils/cookies.cjs +59 -0
  105. package/dist/cjs/utils/cookies.cjs.map +1 -0
  106. package/dist/cjs/utils/errors/ErrorHandler.cjs +103 -0
  107. package/dist/cjs/utils/errors/ErrorHandler.cjs.map +1 -0
  108. package/dist/cjs/utils/errors/ErrorsClass.cjs +65 -0
  109. package/dist/cjs/utils/errors/ErrorsClass.cjs.map +1 -0
  110. package/dist/cjs/utils/errors/errorCodes.cjs +837 -0
  111. package/dist/cjs/utils/errors/errorCodes.cjs.map +1 -0
  112. package/dist/cjs/utils/errors/index.cjs +37 -0
  113. package/dist/cjs/utils/errors/index.cjs.map +1 -0
  114. package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs +55 -0
  115. package/dist/cjs/utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs.map +1 -0
  116. package/dist/cjs/utils/filtersAndPagination/getFiltersAndPaginationFromBody.cjs +65 -0
  117. package/dist/cjs/utils/filtersAndPagination/getFiltersAndPaginationFromBody.cjs.map +1 -0
  118. package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs +55 -0
  119. package/dist/cjs/utils/filtersAndPagination/getOrganizationFiltersAndPagination.cjs.map +1 -0
  120. package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs +58 -0
  121. package/dist/cjs/utils/filtersAndPagination/getProjectFiltersAndPagination.cjs.map +1 -0
  122. package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs +52 -0
  123. package/dist/cjs/utils/filtersAndPagination/getUserFiltersAndPagination.cjs.map +1 -0
  124. package/dist/cjs/utils/httpStatusCodes.cjs +93 -0
  125. package/dist/cjs/utils/httpStatusCodes.cjs.map +1 -0
  126. package/dist/cjs/utils/mapper/dictionary.cjs +40 -0
  127. package/dist/cjs/utils/mapper/dictionary.cjs.map +1 -0
  128. package/dist/cjs/utils/mapper/organization.cjs +39 -0
  129. package/dist/cjs/utils/mapper/organization.cjs.map +1 -0
  130. package/dist/cjs/utils/mapper/project.cjs +39 -0
  131. package/dist/cjs/utils/mapper/project.cjs.map +1 -0
  132. package/dist/cjs/utils/mapper/user.cjs +39 -0
  133. package/dist/cjs/utils/mapper/user.cjs.map +1 -0
  134. package/dist/cjs/utils/mongoDB/connectDB.cjs +53 -0
  135. package/dist/cjs/utils/mongoDB/connectDB.cjs.map +1 -0
  136. package/dist/cjs/utils/oAuth2.cjs +50 -0
  137. package/dist/cjs/utils/oAuth2.cjs.map +1 -0
  138. package/dist/cjs/utils/responseData.cjs +66 -0
  139. package/dist/cjs/utils/responseData.cjs.map +1 -0
  140. package/dist/cjs/utils/validation/validateArray.cjs +57 -0
  141. package/dist/cjs/utils/validation/validateArray.cjs.map +1 -0
  142. package/dist/cjs/utils/validation/validateDictionary.cjs +66 -0
  143. package/dist/cjs/utils/validation/validateDictionary.cjs.map +1 -0
  144. package/dist/cjs/utils/validation/validateEmail.cjs +37 -0
  145. package/dist/cjs/utils/validation/validateEmail.cjs.map +1 -0
  146. package/dist/cjs/utils/validation/validateOrganization.cjs +79 -0
  147. package/dist/cjs/utils/validation/validateOrganization.cjs.map +1 -0
  148. package/dist/cjs/utils/validation/validatePhone.cjs +37 -0
  149. package/dist/cjs/utils/validation/validatePhone.cjs.map +1 -0
  150. package/dist/cjs/utils/validation/validateProject.cjs +97 -0
  151. package/dist/cjs/utils/validation/validateProject.cjs.map +1 -0
  152. package/dist/cjs/utils/validation/validateString.cjs +39 -0
  153. package/dist/cjs/utils/validation/validateString.cjs.map +1 -0
  154. package/dist/cjs/utils/validation/validateUser.cjs +73 -0
  155. package/dist/cjs/utils/validation/validateUser.cjs.map +1 -0
  156. package/dist/esm/controllers/dictionary.controller.mjs +321 -0
  157. package/dist/esm/controllers/dictionary.controller.mjs.map +1 -0
  158. package/dist/esm/controllers/oAuth2.controller.mjs +25 -0
  159. package/dist/esm/controllers/oAuth2.controller.mjs.map +1 -0
  160. package/dist/esm/controllers/organization.controller.mjs +317 -0
  161. package/dist/esm/controllers/organization.controller.mjs.map +1 -0
  162. package/dist/esm/controllers/project.controller.mjs +263 -0
  163. package/dist/esm/controllers/project.controller.mjs.map +1 -0
  164. package/dist/esm/controllers/projectAccessKey.controller.mjs +98 -0
  165. package/dist/esm/controllers/projectAccessKey.controller.mjs.map +1 -0
  166. package/dist/esm/controllers/sessionAuth.controller.mjs +570 -0
  167. package/dist/esm/controllers/sessionAuth.controller.mjs.map +1 -0
  168. package/dist/esm/controllers/user.controller.mjs +160 -0
  169. package/dist/esm/controllers/user.controller.mjs.map +1 -0
  170. package/dist/esm/emails/InviteUserEmail.mjs +285 -0
  171. package/dist/esm/emails/InviteUserEmail.mjs.map +1 -0
  172. package/dist/esm/emails/PasswordChangeConfirmation.mjs +134 -0
  173. package/dist/esm/emails/PasswordChangeConfirmation.mjs.map +1 -0
  174. package/dist/esm/emails/ResetUserPassword.mjs +197 -0
  175. package/dist/esm/emails/ResetUserPassword.mjs.map +1 -0
  176. package/dist/esm/emails/ValidateUserEmail.mjs +218 -0
  177. package/dist/esm/emails/ValidateUserEmail.mjs.map +1 -0
  178. package/dist/esm/emails/Welcome.mjs +173 -0
  179. package/dist/esm/emails/Welcome.mjs.map +1 -0
  180. package/dist/esm/emails/index.mjs +6 -0
  181. package/dist/esm/emails/index.mjs.map +1 -0
  182. package/dist/esm/export.mjs +15 -0
  183. package/dist/esm/export.mjs.map +1 -0
  184. package/dist/esm/index.mjs +102 -0
  185. package/dist/esm/index.mjs.map +1 -0
  186. package/dist/esm/logger/index.mjs +29 -0
  187. package/dist/esm/logger/index.mjs.map +1 -0
  188. package/dist/esm/middlewares/admin.middleware.mjs +20 -0
  189. package/dist/esm/middlewares/admin.middleware.mjs.map +1 -0
  190. package/dist/esm/middlewares/oAuth2.middleware.mjs +57 -0
  191. package/dist/esm/middlewares/oAuth2.middleware.mjs.map +1 -0
  192. package/dist/esm/middlewares/request.middleware.mjs +17 -0
  193. package/dist/esm/middlewares/request.middleware.mjs.map +1 -0
  194. package/dist/esm/middlewares/sessionAuth.middleware.mjs +96 -0
  195. package/dist/esm/middlewares/sessionAuth.middleware.mjs.map +1 -0
  196. package/dist/esm/models/dictionary.model.mjs +10 -0
  197. package/dist/esm/models/dictionary.model.mjs.map +1 -0
  198. package/dist/esm/models/oAuth2.model.mjs +7 -0
  199. package/dist/esm/models/oAuth2.model.mjs.map +1 -0
  200. package/dist/esm/models/organization.model.mjs +10 -0
  201. package/dist/esm/models/organization.model.mjs.map +1 -0
  202. package/dist/esm/models/project.model.mjs +7 -0
  203. package/dist/esm/models/project.model.mjs.map +1 -0
  204. package/dist/esm/models/user.model.mjs +7 -0
  205. package/dist/esm/models/user.model.mjs.map +1 -0
  206. package/dist/esm/routes/dictionary.routes.mjs +139 -0
  207. package/dist/esm/routes/dictionary.routes.mjs.map +1 -0
  208. package/dist/esm/routes/organization.routes.mjs +116 -0
  209. package/dist/esm/routes/organization.routes.mjs.map +1 -0
  210. package/dist/esm/routes/project.routes.mjs +162 -0
  211. package/dist/esm/routes/project.routes.mjs.map +1 -0
  212. package/dist/esm/routes/sessionAuth.routes.mjs +134 -0
  213. package/dist/esm/routes/sessionAuth.routes.mjs.map +1 -0
  214. package/dist/esm/routes/user.routes.mjs +78 -0
  215. package/dist/esm/routes/user.routes.mjs.map +1 -0
  216. package/dist/esm/schemas/dictionary.schema.mjs +45 -0
  217. package/dist/esm/schemas/dictionary.schema.mjs.map +1 -0
  218. package/dist/esm/schemas/oAuth2.schema.mjs +31 -0
  219. package/dist/esm/schemas/oAuth2.schema.mjs.map +1 -0
  220. package/dist/esm/schemas/organization.schema.mjs +40 -0
  221. package/dist/esm/schemas/organization.schema.mjs.map +1 -0
  222. package/dist/esm/schemas/project.schema.mjs +59 -0
  223. package/dist/esm/schemas/project.schema.mjs.map +1 -0
  224. package/dist/esm/schemas/user.schema.mjs +81 -0
  225. package/dist/esm/schemas/user.schema.mjs.map +1 -0
  226. package/dist/esm/services/dictionary.service.mjs +134 -0
  227. package/dist/esm/services/dictionary.service.mjs.map +1 -0
  228. package/dist/esm/services/email.service.mjs +114 -0
  229. package/dist/esm/services/email.service.mjs.map +1 -0
  230. package/dist/esm/services/oAuth2.service.mjs +150 -0
  231. package/dist/esm/services/oAuth2.service.mjs.map +1 -0
  232. package/dist/esm/services/organization.service.mjs +68 -0
  233. package/dist/esm/services/organization.service.mjs.map +1 -0
  234. package/dist/esm/services/project.service.mjs +60 -0
  235. package/dist/esm/services/project.service.mjs.map +1 -0
  236. package/dist/esm/services/projectAccessKey.service.mjs +113 -0
  237. package/dist/esm/services/projectAccessKey.service.mjs.map +1 -0
  238. package/dist/esm/services/sessionAuth.service.mjs +337 -0
  239. package/dist/esm/services/sessionAuth.service.mjs.map +1 -0
  240. package/dist/esm/services/user.service.mjs +122 -0
  241. package/dist/esm/services/user.service.mjs.map +1 -0
  242. package/dist/esm/types/Routes.mjs +1 -0
  243. package/dist/esm/types/Routes.mjs.map +1 -0
  244. package/dist/esm/types/dictionary.types.mjs +1 -0
  245. package/dist/esm/types/dictionary.types.mjs.map +1 -0
  246. package/dist/esm/types/organization.types.mjs +1 -0
  247. package/dist/esm/types/organization.types.mjs.map +1 -0
  248. package/dist/esm/types/project.types.mjs +1 -0
  249. package/dist/esm/types/project.types.mjs.map +1 -0
  250. package/dist/esm/types/session.types.mjs +1 -0
  251. package/dist/esm/types/session.types.mjs.map +1 -0
  252. package/dist/esm/types/user.types.mjs +1 -0
  253. package/dist/esm/types/user.types.mjs.map +1 -0
  254. package/dist/esm/utils/CSRF.mjs +21 -0
  255. package/dist/esm/utils/CSRF.mjs.map +1 -0
  256. package/dist/esm/utils/accessControl.mjs +95 -0
  257. package/dist/esm/utils/accessControl.mjs.map +1 -0
  258. package/dist/esm/utils/cookies.mjs +32 -0
  259. package/dist/esm/utils/cookies.mjs.map +1 -0
  260. package/dist/esm/utils/errors/ErrorHandler.mjs +79 -0
  261. package/dist/esm/utils/errors/ErrorHandler.mjs.map +1 -0
  262. package/dist/esm/utils/errors/ErrorsClass.mjs +40 -0
  263. package/dist/esm/utils/errors/ErrorsClass.mjs.map +1 -0
  264. package/dist/esm/utils/errors/errorCodes.mjs +813 -0
  265. package/dist/esm/utils/errors/errorCodes.mjs.map +1 -0
  266. package/dist/esm/utils/errors/index.mjs +10 -0
  267. package/dist/esm/utils/errors/index.mjs.map +1 -0
  268. package/dist/esm/utils/filtersAndPagination/getDictionaryFiltersAndPagination.mjs +33 -0
  269. package/dist/esm/utils/filtersAndPagination/getDictionaryFiltersAndPagination.mjs.map +1 -0
  270. package/dist/esm/utils/filtersAndPagination/getFiltersAndPaginationFromBody.mjs +41 -0
  271. package/dist/esm/utils/filtersAndPagination/getFiltersAndPaginationFromBody.mjs.map +1 -0
  272. package/dist/esm/utils/filtersAndPagination/getOrganizationFiltersAndPagination.mjs +33 -0
  273. package/dist/esm/utils/filtersAndPagination/getOrganizationFiltersAndPagination.mjs.map +1 -0
  274. package/dist/esm/utils/filtersAndPagination/getProjectFiltersAndPagination.mjs +36 -0
  275. package/dist/esm/utils/filtersAndPagination/getProjectFiltersAndPagination.mjs.map +1 -0
  276. package/dist/esm/utils/filtersAndPagination/getUserFiltersAndPagination.mjs +30 -0
  277. package/dist/esm/utils/filtersAndPagination/getUserFiltersAndPagination.mjs.map +1 -0
  278. package/dist/esm/utils/httpStatusCodes.mjs +69 -0
  279. package/dist/esm/utils/httpStatusCodes.mjs.map +1 -0
  280. package/dist/esm/utils/mapper/dictionary.mjs +16 -0
  281. package/dist/esm/utils/mapper/dictionary.mjs.map +1 -0
  282. package/dist/esm/utils/mapper/organization.mjs +15 -0
  283. package/dist/esm/utils/mapper/organization.mjs.map +1 -0
  284. package/dist/esm/utils/mapper/project.mjs +15 -0
  285. package/dist/esm/utils/mapper/project.mjs.map +1 -0
  286. package/dist/esm/utils/mapper/user.mjs +14 -0
  287. package/dist/esm/utils/mapper/user.mjs.map +1 -0
  288. package/dist/esm/utils/mongoDB/connectDB.mjs +19 -0
  289. package/dist/esm/utils/mongoDB/connectDB.mjs.map +1 -0
  290. package/dist/esm/utils/oAuth2.mjs +29 -0
  291. package/dist/esm/utils/oAuth2.mjs.map +1 -0
  292. package/dist/esm/utils/responseData.mjs +41 -0
  293. package/dist/esm/utils/responseData.mjs.map +1 -0
  294. package/dist/esm/utils/validation/validateArray.mjs +33 -0
  295. package/dist/esm/utils/validation/validateArray.mjs.map +1 -0
  296. package/dist/esm/utils/validation/validateDictionary.mjs +42 -0
  297. package/dist/esm/utils/validation/validateDictionary.mjs.map +1 -0
  298. package/dist/esm/utils/validation/validateEmail.mjs +13 -0
  299. package/dist/esm/utils/validation/validateEmail.mjs.map +1 -0
  300. package/dist/esm/utils/validation/validateOrganization.mjs +52 -0
  301. package/dist/esm/utils/validation/validateOrganization.mjs.map +1 -0
  302. package/dist/esm/utils/validation/validatePhone.mjs +13 -0
  303. package/dist/esm/utils/validation/validatePhone.mjs.map +1 -0
  304. package/dist/esm/utils/validation/validateProject.mjs +70 -0
  305. package/dist/esm/utils/validation/validateProject.mjs.map +1 -0
  306. package/dist/esm/utils/validation/validateString.mjs +15 -0
  307. package/dist/esm/utils/validation/validateString.mjs.map +1 -0
  308. package/dist/esm/utils/validation/validateUser.mjs +47 -0
  309. package/dist/esm/utils/validation/validateUser.mjs.map +1 -0
  310. package/dist/types/controllers/dictionary.controller.d.ts +70 -0
  311. package/dist/types/controllers/dictionary.controller.d.ts.map +1 -0
  312. package/dist/types/controllers/oAuth2.controller.d.ts +14 -0
  313. package/dist/types/controllers/oAuth2.controller.d.ts.map +1 -0
  314. package/dist/types/controllers/organization.controller.d.ts +72 -0
  315. package/dist/types/controllers/organization.controller.d.ts.map +1 -0
  316. package/dist/types/controllers/project.controller.d.ts +59 -0
  317. package/dist/types/controllers/project.controller.d.ts.map +1 -0
  318. package/dist/types/controllers/projectAccessKey.controller.d.ts +27 -0
  319. package/dist/types/controllers/projectAccessKey.controller.d.ts.map +1 -0
  320. package/dist/types/controllers/sessionAuth.controller.d.ts +120 -0
  321. package/dist/types/controllers/sessionAuth.controller.d.ts.map +1 -0
  322. package/dist/types/controllers/user.controller.d.ts +56 -0
  323. package/dist/types/controllers/user.controller.d.ts.map +1 -0
  324. package/dist/types/emails/InviteUserEmail.d.ts +22 -0
  325. package/dist/types/emails/InviteUserEmail.d.ts.map +1 -0
  326. package/dist/types/emails/PasswordChangeConfirmation.d.ts +16 -0
  327. package/dist/types/emails/PasswordChangeConfirmation.d.ts.map +1 -0
  328. package/dist/types/emails/ResetUserPassword.d.ts +17 -0
  329. package/dist/types/emails/ResetUserPassword.d.ts.map +1 -0
  330. package/dist/types/emails/ValidateUserEmail.d.ts +17 -0
  331. package/dist/types/emails/ValidateUserEmail.d.ts.map +1 -0
  332. package/dist/types/emails/Welcome.d.ts +17 -0
  333. package/dist/types/emails/Welcome.d.ts.map +1 -0
  334. package/dist/types/emails/index.d.ts +6 -0
  335. package/dist/types/emails/index.d.ts.map +1 -0
  336. package/dist/types/export.d.ts +19 -0
  337. package/dist/types/export.d.ts.map +1 -0
  338. package/dist/types/index.d.ts +4 -0
  339. package/dist/types/index.d.ts.map +1 -0
  340. package/dist/types/logger/index.d.ts +2 -0
  341. package/dist/types/logger/index.d.ts.map +1 -0
  342. package/dist/types/middlewares/admin.middleware.d.ts +10 -0
  343. package/dist/types/middlewares/admin.middleware.d.ts.map +1 -0
  344. package/dist/types/middlewares/oAuth2.middleware.d.ts +9 -0
  345. package/dist/types/middlewares/oAuth2.middleware.d.ts.map +1 -0
  346. package/dist/types/middlewares/request.middleware.d.ts +4 -0
  347. package/dist/types/middlewares/request.middleware.d.ts.map +1 -0
  348. package/dist/types/middlewares/sessionAuth.middleware.d.ts +20 -0
  349. package/dist/types/middlewares/sessionAuth.middleware.d.ts.map +1 -0
  350. package/dist/types/models/dictionary.model.d.ts +11 -0
  351. package/dist/types/models/dictionary.model.d.ts.map +1 -0
  352. package/dist/types/models/oAuth2.model.d.ts +10 -0
  353. package/dist/types/models/oAuth2.model.d.ts.map +1 -0
  354. package/dist/types/models/organization.model.d.ts +12 -0
  355. package/dist/types/models/organization.model.d.ts.map +1 -0
  356. package/dist/types/models/project.model.d.ts +12 -0
  357. package/dist/types/models/project.model.d.ts.map +1 -0
  358. package/dist/types/models/user.model.d.ts +3 -0
  359. package/dist/types/models/user.model.d.ts.map +1 -0
  360. package/dist/types/routes/dictionary.routes.d.ts +42 -0
  361. package/dist/types/routes/dictionary.routes.d.ts.map +1 -0
  362. package/dist/types/routes/organization.routes.d.ts +47 -0
  363. package/dist/types/routes/organization.routes.d.ts.map +1 -0
  364. package/dist/types/routes/project.routes.d.ts +57 -0
  365. package/dist/types/routes/project.routes.d.ts.map +1 -0
  366. package/dist/types/routes/sessionAuth.routes.d.ts +66 -0
  367. package/dist/types/routes/sessionAuth.routes.d.ts.map +1 -0
  368. package/dist/types/routes/user.routes.d.ts +42 -0
  369. package/dist/types/routes/user.routes.d.ts.map +1 -0
  370. package/dist/types/schemas/dictionary.schema.d.ts +16 -0
  371. package/dist/types/schemas/dictionary.schema.d.ts.map +1 -0
  372. package/dist/types/schemas/oAuth2.schema.d.ts +19 -0
  373. package/dist/types/schemas/oAuth2.schema.d.ts.map +1 -0
  374. package/dist/types/schemas/organization.schema.d.ts +17 -0
  375. package/dist/types/schemas/organization.schema.d.ts.map +1 -0
  376. package/dist/types/schemas/project.schema.d.ts +17 -0
  377. package/dist/types/schemas/project.schema.d.ts.map +1 -0
  378. package/dist/types/schemas/user.schema.d.ts +12 -0
  379. package/dist/types/schemas/user.schema.d.ts.map +1 -0
  380. package/dist/types/services/dictionary.service.d.ts +70 -0
  381. package/dist/types/services/dictionary.service.d.ts.map +1 -0
  382. package/dist/types/services/email.service.d.ts +18 -0
  383. package/dist/types/services/email.service.d.ts.map +1 -0
  384. package/dist/types/services/oAuth2.service.d.ts +85 -0
  385. package/dist/types/services/oAuth2.service.d.ts.map +1 -0
  386. package/dist/types/services/organization.service.d.ts +43 -0
  387. package/dist/types/services/organization.service.d.ts.map +1 -0
  388. package/dist/types/services/project.service.d.ts +43 -0
  389. package/dist/types/services/project.service.d.ts.map +1 -0
  390. package/dist/types/services/projectAccessKey.service.d.ts +16 -0
  391. package/dist/types/services/projectAccessKey.service.d.ts.map +1 -0
  392. package/dist/types/services/sessionAuth.service.d.ts +148 -0
  393. package/dist/types/services/sessionAuth.service.d.ts.map +1 -0
  394. package/dist/types/services/user.service.d.ts +89 -0
  395. package/dist/types/services/user.service.d.ts.map +1 -0
  396. package/dist/types/types/Routes.d.ts +7 -0
  397. package/dist/types/types/Routes.d.ts.map +1 -0
  398. package/dist/types/types/dictionary.types.d.ts +35 -0
  399. package/dist/types/types/dictionary.types.d.ts.map +1 -0
  400. package/dist/types/types/organization.types.d.ts +21 -0
  401. package/dist/types/types/organization.types.d.ts.map +1 -0
  402. package/dist/types/types/project.types.d.ts +40 -0
  403. package/dist/types/types/project.types.d.ts.map +1 -0
  404. package/dist/types/types/session.types.d.ts +22 -0
  405. package/dist/types/types/session.types.d.ts.map +1 -0
  406. package/dist/types/types/user.types.d.ts +28 -0
  407. package/dist/types/types/user.types.d.ts.map +1 -0
  408. package/dist/types/utils/CSRF.d.ts +3 -0
  409. package/dist/types/utils/CSRF.d.ts.map +1 -0
  410. package/dist/types/utils/accessControl.d.ts +58 -0
  411. package/dist/types/utils/accessControl.d.ts.map +1 -0
  412. package/dist/types/utils/cookies.d.ts +12 -0
  413. package/dist/types/utils/cookies.d.ts.map +1 -0
  414. package/dist/types/utils/errors/ErrorHandler.d.ts +32 -0
  415. package/dist/types/utils/errors/ErrorHandler.d.ts.map +1 -0
  416. package/dist/types/utils/errors/ErrorsClass.d.ts +26 -0
  417. package/dist/types/utils/errors/ErrorsClass.d.ts.map +1 -0
  418. package/dist/types/utils/errors/errorCodes.d.ts +811 -0
  419. package/dist/types/utils/errors/errorCodes.d.ts.map +1 -0
  420. package/dist/types/utils/errors/index.d.ts +4 -0
  421. package/dist/types/utils/errors/index.d.ts.map +1 -0
  422. package/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts +23 -0
  423. package/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts.map +1 -0
  424. package/dist/types/utils/filtersAndPagination/getFiltersAndPaginationFromBody.d.ts +22 -0
  425. package/dist/types/utils/filtersAndPagination/getFiltersAndPaginationFromBody.d.ts.map +1 -0
  426. package/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts +31 -0
  427. package/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts.map +1 -0
  428. package/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts +24 -0
  429. package/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts.map +1 -0
  430. package/dist/types/utils/filtersAndPagination/getUserFiltersAndPagination.d.ts +22 -0
  431. package/dist/types/utils/filtersAndPagination/getUserFiltersAndPagination.d.ts.map +1 -0
  432. package/dist/types/utils/httpStatusCodes.d.ts +395 -0
  433. package/dist/types/utils/httpStatusCodes.d.ts.map +1 -0
  434. package/dist/types/utils/mapper/dictionary.d.ts +12 -0
  435. package/dist/types/utils/mapper/dictionary.d.ts.map +1 -0
  436. package/dist/types/utils/mapper/organization.d.ts +9 -0
  437. package/dist/types/utils/mapper/organization.d.ts.map +1 -0
  438. package/dist/types/utils/mapper/project.d.ts +9 -0
  439. package/dist/types/utils/mapper/project.d.ts.map +1 -0
  440. package/dist/types/utils/mapper/user.d.ts +14 -0
  441. package/dist/types/utils/mapper/user.d.ts.map +1 -0
  442. package/dist/types/utils/mongoDB/connectDB.d.ts +3 -0
  443. package/dist/types/utils/mongoDB/connectDB.d.ts.map +1 -0
  444. package/dist/types/utils/oAuth2.d.ts +6 -0
  445. package/dist/types/utils/oAuth2.d.ts.map +1 -0
  446. package/dist/types/utils/responseData.d.ts +53 -0
  447. package/dist/types/utils/responseData.d.ts.map +1 -0
  448. package/dist/types/utils/validation/validateArray.d.ts +13 -0
  449. package/dist/types/utils/validation/validateArray.d.ts.map +1 -0
  450. package/dist/types/utils/validation/validateDictionary.d.ts +12 -0
  451. package/dist/types/utils/validation/validateDictionary.d.ts.map +1 -0
  452. package/dist/types/utils/validation/validateEmail.d.ts +10 -0
  453. package/dist/types/utils/validation/validateEmail.d.ts.map +1 -0
  454. package/dist/types/utils/validation/validateOrganization.d.ts +15 -0
  455. package/dist/types/utils/validation/validateOrganization.d.ts.map +1 -0
  456. package/dist/types/utils/validation/validatePhone.d.ts +10 -0
  457. package/dist/types/utils/validation/validatePhone.d.ts.map +1 -0
  458. package/dist/types/utils/validation/validateProject.d.ts +15 -0
  459. package/dist/types/utils/validation/validateProject.d.ts.map +1 -0
  460. package/dist/types/utils/validation/validateString.d.ts +10 -0
  461. package/dist/types/utils/validation/validateString.d.ts.map +1 -0
  462. package/dist/types/utils/validation/validateUser.d.ts +15 -0
  463. package/dist/types/utils/validation/validateUser.d.ts.map +1 -0
  464. package/package.json +115 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and improving
59
+ the Work, but excluding communication that is conspicuously marked or
60
+ otherwise designated in writing by the copyright owner as "Not a
61
+ Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Aymeric PINEAU
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,356 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var dictionary_controller_exports = {};
30
+ __export(dictionary_controller_exports, {
31
+ addDictionary: () => addDictionary,
32
+ deleteDictionary: () => deleteDictionary,
33
+ getDictionaries: () => getDictionaries,
34
+ getDictionariesKeys: () => getDictionariesKeys,
35
+ getDictionaryByKey: () => getDictionaryByKey,
36
+ pushDictionaries: () => pushDictionaries,
37
+ updateDictionary: () => updateDictionary
38
+ });
39
+ module.exports = __toCommonJS(dictionary_controller_exports);
40
+ var import_logger = require('./../logger/index.cjs');
41
+ var dictionaryService = __toESM(require('./../services/dictionary.service.cjs'), 1);
42
+ var import_errors = require('./../utils/errors/index.cjs');
43
+ var import_getDictionaryFiltersAndPagination = require('./../utils/filtersAndPagination/getDictionaryFiltersAndPagination.cjs');
44
+ var import_dictionary = require('./../utils/mapper/dictionary.cjs');
45
+ var import_responseData = require('./../utils/responseData.cjs');
46
+ const getDictionaries = async (req, res, _next) => {
47
+ const { user, project } = res.locals;
48
+ const { filters, pageSize, skip, page, getNumberOfPages } = (0, import_getDictionaryFiltersAndPagination.getDictionaryFiltersAndPagination)(req);
49
+ if (!project) {
50
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
51
+ return;
52
+ }
53
+ if (!user) {
54
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_FOUND");
55
+ return;
56
+ }
57
+ try {
58
+ const dictionaries = await dictionaryService.findDictionaries(
59
+ filters,
60
+ skip,
61
+ pageSize
62
+ );
63
+ const totalItems = await dictionaryService.countDictionaries(filters);
64
+ const dictionariesAPI = dictionaries.map(
65
+ (el) => (0, import_dictionary.mapDictionaryToAPI)(el, project._id)
66
+ );
67
+ const responseData = (0, import_responseData.formatPaginatedResponse)({
68
+ data: dictionariesAPI,
69
+ page,
70
+ pageSize,
71
+ totalPages: getNumberOfPages(totalItems),
72
+ totalItems
73
+ });
74
+ res.json(responseData);
75
+ return;
76
+ } catch (error) {
77
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
78
+ return;
79
+ }
80
+ };
81
+ const getDictionariesKeys = async (_req, res, _next) => {
82
+ const { project } = res.locals;
83
+ if (!project) {
84
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
85
+ return;
86
+ }
87
+ try {
88
+ const dictionariesKeys = await dictionaryService.getDictionariesKeys(
89
+ project._id
90
+ );
91
+ const responseData = (0, import_responseData.formatResponse)({
92
+ data: dictionariesKeys
93
+ });
94
+ res.json(responseData);
95
+ return;
96
+ } catch (error) {
97
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
98
+ return;
99
+ }
100
+ };
101
+ const getDictionaryByKey = async (req, res, _next) => {
102
+ const { project, user } = res.locals;
103
+ const { dictionaryKey } = req.params;
104
+ const { version } = req.query;
105
+ if (!project) {
106
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
107
+ return;
108
+ }
109
+ if (!user) {
110
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_FOUND");
111
+ return;
112
+ }
113
+ try {
114
+ const dictionaries = await dictionaryService.getDictionaryByKey(
115
+ dictionaryKey,
116
+ project._id
117
+ );
118
+ if (!dictionaries.projectIds.includes(String(project._id))) {
119
+ import_errors.ErrorHandler.handleGenericErrorResponse(
120
+ res,
121
+ "DICTIONARY_PROJECT_MISMATCH"
122
+ );
123
+ return;
124
+ }
125
+ const apiResult = (0, import_dictionary.mapDictionaryToAPI)(dictionaries, project._id, version);
126
+ const responseData = (0, import_responseData.formatResponse)({
127
+ data: apiResult
128
+ });
129
+ res.json(responseData);
130
+ return;
131
+ } catch (error) {
132
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
133
+ return;
134
+ }
135
+ };
136
+ const addDictionary = async (req, res, _next) => {
137
+ const { project, user } = res.locals;
138
+ const dictionaryData = req.body;
139
+ if (!dictionaryData) {
140
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_DATA_NOT_FOUND");
141
+ return;
142
+ }
143
+ if (!project) {
144
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
145
+ return;
146
+ }
147
+ if (!user) {
148
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_FOUND");
149
+ return;
150
+ }
151
+ if (!dictionaryData.projectIds.includes(String(project._id))) {
152
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_PROJECT_MISMATCH");
153
+ return;
154
+ }
155
+ const dictionary = {
156
+ key: dictionaryData.key,
157
+ title: dictionaryData.title,
158
+ description: dictionaryData.description,
159
+ content: [dictionaryData.content],
160
+ creatorId: user._id,
161
+ filePath: { [String(project._id)]: dictionaryData.filePath ?? "" },
162
+ projectIds: dictionaryData.projectIds ?? [String(project._id)]
163
+ };
164
+ try {
165
+ const newDictionary = await dictionaryService.createDictionary(dictionary);
166
+ const apiResult = (0, import_dictionary.mapDictionaryToAPI)(newDictionary, project._id);
167
+ const responseData = (0, import_responseData.formatResponse)({
168
+ data: apiResult
169
+ });
170
+ res.json(responseData);
171
+ return;
172
+ } catch (error) {
173
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
174
+ return;
175
+ }
176
+ };
177
+ const pushDictionaries = async (req, res, _next) => {
178
+ const { project, user } = res.locals;
179
+ const dictionaryData = req.body.dictionaries;
180
+ const dictionariesKeys = dictionaryData.map((dictionary) => dictionary.key);
181
+ if (typeof dictionaryData === "object" && Array.isArray(dictionaryData) && dictionaryData.length === 0) {
182
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARIES_NOT_PROVIDED");
183
+ return;
184
+ } else if (!dictionaryData) {
185
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_DATA_NOT_FOUND");
186
+ return;
187
+ }
188
+ if (!project) {
189
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
190
+ return;
191
+ }
192
+ if (!user) {
193
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "USER_NOT_FOUND");
194
+ return;
195
+ }
196
+ try {
197
+ const { existingDictionariesKey, newDictionariesKey } = await dictionaryService.getExistingDictionaryKey(
198
+ dictionariesKeys,
199
+ project._id
200
+ );
201
+ const existingDictionaries = dictionaryData.filter(
202
+ (dictionary) => existingDictionariesKey.includes(dictionary.key)
203
+ );
204
+ const newDictionaries = dictionaryData.filter(
205
+ (dictionary) => newDictionariesKey.includes(dictionary.key)
206
+ );
207
+ const result = {
208
+ newDictionaries: [],
209
+ updatedDictionaries: [],
210
+ error: []
211
+ };
212
+ for (const dictionaryDataEl of newDictionaries) {
213
+ const dictionary = {
214
+ title: dictionaryDataEl.title,
215
+ description: dictionaryDataEl.description,
216
+ content: [dictionaryDataEl.content],
217
+ projectIds: [String(project._id)],
218
+ creatorId: user._id,
219
+ filePath: { [String(project._id)]: dictionaryDataEl.filePath ?? "" },
220
+ key: dictionaryDataEl.key
221
+ };
222
+ try {
223
+ const newDictionary = await dictionaryService.createDictionary(dictionary);
224
+ result.newDictionaries.push(newDictionary.key);
225
+ } catch (error) {
226
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
227
+ }
228
+ }
229
+ if (existingDictionariesKey.length >= 0) {
230
+ const existingDictionariesDB = await dictionaryService.getDictionariesByKeys(
231
+ existingDictionariesKey,
232
+ project._id
233
+ );
234
+ for (const dictionaryDataEl of existingDictionaries) {
235
+ const existingDictionaryDB = existingDictionariesDB.find(
236
+ (dictionaryDB) => dictionaryDB.key === dictionaryDataEl.key
237
+ );
238
+ const dictionary = {
239
+ ...existingDictionaryDB,
240
+ ...dictionaryDataEl,
241
+ content: [
242
+ ...existingDictionaryDB.content ?? [],
243
+ dictionaryDataEl.content
244
+ ],
245
+ projectIds: [String(project._id)],
246
+ creatorId: user._id,
247
+ filePath: { [String(project._id)]: dictionaryDataEl.filePath ?? "" },
248
+ key: dictionaryDataEl.key
249
+ };
250
+ try {
251
+ const newDictionary = await dictionaryService.updateDictionaryByKey(
252
+ dictionaryDataEl.key,
253
+ dictionary,
254
+ project._id
255
+ );
256
+ result.updatedDictionaries.push(newDictionary.key);
257
+ } catch (error) {
258
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
259
+ }
260
+ }
261
+ }
262
+ const responseData = (0, import_responseData.formatResponse)({
263
+ data: result
264
+ });
265
+ res.json(responseData);
266
+ return;
267
+ } catch (error) {
268
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
269
+ return;
270
+ }
271
+ };
272
+ const updateDictionary = async (req, res, _next) => {
273
+ const { project } = res.locals;
274
+ const dictionaryData = req.body;
275
+ if (!dictionaryData) {
276
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_DATA_NOT_FOUND");
277
+ return;
278
+ }
279
+ if (!project) {
280
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
281
+ return;
282
+ }
283
+ if (!dictionaryData.projectIds?.includes(String(project._id))) {
284
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_PROJECT_MISMATCH");
285
+ return;
286
+ }
287
+ if (typeof dictionaryData._id === "undefined") {
288
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_ID_NOT_FOUND");
289
+ return;
290
+ }
291
+ try {
292
+ const updatedDictionary = await dictionaryService.updateDictionaryById(
293
+ dictionaryData._id,
294
+ dictionaryData
295
+ );
296
+ const apiResult = (0, import_dictionary.mapDictionaryToAPI)(updatedDictionary, project._id);
297
+ const responseData = (0, import_responseData.formatResponse)({
298
+ data: apiResult
299
+ });
300
+ res.json(responseData);
301
+ return;
302
+ } catch (error) {
303
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
304
+ return;
305
+ }
306
+ };
307
+ const deleteDictionary = async (req, res, _next) => {
308
+ const { project } = res.locals;
309
+ const { dictionaryId } = req.params;
310
+ if (!dictionaryId) {
311
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_ID_NOT_FOUND");
312
+ return;
313
+ }
314
+ if (!project) {
315
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "PROJECT_NOT_FOUND");
316
+ return;
317
+ }
318
+ try {
319
+ const dictionaryToDelete = await dictionaryService.getDictionaryById(dictionaryId);
320
+ if (!dictionaryToDelete.projectIds.includes(project._id)) {
321
+ import_errors.ErrorHandler.handleGenericErrorResponse(
322
+ res,
323
+ "DICTIONARY_PROJECT_MISMATCH"
324
+ );
325
+ return;
326
+ }
327
+ const deletedDictionary = await dictionaryService.deleteDictionaryById(dictionaryId);
328
+ if (!deletedDictionary) {
329
+ import_errors.ErrorHandler.handleGenericErrorResponse(res, "DICTIONARY_NOT_FOUND", {
330
+ dictionaryId
331
+ });
332
+ return;
333
+ }
334
+ import_logger.logger.info(`Dictionary deleted: ${String(deletedDictionary._id)}`);
335
+ const apiResult = (0, import_dictionary.mapDictionaryToAPI)(deletedDictionary, project._id);
336
+ const responseData = (0, import_responseData.formatResponse)({
337
+ data: apiResult
338
+ });
339
+ res.json(responseData);
340
+ return;
341
+ } catch (error) {
342
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
343
+ return;
344
+ }
345
+ };
346
+ // Annotate the CommonJS export names for ESM import in node:
347
+ 0 && (module.exports = {
348
+ addDictionary,
349
+ deleteDictionary,
350
+ getDictionaries,
351
+ getDictionariesKeys,
352
+ getDictionaryByKey,
353
+ pushDictionaries,
354
+ updateDictionary
355
+ });
356
+ //# sourceMappingURL=dictionary.controller.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/controllers/dictionary.controller.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Dictionary as LocalDictionary } from '@intlayer/core';\nimport { logger } from '@logger';\nimport type { ResponseWithInformation } from '@middlewares/sessionAuth.middleware';\nimport * as dictionaryService from '@services/dictionary.service';\nimport { AppError, ErrorHandler } from '@utils/errors';\nimport {\n type DictionaryFiltersParams,\n getDictionaryFiltersAndPagination,\n} from '@utils/filtersAndPagination/getDictionaryFiltersAndPagination';\nimport type { FiltersAndPagination } from '@utils/filtersAndPagination/getFiltersAndPaginationFromBody';\nimport { mapDictionaryToAPI } from '@utils/mapper/dictionary';\nimport {\n formatPaginatedResponse,\n type ResponseData,\n type PaginatedResponse,\n formatResponse,\n} from '@utils/responseData';\nimport type { NextFunction, Request } from 'express';\nimport type {\n Dictionary,\n DictionaryAPI,\n DictionaryCreationData,\n DictionaryData,\n} from '@/types/dictionary.types';\n\nexport type GetDictionariesParams =\n FiltersAndPagination<DictionaryFiltersParams>;\nexport type GetDictionariesResult = PaginatedResponse<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaries = async (\n req: Request<GetDictionariesParams>,\n res: ResponseWithInformation<GetDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { user, project } = res.locals;\n const { filters, pageSize, skip, page, getNumberOfPages } =\n getDictionaryFiltersAndPagination(req);\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_FOUND');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.findDictionaries(\n filters,\n skip,\n pageSize\n );\n const totalItems = await dictionaryService.countDictionaries(filters);\n\n const dictionariesAPI = dictionaries.map((el) =>\n mapDictionaryToAPI(el, project._id)\n );\n\n const responseData = formatPaginatedResponse<DictionaryAPI>({\n data: dictionariesAPI,\n page,\n pageSize,\n totalPages: getNumberOfPages(totalItems),\n totalItems,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionariesKeysResult = ResponseData<string[]>;\n\n/**\n * Retrieves a list of dictionaries keys based on filters and pagination.\n */\nexport const getDictionariesKeys = async (\n _req: Request,\n res: ResponseWithInformation<GetDictionariesKeysResult>,\n _next: NextFunction\n) => {\n const { project } = res.locals;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n\n try {\n const dictionariesKeys = await dictionaryService.getDictionariesKeys(\n project._id\n );\n\n const responseData = formatResponse<string[]>({\n data: dictionariesKeys,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type GetDictionaryParams = { dictionaryKey: string };\nexport type GetDictionaryQuery = { version?: number };\nexport type GetDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Retrieves a list of dictionaries based on filters and pagination.\n */\nexport const getDictionaryByKey = async (\n req: Request<GetDictionaryParams>,\n res: ResponseWithInformation<GetDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user } = res.locals;\n const { dictionaryKey } = req.params;\n const { version } = req.query as GetDictionaryQuery;\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_FOUND');\n return;\n }\n\n try {\n const dictionaries = await dictionaryService.getDictionaryByKey(\n dictionaryKey,\n project._id\n );\n\n if (!dictionaries.projectIds.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const apiResult = mapDictionaryToAPI(dictionaries, project._id, version);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type AddDictionaryBody = DictionaryCreationData;\nexport type AddDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const addDictionary = async (\n req: Request<any, any, AddDictionaryBody>,\n res: ResponseWithInformation<AddDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_FOUND');\n return;\n }\n\n if (!dictionaryData.projectIds.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n const dictionary: DictionaryData = {\n key: dictionaryData.key,\n title: dictionaryData.title,\n description: dictionaryData.description,\n content: [dictionaryData.content],\n creatorId: user._id,\n filePath: { [String(project._id)]: dictionaryData.filePath ?? '' },\n projectIds: dictionaryData.projectIds ?? [String(project._id)],\n };\n\n try {\n const newDictionary = await dictionaryService.createDictionary(dictionary);\n\n const apiResult = mapDictionaryToAPI(newDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type PushDictionariesBody = { dictionaries: LocalDictionary[] };\ntype PushDictionariesResultData = {\n newDictionaries: string[];\n updatedDictionaries: string[];\n error: { dictionaryId: string; message: string }[];\n};\nexport type PushDictionariesResult = ResponseData<PushDictionariesResultData>;\n\n/**\n * Check each dictionaries, add the new ones and update the existing ones.\n * @param req - Express request object.\n * @param res - Express response object.\n * @returns Response containing the created dictionary.\n */\nexport const pushDictionaries = async (\n req: Request<any, any, PushDictionariesBody>,\n res: ResponseWithInformation<PushDictionariesResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project, user } = res.locals;\n const dictionaryData = req.body.dictionaries;\n const dictionariesKeys = dictionaryData.map((dictionary) => dictionary.key);\n\n if (\n typeof dictionaryData === 'object' &&\n Array.isArray(dictionaryData) &&\n dictionaryData.length === 0\n ) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARIES_NOT_PROVIDED');\n return;\n } else if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n\n if (!user) {\n ErrorHandler.handleGenericErrorResponse(res, 'USER_NOT_FOUND');\n return;\n }\n\n try {\n const { existingDictionariesKey, newDictionariesKey } =\n await dictionaryService.getExistingDictionaryKey(\n dictionariesKeys,\n project._id\n );\n\n const existingDictionaries = dictionaryData.filter((dictionary) =>\n existingDictionariesKey.includes(dictionary.key)\n );\n const newDictionaries = dictionaryData.filter((dictionary) =>\n newDictionariesKey.includes(dictionary.key)\n );\n\n const result: PushDictionariesResultData = {\n newDictionaries: [],\n updatedDictionaries: [],\n error: [],\n };\n\n for (const dictionaryDataEl of newDictionaries) {\n const dictionary: DictionaryData = {\n title: dictionaryDataEl.title,\n description: dictionaryDataEl.description,\n content: [dictionaryDataEl.content],\n projectIds: [String(project._id)],\n creatorId: user._id,\n filePath: { [String(project._id)]: dictionaryDataEl.filePath ?? '' },\n key: dictionaryDataEl.key,\n };\n\n try {\n const newDictionary =\n await dictionaryService.createDictionary(dictionary);\n result.newDictionaries.push(newDictionary.key);\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n }\n }\n\n if (existingDictionariesKey.length >= 0) {\n const existingDictionariesDB =\n await dictionaryService.getDictionariesByKeys(\n existingDictionariesKey,\n project._id\n );\n\n for (const dictionaryDataEl of existingDictionaries) {\n const existingDictionaryDB = existingDictionariesDB.find(\n (dictionaryDB) => dictionaryDB.key === dictionaryDataEl.key\n )!;\n\n const dictionary: DictionaryData = {\n ...existingDictionaryDB,\n ...dictionaryDataEl,\n content: [\n ...(existingDictionaryDB.content ?? []),\n dictionaryDataEl.content,\n ],\n projectIds: [String(project._id)],\n creatorId: user._id,\n filePath: { [String(project._id)]: dictionaryDataEl.filePath ?? '' },\n key: dictionaryDataEl.key,\n };\n\n try {\n const newDictionary = await dictionaryService.updateDictionaryByKey(\n dictionaryDataEl.key,\n dictionary,\n project._id\n );\n result.updatedDictionaries.push(newDictionary.key);\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n }\n }\n }\n\n const responseData = formatResponse<PushDictionariesResultData>({\n data: result,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type UpdateDictionaryBody = Partial<Dictionary>;\nexport type UpdateDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Updates an existing dictionary in the database.\n */\nexport const updateDictionary = async (\n req: Request<any, any, UpdateDictionaryBody>,\n res: ResponseWithInformation<UpdateDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project } = res.locals;\n const dictionaryData = req.body;\n\n if (!dictionaryData) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_DATA_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n\n if (!dictionaryData.projectIds?.includes(String(project._id))) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_PROJECT_MISMATCH');\n return;\n }\n\n if (typeof dictionaryData._id === 'undefined') {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n try {\n const updatedDictionary = await dictionaryService.updateDictionaryById(\n dictionaryData._id,\n dictionaryData\n );\n\n const apiResult = mapDictionaryToAPI(updatedDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n\nexport type DeleteDictionaryParam = { dictionaryId: string };\nexport type DeleteDictionaryResult = ResponseData<DictionaryAPI>;\n\n/**\n * Deletes a dictionary from the database by its ID.\n */\nexport const deleteDictionary = async (\n req: Request<DeleteDictionaryParam>,\n res: ResponseWithInformation<DeleteDictionaryResult>,\n _next: NextFunction\n): Promise<void> => {\n const { project } = res.locals;\n const { dictionaryId } = req.params as Partial<DeleteDictionaryParam>;\n\n if (!dictionaryId) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_ID_NOT_FOUND');\n return;\n }\n\n if (!project) {\n ErrorHandler.handleGenericErrorResponse(res, 'PROJECT_NOT_FOUND');\n return;\n }\n\n try {\n const dictionaryToDelete =\n await dictionaryService.getDictionaryById(dictionaryId);\n\n if (!dictionaryToDelete.projectIds.includes(project._id)) {\n ErrorHandler.handleGenericErrorResponse(\n res,\n 'DICTIONARY_PROJECT_MISMATCH'\n );\n return;\n }\n\n const deletedDictionary =\n await dictionaryService.deleteDictionaryById(dictionaryId);\n\n if (!deletedDictionary) {\n ErrorHandler.handleGenericErrorResponse(res, 'DICTIONARY_NOT_FOUND', {\n dictionaryId,\n });\n return;\n }\n\n logger.info(`Dictionary deleted: ${String(deletedDictionary._id)}`);\n\n const apiResult = mapDictionaryToAPI(deletedDictionary, project._id);\n\n const responseData = formatResponse<DictionaryAPI>({\n data: apiResult,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuB;AAEvB,wBAAmC;AACnC,oBAAuC;AACvC,+CAGO;AAEP,wBAAmC;AACnC,0BAKO;AAgBA,MAAM,kBAAkB,OAC7B,KACA,KACA,UACkB;AAClB,QAAM,EAAE,MAAM,QAAQ,IAAI,IAAI;AAC9B,QAAM,EAAE,SAAS,UAAU,MAAM,MAAM,iBAAiB,QACtD,4EAAkC,GAAG;AAEvC,MAAI,CAAC,SAAS;AACZ,+BAAa,2BAA2B,KAAK,mBAAmB;AAChE;AAAA,EACF;AACA,MAAI,CAAC,MAAM;AACT,+BAAa,2BAA2B,KAAK,gBAAgB;AAC7D;AAAA,EACF;AAEA,MAAI;AACF,UAAM,eAAe,MAAM,kBAAkB;AAAA,MAC3C;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,UAAM,aAAa,MAAM,kBAAkB,kBAAkB,OAAO;AAEpE,UAAM,kBAAkB,aAAa;AAAA,MAAI,CAAC,WACxC,sCAAmB,IAAI,QAAQ,GAAG;AAAA,IACpC;AAEA,UAAM,mBAAe,6CAAuC;AAAA,MAC1D,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,YAAY,iBAAiB,UAAU;AAAA,MACvC;AAAA,IACF,CAAC;AAED,QAAI,KAAK,YAAY;AACrB;AAAA,EACF,SAAS,OAAO;AACd,+BAAa,uBAAuB,KAAK,KAAiB;AAC1D;AAAA,EACF;AACF;AAOO,MAAM,sBAAsB,OACjC,MACA,KACA,UACG;AACH,QAAM,EAAE,QAAQ,IAAI,IAAI;AAExB,MAAI,CAAC,SAAS;AACZ,+BAAa,2BAA2B,KAAK,mBAAmB;AA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;AACF;","names":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var oAuth2_controller_exports = {};
20
+ __export(oAuth2_controller_exports, {
21
+ getOAuth2Token: () => getOAuth2Token
22
+ });
23
+ module.exports = __toCommonJS(oAuth2_controller_exports);
24
+ var import_errors = require('./../utils/errors/index.cjs');
25
+ var import_responseData = require('./../utils/responseData.cjs');
26
+ var import_oauth2_server = require("oauth2-server");
27
+ const getOAuth2Token = async (req, res, _next) => {
28
+ const oauthRequest = new import_oauth2_server.Request(req);
29
+ const oauthResponse = new import_oauth2_server.Response(res);
30
+ try {
31
+ const token = await req.oauth.token(oauthRequest, oauthResponse);
32
+ const responseData = (0, import_responseData.formatResponse)({
33
+ data: token
34
+ });
35
+ res.json(responseData);
36
+ return;
37
+ } catch (error) {
38
+ import_errors.ErrorHandler.handleAppErrorResponse(res, error);
39
+ return;
40
+ }
41
+ };
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ getOAuth2Token
45
+ });
46
+ //# sourceMappingURL=oAuth2.controller.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/controllers/oAuth2.controller.ts"],"sourcesContent":["import { RequestWithOAuth2Information } from '@middlewares/oAuth2.middleware';\nimport { AppError, ErrorHandler } from '@utils/errors';\nimport { formatResponse, ResponseData } from '@utils/responseData';\nimport { Response, Request, NextFunction } from 'express';\nimport {\n type Token as OAuth2ServerToken,\n Request as OAuthRequest,\n Response as OAuthResponse,\n} from 'oauth2-server';\n\nexport type GetOAuth2TokenBody = {\n grant_type: 'client_credentials';\n client_id: string;\n client_secret: string;\n};\nexport type OAuth2Token = {\n [K in keyof OAuth2ServerToken]: OAuth2ServerToken[K];\n};\nexport type GetOAuth2TokenResult = ResponseData<OAuth2Token>;\n\n// Method to get the token\nexport const getOAuth2Token = async (\n req: Request,\n res: Response,\n _next: NextFunction\n): Promise<void> => {\n const oauthRequest = new OAuthRequest(req);\n const oauthResponse = new OAuthResponse(res);\n\n try {\n const token: OAuth2Token = await (\n req as unknown as RequestWithOAuth2Information<\n undefined,\n undefined,\n GetOAuth2TokenBody\n >\n ).oauth.token(oauthRequest, oauthResponse);\n\n const responseData = formatResponse<OAuth2Token>({\n data: token,\n });\n\n res.json(responseData);\n return;\n } catch (error) {\n ErrorHandler.handleAppErrorResponse(res, error as AppError);\n return;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuC;AACvC,0BAA6C;AAE7C,2BAIO;AAaA,MAAM,iBAAiB,OAC5B,KACA,KACA,UACkB;AAClB,QAAM,eAAe,IAAI,qBAAAA,QAAa,GAAG;AACzC,QAAM,gBAAgB,IAAI,qBAAAC,SAAc,GAAG;AAE3C,MAAI;AACF,UAAM,QAAqB,MACzB,IAKA,MAAM,MAAM,cAAc,aAAa;AAEzC,UAAM,mBAAe,oCAA4B;AAAA,MAC/C,MAAM;AAAA,IACR,CAAC;AAED,QAAI,KAAK,YAAY;AACrB;AAAA,EACF,SAAS,OAAO;AACd,+BAAa,uBAAuB,KAAK,KAAiB;AAC1D;AAAA,EACF;AACF;","names":["OAuthRequest","OAuthResponse"]}