@northern.tech/store 0.42.0 → 0.44.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 (97) hide show
  1. package/dist/actions.d.cts +3 -3
  2. package/dist/actions.d.ts +3 -3
  3. package/dist/appSlice/index.cjs +1 -0
  4. package/dist/appSlice/index.cjs.map +1 -1
  5. package/dist/appSlice/index.js +1 -0
  6. package/dist/appSlice/index.js.map +1 -1
  7. package/dist/appSlice/selectors.d.cts +3 -3
  8. package/dist/appSlice/selectors.d.ts +3 -3
  9. package/dist/appSlice/thunks.d.cts +1 -1
  10. package/dist/appSlice/thunks.d.ts +1 -1
  11. package/dist/auth.d.cts +1 -1
  12. package/dist/auth.d.ts +1 -1
  13. package/dist/commonSelectors.d.cts +3 -3
  14. package/dist/commonSelectors.d.ts +3 -3
  15. package/dist/deploymentsSlice/selectors.d.cts +3 -3
  16. package/dist/deploymentsSlice/selectors.d.ts +3 -3
  17. package/dist/deploymentsSlice/thunks.d.cts +2 -2
  18. package/dist/deploymentsSlice/thunks.d.ts +2 -2
  19. package/dist/devicesSlice/index.cjs +4 -1
  20. package/dist/devicesSlice/index.cjs.map +1 -1
  21. package/dist/devicesSlice/index.d.cts +2 -2
  22. package/dist/devicesSlice/index.d.ts +2 -2
  23. package/dist/devicesSlice/index.js +4 -1
  24. package/dist/devicesSlice/index.js.map +1 -1
  25. package/dist/devicesSlice/mocks.d.cts +1 -0
  26. package/dist/devicesSlice/mocks.d.ts +1 -0
  27. package/dist/devicesSlice/selectors.cjs +2 -0
  28. package/dist/devicesSlice/selectors.cjs.map +1 -1
  29. package/dist/devicesSlice/selectors.d.cts +35 -34
  30. package/dist/devicesSlice/selectors.d.ts +35 -34
  31. package/dist/devicesSlice/selectors.js +2 -1
  32. package/dist/devicesSlice/selectors.js.map +1 -1
  33. package/dist/devicesSlice/thunks.cjs +1 -0
  34. package/dist/devicesSlice/thunks.d.cts +18 -5
  35. package/dist/devicesSlice/thunks.d.ts +18 -5
  36. package/dist/devicesSlice/thunks.js +2 -2
  37. package/dist/{index-Bvyf8OO6.d.ts → index-BpamudGf.d.ts} +8 -6
  38. package/dist/{index-CpfhQHfg.d.ts → index-C0yQmQih.d.ts} +4 -2
  39. package/dist/{index-BgF6rhXn.d.cts → index-DjSjrp5b.d.cts} +4 -2
  40. package/dist/{index-CiQ95u1W.d.cts → index-DnKVKM0G.d.cts} +8 -6
  41. package/dist/locationutils.d.cts +1 -1
  42. package/dist/locationutils.d.ts +1 -1
  43. package/dist/monitorSlice/selectors.d.cts +1 -1
  44. package/dist/monitorSlice/selectors.d.ts +1 -1
  45. package/dist/monitorSlice/thunks.d.cts +2 -2
  46. package/dist/monitorSlice/thunks.d.ts +2 -2
  47. package/dist/onboardingSlice/selectors.d.cts +1 -1
  48. package/dist/onboardingSlice/selectors.d.ts +1 -1
  49. package/dist/onboardingSlice/thunks.d.cts +2 -2
  50. package/dist/onboardingSlice/thunks.d.ts +2 -2
  51. package/dist/organizationSlice/selectors.d.cts +3 -3
  52. package/dist/organizationSlice/selectors.d.ts +3 -3
  53. package/dist/organizationSlice/thunks.cjs +1 -0
  54. package/dist/organizationSlice/thunks.d.cts +16 -3
  55. package/dist/organizationSlice/thunks.d.ts +16 -3
  56. package/dist/organizationSlice/thunks.js +2 -2
  57. package/dist/releasesSlice/selectors.d.cts +3 -3
  58. package/dist/releasesSlice/selectors.d.ts +3 -3
  59. package/dist/releasesSlice/thunks.cjs +5 -8
  60. package/dist/releasesSlice/thunks.cjs.map +1 -1
  61. package/dist/releasesSlice/thunks.d.cts +1 -1
  62. package/dist/releasesSlice/thunks.d.ts +1 -1
  63. package/dist/releasesSlice/thunks.js +5 -8
  64. package/dist/releasesSlice/thunks.js.map +1 -1
  65. package/dist/selectors.cjs +1 -0
  66. package/dist/selectors.d.cts +2 -2
  67. package/dist/selectors.d.ts +2 -2
  68. package/dist/selectors.js +2 -2
  69. package/dist/{store-CPptM5Ts.d.ts → store-BKVs6gSc.d.ts} +3 -3
  70. package/dist/{store-CUUm1GTI.d.cts → store-ByJVpIz9.d.cts} +3 -3
  71. package/dist/store.d.cts +1 -1
  72. package/dist/store.d.ts +1 -1
  73. package/dist/storehooks.cjs +3 -1
  74. package/dist/storehooks.cjs.map +1 -1
  75. package/dist/storehooks.d.cts +2 -2
  76. package/dist/storehooks.d.ts +2 -2
  77. package/dist/storehooks.js +3 -1
  78. package/dist/storehooks.js.map +1 -1
  79. package/dist/thunks.cjs +17 -1
  80. package/dist/thunks.cjs.map +1 -1
  81. package/dist/thunks.d.cts +3 -3
  82. package/dist/thunks.d.ts +3 -3
  83. package/dist/thunks.js +17 -3
  84. package/dist/thunks.js.map +1 -1
  85. package/dist/usersSlice/index.cjs.map +1 -1
  86. package/dist/usersSlice/index.d.cts +1 -1
  87. package/dist/usersSlice/index.d.ts +1 -1
  88. package/dist/usersSlice/index.js.map +1 -1
  89. package/dist/usersSlice/mocks.d.cts +1 -1
  90. package/dist/usersSlice/mocks.d.ts +1 -1
  91. package/dist/usersSlice/selectors.d.cts +3 -3
  92. package/dist/usersSlice/selectors.d.ts +3 -3
  93. package/dist/usersSlice/thunks.d.cts +2 -2
  94. package/dist/usersSlice/thunks.d.ts +2 -2
  95. package/dist/utils.d.cts +1 -1
  96. package/dist/utils.d.ts +1 -1
  97. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { i as UserSession } from "./index-CpfhQHfg.js";
2
- import { r as RootState, t as AppDispatch } from "./store-CPptM5Ts.js";
1
+ import { i as UserSession } from "./index-C0yQmQih.js";
2
+ import { r as RootState, t as AppDispatch } from "./store-BKVs6gSc.js";
3
3
  //#region src/storehooks.d.ts
4
4
  declare const parseEnvironmentInfo: import("@reduxjs/toolkit").AsyncThunk<[{
5
5
  payload: UserSession;
@@ -35,6 +35,7 @@ const featureFlags = [
35
35
  "hasManifestsEnabled",
36
36
  "hasMonitor",
37
37
  "hasMCUEnabled",
38
+ "hasNewSearch",
38
39
  "isEnterprise"
39
40
  ];
40
41
  const environmentDatas = [
@@ -148,7 +149,8 @@ const useAppInit = (userId) => {
148
149
  } else tasks.push(Promise.resolve(dispatch(actions_default.setDeviceLimits({
149
150
  micro: 0,
150
151
  standard: -1,
151
- system: 0
152
+ system: 0,
153
+ test: -1
152
154
  }))));
153
155
  return Promise.all(tasks);
154
156
  }, [
@@ -1 +1 @@
1
- {"version":3,"file":"storehooks.js","names":["storeActions","getOnboardingStateSelector","getDevicesByStatusSelector","getUserSettingsSelector","getGlobalSettingsSelector","getUserSettings","getGlobalSettings","getDevicesByStatus","actions","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 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 { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport actions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, locations, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\n// a host is hosted when it is one of the known hosted domains or a subdomain of one (e.g. staging.hosted.mender.io),\n// except for per-PR preview deployments whose leading label looks like <component>-pr-<number> (e.g. os-pr-2012.staging.hosted.mender.io)\nconst hostedDomains = Object.values(locations).map(({ location }) => location);\nconst isPreviewDeployment = (hostname: string) => /^[^.]+-pr-\\d+\\./.test(hostname);\nconst isHostedHostname = (hostname: string) =>\n !isPreviewDeployment(hostname) && hostedDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasDeviceFlags',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docsVersion?: string;\n version?: string;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, version } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || isHostedHostname(window.location.hostname)\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docsVersion: isNaN(parseInt(version.charAt(0))) ? '' : version.split('.').slice(0, 2).join('.'),\n version\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation(versionInfo)),\n dispatch(storeActions.setEnvironmentData(environmentData))\n ]);\n});\n\n// probes the organization endpoint to classify the deployment: reaching it means the deployment is multitenant,\n// which - when not hosted - identifies an on-prem enterprise installation, while an unreachable endpoint identifies\n// a single-tenant OS installation. hosted deployments keep their plan-derived enterprise status (getIsEnterprise).\n// must run after parseEnvironmentInfo so the final isHosted value is available in the store.\nexport const probeOrganizationCapabilities = createAppAsyncThunk(`app/probeOrganizationCapabilities`, (_, { dispatch, getState }) =>\n dispatch(getUserOrganization())\n .unwrap()\n .then(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: true, isEnterprise: true }));\n }\n })\n .catch(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: false, isEnterprise: false }));\n }\n })\n);\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const { hasMultitenancy } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback(\n (): Promise<unknown[]> =>\n Promise.all([\n // parse the environment first so isHosted is set before the organization probe classifies the deployment type\n dispatch(parseEnvironmentInfo())\n .unwrap()\n .then(() => dispatch(probeOrganizationCapabilities()).unwrap()),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ]),\n [dispatch]\n );\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n } else {\n tasks.push(Promise.resolve(dispatch(actions.setDeviceLimits({ micro: 0, standard: -1, system: 0 }))));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4DA,MAAM,UAAU,IAAI,QAAQ;AAC5B,MAAM,OAAO,aAAa;AAE1B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BA;AAIvG,MAAM,gBAAgB,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,EAAE,eAAe,QAAQ;AAC7E,MAAM,uBAAuB,aAAqB,kBAAkB,KAAK,QAAQ;AACjF,MAAM,oBAAoB,aACxB,CAAC,oBAAoB,QAAQ,KAAK,cAAc,MAAK,WAAU,aAAa,UAAU,SAAS,SAAS,IAAI,QAAQ,CAAC;AAEvH,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AASA,MAAa,uBAAuB,oBAAoB,6BAA6B,GAAG,EAAE,UAAU,eAAe;CACjH,MAAM,QAAQ,SAAS;CACvB,IAAI,qBAAqBC,mBAA2B,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,KAAK,MAAM,OAAO,aAAa,QAAQ,oBAAoB,KAAK,OAAO;CAChJ,IAAI,mBAAmB;CACvB,IAAI,kBAA2C,CAAC;CAChD,IAAI,sBAAyC,CAAC;CAC9C,IAAI,cAA2B,CAAC;CAChC,MAAM,qBAAqB,OAAO;CAClC,IAAI,oBAAoB;EACtB,MAAM,EAAE,WAAW,CAAC,GAAG,kBAAkB,MAAM,mBAAmB,YAAY;EAC9E,mBAAmB,OAAO,IAAI,KAAK;EACnC,MAAM,WAAW,MAAM;EACvB,kBAAkB,iBAAiB,QAAQ,MAAM,UAAU;GAAE,GAAG;IAAO,OAAO,mBAAmB,SAAS,SAAS;EAA+B,IAAI,CAAC,CAAC;EACxJ,s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AC,GAC9C;EAAC;EAAU;EAAiB;CAAgB,CAC9C;CAEA,gBAAgB;EACd,IAAI,CAAC,UAAU,gBAAgB,SAC7B;EAEF,gBAAgB,UAAU;EAC1B,iBAAiB,CAAC,CAAC,WAAW,gBAAgB,IAAI,CAAC;CACrD,GAAG,CAAC,QAAQ,gBAAgB,CAAC;CAE7B,gBAAgB;EACd,IAAI,gBAAgB,WAAW,CAAC,cAC9B;EAEF,gBAAgB,UAAU;EAC1B,kBAAkB;CACpB,GAAG,CAAC,mBAAmB,YAAY,CAAC;CAEpC,OAAO,EAAE,aAAa;AACxB"}
1
+ {"version":3,"file":"storehooks.js","names":["storeActions","getOnboardingStateSelector","getDevicesByStatusSelector","getUserSettingsSelector","getGlobalSettingsSelector","getUserSettings","getGlobalSettings","getDevicesByStatus","actions","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 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 { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport actions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, locations, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\n// a host is hosted when it is one of the known hosted domains or a subdomain of one (e.g. staging.hosted.mender.io),\n// except for per-PR preview deployments whose leading label looks like <component>-pr-<number> (e.g. os-pr-2012.staging.hosted.mender.io)\nconst hostedDomains = Object.values(locations).map(({ location }) => location);\nconst isPreviewDeployment = (hostname: string) => /^[^.]+-pr-\\d+\\./.test(hostname);\nconst isHostedHostname = (hostname: string) =>\n !isPreviewDeployment(hostname) && hostedDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasDeviceFlags',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'hasNewSearch',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docsVersion?: string;\n version?: string;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, version } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || isHostedHostname(window.location.hostname)\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docsVersion: isNaN(parseInt(version.charAt(0))) ? '' : version.split('.').slice(0, 2).join('.'),\n version\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation(versionInfo)),\n dispatch(storeActions.setEnvironmentData(environmentData))\n ]);\n});\n\n// probes the organization endpoint to classify the deployment: reaching it means the deployment is multitenant,\n// which - when not hosted - identifies an on-prem enterprise installation, while an unreachable endpoint identifies\n// a single-tenant OS installation. hosted deployments keep their plan-derived enterprise status (getIsEnterprise).\n// must run after parseEnvironmentInfo so the final isHosted value is available in the store.\nexport const probeOrganizationCapabilities = createAppAsyncThunk(`app/probeOrganizationCapabilities`, (_, { dispatch, getState }) =>\n dispatch(getUserOrganization())\n .unwrap()\n .then(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: true, isEnterprise: true }));\n }\n })\n .catch(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: false, isEnterprise: false }));\n }\n })\n);\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const { hasMultitenancy } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback(\n (): Promise<unknown[]> =>\n Promise.all([\n // parse the environment first so isHosted is set before the organization probe classifies the deployment type\n dispatch(parseEnvironmentInfo())\n .unwrap()\n .then(() => dispatch(probeOrganizationCapabilities()).unwrap()),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ]),\n [dispatch]\n );\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n } else {\n // OS users have unlimited standard and test devices\n tasks.push(Promise.resolve(dispatch(actions.setDeviceLimits({ micro: 0, standard: -1, system: 0, test: -1 }))));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4DA,MAAM,UAAU,IAAI,QAAQ;AAC5B,MAAM,OAAO,aAAa;AAE1B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BA;AAIvG,MAAM,gBAAgB,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,EAAE,eAAe,QAAQ;AAC7E,MAAM,uBAAuB,aAAqB,kBAAkB,KAAK,QAAQ;AACjF,MAAM,oBAAoB,aACxB,CAAC,oBAAoB,QAAQ,KAAK,cAAc,MAAK,WAAU,aAAa,UAAU,SAAS,SAAS,IAAI,QAAQ,CAAC;AAEvH,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AASA,MAAa,uBAAuB,oBAAoB,6BAA6B,GAAG,EAAE,UAAU,eAAe;CACjH,MAAM,QAAQ,SAAS;CACvB,IAAI,qBAAqBC,mBAA2B,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,KAAK,MAAM,OAAO,aAAa,QAAQ,oBAAoB,KAAK,OAAO;CAChJ,IAAI,mBAAmB;CACvB,IAAI,kBAA2C,CAAC;CAChD,IAAI,sBAAyC,CAAC;CAC9C,IAAI,cAA2B,CAAC;CAChC,MAAM,qBAAqB,OAAO;CAClC,IAAI,oBAAoB;EACtB,MAAM,EAAE,WAAW,CAAC,GAAG,kBAAkB,MA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A;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,oBAAoB,kBAEtB,gBAAgB,CAAC,CACd,KAAK,gBAAgB,CAAC,CAEtB,OAAM,QAAO,QAAQ,IAAI,oBAAoB,GAAG,CAAC,CAAC,CAAC,CACnD,WAAW,SAASS,qBAAmB,CAAC,CAAC,GAC9C;EAAC;EAAU;EAAiB;CAAgB,CAC9C;CAEA,gBAAgB;EACd,IAAI,CAAC,UAAU,gBAAgB,SAC7B;EAEF,gBAAgB,UAAU;EAC1B,iBAAiB,CAAC,CAAC,WAAW,gBAAgB,IAAI,CAAC;CACrD,GAAG,CAAC,QAAQ,gBAAgB,CAAC;CAE7B,gBAAgB;EACd,IAAI,gBAAgB,WAAW,CAAC,cAC9B;EAEF,gBAAgB,UAAU;EAC1B,kBAAkB;CACpB,GAAG,CAAC,mBAAmB,YAAY,CAAC;CAEpC,OAAO,EAAE,aAAa;AACxB"}
package/dist/thunks.cjs CHANGED
@@ -1023,6 +1023,19 @@ const searchDevices = require_store.createAppAsyncThunk(`${require_devicesSlice_
1023
1023
  searchTotal: Number(response.headers[_northern_tech_utils_constants.headerNames.total])
1024
1024
  };
1025
1025
  });
1026
+ const searchIdentities = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/searchIdentities`, async (options, { dispatch }) => {
1027
+ const { attributes: additionalAttributes = [], page = defaultPage$1, per_page = defaultPerPage$1, ...remainder } = options;
1028
+ const response = await require_api_general_api.default.post(`${_northern_tech_utils_constants.inventoryApiUrlV2alpha1}/identities/search`, {
1029
+ ...remainder,
1030
+ attributes: (0, _northern_tech_utils_helpers.attributeDuplicateFilter)([...defaultAttributes, ...additionalAttributes], "attribute"),
1031
+ page,
1032
+ per_page
1033
+ }).catch((err) => require_store.commonErrorHandler(err, `devices couldn't be searched.`, dispatch, require_store.commonErrorFallback));
1034
+ return {
1035
+ devices: response.data,
1036
+ total: Number(response.headers[_northern_tech_utils_constants.headerNames.total])
1037
+ };
1038
+ });
1026
1039
  const ATTRIBUTE_LIST_CUTOFF = 100;
1027
1040
  const attributeReducer = (attributes = []) => attributes.slice(0, ATTRIBUTE_LIST_CUTOFF).reduce((accu, { name, scope }) => {
1028
1041
  if (!accu[scope]) accu[scope] = [];
@@ -1721,7 +1734,7 @@ const removeTenant = require_store.createAppAsyncThunk(`${require_organizationSl
1721
1734
  dispatch
1722
1735
  });
1723
1736
  }));
1724
- const getUserOrganization = require_store.createAppAsyncThunk(`${require_organizationSlice_index.sliceName}/getUserOrganization`, (_, { dispatch, getState }) => require_api_general_api.default.get(`${_northern_tech_utils_constants.tenantadmApiUrlv1}/user/tenant?tiers=true`).then((res) => {
1737
+ const getUserOrganization = require_store.createAppAsyncThunk(`${require_organizationSlice_index.sliceName}/getUserOrganization`, (_, { dispatch, getState }) => require_api_general_api.default.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/me?tiers=true`).then((res) => {
1725
1738
  const { addons, plan, trial } = res.data;
1726
1739
  const { addons: currentAddons, id: currentId, plan: currentPlan, trial: currentTrial } = require_organizationSlice_selectors.getOrganization(getState());
1727
1740
  const tasks = [dispatch(require_organizationSlice_index.actions.setOrganization(res.data))];
@@ -1741,6 +1754,7 @@ const getUserOrganization = require_store.createAppAsyncThunk(`${require_organiz
1741
1754
  }
1742
1755
  return Promise.all(tasks);
1743
1756
  }));
1757
+ const getTenantToken = require_store.createAppAsyncThunk(`${require_organizationSlice_index.sliceName}/getTenantToken`, (_, { dispatch }) => require_api_general_api.default.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/me/token`).catch((err) => require_store.commonErrorHandler(err, "There was an error retrieving your organization token", dispatch, require_store.commonErrorFallback)).then(({ data: { tenant_token } }) => dispatch(require_organizationSlice_index.actions.setOrganization({ tenant_token }))));
1744
1758
  const getUserBilling = require_store.createAppAsyncThunk(`${require_organizationSlice_index.sliceName}/getUserBilling`, (_, { dispatch }) => require_api_general_api.default.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/profile`).catch((err) => require_store.commonErrorHandler(err, "There was an error getting your billing profile:", dispatch, require_store.commonErrorFallback)).then((res) => dispatch(require_organizationSlice_index.actions.setBillingProfile(res.data))));
1745
1759
  const getUserSubscription = require_store.createAppAsyncThunk(`${require_organizationSlice_index.sliceName}/getUserSubscription`, async (_, { dispatch }) => {
1746
1760
  const currentSubscription = await dispatch(getCurrentSubscription()).unwrap();
@@ -2539,6 +2553,7 @@ exports.getSoftwareList = require_releasesSlice_thunks.getSoftwareList;
2539
2553
  exports.getSsoConfigById = getSsoConfigById;
2540
2554
  exports.getSsoConfigs = getSsoConfigs;
2541
2555
  exports.getTargetLocation = getTargetLocation;
2556
+ exports.getTenantToken = getTenantToken;
2542
2557
  exports.getTenants = getTenants;
2543
2558
  exports.getTestDeviceCount = getTestDeviceCount;
2544
2559
  exports.getTokens = getTokens;
@@ -2578,6 +2593,7 @@ exports.saveDeltaDeploymentsConfig = saveDeltaDeploymentsConfig;
2578
2593
  exports.saveGlobalSettings = saveGlobalSettings;
2579
2594
  exports.saveUserSettings = saveUserSettings;
2580
2595
  exports.searchDevices = searchDevices;
2596
+ exports.searchIdentities = searchIdentities;
2581
2597
  exports.selectGroup = selectGroup;
2582
2598
  exports.selectManifest = require_releasesSlice_thunks.selectManifest;
2583
2599
  exports.selectRelease = require_releasesSlice_thunks.selectRelease;