cetus-tools 1.0.53 → 1.0.54
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.
|
@@ -50,7 +50,7 @@ class ContributorActionManager extends itrm_tools_1.CrudServiceManager {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
buildRequestUrl(url, details) {
|
|
53
|
-
let suffix = `${details.contributorId ? `&contributorId=${details.contributorId}` : ""}${details.
|
|
53
|
+
let suffix = `${details.contributorId ? `&contributorId=${details.contributorId}` : ""}${details.sourceId ? `&sourceId=${details.sourceId}` : ""}${details.typeId ? `&typeId=${details.typeId}` : ""}${details.tier ? `&tier=${details.tier}` : ""}`;
|
|
54
54
|
return `${url}?${suffix.substring(1)}`;
|
|
55
55
|
}
|
|
56
56
|
findById(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContributorActionManager.js","sourceRoot":"","sources":["../../src/crud/ContributorActionManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6E;AAC7E,+CAA4C;AAuC5C,MAAa,wBAAyB,SAAQ,+BAAiE;IAI3G,YAAY,GAAW;QACnB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAEM,IAAI,CAAC,OAAkC;QAC1C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,GAAG,gCAAgC,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3G,CAAC;IAEY,KAAK,CAAC,OAA2B;;;YAC1C,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,E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BAAqC;QAC/C,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,uBAAuB,iBAAiB,CAAC,mBAAmB,EAAE,EAAE;YACpG,aAAa,EAAE,iBAAiB,CAAC,aAAa;YAC9C,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YACpC,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,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,cAAc,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,iBAAiB,CAAC,mBAAmB,EAAE,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACzH,CAAC;CACJ;AAlFD,4DAkFC"}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
|
|
3
|
-
export interface IExpense {
|
|
4
|
-
expenseId?: number;
|
|
5
|
-
sourceId?: number;
|
|
6
|
-
typeId?: number;
|
|
7
|
-
date?: number;
|
|
8
|
-
fromDate?: number;
|
|
9
|
-
toDate?: number;
|
|
10
|
-
amount?: number;
|
|
11
|
-
reason?: string;
|
|
12
|
-
details?: any;
|
|
13
|
-
updatedAt?: string;
|
|
14
|
-
createdAt?: string;
|
|
15
|
-
config?: AxiosRequestConfig;
|
|
16
|
-
}
|
|
17
|
-
export interface IExpenseDetails {
|
|
18
|
-
sourceId?: number;
|
|
19
|
-
typeId?: number;
|
|
20
|
-
date?: number;
|
|
21
|
-
fromDate?: number;
|
|
22
|
-
toDate?: number;
|
|
23
|
-
amount?: number;
|
|
24
|
-
reason?: string;
|
|
25
|
-
details?: any;
|
|
26
|
-
limit?: number;
|
|
27
|
-
offset?: number;
|
|
28
|
-
config?: AxiosRequestConfig;
|
|
29
|
-
}
|
|
30
|
-
export declare class ExpenseManager extends CrudServiceManager<IExpenseDetails, IExpense> {
|
|
31
|
-
private url;
|
|
32
|
-
constructor(url: string);
|
|
33
|
-
find(details: IExpenseDetails): Promise<IExpense | undefined>;
|
|
34
|
-
count(details: IExpense): Promise<{
|
|
35
|
-
result: number;
|
|
36
|
-
}>;
|
|
37
|
-
findAll(details: IExpenseDetails): Promise<IExpense[] | undefined>;
|
|
38
|
-
private buildRequestUrl;
|
|
39
|
-
findById(id: StandardIdRequestDefinition): Promise<IExpense | undefined>;
|
|
40
|
-
create(details: IExpenseDetails): Promise<IExpense | undefined>;
|
|
41
|
-
modify(expense: IExpense): Promise<any>;
|
|
42
|
-
destroy(expense: IExpense): Promise<any>;
|
|
43
|
-
}
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
|
|
3
|
+
export interface IExpense {
|
|
4
|
+
expenseId?: number;
|
|
5
|
+
sourceId?: number;
|
|
6
|
+
typeId?: number;
|
|
7
|
+
date?: number;
|
|
8
|
+
fromDate?: number;
|
|
9
|
+
toDate?: number;
|
|
10
|
+
amount?: number;
|
|
11
|
+
reason?: string;
|
|
12
|
+
details?: any;
|
|
13
|
+
updatedAt?: string;
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
config?: AxiosRequestConfig;
|
|
16
|
+
}
|
|
17
|
+
export interface IExpenseDetails {
|
|
18
|
+
sourceId?: number;
|
|
19
|
+
typeId?: number;
|
|
20
|
+
date?: number;
|
|
21
|
+
fromDate?: number;
|
|
22
|
+
toDate?: number;
|
|
23
|
+
amount?: number;
|
|
24
|
+
reason?: string;
|
|
25
|
+
details?: any;
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
config?: AxiosRequestConfig;
|
|
29
|
+
}
|
|
30
|
+
export declare class ExpenseManager extends CrudServiceManager<IExpenseDetails, IExpense> {
|
|
31
|
+
private url;
|
|
32
|
+
constructor(url: string);
|
|
33
|
+
find(details: IExpenseDetails): Promise<IExpense | undefined>;
|
|
34
|
+
count(details: IExpense): Promise<{
|
|
35
|
+
result: number;
|
|
36
|
+
}>;
|
|
37
|
+
findAll(details: IExpenseDetails): Promise<IExpense[] | undefined>;
|
|
38
|
+
private buildRequestUrl;
|
|
39
|
+
findById(id: StandardIdRequestDefinition): Promise<IExpense | undefined>;
|
|
40
|
+
create(details: IExpenseDetails): Promise<IExpense | undefined>;
|
|
41
|
+
modify(expense: IExpense): Promise<any>;
|
|
42
|
+
destroy(expense: IExpense): Promise<any>;
|
|
43
|
+
}
|
|
@@ -1,84 +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.ExpenseManager = void 0;
|
|
13
|
-
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
-
class ExpenseManager extends itrm_tools_1.CrudServiceManager {
|
|
15
|
-
constructor(url) {
|
|
16
|
-
super();
|
|
17
|
-
this.url = url;
|
|
18
|
-
}
|
|
19
|
-
find(details) {
|
|
20
|
-
return this.sendFinding(`${this.url}/expenses?sourceId=${details.sourceId}${details.date ? `&date=${details.date}` : ""}`, details.config);
|
|
21
|
-
}
|
|
22
|
-
count(details) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
var _a;
|
|
25
|
-
let url = this.buildRequestUrl(`${this.url}/expenses`, details);
|
|
26
|
-
return (_a = (yield this.sendCounting(url, details.config))) !== null && _a !== void 0 ? _a : { result: 0 };
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
findAll(details) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
|
-
let expenses = [];
|
|
33
|
-
let url = this.buildRequestUrl(`${this.url}/expenses`, details);
|
|
34
|
-
if (details.limit) {
|
|
35
|
-
expenses = (_a = (yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config))) !== null && _a !== void 0 ? _a : [];
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
let limit = 5000, offset = 0, isEmpty = false;
|
|
39
|
-
do {
|
|
40
|
-
let values = yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
41
|
-
if (values)
|
|
42
|
-
expenses = expenses.concat(values);
|
|
43
|
-
isEmpty = values == undefined || values.length == 0;
|
|
44
|
-
offset += limit;
|
|
45
|
-
} while (!isEmpty);
|
|
46
|
-
}
|
|
47
|
-
return expenses;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
buildRequestUrl(url, details) {
|
|
51
|
-
let suffix = `${details.sourceId ? `&sourceId=${details.sourceId}` : ""}${details.date ? `&date=${details.date}` : ""}${details.fromDate ? `&fromDate=${details.fromDate}` : ""}${details.toDate ? `&toDate=${details.toDate}` : ""}`;
|
|
52
|
-
return `${url}?${suffix.substring(1)}`;
|
|
53
|
-
}
|
|
54
|
-
findById(id) {
|
|
55
|
-
return this.sendFinding(`${this.url}/expenses?id=${id.id}`, id.config);
|
|
56
|
-
}
|
|
57
|
-
create(details) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
return this.sendCreation(`${this.url}/expenses`, {
|
|
60
|
-
sourceId: details.sourceId,
|
|
61
|
-
typeId: details.typeId,
|
|
62
|
-
date: details.date,
|
|
63
|
-
amount: details.amount,
|
|
64
|
-
reason: details.reason,
|
|
65
|
-
details: details.details
|
|
66
|
-
}, details.config);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
modify(expense) {
|
|
70
|
-
return this.sendModification(`${this.url}/expenses/${expense.expenseId}`, {
|
|
71
|
-
sourceId: expense.sourceId,
|
|
72
|
-
typeId: expense.typeId,
|
|
73
|
-
date: expense.date,
|
|
74
|
-
amount: expense.amount,
|
|
75
|
-
reason: expense.reason,
|
|
76
|
-
details: expense.details
|
|
77
|
-
}, expense.config);
|
|
78
|
-
}
|
|
79
|
-
destroy(expense) {
|
|
80
|
-
return this.sendDestuction(`${this.url}/expenses/${expense.expenseId}`, expense.config);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.ExpenseManager = ExpenseManager;
|
|
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.ExpenseManager = void 0;
|
|
13
|
+
const itrm_tools_1 = require("itrm-tools");
|
|
14
|
+
class ExpenseManager extends itrm_tools_1.CrudServiceManager {
|
|
15
|
+
constructor(url) {
|
|
16
|
+
super();
|
|
17
|
+
this.url = url;
|
|
18
|
+
}
|
|
19
|
+
find(details) {
|
|
20
|
+
return this.sendFinding(`${this.url}/expenses?sourceId=${details.sourceId}${details.date ? `&date=${details.date}` : ""}`, details.config);
|
|
21
|
+
}
|
|
22
|
+
count(details) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a;
|
|
25
|
+
let url = this.buildRequestUrl(`${this.url}/expenses`, details);
|
|
26
|
+
return (_a = (yield this.sendCounting(url, details.config))) !== null && _a !== void 0 ? _a : { result: 0 };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
findAll(details) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
var _a;
|
|
32
|
+
let expenses = [];
|
|
33
|
+
let url = this.buildRequestUrl(`${this.url}/expenses`, details);
|
|
34
|
+
if (details.limit) {
|
|
35
|
+
expenses = (_a = (yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${details.limit}&offset=${details.offset}`, details.config))) !== null && _a !== void 0 ? _a : [];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
let limit = 5000, offset = 0, isEmpty = false;
|
|
39
|
+
do {
|
|
40
|
+
let values = yield this.sendAllFinding(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}limit=${limit}&offset=${offset}`, details.config);
|
|
41
|
+
if (values)
|
|
42
|
+
expenses = expenses.concat(values);
|
|
43
|
+
isEmpty = values == undefined || values.length == 0;
|
|
44
|
+
offset += limit;
|
|
45
|
+
} while (!isEmpty);
|
|
46
|
+
}
|
|
47
|
+
return expenses;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
buildRequestUrl(url, details) {
|
|
51
|
+
let suffix = `${details.sourceId ? `&sourceId=${details.sourceId}` : ""}${details.date ? `&date=${details.date}` : ""}${details.fromDate ? `&fromDate=${details.fromDate}` : ""}${details.toDate ? `&toDate=${details.toDate}` : ""}`;
|
|
52
|
+
return `${url}?${suffix.substring(1)}`;
|
|
53
|
+
}
|
|
54
|
+
findById(id) {
|
|
55
|
+
return this.sendFinding(`${this.url}/expenses?id=${id.id}`, id.config);
|
|
56
|
+
}
|
|
57
|
+
create(details) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return this.sendCreation(`${this.url}/expenses`, {
|
|
60
|
+
sourceId: details.sourceId,
|
|
61
|
+
typeId: details.typeId,
|
|
62
|
+
date: details.date,
|
|
63
|
+
amount: details.amount,
|
|
64
|
+
reason: details.reason,
|
|
65
|
+
details: details.details
|
|
66
|
+
}, details.config);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
modify(expense) {
|
|
70
|
+
return this.sendModification(`${this.url}/expenses/${expense.expenseId}`, {
|
|
71
|
+
sourceId: expense.sourceId,
|
|
72
|
+
typeId: expense.typeId,
|
|
73
|
+
date: expense.date,
|
|
74
|
+
amount: expense.amount,
|
|
75
|
+
reason: expense.reason,
|
|
76
|
+
details: expense.details
|
|
77
|
+
}, expense.config);
|
|
78
|
+
}
|
|
79
|
+
destroy(expense) {
|
|
80
|
+
return this.sendDestuction(`${this.url}/expenses/${expense.expenseId}`, expense.config);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.ExpenseManager = ExpenseManager;
|
|
84
84
|
//# sourceMappingURL=ExpenseManager.js.map
|