@neuralinnovations/dataisland-sdk 0.2.1 → 0.3.0
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/dist/package.json +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/administration.d.ts +30 -0
- package/dist/src/dto/administration.d.ts.map +1 -0
- package/dist/src/dto/administration.js +3 -0
- package/dist/src/dto/administration.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- 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/statistics.d.ts +12 -0
- package/dist/src/services/statistics.d.ts.map +1 -0
- package/dist/src/services/statistics.js +21 -0
- package/dist/src/services/statistics.js.map +1 -0
- package/dist/src/storages/administration/administration.d.ts +7 -0
- package/dist/src/storages/administration/administration.d.ts.map +1 -0
- package/dist/src/storages/administration/administration.js +7 -0
- package/dist/src/storages/administration/administration.js.map +1 -0
- package/dist/src/storages/administration/library.administration.d.ts +29 -0
- package/dist/src/storages/administration/library.administration.d.ts.map +1 -0
- package/dist/src/storages/administration/library.administration.impl.d.ts +15 -0
- package/dist/src/storages/administration/library.administration.impl.d.ts.map +1 -0
- package/dist/src/storages/administration/library.administration.impl.js +118 -0
- package/dist/src/storages/administration/library.administration.impl.js.map +1 -0
- package/dist/src/storages/administration/library.administration.js +10 -0
- package/dist/src/storages/administration/library.administration.js.map +1 -0
- package/dist/src/storages/administration/statistics.administration.d.ts +16 -0
- package/dist/src/storages/administration/statistics.administration.d.ts.map +1 -0
- package/dist/src/storages/administration/statistics.administration.impl.d.ts +11 -0
- package/dist/src/storages/administration/statistics.administration.impl.d.ts.map +1 -0
- package/dist/src/storages/administration/statistics.administration.impl.js +32 -0
- package/dist/src/storages/administration/statistics.administration.impl.js.map +1 -0
- package/dist/src/storages/administration/statistics.administration.js +10 -0
- package/dist/src/storages/administration/statistics.administration.js.map +1 -0
- package/dist/src/storages/library/libraries.d.ts +0 -31
- package/dist/src/storages/library/libraries.d.ts.map +1 -1
- package/dist/src/storages/library/libraries.impl.d.ts +1 -14
- package/dist/src/storages/library/libraries.impl.d.ts.map +1 -1
- package/dist/src/storages/library/libraries.impl.js +1 -116
- package/dist/src/storages/library/libraries.impl.js.map +1 -1
- package/dist/src/storages/library/libraries.js +1 -7
- package/dist/src/storages/library/libraries.js.map +1 -1
- package/package.json +1 -1
- package/src/dataIslandApp.ts +7 -1
- package/src/dto/administration.ts +34 -0
- package/src/index.ts +4 -1
- package/src/internal/app.impl.ts +11 -2
- package/src/services/statistics.ts +31 -0
- package/src/storages/administration/administration.ts +8 -0
- package/src/storages/administration/library.administration.impl.ts +169 -0
- package/src/storages/administration/library.administration.ts +33 -0
- package/src/storages/administration/statistics.administration.impl.ts +51 -0
- package/src/storages/administration/statistics.administration.ts +21 -0
- package/src/storages/library/libraries.impl.ts +2 -170
- package/src/storages/library/libraries.ts +0 -37
@@ -0,0 +1,51 @@
|
|
1
|
+
import { StatisticAdministration } from "./statistics.administration"
|
2
|
+
import { RpcService } from "../../services/rpcService"
|
3
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
4
|
+
import {
|
5
|
+
OrganizationMembersStatisticResponse,
|
6
|
+
OrganizationStatisticResponse
|
7
|
+
} from "../../dto/administration"
|
8
|
+
import { OrganizationId } from "../organizations/organizations"
|
9
|
+
import { Context } from "../../context"
|
10
|
+
|
11
|
+
export class StatisticAdministrationImpl implements StatisticAdministration {
|
12
|
+
constructor(private readonly context: Context) {
|
13
|
+
}
|
14
|
+
|
15
|
+
async getOrganizationMembers(
|
16
|
+
organizationId: OrganizationId,
|
17
|
+
dateFrom: number,
|
18
|
+
dateTo: number
|
19
|
+
): Promise<OrganizationMembersStatisticResponse> {
|
20
|
+
const response = await this.context
|
21
|
+
.resolve(RpcService)
|
22
|
+
?.requestBuilder("api/v1/Stats/internal/organization/members/total")
|
23
|
+
.searchParam("organizationId", organizationId)
|
24
|
+
.searchParam("dateFrom", dateFrom.toString())
|
25
|
+
.searchParam("dateTo", dateTo.toString())
|
26
|
+
.sendGet()
|
27
|
+
|
28
|
+
// check response status
|
29
|
+
if (ResponseUtils.isFail(response)) {
|
30
|
+
await ResponseUtils.throwError("Failed to get statistics", response)
|
31
|
+
}
|
32
|
+
|
33
|
+
return await response!.json() as OrganizationMembersStatisticResponse
|
34
|
+
}
|
35
|
+
|
36
|
+
async getOrganizations(dateFrom: number, dateTo: number): Promise<OrganizationStatisticResponse> {
|
37
|
+
const response = await this.context
|
38
|
+
.resolve(RpcService)
|
39
|
+
?.requestBuilder("/api/v1/Stats/internal/organizations")
|
40
|
+
.searchParam("dateFrom", dateFrom.toString())
|
41
|
+
.searchParam("dateTo", dateTo.toString())
|
42
|
+
.sendGet()
|
43
|
+
|
44
|
+
// check response status
|
45
|
+
if (ResponseUtils.isFail(response)) {
|
46
|
+
await ResponseUtils.throwError("Failed to get statistics", response)
|
47
|
+
}
|
48
|
+
|
49
|
+
return await response!.json() as OrganizationStatisticResponse
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { OrganizationId } from "../organizations/organizations"
|
2
|
+
import {
|
3
|
+
OrganizationMembersStatisticResponse,
|
4
|
+
OrganizationStatisticResponse
|
5
|
+
} from "../../dto/administration"
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Statistic management, you must have permissions to manage statistics
|
9
|
+
*/
|
10
|
+
export abstract class StatisticAdministration {
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Get organization statistics
|
14
|
+
*/
|
15
|
+
abstract getOrganizations(dateFrom: number, dateTo: number): Promise<OrganizationStatisticResponse>;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Get organization members statistics
|
19
|
+
*/
|
20
|
+
abstract getOrganizationMembers(organizationId: OrganizationId, dateFrom: number, dateTo: number): Promise<OrganizationMembersStatisticResponse>;
|
21
|
+
}
|
@@ -1,183 +1,19 @@
|
|
1
|
-
import { Libraries
|
1
|
+
import { Libraries } from "./libraries"
|
2
2
|
import { Library } from "./library"
|
3
3
|
import { LibraryImpl } from "./library.impl"
|
4
4
|
import { Context } from "../../context"
|
5
|
-
import {
|
6
|
-
CreateLibraryResponse,
|
7
|
-
LibrariesResponse, LibraryDto, LibraryResponse
|
8
|
-
} from "../../dto/libraryResponse"
|
5
|
+
import { LibrariesResponse } from "../../dto/libraryResponse"
|
9
6
|
import { RpcService } from "../../services/rpcService"
|
10
7
|
import { ResponseUtils } from "../../services/responseUtils"
|
11
|
-
import { OrganizationId } from "../organizations/organizations"
|
12
8
|
import { LibraryId } from "./libraryId"
|
13
9
|
|
14
|
-
export class LibraryManagementImpl extends LibraryManagement {
|
15
|
-
private context: Context
|
16
|
-
|
17
|
-
constructor(context: Context) {
|
18
|
-
super()
|
19
|
-
this.context = context
|
20
|
-
}
|
21
|
-
|
22
|
-
async createLibrary(name: string, description: string, region: number, isPublic: boolean): Promise<LibraryId> {
|
23
|
-
if (
|
24
|
-
name === undefined ||
|
25
|
-
name === null ||
|
26
|
-
name.trim() === ""
|
27
|
-
) {
|
28
|
-
throw new Error("Name for library is required, must be not empty")
|
29
|
-
}
|
30
|
-
|
31
|
-
if (
|
32
|
-
description === undefined ||
|
33
|
-
description === null ||
|
34
|
-
description.trim() === ""
|
35
|
-
) {
|
36
|
-
throw new Error("Description for library is required, must be not empty")
|
37
|
-
}
|
38
|
-
|
39
|
-
if (
|
40
|
-
isPublic === undefined ||
|
41
|
-
isPublic === null
|
42
|
-
) {
|
43
|
-
throw new Error("IsPublic is required, must be not empty")
|
44
|
-
}
|
45
|
-
|
46
|
-
// send create request to the server
|
47
|
-
const response = await this.context
|
48
|
-
.resolve(RpcService)
|
49
|
-
?.requestBuilder("api/v1/libraries/management")
|
50
|
-
.sendPostJson({
|
51
|
-
name: name,
|
52
|
-
description: description,
|
53
|
-
region: region,
|
54
|
-
isPublic: isPublic
|
55
|
-
})
|
56
|
-
|
57
|
-
// check response status
|
58
|
-
if (ResponseUtils.isFail(response)) {
|
59
|
-
await ResponseUtils.throwError(`Failed to create library ${name}`, response)
|
60
|
-
}
|
61
|
-
|
62
|
-
const library = (await response!.json()) as CreateLibraryResponse
|
63
|
-
|
64
|
-
return library.libraryId
|
65
|
-
}
|
66
|
-
|
67
|
-
async addOrgToLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void> {
|
68
|
-
if (libraryId === undefined || libraryId === null) {
|
69
|
-
throw new Error("Organization add to library, libraryId is undefined or null")
|
70
|
-
}
|
71
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
72
|
-
throw new Error("Organization add to from library, libraryId is empty")
|
73
|
-
}
|
74
|
-
if (organizationId === undefined || organizationId === null) {
|
75
|
-
throw new Error("Organization add to from library, organizationId is undefined or null")
|
76
|
-
}
|
77
|
-
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
78
|
-
throw new Error("Organization add to from library, organizationId is empty")
|
79
|
-
}
|
80
|
-
|
81
|
-
const response = await this.context
|
82
|
-
.resolve(RpcService)
|
83
|
-
?.requestBuilder("api/v1/libraries/management/allowed/organization")
|
84
|
-
.sendPutJson({
|
85
|
-
libraryId: libraryId,
|
86
|
-
organizationId: organizationId
|
87
|
-
})
|
88
|
-
if (ResponseUtils.isFail(response)) {
|
89
|
-
await ResponseUtils.throwError(
|
90
|
-
`Organization ${organizationId} add to library ${libraryId} failed`,
|
91
|
-
response
|
92
|
-
)
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
async getLibraries(): Promise<LibraryDto[]> {
|
97
|
-
const response = await this.context
|
98
|
-
.resolve(RpcService)
|
99
|
-
?.requestBuilder("api/v1/libraries/management/allowed/organizations")
|
100
|
-
.sendGet()
|
101
|
-
|
102
|
-
// check response status
|
103
|
-
if (ResponseUtils.isFail(response)) {
|
104
|
-
await ResponseUtils.throwError(
|
105
|
-
"Can not get libraries",
|
106
|
-
response
|
107
|
-
)
|
108
|
-
}
|
109
|
-
|
110
|
-
// parse libraries from the server's response
|
111
|
-
const libraries = (await response!.json()) as LibraryResponse
|
112
|
-
|
113
|
-
return libraries.libraries
|
114
|
-
}
|
115
|
-
|
116
|
-
async deleteOrgFromLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void> {
|
117
|
-
if (libraryId === undefined || libraryId === null) {
|
118
|
-
throw new Error("Organization delete from library, libraryId is undefined or null")
|
119
|
-
}
|
120
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
121
|
-
throw new Error("Organization delete from library, libraryId is empty")
|
122
|
-
}
|
123
|
-
if (organizationId === undefined || organizationId === null) {
|
124
|
-
throw new Error("Organization delete from library, organizationId is undefined or null")
|
125
|
-
}
|
126
|
-
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
127
|
-
throw new Error("Organization delete from library, organizationId is empty")
|
128
|
-
}
|
129
|
-
|
130
|
-
// send request to the server
|
131
|
-
const response = await this.context
|
132
|
-
.resolve(RpcService)
|
133
|
-
?.requestBuilder("api/v1/libraries/management/allowed/organization")
|
134
|
-
.searchParam("libraryId", libraryId)
|
135
|
-
.searchParam("organizationId", organizationId)
|
136
|
-
.sendDelete()
|
137
|
-
|
138
|
-
// check response status
|
139
|
-
if (ResponseUtils.isFail(response)) {
|
140
|
-
await ResponseUtils.throwError(
|
141
|
-
`Organization ${organizationId} delete from library ${libraryId}, failed`,
|
142
|
-
response
|
143
|
-
)
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
async deleteLibrary(libraryId: LibraryId): Promise<void> {
|
148
|
-
if (libraryId === undefined || libraryId === null) {
|
149
|
-
throw new Error("Library delete, libraryId is undefined or null")
|
150
|
-
}
|
151
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
152
|
-
throw new Error("Library delete, libraryId is empty")
|
153
|
-
}
|
154
|
-
|
155
|
-
// send request to the server
|
156
|
-
const response = await this.context
|
157
|
-
.resolve(RpcService)
|
158
|
-
?.requestBuilder("api/v1/libraries/management")
|
159
|
-
.searchParam("libraryId", libraryId)
|
160
|
-
.sendDelete()
|
161
|
-
|
162
|
-
// check response status
|
163
|
-
if (ResponseUtils.isFail(response)) {
|
164
|
-
await ResponseUtils.throwError(
|
165
|
-
`Library ${libraryId} delete, failed`,
|
166
|
-
response
|
167
|
-
)
|
168
|
-
}
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
10
|
export class LibrariesImpl extends Libraries {
|
173
11
|
private readonly _libraries: LibraryImpl[] = []
|
174
|
-
private readonly _management
|
175
12
|
|
176
13
|
constructor(
|
177
14
|
private readonly context: Context
|
178
15
|
) {
|
179
16
|
super()
|
180
|
-
this._management = new LibraryManagementImpl(context)
|
181
17
|
}
|
182
18
|
|
183
19
|
async initialize() {
|
@@ -212,8 +48,4 @@ export class LibrariesImpl extends Libraries {
|
|
212
48
|
return this._libraries.find((library) => library.id === libraryId)
|
213
49
|
}
|
214
50
|
|
215
|
-
get management(): LibraryManagement {
|
216
|
-
return this._management
|
217
|
-
}
|
218
|
-
|
219
51
|
}
|
@@ -1,38 +1,6 @@
|
|
1
1
|
import { Library } from "./library"
|
2
|
-
import { OrganizationId } from "../organizations/organizations"
|
3
|
-
import { LibraryDto } from "../../dto/libraryResponse"
|
4
2
|
import { LibraryId } from "./libraryId"
|
5
3
|
|
6
|
-
/**
|
7
|
-
* Library management, you must have permissions to manage libraries
|
8
|
-
*/
|
9
|
-
export abstract class LibraryManagement {
|
10
|
-
/**
|
11
|
-
* Create a new library
|
12
|
-
*/
|
13
|
-
abstract createLibrary(name: string, description: string, region: number, isPublic: boolean): Promise<LibraryId>
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Add permission for an organization to share its data through the library
|
17
|
-
*/
|
18
|
-
abstract addOrgToLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Get all libraries
|
22
|
-
*/
|
23
|
-
abstract getLibraries(): Promise<LibraryDto[]>
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Delete permission for an organization to share its data through the library
|
27
|
-
*/
|
28
|
-
abstract deleteOrgFromLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Delete a library by id
|
32
|
-
*/
|
33
|
-
abstract deleteLibrary(libraryId: LibraryId): Promise<void>
|
34
|
-
}
|
35
|
-
|
36
4
|
/**
|
37
5
|
* Libraries
|
38
6
|
*/
|
@@ -48,9 +16,4 @@ export abstract class Libraries {
|
|
48
16
|
* @param libraryId
|
49
17
|
*/
|
50
18
|
abstract getLibraryById(libraryId: LibraryId): Library | undefined
|
51
|
-
|
52
|
-
/**
|
53
|
-
* You must have permissions to manage libraries
|
54
|
-
*/
|
55
|
-
abstract get management(): LibraryManagement
|
56
19
|
}
|