@financial-times/qanda-ui 0.0.1-beta.2 → 0.0.1-beta.21

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 (123) hide show
  1. package/README.md +38 -6
  2. package/dist/cjs/components/Author/index.js +19 -0
  3. package/dist/cjs/components/Calendar/Apps.js +48 -0
  4. package/dist/cjs/components/Calendar/CalendarList.js +12 -0
  5. package/dist/cjs/components/Calendar/CalendarListItem.js +24 -0
  6. package/dist/cjs/components/Calendar/index.js +47 -0
  7. package/dist/cjs/components/CountdownTimer/index.js +91 -0
  8. package/dist/cjs/components/EmbedFormField/index.js +24 -0
  9. package/dist/cjs/components/ErrorMessage/humanReadableError.js +74 -0
  10. package/dist/cjs/components/ErrorMessage/index.js +63 -0
  11. package/dist/cjs/components/Expander/index.js +71 -0
  12. package/dist/cjs/components/ExpertDrawer/index.js +36 -0
  13. package/dist/cjs/components/FloatingActionBar/index.js +59 -0
  14. package/dist/cjs/components/Loader/index.js +7 -0
  15. package/dist/cjs/components/MessageBox/index.js +7 -0
  16. package/dist/cjs/components/Overlay/index.js +18 -0
  17. package/dist/cjs/components/Qanda.js +37 -0
  18. package/dist/cjs/components/QandaBlock/index.js +78 -0
  19. package/dist/cjs/components/QandaContainer.js +99 -0
  20. package/dist/cjs/components/QandaProvider.js +11 -0
  21. package/dist/cjs/components/QuestionForm/index.js +165 -0
  22. package/dist/cjs/components/QuestionForm/messagesByUserType.js +33 -0
  23. package/dist/cjs/components/Stream/index.js +37 -0
  24. package/dist/cjs/components/Survey/index.js +36 -0
  25. package/dist/cjs/hooks/useIsMobile.js +15 -0
  26. package/dist/cjs/index.js +53 -0
  27. package/dist/cjs/services/comments-api.js +152 -0
  28. package/dist/cjs/services/error-middleware.js +47 -0
  29. package/dist/cjs/services/reliability.js +79 -0
  30. package/dist/cjs/store/expertSlice.js +26 -0
  31. package/dist/cjs/store/index.js +30 -0
  32. package/dist/cjs/store/questionSlice.js +32 -0
  33. package/dist/cjs/store/stream.js +17 -0
  34. package/dist/cjs/store/updateComments.js +40 -0
  35. package/dist/cjs/store/user.js +51 -0
  36. package/dist/cjs/utils/auth.js +26 -0
  37. package/dist/cjs/utils/qandas.js +20 -0
  38. package/dist/cjs/utils/strings.js +16 -0
  39. package/dist/cjs/utils/tracking.js +11 -0
  40. package/dist/cjs/utils/validate-display-name.js +22 -0
  41. package/dist/esm/components/Author/index.js +14 -0
  42. package/dist/esm/components/Calendar/Apps.js +46 -0
  43. package/dist/esm/components/Calendar/CalendarList.js +7 -0
  44. package/dist/esm/components/Calendar/CalendarListItem.js +22 -0
  45. package/dist/esm/components/Calendar/index.js +42 -0
  46. package/dist/esm/components/CountdownTimer/index.js +88 -0
  47. package/dist/esm/components/EmbedFormField/index.js +22 -0
  48. package/dist/esm/components/ErrorMessage/humanReadableError.js +71 -0
  49. package/dist/esm/components/ErrorMessage/index.js +57 -0
  50. package/dist/esm/components/Expander/index.js +69 -0
  51. package/dist/esm/components/ExpertDrawer/index.js +31 -0
  52. package/dist/esm/components/FloatingActionBar/index.js +57 -0
  53. package/dist/esm/components/Loader/index.js +4 -0
  54. package/dist/esm/components/MessageBox/index.js +5 -0
  55. package/dist/esm/components/Overlay/index.js +13 -0
  56. package/dist/esm/components/Qanda.js +32 -0
  57. package/dist/esm/components/QandaBlock/index.js +73 -0
  58. package/dist/esm/components/QandaContainer.js +94 -0
  59. package/dist/esm/components/QandaProvider.js +8 -0
  60. package/dist/esm/components/QuestionForm/index.js +159 -0
  61. package/dist/esm/components/QuestionForm/messagesByUserType.js +28 -0
  62. package/dist/esm/components/Stream/index.js +32 -0
  63. package/dist/esm/components/Survey/index.js +34 -0
  64. package/dist/esm/hooks/useIsMobile.js +12 -0
  65. package/dist/esm/index.js +46 -0
  66. package/dist/esm/services/comments-api.js +147 -0
  67. package/dist/esm/services/error-middleware.js +43 -0
  68. package/dist/esm/services/reliability.js +75 -0
  69. package/dist/esm/store/expertSlice.js +22 -0
  70. package/dist/esm/store/index.js +24 -0
  71. package/dist/esm/store/questionSlice.js +28 -0
  72. package/dist/esm/store/stream.js +14 -0
  73. package/dist/esm/store/updateComments.js +36 -0
  74. package/dist/esm/store/user.js +45 -0
  75. package/dist/esm/utils/auth.js +24 -0
  76. package/dist/esm/utils/qandas.js +16 -0
  77. package/dist/esm/utils/strings.js +13 -0
  78. package/dist/esm/utils/tracking.js +7 -0
  79. package/dist/esm/utils/validate-display-name.js +19 -0
  80. package/dist/qanda.scss +802 -0
  81. package/dist/types/components/Author/index.d.ts +18 -0
  82. package/dist/types/components/Calendar/Apps.d.ts +14 -0
  83. package/dist/types/components/Calendar/CalendarList.d.ts +2 -0
  84. package/dist/types/components/Calendar/CalendarListItem.d.ts +8 -0
  85. package/dist/types/components/Calendar/index.d.ts +2 -0
  86. package/dist/types/components/CountdownTimer/index.d.ts +6 -0
  87. package/dist/types/components/EmbedFormField/index.d.ts +5 -0
  88. package/dist/types/components/ErrorMessage/humanReadableError.d.ts +29 -0
  89. package/dist/types/components/ErrorMessage/index.d.ts +8 -0
  90. package/dist/types/components/Expander/index.d.ts +8 -0
  91. package/dist/types/components/ExpertDrawer/index.d.ts +2 -0
  92. package/dist/types/components/FloatingActionBar/index.d.ts +4 -0
  93. package/dist/types/components/Loader/index.d.ts +14 -0
  94. package/dist/types/components/MessageBox/index.d.ts +10 -0
  95. package/dist/types/components/Overlay/index.d.ts +12 -0
  96. package/dist/types/components/Qanda.d.ts +3 -0
  97. package/dist/types/components/QandaBlock/index.d.ts +7 -0
  98. package/dist/types/components/QandaContainer.d.ts +6 -0
  99. package/dist/types/components/QandaProvider.d.ts +9 -0
  100. package/dist/types/components/QuestionForm/index.d.ts +1 -0
  101. package/dist/types/components/QuestionForm/messagesByUserType.d.ts +7 -0
  102. package/dist/types/components/Stream/index.d.ts +5 -0
  103. package/dist/types/components/Survey/index.d.ts +6 -0
  104. package/dist/types/hooks/useIsMobile.d.ts +1 -0
  105. package/dist/types/index.d.ts +17 -0
  106. package/dist/types/services/comments-api.d.ts +52 -0
  107. package/dist/types/services/error-middleware.d.ts +2 -0
  108. package/dist/types/services/reliability.d.ts +19 -0
  109. package/dist/types/store/expertSlice.d.ts +14 -0
  110. package/dist/types/store/index.d.ts +218 -0
  111. package/dist/types/store/questionSlice.d.ts +16 -0
  112. package/dist/types/store/stream.d.ts +7 -0
  113. package/dist/types/store/updateComments.d.ts +3 -0
  114. package/dist/types/store/user.d.ts +26 -0
  115. package/dist/types/utils/auth.d.ts +6 -0
  116. package/dist/types/utils/qandas.d.ts +2 -0
  117. package/dist/types/utils/strings.d.ts +1 -0
  118. package/dist/types/utils/tracking.d.ts +2 -0
  119. package/dist/types/utils/validate-display-name.d.ts +1 -0
  120. package/package.json +35 -29
  121. package/dist/index.html +0 -19
  122. package/dist/index.js +0 -2
  123. package/dist/index.js.LICENSE.txt +0 -15
@@ -0,0 +1,18 @@
1
+ import { StructuredTreeFragment } from '@financial-times/cp-content-pipeline-client';
2
+ type AuthorProps = {
3
+ byline: StructuredTreeFragment;
4
+ headshot?: string;
5
+ prefLabel?: string;
6
+ role: string;
7
+ streamPage?: string;
8
+ };
9
+ declare function Author({ byline, headshot, prefLabel, role, streamPage, }: AuthorProps): import("preact").JSX.Element;
10
+ declare namespace Author {
11
+ var defaultProps: {
12
+ byline: string;
13
+ headshot: boolean;
14
+ prefLabel: boolean;
15
+ streamPage: string;
16
+ };
17
+ }
18
+ export default Author;
@@ -0,0 +1,14 @@
1
+ import { JSX, PropsWithChildren } from 'react';
2
+ export type LinkProps = {
3
+ title: string;
4
+ startDateTime: string;
5
+ endDateTime: string;
6
+ url: string;
7
+ children?: string;
8
+ };
9
+ declare const _default: {
10
+ name: string;
11
+ icon: JSX.Element;
12
+ link: ({ title, startDateTime, endDateTime, url, }: PropsWithChildren<LinkProps>) => JSX.Element;
13
+ }[];
14
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare function CalendarList(): import("preact").JSX.Element;
2
+ export default CalendarList;
@@ -0,0 +1,8 @@
1
+ import { JSX } from 'react';
2
+ import type { LinkProps } from './Apps';
3
+ type CalendarListItemProps = {
4
+ name: string;
5
+ link: (props: LinkProps) => JSX.Element;
6
+ };
7
+ declare function CalendarListItem({ name, link }: CalendarListItemProps): JSX.Element;
8
+ export default CalendarListItem;
@@ -0,0 +1,2 @@
1
+ declare function Calendar(): import("react").JSX.Element;
2
+ export default Calendar;
@@ -0,0 +1,6 @@
1
+ type CountdownTimerProps = {
2
+ container?: HTMLElement;
3
+ };
4
+ export declare function formatTime(remainingTime: number): string | undefined;
5
+ declare function CountdownTimer({ container }: CountdownTimerProps): import("react").JSX.Element;
6
+ export default CountdownTimer;
@@ -0,0 +1,5 @@
1
+ type EmbedFormFieldProps = {
2
+ container?: HTMLElement;
3
+ };
4
+ declare function EmbedFormField({ container }: EmbedFormFieldProps): import("react").JSX.Element;
5
+ export default EmbedFormField;
@@ -0,0 +1,29 @@
1
+ import type { FetchBaseQueryError } from '@reduxjs/toolkit/query';
2
+ import type { SerializedError } from '@reduxjs/toolkit';
3
+ import type { ErrorObjectResponseWithUserErrorCode } from '../../types/comments-api';
4
+ type AbortError = {
5
+ name: 'AbortError';
6
+ message: string;
7
+ };
8
+ type UnMappedErrorDetails = {
9
+ name: string;
10
+ message: string;
11
+ };
12
+ export type ErrorMessage = Record<string, {
13
+ title: string;
14
+ message: string;
15
+ }>;
16
+ type FetchBaseQueryErrorWithUserErrorCode = {
17
+ status: number;
18
+ data: ErrorObjectResponseWithUserErrorCode;
19
+ };
20
+ export type AcceptedError = FetchBaseQueryError | SerializedError | AbortError | FetchBaseQueryErrorWithUserErrorCode;
21
+ export default class HumanReadableError {
22
+ private _humanReadableError;
23
+ private _unMappedError;
24
+ constructor(error: AcceptedError, customErrorMessages?: ErrorMessage);
25
+ get title(): string;
26
+ get message(): string;
27
+ get unmappedError(): UnMappedErrorDetails | null;
28
+ }
29
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { AcceptedError, ErrorMessage } from './humanReadableError';
2
+ export default function ErrorMessage({ error, storyId, errorMapping, operation, id, }: {
3
+ error: AcceptedError;
4
+ storyId: string;
5
+ errorMapping?: ErrorMessage;
6
+ operation?: string;
7
+ id?: string;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ type ExpanderProps = {
2
+ className?: string;
3
+ expandLabel?: string;
4
+ collapseLabel?: string;
5
+ id: string;
6
+ };
7
+ declare function Expander({ className, children, expandLabel, collapseLabel, id, }: React.PropsWithChildren<ExpanderProps>): import("react").JSX.Element;
8
+ export default Expander;
@@ -0,0 +1,2 @@
1
+ declare function ExpertDrawer(): import("react").JSX.Element | null;
2
+ export default ExpertDrawer;
@@ -0,0 +1,4 @@
1
+ declare function FloatingActionBar({ showLiveIndicator, }: {
2
+ showLiveIndicator?: boolean;
3
+ }): import("react").JSX.Element;
4
+ export default FloatingActionBar;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Loader component that shows the o-loading spinner, defaults to small light variant
3
+ * @typedef {Object} LoaderProps
4
+ * @property {('mini'|'small'|'medium'|'large')} [size] - Size variant of the loader.
5
+ * @property {('dark'|'light')} [theme] - Theme variant of the loader.
6
+
7
+ * @property {string} [extraClassNames] - Additional CSS class names to be applied to the loader component for custom styling.
8
+ */
9
+ export type LoaderProps = {
10
+ size?: 'mini' | 'small' | 'medium' | 'large';
11
+ theme?: 'dark' | 'light';
12
+ extraClassNames?: string;
13
+ };
14
+ export default function Loader({ size, theme, extraClassNames, }: LoaderProps): import("preact").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { JSX } from 'react';
2
+ type MessageBoxProps = {
3
+ color?: string;
4
+ text: string | JSX.Element;
5
+ title: string;
6
+ extraClassNames?: string;
7
+ id?: string;
8
+ };
9
+ declare function MessageBox({ color, extraClassNames, text, title, id, }: MessageBoxProps): JSX.Element;
10
+ export default MessageBox;
@@ -0,0 +1,12 @@
1
+ type OverlayOptions = {
2
+ noBackground?: boolean;
3
+ shadow?: boolean;
4
+ };
5
+ type OverlayProps = {
6
+ title: String;
7
+ children: React.ReactNode;
8
+ closeCallback: () => void;
9
+ options?: OverlayOptions;
10
+ };
11
+ declare function Overlay({ title, children, closeCallback, options, }: OverlayProps): import("preact").JSX.Element;
12
+ export default Overlay;
@@ -0,0 +1,3 @@
1
+ import type { QandaProps } from '../types/qanda';
2
+ declare function Qanda({ storyId, useStaging, title, commentsAPIHost, commentsAPIVersion, maxQuestionLength, embedFormFieldContainer, countdownTimerContainer, }: QandaProps): import("preact").JSX.Element | null;
3
+ export default Qanda;
@@ -0,0 +1,7 @@
1
+ import type { Comment } from '../../types/comment';
2
+ import '../Expander/index';
3
+ type QandaBlockProps = Comment & {
4
+ showAnswerTime: boolean;
5
+ };
6
+ declare function QandaBlock({ id, body, children, byline, subtitle, showAnswerTime, }: QandaBlockProps): import("react").JSX.Element;
7
+ export default QandaBlock;
@@ -0,0 +1,6 @@
1
+ type QandaContainerProps = {
2
+ embedFormFieldContainer?: HTMLElement;
3
+ countdownTimerContainer?: HTMLElement;
4
+ };
5
+ declare function QandaContainer({ embedFormFieldContainer, countdownTimerContainer, }: QandaContainerProps): import("react").JSX.Element;
6
+ export default QandaContainer;
@@ -0,0 +1,9 @@
1
+ type QandaContextType = {
2
+ storyId: string;
3
+ useStaging: boolean;
4
+ commentsAPIUrl: string;
5
+ title: string;
6
+ maxQuestionLength?: number;
7
+ };
8
+ export declare const QandaContext: import("preact").Context<QandaContextType>;
9
+ export {};
@@ -0,0 +1 @@
1
+ export default function QuestionForm(): import("react").JSX.Element | undefined;
@@ -0,0 +1,7 @@
1
+ import { UserDetails } from '../../store/user';
2
+ export declare const SIGN_IN_URL = "https://www.ft.com/login";
3
+ export declare const SUBSCRIBE_URL = "https://subs.ft.com/products";
4
+ export declare const COMMUNITY_GUIDELINES_URL = "https://help.ft.com/help/article-queries/commenting-on-an-article/commenting-guidelines";
5
+ export declare const TERMS_AND_CONDITIONS_URL = "https://help.ft.com/help/legal-privacy/terms-conditions";
6
+ export declare function getTitleByUser(profile: UserDetails): "Q&A guidelines" | "You are still on a trial period" | "Asking a question is only available to readers with an FT subscription";
7
+ export declare function getTextByUser(profile: UserDetails): import("preact").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { Status } from '../../types/qa';
2
+ declare function Stream({ status }: {
3
+ status: Status;
4
+ }): import("react").JSX.Element;
5
+ export default Stream;
@@ -0,0 +1,6 @@
1
+ type SurveyProps = {
2
+ storyId: string;
3
+ status: string;
4
+ };
5
+ declare function Survey({ storyId, status }: SurveyProps): import("preact").JSX.Element;
6
+ export default Survey;
@@ -0,0 +1 @@
1
+ export declare function useIsMobile(breakpoint?: number): boolean;
@@ -0,0 +1,17 @@
1
+ import QandaBlock from './components/QandaBlock';
2
+ import type { QandaProps } from './types/qanda';
3
+ declare class QandaUI {
4
+ containerElement: HTMLElement;
5
+ embedFormFieldContainer: HTMLElement;
6
+ countdownTimerContainer: HTMLElement;
7
+ storyId: string;
8
+ useStaging: boolean;
9
+ title: string;
10
+ commentsAPIHost: string;
11
+ commentsAPIVersion: string;
12
+ maxQuestionLength: number;
13
+ constructor(containerElement: HTMLElement, options?: QandaProps);
14
+ init(): void;
15
+ destroy(): void;
16
+ }
17
+ export { QandaUI, QandaBlock };
@@ -0,0 +1,52 @@
1
+ import type { Comment } from '../types/comment';
2
+ import type { QA } from '../types/qa';
3
+ import type { Status } from '../types/qa';
4
+ export declare let eventSource: EventSource | null;
5
+ type CommentsStreamResponse = {
6
+ type: string;
7
+ children?: Comment[];
8
+ status?: Status;
9
+ startDateTime?: string;
10
+ endDateTime?: string;
11
+ };
12
+ type CommentsStreamTransformed = Omit<CommentsStreamResponse, 'children'> & {
13
+ qandas: Comment[];
14
+ };
15
+ type CommentsAPIUrlParams = {
16
+ storyId: string;
17
+ useStaging: boolean;
18
+ commentsAPIUrl: string;
19
+ };
20
+ type CommentsAPIUrlTokenParams = CommentsAPIUrlParams & {
21
+ token: string;
22
+ };
23
+ type CommentsAPIUrlQuestionParams = CommentsAPIUrlTokenParams & {
24
+ question: string;
25
+ postAnonymously: boolean;
26
+ };
27
+ type CachedData = {
28
+ updatedComments?: Comment[];
29
+ updateQA?: QA;
30
+ [key: string]: any;
31
+ };
32
+ type UserRolesTransformed = {
33
+ expertView: boolean;
34
+ };
35
+ export declare const nextCommentsApi: import("@reduxjs/toolkit/query/react").Api<import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, {
36
+ getQandAStream: import("@reduxjs/toolkit/query/react").QueryDefinition<CommentsAPIUrlParams & {
37
+ status: Status;
38
+ }, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, CommentsStreamTransformed, "nextCommentsApi">;
39
+ getQandAUpdates: import("@reduxjs/toolkit/query/react").QueryDefinition<CommentsAPIUrlParams, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, CachedData, "nextCommentsApi">;
40
+ getUserRoles: import("@reduxjs/toolkit/query/react").QueryDefinition<CommentsAPIUrlTokenParams, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, UserRolesTransformed, "nextCommentsApi">;
41
+ postQuestion: import("@reduxjs/toolkit/query/react").MutationDefinition<CommentsAPIUrlQuestionParams, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, {
42
+ message: string;
43
+ }, "nextCommentsApi">;
44
+ }, "nextCommentsApi", never, typeof import("@reduxjs/toolkit/query/react").coreModuleName | typeof import("@reduxjs/toolkit/query/react").reactHooksModuleName>;
45
+ export declare const useGetQandAStreamQuery: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseQuery<import("@reduxjs/toolkit/query/react").QueryDefinition<CommentsAPIUrlParams & {
46
+ status: Status;
47
+ }, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, CommentsStreamTransformed, "nextCommentsApi">>, useGetQandAUpdatesQuery: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseQuery<import("@reduxjs/toolkit/query/react").QueryDefinition<CommentsAPIUrlParams, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, CachedData, "nextCommentsApi">>, useGetUserRolesQuery: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseQuery<import("@reduxjs/toolkit/query/react").QueryDefinition<CommentsAPIUrlTokenParams, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, UserRolesTransformed, "nextCommentsApi">>, usePostQuestionMutation: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseMutation<import("@reduxjs/toolkit/query/react").MutationDefinition<CommentsAPIUrlQuestionParams, import("@reduxjs/toolkit/query/react").BaseQueryFn<string | import("@reduxjs/toolkit/query/react").FetchArgs, unknown, import("@reduxjs/toolkit/query/react").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query/react").FetchBaseQueryMeta>, never, {
48
+ message: string;
49
+ }, "nextCommentsApi">>;
50
+ export declare const useUpdatedComments: ({ storyId, useStaging, commentsAPIUrl, }: CommentsAPIUrlParams) => Comment[];
51
+ export declare const useUpdatedQA: ({ storyId, useStaging, commentsAPIUrl, }: CommentsAPIUrlParams) => any;
52
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Middleware, Dispatch, Action } from '@reduxjs/toolkit';
2
+ export declare const rtkQueryErrorLogger: Middleware<{}, any, Dispatch<Action>>;
@@ -0,0 +1,19 @@
1
+ type Outcome = 'success' | 'failure';
2
+ export type CriticalOperation = 'initialisation' | 'expert-load-coral-ui' | 'question-submission' | 'profile-load' | 'stream-load' | 'qa-updates' | 'unmapped-operation';
3
+ declare class Reliability {
4
+ private articleId;
5
+ private testOnly;
6
+ private topLevelNamespace;
7
+ constructor(options: {
8
+ topLevelNamespace: string;
9
+ testOnly?: boolean;
10
+ });
11
+ setArticleId(articleId: string): void;
12
+ dispatch(outcome: Outcome, operation: CriticalOperation, error?: Error | null): void;
13
+ normaliseError(error: unknown): Error;
14
+ failure(operation: CriticalOperation, error: unknown): void;
15
+ success(operation: CriticalOperation): void;
16
+ throw(error?: string): void;
17
+ }
18
+ declare const qandaReliability: Reliability;
19
+ export { qandaReliability, Reliability };
@@ -0,0 +1,14 @@
1
+ import { Slice, CaseReducer, PayloadAction } from '@reduxjs/toolkit';
2
+ export interface ExpertState {
3
+ isExpertFormOpen: boolean;
4
+ expertView?: boolean;
5
+ }
6
+ type ExpertCaseReducers = {
7
+ openExpertForm: CaseReducer<ExpertState>;
8
+ closeExpertForm: CaseReducer<ExpertState>;
9
+ setExpertView: CaseReducer<ExpertState, PayloadAction<boolean | undefined>>;
10
+ };
11
+ export declare const expertSlice: Slice<ExpertState, ExpertCaseReducers, 'expert'>;
12
+ export declare const openExpertForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expert/openExpertForm">, closeExpertForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expert/closeExpertForm">, setExpertView: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<boolean | undefined, "expert/setExpertView">;
13
+ declare const _default: import("@reduxjs/toolkit").Reducer<ExpertState>;
14
+ export default _default;
@@ -0,0 +1,218 @@
1
+ import { ThunkAction, Action, ThunkDispatch } from '@reduxjs/toolkit';
2
+ import { QuestionState } from './questionSlice';
3
+ import { StreamState } from './stream';
4
+ import { UserState } from './user';
5
+ import { ExpertState } from './expertSlice';
6
+ export declare const rootReducer: import("@reduxjs/toolkit").Reducer<import("@reduxjs/toolkit").CombinedState<{
7
+ stream: any;
8
+ question: QuestionState;
9
+ user: any;
10
+ expert: ExpertState;
11
+ nextCommentsApi: import("@reduxjs/toolkit/query").CombinedState<{
12
+ getQandAStream: import("@reduxjs/toolkit/query").QueryDefinition<{
13
+ storyId: string;
14
+ useStaging: boolean;
15
+ commentsAPIUrl: string;
16
+ } & {
17
+ status: import("../types/qa").Status;
18
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, Omit<{
19
+ type: string;
20
+ children?: import("../types/comment").Comment[];
21
+ status?: import("../types/qa").Status;
22
+ startDateTime?: string;
23
+ endDateTime?: string;
24
+ }, "children"> & {
25
+ qandas: import("../types/comment").Comment[];
26
+ }, "nextCommentsApi">;
27
+ getQandAUpdates: import("@reduxjs/toolkit/query").QueryDefinition<{
28
+ storyId: string;
29
+ useStaging: boolean;
30
+ commentsAPIUrl: string;
31
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
32
+ [key: string]: any;
33
+ updatedComments?: import("../types/comment").Comment[];
34
+ updateQA?: import("../types/qa").QA;
35
+ }, "nextCommentsApi">;
36
+ getUserRoles: import("@reduxjs/toolkit/query").QueryDefinition<{
37
+ storyId: string;
38
+ useStaging: boolean;
39
+ commentsAPIUrl: string;
40
+ } & {
41
+ token: string;
42
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
43
+ expertView: boolean;
44
+ }, "nextCommentsApi">;
45
+ postQuestion: import("@reduxjs/toolkit/query").MutationDefinition<{
46
+ storyId: string;
47
+ useStaging: boolean;
48
+ commentsAPIUrl: string;
49
+ } & {
50
+ token: string;
51
+ } & {
52
+ question: string;
53
+ postAnonymously: boolean;
54
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
55
+ message: string;
56
+ }, "nextCommentsApi">;
57
+ }, never, "nextCommentsApi">;
58
+ }>, import("@reduxjs/toolkit").AnyAction>;
59
+ export type RootState = {
60
+ stream: StreamState;
61
+ question: QuestionState;
62
+ user: UserState;
63
+ expert: ExpertState;
64
+ };
65
+ export declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("@reduxjs/toolkit").EmptyObject & {
66
+ stream: any;
67
+ question: QuestionState;
68
+ user: any;
69
+ expert: ExpertState;
70
+ nextCommentsApi: import("@reduxjs/toolkit/query").CombinedState<{
71
+ getQandAStream: import("@reduxjs/toolkit/query").QueryDefinition<{
72
+ storyId: string;
73
+ useStaging: boolean;
74
+ commentsAPIUrl: string;
75
+ } & {
76
+ status: import("../types/qa").Status;
77
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, Omit<{
78
+ type: string;
79
+ children?: import("../types/comment").Comment[];
80
+ status?: import("../types/qa").Status;
81
+ startDateTime?: string;
82
+ endDateTime?: string;
83
+ }, "children"> & {
84
+ qandas: import("../types/comment").Comment[];
85
+ }, "nextCommentsApi">;
86
+ getQandAUpdates: import("@reduxjs/toolkit/query").QueryDefinition<{
87
+ storyId: string;
88
+ useStaging: boolean;
89
+ commentsAPIUrl: string;
90
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
91
+ [key: string]: any;
92
+ updatedComments?: import("../types/comment").Comment[];
93
+ updateQA?: import("../types/qa").QA;
94
+ }, "nextCommentsApi">;
95
+ getUserRoles: import("@reduxjs/toolkit/query").QueryDefinition<{
96
+ storyId: string;
97
+ useStaging: boolean;
98
+ commentsAPIUrl: string;
99
+ } & {
100
+ token: string;
101
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
102
+ expertView: boolean;
103
+ }, "nextCommentsApi">;
104
+ postQuestion: import("@reduxjs/toolkit/query").MutationDefinition<{
105
+ storyId: string;
106
+ useStaging: boolean;
107
+ commentsAPIUrl: string;
108
+ } & {
109
+ token: string;
110
+ } & {
111
+ question: string;
112
+ postAnonymously: boolean;
113
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
114
+ message: string;
115
+ }, "nextCommentsApi">;
116
+ }, never, "nextCommentsApi">;
117
+ }, import("@reduxjs/toolkit").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ThunkMiddleware<import("@reduxjs/toolkit").CombinedState<{
118
+ stream: any;
119
+ question: QuestionState;
120
+ user: any;
121
+ expert: ExpertState;
122
+ nextCommentsApi: import("@reduxjs/toolkit/query").CombinedState<{
123
+ getQandAStream: import("@reduxjs/toolkit/query").QueryDefinition<{
124
+ storyId: string;
125
+ useStaging: boolean;
126
+ commentsAPIUrl: string;
127
+ } & {
128
+ status: import("../types/qa").Status;
129
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, Omit<{
130
+ type: string;
131
+ children?: import("../types/comment").Comment[];
132
+ status?: import("../types/qa").Status;
133
+ startDateTime?: string;
134
+ endDateTime?: string;
135
+ }, "children"> & {
136
+ qandas: import("../types/comment").Comment[];
137
+ }, "nextCommentsApi">;
138
+ getQandAUpdates: import("@reduxjs/toolkit/query").QueryDefinition<{
139
+ storyId: string;
140
+ useStaging: boolean;
141
+ commentsAPIUrl: string;
142
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
143
+ [key: string]: any;
144
+ updatedComments?: import("../types/comment").Comment[];
145
+ updateQA?: import("../types/qa").QA;
146
+ }, "nextCommentsApi">;
147
+ getUserRoles: import("@reduxjs/toolkit/query").QueryDefinition<{
148
+ storyId: string;
149
+ useStaging: boolean;
150
+ commentsAPIUrl: string;
151
+ } & {
152
+ token: string;
153
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
154
+ expertView: boolean;
155
+ }, "nextCommentsApi">;
156
+ postQuestion: import("@reduxjs/toolkit/query").MutationDefinition<{
157
+ storyId: string;
158
+ useStaging: boolean;
159
+ commentsAPIUrl: string;
160
+ } & {
161
+ token: string;
162
+ } & {
163
+ question: string;
164
+ postAnonymously: boolean;
165
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
166
+ message: string;
167
+ }, "nextCommentsApi">;
168
+ }, never, "nextCommentsApi">;
169
+ }>, import("@reduxjs/toolkit").AnyAction>, import("@reduxjs/toolkit").Middleware<{}, import("@reduxjs/toolkit/query").RootState<{
170
+ getQandAStream: import("@reduxjs/toolkit/query").QueryDefinition<{
171
+ storyId: string;
172
+ useStaging: boolean;
173
+ commentsAPIUrl: string;
174
+ } & {
175
+ status: import("../types/qa").Status;
176
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, Omit<{
177
+ type: string;
178
+ children?: import("../types/comment").Comment[];
179
+ status?: import("../types/qa").Status;
180
+ startDateTime?: string;
181
+ endDateTime?: string;
182
+ }, "children"> & {
183
+ qandas: import("../types/comment").Comment[];
184
+ }, "nextCommentsApi">;
185
+ getQandAUpdates: import("@reduxjs/toolkit/query").QueryDefinition<{
186
+ storyId: string;
187
+ useStaging: boolean;
188
+ commentsAPIUrl: string;
189
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
190
+ [key: string]: any;
191
+ updatedComments?: import("../types/comment").Comment[];
192
+ updateQA?: import("../types/qa").QA;
193
+ }, "nextCommentsApi">;
194
+ getUserRoles: import("@reduxjs/toolkit/query").QueryDefinition<{
195
+ storyId: string;
196
+ useStaging: boolean;
197
+ commentsAPIUrl: string;
198
+ } & {
199
+ token: string;
200
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
201
+ expertView: boolean;
202
+ }, "nextCommentsApi">;
203
+ postQuestion: import("@reduxjs/toolkit/query").MutationDefinition<{
204
+ storyId: string;
205
+ useStaging: boolean;
206
+ commentsAPIUrl: string;
207
+ } & {
208
+ token: string;
209
+ } & {
210
+ question: string;
211
+ postAnonymously: boolean;
212
+ }, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, {
213
+ message: string;
214
+ }, "nextCommentsApi">;
215
+ }, string, "nextCommentsApi">, ThunkDispatch<any, any, import("@reduxjs/toolkit").AnyAction>>, import("@reduxjs/toolkit").Middleware<{}, any, import("@reduxjs/toolkit").Dispatch<Action<any>>>]>>;
216
+ export type AnyAction = typeof store.dispatch;
217
+ export type AppDispatch = ThunkDispatch<RootState, unknown, any>;
218
+ export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, RootState, unknown, Action<string>>;
@@ -0,0 +1,16 @@
1
+ import { PayloadAction, Slice, CaseReducer } from '@reduxjs/toolkit';
2
+ export interface QuestionState {
3
+ isFormOpen: boolean;
4
+ question: string;
5
+ displayNameError: string | null;
6
+ }
7
+ type ExpertCaseReducers = {
8
+ openForm: CaseReducer<QuestionState>;
9
+ closeForm: CaseReducer<QuestionState>;
10
+ updateQuestion: CaseReducer<QuestionState, PayloadAction<string>>;
11
+ updateDisplayNameError: CaseReducer<QuestionState, PayloadAction<string | null>>;
12
+ };
13
+ export declare const questionSlice: Slice<QuestionState, ExpertCaseReducers, 'question'>;
14
+ export declare const openForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"question/openForm">, closeForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"question/closeForm">, updateQuestion: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "question/updateQuestion">, updateDisplayNameError: import("@reduxjs/toolkit").ActionCreatorWithPayload<string | null, "question/updateDisplayNameError">;
15
+ declare const _default: import("@reduxjs/toolkit").Reducer<QuestionState>;
16
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { Slice } from '@reduxjs/toolkit';
2
+ export type StreamState = {
3
+ latestAnsweredQuestionId: string;
4
+ };
5
+ export declare const initialState: StreamState;
6
+ export declare const stream: Slice;
7
+ export declare const setLatestAnsweredQuestionId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, `${string}/${string}`> | import("@reduxjs/toolkit").ActionCreatorWithoutPayload<`${string}/${string}`>;
@@ -0,0 +1,3 @@
1
+ import { AppDispatch } from './index';
2
+ import type { Comment } from '../types/comment';
3
+ export declare const updateComments: (dispatch: AppDispatch, updatedComments: Comment[], storyId: string, useStaging: boolean, commentsAPIUrl: string) => void;
@@ -0,0 +1,26 @@
1
+ import { Slice } from '@reduxjs/toolkit';
2
+ export type UserDetails = {
3
+ token: string;
4
+ displayName: string;
5
+ isRegistered?: boolean;
6
+ isTrialist?: boolean;
7
+ isSubscribed?: boolean;
8
+ };
9
+ export type UserState = {
10
+ profile: UserDetails;
11
+ } & AsyncOperation;
12
+ export declare const getUserProfile: import("@reduxjs/toolkit").AsyncThunk<UserDetails, {
13
+ useStaging: boolean;
14
+ displayName?: string;
15
+ commentsAPIUrl: string;
16
+ }, {
17
+ state?: unknown;
18
+ dispatch?: import("@reduxjs/toolkit").Dispatch;
19
+ extra?: unknown;
20
+ rejectValue?: unknown;
21
+ serializedErrorType?: unknown;
22
+ pendingMeta?: unknown;
23
+ fulfilledMeta?: unknown;
24
+ rejectedMeta?: unknown;
25
+ }>;
26
+ export declare const user: Slice;
@@ -0,0 +1,6 @@
1
+ declare const _default: ({ useStaging, displayName, commentsAPIUrl, }: {
2
+ useStaging: boolean;
3
+ displayName: string;
4
+ commentsAPIUrl?: string;
5
+ }) => Promise<import("@financial-times/o-comments").AuthResponse>;
6
+ export default _default;