@neuralinnovations/dataisland-sdk 0.2.0 → 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 -110
- 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 -161
- package/src/storages/library/libraries.ts +0 -37
@@ -1,32 +1,5 @@
|
|
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
|
-
/**
|
6
|
-
* Library management, you must have permissions to manage libraries
|
7
|
-
*/
|
8
|
-
export declare abstract class LibraryManagement {
|
9
|
-
/**
|
10
|
-
* Create a new library
|
11
|
-
*/
|
12
|
-
abstract createLibrary(name: string, region: number, isPublic: boolean): Promise<LibraryId>;
|
13
|
-
/**
|
14
|
-
* Add permission for an organization to share its data through the library
|
15
|
-
*/
|
16
|
-
abstract addOrgToLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>;
|
17
|
-
/**
|
18
|
-
* Get all libraries
|
19
|
-
*/
|
20
|
-
abstract getLibraries(): Promise<LibraryDto[]>;
|
21
|
-
/**
|
22
|
-
* Delete permission for an organization to share its data through the library
|
23
|
-
*/
|
24
|
-
abstract deleteOrgFromLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>;
|
25
|
-
/**
|
26
|
-
* Delete a library by id
|
27
|
-
*/
|
28
|
-
abstract deleteLibrary(libraryId: LibraryId): Promise<void>;
|
29
|
-
}
|
30
3
|
/**
|
31
4
|
* Libraries
|
32
5
|
*/
|
@@ -40,9 +13,5 @@ export declare abstract class Libraries {
|
|
40
13
|
* @param libraryId
|
41
14
|
*/
|
42
15
|
abstract getLibraryById(libraryId: LibraryId): Library | undefined;
|
43
|
-
/**
|
44
|
-
* You must have permissions to manage libraries
|
45
|
-
*/
|
46
|
-
abstract get management(): LibraryManagement;
|
47
16
|
}
|
48
17
|
//# sourceMappingURL=libraries.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../../../../src/storages/library/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../../../../src/storages/library/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC;;GAEG;AACH,8BAAsB,SAAS;IAE7B;;OAEG;IACH,QAAQ,KAAK,UAAU,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IAEjD;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS;CACnE"}
|
@@ -1,26 +1,13 @@
|
|
1
|
-
import { Libraries
|
1
|
+
import { Libraries } from "./libraries";
|
2
2
|
import { Library } from "./library";
|
3
3
|
import { Context } from "../../context";
|
4
|
-
import { LibraryDto } from "../../dto/libraryResponse";
|
5
|
-
import { OrganizationId } from "../organizations/organizations";
|
6
4
|
import { LibraryId } from "./libraryId";
|
7
|
-
export declare class LibraryManagementImpl extends LibraryManagement {
|
8
|
-
private context;
|
9
|
-
constructor(context: Context);
|
10
|
-
createLibrary(name: string, region: number, isPublic: boolean): Promise<LibraryId>;
|
11
|
-
addOrgToLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>;
|
12
|
-
getLibraries(): Promise<LibraryDto[]>;
|
13
|
-
deleteOrgFromLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>;
|
14
|
-
deleteLibrary(libraryId: LibraryId): Promise<void>;
|
15
|
-
}
|
16
5
|
export declare class LibrariesImpl extends Libraries {
|
17
6
|
private readonly context;
|
18
7
|
private readonly _libraries;
|
19
|
-
private readonly _management;
|
20
8
|
constructor(context: Context);
|
21
9
|
initialize(): Promise<void>;
|
22
10
|
get collection(): readonly Library[];
|
23
11
|
getLibraryById(libraryId: LibraryId): Library | undefined;
|
24
|
-
get management(): LibraryManagement;
|
25
12
|
}
|
26
13
|
//# sourceMappingURL=libraries.impl.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"libraries.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/library/libraries.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"libraries.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/library/libraries.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,qBAAa,aAAc,SAAQ,SAAS;IAIxC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAG5B,OAAO,EAAE,OAAO;IAK7B,UAAU;IAwBhB,IAAI,UAAU,IAAI,SAAS,OAAO,EAAE,CAEnC;IAED,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS;CAI1D"}
|
@@ -1,121 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.LibrariesImpl =
|
3
|
+
exports.LibrariesImpl = void 0;
|
4
4
|
const libraries_1 = require("./libraries");
|
5
5
|
const library_impl_1 = require("./library.impl");
|
6
6
|
const rpcService_1 = require("../../services/rpcService");
|
7
7
|
const responseUtils_1 = require("../../services/responseUtils");
|
8
|
-
class LibraryManagementImpl extends libraries_1.LibraryManagement {
|
9
|
-
constructor(context) {
|
10
|
-
super();
|
11
|
-
this.context = context;
|
12
|
-
}
|
13
|
-
async createLibrary(name, region, isPublic) {
|
14
|
-
var _a;
|
15
|
-
if (name === undefined ||
|
16
|
-
name === null ||
|
17
|
-
name.trim() === "") {
|
18
|
-
throw new Error("Name for library is required, must be not empty");
|
19
|
-
}
|
20
|
-
if (isPublic === undefined ||
|
21
|
-
isPublic === null) {
|
22
|
-
throw new Error("IsPublic is required, must be not empty");
|
23
|
-
}
|
24
|
-
// send create request to the server
|
25
|
-
const response = await ((_a = this.context
|
26
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management").sendPostJson({
|
27
|
-
name: name,
|
28
|
-
region: region,
|
29
|
-
isPublic: isPublic
|
30
|
-
}));
|
31
|
-
// check response status
|
32
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
33
|
-
await responseUtils_1.ResponseUtils.throwError(`Failed to create library ${name}`, response);
|
34
|
-
}
|
35
|
-
const library = (await response.json());
|
36
|
-
return library.libraryId;
|
37
|
-
}
|
38
|
-
async addOrgToLibrary(libraryId, organizationId) {
|
39
|
-
var _a;
|
40
|
-
if (libraryId === undefined || libraryId === null) {
|
41
|
-
throw new Error("Organization add to library, libraryId is undefined or null");
|
42
|
-
}
|
43
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
44
|
-
throw new Error("Organization add to from library, libraryId is empty");
|
45
|
-
}
|
46
|
-
if (organizationId === undefined || organizationId === null) {
|
47
|
-
throw new Error("Organization add to from library, organizationId is undefined or null");
|
48
|
-
}
|
49
|
-
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
50
|
-
throw new Error("Organization add to from library, organizationId is empty");
|
51
|
-
}
|
52
|
-
const response = await ((_a = this.context
|
53
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management/allowed/organization").sendPutJson({
|
54
|
-
libraryId: libraryId,
|
55
|
-
organizationId: organizationId
|
56
|
-
}));
|
57
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
58
|
-
await responseUtils_1.ResponseUtils.throwError(`Organization ${organizationId} add to library ${libraryId} failed`, response);
|
59
|
-
}
|
60
|
-
}
|
61
|
-
async getLibraries() {
|
62
|
-
var _a;
|
63
|
-
const response = await ((_a = this.context
|
64
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management/allowed/organizations").sendGet());
|
65
|
-
// check response status
|
66
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
67
|
-
await responseUtils_1.ResponseUtils.throwError("Can not get libraries", response);
|
68
|
-
}
|
69
|
-
// parse libraries from the server's response
|
70
|
-
const libraries = (await response.json());
|
71
|
-
return libraries.libraries;
|
72
|
-
}
|
73
|
-
async deleteOrgFromLibrary(libraryId, organizationId) {
|
74
|
-
var _a;
|
75
|
-
if (libraryId === undefined || libraryId === null) {
|
76
|
-
throw new Error("Organization delete from library, libraryId is undefined or null");
|
77
|
-
}
|
78
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
79
|
-
throw new Error("Organization delete from library, libraryId is empty");
|
80
|
-
}
|
81
|
-
if (organizationId === undefined || organizationId === null) {
|
82
|
-
throw new Error("Organization delete from library, organizationId is undefined or null");
|
83
|
-
}
|
84
|
-
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
85
|
-
throw new Error("Organization delete from library, organizationId is empty");
|
86
|
-
}
|
87
|
-
// send request to the server
|
88
|
-
const response = await ((_a = this.context
|
89
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management/allowed/organization").searchParam("libraryId", libraryId).searchParam("organizationId", organizationId).sendDelete());
|
90
|
-
// check response status
|
91
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
92
|
-
await responseUtils_1.ResponseUtils.throwError(`Organization ${organizationId} delete from library ${libraryId}, failed`, response);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
async deleteLibrary(libraryId) {
|
96
|
-
var _a;
|
97
|
-
if (libraryId === undefined || libraryId === null) {
|
98
|
-
throw new Error("Library delete, libraryId is undefined or null");
|
99
|
-
}
|
100
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
101
|
-
throw new Error("Library delete, libraryId is empty");
|
102
|
-
}
|
103
|
-
// send request to the server
|
104
|
-
const response = await ((_a = this.context
|
105
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management").searchParam("libraryId", libraryId).sendDelete());
|
106
|
-
// check response status
|
107
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
108
|
-
await responseUtils_1.ResponseUtils.throwError(`Library ${libraryId} delete, failed`, response);
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
exports.LibraryManagementImpl = LibraryManagementImpl;
|
113
8
|
class LibrariesImpl extends libraries_1.Libraries {
|
114
9
|
constructor(context) {
|
115
10
|
super();
|
116
11
|
this.context = context;
|
117
12
|
this._libraries = [];
|
118
|
-
this._management = new LibraryManagementImpl(context);
|
119
13
|
}
|
120
14
|
async initialize() {
|
121
15
|
var _a;
|
@@ -141,9 +35,6 @@ class LibrariesImpl extends libraries_1.Libraries {
|
|
141
35
|
getLibraryById(libraryId) {
|
142
36
|
return this._libraries.find((library) => library.id === libraryId);
|
143
37
|
}
|
144
|
-
get management() {
|
145
|
-
return this._management;
|
146
|
-
}
|
147
38
|
}
|
148
39
|
exports.LibrariesImpl = LibrariesImpl;
|
149
40
|
//# sourceMappingURL=libraries.impl.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"libraries.impl.js","sourceRoot":"","sources":["../../../../src/storages/library/libraries.impl.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"libraries.impl.js","sourceRoot":"","sources":["../../../../src/storages/library/libraries.impl.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,iDAA4C;AAG5C,0DAAsD;AACtD,gEAA4D;AAG5D,MAAa,aAAc,SAAQ,qBAAS;IAG1C,YACmB,OAAgB;QAEjC,KAAK,EAAE,CAAA;QAFU,YAAO,GAAP,OAAO,CAAS;QAHlB,eAAU,GAAkB,EAAE,CAAA;IAM/C,CAAC;IAED,KAAK,CAAC,UAAU;;QACd,eAAe;QACf,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAU,CAAC,0CACnD,cAAc,CAAC,kBAAkB,EAClC,OAAO,EAAE,CAAA,CAAA;QAEZ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAA;QACrE,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAS,CAAC,IAAI,EAAE,CAAA;QAEnC,0CAA0C;QAC1C,MAAM,SAAS,GAAI,IAA0B,CAAC,SAAS,CAAA;QAEvD,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAA;QAC1B,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAC1C,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;YAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,cAAc,CAAC,SAAoB;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,CAAA;IACpE,CAAC;CAEF;AAzCD,sCAyCC"}
|
@@ -1,12 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Libraries =
|
4
|
-
/**
|
5
|
-
* Library management, you must have permissions to manage libraries
|
6
|
-
*/
|
7
|
-
class LibraryManagement {
|
8
|
-
}
|
9
|
-
exports.LibraryManagement = LibraryManagement;
|
3
|
+
exports.Libraries = void 0;
|
10
4
|
/**
|
11
5
|
* Libraries
|
12
6
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../../../src/storages/library/libraries.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../../../src/storages/library/libraries.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAsB,SAAS;CAY9B;AAZD,8BAYC"}
|
package/package.json
CHANGED
package/src/dataIslandApp.ts
CHANGED
@@ -5,7 +5,8 @@ import type { Constructor } from "./internal/registry"
|
|
5
5
|
import { Organizations } from "./storages/organizations/organizations"
|
6
6
|
import { UserProfile } from "./storages/user/userProfile"
|
7
7
|
import { Acquiring } from "./storages/acquirings/acquiring"
|
8
|
-
import {Libraries} from "./storages/library/libraries"
|
8
|
+
import { Libraries } from "./storages/library/libraries"
|
9
|
+
import { Administration } from "./storages/administration/administration"
|
9
10
|
|
10
11
|
/**
|
11
12
|
* DataIsland App instance.
|
@@ -63,6 +64,11 @@ export abstract class DataIslandApp {
|
|
63
64
|
*/
|
64
65
|
abstract get libraries(): Libraries
|
65
66
|
|
67
|
+
/**
|
68
|
+
* Administration.
|
69
|
+
*/
|
70
|
+
abstract get administration(): Administration
|
71
|
+
|
66
72
|
/**
|
67
73
|
* Resolve a service from the app.
|
68
74
|
* @param type
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { OrganizationId } from "../storages/organizations/organizations"
|
2
|
+
import { UserId } from "../storages/user/userProfile"
|
3
|
+
|
4
|
+
export interface OrganizationStatisticDataDto {
|
5
|
+
modelName: string,
|
6
|
+
promptUsage: 0,
|
7
|
+
completionUsage: 0
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface OrganizationStatisticDto {
|
11
|
+
organizationId: OrganizationId
|
12
|
+
organizationName: string
|
13
|
+
totalUsage: number
|
14
|
+
data: OrganizationStatisticDataDto[]
|
15
|
+
}
|
16
|
+
|
17
|
+
export interface OrganizationStatisticResponse {
|
18
|
+
dateFrom: string,
|
19
|
+
dateTo: string,
|
20
|
+
organizationStats: OrganizationStatisticDto[]
|
21
|
+
}
|
22
|
+
|
23
|
+
export interface OrganizationMemberStatisticDto {
|
24
|
+
userId: UserId
|
25
|
+
userEmail: string
|
26
|
+
totalUsage: number
|
27
|
+
data: OrganizationStatisticDataDto[]
|
28
|
+
}
|
29
|
+
|
30
|
+
export interface OrganizationMembersStatisticResponse {
|
31
|
+
dateFrom: string,
|
32
|
+
dateTo: string,
|
33
|
+
organizationStats: OrganizationMemberStatisticDto[]
|
34
|
+
}
|
package/src/index.ts
CHANGED
@@ -73,7 +73,7 @@ export {
|
|
73
73
|
export { FolderId } from "./storages/library/folderId"
|
74
74
|
export { LibraryId } from "./storages/library/libraryId"
|
75
75
|
export { Library } from "./storages/library/library"
|
76
|
-
export { Libraries
|
76
|
+
export { Libraries } from "./storages/library/libraries"
|
77
77
|
export { LibraryPage, LibraryParent } from "./storages/library/libraryPage"
|
78
78
|
export { LibraryFolder } from "./storages/library/libraryFolder"
|
79
79
|
|
@@ -147,3 +147,6 @@ export async function dataIslandApp(
|
|
147
147
|
}
|
148
148
|
return await appPromise
|
149
149
|
}
|
150
|
+
export {
|
151
|
+
LibraryAdministration
|
152
|
+
} from "./storages/administration/library.administration"
|
package/src/internal/app.impl.ts
CHANGED
@@ -32,8 +32,10 @@ import { CookieService } from "../services/cookieService"
|
|
32
32
|
import { AnonymousService } from "../services/anonymousService"
|
33
33
|
import { Acquiring } from "../storages/acquirings/acquiring"
|
34
34
|
import { AcquiringService } from "../services/acquiringService"
|
35
|
-
import {Libraries} from "../storages/library/libraries"
|
36
|
-
import {LibrariesService} from "../services/librariesService"
|
35
|
+
import { Libraries } from "../storages/library/libraries"
|
36
|
+
import { LibrariesService } from "../services/librariesService"
|
37
|
+
import { AdministrationService } from "../services/statistics"
|
38
|
+
import { Administration } from "../storages/administration/administration"
|
37
39
|
|
38
40
|
export class DataIslandAppImpl extends DataIslandApp {
|
39
41
|
readonly name: string
|
@@ -95,6 +97,10 @@ export class DataIslandAppImpl extends DataIslandApp {
|
|
95
97
|
return (this.resolve(LibrariesService) as LibrariesService).libraries
|
96
98
|
}
|
97
99
|
|
100
|
+
get administration(): Administration {
|
101
|
+
return this.resolve(AdministrationService) as Administration
|
102
|
+
}
|
103
|
+
|
98
104
|
async invalidate(): Promise<void> {
|
99
105
|
await this.context.execute(new StartCommand())
|
100
106
|
}
|
@@ -144,6 +150,9 @@ export class DataIslandAppImpl extends DataIslandApp {
|
|
144
150
|
builder.registerService(LibrariesService, (context: ServiceContext) => {
|
145
151
|
return new LibrariesService(context)
|
146
152
|
})
|
153
|
+
builder.registerService(AdministrationService, (context: ServiceContext) => {
|
154
|
+
return new AdministrationService(context)
|
155
|
+
})
|
147
156
|
|
148
157
|
// call customer setup
|
149
158
|
if (setup !== undefined) {
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Service, ServiceContext } from "./service"
|
2
|
+
import {
|
3
|
+
LibraryAdministrationImpl
|
4
|
+
} from "../storages/administration/library.administration.impl"
|
5
|
+
import {
|
6
|
+
LibraryAdministration
|
7
|
+
} from "../storages/administration/library.administration"
|
8
|
+
import {
|
9
|
+
StatisticAdministrationImpl
|
10
|
+
} from "../storages/administration/statistics.administration.impl"
|
11
|
+
import { Administration } from "../storages/administration/administration"
|
12
|
+
|
13
|
+
export class AdministrationService extends Service implements Administration {
|
14
|
+
private readonly _libraries: LibraryAdministrationImpl
|
15
|
+
private readonly _statistic: StatisticAdministrationImpl
|
16
|
+
|
17
|
+
constructor(context: ServiceContext) {
|
18
|
+
super(context)
|
19
|
+
|
20
|
+
this._libraries = new LibraryAdministrationImpl(context.context)
|
21
|
+
this._statistic = new StatisticAdministrationImpl(context.context)
|
22
|
+
}
|
23
|
+
|
24
|
+
get libraries(): LibraryAdministration {
|
25
|
+
return this._libraries
|
26
|
+
}
|
27
|
+
|
28
|
+
get statistic(): StatisticAdministrationImpl {
|
29
|
+
return this._statistic
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { LibraryAdministration } from "./library.administration"
|
2
|
+
import { StatisticAdministration } from "./statistics.administration"
|
3
|
+
|
4
|
+
export abstract class Administration {
|
5
|
+
abstract get libraries(): LibraryAdministration ;
|
6
|
+
|
7
|
+
abstract get statistic(): StatisticAdministration;
|
8
|
+
}
|
@@ -0,0 +1,169 @@
|
|
1
|
+
import { LibraryAdministration } from "./library.administration"
|
2
|
+
import { Context } from "../../context"
|
3
|
+
import { LibraryId } from "../library/libraryId"
|
4
|
+
import { RpcService } from "../../services/rpcService"
|
5
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
6
|
+
import {
|
7
|
+
CreateLibraryResponse,
|
8
|
+
LibraryDto,
|
9
|
+
LibraryResponse
|
10
|
+
} from "../../dto/libraryResponse"
|
11
|
+
import { OrganizationId } from "../organizations/organizations"
|
12
|
+
|
13
|
+
export class LibraryAdministrationImpl extends LibraryAdministration {
|
14
|
+
private context: Context
|
15
|
+
|
16
|
+
constructor(context: Context) {
|
17
|
+
super()
|
18
|
+
this.context = context
|
19
|
+
}
|
20
|
+
|
21
|
+
async createLibrary(name: string, description: string, region: number, isPublic: boolean): Promise<LibraryId> {
|
22
|
+
if (
|
23
|
+
name === undefined ||
|
24
|
+
name === null ||
|
25
|
+
name.trim() === ""
|
26
|
+
) {
|
27
|
+
throw new Error("Name for library is required, must be not empty")
|
28
|
+
}
|
29
|
+
|
30
|
+
if (
|
31
|
+
description === undefined ||
|
32
|
+
description === null ||
|
33
|
+
description.trim() === ""
|
34
|
+
) {
|
35
|
+
throw new Error("Description for library is required, must be not empty")
|
36
|
+
}
|
37
|
+
|
38
|
+
if (
|
39
|
+
isPublic === undefined ||
|
40
|
+
isPublic === null
|
41
|
+
) {
|
42
|
+
throw new Error("IsPublic is required, must be not empty")
|
43
|
+
}
|
44
|
+
|
45
|
+
// send create request to the server
|
46
|
+
const response = await this.context
|
47
|
+
.resolve(RpcService)
|
48
|
+
?.requestBuilder("api/v1/libraries/management")
|
49
|
+
.sendPostJson({
|
50
|
+
name: name,
|
51
|
+
description: description,
|
52
|
+
region: region,
|
53
|
+
isPublic: isPublic
|
54
|
+
})
|
55
|
+
|
56
|
+
// check response status
|
57
|
+
if (ResponseUtils.isFail(response)) {
|
58
|
+
await ResponseUtils.throwError(`Failed to create library ${name}`, response)
|
59
|
+
}
|
60
|
+
|
61
|
+
const library = (await response!.json()) as CreateLibraryResponse
|
62
|
+
|
63
|
+
return library.libraryId
|
64
|
+
}
|
65
|
+
|
66
|
+
async addOrgToLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void> {
|
67
|
+
if (libraryId === undefined || libraryId === null) {
|
68
|
+
throw new Error("Organization add to library, libraryId is undefined or null")
|
69
|
+
}
|
70
|
+
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
71
|
+
throw new Error("Organization add to from library, libraryId is empty")
|
72
|
+
}
|
73
|
+
if (organizationId === undefined || organizationId === null) {
|
74
|
+
throw new Error("Organization add to from library, organizationId is undefined or null")
|
75
|
+
}
|
76
|
+
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
77
|
+
throw new Error("Organization add to from library, organizationId is empty")
|
78
|
+
}
|
79
|
+
|
80
|
+
const response = await this.context
|
81
|
+
.resolve(RpcService)
|
82
|
+
?.requestBuilder("api/v1/libraries/management/allowed/organization")
|
83
|
+
.sendPutJson({
|
84
|
+
libraryId: libraryId,
|
85
|
+
organizationId: organizationId
|
86
|
+
})
|
87
|
+
if (ResponseUtils.isFail(response)) {
|
88
|
+
await ResponseUtils.throwError(
|
89
|
+
`Organization ${organizationId} add to library ${libraryId} failed`,
|
90
|
+
response
|
91
|
+
)
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
async getLibraries(): Promise<LibraryDto[]> {
|
96
|
+
const response = await this.context
|
97
|
+
.resolve(RpcService)
|
98
|
+
?.requestBuilder("api/v1/libraries/management/allowed/organizations")
|
99
|
+
.sendGet()
|
100
|
+
|
101
|
+
// check response status
|
102
|
+
if (ResponseUtils.isFail(response)) {
|
103
|
+
await ResponseUtils.throwError(
|
104
|
+
"Can not get libraries",
|
105
|
+
response
|
106
|
+
)
|
107
|
+
}
|
108
|
+
|
109
|
+
// parse libraries from the server's response
|
110
|
+
const libraries = (await response!.json()) as LibraryResponse
|
111
|
+
|
112
|
+
return libraries.libraries
|
113
|
+
}
|
114
|
+
|
115
|
+
async deleteOrgFromLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void> {
|
116
|
+
if (libraryId === undefined || libraryId === null) {
|
117
|
+
throw new Error("Organization delete from library, libraryId is undefined or null")
|
118
|
+
}
|
119
|
+
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
120
|
+
throw new Error("Organization delete from library, libraryId is empty")
|
121
|
+
}
|
122
|
+
if (organizationId === undefined || organizationId === null) {
|
123
|
+
throw new Error("Organization delete from library, organizationId is undefined or null")
|
124
|
+
}
|
125
|
+
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
126
|
+
throw new Error("Organization delete from library, organizationId is empty")
|
127
|
+
}
|
128
|
+
|
129
|
+
// send request to the server
|
130
|
+
const response = await this.context
|
131
|
+
.resolve(RpcService)
|
132
|
+
?.requestBuilder("api/v1/libraries/management/allowed/organization")
|
133
|
+
.searchParam("libraryId", libraryId)
|
134
|
+
.searchParam("organizationId", organizationId)
|
135
|
+
.sendDelete()
|
136
|
+
|
137
|
+
// check response status
|
138
|
+
if (ResponseUtils.isFail(response)) {
|
139
|
+
await ResponseUtils.throwError(
|
140
|
+
`Organization ${organizationId} delete from library ${libraryId}, failed`,
|
141
|
+
response
|
142
|
+
)
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
async deleteLibrary(libraryId: LibraryId): Promise<void> {
|
147
|
+
if (libraryId === undefined || libraryId === null) {
|
148
|
+
throw new Error("Library delete, libraryId is undefined or null")
|
149
|
+
}
|
150
|
+
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
151
|
+
throw new Error("Library delete, libraryId is empty")
|
152
|
+
}
|
153
|
+
|
154
|
+
// send request to the server
|
155
|
+
const response = await this.context
|
156
|
+
.resolve(RpcService)
|
157
|
+
?.requestBuilder("api/v1/libraries/management")
|
158
|
+
.searchParam("libraryId", libraryId)
|
159
|
+
.sendDelete()
|
160
|
+
|
161
|
+
// check response status
|
162
|
+
if (ResponseUtils.isFail(response)) {
|
163
|
+
await ResponseUtils.throwError(
|
164
|
+
`Library ${libraryId} delete, failed`,
|
165
|
+
response
|
166
|
+
)
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { LibraryId } from "../library/libraryId"
|
2
|
+
import { OrganizationId } from "../organizations/organizations"
|
3
|
+
import { LibraryDto } from "../../dto/libraryResponse"
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Library management, you must have permissions to manage libraries
|
7
|
+
*/
|
8
|
+
export abstract class LibraryAdministration {
|
9
|
+
/**
|
10
|
+
* Create a new library
|
11
|
+
*/
|
12
|
+
abstract createLibrary(name: string, description: string, region: number, isPublic: boolean): Promise<LibraryId>
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Add permission for an organization to share its data through the library
|
16
|
+
*/
|
17
|
+
abstract addOrgToLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Get all libraries
|
21
|
+
*/
|
22
|
+
abstract getLibraries(): Promise<LibraryDto[]>
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Delete permission for an organization to share its data through the library
|
26
|
+
*/
|
27
|
+
abstract deleteOrgFromLibrary(libraryId: LibraryId, organizationId: OrganizationId): Promise<void>
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Delete a library by id
|
31
|
+
*/
|
32
|
+
abstract deleteLibrary(libraryId: LibraryId): Promise<void>
|
33
|
+
}
|