@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.
- package/README.md +5 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/startCommandHandler.d.ts.map +1 -1
- package/dist/src/commands/startCommandHandler.js +3 -0
- package/dist/src/commands/startCommandHandler.js.map +1 -1
- package/dist/src/dataIslandApp.d.ts +5 -0
- package/dist/src/dataIslandApp.d.ts.map +1 -1
- package/dist/src/dataIslandApp.js.map +1 -1
- package/dist/src/dto/chatResponse.d.ts +18 -3
- package/dist/src/dto/chatResponse.d.ts.map +1 -1
- package/dist/src/dto/chatResponse.js +12 -1
- package/dist/src/dto/chatResponse.js.map +1 -1
- package/dist/src/dto/libraryResponse.d.ts +41 -0
- package/dist/src/dto/libraryResponse.d.ts.map +1 -0
- package/dist/src/dto/libraryResponse.js +3 -0
- package/dist/src/dto/libraryResponse.js.map +1 -0
- package/dist/src/dto/queryFlowResponse.d.ts +1 -0
- package/dist/src/dto/queryFlowResponse.d.ts.map +1 -1
- package/dist/src/dto/userInfoResponse.d.ts +1 -0
- package/dist/src/dto/userInfoResponse.d.ts.map +1 -1
- package/dist/src/dto/workspacesResponse.d.ts +1 -0
- package/dist/src/dto/workspacesResponse.d.ts.map +1 -1
- package/dist/src/dto/workspacesResponse.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/app.impl.d.ts +2 -0
- package/dist/src/internal/app.impl.d.ts.map +1 -1
- package/dist/src/internal/app.impl.js +7 -0
- package/dist/src/internal/app.impl.js.map +1 -1
- package/dist/src/services/acquiringService.d.ts.map +1 -1
- package/dist/src/services/acquiringService.js +2 -2
- package/dist/src/services/acquiringService.js.map +1 -1
- package/dist/src/services/librariesService.d.ts +9 -0
- package/dist/src/services/librariesService.d.ts.map +1 -0
- package/dist/src/services/librariesService.js +19 -0
- package/dist/src/services/librariesService.js.map +1 -0
- package/dist/src/storages/chats/chat.d.ts +3 -6
- 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 -6
- 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/chats/chats.d.ts +12 -0
- package/dist/src/storages/chats/chats.d.ts.map +1 -1
- package/dist/src/storages/chats/chats.impl.d.ts +2 -0
- package/dist/src/storages/chats/chats.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/chats.impl.js +68 -0
- package/dist/src/storages/chats/chats.impl.js.map +1 -1
- package/dist/src/storages/chats/chats.js.map +1 -1
- package/dist/src/storages/library/libraries.d.ts +12 -0
- package/dist/src/storages/library/libraries.d.ts.map +1 -0
- package/dist/src/storages/library/libraries.impl.d.ts +18 -0
- package/dist/src/storages/library/libraries.impl.d.ts.map +1 -0
- package/dist/src/storages/library/libraries.impl.js +134 -0
- package/dist/src/storages/library/libraries.impl.js.map +1 -0
- package/dist/src/storages/library/libraries.js +7 -0
- package/dist/src/storages/library/libraries.js.map +1 -0
- package/dist/src/storages/library/library.d.ts +10 -0
- package/dist/src/storages/library/library.d.ts.map +1 -0
- package/dist/src/storages/library/library.impl.d.ts +17 -0
- package/dist/src/storages/library/library.impl.d.ts.map +1 -0
- package/dist/src/storages/library/library.impl.js +98 -0
- package/dist/src/storages/library/library.impl.js.map +1 -0
- package/dist/src/storages/library/library.js +7 -0
- package/dist/src/storages/library/library.js.map +1 -0
- package/dist/src/storages/library/libraryFolder.d.ts +16 -0
- package/dist/src/storages/library/libraryFolder.d.ts.map +1 -0
- package/dist/src/storages/library/libraryFolder.impl.d.ts +22 -0
- package/dist/src/storages/library/libraryFolder.impl.d.ts.map +1 -0
- package/dist/src/storages/library/libraryFolder.impl.js +97 -0
- package/dist/src/storages/library/libraryFolder.impl.js.map +1 -0
- package/dist/src/storages/library/libraryFolder.js +7 -0
- package/dist/src/storages/library/libraryFolder.js.map +1 -0
- package/dist/src/storages/library/libraryPage.d.ts +29 -0
- package/dist/src/storages/library/libraryPage.d.ts.map +1 -0
- package/dist/src/storages/library/libraryPage.impl.d.ts +13 -0
- package/dist/src/storages/library/libraryPage.impl.d.ts.map +1 -0
- package/dist/src/storages/library/libraryPage.impl.js +20 -0
- package/dist/src/storages/library/libraryPage.impl.js.map +1 -0
- package/dist/src/storages/library/libraryPage.js +7 -0
- package/dist/src/storages/library/libraryPage.js.map +1 -0
- package/dist/src/storages/organizations/organization.d.ts +4 -0
- package/dist/src/storages/organizations/organization.d.ts.map +1 -1
- package/dist/src/storages/organizations/organization.impl.d.ts +1 -0
- package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
- package/dist/src/storages/organizations/organization.impl.js +4 -0
- package/dist/src/storages/organizations/organization.impl.js.map +1 -1
- package/dist/src/storages/organizations/organization.js.map +1 -1
- package/dist/src/storages/queryFlows/queryFlow.d.ts +1 -0
- package/dist/src/storages/queryFlows/queryFlow.d.ts.map +1 -1
- package/dist/src/storages/queryFlows/queryFlow.impl.d.ts +1 -0
- package/dist/src/storages/queryFlows/queryFlow.impl.d.ts.map +1 -1
- package/dist/src/storages/queryFlows/queryFlow.impl.js +7 -1
- package/dist/src/storages/queryFlows/queryFlow.impl.js.map +1 -1
- package/dist/src/storages/queryFlows/queryFlow.js.map +1 -1
- package/dist/src/storages/queryFlows/queryFlows.d.ts +1 -1
- package/dist/src/storages/queryFlows/queryFlows.d.ts.map +1 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.d.ts +1 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.d.ts.map +1 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.js +5 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.js.map +1 -1
- package/dist/src/storages/workspaces/workspace.d.ts +6 -0
- package/dist/src/storages/workspaces/workspace.d.ts.map +1 -1
- package/dist/src/storages/workspaces/workspace.impl.d.ts +2 -0
- package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -1
- package/dist/src/storages/workspaces/workspace.impl.js +38 -3
- package/dist/src/storages/workspaces/workspace.impl.js.map +1 -1
- package/dist/src/storages/workspaces/workspace.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/startCommandHandler.ts +3 -0
- package/src/dataIslandApp.ts +6 -0
- package/src/dto/chatResponse.ts +21 -3
- package/src/dto/libraryResponse.ts +49 -0
- package/src/dto/queryFlowResponse.ts +1 -0
- package/src/dto/userInfoResponse.ts +1 -0
- package/src/dto/workspacesResponse.ts +1 -0
- package/src/index.ts +4 -0
- package/src/internal/app.impl.ts +9 -0
- package/src/services/acquiringService.ts +2 -2
- package/src/services/librariesService.ts +22 -0
- package/src/storages/chats/chat.impl.ts +3 -7
- package/src/storages/chats/chat.ts +3 -7
- package/src/storages/chats/chats.impl.ts +92 -0
- package/src/storages/chats/chats.ts +14 -0
- package/src/storages/library/libraries.impl.ts +192 -0
- package/src/storages/library/libraries.ts +20 -0
- package/src/storages/library/library.impl.ts +150 -0
- package/src/storages/library/library.ts +16 -0
- package/src/storages/library/libraryFolder.impl.ts +136 -0
- package/src/storages/library/libraryFolder.ts +25 -0
- package/src/storages/library/libraryPage.impl.ts +23 -0
- package/src/storages/library/libraryPage.ts +37 -0
- package/src/storages/organizations/organization.impl.ts +4 -0
- package/src/storages/organizations/organization.ts +5 -0
- package/src/storages/queryFlows/queryFlow.impl.ts +8 -1
- package/src/storages/queryFlows/queryFlow.ts +2 -0
- package/src/storages/queryFlows/queryFlows.impl.ts +5 -1
- package/src/storages/queryFlows/queryFlows.ts +1 -1
- package/src/storages/workspaces/workspace.impl.ts +45 -5
- 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
|
}
|
@@ -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
|
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 {
|
@@ -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
|
-
|
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
|
}
|