@neuralinnovations/dataisland-sdk 0.2.1 → 0.4.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/credentials.d.ts +9 -8
- package/dist/src/credentials.d.ts.map +1 -1
- package/dist/src/credentials.js +8 -4
- package/dist/src/credentials.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/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/credentials.ts +18 -12
- 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,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.LibraryAdministration = void 0;
|
4
|
+
/**
|
5
|
+
* Library management, you must have permissions to manage libraries
|
6
|
+
*/
|
7
|
+
class LibraryAdministration {
|
8
|
+
}
|
9
|
+
exports.LibraryAdministration = LibraryAdministration;
|
10
|
+
//# sourceMappingURL=library.administration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"library.administration.js","sourceRoot":"","sources":["../../../../src/storages/administration/library.administration.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,MAAsB,qBAAqB;CAyB1C;AAzBD,sDAyBC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { OrganizationId } from "../organizations/organizations";
|
2
|
+
import { OrganizationMembersStatisticResponse, OrganizationStatisticResponse } from "../../dto/administration";
|
3
|
+
/**
|
4
|
+
* Statistic management, you must have permissions to manage statistics
|
5
|
+
*/
|
6
|
+
export declare abstract class StatisticAdministration {
|
7
|
+
/**
|
8
|
+
* Get organization statistics
|
9
|
+
*/
|
10
|
+
abstract getOrganizations(dateFrom: number, dateTo: number): Promise<OrganizationStatisticResponse>;
|
11
|
+
/**
|
12
|
+
* Get organization members statistics
|
13
|
+
*/
|
14
|
+
abstract getOrganizationMembers(organizationId: OrganizationId, dateFrom: number, dateTo: number): Promise<OrganizationMembersStatisticResponse>;
|
15
|
+
}
|
16
|
+
//# sourceMappingURL=statistics.administration.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statistics.administration.d.ts","sourceRoot":"","sources":["../../../../src/storages/administration/statistics.administration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC9B,MAAM,0BAA0B,CAAA;AAEjC;;GAEG;AACH,8BAAsB,uBAAuB;IAE3C;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAEnG;;OAEG;IACH,QAAQ,CAAC,sBAAsB,CAAC,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oCAAoC,CAAC;CACjJ"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { StatisticAdministration } from "./statistics.administration";
|
2
|
+
import { OrganizationMembersStatisticResponse, OrganizationStatisticResponse } from "../../dto/administration";
|
3
|
+
import { OrganizationId } from "../organizations/organizations";
|
4
|
+
import { Context } from "../../context";
|
5
|
+
export declare class StatisticAdministrationImpl implements StatisticAdministration {
|
6
|
+
private readonly context;
|
7
|
+
constructor(context: Context);
|
8
|
+
getOrganizationMembers(organizationId: OrganizationId, dateFrom: number, dateTo: number): Promise<OrganizationMembersStatisticResponse>;
|
9
|
+
getOrganizations(dateFrom: number, dateTo: number): Promise<OrganizationStatisticResponse>;
|
10
|
+
}
|
11
|
+
//# sourceMappingURL=statistics.administration.impl.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statistics.administration.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/administration/statistics.administration.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAGrE,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC9B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,qBAAa,2BAA4B,YAAW,uBAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAGvC,sBAAsB,CAC1B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oCAAoC,CAAC;IAiB1C,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;CAejG"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.StatisticAdministrationImpl = void 0;
|
4
|
+
const rpcService_1 = require("../../services/rpcService");
|
5
|
+
const responseUtils_1 = require("../../services/responseUtils");
|
6
|
+
class StatisticAdministrationImpl {
|
7
|
+
constructor(context) {
|
8
|
+
this.context = context;
|
9
|
+
}
|
10
|
+
async getOrganizationMembers(organizationId, dateFrom, dateTo) {
|
11
|
+
var _a;
|
12
|
+
const response = await ((_a = this.context
|
13
|
+
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Stats/internal/organization/members/total").searchParam("organizationId", organizationId).searchParam("dateFrom", dateFrom.toString()).searchParam("dateTo", dateTo.toString()).sendGet());
|
14
|
+
// check response status
|
15
|
+
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
16
|
+
await responseUtils_1.ResponseUtils.throwError("Failed to get statistics", response);
|
17
|
+
}
|
18
|
+
return await response.json();
|
19
|
+
}
|
20
|
+
async getOrganizations(dateFrom, dateTo) {
|
21
|
+
var _a;
|
22
|
+
const response = await ((_a = this.context
|
23
|
+
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("/api/v1/Stats/internal/organizations").searchParam("dateFrom", dateFrom.toString()).searchParam("dateTo", dateTo.toString()).sendGet());
|
24
|
+
// check response status
|
25
|
+
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
26
|
+
await responseUtils_1.ResponseUtils.throwError("Failed to get statistics", response);
|
27
|
+
}
|
28
|
+
return await response.json();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
exports.StatisticAdministrationImpl = StatisticAdministrationImpl;
|
32
|
+
//# sourceMappingURL=statistics.administration.impl.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statistics.administration.impl.js","sourceRoot":"","sources":["../../../../src/storages/administration/statistics.administration.impl.ts"],"names":[],"mappings":";;;AACA,0DAAsD;AACtD,gEAA4D;AAQ5D,MAAa,2BAA2B;IACtC,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAC7C,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,cAA8B,EAC9B,QAAgB,EAChB,MAAc;;QAEd,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,kDAAkD,EAClE,WAAW,CAAC,gBAAgB,EAAE,cAAc,EAC5C,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAC3C,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EACvC,OAAO,EAAE,CAAA,CAAA;QAEZ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA;QACtE,CAAC;QAED,OAAO,MAAM,QAAS,CAAC,IAAI,EAA0C,CAAA;IACvE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAgB,EAAE,MAAc;;QACrD,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO;aAChC,OAAO,CAAC,uBAAU,CAAC,0CAClB,cAAc,CAAC,sCAAsC,EACtD,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAC3C,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EACvC,OAAO,EAAE,CAAA,CAAA;QAEZ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA;QACtE,CAAC;QAED,OAAO,MAAM,QAAS,CAAC,IAAI,EAAmC,CAAA;IAChE,CAAC;CACF;AAxCD,kEAwCC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.StatisticAdministration = void 0;
|
4
|
+
/**
|
5
|
+
* Statistic management, you must have permissions to manage statistics
|
6
|
+
*/
|
7
|
+
class StatisticAdministration {
|
8
|
+
}
|
9
|
+
exports.StatisticAdministration = StatisticAdministration;
|
10
|
+
//# sourceMappingURL=statistics.administration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statistics.administration.js","sourceRoot":"","sources":["../../../../src/storages/administration/statistics.administration.ts"],"names":[],"mappings":";;;AAMA;;GAEG;AACH,MAAsB,uBAAuB;CAW5C;AAXD,0DAWC"}
|
@@ -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, description: 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, description: 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,127 +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, description, 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 (description === undefined ||
|
21
|
-
description === null ||
|
22
|
-
description.trim() === "") {
|
23
|
-
throw new Error("Description for library is required, must be not empty");
|
24
|
-
}
|
25
|
-
if (isPublic === undefined ||
|
26
|
-
isPublic === null) {
|
27
|
-
throw new Error("IsPublic is required, must be not empty");
|
28
|
-
}
|
29
|
-
// send create request to the server
|
30
|
-
const response = await ((_a = this.context
|
31
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management").sendPostJson({
|
32
|
-
name: name,
|
33
|
-
description: description,
|
34
|
-
region: region,
|
35
|
-
isPublic: isPublic
|
36
|
-
}));
|
37
|
-
// check response status
|
38
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
39
|
-
await responseUtils_1.ResponseUtils.throwError(`Failed to create library ${name}`, response);
|
40
|
-
}
|
41
|
-
const library = (await response.json());
|
42
|
-
return library.libraryId;
|
43
|
-
}
|
44
|
-
async addOrgToLibrary(libraryId, organizationId) {
|
45
|
-
var _a;
|
46
|
-
if (libraryId === undefined || libraryId === null) {
|
47
|
-
throw new Error("Organization add to library, libraryId is undefined or null");
|
48
|
-
}
|
49
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
50
|
-
throw new Error("Organization add to from library, libraryId is empty");
|
51
|
-
}
|
52
|
-
if (organizationId === undefined || organizationId === null) {
|
53
|
-
throw new Error("Organization add to from library, organizationId is undefined or null");
|
54
|
-
}
|
55
|
-
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
56
|
-
throw new Error("Organization add to from library, organizationId is empty");
|
57
|
-
}
|
58
|
-
const response = await ((_a = this.context
|
59
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management/allowed/organization").sendPutJson({
|
60
|
-
libraryId: libraryId,
|
61
|
-
organizationId: organizationId
|
62
|
-
}));
|
63
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
64
|
-
await responseUtils_1.ResponseUtils.throwError(`Organization ${organizationId} add to library ${libraryId} failed`, response);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
async getLibraries() {
|
68
|
-
var _a;
|
69
|
-
const response = await ((_a = this.context
|
70
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management/allowed/organizations").sendGet());
|
71
|
-
// check response status
|
72
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
73
|
-
await responseUtils_1.ResponseUtils.throwError("Can not get libraries", response);
|
74
|
-
}
|
75
|
-
// parse libraries from the server's response
|
76
|
-
const libraries = (await response.json());
|
77
|
-
return libraries.libraries;
|
78
|
-
}
|
79
|
-
async deleteOrgFromLibrary(libraryId, organizationId) {
|
80
|
-
var _a;
|
81
|
-
if (libraryId === undefined || libraryId === null) {
|
82
|
-
throw new Error("Organization delete from library, libraryId is undefined or null");
|
83
|
-
}
|
84
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
85
|
-
throw new Error("Organization delete from library, libraryId is empty");
|
86
|
-
}
|
87
|
-
if (organizationId === undefined || organizationId === null) {
|
88
|
-
throw new Error("Organization delete from library, organizationId is undefined or null");
|
89
|
-
}
|
90
|
-
if (organizationId.length === 0 || organizationId.trim().length === 0) {
|
91
|
-
throw new Error("Organization delete from library, organizationId is empty");
|
92
|
-
}
|
93
|
-
// send request to the server
|
94
|
-
const response = await ((_a = this.context
|
95
|
-
.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());
|
96
|
-
// check response status
|
97
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
98
|
-
await responseUtils_1.ResponseUtils.throwError(`Organization ${organizationId} delete from library ${libraryId}, failed`, response);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
async deleteLibrary(libraryId) {
|
102
|
-
var _a;
|
103
|
-
if (libraryId === undefined || libraryId === null) {
|
104
|
-
throw new Error("Library delete, libraryId is undefined or null");
|
105
|
-
}
|
106
|
-
if (libraryId.length === 0 || libraryId.trim().length === 0) {
|
107
|
-
throw new Error("Library delete, libraryId is empty");
|
108
|
-
}
|
109
|
-
// send request to the server
|
110
|
-
const response = await ((_a = this.context
|
111
|
-
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/libraries/management").searchParam("libraryId", libraryId).sendDelete());
|
112
|
-
// check response status
|
113
|
-
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
114
|
-
await responseUtils_1.ResponseUtils.throwError(`Library ${libraryId} delete, failed`, response);
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
exports.LibraryManagementImpl = LibraryManagementImpl;
|
119
8
|
class LibrariesImpl extends libraries_1.Libraries {
|
120
9
|
constructor(context) {
|
121
10
|
super();
|
122
11
|
this.context = context;
|
123
12
|
this._libraries = [];
|
124
|
-
this._management = new LibraryManagementImpl(context);
|
125
13
|
}
|
126
14
|
async initialize() {
|
127
15
|
var _a;
|
@@ -147,9 +35,6 @@ class LibrariesImpl extends libraries_1.Libraries {
|
|
147
35
|
getLibraryById(libraryId) {
|
148
36
|
return this._libraries.find((library) => library.id === libraryId);
|
149
37
|
}
|
150
|
-
get management() {
|
151
|
-
return this._management;
|
152
|
-
}
|
153
38
|
}
|
154
39
|
exports.LibrariesImpl = LibrariesImpl;
|
155
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/credentials.ts
CHANGED
@@ -16,6 +16,8 @@ export class DefaultCredential extends CredentialBase {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
19
|
+
export type TokenProvider = (req: Request) => Promise<string>;
|
20
|
+
|
19
21
|
export class BasicCredential extends CredentialBase {
|
20
22
|
readonly email: string
|
21
23
|
readonly password: string
|
@@ -41,9 +43,9 @@ export class BasicCredential extends CredentialBase {
|
|
41
43
|
}
|
42
44
|
|
43
45
|
export class DebugCredential extends CredentialBase {
|
44
|
-
readonly token: string
|
46
|
+
readonly token: string | TokenProvider
|
45
47
|
|
46
|
-
constructor(token: string) {
|
48
|
+
constructor(token: string | TokenProvider) {
|
47
49
|
super()
|
48
50
|
this.token = token
|
49
51
|
}
|
@@ -55,7 +57,8 @@ export class DebugCredential extends CredentialBase {
|
|
55
57
|
}
|
56
58
|
lifetime.add(
|
57
59
|
service.useMiddleware(async (req, next) => {
|
58
|
-
|
60
|
+
const currenToken = typeof this.token === "function" ? await this.token(req) : this.token
|
61
|
+
req.headers.set("Authorization", `Debug ${currenToken}`)
|
59
62
|
return await next(req)
|
60
63
|
})
|
61
64
|
)
|
@@ -63,9 +66,9 @@ export class DebugCredential extends CredentialBase {
|
|
63
66
|
}
|
64
67
|
|
65
68
|
export class BearerCredential extends CredentialBase {
|
66
|
-
readonly token: string
|
69
|
+
readonly token: string | TokenProvider
|
67
70
|
|
68
|
-
constructor(token: string) {
|
71
|
+
constructor(token: string | TokenProvider) {
|
69
72
|
super()
|
70
73
|
this.token = token
|
71
74
|
}
|
@@ -77,7 +80,8 @@ export class BearerCredential extends CredentialBase {
|
|
77
80
|
}
|
78
81
|
lifetime.add(
|
79
82
|
service.useMiddleware(async (req, next) => {
|
80
|
-
|
83
|
+
const currenToken = typeof this.token === "function" ? await this.token(req) : this.token
|
84
|
+
req.headers.set("Authorization", `Bearer ${currenToken}`)
|
81
85
|
return await next(req)
|
82
86
|
})
|
83
87
|
)
|
@@ -85,9 +89,9 @@ export class BearerCredential extends CredentialBase {
|
|
85
89
|
}
|
86
90
|
|
87
91
|
export class AnonymousCredential extends CredentialBase {
|
88
|
-
readonly token: string
|
92
|
+
readonly token: string | TokenProvider
|
89
93
|
|
90
|
-
constructor(token: string) {
|
94
|
+
constructor(token: string | TokenProvider) {
|
91
95
|
super()
|
92
96
|
this.token = token
|
93
97
|
}
|
@@ -99,7 +103,8 @@ export class AnonymousCredential extends CredentialBase {
|
|
99
103
|
}
|
100
104
|
lifetime.add(
|
101
105
|
service.useMiddleware(async (req, next) => {
|
102
|
-
|
106
|
+
const currenToken = typeof this.token === "function" ? await this.token(req) : this.token
|
107
|
+
req.headers.set("Authorization", `InternalJWT ${currenToken}`)
|
103
108
|
return await next(req)
|
104
109
|
})
|
105
110
|
)
|
@@ -108,9 +113,9 @@ export class AnonymousCredential extends CredentialBase {
|
|
108
113
|
|
109
114
|
export class CustomCredential extends CredentialBase {
|
110
115
|
readonly schema: string
|
111
|
-
readonly token: string
|
116
|
+
readonly token: string | TokenProvider
|
112
117
|
|
113
|
-
constructor(schema: string, token: string) {
|
118
|
+
constructor(schema: string, token: string | TokenProvider) {
|
114
119
|
super()
|
115
120
|
this.token = token
|
116
121
|
this.schema = schema
|
@@ -123,7 +128,8 @@ export class CustomCredential extends CredentialBase {
|
|
123
128
|
}
|
124
129
|
lifetime.add(
|
125
130
|
service.useMiddleware(async (req, next) => {
|
126
|
-
|
131
|
+
const currenToken = typeof this.token === "function" ? await this.token(req) : this.token
|
132
|
+
req.headers.set("Authorization", `${this.schema} ${currenToken}`)
|
127
133
|
return await next(req)
|
128
134
|
})
|
129
135
|
)
|
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
|
+
membersStats: 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
|
+
}
|