@commercetools-frontend/application-shell-connectors 22.30.2 → 22.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commercetools-frontend-application-shell-connectors.cjs.dev.js +45 -62
- package/dist/commercetools-frontend-application-shell-connectors.cjs.prod.js +42 -58
- package/dist/commercetools-frontend-application-shell-connectors.esm.js +45 -61
- package/dist/declarations/src/components/application-context/application-context.d.ts +10 -0
- package/dist/declarations/src/components/application-context/normalizers.d.ts +18 -0
- package/dist/declarations/src/types/generated/mc.d.ts +5 -0
- package/dist/declarations/src/types/generated/settings.d.ts +22 -0
- package/dist/declarations/src/utils/http-client.d.ts +76 -0
- package/package.json +5 -5
|
@@ -12,7 +12,6 @@ import { createContext, useContext, useMemo, useEffect } from 'react';
|
|
|
12
12
|
import moment from 'moment-timezone';
|
|
13
13
|
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
14
14
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
15
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
16
15
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
17
16
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
18
17
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
@@ -46,7 +45,7 @@ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringif
|
|
|
46
45
|
import { RetryLink } from '@apollo/client/link/retry';
|
|
47
46
|
|
|
48
47
|
// NOTE: This string will be replaced on build time with the package version.
|
|
49
|
-
var version = "22.
|
|
48
|
+
var version = "22.31.0";
|
|
50
49
|
|
|
51
50
|
// From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
|
|
52
51
|
const getDisplayName = Component => {
|
|
@@ -68,10 +67,9 @@ const getMcOriginTld = host => {
|
|
|
68
67
|
return host.replace(mcHostnameRegex, '$3');
|
|
69
68
|
};
|
|
70
69
|
const getMcApiUrlFromOrigin = origin => {
|
|
71
|
-
var _context;
|
|
72
70
|
const url = new _URL(origin);
|
|
73
71
|
const originTld = getMcOriginTld(url.host);
|
|
74
|
-
return
|
|
72
|
+
return `${url.protocol}//mc-api.${originTld}`;
|
|
75
73
|
};
|
|
76
74
|
const parseAsBoolean = value => value === true || value === 'true';
|
|
77
75
|
function getMcApiUrl() {
|
|
@@ -303,9 +301,9 @@ const createApplicationContext = (environment, user, project, projectDataLocale)
|
|
|
303
301
|
environment: mapEnvironmentToApplicationContextEnvironment(environment),
|
|
304
302
|
user: mapUserToApplicationContextUser(user),
|
|
305
303
|
project: mapProjectToApplicationContextProject(project),
|
|
306
|
-
permissions: normalizeAllAppliedPermissions(project
|
|
307
|
-
actionRights: normalizeAllAppliedActionRights(project
|
|
308
|
-
dataFences: normalizeAllAppliedDataFences(project
|
|
304
|
+
permissions: normalizeAllAppliedPermissions(project?.allAppliedPermissions),
|
|
305
|
+
actionRights: normalizeAllAppliedActionRights(project?.allAppliedActionRights),
|
|
306
|
+
dataFences: normalizeAllAppliedDataFences(project?.allAppliedDataFences),
|
|
309
307
|
dataLocale: projectDataLocale || null
|
|
310
308
|
});
|
|
311
309
|
const ApplicationContextProvider = props => jsx(Context$2.Provider, {
|
|
@@ -341,7 +339,7 @@ function withApplicationContext(mapApplicationContextToProps) {
|
|
|
341
339
|
return jsx(Component, _objectSpread$6(_objectSpread$6({}, props), mappedProps));
|
|
342
340
|
}
|
|
343
341
|
});
|
|
344
|
-
WrappedComponent.displayName =
|
|
342
|
+
WrappedComponent.displayName = `withApplicationContext(${getDisplayName(Component)})`;
|
|
345
343
|
return WrappedComponent;
|
|
346
344
|
};
|
|
347
345
|
}
|
|
@@ -450,7 +448,7 @@ ProjectExtensionProviderForImageRegex.propTypes = process.env.NODE_ENV !== "prod
|
|
|
450
448
|
} : {};
|
|
451
449
|
ProjectExtensionProviderForImageRegex.displayName = 'ProjectExtensionProviderForImageRegex';
|
|
452
450
|
const GetProjectExtensionImageRegex = props => {
|
|
453
|
-
useWarning(false,
|
|
451
|
+
useWarning(false, `@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'GetProjectExtensionImageRegex' anymore. Please use the 'useProjectExtensionImageRegex' hook instead.`);
|
|
454
452
|
return jsx(Context.Consumer, {
|
|
455
453
|
children: imageRegexContext => props.render(imageRegexContext)
|
|
456
454
|
});
|
|
@@ -463,7 +461,7 @@ function withProjectExtensionImageRegex() {
|
|
|
463
461
|
let propKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'imageRegexData';
|
|
464
462
|
return Component => {
|
|
465
463
|
const WrappedComponent = props => {
|
|
466
|
-
useWarning(false,
|
|
464
|
+
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.`);
|
|
467
465
|
const imageregexContext = useProjectExtensionImageRegex();
|
|
468
466
|
return jsx(GetProjectExtensionImageRegex, {
|
|
469
467
|
render: () => jsx(Component, _objectSpread$4(_objectSpread$4({}, props), {}, {
|
|
@@ -471,7 +469,7 @@ function withProjectExtensionImageRegex() {
|
|
|
471
469
|
}))
|
|
472
470
|
});
|
|
473
471
|
};
|
|
474
|
-
WrappedComponent.displayName =
|
|
472
|
+
WrappedComponent.displayName = `withProjectExtensionImageRegex(${getDisplayName(Component)})`;
|
|
475
473
|
return WrappedComponent;
|
|
476
474
|
};
|
|
477
475
|
}
|
|
@@ -492,8 +490,8 @@ const forwardTokenRetryHeader = headers => _objectSpread$3(_objectSpread$3({}, h
|
|
|
492
490
|
// so that the MC BE can issue a new token.
|
|
493
491
|
// NOTE: the retry is not meant to work for the MC access token.
|
|
494
492
|
const getDoesGraphQLTargetSupportTokenRetry = context => {
|
|
495
|
-
var _context
|
|
496
|
-
const graphQLTarget =
|
|
493
|
+
var _context;
|
|
494
|
+
const graphQLTarget = context.headers?.[SUPPORTED_HEADERS.X_GRAPHQL_TARGET] || context.headers?.[SUPPORTED_HEADERS.X_GRAPHQL_TARGET.toLowerCase()];
|
|
497
495
|
return Boolean(graphQLTarget && _includesInstanceProperty(_context = [GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM, GRAPHQL_TARGETS.ADMINISTRATION_SERVICE, GRAPHQL_TARGETS.SETTINGS_SERVICE, GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND]).call(_context, graphQLTarget));
|
|
498
496
|
};
|
|
499
497
|
const isHttpError = error => error.statusCode !== undefined || error.statusCode !== undefined;
|
|
@@ -507,7 +505,7 @@ const errorLink = onError(_ref => {
|
|
|
507
505
|
operation = _ref.operation,
|
|
508
506
|
forward = _ref.forward;
|
|
509
507
|
if (networkError && isHttpError(networkError) && networkError.statusCode === STATUS_CODES.UNAUTHORIZED) {
|
|
510
|
-
history.push(
|
|
508
|
+
history.push(`/logout?reason=${LOGOUT_REASONS.UNAUTHORIZED}`);
|
|
511
509
|
return;
|
|
512
510
|
}
|
|
513
511
|
|
|
@@ -519,8 +517,7 @@ const errorLink = onError(_ref => {
|
|
|
519
517
|
if (graphQLErrors && isGraphQLError(graphQLErrors)) {
|
|
520
518
|
const context = operation.getContext();
|
|
521
519
|
for (const err of graphQLErrors) {
|
|
522
|
-
|
|
523
|
-
const isNonAuthenticatedViaExtensionCode = (err === null || err === void 0 || (_err$extensions = err.extensions) === null || _err$extensions === void 0 ? void 0 : _err$extensions.code) === 'UNAUTHENTICATED';
|
|
520
|
+
const isNonAuthenticatedViaExtensionCode = err?.extensions?.code === 'UNAUTHENTICATED';
|
|
524
521
|
/**
|
|
525
522
|
* NOTE:
|
|
526
523
|
* Not not all GraphQL APIs expose an `extensions` field in
|
|
@@ -528,7 +525,7 @@ const errorLink = onError(_ref => {
|
|
|
528
525
|
* property until they introduced support for the `extensions`
|
|
529
526
|
* field.
|
|
530
527
|
*/
|
|
531
|
-
const isNonAuthenticatedViaCode =
|
|
528
|
+
const isNonAuthenticatedViaCode = err?.message === 'invalid_token';
|
|
532
529
|
if ((isNonAuthenticatedViaExtensionCode || isNonAuthenticatedViaCode) && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
533
530
|
operation.setContext(_ref2 => {
|
|
534
531
|
let headers = _ref2.headers;
|
|
@@ -546,8 +543,7 @@ const errorLink = onError(_ref => {
|
|
|
546
543
|
|
|
547
544
|
// Attempt to load the `teamId` from sessionStorage
|
|
548
545
|
function selectTeamIdFromStorage() {
|
|
549
|
-
|
|
550
|
-
return window.sessionStorage.getItem(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);
|
|
546
|
+
return window.sessionStorage.getItem(STORAGE_KEYS.ACTIVE_TEAM_ID) || window.app.__DEVELOPMENT__?.oidc?.teamId;
|
|
551
547
|
}
|
|
552
548
|
|
|
553
549
|
const staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account'];
|
|
@@ -608,7 +604,7 @@ function getCorrelationId() {
|
|
|
608
604
|
|
|
609
605
|
const createApolloContextForProxyForwardTo = proxyForwardTocontext => ({
|
|
610
606
|
// Send the request to the forward-to endpoint.
|
|
611
|
-
uri:
|
|
607
|
+
uri: `${getMcApiUrl()}/proxy/forward-to`,
|
|
612
608
|
// Custom properties to be used by the "header-link".
|
|
613
609
|
forwardToConfig: proxyForwardTocontext,
|
|
614
610
|
skipGraphQlTargetCheck: true
|
|
@@ -645,7 +641,7 @@ const logger = {
|
|
|
645
641
|
const getSessionToken = () => window.sessionStorage.getItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
646
642
|
const setActiveSession = sessionToken => {
|
|
647
643
|
if (!sessionToken) return;
|
|
648
|
-
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_TOKEN, sessionToken
|
|
644
|
+
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_TOKEN, sessionToken ?? '');
|
|
649
645
|
window.localStorage.setItem(STORAGE_KEYS.LOGIN_STRATEGY, LOGIN_STRATEGY_OIDC);
|
|
650
646
|
// Remove flag for original workflow
|
|
651
647
|
window.localStorage.removeItem(STORAGE_KEYS.IS_AUTHENTICATED);
|
|
@@ -667,8 +663,7 @@ const setSessionScope = scope => {
|
|
|
667
663
|
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, scope);
|
|
668
664
|
};
|
|
669
665
|
const getSessionState = stateId => {
|
|
670
|
-
|
|
671
|
-
const sessionStateKey = _concatInstanceProperty(_context = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context, stateId);
|
|
666
|
+
const sessionStateKey = `${STORAGE_KEYS.NONCE}_${stateId}`;
|
|
672
667
|
const unparsedSessionState = window.sessionStorage.getItem(sessionStateKey);
|
|
673
668
|
if (unparsedSessionState) {
|
|
674
669
|
try {
|
|
@@ -676,22 +671,19 @@ const getSessionState = stateId => {
|
|
|
676
671
|
return parsedSessionState;
|
|
677
672
|
} catch (error) {
|
|
678
673
|
if (process.env.NODE_ENV !== 'production') {
|
|
679
|
-
var _context2;
|
|
680
674
|
// eslint-disable-next-line no-console
|
|
681
|
-
console.warn(
|
|
675
|
+
console.warn(`Cannot parse session state for "${sessionStateKey}".\n${unparsedSessionState}`);
|
|
682
676
|
}
|
|
683
677
|
}
|
|
684
678
|
}
|
|
685
679
|
return null;
|
|
686
680
|
};
|
|
687
681
|
const setSessionState = (stateId, state) => {
|
|
688
|
-
|
|
689
|
-
const sessionStateKey = _concatInstanceProperty(_context3 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context3, stateId);
|
|
682
|
+
const sessionStateKey = `${STORAGE_KEYS.NONCE}_${stateId}`;
|
|
690
683
|
window.sessionStorage.setItem(sessionStateKey, _JSON$stringify(state));
|
|
691
684
|
};
|
|
692
685
|
const removeSessionState = stateId => {
|
|
693
|
-
|
|
694
|
-
const sessionStateKey = _concatInstanceProperty(_context4 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context4, stateId);
|
|
686
|
+
const sessionStateKey = `${STORAGE_KEYS.NONCE}_${stateId}`;
|
|
695
687
|
window.sessionStorage.removeItem(sessionStateKey);
|
|
696
688
|
};
|
|
697
689
|
|
|
@@ -713,7 +705,7 @@ var oidcStorage = /*#__PURE__*/Object.freeze({
|
|
|
713
705
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
714
706
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
715
707
|
function ownKeys$2(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
716
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
708
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$2(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$2(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
717
709
|
const defaultUserAgent = createHttpUserAgent({
|
|
718
710
|
name: 'unknown-http-client',
|
|
719
711
|
libraryName: typeof window !== 'undefined' ? window.app.applicationName : 'unknown-application-name'
|
|
@@ -721,50 +713,48 @@ const defaultUserAgent = createHttpUserAgent({
|
|
|
721
713
|
const defaultForwardToVersion = 'v2';
|
|
722
714
|
const defaultForwardToAudiencePolicy = 'forward-url-full-path';
|
|
723
715
|
function buildApiUrl(endpoint) {
|
|
724
|
-
var _context;
|
|
725
716
|
const apiUrl = getMcApiUrl().replace(/\/$/, '');
|
|
726
|
-
return
|
|
717
|
+
return `${apiUrl}${endpoint}`;
|
|
727
718
|
}
|
|
728
719
|
const getAppliedForwardToHeaders = forwardToConfig => {
|
|
729
|
-
var
|
|
720
|
+
var _context;
|
|
730
721
|
if (!forwardToConfig) {
|
|
731
722
|
return {};
|
|
732
723
|
}
|
|
733
724
|
if (!forwardToConfig.uri) {
|
|
734
|
-
throw new Error(
|
|
725
|
+
throw new Error(`Missing required "uri" option.`);
|
|
735
726
|
}
|
|
736
727
|
const exchangeTokenClaims = [];
|
|
737
728
|
if (forwardToConfig.includeUserPermissions) {
|
|
738
729
|
exchangeTokenClaims.push('permissions');
|
|
739
730
|
}
|
|
740
|
-
return _objectSpread$2(_objectSpread$2({}, _reduceInstanceProperty(
|
|
731
|
+
return _objectSpread$2(_objectSpread$2({}, _reduceInstanceProperty(_context = _Object$entries(forwardToConfig.headers ?? {})).call(_context, (customForwardHeaders, _ref) => {
|
|
741
732
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
742
733
|
headerName = _ref2[0],
|
|
743
734
|
headerValue = _ref2[1];
|
|
744
735
|
return _objectSpread$2(_objectSpread$2({}, customForwardHeaders), {}, {
|
|
745
736
|
// Prefix headers so that the MC API can allow and forward them.
|
|
746
|
-
[
|
|
737
|
+
[`x-forward-header-${headerName}`]: headerValue
|
|
747
738
|
});
|
|
748
739
|
}, {})), {}, {
|
|
749
|
-
[SUPPORTED_HEADERS.ACCEPT_VERSION]:
|
|
740
|
+
[SUPPORTED_HEADERS.ACCEPT_VERSION]: forwardToConfig.version ?? defaultForwardToVersion,
|
|
750
741
|
[SUPPORTED_HEADERS.X_FORWARD_TO]: forwardToConfig.uri,
|
|
751
|
-
[SUPPORTED_HEADERS.X_FORWARD_TO_AUDIENCE_POLICY]:
|
|
742
|
+
[SUPPORTED_HEADERS.X_FORWARD_TO_AUDIENCE_POLICY]: forwardToConfig.audiencePolicy ?? defaultForwardToAudiencePolicy,
|
|
752
743
|
[SUPPORTED_HEADERS.X_FORWARD_TO_CLAIMS]: exchangeTokenClaims.join(' ')
|
|
753
744
|
});
|
|
754
745
|
};
|
|
755
746
|
function createHttpClientOptions() {
|
|
756
|
-
var _config$projectKey;
|
|
757
747
|
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
758
748
|
const sessionToken = getSessionToken();
|
|
759
|
-
const projectKey =
|
|
749
|
+
const projectKey = config.projectKey ?? selectProjectKeyFromUrl();
|
|
760
750
|
const userId = selectUserId();
|
|
761
|
-
const userAgent =
|
|
751
|
+
const userAgent = config?.userAgent || defaultUserAgent;
|
|
762
752
|
return {
|
|
763
753
|
credentials: 'include',
|
|
764
754
|
headers: omitEmpty(_objectSpread$2(_objectSpread$2({}, config.headers), {}, {
|
|
765
755
|
// Required headers
|
|
766
756
|
[SUPPORTED_HEADERS.ACCEPT]: 'application/json',
|
|
767
|
-
[SUPPORTED_HEADERS.AUTHORIZATION]: sessionToken ?
|
|
757
|
+
[SUPPORTED_HEADERS.AUTHORIZATION]: sessionToken ? `Bearer ${sessionToken}` : undefined,
|
|
768
758
|
[SUPPORTED_HEADERS.X_APPLICATION_ID]: window.app.applicationIdentifier,
|
|
769
759
|
[SUPPORTED_HEADERS.X_CUSTOM_VIEW_ID]: window.app.customViewId,
|
|
770
760
|
[SUPPORTED_HEADERS.X_CORRELATION_ID]: getCorrelationId({
|
|
@@ -803,7 +793,7 @@ async function executeHttpClientRequest(fetcher) {
|
|
|
803
793
|
}))
|
|
804
794
|
}));
|
|
805
795
|
if (response.statusCode === STATUS_CODES.UNAUTHORIZED) {
|
|
806
|
-
throw new RenewTokenError(
|
|
796
|
+
throw new RenewTokenError(`Unauthorized response, attempting retry.`);
|
|
807
797
|
}
|
|
808
798
|
|
|
809
799
|
// In case a new session token is returned from the server, save it.
|
|
@@ -827,7 +817,7 @@ async function executeHttpClientRequest(fetcher) {
|
|
|
827
817
|
}
|
|
828
818
|
|
|
829
819
|
function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
830
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
820
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$1(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$1(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
831
821
|
const userAgent = createHttpUserAgent({
|
|
832
822
|
name: 'apollo-client',
|
|
833
823
|
// version: apolloVersion,
|
|
@@ -842,18 +832,13 @@ const isKnownGraphQlTarget = target => {
|
|
|
842
832
|
return target ? _includesInstanceProperty(_context = _Object$values(GRAPHQL_TARGETS)).call(_context, target) : false;
|
|
843
833
|
};
|
|
844
834
|
const extractSessionTokenFromResponse = context => {
|
|
845
|
-
|
|
846
|
-
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');
|
|
835
|
+
const refreshedSessionToken = context.response?.headers?.get('x-refreshed-session-token');
|
|
847
836
|
if (refreshedSessionToken) {
|
|
848
|
-
return refreshedSessionToken
|
|
837
|
+
return refreshedSessionToken ?? null;
|
|
849
838
|
}
|
|
850
|
-
const restResponseWithRefreshTokenHeader =
|
|
851
|
-
var _response$headers;
|
|
852
|
-
return (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.has('x-refreshed-session-token');
|
|
853
|
-
});
|
|
839
|
+
const restResponseWithRefreshTokenHeader = context.restResponses?.find(response => response.headers?.has('x-refreshed-session-token'));
|
|
854
840
|
if (restResponseWithRefreshTokenHeader) {
|
|
855
|
-
|
|
856
|
-
return (_restResponseWithRefr = restResponseWithRefreshTokenHeader.headers.get('x-refreshed-session-token')) !== null && _restResponseWithRefr !== void 0 ? _restResponseWithRefr : null;
|
|
841
|
+
return restResponseWithRefreshTokenHeader.headers.get('x-refreshed-session-token') ?? null;
|
|
857
842
|
}
|
|
858
843
|
return null;
|
|
859
844
|
};
|
|
@@ -861,11 +846,11 @@ const extractSessionTokenFromResponse = context => {
|
|
|
861
846
|
/* eslint-disable import/prefer-default-export */
|
|
862
847
|
// Use a middleware to update the request headers with the correct params.
|
|
863
848
|
const headerLink = new ApolloLink((operation, forward) => {
|
|
864
|
-
var _context2
|
|
849
|
+
var _context2;
|
|
865
850
|
const apolloContext = operation.getContext();
|
|
866
851
|
const variables = operation.variables;
|
|
867
852
|
const graphQlTarget = apolloContext.target || variables.target;
|
|
868
|
-
if (!apolloContext.skipGraphQlTargetCheck && !isKnownGraphQlTarget(graphQlTarget)) throw new Error(
|
|
853
|
+
if (!apolloContext.skipGraphQlTargetCheck && !isKnownGraphQlTarget(graphQlTarget)) throw new Error(`GraphQL target "${graphQlTarget}" is missing (or is not supported) in operation "${operation.operationName}"`);
|
|
869
854
|
|
|
870
855
|
/**
|
|
871
856
|
* NOTE:
|
|
@@ -892,7 +877,7 @@ const headerLink = new ApolloLink((operation, forward) => {
|
|
|
892
877
|
forwardToConfig: apolloContext.forwardToConfig,
|
|
893
878
|
projectKey
|
|
894
879
|
}));
|
|
895
|
-
return _mapInstanceProperty(
|
|
880
|
+
return _mapInstanceProperty(_context2 = forward(operation)).call(_context2, response => {
|
|
896
881
|
const context = operation.getContext();
|
|
897
882
|
const refreshedSessionToken = extractSessionTokenFromResponse(context);
|
|
898
883
|
if (refreshedSessionToken) {
|
|
@@ -905,7 +890,7 @@ const headerLink = new ApolloLink((operation, forward) => {
|
|
|
905
890
|
const tokenRetryLink = new RetryLink({
|
|
906
891
|
attempts: (count, operation, error) => {
|
|
907
892
|
const context = operation.getContext();
|
|
908
|
-
if (
|
|
893
|
+
if (error?.statusCode === STATUS_CODES.UNAUTHORIZED && count === 1 && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
909
894
|
operation.setContext(_ref => {
|
|
910
895
|
let headers = _ref.headers;
|
|
911
896
|
return {
|
|
@@ -923,7 +908,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
923
908
|
const createApolloLink = function () {
|
|
924
909
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
925
910
|
const httpLink = createHttpLink({
|
|
926
|
-
uri:
|
|
911
|
+
uri: `${getMcApiUrl()}/graphql`,
|
|
927
912
|
fetch
|
|
928
913
|
});
|
|
929
914
|
|
|
@@ -967,9 +952,8 @@ const mergeArraysObjects = function () {
|
|
|
967
952
|
}, []);
|
|
968
953
|
};
|
|
969
954
|
const createApolloClient = function () {
|
|
970
|
-
var _options$cache, _customCacheConfig$ty;
|
|
971
955
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
972
|
-
const customCacheConfig =
|
|
956
|
+
const customCacheConfig = options?.cache ?? {};
|
|
973
957
|
return new ApolloClient({
|
|
974
958
|
link: createApolloLink(options),
|
|
975
959
|
// https://www.apollographql.com/docs/react/caching/cache-configuration/
|
|
@@ -1008,7 +992,7 @@ const createApolloClient = function () {
|
|
|
1008
992
|
}
|
|
1009
993
|
}
|
|
1010
994
|
}
|
|
1011
|
-
},
|
|
995
|
+
}, customCacheConfig.typePolicies ?? {})
|
|
1012
996
|
}))
|
|
1013
997
|
});
|
|
1014
998
|
};
|
|
@@ -20,6 +20,16 @@ type TApplicationContextGroupedByPermission = {
|
|
|
20
20
|
type TApplicationContextGroupedByResourceType = {
|
|
21
21
|
[key: string]: TApplicationContextGroupedByPermission | null;
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* dataFence: {
|
|
25
|
+
* store: {
|
|
26
|
+
* orders: {
|
|
27
|
+
* canManageOrders: { values: ['usa', 'germany'] },
|
|
28
|
+
* canViewOrders: { values: ['canada'] },
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
23
33
|
type TApplicationContextDataFenceType = 'store';
|
|
24
34
|
type TApplicationContextDataFences = Partial<Record<TApplicationContextDataFenceType, TApplicationContextGroupedByResourceType>>;
|
|
25
35
|
type TApplicationContextEnvironment = ApplicationWindow['app'];
|
|
@@ -24,6 +24,24 @@ export type TDataFenceStoresGroupByResourceType = {
|
|
|
24
24
|
};
|
|
25
25
|
export type TDataFenceType = 'store';
|
|
26
26
|
export type TDataFences = Partial<Record<TDataFenceType, TDataFenceGroupedByResourceType>>;
|
|
27
|
+
/**
|
|
28
|
+
* NOTE:
|
|
29
|
+
*
|
|
30
|
+
* Permissions and menu visibilities are being fetched though the `allAppliedPermissions`
|
|
31
|
+
* and the `allAppliedMenuVisibilities` which both return an array of `{ name: string, value: boolean }`.
|
|
32
|
+
* This gives more flexibility to introduce new values to apps without having to release
|
|
33
|
+
* the merchant-center-app-kit by adding/exposing them from the mc-be (our proxy service).
|
|
34
|
+
*
|
|
35
|
+
* The application below however expects both permissions an menu visibilities to be of the shape
|
|
36
|
+
* `[name: string]: boolean` which is what the shape above is mapped into here. This object shape is easier
|
|
37
|
+
* to work with in application level code (while be a non breaking change to other packages) as you can just
|
|
38
|
+
* do `canViewProducts`.
|
|
39
|
+
*
|
|
40
|
+
* This function considering its concern belongs into the `permissions` package. However,
|
|
41
|
+
* for now it doesn't have to be shared and as a result can be co-located with
|
|
42
|
+
* the fetching logic. Given this mapping needs to be used elsewere feel free
|
|
43
|
+
* to move this over to `permissions` and export it there.
|
|
44
|
+
*/
|
|
27
45
|
export declare const normalizeAllAppliedPermissions: (allAppliedPermissions?: TAppliedPermission[]) => TPermissions | null;
|
|
28
46
|
export declare const normalizeAllAppliedMenuVisibilities: (allAppliedMenuVisibilities?: TAppliedMenuVisibilities[]) => TMenuVisibilities | null;
|
|
29
47
|
export declare const normalizeAllAppliedActionRights: (allAppliedActionRights?: TAppliedActionRight[]) => TActionRights | null;
|
|
@@ -11,6 +11,7 @@ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
|
11
11
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
12
12
|
[SubKey in K]: Maybe<T[SubKey]>;
|
|
13
13
|
};
|
|
14
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
14
15
|
export type Scalars = {
|
|
15
16
|
ID: string;
|
|
16
17
|
String: string;
|
|
@@ -244,6 +245,7 @@ export type TOAuthClientTemplate = {
|
|
|
244
245
|
};
|
|
245
246
|
export type TOrganization = {
|
|
246
247
|
__typename?: 'Organization';
|
|
248
|
+
/** @deprecated This field will be removed in the future. */
|
|
247
249
|
createdAt: Scalars['String'];
|
|
248
250
|
id: Scalars['ID'];
|
|
249
251
|
name: Scalars['String'];
|
|
@@ -267,6 +269,7 @@ export type TProject = TMetaData & {
|
|
|
267
269
|
__typename?: 'Project';
|
|
268
270
|
allAppliedActionRights: Array<TAppliedActionRight>;
|
|
269
271
|
allAppliedDataFences: Array<TAppliedDataFence>;
|
|
272
|
+
/** @deprecated This field has been moved into the menuPermissionsForAllApplications field. */
|
|
270
273
|
allAppliedMenuVisibilities: Array<TAppliedMenuVisibilities>;
|
|
271
274
|
allAppliedPermissions: Array<TAppliedPermission>;
|
|
272
275
|
allPermissionsForAllApplications: TAllPermissionsForAllApplications;
|
|
@@ -521,10 +524,12 @@ export type TUser = TMetaData & {
|
|
|
521
524
|
launchdarklyTrackingId: Scalars['String'];
|
|
522
525
|
launchdarklyTrackingSubgroup?: Maybe<Scalars['String']>;
|
|
523
526
|
launchdarklyTrackingTeam?: Maybe<Array<Scalars['String']>>;
|
|
527
|
+
/** @deprecated This field is replaced by launchdarklyTrackingCloudEnvironment. */
|
|
524
528
|
launchdarklyTrackingTenant: Scalars['String'];
|
|
525
529
|
numberFormat: Scalars['String'];
|
|
526
530
|
projects: TProjectQueryResult;
|
|
527
531
|
timeZone?: Maybe<Scalars['String']>;
|
|
532
|
+
/** @deprecated This field is not used anymore. */
|
|
528
533
|
verificationStatus: TVerificationStatus;
|
|
529
534
|
version?: Maybe<Scalars['Int']>;
|
|
530
535
|
};
|
|
@@ -11,6 +11,7 @@ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
|
11
11
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
12
12
|
[SubKey in K]: Maybe<T[SubKey]>;
|
|
13
13
|
};
|
|
14
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
14
15
|
export type Scalars = {
|
|
15
16
|
ID: string;
|
|
16
17
|
String: string;
|
|
@@ -98,6 +99,7 @@ export type TBusinessUnitsListMyViewTableInput = {
|
|
|
98
99
|
};
|
|
99
100
|
export declare enum TCategoryRecommendationSearchProperty {
|
|
100
101
|
Attribute = "Attribute",
|
|
102
|
+
/** @deprecated The machine learning APIs are not available anymore. */
|
|
101
103
|
MachineLearning = "MachineLearning",
|
|
102
104
|
ProductType = "ProductType"
|
|
103
105
|
}
|
|
@@ -197,11 +199,14 @@ export type TCustomApplicationMenuLink = {
|
|
|
197
199
|
__typename?: 'CustomApplicationMenuLink';
|
|
198
200
|
createdAt: Scalars['DateTime'];
|
|
199
201
|
defaultLabel: Scalars['String'];
|
|
202
|
+
/** @deprecated This field has been moved outside of the menu link. */
|
|
200
203
|
icon: Scalars['String'];
|
|
204
|
+
/** @deprecated This field has been renamed to icon. */
|
|
201
205
|
iconName?: Maybe<Scalars['String']>;
|
|
202
206
|
id: Scalars['ID'];
|
|
203
207
|
labelAllLocales: Array<TLocalizedField>;
|
|
204
208
|
permissions: Array<Scalars['String']>;
|
|
209
|
+
/** @deprecated This field has been moved outside of the menu link and is now a top level field. */
|
|
205
210
|
submenuLinks: Array<TCustomApplicationSubmenuLink>;
|
|
206
211
|
updatedAt: Scalars['DateTime'];
|
|
207
212
|
};
|
|
@@ -295,6 +300,10 @@ export type TCustomViewDraftDataInput = {
|
|
|
295
300
|
locators: Array<Scalars['String']>;
|
|
296
301
|
permissions: Array<TCustomViewPermissionDataInput>;
|
|
297
302
|
type: TCustomViewType;
|
|
303
|
+
/**
|
|
304
|
+
* The value of this property depends on the value of the 'type' property value.
|
|
305
|
+
* In case the `type` value is `CustomPanel`, you are supposed to provide it's size.
|
|
306
|
+
*/
|
|
298
307
|
typeSettings?: InputMaybe<TCustomViewTypeSettingsInput>;
|
|
299
308
|
url: Scalars['String'];
|
|
300
309
|
};
|
|
@@ -694,8 +703,10 @@ export type TMutation = {
|
|
|
694
703
|
deleteProjectSettingsStoresView?: Maybe<TProjectSettingsStoresView>;
|
|
695
704
|
installCustomApplication?: Maybe<TRestrictedCustomApplicationInstallationForOrganization>;
|
|
696
705
|
installCustomView?: Maybe<TRestrictedCustomViewInstallationForOrganization>;
|
|
706
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
697
707
|
moveMessagesFromDeadLetterQueueToMainQueue?: Maybe<TBatchProcessResult>;
|
|
698
708
|
random: Scalars['String'];
|
|
709
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
699
710
|
removeMessagesFromDeadLetterQueue?: Maybe<TBatchProcessResult>;
|
|
700
711
|
sendLinkToVerifyCustomApplicationsMaintainerContactEmail?: Maybe<TCustomApplicationsMaintainerContactEmailVerificationRequest>;
|
|
701
712
|
setCustomApplicationsMaintainerContactInformation?: Maybe<TOrganizationExtension>;
|
|
@@ -1337,6 +1348,7 @@ export type TProductTypeAttributesViewUpdateInput = {
|
|
|
1337
1348
|
};
|
|
1338
1349
|
export type TProjectExtension = {
|
|
1339
1350
|
__typename?: 'ProjectExtension';
|
|
1351
|
+
/** @deprecated Feature not available anymore */
|
|
1340
1352
|
applications: Array<TApplicationExtension>;
|
|
1341
1353
|
categoryRecommendationSettings?: Maybe<TCategoryRecommendationSettings>;
|
|
1342
1354
|
createdAt: Scalars['DateTime'];
|
|
@@ -1409,13 +1421,18 @@ export type TQuery = {
|
|
|
1409
1421
|
activeProductDiscountsCustomView?: Maybe<TDiscountsCustomView>;
|
|
1410
1422
|
activeProductTypeAttributesView?: Maybe<TProductTypeAttributesView>;
|
|
1411
1423
|
activeProjectSettingsStoresView?: Maybe<TProjectSettingsStoresView>;
|
|
1424
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1412
1425
|
allAppliedCustomApplicationPermissions: Array<TCustomApplicationInstallationPermission>;
|
|
1426
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1413
1427
|
allAppliedCustomViewPermissions: Array<TCustomViewInstallationPermission>;
|
|
1428
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1414
1429
|
allCustomApplications: TCustomApplicationsPagedQueryResult;
|
|
1430
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1415
1431
|
allCustomViews: TCustomViewsPagedQueryResult;
|
|
1416
1432
|
allCustomViewsInstallationsByLocator: Array<TRestrictedCustomViewInstallationForProject>;
|
|
1417
1433
|
allCustomViewsLocatorGroups: Array<TCustomViewLocatorGroup>;
|
|
1418
1434
|
allFeatures: Array<TFeature>;
|
|
1435
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1419
1436
|
allOrganizationExtensions: Array<TOrganizationExtension>;
|
|
1420
1437
|
allProjectExtensions: Array<TProjectExtension>;
|
|
1421
1438
|
allPublicCustomApplicationsDevelopedByCommercetools: Array<TPublicCustomApplicationDevelopedByCommercetools>;
|
|
@@ -1423,7 +1440,9 @@ export type TQuery = {
|
|
|
1423
1440
|
businessUnitsListMyViews: Array<Maybe<TBusinessUnitsListMyView>>;
|
|
1424
1441
|
cartDiscountsCustomView?: Maybe<TDiscountsCustomView>;
|
|
1425
1442
|
cartDiscountsCustomViews: Array<Maybe<TDiscountsCustomView>>;
|
|
1443
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1426
1444
|
customApplication?: Maybe<TCustomApplication>;
|
|
1445
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1427
1446
|
customView?: Maybe<TCustomView>;
|
|
1428
1447
|
customersListView?: Maybe<TCustomersListView>;
|
|
1429
1448
|
customersListViews: Array<Maybe<TCustomersListView>>;
|
|
@@ -1433,6 +1452,7 @@ export type TQuery = {
|
|
|
1433
1452
|
dashboardViews: Array<Maybe<TDashboardView>>;
|
|
1434
1453
|
discountCodesCustomView?: Maybe<TDiscountsCustomView>;
|
|
1435
1454
|
discountCodesCustomViews: Array<Maybe<TDiscountsCustomView>>;
|
|
1455
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1436
1456
|
globalOrganizationExtension?: Maybe<TOrganizationExtension>;
|
|
1437
1457
|
myCustomApplications: Array<TMyCustomApplication>;
|
|
1438
1458
|
myCustomViews: Array<TMyCustomView>;
|
|
@@ -1452,6 +1472,7 @@ export type TQuery = {
|
|
|
1452
1472
|
projectExtension?: Maybe<TProjectExtension>;
|
|
1453
1473
|
projectSettingsStoresView?: Maybe<TProjectSettingsStoresView>;
|
|
1454
1474
|
projectSettingsStoresViews: Array<Maybe<TProjectSettingsStoresView>>;
|
|
1475
|
+
/** @deprecated Experimental feature - For internal usage only */
|
|
1455
1476
|
readMessagesFromDeadLetterQueue: Array<TMessage>;
|
|
1456
1477
|
release?: Maybe<Scalars['String']>;
|
|
1457
1478
|
ruleBuilderQuickSelectionValues?: Maybe<Array<Maybe<TRuleBuilderQuickSelectionValues>>>;
|
|
@@ -1602,6 +1623,7 @@ export type TRestrictedCustomApplicationForProject = {
|
|
|
1602
1623
|
icon: Scalars['String'];
|
|
1603
1624
|
id: Scalars['ID'];
|
|
1604
1625
|
mainMenuLink: TCustomApplicationMenuLink;
|
|
1626
|
+
/** @deprecated This field has been renamed to mainMenuLink field. The nested submenuLinks is also now a top level field. */
|
|
1605
1627
|
menuLinks?: Maybe<TCustomApplicationMenuLink>;
|
|
1606
1628
|
name: Scalars['String'];
|
|
1607
1629
|
permissions: Array<TCustomApplicationPermission>;
|
|
@@ -1,27 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains helper functions to configure an HTTP client
|
|
3
|
+
* with the recommended configuration for the Merchant Center API.
|
|
4
|
+
*/
|
|
1
5
|
export type THeaders = Record<string, string>;
|
|
2
6
|
export type TForwardToAudiencePolicy = 'forward-url-full-path' | 'forward-url-origin';
|
|
3
7
|
export type TForwardToExchangeTokenClaim = 'permissions';
|
|
4
8
|
export type TForwardToConfigVersion = 'v1' | 'v2';
|
|
5
9
|
export type TForwardToConfig = {
|
|
10
|
+
/**
|
|
11
|
+
* The URL of the external API to forward the request to.
|
|
12
|
+
*/
|
|
6
13
|
uri: string;
|
|
14
|
+
/**
|
|
15
|
+
* Additional HTTP headers to be included in the request to the external API.
|
|
16
|
+
*/
|
|
7
17
|
headers?: THeaders;
|
|
18
|
+
/**
|
|
19
|
+
* The audience policy for verifying the incoming request from the Merchant Center API.
|
|
20
|
+
*/
|
|
8
21
|
audiencePolicy?: TForwardToAudiencePolicy;
|
|
22
|
+
/**
|
|
23
|
+
* A list of user permissions to be included in the request to the external API.
|
|
24
|
+
*/
|
|
9
25
|
includeUserPermissions?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The version of the `/proxy/forward-to` endpoint to use.
|
|
28
|
+
*/
|
|
10
29
|
version?: TForwardToConfigVersion;
|
|
11
30
|
};
|
|
12
31
|
export type TConfig = {
|
|
32
|
+
/**
|
|
33
|
+
* A custom user agent to identify the HTTP client.
|
|
34
|
+
* We recommend to use the `@commercetools/http-user-agent` package.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* import createHttpUserAgent from '@commercetools/http-user-agent';
|
|
38
|
+
*
|
|
39
|
+
* const userAgent = createHttpUserAgent({
|
|
40
|
+
* name: 'fetch-client',
|
|
41
|
+
* version: '2.6.0',
|
|
42
|
+
* libraryName: window.app.applicationName,
|
|
43
|
+
* contactEmail: 'support@my-company.com',
|
|
44
|
+
* });
|
|
45
|
+
*/
|
|
13
46
|
userAgent?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Additional headers to be included in the request.
|
|
49
|
+
* The provided recommended headers won't be overwritten.
|
|
50
|
+
* See `TOptions.headers`.
|
|
51
|
+
*/
|
|
14
52
|
headers?: THeaders;
|
|
53
|
+
/**
|
|
54
|
+
* Configuration for using the `/proxy/forward-to` endpoint
|
|
55
|
+
* to connect to an external API.
|
|
56
|
+
* {@link https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* {
|
|
60
|
+
* forwardToConfig: {
|
|
61
|
+
* uri: 'https://my-api.com/my-endpoint',
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
15
65
|
forwardToConfig?: TForwardToConfig;
|
|
66
|
+
/**
|
|
67
|
+
* The project key to be assigned to the `x-project-key` header.
|
|
68
|
+
* By default the project key is extracted from the URL.
|
|
69
|
+
* We do not recommend to use this option unless you know what you are doing.
|
|
70
|
+
*/
|
|
16
71
|
projectKey?: string;
|
|
17
72
|
};
|
|
18
73
|
export type TOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* Include user credentials (session token).
|
|
76
|
+
*/
|
|
19
77
|
credentials: 'include';
|
|
78
|
+
/**
|
|
79
|
+
* The HTTP headers included by default are:
|
|
80
|
+
* - Accept
|
|
81
|
+
* - Authorization (only in development)
|
|
82
|
+
* - X-Application-Id
|
|
83
|
+
* - X-Correlation-Id
|
|
84
|
+
* - X-Project-Key
|
|
85
|
+
* - X-User-Agent
|
|
86
|
+
*/
|
|
20
87
|
headers: THeaders;
|
|
21
88
|
};
|
|
22
89
|
export type TFetcherResponse<Data> = {
|
|
90
|
+
/**
|
|
91
|
+
* The parsed response from the server.
|
|
92
|
+
*/
|
|
23
93
|
data: Data;
|
|
94
|
+
/**
|
|
95
|
+
* The HTTP status code from the server response.
|
|
96
|
+
*/
|
|
24
97
|
statusCode: number;
|
|
98
|
+
/**
|
|
99
|
+
* Implement a function to access the HTTP headers from the server response.
|
|
100
|
+
*/
|
|
25
101
|
getHeader: (headerName: string) => string | null;
|
|
26
102
|
};
|
|
27
103
|
export type TFetcher<Data> = (options: TOptions) => Promise<TFetcherResponse<Data>>;
|