@northern.tech/store 0.38.0 → 0.40.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 (86) hide show
  1. package/dist/api/general-api.cjs +1 -1
  2. package/dist/api/general-api.js +1 -1
  3. package/dist/appSlice/index.js +1 -1
  4. package/dist/auth.cjs +1 -1
  5. package/dist/auth.js +1 -1
  6. package/dist/commonConstants.cjs +1 -1
  7. package/dist/commonConstants.js +1 -1
  8. package/dist/commonSelectors.cjs +1 -1
  9. package/dist/commonSelectors.js +1 -1
  10. package/dist/constants-CNZ5L0A0.cjs +957 -0
  11. package/dist/constants-CNZ5L0A0.cjs.map +1 -0
  12. package/dist/constants-Cj2kp3Iy.js +676 -0
  13. package/dist/constants-Cj2kp3Iy.js.map +1 -0
  14. package/dist/{constants-BwKiHHaB.d.ts → constants-D9o0Cnk_.d.cts} +2 -1
  15. package/dist/{constants-BwKiHHaB.d.cts → constants-D9o0Cnk_.d.ts} +2 -1
  16. package/dist/constants.cjs +48 -718
  17. package/dist/constants.d.cts +1 -1
  18. package/dist/constants.d.ts +1 -1
  19. package/dist/constants.js +1 -672
  20. package/dist/deploymentsSlice/constants.cjs +1 -1
  21. package/dist/deploymentsSlice/constants.d.cts +1 -1
  22. package/dist/deploymentsSlice/constants.d.ts +1 -1
  23. package/dist/deploymentsSlice/constants.js +1 -1
  24. package/dist/deploymentsSlice/index.cjs +1 -1
  25. package/dist/deploymentsSlice/index.js +1 -1
  26. package/dist/deploymentsSlice/mocks.cjs +1 -1
  27. package/dist/deploymentsSlice/mocks.cjs.map +1 -1
  28. package/dist/deploymentsSlice/mocks.d.cts +1 -1
  29. package/dist/deploymentsSlice/mocks.d.ts +1 -1
  30. package/dist/deploymentsSlice/mocks.js +1 -1
  31. package/dist/deploymentsSlice/mocks.js.map +1 -1
  32. package/dist/deploymentsSlice/selectors.cjs +1 -1
  33. package/dist/deploymentsSlice/selectors.js +1 -1
  34. package/dist/devicesSlice/constants.cjs +1 -1
  35. package/dist/devicesSlice/constants.js +1 -1
  36. package/dist/devicesSlice/index.js +1 -1
  37. package/dist/devicesSlice/mocks.js +1 -1
  38. package/dist/devicesSlice/selectors.cjs +1 -1
  39. package/dist/devicesSlice/selectors.js +1 -1
  40. package/dist/liststatehook.cjs +2 -1
  41. package/dist/liststatehook.cjs.map +1 -1
  42. package/dist/liststatehook.js +2 -1
  43. package/dist/liststatehook.js.map +1 -1
  44. package/dist/locationutils.cjs +1 -1
  45. package/dist/locationutils.js +1 -1
  46. package/dist/monitorSlice/index.js +1 -1
  47. package/dist/monitorSlice/mocks.js +1 -1
  48. package/dist/monitorSlice/thunks.cjs +1 -1
  49. package/dist/monitorSlice/thunks.js +1 -1
  50. package/dist/organizationSlice/constants.cjs +1 -1
  51. package/dist/organizationSlice/constants.js +1 -1
  52. package/dist/organizationSlice/index.cjs +1 -1
  53. package/dist/organizationSlice/index.js +1 -1
  54. package/dist/organizationSlice/mocks.js +1 -1
  55. package/dist/organizationSlice/selectors.cjs +1 -1
  56. package/dist/organizationSlice/selectors.js +1 -1
  57. package/dist/releasesSlice/index.js +1 -1
  58. package/dist/releasesSlice/mocks.js +1 -1
  59. package/dist/releasesSlice/thunks.cjs +6 -4
  60. package/dist/releasesSlice/thunks.cjs.map +1 -1
  61. package/dist/releasesSlice/thunks.js +6 -4
  62. package/dist/releasesSlice/thunks.js.map +1 -1
  63. package/dist/sockethook.cjs +1 -1
  64. package/dist/sockethook.js +1 -1
  65. package/dist/store.cjs +1 -1
  66. package/dist/store.js +1 -1
  67. package/dist/storehooks.cjs +1 -1
  68. package/dist/storehooks.js +1 -1
  69. package/dist/thunks.cjs +61 -44
  70. package/dist/thunks.cjs.map +1 -1
  71. package/dist/thunks.js +62 -45
  72. package/dist/thunks.js.map +1 -1
  73. package/dist/usersSlice/constants.cjs +1 -1
  74. package/dist/usersSlice/constants.js +1 -1
  75. package/dist/usersSlice/index.cjs +1 -1
  76. package/dist/usersSlice/index.js +1 -1
  77. package/dist/usersSlice/mocks.js +1 -1
  78. package/dist/usersSlice/selectors.cjs +1 -1
  79. package/dist/usersSlice/selectors.js +1 -1
  80. package/dist/utils.cjs +11 -21
  81. package/dist/utils.cjs.map +1 -1
  82. package/dist/utils.js +11 -21
  83. package/dist/utils.js.map +1 -1
  84. package/package.json +5 -5
  85. package/dist/constants.cjs.map +0 -1
  86. package/dist/constants.js.map +0 -1
package/dist/thunks.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ADDONS, PLANS, locations } from "./appSlice/constants.js";
2
+ import { B as twoFAStates, C as deviceConnect, D as inventoryApiUrl, E as headerNames, F as scopedPermissionAreas, G as useradmApiUrlv2, H as uiPermissionsById, J as USER_LOGOUT, L as ssoIdpApiUrlv1, Mt as UNGROUPED_GROUP, N as rolesById, O as inventoryApiUrlV2, R as tenantadmApiUrlv1, S as deviceConfig, T as emptyUiPermissions, U as useradmApiUrl, V as uiPermissionsByArea, X as itemUiPermissionsReducer, Z as settingsKeys, _ as defaultPermissionSets, _t as DEPLOYMENT_TYPES, a as APPLICATION_JWT_CONTENT_TYPE, b as deploymentsApiUrlV2, bt as deploymentPrototype, d as PermissionTypes, f as SORTING_OPTIONS, ft as emptyFilter, g as auditLogsApiUrl, gt as DEPLOYMENT_STATES, ht as DEPLOYMENT_ROUTES, i as APPLICATION_JSON_CONTENT_TYPE, j as maxSessionAge, jt as TIMEOUTS, k as iotManagerBaseURL, kt as EXTERNAL_PROVIDER, l as DEVICE_LIST_DEFAULTS, m as apiRoot, n as ALL_DEVICE_STATES, nt as TENANT_LIST_DEFAULT, q as READ_STATES, r as ALL_RELEASES, s as DEVICE_FILTERING_OPTIONS, tt as SSO_TYPES, u as DEVICE_STATES, v as deploymentsApiUrl, w as emptyRole, x as deviceAuthV2, z as tenantadmApiUrlv2 } from "./constants-Cj2kp3Iy.js";
2
3
  import { onboardingSteps, orderedOnboardingSteps } from "./onboardingSlice/constants.js";
3
4
  import { rootfsImageVersion } from "./releasesSlice/constants.js";
4
- import { ALL_DEVICE_STATES, ALL_RELEASES, APPLICATION_JSON_CONTENT_TYPE, APPLICATION_JWT_CONTENT_TYPE, DEPLOYMENT_ROUTES, DEPLOYMENT_STATES, DEPLOYMENT_TYPES, DEVICE_FILTERING_OPTIONS, DEVICE_LIST_DEFAULTS, DEVICE_STATES, EXTERNAL_PROVIDER, PermissionTypes, READ_STATES, SORTING_OPTIONS, SSO_TYPES, TENANT_LIST_DEFAULT, TIMEOUTS, UNGROUPED_GROUP, USER_LOGOUT, apiRoot, auditLogsApiUrl, defaultPermissionSets, deploymentPrototype, deploymentsApiUrl, deploymentsApiUrlV2, deviceAuthV2, deviceConfig, deviceConnect, emptyFilter, emptyRole, emptyUiPermissions, headerNames, inventoryApiUrl, inventoryApiUrlV2, iotManagerBaseURL, itemUiPermissionsReducer, maxSessionAge, rolesById, scopedPermissionAreas, settingsKeys, ssoIdpApiUrlv1, tenantadmApiUrlv1, tenantadmApiUrlv2, twoFAStates, uiPermissionsByArea, uiPermissionsById, useradmApiUrl, useradmApiUrlv2 } from "./constants.js";
5
5
  import { actions } from "./appSlice/index.js";
6
6
  import { actions as actions$1, sliceName as sliceName$1 } from "./deploymentsSlice/index.js";
7
7
  import { actions as actions$2, sliceName as sliceName$2 } from "./devicesSlice/index.js";
@@ -22,7 +22,7 @@ import Api from "./api/general-api.js";
22
22
  import { changeNotificationSetting, getDeviceAlerts, getDeviceMonitorConfig, getIssueCountsByType, getLatestDeviceAlerts } from "./monitorSlice/thunks.js";
23
23
  import { cancelFileUpload, checkReleasesExistence, createArtifact, editArtifact, generateManifest, getArtifactInstallCount, getArtifactUrl, getDeltaGenerationJobDetails, getDeltaGenerationJobs, getExistingManifestTags, getExistingReleaseTags, getExistingSoftwareTags, getManifest, getManifests, getRelease, getReleases, getSoftware, getSoftwareList, getUpdateTypes, removeArtifact, removeManifest, removeManifests, removeRelease, removeReleases, selectManifest, selectRelease, setManifestsListState, setReleaseTags, setReleasesListState, setReleasesTags, setSingleReleaseTags, setSoftwareListState, updateManifestInfo, updateReleaseInfo, uploadArtifact, uploadManifest } from "./releasesSlice/thunks.js";
24
24
  import Api$1 from "./api/users-api.js";
25
- import { attributeDuplicateFilter, customSort, dateRangeToUnix, deepCompare, duplicateFilter, extractErrorMessage, getDemoDeviceAddress, getSnackbarMessage, isEmpty, standardizePhases } from "@northern.tech/utils/helpers";
25
+ import { attributeDuplicateFilter, customSort, dateRangeToUnix, deepCompare, duplicateFilter, extractErrorMessage, getDemoDeviceAddress, isEmpty, standardizePhases } from "@northern.tech/utils/helpers";
26
26
  import Cookies from "universal-cookie";
27
27
  import dayjs from "dayjs";
28
28
  import Tracking from "@northern.tech/utils/tracking";
@@ -446,10 +446,11 @@ const deepClean = (source) => Object.entries(source).reduce((accu, [key, value])
446
446
  return accu;
447
447
  }, void 0);
448
448
  const saveDeltaDeploymentsConfig = createAppAsyncThunk(`${sliceName$1}/saveDeltaDeploymentsConfig`, (config, { dispatch, getState }) => {
449
- const result = deepClean({ xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
449
+ const configChange = { xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
450
450
  if (config[here] !== void 0) accu[there] = config[here];
451
451
  return accu;
452
- }, {}) });
452
+ }, {}) };
453
+ const result = deepClean(configChange);
453
454
  if (!result) return Promise.resolve();
454
455
  return Api.put(`${deploymentsApiUrl}/config/binary_delta`, result).catch((err) => commonErrorHandler(err, "There was a problem storing your delta artifact generation configuration.", dispatch)).then(() => {
455
456
  const oldConfig = getState().deployments.config;
@@ -709,7 +710,8 @@ const reduceReceivedDevices = (devices, ids, state, status) => devices.reduce((a
709
710
  device.created_ts = getEarliestTs(getEarliestTs(system.created_ts, device.created_ts), stateDevice.created_ts);
710
711
  device.updated_ts = device.attributes ? device.updated_ts : stateDevice.updated_ts;
711
712
  device.isNew = new Date(device.created_ts) > new Date(state.app.newThreshold);
712
- device.isOffline = new Date(device.check_in_time_rounded) < new Date(state.app.offlineThreshold) || device.check_in_time_rounded === void 0;
713
+ const lastCheckIn = device.check_in_time_exact ?? device.check_in_time_rounded;
714
+ device.isOffline = new Date(lastCheckIn) < new Date(state.app.offlineThreshold) || lastCheckIn === void 0;
713
715
  device.attributes = device.attributes ? {
714
716
  ...storedAttributes,
715
717
  ...inventory
@@ -1181,13 +1183,22 @@ const getDevicesWithAuth = createAppAsyncThunk(`${sliceName$2}/getDevicesWithAut
1181
1183
  dispatch(actions$2.receivedDevices(devicesById));
1182
1184
  return receivedDevices;
1183
1185
  });
1184
- const updateDeviceAuth = createAppAsyncThunk(`${sliceName$2}/updateDeviceAuth`, ({ deviceId, authId, status }, { dispatch, getState }) => Api.put(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar$2("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions$2.maybeUpdateDevicesByStatus({
1186
+ const getSnackbarMessage = (skipped, done, failed = 0) => {
1187
+ pluralize.addIrregularRule("its", "their");
1188
+ const skipText = skipped ? `${skipped} ${pluralize("devices", skipped)} ${pluralize("have", skipped)} more than one pending authset. Expand ${pluralize("this", skipped)} ${pluralize("device", skipped)} to individually adjust ${pluralize("their", skipped)} authorization status. ` : "";
1189
+ const failedText = failed ? `${failed} ${pluralize("device", failed)} could not be updated. You may have reached your device limit. ` : "";
1190
+ return `${done ? `${done} ${pluralize("device", done)} ${pluralize("was", done)} updated successfully. ` : ""}${skipText}${failedText}`;
1191
+ };
1192
+ const updateDeviceAuth = createAppAsyncThunk(`${sliceName$2}/updateDeviceAuth`, ({ deviceId, authId, status }, { dispatch, getState }) => Api.put(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar$2("Device authorization status was updated successfully"))])).catch((err) => {
1193
+ return commonErrorHandler(err, err.response?.status === 422 ? "Device limit reached: You have reached your limit of accepted devices." : "There was a problem updating the device authorization status:", dispatch);
1194
+ }).then(() => Promise.resolve(dispatch(actions$2.maybeUpdateDevicesByStatus({
1185
1195
  deviceId,
1186
1196
  authId
1187
1197
  })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getDeviceListState(getState()).refreshTrigger }))));
1188
1198
  const updateDevicesAuth = createAppAsyncThunk(`${sliceName$2}/updateDevicesAuth`, ({ deviceIds, status }, { dispatch, getState }) => {
1189
1199
  let devices = getDevicesById(getState());
1190
- return dispatch(getDevicesWithAuth(deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []))).then(() => {
1200
+ const deviceIdsWithoutAuth = deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []);
1201
+ return dispatch(getDevicesWithAuth(deviceIdsWithoutAuth)).then(() => {
1191
1202
  devices = getDevicesById(getState());
1192
1203
  const deviceAuthUpdates = deviceIds.map((id) => {
1193
1204
  const device = devices[id];
@@ -1199,15 +1210,18 @@ const updateDevicesAuth = createAppAsyncThunk(`${sliceName$2}/updateDevicesAuth`
1199
1210
  })).unwrap().catch((err) => commonErrorHandler(err, "The action was stopped as there was a problem updating a device authorization status: ", dispatch, "", false));
1200
1211
  });
1201
1212
  return Promise.allSettled(deviceAuthUpdates).then((results) => {
1202
- const { skipped, count } = results.reduce((accu, item) => {
1203
- if (item.status === "rejected") accu.skipped = accu.skipped + 1;
1213
+ const { skipped, failed, count } = results.reduce((accu, item) => {
1214
+ if (item.status === "rejected") if (item.reason) accu.failed = accu.failed + 1;
1215
+ else accu.skipped = accu.skipped + 1;
1204
1216
  else accu.count = accu.count + 1;
1205
1217
  return accu;
1206
1218
  }, {
1207
1219
  skipped: 0,
1220
+ failed: 0,
1208
1221
  count: 0
1209
1222
  });
1210
- return dispatch(setSnackbar$2(getSnackbarMessage(skipped, count)));
1223
+ const message = getSnackbarMessage(skipped, count, failed);
1224
+ return dispatch(setSnackbar$2(message));
1211
1225
  });
1212
1226
  });
1213
1227
  });
@@ -1343,19 +1357,20 @@ const getSystemDevices = createAppAsyncThunk(`${sliceName$2}/getSystemDevices`,
1343
1357
  if (!hasFullFiltering) return Promise.resolve();
1344
1358
  const { attributes: deviceAttributes = {} } = getDeviceById$1(state, id);
1345
1359
  const { mender_gateway_system_id = "" } = deviceAttributes;
1360
+ const filters = [{
1361
+ ...emptyFilter,
1362
+ key: "mender_is_gateway",
1363
+ operator: DEVICE_FILTERING_OPTIONS.$ne.key,
1364
+ value: "true",
1365
+ scope: "inventory"
1366
+ }, {
1367
+ ...emptyFilter,
1368
+ key: "mender_gateway_system_id",
1369
+ value: mender_gateway_system_id,
1370
+ scope: "inventory"
1371
+ }];
1346
1372
  const { attributes, filterTerms } = prepareSearchArguments({
1347
- filters: [{
1348
- ...emptyFilter,
1349
- key: "mender_is_gateway",
1350
- operator: DEVICE_FILTERING_OPTIONS.$ne.key,
1351
- value: "true",
1352
- scope: "inventory"
1353
- }, {
1354
- ...emptyFilter,
1355
- key: "mender_gateway_system_id",
1356
- value: mender_gateway_system_id,
1357
- scope: "inventory"
1358
- }],
1373
+ filters,
1359
1374
  state
1360
1375
  });
1361
1376
  return Api.post(`${inventoryApiUrlV2}/filters/search`, {
@@ -1382,28 +1397,29 @@ const getGatewayDevices = createAppAsyncThunk(`${sliceName$2}/getGatewayDevices`
1382
1397
  const state = getState();
1383
1398
  const { attributes = {} } = getDeviceById$1(state, deviceId);
1384
1399
  const { mender_gateway_system_id = "" } = attributes;
1400
+ const filters = [
1401
+ {
1402
+ ...emptyFilter,
1403
+ key: "id",
1404
+ operator: DEVICE_FILTERING_OPTIONS.$ne.key,
1405
+ value: deviceId,
1406
+ scope: "identity"
1407
+ },
1408
+ {
1409
+ ...emptyFilter,
1410
+ key: "mender_is_gateway",
1411
+ value: "true",
1412
+ scope: "inventory"
1413
+ },
1414
+ {
1415
+ ...emptyFilter,
1416
+ key: "mender_gateway_system_id",
1417
+ value: mender_gateway_system_id,
1418
+ scope: "inventory"
1419
+ }
1420
+ ];
1385
1421
  const { attributes: attributeSelection, filterTerms } = prepareSearchArguments({
1386
- filters: [
1387
- {
1388
- ...emptyFilter,
1389
- key: "id",
1390
- operator: DEVICE_FILTERING_OPTIONS.$ne.key,
1391
- value: deviceId,
1392
- scope: "identity"
1393
- },
1394
- {
1395
- ...emptyFilter,
1396
- key: "mender_is_gateway",
1397
- value: "true",
1398
- scope: "inventory"
1399
- },
1400
- {
1401
- ...emptyFilter,
1402
- key: "mender_gateway_system_id",
1403
- value: mender_gateway_system_id,
1404
- scope: "inventory"
1405
- }
1406
- ],
1422
+ filters,
1407
1423
  state
1408
1424
  });
1409
1425
  return Api.post(`${inventoryApiUrlV2}/filters/search`, {
@@ -1570,7 +1586,7 @@ const getProductAddons = (products) => products.reduce((accu, product) => {
1570
1586
  const newEligible = addonPrices.map((p) => p.plan);
1571
1587
  accu[addonName] = {
1572
1588
  ...ADDONS[addonName],
1573
- eligible: [...new Set([
1589
+ eligible: [.../* @__PURE__ */ new Set([
1574
1590
  ...existingEligible,
1575
1591
  ...newEligible,
1576
1592
  PLANS.enterprise.id
@@ -2261,7 +2277,8 @@ const deriveImpliedAreaPermissions = (area, areaPermissions, skipPermissions = [
2261
2277
  */
2262
2278
  const transformAreaRoleDataToScopedPermissionsSets = (area, areaPermissions, excessiveAccessSelector) => {
2263
2279
  const permissionSetObject = areaPermissions.reduce((accu, { item, uiPermissions }) => {
2264
- accu = deriveImpliedAreaPermissions(area, uiPermissions, scopedPermissionAreas.releases.key === area && item !== ALL_RELEASES ? [uiPermissionsById.upload.value] : []).reduce((itemPermissionAccu, impliedPermission) => {
2280
+ const skipPermissions = scopedPermissionAreas.releases.key === area && item !== ALL_RELEASES ? [uiPermissionsById.upload.value] : [];
2281
+ accu = deriveImpliedAreaPermissions(area, uiPermissions, skipPermissions).reduce((itemPermissionAccu, impliedPermission) => {
2265
2282
  const permissionSetState = itemPermissionAccu[uiPermissionsById[impliedPermission].permissionSets[area]] ?? {
2266
2283
  type: uiPermissionsByArea[area].scope,
2267
2284
  value: []