@atlaskit/smart-card 26.50.9 → 26.50.11

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 (71) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/constants.js +2 -1
  3. package/dist/cjs/messages.js +5 -0
  4. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +16 -5
  5. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/types.js +7 -1
  6. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/utils.js +47 -41
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/EmbedCard/components/styled.js +1 -1
  9. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  10. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.js +6 -3
  11. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.js +38 -12
  12. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.js +4 -2
  13. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +6 -2
  14. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/styled.js +1 -1
  15. package/dist/cjs/view/HoverCard/components/ContentContainer.js +1 -1
  16. package/dist/cjs/view/HoverCard/styled.js +23 -8
  17. package/dist/cjs/view/LinkUrl/index.js +1 -1
  18. package/dist/cjs/view/common/ai-prism/index.js +11 -4
  19. package/dist/es2019/constants.js +1 -0
  20. package/dist/es2019/messages.js +5 -0
  21. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +8 -2
  22. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -0
  23. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/utils.js +16 -12
  24. package/dist/es2019/utils/analytics/analytics.js +1 -1
  25. package/dist/es2019/view/EmbedCard/components/styled.js +1 -1
  26. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +2 -1
  27. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.js +7 -3
  28. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.js +35 -9
  29. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.js +4 -2
  30. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +6 -2
  31. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/styled.js +1 -1
  32. package/dist/es2019/view/HoverCard/components/ContentContainer.js +1 -1
  33. package/dist/es2019/view/HoverCard/styled.js +19 -20
  34. package/dist/es2019/view/LinkUrl/index.js +1 -1
  35. package/dist/es2019/view/common/ai-prism/index.js +12 -5
  36. package/dist/esm/constants.js +1 -0
  37. package/dist/esm/messages.js +5 -0
  38. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +16 -5
  39. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/types.js +1 -0
  40. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/utils.js +47 -41
  41. package/dist/esm/utils/analytics/analytics.js +1 -1
  42. package/dist/esm/view/EmbedCard/components/styled.js +1 -1
  43. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +2 -1
  44. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.js +6 -3
  45. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.js +39 -13
  46. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.js +4 -2
  47. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +6 -2
  48. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/styled.js +1 -1
  49. package/dist/esm/view/HoverCard/components/ContentContainer.js +1 -1
  50. package/dist/esm/view/HoverCard/styled.js +23 -8
  51. package/dist/esm/view/LinkUrl/index.js +1 -1
  52. package/dist/esm/view/common/ai-prism/index.js +12 -5
  53. package/dist/types/common/analytics/generated/analytics.types.d.ts +3 -1
  54. package/dist/types/constants.d.ts +1 -0
  55. package/dist/types/messages.d.ts +1 -1
  56. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +2 -1
  57. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +4 -1
  58. package/dist/types/state/hooks/use-ai-summary/index.d.ts +2 -5
  59. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.d.ts +3 -1
  60. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.d.ts +2 -1
  61. package/dist/types/view/HoverCard/styled.d.ts +1 -1
  62. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +3 -1
  63. package/dist/types-ts4.5/constants.d.ts +1 -0
  64. package/dist/types-ts4.5/messages.d.ts +1 -1
  65. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +2 -1
  66. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +14 -1
  67. package/dist/types-ts4.5/state/hooks/use-ai-summary/index.d.ts +2 -5
  68. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.d.ts +3 -1
  69. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.d.ts +2 -1
  70. package/dist/types-ts4.5/view/HoverCard/styled.d.ts +1 -1
  71. package/package.json +4 -4
@@ -2,6 +2,7 @@ export async function* readStream(response) {
2
2
  const reader = getBufferReader(response);
3
3
  let doneStreaming = false;
4
4
  let chunkBuffer = '';
5
+ const chunkTypeErrorMessage = 'jsonChunkType error';
5
6
  do {
6
7
  try {
7
8
  const {
@@ -10,21 +11,23 @@ export async function* readStream(response) {
10
11
  } = await reader.read();
11
12
  doneStreaming = done;
12
13
  if (value) {
13
- try {
14
- const processedChunks = `${chunkBuffer}${value}`.split('\n'); // assumes that all JSON chunks are separated by a new-line;
14
+ const processedChunks = `${chunkBuffer}${value}`.split('\n'); // assumes that all JSON chunks are separated by a new-line;
15
15
 
16
- chunkBuffer = '';
17
- for (let chunk of processedChunks) {
18
- try {
19
- yield JSON.parse(chunk);
20
- } catch (e) {
21
- // the chunk may be incomplete, so we'll save it for the next iteration.
22
- chunkBuffer = chunk;
16
+ chunkBuffer = '';
17
+ for (let chunk of processedChunks) {
18
+ try {
19
+ const jsonChunk = JSON.parse(chunk);
20
+ if (jsonChunk.type === 'ERROR') {
21
+ throw new Error(chunkTypeErrorMessage);
23
22
  }
23
+ yield jsonChunk;
24
+ } catch (e) {
25
+ if (e instanceof Error && e.message === chunkTypeErrorMessage) {
26
+ throw e;
27
+ }
28
+ // the chunk may be incomplete, so we'll save it for the next iteration.
29
+ chunkBuffer = chunk;
24
30
  }
25
- } catch (e) {
26
- const error = new Error(`Error Processing Stream Data: ${value}`);
27
- throw error;
28
31
  }
29
32
  }
30
33
  } catch (e) {
@@ -32,6 +35,7 @@ export async function* readStream(response) {
32
35
  if (e instanceof DOMException && e.name === 'AbortError') {
33
36
  doneStreaming = true;
34
37
  } else {
38
+ reader.cancel();
35
39
  throw e;
36
40
  }
37
41
  }
@@ -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.50.9"
7
+ packageVersion: "26.50.11"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -146,7 +146,7 @@ export const LinkWrapper = styled.div`
146
146
  export const Wrapper = styled.div(props => wrapperStyles(props), {
147
147
  // We are keeping this margin as a hardcoded variable as it is not a standard token size and needs
148
148
  // to be thoroughly checked with a designer so that we do not miss an unintended visual change
149
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
149
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
150
150
  marginTop: '10px'
151
151
  });
152
152
  export const embedHeaderHeight = 32;
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
+
3
4
  import { useCallback, useMemo, useState } from 'react';
4
5
  import { FormattedMessage } from 'react-intl-next';
5
6
  import { css, jsx } from '@emotion/react';
@@ -21,7 +22,7 @@ const styles = css({
21
22
  '> div': {
22
23
  alignItems: 'center',
23
24
  'button:focus-visible': {
24
- outlineOffset: '-2px'
25
+ outlineOffset: "var(--ds-space-negative-025, -2px)"
25
26
  }
26
27
  }
27
28
  });
@@ -1,12 +1,16 @@
1
1
  import { useEffect } from 'react';
2
2
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
3
- const AIEventErrorViewed = () => {
3
+ const AIEventErrorViewed = ({
4
+ reason
5
+ }) => {
4
6
  const {
5
7
  fireEvent
6
8
  } = useAnalyticsEvents();
7
9
  useEffect(() => {
8
- fireEvent('ui.error.viewed.aiSummary', {});
9
- }, [fireEvent]);
10
+ fireEvent('ui.error.viewed.aiSummary', {
11
+ reason
12
+ });
13
+ }, [fireEvent, reason]);
10
14
  return null;
11
15
  };
12
16
  export default AIEventErrorViewed;
@@ -6,7 +6,7 @@ import { Box, xcss } from '@atlaskit/primitives';
6
6
  import { messages } from '../../../../../../messages';
7
7
  import AIIndicatorContainer from './ai-indicator-container';
8
8
  import AILearnMoreAnchor from './ai-learn-more-anchor';
9
- import { CONTENT_URL_AI_TROUBLESHOOTING } from '../../../../../../constants';
9
+ import { CONTENT_URL_ACCEPTABLE_USE_POLICY, CONTENT_URL_AI_TROUBLESHOOTING } from '../../../../../../constants';
10
10
  const contentStyles = xcss({
11
11
  color: 'color.text.subtle',
12
12
  fontSize: '11px',
@@ -14,10 +14,39 @@ const contentStyles = xcss({
14
14
  fontWeight: '400',
15
15
  lineHeight: '14px'
16
16
  });
17
+ const MessageWithAnchor = ({
18
+ message,
19
+ url
20
+ }) => /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, message, {
21
+ values: {
22
+ a: chunks => /*#__PURE__*/React.createElement(AILearnMoreAnchor, {
23
+ href: url
24
+ }, chunks)
25
+ }
26
+ }));
27
+ const getErrorMesssageProps = error => {
28
+ switch (error) {
29
+ case 'ACCEPTABLE_USE_VIOLATIONS':
30
+ return {
31
+ message: messages.ai_summary_error_acceptable_use_violation,
32
+ url: CONTENT_URL_ACCEPTABLE_USE_POLICY
33
+ };
34
+ default:
35
+ return {
36
+ message: messages.ai_summary_error_generic,
37
+ url: CONTENT_URL_AI_TROUBLESHOOTING
38
+ };
39
+ }
40
+ };
17
41
  const AIStateError = ({
18
42
  appearance,
19
- testId
43
+ testId,
44
+ error
20
45
  }) => {
46
+ const {
47
+ message,
48
+ url
49
+ } = getErrorMesssageProps(error);
21
50
  switch (appearance) {
22
51
  case 'icon-only':
23
52
  return null;
@@ -32,13 +61,10 @@ const AIStateError = ({
32
61
  content: /*#__PURE__*/React.createElement(Box, {
33
62
  testId: `${testId}-error-message`,
34
63
  xcss: contentStyles
35
- }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.ai_summary_error_generic, {
36
- values: {
37
- a: chunks => /*#__PURE__*/React.createElement(AILearnMoreAnchor, {
38
- href: CONTENT_URL_AI_TROUBLESHOOTING
39
- }, chunks)
40
- }
41
- }))),
64
+ }, /*#__PURE__*/React.createElement(MessageWithAnchor, {
65
+ message: message,
66
+ url: url
67
+ })),
42
68
  testId: `${testId}-error`
43
69
  });
44
70
  }
@@ -7,13 +7,15 @@ import AIStateError from './ai-state-error';
7
7
  const AIStateIndicator = ({
8
8
  state,
9
9
  appearance = 'default',
10
- testId = 'ai-state-indicator'
10
+ testId = 'ai-state-indicator',
11
+ error
11
12
  }) => {
12
13
  switch (state) {
13
14
  case 'error':
14
15
  return jsx(AIStateError, {
15
16
  appearance: appearance,
16
- testId: testId
17
+ testId: testId,
18
+ error: error
17
19
  });
18
20
  case 'loading':
19
21
  return jsx(AIStateLoading, {
@@ -35,7 +35,8 @@ const AISummaryBlockResolvedView = props => {
35
35
  summariseUrl,
36
36
  state: {
37
37
  content,
38
- status
38
+ status,
39
+ error
39
40
  }
40
41
  } = useAISummary({
41
42
  url
@@ -107,7 +108,10 @@ const AISummaryBlockResolvedView = props => {
107
108
  size: size
108
109
  }))), showAISummaryErrorMessage && /*#__PURE__*/React.createElement(Inline, {
109
110
  grow: "fill"
110
- }, /*#__PURE__*/React.createElement(AIEventErrorViewed, null), /*#__PURE__*/React.createElement(AIStateIndicator, {
111
+ }, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
112
+ reason: error
113
+ }), /*#__PURE__*/React.createElement(AIStateIndicator, {
114
+ error: error,
111
115
  state: status,
112
116
  testId: testId
113
117
  })));
@@ -12,7 +12,7 @@ export const dropdownItemGroupStyles = css({
12
12
  });
13
13
  const sharedBlockStyles = css({
14
14
  display: 'flex',
15
- gap: '0.5rem',
15
+ gap: "var(--ds-space-100, 0.5rem)",
16
16
  lineHeight: '1rem',
17
17
  minWidth: 0,
18
18
  overflow: 'hidden',
@@ -32,7 +32,7 @@ const ConnectedAIPrismContainer = ({
32
32
  }, [status]);
33
33
  const container = jsx("div", _extends({
34
34
  className: hoverCardClassName,
35
- css: [HoverCardContainer, isAIEnabled && showPrism ? undefined : popupContainerStyles],
35
+ css: [HoverCardContainer, !isAIEnabled ? popupContainerStyles : undefined],
36
36
  "data-testid": testId
37
37
  }, props), children);
38
38
  return isAIEnabled ? jsx(AIPrism, {
@@ -14,16 +14,16 @@ export const flexibleUiOptions = {
14
14
  zIndex: HOVER_CARD_Z_INDEX + 1
15
15
  };
16
16
  export const CARD_WIDTH_REM = 24;
17
- export const NEW_CARD_WIDTH_REM = 28;
17
+ export const NEW_CARD_WIDTH_REM = 25;
18
18
  // gap between mouse cursor and hover card
19
19
  export const CARD_GAP_PX = 10;
20
20
  const blockGap = '0.5rem';
21
21
  const elementGap = '0.5rem';
22
- export const separatorCss = css`
23
- [data-separator] + [data-separator]:before {
24
- margin-right: ${elementGap};
22
+ export const separatorCss = css({
23
+ '[data-separator] + [data-separator]:before': {
24
+ marginRight: elementGap
25
25
  }
26
- `;
26
+ });
27
27
  export const HoverCardContainer = css`
28
28
  background: none;
29
29
  border-width: 0;
@@ -56,18 +56,17 @@ export const titleBlockCss = css`
56
56
  font-weight: 600;
57
57
  }
58
58
  `;
59
- export const getTransitionStyles = snippetHeight => css`
60
- transition: height 300ms ease-in-out;
61
- height: ${snippetHeight}px;
62
- `;
63
- export const popupContainerStyles = css`
64
- border-radius: ${"var(--ds-border-radius-200, 8px)"};
65
- background-color: ${"var(--ds-surface-raised, white)"};
66
- box-shadow: ${"var(--ds-shadow-overlay, 0px 8px 12px rgba(9, 30, 66, 0.15),0px 0px 1px rgba(9, 30, 66, 0.31))"};
67
- `;
68
- export const getPreviewBlockStyles = previewHeight => css`
69
- ${previewHeight ? `height: ${previewHeight}px;` : ''}
70
- border-top-left-radius: ${"var(--ds-border-radius-200, 8px)"};
71
- border-top-right-radius: ${"var(--ds-border-radius-200, 8px)"};
72
- margin-bottom: ${blockGap};
73
- `;
59
+ export const getTransitionStyles = snippetHeight => css({
60
+ transition: 'height 300ms ease-in-out',
61
+ height: `${snippetHeight}px`
62
+ });
63
+ export const popupContainerStyles = css({
64
+ borderRadius: "var(--ds-border-radius-200, 8px)",
65
+ backgroundColor: "var(--ds-surface-raised, white)",
66
+ boxShadow: "var(--ds-shadow-overlay, 0px 8px 12px rgba(9, 30, 66, 0.15),0px 0px 1px rgba(9, 30, 66, 0.31))"
67
+ });
68
+ export const getPreviewBlockStyles = previewHeight => css(previewHeight ? `height: ${previewHeight}px;` : '', {
69
+ borderTopLeftRadius: "var(--ds-border-radius-200, 8px)",
70
+ borderTopRightRadius: "var(--ds-border-radius-200, 8px)",
71
+ marginBottom: blockGap
72
+ });
@@ -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.50.9",
10
+ packageVersion: "26.50.11",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -1,11 +1,17 @@
1
1
  /** @jsx jsx */
2
2
  import { css, jsx } from '@emotion/react';
3
3
  import { useThemeObserver } from '@atlaskit/tokens';
4
- import { AI_BORDER_PALETTE, INNER_BORDER_RADIUS } from './constants';
4
+ import { AI_BORDER_PALETTE } from './constants';
5
5
  import AIGlowingBorder from './ai-glowing-border';
6
+ import { popupContainerStyles } from '../../HoverCard/styled';
6
7
  const contentStyles = css({
7
- backgroundColor: "var(--ds-surface-raised, white)",
8
- borderRadius: INNER_BORDER_RADIUS
8
+ transition: 'box-shadow 0.5s ease'
9
+ });
10
+ const contentStylesPrismVisible = css({
11
+ // intentionally set opacity to 0 to remove the shadow with fade out animation
12
+ boxShadow:
13
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
14
+ '0px 8px 12px rgba(9, 30, 66, 0),0px 0px 1px rgba(9, 30, 66, 0)'
9
15
  });
10
16
  const AIPrism = ({
11
17
  children,
@@ -21,7 +27,8 @@ const AIPrism = ({
21
27
  return jsx(AIGlowingBorder, {
22
28
  additionalCss: {
23
29
  animatedSvgContainer: css({
24
- opacity: isVisible ? 1 : 0
30
+ opacity: isVisible ? 1 : 0,
31
+ transition: 'opacity 0.5s ease'
25
32
  })
26
33
  },
27
34
  palette: (_AI_BORDER_PALETTE$co = AI_BORDER_PALETTE[colorMode]) !== null && _AI_BORDER_PALETTE$co !== void 0 ? _AI_BORDER_PALETTE$co : AI_BORDER_PALETTE.light,
@@ -29,7 +36,7 @@ const AIPrism = ({
29
36
  isMoving: isMoving,
30
37
  testId: testId
31
38
  }, jsx("div", {
32
- css: contentStyles
39
+ css: [popupContainerStyles, contentStyles, isVisible ? contentStylesPrismVisible : undefined]
33
40
  }, children));
34
41
  };
35
42
  export default AIPrism;
@@ -2,6 +2,7 @@ export var CONTENT_URL_SECURITY_AND_PERMISSIONS = 'https://support.atlassian.com
2
2
  export var CONTENT_URL_3P_ACCOUNT_AUTH = 'https://support.atlassian.com/confluence-cloud/docs/what-data-is-sent-and-received-when-pasting-a-smart-link/';
3
3
  export var CONTENT_URL_AI = 'https://www.atlassian.com/trust/atlassian-intelligence';
4
4
  export var CONTENT_URL_AI_TROUBLESHOOTING = 'https://support.atlassian.com/organization-administration/docs/troubleshooting-for-atlassian-intelligence/';
5
+ export var CONTENT_URL_ACCEPTABLE_USE_POLICY = 'https://www.atlassian.com/legal/acceptable-use-policy';
5
6
 
6
7
  /**
7
8
  * The alignment of Flexible UI component.
@@ -40,6 +40,11 @@ export var messages = defineMessages({
40
40
  defaultMessage: "Atlassian Intelligence can't provide a response right now. Read more <a>in our support documentation</a>.",
41
41
  description: 'Shown when AI summary is summarising the link resource content.'
42
42
  },
43
+ ai_summary_error_acceptable_use_violation: {
44
+ id: 'fabric.linking.ai_summary_error_acceptable_use_violation',
45
+ defaultMessage: "We cannot show the results of this summary as it goes against <a>Atlassian's Acceptable Use Policy</a>.",
46
+ description: 'Shown when AI summary is summarising the link resource content and the content violates atlassians acceptable use policy.'
47
+ },
43
48
  assigned_to: {
44
49
  id: 'fabric.linking.assigned_to',
45
50
  defaultMessage: 'Assigned to {context}',
@@ -11,6 +11,7 @@ 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
+ import { errorMessages } from './types';
14
15
  import { readStream, addPath } from './utils';
15
16
  export var AISummaryService = /*#__PURE__*/function () {
16
17
  function AISummaryService(props) {
@@ -104,6 +105,7 @@ export var AISummaryService = /*#__PURE__*/function () {
104
105
  subscriber,
105
106
  _chunk$message,
106
107
  _this$onError,
108
+ message,
107
109
  _iterator4,
108
110
  _step4,
109
111
  _subscriber2,
@@ -212,17 +214,19 @@ export var AISummaryService = /*#__PURE__*/function () {
212
214
  status: 'done',
213
215
  content: bufferContent
214
216
  };
215
- _context2.next = 50;
217
+ _context2.next = 51;
216
218
  break;
217
219
  case 46:
218
220
  _context2.prev = 46;
219
221
  _context2.t1 = _context2["catch"](5);
220
- (_this$onError = this.onError) === null || _this$onError === void 0 || _this$onError.call(this, id, 'generic');
222
+ message = _context2.t1 instanceof Error && this.isExpectedError(_context2.t1.message) ? _context2.t1.message : 'UNEXPECTED';
223
+ (_this$onError = this.onError) === null || _this$onError === void 0 || _this$onError.call(this, id, message);
221
224
  this.state = {
222
225
  status: 'error',
223
- content: ''
226
+ content: '',
227
+ error: message
224
228
  };
225
- case 50:
229
+ case 51:
226
230
  _iterator4 = _createForOfIteratorHelper(this.subscribedStateSetters);
227
231
  try {
228
232
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
@@ -234,7 +238,7 @@ export var AISummaryService = /*#__PURE__*/function () {
234
238
  } finally {
235
239
  _iterator4.f();
236
240
  }
237
- case 52:
241
+ case 53:
238
242
  case "end":
239
243
  return _context2.stop();
240
244
  }
@@ -245,6 +249,13 @@ export var AISummaryService = /*#__PURE__*/function () {
245
249
  }
246
250
  return summariseUrl;
247
251
  }()
252
+ }, {
253
+ key: "isExpectedError",
254
+ value: function isExpectedError(value) {
255
+ return typeof value === 'string' && errorMessages.some(function (a) {
256
+ return a === value;
257
+ });
258
+ }
248
259
  }, {
249
260
  key: "subscribe",
250
261
  value: function subscribe(stateSetter) {
@@ -0,0 +1 @@
1
+ export var errorMessages = ['NETWORK_ERROR', 'NO_ANSWER', 'RATE_LIMIT', 'NO_AGENT', 'PLUGIN_ERRORED', 'OPENAI_RATE_LIMIT_USER_ABUSE', 'ACCEPTABLE_USE_VIOLATIONS', 'AI_DISABLED', 'UNEXPECTED'];
@@ -9,27 +9,27 @@ export function readStream(_x) {
9
9
  }
10
10
  function _readStream() {
11
11
  _readStream = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
12
- var reader, doneStreaming, chunkBuffer, _yield$_awaitAsyncGen, value, done, processedChunks, _iterator, _step, chunk, error, _error;
12
+ var reader, doneStreaming, chunkBuffer, chunkTypeErrorMessage, _yield$_awaitAsyncGen, value, done, processedChunks, _iterator, _step, chunk, jsonChunk, error;
13
13
  return _regeneratorRuntime.wrap(function _callee$(_context) {
14
14
  while (1) switch (_context.prev = _context.next) {
15
15
  case 0:
16
16
  reader = getBufferReader(response);
17
17
  doneStreaming = false;
18
18
  chunkBuffer = '';
19
- case 3:
20
- _context.prev = 3;
21
- _context.next = 6;
19
+ chunkTypeErrorMessage = 'jsonChunkType error';
20
+ case 4:
21
+ _context.prev = 4;
22
+ _context.next = 7;
22
23
  return _awaitAsyncGenerator(reader.read());
23
- case 6:
24
+ case 7:
24
25
  _yield$_awaitAsyncGen = _context.sent;
25
26
  value = _yield$_awaitAsyncGen.value;
26
27
  done = _yield$_awaitAsyncGen.done;
27
28
  doneStreaming = done;
28
29
  if (!value) {
29
- _context.next = 43;
30
+ _context.next = 42;
30
31
  break;
31
32
  }
32
- _context.prev = 11;
33
33
  processedChunks = "".concat(chunkBuffer).concat(value).split('\n'); // assumes that all JSON chunks are separated by a new-line;
34
34
  chunkBuffer = '';
35
35
  _iterator = _createForOfIteratorHelper(processedChunks);
@@ -37,61 +37,67 @@ function _readStream() {
37
37
  _iterator.s();
38
38
  case 17:
39
39
  if ((_step = _iterator.n()).done) {
40
- _context.next = 29;
40
+ _context.next = 34;
41
41
  break;
42
42
  }
43
43
  chunk = _step.value;
44
44
  _context.prev = 19;
45
- _context.next = 22;
46
- return JSON.parse(chunk);
47
- case 22:
48
- _context.next = 27;
45
+ jsonChunk = JSON.parse(chunk);
46
+ if (!(jsonChunk.type === 'ERROR')) {
47
+ _context.next = 23;
48
+ break;
49
+ }
50
+ throw new Error(chunkTypeErrorMessage);
51
+ case 23:
52
+ _context.next = 25;
53
+ return jsonChunk;
54
+ case 25:
55
+ _context.next = 32;
49
56
  break;
50
- case 24:
51
- _context.prev = 24;
57
+ case 27:
58
+ _context.prev = 27;
52
59
  _context.t0 = _context["catch"](19);
60
+ if (!(_context.t0 instanceof Error && _context.t0.message === chunkTypeErrorMessage)) {
61
+ _context.next = 31;
62
+ break;
63
+ }
64
+ throw _context.t0;
65
+ case 31:
53
66
  // the chunk may be incomplete, so we'll save it for the next iteration.
54
67
  chunkBuffer = chunk;
55
- case 27:
68
+ case 32:
56
69
  _context.next = 17;
57
70
  break;
58
- case 29:
59
- _context.next = 34;
71
+ case 34:
72
+ _context.next = 39;
60
73
  break;
61
- case 31:
62
- _context.prev = 31;
74
+ case 36:
75
+ _context.prev = 36;
63
76
  _context.t1 = _context["catch"](15);
64
77
  _iterator.e(_context.t1);
65
- case 34:
66
- _context.prev = 34;
67
- _iterator.f();
68
- return _context.finish(34);
69
- case 37:
70
- _context.next = 43;
71
- break;
72
78
  case 39:
73
79
  _context.prev = 39;
74
- _context.t2 = _context["catch"](11);
75
- error = new Error("Error Processing Stream Data: ".concat(value));
76
- throw error;
77
- case 43:
80
+ _iterator.f();
81
+ return _context.finish(39);
82
+ case 42:
78
83
  _context.next = 52;
79
84
  break;
80
- case 45:
81
- _context.prev = 45;
82
- _context.t3 = _context["catch"](3);
83
- if (!(_context.t3 instanceof DOMException && _context.t3.name === 'AbortError')) {
84
- _context.next = 51;
85
+ case 44:
86
+ _context.prev = 44;
87
+ _context.t2 = _context["catch"](4);
88
+ if (!(_context.t2 instanceof DOMException && _context.t2.name === 'AbortError')) {
89
+ _context.next = 50;
85
90
  break;
86
91
  }
87
92
  doneStreaming = true;
88
93
  _context.next = 52;
89
94
  break;
90
- case 51:
91
- throw _context.t3;
95
+ case 50:
96
+ reader.cancel();
97
+ throw _context.t2;
92
98
  case 52:
93
99
  if (!doneStreaming) {
94
- _context.next = 3;
100
+ _context.next = 4;
95
101
  break;
96
102
  }
97
103
  case 53:
@@ -99,13 +105,13 @@ function _readStream() {
99
105
  _context.next = 56;
100
106
  break;
101
107
  }
102
- _error = new Error("Not all the data was processed: ".concat(chunkBuffer));
103
- throw _error;
108
+ error = new Error("Not all the data was processed: ".concat(chunkBuffer));
109
+ throw error;
104
110
  case 56:
105
111
  case "end":
106
112
  return _context.stop();
107
113
  }
108
- }, _callee, null, [[3, 45], [11, 39], [15, 31, 34, 37], [19, 24]]);
114
+ }, _callee, null, [[4, 44], [15, 36, 39, 42], [19, 27]]);
109
115
  }));
110
116
  return _readStream.apply(this, arguments);
111
117
  }
@@ -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.50.9"
18
+ packageVersion: "26.50.11"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -76,7 +76,7 @@ export var Wrapper = styled.div(function (props) {
76
76
  }, {
77
77
  // We are keeping this margin as a hardcoded variable as it is not a standard token size and needs
78
78
  // to be thoroughly checked with a designer so that we do not miss an unintended visual change
79
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
79
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
80
80
  marginTop: '10px'
81
81
  });
82
82
  export var embedHeaderHeight = 32;
@@ -3,6 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  var _excluded = ["triggerRef"];
5
5
  /** @jsx jsx */
6
+
6
7
  import { useCallback, useMemo, useState } from 'react';
7
8
  import { FormattedMessage } from 'react-intl-next';
8
9
  import { css, jsx } from '@emotion/react';
@@ -24,7 +25,7 @@ var styles = css({
24
25
  '> div': {
25
26
  alignItems: 'center',
26
27
  'button:focus-visible': {
27
- outlineOffset: '-2px'
28
+ outlineOffset: "var(--ds-space-negative-025, -2px)"
28
29
  }
29
30
  }
30
31
  });
@@ -1,11 +1,14 @@
1
1
  import { useEffect } from 'react';
2
2
  import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
3
- var AIEventErrorViewed = function AIEventErrorViewed() {
3
+ var AIEventErrorViewed = function AIEventErrorViewed(_ref) {
4
+ var reason = _ref.reason;
4
5
  var _useAnalyticsEvents = useAnalyticsEvents(),
5
6
  fireEvent = _useAnalyticsEvents.fireEvent;
6
7
  useEffect(function () {
7
- fireEvent('ui.error.viewed.aiSummary', {});
8
- }, [fireEvent]);
8
+ fireEvent('ui.error.viewed.aiSummary', {
9
+ reason: reason
10
+ });
11
+ }, [fireEvent, reason]);
9
12
  return null;
10
13
  };
11
14
  export default AIEventErrorViewed;