@atlaskit/profilecard 16.2.3 → 16.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 16.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ce207d8ea47`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ce207d8ea47) - Add option to query teams with AGG
8
+
3
9
  ## 16.2.3
4
10
 
5
11
  ### Patch Changes
@@ -23,6 +23,8 @@ var _performance = require("../util/performance");
23
23
 
24
24
  var _CachingClient2 = _interopRequireDefault(require("./CachingClient"));
25
25
 
26
+ var _getTeamFromAGG = require("./getTeamFromAGG");
27
+
26
28
  var _graphqlUtils = require("./graphqlUtils");
27
29
 
28
30
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -30,11 +32,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
30
32
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
33
 
32
34
  var QUERY = "query Team($teamId: String!, $organizationId: String) {\n Team: Team(teamId: $teamId, organizationId: $organizationId) {\n id,\n description,\n displayName,\n largeHeaderImageUrl,\n smallHeaderImageUrl,\n largeAvatarImageUrl,\n smallAvatarImageUrl,\n members {\n id,\n fullName,\n avatarUrl,\n },\n }\n}";
33
- /**
34
- * @param {string} userId
35
- * @param {string} cloudId
36
- * @return {string} GraphQL Query String
37
- */
38
35
 
39
36
  var buildTeamQuery = function buildTeamQuery(teamId, orgId) {
40
37
  return {
@@ -61,6 +58,15 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
61
58
  }
62
59
 
63
60
  (0, _createClass2.default)(TeamProfileCardClient, [{
61
+ key: "makeRequestViaGateway",
62
+ value: function makeRequestViaGateway(teamId, _orgId) {
63
+ if (!this.options.gatewayGraphqlUrl) {
64
+ throw new Error('Trying to fetch via gateway with no specified config.gatewayGraphqlUrl');
65
+ }
66
+
67
+ return (0, _getTeamFromAGG.getTeamFromAGG)(this.options.gatewayGraphqlUrl, teamId);
68
+ }
69
+ }, {
64
70
  key: "makeRequest",
65
71
  value: function makeRequest(teamId, orgId) {
66
72
  if (!this.options.url) {
@@ -94,14 +100,17 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
94
100
  analytics((0, _analytics.teamRequestAnalytics)('triggered'));
95
101
  }
96
102
 
97
- _this2.makeRequest(teamId, orgId).then(function (data) {
103
+ var shouldUseGateway = !!_this2.options.gatewayGraphqlUrl;
104
+ var promise = shouldUseGateway ? _this2.makeRequestViaGateway(teamId, orgId) : _this2.makeRequest(teamId, orgId);
105
+ promise.then(function (data) {
98
106
  if (_this2.cache) {
99
107
  _this2.setCachedProfile(teamId, data);
100
108
  }
101
109
 
102
110
  if (analytics) {
103
111
  analytics((0, _analytics.teamRequestAnalytics)('succeeded', {
104
- duration: (0, _performance.getPageTime)() - startTime
112
+ duration: (0, _performance.getPageTime)() - startTime,
113
+ gateway: shouldUseGateway
105
114
  }));
106
115
  }
107
116
 
@@ -111,7 +120,8 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
111
120
  analytics((0, _analytics.teamRequestAnalytics)('failed', {
112
121
  duration: (0, _performance.getPageTime)() - startTime,
113
122
  errorStatus: error.code,
114
- errorReason: error.reason
123
+ errorReason: error.reason,
124
+ gateway: shouldUseGateway
115
125
  }));
116
126
  }
117
127
 
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.extractIdFromAri = exports.convertTeam = exports.buildGatewayQuery = exports.addExperimentalHeaders = void 0;
9
+ exports.getTeamFromAGG = getTeamFromAGG;
10
+ exports.idToAri = void 0;
11
+
12
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
18
+ var _graphqlUtils = require("./graphqlUtils");
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ var extractIdFromAri = function extractIdFromAri(ari) {
25
+ var slashPos = ari.indexOf('/');
26
+ var id = ari.slice(slashPos + 1);
27
+ return id;
28
+ };
29
+
30
+ exports.extractIdFromAri = extractIdFromAri;
31
+
32
+ var idToAri = function idToAri(teamId) {
33
+ return "ari:cloud:teams::team/".concat(teamId);
34
+ };
35
+
36
+ exports.idToAri = idToAri;
37
+
38
+ var convertTeam = function convertTeam(result) {
39
+ var _team$members;
40
+
41
+ var team = result.team;
42
+ return _objectSpread(_objectSpread({}, team), {}, {
43
+ id: extractIdFromAri(team.id),
44
+ members: (_team$members = team.members) === null || _team$members === void 0 ? void 0 : _team$members.nodes.map(function (_ref) {
45
+ var member = _ref.member;
46
+ return {
47
+ id: member.accountId,
48
+ fullName: member.name,
49
+ avatarUrl: member.picture
50
+ };
51
+ })
52
+ });
53
+ };
54
+
55
+ exports.convertTeam = convertTeam;
56
+ var GATEWAY_QUERY = "query TeamCard($teamId: ID!) {\n Team: team {\n team (id: $teamId) {\n id\n displayName\n description\n smallHeaderImageUrl\n largeHeaderImageUrl\n smallAvatarImageUrl\n largeAvatarImageUrl\n members {\n nodes {\n member {\n accountId\n name\n picture\n }\n }\n }\n }\n }\n}";
57
+
58
+ var buildGatewayQuery = function buildGatewayQuery(teamId) {
59
+ return {
60
+ query: GATEWAY_QUERY,
61
+ variables: {
62
+ teamId: idToAri(teamId)
63
+ }
64
+ };
65
+ };
66
+
67
+ exports.buildGatewayQuery = buildGatewayQuery;
68
+
69
+ var addExperimentalHeaders = function addExperimentalHeaders(headers) {
70
+ headers.append('X-ExperimentalApi', 'teams-beta');
71
+ headers.append('X-ExperimentalApi', 'team-members-beta');
72
+ return headers;
73
+ };
74
+
75
+ exports.addExperimentalHeaders = addExperimentalHeaders;
76
+
77
+ function getTeamFromAGG(_x, _x2) {
78
+ return _getTeamFromAGG.apply(this, arguments);
79
+ }
80
+
81
+ function _getTeamFromAGG() {
82
+ _getTeamFromAGG = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url, teamId) {
83
+ var query, _yield$graphqlQuery, Team;
84
+
85
+ return _regenerator.default.wrap(function _callee$(_context) {
86
+ while (1) {
87
+ switch (_context.prev = _context.next) {
88
+ case 0:
89
+ query = buildGatewayQuery(teamId);
90
+ _context.next = 3;
91
+ return (0, _graphqlUtils.graphqlQuery)(url, query, addExperimentalHeaders);
92
+
93
+ case 3:
94
+ _yield$graphqlQuery = _context.sent;
95
+ Team = _yield$graphqlQuery.Team;
96
+ return _context.abrupt("return", convertTeam(Team));
97
+
98
+ case 6:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }
103
+ }, _callee);
104
+ }));
105
+ return _getTeamFromAGG.apply(this, arguments);
106
+ }
@@ -11,12 +11,19 @@ var buildHeaders = function buildHeaders() {
11
11
  return headers;
12
12
  };
13
13
 
14
+ var id = function id(headers) {
15
+ return headers;
16
+ };
14
17
  /**
15
18
  * @param {string} serviceUrl - GraphQL service endpoint
16
19
  * @param {Query} query - GraphQL query
20
+ * @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
17
21
  */
22
+
23
+
18
24
  function graphqlQuery(serviceUrl, query) {
19
- var headers = buildHeaders();
25
+ var processHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : id;
26
+ var headers = processHeaders(buildHeaders());
20
27
  return fetch(new Request(serviceUrl, {
21
28
  method: 'POST',
22
29
  credentials: 'include',
@@ -59,6 +59,11 @@ function getMockTeamClient(data) {
59
59
  }, data.timeout);
60
60
  });
61
61
  }
62
+ }, {
63
+ key: "makeRequestViaGateway",
64
+ value: function makeRequestViaGateway(teamId) {
65
+ return this.makeRequest(teamId);
66
+ }
62
67
  }]);
63
68
  return MockTeamClient;
64
69
  }(_TeamProfileCardClient.default);
@@ -31,7 +31,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
31
31
  actionSubjectId: actionSubjectId,
32
32
  attributes: _objectSpread(_objectSpread({
33
33
  packageName: "@atlaskit/profilecard",
34
- packageVersion: "16.2.3"
34
+ packageVersion: "16.3.0"
35
35
  }, attributes), {}, {
36
36
  firedAt: (0, _performance.getPageTime)()
37
37
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.2.3"
3
+ "version": "16.3.0"
4
4
  }
@@ -1,6 +1,7 @@
1
1
  import { teamRequestAnalytics } from '../util/analytics';
2
2
  import { getPageTime } from '../util/performance';
3
3
  import CachingClient from './CachingClient';
4
+ import { getTeamFromAGG } from './getTeamFromAGG';
4
5
  import { graphqlQuery } from './graphqlUtils';
5
6
  const QUERY = `query Team($teamId: String!, $organizationId: String) {
6
7
  Team: Team(teamId: $teamId, organizationId: $organizationId) {
@@ -18,11 +19,6 @@ const QUERY = `query Team($teamId: String!, $organizationId: String) {
18
19
  },
19
20
  }
20
21
  }`;
21
- /**
22
- * @param {string} userId
23
- * @param {string} cloudId
24
- * @return {string} GraphQL Query String
25
- */
26
22
 
27
23
  const buildTeamQuery = (teamId, orgId) => ({
28
24
  query: QUERY,
@@ -38,6 +34,14 @@ export default class TeamProfileCardClient extends CachingClient {
38
34
  this.options = options;
39
35
  }
40
36
 
37
+ makeRequestViaGateway(teamId, _orgId) {
38
+ if (!this.options.gatewayGraphqlUrl) {
39
+ throw new Error('Trying to fetch via gateway with no specified config.gatewayGraphqlUrl');
40
+ }
41
+
42
+ return getTeamFromAGG(this.options.gatewayGraphqlUrl, teamId);
43
+ }
44
+
41
45
  makeRequest(teamId, orgId) {
42
46
  if (!this.options.url) {
43
47
  throw new Error('config.url is a required parameter for fetching teams');
@@ -65,14 +69,17 @@ export default class TeamProfileCardClient extends CachingClient {
65
69
  analytics(teamRequestAnalytics('triggered'));
66
70
  }
67
71
 
68
- this.makeRequest(teamId, orgId).then(data => {
72
+ const shouldUseGateway = !!this.options.gatewayGraphqlUrl;
73
+ const promise = shouldUseGateway ? this.makeRequestViaGateway(teamId, orgId) : this.makeRequest(teamId, orgId);
74
+ promise.then(data => {
69
75
  if (this.cache) {
70
76
  this.setCachedProfile(teamId, data);
71
77
  }
72
78
 
73
79
  if (analytics) {
74
80
  analytics(teamRequestAnalytics('succeeded', {
75
- duration: getPageTime() - startTime
81
+ duration: getPageTime() - startTime,
82
+ gateway: shouldUseGateway
76
83
  }));
77
84
  }
78
85
 
@@ -82,7 +89,8 @@ export default class TeamProfileCardClient extends CachingClient {
82
89
  analytics(teamRequestAnalytics('failed', {
83
90
  duration: getPageTime() - startTime,
84
91
  errorStatus: error.code,
85
- errorReason: error.reason
92
+ errorReason: error.reason,
93
+ gateway: shouldUseGateway
86
94
  }));
87
95
  }
88
96
 
@@ -0,0 +1,66 @@
1
+ import { graphqlQuery } from './graphqlUtils';
2
+ export const extractIdFromAri = ari => {
3
+ const slashPos = ari.indexOf('/');
4
+ const id = ari.slice(slashPos + 1);
5
+ return id;
6
+ };
7
+ export const idToAri = teamId => {
8
+ return `ari:cloud:teams::team/${teamId}`;
9
+ };
10
+ export const convertTeam = result => {
11
+ var _team$members;
12
+
13
+ const {
14
+ team
15
+ } = result;
16
+ return { ...team,
17
+ id: extractIdFromAri(team.id),
18
+ members: (_team$members = team.members) === null || _team$members === void 0 ? void 0 : _team$members.nodes.map(({
19
+ member
20
+ }) => ({
21
+ id: member.accountId,
22
+ fullName: member.name,
23
+ avatarUrl: member.picture
24
+ }))
25
+ };
26
+ };
27
+ const GATEWAY_QUERY = `query TeamCard($teamId: ID!) {
28
+ Team: team {
29
+ team (id: $teamId) {
30
+ id
31
+ displayName
32
+ description
33
+ smallHeaderImageUrl
34
+ largeHeaderImageUrl
35
+ smallAvatarImageUrl
36
+ largeAvatarImageUrl
37
+ members {
38
+ nodes {
39
+ member {
40
+ accountId
41
+ name
42
+ picture
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }`;
49
+ export const buildGatewayQuery = teamId => ({
50
+ query: GATEWAY_QUERY,
51
+ variables: {
52
+ teamId: idToAri(teamId)
53
+ }
54
+ });
55
+ export const addExperimentalHeaders = headers => {
56
+ headers.append('X-ExperimentalApi', 'teams-beta');
57
+ headers.append('X-ExperimentalApi', 'team-members-beta');
58
+ return headers;
59
+ };
60
+ export async function getTeamFromAGG(url, teamId) {
61
+ const query = buildGatewayQuery(teamId);
62
+ const {
63
+ Team
64
+ } = await graphqlQuery(url, query, addExperimentalHeaders);
65
+ return convertTeam(Team);
66
+ }
@@ -4,12 +4,16 @@ const buildHeaders = () => {
4
4
  return headers;
5
5
  };
6
6
 
7
+ const id = headers => headers;
7
8
  /**
8
9
  * @param {string} serviceUrl - GraphQL service endpoint
9
10
  * @param {Query} query - GraphQL query
11
+ * @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
10
12
  */
11
- export function graphqlQuery(serviceUrl, query) {
12
- const headers = buildHeaders();
13
+
14
+
15
+ export function graphqlQuery(serviceUrl, query, processHeaders = id) {
16
+ const headers = processHeaders(buildHeaders());
13
17
  return fetch(new Request(serviceUrl, {
14
18
  method: 'POST',
15
19
  credentials: 'include',
@@ -25,5 +25,9 @@ export default function getMockTeamClient(data) {
25
25
  });
26
26
  }
27
27
 
28
+ makeRequestViaGateway(teamId) {
29
+ return this.makeRequest(teamId);
30
+ }
31
+
28
32
  };
29
33
  }
@@ -11,7 +11,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
11
11
  actionSubjectId,
12
12
  attributes: {
13
13
  packageName: "@atlaskit/profilecard",
14
- packageVersion: "16.2.3",
14
+ packageVersion: "16.3.0",
15
15
  ...attributes,
16
16
  firedAt: getPageTime()
17
17
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.2.3"
3
+ "version": "16.3.0"
4
4
  }
@@ -11,13 +11,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
11
11
  import { teamRequestAnalytics } from '../util/analytics';
12
12
  import { getPageTime } from '../util/performance';
13
13
  import CachingClient from './CachingClient';
14
+ import { getTeamFromAGG } from './getTeamFromAGG';
14
15
  import { graphqlQuery } from './graphqlUtils';
15
16
  var QUERY = "query Team($teamId: String!, $organizationId: String) {\n Team: Team(teamId: $teamId, organizationId: $organizationId) {\n id,\n description,\n displayName,\n largeHeaderImageUrl,\n smallHeaderImageUrl,\n largeAvatarImageUrl,\n smallAvatarImageUrl,\n members {\n id,\n fullName,\n avatarUrl,\n },\n }\n}";
16
- /**
17
- * @param {string} userId
18
- * @param {string} cloudId
19
- * @return {string} GraphQL Query String
20
- */
21
17
 
22
18
  var buildTeamQuery = function buildTeamQuery(teamId, orgId) {
23
19
  return {
@@ -45,6 +41,15 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
45
41
  }
46
42
 
47
43
  _createClass(TeamProfileCardClient, [{
44
+ key: "makeRequestViaGateway",
45
+ value: function makeRequestViaGateway(teamId, _orgId) {
46
+ if (!this.options.gatewayGraphqlUrl) {
47
+ throw new Error('Trying to fetch via gateway with no specified config.gatewayGraphqlUrl');
48
+ }
49
+
50
+ return getTeamFromAGG(this.options.gatewayGraphqlUrl, teamId);
51
+ }
52
+ }, {
48
53
  key: "makeRequest",
49
54
  value: function makeRequest(teamId, orgId) {
50
55
  if (!this.options.url) {
@@ -78,14 +83,17 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
78
83
  analytics(teamRequestAnalytics('triggered'));
79
84
  }
80
85
 
81
- _this2.makeRequest(teamId, orgId).then(function (data) {
86
+ var shouldUseGateway = !!_this2.options.gatewayGraphqlUrl;
87
+ var promise = shouldUseGateway ? _this2.makeRequestViaGateway(teamId, orgId) : _this2.makeRequest(teamId, orgId);
88
+ promise.then(function (data) {
82
89
  if (_this2.cache) {
83
90
  _this2.setCachedProfile(teamId, data);
84
91
  }
85
92
 
86
93
  if (analytics) {
87
94
  analytics(teamRequestAnalytics('succeeded', {
88
- duration: getPageTime() - startTime
95
+ duration: getPageTime() - startTime,
96
+ gateway: shouldUseGateway
89
97
  }));
90
98
  }
91
99
 
@@ -95,7 +103,8 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
95
103
  analytics(teamRequestAnalytics('failed', {
96
104
  duration: getPageTime() - startTime,
97
105
  errorStatus: error.code,
98
- errorReason: error.reason
106
+ errorReason: error.reason,
107
+ gateway: shouldUseGateway
99
108
  }));
100
109
  }
101
110
 
@@ -0,0 +1,77 @@
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+
9
+ import { graphqlQuery } from './graphqlUtils';
10
+ export var extractIdFromAri = function extractIdFromAri(ari) {
11
+ var slashPos = ari.indexOf('/');
12
+ var id = ari.slice(slashPos + 1);
13
+ return id;
14
+ };
15
+ export var idToAri = function idToAri(teamId) {
16
+ return "ari:cloud:teams::team/".concat(teamId);
17
+ };
18
+ export var convertTeam = function convertTeam(result) {
19
+ var _team$members;
20
+
21
+ var team = result.team;
22
+ return _objectSpread(_objectSpread({}, team), {}, {
23
+ id: extractIdFromAri(team.id),
24
+ members: (_team$members = team.members) === null || _team$members === void 0 ? void 0 : _team$members.nodes.map(function (_ref) {
25
+ var member = _ref.member;
26
+ return {
27
+ id: member.accountId,
28
+ fullName: member.name,
29
+ avatarUrl: member.picture
30
+ };
31
+ })
32
+ });
33
+ };
34
+ var GATEWAY_QUERY = "query TeamCard($teamId: ID!) {\n Team: team {\n team (id: $teamId) {\n id\n displayName\n description\n smallHeaderImageUrl\n largeHeaderImageUrl\n smallAvatarImageUrl\n largeAvatarImageUrl\n members {\n nodes {\n member {\n accountId\n name\n picture\n }\n }\n }\n }\n }\n}";
35
+ export var buildGatewayQuery = function buildGatewayQuery(teamId) {
36
+ return {
37
+ query: GATEWAY_QUERY,
38
+ variables: {
39
+ teamId: idToAri(teamId)
40
+ }
41
+ };
42
+ };
43
+ export var addExperimentalHeaders = function addExperimentalHeaders(headers) {
44
+ headers.append('X-ExperimentalApi', 'teams-beta');
45
+ headers.append('X-ExperimentalApi', 'team-members-beta');
46
+ return headers;
47
+ };
48
+ export function getTeamFromAGG(_x, _x2) {
49
+ return _getTeamFromAGG.apply(this, arguments);
50
+ }
51
+
52
+ function _getTeamFromAGG() {
53
+ _getTeamFromAGG = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, teamId) {
54
+ var query, _yield$graphqlQuery, Team;
55
+
56
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ while (1) {
58
+ switch (_context.prev = _context.next) {
59
+ case 0:
60
+ query = buildGatewayQuery(teamId);
61
+ _context.next = 3;
62
+ return graphqlQuery(url, query, addExperimentalHeaders);
63
+
64
+ case 3:
65
+ _yield$graphqlQuery = _context.sent;
66
+ Team = _yield$graphqlQuery.Team;
67
+ return _context.abrupt("return", convertTeam(Team));
68
+
69
+ case 6:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }
74
+ }, _callee);
75
+ }));
76
+ return _getTeamFromAGG.apply(this, arguments);
77
+ }
@@ -4,12 +4,19 @@ var buildHeaders = function buildHeaders() {
4
4
  return headers;
5
5
  };
6
6
 
7
+ var id = function id(headers) {
8
+ return headers;
9
+ };
7
10
  /**
8
11
  * @param {string} serviceUrl - GraphQL service endpoint
9
12
  * @param {Query} query - GraphQL query
13
+ * @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
10
14
  */
15
+
16
+
11
17
  export function graphqlQuery(serviceUrl, query) {
12
- var headers = buildHeaders();
18
+ var processHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : id;
19
+ var headers = processHeaders(buildHeaders());
13
20
  return fetch(new Request(serviceUrl, {
14
21
  method: 'POST',
15
22
  credentials: 'include',
@@ -46,6 +46,11 @@ export default function getMockTeamClient(data) {
46
46
  }, data.timeout);
47
47
  });
48
48
  }
49
+ }, {
50
+ key: "makeRequestViaGateway",
51
+ value: function makeRequestViaGateway(teamId) {
52
+ return this.makeRequest(teamId);
53
+ }
49
54
  }]);
50
55
 
51
56
  return MockTeamClient;
@@ -19,7 +19,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
19
19
  actionSubjectId: actionSubjectId,
20
20
  attributes: _objectSpread(_objectSpread({
21
21
  packageName: "@atlaskit/profilecard",
22
- packageVersion: "16.2.3"
22
+ packageVersion: "16.3.0"
23
23
  }, attributes), {}, {
24
24
  firedAt: getPageTime()
25
25
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.2.3"
3
+ "version": "16.3.0"
4
4
  }
@@ -3,6 +3,7 @@ import CachingClient from './CachingClient';
3
3
  export default class TeamProfileCardClient extends CachingClient<Team> {
4
4
  options: ProfileClientOptions;
5
5
  constructor(options: ProfileClientOptions);
6
+ makeRequestViaGateway(teamId: string, _orgId: string | undefined): Promise<Team>;
6
7
  makeRequest(teamId: string, orgId: string | undefined): Promise<Team>;
7
8
  getProfile(teamId: string, orgId: string | undefined, analytics?: (event: Record<string, any>) => void): Promise<Team>;
8
9
  }
@@ -0,0 +1,28 @@
1
+ import type { Team } from '../types';
2
+ interface AGGTeam extends Omit<Team, 'members'> {
3
+ members?: {
4
+ nodes: AGGMember[];
5
+ };
6
+ }
7
+ interface AGGMember {
8
+ member: {
9
+ accountId: string;
10
+ name: string;
11
+ picture: string;
12
+ };
13
+ }
14
+ interface AGGResult {
15
+ team: AGGTeam;
16
+ }
17
+ export declare const extractIdFromAri: (ari: string) => string;
18
+ export declare const idToAri: (teamId: string) => string;
19
+ export declare const convertTeam: (result: AGGResult) => Team;
20
+ export declare const buildGatewayQuery: (teamId: string) => {
21
+ query: string;
22
+ variables: {
23
+ teamId: string;
24
+ };
25
+ };
26
+ export declare const addExperimentalHeaders: (headers: Headers) => Headers;
27
+ export declare function getTeamFromAGG(url: string, teamId: string): Promise<Team>;
28
+ export {};
@@ -6,9 +6,11 @@ export interface GraphQLError {
6
6
  code?: number;
7
7
  reason: string;
8
8
  }
9
+ declare type HeaderProcessor = (headers: Headers) => Headers;
9
10
  /**
10
11
  * @param {string} serviceUrl - GraphQL service endpoint
11
12
  * @param {Query} query - GraphQL query
13
+ * @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
12
14
  */
13
- export declare function graphqlQuery<D>(serviceUrl: string, query: Query): Promise<D>;
15
+ export declare function graphqlQuery<D>(serviceUrl: string, query: Query, processHeaders?: HeaderProcessor): Promise<D>;
14
16
  export {};
@@ -309,6 +309,7 @@ export declare type ProfileCardErrorType = {
309
309
  } | null;
310
310
  export interface ProfileClientOptions {
311
311
  url: string;
312
+ gatewayGraphqlUrl?: string;
312
313
  cacheSize?: number;
313
314
  cacheMaxAge?: number;
314
315
  /** Enables Team Central functionality if enabled */
@@ -2,7 +2,7 @@ export declare const firePeopleTeamsEvent: (payload: Record<string, any>) => (cr
2
2
  export declare const teamCardTriggered: (method: 'hover' | 'click') => Record<string, any>;
3
3
  export declare const teamRequestAnalytics: (action: 'triggered' | 'succeeded' | 'failed', attributes?: ({
4
4
  duration: number;
5
- } & Record<string, string | number | undefined>) | undefined) => Record<string, any>;
5
+ } & Record<string, string | number | boolean | undefined>) | undefined) => Record<string, any>;
6
6
  export declare const teamProfileCardRendered: (actionSubjectId: 'spinner' | 'content' | 'error' | 'errorBoundary', attributes: {
7
7
  duration: number;
8
8
  hasRetry?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.2.3",
3
+ "version": "16.3.0",
4
4
  "description": "A React component to display a card with user information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"