@atlaskit/smart-card 26.62.1 → 26.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +23 -12
  3. package/dist/cjs/state/hooks/use-ai-summary/index.js +5 -3
  4. package/dist/cjs/utils/analytics/analytics.js +1 -1
  5. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +5 -2
  6. package/dist/cjs/view/HoverCard/components/ContentContainer.js +5 -2
  7. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +5 -2
  8. package/dist/cjs/view/LinkUrl/index.js +1 -1
  9. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +17 -5
  10. package/dist/es2019/state/hooks/use-ai-summary/index.js +5 -3
  11. package/dist/es2019/utils/analytics/analytics.js +1 -1
  12. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +5 -2
  13. package/dist/es2019/view/HoverCard/components/ContentContainer.js +5 -2
  14. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +5 -2
  15. package/dist/es2019/view/LinkUrl/index.js +1 -1
  16. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +24 -13
  17. package/dist/esm/state/hooks/use-ai-summary/index.js +5 -3
  18. package/dist/esm/utils/analytics/analytics.js +1 -1
  19. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +5 -2
  20. package/dist/esm/view/HoverCard/components/ContentContainer.js +5 -2
  21. package/dist/esm/view/HoverCard/components/views/resolved/index.js +5 -2
  22. package/dist/esm/view/LinkUrl/index.js +1 -1
  23. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +1 -0
  24. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +3 -2
  25. package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +2 -2
  26. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +1 -0
  27. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +3 -2
  28. package/dist/types-ts4.5/view/HoverCard/components/views/resolved/index.d.ts +2 -2
  29. package/package.json +4 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.63.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#95197](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/95197)
8
+ [`9f465475d148`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9f465475d148) -
9
+ Adding support for the custom baseURL to the AI Summary Service
10
+
3
11
  ## 26.62.1
4
12
 
5
13
  ### Patch Changes
@@ -14,6 +14,8 @@ var _uuid = _interopRequireDefault(require("uuid"));
14
14
  var _types = require("./types");
15
15
  var _utils = require("./utils");
16
16
  var _readStream = require("./readStream");
17
+ var _linkingCommon = require("@atlaskit/linking-common");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
19
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
18
20
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
21
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -31,8 +33,16 @@ var AISummaryService = exports.AISummaryService = /*#__PURE__*/function () {
31
33
  status: 'ready'
32
34
  });
33
35
  (0, _defineProperty2.default)(this, "subscribedStateSetters", new Set());
36
+ (0, _defineProperty2.default)(this, "getRequestUrl", function (envKey, baseUrlOverride) {
37
+ var path = 'assist/chat/v1/invoke_agent/stream';
38
+ if (baseUrlOverride || envKey) {
39
+ var baseUrl = baseUrlOverride || (0, _linkingCommon.getBaseUrl)(envKey);
40
+ return (0, _utils.addPath)(baseUrl, path);
41
+ }
42
+ return (0, _utils.addPath)('/gateway/api/', path);
43
+ });
34
44
  (0, _defineProperty2.default)(this, "fetchStream", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
35
- var payload, options, path, requestUrl, response;
45
+ var payload, options, requestURL, response;
36
46
  return _regenerator.default.wrap(function _callee$(_context) {
37
47
  while (1) switch (_context.prev = _context.next) {
38
48
  case 0:
@@ -45,32 +55,33 @@ var AISummaryService = exports.AISummaryService = /*#__PURE__*/function () {
45
55
  summary_output_mimetype: 'text/markdown'
46
56
  }
47
57
  };
48
- options = {
58
+ options = _objectSpread({
49
59
  method: 'POST',
50
60
  headers: _this.config.headers,
51
61
  body: JSON.stringify(payload)
52
- };
53
- path = 'chat/v1/invoke_agent/stream';
54
- requestUrl = (0, _utils.addPath)(_this.config.baseUrl, path);
55
- _context.next = 6;
56
- return fetch(requestUrl, options);
57
- case 6:
62
+ }, (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.ai-summary-service-base-url') && {
63
+ credentials: 'include'
64
+ });
65
+ requestURL = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.ai-summary-service-base-url') ? _this.config.requestUrl : '/gateway/api/assist/chat/v1/invoke_agent/stream';
66
+ _context.next = 5;
67
+ return fetch(requestURL, options);
68
+ case 5:
58
69
  response = _context.sent;
59
70
  if (!(!response.ok || response.status >= 400)) {
60
- _context.next = 11;
71
+ _context.next = 10;
61
72
  break;
62
73
  }
63
74
  throw new Error("Status: ".concat(response.status, "\n URL: ").concat(_this.url, "\n StatusText ").concat(response.statusText));
64
- case 11:
75
+ case 10:
65
76
  return _context.abrupt("return", (0, _readStream.readStream)(response));
66
- case 12:
77
+ case 11:
67
78
  case "end":
68
79
  return _context.stop();
69
80
  }
70
81
  }, _callee);
71
82
  })));
72
83
  this.config = {
73
- baseUrl: props.baseUrl || '/gateway/api/assist',
84
+ requestUrl: this.getRequestUrl(props.envKey, props.baseUrl),
74
85
  headers: _objectSpread({
75
86
  'Content-Type': 'application/json;charset=UTF-8',
76
87
  'x-experience-id': 'smart-link',
@@ -18,7 +18,8 @@ var useAISummary = exports.useAISummary = function useAISummary(props) {
18
18
  baseUrl = props.baseUrl,
19
19
  headers = props.headers,
20
20
  product = props.product,
21
- ari = props.ari;
21
+ ari = props.ari,
22
+ envKey = props.envKey;
22
23
  var _useState = (0, _react.useState)(((_AISummariesStore$get = _store.AISummariesStore.get(url)) === null || _AISummariesStore$get === void 0 ? void 0 : _AISummariesStore$get.state) || {
23
24
  status: 'ready',
24
25
  content: ''
@@ -54,13 +55,14 @@ var useAISummary = exports.useAISummary = function useAISummary(props) {
54
55
  onError: onError,
55
56
  onStart: onStart,
56
57
  onSuccess: onSuccess,
57
- product: product
58
+ product: product,
59
+ envKey: envKey
58
60
  }));
59
61
  }
60
62
 
61
63
  //returns function that calls unsubscribe method
62
64
  return (_AISummariesStore$get2 = _store.AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.subscribe(setState);
63
- }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari]);
65
+ }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari, envKey]);
64
66
  var summariseUrl = function summariseUrl() {
65
67
  var _AISummariesStore$get3;
66
68
  return (_AISummariesStore$get3 = _store.AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.summariseUrl();
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "26.62.1"
25
+ packageVersion: "26.63.0"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -80,11 +80,14 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
80
80
  var url = (context === null || context === void 0 ? void 0 : context.url) || '';
81
81
  var ari = (context === null || context === void 0 ? void 0 : context.ari) || '';
82
82
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
83
- product = _useSmartLinkContext.product;
83
+ product = _useSmartLinkContext.product,
84
+ connections = _useSmartLinkContext.connections;
84
85
  var _useAISummary = (0, _useAiSummary.useAISummary)({
85
86
  url: url,
86
87
  ari: ari,
87
- product: product
88
+ product: product,
89
+ envKey: connections.client.envKey,
90
+ baseUrl: connections.client.baseUrlOverride
88
91
  }),
89
92
  summariseUrl = _useAISummary.summariseUrl,
90
93
  _useAISummary$state = _useAISummary.state,
@@ -37,11 +37,14 @@ var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
37
37
  var dataUrl = data ? (0, _linkExtractors.extractLink)(data) : null;
38
38
  var dataAri = data ? (0, _linkExtractors.extractAri)(data) : null;
39
39
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
40
- product = _useSmartLinkContext.product;
40
+ product = _useSmartLinkContext.product,
41
+ connections = _useSmartLinkContext.connections;
41
42
  var _useAISummary = (0, _useAiSummary.useAISummary)({
42
43
  url: dataUrl || '',
43
44
  ari: dataAri || '',
44
- product: product
45
+ product: product,
46
+ envKey: connections.client.envKey,
47
+ baseUrl: connections.client.baseUrlOverride
45
48
  }),
46
49
  status = _useAISummary.state.status;
47
50
  var _useState = (0, _react2.useState)(status === 'loading'),
@@ -68,11 +68,14 @@ var ConnectedAIBlock = function ConnectedAIBlock(_ref) {
68
68
  var dataUrl = data ? (0, _linkExtractors.extractLink)(data) : null;
69
69
  var dataAri = data ? (0, _linkExtractors.extractAri)(data) : null;
70
70
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
71
- product = _useSmartLinkContext.product;
71
+ product = _useSmartLinkContext.product,
72
+ connections = _useSmartLinkContext.connections;
72
73
  var _useAISummary = (0, _useAiSummary.useAISummary)({
73
74
  url: dataUrl || '',
74
75
  ari: dataAri || '',
75
- product: product
76
+ product: product,
77
+ envKey: connections.client.envKey,
78
+ baseUrl: connections.client.baseUrlOverride
76
79
  }),
77
80
  _useAISummary$state = _useAISummary.state,
78
81
  status = _useAISummary$state.status,
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.62.1",
20
+ packageVersion: "26.63.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -3,6 +3,8 @@ import uuid from 'uuid';
3
3
  import { errorMessages } from './types';
4
4
  import { addPath } from './utils';
5
5
  import { readStream } from './readStream';
6
+ import { getBaseUrl } from '@atlaskit/linking-common';
7
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
8
  export class AISummaryService {
7
9
  constructor(props) {
8
10
  var _props$product;
@@ -11,6 +13,14 @@ export class AISummaryService {
11
13
  status: 'ready'
12
14
  });
13
15
  _defineProperty(this, "subscribedStateSetters", new Set());
16
+ _defineProperty(this, "getRequestUrl", (envKey, baseUrlOverride) => {
17
+ const path = 'assist/chat/v1/invoke_agent/stream';
18
+ if (baseUrlOverride || envKey) {
19
+ const baseUrl = baseUrlOverride || getBaseUrl(envKey);
20
+ return addPath(baseUrl, path);
21
+ }
22
+ return addPath('/gateway/api/', path);
23
+ });
14
24
  _defineProperty(this, "fetchStream", async () => {
15
25
  const payload = {
16
26
  recipient_agent_named_id: 'summary_agent',
@@ -24,11 +34,13 @@ export class AISummaryService {
24
34
  const options = {
25
35
  method: 'POST',
26
36
  headers: this.config.headers,
27
- body: JSON.stringify(payload)
37
+ body: JSON.stringify(payload),
38
+ ...(getBooleanFF('platform.linking-platform.smart-card.ai-summary-service-base-url') && {
39
+ credentials: 'include'
40
+ })
28
41
  };
29
- const path = 'chat/v1/invoke_agent/stream';
30
- const requestUrl = addPath(this.config.baseUrl, path);
31
- const response = await fetch(requestUrl, options);
42
+ const requestURL = getBooleanFF('platform.linking-platform.smart-card.ai-summary-service-base-url') ? this.config.requestUrl : '/gateway/api/assist/chat/v1/invoke_agent/stream';
43
+ const response = await fetch(requestURL, options);
32
44
  if (!response.ok || response.status >= 400) {
33
45
  throw new Error(`Status: ${response.status}\n URL: ${this.url}\n StatusText ${response.statusText}`);
34
46
  } else {
@@ -36,7 +48,7 @@ export class AISummaryService {
36
48
  }
37
49
  });
38
50
  this.config = {
39
- baseUrl: props.baseUrl || '/gateway/api/assist',
51
+ requestUrl: this.getRequestUrl(props.envKey, props.baseUrl),
40
52
  headers: {
41
53
  'Content-Type': 'application/json;charset=UTF-8',
42
54
  'x-experience-id': 'smart-link',
@@ -11,7 +11,8 @@ export const useAISummary = props => {
11
11
  baseUrl,
12
12
  headers,
13
13
  product,
14
- ari
14
+ ari,
15
+ envKey
15
16
  } = props;
16
17
  const [state, setState] = useState(((_AISummariesStore$get = AISummariesStore.get(url)) === null || _AISummariesStore$get === void 0 ? void 0 : _AISummariesStore$get.state) || {
17
18
  status: 'ready',
@@ -46,13 +47,14 @@ export const useAISummary = props => {
46
47
  onError,
47
48
  onStart,
48
49
  onSuccess,
49
- product
50
+ product,
51
+ envKey
50
52
  }));
51
53
  }
52
54
 
53
55
  //returns function that calls unsubscribe method
54
56
  return (_AISummariesStore$get2 = AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.subscribe(setState);
55
- }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari]);
57
+ }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari, envKey]);
56
58
  const summariseUrl = () => {
57
59
  var _AISummariesStore$get3;
58
60
  return (_AISummariesStore$get3 = AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.summariseUrl();
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "26.62.1"
7
+ packageVersion: "26.63.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -69,7 +69,8 @@ const AISummaryBlockResolvedView = props => {
69
69
  const url = (context === null || context === void 0 ? void 0 : context.url) || '';
70
70
  const ari = (context === null || context === void 0 ? void 0 : context.ari) || '';
71
71
  const {
72
- product
72
+ product,
73
+ connections
73
74
  } = useSmartLinkContext();
74
75
  const {
75
76
  summariseUrl,
@@ -81,7 +82,9 @@ const AISummaryBlockResolvedView = props => {
81
82
  } = useAISummary({
82
83
  url,
83
84
  ari,
84
- product
85
+ product,
86
+ envKey: connections.client.envKey,
87
+ baseUrl: connections.client.baseUrlOverride
85
88
  });
86
89
  const showAISummary = status === 'done' ||
87
90
  // We want to display the AI Summary component only when there is content available during the loading process.
@@ -26,7 +26,8 @@ const ConnectedAIPrismContainer = ({
26
26
  const dataUrl = data ? extractLink(data) : null;
27
27
  const dataAri = data ? extractAri(data) : null;
28
28
  const {
29
- product
29
+ product,
30
+ connections
30
31
  } = useSmartLinkContext();
31
32
  const {
32
33
  state: {
@@ -35,7 +36,9 @@ const ConnectedAIPrismContainer = ({
35
36
  } = useAISummary({
36
37
  url: dataUrl || '',
37
38
  ari: dataAri || '',
38
- product: product
39
+ product: product,
40
+ envKey: connections.client.envKey,
41
+ baseUrl: connections.client.baseUrlOverride
39
42
  });
40
43
  const [showPrism, setShowPrism] = useState(status === 'loading');
41
44
  useEffect(() => {
@@ -59,7 +59,8 @@ const ConnectedAIBlock = ({
59
59
  const dataUrl = data ? extractLink(data) : null;
60
60
  const dataAri = data ? extractAri(data) : null;
61
61
  const {
62
- product
62
+ product,
63
+ connections
63
64
  } = useSmartLinkContext();
64
65
  const {
65
66
  state: {
@@ -69,7 +70,9 @@ const ConnectedAIBlock = ({
69
70
  } = useAISummary({
70
71
  url: dataUrl || '',
71
72
  ari: dataAri || '',
72
- product
73
+ product,
74
+ envKey: connections.client.envKey,
75
+ baseUrl: connections.client.baseUrlOverride
73
76
  });
74
77
  const showData = status === 'ready' || status === 'error' ||
75
78
  // Description & bottom metadata should only disappear when we start getting summary content
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.62.1",
10
+ packageVersion: "26.63.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -5,15 +5,17 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
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; }
9
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; }
10
- import _regeneratorRuntime from "@babel/runtime/regenerator";
11
11
  function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
12
12
  function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function _throw(r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
13
13
  import uuid from 'uuid';
14
14
  import { errorMessages } from './types';
15
15
  import { addPath } from './utils';
16
16
  import { readStream } from './readStream';
17
+ import { getBaseUrl } from '@atlaskit/linking-common';
18
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
17
19
  export var AISummaryService = /*#__PURE__*/function () {
18
20
  function AISummaryService(props) {
19
21
  var _this = this,
@@ -24,8 +26,16 @@ export var AISummaryService = /*#__PURE__*/function () {
24
26
  status: 'ready'
25
27
  });
26
28
  _defineProperty(this, "subscribedStateSetters", new Set());
29
+ _defineProperty(this, "getRequestUrl", function (envKey, baseUrlOverride) {
30
+ var path = 'assist/chat/v1/invoke_agent/stream';
31
+ if (baseUrlOverride || envKey) {
32
+ var baseUrl = baseUrlOverride || getBaseUrl(envKey);
33
+ return addPath(baseUrl, path);
34
+ }
35
+ return addPath('/gateway/api/', path);
36
+ });
27
37
  _defineProperty(this, "fetchStream", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
28
- var payload, options, path, requestUrl, response;
38
+ var payload, options, requestURL, response;
29
39
  return _regeneratorRuntime.wrap(function _callee$(_context) {
30
40
  while (1) switch (_context.prev = _context.next) {
31
41
  case 0:
@@ -38,32 +48,33 @@ export var AISummaryService = /*#__PURE__*/function () {
38
48
  summary_output_mimetype: 'text/markdown'
39
49
  }
40
50
  };
41
- options = {
51
+ options = _objectSpread({
42
52
  method: 'POST',
43
53
  headers: _this.config.headers,
44
54
  body: JSON.stringify(payload)
45
- };
46
- path = 'chat/v1/invoke_agent/stream';
47
- requestUrl = addPath(_this.config.baseUrl, path);
48
- _context.next = 6;
49
- return fetch(requestUrl, options);
50
- case 6:
55
+ }, getBooleanFF('platform.linking-platform.smart-card.ai-summary-service-base-url') && {
56
+ credentials: 'include'
57
+ });
58
+ requestURL = getBooleanFF('platform.linking-platform.smart-card.ai-summary-service-base-url') ? _this.config.requestUrl : '/gateway/api/assist/chat/v1/invoke_agent/stream';
59
+ _context.next = 5;
60
+ return fetch(requestURL, options);
61
+ case 5:
51
62
  response = _context.sent;
52
63
  if (!(!response.ok || response.status >= 400)) {
53
- _context.next = 11;
64
+ _context.next = 10;
54
65
  break;
55
66
  }
56
67
  throw new Error("Status: ".concat(response.status, "\n URL: ").concat(_this.url, "\n StatusText ").concat(response.statusText));
57
- case 11:
68
+ case 10:
58
69
  return _context.abrupt("return", readStream(response));
59
- case 12:
70
+ case 11:
60
71
  case "end":
61
72
  return _context.stop();
62
73
  }
63
74
  }, _callee);
64
75
  })));
65
76
  this.config = {
66
- baseUrl: props.baseUrl || '/gateway/api/assist',
77
+ requestUrl: this.getRequestUrl(props.envKey, props.baseUrl),
67
78
  headers: _objectSpread({
68
79
  'Content-Type': 'application/json;charset=UTF-8',
69
80
  'x-experience-id': 'smart-link',
@@ -11,7 +11,8 @@ export var useAISummary = function useAISummary(props) {
11
11
  baseUrl = props.baseUrl,
12
12
  headers = props.headers,
13
13
  product = props.product,
14
- ari = props.ari;
14
+ ari = props.ari,
15
+ envKey = props.envKey;
15
16
  var _useState = useState(((_AISummariesStore$get = AISummariesStore.get(url)) === null || _AISummariesStore$get === void 0 ? void 0 : _AISummariesStore$get.state) || {
16
17
  status: 'ready',
17
18
  content: ''
@@ -47,13 +48,14 @@ export var useAISummary = function useAISummary(props) {
47
48
  onError: onError,
48
49
  onStart: onStart,
49
50
  onSuccess: onSuccess,
50
- product: product
51
+ product: product,
52
+ envKey: envKey
51
53
  }));
52
54
  }
53
55
 
54
56
  //returns function that calls unsubscribe method
55
57
  return (_AISummariesStore$get2 = AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.subscribe(setState);
56
- }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari]);
58
+ }, [url, baseUrl, headers, onError, onStart, onSuccess, product, ari, envKey]);
57
59
  var summariseUrl = function summariseUrl() {
58
60
  var _AISummariesStore$get3;
59
61
  return (_AISummariesStore$get3 = AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.summariseUrl();
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.62.1"
18
+ packageVersion: "26.63.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -70,11 +70,14 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
70
70
  var url = (context === null || context === void 0 ? void 0 : context.url) || '';
71
71
  var ari = (context === null || context === void 0 ? void 0 : context.ari) || '';
72
72
  var _useSmartLinkContext = useSmartLinkContext(),
73
- product = _useSmartLinkContext.product;
73
+ product = _useSmartLinkContext.product,
74
+ connections = _useSmartLinkContext.connections;
74
75
  var _useAISummary = useAISummary({
75
76
  url: url,
76
77
  ari: ari,
77
- product: product
78
+ product: product,
79
+ envKey: connections.client.envKey,
80
+ baseUrl: connections.client.baseUrlOverride
78
81
  }),
79
82
  summariseUrl = _useAISummary.summariseUrl,
80
83
  _useAISummary$state = _useAISummary.state,
@@ -30,11 +30,14 @@ var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
30
30
  var dataUrl = data ? extractLink(data) : null;
31
31
  var dataAri = data ? extractAri(data) : null;
32
32
  var _useSmartLinkContext = useSmartLinkContext(),
33
- product = _useSmartLinkContext.product;
33
+ product = _useSmartLinkContext.product,
34
+ connections = _useSmartLinkContext.connections;
34
35
  var _useAISummary = useAISummary({
35
36
  url: dataUrl || '',
36
37
  ari: dataAri || '',
37
- product: product
38
+ product: product,
39
+ envKey: connections.client.envKey,
40
+ baseUrl: connections.client.baseUrlOverride
38
41
  }),
39
42
  status = _useAISummary.state.status;
40
43
  var _useState = useState(status === 'loading'),
@@ -59,11 +59,14 @@ var ConnectedAIBlock = function ConnectedAIBlock(_ref) {
59
59
  var dataUrl = data ? extractLink(data) : null;
60
60
  var dataAri = data ? extractAri(data) : null;
61
61
  var _useSmartLinkContext = useSmartLinkContext(),
62
- product = _useSmartLinkContext.product;
62
+ product = _useSmartLinkContext.product,
63
+ connections = _useSmartLinkContext.connections;
63
64
  var _useAISummary = useAISummary({
64
65
  url: dataUrl || '',
65
66
  ari: dataAri || '',
66
- product: product
67
+ product: product,
68
+ envKey: connections.client.envKey,
69
+ baseUrl: connections.client.baseUrlOverride
67
70
  }),
68
71
  _useAISummary$state = _useAISummary.state,
69
72
  status = _useAISummary$state.status,
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.62.1",
13
+ packageVersion: "26.63.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -9,6 +9,7 @@ export declare class AISummaryService implements AISummaryServiceInt {
9
9
  private onSuccess?;
10
10
  private onError?;
11
11
  constructor(props: AISummaryServiceProps);
12
+ private getRequestUrl;
12
13
  private fetchStream;
13
14
  summariseUrl(): Promise<AISummaryState>;
14
15
  private isExpectedError;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="filesystem" />
2
- import type { ProductType } from '@atlaskit/linking-common';
2
+ import type { ProductType, EnvironmentsKeys } from '@atlaskit/linking-common';
3
3
  export interface AISummaryServiceInt {
4
4
  summariseUrl: () => Promise<AISummaryState>;
5
5
  state: AISummaryState;
@@ -16,10 +16,11 @@ export type AISummaryServiceProps = {
16
16
  * we should always include the ARI if possible
17
17
  */
18
18
  ari?: string;
19
+ envKey?: EnvironmentsKeys;
19
20
  url: string;
20
21
  };
21
22
  export type AISummaryServiceConfig = {
22
- baseUrl: string;
23
+ requestUrl: string;
23
24
  headers: Record<string, string>;
24
25
  };
25
26
  export type AISummaryStatus = 'ready' | 'loading' | 'error' | 'done';
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { type ActionItem } from '../../../../FlexibleCard/components/blocks/types';
3
3
  import { type LinkAction } from '../../../../../state/hooks-external/useSmartLinkActions';
4
4
  import { type HoverCardResolvedProps } from './types';
5
5
  export declare const toFooterActions: (cardActions: LinkAction[], onActionClick?: ((actionId: string) => void) | undefined) => ActionItem[];
6
- declare const HoverCardResolvedView: React.FC<HoverCardResolvedProps>;
6
+ declare const HoverCardResolvedView: ({ flexibleCardProps, titleBlockProps, analytics, cardState, cardActions, isAISummaryEnabled, onActionClick, extensionKey, url, }: HoverCardResolvedProps) => JSX.Element;
7
7
  export default HoverCardResolvedView;
@@ -9,6 +9,7 @@ export declare class AISummaryService implements AISummaryServiceInt {
9
9
  private onSuccess?;
10
10
  private onError?;
11
11
  constructor(props: AISummaryServiceProps);
12
+ private getRequestUrl;
12
13
  private fetchStream;
13
14
  summariseUrl(): Promise<AISummaryState>;
14
15
  private isExpectedError;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="filesystem" />
2
- import type { ProductType } from '@atlaskit/linking-common';
2
+ import type { ProductType, EnvironmentsKeys } from '@atlaskit/linking-common';
3
3
  export interface AISummaryServiceInt {
4
4
  summariseUrl: () => Promise<AISummaryState>;
5
5
  state: AISummaryState;
@@ -16,10 +16,11 @@ export type AISummaryServiceProps = {
16
16
  * we should always include the ARI if possible
17
17
  */
18
18
  ari?: string;
19
+ envKey?: EnvironmentsKeys;
19
20
  url: string;
20
21
  };
21
22
  export type AISummaryServiceConfig = {
22
- baseUrl: string;
23
+ requestUrl: string;
23
24
  headers: Record<string, string>;
24
25
  };
25
26
  export type AISummaryStatus = 'ready' | 'loading' | 'error' | 'done';
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { type ActionItem } from '../../../../FlexibleCard/components/blocks/types';
3
3
  import { type LinkAction } from '../../../../../state/hooks-external/useSmartLinkActions';
4
4
  import { type HoverCardResolvedProps } from './types';
5
5
  export declare const toFooterActions: (cardActions: LinkAction[], onActionClick?: ((actionId: string) => void) | undefined) => ActionItem[];
6
- declare const HoverCardResolvedView: React.FC<HoverCardResolvedProps>;
6
+ declare const HoverCardResolvedView: ({ flexibleCardProps, titleBlockProps, analytics, cardState, cardActions, isAISummaryEnabled, onActionClick, extensionKey, url, }: HoverCardResolvedProps) => JSX.Element;
7
7
  export default HoverCardResolvedView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.62.1",
3
+ "version": "26.63.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -162,6 +162,9 @@
162
162
  "platform.linking-platform.smart-card.hover-card-ai-summaries-release-stable": {
163
163
  "type": "boolean"
164
164
  },
165
+ "platform.linking-platform.smart-card.ai-summary-service-base-url": {
166
+ "type": "boolean"
167
+ },
165
168
  "platform.linking-platform.smart-card.enable-embed-card-header-tooltip_g9saw": {
166
169
  "type": "boolean"
167
170
  },