@neuralinnovations/dataisland-sdk 0.0.1-dev2 → 0.0.1-dev21

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 (286) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +306 -1
  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 +100 -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/startCommandHandler.d.ts +7 -0
  13. package/dist/src/commands/startCommandHandler.d.ts.map +1 -0
  14. package/dist/src/commands/startCommandHandler.js +17 -0
  15. package/dist/src/commands/startCommandHandler.js.map +1 -0
  16. package/dist/src/context.d.ts +23 -0
  17. package/dist/src/context.d.ts.map +1 -0
  18. package/dist/src/context.js +31 -0
  19. package/dist/src/context.js.map +1 -0
  20. package/dist/src/credentials.d.ts +28 -0
  21. package/dist/src/credentials.d.ts.map +1 -0
  22. package/dist/src/credentials.js +70 -0
  23. package/dist/src/credentials.js.map +1 -0
  24. package/dist/src/dataIslandApp.d.ts +50 -0
  25. package/dist/src/dataIslandApp.d.ts.map +1 -0
  26. package/dist/src/dataIslandApp.js +10 -0
  27. package/dist/src/dataIslandApp.js.map +1 -0
  28. package/dist/src/disposable.d.ts +84 -0
  29. package/dist/src/disposable.d.ts.map +1 -0
  30. package/dist/src/disposable.js +147 -0
  31. package/dist/src/disposable.js.map +1 -0
  32. package/dist/src/dto/accessGroupResponse.d.ts +27 -0
  33. package/dist/src/dto/accessGroupResponse.d.ts.map +1 -0
  34. package/dist/src/dto/accessGroupResponse.js +3 -0
  35. package/dist/src/dto/accessGroupResponse.js.map +1 -0
  36. package/dist/src/dto/chatResponse.d.ts +78 -0
  37. package/dist/src/dto/chatResponse.d.ts.map +1 -0
  38. package/dist/src/dto/chatResponse.js +45 -0
  39. package/dist/src/dto/chatResponse.js.map +1 -0
  40. package/dist/src/dto/userInfoResponse.d.ts +42 -0
  41. package/dist/src/dto/userInfoResponse.d.ts.map +1 -0
  42. package/dist/src/dto/userInfoResponse.js +3 -0
  43. package/dist/src/dto/userInfoResponse.js.map +1 -0
  44. package/dist/src/dto/workspacesResponse.d.ts +43 -0
  45. package/dist/src/dto/workspacesResponse.d.ts.map +1 -0
  46. package/dist/src/dto/workspacesResponse.js +3 -0
  47. package/dist/src/dto/workspacesResponse.js.map +1 -0
  48. package/dist/src/events.d.ts +17 -0
  49. package/dist/src/events.d.ts.map +1 -0
  50. package/dist/src/events.js +52 -0
  51. package/dist/src/events.js.map +1 -0
  52. package/dist/src/index.d.ts +58 -0
  53. package/dist/src/index.d.ts.map +1 -0
  54. package/dist/src/index.js +91 -0
  55. package/dist/src/index.js.map +1 -0
  56. package/dist/src/internal/app.impl.d.ts +28 -0
  57. package/dist/src/internal/app.impl.d.ts.map +1 -0
  58. package/dist/src/internal/app.impl.js +151 -0
  59. package/dist/src/internal/app.impl.js.map +1 -0
  60. package/dist/src/internal/appBuilder.impl.d.ts +27 -0
  61. package/dist/src/internal/appBuilder.impl.d.ts.map +1 -0
  62. package/dist/src/internal/appBuilder.impl.js +71 -0
  63. package/dist/src/internal/appBuilder.impl.js.map +1 -0
  64. package/dist/src/internal/createApp.impl.d.ts +4 -0
  65. package/dist/src/internal/createApp.impl.d.ts.map +1 -0
  66. package/dist/src/internal/createApp.impl.js +11 -0
  67. package/dist/src/internal/createApp.impl.js.map +1 -0
  68. package/dist/src/internal/registry.d.ts +66 -0
  69. package/dist/src/internal/registry.d.ts.map +1 -0
  70. package/dist/src/internal/registry.js +114 -0
  71. package/dist/src/internal/registry.js.map +1 -0
  72. package/dist/src/middleware.d.ts +5 -0
  73. package/dist/src/middleware.d.ts.map +1 -0
  74. package/dist/src/middleware.js +3 -0
  75. package/dist/src/middleware.js.map +1 -0
  76. package/dist/src/services/commandService.d.ts +18 -0
  77. package/dist/src/services/commandService.d.ts.map +1 -0
  78. package/dist/src/services/commandService.js +40 -0
  79. package/dist/src/services/commandService.js.map +1 -0
  80. package/dist/src/services/credentialService.d.ts +9 -0
  81. package/dist/src/services/credentialService.d.ts.map +1 -0
  82. package/dist/src/services/credentialService.js +26 -0
  83. package/dist/src/services/credentialService.js.map +1 -0
  84. package/dist/src/services/middlewareService.d.ts +9 -0
  85. package/dist/src/services/middlewareService.d.ts.map +1 -0
  86. package/dist/src/services/middlewareService.js +34 -0
  87. package/dist/src/services/middlewareService.js.map +1 -0
  88. package/dist/src/services/organizationService.d.ts +10 -0
  89. package/dist/src/services/organizationService.d.ts.map +1 -0
  90. package/dist/src/services/organizationService.js +19 -0
  91. package/dist/src/services/organizationService.js.map +1 -0
  92. package/dist/src/services/requestBuilder.d.ts +17 -0
  93. package/dist/src/services/requestBuilder.d.ts.map +1 -0
  94. package/dist/src/services/requestBuilder.js +104 -0
  95. package/dist/src/services/requestBuilder.js.map +1 -0
  96. package/dist/src/services/responseUtils.d.ts +6 -0
  97. package/dist/src/services/responseUtils.d.ts.map +1 -0
  98. package/dist/src/services/responseUtils.js +32 -0
  99. package/dist/src/services/responseUtils.js.map +1 -0
  100. package/dist/src/services/rpcService.d.ts +77 -0
  101. package/dist/src/services/rpcService.d.ts.map +1 -0
  102. package/dist/src/services/rpcService.js +125 -0
  103. package/dist/src/services/rpcService.js.map +1 -0
  104. package/dist/src/services/service.d.ts +21 -0
  105. package/dist/src/services/service.d.ts.map +1 -0
  106. package/dist/src/services/service.js +41 -0
  107. package/dist/src/services/service.js.map +1 -0
  108. package/dist/src/services/userProfileService.d.ts +8 -0
  109. package/dist/src/services/userProfileService.d.ts.map +1 -0
  110. package/dist/src/services/userProfileService.js +32 -0
  111. package/dist/src/services/userProfileService.js.map +1 -0
  112. package/dist/src/storages/chats/answer.d.ts +40 -0
  113. package/dist/src/storages/chats/answer.d.ts.map +1 -0
  114. package/dist/src/storages/chats/answer.impl.d.ts +24 -0
  115. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -0
  116. package/dist/src/storages/chats/answer.impl.js +130 -0
  117. package/dist/src/storages/chats/answer.impl.js.map +1 -0
  118. package/dist/src/storages/chats/answer.js +14 -0
  119. package/dist/src/storages/chats/answer.js.map +1 -0
  120. package/dist/src/storages/chats/chat.d.ts +39 -0
  121. package/dist/src/storages/chats/chat.d.ts.map +1 -0
  122. package/dist/src/storages/chats/chat.impl.d.ts +24 -0
  123. package/dist/src/storages/chats/chat.impl.d.ts.map +1 -0
  124. package/dist/src/storages/chats/chat.impl.js +98 -0
  125. package/dist/src/storages/chats/chat.impl.js.map +1 -0
  126. package/dist/src/storages/chats/chat.js +12 -0
  127. package/dist/src/storages/chats/chat.js.map +1 -0
  128. package/dist/src/storages/chats/chats.d.ts +40 -0
  129. package/dist/src/storages/chats/chats.d.ts.map +1 -0
  130. package/dist/src/storages/chats/chats.impl.d.ts +18 -0
  131. package/dist/src/storages/chats/chats.impl.d.ts.map +1 -0
  132. package/dist/src/storages/chats/chats.impl.js +102 -0
  133. package/dist/src/storages/chats/chats.impl.js.map +1 -0
  134. package/dist/src/storages/chats/chats.js +16 -0
  135. package/dist/src/storages/chats/chats.js.map +1 -0
  136. package/dist/src/storages/files/file.d.ts +31 -0
  137. package/dist/src/storages/files/file.d.ts.map +1 -0
  138. package/dist/src/storages/files/file.impl.d.ts +21 -0
  139. package/dist/src/storages/files/file.impl.d.ts.map +1 -0
  140. package/dist/src/storages/files/file.impl.js +64 -0
  141. package/dist/src/storages/files/file.impl.js.map +1 -0
  142. package/dist/src/storages/files/file.js +11 -0
  143. package/dist/src/storages/files/file.js.map +1 -0
  144. package/dist/src/storages/files/files.d.ts +34 -0
  145. package/dist/src/storages/files/files.d.ts.map +1 -0
  146. package/dist/src/storages/files/files.impl.d.ts +22 -0
  147. package/dist/src/storages/files/files.impl.d.ts.map +1 -0
  148. package/dist/src/storages/files/files.impl.js +140 -0
  149. package/dist/src/storages/files/files.impl.js.map +1 -0
  150. package/dist/src/storages/files/files.js +20 -0
  151. package/dist/src/storages/files/files.js.map +1 -0
  152. package/dist/src/storages/files/filesPage.d.ts +28 -0
  153. package/dist/src/storages/files/filesPage.d.ts.map +1 -0
  154. package/dist/src/storages/files/filesPage.impl.d.ts +15 -0
  155. package/dist/src/storages/files/filesPage.impl.d.ts.map +1 -0
  156. package/dist/src/storages/files/filesPage.impl.js +38 -0
  157. package/dist/src/storages/files/filesPage.impl.js.map +1 -0
  158. package/dist/src/storages/files/filesPage.js +10 -0
  159. package/dist/src/storages/files/filesPage.js.map +1 -0
  160. package/dist/src/storages/groups/groups.d.ts +91 -0
  161. package/dist/src/storages/groups/groups.d.ts.map +1 -0
  162. package/dist/src/storages/groups/groups.impl.d.ts +61 -0
  163. package/dist/src/storages/groups/groups.impl.d.ts.map +1 -0
  164. package/dist/src/storages/groups/groups.impl.js +293 -0
  165. package/dist/src/storages/groups/groups.impl.js.map +1 -0
  166. package/dist/src/storages/groups/groups.js +26 -0
  167. package/dist/src/storages/groups/groups.js.map +1 -0
  168. package/dist/src/storages/organizations/organization.d.ts +54 -0
  169. package/dist/src/storages/organizations/organization.d.ts.map +1 -0
  170. package/dist/src/storages/organizations/organization.impl.d.ts +32 -0
  171. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -0
  172. package/dist/src/storages/organizations/organization.impl.js +120 -0
  173. package/dist/src/storages/organizations/organization.impl.js.map +1 -0
  174. package/dist/src/storages/organizations/organization.js +18 -0
  175. package/dist/src/storages/organizations/organization.js.map +1 -0
  176. package/dist/src/storages/organizations/organizations.d.ts +46 -0
  177. package/dist/src/storages/organizations/organizations.d.ts.map +1 -0
  178. package/dist/src/storages/organizations/organizations.impl.d.ts +38 -0
  179. package/dist/src/storages/organizations/organizations.impl.d.ts.map +1 -0
  180. package/dist/src/storages/organizations/organizations.impl.js +151 -0
  181. package/dist/src/storages/organizations/organizations.impl.js.map +1 -0
  182. package/dist/src/storages/organizations/organizations.js +20 -0
  183. package/dist/src/storages/organizations/organizations.js.map +1 -0
  184. package/dist/src/storages/user/userProfile.d.ts +32 -0
  185. package/dist/src/storages/user/userProfile.d.ts.map +1 -0
  186. package/dist/src/storages/user/userProfile.impl.d.ts +13 -0
  187. package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -0
  188. package/dist/src/storages/user/userProfile.impl.js +51 -0
  189. package/dist/src/storages/user/userProfile.impl.js.map +1 -0
  190. package/dist/src/storages/user/userProfile.js +12 -0
  191. package/dist/src/storages/user/userProfile.js.map +1 -0
  192. package/dist/src/storages/workspaces/workspace.d.ts +44 -0
  193. package/dist/src/storages/workspaces/workspace.d.ts.map +1 -0
  194. package/dist/src/storages/workspaces/workspace.impl.d.ts +23 -0
  195. package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -0
  196. package/dist/src/storages/workspaces/workspace.impl.js +98 -0
  197. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -0
  198. package/dist/src/storages/workspaces/workspace.js +18 -0
  199. package/dist/src/storages/workspaces/workspace.js.map +1 -0
  200. package/dist/src/storages/workspaces/workspaces.d.ts +47 -0
  201. package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -0
  202. package/dist/src/storages/workspaces/workspaces.impl.d.ts +33 -0
  203. package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -0
  204. package/dist/src/storages/workspaces/workspaces.impl.js +157 -0
  205. package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -0
  206. package/dist/src/storages/workspaces/workspaces.js +19 -0
  207. package/dist/src/storages/workspaces/workspaces.js.map +1 -0
  208. package/dist/src/unitTest.d.ts +12 -0
  209. package/dist/src/unitTest.d.ts.map +1 -0
  210. package/dist/src/unitTest.js +44 -0
  211. package/dist/src/unitTest.js.map +1 -0
  212. package/index.d.ts +1 -0
  213. package/index.js +1 -0
  214. package/package.json +43 -4
  215. package/src/appBuilder.ts +6 -6
  216. package/src/commands/startCommandHandler.ts +2 -2
  217. package/src/context.ts +5 -4
  218. package/src/credentials.ts +29 -7
  219. package/src/{appSdk.ts → dataIslandApp.ts} +7 -7
  220. package/src/disposable.ts +20 -8
  221. package/src/dto/accessGroupResponse.ts +35 -0
  222. package/src/dto/chatResponse.ts +103 -0
  223. package/src/dto/userInfoResponse.ts +15 -3
  224. package/src/dto/workspacesResponse.ts +49 -0
  225. package/src/events.ts +13 -13
  226. package/src/index.ts +41 -20
  227. package/src/internal/app.impl.ts +28 -31
  228. package/src/internal/appBuilder.impl.ts +16 -16
  229. package/src/internal/createApp.impl.ts +5 -5
  230. package/src/internal/registry.ts +54 -6
  231. package/src/services/commandService.ts +3 -3
  232. package/src/services/credentialService.ts +3 -3
  233. package/src/services/middlewareService.ts +4 -4
  234. package/src/services/organizationService.ts +18 -116
  235. package/src/services/requestBuilder.ts +40 -15
  236. package/src/services/responseUtils.ts +32 -0
  237. package/src/services/rpcService.ts +28 -11
  238. package/src/services/service.ts +10 -8
  239. package/src/services/userProfileService.ts +18 -66
  240. package/src/storages/chats/answer.impl.ts +186 -0
  241. package/src/storages/chats/answer.ts +55 -0
  242. package/src/storages/chats/chat.impl.ts +126 -0
  243. package/src/storages/chats/chat.ts +49 -0
  244. package/src/storages/chats/chats.impl.ts +142 -0
  245. package/src/storages/chats/chats.ts +47 -0
  246. package/src/storages/files/file.impl.ts +87 -0
  247. package/src/storages/files/file.ts +40 -0
  248. package/src/storages/files/files.impl.ts +191 -0
  249. package/src/storages/files/files.ts +39 -0
  250. package/src/storages/files/filesPage.impl.ts +37 -0
  251. package/src/storages/files/filesPage.ts +33 -0
  252. package/src/storages/groups/groups.impl.ts +386 -0
  253. package/src/storages/groups/groups.ts +106 -0
  254. package/src/storages/organizations/organization.impl.ts +163 -0
  255. package/src/storages/organizations/organization.ts +67 -0
  256. package/src/storages/organizations/organizations.impl.ts +197 -0
  257. package/src/storages/{organizations.ts → organizations/organizations.ts} +8 -28
  258. package/src/storages/user/userProfile.impl.ts +56 -0
  259. package/src/storages/{userProfile.ts → user/userProfile.ts} +2 -2
  260. package/src/storages/workspaces/workspace.impl.ts +129 -0
  261. package/src/storages/workspaces/workspace.ts +54 -0
  262. package/src/storages/workspaces/workspaces.impl.ts +212 -0
  263. package/src/storages/workspaces/workspaces.ts +53 -0
  264. package/src/unitTest.ts +12 -1
  265. package/.browserslistrc +0 -5
  266. package/.editorconfig +0 -22
  267. package/.eslintrc.json +0 -44
  268. package/.github/workflows/publish-npm.yml +0 -28
  269. package/.prettierignore +0 -1
  270. package/.prettierrc +0 -11
  271. package/.yarnrc +0 -2
  272. package/babel.config.js +0 -6
  273. package/jest.config.ts +0 -199
  274. package/jest.setup.ts +0 -2
  275. package/src/services/organizationImpl.ts +0 -51
  276. package/src/services/organizationsImpl.ts +0 -55
  277. package/src/types.ts +0 -86
  278. package/test/commands.test.ts +0 -24
  279. package/test/disposable.test.ts +0 -39
  280. package/test/events.test.ts +0 -151
  281. package/test/index.test.ts +0 -163
  282. package/test/registry.test.ts +0 -44
  283. package/test/services.test.ts +0 -56
  284. package/test/setup.ts +0 -2
  285. package/test/unitTest.test.ts +0 -21
  286. package/tsconfig.json +0 -31
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupsImpl = exports.GroupImpl = void 0;
4
+ const rpcService_1 = require("../../services/rpcService");
5
+ const groups_1 = require("./groups");
6
+ const responseUtils_1 = require("../../services/responseUtils");
7
+ class GroupImpl extends groups_1.Group {
8
+ constructor(context, organization) {
9
+ super();
10
+ this.context = context;
11
+ this.organization = organization;
12
+ this._isDisposed = false;
13
+ this._workspaces = [];
14
+ }
15
+ async initFrom(id) {
16
+ await this.reloadGroup(id);
17
+ await this.reloadWorkspaces();
18
+ return this;
19
+ }
20
+ async reloadGroup(id) {
21
+ var _a;
22
+ // fetch group
23
+ const response = await ((_a = this.context.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups").searchParam("groupId", id).sendGet());
24
+ // check response status
25
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
26
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get group: ${id}, organization: ${this.organization.id}`, response);
27
+ }
28
+ // parse group from the server's response
29
+ const group = (await response.json());
30
+ // init group
31
+ this._content = group.group;
32
+ this._members = group.members;
33
+ }
34
+ async reloadWorkspaces() {
35
+ const groupWorkspaces = await this.loadWorkspaces(this.id);
36
+ this._workspaces.length = 0;
37
+ this._workspaces.push(...groupWorkspaces);
38
+ }
39
+ async loadWorkspaces(groupId) {
40
+ var _a;
41
+ // fetch workspaces
42
+ const response = await ((_a = this.context.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups/workspaces").searchParam("groupId", groupId).sendGet());
43
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
44
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get workspaces for group: ${this.id}, organization: ${this.organization.id}`, response);
45
+ }
46
+ // parse workspaces from the server's response
47
+ const workspaces = (await response.json());
48
+ // get workspaces
49
+ const result = [];
50
+ for (const workspaceDto of workspaces.workspaces) {
51
+ result.push(this.organization.workspaces.get(workspaceDto.id));
52
+ }
53
+ return result;
54
+ }
55
+ get id() {
56
+ if (this._content) {
57
+ return this._content.id;
58
+ }
59
+ throw new Error("Access group is not loaded.");
60
+ }
61
+ get group() {
62
+ if (this._content) {
63
+ return this._content;
64
+ }
65
+ throw new Error("Access group is not loaded.");
66
+ }
67
+ get workspaces() {
68
+ return this._workspaces;
69
+ }
70
+ get members() {
71
+ if (this._members) {
72
+ return this._members;
73
+ }
74
+ throw new Error("Access group is not loaded.");
75
+ }
76
+ async setName(name) {
77
+ var _a;
78
+ if (name === undefined || name === null) {
79
+ throw new Error("Groups change, name is undefined or null");
80
+ }
81
+ if (name.length === 0 || name.trim().length === 0) {
82
+ throw new Error("Groups change, name is empty");
83
+ }
84
+ // send request to the server
85
+ const response = await ((_a = this.context
86
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups/name").sendPutJson({
87
+ groupId: this.id,
88
+ name: name
89
+ }));
90
+ // check response status
91
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
92
+ await responseUtils_1.ResponseUtils.throwError(`Failed to change group name, group: ${this.id}, organization: ${this.organization.id}`, response);
93
+ }
94
+ // change name
95
+ if (this._content) {
96
+ this._content.name = name;
97
+ }
98
+ }
99
+ async setPermits(permits) {
100
+ var _a;
101
+ // send request to the server
102
+ const response = await ((_a = this.context
103
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups/permits").sendPutJson({
104
+ groupId: this.id,
105
+ permits: permits
106
+ }));
107
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
108
+ await responseUtils_1.ResponseUtils.throwError(`Failed to change group permits, group: ${this.id}, organization: ${this.organization.id}`, response);
109
+ }
110
+ }
111
+ async setWorkspaces(workspaces) {
112
+ var _a;
113
+ if (workspaces === null || workspaces === undefined) {
114
+ throw new Error("Group add workspaces, workspaces is undefined or null");
115
+ }
116
+ // send request to the server
117
+ const response = await ((_a = this.context
118
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups/workspaces").sendPutJson({
119
+ groupId: this.id,
120
+ actualWorkspaceIds: workspaces
121
+ }));
122
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
123
+ await responseUtils_1.ResponseUtils.throwError(`Failed to set workspaces for group: ${this.id}, organization: ${this.organization.id}`, response);
124
+ }
125
+ // reload workspaces
126
+ await this.reloadWorkspaces();
127
+ }
128
+ async setMembersIds(members) {
129
+ var _a;
130
+ if (members === null || members === undefined) {
131
+ throw new Error("Group setMembersIds, members is undefined or null");
132
+ }
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/AccessGroups/members").sendPutJson({
136
+ groupId: this.id,
137
+ memberIds: members
138
+ }));
139
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
140
+ await responseUtils_1.ResponseUtils.throwError(`Failed to set members for group: ${this.id}, organization: ${this.organization.id}`, response);
141
+ }
142
+ // reload group
143
+ await this.reloadGroup(this.id);
144
+ }
145
+ async removeMembers(members) {
146
+ // check members
147
+ if (members === null || members === undefined) {
148
+ throw new Error("Group removeMembers, members is undefined or null");
149
+ }
150
+ // make set of members
151
+ const groupMembers = new Set(this.members.map(m => m.id));
152
+ // check argument
153
+ if (!members.every(m => groupMembers.has(m))) {
154
+ const notExistingMembers = members.filter(memberId => !groupMembers.has(memberId));
155
+ throw new Error(`Group removeMembers, members contains not existing members: ${notExistingMembers}`);
156
+ }
157
+ // remove members
158
+ for (const id of members) {
159
+ groupMembers.delete(id);
160
+ }
161
+ // send request to the server
162
+ await this.setMembersIds(Array.from(groupMembers));
163
+ }
164
+ get isDisposed() {
165
+ return this._isDisposed;
166
+ }
167
+ dispose() {
168
+ this._isDisposed = true;
169
+ }
170
+ }
171
+ exports.GroupImpl = GroupImpl;
172
+ class GroupsImpl extends groups_1.Groups {
173
+ constructor(organization, context) {
174
+ super();
175
+ this.organization = organization;
176
+ this.context = context;
177
+ this._groups = [];
178
+ }
179
+ get collection() {
180
+ return this._groups;
181
+ }
182
+ async initialize() {
183
+ await this.internalInit();
184
+ }
185
+ async create(name, permits, memberIds) {
186
+ return await this.internalCreate(name, permits, memberIds);
187
+ }
188
+ get(id) {
189
+ return this._groups.find(group => group.id === id);
190
+ }
191
+ async delete(id) {
192
+ return await this.internalDeleteGroup(id);
193
+ }
194
+ //----------------------------------------------------------------------------
195
+ // INTERNALS
196
+ //----------------------------------------------------------------------------
197
+ /**
198
+ * Init access groups.
199
+ */
200
+ async internalInit() {
201
+ var _a;
202
+ // fetch groups
203
+ 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());
204
+ // check response status
205
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
206
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get groups for organization: ${this.organization.id}`, response);
207
+ }
208
+ // parse groups from the server's response
209
+ const groups = (await response.json());
210
+ // init groups
211
+ for (const gr of groups.groups) {
212
+ // create group implementation
213
+ const group = await new GroupImpl(this.context, this.organization).initFrom(gr.id);
214
+ // add group to the collection
215
+ this._groups.push(group);
216
+ // dispatch event
217
+ this.dispatch({
218
+ type: groups_1.GroupEvent.ADDED,
219
+ data: group
220
+ });
221
+ }
222
+ }
223
+ async internalCreate(name, permits, memberIds) {
224
+ var _a;
225
+ if (name === undefined || name === null) {
226
+ throw new Error("Group create, name is undefined or null");
227
+ }
228
+ if (name.length === 0 || name.trim().length === 0) {
229
+ throw new Error("Group create, name is empty");
230
+ }
231
+ // send request to the server
232
+ const response = await ((_a = this.context
233
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/AccessGroups").sendPostJson({
234
+ name: name,
235
+ organizationId: this.organization.id,
236
+ permits: permits,
237
+ memberIds: memberIds
238
+ }));
239
+ // check response status
240
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
241
+ await responseUtils_1.ResponseUtils.throwError(`Failed to create group, organization: ${this.organization.id}`, response);
242
+ }
243
+ // parse group from the server's response
244
+ const content = (await response.json());
245
+ // create group implementation
246
+ const group = await new GroupImpl(this.context, this.organization).initFrom(content.group.id);
247
+ // add group to the collection
248
+ this._groups.push(group);
249
+ // dispatch event
250
+ this.dispatch({
251
+ type: groups_1.GroupEvent.ADDED,
252
+ data: group
253
+ });
254
+ return group;
255
+ }
256
+ /**
257
+ * Delete group.
258
+ * @param id
259
+ */
260
+ async internalDeleteGroup(id) {
261
+ var _a;
262
+ if (id === undefined || id === null) {
263
+ throw new Error("Group delete, id is undefined or null");
264
+ }
265
+ if (id.length === 0 || id.trim().length === 0) {
266
+ throw new Error("Group delete, id is empty");
267
+ }
268
+ // send request to the server
269
+ const response = await ((_a = this.context
270
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("/api/v1/AccessGroups").searchParam("groupId", id).sendDelete());
271
+ // check response status
272
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
273
+ await responseUtils_1.ResponseUtils.throwError(`Failed to delete group: ${id}, organization: ${this.organization.id}`, response);
274
+ }
275
+ // delete group from collection
276
+ const group = this._groups.find(f => f.id === id);
277
+ const index = this._groups.indexOf(group);
278
+ if (index < 0) {
279
+ throw new Error("Group delete, index is not found");
280
+ }
281
+ // remove group from collection
282
+ this._groups.splice(index, 1);
283
+ // dispatch event, group removed
284
+ this.dispatch({
285
+ type: groups_1.GroupEvent.REMOVED,
286
+ data: group
287
+ });
288
+ // dispose group
289
+ group.dispose();
290
+ }
291
+ }
292
+ exports.GroupsImpl = GroupsImpl;
293
+ //# 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":";;;AASA,0DAAsD;AACtD,qCAA6D;AAE7D,gEAA4D;AAK5D,MAAa,SAAU,SAAQ,cAAK;IAMlC,YACmB,OAAgB,EACjB,YAA0B;QAE1C,KAAK,EAAE,CAAA;QAHU,YAAO,GAAP,OAAO,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAc;QAPpC,gBAAW,GAAY,KAAK,CAAA;QAG5B,gBAAW,GAAgB,EAAE,CAAA;IAOrC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAW;QACxB,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QAC1B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAAW;;QAC3B,cAAc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Ef,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,2BAA2B,EAAE,mBAAmB,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAClH,CAAC;QAED,+BAA+B;QAC/B,MAAM,KAAK,GAAc,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACzC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACrD,CAAC;QAED,+BAA+B;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAE7B,gCAAgC;QAChC,IAAI,CAAC,QAAQ,CAAC;YACZ,IAAI,EAAE,mBAAU,CAAC,OAAO;YACxB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAA;QAEF,gBAAgB;QAChB,KAAK,CAAC,OAAO,EAAE,CAAA;IACjB,CAAC;CACF;AA7JD,gCA6JC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Groups = exports.Group = exports.GroupEvent = void 0;
4
+ const events_1 = require("../../events");
5
+ /**
6
+ * Group event.
7
+ */
8
+ var GroupEvent;
9
+ (function (GroupEvent) {
10
+ GroupEvent["ADDED"] = "added";
11
+ GroupEvent["REMOVED"] = "removed";
12
+ GroupEvent["UPDATED"] = "updated";
13
+ })(GroupEvent || (exports.GroupEvent = GroupEvent = {}));
14
+ /**
15
+ * Group.
16
+ */
17
+ class Group extends events_1.EventDispatcher {
18
+ }
19
+ exports.Group = Group;
20
+ /**
21
+ * Groups storage.
22
+ */
23
+ class Groups extends events_1.EventDispatcher {
24
+ }
25
+ exports.Groups = Groups;
26
+ //# sourceMappingURL=groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../../src/storages/groups/groups.ts"],"names":[],"mappings":";;;AAEA,yCAA8C;AAU9C;;GAEG;AACH,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;AACrB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED;;GAEG;AACH,MAAsB,KAAM,SAAQ,wBAAkC;CA+CrE;AA/CD,sBA+CC;AAED;;GAEG;AACH,MAAsB,MAAO,SAAQ,wBAAkC;CA6BtE;AA7BD,wBA6BC"}
@@ -0,0 +1,54 @@
1
+ import { Workspaces } from "../workspaces/workspaces";
2
+ import { OrganizationId } from "./organizations";
3
+ import { GroupId, Groups } from "../groups/groups";
4
+ import { Chats } from "../chats/chats";
5
+ import { EventDispatcher } from "../../events";
6
+ import { UserDto } from "../../dto/userInfoResponse";
7
+ /**
8
+ * Organization event.
9
+ */
10
+ export declare enum OrganizationEvent {
11
+ CHANGED = "changed"
12
+ }
13
+ /**
14
+ * Organization.
15
+ */
16
+ export declare abstract class Organization extends EventDispatcher<OrganizationEvent, Organization> {
17
+ /**
18
+ * Organization id.
19
+ */
20
+ abstract get id(): OrganizationId;
21
+ /**
22
+ * Organization name.
23
+ */
24
+ abstract get name(): string;
25
+ /**
26
+ * Organization description.
27
+ */
28
+ abstract get description(): string;
29
+ /**
30
+ * Workspaces.
31
+ */
32
+ abstract get workspaces(): Workspaces;
33
+ /**
34
+ * Chats.
35
+ */
36
+ abstract get chats(): Chats;
37
+ /**
38
+ * Groups.
39
+ */
40
+ abstract get accessGroups(): Groups;
41
+ /**
42
+ * Get organization members
43
+ */
44
+ abstract members(): Promise<UserDto[]>;
45
+ /**
46
+ * Change organization name and description.
47
+ */
48
+ abstract change(name: string, description: string): Promise<void>;
49
+ /**
50
+ * Create invite link
51
+ */
52
+ abstract createInviteLink(emails: string[], accessGroups: GroupId[]): Promise<void>;
53
+ }
54
+ //# 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,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAGpD;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,8BAAsB,YAAa,SAAQ,eAAe,CAC1D,iBAAiB,EACjB,YAAY,CACX;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;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjE;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CACpF"}
@@ -0,0 +1,32 @@
1
+ import { OrganizationId } from "./organizations";
2
+ import { Disposable } from "../../disposable";
3
+ import { OrganizationDto, UserDto } 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
+ export declare class OrganizationImpl extends Organization implements Disposable {
10
+ private readonly context;
11
+ private _isDisposed;
12
+ private _isAdmin;
13
+ private _content?;
14
+ private readonly _workspaces;
15
+ private readonly _accessGroups;
16
+ private readonly _chats;
17
+ constructor(context: Context);
18
+ initFrom(content: OrganizationDto, isAdmin: boolean): Promise<OrganizationImpl>;
19
+ get isAdmin(): boolean;
20
+ get isDisposed(): boolean;
21
+ dispose(): void;
22
+ get id(): OrganizationId;
23
+ get name(): string;
24
+ get description(): string;
25
+ get workspaces(): Workspaces;
26
+ get accessGroups(): Groups;
27
+ get chats(): Chats;
28
+ members(): Promise<UserDto[]>;
29
+ change(name: string, description: string): Promise<void>;
30
+ createInviteLink(emails: string[], accessGroups: string[]): Promise<void>;
31
+ }
32
+ //# 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,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC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 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
+ await this._workspaces.initFrom(content.id);
25
+ await this._chats.initFrom(content.id);
26
+ await this._accessGroups.initialize();
27
+ return this;
28
+ }
29
+ get isAdmin() {
30
+ return this._isAdmin;
31
+ }
32
+ get isDisposed() {
33
+ return this._isDisposed;
34
+ }
35
+ dispose() {
36
+ this._isDisposed = true;
37
+ }
38
+ get id() {
39
+ var _a;
40
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.id;
41
+ }
42
+ get name() {
43
+ var _a;
44
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.profile.name;
45
+ }
46
+ get description() {
47
+ var _a;
48
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.profile.description;
49
+ }
50
+ get workspaces() {
51
+ return this._workspaces;
52
+ }
53
+ get accessGroups() {
54
+ return this._accessGroups;
55
+ }
56
+ get chats() {
57
+ return this._chats;
58
+ }
59
+ async members() {
60
+ var _a;
61
+ // send request to the server
62
+ const response = await ((_a = this.context
63
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Organizations/members").searchParam("id", this.id).sendGet());
64
+ // check response status
65
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
66
+ await responseUtils_1.ResponseUtils.throwError(`Failed during fetch of organization members ${this.id}`, response);
67
+ }
68
+ return (await response.json()).members;
69
+ }
70
+ async change(name, description) {
71
+ var _a;
72
+ if (!this._content) {
73
+ throw new Error("Organization is not loaded.");
74
+ }
75
+ if (name === this.name && description === this.description) {
76
+ return Promise.resolve();
77
+ }
78
+ if (name === undefined || name === null || name.trim() === "") {
79
+ throw new Error("Name is required. Please provide a valid name.");
80
+ }
81
+ if (description === undefined ||
82
+ description === null ||
83
+ description.trim() === "") {
84
+ throw new Error("Description is required. Please provide a valid description.");
85
+ }
86
+ const response = await ((_a = this.context
87
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Organizations").sendPutJson({
88
+ organizationId: this.id,
89
+ profile: {
90
+ name,
91
+ description
92
+ }
93
+ }));
94
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
95
+ await responseUtils_1.ResponseUtils.throwError("Failed to change organization", response);
96
+ }
97
+ if (this._content) {
98
+ this._content.profile.name = name;
99
+ this._content.profile.description = description;
100
+ }
101
+ this.dispatch({
102
+ type: organization_1.OrganizationEvent.CHANGED,
103
+ data: this
104
+ });
105
+ }
106
+ async createInviteLink(emails, accessGroups) {
107
+ var _a;
108
+ const response = await ((_a = this.context
109
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Invites").sendPostJson({
110
+ organizationId: this.id,
111
+ emails: emails,
112
+ accessGroupIds: accessGroups
113
+ }));
114
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
115
+ await responseUtils_1.ResponseUtils.throwError(`Invite link creation failed for organization ${this.id}`, response);
116
+ }
117
+ }
118
+ }
119
+ exports.OrganizationImpl = OrganizationImpl;
120
+ //# sourceMappingURL=organization.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.impl.js","sourceRoot":"","sources":["../../../../src/storages/organizations/organization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YAAY,CAAC;YACZ,cAAc,EAAE,IAAI,CAAC,EAAE;YACvB,MAAM,EAAE,MAAM;YACd,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;IACH,CAAC;CACF;AApJD,4CAoJC"}
@@ -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;AAI9C;;GAEG;AACH,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;AACrB,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B;AAED;;GAEG;AACH,MAAsB,YAAa,SAAQ,wBAG1C;CA6CA;AAhDD,oCAgDC"}
@@ -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"}