@neuralinnovations/dataisland-sdk 0.0.1-dev25 → 0.0.1-dev26
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.
- package/README.md +8 -26
- package/dist/package.json +10 -10
- package/dist/src/commands/deleteUserFullCommandHandler.d.ts +7 -0
- package/dist/src/commands/deleteUserFullCommandHandler.d.ts.map +1 -0
- package/dist/src/commands/deleteUserFullCommandHandler.js +21 -0
- package/dist/src/commands/deleteUserFullCommandHandler.js.map +1 -0
- package/dist/src/dto/chatResponse.d.ts +9 -6
- package/dist/src/dto/chatResponse.d.ts.map +1 -1
- package/dist/src/dto/chatResponse.js.map +1 -1
- package/dist/src/internal/app.impl.d.ts.map +1 -1
- package/dist/src/internal/app.impl.js +4 -0
- package/dist/src/internal/app.impl.js.map +1 -1
- package/dist/src/storages/chats/answer.d.ts +8 -11
- package/dist/src/storages/chats/answer.d.ts.map +1 -1
- package/dist/src/storages/chats/answer.impl.d.ts +11 -8
- package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/answer.impl.js +28 -57
- package/dist/src/storages/chats/answer.impl.js.map +1 -1
- package/dist/src/storages/chats/answer.js +1 -0
- package/dist/src/storages/chats/answer.js.map +1 -1
- package/dist/src/storages/chats/chat.d.ts +0 -4
- package/dist/src/storages/chats/chat.d.ts.map +1 -1
- package/dist/src/storages/chats/chat.impl.d.ts +2 -3
- package/dist/src/storages/chats/chat.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/chat.impl.js +2 -26
- package/dist/src/storages/chats/chat.impl.js.map +1 -1
- package/dist/src/storages/chats/chat.js.map +1 -1
- package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -1
- package/dist/src/storages/workspaces/workspaces.impl.js +4 -2
- package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -1
- package/dist/src/unitTest.d.ts +1 -1
- package/dist/src/unitTest.d.ts.map +1 -1
- package/dist/src/unitTest.js +3 -3
- package/dist/src/unitTest.js.map +1 -1
- package/package.json +11 -11
- package/src/commands/deleteUserFullCommandHandler.ts +19 -0
- package/src/dto/chatResponse.ts +10 -6
- package/src/internal/app.impl.ts +7 -0
- package/src/storages/chats/answer.impl.ts +36 -81
- package/src/storages/chats/answer.ts +9 -16
- package/src/storages/chats/chat.impl.ts +5 -36
- package/src/storages/chats/chat.ts +0 -4
- package/src/storages/workspaces/workspaces.impl.ts +4 -1
- package/src/unitTest.ts +3 -3
package/README.md
CHANGED
@@ -214,7 +214,7 @@ You can access all chats list using **collection** property.
|
|
214
214
|
const chats = organization.chats.collection
|
215
215
|
```
|
216
216
|
|
217
|
-
Main chat functionality is answer handling. You can create
|
217
|
+
Main chat functionality is answer handling. You can create and cancel answer in the chat. Answer is a data object which contains question, answer (tokens), and answer sources.
|
218
218
|
|
219
219
|
Here are some examples:
|
220
220
|
|
@@ -222,49 +222,33 @@ Here are some examples:
|
|
222
222
|
const answer = await chat.ask("Hello!", ChatAnswerType.SHORT)
|
223
223
|
|
224
224
|
await chat.getAnswer(answer.id).cancel()
|
225
|
-
|
226
|
-
```
|
227
|
-
|
228
|
-
Answer can be updated using fetch method.
|
229
|
-
|
230
|
-
```
|
231
|
-
await chat.getAnswer(answer.id).fetch()
|
232
225
|
```
|
233
226
|
|
234
|
-
Answer have two main states: running and done. This states is represented in answer status propery.
|
227
|
+
```Answer have two main states: running and done. This states is represented in answer status propery.
|
235
228
|
Main statuses are RUNNING, SUCCESS, CANCELED, FAIL. You can use them to correctly draw answer in chat.
|
236
229
|
|
237
230
|
```
|
238
231
|
status = chat.getAnswer(answer.id).status
|
239
232
|
```
|
240
|
-
|
241
|
-
Answer is consists of step. Main steps are Prepare, Generate answer, Sources and Done. Each step also includes tokens that model generate during execution. You can access them using fetch_tokens method.
|
233
|
+
You can access answer for your question in "tokens" property, question is stored in "question' property.
|
242
234
|
|
243
235
|
```
|
244
|
-
const tokens = await chat.getAnswer(answer.id).
|
236
|
+
const tokens = await chat.getAnswer(answer.id).tokens
|
237
|
+
const question = await chat.getAnswer(answer.id).question
|
245
238
|
```
|
246
|
-
|
247
|
-
Every step also includes Sources that were used during execution. Step "Sources" contains all sources of all answer steps.
|
239
|
+
Every step also includes Sources that were used during execution. Property "sources" contains all sources of all answer steps.
|
248
240
|
|
249
241
|
```
|
250
|
-
const sources = await chat.getAnswer(answer.id).sources
|
242
|
+
const sources = await chat.getAnswer(answer.id).sources
|
251
243
|
```
|
252
|
-
|
253
244
|
If you want to get chat history, you can access chat.collection property
|
254
245
|
|
255
246
|
```
|
256
247
|
const answers = chat.collection
|
257
248
|
```
|
258
|
-
|
259
|
-
After some answer is done, it's content property is become available. There you can have answer data object to draw an answer in history.Every answer from history is accessed from collection after it status is changed from RUNNING.
|
260
|
-
|
261
|
-
```
|
262
|
-
const answer = chat.getAnswer(id).content
|
263
|
-
```
|
264
|
-
|
265
249
|
#### Events
|
266
250
|
|
267
|
-
Chat object have a variety of events. You can track chat and answer creation and deletion. Answer also contains "update" event.
|
251
|
+
Chat object have a variety of events. You can track chat and answer creation and deletion. Answer also contains "update" event for updating answer view and stream answer tokens.
|
268
252
|
|
269
253
|
Chat events:
|
270
254
|
|
@@ -282,7 +266,6 @@ Event subscribe example:
|
|
282
266
|
```
|
283
267
|
chat.answer.subscribe((event) => { const answer = event.data }, AnswerEvent.UPDATED)
|
284
268
|
```
|
285
|
-
|
286
269
|
---
|
287
270
|
|
288
271
|
### Use access groups
|
@@ -300,7 +283,6 @@ const group = await organization.accessGroups.create(
|
|
300
283
|
|
301
284
|
await organization.accessGroups.delete(group.id)
|
302
285
|
```
|
303
|
-
|
304
286
|
---
|
305
287
|
|
306
288
|
### Use Invites
|
package/dist/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@neuralinnovations/dataisland-sdk",
|
3
|
-
"version": "0.0.1-
|
3
|
+
"version": "0.0.1-dev26",
|
4
4
|
"description": "SDK for DataIsland project",
|
5
5
|
"licenses": [
|
6
6
|
{
|
@@ -12,6 +12,15 @@
|
|
12
12
|
"type": "git",
|
13
13
|
"url": "https://github.com/NeuralInnovations/dataisland-client-js-sdk.git"
|
14
14
|
},
|
15
|
+
"scripts": {
|
16
|
+
"build": "tsc",
|
17
|
+
"test": "jest",
|
18
|
+
"lint": "eslint --ext .ts,.tsx src test",
|
19
|
+
"lint:fix": "eslint --fix --ext .ts,.tsx src test",
|
20
|
+
"docs": "typedoc --disableSources --includeVersion --plugin typedoc-plugin-markdown --out docs src/index.ts && node scripts/docs/index.js",
|
21
|
+
"version-up-dev": "node scripts/version/up-dev.js && rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs",
|
22
|
+
"release": "rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs"
|
23
|
+
},
|
15
24
|
"publishConfig": {
|
16
25
|
"access": "public"
|
17
26
|
},
|
@@ -33,15 +42,6 @@
|
|
33
42
|
"engines": {
|
34
43
|
"node": ">=16"
|
35
44
|
},
|
36
|
-
"scripts": {
|
37
|
-
"build": "tsc",
|
38
|
-
"test": "jest --runInBand",
|
39
|
-
"lint": "eslint --ext .ts,.tsx src test",
|
40
|
-
"lint:fix": "eslint --fix --ext .ts,.tsx src test",
|
41
|
-
"docs": "typedoc --disableSources --includeVersion --plugin typedoc-plugin-markdown --out docs src/index.ts && node scripts/docs/index.js",
|
42
|
-
"version-up-dev": "node scripts/version/up-dev.js && rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs",
|
43
|
-
"release": "rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs"
|
44
|
-
},
|
45
45
|
"keywords": [
|
46
46
|
"dataisland",
|
47
47
|
"sdk",
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Command, CommandHandler } from "../services/commandService";
|
2
|
+
export declare class DeleteUserFullCommand extends Command {
|
3
|
+
}
|
4
|
+
export declare class DeleteUserFullCommandHandler extends CommandHandler<DeleteUserFullCommand> {
|
5
|
+
execute(message: DeleteUserFullCommand): Promise<void>;
|
6
|
+
}
|
7
|
+
//# sourceMappingURL=deleteUserFullCommandHandler.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"deleteUserFullCommandHandler.d.ts","sourceRoot":"","sources":["../../../src/commands/deleteUserFullCommandHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAIpE,qBAAa,qBAAsB,SAAQ,OAAO;CAEjD;AAED,qBAAa,4BAA6B,SAAQ,cAAc,CAAC,qBAAqB,CAAC;IAE/E,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7D"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DeleteUserFullCommandHandler = exports.DeleteUserFullCommand = void 0;
|
4
|
+
const commandService_1 = require("../services/commandService");
|
5
|
+
const rpcService_1 = require("../services/rpcService");
|
6
|
+
const responseUtils_1 = require("../services/responseUtils");
|
7
|
+
class DeleteUserFullCommand extends commandService_1.Command {
|
8
|
+
}
|
9
|
+
exports.DeleteUserFullCommand = DeleteUserFullCommand;
|
10
|
+
class DeleteUserFullCommandHandler extends commandService_1.CommandHandler {
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
12
|
+
async execute(message) {
|
13
|
+
var _a;
|
14
|
+
const response = await ((_a = this.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("/api/v1/Users/self/full").sendDelete());
|
15
|
+
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
16
|
+
await responseUtils_1.ResponseUtils.throwError("Failed to delete user", response);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
exports.DeleteUserFullCommandHandler = DeleteUserFullCommandHandler;
|
21
|
+
//# sourceMappingURL=deleteUserFullCommandHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"deleteUserFullCommandHandler.js","sourceRoot":"","sources":["../../../src/commands/deleteUserFullCommandHandler.ts"],"names":[],"mappings":";;;AAAA,+DAAoE;AACpE,uDAAmD;AACnD,6DAAyD;AAEzD,MAAa,qBAAsB,SAAQ,wBAAO;CAEjD;AAFD,sDAEC;AAED,MAAa,4BAA6B,SAAQ,+BAAqC;IACrF,6DAA6D;IAC7D,KAAK,CAAC,OAAO,CAAC,OAA8B;;QAC1C,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,uBAAU,CAAC,0CAAE,cAAc,CAAC,yBAAyB,EACtF,UAAU,EAAE,CAAA,CAAA;QAEf,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;CACF;AAVD,oEAUC"}
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import { AnswerId, StepId } from "../storages/chats/answer";
|
2
|
+
import { ChatId } from "../storages/chats/chat";
|
3
|
+
import { UserId } from "../storages/user/userProfile";
|
1
4
|
export interface SourceDto {
|
2
5
|
id: string;
|
3
6
|
name: string;
|
@@ -6,19 +9,19 @@ export interface SourceDto {
|
|
6
9
|
page: number;
|
7
10
|
}
|
8
11
|
export interface AnswerDto {
|
9
|
-
id:
|
10
|
-
chatId:
|
12
|
+
id: AnswerId;
|
13
|
+
chatId: ChatId;
|
11
14
|
question: string;
|
12
15
|
context: string;
|
13
16
|
sources: SourceDto[];
|
14
17
|
timestamp: number;
|
15
18
|
}
|
16
19
|
export interface ChatDto {
|
17
|
-
id:
|
20
|
+
id: ChatId;
|
18
21
|
name: string;
|
19
22
|
createdAt: number;
|
20
23
|
modifiedAt: number;
|
21
|
-
userId:
|
24
|
+
userId: UserId;
|
22
25
|
organizationId: string;
|
23
26
|
workspaceId: string;
|
24
27
|
answers: AnswerDto[];
|
@@ -33,7 +36,7 @@ export declare enum AnswerStatus {
|
|
33
36
|
FAIL = 3
|
34
37
|
}
|
35
38
|
export interface AnswerStepDto {
|
36
|
-
id:
|
39
|
+
id: StepId;
|
37
40
|
type: StepType;
|
38
41
|
status: StepStatus;
|
39
42
|
start_at: string;
|
@@ -42,7 +45,7 @@ export interface AnswerStepDto {
|
|
42
45
|
sources: SourceDto[];
|
43
46
|
}
|
44
47
|
export interface FetchAnswerResponse {
|
45
|
-
id:
|
48
|
+
id: AnswerId;
|
46
49
|
status: AnswerStatus;
|
47
50
|
steps: AnswerStepDto[];
|
48
51
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"chatResponse.d.ts","sourceRoot":"","sources":["../../../src/dto/chatResponse.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,
|
1
|
+
{"version":3,"file":"chatResponse.d.ts","sourceRoot":"","sources":["../../../src/dto/chatResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAErD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf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,SAAS,EAAE,CAAC;CACtB;AAED,oBAAY,UAAU;IACpB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,IAAI,IAAI;IACR,QAAQ,IAAI;CACb;AAED,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,eAAe,IAAI;IACnB,eAAe,IAAI;IACnB,IAAI,KAAK;CACV;AAED,qBAAa,YAAY;WACT,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;WAUlC,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;CAOlD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"chatResponse.js","sourceRoot":"","sources":["../../../src/dto/chatResponse.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"chatResponse.js","sourceRoot":"","sources":["../../../src/dto/chatResponse.ts"],"names":[],"mappings":";;;AAoCA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,qDAAW,CAAA;IACX,uDAAY,CAAA;IACZ,+CAAQ,CAAA;AACV,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAgCD,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,iDAAW,CAAA;IACX,iDAAW,CAAA;IACX,2CAAQ,CAAA;IACR,mDAAY,CAAA;AACd,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAED,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,6CAAW,CAAA;IACX,6DAAmB,CAAA;IACnB,6DAAmB,CAAA;IACnB,wCAAS,CAAA;AACX,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAED,MAAa,YAAY;IAChB,MAAM,CAAC,SAAS,CAAC,IAAc;QACpC,QAAQ,IAAI,EAAE,CAAC;YACf,KAAK,QAAQ,CAAC,eAAe,CAAC;YAC9B,KAAK,QAAQ,CAAC,IAAI,CAAC;YACnB,KAAK,QAAQ,CAAC,eAAe;gBAC3B,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,IAAc;QACrC,QAAQ,IAAI,EAAE,CAAC;YACf,KAAK,QAAQ,CAAC,OAAO;gBACnB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAlBD,oCAkBC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"app.impl.d.ts","sourceRoot":"","sources":["../../../src/internal/app.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIlE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAShD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;
|
1
|
+
{"version":3,"file":"app.impl.d.ts","sourceRoot":"","sources":["../../../src/internal/app.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIlE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAShD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAO1D,qBAAa,iBAAkB,SAAQ,aAAa;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,+BAA+B,CAAgB;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;gBAErC,IAAI,EAAE,MAAM;IAUxB,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,cAAc,GAAG,SAAS,CAE3C;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,cAAc,EAEnC;IAED,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,OAAO,6CAAuE;IAE9E,IAAI,8BAA8B,IAAI,OAAO,CAE5C;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,aAAa,IAAI,aAAa,CAEjC;IAED,IAAI,WAAW,IAAI,WAAW,CAE7B;IAEK,UAAU,CACd,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,GAC1D,OAAO,CAAC,IAAI,CAAC;CA6GjB"}
|
@@ -16,6 +16,7 @@ const startCommandHandler_1 = require("../commands/startCommandHandler");
|
|
16
16
|
const userProfileService_1 = require("../services/userProfileService");
|
17
17
|
const organizationService_1 = require("../services/organizationService");
|
18
18
|
const unitTest_1 = require("../unitTest");
|
19
|
+
const deleteUserFullCommandHandler_1 = require("../commands/deleteUserFullCommandHandler");
|
19
20
|
class DataIslandAppImpl extends dataIslandApp_1.DataIslandApp {
|
20
21
|
constructor(name) {
|
21
22
|
super();
|
@@ -63,6 +64,9 @@ class DataIslandAppImpl extends dataIslandApp_1.DataIslandApp {
|
|
63
64
|
builder.registerCommand(startCommandHandler_1.StartCommand, (context) => {
|
64
65
|
return new startCommandHandler_1.StartCommandHandler(context);
|
65
66
|
});
|
67
|
+
builder.registerCommand(deleteUserFullCommandHandler_1.DeleteUserFullCommand, (context) => {
|
68
|
+
return new deleteUserFullCommandHandler_1.DeleteUserFullCommandHandler(context);
|
69
|
+
});
|
66
70
|
// register services
|
67
71
|
builder.registerService(credentialService_1.CredentialService, (context) => {
|
68
72
|
return new credentialService_1.CredentialService(context);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"app.impl.js","sourceRoot":"","sources":["../../../src/internal/app.impl.ts"],"names":[],"mappings":";;;AAAA,oCAAuC;AAEvC,uDAA4D;AAC5D,yCAAuD;AACvD,wCAAoC;AACpC,8CAAkE;AAClE,iDAAkE;AAClE,qEAAiE;AACjE,qEAAiE;AAEjE,oDAAgD;AAChD,uDAAmD;AACnD,+DAA2D;AAC3D,yEAGwC;AACxC,uEAAmE;AACnE,yEAAqE;AAGrE,0CAAkD;
|
1
|
+
{"version":3,"file":"app.impl.js","sourceRoot":"","sources":["../../../src/internal/app.impl.ts"],"names":[],"mappings":";;;AAAA,oCAAuC;AAEvC,uDAA4D;AAC5D,yCAAuD;AACvD,wCAAoC;AACpC,8CAAkE;AAClE,iDAAkE;AAClE,qEAAiE;AACjE,qEAAiE;AAEjE,oDAAgD;AAChD,uDAAmD;AACnD,+DAA2D;AAC3D,yEAGwC;AACxC,uEAAmE;AACnE,yEAAqE;AAGrE,0CAAkD;AAClD,2FAGiD;AAEjD,MAAa,iBAAkB,SAAQ,6BAAa;IAQlD,YAAY,IAAY;QACtB,KAAK,EAAE,CAAA;QAPD,UAAK,GAAW,oBAAY,CAAA;QAC5B,oCAA+B,GAAY,IAAI,CAAA;QA+BvD,YAAO,GAAG,CAAI,IAAoB,EAAiB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAxB5E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,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D,8CAmKC"}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { AnswerStatus, SourceDto } from "../../dto/chatResponse";
|
2
2
|
import { EventDispatcher } from "../../events";
|
3
3
|
export type AnswerId = string;
|
4
4
|
export type StepId = string;
|
5
5
|
export declare enum AnswerEvent {
|
6
6
|
ADDED = "added",
|
7
7
|
CANCALLED = "cancelled",
|
8
|
+
FAILED = "failed",
|
8
9
|
UPDATED = "updated"
|
9
10
|
}
|
10
11
|
export declare abstract class Answer extends EventDispatcher<AnswerEvent, Answer> {
|
@@ -15,7 +16,11 @@ export declare abstract class Answer extends EventDispatcher<AnswerEvent, Answer
|
|
15
16
|
/**
|
16
17
|
* Answer data object
|
17
18
|
*/
|
18
|
-
abstract get
|
19
|
+
abstract get question(): string;
|
20
|
+
/**
|
21
|
+
* Answer tokens
|
22
|
+
*/
|
23
|
+
abstract get tokens(): string;
|
19
24
|
/**
|
20
25
|
* Answer status.
|
21
26
|
*/
|
@@ -23,15 +28,7 @@ export declare abstract class Answer extends EventDispatcher<AnswerEvent, Answer
|
|
23
28
|
/**
|
24
29
|
* Answer sources.
|
25
30
|
*/
|
26
|
-
abstract sources(
|
27
|
-
/**
|
28
|
-
* Fetch answer.
|
29
|
-
*/
|
30
|
-
abstract fetch(): Promise<void>;
|
31
|
-
/**
|
32
|
-
* Fetch answer.
|
33
|
-
*/
|
34
|
-
abstract fetchTokens(type: StepType, tokenStartAt: number): Promise<FetchTokensResponse>;
|
31
|
+
abstract get sources(): SourceDto[];
|
35
32
|
/**
|
36
33
|
* Cancel answer
|
37
34
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../../../src/storages/chats/answer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
1
|
+
{"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../../../src/storages/chats/answer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACV,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,8BAAsB,MAAO,SAAQ,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC;IAEvE;;OAEG;IACH,QAAQ,KAAK,EAAE,IAAI,QAAQ,CAAA;IAE3B;;OAEG;IACH,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAA;IAE/B;;OAEG;IACH,QAAQ,KAAK,MAAM,IAAI,MAAM,CAAA;IAE7B;;OAEG;IACH,QAAQ,KAAK,MAAM,IAAI,YAAY,CAAA;IAEnC;;OAEG;IACH,QAAQ,KAAK,OAAO,IAAI,SAAS,EAAE,CAAA;IAEnC;;OAEG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CACjC"}
|
@@ -1,24 +1,27 @@
|
|
1
1
|
import { Context } from "../../context";
|
2
|
-
import { AnswerDto, AnswerStatus,
|
2
|
+
import { AnswerDto, AnswerStatus, SourceDto } from "../../dto/chatResponse";
|
3
3
|
import { Answer, AnswerId } from "./answer";
|
4
4
|
import { Chat } from "./chat";
|
5
5
|
export declare class AnswerImpl extends Answer {
|
6
6
|
private readonly chat;
|
7
7
|
private readonly context;
|
8
|
-
private _content?;
|
9
8
|
private _steps?;
|
10
9
|
private _status?;
|
11
10
|
private _id?;
|
11
|
+
private _question?;
|
12
|
+
private _sources?;
|
13
|
+
private _answer?;
|
12
14
|
constructor(chat: Chat, context: Context);
|
13
|
-
|
14
|
-
|
15
|
-
get id():
|
15
|
+
initFromHistory(answer: AnswerDto): AnswerImpl;
|
16
|
+
initNew(id: AnswerId, question: string): Promise<AnswerImpl>;
|
17
|
+
get id(): AnswerId;
|
16
18
|
get status(): AnswerStatus;
|
17
|
-
get
|
19
|
+
get question(): string;
|
20
|
+
get sources(): SourceDto[];
|
21
|
+
get tokens(): string;
|
22
|
+
fetchAfter(): void;
|
18
23
|
private getStep;
|
19
|
-
sources(type: StepType): Promise<SourceDto[]>;
|
20
24
|
fetch(): Promise<void>;
|
21
|
-
fetchTokens(type: StepType, token_start_at: number): Promise<FetchTokensResponse>;
|
22
25
|
cancel(): Promise<void>;
|
23
26
|
}
|
24
27
|
//# sourceMappingURL=answer.impl.d.ts.map
|
@@ -1 +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,
|
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,SAAS,EAEV,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EAAE,MAAM,EAAe,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,qBAAa,UAAW,SAAQ,MAAM;IAUlC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B,OAAO,CAAC,MAAM,CAAC,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAC,CAAc;IAC9B,OAAO,CAAC,GAAG,CAAC,CAAU;IACtB,OAAO,CAAC,SAAS,CAAC,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,OAAO,CAAC,CAAQ;gBAGL,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO;IAInC,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU;IASxC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAUlE,IAAI,EAAE,IAAI,QAAQ,CAEjB;IAED,IAAI,MAAM,IAAI,YAAY,CAEzB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,OAAO,IAAI,SAAS,EAAE,CAEzB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAEM,UAAU;IAMjB,OAAO,CAAC,OAAO;IAIT,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAoB9B"}
|
@@ -11,19 +11,18 @@ class AnswerImpl extends answer_1.Answer {
|
|
11
11
|
this.chat = chat;
|
12
12
|
this.context = context;
|
13
13
|
}
|
14
|
-
|
15
|
-
this._content = answer;
|
14
|
+
initFromHistory(answer) {
|
16
15
|
this._id = answer.id;
|
16
|
+
this._question = answer.question;
|
17
|
+
this._answer = answer.context;
|
18
|
+
this._sources = answer.sources;
|
17
19
|
return this;
|
18
20
|
}
|
19
|
-
async
|
21
|
+
async initNew(id, question) {
|
20
22
|
this._id = id;
|
21
|
-
|
23
|
+
this._question = question;
|
24
|
+
this._answer = "";
|
22
25
|
await this.fetch();
|
23
|
-
this.dispatch({
|
24
|
-
type: answer_1.AnswerEvent.ADDED,
|
25
|
-
data: this
|
26
|
-
});
|
27
26
|
return this;
|
28
27
|
}
|
29
28
|
get id() {
|
@@ -32,37 +31,24 @@ class AnswerImpl extends answer_1.Answer {
|
|
32
31
|
get status() {
|
33
32
|
return this._status;
|
34
33
|
}
|
35
|
-
get
|
36
|
-
|
37
|
-
|
34
|
+
get question() {
|
35
|
+
return this._question;
|
36
|
+
}
|
37
|
+
get sources() {
|
38
|
+
return this._sources;
|
39
|
+
}
|
40
|
+
get tokens() {
|
41
|
+
return this._answer;
|
42
|
+
}
|
43
|
+
fetchAfter() {
|
44
|
+
if (this._status === undefined || this._status === chatResponse_1.AnswerStatus.RUNNING) {
|
45
|
+
setTimeout(async () => await this.fetch(), 300);
|
38
46
|
}
|
39
|
-
throw new Error("Answer status is running, please use fetch() or fetch_tokens()");
|
40
47
|
}
|
41
48
|
getStep(type) {
|
42
49
|
var _a;
|
43
50
|
return (_a = this._steps) === null || _a === void 0 ? void 0 : _a.find(step => step.type === type);
|
44
51
|
}
|
45
|
-
async sources(type) {
|
46
|
-
var _a;
|
47
|
-
// fetch answer
|
48
|
-
await this.fetch();
|
49
|
-
// get step
|
50
|
-
const step = this.getStep(type);
|
51
|
-
// check step
|
52
|
-
if (!step) {
|
53
|
-
throw new Error(`Step with type ${type.toString()} is not found, answer: ${this.id}, organization: ${this.chat.organization.id}`);
|
54
|
-
}
|
55
|
-
// get sources
|
56
|
-
const response = await ((_a = this.context
|
57
|
-
.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());
|
58
|
-
// check response status
|
59
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
60
|
-
await responseUtils_1.ResponseUtils.throwError(`Failed to get sources for ${type.toString()}, answer: ${this.id}, organization: ${this.chat.organization.id}`, response);
|
61
|
-
}
|
62
|
-
// parse sources from the server's response
|
63
|
-
const sources = (await response.json()).sources;
|
64
|
-
return sources;
|
65
|
-
}
|
66
52
|
async fetch() {
|
67
53
|
var _a;
|
68
54
|
// fetch answer from position 0
|
@@ -79,34 +65,19 @@ class AnswerImpl extends answer_1.Answer {
|
|
79
65
|
// update answer
|
80
66
|
this._status = answer.status;
|
81
67
|
this._steps = answer.steps;
|
68
|
+
if (this.getStep(chatResponse_1.StepType.GENERATE_ANSWER) !== undefined) {
|
69
|
+
const step = this.getStep(chatResponse_1.StepType.GENERATE_ANSWER);
|
70
|
+
this._answer = step === null || step === void 0 ? void 0 : step.tokens.join("");
|
71
|
+
}
|
72
|
+
if (this.getStep(chatResponse_1.StepType.SOURCES) !== undefined) {
|
73
|
+
const sources_step = this.getStep(chatResponse_1.StepType.SOURCES);
|
74
|
+
this._sources = sources_step === null || sources_step === void 0 ? void 0 : sources_step.sources;
|
75
|
+
}
|
82
76
|
this.dispatch({
|
83
77
|
type: answer_1.AnswerEvent.UPDATED,
|
84
78
|
data: this
|
85
79
|
});
|
86
|
-
|
87
|
-
await this.chat.update();
|
88
|
-
}
|
89
|
-
}
|
90
|
-
async fetchTokens(type, token_start_at) {
|
91
|
-
var _a;
|
92
|
-
// fetch answer
|
93
|
-
await this.fetch();
|
94
|
-
// get step
|
95
|
-
const step = this.getStep(type);
|
96
|
-
// check step
|
97
|
-
if (!step) {
|
98
|
-
throw new Error(`Step with type ${type.toString()} is not found`);
|
99
|
-
}
|
100
|
-
// get tokens
|
101
|
-
const response = await ((_a = this.context
|
102
|
-
.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());
|
103
|
-
// check response status
|
104
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
105
|
-
await responseUtils_1.ResponseUtils.throwError(`Failed to get sources for ${type.toString()}`, response);
|
106
|
-
}
|
107
|
-
// parse tokens from the server's response
|
108
|
-
const tokens = (await response.json());
|
109
|
-
return tokens;
|
80
|
+
this.fetchAfter();
|
110
81
|
}
|
111
82
|
async cancel() {
|
112
83
|
var _a;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"answer.impl.js","sourceRoot":"","sources":["../../../../src/storages/chats/answer.impl.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"answer.impl.js","sourceRoot":"","sources":["../../../../src/storages/chats/answer.impl.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";
|
8
8
|
AnswerEvent["CANCALLED"] = "cancelled";
|
9
|
+
AnswerEvent["FAILED"] = "failed";
|
9
10
|
AnswerEvent["UPDATED"] = "updated";
|
10
11
|
})(AnswerEvent || (exports.AnswerEvent = AnswerEvent = {}));
|
11
12
|
class Answer extends events_1.EventDispatcher {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"answer.js","sourceRoot":"","sources":["../../../../src/storages/chats/answer.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"answer.js","sourceRoot":"","sources":["../../../../src/storages/chats/answer.ts"],"names":[],"mappings":";;;AAIA,yCAA8C;AAK9C,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,sCAAuB,CAAA;IACvB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;AACrB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED,MAAsB,MAAO,SAAQ,wBAAoC;CA+BxE;AA/BD,wBA+BC"}
|
@@ -31,9 +31,5 @@ export declare abstract class Chat {
|
|
31
31
|
* Ask new question in chat.
|
32
32
|
*/
|
33
33
|
abstract ask(message: string, answerType: ChatAnswerType): Promise<Answer>;
|
34
|
-
/**
|
35
|
-
* Update chat
|
36
|
-
*/
|
37
|
-
abstract update(): Promise<void>;
|
38
34
|
}
|
39
35
|
//# sourceMappingURL=chat.d.ts.map
|
@@ -1 +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;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAEtC;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;
|
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;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAEtC;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;CAE3E"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Chat, ChatAnswerType } from "./chat";
|
2
2
|
import { Disposable } from "../../disposable";
|
3
|
-
import { Answer } from "./answer";
|
3
|
+
import { Answer, AnswerId } from "./answer";
|
4
4
|
import { ChatDto } from "../../dto/chatResponse";
|
5
5
|
import { Context } from "../../context";
|
6
6
|
import { Organization } from "../organizations/organization";
|
@@ -16,9 +16,8 @@ export declare class ChatImpl extends Chat implements Disposable {
|
|
16
16
|
get name(): string;
|
17
17
|
get collection(): readonly Answer[];
|
18
18
|
get isDisposed(): boolean;
|
19
|
-
getAnswer(id:
|
19
|
+
getAnswer(id: AnswerId): Answer;
|
20
20
|
ask(message: string, answerType: ChatAnswerType): Promise<Answer>;
|
21
|
-
update(): Promise<void>;
|
22
21
|
dispose(): void;
|
23
22
|
}
|
24
23
|
//# sourceMappingURL=chat.impl.d.ts.map
|
@@ -1 +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;
|
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,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC3C,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,CAAmB;IAE5C,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;IAEM,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM;IAQhC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BvE,OAAO,IAAI,IAAI;CAIhB"}
|
@@ -18,7 +18,7 @@ class ChatImpl extends chat_1.Chat {
|
|
18
18
|
// init answers
|
19
19
|
for (const ans of chat.answers) {
|
20
20
|
// create answer implementation
|
21
|
-
const answer =
|
21
|
+
const answer = new answer_impl_1.AnswerImpl(this, this.context).initFromHistory(ans);
|
22
22
|
// add answer to the collection
|
23
23
|
this._answers.push(answer);
|
24
24
|
}
|
@@ -61,35 +61,11 @@ class ChatImpl extends chat_1.Chat {
|
|
61
61
|
// parse answer id from the server's response
|
62
62
|
const id = (await response.json()).id;
|
63
63
|
// create answer implementation
|
64
|
-
const answer = await new answer_impl_1.AnswerImpl(this, this.context).
|
64
|
+
const answer = await new answer_impl_1.AnswerImpl(this, this.context).initNew(id, message);
|
65
65
|
// add answer to the collection
|
66
66
|
this._answers.push(answer);
|
67
67
|
return answer;
|
68
68
|
}
|
69
|
-
async update() {
|
70
|
-
var _a;
|
71
|
-
const response = await ((_a = this.context
|
72
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Chats").searchParam("id", this.id).sendGet());
|
73
|
-
// check response status
|
74
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
75
|
-
await responseUtils_1.ResponseUtils.throwError(`Failed to update chat ${this.id}`, response);
|
76
|
-
}
|
77
|
-
const chat = (await response.json()).chat;
|
78
|
-
this._content = chat;
|
79
|
-
for (const ans of chat.answers) {
|
80
|
-
let answer = this._answers.find(answer => answer.id === ans.id);
|
81
|
-
if (!answer) {
|
82
|
-
// create answer implementation
|
83
|
-
answer = new answer_impl_1.AnswerImpl(this, this.context).initFromData(ans);
|
84
|
-
}
|
85
|
-
else {
|
86
|
-
this._answers.splice(this._answers.indexOf(answer), 1);
|
87
|
-
answer.initFromData(ans);
|
88
|
-
}
|
89
|
-
// add answer to the collection
|
90
|
-
this._answers.push(answer);
|
91
|
-
}
|
92
|
-
}
|
93
69
|
dispose() {
|
94
70
|
this._isDisposed = true;
|
95
71
|
}
|