@northern.tech/store 0.46.5 → 0.48.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.
- package/dist/actions.d.cts +6 -6
- package/dist/actions.d.ts +6 -6
- package/dist/api/general-api.cjs +2 -2
- package/dist/api/general-api.cjs.map +1 -1
- package/dist/api/general-api.js +1 -1
- package/dist/api/general-api.js.map +1 -1
- package/dist/appSlice/constants.cjs +3 -4
- package/dist/appSlice/constants.cjs.map +1 -1
- package/dist/appSlice/constants.d.cts +1 -1
- package/dist/appSlice/constants.d.ts +1 -1
- package/dist/appSlice/constants.js +1 -2
- package/dist/appSlice/constants.js.map +1 -1
- package/dist/appSlice/index.d.cts +1 -1
- package/dist/appSlice/index.d.ts +1 -1
- package/dist/appSlice/index.js +1 -1
- package/dist/appSlice/mocks.d.cts +1 -1
- package/dist/appSlice/mocks.d.ts +1 -1
- package/dist/appSlice/selectors.cjs.map +1 -1
- package/dist/appSlice/selectors.d.cts +2 -130
- package/dist/appSlice/selectors.d.ts +2 -130
- package/dist/appSlice/selectors.js.map +1 -1
- package/dist/appSlice/thunks.d.cts +2 -2
- package/dist/appSlice/thunks.d.ts +2 -2
- package/dist/auth.cjs +3 -3
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +2 -1
- package/dist/auth.js.map +1 -1
- package/dist/commonConstants.cjs +4 -3
- package/dist/commonConstants.d.cts +2 -2
- package/dist/commonConstants.d.ts +2 -2
- package/dist/commonConstants.js +1 -1
- package/dist/commonSelectors.cjs +1 -1
- package/dist/commonSelectors.d.cts +80 -373
- package/dist/commonSelectors.d.ts +80 -373
- package/dist/commonSelectors.js +1 -1
- package/dist/constants-3gsHyxWr.d.ts +109 -0
- package/dist/{constants-B3NH1IQi.d.ts → constants-DOnQ-UzD.d.cts} +2 -3
- package/dist/{constants-B3NH1IQi.d.cts → constants-DOnQ-UzD.d.ts} +2 -3
- package/dist/{constants-MVizYy89.cjs → constants-DsOnY5o5.cjs} +1 -279
- package/dist/constants-DsOnY5o5.cjs.map +1 -0
- package/dist/constants-hMMMdt0R.d.cts +109 -0
- package/dist/{constants-nKSWZ8oD.d.ts → constants-tC3RR_Oo.d.cts} +2 -3
- package/dist/{constants-nKSWZ8oD.d.cts → constants-tC3RR_Oo.d.ts} +2 -3
- package/dist/{constants-D5hACLhF.js → constants-yul-O5hD.js} +3 -269
- package/dist/constants-yul-O5hD.js.map +1 -0
- package/dist/constants.cjs +6 -6
- package/dist/constants.d.cts +4 -4
- package/dist/constants.d.ts +4 -4
- package/dist/constants.js +2 -2
- package/dist/deploymentsSlice/constants.cjs +1 -1
- package/dist/deploymentsSlice/constants.js +1 -1
- package/dist/deploymentsSlice/index.cjs +1 -1
- package/dist/deploymentsSlice/index.js +1 -1
- package/dist/deploymentsSlice/selectors.cjs +1 -1
- package/dist/deploymentsSlice/selectors.cjs.map +1 -1
- package/dist/deploymentsSlice/selectors.d.cts +2 -97
- package/dist/deploymentsSlice/selectors.d.ts +2 -97
- package/dist/deploymentsSlice/selectors.js +1 -1
- package/dist/deploymentsSlice/selectors.js.map +1 -1
- package/dist/deploymentsSlice/thunks.d.cts +13 -13
- package/dist/deploymentsSlice/thunks.d.ts +13 -13
- package/dist/devicesSlice/constants.cjs +1 -1
- package/dist/devicesSlice/constants.d.cts +1 -1
- package/dist/devicesSlice/constants.d.ts +1 -1
- package/dist/devicesSlice/constants.js +1 -1
- package/dist/devicesSlice/index.d.cts +1 -1
- package/dist/devicesSlice/index.d.ts +1 -1
- package/dist/devicesSlice/index.js +1 -1
- package/dist/devicesSlice/mocks.js +1 -1
- package/dist/devicesSlice/selectors.cjs +1 -1
- package/dist/devicesSlice/selectors.cjs.map +1 -1
- package/dist/devicesSlice/selectors.d.cts +2 -887
- package/dist/devicesSlice/selectors.d.ts +2 -887
- package/dist/devicesSlice/selectors.js +1 -1
- package/dist/devicesSlice/selectors.js.map +1 -1
- package/dist/devicesSlice/thunks.d.cts +4 -4
- package/dist/devicesSlice/thunks.d.ts +4 -4
- package/dist/{index-fGVC5s1C.d.cts → index-B9jUHGsM.d.cts} +2 -2
- package/dist/{index-xxqlerg5.d.ts → index-BMi8ZqpV.d.ts} +2 -2
- package/dist/{index-BKU1G9-x.d.cts → index-BoZjwQHk.d.cts} +2 -2
- package/dist/{index-BfmRpbiJ.d.cts → index-C-6WkMAo.d.cts} +2 -2
- package/dist/{index-CRqnH_go.d.ts → index-CD39K38q.d.ts} +2 -2
- package/dist/{index-KxRmyFLr.d.cts → index-D8O1HJ8Q.d.cts} +2 -2
- package/dist/{index-BMsafOyJ.d.ts → index-DXfbW2gi.d.ts} +2 -2
- package/dist/{index-HjOSTTGF.d.cts → index-Dd_guNwA.d.cts} +2 -2
- package/dist/{index-CqhXqGLt.d.cts → index-DlTiYWBe.d.cts} +2 -2
- package/dist/{index-BVNS-Aut.d.ts → index-I82Wu-Ah.d.ts} +2 -2
- package/dist/{index--SKVGToc.d.ts → index-KQNyWRoG.d.ts} +2 -2
- package/dist/{index-D9GJhX1I.d.ts → index-uhmZ9qaP.d.ts} +2 -2
- package/dist/locationutils.cjs +1 -1
- package/dist/locationutils.d.cts +2 -2
- package/dist/locationutils.d.ts +2 -2
- package/dist/locationutils.js +1 -1
- package/dist/mockState.cjs +24 -0
- package/dist/mockState.cjs.map +1 -0
- package/dist/mockState.d.cts +7 -0
- package/dist/mockState.d.ts +7 -0
- package/dist/mockState.js +23 -0
- package/dist/mockState.js.map +1 -0
- package/dist/monitorSlice/constants.d.cts +1 -1
- package/dist/monitorSlice/constants.d.ts +1 -1
- package/dist/monitorSlice/index.d.cts +1 -1
- package/dist/monitorSlice/index.d.ts +1 -1
- package/dist/monitorSlice/index.js +1 -1
- package/dist/monitorSlice/mocks.d.cts +1 -1
- package/dist/monitorSlice/mocks.d.ts +1 -1
- package/dist/monitorSlice/mocks.js +1 -1
- package/dist/monitorSlice/selectors.cjs.map +1 -1
- package/dist/monitorSlice/selectors.d.cts +2 -10
- package/dist/monitorSlice/selectors.d.ts +2 -10
- package/dist/monitorSlice/selectors.js.map +1 -1
- package/dist/monitorSlice/thunks.cjs +2 -3
- package/dist/monitorSlice/thunks.cjs.map +1 -1
- package/dist/monitorSlice/thunks.d.cts +4 -4
- package/dist/monitorSlice/thunks.d.ts +4 -4
- package/dist/monitorSlice/thunks.js +3 -2
- package/dist/monitorSlice/thunks.js.map +1 -1
- package/dist/onboardingSlice/selectors.cjs.map +1 -1
- package/dist/onboardingSlice/selectors.d.cts +2 -6
- package/dist/onboardingSlice/selectors.d.ts +2 -6
- package/dist/onboardingSlice/selectors.js.map +1 -1
- package/dist/onboardingSlice/thunks.d.cts +3 -3
- package/dist/onboardingSlice/thunks.d.ts +3 -3
- package/dist/organizationSlice/constants.cjs +1 -1
- package/dist/organizationSlice/constants.js +1 -1
- package/dist/organizationSlice/index.cjs +1 -1
- package/dist/organizationSlice/index.d.cts +1 -1
- package/dist/organizationSlice/index.d.ts +1 -1
- package/dist/organizationSlice/index.js +1 -1
- package/dist/organizationSlice/mocks.d.cts +3 -3
- package/dist/organizationSlice/mocks.d.ts +3 -3
- package/dist/organizationSlice/mocks.js +1 -1
- package/dist/organizationSlice/selectors.cjs +1 -1
- package/dist/organizationSlice/selectors.cjs.map +1 -1
- package/dist/organizationSlice/selectors.d.cts +2 -472
- package/dist/organizationSlice/selectors.d.ts +2 -472
- package/dist/organizationSlice/selectors.js +1 -1
- package/dist/organizationSlice/selectors.js.map +1 -1
- package/dist/organizationSlice/thunks.d.cts +25 -21
- package/dist/organizationSlice/thunks.d.ts +25 -21
- package/dist/organizationSlice/types.d.cts +1 -1
- package/dist/organizationSlice/types.d.ts +1 -1
- package/dist/releasesSlice/constants.cjs +0 -2
- package/dist/releasesSlice/constants.cjs.map +1 -1
- package/dist/releasesSlice/constants.d.cts +2 -2
- package/dist/releasesSlice/constants.d.ts +2 -2
- package/dist/releasesSlice/constants.js +1 -2
- package/dist/releasesSlice/constants.js.map +1 -1
- package/dist/releasesSlice/index.d.cts +1 -1
- package/dist/releasesSlice/index.d.ts +1 -1
- package/dist/releasesSlice/index.js +1 -1
- package/dist/releasesSlice/mocks.js +1 -1
- package/dist/releasesSlice/selectors.cjs.map +1 -1
- package/dist/releasesSlice/selectors.d.cts +2 -795
- package/dist/releasesSlice/selectors.d.ts +2 -795
- package/dist/releasesSlice/selectors.js.map +1 -1
- package/dist/releasesSlice/thunks.cjs +18 -18
- package/dist/releasesSlice/thunks.cjs.map +1 -1
- package/dist/releasesSlice/thunks.d.cts +4 -4
- package/dist/releasesSlice/thunks.d.ts +4 -4
- package/dist/releasesSlice/thunks.js +3 -2
- package/dist/releasesSlice/thunks.js.map +1 -1
- package/dist/selectors-CH-yXu-7.d.cts +84 -0
- package/dist/selectors-CQYkG1VI.d.cts +9 -0
- package/dist/selectors-CR0q7rXC.d.cts +593 -0
- package/dist/selectors-CdCZGn7e.d.cts +99 -0
- package/dist/selectors-CdllyZyW.d.cts +363 -0
- package/dist/selectors-CftbLtXH.d.cts +14 -0
- package/dist/selectors-D2j3_Mnp.d.ts +363 -0
- package/dist/selectors-D78O3T1o.d.ts +99 -0
- package/dist/selectors-D9t4It2i.d.ts +84 -0
- package/dist/selectors-D_UFk4Uz.d.ts +14 -0
- package/dist/selectors-DuHGqmMJ.d.cts +712 -0
- package/dist/selectors-SvKXGJM5.d.ts +712 -0
- package/dist/selectors-eYLuQW4M.d.ts +593 -0
- package/dist/selectors-elCimAHX.d.ts +9 -0
- package/dist/selectors-qClZ9EXM.d.ts +374 -0
- package/dist/selectors-rto0SO4z.d.cts +374 -0
- package/dist/selectors.d.cts +9 -9
- package/dist/selectors.d.ts +9 -9
- package/dist/sockethook.cjs +4 -4
- package/dist/sockethook.cjs.map +1 -1
- package/dist/sockethook.js +2 -1
- package/dist/sockethook.js.map +1 -1
- package/dist/{store-DLp6ajT8.d.ts → store-BQcycBPp.d.ts} +15 -34
- package/dist/{store-Dw8Uo_Df.d.cts → store-CrLzRDCx.d.cts} +14 -33
- package/dist/store.cjs +2 -4
- package/dist/store.cjs.map +1 -1
- package/dist/store.d.cts +2 -2
- package/dist/store.d.ts +2 -2
- package/dist/store.js +2 -4
- package/dist/store.js.map +1 -1
- package/dist/thunks.cjs +39 -43
- package/dist/thunks.cjs.map +1 -1
- package/dist/thunks.js +19 -22
- package/dist/thunks.js.map +1 -1
- package/dist/{types-DY0J79yF.d.ts → types-DB1IOQX8.d.ts} +3 -3
- package/dist/{types-B67YW1jV.d.cts → types-DtTmD7Yn.d.cts} +3 -3
- package/dist/usersSlice/constants.cjs +1 -1
- package/dist/usersSlice/constants.js +1 -1
- package/dist/usersSlice/index.cjs +1 -1
- package/dist/usersSlice/index.d.cts +1 -1
- package/dist/usersSlice/index.d.ts +1 -1
- package/dist/usersSlice/index.js +1 -1
- package/dist/usersSlice/mocks.d.cts +1 -1
- package/dist/usersSlice/mocks.d.ts +1 -1
- package/dist/usersSlice/mocks.js +1 -1
- package/dist/usersSlice/selectors.cjs +3 -3
- package/dist/usersSlice/selectors.cjs.map +1 -1
- package/dist/usersSlice/selectors.d.cts +2 -466
- package/dist/usersSlice/selectors.d.ts +2 -466
- package/dist/usersSlice/selectors.js +2 -2
- package/dist/usersSlice/selectors.js.map +1 -1
- package/dist/usersSlice/thunks.d.cts +88 -88
- package/dist/usersSlice/thunks.d.ts +88 -88
- package/dist/utils.cjs +5 -8
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +4 -6
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/constants-BJuY-ODE.d.ts +0 -124
- package/dist/constants-C2O55iZu.d.cts +0 -124
- package/dist/constants-D5hACLhF.js.map +0 -1
- package/dist/constants-MVizYy89.cjs.map +0 -1
- package/dist/storehooks.cjs +0 -249
- package/dist/storehooks.cjs.map +0 -1
- package/dist/storehooks.d.cts +0 -49
- package/dist/storehooks.d.ts +0 -49
- package/dist/storehooks.js +0 -241
- package/dist/storehooks.js.map +0 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { d as TenantList, i as Organization, l as SSOConfig, n as AuditLogSelectionState, o as ProductConfig, r as Card, u as Tenant } from "./types-DtTmD7Yn.cjs";
|
|
2
|
+
import { t as OrganizationSliceType } from "./index-Dd_guNwA.cjs";
|
|
3
|
+
//#region src/organizationSlice/selectors.d.ts
|
|
4
|
+
type OrganizationState = {
|
|
5
|
+
organization: OrganizationSliceType;
|
|
6
|
+
};
|
|
7
|
+
declare const getOrganization: (state: OrganizationState) => Partial<Organization>;
|
|
8
|
+
declare const getProducts: (state: OrganizationState) => ProductConfig | undefined;
|
|
9
|
+
declare const getExternalIntegrations: (state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[];
|
|
10
|
+
declare const getAuditlogState: (state: OrganizationState) => AuditLogSelectionState;
|
|
11
|
+
declare const getAuditLog: (state: OrganizationState) => import("@northern.tech/types/types.gen").AuditLog[];
|
|
12
|
+
declare const getAuditLogSelectionState: (state: OrganizationState) => AuditLogSelectionState;
|
|
13
|
+
declare const getBillingProfile: (state: OrganizationState) => import("@northern.tech/types/types.gen").BillingProfile | undefined;
|
|
14
|
+
declare const getSubscription: (state: OrganizationState) => import("@northern.tech/types/types.gen").SubscriptionData | undefined;
|
|
15
|
+
declare const getCard: (state: OrganizationState) => Card;
|
|
16
|
+
declare const getSsoConfig: ({ organization: { ssoConfigs } }: OrganizationState) => SSOConfig;
|
|
17
|
+
declare const getTenantsList: (state: OrganizationState) => TenantList;
|
|
18
|
+
declare const getWebhookEvents: (state: OrganizationState) => import("@northern.tech/types/types.gen").Event[];
|
|
19
|
+
declare const getWebhookEventsTotal: (state: OrganizationState) => number;
|
|
20
|
+
declare const getDeviceTwinIntegrations: ((state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[]) & {
|
|
21
|
+
clearCache: () => void;
|
|
22
|
+
resultsCount: () => number;
|
|
23
|
+
resetResultsCount: () => void;
|
|
24
|
+
} & {
|
|
25
|
+
resultFunc: (resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[]) => import("@northern.tech/types/types.gen").Integration[];
|
|
26
|
+
memoizedResultFunc: ((resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[]) => import("@northern.tech/types/types.gen").Integration[]) & {
|
|
27
|
+
clearCache: () => void;
|
|
28
|
+
resultsCount: () => number;
|
|
29
|
+
resetResultsCount: () => void;
|
|
30
|
+
};
|
|
31
|
+
lastResult: () => import("@northern.tech/types/types.gen").Integration[];
|
|
32
|
+
dependencies: [(state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[]];
|
|
33
|
+
recomputations: () => number;
|
|
34
|
+
resetRecomputations: () => void;
|
|
35
|
+
dependencyRecomputations: () => number;
|
|
36
|
+
resetDependencyRecomputations: () => void;
|
|
37
|
+
} & {
|
|
38
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
39
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
40
|
+
};
|
|
41
|
+
declare const getIsServiceProvider: (state: OrganizationState) => boolean | undefined;
|
|
42
|
+
declare const getWebhooks: ((state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[]) & {
|
|
43
|
+
clearCache: () => void;
|
|
44
|
+
resultsCount: () => number;
|
|
45
|
+
resetResultsCount: () => void;
|
|
46
|
+
} & {
|
|
47
|
+
resultFunc: (resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[]) => import("@northern.tech/types/types.gen").Integration[];
|
|
48
|
+
memoizedResultFunc: ((resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[]) => import("@northern.tech/types/types.gen").Integration[]) & {
|
|
49
|
+
clearCache: () => void;
|
|
50
|
+
resultsCount: () => number;
|
|
51
|
+
resetResultsCount: () => void;
|
|
52
|
+
};
|
|
53
|
+
lastResult: () => import("@northern.tech/types/types.gen").Integration[];
|
|
54
|
+
dependencies: [(state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[]];
|
|
55
|
+
recomputations: () => number;
|
|
56
|
+
resetRecomputations: () => void;
|
|
57
|
+
dependencyRecomputations: () => number;
|
|
58
|
+
resetDependencyRecomputations: () => void;
|
|
59
|
+
} & {
|
|
60
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
61
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
62
|
+
};
|
|
63
|
+
declare const getWebhookEventInfo: ((state: OrganizationState) => {
|
|
64
|
+
events: import("@northern.tech/types/types.gen").Event[];
|
|
65
|
+
eventsTotal: number;
|
|
66
|
+
}) & {
|
|
67
|
+
clearCache: () => void;
|
|
68
|
+
resultsCount: () => number;
|
|
69
|
+
resetResultsCount: () => void;
|
|
70
|
+
} & {
|
|
71
|
+
resultFunc: (resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[], resultFuncArgs_1: import("@northern.tech/types/types.gen").Event[], resultFuncArgs_2: number) => {
|
|
72
|
+
events: import("@northern.tech/types/types.gen").Event[];
|
|
73
|
+
eventsTotal: number;
|
|
74
|
+
};
|
|
75
|
+
memoizedResultFunc: ((resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[], resultFuncArgs_1: import("@northern.tech/types/types.gen").Event[], resultFuncArgs_2: number) => {
|
|
76
|
+
events: import("@northern.tech/types/types.gen").Event[];
|
|
77
|
+
eventsTotal: number;
|
|
78
|
+
}) & {
|
|
79
|
+
clearCache: () => void;
|
|
80
|
+
resultsCount: () => number;
|
|
81
|
+
resetResultsCount: () => void;
|
|
82
|
+
};
|
|
83
|
+
lastResult: () => {
|
|
84
|
+
events: import("@northern.tech/types/types.gen").Event[];
|
|
85
|
+
eventsTotal: number;
|
|
86
|
+
};
|
|
87
|
+
dependencies: [((state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[]) & {
|
|
88
|
+
clearCache: () => void;
|
|
89
|
+
resultsCount: () => number;
|
|
90
|
+
resetResultsCount: () => void;
|
|
91
|
+
} & {
|
|
92
|
+
resultFunc: (resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[]) => import("@northern.tech/types/types.gen").Integration[];
|
|
93
|
+
memoizedResultFunc: ((resultFuncArgs_0: import("@northern.tech/types/types.gen").Integration[]) => import("@northern.tech/types/types.gen").Integration[]) & {
|
|
94
|
+
clearCache: () => void;
|
|
95
|
+
resultsCount: () => number;
|
|
96
|
+
resetResultsCount: () => void;
|
|
97
|
+
};
|
|
98
|
+
lastResult: () => import("@northern.tech/types/types.gen").Integration[];
|
|
99
|
+
dependencies: [(state: OrganizationState) => import("@northern.tech/types/types.gen").Integration[]];
|
|
100
|
+
recomputations: () => number;
|
|
101
|
+
resetRecomputations: () => void;
|
|
102
|
+
dependencyRecomputations: () => number;
|
|
103
|
+
resetDependencyRecomputations: () => void;
|
|
104
|
+
} & {
|
|
105
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
106
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
107
|
+
}, (state: OrganizationState) => import("@northern.tech/types/types.gen").Event[], (state: OrganizationState) => number];
|
|
108
|
+
recomputations: () => number;
|
|
109
|
+
resetRecomputations: () => void;
|
|
110
|
+
dependencyRecomputations: () => number;
|
|
111
|
+
resetDependencyRecomputations: () => void;
|
|
112
|
+
} & {
|
|
113
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
114
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
115
|
+
};
|
|
116
|
+
declare const getAuditLogEntry: ((state: OrganizationState) => import("@northern.tech/types/types.gen").AuditLog | undefined) & {
|
|
117
|
+
clearCache: () => void;
|
|
118
|
+
resultsCount: () => number;
|
|
119
|
+
resetResultsCount: () => void;
|
|
120
|
+
} & {
|
|
121
|
+
resultFunc: (resultFuncArgs_0: import("@northern.tech/types/types.gen").AuditLog[], resultFuncArgs_1: AuditLogSelectionState) => import("@northern.tech/types/types.gen").AuditLog | undefined;
|
|
122
|
+
memoizedResultFunc: ((resultFuncArgs_0: import("@northern.tech/types/types.gen").AuditLog[], resultFuncArgs_1: AuditLogSelectionState) => import("@northern.tech/types/types.gen").AuditLog | undefined) & {
|
|
123
|
+
clearCache: () => void;
|
|
124
|
+
resultsCount: () => number;
|
|
125
|
+
resetResultsCount: () => void;
|
|
126
|
+
};
|
|
127
|
+
lastResult: () => import("@northern.tech/types/types.gen").AuditLog | undefined;
|
|
128
|
+
dependencies: [(state: OrganizationState) => import("@northern.tech/types/types.gen").AuditLog[], (state: OrganizationState) => AuditLogSelectionState];
|
|
129
|
+
recomputations: () => number;
|
|
130
|
+
resetRecomputations: () => void;
|
|
131
|
+
dependencyRecomputations: () => number;
|
|
132
|
+
resetDependencyRecomputations: () => void;
|
|
133
|
+
} & {
|
|
134
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
135
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
136
|
+
};
|
|
137
|
+
declare const getDisabledTiers: ((state: OrganizationState) => string[]) & {
|
|
138
|
+
clearCache: () => void;
|
|
139
|
+
resultsCount: () => number;
|
|
140
|
+
resetResultsCount: () => void;
|
|
141
|
+
} & {
|
|
142
|
+
resultFunc: (resultFuncArgs_0: {
|
|
143
|
+
disabled: string[];
|
|
144
|
+
limits: Record<string, object>;
|
|
145
|
+
}) => string[];
|
|
146
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
147
|
+
disabled: string[];
|
|
148
|
+
limits: Record<string, object>;
|
|
149
|
+
}) => string[]) & {
|
|
150
|
+
clearCache: () => void;
|
|
151
|
+
resultsCount: () => number;
|
|
152
|
+
resetResultsCount: () => void;
|
|
153
|
+
};
|
|
154
|
+
lastResult: () => string[];
|
|
155
|
+
dependencies: [((state: OrganizationState) => {
|
|
156
|
+
disabled: string[];
|
|
157
|
+
limits: Record<string, object>;
|
|
158
|
+
}) & {
|
|
159
|
+
clearCache: () => void;
|
|
160
|
+
resultsCount: () => number;
|
|
161
|
+
resetResultsCount: () => void;
|
|
162
|
+
} & {
|
|
163
|
+
resultFunc: (resultFuncArgs_0: Partial<Organization>) => {
|
|
164
|
+
disabled: string[];
|
|
165
|
+
limits: Record<string, object>;
|
|
166
|
+
};
|
|
167
|
+
memoizedResultFunc: ((resultFuncArgs_0: Partial<Organization>) => {
|
|
168
|
+
disabled: string[];
|
|
169
|
+
limits: Record<string, object>;
|
|
170
|
+
}) & {
|
|
171
|
+
clearCache: () => void;
|
|
172
|
+
resultsCount: () => number;
|
|
173
|
+
resetResultsCount: () => void;
|
|
174
|
+
};
|
|
175
|
+
lastResult: () => {
|
|
176
|
+
disabled: string[];
|
|
177
|
+
limits: Record<string, object>;
|
|
178
|
+
};
|
|
179
|
+
dependencies: [(state: OrganizationState) => Partial<Organization>];
|
|
180
|
+
recomputations: () => number;
|
|
181
|
+
resetRecomputations: () => void;
|
|
182
|
+
dependencyRecomputations: () => number;
|
|
183
|
+
resetDependencyRecomputations: () => void;
|
|
184
|
+
} & {
|
|
185
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
186
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
187
|
+
}];
|
|
188
|
+
recomputations: () => number;
|
|
189
|
+
resetRecomputations: () => void;
|
|
190
|
+
dependencyRecomputations: () => number;
|
|
191
|
+
resetDependencyRecomputations: () => void;
|
|
192
|
+
} & {
|
|
193
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
194
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
195
|
+
};
|
|
196
|
+
declare const getSpLimits: ((state: OrganizationState) => Record<string, object>) & {
|
|
197
|
+
clearCache: () => void;
|
|
198
|
+
resultsCount: () => number;
|
|
199
|
+
resetResultsCount: () => void;
|
|
200
|
+
} & {
|
|
201
|
+
resultFunc: (resultFuncArgs_0: {
|
|
202
|
+
disabled: string[];
|
|
203
|
+
limits: Record<string, object>;
|
|
204
|
+
}) => Record<string, object>;
|
|
205
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
206
|
+
disabled: string[];
|
|
207
|
+
limits: Record<string, object>;
|
|
208
|
+
}) => Record<string, object>) & {
|
|
209
|
+
clearCache: () => void;
|
|
210
|
+
resultsCount: () => number;
|
|
211
|
+
resetResultsCount: () => void;
|
|
212
|
+
};
|
|
213
|
+
lastResult: () => Record<string, object>;
|
|
214
|
+
dependencies: [((state: OrganizationState) => {
|
|
215
|
+
disabled: string[];
|
|
216
|
+
limits: Record<string, object>;
|
|
217
|
+
}) & {
|
|
218
|
+
clearCache: () => void;
|
|
219
|
+
resultsCount: () => number;
|
|
220
|
+
resetResultsCount: () => void;
|
|
221
|
+
} & {
|
|
222
|
+
resultFunc: (resultFuncArgs_0: Partial<Organization>) => {
|
|
223
|
+
disabled: string[];
|
|
224
|
+
limits: Record<string, object>;
|
|
225
|
+
};
|
|
226
|
+
memoizedResultFunc: ((resultFuncArgs_0: Partial<Organization>) => {
|
|
227
|
+
disabled: string[];
|
|
228
|
+
limits: Record<string, object>;
|
|
229
|
+
}) & {
|
|
230
|
+
clearCache: () => void;
|
|
231
|
+
resultsCount: () => number;
|
|
232
|
+
resetResultsCount: () => void;
|
|
233
|
+
};
|
|
234
|
+
lastResult: () => {
|
|
235
|
+
disabled: string[];
|
|
236
|
+
limits: Record<string, object>;
|
|
237
|
+
};
|
|
238
|
+
dependencies: [(state: OrganizationState) => Partial<Organization>];
|
|
239
|
+
recomputations: () => number;
|
|
240
|
+
resetRecomputations: () => void;
|
|
241
|
+
dependencyRecomputations: () => number;
|
|
242
|
+
resetDependencyRecomputations: () => void;
|
|
243
|
+
} & {
|
|
244
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
245
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
246
|
+
}];
|
|
247
|
+
recomputations: () => number;
|
|
248
|
+
resetRecomputations: () => void;
|
|
249
|
+
dependencyRecomputations: () => number;
|
|
250
|
+
resetDependencyRecomputations: () => void;
|
|
251
|
+
} & {
|
|
252
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
253
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
254
|
+
};
|
|
255
|
+
declare const getTenantListWithLimits: ((state: OrganizationState) => {
|
|
256
|
+
tenants: {
|
|
257
|
+
device_limits: Record<string, object>;
|
|
258
|
+
id: string;
|
|
259
|
+
name: string;
|
|
260
|
+
tenant_token?: string;
|
|
261
|
+
status?: "active" | "suspended";
|
|
262
|
+
plan?: "os" | "enterprise" | "professional";
|
|
263
|
+
trial?: boolean;
|
|
264
|
+
trial_expiration?: string;
|
|
265
|
+
addons?: Array<import("@northern.tech/types/types.gen").Addon>;
|
|
266
|
+
service_provider?: boolean;
|
|
267
|
+
additional_info?: import("@northern.tech/types/types.gen").TenantAdditionalInfo;
|
|
268
|
+
api_limits?: import("@northern.tech/types/types.gen").TenantApiLimits;
|
|
269
|
+
created_at?: string;
|
|
270
|
+
updated_at?: string;
|
|
271
|
+
device_count?: number;
|
|
272
|
+
device_limit?: number;
|
|
273
|
+
}[];
|
|
274
|
+
page: number;
|
|
275
|
+
perPage: number;
|
|
276
|
+
selectedTenant: Tenant | null;
|
|
277
|
+
sort: import("@northern.tech/utils/constants").SortOptions;
|
|
278
|
+
total: number;
|
|
279
|
+
}) & {
|
|
280
|
+
clearCache: () => void;
|
|
281
|
+
resultsCount: () => number;
|
|
282
|
+
resetResultsCount: () => void;
|
|
283
|
+
} & {
|
|
284
|
+
resultFunc: (resultFuncArgs_0: TenantList) => {
|
|
285
|
+
tenants: {
|
|
286
|
+
device_limits: Record<string, object>;
|
|
287
|
+
id: string;
|
|
288
|
+
name: string;
|
|
289
|
+
tenant_token?: string;
|
|
290
|
+
status?: "active" | "suspended";
|
|
291
|
+
plan?: "os" | "enterprise" | "professional";
|
|
292
|
+
trial?: boolean;
|
|
293
|
+
trial_expiration?: string;
|
|
294
|
+
addons?: Array<import("@northern.tech/types/types.gen").Addon>;
|
|
295
|
+
service_provider?: boolean;
|
|
296
|
+
additional_info?: import("@northern.tech/types/types.gen").TenantAdditionalInfo;
|
|
297
|
+
api_limits?: import("@northern.tech/types/types.gen").TenantApiLimits;
|
|
298
|
+
created_at?: string;
|
|
299
|
+
updated_at?: string;
|
|
300
|
+
device_count?: number;
|
|
301
|
+
device_limit?: number;
|
|
302
|
+
}[];
|
|
303
|
+
page: number;
|
|
304
|
+
perPage: number;
|
|
305
|
+
selectedTenant: Tenant | null;
|
|
306
|
+
sort: import("@northern.tech/utils/constants").SortOptions;
|
|
307
|
+
total: number;
|
|
308
|
+
};
|
|
309
|
+
memoizedResultFunc: ((resultFuncArgs_0: TenantList) => {
|
|
310
|
+
tenants: {
|
|
311
|
+
device_limits: Record<string, object>;
|
|
312
|
+
id: string;
|
|
313
|
+
name: string;
|
|
314
|
+
tenant_token?: string;
|
|
315
|
+
status?: "active" | "suspended";
|
|
316
|
+
plan?: "os" | "enterprise" | "professional";
|
|
317
|
+
trial?: boolean;
|
|
318
|
+
trial_expiration?: string;
|
|
319
|
+
addons?: Array<import("@northern.tech/types/types.gen").Addon>;
|
|
320
|
+
service_provider?: boolean;
|
|
321
|
+
additional_info?: import("@northern.tech/types/types.gen").TenantAdditionalInfo;
|
|
322
|
+
api_limits?: import("@northern.tech/types/types.gen").TenantApiLimits;
|
|
323
|
+
created_at?: string;
|
|
324
|
+
updated_at?: string;
|
|
325
|
+
device_count?: number;
|
|
326
|
+
device_limit?: number;
|
|
327
|
+
}[];
|
|
328
|
+
page: number;
|
|
329
|
+
perPage: number;
|
|
330
|
+
selectedTenant: Tenant | null;
|
|
331
|
+
sort: import("@northern.tech/utils/constants").SortOptions;
|
|
332
|
+
total: number;
|
|
333
|
+
}) & {
|
|
334
|
+
clearCache: () => void;
|
|
335
|
+
resultsCount: () => number;
|
|
336
|
+
resetResultsCount: () => void;
|
|
337
|
+
};
|
|
338
|
+
lastResult: () => {
|
|
339
|
+
tenants: {
|
|
340
|
+
device_limits: Record<string, object>;
|
|
341
|
+
id: string;
|
|
342
|
+
name: string;
|
|
343
|
+
tenant_token?: string;
|
|
344
|
+
status?: "active" | "suspended";
|
|
345
|
+
plan?: "os" | "enterprise" | "professional";
|
|
346
|
+
trial?: boolean;
|
|
347
|
+
trial_expiration?: string;
|
|
348
|
+
addons?: Array<import("@northern.tech/types/types.gen").Addon>;
|
|
349
|
+
service_provider?: boolean;
|
|
350
|
+
additional_info?: import("@northern.tech/types/types.gen").TenantAdditionalInfo;
|
|
351
|
+
api_limits?: import("@northern.tech/types/types.gen").TenantApiLimits;
|
|
352
|
+
created_at?: string;
|
|
353
|
+
updated_at?: string;
|
|
354
|
+
device_count?: number;
|
|
355
|
+
device_limit?: number;
|
|
356
|
+
}[];
|
|
357
|
+
page: number;
|
|
358
|
+
perPage: number;
|
|
359
|
+
selectedTenant: Tenant | null;
|
|
360
|
+
sort: import("@northern.tech/utils/constants").SortOptions;
|
|
361
|
+
total: number;
|
|
362
|
+
};
|
|
363
|
+
dependencies: [(state: OrganizationState) => TenantList];
|
|
364
|
+
recomputations: () => number;
|
|
365
|
+
resetRecomputations: () => void;
|
|
366
|
+
dependencyRecomputations: () => number;
|
|
367
|
+
resetDependencyRecomputations: () => void;
|
|
368
|
+
} & {
|
|
369
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
370
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
371
|
+
};
|
|
372
|
+
//#endregion
|
|
373
|
+
export { getWebhooks as S, getTenantListWithLimits as _, getAuditlogState as a, getWebhookEvents as b, getDeviceTwinIntegrations as c, getIsServiceProvider as d, getOrganization as f, getSubscription as g, getSsoConfig as h, getAuditLogSelectionState as i, getDisabledTiers as l, getSpLimits as m, getAuditLog as n, getBillingProfile as o, getProducts as p, getAuditLogEntry as r, getCard as s, OrganizationState as t, getExternalIntegrations as u, getTenantsList as v, getWebhookEventsTotal as x, getWebhookEventInfo as y };
|
|
374
|
+
//# sourceMappingURL=selectors-rto0SO4z.d.cts.map
|
package/dist/selectors.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
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-CdCZGn7e.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-DuHGqmMJ.cjs";
|
|
4
|
+
import { n as getIssueCountsByType, t as MonitorState } from "./selectors-CftbLtXH.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-rto0SO4z.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-CR0q7rXC.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-CdllyZyW.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
|
-
|
|
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 };
|
package/dist/selectors.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
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-D78O3T1o.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-SvKXGJM5.js";
|
|
4
|
+
import { n as getIssueCountsByType, t as MonitorState } from "./selectors-D_UFk4Uz.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-qClZ9EXM.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-eYLuQW4M.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-D2j3_Mnp.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
|
-
|
|
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 };
|
package/dist/sockethook.cjs
CHANGED
|
@@ -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-
|
|
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 *
|
|
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 *
|
|
70
|
+
if (timeout > 0) healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * _northern_tech_utils_constants.TIMEOUTS.oneSecond);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
}
|
package/dist/sockethook.cjs.map
CHANGED
|
@@ -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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,GAAgBF,MAAAA,YAAAA,EACnB,MAAwB;EACvB,QAAQ,IAAI,SAAS;EACrB,QAAQ,CAAC;EACT,MAAM;CACR,GACA,CAAC,OAAO,OAAO,CACjB;CAEA,MAAM,WAAA,GAAUA,MAAAA,YAAAA,EACb,aAA2B;EAC1B,MAAM,MAAM,SAAS,OAAO,SAAS,OAAOM,+BAAAA,OAAO,GAAG,yBAAyB,SAAS;EACxF,aAAa,KAAA,CAAS;EACtB,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,CAAA,GAAA,MAAA,UAAA,OAAgB;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.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 [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;;;;;AAsBA,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,GAAY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,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,CAAA,GAAA,MAAA,UAAA,OAAgB;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"}
|
package/dist/sockethook.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as DEVICE_MESSAGE_PROTOCOLS, ft as DEVICE_MESSAGE_TYPES, h as apiUrl } from "./constants-yul-O5hD.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";
|
package/dist/sockethook.js.map
CHANGED
|
@@ -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,
|
|
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,CAAC;EACjD,UAAU,QAAQ,MAAM;EACxB,aAAa,KAAA,CAAS;CACxB,GAAG,CAAC,WAAW,CAAC;CAEhB,MAAM,oBAAoB,kBAAwB;EAChD,oBAAoB;EACpB,MAAM;CACR,GAAG,CAAC,OAAO,mBAAmB,CAAC;CAE/B,MAAM,kBAAkB,aACrB,UACC,aAAa,MAAM,IAAI,CAAC,CAAC,MAAM,SAAkB;EAC/C,MAAM,EACJ,KAAK,EA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