@commercetools-frontend/application-shell-connectors 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.
@@ -14,22 +14,21 @@ import { createContext, useContext, useEffect } from 'react';
14
14
  import moment from 'moment-timezone';
15
15
  import { reportErrorToSentry } from '@commercetools-frontend/sentry';
16
16
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
17
- import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
18
17
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
19
18
  import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
20
19
  import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
21
20
  import { jsx } from '@emotion/react/jsx-runtime';
22
- import warning from 'tiny-warning';
23
21
  import { useQuery } from '@apollo/client/react';
22
+ import warning from 'tiny-warning';
24
23
  import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants';
25
24
 
26
25
  // NOTE: This string will be replaced on build time with the package version.
27
- var version = "21.23.10";
26
+ var version = "21.24.1";
28
27
 
29
- var mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
30
- var mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
28
+ const mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
29
+ const mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
31
30
 
32
- var getMcOriginTld = function getMcOriginTld(host) {
31
+ const getMcOriginTld = host => {
33
32
  if (host.match(mcPreviewHostnameRegex)) {
34
33
  return host.replace(mcPreviewHostnameRegex, '$1');
35
34
  }
@@ -37,22 +36,20 @@ var getMcOriginTld = function getMcOriginTld(host) {
37
36
  return host.replace(mcHostnameRegex, '$3');
38
37
  };
39
38
 
40
- var getMcApiUrlFromOrigin = function getMcApiUrlFromOrigin(origin) {
39
+ const getMcApiUrlFromOrigin = origin => {
41
40
  var _context;
42
41
 
43
- var url = new _URL(origin);
44
- var originTld = getMcOriginTld(url.host);
42
+ const url = new _URL(origin);
43
+ const originTld = getMcOriginTld(url.host);
45
44
  return _concatInstanceProperty(_context = "".concat(url.protocol, "//mc-api.")).call(_context, originTld);
46
45
  };
47
46
 
48
- var parseAsBoolean = function parseAsBoolean(value) {
49
- return value === true || value === 'true';
50
- };
47
+ const parseAsBoolean = value => value === true || value === 'true';
51
48
 
52
49
  function getMcApiUrl() {
53
- var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.app;
54
- var origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.origin;
55
- var isServedByProxy = parseAsBoolean(environment.servedByProxy);
50
+ let environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.app;
51
+ let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.origin;
52
+ const isServedByProxy = parseAsBoolean(environment.servedByProxy);
56
53
  /**
57
54
  * Prefer using the origin URL for the MC API based on the origin value
58
55
  * of the browser's `window.location`.
@@ -68,7 +65,7 @@ function getMcApiUrl() {
68
65
  }
69
66
 
70
67
  // From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
71
- var getDisplayName = function getDisplayName(Component) {
68
+ const getDisplayName = Component => {
72
69
  if (typeof Component === 'string') {
73
70
  return Component;
74
71
  }
@@ -82,7 +79,7 @@ var getDisplayName = function getDisplayName(Component) {
82
79
 
83
80
  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; }
84
81
 
85
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys$2(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys$2(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
82
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys$2(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys$2(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
86
83
  // Menu visibilities
87
84
  // Permissions
88
85
  // Action rights
@@ -106,66 +103,76 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
106
103
  * the fetching logic. Given this mapping needs to be used elsewere feel free
107
104
  * to move this over to `permissions` and export it there.
108
105
  */
109
- var normalizeAllAppliedPermissions = function normalizeAllAppliedPermissions(allAppliedPermissions) {
106
+ const normalizeAllAppliedPermissions = allAppliedPermissions => {
110
107
  if (!allAppliedPermissions || allAppliedPermissions.length === 0) {
111
108
  return null;
112
109
  }
113
110
 
114
- return _reduceInstanceProperty(allAppliedPermissions).call(allAppliedPermissions, function (transformedAllApplied, allApplied) {
111
+ return _reduceInstanceProperty(allAppliedPermissions).call(allAppliedPermissions, (transformedAllApplied, allApplied) => {
115
112
  if (!allApplied) return transformedAllApplied;
116
- return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, _defineProperty({}, allApplied.name, allApplied.value));
113
+ return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, {
114
+ [allApplied.name]: allApplied.value
115
+ });
117
116
  }, {});
118
117
  };
119
- var normalizeAllAppliedMenuVisibilities = function normalizeAllAppliedMenuVisibilities(allAppliedMenuVisibilities) {
118
+ const normalizeAllAppliedMenuVisibilities = allAppliedMenuVisibilities => {
120
119
  if (!allAppliedMenuVisibilities || allAppliedMenuVisibilities.length === 0) {
121
120
  return null;
122
121
  }
123
122
 
124
- return _reduceInstanceProperty(allAppliedMenuVisibilities).call(allAppliedMenuVisibilities, function (transformedAllApplied, allApplied) {
123
+ return _reduceInstanceProperty(allAppliedMenuVisibilities).call(allAppliedMenuVisibilities, (transformedAllApplied, allApplied) => {
125
124
  if (!allApplied) return transformedAllApplied;
126
- return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, _defineProperty({}, allApplied.name, allApplied.value));
125
+ return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, {
126
+ [allApplied.name]: allApplied.value
127
+ });
127
128
  }, {});
128
129
  };
129
- var normalizeAllAppliedActionRights = function normalizeAllAppliedActionRights(allAppliedActionRights) {
130
+ const normalizeAllAppliedActionRights = allAppliedActionRights => {
130
131
  if (!allAppliedActionRights || allAppliedActionRights.length === 0) {
131
132
  return null;
132
133
  }
133
134
 
134
- return _reduceInstanceProperty(allAppliedActionRights).call(allAppliedActionRights, function (transformedAllApplied, allApplied) {
135
+ return _reduceInstanceProperty(allAppliedActionRights).call(allAppliedActionRights, (transformedAllApplied, allApplied) => {
135
136
  if (!allApplied) return transformedAllApplied;
136
- var previousAllAppliedGroup = transformedAllApplied[allApplied.group];
137
- return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, _defineProperty({}, allApplied.group, _objectSpread$2(_objectSpread$2({}, previousAllAppliedGroup), {}, _defineProperty({}, allApplied.name, allApplied.value))));
137
+ const previousAllAppliedGroup = transformedAllApplied[allApplied.group];
138
+ return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, {
139
+ [allApplied.group]: _objectSpread$2(_objectSpread$2({}, previousAllAppliedGroup), {}, {
140
+ [allApplied.name]: allApplied.value
141
+ })
142
+ });
138
143
  }, {});
139
144
  };
140
145
 
141
- var normalizeAppliedDataFencesForStoresByResourceType = function normalizeAppliedDataFencesForStoresByResourceType(dataFences) {
142
- var _context2;
143
-
144
- var groupedByResourceType = _reduceInstanceProperty(dataFences).call(dataFences, function (previousGroupsOfSameType, appliedDataFence) {
145
- var _context;
146
+ const normalizeAppliedDataFencesForStoresByResourceType = dataFences => {
147
+ var _context;
146
148
 
149
+ const groupedByResourceType = _reduceInstanceProperty(dataFences).call(dataFences, (previousGroupsOfSameType, appliedDataFence) => {
147
150
  if (!appliedDataFence) return previousGroupsOfSameType;
148
- var previousGroup = previousGroupsOfSameType[appliedDataFence.group];
149
- return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, _defineProperty({}, appliedDataFence.group, _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(previousGroup || []), [appliedDataFence])));
151
+ const previousGroup = previousGroupsOfSameType[appliedDataFence.group];
152
+ return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, {
153
+ [appliedDataFence.group]: [...(previousGroup || []), appliedDataFence]
154
+ });
150
155
  }, {});
151
156
 
152
- return _reduceInstanceProperty(_context2 = _Object$entries(groupedByResourceType)).call(_context2, function (previousGroupedByResourceType, _ref) {
153
- var _ref2 = _slicedToArray(_ref, 2),
157
+ return _reduceInstanceProperty(_context = _Object$entries(groupedByResourceType)).call(_context, (previousGroupedByResourceType, _ref) => {
158
+ let _ref2 = _slicedToArray(_ref, 2),
154
159
  resourceType = _ref2[0],
155
160
  dataFences = _ref2[1];
156
161
 
157
- var groupByDataFenceName = _reduceInstanceProperty(dataFences).call(dataFences, function (nextDataFenceValues, dataFence) {
158
- var _context3;
159
-
160
- var dataFenceByName = nextDataFenceValues[dataFence.name] || {
162
+ const groupByDataFenceName = _reduceInstanceProperty(dataFences).call(dataFences, (nextDataFenceValues, dataFence) => {
163
+ const dataFenceByName = nextDataFenceValues[dataFence.name] || {
161
164
  values: []
162
165
  };
163
- return _objectSpread$2(_objectSpread$2({}, nextDataFenceValues), {}, _defineProperty({}, dataFence.name, _objectSpread$2(_objectSpread$2({}, dataFenceByName), {}, {
164
- values: _concatInstanceProperty(_context3 = []).call(_context3, _toConsumableArray(_valuesInstanceProperty(dataFenceByName)), [dataFence.value])
165
- })));
166
+ return _objectSpread$2(_objectSpread$2({}, nextDataFenceValues), {}, {
167
+ [dataFence.name]: _objectSpread$2(_objectSpread$2({}, dataFenceByName), {}, {
168
+ values: [..._valuesInstanceProperty(dataFenceByName), dataFence.value]
169
+ })
170
+ });
166
171
  }, {});
167
172
 
168
- return _objectSpread$2(_objectSpread$2({}, previousGroupedByResourceType), {}, _defineProperty({}, resourceType, groupByDataFenceName));
173
+ return _objectSpread$2(_objectSpread$2({}, previousGroupedByResourceType), {}, {
174
+ [resourceType]: groupByDataFenceName
175
+ });
169
176
  }, {});
170
177
  }; // input:
171
178
  // [
@@ -199,20 +206,20 @@ var normalizeAppliedDataFencesForStoresByResourceType = function normalizeApplie
199
206
  // }
200
207
 
201
208
 
202
- var normalizeAllAppliedDataFences = function normalizeAllAppliedDataFences(allAppliedDataFences) {
209
+ const normalizeAllAppliedDataFences = allAppliedDataFences => {
203
210
  if (!allAppliedDataFences || allAppliedDataFences.length === 0) {
204
211
  return null;
205
212
  }
206
213
 
207
- var groupedByType = _reduceInstanceProperty(allAppliedDataFences).call(allAppliedDataFences, function (previousGroupsOfSameType, appliedDataFence) {
208
- var _context4;
209
-
214
+ const groupedByType = _reduceInstanceProperty(allAppliedDataFences).call(allAppliedDataFences, (previousGroupsOfSameType, appliedDataFence) => {
210
215
  if (!appliedDataFence) return previousGroupsOfSameType;
211
- var previousGroup = previousGroupsOfSameType[appliedDataFence.type];
212
- return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, _defineProperty({}, appliedDataFence.type, _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(previousGroup || []), [appliedDataFence])));
216
+ const previousGroup = previousGroupsOfSameType[appliedDataFence.type];
217
+ return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, {
218
+ [appliedDataFence.type]: [...(previousGroup || []), appliedDataFence]
219
+ });
213
220
  }, {});
214
221
 
215
- var normalizedDataFences = _objectSpread$2({}, 'store' in groupedByType ? {
222
+ const normalizedDataFences = _objectSpread$2({}, 'store' in groupedByType ? {
216
223
  store: normalizeAppliedDataFencesForStoresByResourceType(groupedByType.store)
217
224
  } : {});
218
225
 
@@ -223,13 +230,13 @@ var normalizeAllAppliedDataFences = function normalizeAllAppliedDataFences(allAp
223
230
  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; }
224
231
 
225
232
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
226
- var Context$1 = /*#__PURE__*/createContext({});
227
- var defaultTimeZone = moment.tz.guess() || 'Etc/UTC'; // Expose only certain fields as some of them are only meant to
233
+ const Context$1 = /*#__PURE__*/createContext({});
234
+ const defaultTimeZone = moment.tz.guess() || 'Etc/UTC'; // Expose only certain fields as some of them are only meant to
228
235
  // be used internally in the AppShell
229
236
 
230
- var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(user) {
237
+ const mapUserToApplicationContextUser = user => {
231
238
  if (!user) return null;
232
- var applicationContextUser = {
239
+ let applicationContextUser = {
233
240
  id: user.id,
234
241
  email: user.email,
235
242
  createdAt: user.createdAt,
@@ -244,7 +251,7 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
244
251
  }; // This property will only be populated when user has logged in using SSO
245
252
 
246
253
  if (user.idTokenUserInfo) {
247
- var additionalClaims = {};
254
+ let additionalClaims = {};
248
255
 
249
256
  try {
250
257
  additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '{}');
@@ -257,22 +264,20 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
257
264
  }
258
265
 
259
266
  applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
260
- additionalClaims: additionalClaims
267
+ additionalClaims
261
268
  });
262
269
  }
263
270
 
264
271
  return applicationContextUser;
265
272
  }; // Adjust certain fields which depend e.g. on the origin
266
273
 
267
- var mapEnvironmentToApplicationContextEnvironment = function mapEnvironmentToApplicationContextEnvironment(environment, origin) {
268
- return _objectSpread$1(_objectSpread$1({}, environment), {}, {
269
- // NOTE: The `mcApiUrl` depends on `servedByProxy`
270
- mcApiUrl: getMcApiUrl(environment, origin)
271
- });
272
- }; // Expose only certain fields as some of them are only meant to
274
+ const mapEnvironmentToApplicationContextEnvironment = (environment, origin) => _objectSpread$1(_objectSpread$1({}, environment), {}, {
275
+ // NOTE: The `mcApiUrl` depends on `servedByProxy`
276
+ mcApiUrl: getMcApiUrl(environment, origin)
277
+ }); // Expose only certain fields as some of them are only meant to
273
278
  // be used internally in the AppShell
274
279
 
275
- var mapProjectToApplicationContextProject = function mapProjectToApplicationContextProject(project) {
280
+ const mapProjectToApplicationContextProject = project => {
276
281
  if (!project) return null;
277
282
  return {
278
283
  key: project.key,
@@ -286,24 +291,20 @@ var mapProjectToApplicationContextProject = function mapProjectToApplicationCont
286
291
  };
287
292
  };
288
293
 
289
- var createApplicationContext = function createApplicationContext(environment, user, project, projectDataLocale) {
290
- return {
291
- environment: mapEnvironmentToApplicationContextEnvironment(environment),
292
- user: mapUserToApplicationContextUser(user),
293
- project: mapProjectToApplicationContextProject(project),
294
- permissions: normalizeAllAppliedPermissions(project === null || project === void 0 ? void 0 : project.allAppliedPermissions),
295
- actionRights: normalizeAllAppliedActionRights(project === null || project === void 0 ? void 0 : project.allAppliedActionRights),
296
- dataFences: normalizeAllAppliedDataFences(project === null || project === void 0 ? void 0 : project.allAppliedDataFences),
297
- dataLocale: projectDataLocale || null
298
- };
299
- };
294
+ const createApplicationContext = (environment, user, project, projectDataLocale) => ({
295
+ environment: mapEnvironmentToApplicationContextEnvironment(environment),
296
+ user: mapUserToApplicationContextUser(user),
297
+ project: mapProjectToApplicationContextProject(project),
298
+ permissions: normalizeAllAppliedPermissions(project === null || project === void 0 ? void 0 : project.allAppliedPermissions),
299
+ actionRights: normalizeAllAppliedActionRights(project === null || project === void 0 ? void 0 : project.allAppliedActionRights),
300
+ dataFences: normalizeAllAppliedDataFences(project === null || project === void 0 ? void 0 : project.allAppliedDataFences),
301
+ dataLocale: projectDataLocale || null
302
+ });
300
303
 
301
- var ApplicationContextProvider = function ApplicationContextProvider(props) {
302
- return jsx(Context$1.Provider, {
303
- value: createApplicationContext(props.environment, props.user, props.project, props.projectDataLocale),
304
- children: props.children
305
- });
306
- };
304
+ const ApplicationContextProvider = props => jsx(Context$1.Provider, {
305
+ value: createApplicationContext(props.environment, props.user, props.project, props.projectDataLocale),
306
+ children: props.children
307
+ });
307
308
 
308
309
  ApplicationContextProvider.propTypes = process.env.NODE_ENV !== "production" ? {
309
310
  projectDataLocale: _pt.string,
@@ -311,18 +312,16 @@ ApplicationContextProvider.propTypes = process.env.NODE_ENV !== "production" ? {
311
312
  } : {};
312
313
  ApplicationContextProvider.displayName = 'ApplicationContextProvider';
313
314
 
314
- var ApplicationContext = function ApplicationContext(props) {
315
- return jsx(Context$1.Consumer, {
316
- children: function children(context) {
317
- // Because of the way the ApplicationShell configures the Context.Provider,
318
- // we ensure that, when we read from the context, we always get actual
319
- // context object and not the initial value.
320
- // Therefore, we can safely cast the value to be out `TApplicationContext` type.
321
- var applicationContext = context;
322
- return props.render(applicationContext);
323
- }
324
- });
325
- };
315
+ const ApplicationContext = props => jsx(Context$1.Consumer, {
316
+ children: context => {
317
+ // Because of the way the ApplicationShell configures the Context.Provider,
318
+ // we ensure that, when we read from the context, we always get actual
319
+ // context object and not the initial value.
320
+ // Therefore, we can safely cast the value to be out `TApplicationContext` type.
321
+ const applicationContext = context;
322
+ return props.render(applicationContext);
323
+ }
324
+ });
326
325
 
327
326
  ApplicationContext.propTypes = process.env.NODE_ENV !== "production" ? {
328
327
  render: _pt.func.isRequired
@@ -330,17 +329,15 @@ ApplicationContext.propTypes = process.env.NODE_ENV !== "production" ? {
330
329
  ApplicationContext.displayName = 'ApplicationContext';
331
330
 
332
331
  function withApplicationContext(mapApplicationContextToProps) {
333
- return function (Component) {
334
- var WrappedComponent = function WrappedComponent(props) {
335
- return jsx(ApplicationContext, {
336
- render: function render(applicationContext) {
337
- var mappedProps = mapApplicationContextToProps ? mapApplicationContextToProps(applicationContext) : {
338
- applicationContext: applicationContext
339
- };
340
- return jsx(Component, _objectSpread$1(_objectSpread$1({}, props), mappedProps));
341
- }
342
- });
343
- };
332
+ return Component => {
333
+ const WrappedComponent = props => jsx(ApplicationContext, {
334
+ render: applicationContext => {
335
+ const mappedProps = mapApplicationContextToProps ? mapApplicationContextToProps(applicationContext) : {
336
+ applicationContext
337
+ };
338
+ return jsx(Component, _objectSpread$1(_objectSpread$1({}, props), mappedProps));
339
+ }
340
+ });
344
341
 
345
342
  WrappedComponent.displayName = "withApplicationContext(".concat(getDisplayName(Component), ")");
346
343
  return WrappedComponent;
@@ -352,56 +349,56 @@ function withApplicationContext(mapApplicationContextToProps) {
352
349
  // Then implement the function. Typescript will pick the appropriate signature
353
350
  // based on the function arguments.
354
351
  function useApplicationContextHook(selector) {
355
- var context = useContext(Context$1); // Because of the way the ApplicationShell configures the Context.Provider,
352
+ const context = useContext(Context$1); // Because of the way the ApplicationShell configures the Context.Provider,
356
353
  // we ensure that, when we read from the context, we always get actual
357
354
  // context object and not the initial value.
358
355
  // Therefore, we can safely cast the value to be out `TApplicationContext` type.
359
356
 
360
- var applicationContext = context;
357
+ const applicationContext = context;
361
358
  return selector ? selector(applicationContext) : applicationContext;
362
359
  } // This is a workaround to trick babel/rollup to correctly export the function.
363
360
  // Most likely the problem arises with the use of overloading.
364
361
  // See related issue: https://github.com/babel/babel/issues/8361
365
362
 
366
363
 
367
- var useApplicationContext = useApplicationContextHook; // Exports
364
+ const useApplicationContext = useApplicationContextHook; // Exports
368
365
 
369
366
  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; }
370
367
 
371
368
  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; }
372
369
  var FetchProjectExtensionImageRegex = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProjectExtensionImageRegex" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "projectExtension" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "imageRegex" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "thumb" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "small" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "ImageRegex" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ImageRegexOptions" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "flag" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "search" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "replace" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 256, source: { body: "query FetchProjectExtensionImageRegex {\n projectExtension {\n id\n imageRegex {\n thumb {\n ...ImageRegex\n }\n small {\n ...ImageRegex\n }\n }\n }\n}\nfragment ImageRegex on ImageRegexOptions {\n flag\n search\n replace\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
373
370
 
374
- var useWarning = function useWarning(condition, message) {
375
- useEffect(function () {
371
+ const useWarning = (condition, message) => {
372
+ useEffect(() => {
376
373
  process.env.NODE_ENV !== "production" ? warning(condition, message) : void 0; // eslint-disable-next-line react-hooks/exhaustive-deps
377
374
  }, []);
378
375
  };
379
376
 
380
- var Context = /*#__PURE__*/createContext({
377
+ const Context = /*#__PURE__*/createContext({
381
378
  isLoading: false
382
379
  });
383
380
 
384
- var useProjectExtensionImageRegex = function useProjectExtensionImageRegex() {
385
- var _useContext = useContext(Context),
386
- isLoading = _useContext.isLoading,
387
- imageRegex = _useContext.imageRegex;
381
+ const useProjectExtensionImageRegex = () => {
382
+ const _useContext = useContext(Context),
383
+ isLoading = _useContext.isLoading,
384
+ imageRegex = _useContext.imageRegex;
388
385
 
389
386
  return {
390
- isLoading: isLoading,
391
- imageRegex: imageRegex
387
+ isLoading,
388
+ imageRegex
392
389
  };
393
390
  };
394
391
 
395
- var ProjectExtensionProviderForImageRegex = function ProjectExtensionProviderForImageRegex(props) {
396
- var _useQuery = useQuery(FetchProjectExtensionImageRegex, {
392
+ const ProjectExtensionProviderForImageRegex = props => {
393
+ const _useQuery = useQuery(FetchProjectExtensionImageRegex, {
397
394
  skip: props.skip,
398
395
  onError: reportErrorToSentry,
399
396
  context: {
400
397
  target: GRAPHQL_TARGETS.SETTINGS_SERVICE
401
398
  }
402
399
  }),
403
- loading = _useQuery.loading,
404
- data = _useQuery.data;
400
+ loading = _useQuery.loading,
401
+ data = _useQuery.data;
405
402
 
406
403
  return jsx(Context.Provider, {
407
404
  value: {
@@ -418,12 +415,10 @@ ProjectExtensionProviderForImageRegex.propTypes = process.env.NODE_ENV !== "prod
418
415
  } : {};
419
416
  ProjectExtensionProviderForImageRegex.displayName = 'ProjectExtensionProviderForImageRegex';
420
417
 
421
- var GetProjectExtensionImageRegex = function GetProjectExtensionImageRegex(props) {
418
+ const GetProjectExtensionImageRegex = props => {
422
419
  useWarning(false, "@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'GetProjectExtensionImageRegex' anymore. Please use the 'useProjectExtensionImageRegex' hook instead.");
423
420
  return jsx(Context.Consumer, {
424
- children: function children(imageRegexContext) {
425
- return props.render(imageRegexContext);
426
- }
421
+ children: imageRegexContext => props.render(imageRegexContext)
427
422
  });
428
423
  };
429
424
 
@@ -433,15 +428,15 @@ GetProjectExtensionImageRegex.propTypes = process.env.NODE_ENV !== "production"
433
428
  GetProjectExtensionImageRegex.displayName = 'GetProjectExtensionImageRegex';
434
429
 
435
430
  function withProjectExtensionImageRegex() {
436
- var propKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'imageRegexData';
437
- return function (Component) {
438
- var WrappedComponent = function WrappedComponent(props) {
431
+ let propKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'imageRegexData';
432
+ return Component => {
433
+ const WrappedComponent = props => {
439
434
  useWarning(false, "@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'withProjectExtensionImageRegex' high order component anymore. Please use the 'useProjectExtensionImageRegex' hook instead.");
440
- var imageregexContext = useProjectExtensionImageRegex();
435
+ const imageregexContext = useProjectExtensionImageRegex();
441
436
  return jsx(GetProjectExtensionImageRegex, {
442
- render: function render() {
443
- return jsx(Component, _objectSpread(_objectSpread({}, props), _defineProperty({}, propKey, imageregexContext)));
444
- }
437
+ render: () => jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
438
+ [propKey]: imageregexContext
439
+ }))
445
440
  });
446
441
  };
447
442
 
@@ -1,6 +1,6 @@
1
+ import { ComponentType, ReactNode } from 'react';
1
2
  import type { ApplicationWindow } from '@commercetools-frontend/constants';
2
3
  import type { TFetchLoggedInUserQuery, TFetchProjectQuery, TIdTokenUserInfo } from '../../types/generated/mc';
3
- import { ComponentType, ReactNode } from 'react';
4
4
  type TFetchedUser = TFetchLoggedInUserQuery['user'];
5
5
  type TFetchedProject = TFetchProjectQuery['project'];
6
6
  type TApplicationContextPermissions = {
@@ -43,13 +43,9 @@ export declare const mapEnvironmentToApplicationContextEnvironment: <AdditionalE
43
43
  mcApiUrl: string;
44
44
  frontendHost: string;
45
45
  servedByProxy: boolean;
46
- mcProxyApiUrl?: string | undefined;
47
46
  ldClientSideId?: string | undefined;
48
47
  trackingSentry?: string | undefined;
49
48
  trackingGtm?: string | undefined;
50
- enableSignUp?: boolean | undefined;
51
- enableLongLivedFeatureFlags?: boolean | undefined;
52
- useFullRedirectsForLinks?: boolean | undefined;
53
49
  __DEVELOPMENT__?: {
54
50
  oidc?: import("@commercetools-frontend/constants").ApplicationOidcForDevelopmentConfig | undefined;
55
51
  menuLinks?: import("@commercetools-frontend/constants").ApplicationMenuLinksForDevelopmentConfig | undefined;
@@ -65,13 +61,9 @@ export declare const mapEnvironmentToApplicationContextEnvironment: <AdditionalE
65
61
  cdnUrl: string;
66
62
  frontendHost: string;
67
63
  servedByProxy: boolean;
68
- mcProxyApiUrl?: string | undefined;
69
64
  ldClientSideId?: string | undefined;
70
65
  trackingSentry?: string | undefined;
71
66
  trackingGtm?: string | undefined;
72
- enableSignUp?: boolean | undefined;
73
- enableLongLivedFeatureFlags?: boolean | undefined;
74
- useFullRedirectsForLinks?: boolean | undefined;
75
67
  __DEVELOPMENT__?: {
76
68
  oidc?: import("@commercetools-frontend/constants").ApplicationOidcForDevelopmentConfig | undefined;
77
69
  menuLinks?: import("@commercetools-frontend/constants").ApplicationMenuLinksForDevelopmentConfig | undefined;
@@ -1,5 +1,5 @@
1
- import type { TImageRegexOptions } from '../../types/generated/settings';
2
1
  import { type ComponentType, type ReactNode } from 'react';
2
+ import type { TImageRegexOptions } from '../../types/generated/settings';
3
3
  export type TImageRegexContext = {
4
4
  isLoading: boolean;
5
5
  imageRegex?: {
@@ -90,7 +90,7 @@ export type TIdTokenUserInfo = {
90
90
  aud: Scalars['String'];
91
91
  email?: Maybe<Scalars['String']>;
92
92
  exp: Scalars['Float'];
93
- iat: Scalars['Float'];
93
+ iat?: Maybe<Scalars['Float']>;
94
94
  iss: Scalars['String'];
95
95
  name?: Maybe<Scalars['String']>;
96
96
  sub: Scalars['String'];
@@ -605,7 +605,7 @@ export type TAmILoggedInQuery = {
605
605
  amILoggedIn: boolean;
606
606
  };
607
607
  export type TFetchProjectQueryVariables = Exact<{
608
- projectKey: Scalars['String'];
608
+ projectKey?: InputMaybe<Scalars['String']>;
609
609
  }>;
610
610
  export type TFetchProjectQuery = {
611
611
  __typename?: 'Query';
@@ -725,7 +725,7 @@ export type TFetchLoggedInUserQuery = {
725
725
  sub: string;
726
726
  aud: string;
727
727
  exp: number;
728
- iat: number;
728
+ iat?: number | null;
729
729
  email?: string | null;
730
730
  name?: string | null;
731
731
  additionalClaims?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-shell-connectors",
3
- "version": "21.23.10",
3
+ "version": "21.24.1",
4
4
  "description": "Contains complementary tools for @commercetools-frontend/application-shell",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -23,9 +23,9 @@
23
23
  "dependencies": {
24
24
  "@babel/runtime": "^7.20.13",
25
25
  "@babel/runtime-corejs3": "^7.20.13",
26
- "@commercetools-frontend/constants": "21.23.10",
27
- "@commercetools-frontend/sentry": "21.23.10",
28
- "@emotion/react": "11.10.5",
26
+ "@commercetools-frontend/constants": "21.24.1",
27
+ "@commercetools-frontend/sentry": "21.24.1",
28
+ "@emotion/react": "11.10.6",
29
29
  "@types/lodash": "^4.14.191",
30
30
  "@types/prop-types": "^15.7.5",
31
31
  "@types/react": "^17.0.53",
@@ -36,7 +36,7 @@
36
36
  "tiny-warning": "1.0.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@apollo/client": "3.7.7",
39
+ "@apollo/client": "3.7.10",
40
40
  "@testing-library/react": "12.1.5",
41
41
  "react": "17.0.2"
42
42
  },
@@ -28,8 +28,8 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
28
28
 
29
29
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
30
30
  var FetchProjectExtensionImageRegex = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProjectExtensionImageRegex" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "projectExtension" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "imageRegex" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "thumb" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "small" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "ImageRegex" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ImageRegexOptions" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "flag" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "search" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "replace" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 256, source: { body: "query FetchProjectExtensionImageRegex {\n projectExtension {\n id\n imageRegex {\n thumb {\n ...ImageRegex\n }\n small {\n ...ImageRegex\n }\n }\n }\n}\nfragment ImageRegex on ImageRegexOptions {\n flag\n search\n replace\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
31
- var createGraphqlResponseForProjectExtensionImageRegexQuery = function createGraphqlResponseForProjectExtensionImageRegexQuery() {
32
- var customResponse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
+ const createGraphqlResponseForProjectExtensionImageRegexQuery = function () {
32
+ let customResponse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
33
  return _objectSpread({
34
34
  projectExtension: {
35
35
  __typename: 'ProjectExtension',
@@ -52,8 +52,8 @@ var createGraphqlResponseForProjectExtensionImageRegexQuery = function createGra
52
52
  }
53
53
  }, customResponse);
54
54
  };
55
- var createFetchProjectExtensionImageRegexMock = function createFetchProjectExtensionImageRegexMock() {
56
- var customMock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
55
+ const createFetchProjectExtensionImageRegexMock = function () {
56
+ let customMock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
57
57
  return _objectSpread({
58
58
  request: {
59
59
  query: FetchProjectExtensionImageRegex,
@@ -28,8 +28,8 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
28
28
 
29
29
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
30
30
  var FetchProjectExtensionImageRegex = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProjectExtensionImageRegex" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "projectExtension" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "imageRegex" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "thumb" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "small" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "ImageRegex" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ImageRegexOptions" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "flag" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "search" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "replace" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 256, source: { body: "query FetchProjectExtensionImageRegex {\n projectExtension {\n id\n imageRegex {\n thumb {\n ...ImageRegex\n }\n small {\n ...ImageRegex\n }\n }\n }\n}\nfragment ImageRegex on ImageRegexOptions {\n flag\n search\n replace\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
31
- var createGraphqlResponseForProjectExtensionImageRegexQuery = function createGraphqlResponseForProjectExtensionImageRegexQuery() {
32
- var customResponse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
+ const createGraphqlResponseForProjectExtensionImageRegexQuery = function () {
32
+ let customResponse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
33
  return _objectSpread({
34
34
  projectExtension: {
35
35
  __typename: 'ProjectExtension',
@@ -52,8 +52,8 @@ var createGraphqlResponseForProjectExtensionImageRegexQuery = function createGra
52
52
  }
53
53
  }, customResponse);
54
54
  };
55
- var createFetchProjectExtensionImageRegexMock = function createFetchProjectExtensionImageRegexMock() {
56
- var customMock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
55
+ const createFetchProjectExtensionImageRegexMock = function () {
56
+ let customMock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
57
57
  return _objectSpread({
58
58
  request: {
59
59
  query: FetchProjectExtensionImageRegex,