@northern.tech/store 0.46.4 → 0.47.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 (226) hide show
  1. package/dist/actions.d.cts +6 -6
  2. package/dist/actions.d.ts +6 -6
  3. package/dist/api/general-api.cjs +2 -2
  4. package/dist/api/general-api.cjs.map +1 -1
  5. package/dist/api/general-api.js +1 -1
  6. package/dist/api/general-api.js.map +1 -1
  7. package/dist/appSlice/constants.cjs +3 -4
  8. package/dist/appSlice/constants.cjs.map +1 -1
  9. package/dist/appSlice/constants.d.cts +1 -1
  10. package/dist/appSlice/constants.d.ts +1 -1
  11. package/dist/appSlice/constants.js +1 -2
  12. package/dist/appSlice/constants.js.map +1 -1
  13. package/dist/appSlice/index.d.cts +1 -1
  14. package/dist/appSlice/index.d.ts +1 -1
  15. package/dist/appSlice/index.js +1 -1
  16. package/dist/appSlice/mocks.d.cts +1 -1
  17. package/dist/appSlice/mocks.d.ts +1 -1
  18. package/dist/appSlice/selectors.cjs.map +1 -1
  19. package/dist/appSlice/selectors.d.cts +2 -130
  20. package/dist/appSlice/selectors.d.ts +2 -130
  21. package/dist/appSlice/selectors.js.map +1 -1
  22. package/dist/appSlice/thunks.d.cts +2 -2
  23. package/dist/appSlice/thunks.d.ts +2 -2
  24. package/dist/auth.cjs +3 -3
  25. package/dist/auth.cjs.map +1 -1
  26. package/dist/auth.d.cts +1 -1
  27. package/dist/auth.d.ts +1 -1
  28. package/dist/auth.js +2 -1
  29. package/dist/auth.js.map +1 -1
  30. package/dist/commonConstants.cjs +4 -3
  31. package/dist/commonConstants.d.cts +2 -2
  32. package/dist/commonConstants.d.ts +2 -2
  33. package/dist/commonConstants.js +1 -1
  34. package/dist/commonSelectors.cjs +1 -1
  35. package/dist/commonSelectors.d.cts +76 -369
  36. package/dist/commonSelectors.d.ts +76 -369
  37. package/dist/commonSelectors.js +1 -1
  38. package/dist/constants-CCkKh9KM.d.ts +109 -0
  39. package/dist/constants-CUwYPOYK.d.cts +109 -0
  40. package/dist/{constants-D5hACLhF.js → constants-DjiC_FnZ.js} +3 -269
  41. package/dist/constants-DjiC_FnZ.js.map +1 -0
  42. package/dist/{constants-MVizYy89.cjs → constants-DsOnY5o5.cjs} +1 -279
  43. package/dist/constants-DsOnY5o5.cjs.map +1 -0
  44. package/dist/{constants-nKSWZ8oD.d.ts → constants-tC3RR_Oo.d.cts} +2 -3
  45. package/dist/{constants-nKSWZ8oD.d.cts → constants-tC3RR_Oo.d.ts} +2 -3
  46. package/dist/constants.cjs +5 -5
  47. package/dist/constants.d.cts +3 -3
  48. package/dist/constants.d.ts +3 -3
  49. package/dist/constants.js +1 -1
  50. package/dist/deploymentsSlice/constants.cjs +1 -1
  51. package/dist/deploymentsSlice/constants.js +1 -1
  52. package/dist/deploymentsSlice/index.cjs +1 -1
  53. package/dist/deploymentsSlice/index.js +1 -1
  54. package/dist/deploymentsSlice/selectors.cjs +1 -1
  55. package/dist/deploymentsSlice/selectors.cjs.map +1 -1
  56. package/dist/deploymentsSlice/selectors.d.cts +2 -97
  57. package/dist/deploymentsSlice/selectors.d.ts +2 -97
  58. package/dist/deploymentsSlice/selectors.js +1 -1
  59. package/dist/deploymentsSlice/selectors.js.map +1 -1
  60. package/dist/deploymentsSlice/thunks.d.cts +4 -4
  61. package/dist/deploymentsSlice/thunks.d.ts +4 -4
  62. package/dist/devicesSlice/constants.cjs +1 -1
  63. package/dist/devicesSlice/constants.d.cts +1 -1
  64. package/dist/devicesSlice/constants.d.ts +1 -1
  65. package/dist/devicesSlice/constants.js +1 -1
  66. package/dist/devicesSlice/index.d.cts +1 -1
  67. package/dist/devicesSlice/index.d.ts +1 -1
  68. package/dist/devicesSlice/index.js +1 -1
  69. package/dist/devicesSlice/mocks.js +1 -1
  70. package/dist/devicesSlice/selectors.cjs +2 -2
  71. package/dist/devicesSlice/selectors.cjs.map +1 -1
  72. package/dist/devicesSlice/selectors.d.cts +2 -887
  73. package/dist/devicesSlice/selectors.d.ts +2 -887
  74. package/dist/devicesSlice/selectors.js +2 -2
  75. package/dist/devicesSlice/selectors.js.map +1 -1
  76. package/dist/devicesSlice/thunks.d.cts +4 -4
  77. package/dist/devicesSlice/thunks.d.ts +4 -4
  78. package/dist/{index-KxRmyFLr.d.cts → index-7jVuB4tG.d.cts} +2 -2
  79. package/dist/{index-fGVC5s1C.d.cts → index-BWtIaimn.d.cts} +2 -2
  80. package/dist/{index-BfmRpbiJ.d.cts → index-BcrZxKLw.d.cts} +2 -2
  81. package/dist/{index--SKVGToc.d.ts → index-C1vNDCYR.d.ts} +2 -2
  82. package/dist/{index-CRqnH_go.d.ts → index-C2za83Qs.d.ts} +2 -2
  83. package/dist/{index-xxqlerg5.d.ts → index-CThE5Gfh.d.ts} +2 -2
  84. package/dist/{index-BKU1G9-x.d.cts → index-CaNZaXie.d.cts} +2 -2
  85. package/dist/{index-BVNS-Aut.d.ts → index-CvMpbsOo.d.ts} +2 -2
  86. package/dist/{index-HjOSTTGF.d.cts → index-CzQRHJ6f.d.cts} +2 -2
  87. package/dist/{index-CqhXqGLt.d.cts → index-DNYeo7wc.d.cts} +2 -2
  88. package/dist/{index-D9GJhX1I.d.ts → index-DOPRnlaC.d.ts} +2 -2
  89. package/dist/{index-BMsafOyJ.d.ts → index-o_m7WKiR.d.ts} +2 -2
  90. package/dist/locationutils.cjs +1 -1
  91. package/dist/locationutils.d.cts +2 -2
  92. package/dist/locationutils.d.ts +2 -2
  93. package/dist/locationutils.js +1 -1
  94. package/dist/mockState.cjs +24 -0
  95. package/dist/mockState.cjs.map +1 -0
  96. package/dist/mockState.d.cts +7 -0
  97. package/dist/mockState.d.ts +7 -0
  98. package/dist/mockState.js +23 -0
  99. package/dist/mockState.js.map +1 -0
  100. package/dist/monitorSlice/constants.d.cts +1 -1
  101. package/dist/monitorSlice/constants.d.ts +1 -1
  102. package/dist/monitorSlice/index.d.cts +1 -1
  103. package/dist/monitorSlice/index.d.ts +1 -1
  104. package/dist/monitorSlice/index.js +1 -1
  105. package/dist/monitorSlice/mocks.d.cts +1 -1
  106. package/dist/monitorSlice/mocks.d.ts +1 -1
  107. package/dist/monitorSlice/mocks.js +1 -1
  108. package/dist/monitorSlice/selectors.cjs.map +1 -1
  109. package/dist/monitorSlice/selectors.d.cts +2 -10
  110. package/dist/monitorSlice/selectors.d.ts +2 -10
  111. package/dist/monitorSlice/selectors.js.map +1 -1
  112. package/dist/monitorSlice/thunks.cjs +2 -3
  113. package/dist/monitorSlice/thunks.cjs.map +1 -1
  114. package/dist/monitorSlice/thunks.d.cts +4 -4
  115. package/dist/monitorSlice/thunks.d.ts +4 -4
  116. package/dist/monitorSlice/thunks.js +3 -2
  117. package/dist/monitorSlice/thunks.js.map +1 -1
  118. package/dist/onboardingSlice/selectors.cjs.map +1 -1
  119. package/dist/onboardingSlice/selectors.d.cts +2 -6
  120. package/dist/onboardingSlice/selectors.d.ts +2 -6
  121. package/dist/onboardingSlice/selectors.js.map +1 -1
  122. package/dist/onboardingSlice/thunks.d.cts +3 -3
  123. package/dist/onboardingSlice/thunks.d.ts +3 -3
  124. package/dist/organizationSlice/constants.cjs +1 -1
  125. package/dist/organizationSlice/constants.js +1 -1
  126. package/dist/organizationSlice/index.cjs +1 -1
  127. package/dist/organizationSlice/index.d.cts +1 -1
  128. package/dist/organizationSlice/index.d.ts +1 -1
  129. package/dist/organizationSlice/index.js +1 -1
  130. package/dist/organizationSlice/mocks.d.cts +3 -3
  131. package/dist/organizationSlice/mocks.d.ts +3 -3
  132. package/dist/organizationSlice/mocks.js +1 -1
  133. package/dist/organizationSlice/selectors.cjs +1 -1
  134. package/dist/organizationSlice/selectors.cjs.map +1 -1
  135. package/dist/organizationSlice/selectors.d.cts +2 -472
  136. package/dist/organizationSlice/selectors.d.ts +2 -472
  137. package/dist/organizationSlice/selectors.js +1 -1
  138. package/dist/organizationSlice/selectors.js.map +1 -1
  139. package/dist/organizationSlice/thunks.d.cts +25 -21
  140. package/dist/organizationSlice/thunks.d.ts +25 -21
  141. package/dist/organizationSlice/types.d.cts +1 -1
  142. package/dist/organizationSlice/types.d.ts +1 -1
  143. package/dist/releasesSlice/index.d.cts +1 -1
  144. package/dist/releasesSlice/index.d.ts +1 -1
  145. package/dist/releasesSlice/index.js +1 -1
  146. package/dist/releasesSlice/mocks.js +1 -1
  147. package/dist/releasesSlice/selectors.cjs.map +1 -1
  148. package/dist/releasesSlice/selectors.d.cts +2 -795
  149. package/dist/releasesSlice/selectors.d.ts +2 -795
  150. package/dist/releasesSlice/selectors.js.map +1 -1
  151. package/dist/releasesSlice/thunks.cjs +17 -17
  152. package/dist/releasesSlice/thunks.cjs.map +1 -1
  153. package/dist/releasesSlice/thunks.d.cts +5 -5
  154. package/dist/releasesSlice/thunks.d.ts +5 -5
  155. package/dist/releasesSlice/thunks.js +2 -1
  156. package/dist/releasesSlice/thunks.js.map +1 -1
  157. package/dist/selectors-1394DVvN.d.ts +712 -0
  158. package/dist/selectors-Ba9LUr_0.d.ts +593 -0
  159. package/dist/selectors-CAo0fzIZ.d.ts +99 -0
  160. package/dist/selectors-CH-yXu-7.d.cts +84 -0
  161. package/dist/selectors-CQYkG1VI.d.cts +9 -0
  162. package/dist/selectors-D9t4It2i.d.ts +84 -0
  163. package/dist/selectors-DDsFLtxz.d.cts +712 -0
  164. package/dist/selectors-DFSv4A_m.d.ts +378 -0
  165. package/dist/selectors-DQKg681M.d.ts +363 -0
  166. package/dist/selectors-DeqP_VLU.d.cts +593 -0
  167. package/dist/selectors-LhR8TyWU.d.cts +378 -0
  168. package/dist/selectors-XzNyGFJI.d.cts +99 -0
  169. package/dist/selectors-aLOjKkxN.d.cts +14 -0
  170. package/dist/selectors-elCimAHX.d.ts +9 -0
  171. package/dist/selectors-jusUdUdc.d.cts +363 -0
  172. package/dist/selectors-vk0GUGHf.d.ts +14 -0
  173. package/dist/selectors.d.cts +9 -9
  174. package/dist/selectors.d.ts +9 -9
  175. package/dist/sockethook.cjs +4 -4
  176. package/dist/sockethook.cjs.map +1 -1
  177. package/dist/sockethook.js +2 -1
  178. package/dist/sockethook.js.map +1 -1
  179. package/dist/{store-Dw8Uo_Df.d.cts → store-CCvk8X-k.d.cts} +14 -33
  180. package/dist/{store-DLp6ajT8.d.ts → store-v5V-bbB_.d.ts} +15 -34
  181. package/dist/store.cjs +2 -4
  182. package/dist/store.cjs.map +1 -1
  183. package/dist/store.d.cts +2 -2
  184. package/dist/store.d.ts +2 -2
  185. package/dist/store.js +2 -4
  186. package/dist/store.js.map +1 -1
  187. package/dist/thunks.cjs +30 -38
  188. package/dist/thunks.cjs.map +1 -1
  189. package/dist/thunks.js +10 -17
  190. package/dist/thunks.js.map +1 -1
  191. package/dist/{types-DY0J79yF.d.ts → types-B2gphGj8.d.ts} +3 -3
  192. package/dist/{types-B67YW1jV.d.cts → types-CLASWtVP.d.cts} +3 -3
  193. package/dist/usersSlice/constants.cjs +1 -1
  194. package/dist/usersSlice/constants.js +1 -1
  195. package/dist/usersSlice/index.cjs +1 -1
  196. package/dist/usersSlice/index.d.cts +1 -1
  197. package/dist/usersSlice/index.d.ts +1 -1
  198. package/dist/usersSlice/index.js +1 -1
  199. package/dist/usersSlice/mocks.d.cts +1 -1
  200. package/dist/usersSlice/mocks.d.ts +1 -1
  201. package/dist/usersSlice/mocks.js +1 -1
  202. package/dist/usersSlice/selectors.cjs +3 -3
  203. package/dist/usersSlice/selectors.cjs.map +1 -1
  204. package/dist/usersSlice/selectors.d.cts +2 -466
  205. package/dist/usersSlice/selectors.d.ts +2 -466
  206. package/dist/usersSlice/selectors.js +2 -2
  207. package/dist/usersSlice/selectors.js.map +1 -1
  208. package/dist/usersSlice/thunks.d.cts +88 -88
  209. package/dist/usersSlice/thunks.d.ts +88 -88
  210. package/dist/utils.cjs +5 -10
  211. package/dist/utils.cjs.map +1 -1
  212. package/dist/utils.d.cts +1 -1
  213. package/dist/utils.d.ts +1 -1
  214. package/dist/utils.js +4 -8
  215. package/dist/utils.js.map +1 -1
  216. package/package.json +1 -1
  217. package/dist/constants-BJuY-ODE.d.ts +0 -124
  218. package/dist/constants-C2O55iZu.d.cts +0 -124
  219. package/dist/constants-D5hACLhF.js.map +0 -1
  220. package/dist/constants-MVizYy89.cjs.map +0 -1
  221. package/dist/storehooks.cjs +0 -249
  222. package/dist/storehooks.cjs.map +0 -1
  223. package/dist/storehooks.d.cts +0 -49
  224. package/dist/storehooks.d.ts +0 -49
  225. package/dist/storehooks.js +0 -241
  226. package/dist/storehooks.js.map +0 -1
@@ -0,0 +1,363 @@
1
+ import { i as ReadState } from "./constants-D8-yUk19.cjs";
2
+ import { a as UserSettings, i as UserSession, n as GlobalSettings, o as UserSliceType, r as User } from "./index-DNYeo7wc.cjs";
3
+ //#region src/usersSlice/selectors.d.ts
4
+ type UsersState = {
5
+ users: UserSliceType;
6
+ };
7
+ declare const getRolesById: (state: UsersState) => Record<string, import("@northern.tech/utils/constants").Role>;
8
+ declare const getTooltipsById: (state: UsersState) => Record<string, {
9
+ readState: ReadState;
10
+ }>;
11
+ declare const getGlobalSettings: (state: UsersState) => GlobalSettings;
12
+ declare const getGlobalSettingsInitialized: (state: UsersState) => boolean;
13
+ declare const getUserSettingsInitialized: (state: UsersState) => boolean;
14
+ declare const getUsersById: (state: UsersState) => Record<string, User>;
15
+ declare const getUsersList: ((state: UsersState) => User[]) & {
16
+ clearCache: () => void;
17
+ resultsCount: () => number;
18
+ resetResultsCount: () => void;
19
+ } & {
20
+ resultFunc: (resultFuncArgs_0: Record<string, User>) => User[];
21
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, User>) => User[]) & {
22
+ clearCache: () => void;
23
+ resultsCount: () => number;
24
+ resetResultsCount: () => void;
25
+ };
26
+ lastResult: () => User[];
27
+ dependencies: [(state: UsersState) => Record<string, User>];
28
+ recomputations: () => number;
29
+ resetRecomputations: () => void;
30
+ dependencyRecomputations: () => number;
31
+ resetDependencyRecomputations: () => void;
32
+ } & {
33
+ memoize: typeof import("reselect").weakMapMemoize;
34
+ argsMemoize: typeof import("reselect").weakMapMemoize;
35
+ };
36
+ declare const getCurrentUser: ((state: UsersState) => User) & {
37
+ clearCache: () => void;
38
+ resultsCount: () => number;
39
+ resetResultsCount: () => void;
40
+ } & {
41
+ resultFunc: (resultFuncArgs_0: Record<string, User>, resultFuncArgs_1: string | null) => User;
42
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, User>, resultFuncArgs_1: string | null) => User) & {
43
+ clearCache: () => void;
44
+ resultsCount: () => number;
45
+ resetResultsCount: () => void;
46
+ };
47
+ lastResult: () => User;
48
+ dependencies: [(state: UsersState) => Record<string, User>, (state: UsersState) => string | null];
49
+ recomputations: () => number;
50
+ resetRecomputations: () => void;
51
+ dependencyRecomputations: () => number;
52
+ resetDependencyRecomputations: () => void;
53
+ } & {
54
+ memoize: typeof import("reselect").weakMapMemoize;
55
+ argsMemoize: typeof import("reselect").weakMapMemoize;
56
+ };
57
+ declare const getUserSettings: (state: UsersState) => UserSettings;
58
+ declare const getSelectedDeviceAttribute: ((state: UsersState) => {
59
+ attribute: string;
60
+ scope: string;
61
+ }[]) & {
62
+ clearCache: () => void;
63
+ resultsCount: () => number;
64
+ resetResultsCount: () => void;
65
+ } & {
66
+ resultFunc: (resultFuncArgs_0: UserSettings) => {
67
+ attribute: string;
68
+ scope: string;
69
+ }[];
70
+ memoizedResultFunc: ((resultFuncArgs_0: UserSettings) => {
71
+ attribute: string;
72
+ scope: string;
73
+ }[]) & {
74
+ clearCache: () => void;
75
+ resultsCount: () => number;
76
+ resetResultsCount: () => void;
77
+ };
78
+ lastResult: () => {
79
+ attribute: string;
80
+ scope: string;
81
+ }[];
82
+ dependencies: [(state: UsersState) => UserSettings];
83
+ recomputations: () => number;
84
+ resetRecomputations: () => void;
85
+ dependencyRecomputations: () => number;
86
+ resetDependencyRecomputations: () => void;
87
+ } & {
88
+ memoize: typeof import("reselect").weakMapMemoize;
89
+ argsMemoize: typeof import("reselect").weakMapMemoize;
90
+ };
91
+ declare const getIsDarkMode: ((state: UsersState) => boolean) & {
92
+ clearCache: () => void;
93
+ resultsCount: () => number;
94
+ resetResultsCount: () => void;
95
+ } & {
96
+ resultFunc: (resultFuncArgs_0: UserSettings) => boolean;
97
+ memoizedResultFunc: ((resultFuncArgs_0: UserSettings) => boolean) & {
98
+ clearCache: () => void;
99
+ resultsCount: () => number;
100
+ resetResultsCount: () => void;
101
+ };
102
+ lastResult: () => boolean;
103
+ dependencies: [(state: UsersState) => UserSettings];
104
+ recomputations: () => number;
105
+ resetRecomputations: () => void;
106
+ dependencyRecomputations: () => number;
107
+ resetDependencyRecomputations: () => void;
108
+ } & {
109
+ memoize: typeof import("reselect").weakMapMemoize;
110
+ argsMemoize: typeof import("reselect").weakMapMemoize;
111
+ };
112
+ declare const getReadAllHelptips: ((state: UsersState) => boolean) & {
113
+ clearCache: () => void;
114
+ resultsCount: () => number;
115
+ resetResultsCount: () => void;
116
+ } & {
117
+ resultFunc: (resultFuncArgs_0: Record<string, {
118
+ readState: ReadState;
119
+ }>) => boolean;
120
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, {
121
+ readState: ReadState;
122
+ }>) => boolean) & {
123
+ clearCache: () => void;
124
+ resultsCount: () => number;
125
+ resetResultsCount: () => void;
126
+ };
127
+ lastResult: () => boolean;
128
+ dependencies: [(state: UsersState) => Record<string, {
129
+ readState: ReadState;
130
+ }>];
131
+ recomputations: () => number;
132
+ resetRecomputations: () => void;
133
+ dependencyRecomputations: () => number;
134
+ resetDependencyRecomputations: () => void;
135
+ } & {
136
+ memoize: typeof import("reselect").weakMapMemoize;
137
+ argsMemoize: typeof import("reselect").weakMapMemoize;
138
+ };
139
+ declare const getTooltipsState: ((state: UsersState) => {}) & {
140
+ clearCache: () => void;
141
+ resultsCount: () => number;
142
+ resetResultsCount: () => void;
143
+ } & {
144
+ resultFunc: (resultFuncArgs_0: Record<string, {
145
+ readState: ReadState;
146
+ }>, resultFuncArgs_1: UserSettings) => {};
147
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, {
148
+ readState: ReadState;
149
+ }>, resultFuncArgs_1: UserSettings) => {}) & {
150
+ clearCache: () => void;
151
+ resultsCount: () => number;
152
+ resetResultsCount: () => void;
153
+ };
154
+ lastResult: () => {};
155
+ dependencies: [(state: UsersState) => Record<string, {
156
+ readState: ReadState;
157
+ }>, (state: UsersState) => UserSettings];
158
+ recomputations: () => number;
159
+ resetRecomputations: () => void;
160
+ dependencyRecomputations: () => number;
161
+ resetDependencyRecomputations: () => void;
162
+ } & {
163
+ memoize: typeof import("reselect").weakMapMemoize;
164
+ argsMemoize: typeof import("reselect").weakMapMemoize;
165
+ };
166
+ declare const getHas2FA: ((state: UsersState) => boolean) & {
167
+ clearCache: () => void;
168
+ resultsCount: () => number;
169
+ resetResultsCount: () => void;
170
+ } & {
171
+ resultFunc: (resultFuncArgs_0: User) => boolean;
172
+ memoizedResultFunc: ((resultFuncArgs_0: User) => boolean) & {
173
+ clearCache: () => void;
174
+ resultsCount: () => number;
175
+ resetResultsCount: () => void;
176
+ };
177
+ lastResult: () => boolean;
178
+ dependencies: [((state: UsersState) => User) & {
179
+ clearCache: () => void;
180
+ resultsCount: () => number;
181
+ resetResultsCount: () => void;
182
+ } & {
183
+ resultFunc: (resultFuncArgs_0: Record<string, User>, resultFuncArgs_1: string | null) => User;
184
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, User>, resultFuncArgs_1: string | null) => User) & {
185
+ clearCache: () => void;
186
+ resultsCount: () => number;
187
+ resetResultsCount: () => void;
188
+ };
189
+ lastResult: () => User;
190
+ dependencies: [(state: UsersState) => Record<string, User>, (state: UsersState) => string | null];
191
+ recomputations: () => number;
192
+ resetRecomputations: () => void;
193
+ dependencyRecomputations: () => number;
194
+ resetDependencyRecomputations: () => void;
195
+ } & {
196
+ memoize: typeof import("reselect").weakMapMemoize;
197
+ argsMemoize: typeof import("reselect").weakMapMemoize;
198
+ }];
199
+ recomputations: () => number;
200
+ resetRecomputations: () => void;
201
+ dependencyRecomputations: () => number;
202
+ resetDependencyRecomputations: () => void;
203
+ } & {
204
+ memoize: typeof import("reselect").weakMapMemoize;
205
+ argsMemoize: typeof import("reselect").weakMapMemoize;
206
+ };
207
+ declare const getIdAttribute: ((state: UsersState) => {
208
+ attribute: string;
209
+ scope: string;
210
+ }) & {
211
+ clearCache: () => void;
212
+ resultsCount: () => number;
213
+ resetResultsCount: () => void;
214
+ } & {
215
+ resultFunc: (resultFuncArgs_0: GlobalSettings) => {
216
+ attribute: string;
217
+ scope: string;
218
+ };
219
+ memoizedResultFunc: ((resultFuncArgs_0: GlobalSettings) => {
220
+ attribute: string;
221
+ scope: string;
222
+ }) & {
223
+ clearCache: () => void;
224
+ resultsCount: () => number;
225
+ resetResultsCount: () => void;
226
+ };
227
+ lastResult: () => {
228
+ attribute: string;
229
+ scope: string;
230
+ };
231
+ dependencies: [(state: UsersState) => GlobalSettings];
232
+ recomputations: () => number;
233
+ resetRecomputations: () => void;
234
+ dependencyRecomputations: () => number;
235
+ resetDependencyRecomputations: () => void;
236
+ } & {
237
+ memoize: typeof import("reselect").weakMapMemoize;
238
+ argsMemoize: typeof import("reselect").weakMapMemoize;
239
+ };
240
+ declare const getOfflineThresholdSettings: ((state: UsersState) => {
241
+ interval: any;
242
+ intervalUnit: any;
243
+ }) & {
244
+ clearCache: () => void;
245
+ resultsCount: () => number;
246
+ resetResultsCount: () => void;
247
+ } & {
248
+ resultFunc: (resultFuncArgs_0: GlobalSettings) => {
249
+ interval: any;
250
+ intervalUnit: any;
251
+ };
252
+ memoizedResultFunc: ((resultFuncArgs_0: GlobalSettings) => {
253
+ interval: any;
254
+ intervalUnit: any;
255
+ }) & {
256
+ clearCache: () => void;
257
+ resultsCount: () => number;
258
+ resetResultsCount: () => void;
259
+ };
260
+ lastResult: () => {
261
+ interval: any;
262
+ intervalUnit: any;
263
+ };
264
+ dependencies: [(state: UsersState) => GlobalSettings];
265
+ recomputations: () => number;
266
+ resetRecomputations: () => void;
267
+ dependencyRecomputations: () => number;
268
+ resetDependencyRecomputations: () => void;
269
+ } & {
270
+ memoize: typeof import("reselect").weakMapMemoize;
271
+ argsMemoize: typeof import("reselect").weakMapMemoize;
272
+ };
273
+ declare const getRolesList: ((state: UsersState) => {
274
+ name: string;
275
+ description?: string;
276
+ permissions?: Array<import("@northern.tech/types/types.gen").RolePermission>;
277
+ permission_sets_with_scope?: Array<import("@northern.tech/types/types.gen").PermissionSetWithScope>;
278
+ editable?: boolean;
279
+ isCustom?: boolean;
280
+ uiPermissions: Readonly<{
281
+ auditlog: string[];
282
+ deployments?: string[];
283
+ groups: Record<string, string[]>;
284
+ releases: Record<string, string[]>;
285
+ tenantManagement: string[];
286
+ userManagement: string[];
287
+ }>;
288
+ value: string;
289
+ }[]) & {
290
+ clearCache: () => void;
291
+ resultsCount: () => number;
292
+ resetResultsCount: () => void;
293
+ } & {
294
+ resultFunc: (resultFuncArgs_0: Record<string, import("@northern.tech/utils/constants").Role>) => {
295
+ name: string;
296
+ description?: string;
297
+ permissions?: Array<import("@northern.tech/types/types.gen").RolePermission>;
298
+ permission_sets_with_scope?: Array<import("@northern.tech/types/types.gen").PermissionSetWithScope>;
299
+ editable?: boolean;
300
+ isCustom?: boolean;
301
+ uiPermissions: Readonly<{
302
+ auditlog: string[];
303
+ deployments?: string[];
304
+ groups: Record<string, string[]>;
305
+ releases: Record<string, string[]>;
306
+ tenantManagement: string[];
307
+ userManagement: string[];
308
+ }>;
309
+ value: string;
310
+ }[];
311
+ memoizedResultFunc: ((resultFuncArgs_0: Record<string, import("@northern.tech/utils/constants").Role>) => {
312
+ name: string;
313
+ description?: string;
314
+ permissions?: Array<import("@northern.tech/types/types.gen").RolePermission>;
315
+ permission_sets_with_scope?: Array<import("@northern.tech/types/types.gen").PermissionSetWithScope>;
316
+ editable?: boolean;
317
+ isCustom?: boolean;
318
+ uiPermissions: Readonly<{
319
+ auditlog: string[];
320
+ deployments?: string[];
321
+ groups: Record<string, string[]>;
322
+ releases: Record<string, string[]>;
323
+ tenantManagement: string[];
324
+ userManagement: string[];
325
+ }>;
326
+ value: string;
327
+ }[]) & {
328
+ clearCache: () => void;
329
+ resultsCount: () => number;
330
+ resetResultsCount: () => void;
331
+ };
332
+ lastResult: () => {
333
+ name: string;
334
+ description?: string;
335
+ permissions?: Array<import("@northern.tech/types/types.gen").RolePermission>;
336
+ permission_sets_with_scope?: Array<import("@northern.tech/types/types.gen").PermissionSetWithScope>;
337
+ editable?: boolean;
338
+ isCustom?: boolean;
339
+ uiPermissions: Readonly<{
340
+ auditlog: string[];
341
+ deployments?: string[];
342
+ groups: Record<string, string[]>;
343
+ releases: Record<string, string[]>;
344
+ tenantManagement: string[];
345
+ userManagement: string[];
346
+ }>;
347
+ value: string;
348
+ }[];
349
+ dependencies: [(state: UsersState) => Record<string, import("@northern.tech/utils/constants").Role>];
350
+ recomputations: () => number;
351
+ resetRecomputations: () => void;
352
+ dependencyRecomputations: () => number;
353
+ resetDependencyRecomputations: () => void;
354
+ } & {
355
+ memoize: typeof import("reselect").weakMapMemoize;
356
+ argsMemoize: typeof import("reselect").weakMapMemoize;
357
+ };
358
+ declare const getCurrentSession: (state: UsersState) => object | UserSession | undefined;
359
+ declare const getRolesInitialized: (state: UsersState) => boolean;
360
+ declare const getSecurityAlertDismissedTimestamp: (state: UsersState) => string | null;
361
+ //#endregion
362
+ export { getTooltipsState as _, getGlobalSettingsInitialized as a, getUsersById as b, getIsDarkMode as c, getRolesById as d, getRolesInitialized as f, getTooltipsById as g, getSelectedDeviceAttribute as h, getGlobalSettings as i, getOfflineThresholdSettings as l, getSecurityAlertDismissedTimestamp as m, getCurrentSession as n, getHas2FA as o, getRolesList as p, getCurrentUser as r, getIdAttribute as s, UsersState as t, getReadAllHelptips as u, getUserSettings as v, getUsersList as x, getUserSettingsInitialized as y };
363
+ //# sourceMappingURL=selectors-jusUdUdc.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { t as MonitorSliceType } from "./index-C2za83Qs.js";
2
+ //#region src/monitorSlice/selectors.d.ts
3
+ type MonitorState = {
4
+ monitor: MonitorSliceType;
5
+ };
6
+ declare const getIssueCountsByType: (state: MonitorState) => {
7
+ [x: string]: {
8
+ filtered: number;
9
+ total: number;
10
+ };
11
+ };
12
+ //#endregion
13
+ export { getIssueCountsByType as n, MonitorState as t };
14
+ //# sourceMappingURL=selectors-vk0GUGHf.d.ts.map
@@ -1,10 +1,10 @@
1
- import { getAppInitDone, getCommit, getDocsVersion, getFeatures, getFeedbackProbability, getHostAddress, getHostedAnnouncement, getIsFirstLogin, getIsPreview, getIsUploading, getRecaptchaKey, getSearchState, getSearchedDevices, getSentryConfig, getSnackbar, getStripeKey, getTrackerCode, getUploads, getVersionInformation } from "./appSlice/selectors.cjs";
1
+ import { _ as getStripeKey, a as getFeatures, b as getVersionInformation, c as getHostedAnnouncement, d as getIsUploading, f as getRecaptchaKey, g as getSnackbar, h as getSentryConfig, i as getDocsVersion, l as getIsFirstLogin, m as getSearchedDevices, n as getAppInitDone, o as getFeedbackProbability, p as getSearchState, r as getCommit, s as getHostAddress, t as AppState, u as getIsPreview, v as getTrackerCode, y as getUploads } from "./selectors-XzNyGFJI.cjs";
2
+ import { a as getDeploymentsByStatus, c as getRecentDeployments, i as getDeploymentsById, l as getSelectedDeploymentDeviceIds, n as DeploymentsState, o as getDeploymentsSelectionState, r as getDeploymentById, s as getMappedDeploymentSelection, t as DEPLOYMENT_CUTOFF } from "./selectors-CH-yXu-7.cjs";
3
+ import { C as getListedDevices, D as getTestDeviceCount, E as getSortedFilteringAttributes, O as getTestDeviceLimit, S as getLimitMaxed, T as getSelectedGroupInfo, _ as getFilteringAttributes, a as getDeviceById, b as getGroupsById, c as getDeviceIdentityAttributes, d as getDeviceListState, f as getDeviceReports, g as getEnabledTiers, h as getDevicesByStatus, i as getCombinedLimit, l as getDeviceLimitStats, m as getDevicesById, n as getAcceptedDevices, o as getDeviceCountsByStatus, p as getDeviceTypes, r as getAttributesList, s as getDeviceFilters, t as DevicesState, u as getDeviceLimits, v as getGroupData, w as getSelectedGroup, x as getGroupsByIdWithoutUngrouped, y as getGroups } from "./selectors-DDsFLtxz.cjs";
4
+ import { n as getIssueCountsByType, t as MonitorState } from "./selectors-aLOjKkxN.cjs";
5
+ import { n as getOnboarding, t as OnboardingState } from "./selectors-CQYkG1VI.cjs";
6
+ import { S as getWebhooks, _ as getTenantListWithLimits, a as getAuditlogState, b as getWebhookEvents, c as getDeviceTwinIntegrations, d as getIsServiceProvider, f as getOrganization, g as getSubscription, h as getSsoConfig, i as getAuditLogSelectionState, l as getDisabledTiers, m as getSpLimits, n as getAuditLog, o as getBillingProfile, p as getProducts, r as getAuditLogEntry, s as getCard, t as OrganizationState, u as getExternalIntegrations, v as getTenantsList, x as getWebhookEventsTotal, y as getWebhookEventInfo } from "./selectors-LhR8TyWU.cjs";
7
+ import { C as getSelectedReleases, D as getSoftwareTags, E as getSoftwareListState, O as getSoftwareTagsById, S as getSelectedRelease, T as getSoftwareList, _ as getReleasesById, a as getDeltaJobsListState, b as getSelectedManifest, c as getHasSoftware, d as getManifestsById, f as getManifestsList, g as getReleaseTagsById, h as getReleaseTags, i as getDeltaJobsById, k as getUpdateTypes, l as getManifestTags, m as getReleaseListState, n as getActiveTab, o as getHasManifests, p as getManifestsListState, r as getDeltaJobById, s as getHasReleases, t as ReleasesState, u as getManifestTagsById, v as getReleasesList, w as getSoftwareById, x as getSelectedManifests, y as getSelectedJob } from "./selectors-DeqP_VLU.cjs";
8
+ import { _ as getTooltipsState, a as getGlobalSettingsInitialized, b as getUsersById, c as getIsDarkMode, d as getRolesById, f as getRolesInitialized, g as getTooltipsById, h as getSelectedDeviceAttribute, i as getGlobalSettings, l as getOfflineThresholdSettings, m as getSecurityAlertDismissedTimestamp, n as getCurrentSession, o as getHas2FA, p as getRolesList, r as getCurrentUser, s as getIdAttribute, t as UsersState, u as getReadAllHelptips, v as getUserSettings, x as getUsersList, y as getUserSettingsInitialized } from "./selectors-jusUdUdc.cjs";
2
9
  import { getAuditlogDevice, getAvailableIssueOptionsByType, getDemoDeviceAddress, getDeploymentRelease, getDeviceConfigDeployment, getDeviceReportsForUser, getFilterAttributes, getGroupNames, getIsEnterprise, getMappedDevicesList, getOnboardingState, getRelevantRoles, getSelectedDeploymentData, getShowSecurityAlert, getTenantCapabilities, getUserCapabilities, getUserRoles } from "./commonSelectors.cjs";
3
- import { DEPLOYMENT_CUTOFF, getDeploymentById, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getMappedDeploymentSelection, getRecentDeployments, getSelectedDeploymentDeviceIds } from "./deploymentsSlice/selectors.cjs";
4
- import { getAcceptedDevices, getAttributesList, getCombinedLimit, getDeviceById, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceTypes, getDevicesById, getDevicesByStatus, getEnabledTiers, getFilteringAttributes, getGroupData, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getLimitMaxed, getListedDevices, getSelectedGroup, getSelectedGroupInfo, getSortedFilteringAttributes, getTestDeviceCount, getTestDeviceLimit } from "./devicesSlice/selectors.cjs";
5
- import { getIssueCountsByType } from "./monitorSlice/selectors.cjs";
6
- import { getOnboarding } from "./onboardingSlice/selectors.cjs";
7
- import { getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogState, getBillingProfile, getCard, getDeviceTwinIntegrations, getDisabledTiers, getExternalIntegrations, getIsServiceProvider, getOrganization, getProducts, getSpLimits, getSsoConfig, getSubscription, getTenantListWithLimits, getTenantsList, getWebhookEventInfo, getWebhookEvents, getWebhookEventsTotal, getWebhooks } from "./organizationSlice/selectors.cjs";
8
- import { getActiveTab, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasManifests, getHasReleases, getHasSoftware, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSoftwareById, getSoftwareList, getSoftwareListState, getSoftwareTags, getSoftwareTagsById, getUpdateTypes } from "./releasesSlice/selectors.cjs";
9
- import { getCurrentSession, getCurrentUser, getGlobalSettings, getGlobalSettingsInitialized, getHas2FA, getIdAttribute, getIsDarkMode, getOfflineThresholdSettings, getReadAllHelptips, getRolesById, getRolesInitialized, getRolesList, getSecurityAlertDismissedTimestamp, getSelectedDeviceAttribute, getTooltipsById, getTooltipsState, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList } from "./usersSlice/selectors.cjs";
10
- export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHasSoftware, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareById, getSoftwareList, getSoftwareListState, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTestDeviceCount, getTestDeviceLimit, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEvents, getWebhookEventsTotal, getWebhooks };
10
+ export { AppState, DEPLOYMENT_CUTOFF, DeploymentsState, DevicesState, MonitorState, OnboardingState, OrganizationState, ReleasesState, UsersState, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHasSoftware, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareById, getSoftwareList, getSoftwareListState, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTestDeviceCount, getTestDeviceLimit, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEvents, getWebhookEventsTotal, getWebhooks };
@@ -1,10 +1,10 @@
1
- import { getAppInitDone, getCommit, getDocsVersion, getFeatures, getFeedbackProbability, getHostAddress, getHostedAnnouncement, getIsFirstLogin, getIsPreview, getIsUploading, getRecaptchaKey, getSearchState, getSearchedDevices, getSentryConfig, getSnackbar, getStripeKey, getTrackerCode, getUploads, getVersionInformation } from "./appSlice/selectors.js";
1
+ import { _ as getStripeKey, a as getFeatures, b as getVersionInformation, c as getHostedAnnouncement, d as getIsUploading, f as getRecaptchaKey, g as getSnackbar, h as getSentryConfig, i as getDocsVersion, l as getIsFirstLogin, m as getSearchedDevices, n as getAppInitDone, o as getFeedbackProbability, p as getSearchState, r as getCommit, s as getHostAddress, t as AppState, u as getIsPreview, v as getTrackerCode, y as getUploads } from "./selectors-CAo0fzIZ.js";
2
+ import { a as getDeploymentsByStatus, c as getRecentDeployments, i as getDeploymentsById, l as getSelectedDeploymentDeviceIds, n as DeploymentsState, o as getDeploymentsSelectionState, r as getDeploymentById, s as getMappedDeploymentSelection, t as DEPLOYMENT_CUTOFF } from "./selectors-D9t4It2i.js";
3
+ import { C as getListedDevices, D as getTestDeviceCount, E as getSortedFilteringAttributes, O as getTestDeviceLimit, S as getLimitMaxed, T as getSelectedGroupInfo, _ as getFilteringAttributes, a as getDeviceById, b as getGroupsById, c as getDeviceIdentityAttributes, d as getDeviceListState, f as getDeviceReports, g as getEnabledTiers, h as getDevicesByStatus, i as getCombinedLimit, l as getDeviceLimitStats, m as getDevicesById, n as getAcceptedDevices, o as getDeviceCountsByStatus, p as getDeviceTypes, r as getAttributesList, s as getDeviceFilters, t as DevicesState, u as getDeviceLimits, v as getGroupData, w as getSelectedGroup, x as getGroupsByIdWithoutUngrouped, y as getGroups } from "./selectors-1394DVvN.js";
4
+ import { n as getIssueCountsByType, t as MonitorState } from "./selectors-vk0GUGHf.js";
5
+ import { n as getOnboarding, t as OnboardingState } from "./selectors-elCimAHX.js";
6
+ import { S as getWebhooks, _ as getTenantListWithLimits, a as getAuditlogState, b as getWebhookEvents, c as getDeviceTwinIntegrations, d as getIsServiceProvider, f as getOrganization, g as getSubscription, h as getSsoConfig, i as getAuditLogSelectionState, l as getDisabledTiers, m as getSpLimits, n as getAuditLog, o as getBillingProfile, p as getProducts, r as getAuditLogEntry, s as getCard, t as OrganizationState, u as getExternalIntegrations, v as getTenantsList, x as getWebhookEventsTotal, y as getWebhookEventInfo } from "./selectors-DFSv4A_m.js";
7
+ import { C as getSelectedReleases, D as getSoftwareTags, E as getSoftwareListState, O as getSoftwareTagsById, S as getSelectedRelease, T as getSoftwareList, _ as getReleasesById, a as getDeltaJobsListState, b as getSelectedManifest, c as getHasSoftware, d as getManifestsById, f as getManifestsList, g as getReleaseTagsById, h as getReleaseTags, i as getDeltaJobsById, k as getUpdateTypes, l as getManifestTags, m as getReleaseListState, n as getActiveTab, o as getHasManifests, p as getManifestsListState, r as getDeltaJobById, s as getHasReleases, t as ReleasesState, u as getManifestTagsById, v as getReleasesList, w as getSoftwareById, x as getSelectedManifests, y as getSelectedJob } from "./selectors-Ba9LUr_0.js";
8
+ import { _ as getTooltipsState, a as getGlobalSettingsInitialized, b as getUsersById, c as getIsDarkMode, d as getRolesById, f as getRolesInitialized, g as getTooltipsById, h as getSelectedDeviceAttribute, i as getGlobalSettings, l as getOfflineThresholdSettings, m as getSecurityAlertDismissedTimestamp, n as getCurrentSession, o as getHas2FA, p as getRolesList, r as getCurrentUser, s as getIdAttribute, t as UsersState, u as getReadAllHelptips, v as getUserSettings, x as getUsersList, y as getUserSettingsInitialized } from "./selectors-DQKg681M.js";
2
9
  import { getAuditlogDevice, getAvailableIssueOptionsByType, getDemoDeviceAddress, getDeploymentRelease, getDeviceConfigDeployment, getDeviceReportsForUser, getFilterAttributes, getGroupNames, getIsEnterprise, getMappedDevicesList, getOnboardingState, getRelevantRoles, getSelectedDeploymentData, getShowSecurityAlert, getTenantCapabilities, getUserCapabilities, getUserRoles } from "./commonSelectors.js";
3
- import { DEPLOYMENT_CUTOFF, getDeploymentById, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getMappedDeploymentSelection, getRecentDeployments, getSelectedDeploymentDeviceIds } from "./deploymentsSlice/selectors.js";
4
- import { getAcceptedDevices, getAttributesList, getCombinedLimit, getDeviceById, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceTypes, getDevicesById, getDevicesByStatus, getEnabledTiers, getFilteringAttributes, getGroupData, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getLimitMaxed, getListedDevices, getSelectedGroup, getSelectedGroupInfo, getSortedFilteringAttributes, getTestDeviceCount, getTestDeviceLimit } from "./devicesSlice/selectors.js";
5
- import { getIssueCountsByType } from "./monitorSlice/selectors.js";
6
- import { getOnboarding } from "./onboardingSlice/selectors.js";
7
- import { getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogState, getBillingProfile, getCard, getDeviceTwinIntegrations, getDisabledTiers, getExternalIntegrations, getIsServiceProvider, getOrganization, getProducts, getSpLimits, getSsoConfig, getSubscription, getTenantListWithLimits, getTenantsList, getWebhookEventInfo, getWebhookEvents, getWebhookEventsTotal, getWebhooks } from "./organizationSlice/selectors.js";
8
- import { getActiveTab, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasManifests, getHasReleases, getHasSoftware, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSoftwareById, getSoftwareList, getSoftwareListState, getSoftwareTags, getSoftwareTagsById, getUpdateTypes } from "./releasesSlice/selectors.js";
9
- import { getCurrentSession, getCurrentUser, getGlobalSettings, getGlobalSettingsInitialized, getHas2FA, getIdAttribute, getIsDarkMode, getOfflineThresholdSettings, getReadAllHelptips, getRolesById, getRolesInitialized, getRolesList, getSecurityAlertDismissedTimestamp, getSelectedDeviceAttribute, getTooltipsById, getTooltipsState, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList } from "./usersSlice/selectors.js";
10
- export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHasSoftware, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareById, getSoftwareList, getSoftwareListState, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTestDeviceCount, getTestDeviceLimit, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEvents, getWebhookEventsTotal, getWebhooks };
10
+ export { AppState, DEPLOYMENT_CUTOFF, DeploymentsState, DevicesState, MonitorState, OnboardingState, OrganizationState, ReleasesState, UsersState, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHasSoftware, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareById, getSoftwareList, getSoftwareListState, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTestDeviceCount, getTestDeviceLimit, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEvents, getWebhookEventsTotal, getWebhooks };
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
- const require_constants = require("./constants-MVizYy89.cjs");
3
+ const require_constants = require("./constants-DsOnY5o5.cjs");
4
+ let _northern_tech_utils_constants = require("@northern.tech/utils/constants");
4
5
  let _northern_tech_utils_helpers = require("@northern.tech/utils/helpers");
5
6
  let universal_cookie = require("universal-cookie");
6
7
  universal_cookie = require_rolldown_runtime.__toESM(universal_cookie, 1);
7
8
  let react = require("react");
8
9
  let msgpackr = require("msgpackr");
9
- let _northern_tech_utils_constants = require("@northern.tech/utils/constants");
10
10
  //#region src/sockethook.ts
11
11
  const cookies = new universal_cookie.default();
12
12
  const MessagePack = new msgpackr.Packr({
@@ -54,7 +54,7 @@ const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify,
54
54
  return close();
55
55
  } else {
56
56
  clearTimeout(healthcheckTimeout.current);
57
- healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * require_constants.TIMEOUTS.oneSecond);
57
+ healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * _northern_tech_utils_constants.TIMEOUTS.oneSecond);
58
58
  if (socketRef.current) socketRef.current.sessionId = sid;
59
59
  return setSessionId(sid);
60
60
  }
@@ -67,7 +67,7 @@ const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify,
67
67
  props: {}
68
68
  });
69
69
  const timeout = parseInt(props.timeout);
70
- if (timeout > 0) healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * require_constants.TIMEOUTS.oneSecond);
70
+ if (timeout > 0) healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * _northern_tech_utils_constants.TIMEOUTS.oneSecond);
71
71
  return;
72
72
  }
73
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sockethook.cjs","names":["Cookies","Packr","useState","useRef","useCallback","MessageProtocols","MessageTypes","blobToString","byteArrayToString","TIMEOUTS","apiUrl"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport { Packr } from 'msgpackr';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, TIMEOUTS, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\n// plain maps + omitted undefined fields keep the wire format compatible with the deviceconnect backend\nconst MessagePack = new Packr({ skipValues: [undefined], useRecords: false });\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.pack({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.unpack(new Uint8Array(data as ArrayBuffer)) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,UAAU,IAAIA,iBAAAA,QAAQ;AAG5B,MAAM,cAAc,IAAIC,SAAAA,MAAM;CAAE,YAAY,CAAC,KAAA,CAAS;CAAG,YAAY;AAAM,CAAC;AA2B5E,MAAa,cAAc,EAAE,SAAS,qBAAqB,mBAAmB,UAAU,QAAQ,YAA+C;CAC7I,MAAM,CAAC,WAAW,iBAAA,GAAgBC,MAAAA,SAAAA,CAA6B;CAC/D,MAAM,sBAAA,GAAqBC,MAAAA,OAAAA,CAAkD,KAAA,CAAS;CACtF,MAAM,aAAA,GAAYA,MAAAA,OAAAA,CAAqC,KAAA,CAAS;CAChE,MAAM,eAAA,GAAcC,MAAAA,YAAAA,EAAa,EAAE,KAAK,MAAM,YAAgC;EAC5E,IAAI,CAAC,UAAU,SACb;EAEF,MAAM,eAAe;GAAE,OAAOC,kBAAAA,yBAAiB;GAAO;GAAK,KAAK,UAAU,QAAQ;GAAW;EAAM;EACnG,MAAM,cAAc,YAAY,KAAK;GAAE,KAAK;GAAc;EAAK,CAAC;EAChE,UAAU,QAAQ,KAAK,WAAW;CACpC,GAAG,CAAC,CAAC;CAEL,MAAM,SAAA,GAAQD,MAAAA,YAAAA,OAAwB;EACpC,IAAI,CAAC,UAAU,WAAW,UAAU,SAAS,eAAe,UAAU,MACpE;EAEF,YAAY;GAAE,KAAKE,kBAAAA,qBAAa;GAAM,OAA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,cAAc,oBAAoB,WAAW,eAAe;GAC5D,cAAc,oBAAoB,QAAQ,YAAY;EACxD;CAEF,GAAG;EAAC;EAAe;EAAe;EAAiB;EAAc,UAAU,SAAS;CAAU,CAAC;CAG/F,OAAO;EAAC;EAAS;EAAa;EAAO,UAAU,SAAS,cAAc,UAAU;EAAQ;CAAS;AACnG"}
1
+ {"version":3,"file":"sockethook.cjs","names":["Cookies","Packr","useState","useRef","useCallback","MessageProtocols","MessageTypes","blobToString","byteArrayToString","TIMEOUTS","apiUrl"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { TIMEOUTS } from '@northern.tech/utils/constants';\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport { Packr } from 'msgpackr';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\n// plain maps + omitted undefined fields keep the wire format compatible with the deviceconnect backend\nconst MessagePack = new Packr({ skipValues: [undefined], useRecords: false });\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.pack({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.unpack(new Uint8Array(data as ArrayBuffer)) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [conn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VICE_MESSAGE_PROTOCOLS } from "./constants-D5hACLhF.js";
1
+ import { dt as DEVICE_MESSAGE_TYPES, h as apiUrl, ut as DEVICE_MESSAGE_PROTOCOLS } from "./constants-DjiC_FnZ.js";
2
+ import { TIMEOUTS } from "@northern.tech/utils/constants";
2
3
  import { blobToString, byteArrayToString } from "@northern.tech/utils/helpers";
3
4
  import Cookies from "universal-cookie";
4
5
  import { useCallback, useEffect, useRef, useState } from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"sockethook.js","names":["MessageProtocols","MessageTypes"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport { Packr } from 'msgpackr';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, TIMEOUTS, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\n// plain maps + omitted undefined fields keep the wire format compatible with the deviceconnect backend\nconst MessagePack = new Packr({ skipValues: [undefined], useRecords: false });\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.pack({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.unpack(new Uint8Array(data as ArrayBuffer)) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close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ACtB,QAAQ,IAAI,OAAO,OAAO;GAAE,MAAM;GAAK,QAAQ;GAAM,UAAU;GAAU,QAAQ;EAAE,CAAC;EACpF,IAAI;GACF,UAAU,UAAU,IAAI,UAAU,GAAG;EACvC,SAAS,OAAO;GACd,QAAQ,IAAI,KAAK;EACnB;CACF,GACA,CAAC,KAAK,CACR;CAEA,gBAAgB;EACd,MAAM,gBAAgB,UAAU;EAChC,IAAI,CAAC,eACH;EAGF,cAAc,iBAAiB,SAAS,aAAa;EACrD,cAAc,iBAAiB,SAAS,aAAa;EACrD,cAAc,iBAAiB,WAAW,eAAe;EACzD,cAAc,iBAAiB,QAAQ,YAAY;EAEnD,aAAa;GACX,cAAc,oBAAoB,SAAS,aAAa;GACxD,cAAc,oBAAoB,SAAS,aAAa;GACxD,cAAc,oBAAoB,WAAW,eAAe;GAC5D,cAAc,oBAAoB,QAAQ,YAAY;EACxD;CAEF,GAAG;EAAC;EAAe;EAAe;EAAiB;EAAc,UAAU,SAAS;CAAU,CAAC;CAG/F,OAAO;EAAC;EAAS;EAAa;EAAO,UAAU,SAAS,cAAc,UAAU;EAAQ;CAAS;AACnG"}
1
+ {"version":3,"file":"sockethook.js","names":["MessageProtocols","MessageTypes"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { TIMEOUTS } from '@northern.tech/utils/constants';\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport { Packr } from 'msgpackr';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\n// plain maps + omitted undefined fields keep the wire format compatible with the deviceconnect backend\nconst MessagePack = new Packr({ skipValues: [undefined], useRecords: false });\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.pack({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.unpack(new Uint8Array(data as ArrayBuffer)) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;;AAsBA,MAAM,UAAU,IAAI,QAAQ;AAG5B,MAAM,cAAc,IAAI,MAAM;CAAE,YAAY,CAAC,KAAA,CAAS;CAAG,YAAY;AAAM,CAAC;AA2B5E,MAAa,cAAc,EAAE,SAAS,qBAAqB,mBAAmB,UAAU,QAAQ,YAA+C;CAC7I,MAAM,CAAC,WAAW,gBAAgB,SAA6B;CAC/D,MAAM,qBAAqB,OAAkD,KAAA,CAAS;CACtF,MAAM,YAAY,OAAqC,KAAA,CAAS;CAChE,MAAM,cAAc,aAAa,EAAE,KAAK,MAAM,YAAgC;EAC5E,IAAI,CAAC,UAAU,SACb;EAEF,MAAM,eAAe;GAAE,OAAOA,yBAAiB;GAAO;GAAK,KAAK,UAAU,QAAQ;GAAW;EAAM;EACnG,MAAM,cAAc,YAAY,KAAK;GAAE,KAAK;GAAc;EAAK,CAAC;EAChE,UAAU,QAAQ,KAAK,WAAW;CACpC,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,kBAAwB;EACpC,IAAI,CAAC,UAAU,WAAW,UAAU,SAAS,eAAe,UAAU,MACpE;EAEF,YAAY;GAAE,KAAKC,qBAAa;GAAM,OAAO,CAAC;EAAE,CA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