@provis/provis-common-be-module 2.3.26 → 2.3.28

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.
Files changed (135) hide show
  1. package/dist/class/main.repository.d.ts +27 -0
  2. package/dist/class/main.repository.js +303 -0
  3. package/dist/constants/brokerage.d.ts +25 -0
  4. package/dist/constants/brokerage.js +30 -0
  5. package/dist/constants/claim/document-container.d.ts +14 -0
  6. package/dist/constants/claim/document-container.js +65 -0
  7. package/dist/constants/claim/generalInsurance.d.ts +535 -0
  8. package/dist/constants/claim/generalInsurance.js +18 -0
  9. package/dist/constants/claim/kalog.d.ts +28 -0
  10. package/dist/constants/claim/kalog.js +186 -0
  11. package/dist/constants/claim/loket.d.ts +36 -0
  12. package/dist/constants/claim/loket.js +290 -0
  13. package/dist/constants/claim/motorVehicle.d.ts +158 -0
  14. package/dist/constants/claim/motorVehicle.js +139 -0
  15. package/dist/constants/claim/status.d.ts +137 -0
  16. package/dist/constants/claim/status.js +160 -0
  17. package/dist/constants/claim/travel.d.ts +358 -0
  18. package/dist/constants/claim/travel.js +268 -0
  19. package/dist/constants/config.d.ts +2 -0
  20. package/dist/constants/config.js +23 -0
  21. package/dist/constants/currency.d.ts +2 -0
  22. package/dist/constants/currency.js +7 -0
  23. package/dist/constants/index.d.ts +5 -0
  24. package/dist/constants/index.js +11 -0
  25. package/dist/constants/insurance.d.ts +7 -0
  26. package/dist/constants/insurance.js +965 -0
  27. package/dist/constants/join.d.ts +5 -0
  28. package/dist/constants/join.js +2 -0
  29. package/dist/constants/loket.d.ts +17 -0
  30. package/dist/constants/loket.js +19 -0
  31. package/dist/constants/martialStatus.d.ts +2 -0
  32. package/dist/constants/martialStatus.js +32 -0
  33. package/dist/constants/operator.d.ts +2 -0
  34. package/dist/constants/operator.js +12 -0
  35. package/dist/constants/product/cargo.d.ts +39 -0
  36. package/dist/constants/product/cargo.js +41 -0
  37. package/dist/constants/product/mv/clause.d.ts +52 -0
  38. package/dist/constants/product/mv/clause.js +214 -0
  39. package/dist/constants/product/mv/merk.d.ts +7 -0
  40. package/dist/constants/product/mv/merk.js +111 -0
  41. package/dist/constants/product/mv/mv.d.ts +48 -0
  42. package/dist/constants/product/mv/mv.js +215 -0
  43. package/dist/constants/product/mv/plat.d.ts +7 -0
  44. package/dist/constants/product/mv/plat.js +334 -0
  45. package/dist/constants/product/occupation.d.ts +5 -0
  46. package/dist/constants/product/occupation.js +25 -0
  47. package/dist/constants/product/policy.d.ts +31 -0
  48. package/dist/constants/product/policy.js +33 -0
  49. package/dist/constants/product.d.ts +72 -0
  50. package/dist/constants/product.js +394 -0
  51. package/dist/constants/quotation.d.ts +32 -0
  52. package/dist/constants/quotation.js +38 -0
  53. package/dist/constants/report.d.ts +46 -0
  54. package/dist/constants/report.js +60 -0
  55. package/dist/constants/vesselList.d.ts +5 -0
  56. package/dist/constants/vesselList.js +116 -0
  57. package/dist/helpers/addDateTime.d.ts +6 -0
  58. package/dist/helpers/addDateTime.js +30 -0
  59. package/dist/helpers/amountDescription.d.ts +1 -0
  60. package/dist/helpers/amountDescription.js +44 -0
  61. package/dist/helpers/axiosGet.d.ts +8 -0
  62. package/dist/helpers/axiosGet.js +47 -0
  63. package/dist/helpers/axiosPost.d.ts +8 -0
  64. package/dist/helpers/axiosPost.js +46 -0
  65. package/dist/helpers/axiosPut.d.ts +8 -0
  66. package/dist/helpers/axiosPut.js +46 -0
  67. package/dist/helpers/calculateByType.d.ts +5 -0
  68. package/dist/helpers/calculateByType.js +19 -0
  69. package/dist/helpers/calculateForNullable.d.ts +5 -0
  70. package/dist/helpers/calculateForNullable.js +46 -0
  71. package/dist/helpers/combineObj.d.ts +2 -0
  72. package/dist/helpers/combineObj.js +17 -0
  73. package/dist/helpers/compareDiffObj.d.ts +2 -0
  74. package/dist/helpers/compareDiffObj.js +14 -0
  75. package/dist/helpers/convertCurrencySymbol.d.ts +2 -0
  76. package/dist/helpers/convertCurrencySymbol.js +20 -0
  77. package/dist/helpers/convertDateTimeFormat.d.ts +6 -0
  78. package/dist/helpers/convertDateTimeFormat.js +113 -0
  79. package/dist/helpers/convertObjToNumber.d.ts +2 -0
  80. package/dist/helpers/convertObjToNumber.js +14 -0
  81. package/dist/helpers/convertToCurrency.d.ts +2 -0
  82. package/dist/helpers/convertToCurrency.js +21 -0
  83. package/dist/helpers/excelDateToJsDate.d.ts +4 -0
  84. package/dist/helpers/excelDateToJsDate.js +30 -0
  85. package/dist/helpers/filterObj.d.ts +2 -0
  86. package/dist/helpers/filterObj.js +9 -0
  87. package/dist/helpers/generateHashString.d.ts +2 -0
  88. package/dist/helpers/generateHashString.js +15 -0
  89. package/dist/helpers/generateRelationId.d.ts +2 -0
  90. package/dist/helpers/generateRelationId.js +15 -0
  91. package/dist/helpers/getCargoType.d.ts +2 -0
  92. package/dist/helpers/getCargoType.js +9 -0
  93. package/dist/helpers/getCurrentDate.d.ts +2 -0
  94. package/dist/helpers/getCurrentDate.js +11 -0
  95. package/dist/helpers/getDiffValue.d.ts +2 -0
  96. package/dist/helpers/getDiffValue.js +24 -0
  97. package/dist/helpers/getObjByKeys.d.ts +2 -0
  98. package/dist/helpers/getObjByKeys.js +19 -0
  99. package/dist/helpers/index.d.ts +25 -0
  100. package/dist/helpers/index.js +51 -0
  101. package/dist/helpers/loop.d.ts +2 -0
  102. package/dist/helpers/loop.js +21 -0
  103. package/dist/helpers/loopBackward.d.ts +2 -0
  104. package/dist/helpers/loopBackward.js +21 -0
  105. package/dist/helpers/mergeObj.d.ts +2 -0
  106. package/dist/helpers/mergeObj.js +16 -0
  107. package/dist/helpers/readExcel.d.ts +3 -0
  108. package/dist/helpers/readExcel.js +115 -0
  109. package/dist/helpers/searchValue.d.ts +4 -0
  110. package/dist/helpers/searchValue.js +63 -0
  111. package/dist/index.d.ts +3 -0
  112. package/dist/index.js +7 -0
  113. package/dist/interface/axios.interface.d.ts +5 -0
  114. package/dist/interface/axios.interface.js +2 -0
  115. package/dist/interface/find.all.count.interface.d.ts +10 -0
  116. package/dist/interface/find.all.count.interface.js +2 -0
  117. package/dist/interface/multi.join.interface.d.ts +9 -0
  118. package/dist/interface/multi.join.interface.js +2 -0
  119. package/dist/interface/read.excel.interface.d.ts +12 -0
  120. package/dist/interface/read.excel.interface.js +2 -0
  121. package/dist/interface/search.conditions.interface.d.ts +8 -0
  122. package/dist/interface/search.conditions.interface.js +2 -0
  123. package/dist/interface/search.initial.interface.d.ts +8 -0
  124. package/dist/interface/search.initial.interface.js +2 -0
  125. package/dist/interface/search.query.interface.d.ts +5 -0
  126. package/dist/interface/search.query.interface.js +3 -0
  127. package/dist/interface/search.summary.interface.d.ts +9 -0
  128. package/dist/interface/search.summary.interface.js +2 -0
  129. package/dist/interface/search.value.interface.d.ts +6 -0
  130. package/dist/interface/search.value.interface.js +3 -0
  131. package/dist/interface/summary.field.interface.d.ts +4 -0
  132. package/dist/interface/summary.field.interface.js +3 -0
  133. package/dist/interface/user.interface.d.ts +4 -0
  134. package/dist/interface/user.interface.js +2 -0
  135. package/package.json +2 -2
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getCurrentDate_1 = require("./getCurrentDate");
4
+ exports.default = (decimal, isCheckNegative = false) => {
5
+ try {
6
+ if (decimal === undefined || decimal === null)
7
+ return '-';
8
+ let currency = (typeof decimal === 'string') ? decimal = parseFloat(decimal) : decimal;
9
+ if (decimal === 0)
10
+ return '-';
11
+ if (isCheckNegative && currency < 0) {
12
+ currency = currency * -1;
13
+ return `(${currency.toLocaleString(undefined, { minimumFractionDigits: 0 })})`;
14
+ }
15
+ return currency.toLocaleString(undefined, { minimumFractionDigits: 0 });
16
+ }
17
+ catch (err) {
18
+ console.log(`[error][${(0, getCurrentDate_1.default)()}] Convert to currency error: ${err.message}`);
19
+ return '-';
20
+ }
21
+ };
@@ -0,0 +1,4 @@
1
+ declare const _default: ({ initialValue, }: {
2
+ initialValue: number;
3
+ }) => Date | number | string;
4
+ export default _default;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ({ initialValue, }) => {
4
+ try {
5
+ if (!initialValue) {
6
+ throw new Error('initial value is not found');
7
+ }
8
+ const datePattern = /^\d{2}-\d{2}-\d{4}$/;
9
+ if (datePattern.test(String(initialValue))) {
10
+ const parts = String(initialValue).split('-');
11
+ const day = parseInt(parts[0]);
12
+ const month = parseInt(parts[1]);
13
+ const year = parseInt(parts[2]);
14
+ return `${year}-${month}-${day}`;
15
+ }
16
+ const utc_days = Math.floor(initialValue - 25569);
17
+ const utc_value = utc_days * 86400;
18
+ const date_info = new Date(utc_value * 1000);
19
+ const fractional_day = initialValue - Math.floor(initialValue) + 0.0000001;
20
+ let total_seconds = Math.floor(86400 * fractional_day);
21
+ const seconds = total_seconds % 60;
22
+ total_seconds -= seconds;
23
+ const hours = Math.floor(total_seconds / (60 * 60));
24
+ const minutes = Math.floor(total_seconds / 60) % 60;
25
+ return new Date(date_info.getFullYear(), date_info.getMonth(), date_info.getDate(), hours, minutes, seconds);
26
+ }
27
+ catch (err) {
28
+ throw new Error(`error convert ${err.message}`);
29
+ }
30
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: (obj: any, filters: string[]) => {};
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4
+ exports.default = (obj, filters) => {
5
+ return Object.keys(obj).filter((key) => !filters.includes(key)).reduce((value, key) => {
6
+ value[key] = obj[key];
7
+ return value;
8
+ }, {});
9
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: (message: string) => Promise<string>;
2
+ export default _default;
@@ -0,0 +1,15 @@
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 sha512 = require("js-sha512");
13
+ exports.default = (message) => __awaiter(void 0, void 0, void 0, function* () {
14
+ return sha512.sha512(message);
15
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: (totalLength?: number) => string;
2
+ export default _default;
@@ -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,2 @@
1
+ declare function getCargoType(code: string, lang?: string): string | null;
2
+ export default getCargoType;
@@ -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,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -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,2 @@
1
+ declare const _default: (obj1: any, obj2: any) => Promise<any>;
2
+ export default _default;
@@ -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,2 @@
1
+ declare const _default: (obj: any, keys: string[]) => Promise<any>;
2
+ export default _default;
@@ -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,2 @@
1
+ declare function loop(list: any[], callback: (data: any) => Promise<any>, result?: any[]): Promise<any>;
2
+ export 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_1, callback_1) {
13
+ return __awaiter(this, arguments, void 0, function* (list, callback, result = []) {
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,2 @@
1
+ declare function loop(list: any[], callback: (data: any) => Promise<any>, result?: any[]): Promise<any>;
2
+ export 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_1, callback_1) {
13
+ return __awaiter(this, arguments, void 0, function* (list, callback, result = []) {
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,2 @@
1
+ declare const _default: (obj1: any, obj2: any) => any;
2
+ export default _default;
@@ -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,3 @@
1
+ import IReadExcel from '../interface/read.excel.interface';
2
+ declare function readExcel(file: Buffer, data: IReadExcel): Promise<any>;
3
+ export default readExcel;
@@ -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
+ };
@@ -0,0 +1,3 @@
1
+ import * as constants from './constants';
2
+ import * as helpers from './helpers';
3
+ export { constants, helpers, };
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,5 @@
1
+ export default interface IAxios<T> {
2
+ statusCode: number;
3
+ data?: T;
4
+ message?: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import Join from "../constants/join";
2
+ import ISearchQuery from "./search.query.interface";
3
+ export default interface IMultiJoin {
4
+ model: string;
5
+ aliasTable?: string;
6
+ join?: Join;
7
+ searchs?: ISearchQuery[];
8
+ additionalSearchOr?: ISearchQuery[][];
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ interface IListKey {
2
+ isMandatory: boolean;
3
+ type: string;
4
+ name: string;
5
+ }
6
+ interface IReadExcel {
7
+ listKey: IListKey[];
8
+ headerExcel: string[];
9
+ startRow?: number;
10
+ startColumn?: number;
11
+ }
12
+ export default IReadExcel;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import IMultiJoin from "./multi.join.interface";
2
+ import ISearchQuery from "./search.query.interface";
3
+ export default interface ISearchConditions {
4
+ query: any;
5
+ search?: ISearchQuery[];
6
+ additionalSearchOr?: ISearchQuery[][];
7
+ relations?: IMultiJoin[];
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import IUser from "./user.interface";
2
+ export default interface ISearchInitial {
3
+ search: any;
4
+ maxCount?: number;
5
+ offset?: number;
6
+ sortBy?: string;
7
+ user?: IUser | undefined;
8
+ }