@atlaskit/profilecard 24.19.0 → 24.20.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 +12 -0
- package/dist/cjs/client/RovoAgentCardClient.js +201 -33
- package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/AgentProfileCardResourced.js +50 -34
- package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +50 -33
- package/dist/cjs/mocks/agent-data.js +7 -1
- package/dist/cjs/mocks/simple-mock-clients.js +8 -3
- package/dist/cjs/util/analytics.js +2 -2
- package/dist/es2019/client/RovoAgentCardClient.js +135 -9
- package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/AgentProfileCardResourced.js +21 -3
- package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +21 -3
- package/dist/es2019/mocks/agent-data.js +6 -0
- package/dist/es2019/mocks/simple-mock-clients.js +6 -3
- package/dist/es2019/util/analytics.js +2 -2
- package/dist/esm/client/RovoAgentCardClient.js +202 -34
- package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/AgentProfileCardResourced.js +50 -34
- package/dist/esm/components/Agent/AgentProfileCardTrigger.js +50 -33
- package/dist/esm/mocks/agent-data.js +6 -0
- package/dist/esm/mocks/simple-mock-clients.js +6 -3
- package/dist/esm/util/analytics.js +2 -2
- package/dist/types/client/ProfileCardClient.d.ts +1 -1
- package/dist/types/client/RovoAgentCardClient.d.ts +14 -4
- package/dist/types/mocks/agent-data.d.ts +2 -1
- package/dist/types/mocks/simple-mock-clients.d.ts +2 -2
- package/dist/types/types.d.ts +11 -1
- package/dist/types-ts4.5/client/ProfileCardClient.d.ts +1 -1
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +14 -4
- package/dist/types-ts4.5/mocks/agent-data.d.ts +2 -1
- package/dist/types-ts4.5/mocks/simple-mock-clients.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +11 -1
- package/package.json +8 -5
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
8
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
9
|
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; }
|
|
10
10
|
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; }
|
|
11
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
12
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -15,6 +16,33 @@ import { agentRequestAnalytics, PACKAGE_META_DATA } from '../util/analytics';
|
|
|
15
16
|
import { getPageTime } from '../util/performance';
|
|
16
17
|
import CachingClient from './CachingClient';
|
|
17
18
|
import { DEPRECATED_getErrorAttributes, getErrorAttributes } from './errorUtils';
|
|
19
|
+
import { AGGQuery } from './graphqlUtils';
|
|
20
|
+
var buildActivationIdQuery = function buildActivationIdQuery(cloudId, product) {
|
|
21
|
+
return {
|
|
22
|
+
query: "\n\t\tquery RovoAgentProfileCard_ActivationQuery($cloudId: ID!, $product: String!) {\n\t\t\ttenantContexts(cloudIds: [$cloudId]) {\n\t\t\t\tactivationIdByProduct(product: $product) {\n\t\t\t\t\tactive\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t",
|
|
23
|
+
variables: {
|
|
24
|
+
cloudId: cloudId,
|
|
25
|
+
product: product
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var buildRovoAgentQueryByAri = function buildRovoAgentQueryByAri(agentAri) {
|
|
30
|
+
return {
|
|
31
|
+
query: "\n\t query RovoAgentProfileCard_AgentQueryByAri($agentAri: ID!) {\n\t\t\tagentStudio_agentById(id: $agentAri) @optIn(to: \"AgentStudio\") {\n\t\t\t __typename\n\t\t\t\t... on AgentStudioAssistant {\n\t\t\t\t\tauthoringTeam {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t... on QueryError {\n\t\t\t\t\tmessage\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t",
|
|
32
|
+
variables: {
|
|
33
|
+
agentAri: agentAri
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var buildRovoAgentQueryByAccountId = function buildRovoAgentQueryByAccountId(identityAccountId, cloudId) {
|
|
38
|
+
return {
|
|
39
|
+
query: "\n\t\tquery RovoAgentProfileCard_AgentQueryByAccountId($identityAccountId: ID!, $cloudId: ID!) {\n\t\t\tagentStudio_agentByIdentityAccountId(identityAccountId: $identityAccountId, cloudId: $cloudId) @optIn(to: \"AgentStudio\") {\n\t\t\t __typename\n\t\t\t\t... on AgentStudioAssistant {\n\t\t\t\t\tauthoringTeam {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t\tprofileUrl\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t... on QueryError {\n\t\t\t\t\tmessage\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t",
|
|
40
|
+
variables: {
|
|
41
|
+
identityAccountId: identityAccountId,
|
|
42
|
+
cloudId: cloudId
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
18
46
|
var createHeaders = function createHeaders(product, cloudId, isBodyJson) {
|
|
19
47
|
var headers = new Headers({
|
|
20
48
|
'X-Product': product,
|
|
@@ -40,13 +68,111 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
40
68
|
value: function basePath() {
|
|
41
69
|
return fg('pt-deprecate-assistance-service') ? '/gateway/api/assist/rovo/v1/agents' : '/gateway/api/assist/agents/v1';
|
|
42
70
|
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "getActivationId",
|
|
73
|
+
value: function () {
|
|
74
|
+
var _getActivationId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(cloudId, product) {
|
|
75
|
+
var _response$tenantConte, _response$tenantConte2;
|
|
76
|
+
var response;
|
|
77
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
78
|
+
while (1) switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context.next = 2;
|
|
81
|
+
return AGGQuery('/gateway/api/graphql', buildActivationIdQuery(cloudId, product));
|
|
82
|
+
case 2:
|
|
83
|
+
response = _context.sent;
|
|
84
|
+
return _context.abrupt("return", (_response$tenantConte = response === null || response === void 0 || (_response$tenantConte2 = response.tenantContexts) === null || _response$tenantConte2 === void 0 || (_response$tenantConte2 = _response$tenantConte2[0]) === null || _response$tenantConte2 === void 0 || (_response$tenantConte2 = _response$tenantConte2.activationIdByProduct) === null || _response$tenantConte2 === void 0 ? void 0 : _response$tenantConte2.active) !== null && _response$tenantConte !== void 0 ? _response$tenantConte : null);
|
|
85
|
+
case 4:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee);
|
|
90
|
+
}));
|
|
91
|
+
function getActivationId(_x, _x2) {
|
|
92
|
+
return _getActivationId.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
return getActivationId;
|
|
95
|
+
}()
|
|
96
|
+
}, {
|
|
97
|
+
key: "getAgentByARIAgg",
|
|
98
|
+
value: function () {
|
|
99
|
+
var _getAgentByARIAgg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(agentAri) {
|
|
100
|
+
var _response$agentStudio;
|
|
101
|
+
var response;
|
|
102
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
_context2.next = 2;
|
|
106
|
+
return AGGQuery('/gateway/api/graphql', buildRovoAgentQueryByAri(agentAri));
|
|
107
|
+
case 2:
|
|
108
|
+
response = _context2.sent;
|
|
109
|
+
if (!(((_response$agentStudio = response.agentStudio_agentById) === null || _response$agentStudio === void 0 ? void 0 : _response$agentStudio.__typename) === 'QueryError')) {
|
|
110
|
+
_context2.next = 5;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
throw new Error("ProfileCard agentStudio_agentById returning QueryError: ".concat(response.agentStudio_agentById.message));
|
|
114
|
+
case 5:
|
|
115
|
+
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.agentStudio_agentById);
|
|
116
|
+
case 6:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context2.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee2);
|
|
121
|
+
}));
|
|
122
|
+
function getAgentByARIAgg(_x3) {
|
|
123
|
+
return _getAgentByARIAgg.apply(this, arguments);
|
|
124
|
+
}
|
|
125
|
+
return getAgentByARIAgg;
|
|
126
|
+
}()
|
|
127
|
+
}, {
|
|
128
|
+
key: "getAgentByAccountIdAgg",
|
|
129
|
+
value: function () {
|
|
130
|
+
var _getAgentByAccountIdAgg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(identityAccountId, cloudId) {
|
|
131
|
+
var _response$agentStudio2;
|
|
132
|
+
var response;
|
|
133
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
134
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
_context3.next = 2;
|
|
137
|
+
return AGGQuery('/gateway/api/graphql', buildRovoAgentQueryByAccountId(identityAccountId, cloudId));
|
|
138
|
+
case 2:
|
|
139
|
+
response = _context3.sent;
|
|
140
|
+
if (!(((_response$agentStudio2 = response.agentStudio_agentByIdentityAccountId) === null || _response$agentStudio2 === void 0 ? void 0 : _response$agentStudio2.__typename) === 'QueryError')) {
|
|
141
|
+
_context3.next = 5;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
throw new Error("ProfileCard agentStudio_agentByIdentityAccountId returning QueryError: ".concat(response.agentStudio_agentByIdentityAccountId.message));
|
|
145
|
+
case 5:
|
|
146
|
+
return _context3.abrupt("return", response === null || response === void 0 ? void 0 : response.agentStudio_agentByIdentityAccountId);
|
|
147
|
+
case 6:
|
|
148
|
+
case "end":
|
|
149
|
+
return _context3.stop();
|
|
150
|
+
}
|
|
151
|
+
}, _callee3);
|
|
152
|
+
}));
|
|
153
|
+
function getAgentByAccountIdAgg(_x4, _x5) {
|
|
154
|
+
return _getAgentByAccountIdAgg.apply(this, arguments);
|
|
155
|
+
}
|
|
156
|
+
return getAgentByAccountIdAgg;
|
|
157
|
+
}()
|
|
43
158
|
}, {
|
|
44
159
|
key: "makeRequest",
|
|
45
|
-
value: function makeRequest(id,
|
|
160
|
+
value: function makeRequest(id, analyticsNext) {
|
|
161
|
+
var _this2 = this;
|
|
46
162
|
var product = this.options.productIdentifier || 'rovo';
|
|
47
163
|
var headers = createHeaders(product, this.options.cloudId);
|
|
164
|
+
var restPromise;
|
|
48
165
|
if (id.type === 'identity') {
|
|
49
|
-
|
|
166
|
+
restPromise = fetch(new Request("".concat(this.basePath(), "/accountid/").concat(id.value), {
|
|
167
|
+
method: 'GET',
|
|
168
|
+
credentials: 'include',
|
|
169
|
+
mode: 'cors',
|
|
170
|
+
headers: headers
|
|
171
|
+
})).then(function (response) {
|
|
172
|
+
return response.json();
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
restPromise = fetch(new Request("".concat(this.basePath(), "/").concat(id.value), {
|
|
50
176
|
method: 'GET',
|
|
51
177
|
credentials: 'include',
|
|
52
178
|
mode: 'cors',
|
|
@@ -55,19 +181,61 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
55
181
|
return response.json();
|
|
56
182
|
});
|
|
57
183
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
184
|
+
if (!fg('agent_studio_permissions_settings_m3_profiles')) {
|
|
185
|
+
return restPromise.then(function (restData) {
|
|
186
|
+
return {
|
|
187
|
+
restData: restData,
|
|
188
|
+
aggData: null
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
var aggStartTime = getPageTime();
|
|
193
|
+
var aggPromise = this.getActivationId(this.options.cloudId || '', this.options.productIdentifier || 'rovo').then(function (activationId) {
|
|
194
|
+
if (!activationId) {
|
|
195
|
+
throw new Error('ProfileCard Activation ID not found');
|
|
196
|
+
}
|
|
197
|
+
if (id.type === 'identity') {
|
|
198
|
+
return _this2.getAgentByAccountIdAgg(id.value, _this2.options.cloudId || '');
|
|
199
|
+
} else {
|
|
200
|
+
var agentAri = "ari:cloud:rovo::agent/activation/".concat(activationId, "/").concat(id.value);
|
|
201
|
+
return _this2.getAgentByARIAgg(agentAri);
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
// We are not going to break the flow if the AGG endpoint fails for now
|
|
205
|
+
// @TODO once all the data moved to AGG, we can remove this catch
|
|
206
|
+
.catch(function (error) {
|
|
207
|
+
if (analyticsNext) {
|
|
208
|
+
analyticsNext('operational.rovoAgentProfilecard.failed.request', _objectSpread(_objectSpread({}, getErrorAttributes(error)), {}, {
|
|
209
|
+
errorType: 'RovoAgentProfileCardAggError',
|
|
210
|
+
duration: getPageTime() - aggStartTime,
|
|
211
|
+
gateway: true,
|
|
212
|
+
firedAt: Math.round(getPageTime())
|
|
213
|
+
}, PACKAGE_META_DATA));
|
|
214
|
+
}
|
|
215
|
+
return Promise.resolve(null);
|
|
216
|
+
});
|
|
217
|
+
return Promise.all([restPromise, aggPromise]).then(function (_ref) {
|
|
218
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
219
|
+
restData = _ref2[0],
|
|
220
|
+
aggData = _ref2[1];
|
|
221
|
+
return {
|
|
222
|
+
restData: restData,
|
|
223
|
+
aggData: aggData
|
|
224
|
+
};
|
|
65
225
|
});
|
|
66
226
|
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* This function will call both REST and AGG endpoints to get the agent profile
|
|
230
|
+
* There are some data that is only available in the AGG endpoint, so we need to call both
|
|
231
|
+
* For any new fields, please only add them to the AGG endpoint
|
|
232
|
+
*
|
|
233
|
+
* @TODO migrate everything to AGG endpoint
|
|
234
|
+
*/
|
|
67
235
|
}, {
|
|
68
236
|
key: "getProfile",
|
|
69
237
|
value: function getProfile(id, analytics, analyticsNext) {
|
|
70
|
-
var
|
|
238
|
+
var _this3 = this;
|
|
71
239
|
if (!id.value) {
|
|
72
240
|
return Promise.reject(new Error('Id is missing'));
|
|
73
241
|
}
|
|
@@ -91,9 +259,9 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
91
259
|
analytics(agentRequestAnalytics('triggered'));
|
|
92
260
|
}
|
|
93
261
|
}
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
262
|
+
_this3.makeRequest(id, analyticsNext).then(function (data) {
|
|
263
|
+
if (_this3.cache) {
|
|
264
|
+
_this3.setCachedProfile(id.value, data);
|
|
97
265
|
}
|
|
98
266
|
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
99
267
|
if (analyticsNext) {
|
|
@@ -138,13 +306,13 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
138
306
|
}, {
|
|
139
307
|
key: "deleteAgent",
|
|
140
308
|
value: function deleteAgent(agentId, analytics, analyticsNext) {
|
|
141
|
-
var
|
|
309
|
+
var _this4 = this;
|
|
142
310
|
if (!this.options.cloudId) {
|
|
143
311
|
return Promise.reject(new Error('cloudId is missing'));
|
|
144
312
|
}
|
|
145
313
|
return new Promise(function (resolve, reject) {
|
|
146
314
|
var startTime = getPageTime();
|
|
147
|
-
var product =
|
|
315
|
+
var product = _this4.options.productIdentifier || 'rovo';
|
|
148
316
|
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
149
317
|
if (analyticsNext) {
|
|
150
318
|
analyticsNext('operational.rovoAgentProfilecard.triggered.request', _objectSpread({
|
|
@@ -156,8 +324,8 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
156
324
|
analytics(agentRequestAnalytics('triggered'));
|
|
157
325
|
}
|
|
158
326
|
}
|
|
159
|
-
var headers = createHeaders(product,
|
|
160
|
-
fetch(new Request("".concat(
|
|
327
|
+
var headers = createHeaders(product, _this4.options.cloudId);
|
|
328
|
+
fetch(new Request("".concat(_this4.basePath(), "/").concat(agentId), {
|
|
161
329
|
method: 'DELETE',
|
|
162
330
|
credentials: 'include',
|
|
163
331
|
mode: 'cors',
|
|
@@ -206,18 +374,18 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
206
374
|
}, {
|
|
207
375
|
key: "setFavouriteAgent",
|
|
208
376
|
value: function setFavouriteAgent(agentId, isFavourite, analytics, analyticsNext) {
|
|
209
|
-
var
|
|
377
|
+
var _this5 = this;
|
|
210
378
|
if (!this.options.cloudId) {
|
|
211
379
|
return Promise.reject(new Error('cloudId is missing'));
|
|
212
380
|
}
|
|
213
381
|
return new Promise( /*#__PURE__*/function () {
|
|
214
|
-
var
|
|
382
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resolve, reject) {
|
|
215
383
|
var startTime, product, actionSubjectId, requestMethod, headers;
|
|
216
|
-
return _regeneratorRuntime.wrap(function
|
|
217
|
-
while (1) switch (
|
|
384
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
385
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
218
386
|
case 0:
|
|
219
387
|
startTime = getPageTime();
|
|
220
|
-
product =
|
|
388
|
+
product = _this5.options.productIdentifier || 'rovo';
|
|
221
389
|
actionSubjectId = isFavourite ? 'favourite' : 'unfavourite';
|
|
222
390
|
requestMethod = isFavourite ? 'POST' : 'DELETE';
|
|
223
391
|
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
@@ -231,9 +399,9 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
231
399
|
analytics(agentRequestAnalytics('triggered', 'actionSubjectId'));
|
|
232
400
|
}
|
|
233
401
|
}
|
|
234
|
-
headers = createHeaders(product,
|
|
235
|
-
|
|
236
|
-
return fetch(new Request("".concat(
|
|
402
|
+
headers = createHeaders(product, _this5.options.cloudId);
|
|
403
|
+
_context4.next = 8;
|
|
404
|
+
return fetch(new Request("".concat(_this5.basePath(), "/").concat(agentId, "/favourite"), {
|
|
237
405
|
method: requestMethod,
|
|
238
406
|
credentials: 'include',
|
|
239
407
|
mode: 'cors',
|
|
@@ -279,25 +447,25 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
279
447
|
});
|
|
280
448
|
case 8:
|
|
281
449
|
case "end":
|
|
282
|
-
return
|
|
450
|
+
return _context4.stop();
|
|
283
451
|
}
|
|
284
|
-
},
|
|
452
|
+
}, _callee4);
|
|
285
453
|
}));
|
|
286
|
-
return function (
|
|
287
|
-
return
|
|
454
|
+
return function (_x6, _x7) {
|
|
455
|
+
return _ref3.apply(this, arguments);
|
|
288
456
|
};
|
|
289
457
|
}());
|
|
290
458
|
}
|
|
291
459
|
}, {
|
|
292
460
|
key: "getPermissions",
|
|
293
461
|
value: function getPermissions(id, fireAnalytics, fireAnalyticsNext) {
|
|
294
|
-
var
|
|
462
|
+
var _this6 = this;
|
|
295
463
|
if (!this.options.cloudId) {
|
|
296
464
|
return Promise.reject(new Error('cloudId is missing'));
|
|
297
465
|
}
|
|
298
466
|
return new Promise(function (resolve, reject) {
|
|
299
467
|
var startTime = getPageTime();
|
|
300
|
-
var product =
|
|
468
|
+
var product = _this6.options.productIdentifier || 'rovo';
|
|
301
469
|
if (fg('ptc-enable-profile-card-analytics-refactor')) {
|
|
302
470
|
if (fireAnalyticsNext) {
|
|
303
471
|
fireAnalyticsNext('operational.rovoAgentProfilecard.triggered.request', _objectSpread({
|
|
@@ -309,7 +477,7 @@ var RovoAgentCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
309
477
|
fireAnalytics(agentRequestAnalytics('triggered'));
|
|
310
478
|
}
|
|
311
479
|
}
|
|
312
|
-
var headers = createHeaders(product,
|
|
480
|
+
var headers = createHeaders(product, _this6.options.cloudId, true);
|
|
313
481
|
fetch(new Request("/gateway/api/assist/api/rovo/v2/permissions/agents/".concat(id), {
|
|
314
482
|
method: 'POST',
|
|
315
483
|
credentials: 'include',
|
|
@@ -4,7 +4,7 @@ import { AGGQuery } from './graphqlUtils';
|
|
|
4
4
|
var ORG_ID_FROM_CLOUD_ID_QUERY = "query OrgIdFromCloudId($cloudId: ID!) {\n\ttenantContexts(cloudIds: [$cloudId]) {\n\t\torgId\n\t}\n}";
|
|
5
5
|
var addHeaders = function addHeaders(headers) {
|
|
6
6
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
7
|
-
headers.append('atl-client-version', "24.
|
|
7
|
+
headers.append('atl-client-version', "24.19.0");
|
|
8
8
|
return headers;
|
|
9
9
|
};
|
|
10
10
|
export function getOrgIdForCloudIdFromAGG(_x, _x2) {
|
|
@@ -59,7 +59,7 @@ export var addHeaders = function addHeaders(headers) {
|
|
|
59
59
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
60
60
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
61
61
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
62
|
-
headers.append('atl-client-version', "24.
|
|
62
|
+
headers.append('atl-client-version', "24.19.0");
|
|
63
63
|
return headers;
|
|
64
64
|
};
|
|
65
65
|
export function getTeamFromAGG(_x, _x2, _x3) {
|
|
@@ -48,40 +48,51 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
|
|
|
48
48
|
}),
|
|
49
49
|
profileHref = _navigateToTeamsApp.href;
|
|
50
50
|
var getCreator = useCallback( /*#__PURE__*/function () {
|
|
51
|
-
var
|
|
52
|
-
var creatorInfo;
|
|
51
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
52
|
+
var creator_type, creator, authoringTeam, _authoringTeam$displa, _authoringTeam$profil, creatorInfo;
|
|
53
53
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
54
54
|
while (1) switch (_context.prev = _context.next) {
|
|
55
55
|
case 0:
|
|
56
|
+
creator_type = _ref.creator_type, creator = _ref.creator, authoringTeam = _ref.authoringTeam;
|
|
56
57
|
if (creator) {
|
|
57
|
-
_context.next =
|
|
58
|
+
_context.next = 3;
|
|
58
59
|
break;
|
|
59
60
|
}
|
|
60
61
|
return _context.abrupt("return", undefined);
|
|
61
|
-
case
|
|
62
|
+
case 3:
|
|
62
63
|
_context.t0 = creator_type;
|
|
63
|
-
_context.next = _context.t0 === 'SYSTEM' ?
|
|
64
|
+
_context.next = _context.t0 === 'SYSTEM' ? 6 : _context.t0 === 'THIRD_PARTY' ? 7 : _context.t0 === 'CUSTOMER' ? 8 : 22;
|
|
64
65
|
break;
|
|
65
|
-
case
|
|
66
|
+
case 6:
|
|
66
67
|
return _context.abrupt("return", {
|
|
67
68
|
type: 'SYSTEM'
|
|
68
69
|
});
|
|
69
|
-
case
|
|
70
|
+
case 7:
|
|
70
71
|
return _context.abrupt("return", {
|
|
71
72
|
type: 'THIRD_PARTY',
|
|
72
73
|
name: creator !== null && creator !== void 0 ? creator : ''
|
|
73
74
|
});
|
|
74
|
-
case
|
|
75
|
-
_context.prev =
|
|
75
|
+
case 8:
|
|
76
|
+
_context.prev = 8;
|
|
76
77
|
if (!(!creatorUserId || !props.cloudId)) {
|
|
77
|
-
_context.next =
|
|
78
|
+
_context.next = 11;
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
81
|
return _context.abrupt("return", undefined);
|
|
81
|
-
case
|
|
82
|
-
|
|
82
|
+
case 11:
|
|
83
|
+
if (!(authoringTeam && fg('agent_studio_permissions_settings_m3_profiles'))) {
|
|
84
|
+
_context.next = 13;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
return _context.abrupt("return", {
|
|
88
|
+
type: 'CUSTOMER',
|
|
89
|
+
name: (_authoringTeam$displa = authoringTeam.displayName) !== null && _authoringTeam$displa !== void 0 ? _authoringTeam$displa : '',
|
|
90
|
+
profileLink: (_authoringTeam$profil = authoringTeam.profileUrl) !== null && _authoringTeam$profil !== void 0 ? _authoringTeam$profil : ''
|
|
91
|
+
});
|
|
92
|
+
case 13:
|
|
93
|
+
_context.next = 15;
|
|
83
94
|
return props.resourceClient.getProfile(creatorUserId, props.cloudId, fireAnalytics, fireEventNext);
|
|
84
|
-
case
|
|
95
|
+
case 15:
|
|
85
96
|
creatorInfo = _context.sent;
|
|
86
97
|
return _context.abrupt("return", {
|
|
87
98
|
type: 'CUSTOMER',
|
|
@@ -89,24 +100,24 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
|
|
|
89
100
|
profileLink: fg('platform-adopt-teams-nav-config') ? profileHref : "/people/".concat(creatorUserId),
|
|
90
101
|
id: creatorUserId
|
|
91
102
|
});
|
|
92
|
-
case 16:
|
|
93
|
-
_context.prev = 16;
|
|
94
|
-
_context.t1 = _context["catch"](7);
|
|
95
|
-
return _context.abrupt("return", undefined);
|
|
96
103
|
case 19:
|
|
104
|
+
_context.prev = 19;
|
|
105
|
+
_context.t1 = _context["catch"](8);
|
|
106
|
+
return _context.abrupt("return", undefined);
|
|
107
|
+
case 22:
|
|
97
108
|
return _context.abrupt("return", undefined);
|
|
98
|
-
case
|
|
109
|
+
case 23:
|
|
99
110
|
case "end":
|
|
100
111
|
return _context.stop();
|
|
101
112
|
}
|
|
102
|
-
}, _callee, null, [[
|
|
113
|
+
}, _callee, null, [[8, 19]]);
|
|
103
114
|
}));
|
|
104
|
-
return function (_x
|
|
105
|
-
return
|
|
115
|
+
return function (_x) {
|
|
116
|
+
return _ref2.apply(this, arguments);
|
|
106
117
|
};
|
|
107
118
|
}(), [creatorUserId, fireAnalytics, fireEventNext, props.cloudId, props.resourceClient, profileHref]);
|
|
108
119
|
var fetchData = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
109
|
-
var profileData, agentCreatorInfo;
|
|
120
|
+
var _profileResult$aggDat, _profileResult$aggDat2, profileResult, profileData, agentCreatorInfo;
|
|
110
121
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
111
122
|
while (1) switch (_context2.prev = _context2.next) {
|
|
112
123
|
case 0:
|
|
@@ -118,29 +129,34 @@ export var AgentProfileCardResourced = function AgentProfileCardResourced(props)
|
|
|
118
129
|
value: props.accountId
|
|
119
130
|
}, fireAnalytics, fireEventNext);
|
|
120
131
|
case 4:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
profileResult = _context2.sent;
|
|
133
|
+
profileData = profileResult.restData;
|
|
134
|
+
_context2.next = 8;
|
|
135
|
+
return getCreator({
|
|
136
|
+
creator_type: profileData === null || profileData === void 0 ? void 0 : profileData.creator_type,
|
|
137
|
+
creator: (profileData === null || profileData === void 0 ? void 0 : profileData.creator) || undefined,
|
|
138
|
+
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
|
|
139
|
+
});
|
|
140
|
+
case 8:
|
|
125
141
|
agentCreatorInfo = _context2.sent;
|
|
126
142
|
setAgentData(_objectSpread(_objectSpread({}, profileData), {}, {
|
|
127
143
|
creatorInfo: agentCreatorInfo
|
|
128
144
|
}));
|
|
129
|
-
_context2.next =
|
|
145
|
+
_context2.next = 15;
|
|
130
146
|
break;
|
|
131
|
-
case
|
|
132
|
-
_context2.prev =
|
|
147
|
+
case 12:
|
|
148
|
+
_context2.prev = 12;
|
|
133
149
|
_context2.t0 = _context2["catch"](1);
|
|
134
150
|
setError(_context2.t0);
|
|
135
|
-
case
|
|
136
|
-
_context2.prev =
|
|
151
|
+
case 15:
|
|
152
|
+
_context2.prev = 15;
|
|
137
153
|
setIsLoading(false);
|
|
138
|
-
return _context2.finish(
|
|
139
|
-
case
|
|
154
|
+
return _context2.finish(15);
|
|
155
|
+
case 18:
|
|
140
156
|
case "end":
|
|
141
157
|
return _context2.stop();
|
|
142
158
|
}
|
|
143
|
-
}, _callee2, null, [[1,
|
|
159
|
+
}, _callee2, null, [[1, 12, 15, 18]]);
|
|
144
160
|
})), [fireAnalytics, fireEventNext, getCreator, props.accountId, props.resourceClient]);
|
|
145
161
|
useEffect(function () {
|
|
146
162
|
fetchData();
|