accounting-tools 1.0.1
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 +2 -0
- package/dist/api/ExpressLogableConfig.d.ts +5 -0
- package/dist/api/ExpressLogableConfig.js +18 -0
- package/dist/api/ExpressLogableConfig.js.map +1 -0
- package/dist/api/checkers/RoleServicePermissionsChecker.d.ts +13 -0
- package/dist/api/checkers/RoleServicePermissionsChecker.js +92 -0
- package/dist/api/checkers/RoleServicePermissionsChecker.js.map +1 -0
- package/dist/api/checkers/ServiceSessionChecker.d.ts +28 -0
- package/dist/api/checkers/ServiceSessionChecker.js +119 -0
- package/dist/api/checkers/ServiceSessionChecker.js.map +1 -0
- package/dist/api/external/CetusApiManager.d.ts +0 -0
- package/dist/api/external/CetusApiManager.js +2 -0
- package/dist/api/external/CetusApiManager.js.map +1 -0
- package/dist/crud/ActivityHistoryManager.d.ts +40 -0
- package/dist/crud/ActivityHistoryManager.js +86 -0
- package/dist/crud/ActivityHistoryManager.js.map +1 -0
- package/dist/crud/AvailablePlatformManager.d.ts +37 -0
- package/dist/crud/AvailablePlatformManager.js +84 -0
- package/dist/crud/AvailablePlatformManager.js.map +1 -0
- package/dist/crud/ComponentManager.d.ts +53 -0
- package/dist/crud/ComponentManager.js +75 -0
- package/dist/crud/ComponentManager.js.map +1 -0
- package/dist/crud/KeyManager.d.ts +39 -0
- package/dist/crud/KeyManager.js +88 -0
- package/dist/crud/KeyManager.js.map +1 -0
- package/dist/crud/PlatformManager.d.ts +42 -0
- package/dist/crud/PlatformManager.js +72 -0
- package/dist/crud/PlatformManager.js.map +1 -0
- package/dist/crud/RoleManager.d.ts +52 -0
- package/dist/crud/RoleManager.js +72 -0
- package/dist/crud/RoleManager.js.map +1 -0
- package/dist/crud/StatusManager.d.ts +34 -0
- package/dist/crud/StatusManager.js +74 -0
- package/dist/crud/StatusManager.js.map +1 -0
- package/dist/crud/TypeManager.d.ts +33 -0
- package/dist/crud/TypeManager.js +76 -0
- package/dist/crud/TypeManager.js.map +1 -0
- package/dist/crud/UserCredentialsManager.d.ts +39 -0
- package/dist/crud/UserCredentialsManager.js +84 -0
- package/dist/crud/UserCredentialsManager.js.map +1 -0
- package/dist/crud/UserManager.d.ts +35 -0
- package/dist/crud/UserManager.js +80 -0
- package/dist/crud/UserManager.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ExpressLogableConfig = void 0;
|
|
7
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
8
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
9
|
+
class ExpressLogableConfig extends itrm_tools_1.ExpressStandardConfiguration {
|
|
10
|
+
apply(app) {
|
|
11
|
+
// Apply standard configuration from parent class
|
|
12
|
+
super.apply(app);
|
|
13
|
+
// Add morgan logging middleware with following format
|
|
14
|
+
app.use((0, morgan_1.default)(':remote-addr - :remote-user [:date[web]] ":method :url HTTP/:http-version" :status :res[content-length]'));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ExpressLogableConfig = ExpressLogableConfig;
|
|
18
|
+
//# sourceMappingURL=ExpressLogableConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressLogableConfig.js","sourceRoot":"","sources":["../../src/api/ExpressLogableConfig.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA0D;AAE1D,oDAA4B;AAE5B,MAAa,oBAAqB,SAAQ,yCAA4B;IACpE,KAAK,CAAC,GAAY;QAChB,iDAAiD;QACjD,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,sDAAsD;QACtD,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,EAAC,yGAAyG,CAAC,CAAC,CAAC;IAC7H,CAAC;CACF;AAPD,oDAOC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APICheck, APICheckConfig, APICheckResult } from "itrm-tools";
|
|
2
|
+
import { Request } from "express";
|
|
3
|
+
export declare class RoleServicePermissionsChecker implements APICheck {
|
|
4
|
+
private service;
|
|
5
|
+
private sessionServiceUrl;
|
|
6
|
+
private roleManager;
|
|
7
|
+
constructor(service: string, sessionServiceUrl: string, sessionServiceCrud: string);
|
|
8
|
+
getConfig(): APICheckConfig;
|
|
9
|
+
apply(config: APICheckConfig, req: Request): Promise<APICheckResult>;
|
|
10
|
+
private checkServicePermissions;
|
|
11
|
+
private isMethodAndPathAllowed;
|
|
12
|
+
private unexpectedErrorRejection;
|
|
13
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RoleServicePermissionsChecker = void 0;
|
|
13
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
+
const RoleManager_1 = require("../../crud/RoleManager");
|
|
15
|
+
class RoleServicePermissionsChecker {
|
|
16
|
+
constructor(service, sessionServiceUrl, sessionServiceCrud) {
|
|
17
|
+
this.service = service;
|
|
18
|
+
this.sessionServiceUrl = sessionServiceUrl;
|
|
19
|
+
this.roleManager = new RoleManager_1.RoleManager(`${sessionServiceCrud}/v1`);
|
|
20
|
+
}
|
|
21
|
+
getConfig() {
|
|
22
|
+
return {
|
|
23
|
+
check: "rolePermissionService",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
apply(config, req) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
try {
|
|
30
|
+
const { platform } = req.headers;
|
|
31
|
+
let headers = {
|
|
32
|
+
headers: {
|
|
33
|
+
"Authorization": req.headers.authorization,
|
|
34
|
+
"platform": platform
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// Verify the JWT and platform with the session service
|
|
38
|
+
let verification = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/v1/verify`, { jwt: ((_a = req.headers.authorization) !== null && _a !== void 0 ? _a : 'NoToken').replace("Bearer ", ""), platform: platform }, headers);
|
|
39
|
+
// Fetch the service role
|
|
40
|
+
let role = yield this.roleManager.find({ name: verification === null || verification === void 0 ? void 0 : verification.role, config: headers });
|
|
41
|
+
// Check if the service and endpoint are allowed
|
|
42
|
+
return this.checkServicePermissions((_c = (_b = role === null || role === void 0 ? void 0 : role.permissions) === null || _b === void 0 ? void 0 : _b.services) !== null && _c !== void 0 ? _c : {}, req, verification);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return this.unexpectedErrorRejection(error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// Checks if the requested service, method, and path are allowed for the user's role.
|
|
50
|
+
checkServicePermissions(permissions, req, verification) {
|
|
51
|
+
if (permissions[this.service]) {
|
|
52
|
+
if (this.isMethodAndPathAllowed(permissions[this.service], req))
|
|
53
|
+
return { approved: true, payload: verification };
|
|
54
|
+
return {
|
|
55
|
+
approved: false,
|
|
56
|
+
rejection: {
|
|
57
|
+
code: 401,
|
|
58
|
+
payload: {
|
|
59
|
+
status: "Error",
|
|
60
|
+
message: `Method or Path are not allowed: ${req.method} ${req.baseUrl + req.path.replace(/\/\d+$/, "")}`
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
approved: false,
|
|
67
|
+
rejection: {
|
|
68
|
+
code: 401,
|
|
69
|
+
payload: {
|
|
70
|
+
status: "Error",
|
|
71
|
+
message: `Service is not allowed: ${this.service}`
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//Checks if the HTTP method and path are allowed in the permissions object.
|
|
77
|
+
isMethodAndPathAllowed(permissions, req) {
|
|
78
|
+
return permissions[req.method] && permissions[req.method][req.baseUrl + req.path.replace(/\/\d+$/, "")];
|
|
79
|
+
}
|
|
80
|
+
unexpectedErrorRejection(error) {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
return {
|
|
83
|
+
approved: false,
|
|
84
|
+
rejection: {
|
|
85
|
+
code: (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 500,
|
|
86
|
+
payload: { status: "Error", message: (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : error }
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.RoleServicePermissionsChecker = RoleServicePermissionsChecker;
|
|
92
|
+
//# sourceMappingURL=RoleServicePermissionsChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoleServicePermissionsChecker.js","sourceRoot":"","sources":["../../../src/api/checkers/RoleServicePermissionsChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA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,CAAC,KAAU;;QACzC,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE;gBACT,IAAI,EAAE,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,MAAM,mCAAI,GAAG;gBACpC,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,mCAAI,KAAK,EAAE;aACtE;SACF,CAAC;IACJ,CAAC;CACF;AApFD,sEAoFC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
import { APICheck, APICheckConfig, APICheckResult } from "itrm-tools";
|
|
3
|
+
export interface IServiceSessionConfig {
|
|
4
|
+
name: string;
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IServiceCredentials {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
apiSecret: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ServiceSessionChecker implements APICheck {
|
|
12
|
+
private token;
|
|
13
|
+
private readonly sessionServiceUrl;
|
|
14
|
+
private readonly config;
|
|
15
|
+
constructor(sessionServiceUrl: string, config: IServiceSessionConfig);
|
|
16
|
+
getConfig(): APICheckConfig;
|
|
17
|
+
apply(config: APICheckConfig, req: Request): Promise<APICheckResult>;
|
|
18
|
+
private createToken;
|
|
19
|
+
sign(params: {
|
|
20
|
+
method: string;
|
|
21
|
+
path: string;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: string;
|
|
25
|
+
};
|
|
26
|
+
} | undefined>;
|
|
27
|
+
private getServiceCredentials;
|
|
28
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ServiceSessionChecker = void 0;
|
|
13
|
+
const crypto_js_1 = require("crypto-js");
|
|
14
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
15
|
+
class ServiceSessionChecker {
|
|
16
|
+
constructor(sessionServiceUrl, config) {
|
|
17
|
+
this.token = "";
|
|
18
|
+
this.sessionServiceUrl = sessionServiceUrl;
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
getConfig() {
|
|
22
|
+
return {
|
|
23
|
+
check: "serviceSession"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
apply(config, req) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a;
|
|
29
|
+
try {
|
|
30
|
+
// Verifies the session token by calling the session service, if it exists approve the request else create new token
|
|
31
|
+
const verification = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/v1/verify`, {
|
|
32
|
+
jwt: ((_a = req.headers.authorization) !== null && _a !== void 0 ? _a : 'NoToken').replace("Bearer ", ""),
|
|
33
|
+
platform: req.headers.platform
|
|
34
|
+
}, {
|
|
35
|
+
headers: { "Authorization": this.token }
|
|
36
|
+
});
|
|
37
|
+
console.log("> verification:", verification);
|
|
38
|
+
return {
|
|
39
|
+
approved: true,
|
|
40
|
+
payload: { headers: { "Authorization": this.token } }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
// If verification fails, create a new token
|
|
45
|
+
return yield this.createToken();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// Generate a new session token
|
|
50
|
+
createToken() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var _a, _b, _c, _d, _e;
|
|
53
|
+
try {
|
|
54
|
+
const headers = yield this.sign({ method: "POST", path: "/login" });
|
|
55
|
+
if (headers) {
|
|
56
|
+
// Call the session service to create a new session
|
|
57
|
+
const session = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/service/login`, { service: this.config.name }, headers);
|
|
58
|
+
// Store the new token
|
|
59
|
+
this.token = (_c = (_b = (_a = session === null || session === void 0 ? void 0 : session.token) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.jwt) !== null && _c !== void 0 ? _c : "";
|
|
60
|
+
return {
|
|
61
|
+
approved: true,
|
|
62
|
+
payload: { headers: { "Authorization": this.token } }
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// If headers are not available, return an error
|
|
66
|
+
return {
|
|
67
|
+
approved: false,
|
|
68
|
+
rejection: {
|
|
69
|
+
code: 500,
|
|
70
|
+
payload: { status: 'Error', message: 'Public API is not available' }
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
// Handle any errors that occur during token creation
|
|
76
|
+
return {
|
|
77
|
+
approved: false,
|
|
78
|
+
rejection: {
|
|
79
|
+
code: 401,
|
|
80
|
+
payload: (_e = (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.data) !== null && _e !== void 0 ? _e : err
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// Sign the request with HMAC, if successful return headers else return undefined
|
|
87
|
+
sign(params) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const { method, path } = params;
|
|
90
|
+
let nonce = Date.now();
|
|
91
|
+
let message = `${nonce}${method}${path}${this.config.name ? JSON.stringify(this.config.name) : ""}`;
|
|
92
|
+
const credentials = yield this.getServiceCredentials();
|
|
93
|
+
if (credentials) {
|
|
94
|
+
const hash = (0, crypto_js_1.HmacSHA256)(message, credentials.apiSecret);
|
|
95
|
+
let signature = crypto_js_1.enc.Hex.stringify(hash);
|
|
96
|
+
return {
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: `${credentials.apiKey}:${nonce}:${signature}`,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Get service credentials
|
|
106
|
+
getServiceCredentials() {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
try {
|
|
109
|
+
const credentials = yield itrm_tools_1.RequestAxiosCall.get(`${this.sessionServiceUrl}/service/credentials?service=${this.config.name}`, { headers: { referer: this.config.url } });
|
|
110
|
+
return credentials.payload;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.ServiceSessionChecker = ServiceSessionChecker;
|
|
119
|
+
//# sourceMappingURL=ServiceSessionChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceSessionChecker.js","sourceRoot":"","sources":["../../../src/api/checkers/ServiceSessionChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA4C;AAE5C,2CAAwF;AAYxF,MAAa,qBAAqB;IAKhC,YAAY,iBAAyB,EAAE,MAA6B;QAJ5D,UAAK,GAAW,EAAE,CAAC;QAKzB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,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AE,CAAC;gBAChB,MAAM,IAAI,GAAG,IAAA,sBAAU,EAAC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;gBACxD,IAAI,SAAS,GAAG,eAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACxC,OAAO;oBACL,OAAO,EAAE;wBACP,aAAa,EAAE,GAAG,WAAW,CAAC,MAAM,IAAI,KAAK,IAAI,SAAS,EAAE;qBAC7D;iBACF,CAAC;YACJ,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;IAED,0BAA0B;IACZ,qBAAqB;;YACjC,IAAI,CAAC;gBACH,MAAM,WAAW,GAAQ,MAAM,6BAAgB,CAAC,GAAG,CACjD,GAAG,IAAI,CAAC,iBAAiB,gCAAgC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAC3E,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAC1C,CAAC;gBACF,OAAO,WAAW,CAAC,OAAO,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;CACF;AAvGD,sDAuGC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CetusApiManager.js","sourceRoot":"","sources":["../../../src/api/external/CetusApiManager.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
|
|
2
|
+
import { AxiosRequestConfig } from "axios";
|
|
3
|
+
export interface IActivityHistory {
|
|
4
|
+
activityHistoryId?: number;
|
|
5
|
+
userId?: number;
|
|
6
|
+
platformId?: number;
|
|
7
|
+
roleId?: number;
|
|
8
|
+
typeId?: number;
|
|
9
|
+
details?: any;
|
|
10
|
+
updatedAt?: string;
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
config?: AxiosRequestConfig;
|
|
13
|
+
}
|
|
14
|
+
export interface IActivityHistoryDetails {
|
|
15
|
+
activityHistoryId?: number;
|
|
16
|
+
userId?: number;
|
|
17
|
+
platformId?: number | string;
|
|
18
|
+
roleId?: number;
|
|
19
|
+
typeId?: number | string;
|
|
20
|
+
details?: any;
|
|
21
|
+
values?: IActivityHistory[];
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
config?: AxiosRequestConfig;
|
|
25
|
+
}
|
|
26
|
+
export declare class ActivityHistoryManager extends CrudServiceManager<IActivityHistoryDetails, IActivityHistory> {
|
|
27
|
+
private url;
|
|
28
|
+
constructor(url: string);
|
|
29
|
+
find(details: IActivityHistoryDetails): Promise<IActivityHistory | undefined>;
|
|
30
|
+
count(details: IActivityHistoryDetails): Promise<{
|
|
31
|
+
result: number;
|
|
32
|
+
}>;
|
|
33
|
+
findAll(details: IActivityHistoryDetails): Promise<IActivityHistory[] | undefined>;
|
|
34
|
+
private buildRequestUrl;
|
|
35
|
+
findById(id: StandardIdRequestDefinition): Promise<IActivityHistory | undefined>;
|
|
36
|
+
create(details: IActivityHistoryDetails): Promise<IActivityHistory | undefined>;
|
|
37
|
+
createMany(details: IActivityHistoryDetails): Promise<IActivityHistory[] | undefined>;
|
|
38
|
+
modify(activityHistory: IActivityHistory): Promise<any>;
|
|
39
|
+
destroy(activityHistory: IActivityHistory): Promise<any>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ActivityHistoryManager = void 0;
|
|
13
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
+
class ActivityHistoryManager extends itrm_tools_1.CrudServiceManager {
|
|
15
|
+
constructor(url) {
|
|
16
|
+
super();
|
|
17
|
+
this.url = url;
|
|
18
|
+
}
|
|
19
|
+
find(details) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return this.sendFinding(`${this.url}/activityHistory?userId=${details.userId}&credentials=true`, details.config);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
count(details) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
let url = this.buildRequestUrl(`${this.url}/activityHistory`, details);
|
|
28
|
+
return (_a = (yield this.sendCounting(url, details.config))) !== null && _a !== void 0 ? _a : { result: 0 };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
findAll(details) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a;
|
|
34
|
+
let activityHistory = [];
|
|
35
|
+
let url = this.buildRequestUrl(`${this.url}/activityHistory`, details);
|
|
36
|
+
if (details.limit) {
|
|
37
|
+
activityHistory = (_a = (yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config))) !== null && _a !== void 0 ? _a : [];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
let limit = 5000, offset = 0, isEmpty = false;
|
|
41
|
+
do {
|
|
42
|
+
let values = yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
43
|
+
if (values)
|
|
44
|
+
activityHistory = activityHistory.concat(values);
|
|
45
|
+
isEmpty = values == undefined || values.length == 0;
|
|
46
|
+
offset += limit;
|
|
47
|
+
} while (!isEmpty);
|
|
48
|
+
}
|
|
49
|
+
return activityHistory;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
buildRequestUrl(url, details) {
|
|
53
|
+
let suffix = `${details.typeId ? `&typeId=${details.typeId}` : ""}`;
|
|
54
|
+
return `${url}?${suffix.substring(1)}`;
|
|
55
|
+
}
|
|
56
|
+
findById(id) {
|
|
57
|
+
return this.sendFinding(`${this.url}/activityHistory?id=${id.id}&credentials=true`, id.config);
|
|
58
|
+
}
|
|
59
|
+
create(details) {
|
|
60
|
+
return this.sendCreation(`${this.url}/activityHistory`, {
|
|
61
|
+
userId: details.userId,
|
|
62
|
+
platformId: details.platformId,
|
|
63
|
+
roleId: details.roleId,
|
|
64
|
+
typeId: details.typeId,
|
|
65
|
+
details: details.details
|
|
66
|
+
}, details.config);
|
|
67
|
+
}
|
|
68
|
+
createMany(details) {
|
|
69
|
+
var _a;
|
|
70
|
+
return this.sendCreationMany(`${this.url}/activityHistory`, (_a = details.values) !== null && _a !== void 0 ? _a : [], details.config);
|
|
71
|
+
}
|
|
72
|
+
modify(activityHistory) {
|
|
73
|
+
return this.sendModification(`${this.url}/activityHistory/${activityHistory.activityHistoryId}`, {
|
|
74
|
+
userId: activityHistory.userId,
|
|
75
|
+
platformId: activityHistory.platformId,
|
|
76
|
+
roleId: activityHistory.roleId,
|
|
77
|
+
typeId: activityHistory.typeId,
|
|
78
|
+
details: activityHistory.details
|
|
79
|
+
}, activityHistory.config);
|
|
80
|
+
}
|
|
81
|
+
destroy(activityHistory) {
|
|
82
|
+
return this.sendDestruction(`${this.url}/activityHistory/${activityHistory.activityHistoryId}`, activityHistory.config);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.ActivityHistoryManager = ActivityHistoryManager;
|
|
86
|
+
//# sourceMappingURL=Activ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AE,OAAO,CAAC,MAAM;YACtB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;IAEM,UAAU,CAAC,OAAgC;;QAChD,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,kBAAkB,EAAE,MAAA,OAAO,CAAC,MAAM,mCAAI,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACpG,CAAC;IAEM,MAAM,CAAC,eAAiC;QAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,oBAAoB,eAAe,CAAC,iBAAiB,EAAE,EAAE;YAC/F,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,UAAU,EAAE,eAAe,CAAC,UAAU;YACtC,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,OAAO,EAAE,eAAe,CAAC,OAAO;SACjC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEM,OAAO,CAAC,eAAiC;QAC9C,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,GAAG,oBAAoB,eAAe,CAAC,iBAAiB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1H,CAAC;CACF;AAvED,wDAuEC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
|
|
2
|
+
import { AxiosRequestConfig } from "axios";
|
|
3
|
+
export interface IAvailablePlatform {
|
|
4
|
+
availablePlatformId?: number;
|
|
5
|
+
userId?: number;
|
|
6
|
+
roleId?: number;
|
|
7
|
+
platformId?: number;
|
|
8
|
+
restictions?: any;
|
|
9
|
+
updatedAt?: string;
|
|
10
|
+
createdAt?: string;
|
|
11
|
+
config?: AxiosRequestConfig;
|
|
12
|
+
}
|
|
13
|
+
export interface IAvailablePlatformSearchDetails {
|
|
14
|
+
userId?: number;
|
|
15
|
+
roleId?: number;
|
|
16
|
+
platformId?: number | string;
|
|
17
|
+
restictions?: any;
|
|
18
|
+
values?: IAvailablePlatform[];
|
|
19
|
+
limit?: number;
|
|
20
|
+
offset?: number;
|
|
21
|
+
config?: AxiosRequestConfig;
|
|
22
|
+
}
|
|
23
|
+
export declare class AvailablePlatformManager extends CrudServiceManager<IAvailablePlatformSearchDetails, IAvailablePlatform> {
|
|
24
|
+
private url;
|
|
25
|
+
constructor(url: string);
|
|
26
|
+
find(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform | undefined>;
|
|
27
|
+
count(details: IAvailablePlatformSearchDetails): Promise<{
|
|
28
|
+
result: number;
|
|
29
|
+
}>;
|
|
30
|
+
findAll(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform[] | undefined>;
|
|
31
|
+
private buildRequestUrl;
|
|
32
|
+
findById(id: StandardIdRequestDefinition): Promise<IAvailablePlatform | undefined>;
|
|
33
|
+
create(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform | undefined>;
|
|
34
|
+
createMany(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform[] | undefined>;
|
|
35
|
+
modify(availablePlatform: IAvailablePlatform): Promise<any>;
|
|
36
|
+
destroy(availablePlatforms: IAvailablePlatform): Promise<any>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AvailablePlatformManager = void 0;
|
|
13
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
+
class AvailablePlatformManager extends itrm_tools_1.CrudServiceManager {
|
|
15
|
+
constructor(url) {
|
|
16
|
+
super();
|
|
17
|
+
this.url = url;
|
|
18
|
+
}
|
|
19
|
+
find(details) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return this.sendFinding(`${this.url}/availablePlatforms?userId=${details.userId}`, details.config);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
count(details) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
let url = this.buildRequestUrl(`${this.url}/availablePlatforms`, details);
|
|
28
|
+
return (_a = (yield this.sendCounting(url, details.config))) !== null && _a !== void 0 ? _a : { result: 0 };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
findAll(details) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a;
|
|
34
|
+
let availablePlatforms = [];
|
|
35
|
+
let url = this.buildRequestUrl(`${this.url}/availablePlatforms`, details);
|
|
36
|
+
if (details.limit) {
|
|
37
|
+
availablePlatforms = (_a = (yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config))) !== null && _a !== void 0 ? _a : [];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
let limit = 5000, offset = 0, isEmpty = false;
|
|
41
|
+
do {
|
|
42
|
+
let values = yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
43
|
+
if (values)
|
|
44
|
+
availablePlatforms = availablePlatforms.concat(values);
|
|
45
|
+
isEmpty = values == undefined || values.length == 0;
|
|
46
|
+
offset += limit;
|
|
47
|
+
} while (!isEmpty);
|
|
48
|
+
}
|
|
49
|
+
return availablePlatforms;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
buildRequestUrl(url, details) {
|
|
53
|
+
let suffix = `${details.userId ? `&userId=${details.userId}` : ""}`;
|
|
54
|
+
return `${url}?${suffix.substring(1)}`;
|
|
55
|
+
}
|
|
56
|
+
findById(id) {
|
|
57
|
+
return this.sendFinding(`${this.url}/availablePlatforms?id=${id.id}`, id.config);
|
|
58
|
+
}
|
|
59
|
+
create(details) {
|
|
60
|
+
return this.sendCreation(`${this.url}/availablePlatforms`, {
|
|
61
|
+
userId: details.userId,
|
|
62
|
+
platformId: details.platformId,
|
|
63
|
+
roleId: details.roleId,
|
|
64
|
+
restictions: details.restictions
|
|
65
|
+
}, details.config);
|
|
66
|
+
}
|
|
67
|
+
createMany(details) {
|
|
68
|
+
var _a;
|
|
69
|
+
return this.sendCreationMany(`${this.url}/availablePlatforms`, (_a = details.values) !== null && _a !== void 0 ? _a : [], details.config);
|
|
70
|
+
}
|
|
71
|
+
modify(availablePlatform) {
|
|
72
|
+
return this.sendModification(`${this.url}/availablePlatforms/${availablePlatform.availablePlatformId}`, {
|
|
73
|
+
userId: availablePlatform.userId,
|
|
74
|
+
platformId: availablePlatform.platformId,
|
|
75
|
+
roleId: availablePlatform.roleId,
|
|
76
|
+
restictions: availablePlatform.restictions
|
|
77
|
+
}, availablePlatform.config);
|
|
78
|
+
}
|
|
79
|
+
destroy(availablePlatforms) {
|
|
80
|
+
return this.sendDestruction(`${this.url}/availablePlatforms/${availablePlatforms.availablePlatformId}`, availablePlatforms.config);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.AvailablePlatformManager = AvailablePlatformManager;
|
|
84
|
+
//# sourceMappingURL=AvailablePlatformManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvailablePlatformManager.js","sourceRoot":"","sources":["../../src/crud/AvailablePlatformManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6E;AAyB7E,MAAa,wBAAyB,SAAQ,+BAAuE;IAGnH,YAAY,GAAW;QACrB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEY,IAAI,CAAC,OAAwC;;YACxD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,GAAG,8BAA8B,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACrG,CAAC;KAAA;IAEY,KAAK,CAAC,OAAwC;;;YACzD,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,GAAG,qBAAqB,EAAE,OAAO,CAAC,CAAC;YAC1E,OAAO,MAAA,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,mCAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACzE,CAAC;KAAA;IAEY,OAAO,CAAC,OAAwC;;;YAC3D,IAAI,kBAAkB,GAAyB,EAAE,CAAC;YAClD,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,GAAG,qBAAqB,EAAE,OAAO,CAAC,CAAC;YAC1E,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,kBAAkB,GAAG,MAAA,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,OAAO,CAAC,KAAK,WAAW,O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AG,IAAI,CAAC,GAAG,qBAAqB,EAAE;YACzD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;IAEM,UAAU,CAAC,OAAwC;;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,qBAAqB,EAAE,MAAA,OAAO,CAAC,MAAM,mCAAI,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvG,CAAC;IAEM,MAAM,CAAC,iBAAqC;QACjD,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,uBAAuB,iBAAiB,CAAC,mBAAmB,EAAE,EAAE;YACtG,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,UAAU,EAAE,iBAAiB,CAAC,UAAU;YACxC,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,WAAW,EAAE,iBAAiB,CAAC,WAAW;SAC3C,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAEM,OAAO,CAAC,kBAAsC;QACnD,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,GAAG,uBAAuB,kBAAkB,CAAC,mBAAmB,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACrI,CAAC;CACF;AArED,4DAqEC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
import { IPlatform } from "./PlatformManager";
|
|
3
|
+
import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
|
|
4
|
+
export interface IComponent {
|
|
5
|
+
componentId?: number;
|
|
6
|
+
platformId?: number;
|
|
7
|
+
name?: string;
|
|
8
|
+
details?: IComponentDetails;
|
|
9
|
+
platforms?: IPlatform[];
|
|
10
|
+
updatedAt?: string;
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
config?: AxiosRequestConfig;
|
|
13
|
+
}
|
|
14
|
+
export interface IComponentDetails {
|
|
15
|
+
lang: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
services: IComponentServiceDetails;
|
|
19
|
+
viewTypes: string[] | string;
|
|
20
|
+
config?: AxiosRequestConfig;
|
|
21
|
+
}
|
|
22
|
+
export interface IComponentServiceDetails {
|
|
23
|
+
[key: string]: {
|
|
24
|
+
[key: string]: {
|
|
25
|
+
[key: string]: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface IComponentSearchDetails {
|
|
30
|
+
platformId?: number;
|
|
31
|
+
name?: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
details?: IComponentDetails;
|
|
34
|
+
values?: IComponent[];
|
|
35
|
+
offset?: number;
|
|
36
|
+
config?: AxiosRequestConfig;
|
|
37
|
+
}
|
|
38
|
+
export declare class ComponentManager extends CrudServiceManager<IComponentDetails, IComponent> {
|
|
39
|
+
private url;
|
|
40
|
+
constructor(url: string);
|
|
41
|
+
findById(id: StandardIdRequestDefinition): Promise<IComponent | undefined>;
|
|
42
|
+
findByPlatformId(details: IComponentSearchDetails): Promise<IComponent | undefined>;
|
|
43
|
+
find(details: IComponentSearchDetails): Promise<IComponent | undefined>;
|
|
44
|
+
count(details: IComponentSearchDetails): Promise<{
|
|
45
|
+
result: number;
|
|
46
|
+
}>;
|
|
47
|
+
findAll(details: IComponentSearchDetails): Promise<IComponent[] | undefined>;
|
|
48
|
+
private buildRequestUrl;
|
|
49
|
+
create(details: IComponentSearchDetails): Promise<IComponent | undefined>;
|
|
50
|
+
createMany(details: IComponentSearchDetails): Promise<IComponent[] | undefined>;
|
|
51
|
+
modify(component: IComponent): Promise<any>;
|
|
52
|
+
destroy(component: IComponent): Promise<any>;
|
|
53
|
+
}
|