@neuralinnovations/dataisland-sdk 0.0.1-dev25 → 0.0.1-dev27
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 +21 -33
- 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 +10 -9
- package/dist/src/storages/chats/answer.d.ts.map +1 -1
- package/dist/src/storages/chats/answer.impl.d.ts +13 -8
- package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/answer.impl.js +44 -58
- 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/files/file.d.ts +13 -5
- package/dist/src/storages/files/file.d.ts.map +1 -1
- package/dist/src/storages/files/file.impl.d.ts +6 -4
- package/dist/src/storages/files/file.impl.d.ts.map +1 -1
- package/dist/src/storages/files/file.impl.js +33 -8
- package/dist/src/storages/files/file.impl.js.map +1 -1
- package/dist/src/storages/files/file.js +7 -1
- package/dist/src/storages/files/file.js.map +1 -1
- package/dist/src/storages/files/files.impl.d.ts.map +1 -1
- package/dist/src/storages/files/files.impl.js +3 -2
- package/dist/src/storages/files/files.impl.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 +10 -10
- 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 +55 -80
- package/src/storages/chats/answer.ts +11 -13
- package/src/storages/chats/chat.impl.ts +5 -36
- package/src/storages/chats/chat.ts +0 -4
- package/src/storages/files/file.impl.ts +38 -14
- package/src/storages/files/file.ts +16 -7
- package/src/storages/files/files.impl.ts +6 -4
- package/src/storages/workspaces/workspaces.impl.ts +4 -1
- package/src/unitTest.ts +3 -3
@@ -4,7 +4,6 @@ import {
|
|
4
4
|
AnswerStatus,
|
5
5
|
AnswerStepDto,
|
6
6
|
FetchAnswerResponse,
|
7
|
-
FetchTokensResponse,
|
8
7
|
SourceDto,
|
9
8
|
StepType
|
10
9
|
} from "../../dto/chatResponse"
|
@@ -14,11 +13,14 @@ import { Answer, AnswerEvent, AnswerId } from "./answer"
|
|
14
13
|
import { Chat } from "./chat"
|
15
14
|
|
16
15
|
export class AnswerImpl extends Answer {
|
17
|
-
private _content?: AnswerDto
|
18
16
|
|
19
17
|
private _steps?: AnswerStepDto[]
|
20
18
|
private _status?: AnswerStatus
|
21
19
|
private _id?: AnswerId
|
20
|
+
private _question?: string
|
21
|
+
private _sources?: SourceDto[]
|
22
|
+
private _answer?: string
|
23
|
+
private _timestamp?: number
|
22
24
|
|
23
25
|
constructor(
|
24
26
|
private readonly chat: Chat,
|
@@ -26,75 +28,58 @@ export class AnswerImpl extends Answer {
|
|
26
28
|
super()
|
27
29
|
}
|
28
30
|
|
29
|
-
|
30
|
-
this._content = answer
|
31
|
+
initFromHistory(answer: AnswerDto): AnswerImpl {
|
31
32
|
this._id = answer.id
|
33
|
+
this._question = answer.question
|
34
|
+
this._answer = answer.context
|
35
|
+
this._sources = answer.sources
|
36
|
+
this._timestamp = answer.timestamp
|
32
37
|
|
33
38
|
return this
|
34
39
|
}
|
35
40
|
|
36
|
-
async
|
41
|
+
async initNew(id: AnswerId, question: string): Promise<AnswerImpl> {
|
37
42
|
this._id = id
|
43
|
+
this._question = question
|
44
|
+
this._answer = ""
|
38
45
|
|
39
|
-
// fetch answer
|
40
46
|
await this.fetch()
|
41
47
|
|
42
|
-
this.dispatch({
|
43
|
-
type: AnswerEvent.ADDED,
|
44
|
-
data: this
|
45
|
-
})
|
46
|
-
|
47
48
|
return this
|
48
49
|
}
|
49
50
|
|
50
|
-
get id():
|
51
|
-
return <
|
51
|
+
get id(): AnswerId {
|
52
|
+
return <AnswerId>this._id
|
52
53
|
}
|
53
54
|
|
54
55
|
get status(): AnswerStatus {
|
55
56
|
return <AnswerStatus>this._status
|
56
57
|
}
|
57
58
|
|
58
|
-
get
|
59
|
-
|
60
|
-
return <AnswerDto>this._content
|
61
|
-
}
|
62
|
-
throw new Error("Answer status is running, please use fetch() or fetch_tokens()")
|
59
|
+
get question(): string {
|
60
|
+
return <string>this._question
|
63
61
|
}
|
64
62
|
|
65
|
-
|
66
|
-
return this.
|
63
|
+
get sources(): SourceDto[] {
|
64
|
+
return <SourceDto[]>this._sources
|
67
65
|
}
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
// get step
|
73
|
-
const step = this.getStep(type)
|
74
|
-
|
75
|
-
// check step
|
76
|
-
if (!step) {
|
77
|
-
throw new Error(`Step with type ${type.toString()} is not found, answer: ${this.id}, organization: ${this.chat.organization.id}`)
|
78
|
-
}
|
67
|
+
get tokens(): string {
|
68
|
+
return <string>this._answer
|
69
|
+
}
|
79
70
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
?.requestBuilder("api/v1/Chats/answer/sources")
|
84
|
-
.searchParam("chat_uid", this.chat.id)
|
85
|
-
.searchParam("uid", this.id)
|
86
|
-
.searchParam("step_id", step.id)
|
87
|
-
.sendGet()
|
71
|
+
get timestamp(): number {
|
72
|
+
return <number>this._timestamp
|
73
|
+
}
|
88
74
|
|
89
|
-
|
90
|
-
if (
|
91
|
-
|
75
|
+
public fetchAfter() {
|
76
|
+
if (this._status === undefined || this._status === AnswerStatus.RUNNING) {
|
77
|
+
setTimeout(async () => await this.fetch(), 300)
|
92
78
|
}
|
79
|
+
}
|
93
80
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
return sources
|
81
|
+
private getStep(type: StepType): AnswerStepDto | undefined {
|
82
|
+
return this._steps?.find(step => step.type === type)
|
98
83
|
}
|
99
84
|
|
100
85
|
async fetch(): Promise<void> {
|
@@ -120,47 +105,37 @@ export class AnswerImpl extends Answer {
|
|
120
105
|
// update answer
|
121
106
|
this._status = <AnswerStatus>answer.status
|
122
107
|
this._steps = <AnswerStepDto[]>answer.steps
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
108
|
+
|
109
|
+
|
110
|
+
if (this.getStep(StepType.GENERATE_ANSWER) !== undefined) {
|
111
|
+
const step = this.getStep(StepType.GENERATE_ANSWER)
|
112
|
+
const step_tokens = step?.tokens.join("")
|
113
|
+
if (this._answer !== step_tokens){
|
114
|
+
this._answer = step_tokens
|
115
|
+
|
116
|
+
this.dispatch({
|
117
|
+
type: AnswerEvent.UPDATED,
|
118
|
+
data: this
|
119
|
+
})
|
120
|
+
}
|
131
121
|
}
|
132
|
-
}
|
133
|
-
|
134
|
-
async fetchTokens(type: StepType, token_start_at: number): Promise<FetchTokensResponse> {
|
135
|
-
// fetch answer
|
136
|
-
await this.fetch()
|
137
|
-
// get step
|
138
|
-
const step = this.getStep(type)
|
139
122
|
|
140
|
-
|
141
|
-
|
142
|
-
|
123
|
+
if (this.getStep(StepType.SOURCES) !== undefined && this._sources === undefined) {
|
124
|
+
const sources_step = this.getStep(StepType.SOURCES)
|
125
|
+
this._sources = sources_step?.sources
|
126
|
+
|
127
|
+
this.dispatch({
|
128
|
+
type: AnswerEvent.UPDATED,
|
129
|
+
data: this
|
130
|
+
})
|
143
131
|
}
|
144
132
|
|
145
|
-
|
146
|
-
|
147
|
-
.
|
148
|
-
?.requestBuilder("api/v1/Chats/answer/fetch/tokens")
|
149
|
-
.searchParam("chat_uid", this.chat.id)
|
150
|
-
.searchParam("uid", this.id)
|
151
|
-
.searchParam("step_id", step.id)
|
152
|
-
.searchParam("token_start_at", token_start_at.toString())
|
153
|
-
.sendGet()
|
154
|
-
|
155
|
-
// check response status
|
156
|
-
if (ResponseUtils.isFail(response)) {
|
157
|
-
await ResponseUtils.throwError(`Failed to get sources for ${type.toString()}`, response)
|
133
|
+
if (this.getStep(StepType.DONE) !== undefined){
|
134
|
+
const step = this.getStep(StepType.DONE)
|
135
|
+
this._timestamp = Date.parse(step!.end_at)
|
158
136
|
}
|
159
137
|
|
160
|
-
|
161
|
-
const tokens = (await response!.json()) as FetchTokensResponse
|
162
|
-
|
163
|
-
return tokens
|
138
|
+
this.fetchAfter()
|
164
139
|
}
|
165
140
|
|
166
141
|
async cancel(): Promise<void> {
|
@@ -1,9 +1,6 @@
|
|
1
1
|
import {
|
2
|
-
AnswerDto,
|
3
2
|
AnswerStatus,
|
4
|
-
|
5
|
-
SourceDto,
|
6
|
-
StepType
|
3
|
+
SourceDto
|
7
4
|
} from "../../dto/chatResponse"
|
8
5
|
import { EventDispatcher } from "../../events"
|
9
6
|
|
@@ -13,6 +10,7 @@ export type StepId = string
|
|
13
10
|
export enum AnswerEvent {
|
14
11
|
ADDED = "added",
|
15
12
|
CANCALLED = "cancelled",
|
13
|
+
FAILED = "failed",
|
16
14
|
UPDATED = "updated"
|
17
15
|
}
|
18
16
|
|
@@ -26,27 +24,27 @@ export abstract class Answer extends EventDispatcher<AnswerEvent, Answer> {
|
|
26
24
|
/**
|
27
25
|
* Answer data object
|
28
26
|
*/
|
29
|
-
abstract get
|
27
|
+
abstract get question(): string
|
30
28
|
|
31
29
|
/**
|
32
|
-
* Answer
|
30
|
+
* Answer tokens
|
33
31
|
*/
|
34
|
-
abstract get
|
32
|
+
abstract get tokens(): string
|
35
33
|
|
36
34
|
/**
|
37
|
-
* Answer
|
35
|
+
* Answer status.
|
38
36
|
*/
|
39
|
-
abstract
|
37
|
+
abstract get status(): AnswerStatus
|
40
38
|
|
41
39
|
/**
|
42
|
-
*
|
40
|
+
* Answer sources.
|
43
41
|
*/
|
44
|
-
abstract
|
42
|
+
abstract get sources(): SourceDto[]
|
45
43
|
|
46
44
|
/**
|
47
|
-
*
|
45
|
+
* Answer time.
|
48
46
|
*/
|
49
|
-
abstract
|
47
|
+
abstract get timestamp(): number
|
50
48
|
|
51
49
|
/**
|
52
50
|
* Cancel answer
|
@@ -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 { AnswerImpl } from "./answer.impl"
|
@@ -27,7 +27,7 @@ export class ChatImpl extends Chat implements Disposable {
|
|
27
27
|
// init answers
|
28
28
|
for (const ans of chat.answers) {
|
29
29
|
// create answer implementation
|
30
|
-
const answer =
|
30
|
+
const answer = new AnswerImpl(this, this.context).initFromHistory(ans)
|
31
31
|
|
32
32
|
// add answer to the collection
|
33
33
|
this._answers.push(answer)
|
@@ -52,9 +52,9 @@ export class ChatImpl extends Chat implements Disposable {
|
|
52
52
|
return this._isDisposed
|
53
53
|
}
|
54
54
|
|
55
|
-
public getAnswer(id:
|
55
|
+
public getAnswer(id: AnswerId): Answer {
|
56
56
|
const answer = this._answers.find(answer => answer.id === id)
|
57
|
-
if (answer){
|
57
|
+
if (answer) {
|
58
58
|
return answer
|
59
59
|
}
|
60
60
|
throw new Error(`Answer with id ${id} is not found`)
|
@@ -80,7 +80,7 @@ export class ChatImpl extends Chat implements Disposable {
|
|
80
80
|
const id = (await response!.json()).id
|
81
81
|
|
82
82
|
// create answer implementation
|
83
|
-
const answer = await new AnswerImpl(this, this.context).
|
83
|
+
const answer = await new AnswerImpl(this, this.context).initNew(id, message)
|
84
84
|
|
85
85
|
// add answer to the collection
|
86
86
|
this._answers.push(answer)
|
@@ -88,37 +88,6 @@ export class ChatImpl extends Chat implements Disposable {
|
|
88
88
|
return answer
|
89
89
|
}
|
90
90
|
|
91
|
-
async update(): Promise<void>{
|
92
|
-
const response = await this.context
|
93
|
-
.resolve(RpcService)
|
94
|
-
?.requestBuilder("api/v1/Chats")
|
95
|
-
.searchParam("id", this.id)
|
96
|
-
.sendGet()
|
97
|
-
|
98
|
-
// check response status
|
99
|
-
if (ResponseUtils.isFail(response)) {
|
100
|
-
await ResponseUtils.throwError(`Failed to update chat ${this.id}`, response)
|
101
|
-
}
|
102
|
-
|
103
|
-
const chat = (await response!.json()).chat as ChatDto
|
104
|
-
|
105
|
-
this._content = chat
|
106
|
-
|
107
|
-
for (const ans of chat.answers) {
|
108
|
-
let answer = this._answers.find(answer => answer.id === ans.id)
|
109
|
-
if (!answer){
|
110
|
-
// create answer implementation
|
111
|
-
answer = new AnswerImpl(this, this.context).initFromData(ans)
|
112
|
-
}else{
|
113
|
-
this._answers.splice(this._answers.indexOf(answer), 1)
|
114
|
-
|
115
|
-
answer.initFromData(ans)
|
116
|
-
}
|
117
|
-
// add answer to the collection
|
118
|
-
this._answers.push(answer)
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
91
|
dispose(): void {
|
123
92
|
this._isDisposed = true
|
124
93
|
}
|
@@ -3,22 +3,23 @@ import { Disposable } from "../../disposable"
|
|
3
3
|
import { FileDto, FileProgressDto } from "../../dto/workspacesResponse"
|
4
4
|
import { RpcService } from "../../services/rpcService"
|
5
5
|
import { ResponseUtils } from "../../services/responseUtils"
|
6
|
-
import { File } from "./file"
|
6
|
+
import { File, FileStatus } from "./file"
|
7
7
|
import { FilesEvent } from "./files"
|
8
8
|
|
9
9
|
export class FileImpl extends File implements Disposable {
|
10
10
|
private _isDisposed: boolean = false
|
11
11
|
private _content?: FileDto
|
12
|
-
private
|
13
|
-
|
12
|
+
private _progress?: FileProgressDto
|
14
13
|
|
15
14
|
constructor(private readonly context: Context) {
|
16
15
|
super()
|
17
16
|
}
|
18
17
|
|
19
|
-
|
18
|
+
async initFrom(file: FileDto): Promise<File> {
|
20
19
|
this._content = file
|
21
20
|
|
21
|
+
await this.updateStatus()
|
22
|
+
|
22
23
|
return this
|
23
24
|
}
|
24
25
|
|
@@ -42,8 +43,19 @@ export class FileImpl extends File implements Disposable {
|
|
42
43
|
return <number>this._content?.createdAt
|
43
44
|
}
|
44
45
|
|
45
|
-
get
|
46
|
-
return <FileProgressDto>this.
|
46
|
+
get progress(): FileProgressDto {
|
47
|
+
return <FileProgressDto>this._progress
|
48
|
+
}
|
49
|
+
|
50
|
+
get status(): FileStatus {
|
51
|
+
if (this._progress === undefined || this._progress.success === null ||
|
52
|
+
(this._progress.success && this._progress.completed_parts_count !== this._progress.file_parts_count)) {
|
53
|
+
return FileStatus.UPLOADING
|
54
|
+
} else if (this._progress.success) {
|
55
|
+
return FileStatus.SUCCESS
|
56
|
+
} else {
|
57
|
+
return FileStatus.FAILED
|
58
|
+
}
|
47
59
|
}
|
48
60
|
|
49
61
|
async url(): Promise<string> {
|
@@ -63,6 +75,12 @@ export class FileImpl extends File implements Disposable {
|
|
63
75
|
return (await response!.json()).url
|
64
76
|
}
|
65
77
|
|
78
|
+
public fetchAfter() {
|
79
|
+
if (this.status === FileStatus.UPLOADING) {
|
80
|
+
setTimeout(async () => await this.updateStatus(), 500)
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
66
84
|
async updateStatus(): Promise<void> {
|
67
85
|
const response = await this.context
|
68
86
|
.resolve(RpcService)
|
@@ -74,14 +92,20 @@ export class FileImpl extends File implements Disposable {
|
|
74
92
|
await ResponseUtils.throwError(`Failed to get file ${this.id}`, response)
|
75
93
|
}
|
76
94
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
95
|
+
const prev_progress = this._progress
|
96
|
+
this._progress = (await response!.json()).progress as FileProgressDto
|
97
|
+
|
98
|
+
if (prev_progress === undefined ||
|
99
|
+
(this.progress.success !== null && this.progress.completed_parts_count > prev_progress.completed_parts_count) ||
|
100
|
+
this.status === FileStatus.SUCCESS ||
|
101
|
+
this.status === FileStatus.FAILED) {
|
102
|
+
// dispatch event, file updated
|
103
|
+
this.dispatch({
|
104
|
+
type: FilesEvent.UPDATED,
|
105
|
+
data: this
|
106
|
+
})
|
107
|
+
}
|
85
108
|
|
109
|
+
this.fetchAfter()
|
86
110
|
}
|
87
111
|
}
|
@@ -4,12 +4,18 @@ import { FilesEvent } from "./files"
|
|
4
4
|
|
5
5
|
export type FileId = string
|
6
6
|
|
7
|
+
export enum FileStatus {
|
8
|
+
UPLOADING = "uploading",
|
9
|
+
SUCCESS = "success",
|
10
|
+
FAILED = "failed"
|
11
|
+
}
|
12
|
+
|
7
13
|
/**
|
8
14
|
* File.
|
9
15
|
*/
|
10
16
|
export abstract class File extends EventDispatcher<
|
11
|
-
FilesEvent,
|
12
|
-
File
|
17
|
+
FilesEvent,
|
18
|
+
File
|
13
19
|
> {
|
14
20
|
/**
|
15
21
|
* File id.
|
@@ -26,15 +32,18 @@ File
|
|
26
32
|
*/
|
27
33
|
abstract get createdAt(): number
|
28
34
|
|
29
|
-
|
35
|
+
/**
|
36
|
+
* File uploading progress
|
37
|
+
*/
|
38
|
+
abstract get progress(): FileProgressDto
|
30
39
|
|
31
40
|
/**
|
32
|
-
*
|
41
|
+
* File uploading status
|
33
42
|
*/
|
34
|
-
abstract
|
43
|
+
abstract get status(): FileStatus
|
35
44
|
|
36
45
|
/**
|
37
|
-
* Get
|
46
|
+
* Get temporary url.
|
38
47
|
*/
|
39
|
-
abstract
|
48
|
+
abstract url(): Promise<string>
|
40
49
|
}
|
@@ -22,14 +22,14 @@ export class FilesImpl extends Files {
|
|
22
22
|
|
23
23
|
async upload(files: any[]): Promise<File[]> {
|
24
24
|
const loaded_files = []
|
25
|
-
for (
|
25
|
+
for (const file of files) {
|
26
26
|
loaded_files.push(await this.internalUpload(file))
|
27
27
|
}
|
28
28
|
return loaded_files
|
29
29
|
}
|
30
30
|
|
31
31
|
async delete(ids: string[]): Promise<void> {
|
32
|
-
for (
|
32
|
+
for (const id of ids) {
|
33
33
|
await this.internalDeleteFile(id)
|
34
34
|
}
|
35
35
|
}
|
@@ -135,7 +135,7 @@ export class FilesImpl extends Files {
|
|
135
135
|
for (const fl of files.files) {
|
136
136
|
|
137
137
|
// create file implementation
|
138
|
-
const file = new FileImpl(this.context).initFrom(fl)
|
138
|
+
const file = await new FileImpl(this.context).initFrom(fl)
|
139
139
|
|
140
140
|
// add file to the collection
|
141
141
|
filesList.files.push(file)
|
@@ -175,7 +175,9 @@ export class FilesImpl extends Files {
|
|
175
175
|
const result = (await response!.json()).file as FileDto
|
176
176
|
|
177
177
|
// create file implementation
|
178
|
-
const fileImpl = new FileImpl(this.context)
|
178
|
+
const fileImpl = new FileImpl(this.context)
|
179
|
+
|
180
|
+
await fileImpl.initFrom(result)
|
179
181
|
|
180
182
|
// TODO: why is this here?
|
181
183
|
this.filesList?.files.push(fileImpl)
|
@@ -8,6 +8,8 @@ import { RpcService } from "../../services/rpcService"
|
|
8
8
|
import { OrganizationWorkspaces } from "../../dto/userInfoResponse"
|
9
9
|
import { WorkspaceDto } from "../../dto/workspacesResponse"
|
10
10
|
import { ResponseUtils } from "../../services/responseUtils"
|
11
|
+
import { UserProfileService } from "../../services/userProfileService"
|
12
|
+
import { UserProfile } from "../user/userProfile"
|
11
13
|
|
12
14
|
export class WorkspacesImpl extends Workspaces {
|
13
15
|
private readonly _workspaces: WorkspaceImpl[] = []
|
@@ -184,7 +186,8 @@ export class WorkspacesImpl extends Workspaces {
|
|
184
186
|
|
185
187
|
// check response status
|
186
188
|
if (ResponseUtils.isFail(response)) {
|
187
|
-
|
189
|
+
const userProfile = this.context.resolve(UserProfileService)?.userProfile as UserProfile
|
190
|
+
await ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${organizationId}, userId: ${userProfile.id}, email: ${userProfile.email}`, response)
|
188
191
|
}
|
189
192
|
|
190
193
|
// parse workspaces from the server's response
|
package/src/unitTest.ts
CHANGED
@@ -3,7 +3,7 @@ export enum UnitTest {
|
|
3
3
|
DO_NOT_START = 1 << 0,
|
4
4
|
DO_NOT_PRINT_INITIALIZED_LOG = 1 << 1,
|
5
5
|
|
6
|
-
|
6
|
+
DO_NOT_START_SDK = DO_NOT_START | DO_NOT_PRINT_INITIALIZED_LOG
|
7
7
|
}
|
8
8
|
|
9
9
|
export type UnitTestProfileSyncAction = () => void
|
@@ -17,7 +17,7 @@ class AppSdkUnitTest {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
public static async test(
|
20
|
-
unitTest: UnitTest = UnitTest.
|
20
|
+
unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
|
21
21
|
func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
|
22
22
|
): Promise<void> {
|
23
23
|
this._stack.push(unitTest)
|
@@ -38,7 +38,7 @@ class AppSdkUnitTest {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
export const appTest = async (
|
41
|
-
unitTest: UnitTest = UnitTest.
|
41
|
+
unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
|
42
42
|
func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
|
43
43
|
): Promise<void> => {
|
44
44
|
await AppSdkUnitTest.test(unitTest, func)
|