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