@neuralinnovations/dataisland-sdk 0.0.1-dev1 → 0.0.1-dev11

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 (276) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +174 -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 +98 -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 +140 -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 +40 -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 +56 -0
  53. package/dist/src/index.d.ts.map +1 -0
  54. package/dist/src/index.js +89 -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 +22 -0
  69. package/dist/src/internal/registry.d.ts.map +1 -0
  70. package/dist/src/internal/registry.js +69 -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 +30 -0
  113. package/dist/src/storages/chats/answer.d.ts.map +1 -0
  114. package/dist/src/storages/chats/answer.impl.d.ts +23 -0
  115. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -0
  116. package/dist/src/storages/chats/answer.impl.js +110 -0
  117. package/dist/src/storages/chats/answer.impl.js.map +1 -0
  118. package/dist/src/storages/chats/answer.js +7 -0
  119. package/dist/src/storages/chats/answer.js.map +1 -0
  120. package/dist/src/storages/chats/chat.d.ts +30 -0
  121. package/dist/src/storages/chats/chat.d.ts.map +1 -0
  122. package/dist/src/storages/chats/chat.impl.d.ts +22 -0
  123. package/dist/src/storages/chats/chat.impl.d.ts.map +1 -0
  124. package/dist/src/storages/chats/chat.impl.js +67 -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 +24 -0
  137. package/dist/src/storages/files/file.d.ts.map +1 -0
  138. package/dist/src/storages/files/file.impl.d.ts +18 -0
  139. package/dist/src/storages/files/file.impl.d.ts.map +1 -0
  140. package/dist/src/storages/files/file.impl.js +52 -0
  141. package/dist/src/storages/files/file.impl.js.map +1 -0
  142. package/dist/src/storages/files/file.js +10 -0
  143. package/dist/src/storages/files/file.js.map +1 -0
  144. package/dist/src/storages/files/files.d.ts +33 -0
  145. package/dist/src/storages/files/files.d.ts.map +1 -0
  146. package/dist/src/storages/files/files.impl.d.ts +33 -0
  147. package/dist/src/storages/files/files.impl.d.ts.map +1 -0
  148. package/dist/src/storages/files/files.impl.js +159 -0
  149. package/dist/src/storages/files/files.impl.js.map +1 -0
  150. package/dist/src/storages/files/files.js +19 -0
  151. package/dist/src/storages/files/files.js.map +1 -0
  152. package/dist/src/storages/files/filesPage.d.ts +23 -0
  153. package/dist/src/storages/files/filesPage.d.ts.map +1 -0
  154. package/dist/src/storages/files/filesPage.js +10 -0
  155. package/dist/src/storages/files/filesPage.js.map +1 -0
  156. package/dist/src/storages/groups/groups.d.ts +87 -0
  157. package/dist/src/storages/groups/groups.d.ts.map +1 -0
  158. package/dist/src/storages/groups/groups.impl.d.ts +55 -0
  159. package/dist/src/storages/groups/groups.impl.d.ts.map +1 -0
  160. package/dist/src/storages/groups/groups.impl.js +245 -0
  161. package/dist/src/storages/groups/groups.impl.js.map +1 -0
  162. package/dist/src/storages/groups/groups.js +26 -0
  163. package/dist/src/storages/groups/groups.js.map +1 -0
  164. package/dist/src/storages/organizations/organization.d.ts +38 -0
  165. package/dist/src/storages/organizations/organization.d.ts.map +1 -0
  166. package/dist/src/storages/organizations/organization.impl.d.ts +30 -0
  167. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -0
  168. package/dist/src/storages/organizations/organization.impl.js +71 -0
  169. package/dist/src/storages/organizations/organization.impl.js.map +1 -0
  170. package/dist/src/storages/organizations/organization.js +10 -0
  171. package/dist/src/storages/organizations/organization.js.map +1 -0
  172. package/dist/src/storages/organizations/organizations.d.ts +46 -0
  173. package/dist/src/storages/organizations/organizations.d.ts.map +1 -0
  174. package/dist/src/storages/organizations/organizations.impl.d.ts +38 -0
  175. package/dist/src/storages/organizations/organizations.impl.d.ts.map +1 -0
  176. package/dist/src/storages/organizations/organizations.impl.js +151 -0
  177. package/dist/src/storages/organizations/organizations.impl.js.map +1 -0
  178. package/dist/src/storages/organizations/organizations.js +20 -0
  179. package/dist/src/storages/organizations/organizations.js.map +1 -0
  180. package/dist/src/storages/user/userProfile.d.ts +32 -0
  181. package/dist/src/storages/user/userProfile.d.ts.map +1 -0
  182. package/dist/src/storages/user/userProfile.impl.d.ts +13 -0
  183. package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -0
  184. package/dist/src/storages/user/userProfile.impl.js +51 -0
  185. package/dist/src/storages/user/userProfile.impl.js.map +1 -0
  186. package/dist/src/storages/user/userProfile.js +12 -0
  187. package/dist/src/storages/user/userProfile.js.map +1 -0
  188. package/dist/src/storages/workspaces/workspace.d.ts +40 -0
  189. package/dist/src/storages/workspaces/workspace.d.ts.map +1 -0
  190. package/dist/src/storages/workspaces/workspace.impl.d.ts +22 -0
  191. package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -0
  192. package/dist/src/storages/workspaces/workspace.impl.js +87 -0
  193. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -0
  194. package/dist/src/storages/workspaces/workspace.js +18 -0
  195. package/dist/src/storages/workspaces/workspace.js.map +1 -0
  196. package/dist/src/storages/workspaces/workspaces.d.ts +47 -0
  197. package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -0
  198. package/dist/src/storages/workspaces/workspaces.impl.d.ts +33 -0
  199. package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -0
  200. package/dist/src/storages/workspaces/workspaces.impl.js +157 -0
  201. package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -0
  202. package/dist/src/storages/workspaces/workspaces.js +19 -0
  203. package/dist/src/storages/workspaces/workspaces.js.map +1 -0
  204. package/dist/src/unitTest.d.ts +12 -0
  205. package/dist/src/unitTest.d.ts.map +1 -0
  206. package/dist/src/unitTest.js +44 -0
  207. package/dist/src/unitTest.js.map +1 -0
  208. package/index.d.ts +1 -0
  209. package/index.js +1 -0
  210. package/package.json +41 -3
  211. package/src/appBuilder.ts +24 -5
  212. package/src/commands/startCommandHandler.ts +14 -0
  213. package/src/context.ts +32 -0
  214. package/src/credentials.ts +31 -9
  215. package/src/dataIslandApp.ts +59 -0
  216. package/src/disposable.ts +4 -5
  217. package/src/dto/accessGroupResponse.ts +35 -0
  218. package/src/dto/chatResponse.ts +103 -0
  219. package/src/dto/userInfoResponse.ts +47 -0
  220. package/src/dto/workspacesResponse.ts +49 -0
  221. package/src/events.ts +13 -17
  222. package/src/index.ts +44 -18
  223. package/src/internal/app.impl.ts +97 -32
  224. package/src/internal/appBuilder.impl.ts +39 -12
  225. package/src/internal/createApp.impl.ts +5 -5
  226. package/src/middleware.ts +1 -1
  227. package/src/services/commandService.ts +44 -0
  228. package/src/services/credentialService.ts +3 -3
  229. package/src/services/middlewareService.ts +8 -6
  230. package/src/services/organizationService.ts +28 -0
  231. package/src/services/requestBuilder.ts +127 -0
  232. package/src/services/responseUtils.ts +32 -0
  233. package/src/services/rpcService.ts +129 -52
  234. package/src/services/service.ts +10 -8
  235. package/src/services/userProfileService.ts +38 -0
  236. package/src/storages/chats/answer.impl.ts +163 -0
  237. package/src/storages/chats/answer.ts +42 -0
  238. package/src/storages/chats/chat.impl.ts +87 -0
  239. package/src/storages/chats/chat.ts +38 -0
  240. package/src/storages/chats/chats.impl.ts +142 -0
  241. package/src/storages/chats/chats.ts +47 -0
  242. package/src/storages/files/file.impl.ts +69 -0
  243. package/src/storages/files/file.ts +28 -0
  244. package/src/storages/files/files.impl.ts +213 -0
  245. package/src/storages/files/files.ts +38 -0
  246. package/src/storages/files/filesPage.ts +27 -0
  247. package/src/storages/groups/groups.impl.ts +326 -0
  248. package/src/storages/groups/groups.ts +101 -0
  249. package/src/storages/organizations/organization.impl.ts +95 -0
  250. package/src/storages/organizations/organization.ts +44 -0
  251. package/src/storages/organizations/organizations.impl.ts +197 -0
  252. package/src/storages/organizations/organizations.ts +56 -0
  253. package/src/storages/user/userProfile.impl.ts +56 -0
  254. package/src/storages/user/userProfile.ts +42 -0
  255. package/src/storages/workspaces/workspace.impl.ts +109 -0
  256. package/src/storages/workspaces/workspace.ts +49 -0
  257. package/src/storages/workspaces/workspaces.impl.ts +212 -0
  258. package/src/storages/workspaces/workspaces.ts +53 -0
  259. package/src/unitTest.ts +53 -0
  260. package/.browserslistrc +0 -5
  261. package/.editorconfig +0 -22
  262. package/.eslintrc.json +0 -44
  263. package/.github/workflows/publish-npm.yml +0 -28
  264. package/.prettierignore +0 -1
  265. package/.prettierrc +0 -11
  266. package/.yarnrc +0 -2
  267. package/babel.config.js +0 -6
  268. package/jest.config.ts +0 -199
  269. package/src/appSdk.ts +0 -40
  270. package/src/internal/context.ts +0 -13
  271. package/src/types.ts +0 -110
  272. package/test/disposable.test.ts +0 -39
  273. package/test/events.test.ts +0 -151
  274. package/test/index.test.ts +0 -83
  275. package/test/registry.test.ts +0 -44
  276. package/tsconfig.json +0 -31
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RpcService = void 0;
4
+ const service_1 = require("./service");
5
+ const middlewareService_1 = require("./middlewareService");
6
+ const requestBuilder_1 = require("./requestBuilder");
7
+ /**
8
+ * RPC service.
9
+ */
10
+ class RpcService extends service_1.Service {
11
+ constructor(serviceContext,
12
+ /**
13
+ * Host of the RPC service.
14
+ * It is not used if you use the `urlBuilder` option.
15
+ */
16
+ host,
17
+ /**
18
+ * Options for the RpcService.
19
+ */
20
+ options) {
21
+ super(serviceContext);
22
+ this.host = host;
23
+ this.options = options;
24
+ serviceContext.onRegister = async () => {
25
+ var _a;
26
+ (_a = serviceContext.resolve(middlewareService_1.MiddlewareService)) === null || _a === void 0 ? void 0 : _a.useMiddleware((req, next) => {
27
+ if (!req.headers.has("accept")) {
28
+ req.headers.set("accept", "text/plain");
29
+ }
30
+ if (req.discardContentType) {
31
+ delete req.discardContentType;
32
+ }
33
+ else {
34
+ req.headers.set("content-type", "application/json");
35
+ }
36
+ return next(req);
37
+ });
38
+ };
39
+ }
40
+ /**
41
+ * Request method.
42
+ */
43
+ async request(req) {
44
+ var _a, _b, _c;
45
+ const middlewareService = this.resolve(middlewareService_1.MiddlewareService);
46
+ if (middlewareService !== undefined) {
47
+ return await middlewareService.process(req, async (req) => {
48
+ var _a, _b, _c;
49
+ return (_c = (await ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.fetchMethod) === null || _b === void 0 ? void 0 : _b.call(_a, req)))) !== null && _c !== void 0 ? _c : (await fetch(req));
50
+ });
51
+ }
52
+ return (_c = (await ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.fetchMethod) === null || _b === void 0 ? void 0 : _b.call(_a, req)))) !== null && _c !== void 0 ? _c : (await fetch(req));
53
+ }
54
+ /**
55
+ * Build URL.
56
+ * @param path
57
+ */
58
+ buildUrl(path) {
59
+ if (this.options !== undefined && this.options.urlBuilder !== undefined) {
60
+ return this.options.urlBuilder(path);
61
+ }
62
+ if (this.host.endsWith("/") && path.startsWith("/")) {
63
+ return new URL(`${this.host}${path.slice(1)}`);
64
+ }
65
+ if (!this.host.endsWith("/") && !path.startsWith("/")) {
66
+ return new URL(`${this.host}/${path}`);
67
+ }
68
+ return new URL(`${this.host}${path}`);
69
+ }
70
+ /**
71
+ * Create a request builder.
72
+ * @param path
73
+ */
74
+ requestBuilder(path) {
75
+ return new requestBuilder_1.RequestBuilder(this.buildUrl(path), this.request.bind(this));
76
+ }
77
+ /**
78
+ * Send a GET request.
79
+ * @param path
80
+ * @param options
81
+ */
82
+ async get(path, options) {
83
+ return this.requestBuilder(path)
84
+ .searchParams(options === null || options === void 0 ? void 0 : options.searchParams)
85
+ .headers(options === null || options === void 0 ? void 0 : options.headers)
86
+ .sendGet();
87
+ }
88
+ /**
89
+ * Send a POST request.
90
+ * @param path
91
+ * @param body JSON object
92
+ * @param options
93
+ */
94
+ async post(path, body, options) {
95
+ return this.requestBuilder(path)
96
+ .searchParams(options === null || options === void 0 ? void 0 : options.searchParams)
97
+ .headers(options === null || options === void 0 ? void 0 : options.headers)
98
+ .sendPostJson(body);
99
+ }
100
+ /**
101
+ * Send a PUT request.
102
+ * @param path
103
+ * @param body JSON object
104
+ * @param options
105
+ */
106
+ async put(path, body, options) {
107
+ return this.requestBuilder(path)
108
+ .searchParams(options === null || options === void 0 ? void 0 : options.searchParams)
109
+ .headers(options === null || options === void 0 ? void 0 : options.headers)
110
+ .sendPutJson(body);
111
+ }
112
+ /**
113
+ * Send a DELETE request.
114
+ * @param path
115
+ * @param options
116
+ */
117
+ async delete(path, options) {
118
+ return this.requestBuilder(path)
119
+ .searchParams(options === null || options === void 0 ? void 0 : options.searchParams)
120
+ .headers(options === null || options === void 0 ? void 0 : options.headers)
121
+ .sendDelete();
122
+ }
123
+ }
124
+ exports.RpcService = RpcService;
125
+ //# sourceMappingURL=rpcService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpcService.js","sourceRoot":"","sources":["../../../src/services/rpcService.ts"],"names":[],"mappings":";;;AAAA,uCAAwD;AACxD,2DAAuD;AACvD,qDAAiD;AAUjD;;GAEG;AACH,MAAa,UAAW,SAAQ,iBAAO;IAErC,YACE,cAA8B;IAC9B;;;OAGG;IACa,IAAY;IAC5B;;OAEG;IACc,OAKhB;QAED,KAAK,CAAC,cAAc,CAAC,CAAA;QAXL,SAAI,GAAJ,IAAI,CAAQ;QAIX,YAAO,GAAP,OAAO,CAKvB;QAID,cAAc,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE;;YACrC,MAAA,cAAc,CAAC,OAAO,CAAC,qCAAiB,CAAC,0CAAE,aAAa,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBACrE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC/B,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;gBACzC,CAAC;gBAED,IAAK,GAAW,CAAC,kBAAkB,EAAE,CAAC;oBACpC,OAAQ,GAAW,CAAC,kBAAkB,CAAA;gBACxC,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;gBACrD,CAAC;gBAED,OAAO,IAAI,CAAC,GAAG,CAAC,CA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AAO,uBAAP,OAAO,CAAE,OAAO,CAAC;aACzB,WAAW,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;aAC7B,YAAY,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC;aACnC,OAAO,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC;aACzB,UAAU,EAAE,CAAA;IACjB,CAAC;CACF;AArID,gCAqIC"}
@@ -0,0 +1,21 @@
1
+ import { type Context } from "../context";
2
+ import { type Constructor } from "../internal/registry";
3
+ import { type DisposableContainer, type Lifetime } from "../disposable";
4
+ export declare class ServiceContext {
5
+ readonly context: Context;
6
+ private readonly disposableContainer;
7
+ constructor(context: Context, disposableContainer: DisposableContainer);
8
+ get lifetime(): Lifetime;
9
+ resolve<T>(type: Constructor<T>): T | undefined;
10
+ onRegister: () => Promise<void>;
11
+ onStart: () => Promise<void>;
12
+ onUnregister: () => void;
13
+ }
14
+ export declare abstract class Service {
15
+ private readonly serviceContext;
16
+ resolve<T>(type: Constructor<T>): T | undefined;
17
+ get lifetime(): Lifetime;
18
+ get context(): Context;
19
+ constructor(serviceContext: ServiceContext);
20
+ }
21
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEvE,qBAAa,cAAc;aAEP,OAAO,EAAE,OAAO;IAChC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBADpB,OAAO,EAAE,OAAO,EACf,mBAAmB,EAAE,mBAAmB;IAI3D,IAAW,QAAQ,IAAI,QAAQ,CAE9B;IAED,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAIxC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAErC;IAEM,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAElC;IAEM,YAAY,EAAE,MAAM,IAAI,CAE9B;CACF;AAED,8BAAsB,OAAO;IAaR,OAAO,CAAC,QAAQ,CAAC,cAAc;IAZ3C,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAItD,IAAW,QAAQ,IAAI,QAAQ,CAE9B;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;gBAEmC,cAAc,EAAE,cAAc;CAEnE"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Service = exports.ServiceContext = void 0;
4
+ class ServiceContext {
5
+ constructor(context, disposableContainer) {
6
+ this.context = context;
7
+ this.disposableContainer = disposableContainer;
8
+ this.onRegister = async () => {
9
+ await Promise.resolve();
10
+ };
11
+ this.onStart = async () => {
12
+ await Promise.resolve();
13
+ };
14
+ this.onUnregister = () => {
15
+ // do nothing
16
+ };
17
+ }
18
+ get lifetime() {
19
+ return this.disposableContainer.lifetime;
20
+ }
21
+ resolve(type) {
22
+ return this.context.resolve(type);
23
+ }
24
+ }
25
+ exports.ServiceContext = ServiceContext;
26
+ class Service {
27
+ resolve(type) {
28
+ return this.serviceContext.resolve(type);
29
+ }
30
+ get lifetime() {
31
+ return this.serviceContext.lifetime;
32
+ }
33
+ get context() {
34
+ return this.serviceContext.context;
35
+ }
36
+ constructor(serviceContext) {
37
+ this.serviceContext = serviceContext;
38
+ }
39
+ }
40
+ exports.Service = Service;
41
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/service.ts"],"names":[],"mappings":";;;AAIA,MAAa,cAAc;IACzB,YACkB,OAAgB,EACf,mBAAwC;QADzC,YAAO,GAAP,OAAO,CAAS;QACf,wBAAmB,GAAnB,mBAAmB,CAAqB;QAYpD,eAAU,GAAwB,KAAK,IAAmB,EAAE;YACjE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;QACzB,CAAC,CAAA;QAEM,YAAO,GAAwB,KAAK,IAAmB,EAAE;YAC9D,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;QACzB,CAAC,CAAA;QAEM,iBAAY,GAAe,GAAS,EAAE;YAC3C,aAAa;QACf,CAAC,CAAA;IApBD,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAA;IAC1C,CAAC;IAED,OAAO,CAAI,IAAoB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;CAaF;AA1BD,wCA0BC;AAED,MAAsB,OAAO;IACpB,OAAO,CAAI,IAAoB;QACpC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAA;IACrC,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAA;IACpC,CAAC;IAED,YAAoC,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAClE,CAAC;CACF;AAfD,0BAeC"}
@@ -0,0 +1,8 @@
1
+ import { Service } from "./service";
2
+ import { UserProfile } from "../storages/user/userProfile";
3
+ export declare class UserProfileService extends Service {
4
+ private readonly impl;
5
+ get userProfile(): UserProfile;
6
+ fetch(): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=userProfileService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userProfileService.d.ts","sourceRoot":"","sources":["../../../src/services/userProfileService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAM1D,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAE9D,IAAI,WAAW,IAAI,WAAW,CAE7B;IAEK,KAAK;CAsBZ"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserProfileService = void 0;
4
+ const service_1 = require("./service");
5
+ const rpcService_1 = require("./rpcService");
6
+ const organizationService_1 = require("./organizationService");
7
+ const userProfile_impl_1 = require("../storages/user/userProfile.impl");
8
+ const responseUtils_1 = require("./responseUtils");
9
+ class UserProfileService extends service_1.Service {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.impl = new userProfile_impl_1.UserProfileImpl();
13
+ }
14
+ get userProfile() {
15
+ return this.impl;
16
+ }
17
+ async fetch() {
18
+ const rpc = this.resolve(rpcService_1.RpcService);
19
+ const response = await rpc.requestBuilder("api/v1/Users/self2").sendGet();
20
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
21
+ await responseUtils_1.ResponseUtils.throwError("Failed to fetch user profile", response);
22
+ }
23
+ const content = (await response.json());
24
+ // init user profile from the server's response
25
+ this.impl.initFrom(content);
26
+ const organizationService = this.resolve(organizationService_1.OrganizationService);
27
+ // init organization service from user profile
28
+ await organizationService.initFrom(content.adminInOrganization, content.organizations, content.user.settings);
29
+ }
30
+ }
31
+ exports.UserProfileService = UserProfileService;
32
+ //# sourceMappingURL=userProfileService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userProfileService.js","sourceRoot":"","sources":["../../../src/services/userProfileService.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,6CAAyC;AAGzC,+DAA2D;AAC3D,wEAAmE;AACnE,mDAA+C;AAE/C,MAAa,kBAAmB,SAAQ,iBAAO;IAA/C;;QACmB,SAAI,GAAoB,IAAI,kCAAe,EAAE,CAAA;IA4BhE,CAAC;IA1BC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAU,CAAe,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAA;QACzE,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAA;QAC1E,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAqB,CAAA;QAE3D,+CAA+C;QAC/C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAE3B,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CACtC,yCAAmB,CACG,CAAA;QAExB,8CAA8C;QAC9C,MAAM,mBAAmB,CAAC,QAAQ,CAChC,OAAO,CAAC,mBAAmB,EAC3B,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,CACtB,CAAA;IACH,CAAC;CACF;AA7BD,gDA6BC"}
@@ -0,0 +1,30 @@
1
+ import { AnswerStatus, FetchTokensResponse, SourceDto, StepType } from "../../dto/chatResponse";
2
+ export type AnswerId = string;
3
+ export type StepId = string;
4
+ export declare abstract class Answer {
5
+ /**
6
+ * Answer id.
7
+ */
8
+ abstract get id(): AnswerId;
9
+ /**
10
+ * Answer status.
11
+ */
12
+ abstract get status(): AnswerStatus;
13
+ /**
14
+ * Answer sources.
15
+ */
16
+ abstract sources(type: StepType): Promise<SourceDto[]>;
17
+ /**
18
+ * Fetch answer.
19
+ */
20
+ abstract fetch(): Promise<void>;
21
+ /**
22
+ * Fetch answer.
23
+ */
24
+ abstract fetchTokens(type: StepType, tokenStartAt: number): Promise<FetchTokensResponse>;
25
+ /**
26
+ * Cancel answer
27
+ */
28
+ abstract cancel(): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=answer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../../../src/storages/chats/answer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACT,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,8BAAsB,MAAM;IAE1B;;OAEG;IACH,QAAQ,KAAK,EAAE,IAAI,QAAQ,CAAA;IAE3B;;OAEG;IACH,QAAQ,KAAK,MAAM,IAAI,YAAY,CAAA;IAEnC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAExF;;OAEG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CACjC"}
@@ -0,0 +1,23 @@
1
+ import { Context } from "../../context";
2
+ import { AnswerDto, AnswerStatus, FetchTokensResponse, SourceDto, StepType } from "../../dto/chatResponse";
3
+ import { Answer, AnswerId } from "./answer";
4
+ import { Chat } from "./chat";
5
+ export declare class AnswerImpl extends Answer {
6
+ private readonly chat;
7
+ private readonly context;
8
+ private _content?;
9
+ private _steps?;
10
+ private _status?;
11
+ private _id?;
12
+ constructor(chat: Chat, context: Context);
13
+ initFromData(answer: AnswerDto): Promise<AnswerImpl>;
14
+ initFromId(id: AnswerId): Promise<AnswerImpl>;
15
+ get id(): string;
16
+ get status(): AnswerStatus;
17
+ private getStep;
18
+ sources(type: StepType): Promise<SourceDto[]>;
19
+ fetch(): Promise<void>;
20
+ fetchTokens(type: StepType, token_start_at: number): Promise<FetchTokensResponse>;
21
+ cancel(): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=answer.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/chats/answer.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,SAAS,EACT,YAAY,EAGZ,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACT,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,qBAAa,UAAW,SAAQ,MAAM;IAQlC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,OAAO,CAAC,QAAQ,CAAC,CAAW;IAE5B,OAAO,CAAC,MAAM,CAAC,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAC,CAAc;IAC9B,OAAO,CAAC,GAAG,CAAC,CAAU;gBAGH,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO;IAI7B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAUpD,UAAU,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IASnD,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,MAAM,IAAI,YAAY,CAEzB;IAED,OAAO,CAAC,OAAO;IAIT,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA+B7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBtB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgCjF,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAe9B"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnswerImpl = void 0;
4
+ const responseUtils_1 = require("../../services/responseUtils");
5
+ const rpcService_1 = require("../../services/rpcService");
6
+ const answer_1 = require("./answer");
7
+ class AnswerImpl extends answer_1.Answer {
8
+ constructor(chat, context) {
9
+ super();
10
+ this.chat = chat;
11
+ this.context = context;
12
+ }
13
+ async initFromData(answer) {
14
+ this._content = answer;
15
+ this._id = answer.id;
16
+ // fetch answer
17
+ await this.fetch();
18
+ return this;
19
+ }
20
+ async initFromId(id) {
21
+ this._id = id;
22
+ // fetch answer
23
+ await this.fetch();
24
+ return this;
25
+ }
26
+ get id() {
27
+ return this._id;
28
+ }
29
+ get status() {
30
+ return this._status;
31
+ }
32
+ getStep(type) {
33
+ var _a;
34
+ return (_a = this._steps) === null || _a === void 0 ? void 0 : _a.find(step => step.type === type);
35
+ }
36
+ async sources(type) {
37
+ var _a;
38
+ // fetch answer
39
+ await this.fetch();
40
+ // get step
41
+ const step = this.getStep(type);
42
+ // check step
43
+ if (!step) {
44
+ throw new Error(`Step with type ${type.toString()} is not found, answer: ${this.id}, organization: ${this.chat.organization.id}`);
45
+ }
46
+ // get sources
47
+ const response = await ((_a = this.context
48
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Chats/answer/sources").searchParam("chat_uid", this.chat.id).searchParam("uid", this.id).searchParam("step_id", step.id).sendGet());
49
+ // check response status
50
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
51
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get sources for ${type.toString()}, answer: ${this.id}, organization: ${this.chat.organization.id}`, response);
52
+ }
53
+ // parse sources from the server's response
54
+ const sources = (await response.json()).sources;
55
+ return sources;
56
+ }
57
+ async fetch() {
58
+ var _a;
59
+ // fetch answer from position 0
60
+ const position = 0;
61
+ // fetch answer
62
+ const response = await ((_a = this.context
63
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Chats/answer/fetch").searchParam("chatId", this.chat.id).searchParam("questionId", this.id).searchParam("position", position.toString()).sendGet());
64
+ // check response status
65
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
66
+ await responseUtils_1.ResponseUtils.throwError(`Failed to fetch answer ${this.id}`, response);
67
+ }
68
+ // parse answer from the server's response
69
+ const answer = (await response.json());
70
+ // update answer
71
+ this._status = answer.status;
72
+ this._steps = answer.steps;
73
+ }
74
+ async fetchTokens(type, token_start_at) {
75
+ var _a;
76
+ // fetch answer
77
+ await this.fetch();
78
+ // get step
79
+ const step = this.getStep(type);
80
+ // check step
81
+ if (!step) {
82
+ throw new Error(`Step with type ${type.toString()} is not found`);
83
+ }
84
+ // get tokens
85
+ const response = await ((_a = this.context
86
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Chats/answer/fetch/tokens").searchParam("chat_uid", this.chat.id).searchParam("uid", this.id).searchParam("step_id", step.id).searchParam("token_start_at", token_start_at.toString()).sendGet());
87
+ // check response status
88
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
89
+ await responseUtils_1.ResponseUtils.throwError(`Failed to get sources for ${type.toString()}`, response);
90
+ }
91
+ // parse tokens from the server's response
92
+ const tokens = (await response.json());
93
+ return tokens;
94
+ }
95
+ async cancel() {
96
+ var _a;
97
+ // send request to the server
98
+ const response = await ((_a = this.context
99
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Chats/answer/cancel").sendPutJson({
100
+ chat_id: this.chat.id,
101
+ uid: this.id
102
+ }));
103
+ // check response status
104
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
105
+ await responseUtils_1.ResponseUtils.throwError("Failed to cancel a question", response);
106
+ }
107
+ }
108
+ }
109
+ exports.AnswerImpl = AnswerImpl;
110
+ //# sourceMappingURL=answer.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer.impl.js","sourceRoot":"","sources":["../../../../src/storages/chats/answer.impl.ts"],"names":[],"mappings":";;;AAUA,gEAA4D;AAC5D,0DAAsD;AACtD,qCAA2C;AAG3C,MAAa,UAAW,SAAQ,eAAM;IAOpC,YACmB,IAAU,EACV,OAAgB;QACjC,KAAK,EAAE,CAAA;QAFU,SAAI,GAAJ,IAAI,CAAM;QACV,YAAO,GAAP,OAAO,CAAS;IAEnC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAiB;QAClC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAA;QAEpB,eAAe;QACf,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAElB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAY;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QAEb,eAAe;QACf,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAElB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,EAAE;QACJ,OAAe,IAAI,CAAC,GAAG,CAAA;IACzB,CAAC;IAED,IAAI,MAAM;QACR,OAAqB,IAAI,CAAC,OAAO,CAAA;IACnC,CAAC;IAEO,OAAO,CAAC,IAAc;;QAC5B,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,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,IAAI,CAAC,IAAI,CAAC,EAAE,EACpC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAC1B,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAC9B,WAAW,CAAC,gBAAgB,EAAE,cAAc,CAAC,QAAQ,EAAE,EACvD,OAAO,EAAE,CAAA,CAAA;QAEZ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAC1F,CAAC;QAED,0CAA0C;QAC1C,MAAM,MAAM,GAAG,CAAC,MAAM,QAAS,CAAC,IAAI,EAAE,CAAwB,CAAA;QAE9D,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,MAAM;;QACV,6BAA6B;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,4BAA4B,EAC5C,WAAW,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YACrB,GAAG,EAAE,IAAI,CAAC,EAAE;SACb,CAAC,CAAA,CAAA;QAEJ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAA;QACzE,CAAC;IACH,CAAC;CACF;AAnJD,gCAmJC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Answer = void 0;
4
+ class Answer {
5
+ }
6
+ exports.Answer = Answer;
7
+ //# sourceMappingURL=answer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer.js","sourceRoot":"","sources":["../../../../src/storages/chats/answer.ts"],"names":[],"mappings":";;;AAUA,MAAsB,MAAM;CA+B3B;AA/BD,wBA+BC"}
@@ -0,0 +1,30 @@
1
+ import { Answer } from "./answer";
2
+ import { Organization } from "../organizations/organization";
3
+ export type ChatId = string;
4
+ export declare enum ChatAnswerType {
5
+ SHORT = "short",
6
+ LONG = "long"
7
+ }
8
+ export declare abstract class Chat {
9
+ /**
10
+ * Organization.
11
+ */
12
+ abstract get organization(): Organization;
13
+ /**
14
+ * Chat id.
15
+ */
16
+ abstract get id(): ChatId;
17
+ /**
18
+ * Chat name.
19
+ */
20
+ abstract get name(): string;
21
+ /**
22
+ * Answers list.
23
+ */
24
+ abstract get collection(): ReadonlyArray<Answer>;
25
+ /**
26
+ * Ask new question in chat.
27
+ */
28
+ abstract ask(message: string, answerType: ChatAnswerType): Promise<Answer>;
29
+ }
30
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../src/storages/chats/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAE5D,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,oBAAY,cAAc;IACxB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,8BAAsB,IAAI;IAExB;;OAEG;IACH,QAAQ,KAAK,YAAY,IAAI,YAAY,CAAA;IAEzC;;OAEG;IACH,QAAQ,KAAK,EAAE,IAAI,MAAM,CAAA;IAEzB;;OAEG;IACH,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAA;IAE3B;;OAEG;IACH,QAAQ,KAAK,UAAU,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;IAEhD;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;CAC3E"}
@@ -0,0 +1,22 @@
1
+ import { Chat, ChatAnswerType } from "./chat";
2
+ import { Disposable } from "../../disposable";
3
+ import { Answer } from "./answer";
4
+ import { ChatDto } from "../../dto/chatResponse";
5
+ import { Context } from "../../context";
6
+ import { Organization } from "../organizations/organization";
7
+ export declare class ChatImpl extends Chat implements Disposable {
8
+ private readonly context;
9
+ readonly organization: Organization;
10
+ private _isDisposed;
11
+ private readonly _answers;
12
+ private _content?;
13
+ constructor(context: Context, organization: Organization);
14
+ initFrom(chat: ChatDto): Promise<ChatImpl>;
15
+ get id(): string;
16
+ get name(): string;
17
+ get collection(): readonly Answer[];
18
+ get isDisposed(): boolean;
19
+ ask(message: string, answerType: ChatAnswerType): Promise<Answer>;
20
+ dispose(): void;
21
+ }
22
+ //# sourceMappingURL=chat.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/chats/chat.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAE5D,qBAAa,QAAS,SAAQ,IAAK,YAAW,UAAU;IAOpD,OAAO,CAAC,QAAQ,CAAC,OAAO;aACR,YAAY,EAAE,YAAY;IAP5C,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IAExC,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAGP,OAAO,EAAE,OAAO,EACjB,YAAY,EAAE,YAAY;IAKtC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAehD,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,UAAU,IAAI,SAAS,MAAM,EAAE,CAElC;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAEK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BvE,OAAO,IAAI,IAAI;CAIhB"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatImpl = void 0;
4
+ const chat_1 = require("./chat");
5
+ const answer_impl_1 = require("./answer.impl");
6
+ const rpcService_1 = require("../../services/rpcService");
7
+ const responseUtils_1 = require("../../services/responseUtils");
8
+ class ChatImpl extends chat_1.Chat {
9
+ constructor(context, organization) {
10
+ super();
11
+ this.context = context;
12
+ this.organization = organization;
13
+ this._isDisposed = false;
14
+ this._answers = [];
15
+ }
16
+ async initFrom(chat) {
17
+ this._content = chat;
18
+ // init answers
19
+ for (const ans of chat.answers) {
20
+ // create answer implementation
21
+ const answer = await new answer_impl_1.AnswerImpl(this, this.context).initFromData(ans);
22
+ // add answer to the collection
23
+ this._answers.push(answer);
24
+ }
25
+ return this;
26
+ }
27
+ get id() {
28
+ var _a;
29
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.id;
30
+ }
31
+ get name() {
32
+ var _a;
33
+ return (_a = this._content) === null || _a === void 0 ? void 0 : _a.name;
34
+ }
35
+ get collection() {
36
+ return this._answers;
37
+ }
38
+ get isDisposed() {
39
+ return this._isDisposed;
40
+ }
41
+ async ask(message, answerType) {
42
+ var _a;
43
+ // send request to the server
44
+ const response = await ((_a = this.context
45
+ .resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Chats/question").sendPutJson({
46
+ chatId: this.id,
47
+ questionMessage: message,
48
+ isLongAnswer: (answerType === chat_1.ChatAnswerType.LONG)
49
+ }));
50
+ // check response status
51
+ if (responseUtils_1.ResponseUtils.isFail(response)) {
52
+ await responseUtils_1.ResponseUtils.throwError(`Failed to ask a question, organization: ${this.organization.id}`, response);
53
+ }
54
+ // parse answer id from the server's response
55
+ const id = (await response.json()).id;
56
+ // create answer implementation
57
+ const answer = await new answer_impl_1.AnswerImpl(this, this.context).initFromId(id);
58
+ // add answer to the collection
59
+ this._answers.push(answer);
60
+ return answer;
61
+ }
62
+ dispose() {
63
+ this._isDisposed = true;
64
+ }
65
+ }
66
+ exports.ChatImpl = ChatImpl;
67
+ //# sourceMappingURL=chat.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.impl.js","sourceRoot":"","sources":["../../../../src/storages/chats/chat.impl.ts"],"names":[],"mappings":";;;AAAA,iCAA6C;AAK7C,+CAA0C;AAC1C,0DAAsD;AACtD,gEAA4D;AAG5D,MAAa,QAAS,SAAQ,WAAI;IAMhC,YACmB,OAAgB,EACjB,YAA0B;QAE1C,KAAK,EAAE,CAAA;QAHU,YAAO,GAAP,OAAO,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAc;QAPpC,gBAAW,GAAY,KAAK,CAAA;QACnB,aAAQ,GAAa,EAAE,CAAA;IASxC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAa;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QAEpB,eAAe;QACf,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC/B,+BAA+B;YAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,wBAAU,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;YAEzE,+BAA+B;YAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC5B,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,EA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CAAA;IACzB,CAAC;CAEF;AA5ED,4BA4EC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Chat = exports.ChatAnswerType = void 0;
4
+ var ChatAnswerType;
5
+ (function (ChatAnswerType) {
6
+ ChatAnswerType["SHORT"] = "short";
7
+ ChatAnswerType["LONG"] = "long";
8
+ })(ChatAnswerType || (exports.ChatAnswerType = ChatAnswerType = {}));
9
+ class Chat {
10
+ }
11
+ exports.Chat = Chat;
12
+ //# sourceMappingURL=chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../src/storages/chats/chat.ts"],"names":[],"mappings":";;;AAKA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,MAAsB,IAAI;CA0BzB;AA1BD,oBA0BC"}
@@ -0,0 +1,40 @@
1
+ import { EventDispatcher } from "../../events";
2
+ import { Chat, ChatId } from "./chat";
3
+ import { Organization } from "../organizations/organization";
4
+ export declare enum ChatsEvent {
5
+ ADDED = "added",
6
+ REMOVED = "removed"
7
+ }
8
+ /**
9
+ * Chats storage.
10
+ */
11
+ export declare abstract class Chats extends EventDispatcher<ChatsEvent, Chat> {
12
+ /**
13
+ * Organization.
14
+ */
15
+ abstract get organization(): Organization;
16
+ /**
17
+ * Chats list.
18
+ */
19
+ abstract get collection(): ReadonlyArray<Chat>;
20
+ /**
21
+ * Create new chat.
22
+ */
23
+ abstract create(): Promise<Chat>;
24
+ /**
25
+ * Get chat by id.
26
+ * @param id
27
+ */
28
+ abstract get(id: ChatId): Chat;
29
+ /**
30
+ * Try to get chat by id.
31
+ * @param id
32
+ */
33
+ abstract tryGet(id: ChatId): Chat | undefined;
34
+ /**
35
+ * Delete chat.
36
+ * @param id
37
+ */
38
+ abstract delete(id: ChatId): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=chats.d.ts.map