@neuralinnovations/dataisland-sdk 0.0.1-dev74 → 0.0.1-dev76

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 (143) 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 +1 -0
  18. package/dist/src/dto/queryFlowResponse.d.ts.map +1 -1
  19. package/dist/src/dto/userInfoResponse.d.ts +1 -0
  20. package/dist/src/dto/userInfoResponse.d.ts.map +1 -1
  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 +4 -0
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/index.js +4 -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 +4 -0
  86. package/dist/src/storages/organizations/organization.d.ts.map +1 -1
  87. package/dist/src/storages/organizations/organization.impl.d.ts +1 -0
  88. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
  89. package/dist/src/storages/organizations/organization.impl.js +4 -0
  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 +1 -0
  93. package/dist/src/storages/queryFlows/queryFlow.d.ts.map +1 -1
  94. package/dist/src/storages/queryFlows/queryFlow.impl.d.ts +1 -0
  95. package/dist/src/storages/queryFlows/queryFlow.impl.d.ts.map +1 -1
  96. package/dist/src/storages/queryFlows/queryFlow.impl.js +7 -1
  97. package/dist/src/storages/queryFlows/queryFlow.impl.js.map +1 -1
  98. package/dist/src/storages/queryFlows/queryFlow.js.map +1 -1
  99. package/dist/src/storages/queryFlows/queryFlows.d.ts +1 -1
  100. package/dist/src/storages/queryFlows/queryFlows.d.ts.map +1 -1
  101. package/dist/src/storages/queryFlows/queryFlows.impl.d.ts +1 -1
  102. package/dist/src/storages/queryFlows/queryFlows.impl.d.ts.map +1 -1
  103. package/dist/src/storages/queryFlows/queryFlows.impl.js +5 -1
  104. package/dist/src/storages/queryFlows/queryFlows.impl.js.map +1 -1
  105. package/dist/src/storages/workspaces/workspace.d.ts +6 -0
  106. package/dist/src/storages/workspaces/workspace.d.ts.map +1 -1
  107. package/dist/src/storages/workspaces/workspace.impl.d.ts +2 -0
  108. package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -1
  109. package/dist/src/storages/workspaces/workspace.impl.js +38 -3
  110. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -1
  111. package/dist/src/storages/workspaces/workspace.js.map +1 -1
  112. package/package.json +1 -1
  113. package/src/commands/startCommandHandler.ts +3 -0
  114. package/src/dataIslandApp.ts +6 -0
  115. package/src/dto/chatResponse.ts +21 -3
  116. package/src/dto/libraryResponse.ts +49 -0
  117. package/src/dto/queryFlowResponse.ts +1 -0
  118. package/src/dto/userInfoResponse.ts +1 -0
  119. package/src/dto/workspacesResponse.ts +1 -0
  120. package/src/index.ts +4 -0
  121. package/src/internal/app.impl.ts +9 -0
  122. package/src/services/acquiringService.ts +2 -2
  123. package/src/services/librariesService.ts +22 -0
  124. package/src/storages/chats/chat.impl.ts +3 -7
  125. package/src/storages/chats/chat.ts +3 -7
  126. package/src/storages/chats/chats.impl.ts +92 -0
  127. package/src/storages/chats/chats.ts +14 -0
  128. package/src/storages/library/libraries.impl.ts +192 -0
  129. package/src/storages/library/libraries.ts +20 -0
  130. package/src/storages/library/library.impl.ts +150 -0
  131. package/src/storages/library/library.ts +16 -0
  132. package/src/storages/library/libraryFolder.impl.ts +136 -0
  133. package/src/storages/library/libraryFolder.ts +25 -0
  134. package/src/storages/library/libraryPage.impl.ts +23 -0
  135. package/src/storages/library/libraryPage.ts +37 -0
  136. package/src/storages/organizations/organization.impl.ts +4 -0
  137. package/src/storages/organizations/organization.ts +5 -0
  138. package/src/storages/queryFlows/queryFlow.impl.ts +8 -1
  139. package/src/storages/queryFlows/queryFlow.ts +2 -0
  140. package/src/storages/queryFlows/queryFlows.impl.ts +5 -1
  141. package/src/storages/queryFlows/queryFlows.ts +1 -1
  142. package/src/storages/workspaces/workspace.impl.ts +45 -5
  143. package/src/storages/workspaces/workspace.ts +8 -0
@@ -0,0 +1,150 @@
1
+ import {Library, LibraryId} from "./library"
2
+ import {
3
+ LibraryFolderDto,
4
+ LibraryFolderResponse,
5
+ LibraryPageResponse
6
+ } from "../../dto/libraryResponse"
7
+ import {LibraryPage} from "./libraryPage"
8
+ import {RpcService} from "../../services/rpcService"
9
+ import {ResponseUtils} from "../../services/responseUtils"
10
+ import {FileImpl} from "../files/file.impl"
11
+ import {Context} from "../../context"
12
+ import {LibraryPageImpl} from "./libraryPage.impl"
13
+ import {LibraryFolderImpl} from "./libraryFolder.impl"
14
+ import {FolderId, LibraryFolder} from "./libraryFolder"
15
+
16
+
17
+ export class LibraryImpl extends Library {
18
+
19
+ private _library?: LibraryFolderDto
20
+
21
+ public root?: LibraryPage
22
+
23
+ constructor(
24
+ private readonly context: Context
25
+ ) {
26
+ super()
27
+ }
28
+
29
+ async initFrom(library: LibraryFolderDto){
30
+ this._library = library
31
+ }
32
+
33
+ get id(): LibraryId {
34
+ if (this._library) {
35
+ return this._library.id
36
+ }
37
+ throw new Error("Library is not loaded.")
38
+ }
39
+
40
+ get name(): string {
41
+ if (this._library) {
42
+ return this._library.name
43
+ }
44
+ throw new Error("Library is not loaded.")
45
+ }
46
+
47
+ async getFolder(folderId: FolderId): Promise<LibraryFolder> {
48
+ if (folderId === undefined || folderId === null || folderId.trim() === "") {
49
+ throw new Error("Query library folder, folderId is undefined or null")
50
+ }
51
+
52
+ // send request to the server
53
+ const response = await this.context
54
+ .resolve(RpcService)
55
+ ?.requestBuilder("api/v1/libraries/folder")
56
+ .searchParam("libraryId", this.id)
57
+ .searchParam("folderId", folderId)
58
+ .sendGet()
59
+
60
+ // check response status
61
+ if (ResponseUtils.isFail(response)) {
62
+ await ResponseUtils.throwError(
63
+ `Query library folder for ${folderId} failed`,
64
+ response
65
+ )
66
+ }
67
+
68
+ // parse files from the server's response
69
+ const folder = (await response!.json()) as LibraryFolderResponse
70
+
71
+ const libFolder = new LibraryFolderImpl(this, this.context)
72
+
73
+ await libFolder.initFrom(folder.folder)
74
+
75
+ return libFolder
76
+ }
77
+
78
+ async query(query: string, page: number, limit: number): Promise<LibraryPage> {
79
+ // check page
80
+ if (page === undefined || page === null) {
81
+ throw new Error("Query library root, page is undefined or null")
82
+ }
83
+ if (page < 0) {
84
+ throw new Error("Query library root, page is negative")
85
+ }
86
+
87
+ // check limit
88
+ if (limit === undefined || limit === null) {
89
+ throw new Error("Query library root, limit is undefined or null")
90
+ }
91
+ if (limit === 0) {
92
+ throw new Error("Query library root, limit is 0")
93
+ }
94
+
95
+ // send request to the server
96
+ const response = await this.context
97
+ .resolve(RpcService)
98
+ ?.requestBuilder("api/v1/libraries/content/list")
99
+ .searchParam("libraryId", this.id)
100
+ .searchParam("nodeId", "")
101
+ .searchParam("query", query)
102
+ .searchParam("page", page.toString())
103
+ .searchParam("limit", limit.toString())
104
+ .sendGet()
105
+
106
+ // check response status
107
+ if (ResponseUtils.isFail(response)) {
108
+ await ResponseUtils.throwError(
109
+ `Query library root :${query}, page:${page}, limit:${limit}, failed`,
110
+ response
111
+ )
112
+ }
113
+
114
+ // parse files from the server's response
115
+ const pageResponse = (await response!.json()) as LibraryPageResponse
116
+
117
+ // create files list
118
+ const root = new LibraryPageImpl()
119
+ root.total = pageResponse.totalItemsCount
120
+ root.filesPerPage = pageResponse.itemsPerPage
121
+ root.page = page
122
+
123
+ // init files from the server's response
124
+ for (const fl of pageResponse.files) {
125
+
126
+ // create file implementation
127
+ const file = await new FileImpl(this.context).initFrom(fl)
128
+
129
+ // add file to the collection
130
+ root.files.push(file)
131
+ }
132
+
133
+ for (const flr of pageResponse.folders) {
134
+
135
+ // create folder implementation
136
+ const folder = new LibraryFolderImpl(this, this.context)
137
+
138
+ await folder.initFrom(flr)
139
+
140
+ // add folder to the collection
141
+ root.folders.push(folder)
142
+ }
143
+
144
+ // set files list
145
+ this.root = root
146
+
147
+ return root
148
+ }
149
+
150
+ }
@@ -0,0 +1,16 @@
1
+ import {LibraryPage} from "./libraryPage"
2
+ import {LibraryFolder, FolderId} from "./libraryFolder"
3
+
4
+ export type LibraryId = string
5
+
6
+
7
+ export abstract class Library {
8
+
9
+ abstract get id(): LibraryId
10
+
11
+ abstract get name(): string
12
+
13
+ abstract getFolder(folderId: FolderId): Promise<LibraryFolder>
14
+
15
+ abstract query(query: string, page: number, limit: number): Promise<LibraryPage>
16
+ }
@@ -0,0 +1,136 @@
1
+ import {LibraryFolder, FolderId} from "./libraryFolder"
2
+ import {LibraryId} from "./library"
3
+ import {LibraryPage} from "./libraryPage"
4
+ import {Context} from "../../context"
5
+ import {LibraryFolderDto, LibraryPageResponse} from "../../dto/libraryResponse"
6
+ import {LibraryImpl} from "./library.impl"
7
+ import {RpcService} from "../../services/rpcService"
8
+ import {ResponseUtils} from "../../services/responseUtils"
9
+ import {LibraryPageImpl} from "./libraryPage.impl"
10
+ import {FileImpl} from "../files/file.impl"
11
+
12
+
13
+ export class LibraryFolderImpl extends LibraryFolder {
14
+ private _libFolder?: LibraryFolderDto
15
+
16
+ public libraryPage?: LibraryPage
17
+
18
+ constructor(
19
+ private readonly libraryImpl: LibraryImpl,
20
+ private readonly context: Context
21
+ ) {
22
+ super()
23
+ }
24
+
25
+ async initFrom(libFolder: LibraryFolderDto) {
26
+ this._libFolder = libFolder
27
+ }
28
+
29
+ get iconId(): string {
30
+ if (this._libFolder) {
31
+ return this._libFolder.iconId
32
+ }
33
+ throw new Error("LibraryFolder is not loaded.")
34
+ }
35
+
36
+ itemsCount(): Promise<number> {
37
+ return Promise.resolve(0)
38
+ }
39
+
40
+ get libraryId(): LibraryId {
41
+ return this.libraryImpl.id
42
+ }
43
+
44
+ get name(): string {
45
+ if (this._libFolder) {
46
+ return this._libFolder.name
47
+ }
48
+ throw new Error("LibraryFolder is not loaded.")
49
+ }
50
+
51
+ get parents(): string[] {
52
+ if (this.libraryPage) {
53
+ return this.libraryPage.parents
54
+ }
55
+ throw new Error("Library page is not loaded, try query first")
56
+ }
57
+
58
+ get folderId(): FolderId {
59
+ if (this._libFolder) {
60
+ return this._libFolder.id
61
+ }
62
+ throw new Error("LibraryFolder is not loaded.")
63
+ }
64
+
65
+ async query(query: string, page: number, limit: number): Promise<LibraryPage> {
66
+ if (page === undefined || page === null) {
67
+ throw new Error("Query library folder, page is undefined or null")
68
+ }
69
+ if (page < 0) {
70
+ throw new Error("Query library folder, page is negative")
71
+ }
72
+
73
+ // check limit
74
+ if (limit === undefined || limit === null) {
75
+ throw new Error("Query library folder, limit is undefined or null")
76
+ }
77
+ if (limit === 0) {
78
+ throw new Error("Query library folder, limit is 0")
79
+ }
80
+
81
+ // send request to the server
82
+ const response = await this.context
83
+ .resolve(RpcService)
84
+ ?.requestBuilder("api/v1/libraries/content/list")
85
+ .searchParam("libraryId", this.libraryId)
86
+ .searchParam("folderId", this.folderId)
87
+ .searchParam("query", query)
88
+ .searchParam("page", page.toString())
89
+ .searchParam("limit", limit.toString())
90
+ .sendGet()
91
+
92
+ // check response status
93
+ if (ResponseUtils.isFail(response)) {
94
+ await ResponseUtils.throwError(
95
+ `Query library folder :${query}, page:${page}, limit:${limit}, failed`,
96
+ response
97
+ )
98
+ }
99
+
100
+ // parse files from the server's response
101
+ const libPageResponse = (await response!.json()) as LibraryPageResponse
102
+
103
+ // create files list
104
+ const libraryPage = new LibraryPageImpl()
105
+ libraryPage.total = libPageResponse.totalItemsCount
106
+ libraryPage.filesPerPage = libPageResponse.itemsPerPage
107
+ libraryPage.page = page
108
+
109
+ // init files from the server's response
110
+ for (const fl of libPageResponse.files) {
111
+
112
+ // create file implementation
113
+ const file = await new FileImpl(this.context).initFrom(fl)
114
+
115
+ // add file to the collection
116
+ libraryPage.files.push(file)
117
+ }
118
+
119
+ for (const flr of libPageResponse.folders) {
120
+
121
+ // create folder implementation
122
+ const folder = new LibraryFolderImpl(this.libraryImpl, this.context)
123
+
124
+ await folder.initFrom(flr)
125
+
126
+ // add folder to the collection
127
+ libraryPage.folders.push(folder)
128
+ }
129
+
130
+ // set files list
131
+ this.libraryPage = libraryPage
132
+
133
+ return libraryPage
134
+ }
135
+
136
+ }
@@ -0,0 +1,25 @@
1
+ import {LibraryId} from "./library"
2
+ import {LibraryPage} from "./libraryPage"
3
+
4
+
5
+ export type FolderId = string
6
+
7
+ export abstract class LibraryFolder {
8
+
9
+ abstract get libraryId(): LibraryId
10
+
11
+ abstract get parents(): FolderId[]
12
+
13
+ abstract get folderId(): FolderId
14
+
15
+ abstract get name(): string
16
+
17
+ abstract get iconId(): string
18
+
19
+ abstract itemsCount(): Promise<number>
20
+
21
+ /**
22
+ * Query files.
23
+ */
24
+ abstract query(query: string, page: number, limit: number): Promise<LibraryPage>
25
+ }
@@ -0,0 +1,23 @@
1
+ import {LibraryPage} from "./libraryPage"
2
+ import {LibraryFolder} from "./libraryFolder"
3
+ import {File} from "../files/file"
4
+
5
+
6
+ export class LibraryPageImpl extends LibraryPage {
7
+
8
+ public parents: string[] = []
9
+
10
+ public files: File[] = []
11
+ public folders: LibraryFolder[] = []
12
+
13
+ public total: number = 0
14
+ public filesPerPage: number = 0
15
+ public page: number = 0
16
+
17
+
18
+ get pages(): number {
19
+ return Math.ceil(Math.max(this.total / this.filesPerPage, 1.0))
20
+ }
21
+
22
+
23
+ }
@@ -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
+ }
@@ -104,6 +104,10 @@ export class OrganizationImpl extends Organization implements Disposable {
104
104
  return <string>this._content?.profile.iconId
105
105
  }
106
106
 
107
+ get isAllowedInLibraries(): boolean {
108
+ return <boolean>this._content?.profile.isAllowedInLibraries
109
+ }
110
+
107
111
  get workspaces(): Workspaces {
108
112
  return this._workspaces
109
113
  }
@@ -52,6 +52,11 @@ export abstract class Organization extends EventDispatcher<
52
52
  */
53
53
  abstract get icon(): string
54
54
 
55
+ /**
56
+ * If organizations allowed in libraries
57
+ */
58
+ abstract get isAllowedInLibraries(): boolean
59
+
55
60
  /**
56
61
  * Workspaces.
57
62
  */
@@ -54,7 +54,14 @@ export class QueryFlowImpl extends QueryFlow {
54
54
  if (this._id)
55
55
  return this._id
56
56
  else
57
- throw new Error("Query fLow is not loaded")
57
+ throw new Error("Query flow is not loaded")
58
+ }
59
+
60
+ get name(): string {
61
+ if (this._content)
62
+ return this._content.name
63
+ else
64
+ throw new Error("Query flow is not loaded")
58
65
  }
59
66
 
60
67
  get resultUrl(): string {
@@ -13,6 +13,8 @@ export abstract class QueryFlow extends EventDispatcher<
13
13
 
14
14
  abstract get id(): FlowId
15
15
 
16
+ abstract get name(): string
17
+
16
18
  abstract get status(): QueryFlowStatus
17
19
 
18
20
  abstract get resultUrl(): string
@@ -64,7 +64,10 @@ export class QueryFlowsImpl extends QueryFlows {
64
64
  return this._collection
65
65
  }
66
66
 
67
- async create(workspaceId: WorkspaceId, fileId: FileId, file: UploadFile ): Promise<FlowId> {
67
+ async create(name: string, workspaceId: WorkspaceId, fileId: FileId, file: UploadFile ): Promise<FlowId> {
68
+ if (name === undefined || name === null || name.trim() === "") {
69
+ throw new Error("Name is required, must be not empty")
70
+ }
68
71
  if (workspaceId === undefined || workspaceId === null || workspaceId.trim() === "") {
69
72
  throw new Error("WorkspaceId is required, must be not empty")
70
73
  }
@@ -80,6 +83,7 @@ export class QueryFlowsImpl extends QueryFlows {
80
83
  form.append("organizationId", this.organization.id)
81
84
  form.append("workspaceId", workspaceId)
82
85
  form.append("fileId", fileId)
86
+ form.append("name", name)
83
87
  form.append("file", file, file.name)
84
88
 
85
89
  // send request to the server
@@ -25,7 +25,7 @@ export abstract class QueryFlows extends EventDispatcher<
25
25
 
26
26
  abstract get collection(): QueryFlow[]
27
27
 
28
- abstract create(workspaceId: WorkspaceId, fileId: FileId, file: UploadFile ): Promise<FlowId>
28
+ abstract create(name: string, workspaceId: WorkspaceId, fileId: FileId, file: UploadFile ): Promise<FlowId>
29
29
 
30
30
  abstract delete(id: FlowId): Promise<void>
31
31
 
@@ -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
  }
@@ -81,12 +88,9 @@ export class WorkspaceImpl extends Workspace {
81
88
  }
82
89
  if (
83
90
  description === undefined ||
84
- description === null ||
85
- description.trim() === ""
91
+ description === null
86
92
  ) {
87
- throw new Error(
88
- "Description is required. Please provide a valid description."
89
- )
93
+ description = ""
90
94
  }
91
95
 
92
96
  const response = await this.context
@@ -115,6 +119,42 @@ export class WorkspaceImpl extends Workspace {
115
119
  })
116
120
  }
117
121
 
122
+ async share(isShared: boolean): Promise<void> {
123
+ if (!this._workspace) {
124
+ throw new Error("Workspace is not loaded.")
125
+ }
126
+ if (this._isMarkAsDeleted) {
127
+ throw new Error("Workspace is marked as deleted.")
128
+ }
129
+ if (isShared === this.isShared) {
130
+ return Promise.resolve()
131
+ }
132
+ if (isShared === undefined || isShared === null) {
133
+ throw new Error("Is shared parameter is required.")
134
+ }
135
+
136
+ const response = await this.context
137
+ .resolve(RpcService)
138
+ ?.requestBuilder("api/v1/workspaces/library")
139
+ .sendPutJson({
140
+ workspaceId: this.id,
141
+ isShared: isShared
142
+ })
143
+
144
+ if (ResponseUtils.isFail(response)) {
145
+ await ResponseUtils.throwError("Failed to change workspace shared state", response)
146
+ }
147
+
148
+ if (this._workspace) {
149
+ this._workspace.isShared = isShared
150
+ }
151
+
152
+ this.dispatch({
153
+ type: WorkspaceEvent.CHANGED,
154
+ data: this
155
+ })
156
+ }
157
+
118
158
  async initFrom(workspace: WorkspaceDto) {
119
159
  this._workspace = workspace
120
160
  }
@@ -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
  }