@fdm-monster/server 1.5.4 → 1.6.0-rc2

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 (288) hide show
  1. package/.env.template +7 -0
  2. package/.gitattributes +2 -0
  3. package/.yarn/install-state.gz +0 -0
  4. package/.yarn/releases/yarn-4.1.0.cjs +893 -0
  5. package/.yarnrc.yml +4 -0
  6. package/README.md +3 -2
  7. package/dist/consoles/sqlite-torm.js +31 -0
  8. package/dist/consoles/sqlite-torm.js.map +1 -0
  9. package/dist/consoles/typeorm-generate.js +194 -0
  10. package/dist/consoles/typeorm-generate.js.map +1 -0
  11. package/dist/consoles/typeorm-migrate.js +48 -0
  12. package/dist/consoles/typeorm-migrate.js.map +1 -0
  13. package/dist/consoles/upload-test.js +52 -0
  14. package/dist/consoles/upload-test.js.map +1 -0
  15. package/dist/constants/event.constants.js.map +1 -1
  16. package/dist/constants/service.constants.js +3 -18
  17. package/dist/constants/service.constants.js.map +1 -1
  18. package/dist/container.js +64 -19
  19. package/dist/container.js.map +1 -1
  20. package/dist/container.tokens.js +2 -0
  21. package/dist/container.tokens.js.map +1 -1
  22. package/dist/controllers/batch-call.controller.js +10 -5
  23. package/dist/controllers/batch-call.controller.js.map +1 -1
  24. package/dist/controllers/custom-gcode.controller.js.map +1 -1
  25. package/dist/controllers/dto/update-client-dist.dto.js +38 -0
  26. package/dist/controllers/dto/update-client-dist.dto.js.map +1 -0
  27. package/dist/controllers/printer-files.controller.js +10 -49
  28. package/dist/controllers/printer-files.controller.js.map +1 -1
  29. package/dist/controllers/printer.controller.js +1 -1
  30. package/dist/controllers/printer.controller.js.map +1 -1
  31. package/dist/controllers/server-private.controller.js +25 -6
  32. package/dist/controllers/server-private.controller.js.map +1 -1
  33. package/dist/controllers/validation/batch-controller.validation.js +9 -0
  34. package/dist/controllers/validation/batch-controller.validation.js.map +1 -1
  35. package/dist/data-source.js +66 -0
  36. package/dist/data-source.js.map +1 -0
  37. package/dist/entities/base.entity.js +29 -0
  38. package/dist/entities/base.entity.js.map +1 -0
  39. package/dist/entities/camera-stream.entity.js +94 -0
  40. package/dist/entities/camera-stream.entity.js.map +1 -0
  41. package/dist/entities/custom-gcode.entity.js +50 -0
  42. package/dist/entities/custom-gcode.entity.js.map +1 -0
  43. package/dist/entities/floor-position.entity.js +78 -0
  44. package/dist/entities/floor-position.entity.js.map +1 -0
  45. package/dist/entities/floor.entity.js +53 -0
  46. package/dist/entities/floor.entity.js.map +1 -0
  47. package/dist/entities/index.js +58 -0
  48. package/dist/entities/index.js.map +1 -0
  49. package/dist/entities/permission.entity.js +38 -0
  50. package/dist/entities/permission.entity.js.map +1 -0
  51. package/dist/entities/print-completion.entity.js +91 -0
  52. package/dist/entities/print-completion.entity.js.map +1 -0
  53. package/dist/entities/printer-file.entity.js +140 -0
  54. package/dist/entities/printer-file.entity.js.map +1 -0
  55. package/dist/entities/printer.entity.js +105 -0
  56. package/dist/entities/printer.entity.js.map +1 -0
  57. package/dist/entities/refresh-token.entity.js +70 -0
  58. package/dist/entities/refresh-token.entity.js.map +1 -0
  59. package/dist/entities/role.entity.js +46 -0
  60. package/dist/entities/role.entity.js.map +1 -0
  61. package/dist/entities/settings.entity.js +89 -0
  62. package/dist/entities/settings.entity.js.map +1 -0
  63. package/dist/entities/user-role.entity.js +70 -0
  64. package/dist/entities/user-role.entity.js.map +1 -0
  65. package/dist/entities/user.entity.js +90 -0
  66. package/dist/entities/user.entity.js.map +1 -0
  67. package/dist/middleware/exception.filter.js +2 -1
  68. package/dist/middleware/exception.filter.js.map +1 -1
  69. package/dist/middleware/passport.js.map +1 -1
  70. package/dist/migrations/1706829146617-InitSqlite.js +670 -0
  71. package/dist/migrations/1706829146617-InitSqlite.js.map +1 -0
  72. package/dist/models/Floor.js.map +1 -1
  73. package/dist/models/Printer.js +4 -43
  74. package/dist/models/Printer.js.map +1 -1
  75. package/dist/models/PrinterFile.js +85 -0
  76. package/dist/models/PrinterFile.js.map +1 -0
  77. package/dist/models/index.js +4 -0
  78. package/dist/models/index.js.map +1 -1
  79. package/dist/mongo-migrations/20231202183902-printer-files-simpler.js +41 -0
  80. package/dist/mongo-migrations/20231202183902-printer-files-simpler.js.map +1 -0
  81. package/dist/server.constants.js +4 -2
  82. package/dist/server.constants.js.map +1 -1
  83. package/dist/server.core.js +10 -1
  84. package/dist/server.core.js.map +1 -1
  85. package/dist/server.host.js +11 -3
  86. package/dist/server.host.js.map +1 -1
  87. package/dist/services/batch-call.service.js +43 -20
  88. package/dist/services/batch-call.service.js.map +1 -1
  89. package/dist/services/core/client-bundle.service.js +92 -25
  90. package/dist/services/core/client-bundle.service.js.map +1 -1
  91. package/dist/services/core/github.service.js +18 -14
  92. package/dist/services/core/github.service.js.map +1 -1
  93. package/dist/services/core/multer.service.js +3 -3
  94. package/dist/services/core/multer.service.js.map +1 -1
  95. package/dist/services/core/task-manager.service.js +1 -1
  96. package/dist/services/core/task-manager.service.js.map +1 -1
  97. package/dist/services/core/yaml.service.js.map +1 -1
  98. package/dist/services/floor.service.js +1 -1
  99. package/dist/services/floor.service.js.map +1 -1
  100. package/dist/services/interfaces/print-completion.dto.js +0 -2
  101. package/dist/services/interfaces/print-completion.dto.js.map +1 -1
  102. package/dist/services/interfaces/print-completion.interface.js +6 -0
  103. package/dist/services/interfaces/{print-completion.service.js.map → print-completion.interface.js.map} +1 -1
  104. package/dist/services/interfaces/printer-file.dto.js +32 -4
  105. package/dist/services/interfaces/printer-file.dto.js.map +1 -1
  106. package/dist/services/octoprint/dto/connection-state.dto.js +21 -0
  107. package/dist/services/octoprint/dto/connection-state.dto.js.map +1 -0
  108. package/dist/services/{interfaces/print-completion.service.js → octoprint/dto/connection.dto.js} +1 -1
  109. package/dist/services/octoprint/dto/connection.dto.js.map +1 -0
  110. package/dist/services/octoprint/dto/octoprint-currentuser.dto.js +6 -0
  111. package/dist/services/octoprint/dto/octoprint-currentuser.dto.js.map +1 -0
  112. package/dist/services/octoprint/dto/octoprint-event.dto.js +41 -0
  113. package/dist/services/octoprint/dto/octoprint-event.dto.js.map +1 -0
  114. package/dist/services/octoprint/dto/octoprint-file.dto.js +84 -0
  115. package/dist/services/octoprint/dto/octoprint-file.dto.js.map +1 -0
  116. package/dist/services/octoprint/dto/octoprint-files.dto.js +17 -0
  117. package/dist/services/octoprint/dto/octoprint-files.dto.js.map +1 -0
  118. package/dist/services/octoprint/dto/octoprint-session.dto.js +6 -0
  119. package/dist/services/octoprint/dto/octoprint-session.dto.js.map +1 -0
  120. package/dist/services/octoprint/dto/octoprint-settings.dto.js +29 -0
  121. package/dist/services/octoprint/dto/octoprint-settings.dto.js.map +1 -0
  122. package/dist/services/octoprint/dto/octoprint-system-info.dto.js +41 -0
  123. package/dist/services/octoprint/dto/octoprint-system-info.dto.js.map +1 -0
  124. package/dist/services/octoprint/dto/state.dto.js +38 -0
  125. package/dist/services/octoprint/dto/state.dto.js.map +1 -0
  126. package/dist/services/octoprint/dto/websocket-output/connection-message.dto.js +6 -0
  127. package/dist/services/octoprint/dto/websocket-output/connection-message.dto.js.map +1 -0
  128. package/dist/services/octoprint/dto/websocket-output/current-message.dto.js +6 -0
  129. package/dist/services/octoprint/dto/websocket-output/current-message.dto.js.map +1 -0
  130. package/dist/services/octoprint/dto/websocket-output/event-message.dto.js +6 -0
  131. package/dist/services/octoprint/dto/websocket-output/event-message.dto.js.map +1 -0
  132. package/dist/services/octoprint/dto/websocket-output/event.type.js +54 -0
  133. package/dist/services/octoprint/dto/websocket-output/event.type.js.map +1 -0
  134. package/dist/services/octoprint/dto/websocket-output/events/client-authed.dto.js +6 -0
  135. package/dist/services/octoprint/dto/websocket-output/events/client-authed.dto.js.map +1 -0
  136. package/dist/services/octoprint/dto/websocket-output/events/client-closed.dto.js +6 -0
  137. package/dist/services/octoprint/dto/websocket-output/events/client-closed.dto.js.map +1 -0
  138. package/dist/services/octoprint/dto/websocket-output/events/client-opened.dto.js +6 -0
  139. package/dist/services/octoprint/dto/websocket-output/events/client-opened.dto.js.map +1 -0
  140. package/dist/services/octoprint/dto/websocket-output/events/dwelling.dto.js +6 -0
  141. package/dist/services/octoprint/dto/websocket-output/events/dwelling.dto.js.map +1 -0
  142. package/dist/services/octoprint/dto/websocket-output/events/file-added.dto.js +6 -0
  143. package/dist/services/octoprint/dto/websocket-output/events/file-added.dto.js.map +1 -0
  144. package/dist/services/octoprint/dto/websocket-output/events/file-deselected.dto.js +6 -0
  145. package/dist/services/octoprint/dto/websocket-output/events/file-deselected.dto.js.map +1 -0
  146. package/dist/services/octoprint/dto/websocket-output/events/file-removed.dto.js +6 -0
  147. package/dist/services/octoprint/dto/websocket-output/events/file-removed.dto.js.map +1 -0
  148. package/dist/services/octoprint/dto/websocket-output/events/folder-added.dto.js +6 -0
  149. package/dist/services/octoprint/dto/websocket-output/events/folder-added.dto.js.map +1 -0
  150. package/dist/services/octoprint/dto/websocket-output/events/home.dto.js +6 -0
  151. package/dist/services/octoprint/dto/websocket-output/events/home.dto.js.map +1 -0
  152. package/dist/services/octoprint/dto/websocket-output/events/metadata-analysis-finished.dto.js +6 -0
  153. package/dist/services/octoprint/dto/websocket-output/events/metadata-analysis-finished.dto.js.map +1 -0
  154. package/dist/services/octoprint/dto/websocket-output/events/metadata-analysis-started.dto.js +6 -0
  155. package/dist/services/octoprint/dto/websocket-output/events/metadata-analysis-started.dto.js.map +1 -0
  156. package/dist/services/octoprint/dto/websocket-output/events/metadata-statistics-updated.dto.js +6 -0
  157. package/dist/services/octoprint/dto/websocket-output/events/metadata-statistics-updated.dto.js.map +1 -0
  158. package/dist/services/octoprint/dto/websocket-output/events/position-update.dto.js +6 -0
  159. package/dist/services/octoprint/dto/websocket-output/events/position-update.dto.js.map +1 -0
  160. package/dist/services/octoprint/dto/websocket-output/events/print-cancelled.dto.js +6 -0
  161. package/dist/services/octoprint/dto/websocket-output/events/print-cancelled.dto.js.map +1 -0
  162. package/dist/services/octoprint/dto/websocket-output/events/print-cancelling.dto.js +6 -0
  163. package/dist/services/octoprint/dto/websocket-output/events/print-cancelling.dto.js.map +1 -0
  164. package/dist/services/octoprint/dto/websocket-output/events/print-done.dto.js +6 -0
  165. package/dist/services/octoprint/dto/websocket-output/events/print-done.dto.js.map +1 -0
  166. package/dist/services/octoprint/dto/websocket-output/events/print-failed.dto.js +6 -0
  167. package/dist/services/octoprint/dto/websocket-output/events/print-failed.dto.js.map +1 -0
  168. package/dist/services/octoprint/dto/websocket-output/events/print-paused.dto.js +6 -0
  169. package/dist/services/octoprint/dto/websocket-output/events/print-paused.dto.js.map +1 -0
  170. package/dist/services/octoprint/dto/websocket-output/events/print-resumed.dto.js +6 -0
  171. package/dist/services/octoprint/dto/websocket-output/events/print-resumed.dto.js.map +1 -0
  172. package/dist/services/octoprint/dto/websocket-output/events/print-started.dto.js +6 -0
  173. package/dist/services/octoprint/dto/websocket-output/events/print-started.dto.js.map +1 -0
  174. package/dist/services/octoprint/dto/websocket-output/events/printer-state-changed.dto.js +6 -0
  175. package/dist/services/octoprint/dto/websocket-output/events/printer-state-changed.dto.js.map +1 -0
  176. package/dist/services/octoprint/dto/websocket-output/events/transfer-done.dto.js +6 -0
  177. package/dist/services/octoprint/dto/websocket-output/events/transfer-done.dto.js.map +1 -0
  178. package/dist/services/octoprint/dto/websocket-output/events/transfer-started.dto.js +6 -0
  179. package/dist/services/octoprint/dto/websocket-output/events/transfer-started.dto.js.map +1 -0
  180. package/dist/services/octoprint/dto/websocket-output/events/updated-files.dto.js +6 -0
  181. package/dist/services/octoprint/dto/websocket-output/events/updated-files.dto.js.map +1 -0
  182. package/dist/services/octoprint/dto/websocket-output/events/upload.dto.js +6 -0
  183. package/dist/services/octoprint/dto/websocket-output/events/upload.dto.js.map +1 -0
  184. package/dist/services/octoprint/dto/websocket-output/events/user-logged-in.dto.js +6 -0
  185. package/dist/services/octoprint/dto/websocket-output/events/user-logged-in.dto.js.map +1 -0
  186. package/dist/services/octoprint/dto/websocket-output/events/z-change.dto.js +6 -0
  187. package/dist/services/octoprint/dto/websocket-output/events/z-change.dto.js.map +1 -0
  188. package/dist/services/octoprint/dto/websocket-output/history-message.dto.js +6 -0
  189. package/dist/services/octoprint/dto/websocket-output/history-message.dto.js.map +1 -0
  190. package/dist/services/octoprint/dto/websocket-output/plugin-message.dto.js +6 -0
  191. package/dist/services/octoprint/dto/websocket-output/plugin-message.dto.js.map +1 -0
  192. package/dist/services/octoprint/dto/websocket-output/timelapse-message.dto.js +6 -0
  193. package/dist/services/octoprint/dto/websocket-output/timelapse-message.dto.js.map +1 -0
  194. package/dist/services/octoprint/models/octoprint-file.dto.js +6 -0
  195. package/dist/services/octoprint/models/octoprint-file.dto.js.map +1 -0
  196. package/dist/services/octoprint/octoprint-api.routes.js +24 -18
  197. package/dist/services/octoprint/octoprint-api.routes.js.map +1 -1
  198. package/dist/services/octoprint/octoprint-api.service.js +201 -138
  199. package/dist/services/octoprint/octoprint-api.service.js.map +1 -1
  200. package/dist/services/octoprint/octoprint-sockio.adapter.js +72 -66
  201. package/dist/services/octoprint/octoprint-sockio.adapter.js.map +1 -1
  202. package/dist/services/octoprint/utils/api.utils.js +0 -35
  203. package/dist/services/octoprint/utils/api.utils.js.map +1 -1
  204. package/dist/services/octoprint/utils/file.utils.js +44 -0
  205. package/dist/services/octoprint/utils/file.utils.js.map +1 -0
  206. package/dist/services/orm/base.interface.js +6 -0
  207. package/dist/services/orm/base.interface.js.map +1 -0
  208. package/dist/services/orm/base.service.js +72 -0
  209. package/dist/services/orm/base.service.js.map +1 -0
  210. package/dist/services/orm/camera-stream.service.js +25 -0
  211. package/dist/services/orm/camera-stream.service.js.map +1 -0
  212. package/dist/services/orm/custom-gcode.service.js +42 -0
  213. package/dist/services/orm/custom-gcode.service.js.map +1 -0
  214. package/dist/services/orm/floor-position.service.js +55 -0
  215. package/dist/services/orm/floor-position.service.js.map +1 -0
  216. package/dist/services/orm/floor.service.js +122 -0
  217. package/dist/services/orm/floor.service.js.map +1 -0
  218. package/dist/services/orm/permission.service.js +77 -0
  219. package/dist/services/orm/permission.service.js.map +1 -0
  220. package/dist/services/orm/print-completion.service.js +90 -0
  221. package/dist/services/orm/print-completion.service.js.map +1 -0
  222. package/dist/services/orm/printer-files.service.js +123 -0
  223. package/dist/services/orm/printer-files.service.js.map +1 -0
  224. package/dist/services/orm/printer.service.js +145 -0
  225. package/dist/services/orm/printer.service.js.map +1 -0
  226. package/dist/services/orm/refresh-token.service.js +107 -0
  227. package/dist/services/orm/refresh-token.service.js.map +1 -0
  228. package/dist/services/orm/role.service.js +131 -0
  229. package/dist/services/orm/role.service.js.map +1 -0
  230. package/dist/services/orm/settings.service.js +208 -0
  231. package/dist/services/orm/settings.service.js.map +1 -0
  232. package/dist/services/orm/user-role.service.js +55 -0
  233. package/dist/services/orm/user-role.service.js.map +1 -0
  234. package/dist/services/orm/user.service.js +146 -0
  235. package/dist/services/orm/user.service.js.map +1 -0
  236. package/dist/services/orm-migration.service.js +20 -0
  237. package/dist/services/orm-migration.service.js.map +1 -0
  238. package/dist/services/print-completion.service.js +0 -1
  239. package/dist/services/print-completion.service.js.map +1 -1
  240. package/dist/services/printer-files.service.js +73 -49
  241. package/dist/services/printer-files.service.js.map +1 -1
  242. package/dist/services/printer.service.js +0 -2
  243. package/dist/services/printer.service.js.map +1 -1
  244. package/dist/services/typeorm/typeorm.service.js +48 -0
  245. package/dist/services/typeorm/typeorm.service.js.map +1 -0
  246. package/dist/shared/dtos/printer-login.dto.js +58 -0
  247. package/dist/shared/dtos/printer-login.dto.js.map +1 -0
  248. package/dist/{utils → shared}/websocket.adapter.js +3 -3
  249. package/dist/shared/websocket.adapter.js.map +1 -0
  250. package/dist/state/file-upload-tracker.cache.js.map +1 -1
  251. package/dist/state/file.cache.js +12 -35
  252. package/dist/state/file.cache.js.map +1 -1
  253. package/dist/state/printer-connection.cache.js +21 -0
  254. package/dist/state/printer-connection.cache.js.map +1 -0
  255. package/dist/state/printer-events.cache.js +13 -7
  256. package/dist/state/printer-events.cache.js.map +1 -1
  257. package/dist/state/printer-files.store.js +14 -18
  258. package/dist/state/printer-files.store.js.map +1 -1
  259. package/dist/state/printer-socket.store.js +3 -3
  260. package/dist/state/printer-socket.store.js.map +1 -1
  261. package/dist/state/printer.cache.js +3 -0
  262. package/dist/state/printer.cache.js.map +1 -1
  263. package/dist/state/settings.store.js +9 -1
  264. package/dist/state/settings.store.js.map +1 -1
  265. package/dist/state/test-printer-socket.store.js +1 -1
  266. package/dist/task.presets.js.map +1 -1
  267. package/dist/tasks/boot.task.js +30 -18
  268. package/dist/tasks/boot.task.js.map +1 -1
  269. package/dist/tasks/print-completion.socketio.task.js +28 -19
  270. package/dist/tasks/print-completion.socketio.task.js.map +1 -1
  271. package/dist/tasks/printer-file-clean.task.js +14 -0
  272. package/dist/tasks/printer-file-clean.task.js.map +1 -1
  273. package/dist/tasks/printer-state-update-poll.task.js +89 -0
  274. package/dist/tasks/printer-state-update-poll.task.js.map +1 -0
  275. package/dist/tasks/printer-websocket-restore.task.js +4 -3
  276. package/dist/tasks/printer-websocket-restore.task.js.map +1 -1
  277. package/dist/tasks/printer-websocket.task.js +1 -1
  278. package/dist/tasks/printer-websocket.task.js.map +1 -1
  279. package/dist/tasks.js +2 -1
  280. package/dist/tasks.js.map +1 -1
  281. package/dist/utils/env.utils.js +0 -10
  282. package/dist/utils/env.utils.js.map +1 -1
  283. package/dist/utils/semver.utils.js +19 -4
  284. package/dist/utils/semver.utils.js.map +1 -1
  285. package/package.json +58 -47
  286. package/dist/utils/find-predicate.utils.js +0 -18
  287. package/dist/utils/find-predicate.utils.js.map +0 -1
  288. package/dist/utils/websocket.adapter.js.map +0 -1
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RefreshTokenService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RefreshTokenService;
9
+ }
10
+ });
11
+ const _baseservice = require("./base.service");
12
+ const _entities = require("../../entities");
13
+ const _refreshtokendto = require("../interfaces/refresh-token.dto");
14
+ const _runtimeexceptions = require("../../exceptions/runtime.exceptions");
15
+ const _uuid = require("uuid");
16
+ const _serverconstants = require("../../server.constants");
17
+ const _typeorm = require("typeorm");
18
+ const _authorizationconstants = require("../../constants/authorization.constants");
19
+ class RefreshTokenService extends (0, _baseservice.BaseService)(_entities.RefreshToken, _refreshtokendto.RefreshTokenDto) {
20
+ settingsStore;
21
+ logger;
22
+ constructor({ typeormService, settingsStore, loggerFactory }){
23
+ super({
24
+ typeormService
25
+ });
26
+ this.settingsStore = settingsStore;
27
+ this.logger = loggerFactory(RefreshTokenService.name);
28
+ }
29
+ toDto(entity) {
30
+ return {
31
+ id: entity.id,
32
+ userId: entity.userId,
33
+ expiresAt: entity.expiresAt,
34
+ refreshAttemptsUsed: entity.refreshAttemptsUsed
35
+ };
36
+ }
37
+ async getRefreshToken(refreshToken, throwNotFoundError = true) {
38
+ const entity = await this.repository.findOneBy({
39
+ refreshToken
40
+ });
41
+ if (!entity) {
42
+ if (throwNotFoundError) {
43
+ throw new _runtimeexceptions.AuthenticationError(`The entity ${_entities.RefreshToken.name} '${refreshToken}' was not found.`, _authorizationconstants.AUTH_ERROR_REASON.InvalidOrExpiredRefreshToken);
44
+ }
45
+ return null;
46
+ }
47
+ return entity;
48
+ }
49
+ async createRefreshTokenForUserId(userId) {
50
+ const { refreshTokenExpiry } = await this.settingsStore.getCredentialSettings();
51
+ const refreshToken = (0, _uuid.v4)();
52
+ const timespan = refreshTokenExpiry ?? _serverconstants.AppConstants.DEFAULT_REFRESH_TOKEN_EXPIRY;
53
+ if (!refreshTokenExpiry) {
54
+ this.logger.warn(`Refresh token expiry not set in Settings:credentials, using default ${timespan} seconds}`);
55
+ }
56
+ await this.create({
57
+ userId,
58
+ expiresAt: Date.now() + timespan * 1000,
59
+ refreshToken,
60
+ refreshAttemptsUsed: 0
61
+ });
62
+ return refreshToken;
63
+ }
64
+ async updateRefreshTokenAttempts(refreshToken, refreshAttemptsUsed) {
65
+ await this.getRefreshToken(refreshToken, true);
66
+ await this.repository.update({
67
+ refreshToken
68
+ }, {
69
+ refreshAttemptsUsed
70
+ });
71
+ }
72
+ async purgeAllOutdatedRefreshTokens() {
73
+ const result = await this.repository.delete({
74
+ expiresAt: (0, _typeorm.LessThan)(Date.now())
75
+ });
76
+ if (result.affected) {
77
+ this.logger.debug(`Removed ${result.affected} outdated refresh tokens`);
78
+ }
79
+ }
80
+ async deleteRefreshTokenByUserId(userId) {
81
+ const result = await this.repository.delete({
82
+ userId
83
+ });
84
+ if (result.affected) {
85
+ this.logger.debug(`Removed ${result.affected} login refresh tokens for user ${userId}`);
86
+ }
87
+ }
88
+ async deleteRefreshToken(refreshToken) {
89
+ const result = await this.repository.delete({
90
+ refreshToken
91
+ });
92
+ if (result.affected) {
93
+ this.logger.debug(`Removed ${result.affected} login refresh tokens`);
94
+ }
95
+ }
96
+ async purgeOutdatedRefreshTokensByUserId(userId) {
97
+ const result = await this.repository.delete({
98
+ userId,
99
+ expiresAt: (0, _typeorm.LessThan)(Date.now())
100
+ });
101
+ if (result.affected) {
102
+ this.logger.debug(`Removed ${result.affected} outdated login refresh tokens for user ${userId}`);
103
+ }
104
+ }
105
+ }
106
+
107
+ //# sourceMappingURL=refresh-token.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/orm/refresh-token.service.ts"],"names":["RefreshTokenService","BaseService","RefreshToken","RefreshTokenDto","settingsStore","logger","constructor","typeormService","loggerFactory","name","toDto","entity","id","userId","expiresAt","refreshAttemptsUsed","getRefreshToken","refreshToken","throwNotFoundError","repository","findOneBy","AuthenticationError","AUTH_ERROR_REASON","InvalidOrExpiredRefreshToken","createRefreshTokenForUserId","refreshTokenExpiry","getCredentialSettings","uuidv4","timespan","AppConstants","DEFAULT_REFRESH_TOKEN_EXPIRY","warn","create","Date","now","updateRefreshTokenAttempts","update","purgeAllOutdatedRefreshTokens","result","delete","LessThan","affected","debug","deleteRefreshTokenByUserId","deleteRefreshToken","purgeOutdatedRefreshTokens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nB,UAAU,CAACoB,MAAM,CAAC;YAC1C1B;YACAC,WAAW0B,IAAAA,iBAAQ,EAACP,KAAKC,GAAG;QAC9B;QAEA,IAAII,OAAOG,QAAQ,EAAE;YACnB,IAAI,CAACpC,MAAM,CAACqC,KAAK,CAAC,CAAC,QAAQ,EAAEJ,OAAOG,QAAQ,CAAC,wCAAwC,EAAE5B,OAAO,CAAC;QACjG;IACF;AACF"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RoleService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RoleService;
9
+ }
10
+ });
11
+ const _baseservice = require("./base.service");
12
+ const _entities = require("../../entities");
13
+ const _roledto = require("../interfaces/role.dto");
14
+ const _lodash = require("lodash");
15
+ const _runtimeexceptions = require("../../exceptions/runtime.exceptions");
16
+ const _authorizationconstants = require("../../constants/authorization.constants");
17
+ class RoleService extends (0, _baseservice.BaseService)(_entities.Role, _roledto.RoleDto) {
18
+ settingsStore;
19
+ appDefaultRole;
20
+ appDefaultRoleNoLogin;
21
+ logger;
22
+ constructor({ loggerFactory, appDefaultRole, appDefaultRoleNoLogin, settingsStore, typeormService }){
23
+ super({
24
+ typeormService
25
+ });
26
+ this.logger = loggerFactory(RoleService.name);
27
+ this.settingsStore = settingsStore;
28
+ this.appDefaultRole = appDefaultRole;
29
+ this.appDefaultRoleNoLogin = appDefaultRoleNoLogin;
30
+ }
31
+ _roles = [];
32
+ get roles() {
33
+ return this._roles;
34
+ }
35
+ async getAppDefaultRole() {
36
+ if (await this.settingsStore.getLoginRequired()) {
37
+ return this.appDefaultRole;
38
+ }
39
+ return this.appDefaultRoleNoLogin;
40
+ }
41
+ async getAppDefaultRoleIds() {
42
+ if (!this._roles?.length) {
43
+ await this.syncRoles();
44
+ }
45
+ const guestRole = this.getRoleByName(await this.getAppDefaultRole());
46
+ return [
47
+ guestRole.id
48
+ ];
49
+ }
50
+ toDto(role) {
51
+ return {
52
+ id: role.id,
53
+ name: role.name
54
+ };
55
+ }
56
+ getRolesPermissions(roles) {
57
+ let permissions = [];
58
+ if (!roles?.length) return [];
59
+ for (let role of roles){
60
+ const normalizedRole = this.normalizeRoleIdOrName(role);
61
+ const rolePermissions = this.getRolePermissions(normalizedRole);
62
+ permissions = (0, _lodash.union)(permissions, rolePermissions);
63
+ }
64
+ return permissions;
65
+ }
66
+ authorizeRoles(requiredRoles, assignedRoles, subset) {
67
+ let isAuthorized = false;
68
+ if (!requiredRoles?.length) return true;
69
+ requiredRoles.forEach((rr)=>{
70
+ const result = this.authorizeRole(rr, assignedRoles);
71
+ isAuthorized = subset ? isAuthorized || result : isAuthorized && result;
72
+ });
73
+ return isAuthorized;
74
+ }
75
+ authorizeRole(requiredRole, assignedRoles) {
76
+ return !!assignedRoles.find((ar)=>{
77
+ const normalizedRole = this.normalizeRoleIdOrName(ar);
78
+ if (!normalizedRole) return false;
79
+ return normalizedRole === requiredRole;
80
+ });
81
+ }
82
+ getManyRoles(roleIds) {
83
+ return roleIds.map((roleId)=>this.getRole(roleId));
84
+ }
85
+ getRole(roleId) {
86
+ const role = this._roles.find((r)=>r.id === roleId);
87
+ if (!role) throw new _runtimeexceptions.NotFoundException(`Role Id '${roleId}' not found`);
88
+ return role;
89
+ }
90
+ getRoleByName(roleName) {
91
+ const role = this._roles.find((r)=>r.name === roleName);
92
+ if (!role) throw new _runtimeexceptions.NotFoundException(`Role by name ${roleName} not found`);
93
+ return role;
94
+ }
95
+ getRolePermissions(role) {
96
+ const normalizedRole = this.normalizeRoleIdOrName(role);
97
+ return _authorizationconstants.ROLE_PERMS[normalizedRole];
98
+ }
99
+ async getSynchronizedRoleByName(roleName) {
100
+ if (!this._roles?.length) {
101
+ await this.syncRoles();
102
+ }
103
+ return this.getRoleByName(roleName);
104
+ }
105
+ normalizeRoleIdOrName(assignedRole) {
106
+ const roleInstance = this.roles.find((r)=>r.id === assignedRole || r.name === assignedRole);
107
+ if (!roleInstance) {
108
+ console.warn(`The role by ID ${assignedRole} did not exist in definition. Skipping.`);
109
+ return;
110
+ }
111
+ return roleInstance.name;
112
+ }
113
+ async syncRoles() {
114
+ this._roles = [];
115
+ for (let roleName of Object.values(_authorizationconstants.ROLES)){
116
+ const storedRole = await this.repository.findOneBy({
117
+ name: roleName
118
+ });
119
+ if (!storedRole) {
120
+ const newRole = await this.create({
121
+ name: roleName
122
+ });
123
+ this._roles.push(newRole);
124
+ } else {
125
+ this._roles.push(storedRole);
126
+ }
127
+ }
128
+ }
129
+ }
130
+
131
+ //# sourceMappingURL=role.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/orm/role.service.ts"],"names":["RoleService","BaseService","Role","RoleDto","settingsStore","appDefaultRole","appDefaultRoleNoLogin","logger","constructor","loggerFactory","typeormService","name","_roles","roles","getAppDefaultRole","getLoginRequired","getAppDefaultRoleIds","length","syncRoles","guestRole","getRoleByName","id","toDto","role","getRolesPermissions","permissions","normalizedRole","normalizeRoleIdOrName","rolePermissions","getRolePermissions","union","authorizeRoles","requiredRoles","assignedRoles","subset","isAuthorized","forEach","rr","result","authorizeRole","requiredRole","find","ar","getManyRoles","roleIds","map","roleId","getRole","r","NotFoundException","roleName","ROLE_PERMS","getSynchronizedRoleByName","assignedRole","roleInstance","console","warn","Object","values","ROLES","storedRole","repository","findOneBy","newRole","create","push"],"mappings":";;;;+BAaaA;;;eAAAA;;;6BAbe;0BAGP;yBAKG;wBACF;mCACY;wCACA;AAE3B,MAAMA,oBAAoBC,IAAAA,wBAAW,EAACC,cAAI,EAAEC,gBAAO;IACxDC,cAA6B;IAC7BC,eAAwB;IACxBC,sBAA8B;IACtBC,OAAsB;IAE9BC,YAAY,EACVC,aAAa,EACbJ,cAAc,EACdC,qBAAqB,EACrBF,aAAa,EACbM,cAAc,EAOf,CAAE;QACD,KAAK,CAAC;YAAEA;QAAe;QACvB,IAAI,CAACH,MAAM,GAAGE,cAAcT,YAAYW,IAAI;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AAErC,IAAI,KAAK0C;QAChF,IAAI,CAACC,cAAc;YACjBC,QAAQC,IAAI,CAAC,CAAC,eAAe,EAAEH,aAAa,uCAAuC,CAAC;YACpF;QACF;QAEA,OAAOC,aAAa3C,IAAI;IAC1B;IAEA,MAAMO,YAA2B;QAC/B,IAAI,CAACN,MAAM,GAAG,EAAE;QAChB,KAAK,IAAIsC,YAAYO,OAAOC,MAAM,CAACC,6BAAK,EAAG;YACzC,MAAMC,aAAa,MAAM,IAAI,CAACC,UAAU,CAACC,SAAS,CAAC;gBAAEnD,MAAMuC;YAAS;YACpE,IAAI,CAACU,YAAY;gBACf,MAAMG,UAAU,MAAM,IAAI,CAACC,MAAM,CAAC;oBAChCrD,MAAMuC;gBACR;gBACA,IAAI,CAACtC,MAAM,CAACqD,IAAI,CAACF;YACnB,OAAO;gBACL,IAAI,CAACnD,MAAM,CAACqD,IAAI,CAACL;YACnB;QACF;IACF;AACF"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "SettingsService2", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return SettingsService2;
9
+ }
10
+ });
11
+ const _entities = require("../../entities");
12
+ const _serversettingsconstants = require("../../constants/server-settings.constants");
13
+ const _baseservice = require("./base.service");
14
+ const _settingsdto = require("../interfaces/settings.dto");
15
+ const _runtimeexceptions = require("../../exceptions/runtime.exceptions");
16
+ const _serverconstants = require("../../server.constants");
17
+ const _validators = require("../../handlers/validators");
18
+ const _settingsservicevalidation = require("../validators/settings-service.validation");
19
+ class SettingsService2 extends (0, _baseservice.BaseService)(_entities.Settings, _settingsdto.SettingsDto) {
20
+ configService;
21
+ constructor({ configService, typeormService }){
22
+ super({
23
+ typeormService
24
+ });
25
+ this.configService = configService;
26
+ }
27
+ toDto(entity) {
28
+ return {
29
+ [_serversettingsconstants.serverSettingsKey]: entity[_serversettingsconstants.serverSettingsKey],
30
+ [_serversettingsconstants.frontendSettingKey]: entity[_serversettingsconstants.frontendSettingKey],
31
+ [_serversettingsconstants.fileCleanSettingKey]: entity[_serversettingsconstants.fileCleanSettingKey],
32
+ [_serversettingsconstants.wizardSettingKey]: entity[_serversettingsconstants.wizardSettingKey],
33
+ [_serversettingsconstants.timeoutSettingKey]: entity[_serversettingsconstants.timeoutSettingKey]
34
+ };
35
+ }
36
+ async getOrCreate() {
37
+ let settings = await this.get();
38
+ if (!settings) {
39
+ const settings = await this.create({
40
+ [_serversettingsconstants.serverSettingsKey]: (0, _serversettingsconstants.getDefaultServerSettings)(),
41
+ [_serversettingsconstants.credentialSettingsKey]: (0, _serversettingsconstants.getDefaultCredentialSettings)(),
42
+ [_serversettingsconstants.wizardSettingKey]: (0, _serversettingsconstants.getDefaultWizardSettings)(),
43
+ [_serversettingsconstants.fileCleanSettingKey]: (0, _serversettingsconstants.getDefaultFileCleanSettings)(),
44
+ [_serversettingsconstants.frontendSettingKey]: (0, _serversettingsconstants.getDefaultFrontendSettings)(),
45
+ [_serversettingsconstants.timeoutSettingKey]: (0, _serversettingsconstants.getDefaultTimeout)()
46
+ });
47
+ return settings;
48
+ } else {
49
+ settings = this.migrateSettingsRuntime(settings);
50
+ }
51
+ return settings;
52
+ }
53
+ async getServerSettings() {
54
+ const settings = await this.getOrCreate();
55
+ return settings[_serversettingsconstants.serverSettingsKey];
56
+ }
57
+ async patchServerSettings(serverSettingsPartial) {
58
+ const entity = await this.getOrCreate();
59
+ if (!entity[_serversettingsconstants.serverSettingsKey]) {
60
+ throw new Error("No existing server settings found, cant patch");
61
+ }
62
+ const newServerSettings = {
63
+ ...entity[_serversettingsconstants.serverSettingsKey],
64
+ ...serverSettingsPartial
65
+ };
66
+ return await this.updateServerSettings(newServerSettings);
67
+ }
68
+ async updateServerSettings(serverSettings) {
69
+ const entity = await this.getOrCreate();
70
+ entity[_serversettingsconstants.serverSettingsKey] = serverSettings;
71
+ await this.update(entity.id, entity);
72
+ return entity;
73
+ }
74
+ async updateCredentialSettings(credentialSettings) {
75
+ const entity = await this.getOrCreate();
76
+ entity[_serversettingsconstants.credentialSettingsKey] = credentialSettings;
77
+ await this.update(entity.id, entity);
78
+ return entity;
79
+ }
80
+ async updateFileCleanSettings(fileCleanSettings) {
81
+ const entity = await this.getOrCreate();
82
+ entity[_serversettingsconstants.fileCleanSettingKey] = fileCleanSettings;
83
+ await this.update(entity.id, entity);
84
+ return entity;
85
+ }
86
+ async updateFrontendSettings(frontendSettings) {
87
+ const entity = await this.getOrCreate();
88
+ entity[_serversettingsconstants.frontendSettingKey] = frontendSettings;
89
+ await this.update(entity.id, entity);
90
+ return entity;
91
+ }
92
+ async updateTimeoutSettings(timeoutSettings) {
93
+ const entity = await this.getOrCreate();
94
+ entity[_serversettingsconstants.timeoutSettingKey] = timeoutSettings;
95
+ await this.update(entity.id, entity);
96
+ return entity;
97
+ }
98
+ async patchWizardSettings(wizardSettingsPartial) {
99
+ const entity = await this.getOrCreate();
100
+ if (!entity[_serversettingsconstants.wizardSettingKey]) {
101
+ throw new Error("No existing wizard settings found, cant patch");
102
+ }
103
+ const newWizardSettings = {
104
+ ...entity[_serversettingsconstants.wizardSettingKey],
105
+ ...wizardSettingsPartial
106
+ };
107
+ return await this.updateWizardSettings(newWizardSettings);
108
+ }
109
+ async updateWizardSettings(wizardSettings) {
110
+ const entity = await this.getOrCreate();
111
+ entity[_serversettingsconstants.wizardSettingKey] = wizardSettings;
112
+ await this.update(entity.id, entity);
113
+ return entity;
114
+ }
115
+ async get() {
116
+ const settingsList = await this.repository.find({
117
+ take: 1
118
+ });
119
+ return settingsList?.length ? settingsList[0] : null;
120
+ }
121
+ migrateSettingsRuntime(knownSettings) {
122
+ const entity = knownSettings;
123
+ if (!entity[_serversettingsconstants.fileCleanSettingKey]) {
124
+ entity[_serversettingsconstants.fileCleanSettingKey] = (0, _serversettingsconstants.getDefaultFileCleanSettings)();
125
+ }
126
+ if (!entity[_serversettingsconstants.wizardSettingKey]) {
127
+ entity[_serversettingsconstants.wizardSettingKey] = (0, _serversettingsconstants.getDefaultWizardSettings)();
128
+ }
129
+ if (!entity[_serversettingsconstants.timeoutSettingKey]) {
130
+ entity[_serversettingsconstants.timeoutSettingKey] = (0, _serversettingsconstants.getDefaultTimeout)();
131
+ }
132
+ if (!entity[_serversettingsconstants.serverSettingsKey]) {
133
+ entity[_serversettingsconstants.serverSettingsKey] = (0, _serversettingsconstants.getDefaultServerSettings)();
134
+ }
135
+ if (!entity[_serversettingsconstants.credentialSettingsKey]) {
136
+ entity[_serversettingsconstants.credentialSettingsKey] = (0, _serversettingsconstants.getDefaultCredentialSettings)();
137
+ }
138
+ if (!this.isWhiteListSettingEnabled()) {
139
+ entity.server.whitelistEnabled = false;
140
+ entity.server.whitelistedIpAddresses = (0, _serversettingsconstants.getDefaultWhitelistIpAddresses)();
141
+ } else if (!entity.server.whitelistedIpAddresses?.length) {
142
+ entity.server.whitelistedIpAddresses = (0, _serversettingsconstants.getDefaultWhitelistIpAddresses)();
143
+ }
144
+ if (!entity[_serversettingsconstants.frontendSettingKey]) {
145
+ entity[_serversettingsconstants.frontendSettingKey] = (0, _serversettingsconstants.getDefaultFrontendSettings)();
146
+ }
147
+ return entity;
148
+ }
149
+ async patchCredentialSettings(patchUpdate) {
150
+ const entity = await this.getOrCreate();
151
+ if (!entity[_serversettingsconstants.credentialSettingsKey]) {
152
+ throw new Error("No existing wizard settings found, cant patch");
153
+ }
154
+ const newCredentialSettings = {
155
+ ...entity[_serversettingsconstants.credentialSettingsKey],
156
+ ...patchUpdate
157
+ };
158
+ return await this.updateCredentialSettings(newCredentialSettings);
159
+ }
160
+ async patchFileCleanSettings(patchUpdate) {
161
+ const entity = await this.getOrCreate();
162
+ if (!entity[_serversettingsconstants.fileCleanSettingKey]) {
163
+ throw new Error("No existing wizard settings found, cant patch");
164
+ }
165
+ const newFileCleanSettings = {
166
+ ...entity[_serversettingsconstants.fileCleanSettingKey],
167
+ ...patchUpdate
168
+ };
169
+ return await this.updateFileCleanSettings(newFileCleanSettings);
170
+ }
171
+ async setLoginRequired(enabled) {
172
+ const entity = await this.getOrCreate();
173
+ entity[_serversettingsconstants.serverSettingsKey].loginRequired = enabled;
174
+ await this.update(entity.id, entity);
175
+ return entity;
176
+ }
177
+ async setRegistrationEnabled(enabled) {
178
+ const entity = await this.getOrCreate();
179
+ entity[_serversettingsconstants.serverSettingsKey].registration = enabled;
180
+ await this.update(entity.id, entity);
181
+ return entity;
182
+ }
183
+ async setSentryDiagnosticsEnabled(enabled) {
184
+ const entity = await this.getOrCreate();
185
+ entity[_serversettingsconstants.serverSettingsKey].sentryDiagnosticsEnabled = enabled;
186
+ await this.update(entity.id, entity);
187
+ return entity;
188
+ }
189
+ async setWhitelist(enabled, ipAddresses) {
190
+ if (!this.isWhiteListSettingEnabled()) {
191
+ throw new _runtimeexceptions.BadRequestException("Whitelist settings are not enabled");
192
+ }
193
+ await (0, _validators.validateInput)({
194
+ whitelistEnabled: enabled,
195
+ whitelistedIpAddresses: ipAddresses
196
+ }, _settingsservicevalidation.whitelistSettingUpdateRules);
197
+ const entity = await this.getOrCreate();
198
+ entity[_serversettingsconstants.serverSettingsKey].whitelistEnabled = enabled;
199
+ entity[_serversettingsconstants.serverSettingsKey].whitelistedIpAddresses = ipAddresses;
200
+ await this.update(entity.id, entity);
201
+ return entity;
202
+ }
203
+ isWhiteListSettingEnabled() {
204
+ return this.configService.get(_serverconstants.AppConstants.ENABLE_EXPERIMENTAL_WHITELIST_SETTINGS, "false") === "true";
205
+ }
206
+ }
207
+
208
+ //# sourceMappingURL=settings.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/orm/settings.service.ts"],"names":["SettingsService2","BaseService","Settings","SettingsDto","configService","constructor","typeormService","toDto","entity","serverSettingsKey","frontendSettingKey","fileCleanSettingKey","wizardSettingKey","timeoutSettingKey","getOrCreate","settings","get","create","getDefaultServerSettings","credentialSettingsKey","getDefaultCredentialSettings","getDefaultWizardSettings","getDefaultFileCleanSettings","getDefaultFrontendSettings","getDefaultTimeout","migrateSettingsRuntime","getServerSettings","patchServerSettings","serverSettingsPartial","Error","newServerSettings","updateServerSettings","serverSettings","update","id","updateCredentialSettings","credentialSettings","updateFileCleanSettings","fileCleanSettings","updateFrontendSettings","frontendSettings","updateTimeoutSettings","timeoutSettings","patchWizardSettings","wizardSettingsPartial","newWizardSettings","updateWizardSettings","wizardSettings","settingsList","repository","find","take","length","knownSettings","isWhiteListSettingEnabled","server","whitelistEnabled","whitelistedIpAddresses","getDefaultWhitelistIpAddresses","patchCredentialSettings","patchUpdate","newCredentialSettings","patchFileCleanSettings","newFileCleanSettings","setLoginRequired","enabled","loginRequired","setRegistrationEnabled","registration","setSentryDiagnosticsEnabled","sentryDiagnosticsEnabled","setWhitelist","ipAddresses","BadRequestException","validateInput","whitelistSettingUpdateRules","AppConstants","ENABLE_EXPERIMENTAL_WHITELIST_SETTINGS"],"mappings":";;;;+BAoCaA;;;eAAAA;;;0BApCY;yCAelB;6BACqB;6BASrB;mCAI6B;iCACP;4BAGC;2CACc;AAErC,MAAMA,yBAAyBC,IAAAA,wBAAW,EAACC,kBAAQ,EAAEC,wBAAW;IACrEC,cAA8B;IAE9BC,YAAY,EAAED,aAAa,EAAEE,cAAc,EAAqE,CAAE;QAChH,KAAK,CAAC;YAAEA;QAAe;QACvB,IAAI,CAACF,aAAa,GAAGA;IACvB;IAEAG,MAAMC,MAAgB,EAA6B;QACjD,OAAO;YACL,CAACC,0CAAiB,CAAC,EAAED,MAAM,CAACC,0CAAiB,CAAC;YAC9C,CAACC,2CAAkB,CAAC,EAAEF,MAAM,CAACE,2CAAkB,CAAC;YAChD,CAACC,4CAAmB,CAAC,EAAEH,MAAM,CAACG,4CAAmB,CAAC;YAClD,CAACC,yCAAgB,CAAC,EAAEJ,MAAM,CAACI,yCAAgB,CAAC;YAC5C,CAACC,0CAAiB,CAAC,EAAEL,MAAM,CAACK,0CAAiB,CAAC;QAChD;IACF;IAEA,MAAMC,cAAc;QAClB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B,EAAE,EAAE1B;QAC7B,OAAOA;IACT;IAEA,MAAM+D,aAAaN,OAAgB,EAAEO,WAAqB,EAAqB;QAC7E,IAAI,CAAC,IAAI,CAAClB,yBAAyB,IAAI;YACrC,MAAM,IAAImB,sCAAmB,CAAC;QAChC;QACA,MAAMC,IAAAA,yBAAa,EACjB;YACElB,kBAAkBS;YAClBR,wBAAwBe;QAC1B,GACAG,sDAA2B;QAG7B,MAAMnE,SAAS,MAAM,IAAI,CAACM,WAAW;QACrCN,MAAM,CAACC,0CAAiB,CAAC,CAAC+C,gBAAgB,GAAGS;QAC7CzD,MAAM,CAACC,0CAAiB,CAAC,CAACgD,sBAAsB,GAAGe;QACnD,MAAM,IAAI,CAACvC,MAAM,CAACzB,OAAO0B,EAAE,EAAE1B;QAC7B,OAAOA;IACT;IAEA8C,4BAA4B;QAC1B,OAAO,IAAI,CAAClD,aAAa,CAACY,GAAG,CAAC4D,6BAAY,CAACC,sCAAsC,EAAE,aAAa;IAClG;AACF"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "UserRoleService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return UserRoleService;
9
+ }
10
+ });
11
+ const _baseservice = require("./base.service");
12
+ const _userroleentity = require("../../entities/user-role.entity");
13
+ const _userroledto = require("../interfaces/user-role.dto");
14
+ const _typeorm = require("typeorm");
15
+ class UserRoleService extends (0, _baseservice.BaseService)(_userroleentity.UserRole, _userroledto.UserRoleDto) {
16
+ toDto(entity) {
17
+ return {
18
+ id: entity.id,
19
+ roleId: entity.roleId,
20
+ userId: entity.userId,
21
+ createdAt: entity.createdAt
22
+ };
23
+ }
24
+ async setUserRoles(userId, roleIds) {
25
+ const previousRoles = await this.listUserRoles(userId);
26
+ const previousIds = previousRoles.map((p)=>p.roleId);
27
+ const deletedRoleIds = previousIds.filter((p)=>!roleIds.includes(p));
28
+ await this.deleteManyUserRoles(userId, deletedRoleIds);
29
+ const createdRoleIds = roleIds.filter((r)=>!previousIds.includes(r));
30
+ for (let roleId of createdRoleIds){
31
+ await this.create({
32
+ roleId,
33
+ userId
34
+ });
35
+ }
36
+ }
37
+ deleteManyUserRoles(userId, roleIds) {
38
+ return this.repository.delete({
39
+ userId,
40
+ roleId: (0, _typeorm.In)(roleIds)
41
+ });
42
+ }
43
+ listByRoleId(roleId) {
44
+ return this.repository.findBy({
45
+ roleId
46
+ });
47
+ }
48
+ async listUserRoles(userId) {
49
+ return this.repository.findBy({
50
+ userId
51
+ });
52
+ }
53
+ }
54
+
55
+ //# sourceMappingURL=user-role.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/orm/user-role.service.ts"],"names":["UserRoleService","BaseService","UserRole","UserRoleDto","toDto","entity","id","roleId","userId","createdAt","setUserRoles","roleIds","previousRoles","listUserRoles","previousIds","map","p","deletedRoleIds","filter","includes","deleteManyUserRoles","createdRoleIds","r","create","repository","delete","In","listByRoleId","findBy"],"mappings":";;;;+BAKaA;;;eAAAA;;;6BALe;gCACH;6BACG;yBACT;AAEZ,MAAMA,wBAAwBC,IAAAA,wBAAW,EAACC,wBAAQ,EAAEC,wBAAW;IACpEC,MAAMC,MAAgB,EAAe;QACnC,OAAO;YACLC,IAAID,OAAOC,EAAE;YACbC,QAAQF,OAAOE,MAAM;YACrBC,QAAQH,OAAOG,MAAM;YACrBC,WAAWJ,OAAOI,SAAS;QAC7B;IACF;IAEA,MAAMC,aAAaF,MAAc,EAAEG,OAAiB,EAAE;QACpD,MAAMC,gBAAgB,MAAM,IAAI,CAACC,aAAa,CAACL;QAC/C,MAAMM,cAAcF,cAAcG,GAAG,CAAC,CAACC,IAAMA,EAAET,MAAM;QAErD,MAAMU,iBAAiBH,YAAYI,MAAM,CAAC,CAACF,IAAM,CAACL,QAAQQ,QAAQ,CAACH;QACnE,MAAM,IAAI,CAACI,mBAAmB,CAACZ,QAAQS;QACvC,MAAMI,iBAAiBV,QAAQO,MAAM,CAAC,CAACI,IAAM,CAACR,YAAYK,QAAQ,CAACG;QACnE,KAAK,IAAIf,UAAUc,eAAgB;YACjC,MAAM,IAAI,CAACE,MAAM,CAAC;gBAChBhB;gBACAC;YACF;QACF;IACF;IAEAY,oBAAoBZ,MAAc,EAAEG,OAAiB,EAAE;QACrD,OAAO,IAAI,CAACa,UAAU,CAACC,MAAM,CAAC;YAC5BjB;YACAD,QAAQmB,IAAAA,WAAE,EAACf;QACb;IACF;IAEAgB,aAAapB,MAAc,EAAE;QAC3B,OAAO,IAAI,CAACiB,UAAU,CAACI,MAAM,CAAC;YAAErB;QAAO;IACzC;IAEA,MAAMM,cAAcL,MAAc,EAAE;QAClC,OAAO,IAAI,CAACgB,UAAU,CAACI,MAAM,CAAC;YAAEpB;QAAO;IACzC;AACF"}