@infosel-sdk/markets 1.2.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/CHANGELOG.md +235 -0
  2. package/README.md +111 -423
  3. package/package.json +1 -1
  4. package/src/__tests__/__mocks__/apis/markets-api.mock.d.ts +0 -73
  5. package/src/__tests__/__mocks__/apis/markets-api.mock.js +3 -45
  6. package/src/__tests__/__mocks__/apis/markets-api.mock.js.map +1 -1
  7. package/src/__tests__/utils/mock-datasource.js +0 -16
  8. package/src/__tests__/utils/mock-datasource.js.map +1 -1
  9. package/src/__tests__/utils/mock-factories.d.ts +0 -104
  10. package/src/__tests__/utils/mock-factories.js +6 -24
  11. package/src/__tests__/utils/mock-factories.js.map +1 -1
  12. package/src/__tests__/utils/mock-repository.d.ts +0 -12
  13. package/src/__tests__/utils/mock-repository.js +2 -46
  14. package/src/__tests__/utils/mock-repository.js.map +1 -1
  15. package/src/__tests__/utils/test-helpers.d.ts +0 -2
  16. package/src/__tests__/utils/test-helpers.js +0 -6
  17. package/src/__tests__/utils/test-helpers.js.map +1 -1
  18. package/src/data/datasources/markets_datasource_impl.d.ts +6 -55
  19. package/src/data/datasources/markets_datasource_impl.js +11 -985
  20. package/src/data/datasources/markets_datasource_impl.js.map +1 -1
  21. package/src/data/di/infosel_markets_component.d.ts +4 -60
  22. package/src/data/di/infosel_markets_component.js +0 -137
  23. package/src/data/di/infosel_markets_component.js.map +1 -1
  24. package/src/data/di/infosel_markets_module.d.ts +1 -4
  25. package/src/data/di/infosel_markets_module.js +1 -7
  26. package/src/data/di/infosel_markets_module.js.map +1 -1
  27. package/src/data/mappers/markets_mapper.d.ts +1 -41
  28. package/src/data/mappers/markets_mapper.js +7 -177
  29. package/src/data/mappers/markets_mapper.js.map +1 -1
  30. package/src/data/models/instrument_fields_model.d.ts +7 -0
  31. package/src/data/repositories/markets_repository_impl.d.ts +4 -48
  32. package/src/data/repositories/markets_repository_impl.js +0 -57
  33. package/src/data/repositories/markets_repository_impl.js.map +1 -1
  34. package/src/domain/datasources/markets_datasource.d.ts +4 -47
  35. package/src/domain/di/markets_component.d.ts +18 -41
  36. package/src/domain/di/markets_module.d.ts +1 -2
  37. package/src/domain/entities/get_last_request.d.ts +4 -0
  38. package/src/{data/models/user_model.js → domain/entities/get_last_request.js} +1 -1
  39. package/src/domain/entities/get_last_request.js.map +1 -0
  40. package/src/domain/entities/index.d.ts +0 -20
  41. package/src/domain/entities/index.js +0 -20
  42. package/src/domain/entities/index.js.map +1 -1
  43. package/src/domain/entities/instrument_fields.d.ts +7 -0
  44. package/src/domain/repositories/markets_repository.d.ts +4 -43
  45. package/src/domain/use_cases/get_instrument_fields_use_case.d.ts +3 -2
  46. package/src/domain/use_cases/get_instrument_fields_use_case.js.map +1 -1
  47. package/src/domain/use_cases/get_instrument_multiple_fields_use_case.d.ts +2 -1
  48. package/src/domain/use_cases/get_instrument_multiple_fields_use_case.js.map +1 -1
  49. package/src/index.d.ts +1 -4
  50. package/src/index.js +0 -2
  51. package/src/index.js.map +1 -1
  52. package/src/data/models/delete_workspace_response_model.d.ts +0 -5
  53. package/src/data/models/delete_workspace_response_model.js +0 -3
  54. package/src/data/models/delete_workspace_response_model.js.map +0 -1
  55. package/src/data/models/get_user_workspaces_response_model.d.ts +0 -15
  56. package/src/data/models/get_user_workspaces_response_model.js +0 -3
  57. package/src/data/models/get_user_workspaces_response_model.js.map +0 -1
  58. package/src/data/models/project_model.d.ts +0 -12
  59. package/src/data/models/project_model.js +0 -3
  60. package/src/data/models/project_model.js.map +0 -1
  61. package/src/data/models/project_widgets_response_model.d.ts +0 -8
  62. package/src/data/models/project_widgets_response_model.js +0 -3
  63. package/src/data/models/project_widgets_response_model.js.map +0 -1
  64. package/src/data/models/user_model.d.ts +0 -7
  65. package/src/data/models/user_model.js.map +0 -1
  66. package/src/data/models/user_widgets_response_model.d.ts +0 -7
  67. package/src/data/models/user_widgets_response_model.js +0 -3
  68. package/src/data/models/user_widgets_response_model.js.map +0 -1
  69. package/src/data/models/widget_brokerage_concentration_configuration.d.ts +0 -4
  70. package/src/data/models/widget_brokerage_concentration_configuration.js +0 -3
  71. package/src/data/models/widget_brokerage_concentration_configuration.js.map +0 -1
  72. package/src/data/models/widget_brokerage_participation_configuration.d.ts +0 -10
  73. package/src/data/models/widget_brokerage_participation_configuration.js +0 -3
  74. package/src/data/models/widget_brokerage_participation_configuration.js.map +0 -1
  75. package/src/data/models/widget_brokerage_trades_configuration.d.ts +0 -11
  76. package/src/data/models/widget_brokerage_trades_configuration.js +0 -3
  77. package/src/data/models/widget_brokerage_trades_configuration.js.map +0 -1
  78. package/src/data/models/widget_chart_configuration_model.d.ts +0 -4
  79. package/src/data/models/widget_chart_configuration_model.js +0 -3
  80. package/src/data/models/widget_chart_configuration_model.js.map +0 -1
  81. package/src/data/models/widget_decreed_search_configuration.d.ts +0 -10
  82. package/src/data/models/widget_decreed_search_configuration.js +0 -3
  83. package/src/data/models/widget_decreed_search_configuration.js.map +0 -1
  84. package/src/data/models/widget_dynamic_table_configuration.d.ts +0 -14
  85. package/src/data/models/widget_dynamic_table_configuration.js +0 -3
  86. package/src/data/models/widget_dynamic_table_configuration.js.map +0 -1
  87. package/src/data/models/widget_indices_components_configuration.d.ts +0 -7
  88. package/src/data/models/widget_indices_components_configuration.js +0 -3
  89. package/src/data/models/widget_indices_components_configuration.js.map +0 -1
  90. package/src/data/models/widget_layout_model.d.ts +0 -6
  91. package/src/data/models/widget_layout_model.js +0 -3
  92. package/src/data/models/widget_layout_model.js.map +0 -1
  93. package/src/data/models/widget_market_total_configuration.d.ts +0 -4
  94. package/src/data/models/widget_market_total_configuration.js +0 -3
  95. package/src/data/models/widget_market_total_configuration.js.map +0 -1
  96. package/src/data/models/widget_model.d.ts +0 -33
  97. package/src/data/models/widget_model.js +0 -3
  98. package/src/data/models/widget_model.js.map +0 -1
  99. package/src/data/models/widget_size_model.d.ts +0 -14
  100. package/src/data/models/widget_size_model.js +0 -3
  101. package/src/data/models/widget_size_model.js.map +0 -1
  102. package/src/data/models/widget_table_column_format_model.d.ts +0 -6
  103. package/src/data/models/widget_table_column_format_model.js +0 -3
  104. package/src/data/models/widget_table_column_format_model.js.map +0 -1
  105. package/src/data/models/widget_table_column_model.d.ts +0 -8
  106. package/src/data/models/widget_table_column_model.js +0 -3
  107. package/src/data/models/widget_table_column_model.js.map +0 -1
  108. package/src/data/models/widget_ticker_configuration.d.ts +0 -7
  109. package/src/data/models/widget_ticker_configuration.js +0 -3
  110. package/src/data/models/widget_ticker_configuration.js.map +0 -1
  111. package/src/data/models/widget_traded_packages_configuration.d.ts +0 -4
  112. package/src/data/models/widget_traded_packages_configuration.js +0 -3
  113. package/src/data/models/widget_traded_packages_configuration.js.map +0 -1
  114. package/src/data/models/workspace_model.d.ts +0 -6
  115. package/src/data/models/workspace_model.js +0 -3
  116. package/src/data/models/workspace_model.js.map +0 -1
  117. package/src/domain/entities/chart_configuration.d.ts +0 -5
  118. package/src/domain/entities/chart_configuration.js +0 -3
  119. package/src/domain/entities/chart_configuration.js.map +0 -1
  120. package/src/domain/entities/create_instrument_request.d.ts +0 -5
  121. package/src/domain/entities/create_instrument_request.js +0 -3
  122. package/src/domain/entities/create_instrument_request.js.map +0 -1
  123. package/src/domain/entities/create_widget_request.d.ts +0 -36
  124. package/src/domain/entities/create_widget_request.js +0 -3
  125. package/src/domain/entities/create_widget_request.js.map +0 -1
  126. package/src/domain/entities/create_workspace_request.d.ts +0 -5
  127. package/src/domain/entities/create_workspace_request.js +0 -3
  128. package/src/domain/entities/create_workspace_request.js.map +0 -1
  129. package/src/domain/entities/delete_workspace_request.d.ts +0 -3
  130. package/src/domain/entities/delete_workspace_request.js +0 -3
  131. package/src/domain/entities/delete_workspace_request.js.map +0 -1
  132. package/src/domain/entities/duplicate_widget_request.d.ts +0 -5
  133. package/src/domain/entities/duplicate_widget_request.js +0 -3
  134. package/src/domain/entities/duplicate_widget_request.js.map +0 -1
  135. package/src/domain/entities/duplicate_workspace_request.d.ts +0 -5
  136. package/src/domain/entities/duplicate_workspace_request.js +0 -3
  137. package/src/domain/entities/duplicate_workspace_request.js.map +0 -1
  138. package/src/domain/entities/get_instruments_request.d.ts +0 -12
  139. package/src/domain/entities/get_instruments_request.js +0 -3
  140. package/src/domain/entities/get_instruments_request.js.map +0 -1
  141. package/src/domain/entities/get_project_widgets_request.d.ts +0 -12
  142. package/src/domain/entities/get_project_widgets_request.js +0 -3
  143. package/src/domain/entities/get_project_widgets_request.js.map +0 -1
  144. package/src/domain/entities/get_user_widgets_request.d.ts +0 -3
  145. package/src/domain/entities/get_user_widgets_request.js +0 -3
  146. package/src/domain/entities/get_user_widgets_request.js.map +0 -1
  147. package/src/domain/entities/get_user_workspaces_request.d.ts +0 -4
  148. package/src/domain/entities/get_user_workspaces_request.js +0 -3
  149. package/src/domain/entities/get_user_workspaces_request.js.map +0 -1
  150. package/src/domain/entities/get_workspace_request.d.ts +0 -3
  151. package/src/domain/entities/get_workspace_request.js +0 -3
  152. package/src/domain/entities/get_workspace_request.js.map +0 -1
  153. package/src/domain/entities/get_workspaces_by_user_request.d.ts +0 -12
  154. package/src/domain/entities/get_workspaces_by_user_request.js +0 -3
  155. package/src/domain/entities/get_workspaces_by_user_request.js.map +0 -1
  156. package/src/domain/entities/get_workspaces_request.d.ts +0 -12
  157. package/src/domain/entities/get_workspaces_request.js +0 -3
  158. package/src/domain/entities/get_workspaces_request.js.map +0 -1
  159. package/src/domain/entities/instruments_response.d.ts +0 -6
  160. package/src/domain/entities/instruments_response.js +0 -3
  161. package/src/domain/entities/instruments_response.js.map +0 -1
  162. package/src/domain/entities/news_configuration.d.ts +0 -8
  163. package/src/domain/entities/news_configuration.js +0 -3
  164. package/src/domain/entities/news_configuration.js.map +0 -1
  165. package/src/domain/entities/project_widgets_container.d.ts +0 -12
  166. package/src/domain/entities/project_widgets_container.js +0 -3
  167. package/src/domain/entities/project_widgets_container.js.map +0 -1
  168. package/src/domain/entities/update_widget_chart_request.d.ts +0 -4
  169. package/src/domain/entities/update_widget_chart_request.js +0 -3
  170. package/src/domain/entities/update_widget_chart_request.js.map +0 -1
  171. package/src/domain/entities/update_widget_instruments_reques.d.ts +0 -11
  172. package/src/domain/entities/update_widget_instruments_reques.js +0 -3
  173. package/src/domain/entities/update_widget_instruments_reques.js.map +0 -1
  174. package/src/domain/entities/update_workspace_request.d.ts +0 -19
  175. package/src/domain/entities/update_workspace_request.js +0 -3
  176. package/src/domain/entities/update_workspace_request.js.map +0 -1
  177. package/src/domain/entities/user_widgets.d.ts +0 -5
  178. package/src/domain/entities/user_widgets.js +0 -3
  179. package/src/domain/entities/user_widgets.js.map +0 -1
  180. package/src/domain/entities/user_workspaces.d.ts +0 -8
  181. package/src/domain/entities/user_workspaces.js +0 -3
  182. package/src/domain/entities/user_workspaces.js.map +0 -1
  183. package/src/domain/entities/widget.d.ts +0 -129
  184. package/src/domain/entities/widget.js +0 -3
  185. package/src/domain/entities/widget.js.map +0 -1
  186. package/src/domain/entities/widget_layout_config.d.ts +0 -15
  187. package/src/domain/entities/widget_layout_config.js +0 -3
  188. package/src/domain/entities/widget_layout_config.js.map +0 -1
  189. package/src/domain/entities/widget_size_config.d.ts +0 -6
  190. package/src/domain/entities/widget_size_config.js +0 -3
  191. package/src/domain/entities/widget_size_config.js.map +0 -1
  192. package/src/domain/entities/workspace.d.ts +0 -13
  193. package/src/domain/entities/workspace.js +0 -3
  194. package/src/domain/entities/workspace.js.map +0 -1
  195. package/src/domain/entities/workspace_widgets.d.ts +0 -6
  196. package/src/domain/entities/workspace_widgets.js +0 -3
  197. package/src/domain/entities/workspace_widgets.js.map +0 -1
  198. package/src/domain/entities/workspaces_container.d.ts +0 -18
  199. package/src/domain/entities/workspaces_container.js +0 -3
  200. package/src/domain/entities/workspaces_container.js.map +0 -1
  201. package/src/domain/use_cases/create_instrument_use_case.d.ts +0 -9
  202. package/src/domain/use_cases/create_instrument_use_case.js +0 -22
  203. package/src/domain/use_cases/create_instrument_use_case.js.map +0 -1
  204. package/src/domain/use_cases/create_widget_use_case.d.ts +0 -9
  205. package/src/domain/use_cases/create_widget_use_case.js +0 -32
  206. package/src/domain/use_cases/create_widget_use_case.js.map +0 -1
  207. package/src/domain/use_cases/create_workspace_use_case.d.ts +0 -9
  208. package/src/domain/use_cases/create_workspace_use_case.js +0 -22
  209. package/src/domain/use_cases/create_workspace_use_case.js.map +0 -1
  210. package/src/domain/use_cases/delete_instrument_use_case.d.ts +0 -7
  211. package/src/domain/use_cases/delete_instrument_use_case.js +0 -19
  212. package/src/domain/use_cases/delete_instrument_use_case.js.map +0 -1
  213. package/src/domain/use_cases/delete_widget_use_case.d.ts +0 -7
  214. package/src/domain/use_cases/delete_widget_use_case.js +0 -19
  215. package/src/domain/use_cases/delete_widget_use_case.js.map +0 -1
  216. package/src/domain/use_cases/delete_workspace_use_case.d.ts +0 -8
  217. package/src/domain/use_cases/delete_workspace_use_case.js +0 -22
  218. package/src/domain/use_cases/delete_workspace_use_case.js.map +0 -1
  219. package/src/domain/use_cases/duplicate_widget_use_case.d.ts +0 -8
  220. package/src/domain/use_cases/duplicate_widget_use_case.js +0 -15
  221. package/src/domain/use_cases/duplicate_widget_use_case.js.map +0 -1
  222. package/src/domain/use_cases/duplicate_workspace_use_case.d.ts +0 -8
  223. package/src/domain/use_cases/duplicate_workspace_use_case.js +0 -15
  224. package/src/domain/use_cases/duplicate_workspace_use_case.js.map +0 -1
  225. package/src/domain/use_cases/get_instruments_use_case.d.ts +0 -9
  226. package/src/domain/use_cases/get_instruments_use_case.js +0 -16
  227. package/src/domain/use_cases/get_instruments_use_case.js.map +0 -1
  228. package/src/domain/use_cases/get_project_widgets_use_case.d.ts +0 -9
  229. package/src/domain/use_cases/get_project_widgets_use_case.js +0 -19
  230. package/src/domain/use_cases/get_project_widgets_use_case.js.map +0 -1
  231. package/src/domain/use_cases/get_user_widgets_use_case.d.ts +0 -9
  232. package/src/domain/use_cases/get_user_widgets_use_case.js +0 -22
  233. package/src/domain/use_cases/get_user_widgets_use_case.js.map +0 -1
  234. package/src/domain/use_cases/get_user_workspace_use_case.d.ts +0 -9
  235. package/src/domain/use_cases/get_user_workspace_use_case.js +0 -22
  236. package/src/domain/use_cases/get_user_workspace_use_case.js.map +0 -1
  237. package/src/domain/use_cases/get_workspace_use_case.d.ts +0 -9
  238. package/src/domain/use_cases/get_workspace_use_case.js +0 -19
  239. package/src/domain/use_cases/get_workspace_use_case.js.map +0 -1
  240. package/src/domain/use_cases/get_workspaces_by_project_id_use_case.d.ts +0 -9
  241. package/src/domain/use_cases/get_workspaces_by_project_id_use_case.js +0 -19
  242. package/src/domain/use_cases/get_workspaces_by_project_id_use_case.js.map +0 -1
  243. package/src/domain/use_cases/get_workspaces_by_user_use_case.d.ts +0 -9
  244. package/src/domain/use_cases/get_workspaces_by_user_use_case.js +0 -19
  245. package/src/domain/use_cases/get_workspaces_by_user_use_case.js.map +0 -1
  246. package/src/domain/use_cases/get_workspaces_use_case.d.ts +0 -9
  247. package/src/domain/use_cases/get_workspaces_use_case.js +0 -19
  248. package/src/domain/use_cases/get_workspaces_use_case.js.map +0 -1
  249. package/src/domain/use_cases/update_widget_chart_use_case.d.ts +0 -7
  250. package/src/domain/use_cases/update_widget_chart_use_case.js +0 -15
  251. package/src/domain/use_cases/update_widget_chart_use_case.js.map +0 -1
  252. package/src/domain/use_cases/update_widget_instruments_use_case.d.ts +0 -9
  253. package/src/domain/use_cases/update_widget_instruments_use_case.js +0 -22
  254. package/src/domain/use_cases/update_widget_instruments_use_case.js.map +0 -1
  255. package/src/domain/use_cases/update_workspace_use_case.d.ts +0 -8
  256. package/src/domain/use_cases/update_workspace_use_case.js +0 -15
  257. package/src/domain/use_cases/update_workspace_use_case.js.map +0 -1
@@ -3,965 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@infosel-sdk/core");
5
5
  class MarketsDatasourceImpl {
6
- constructor(graphQlClient, marketsHttpClient, mapper) {
7
- this.graphQlClient = graphQlClient;
6
+ constructor(marketsHttpClient, mapper) {
8
7
  this.marketsHttpClient = marketsHttpClient;
9
8
  this.mapper = mapper;
10
- this.getMapperWorkspaces = (models) => {
11
- const workspaces = this.mapper.mapWorkspaces(models);
12
- const widgets = this.mapper.mapWidgetsContainer(models);
13
- const instruments = this.mapper.mapInstrumentsContainer(models);
14
- return { workspaces, widgets, instruments };
15
- };
16
- }
17
- getUserWorkspaces(request) {
18
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
- const query = `
20
- query($connectionId: String!, $projectId: String!) {
21
- userByConnectionId(connectionId: $connectionId, projectId: $projectId) {
22
- id
23
- connectionId
24
- workspaces {
25
- id
26
- name
27
- order
28
- createdAt
29
- updatedAt
30
- widgets {
31
- id
32
- name
33
- type
34
- }
35
- }
36
- }
37
- }
38
- `;
39
- const response = yield this.graphQlClient.query(query, {
40
- connectionId: request.connectionId,
41
- projectId: request.projectId,
42
- });
43
- const model = response.userByConnectionId;
44
- if (!model) {
45
- throw new core_1.SdkError(core_1.SdkErrorType.USER_NOT_EXIST);
46
- }
47
- const workspaces = (model.workspaces || []).map(workspace => ({
48
- id: workspace.id || '-',
49
- name: workspace.name || '-',
50
- order: workspace.order || 0,
51
- createdAt: workspace.createdAt || '-',
52
- updatedAt: workspace.updatedAt || '-',
53
- }));
54
- const widgets = this.mapper.mapWidgets(model.widgets || []);
55
- return {
56
- id: model.id || '-',
57
- connectionId: model.connectionId || '-',
58
- workspaces,
59
- widgets,
60
- };
61
- });
62
- }
63
- getUserWidgets(request) {
64
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
- const query = `
66
- query user ($id: String!) {
67
- user (id: $id) {
68
- id
69
- widgets {
70
- id
71
- name
72
- type
73
- tableColumns {
74
- id
75
- field
76
- description
77
- visible
78
- active
79
- format
80
- }
81
- instruments {
82
- symbol
83
- uniqueKey
84
- }
85
- chartConfiguration {
86
- id
87
- globalConfiguration
88
- }
89
- }
90
- }
91
- }
92
- `;
93
- const response = yield this.graphQlClient.query(query, {
94
- id: request.id,
95
- });
96
- const model = response.user;
97
- if (!model) {
98
- throw new core_1.SdkError(core_1.SdkErrorType.USER_NOT_EXIST);
99
- }
100
- const widgets = this.mapper.mapWidgets(model.widgets || []);
101
- return {
102
- id: model.id || '-',
103
- widgets,
104
- };
105
- });
106
- }
107
- createWorkspace(request) {
108
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
109
- const query = `
110
- mutation($input: CreateWorkspaceInput!) {
111
- createWorkspace(createWorkspaceInput: $input) {
112
- id
113
- name
114
- }
115
- }
116
- `;
117
- const response = yield this.graphQlClient.mutate(query, { input: request });
118
- const model = response.createWorkspace;
119
- if (!model) {
120
- throw new core_1.SdkError(core_1.SdkErrorType.UNABLE_TO_CREATE_WORKSPACE);
121
- }
122
- return { id: (model === null || model === void 0 ? void 0 : model.id) || '-', name: (model === null || model === void 0 ? void 0 : model.name) || '-' };
123
- });
124
- }
125
- updateWorkspace(request) {
126
- var _a;
127
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
128
- const mutation = `
129
- mutation updateWorkspace ($updateWorkspaceInput: UpdateWorkspaceInput!, $whereInput: WhereWorkspaceInput!) {
130
- updateWorkspace (updateWorkspaceInput: $updateWorkspaceInput, whereInput: $whereInput) {
131
- id
132
- name
133
- order
134
- widgets {
135
- id
136
- sizes {
137
- id
138
- x
139
- y
140
- }
141
- }
142
- }
143
- }
144
- `;
145
- const response = yield this.graphQlClient.mutate(mutation, {
146
- updateWorkspaceInput: {
147
- name: request.name,
148
- order: request.order,
149
- sizes: request.sizes,
150
- },
151
- whereInput: {
152
- id: request.id,
153
- },
154
- });
155
- const model = response.updateWorkspace;
156
- if (!model) {
157
- throw new core_1.SdkError(core_1.SdkErrorType.UNABLE_TO_UPDATE_WORKSPACE);
158
- }
159
- return {
160
- id: model.id || '-',
161
- name: model.name || '-',
162
- order: model.order,
163
- widgets: (_a = model.widgets) === null || _a === void 0 ? void 0 : _a.map(widget => {
164
- var _a;
165
- return ({
166
- id: widget.id || '-',
167
- size: {
168
- id: ((_a = widget.size) === null || _a === void 0 ? void 0 : _a.id) || '-',
169
- },
170
- });
171
- }),
172
- };
173
- });
174
- }
175
- deleteWorkspace(request) {
176
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
177
- const mutation = `
178
- mutation deleteWorkspace ($whereInput: WhereWorkspaceInput!) {
179
- deleteWorkspace (whereInput: $whereInput) {
180
- nodesDeleted
181
- }
182
- }
183
- `;
184
- yield this.graphQlClient.mutate(mutation, {
185
- whereInput: { id: request.id },
186
- });
187
- return request.id;
188
- });
189
- }
190
- duplicateWorkspace(request) {
191
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
192
- const mutation = `
193
- mutation DUPLICATE_WORKSPACE($duplicateWorkspaceInput: DuplicateWorkspaceInput!) {
194
- duplicateWorkspace(duplicateWorkspaceInput: $duplicateWorkspaceInput) {
195
- id
196
- name
197
- }
198
- }
199
- `;
200
- const response = yield this.graphQlClient.mutate(mutation, {
201
- duplicateWorkspaceInput: {
202
- workspaceId: request.workspaceId,
203
- userId: request.userId,
204
- },
205
- });
206
- const model = response.duplicateWorkspace;
207
- if (!model) {
208
- throw new core_1.SdkError(core_1.SdkErrorType.UNABLE_TO_DUPLICATE_WORKSPACE);
209
- }
210
- return { id: (model === null || model === void 0 ? void 0 : model.id) || '-', name: (model === null || model === void 0 ? void 0 : model.name) || '-' };
211
- });
212
- }
213
- createWidget(request) {
214
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
215
- const mutation = `
216
- mutation($input: CreateWidgetInput!) {
217
- createWidget(createWidgetInput: $input) {
218
- id
219
- name
220
- type
221
- instruments {
222
- symbol
223
- uniqueKey
224
- }
225
- }
226
- }
227
- `;
228
- // Build the input object dynamically based on optional fields
229
- const input = {
230
- type: request.type,
231
- name: request.name,
232
- };
233
- // Add userId OR workspaceId based on what's provided
234
- if (request.userId) {
235
- input['userId'] = request.userId;
236
- }
237
- else if (request.workspaceId) {
238
- input['workspaceId'] = request.workspaceId;
239
- }
240
- // Add instruments only if provided
241
- if (request.instruments && request.instruments.length > 0) {
242
- input['instruments'] = {
243
- create: request.instruments.map(node => ({
244
- node,
245
- })),
246
- };
247
- }
248
- // Add newsConfiguration if provided
249
- if (request.type === 'NEWS_LIST' && request.newsConfiguration) {
250
- input['newsConfiguration'] = {
251
- create: {
252
- node: request.newsConfiguration,
253
- },
254
- };
255
- }
256
- // Add dynamicTableConfiguration if provided
257
- if (request.type === 'DYNAMIC_TABLE' && request.dynamicTableConfiguration) {
258
- input['dynamicTableConfiguration'] = {
259
- create: {
260
- node: request.dynamicTableConfiguration,
261
- },
262
- };
263
- }
264
- // Add sizes if provided
265
- if (request.sizes) {
266
- input['sizes'] = request.sizes;
267
- }
268
- // Add layout if provided
269
- if (request.layout) {
270
- input['layout'] = request.layout;
271
- }
272
- // Add chartConfiguration if provided
273
- if (request.type === 'CHART' && request.chartConfiguration) {
274
- input['chartConfiguration'] = {
275
- create: {
276
- node: request.chartConfiguration,
277
- },
278
- };
279
- }
280
- const response = yield this.graphQlClient.mutate(mutation, {
281
- input,
282
- });
283
- const model = response.createWidget;
284
- if (!model) {
285
- throw new core_1.SdkError(core_1.SdkErrorType.UNABLE_TO_CREATE_WIDGET);
286
- }
287
- return this.mapper.mapWidget(model);
288
- });
289
- }
290
- duplicateWidget(request) {
291
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
292
- const mutation = `
293
- mutation($duplicateWidgetInput: DuplicateWidgetInput!) {
294
- duplicateWidget(duplicateWidgetInput: $duplicateWidgetInput) {
295
- id
296
- name
297
- type
298
- layout {
299
- x
300
- y
301
- draggable
302
- resizable
303
- }
304
- tableColumns {
305
- id
306
- field
307
- description
308
- visible
309
- active
310
- format
311
- }
312
- size {
313
- id
314
- width
315
- height
316
- minWidth
317
- minHeight
318
- maxWidth
319
- maxHeight
320
- x
321
- y
322
- draggable
323
- resizable
324
- }
325
- tickerConfiguration {
326
- id
327
- position
328
- size
329
- visible
330
- speed
331
- }
332
- dynamicTableConfiguration {
333
- id
334
- period
335
- instrumentLimit
336
- field
337
- condition
338
- marketTypeId
339
- valueTypeIds
340
- exchangeId
341
- hasActivity
342
- scope
343
- isFiltered
344
- isYields
345
- operatingCompany
346
- }
347
- instruments {
348
- symbol
349
- uniqueKey
350
- }
351
- chartConfiguration {
352
- id
353
- globalConfiguration
354
- }
355
- marketTotalConfiguration {
356
- id
357
- scope
358
- }
359
- tradedPackagesConfiguration {
360
- id
361
- scope
362
- }
363
- brokerageTradesConfiguration {
364
- id
365
- scope
366
- }
367
- brokerageConcentrationConfiguration {
368
- id
369
- scope
370
- }
371
- brokerageParticipationConfiguration {
372
- id
373
- broker
374
- instrumentType
375
- crosses
376
- purchases
377
- sales
378
- totals
379
- symbol
380
- }
381
- decreedRightsSearcherConfiguration {
382
- id
383
- scope
384
- endDate
385
- issuer
386
- limit
387
- offset
388
- startDate
389
- type
390
- }
391
- indicesComponentsConfiguration {
392
- id
393
- scope
394
- component
395
- sector
396
- type
397
- }
398
- }
399
- }
400
- `;
401
- const response = yield this.graphQlClient.mutate(mutation, {
402
- duplicateWidgetInput: {
403
- workspaceId: request.workspaceId,
404
- widgetId: request.widgetId,
405
- },
406
- });
407
- const model = response.duplicateWidget;
408
- if (!model) {
409
- throw new core_1.SdkError(core_1.SdkErrorType.UNABLE_TO_CREATE_WIDGET);
410
- }
411
- return this.mapper.mapWidget(model);
412
- });
413
- }
414
- updateWidgetInstruments(request) {
415
- var _a, _b;
416
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
417
- const MUTATION = `
418
- mutation ($whereInput: WhereWidgetInput!,
419
- $updateInput: UpdateWidgetInstrumentsInput!
420
- $sortInput: InstrumentOptionsInput!
421
- ) {
422
- updateWidgetInstruments(whereInput: $whereInput, updateWidgetInstrumentsInput: $updateInput) {
423
- instruments (
424
- options: $sortInput
425
- ) {
426
- symbol
427
- uniqueKey
428
- }
429
- }
430
- }
431
- `;
432
- const response = yield this.graphQlClient.mutate(MUTATION, {
433
- whereInput: { id: request.widgetId },
434
- updateInput: { instrumentKeys: request.instruments.keys },
435
- sortInput: ((_a = request.instruments) === null || _a === void 0 ? void 0 : _a.options) || {
436
- sort: {
437
- field: 'symbol',
438
- direction: 'ASC',
439
- },
440
- offset: 0,
441
- limit: 40,
442
- },
443
- });
444
- const models = ((_b = response.updateWidgetInstruments) === null || _b === void 0 ? void 0 : _b.instruments) || [];
445
- return this.mapper.mapInstruments(models);
446
- });
447
- }
448
- updateWidgetChart(request) {
449
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
450
- const mutation = `
451
- mutation UPDATE_CHART($id: String!, $chartConfiguration: String!) {
452
- updateChartConfiguration(
453
- updateChartConfigurationInput: { globalConfiguration: $chartConfiguration }
454
- whereInput: { id: $id }
455
- ) {
456
- id
457
- }
458
- }
459
- `;
460
- const response = yield this.graphQlClient.mutate(mutation, {
461
- id: request.id,
462
- chartConfiguration: request.chartConfiguration,
463
- });
464
- const model = response.updateChartConfiguration;
465
- if (!model) {
466
- throw new core_1.SdkError(core_1.SdkErrorType.UNABLE_TO_CREATE_WIDGET);
467
- }
468
- return model.id || request.id;
469
- });
470
- }
471
- deleteWidget(request) {
472
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
473
- const MUTATION = `
474
- mutation ($input: WhereWidgetInput!) {
475
- deleteWidget(whereInput: $input) {
476
- nodesDeleted
477
- }
478
- }
479
- `;
480
- yield this.graphQlClient.mutate(MUTATION, {
481
- input: { id: request },
482
- });
483
- return request;
484
- });
485
- }
486
- createInstrument(request) {
487
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
488
- const mutation = `
489
- mutation($input: CreateInstrumentInput!) {
490
- createInstrument(createInstrumentInput: $input) {
491
- symbol
492
- uniqueKey
493
- }
494
- }
495
- `;
496
- const response = yield this.graphQlClient.mutate(mutation, {
497
- input: request,
498
- });
499
- const model = response.createInstrument;
500
- if (!model) {
501
- throw new core_1.SdkError(core_1.SdkErrorType.INVALID_TO_CREATE_INSTRUMENT);
502
- }
503
- const symbol = model.symbol || '';
504
- const uniqueKey = model.uniqueKey || '';
505
- return { instrumentKey: `${uniqueKey}/${symbol}`, symbol };
506
- });
507
- }
508
- deleteInstrument(request) {
509
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
510
- const mutation = `
511
- mutation($input: WhereInstrumentInput!) {
512
- deleteInstrument(whereInput: $input) {
513
- nodesDeleted
514
- }
515
- }
516
- `;
517
- yield this.graphQlClient.mutate(mutation, {
518
- input: { id: request },
519
- });
520
- return request;
521
- });
522
- }
523
- getWorkspaces(request) {
524
- var _a, _b, _c, _d, _e;
525
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
526
- const query = `
527
- query($id: String!) {
528
- project(id: $id) {
529
- id
530
- name
531
- client
532
- workspaces {
533
- id
534
- name
535
- widgets {
536
- id
537
- name
538
- type
539
- layout {
540
- x
541
- y
542
- draggable
543
- resizable
544
- }
545
- tableColumns {
546
- id
547
- field
548
- description
549
- visible
550
- active
551
- format
552
- }
553
- size {
554
- id
555
- width
556
- height
557
- minWidth
558
- minHeight
559
- maxWidth
560
- maxHeight
561
- x
562
- y
563
- draggable
564
- resizable
565
- }
566
- tickerConfiguration {
567
- id
568
- position
569
- size
570
- visible
571
- speed
572
- }
573
- tradedPackagesConfiguration {
574
- id
575
- scope
576
- }
577
- brokerageTradesConfiguration {
578
- id
579
- scope
580
- }
581
- brokerageConcentrationConfiguration {
582
- id
583
- scope
584
- }
585
- brokerageParticipationConfiguration {
586
- id
587
- broker
588
- instrumentType
589
- crosses
590
- purchases
591
- sales
592
- totals
593
- symbol
594
- }
595
- decreedRightsSearcherConfiguration {
596
- id
597
- scope
598
- endDate
599
- issuer
600
- limit
601
- offset
602
- startDate
603
- type
604
- }
605
- dynamicTableConfiguration {
606
- id
607
- period
608
- instrumentLimit
609
- field
610
- condition
611
- marketTypeId
612
- valueTypeIds
613
- exchangeId
614
- scope
615
- hasActivity
616
- isFiltered
617
- operatingCompany
618
- isYields
619
- }
620
- indicesComponentsConfiguration {
621
- id
622
- scope
623
- component
624
- sector
625
- type
626
- }
627
- instruments (
628
- options: ${((_b = (_a = request.params) === null || _a === void 0 ? void 0 : _a.instruments) === null || _b === void 0 ? void 0 : _b.options)
629
- ? (0, core_1.queryfy)((_d = (_c = request.params) === null || _c === void 0 ? void 0 : _c.instruments) === null || _d === void 0 ? void 0 : _d.options)
630
- : `{
631
- sort: {
632
- field: symbol,
633
- direction: ASC
634
- }
635
- offset: 0
636
- limit: 40
637
- }`}
638
- ) {
639
- symbol
640
- uniqueKey
641
- }
642
- }
643
- }
644
- }
645
- }
646
- `;
647
- const response = yield this.graphQlClient.query(query, {
648
- id: request.projectId,
649
- });
650
- const models = ((_e = response === null || response === void 0 ? void 0 : response.project) === null || _e === void 0 ? void 0 : _e.workspaces) || [];
651
- const { workspaces, widgets, instruments } = this.getMapperWorkspaces(models);
652
- return { workspaces, widgets, instruments };
653
- });
654
- }
655
- getWorkspace(request) {
656
- var _a, _b, _c;
657
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
658
- const query = `
659
- query ($id: String!) {
660
- workspace(id: $id) {
661
- id
662
- name
663
- widgets {
664
- id
665
- name
666
- type
667
- layout {
668
- x
669
- y
670
- draggable
671
- resizable
672
- }
673
- tableColumns {
674
- id
675
- field
676
- description
677
- visible
678
- active
679
- format
680
- }
681
- size {
682
- id
683
- width
684
- height
685
- minWidth
686
- minHeight
687
- maxWidth
688
- maxHeight
689
- x
690
- y
691
- draggable
692
- resizable
693
- }
694
- tickerConfiguration {
695
- id
696
- position
697
- size
698
- visible
699
- speed
700
- }
701
- dynamicTableConfiguration {
702
- id
703
- period
704
- instrumentLimit
705
- field
706
- condition
707
- marketTypeId
708
- valueTypeIds
709
- exchangeId
710
- hasActivity
711
- scope
712
- isFiltered
713
- operatingCompany
714
- isYields
715
- }
716
- decreedRightsSearcherConfiguration {
717
- id
718
- scope
719
- endDate
720
- issuer
721
- limit
722
- offset
723
- startDate
724
- type
725
- }
726
- instruments {
727
- symbol
728
- uniqueKey
729
- }
730
- chartConfiguration {
731
- id
732
- globalConfiguration
733
- }
734
- marketTotalConfiguration {
735
- id
736
- scope
737
- }
738
- tradedPackagesConfiguration {
739
- id
740
- scope
741
- }
742
- brokerageTradesConfiguration {
743
- id
744
- scope
745
- }
746
- brokerageConcentrationConfiguration {
747
- id
748
- scope
749
- }
750
- brokerageParticipationConfiguration {
751
- id
752
- broker
753
- instrumentType
754
- crosses
755
- purchases
756
- sales
757
- totals
758
- symbol
759
- }
760
- indicesComponentsConfiguration {
761
- id
762
- scope
763
- component
764
- sector
765
- type
766
- }
767
- }
768
- }
769
- }
770
- `;
771
- const response = yield this.graphQlClient.query(query, {
772
- id: request.workspaceId,
773
- });
774
- const models = ((_a = response === null || response === void 0 ? void 0 : response.workspace) === null || _a === void 0 ? void 0 : _a.widgets) || [];
775
- const widgets = this.mapper.mapWidgets(models);
776
- return {
777
- id: ((_b = response.workspace) === null || _b === void 0 ? void 0 : _b.id) || '-',
778
- name: ((_c = response.workspace) === null || _c === void 0 ? void 0 : _c.name) || 'unknown workspace',
779
- widgets,
780
- };
781
- });
782
- }
783
- getWorkspacesByUser(request) {
784
- var _a;
785
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
786
- const query = `
787
- query($id: String!) {
788
- user(id: $id) {
789
- id
790
- workspaces {
791
- id
792
- name
793
- widgets {
794
- id
795
- name
796
- type
797
- layout {
798
- x
799
- y
800
- draggable
801
- resizable
802
- }
803
- tableColumns {
804
- id
805
- field
806
- description
807
- visible
808
- active
809
- format
810
- }
811
- size {
812
- id
813
- width
814
- height
815
- minWidth
816
- minHeight
817
- maxWidth
818
- maxHeight
819
- }
820
- tickerConfiguration {
821
- id
822
- position
823
- size
824
- visible
825
- speed
826
- }
827
- instruments {
828
- symbol
829
- uniqueKey
830
- }
831
- }
832
- }
833
- }
834
- }
835
- `;
836
- const response = yield this.graphQlClient.query(query, {
837
- id: request.userId,
838
- });
839
- const models = ((_a = response === null || response === void 0 ? void 0 : response.user) === null || _a === void 0 ? void 0 : _a.workspaces) || [];
840
- const { workspaces, widgets, instruments } = this.getMapperWorkspaces(models);
841
- return { workspaces, widgets, instruments };
842
- });
843
- }
844
- getProjectWidgets(request) {
845
- var _a, _b, _c, _d, _e, _f, _g;
846
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
847
- const query = `
848
- query($id: String!) {
849
- project(id: $id) {
850
- id
851
- name
852
- client
853
- widgets {
854
- id
855
- name
856
- type
857
- tickerConfiguration {
858
- id
859
- position
860
- size
861
- visible
862
- speed
863
- }
864
- layout {
865
- x
866
- y
867
- draggable
868
- resizable
869
- }
870
- tableColumns {
871
- id
872
- field
873
- description
874
- visible
875
- active
876
- format
877
- }
878
- size {
879
- id
880
- width
881
- height
882
- minWidth
883
- minHeight
884
- maxWidth
885
- maxHeight
886
- }
887
- instruments (
888
- options: ${((_b = (_a = request.params) === null || _a === void 0 ? void 0 : _a.instruments) === null || _b === void 0 ? void 0 : _b.options)
889
- ? (0, core_1.queryfy)((_d = (_c = request.params) === null || _c === void 0 ? void 0 : _c.instruments) === null || _d === void 0 ? void 0 : _d.options)
890
- : `{
891
- sort: {
892
- field: symbol,
893
- direction: ASC
894
- }
895
- offset: 0
896
- limit: 40
897
- }`}
898
- ) {
899
- symbol
900
- uniqueKey
901
- }
902
- }
903
- }
904
- }
905
- `;
906
- const response = yield this.graphQlClient.query(query, {
907
- id: request.projectId,
908
- });
909
- const widgetsProject = ((_e = response.project) === null || _e === void 0 ? void 0 : _e.widgets) || [];
910
- const widgets = this.mapper.mapWidgets(widgetsProject);
911
- const instrumentsHolder = {};
912
- const instruments = widgetsProject
913
- .flat()
914
- .reduce((holder, widget) => {
915
- const id = widget.id || '-';
916
- holder[id] = this.mapper.mapInstruments(widget.instruments || []);
917
- return holder;
918
- }, instrumentsHolder);
919
- return {
920
- id: ((_f = response.project) === null || _f === void 0 ? void 0 : _f.id) || '-',
921
- name: ((_g = response.project) === null || _g === void 0 ? void 0 : _g.name) || '',
922
- widgets,
923
- instruments,
924
- };
925
- });
926
- }
927
- getInstruments(request) {
928
- var _a, _b, _c, _d, _e;
929
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
930
- const query = `
931
- query($input: WidgetLastInput!) {
932
- widgetInstrumentLast(lastInput:$input) {
933
- instruments {
934
- symbol
935
- uniqueKey
936
- fields
937
- }
938
- }
939
- }
940
- `;
941
- const input = Object.fromEntries(Object.entries({
942
- widgetId: request.widgetId,
943
- columnSort: (_a = request.sort) === null || _a === void 0 ? void 0 : _a.column,
944
- sortDirection: (_b = request.sort) === null || _b === void 0 ? void 0 : _b.direction,
945
- offset: (_c = request.pagination) === null || _c === void 0 ? void 0 : _c.offset,
946
- limit: (_d = request.pagination) === null || _d === void 0 ? void 0 : _d.limit,
947
- }).filter(([_, value]) => value !== undefined));
948
- const response = yield this.graphQlClient.query(query, { input });
949
- const instrumentModels = ((_e = response.widgetInstrumentLast) === null || _e === void 0 ? void 0 : _e.instruments) || [];
950
- const instruments = this.mapper.mapInstruments(instrumentModels);
951
- const fieldsHolder = {};
952
- const fields = instrumentModels.reduce((holder, model) => {
953
- const fieldsModel = this.mapper.parseInstrumentFields(model);
954
- const item = this.mapper.mapInstrumentFields(fieldsModel);
955
- holder[item.instrumentKey] = item;
956
- return holder;
957
- }, fieldsHolder);
958
- return { instruments, fields };
959
- });
960
9
  }
961
10
  getInstrumentFields(request) {
962
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const params = Object.fromEntries(Object.entries({
13
+ instrumentKey: request.instrumentKey,
14
+ useCache: request.useCache,
15
+ }).filter(([_, value]) => value !== undefined));
963
16
  const response = yield this.marketsHttpClient.get('/instruments/last', {
964
- params: { instrumentKey: request },
17
+ params,
965
18
  });
966
19
  const models = response.data || [];
967
20
  if (models.length <= 0) {
@@ -973,8 +26,12 @@ class MarketsDatasourceImpl {
973
26
  }
974
27
  getInstrumentMultipleFields(request) {
975
28
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ const params = Object.fromEntries(Object.entries({
30
+ instrumentKey: request.instrumentKey,
31
+ useCache: request.useCache,
32
+ }).filter(([_, value]) => value !== undefined));
976
33
  const response = yield this.marketsHttpClient.get('/instruments/last', {
977
- params: { instrumentKey: request },
34
+ params,
978
35
  });
979
36
  const models = response.data || [];
980
37
  if (models.length <= 0) {
@@ -1179,37 +236,6 @@ class MarketsDatasourceImpl {
1179
236
  };
1180
237
  });
1181
238
  }
1182
- getWorkspacesByProjectId(request) {
1183
- var _a;
1184
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
1185
- const query = `
1186
- query($id: String!) {
1187
- project(id: $id) {
1188
- id
1189
- name
1190
- client
1191
- workspaces {
1192
- id
1193
- name
1194
- createdAt
1195
- updatedAt
1196
- widgets {
1197
- id
1198
- name
1199
- type
1200
- }
1201
- }
1202
- }
1203
- }
1204
- `;
1205
- const response = yield this.graphQlClient.query(query, {
1206
- id: request.projectId,
1207
- });
1208
- const models = ((_a = response === null || response === void 0 ? void 0 : response.project) === null || _a === void 0 ? void 0 : _a.workspaces) || [];
1209
- const { workspaces, widgets, instruments } = this.getMapperWorkspaces(models);
1210
- return { workspaces, widgets, instruments };
1211
- });
1212
- }
1213
239
  }
1214
240
  exports.default = MarketsDatasourceImpl;
1215
241
  //# sourceMappingURL=markets_datasource_impl.js.map