@commercetools-frontend/application-shell 22.8.3 → 22.9.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-dbbccce1.esm.js → application-entry-point-3613e4a5.esm.js} +1 -1
- package/dist/{application-entry-point-a5e4db17.cjs.prod.js → application-entry-point-bde45acf.cjs.prod.js} +2 -2
- package/dist/{application-entry-point-52223768.cjs.dev.js → application-entry-point-fd6f9973.cjs.dev.js} +2 -2
- package/dist/commercetools-frontend-application-shell.cjs.dev.js +90 -68
- package/dist/commercetools-frontend-application-shell.cjs.prod.js +90 -68
- package/dist/commercetools-frontend-application-shell.esm.js +43 -53
- package/dist/{custom-view-dev-host-9b43261f.esm.js → custom-view-dev-host-5ce5a507.esm.js} +17 -27
- package/dist/{custom-view-dev-host-a392d222.cjs.dev.js → custom-view-dev-host-621386e0.cjs.dev.js} +18 -28
- package/dist/declarations/src/components/navbar/use-navbar-state-manager.d.ts +1 -1
- package/dist/declarations/src/components/quick-access/types.d.ts +1 -1
- package/dist/declarations/src/components/user-settings-menu/index.d.ts +1 -1
- package/dist/declarations/src/constants.d.ts +7 -41
- package/dist/declarations/src/export-types.d.ts +1 -2
- package/dist/declarations/src/index.d.ts +1 -5
- package/dist/declarations/src/types/generated/settings.d.ts +223 -29
- package/dist/declarations/src/utils/index.d.ts +0 -5
- package/dist/index-37a25e51.cjs.dev.js +232 -0
- package/dist/index-6cd618cc.cjs.prod.js +232 -0
- package/dist/index-89e5711a.esm.js +206 -0
- package/dist/{index-4a75865e.cjs.prod.js → index-beeb5dbb.cjs.prod.js} +64 -195
- package/dist/index-c0b19086.cjs.dev.js +2081 -0
- package/dist/index-e6cf101e.esm.js +2019 -0
- package/dist/{navbar-b29ac568.esm.js → navbar-1d867dcd.esm.js} +50 -50
- package/dist/{navbar-48952f4b.cjs.dev.js → navbar-5d636a16.cjs.dev.js} +56 -56
- package/dist/{navbar-d62e53a4.cjs.prod.js → navbar-78f58680.cjs.prod.js} +46 -51
- package/dist/{oidc-a55e3dd9.cjs.prod.js → oidc-0c6ca06c.cjs.dev.js} +48 -7
- package/dist/{oidc-db881d40.esm.js → oidc-95696f7b.esm.js} +37 -2
- package/dist/{oidc-97f361cb.cjs.dev.js → oidc-b2ac8a92.cjs.prod.js} +48 -7
- package/dist/{oidc-callback-2f5b05ea.cjs.prod.js → oidc-callback-27fd978b.cjs.prod.js} +22 -32
- package/dist/{oidc-callback-1f9ca05f.esm.js → oidc-callback-7e6fcaff.esm.js} +22 -32
- package/dist/{oidc-callback-0a74a7dc.cjs.dev.js → oidc-callback-9d5cdf00.cjs.dev.js} +22 -32
- package/dist/{project-container-c4ebe8aa.cjs.dev.js → project-container-0ef3869c.cjs.dev.js} +26 -36
- package/dist/{project-container-a3deaee5.esm.js → project-container-b189c7a3.esm.js} +22 -32
- package/dist/{project-container-9641544a.cjs.prod.js → project-container-c6fb1e4f.cjs.prod.js} +26 -36
- package/dist/{project-expired-bd8619e1.cjs.prod.js → project-expired-911e2f79.cjs.prod.js} +20 -30
- package/dist/{project-expired-d6299039.esm.js → project-expired-bd4f93bc.esm.js} +20 -30
- package/dist/{project-expired-67bdb8ed.cjs.dev.js → project-expired-e2815596.cjs.dev.js} +20 -30
- package/dist/{project-not-found-7131fe47.esm.js → project-not-found-bfd9a058.esm.js} +20 -30
- package/dist/{project-not-found-6a440b40.cjs.dev.js → project-not-found-c0f09321.cjs.dev.js} +20 -30
- package/dist/{project-not-found-2fd77390.cjs.prod.js → project-not-found-e5255cac.cjs.prod.js} +20 -30
- package/dist/{project-not-initialized-888415dd.cjs.dev.js → project-not-initialized-0ed0f209.cjs.dev.js} +20 -30
- package/dist/{project-not-initialized-91e2d49f.cjs.prod.js → project-not-initialized-2b02f3bb.cjs.prod.js} +20 -30
- package/dist/{project-not-initialized-ac8b0f01.esm.js → project-not-initialized-8d0cab2e.esm.js} +20 -30
- package/dist/{project-suspended-90cd41ac.cjs.dev.js → project-suspended-94956aec.cjs.dev.js} +20 -30
- package/dist/{project-suspended-3bf9e6e2.esm.js → project-suspended-cee209a6.esm.js} +20 -30
- package/dist/{project-suspended-8ea83f97.cjs.prod.js → project-suspended-cfa2eb3b.cjs.prod.js} +20 -30
- package/dist/{quick-access-7859d40c.cjs.dev.js → quick-access-1b73b555.cjs.dev.js} +13 -23
- package/dist/{quick-access-13fcd04a.esm.js → quick-access-232ff40f.esm.js} +13 -23
- package/dist/{quick-access-d5b833d4.cjs.prod.js → quick-access-ce774311.cjs.prod.js} +13 -23
- package/dist/{redirect-to-login-45587473.esm.js → redirect-to-login-9535ddbc.esm.js} +9 -46
- package/dist/{redirect-to-login-9f939764.cjs.dev.js → redirect-to-login-aa538da2.cjs.dev.js} +10 -47
- package/dist/{redirect-to-login-96f9b90c.cjs.prod.js → redirect-to-login-ee9f3801.cjs.prod.js} +10 -47
- package/dist/{redirect-to-logout-3becf8fb.esm.js → redirect-to-logout-3a0798c1.esm.js} +21 -31
- package/dist/{redirect-to-logout-2eb95761.cjs.prod.js → redirect-to-logout-96e94d9d.cjs.prod.js} +21 -31
- package/dist/{redirect-to-logout-b3015931.cjs.dev.js → redirect-to-logout-ccdd9a48.cjs.dev.js} +21 -31
- package/dist/{requests-in-flight-loader-02cdbb97.cjs.prod.js → requests-in-flight-loader-7f4804b4.cjs.prod.js} +22 -32
- package/dist/{requests-in-flight-loader-df478973.esm.js → requests-in-flight-loader-8333ff01.esm.js} +22 -32
- package/dist/{requests-in-flight-loader-b5e014a6.cjs.dev.js → requests-in-flight-loader-b48dcc38.cjs.dev.js} +22 -32
- package/dist/{service-page-project-switcher-6bee2a11.cjs.prod.js → service-page-project-switcher-d656d2f0.cjs.prod.js} +1 -1
- package/dist/{service-page-project-switcher-7021623b.esm.js → service-page-project-switcher-dd1d0479.esm.js} +1 -1
- package/dist/{service-page-project-switcher-1059771d.cjs.dev.js → service-page-project-switcher-ea2d1f5b.cjs.dev.js} +1 -1
- package/dist/{use-applications-menu-d9c5a942.cjs.dev.js → use-applications-menu-10d6d71b.cjs.prod.js} +1 -2
- package/dist/{use-applications-menu-44c909ae.esm.js → use-applications-menu-902e4f5f.esm.js} +1 -2
- package/dist/{use-applications-menu-b3754808.cjs.prod.js → use-applications-menu-c03f484f.cjs.dev.js} +1 -2
- package/dist/{user-settings-menu-007b5fc6.esm.js → user-settings-menu-5841d422.esm.js} +2 -62
- package/dist/{user-settings-menu-40649589.cjs.dev.js → user-settings-menu-59dbf5d2.cjs.dev.js} +3 -63
- package/dist/{user-settings-menu-83aa2470.cjs.prod.js → user-settings-menu-70751be9.cjs.prod.js} +3 -63
- package/dist/{version-tracker-ac87bd0d.esm.js → version-tracker-8e09ba95.esm.js} +44 -16
- package/dist/{version-tracker-b30517eb.cjs.dev.js → version-tracker-b14edb65.cjs.prod.js} +45 -17
- package/dist/{version-tracker-3b334a55.cjs.prod.js → version-tracker-e862fb1a.cjs.dev.js} +45 -17
- package/package.json +18 -21
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.dev.js +1 -2
- package/ssr/dist/commercetools-frontend-application-shell-ssr.cjs.prod.js +1 -2
- package/ssr/dist/commercetools-frontend-application-shell-ssr.esm.js +1 -2
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.dev.js +5 -26
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.cjs.prod.js +5 -26
- package/test-utils/dist/commercetools-frontend-application-shell-test-utils.esm.js +3 -24
- package/dist/configure-apollo-881e73b2.cjs.dev.js +0 -821
- package/dist/configure-apollo-a9f36ac3.cjs.prod.js +0 -815
- package/dist/configure-apollo-dc168d1e.esm.js +0 -765
- package/dist/constants-0b9c2426.esm.js +0 -68
- package/dist/constants-0da1db32.cjs.prod.js +0 -78
- package/dist/constants-bef5a843.cjs.dev.js +0 -78
- package/dist/declarations/src/apollo-links/error-link.d.ts +0 -2
- package/dist/declarations/src/apollo-links/header-link.d.ts +0 -3
- package/dist/declarations/src/apollo-links/index.d.ts +0 -4
- package/dist/declarations/src/apollo-links/token-retry-link.d.ts +0 -3
- package/dist/declarations/src/apollo-links/utils.d.ts +0 -10
- package/dist/declarations/src/components/custom-view-loader/custom-view-loader.d.ts +0 -8
- package/dist/declarations/src/components/custom-view-loader/index.d.ts +0 -1
- package/dist/declarations/src/components/custom-view-loader/messages.d.ts +0 -7
- package/dist/declarations/src/configure-apollo.d.ts +0 -7
- package/dist/declarations/src/hooks/apollo-hooks/apollo-hooks.d.ts +0 -13
- package/dist/declarations/src/hooks/apollo-hooks/index.d.ts +0 -1
- package/dist/declarations/src/utils/apollo-client-runtime-cache.d.ts +0 -4
- package/dist/declarations/src/utils/apollo-context.d.ts +0 -15
- package/dist/declarations/src/utils/get-correlation-id/get-correlation-id.d.ts +0 -3
- package/dist/declarations/src/utils/get-correlation-id/index.d.ts +0 -1
- package/dist/declarations/src/utils/http-client.d.ts +0 -31
- package/dist/declarations/src/utils/logger.d.ts +0 -10
- package/dist/declarations/src/utils/oidc-storage.d.ts +0 -11
- package/dist/declarations/src/utils/select-project-key-from-url/index.d.ts +0 -1
- package/dist/declarations/src/utils/select-project-key-from-url/select-project-key-from-url.d.ts +0 -1
- package/dist/declarations/src/utils/select-team-id-from-storage/index.d.ts +0 -1
- package/dist/declarations/src/utils/select-team-id-from-storage/select-team-id-from-storage.d.ts +0 -1
- package/dist/declarations/src/utils/select-user-id/index.d.ts +0 -1
- package/dist/declarations/src/utils/select-user-id/select-user-id.d.ts +0 -1
- package/dist/index-3081e563.esm.js +0 -2159
- package/dist/index-85533f79.cjs.dev.js +0 -2225
|
@@ -1,815 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
4
|
-
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
5
|
-
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
|
-
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
7
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
|
-
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
9
|
-
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
10
|
-
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
11
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
13
|
-
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
14
|
-
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
15
|
-
var _Reflect$has = require('@babel/runtime-corejs3/core-js-stable/reflect/has');
|
|
16
|
-
var toolkit = require('@reduxjs/toolkit');
|
|
17
|
-
var mapValues = require('lodash/mapValues');
|
|
18
|
-
var omitEmpty = require('omit-empty-es');
|
|
19
|
-
var thunk = require('redux-thunk');
|
|
20
|
-
var constants = require('@commercetools-frontend/constants');
|
|
21
|
-
var notifications = require('@commercetools-frontend/notifications');
|
|
22
|
-
var sdk = require('@commercetools-frontend/sdk');
|
|
23
|
-
var react = require('react');
|
|
24
|
-
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
25
|
-
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
26
|
-
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
27
|
-
var sentry = require('@commercetools-frontend/sentry');
|
|
28
|
-
var constants$1 = require('./constants-0da1db32.cjs.prod.js');
|
|
29
|
-
var reactNotifications = require('@commercetools-frontend/react-notifications');
|
|
30
|
-
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
31
|
-
var reduxLogger = require('redux-logger');
|
|
32
|
-
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
33
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
34
|
-
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
35
|
-
var client = require('@apollo/client');
|
|
36
|
-
var loggerLink = require('apollo-link-logger');
|
|
37
|
-
var error = require('@apollo/client/link/error');
|
|
38
|
-
var history = require('@commercetools-frontend/browser-history');
|
|
39
|
-
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
40
|
-
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
41
|
-
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
42
|
-
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
43
|
-
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
44
|
-
var uuid = require('uuid');
|
|
45
|
-
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
46
|
-
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
47
|
-
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
48
|
-
var _assertThisInitialized = require('@babel/runtime-corejs3/helpers/assertThisInitialized');
|
|
49
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
50
|
-
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
51
|
-
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
52
|
-
var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
|
|
53
|
-
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
54
|
-
var retry = require('@apollo/client/link/retry');
|
|
55
|
-
|
|
56
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
57
|
-
|
|
58
|
-
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
59
|
-
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
60
|
-
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
61
|
-
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
62
|
-
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
63
|
-
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
64
|
-
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
65
|
-
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
66
|
-
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
67
|
-
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
68
|
-
var _Reflect$has__default = /*#__PURE__*/_interopDefault(_Reflect$has);
|
|
69
|
-
var mapValues__default = /*#__PURE__*/_interopDefault(mapValues);
|
|
70
|
-
var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
|
|
71
|
-
var thunk__default = /*#__PURE__*/_interopDefault(thunk);
|
|
72
|
-
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
73
|
-
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
74
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
75
|
-
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
76
|
-
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
77
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
78
|
-
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
79
|
-
var loggerLink__default = /*#__PURE__*/_interopDefault(loggerLink);
|
|
80
|
-
var history__default = /*#__PURE__*/_interopDefault(history);
|
|
81
|
-
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
82
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
83
|
-
var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
|
|
84
|
-
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
85
|
-
var createHttpUserAgent__default = /*#__PURE__*/_interopDefault(createHttpUserAgent);
|
|
86
|
-
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
87
|
-
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
88
|
-
|
|
89
|
-
// NOTE: This string will be replaced on build time with the package version.
|
|
90
|
-
var applicationShellVersion = "22.8.3";
|
|
91
|
-
|
|
92
|
-
const isShowRequestInFlightAction = action => action.type === constants.SHOW_LOADING;
|
|
93
|
-
const isHideRequestInFlightAction = action => action.type === constants.HIDE_LOADING;
|
|
94
|
-
const excludeFirstOccurrence = (list, item) => {
|
|
95
|
-
const index = _indexOfInstanceProperty__default["default"](list).call(list, item);
|
|
96
|
-
return [..._sliceInstanceProperty__default["default"](list).call(list, 0, index), ..._sliceInstanceProperty__default["default"](list).call(list, index + 1)];
|
|
97
|
-
};
|
|
98
|
-
var requestsInFlightReducer = ((requestsInFlight, action) => {
|
|
99
|
-
if (!requestsInFlight || !action) return [];
|
|
100
|
-
if (isShowRequestInFlightAction(action)) return [...requestsInFlight, action.payload];
|
|
101
|
-
if (isHideRequestInFlightAction(action)) {
|
|
102
|
-
// may only remove first occurence
|
|
103
|
-
if (!_includesInstanceProperty__default["default"](requestsInFlight).call(requestsInFlight, action.payload)) {
|
|
104
|
-
sentry.reportErrorToSentry(new Error("Tried to hide \"".concat(action.payload, "\", but it was not progressing!")));
|
|
105
|
-
return requestsInFlight;
|
|
106
|
-
}
|
|
107
|
-
return excludeFirstOccurrence(requestsInFlight, action.payload);
|
|
108
|
-
}
|
|
109
|
-
return requestsInFlight;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const isAddNotificationErrorAction = action => {
|
|
113
|
-
const errorAction = action;
|
|
114
|
-
return errorAction.type === notifications.ADD_NOTIFICATION && errorAction.payload && (errorAction.payload.kind === constants.NOTIFICATION_KINDS_PAGE['api-error'] || errorAction.payload.kind === constants.NOTIFICATION_KINDS_PAGE['unexpected-error']);
|
|
115
|
-
};
|
|
116
|
-
const isHideAllNotificationsAction = action => action.type === constants.HIDE_ALL_PAGE_NOTIFICATIONS;
|
|
117
|
-
const hideNotificationsMiddleware = _ref => {
|
|
118
|
-
let getState = _ref.getState;
|
|
119
|
-
return next => action => {
|
|
120
|
-
if (isHideAllNotificationsAction(action) || isAddNotificationErrorAction(action)) {
|
|
121
|
-
var _context;
|
|
122
|
-
const state = getState();
|
|
123
|
-
_forEachInstanceProperty__default["default"](_context = reactNotifications.selectPageNotifications(state)).call(_context, notification => {
|
|
124
|
-
next(notifications.removeNotification(notification.id));
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return next(action);
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
/* eslint-disable no-console */
|
|
132
|
-
|
|
133
|
-
const isLoggerEnabled = () => {
|
|
134
|
-
if (process.env.DEBUG === 'true') return true;
|
|
135
|
-
const queryParams = new _URL__default["default"](window.location.href);
|
|
136
|
-
if (queryParams.searchParams.get('debug') === 'true') return true;
|
|
137
|
-
return false;
|
|
138
|
-
};
|
|
139
|
-
const logger = {
|
|
140
|
-
groupCollapsed: function () {
|
|
141
|
-
return isLoggerEnabled() && console.groupCollapsed(...arguments);
|
|
142
|
-
},
|
|
143
|
-
groupEnd: () => isLoggerEnabled() && console.groupEnd(),
|
|
144
|
-
info: function () {
|
|
145
|
-
return isLoggerEnabled() && console.info(...arguments);
|
|
146
|
-
},
|
|
147
|
-
log: function () {
|
|
148
|
-
return isLoggerEnabled() && console.log(...arguments);
|
|
149
|
-
},
|
|
150
|
-
error: function () {
|
|
151
|
-
return isLoggerEnabled() && console.error(...arguments);
|
|
152
|
-
},
|
|
153
|
-
warn: function () {
|
|
154
|
-
return isLoggerEnabled() && console.warn(...arguments);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const loggerMiddleware = reduxLogger.createLogger({
|
|
159
|
-
logger,
|
|
160
|
-
collapsed: true,
|
|
161
|
-
colors: {
|
|
162
|
-
title: () => '#000000',
|
|
163
|
-
prevState: () => '#9E9E9E',
|
|
164
|
-
action: () => '#03A9F4',
|
|
165
|
-
nextState: () => '#4CAF50',
|
|
166
|
-
error: () => '#F20404'
|
|
167
|
-
},
|
|
168
|
-
// WARNING: Enabling this option causes huge performance degradation.
|
|
169
|
-
// Only enable if you want detailed debugging.
|
|
170
|
-
diff: false,
|
|
171
|
-
predicate: (_getState, action) => {
|
|
172
|
-
if (!action) return false;
|
|
173
|
-
const type = action.type,
|
|
174
|
-
payload = action.payload;
|
|
175
|
-
if (!type) return false;
|
|
176
|
-
if (_startsWithInstanceProperty__default["default"](type).call(type, 'SHOW_') || _startsWithInstanceProperty__default["default"](type).call(type, 'HIDE_') || _startsWithInstanceProperty__default["default"](type).call(type, 'APOLLO_')) return false;
|
|
177
|
-
switch (type) {
|
|
178
|
-
case notifications.REMOVE_NOTIFICATION:
|
|
179
|
-
return false;
|
|
180
|
-
case notifications.ADD_NOTIFICATION:
|
|
181
|
-
{
|
|
182
|
-
const ignoredKinds = ['api-error', 'unexpected-error'];
|
|
183
|
-
return !_includesInstanceProperty__default["default"](ignoredKinds).call(ignoredKinds, payload.kind);
|
|
184
|
-
}
|
|
185
|
-
default:
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// Attempt to load the `teamId` from sessionStorage
|
|
192
|
-
function selectTeamIdFromStorage() {
|
|
193
|
-
var _window$app$__DEVELOP;
|
|
194
|
-
return window.sessionStorage.getItem(constants$1.STORAGE_KEYS.ACTIVE_TEAM_ID) || ((_window$app$__DEVELOP = window.app.__DEVELOPMENT__) === null || _window$app$__DEVELOP === void 0 || (_window$app$__DEVELOP = _window$app$__DEVELOP.oidc) === null || _window$app$__DEVELOP === void 0 ? void 0 : _window$app$__DEVELOP.teamId);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account'];
|
|
198
|
-
|
|
199
|
-
// Attempt to extract the `:projectKey` from the URL.
|
|
200
|
-
// If the value matches one of the values in the list above,
|
|
201
|
-
// return `undefined` as we're not within a project context.
|
|
202
|
-
function selectProjectKeyFromUrl() {
|
|
203
|
-
let locationPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.pathname;
|
|
204
|
-
let possibleProjectKey = '';
|
|
205
|
-
const pathParts = locationPath.split('/');
|
|
206
|
-
if (pathParts[1] === 'custom-views') {
|
|
207
|
-
// Custom Views paths: /custom-views/:customViewId/projects/:projectKey
|
|
208
|
-
possibleProjectKey = pathParts[4];
|
|
209
|
-
} else {
|
|
210
|
-
// Application paths: /:projectKey/:applicationId
|
|
211
|
-
possibleProjectKey = pathParts[1];
|
|
212
|
-
}
|
|
213
|
-
return _includesInstanceProperty__default["default"](staticUrlPathsInPositionOfProjectKey).call(staticUrlPathsInPositionOfProjectKey, possibleProjectKey) ? undefined : possibleProjectKey;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Keep an in-memory reference to the apollo client that would be initialized
|
|
217
|
-
// by the application. This is useful to retrieve on runtime the reference
|
|
218
|
-
// to the apollo client in other static modules.
|
|
219
|
-
let cachedApolloClient;
|
|
220
|
-
const setCachedApolloClient = apolloClient => {
|
|
221
|
-
cachedApolloClient = apolloClient;
|
|
222
|
-
};
|
|
223
|
-
const getCachedApolloClient = () => cachedApolloClient;
|
|
224
|
-
|
|
225
|
-
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 } } } };
|
|
226
|
-
function selectUserId() {
|
|
227
|
-
const apolloClient = getCachedApolloClient();
|
|
228
|
-
if (!apolloClient) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
try {
|
|
232
|
-
const queryResult = apolloClient.readQuery({
|
|
233
|
-
query: FetchUserId
|
|
234
|
-
});
|
|
235
|
-
if (queryResult && queryResult.user) {
|
|
236
|
-
return queryResult.user.id;
|
|
237
|
-
}
|
|
238
|
-
} catch (e) {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const VALID_ID_PART_FORMAT = /^[\w-/]+$/;
|
|
245
|
-
const skipMalformedPart = part => part && VALID_ID_PART_FORMAT.test(part);
|
|
246
|
-
function getCorrelationId() {
|
|
247
|
-
var _context;
|
|
248
|
-
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
249
|
-
userId = _ref.userId;
|
|
250
|
-
return _filterInstanceProperty__default["default"](_context = ['mc', selectProjectKeyFromUrl(), userId, uuid.v4()]).call(_context, skipMalformedPart).join('/');
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// NOTE: Copied from `@application-shell-connectors`.
|
|
254
|
-
// TODO: Remove this version once the change in the connectors has been released.
|
|
255
|
-
|
|
256
|
-
const mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
|
|
257
|
-
const mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
|
|
258
|
-
const getMcOriginTld = host => {
|
|
259
|
-
if (host.match(mcPreviewHostnameRegex)) {
|
|
260
|
-
return host.replace(mcPreviewHostnameRegex, '$1');
|
|
261
|
-
}
|
|
262
|
-
return host.replace(mcHostnameRegex, '$3');
|
|
263
|
-
};
|
|
264
|
-
const getMcApiUrlFromOrigin = origin => {
|
|
265
|
-
var _context;
|
|
266
|
-
const url = new _URL__default["default"](origin);
|
|
267
|
-
const originTld = getMcOriginTld(url.host);
|
|
268
|
-
return _concatInstanceProperty__default["default"](_context = "".concat(url.protocol, "//mc-api.")).call(_context, originTld);
|
|
269
|
-
};
|
|
270
|
-
const parseAsBoolean = value => value === true || value === 'true';
|
|
271
|
-
function getMcApiUrl() {
|
|
272
|
-
let environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.app;
|
|
273
|
-
let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.origin;
|
|
274
|
-
const isServedByProxy = parseAsBoolean(environment.servedByProxy);
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Prefer using the origin URL for the MC API based on the origin value
|
|
278
|
-
* of the browser's `window.location`.
|
|
279
|
-
* This ensures that the application always uses the correct URL associated
|
|
280
|
-
* with that environment, instead of relying on the config value.
|
|
281
|
-
*/
|
|
282
|
-
if (isServedByProxy) {
|
|
283
|
-
return getMcApiUrlFromOrigin(origin);
|
|
284
|
-
}
|
|
285
|
-
return environment.mcApiUrl;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const getSessionToken = () => window.sessionStorage.getItem(constants$1.STORAGE_KEYS.SESSION_TOKEN);
|
|
289
|
-
const setActiveSession = sessionToken => {
|
|
290
|
-
if (!sessionToken) return;
|
|
291
|
-
window.sessionStorage.setItem(constants$1.STORAGE_KEYS.SESSION_TOKEN, sessionToken !== null && sessionToken !== void 0 ? sessionToken : '');
|
|
292
|
-
window.localStorage.setItem(constants$1.STORAGE_KEYS.LOGIN_STRATEGY, constants$1.LOGIN_STRATEGY_OIDC);
|
|
293
|
-
// Remove flag for original workflow
|
|
294
|
-
window.localStorage.removeItem(constants$1.STORAGE_KEYS.IS_AUTHENTICATED);
|
|
295
|
-
};
|
|
296
|
-
const clearSession = () => {
|
|
297
|
-
window.sessionStorage.removeItem(constants$1.STORAGE_KEYS.SESSION_TOKEN);
|
|
298
|
-
window.sessionStorage.removeItem(constants$1.STORAGE_KEYS.SESSION_SCOPE);
|
|
299
|
-
window.sessionStorage.removeItem(constants$1.STORAGE_KEYS.IS_AUTHENTICATED);
|
|
300
|
-
};
|
|
301
|
-
const getActiveProjectKey = () => window.localStorage.getItem(constants$1.STORAGE_KEYS.ACTIVE_PROJECT_KEY);
|
|
302
|
-
const removeActiveProjectKey = () => {
|
|
303
|
-
window.localStorage.removeItem(constants$1.STORAGE_KEYS.ACTIVE_PROJECT_KEY);
|
|
304
|
-
};
|
|
305
|
-
const setActiveProjectKey = projectKey => {
|
|
306
|
-
window.localStorage.setItem(constants$1.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
|
|
307
|
-
};
|
|
308
|
-
const getSessionScope = () => window.sessionStorage.getItem(constants$1.STORAGE_KEYS.SESSION_SCOPE);
|
|
309
|
-
const setSessionScope = scope => {
|
|
310
|
-
window.sessionStorage.setItem(constants$1.STORAGE_KEYS.SESSION_SCOPE, scope);
|
|
311
|
-
};
|
|
312
|
-
const getSessionState = stateId => {
|
|
313
|
-
var _context;
|
|
314
|
-
const sessionStateKey = _concatInstanceProperty__default["default"](_context = "".concat(constants$1.STORAGE_KEYS.NONCE, "_")).call(_context, stateId);
|
|
315
|
-
const unparsedSessionState = window.sessionStorage.getItem(sessionStateKey);
|
|
316
|
-
if (unparsedSessionState) {
|
|
317
|
-
try {
|
|
318
|
-
const parsedSessionState = JSON.parse(unparsedSessionState);
|
|
319
|
-
window.sessionStorage.removeItem(sessionStateKey);
|
|
320
|
-
return parsedSessionState;
|
|
321
|
-
} catch (error) {
|
|
322
|
-
window.sessionStorage.removeItem(sessionStateKey);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return null;
|
|
326
|
-
};
|
|
327
|
-
const setSessionState = (stateId, state) => {
|
|
328
|
-
var _context3;
|
|
329
|
-
const sessionStateKey = _concatInstanceProperty__default["default"](_context3 = "".concat(constants$1.STORAGE_KEYS.NONCE, "_")).call(_context3, stateId);
|
|
330
|
-
window.sessionStorage.setItem(sessionStateKey, _JSON$stringify__default["default"](state));
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
334
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$4(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
335
|
-
const mergeObjectValues = object => {
|
|
336
|
-
var _context;
|
|
337
|
-
return _reduceInstanceProperty__default["default"](_context = _Object$entries__default["default"](object)).call(_context, (acc, _ref) => {
|
|
338
|
-
let _ref2 = _slicedToArray(_ref, 2),
|
|
339
|
-
value = _ref2[1];
|
|
340
|
-
return _objectSpread$4(_objectSpread$4({}, acc), value);
|
|
341
|
-
}, {});
|
|
342
|
-
};
|
|
343
|
-
const patchedGetCorrelationId = () => getCorrelationId({
|
|
344
|
-
userId: selectUserId()
|
|
345
|
-
});
|
|
346
|
-
const getAdditionalHeaders = () => {
|
|
347
|
-
const sessionToken = getSessionToken();
|
|
348
|
-
return omitEmpty__default["default"]({
|
|
349
|
-
[constants$1.SUPPORTED_HEADERS.AUTHORIZATION]: sessionToken ? "Bearer ".concat(sessionToken) : undefined,
|
|
350
|
-
[constants$1.SUPPORTED_HEADERS.X_APPLICATION_ID]: window.app.applicationIdentifier,
|
|
351
|
-
[constants$1.SUPPORTED_HEADERS.X_CUSTOM_VIEW_ID]: window.app.customViewId,
|
|
352
|
-
[constants$1.SUPPORTED_HEADERS.X_TEAM_ID]: selectTeamIdFromStorage()
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
const sdkMiddleware = sdk.createMiddleware({
|
|
356
|
-
getCorrelationId: patchedGetCorrelationId,
|
|
357
|
-
getProjectKey: selectProjectKeyFromUrl,
|
|
358
|
-
getAdditionalHeaders
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* @deprecated: This function should not be used directly anymore.
|
|
363
|
-
*/
|
|
364
|
-
const applyDefaultMiddlewares = function () {
|
|
365
|
-
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
366
|
-
middlewares[_key] = arguments[_key];
|
|
367
|
-
}
|
|
368
|
-
return toolkit.applyMiddleware(...middlewares, thunk__default["default"], loggerMiddleware);
|
|
369
|
-
};
|
|
370
|
-
const createInternalReducer = function () {
|
|
371
|
-
let injectedReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
372
|
-
let preloadedState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
373
|
-
// not providing preloadedStateReducers to combineReducers will cause an error
|
|
374
|
-
// when preloadedState contains keys other than requestsInFlight and
|
|
375
|
-
// notifications:
|
|
376
|
-
// 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.
|
|
377
|
-
// https://redux.js.org/api/createstore#createstorereducer-preloadedstate-enhancer
|
|
378
|
-
const preloadedStateReducers = mapValues__default["default"](preloadedState, value => () => value);
|
|
379
|
-
|
|
380
|
-
// NOTE: since we don't know in advance which reducers will be injected,
|
|
381
|
-
// we pass an `unknown` type to express this uncertainty and make the compiler happy.
|
|
382
|
-
return toolkit.combineReducers(_objectSpread$4(_objectSpread$4({
|
|
383
|
-
requestsInFlight: requestsInFlightReducer,
|
|
384
|
-
notifications: notifications.reducer
|
|
385
|
-
}, injectedReducers), preloadedStateReducers));
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
// We use a factory as it's more practicable for tests
|
|
389
|
-
// The application can import the configured store (the default export)
|
|
390
|
-
const createReduxStore = function () {
|
|
391
|
-
let preloadedState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
392
|
-
let additionalMiddlewares = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
393
|
-
const store = toolkit.configureStore({
|
|
394
|
-
preloadedState,
|
|
395
|
-
reducer: createInternalReducer(undefined, preloadedState),
|
|
396
|
-
devTools: {
|
|
397
|
-
actionsDenylist: [constants.SHOW_LOADING, constants.HIDE_LOADING]
|
|
398
|
-
},
|
|
399
|
-
middleware: getDefaultMiddleware => [...additionalMiddlewares, hideNotificationsMiddleware, notifications.middleware, sdkMiddleware, ...getDefaultMiddleware({
|
|
400
|
-
// https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data
|
|
401
|
-
serializableCheck: false,
|
|
402
|
-
// This default check is logging warnings to console for some MC FE tests, probably
|
|
403
|
-
// due to lower resources when running tests on CI.
|
|
404
|
-
// We don't consider this check to be very valuable in this context so we decided
|
|
405
|
-
// to turn it off.
|
|
406
|
-
// https://redux-toolkit.js.org/api/immutabilityMiddleware
|
|
407
|
-
immutableCheck: false
|
|
408
|
-
}), loggerMiddleware]
|
|
409
|
-
});
|
|
410
|
-
const enhancedStore = store;
|
|
411
|
-
|
|
412
|
-
// Enable reducers to be injected on runtime (see `<InjectReducer>`)
|
|
413
|
-
enhancedStore.injectedReducers = {};
|
|
414
|
-
enhancedStore.injectReducers = _ref3 => {
|
|
415
|
-
let id = _ref3.id,
|
|
416
|
-
reducers = _ref3.reducers;
|
|
417
|
-
const hasReducerBeenInjected = _Reflect$has__default["default"](enhancedStore.injectedReducers, id) && enhancedStore.injectedReducers[id] === reducers;
|
|
418
|
-
if (!hasReducerBeenInjected) {
|
|
419
|
-
// Keep track of the reducer by id, so we can check if it's been injected aleady
|
|
420
|
-
enhancedStore.injectedReducers[id] = reducers;
|
|
421
|
-
// ...when we create the new reducer though, we spread the reducers from each namespace
|
|
422
|
-
enhancedStore.replaceReducer(createInternalReducer(mergeObjectValues(enhancedStore.injectedReducers)));
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
enhancedStore.removeReducers = _ref4 => {
|
|
426
|
-
let id = _ref4.id;
|
|
427
|
-
delete enhancedStore.injectedReducers[id];
|
|
428
|
-
enhancedStore.replaceReducer(createInternalReducer(mergeObjectValues(enhancedStore.injectedReducers)));
|
|
429
|
-
};
|
|
430
|
-
return enhancedStore;
|
|
431
|
-
};
|
|
432
|
-
var internalReduxStore = createReduxStore();
|
|
433
|
-
|
|
434
|
-
const RouteCatchAll = /*#__PURE__*/react.lazy(() => Promise.resolve().then(function () { return require('./route-catch-all-373c69c6.cjs.prod.js' /* webpackChunkName: "route-catch-all" */); }));
|
|
435
|
-
|
|
436
|
-
function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
437
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$3(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
438
|
-
const getSkipTokenRetry = context => {
|
|
439
|
-
const skipTokenRetry = Boolean(context.skipTokenRetry);
|
|
440
|
-
return skipTokenRetry;
|
|
441
|
-
};
|
|
442
|
-
const forwardTokenRetryHeader = headers => _objectSpread$3(_objectSpread$3({}, headers), {}, {
|
|
443
|
-
[constants$1.SUPPORTED_HEADERS.X_TOKEN_RETRY]: 'true'
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
// This link retries requests to the CTP API that have been rejected
|
|
447
|
-
// because of an invalid/expired oauth token.
|
|
448
|
-
// To do so, we resend the request with the header "X-Force-Token: true"
|
|
449
|
-
// so that the MC BE can issue a new token.
|
|
450
|
-
// NOTE: the retry is not meant to work for the MC access token.
|
|
451
|
-
const getDoesGraphQLTargetSupportTokenRetry = context => {
|
|
452
|
-
var _context$headers, _context$headers2, _context;
|
|
453
|
-
const graphQLTarget = ((_context$headers = context.headers) === null || _context$headers === void 0 ? void 0 : _context$headers[constants$1.SUPPORTED_HEADERS.X_GRAPHQL_TARGET]) || ((_context$headers2 = context.headers) === null || _context$headers2 === void 0 ? void 0 : _context$headers2[constants$1.SUPPORTED_HEADERS.X_GRAPHQL_TARGET.toLowerCase()]);
|
|
454
|
-
return Boolean(graphQLTarget && _includesInstanceProperty__default["default"](_context = [constants.GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM, constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE, constants.GRAPHQL_TARGETS.SETTINGS_SERVICE, constants.GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND]).call(_context, graphQLTarget));
|
|
455
|
-
};
|
|
456
|
-
const isHttpError = error => error.statusCode !== undefined || error.statusCode !== undefined;
|
|
457
|
-
const isGraphQLError = error => _Array$isArray__default["default"](error) && _someInstanceProperty__default["default"](error).call(error, err => err.message !== undefined || err.extensions !== undefined);
|
|
458
|
-
|
|
459
|
-
// Checks response from GraphQL in order to scan 401 errors and redirect the
|
|
460
|
-
// user to the login page resetting the store and showing the proper message
|
|
461
|
-
const errorLink = error.onError(_ref => {
|
|
462
|
-
let graphQLErrors = _ref.graphQLErrors,
|
|
463
|
-
networkError = _ref.networkError,
|
|
464
|
-
operation = _ref.operation,
|
|
465
|
-
forward = _ref.forward;
|
|
466
|
-
if (networkError && isHttpError(networkError) && networkError.statusCode === constants.STATUS_CODES.UNAUTHORIZED) {
|
|
467
|
-
history__default["default"].push("/logout?reason=".concat(constants.LOGOUT_REASONS.UNAUTHORIZED));
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// In case of graphql errors, we want to retry unauthenticated requests by
|
|
472
|
-
// forcing our API to fetch a new token, using the `X-Force-Token` header.
|
|
473
|
-
// https://www.apollographql.com/docs/link/links/error/#retrying-failed-requests
|
|
474
|
-
// We need to do this as the `token-retry-link` only works for network errors.
|
|
475
|
-
// https://www.apollographql.com/docs/link/links/retry/
|
|
476
|
-
if (graphQLErrors && isGraphQLError(graphQLErrors)) {
|
|
477
|
-
const context = operation.getContext();
|
|
478
|
-
for (const err of graphQLErrors) {
|
|
479
|
-
var _err$extensions;
|
|
480
|
-
const isNonAuthenticatedViaExtensionCode = (err === null || err === void 0 || (_err$extensions = err.extensions) === null || _err$extensions === void 0 ? void 0 : _err$extensions.code) === 'UNAUTHENTICATED';
|
|
481
|
-
/**
|
|
482
|
-
* NOTE:
|
|
483
|
-
* Not not all GraphQL APIs expose an `extensions` field in
|
|
484
|
-
* each error. For those we have to use the `message`
|
|
485
|
-
* property until they introduced support for the `extensions`
|
|
486
|
-
* field.
|
|
487
|
-
*/
|
|
488
|
-
const isNonAuthenticatedViaCode = (err === null || err === void 0 ? void 0 : err.message) === 'invalid_token';
|
|
489
|
-
if ((isNonAuthenticatedViaExtensionCode || isNonAuthenticatedViaCode) && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
490
|
-
operation.setContext(_ref2 => {
|
|
491
|
-
let headers = _ref2.headers;
|
|
492
|
-
return {
|
|
493
|
-
headers: forwardTokenRetryHeader(headers)
|
|
494
|
-
};
|
|
495
|
-
});
|
|
496
|
-
// retry the request, returning the new observable
|
|
497
|
-
return forward(operation);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return;
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
505
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
506
|
-
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
507
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$2(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$2(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
508
|
-
const defaultUserAgent = createHttpUserAgent__default["default"]({
|
|
509
|
-
name: 'unknown-http-client',
|
|
510
|
-
libraryName: window.app.applicationName
|
|
511
|
-
});
|
|
512
|
-
const defaultForwardToVersion = 'v2';
|
|
513
|
-
const defaultForwardToAudiencePolicy = 'forward-url-full-path';
|
|
514
|
-
function buildApiUrl(endpoint) {
|
|
515
|
-
var _context;
|
|
516
|
-
const apiUrl = getMcApiUrl().replace(/\/$/, '');
|
|
517
|
-
return _concatInstanceProperty__default["default"](_context = "".concat(apiUrl)).call(_context, endpoint);
|
|
518
|
-
}
|
|
519
|
-
const getAppliedForwardToHeaders = forwardToConfig => {
|
|
520
|
-
var _context2, _forwardToConfig$head, _forwardToConfig$vers, _forwardToConfig$audi;
|
|
521
|
-
if (!forwardToConfig) {
|
|
522
|
-
return {};
|
|
523
|
-
}
|
|
524
|
-
if (!forwardToConfig.uri) {
|
|
525
|
-
throw new Error("Missing required \"uri\" option.");
|
|
526
|
-
}
|
|
527
|
-
const exchangeTokenClaims = [];
|
|
528
|
-
if (forwardToConfig.includeUserPermissions) {
|
|
529
|
-
exchangeTokenClaims.push('permissions');
|
|
530
|
-
}
|
|
531
|
-
return _objectSpread$2(_objectSpread$2({}, _reduceInstanceProperty__default["default"](_context2 = _Object$entries__default["default"]((_forwardToConfig$head = forwardToConfig.headers) !== null && _forwardToConfig$head !== void 0 ? _forwardToConfig$head : {})).call(_context2, (customForwardHeaders, _ref) => {
|
|
532
|
-
let _ref2 = _slicedToArray(_ref, 2),
|
|
533
|
-
headerName = _ref2[0],
|
|
534
|
-
headerValue = _ref2[1];
|
|
535
|
-
return _objectSpread$2(_objectSpread$2({}, customForwardHeaders), {}, {
|
|
536
|
-
// Prefix headers so that the MC API can allow and forward them.
|
|
537
|
-
["x-forward-header-".concat(headerName)]: headerValue
|
|
538
|
-
});
|
|
539
|
-
}, {})), {}, {
|
|
540
|
-
[constants$1.SUPPORTED_HEADERS.ACCEPT_VERSION]: (_forwardToConfig$vers = forwardToConfig.version) !== null && _forwardToConfig$vers !== void 0 ? _forwardToConfig$vers : defaultForwardToVersion,
|
|
541
|
-
[constants$1.SUPPORTED_HEADERS.X_FORWARD_TO]: forwardToConfig.uri,
|
|
542
|
-
[constants$1.SUPPORTED_HEADERS.X_FORWARD_TO_AUDIENCE_POLICY]: (_forwardToConfig$audi = forwardToConfig.audiencePolicy) !== null && _forwardToConfig$audi !== void 0 ? _forwardToConfig$audi : defaultForwardToAudiencePolicy,
|
|
543
|
-
[constants$1.SUPPORTED_HEADERS.X_FORWARD_TO_CLAIMS]: exchangeTokenClaims.join(' ')
|
|
544
|
-
});
|
|
545
|
-
};
|
|
546
|
-
function createHttpClientOptions() {
|
|
547
|
-
var _config$projectKey;
|
|
548
|
-
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
549
|
-
const sessionToken = getSessionToken();
|
|
550
|
-
const projectKey = (_config$projectKey = config.projectKey) !== null && _config$projectKey !== void 0 ? _config$projectKey : selectProjectKeyFromUrl();
|
|
551
|
-
const userId = selectUserId();
|
|
552
|
-
const userAgent = (config === null || config === void 0 ? void 0 : config.userAgent) || defaultUserAgent;
|
|
553
|
-
return {
|
|
554
|
-
credentials: 'include',
|
|
555
|
-
headers: omitEmpty__default["default"](_objectSpread$2(_objectSpread$2({}, config.headers), {}, {
|
|
556
|
-
// Required headers
|
|
557
|
-
[constants$1.SUPPORTED_HEADERS.ACCEPT]: 'application/json',
|
|
558
|
-
[constants$1.SUPPORTED_HEADERS.AUTHORIZATION]: sessionToken ? "Bearer ".concat(sessionToken) : undefined,
|
|
559
|
-
[constants$1.SUPPORTED_HEADERS.X_APPLICATION_ID]: window.app.applicationIdentifier,
|
|
560
|
-
[constants$1.SUPPORTED_HEADERS.X_CUSTOM_VIEW_ID]: window.app.customViewId,
|
|
561
|
-
[constants$1.SUPPORTED_HEADERS.X_CORRELATION_ID]: getCorrelationId({
|
|
562
|
-
userId
|
|
563
|
-
}),
|
|
564
|
-
[constants$1.SUPPORTED_HEADERS.X_PROJECT_KEY]: projectKey,
|
|
565
|
-
[constants$1.SUPPORTED_HEADERS.X_USER_AGENT]: userAgent
|
|
566
|
-
}, getAppliedForwardToHeaders(config.forwardToConfig)))
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
let RenewTokenError = /*#__PURE__*/function (_Error) {
|
|
570
|
-
_inherits(RenewTokenError, _Error);
|
|
571
|
-
var _super = _createSuper(RenewTokenError);
|
|
572
|
-
function RenewTokenError(message) {
|
|
573
|
-
var _this;
|
|
574
|
-
_classCallCheck(this, RenewTokenError);
|
|
575
|
-
_this = _super.call(this, message);
|
|
576
|
-
_Object$defineProperty__default["default"](_assertThisInitialized(_this), 'name', {
|
|
577
|
-
value: 'RenewTokenError'
|
|
578
|
-
});
|
|
579
|
-
return _this;
|
|
580
|
-
}
|
|
581
|
-
return _createClass(RenewTokenError);
|
|
582
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
583
|
-
async function executeHttpClientRequest(fetcher) {
|
|
584
|
-
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
585
|
-
// Wrapper function to be called again (once) on retry.
|
|
586
|
-
async function sendRequest() {
|
|
587
|
-
let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
588
|
-
shouldRenewToken = _ref3.shouldRenewToken;
|
|
589
|
-
const requestOptions = createHttpClientOptions(config);
|
|
590
|
-
const response = await fetcher(_objectSpread$2(_objectSpread$2({}, requestOptions), {}, {
|
|
591
|
-
headers: omitEmpty__default["default"](_objectSpread$2(_objectSpread$2({}, requestOptions.headers), {}, {
|
|
592
|
-
// Passing this header forces a token renewal.
|
|
593
|
-
[constants$1.SUPPORTED_HEADERS.X_TOKEN_RETRY]: shouldRenewToken
|
|
594
|
-
}))
|
|
595
|
-
}));
|
|
596
|
-
if (response.statusCode === constants.STATUS_CODES.UNAUTHORIZED) {
|
|
597
|
-
throw new RenewTokenError("Unauthorized response, attempting retry.");
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// In case a new session token is returned from the server, save it.
|
|
601
|
-
const refreshedSessionToken = response.getHeader('x-refreshed-session-token');
|
|
602
|
-
if (refreshedSessionToken) {
|
|
603
|
-
setActiveSession(refreshedSessionToken);
|
|
604
|
-
}
|
|
605
|
-
return response.data;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// Attempt to send the request.
|
|
609
|
-
return sendRequest().catch(error => {
|
|
610
|
-
if (error instanceof RenewTokenError) {
|
|
611
|
-
// Retry the request and ask to renew the token.
|
|
612
|
-
return sendRequest({
|
|
613
|
-
shouldRenewToken: true
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
throw error;
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
621
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$1(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
622
|
-
const userAgent = createHttpUserAgent__default["default"]({
|
|
623
|
-
name: 'apollo-client',
|
|
624
|
-
// version: apolloVersion,
|
|
625
|
-
libraryName: [window.app.applicationName, 'application-shell'].join('/'),
|
|
626
|
-
libraryVersion: applicationShellVersion,
|
|
627
|
-
contactUrl: 'https://git.io/fjuyC',
|
|
628
|
-
// points to the appkit repo issues
|
|
629
|
-
contactEmail: 'support@commercetools.com'
|
|
630
|
-
});
|
|
631
|
-
const isKnownGraphQlTarget = target => {
|
|
632
|
-
var _context;
|
|
633
|
-
return target ? _includesInstanceProperty__default["default"](_context = _Object$values__default["default"](constants.GRAPHQL_TARGETS)).call(_context, target) : false;
|
|
634
|
-
};
|
|
635
|
-
const extractSessionTokenFromResponse = context => {
|
|
636
|
-
var _context$response, _context$restResponse;
|
|
637
|
-
const refreshedSessionToken = (_context$response = context.response) === null || _context$response === void 0 || (_context$response = _context$response.headers) === null || _context$response === void 0 ? void 0 : _context$response.get('x-refreshed-session-token');
|
|
638
|
-
if (refreshedSessionToken) {
|
|
639
|
-
return refreshedSessionToken !== null && refreshedSessionToken !== void 0 ? refreshedSessionToken : null;
|
|
640
|
-
}
|
|
641
|
-
const restResponseWithRefreshTokenHeader = (_context$restResponse = context.restResponses) === null || _context$restResponse === void 0 ? void 0 : _findInstanceProperty__default["default"](_context$restResponse).call(_context$restResponse, response => {
|
|
642
|
-
var _response$headers;
|
|
643
|
-
return (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.has('x-refreshed-session-token');
|
|
644
|
-
});
|
|
645
|
-
if (restResponseWithRefreshTokenHeader) {
|
|
646
|
-
var _restResponseWithRefr;
|
|
647
|
-
return (_restResponseWithRefr = restResponseWithRefreshTokenHeader.headers.get('x-refreshed-session-token')) !== null && _restResponseWithRefr !== void 0 ? _restResponseWithRefr : null;
|
|
648
|
-
}
|
|
649
|
-
return null;
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
/* eslint-disable import/prefer-default-export */
|
|
653
|
-
// Use a middleware to update the request headers with the correct params.
|
|
654
|
-
const headerLink = new client.ApolloLink((operation, forward) => {
|
|
655
|
-
var _context2, _context3;
|
|
656
|
-
const apolloContext = operation.getContext();
|
|
657
|
-
const variables = operation.variables;
|
|
658
|
-
const graphQlTarget = apolloContext.target || variables.target;
|
|
659
|
-
if (!apolloContext.skipGraphQlTargetCheck && !isKnownGraphQlTarget(graphQlTarget)) throw new Error(_concatInstanceProperty__default["default"](_context2 = "GraphQL target \"".concat(graphQlTarget, "\" is missing (or is not supported) in operation \"")).call(_context2, operation.operationName, "\""));
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* NOTE:
|
|
663
|
-
* The project key is read from the url in a project related application context.
|
|
664
|
-
* This holds for most applications like `application-categories`, `application-discounts` etc.
|
|
665
|
-
* However, the `application-account` does not run with the project key being part of the url.
|
|
666
|
-
* As a result we allow passing the project key as a variable on the operation allowing
|
|
667
|
-
* it to be the fallback.
|
|
668
|
-
*/
|
|
669
|
-
const projectKey = apolloContext.projectKey || variables.projectKey || selectProjectKeyFromUrl();
|
|
670
|
-
const teamId = apolloContext.teamId || variables.teamId || selectTeamIdFromStorage();
|
|
671
|
-
const featureFlag = apolloContext.featureFlag || variables.featureFlag;
|
|
672
|
-
operation.setContext(createHttpClientOptions({
|
|
673
|
-
userAgent,
|
|
674
|
-
headers: omitEmpty__default["default"](_objectSpread$1(_objectSpread$1({}, apolloContext.headers), {}, {
|
|
675
|
-
// Required headers for GraphQL API.
|
|
676
|
-
[constants$1.SUPPORTED_HEADERS.X_GRAPHQL_TARGET]: graphQlTarget,
|
|
677
|
-
// For logging/debugging purposes.
|
|
678
|
-
[constants$1.SUPPORTED_HEADERS.X_GRAPHQL_OPERATION_NAME]: operation.operationName,
|
|
679
|
-
// Experimental features, use with caution.
|
|
680
|
-
[constants$1.SUPPORTED_HEADERS.X_TEAM_ID]: teamId,
|
|
681
|
-
[constants$1.SUPPORTED_HEADERS.X_FEATURE_FLAG]: featureFlag
|
|
682
|
-
})),
|
|
683
|
-
forwardToConfig: apolloContext.forwardToConfig,
|
|
684
|
-
projectKey
|
|
685
|
-
}));
|
|
686
|
-
return _mapInstanceProperty__default["default"](_context3 = forward(operation)).call(_context3, response => {
|
|
687
|
-
const context = operation.getContext();
|
|
688
|
-
const refreshedSessionToken = extractSessionTokenFromResponse(context);
|
|
689
|
-
if (refreshedSessionToken) {
|
|
690
|
-
setActiveSession(refreshedSessionToken);
|
|
691
|
-
}
|
|
692
|
-
return response;
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
const tokenRetryLink = new retry.RetryLink({
|
|
697
|
-
attempts: (count, operation, error) => {
|
|
698
|
-
const context = operation.getContext();
|
|
699
|
-
if ((error === null || error === void 0 ? void 0 : error.statusCode) === constants.STATUS_CODES.UNAUTHORIZED && count === 1 && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
700
|
-
operation.setContext(_ref => {
|
|
701
|
-
let headers = _ref.headers;
|
|
702
|
-
return {
|
|
703
|
-
headers: forwardTokenRetryHeader(headers)
|
|
704
|
-
};
|
|
705
|
-
});
|
|
706
|
-
return true;
|
|
707
|
-
}
|
|
708
|
-
return false;
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
713
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
714
|
-
const httpLink = client.createHttpLink({
|
|
715
|
-
uri: "".concat(getMcApiUrl(), "/graphql"),
|
|
716
|
-
fetch
|
|
717
|
-
});
|
|
718
|
-
const createApolloLink = function () {
|
|
719
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
720
|
-
return (
|
|
721
|
-
// The order of links is IMPORTANT!
|
|
722
|
-
// In the request-phase they are executed top to bottom.
|
|
723
|
-
// In the response/phase they are executed bottom to top.
|
|
724
|
-
// The `httpLink` is terminating so it must be last, while `tokenRetryLink` and `errorLink`
|
|
725
|
-
// wrap the links the their right.
|
|
726
|
-
client.from([headerLink,
|
|
727
|
-
// See https://www.apollographql.com/docs/react/api/link/apollo-link-rest/#link-order
|
|
728
|
-
// State & context links should happen before (to the left of) `restLink`.
|
|
729
|
-
...(options.restLink ? [options.restLink] : []),
|
|
730
|
-
// Must be before `tokenRetryLink`.
|
|
731
|
-
errorLink,
|
|
732
|
-
// Avoid logging queries in test environment
|
|
733
|
-
...(isLoggerEnabled() ? [loggerLink__default["default"]] : []),
|
|
734
|
-
// Must be after `errorLink`.
|
|
735
|
-
tokenRetryLink,
|
|
736
|
-
// Must be last.
|
|
737
|
-
httpLink])
|
|
738
|
-
);
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
// This custom merge function allows to merge two arrays of objects.
|
|
742
|
-
// The incoming list is what we need to update to, but we still need
|
|
743
|
-
// to ensure that existing cache elements are not removed but updated.
|
|
744
|
-
// This is usually the case when elements get removed.
|
|
745
|
-
const mergeArraysObjects = function () {
|
|
746
|
-
let existing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
747
|
-
let incoming = arguments.length > 1 ? arguments[1] : undefined;
|
|
748
|
-
let _ref = arguments.length > 2 ? arguments[2] : undefined,
|
|
749
|
-
mergeObjects = _ref.mergeObjects;
|
|
750
|
-
return _reduceInstanceProperty__default["default"](incoming).call(incoming, (mergedElements, elem) => {
|
|
751
|
-
const existingElem = _findInstanceProperty__default["default"](existing).call(existing, el => el.__ref === elem.__ref);
|
|
752
|
-
if (existingElem) {
|
|
753
|
-
const updatedElem = mergeObjects(existingElem, elem);
|
|
754
|
-
if (updatedElem) {
|
|
755
|
-
return [...mergedElements, updatedElem];
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
return [...mergedElements, elem];
|
|
759
|
-
}, []);
|
|
760
|
-
};
|
|
761
|
-
const createApolloClient = function () {
|
|
762
|
-
var _options$cache, _customCacheConfig$ty;
|
|
763
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
764
|
-
const customCacheConfig = (_options$cache = options === null || options === void 0 ? void 0 : options.cache) !== null && _options$cache !== void 0 ? _options$cache : {};
|
|
765
|
-
return new client.ApolloClient({
|
|
766
|
-
link: createApolloLink(options),
|
|
767
|
-
// https://www.apollographql.com/docs/react/caching/cache-configuration/
|
|
768
|
-
cache: new client.InMemoryCache(_objectSpread(_objectSpread({}, customCacheConfig), {}, {
|
|
769
|
-
// https://www.apollographql.com/docs/react/caching/cache-configuration/#generating-unique-identifiers
|
|
770
|
-
typePolicies: _objectSpread({
|
|
771
|
-
// CTP types with `key` as identifier
|
|
772
|
-
Project: {
|
|
773
|
-
keyFields: ['key']
|
|
774
|
-
},
|
|
775
|
-
Store: {
|
|
776
|
-
keyFields: ['key']
|
|
777
|
-
},
|
|
778
|
-
// Internal apps menu links representations
|
|
779
|
-
ApplicationsMenu: {
|
|
780
|
-
fields: {
|
|
781
|
-
appBar: {
|
|
782
|
-
merge: mergeArraysObjects
|
|
783
|
-
},
|
|
784
|
-
navBar: {
|
|
785
|
-
merge: mergeArraysObjects
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
}, (_customCacheConfig$ty = customCacheConfig.typePolicies) !== null && _customCacheConfig$ty !== void 0 ? _customCacheConfig$ty : {})
|
|
790
|
-
}))
|
|
791
|
-
});
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
exports.RouteCatchAll = RouteCatchAll;
|
|
795
|
-
exports.applicationShellVersion = applicationShellVersion;
|
|
796
|
-
exports.applyDefaultMiddlewares = applyDefaultMiddlewares;
|
|
797
|
-
exports.buildApiUrl = buildApiUrl;
|
|
798
|
-
exports.clearSession = clearSession;
|
|
799
|
-
exports.createApolloClient = createApolloClient;
|
|
800
|
-
exports.createHttpClientOptions = createHttpClientOptions;
|
|
801
|
-
exports.createReduxStore = createReduxStore;
|
|
802
|
-
exports.executeHttpClientRequest = executeHttpClientRequest;
|
|
803
|
-
exports.getActiveProjectKey = getActiveProjectKey;
|
|
804
|
-
exports.getMcApiUrl = getMcApiUrl;
|
|
805
|
-
exports.getSessionScope = getSessionScope;
|
|
806
|
-
exports.getSessionState = getSessionState;
|
|
807
|
-
exports.internalReduxStore = internalReduxStore;
|
|
808
|
-
exports.removeActiveProjectKey = removeActiveProjectKey;
|
|
809
|
-
exports.selectProjectKeyFromUrl = selectProjectKeyFromUrl;
|
|
810
|
-
exports.selectUserId = selectUserId;
|
|
811
|
-
exports.setActiveProjectKey = setActiveProjectKey;
|
|
812
|
-
exports.setActiveSession = setActiveSession;
|
|
813
|
-
exports.setCachedApolloClient = setCachedApolloClient;
|
|
814
|
-
exports.setSessionScope = setSessionScope;
|
|
815
|
-
exports.setSessionState = setSessionState;
|