@northern.tech/store 0.3.3 → 0.4.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 (602) hide show
  1. package/dist/actions.cjs +80 -833
  2. package/dist/actions.cjs.map +1 -1
  3. package/dist/actions.d.cts +229 -85
  4. package/dist/actions.d.ts +229 -85
  5. package/dist/actions.js +14 -14
  6. package/dist/api/general-api.cjs +274 -148
  7. package/dist/api/general-api.cjs.map +1 -1
  8. package/dist/api/general-api.d.cts +1 -1
  9. package/dist/api/general-api.d.ts +1 -1
  10. package/dist/api/general-api.js +7 -7
  11. package/dist/api/users-api.cjs +274 -148
  12. package/dist/api/users-api.cjs.map +1 -1
  13. package/dist/api/users-api.d.cts +7 -5
  14. package/dist/api/users-api.d.ts +7 -5
  15. package/dist/api/users-api.js +8 -8
  16. package/dist/appSlice/constants.cjs +23 -43
  17. package/dist/appSlice/constants.cjs.map +1 -1
  18. package/dist/appSlice/constants.d.cts +109 -119
  19. package/dist/appSlice/constants.d.ts +109 -119
  20. package/dist/appSlice/constants.js +1 -11
  21. package/dist/appSlice/index.cjs +25 -242
  22. package/dist/appSlice/index.cjs.map +1 -1
  23. package/dist/appSlice/index.d.cts +119 -1531
  24. package/dist/appSlice/index.d.ts +119 -1531
  25. package/dist/appSlice/index.js +6 -6
  26. package/dist/appSlice/mocks.cjs +186 -0
  27. package/dist/appSlice/mocks.cjs.map +1 -0
  28. package/dist/appSlice/mocks.d.cts +39 -0
  29. package/dist/appSlice/mocks.d.ts +39 -0
  30. package/dist/appSlice/mocks.js +27 -0
  31. package/dist/appSlice/mocks.js.map +1 -0
  32. package/dist/appSlice/selectors.cjs +31 -5
  33. package/dist/appSlice/selectors.cjs.map +1 -1
  34. package/dist/appSlice/selectors.d.cts +709 -23
  35. package/dist/appSlice/selectors.d.ts +709 -23
  36. package/dist/appSlice/selectors.js +21 -1
  37. package/dist/appSlice/thunks.cjs +1563 -1790
  38. package/dist/appSlice/thunks.cjs.map +1 -1
  39. package/dist/appSlice/thunks.d.cts +34 -14
  40. package/dist/appSlice/thunks.d.ts +34 -14
  41. package/dist/appSlice/thunks.js +30 -29
  42. package/dist/auth.cjs +276 -153
  43. package/dist/auth.cjs.map +1 -1
  44. package/dist/auth.d.cts +13 -10
  45. package/dist/auth.d.ts +13 -10
  46. package/dist/auth.js +6 -8
  47. package/dist/{chunk-CK6YE6AN.js → chunk-2DYA3X77.js} +3 -1
  48. package/dist/{chunk-CK6YE6AN.js.map → chunk-2DYA3X77.js.map} +1 -1
  49. package/dist/{chunk-2CYOM4BK.js → chunk-4TUJPE6G.js} +19 -4
  50. package/dist/chunk-4TUJPE6G.js.map +1 -0
  51. package/dist/{chunk-7PVGDMNM.js → chunk-6KGTHJKC.js} +23 -27
  52. package/dist/chunk-6KGTHJKC.js.map +1 -0
  53. package/dist/chunk-7C4SQBEE.js +715 -0
  54. package/dist/chunk-7C4SQBEE.js.map +1 -0
  55. package/dist/{chunk-QRGTG4YB.js → chunk-ABJLRDCO.js} +10 -11
  56. package/dist/chunk-ABJLRDCO.js.map +1 -0
  57. package/dist/{chunk-LEMVXAYP.js → chunk-CW5T6OGF.js} +56 -22
  58. package/dist/chunk-CW5T6OGF.js.map +1 -0
  59. package/dist/{chunk-MRCFLG45.js → chunk-FAJ3I2UQ.js} +2 -1
  60. package/dist/chunk-FAJ3I2UQ.js.map +1 -0
  61. package/dist/{chunk-DCK2DBOA.js → chunk-IQG5I7AM.js} +29 -39
  62. package/dist/chunk-IQG5I7AM.js.map +1 -0
  63. package/dist/chunk-JUGE7L3K.js +110 -0
  64. package/dist/chunk-JUGE7L3K.js.map +1 -0
  65. package/dist/{chunk-7JKWI5FK.js → chunk-JXQUFKID.js} +2 -2
  66. package/dist/chunk-JXQUFKID.js.map +1 -0
  67. package/dist/chunk-KC7SKI3U.js +389 -0
  68. package/dist/chunk-KC7SKI3U.js.map +1 -0
  69. package/dist/{chunk-YDS36ALB.js → chunk-KJNNEDRV.js} +11 -7
  70. package/dist/chunk-KJNNEDRV.js.map +1 -0
  71. package/dist/chunk-MBKAZVE3.js +44 -0
  72. package/dist/chunk-MBKAZVE3.js.map +1 -0
  73. package/dist/{chunk-TI2RL5P2.js → chunk-MZNANSS2.js} +12 -7
  74. package/dist/chunk-MZNANSS2.js.map +1 -0
  75. package/dist/{chunk-LTKOV26W.js → chunk-N2KLYPS5.js} +138 -95
  76. package/dist/chunk-N2KLYPS5.js.map +1 -0
  77. package/dist/{chunk-UWMYZNUB.js → chunk-OHF3YUXX.js} +25 -40
  78. package/dist/chunk-OHF3YUXX.js.map +1 -0
  79. package/dist/{chunk-CYV6632F.js → chunk-OOICURFL.js} +2 -2
  80. package/dist/chunk-OOICURFL.js.map +1 -0
  81. package/dist/{chunk-VMNMD6KF.js → chunk-PGFVHKP5.js} +5 -7
  82. package/dist/chunk-PGFVHKP5.js.map +1 -0
  83. package/dist/{chunk-JAROCU6M.js → chunk-QHK7GGV4.js} +3 -3
  84. package/dist/chunk-QHK7GGV4.js.map +1 -0
  85. package/dist/{chunk-YT73QWCN.js → chunk-RS37Y2PQ.js} +3 -3
  86. package/dist/chunk-RS37Y2PQ.js.map +1 -0
  87. package/dist/{chunk-TUACATJA.js → chunk-UGSLGUS6.js} +8 -6
  88. package/dist/chunk-UGSLGUS6.js.map +1 -0
  89. package/dist/{chunk-DAPAXWA5.js → chunk-URNS6A5T.js} +14 -14
  90. package/dist/{chunk-FGKMJS3B.js → chunk-VANBSJS5.js} +2 -4
  91. package/dist/chunk-VANBSJS5.js.map +1 -0
  92. package/dist/{chunk-HPBE6KYY.js → chunk-VUFRP6P3.js} +5 -6
  93. package/dist/chunk-VUFRP6P3.js.map +1 -0
  94. package/dist/{chunk-X7IEZBM4.js → chunk-X4GUACQO.js} +8 -5
  95. package/dist/chunk-X4GUACQO.js.map +1 -0
  96. package/dist/{chunk-4XJMRVFI.js → chunk-XWYJACQC.js} +45 -22
  97. package/dist/chunk-XWYJACQC.js.map +1 -0
  98. package/dist/{chunk-AMGWP7A4.js → chunk-ZJW3QIPM.js} +8 -9
  99. package/dist/chunk-ZJW3QIPM.js.map +1 -0
  100. package/dist/chunk-ZKAH3APE.js +1 -0
  101. package/dist/chunk-ZKAH3APE.js.map +1 -0
  102. package/dist/{chunk-2JHFUQ6B.js → chunk-ZN5TB2NJ.js} +963 -883
  103. package/dist/chunk-ZN5TB2NJ.js.map +1 -0
  104. package/dist/{chunk-WXL7PVI5.js → chunk-ZRSYBSSY.js} +18 -12
  105. package/dist/chunk-ZRSYBSSY.js.map +1 -0
  106. package/dist/commonConstants.cjs +279 -173
  107. package/dist/commonConstants.cjs.map +1 -1
  108. package/dist/commonConstants.d.cts +46 -212
  109. package/dist/commonConstants.d.ts +46 -212
  110. package/dist/commonConstants.js +11 -19
  111. package/dist/commonSelectors.cjs +513 -778
  112. package/dist/commonSelectors.cjs.map +1 -1
  113. package/dist/commonSelectors.d.cts +4307 -279
  114. package/dist/commonSelectors.d.ts +4307 -279
  115. package/dist/commonSelectors.js +13 -13
  116. package/dist/constants.cjs +355 -655
  117. package/dist/constants.cjs.map +1 -1
  118. package/dist/constants.d.cts +11 -9
  119. package/dist/constants.d.ts +11 -9
  120. package/dist/constants.js +37 -29
  121. package/dist/deploymentsSlice/constants.cjs +5 -360
  122. package/dist/deploymentsSlice/constants.cjs.map +1 -1
  123. package/dist/deploymentsSlice/constants.d.cts +59 -39
  124. package/dist/deploymentsSlice/constants.d.ts +59 -39
  125. package/dist/deploymentsSlice/constants.js +5 -11
  126. package/dist/deploymentsSlice/index.cjs +17 -365
  127. package/dist/deploymentsSlice/index.cjs.map +1 -1
  128. package/dist/deploymentsSlice/index.d.cts +142 -2359
  129. package/dist/deploymentsSlice/index.d.ts +142 -2359
  130. package/dist/deploymentsSlice/index.js +6 -6
  131. package/dist/deploymentsSlice/mocks.cjs +429 -0
  132. package/dist/deploymentsSlice/mocks.cjs.map +1 -0
  133. package/dist/deploymentsSlice/mocks.d.cts +189 -0
  134. package/dist/deploymentsSlice/mocks.d.ts +189 -0
  135. package/dist/deploymentsSlice/mocks.js +146 -0
  136. package/dist/deploymentsSlice/mocks.js.map +1 -0
  137. package/dist/deploymentsSlice/selectors.cjs +5 -353
  138. package/dist/deploymentsSlice/selectors.cjs.map +1 -1
  139. package/dist/deploymentsSlice/selectors.d.cts +167 -11
  140. package/dist/deploymentsSlice/selectors.d.ts +167 -11
  141. package/dist/deploymentsSlice/selectors.js +6 -6
  142. package/dist/deploymentsSlice/thunks.cjs +1551 -1778
  143. package/dist/deploymentsSlice/thunks.cjs.map +1 -1
  144. package/dist/deploymentsSlice/thunks.d.cts +134 -76
  145. package/dist/deploymentsSlice/thunks.d.ts +134 -76
  146. package/dist/deploymentsSlice/thunks.js +30 -29
  147. package/dist/devicesSlice/constants.cjs +5 -375
  148. package/dist/devicesSlice/constants.cjs.map +1 -1
  149. package/dist/devicesSlice/constants.d.cts +8 -16
  150. package/dist/devicesSlice/constants.d.ts +8 -16
  151. package/dist/devicesSlice/constants.js +7 -25
  152. package/dist/devicesSlice/index.cjs +17 -381
  153. package/dist/devicesSlice/index.cjs.map +1 -1
  154. package/dist/devicesSlice/index.d.cts +196 -2208
  155. package/dist/devicesSlice/index.d.ts +196 -2208
  156. package/dist/devicesSlice/index.js +6 -6
  157. package/dist/devicesSlice/mocks.cjs +336 -0
  158. package/dist/devicesSlice/mocks.cjs.map +1 -0
  159. package/dist/devicesSlice/mocks.d.cts +154 -0
  160. package/dist/devicesSlice/mocks.d.ts +154 -0
  161. package/dist/devicesSlice/mocks.js +136 -0
  162. package/dist/devicesSlice/mocks.js.map +1 -0
  163. package/dist/devicesSlice/selectors.cjs +280 -293
  164. package/dist/devicesSlice/selectors.cjs.map +1 -1
  165. package/dist/devicesSlice/selectors.d.cts +1791 -82
  166. package/dist/devicesSlice/selectors.d.ts +1791 -82
  167. package/dist/devicesSlice/selectors.js +8 -6
  168. package/dist/devicesSlice/thunks.cjs +1699 -1936
  169. package/dist/devicesSlice/thunks.cjs.map +1 -1
  170. package/dist/devicesSlice/thunks.d.cts +374 -291
  171. package/dist/devicesSlice/thunks.d.ts +374 -291
  172. package/dist/devicesSlice/thunks.js +36 -45
  173. package/dist/liststatehook.cjs +935 -0
  174. package/dist/liststatehook.cjs.map +1 -0
  175. package/dist/liststatehook.d.cts +234 -0
  176. package/dist/liststatehook.d.ts +234 -0
  177. package/dist/liststatehook.js +88 -0
  178. package/dist/liststatehook.js.map +1 -0
  179. package/dist/locationutils.cjs +906 -0
  180. package/dist/locationutils.cjs.map +1 -0
  181. package/dist/locationutils.d.cts +114 -0
  182. package/dist/locationutils.d.ts +114 -0
  183. package/dist/locationutils.js +46 -0
  184. package/dist/locationutils.js.map +1 -0
  185. package/dist/monitorSlice/constants.cjs +0 -146
  186. package/dist/monitorSlice/constants.cjs.map +1 -1
  187. package/dist/monitorSlice/constants.d.cts +4 -5
  188. package/dist/monitorSlice/constants.d.ts +4 -5
  189. package/dist/monitorSlice/constants.js +1 -12
  190. package/dist/monitorSlice/index.cjs +5 -353
  191. package/dist/monitorSlice/index.cjs.map +1 -1
  192. package/dist/monitorSlice/index.d.cts +63 -260
  193. package/dist/monitorSlice/index.d.ts +63 -260
  194. package/dist/monitorSlice/index.js +6 -6
  195. package/dist/monitorSlice/mocks.cjs +130 -0
  196. package/dist/monitorSlice/mocks.cjs.map +1 -0
  197. package/dist/monitorSlice/mocks.d.cts +57 -0
  198. package/dist/monitorSlice/mocks.d.ts +57 -0
  199. package/dist/monitorSlice/mocks.js +65 -0
  200. package/dist/monitorSlice/mocks.js.map +1 -0
  201. package/dist/monitorSlice/thunks.cjs +633 -880
  202. package/dist/monitorSlice/thunks.cjs.map +1 -1
  203. package/dist/monitorSlice/thunks.d.cts +90 -21
  204. package/dist/monitorSlice/thunks.d.ts +90 -21
  205. package/dist/monitorSlice/thunks.js +26 -26
  206. package/dist/onboardingSlice/constants.cjs +1 -0
  207. package/dist/onboardingSlice/constants.cjs.map +1 -1
  208. package/dist/onboardingSlice/constants.d.cts +23 -20
  209. package/dist/onboardingSlice/constants.d.ts +23 -20
  210. package/dist/onboardingSlice/constants.js +1 -1
  211. package/dist/onboardingSlice/index.cjs +1 -3
  212. package/dist/onboardingSlice/index.cjs.map +1 -1
  213. package/dist/onboardingSlice/index.d.cts +50 -225
  214. package/dist/onboardingSlice/index.d.ts +50 -225
  215. package/dist/onboardingSlice/index.js +1 -1
  216. package/dist/onboardingSlice/mocks.cjs +83 -0
  217. package/dist/onboardingSlice/mocks.cjs.map +1 -0
  218. package/dist/onboardingSlice/mocks.d.cts +19 -0
  219. package/dist/onboardingSlice/mocks.d.ts +19 -0
  220. package/dist/onboardingSlice/mocks.js +17 -0
  221. package/dist/onboardingSlice/mocks.js.map +1 -0
  222. package/dist/onboardingSlice/thunks.cjs +1787 -2020
  223. package/dist/onboardingSlice/thunks.cjs.map +1 -1
  224. package/dist/onboardingSlice/thunks.d.cts +63 -36
  225. package/dist/onboardingSlice/thunks.d.ts +63 -36
  226. package/dist/onboardingSlice/thunks.js +30 -31
  227. package/dist/organizationSlice/constants.cjs +8 -748
  228. package/dist/organizationSlice/constants.cjs.map +1 -1
  229. package/dist/organizationSlice/constants.d.cts +36 -116
  230. package/dist/organizationSlice/constants.d.ts +36 -116
  231. package/dist/organizationSlice/constants.js +7 -17
  232. package/dist/organizationSlice/index.cjs +14 -368
  233. package/dist/organizationSlice/index.cjs.map +1 -1
  234. package/dist/organizationSlice/index.d.cts +45 -73
  235. package/dist/organizationSlice/index.d.ts +45 -73
  236. package/dist/organizationSlice/index.js +6 -6
  237. package/dist/organizationSlice/mocks.cjs +234 -0
  238. package/dist/organizationSlice/mocks.cjs.map +1 -0
  239. package/dist/organizationSlice/mocks.d.cts +107 -0
  240. package/dist/organizationSlice/mocks.d.ts +107 -0
  241. package/dist/organizationSlice/mocks.js +101 -0
  242. package/dist/organizationSlice/mocks.js.map +1 -0
  243. package/dist/organizationSlice/selectors.cjs +301 -146
  244. package/dist/organizationSlice/selectors.cjs.map +1 -1
  245. package/dist/organizationSlice/selectors.d.cts +888 -51
  246. package/dist/organizationSlice/selectors.d.ts +888 -51
  247. package/dist/organizationSlice/selectors.js +14 -6
  248. package/dist/organizationSlice/thunks.cjs +2616 -2759
  249. package/dist/organizationSlice/thunks.cjs.map +1 -1
  250. package/dist/organizationSlice/thunks.d.cts +322 -131
  251. package/dist/organizationSlice/thunks.d.ts +322 -131
  252. package/dist/organizationSlice/thunks.js +44 -29
  253. package/dist/organizationSlice/types.cjs.map +1 -1
  254. package/dist/organizationSlice/types.d.cts +62 -79
  255. package/dist/organizationSlice/types.d.ts +62 -79
  256. package/dist/releasesSlice/constants.cjs +3 -0
  257. package/dist/releasesSlice/constants.cjs.map +1 -1
  258. package/dist/releasesSlice/constants.d.cts +2 -1
  259. package/dist/releasesSlice/constants.d.ts +2 -1
  260. package/dist/releasesSlice/constants.js +3 -1
  261. package/dist/releasesSlice/index.cjs +5 -222
  262. package/dist/releasesSlice/index.cjs.map +1 -1
  263. package/dist/releasesSlice/index.d.cts +52 -473
  264. package/dist/releasesSlice/index.d.ts +52 -473
  265. package/dist/releasesSlice/index.js +6 -6
  266. package/dist/releasesSlice/mocks.cjs +177 -0
  267. package/dist/releasesSlice/mocks.cjs.map +1 -0
  268. package/dist/releasesSlice/mocks.d.cts +49 -0
  269. package/dist/releasesSlice/mocks.d.ts +49 -0
  270. package/dist/releasesSlice/mocks.js +61 -0
  271. package/dist/releasesSlice/mocks.js.map +1 -0
  272. package/dist/releasesSlice/selectors.cjs +293 -165
  273. package/dist/releasesSlice/selectors.cjs.map +1 -1
  274. package/dist/releasesSlice/selectors.d.cts +886 -24
  275. package/dist/releasesSlice/selectors.d.ts +886 -24
  276. package/dist/releasesSlice/selectors.js +9 -7
  277. package/dist/releasesSlice/thunks.cjs +827 -1017
  278. package/dist/releasesSlice/thunks.cjs.map +1 -1
  279. package/dist/releasesSlice/thunks.d.cts +150 -130
  280. package/dist/releasesSlice/thunks.d.ts +150 -130
  281. package/dist/releasesSlice/thunks.js +33 -26
  282. package/dist/selectors.cjs +565 -780
  283. package/dist/selectors.cjs.map +1 -1
  284. package/dist/selectors.d.cts +37 -8
  285. package/dist/selectors.d.ts +37 -8
  286. package/dist/selectors.js +54 -18
  287. package/dist/sockethook.cjs +519 -0
  288. package/dist/sockethook.cjs.map +1 -0
  289. package/dist/sockethook.d.cts +10 -0
  290. package/dist/sockethook.d.ts +10 -0
  291. package/dist/sockethook.js +139 -0
  292. package/dist/sockethook.js.map +1 -0
  293. package/dist/store.cjs +121 -840
  294. package/dist/store.cjs.map +1 -1
  295. package/dist/store.d.cts +697 -1961
  296. package/dist/store.d.ts +697 -1961
  297. package/dist/store.js +18 -16
  298. package/dist/storehooks.cjs +1854 -1968
  299. package/dist/storehooks.cjs.map +1 -1
  300. package/dist/storehooks.js +46 -63
  301. package/dist/storehooks.js.map +1 -1
  302. package/dist/thunks.cjs +2138 -2231
  303. package/dist/thunks.cjs.map +1 -1
  304. package/dist/thunks.d.cts +25 -7
  305. package/dist/thunks.d.ts +25 -7
  306. package/dist/thunks.js +54 -45
  307. package/dist/{deploymentdevicehook.cjs → useDeploymentDevice.cjs} +1797 -2026
  308. package/dist/useDeploymentDevice.cjs.map +1 -0
  309. package/dist/useDeploymentDevice.js +63 -0
  310. package/dist/useDeploymentDevice.js.map +1 -0
  311. package/dist/usersSlice/constants.cjs +5 -747
  312. package/dist/usersSlice/constants.cjs.map +1 -1
  313. package/dist/usersSlice/constants.d.cts +16 -774
  314. package/dist/usersSlice/constants.d.ts +16 -774
  315. package/dist/usersSlice/constants.js +7 -30
  316. package/dist/usersSlice/index.cjs +10 -721
  317. package/dist/usersSlice/index.cjs.map +1 -1
  318. package/dist/usersSlice/index.d.cts +136 -7900
  319. package/dist/usersSlice/index.d.ts +136 -7900
  320. package/dist/usersSlice/index.js +6 -6
  321. package/dist/usersSlice/mocks.cjs +200 -0
  322. package/dist/usersSlice/mocks.cjs.map +1 -0
  323. package/dist/usersSlice/mocks.d.cts +83 -0
  324. package/dist/usersSlice/mocks.d.ts +83 -0
  325. package/dist/usersSlice/mocks.js +47 -0
  326. package/dist/usersSlice/mocks.js.map +1 -0
  327. package/dist/usersSlice/selectors.cjs +319 -566
  328. package/dist/usersSlice/selectors.cjs.map +1 -1
  329. package/dist/usersSlice/selectors.d.cts +1651 -59
  330. package/dist/usersSlice/selectors.d.ts +1651 -59
  331. package/dist/usersSlice/selectors.js +13 -9
  332. package/dist/usersSlice/thunks.cjs +1666 -1893
  333. package/dist/usersSlice/thunks.cjs.map +1 -1
  334. package/dist/usersSlice/thunks.d.cts +362 -312
  335. package/dist/usersSlice/thunks.d.ts +362 -312
  336. package/dist/usersSlice/thunks.js +30 -29
  337. package/dist/utils.cjs +428 -292
  338. package/dist/utils.cjs.map +1 -1
  339. package/dist/utils.d.cts +44 -22
  340. package/dist/utils.d.ts +44 -22
  341. package/dist/utils.js +12 -6
  342. package/package.json +18 -8
  343. package/dist/api/types/AWSCredentials.ts +0 -16
  344. package/dist/api/types/Actor.ts +0 -35
  345. package/dist/api/types/Addon.ts +0 -17
  346. package/dist/api/types/AddonTenantadm.ts +0 -17
  347. package/dist/api/types/Address.ts +0 -6
  348. package/dist/api/types/AddressUpdate.ts +0 -12
  349. package/dist/api/types/Alert.ts +0 -34
  350. package/dist/api/types/AlertDetails.ts +0 -23
  351. package/dist/api/types/AlertSubject.ts +0 -23
  352. package/dist/api/types/ApiBurst.ts +0 -21
  353. package/dist/api/types/ApiBurstTenantadm.ts +0 -21
  354. package/dist/api/types/ApiLimits.ts +0 -16
  355. package/dist/api/types/ApiLimitsTenantadm.ts +0 -16
  356. package/dist/api/types/ApiQuota.ts +0 -17
  357. package/dist/api/types/ApiQuotaTenantadm.ts +0 -17
  358. package/dist/api/types/Artifact.ts +0 -48
  359. package/dist/api/types/ArtifactDeployments.ts +0 -48
  360. package/dist/api/types/ArtifactInfo.ts +0 -11
  361. package/dist/api/types/ArtifactInfoDeployments.ts +0 -11
  362. package/dist/api/types/ArtifactLink.ts +0 -11
  363. package/dist/api/types/ArtifactTypeInfo.ts +0 -13
  364. package/dist/api/types/ArtifactTypeInfoDeployments.ts +0 -13
  365. package/dist/api/types/ArtifactUpdate.ts +0 -10
  366. package/dist/api/types/ArtifactUploadLink.ts +0 -15
  367. package/dist/api/types/Attribute.ts +0 -36
  368. package/dist/api/types/AttributeInventory.ts +0 -32
  369. package/dist/api/types/AuditLog.ts +0 -26
  370. package/dist/api/types/AuthSet.ts +0 -37
  371. package/dist/api/types/AuthSetDeviceauth.ts +0 -37
  372. package/dist/api/types/AuthSetIot_manager.ts +0 -33
  373. package/dist/api/types/AutoAuthRequest.ts +0 -23
  374. package/dist/api/types/AzureSharedAccessSecret.ts +0 -11
  375. package/dist/api/types/BillingInfo.ts +0 -13
  376. package/dist/api/types/BillingProfile.ts +0 -37
  377. package/dist/api/types/BillingProfileUpdate.ts +0 -37
  378. package/dist/api/types/BinaryDeltaConfiguration.ts +0 -15
  379. package/dist/api/types/BinaryDeltaConfigurationDeployments.ts +0 -15
  380. package/dist/api/types/BinaryDeltaLimits.ts +0 -21
  381. package/dist/api/types/BinaryDeltaLimitsDeployments.ts +0 -15
  382. package/dist/api/types/BoundingBox.ts +0 -9
  383. package/dist/api/types/CancelRequest.ts +0 -10
  384. package/dist/api/types/CardData.ts +0 -49
  385. package/dist/api/types/CardSetupData.ts +0 -17
  386. package/dist/api/types/CheckoutData.ts +0 -13
  387. package/dist/api/types/Configuration.ts +0 -11
  388. package/dist/api/types/Count.ts +0 -13
  389. package/dist/api/types/Credentials.ts +0 -23
  390. package/dist/api/types/DBusSubsystem.ts +0 -27
  391. package/dist/api/types/DeltaConfiguration.ts +0 -14
  392. package/dist/api/types/DeltaConfigurationDeployments.ts +0 -14
  393. package/dist/api/types/Deployment.ts +0 -45
  394. package/dist/api/types/DeploymentAggregation.ts +0 -16
  395. package/dist/api/types/DeploymentAggregationItem.ts +0 -16
  396. package/dist/api/types/DeploymentAggregationTerm.ts +0 -22
  397. package/dist/api/types/DeploymentAggregationTerms.ts +0 -16
  398. package/dist/api/types/DeploymentAttributeProjection.ts +0 -10
  399. package/dist/api/types/DeploymentAuditlogs.ts +0 -11
  400. package/dist/api/types/DeploymentDeployments.ts +0 -98
  401. package/dist/api/types/DeploymentFilterTerm.ts +0 -35
  402. package/dist/api/types/DeploymentIdentifier.ts +0 -10
  403. package/dist/api/types/DeploymentPhase.ts +0 -23
  404. package/dist/api/types/DeploymentPhaseDeployments.ts +0 -23
  405. package/dist/api/types/DeploymentReporting.ts +0 -46
  406. package/dist/api/types/DeploymentSearchTerms.ts +0 -37
  407. package/dist/api/types/DeploymentSortTerm.ts +0 -23
  408. package/dist/api/types/DeploymentStatistics.ts +0 -15
  409. package/dist/api/types/DeploymentStatisticsDeployments.ts +0 -15
  410. package/dist/api/types/DeploymentStatusStatistics.ts +0 -54
  411. package/dist/api/types/DeploymentStatusStatisticsDeployments.ts +0 -54
  412. package/dist/api/types/Device.ts +0 -20
  413. package/dist/api/types/DeviceAggregation.ts +0 -16
  414. package/dist/api/types/DeviceAggregationItem.ts +0 -16
  415. package/dist/api/types/DeviceAggregationTerm.ts +0 -26
  416. package/dist/api/types/DeviceAggregationTerms.ts +0 -20
  417. package/dist/api/types/DeviceAttribute.ts +0 -22
  418. package/dist/api/types/DeviceAttributeProjection.ts +0 -14
  419. package/dist/api/types/DeviceAuditlogs.ts +0 -17
  420. package/dist/api/types/DeviceAuthEvent.ts +0 -23
  421. package/dist/api/types/DeviceConfiguration.ts +0 -16
  422. package/dist/api/types/DeviceDeployment.ts +0 -11
  423. package/dist/api/types/DeviceDeployments.ts +0 -29
  424. package/dist/api/types/DeviceDeviceauth.ts +0 -42
  425. package/dist/api/types/DeviceFilterAttribute.ts +0 -21
  426. package/dist/api/types/DeviceFilterTerm.ts +0 -39
  427. package/dist/api/types/DeviceInventory.ts +0 -19
  428. package/dist/api/types/DeviceInventoryInventory.ts +0 -19
  429. package/dist/api/types/DeviceReporting.ts +0 -22
  430. package/dist/api/types/DeviceSearchTerms.ts +0 -37
  431. package/dist/api/types/DeviceSortTerm.ts +0 -27
  432. package/dist/api/types/DeviceState.ts +0 -32
  433. package/dist/api/types/DeviceStateDeviceconnect.ts +0 -33
  434. package/dist/api/types/DeviceStateIot_manager.ts +0 -14
  435. package/dist/api/types/DeviceStatus.ts +0 -19
  436. package/dist/api/types/DeviceWithImage.ts +0 -80
  437. package/dist/api/types/DirectUploadMetadata.ts +0 -18
  438. package/dist/api/types/EmailVerificationCompletion.ts +0 -13
  439. package/dist/api/types/EmailVerificationRequest.ts +0 -13
  440. package/dist/api/types/Error.ts +0 -17
  441. package/dist/api/types/ErrorAuditlogs.ts +0 -13
  442. package/dist/api/types/ErrorDeployments.ts +0 -17
  443. package/dist/api/types/ErrorDeviceauth.ts +0 -13
  444. package/dist/api/types/ErrorDeviceconfig.ts +0 -17
  445. package/dist/api/types/ErrorDeviceconnect.ts +0 -17
  446. package/dist/api/types/ErrorDevicemonitor.ts +0 -17
  447. package/dist/api/types/ErrorExt.ts +0 -18
  448. package/dist/api/types/ErrorInventory.ts +0 -17
  449. package/dist/api/types/ErrorIot_manager.ts +0 -17
  450. package/dist/api/types/ErrorNotFound.ts +0 -17
  451. package/dist/api/types/ErrorReporting.ts +0 -18
  452. package/dist/api/types/ErrorTenantadm.ts +0 -13
  453. package/dist/api/types/ErrorUseradm.ts +0 -17
  454. package/dist/api/types/Event.ts +0 -48
  455. package/dist/api/types/ExternalIdentity.ts +0 -17
  456. package/dist/api/types/Features.ts +0 -17
  457. package/dist/api/types/FileUpload.ts +0 -23
  458. package/dist/api/types/Filter.ts +0 -19
  459. package/dist/api/types/FilterAttribute.ts +0 -21
  460. package/dist/api/types/FilterDefinition.ts +0 -18
  461. package/dist/api/types/FilterDeployments.ts +0 -19
  462. package/dist/api/types/FilterInventory.ts +0 -19
  463. package/dist/api/types/FilterPredicate.ts +0 -48
  464. package/dist/api/types/FilterPredicateDeployments.ts +0 -48
  465. package/dist/api/types/FilterPredicateInventory.ts +0 -78
  466. package/dist/api/types/GeoBoundingBox.ts +0 -8
  467. package/dist/api/types/GeoBoundingBoxFilter.ts +0 -5
  468. package/dist/api/types/GeoDistance.ts +0 -15
  469. package/dist/api/types/GeoDistanceFilter.ts +0 -8
  470. package/dist/api/types/GeoPoint.ts +0 -14
  471. package/dist/api/types/Group.ts +0 -10
  472. package/dist/api/types/HTTP.ts +0 -19
  473. package/dist/api/types/IdentityData.ts +0 -25
  474. package/dist/api/types/InputParameter.ts +0 -8
  475. package/dist/api/types/Integration.ts +0 -30
  476. package/dist/api/types/JobStatus.ts +0 -13
  477. package/dist/api/types/Limit.ts +0 -21
  478. package/dist/api/types/LimitDeployments.ts +0 -21
  479. package/dist/api/types/LimitDeviceauth.ts +0 -10
  480. package/dist/api/types/LimitUseradm.ts +0 -11
  481. package/dist/api/types/Limits.ts +0 -11
  482. package/dist/api/types/LineDescriptor.ts +0 -11
  483. package/dist/api/types/LogSubsystem.ts +0 -23
  484. package/dist/api/types/LoginOptions.ts +0 -18
  485. package/dist/api/types/ManagementAPIConfiguration.ts +0 -5
  486. package/dist/api/types/MenderTypes.ts +0 -213
  487. package/dist/api/types/MonitorConfiguration.ts +0 -22
  488. package/dist/api/types/NewConfigurationDeployment.ts +0 -15
  489. package/dist/api/types/NewConfigurationDeploymentResponse.ts +0 -10
  490. package/dist/api/types/NewDeployment.ts +0 -42
  491. package/dist/api/types/NewDeploymentForGroup.ts +0 -33
  492. package/dist/api/types/NewDeploymentPhase.ts +0 -37
  493. package/dist/api/types/NewDeploymentPhaseDeployments.ts +0 -20
  494. package/dist/api/types/NewDeploymentV2.ts +0 -34
  495. package/dist/api/types/NewTenant.ts +0 -49
  496. package/dist/api/types/Object.ts +0 -38
  497. package/dist/api/types/OwnUserUpdate.ts +0 -21
  498. package/dist/api/types/PasswordResetCompletion.ts +0 -17
  499. package/dist/api/types/PasswordResetRequest.ts +0 -13
  500. package/dist/api/types/Permission.ts +0 -21
  501. package/dist/api/types/PermissionObject.ts +0 -14
  502. package/dist/api/types/PermissionSet.ts +0 -22
  503. package/dist/api/types/PermissionSetWithScope.ts +0 -15
  504. package/dist/api/types/PersonalAccessToken.ts +0 -29
  505. package/dist/api/types/PersonalAccessTokenRequest.ts +0 -18
  506. package/dist/api/types/Plan.ts +0 -19
  507. package/dist/api/types/PlanBindingDetails.ts +0 -13
  508. package/dist/api/types/PlanChangeRequest.ts +0 -14
  509. package/dist/api/types/PlanLimits.ts +0 -12
  510. package/dist/api/types/PreAuthSet.ts +0 -16
  511. package/dist/api/types/Release.ts +0 -32
  512. package/dist/api/types/ReleaseDeployments.ts +0 -32
  513. package/dist/api/types/ReleaseUpdate.ts +0 -13
  514. package/dist/api/types/Releases.ts +0 -9
  515. package/dist/api/types/ReleasesDeleteError.ts +0 -21
  516. package/dist/api/types/ReleasesDeployments.ts +0 -9
  517. package/dist/api/types/Role.ts +0 -19
  518. package/dist/api/types/RolePermission.ts +0 -25
  519. package/dist/api/types/RolePermissionObject.ts +0 -17
  520. package/dist/api/types/RoleUseradm.ts +0 -19
  521. package/dist/api/types/SAMLMetadata.ts +0 -21
  522. package/dist/api/types/Scope.ts +0 -19
  523. package/dist/api/types/SelectAttribute.ts +0 -17
  524. package/dist/api/types/ServiceSubsystem.ts +0 -19
  525. package/dist/api/types/Settings.ts +0 -23
  526. package/dist/api/types/SortCriteria.ts +0 -30
  527. package/dist/api/types/SsoObject.ts +0 -21
  528. package/dist/api/types/Status.ts +0 -18
  529. package/dist/api/types/StatusDeviceauth.ts +0 -18
  530. package/dist/api/types/StatusTenantadm.ts +0 -17
  531. package/dist/api/types/StorageLimit.ts +0 -17
  532. package/dist/api/types/SubscriptionData.ts +0 -8
  533. package/dist/api/types/SupportRequest.ts +0 -17
  534. package/dist/api/types/Tag.ts +0 -27
  535. package/dist/api/types/Tags.ts +0 -10
  536. package/dist/api/types/TaskResult.ts +0 -13
  537. package/dist/api/types/TaskResultCLI.ts +0 -10
  538. package/dist/api/types/TaskResultHTTPRequest.ts +0 -8
  539. package/dist/api/types/TaskResultHTTPResponse.ts +0 -10
  540. package/dist/api/types/Tenant.ts +0 -26
  541. package/dist/api/types/TenantApiLimits.ts +0 -12
  542. package/dist/api/types/TenantApiLimitsTenantadm.ts +0 -12
  543. package/dist/api/types/TenantIdName.ts +0 -14
  544. package/dist/api/types/TenantIdsData.ts +0 -10
  545. package/dist/api/types/TenantInfo.ts +0 -14
  546. package/dist/api/types/TenantShortInfo.ts +0 -21
  547. package/dist/api/types/TenantTenantadm.ts +0 -54
  548. package/dist/api/types/TenantsIdName.ts +0 -6
  549. package/dist/api/types/Update.ts +0 -17
  550. package/dist/api/types/UpdateChildTenant.ts +0 -17
  551. package/dist/api/types/UpdateDeployments.ts +0 -18
  552. package/dist/api/types/UpdateFile.ts +0 -13
  553. package/dist/api/types/UpdateFileDeployments.ts +0 -13
  554. package/dist/api/types/UpdateTypes.ts +0 -8
  555. package/dist/api/types/UpgradeCompleteRequest.ts +0 -25
  556. package/dist/api/types/User.ts +0 -13
  557. package/dist/api/types/UserAuditlogs.ts +0 -13
  558. package/dist/api/types/UserNew.ts +0 -26
  559. package/dist/api/types/UserUpdate.ts +0 -25
  560. package/dist/api/types/UserUseradm.ts +0 -45
  561. package/dist/api/types/UserWithTenantInfo.ts +0 -12
  562. package/dist/api/types/XDeltaArgs.ts +0 -9
  563. package/dist/api/types/XDeltaArgsDeployments.ts +0 -9
  564. package/dist/api/types/XDeltaArgsLimits.ts +0 -10
  565. package/dist/api/types/XDeltaArgsLimitsDeployments.ts +0 -10
  566. package/dist/chunk-2CYOM4BK.js.map +0 -1
  567. package/dist/chunk-2JHFUQ6B.js.map +0 -1
  568. package/dist/chunk-4B3IMP4I.js +0 -245
  569. package/dist/chunk-4B3IMP4I.js.map +0 -1
  570. package/dist/chunk-4XJMRVFI.js.map +0 -1
  571. package/dist/chunk-7JKWI5FK.js.map +0 -1
  572. package/dist/chunk-7PVGDMNM.js.map +0 -1
  573. package/dist/chunk-AMGWP7A4.js.map +0 -1
  574. package/dist/chunk-C5NEDBJI.js +0 -727
  575. package/dist/chunk-C5NEDBJI.js.map +0 -1
  576. package/dist/chunk-CYV6632F.js.map +0 -1
  577. package/dist/chunk-DCK2DBOA.js.map +0 -1
  578. package/dist/chunk-FGKMJS3B.js.map +0 -1
  579. package/dist/chunk-HPBE6KYY.js.map +0 -1
  580. package/dist/chunk-JAROCU6M.js.map +0 -1
  581. package/dist/chunk-LEMVXAYP.js.map +0 -1
  582. package/dist/chunk-LGNOTPUG.js +0 -106
  583. package/dist/chunk-LGNOTPUG.js.map +0 -1
  584. package/dist/chunk-LIJIIRON.js +0 -28
  585. package/dist/chunk-LIJIIRON.js.map +0 -1
  586. package/dist/chunk-LTKOV26W.js.map +0 -1
  587. package/dist/chunk-MRCFLG45.js.map +0 -1
  588. package/dist/chunk-QRGTG4YB.js.map +0 -1
  589. package/dist/chunk-TI2RL5P2.js.map +0 -1
  590. package/dist/chunk-TUACATJA.js.map +0 -1
  591. package/dist/chunk-UWMYZNUB.js.map +0 -1
  592. package/dist/chunk-VMNMD6KF.js.map +0 -1
  593. package/dist/chunk-WXL7PVI5.js.map +0 -1
  594. package/dist/chunk-X7IEZBM4.js.map +0 -1
  595. package/dist/chunk-YDS36ALB.js.map +0 -1
  596. package/dist/chunk-YT73QWCN.js.map +0 -1
  597. package/dist/deploymentdevicehook.cjs.map +0 -1
  598. package/dist/deploymentdevicehook.js +0 -62
  599. package/dist/deploymentdevicehook.js.map +0 -1
  600. /package/dist/{chunk-DAPAXWA5.js.map → chunk-URNS6A5T.js.map} +0 -0
  601. /package/dist/{deploymentdevicehook.d.cts → useDeploymentDevice.d.cts} +0 -0
  602. /package/dist/{deploymentdevicehook.d.ts → useDeploymentDevice.d.ts} +0 -0
@@ -1,20 +1,58 @@
1
1
  import {
2
2
  getDeviceMonitorConfig,
3
3
  getLatestDeviceAlerts
4
- } from "./chunk-LGNOTPUG.js";
4
+ } from "./chunk-JUGE7L3K.js";
5
+ import {
6
+ commonErrorFallback,
7
+ commonErrorHandler,
8
+ createAppAsyncThunk
9
+ } from "./chunk-CW5T6OGF.js";
5
10
  import {
6
11
  users_api_default
7
- } from "./chunk-JAROCU6M.js";
12
+ } from "./chunk-QHK7GGV4.js";
8
13
  import {
9
14
  general_api_default
10
- } from "./chunk-YT73QWCN.js";
15
+ } from "./chunk-RS37Y2PQ.js";
16
+ import {
17
+ actions_default
18
+ } from "./chunk-URNS6A5T.js";
19
+ import {
20
+ actions as actions6,
21
+ sliceName as sliceName6
22
+ } from "./chunk-UGSLGUS6.js";
23
+ import {
24
+ actions as actions5,
25
+ sliceName as sliceName5
26
+ } from "./chunk-MZNANSS2.js";
27
+ import {
28
+ actions as actions4,
29
+ sliceName as sliceName4
30
+ } from "./chunk-VANBSJS5.js";
31
+ import {
32
+ actions as actions2,
33
+ sliceName as sliceName2
34
+ } from "./chunk-VUFRP6P3.js";
35
+ import {
36
+ actions,
37
+ sliceName
38
+ } from "./chunk-6KGTHJKC.js";
39
+ import {
40
+ actions as actions3,
41
+ sliceName as sliceName3
42
+ } from "./chunk-ABJLRDCO.js";
43
+ import {
44
+ cleanUp,
45
+ getSessionInfo,
46
+ setSessionInfo
47
+ } from "./chunk-ZJW3QIPM.js";
11
48
  import {
12
49
  getAttrsEndpoint,
50
+ getDeviceReportsForUser,
13
51
  getOnboardingState,
14
52
  getSearchEndpoint,
15
53
  getTenantCapabilities,
16
54
  getUserCapabilities
17
- } from "./chunk-DCK2DBOA.js";
55
+ } from "./chunk-IQG5I7AM.js";
18
56
  import {
19
57
  getCurrentSession,
20
58
  getCurrentUser,
@@ -26,90 +64,66 @@ import {
26
64
  getTooltipsState,
27
65
  getUserSettings,
28
66
  getUsersById
29
- } from "./chunk-WXL7PVI5.js";
67
+ } from "./chunk-ZRSYBSSY.js";
30
68
  import {
31
69
  getAuditlogState,
32
70
  getDeviceTwinIntegrations,
33
71
  getOrganization,
34
72
  getTenantsList
35
- } from "./chunk-2CYOM4BK.js";
73
+ } from "./chunk-4TUJPE6G.js";
36
74
  import {
37
75
  getDeploymentsById,
38
76
  getDeploymentsByStatus
39
- } from "./chunk-7JKWI5FK.js";
77
+ } from "./chunk-JXQUFKID.js";
40
78
  import {
79
+ getAcceptedDevices,
41
80
  getDeviceById,
42
81
  getDeviceFilters,
43
82
  getDeviceListState,
83
+ getDeviceReports,
44
84
  getDevicesById,
45
- getGroups,
46
85
  getGroupsById,
47
86
  getSelectedGroup
48
- } from "./chunk-YDS36ALB.js";
87
+ } from "./chunk-KJNNEDRV.js";
88
+ import {
89
+ getFeatures,
90
+ getSearchState
91
+ } from "./chunk-MBKAZVE3.js";
49
92
  import {
50
93
  convertDeviceListStateToFilters,
94
+ extractErrorMessage,
51
95
  filtersFilter,
52
96
  getComparisonCompatibleVersion,
53
97
  mapDeviceAttributes,
54
98
  mapFiltersToTerms,
55
99
  mapTermsToFilters,
56
100
  mergePermissions,
101
+ parseSubscriptionPreview,
57
102
  progress
58
- } from "./chunk-4XJMRVFI.js";
59
- import {
60
- getFeatures,
61
- getSearchState
62
- } from "./chunk-LIJIIRON.js";
63
- import {
64
- commonErrorFallback,
65
- commonErrorHandler
66
- } from "./chunk-LEMVXAYP.js";
67
- import {
68
- actions_default
69
- } from "./chunk-DAPAXWA5.js";
70
- import {
71
- actions as actions6,
72
- sliceName as sliceName6
73
- } from "./chunk-TUACATJA.js";
74
- import {
75
- actions as actions5,
76
- sliceName as sliceName5
77
- } from "./chunk-TI2RL5P2.js";
78
- import {
79
- actions as actions2,
80
- sliceName as sliceName2
81
- } from "./chunk-HPBE6KYY.js";
82
- import {
83
- actions as actions4,
84
- sliceName as sliceName4
85
- } from "./chunk-FGKMJS3B.js";
86
- import {
87
- actions as actions3,
88
- sliceName as sliceName3
89
- } from "./chunk-QRGTG4YB.js";
90
- import {
91
- actions,
92
- sliceName
93
- } from "./chunk-7PVGDMNM.js";
94
- import {
95
- cleanUp,
96
- getSessionInfo,
97
- maxSessionAge,
98
- setSessionInfo
99
- } from "./chunk-AMGWP7A4.js";
103
+ } from "./chunk-XWYJACQC.js";
100
104
  import {
101
105
  ALL_DEVICE_STATES,
106
+ ALL_RELEASES,
107
+ APPLICATION_JSON_CONTENT_TYPE,
108
+ APPLICATION_JWT_CONTENT_TYPE,
102
109
  DEPLOYMENT_ROUTES,
103
110
  DEPLOYMENT_STATES,
104
111
  DEPLOYMENT_TYPES,
112
+ DEVICE_FILTERING_OPTIONS,
113
+ DEVICE_LIST_DEFAULTS,
105
114
  DEVICE_STATES,
115
+ EXTERNAL_PROVIDER,
116
+ MAX_PAGE_SIZE,
106
117
  OWN_USER_ID,
107
118
  PermissionTypes,
108
119
  READ_STATES,
109
- REPORT_CHART_SIZE_LIMIT,
120
+ SORTING_OPTIONS,
110
121
  SSO_TYPES,
111
122
  TENANT_LIST_DEFAULT,
123
+ TIMEOUTS,
124
+ UNGROUPED_GROUP,
112
125
  USER_LOGOUT,
126
+ apiRoot,
113
127
  auditLogsApiUrl,
114
128
  defaultPermissionSets,
115
129
  deploymentPrototype,
@@ -119,12 +133,14 @@ import {
119
133
  deviceConfig,
120
134
  deviceConnect,
121
135
  emptyFilter,
122
- geoAttributes,
136
+ emptyRole,
137
+ emptyUiPermissions,
138
+ headerNames,
123
139
  inventoryApiUrl,
124
140
  inventoryApiUrlV2,
125
141
  iotManagerBaseURL,
126
142
  itemUiPermissionsReducer,
127
- reportingApiUrl,
143
+ maxSessionAge,
128
144
  rolesById,
129
145
  scopedPermissionAreas,
130
146
  settingsKeys,
@@ -134,53 +150,40 @@ import {
134
150
  twoFAStates,
135
151
  uiPermissionsByArea,
136
152
  uiPermissionsById,
137
- useradmApiUrlv1,
153
+ useradmApiUrl,
138
154
  useradmApiUrlv2
139
- } from "./chunk-C5NEDBJI.js";
155
+ } from "./chunk-7C4SQBEE.js";
140
156
  import {
141
157
  rootfsImageVersion
142
- } from "./chunk-CK6YE6AN.js";
158
+ } from "./chunk-2DYA3X77.js";
143
159
  import {
144
- onboardingSteps
145
- } from "./chunk-MRCFLG45.js";
160
+ onboardingSteps,
161
+ orderedOnboardingSteps
162
+ } from "./chunk-FAJ3I2UQ.js";
146
163
  import {
147
- APPLICATION_JSON_CONTENT_TYPE,
148
- APPLICATION_JWT_CONTENT_TYPE,
149
- apiRoot,
150
- defaultReports,
151
- headerNames,
164
+ PLANS,
152
165
  locations
153
- } from "./chunk-UWMYZNUB.js";
154
- import {
155
- ALL_DEVICES,
156
- ALL_RELEASES,
157
- DEVICE_FILTERING_OPTIONS,
158
- DEVICE_LIST_DEFAULTS,
159
- EXTERNAL_PROVIDER,
160
- MAX_PAGE_SIZE,
161
- SORTING_OPTIONS,
162
- TIMEOUTS,
163
- UNGROUPED_GROUP,
164
- emptyRole,
165
- emptyUiPermissions
166
- } from "./chunk-4B3IMP4I.js";
166
+ } from "./chunk-OHF3YUXX.js";
167
+
168
+ // src/appSlice/thunks.ts
169
+ import { deepCompare as deepCompare4, extractErrorMessage as extractErrorMessage3 } from "@northern.tech/utils/helpers";
170
+ import Cookies4 from "universal-cookie";
167
171
 
168
172
  // src/deploymentsSlice/thunks.ts
169
- import { deepCompare, isEmpty, standardizePhases, startTimeSort } from "@northern.tech/utils/helpers";
173
+ import { customSort, deepCompare, isEmpty, standardizePhases } from "@northern.tech/utils/helpers";
170
174
  import Tracking from "@northern.tech/utils/tracking";
171
- import { createAsyncThunk } from "@reduxjs/toolkit";
172
- import { isUUID } from "validator";
175
+ import isUUID from "validator/lib/isUUID";
173
176
  var { receivedDevice, setSnackbar } = actions_default;
174
177
  var { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
175
- var deriveDeploymentGroup = ({ filter = {}, group, groups = [], name }) => group || groups.length === 1 && !isUUID(name) ? groups[0] : filter.name;
176
- var transformDeployments = (deployments, deploymentsById) => deployments.sort(startTimeSort).reduce(
178
+ var deriveDeploymentGroup = ({ filter, group, groups = [], name }) => group || groups.length === 1 && !isUUID(name) ? groups[0] : filter?.name;
179
+ var transformDeployments = (deployments, deploymentsById) => deployments.sort(customSort(true, "created")).reduce(
177
180
  (accu, item) => {
178
- const filter = item.filter ?? {};
181
+ const filter = item.filter;
179
182
  let deployment = {
180
183
  ...deploymentPrototype,
181
184
  ...deploymentsById[item.id],
182
185
  ...item,
183
- filter: item.filter ? { ...filter, name: filter.name ?? filter.id, filters: mapTermsToFilters(filter.terms) } : void 0,
186
+ filter: filter ? { ...filter, name: filter.name ?? filter.id, filters: mapTermsToFilters(filter.terms) } : void 0,
184
187
  name: decodeURIComponent(item.name)
185
188
  };
186
189
  deployment = { ...deployment, group: deriveDeploymentGroup(deployment) };
@@ -190,40 +193,43 @@ var transformDeployments = (deployments, deploymentsById) => deployments.sort(st
190
193
  },
191
194
  { deployments: {}, deploymentIds: [] }
192
195
  );
193
- var getDeploymentsByStatus2 = createAsyncThunk(`${sliceName2}/getDeploymentsByStatus`, (options = {}, { dispatch, getState }) => {
194
- const { status, page = defaultPage, per_page = defaultPerPage, startDate, endDate, group, type, shouldSelect = true, sort = SORTING_OPTIONS.desc } = options;
195
- const created_after = startDate ? `&created_after=${startDate}` : "";
196
- const created_before = endDate ? `&created_before=${endDate}` : "";
197
- const search = group ? `&search=${group}` : "";
198
- const typeFilter = type ? `&type=${type}` : "";
199
- return general_api_default.get(
200
- `${deploymentsApiUrl}/deployments?status=${status}&per_page=${per_page}&page=${page}${created_after}${created_before}${search}${typeFilter}&sort=${sort}`
201
- ).then((res) => {
202
- const { deployments, deploymentIds } = transformDeployments(res.data, getState().deployments.byId);
203
- const total = Number(res.headers[headerNames.total]);
204
- let tasks = [
205
- dispatch(actions2.receivedDeployments(deployments)),
206
- dispatch(
207
- actions2.receivedDeploymentsForStatus({
208
- deploymentIds,
209
- status,
210
- total: !(startDate || endDate || group || type) ? total : getState().deployments.byStatus[status].total
211
- })
212
- )
213
- ];
214
- tasks = deploymentIds.reduce((accu, deploymentId) => {
215
- if (deployments[deploymentId].type === DEPLOYMENT_TYPES.configuration) {
216
- accu.push(dispatch(getSingleDeployment(deploymentId)));
196
+ var getDeploymentsByStatus2 = createAppAsyncThunk(
197
+ `${sliceName2}/getDeploymentsByStatus`,
198
+ (options, { dispatch, getState }) => {
199
+ const { status, page = defaultPage, perPage = defaultPerPage, startDate, endDate, group, type, shouldSelect = true, sort = SORTING_OPTIONS.desc } = options;
200
+ const created_after = startDate ? `&created_after=${startDate}` : "";
201
+ const created_before = endDate ? `&created_before=${endDate}` : "";
202
+ const search = group ? `&search=${group}` : "";
203
+ const typeFilter = type ? `&type=${type}` : "";
204
+ return general_api_default.get(
205
+ `${deploymentsApiUrl}/deployments?status=${status}&per_page=${perPage}&page=${page}${created_after}${created_before}${search}${typeFilter}&sort=${sort}`
206
+ ).then((res) => {
207
+ const { deployments, deploymentIds } = transformDeployments(res.data, getState().deployments.byId);
208
+ const total = Number(res.headers[headerNames.total]);
209
+ let tasks = [
210
+ dispatch(actions2.receivedDeployments(deployments)),
211
+ dispatch(
212
+ actions2.receivedDeploymentsForStatus({
213
+ deploymentIds,
214
+ status,
215
+ total: !(startDate || endDate || group || type) ? total : getState().deployments.byStatus[status].total
216
+ })
217
+ )
218
+ ];
219
+ tasks = deploymentIds.reduce((accu, deploymentId) => {
220
+ if (deployments[deploymentId].type === DEPLOYMENT_TYPES.configuration) {
221
+ accu.push(dispatch(getSingleDeployment(deploymentId)));
222
+ }
223
+ return accu;
224
+ }, tasks);
225
+ if (shouldSelect) {
226
+ tasks.push(dispatch(actions2.selectDeploymentsForStatus({ deploymentIds, status, total })));
217
227
  }
218
- return accu;
219
- }, tasks);
220
- if (shouldSelect) {
221
- tasks.push(dispatch(actions2.selectDeploymentsForStatus({ deploymentIds, status, total })));
222
- }
223
- tasks.push({ deploymentIds, total });
224
- return Promise.all(tasks);
225
- });
226
- });
228
+ tasks.push({ deploymentIds, total });
229
+ return Promise.all(tasks);
230
+ });
231
+ }
232
+ );
227
233
  var isWithinFirstMonth = (expirationDate) => {
228
234
  if (!expirationDate) {
229
235
  return false;
@@ -245,86 +251,98 @@ var trackDeploymentCreation = (totalDeploymentCount, hasDeployments, trial_expir
245
251
  }
246
252
  };
247
253
  var MAX_PREVIOUS_PHASES_COUNT = 5;
248
- var createDeployment = createAsyncThunk(`${sliceName2}/createDeployment`, ({ newDeployment, hasNewRetryDefault = false }, { dispatch, getState }) => {
249
- let request;
250
- if (newDeployment.filter_id) {
251
- request = general_api_default.post(`${deploymentsApiUrlV2}/deployments`, newDeployment);
252
- } else if (newDeployment.group) {
253
- request = general_api_default.post(`${deploymentsApiUrl}/deployments/group/${newDeployment.group}`, newDeployment);
254
- } else {
255
- request = general_api_default.post(`${deploymentsApiUrl}/deployments`, newDeployment);
256
- }
257
- const totalDeploymentCount = Object.values(getDeploymentsByStatus(getState())).reduce((accu, item) => accu + item.total, 0);
258
- const { hasDeployments } = getGlobalSettings(getState());
259
- const { trial_expiration } = getOrganization(getState());
260
- return request.catch((err) => commonErrorHandler(err, "Error creating deployment.", dispatch)).then((data) => {
261
- const lastslashindex = data.headers.location.lastIndexOf("/");
262
- const deploymentId = data.headers.location.substring(lastslashindex + 1);
263
- const deployment = {
264
- ...newDeployment,
265
- id: deploymentId,
266
- devices: newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
267
- statistics: { status: {} }
268
- };
269
- let tasks = [
270
- dispatch(actions2.createdDeployment(deployment)),
271
- dispatch(getSingleDeployment(deploymentId)),
272
- dispatch(setSnackbar("Deployment created successfully", TIMEOUTS.fiveSeconds))
273
- ];
274
- trackDeploymentCreation(totalDeploymentCount, hasDeployments, trial_expiration);
275
- const { canManageUsers } = getUserCapabilities(getState());
276
- if (canManageUsers) {
277
- const { phases, retries } = newDeployment;
278
- const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
279
- let newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
280
- if (phases) {
281
- const standardPhases = standardizePhases(phases);
282
- let prevPhases = previousPhases.map(standardizePhases);
283
- if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => deepCompare(phase, oldPhase))))) {
284
- prevPhases.push(standardPhases);
285
- }
286
- newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
287
- }
288
- tasks.push(dispatch(saveGlobalSettings(newSettings)));
254
+ var createDeployment = createAppAsyncThunk(
255
+ `${sliceName2}/createDeployment`,
256
+ ({
257
+ newDeployment,
258
+ hasNewRetryDefault = false
259
+ }, { dispatch, getState }) => {
260
+ let request;
261
+ if ("filter_id" in newDeployment && newDeployment.filter_id) {
262
+ request = general_api_default.post(`${deploymentsApiUrlV2}/deployments`, newDeployment);
263
+ } else if ("group" in newDeployment && newDeployment.group) {
264
+ request = general_api_default.post(`${deploymentsApiUrl}/deployments/group/${newDeployment.group}`, newDeployment);
265
+ } else {
266
+ request = general_api_default.post(`${deploymentsApiUrl}/deployments`, newDeployment);
289
267
  }
290
- return Promise.all(tasks);
291
- });
292
- });
293
- var getDeploymentDevices = createAsyncThunk(`${sliceName2}/getDeploymentDevices`, (options, { dispatch, getState }) => {
294
- const { id, page = defaultPage, perPage = defaultPerPage } = options;
295
- return general_api_default.get(`${deploymentsApiUrl}/deployments/${id}/devices/list?&page=${page}&per_page=${perPage}`).then((response) => {
296
- const { devices: deploymentDevices = {} } = getState().deployments.byId[id] || {};
297
- const devices = response.data.reduce((accu, item) => {
298
- accu[item.id] = item;
299
- const log = (deploymentDevices[item.id] || {}).log;
300
- if (log) {
301
- accu[item.id].log = log;
302
- }
303
- return accu;
304
- }, {});
305
- const selectedDeviceIds = Object.keys(devices);
306
- let tasks = [
307
- dispatch(
308
- actions2.receivedDeploymentDevices({
309
- id,
310
- devices,
311
- selectedDeviceIds,
312
- totalDeviceCount: Number(response.headers[headerNames.total])
313
- })
314
- )
315
- ];
316
- const devicesById = getDevicesById(getState());
317
- const lackingData = selectedDeviceIds.reduce((accu, deviceId) => {
318
- const device = devicesById[deviceId];
319
- if (!device || !device.identity_data || !device.attributes || Object.keys(device.attributes).length === 0) {
320
- accu.push(deviceId);
268
+ const totalDeploymentCount = Object.values(getDeploymentsByStatus(getState())).reduce(
269
+ (accu, item) => accu + item.total,
270
+ 0
271
+ );
272
+ const { hasDeployments } = getGlobalSettings(getState());
273
+ const { trial_expiration } = getOrganization(getState());
274
+ return request.catch((err) => commonErrorHandler(err, "Error creating deployment.", dispatch)).then((data) => {
275
+ const lastslashindex = data.headers.location.lastIndexOf("/");
276
+ const deploymentId = data.headers.location.substring(lastslashindex + 1);
277
+ const deployment = {
278
+ ...newDeployment,
279
+ id: deploymentId,
280
+ devices: "devices" in newDeployment && newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
281
+ statistics: { status: {} }
282
+ };
283
+ const tasks = [
284
+ dispatch(actions2.createdDeployment(deployment)),
285
+ dispatch(getSingleDeployment(deploymentId)),
286
+ dispatch(setSnackbar({ message: "Deployment created successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
287
+ ];
288
+ trackDeploymentCreation(totalDeploymentCount, hasDeployments, trial_expiration);
289
+ const { canManageUsers } = getUserCapabilities(getState());
290
+ if (canManageUsers) {
291
+ const { phases, retries } = newDeployment;
292
+ const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
293
+ const newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
294
+ if (phases) {
295
+ const standardPhases = standardizePhases(phases);
296
+ const prevPhases = previousPhases.map(standardizePhases);
297
+ if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => deepCompare(phase, oldPhase))))) {
298
+ prevPhases.push(standardPhases);
299
+ }
300
+ newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
301
+ }
302
+ tasks.push(dispatch(saveGlobalSettings(newSettings)));
321
303
  }
322
- return accu;
323
- }, []);
324
- tasks = lackingData.reduce((accu, deviceId) => [...accu, dispatch(getDeviceById2(deviceId)), dispatch(getDeviceAuth(deviceId))], tasks);
325
- return Promise.all(tasks);
326
- });
327
- });
304
+ return Promise.all(tasks);
305
+ });
306
+ }
307
+ );
308
+ var getDeploymentDevices = createAppAsyncThunk(
309
+ `${sliceName2}/getDeploymentDevices`,
310
+ (options, { dispatch, getState }) => {
311
+ const { id, page = defaultPage, perPage = defaultPerPage } = options;
312
+ return general_api_default.get(`${deploymentsApiUrl}/deployments/${id}/devices/list?&page=${page}&per_page=${perPage}`).then((response) => {
313
+ const { devices: deploymentDevices = {} } = getState().deployments.byId[id] || {};
314
+ const devices = response.data.reduce((accu, item) => {
315
+ accu[item.id] = item;
316
+ const log = (deploymentDevices[item.id] || {}).log;
317
+ if (log) {
318
+ accu[item.id].log = log;
319
+ }
320
+ return accu;
321
+ }, {});
322
+ const selectedDeviceIds = Object.keys(devices);
323
+ let tasks = [
324
+ dispatch(
325
+ actions2.receivedDeploymentDevices({
326
+ id,
327
+ devices,
328
+ selectedDeviceIds,
329
+ totalDeviceCount: Number(response.headers[headerNames.total])
330
+ })
331
+ )
332
+ ];
333
+ const devicesById = getDevicesById(getState());
334
+ const lackingData = selectedDeviceIds.reduce((accu, deviceId) => {
335
+ const device = devicesById[deviceId];
336
+ if (!device || !device.identity_data || !device.attributes || Object.keys(device.attributes).length === 0) {
337
+ accu.push(deviceId);
338
+ }
339
+ return accu;
340
+ }, []);
341
+ tasks = lackingData.reduce((accu, deviceId) => [...accu, dispatch(getDeviceById2(deviceId)), dispatch(getDeviceAuth(deviceId))], tasks);
342
+ return Promise.all(tasks);
343
+ });
344
+ }
345
+ );
328
346
  var parseDeviceDeployment = ({
329
347
  deployment: { id, artifact_name: release, status: deploymentStatus },
330
348
  device: { created, deleted, id: deviceId, finished, status, log }
@@ -344,7 +362,7 @@ var parseDeviceDeployment = ({
344
362
  return accu;
345
363
  }, "")
346
364
  });
347
- var getDeviceDeployments = createAsyncThunk(`${sliceName2}/getDeviceDeployments`, (options, { dispatch }) => {
365
+ var getDeviceDeployments = createAppAsyncThunk(`${sliceName2}/getDeviceDeployments`, (options, { dispatch }) => {
348
366
  const { deviceId, filterSelection = [], page = defaultPage, perPage = defaultPerPage } = options;
349
367
  const filters = filterSelection.map((item) => `&status=${item}`).join("");
350
368
  return general_api_default.get(`${deploymentsApiUrl}/deployments/devices/${deviceId}?page=${page}&per_page=${perPage}${filters}`).then(
@@ -359,18 +377,18 @@ var getDeviceDeployments = createAsyncThunk(`${sliceName2}/getDeviceDeployments`
359
377
  )
360
378
  ).catch((err) => commonErrorHandler(err, "There was an error retrieving the device deployment history:", dispatch));
361
379
  });
362
- var resetDeviceDeployments = createAsyncThunk(
380
+ var resetDeviceDeployments = createAppAsyncThunk(
363
381
  `${sliceName2}/resetDeviceDeployments`,
364
382
  (deviceId, { dispatch }) => general_api_default.delete(`${deploymentsApiUrl}/deployments/devices/${deviceId}/history`).then(() => Promise.resolve(dispatch(getDeviceDeployments({ deviceId })))).catch((err) => commonErrorHandler(err, "There was an error resetting the device deployment history:", dispatch))
365
383
  );
366
- var getSingleDeployment = createAsyncThunk(
384
+ var getSingleDeployment = createAppAsyncThunk(
367
385
  `${sliceName2}/getSingleDeployment`,
368
386
  (id, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${id}`).then(({ data }) => {
369
387
  const { deployments } = transformDeployments([data], getState().deployments.byId);
370
388
  return Promise.resolve(dispatch(actions2.receivedDeployment(deployments[id])));
371
389
  })
372
390
  );
373
- var getDeviceLog = createAsyncThunk(
391
+ var getDeviceLog = createAppAsyncThunk(
374
392
  `${sliceName2}/getDeviceLog`,
375
393
  ({ deploymentId, deviceId }, { dispatch }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${deploymentId}/devices/${deviceId}/log`).catch((e) => {
376
394
  console.log("no log here", e);
@@ -379,7 +397,7 @@ var getDeviceLog = createAsyncThunk(
379
397
  ({ data: log }) => Promise.all([Promise.resolve(dispatch(actions2.receivedDeploymentDeviceLog({ id: deploymentId, deviceId, log }))), Promise.resolve(log)])
380
398
  )
381
399
  );
382
- var abortDeployment = createAsyncThunk(
400
+ var abortDeployment = createAppAsyncThunk(
383
401
  `${sliceName2}/abortDeployment`,
384
402
  (deploymentId, { dispatch, getState }) => general_api_default.put(`${deploymentsApiUrl}/deployments/${deploymentId}/status`, { status: "aborted" }).then(() => {
385
403
  const deploymentsByStatus = getDeploymentsByStatus(getState());
@@ -404,14 +422,14 @@ var abortDeployment = createAsyncThunk(
404
422
  ]);
405
423
  }).catch((err) => commonErrorHandler(err, "There was an error while aborting the deployment:", dispatch))
406
424
  );
407
- var updateDeploymentControlMap = createAsyncThunk(
425
+ var updateDeploymentControlMap = createAppAsyncThunk(
408
426
  `${sliceName2}/updateDeploymentControlMap`,
409
427
  ({ deploymentId, updateControlMap }, { dispatch }) => general_api_default.patch(`${deploymentsApiUrl}/deployments/${deploymentId}`, { update_control_map: updateControlMap }).catch((err) => commonErrorHandler(err, "There was an error while updating the deployment status:", dispatch)).then(() => Promise.resolve(dispatch(getSingleDeployment(deploymentId))))
410
428
  );
411
- var setDeploymentsState = createAsyncThunk(`${sliceName2}/setDeploymentsState`, (selection, { dispatch, getState }) => {
429
+ var setDeploymentsState = createAppAsyncThunk(`${sliceName2}/setDeploymentsState`, (selection, { dispatch, getState }) => {
412
430
  const { page, perPage, ...selectionState } = selection;
413
431
  const currentState = getState().deployments.selectionState;
414
- let nextState = {
432
+ const nextState = {
415
433
  ...currentState,
416
434
  ...selectionState,
417
435
  ...Object.keys(DEPLOYMENT_STATES).reduce((accu, item) => {
@@ -426,7 +444,7 @@ var setDeploymentsState = createAsyncThunk(`${sliceName2}/setDeploymentsState`,
426
444
  ...selectionState.general
427
445
  }
428
446
  };
429
- let tasks = [dispatch(actions2.setDeploymentsState(nextState))];
447
+ const tasks = [dispatch(actions2.setDeploymentsState(nextState))];
430
448
  if (nextState.selectedId && currentState.selectedId !== nextState.selectedId) {
431
449
  tasks.push(dispatch(getSingleDeployment(nextState.selectedId)));
432
450
  }
@@ -447,25 +465,23 @@ var mapExternalDeltaConfig = (config = {}) => deltaAttributeMappings.reduce((acc
447
465
  }
448
466
  return accu;
449
467
  }, {});
450
- var getDeploymentsConfig = createAsyncThunk(
468
+ var getDeploymentsConfig = createAppAsyncThunk(
451
469
  `${sliceName2}/getDeploymentsConfig`,
452
470
  (_, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/config`).then(({ data }) => {
453
471
  const oldConfig = getState().deployments.config;
454
472
  const { delta = {} } = data;
455
473
  const { binary_delta = {}, binary_delta_limits = {} } = delta;
456
- const { xdelta_args = {}, timeout: timeoutConfig = oldConfig.binaryDelta.timeout } = binary_delta;
457
- const { xdelta_args_limits = {}, timeout: timeoutLimit = oldConfig.binaryDeltaLimits.timeout } = binary_delta_limits;
474
+ const { xdelta_args = {} } = binary_delta;
475
+ const { xdelta_args_limits = {} } = binary_delta_limits;
458
476
  const config = {
459
477
  ...oldConfig,
460
478
  hasDelta: Boolean(delta.enabled),
461
479
  binaryDelta: {
462
480
  ...oldConfig.binaryDelta,
463
- timeout: timeoutConfig,
464
481
  ...mapExternalDeltaConfig(xdelta_args)
465
482
  },
466
483
  binaryDeltaLimits: {
467
484
  ...oldConfig.binaryDeltaLimits,
468
- timeout: timeoutLimit,
469
485
  ...mapExternalDeltaConfig(xdelta_args_limits)
470
486
  }
471
487
  };
@@ -474,7 +490,7 @@ var getDeploymentsConfig = createAsyncThunk(
474
490
  );
475
491
  var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) => {
476
492
  if (value !== void 0) {
477
- let cleanedValue = typeof value === "object" ? deepClean(value) : value;
493
+ const cleanedValue = typeof value === "object" ? deepClean(value) : value;
478
494
  if (cleanedValue === void 0 || typeof cleanedValue === "object" && isEmpty(cleanedValue)) {
479
495
  return accu;
480
496
  }
@@ -482,37 +498,38 @@ var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) =
482
498
  }
483
499
  return accu;
484
500
  }, void 0);
485
- var saveDeltaDeploymentsConfig = createAsyncThunk(`${sliceName2}/saveDeltaDeploymentsConfig`, (config, { dispatch, getState }) => {
486
- const configChange = {
487
- timeout: config.timeout,
488
- xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
489
- if (config[here] !== void 0) {
490
- accu[there] = config[here];
491
- }
492
- return accu;
493
- }, {})
494
- };
495
- const result = deepClean(configChange);
496
- if (!result) {
497
- return Promise.resolve();
498
- }
499
- return general_api_default.put(`${deploymentsApiUrl}/config/binary_delta`, result).catch((err) => commonErrorHandler(err, "There was a problem storing your delta artifact generation configuration.", dispatch)).then(() => {
500
- const oldConfig = getState().deployments.config;
501
- const newConfig = {
502
- ...oldConfig,
503
- binaryDelta: {
504
- ...oldConfig.binaryDelta,
505
- ...config
506
- }
501
+ var saveDeltaDeploymentsConfig = createAppAsyncThunk(
502
+ `${sliceName2}/saveDeltaDeploymentsConfig`,
503
+ (config, { dispatch, getState }) => {
504
+ const configChange = {
505
+ xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
506
+ if (config[here] !== void 0) {
507
+ accu[there] = config[here];
508
+ }
509
+ return accu;
510
+ }, {})
507
511
  };
508
- return Promise.all([dispatch(actions2.setDeploymentsConfig(newConfig)), dispatch(setSnackbar("Settings saved successfully"))]);
509
- });
510
- });
512
+ const result = deepClean(configChange);
513
+ if (!result) {
514
+ return Promise.resolve();
515
+ }
516
+ return general_api_default.put(`${deploymentsApiUrl}/config/binary_delta`, result).catch((err) => commonErrorHandler(err, "There was a problem storing your delta artifact generation configuration.", dispatch)).then(() => {
517
+ const oldConfig = getState().deployments.config;
518
+ const newConfig = {
519
+ ...oldConfig,
520
+ binaryDelta: {
521
+ ...oldConfig.binaryDelta,
522
+ ...config
523
+ }
524
+ };
525
+ return Promise.all([dispatch(actions2.setDeploymentsConfig(newConfig)), dispatch(setSnackbar("Settings saved successfully"))]);
526
+ });
527
+ }
528
+ );
511
529
 
512
530
  // src/devicesSlice/thunks.tsx
513
531
  import { Link } from "react-router-dom";
514
- import { attributeDuplicateFilter, dateRangeToUnix, deepCompare as deepCompare2, extractErrorMessage, getSnackbarMessage } from "@northern.tech/utils/helpers";
515
- import { createAsyncThunk as createAsyncThunk2 } from "@reduxjs/toolkit";
532
+ import { attributeDuplicateFilter, dateRangeToUnix, deepCompare as deepCompare2, getSnackbarMessage } from "@northern.tech/utils/helpers";
516
533
  import { isCancel } from "axios";
517
534
  import pluralize from "pluralize";
518
535
  import { v4 as uuid } from "uuid";
@@ -533,7 +550,7 @@ var defaultAttributes = [
533
550
  { scope: "system", attribute: "group" },
534
551
  { scope: "tags", attribute: "name" }
535
552
  ];
536
- var getGroups2 = createAsyncThunk2(
553
+ var getGroups = createAppAsyncThunk(
537
554
  `${sliceName3}/getGroups`,
538
555
  (_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/groups`).then((res) => {
539
556
  const state = getGroupsById(getState());
@@ -550,7 +567,7 @@ var getGroups2 = createAsyncThunk2(
550
567
  const filters = [{ key: "group", value: res.data, operator: DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }];
551
568
  return Promise.all([
552
569
  dispatch(actions3.receivedGroups(groups)),
553
- dispatch(getDevicesByStatus({ filterSelection: filters, group: 0, page: 1, perPage: 1, status: void 0 }))
570
+ dispatch(getDevicesByStatus({ filterSelection: filters, group: "", page: 1, perPage: 1, status: void 0 }))
554
571
  ]).then((promises) => {
555
572
  const devicesRetrieval = promises[promises.length - 1] || [];
556
573
  const { payload } = devicesRetrieval || {};
@@ -569,39 +586,42 @@ var getGroups2 = createAsyncThunk2(
569
586
  });
570
587
  })
571
588
  );
572
- var addDevicesToGroup = createAsyncThunk2(
589
+ var addDevicesToGroup = createAppAsyncThunk(
573
590
  `${sliceName3}/addDevicesToGroup`,
574
- ({ group, deviceIds, isCreation }, { dispatch }) => general_api_default.patch(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(() => dispatch(actions3.addToGroup({ group, deviceIds }))).finally(() => isCreation ? Promise.resolve(dispatch(getGroups2())) : {})
591
+ ({ group, deviceIds, isCreation }, { dispatch }) => general_api_default.patch(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(() => dispatch(actions3.addToGroup({ group, deviceIds }))).finally(() => isCreation ? Promise.resolve(dispatch(getGroups())) : {})
575
592
  );
576
- var removeDevicesFromGroup = createAsyncThunk2(
593
+ var removeDevicesFromGroup = createAppAsyncThunk(
577
594
  `${sliceName3}/removeDevicesFromGroup`,
578
595
  ({ group, deviceIds }, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(
579
596
  () => Promise.all([
580
597
  dispatch(actions3.removeFromGroup({ group, deviceIds })),
581
- dispatch(setSnackbar2(`The ${pluralize("devices", deviceIds.length)} ${pluralize("were", deviceIds.length)} removed from the group`, TIMEOUTS.fiveSeconds))
598
+ dispatch(
599
+ setSnackbar2({
600
+ message: `The ${pluralize("devices", deviceIds.length)} ${pluralize("were", deviceIds.length)} removed from the group`,
601
+ autoHideDuration: TIMEOUTS.fiveSeconds
602
+ })
603
+ )
582
604
  ])
583
605
  )
584
606
  );
585
607
  var getGroupNotification = (newGroup, selectedGroup) => {
586
- const successMessage = "The group was updated successfully";
608
+ const successMessage2 = "The group was updated successfully";
587
609
  if (newGroup === selectedGroup) {
588
- return [successMessage, TIMEOUTS.fiveSeconds];
610
+ return { message: successMessage2, autoHideDuration: TIMEOUTS.fiveSeconds };
589
611
  }
590
- return [
591
- /* @__PURE__ */ jsxs(Fragment, { children: [
592
- successMessage,
612
+ return {
613
+ action: "",
614
+ autoHideDuration: TIMEOUTS.fiveSeconds,
615
+ message: /* @__PURE__ */ jsxs(Fragment, { children: [
616
+ successMessage2,
593
617
  " - ",
594
618
  /* @__PURE__ */ jsx(Link, { to: `/devices?inventory=group:eq:${newGroup}`, children: "click here" }),
595
619
  " to see it."
596
620
  ] }),
597
- 5e3,
598
- void 0,
599
- void 0,
600
- () => {
601
- }
602
- ];
621
+ preventClickToCopy: true
622
+ };
603
623
  };
604
- var addStaticGroup = createAsyncThunk2(
624
+ var addStaticGroup = createAppAsyncThunk(
605
625
  `${sliceName3}/addStaticGroup`,
606
626
  ({ group, devices }, { dispatch, getState }) => Promise.resolve(dispatch(addDevicesToGroup({ group, deviceIds: devices.map(({ id }) => id), isCreation: true }))).then(
607
627
  () => Promise.resolve(
@@ -614,23 +634,23 @@ var addStaticGroup = createAsyncThunk2(
614
634
  ).then(
615
635
  () => Promise.all([
616
636
  dispatch(setDeviceListState({ setOnly: true })),
617
- dispatch(getGroups2()),
618
- dispatch(setSnackbar2(...getGroupNotification(group, getState().devices.groups.selectedGroup)))
637
+ dispatch(getGroups()),
638
+ dispatch(setSnackbar2(getGroupNotification(group, getState().devices.groups.selectedGroup)))
619
639
  ])
620
640
  )
621
641
  ).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
622
642
  );
623
- var removeStaticGroup = createAsyncThunk2(
643
+ var removeStaticGroup = createAppAsyncThunk(
624
644
  `${sliceName3}/removeStaticGroup`,
625
645
  (groupName, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${groupName}`).then(
626
646
  () => Promise.all([
627
647
  dispatch(actions3.removeGroup(groupName)),
628
- dispatch(getGroups2()),
629
- dispatch(setSnackbar2("Group was removed successfully", TIMEOUTS.fiveSeconds))
648
+ dispatch(getGroups()),
649
+ dispatch(setSnackbar2({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
630
650
  ])
631
651
  )
632
652
  );
633
- var getDynamicGroups = createAsyncThunk2(
653
+ var getDynamicGroups = createAppAsyncThunk(
634
654
  `${sliceName3}/getDynamicGroups`,
635
655
  (_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrlV2}/filters?per_page=${MAX_PAGE_SIZE}`).then(({ data: filters }) => {
636
656
  const state = getGroupsById(getState());
@@ -653,7 +673,7 @@ var getDynamicGroups = createAsyncThunk2(
653
673
  return Promise.resolve(dispatch(actions3.receivedGroups(groups)));
654
674
  }).catch(() => console.log("Dynamic group retrieval failed - likely accessing a non-enterprise backend"))
655
675
  );
656
- var addDynamicGroup = createAsyncThunk2(
676
+ var addDynamicGroup = createAppAsyncThunk(
657
677
  `${sliceName3}/addDynamicGroup`,
658
678
  ({ groupName, filterPredicates }, { dispatch, getState }) => general_api_default.post(`${inventoryApiUrlV2}/filters`, { name: groupName, terms: mapFiltersToTerms(filterPredicates) }).then(
659
679
  (res) => Promise.resolve(
@@ -670,45 +690,56 @@ var addDynamicGroup = createAsyncThunk2(
670
690
  const { cleanedFilters } = getGroupFilters(groupName, getState().devices.groups);
671
691
  return Promise.all([
672
692
  dispatch(actions3.setDeviceFilters(cleanedFilters)),
673
- dispatch(setSnackbar2(...getGroupNotification(groupName, getState().devices.groups.selectedGroup))),
693
+ dispatch(setSnackbar2(getGroupNotification(groupName, getState().devices.groups.selectedGroup))),
674
694
  dispatch(getDynamicGroups())
675
695
  ]);
676
696
  })
677
697
  ).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
678
698
  );
679
- var updateDynamicGroup = createAsyncThunk2(`${sliceName3}/updateDynamicGroup`, ({ groupName, filterPredicates }, { dispatch, getState }) => {
680
- const filterId = getState().devices.groups.byId[groupName].id;
681
- return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(() => Promise.resolve(dispatch(addDynamicGroup({ groupName, filterPredicates }))));
682
- });
683
- var removeDynamicGroup = createAsyncThunk2(`${sliceName3}/removeDynamicGroup`, (groupName, { dispatch, getState }) => {
699
+ var updateDynamicGroup = createAppAsyncThunk(
700
+ `${sliceName3}/updateDynamicGroup`,
701
+ ({ groupName, filterPredicates }, { dispatch, getState }) => {
702
+ const filterId = getState().devices.groups.byId[groupName].id;
703
+ return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(
704
+ () => Promise.resolve(dispatch(addDynamicGroup({ groupName, filterPredicates })))
705
+ );
706
+ }
707
+ );
708
+ var removeDynamicGroup = createAppAsyncThunk(`${sliceName3}/removeDynamicGroup`, (groupName, { dispatch, getState }) => {
684
709
  const filterId = getState().devices.groups.byId[groupName].id;
685
710
  return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(
686
- () => Promise.all([dispatch(actions3.removeGroup(groupName)), dispatch(setSnackbar2("Group was removed successfully", TIMEOUTS.fiveSeconds))])
711
+ () => Promise.all([
712
+ dispatch(actions3.removeGroup(groupName)),
713
+ dispatch(setSnackbar2({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
714
+ ])
687
715
  );
688
716
  });
689
717
  var getGroupFilters = (group, groupsState, filters = []) => {
690
718
  const groupName = group === UNGROUPED_GROUP.id || group === UNGROUPED_GROUP.name ? UNGROUPED_GROUP.id : group;
691
719
  const selectedGroup = groupsState.byId[groupName];
692
720
  const groupFilterLength = selectedGroup?.filters?.length || 0;
693
- const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters].filter(filtersFilter) : filters;
721
+ const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters || []].filter(filtersFilter) : filters;
694
722
  return { cleanedFilters, groupName, selectedGroup, groupFilterLength };
695
723
  };
696
- var selectGroup = createAsyncThunk2(`${sliceName3}/selectGroup`, ({ group, filters = [] }, { dispatch, getState }) => {
697
- const { cleanedFilters, groupName, selectedGroup, groupFilterLength } = getGroupFilters(group, getState().devices.groups, filters);
698
- if (getSelectedGroup(getState()) === groupName && (filters.length === 0 && !groupFilterLength || filters.length === cleanedFilters.length)) {
699
- return Promise.resolve();
700
- }
701
- let tasks = [];
702
- if (groupFilterLength) {
703
- tasks.push(dispatch(actions3.setDeviceFilters(cleanedFilters)));
704
- } else {
705
- tasks.push(dispatch(actions3.setDeviceFilters(filters)));
706
- tasks.push(dispatch(getGroupDevices({ group: groupName, perPage: 1, shouldIncludeAllStates: true })));
724
+ var selectGroup = createAppAsyncThunk(
725
+ `${sliceName3}/selectGroup`,
726
+ ({ group, filters = [] }, { dispatch, getState }) => {
727
+ const { cleanedFilters, groupName, selectedGroup, groupFilterLength } = getGroupFilters(group, getState().devices.groups, filters);
728
+ if (getSelectedGroup(getState()) === groupName && (filters.length === 0 && !groupFilterLength || filters.length === cleanedFilters.length)) {
729
+ return Promise.resolve();
730
+ }
731
+ const tasks = [];
732
+ if (groupFilterLength) {
733
+ tasks.push(dispatch(actions3.setDeviceFilters(cleanedFilters)));
734
+ } else {
735
+ tasks.push(dispatch(actions3.setDeviceFilters(filters)));
736
+ tasks.push(dispatch(getGroupDevices({ group: groupName, perPage: 1, shouldIncludeAllStates: true })));
737
+ }
738
+ const selectedGroupName = selectedGroup || !Object.keys(getGroupsById(getState())).length ? groupName : void 0;
739
+ tasks.push(dispatch(actions3.selectGroup(selectedGroupName)));
740
+ return Promise.all(tasks);
707
741
  }
708
- const selectedGroupName = selectedGroup || !Object.keys(getGroupsById(getState())).length ? groupName : void 0;
709
- tasks.push(dispatch(actions3.selectGroup(selectedGroupName)));
710
- return Promise.all(tasks);
711
- });
742
+ );
712
743
  var getEarliestTs = (dateA = "", dateB = "") => !dateA || !dateB ? dateA || dateB : dateA < dateB ? dateA : dateB;
713
744
  var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
714
745
  (accu, device) => {
@@ -739,11 +770,16 @@ var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
739
770
  },
740
771
  { ids, devicesById: {} }
741
772
  );
742
- var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (options, { dispatch, getState }) => {
773
+ var getGroupDevices = createAppAsyncThunk(`${sliceName3}/getGroupDevices`, (options, { dispatch, getState }) => {
743
774
  const { group, shouldIncludeAllStates, ...remainder } = options;
744
775
  const { cleanedFilters: filterSelection } = getGroupFilters(group, getState().devices.groups);
745
- return Promise.resolve(
746
- dispatch(getDevicesByStatus({ ...remainder, filterSelection, group, status: shouldIncludeAllStates ? void 0 : DEVICE_STATES.accepted }))
776
+ return dispatch(
777
+ getDevicesByStatus({
778
+ ...remainder,
779
+ filterSelection,
780
+ group,
781
+ status: shouldIncludeAllStates ? void 0 : DEVICE_STATES.accepted
782
+ })
747
783
  ).unwrap().then((results) => {
748
784
  if (!group) {
749
785
  return Promise.resolve();
@@ -757,7 +793,7 @@ var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (option
757
793
  dispatch(
758
794
  actions3.addGroup({
759
795
  group: {
760
- deviceIds: deviceAccu.ids.length === total || deviceAccu.ids.length > stateGroup?.deviceIds ? deviceAccu.ids : stateGroup.deviceIds,
796
+ deviceIds: deviceAccu.ids.length === total || stateGroup && stateGroup.deviceIds && deviceAccu.ids.length > stateGroup.deviceIds ? deviceAccu.ids : stateGroup.deviceIds,
761
797
  total
762
798
  },
763
799
  groupName: group
@@ -766,55 +802,63 @@ var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (option
766
802
  );
767
803
  });
768
804
  });
769
- var getAllGroupDevices = createAsyncThunk2(`${sliceName3}/getAllGroupDevices`, (group, { dispatch, getState }) => {
770
- if (!group || !!group && (!getGroupsById(getState())[group] || getGroupsById(getState())[group].filters.length)) {
771
- return Promise.resolve();
772
- }
773
- const { attributes, filterTerms } = prepareSearchArguments({
774
- filters: [],
775
- group,
776
- state: getState(),
777
- status: DEVICE_STATES.accepted
778
- });
779
- const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
780
- page,
781
- per_page: perPage,
782
- filters: filterTerms,
783
- attributes
784
- }).then((res) => {
785
- const state = getState();
786
- const deviceAccu = reduceReceivedDevices(res.data, devices, state);
787
- dispatch(actions3.receivedDevices(deviceAccu.devicesById));
788
- const total = Number(res.headers[headerNames.total]);
789
- if (total > perPage * page) {
790
- return getAllDevices(perPage, page + 1, deviceAccu.ids);
805
+ var getAllGroupDevices = createAppAsyncThunk(
806
+ `${sliceName3}/getAllGroupDevices`,
807
+ ({ group, attribute }, { dispatch, getState }) => {
808
+ if (!group || !!group && (!getGroupsById(getState())[group] || getGroupsById(getState())[group].filters.length)) {
809
+ return Promise.resolve();
791
810
  }
792
- return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total: deviceAccu.ids.length }, groupName: group })));
793
- });
794
- return getAllDevices();
795
- });
796
- var getAllDynamicGroupDevices = createAsyncThunk2(`${sliceName3}/getAllDynamicGroupDevices`, (group, { dispatch, getState }) => {
797
- if (!!group && (!getGroupsById(getState())[group] || !getGroupsById(getState())[group].filters.length)) {
798
- return Promise.resolve();
811
+ const { attributes, filterTerms } = prepareSearchArguments({
812
+ filters: [],
813
+ group,
814
+ state: getState(),
815
+ status: DEVICE_STATES.accepted
816
+ });
817
+ const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
818
+ page,
819
+ per_page: perPage,
820
+ filters: filterTerms,
821
+ attributes: [...attributes, { scope: "inventory", attribute }]
822
+ }).then((res) => {
823
+ const state = getState();
824
+ const deviceAccu = reduceReceivedDevices(res.data, devices, state);
825
+ dispatch(actions3.receivedDevices(deviceAccu.devicesById));
826
+ const total = Number(res.headers[headerNames.total]);
827
+ if (total > perPage * page) {
828
+ return getAllDevices(perPage, page + 1, deviceAccu.ids);
829
+ }
830
+ return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total: deviceAccu.ids.length }, groupName: group })));
831
+ });
832
+ return getAllDevices();
799
833
  }
800
- const { attributes, filterTerms: filters } = prepareSearchArguments({
801
- filters: getState().devices.groups.byId[group].filters,
802
- state: getState(),
803
- status: DEVICE_STATES.accepted
804
- });
805
- const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), { page, per_page: perPage, filters, attributes }).then((res) => {
806
- const state = getState();
807
- const deviceAccu = reduceReceivedDevices(res.data, devices, state);
808
- dispatch(actions3.receivedDevices(deviceAccu.devicesById));
809
- const total = Number(res.headers[headerNames.total]);
810
- if (total > deviceAccu.ids.length) {
811
- return getAllDevices(perPage, page + 1, deviceAccu.ids);
834
+ );
835
+ var getAllDynamicGroupDevices = createAppAsyncThunk(
836
+ `${sliceName3}/getAllDynamicGroupDevices`,
837
+ ({ group, attribute }, { dispatch, getState }) => {
838
+ if (!!group && (!getGroupsById(getState())[group] || !getGroupsById(getState())[group].filters.length)) {
839
+ return Promise.resolve();
812
840
  }
813
- return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total }, groupName: group })));
814
- });
815
- return getAllDevices();
816
- });
817
- var getDeviceById2 = createAsyncThunk2(
841
+ const { attributes, filterTerms: filters } = prepareSearchArguments({
842
+ filters: getState().devices.groups.byId[group].filters,
843
+ state: getState(),
844
+ status: DEVICE_STATES.accepted
845
+ });
846
+ const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), { page, per_page: perPage, filters, attributes: [...attributes, { scope: "inventory", attribute }] }).then(
847
+ (res) => {
848
+ const state = getState();
849
+ const deviceAccu = reduceReceivedDevices(res.data, devices, state);
850
+ dispatch(actions3.receivedDevices(deviceAccu.devicesById));
851
+ const total = Number(res.headers[headerNames.total]);
852
+ if (total > deviceAccu.ids.length) {
853
+ return getAllDevices(perPage, page + 1, deviceAccu.ids);
854
+ }
855
+ return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total }, groupName: group })));
856
+ }
857
+ );
858
+ return getAllDevices();
859
+ }
860
+ );
861
+ var getDeviceById2 = createAppAsyncThunk(
818
862
  `${sliceName3}/getDeviceById`,
819
863
  (id, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/devices/${id}`).then((res) => {
820
864
  const device = reduceReceivedDevices([res.data], [], getState()).devicesById[id];
@@ -832,7 +876,8 @@ var getDeviceById2 = createAsyncThunk2(
832
876
  attributes: [
833
877
  { name: "status", value: "decomissioned", scope: "identity" },
834
878
  { name: "decomissioned", value: "true", scope: "inventory" }
835
- ]
879
+ ],
880
+ log: false
836
881
  }
837
882
  ],
838
883
  [],
@@ -842,17 +887,20 @@ var getDeviceById2 = createAsyncThunk2(
842
887
  }
843
888
  })
844
889
  );
845
- var getDeviceInfo = createAsyncThunk2(`${sliceName3}/getDeviceInfo`, (deviceId, { dispatch, getState }) => {
890
+ var getDeviceInfo = createAppAsyncThunk(`${sliceName3}/getDeviceInfo`, (deviceId, { dispatch, getState }) => {
846
891
  const device = getDeviceById(getState(), deviceId);
847
892
  const { hasDeviceConfig, hasDeviceConnect, hasMonitor } = getTenantCapabilities(getState());
848
893
  const { canConfigure } = getUserCapabilities(getState());
849
894
  const integrations = getDeviceTwinIntegrations(getState());
850
- let tasks = [dispatch(getDeviceAuth(deviceId)), ...integrations.map((integration) => dispatch(getDeviceTwin({ deviceId, integration })))];
851
- if (hasDeviceConfig && canConfigure && [DEVICE_STATES.accepted, DEVICE_STATES.preauth].includes(device.status)) {
895
+ const tasks = [
896
+ dispatch(getDeviceAuth(deviceId)),
897
+ dispatch(getDeviceById2(deviceId)),
898
+ ...integrations.map((integration) => dispatch(getDeviceTwin({ deviceId, integration })))
899
+ ];
900
+ if (hasDeviceConfig && canConfigure && (device.status === DEVICE_STATES.accepted || device.status === DEVICE_STATES.preauth)) {
852
901
  tasks.push(dispatch(getDeviceConfig(deviceId)));
853
902
  }
854
903
  if (device.status === DEVICE_STATES.accepted) {
855
- tasks.push(dispatch(getDeviceById2(deviceId)));
856
904
  if (hasDeviceConnect) {
857
905
  tasks.push(dispatch(getDeviceConnect(deviceId)));
858
906
  }
@@ -863,25 +911,7 @@ var getDeviceInfo = createAsyncThunk2(`${sliceName3}/getDeviceInfo`, (deviceId,
863
911
  }
864
912
  return Promise.all(tasks);
865
913
  });
866
- var deriveInactiveDevices = createAsyncThunk2(`${sliceName3}/deriveInactiveDevices`, (deviceIds, { dispatch, getState }) => {
867
- const yesterday = /* @__PURE__ */ new Date();
868
- yesterday.setDate(yesterday.getDate() - 1);
869
- const yesterdaysIsoString = yesterday.toISOString();
870
- const devices = deviceIds.reduce(
871
- (accu, id) => {
872
- const device = getDeviceById(getState(), id);
873
- if (device && device.updated_ts > yesterdaysIsoString) {
874
- accu.active.push(id);
875
- } else {
876
- accu.inactive.push(id);
877
- }
878
- return accu;
879
- },
880
- { active: [], inactive: [] }
881
- );
882
- return dispatch(actions3.setInactiveDevices({ activeDeviceTotal: devices.active.length, inactiveDeviceTotal: devices.inactive.length }));
883
- });
884
- var getDeviceCount = createAsyncThunk2(
914
+ var getDeviceCount = createAppAsyncThunk(
885
915
  `${sliceName3}/getDeviceCount`,
886
916
  (status, { dispatch, getState }) => general_api_default.post(getSearchEndpoint(getState()), {
887
917
  page: 1,
@@ -890,37 +920,34 @@ var getDeviceCount = createAsyncThunk2(
890
920
  attributes: defaultAttributes
891
921
  }).then((response) => {
892
922
  const count = Number(response.headers[headerNames.total]);
893
- if (status) {
894
- return dispatch(actions3.setDevicesCountByStatus({ count, status }));
895
- }
896
- return dispatch(actions3.setTotalDevices(count));
923
+ return dispatch(actions3.setDevicesCountByStatus({ count, status }));
897
924
  })
898
925
  );
899
- var getAllDeviceCounts = createAsyncThunk2(
926
+ var getAllDeviceCounts = createAppAsyncThunk(
900
927
  `${sliceName3}/getAllDeviceCounts`,
901
928
  (_, { dispatch }) => Promise.all([DEVICE_STATES.accepted, DEVICE_STATES.pending].map((status) => dispatch(getDeviceCount(status))))
902
929
  );
903
- var getDeviceLimit = createAsyncThunk2(
930
+ var getDeviceLimit = createAppAsyncThunk(
904
931
  `${sliceName3}/getDeviceLimit`,
905
932
  (_, { dispatch }) => general_api_default.get(`${deviceAuthV2}/limits/max_devices`).then((res) => dispatch(actions3.setDeviceLimit(res.data.limit)))
906
933
  );
907
- var setDeviceListState = createAsyncThunk2(
934
+ var setDeviceListState = createAppAsyncThunk(
908
935
  `${sliceName3}/setDeviceListState`,
909
936
  ({ shouldSelectDevices = true, forceRefresh, fetchAuth = true, ...selectionState }, { dispatch, getState }) => {
910
937
  const currentState = getDeviceListState(getState());
911
938
  const refreshTrigger = forceRefresh ? !currentState.refreshTrigger : selectionState.refreshTrigger;
912
- let nextState = {
939
+ const nextState = {
913
940
  ...currentState,
914
941
  setOnly: false,
915
942
  refreshTrigger,
916
943
  ...selectionState,
917
944
  sort: { ...currentState.sort, ...selectionState.sort }
918
945
  };
919
- let tasks = [];
946
+ const tasks = [];
920
947
  const { isLoading: currentLoading, deviceIds: currentDevices, selection: currentSelection, ...currentRequestState } = currentState;
921
948
  const { isLoading: nextLoading, deviceIds: nextDevices, selection: nextSelection, ...nextRequestState } = nextState;
922
949
  if (!nextState.setOnly && !deepCompare2(currentRequestState, nextRequestState)) {
923
- const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol, scope: sortScope } = nextState.sort ?? {};
950
+ const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol, scope: sortScope = "" } = nextState.sort ?? {};
924
951
  const sortBy = sortCol ? [{ attribute: sortCol, order: sortDown, scope: sortScope }] : void 0;
925
952
  const applicableSelectedState = nextState.state === ALL_DEVICE_STATES ? void 0 : nextState.state;
926
953
  nextState.isLoading = true;
@@ -936,83 +963,84 @@ var setDeviceListState = createAsyncThunk2(
936
963
  return Promise.all(tasks);
937
964
  }
938
965
  );
939
- var getDevicesByStatus = createAsyncThunk2(`${sliceName3}/getDevicesByStatus`, (options, { dispatch, getState }) => {
940
- const {
941
- status,
942
- fetchAuth = true,
943
- filterSelection,
944
- group,
945
- selectedIssues = [],
946
- page = defaultPage2,
947
- perPage = defaultPerPage2,
948
- sortOptions = [],
949
- selectedAttributes = getSelectedDeviceAttribute(getState())
950
- } = options;
951
- const state = getState();
952
- const { applicableFilters, filterTerms } = convertDeviceListStateToFilters({
953
- filters: filterSelection ?? getDeviceFilters(state),
954
- group: group ?? getSelectedGroup(state),
955
- groups: state.devices.groups,
956
- offlineThreshold: state.app.offlineThreshold,
957
- selectedIssues,
958
- status
959
- });
960
- const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
961
- return general_api_default.post(getSearchEndpoint(getState()), {
962
- page,
963
- per_page: perPage,
964
- filters: filterTerms,
965
- sort: sortOptions,
966
- attributes
967
- }).then((response) => {
968
- const state2 = getState();
969
- const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
970
- let total = !applicableFilters.length ? Number(response.headers[headerNames.total]) : null;
971
- if (status && state2.devices.byStatus[status].total === deviceAccu.ids.length) {
972
- total = deviceAccu.ids.length;
973
- }
974
- let tasks = [dispatch(actions3.receivedDevices(deviceAccu.devicesById))];
975
- if (status) {
976
- tasks.push(dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
977
- }
978
- const receivedDevices = Object.values(deviceAccu.devicesById);
979
- if (receivedDevices.length && fetchAuth) {
980
- tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
981
- }
982
- tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[headerNames.total]) }));
983
- return Promise.all(tasks);
984
- }).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
985
- });
986
- var getAllDevicesByStatus = createAsyncThunk2(`${sliceName3}/getAllDevicesByStatus`, (status, { dispatch, getState }) => {
987
- const attributes = [...defaultAttributes, getIdAttribute(getState())];
988
- const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
989
- page,
990
- per_page: perPage,
991
- filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
992
- attributes
993
- }).then((res) => {
966
+ var getDevicesByStatus = createAppAsyncThunk(
967
+ `${sliceName3}/getDevicesByStatus`,
968
+ (options, { dispatch, getState }) => {
969
+ const {
970
+ status,
971
+ fetchAuth = true,
972
+ filterSelection,
973
+ group,
974
+ selectedIssues = [],
975
+ page = defaultPage2,
976
+ perPage = defaultPerPage2,
977
+ sortOptions = [],
978
+ selectedAttributes = getSelectedDeviceAttribute(getState())
979
+ } = options;
994
980
  const state = getState();
995
- const deviceAccu = reduceReceivedDevices(res.data, devices, state, status);
996
- dispatch(actions3.receivedDevices(deviceAccu.devicesById));
997
- const total = Number(res.headers[headerNames.total]);
998
- if (total > state.deployments.deploymentDeviceLimit) {
981
+ const { applicableFilters, filterTerms } = convertDeviceListStateToFilters({
982
+ filters: filterSelection ?? getDeviceFilters(state),
983
+ group: group ?? getSelectedGroup(state),
984
+ groups: state.devices.groups,
985
+ offlineThreshold: state.app.offlineThreshold,
986
+ selectedIssues,
987
+ status
988
+ });
989
+ const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
990
+ return general_api_default.post(getSearchEndpoint(getState()), {
991
+ page,
992
+ per_page: perPage,
993
+ filters: filterTerms,
994
+ sort: sortOptions,
995
+ attributes
996
+ }).then((response) => {
997
+ const state2 = getState();
998
+ const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
999
+ let total = !applicableFilters.length ? Number(response.headers[headerNames.total]) : 0;
1000
+ if (status && state2.devices.byStatus[status].total === deviceAccu.ids.length) {
1001
+ total = deviceAccu.ids.length;
1002
+ }
1003
+ const tasks = [dispatch(actions3.receivedDevices(deviceAccu.devicesById))];
1004
+ if (status) {
1005
+ tasks.push(dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
1006
+ }
1007
+ const receivedDevices = Object.values(deviceAccu.devicesById);
1008
+ if (receivedDevices.length && fetchAuth) {
1009
+ tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
1010
+ }
1011
+ tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[headerNames.total]) }));
1012
+ return Promise.all(tasks);
1013
+ }).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
1014
+ }
1015
+ );
1016
+ var getAllDevicesByStatus = createAppAsyncThunk(
1017
+ `${sliceName3}/getAllDevicesByStatus`,
1018
+ ({ status, attribute }, { dispatch, getState }) => {
1019
+ const attributes = [...defaultAttributes, getIdAttribute(getState())];
1020
+ const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
1021
+ page,
1022
+ per_page: perPage,
1023
+ filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
1024
+ attributes: [...attributes, { scope: "inventory", attribute }]
1025
+ }).then((res) => {
1026
+ const state = getState();
1027
+ const deviceAccu = reduceReceivedDevices(res.data, devices, state, status);
1028
+ dispatch(actions3.receivedDevices(deviceAccu.devicesById));
1029
+ const total = Number(res.headers[headerNames.total]);
1030
+ if (total > state.deployments.deploymentDeviceLimit) {
1031
+ return Promise.resolve();
1032
+ }
1033
+ if (total > perPage * page) {
1034
+ return getAllDevices(perPage, page + 1, deviceAccu.ids);
1035
+ }
999
1036
  return Promise.resolve();
1000
- }
1001
- if (total > perPage * page) {
1002
- return getAllDevices(perPage, page + 1, deviceAccu.ids);
1003
- }
1004
- let tasks = [dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, forceUpdate: true, status, total: deviceAccu.ids.length }))];
1005
- if (status === DEVICE_STATES.accepted && deviceAccu.ids.length === total) {
1006
- tasks.push(dispatch(deriveInactiveDevices(deviceAccu.ids)));
1007
- tasks.push(dispatch(deriveReportsData()));
1008
- }
1009
- return Promise.all(tasks);
1010
- });
1011
- return getAllDevices();
1012
- });
1013
- var searchDevices = createAsyncThunk2(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
1037
+ });
1038
+ return getAllDevices();
1039
+ }
1040
+ );
1041
+ var searchDevices = createAppAsyncThunk(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
1014
1042
  const state = getState();
1015
- let options = { ...state.app.searchState, ...passedOptions };
1043
+ const options = { ...state.app.searchState, ...passedOptions };
1016
1044
  const { page = defaultPage2, searchTerm, sortOptions = [] } = options;
1017
1045
  const { columnSelection = [] } = getUserSettings(state);
1018
1046
  const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
@@ -1043,64 +1071,25 @@ var attributeReducer = (attributes = []) => attributes.slice(0, ATTRIBUTE_LIST_C
1043
1071
  },
1044
1072
  { identity: [], inventory: [], system: [], tags: [] }
1045
1073
  );
1046
- var getDeviceAttributes = createAsyncThunk2(
1074
+ var getDeviceAttributes = createAppAsyncThunk(
1047
1075
  `${sliceName3}/getDeviceAttributes`,
1048
1076
  (_, { dispatch, getState }) => general_api_default.get(getAttrsEndpoint(getState())).then(({ data }) => {
1049
1077
  const { identity: identityAttributes, inventory: inventoryAttributes, system: systemAttributes, tags: tagAttributes } = attributeReducer(data || []);
1050
1078
  return dispatch(actions3.setFilterAttributes({ identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }));
1051
1079
  })
1052
1080
  );
1053
- var getReportingLimits = createAsyncThunk2(
1054
- `${sliceName3}/getReportingLimits`,
1055
- (_, { dispatch }) => general_api_default.get(`${reportingApiUrl}/devices/attributes`).catch((err) => commonErrorHandler(err, `filterable attributes limit & usage could not be retrieved.`, dispatch, commonErrorFallback)).then(({ data }) => {
1056
- const { attributes, count, limit } = data;
1057
- const groupedAttributes = attributeReducer(attributes);
1058
- return Promise.resolve(dispatch(actions3.setFilterablesConfig({ count, limit, attributes: groupedAttributes })));
1059
- })
1060
- );
1061
- var ensureVersionString = (software, fallback) => software.length && software !== "artifact_name" ? software.endsWith(".version") ? software : `${software}.version` : fallback;
1062
- var getSingleReportData = (reportConfig, groups) => {
1063
- const { attribute, group, software = "" } = reportConfig;
1064
- const filters = [{ key: "status", scope: "identity", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: "accepted" }];
1065
- if (group) {
1066
- const staticGroupFilter = { key: "group", scope: "system", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: group };
1067
- const { cleanedFilters: groupFilters } = getGroupFilters(group, groups);
1068
- filters.push(...groupFilters.length ? groupFilters : [staticGroupFilter]);
1069
- }
1070
- const aggregationAttribute = ensureVersionString(software, attribute);
1071
- return general_api_default.post(`${reportingApiUrl}/devices/aggregate`, {
1072
- aggregations: [{ attribute: aggregationAttribute, name: "*", scope: "inventory", size: REPORT_CHART_SIZE_LIMIT }],
1073
- filters: mapFiltersToTerms(filters)
1074
- }).then(({ data }) => ({ data, reportConfig }));
1075
- };
1076
- var getReportsData = createAsyncThunk2(`${sliceName3}/getReportsData`, (_, { dispatch, getState }) => {
1077
- const state = getState();
1078
- const currentUserId = getCurrentUser(state).id;
1079
- const reports = getUserSettings(state).reports || getGlobalSettings(state)[`${currentUserId}-reports`] || (Object.keys(getDevicesById(state)).length ? defaultReports : []);
1080
- return Promise.all(reports.map((report) => getSingleReportData(report, getState().devices.groups))).then((results) => {
1081
- const devicesState = getState().devices;
1082
- const totalDeviceCount = devicesState.byStatus.accepted.total;
1083
- const newReports = results.map(({ data, reportConfig }) => {
1084
- let { items, other_count } = data[0];
1085
- const { attribute, group, software = "" } = reportConfig;
1086
- const dataCount = items.reduce((accu, item) => accu + item.count, 0);
1087
- const otherCount = !group && (software === rootfsImageVersion || attribute === "artifact_name") ? totalDeviceCount - dataCount : other_count;
1088
- return { items, otherCount, total: otherCount + dataCount };
1089
- });
1090
- return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
1091
- });
1092
- });
1093
1081
  var initializeDistributionData = (report, groups, devices, totalDeviceCount) => {
1094
1082
  const { attribute, group = "", software = "" } = report;
1095
1083
  const effectiveAttribute = software ? software : attribute;
1096
1084
  const { deviceIds, total = 0 } = groups[group] || {};
1097
- const relevantDevices = groups[group] ? deviceIds.map((id) => devices[id]) : Object.values(devices);
1085
+ const relevantDevices = deviceIds ? deviceIds.map((id) => devices[id]) : Object.values(devices);
1098
1086
  const distributionByAttribute = relevantDevices.reduce((accu, item) => {
1099
1087
  if (!item.attributes || item.status !== DEVICE_STATES.accepted) return accu;
1100
- if (!accu[item.attributes[effectiveAttribute]]) {
1101
- accu[item.attributes[effectiveAttribute]] = 0;
1088
+ const attributeValue = item.attributes[effectiveAttribute];
1089
+ if (!accu[attributeValue]) {
1090
+ accu[attributeValue] = 0;
1102
1091
  }
1103
- accu[item.attributes[effectiveAttribute]] = accu[item.attributes[effectiveAttribute]] + 1;
1092
+ accu[attributeValue] = accu[attributeValue] + 1;
1104
1093
  return accu;
1105
1094
  }, {});
1106
1095
  const distributionByAttributeSorted = Object.entries(distributionByAttribute).sort((pairA, pairB) => pairB[1] - pairA[1]);
@@ -1109,90 +1098,111 @@ var initializeDistributionData = (report, groups, devices, totalDeviceCount) =>
1109
1098
  const otherCount = (groups[group] ? total : totalDeviceCount) - dataCount;
1110
1099
  return { items, otherCount, total: otherCount + dataCount };
1111
1100
  };
1112
- var deriveReportsData = createAsyncThunk2(`${sliceName3}/deriveReportsData`, (_, { dispatch, getState }) => {
1113
- const state = getState();
1114
- const {
1115
- groups: { byId: groupsById },
1116
- byId,
1117
- byStatus: {
1118
- accepted: { total }
1119
- }
1120
- } = state.devices;
1121
- const reports = getUserSettings(state).reports || state.users.globalSettings[`${state.users.currentUser}-reports`] || (Object.keys(byId).length ? defaultReports : []);
1122
- const newReports = reports.map((report) => initializeDistributionData(report, groupsById, byId, total));
1101
+ var updateReportData = createAppAsyncThunk(`${sliceName3}/updateReportData`, (reportIndex, { dispatch, getState }) => {
1102
+ const reports = getDeviceReportsForUser(getState());
1103
+ const report = reports[reportIndex];
1104
+ const { group = "" } = report;
1105
+ const devicesById = getDevicesById(getState());
1106
+ const groups = getGroupsById(getState());
1107
+ const acceptedDevices = getAcceptedDevices(getState());
1108
+ const totalDeviceCount = groups[group] ? groups[group].total : acceptedDevices.total;
1109
+ const reportsData = getDeviceReports(getState());
1110
+ const newReports = [...reportsData];
1111
+ newReports[reportIndex] = initializeDistributionData(report, groups, devicesById, totalDeviceCount);
1123
1112
  return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
1124
1113
  });
1125
- var getReportsDataWithoutBackendSupport = createAsyncThunk2(
1126
- `${sliceName3}/getReportsDataWithoutBackendSupport`,
1127
- (_, { dispatch, getState }) => Promise.all([dispatch(getAllDevicesByStatus(DEVICE_STATES.accepted)), dispatch(getGroups2()), dispatch(getDynamicGroups())]).then(() => {
1128
- const { dynamic: dynamicGroups, static: staticGroups } = getGroups(getState());
1129
- return Promise.all([
1130
- ...staticGroups.map(({ groupId }) => dispatch(getAllGroupDevices(groupId))),
1131
- ...dynamicGroups.map(({ groupId }) => dispatch(getAllDynamicGroupDevices(groupId)))
1132
- ]).then(() => dispatch(deriveReportsData()));
1133
- })
1114
+ var getReportDataWithoutBackendSupport = createAppAsyncThunk(
1115
+ `${sliceName3}/getReportDataWithoutBackendSupport`,
1116
+ (reportIndex, { dispatch, getState }) => {
1117
+ const reports = getDeviceReportsForUser(getState());
1118
+ const report = reports[reportIndex];
1119
+ if (!report) {
1120
+ return;
1121
+ }
1122
+ const { attribute, group = "", software = "" } = report;
1123
+ const effectiveAttribute = software ? software : attribute;
1124
+ const devicesById = getDevicesById(getState());
1125
+ const acceptedDevices = getAcceptedDevices(getState());
1126
+ const groups = getGroupsById(getState());
1127
+ const { deviceIds = [], filters = [], total = 0 } = groups[group] || {};
1128
+ let groupDevicesRequest = Promise.resolve({
1129
+ payload: { groupName: "", group: { deviceIds: Object.keys(devicesById), total: Object.keys(devicesById).length } }
1130
+ });
1131
+ if (group && (!(deviceIds.length && total) || deviceIds.length !== total || !deviceIds.every((id) => !!devicesById[id]))) {
1132
+ groupDevicesRequest = filters.length ? dispatch(getAllDynamicGroupDevices({ group, attribute: effectiveAttribute })).unwrap() : dispatch(getAllGroupDevices({ group, attribute: effectiveAttribute })).unwrap();
1133
+ } else if (!group && (acceptedDevices.deviceIds.length !== acceptedDevices.total || !acceptedDevices.deviceIds.every((id) => !!devicesById[id]))) {
1134
+ groupDevicesRequest = dispatch(getAllDevicesByStatus({ status: DEVICE_STATES.accepted, attribute: effectiveAttribute })).unwrap();
1135
+ }
1136
+ return groupDevicesRequest.then(() => dispatch(updateReportData(reportIndex)));
1137
+ }
1134
1138
  );
1135
- var getDeviceConnect = createAsyncThunk2(
1139
+ var getDeviceConnect = createAppAsyncThunk(
1136
1140
  `${sliceName3}/getDeviceConnect`,
1137
1141
  (id, { dispatch }) => general_api_default.get(`${deviceConnect}/devices/${id}`).then(
1138
1142
  ({ data }) => Promise.all([dispatch(actions3.receivedDevice({ connect_status: data.status, connect_updated_ts: data.updated_ts, id })), Promise.resolve(data)])
1139
1143
  )
1140
1144
  );
1141
1145
  var updateTypeMap = { deploymentUpdate: "check-update", inventoryUpdate: "send-inventory" };
1142
- var triggerDeviceUpdate = createAsyncThunk2(
1146
+ var triggerDeviceUpdate = createAppAsyncThunk(
1143
1147
  `${sliceName3}/triggerDeviceUpdate`,
1144
1148
  ({ id, type }, { dispatch }) => general_api_default.post(`${deviceConnect}/devices/${id}/${updateTypeMap[type] ?? updateTypeMap.deploymentUpdate}`).then(
1145
1149
  () => new Promise((resolve) => setTimeout(() => resolve(dispatch(getDeviceById2(id))), TIMEOUTS.threeSeconds))
1146
1150
  )
1147
1151
  );
1148
- var getSessionDetails = createAsyncThunk2(`${sliceName3}/getSessionDetails`, ({ sessionId, deviceId, userId, startDate, endDate }) => {
1149
- const { start: startUnix, end: endUnix } = dateRangeToUnix(startDate, endDate);
1150
- const createdAfter = startDate ? `&created_after=${startUnix}` : "";
1151
- const createdBefore = endDate ? `&created_before=${endUnix}` : "";
1152
- const objectSearch = `&object_id=${deviceId}`;
1153
- return general_api_default.get(`${auditLogsApiUrl}/logs?per_page=500${createdAfter}${createdBefore}&actor_id=${userId}${objectSearch}`).then(
1154
- ({ data: auditLogEntries }) => {
1155
- const { start, end } = auditLogEntries.reduce(
1156
- (accu, item) => {
1157
- if (item.meta?.session_id?.includes(sessionId)) {
1158
- accu.start = new Date(item.action.startsWith("open") ? item.time : accu.start);
1159
- accu.end = new Date(item.action.startsWith("close") ? item.time : accu.end);
1160
- }
1161
- return accu;
1162
- },
1163
- { start: startDate || endDate, end: endDate || startDate }
1164
- );
1165
- return Promise.resolve({ start, end });
1166
- }
1167
- );
1168
- });
1169
- var getDeviceFileDownloadLink = createAsyncThunk2(
1152
+ var getSessionDetails = createAppAsyncThunk(
1153
+ `${sliceName3}/getSessionDetails`,
1154
+ ({ sessionId, deviceId, userId, startDate, endDate }) => {
1155
+ const { start: startUnix, end: endUnix } = dateRangeToUnix(startDate, endDate);
1156
+ const createdAfter = startDate ? `&created_after=${startUnix}` : "";
1157
+ const createdBefore = endDate ? `&created_before=${endUnix}` : "";
1158
+ const objectSearch = `&object_id=${deviceId}`;
1159
+ return general_api_default.get(`${auditLogsApiUrl}/logs?per_page=500${createdAfter}${createdBefore}&actor_id=${userId}${objectSearch}`).then(
1160
+ ({ data: auditLogEntries }) => {
1161
+ const { start, end } = auditLogEntries.reduce(
1162
+ (accu, item) => {
1163
+ if (item.meta?.session_id?.includes(sessionId)) {
1164
+ accu.start = new Date(item.action.startsWith("open") ? item.time : accu.start);
1165
+ accu.end = new Date(item.action.startsWith("close") ? item.time : accu.end);
1166
+ }
1167
+ return accu;
1168
+ },
1169
+ { start: startDate || endDate, end: endDate || startDate }
1170
+ );
1171
+ return Promise.resolve({ start, end });
1172
+ }
1173
+ );
1174
+ }
1175
+ );
1176
+ var getDeviceFileDownloadLink = createAppAsyncThunk(
1170
1177
  `${sliceName3}/getDeviceFileDownloadLink`,
1171
1178
  ({ deviceId, path }) => Promise.resolve(`${window.location.origin}${deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
1172
1179
  );
1173
- var deviceFileUpload = createAsyncThunk2(`${sliceName3}/deviceFileUpload`, ({ deviceId, path, file }, { dispatch }) => {
1174
- let formData = new FormData();
1175
- formData.append("path", path);
1176
- formData.append("file", file);
1177
- const uploadId = uuid();
1178
- const cancelSource = new AbortController();
1179
- return Promise.all([
1180
- dispatch(setSnackbar2("Uploading file")),
1181
- dispatch(initUpload({ id: uploadId, upload: { inprogress: true, uploadProgress: 0, cancelSource } })),
1182
- general_api_default.uploadPut(
1183
- `${deviceConnect}/devices/${deviceId}/upload`,
1184
- formData,
1185
- (e) => dispatch(uploadProgress({ id: uploadId, progress: progress(e) })),
1186
- cancelSource.signal
1187
- )
1188
- ]).then(() => Promise.resolve(dispatch(setSnackbar2("Upload successful", TIMEOUTS.fiveSeconds)))).catch((err) => {
1189
- if (isCancel(err)) {
1190
- return dispatch(setSnackbar2("The upload has been cancelled", TIMEOUTS.fiveSeconds));
1191
- }
1192
- return commonErrorHandler(err, `Error uploading file to device.`, dispatch);
1193
- }).finally(() => dispatch(cleanUpUpload(uploadId)));
1194
- });
1195
- var getDeviceAuth = createAsyncThunk2(
1180
+ var deviceFileUpload = createAppAsyncThunk(
1181
+ `${sliceName3}/deviceFileUpload`,
1182
+ ({ deviceId, path, file }, { dispatch }) => {
1183
+ const formData = new FormData();
1184
+ formData.append("path", path);
1185
+ formData.append("file", file);
1186
+ const uploadId = uuid();
1187
+ const cancelSource = new AbortController();
1188
+ return Promise.all([
1189
+ dispatch(setSnackbar2("Uploading file")),
1190
+ dispatch(initUpload({ id: uploadId, upload: { progress: 0, cancelSource } })),
1191
+ general_api_default.uploadPut(
1192
+ `${deviceConnect}/devices/${deviceId}/upload`,
1193
+ formData,
1194
+ (e) => dispatch(uploadProgress({ id: uploadId, progress: progress(e) })),
1195
+ cancelSource.signal
1196
+ )
1197
+ ]).then(() => Promise.resolve(dispatch(setSnackbar2({ message: "Upload successful", autoHideDuration: TIMEOUTS.fiveSeconds })))).catch((err) => {
1198
+ if (isCancel(err)) {
1199
+ return dispatch(setSnackbar2({ message: "The upload has been cancelled", autoHideDuration: TIMEOUTS.fiveSeconds }));
1200
+ }
1201
+ return commonErrorHandler(err, `Error uploading file to device.`, dispatch);
1202
+ }).finally(() => dispatch(cleanUpUpload(uploadId)));
1203
+ }
1204
+ );
1205
+ var getDeviceAuth = createAppAsyncThunk(
1196
1206
  `${sliceName3}/getDeviceAuth`,
1197
1207
  (id, { dispatch }) => dispatch(getDevicesWithAuth([{ id }])).unwrap().then((results) => {
1198
1208
  if (results[results.length - 1]) {
@@ -1201,64 +1211,69 @@ var getDeviceAuth = createAsyncThunk2(
1201
1211
  return Promise.resolve();
1202
1212
  })
1203
1213
  );
1204
- var getDevicesWithAuth = createAsyncThunk2(
1214
+ var getDevicesWithAuth = createAppAsyncThunk(
1205
1215
  `${sliceName3}/getDevicesWithAuth`,
1206
1216
  (devices, { dispatch, getState }) => devices.length ? general_api_default.get(`${deviceAuthV2}/devices?id=${devices.map((device) => device.id).join("&id=")}`).then(({ data: receivedDevices }) => {
1207
1217
  const { devicesById } = reduceReceivedDevices(receivedDevices, [], getState());
1208
1218
  return Promise.all([dispatch(actions3.receivedDevices(devicesById)), Promise.resolve(receivedDevices)]);
1209
1219
  }).catch((err) => commonErrorHandler(err, `Error: ${err}`, dispatch)) : Promise.resolve([[], []])
1210
1220
  );
1211
- var updateDeviceAuth = createAsyncThunk2(
1221
+ var updateDeviceAuth = createAppAsyncThunk(
1212
1222
  `${sliceName3}/updateDeviceAuth`,
1213
1223
  ({ deviceId, authId, status }, { dispatch, getState }) => general_api_default.put(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar2("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions3.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getDeviceListState(getState()).refreshTrigger })))
1214
1224
  );
1215
- var updateDevicesAuth = createAsyncThunk2(`${sliceName3}/updateDevicesAuth`, ({ deviceIds, status }, { dispatch, getState }) => {
1216
- let devices = getDevicesById(getState());
1217
- const deviceIdsWithoutAuth = deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []);
1218
- return dispatch(getDevicesWithAuth(deviceIdsWithoutAuth)).then(() => {
1219
- devices = getDevicesById(getState());
1220
- const deviceAuthUpdates = deviceIds.map((id) => {
1221
- const device = devices[id];
1222
- if (device.auth_sets.length !== 1) {
1223
- return Promise.reject();
1224
- }
1225
- return dispatch(updateDeviceAuth({ authId: device.auth_sets[0].id, deviceId: device.id, status })).unwrap().catch((err) => commonErrorHandler(err, "The action was stopped as there was a problem updating a device authorization status: ", dispatch, "", false));
1226
- });
1227
- return Promise.allSettled(deviceAuthUpdates).then((results) => {
1228
- const { skipped, count } = results.reduce(
1229
- (accu, item) => {
1230
- if (item.status === "rejected") {
1231
- accu.skipped = accu.skipped + 1;
1232
- } else {
1233
- accu.count = accu.count + 1;
1234
- }
1235
- return accu;
1236
- },
1237
- { skipped: 0, count: 0 }
1238
- );
1239
- const message = getSnackbarMessage(skipped, count);
1240
- return dispatch(setSnackbar2(message));
1225
+ var updateDevicesAuth = createAppAsyncThunk(
1226
+ `${sliceName3}/updateDevicesAuth`,
1227
+ ({ deviceIds, status }, { dispatch, getState }) => {
1228
+ let devices = getDevicesById(getState());
1229
+ const deviceIdsWithoutAuth = deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []);
1230
+ return dispatch(getDevicesWithAuth(deviceIdsWithoutAuth)).then(() => {
1231
+ devices = getDevicesById(getState());
1232
+ const deviceAuthUpdates = deviceIds.map((id) => {
1233
+ const device = devices[id];
1234
+ if (device.auth_sets && device.auth_sets.length !== 1) {
1235
+ return Promise.reject();
1236
+ }
1237
+ return dispatch(updateDeviceAuth({ authId: device.auth_sets[0].id, deviceId: device.id, status })).unwrap().catch((err) => commonErrorHandler(err, "The action was stopped as there was a problem updating a device authorization status: ", dispatch, "", false));
1238
+ });
1239
+ return Promise.allSettled(deviceAuthUpdates).then((results) => {
1240
+ const { skipped, count } = results.reduce(
1241
+ (accu, item) => {
1242
+ if (item.status === "rejected") {
1243
+ accu.skipped = accu.skipped + 1;
1244
+ } else {
1245
+ accu.count = accu.count + 1;
1246
+ }
1247
+ return accu;
1248
+ },
1249
+ { skipped: 0, count: 0 }
1250
+ );
1251
+ const message = getSnackbarMessage(skipped, count);
1252
+ return dispatch(setSnackbar2(message));
1253
+ });
1241
1254
  });
1242
- });
1243
- });
1244
- var deleteAuthset = createAsyncThunk2(
1255
+ }
1256
+ );
1257
+ var deleteAuthset = createAppAsyncThunk(
1245
1258
  `${sliceName3}/deleteAuthset`,
1246
1259
  ({ deviceId, authId }, { dispatch, getState }) => general_api_default.delete(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}`).then(() => Promise.all([dispatch(setSnackbar2("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions3.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getState().devices.deviceList.refreshTrigger })))
1247
1260
  );
1248
- var preauthDevice = createAsyncThunk2(
1261
+ var preauthDevice = createAppAsyncThunk(
1249
1262
  `${sliceName3}/preauthDevice`,
1250
- (authset, { dispatch, rejectWithValue }) => general_api_default.post(`${deviceAuthV2}/devices`, authset).then(() => Promise.resolve(dispatch(setSnackbar2("Device was successfully added to the preauthorization list", TIMEOUTS.fiveSeconds)))).catch((err) => {
1263
+ (authset, { dispatch, rejectWithValue }) => general_api_default.post(`${deviceAuthV2}/devices`, authset).then(
1264
+ () => Promise.resolve(dispatch(setSnackbar2({ message: "Device was successfully added to the preauthorization list", autoHideDuration: TIMEOUTS.fiveSeconds })))
1265
+ ).catch((err) => {
1251
1266
  if (err.response.status === 409) {
1252
1267
  return rejectWithValue("A device with a matching identity data set already exists");
1253
1268
  }
1254
1269
  return commonErrorHandler(err, "The device could not be added:", dispatch);
1255
1270
  })
1256
1271
  );
1257
- var decommissionDevice = createAsyncThunk2(
1272
+ var decommissionDevice = createAppAsyncThunk(
1258
1273
  `${sliceName3}/decommissionDevice`,
1259
1274
  ({ deviceId, authId }, { dispatch, getState }) => general_api_default.delete(`${deviceAuthV2}/devices/${deviceId}`).then(() => Promise.resolve(dispatch(setSnackbar2("Device was decommissioned successfully")))).catch((err) => commonErrorHandler(err, "There was a problem decommissioning the device:", dispatch)).then(() => Promise.resolve(dispatch(actions3.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getState().devices.deviceList.refreshTrigger })))
1260
1275
  );
1261
- var getDeviceConfig = createAsyncThunk2(
1276
+ var getDeviceConfig = createAppAsyncThunk(
1262
1277
  `${sliceName3}/getDeviceConfig`,
1263
1278
  (deviceId, { dispatch }) => general_api_default.get(`${deviceConfig}/${deviceId}`).then(({ data }) => Promise.all([dispatch(actions3.receivedDevice({ id: deviceId, config: data })), Promise.resolve(data)])).catch((err) => {
1264
1279
  if (err.response?.data?.error.status_code !== 404) {
@@ -1266,16 +1281,16 @@ var getDeviceConfig = createAsyncThunk2(
1266
1281
  }
1267
1282
  })
1268
1283
  );
1269
- var setDeviceConfig = createAsyncThunk2(
1284
+ var setDeviceConfig = createAppAsyncThunk(
1270
1285
  `${sliceName3}/setDeviceConfig`,
1271
1286
  ({ deviceId, config }, { dispatch }) => general_api_default.put(`${deviceConfig}/${deviceId}`, config).catch((err) => commonErrorHandler(err, `There was an error setting the configuration for device ${deviceId}.`, dispatch, commonErrorFallback)).then(() => Promise.resolve(dispatch(getDeviceConfig(deviceId))))
1272
1287
  );
1273
- var applyDeviceConfig = createAsyncThunk2(
1288
+ var applyDeviceConfig = createAppAsyncThunk(
1274
1289
  `${sliceName3}/applyDeviceConfig`,
1275
1290
  ({ deviceId, configDeploymentConfiguration, isDefault, config }, { dispatch, getState }) => general_api_default.post(`${deviceConfig}/${deviceId}/deploy`, configDeploymentConfiguration).catch((err) => commonErrorHandler(err, `There was an error deploying the configuration to device ${deviceId}.`, dispatch, commonErrorFallback)).then(({ data }) => {
1276
1291
  const device = getDeviceById(getState(), deviceId);
1277
1292
  const { canManageUsers } = getUserCapabilities(getState());
1278
- let tasks = [
1293
+ const tasks = [
1279
1294
  dispatch(actions3.receivedDevice({ ...device, config: { ...device.config, deployment_id: data.deployment_id } })),
1280
1295
  new Promise((resolve) => setTimeout(() => resolve(dispatch(getSingleDeployment(data.deployment_id))), TIMEOUTS.oneSecond))
1281
1296
  ];
@@ -1286,21 +1301,24 @@ var applyDeviceConfig = createAsyncThunk2(
1286
1301
  return Promise.all(tasks);
1287
1302
  })
1288
1303
  );
1289
- var setDeviceTags = createAsyncThunk2(
1304
+ var setDeviceTags = createAppAsyncThunk(
1290
1305
  `${sliceName3}/setDeviceTags`,
1291
1306
  ({ deviceId, tags }, { dispatch }) => (
1292
1307
  // to prevent tag set failures, retrieve the device & use the freshest etag we can get
1293
- Promise.resolve(dispatch(getDeviceById2(deviceId))).then((device) => {
1308
+ dispatch(getDeviceById2(deviceId)).unwrap().then((device) => {
1294
1309
  const headers = device.etag ? { "If-Match": device.etag } : {};
1295
- return general_api_default.put(
1296
- `${inventoryApiUrl}/devices/${deviceId}/tags`,
1297
- Object.entries(tags).map(([name, value]) => ({ name, value })),
1298
- { headers }
1299
- ).catch((err) => commonErrorHandler(err, `There was an error setting tags for device ${deviceId}.`, dispatch, "Please check your connection.")).then(() => Promise.all([dispatch(actions3.receivedDevice({ ...device, id: deviceId, tags })), dispatch(setSnackbar2("Device name changed"))]));
1310
+ const tagList = Object.entries(tags).map(([name, value]) => ({ name, value }));
1311
+ const isNameChange = tagList.some(({ name }) => name === "name");
1312
+ return general_api_default.put(`${inventoryApiUrl}/devices/${deviceId}/tags`, tagList, { headers }).catch((err) => commonErrorHandler(err, `There was an error setting tags for device ${deviceId}.`, dispatch, "Please check your connection.")).then(
1313
+ () => Promise.all([
1314
+ dispatch(actions3.receivedDevice({ ...device, id: deviceId, tags })),
1315
+ dispatch(setSnackbar2(`Device ${tagList.length === 1 && isNameChange ? "name" : "tags"} changed`))
1316
+ ])
1317
+ );
1300
1318
  })
1301
1319
  )
1302
1320
  );
1303
- var getDeviceTwin = createAsyncThunk2(`${sliceName3}/getDeviceTwin`, ({ deviceId, integration }, { dispatch, getState }) => {
1321
+ var getDeviceTwin = createAppAsyncThunk(`${sliceName3}/getDeviceTwin`, ({ deviceId, integration }, { dispatch, getState }) => {
1304
1322
  let providerResult = {};
1305
1323
  return general_api_default.get(`${iotManagerBaseURL}/devices/${deviceId}/state`).then(({ data }) => {
1306
1324
  providerResult = { ...data, twinError: "" };
@@ -1313,7 +1331,7 @@ var getDeviceTwin = createAsyncThunk2(`${sliceName3}/getDeviceTwin`, ({ deviceId
1313
1331
  Promise.resolve(dispatch(actions3.receivedDevice({ ...device, twinsByIntegration: { ...device.twinsByIntegration, ...providerResult } })));
1314
1332
  });
1315
1333
  });
1316
- var setDeviceTwin = createAsyncThunk2(
1334
+ var setDeviceTwin = createAppAsyncThunk(
1317
1335
  `${sliceName3}/setDeviceTwin`,
1318
1336
  ({ deviceId, integration, settings }, { dispatch, getState }) => general_api_default.put(`${iotManagerBaseURL}/devices/${deviceId}/state/${integration.id}`, { desired: settings }).catch(
1319
1337
  (err) => commonErrorHandler(
@@ -1326,7 +1344,9 @@ var setDeviceTwin = createAsyncThunk2(
1326
1344
  const { twinsByIntegration = {} } = device;
1327
1345
  const { [integration.id]: currentState = {} } = twinsByIntegration;
1328
1346
  return Promise.resolve(
1329
- dispatch(actions3.receivedDevice({ ...device, twinsByIntegration: { ...twinsByIntegration, [integration.id]: { ...currentState, desired: settings } } }))
1347
+ dispatch(
1348
+ actions3.receivedDevice({ ...device, twinsByIntegration: { ...twinsByIntegration, [integration.id]: { ...currentState, desired: settings } } })
1349
+ )
1330
1350
  );
1331
1351
  })
1332
1352
  );
@@ -1337,7 +1357,7 @@ var prepareSearchArguments = ({ filters, group, state, status }) => {
1337
1357
  const attributes = [...defaultAttributes, getIdAttribute(state), ...selectedAttributes];
1338
1358
  return { attributes, filterTerms };
1339
1359
  };
1340
- var getSystemDevices = createAsyncThunk2(`${sliceName3}/getSystemDevices`, (options, { dispatch, getState }) => {
1360
+ var getSystemDevices = createAppAsyncThunk(`${sliceName3}/getSystemDevices`, (options, { dispatch, getState }) => {
1341
1361
  const { id, page = defaultPage2, perPage = defaultPerPage2, sortOptions = [] } = options;
1342
1362
  const state = getState();
1343
1363
  const { hasFullFiltering } = getTenantCapabilities(state);
@@ -1368,7 +1388,7 @@ var getSystemDevices = createAsyncThunk2(`${sliceName3}/getSystemDevices`, (opti
1368
1388
  return Promise.resolve(dispatch(actions3.receivedDevices({ ...devicesById, [id]: device })));
1369
1389
  });
1370
1390
  });
1371
- var getGatewayDevices = createAsyncThunk2(`${sliceName3}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
1391
+ var getGatewayDevices = createAppAsyncThunk(`${sliceName3}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
1372
1392
  const state = getState();
1373
1393
  const { attributes = {} } = getDeviceById(state, deviceId);
1374
1394
  const { mender_gateway_system_id = "" } = attributes;
@@ -1385,53 +1405,26 @@ var getGatewayDevices = createAsyncThunk2(`${sliceName3}/getGatewayDevices`, (de
1385
1405
  attributes: attributeSelection
1386
1406
  }).then(({ data }) => {
1387
1407
  const { ids } = reduceReceivedDevices(data, [], getState());
1388
- let tasks = ids.map((deviceId2) => dispatch(getDeviceInfo(deviceId2)));
1408
+ const tasks = ids.map((deviceId2) => dispatch(getDeviceInfo(deviceId2)));
1389
1409
  tasks.push(dispatch(actions3.receivedDevice({ id: deviceId, gatewayIds: ids })));
1390
1410
  return Promise.all(tasks);
1391
1411
  });
1392
1412
  });
1393
- var getDevicesInBounds = createAsyncThunk2(`${sliceName3}/getDevicesInBounds`, ({ bounds, group }, { dispatch, getState }) => {
1394
- const state = getState();
1395
- const { filterTerms } = convertDeviceListStateToFilters({
1396
- group: group === ALL_DEVICES ? void 0 : group,
1397
- groups: state.devices.groups,
1398
- status: DEVICE_STATES.accepted
1399
- });
1400
- return general_api_default.post(getSearchEndpoint(getState()), {
1401
- page: 1,
1402
- per_page: MAX_PAGE_SIZE,
1403
- filters: filterTerms,
1404
- attributes: geoAttributes,
1405
- geo_bounding_box_filter: {
1406
- geo_bounding_box: {
1407
- location: {
1408
- top_left: { lat: bounds._northEast.lat, lon: bounds._southWest.lng },
1409
- bottom_right: { lat: bounds._southWest.lat, lon: bounds._northEast.lng }
1410
- }
1411
- }
1412
- }
1413
- }).then(({ data }) => {
1414
- const { devicesById } = reduceReceivedDevices(data, [], getState());
1415
- return Promise.resolve(dispatch(actions3.receivedDevices(devicesById)));
1416
- });
1417
- });
1418
1413
 
1419
1414
  // src/onboardingSlice/thunks.ts
1420
1415
  import { getDemoDeviceAddress } from "@northern.tech/utils/helpers";
1421
- import { onboardingSteps as onboardingSteps2 } from "@northern.tech/utils/onboardingManager";
1422
1416
  import Tracking2 from "@northern.tech/utils/tracking";
1423
- import { createAsyncThunk as createAsyncThunk3 } from "@reduxjs/toolkit";
1424
1417
  import Cookies from "universal-cookie";
1425
1418
  var cookies = new Cookies();
1426
1419
  var applyOnboardingFallbacks = (progress2) => {
1427
- const step = onboardingSteps2[progress2];
1420
+ const step = orderedOnboardingSteps[progress2];
1428
1421
  if (step && step.fallbackStep) {
1429
1422
  return step.fallbackStep;
1430
1423
  }
1431
1424
  return progress2;
1432
1425
  };
1433
1426
  var determineProgress = (acceptedDevices, pendingDevices, releases, pastDeployments) => {
1434
- const steps = Object.keys(onboardingSteps2);
1427
+ const steps = orderedOnboardingSteps;
1435
1428
  let progress2 = -1;
1436
1429
  progress2 = pendingDevices.length > 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING) : progress2;
1437
1430
  progress2 = acceptedDevices.length >= 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_ACCEPTED_ONBOARDING) : progress2;
@@ -1448,14 +1441,14 @@ var deductOnboardingState = ({ devicesById, devicesByStatus, onboardingState, pa
1448
1441
  const progress2 = applyOnboardingFallbacks(onboardingState.progress || determineProgress(acceptedDevices, pendingDevices, releases, pastDeployments));
1449
1442
  return {
1450
1443
  ...onboardingState,
1451
- complete: !!(Boolean(userCookie) || onboardingState.complete || acceptedDevices.length > 1 && pendingDevices.length > 0 && releases.length > 1 && pastDeployments.length > 1 || acceptedDevices.length >= 1 && releases.length >= 2 && pastDeployments.length > 2 || acceptedDevices.length >= 1 && pendingDevices.length > 0 && releases.length >= 2 && pastDeployments.length >= 2 || Object.keys(onboardingSteps2).findIndex((step) => step === progress2) >= Object.keys(onboardingSteps2).length - 1 || onboardingState.disable || ![canDeploy, canManageDevices, canReadDeployments, canReadDevices, canReadReleases, canUploadReleases].every((i) => i)),
1444
+ complete: !!(Boolean(userCookie) || onboardingState.complete || acceptedDevices.length > 1 && pendingDevices.length > 0 && releases.length > 1 && pastDeployments.length > 1 || acceptedDevices.length >= 1 && releases.length >= 2 && pastDeployments.length > 2 || acceptedDevices.length >= 1 && pendingDevices.length > 0 && releases.length >= 2 && pastDeployments.length >= 2 || orderedOnboardingSteps.findIndex((step) => step === progress2) >= orderedOnboardingSteps.length - 1 || onboardingState.disable || ![canDeploy, canManageDevices, canReadDeployments, canReadDevices, canReadReleases, canUploadReleases].every((i) => i)),
1452
1445
  showTips: onboardingState.showTips != null ? onboardingState.showTips : true,
1453
1446
  deviceType,
1454
1447
  approach: onboardingState.approach || (deviceType.some((type) => type.startsWith("qemu")) ? "virtual" : "physical"),
1455
1448
  progress: progress2
1456
1449
  };
1457
1450
  };
1458
- var getOnboardingState2 = createAsyncThunk3(`${sliceName4}/getOnboardingState`, (_, { dispatch, getState }) => {
1451
+ var getOnboardingState2 = createAppAsyncThunk(`${sliceName4}/getOnboardingState`, (_, { dispatch, getState }) => {
1459
1452
  const state = getState();
1460
1453
  let onboardingState = getOnboardingState(state);
1461
1454
  if (!onboardingState.complete) {
@@ -1479,32 +1472,32 @@ var getOnboardingState2 = createAsyncThunk3(`${sliceName4}/getOnboardingState`,
1479
1472
  dispatch(saveUserSettings({ onboarding: onboardingState }))
1480
1473
  ]);
1481
1474
  });
1482
- var setOnboardingDeviceType = createAsyncThunk3(
1475
+ var setOnboardingDeviceType = createAppAsyncThunk(
1483
1476
  `${sliceName4}/setOnboardingDeviceType`,
1484
1477
  (value, { dispatch }) => Promise.all([dispatch(actions4.setOnboardingDeviceType(value)), dispatch(saveUserSettings({ onboarding: { deviceType: value } }))])
1485
1478
  );
1486
- var setOnboardingApproach = createAsyncThunk3(
1479
+ var setOnboardingApproach = createAppAsyncThunk(
1487
1480
  `${sliceName4}/setOnboardingApproach`,
1488
1481
  (value, { dispatch }) => Promise.all([dispatch(actions4.setOnboardingApproach(value)), dispatch(saveUserSettings({ onboarding: { approach: value } }))])
1489
1482
  );
1490
- var setOnboardingComplete = createAsyncThunk3(`${sliceName4}/setOnboardingComplete`, (value, { dispatch }) => {
1491
- let tasks = [Promise.resolve(dispatch(actions4.setOnboardingComplete(value)))];
1483
+ var setOnboardingComplete = createAppAsyncThunk(`${sliceName4}/setOnboardingComplete`, (value, { dispatch }) => {
1484
+ const tasks = [Promise.resolve(dispatch(actions4.setOnboardingComplete(value)))];
1492
1485
  if (value) {
1493
1486
  tasks.push(Promise.resolve(dispatch(actions4.setShowOnboardingHelp(false))));
1494
1487
  tasks.push(Promise.resolve(dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED))));
1495
1488
  }
1496
1489
  return Promise.all(tasks);
1497
1490
  });
1498
- var setOnboardingCanceled = createAsyncThunk3(
1491
+ var setOnboardingCanceled = createAppAsyncThunk(
1499
1492
  `${sliceName4}/setOnboardingCanceled`,
1500
1493
  (_, { dispatch }) => Promise.all([
1501
1494
  Promise.resolve(dispatch(actions4.setShowOnboardingHelp(false))),
1502
1495
  Promise.resolve(dispatch(actions4.setShowDismissOnboardingTipsDialog(false))),
1503
1496
  Promise.resolve(dispatch(actions4.setOnboardingComplete(true)))
1504
- ]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE))).then(() => Tracking2.event({ category: "onboarding", action: onboardingSteps2.ONBOARDING_CANCELED }))
1497
+ ]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE))).then(() => Tracking2.event({ category: "onboarding", action: onboardingSteps.ONBOARDING_CANCELED }))
1505
1498
  );
1506
- var advanceOnboarding = createAsyncThunk3(`${sliceName4}/advanceOnboarding`, (stepId, { dispatch, getState }) => {
1507
- const steps = Object.keys(onboardingSteps2);
1499
+ var advanceOnboarding = createAppAsyncThunk(`${sliceName4}/advanceOnboarding`, (stepId, { dispatch, getState }) => {
1500
+ const steps = orderedOnboardingSteps;
1508
1501
  const progress2 = steps.findIndex((step) => step === getState().onboarding.progress);
1509
1502
  const stepIndex = steps.findIndex((step) => step === stepId);
1510
1503
  if (progress2 > stepIndex || getState().onboarding.progress === null) {
@@ -1512,21 +1505,24 @@ var advanceOnboarding = createAsyncThunk3(`${sliceName4}/advanceOnboarding`, (st
1512
1505
  }
1513
1506
  const madeProgress = steps[stepIndex + 1];
1514
1507
  const state = { ...getOnboardingState(getState()), progress: madeProgress };
1515
- state.complete = stepIndex + 1 >= Object.keys(onboardingSteps2).findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE) ? true : state.complete;
1508
+ state.complete = stepIndex + 1 >= orderedOnboardingSteps.findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE) ? true : state.complete;
1516
1509
  Tracking2.event({ category: "onboarding", action: stepId });
1517
1510
  return Promise.all([dispatch(actions4.setOnboardingProgress(madeProgress)), dispatch(saveUserSettings({ onboarding: state }))]);
1518
1511
  });
1519
1512
 
1520
1513
  // src/organizationSlice/thunks.ts
1514
+ import { PreviewRequest as PreviewRequestEnum } from "@northern.tech/types/MenderTypes";
1521
1515
  import { dateRangeToUnix as dateRangeToUnix2, deepCompare as deepCompare3 } from "@northern.tech/utils/helpers";
1522
- import { createAsyncThunk as createAsyncThunk4 } from "@reduxjs/toolkit";
1516
+ import dayjs from "dayjs";
1517
+ import utc from "dayjs/plugin/utc";
1523
1518
  import { jwtDecode } from "jwt-decode";
1524
1519
  import hashString from "md5";
1525
1520
  import Cookies2 from "universal-cookie";
1526
1521
  var cookies2 = new Cookies2();
1522
+ dayjs.extend(utc);
1527
1523
  var { setAnnouncement, setSnackbar: setSnackbar3 } = actions_default;
1528
1524
  var { page: defaultPage3, perPage: defaultPerPage3 } = DEVICE_LIST_DEFAULTS;
1529
- var cancelRequest = createAsyncThunk4(`${sliceName5}/cancelRequest`, (reason, { dispatch, getState }) => {
1525
+ var cancelRequest = createAppAsyncThunk(`${sliceName5}/cancelRequest`, (reason, { dispatch, getState }) => {
1530
1526
  const { id: tenantId } = getOrganization(getState());
1531
1527
  return general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/cancel`, { reason }).then(
1532
1528
  () => Promise.resolve(dispatch(setSnackbar3({ message: "Deactivation request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds })))
@@ -1545,7 +1541,7 @@ var getTargetLocation = (key) => {
1545
1541
  return `https://${window.location.hostname}`;
1546
1542
  };
1547
1543
  var devLocations = ["localhost", "docker.mender.io"];
1548
- var createOrganizationTrial = createAsyncThunk4(`${sliceName5}/createOrganizationTrial`, (data, { dispatch }) => {
1544
+ var createOrganizationTrial = createAppAsyncThunk(`${sliceName5}/createOrganizationTrial`, (data, { dispatch }) => {
1549
1545
  const { key } = locations[data.location];
1550
1546
  const targetLocation = getTargetLocation(key);
1551
1547
  const target = `${targetLocation}${tenantadmApiUrlv2}/tenants/trial`;
@@ -1567,36 +1563,46 @@ var createOrganizationTrial = createAsyncThunk4(`${sliceName5}/createOrganizatio
1567
1563
  );
1568
1564
  });
1569
1565
  });
1570
- var startCardUpdate = createAsyncThunk4(
1566
+ var startCardUpdate = createAppAsyncThunk(
1571
1567
  `${sliceName5}/startCardUpdate`,
1572
1568
  (_, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/card`).then(({ data }) => {
1573
1569
  dispatch(actions5.receiveSetupIntent(data.intent_id));
1574
1570
  return Promise.resolve(data.secret);
1575
1571
  }).catch((err) => commonErrorHandler(err, `Updating the card failed:`, dispatch))
1576
1572
  );
1577
- var confirmCardUpdate = createAsyncThunk4(
1573
+ var confirmCardUpdate = createAppAsyncThunk(
1578
1574
  `${sliceName5}/confirmCardUpdate`,
1579
1575
  (_, { dispatch, getState }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/card/${getState().organization.intentId}/confirm`).then(() => Promise.all([dispatch(setSnackbar3("Payment card was updated successfully")), dispatch(actions5.receiveSetupIntent(null))])).catch((err) => commonErrorHandler(err, `Updating the card failed:`, dispatch))
1580
1576
  );
1581
- var getCurrentCard = createAsyncThunk4(
1577
+ var getCurrentCard = createAppAsyncThunk(
1582
1578
  `${sliceName5}/getCurrentCard`,
1583
1579
  (_, { dispatch }) => general_api_default.get(`${tenantadmApiUrlv2}/billing`).then((res) => {
1584
1580
  const { last4, exp_month, exp_year, brand } = res.data.card || {};
1585
1581
  return Promise.resolve(dispatch(actions5.receiveCurrentCard({ brand, last4, expiration: { month: exp_month, year: exp_year } })));
1586
1582
  })
1587
1583
  );
1588
- var startUpgrade = createAsyncThunk4(
1584
+ var startUpgrade = createAppAsyncThunk(
1589
1585
  `${sliceName5}/startUpgrade`,
1590
1586
  (tenantId, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/start`).then(({ data }) => Promise.resolve(data.secret)).catch((err) => commonErrorHandler(err, `There was an error upgrading your account:`, dispatch))
1591
1587
  );
1592
- var cancelUpgrade = createAsyncThunk4(`${sliceName5}/cancelUpgrade`, (tenantId) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/cancel`));
1593
- var completeUpgrade = createAsyncThunk4(
1588
+ var cancelUpgrade = createAppAsyncThunk(
1589
+ `${sliceName5}/cancelUpgrade`,
1590
+ (tenantId) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/cancel`)
1591
+ );
1592
+ var completeUpgrade = createAppAsyncThunk(
1594
1593
  `${sliceName5}/completeUpgrade`,
1595
1594
  ({ tenantId, plan, billing_profile }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/complete`, { plan, billing_profile }).catch((err) => commonErrorHandler(err, `There was an error upgrading your account:`, dispatch)).then(() => Promise.all([dispatch(getDeviceLimit()), dispatch(getUserOrganization())]))
1596
1595
  );
1597
- var prepareAuditlogQuery = ({ startDate, endDate, user: userFilter, type, detail: detailFilter, sort = {} }) => {
1598
- const userId = userFilter?.id || userFilter;
1599
- const detail = detailFilter?.id || detailFilter;
1596
+ var prepareAuditlogQuery = ({
1597
+ startDate,
1598
+ endDate,
1599
+ user: userFilter,
1600
+ type,
1601
+ detail: detailFilter,
1602
+ sort = { direction: SORTING_OPTIONS.desc }
1603
+ }) => {
1604
+ const userId = typeof userFilter === "object" && userFilter ? userFilter.id : userFilter;
1605
+ const detail = typeof detailFilter === "object" && detailFilter ? detailFilter.id : detailFilter;
1600
1606
  const { start: startUnix, end: endUnix } = dateRangeToUnix2(startDate, endDate);
1601
1607
  const createdAfter = startDate ? `&created_after=${startUnix}` : "";
1602
1608
  const createdBefore = endDate ? `&created_before=${endUnix}` : "";
@@ -1606,7 +1612,7 @@ var prepareAuditlogQuery = ({ startDate, endDate, user: userFilter, type, detail
1606
1612
  const { direction = SORTING_OPTIONS.desc } = sort;
1607
1613
  return `${createdAfter}${createdBefore}${userSearch}${typeSearch}${objectSearch}&sort=${direction}`;
1608
1614
  };
1609
- var getAuditLogs = createAsyncThunk4(`${sliceName5}/getAuditLogs`, (selectionState, { dispatch, getState }) => {
1615
+ var getAuditLogs = createAppAsyncThunk(`${sliceName5}/getAuditLogs`, (selectionState, { dispatch, getState }) => {
1610
1616
  const { page, perPage } = selectionState;
1611
1617
  const { hasAuditlogs } = getTenantCapabilities(getState());
1612
1618
  if (!hasAuditlogs) {
@@ -1618,36 +1624,40 @@ var getAuditLogs = createAsyncThunk4(`${sliceName5}/getAuditLogs`, (selectionSta
1618
1624
  return Promise.resolve(dispatch(actions5.receiveAuditLogs({ events: data, total })));
1619
1625
  }).catch((err) => commonErrorHandler(err, `There was an error retrieving audit logs:`, dispatch));
1620
1626
  });
1621
- var getAuditLogsCsvLink = createAsyncThunk4(
1627
+ var getAuditLogsCsvLink = createAppAsyncThunk(
1622
1628
  `${sliceName5}/getAuditLogsCsvLink`,
1623
1629
  (_, { getState }) => Promise.resolve(`${window.location.origin}${auditLogsApiUrl}/logs/export?limit=20000${prepareAuditlogQuery(getAuditlogState(getState()))}`)
1624
1630
  );
1625
- var setAuditlogsState = createAsyncThunk4(`${sliceName5}/setAuditlogsState`, (selectionState, { dispatch, getState }) => {
1626
- const currentState = getAuditlogState(getState());
1627
- let nextState = {
1628
- ...currentState,
1629
- ...selectionState,
1630
- sort: { ...currentState.sort, ...selectionState.sort }
1631
- };
1632
- let tasks = [];
1633
- const { isLoading: currentLoading, selectedIssue: currentIssue, ...currentRequestState } = currentState;
1634
- const { isLoading: selectionLoading, selectedIssue: selectionIssue, ...selectionRequestState } = nextState;
1635
- if (!deepCompare3(currentRequestState, selectionRequestState)) {
1636
- nextState.isLoading = true;
1637
- tasks.push(dispatch(getAuditLogs(nextState)).finally(() => dispatch(actions5.setAuditLogState({ isLoading: false }))));
1631
+ var setAuditlogsState = createAppAsyncThunk(
1632
+ `${sliceName5}/setAuditlogsState`,
1633
+ (selectionState, { dispatch, getState }) => {
1634
+ const currentState = getAuditlogState(getState());
1635
+ const nextState = {
1636
+ ...currentState,
1637
+ ...selectionState,
1638
+ sort: { ...currentState.sort, ...selectionState.sort }
1639
+ };
1640
+ const tasks = [];
1641
+ const { isLoading: currentLoading, selectedIssue: currentIssue, ...currentRequestState } = currentState;
1642
+ const { isLoading: selectionLoading, selectedIssue: selectionIssue, ...selectionRequestState } = nextState;
1643
+ if (!deepCompare3(currentRequestState, selectionRequestState)) {
1644
+ nextState.isLoading = true;
1645
+ tasks.push(dispatch(getAuditLogs(nextState)).finally(() => dispatch(actions5.setAuditLogState({ isLoading: false }))));
1646
+ }
1647
+ tasks.push(dispatch(actions5.setAuditLogState(nextState)));
1648
+ return Promise.all(tasks);
1638
1649
  }
1639
- tasks.push(dispatch(actions5.setAuditLogState(nextState)));
1640
- return Promise.all(tasks);
1641
- });
1650
+ );
1642
1651
  var tenantDataDivergedMessage = "The system detected there is a change in your plan or purchased add-ons. Please log out and log in again";
1643
- var addTenant = createAsyncThunk4(`${sliceName5}/createTenant`, (selectionState, { dispatch }) => {
1644
- return general_api_default.post(`${tenantadmApiUrlv2}/tenants`, selectionState).then(
1652
+ var addTenant = createAppAsyncThunk(
1653
+ `${sliceName5}/createTenant`,
1654
+ (selectionState, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants`, selectionState).then(
1645
1655
  () => Promise.all([
1646
1656
  dispatch(setSnackbar3("Tenant was created successfully.")),
1647
1657
  new Promise((resolve) => setTimeout(() => resolve(dispatch(getTenants())), TIMEOUTS.oneSecond))
1648
1658
  ])
1649
- ).catch((err) => commonErrorHandler(err, "There was an error creating tenant", dispatch, commonErrorFallback));
1650
- });
1659
+ ).catch((err) => commonErrorHandler(err, "There was an error creating tenant", dispatch, commonErrorFallback))
1660
+ );
1651
1661
  var tenantListRetrieval = async (config) => {
1652
1662
  const { page, perPage } = config;
1653
1663
  const params = new URLSearchParams({ page, per_page: perPage }).toString();
@@ -1655,44 +1665,58 @@ var tenantListRetrieval = async (config) => {
1655
1665
  const totalCount = tenantList.headers[headerNames.total] || TENANT_LIST_DEFAULT.perPage;
1656
1666
  return [tenantList.data, Number(totalCount)];
1657
1667
  };
1658
- var getTenants = createAsyncThunk4(`${sliceName5}/getTenants`, async (_, { dispatch, getState }) => {
1668
+ var getTenants = createAppAsyncThunk(`${sliceName5}/getTenants`, async (_, { dispatch, getState }) => {
1659
1669
  const currentState = getTenantsList(getState());
1660
1670
  const [tenants, pageCount] = await tenantListRetrieval(currentState);
1661
1671
  dispatch(actions5.setTenantListState({ ...currentState, total: pageCount, tenants }));
1662
1672
  });
1663
- var setTenantsListState = createAsyncThunk4(`${sliceName5}/setTenantsListState`, async (selectionState, { dispatch, getState }) => {
1664
- const currentState = getTenantsList(getState());
1665
- const nextState = {
1666
- ...currentState,
1667
- ...selectionState
1668
- };
1669
- if (!deepCompare3(currentState, selectionState)) {
1670
- const [tenants, pageCount] = await tenantListRetrieval(nextState);
1671
- return dispatch(actions5.setTenantListState({ ...nextState, tenants, total: pageCount }));
1673
+ var setTenantsListState = createAppAsyncThunk(
1674
+ `${sliceName5}/setTenantsListState`,
1675
+ async (selectionState, { dispatch, getState }) => {
1676
+ const currentState = getTenantsList(getState());
1677
+ const nextState = {
1678
+ ...currentState,
1679
+ ...selectionState
1680
+ };
1681
+ if (!deepCompare3(currentState, selectionState)) {
1682
+ const [tenants, pageCount] = await tenantListRetrieval(nextState);
1683
+ return dispatch(actions5.setTenantListState({ ...nextState, tenants, total: pageCount }));
1684
+ }
1685
+ return dispatch(actions5.setTenantListState({ ...nextState }));
1672
1686
  }
1673
- return dispatch(actions5.setTenantListState({ ...nextState }));
1674
- });
1675
- var editTenantDeviceLimit = createAsyncThunk4(`${sliceName5}/editDeviceLimit`, ({ newLimit, id, name }, { dispatch }) => {
1676
- return general_api_default.put(`${tenantadmApiUrlv2}/tenants/${id}/child`, { device_limit: newLimit, name }).catch((err) => commonErrorHandler(err, `Device Limit cannot be changed`, dispatch)).then(() => {
1677
- return Promise.all([
1687
+ );
1688
+ var editTenantDeviceLimit = createAppAsyncThunk(
1689
+ `${sliceName5}/editDeviceLimit`,
1690
+ ({ newLimit, id, name }, { dispatch }) => general_api_default.put(`${tenantadmApiUrlv2}/tenants/${id}/child`, { device_limit: newLimit, name }).catch((err) => commonErrorHandler(err, `Device Limit cannot be changed`, dispatch)).then(
1691
+ () => Promise.all([
1678
1692
  dispatch(setSnackbar3("Device Limit was changed successfully")),
1679
1693
  dispatch(getUserOrganization()),
1680
1694
  new Promise((resolve) => setTimeout(() => resolve(dispatch(getTenants())), TIMEOUTS.oneSecond))
1681
- ]);
1682
- });
1683
- });
1684
- var removeTenant = createAsyncThunk4(`${sliceName5}/editDeviceLimit`, ({ id }, { dispatch }) => {
1685
- return general_api_default.post(`${tenantadmApiUrlv2}/tenants/${id}/remove/start`).catch((err) => commonErrorHandler(err, `There was an error removing the tenant`, dispatch)).then(
1695
+ ])
1696
+ )
1697
+ );
1698
+ var editBillingProfile = createAppAsyncThunk(
1699
+ `${sliceName5}/editBillingProfileEmail`,
1700
+ ({ billingProfile }, { dispatch }) => general_api_default.patch(`${tenantadmApiUrlv2}/billing/profile`, billingProfile).catch((err) => commonErrorHandler(err, `Failed to change billing profile`, dispatch)).then(() => Promise.all([dispatch(setSnackbar3("Billing Profile was changed successfully")), dispatch(getUserBilling())]))
1701
+ );
1702
+ var createBillingProfile = createAppAsyncThunk(
1703
+ `${sliceName5}/createBillingProfileEmail`,
1704
+ ({ billingProfile }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/profile`, billingProfile).catch((err) => commonErrorHandler(err, `Failed to create billing profile`, dispatch)).then(() => Promise.all([dispatch(setSnackbar3("Billing Profile was created successfully")), dispatch(getUserBilling())]))
1705
+ );
1706
+ var removeTenant = createAppAsyncThunk(
1707
+ `${sliceName5}/editDeviceLimit`,
1708
+ ({ id }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${id}/remove/start`).catch((err) => commonErrorHandler(err, `There was an error removing the tenant`, dispatch)).then(
1686
1709
  () => Promise.all([
1687
1710
  dispatch(setSnackbar3("The tenant was removed successfully")),
1688
1711
  dispatch(getUserOrganization()),
1689
1712
  new Promise((resolve) => setTimeout(() => resolve(dispatch(getTenants())), TIMEOUTS.oneSecond))
1690
1713
  ])
1691
- );
1692
- });
1693
- var getUserOrganization = createAsyncThunk4(`${sliceName5}/getUserOrganization`, (_, { dispatch, getState }) => {
1694
- return general_api_default.get(`${tenantadmApiUrlv1}/user/tenant`).then((res) => {
1695
- let tasks = [dispatch(actions5.setOrganization(res.data))];
1714
+ )
1715
+ );
1716
+ var getUserOrganization = createAppAsyncThunk(
1717
+ `${sliceName5}/getUserOrganization`,
1718
+ (_, { dispatch, getState }) => general_api_default.get(`${tenantadmApiUrlv1}/user/tenant`).then((res) => {
1719
+ const tasks = [dispatch(actions5.setOrganization(res.data))];
1696
1720
  const { addons, plan, trial } = res.data;
1697
1721
  const { token } = getCurrentSession(getState());
1698
1722
  const jwt = jwtDecode(token);
@@ -1703,32 +1727,61 @@ var getUserOrganization = createAsyncThunk4(`${sliceName5}/getUserOrganization`,
1703
1727
  tasks.push(dispatch(setAnnouncement(tenantDataDivergedMessage)));
1704
1728
  }
1705
1729
  return Promise.all(tasks);
1706
- });
1730
+ })
1731
+ );
1732
+ var getUserBilling = createAppAsyncThunk(
1733
+ `${sliceName5}/getUserBilling`,
1734
+ (_, { dispatch }) => general_api_default.get(`${tenantadmApiUrlv2}/billing/profile`).then((res) => dispatch(actions5.setBillingProfile(res.data)))
1735
+ );
1736
+ var getUserSubscription = createAppAsyncThunk(`${sliceName5}/getUserSubscription`, (_, { dispatch }) => {
1737
+ const tasks = [dispatch(getBillingPreview({ preview_mode: PreviewRequestEnum.preview_mode.NEXT })).unwrap(), dispatch(getCurrentSubscription()).unwrap()];
1738
+ Promise.all(tasks).then(([currentPreview, currentSubscription]) => dispatch(actions5.setSubscription({ ...currentPreview, ...currentSubscription })));
1707
1739
  });
1708
- var sendSupportMessage = createAsyncThunk4(
1740
+ var getBillingPreview = createAppAsyncThunk(
1741
+ `${sliceName5}/getBillingPreview`,
1742
+ (order) => general_api_default.post(`${tenantadmApiUrlv2}/billing/subscription/invoices/preview`, order).then(
1743
+ ({ data }) => order.preview_mode === "recurring" ? { ...parseSubscriptionPreview(data.lines), total: data.total } : data
1744
+ )
1745
+ );
1746
+ var getCurrentSubscription = createAppAsyncThunk(
1747
+ `${sliceName5}/getCurrentSubscription`,
1748
+ () => general_api_default.get(`${tenantadmApiUrlv2}/billing/subscription`).then((res) => res.data)
1749
+ );
1750
+ var successMessage = (planId) => `Thank you! You have successfully subscribed to the ${PLANS[planId].name} plan. You can view and edit your billing details on the Organization and billing page.`;
1751
+ var requestPlanUpgrade = createAppAsyncThunk(
1752
+ `${sliceName5}/requestPlanUpgrade`,
1753
+ (order, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/subscription`, order).catch((err) => commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback)).then(
1754
+ () => Promise.all([
1755
+ dispatch(setSnackbar3(successMessage(order.plan))),
1756
+ setTimeout(() => dispatch(getDeviceLimit()), TIMEOUTS.threeSeconds),
1757
+ dispatch(getUserOrganization())
1758
+ ])
1759
+ )
1760
+ );
1761
+ var sendSupportMessage = createAppAsyncThunk(
1709
1762
  `${sliceName5}/sendSupportMessage`,
1710
1763
  (content, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/contact/support`, content).catch((err) => commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback)).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Your request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))))
1711
1764
  );
1712
- var requestPlanChange = createAsyncThunk4(
1765
+ var requestPlanChange = createAppAsyncThunk(
1713
1766
  `${sliceName5}/requestPlanChange`,
1714
1767
  ({ content, tenantId }, { dispatch, rejectWithValue }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/plan`, content).catch(async (err) => {
1715
1768
  await commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback);
1716
1769
  rejectWithValue(err);
1717
1770
  }).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Your request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))))
1718
1771
  );
1719
- var downloadLicenseReport = createAsyncThunk4(
1772
+ var downloadLicenseReport = createAppAsyncThunk(
1720
1773
  `${sliceName5}/downloadLicenseReport`,
1721
1774
  (_, { dispatch }) => general_api_default.get(`${deviceAuthV2}/reports/devices`).catch((err) => commonErrorHandler(err, "There was an error downloading the report", dispatch, commonErrorFallback)).then((res) => res.data)
1722
1775
  );
1723
- var createIntegration = createAsyncThunk4(
1776
+ var createIntegration = createAppAsyncThunk(
1724
1777
  `${sliceName5}/createIntegration`,
1725
1778
  ({ id, ...integration }, { dispatch }) => general_api_default.post(`${iotManagerBaseURL}/integrations`, integration).catch((err) => commonErrorHandler(err, "There was an error creating the integration", dispatch, commonErrorFallback)).then(() => Promise.all([dispatch(setSnackbar3("The integration was set up successfully")), dispatch(getIntegrations())]))
1726
1779
  );
1727
- var changeIntegration = createAsyncThunk4(
1780
+ var changeIntegration = createAppAsyncThunk(
1728
1781
  `${sliceName5}/changeIntegration`,
1729
1782
  ({ id, credentials }, { dispatch }) => general_api_default.put(`${iotManagerBaseURL}/integrations/${id}/credentials`, credentials).catch((err) => commonErrorHandler(err, "There was an error updating the integration", dispatch, commonErrorFallback)).then(() => Promise.all([dispatch(setSnackbar3("The integration was updated successfully")), dispatch(getIntegrations())]))
1730
1783
  );
1731
- var deleteIntegration = createAsyncThunk4(
1784
+ var deleteIntegration = createAppAsyncThunk(
1732
1785
  `${sliceName5}/deleteIntegration`,
1733
1786
  ({ id, provider }, { dispatch, getState }) => general_api_default.delete(`${iotManagerBaseURL}/integrations/${id}`, {}).catch((err) => commonErrorHandler(err, "There was an error removing the integration", dispatch, commonErrorFallback)).then(() => {
1734
1787
  const integrations = getState().organization.externalDeviceIntegrations.filter((item) => provider !== item.provider);
@@ -1738,7 +1791,7 @@ var deleteIntegration = createAsyncThunk4(
1738
1791
  ]);
1739
1792
  })
1740
1793
  );
1741
- var getIntegrations = createAsyncThunk4(
1794
+ var getIntegrations = createAppAsyncThunk(
1742
1795
  `${sliceName5}/getIntegrations`,
1743
1796
  (_, { dispatch, getState }) => general_api_default.get(`${iotManagerBaseURL}/integrations`).catch((err) => commonErrorHandler(err, "There was an error retrieving the integration", dispatch, commonErrorFallback)).then(({ data }) => {
1744
1797
  const existingIntegrations = getState().organization.externalDeviceIntegrations;
@@ -1751,10 +1804,10 @@ var getIntegrations = createAsyncThunk4(
1751
1804
  return Promise.resolve(dispatch(actions5.receiveExternalDeviceIntegrations(integrations)));
1752
1805
  })
1753
1806
  );
1754
- var getWebhookEvents = createAsyncThunk4(`${sliceName5}/getWebhookEvents`, (config = {}, { dispatch, getState }) => {
1807
+ var getWebhookEvents = createAppAsyncThunk(`${sliceName5}/getWebhookEvents`, (config = {}, { dispatch, getState }) => {
1755
1808
  const { isFollowUp, page = defaultPage3, perPage = defaultPerPage3 } = config;
1756
1809
  return general_api_default.get(`${iotManagerBaseURL}/events?page=${page}&per_page=${perPage}`).catch((err) => commonErrorHandler(err, "There was an error retrieving activity for this integration", dispatch, commonErrorFallback)).then(({ data }) => {
1757
- let tasks = [
1810
+ const tasks = [
1758
1811
  dispatch(
1759
1812
  actions5.receiveWebhookEvents({
1760
1813
  value: isFollowUp ? getState().organization.webhooks.events : data,
@@ -1777,29 +1830,29 @@ var ssoConfigActions = {
1777
1830
  };
1778
1831
  var ssoConfigActionErrorHandler = (err, type) => (dispatch) => commonErrorHandler(err, `There was an error ${ssoConfigActions[type].error} the SSO configuration.`, dispatch, commonErrorFallback);
1779
1832
  var ssoConfigActionSuccessHandler = (type) => (dispatch) => dispatch(setSnackbar3(`The SSO configuration was ${ssoConfigActions[type].success} successfully`));
1780
- var storeSsoConfig = createAsyncThunk4(
1833
+ var storeSsoConfig = createAppAsyncThunk(
1781
1834
  `${sliceName5}/storeSsoConfig`,
1782
1835
  ({ config, contentType }, { dispatch }) => general_api_default.post(ssoIdpApiUrlv1, config, { headers: { "Content-Type": contentType, Accept: "application/json" } }).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "create"))).then(() => Promise.all([dispatch(ssoConfigActionSuccessHandler("create")), dispatch(getSsoConfigs())]))
1783
1836
  );
1784
- var changeSsoConfig = createAsyncThunk4(
1837
+ var changeSsoConfig = createAppAsyncThunk(
1785
1838
  `${sliceName5}/changeSsoConfig`,
1786
1839
  ({ config, contentType }, { dispatch }) => general_api_default.put(`${ssoIdpApiUrlv1}/${config.id}`, config, { headers: { "Content-Type": contentType, Accept: "application/json" } }).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "edit"))).then(() => Promise.all([dispatch(ssoConfigActionSuccessHandler("edit")), dispatch(getSsoConfigs())]))
1787
1840
  );
1788
- var deleteSsoConfig = createAsyncThunk4(
1841
+ var deleteSsoConfig = createAppAsyncThunk(
1789
1842
  `${sliceName5}/deleteSsoConfig`,
1790
1843
  ({ id }, { dispatch, getState }) => general_api_default.delete(`${ssoIdpApiUrlv1}/${id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "remove"))).then(() => {
1791
1844
  const configs = getState().organization.ssoConfigs.filter((item) => id !== item.id);
1792
1845
  return Promise.all([dispatch(ssoConfigActionSuccessHandler("remove")), dispatch(actions5.receiveSsoConfigs(configs))]);
1793
1846
  })
1794
1847
  );
1795
- var getSsoConfigById = createAsyncThunk4(
1848
+ var getSsoConfigById = createAppAsyncThunk(
1796
1849
  `${sliceName5}/getSsoConfigById`,
1797
1850
  (config, { dispatch }) => general_api_default.get(`${ssoIdpApiUrlv1}/${config.id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "read"))).then(({ data, headers }) => {
1798
1851
  const sso = Object.values(SSO_TYPES).find(({ contentType }) => contentType === headers["content-type"]);
1799
1852
  return sso ? Promise.resolve({ ...config, config: data, type: sso.id }) : Promise.reject("Unsupported SSO config content type.");
1800
1853
  })
1801
1854
  );
1802
- var getSsoConfigs = createAsyncThunk4(
1855
+ var getSsoConfigs = createAppAsyncThunk(
1803
1856
  `${sliceName5}/getSsoConfigs`,
1804
1857
  (_, { dispatch }) => general_api_default.get(ssoIdpApiUrlv1).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "readMultiple"))).then(
1805
1858
  ({ data }) => Promise.all(data.map((config) => dispatch(getSsoConfigById(config)).unwrap())).then((configs) => dispatch(actions5.receiveSsoConfigs(configs))).catch((err) => commonErrorHandler(err, err, dispatch, ""))
@@ -1807,15 +1860,13 @@ var getSsoConfigs = createAsyncThunk4(
1807
1860
  );
1808
1861
 
1809
1862
  // src/usersSlice/thunks.ts
1810
- import { HELPTOOLTIPS } from "@northern.tech/common-ui/helptips";
1811
- import { duplicateFilter, extractErrorMessage as extractErrorMessage2, isEmpty as isEmpty2, preformatWithRequestID } from "@northern.tech/utils/helpers";
1863
+ import { duplicateFilter, extractErrorMessage as extractErrorMessage2, isEmpty as isEmpty2 } from "@northern.tech/utils/helpers";
1812
1864
  import { clearAllRetryTimers } from "@northern.tech/utils/retrytimer";
1813
- import { createAsyncThunk as createAsyncThunk5 } from "@reduxjs/toolkit";
1814
1865
  import hashString2 from "md5";
1815
1866
  import Cookies3 from "universal-cookie";
1816
1867
  var cookies3 = new Cookies3();
1817
1868
  var { setAnnouncement: setAnnouncement2, setSnackbar: setSnackbar4 } = actions_default;
1818
- var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => (dispatch) => {
1869
+ var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => () => {
1819
1870
  const errorText = extractErrorMessage2(err);
1820
1871
  const is2FABackend = errorText.includes("2fa");
1821
1872
  if (is2FABackend && !has2FA) {
@@ -1826,26 +1877,25 @@ var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) =>
1826
1877
  }
1827
1878
  const twoFAError = is2FABackend ? " and verification code" : "";
1828
1879
  const errorMessage = `There was a problem logging in. Please check your email${twoFAError ? "," : " and"} password${twoFAError}. If you still have problems, contact an administrator.`;
1829
- return Promise.reject(dispatch(setSnackbar4({ message: preformatWithRequestID(err.response, errorMessage), action: "Copy to clipboard" })));
1880
+ return rejectWithValue({ error: errorMessage });
1830
1881
  };
1831
- var loginUser = createAsyncThunk5(
1882
+ var loginUser = createAppAsyncThunk(
1832
1883
  `${sliceName6}/loginUser`,
1833
- ({ stayLoggedIn, ...userData }, { dispatch, rejectWithValue }) => users_api_default.postLogin(`${useradmApiUrlv1}/auth/login`, { ...userData, no_expiry: stayLoggedIn }).catch((err) => {
1884
+ ({ stayLoggedIn, ...userData }, { dispatch, rejectWithValue }) => users_api_default.postLogin(`${useradmApiUrl}/auth/login`, { ...userData, no_expiry: stayLoggedIn }).catch((err) => {
1834
1885
  cleanUp();
1835
1886
  return Promise.reject(dispatch(handleLoginError(err, userData, rejectWithValue)));
1836
- }).then(({ text: response, contentType }) => {
1887
+ }).then(({ text: token, contentType }) => {
1837
1888
  if (contentType.includes(APPLICATION_JSON_CONTENT_TYPE)) {
1838
- const { id, kind } = response;
1889
+ const { id, kind } = token;
1839
1890
  const type = kind.split("/")[1];
1840
1891
  const ssoLoginUrl = SSO_TYPES[type].getStartUrl(id);
1841
1892
  window.location.replace(ssoLoginUrl);
1842
1893
  return;
1843
1894
  }
1844
- const token = response;
1845
1895
  if (contentType !== APPLICATION_JWT_CONTENT_TYPE || !token) {
1846
1896
  return;
1847
1897
  }
1848
- let now = /* @__PURE__ */ new Date();
1898
+ const now = /* @__PURE__ */ new Date();
1849
1899
  now.setSeconds(now.getSeconds() + maxSessionAge);
1850
1900
  const expiresAt = stayLoggedIn ? void 0 : now.toISOString();
1851
1901
  setSessionInfo({ token, expiresAt });
@@ -1862,35 +1912,35 @@ var loginUser = createAsyncThunk5(
1862
1912
  });
1863
1913
  })
1864
1914
  );
1865
- var logoutUser = createAsyncThunk5(`${sliceName6}/logoutUser`, (_, { dispatch, getState }) => {
1915
+ var logoutUser = createAppAsyncThunk(`${sliceName6}/logoutUser`, (_, { dispatch, getState }) => {
1866
1916
  if (Object.keys(getState().app.uploadsById).length) {
1867
1917
  return Promise.reject();
1868
1918
  }
1869
- return general_api_default.post(`${useradmApiUrlv1}/auth/logout`).finally(() => {
1919
+ return general_api_default.post(`${useradmApiUrl}/auth/logout`).finally(() => {
1870
1920
  cleanUp();
1871
1921
  clearAllRetryTimers(setSnackbar4);
1872
1922
  return Promise.resolve(dispatch({ type: USER_LOGOUT }));
1873
1923
  });
1874
1924
  });
1875
- var switchUserOrganization = createAsyncThunk5(`${sliceName6}/switchUserOrganization`, (tenantId, { getState }) => {
1925
+ var switchUserOrganization = createAppAsyncThunk(`${sliceName6}/switchUserOrganization`, (tenantId, { getState }) => {
1876
1926
  if (Object.keys(getState().app.uploadsById).length) {
1877
1927
  return Promise.reject();
1878
1928
  }
1879
- return general_api_default.get(`${useradmApiUrlv1}/users/tenants/${tenantId}/token`).then(({ data: token }) => {
1929
+ return general_api_default.get(`${useradmApiUrl}/users/tenants/${tenantId}/token`).then(({ data: token }) => {
1880
1930
  window.sessionStorage.setItem("tenantChanged", "true");
1881
1931
  setSessionInfo({ ...getSessionInfo(), token });
1882
1932
  window.location.reload();
1883
1933
  });
1884
1934
  });
1885
- var passwordResetStart = createAsyncThunk5(
1935
+ var passwordResetStart = createAppAsyncThunk(
1886
1936
  `${sliceName6}/passwordResetStart`,
1887
- (email, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/auth/password-reset/start`, { email }).catch(
1937
+ (email, { dispatch }) => general_api_default.post(`${useradmApiUrl}/auth/password-reset/start`, { email }).catch(
1888
1938
  (err) => commonErrorHandler(err, `The password reset request cannot be processed:`, dispatch, void 0, true)
1889
1939
  )
1890
1940
  );
1891
- var passwordResetComplete = createAsyncThunk5(
1941
+ var passwordResetComplete = createAppAsyncThunk(
1892
1942
  `${sliceName6}/passwordResetComplete`,
1893
- ({ secretHash, newPassword }, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/auth/password-reset/complete`, { secret_hash: secretHash, password: newPassword }).catch((err = {}) => {
1943
+ ({ secretHash, newPassword }, { dispatch }) => general_api_default.post(`${useradmApiUrl}/auth/password-reset/complete`, { secret_hash: secretHash, password: newPassword }).catch((err = {}) => {
1894
1944
  const { error, response = {} } = err;
1895
1945
  let errorMsg = "";
1896
1946
  if (response.status == 400) {
@@ -1902,23 +1952,23 @@ var passwordResetComplete = createAsyncThunk5(
1902
1952
  return Promise.reject(err);
1903
1953
  })
1904
1954
  );
1905
- var verifyEmailStart = createAsyncThunk5(
1955
+ var verifyEmailStart = createAppAsyncThunk(
1906
1956
  `${sliceName6}/verifyEmailStart`,
1907
- (_, { dispatch, getState }) => general_api_default.post(`${useradmApiUrlv1}/auth/verify-email/start`, { email: getCurrentUser(getState()).email }).catch((err) => commonErrorHandler(err, "An error occured starting the email verification process:", dispatch)).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
1957
+ (_, { dispatch, getState }) => general_api_default.post(`${useradmApiUrl}/auth/verify-email/start`, { email: getCurrentUser(getState()).email }).catch((err) => commonErrorHandler(err, "An error occured starting the email verification process:", dispatch)).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
1908
1958
  );
1909
- var verifyEmailComplete = createAsyncThunk5(
1959
+ var verifyEmailComplete = createAppAsyncThunk(
1910
1960
  `${sliceName6}/verifyEmailComplete`,
1911
- (secret_hash, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/auth/verify-email/complete`, { secret_hash }).catch((err) => commonErrorHandler(err, "An error occured completing the email verification process:", dispatch)).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
1961
+ (secret_hash, { dispatch }) => general_api_default.post(`${useradmApiUrl}/auth/verify-email/complete`, { secret_hash }).catch((err) => commonErrorHandler(err, "An error occured completing the email verification process:", dispatch)).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
1912
1962
  );
1913
- var verify2FA = createAsyncThunk5(
1963
+ var verify2FA = createAppAsyncThunk(
1914
1964
  `${sliceName6}/verify2FA`,
1915
- (tfaData, { dispatch }) => users_api_default.putVerifyTFA(`${useradmApiUrlv1}/2faverify`, tfaData).then(() => Promise.resolve(dispatch(getUser(OWN_USER_ID)))).catch(
1965
+ (tfaData, { dispatch }) => users_api_default.putVerifyTFA(`${useradmApiUrl}/2faverify`, tfaData).then(() => Promise.resolve(dispatch(getUser(OWN_USER_ID)))).catch(
1916
1966
  (err) => commonErrorHandler(err, "An error occured validating the verification code: failed to verify token, please try again.", dispatch, void 0, true)
1917
1967
  )
1918
1968
  );
1919
- var getUserList = createAsyncThunk5(
1969
+ var getUserList = createAppAsyncThunk(
1920
1970
  `${sliceName6}/getUserList`,
1921
- (_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv1}/users`).then((res) => {
1971
+ (_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrl}/users`).then((res) => {
1922
1972
  const currentUsersById = getUsersById(getState());
1923
1973
  const users = res.data.reduce(
1924
1974
  (accu, item) => {
@@ -1933,9 +1983,9 @@ var getUserList = createAsyncThunk5(
1933
1983
  return dispatch(actions6.receivedUserList(users));
1934
1984
  }).catch((err) => commonErrorHandler(err, `Users couldn't be loaded.`, dispatch, commonErrorFallback))
1935
1985
  );
1936
- var getUser = createAsyncThunk5(
1986
+ var getUser = createAppAsyncThunk(
1937
1987
  `${sliceName6}/getUser`,
1938
- (id, { dispatch, rejectWithValue }) => general_api_default.get(`${useradmApiUrlv1}/users/${id}`).then(
1988
+ (id, { dispatch, rejectWithValue }) => general_api_default.get(`${useradmApiUrl}/users/${id}`).then(
1939
1989
  ({ data: user }) => Promise.all([
1940
1990
  dispatch(actions6.receivedUser(user)),
1941
1991
  dispatch(setHideAnnouncement({ shouldHide: false, userId: user.id })),
@@ -1944,22 +1994,25 @@ var getUser = createAsyncThunk5(
1944
1994
  ])
1945
1995
  ).catch((e) => rejectWithValue(e))
1946
1996
  );
1947
- var initializeSelf = createAsyncThunk5(`${sliceName6}/initializeSelf`, (_, { dispatch }) => dispatch(getUser(OWN_USER_ID)));
1948
- var updateUserColumnSettings = createAsyncThunk5(`${sliceName6}/updateUserColumnSettings`, ({ columns, currentUserId }, { dispatch, getState }) => {
1949
- const userId = currentUserId ?? getCurrentUser(getState()).id;
1950
- const storageKey = `${userId}-column-widths`;
1951
- let customColumns = [];
1952
- if (!columns) {
1953
- try {
1954
- customColumns = JSON.parse(window.localStorage.getItem(storageKey)) || customColumns;
1955
- } catch {
1997
+ var initializeSelf = createAppAsyncThunk(`${sliceName6}/initializeSelf`, (_, { dispatch }) => dispatch(getUser(OWN_USER_ID)));
1998
+ var updateUserColumnSettings = createAppAsyncThunk(
1999
+ `${sliceName6}/updateUserColumnSettings`,
2000
+ ({ columns, currentUserId }, { dispatch, getState }) => {
2001
+ const userId = currentUserId ?? getCurrentUser(getState()).id;
2002
+ const storageKey = `${userId}-column-widths`;
2003
+ let customColumns = [];
2004
+ if (!columns) {
2005
+ try {
2006
+ customColumns = JSON.parse(window.localStorage.getItem(storageKey) || "") || customColumns;
2007
+ } catch {
2008
+ }
2009
+ } else {
2010
+ customColumns = columns;
1956
2011
  }
1957
- } else {
1958
- customColumns = columns;
2012
+ window.localStorage.setItem(storageKey, JSON.stringify(customColumns));
2013
+ return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
1959
2014
  }
1960
- window.localStorage.setItem(storageKey, JSON.stringify(customColumns));
1961
- return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
1962
- });
2015
+ );
1963
2016
  var userActions = {
1964
2017
  add: {
1965
2018
  successMessage: "The user was added successfully.",
@@ -1979,34 +2032,34 @@ var userActions = {
1979
2032
  }
1980
2033
  };
1981
2034
  var userActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${userActions[type].errorMessage} the user.`, dispatch);
1982
- var createUser = createAsyncThunk5(
2035
+ var createUser = createAppAsyncThunk(
1983
2036
  `${sliceName6}/createUser`,
1984
- ({ shouldResetPassword, ...userData }, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/users`, { ...userData, send_reset_password: shouldResetPassword }).then(() => Promise.all([dispatch(actions6.createdUser(userData)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.create.successMessage))])).catch((err) => userActionErrorHandler(err, "create", dispatch))
2037
+ ({ shouldResetPassword, ...userData }, { dispatch }) => general_api_default.post(`${useradmApiUrl}/users`, { ...userData, send_reset_password: shouldResetPassword }).then(() => Promise.all([dispatch(getUserList()), dispatch(setSnackbar4(userActions.create.successMessage))])).catch((err) => userActionErrorHandler(err, "create", dispatch))
1985
2038
  );
1986
- var removeUser = createAsyncThunk5(
2039
+ var removeUser = createAppAsyncThunk(
1987
2040
  `${sliceName6}/removeUser`,
1988
- (userId, { dispatch }) => general_api_default.delete(`${useradmApiUrlv1}/users/${userId}`).then(() => Promise.all([dispatch(actions6.removedUser(userId)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.remove.successMessage))])).catch((err) => userActionErrorHandler(err, "remove", dispatch))
2041
+ (userId, { dispatch }) => general_api_default.delete(`${useradmApiUrl}/users/${userId}`).then(() => Promise.all([dispatch(actions6.removedUser(userId)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.remove.successMessage))])).catch((err) => userActionErrorHandler(err, "remove", dispatch))
1989
2042
  );
1990
- var editUser = createAsyncThunk5(
2043
+ var editUser = createAppAsyncThunk(
1991
2044
  `${sliceName6}/editUser`,
1992
- ({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${useradmApiUrlv1}/users/${id}`, userData).then(
2045
+ ({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${useradmApiUrl}/users/${id}`, userData).then(
1993
2046
  () => Promise.all([
1994
2047
  dispatch(actions6.updatedUser({ ...userData, id: id === OWN_USER_ID ? getCurrentUser(getState()).id : id })),
1995
2048
  dispatch(setSnackbar4(userActions.edit.successMessage))
1996
2049
  ])
1997
- )
2050
+ ).catch((err) => userActionErrorHandler(err, "edit", dispatch))
1998
2051
  );
1999
- var addUserToCurrentTenant = createAsyncThunk5(`${sliceName6}/addUserToTenant`, (userId, { dispatch, getState }) => {
2052
+ var addUserToCurrentTenant = createAppAsyncThunk(`${sliceName6}/addUserToTenant`, (userId, { dispatch, getState }) => {
2000
2053
  const { id } = getOrganization(getState());
2001
- return general_api_default.post(`${useradmApiUrlv1}/users/${userId}/assign`, { tenant_ids: [id] }).catch((err) => commonErrorHandler(err, `There was an error adding the user to your organization:`, dispatch)).then(() => Promise.all([dispatch(setSnackbar4(userActions.add.successMessage)), dispatch(getUserList())]));
2054
+ return general_api_default.post(`${useradmApiUrl}/users/${userId}/assign`, { tenant_ids: [id] }).catch((err) => commonErrorHandler(err, `There was an error adding the user to your organization:`, dispatch)).then(() => Promise.all([dispatch(setSnackbar4(userActions.add.successMessage)), dispatch(getUserList())]));
2002
2055
  });
2003
- var enableUser2fa = createAsyncThunk5(
2056
+ var enableUser2fa = createAppAsyncThunk(
2004
2057
  `${sliceName6}/enableUser2fa`,
2005
- (userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/users/${userId}/2fa/enable`).catch((err) => commonErrorHandler(err, `There was an error enabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.resolve(dispatch(getUser(userId))))
2058
+ (userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrl}/users/${userId}/2fa/enable`).catch((err) => commonErrorHandler(err, `There was an error enabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.resolve(dispatch(getUser(userId))))
2006
2059
  );
2007
- var disableUser2fa = createAsyncThunk5(
2060
+ var disableUser2fa = createAppAsyncThunk(
2008
2061
  `${sliceName6}/disableUser2fa`,
2009
- (userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/users/${userId}/2fa/disable`).catch((err) => commonErrorHandler(err, `There was an error disabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.all([dispatch(getUser(userId)), dispatch(actions6.receivedQrCode(null))]))
2062
+ (userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrl}/users/${userId}/2fa/disable`).catch((err) => commonErrorHandler(err, `There was an error disabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.all([dispatch(getUser(userId)), dispatch(actions6.receivedQrCode(null))]))
2010
2063
  );
2011
2064
  var mapHttpPermission = (permission) => Object.entries(uiPermissionsByArea).reduce(
2012
2065
  (accu, [area, definition]) => {
@@ -2046,7 +2099,7 @@ var permissionActionTypes = {
2046
2099
  } : {}
2047
2100
  };
2048
2101
  var combinePermissions = (existingPermissions, additionalPermissions = {}) => Object.entries(additionalPermissions).reduce((accu, [name, permissions]) => {
2049
- let maybeExistingPermissions = accu[name] || [];
2102
+ const maybeExistingPermissions = accu[name] || [];
2050
2103
  accu[name] = [...permissions, ...maybeExistingPermissions].filter(duplicateFilter);
2051
2104
  return accu;
2052
2105
  }, existingPermissions);
@@ -2056,7 +2109,7 @@ var tryParseCustomPermission = (permission) => {
2056
2109
  return { isCustom: true, permission, result };
2057
2110
  };
2058
2111
  var customPermissionHandler = (accu, permission) => {
2059
- let processor = tryParseCustomPermission(permission);
2112
+ const processor = tryParseCustomPermission(permission);
2060
2113
  return {
2061
2114
  ...accu,
2062
2115
  isCustom: accu.isCustom || processor.isCustom,
@@ -2064,7 +2117,7 @@ var customPermissionHandler = (accu, permission) => {
2064
2117
  };
2065
2118
  };
2066
2119
  var mapPermissionSet = (permissionSetName, names, scope, existingGroupsPermissions = {}) => {
2067
- const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName).value;
2120
+ const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName)?.value;
2068
2121
  const scopedPermissions = names.reduce((accu, name) => combinePermissions(accu, { [name]: [permission] }), existingGroupsPermissions);
2069
2122
  return Object.entries(scopedPermissions).reduce((accu, [key, permissions]) => ({ ...accu, [key]: deriveImpliedAreaPermissions(scope, permissions) }), {});
2070
2123
  };
@@ -2077,16 +2130,21 @@ var isEmptyPermissionSet = (permissionSet) => !Object.values(permissionSet).redu
2077
2130
  var parseRolePermissions = ({ permission_sets_with_scope = [], permissions = [] }, permissionSets) => {
2078
2131
  const preliminaryResult = permission_sets_with_scope.reduce(
2079
2132
  (accu, permissionSet) => {
2080
- let processor = permissionSets[permissionSet.name];
2133
+ const processor = permissionSets[permissionSet.name];
2081
2134
  if (!processor) {
2082
2135
  return accu;
2083
2136
  }
2084
2137
  const scope = Object.keys(scopedPermissionAreas).find((scope2) => uiPermissionsByArea[scope2].scope === permissionSet.scope?.type);
2085
2138
  if (scope) {
2086
- const result = mapPermissionSet(permissionSet.name, permissionSet.scope.value, scope, accu.uiPermissions[scope]);
2139
+ const result = mapPermissionSet(
2140
+ permissionSet.name,
2141
+ permissionSet.scope.value,
2142
+ scope,
2143
+ accu.uiPermissions[scope]
2144
+ );
2087
2145
  return { ...accu, uiPermissions: { ...accu.uiPermissions, [scope]: result } };
2088
2146
  } else if (isEmptyPermissionSet(processor.result)) {
2089
- return processor.permissions.reduce(customPermissionHandler, accu);
2147
+ return processor.permissions?.reduce(customPermissionHandler, accu);
2090
2148
  }
2091
2149
  return {
2092
2150
  ...accu,
@@ -2127,7 +2185,7 @@ var normalizeRbacRoles = (roles, rolesById2, permissionSets) => roles.reduce(
2127
2185
  },
2128
2186
  { ...rolesById2 }
2129
2187
  );
2130
- var getPermissionSets = createAsyncThunk5(
2188
+ var getPermissionSets = createAppAsyncThunk(
2131
2189
  `${sliceName6}/getPermissionSets`,
2132
2190
  (_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv2}/permission_sets?per_page=500`).then(({ data }) => {
2133
2191
  const permissionSets = data.reduce(
@@ -2153,7 +2211,10 @@ var getPermissionSets = createAsyncThunk5(
2153
2211
  return accu2;
2154
2212
  }, []);
2155
2213
  permissionSetObject = scopes.reduce((accu2, scope) => {
2156
- accu2.result[scope] = mapPermissionSet(permissionSetObject.name, [scopedPermissionAreas[scope].excessiveAccessSelector], scope);
2214
+ accu2.result = {
2215
+ ...accu2.result,
2216
+ [scope]: mapPermissionSet(permissionSetObject.name, [scopedPermissionAreas[scope].excessiveAccessSelector], scope)
2217
+ };
2157
2218
  return accu2;
2158
2219
  }, permissionSetObject);
2159
2220
  accu[permissionSet.name] = permissionSetObject;
@@ -2164,7 +2225,7 @@ var getPermissionSets = createAsyncThunk5(
2164
2225
  return Promise.all([dispatch(actions6.receivedPermissionSets(permissionSets)), permissionSets]);
2165
2226
  }).catch(() => console.log("Permission set retrieval failed - likely accessing a non-RBAC backend"))
2166
2227
  );
2167
- var getRoles = createAsyncThunk5(
2228
+ var getRoles = createAppAsyncThunk(
2168
2229
  `${sliceName6}/getRoles`,
2169
2230
  (_, { dispatch, getState }) => Promise.all([general_api_default.get(`${useradmApiUrlv2}/roles?per_page=500`), dispatch(getPermissionSets())]).then((results) => {
2170
2231
  if (!results) {
@@ -2173,7 +2234,7 @@ var getRoles = createAsyncThunk5(
2173
2234
  const [{ data: roles }, { payload: permissionSetTasks }] = results;
2174
2235
  const rolesById2 = normalizeRbacRoles(roles, getRolesById(getState()), permissionSetTasks[permissionSetTasks.length - 1]);
2175
2236
  return Promise.resolve(dispatch(actions6.receivedRoles(rolesById2)));
2176
- }).catch(() => console.log("Role retrieval failed - likely accessing a non-RBAC backend"))
2237
+ }).catch(() => console.log("Role retrieval failed - likely accessing a non-RBAC backend")).finally(() => Promise.resolve(dispatch(actions6.finishedRoleInitialization(true))))
2177
2238
  );
2178
2239
  var deriveImpliedAreaPermissions = (area, areaPermissions, skipPermissions = []) => {
2179
2240
  const highestAreaPermissionLevelSelected = areaPermissions.reduce(
@@ -2243,7 +2304,13 @@ var transformRoleDataToRole = (roleData, roleState = {}) => {
2243
2304
  if (!uiPermissions[key]) {
2244
2305
  return accu;
2245
2306
  }
2246
- accu.push(...transformAreaRoleDataToScopedPermissionsSets(key, uiPermissions[key], excessiveAccessSelector));
2307
+ accu.push(
2308
+ ...transformAreaRoleDataToScopedPermissionsSets(
2309
+ key,
2310
+ uiPermissions[key],
2311
+ excessiveAccessSelector
2312
+ )
2313
+ );
2247
2314
  return accu;
2248
2315
  }, []);
2249
2316
  return {
@@ -2251,7 +2318,7 @@ var transformRoleDataToRole = (roleData, roleState = {}) => {
2251
2318
  role: {
2252
2319
  ...emptyRole,
2253
2320
  name,
2254
- description: description ? description : roleState.description,
2321
+ description: description ? description : roleState.description || "",
2255
2322
  uiPermissions: {
2256
2323
  ...emptyUiPermissions,
2257
2324
  ...roleUiPermissions,
@@ -2274,50 +2341,57 @@ var roleActions = {
2274
2341
  errorMessage: "removing"
2275
2342
  }
2276
2343
  };
2277
- var roleActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${roleActions[type].errorMessage} the role.`, dispatch);
2278
- var createRole = createAsyncThunk5(`${sliceName6}/createRole`, (roleData, { dispatch }) => {
2344
+ var roleActionErrorHandler = (err, type, dispatch, meta) => {
2345
+ let errorContext = `There was an error ${roleActions[type].errorMessage} the role.`;
2346
+ if (meta) {
2347
+ const { permissionSetsCreated, name } = meta;
2348
+ errorContext += ` Tried to ${type} role ${name} with ${permissionSetsCreated} permission sets.`;
2349
+ }
2350
+ return commonErrorHandler(err, errorContext, dispatch);
2351
+ };
2352
+ var createRole = createAppAsyncThunk(`${sliceName6}/createRole`, (roleData, { dispatch }) => {
2279
2353
  const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData);
2280
2354
  return general_api_default.post(`${useradmApiUrlv2}/roles`, {
2281
2355
  name: role.name,
2282
2356
  description: role.description,
2283
2357
  permission_sets_with_scope: permissionSetsWithScope
2284
- }).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.create.successMessage))])).catch((err) => roleActionErrorHandler(err, "create", dispatch));
2358
+ }).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.create.successMessage))])).catch((err) => roleActionErrorHandler(err, "create", dispatch, { permissionSetsCreated: permissionSetsWithScope.length, name: role.name }));
2285
2359
  });
2286
- var editRole = createAsyncThunk5(`${sliceName6}/editRole`, (roleData, { dispatch, getState }) => {
2360
+ var editRole = createAppAsyncThunk(`${sliceName6}/editRole`, (roleData, { dispatch, getState }) => {
2287
2361
  const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData, getRolesById(getState())[roleData.name]);
2288
2362
  return general_api_default.put(`${useradmApiUrlv2}/roles/${role.name}`, {
2289
2363
  description: role.description,
2290
2364
  name: role.name,
2291
2365
  permission_sets_with_scope: permissionSetsWithScope
2292
- }).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.edit.successMessage))])).catch((err) => roleActionErrorHandler(err, "edit", dispatch));
2366
+ }).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.edit.successMessage))])).catch((err) => roleActionErrorHandler(err, "edit", dispatch, { permissionSetsCreated: permissionSetsWithScope.length, name: role.name }));
2293
2367
  });
2294
- var removeRole = createAsyncThunk5(
2368
+ var removeRole = createAppAsyncThunk(
2295
2369
  `${sliceName6}/removeRole`,
2296
2370
  (roleId, { dispatch }) => general_api_default.delete(`${useradmApiUrlv2}/roles/${roleId}`).then(() => Promise.all([dispatch(actions6.removedRole(roleId)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.remove.successMessage))])).catch((err) => roleActionErrorHandler(err, "remove", dispatch))
2297
2371
  );
2298
- var getGlobalSettings2 = createAsyncThunk5(
2372
+ var getGlobalSettings2 = createAppAsyncThunk(
2299
2373
  `${sliceName6}/getGlobalSettings`,
2300
- (_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/settings`).then(({ data: settings, headers: { etag } }) => {
2301
- window.sessionStorage.setItem(settingsKeys.initialized, true);
2374
+ (_, { dispatch }) => general_api_default.get(`${useradmApiUrl}/settings`).then(({ data: settings, headers: { etag } }) => {
2375
+ window.sessionStorage.setItem(settingsKeys.initialized, "true");
2302
2376
  return Promise.all([dispatch(actions6.setGlobalSettings(settings)), dispatch(setOfflineThreshold()), etag]);
2303
2377
  })
2304
2378
  );
2305
- var saveGlobalSettings = createAsyncThunk5(
2379
+ var saveGlobalSettings = createAppAsyncThunk(
2306
2380
  `${sliceName6}/saveGlobalSettings`,
2307
2381
  ({ beOptimistic = false, notify = false, ...settings }, { dispatch, getState }) => {
2308
2382
  if (!window.sessionStorage.getItem(settingsKeys.initialized) && !beOptimistic) {
2309
2383
  return;
2310
2384
  }
2311
2385
  return dispatch(getGlobalSettings2()).unwrap().then((result) => {
2312
- let updatedSettings = { ...getState().users.globalSettings, ...settings };
2386
+ const updatedSettings = { ...getState().users.globalSettings, ...settings };
2313
2387
  if (getCurrentUser(getState()).verified) {
2314
2388
  updatedSettings["2fa"] = twoFAStates.enabled;
2315
2389
  } else {
2316
2390
  delete updatedSettings["2fa"];
2317
2391
  }
2318
- let tasks = [dispatch(actions6.setGlobalSettings(updatedSettings))];
2392
+ const tasks = [dispatch(actions6.setGlobalSettings(updatedSettings))];
2319
2393
  const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
2320
- return general_api_default.post(`${useradmApiUrlv1}/settings`, updatedSettings, { headers }).then(() => {
2394
+ return general_api_default.post(`${useradmApiUrl}/settings`, updatedSettings, { headers }).then(() => {
2321
2395
  if (notify) {
2322
2396
  tasks.push(dispatch(setSnackbar4("Settings saved successfully")));
2323
2397
  }
@@ -2332,54 +2406,59 @@ var saveGlobalSettings = createAsyncThunk5(
2332
2406
  });
2333
2407
  }
2334
2408
  );
2335
- var getUserSettings2 = createAsyncThunk5(
2409
+ var getUserSettings2 = createAppAsyncThunk(
2336
2410
  `${sliceName6}/getUserSettings`,
2337
- (_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/settings/me`).then(({ data: settings, headers: { etag } }) => {
2338
- window.sessionStorage.setItem(settingsKeys.initialized, true);
2411
+ (_, { dispatch }) => general_api_default.get(`${useradmApiUrl}/settings/me`).then(({ data: settings, headers: { etag } }) => {
2412
+ window.sessionStorage.setItem(settingsKeys.initialized, "true");
2339
2413
  return Promise.all([dispatch(actions6.setUserSettings(settings)), etag]);
2340
2414
  })
2341
2415
  );
2342
- var saveUserSettings = createAsyncThunk5(`${sliceName6}/saveUserSettings`, (settings = { onboarding: {} }, { dispatch, getState }) => {
2343
- if (!getCurrentUser(getState()).id) {
2344
- return Promise.resolve();
2416
+ var saveUserSettings = createAppAsyncThunk(
2417
+ `${sliceName6}/saveUserSettings`,
2418
+ (settings = { onboarding: {} }, { dispatch, getState }) => {
2419
+ if (!getCurrentUser(getState()).id) {
2420
+ return Promise.resolve();
2421
+ }
2422
+ return dispatch(getUserSettings2()).unwrap().then((result) => {
2423
+ const userSettings = getUserSettings(getState());
2424
+ const onboardingState = getOnboardingState(getState());
2425
+ const tooltipState = getTooltipsState(getState());
2426
+ const updatedSettings = {
2427
+ ...userSettings,
2428
+ ...settings,
2429
+ onboarding: {
2430
+ ...onboardingState,
2431
+ ...settings.onboarding
2432
+ },
2433
+ tooltips: tooltipState
2434
+ };
2435
+ const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
2436
+ return Promise.all([
2437
+ Promise.resolve(dispatch(actions6.setUserSettings(updatedSettings))),
2438
+ general_api_default.post(`${useradmApiUrl}/settings/me`, updatedSettings, { headers })
2439
+ ]).catch(() => dispatch(actions6.setUserSettings(userSettings)));
2440
+ });
2345
2441
  }
2346
- return dispatch(getUserSettings2()).unwrap().then((result) => {
2347
- const userSettings = getUserSettings(getState());
2348
- const onboardingState = getOnboardingState(getState());
2349
- const tooltipState = getTooltipsState(getState());
2350
- const updatedSettings = {
2351
- ...userSettings,
2352
- ...settings,
2353
- onboarding: {
2354
- ...onboardingState,
2355
- ...settings.onboarding
2356
- },
2357
- tooltips: tooltipState
2358
- };
2359
- const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
2360
- return Promise.all([
2361
- Promise.resolve(dispatch(actions6.setUserSettings(updatedSettings))),
2362
- general_api_default.post(`${useradmApiUrlv1}/settings/me`, updatedSettings, { headers })
2363
- ]).catch(() => dispatch(actions6.setUserSettings(userSettings)));
2364
- });
2365
- });
2366
- var get2FAQRCode = createAsyncThunk5(
2442
+ );
2443
+ var get2FAQRCode = createAppAsyncThunk(
2367
2444
  `${sliceName6}/get2FAQRCode`,
2368
- (_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/2faqr`).then((res) => dispatch(actions6.receivedQrCode(res.data.qr)))
2369
- );
2370
- var setHideAnnouncement = createAsyncThunk5(`${sliceName6}/setHideAnnouncement`, ({ shouldHide, userId }, { dispatch, getState }) => {
2371
- const currentUserId = userId || getCurrentUser(getState()).id;
2372
- const hash = getState().app.hostedAnnouncement ? hashString2(getState().app.hostedAnnouncement) : "";
2373
- const announceCookie = cookies3.get(`${currentUserId}${hash}`);
2374
- if (shouldHide || hash.length && typeof announceCookie !== "undefined") {
2375
- cookies3.set(`${currentUserId}${hash}`, true, { maxAge: 604800 });
2376
- return Promise.resolve(dispatch(setAnnouncement2()));
2445
+ (_, { dispatch }) => general_api_default.get(`${useradmApiUrl}/2faqr`).then((res) => dispatch(actions6.receivedQrCode(res.data.qr)))
2446
+ );
2447
+ var setHideAnnouncement = createAppAsyncThunk(
2448
+ `${sliceName6}/setHideAnnouncement`,
2449
+ ({ shouldHide, userId }, { dispatch, getState }) => {
2450
+ const currentUserId = userId || getCurrentUser(getState()).id;
2451
+ const hash = getState().app.hostedAnnouncement ? hashString2(getState().app.hostedAnnouncement) : "";
2452
+ const announceCookie = cookies3.get(`${currentUserId}${hash}`);
2453
+ if (shouldHide || hash.length && typeof announceCookie !== "undefined") {
2454
+ cookies3.set(`${currentUserId}${hash}`, true, { maxAge: 604800 });
2455
+ dispatch(setAnnouncement2(""));
2456
+ }
2377
2457
  }
2378
- return Promise.resolve();
2379
- });
2380
- var getTokens = createAsyncThunk5(
2458
+ );
2459
+ var getTokens = createAppAsyncThunk(
2381
2460
  `${sliceName6}/getTokens`,
2382
- (_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv1}/settings/tokens`).then(({ data: tokens }) => {
2461
+ (_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrl}/settings/tokens`).then(({ data: tokens }) => {
2383
2462
  const user = getCurrentUser(getState());
2384
2463
  const updatedUser = {
2385
2464
  ...user,
@@ -2389,26 +2468,31 @@ var getTokens = createAsyncThunk5(
2389
2468
  })
2390
2469
  );
2391
2470
  var ONE_YEAR = 31536e3;
2392
- var generateToken = createAsyncThunk5(
2471
+ var generateToken = createAppAsyncThunk(
2393
2472
  `${sliceName6}/generateToken`,
2394
- ({ expiresIn = ONE_YEAR, name }, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/settings/tokens`, { name, expires_in: expiresIn }).then(({ data: token }) => Promise.all([dispatch(getTokens()), token])).catch((err) => commonErrorHandler(err, "There was an error creating the token:", dispatch))
2473
+ ({ expiresIn = ONE_YEAR, name }, { dispatch }) => general_api_default.post(`${useradmApiUrl}/settings/tokens`, { name, expires_in: expiresIn }).then(({ data: token }) => Promise.all([dispatch(getTokens()), token])).catch((err) => commonErrorHandler(err, "There was an error creating the token:", dispatch))
2395
2474
  );
2396
- var revokeToken = createAsyncThunk5(
2475
+ var revokeToken = createAppAsyncThunk(
2397
2476
  `${sliceName6}/revokeToken`,
2398
- (token, { dispatch }) => general_api_default.delete(`${useradmApiUrlv1}/settings/tokens/${token.id}`).then(() => Promise.resolve(dispatch(getTokens())))
2477
+ (token, { dispatch }) => general_api_default.delete(`${useradmApiUrl}/settings/tokens/${token.id}`).then(() => Promise.resolve(dispatch(getTokens())))
2478
+ );
2479
+ var setTooltipReadState = createAppAsyncThunk(
2480
+ `${sliceName6}/setTooltipReadState`,
2481
+ async ({ persist, ...remainder }, { dispatch }) => {
2482
+ dispatch(actions6.setTooltipState(remainder));
2483
+ if (persist) {
2484
+ await dispatch(saveUserSettings());
2485
+ }
2486
+ }
2399
2487
  );
2400
- var setTooltipReadState = createAsyncThunk5(`${sliceName6}/setTooltipReadState`, ({ persist, ...remainder }, { dispatch }) => {
2401
- let tasks = [dispatch(actions6.setTooltipState(remainder))];
2402
- if (persist) {
2403
- tasks.push(dispatch(saveUserSettings()));
2488
+ var setAllTooltipsReadState = createAppAsyncThunk(
2489
+ `${sliceName6}/toggleHelptips`,
2490
+ ({ readState = READ_STATES.read, tooltipIds }, { dispatch }) => {
2491
+ const updatedTips = tooltipIds.reduce((accu, id) => ({ ...accu, [id]: { readState } }), {});
2492
+ return Promise.resolve(dispatch(actions6.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
2404
2493
  }
2405
- return Promise.all(tasks);
2406
- });
2407
- var setAllTooltipsReadState = createAsyncThunk5(`${sliceName6}/toggleHelptips`, (readState = READ_STATES.read, { dispatch }) => {
2408
- const updatedTips = Object.keys(HELPTOOLTIPS).reduce((accu, id) => ({ ...accu, [id]: { readState } }), {});
2409
- return Promise.resolve(dispatch(actions6.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
2410
- });
2411
- var submitFeedback = createAsyncThunk5(
2494
+ );
2495
+ var submitFeedback = createAppAsyncThunk(
2412
2496
  `${sliceName6}/submitFeedback`,
2413
2497
  ({ satisfaction, feedback, ...meta }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/contact/support`, {
2414
2498
  subject: "feedback submission",
@@ -2421,11 +2505,8 @@ var submitFeedback = createAsyncThunk5(
2421
2505
  );
2422
2506
 
2423
2507
  // src/appSlice/thunks.ts
2424
- import { deepCompare as deepCompare4, extractErrorMessage as extractErrorMessage3 } from "@northern.tech/utils/helpers";
2425
- import { createAsyncThunk as createAsyncThunk6 } from "@reduxjs/toolkit";
2426
- import Cookies4 from "universal-cookie";
2427
2508
  var cookies4 = new Cookies4();
2428
- var setFirstLoginAfterSignup = createAsyncThunk6(`${sliceName}/setFirstLoginAfterSignup`, (firstLoginAfterSignup, { dispatch }) => {
2509
+ var setFirstLoginAfterSignup = createAppAsyncThunk(`${sliceName}/setFirstLoginAfterSignup`, (firstLoginAfterSignup, { dispatch }) => {
2429
2510
  cookies4.set("firstLoginAfterSignup", !!firstLoginAfterSignup, { maxAge: 60, path: "/", domain: ".mender.io", sameSite: false });
2430
2511
  dispatch(actions.setFirstLoginAfterSignup(!!firstLoginAfterSignup));
2431
2512
  });
@@ -2433,7 +2514,7 @@ var dateFunctionMap = {
2433
2514
  getDays: "getDate",
2434
2515
  setDays: "setDate"
2435
2516
  };
2436
- var setOfflineThreshold = createAsyncThunk6(`${sliceName}/setOfflineThreshold`, (_, { dispatch, getState }) => {
2517
+ var setOfflineThreshold = createAppAsyncThunk(`${sliceName}/setOfflineThreshold`, (_, { dispatch, getState }) => {
2437
2518
  const { interval, intervalUnit } = getOfflineThresholdSettings(getState());
2438
2519
  const today = /* @__PURE__ */ new Date();
2439
2520
  const intervalName = `${intervalUnit.charAt(0).toUpperCase()}${intervalUnit.substring(1)}`;
@@ -2458,12 +2539,11 @@ var repoKeyMap = {
2458
2539
  mender: "Mender-Client",
2459
2540
  "mender-artifact": "Mender-Artifact"
2460
2541
  };
2461
- var deductSaasState = (latestRelease, guiTags, saasReleases) => {
2542
+ var deductSaasState = (latestRelease, guiTags) => {
2462
2543
  const latestGuiTag = guiTags.length ? guiTags[0].name : "";
2463
- const latestSaasRelease = latestGuiTag.startsWith("saas-v") ? { date: latestGuiTag.split("-v")[1].replaceAll(".", "-"), tag: latestGuiTag } : saasReleases[0];
2464
- return latestSaasRelease.date > latestRelease.release_date ? latestSaasRelease.tag : latestRelease.release;
2544
+ return latestGuiTag ? latestGuiTag : latestRelease.release;
2465
2545
  };
2466
- var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`, (_, { dispatch, getState }) => {
2546
+ var getLatestReleaseInfo = createAppAsyncThunk(`${sliceName}/getLatestReleaseInfo`, (_, { dispatch, getState }) => {
2467
2547
  if (!getFeatures(getState()).isHosted) {
2468
2548
  return Promise.resolve();
2469
2549
  }
@@ -2474,7 +2554,7 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
2474
2554
  if (!guiTags.length) {
2475
2555
  return Promise.resolve();
2476
2556
  }
2477
- const { releases, saas } = data;
2557
+ const { releases } = data;
2478
2558
  const latestRelease = getLatestRelease(getLatestRelease(releases));
2479
2559
  const { latestRepos, latestVersions } = latestRelease.repos.reduce(
2480
2560
  (accu, item) => {
@@ -2486,13 +2566,12 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
2486
2566
  },
2487
2567
  { latestVersions: { ...getState().app.versionInformation }, latestRepos: {} }
2488
2568
  );
2489
- const info = deductSaasState(latestRelease, guiTags, saas);
2569
+ const info = deductSaasState(latestRelease, guiTags);
2490
2570
  return Promise.resolve(
2491
2571
  dispatch(
2492
2572
  actions.setVersionInformation({
2493
2573
  ...latestVersions,
2494
- backend: info,
2495
- GUI: info,
2574
+ Server: info,
2496
2575
  latestRelease: {
2497
2576
  releaseDate: latestRelease.release_date,
2498
2577
  repos: latestRepos
@@ -2502,9 +2581,9 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
2502
2581
  );
2503
2582
  });
2504
2583
  });
2505
- var setSearchState = createAsyncThunk6(`${sliceName}/setSearchState`, (searchState, { dispatch, getState }) => {
2584
+ var setSearchState = createAppAsyncThunk(`${sliceName}/setSearchState`, (searchState, { dispatch, getState }) => {
2506
2585
  const currentState = getSearchState(getState());
2507
- let nextState = {
2586
+ const nextState = {
2508
2587
  ...currentState,
2509
2588
  ...searchState,
2510
2589
  sort: {
@@ -2512,7 +2591,7 @@ var setSearchState = createAsyncThunk6(`${sliceName}/setSearchState`, (searchSta
2512
2591
  ...searchState.sort
2513
2592
  }
2514
2593
  };
2515
- let tasks = [];
2594
+ const tasks = [];
2516
2595
  const { isSearching: currentSearching, deviceIds: currentDevices, searchTotal: currentTotal, ...currentRequestState } = currentState;
2517
2596
  const { isSearching: nextSearching, deviceIds: nextDevices, searchTotal: nextTotal, ...nextRequestState } = nextState;
2518
2597
  if (nextRequestState.searchTerm && !deepCompare4(currentRequestState, nextRequestState)) {
@@ -2546,7 +2625,7 @@ export {
2546
2625
  setDeploymentsState,
2547
2626
  getDeploymentsConfig,
2548
2627
  saveDeltaDeploymentsConfig,
2549
- getGroups2 as getGroups,
2628
+ getGroups,
2550
2629
  addDevicesToGroup,
2551
2630
  removeDevicesFromGroup,
2552
2631
  addStaticGroup,
@@ -2561,7 +2640,6 @@ export {
2561
2640
  getAllDynamicGroupDevices,
2562
2641
  getDeviceById2 as getDeviceById,
2563
2642
  getDeviceInfo,
2564
- deriveInactiveDevices,
2565
2643
  getDeviceCount,
2566
2644
  getAllDeviceCounts,
2567
2645
  getDeviceLimit,
@@ -2570,11 +2648,8 @@ export {
2570
2648
  getAllDevicesByStatus,
2571
2649
  searchDevices,
2572
2650
  getDeviceAttributes,
2573
- getReportingLimits,
2574
- ensureVersionString,
2575
- getReportsData,
2576
- deriveReportsData,
2577
- getReportsDataWithoutBackendSupport,
2651
+ updateReportData,
2652
+ getReportDataWithoutBackendSupport,
2578
2653
  getDeviceConnect,
2579
2654
  triggerDeviceUpdate,
2580
2655
  getSessionDetails,
@@ -2595,8 +2670,6 @@ export {
2595
2670
  setDeviceTwin,
2596
2671
  getSystemDevices,
2597
2672
  getGatewayDevices,
2598
- getDevicesInBounds,
2599
- applyOnboardingFallbacks,
2600
2673
  getOnboardingState2 as getOnboardingState,
2601
2674
  setOnboardingDeviceType,
2602
2675
  setOnboardingApproach,
@@ -2620,8 +2693,15 @@ export {
2620
2693
  getTenants,
2621
2694
  setTenantsListState,
2622
2695
  editTenantDeviceLimit,
2696
+ editBillingProfile,
2697
+ createBillingProfile,
2623
2698
  removeTenant,
2624
2699
  getUserOrganization,
2700
+ getUserBilling,
2701
+ getUserSubscription,
2702
+ getBillingPreview,
2703
+ getCurrentSubscription,
2704
+ requestPlanUpgrade,
2625
2705
  sendSupportMessage,
2626
2706
  requestPlanChange,
2627
2707
  downloadLicenseReport,
@@ -2672,4 +2752,4 @@ export {
2672
2752
  setAllTooltipsReadState,
2673
2753
  submitFeedback
2674
2754
  };
2675
- //# sourceMappingURL=chunk-2JHFUQ6B.js.map
2755
+ //# sourceMappingURL=chunk-ZN5TB2NJ.js.map