@frontegg/redux-store 5.61.0 → 6.0.1-alpha.2

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 (389) hide show
  1. package/audits/AuditLogsState/index.d.ts +47 -47
  2. package/audits/AuditLogsState/index.js +28 -0
  3. package/audits/AuditLogsState/interfaces.d.ts +19 -19
  4. package/audits/AuditLogsState/interfaces.js +1 -0
  5. package/audits/AuditLogsState/saga.d.ts +2 -2
  6. package/audits/AuditLogsState/saga.js +166 -0
  7. package/audits/AuditsMetadataState/index.d.ts +35 -35
  8. package/audits/AuditsMetadataState/index.js +18 -0
  9. package/audits/AuditsMetadataState/interfaces.d.ts +17 -17
  10. package/audits/AuditsMetadataState/interfaces.js +1 -0
  11. package/audits/AuditsMetadataState/saga.d.ts +2 -2
  12. package/audits/AuditsMetadataState/saga.js +56 -0
  13. package/audits/backward-compatibility/index.d.ts +4 -4
  14. package/audits/backward-compatibility/index.js +4 -4
  15. package/audits/backward-compatibility/initialState.d.ts +2 -2
  16. package/audits/backward-compatibility/initialState.js +20 -0
  17. package/audits/backward-compatibility/interfaces.d.ts +55 -55
  18. package/audits/backward-compatibility/interfaces.js +1 -0
  19. package/audits/backward-compatibility/reducer.d.ts +35 -35
  20. package/audits/backward-compatibility/reducer.js +129 -0
  21. package/audits/backward-compatibility/saga.d.ts +1 -1
  22. package/audits/backward-compatibility/saga.js +187 -0
  23. package/audits/dummy.d.ts +10 -10
  24. package/audits/dummy.js +191 -0
  25. package/audits/index.d.ts +40 -40
  26. package/audits/index.js +18 -362
  27. package/audits/initialState.d.ts +2 -2
  28. package/audits/initialState.js +6 -0
  29. package/audits/interfaces.d.ts +6 -6
  30. package/audits/interfaces.js +1 -0
  31. package/audits/reducer.d.ts +31 -31
  32. package/audits/reducer.js +23 -0
  33. package/audits/saga.d.ts +2 -2
  34. package/audits/saga.js +9 -0
  35. package/audits/utils.d.ts +14 -14
  36. package/audits/utils.js +13 -0
  37. package/auth/AcceptInvitationState/index.d.ts +85 -85
  38. package/auth/AcceptInvitationState/index.js +20 -0
  39. package/auth/AcceptInvitationState/interfaces.d.ts +11 -11
  40. package/auth/AcceptInvitationState/interfaces.js +9 -0
  41. package/auth/AcceptInvitationState/saga.d.ts +1 -1
  42. package/auth/AcceptInvitationState/saga.js +41 -0
  43. package/auth/AccountSettingsState/index.d.ts +92 -92
  44. package/auth/AccountSettingsState/index.js +22 -0
  45. package/auth/AccountSettingsState/interfaces.d.ts +10 -10
  46. package/auth/AccountSettingsState/interfaces.js +1 -0
  47. package/auth/AccountSettingsState/saga.d.ts +2 -2
  48. package/auth/AccountSettingsState/saga.js +133 -0
  49. package/auth/ActivateState/index.d.ts +130 -130
  50. package/auth/ActivateState/index.js +35 -0
  51. package/auth/ActivateState/interfaces.d.ts +26 -26
  52. package/auth/ActivateState/interfaces.js +8 -0
  53. package/auth/ActivateState/saga.d.ts +1 -1
  54. package/auth/ActivateState/saga.js +187 -0
  55. package/auth/ApiTokensState/index.d.ts +119 -119
  56. package/auth/ApiTokensState/index.js +54 -0
  57. package/auth/ApiTokensState/interfaces.d.ts +49 -49
  58. package/auth/ApiTokensState/interfaces.js +7 -0
  59. package/auth/ApiTokensState/saga.d.ts +2 -2
  60. package/auth/ApiTokensState/saga.js +410 -0
  61. package/auth/ForgotPasswordState/index.d.ts +90 -90
  62. package/auth/ForgotPasswordState/index.js +29 -0
  63. package/auth/ForgotPasswordState/interfaces.d.ts +18 -18
  64. package/auth/ForgotPasswordState/interfaces.js +6 -0
  65. package/auth/ForgotPasswordState/saga.d.ts +8 -8
  66. package/auth/ForgotPasswordState/saga.js +83 -0
  67. package/auth/LoginState/index.d.ts +132 -144
  68. package/auth/LoginState/index.js +64 -0
  69. package/auth/LoginState/interfaces.d.ts +41 -60
  70. package/auth/LoginState/interfaces.js +17 -0
  71. package/auth/LoginState/saga.d.ts +80 -84
  72. package/auth/LoginState/saga.js +860 -0
  73. package/auth/MfaState/index.d.ts +92 -92
  74. package/auth/MfaState/index.js +28 -0
  75. package/auth/MfaState/interfaces.d.ts +12 -12
  76. package/auth/MfaState/interfaces.js +6 -0
  77. package/auth/MfaState/saga.d.ts +2 -2
  78. package/auth/MfaState/saga.js +252 -0
  79. package/auth/ProfileState/index.d.ts +90 -90
  80. package/auth/ProfileState/index.js +24 -0
  81. package/auth/ProfileState/interfaces.d.ts +9 -9
  82. package/auth/ProfileState/interfaces.js +1 -0
  83. package/auth/ProfileState/saga.d.ts +2 -2
  84. package/auth/ProfileState/saga.js +230 -0
  85. package/auth/ResetPhoneNumberState/index.d.ts +96 -96
  86. package/auth/ResetPhoneNumberState/index.js +27 -0
  87. package/auth/ResetPhoneNumberState/interfaces.d.ts +18 -18
  88. package/auth/ResetPhoneNumberState/interfaces.js +7 -0
  89. package/auth/ResetPhoneNumberState/saga.d.ts +17 -17
  90. package/auth/ResetPhoneNumberState/saga.js +127 -0
  91. package/auth/RolesState/index.d.ts +100 -100
  92. package/auth/RolesState/index.js +37 -0
  93. package/auth/RolesState/interfaces.d.ts +7 -7
  94. package/auth/RolesState/interfaces.js +1 -0
  95. package/auth/RolesState/saga.d.ts +1 -1
  96. package/auth/RolesState/saga.js +197 -0
  97. package/auth/SSOState/index.d.ts +224 -224
  98. package/auth/SSOState/index.js +83 -0
  99. package/auth/SSOState/interfaces.d.ts +92 -92
  100. package/auth/SSOState/interfaces.js +28 -0
  101. package/auth/SSOState/saga.d.ts +2 -2
  102. package/auth/SSOState/saga.js +523 -0
  103. package/auth/SSOState/saga.v2.d.ts +1 -1
  104. package/auth/SSOState/saga.v2.js +501 -0
  105. package/auth/SecurityPolicyState/index.d.ts +456 -502
  106. package/auth/SecurityPolicyState/index.js +64 -0
  107. package/auth/SecurityPolicyState/interfaces.d.ts +26 -28
  108. package/auth/SecurityPolicyState/interfaces.js +1 -0
  109. package/auth/SecurityPolicyState/saga.d.ts +18 -24
  110. package/auth/SecurityPolicyState/saga.js +464 -0
  111. package/auth/SignUp/index.d.ts +86 -86
  112. package/auth/SignUp/index.js +25 -0
  113. package/auth/SignUp/interfaces.d.ts +19 -19
  114. package/auth/SignUp/interfaces.js +6 -0
  115. package/auth/SignUp/saga.d.ts +49 -49
  116. package/auth/SignUp/saga.js +147 -0
  117. package/auth/SocialLogins/index.d.ts +91 -91
  118. package/auth/SocialLogins/index.js +26 -0
  119. package/auth/SocialLogins/interfaces.d.ts +13 -13
  120. package/auth/SocialLogins/interfaces.js +1 -0
  121. package/auth/SocialLogins/saga.d.ts +10 -10
  122. package/auth/SocialLogins/saga.js +140 -0
  123. package/auth/TeamState/index.d.ts +168 -168
  124. package/auth/TeamState/index.js +111 -0
  125. package/auth/TeamState/interfaces.d.ts +78 -78
  126. package/auth/TeamState/interfaces.js +16 -0
  127. package/auth/TeamState/saga.d.ts +2 -2
  128. package/auth/TeamState/saga.js +1123 -0
  129. package/auth/TenantsState/index.d.ts +104 -104
  130. package/auth/TenantsState/index.js +31 -0
  131. package/auth/TenantsState/interfaces.d.ts +9 -9
  132. package/auth/TenantsState/interfaces.js +1 -0
  133. package/auth/TenantsState/saga.d.ts +2 -2
  134. package/auth/TenantsState/saga.js +136 -0
  135. package/auth/dummy.d.ts +28 -28
  136. package/auth/dummy.js +250 -0
  137. package/auth/index.d.ts +378 -392
  138. package/auth/index.js +46 -4078
  139. package/auth/initialState.d.ts +3 -3
  140. package/auth/initialState.js +58 -0
  141. package/auth/interfaces.d.ts +161 -161
  142. package/auth/interfaces.js +14 -0
  143. package/auth/reducer.d.ts +356 -370
  144. package/auth/reducer.js +39 -0
  145. package/auth/saga.d.ts +2 -2
  146. package/auth/saga.js +24 -0
  147. package/auth/utils.d.ts +162 -165
  148. package/auth/utils.js +74 -0
  149. package/connectivity/ConnectivityState/index.d.ts +292 -292
  150. package/connectivity/ConnectivityState/index.js +94 -0
  151. package/connectivity/consts.d.ts +12 -12
  152. package/connectivity/consts.js +71 -0
  153. package/connectivity/index.d.ts +40 -40
  154. package/connectivity/index.js +12 -454
  155. package/connectivity/interfaces.d.ts +112 -112
  156. package/connectivity/interfaces.js +1 -0
  157. package/connectivity/reducer.d.ts +31 -31
  158. package/connectivity/reducer.js +25 -0
  159. package/connectivity/saga.d.ts +1 -1
  160. package/connectivity/saga.js +546 -0
  161. package/constants.d.ts +7 -7
  162. package/constants.js +7 -0
  163. package/helpers.d.ts +5 -5
  164. package/helpers.js +37 -0
  165. package/index.d.ts +28 -28
  166. package/index.js +17 -15
  167. package/interfaces.d.ts +15 -15
  168. package/interfaces.js +1 -0
  169. package/node/audits/AuditLogsState/index.js +43 -0
  170. package/node/audits/AuditLogsState/interfaces.js +5 -0
  171. package/node/audits/AuditLogsState/saga.js +181 -0
  172. package/node/audits/AuditsMetadataState/index.js +33 -0
  173. package/node/audits/AuditsMetadataState/interfaces.js +5 -0
  174. package/node/audits/AuditsMetadataState/saga.js +67 -0
  175. package/node/audits/backward-compatibility/index.js +52 -12
  176. package/node/audits/backward-compatibility/initialState.js +27 -0
  177. package/node/audits/backward-compatibility/interfaces.js +5 -0
  178. package/node/audits/backward-compatibility/reducer.js +144 -0
  179. package/node/audits/backward-compatibility/saga.js +199 -0
  180. package/node/audits/dummy.js +204 -0
  181. package/node/audits/index.js +124 -364
  182. package/node/audits/initialState.js +16 -0
  183. package/node/audits/interfaces.js +5 -0
  184. package/node/audits/reducer.js +37 -0
  185. package/node/audits/saga.js +21 -0
  186. package/node/audits/utils.js +25 -0
  187. package/node/auth/AcceptInvitationState/index.js +33 -0
  188. package/node/auth/AcceptInvitationState/interfaces.js +16 -0
  189. package/node/auth/AcceptInvitationState/saga.js +51 -0
  190. package/node/auth/AccountSettingsState/index.js +34 -0
  191. package/node/auth/AccountSettingsState/interfaces.js +5 -0
  192. package/node/auth/AccountSettingsState/saga.js +145 -0
  193. package/node/auth/ActivateState/index.js +48 -0
  194. package/node/auth/ActivateState/interfaces.js +15 -0
  195. package/node/auth/ActivateState/saga.js +201 -0
  196. package/node/auth/ApiTokensState/index.js +66 -0
  197. package/node/auth/ApiTokensState/interfaces.js +14 -0
  198. package/node/auth/ApiTokensState/saga.js +424 -0
  199. package/node/auth/ForgotPasswordState/index.js +42 -0
  200. package/node/auth/ForgotPasswordState/interfaces.js +13 -0
  201. package/node/auth/ForgotPasswordState/saga.js +98 -0
  202. package/node/auth/LoginState/index.js +77 -0
  203. package/node/auth/LoginState/interfaces.js +31 -0
  204. package/node/auth/LoginState/saga.js +918 -0
  205. package/node/auth/MfaState/index.js +41 -0
  206. package/node/auth/MfaState/interfaces.js +13 -0
  207. package/node/auth/MfaState/saga.js +265 -0
  208. package/node/auth/ProfileState/index.js +36 -0
  209. package/node/auth/ProfileState/interfaces.js +5 -0
  210. package/node/auth/ProfileState/saga.js +245 -0
  211. package/node/auth/ResetPhoneNumberState/index.js +40 -0
  212. package/node/auth/ResetPhoneNumberState/interfaces.js +14 -0
  213. package/node/auth/ResetPhoneNumberState/saga.js +141 -0
  214. package/node/auth/RolesState/index.js +49 -0
  215. package/node/auth/RolesState/interfaces.js +5 -0
  216. package/node/auth/RolesState/saga.js +205 -0
  217. package/node/auth/SSOState/index.js +95 -0
  218. package/node/auth/SSOState/interfaces.js +36 -0
  219. package/node/auth/SSOState/saga.js +535 -0
  220. package/node/auth/SSOState/saga.v2.js +512 -0
  221. package/node/auth/SecurityPolicyState/index.js +76 -0
  222. package/node/auth/SecurityPolicyState/interfaces.js +5 -0
  223. package/node/auth/SecurityPolicyState/saga.js +472 -0
  224. package/node/auth/SignUp/index.js +38 -0
  225. package/node/auth/SignUp/interfaces.js +13 -0
  226. package/node/auth/SignUp/saga.js +173 -0
  227. package/node/auth/SocialLogins/index.js +38 -0
  228. package/node/auth/SocialLogins/interfaces.js +5 -0
  229. package/node/auth/SocialLogins/saga.js +162 -0
  230. package/node/auth/TeamState/index.js +123 -0
  231. package/node/auth/TeamState/interfaces.js +23 -0
  232. package/node/auth/TeamState/saga.js +1118 -0
  233. package/node/auth/TenantsState/index.js +43 -0
  234. package/node/auth/TenantsState/interfaces.js +5 -0
  235. package/node/auth/TenantsState/saga.js +149 -0
  236. package/node/auth/dummy.js +284 -0
  237. package/node/auth/index.js +528 -170
  238. package/node/auth/initialState.js +86 -0
  239. package/node/auth/interfaces.js +22 -0
  240. package/node/auth/reducer.js +68 -0
  241. package/node/auth/saga.js +51 -0
  242. package/node/auth/utils.js +104 -0
  243. package/node/connectivity/ConnectivityState/index.js +107 -0
  244. package/node/connectivity/consts.js +84 -0
  245. package/node/connectivity/index.js +64 -455
  246. package/node/connectivity/interfaces.js +5 -0
  247. package/node/connectivity/reducer.js +38 -0
  248. package/node/connectivity/saga.js +560 -0
  249. package/node/{constants-52e37c08.js → constants.js} +14 -11
  250. package/node/helpers.js +57 -0
  251. package/node/index.js +120 -293
  252. package/node/interfaces.js +5 -0
  253. package/node/subscriptions/Billing/Information/index.js +42 -0
  254. package/node/subscriptions/Billing/Information/interfaces.js +5 -0
  255. package/node/subscriptions/Billing/Information/saga.js +141 -0
  256. package/node/subscriptions/Billing/Invoices/index.js +55 -0
  257. package/node/subscriptions/Billing/Invoices/interfaces.js +5 -0
  258. package/node/subscriptions/Billing/Invoices/saga.js +92 -0
  259. package/node/subscriptions/Billing/PaymentMethod/index.js +51 -0
  260. package/node/subscriptions/Billing/PaymentMethod/interfaces.js +13 -0
  261. package/node/subscriptions/Billing/PaymentMethod/saga.js +98 -0
  262. package/node/subscriptions/Billing/Subscription/index.js +53 -0
  263. package/node/subscriptions/Billing/Subscription/interfaces.js +5 -0
  264. package/node/subscriptions/Billing/Subscription/saga.js +131 -0
  265. package/node/subscriptions/Billing/index.js +38 -0
  266. package/node/subscriptions/Billing/interfaces.js +57 -0
  267. package/node/subscriptions/Billing/saga.js +25 -0
  268. package/node/subscriptions/Checkout/index.js +47 -0
  269. package/node/subscriptions/Checkout/interfaces.js +5 -0
  270. package/node/subscriptions/Checkout/saga.js +129 -0
  271. package/node/subscriptions/Config/index.js +39 -0
  272. package/node/subscriptions/Config/interfaces.js +5 -0
  273. package/node/subscriptions/Config/saga.js +71 -0
  274. package/node/subscriptions/Plans/index.js +38 -0
  275. package/node/subscriptions/Plans/interfaces.js +5 -0
  276. package/node/subscriptions/Plans/saga.js +73 -0
  277. package/node/subscriptions/Stripe/index.js +39 -0
  278. package/node/subscriptions/Stripe/interfaces.js +5 -0
  279. package/node/subscriptions/Stripe/saga.js +44 -0
  280. package/node/subscriptions/dummy.js +84 -0
  281. package/node/subscriptions/general.interfaces.js +30 -0
  282. package/node/subscriptions/index.js +70 -906
  283. package/node/subscriptions/interfaces.js +83 -0
  284. package/node/subscriptions/mapper.js +51 -0
  285. package/node/subscriptions/reducer.js +52 -0
  286. package/node/subscriptions/saga.js +27 -0
  287. package/node/subscriptions/utils.js +68 -0
  288. package/node/toolkit/index.js +163 -99
  289. package/node/toolkit/redux-saga.js +59 -0
  290. package/node/toolkit/redux.js +43 -0
  291. package/node/vendor/VendorState/index.js +26 -0
  292. package/node/vendor/index.js +66 -13
  293. package/node/vendor/interfaces.js +5 -0
  294. package/node/vendor/reducer.js +32 -0
  295. package/node/vendor/saga.js +48 -0
  296. package/package.json +12 -11
  297. package/subscriptions/Billing/Information/index.d.ts +12 -12
  298. package/subscriptions/Billing/Information/index.js +30 -0
  299. package/subscriptions/Billing/Information/interfaces.d.ts +14 -14
  300. package/subscriptions/Billing/Information/interfaces.js +1 -0
  301. package/subscriptions/Billing/Information/saga.d.ts +52 -52
  302. package/subscriptions/Billing/Information/saga.js +118 -0
  303. package/subscriptions/Billing/Invoices/index.d.ts +18 -18
  304. package/subscriptions/Billing/Invoices/index.js +44 -0
  305. package/subscriptions/Billing/Invoices/interfaces.d.ts +19 -19
  306. package/subscriptions/Billing/Invoices/interfaces.js +1 -0
  307. package/subscriptions/Billing/Invoices/saga.d.ts +13 -13
  308. package/subscriptions/Billing/Invoices/saga.js +75 -0
  309. package/subscriptions/Billing/PaymentMethod/index.d.ts +20 -20
  310. package/subscriptions/Billing/PaymentMethod/index.js +40 -0
  311. package/subscriptions/Billing/PaymentMethod/interfaces.d.ts +46 -46
  312. package/subscriptions/Billing/PaymentMethod/interfaces.js +6 -0
  313. package/subscriptions/Billing/PaymentMethod/saga.d.ts +13 -13
  314. package/subscriptions/Billing/PaymentMethod/saga.js +81 -0
  315. package/subscriptions/Billing/Subscription/index.d.ts +16 -16
  316. package/subscriptions/Billing/Subscription/index.js +42 -0
  317. package/subscriptions/Billing/Subscription/interfaces.d.ts +18 -18
  318. package/subscriptions/Billing/Subscription/interfaces.js +1 -0
  319. package/subscriptions/Billing/Subscription/saga.d.ts +13 -13
  320. package/subscriptions/Billing/Subscription/saga.js +117 -0
  321. package/subscriptions/Billing/index.d.ts +54 -54
  322. package/subscriptions/Billing/index.js +23 -0
  323. package/subscriptions/Billing/interfaces.d.ts +20 -20
  324. package/subscriptions/Billing/interfaces.js +5 -0
  325. package/subscriptions/Billing/saga.d.ts +2 -2
  326. package/subscriptions/Billing/saga.js +11 -0
  327. package/subscriptions/Checkout/index.d.ts +14 -14
  328. package/subscriptions/Checkout/index.js +36 -0
  329. package/subscriptions/Checkout/interfaces.d.ts +17 -17
  330. package/subscriptions/Checkout/interfaces.js +1 -0
  331. package/subscriptions/Checkout/saga.d.ts +5 -5
  332. package/subscriptions/Checkout/saga.js +110 -0
  333. package/subscriptions/Config/index.d.ts +10 -10
  334. package/subscriptions/Config/index.js +28 -0
  335. package/subscriptions/Config/interfaces.d.ts +16 -16
  336. package/subscriptions/Config/interfaces.js +1 -0
  337. package/subscriptions/Config/saga.d.ts +2 -2
  338. package/subscriptions/Config/saga.js +59 -0
  339. package/subscriptions/Plans/index.d.ts +10 -10
  340. package/subscriptions/Plans/index.js +25 -0
  341. package/subscriptions/Plans/interfaces.d.ts +10 -10
  342. package/subscriptions/Plans/interfaces.js +1 -0
  343. package/subscriptions/Plans/saga.d.ts +2 -2
  344. package/subscriptions/Plans/saga.js +58 -0
  345. package/subscriptions/Stripe/index.d.ts +11 -11
  346. package/subscriptions/Stripe/index.js +28 -0
  347. package/subscriptions/Stripe/interfaces.d.ts +10 -10
  348. package/subscriptions/Stripe/interfaces.js +1 -0
  349. package/subscriptions/Stripe/saga.d.ts +1 -1
  350. package/subscriptions/Stripe/saga.js +34 -0
  351. package/subscriptions/dummy.d.ts +5 -5
  352. package/subscriptions/dummy.js +72 -0
  353. package/subscriptions/general.interfaces.d.ts +49 -49
  354. package/subscriptions/general.interfaces.js +21 -0
  355. package/subscriptions/index.d.ts +100 -100
  356. package/subscriptions/index.js +13 -906
  357. package/subscriptions/interfaces.d.ts +25 -25
  358. package/subscriptions/interfaces.js +7 -0
  359. package/subscriptions/mapper.d.ts +6 -6
  360. package/subscriptions/mapper.js +36 -0
  361. package/subscriptions/reducer.d.ts +92 -92
  362. package/subscriptions/reducer.js +29 -0
  363. package/subscriptions/saga.d.ts +2 -2
  364. package/subscriptions/saga.js +12 -0
  365. package/subscriptions/utils.d.ts +68 -68
  366. package/subscriptions/utils.js +52 -0
  367. package/toolkit/index.d.ts +24 -23
  368. package/toolkit/index.js +106 -94
  369. package/toolkit/redux-saga.d.ts +4 -4
  370. package/toolkit/redux-saga.js +3 -0
  371. package/toolkit/redux.d.ts +3 -2
  372. package/toolkit/redux.js +1 -0
  373. package/vendor/VendorState/index.d.ts +20 -20
  374. package/vendor/VendorState/index.js +13 -0
  375. package/vendor/index.d.ts +17 -17
  376. package/vendor/index.js +12 -18
  377. package/vendor/interfaces.d.ts +3 -3
  378. package/vendor/interfaces.js +1 -0
  379. package/vendor/reducer.d.ts +8 -8
  380. package/vendor/reducer.js +19 -0
  381. package/vendor/saga.d.ts +8 -8
  382. package/vendor/saga.js +34 -0
  383. package/audits/backward-compatibility/package.json +0 -6
  384. package/constants-4d9682b2.js +0 -9
  385. package/node/index-5642a636.js +0 -4131
  386. package/node/index-6906e508.js +0 -151
  387. package/node/saga-b0d1a607.js +0 -230
  388. package/saga-7a267fe0.js +0 -223
  389. package/saga-b6529ffb.js +0 -36
@@ -0,0 +1,1123 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["callback"],
4
+ _excluded2 = ["roles"],
5
+ _excluded3 = ["callback"],
6
+ _excluded4 = ["callback", "profileImage"],
7
+ _excluded5 = ["callback"],
8
+ _excluded6 = ["callback", "userId"],
9
+ _excluded7 = ["callback"],
10
+ _excluded8 = ["callback"],
11
+ _excluded9 = ["callback"],
12
+ _excluded10 = ["callback"],
13
+ _excluded11 = ["callback"],
14
+ _excluded12 = ["callback", "profileImage"],
15
+ _excluded13 = ["callback"],
16
+ _excluded14 = ["callback"],
17
+ _excluded15 = ["callback"],
18
+ _excluded16 = ["callback"];
19
+ import { takeLatest, put, call, all, takeEvery, select as sagaSelect } from 'redux-saga/effects';
20
+ import { api } from '@frontegg/rest-api';
21
+ import { actions } from '../reducer';
22
+ import { TeamStateKeys } from './interfaces';
23
+ import { authStoreName } from '../../constants';
24
+ import { delay } from '../utils';
25
+ import { allUsersDemo, permissionsDemo, rolesDemo, usersDemo, userTeamDemo } from '../dummy';
26
+ import { v4 as uuidv4 } from 'uuid';
27
+
28
+ const selectTeamState = () => sagaSelect(_ => _[authStoreName].teamState);
29
+
30
+ function* loadUsers({
31
+ payload
32
+ }) {
33
+ var _payload$pageSize, _payload$pageOffset, _payload$filter, _payload$sort;
34
+
35
+ const {
36
+ silentLoading,
37
+ callback
38
+ } = payload;
39
+ const teamState = yield selectTeamState();
40
+ const pageSize = (_payload$pageSize = payload.pageSize) != null ? _payload$pageSize : teamState.pageSize;
41
+ const pageOffset = (_payload$pageOffset = payload.pageOffset) != null ? _payload$pageOffset : teamState.pageOffset;
42
+ const filter = (_payload$filter = payload.filter) != null ? _payload$filter : teamState.filter;
43
+ const sort = (_payload$sort = payload.sort) != null ? _payload$sort : teamState.sort;
44
+ yield put(actions.setTeamLoader({
45
+ key: TeamStateKeys.USERS,
46
+ value: !silentLoading
47
+ }));
48
+ yield put(actions.setTeamState({
49
+ pageSize,
50
+ pageOffset,
51
+ filter,
52
+ sort
53
+ }));
54
+
55
+ try {
56
+ const [{
57
+ items: users,
58
+ totalPages,
59
+ totalItems
60
+ }, {
61
+ items: roles
62
+ }, {
63
+ items: permissions
64
+ }] = yield all([call(api.teams.loadUsers, {
65
+ pageSize,
66
+ pageOffset,
67
+ filter,
68
+ sort
69
+ }), call(api.teams.loadAvailableRoles), call(api.teams.loadAvailablePermissions)]);
70
+ yield put(actions.setTeamState({
71
+ users,
72
+ totalPages,
73
+ totalItems,
74
+ roles,
75
+ permissions
76
+ }));
77
+ callback == null ? void 0 : callback(users);
78
+ } catch (e) {
79
+ yield put(actions.setTeamError({
80
+ key: TeamStateKeys.USERS,
81
+ value: e.message
82
+ }));
83
+ yield put(actions.setTeamState({
84
+ totalPages: 0,
85
+ users: []
86
+ }));
87
+ callback == null ? void 0 : callback(null, e);
88
+ }
89
+
90
+ yield put(actions.setTeamLoader({
91
+ key: TeamStateKeys.USERS,
92
+ value: false
93
+ }));
94
+ }
95
+
96
+ function* loadAllSubTenantsUsers({
97
+ payload
98
+ }) {
99
+ var _payload$_limit, _payload$_offset, _payload$_filter, _payload$_sortBy, _payload$_order;
100
+
101
+ const {
102
+ silentLoading,
103
+ callback
104
+ } = payload;
105
+ const teamState = yield selectTeamState();
106
+
107
+ const _limit = (_payload$_limit = payload._limit) != null ? _payload$_limit : teamState.allUsersQueryParams._limit;
108
+
109
+ const _offset = (_payload$_offset = payload._offset) != null ? _payload$_offset : teamState.allUsersQueryParams._offset;
110
+
111
+ const _filter = (_payload$_filter = payload._filter) != null ? _payload$_filter : teamState.allUsersQueryParams._filter;
112
+
113
+ const _sortBy = (_payload$_sortBy = payload._sortBy) != null ? _payload$_sortBy : teamState.allUsersQueryParams._sortBy;
114
+
115
+ const _order = (_payload$_order = payload._order) != null ? _payload$_order : teamState.allUsersQueryParams._order;
116
+
117
+ const allUsersQueryParams = {
118
+ _limit: _limit || 20,
119
+ _offset: _offset || 0,
120
+ _filter: _filter || '',
121
+ _sortBy: _sortBy || 'name',
122
+ _order: _order || 'DESC'
123
+ };
124
+ yield put(actions.setTeamLoader({
125
+ key: TeamStateKeys.USERS,
126
+ value: !silentLoading
127
+ }));
128
+ yield put(actions.setTeamState({
129
+ allUsersQueryParams
130
+ }));
131
+
132
+ try {
133
+ const [{
134
+ items: users,
135
+ _metadata: {
136
+ totalPages,
137
+ totalItems
138
+ }
139
+ }, {
140
+ items: roles
141
+ }, {
142
+ items: permissions
143
+ }] = yield all([call(api.subTenants.loadAllUsers, _extends({}, allUsersQueryParams)), call(api.teams.loadAvailableRoles), call(api.teams.loadAvailablePermissions)]);
144
+ yield put(actions.setTeamState({
145
+ allUsers: users,
146
+ totalPages,
147
+ totalItems,
148
+ roles,
149
+ permissions
150
+ }));
151
+ callback == null ? void 0 : callback(users);
152
+ } catch (e) {
153
+ yield put(actions.setTeamError({
154
+ key: TeamStateKeys.USERS,
155
+ value: e.message
156
+ }));
157
+ yield put(actions.setTeamState({
158
+ totalPages: 0,
159
+ users: []
160
+ }));
161
+ callback == null ? void 0 : callback(null, e);
162
+ }
163
+
164
+ yield put(actions.setTeamLoader({
165
+ key: TeamStateKeys.USERS,
166
+ value: false
167
+ }));
168
+ }
169
+
170
+ function* loadRoles({
171
+ payload
172
+ }) {
173
+ yield put(actions.setTeamLoader({
174
+ key: TeamStateKeys.ROLES_AND_PERMISSIONS,
175
+ value: true
176
+ }));
177
+
178
+ try {
179
+ var _payload$callback;
180
+
181
+ const [{
182
+ items: roles
183
+ }, {
184
+ items: permissions
185
+ }] = yield all([call(api.teams.loadAvailableRoles), call(api.teams.loadAvailablePermissions)]);
186
+ yield put(actions.setTeamState({
187
+ roles,
188
+ permissions
189
+ }));
190
+ payload == null ? void 0 : (_payload$callback = payload.callback) == null ? void 0 : _payload$callback.call(payload, {
191
+ roles,
192
+ permissions
193
+ });
194
+ } catch (e) {
195
+ var _payload$callback2;
196
+
197
+ payload == null ? void 0 : (_payload$callback2 = payload.callback) == null ? void 0 : _payload$callback2.call(payload, null, e);
198
+ yield put(actions.setTeamError({
199
+ key: TeamStateKeys.ROLES_AND_PERMISSIONS,
200
+ value: e.message
201
+ }));
202
+ }
203
+
204
+ yield put(actions.setTeamLoader({
205
+ key: TeamStateKeys.ROLES_AND_PERMISSIONS,
206
+ value: true
207
+ }));
208
+ }
209
+
210
+ function* addUser({
211
+ payload
212
+ }) {
213
+ const {
214
+ callback
215
+ } = payload,
216
+ body = _objectWithoutPropertiesLoose(payload, _excluded);
217
+
218
+ const teamState = yield selectTeamState();
219
+ yield put(actions.setTeamState({
220
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
221
+ loading: true
222
+ })
223
+ }));
224
+
225
+ try {
226
+ const res = yield call(api.teams.addUser, body);
227
+
228
+ const {
229
+ roles
230
+ } = res,
231
+ userWithoutRoleIds = _objectWithoutPropertiesLoose(res, _excluded2);
232
+
233
+ const roleIds = roles.map(role => role.id);
234
+
235
+ const newUser = _extends({}, userWithoutRoleIds, {
236
+ roleIds
237
+ });
238
+
239
+ callback == null ? void 0 : callback(newUser);
240
+ yield put(actions.setTeamState({
241
+ users: [newUser, ...teamState.users],
242
+ addUserDialogState: {
243
+ open: false,
244
+ loading: false
245
+ }
246
+ }));
247
+ } catch (e) {
248
+ yield put(actions.setTeamState({
249
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
250
+ loading: false,
251
+ error: e.message
252
+ })
253
+ }));
254
+ callback == null ? void 0 : callback(null, e.message);
255
+ }
256
+ }
257
+
258
+ function* addUserToSubTenants({
259
+ payload
260
+ }) {
261
+ const {
262
+ callback
263
+ } = payload,
264
+ body = _objectWithoutPropertiesLoose(payload, _excluded3);
265
+
266
+ const teamState = yield selectTeamState();
267
+ yield put(actions.setTeamState({
268
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
269
+ loading: true
270
+ })
271
+ }));
272
+
273
+ try {
274
+ yield call(api.subTenants.addUserToTenantAndSubTenants, body);
275
+ const {
276
+ items: users,
277
+ _metadata: {
278
+ totalPages,
279
+ totalItems
280
+ }
281
+ } = yield call(api.subTenants.loadAllUsers, {
282
+ _limit: 20,
283
+ _offset: 0,
284
+ _filter: '',
285
+ _sortBy: 'name',
286
+ _order: 'DESC'
287
+ });
288
+ yield put(actions.setTeamState({
289
+ allUsers: users,
290
+ totalPages,
291
+ totalItems,
292
+ addUserDialogState: {
293
+ open: false,
294
+ loading: false
295
+ }
296
+ }));
297
+ callback == null ? void 0 : callback(null);
298
+ } catch (e) {
299
+ yield put(actions.setTeamState({
300
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
301
+ loading: false,
302
+ error: e.message
303
+ })
304
+ }));
305
+ callback == null ? void 0 : callback(null, e.message);
306
+ }
307
+ }
308
+
309
+ function* updateUser({
310
+ payload
311
+ }) {
312
+ const {
313
+ callback
314
+ } = payload,
315
+ body = _objectWithoutPropertiesLoose(payload, _excluded4);
316
+
317
+ const {
318
+ id: userId
319
+ } = body;
320
+ const teamState = yield selectTeamState();
321
+ const oldUserData = teamState.users.find(user => user.id === body.id);
322
+ yield put(actions.setTeamLoader({
323
+ key: TeamStateKeys.UPDATE_USER,
324
+ value: userId || ''
325
+ }));
326
+ yield put(actions.setTeamState({
327
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
328
+ loading: true
329
+ })
330
+ }));
331
+ yield put(actions.setTeamState({
332
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
333
+ loading: true
334
+ }),
335
+ users: teamState.users.map(user => {
336
+ if (user.id === body.id) {
337
+ return _extends({}, user, body);
338
+ }
339
+
340
+ return user;
341
+ })
342
+ }));
343
+
344
+ try {
345
+ var _body$roleIds;
346
+
347
+ if (oldUserData.roleIds.length > 0 && ((_body$roleIds = body.roleIds) == null ? void 0 : _body$roleIds.length) === 0) {
348
+ body.roleIds = [''];
349
+ }
350
+
351
+ const {
352
+ item: newUser
353
+ } = yield call(api.teams.updateUser, body);
354
+ callback == null ? void 0 : callback(newUser);
355
+ yield put(actions.setTeamState({
356
+ users: teamState.users.map(user => user.id === newUser.id ? _extends({}, user, newUser, {
357
+ createdAt: user.createdAt,
358
+ customData: user.customData,
359
+ lastLogin: user.lastLogin
360
+ }) : user)
361
+ }));
362
+ yield put(actions.setTeamLoader({
363
+ key: TeamStateKeys.UPDATE_USER,
364
+ value: false
365
+ }));
366
+ } catch (e) {
367
+ yield put(actions.setTeamState({
368
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
369
+ loading: false,
370
+ error: e.message
371
+ }),
372
+ users: teamState.users.map(user => user.id === body.id ? _extends({}, user, oldUserData) : user)
373
+ }));
374
+ yield put(actions.setTeamLoader({
375
+ key: TeamStateKeys.UPDATE_USER,
376
+ value: false
377
+ }));
378
+ callback == null ? void 0 : callback(null, e.message);
379
+ }
380
+ }
381
+
382
+ function* deleteUser({
383
+ payload
384
+ }) {
385
+ const {
386
+ callback
387
+ } = payload,
388
+ body = _objectWithoutPropertiesLoose(payload, _excluded5);
389
+
390
+ const teamState = yield selectTeamState();
391
+ yield put(actions.setTeamState({
392
+ deleteUserDialogState: _extends({}, teamState.deleteUserDialogState, {
393
+ loading: true
394
+ })
395
+ }));
396
+
397
+ try {
398
+ yield call(api.teams.deleteUser, body);
399
+ callback == null ? void 0 : callback(true);
400
+ yield put(actions.setTeamState({
401
+ users: teamState.users.filter(user => user.id !== body.userId),
402
+ deleteUserDialogState: {
403
+ open: false,
404
+ loading: false
405
+ }
406
+ }));
407
+ } catch (e) {
408
+ yield put(actions.setTeamState({
409
+ deleteUserDialogState: _extends({}, teamState.deleteUserDialogState, {
410
+ loading: false,
411
+ error: e.message
412
+ })
413
+ }));
414
+ callback == null ? void 0 : callback(null, e.message);
415
+ }
416
+ }
417
+
418
+ function* setUserRolesForSubTenants({
419
+ payload
420
+ }) {
421
+ const {
422
+ callback,
423
+ userId
424
+ } = payload,
425
+ body = _objectWithoutPropertiesLoose(payload, _excluded6);
426
+
427
+ const teamState = yield selectTeamState();
428
+ yield put(actions.setTeamState({
429
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
430
+ loading: true
431
+ })
432
+ }));
433
+
434
+ try {
435
+ yield call(api.subTenants.setUserRolesForSubTenants, userId, body);
436
+ const updatedUser = teamState.allUsers.find(user => user.id === userId);
437
+
438
+ if (updatedUser) {
439
+ updatedUser.tenants = updatedUser.tenants.map(tenant => {
440
+ var _body$subTenantsRoles;
441
+
442
+ return _extends({}, tenant, {
443
+ roles: ((_body$subTenantsRoles = body.subTenantsRoles.find(roleUpdate => roleUpdate.tenantId === tenant.tenantId)) == null ? void 0 : _body$subTenantsRoles.roleIds.map(roleId => {
444
+ const role = teamState.roles.find(({
445
+ id
446
+ }) => roleId === id);
447
+ return role;
448
+ }).filter(role => role)) || tenant.roles
449
+ });
450
+ });
451
+ }
452
+
453
+ yield put(actions.setTeamState({
454
+ allUsers: [...teamState.allUsers.filter(user => user.id !== userId), ...(updatedUser ? [updatedUser] : [])],
455
+ addUserDialogState: {
456
+ open: false,
457
+ loading: false
458
+ }
459
+ }));
460
+ callback == null ? void 0 : callback(true);
461
+ } catch (e) {
462
+ yield put(actions.setTeamState({
463
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
464
+ loading: false,
465
+ error: e.message
466
+ })
467
+ }));
468
+ callback == null ? void 0 : callback(null, e.message);
469
+ }
470
+ }
471
+
472
+ function* deleteUserFromSubTenants({
473
+ payload
474
+ }) {
475
+ const {
476
+ callback
477
+ } = payload,
478
+ body = _objectWithoutPropertiesLoose(payload, _excluded7);
479
+
480
+ const teamState = yield selectTeamState();
481
+ yield put(actions.setTeamState({
482
+ deleteUserDialogState: _extends({}, teamState.deleteUserDialogState, {
483
+ loading: true
484
+ })
485
+ }));
486
+
487
+ try {
488
+ yield call(api.subTenants.removeUserFromTenantAndSubTenants, body);
489
+ callback == null ? void 0 : callback(true);
490
+ yield put(actions.setTeamState({
491
+ allUsers: teamState.allUsers.filter(user => user.id !== body.userId && user.tenants.length === body.subTenants.length),
492
+ deleteUserDialogState: {
493
+ open: false,
494
+ loading: false
495
+ }
496
+ }));
497
+ } catch (e) {
498
+ yield put(actions.setTeamState({
499
+ deleteUserDialogState: _extends({}, teamState.deleteUserDialogState, {
500
+ loading: false,
501
+ error: e.message
502
+ })
503
+ }));
504
+ callback == null ? void 0 : callback(null, e.message);
505
+ }
506
+ }
507
+
508
+ function* resendActivationLink({
509
+ payload
510
+ }) {
511
+ const {
512
+ callback
513
+ } = payload,
514
+ body = _objectWithoutPropertiesLoose(payload, _excluded8);
515
+
516
+ yield put(actions.setTeamLoader({
517
+ key: TeamStateKeys.RESEND_ACTIVATE_LINK,
518
+ value: body.userId
519
+ }));
520
+
521
+ try {
522
+ yield call(api.teams.resendActivationLink, body);
523
+ callback == null ? void 0 : callback(true);
524
+ } catch (e) {
525
+ yield put(actions.setTeamError({
526
+ key: TeamStateKeys.RESEND_ACTIVATE_LINK,
527
+ value: e.message
528
+ }));
529
+ callback == null ? void 0 : callback(null, e.message);
530
+ }
531
+
532
+ yield put(actions.setTeamLoader({
533
+ key: TeamStateKeys.RESEND_ACTIVATE_LINK,
534
+ value: false
535
+ }));
536
+ }
537
+
538
+ function* resendInvitationLink({
539
+ payload
540
+ }) {
541
+ const {
542
+ callback
543
+ } = payload,
544
+ body = _objectWithoutPropertiesLoose(payload, _excluded9);
545
+
546
+ yield put(actions.setTeamLoader({
547
+ key: TeamStateKeys.RESEND_INVITATION_LINK,
548
+ value: body.email
549
+ }));
550
+
551
+ try {
552
+ yield call(api.teams.resendInvitationLink, body);
553
+ callback == null ? void 0 : callback(true);
554
+ } catch (e) {
555
+ yield put(actions.setTeamError({
556
+ key: TeamStateKeys.RESEND_INVITATION_LINK,
557
+ value: e.message
558
+ }));
559
+ callback == null ? void 0 : callback(null, e.message);
560
+ }
561
+
562
+ yield put(actions.setTeamLoader({
563
+ key: TeamStateKeys.RESEND_INVITATION_LINK,
564
+ value: false
565
+ }));
566
+ }
567
+
568
+ function* getInvitationLinkConfig() {
569
+ yield put(actions.setTeamError({
570
+ key: TeamStateKeys.CONFIG_TOKEN_LINK,
571
+ value: false
572
+ }));
573
+
574
+ try {
575
+ const invitationLinkConfig = yield call(api.teams.getInviteLinkConfiguration);
576
+ yield put(actions.setTeamState({
577
+ inviteTokenState: _extends({}, invitationLinkConfig)
578
+ }));
579
+ } catch (e) {
580
+ yield put(actions.setTeamError({
581
+ key: TeamStateKeys.CONFIG_TOKEN_LINK,
582
+ value: e.message
583
+ }));
584
+ }
585
+ }
586
+
587
+ function* getInvitationLink() {
588
+ yield put(actions.setTeamError({
589
+ key: TeamStateKeys.GET_TOKEN_LINK,
590
+ value: false
591
+ }));
592
+
593
+ try {
594
+ yield call(getInvitationLinkConfig);
595
+ const data = yield call(api.teams.getInviteUserLink);
596
+ const {
597
+ inviteTokenState
598
+ } = yield selectTeamState();
599
+ yield put(actions.setTeamState({
600
+ inviteTokenState: _extends({}, inviteTokenState, data)
601
+ }));
602
+ } catch (e) {
603
+ yield put(actions.setTeamError({
604
+ key: TeamStateKeys.GET_TOKEN_LINK,
605
+ value: e.message
606
+ }));
607
+ }
608
+ }
609
+
610
+ function* createInvitationLink({
611
+ payload: {
612
+ callback
613
+ }
614
+ }) {
615
+ yield put(actions.setTeamError({
616
+ key: TeamStateKeys.CREATE_TOKEN_LINK,
617
+ value: false
618
+ }));
619
+ const {
620
+ inviteTokenState
621
+ } = yield selectTeamState();
622
+
623
+ try {
624
+ const data = yield call(api.teams.createInviteUserLink, {
625
+ expiresInMinutes: 43200
626
+ });
627
+ yield put(actions.setTeamState({
628
+ inviteTokenState: _extends({}, inviteTokenState, data)
629
+ }));
630
+ callback == null ? void 0 : callback(data.token);
631
+ } catch (e) {
632
+ callback == null ? void 0 : callback(null, e.message);
633
+ yield put(actions.setTeamError({
634
+ key: TeamStateKeys.CREATE_TOKEN_LINK,
635
+ value: e.message
636
+ }));
637
+ }
638
+ }
639
+
640
+ function* updateInvitationLink({
641
+ payload: {
642
+ callback,
643
+ expiresInMinutes,
644
+ shouldSendEmail
645
+ }
646
+ }) {
647
+ const {
648
+ inviteTokenState
649
+ } = yield selectTeamState();
650
+ yield put(actions.setTeamError({
651
+ key: TeamStateKeys.UPDATE_TOKEN_LINK,
652
+ value: false
653
+ }));
654
+
655
+ try {
656
+ const data = yield call(api.teams.updateInviteUserLink, {
657
+ expiresInMinutes,
658
+ shouldSendEmail
659
+ });
660
+ yield put(actions.setTeamState({
661
+ inviteTokenState: _extends({}, inviteTokenState, data)
662
+ }));
663
+ callback == null ? void 0 : callback(true);
664
+ } catch (e) {
665
+ callback == null ? void 0 : callback(null, e.message);
666
+ yield put(actions.setTeamError({
667
+ key: TeamStateKeys.UPDATE_TOKEN_LINK,
668
+ value: e.message
669
+ }));
670
+ }
671
+ }
672
+
673
+ function* deleteInvitationLink({
674
+ payload
675
+ }) {
676
+ const {
677
+ callback
678
+ } = payload != null ? payload : {};
679
+ yield put(actions.setTeamError({
680
+ key: TeamStateKeys.DELETE_TOKEN_LINK,
681
+ value: false
682
+ }));
683
+
684
+ try {
685
+ yield call(api.teams.deleteInviteUserLink);
686
+ yield put(actions.setTeamState({
687
+ inviteTokenState: undefined
688
+ }));
689
+ callback == null ? void 0 : callback(true);
690
+ } catch (e) {
691
+ yield put(actions.setTeamError({
692
+ key: TeamStateKeys.DELETE_TOKEN_LINK,
693
+ value: e.message
694
+ }));
695
+ callback == null ? void 0 : callback(false, e.message);
696
+ }
697
+ }
698
+
699
+ function* openAddUserDialog({
700
+ payload
701
+ }) {
702
+ yield put(actions.setTeamState({
703
+ addUserDialogState: _extends({
704
+ open: true,
705
+ loading: false,
706
+ error: false
707
+ }, payload)
708
+ }));
709
+ }
710
+
711
+ function* closeAddUserDialog({
712
+ payload
713
+ }) {
714
+ const teamState = yield selectTeamState();
715
+ const {
716
+ addUserDialogState: {
717
+ onClose
718
+ }
719
+ } = teamState;
720
+ onClose == null ? void 0 : onClose(payload);
721
+ yield put(actions.setTeamState({
722
+ addUserDialogState: {
723
+ loading: false,
724
+ error: false,
725
+ open: false
726
+ }
727
+ }));
728
+ }
729
+
730
+ function* openDeleteUserDialog({
731
+ payload
732
+ }) {
733
+ yield put(actions.setTeamState({
734
+ deleteUserDialogState: _extends({
735
+ open: true,
736
+ loading: false,
737
+ error: false
738
+ }, payload)
739
+ }));
740
+ }
741
+
742
+ function* closeDeleteUserDialog({
743
+ payload
744
+ }) {
745
+ const teamState = yield selectTeamState();
746
+ const {
747
+ deleteUserDialogState: {
748
+ onClose
749
+ }
750
+ } = teamState;
751
+ onClose == null ? void 0 : onClose(payload);
752
+ yield put(actions.setTeamState({
753
+ deleteUserDialogState: {
754
+ loading: false,
755
+ error: false,
756
+ open: false
757
+ }
758
+ }));
759
+ }
760
+
761
+ export function* teamSagas() {
762
+ yield takeLatest(actions.loadUsers, loadUsers);
763
+ yield takeLatest(actions.loadAllSubTenantsUsers, loadAllSubTenantsUsers);
764
+ yield takeLatest(actions.loadRoles, loadRoles);
765
+ yield takeEvery(actions.addUser, addUser);
766
+ yield takeEvery(actions.addUserToSubTenants, addUserToSubTenants);
767
+ yield takeEvery(actions.updateUser, updateUser);
768
+ yield takeEvery(actions.setUserRolesForSubTenants, setUserRolesForSubTenants);
769
+ yield takeEvery(actions.deleteUser, deleteUser);
770
+ yield takeEvery(actions.deleteUserFromSubTenants, deleteUserFromSubTenants);
771
+ yield takeEvery(actions.resendActivationLink, resendActivationLink);
772
+ yield takeEvery(actions.resendInvitationLink, resendInvitationLink);
773
+ yield takeEvery(actions.getInvitationLink, getInvitationLink);
774
+ yield takeEvery(actions.createInvitationLink, createInvitationLink);
775
+ yield takeEvery(actions.updateInvitationLink, updateInvitationLink);
776
+ yield takeEvery(actions.deleteInvitationLink, deleteInvitationLink);
777
+ yield takeEvery(actions.openAddUserDialog, openAddUserDialog);
778
+ yield takeEvery(actions.closeAddUserDialog, closeAddUserDialog);
779
+ yield takeEvery(actions.openDeleteUserDialog, openDeleteUserDialog);
780
+ yield takeEvery(actions.closeDeleteUserDialog, closeDeleteUserDialog);
781
+ }
782
+
783
+ function* loadUsersMock({
784
+ payload
785
+ }) {
786
+ var _payload$pageSize2, _payload$pageOffset2, _payload$filter2, _payload$sort2;
787
+
788
+ const {
789
+ silentLoading,
790
+ callback
791
+ } = payload;
792
+ const teamState = yield selectTeamState();
793
+ const pageSize = (_payload$pageSize2 = payload.pageSize) != null ? _payload$pageSize2 : teamState.pageSize;
794
+ const pageOffset = (_payload$pageOffset2 = payload.pageOffset) != null ? _payload$pageOffset2 : teamState.pageOffset;
795
+ const filter = (_payload$filter2 = payload.filter) != null ? _payload$filter2 : teamState.filter;
796
+ const sort = (_payload$sort2 = payload.sort) != null ? _payload$sort2 : teamState.sort;
797
+ yield put(actions.setTeamLoader({
798
+ key: TeamStateKeys.USERS,
799
+ value: !silentLoading
800
+ }));
801
+ yield put(actions.setTeamState({
802
+ pageSize,
803
+ pageOffset,
804
+ filter,
805
+ sort
806
+ }));
807
+ const totalPages = 2;
808
+ const totalItems = 10;
809
+ yield delay();
810
+ yield put(actions.setTeamState({
811
+ users: usersDemo,
812
+ totalPages,
813
+ totalItems,
814
+ roles: rolesDemo,
815
+ permissions: permissionsDemo
816
+ }));
817
+ yield put(actions.setTeamLoader({
818
+ key: TeamStateKeys.USERS,
819
+ value: false
820
+ }));
821
+ callback == null ? void 0 : callback(usersDemo);
822
+ }
823
+
824
+ function* loadAllSubTenantsUsersMock({
825
+ payload
826
+ }) {
827
+ var _payload$_limit2, _payload$_offset2, _payload$_filter2, _payload$_sortBy2, _payload$_order2;
828
+
829
+ const {
830
+ silentLoading,
831
+ callback
832
+ } = payload;
833
+ const teamState = yield selectTeamState();
834
+
835
+ const _limit = (_payload$_limit2 = payload._limit) != null ? _payload$_limit2 : teamState.allUsersQueryParams._limit;
836
+
837
+ const _offset = (_payload$_offset2 = payload._offset) != null ? _payload$_offset2 : teamState.allUsersQueryParams._offset;
838
+
839
+ const _filter = (_payload$_filter2 = payload._filter) != null ? _payload$_filter2 : teamState.allUsersQueryParams._filter;
840
+
841
+ const _sortBy = (_payload$_sortBy2 = payload._sortBy) != null ? _payload$_sortBy2 : teamState.allUsersQueryParams._sortBy;
842
+
843
+ const _order = (_payload$_order2 = payload._order) != null ? _payload$_order2 : teamState.allUsersQueryParams._order;
844
+
845
+ yield put(actions.setTeamLoader({
846
+ key: TeamStateKeys.USERS,
847
+ value: !silentLoading
848
+ }));
849
+ yield put(actions.setTeamState({
850
+ allUsersQueryParams: {
851
+ _limit,
852
+ _offset,
853
+ _filter,
854
+ _sortBy,
855
+ _order
856
+ }
857
+ }));
858
+ const totalPages = 2;
859
+ const totalItems = 10;
860
+ yield delay();
861
+ yield put(actions.setTeamState({
862
+ allUsers: allUsersDemo,
863
+ totalPages,
864
+ totalItems,
865
+ roles: rolesDemo,
866
+ permissions: permissionsDemo
867
+ }));
868
+ yield put(actions.setTeamLoader({
869
+ key: TeamStateKeys.USERS,
870
+ value: false
871
+ }));
872
+ callback == null ? void 0 : callback(allUsersDemo);
873
+ }
874
+
875
+ function* loadRolesMock({
876
+ payload
877
+ }) {
878
+ var _payload$callback3;
879
+
880
+ yield put(actions.setTeamLoader({
881
+ key: TeamStateKeys.ROLES_AND_PERMISSIONS,
882
+ value: true
883
+ }));
884
+ yield delay();
885
+ yield put(actions.setTeamState({
886
+ roles: rolesDemo,
887
+ permissions: permissionsDemo
888
+ }));
889
+ yield put(actions.setTeamLoader({
890
+ key: TeamStateKeys.ROLES_AND_PERMISSIONS,
891
+ value: true
892
+ }));
893
+ payload == null ? void 0 : (_payload$callback3 = payload.callback) == null ? void 0 : _payload$callback3.call(payload, {
894
+ roles: rolesDemo,
895
+ permissions: permissionsDemo
896
+ });
897
+ }
898
+
899
+ function* addUserMock({
900
+ payload
901
+ }) {
902
+ const {
903
+ callback
904
+ } = payload,
905
+ body = _objectWithoutPropertiesLoose(payload, _excluded10);
906
+
907
+ const teamState = yield selectTeamState();
908
+ yield put(actions.setTeamState({
909
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
910
+ loading: true
911
+ })
912
+ }));
913
+ yield delay();
914
+
915
+ const newUser = _extends({}, userTeamDemo, body, {
916
+ id: `${uuidv4()}`
917
+ });
918
+
919
+ callback == null ? void 0 : callback(newUser);
920
+ yield put(actions.setTeamState({
921
+ users: [newUser, ...teamState.users],
922
+ addUserDialogState: {
923
+ open: false,
924
+ loading: false
925
+ }
926
+ }));
927
+ }
928
+
929
+ function* addUserToSubTenantsMock({
930
+ payload
931
+ }) {
932
+ const {
933
+ callback
934
+ } = payload,
935
+ body = _objectWithoutPropertiesLoose(payload, _excluded11);
936
+
937
+ const teamState = yield selectTeamState();
938
+ yield put(actions.setTeamState({
939
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
940
+ loading: true
941
+ })
942
+ }));
943
+ yield delay();
944
+
945
+ const newUser = _extends({}, userTeamDemo, body, {
946
+ id: `${uuidv4()}`
947
+ });
948
+
949
+ yield put(actions.setTeamState({
950
+ users: [newUser, ...teamState.users],
951
+ addUserDialogState: {
952
+ open: false,
953
+ loading: false
954
+ }
955
+ }));
956
+ callback == null ? void 0 : callback(null);
957
+ }
958
+
959
+ function* updateUserMock({
960
+ payload
961
+ }) {
962
+ var _body$roleIds2;
963
+
964
+ const {
965
+ callback
966
+ } = payload,
967
+ body = _objectWithoutPropertiesLoose(payload, _excluded12);
968
+
969
+ const {
970
+ id: userId
971
+ } = body;
972
+ const teamState = yield selectTeamState();
973
+ const oldUserData = teamState.users.find(user => user.id === body.id);
974
+ yield put(actions.setTeamLoader({
975
+ key: TeamStateKeys.UPDATE_USER,
976
+ value: userId || ''
977
+ }));
978
+ yield put(actions.setTeamState({
979
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
980
+ loading: true
981
+ })
982
+ }));
983
+ yield put(actions.setTeamState({
984
+ addUserDialogState: _extends({}, teamState.addUserDialogState, {
985
+ loading: true
986
+ }),
987
+ users: teamState.users.map(user => {
988
+ if (user.id === body.id) {
989
+ return _extends({}, user, body);
990
+ }
991
+
992
+ return user;
993
+ })
994
+ }));
995
+
996
+ if (oldUserData.roleIds.length > 0 && ((_body$roleIds2 = body.roleIds) == null ? void 0 : _body$roleIds2.length) === 0) {
997
+ body.roleIds = [''];
998
+ }
999
+
1000
+ yield delay();
1001
+
1002
+ const newUser = _extends({}, oldUserData, body);
1003
+
1004
+ callback == null ? void 0 : callback(newUser);
1005
+ yield put(actions.setTeamState({
1006
+ users: teamState.users.map(user => user.id === newUser.id ? _extends({}, user, newUser, {
1007
+ createdAt: user.createdAt,
1008
+ customData: user.customData,
1009
+ lastLogin: user.lastLogin
1010
+ }) : user)
1011
+ }));
1012
+ yield put(actions.setTeamLoader({
1013
+ key: TeamStateKeys.UPDATE_USER,
1014
+ value: false
1015
+ }));
1016
+ }
1017
+
1018
+ function* deleteUserMock({
1019
+ payload
1020
+ }) {
1021
+ const {
1022
+ callback
1023
+ } = payload,
1024
+ body = _objectWithoutPropertiesLoose(payload, _excluded13);
1025
+
1026
+ const teamState = yield selectTeamState();
1027
+ yield put(actions.setTeamState({
1028
+ deleteUserDialogState: _extends({}, teamState.deleteUserDialogState, {
1029
+ loading: true
1030
+ })
1031
+ }));
1032
+ yield delay();
1033
+ callback == null ? void 0 : callback(true);
1034
+ yield put(actions.setTeamState({
1035
+ users: teamState.users.filter(user => user.id !== body.userId),
1036
+ deleteUserDialogState: {
1037
+ open: false,
1038
+ loading: false
1039
+ }
1040
+ }));
1041
+ }
1042
+
1043
+ function* deleteUserFromSubTenantsMock({
1044
+ payload
1045
+ }) {
1046
+ const {
1047
+ callback
1048
+ } = payload,
1049
+ body = _objectWithoutPropertiesLoose(payload, _excluded14);
1050
+
1051
+ const teamState = yield selectTeamState();
1052
+ yield put(actions.setTeamState({
1053
+ deleteUserDialogState: _extends({}, teamState.deleteUserDialogState, {
1054
+ loading: true
1055
+ })
1056
+ }));
1057
+ yield delay();
1058
+ callback == null ? void 0 : callback(true);
1059
+ yield put(actions.setTeamState({
1060
+ allUsers: teamState.allUsers.filter(user => user.id !== body.userId),
1061
+ deleteUserDialogState: {
1062
+ open: false,
1063
+ loading: false
1064
+ }
1065
+ }));
1066
+ }
1067
+
1068
+ function* resendActivationLinkMock({
1069
+ payload
1070
+ }) {
1071
+ const {
1072
+ callback
1073
+ } = payload,
1074
+ body = _objectWithoutPropertiesLoose(payload, _excluded15);
1075
+
1076
+ yield put(actions.setTeamLoader({
1077
+ key: TeamStateKeys.RESEND_ACTIVATE_LINK,
1078
+ value: body.userId
1079
+ }));
1080
+ yield delay();
1081
+ callback == null ? void 0 : callback(true);
1082
+ yield put(actions.setTeamLoader({
1083
+ key: TeamStateKeys.RESEND_ACTIVATE_LINK,
1084
+ value: false
1085
+ }));
1086
+ }
1087
+
1088
+ function* resendInvitationLinkMock({
1089
+ payload
1090
+ }) {
1091
+ const {
1092
+ callback
1093
+ } = payload,
1094
+ body = _objectWithoutPropertiesLoose(payload, _excluded16);
1095
+
1096
+ yield put(actions.setTeamLoader({
1097
+ key: TeamStateKeys.RESEND_INVITATION_LINK,
1098
+ value: body.email
1099
+ }));
1100
+ yield delay();
1101
+ callback == null ? void 0 : callback(true);
1102
+ yield put(actions.setTeamLoader({
1103
+ key: TeamStateKeys.RESEND_INVITATION_LINK,
1104
+ value: false
1105
+ }));
1106
+ }
1107
+
1108
+ export function* teamSagasMock() {
1109
+ yield takeLatest(actions.loadUsers, loadUsersMock);
1110
+ yield takeLatest(actions.loadAllSubTenantsUsers, loadAllSubTenantsUsersMock);
1111
+ yield takeLatest(actions.loadRoles, loadRolesMock);
1112
+ yield takeEvery(actions.addUser, addUserMock);
1113
+ yield takeEvery(actions.addUserToSubTenants, addUserToSubTenantsMock);
1114
+ yield takeEvery(actions.updateUser, updateUserMock);
1115
+ yield takeEvery(actions.deleteUser, deleteUserMock);
1116
+ yield takeEvery(actions.deleteUserFromSubTenants, deleteUserFromSubTenantsMock);
1117
+ yield takeEvery(actions.resendActivationLink, resendActivationLinkMock);
1118
+ yield takeEvery(actions.resendInvitationLink, resendInvitationLinkMock);
1119
+ yield takeEvery(actions.openAddUserDialog, openAddUserDialog);
1120
+ yield takeEvery(actions.closeAddUserDialog, closeAddUserDialog);
1121
+ yield takeEvery(actions.openDeleteUserDialog, openDeleteUserDialog);
1122
+ yield takeEvery(actions.closeDeleteUserDialog, closeDeleteUserDialog);
1123
+ }