@provis/provis-common-be-module 2.3.26 → 2.3.27
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/class/main.repository.d.ts +27 -0
- package/dist/class/main.repository.js +303 -0
- package/dist/constants/brokerage.d.ts +25 -0
- package/dist/constants/brokerage.js +30 -0
- package/dist/constants/claim/document-container.d.ts +14 -0
- package/dist/constants/claim/document-container.js +65 -0
- package/dist/constants/claim/generalInsurance.d.ts +535 -0
- package/dist/constants/claim/generalInsurance.js +18 -0
- package/dist/constants/claim/kalog.d.ts +28 -0
- package/dist/constants/claim/kalog.js +186 -0
- package/dist/constants/claim/loket.d.ts +36 -0
- package/dist/constants/claim/loket.js +290 -0
- package/dist/constants/claim/motorVehicle.d.ts +158 -0
- package/dist/constants/claim/motorVehicle.js +139 -0
- package/dist/constants/claim/status.d.ts +137 -0
- package/dist/constants/claim/status.js +160 -0
- package/dist/constants/claim/travel.d.ts +358 -0
- package/dist/constants/claim/travel.js +268 -0
- package/dist/constants/config.d.ts +2 -0
- package/dist/constants/config.js +23 -0
- package/dist/constants/currency.d.ts +2 -0
- package/dist/constants/currency.js +7 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +11 -0
- package/dist/constants/join.d.ts +5 -0
- package/dist/constants/join.js +2 -0
- package/dist/constants/loket.d.ts +17 -0
- package/dist/constants/loket.js +19 -0
- package/dist/constants/martialStatus.d.ts +2 -0
- package/dist/constants/martialStatus.js +32 -0
- package/dist/constants/operator.d.ts +2 -0
- package/dist/constants/operator.js +12 -0
- package/dist/constants/product/cargo.d.ts +39 -0
- package/dist/constants/product/cargo.js +41 -0
- package/dist/constants/product/mv/clause.d.ts +52 -0
- package/dist/constants/product/mv/clause.js +214 -0
- package/dist/constants/product/mv/merk.d.ts +7 -0
- package/dist/constants/product/mv/merk.js +111 -0
- package/dist/constants/product/mv/mv.d.ts +48 -0
- package/dist/constants/product/mv/mv.js +215 -0
- package/dist/constants/product/mv/plat.d.ts +7 -0
- package/dist/constants/product/mv/plat.js +334 -0
- package/dist/constants/product/mv.d.ts +30 -0
- package/dist/constants/product/mv.js +158 -0
- package/dist/constants/product/occupation.d.ts +5 -0
- package/dist/constants/product/occupation.js +25 -0
- package/dist/constants/product/policy.d.ts +31 -0
- package/dist/constants/product/policy.js +33 -0
- package/dist/constants/product.d.ts +72 -0
- package/dist/constants/product.js +394 -0
- package/dist/constants/quotation.d.ts +32 -0
- package/dist/constants/quotation.js +38 -0
- package/dist/constants/report.d.ts +46 -0
- package/dist/constants/report.js +60 -0
- package/dist/constants/vesselList.d.ts +5 -0
- package/dist/constants/vesselList.js +116 -0
- package/dist/helpers/addDateTime.d.ts +6 -0
- package/dist/helpers/addDateTime.js +30 -0
- package/dist/helpers/amountDescription.d.ts +1 -0
- package/dist/helpers/amountDescription.js +44 -0
- package/dist/helpers/axiosGet.d.ts +8 -0
- package/dist/helpers/axiosGet.js +47 -0
- package/dist/helpers/axiosPost.d.ts +8 -0
- package/dist/helpers/axiosPost.js +46 -0
- package/dist/helpers/axiosPut.d.ts +8 -0
- package/dist/helpers/axiosPut.js +46 -0
- package/dist/helpers/calculateByType.d.ts +5 -0
- package/dist/helpers/calculateByType.js +19 -0
- package/dist/helpers/calculateForNullable.d.ts +5 -0
- package/dist/helpers/calculateForNullable.js +47 -0
- package/dist/helpers/combineObj.d.ts +2 -0
- package/dist/helpers/combineObj.js +17 -0
- package/dist/helpers/compareDiffObj.d.ts +2 -0
- package/dist/helpers/compareDiffObj.js +14 -0
- package/dist/helpers/convertCurrencySymbol.d.ts +2 -0
- package/dist/helpers/convertCurrencySymbol.js +20 -0
- package/dist/helpers/convertDateTimeFormat.d.ts +6 -0
- package/dist/helpers/convertDateTimeFormat.js +113 -0
- package/dist/helpers/convertObjToNumber.d.ts +2 -0
- package/dist/helpers/convertObjToNumber.js +14 -0
- package/dist/helpers/convertToCurrency.d.ts +2 -0
- package/dist/helpers/convertToCurrency.js +21 -0
- package/dist/helpers/excelDateToJsDate.d.ts +4 -0
- package/dist/helpers/excelDateToJsDate.js +30 -0
- package/dist/helpers/filterObj.d.ts +2 -0
- package/dist/helpers/filterObj.js +9 -0
- package/dist/helpers/generateHashString.d.ts +2 -0
- package/dist/helpers/generateHashString.js +15 -0
- package/dist/helpers/generateRelationId.d.ts +2 -0
- package/dist/helpers/generateRelationId.js +15 -0
- package/dist/helpers/getCargoType.d.ts +2 -0
- package/dist/helpers/getCargoType.js +9 -0
- package/dist/helpers/getCurrentDate.d.ts +2 -0
- package/dist/helpers/getCurrentDate.js +11 -0
- package/dist/helpers/getDiffValue.d.ts +2 -0
- package/dist/helpers/getDiffValue.js +24 -0
- package/dist/helpers/getObjByKeys.d.ts +2 -0
- package/dist/helpers/getObjByKeys.js +19 -0
- package/dist/helpers/index.d.ts +25 -0
- package/dist/helpers/index.js +51 -0
- package/dist/helpers/loop.d.ts +2 -0
- package/dist/helpers/loop.js +21 -0
- package/dist/helpers/loopBackward.d.ts +2 -0
- package/dist/helpers/loopBackward.js +21 -0
- package/dist/helpers/mergeObj.d.ts +2 -0
- package/dist/helpers/mergeObj.js +16 -0
- package/dist/helpers/readExcel.d.ts +5 -0
- package/dist/helpers/readExcel.js +115 -0
- package/dist/helpers/searchValue.d.ts +4 -0
- package/dist/helpers/searchValue.js +63 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/interface/axios.interface.d.ts +5 -0
- package/dist/interface/axios.interface.js +2 -0
- package/dist/interface/find.all.count.interface.d.ts +10 -0
- package/dist/interface/find.all.count.interface.js +2 -0
- package/dist/interface/multi.join.interface.d.ts +9 -0
- package/dist/interface/multi.join.interface.js +2 -0
- package/dist/interface/read.excel.interface.d.ts +12 -0
- package/dist/interface/read.excel.interface.js +2 -0
- package/dist/interface/search.conditions.interface.d.ts +8 -0
- package/dist/interface/search.conditions.interface.js +2 -0
- package/dist/interface/search.initial.interface.d.ts +8 -0
- package/dist/interface/search.initial.interface.js +2 -0
- package/dist/interface/search.query.interface.d.ts +5 -0
- package/dist/interface/search.query.interface.js +3 -0
- package/dist/interface/search.summary.interface.d.ts +9 -0
- package/dist/interface/search.summary.interface.js +2 -0
- package/dist/interface/search.value.interface.d.ts +6 -0
- package/dist/interface/search.value.interface.js +3 -0
- package/dist/interface/summary.field.interface.d.ts +4 -0
- package/dist/interface/summary.field.interface.js +3 -0
- package/dist/interface/user.interface.d.ts +4 -0
- package/dist/interface/user.interface.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const uniqId = require("uniqid");
|
|
4
|
+
exports.default = (totalLength = 24) => {
|
|
5
|
+
const variable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_'.split('');
|
|
6
|
+
let code = uniqId();
|
|
7
|
+
while (true) {
|
|
8
|
+
if (code.length < totalLength) {
|
|
9
|
+
code = `${code}${variable[Math.ceil(Math.random() * (variable.length - 1))]}`;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cargo_1 = require("../constants/product/cargo");
|
|
4
|
+
function getCargoType(code, lang = 'en') {
|
|
5
|
+
var _a;
|
|
6
|
+
const match = Object.values(cargo_1.default.TYPE).find((item) => item.code === code);
|
|
7
|
+
return ((_a = match === null || match === void 0 ? void 0 : match.desc) === null || _a === void 0 ? void 0 : _a[lang]) || null;
|
|
8
|
+
}
|
|
9
|
+
exports.default = getCargoType;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const convertDateTimeFormat_1 = require("./convertDateTimeFormat");
|
|
4
|
+
const config_1 = require("../constants/config");
|
|
5
|
+
exports.default = () => {
|
|
6
|
+
return (0, convertDateTimeFormat_1.default)({
|
|
7
|
+
initialValue: Date.now(),
|
|
8
|
+
dateTimeFormatFrom: config_1.default.date_format_timestamp,
|
|
9
|
+
dateTimeFormatTo: config_1.default.date_format_full_datetime_with_separator,
|
|
10
|
+
}).toString();
|
|
11
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
13
|
+
exports.default = (obj1, obj2) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const keys = Object.keys(obj2);
|
|
15
|
+
return new Promise((res) => {
|
|
16
|
+
res(keys.filter((key) => {
|
|
17
|
+
if (obj1[key] != obj2[key]) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}).map((key) => ({
|
|
21
|
+
[key]: `${obj1[key]} - ${obj2[key]}`,
|
|
22
|
+
})));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
13
|
+
exports.default = (obj, keys) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
return new Promise((res) => {
|
|
15
|
+
res(keys.map((key) => ({
|
|
16
|
+
[key]: obj[key]
|
|
17
|
+
})));
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import addDateTime from "./addDateTime";
|
|
2
|
+
import amountDescription from './amountDescription';
|
|
3
|
+
import axiosGet from "./axiosGet";
|
|
4
|
+
import axiosPost from "./axiosPost";
|
|
5
|
+
import axiosPut from "./axiosPut";
|
|
6
|
+
import compareDiffObj from "./compareDiffObj";
|
|
7
|
+
import convertCurrencySymbol from "./convertCurrencySymbol";
|
|
8
|
+
import convertDateTimeFormat from "./convertDateTimeFormat";
|
|
9
|
+
import convertObjToNumber from "./convertObjToNumber";
|
|
10
|
+
import convertToCurrency from "./convertToCurrency";
|
|
11
|
+
import filterObj from "./filterObj";
|
|
12
|
+
import generateRelationId from "./generateRelationId";
|
|
13
|
+
import getCurrentDate from "./getCurrentDate";
|
|
14
|
+
import getDiffValue from "./getDiffValue";
|
|
15
|
+
import getObjByKeys from "./getObjByKeys";
|
|
16
|
+
import loop from "./loop";
|
|
17
|
+
import loopBackward from "./loopBackward";
|
|
18
|
+
import searchValue from "./searchValue";
|
|
19
|
+
import readExcel from "./readExcel";
|
|
20
|
+
import generateHashString from "./generateHashString";
|
|
21
|
+
import mergeObj from "./mergeObj";
|
|
22
|
+
import combineObj from "./combineObj";
|
|
23
|
+
import calculateByType from './calculateByType';
|
|
24
|
+
import getCargoType from "./getCargoType";
|
|
25
|
+
export { addDateTime, amountDescription, axiosGet, axiosPost, axiosPut, compareDiffObj, convertCurrencySymbol, convertDateTimeFormat, convertObjToNumber, convertToCurrency, filterObj, generateRelationId, getCurrentDate, getDiffValue, getObjByKeys, loop, loopBackward, searchValue, readExcel, generateHashString, mergeObj, combineObj, calculateByType, getCargoType, };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCargoType = exports.calculateByType = exports.combineObj = exports.mergeObj = exports.generateHashString = exports.readExcel = exports.searchValue = exports.loopBackward = exports.loop = exports.getObjByKeys = exports.getDiffValue = exports.getCurrentDate = exports.generateRelationId = exports.filterObj = exports.convertToCurrency = exports.convertObjToNumber = exports.convertDateTimeFormat = exports.convertCurrencySymbol = exports.compareDiffObj = exports.axiosPut = exports.axiosPost = exports.axiosGet = exports.amountDescription = exports.addDateTime = void 0;
|
|
4
|
+
const addDateTime_1 = require("./addDateTime");
|
|
5
|
+
exports.addDateTime = addDateTime_1.default;
|
|
6
|
+
const amountDescription_1 = require("./amountDescription");
|
|
7
|
+
exports.amountDescription = amountDescription_1.default;
|
|
8
|
+
const axiosGet_1 = require("./axiosGet");
|
|
9
|
+
exports.axiosGet = axiosGet_1.default;
|
|
10
|
+
const axiosPost_1 = require("./axiosPost");
|
|
11
|
+
exports.axiosPost = axiosPost_1.default;
|
|
12
|
+
const axiosPut_1 = require("./axiosPut");
|
|
13
|
+
exports.axiosPut = axiosPut_1.default;
|
|
14
|
+
const compareDiffObj_1 = require("./compareDiffObj");
|
|
15
|
+
exports.compareDiffObj = compareDiffObj_1.default;
|
|
16
|
+
const convertCurrencySymbol_1 = require("./convertCurrencySymbol");
|
|
17
|
+
exports.convertCurrencySymbol = convertCurrencySymbol_1.default;
|
|
18
|
+
const convertDateTimeFormat_1 = require("./convertDateTimeFormat");
|
|
19
|
+
exports.convertDateTimeFormat = convertDateTimeFormat_1.default;
|
|
20
|
+
const convertObjToNumber_1 = require("./convertObjToNumber");
|
|
21
|
+
exports.convertObjToNumber = convertObjToNumber_1.default;
|
|
22
|
+
const convertToCurrency_1 = require("./convertToCurrency");
|
|
23
|
+
exports.convertToCurrency = convertToCurrency_1.default;
|
|
24
|
+
const filterObj_1 = require("./filterObj");
|
|
25
|
+
exports.filterObj = filterObj_1.default;
|
|
26
|
+
const generateRelationId_1 = require("./generateRelationId");
|
|
27
|
+
exports.generateRelationId = generateRelationId_1.default;
|
|
28
|
+
const getCurrentDate_1 = require("./getCurrentDate");
|
|
29
|
+
exports.getCurrentDate = getCurrentDate_1.default;
|
|
30
|
+
const getDiffValue_1 = require("./getDiffValue");
|
|
31
|
+
exports.getDiffValue = getDiffValue_1.default;
|
|
32
|
+
const getObjByKeys_1 = require("./getObjByKeys");
|
|
33
|
+
exports.getObjByKeys = getObjByKeys_1.default;
|
|
34
|
+
const loop_1 = require("./loop");
|
|
35
|
+
exports.loop = loop_1.default;
|
|
36
|
+
const loopBackward_1 = require("./loopBackward");
|
|
37
|
+
exports.loopBackward = loopBackward_1.default;
|
|
38
|
+
const searchValue_1 = require("./searchValue");
|
|
39
|
+
exports.searchValue = searchValue_1.default;
|
|
40
|
+
const readExcel_1 = require("./readExcel");
|
|
41
|
+
exports.readExcel = readExcel_1.default;
|
|
42
|
+
const generateHashString_1 = require("./generateHashString");
|
|
43
|
+
exports.generateHashString = generateHashString_1.default;
|
|
44
|
+
const mergeObj_1 = require("./mergeObj");
|
|
45
|
+
exports.mergeObj = mergeObj_1.default;
|
|
46
|
+
const combineObj_1 = require("./combineObj");
|
|
47
|
+
exports.combineObj = combineObj_1.default;
|
|
48
|
+
const calculateByType_1 = require("./calculateByType");
|
|
49
|
+
exports.calculateByType = calculateByType_1.default;
|
|
50
|
+
const getCargoType_1 = require("./getCargoType");
|
|
51
|
+
exports.getCargoType = getCargoType_1.default;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
function loop(list, callback, result = []) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
if (list && list.length > 0) {
|
|
15
|
+
const [head, ...tail] = list;
|
|
16
|
+
return loop(tail, callback, [yield callback(head), ...result]);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.default = loop;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
function loop(list, callback, result = []) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
if (list && list.length > 0) {
|
|
15
|
+
const [head, ...tail] = list;
|
|
16
|
+
return loop(tail, callback, [...result, yield callback(head)]);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.default = loop;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = (obj1, obj2) => {
|
|
4
|
+
const merged = Object.assign({}, obj1);
|
|
5
|
+
for (const key in obj2) {
|
|
6
|
+
if (merged[key]) {
|
|
7
|
+
// Combine arrays if the key exists in both objects
|
|
8
|
+
merged[key] = merged[key].concat(obj2[key]);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
// Add the new key and its value
|
|
12
|
+
merged[key] = obj2[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return merged;
|
|
16
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
const helpers_1 = require("../helpers");
|
|
13
|
+
const XLSX = require("xlsx");
|
|
14
|
+
const excelDateToJsDate_1 = require("./excelDateToJsDate");
|
|
15
|
+
const constants_1 = require("../constants");
|
|
16
|
+
function readExcel(file, data) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const dataPost = [];
|
|
19
|
+
let validationPassed = true;
|
|
20
|
+
let errorMessage = '';
|
|
21
|
+
try {
|
|
22
|
+
const { listKey, headerExcel, startRow, startColumn } = data;
|
|
23
|
+
const workbook = XLSX.read(file, { type: 'buffer' });
|
|
24
|
+
const sheet = workbook.Sheets[workbook.SheetNames[0]];
|
|
25
|
+
const merges = sheet['!merges'] || [];
|
|
26
|
+
const endRange = XLSX.utils.decode_range(sheet['!ref']);
|
|
27
|
+
const endRow = endRange.e.r;
|
|
28
|
+
const endColumn = endRange.e.c;
|
|
29
|
+
let tempData = {};
|
|
30
|
+
const rows = XLSX.utils.sheet_to_json(sheet, {
|
|
31
|
+
range: {
|
|
32
|
+
s: { c: startColumn || 0, r: startRow || 0 },
|
|
33
|
+
e: { c: endColumn, r: endRow },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const remadeRows = rows.map((item) => {
|
|
37
|
+
const remadeItem = {};
|
|
38
|
+
for (const key in item) {
|
|
39
|
+
const trimmedKey = key.trim();
|
|
40
|
+
const value = item[key];
|
|
41
|
+
remadeItem[trimmedKey] =
|
|
42
|
+
typeof value === 'string' ? value.trim() : value;
|
|
43
|
+
}
|
|
44
|
+
return remadeItem;
|
|
45
|
+
});
|
|
46
|
+
for (let i = 0; i < remadeRows.length; i++) {
|
|
47
|
+
const rowData = remadeRows[i];
|
|
48
|
+
const obj = {};
|
|
49
|
+
let isReset = false;
|
|
50
|
+
for (let j = 0; j < listKey.length; j++) {
|
|
51
|
+
const { name: key, isMandatory, type } = listKey[j];
|
|
52
|
+
const header = headerExcel[j];
|
|
53
|
+
obj[key] = rowData[header];
|
|
54
|
+
if (obj[key] != undefined) {
|
|
55
|
+
tempData[key] = obj[key];
|
|
56
|
+
}
|
|
57
|
+
for (const merge of merges) {
|
|
58
|
+
if (i >= merge.s.r &&
|
|
59
|
+
i <= merge.e.r &&
|
|
60
|
+
j >= merge.s.c &&
|
|
61
|
+
j <= merge.e.c) {
|
|
62
|
+
console.log(`Merged Cell => ${key} | ${header}`, rowData[header]);
|
|
63
|
+
obj[key] = tempData[key];
|
|
64
|
+
const nextRow = remadeRows[i + 1];
|
|
65
|
+
if (nextRow) {
|
|
66
|
+
if (nextRow[header] != undefined &&
|
|
67
|
+
nextRow[header] != obj[key]) {
|
|
68
|
+
isReset = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (isMandatory && obj[key] == undefined) {
|
|
74
|
+
validationPassed = false;
|
|
75
|
+
errorMessage += `Error in column: ${headerExcel[j]} at row ${i + 1}\n`;
|
|
76
|
+
}
|
|
77
|
+
obj[key] = convertValue(type, obj[key]);
|
|
78
|
+
}
|
|
79
|
+
if (isReset) {
|
|
80
|
+
tempData = {};
|
|
81
|
+
}
|
|
82
|
+
dataPost.push(obj);
|
|
83
|
+
}
|
|
84
|
+
if (!validationPassed) {
|
|
85
|
+
throw new Error(errorMessage);
|
|
86
|
+
}
|
|
87
|
+
return dataPost;
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.error(`[error][${(0, helpers_1.getCurrentDate)()}] ${err.message}`);
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function convertValue(type, value) {
|
|
96
|
+
try {
|
|
97
|
+
if (value == undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
switch (type) {
|
|
100
|
+
case 'date':
|
|
101
|
+
return (0, helpers_1.convertDateTimeFormat)({
|
|
102
|
+
initialValue: (0, excelDateToJsDate_1.default)({ initialValue: value }).toString(),
|
|
103
|
+
dateTimeFormatFrom: constants_1.config.date_format_timestamp,
|
|
104
|
+
dateTimeFormatTo: constants_1.config.date_simple_format,
|
|
105
|
+
}).toString();
|
|
106
|
+
default:
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error(`[error][provis-read-excel] Failed to convert type: ${type}, value: ${value}, error: ${error.message}`);
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.default = readExcel;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import ISearchQuery from "../interface/search.query.interface";
|
|
2
|
+
import ISearchValue from "../interface/search.value.interface";
|
|
3
|
+
declare const _default: ({ searchValue, searchKey, operatorValue, keyName, }: ISearchValue) => ISearchQuery | undefined;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const operator_1 = require("../constants/operator");
|
|
4
|
+
exports.default = ({ searchValue, searchKey, operatorValue, keyName = searchKey, }) => {
|
|
5
|
+
/**
|
|
6
|
+
* EXAMPLE: insured=&companyName=&invoiceNumber=123&placingSlipNo=123&productCode=1234&minSumInsured=1000&maxSumInsured=100000&minPremium=100&maxPremium=10000&minPolicyIssueDate=&maxPolicyIssueDate=&minInvoiceIssueDate=&maxInvoiceIssueDate=&minSchedulePaymentDate=&maxSchedulePaymentDate=&minPaymentDate=&maxPaymentDate=&status=&maxCount=
|
|
7
|
+
*/
|
|
8
|
+
const value = searchValue[searchKey];
|
|
9
|
+
if (value) {
|
|
10
|
+
switch (operatorValue) {
|
|
11
|
+
case operator_1.default.OPERATOR_LIKE:
|
|
12
|
+
return {
|
|
13
|
+
query: `${keyName} iLike :${keyName}`,
|
|
14
|
+
key: keyName,
|
|
15
|
+
value: `%${value}%`,
|
|
16
|
+
};
|
|
17
|
+
case operator_1.default.OPERATOR_EXACTLY:
|
|
18
|
+
return {
|
|
19
|
+
query: `${keyName} = :${keyName}`,
|
|
20
|
+
key: keyName,
|
|
21
|
+
value,
|
|
22
|
+
};
|
|
23
|
+
case operator_1.default.OPERATOR_NUMBER_MIN:
|
|
24
|
+
return {
|
|
25
|
+
query: `${keyName} >= :${searchKey}`,
|
|
26
|
+
key: searchKey,
|
|
27
|
+
value,
|
|
28
|
+
};
|
|
29
|
+
case operator_1.default.OPERATOR_NUMBER_MAX:
|
|
30
|
+
return {
|
|
31
|
+
query: `${keyName} <= :${searchKey}`,
|
|
32
|
+
key: searchKey,
|
|
33
|
+
value,
|
|
34
|
+
};
|
|
35
|
+
case operator_1.default.OPERATOR_DATE_MIN:
|
|
36
|
+
return {
|
|
37
|
+
query: `${keyName} ::date >= :${searchKey}`,
|
|
38
|
+
key: searchKey,
|
|
39
|
+
value,
|
|
40
|
+
};
|
|
41
|
+
case operator_1.default.OPERATOR_DATE_MAX:
|
|
42
|
+
return {
|
|
43
|
+
query: `${keyName} ::date <= :${searchKey}`,
|
|
44
|
+
key: searchKey,
|
|
45
|
+
value,
|
|
46
|
+
};
|
|
47
|
+
case operator_1.default.OPERATOR_IN:
|
|
48
|
+
return {
|
|
49
|
+
query: `${keyName} IN (:...${searchKey})`,
|
|
50
|
+
key: searchKey,
|
|
51
|
+
value: value.split(','),
|
|
52
|
+
};
|
|
53
|
+
case operator_1.default.OPERATOR_NOT_IN:
|
|
54
|
+
return {
|
|
55
|
+
query: `${keyName} NOT IN (:...${searchKey})`,
|
|
56
|
+
key: searchKey,
|
|
57
|
+
value: value.split(','),
|
|
58
|
+
};
|
|
59
|
+
default:
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.helpers = exports.constants = void 0;
|
|
4
|
+
const constants = require("./constants");
|
|
5
|
+
exports.constants = constants;
|
|
6
|
+
const helpers = require("./helpers");
|
|
7
|
+
exports.helpers = helpers;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import IMultiJoin from "./multi.join.interface";
|
|
2
|
+
import ISearchQuery from "./search.query.interface";
|
|
3
|
+
export default interface IFindAllCount {
|
|
4
|
+
search: ISearchQuery[];
|
|
5
|
+
additionalSearchOr?: ISearchQuery[][];
|
|
6
|
+
sortBy?: string;
|
|
7
|
+
relations?: IMultiJoin[];
|
|
8
|
+
maxCount?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import IMultiJoin from "./multi.join.interface";
|
|
2
|
+
import ISearchQuery from "./search.query.interface";
|
|
3
|
+
import ISummaryField from "./summary.field.interface";
|
|
4
|
+
export default interface ISearchSummary {
|
|
5
|
+
fieldToSum: ISummaryField[];
|
|
6
|
+
search: ISearchQuery[];
|
|
7
|
+
additionalSearchOr?: ISearchQuery[][];
|
|
8
|
+
relations?: IMultiJoin[];
|
|
9
|
+
}
|