@neuralinnovations/dataisland-sdk 0.0.1-dev5 → 0.0.1-dev51

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 (372) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +283 -37
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/package.json +103 -0
  8. package/dist/src/appBuilder.d.ts +44 -0
  9. package/dist/src/appBuilder.d.ts.map +1 -0
  10. package/dist/src/appBuilder.js +10 -0
  11. package/dist/src/appBuilder.js.map +1 -0
  12. package/dist/src/commands/deleteUserFullCommandHandler.d.ts +7 -0
  13. package/dist/src/commands/deleteUserFullCommandHandler.d.ts.map +1 -0
  14. package/dist/src/commands/deleteUserFullCommandHandler.js +21 -0
  15. package/dist/src/commands/deleteUserFullCommandHandler.js.map +1 -0
  16. package/dist/src/commands/startCommandHandler.d.ts +7 -0
  17. package/dist/src/commands/startCommandHandler.d.ts.map +1 -0
  18. package/dist/src/commands/startCommandHandler.js +30 -0
  19. package/dist/src/commands/startCommandHandler.js.map +1 -0
  20. package/dist/src/context.d.ts +24 -0
  21. package/dist/src/context.d.ts.map +1 -0
  22. package/dist/src/context.js +31 -0
  23. package/dist/src/context.js.map +1 -0
  24. package/dist/src/credentials.d.ts +33 -0
  25. package/dist/src/credentials.d.ts.map +1 -0
  26. package/dist/src/credentials.js +87 -0
  27. package/dist/src/credentials.js.map +1 -0
  28. package/dist/src/dataIslandApp.d.ts +55 -0
  29. package/dist/src/dataIslandApp.d.ts.map +1 -0
  30. package/dist/src/dataIslandApp.js +10 -0
  31. package/dist/src/dataIslandApp.js.map +1 -0
  32. package/dist/src/disposable.d.ts +84 -0
  33. package/dist/src/disposable.d.ts.map +1 -0
  34. package/dist/src/disposable.js +147 -0
  35. package/dist/src/disposable.js.map +1 -0
  36. package/dist/src/dto/accessGroupResponse.d.ts +30 -0
  37. package/dist/src/dto/accessGroupResponse.d.ts.map +1 -0
  38. package/dist/src/dto/accessGroupResponse.js +3 -0
  39. package/dist/src/dto/accessGroupResponse.js.map +1 -0
  40. package/dist/src/dto/acquiringResponse.d.ts +46 -0
  41. package/dist/src/dto/acquiringResponse.d.ts.map +1 -0
  42. package/dist/src/dto/acquiringResponse.js +11 -0
  43. package/dist/src/dto/acquiringResponse.js.map +1 -0
  44. package/dist/src/dto/badRequestResponse.d.ts +6 -0
  45. package/dist/src/dto/badRequestResponse.d.ts.map +1 -0
  46. package/dist/src/dto/badRequestResponse.js +3 -0
  47. package/dist/src/dto/badRequestResponse.js.map +1 -0
  48. package/dist/src/dto/chatResponse.d.ts +83 -0
  49. package/dist/src/dto/chatResponse.d.ts.map +1 -0
  50. package/dist/src/dto/chatResponse.js +45 -0
  51. package/dist/src/dto/chatResponse.js.map +1 -0
  52. package/dist/src/dto/limitsResponse.d.ts +29 -0
  53. package/dist/src/dto/limitsResponse.d.ts.map +1 -0
  54. package/dist/src/dto/limitsResponse.js +13 -0
  55. package/dist/src/dto/limitsResponse.js.map +1 -0
  56. package/dist/src/dto/statisticsResponse.d.ts +11 -0
  57. package/dist/src/dto/statisticsResponse.d.ts.map +1 -0
  58. package/dist/src/dto/statisticsResponse.js +3 -0
  59. package/dist/src/dto/statisticsResponse.js.map +1 -0
  60. package/dist/src/dto/userInfoResponse.d.ts +88 -0
  61. package/dist/src/dto/userInfoResponse.d.ts.map +1 -0
  62. package/dist/src/dto/userInfoResponse.js +3 -0
  63. package/dist/src/dto/userInfoResponse.js.map +1 -0
  64. package/dist/src/dto/workspacesResponse.d.ts +45 -0
  65. package/dist/src/dto/workspacesResponse.d.ts.map +1 -0
  66. package/dist/src/dto/workspacesResponse.js +3 -0
  67. package/dist/src/dto/workspacesResponse.js.map +1 -0
  68. package/dist/src/events.d.ts +17 -0
  69. package/dist/src/events.d.ts.map +1 -0
  70. package/dist/src/events.js +52 -0
  71. package/dist/src/events.js.map +1 -0
  72. package/dist/src/index.d.ts +72 -0
  73. package/dist/src/index.d.ts.map +1 -0
  74. package/dist/src/index.js +121 -0
  75. package/dist/src/index.js.map +1 -0
  76. package/dist/src/internal/app.impl.d.ts +30 -0
  77. package/dist/src/internal/app.impl.d.ts.map +1 -0
  78. package/dist/src/internal/app.impl.js +180 -0
  79. package/dist/src/internal/app.impl.js.map +1 -0
  80. package/dist/src/internal/appBuilder.impl.d.ts +27 -0
  81. package/dist/src/internal/appBuilder.impl.d.ts.map +1 -0
  82. package/dist/src/internal/appBuilder.impl.js +71 -0
  83. package/dist/src/internal/appBuilder.impl.js.map +1 -0
  84. package/dist/src/internal/createApp.impl.d.ts +4 -0
  85. package/dist/src/internal/createApp.impl.d.ts.map +1 -0
  86. package/dist/src/internal/createApp.impl.js +11 -0
  87. package/dist/src/internal/createApp.impl.js.map +1 -0
  88. package/dist/src/internal/registry.d.ts +66 -0
  89. package/dist/src/internal/registry.d.ts.map +1 -0
  90. package/dist/src/internal/registry.js +114 -0
  91. package/dist/src/internal/registry.js.map +1 -0
  92. package/dist/src/middleware.d.ts +6 -0
  93. package/dist/src/middleware.d.ts.map +1 -0
  94. package/dist/src/middleware.js +3 -0
  95. package/dist/src/middleware.js.map +1 -0
  96. package/dist/src/services/acquiringService.d.ts +9 -0
  97. package/dist/src/services/acquiringService.d.ts.map +1 -0
  98. package/dist/src/services/acquiringService.js +19 -0
  99. package/dist/src/services/acquiringService.js.map +1 -0
  100. package/dist/src/services/anonymousService.d.ts +8 -0
  101. package/dist/src/services/anonymousService.d.ts.map +1 -0
  102. package/dist/src/services/anonymousService.js +41 -0
  103. package/dist/src/services/anonymousService.js.map +1 -0
  104. package/dist/src/services/commandService.d.ts +18 -0
  105. package/dist/src/services/commandService.d.ts.map +1 -0
  106. package/dist/src/services/commandService.js +40 -0
  107. package/dist/src/services/commandService.js.map +1 -0
  108. package/dist/src/services/cookieService.d.ts +7 -0
  109. package/dist/src/services/cookieService.d.ts.map +1 -0
  110. package/dist/src/services/cookieService.js +18 -0
  111. package/dist/src/services/cookieService.js.map +1 -0
  112. package/dist/src/services/credentialService.d.ts +9 -0
  113. package/dist/src/services/credentialService.d.ts.map +1 -0
  114. package/dist/src/services/credentialService.js +26 -0
  115. package/dist/src/services/credentialService.js.map +1 -0
  116. package/dist/src/services/httpMethod.d.ts +2 -0
  117. package/dist/src/services/httpMethod.d.ts.map +1 -0
  118. package/dist/src/services/httpMethod.js +3 -0
  119. package/dist/src/services/httpMethod.js.map +1 -0
  120. package/dist/src/services/middlewareService.d.ts +10 -0
  121. package/dist/src/services/middlewareService.d.ts.map +1 -0
  122. package/dist/src/services/middlewareService.js +34 -0
  123. package/dist/src/services/middlewareService.js.map +1 -0
  124. package/dist/src/services/organizationService.d.ts +10 -0
  125. package/dist/src/services/organizationService.d.ts.map +1 -0
  126. package/dist/src/services/organizationService.js +19 -0
  127. package/dist/src/services/organizationService.js.map +1 -0
  128. package/dist/src/services/requestBuilder.d.ts +17 -0
  129. package/dist/src/services/requestBuilder.d.ts.map +1 -0
  130. package/dist/src/services/requestBuilder.js +105 -0
  131. package/dist/src/services/requestBuilder.js.map +1 -0
  132. package/dist/src/services/responseUtils.d.ts +8 -0
  133. package/dist/src/services/responseUtils.d.ts.map +1 -0
  134. package/dist/src/services/responseUtils.js +40 -0
  135. package/dist/src/services/responseUtils.js.map +1 -0
  136. package/dist/src/services/rpcService.d.ts +77 -0
  137. package/dist/src/services/rpcService.d.ts.map +1 -0
  138. package/dist/src/services/rpcService.js +125 -0
  139. package/dist/src/services/rpcService.js.map +1 -0
  140. package/dist/src/services/service.d.ts +21 -0
  141. package/dist/src/services/service.d.ts.map +1 -0
  142. package/dist/src/services/service.js +41 -0
  143. package/dist/src/services/service.js.map +1 -0
  144. package/dist/src/services/userProfileService.d.ts +10 -0
  145. package/dist/src/services/userProfileService.d.ts.map +1 -0
  146. package/dist/src/services/userProfileService.js +59 -0
  147. package/dist/src/services/userProfileService.js.map +1 -0
  148. package/dist/src/storages/acquirings/acquiring.d.ts +41 -0
  149. package/dist/src/storages/acquirings/acquiring.d.ts.map +1 -0
  150. package/dist/src/storages/acquirings/acquiring.impl.d.ts +20 -0
  151. package/dist/src/storages/acquirings/acquiring.impl.d.ts.map +1 -0
  152. package/dist/src/storages/acquirings/acquiring.impl.js +92 -0
  153. package/dist/src/storages/acquirings/acquiring.impl.js.map +1 -0
  154. package/dist/src/storages/acquirings/acquiring.js +10 -0
  155. package/dist/src/storages/acquirings/acquiring.js.map +1 -0
  156. package/dist/src/storages/chats/answer.d.ts +41 -0
  157. package/dist/src/storages/chats/answer.d.ts.map +1 -0
  158. package/dist/src/storages/chats/answer.impl.d.ts +29 -0
  159. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -0
  160. package/dist/src/storages/chats/answer.impl.js +116 -0
  161. package/dist/src/storages/chats/answer.impl.js.map +1 -0
  162. package/dist/src/storages/chats/answer.js +15 -0
  163. package/dist/src/storages/chats/answer.js.map +1 -0
  164. package/dist/src/storages/chats/chat.d.ts +43 -0
  165. package/dist/src/storages/chats/chat.d.ts.map +1 -0
  166. package/dist/src/storages/chats/chat.impl.d.ts +25 -0
  167. package/dist/src/storages/chats/chat.impl.d.ts.map +1 -0
  168. package/dist/src/storages/chats/chat.impl.js +85 -0
  169. package/dist/src/storages/chats/chat.impl.js.map +1 -0
  170. package/dist/src/storages/chats/chat.js +12 -0
  171. package/dist/src/storages/chats/chat.js.map +1 -0
  172. package/dist/src/storages/chats/chats.d.ts +45 -0
  173. package/dist/src/storages/chats/chats.d.ts.map +1 -0
  174. package/dist/src/storages/chats/chats.impl.d.ts +19 -0
  175. package/dist/src/storages/chats/chats.impl.d.ts.map +1 -0
  176. package/dist/src/storages/chats/chats.impl.js +147 -0
  177. package/dist/src/storages/chats/chats.impl.js.map +1 -0
  178. package/dist/src/storages/chats/chats.js +16 -0
  179. package/dist/src/storages/chats/chats.js.map +1 -0
  180. package/dist/src/storages/files/file.d.ts +47 -0
  181. package/dist/src/storages/files/file.d.ts.map +1 -0
  182. package/dist/src/storages/files/file.impl.d.ts +25 -0
  183. package/dist/src/storages/files/file.impl.d.ts.map +1 -0
  184. package/dist/src/storages/files/file.impl.js +93 -0
  185. package/dist/src/storages/files/file.impl.js.map +1 -0
  186. package/dist/src/storages/files/file.js +17 -0
  187. package/dist/src/storages/files/file.js.map +1 -0
  188. package/dist/src/storages/files/files.d.ts +39 -0
  189. package/dist/src/storages/files/files.d.ts.map +1 -0
  190. package/dist/src/storages/files/files.impl.d.ts +24 -0
  191. package/dist/src/storages/files/files.impl.d.ts.map +1 -0
  192. package/dist/src/storages/files/files.impl.js +168 -0
  193. package/dist/src/storages/files/files.impl.js.map +1 -0
  194. package/dist/src/storages/files/files.js +20 -0
  195. package/dist/src/storages/files/files.js.map +1 -0
  196. package/dist/src/storages/files/filesPage.d.ts +28 -0
  197. package/dist/src/storages/files/filesPage.d.ts.map +1 -0
  198. package/dist/src/storages/files/filesPage.impl.d.ts +15 -0
  199. package/dist/src/storages/files/filesPage.impl.d.ts.map +1 -0
  200. package/dist/src/storages/files/filesPage.impl.js +38 -0
  201. package/dist/src/storages/files/filesPage.impl.js.map +1 -0
  202. package/dist/src/storages/files/filesPage.js +10 -0
  203. package/dist/src/storages/files/filesPage.js.map +1 -0
  204. package/dist/src/storages/groups/group.d.ts +63 -0
  205. package/dist/src/storages/groups/group.d.ts.map +1 -0
  206. package/dist/src/storages/groups/group.impl.d.ts +38 -0
  207. package/dist/src/storages/groups/group.impl.d.ts.map +1 -0
  208. package/dist/src/storages/groups/group.impl.js +210 -0
  209. package/dist/src/storages/groups/group.impl.js.map +1 -0
  210. package/dist/src/storages/groups/group.js +15 -0
  211. package/dist/src/storages/groups/group.js.map +1 -0
  212. package/dist/src/storages/groups/groups.d.ts +39 -0
  213. package/dist/src/storages/groups/groups.d.ts.map +1 -0
  214. package/dist/src/storages/groups/groups.impl.d.ts +30 -0
  215. package/dist/src/storages/groups/groups.impl.d.ts.map +1 -0
  216. package/dist/src/storages/groups/groups.impl.js +132 -0
  217. package/dist/src/storages/groups/groups.impl.js.map +1 -0
  218. package/dist/src/storages/groups/groups.js +20 -0
  219. package/dist/src/storages/groups/groups.js.map +1 -0
  220. package/dist/src/storages/organizations/organization.d.ts +96 -0
  221. package/dist/src/storages/organizations/organization.d.ts.map +1 -0
  222. package/dist/src/storages/organizations/organization.impl.d.ts +42 -0
  223. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -0
  224. package/dist/src/storages/organizations/organization.impl.js +249 -0
  225. package/dist/src/storages/organizations/organization.impl.js.map +1 -0
  226. package/dist/src/storages/organizations/organization.js +18 -0
  227. package/dist/src/storages/organizations/organization.js.map +1 -0
  228. package/dist/src/storages/organizations/organizations.d.ts +46 -0
  229. package/dist/src/storages/organizations/organizations.d.ts.map +1 -0
  230. package/dist/src/storages/organizations/organizations.impl.d.ts +38 -0
  231. package/dist/src/storages/organizations/organizations.impl.d.ts.map +1 -0
  232. package/dist/src/storages/organizations/organizations.impl.js +158 -0
  233. package/dist/src/storages/organizations/organizations.impl.js.map +1 -0
  234. package/dist/src/storages/organizations/organizations.js +20 -0
  235. package/dist/src/storages/organizations/organizations.js.map +1 -0
  236. package/dist/src/storages/user/userProfile.d.ts +55 -0
  237. package/dist/src/storages/user/userProfile.d.ts.map +1 -0
  238. package/dist/src/storages/user/userProfile.impl.d.ts +21 -0
  239. package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -0
  240. package/dist/src/storages/user/userProfile.impl.js +113 -0
  241. package/dist/src/storages/user/userProfile.impl.js.map +1 -0
  242. package/dist/src/storages/user/userProfile.js +12 -0
  243. package/dist/src/storages/user/userProfile.js.map +1 -0
  244. package/dist/src/storages/workspaces/workspace.d.ts +44 -0
  245. package/dist/src/storages/workspaces/workspace.d.ts.map +1 -0
  246. package/dist/src/storages/workspaces/workspace.impl.d.ts +23 -0
  247. package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -0
  248. package/dist/src/storages/workspaces/workspace.impl.js +98 -0
  249. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -0
  250. package/dist/src/storages/workspaces/workspace.js +18 -0
  251. package/dist/src/storages/workspaces/workspace.js.map +1 -0
  252. package/dist/src/storages/workspaces/workspaces.d.ts +47 -0
  253. package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -0
  254. package/dist/src/storages/workspaces/workspaces.impl.d.ts +33 -0
  255. package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -0
  256. package/dist/src/storages/workspaces/workspaces.impl.js +152 -0
  257. package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -0
  258. package/dist/src/storages/workspaces/workspaces.js +19 -0
  259. package/dist/src/storages/workspaces/workspaces.js.map +1 -0
  260. package/dist/src/unitTest.d.ts +12 -0
  261. package/dist/src/unitTest.d.ts.map +1 -0
  262. package/dist/src/unitTest.js +44 -0
  263. package/dist/src/unitTest.js.map +1 -0
  264. package/dist/src/utils/browserUtils.d.ts +4 -0
  265. package/dist/src/utils/browserUtils.d.ts.map +1 -0
  266. package/dist/src/utils/browserUtils.js +64 -0
  267. package/dist/src/utils/browserUtils.js.map +1 -0
  268. package/dist/src/utils/request.d.ts +6 -0
  269. package/dist/src/utils/request.d.ts.map +1 -0
  270. package/dist/src/utils/request.js +3 -0
  271. package/dist/src/utils/request.js.map +1 -0
  272. package/dist/src/utils/utils.d.ts +3 -0
  273. package/dist/src/utils/utils.d.ts.map +1 -0
  274. package/dist/src/utils/utils.js +13 -0
  275. package/dist/src/utils/utils.js.map +1 -0
  276. package/index.d.ts +1 -0
  277. package/index.js +1 -0
  278. package/package.json +46 -5
  279. package/src/commands/deleteUserFullCommandHandler.ts +19 -0
  280. package/src/commands/startCommandHandler.ts +19 -5
  281. package/src/context.ts +4 -2
  282. package/src/credentials.ts +22 -0
  283. package/src/dataIslandApp.ts +8 -2
  284. package/src/disposable.ts +18 -5
  285. package/src/dto/accessGroupResponse.ts +19 -16
  286. package/src/dto/acquiringResponse.ts +54 -0
  287. package/src/dto/badRequestResponse.ts +6 -0
  288. package/src/dto/chatResponse.ts +59 -54
  289. package/src/dto/limitsResponse.ts +32 -0
  290. package/src/dto/statisticsResponse.ts +12 -0
  291. package/src/dto/userInfoResponse.ts +59 -2
  292. package/src/dto/workspacesResponse.ts +5 -3
  293. package/src/index.ts +56 -16
  294. package/src/internal/app.impl.ts +54 -12
  295. package/src/internal/registry.ts +54 -6
  296. package/src/middleware.ts +2 -0
  297. package/src/services/acquiringService.ts +21 -0
  298. package/src/services/anonymousService.ts +43 -0
  299. package/src/services/commandService.ts +4 -2
  300. package/src/services/cookieService.ts +16 -0
  301. package/src/services/httpMethod.ts +1 -0
  302. package/src/services/middlewareService.ts +1 -0
  303. package/src/services/organizationService.ts +2 -2
  304. package/src/services/requestBuilder.ts +10 -8
  305. package/src/services/responseUtils.ts +12 -0
  306. package/src/services/rpcService.ts +1 -0
  307. package/src/services/userProfileService.ts +36 -4
  308. package/src/storages/acquirings/acquiring.impl.ts +132 -0
  309. package/src/storages/acquirings/acquiring.ts +54 -0
  310. package/src/storages/chats/answer.impl.ts +160 -0
  311. package/src/storages/chats/answer.ts +53 -0
  312. package/src/storages/chats/chat.impl.ts +107 -0
  313. package/src/storages/chats/chat.ts +55 -0
  314. package/src/storages/chats/chats.impl.ts +204 -0
  315. package/src/storages/chats/chats.ts +53 -0
  316. package/src/storages/files/file.impl.ts +111 -0
  317. package/src/storages/files/file.ts +58 -0
  318. package/src/storages/{files.impl.ts → files/files.impl.ts} +67 -46
  319. package/src/storages/{files.ts → files/files.ts} +14 -7
  320. package/src/storages/files/filesPage.impl.ts +37 -0
  321. package/src/storages/{filesPage.ts → files/filesPage.ts} +6 -0
  322. package/src/storages/groups/group.impl.ts +276 -0
  323. package/src/storages/groups/group.ts +73 -0
  324. package/src/storages/groups/groups.impl.ts +175 -0
  325. package/src/storages/groups/groups.ts +45 -0
  326. package/src/storages/organizations/organization.impl.ts +378 -0
  327. package/src/storages/organizations/organization.ts +120 -0
  328. package/src/storages/{organizations.impl.ts → organizations/organizations.impl.ts} +31 -13
  329. package/src/storages/{organizations.ts → organizations/organizations.ts} +1 -1
  330. package/src/storages/user/userProfile.impl.ts +135 -0
  331. package/src/storages/user/userProfile.ts +70 -0
  332. package/src/storages/{workspace.impl.ts → workspaces/workspace.impl.ts} +27 -7
  333. package/src/storages/{workspace.ts → workspaces/workspace.ts} +8 -3
  334. package/src/storages/{workspaces.impl.ts → workspaces/workspaces.impl.ts} +27 -32
  335. package/src/storages/{workspaces.ts → workspaces/workspaces.ts} +6 -2
  336. package/src/unitTest.ts +3 -3
  337. package/src/utils/browserUtils.ts +68 -0
  338. package/src/utils/request.ts +6 -0
  339. package/src/utils/utils.ts +8 -0
  340. package/.browserslistrc +0 -5
  341. package/.editorconfig +0 -25
  342. package/.eslintrc.json +0 -44
  343. package/.github/workflows/publish-npm.yml +0 -28
  344. package/.prettierignore +0 -1
  345. package/.prettierrc +0 -11
  346. package/.yarnrc +0 -2
  347. package/babel.config.js +0 -6
  348. package/jest.config.ts +0 -199
  349. package/jest.setup.ts +0 -2
  350. package/src/storages/chat.ts +0 -21
  351. package/src/storages/chats.ts +0 -17
  352. package/src/storages/file.impl.ts +0 -69
  353. package/src/storages/file.ts +0 -28
  354. package/src/storages/groups.impl.ts +0 -337
  355. package/src/storages/groups.ts +0 -43
  356. package/src/storages/organization.impl.ts +0 -68
  357. package/src/storages/organization.ts +0 -33
  358. package/src/storages/userProfile.impl.ts +0 -56
  359. package/src/storages/userProfile.ts +0 -42
  360. package/test/commands.test.ts +0 -24
  361. package/test/data/test_file.pdf +0 -0
  362. package/test/disposable.test.ts +0 -39
  363. package/test/events.test.ts +0 -151
  364. package/test/files.test.ts +0 -52
  365. package/test/index.test.ts +0 -122
  366. package/test/organization.test.ts +0 -57
  367. package/test/registry.test.ts +0 -44
  368. package/test/services.test.ts +0 -56
  369. package/test/setup.ts +0 -54
  370. package/test/unitTest.test.ts +0 -21
  371. package/test/workspace.test.ts +0 -71
  372. package/tsconfig.json +0 -31
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupsImpl = void 0;
4
+ const rpcService_1 = require("../../services/rpcService");
5
+ const groups_1 = require("./groups");
6
+ const responseUtils_1 = require("../../services/responseUtils");
7
+ const group_impl_1 = require("./group.impl");
8
+ class GroupsImpl extends groups_1.Groups {
9
+ constructor(organization, context) {
10
+ super();
11
+ this.organization = organization;
12
+ this.context = context;
13
+ this._groups = [];
14
+ }
15
+ get collection() {
16
+ return this._groups;
17
+ }
18
+ async initialize() {
19
+ await this.internalInit();
20
+ }
21
+ async create(name, permits, memberIds) {
22
+ return await this.internalCreate(name, permits, memberIds);
23
+ }
24
+ get(id) {
25
+ return this._groups.find(group => group.id === id);
26
+ }
27
+ async delete(id) {
28
+ return await this.internalDeleteGroup(id);
29
+ }
30
+ //----------------------------------------------------------------------------
31
+ // INTERNALS
32
+ //----------------------------------------------------------------------------
33
+ /**
34
+ * Init access groups.
35
+ */
36
+ async internalInit() {
37
+ var _a;
38
+ // fetch groups
39
+ const response = await ((_a = this.context.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Organizations/access_groups").searchParam("id", this.organization.id).sendGet());
40
+ // check response status
41
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
42
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get groups for organization: ${this.organization.id}`, response);
43
+ }
44
+ // parse groups from the server's response
45
+ const groups = (await response.json());
46
+ const wait = [];
47
+ // init groups
48
+ for (const gr of groups.groups) {
49
+ // create group implementation
50
+ const group = new group_impl_1.GroupImpl(this.context, this.organization).initFrom(gr.id);
51
+ // add to the wait list
52
+ wait.push(group);
53
+ }
54
+ // wait for all groups
55
+ const groupsResult = await Promise.all(wait);
56
+ // add groups to the collection
57
+ for (const group of groupsResult) {
58
+ // add group to the collection
59
+ this._groups.push(group);
60
+ }
61
+ }
62
+ async internalCreate(name, permits, memberIds) {
63
+ var _a;
64
+ if (name === undefined || name === null) {
65
+ throw new Error("Group create, name is undefined or null");
66
+ }
67
+ if (name.length === 0 || name.trim().length === 0) {
68
+ throw new Error("Group create, name is empty");
69
+ }
70
+ // send request to the server
71
+ const response = await ((_a = this.context
72
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups").sendPostJson({
73
+ name: name,
74
+ organizationId: this.organization.id,
75
+ permits: permits,
76
+ memberIds: memberIds
77
+ }));
78
+ // check response status
79
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
80
+ await responseUtils_1.ResponseUtils.throwError(`Failed to create group, organization: ${this.organization.id}`, response);
81
+ }
82
+ // parse group from the server's response
83
+ const content = (await response.json());
84
+ // create group implementation
85
+ const group = await new group_impl_1.GroupImpl(this.context, this.organization).initFrom(content.group.id);
86
+ // add group to the collection
87
+ this._groups.push(group);
88
+ // dispatch event
89
+ this.dispatch({
90
+ type: groups_1.GroupsEvent.ADDED,
91
+ data: group
92
+ });
93
+ return group;
94
+ }
95
+ /**
96
+ * Delete group.
97
+ * @param id
98
+ */
99
+ async internalDeleteGroup(id) {
100
+ var _a;
101
+ if (id === undefined || id === null) {
102
+ throw new Error("Group delete, id is undefined or null");
103
+ }
104
+ if (id.length === 0 || id.trim().length === 0) {
105
+ throw new Error("Group delete, id is empty");
106
+ }
107
+ // send request to the server
108
+ const response = await ((_a = this.context
109
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("/api/v1/AccessGroups").searchParam("groupId", id).sendDelete());
110
+ // check response status
111
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
112
+ await responseUtils_1.ResponseUtils.throwError(`Failed to delete group: ${id}, organization: ${this.organization.id}`, response);
113
+ }
114
+ // delete group from collection
115
+ const group = this._groups.find(f => f.id === id);
116
+ const index = this._groups.indexOf(group);
117
+ if (index < 0) {
118
+ throw new Error("Group delete, index is not found");
119
+ }
120
+ // remove group from collection
121
+ this._groups.splice(index, 1);
122
+ // dispatch event, group removed
123
+ this.dispatch({
124
+ type: groups_1.GroupsEvent.REMOVED,
125
+ data: group
126
+ });
127
+ // dispose group
128
+ group.dispose();
129
+ }
130
+ }
131
+ exports.GroupsImpl = GroupsImpl;
132
+ //# sourceMappingURL=groups.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.impl.js","sourceRoot":"","sources":["../../../../src/storages/groups/groups.impl.ts"],"names":[],"mappings":";;;AAKA,0DAAsD;AACtD,qCAA8C;AAE9C,gEAA4D;AAE5D,6CAAwC;AAExC,MAAa,UAAW,SAAQ,eAAM;IAIpC,YACkB,YAA8B,EAC7B,OAAgB;QAEjC,KAAK,EAAE,CAAA;QAHS,iBAAY,GAAZ,YAAY,CAAkB;QAC7B,YAAO,GAAP,OAAO,CAAS;QAJ3B,YAAO,GAAY,EAAE,CAAA;IAO7B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,OAE1B,EAAE,SAAmB;QACpB,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC5D,CAAC;IAED,GAAG,CAAC,EAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAW;QACtB,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,8EAA8E;IAC9E,YAAY;IACZ,8EAA8E;IAE9E;;OAEG;IACH,KAAK,CAAC,YAAY;;QAChB,eAAe;QACf,MAAM,QAAQ,GAAG,MAAM,CA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SACZ,CAAC,CAAA;QAEF,gBAAgB;QAChB,KAAK,CAAC,OAAO,EAAE,CAAA;IACjB,CAAC;CACF;AAlKD,gCAkKC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Groups = exports.GroupsEvent = void 0;
4
+ const events_1 = require("../../events");
5
+ /**
6
+ * Group event.
7
+ */
8
+ var GroupsEvent;
9
+ (function (GroupsEvent) {
10
+ GroupsEvent["ADDED"] = "added";
11
+ GroupsEvent["REMOVED"] = "removed";
12
+ GroupsEvent["UPDATED"] = "updated";
13
+ })(GroupsEvent || (exports.GroupsEvent = GroupsEvent = {}));
14
+ /**
15
+ * Groups storage.
16
+ */
17
+ class Groups extends events_1.EventDispatcher {
18
+ }
19
+ exports.Groups = Groups;
20
+ //# sourceMappingURL=groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../../src/storages/groups/groups.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAG9C;;GAEG;AACH,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAED;;GAEG;AACH,MAAsB,MAAO,SAAQ,wBAAmC;CA6BvE;AA7BD,wBA6BC"}
@@ -0,0 +1,96 @@
1
+ import { Workspaces } from "../workspaces/workspaces";
2
+ import { OrganizationId } from "./organizations";
3
+ import { Groups } from "../groups/groups";
4
+ import { Chats } from "../chats/chats";
5
+ import { EventDispatcher } from "../../events";
6
+ import { CurrentLimitsData, UserDto, UsersStatisticsResponse } from "../../dto/userInfoResponse";
7
+ import { GroupId } from "../groups/group";
8
+ import { StatisticsResponse } from "../../dto/statisticsResponse";
9
+ import { SegmentData } from "../../dto/limitsResponse";
10
+ /**
11
+ * Organization event.
12
+ */
13
+ export declare enum OrganizationEvent {
14
+ CHANGED = "changed"
15
+ }
16
+ /**
17
+ * Organization.
18
+ */
19
+ export declare abstract class Organization extends EventDispatcher<OrganizationEvent, Organization> {
20
+ /**
21
+ * Organization id.
22
+ */
23
+ abstract get id(): OrganizationId;
24
+ /**
25
+ * Organization name.
26
+ */
27
+ abstract get name(): string;
28
+ /**
29
+ * Organization description.
30
+ */
31
+ abstract get description(): string;
32
+ /**
33
+ * Workspaces.
34
+ */
35
+ abstract get workspaces(): Workspaces;
36
+ /**
37
+ * Chats.
38
+ */
39
+ abstract get chats(): Chats;
40
+ /**
41
+ * Groups.
42
+ */
43
+ abstract get accessGroups(): Groups;
44
+ /**
45
+ * Get organization members
46
+ */
47
+ abstract members(): Promise<UserDto[]>;
48
+ /**
49
+ * Get organization statistics
50
+ * @param dateFrom
51
+ * @param dateTo
52
+ */
53
+ abstract statistics(dateFrom: number, dateTo: number): Promise<StatisticsResponse>;
54
+ /**
55
+ * Get organization statistics
56
+ * @param dateFrom
57
+ * @param dateTo
58
+ */
59
+ abstract membersStatistics(dateFrom: number, dateTo: number): Promise<UsersStatisticsResponse>;
60
+ /**
61
+ * Get statistics for user
62
+ * @param userid
63
+ * @param dateFrom
64
+ * @param dateTo
65
+ */
66
+ abstract userStatistic(userid: string, dateFrom: number, dateTo: number): Promise<StatisticsResponse>;
67
+ /**
68
+ * Get user limits data
69
+ */
70
+ abstract userLimits(): Promise<CurrentLimitsData>;
71
+ /**
72
+ * Get default organization limits
73
+ */
74
+ abstract organizationLimits(): Promise<SegmentData>;
75
+ /**
76
+ * Get all available segments data
77
+ */
78
+ abstract limitSegments(): Promise<SegmentData[]>;
79
+ /**
80
+ * Change organization name and description.
81
+ */
82
+ abstract change(name: string, description: string): Promise<void>;
83
+ /**
84
+ * Invite users with given emails to organization
85
+ */
86
+ abstract inviteUsers(emails: string[], accessGroups: GroupId[]): Promise<void>;
87
+ /**
88
+ * Create invite code for users outside organization
89
+ */
90
+ abstract createInviteCode(accessGroups: GroupId[]): Promise<string>;
91
+ /**
92
+ * Validate invite code for user
93
+ */
94
+ abstract validateInviteCode(code: string): Promise<void>;
95
+ }
96
+ //# sourceMappingURL=organization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../../../src/storages/organizations/organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,uBAAuB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,8BAAsB,YAAa,SAAQ,eAAe,CACxD,iBAAiB,EACjB,YAAY,CACb;IACC;;OAEG;IACH,QAAQ,KAAK,EAAE,IAAI,cAAc,CAAA;IAEjC;;OAEG;IACH,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAA;IAE3B;;OAEG;IACH,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAA;IAElC;;OAEG;IACH,QAAQ,KAAK,UAAU,IAAI,UAAU,CAAA;IAErC;;OAEG;IACH,QAAQ,KAAK,KAAK,IAAI,KAAK,CAAA;IAE3B;;OAEG;IACH,QAAQ,KAAK,YAAY,IAAI,MAAM,CAAA;IAEnC;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAElF;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAE9F;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAErG;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAEjD;;OAEG;IACH,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAEhD;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjE;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAE9E;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAEnE;;OAEG;IACH,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CACzD"}
@@ -0,0 +1,42 @@
1
+ import { OrganizationId } from "./organizations";
2
+ import { Disposable } from "../../disposable";
3
+ import { CurrentLimitsData, OrganizationDto, UserDto, UsersStatisticsResponse } from "../../dto/userInfoResponse";
4
+ import { Workspaces } from "../workspaces/workspaces";
5
+ import { Context } from "../../context";
6
+ import { Organization } from "./organization";
7
+ import { Groups } from "../groups/groups";
8
+ import { Chats } from "../chats/chats";
9
+ import { StatisticsResponse } from "../../dto/statisticsResponse";
10
+ import { SegmentData } from "../../dto/limitsResponse";
11
+ export declare class OrganizationImpl extends Organization implements Disposable {
12
+ private readonly context;
13
+ private _isDisposed;
14
+ private _isAdmin;
15
+ private _content?;
16
+ private readonly _workspaces;
17
+ private readonly _accessGroups;
18
+ private readonly _chats;
19
+ constructor(context: Context);
20
+ initFrom(content: OrganizationDto, isAdmin: boolean): Promise<OrganizationImpl>;
21
+ get isAdmin(): boolean;
22
+ get isDisposed(): boolean;
23
+ dispose(): void;
24
+ get id(): OrganizationId;
25
+ get name(): string;
26
+ get description(): string;
27
+ get workspaces(): Workspaces;
28
+ get accessGroups(): Groups;
29
+ get chats(): Chats;
30
+ members(): Promise<UserDto[]>;
31
+ change(name: string, description: string): Promise<void>;
32
+ statistics(dateFrom: number, dateTo: number): Promise<StatisticsResponse>;
33
+ membersStatistics(dateFrom: number, dateTo: number): Promise<UsersStatisticsResponse>;
34
+ userStatistic(userId: string, dateFrom: number, dateTo: number): Promise<StatisticsResponse>;
35
+ userLimits(): Promise<CurrentLimitsData>;
36
+ organizationLimits(): Promise<SegmentData>;
37
+ limitSegments(): Promise<SegmentData[]>;
38
+ inviteUsers(emails: string[], accessGroups: string[]): Promise<void>;
39
+ createInviteCode(accessGroups: string[]): Promise<string>;
40
+ validateInviteCode(code: string): Promise<void>;
41
+ }
42
+ //# sourceMappingURL=organization.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/organizations/organization.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAEf,OAAO,EAEP,uBAAuB,EACxB,MAAM,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AE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+CxD,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqBzE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqBrF,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsB5F,UAAU,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAsDxC,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC;IAoB1C,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAkBvC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpE,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBzD,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CActD"}
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationImpl = void 0;
4
+ const workspaces_impl_1 = require("../workspaces/workspaces.impl");
5
+ const organization_1 = require("./organization");
6
+ const groups_impl_1 = require("../groups/groups.impl");
7
+ const chats_impl_1 = require("../chats/chats.impl");
8
+ const rpcService_1 = require("../../services/rpcService");
9
+ const responseUtils_1 = require("../../services/responseUtils");
10
+ class OrganizationImpl extends organization_1.Organization {
11
+ constructor(context) {
12
+ super();
13
+ this.context = context;
14
+ this._isDisposed = false;
15
+ this._isAdmin = false;
16
+ this._workspaces = new workspaces_impl_1.WorkspacesImpl(this, this.context);
17
+ this._accessGroups = new groups_impl_1.GroupsImpl(this, this.context);
18
+ this._chats = new chats_impl_1.ChatsImpl(this, this.context);
19
+ }
20
+ async initFrom(content, isAdmin) {
21
+ this._content = content;
22
+ this._isAdmin = isAdmin;
23
+ // init workspaces by organization id
24
+ const promises = [
25
+ this._workspaces.initFrom(content.id),
26
+ this._chats.initFrom(content.id),
27
+ this._accessGroups.initialize()
28
+ ];
29
+ await Promise.all(promises);
30
+ return this;
31
+ }
32
+ get isAdmin() {
33
+ return this._isAdmin;
34
+ }
35
+ get isDisposed() {
36
+ return this._isDisposed;
37
+ }
38
+ dispose() {
39
+ this._isDisposed = true;
40
+ }
41
+ get id() {
42
+ var _a;
43
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.id;
44
+ }
45
+ get name() {
46
+ var _a;
47
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.profile.name;
48
+ }
49
+ get description() {
50
+ var _a;
51
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.profile.description;
52
+ }
53
+ get workspaces() {
54
+ return this._workspaces;
55
+ }
56
+ get accessGroups() {
57
+ return this._accessGroups;
58
+ }
59
+ get chats() {
60
+ return this._chats;
61
+ }
62
+ async members() {
63
+ var _a;
64
+ // send request to the server
65
+ const response = await ((_a = this.context
66
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Organizations/members").searchParam("id", this.id).sendGet());
67
+ // check response status
68
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
69
+ await responseUtils_1.ResponseUtils.throwError(`Failed during fetch of organization members ${this.id}`, response);
70
+ }
71
+ return (await response.json()).members;
72
+ }
73
+ async change(name, description) {
74
+ var _a;
75
+ if (!this._content) {
76
+ throw new Error("Organization is not loaded.");
77
+ }
78
+ if (name === this.name && description === this.description) {
79
+ return Promise.resolve();
80
+ }
81
+ if (name === undefined || name === null || name.trim() === "") {
82
+ throw new Error("Name is required. Please provide a valid name.");
83
+ }
84
+ if (description === undefined ||
85
+ description === null ||
86
+ description.trim() === "") {
87
+ throw new Error("Description is required. Please provide a valid description.");
88
+ }
89
+ const response = await ((_a = this.context
90
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Organizations").sendPutJson({
91
+ organizationId: this.id,
92
+ profile: {
93
+ name,
94
+ description
95
+ }
96
+ }));
97
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
98
+ await responseUtils_1.ResponseUtils.throwError("Failed to change organization", response);
99
+ }
100
+ if (this._content) {
101
+ this._content.profile.name = name;
102
+ this._content.profile.description = description;
103
+ }
104
+ this.dispatch({
105
+ type: organization_1.OrganizationEvent.CHANGED,
106
+ data: this
107
+ });
108
+ }
109
+ async statistics(dateFrom, dateTo) {
110
+ var _a;
111
+ // send request to the server
112
+ const response = await ((_a = this.context
113
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Stats/organization").searchParam("organizationId", this.id).searchParam("dateFrom", dateFrom.toString()).searchParam("dateTo", dateTo.toString()).sendGet());
114
+ // check response status
115
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
116
+ await responseUtils_1.ResponseUtils.throwError(`Failed during fetch of organization statistics ${this.id}`, response);
117
+ }
118
+ return await response.json();
119
+ }
120
+ async membersStatistics(dateFrom, dateTo) {
121
+ var _a;
122
+ // send request to the server
123
+ const response = await ((_a = this.context
124
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Stats/organization/members").searchParam("organizationId", this.id).searchParam("dateFrom", dateFrom.toString()).searchParam("dateTo", dateTo.toString()).sendGet());
125
+ // check response status
126
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
127
+ await responseUtils_1.ResponseUtils.throwError(`Failed during fetch of organization members statistics ${this.id}`, response);
128
+ }
129
+ return await response.json();
130
+ }
131
+ async userStatistic(userId, dateFrom, dateTo) {
132
+ var _a;
133
+ // send request to the server
134
+ const response = await ((_a = this.context
135
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Stats/user").searchParam("userId", userId).searchParam("organizationId", this.id).searchParam("dateFrom", dateFrom.toString()).searchParam("dateTo", dateTo.toString()).sendGet());
136
+ // check response status
137
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
138
+ await responseUtils_1.ResponseUtils.throwError(`Failed during fetch of user statistics ${this.id}`, response);
139
+ }
140
+ return await response.json();
141
+ }
142
+ async userLimits() {
143
+ var _a, _b, _c;
144
+ // fetch limits
145
+ const response = await ((_a = this.context.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Users/limits").sendGet());
146
+ // check response status
147
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
148
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get limits in organization: ${this.id}`, response);
149
+ }
150
+ // parse limits from the server's response
151
+ const limits = (await response.json());
152
+ const currentLimits = {
153
+ segment: limits.userSegment.key,
154
+ limits: []
155
+ };
156
+ for (const limit of limits.userLimits) {
157
+ const type = limit.action;
158
+ const currentItem = {
159
+ action: type,
160
+ records: []
161
+ };
162
+ if (limit.records.length == 0)
163
+ continue;
164
+ for (const record of limit.records) {
165
+ const segmentRecord = limits.userSegment.dayItems.find(item => item.daysCount == record.daysCount);
166
+ if (segmentRecord == null) {
167
+ throw new Error(`Invalid response during get limits in organization: ${this.id}. Days count with ${type} not found in segment ${limits.userSegment.key}`);
168
+ }
169
+ const actionRecord = segmentRecord === null || segmentRecord === void 0 ? void 0 : segmentRecord.actionItems.find(item => item.type == type);
170
+ if (actionRecord == null) {
171
+ throw new Error(`Invalid response during get limits in organization: ${this.id}. Type ${type} not found in segment ${limits.userSegment.key}`);
172
+ }
173
+ const currentRecord = {};
174
+ currentRecord.daysCount = record.daysCount;
175
+ currentRecord.activeTill = record.activeTill;
176
+ currentRecord.all = (_b = actionRecord === null || actionRecord === void 0 ? void 0 : actionRecord.tokenLimit) !== null && _b !== void 0 ? _b : actionRecord === null || actionRecord === void 0 ? void 0 : actionRecord.countLimit;
177
+ const available = (_c = record.tokenLimit) !== null && _c !== void 0 ? _c : record.countLimit;
178
+ currentRecord.used = currentRecord.all - available;
179
+ currentItem.records.push(currentRecord);
180
+ }
181
+ currentLimits.limits.push(currentItem);
182
+ }
183
+ return currentLimits;
184
+ }
185
+ async organizationLimits() {
186
+ var _a;
187
+ // fetch limits
188
+ const response = await ((_a = this.context.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Descriptions/limits/organization").searchParam("organizationId", this.id).sendGet());
189
+ // check response status
190
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
191
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get limits in organization: ${this.id}`, response);
192
+ }
193
+ const json = await response.json();
194
+ // parse limits from the server's response
195
+ const limits = json.segment;
196
+ return limits;
197
+ }
198
+ async limitSegments() {
199
+ var _a;
200
+ // fetch limits
201
+ const response = await ((_a = this.context.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Descriptions/limits/segments").sendGet());
202
+ // check response status
203
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
204
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get limits in organization: ${this.id}`, response);
205
+ }
206
+ const json = await response.json();
207
+ // parse limits from the server's response
208
+ const limits = json.segments;
209
+ return limits;
210
+ }
211
+ async inviteUsers(emails, accessGroups) {
212
+ var _a;
213
+ const response = await ((_a = this.context
214
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Invites").sendPostJson({
215
+ organizationId: this.id,
216
+ emails: emails,
217
+ accessGroupIds: accessGroups
218
+ }));
219
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
220
+ await responseUtils_1.ResponseUtils.throwError(`Invite users failed for organization ${this.id}`, response);
221
+ }
222
+ }
223
+ async createInviteCode(accessGroups) {
224
+ var _a;
225
+ const response = await ((_a = this.context
226
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Invites/link").sendPostJson({
227
+ organizationId: this.id,
228
+ accessGroupIds: accessGroups
229
+ }));
230
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
231
+ await responseUtils_1.ResponseUtils.throwError(`Invite code creation failed for organization ${this.id}`, response);
232
+ }
233
+ const json = await response.json();
234
+ const code = json.code;
235
+ return code;
236
+ }
237
+ async validateInviteCode(code) {
238
+ var _a;
239
+ const response = await ((_a = this.context
240
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Invites/apply").sendPutJson({
241
+ code: code
242
+ }));
243
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
244
+ await responseUtils_1.ResponseUtils.throwError(`Invite code validation failed for organization ${this.id}`, response);
245
+ }
246
+ }
247
+ }
248
+ exports.OrganizationImpl = OrganizationImpl;
249
+ //# sourceMappingURL=organization.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.impl.js","sourceRoot":"","sources":["../../../../src/storages/organizations/organization.impl.ts"],"names":[],"mappings":";;;AAaA,mEAA8D;AAE9D,iDAAgE;AAChE,uDAAkD;AAElD,oDAA+C;AAE/C,0DAAsD;AACtD,gEAA4D;AAS5D,MAAa,gBAAiB,SAAQ,2BAAY;IAQhD,YAA6B,OAAgB;QAC3C,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAS;QAPrC,gBAAW,GAAY,KAAK,CAAA;QAC5B,aAAQ,GAAY,KAAK,CAAA;QAQ/B,IAAI,CAAC,WAAW,GAAG,IAAI,gCAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACzD,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAU,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,sBAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,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AAa,CAAC,UAAU,CAC5B,wCAAwC,IAAI,CAAC,EAAE,EAAE,EACjD,QAAQ,CACT,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,YAAsB;;QAC3C,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,qBAAqB,EACrC,YAAY,CAAC;YACZ,cAAc,EAAE,IAAI,CAAC,EAAE;YACvB,cAAc,EAAE,YAAY;SAC7B,CAAC,CAAA,CAAA;QACJ,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAC5B,gDAAgD,IAAI,CAAC,EAAE,EAAE,EACzD,QAAQ,CACT,CAAA;QACH,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAS,CAAC,IAAI,EAAE,CAAA;QAEnC,MAAM,IAAI,GAAI,IAA2B,CAAC,IAAI,CAAA;QAE9C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAAY;;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,sBAAsB,EACtC,WAAW,CAAC;YACX,IAAI,EAAE,IAAI;SACX,CAAC,CAAA,CAAA;QACJ,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAC5B,kDAAkD,IAAI,CAAC,EAAE,EAAE,EAC3D,QAAQ,CACT,CAAA;QACH,CAAC;IACH,CAAC;CACF;AA3VD,4CA2VC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Organization = exports.OrganizationEvent = void 0;
4
+ const events_1 = require("../../events");
5
+ /**
6
+ * Organization event.
7
+ */
8
+ var OrganizationEvent;
9
+ (function (OrganizationEvent) {
10
+ OrganizationEvent["CHANGED"] = "changed";
11
+ })(OrganizationEvent || (exports.OrganizationEvent = OrganizationEvent = {}));
12
+ /**
13
+ * Organization.
14
+ */
15
+ class Organization extends events_1.EventDispatcher {
16
+ }
17
+ exports.Organization = Organization;
18
+ //# sourceMappingURL=organization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.js","sourceRoot":"","sources":["../../../../src/storages/organizations/organization.ts"],"names":[],"mappings":";;;AAIA,yCAA8C;AAU9C;;GAEG;AACH,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;AACrB,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B;AAED;;GAEG;AACH,MAAsB,YAAa,SAAQ,wBAG1C;CA4FA;AA/FD,oCA+FC"}
@@ -0,0 +1,46 @@
1
+ import { EventDispatcher } from "../../events";
2
+ import { Organization } from "./organization";
3
+ /**
4
+ * Organization id.
5
+ */
6
+ export type OrganizationId = string;
7
+ /**
8
+ * Organization event.
9
+ */
10
+ export declare enum OrganizationsEvent {
11
+ ADDED = "added",
12
+ REMOVED = "removed",
13
+ CURRENT_CHANGED = "currentChanged"
14
+ }
15
+ /**
16
+ * Organizations storage.
17
+ */
18
+ export declare abstract class Organizations extends EventDispatcher<OrganizationsEvent, Organization> {
19
+ /**
20
+ * User's organizations.
21
+ */
22
+ abstract get collection(): ReadonlyArray<Organization>;
23
+ /**
24
+ * Current organization.
25
+ */
26
+ abstract get current(): OrganizationId;
27
+ abstract set current(value: OrganizationId);
28
+ /**
29
+ * Get organization by id.
30
+ */
31
+ abstract get(id: OrganizationId): Organization;
32
+ /**
33
+ * Try to get organization by id.
34
+ * @param id
35
+ */
36
+ abstract tryGet(id: OrganizationId): Organization | undefined;
37
+ /**
38
+ * Create new organization.
39
+ */
40
+ abstract create(name: string, description: string): Promise<Organization>;
41
+ /**
42
+ * Delete organization.
43
+ */
44
+ abstract delete(id: OrganizationId): Promise<void>;
45
+ }
46
+ //# sourceMappingURL=organizations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../../../src/storages/organizations/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAEnC;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,eAAe,mBAAmB;CACnC;AAED;;GAEG;AACH,8BAAsB,aAAc,SAAQ,eAAe,CACzD,kBAAkB,EAClB,YAAY,CACb;IACC;;OAEG;IACH,QAAQ,KAAK,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,CAAA;IAEtD;;OAEG;IACH,QAAQ,KAAK,OAAO,IAAI,cAAc,CAAA;IACtC,QAAQ,KAAK,OAAO,CAAC,KAAK,EAAE,cAAc,EAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,cAAc,GAAG,YAAY;IAE9C;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS;IAE7D;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAEzE;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CACnD"}