@atlaskit/teams-public 0.2.0 → 0.3.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/common/utils/error/index.js +120 -0
  3. package/dist/cjs/common/utils/get-container-properties.js +2 -12
  4. package/dist/cjs/common/utils/http.js +119 -0
  5. package/dist/cjs/common/utils/status-code-handlers-provider.js +30 -0
  6. package/dist/cjs/common/utils/team-id-to-ari.js +10 -0
  7. package/dist/cjs/controllers/hooks/use-team-containers/index.js +79 -0
  8. package/dist/cjs/controllers/index.js +12 -0
  9. package/dist/cjs/services/agg-client/index.js +79 -0
  10. package/dist/cjs/services/agg-client/mocks/index.js +52 -0
  11. package/dist/cjs/services/agg-client/utils/queries/team-containers-query.js +12 -0
  12. package/dist/cjs/services/base-client/index.js +92 -0
  13. package/dist/cjs/services/constants.js +9 -0
  14. package/dist/cjs/services/graphql-client/index.js +12 -0
  15. package/dist/cjs/services/graphql-client/main.js +69 -0
  16. package/dist/cjs/services/graphql-client/types.js +5 -0
  17. package/dist/cjs/services/graphql-client/utils/index.js +157 -0
  18. package/dist/cjs/services/index.js +18 -0
  19. package/dist/cjs/services/main.js +72 -0
  20. package/dist/cjs/services/types.js +5 -0
  21. package/dist/cjs/ui/team-containers/add-container-card/index.compiled.css +0 -2
  22. package/dist/cjs/ui/team-containers/add-container-card/index.js +30 -12
  23. package/dist/cjs/ui/team-containers/linked-container-card/index.compiled.css +1 -2
  24. package/dist/cjs/ui/team-containers/linked-container-card/index.js +45 -15
  25. package/dist/cjs/ui/team-containers/main.js +94 -16
  26. package/dist/cjs/ui/team-containers/team-containers-skeleton/index.compiled.css +4 -0
  27. package/dist/cjs/ui/team-containers/team-containers-skeleton/index.js +36 -0
  28. package/dist/cjs/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.compiled.css +14 -0
  29. package/dist/cjs/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js +38 -0
  30. package/dist/es2019/common/utils/error/index.js +87 -0
  31. package/dist/es2019/common/utils/get-container-properties.js +3 -13
  32. package/dist/es2019/common/utils/http.js +82 -0
  33. package/dist/es2019/common/utils/status-code-handlers-provider.js +25 -0
  34. package/dist/es2019/common/utils/team-id-to-ari.js +2 -0
  35. package/dist/es2019/controllers/hooks/use-team-containers/index.js +45 -0
  36. package/dist/es2019/controllers/index.js +1 -0
  37. package/dist/es2019/services/agg-client/index.js +36 -0
  38. package/dist/es2019/services/agg-client/mocks/index.js +46 -0
  39. package/dist/es2019/services/agg-client/utils/queries/team-containers-query.js +46 -0
  40. package/dist/es2019/services/base-client/index.js +64 -0
  41. package/dist/es2019/services/constants.js +3 -0
  42. package/dist/es2019/services/graphql-client/index.js +1 -0
  43. package/dist/es2019/services/graphql-client/main.js +23 -0
  44. package/dist/es2019/services/graphql-client/types.js +1 -0
  45. package/dist/es2019/services/graphql-client/utils/index.js +76 -0
  46. package/dist/es2019/services/index.js +1 -0
  47. package/dist/es2019/services/main.js +39 -0
  48. package/dist/es2019/services/types.js +1 -0
  49. package/dist/es2019/ui/team-containers/add-container-card/index.compiled.css +0 -2
  50. package/dist/es2019/ui/team-containers/add-container-card/index.js +15 -7
  51. package/dist/es2019/ui/team-containers/linked-container-card/index.compiled.css +1 -2
  52. package/dist/es2019/ui/team-containers/linked-container-card/index.js +28 -9
  53. package/dist/es2019/ui/team-containers/main.js +79 -16
  54. package/dist/es2019/ui/team-containers/team-containers-skeleton/index.compiled.css +4 -0
  55. package/dist/es2019/ui/team-containers/team-containers-skeleton/index.js +27 -0
  56. package/dist/es2019/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.compiled.css +14 -0
  57. package/dist/es2019/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js +31 -0
  58. package/dist/esm/common/utils/error/index.js +117 -0
  59. package/dist/esm/common/utils/get-container-properties.js +3 -13
  60. package/dist/esm/common/utils/http.js +109 -0
  61. package/dist/esm/common/utils/status-code-handlers-provider.js +23 -0
  62. package/dist/esm/common/utils/team-id-to-ari.js +4 -0
  63. package/dist/esm/controllers/hooks/use-team-containers/index.js +72 -0
  64. package/dist/esm/controllers/index.js +1 -0
  65. package/dist/esm/services/agg-client/index.js +72 -0
  66. package/dist/esm/services/agg-client/mocks/index.js +46 -0
  67. package/dist/esm/services/agg-client/utils/queries/team-containers-query.js +5 -0
  68. package/dist/esm/services/base-client/index.js +85 -0
  69. package/dist/esm/services/constants.js +3 -0
  70. package/dist/esm/services/graphql-client/index.js +1 -0
  71. package/dist/esm/services/graphql-client/main.js +62 -0
  72. package/dist/esm/services/graphql-client/types.js +1 -0
  73. package/dist/esm/services/graphql-client/utils/index.js +149 -0
  74. package/dist/esm/services/index.js +1 -0
  75. package/dist/esm/services/main.js +65 -0
  76. package/dist/esm/services/types.js +1 -0
  77. package/dist/esm/ui/team-containers/add-container-card/index.compiled.css +0 -2
  78. package/dist/esm/ui/team-containers/add-container-card/index.js +25 -7
  79. package/dist/esm/ui/team-containers/linked-container-card/index.compiled.css +1 -2
  80. package/dist/esm/ui/team-containers/linked-container-card/index.js +39 -9
  81. package/dist/esm/ui/team-containers/main.js +91 -16
  82. package/dist/esm/ui/team-containers/team-containers-skeleton/index.compiled.css +4 -0
  83. package/dist/esm/ui/team-containers/team-containers-skeleton/index.js +29 -0
  84. package/dist/esm/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.compiled.css +14 -0
  85. package/dist/esm/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js +31 -0
  86. package/dist/types/common/types.d.ts +1 -1
  87. package/dist/types/common/utils/error/index.d.ts +59 -0
  88. package/dist/types/common/utils/http.d.ts +31 -0
  89. package/dist/types/common/utils/status-code-handlers-provider.d.ts +17 -0
  90. package/dist/types/common/utils/team-id-to-ari.d.ts +2 -0
  91. package/dist/types/controllers/hooks/use-team-containers/index.d.ts +12 -0
  92. package/dist/types/controllers/index.d.ts +1 -0
  93. package/dist/types/services/agg-client/index.d.ts +15 -0
  94. package/dist/types/services/agg-client/mocks/index.d.ts +55 -0
  95. package/dist/types/services/agg-client/utils/queries/team-containers-query.d.ts +44 -0
  96. package/dist/types/services/base-client/index.d.ts +37 -0
  97. package/dist/types/services/constants.d.ts +4 -0
  98. package/dist/types/services/graphql-client/index.d.ts +1 -0
  99. package/dist/types/services/graphql-client/main.d.ts +8 -0
  100. package/dist/types/services/graphql-client/types.d.ts +19 -0
  101. package/dist/types/services/graphql-client/utils/index.d.ts +3 -0
  102. package/dist/types/services/index.d.ts +1 -0
  103. package/dist/types/services/main.d.ts +25 -0
  104. package/dist/types/services/types.d.ts +19 -0
  105. package/dist/types/ui/team-containers/add-container-card/index.d.ts +3 -2
  106. package/dist/types/ui/team-containers/linked-container-card/index.d.ts +3 -6
  107. package/dist/types/ui/team-containers/main.d.ts +3 -1
  108. package/dist/types/ui/team-containers/team-containers-skeleton/index.d.ts +6 -0
  109. package/dist/types/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.d.ts +2 -0
  110. package/dist/types/ui/team-containers/types.d.ts +5 -0
  111. package/dist/types-ts4.5/common/types.d.ts +1 -1
  112. package/dist/types-ts4.5/common/utils/error/index.d.ts +59 -0
  113. package/dist/types-ts4.5/common/utils/http.d.ts +31 -0
  114. package/dist/types-ts4.5/common/utils/status-code-handlers-provider.d.ts +17 -0
  115. package/dist/types-ts4.5/common/utils/team-id-to-ari.d.ts +2 -0
  116. package/dist/types-ts4.5/controllers/hooks/use-team-containers/index.d.ts +12 -0
  117. package/dist/types-ts4.5/controllers/index.d.ts +1 -0
  118. package/dist/types-ts4.5/services/agg-client/index.d.ts +15 -0
  119. package/dist/types-ts4.5/services/agg-client/mocks/index.d.ts +55 -0
  120. package/dist/types-ts4.5/services/agg-client/utils/queries/team-containers-query.d.ts +44 -0
  121. package/dist/types-ts4.5/services/base-client/index.d.ts +37 -0
  122. package/dist/types-ts4.5/services/constants.d.ts +4 -0
  123. package/dist/types-ts4.5/services/graphql-client/index.d.ts +1 -0
  124. package/dist/types-ts4.5/services/graphql-client/main.d.ts +8 -0
  125. package/dist/types-ts4.5/services/graphql-client/types.d.ts +19 -0
  126. package/dist/types-ts4.5/services/graphql-client/utils/index.d.ts +3 -0
  127. package/dist/types-ts4.5/services/index.d.ts +1 -0
  128. package/dist/types-ts4.5/services/main.d.ts +25 -0
  129. package/dist/types-ts4.5/services/types.d.ts +19 -0
  130. package/dist/types-ts4.5/ui/team-containers/add-container-card/index.d.ts +3 -2
  131. package/dist/types-ts4.5/ui/team-containers/linked-container-card/index.d.ts +3 -6
  132. package/dist/types-ts4.5/ui/team-containers/main.d.ts +3 -1
  133. package/dist/types-ts4.5/ui/team-containers/team-containers-skeleton/index.d.ts +6 -0
  134. package/dist/types-ts4.5/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.d.ts +2 -0
  135. package/dist/types-ts4.5/ui/team-containers/types.d.ts +5 -0
  136. package/package.json +13 -9
  137. package/dist/cjs/ui/team-containers/constants.js +0 -7
  138. package/dist/es2019/ui/team-containers/constants.js +0 -1
  139. package/dist/esm/ui/team-containers/constants.js +0 -1
  140. package/dist/types/ui/team-containers/constants.d.ts +0 -1
  141. package/dist/types-ts4.5/ui/team-containers/constants.d.ts +0 -1
@@ -0,0 +1,117 @@
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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { defineMessages, FormattedMessage } from 'react-intl-next';
3
- import { ConfluenceIcon, JiraIcon, LoomIcon } from '@atlaskit/logo';
3
+ import { ConfluenceIcon, JiraIcon } from '@atlaskit/logo';
4
4
  export var messages = defineMessages({
5
5
  addConfluenceContainerTitle: {
6
6
  id: 'ptc-directory.team-profile-page.team-containers.add-confluence-space-title.non-final',
@@ -35,7 +35,7 @@ export var messages = defineMessages({
35
35
  });
36
36
  export var getContainerProperties = function getContainerProperties(containerType) {
37
37
  switch (containerType) {
38
- case 'confluence':
38
+ case 'ConfluenceSpace':
39
39
  return {
40
40
  description: /*#__PURE__*/React.createElement(FormattedMessage, messages.confluenceContainerDescription),
41
41
  icon: /*#__PURE__*/React.createElement(ConfluenceIcon, {
@@ -45,7 +45,7 @@ export var getContainerProperties = function getContainerProperties(containerTyp
45
45
  }),
46
46
  title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addConfluenceContainerTitle)
47
47
  };
48
- case 'jira':
48
+ case 'JiraProject':
49
49
  return {
50
50
  description: /*#__PURE__*/React.createElement(FormattedMessage, messages.jiraProjectDescription),
51
51
  icon: /*#__PURE__*/React.createElement(JiraIcon, {
@@ -55,16 +55,6 @@ export var getContainerProperties = function getContainerProperties(containerTyp
55
55
  }),
56
56
  title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addJiraProjectTitle)
57
57
  };
58
- case 'loom':
59
- return {
60
- description: /*#__PURE__*/React.createElement(FormattedMessage, messages.loomSpaceDescription),
61
- icon: /*#__PURE__*/React.createElement(LoomIcon, {
62
- appearance: "brand",
63
- label: "",
64
- size: "xsmall"
65
- }),
66
- title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addLoomSpaceTitle)
67
- };
68
58
  default:
69
59
  return {
70
60
  description: null,
@@ -0,0 +1,109 @@
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
+ });
@@ -0,0 +1,23 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ export var ARI_PREFIX = 'ari:cloud:identity::team/';
2
+ export var teamIdToAri = function teamIdToAri(teamIdOrTeamAri) {
3
+ return teamIdOrTeamAri.startsWith(ARI_PREFIX) ? teamIdOrTeamAri : "".concat(ARI_PREFIX).concat(teamIdOrTeamAri);
4
+ };
@@ -0,0 +1,72 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { useEffect } from 'react';
5
+ import { createHook, createStore } from 'react-sweet-state';
6
+ import { teamsClient } from '../../../services';
7
+ var initialState = {
8
+ teamContainers: [],
9
+ loading: true,
10
+ error: null
11
+ };
12
+ var actions = {
13
+ fetchTeamContainers: function fetchTeamContainers(teamId) {
14
+ return /*#__PURE__*/function () {
15
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
16
+ var setState, containers;
17
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ setState = _ref.setState;
21
+ setState({
22
+ loading: true,
23
+ error: null
24
+ });
25
+ _context.prev = 2;
26
+ _context.next = 5;
27
+ return teamsClient.getTeamContainers(teamId);
28
+ case 5:
29
+ containers = _context.sent;
30
+ setState({
31
+ teamContainers: containers,
32
+ loading: false,
33
+ error: null
34
+ });
35
+ _context.next = 12;
36
+ break;
37
+ case 9:
38
+ _context.prev = 9;
39
+ _context.t0 = _context["catch"](2);
40
+ setState({
41
+ teamContainers: [],
42
+ error: _context.t0,
43
+ loading: false
44
+ });
45
+ case 12:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }, _callee, null, [[2, 9]]);
50
+ }));
51
+ return function (_x) {
52
+ return _ref2.apply(this, arguments);
53
+ };
54
+ }();
55
+ }
56
+ };
57
+ var Store = createStore({
58
+ initialState: initialState,
59
+ actions: actions,
60
+ name: 'teamContainersStore'
61
+ });
62
+ export var useTeamContainersHook = createHook(Store);
63
+ export var useTeamContainers = function useTeamContainers(teamId) {
64
+ var _useTeamContainersHoo = useTeamContainersHook(),
65
+ _useTeamContainersHoo2 = _slicedToArray(_useTeamContainersHoo, 2),
66
+ state = _useTeamContainersHoo2[0],
67
+ actions = _useTeamContainersHoo2[1];
68
+ useEffect(function () {
69
+ actions.fetchTeamContainers(teamId);
70
+ }, [teamId, actions]);
71
+ return state;
72
+ };
@@ -0,0 +1 @@
1
+ export { useTeamContainers } from './hooks/use-team-containers';
@@ -0,0 +1,72 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
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 _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ import { teamIdToAri } from '../../common/utils/team-id-to-ari';
11
+ import { DEFAULT_CONFIG } from '../constants';
12
+ import { BaseGraphQlClient } from '../graphql-client';
13
+ import { TeamContainersQuery } from './utils/queries/team-containers-query';
14
+ export var AGGClient = /*#__PURE__*/function (_BaseGraphQlClient) {
15
+ function AGGClient(baseUrl, config) {
16
+ _classCallCheck(this, AGGClient);
17
+ return _callSuper(this, AGGClient, ["".concat(baseUrl, "/graphql"), config]);
18
+ }
19
+ _inherits(AGGClient, _BaseGraphQlClient);
20
+ return _createClass(AGGClient, [{
21
+ key: "setBaseUrl",
22
+ value: function setBaseUrl(baseUrl) {
23
+ this.setServiceUrl("".concat(baseUrl, "/graphql"));
24
+ }
25
+ }, {
26
+ key: "getTeamContainers",
27
+ value: function () {
28
+ var _getTeamContainers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(teamId) {
29
+ var teamAri, cypherQuery, response, containersResult;
30
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
31
+ while (1) switch (_context.prev = _context.next) {
32
+ case 0:
33
+ teamAri = teamIdToAri(teamId);
34
+ cypherQuery = "MATCH (team:IdentityTeam {id: '".concat(teamAri, "'})-[:team_connected_to_container]->(container) RETURN container");
35
+ _context.next = 4;
36
+ return this.makeGraphQLRequest({
37
+ query: TeamContainersQuery,
38
+ variables: {
39
+ cypherQuery: cypherQuery
40
+ }
41
+ }, {
42
+ operationName: 'TeamContainersQuery'
43
+ });
44
+ case 4:
45
+ response = _context.sent;
46
+ containersResult = response.graphStore.cypherQuery.edges.map(function (edge) {
47
+ return {
48
+ id: edge.node.to.id,
49
+ type: edge.node.to.data.__typename,
50
+ name: edge.node.to.data.__typename === 'ConfluenceSpace' ? edge.node.to.data.confluenceSpaceName || '' : edge.node.to.data.jiraProjectName,
51
+ icon: edge.node.to.data.__typename === 'ConfluenceSpace' ? "".concat(edge.node.to.data.links.base).concat(edge.node.to.data.icon.path) : edge.node.to.data.avatar.medium,
52
+ createdDate: edge.node.to.data.__typename === 'ConfluenceSpace' ? new Date(edge.node.to.data.createdDate) : new Date(edge.node.to.data.created),
53
+ link: edge.node.to.data.__typename === 'ConfluenceSpace' ? "".concat(edge.node.to.data.links.base).concat(edge.node.to.data.links.webUi) : edge.node.to.data.webUrl
54
+ };
55
+ });
56
+ return _context.abrupt("return", containersResult);
57
+ case 7:
58
+ case "end":
59
+ return _context.stop();
60
+ }
61
+ }, _callee, this);
62
+ }));
63
+ function getTeamContainers(_x) {
64
+ return _getTeamContainers.apply(this, arguments);
65
+ }
66
+ return getTeamContainers;
67
+ }()
68
+ }]);
69
+ }(BaseGraphQlClient);
70
+ export var aggClient = new AGGClient(DEFAULT_CONFIG.stargateRoot, {
71
+ logException: function logException() {}
72
+ });
@@ -0,0 +1,46 @@
1
+ export var MOCK_TEAM_CONTAINERS = {
2
+ graphStore: {
3
+ cypherQuery: {
4
+ edges: [{
5
+ node: {
6
+ from: {
7
+ id: '1'
8
+ },
9
+ to: {
10
+ id: '2',
11
+ data: {
12
+ __typename: 'ConfluenceSpace',
13
+ confluenceSpaceName: 'Confluence Space',
14
+ type: 'confluence',
15
+ createdDate: '2021-01-01',
16
+ links: {
17
+ webUi: 'web-link'
18
+ },
19
+ icon: {
20
+ path: 'https://avatar-management--avatars.us-west-2.staging.public.atl-paas.net/712020:2981defd-17f1-440e-a377-8c7657b72a6f/4b5b0d55-614b-4e75-858f-9da3d0c7e3f8/128'
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }, {
26
+ node: {
27
+ from: {
28
+ id: '1'
29
+ },
30
+ to: {
31
+ id: '3',
32
+ data: {
33
+ __typename: 'JiraProject',
34
+ jiraProjectName: 'Jira Project',
35
+ webUrl: 'web-link',
36
+ created: '2021-01-01',
37
+ avatar: {
38
+ medium: 'https://avatar-management--avatars.us-west-2.staging.public.atl-paas.net/712020:2981defd-17f1-440e-a377-8c7657b72a6f/4b5b0d55-614b-4e75-858f-9da3d0c7e3f8/128'
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }]
44
+ }
45
+ }
46
+ };
@@ -0,0 +1,5 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import { print } from 'graphql';
4
+ import gql from 'graphql-tag';
5
+ export var TeamContainersQuery = print(gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tquery TeamContainersQuery($cypherQuery: String!) {\n\t\tgraphStore @optIn(to: [\"GraphStore\"]) {\n\t\t\tcypherQuery(query: $cypherQuery) @optIn(to: [\"GraphStoreCypherQuery\"]) {\n\t\t\t\tedges {\n\t\t\t\t\t__typename\n\t\t\t\t\tnode {\n\t\t\t\t\t\tfrom {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t}\n\t\t\t\t\t\tto {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tdata {\n\t\t\t\t\t\t\t\t__typename\n\t\t\t\t\t\t\t\t... on ConfluenceSpace {\n\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\tconfluenceSpaceName: name\n\t\t\t\t\t\t\t\t\ttype\n\t\t\t\t\t\t\t\t\tcreatedDate\n\t\t\t\t\t\t\t\t\tlinks {\n\t\t\t\t\t\t\t\t\t\tbase\n\t\t\t\t\t\t\t\t\t\twebUi\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\ticon {\n\t\t\t\t\t\t\t\t\t\tpath\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t... on JiraProject {\n\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\tjiraProjectName: name\n\t\t\t\t\t\t\t\t\twebUrl\n\t\t\t\t\t\t\t\t\tcreated\n\t\t\t\t\t\t\t\t\tavatar {\n\t\t\t\t\t\t\t\t\t\tmedium\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"]))));
@@ -0,0 +1,85 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ export var BaseClient = /*#__PURE__*/function () {
7
+ function BaseClient(config) {
8
+ var _this = this;
9
+ _classCallCheck(this, BaseClient);
10
+ _defineProperty(this, "cache", {});
11
+ _defineProperty(this, "logException", function (ex, name, context) {
12
+ _this.config.logException(ex, name, context);
13
+ });
14
+ this.config = config;
15
+ this.context = {
16
+ cloudId: null
17
+ };
18
+ }
19
+ return _createClass(BaseClient, [{
20
+ key: "setContext",
21
+ value: function setContext(context) {
22
+ this.context = _objectSpread(_objectSpread({}, context), {}, {
23
+ cloudId: context.cloudId || null
24
+ });
25
+ }
26
+ }, {
27
+ key: "getContext",
28
+ value: function getContext() {
29
+ return this.context;
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @param localValue is used for backwards compatibility
35
+ * @returns
36
+ */
37
+ }, {
38
+ key: "getOrgId",
39
+ value: function getOrgId(localValue) {
40
+ var orgId = localValue || this.getContext().orgId;
41
+ if (!orgId) {
42
+ var err = new Error('No orgId set');
43
+ this.logException(err, 'No orgId set');
44
+ throw err;
45
+ }
46
+ return orgId;
47
+ }
48
+ /**
49
+ *
50
+ * @param localValue is used for backwards compatibility
51
+ * @returns
52
+ */
53
+ }, {
54
+ key: "getCloudId",
55
+ value: function getCloudId(localValue) {
56
+ return localValue || this.getContext().cloudId;
57
+ }
58
+ }, {
59
+ key: "keyWithContext",
60
+ value: function keyWithContext(key) {
61
+ var _this$getContext$orgI, _this$getContext$user;
62
+ return "".concat(this.getContext().cloudId, "-").concat((_this$getContext$orgI = this.getContext().orgId) !== null && _this$getContext$orgI !== void 0 ? _this$getContext$orgI : 'no-org-id', "-").concat((_this$getContext$user = this.getContext().userId) !== null && _this$getContext$user !== void 0 ? _this$getContext$user : 'no-user-id', "-").concat(key);
63
+ }
64
+
65
+ // Default expiration is 5 minutes
66
+ }, {
67
+ key: "cacheValue",
68
+ value: function cacheValue(key, value) {
69
+ var expiryMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000 * 60 * 5;
70
+ this.cache[this.keyWithContext(key)] = {
71
+ data: value,
72
+ expiration: Date.now() + expiryMs
73
+ };
74
+ }
75
+ }, {
76
+ key: "getCachedValue",
77
+ value: function getCachedValue(key) {
78
+ var record = this.cache[this.keyWithContext(key)];
79
+ if (record && record.expiration > Date.now()) {
80
+ return record.data;
81
+ }
82
+ return undefined;
83
+ }
84
+ }]);
85
+ }();
@@ -0,0 +1,3 @@
1
+ export var DEFAULT_CONFIG = {
2
+ stargateRoot: '/gateway/api'
3
+ };
@@ -0,0 +1 @@
1
+ export { BaseGraphQlClient } from './main';
@@ -0,0 +1,62 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
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 _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ import { DefaultError, GraphQLError } from '../../common/utils/error';
11
+ import { BaseClient } from '../base-client';
12
+ import { handleGraphQLRequest } from './utils';
13
+ export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
14
+ function BaseGraphQlClient(serviceUrl, config) {
15
+ var _this;
16
+ _classCallCheck(this, BaseGraphQlClient);
17
+ _this = _callSuper(this, BaseGraphQlClient, [config]);
18
+ _this.serviceUrl = serviceUrl;
19
+ return _this;
20
+ }
21
+ _inherits(BaseGraphQlClient, _BaseClient);
22
+ return _createClass(BaseGraphQlClient, [{
23
+ key: "setServiceUrl",
24
+ value: function setServiceUrl(serviceUrl) {
25
+ this.serviceUrl = serviceUrl;
26
+ }
27
+ }, {
28
+ key: "makeGraphQLRequest",
29
+ value: function () {
30
+ var _makeGraphQLRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(body) {
31
+ var options,
32
+ _args = arguments;
33
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
34
+ while (1) switch (_context.prev = _context.next) {
35
+ case 0:
36
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
37
+ _context.prev = 1;
38
+ return _context.abrupt("return", handleGraphQLRequest(this.serviceUrl, body, options));
39
+ case 5:
40
+ _context.prev = 5;
41
+ _context.t0 = _context["catch"](1);
42
+ if (!(_context.t0 instanceof GraphQLError)) {
43
+ _context.next = 9;
44
+ break;
45
+ }
46
+ throw _context.t0;
47
+ case 9:
48
+ this.logException(_context.t0, 'UnknownError in GraphQLClient.makeGraphQLRequestWithoutRetries');
49
+ throw new DefaultError({});
50
+ case 11:
51
+ case "end":
52
+ return _context.stop();
53
+ }
54
+ }, _callee, this, [[1, 5]]);
55
+ }));
56
+ function makeGraphQLRequest(_x) {
57
+ return _makeGraphQLRequest.apply(this, arguments);
58
+ }
59
+ return makeGraphQLRequest;
60
+ }()
61
+ }]);
62
+ }(BaseClient);
@@ -0,0 +1 @@
1
+ export {};