@atlaskit/profilecard 24.19.0 → 24.20.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 (36) hide show
  1. package/CHANGELOG.md +18 -21
  2. package/dist/cjs/client/RovoAgentCardClient.js +201 -33
  3. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  4. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  5. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +55 -34
  6. package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +55 -33
  7. package/dist/cjs/mocks/agent-data.js +7 -1
  8. package/dist/cjs/mocks/simple-mock-clients.js +8 -3
  9. package/dist/cjs/util/analytics.js +2 -2
  10. package/dist/es2019/client/RovoAgentCardClient.js +135 -9
  11. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  12. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  13. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +26 -3
  14. package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +26 -3
  15. package/dist/es2019/mocks/agent-data.js +6 -0
  16. package/dist/es2019/mocks/simple-mock-clients.js +6 -3
  17. package/dist/es2019/util/analytics.js +2 -2
  18. package/dist/esm/client/RovoAgentCardClient.js +202 -34
  19. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  20. package/dist/esm/client/getTeamFromAGG.js +1 -1
  21. package/dist/esm/components/Agent/AgentProfileCardResourced.js +55 -34
  22. package/dist/esm/components/Agent/AgentProfileCardTrigger.js +55 -33
  23. package/dist/esm/mocks/agent-data.js +6 -0
  24. package/dist/esm/mocks/simple-mock-clients.js +6 -3
  25. package/dist/esm/util/analytics.js +2 -2
  26. package/dist/types/client/ProfileCardClient.d.ts +1 -1
  27. package/dist/types/client/RovoAgentCardClient.d.ts +14 -4
  28. package/dist/types/mocks/agent-data.d.ts +2 -1
  29. package/dist/types/mocks/simple-mock-clients.d.ts +2 -2
  30. package/dist/types/types.d.ts +11 -1
  31. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +1 -1
  32. package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +14 -4
  33. package/dist/types-ts4.5/mocks/agent-data.d.ts +2 -1
  34. package/dist/types-ts4.5/mocks/simple-mock-clients.d.ts +2 -2
  35. package/dist/types-ts4.5/types.d.ts +11 -1
  36. package/package.json +10 -7
@@ -56,41 +56,57 @@ var AgentProfileCardResourced = exports.AgentProfileCardResourced = function Age
56
56
  cloudId: props.cloudId
57
57
  }),
58
58
  profileHref = _navigateToTeamsApp.href;
59
+
60
+ /**
61
+ * @TODO replace with `getAgentCreator` from `@atlassian/rovo-agent-components`
62
+ * @deprecated use `getAgentCreator` from `@atlassian/rovo-agent-components`
63
+ */
59
64
  var getCreator = (0, _react.useCallback)( /*#__PURE__*/function () {
60
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(creator_type, creator) {
61
- var creatorInfo;
65
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
66
+ var creator_type, creator, authoringTeam, _authoringTeam$displa, _authoringTeam$profil, creatorInfo;
62
67
  return _regenerator.default.wrap(function _callee$(_context) {
63
68
  while (1) switch (_context.prev = _context.next) {
64
69
  case 0:
70
+ creator_type = _ref.creator_type, creator = _ref.creator, authoringTeam = _ref.authoringTeam;
65
71
  if (creator) {
66
- _context.next = 2;
72
+ _context.next = 3;
67
73
  break;
68
74
  }
69
75
  return _context.abrupt("return", undefined);
70
- case 2:
76
+ case 3:
71
77
  _context.t0 = creator_type;
72
- _context.next = _context.t0 === 'SYSTEM' ? 5 : _context.t0 === 'THIRD_PARTY' ? 6 : _context.t0 === 'CUSTOMER' ? 7 : 19;
78
+ _context.next = _context.t0 === 'SYSTEM' ? 6 : _context.t0 === 'THIRD_PARTY' ? 7 : _context.t0 === 'CUSTOMER' ? 8 : 22;
73
79
  break;
74
- case 5:
80
+ case 6:
75
81
  return _context.abrupt("return", {
76
82
  type: 'SYSTEM'
77
83
  });
78
- case 6:
84
+ case 7:
79
85
  return _context.abrupt("return", {
80
86
  type: 'THIRD_PARTY',
81
87
  name: creator !== null && creator !== void 0 ? creator : ''
82
88
  });
83
- case 7:
84
- _context.prev = 7;
89
+ case 8:
90
+ _context.prev = 8;
85
91
  if (!(!creatorUserId || !props.cloudId)) {
86
- _context.next = 10;
92
+ _context.next = 11;
87
93
  break;
88
94
  }
89
95
  return _context.abrupt("return", undefined);
90
- case 10:
91
- _context.next = 12;
96
+ case 11:
97
+ if (!(authoringTeam && (0, _platformFeatureFlags.fg)('agent_studio_permissions_settings_m3_profiles'))) {
98
+ _context.next = 13;
99
+ break;
100
+ }
101
+ return _context.abrupt("return", {
102
+ type: 'CUSTOMER',
103
+ name: (_authoringTeam$displa = authoringTeam.displayName) !== null && _authoringTeam$displa !== void 0 ? _authoringTeam$displa : '',
104
+ profileLink: (_authoringTeam$profil = authoringTeam.profileUrl) !== null && _authoringTeam$profil !== void 0 ? _authoringTeam$profil : ''
105
+ });
106
+ case 13:
107
+ _context.next = 15;
92
108
  return props.resourceClient.getProfile(creatorUserId, props.cloudId, fireAnalytics, fireEventNext);
93
- case 12:
109
+ case 15:
94
110
  creatorInfo = _context.sent;
95
111
  return _context.abrupt("return", {
96
112
  type: 'CUSTOMER',
@@ -98,24 +114,24 @@ var AgentProfileCardResourced = exports.AgentProfileCardResourced = function Age
98
114
  profileLink: (0, _platformFeatureFlags.fg)('platform-adopt-teams-nav-config') ? profileHref : "/people/".concat(creatorUserId),
99
115
  id: creatorUserId
100
116
  });
101
- case 16:
102
- _context.prev = 16;
103
- _context.t1 = _context["catch"](7);
104
- return _context.abrupt("return", undefined);
105
117
  case 19:
118
+ _context.prev = 19;
119
+ _context.t1 = _context["catch"](8);
120
+ return _context.abrupt("return", undefined);
121
+ case 22:
106
122
  return _context.abrupt("return", undefined);
107
- case 20:
123
+ case 23:
108
124
  case "end":
109
125
  return _context.stop();
110
126
  }
111
- }, _callee, null, [[7, 16]]);
127
+ }, _callee, null, [[8, 19]]);
112
128
  }));
113
- return function (_x, _x2) {
114
- return _ref.apply(this, arguments);
129
+ return function (_x) {
130
+ return _ref2.apply(this, arguments);
115
131
  };
116
132
  }(), [creatorUserId, fireAnalytics, fireEventNext, props.cloudId, props.resourceClient, profileHref]);
117
133
  var fetchData = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
118
- var profileData, agentCreatorInfo;
134
+ var _profileResult$aggDat, _profileResult$aggDat2, profileResult, profileData, agentCreatorInfo;
119
135
  return _regenerator.default.wrap(function _callee2$(_context2) {
120
136
  while (1) switch (_context2.prev = _context2.next) {
121
137
  case 0:
@@ -127,29 +143,34 @@ var AgentProfileCardResourced = exports.AgentProfileCardResourced = function Age
127
143
  value: props.accountId
128
144
  }, fireAnalytics, fireEventNext);
129
145
  case 4:
130
- profileData = _context2.sent;
131
- _context2.next = 7;
132
- return getCreator(profileData === null || profileData === void 0 ? void 0 : profileData.creator_type, (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined);
133
- case 7:
146
+ profileResult = _context2.sent;
147
+ profileData = profileResult.restData;
148
+ _context2.next = 8;
149
+ return getCreator({
150
+ creator_type: profileData === null || profileData === void 0 ? void 0 : profileData.creator_type,
151
+ creator: (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined,
152
+ authoringTeam: (_profileResult$aggDat = (_profileResult$aggDat2 = profileResult.aggData) === null || _profileResult$aggDat2 === void 0 ? void 0 : _profileResult$aggDat2.authoringTeam) !== null && _profileResult$aggDat !== void 0 ? _profileResult$aggDat : undefined
153
+ });
154
+ case 8:
134
155
  agentCreatorInfo = _context2.sent;
135
156
  setAgentData(_objectSpread(_objectSpread({}, profileData), {}, {
136
157
  creatorInfo: agentCreatorInfo
137
158
  }));
138
- _context2.next = 14;
159
+ _context2.next = 15;
139
160
  break;
140
- case 11:
141
- _context2.prev = 11;
161
+ case 12:
162
+ _context2.prev = 12;
142
163
  _context2.t0 = _context2["catch"](1);
143
164
  setError(_context2.t0);
144
- case 14:
145
- _context2.prev = 14;
165
+ case 15:
166
+ _context2.prev = 15;
146
167
  setIsLoading(false);
147
- return _context2.finish(14);
148
- case 17:
168
+ return _context2.finish(15);
169
+ case 18:
149
170
  case "end":
150
171
  return _context2.stop();
151
172
  }
152
- }, _callee2, null, [[1, 11, 14, 17]]);
173
+ }, _callee2, null, [[1, 12, 15, 18]]);
153
174
  })), [fireAnalytics, fireEventNext, getCreator, props.accountId, props.resourceClient]);
154
175
  (0, _react.useEffect)(function () {
155
176
  fetchData();
@@ -42,44 +42,60 @@ var AgentProfileCardTrigger = exports.AgentProfileCardTrigger = /*#__PURE__*/(0,
42
42
  (0, _analytics.fireEvent)(createAnalyticsEvent, payload);
43
43
  }
44
44
  }, [createAnalyticsEvent]);
45
+
46
+ /**
47
+ * @TODO replace with `getAgentCreator` from `@atlassian/rovo-agent-components`
48
+ * @deprecated use `getAgentCreator` from `@atlassian/rovo-agent-components`
49
+ */
45
50
  var getCreator = /*#__PURE__*/function () {
46
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(creator_type, creator) {
47
- var _userId, _navigateToTeamsApp, profileHref, creatorInfo;
51
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
52
+ var creator_type, creator, authoringTeam, _userId, _authoringTeam$displa, _authoringTeam$profil, _navigateToTeamsApp, profileHref, creatorInfo;
48
53
  return _regenerator.default.wrap(function _callee$(_context) {
49
54
  while (1) switch (_context.prev = _context.next) {
50
55
  case 0:
56
+ creator_type = _ref2.creator_type, creator = _ref2.creator, authoringTeam = _ref2.authoringTeam;
51
57
  if (creator) {
52
- _context.next = 2;
58
+ _context.next = 3;
53
59
  break;
54
60
  }
55
61
  return _context.abrupt("return", undefined);
56
- case 2:
62
+ case 3:
57
63
  _context.t0 = creator_type;
58
- _context.next = _context.t0 === 'SYSTEM' ? 5 : _context.t0 === 'THIRD_PARTY' ? 6 : _context.t0 === 'FORGE' ? 7 : _context.t0 === 'CUSTOMER' ? 8 : 22;
64
+ _context.next = _context.t0 === 'SYSTEM' ? 6 : _context.t0 === 'THIRD_PARTY' ? 7 : _context.t0 === 'FORGE' ? 8 : _context.t0 === 'CUSTOMER' ? 9 : 25;
59
65
  break;
60
- case 5:
66
+ case 6:
61
67
  return _context.abrupt("return", {
62
68
  type: 'SYSTEM'
63
69
  });
64
- case 6:
70
+ case 7:
65
71
  return _context.abrupt("return", {
66
72
  type: 'THIRD_PARTY',
67
73
  name: creator !== null && creator !== void 0 ? creator : ''
68
74
  });
69
- case 7:
75
+ case 8:
70
76
  return _context.abrupt("return", {
71
77
  type: 'THIRD_PARTY',
72
78
  name: creator !== null && creator !== void 0 ? creator : ''
73
79
  });
74
- case 8:
80
+ case 9:
75
81
  _userId = (0, _rovoAgentUtils.getAAIDFromARI)(creator) || '';
76
- _context.prev = 9;
82
+ _context.prev = 10;
77
83
  if (!(!_userId || !cloudId)) {
78
- _context.next = 12;
84
+ _context.next = 13;
79
85
  break;
80
86
  }
81
87
  return _context.abrupt("return", undefined);
82
- case 12:
88
+ case 13:
89
+ if (!(authoringTeam && (0, _platformFeatureFlags.fg)('agent_studio_permissions_settings_m3_profiles'))) {
90
+ _context.next = 15;
91
+ break;
92
+ }
93
+ return _context.abrupt("return", {
94
+ type: 'CUSTOMER',
95
+ name: (_authoringTeam$displa = authoringTeam.displayName) !== null && _authoringTeam$displa !== void 0 ? _authoringTeam$displa : '',
96
+ profileLink: (_authoringTeam$profil = authoringTeam.profileUrl) !== null && _authoringTeam$profil !== void 0 ? _authoringTeam$profil : ''
97
+ });
98
+ case 15:
83
99
  _navigateToTeamsApp = (0, _navigation.navigateToTeamsApp)({
84
100
  type: 'USER',
85
101
  payload: {
@@ -87,9 +103,9 @@ var AgentProfileCardTrigger = exports.AgentProfileCardTrigger = /*#__PURE__*/(0,
87
103
  },
88
104
  cloudId: cloudId
89
105
  }), profileHref = _navigateToTeamsApp.href;
90
- _context.next = 15;
106
+ _context.next = 18;
91
107
  return props.resourceClient.getProfile(cloudId, _userId, fireAnalytics, fireEventNext);
92
- case 15:
108
+ case 18:
93
109
  creatorInfo = _context.sent;
94
110
  return _context.abrupt("return", {
95
111
  type: 'CUSTOMER',
@@ -97,25 +113,26 @@ var AgentProfileCardTrigger = exports.AgentProfileCardTrigger = /*#__PURE__*/(0,
97
113
  profileLink: (0, _platformFeatureFlags.fg)('platform-adopt-teams-nav-config') ? profileHref : "/people/".concat(_userId),
98
114
  id: _userId
99
115
  });
100
- case 19:
101
- _context.prev = 19;
102
- _context.t1 = _context["catch"](9);
103
- return _context.abrupt("return", undefined);
104
116
  case 22:
117
+ _context.prev = 22;
118
+ _context.t1 = _context["catch"](10);
119
+ return _context.abrupt("return", undefined);
120
+ case 25:
105
121
  return _context.abrupt("return", undefined);
106
- case 23:
122
+ case 26:
107
123
  case "end":
108
124
  return _context.stop();
109
125
  }
110
- }, _callee, null, [[9, 19]]);
126
+ }, _callee, null, [[10, 22]]);
111
127
  }));
112
- return function getCreator(_x, _x2) {
113
- return _ref2.apply(this, arguments);
128
+ return function getCreator(_x) {
129
+ return _ref3.apply(this, arguments);
114
130
  };
115
131
  }();
116
132
  var fetchAgentProfile = /*#__PURE__*/function () {
117
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
118
- var agentInfo, agentCreatorInfo;
133
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
134
+ var _agentProfileResult$a, _agentProfileResult$a2;
135
+ var agentProfileResult, agentInfo, agentCreatorInfo;
119
136
  return _regenerator.default.wrap(function _callee2$(_context2) {
120
137
  while (1) switch (_context2.prev = _context2.next) {
121
138
  case 0:
@@ -125,27 +142,32 @@ var AgentProfileCardTrigger = exports.AgentProfileCardTrigger = /*#__PURE__*/(0,
125
142
  value: userId
126
143
  }, fireAnalytics, fireEventNext);
127
144
  case 2:
128
- agentInfo = _context2.sent;
129
- _context2.next = 5;
130
- return getCreator(agentInfo.creator_type, agentInfo.creator || undefined);
131
- case 5:
145
+ agentProfileResult = _context2.sent;
146
+ agentInfo = agentProfileResult.restData;
147
+ _context2.next = 6;
148
+ return getCreator({
149
+ creator_type: agentInfo.creator_type,
150
+ creator: agentInfo.creator || undefined,
151
+ authoringTeam: (_agentProfileResult$a = (_agentProfileResult$a2 = agentProfileResult.aggData) === null || _agentProfileResult$a2 === void 0 ? void 0 : _agentProfileResult$a2.authoringTeam) !== null && _agentProfileResult$a !== void 0 ? _agentProfileResult$a : undefined
152
+ });
153
+ case 6:
132
154
  agentCreatorInfo = _context2.sent;
133
155
  return _context2.abrupt("return", _objectSpread(_objectSpread({}, agentInfo), {}, {
134
156
  creatorInfo: agentCreatorInfo
135
157
  }));
136
- case 7:
158
+ case 8:
137
159
  case "end":
138
160
  return _context2.stop();
139
161
  }
140
162
  }, _callee2);
141
163
  }));
142
164
  return function fetchAgentProfile() {
143
- return _ref3.apply(this, arguments);
165
+ return _ref4.apply(this, arguments);
144
166
  };
145
167
  }();
146
- var renderProfileCard = function renderProfileCard(_ref4) {
147
- var profileData = _ref4.profileData,
148
- error = _ref4.error;
168
+ var renderProfileCard = function renderProfileCard(_ref5) {
169
+ var profileData = _ref5.profileData,
170
+ error = _ref5.error;
149
171
  return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
150
172
  fallback: null
151
173
  }, /*#__PURE__*/_react.default.createElement(_lazyAgentProfileCard.AgentProfileCardLazy, {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.agentAggData = void 0;
7
7
  var agentData = {
8
8
  id: 'agentId',
9
9
  name: 'Profile card agent',
@@ -17,4 +17,10 @@ var agentData = {
17
17
  user_defined_conversation_starters: [],
18
18
  deactivated: false
19
19
  };
20
+ var agentAggData = exports.agentAggData = {
21
+ authoringTeam: {
22
+ displayName: 'Profile card agent',
23
+ profileUrl: 'https://example.com/profile'
24
+ }
25
+ };
20
26
  var _default = exports.default = agentData;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -15,10 +16,11 @@ var _ProfileCardClient = _interopRequireDefault(require("../client/ProfileCardCl
15
16
  var _RovoAgentCardClient2 = _interopRequireDefault(require("../client/RovoAgentCardClient"));
16
17
  var _TeamProfileCardClient = _interopRequireDefault(require("../client/TeamProfileCardClient"));
17
18
  var _UserProfileCardClient = _interopRequireDefault(require("../client/UserProfileCardClient"));
18
- var _agentData = _interopRequireDefault(require("./agent-data"));
19
+ var _agentData = _interopRequireWildcard(require("./agent-data"));
19
20
  var _profileData = _interopRequireDefault(require("./profile-data"));
20
21
  var _teamData = _interopRequireDefault(require("./team-data"));
21
22
  var _util = require("./util");
23
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
22
24
  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; }
23
25
  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) { (0, _defineProperty2.default)(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; }
24
26
  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)); }
@@ -68,8 +70,11 @@ var SimpleMockAgentClient = /*#__PURE__*/function (_RovoAgentCardClient) {
68
70
  (0, _inherits2.default)(SimpleMockAgentClient, _RovoAgentCardClient);
69
71
  return (0, _createClass2.default)(SimpleMockAgentClient, [{
70
72
  key: "makeRequest",
71
- value: function makeRequest(id, cloudId) {
72
- return Promise.resolve(_agentData.default);
73
+ value: function makeRequest(id) {
74
+ return Promise.resolve({
75
+ restData: _agentData.default,
76
+ aggData: _agentData.agentAggData
77
+ });
73
78
  }
74
79
  }]);
75
80
  }(_RovoAgentCardClient2.default);
@@ -13,7 +13,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
13
13
  var ANALYTICS_CHANNEL = 'peopleTeams';
14
14
  var PACKAGE_META_DATA = exports.PACKAGE_META_DATA = {
15
15
  packageName: "@atlaskit/profilecard",
16
- packageVersion: "24.18.1"
16
+ packageVersion: "24.20.0"
17
17
  };
18
18
  var runItLater = function runItLater(cb) {
19
19
  var requestIdleCallback = window.requestIdleCallback;
@@ -58,7 +58,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
58
58
  actionSubjectId: actionSubjectId,
59
59
  attributes: _objectSpread(_objectSpread({
60
60
  packageName: "@atlaskit/profilecard",
61
- packageVersion: "24.18.1"
61
+ packageVersion: "24.20.0"
62
62
  }, attributes), {}, {
63
63
  firedAt: Math.round((0, _performance.getPageTime)())
64
64
  })
@@ -3,6 +3,64 @@ import { agentRequestAnalytics, PACKAGE_META_DATA } from '../util/analytics';
3
3
  import { getPageTime } from '../util/performance';
4
4
  import CachingClient from './CachingClient';
5
5
  import { DEPRECATED_getErrorAttributes, getErrorAttributes } from './errorUtils';
6
+ import { AGGQuery } from './graphqlUtils';
7
+ const buildActivationIdQuery = (cloudId, product) => ({
8
+ query: `
9
+ query RovoAgentProfileCard_ActivationQuery($cloudId: ID!, $product: String!) {
10
+ tenantContexts(cloudIds: [$cloudId]) {
11
+ activationIdByProduct(product: $product) {
12
+ active
13
+ }
14
+ }
15
+ }
16
+ `,
17
+ variables: {
18
+ cloudId,
19
+ product
20
+ }
21
+ });
22
+ const buildRovoAgentQueryByAri = agentAri => ({
23
+ query: `
24
+ query RovoAgentProfileCard_AgentQueryByAri($agentAri: ID!) {
25
+ agentStudio_agentById(id: $agentAri) @optIn(to: "AgentStudio") {
26
+ __typename
27
+ ... on AgentStudioAssistant {
28
+ authoringTeam {
29
+ displayName
30
+ }
31
+ }
32
+ ... on QueryError {
33
+ message
34
+ }
35
+ }
36
+ }
37
+ `,
38
+ variables: {
39
+ agentAri
40
+ }
41
+ });
42
+ const buildRovoAgentQueryByAccountId = (identityAccountId, cloudId) => ({
43
+ query: `
44
+ query RovoAgentProfileCard_AgentQueryByAccountId($identityAccountId: ID!, $cloudId: ID!) {
45
+ agentStudio_agentByIdentityAccountId(identityAccountId: $identityAccountId, cloudId: $cloudId) @optIn(to: "AgentStudio") {
46
+ __typename
47
+ ... on AgentStudioAssistant {
48
+ authoringTeam {
49
+ displayName
50
+ profileUrl
51
+ }
52
+ }
53
+ ... on QueryError {
54
+ message
55
+ }
56
+ }
57
+ }
58
+ `,
59
+ variables: {
60
+ identityAccountId,
61
+ cloudId
62
+ }
63
+ });
6
64
  const createHeaders = (product, cloudId, isBodyJson) => {
7
65
  const headers = new Headers({
8
66
  'X-Product': product,
@@ -22,24 +80,92 @@ export default class RovoAgentCardClient extends CachingClient {
22
80
  basePath() {
23
81
  return fg('pt-deprecate-assistance-service') ? '/gateway/api/assist/rovo/v1/agents' : '/gateway/api/assist/agents/v1';
24
82
  }
25
- makeRequest(id, cloudId) {
83
+ async getActivationId(cloudId, product) {
84
+ var _response$tenantConte, _response$tenantConte2, _response$tenantConte3, _response$tenantConte4;
85
+ const response = await AGGQuery('/gateway/api/graphql', buildActivationIdQuery(cloudId, product));
86
+ return (_response$tenantConte = response === null || response === void 0 ? void 0 : (_response$tenantConte2 = response.tenantContexts) === null || _response$tenantConte2 === void 0 ? void 0 : (_response$tenantConte3 = _response$tenantConte2[0]) === null || _response$tenantConte3 === void 0 ? void 0 : (_response$tenantConte4 = _response$tenantConte3.activationIdByProduct) === null || _response$tenantConte4 === void 0 ? void 0 : _response$tenantConte4.active) !== null && _response$tenantConte !== void 0 ? _response$tenantConte : null;
87
+ }
88
+ async getAgentByARIAgg(agentAri) {
89
+ var _response$agentStudio;
90
+ const response = await AGGQuery('/gateway/api/graphql', buildRovoAgentQueryByAri(agentAri));
91
+ if (((_response$agentStudio = response.agentStudio_agentById) === null || _response$agentStudio === void 0 ? void 0 : _response$agentStudio.__typename) === 'QueryError') {
92
+ throw new Error(`ProfileCard agentStudio_agentById returning QueryError: ${response.agentStudio_agentById.message}`);
93
+ }
94
+ return response === null || response === void 0 ? void 0 : response.agentStudio_agentById;
95
+ }
96
+ async getAgentByAccountIdAgg(identityAccountId, cloudId) {
97
+ var _response$agentStudio2;
98
+ const response = await AGGQuery('/gateway/api/graphql', buildRovoAgentQueryByAccountId(identityAccountId, cloudId));
99
+ if (((_response$agentStudio2 = response.agentStudio_agentByIdentityAccountId) === null || _response$agentStudio2 === void 0 ? void 0 : _response$agentStudio2.__typename) === 'QueryError') {
100
+ throw new Error(`ProfileCard agentStudio_agentByIdentityAccountId returning QueryError: ${response.agentStudio_agentByIdentityAccountId.message}`);
101
+ }
102
+ return response === null || response === void 0 ? void 0 : response.agentStudio_agentByIdentityAccountId;
103
+ }
104
+ makeRequest(id, analyticsNext) {
26
105
  const product = this.options.productIdentifier || 'rovo';
27
106
  const headers = createHeaders(product, this.options.cloudId);
107
+ let restPromise;
28
108
  if (id.type === 'identity') {
29
- return fetch(new Request(`${this.basePath()}/accountid/${id.value}`, {
109
+ restPromise = fetch(new Request(`${this.basePath()}/accountid/${id.value}`, {
110
+ method: 'GET',
111
+ credentials: 'include',
112
+ mode: 'cors',
113
+ headers
114
+ })).then(response => response.json());
115
+ } else {
116
+ restPromise = fetch(new Request(`${this.basePath()}/${id.value}`, {
30
117
  method: 'GET',
31
118
  credentials: 'include',
32
119
  mode: 'cors',
33
120
  headers
34
121
  })).then(response => response.json());
35
122
  }
36
- return fetch(new Request(`${this.basePath()}/${id.value}`, {
37
- method: 'GET',
38
- credentials: 'include',
39
- mode: 'cors',
40
- headers
41
- })).then(response => response.json());
123
+ if (!fg('agent_studio_permissions_settings_m3_profiles')) {
124
+ return restPromise.then(restData => ({
125
+ restData,
126
+ aggData: null
127
+ }));
128
+ }
129
+ const aggStartTime = getPageTime();
130
+ const aggPromise = this.getActivationId(this.options.cloudId || '', this.options.productIdentifier || 'rovo').then(activationId => {
131
+ if (!activationId) {
132
+ throw new Error('ProfileCard Activation ID not found');
133
+ }
134
+ if (id.type === 'identity') {
135
+ return this.getAgentByAccountIdAgg(id.value, this.options.cloudId || '');
136
+ } else {
137
+ const agentAri = `ari:cloud:rovo::agent/activation/${activationId}/${id.value}`;
138
+ return this.getAgentByARIAgg(agentAri);
139
+ }
140
+ })
141
+ // We are not going to break the flow if the AGG endpoint fails for now
142
+ // @TODO once all the data moved to AGG, we can remove this catch
143
+ .catch(error => {
144
+ if (analyticsNext) {
145
+ analyticsNext('operational.rovoAgentProfilecard.failed.request', {
146
+ ...getErrorAttributes(error),
147
+ errorType: 'RovoAgentProfileCardAggError',
148
+ duration: getPageTime() - aggStartTime,
149
+ gateway: true,
150
+ firedAt: Math.round(getPageTime()),
151
+ ...PACKAGE_META_DATA
152
+ });
153
+ }
154
+ return Promise.resolve(null);
155
+ });
156
+ return Promise.all([restPromise, aggPromise]).then(([restData, aggData]) => ({
157
+ restData,
158
+ aggData
159
+ }));
42
160
  }
161
+
162
+ /**
163
+ * This function will call both REST and AGG endpoints to get the agent profile
164
+ * There are some data that is only available in the AGG endpoint, so we need to call both
165
+ * For any new fields, please only add them to the AGG endpoint
166
+ *
167
+ * @TODO migrate everything to AGG endpoint
168
+ */
43
169
  getProfile(id, analytics, analyticsNext) {
44
170
  if (!id.value) {
45
171
  return Promise.reject(new Error('Id is missing'));
@@ -65,7 +191,7 @@ export default class RovoAgentCardClient extends CachingClient {
65
191
  analytics(agentRequestAnalytics('triggered'));
66
192
  }
67
193
  }
68
- this.makeRequest(id, this.options.cloudId || '').then(data => {
194
+ this.makeRequest(id, analyticsNext).then(data => {
69
195
  if (this.cache) {
70
196
  this.setCachedProfile(id.value, data);
71
197
  }
@@ -6,7 +6,7 @@ const ORG_ID_FROM_CLOUD_ID_QUERY = `query OrgIdFromCloudId($cloudId: ID!) {
6
6
  }`;
7
7
  const addHeaders = headers => {
8
8
  headers.append('atl-client-name', "@atlaskit/profilecard");
9
- headers.append('atl-client-version', "24.18.1");
9
+ headers.append('atl-client-version', "24.20.0");
10
10
  return headers;
11
11
  };
12
12
  export async function getOrgIdForCloudIdFromAGG(url, cloudId) {
@@ -77,7 +77,7 @@ export const addHeaders = headers => {
77
77
  headers.append('X-ExperimentalApi', 'teams-beta');
78
78
  headers.append('X-ExperimentalApi', 'team-members-beta');
79
79
  headers.append('atl-client-name', "@atlaskit/profilecard");
80
- headers.append('atl-client-version', "24.18.1");
80
+ headers.append('atl-client-version', "24.20.0");
81
81
  return headers;
82
82
  };
83
83
  export async function getTeamFromAGG(url, teamId, siteId) {
@@ -33,7 +33,16 @@ export const AgentProfileCardResourced = props => {
33
33
  },
34
34
  cloudId: props.cloudId
35
35
  });
36
- const getCreator = useCallback(async (creator_type, creator) => {
36
+
37
+ /**
38
+ * @TODO replace with `getAgentCreator` from `@atlassian/rovo-agent-components`
39
+ * @deprecated use `getAgentCreator` from `@atlassian/rovo-agent-components`
40
+ */
41
+ const getCreator = useCallback(async ({
42
+ creator_type,
43
+ creator,
44
+ authoringTeam
45
+ }) => {
37
46
  if (!creator) {
38
47
  return undefined;
39
48
  }
@@ -52,6 +61,14 @@ export const AgentProfileCardResourced = props => {
52
61
  if (!creatorUserId || !props.cloudId) {
53
62
  return undefined;
54
63
  }
64
+ if (authoringTeam && fg('agent_studio_permissions_settings_m3_profiles')) {
65
+ var _authoringTeam$displa, _authoringTeam$profil;
66
+ return {
67
+ type: 'CUSTOMER',
68
+ name: (_authoringTeam$displa = authoringTeam.displayName) !== null && _authoringTeam$displa !== void 0 ? _authoringTeam$displa : '',
69
+ profileLink: (_authoringTeam$profil = authoringTeam.profileUrl) !== null && _authoringTeam$profil !== void 0 ? _authoringTeam$profil : ''
70
+ };
71
+ }
55
72
  const creatorInfo = await props.resourceClient.getProfile(creatorUserId, props.cloudId, fireAnalytics, fireEventNext);
56
73
  return {
57
74
  type: 'CUSTOMER',
@@ -69,11 +86,17 @@ export const AgentProfileCardResourced = props => {
69
86
  const fetchData = useCallback(async () => {
70
87
  setIsLoading(true);
71
88
  try {
72
- const profileData = await props.resourceClient.getRovoAgentProfile({
89
+ var _profileResult$aggDat, _profileResult$aggDat2;
90
+ const profileResult = await props.resourceClient.getRovoAgentProfile({
73
91
  type: 'identity',
74
92
  value: props.accountId
75
93
  }, fireAnalytics, fireEventNext);
76
- const agentCreatorInfo = await getCreator(profileData === null || profileData === void 0 ? void 0 : profileData.creator_type, (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined);
94
+ const profileData = profileResult.restData;
95
+ const agentCreatorInfo = await getCreator({
96
+ creator_type: profileData === null || profileData === void 0 ? void 0 : profileData.creator_type,
97
+ creator: (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined,
98
+ authoringTeam: (_profileResult$aggDat = (_profileResult$aggDat2 = profileResult.aggData) === null || _profileResult$aggDat2 === void 0 ? void 0 : _profileResult$aggDat2.authoringTeam) !== null && _profileResult$aggDat !== void 0 ? _profileResult$aggDat : undefined
99
+ });
77
100
  setAgentData({
78
101
  ...profileData,
79
102
  creatorInfo: agentCreatorInfo