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