@commercetools-frontend/application-shell 21.23.10 → 21.24.1
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/application-entry-point-47d5c548.cjs.dev.js +116 -0
- package/dist/application-entry-point-5619d5aa.cjs.prod.js +99 -0
- package/dist/application-entry-point-dc726674.esm.js +101 -0
- package/dist/{box-dd9e7e68.esm.js → box-4395623b.esm.js} +1 -3
- package/dist/{box-fdb2ccb6.cjs.dev.js → box-6b5be9a9.cjs.dev.js} +1 -3
- package/dist/{box-d849ea03.cjs.prod.js → box-8850277f.cjs.prod.js} +1 -3
- package/dist/{cart-ad0aba9b.cjs.prod.js → cart-0698b97d.cjs.prod.js} +1 -3
- package/dist/{cart-b92f3a8e.cjs.dev.js → cart-41f0b7bc.cjs.dev.js} +1 -3
- package/dist/{cart-167fea3b.esm.js → cart-a49faf67.esm.js} +1 -3
- package/dist/commercetools-frontend-application-shell.cjs.dev.js +49 -68
- package/dist/commercetools-frontend-application-shell.cjs.prod.js +49 -68
- package/dist/commercetools-frontend-application-shell.esm.js +39 -58
- package/dist/configure-apollo-942ef373.cjs.prod.js +922 -0
- package/dist/configure-apollo-a6f03ff8.cjs.dev.js +930 -0
- package/dist/configure-apollo-cc0b1668.esm.js +873 -0
- package/dist/{connected-square-4743b7de.esm.js → connected-square-3cac6bd7.esm.js} +1 -3
- package/dist/connected-square-47233754.cjs.dev.js +32 -0
- package/dist/connected-square-b2e25621.cjs.prod.js +32 -0
- package/dist/{constants-69249abd.esm.js → constants-7f04db3f.esm.js} +9 -9
- package/dist/{constants-88fb9ef8.cjs.prod.js → constants-e6409334.cjs.prod.js} +8 -8
- package/dist/{constants-c2d56f3d.cjs.dev.js → constants-e6f058e5.cjs.dev.js} +8 -8
- package/dist/declarations/src/apollo-links/utils.d.ts +2 -2
- package/dist/declarations/src/components/application-entry-point/application-entry-point.d.ts +4 -4
- package/dist/declarations/src/components/application-shell/application-shell.d.ts +7 -15
- package/dist/declarations/src/components/application-shell-authenticated/application-shell-authenticated.d.ts +21 -0
- package/dist/declarations/src/components/application-shell-provider/application-shell-provider.d.ts +6 -7
- package/dist/declarations/src/components/application-shell-provider/use-coerced-environment-values.d.ts +1 -23
- package/dist/declarations/src/components/authenticated/authenticated.d.ts +2 -2
- package/dist/declarations/src/components/authenticated/oidc-callback.async.d.ts +6 -0
- package/dist/declarations/src/components/authenticated/oidc-callback.d.ts +2 -2
- package/dist/declarations/src/components/configure-intl-provider/configure-intl-provider.d.ts +1 -1
- package/dist/declarations/src/components/error-apologizer/index.d.ts +6 -1
- package/dist/declarations/src/components/fetch-project/fetch-project.d.ts +4 -4
- package/dist/declarations/src/components/fetch-user/fetch-user.d.ts +3 -3
- package/dist/declarations/src/components/inject-reducers/inject-reducers.d.ts +1 -1
- package/dist/declarations/src/components/navbar/index.d.ts +100 -1
- package/dist/declarations/src/components/navbar/loading-navbar.d.ts +5 -0
- package/dist/declarations/src/components/navbar/menu-items.d.ts +99 -0
- package/dist/declarations/src/components/navbar/navbar.d.ts +6 -15
- package/dist/declarations/src/components/project-container/index.d.ts +78 -1
- package/dist/declarations/src/components/project-container/project-container.d.ts +6 -8
- package/dist/declarations/src/components/quick-access/butler-command/butler-command.d.ts +1 -1
- package/dist/declarations/src/components/quick-access/index.d.ts +2 -2
- package/dist/declarations/src/components/quick-access/types.d.ts +1 -1
- package/dist/declarations/src/components/redirect-to-login/index.d.ts +6 -0
- package/dist/declarations/src/components/redirect-to-logout/index.d.ts +5 -0
- package/dist/declarations/src/components/redirect-to-project-create/index.d.ts +6 -1
- package/dist/declarations/src/components/requests-in-flight-loader/index.d.ts +6 -1
- package/dist/declarations/src/components/route-catch-all/index.d.ts +3 -1
- package/dist/declarations/src/components/setup-flop-flip-provider/setup-flop-flip-provider.d.ts +3 -3
- package/dist/declarations/src/components/suspended-route/suspended-route.d.ts +1 -1
- package/dist/declarations/src/components/user-settings-menu/index.d.ts +12 -1
- package/dist/declarations/src/components/version-tracker/index.d.ts +6 -1
- package/dist/declarations/src/hooks/apollo-hooks/apollo-hooks.d.ts +1 -1
- package/dist/declarations/src/test-utils/test-utils.d.ts +2 -2
- package/dist/declarations/src/types/generated/mc.d.ts +3 -3
- package/dist/declarations/src/utils/get-mc-origin/get-mc-origin.d.ts +2 -0
- package/dist/declarations/src/utils/get-mc-origin/index.d.ts +1 -0
- package/dist/error-apologizer-c336db61.cjs.dev.js +56 -0
- package/dist/error-apologizer-c55ec6f7.cjs.prod.js +56 -0
- package/dist/error-apologizer-f8772b68.esm.js +42 -0
- package/dist/gear-2890f7fb.cjs.prod.js +32 -0
- package/dist/{gear-8418cd46.esm.js → gear-300dd24c.esm.js} +1 -3
- package/dist/gear-e8014c5a.cjs.dev.js +32 -0
- package/dist/get-mc-origin-314b77a2.cjs.dev.js +57 -0
- package/dist/get-mc-origin-5df60933.esm.js +50 -0
- package/dist/get-mc-origin-7968e04f.cjs.prod.js +57 -0
- package/dist/heart-000a023d.cjs.prod.js +32 -0
- package/dist/{heart-48c28091.esm.js → heart-dded66b4.esm.js} +1 -3
- package/dist/heart-f21b7d39.cjs.dev.js +32 -0
- package/dist/index-3765c4c9.cjs.prod.js +2870 -0
- package/dist/index-3fdf5681.esm.js +2970 -0
- package/dist/index-b9b8b690.cjs.dev.js +3054 -0
- package/dist/{list-with-search-c154a56e.esm.js → list-with-search-a3302710.esm.js} +1 -3
- package/dist/list-with-search-a5b72b33.cjs.prod.js +32 -0
- package/dist/list-with-search-ee796e9e.cjs.dev.js +32 -0
- package/dist/navbar-08a76df9.cjs.dev.js +670 -0
- package/dist/navbar-5384b0c3.esm.js +650 -0
- package/dist/navbar-c02843fb.cjs.prod.js +649 -0
- package/dist/oidc-0638d0c8.cjs.dev.js +67 -0
- package/dist/oidc-10fa96f0.esm.js +59 -0
- package/dist/oidc-540a091a.cjs.prod.js +67 -0
- package/dist/oidc-callback-152dc622.esm.js +240 -0
- package/dist/oidc-callback-784c3a39.cjs.prod.js +251 -0
- package/dist/oidc-callback-dc8682c0.cjs.dev.js +254 -0
- package/dist/paperclip-23d1e69c.cjs.prod.js +32 -0
- package/dist/{paperclip-18785dda.esm.js → paperclip-a61112e8.esm.js} +1 -3
- package/dist/paperclip-d653c134.cjs.dev.js +32 -0
- package/dist/plugin-0ee6aee4.cjs.dev.js +32 -0
- package/dist/{plugin-53c047bb.esm.js → plugin-3d353a5b.esm.js} +1 -3
- package/dist/plugin-7e57f237.cjs.prod.js +32 -0
- package/dist/project-container-6f0ea904.cjs.dev.js +387 -0
- package/dist/project-container-b6b2f6b2.esm.js +368 -0
- package/dist/project-container-bf8678e2.cjs.prod.js +369 -0
- package/dist/{project-expired-d8eaa253.esm.js → project-expired-6b9b6feb.esm.js} +47 -68
- package/dist/{project-expired-adce523b.cjs.dev.js → project-expired-9d71c314.cjs.dev.js} +47 -68
- package/dist/{project-expired-576a8329.cjs.prod.js → project-expired-d75d9e84.cjs.prod.js} +47 -68
- package/dist/{project-not-found-9a9753f2.cjs.dev.js → project-not-found-4b5b9479.cjs.prod.js} +42 -61
- package/dist/{project-not-found-8208c8f1.esm.js → project-not-found-c4634d60.esm.js} +42 -61
- package/dist/{project-not-found-daa5200b.cjs.prod.js → project-not-found-c977dbb0.cjs.dev.js} +42 -61
- package/dist/{project-not-initialized-4aeafe19.cjs.dev.js → project-not-initialized-4d0badf3.cjs.prod.js} +47 -68
- package/dist/{project-not-initialized-3408e87f.esm.js → project-not-initialized-a2f7b46e.esm.js} +47 -68
- package/dist/{project-not-initialized-5b416bcf.cjs.prod.js → project-not-initialized-e1533577.cjs.dev.js} +47 -68
- package/dist/{project-suspended-d3a6001d.cjs.dev.js → project-suspended-9027fc60.cjs.prod.js} +44 -63
- package/dist/{project-suspended-dc9ace34.cjs.prod.js → project-suspended-9e084c21.cjs.dev.js} +44 -63
- package/dist/{project-suspended-a7edc962.esm.js → project-suspended-f3d78447.esm.js} +44 -63
- package/dist/{quick-access-f42a8e0a.cjs.prod.js → quick-access-517ad7e1.cjs.prod.js} +573 -957
- package/dist/quick-access-82e1c9aa.esm.js +1907 -0
- package/dist/quick-access-8b2b678f.cjs.dev.js +1937 -0
- package/dist/redirect-to-login-1b892ab5.esm.js +147 -0
- package/dist/redirect-to-login-2be0e5db.cjs.prod.js +149 -0
- package/dist/redirect-to-login-64230f67.cjs.dev.js +149 -0
- package/dist/redirect-to-logout-15810ffb.cjs.dev.js +151 -0
- package/dist/redirect-to-logout-17e4ba2c.cjs.prod.js +151 -0
- package/dist/redirect-to-logout-80e772d1.esm.js +138 -0
- package/dist/redirect-to-project-create-048efa71.cjs.prod.js +61 -0
- package/dist/redirect-to-project-create-052f293e.esm.js +52 -0
- package/dist/redirect-to-project-create-f0e7b35e.cjs.dev.js +61 -0
- package/dist/{gear-28ff4f04.cjs.dev.js → redirector-0d98f9df.cjs.dev.js} +44 -5
- package/dist/redirector-47a6be71.esm.js +58 -0
- package/dist/{gear-6f8c30e3.cjs.prod.js → redirector-77ce2f5c.cjs.prod.js} +44 -5
- package/dist/requests-in-flight-loader-5329586b.esm.js +129 -0
- package/dist/requests-in-flight-loader-88f14402.cjs.dev.js +144 -0
- package/dist/requests-in-flight-loader-a7bc4e12.cjs.prod.js +144 -0
- package/dist/rocket-3e3f0a98.cjs.prod.js +32 -0
- package/dist/{rocket-ba116b5e.esm.js → rocket-4b088727.esm.js} +1 -3
- package/dist/rocket-95b6858d.cjs.dev.js +32 -0
- package/dist/route-catch-all-01cf0095.esm.js +41 -0
- package/dist/route-catch-all-3b490df1.cjs.prod.js +43 -0
- package/dist/route-catch-all-9ac99936.cjs.dev.js +43 -0
- package/dist/{service-page-project-switcher-49afafeb.cjs.prod.js → service-page-project-switcher-39dcfee8.cjs.prod.js} +5 -7
- package/dist/{service-page-project-switcher-866b2139.cjs.dev.js → service-page-project-switcher-7698339b.cjs.dev.js} +6 -8
- package/dist/{service-page-project-switcher-365c4c10.esm.js → service-page-project-switcher-fd30959b.esm.js} +6 -8
- package/dist/{speedometer-c1b94505.esm.js → speedometer-08a11d5a.esm.js} +1 -3
- package/dist/speedometer-2881cef6.cjs.prod.js +32 -0
- package/dist/speedometer-54f872f2.cjs.dev.js +32 -0
- package/dist/{star-da9123e0.esm.js → star-15244db1.esm.js} +1 -3
- package/dist/star-52bf7a64.cjs.dev.js +32 -0
- package/dist/star-f8502efb.cjs.prod.js +32 -0
- package/dist/tag-multi-1d1553b6.cjs.dev.js +32 -0
- package/dist/{tag-multi-c650b738.esm.js → tag-multi-3be995ac.esm.js} +1 -3
- package/dist/tag-multi-f9acb1c2.cjs.prod.js +32 -0
- package/dist/tree-structure-4650688d.cjs.dev.js +32 -0
- package/dist/{tree-structure-6af6fc3a.esm.js → tree-structure-c8753526.esm.js} +1 -3
- package/dist/tree-structure-f24ee3f6.cjs.prod.js +32 -0
- package/dist/use-applications-menu-4abb5796.esm.js +172 -0
- package/dist/use-applications-menu-68d83733.cjs.dev.js +188 -0
- package/dist/use-applications-menu-6b872b83.cjs.prod.js +188 -0
- package/dist/use-is-served-by-proxy-2b4916e5.cjs.dev.js +42 -0
- package/dist/use-is-served-by-proxy-499bfa16.esm.js +39 -0
- package/dist/use-is-served-by-proxy-51e76976.cjs.prod.js +42 -0
- package/dist/{user-filled-41729d77.esm.js → user-filled-2dc4e79e.esm.js} +1 -3
- package/dist/user-filled-2e6cb25e.cjs.dev.js +32 -0
- package/dist/user-filled-815b49a0.cjs.prod.js +32 -0
- package/dist/user-settings-menu-79d4cb1e.cjs.dev.js +523 -0
- package/dist/user-settings-menu-7bf6f146.cjs.prod.js +496 -0
- package/dist/user-settings-menu-ad7c27f0.esm.js +497 -0
- package/dist/version-tracker-20bb239d.esm.js +101 -0
- package/dist/version-tracker-69607d15.cjs.dev.js +107 -0
- package/dist/version-tracker-80e0f8f6.cjs.prod.js +107 -0
- package/dist/world-973090a5.cjs.dev.js +32 -0
- package/dist/{world-d91df1ee.esm.js → world-c5ea311a.esm.js} +1 -3
- package/dist/world-e1f9dbf8.cjs.prod.js +32 -0
- package/package.json +27 -27
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.dev.js +2 -3
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.prod.js +2 -3
- package/ssr/dist/commercetools-frontend-application-shell-ssr.esm.js +2 -3
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.dev.js +182 -215
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.prod.js +182 -215
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.esm.js +173 -206
- package/dist/application-entry-point-307baa50.cjs.prod.js +0 -1225
- package/dist/application-entry-point-3e14d46d.cjs.dev.js +0 -1250
- package/dist/application-entry-point-8d923438.esm.js +0 -1180
- package/dist/connected-square-abf36852.cjs.prod.js +0 -34
- package/dist/connected-square-ac52014f.cjs.dev.js +0 -34
- package/dist/declarations/src/components/application-shell/helpers.d.ts +0 -1
- package/dist/heart-33cd94c6.cjs.prod.js +0 -34
- package/dist/heart-fb31cf30.cjs.dev.js +0 -34
- package/dist/index-284fb405.esm.js +0 -4809
- package/dist/index-37414a3f.cjs.prod.js +0 -4643
- package/dist/index-ea32a85e.cjs.dev.js +0 -4888
- package/dist/list-with-search-34cd926c.cjs.dev.js +0 -34
- package/dist/list-with-search-a0b22169.cjs.prod.js +0 -34
- package/dist/oidc-1c91f5ee.cjs.prod.js +0 -67
- package/dist/oidc-5b2e4f8f.cjs.dev.js +0 -67
- package/dist/oidc-77749f1b.esm.js +0 -59
- package/dist/paperclip-2cd45b86.cjs.dev.js +0 -34
- package/dist/paperclip-b1b806ab.cjs.prod.js +0 -34
- package/dist/plugin-7cb7827e.cjs.dev.js +0 -34
- package/dist/plugin-e97ae3e6.cjs.prod.js +0 -34
- package/dist/quick-access-457a9f41.esm.js +0 -2290
- package/dist/quick-access-d553524e.cjs.dev.js +0 -2321
- package/dist/rocket-37c1aa11.cjs.dev.js +0 -34
- package/dist/rocket-b2dbda7f.cjs.prod.js +0 -34
- package/dist/speedometer-13b393fb.cjs.dev.js +0 -34
- package/dist/speedometer-1e69fd13.cjs.prod.js +0 -34
- package/dist/star-ab4be629.cjs.prod.js +0 -34
- package/dist/star-e165111e.cjs.dev.js +0 -34
- package/dist/tag-multi-5f498a7d.cjs.dev.js +0 -34
- package/dist/tag-multi-fb817131.cjs.prod.js +0 -34
- package/dist/tree-structure-779fcc36.cjs.prod.js +0 -34
- package/dist/tree-structure-ed6cdff8.cjs.dev.js +0 -34
- package/dist/user-filled-384a2eaf.cjs.prod.js +0 -34
- package/dist/user-filled-53d2eae0.cjs.dev.js +0 -34
- package/dist/world-12528632.cjs.prod.js +0 -34
- package/dist/world-6471d9f6.cjs.dev.js +0 -34
- /package/dist/declarations/src/components/{application-shell → redirect-to-login}/redirect-to-login.d.ts +0 -0
- /package/dist/declarations/src/components/{application-shell → redirect-to-logout}/redirect-to-logout.d.ts +0 -0
|
@@ -1,1180 +0,0 @@
|
|
|
1
|
-
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
|
-
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
|
-
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
|
-
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
5
|
-
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
6
|
-
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
|
-
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
|
-
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
-
import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
|
|
10
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
11
|
-
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
12
|
-
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
13
|
-
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
14
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
15
|
-
import _Reflect$has from '@babel/runtime-corejs3/core-js-stable/reflect/has';
|
|
16
|
-
import mapValues from 'lodash/mapValues';
|
|
17
|
-
import { applyMiddleware, configureStore, combineReducers } from '@reduxjs/toolkit';
|
|
18
|
-
import thunk from 'redux-thunk';
|
|
19
|
-
import omitEmpty from 'omit-empty-es';
|
|
20
|
-
import { ADD_NOTIFICATION, removeNotification, REMOVE_NOTIFICATION, reducer, middleware } from '@commercetools-frontend/notifications';
|
|
21
|
-
import { createMiddleware } from '@commercetools-frontend/sdk';
|
|
22
|
-
import { HIDE_ALL_PAGE_NOTIFICATIONS, NOTIFICATION_KINDS_PAGE, SHOW_LOADING, HIDE_LOADING, GRAPHQL_TARGETS, STATUS_CODES, LOGOUT_REASONS } from '@commercetools-frontend/constants';
|
|
23
|
-
import { S as STORAGE_KEYS, L as LOGIN_STRATEGY_OIDC, c as SUPPORTED_HEADERS } from './constants-69249abd.esm.js';
|
|
24
|
-
import { selectPageNotifications } from '@commercetools-frontend/react-notifications';
|
|
25
|
-
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
26
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
27
|
-
import { createLogger } from 'redux-logger';
|
|
28
|
-
import ReactDOM from 'react-dom';
|
|
29
|
-
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
30
|
-
import { useSelector } from 'react-redux';
|
|
31
|
-
import LoadingSpinner from '@commercetools-uikit/loading-spinner';
|
|
32
|
-
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
33
|
-
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
34
|
-
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
35
|
-
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
36
|
-
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
37
|
-
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
38
|
-
import { ApolloLink, createHttpLink, ApolloClient, from, InMemoryCache } from '@apollo/client';
|
|
39
|
-
import loggerLink from 'apollo-link-logger';
|
|
40
|
-
import _Array$from from '@babel/runtime-corejs3/core-js-stable/array/from';
|
|
41
|
-
import _Symbol from '@babel/runtime-corejs3/core-js-stable/symbol';
|
|
42
|
-
import _getIteratorMethod from '@babel/runtime-corejs3/core-js/get-iterator-method';
|
|
43
|
-
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
44
|
-
import { onError } from '@apollo/client/link/error';
|
|
45
|
-
import history from '@commercetools-frontend/browser-history';
|
|
46
|
-
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
47
|
-
import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
48
|
-
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
49
|
-
import createHttpUserAgent from '@commercetools/http-user-agent';
|
|
50
|
-
import { v4 } from 'uuid';
|
|
51
|
-
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
52
|
-
import _Reflect$construct from '@babel/runtime-corejs3/core-js-stable/reflect/construct';
|
|
53
|
-
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
|
|
54
|
-
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
55
|
-
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
56
|
-
import _assertThisInitialized from '@babel/runtime-corejs3/helpers/esm/assertThisInitialized';
|
|
57
|
-
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
58
|
-
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
59
|
-
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
60
|
-
import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper';
|
|
61
|
-
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
62
|
-
import { RetryLink } from '@apollo/client/link/retry';
|
|
63
|
-
import _pt from 'prop-types';
|
|
64
|
-
import { useEffect, Children } from 'react';
|
|
65
|
-
import { Route, Switch, Redirect } from 'react-router-dom';
|
|
66
|
-
import invariant from 'tiny-invariant';
|
|
67
|
-
import { useIsAuthorized } from '@commercetools-frontend/permissions';
|
|
68
|
-
import { PageNotFound, PageUnauthorized } from '@commercetools-frontend/application-components';
|
|
69
|
-
import { entryPointUriPathToPermissionKeys } from '@commercetools-frontend/application-config/ssr';
|
|
70
|
-
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
|
|
71
|
-
|
|
72
|
-
// NOTE: This string will be replaced on build time with the package version.
|
|
73
|
-
var version = "21.23.10";
|
|
74
|
-
|
|
75
|
-
var isAddNotificationErrorAction = function isAddNotificationErrorAction(action) {
|
|
76
|
-
var errorAction = action;
|
|
77
|
-
return errorAction.type === ADD_NOTIFICATION && errorAction.payload && (errorAction.payload.kind === NOTIFICATION_KINDS_PAGE['api-error'] || errorAction.payload.kind === NOTIFICATION_KINDS_PAGE['unexpected-error']);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
var isHideAllNotificationsAction = function isHideAllNotificationsAction(action) {
|
|
81
|
-
return action.type === HIDE_ALL_PAGE_NOTIFICATIONS;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
var hideNotificationsMiddleware = function hideNotificationsMiddleware(_ref) {
|
|
85
|
-
var getState = _ref.getState;
|
|
86
|
-
return function (next) {
|
|
87
|
-
return function (action) {
|
|
88
|
-
if (isHideAllNotificationsAction(action) || isAddNotificationErrorAction(action)) {
|
|
89
|
-
var _context;
|
|
90
|
-
|
|
91
|
-
var state = getState();
|
|
92
|
-
|
|
93
|
-
_forEachInstanceProperty(_context = selectPageNotifications(state)).call(_context, function (notification) {
|
|
94
|
-
next(removeNotification(notification.id));
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return next(action);
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/* eslint-disable no-console */
|
|
104
|
-
var isLoggerEnabled = function isLoggerEnabled() {
|
|
105
|
-
if (process.env.DEBUG === 'true') return true;
|
|
106
|
-
if (process.env.NODE_ENV === 'development') return true;
|
|
107
|
-
var queryParams = new _URL(window.location.href);
|
|
108
|
-
if (process.env.NODE_ENV === 'production' && queryParams.searchParams.get('debug') === 'true') return true;
|
|
109
|
-
return false;
|
|
110
|
-
};
|
|
111
|
-
var logger = {
|
|
112
|
-
groupCollapsed: function groupCollapsed() {
|
|
113
|
-
var _console;
|
|
114
|
-
|
|
115
|
-
return isLoggerEnabled() && (_console = console).groupCollapsed.apply(_console, arguments);
|
|
116
|
-
},
|
|
117
|
-
groupEnd: function groupEnd() {
|
|
118
|
-
return isLoggerEnabled() && console.groupEnd();
|
|
119
|
-
},
|
|
120
|
-
info: function info() {
|
|
121
|
-
var _console2;
|
|
122
|
-
|
|
123
|
-
return isLoggerEnabled() && (_console2 = console).info.apply(_console2, arguments);
|
|
124
|
-
},
|
|
125
|
-
log: function log() {
|
|
126
|
-
var _console3;
|
|
127
|
-
|
|
128
|
-
return isLoggerEnabled() && (_console3 = console).log.apply(_console3, arguments);
|
|
129
|
-
},
|
|
130
|
-
error: function error() {
|
|
131
|
-
var _console4;
|
|
132
|
-
|
|
133
|
-
return isLoggerEnabled() && (_console4 = console).error.apply(_console4, arguments);
|
|
134
|
-
},
|
|
135
|
-
warn: function warn() {
|
|
136
|
-
var _console5;
|
|
137
|
-
|
|
138
|
-
return isLoggerEnabled() && (_console5 = console).warn.apply(_console5, arguments);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var loggerMiddleware = createLogger({
|
|
143
|
-
logger: logger,
|
|
144
|
-
collapsed: true,
|
|
145
|
-
colors: {
|
|
146
|
-
title: function title() {
|
|
147
|
-
return '#000000';
|
|
148
|
-
},
|
|
149
|
-
prevState: function prevState() {
|
|
150
|
-
return '#9E9E9E';
|
|
151
|
-
},
|
|
152
|
-
action: function action() {
|
|
153
|
-
return '#03A9F4';
|
|
154
|
-
},
|
|
155
|
-
nextState: function nextState() {
|
|
156
|
-
return '#4CAF50';
|
|
157
|
-
},
|
|
158
|
-
error: function error() {
|
|
159
|
-
return '#F20404';
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
// WARNING: Enabling this option causes huge performance degradation.
|
|
163
|
-
// Only enable if you want detailed debugging.
|
|
164
|
-
diff: false,
|
|
165
|
-
predicate: function predicate(_getState, action) {
|
|
166
|
-
if (!action) return false;
|
|
167
|
-
var type = action.type,
|
|
168
|
-
payload = action.payload;
|
|
169
|
-
if (!type) return false;
|
|
170
|
-
if (_startsWithInstanceProperty(type).call(type, 'SHOW_') || _startsWithInstanceProperty(type).call(type, 'HIDE_') || _startsWithInstanceProperty(type).call(type, 'APOLLO_')) return false;
|
|
171
|
-
|
|
172
|
-
switch (type) {
|
|
173
|
-
case REMOVE_NOTIFICATION:
|
|
174
|
-
return false;
|
|
175
|
-
|
|
176
|
-
case ADD_NOTIFICATION:
|
|
177
|
-
{
|
|
178
|
-
var ignoredKinds = ['api-error', 'unexpected-error'];
|
|
179
|
-
return !_includesInstanceProperty(ignoredKinds).call(ignoredKinds, payload.kind);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
default:
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
189
|
-
var REQUESTS_IN_FLIGHT_LOADER_DOM_ID = 'loader-for-requests-in-flight';
|
|
190
|
-
|
|
191
|
-
var messages = defineMessages({
|
|
192
|
-
labelLoading: {
|
|
193
|
-
// Keep the id for backwards compatibility.
|
|
194
|
-
// TODO: provide a new key?
|
|
195
|
-
id: 'TopNavigation.labelLoading',
|
|
196
|
-
description: 'The text to show next to the loading icon',
|
|
197
|
-
defaultMessage: 'Processing...'
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
function ownKeys$6(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
202
|
-
|
|
203
|
-
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys$6(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys$6(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
204
|
-
|
|
205
|
-
var getPortalContainer = function getPortalContainer() {
|
|
206
|
-
return process.env.NODE_ENV === 'test' ? document.body : document.querySelector("#".concat(REQUESTS_IN_FLIGHT_LOADER_DOM_ID));
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
var RequestsInFlightLoader = function RequestsInFlightLoader() {
|
|
210
|
-
var hasRequestsInFlight = useSelector(function (state) {
|
|
211
|
-
return Boolean(state.requestsInFlight && state.requestsInFlight.length > 0);
|
|
212
|
-
});
|
|
213
|
-
if (!hasRequestsInFlight) return null;
|
|
214
|
-
return /*#__PURE__*/ReactDOM.createPortal(jsx(LoadingSpinner, {
|
|
215
|
-
children: jsx(FormattedMessage, _objectSpread$6({}, messages.labelLoading))
|
|
216
|
-
}), getPortalContainer());
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
RequestsInFlightLoader.displayName = 'RequestsInFlightLoader';
|
|
220
|
-
|
|
221
|
-
var isShowRequestInFlightAction = function isShowRequestInFlightAction(action) {
|
|
222
|
-
return action.type === SHOW_LOADING;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
var isHideRequestInFlightAction = function isHideRequestInFlightAction(action) {
|
|
226
|
-
return action.type === HIDE_LOADING;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
var excludeFirstOccurrence = function excludeFirstOccurrence(list, item) {
|
|
230
|
-
var _context;
|
|
231
|
-
|
|
232
|
-
var index = _indexOfInstanceProperty(list).call(list, item);
|
|
233
|
-
|
|
234
|
-
return _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(_sliceInstanceProperty(list).call(list, 0, index)), _toConsumableArray(_sliceInstanceProperty(list).call(list, index + 1)));
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
var requestsInFlightReducer = (function (requestsInFlight, action) {
|
|
238
|
-
var _context2;
|
|
239
|
-
|
|
240
|
-
if (!requestsInFlight || !action) return [];
|
|
241
|
-
if (isShowRequestInFlightAction(action)) return _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(requestsInFlight), [action.payload]);
|
|
242
|
-
|
|
243
|
-
if (isHideRequestInFlightAction(action)) {
|
|
244
|
-
// may only remove first occurence
|
|
245
|
-
if (!_includesInstanceProperty(requestsInFlight).call(requestsInFlight, action.payload)) {
|
|
246
|
-
reportErrorToSentry(new Error("Tried to hide \"".concat(action.payload, "\", but it was not progressing!")));
|
|
247
|
-
return requestsInFlight;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return excludeFirstOccurrence(requestsInFlight, action.payload);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return requestsInFlight;
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
function selectTeamIdFromLocalStorage() {
|
|
257
|
-
return window.localStorage.getItem(STORAGE_KEYS.ACTIVE_TEAM_ID) || undefined;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
var staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account']; // Attempt to extract the `:projectKey` from the URL.
|
|
261
|
-
// If the value matches one of the values in the list above,
|
|
262
|
-
// return `undefined` as we're not within a project context.
|
|
263
|
-
|
|
264
|
-
function selectProjectKeyFromUrl() {
|
|
265
|
-
var locationPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.pathname;
|
|
266
|
-
var possibleProjectKey = locationPath.split('/')[1];
|
|
267
|
-
return _includesInstanceProperty(staticUrlPathsInPositionOfProjectKey).call(staticUrlPathsInPositionOfProjectKey, possibleProjectKey) ? undefined : possibleProjectKey;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Keep an in-memory reference to the apollo client that would be initialized
|
|
271
|
-
// by the application. This is useful to retrieve on runtime the reference
|
|
272
|
-
// to the apollo client in other static modules.
|
|
273
|
-
var cachedApolloClient;
|
|
274
|
-
|
|
275
|
-
var setCachedApolloClient = function setCachedApolloClient(apolloClient) {
|
|
276
|
-
cachedApolloClient = apolloClient;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
var getCachedApolloClient = function getCachedApolloClient() {
|
|
280
|
-
return cachedApolloClient;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
var FetchUserId = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchUserId" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "user" }, name: { kind: "Name", value: "me" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 46, source: { body: "query FetchUserId {\n user: me {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
284
|
-
function selectUserId() {
|
|
285
|
-
var apolloClient = getCachedApolloClient();
|
|
286
|
-
|
|
287
|
-
if (!apolloClient) {
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
try {
|
|
292
|
-
var queryResult = apolloClient.readQuery({
|
|
293
|
-
query: FetchUserId
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
if (queryResult && queryResult.user) {
|
|
297
|
-
return queryResult.user.id;
|
|
298
|
-
}
|
|
299
|
-
} catch (e) {
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
var VALID_ID_PART_FORMAT = /^[\w-/]+$/;
|
|
307
|
-
|
|
308
|
-
var skipMalformedPart = function skipMalformedPart(part) {
|
|
309
|
-
return part && VALID_ID_PART_FORMAT.test(part);
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
function getCorrelationId() {
|
|
313
|
-
var _context;
|
|
314
|
-
|
|
315
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
316
|
-
userId = _ref.userId;
|
|
317
|
-
|
|
318
|
-
return _filterInstanceProperty(_context = ['mc', selectProjectKeyFromUrl(), userId, v4()]).call(_context, skipMalformedPart).join('/');
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// NOTE: Copied from `@application-shell-connectors`.
|
|
322
|
-
// TODO: Remove this version once the change in the connectors has been released.
|
|
323
|
-
var mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
|
|
324
|
-
var mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
|
|
325
|
-
|
|
326
|
-
var getMcOriginTld = function getMcOriginTld(host) {
|
|
327
|
-
if (host.match(mcPreviewHostnameRegex)) {
|
|
328
|
-
return host.replace(mcPreviewHostnameRegex, '$1');
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return host.replace(mcHostnameRegex, '$3');
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
var getMcApiUrlFromOrigin = function getMcApiUrlFromOrigin(origin) {
|
|
335
|
-
var _context;
|
|
336
|
-
|
|
337
|
-
var url = new _URL(origin);
|
|
338
|
-
var originTld = getMcOriginTld(url.host);
|
|
339
|
-
return _concatInstanceProperty(_context = "".concat(url.protocol, "//mc-api.")).call(_context, originTld);
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
var parseAsBoolean = function parseAsBoolean(value) {
|
|
343
|
-
return value === true || value === 'true';
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
function getMcApiUrl() {
|
|
347
|
-
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.app;
|
|
348
|
-
var origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.origin;
|
|
349
|
-
var isServedByProxy = parseAsBoolean(environment.servedByProxy);
|
|
350
|
-
/**
|
|
351
|
-
* Prefer using the origin URL for the MC API based on the origin value
|
|
352
|
-
* of the browser's `window.location`.
|
|
353
|
-
* This ensures that the application always uses the correct URL associated
|
|
354
|
-
* with that environment, instead of relying on the config value.
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
if (isServedByProxy) {
|
|
358
|
-
return getMcApiUrlFromOrigin(origin);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return environment.mcApiUrl;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
var getSessionToken = function getSessionToken() {
|
|
365
|
-
return window.sessionStorage.getItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
var setActiveSession = function setActiveSession(sessionToken) {
|
|
369
|
-
if (!sessionToken) return;
|
|
370
|
-
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_TOKEN, sessionToken !== null && sessionToken !== void 0 ? sessionToken : '');
|
|
371
|
-
window.localStorage.setItem(STORAGE_KEYS.LOGIN_STRATEGY, LOGIN_STRATEGY_OIDC); // Remove flag for original workflow
|
|
372
|
-
|
|
373
|
-
window.localStorage.removeItem(STORAGE_KEYS.IS_AUTHENTICATED);
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
var clearSession = function clearSession() {
|
|
377
|
-
window.sessionStorage.removeItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
378
|
-
window.sessionStorage.removeItem(STORAGE_KEYS.SESSION_SCOPE);
|
|
379
|
-
window.sessionStorage.removeItem(STORAGE_KEYS.IS_AUTHENTICATED);
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
var getActiveProjectKey = function getActiveProjectKey() {
|
|
383
|
-
return window.localStorage.getItem(STORAGE_KEYS.ACTIVE_PROJECT_KEY);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
var removeActiveProjectKey = function removeActiveProjectKey() {
|
|
387
|
-
window.localStorage.removeItem(STORAGE_KEYS.ACTIVE_PROJECT_KEY);
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
var setActiveProjectKey = function setActiveProjectKey(projectKey) {
|
|
391
|
-
window.localStorage.setItem(STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
var getSessionScope = function getSessionScope() {
|
|
395
|
-
return window.sessionStorage.getItem(STORAGE_KEYS.SESSION_SCOPE);
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
var setSessionScope = function setSessionScope(scope) {
|
|
399
|
-
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, scope);
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
var getSessionState = function getSessionState(stateId) {
|
|
403
|
-
var _context;
|
|
404
|
-
|
|
405
|
-
var sessionStateKey = _concatInstanceProperty(_context = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context, stateId);
|
|
406
|
-
|
|
407
|
-
var unparsedSessionState = window.sessionStorage.getItem(sessionStateKey);
|
|
408
|
-
|
|
409
|
-
if (unparsedSessionState) {
|
|
410
|
-
try {
|
|
411
|
-
var parsedSessionState = JSON.parse(unparsedSessionState);
|
|
412
|
-
window.sessionStorage.removeItem(sessionStateKey);
|
|
413
|
-
return parsedSessionState;
|
|
414
|
-
} catch (error) {
|
|
415
|
-
window.sessionStorage.removeItem(sessionStateKey);
|
|
416
|
-
|
|
417
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
418
|
-
var _context2;
|
|
419
|
-
|
|
420
|
-
// eslint-disable-next-line no-console
|
|
421
|
-
console.warn(_concatInstanceProperty(_context2 = "Cannot parse session state for \"".concat(sessionStateKey, "\".\n")).call(_context2, unparsedSessionState));
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
return null;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
var setSessionState = function setSessionState(stateId, state) {
|
|
430
|
-
var _context3;
|
|
431
|
-
|
|
432
|
-
var sessionStateKey = _concatInstanceProperty(_context3 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context3, stateId);
|
|
433
|
-
|
|
434
|
-
window.sessionStorage.setItem(sessionStateKey, _JSON$stringify(state));
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
function ownKeys$5(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
438
|
-
|
|
439
|
-
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys$5(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys$5(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
440
|
-
|
|
441
|
-
var mergeObjectValues = function mergeObjectValues(object) {
|
|
442
|
-
var _context;
|
|
443
|
-
|
|
444
|
-
return _reduceInstanceProperty(_context = _Object$entries(object)).call(_context, function (acc, _ref) {
|
|
445
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
446
|
-
value = _ref2[1];
|
|
447
|
-
|
|
448
|
-
return _objectSpread$5(_objectSpread$5({}, acc), value);
|
|
449
|
-
}, {});
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
var patchedGetCorrelationId = function patchedGetCorrelationId() {
|
|
453
|
-
return getCorrelationId({
|
|
454
|
-
userId: selectUserId()
|
|
455
|
-
});
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
var getAdditionalHeaders = function getAdditionalHeaders() {
|
|
459
|
-
var _omitEmpty;
|
|
460
|
-
|
|
461
|
-
var sessionToken = getSessionToken();
|
|
462
|
-
return omitEmpty((_omitEmpty = {}, _defineProperty(_omitEmpty, SUPPORTED_HEADERS.AUTHORIZATION, sessionToken ? "Bearer ".concat(sessionToken) : undefined), _defineProperty(_omitEmpty, SUPPORTED_HEADERS.X_APPLICATION_ID, window.app.applicationId), _defineProperty(_omitEmpty, SUPPORTED_HEADERS.X_TEAM_ID, selectTeamIdFromLocalStorage()), _omitEmpty));
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
var sdkMiddleware = createMiddleware({
|
|
466
|
-
getCorrelationId: patchedGetCorrelationId,
|
|
467
|
-
getProjectKey: selectProjectKeyFromUrl,
|
|
468
|
-
getAdditionalHeaders: getAdditionalHeaders
|
|
469
|
-
});
|
|
470
|
-
/**
|
|
471
|
-
* @deprecated: This function should not be used directly anymore.
|
|
472
|
-
*/
|
|
473
|
-
|
|
474
|
-
var applyDefaultMiddlewares = function applyDefaultMiddlewares() {
|
|
475
|
-
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
476
|
-
middlewares[_key] = arguments[_key];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
return applyMiddleware.apply(void 0, _concatInstanceProperty(middlewares).call(middlewares, [thunk, loggerMiddleware]));
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
var createInternalReducer = function createInternalReducer() {
|
|
483
|
-
var injectedReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
484
|
-
var preloadedState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
485
|
-
// not providing preloadedStateReducers to combineReducers will cause an error
|
|
486
|
-
// when preloadedState contains keys other than requestsInFlight and
|
|
487
|
-
// notifications:
|
|
488
|
-
// Unexpected key "new Key" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "requestsInFlight", "notifications". Unexpected keys will be ignored.
|
|
489
|
-
// https://redux.js.org/api/createstore#createstorereducer-preloadedstate-enhancer
|
|
490
|
-
var preloadedStateReducers = mapValues(preloadedState, function (value) {
|
|
491
|
-
return function () {
|
|
492
|
-
return value;
|
|
493
|
-
};
|
|
494
|
-
}); // NOTE: since we don't know in advance which reducers will be injected,
|
|
495
|
-
// we pass an `unknown` type to express this uncertainty and make the compiler happy.
|
|
496
|
-
|
|
497
|
-
return combineReducers(_objectSpread$5(_objectSpread$5({
|
|
498
|
-
requestsInFlight: requestsInFlightReducer,
|
|
499
|
-
notifications: reducer
|
|
500
|
-
}, injectedReducers), preloadedStateReducers));
|
|
501
|
-
}; // We use a factory as it's more practicable for tests
|
|
502
|
-
// The application can import the configured store (the default export)
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
var createReduxStore = function createReduxStore() {
|
|
506
|
-
var preloadedState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
507
|
-
var additionalMiddlewares = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
508
|
-
var store = configureStore({
|
|
509
|
-
preloadedState: preloadedState,
|
|
510
|
-
reducer: createInternalReducer(undefined, preloadedState),
|
|
511
|
-
devTools: {
|
|
512
|
-
actionsDenylist: [SHOW_LOADING, HIDE_LOADING]
|
|
513
|
-
},
|
|
514
|
-
middleware: function middleware$1(getDefaultMiddleware) {
|
|
515
|
-
var _context2;
|
|
516
|
-
|
|
517
|
-
return _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(additionalMiddlewares), [hideNotificationsMiddleware, middleware, sdkMiddleware], _toConsumableArray(getDefaultMiddleware({
|
|
518
|
-
// https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data
|
|
519
|
-
serializableCheck: false,
|
|
520
|
-
// This default check is logging warnings to console for some MC FE tests, probably
|
|
521
|
-
// due to lower resources when running tests on CI.
|
|
522
|
-
// We don't consider this check to be very valuable in this context so we decided
|
|
523
|
-
// to turn it off.
|
|
524
|
-
// https://redux-toolkit.js.org/api/immutabilityMiddleware
|
|
525
|
-
immutableCheck: false
|
|
526
|
-
})), [loggerMiddleware]);
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
var enhancedStore = store; // Enable reducers to be injected on runtime (see `<InjectReducer>`)
|
|
530
|
-
|
|
531
|
-
enhancedStore.injectedReducers = {};
|
|
532
|
-
|
|
533
|
-
enhancedStore.injectReducers = function (_ref3) {
|
|
534
|
-
var id = _ref3.id,
|
|
535
|
-
reducers = _ref3.reducers;
|
|
536
|
-
var hasReducerBeenInjected = _Reflect$has(enhancedStore.injectedReducers, id) && enhancedStore.injectedReducers[id] === reducers;
|
|
537
|
-
|
|
538
|
-
if (!hasReducerBeenInjected) {
|
|
539
|
-
// Keep track of the reducer by id, so we can check if it's been injected aleady
|
|
540
|
-
enhancedStore.injectedReducers[id] = reducers; // ...when we create the new reducer though, we spread the reducers from each namespace
|
|
541
|
-
|
|
542
|
-
enhancedStore.replaceReducer(createInternalReducer(mergeObjectValues(enhancedStore.injectedReducers)));
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
enhancedStore.removeReducers = function (_ref4) {
|
|
547
|
-
var id = _ref4.id;
|
|
548
|
-
delete enhancedStore.injectedReducers[id];
|
|
549
|
-
enhancedStore.replaceReducer(createInternalReducer(mergeObjectValues(enhancedStore.injectedReducers)));
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
return enhancedStore;
|
|
553
|
-
};
|
|
554
|
-
var internalReduxStore = createReduxStore();
|
|
555
|
-
|
|
556
|
-
function ownKeys$4(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
557
|
-
|
|
558
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys$4(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys$4(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
559
|
-
|
|
560
|
-
var getSkipTokenRetry = function getSkipTokenRetry(context) {
|
|
561
|
-
var skipTokenRetry = Boolean(context.skipTokenRetry);
|
|
562
|
-
return skipTokenRetry;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
var forwardTokenRetryHeader = function forwardTokenRetryHeader(headers) {
|
|
566
|
-
return _objectSpread$4(_objectSpread$4({}, headers), {}, _defineProperty({}, SUPPORTED_HEADERS.X_TOKEN_RETRY, 'true'));
|
|
567
|
-
}; // This link retries requests to the CTP API that have been rejected
|
|
568
|
-
// because of an invalid/expired oauth token.
|
|
569
|
-
// To do so, we resend the request with the header "X-Force-Token: true"
|
|
570
|
-
// so that the MC BE can issue a new token.
|
|
571
|
-
// NOTE: the retry is not meant to work for the MC access token.
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
var getDoesGraphQLTargetSupportTokenRetry = function getDoesGraphQLTargetSupportTokenRetry(context) {
|
|
575
|
-
var _context$headers, _context$headers2, _context;
|
|
576
|
-
|
|
577
|
-
var graphQLTarget = ((_context$headers = context.headers) === null || _context$headers === void 0 ? void 0 : _context$headers[SUPPORTED_HEADERS.X_GRAPHQL_TARGET]) || ((_context$headers2 = context.headers) === null || _context$headers2 === void 0 ? void 0 : _context$headers2[SUPPORTED_HEADERS.X_GRAPHQL_TARGET.toLowerCase()]);
|
|
578
|
-
return Boolean(graphQLTarget && _includesInstanceProperty(_context = [GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM, GRAPHQL_TARGETS.ADMINISTRATION_SERVICE, GRAPHQL_TARGETS.SETTINGS_SERVICE, GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND]).call(_context, graphQLTarget));
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
var isHttpError = function isHttpError(error) {
|
|
582
|
-
return error.statusCode !== undefined || error.statusCode !== undefined;
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
var isGraphQLError = function isGraphQLError(error) {
|
|
586
|
-
return _Array$isArray(error) && _someInstanceProperty(error).call(error, function (err) {
|
|
587
|
-
return err.message !== undefined || err.extensions !== undefined;
|
|
588
|
-
});
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
592
|
-
|
|
593
|
-
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
594
|
-
|
|
595
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
596
|
-
// user to the login page resetting the store and showing the proper message
|
|
597
|
-
|
|
598
|
-
var errorLink = onError(function (_ref) {
|
|
599
|
-
var graphQLErrors = _ref.graphQLErrors,
|
|
600
|
-
networkError = _ref.networkError,
|
|
601
|
-
operation = _ref.operation,
|
|
602
|
-
forward = _ref.forward;
|
|
603
|
-
|
|
604
|
-
if (networkError && isHttpError(networkError) && networkError.statusCode === STATUS_CODES.UNAUTHORIZED) {
|
|
605
|
-
history.push("/logout?reason=".concat(LOGOUT_REASONS.UNAUTHORIZED));
|
|
606
|
-
return;
|
|
607
|
-
} // In case of graphql errors, we want to retry unauthenticated requests by
|
|
608
|
-
// forcing our API to fetch a new token, using the `X-Force-Token` header.
|
|
609
|
-
// https://www.apollographql.com/docs/link/links/error/#retrying-failed-requests
|
|
610
|
-
// We need to do this as the `token-retry-link` only works for network errors.
|
|
611
|
-
// https://www.apollographql.com/docs/link/links/retry/
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if (graphQLErrors && isGraphQLError(graphQLErrors)) {
|
|
615
|
-
var context = operation.getContext();
|
|
616
|
-
|
|
617
|
-
var _iterator = _createForOfIteratorHelper(graphQLErrors),
|
|
618
|
-
_step;
|
|
619
|
-
|
|
620
|
-
try {
|
|
621
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
622
|
-
var _err$extensions;
|
|
623
|
-
|
|
624
|
-
var err = _step.value;
|
|
625
|
-
var isNonAuthenticatedViaExtensionCode = (err === null || err === void 0 ? void 0 : (_err$extensions = err.extensions) === null || _err$extensions === void 0 ? void 0 : _err$extensions.code) === 'UNAUTHENTICATED';
|
|
626
|
-
/**
|
|
627
|
-
* NOTE:
|
|
628
|
-
* Not not all GraphQL APIs expose an `extensions` field in
|
|
629
|
-
* each error. For those we have to use the `message`
|
|
630
|
-
* property until they introduced support for the `extensions`
|
|
631
|
-
* field.
|
|
632
|
-
*/
|
|
633
|
-
|
|
634
|
-
var isNonAuthenticatedViaCode = (err === null || err === void 0 ? void 0 : err.message) === 'invalid_token';
|
|
635
|
-
|
|
636
|
-
if ((isNonAuthenticatedViaExtensionCode || isNonAuthenticatedViaCode) && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
637
|
-
operation.setContext(function (_ref2) {
|
|
638
|
-
var headers = _ref2.headers;
|
|
639
|
-
return {
|
|
640
|
-
headers: forwardTokenRetryHeader(headers)
|
|
641
|
-
};
|
|
642
|
-
}); // retry the request, returning the new observable
|
|
643
|
-
|
|
644
|
-
return forward(operation);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
} catch (err) {
|
|
648
|
-
_iterator.e(err);
|
|
649
|
-
} finally {
|
|
650
|
-
_iterator.f();
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
return;
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
658
|
-
|
|
659
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
660
|
-
|
|
661
|
-
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
662
|
-
|
|
663
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys$3(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys$3(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
664
|
-
var defaultUserAgent = createHttpUserAgent({
|
|
665
|
-
name: 'unknown-http-client',
|
|
666
|
-
libraryName: window.app.applicationName
|
|
667
|
-
});
|
|
668
|
-
var defaultForwardToVersion = 'v2';
|
|
669
|
-
var defaultForwardToAudiencePolicy = 'forward-url-full-path';
|
|
670
|
-
|
|
671
|
-
function buildApiUrl(endpoint) {
|
|
672
|
-
var _context;
|
|
673
|
-
|
|
674
|
-
var apiUrl = getMcApiUrl().replace(/\/$/, '');
|
|
675
|
-
return _concatInstanceProperty(_context = "".concat(apiUrl)).call(_context, endpoint);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
var getAppliedForwardToHeaders = function getAppliedForwardToHeaders(forwardToConfig) {
|
|
679
|
-
var _context2, _forwardToConfig$head, _forwardToConfig$vers, _forwardToConfig$audi, _objectSpread3;
|
|
680
|
-
|
|
681
|
-
if (!forwardToConfig) {
|
|
682
|
-
return {};
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
if (!forwardToConfig.uri) {
|
|
686
|
-
throw new Error("Missing required \"uri\" option.");
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
var exchangeTokenClaims = [];
|
|
690
|
-
|
|
691
|
-
if (forwardToConfig.includeUserPermissions) {
|
|
692
|
-
exchangeTokenClaims.push('permissions');
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
return _objectSpread$3(_objectSpread$3({}, _reduceInstanceProperty(_context2 = _Object$entries((_forwardToConfig$head = forwardToConfig.headers) !== null && _forwardToConfig$head !== void 0 ? _forwardToConfig$head : {})).call(_context2, function (customForwardHeaders, _ref) {
|
|
696
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
697
|
-
headerName = _ref2[0],
|
|
698
|
-
headerValue = _ref2[1];
|
|
699
|
-
|
|
700
|
-
return _objectSpread$3(_objectSpread$3({}, customForwardHeaders), {}, _defineProperty({}, "x-forward-header-".concat(headerName), headerValue));
|
|
701
|
-
}, {})), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, SUPPORTED_HEADERS.ACCEPT_VERSION, (_forwardToConfig$vers = forwardToConfig.version) !== null && _forwardToConfig$vers !== void 0 ? _forwardToConfig$vers : defaultForwardToVersion), _defineProperty(_objectSpread3, SUPPORTED_HEADERS.X_FORWARD_TO, forwardToConfig.uri), _defineProperty(_objectSpread3, SUPPORTED_HEADERS.X_FORWARD_TO_AUDIENCE_POLICY, (_forwardToConfig$audi = forwardToConfig.audiencePolicy) !== null && _forwardToConfig$audi !== void 0 ? _forwardToConfig$audi : defaultForwardToAudiencePolicy), _defineProperty(_objectSpread3, SUPPORTED_HEADERS.X_FORWARD_TO_CLAIMS, exchangeTokenClaims.join(' ')), _objectSpread3));
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
function createHttpClientOptions() {
|
|
705
|
-
var _config$projectKey, _objectSpread4;
|
|
706
|
-
|
|
707
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
708
|
-
var sessionToken = getSessionToken();
|
|
709
|
-
var projectKey = (_config$projectKey = config.projectKey) !== null && _config$projectKey !== void 0 ? _config$projectKey : selectProjectKeyFromUrl();
|
|
710
|
-
var userId = selectUserId();
|
|
711
|
-
var userAgent = (config === null || config === void 0 ? void 0 : config.userAgent) || defaultUserAgent;
|
|
712
|
-
return {
|
|
713
|
-
credentials: 'include',
|
|
714
|
-
headers: omitEmpty(_objectSpread$3(_objectSpread$3({}, config.headers), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, SUPPORTED_HEADERS.ACCEPT, 'application/json'), _defineProperty(_objectSpread4, SUPPORTED_HEADERS.AUTHORIZATION, sessionToken ? "Bearer ".concat(sessionToken) : undefined), _defineProperty(_objectSpread4, SUPPORTED_HEADERS.X_APPLICATION_ID, window.app.applicationId), _defineProperty(_objectSpread4, SUPPORTED_HEADERS.X_CORRELATION_ID, getCorrelationId({
|
|
715
|
-
userId: userId
|
|
716
|
-
})), _defineProperty(_objectSpread4, SUPPORTED_HEADERS.X_PROJECT_KEY, projectKey), _defineProperty(_objectSpread4, SUPPORTED_HEADERS.X_USER_AGENT, userAgent), _objectSpread4), getAppliedForwardToHeaders(config.forwardToConfig)))
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
var RenewTokenError = /*#__PURE__*/function (_Error) {
|
|
721
|
-
_inherits(RenewTokenError, _Error);
|
|
722
|
-
|
|
723
|
-
var _super = _createSuper(RenewTokenError);
|
|
724
|
-
|
|
725
|
-
function RenewTokenError(message) {
|
|
726
|
-
var _this;
|
|
727
|
-
|
|
728
|
-
_classCallCheck(this, RenewTokenError);
|
|
729
|
-
|
|
730
|
-
_this = _super.call(this, message);
|
|
731
|
-
|
|
732
|
-
_Object$defineProperty(_assertThisInitialized(_this), 'name', {
|
|
733
|
-
value: 'RenewTokenError'
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
return _this;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
return _createClass(RenewTokenError);
|
|
740
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
741
|
-
|
|
742
|
-
function executeHttpClientRequest(_x) {
|
|
743
|
-
return _executeHttpClientRequest.apply(this, arguments);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function _executeHttpClientRequest() {
|
|
747
|
-
_executeHttpClientRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fetcher) {
|
|
748
|
-
var config,
|
|
749
|
-
sendRequest,
|
|
750
|
-
_sendRequest,
|
|
751
|
-
_args2 = arguments;
|
|
752
|
-
|
|
753
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context4) {
|
|
754
|
-
while (1) {
|
|
755
|
-
switch (_context4.prev = _context4.next) {
|
|
756
|
-
case 0:
|
|
757
|
-
_sendRequest = function _sendRequest3() {
|
|
758
|
-
_sendRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
759
|
-
var _ref3,
|
|
760
|
-
shouldRenewToken,
|
|
761
|
-
requestOptions,
|
|
762
|
-
response,
|
|
763
|
-
refreshedSessionToken,
|
|
764
|
-
_args = arguments;
|
|
765
|
-
|
|
766
|
-
return _regeneratorRuntime.wrap(function _callee$(_context3) {
|
|
767
|
-
while (1) {
|
|
768
|
-
switch (_context3.prev = _context3.next) {
|
|
769
|
-
case 0:
|
|
770
|
-
_ref3 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, shouldRenewToken = _ref3.shouldRenewToken;
|
|
771
|
-
requestOptions = createHttpClientOptions(config);
|
|
772
|
-
_context3.next = 4;
|
|
773
|
-
return fetcher(_objectSpread$3(_objectSpread$3({}, requestOptions), {}, {
|
|
774
|
-
headers: omitEmpty(_objectSpread$3(_objectSpread$3({}, requestOptions.headers), {}, _defineProperty({}, SUPPORTED_HEADERS.X_TOKEN_RETRY, shouldRenewToken)))
|
|
775
|
-
}));
|
|
776
|
-
|
|
777
|
-
case 4:
|
|
778
|
-
response = _context3.sent;
|
|
779
|
-
|
|
780
|
-
if (!(response.statusCode === STATUS_CODES.UNAUTHORIZED)) {
|
|
781
|
-
_context3.next = 7;
|
|
782
|
-
break;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
throw new RenewTokenError("Unauthorized response, attempting retry.");
|
|
786
|
-
|
|
787
|
-
case 7:
|
|
788
|
-
// In case a new session token is returned from the server, save it.
|
|
789
|
-
refreshedSessionToken = response.getHeader('x-refreshed-session-token');
|
|
790
|
-
|
|
791
|
-
if (refreshedSessionToken) {
|
|
792
|
-
setActiveSession(refreshedSessionToken);
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
return _context3.abrupt("return", response.data);
|
|
796
|
-
|
|
797
|
-
case 10:
|
|
798
|
-
case "end":
|
|
799
|
-
return _context3.stop();
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}, _callee);
|
|
803
|
-
}));
|
|
804
|
-
return _sendRequest.apply(this, arguments);
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
sendRequest = function _sendRequest2() {
|
|
808
|
-
return _sendRequest.apply(this, arguments);
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
config = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
812
|
-
return _context4.abrupt("return", sendRequest().catch(function (error) {
|
|
813
|
-
if (error instanceof RenewTokenError) {
|
|
814
|
-
// Retry the request and ask to renew the token.
|
|
815
|
-
return sendRequest({
|
|
816
|
-
shouldRenewToken: true
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
throw error;
|
|
821
|
-
}));
|
|
822
|
-
|
|
823
|
-
case 4:
|
|
824
|
-
case "end":
|
|
825
|
-
return _context4.stop();
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}, _callee2);
|
|
829
|
-
}));
|
|
830
|
-
return _executeHttpClientRequest.apply(this, arguments);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
834
|
-
|
|
835
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context4, _context5; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context4 = ownKeys$2(Object(source), !0)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys$2(Object(source))).call(_context5, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
836
|
-
var userAgent = createHttpUserAgent({
|
|
837
|
-
name: 'apollo-client',
|
|
838
|
-
// version: apolloVersion,
|
|
839
|
-
libraryName: [window.app.applicationName, 'application-shell'].join('/'),
|
|
840
|
-
libraryVersion: version,
|
|
841
|
-
contactUrl: 'https://git.io/fjuyC',
|
|
842
|
-
// points to the appkit repo issues
|
|
843
|
-
contactEmail: 'support@commercetools.com'
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
var isKnownGraphQlTarget = function isKnownGraphQlTarget(target) {
|
|
847
|
-
var _context;
|
|
848
|
-
|
|
849
|
-
return target ? _includesInstanceProperty(_context = _Object$values(GRAPHQL_TARGETS)).call(_context, target) : false;
|
|
850
|
-
};
|
|
851
|
-
|
|
852
|
-
var extractSessionTokenFromResponse = function extractSessionTokenFromResponse(context) {
|
|
853
|
-
var _context$response, _context$response$hea, _context$restResponse;
|
|
854
|
-
|
|
855
|
-
var refreshedSessionToken = (_context$response = context.response) === null || _context$response === void 0 ? void 0 : (_context$response$hea = _context$response.headers) === null || _context$response$hea === void 0 ? void 0 : _context$response$hea.get('x-refreshed-session-token');
|
|
856
|
-
|
|
857
|
-
if (refreshedSessionToken) {
|
|
858
|
-
return refreshedSessionToken !== null && refreshedSessionToken !== void 0 ? refreshedSessionToken : null;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
var restResponseWithRefreshTokenHeader = (_context$restResponse = context.restResponses) === null || _context$restResponse === void 0 ? void 0 : _findInstanceProperty(_context$restResponse).call(_context$restResponse, function (response) {
|
|
862
|
-
var _response$headers;
|
|
863
|
-
|
|
864
|
-
return (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.has('x-refreshed-session-token');
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
if (restResponseWithRefreshTokenHeader) {
|
|
868
|
-
var _restResponseWithRefr;
|
|
869
|
-
|
|
870
|
-
return (_restResponseWithRefr = restResponseWithRefreshTokenHeader.headers.get('x-refreshed-session-token')) !== null && _restResponseWithRefr !== void 0 ? _restResponseWithRefr : null;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
return null;
|
|
874
|
-
};
|
|
875
|
-
/* eslint-disable import/prefer-default-export */
|
|
876
|
-
// Use a middleware to update the request headers with the correct params.
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
var headerLink = new ApolloLink(function (operation, forward) {
|
|
880
|
-
var _context2, _objectSpread2, _context3;
|
|
881
|
-
|
|
882
|
-
var apolloContext = operation.getContext();
|
|
883
|
-
var variables = operation.variables;
|
|
884
|
-
var graphQlTarget = apolloContext.target || variables.target;
|
|
885
|
-
if (!apolloContext.skipGraphQlTargetCheck && !isKnownGraphQlTarget(graphQlTarget)) throw new Error(_concatInstanceProperty(_context2 = "GraphQL target \"".concat(graphQlTarget, "\" is missing (or is not supported) in operation \"")).call(_context2, operation.operationName, "\""));
|
|
886
|
-
/**
|
|
887
|
-
* NOTE:
|
|
888
|
-
* The project key is read from the url in a project related application context.
|
|
889
|
-
* This holds for most applications like `application-categories`, `application-discounts` etc.
|
|
890
|
-
* However, the `application-account` does not run with the project key being part of the url.
|
|
891
|
-
* As a result we allow passing the project key as a variable on the operation allowing
|
|
892
|
-
* it to be the fallback.
|
|
893
|
-
*/
|
|
894
|
-
|
|
895
|
-
var projectKey = apolloContext.projectKey || variables.projectKey || selectProjectKeyFromUrl();
|
|
896
|
-
var teamId = apolloContext.teamId || variables.teamId || selectTeamIdFromLocalStorage();
|
|
897
|
-
var featureFlag = apolloContext.featureFlag || variables.featureFlag;
|
|
898
|
-
operation.setContext(createHttpClientOptions({
|
|
899
|
-
userAgent: userAgent,
|
|
900
|
-
headers: omitEmpty(_objectSpread$2(_objectSpread$2({}, apolloContext.headers), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, SUPPORTED_HEADERS.X_GRAPHQL_TARGET, graphQlTarget), _defineProperty(_objectSpread2, SUPPORTED_HEADERS.X_GRAPHQL_OPERATION_NAME, operation.operationName), _defineProperty(_objectSpread2, SUPPORTED_HEADERS.X_TEAM_ID, teamId), _defineProperty(_objectSpread2, SUPPORTED_HEADERS.X_FEATURE_FLAG, featureFlag), _objectSpread2))),
|
|
901
|
-
forwardToConfig: apolloContext.forwardToConfig,
|
|
902
|
-
projectKey: projectKey
|
|
903
|
-
}));
|
|
904
|
-
return _mapInstanceProperty(_context3 = forward(operation)).call(_context3, function (response) {
|
|
905
|
-
var context = operation.getContext();
|
|
906
|
-
var refreshedSessionToken = extractSessionTokenFromResponse(context);
|
|
907
|
-
|
|
908
|
-
if (refreshedSessionToken) {
|
|
909
|
-
setActiveSession(refreshedSessionToken);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
return response;
|
|
913
|
-
});
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
var tokenRetryLink = new RetryLink({
|
|
917
|
-
attempts: function attempts(count, operation, error) {
|
|
918
|
-
var context = operation.getContext();
|
|
919
|
-
|
|
920
|
-
if ((error === null || error === void 0 ? void 0 : error.statusCode) === STATUS_CODES.UNAUTHORIZED && count === 1 && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
921
|
-
operation.setContext(function (_ref) {
|
|
922
|
-
var headers = _ref.headers;
|
|
923
|
-
return {
|
|
924
|
-
headers: forwardTokenRetryHeader(headers)
|
|
925
|
-
};
|
|
926
|
-
});
|
|
927
|
-
return true;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
return false;
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
|
|
934
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
935
|
-
|
|
936
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context4, _context5; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context4 = ownKeys$1(Object(source), !0)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys$1(Object(source))).call(_context5, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
937
|
-
var httpLink = createHttpLink({
|
|
938
|
-
uri: "".concat(getMcApiUrl(), "/graphql"),
|
|
939
|
-
fetch: fetch
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
var createApolloLink = function createApolloLink() {
|
|
943
|
-
var _context;
|
|
944
|
-
|
|
945
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
946
|
-
return (// The order of links is IMPORTANT!
|
|
947
|
-
// In the request-phase they are executed top to bottom.
|
|
948
|
-
// In the response/phase they are executed bottom to top.
|
|
949
|
-
// The `httpLink` is terminating so it must be last, while `tokenRetryLink` and `errorLink`
|
|
950
|
-
// wrap the links the their right.
|
|
951
|
-
from(_concatInstanceProperty(_context = [headerLink]).call(_context, _toConsumableArray(options.restLink ? [options.restLink] : []), [// Must be before `tokenRetryLink`.
|
|
952
|
-
errorLink], _toConsumableArray(isLoggerEnabled() ? [loggerLink] : []), [// Must be after `errorLink`.
|
|
953
|
-
tokenRetryLink, // Must be last.
|
|
954
|
-
httpLink]))
|
|
955
|
-
);
|
|
956
|
-
}; // This custom merge function allows to merge two arrays of objects.
|
|
957
|
-
// The incoming list is what we need to update to, but we still need
|
|
958
|
-
// to ensure that existing cache elements are not removed but updated.
|
|
959
|
-
// This is usually the case when elements get removed.
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
var mergeArraysObjects = function mergeArraysObjects() {
|
|
963
|
-
var existing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
964
|
-
var incoming = arguments.length > 1 ? arguments[1] : undefined;
|
|
965
|
-
|
|
966
|
-
var _ref = arguments.length > 2 ? arguments[2] : undefined,
|
|
967
|
-
mergeObjects = _ref.mergeObjects;
|
|
968
|
-
|
|
969
|
-
return _reduceInstanceProperty(incoming).call(incoming, function (mergedElements, elem) {
|
|
970
|
-
var _context3;
|
|
971
|
-
|
|
972
|
-
var existingElem = _findInstanceProperty(existing).call(existing, function (el) {
|
|
973
|
-
return el.__ref === elem.__ref;
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
if (existingElem) {
|
|
977
|
-
var updatedElem = mergeObjects(existingElem, elem);
|
|
978
|
-
|
|
979
|
-
if (updatedElem) {
|
|
980
|
-
var _context2;
|
|
981
|
-
|
|
982
|
-
return _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(mergedElements), [updatedElem]);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
return _concatInstanceProperty(_context3 = []).call(_context3, _toConsumableArray(mergedElements), [elem]);
|
|
987
|
-
}, []);
|
|
988
|
-
};
|
|
989
|
-
|
|
990
|
-
var createApolloClient = function createApolloClient() {
|
|
991
|
-
var _options$cache, _customCacheConfig$ty;
|
|
992
|
-
|
|
993
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
994
|
-
var customCacheConfig = (_options$cache = options === null || options === void 0 ? void 0 : options.cache) !== null && _options$cache !== void 0 ? _options$cache : {};
|
|
995
|
-
return new ApolloClient({
|
|
996
|
-
link: createApolloLink(options),
|
|
997
|
-
// https://www.apollographql.com/docs/react/caching/cache-configuration/
|
|
998
|
-
cache: new InMemoryCache(_objectSpread$1(_objectSpread$1({}, customCacheConfig), {}, {
|
|
999
|
-
// https://www.apollographql.com/docs/react/caching/cache-configuration/#generating-unique-identifiers
|
|
1000
|
-
typePolicies: _objectSpread$1({
|
|
1001
|
-
// CTP types with `key` as identifier
|
|
1002
|
-
Project: {
|
|
1003
|
-
keyFields: ['key']
|
|
1004
|
-
},
|
|
1005
|
-
Store: {
|
|
1006
|
-
keyFields: ['key']
|
|
1007
|
-
},
|
|
1008
|
-
// Internal apps menu links representations
|
|
1009
|
-
ApplicationsMenu: {
|
|
1010
|
-
fields: {
|
|
1011
|
-
appBar: {
|
|
1012
|
-
merge: mergeArraysObjects
|
|
1013
|
-
},
|
|
1014
|
-
navBar: {
|
|
1015
|
-
merge: mergeArraysObjects
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}, (_customCacheConfig$ty = customCacheConfig.typePolicies) !== null && _customCacheConfig$ty !== void 0 ? _customCacheConfig$ty : {})
|
|
1020
|
-
}))
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
|
-
/**
|
|
1025
|
-
* NOTE
|
|
1026
|
-
* This module wraps `replace` and `reload` from the window's location.
|
|
1027
|
-
* This mainly helps in tests as we often expect that a reload or
|
|
1028
|
-
* replace on the location happened.
|
|
1029
|
-
* In previous code we could just overwrite the properties by:
|
|
1030
|
-
* `window.location.replace = jest.fn()`
|
|
1031
|
-
* This will fail in never versions of JSDOM (e.g. v16) as these
|
|
1032
|
-
* properties are not writable anymore. JSDOM follows the browser standards
|
|
1033
|
-
* which also state that these should not be writable.
|
|
1034
|
-
* There are different options to solve this:
|
|
1035
|
-
* 1. Extract those functions as a module an use `jest.mock` to mock them under test
|
|
1036
|
-
* 2. Use `Object.defineProperty` to overwrite the property
|
|
1037
|
-
* - The community opinion is that this is not preferred and does
|
|
1038
|
-
* not work in all cases
|
|
1039
|
-
* 3. Delete the property via `delete window.location` to re-create it after
|
|
1040
|
-
* - This is quite repetiive and noisy in tests and can also remote
|
|
1041
|
-
* other properties from under location
|
|
1042
|
-
* Given option 2. and 3. being quite noisy on tests and against working with
|
|
1043
|
-
* the stndards of the browser we will use 1. Here we only utilise the module
|
|
1044
|
-
* mocking system of Jest and no other trickery.
|
|
1045
|
-
* */
|
|
1046
|
-
var replace = function replace(url) {
|
|
1047
|
-
return window.location.replace(url);
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
var reload = function reload() {
|
|
1051
|
-
return window.location.reload();
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
var location = {
|
|
1055
|
-
replace: replace,
|
|
1056
|
-
reload: reload
|
|
1057
|
-
};
|
|
1058
|
-
|
|
1059
|
-
var useIsServedByProxy = function useIsServedByProxy() {
|
|
1060
|
-
var servedByProxy = useApplicationContext(function (context) {
|
|
1061
|
-
return context.environment.servedByProxy;
|
|
1062
|
-
});
|
|
1063
|
-
return servedByProxy;
|
|
1064
|
-
};
|
|
1065
|
-
|
|
1066
|
-
var ForcePageReload = function ForcePageReload() {
|
|
1067
|
-
useEffect(function () {
|
|
1068
|
-
location.reload();
|
|
1069
|
-
}, []);
|
|
1070
|
-
return null;
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
|
-
var RouteCatchAll = function RouteCatchAll() {
|
|
1074
|
-
// NOTE: it's important that the return value is a `Route` component!
|
|
1075
|
-
var servedByProxy = useIsServedByProxy(); // In case the application is served by a proxy server, we assume that
|
|
1076
|
-
// the reverse proxy router handles requests forwarding to the specified
|
|
1077
|
-
// service.
|
|
1078
|
-
// For example, if the current "loaded" app is products and I click
|
|
1079
|
-
// on a link to discounts, the products app does not know about the
|
|
1080
|
-
// discount routes, thus falling back to this "catch all route" component.
|
|
1081
|
-
// At this point we force a page reload, effectively handing the
|
|
1082
|
-
// route control logic to the reverse proxy in our cluster. There,
|
|
1083
|
-
// the router mapping will match the discounts route and it will forward
|
|
1084
|
-
// the request to the discounts app.
|
|
1085
|
-
// If no route matches, the application fallback will handle the request
|
|
1086
|
-
// instead, showing e.g. a 404 page.
|
|
1087
|
-
|
|
1088
|
-
if (servedByProxy) return jsx(Route, {
|
|
1089
|
-
children: jsx(ForcePageReload, {})
|
|
1090
|
-
}); // In case we are developing the app locally, we simply render a 404
|
|
1091
|
-
// page because we most likely don't have other "apps" running at the same
|
|
1092
|
-
// time.
|
|
1093
|
-
|
|
1094
|
-
return jsx(Route, {
|
|
1095
|
-
children: jsx(PageNotFound, {})
|
|
1096
|
-
});
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1100
|
-
|
|
1101
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1102
|
-
|
|
1103
|
-
var ApplicationRouteWithPermissionCheck = function ApplicationRouteWithPermissionCheck(props) {
|
|
1104
|
-
var permissionKeys = entryPointUriPathToPermissionKeys(props.environment.entryPointUriPath); // Require View permission to render the application.
|
|
1105
|
-
|
|
1106
|
-
var canView = useIsAuthorized({
|
|
1107
|
-
demandedPermissions: [permissionKeys.View]
|
|
1108
|
-
});
|
|
1109
|
-
|
|
1110
|
-
if (canView) {
|
|
1111
|
-
return jsx(Fragment, {
|
|
1112
|
-
children: Children.only(props.children)
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
return jsx(PageUnauthorized, {});
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
ApplicationRouteWithPermissionCheck.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
1120
|
-
disableRoutePermissionCheck: _pt.bool,
|
|
1121
|
-
render: _pt.func,
|
|
1122
|
-
children: _pt.node
|
|
1123
|
-
} : {};
|
|
1124
|
-
|
|
1125
|
-
var ApplicationRoute = function ApplicationRoute(props) {
|
|
1126
|
-
if (props.disableRoutePermissionCheck) {
|
|
1127
|
-
return jsx(Fragment, {
|
|
1128
|
-
children: Children.only(props.children)
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
return jsx(ApplicationRouteWithPermissionCheck, _objectSpread({}, props));
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
ApplicationRoute.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
1136
|
-
disableRoutePermissionCheck: _pt.bool,
|
|
1137
|
-
render: _pt.func,
|
|
1138
|
-
children: _pt.node
|
|
1139
|
-
} : {};
|
|
1140
|
-
|
|
1141
|
-
var ApplicationEntryPoint = function ApplicationEntryPoint(props) {
|
|
1142
|
-
// If the `children` prop is used (instead of the `render` prop),
|
|
1143
|
-
// we pre-configure the application entry point routes to avoid
|
|
1144
|
-
// users to do so on their own.
|
|
1145
|
-
if (props.children) {
|
|
1146
|
-
var entryPointUriPath = props.environment.entryPointUriPath;
|
|
1147
|
-
return jsxs(Switch, {
|
|
1148
|
-
children: [// For development, it's useful to redirect to the actual
|
|
1149
|
-
// application routes when you open the browser at http://localhost:3001
|
|
1150
|
-
process.env.NODE_ENV === 'production' ? null : jsx(Redirect, {
|
|
1151
|
-
exact: true,
|
|
1152
|
-
from: "/:projectKey",
|
|
1153
|
-
to: "/:projectKey/".concat(entryPointUriPath)
|
|
1154
|
-
}), jsx(Route, {
|
|
1155
|
-
path: "/:projectKey/".concat(entryPointUriPath),
|
|
1156
|
-
children: jsx(ApplicationRoute, _objectSpread({}, props))
|
|
1157
|
-
}), jsx(RouteCatchAll, {})]
|
|
1158
|
-
});
|
|
1159
|
-
} // We still support the `render` prop, for backwards compatibility
|
|
1160
|
-
// and for having more control in certain cases (mostly to some of our internal apps).
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
if (props.render && typeof props.render === 'function') {
|
|
1164
|
-
return jsx(Fragment, {
|
|
1165
|
-
children: props.render()
|
|
1166
|
-
});
|
|
1167
|
-
} // The `render` prop function is still required (backwards compatibility).
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
!!props.render ? process.env.NODE_ENV !== "production" ? invariant(false, '@commercetools-frontend/application-shell: Missing required function prop "render".') : invariant(false) : void 0;
|
|
1171
|
-
return null;
|
|
1172
|
-
};
|
|
1173
|
-
|
|
1174
|
-
ApplicationEntryPoint.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
1175
|
-
disableRoutePermissionCheck: _pt.bool,
|
|
1176
|
-
render: _pt.func,
|
|
1177
|
-
children: _pt.node
|
|
1178
|
-
} : {};
|
|
1179
|
-
|
|
1180
|
-
export { ApplicationEntryPoint as A, REQUESTS_IN_FLIGHT_LOADER_DOM_ID as R, getActiveProjectKey as a, getSessionScope as b, location as c, getSessionState as d, setActiveSession as e, createApolloClient as f, getMcApiUrl as g, setCachedApolloClient as h, internalReduxStore as i, setSessionScope as j, setSessionState as k, logger as l, clearSession as m, selectProjectKeyFromUrl as n, RequestsInFlightLoader as o, RouteCatchAll as p, applyDefaultMiddlewares as q, removeActiveProjectKey as r, setActiveProjectKey as s, selectUserId as t, useIsServedByProxy as u, version as v, buildApiUrl as w, createHttpClientOptions as x, executeHttpClientRequest as y, createReduxStore as z };
|