@atlaskit/teams-public 0.73.0 → 0.74.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.json +2 -2
  3. package/dist/cjs/common/utils/error/index.js +0 -120
  4. package/dist/cjs/common/utils/http.js +0 -119
  5. package/dist/cjs/common/utils/status-code-handlers-provider.js +0 -30
  6. package/dist/cjs/common/utils/team-id-to-ari.js +0 -10
  7. package/dist/cjs/common/utils/user-ari.js +0 -16
  8. package/dist/cjs/ui/team-containers/utils.js +0 -81
  9. package/dist/es2019/common/utils/error/index.js +0 -87
  10. package/dist/es2019/common/utils/http.js +0 -82
  11. package/dist/es2019/common/utils/status-code-handlers-provider.js +0 -25
  12. package/dist/es2019/common/utils/team-id-to-ari.js +0 -2
  13. package/dist/es2019/common/utils/user-ari.js +0 -8
  14. package/dist/es2019/ui/team-containers/utils.js +0 -71
  15. package/dist/esm/common/utils/error/index.js +0 -117
  16. package/dist/esm/common/utils/http.js +0 -109
  17. package/dist/esm/common/utils/status-code-handlers-provider.js +0 -23
  18. package/dist/esm/common/utils/team-id-to-ari.js +0 -4
  19. package/dist/esm/common/utils/user-ari.js +0 -10
  20. package/dist/esm/ui/team-containers/utils.js +0 -74
  21. package/dist/types/common/utils/error/index.d.ts +0 -59
  22. package/dist/types/common/utils/http.d.ts +0 -31
  23. package/dist/types/common/utils/status-code-handlers-provider.d.ts +0 -17
  24. package/dist/types/common/utils/team-id-to-ari.d.ts +0 -2
  25. package/dist/types/common/utils/user-ari.d.ts +0 -3
  26. package/dist/types/ui/team-containers/utils.d.ts +0 -25
  27. package/dist/types-ts4.5/common/utils/error/index.d.ts +0 -59
  28. package/dist/types-ts4.5/common/utils/http.d.ts +0 -31
  29. package/dist/types-ts4.5/common/utils/status-code-handlers-provider.d.ts +0 -17
  30. package/dist/types-ts4.5/common/utils/team-id-to-ari.d.ts +0 -2
  31. package/dist/types-ts4.5/common/utils/user-ari.d.ts +0 -3
  32. package/dist/types-ts4.5/ui/team-containers/utils.d.ts +0 -25
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/teams-public
2
2
 
3
+ ## 0.74.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1368864a76f91`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1368864a76f91) -
8
+ Remove dead code from teams-public package
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 0.73.0
4
15
 
5
16
  ### Minor Changes
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/skeleton": "^2.1.0",
43
43
  "@atlaskit/teams-app-internal-analytics": "^1.27.0",
44
44
  "@atlaskit/teams-app-internal-product-permissions": "^1.3.0",
45
- "@atlaskit/teams-client": "^4.30.0",
45
+ "@atlaskit/teams-client": "^4.31.0",
46
46
  "@atlaskit/tokens": "^11.4.0",
47
47
  "@atlaskit/tooltip": "^21.1.0",
48
48
  "@babel/runtime": "^7.0.0",
@@ -106,7 +106,7 @@
106
106
  }
107
107
  },
108
108
  "name": "@atlaskit/teams-public",
109
- "version": "0.73.0",
109
+ "version": "0.74.0",
110
110
  "description": "Public components related to teams",
111
111
  "author": "Atlassian Pty Ltd",
112
112
  "license": "Apache-2.0",
@@ -1,120 +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.StatusCode = exports.SLOIgnoreError = exports.HttpError = exports.GraphQLError = exports.DefaultError = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
- var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
15
- var _GraphQLError;
16
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
17
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
18
- var StatusCode = exports.StatusCode = /*#__PURE__*/function (StatusCode) {
19
- StatusCode[StatusCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
20
- StatusCode[StatusCode["FORBIDDEN"] = 403] = "FORBIDDEN";
21
- StatusCode[StatusCode["TIMEOUT"] = 408] = "TIMEOUT";
22
- StatusCode[StatusCode["GONE"] = 410] = "GONE";
23
- StatusCode[StatusCode["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
24
- return StatusCode;
25
- }({});
26
- var CommonError = /*#__PURE__*/function (_Error) {
27
- function CommonError(message) {
28
- var _this;
29
- (0, _classCallCheck2.default)(this, CommonError);
30
- _this = _callSuper(this, CommonError, [message]);
31
- _this.name = _this.constructor.name;
32
- _this.message = message || 'UnknownError';
33
- _this.stack = new Error(message).stack || '';
34
- return _this;
35
- }
36
- (0, _inherits2.default)(CommonError, _Error);
37
- return (0, _createClass2.default)(CommonError);
38
- }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
39
- var DefaultError = exports.DefaultError = /*#__PURE__*/function (_CommonError) {
40
- function DefaultError(_ref) {
41
- var _this2;
42
- var message = _ref.message;
43
- (0, _classCallCheck2.default)(this, DefaultError);
44
- _this2 = _callSuper(this, DefaultError, [message || 'UnknownError']);
45
- Object.setPrototypeOf(_this2, DefaultError.prototype);
46
- return _this2;
47
- }
48
- (0, _inherits2.default)(DefaultError, _CommonError);
49
- return (0, _createClass2.default)(DefaultError);
50
- }(CommonError);
51
- /**
52
- * These errors will not fail UFO experiences
53
- */
54
- var SLOIgnoreError = exports.SLOIgnoreError = /*#__PURE__*/function (_CommonError2) {
55
- function SLOIgnoreError(_ref2) {
56
- var _this3;
57
- var message = _ref2.message;
58
- (0, _classCallCheck2.default)(this, SLOIgnoreError);
59
- _this3 = _callSuper(this, SLOIgnoreError, ["SentryIgnore: ".concat(message || 'UnknownError')]);
60
- Object.setPrototypeOf(_this3, SLOIgnoreError.prototype);
61
- return _this3;
62
- }
63
- (0, _inherits2.default)(SLOIgnoreError, _CommonError2);
64
- return (0, _createClass2.default)(SLOIgnoreError);
65
- }(CommonError);
66
- // Http Errors
67
- var HttpError = exports.HttpError = /*#__PURE__*/function (_CommonError3) {
68
- function HttpError(_ref3) {
69
- var _this4;
70
- var message = _ref3.message,
71
- status = _ref3.status,
72
- traceId = _ref3.traceId,
73
- path = _ref3.path;
74
- (0, _classCallCheck2.default)(this, HttpError);
75
- _this4 = _callSuper(this, HttpError, [message]);
76
- Object.setPrototypeOf(_this4, HttpError.prototype);
77
- _this4.status = status;
78
- _this4.traceId = traceId;
79
- _this4.path = path;
80
- return _this4;
81
- }
82
- (0, _inherits2.default)(HttpError, _CommonError3);
83
- return (0, _createClass2.default)(HttpError);
84
- }(CommonError); // Graphql Errors
85
- var GraphQLError = exports.GraphQLError = /*#__PURE__*/function (_CommonError4) {
86
- // tslint:disable-line no-any
87
-
88
- function GraphQLError(_ref4) {
89
- var _this5;
90
- var message = _ref4.message,
91
- _ref4$category = _ref4.category,
92
- category = _ref4$category === void 0 ? 'default' : _ref4$category,
93
- fields = _ref4.fields;
94
- (0, _classCallCheck2.default)(this, GraphQLError);
95
- _this5 = _callSuper(this, GraphQLError, [message]);
96
- Object.setPrototypeOf(_this5, GraphQLError.prototype);
97
- _this5.category = category;
98
- if (fields) {
99
- _this5.fields = fields;
100
- }
101
- return _this5;
102
- }
103
- (0, _inherits2.default)(GraphQLError, _CommonError4);
104
- return (0, _createClass2.default)(GraphQLError);
105
- }(CommonError);
106
- _GraphQLError = GraphQLError;
107
- (0, _defineProperty2.default)(GraphQLError, "from", function (rawErrors) {
108
- var firstError = rawErrors[0];
109
- var errorData = {
110
- category: firstError.category,
111
- message: firstError.message
112
- };
113
- if (firstError.fields) {
114
- errorData.fields = firstError.fields.reduce(function (obj, item) {
115
- obj[item.field] = item.message;
116
- return obj;
117
- }, {});
118
- }
119
- return new _GraphQLError(errorData);
120
- });
@@ -1,119 +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.fetchWithExponentialBackoff = exports.EXPONENTIAL_BACKOFF_RETRY_POLICY = void 0;
8
- exports.is5xx = is5xx;
9
- exports.isFetchResponse = isFetchResponse;
10
- exports.withExponentialBackoff = withExponentialBackoff;
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
- var EXPONENTIAL_BACKOFF_RETRY_POLICY = exports.EXPONENTIAL_BACKOFF_RETRY_POLICY = {
14
- INITIAL_DELAY: 200,
15
- MAX_RETRIES: 5,
16
- JITTER: true
17
- };
18
-
19
- /**
20
- * Checks whether a status code is a 5xx HTTP code.
21
- * @param {number} status HTTP status code
22
- */
23
- function is5xx(status) {
24
- return 500 <= status && status <= 599;
25
- }
26
- function isFetchResponse(data) {
27
- if (!data || !data.hasOwnProperty('response')) {
28
- return false;
29
- }
30
- return data.response instanceof Response;
31
- }
32
-
33
- // tslint:disable-next-line no-any
34
-
35
- // tslint:disable-next-line no-any
36
- var defaultRetryIfCallback = function defaultRetryIfCallback(a) {
37
- return !a;
38
- };
39
- var defaultOptions = {
40
- initial: 200,
41
- jitter: false,
42
- max: 5,
43
- retryIf: defaultRetryIfCallback
44
- };
45
- /**
46
- * Transparently wrap a function so that it is retried until it succeeds or reaches a max retry limit.
47
- * The returned function has the same signature as the wrapped function.
48
- *
49
- * Modified from https://jsfiddle.net/pajtai/pLka0ow9/
50
- */
51
- function withExponentialBackoff(toTry) {
52
- var hofOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
53
- var initial = hofOptions.initial,
54
- jitter = hofOptions.jitter,
55
- max = hofOptions.max,
56
- retryIf = hofOptions.retryIf;
57
-
58
- // Initialize max retry decrementing counter (range of max...0)
59
- var attemptsRemaining = max;
60
-
61
- // Initialize delay. This will exponentially increase each retry (delay = intial * 2^n)
62
- var delay = initial;
63
-
64
- /**
65
- * This function calls itself recursively until `retryIf` evaluates false or the retry limit is reached.
66
- * The functioned-to-be-retried is called on each recursion.
67
- */
68
- return /*#__PURE__*/function () {
69
- var _tryWithExponentialBackoff = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
70
- var result,
71
- _args = arguments;
72
- return _regenerator.default.wrap(function _callee$(_context) {
73
- while (1) switch (_context.prev = _context.next) {
74
- case 0:
75
- _context.next = 2;
76
- return toTry.apply(void 0, _args);
77
- case 2:
78
- result = _context.sent;
79
- --attemptsRemaining;
80
-
81
- // If tried function was unsuccessful and there are still retries remaining, retry!
82
- if (!(retryIf && retryIf(result) && attemptsRemaining > 0)) {
83
- _context.next = 9;
84
- break;
85
- }
86
- _context.next = 7;
87
- return new Promise(function (resolve) {
88
- return setTimeout(resolve, jitter ? Math.random() * delay : delay);
89
- });
90
- case 7:
91
- // Exponentially increase delay
92
- delay *= 2;
93
-
94
- // Initiate retry
95
- return _context.abrupt("return", tryWithExponentialBackoff.apply(void 0, _args));
96
- case 9:
97
- return _context.abrupt("return", result);
98
- case 10:
99
- case "end":
100
- return _context.stop();
101
- }
102
- }, _callee);
103
- }));
104
- function tryWithExponentialBackoff() {
105
- return _tryWithExponentialBackoff.apply(this, arguments);
106
- }
107
- return tryWithExponentialBackoff;
108
- }();
109
- }
110
- var fetchWithExponentialBackoff = exports.fetchWithExponentialBackoff = withExponentialBackoff(function (url, init) {
111
- return fetch(url, init);
112
- }, {
113
- initial: EXPONENTIAL_BACKOFF_RETRY_POLICY.INITIAL_DELAY,
114
- jitter: EXPONENTIAL_BACKOFF_RETRY_POLICY.JITTER,
115
- max: EXPONENTIAL_BACKOFF_RETRY_POLICY.MAX_RETRIES,
116
- retryIf: function retryIf(response) {
117
- return is5xx(response.status);
118
- }
119
- });
@@ -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,2 +0,0 @@
1
- export const ARI_PREFIX = 'ari:cloud:identity::team/';
2
- export const teamIdToAri = teamIdOrTeamAri => teamIdOrTeamAri.startsWith(ARI_PREFIX) ? teamIdOrTeamAri : `${ARI_PREFIX}${teamIdOrTeamAri}`;
@@ -1,8 +0,0 @@
1
- import { USER_ARI_PREFIX } from '../types';
2
- export const isUserARI = ari => ari.startsWith(USER_ARI_PREFIX);
3
- export const toUserId = ari => {
4
- if (isUserARI(ari)) {
5
- return ari.replace(USER_ARI_PREFIX, '');
6
- }
7
- throw new Error('Invalid UserARI');
8
- };