cetus-tools 1.0.65 → 1.0.66
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/crud/ContributorActionManager.js +102 -102
- package/dist/crud/ContributorActionManager.js.map +1 -1
- package/dist/crud/KeyManager.d.ts +42 -0
- package/dist/crud/KeyManager.js +97 -0
- package/dist/crud/KeyManager.js.map +1 -0
- package/dist/crud/test/KeyMocks.d.ts +2 -0
- package/dist/crud/test/KeyMocks.js +45 -0
- package/dist/crud/test/KeyMocks.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,103 +1,103 @@
|
|
|
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.ContributorActionManager = void 0;
|
|
13
|
-
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
-
const TypeManager_1 = require("./TypeManager");
|
|
15
|
-
class ContributorActionManager extends itrm_tools_1.CrudServiceManager {
|
|
16
|
-
constructor(url) {
|
|
17
|
-
super();
|
|
18
|
-
this.url = url;
|
|
19
|
-
this.typeManager = new TypeManager_1.TypeManager(url);
|
|
20
|
-
}
|
|
21
|
-
find(details) {
|
|
22
|
-
return this.sendFinding(`${this.url}/contributorActions?sourceId=${details.sourceId}`, details.config);
|
|
23
|
-
}
|
|
24
|
-
count(details) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a;
|
|
27
|
-
let url = this.buildRequestUrl(`${this.url}/contributorActions`, 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 contributorActions = [];
|
|
35
|
-
let url = this.buildRequestUrl(`${this.url}/contributorActions`, details);
|
|
36
|
-
if (details.limit) {
|
|
37
|
-
contributorActions = (_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
|
-
contributorActions = contributorActions.concat(values);
|
|
45
|
-
isEmpty = values == undefined || values.length == 0;
|
|
46
|
-
offset += limit;
|
|
47
|
-
} while (!isEmpty);
|
|
48
|
-
}
|
|
49
|
-
return contributorActions;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
buildRequestUrl(url, details) {
|
|
53
|
-
let suffix = `${details.contributorId ? `&contributorId=${details.contributorId}` : ""}${details.sourceId ? `&sourceId=${details.sourceId}` : ""}${details.typeId ? `&typeId=${details.typeId}` : ""}${details.tier ? `&tier=${details.tier}` : ""}${details.fromDate ? `&fromDate=${details.fromDate}` : ""}${details.toDate ? `&toDate=${details.toDate}` : ""}`;
|
|
54
|
-
return `${url}?${suffix.substring(1)}`;
|
|
55
|
-
}
|
|
56
|
-
findById(id) {
|
|
57
|
-
return this.sendFinding(`${this.url}/contributorActions?id=${id.id}`, id.config);
|
|
58
|
-
}
|
|
59
|
-
create(details) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
if (details.type) {
|
|
62
|
-
let contributorActionType = yield this.typeManager.findOrCreate({ type: details.type, config: details.config });
|
|
63
|
-
if (contributorActionType)
|
|
64
|
-
return this.sendCreation(`${this.url}/contributorActions`, {
|
|
65
|
-
contributorId: details.contributorId,
|
|
66
|
-
typeId: contributorActionType.typeId,
|
|
67
|
-
sourceId: details.sourceId,
|
|
68
|
-
date: details.date,
|
|
69
|
-
effectiveDate: details.effectiveDate,
|
|
70
|
-
amount: details.amount,
|
|
71
|
-
rate: details.rate,
|
|
72
|
-
tier: details.tier,
|
|
73
|
-
nav: details.nav,
|
|
74
|
-
units: details.units
|
|
75
|
-
}, details.config);
|
|
76
|
-
}
|
|
77
|
-
return undefined;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
createMany(details) {
|
|
81
|
-
var _a;
|
|
82
|
-
return this.sendCreationMany(`${this.url}/contributorActions`, (_a = details.values) !== null && _a !== void 0 ? _a : [], details.config);
|
|
83
|
-
}
|
|
84
|
-
modify(contributorAction) {
|
|
85
|
-
return this.sendModification(`${this.url}/contributorActions/${contributorAction.contributorActionId}`, {
|
|
86
|
-
contributorId: contributorAction.contributorId,
|
|
87
|
-
typeId: contributorAction.typeId,
|
|
88
|
-
sourceId: contributorAction.sourceId,
|
|
89
|
-
date: contributorAction.date,
|
|
90
|
-
effectiveDate: contributorAction.effectiveDate,
|
|
91
|
-
amount: contributorAction.amount,
|
|
92
|
-
rate: contributorAction.rate,
|
|
93
|
-
tier: contributorAction.tier,
|
|
94
|
-
nav: contributorAction.nav,
|
|
95
|
-
units: contributorAction.units
|
|
96
|
-
}, contributorAction.config);
|
|
97
|
-
}
|
|
98
|
-
destroy(contributorAction) {
|
|
99
|
-
return this.sendDestruction(`${this.url}/contributorActions/${contributorAction.contributorActionId}`, contributorAction.config);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.ContributorActionManager = ContributorActionManager;
|
|
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.ContributorActionManager = void 0;
|
|
13
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
+
const TypeManager_1 = require("./TypeManager");
|
|
15
|
+
class ContributorActionManager extends itrm_tools_1.CrudServiceManager {
|
|
16
|
+
constructor(url) {
|
|
17
|
+
super();
|
|
18
|
+
this.url = url;
|
|
19
|
+
this.typeManager = new TypeManager_1.TypeManager(url);
|
|
20
|
+
}
|
|
21
|
+
find(details) {
|
|
22
|
+
return this.sendFinding(`${this.url}/contributorActions?sourceId=${details.sourceId}`, details.config);
|
|
23
|
+
}
|
|
24
|
+
count(details) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
let url = this.buildRequestUrl(`${this.url}/contributorActions`, 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 contributorActions = [];
|
|
35
|
+
let url = this.buildRequestUrl(`${this.url}/contributorActions`, details);
|
|
36
|
+
if (details.limit) {
|
|
37
|
+
contributorActions = (_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
|
+
contributorActions = contributorActions.concat(values);
|
|
45
|
+
isEmpty = values == undefined || values.length == 0;
|
|
46
|
+
offset += limit;
|
|
47
|
+
} while (!isEmpty);
|
|
48
|
+
}
|
|
49
|
+
return contributorActions;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
buildRequestUrl(url, details) {
|
|
53
|
+
let suffix = `${details.contributorId ? `&contributorId=${details.contributorId}` : ""}${details.sourceId ? `&sourceId=${details.sourceId}` : ""}${details.typeId ? `&typeId=${details.typeId}` : ""}${details.tier ? `&tier=${details.tier}` : ""}${details.fromDate ? `&fromDate=${details.fromDate}` : ""}${details.toDate ? `&toDate=${details.toDate}` : ""}`;
|
|
54
|
+
return `${url}?${suffix.substring(1)}`;
|
|
55
|
+
}
|
|
56
|
+
findById(id) {
|
|
57
|
+
return this.sendFinding(`${this.url}/contributorActions?id=${id.id}`, id.config);
|
|
58
|
+
}
|
|
59
|
+
create(details) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (details.type) {
|
|
62
|
+
let contributorActionType = yield this.typeManager.findOrCreate({ type: details.type, config: details.config });
|
|
63
|
+
if (contributorActionType)
|
|
64
|
+
return this.sendCreation(`${this.url}/contributorActions`, {
|
|
65
|
+
contributorId: details.contributorId,
|
|
66
|
+
typeId: contributorActionType.typeId,
|
|
67
|
+
sourceId: details.sourceId,
|
|
68
|
+
date: details.date,
|
|
69
|
+
effectiveDate: details.effectiveDate,
|
|
70
|
+
amount: details.amount,
|
|
71
|
+
rate: details.rate,
|
|
72
|
+
tier: details.tier,
|
|
73
|
+
nav: details.nav,
|
|
74
|
+
units: details.units
|
|
75
|
+
}, details.config);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
createMany(details) {
|
|
81
|
+
var _a;
|
|
82
|
+
return this.sendCreationMany(`${this.url}/contributorActions`, (_a = details.values) !== null && _a !== void 0 ? _a : [], details.config);
|
|
83
|
+
}
|
|
84
|
+
modify(contributorAction) {
|
|
85
|
+
return this.sendModification(`${this.url}/contributorActions/${contributorAction.contributorActionId}`, {
|
|
86
|
+
contributorId: contributorAction.contributorId,
|
|
87
|
+
typeId: contributorAction.typeId,
|
|
88
|
+
sourceId: contributorAction.sourceId,
|
|
89
|
+
date: contributorAction.date,
|
|
90
|
+
effectiveDate: contributorAction.effectiveDate,
|
|
91
|
+
amount: contributorAction.amount,
|
|
92
|
+
rate: contributorAction.rate,
|
|
93
|
+
tier: contributorAction.tier,
|
|
94
|
+
nav: contributorAction.nav,
|
|
95
|
+
units: contributorAction.units
|
|
96
|
+
}, contributorAction.config);
|
|
97
|
+
}
|
|
98
|
+
destroy(contributorAction) {
|
|
99
|
+
return this.sendDestruction(`${this.url}/contributorActions/${contributorAction.contributorActionId}`, contributorAction.config);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ContributorActionManager = ContributorActionManager;
|
|
103
103
|
//# sourceMappingURL=ContributorActionManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContributorActionManager.js","sourceRoot":"","sources":["../../src/crud/ContributorActionManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6E;AAC7E,+CA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AAC,aAAa;YAC9C,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,GAAG,EAAE,iBAAiB,CAAC,GAAG;YAC1B,KAAK,EAAE,iBAAiB,CAAC,KAAK;SACjC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAEM,OAAO,CAAC,iBAAqC;QAChD,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,GAAG,uBAAuB,iBAAiB,CAAC,mBAAmB,EAAE,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACrI,CAAC;CACJ;AAxFD,4DAwFC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
|
|
2
|
+
import { AxiosRequestConfig } from "axios";
|
|
3
|
+
export interface IKey {
|
|
4
|
+
keyId?: number;
|
|
5
|
+
typeId?: number;
|
|
6
|
+
userId?: number;
|
|
7
|
+
lastNonce?: number;
|
|
8
|
+
publicKey?: string;
|
|
9
|
+
secretKey?: string;
|
|
10
|
+
details?: any;
|
|
11
|
+
updatedAt?: string;
|
|
12
|
+
createdAt?: string;
|
|
13
|
+
config?: AxiosRequestConfig;
|
|
14
|
+
}
|
|
15
|
+
export interface IKeyDetails {
|
|
16
|
+
userId?: number;
|
|
17
|
+
lastNonce?: number;
|
|
18
|
+
publicKey?: string;
|
|
19
|
+
secretKey?: string;
|
|
20
|
+
details?: any;
|
|
21
|
+
type?: string;
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
values?: IKey[];
|
|
25
|
+
config?: AxiosRequestConfig;
|
|
26
|
+
}
|
|
27
|
+
export declare class KeyManager extends CrudServiceManager<IKeyDetails, IKey> {
|
|
28
|
+
private url;
|
|
29
|
+
private typeManager;
|
|
30
|
+
constructor(url: string);
|
|
31
|
+
find(details: IKeyDetails): Promise<IKey | undefined>;
|
|
32
|
+
findAll(details: IKeyDetails): Promise<IKey[] | undefined>;
|
|
33
|
+
private buildRequestUrl;
|
|
34
|
+
count(details: IKeyDetails): Promise<{
|
|
35
|
+
result: number;
|
|
36
|
+
}>;
|
|
37
|
+
findById(id: StandardIdRequestDefinition): Promise<IKey | undefined>;
|
|
38
|
+
create(details: IKeyDetails): Promise<IKey | undefined>;
|
|
39
|
+
createMany(details: IKeyDetails): Promise<IKey[] | undefined>;
|
|
40
|
+
modify(key: IKey): Promise<any>;
|
|
41
|
+
destroy(key: IKey): Promise<any>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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.KeyManager = void 0;
|
|
13
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
+
const TypeManager_1 = require("./TypeManager");
|
|
15
|
+
class KeyManager extends itrm_tools_1.CrudServiceManager {
|
|
16
|
+
constructor(url) {
|
|
17
|
+
super();
|
|
18
|
+
this.url = url;
|
|
19
|
+
this.typeManager = new TypeManager_1.TypeManager(url);
|
|
20
|
+
}
|
|
21
|
+
find(details) {
|
|
22
|
+
return this.sendFinding(`${this.url}/keys?publicKey=${details.publicKey}`, details.config);
|
|
23
|
+
}
|
|
24
|
+
findAll(details) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
let keys = [];
|
|
28
|
+
let url = this.buildRequestUrl(`${this.url}/keys`, details);
|
|
29
|
+
if (details.limit) {
|
|
30
|
+
keys = (_a = (yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config))) !== null && _a !== void 0 ? _a : [];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
let limit = 5000, offset = 0, isEmpty = false;
|
|
34
|
+
do {
|
|
35
|
+
let values = yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
36
|
+
if (values)
|
|
37
|
+
keys = keys.concat(values);
|
|
38
|
+
isEmpty = values == undefined || values.length == 0;
|
|
39
|
+
offset += limit;
|
|
40
|
+
} while (!isEmpty);
|
|
41
|
+
}
|
|
42
|
+
return keys;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
buildRequestUrl(url, details) {
|
|
46
|
+
let suffix = `${details.publicKey ? `&publicKey=${details.publicKey}` : ""}${details.userId ? `&userId=${details.userId}` : ""}`;
|
|
47
|
+
return `${url}?${suffix.substring(1)}`;
|
|
48
|
+
}
|
|
49
|
+
count(details) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
var _a;
|
|
52
|
+
let url = this.buildRequestUrl(`${this.url}/keys`, details);
|
|
53
|
+
return (_a = (yield this.sendCounting(url, details.config))) !== null && _a !== void 0 ? _a : { result: 0 };
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
findById(id) {
|
|
57
|
+
return this.sendFinding(`${this.url}/keys?userId=${id.id}`, id.config);
|
|
58
|
+
}
|
|
59
|
+
create(details) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (details.type) {
|
|
62
|
+
let keyType = yield this.typeManager.findOrCreate({ type: details.type, config: details.config });
|
|
63
|
+
if (keyType)
|
|
64
|
+
return this.sendCreation(`${this.url}/keys`, {
|
|
65
|
+
typeId: keyType.typeId,
|
|
66
|
+
userId: details.userId,
|
|
67
|
+
lastNonce: details.lastNonce,
|
|
68
|
+
publicKey: details.publicKey,
|
|
69
|
+
secretKey: details.secretKey,
|
|
70
|
+
details: details.details
|
|
71
|
+
}, details.config);
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
createMany(details) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a;
|
|
79
|
+
return this.sendCreationMany(`${this.url}/keys`, (_a = details.values) !== null && _a !== void 0 ? _a : [], details.config);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
modify(key) {
|
|
83
|
+
return this.sendModification(`${this.url}/keys/${key.keyId}`, {
|
|
84
|
+
userId: key.userId,
|
|
85
|
+
typeId: key.typeId,
|
|
86
|
+
lastNonce: key.lastNonce,
|
|
87
|
+
publicKey: key.publicKey,
|
|
88
|
+
secretKey: key.secretKey,
|
|
89
|
+
details: key.details
|
|
90
|
+
}, key.config);
|
|
91
|
+
}
|
|
92
|
+
destroy(key) {
|
|
93
|
+
return this.sendDestruction(`${this.url}/keys/${key.keyId}`, key.config);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.KeyManager = KeyManager;
|
|
97
|
+
//# sourceMappingURL=KeyManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyManager.js","sourceRoot":"","sources":["../../src/crud/KeyManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6E;AAC7E,+CAA4C;AA6B5C,MAAa,UAAW,SAAQ,+BAAqC;IAIjE,YAAY,GAAW;QACnB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAA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Property(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyKeyMocks = applyKeyMocks;
|
|
4
|
+
var Keys = {};
|
|
5
|
+
function applyKeyMocks(mock) {
|
|
6
|
+
mock.onGet(/\/keys\?id=[a-zA-Z0-9]+/).reply((config) => {
|
|
7
|
+
let searchedId = config.url ? config.url.split('id=')[1] : '';
|
|
8
|
+
if (Keys[searchedId])
|
|
9
|
+
return [200, { result: [Keys[searchedId]] }];
|
|
10
|
+
return [200, { result: [] }];
|
|
11
|
+
});
|
|
12
|
+
mock.onGet(/\/keys\?name=[a-zA-Z0-9]+/).reply((config) => {
|
|
13
|
+
let searchedKey = config.url ? config.url.split('name=')[1] : '';
|
|
14
|
+
for (let key of Object.keys(Keys))
|
|
15
|
+
if (Keys[key].name === searchedKey)
|
|
16
|
+
return [200, { result: [Keys[key]] }];
|
|
17
|
+
return [200, { result: [] }];
|
|
18
|
+
});
|
|
19
|
+
mock.onPost(/\/keys/).reply((config) => {
|
|
20
|
+
let data = JSON.parse(config.data);
|
|
21
|
+
for (let key of Object.keys(Keys))
|
|
22
|
+
if (Keys[key].type === data.name)
|
|
23
|
+
return [400, { status: 'Error', type: 'SequelizeUniqueConstraintError', error: 'Validation error' }];
|
|
24
|
+
let item = { KeyId: Object.keys(Keys).length + 1, name: data.name, KeyTypeId: data.KeyTypeId };
|
|
25
|
+
Keys["" + item.KeyId] = item;
|
|
26
|
+
return [200, { items: [Keys["" + item.KeyId]] }];
|
|
27
|
+
});
|
|
28
|
+
mock.onPut(/\/keys\/[0-9]+/).reply((config) => {
|
|
29
|
+
let KeyId = config.url ? config.url.split('keys/')[1] : '';
|
|
30
|
+
if (Keys[KeyId]) {
|
|
31
|
+
let data = JSON.parse(config.data);
|
|
32
|
+
Keys[KeyId] = Object.assign(Object.assign({}, Keys[KeyId]), data);
|
|
33
|
+
return [200, { status: 'Ok', message: '1 items were updated' }];
|
|
34
|
+
}
|
|
35
|
+
return [200, { status: 'Ok', message: '0 items were updated' }];
|
|
36
|
+
});
|
|
37
|
+
mock.onDelete(/\/keys\/[0-9]+/).reply((config) => {
|
|
38
|
+
let searchedKeyId = config.url ? config.url.split('keys/')[1] : '';
|
|
39
|
+
for (let key of Object.keys(Keys))
|
|
40
|
+
if (Keys[key].KeyId == parseInt(searchedKeyId))
|
|
41
|
+
delete Keys[key];
|
|
42
|
+
return [200, { status: 'Ok', message: '1 items were deleted' }];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=KeyMocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyMocks.js","sourceRoot":"","sources":["../../../src/crud/test/KeyMocks.ts"],"names":[],"mappings":";;AAIA,sCAuCC;AAzCD,IAAI,IAAI,GAAQ,EAAE,CAAC;AAEnB,SAAgB,aAAa,CAAC,IAAiB;IAC3C,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,KAAK,CAAC,CAAC,MAAW,EAAE,EAAE;QACxD,IAAI,UAAU,GAAW,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,IAAI,IAAI,CAAC,UAAU,CAAC;YACZ,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,KAAK,CAAC,CAAC,MAAW,EAAE,EAAE;QAC1D,IAAI,WAAW,GAAW,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,E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ED
|
@@ -27,8 +27,10 @@ export { ExpenseManager as ExpenseManager, IExpense as IExpense, IExpenseDetails
|
|
|
27
27
|
export { PnlManager as PnlManager, IPnl as IPnl, IPnlDetails as IPnlDetails } from "./crud/PnlManager";
|
|
28
28
|
export { ModificationManager as ModificationManager, IModification as IModification, IModificationDetails as IModificationDetails } from "./crud/ModificationManager";
|
|
29
29
|
export { NavManager as NavManager, INav as INav, INavDetails as INavDetails } from "./crud/NavManager";
|
|
30
|
+
export { KeyManager as KeyManager, IKey as IKey, IKeyDetails as IKeyDetails } from "./crud/KeyManager";
|
|
30
31
|
export { applyLoginMocks as applyLoginMocks } from "./crud/test/LoginServiceMock";
|
|
31
32
|
export { applyPlatformMocks as applyPlatformMocks } from "./crud/test/PlatformMocks";
|
|
32
33
|
export { applyRoleMocks as applyRoleMocks } from "./crud/test/RoleMocks";
|
|
33
34
|
export { applyStatusMocks as applyStatusMocks } from "./crud/test/StatusMocks";
|
|
34
35
|
export { applyTypeMocks as applyTypeMocks } from "./crud/test/TypeMocks";
|
|
36
|
+
export { applyKeyMocks as applyKeyMocks } from "./crud/test/KeyMocks";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyTypeMocks = exports.applyStatusMocks = exports.applyRoleMocks = exports.applyPlatformMocks = exports.applyLoginMocks = exports.NavManager = exports.ModificationManager = exports.PnlManager = exports.ExpenseManager = exports.ContributorActionManager = exports.ContributorManager = exports.SourceManager = exports.RatesManager = exports.PairsManager = exports.OperationsManager = exports.IntermediaryManager = exports.AssetsManager = exports.ActivityHistoryManager = exports.UserManager = exports.UserCredentialsManager = exports.TypeManager = exports.StatusManager = exports.RoleManager = exports.AvailablePlatformManager = exports.PlatformManager = exports.ComponentManager = exports.findBitsoBook = exports.findBalances = exports.BitsoApiConnection = exports.ServiceSessionChecker = exports.RoleServicePermissionsChecker = exports.ExpressLogableConfig = void 0;
|
|
3
|
+
exports.applyKeyMocks = exports.applyTypeMocks = exports.applyStatusMocks = exports.applyRoleMocks = exports.applyPlatformMocks = exports.applyLoginMocks = exports.KeyManager = exports.NavManager = exports.ModificationManager = exports.PnlManager = exports.ExpenseManager = exports.ContributorActionManager = exports.ContributorManager = exports.SourceManager = exports.RatesManager = exports.PairsManager = exports.OperationsManager = exports.IntermediaryManager = exports.AssetsManager = exports.ActivityHistoryManager = exports.UserManager = exports.UserCredentialsManager = exports.TypeManager = exports.StatusManager = exports.RoleManager = exports.AvailablePlatformManager = exports.PlatformManager = exports.ComponentManager = exports.findBitsoBook = exports.findBalances = exports.BitsoApiConnection = exports.ServiceSessionChecker = exports.RoleServicePermissionsChecker = exports.ExpressLogableConfig = void 0;
|
|
4
4
|
var ExpressLogableConfig_1 = require("./api/ExpressLogableConfig");
|
|
5
5
|
Object.defineProperty(exports, "ExpressLogableConfig", { enumerable: true, get: function () { return ExpressLogableConfig_1.ExpressLogableConfig; } });
|
|
6
6
|
var RoleServicePermissionsChecker_1 = require("./api/checkers/RoleServicePermissionsChecker");
|
|
@@ -55,6 +55,8 @@ var ModificationManager_1 = require("./crud/ModificationManager");
|
|
|
55
55
|
Object.defineProperty(exports, "ModificationManager", { enumerable: true, get: function () { return ModificationManager_1.ModificationManager; } });
|
|
56
56
|
var NavManager_1 = require("./crud/NavManager");
|
|
57
57
|
Object.defineProperty(exports, "NavManager", { enumerable: true, get: function () { return NavManager_1.NavManager; } });
|
|
58
|
+
var KeyManager_1 = require("./crud/KeyManager");
|
|
59
|
+
Object.defineProperty(exports, "KeyManager", { enumerable: true, get: function () { return KeyManager_1.KeyManager; } });
|
|
58
60
|
var LoginServiceMock_1 = require("./crud/test/LoginServiceMock");
|
|
59
61
|
Object.defineProperty(exports, "applyLoginMocks", { enumerable: true, get: function () { return LoginServiceMock_1.applyLoginMocks; } });
|
|
60
62
|
var PlatformMocks_1 = require("./crud/test/PlatformMocks");
|
|
@@ -65,4 +67,6 @@ var StatusMocks_1 = require("./crud/test/StatusMocks");
|
|
|
65
67
|
Object.defineProperty(exports, "applyStatusMocks", { enumerable: true, get: function () { return StatusMocks_1.applyStatusMocks; } });
|
|
66
68
|
var TypeMocks_1 = require("./crud/test/TypeMocks");
|
|
67
69
|
Object.defineProperty(exports, "applyTypeMocks", { enumerable: true, get: function () { return TypeMocks_1.applyTypeMocks; } });
|
|
70
|
+
var KeyMocks_1 = require("./crud/test/KeyMocks");
|
|
71
|
+
Object.defineProperty(exports, "applyKeyMocks", { enumerable: true, get: function () { return KeyMocks_1.applyKeyMocks; } });
|
|
68
72
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAA0F;AAAjF,4HAAA,oBAAoB,OAAwB;AAErD,8FAA8H;AAArH,8IAAA,6BAA6B,OAAiC;AACvE,8EAAkM;AAA7F,8HAAA,qBAAqB,OAAyB;AAEnJ,qEAA4H;AAAjF,wHAAA,kBAAkB,OAAsB;AACnF,+DAA8G;AAArE,4GAAA,YAAY,OAAgB;AACrE,yDAAuG;AAApE,0GAAA,aAAa,OAAiB;AAIjE,4DAA2P;AAAtE,oHAAA,gBAAgB,OAAoB;AACzN,0DAA4L;AAAnE,kHAAA,eAAe,OAAmB;AAC3J,4EAAqN;AAA9F,oIAAA,wBAAwB,OAA4B;AAC3K,kDAA0H;AAAvD,0GAAA,WAAW,OAAe;AAC7F,sDAAwI;AAA7D,8GAAA,aAAa,OAAiB;AACzG,kDAA0H;AAAvD,0GAAA,WAAW,OAAe;AAC7F,wEAAuM;AAAxF,gIAAA,sBAAsB,OAA0B;AAC/J,kDAA0H;AAAvD,0GAAA,WAAW,OAAe;AAC7F,wEAA2L;AAAxF,gIAAA,sBAAsB,OAA0B;AACnJ,sDAA4H;AAA7D,8GAAA,aAAa,OAAiB;AAC7F,kEAAsK;A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