@oanda/labs-currency-cross-table 1.0.6 → 1.0.7

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 (85) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +12 -4
  4. package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
  5. package/dist/main/CurrencyCrossTableWidget/Main.js +11 -9
  6. package/dist/main/CurrencyCrossTableWidget/Main.js.map +1 -1
  7. package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js +2 -1
  8. package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
  9. package/dist/main/CurrencyCrossTableWidget/components/CellValidationWrapper.js +51 -0
  10. package/dist/main/CurrencyCrossTableWidget/components/CellValidationWrapper.js.map +1 -0
  11. package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js +19 -11
  12. package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
  13. package/dist/main/CurrencyCrossTableWidget/components/types.js.map +1 -1
  14. package/dist/main/CurrencyCrossTableWidget/render.js +7 -2
  15. package/dist/main/CurrencyCrossTableWidget/render.js.map +1 -1
  16. package/dist/main/CurrencyCrossTableWidget/types.js +0 -13
  17. package/dist/main/CurrencyCrossTableWidget/types.js.map +1 -1
  18. package/dist/main/CurrencyCrossTableWidget/utils.js +13 -30
  19. package/dist/main/CurrencyCrossTableWidget/utils.js.map +1 -1
  20. package/dist/main/gql/types/fragment-masking.js +23 -0
  21. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  22. package/dist/main/gql/types/gql.js +16 -0
  23. package/dist/main/gql/types/gql.js.map +1 -0
  24. package/dist/main/gql/types/graphql.js +223 -0
  25. package/dist/main/gql/types/graphql.js.map +1 -0
  26. package/dist/main/gql/types/index.js +28 -0
  27. package/dist/main/gql/types/index.js.map +1 -0
  28. package/dist/main/gql/validateInstruments.js +16 -0
  29. package/dist/main/gql/validateInstruments.js.map +1 -0
  30. package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +10 -2
  31. package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
  32. package/dist/module/CurrencyCrossTableWidget/Main.js +13 -11
  33. package/dist/module/CurrencyCrossTableWidget/Main.js.map +1 -1
  34. package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js +2 -1
  35. package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
  36. package/dist/module/CurrencyCrossTableWidget/components/CellValidationWrapper.js +44 -0
  37. package/dist/module/CurrencyCrossTableWidget/components/CellValidationWrapper.js.map +1 -0
  38. package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js +20 -12
  39. package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
  40. package/dist/module/CurrencyCrossTableWidget/components/types.js.map +1 -1
  41. package/dist/module/CurrencyCrossTableWidget/render.js +6 -1
  42. package/dist/module/CurrencyCrossTableWidget/render.js.map +1 -1
  43. package/dist/module/CurrencyCrossTableWidget/types.js +0 -12
  44. package/dist/module/CurrencyCrossTableWidget/types.js.map +1 -1
  45. package/dist/module/CurrencyCrossTableWidget/utils.js +10 -29
  46. package/dist/module/CurrencyCrossTableWidget/utils.js.map +1 -1
  47. package/dist/module/gql/types/fragment-masking.js +15 -0
  48. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  49. package/dist/module/gql/types/gql.js +8 -0
  50. package/dist/module/gql/types/gql.js.map +1 -0
  51. package/dist/module/gql/types/graphql.js +217 -0
  52. package/dist/module/gql/types/graphql.js.map +1 -0
  53. package/dist/module/gql/types/index.js +3 -0
  54. package/dist/module/gql/types/index.js.map +1 -0
  55. package/dist/module/gql/validateInstruments.js +10 -0
  56. package/dist/module/gql/validateInstruments.js.map +1 -0
  57. package/dist/types/CurrencyCrossTableWidget/CurrencyCrossTableWidget.d.ts +1 -1
  58. package/dist/types/CurrencyCrossTableWidget/Main.d.ts +1 -1
  59. package/dist/types/CurrencyCrossTableWidget/components/CellValidationWrapper.d.ts +4 -0
  60. package/dist/types/CurrencyCrossTableWidget/components/CellWithData.d.ts +1 -1
  61. package/dist/types/CurrencyCrossTableWidget/components/types.d.ts +15 -1
  62. package/dist/types/CurrencyCrossTableWidget/types.d.ts +3 -11
  63. package/dist/types/CurrencyCrossTableWidget/utils.d.ts +5 -6
  64. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  65. package/dist/types/gql/types/gql.d.ts +37 -0
  66. package/dist/types/gql/types/graphql.d.ts +384 -0
  67. package/dist/types/gql/types/index.d.ts +2 -0
  68. package/dist/types/gql/validateInstruments.d.ts +1 -0
  69. package/package.json +12 -4
  70. package/src/CurrencyCrossTableWidget/CurrencyCrossTableWidget.tsx +16 -6
  71. package/src/CurrencyCrossTableWidget/Main.tsx +19 -13
  72. package/src/CurrencyCrossTableWidget/ValidationWrapper.tsx +1 -0
  73. package/src/CurrencyCrossTableWidget/components/CellValidationWrapper.tsx +51 -0
  74. package/src/CurrencyCrossTableWidget/components/CellWithData.tsx +30 -14
  75. package/src/CurrencyCrossTableWidget/components/types.ts +15 -1
  76. package/src/CurrencyCrossTableWidget/render.tsx +6 -2
  77. package/src/CurrencyCrossTableWidget/types.tsx +3 -12
  78. package/src/CurrencyCrossTableWidget/utils.ts +17 -37
  79. package/src/gql/types/fragment-masking.ts +66 -0
  80. package/src/gql/types/gql.ts +42 -0
  81. package/src/gql/types/graphql.ts +423 -0
  82. package/src/gql/types/index.ts +2 -0
  83. package/src/gql/validateInstruments.ts +10 -0
  84. package/test/Main.test.tsx +12 -6
  85. package/test/mocks.ts +225 -0
@@ -1,9 +1,23 @@
1
1
  import { DataRecord, LoaderSize } from '@oanda/labs-widget-common';
2
+ import { Division } from '../../gql/types/graphql';
3
+ export interface CellValidationWrapperProps {
4
+ currency: string;
5
+ pair: string;
6
+ instrument: string;
7
+ target: EventTarget | null;
8
+ additionalBorderBottom?: boolean;
9
+ division: Division;
10
+ setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;
11
+ setSelectedPair: React.Dispatch<React.SetStateAction<string>>;
12
+ }
2
13
  export interface CellWithDataProps {
3
- loading: boolean;
14
+ currency: string;
15
+ pair: string;
16
+ instrumentForCalculations: string;
4
17
  record: DataRecord;
5
18
  target: EventTarget | null;
6
19
  additionalBorderBottom?: boolean;
20
+ division: Division;
7
21
  setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;
8
22
  setSelectedPair: React.Dispatch<React.SetStateAction<string>>;
9
23
  }
@@ -1,19 +1,10 @@
1
1
  import { Locale } from '@oanda/mono-i18n';
2
2
  import { Theme } from '@oanda/labs-widget-common';
3
+ import { Division } from '../gql/types/graphql';
3
4
  export { Locale } from '@oanda/mono-i18n';
4
- export declare enum Division {
5
- Oap = "OAP",
6
- Oau = "OAU",
7
- Oc = "OC",
8
- Ocan = "OCAN",
9
- Oel = "OEL",
10
- Ogm = "OGM",
11
- Oj = "OJ",
12
- Opt = "OPT",
13
- Otms = "OTMS"
14
- }
15
5
  export interface CurrencyCrossTableConfig {
16
6
  division: Division;
7
+ graphqlUrl: string;
17
8
  liveRatesUrl: string;
18
9
  currencies: string[];
19
10
  locale: Locale;
@@ -29,4 +20,5 @@ export interface ValidationWrapperProps {
29
20
  export interface MainProps {
30
21
  currencies: string[];
31
22
  instruments: string[];
23
+ division: Division;
32
24
  }
@@ -1,8 +1,7 @@
1
- import { DataRecord, LiveRatesErrorMessage } from '@oanda/labs-widget-common';
1
+ import { Division } from '../gql/types/graphql';
2
2
  declare const validCurrencies: (currencies: string[]) => boolean;
3
+ declare const divisionMapper: (division: Division) => "" | "_";
3
4
  declare const currenciesToInstruments: (currencies: string[], division: any) => string[];
4
- declare const useRecords: (record: DataRecord, target: EventTarget | null) => {
5
- updatedRecord: DataRecord;
6
- error: LiveRatesErrorMessage | null;
7
- };
8
- export { validCurrencies, currenciesToInstruments, useRecords, };
5
+ declare const getPriceMovement: (priceMovement: number | undefined, isReversed: boolean) => number;
6
+ declare const getBuyPrice: (price: number | undefined, isReversed: boolean) => number;
7
+ export { validCurrencies, currenciesToInstruments, divisionMapper, getPriceMovement, getBuyPrice, };
@@ -0,0 +1,15 @@
1
+ import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { Incremental } from './graphql';
3
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<infer TType, any> ? [TType] extends [{
4
+ ' $fragmentName'?: infer TKey;
5
+ }] ? TKey extends string ? {
6
+ ' $fragmentRefs'?: {
7
+ [key in TKey]: TType;
8
+ };
9
+ } : never : never : never;
10
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>): TType;
11
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined): TType | null | undefined;
12
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>): ReadonlyArray<TType>;
13
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): ReadonlyArray<TType> | null | undefined;
14
+ export declare function makeFragmentData<F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F>>(data: FT, _fragment: F): FragmentType<F>;
15
+ export declare function isFragmentReady<TQuery, TFrag>(queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined): data is FragmentType<typeof fragmentNode>;
@@ -0,0 +1,37 @@
1
+ import * as types from './graphql';
2
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
+ /**
4
+ * Map of all GraphQL operations in the project.
5
+ *
6
+ * This map has several performance disadvantages:
7
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
8
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
9
+ * 3. It does not support dead code elimination, so it will add unused operations.
10
+ *
11
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
12
+ */
13
+ declare const documents: {
14
+ "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": DocumentNode<types.ValidateInstrumentsQuery, types.Exact<{
15
+ instruments: Array<types.InputMaybe<types.Scalars["String"]["input"]>> | types.InputMaybe<types.Scalars["String"]["input"]>;
16
+ division?: types.InputMaybe<types.Division>;
17
+ }>>;
18
+ };
19
+ /**
20
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
21
+ *
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
26
+ * ```
27
+ *
28
+ * The query argument is unknown!
29
+ * Please regenerate the types.
30
+ */
31
+ export declare function graphql(source: string): unknown;
32
+ /**
33
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
34
+ */
35
+ export declare 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"];
36
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
37
+ export {};
@@ -0,0 +1,384 @@
1
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
+ export type Maybe<T> = T | null;
3
+ export type InputMaybe<T> = Maybe<T>;
4
+ export type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ export type MakeEmpty<T extends {
16
+ [key: string]: unknown;
17
+ }, K extends keyof T> = {
18
+ [_ in K]?: never;
19
+ };
20
+ export type Incremental<T> = T | {
21
+ [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
22
+ };
23
+ /** All built-in and custom scalars, mapped to their actual values */
24
+ export type Scalars = {
25
+ ID: {
26
+ input: string;
27
+ output: string;
28
+ };
29
+ String: {
30
+ input: string;
31
+ output: string;
32
+ };
33
+ Boolean: {
34
+ input: boolean;
35
+ output: boolean;
36
+ };
37
+ Int: {
38
+ input: number;
39
+ output: number;
40
+ };
41
+ Float: {
42
+ input: number;
43
+ output: number;
44
+ };
45
+ };
46
+ export type AssetClass = {
47
+ __typename?: 'AssetClass';
48
+ instruments: Array<Instrument>;
49
+ name: Scalars['String']['output'];
50
+ };
51
+ export declare enum AssetClassName {
52
+ Commodities = "COMMODITIES",
53
+ Cryptocurrency = "CRYPTOCURRENCY",
54
+ Currency = "CURRENCY",
55
+ EquityShares = "EQUITY_SHARES",
56
+ Indices = "INDICES",
57
+ Rates = "RATES"
58
+ }
59
+ export declare enum BookType {
60
+ Order = "ORDER",
61
+ Position = "POSITION"
62
+ }
63
+ export type CorrelationHeatmap = {
64
+ __typename?: 'CorrelationHeatmap';
65
+ baseInstrument: Instrument;
66
+ heatmap: Array<Heatmap>;
67
+ };
68
+ export type CorrelationMatrix = {
69
+ __typename?: 'CorrelationMatrix';
70
+ baseTimeUnit: CorrelationTimeUnit;
71
+ matrix: Array<Matrix>;
72
+ };
73
+ export declare enum CorrelationTimeUnit {
74
+ H1 = "H1",
75
+ H4 = "H4",
76
+ H24 = "H24",
77
+ M1 = "M1",
78
+ M3 = "M3",
79
+ M6 = "M6",
80
+ W1 = "W1",
81
+ Y1 = "Y1"
82
+ }
83
+ export declare enum CurrencyName {
84
+ Aud = "AUD",
85
+ Cad = "CAD",
86
+ Chf = "CHF",
87
+ Eur = "EUR",
88
+ Gbp = "GBP",
89
+ Jpy = "JPY",
90
+ Nzd = "NZD",
91
+ Usd = "USD"
92
+ }
93
+ export type CurrencyPower = {
94
+ __typename?: 'CurrencyPower';
95
+ /** UTC Timestamp */
96
+ point: Scalars['String']['output'];
97
+ price: Scalars['Float']['output'];
98
+ };
99
+ export type CurrencyPowerBalance = {
100
+ __typename?: 'CurrencyPowerBalance';
101
+ currency: CurrencyName;
102
+ power: Array<CurrencyPower>;
103
+ updatedAt: Scalars['String']['output'];
104
+ };
105
+ export declare enum CurrencyPowerBalanceTimeUnit {
106
+ CurrentDay = "CURRENT_DAY",
107
+ H4 = "H4",
108
+ H8 = "H8",
109
+ H24 = "H24",
110
+ M1 = "M1",
111
+ M3 = "M3",
112
+ PreviousDay = "PREVIOUS_DAY",
113
+ W1 = "W1"
114
+ }
115
+ export type CurrencyStrength = {
116
+ __typename?: 'CurrencyStrength';
117
+ currency: CurrencyName;
118
+ strengthRelation?: Maybe<Array<StrengthRelation>>;
119
+ updatedAt: Scalars['String']['output'];
120
+ };
121
+ export declare enum DataSource {
122
+ Ny4 = "NY4",
123
+ Ty3 = "TY3"
124
+ }
125
+ export declare enum Division {
126
+ Oap = "OAP",
127
+ Oau = "OAU",
128
+ Oc = "OC",
129
+ Ocan = "OCAN",
130
+ Oel = "OEL",
131
+ Ogm = "OGM",
132
+ Oj = "OJ",
133
+ Opt = "OPT",
134
+ Otms = "OTMS"
135
+ }
136
+ export type Heatmap = {
137
+ __typename?: 'Heatmap';
138
+ instrument: Instrument;
139
+ timeCorrelation: Array<TimeCorrelation>;
140
+ };
141
+ export type Instrument = {
142
+ __typename?: 'Instrument';
143
+ displayName: Scalars['String']['output'];
144
+ name: Scalars['String']['output'];
145
+ };
146
+ export type InstrumentCorrelation = {
147
+ __typename?: 'InstrumentCorrelation';
148
+ instrument: Instrument;
149
+ value?: Maybe<Scalars['Float']['output']>;
150
+ };
151
+ export type Matrix = {
152
+ __typename?: 'Matrix';
153
+ instrument: Instrument;
154
+ instrumentCorrelation: Array<InstrumentCorrelation>;
155
+ };
156
+ export type OrderPositionBucket = {
157
+ __typename?: 'OrderPositionBucket';
158
+ longCountPercent: Scalars['Float']['output'];
159
+ price: Scalars['Float']['output'];
160
+ shortCountPercent: Scalars['Float']['output'];
161
+ };
162
+ export type OrderPositionData = {
163
+ __typename?: 'OrderPositionData';
164
+ bucketWidth: Scalars['Float']['output'];
165
+ buckets: Array<Maybe<OrderPositionBucket>>;
166
+ dataSource?: Maybe<Scalars['String']['output']>;
167
+ instrument: Scalars['String']['output'];
168
+ price?: Maybe<Scalars['Float']['output']>;
169
+ region?: Maybe<Scalars['String']['output']>;
170
+ time: Scalars['String']['output'];
171
+ unixTime: Scalars['Int']['output'];
172
+ };
173
+ export type Query = {
174
+ __typename?: 'Query';
175
+ assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
176
+ correlationHeatmap: CorrelationHeatmap;
177
+ correlationMatrix: CorrelationMatrix;
178
+ currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
179
+ currencyStrength?: Maybe<Array<CurrencyStrength>>;
180
+ isAllowedPartner?: Maybe<Scalars['Boolean']['output']>;
181
+ mapInstrumentNames?: Maybe<Array<Maybe<Instrument>>>;
182
+ orderPositionBooks: Array<Maybe<OrderPositionData>>;
183
+ sentiment?: Maybe<Array<SentimentInstrument>>;
184
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
185
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
186
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
187
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
188
+ valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
189
+ valueAtRiskChart?: Maybe<ValueAtRiskChart>;
190
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
191
+ volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
192
+ };
193
+ export type QueryAssetClassesArgs = {
194
+ division: Division;
195
+ };
196
+ export type QueryCorrelationHeatmapArgs = {
197
+ division: Division;
198
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
199
+ timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
200
+ };
201
+ export type QueryCorrelationMatrixArgs = {
202
+ division: Division;
203
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
204
+ };
205
+ export type QueryCurrencyPowerBalanceArgs = {
206
+ timeUnit: CurrencyPowerBalanceTimeUnit;
207
+ };
208
+ export type QueryIsAllowedPartnerArgs = {
209
+ url: Scalars['String']['input'];
210
+ };
211
+ export type QueryMapInstrumentNamesArgs = {
212
+ division?: InputMaybe<Division>;
213
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
214
+ };
215
+ export type QueryOrderPositionBooksArgs = {
216
+ bookType: BookType;
217
+ dataSource?: InputMaybe<DataSource>;
218
+ instrument: Scalars['String']['input'];
219
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
220
+ region?: InputMaybe<Region>;
221
+ };
222
+ export type QuerySentimentArgs = {
223
+ division?: InputMaybe<Division>;
224
+ name: Scalars['String']['input'];
225
+ };
226
+ export type QuerySentimentListArgs = {
227
+ division?: InputMaybe<Division>;
228
+ sort?: InputMaybe<Sort>;
229
+ };
230
+ export type QueryTopicalInstrumentsArgs = {
231
+ assetClass?: InputMaybe<AssetClassName>;
232
+ count?: InputMaybe<Scalars['Int']['input']>;
233
+ division?: InputMaybe<Division>;
234
+ offset?: InputMaybe<Scalars['Int']['input']>;
235
+ sort: TopicalSort;
236
+ };
237
+ export type QueryTopicalInstrumentsChartsArgs = {
238
+ division?: InputMaybe<Division>;
239
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
240
+ };
241
+ export type QueryTopicalInstrumentsTotalCountArgs = {
242
+ assetClass?: InputMaybe<AssetClassName>;
243
+ division?: InputMaybe<Division>;
244
+ sort: TopicalSort;
245
+ };
246
+ export type QueryValueAtRiskAssetClassesArgs = {
247
+ division?: InputMaybe<Division>;
248
+ };
249
+ export type QueryValueAtRiskChartArgs = {
250
+ bars: ValueAtRiskBars;
251
+ division?: InputMaybe<Division>;
252
+ duration: ValueAtRiskDuration;
253
+ instrument: Scalars['String']['input'];
254
+ };
255
+ export type QueryVolatilityChartArgs = {
256
+ division?: InputMaybe<Division>;
257
+ instrument: Scalars['String']['input'];
258
+ timeSpan: VolatilityChartTimeSpan;
259
+ timeUnit: VolatilityChartTimeUnit;
260
+ };
261
+ export type QueryVolatilityChartAssetClassesArgs = {
262
+ division?: InputMaybe<Division>;
263
+ };
264
+ export declare enum Region {
265
+ Amer = "AMER",
266
+ Apac = "APAC",
267
+ Emea = "EMEA"
268
+ }
269
+ export type Sentiment = {
270
+ __typename?: 'Sentiment';
271
+ longPercent: Scalars['Float']['output'];
272
+ shortPercent: Scalars['Float']['output'];
273
+ };
274
+ export type SentimentInstrument = {
275
+ __typename?: 'SentimentInstrument';
276
+ displayName: Scalars['String']['output'];
277
+ name: Scalars['String']['output'];
278
+ sentiment: Sentiment;
279
+ updatedAt: Scalars['String']['output'];
280
+ };
281
+ export declare enum Sort {
282
+ Bearish = "BEARISH",
283
+ Bullish = "BULLISH"
284
+ }
285
+ export type StrengthRelation = {
286
+ __typename?: 'StrengthRelation';
287
+ currency: CurrencyName;
288
+ percentage: Scalars['Float']['output'];
289
+ };
290
+ export type TimeCorrelation = {
291
+ __typename?: 'TimeCorrelation';
292
+ timeUnit: CorrelationTimeUnit;
293
+ value?: Maybe<Scalars['Float']['output']>;
294
+ };
295
+ export type TopicalInstrument = {
296
+ __typename?: 'TopicalInstrument';
297
+ assetClass?: Maybe<AssetClassName>;
298
+ displayName: Scalars['String']['output'];
299
+ name: Scalars['String']['output'];
300
+ sentiment: Sentiment;
301
+ updatedAt: Scalars['String']['output'];
302
+ };
303
+ export type TopicalInstrumentChart = {
304
+ __typename?: 'TopicalInstrumentChart';
305
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
306
+ name: Scalars['String']['output'];
307
+ };
308
+ export declare enum TopicalSort {
309
+ Bearish = "BEARISH",
310
+ Bullish = "BULLISH",
311
+ Hot = "HOT",
312
+ Popular = "POPULAR",
313
+ Volatile = "VOLATILE"
314
+ }
315
+ export declare enum ValueAtRiskBars {
316
+ C100 = "C100",
317
+ C200 = "C200",
318
+ C300 = "C300"
319
+ }
320
+ export type ValueAtRiskChart = {
321
+ __typename?: 'ValueAtRiskChart';
322
+ down: ValueAtRiskChartData;
323
+ up: ValueAtRiskChartData;
324
+ };
325
+ export type ValueAtRiskChartData = {
326
+ __typename?: 'ValueAtRiskChartData';
327
+ average: Scalars['Float']['output'];
328
+ max: Scalars['Float']['output'];
329
+ median: Scalars['Float']['output'];
330
+ points?: Maybe<Array<ValueAtRiskChartPoint>>;
331
+ threshold: Scalars['Float']['output'];
332
+ };
333
+ export type ValueAtRiskChartPoint = {
334
+ __typename?: 'ValueAtRiskChartPoint';
335
+ percent: Scalars['Float']['output'];
336
+ pips: Scalars['Float']['output'];
337
+ };
338
+ export declare enum ValueAtRiskDuration {
339
+ C1 = "C1",
340
+ C2 = "C2",
341
+ C3 = "C3",
342
+ C4 = "C4",
343
+ C5 = "C5",
344
+ C10 = "C10"
345
+ }
346
+ export type VolatilityChart = {
347
+ __typename?: 'VolatilityChart';
348
+ pips: Scalars['Float']['output'];
349
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
350
+ point: Scalars['String']['output'];
351
+ updatedAt: Scalars['String']['output'];
352
+ };
353
+ export declare enum VolatilityChartTimeSpan {
354
+ /** Valid for: H */
355
+ D5 = "D5",
356
+ /** Valid for: H */
357
+ D10 = "D10",
358
+ /** Valid for: D */
359
+ M1 = "M1",
360
+ /** Valid for: D */
361
+ M3 = "M3",
362
+ /** Valid for: W */
363
+ W5 = "W5",
364
+ /** Valid for: W */
365
+ W10 = "W10"
366
+ }
367
+ export declare enum VolatilityChartTimeUnit {
368
+ D = "D",
369
+ H = "H",
370
+ W = "W"
371
+ }
372
+ export type ValidateInstrumentsQueryVariables = Exact<{
373
+ instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
374
+ division?: InputMaybe<Division>;
375
+ }>;
376
+ export type ValidateInstrumentsQuery = {
377
+ __typename?: 'Query';
378
+ mapInstrumentNames?: Array<{
379
+ __typename?: 'Instrument';
380
+ name: string;
381
+ displayName: string;
382
+ } | null> | null;
383
+ };
384
+ export declare const ValidateInstrumentsDocument: DocumentNode<ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables>;
@@ -0,0 +1,2 @@
1
+ export * from "./fragment-masking";
2
+ export * from "./gql";
@@ -0,0 +1 @@
1
+ export declare const validateInstruments: import("@apollo/client").DocumentNode;
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-cross-table",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Labs Currency Cross Table",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
7
7
  "types": "dist/types/index.d.ts",
8
+ "scripts": {
9
+ "codegen": "graphql-codegen --config codegen.ts"
10
+ },
8
11
  "keywords": [],
9
12
  "author": "OANDA",
10
13
  "license": "UNLICENSED",
11
14
  "dependencies": {
12
- "@oanda/labs-widget-common": "^1.0.155",
13
- "@oanda/mono-i18n": "10.0.1"
15
+ "@oanda/labs-widget-common": "^1.0.156",
16
+ "@oanda/mono-i18n": "10.0.1",
17
+ "graphql": "16.8.1"
18
+ },
19
+ "devDependencies": {
20
+ "@graphql-codegen/cli": "5.0.0",
21
+ "@graphql-codegen/client-preset": "4.1.0"
14
22
  },
15
- "gitHead": "eecb0d8d995023c4374b106577b8be81b27604d4"
23
+ "gitHead": "0805ed728b9b0cf74d1cf0ef6db7beab69943000"
16
24
  }
@@ -1,13 +1,16 @@
1
1
  import React from 'react';
2
+ import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
2
3
  import { LocaleProvider } from '@oanda/mono-i18n';
3
4
  import {
4
5
  LiveRatesProvider, ThemeProvider, getLocale,
5
6
  } from '@oanda/labs-widget-common';
6
7
  import { translations } from '../translations';
7
- import { Division, CurrencyCrossTableConfig } from './types';
8
+ import { CurrencyCrossTableConfig } from './types';
8
9
  import { ValidationWrapper } from './ValidationWrapper';
10
+ import { Division } from '../gql/types/graphql';
9
11
 
10
12
  const CurrencyCrossTableWidget = ({
13
+ graphqlUrl,
11
14
  liveRatesUrl,
12
15
  currencies,
13
16
  division,
@@ -16,6 +19,11 @@ const CurrencyCrossTableWidget = ({
16
19
  isParamError,
17
20
  removePadding,
18
21
  }: CurrencyCrossTableConfig) => {
22
+ const client = new ApolloClient({
23
+ uri: graphqlUrl,
24
+ cache: new InMemoryCache(),
25
+ });
26
+
19
27
  const divisionCode = division === Division.Opt ? Division.Ogm : division;
20
28
  const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
21
29
 
@@ -26,11 +34,13 @@ const CurrencyCrossTableWidget = ({
26
34
  url={liveRatesUrl}
27
35
  options={{ divisionCode, dataSource }}
28
36
  >
29
- <ValidationWrapper
30
- currencies={currencies}
31
- division={division}
32
- isParamError={isParamError}
33
- />
37
+ <ApolloProvider client={client}>
38
+ <ValidationWrapper
39
+ currencies={currencies}
40
+ division={division}
41
+ isParamError={isParamError}
42
+ />
43
+ </ApolloProvider>
34
44
  </LiveRatesProvider>
35
45
  </LocaleProvider>
36
46
  </ThemeProvider>
@@ -1,11 +1,16 @@
1
- import React, { Fragment, useEffect, useState } from 'react';
1
+ import React, {
2
+ Fragment, Suspense, useEffect, useState,
3
+ } from 'react';
2
4
  import { useLiveRatesQuery } from '@oanda/labs-widget-common';
3
5
  import { MainProps } from './types';
4
- import { CellWithData, TextCell } from './components';
6
+ import { TextCell } from './components';
7
+ import { CellValidationWrapper } from './components/CellValidationWrapper';
8
+ import { divisionMapper } from './utils';
5
9
 
6
10
  const Main = ({
7
11
  instruments,
8
12
  currencies,
13
+ division,
9
14
  }: MainProps) => {
10
15
  const [selectedCurrency, setSelectedCurrency] = useState('');
11
16
  const [selectedPair, setSelectedPair] = useState('');
@@ -46,17 +51,18 @@ const Main = ({
46
51
  {arr.map((pair) => (
47
52
  <Fragment key={`${currency}_${pair}`}>
48
53
  {currency !== pair ? (
49
- <CellWithData
50
- loading={false}
51
- record={{
52
- instrument: `${currency}_${pair}`,
53
- displayName: `${currency}/${pair}`,
54
- }}
55
- target={target}
56
- additionalBorderBottom={index === arr.length - 1}
57
- setSelectedCurrency={setSelectedCurrency}
58
- setSelectedPair={setSelectedPair}
59
- />
54
+ <Suspense>
55
+ <CellValidationWrapper
56
+ currency={currency}
57
+ pair={pair}
58
+ instrument={`${currency}${divisionMapper(division)}${pair}`}
59
+ target={target}
60
+ additionalBorderBottom={index === arr.length - 1}
61
+ setSelectedCurrency={setSelectedCurrency}
62
+ setSelectedPair={setSelectedPair}
63
+ division={division}
64
+ />
65
+ </Suspense>
60
66
  ) : (
61
67
  <TextCell
62
68
  additionalBorderBottom={index === arr.length - 1}
@@ -21,6 +21,7 @@ const ValidationWrapper = ({
21
21
  <Main
22
22
  instruments={currenciesToInstruments(currencies, division)}
23
23
  currencies={currencies}
24
+ division={division}
24
25
  />
25
26
  )}
26
27
  {showError && (