@neuralinnovations/dataisland-sdk 0.0.1-dev24 → 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.
Files changed (49) hide show
  1. package/README.md +8 -26
  2. package/dist/package.json +10 -10
  3. package/dist/src/commands/deleteUserFullCommandHandler.d.ts +7 -0
  4. package/dist/src/commands/deleteUserFullCommandHandler.d.ts.map +1 -0
  5. package/dist/src/commands/deleteUserFullCommandHandler.js +21 -0
  6. package/dist/src/commands/deleteUserFullCommandHandler.js.map +1 -0
  7. package/dist/src/dto/chatResponse.d.ts +9 -6
  8. package/dist/src/dto/chatResponse.d.ts.map +1 -1
  9. package/dist/src/dto/chatResponse.js.map +1 -1
  10. package/dist/src/internal/app.impl.d.ts.map +1 -1
  11. package/dist/src/internal/app.impl.js +4 -0
  12. package/dist/src/internal/app.impl.js.map +1 -1
  13. package/dist/src/storages/chats/answer.d.ts +8 -11
  14. package/dist/src/storages/chats/answer.d.ts.map +1 -1
  15. package/dist/src/storages/chats/answer.impl.d.ts +11 -8
  16. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
  17. package/dist/src/storages/chats/answer.impl.js +28 -57
  18. package/dist/src/storages/chats/answer.impl.js.map +1 -1
  19. package/dist/src/storages/chats/answer.js +1 -0
  20. package/dist/src/storages/chats/answer.js.map +1 -1
  21. package/dist/src/storages/chats/chat.d.ts +0 -4
  22. package/dist/src/storages/chats/chat.d.ts.map +1 -1
  23. package/dist/src/storages/chats/chat.impl.d.ts +2 -3
  24. package/dist/src/storages/chats/chat.impl.d.ts.map +1 -1
  25. package/dist/src/storages/chats/chat.impl.js +2 -26
  26. package/dist/src/storages/chats/chat.impl.js.map +1 -1
  27. package/dist/src/storages/chats/chat.js.map +1 -1
  28. package/dist/src/storages/groups/group.impl.d.ts +2 -1
  29. package/dist/src/storages/groups/group.impl.d.ts.map +1 -1
  30. package/dist/src/storages/groups/group.impl.js +12 -7
  31. package/dist/src/storages/groups/group.impl.js.map +1 -1
  32. package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -1
  33. package/dist/src/storages/workspaces/workspaces.impl.js +4 -2
  34. package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -1
  35. package/dist/src/unitTest.d.ts +1 -1
  36. package/dist/src/unitTest.d.ts.map +1 -1
  37. package/dist/src/unitTest.js +3 -3
  38. package/dist/src/unitTest.js.map +1 -1
  39. package/package.json +11 -11
  40. package/src/commands/deleteUserFullCommandHandler.ts +19 -0
  41. package/src/dto/chatResponse.ts +10 -6
  42. package/src/internal/app.impl.ts +7 -0
  43. package/src/storages/chats/answer.impl.ts +36 -81
  44. package/src/storages/chats/answer.ts +9 -16
  45. package/src/storages/chats/chat.impl.ts +5 -36
  46. package/src/storages/chats/chat.ts +0 -4
  47. package/src/storages/groups/group.impl.ts +16 -7
  48. package/src/storages/workspaces/workspaces.impl.ts +4 -1
  49. package/src/unitTest.ts +3 -3
@@ -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 = await new AnswerImpl(this, this.context).initFromData(ans)
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: string): Answer {
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).initFromId(id)
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
  }
@@ -41,9 +41,5 @@ export abstract class Chat {
41
41
  */
42
42
  abstract ask(message: string, answerType: ChatAnswerType): Promise<Answer>
43
43
 
44
- /**
45
- * Update chat
46
- */
47
- abstract update(): Promise<void>
48
44
  }
49
45
 
@@ -19,6 +19,7 @@ export class GroupImpl extends Group implements Disposable {
19
19
  private _content?: AccessGroupDto
20
20
  private _members?: UserDto[]
21
21
  private _workspaces: Workspace[] = []
22
+ private _id?: GroupId
22
23
 
23
24
  constructor(
24
25
  private readonly context: Context,
@@ -28,8 +29,16 @@ export class GroupImpl extends Group implements Disposable {
28
29
  }
29
30
 
30
31
  async initFrom(id: GroupId): Promise<Group> {
31
- await this.reloadGroup(id)
32
- await this.reloadWorkspaces()
32
+ // set id
33
+ this._id = id
34
+
35
+ // reload group and workspaces
36
+ const groupPromise = this.reloadGroup(id)
37
+ const workspacePromise = this.reloadWorkspaces(id)
38
+
39
+ // wait for all promises
40
+ await Promise.all([groupPromise, workspacePromise])
41
+
33
42
  return this
34
43
  }
35
44
 
@@ -52,8 +61,8 @@ export class GroupImpl extends Group implements Disposable {
52
61
  this._members = group.members
53
62
  }
54
63
 
55
- async reloadWorkspaces(): Promise<void> {
56
- const groupWorkspaces = await this.loadWorkspaces(this.id)
64
+ async reloadWorkspaces(id: GroupId): Promise<void> {
65
+ const groupWorkspaces = await this.loadWorkspaces(id)
57
66
  this._workspaces.length = 0
58
67
  this._workspaces.push(...groupWorkspaces)
59
68
  }
@@ -82,8 +91,8 @@ export class GroupImpl extends Group implements Disposable {
82
91
  }
83
92
 
84
93
  get id(): GroupId {
85
- if (this._content) {
86
- return this._content.id
94
+ if (this._id) {
95
+ return this._id
87
96
  }
88
97
  throw new Error("Access group is not loaded.")
89
98
  }
@@ -173,7 +182,7 @@ export class GroupImpl extends Group implements Disposable {
173
182
  }
174
183
 
175
184
  // reload workspaces
176
- await this.reloadWorkspaces()
185
+ await this.reloadWorkspaces(this.id)
177
186
 
178
187
  // dispatch event
179
188
  this.dispatch({
@@ -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
- await ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${organizationId}`, response)
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
- DEFAULT = DO_NOT_START | DO_NOT_PRINT_INITIALIZED_LOG
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.DEFAULT,
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.DEFAULT,
41
+ unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
42
42
  func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
43
43
  ): Promise<void> => {
44
44
  await AppSdkUnitTest.test(unitTest, func)