@neuralinnovations/dataisland-sdk 0.0.1-dev73 → 0.0.1-dev75

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 (145) hide show
  1. package/README.md +5 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/commands/startCommandHandler.d.ts.map +1 -1
  4. package/dist/src/commands/startCommandHandler.js +3 -0
  5. package/dist/src/commands/startCommandHandler.js.map +1 -1
  6. package/dist/src/dataIslandApp.d.ts +5 -0
  7. package/dist/src/dataIslandApp.d.ts.map +1 -1
  8. package/dist/src/dataIslandApp.js.map +1 -1
  9. package/dist/src/dto/chatResponse.d.ts +18 -3
  10. package/dist/src/dto/chatResponse.d.ts.map +1 -1
  11. package/dist/src/dto/chatResponse.js +12 -1
  12. package/dist/src/dto/chatResponse.js.map +1 -1
  13. package/dist/src/dto/libraryResponse.d.ts +41 -0
  14. package/dist/src/dto/libraryResponse.d.ts.map +1 -0
  15. package/dist/src/dto/libraryResponse.js +3 -0
  16. package/dist/src/dto/libraryResponse.js.map +1 -0
  17. package/dist/src/dto/queryFlowResponse.d.ts +19 -0
  18. package/dist/src/dto/queryFlowResponse.d.ts.map +1 -0
  19. package/dist/src/dto/queryFlowResponse.js +10 -0
  20. package/dist/src/dto/queryFlowResponse.js.map +1 -0
  21. package/dist/src/dto/workspacesResponse.d.ts +1 -0
  22. package/dist/src/dto/workspacesResponse.d.ts.map +1 -1
  23. package/dist/src/dto/workspacesResponse.js.map +1 -1
  24. package/dist/src/index.d.ts +7 -0
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/index.js +7 -0
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/src/internal/app.impl.d.ts +2 -0
  29. package/dist/src/internal/app.impl.d.ts.map +1 -1
  30. package/dist/src/internal/app.impl.js +7 -0
  31. package/dist/src/internal/app.impl.js.map +1 -1
  32. package/dist/src/services/acquiringService.d.ts.map +1 -1
  33. package/dist/src/services/acquiringService.js +2 -2
  34. package/dist/src/services/acquiringService.js.map +1 -1
  35. package/dist/src/services/librariesService.d.ts +9 -0
  36. package/dist/src/services/librariesService.d.ts.map +1 -0
  37. package/dist/src/services/librariesService.js +19 -0
  38. package/dist/src/services/librariesService.js.map +1 -0
  39. package/dist/src/storages/chats/chat.d.ts +3 -6
  40. package/dist/src/storages/chats/chat.d.ts.map +1 -1
  41. package/dist/src/storages/chats/chat.impl.d.ts +2 -3
  42. package/dist/src/storages/chats/chat.impl.d.ts.map +1 -1
  43. package/dist/src/storages/chats/chat.impl.js +2 -6
  44. package/dist/src/storages/chats/chat.impl.js.map +1 -1
  45. package/dist/src/storages/chats/chat.js.map +1 -1
  46. package/dist/src/storages/chats/chats.d.ts +12 -0
  47. package/dist/src/storages/chats/chats.d.ts.map +1 -1
  48. package/dist/src/storages/chats/chats.impl.d.ts +2 -0
  49. package/dist/src/storages/chats/chats.impl.d.ts.map +1 -1
  50. package/dist/src/storages/chats/chats.impl.js +68 -0
  51. package/dist/src/storages/chats/chats.impl.js.map +1 -1
  52. package/dist/src/storages/chats/chats.js.map +1 -1
  53. package/dist/src/storages/library/libraries.d.ts +12 -0
  54. package/dist/src/storages/library/libraries.d.ts.map +1 -0
  55. package/dist/src/storages/library/libraries.impl.d.ts +18 -0
  56. package/dist/src/storages/library/libraries.impl.d.ts.map +1 -0
  57. package/dist/src/storages/library/libraries.impl.js +134 -0
  58. package/dist/src/storages/library/libraries.impl.js.map +1 -0
  59. package/dist/src/storages/library/libraries.js +7 -0
  60. package/dist/src/storages/library/libraries.js.map +1 -0
  61. package/dist/src/storages/library/library.d.ts +10 -0
  62. package/dist/src/storages/library/library.d.ts.map +1 -0
  63. package/dist/src/storages/library/library.impl.d.ts +17 -0
  64. package/dist/src/storages/library/library.impl.d.ts.map +1 -0
  65. package/dist/src/storages/library/library.impl.js +98 -0
  66. package/dist/src/storages/library/library.impl.js.map +1 -0
  67. package/dist/src/storages/library/library.js +7 -0
  68. package/dist/src/storages/library/library.js.map +1 -0
  69. package/dist/src/storages/library/libraryFolder.d.ts +16 -0
  70. package/dist/src/storages/library/libraryFolder.d.ts.map +1 -0
  71. package/dist/src/storages/library/libraryFolder.impl.d.ts +22 -0
  72. package/dist/src/storages/library/libraryFolder.impl.d.ts.map +1 -0
  73. package/dist/src/storages/library/libraryFolder.impl.js +97 -0
  74. package/dist/src/storages/library/libraryFolder.impl.js.map +1 -0
  75. package/dist/src/storages/library/libraryFolder.js +7 -0
  76. package/dist/src/storages/library/libraryFolder.js.map +1 -0
  77. package/dist/src/storages/library/libraryPage.d.ts +29 -0
  78. package/dist/src/storages/library/libraryPage.d.ts.map +1 -0
  79. package/dist/src/storages/library/libraryPage.impl.d.ts +13 -0
  80. package/dist/src/storages/library/libraryPage.impl.d.ts.map +1 -0
  81. package/dist/src/storages/library/libraryPage.impl.js +20 -0
  82. package/dist/src/storages/library/libraryPage.impl.js.map +1 -0
  83. package/dist/src/storages/library/libraryPage.js +7 -0
  84. package/dist/src/storages/library/libraryPage.js.map +1 -0
  85. package/dist/src/storages/organizations/organization.d.ts +5 -0
  86. package/dist/src/storages/organizations/organization.d.ts.map +1 -1
  87. package/dist/src/storages/organizations/organization.impl.d.ts +3 -0
  88. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
  89. package/dist/src/storages/organizations/organization.impl.js +7 -1
  90. package/dist/src/storages/organizations/organization.impl.js.map +1 -1
  91. package/dist/src/storages/organizations/organization.js.map +1 -1
  92. package/dist/src/storages/queryFlows/queryFlow.d.ts +12 -0
  93. package/dist/src/storages/queryFlows/queryFlow.d.ts.map +1 -0
  94. package/dist/src/storages/queryFlows/queryFlow.impl.d.ts +16 -0
  95. package/dist/src/storages/queryFlows/queryFlow.impl.d.ts.map +1 -0
  96. package/dist/src/storages/queryFlows/queryFlow.impl.js +59 -0
  97. package/dist/src/storages/queryFlows/queryFlow.impl.js.map +1 -0
  98. package/dist/src/storages/queryFlows/queryFlow.js +12 -0
  99. package/dist/src/storages/queryFlows/queryFlow.js.map +1 -0
  100. package/dist/src/storages/queryFlows/queryFlows.d.ts +22 -0
  101. package/dist/src/storages/queryFlows/queryFlows.d.ts.map +1 -0
  102. package/dist/src/storages/queryFlows/queryFlows.impl.d.ts +18 -0
  103. package/dist/src/storages/queryFlows/queryFlows.impl.d.ts.map +1 -0
  104. package/dist/src/storages/queryFlows/queryFlows.impl.js +108 -0
  105. package/dist/src/storages/queryFlows/queryFlows.impl.js.map +1 -0
  106. package/dist/src/storages/queryFlows/queryFlows.js +16 -0
  107. package/dist/src/storages/queryFlows/queryFlows.js.map +1 -0
  108. package/dist/src/storages/workspaces/workspace.d.ts +6 -0
  109. package/dist/src/storages/workspaces/workspace.d.ts.map +1 -1
  110. package/dist/src/storages/workspaces/workspace.impl.d.ts +2 -0
  111. package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -1
  112. package/dist/src/storages/workspaces/workspace.impl.js +36 -0
  113. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -1
  114. package/dist/src/storages/workspaces/workspace.js.map +1 -1
  115. package/package.json +1 -1
  116. package/src/commands/startCommandHandler.ts +3 -0
  117. package/src/dataIslandApp.ts +6 -0
  118. package/src/dto/chatResponse.ts +21 -3
  119. package/src/dto/libraryResponse.ts +49 -0
  120. package/src/dto/queryFlowResponse.ts +27 -0
  121. package/src/dto/workspacesResponse.ts +1 -0
  122. package/src/index.ts +7 -0
  123. package/src/internal/app.impl.ts +9 -0
  124. package/src/services/acquiringService.ts +2 -2
  125. package/src/services/librariesService.ts +22 -0
  126. package/src/storages/chats/chat.impl.ts +3 -7
  127. package/src/storages/chats/chat.ts +3 -7
  128. package/src/storages/chats/chats.impl.ts +92 -0
  129. package/src/storages/chats/chats.ts +14 -0
  130. package/src/storages/library/libraries.impl.ts +192 -0
  131. package/src/storages/library/libraries.ts +20 -0
  132. package/src/storages/library/library.impl.ts +150 -0
  133. package/src/storages/library/library.ts +16 -0
  134. package/src/storages/library/libraryFolder.impl.ts +136 -0
  135. package/src/storages/library/libraryFolder.ts +25 -0
  136. package/src/storages/library/libraryPage.impl.ts +23 -0
  137. package/src/storages/library/libraryPage.ts +37 -0
  138. package/src/storages/organizations/organization.impl.ts +10 -1
  139. package/src/storages/organizations/organization.ts +6 -0
  140. package/src/storages/queryFlows/queryFlow.impl.ts +74 -0
  141. package/src/storages/queryFlows/queryFlow.ts +20 -0
  142. package/src/storages/queryFlows/queryFlows.impl.ts +151 -0
  143. package/src/storages/queryFlows/queryFlows.ts +32 -0
  144. package/src/storages/workspaces/workspace.impl.ts +43 -0
  145. package/src/storages/workspaces/workspace.ts +8 -0
@@ -0,0 +1,37 @@
1
+ import {LibraryFolder} from "./libraryFolder"
2
+ import {File} from "../files/file"
3
+
4
+
5
+ export abstract class LibraryPage {
6
+
7
+ /**
8
+ * Get current page.
9
+ */
10
+ abstract get parents(): string[]
11
+
12
+ /**
13
+ * Get page files.
14
+ */
15
+ abstract get files(): File[]
16
+
17
+ /**
18
+ * Get page folders
19
+ */
20
+ abstract get folders(): LibraryFolder[]
21
+
22
+ /**
23
+ * Get pages count.
24
+ */
25
+ abstract get pages(): number
26
+
27
+ /**
28
+ * Get total count.
29
+ */
30
+ abstract get total(): number
31
+
32
+ /**
33
+ * Get current page.
34
+ */
35
+ abstract get page(): number
36
+
37
+ }
@@ -36,6 +36,8 @@ import {
36
36
  } from "../../dto/apiKeyResponse"
37
37
  import {IconResponse} from "../../dto/workspacesResponse"
38
38
  import {UploadFile} from "../files/files"
39
+ import {QueryFlowsImpl} from "../queryFlows/queryFlows.impl"
40
+ import {QueryFlows} from "../queryFlows/queryFlows"
39
41
 
40
42
  export class OrganizationImpl extends Organization implements Disposable {
41
43
  private _isDisposed: boolean = false
@@ -43,6 +45,7 @@ export class OrganizationImpl extends Organization implements Disposable {
43
45
  private _content?: OrganizationDto
44
46
  private readonly _workspaces: WorkspacesImpl
45
47
  private readonly _accessGroups: GroupsImpl
48
+ private readonly _queryFlows: QueryFlowsImpl
46
49
  private readonly _chats: ChatsImpl
47
50
 
48
51
  constructor(private readonly context: Context) {
@@ -50,6 +53,7 @@ export class OrganizationImpl extends Organization implements Disposable {
50
53
  this._workspaces = new WorkspacesImpl(this, this.context)
51
54
  this._accessGroups = new GroupsImpl(this, this.context)
52
55
  this._chats = new ChatsImpl(this, this.context)
56
+ this._queryFlows = new QueryFlowsImpl(this, this.context)
53
57
  }
54
58
 
55
59
  public async initFrom(
@@ -63,7 +67,8 @@ export class OrganizationImpl extends Organization implements Disposable {
63
67
  const promises = [
64
68
  this._workspaces.initFrom(content.id),
65
69
  this._chats.initFrom(content.id),
66
- this._accessGroups.initialize()
70
+ this._accessGroups.initialize(),
71
+ this._queryFlows.init()
67
72
  ]
68
73
 
69
74
  await Promise.all(promises)
@@ -107,6 +112,10 @@ export class OrganizationImpl extends Organization implements Disposable {
107
112
  return this._accessGroups
108
113
  }
109
114
 
115
+ get queryFlows(): QueryFlows {
116
+ return this._queryFlows
117
+ }
118
+
110
119
  get chats(): Chats {
111
120
  return this._chats
112
121
  }
@@ -16,6 +16,7 @@ import {QuizData} from "../../dto/quizResponse"
16
16
  import {InviteResponse} from "../../dto/invitesResponse"
17
17
  import { OrganizationApiKey } from "../../dto/apiKeyResponse"
18
18
  import {UploadFile} from "../files/files"
19
+ import {QueryFlows} from "../queryFlows/queryFlows"
19
20
 
20
21
  /**
21
22
  * Organization event.
@@ -66,6 +67,11 @@ export abstract class Organization extends EventDispatcher<
66
67
  */
67
68
  abstract get accessGroups(): Groups
68
69
 
70
+ /**
71
+ * Query flows
72
+ */
73
+ abstract get queryFlows(): QueryFlows
74
+
69
75
  /**
70
76
  * Get organization members
71
77
  */
@@ -0,0 +1,74 @@
1
+ import {QueryFlow, QueryFlowEvent} from "./queryFlow"
2
+ import {QueryFlowDto, QueryFlowStatus} from "../../dto/queryFlowResponse"
3
+ import {FlowId} from "./queryFlows"
4
+ import {Context} from "../../context"
5
+ import {RpcService} from "../../services/rpcService"
6
+ import {ResponseUtils} from "../../services/responseUtils"
7
+
8
+
9
+ export class QueryFlowImpl extends QueryFlow {
10
+ private _content?: QueryFlowDto
11
+ private _id?: FlowId
12
+
13
+ constructor(private readonly context: Context) {
14
+ super()
15
+ }
16
+
17
+ async initFrom(id: FlowId) {
18
+ this._id = id
19
+ await this.fetch()
20
+ }
21
+
22
+ async fetch() {
23
+ const response = await this.context
24
+ .resolve(RpcService)
25
+ ?.requestBuilder("api/v1/QueryFlows")
26
+ .searchParam("flowId", this.id)
27
+ .sendGet()
28
+
29
+ // check response status
30
+ if (ResponseUtils.isFail(response)) {
31
+ await ResponseUtils.throwError(`Failed to fetch query flow with id ${this.id}`, response)
32
+ }
33
+
34
+ // parse flow from the server's response
35
+ const flow = (await response!.json()) as QueryFlowDto
36
+
37
+ const lastState = this._content?.state
38
+
39
+ this._content = flow
40
+ if (lastState !== undefined && lastState !== this._content.state){
41
+ this.dispatch({
42
+ type: QueryFlowEvent.UPDATED,
43
+ data: this
44
+ })
45
+ }
46
+
47
+ if (this._content.state === QueryFlowStatus.IN_PROGRESS) {
48
+ setTimeout(async () => await this.fetch(), 2000)
49
+ }
50
+ }
51
+
52
+
53
+ get id(): FlowId {
54
+ if (this._id)
55
+ return this._id
56
+ else
57
+ throw new Error("Query fLow is not loaded")
58
+ }
59
+
60
+ get resultUrl(): string {
61
+ if (this._content && this._content.result.fileUrl)
62
+ return this._content.result.fileUrl
63
+ else
64
+ throw new Error("Query fLow is not loaded")
65
+ }
66
+
67
+ get status(): QueryFlowStatus {
68
+ if (this._content)
69
+ return this._content.state
70
+ else
71
+ throw new Error("Query fLow is not loaded")
72
+ }
73
+
74
+ }
@@ -0,0 +1,20 @@
1
+ import {EventDispatcher} from "../../events"
2
+ import {FlowId} from "./queryFlows"
3
+ import {QueryFlowStatus} from "../../dto/queryFlowResponse"
4
+
5
+ export enum QueryFlowEvent {
6
+ UPDATED = "updated"
7
+ }
8
+
9
+ export abstract class QueryFlow extends EventDispatcher<
10
+ QueryFlowEvent,
11
+ QueryFlow
12
+ > {
13
+
14
+ abstract get id(): FlowId
15
+
16
+ abstract get status(): QueryFlowStatus
17
+
18
+ abstract get resultUrl(): string
19
+
20
+ }
@@ -0,0 +1,151 @@
1
+
2
+ import {Context} from "../../context"
3
+ import {FlowId, QueryFlows, QueryFlowsEvent} from "./queryFlows"
4
+ import {QueryFlow} from "./queryFlow"
5
+ import {OrganizationImpl} from "../organizations/organization.impl"
6
+ import {RpcService} from "../../services/rpcService"
7
+ import {ResponseUtils} from "../../services/responseUtils"
8
+ import {WorkspaceId} from "../workspaces/workspaces"
9
+ import {
10
+ QueryFlowListResponse,
11
+ QueryFlowResponse
12
+ } from "../../dto/queryFlowResponse"
13
+ import {QueryFlowImpl} from "./queryFlow.impl"
14
+ import {FileId} from "../files/file"
15
+ import {UploadFile} from "../files/files"
16
+
17
+
18
+ export class QueryFlowsImpl extends QueryFlows {
19
+
20
+ private _collection: QueryFlow[] = []
21
+
22
+ constructor(
23
+ public readonly organization: OrganizationImpl,
24
+ public readonly context: Context) {
25
+ super()
26
+ }
27
+
28
+ async init() {
29
+ const response = await this.context
30
+ .resolve(RpcService)
31
+ ?.requestBuilder("api/v1/QueryFlows/list")
32
+ .searchParam("organizationId", this.organization.id)
33
+ .sendGet()
34
+
35
+ // check response status
36
+ if (ResponseUtils.isFail(response)) {
37
+ await ResponseUtils.throwError(`Failed to fetch query flows for org ${this.organization.id}`, response)
38
+ }
39
+
40
+ // parse flows from the server's response
41
+ const flows = ((await response!.json()) as QueryFlowListResponse)
42
+ .flowIds
43
+
44
+ // init flows from the server's response
45
+ for (const flow of flows) {
46
+ // create workspace implementation
47
+ const flowImpl = new QueryFlowImpl(this.context)
48
+
49
+ // init workspace from the server's response
50
+ await flowImpl.initFrom(flow)
51
+
52
+ // add workspace to the collection
53
+ this._collection.push(flowImpl)
54
+
55
+ // dispatch event
56
+ this.dispatch({
57
+ type: QueryFlowsEvent.ADDED,
58
+ data: flowImpl
59
+ })
60
+ }
61
+ }
62
+
63
+ get collection(): QueryFlow[] {
64
+ return this._collection
65
+ }
66
+
67
+ async create(workspaceId: WorkspaceId, fileId: FileId, file: UploadFile ): Promise<FlowId> {
68
+ if (workspaceId === undefined || workspaceId === null || workspaceId.trim() === "") {
69
+ throw new Error("WorkspaceId is required, must be not empty")
70
+ }
71
+ if (fileId === undefined || fileId === null || fileId.trim() === "") {
72
+ throw new Error("FileId is required, must be not empty")
73
+ }
74
+ if (file === undefined || file === null) {
75
+ throw new Error("Create query flow, file is undefined or null")
76
+ }
77
+
78
+ // form data to send
79
+ const form = new FormData()
80
+ form.append("organizationId", this.organization.id)
81
+ form.append("workspaceId", workspaceId)
82
+ form.append("fileId", fileId)
83
+ form.append("file", file, file.name)
84
+
85
+ // send request to the server
86
+ const response = await this.context
87
+ .resolve(RpcService)
88
+ ?.requestBuilder("api/v1/QueryFlows")
89
+ .sendPostFormData(form)
90
+
91
+ // check response status
92
+ if (ResponseUtils.isFail(response)) {
93
+
94
+ await ResponseUtils.throwError(`Query flow creation for ${file.name}`, response)
95
+ }
96
+
97
+ const content = (await response!.json()) as QueryFlowResponse
98
+ // create workspace implementation
99
+ const queryFlow = new QueryFlowImpl(this.context)
100
+ await queryFlow.initFrom(content.flowId)
101
+
102
+ // add workspace to the collection
103
+ this._collection.push(queryFlow)
104
+
105
+
106
+ // dispatch event
107
+ this.dispatch({
108
+ type: QueryFlowsEvent.ADDED,
109
+ data: queryFlow
110
+ })
111
+
112
+ return queryFlow.id
113
+ }
114
+
115
+ async delete(id: FlowId): Promise<void> {
116
+ const flow = this._collection.find(flow => flow.id == id)
117
+
118
+ if (!flow) {
119
+ throw new Error(`Query flow ${id} is not found`)
120
+ }
121
+
122
+ // send delete request to the server
123
+ const response = await this.context
124
+ .resolve(RpcService)
125
+ ?.requestBuilder("api/v1/QueryFlows")
126
+ .searchParam("flowId", id)
127
+ .sendDelete()
128
+
129
+ // check response status
130
+ if (ResponseUtils.isFail(response)) {
131
+ await ResponseUtils.throwError(
132
+ `Failed to delete query flow ${id} in organization: ${this.organization.id}`,
133
+ response
134
+ )
135
+ }
136
+
137
+ // remove query flow from the collection
138
+ const index = this._collection.indexOf(flow)
139
+ if (index < 0) {
140
+ throw new Error(`Query flow ${id} is not found`)
141
+ }
142
+ this._collection.splice(index, 1)
143
+
144
+ // dispatch event
145
+ this.dispatch({
146
+ type: QueryFlowsEvent.REMOVED,
147
+ data: flow
148
+ })
149
+ }
150
+
151
+ }
@@ -0,0 +1,32 @@
1
+ import {EventDispatcher} from "../../events"
2
+ import {QueryFlow} from "./queryFlow"
3
+ import {WorkspaceId} from "../workspaces/workspaces"
4
+ import {FileId} from "../files/file"
5
+ import {UploadFile} from "../files/files"
6
+
7
+
8
+ /**
9
+ * Query flow id.
10
+ */
11
+ export type FlowId = string
12
+
13
+ /**
14
+ * Query flow event.
15
+ */
16
+ export enum QueryFlowsEvent {
17
+ ADDED = "added",
18
+ REMOVED = "removed"
19
+ }
20
+
21
+ export abstract class QueryFlows extends EventDispatcher<
22
+ QueryFlowsEvent,
23
+ QueryFlow
24
+ > {
25
+
26
+ abstract get collection(): QueryFlow[]
27
+
28
+ abstract create(workspaceId: WorkspaceId, fileId: FileId, file: UploadFile ): Promise<FlowId>
29
+
30
+ abstract delete(id: FlowId): Promise<void>
31
+
32
+ }
@@ -42,6 +42,13 @@ export class WorkspaceImpl extends Workspace {
42
42
  throw new Error("Workspace is not loaded.")
43
43
  }
44
44
 
45
+ get isShared(): boolean {
46
+ if (this._workspace) {
47
+ return this._workspace.isShared
48
+ }
49
+ throw new Error("Workspace is not loaded.")
50
+ }
51
+
45
52
  get files(): Files {
46
53
  return this._files
47
54
  }
@@ -115,6 +122,42 @@ export class WorkspaceImpl extends Workspace {
115
122
  })
116
123
  }
117
124
 
125
+ async share(isShared: boolean): Promise<void> {
126
+ if (!this._workspace) {
127
+ throw new Error("Workspace is not loaded.")
128
+ }
129
+ if (this._isMarkAsDeleted) {
130
+ throw new Error("Workspace is marked as deleted.")
131
+ }
132
+ if (isShared === this.isShared) {
133
+ return Promise.resolve()
134
+ }
135
+ if (isShared === undefined || isShared === null) {
136
+ throw new Error("Is shared parameter is required.")
137
+ }
138
+
139
+ const response = await this.context
140
+ .resolve(RpcService)
141
+ ?.requestBuilder("api/v1/workspaces/library")
142
+ .sendPutJson({
143
+ workspaceId: this.id,
144
+ isShared: isShared
145
+ })
146
+
147
+ if (ResponseUtils.isFail(response)) {
148
+ await ResponseUtils.throwError("Failed to change workspace shared state", response)
149
+ }
150
+
151
+ if (this._workspace) {
152
+ this._workspace.isShared = isShared
153
+ }
154
+
155
+ this.dispatch({
156
+ type: WorkspaceEvent.CHANGED,
157
+ data: this
158
+ })
159
+ }
160
+
118
161
  async initFrom(workspace: WorkspaceDto) {
119
162
  this._workspace = workspace
120
163
  }
@@ -37,6 +37,8 @@ export abstract class Workspace extends EventDispatcher<
37
37
  */
38
38
  abstract get description(): string
39
39
 
40
+ abstract get isShared(): boolean
41
+
40
42
  /**
41
43
  * Workspace files.
42
44
  */
@@ -51,4 +53,10 @@ export abstract class Workspace extends EventDispatcher<
51
53
  * Change workspace name and description.
52
54
  */
53
55
  abstract change(name: string, description: string): Promise<void>
56
+
57
+ /**
58
+ * Make workspace available for the library implementation
59
+ * @param isShared
60
+ */
61
+ abstract share(isShared: boolean): Promise<void>
54
62
  }