@oanda/labs-ticker-tape-widget 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/TickerTapeWidget/Main.js +87 -0
  4. package/dist/main/TickerTapeWidget/Main.js.map +1 -0
  5. package/dist/main/TickerTapeWidget/TickerTapeWidget.js +56 -0
  6. package/dist/main/TickerTapeWidget/TickerTapeWidget.js.map +1 -0
  7. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +46 -0
  8. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
  9. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/index.js +28 -0
  10. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/index.js.map +1 -0
  11. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/types.js +6 -0
  12. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/types.js.map +1 -0
  13. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/utils.js +25 -0
  14. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
  15. package/dist/main/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js +42 -0
  16. package/dist/main/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
  17. package/dist/main/TickerTapeWidget/components/LineChartWithData/index.js +17 -0
  18. package/dist/main/TickerTapeWidget/components/LineChartWithData/index.js.map +1 -0
  19. package/dist/main/TickerTapeWidget/components/LineChartWithData/types.js +6 -0
  20. package/dist/main/TickerTapeWidget/components/LineChartWithData/types.js.map +1 -0
  21. package/dist/main/TickerTapeWidget/constant.js +8 -0
  22. package/dist/main/TickerTapeWidget/constant.js.map +1 -0
  23. package/dist/main/TickerTapeWidget/index.js +28 -0
  24. package/dist/main/TickerTapeWidget/index.js.map +1 -0
  25. package/dist/main/TickerTapeWidget/render.js +55 -0
  26. package/dist/main/TickerTapeWidget/render.js.map +1 -0
  27. package/dist/main/TickerTapeWidget/types.js +20 -0
  28. package/dist/main/TickerTapeWidget/types.js.map +1 -0
  29. package/dist/main/TickerTapeWidget/utils.js +43 -0
  30. package/dist/main/TickerTapeWidget/utils.js.map +1 -0
  31. package/dist/main/gql/getInstrumentsChart.js +16 -0
  32. package/dist/main/gql/getInstrumentsChart.js.map +1 -0
  33. package/dist/main/gql/types/fragment-masking.js +23 -0
  34. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  35. package/dist/main/gql/types/gql.js +17 -0
  36. package/dist/main/gql/types/gql.js.map +1 -0
  37. package/dist/main/gql/types/graphql.js +326 -0
  38. package/dist/main/gql/types/graphql.js.map +1 -0
  39. package/dist/main/gql/types/index.js +28 -0
  40. package/dist/main/gql/types/index.js.map +1 -0
  41. package/dist/main/gql/validateInstruments.js +16 -0
  42. package/dist/main/gql/validateInstruments.js.map +1 -0
  43. package/dist/main/index.js +17 -0
  44. package/dist/main/index.js.map +1 -0
  45. package/dist/main/translations/index.js +27 -0
  46. package/dist/main/translations/index.js.map +1 -0
  47. package/dist/main/translations/sources/en.json +4 -0
  48. package/dist/main/translations/sources/es.json +4 -0
  49. package/dist/main/translations/sources/th.json +4 -0
  50. package/dist/main/translations/sources/zh_TW.json +4 -0
  51. package/dist/main/translations/translations.js +11 -0
  52. package/dist/main/translations/translations.js.map +1 -0
  53. package/dist/module/TickerTapeWidget/Main.js +78 -0
  54. package/dist/module/TickerTapeWidget/Main.js.map +1 -0
  55. package/dist/module/TickerTapeWidget/TickerTapeWidget.js +49 -0
  56. package/dist/module/TickerTapeWidget/TickerTapeWidget.js.map +1 -0
  57. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +38 -0
  58. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
  59. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/index.js +3 -0
  60. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/index.js.map +1 -0
  61. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/types.js +2 -0
  62. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/types.js.map +1 -0
  63. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/utils.js +18 -0
  64. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
  65. package/dist/module/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js +35 -0
  66. package/dist/module/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
  67. package/dist/module/TickerTapeWidget/components/LineChartWithData/index.js +2 -0
  68. package/dist/module/TickerTapeWidget/components/LineChartWithData/index.js.map +1 -0
  69. package/dist/module/TickerTapeWidget/components/LineChartWithData/types.js +2 -0
  70. package/dist/module/TickerTapeWidget/components/LineChartWithData/types.js.map +1 -0
  71. package/dist/module/TickerTapeWidget/constant.js +3 -0
  72. package/dist/module/TickerTapeWidget/constant.js.map +1 -0
  73. package/dist/module/TickerTapeWidget/index.js +3 -0
  74. package/dist/module/TickerTapeWidget/index.js.map +1 -0
  75. package/dist/module/TickerTapeWidget/render.js +52 -0
  76. package/dist/module/TickerTapeWidget/render.js.map +1 -0
  77. package/dist/module/TickerTapeWidget/types.js +3 -0
  78. package/dist/module/TickerTapeWidget/types.js.map +1 -0
  79. package/dist/module/TickerTapeWidget/utils.js +36 -0
  80. package/dist/module/TickerTapeWidget/utils.js.map +1 -0
  81. package/dist/module/gql/getInstrumentsChart.js +10 -0
  82. package/dist/module/gql/getInstrumentsChart.js.map +1 -0
  83. package/dist/module/gql/types/fragment-masking.js +15 -0
  84. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  85. package/dist/module/gql/types/gql.js +9 -0
  86. package/dist/module/gql/types/gql.js.map +1 -0
  87. package/dist/module/gql/types/graphql.js +320 -0
  88. package/dist/module/gql/types/graphql.js.map +1 -0
  89. package/dist/module/gql/types/index.js +3 -0
  90. package/dist/module/gql/types/index.js.map +1 -0
  91. package/dist/module/gql/validateInstruments.js +10 -0
  92. package/dist/module/gql/validateInstruments.js.map +1 -0
  93. package/dist/module/index.js +2 -0
  94. package/dist/module/index.js.map +1 -0
  95. package/dist/module/translations/index.js +20 -0
  96. package/dist/module/translations/index.js.map +1 -0
  97. package/dist/module/translations/sources/en.json +4 -0
  98. package/dist/module/translations/sources/es.json +4 -0
  99. package/dist/module/translations/sources/th.json +4 -0
  100. package/dist/module/translations/sources/zh_TW.json +4 -0
  101. package/dist/module/translations/translations.js +5 -0
  102. package/dist/module/translations/translations.js.map +1 -0
  103. package/dist/types/TickerTapeWidget/Main.d.ts +4 -0
  104. package/dist/types/TickerTapeWidget/TickerTapeWidget.d.ts +4 -0
  105. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +4 -0
  106. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/index.d.ts +2 -0
  107. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/types.d.ts +9 -0
  108. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/utils.d.ts +3 -0
  109. package/dist/types/TickerTapeWidget/components/LineChartWithData/LineChartWithData.d.ts +4 -0
  110. package/dist/types/TickerTapeWidget/components/LineChartWithData/index.d.ts +1 -0
  111. package/dist/types/TickerTapeWidget/components/LineChartWithData/types.d.ts +8 -0
  112. package/dist/types/TickerTapeWidget/constant.d.ts +2 -0
  113. package/dist/types/TickerTapeWidget/index.d.ts +2 -0
  114. package/dist/types/TickerTapeWidget/render.d.ts +1 -0
  115. package/dist/types/TickerTapeWidget/types.d.ts +21 -0
  116. package/dist/types/TickerTapeWidget/utils.d.ts +11 -0
  117. package/dist/types/gql/getInstrumentsChart.d.ts +1 -0
  118. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  119. package/dist/types/gql/types/gql.d.ts +45 -0
  120. package/dist/types/gql/types/graphql.d.ts +397 -0
  121. package/dist/types/gql/types/index.d.ts +2 -0
  122. package/dist/types/gql/validateInstruments.d.ts +1 -0
  123. package/dist/types/index.d.ts +1 -0
  124. package/dist/types/translations/index.d.ts +4 -0
  125. package/dist/types/translations/translations.d.ts +4 -0
  126. package/index.ts +1 -0
  127. package/lokalise.config.json +18 -0
  128. package/package.json +26 -0
  129. package/src/TickerTapeWidget/Main.tsx +91 -0
  130. package/src/TickerTapeWidget/TickerTapeWidget.tsx +57 -0
  131. package/src/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +43 -0
  132. package/src/TickerTapeWidget/components/InstrumentRateWithChart/index.ts +2 -0
  133. package/src/TickerTapeWidget/components/InstrumentRateWithChart/types.ts +10 -0
  134. package/src/TickerTapeWidget/components/InstrumentRateWithChart/utils.ts +25 -0
  135. package/src/TickerTapeWidget/components/LineChartWithData/LineChartWithData.tsx +43 -0
  136. package/src/TickerTapeWidget/components/LineChartWithData/index.ts +1 -0
  137. package/src/TickerTapeWidget/components/LineChartWithData/types.tsx +9 -0
  138. package/src/TickerTapeWidget/constant.ts +5 -0
  139. package/src/TickerTapeWidget/index.ts +2 -0
  140. package/src/TickerTapeWidget/render.tsx +51 -0
  141. package/src/TickerTapeWidget/types.tsx +24 -0
  142. package/src/TickerTapeWidget/utils.ts +48 -0
  143. package/src/gql/getInstrumentsChart.ts +10 -0
  144. package/src/gql/types/fragment-masking.ts +66 -0
  145. package/src/gql/types/gql.ts +47 -0
  146. package/src/gql/types/graphql.ts +432 -0
  147. package/src/gql/types/index.ts +2 -0
  148. package/src/gql/validateInstruments.ts +10 -0
  149. package/src/index.ts +1 -0
  150. package/src/translations/index.ts +17 -0
  151. package/src/translations/sources/en.json +4 -0
  152. package/src/translations/sources/es.json +4 -0
  153. package/src/translations/sources/th.json +4 -0
  154. package/src/translations/sources/zh_TW.json +4 -0
  155. package/src/translations/translations.ts +4 -0
  156. package/test/LineChartWithData.test.tsx +164 -0
  157. package/test/Main.test.tsx +27 -0
  158. package/test/components/InstrumentRateWithChart.test.tsx +62 -0
  159. package/test/components/utils.test.ts +13 -0
  160. package/test/mocks.ts +52 -0
  161. package/tsconfig.types.json +12 -0
@@ -0,0 +1,25 @@
1
+ import { lightTheme, darkTheme } from '@oanda/labs-widget-common';
2
+
3
+ const getColorIndicator = (dailyChange?: string) => {
4
+ const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));
5
+
6
+ return Math.sign(numberValue);
7
+ };
8
+
9
+ const getChartColor = (indicator?: number, isDarkMode?: boolean) => {
10
+ const theme = isDarkMode ? darkTheme : lightTheme;
11
+
12
+ switch (indicator) {
13
+ case 1:
14
+ return theme.textOk;
15
+ case -1:
16
+ return theme.textDanger;
17
+ default:
18
+ return theme.textDisabled;
19
+ }
20
+ };
21
+
22
+ export {
23
+ getColorIndicator,
24
+ getChartColor,
25
+ };
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { useQuery } from '@apollo/client';
3
+ import { LineChart } from '@oanda/labs-widget-common';
4
+ import { LineChartWithDataProps } from './types';
5
+ import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
6
+ import { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';
7
+
8
+ const LineChartWithData = ({
9
+ record,
10
+ isLoading,
11
+ division,
12
+ color,
13
+ }: LineChartWithDataProps) => {
14
+ const { loading, data } = useQuery<
15
+ GetInstrumentsChartQuery,
16
+ GetInstrumentsChartQueryVariables
17
+ >(getInstrumentsChart, {
18
+ variables: {
19
+ instruments: [record.instrument],
20
+ division,
21
+ },
22
+ fetchPolicy: 'network-only',
23
+ skip: !record.instrument,
24
+ });
25
+
26
+ const showChart = isLoading || loading;
27
+ const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
28
+
29
+ return (
30
+ <div className="lw-relative">
31
+ {!showChart ? (
32
+ <div className="lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center">
33
+ <LineChart
34
+ color={color}
35
+ data={chart}
36
+ />
37
+ </div>
38
+ ) : null}
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export { LineChartWithData };
@@ -0,0 +1 @@
1
+ export * from './LineChartWithData';
@@ -0,0 +1,9 @@
1
+ import { DataRecord } from '@oanda/labs-widget-common';
2
+ import { Division } from '../../../gql/types/graphql';
3
+
4
+ export interface LineChartWithDataProps {
5
+ record: DataRecord;
6
+ isLoading: boolean;
7
+ division: Division;
8
+ color: string;
9
+ }
@@ -0,0 +1,5 @@
1
+ const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
2
+
3
+ export {
4
+ INSTRUMENT_TOOLTIP_ID,
5
+ };
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './TickerTapeWidget';
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';
4
+ import { TickerTapeWidget } from './TickerTapeWidget';
5
+ import { Division } from '../gql/types/graphql';
6
+
7
+ const {
8
+ graphqlUrl,
9
+ liveRatesUrl,
10
+ } = window.widgetsConfig || {};
11
+
12
+ const dataTickerTapeParamsElements = document.querySelectorAll('div[data-ticker-tape-params]');
13
+
14
+ dataTickerTapeParamsElements.forEach((element) => {
15
+ const root = createRoot(element);
16
+ const params = element.getAttribute('data-ticker-tape-params');
17
+ const mode = element.getAttribute('data-mode');
18
+ const {
19
+ instruments, division, locale, size,
20
+ } = JSON.parse(params as string);
21
+
22
+ const isParamError = validateToolParams({
23
+ division, locale, graphqlUrl, liveRatesUrl, instruments,
24
+ }, [{
25
+ name: 'locale',
26
+ valueCheck: (value) => validateLocale(value),
27
+ }, {
28
+ name: 'division',
29
+ valueCheck: (value) => Object.values(Division).includes(value),
30
+ }, {
31
+ name: 'instruments',
32
+ valueCheck: (value) => value.length > 0 && value.length <= 10,
33
+ }, {
34
+ name: 'graphqlUrl',
35
+ }, {
36
+ name: 'liveRatesUrl',
37
+ }]);
38
+
39
+ root.render(
40
+ <TickerTapeWidget
41
+ graphqlUrl={graphqlUrl}
42
+ liveRatesUrl={liveRatesUrl}
43
+ division={division}
44
+ instruments={instruments}
45
+ locale={locale}
46
+ theme={mode as Theme}
47
+ isParamError={isParamError}
48
+ size={size}
49
+ />,
50
+ );
51
+ });
@@ -0,0 +1,24 @@
1
+ import { Locale } from '@oanda/mono-i18n';
2
+ import { Theme } from '@oanda/labs-widget-common';
3
+ import { Division } from '../gql/types/graphql';
4
+
5
+ export { Locale } from '@oanda/mono-i18n';
6
+ export { Division } from '../gql/types/graphql';
7
+
8
+ export interface TickerTapeConfig {
9
+ graphqlUrl: string;
10
+ division: Division;
11
+ liveRatesUrl: string;
12
+ instruments: string[];
13
+ locale: Locale;
14
+ theme?: Theme;
15
+ isParamError?: boolean;
16
+ removePadding?: boolean;
17
+ size?: 'compact' | 'full' | 'fullWithChart';
18
+ }
19
+
20
+ export interface MainProps {
21
+ instruments: string[];
22
+ division: Division;
23
+ size?: 'compact' | 'full' | 'fullWithChart'
24
+ }
@@ -0,0 +1,48 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { DataRecord, LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';
3
+ import { ValidateInstrumentsQuery } from '../gql/types/graphql';
4
+
5
+ const getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({
6
+ instrument: item?.name || '',
7
+ displayName: item?.displayName || '',
8
+ }));
9
+
10
+ const useRecords = (
11
+ record: DataRecord,
12
+ target: EventTarget | null,
13
+ ) => {
14
+ const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
15
+ displayName: record.displayName,
16
+ instrument: record.instrument,
17
+ sentiment: record.sentiment,
18
+ });
19
+ const [error, setError] = useState<LiveRatesErrorMessage | null>(null);
20
+
21
+ const { update, error: liveRatesError } = useLiveRatesMessage(
22
+ record.instrument,
23
+ target,
24
+ );
25
+
26
+ useEffect(() => {
27
+ setUpdatedRecord({
28
+ displayName: record.displayName,
29
+ instrument: record.instrument,
30
+ buy: update?.bid,
31
+ buyPriceMovement: update?.bidPriceMovement,
32
+ dailyPercentChange: update?.dailyPercentChangeFromOpen,
33
+ dailyPipsChange: update?.dailyPipsChangeFromOpen,
34
+ displayPrecision: update?.displayPrecision,
35
+ });
36
+ setError(liveRatesError);
37
+ }, [update, record, liveRatesError]);
38
+
39
+ return {
40
+ updatedRecord,
41
+ error,
42
+ };
43
+ };
44
+
45
+ export {
46
+ getRecords,
47
+ useRecords,
48
+ };
@@ -0,0 +1,10 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const getInstrumentsChart = gql`
4
+ query GetInstrumentsChart($instruments: [String!], $division: Division) {
5
+ topicalInstrumentsCharts(instruments: $instruments, division: $division) {
6
+ name
7
+ chart
8
+ }
9
+ }
10
+ `;
@@ -0,0 +1,66 @@
1
+ import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { FragmentDefinitionNode } from 'graphql';
3
+ import { Incremental } from './graphql';
4
+
5
+
6
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
7
+ infer TType,
8
+ any
9
+ >
10
+ ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
11
+ ? TKey extends string
12
+ ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
13
+ : never
14
+ : never
15
+ : never;
16
+
17
+ // return non-nullable if `fragmentType` is non-nullable
18
+ export function useFragment<TType>(
19
+ _documentNode: DocumentTypeDecoration<TType, any>,
20
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
21
+ ): TType;
22
+ // return nullable if `fragmentType` is nullable
23
+ export function useFragment<TType>(
24
+ _documentNode: DocumentTypeDecoration<TType, any>,
25
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
26
+ ): TType | null | undefined;
27
+ // return array of non-nullable if `fragmentType` is array of non-nullable
28
+ export function useFragment<TType>(
29
+ _documentNode: DocumentTypeDecoration<TType, any>,
30
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
31
+ ): ReadonlyArray<TType>;
32
+ // return array of nullable if `fragmentType` is array of nullable
33
+ export function useFragment<TType>(
34
+ _documentNode: DocumentTypeDecoration<TType, any>,
35
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
36
+ ): ReadonlyArray<TType> | null | undefined;
37
+ export function useFragment<TType>(
38
+ _documentNode: DocumentTypeDecoration<TType, any>,
39
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
40
+ ): TType | ReadonlyArray<TType> | null | undefined {
41
+ return fragmentType as any;
42
+ }
43
+
44
+
45
+ export function makeFragmentData<
46
+ F extends DocumentTypeDecoration<any, any>,
47
+ FT extends ResultOf<F>
48
+ >(data: FT, _fragment: F): FragmentType<F> {
49
+ return data as FragmentType<F>;
50
+ }
51
+ export function isFragmentReady<TQuery, TFrag>(
52
+ queryNode: DocumentTypeDecoration<TQuery, any>,
53
+ fragmentNode: TypedDocumentNode<TFrag>,
54
+ data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
55
+ ): data is FragmentType<typeof fragmentNode> {
56
+ const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
57
+ ?.deferredFields;
58
+
59
+ if (!deferredFields) return true;
60
+
61
+ const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;
62
+ const fragName = fragDef?.name?.value;
63
+
64
+ const fields = (fragName && deferredFields[fragName]) || [];
65
+ return fields.length > 0 && fields.every(field => data && field in data);
66
+ }
@@ -0,0 +1,47 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql';
3
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
4
+
5
+ /**
6
+ * Map of all GraphQL operations in the project.
7
+ *
8
+ * This map has several performance disadvantages:
9
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
10
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
11
+ * 3. It does not support dead code elimination, so it will add unused operations.
12
+ *
13
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
14
+ */
15
+ const documents = {
16
+ "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n": types.GetInstrumentsChartDocument,
17
+ "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": types.ValidateInstrumentsDocument,
18
+ };
19
+
20
+ /**
21
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
22
+ *
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
27
+ * ```
28
+ *
29
+ * The query argument is unknown!
30
+ * Please regenerate the types.
31
+ */
32
+ export function graphql(source: string): unknown;
33
+
34
+ /**
35
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
36
+ */
37
+ export function graphql(source: "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n"): (typeof documents)["\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n"];
38
+ /**
39
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
40
+ */
41
+ export function graphql(source: "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"): (typeof documents)["\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"];
42
+
43
+ export function graphql(source: string) {
44
+ return (documents as any)[source] ?? {};
45
+ }
46
+
47
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;