@atlaskit/teams-public 0.73.0 → 0.74.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/CHANGELOG.md +19 -0
- package/dist/cjs/next/ui/team-containers/add-container-card/index.compiled.css +0 -2
- package/dist/cjs/next/ui/team-containers/add-container-card/index.js +4 -7
- package/dist/cjs/next/ui/team-containers/team-link-card/index.js +28 -6
- package/dist/es2019/next/ui/team-containers/add-container-card/index.compiled.css +0 -2
- package/dist/es2019/next/ui/team-containers/add-container-card/index.js +4 -7
- package/dist/es2019/next/ui/team-containers/team-link-card/index.js +28 -6
- package/dist/esm/next/ui/team-containers/add-container-card/index.compiled.css +0 -2
- package/dist/esm/next/ui/team-containers/add-container-card/index.js +4 -7
- package/dist/esm/next/ui/team-containers/team-link-card/index.js +28 -6
- package/package.json +9 -5
- package/dist/cjs/common/utils/error/index.js +0 -120
- package/dist/cjs/common/utils/http.js +0 -119
- package/dist/cjs/common/utils/status-code-handlers-provider.js +0 -30
- package/dist/cjs/common/utils/team-id-to-ari.js +0 -10
- package/dist/cjs/common/utils/user-ari.js +0 -16
- package/dist/cjs/ui/team-containers/utils.js +0 -81
- package/dist/es2019/common/utils/error/index.js +0 -87
- package/dist/es2019/common/utils/http.js +0 -82
- package/dist/es2019/common/utils/status-code-handlers-provider.js +0 -25
- package/dist/es2019/common/utils/team-id-to-ari.js +0 -2
- package/dist/es2019/common/utils/user-ari.js +0 -8
- package/dist/es2019/ui/team-containers/utils.js +0 -71
- package/dist/esm/common/utils/error/index.js +0 -117
- package/dist/esm/common/utils/http.js +0 -109
- package/dist/esm/common/utils/status-code-handlers-provider.js +0 -23
- package/dist/esm/common/utils/team-id-to-ari.js +0 -4
- package/dist/esm/common/utils/user-ari.js +0 -10
- package/dist/esm/ui/team-containers/utils.js +0 -74
- package/dist/types/common/utils/error/index.d.ts +0 -59
- package/dist/types/common/utils/http.d.ts +0 -31
- package/dist/types/common/utils/status-code-handlers-provider.d.ts +0 -17
- package/dist/types/common/utils/team-id-to-ari.d.ts +0 -2
- package/dist/types/common/utils/user-ari.d.ts +0 -3
- package/dist/types/ui/team-containers/utils.d.ts +0 -25
- package/dist/types-ts4.5/common/utils/error/index.d.ts +0 -59
- package/dist/types-ts4.5/common/utils/http.d.ts +0 -31
- package/dist/types-ts4.5/common/utils/status-code-handlers-provider.d.ts +0 -17
- package/dist/types-ts4.5/common/utils/team-id-to-ari.d.ts +0 -2
- package/dist/types-ts4.5/common/utils/user-ari.d.ts +0 -3
- package/dist/types-ts4.5/ui/team-containers/utils.d.ts +0 -25
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handleResponse = handleResponse;
|
|
7
|
-
exports.statusCodeHandlersProvider = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Our REST clients are initialised when their module loads which makes it tricky for them to consume the `statusCodeHandlers` prop passed to App from the host application.
|
|
10
|
-
* This is a temporary measure to enable the clients to consume `statusCodeHandlers`.
|
|
11
|
-
* The long term solution is to replace our REST clients with Apollo client custom resolvers
|
|
12
|
-
* This will unify all remote data handling under the apollo-client module which is able to easily receive `statusCodeHandlers` as it is initialised within the React portion of our app.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
var statusCodeHandlersProvider = exports.statusCodeHandlersProvider = {
|
|
16
|
-
handlers: {},
|
|
17
|
-
get: function get() {
|
|
18
|
-
return statusCodeHandlersProvider.handlers;
|
|
19
|
-
},
|
|
20
|
-
setHandlers: function setHandlers(handlers) {
|
|
21
|
-
statusCodeHandlersProvider.handlers = handlers;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function handleResponse(response) {
|
|
25
|
-
var status = response.status;
|
|
26
|
-
var handler = statusCodeHandlersProvider.get()[status];
|
|
27
|
-
if (typeof handler === 'function') {
|
|
28
|
-
handler(response);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.teamIdToAri = exports.ARI_PREFIX = void 0;
|
|
7
|
-
var ARI_PREFIX = exports.ARI_PREFIX = 'ari:cloud:identity::team/';
|
|
8
|
-
var teamIdToAri = exports.teamIdToAri = function teamIdToAri(teamIdOrTeamAri) {
|
|
9
|
-
return teamIdOrTeamAri.startsWith(ARI_PREFIX) ? teamIdOrTeamAri : "".concat(ARI_PREFIX).concat(teamIdOrTeamAri);
|
|
10
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toUserId = exports.isUserARI = void 0;
|
|
7
|
-
var _types = require("../types");
|
|
8
|
-
var isUserARI = exports.isUserARI = function isUserARI(ari) {
|
|
9
|
-
return ari.startsWith(_types.USER_ARI_PREFIX);
|
|
10
|
-
};
|
|
11
|
-
var toUserId = exports.toUserId = function toUserId(ari) {
|
|
12
|
-
if (isUserARI(ari)) {
|
|
13
|
-
return ari.replace(_types.USER_ARI_PREFIX, '');
|
|
14
|
-
}
|
|
15
|
-
throw new Error('Invalid UserARI');
|
|
16
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getCreateContainerTryAgainFlag = exports.getCreateContainerContactSupportFlag = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _reactIntlNext = require("react-intl-next");
|
|
11
|
-
var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
|
|
12
|
-
var _compiled = require("@atlaskit/primitives/compiled");
|
|
13
|
-
var getCreateContainerContactSupportFlag = exports.getCreateContainerContactSupportFlag = function getCreateContainerContactSupportFlag() {
|
|
14
|
-
return {
|
|
15
|
-
id: 'teams-public.team-container.create-container.error.contact-support',
|
|
16
|
-
type: 'error',
|
|
17
|
-
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.noConnectionTitle),
|
|
18
|
-
description: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.noConnectionDescription),
|
|
19
|
-
actions: [{
|
|
20
|
-
content: /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
|
|
21
|
-
alignItems: "center",
|
|
22
|
-
columnGap: "space.100"
|
|
23
|
-
}, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.noConnectionAction), /*#__PURE__*/_react.default.createElement(_linkExternal.default, {
|
|
24
|
-
label: ""
|
|
25
|
-
})),
|
|
26
|
-
href: 'https://support.atlassian.com/contact/#/&support_type=customer'
|
|
27
|
-
}]
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
var getCreateContainerTryAgainFlag = exports.getCreateContainerTryAgainFlag = function getCreateContainerTryAgainFlag(_ref) {
|
|
31
|
-
var tryAgainAction = _ref.tryAgainAction,
|
|
32
|
-
containerType = _ref.containerType;
|
|
33
|
-
return {
|
|
34
|
-
id: 'teams-public.team-container.create-container.error.try-again',
|
|
35
|
-
type: 'error',
|
|
36
|
-
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, messages.timeoutTitle, {
|
|
37
|
-
values: {
|
|
38
|
-
containerType: containerType
|
|
39
|
-
}
|
|
40
|
-
})),
|
|
41
|
-
description: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.timeoutDescription),
|
|
42
|
-
actions: [{
|
|
43
|
-
content: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.timeoutAction),
|
|
44
|
-
onClick: function onClick() {
|
|
45
|
-
tryAgainAction === null || tryAgainAction === void 0 || tryAgainAction();
|
|
46
|
-
}
|
|
47
|
-
}]
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
var messages = (0, _reactIntlNext.defineMessages)({
|
|
51
|
-
timeoutTitle: {
|
|
52
|
-
id: 'teams-public.team-containers.timeout-title',
|
|
53
|
-
defaultMessage: 'We’re couldn’t connect your {containerType}',
|
|
54
|
-
description: 'Title for the timeout flag'
|
|
55
|
-
},
|
|
56
|
-
timeoutDescription: {
|
|
57
|
-
id: 'teams-public.team-containers.timeout-description',
|
|
58
|
-
defaultMessage: 'Something went wrong. Verify your connection and retry.',
|
|
59
|
-
description: 'Description for the timeout flag'
|
|
60
|
-
},
|
|
61
|
-
timeoutAction: {
|
|
62
|
-
id: 'teams-public.team-containers.timeout-action',
|
|
63
|
-
defaultMessage: 'Try again',
|
|
64
|
-
description: 'Action text for the timeout flag'
|
|
65
|
-
},
|
|
66
|
-
noConnectionTitle: {
|
|
67
|
-
id: 'teams-public.team-containers.timeout-no-connection-title',
|
|
68
|
-
defaultMessage: 'Connection failed',
|
|
69
|
-
description: 'Title for the no connection flag'
|
|
70
|
-
},
|
|
71
|
-
noConnectionDescription: {
|
|
72
|
-
id: 'teams-public.team-containers.timeout-no-connection-description',
|
|
73
|
-
defaultMessage: 'Try manually creating the space yourself.',
|
|
74
|
-
description: 'Description for the no connection flag'
|
|
75
|
-
},
|
|
76
|
-
noConnectionAction: {
|
|
77
|
-
id: 'teams-public.team-containers.timeout-no-connection-action',
|
|
78
|
-
defaultMessage: 'Contact support',
|
|
79
|
-
description: 'Action text for the no connection flag'
|
|
80
|
-
}
|
|
81
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
var _GraphQLError;
|
|
3
|
-
export let StatusCode = /*#__PURE__*/function (StatusCode) {
|
|
4
|
-
StatusCode[StatusCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
5
|
-
StatusCode[StatusCode["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
6
|
-
StatusCode[StatusCode["TIMEOUT"] = 408] = "TIMEOUT";
|
|
7
|
-
StatusCode[StatusCode["GONE"] = 410] = "GONE";
|
|
8
|
-
StatusCode[StatusCode["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
9
|
-
return StatusCode;
|
|
10
|
-
}({});
|
|
11
|
-
class CommonError extends Error {
|
|
12
|
-
constructor(message) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.name = this.constructor.name;
|
|
15
|
-
this.message = message || 'UnknownError';
|
|
16
|
-
this.stack = new Error(message).stack || '';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export class DefaultError extends CommonError {
|
|
20
|
-
constructor({
|
|
21
|
-
message
|
|
22
|
-
}) {
|
|
23
|
-
super(message || 'UnknownError');
|
|
24
|
-
Object.setPrototypeOf(this, DefaultError.prototype);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* These errors will not fail UFO experiences
|
|
30
|
-
*/
|
|
31
|
-
export class SLOIgnoreError extends CommonError {
|
|
32
|
-
constructor({
|
|
33
|
-
message
|
|
34
|
-
}) {
|
|
35
|
-
super(`SentryIgnore: ${message || 'UnknownError'}`);
|
|
36
|
-
Object.setPrototypeOf(this, SLOIgnoreError.prototype);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// Http Errors
|
|
40
|
-
export class HttpError extends CommonError {
|
|
41
|
-
constructor({
|
|
42
|
-
message,
|
|
43
|
-
status,
|
|
44
|
-
traceId,
|
|
45
|
-
path
|
|
46
|
-
}) {
|
|
47
|
-
super(message);
|
|
48
|
-
Object.setPrototypeOf(this, HttpError.prototype);
|
|
49
|
-
this.status = status;
|
|
50
|
-
this.traceId = traceId;
|
|
51
|
-
this.path = path;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Graphql Errors
|
|
56
|
-
|
|
57
|
-
export class GraphQLError extends CommonError {
|
|
58
|
-
// tslint:disable-line no-any
|
|
59
|
-
|
|
60
|
-
constructor({
|
|
61
|
-
message,
|
|
62
|
-
category = 'default',
|
|
63
|
-
fields
|
|
64
|
-
}) {
|
|
65
|
-
super(message);
|
|
66
|
-
Object.setPrototypeOf(this, GraphQLError.prototype);
|
|
67
|
-
this.category = category;
|
|
68
|
-
if (fields) {
|
|
69
|
-
this.fields = fields;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
_GraphQLError = GraphQLError;
|
|
74
|
-
_defineProperty(GraphQLError, "from", rawErrors => {
|
|
75
|
-
const firstError = rawErrors[0];
|
|
76
|
-
const errorData = {
|
|
77
|
-
category: firstError.category,
|
|
78
|
-
message: firstError.message
|
|
79
|
-
};
|
|
80
|
-
if (firstError.fields) {
|
|
81
|
-
errorData.fields = firstError.fields.reduce((obj, item) => {
|
|
82
|
-
obj[item.field] = item.message;
|
|
83
|
-
return obj;
|
|
84
|
-
}, {});
|
|
85
|
-
}
|
|
86
|
-
return new _GraphQLError(errorData);
|
|
87
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export const EXPONENTIAL_BACKOFF_RETRY_POLICY = {
|
|
2
|
-
INITIAL_DELAY: 200,
|
|
3
|
-
MAX_RETRIES: 5,
|
|
4
|
-
JITTER: true
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Checks whether a status code is a 5xx HTTP code.
|
|
9
|
-
* @param {number} status HTTP status code
|
|
10
|
-
*/
|
|
11
|
-
export function is5xx(status) {
|
|
12
|
-
return 500 <= status && status <= 599;
|
|
13
|
-
}
|
|
14
|
-
export function isFetchResponse(data) {
|
|
15
|
-
if (!data || !data.hasOwnProperty('response')) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return data.response instanceof Response;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// tslint:disable-next-line no-any
|
|
22
|
-
|
|
23
|
-
// tslint:disable-next-line no-any
|
|
24
|
-
const defaultRetryIfCallback = a => !a;
|
|
25
|
-
const defaultOptions = {
|
|
26
|
-
initial: 200,
|
|
27
|
-
jitter: false,
|
|
28
|
-
max: 5,
|
|
29
|
-
retryIf: defaultRetryIfCallback
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Transparently wrap a function so that it is retried until it succeeds or reaches a max retry limit.
|
|
33
|
-
* The returned function has the same signature as the wrapped function.
|
|
34
|
-
*
|
|
35
|
-
* Modified from https://jsfiddle.net/pajtai/pLka0ow9/
|
|
36
|
-
*/
|
|
37
|
-
export function withExponentialBackoff(toTry, hofOptions = defaultOptions) {
|
|
38
|
-
const {
|
|
39
|
-
initial,
|
|
40
|
-
jitter,
|
|
41
|
-
max,
|
|
42
|
-
retryIf
|
|
43
|
-
} = hofOptions;
|
|
44
|
-
|
|
45
|
-
// Initialize max retry decrementing counter (range of max...0)
|
|
46
|
-
let attemptsRemaining = max;
|
|
47
|
-
|
|
48
|
-
// Initialize delay. This will exponentially increase each retry (delay = intial * 2^n)
|
|
49
|
-
let delay = initial;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* This function calls itself recursively until `retryIf` evaluates false or the retry limit is reached.
|
|
53
|
-
* The functioned-to-be-retried is called on each recursion.
|
|
54
|
-
*/
|
|
55
|
-
return async function tryWithExponentialBackoff(...args) {
|
|
56
|
-
// "An attempt was made"
|
|
57
|
-
const result = await toTry(...args);
|
|
58
|
-
--attemptsRemaining;
|
|
59
|
-
|
|
60
|
-
// If tried function was unsuccessful and there are still retries remaining, retry!
|
|
61
|
-
if (retryIf && retryIf(result) && attemptsRemaining > 0) {
|
|
62
|
-
// Wait for delay
|
|
63
|
-
await new Promise(resolve => setTimeout(resolve, jitter ? Math.random() * delay : delay));
|
|
64
|
-
|
|
65
|
-
// Exponentially increase delay
|
|
66
|
-
delay *= 2;
|
|
67
|
-
|
|
68
|
-
// Initiate retry
|
|
69
|
-
return tryWithExponentialBackoff(...args);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Return result of tried function if it is successful or if the retry limit
|
|
73
|
-
// was reached regardless of success.
|
|
74
|
-
return result;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
export const fetchWithExponentialBackoff = withExponentialBackoff((url, init) => fetch(url, init), {
|
|
78
|
-
initial: EXPONENTIAL_BACKOFF_RETRY_POLICY.INITIAL_DELAY,
|
|
79
|
-
jitter: EXPONENTIAL_BACKOFF_RETRY_POLICY.JITTER,
|
|
80
|
-
max: EXPONENTIAL_BACKOFF_RETRY_POLICY.MAX_RETRIES,
|
|
81
|
-
retryIf: response => is5xx(response.status)
|
|
82
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Our REST clients are initialised when their module loads which makes it tricky for them to consume the `statusCodeHandlers` prop passed to App from the host application.
|
|
3
|
-
* This is a temporary measure to enable the clients to consume `statusCodeHandlers`.
|
|
4
|
-
* The long term solution is to replace our REST clients with Apollo client custom resolvers
|
|
5
|
-
* This will unify all remote data handling under the apollo-client module which is able to easily receive `statusCodeHandlers` as it is initialised within the React portion of our app.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const statusCodeHandlersProvider = {
|
|
9
|
-
handlers: {},
|
|
10
|
-
get() {
|
|
11
|
-
return statusCodeHandlersProvider.handlers;
|
|
12
|
-
},
|
|
13
|
-
setHandlers(handlers) {
|
|
14
|
-
statusCodeHandlersProvider.handlers = handlers;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
export function handleResponse(response) {
|
|
18
|
-
const {
|
|
19
|
-
status
|
|
20
|
-
} = response;
|
|
21
|
-
const handler = statusCodeHandlersProvider.get()[status];
|
|
22
|
-
if (typeof handler === 'function') {
|
|
23
|
-
handler(response);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { defineMessages, FormattedMessage } from 'react-intl-next';
|
|
4
|
-
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
5
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
6
|
-
export const getCreateContainerContactSupportFlag = () => ({
|
|
7
|
-
id: 'teams-public.team-container.create-container.error.contact-support',
|
|
8
|
-
type: 'error',
|
|
9
|
-
title: /*#__PURE__*/React.createElement(FormattedMessage, messages.noConnectionTitle),
|
|
10
|
-
description: /*#__PURE__*/React.createElement(FormattedMessage, messages.noConnectionDescription),
|
|
11
|
-
actions: [{
|
|
12
|
-
content: /*#__PURE__*/React.createElement(Flex, {
|
|
13
|
-
alignItems: "center",
|
|
14
|
-
columnGap: "space.100"
|
|
15
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.noConnectionAction), /*#__PURE__*/React.createElement(LinkExternalIcon, {
|
|
16
|
-
label: ""
|
|
17
|
-
})),
|
|
18
|
-
href: 'https://support.atlassian.com/contact/#/&support_type=customer'
|
|
19
|
-
}]
|
|
20
|
-
});
|
|
21
|
-
export const getCreateContainerTryAgainFlag = ({
|
|
22
|
-
tryAgainAction,
|
|
23
|
-
containerType
|
|
24
|
-
}) => ({
|
|
25
|
-
id: 'teams-public.team-container.create-container.error.try-again',
|
|
26
|
-
type: 'error',
|
|
27
|
-
title: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.timeoutTitle, {
|
|
28
|
-
values: {
|
|
29
|
-
containerType
|
|
30
|
-
}
|
|
31
|
-
})),
|
|
32
|
-
description: /*#__PURE__*/React.createElement(FormattedMessage, messages.timeoutDescription),
|
|
33
|
-
actions: [{
|
|
34
|
-
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.timeoutAction),
|
|
35
|
-
onClick: () => {
|
|
36
|
-
tryAgainAction === null || tryAgainAction === void 0 ? void 0 : tryAgainAction();
|
|
37
|
-
}
|
|
38
|
-
}]
|
|
39
|
-
});
|
|
40
|
-
const messages = defineMessages({
|
|
41
|
-
timeoutTitle: {
|
|
42
|
-
id: 'teams-public.team-containers.timeout-title',
|
|
43
|
-
defaultMessage: 'We’re couldn’t connect your {containerType}',
|
|
44
|
-
description: 'Title for the timeout flag'
|
|
45
|
-
},
|
|
46
|
-
timeoutDescription: {
|
|
47
|
-
id: 'teams-public.team-containers.timeout-description',
|
|
48
|
-
defaultMessage: 'Something went wrong. Verify your connection and retry.',
|
|
49
|
-
description: 'Description for the timeout flag'
|
|
50
|
-
},
|
|
51
|
-
timeoutAction: {
|
|
52
|
-
id: 'teams-public.team-containers.timeout-action',
|
|
53
|
-
defaultMessage: 'Try again',
|
|
54
|
-
description: 'Action text for the timeout flag'
|
|
55
|
-
},
|
|
56
|
-
noConnectionTitle: {
|
|
57
|
-
id: 'teams-public.team-containers.timeout-no-connection-title',
|
|
58
|
-
defaultMessage: 'Connection failed',
|
|
59
|
-
description: 'Title for the no connection flag'
|
|
60
|
-
},
|
|
61
|
-
noConnectionDescription: {
|
|
62
|
-
id: 'teams-public.team-containers.timeout-no-connection-description',
|
|
63
|
-
defaultMessage: 'Try manually creating the space yourself.',
|
|
64
|
-
description: 'Description for the no connection flag'
|
|
65
|
-
},
|
|
66
|
-
noConnectionAction: {
|
|
67
|
-
id: 'teams-public.team-containers.timeout-no-connection-action',
|
|
68
|
-
defaultMessage: 'Contact support',
|
|
69
|
-
description: 'Action text for the no connection flag'
|
|
70
|
-
}
|
|
71
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
8
|
-
var _GraphQLError;
|
|
9
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
-
export var StatusCode = /*#__PURE__*/function (StatusCode) {
|
|
12
|
-
StatusCode[StatusCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
13
|
-
StatusCode[StatusCode["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
14
|
-
StatusCode[StatusCode["TIMEOUT"] = 408] = "TIMEOUT";
|
|
15
|
-
StatusCode[StatusCode["GONE"] = 410] = "GONE";
|
|
16
|
-
StatusCode[StatusCode["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
17
|
-
return StatusCode;
|
|
18
|
-
}({});
|
|
19
|
-
var CommonError = /*#__PURE__*/function (_Error) {
|
|
20
|
-
function CommonError(message) {
|
|
21
|
-
var _this;
|
|
22
|
-
_classCallCheck(this, CommonError);
|
|
23
|
-
_this = _callSuper(this, CommonError, [message]);
|
|
24
|
-
_this.name = _this.constructor.name;
|
|
25
|
-
_this.message = message || 'UnknownError';
|
|
26
|
-
_this.stack = new Error(message).stack || '';
|
|
27
|
-
return _this;
|
|
28
|
-
}
|
|
29
|
-
_inherits(CommonError, _Error);
|
|
30
|
-
return _createClass(CommonError);
|
|
31
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
32
|
-
export var DefaultError = /*#__PURE__*/function (_CommonError) {
|
|
33
|
-
function DefaultError(_ref) {
|
|
34
|
-
var _this2;
|
|
35
|
-
var message = _ref.message;
|
|
36
|
-
_classCallCheck(this, DefaultError);
|
|
37
|
-
_this2 = _callSuper(this, DefaultError, [message || 'UnknownError']);
|
|
38
|
-
Object.setPrototypeOf(_this2, DefaultError.prototype);
|
|
39
|
-
return _this2;
|
|
40
|
-
}
|
|
41
|
-
_inherits(DefaultError, _CommonError);
|
|
42
|
-
return _createClass(DefaultError);
|
|
43
|
-
}(CommonError);
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* These errors will not fail UFO experiences
|
|
47
|
-
*/
|
|
48
|
-
export var SLOIgnoreError = /*#__PURE__*/function (_CommonError2) {
|
|
49
|
-
function SLOIgnoreError(_ref2) {
|
|
50
|
-
var _this3;
|
|
51
|
-
var message = _ref2.message;
|
|
52
|
-
_classCallCheck(this, SLOIgnoreError);
|
|
53
|
-
_this3 = _callSuper(this, SLOIgnoreError, ["SentryIgnore: ".concat(message || 'UnknownError')]);
|
|
54
|
-
Object.setPrototypeOf(_this3, SLOIgnoreError.prototype);
|
|
55
|
-
return _this3;
|
|
56
|
-
}
|
|
57
|
-
_inherits(SLOIgnoreError, _CommonError2);
|
|
58
|
-
return _createClass(SLOIgnoreError);
|
|
59
|
-
}(CommonError);
|
|
60
|
-
// Http Errors
|
|
61
|
-
export var HttpError = /*#__PURE__*/function (_CommonError3) {
|
|
62
|
-
function HttpError(_ref3) {
|
|
63
|
-
var _this4;
|
|
64
|
-
var message = _ref3.message,
|
|
65
|
-
status = _ref3.status,
|
|
66
|
-
traceId = _ref3.traceId,
|
|
67
|
-
path = _ref3.path;
|
|
68
|
-
_classCallCheck(this, HttpError);
|
|
69
|
-
_this4 = _callSuper(this, HttpError, [message]);
|
|
70
|
-
Object.setPrototypeOf(_this4, HttpError.prototype);
|
|
71
|
-
_this4.status = status;
|
|
72
|
-
_this4.traceId = traceId;
|
|
73
|
-
_this4.path = path;
|
|
74
|
-
return _this4;
|
|
75
|
-
}
|
|
76
|
-
_inherits(HttpError, _CommonError3);
|
|
77
|
-
return _createClass(HttpError);
|
|
78
|
-
}(CommonError);
|
|
79
|
-
|
|
80
|
-
// Graphql Errors
|
|
81
|
-
|
|
82
|
-
export var GraphQLError = /*#__PURE__*/function (_CommonError4) {
|
|
83
|
-
// tslint:disable-line no-any
|
|
84
|
-
|
|
85
|
-
function GraphQLError(_ref4) {
|
|
86
|
-
var _this5;
|
|
87
|
-
var message = _ref4.message,
|
|
88
|
-
_ref4$category = _ref4.category,
|
|
89
|
-
category = _ref4$category === void 0 ? 'default' : _ref4$category,
|
|
90
|
-
fields = _ref4.fields;
|
|
91
|
-
_classCallCheck(this, GraphQLError);
|
|
92
|
-
_this5 = _callSuper(this, GraphQLError, [message]);
|
|
93
|
-
Object.setPrototypeOf(_this5, GraphQLError.prototype);
|
|
94
|
-
_this5.category = category;
|
|
95
|
-
if (fields) {
|
|
96
|
-
_this5.fields = fields;
|
|
97
|
-
}
|
|
98
|
-
return _this5;
|
|
99
|
-
}
|
|
100
|
-
_inherits(GraphQLError, _CommonError4);
|
|
101
|
-
return _createClass(GraphQLError);
|
|
102
|
-
}(CommonError);
|
|
103
|
-
_GraphQLError = GraphQLError;
|
|
104
|
-
_defineProperty(GraphQLError, "from", function (rawErrors) {
|
|
105
|
-
var firstError = rawErrors[0];
|
|
106
|
-
var errorData = {
|
|
107
|
-
category: firstError.category,
|
|
108
|
-
message: firstError.message
|
|
109
|
-
};
|
|
110
|
-
if (firstError.fields) {
|
|
111
|
-
errorData.fields = firstError.fields.reduce(function (obj, item) {
|
|
112
|
-
obj[item.field] = item.message;
|
|
113
|
-
return obj;
|
|
114
|
-
}, {});
|
|
115
|
-
}
|
|
116
|
-
return new _GraphQLError(errorData);
|
|
117
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
export var EXPONENTIAL_BACKOFF_RETRY_POLICY = {
|
|
4
|
-
INITIAL_DELAY: 200,
|
|
5
|
-
MAX_RETRIES: 5,
|
|
6
|
-
JITTER: true
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Checks whether a status code is a 5xx HTTP code.
|
|
11
|
-
* @param {number} status HTTP status code
|
|
12
|
-
*/
|
|
13
|
-
export function is5xx(status) {
|
|
14
|
-
return 500 <= status && status <= 599;
|
|
15
|
-
}
|
|
16
|
-
export function isFetchResponse(data) {
|
|
17
|
-
if (!data || !data.hasOwnProperty('response')) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return data.response instanceof Response;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// tslint:disable-next-line no-any
|
|
24
|
-
|
|
25
|
-
// tslint:disable-next-line no-any
|
|
26
|
-
var defaultRetryIfCallback = function defaultRetryIfCallback(a) {
|
|
27
|
-
return !a;
|
|
28
|
-
};
|
|
29
|
-
var defaultOptions = {
|
|
30
|
-
initial: 200,
|
|
31
|
-
jitter: false,
|
|
32
|
-
max: 5,
|
|
33
|
-
retryIf: defaultRetryIfCallback
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Transparently wrap a function so that it is retried until it succeeds or reaches a max retry limit.
|
|
37
|
-
* The returned function has the same signature as the wrapped function.
|
|
38
|
-
*
|
|
39
|
-
* Modified from https://jsfiddle.net/pajtai/pLka0ow9/
|
|
40
|
-
*/
|
|
41
|
-
export function withExponentialBackoff(toTry) {
|
|
42
|
-
var hofOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
43
|
-
var initial = hofOptions.initial,
|
|
44
|
-
jitter = hofOptions.jitter,
|
|
45
|
-
max = hofOptions.max,
|
|
46
|
-
retryIf = hofOptions.retryIf;
|
|
47
|
-
|
|
48
|
-
// Initialize max retry decrementing counter (range of max...0)
|
|
49
|
-
var attemptsRemaining = max;
|
|
50
|
-
|
|
51
|
-
// Initialize delay. This will exponentially increase each retry (delay = intial * 2^n)
|
|
52
|
-
var delay = initial;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* This function calls itself recursively until `retryIf` evaluates false or the retry limit is reached.
|
|
56
|
-
* The functioned-to-be-retried is called on each recursion.
|
|
57
|
-
*/
|
|
58
|
-
return /*#__PURE__*/function () {
|
|
59
|
-
var _tryWithExponentialBackoff = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
60
|
-
var result,
|
|
61
|
-
_args = arguments;
|
|
62
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
|
-
while (1) switch (_context.prev = _context.next) {
|
|
64
|
-
case 0:
|
|
65
|
-
_context.next = 2;
|
|
66
|
-
return toTry.apply(void 0, _args);
|
|
67
|
-
case 2:
|
|
68
|
-
result = _context.sent;
|
|
69
|
-
--attemptsRemaining;
|
|
70
|
-
|
|
71
|
-
// If tried function was unsuccessful and there are still retries remaining, retry!
|
|
72
|
-
if (!(retryIf && retryIf(result) && attemptsRemaining > 0)) {
|
|
73
|
-
_context.next = 9;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
_context.next = 7;
|
|
77
|
-
return new Promise(function (resolve) {
|
|
78
|
-
return setTimeout(resolve, jitter ? Math.random() * delay : delay);
|
|
79
|
-
});
|
|
80
|
-
case 7:
|
|
81
|
-
// Exponentially increase delay
|
|
82
|
-
delay *= 2;
|
|
83
|
-
|
|
84
|
-
// Initiate retry
|
|
85
|
-
return _context.abrupt("return", tryWithExponentialBackoff.apply(void 0, _args));
|
|
86
|
-
case 9:
|
|
87
|
-
return _context.abrupt("return", result);
|
|
88
|
-
case 10:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context.stop();
|
|
91
|
-
}
|
|
92
|
-
}, _callee);
|
|
93
|
-
}));
|
|
94
|
-
function tryWithExponentialBackoff() {
|
|
95
|
-
return _tryWithExponentialBackoff.apply(this, arguments);
|
|
96
|
-
}
|
|
97
|
-
return tryWithExponentialBackoff;
|
|
98
|
-
}();
|
|
99
|
-
}
|
|
100
|
-
export var fetchWithExponentialBackoff = withExponentialBackoff(function (url, init) {
|
|
101
|
-
return fetch(url, init);
|
|
102
|
-
}, {
|
|
103
|
-
initial: EXPONENTIAL_BACKOFF_RETRY_POLICY.INITIAL_DELAY,
|
|
104
|
-
jitter: EXPONENTIAL_BACKOFF_RETRY_POLICY.JITTER,
|
|
105
|
-
max: EXPONENTIAL_BACKOFF_RETRY_POLICY.MAX_RETRIES,
|
|
106
|
-
retryIf: function retryIf(response) {
|
|
107
|
-
return is5xx(response.status);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Our REST clients are initialised when their module loads which makes it tricky for them to consume the `statusCodeHandlers` prop passed to App from the host application.
|
|
3
|
-
* This is a temporary measure to enable the clients to consume `statusCodeHandlers`.
|
|
4
|
-
* The long term solution is to replace our REST clients with Apollo client custom resolvers
|
|
5
|
-
* This will unify all remote data handling under the apollo-client module which is able to easily receive `statusCodeHandlers` as it is initialised within the React portion of our app.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export var statusCodeHandlersProvider = {
|
|
9
|
-
handlers: {},
|
|
10
|
-
get: function get() {
|
|
11
|
-
return statusCodeHandlersProvider.handlers;
|
|
12
|
-
},
|
|
13
|
-
setHandlers: function setHandlers(handlers) {
|
|
14
|
-
statusCodeHandlersProvider.handlers = handlers;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
export function handleResponse(response) {
|
|
18
|
-
var status = response.status;
|
|
19
|
-
var handler = statusCodeHandlersProvider.get()[status];
|
|
20
|
-
if (typeof handler === 'function') {
|
|
21
|
-
handler(response);
|
|
22
|
-
}
|
|
23
|
-
}
|