av6-core 1.7.17 → 1.7.18
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/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +226 -19
- package/dist/index.mjs +275 -35
- package/package.json +1 -1
- package/prisma-client.d.ts +16 -0
package/dist/index.d.mts
CHANGED
|
@@ -809,10 +809,18 @@ declare class ApprovalService {
|
|
|
809
809
|
act({ instanceId, approverId, action, ccId, comment }: ActInput): Promise<any>;
|
|
810
810
|
private emitEvents;
|
|
811
811
|
private assertPermission;
|
|
812
|
+
getAllApprovalFlow(input: GetMyApprovalFlow): Promise<PaginatedResponse<ApprovalInstanceByUser>>;
|
|
813
|
+
getApprovalActDetailsBySubjectId(subjectId: number, subjectType: string, service: string): Promise<ApprovalAction[]>;
|
|
812
814
|
}
|
|
813
815
|
|
|
814
816
|
declare const approvalRepository: (helpers: Helpers) => {
|
|
815
817
|
findMatchingFlow(tx: PrismaClient | Prisma.TransactionClient, type: string, service: string, ccId: number, netTotal: number, level?: number): Promise<RawFlowWithSelectedStepResponse | null>;
|
|
818
|
+
getAllApprovalFlow(tx: PrismaClient | Prisma.TransactionClient, { staffId, ccId, pageNo, pageSize, service, sortDir, startDate, endDate, searchText, status, flowType, }: GetMyApprovalFlow): Promise<PaginatedResponse<ApprovalInstanceByUser>>;
|
|
819
|
+
getApprovalActDetailsBySubjectId(tx: PrismaClient | Prisma.TransactionClient, { subjectId, subjectType, service }: {
|
|
820
|
+
subjectId: number;
|
|
821
|
+
subjectType: string;
|
|
822
|
+
service: string;
|
|
823
|
+
}): Promise<any>;
|
|
816
824
|
};
|
|
817
825
|
|
|
818
826
|
declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K[]): {
|
package/dist/index.d.ts
CHANGED
|
@@ -809,10 +809,18 @@ declare class ApprovalService {
|
|
|
809
809
|
act({ instanceId, approverId, action, ccId, comment }: ActInput): Promise<any>;
|
|
810
810
|
private emitEvents;
|
|
811
811
|
private assertPermission;
|
|
812
|
+
getAllApprovalFlow(input: GetMyApprovalFlow): Promise<PaginatedResponse<ApprovalInstanceByUser>>;
|
|
813
|
+
getApprovalActDetailsBySubjectId(subjectId: number, subjectType: string, service: string): Promise<ApprovalAction[]>;
|
|
812
814
|
}
|
|
813
815
|
|
|
814
816
|
declare const approvalRepository: (helpers: Helpers) => {
|
|
815
817
|
findMatchingFlow(tx: PrismaClient | Prisma.TransactionClient, type: string, service: string, ccId: number, netTotal: number, level?: number): Promise<RawFlowWithSelectedStepResponse | null>;
|
|
818
|
+
getAllApprovalFlow(tx: PrismaClient | Prisma.TransactionClient, { staffId, ccId, pageNo, pageSize, service, sortDir, startDate, endDate, searchText, status, flowType, }: GetMyApprovalFlow): Promise<PaginatedResponse<ApprovalInstanceByUser>>;
|
|
819
|
+
getApprovalActDetailsBySubjectId(tx: PrismaClient | Prisma.TransactionClient, { subjectId, subjectType, service }: {
|
|
820
|
+
subjectId: number;
|
|
821
|
+
subjectType: string;
|
|
822
|
+
service: string;
|
|
823
|
+
}): Promise<any>;
|
|
816
824
|
};
|
|
817
825
|
|
|
818
826
|
declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K[]): {
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
8
14
|
var __export = (target, all) => {
|
|
9
15
|
for (var name in all)
|
|
10
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +33,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
33
|
));
|
|
28
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
35
|
|
|
36
|
+
// node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
|
|
37
|
+
var init_cjs_shims = __esm({
|
|
38
|
+
"node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
|
+
"use strict";
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// node_modules/.pnpm/@prisma+client@6.19.3_prisma@6.19.3_typescript@5.9.3__typescript@5.9.3/node_modules/@prisma/client/default.js
|
|
44
|
+
var require_default = __commonJS({
|
|
45
|
+
"node_modules/.pnpm/@prisma+client@6.19.3_prisma@6.19.3_typescript@5.9.3__typescript@5.9.3/node_modules/@prisma/client/default.js"(exports2, module2) {
|
|
46
|
+
"use strict";
|
|
47
|
+
init_cjs_shims();
|
|
48
|
+
module2.exports = {
|
|
49
|
+
...require(".prisma/client/default")
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
30
54
|
// src/index.ts
|
|
31
55
|
var index_exports = {};
|
|
32
56
|
__export(index_exports, {
|
|
@@ -57,8 +81,16 @@ __export(index_exports, {
|
|
|
57
81
|
uinConfigService: () => uinConfigService
|
|
58
82
|
});
|
|
59
83
|
module.exports = __toCommonJS(index_exports);
|
|
84
|
+
init_cjs_shims();
|
|
85
|
+
|
|
86
|
+
// src/services/common.service.ts
|
|
87
|
+
init_cjs_shims();
|
|
88
|
+
|
|
89
|
+
// src/repository/common.repository.ts
|
|
90
|
+
init_cjs_shims();
|
|
60
91
|
|
|
61
92
|
// src/utils/dynamicSearchHelper.ts
|
|
93
|
+
init_cjs_shims();
|
|
62
94
|
var import_assert = require("assert");
|
|
63
95
|
var import_util = require("util");
|
|
64
96
|
function buildNestedCondition(keys, searchText, isNot = false) {
|
|
@@ -1012,7 +1044,11 @@ var commonRepository = (serviceDeps) => {
|
|
|
1012
1044
|
};
|
|
1013
1045
|
};
|
|
1014
1046
|
|
|
1047
|
+
// src/repository/commonCreateUpdate.repository.ts
|
|
1048
|
+
init_cjs_shims();
|
|
1049
|
+
|
|
1015
1050
|
// src/utils/dynamicCreateUpdate.utils.ts
|
|
1051
|
+
init_cjs_shims();
|
|
1016
1052
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1017
1053
|
var getByPath = (root, path) => {
|
|
1018
1054
|
if (!path) return void 0;
|
|
@@ -1033,6 +1069,7 @@ var omitUndefined = (obj) => {
|
|
|
1033
1069
|
};
|
|
1034
1070
|
|
|
1035
1071
|
// src/utils/dynamicPrismaBuilder.utils.ts
|
|
1072
|
+
init_cjs_shims();
|
|
1036
1073
|
var resolveSrc = (f, env) => {
|
|
1037
1074
|
const src = f.src ?? `body.${f.db}`;
|
|
1038
1075
|
if (src.startsWith("body.")) return getByPath(env.body, src.slice(5));
|
|
@@ -1316,10 +1353,12 @@ var commonCreateUpdateRepository = (serviceDeps) => {
|
|
|
1316
1353
|
};
|
|
1317
1354
|
|
|
1318
1355
|
// src/utils/dynamicJoiBuilder.utils.ts
|
|
1356
|
+
init_cjs_shims();
|
|
1319
1357
|
var import_joi = __toESM(require("joi"));
|
|
1320
1358
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
1321
1359
|
|
|
1322
1360
|
// src/utils/helper.utils.ts
|
|
1361
|
+
init_cjs_shims();
|
|
1323
1362
|
var import_dayjs = __toESM(require("dayjs"));
|
|
1324
1363
|
function customOmit(obj, keys) {
|
|
1325
1364
|
const rest = { ...obj };
|
|
@@ -1651,6 +1690,7 @@ var buildJoiSchemaForOp = (cfg, op, ctx) => {
|
|
|
1651
1690
|
};
|
|
1652
1691
|
|
|
1653
1692
|
// src/utils/dynamicOperation.utils.ts
|
|
1693
|
+
init_cjs_shims();
|
|
1654
1694
|
var import_av6_utils = require("av6-utils");
|
|
1655
1695
|
var OP_PRECEDENCE = {
|
|
1656
1696
|
"u-": 3,
|
|
@@ -2304,7 +2344,34 @@ var commonService = (serviceDeps) => {
|
|
|
2304
2344
|
};
|
|
2305
2345
|
};
|
|
2306
2346
|
|
|
2347
|
+
// src/services/approval.service.ts
|
|
2348
|
+
init_cjs_shims();
|
|
2349
|
+
|
|
2307
2350
|
// src/repository/approval.repository.ts
|
|
2351
|
+
init_cjs_shims();
|
|
2352
|
+
|
|
2353
|
+
// src/types/approval.type.ts
|
|
2354
|
+
init_cjs_shims();
|
|
2355
|
+
var ApprovalStatus = /* @__PURE__ */ ((ApprovalStatus2) => {
|
|
2356
|
+
ApprovalStatus2[ApprovalStatus2["PENDING"] = 0] = "PENDING";
|
|
2357
|
+
ApprovalStatus2[ApprovalStatus2["PARTIALLY_APPROVED"] = 1] = "PARTIALLY_APPROVED";
|
|
2358
|
+
ApprovalStatus2[ApprovalStatus2["APPROVED"] = 2] = "APPROVED";
|
|
2359
|
+
ApprovalStatus2[ApprovalStatus2["REJECTED"] = 3] = "REJECTED";
|
|
2360
|
+
ApprovalStatus2[ApprovalStatus2["CANCELLED"] = 4] = "CANCELLED";
|
|
2361
|
+
return ApprovalStatus2;
|
|
2362
|
+
})(ApprovalStatus || {});
|
|
2363
|
+
var FlowType = /* @__PURE__ */ ((FlowType3) => {
|
|
2364
|
+
FlowType3[FlowType3["STATUS"] = 0] = "STATUS";
|
|
2365
|
+
FlowType3[FlowType3["CO_PAY"] = 1] = "CO_PAY";
|
|
2366
|
+
FlowType3[FlowType3["INDIVIDUAL_DISCOUNT"] = 2] = "INDIVIDUAL_DISCOUNT";
|
|
2367
|
+
FlowType3[FlowType3["OVERALL_DISCOUNT"] = 3] = "OVERALL_DISCOUNT";
|
|
2368
|
+
FlowType3[FlowType3["SPECIAL_DISCOUNT"] = 4] = "SPECIAL_DISCOUNT";
|
|
2369
|
+
FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
|
|
2370
|
+
return FlowType3;
|
|
2371
|
+
})(FlowType || {});
|
|
2372
|
+
|
|
2373
|
+
// src/repository/approval.repository.ts
|
|
2374
|
+
var import_client = __toESM(require_default());
|
|
2308
2375
|
var approvalRepository = (helpers) => {
|
|
2309
2376
|
return {
|
|
2310
2377
|
async findMatchingFlow(tx, type, service, ccId, netTotal, level = 1) {
|
|
@@ -2332,29 +2399,116 @@ var approvalRepository = (helpers) => {
|
|
|
2332
2399
|
throw new helpers.ErrorHandler(400, "No matching flow found.");
|
|
2333
2400
|
}
|
|
2334
2401
|
return result[0];
|
|
2402
|
+
},
|
|
2403
|
+
async getAllApprovalFlow(tx, {
|
|
2404
|
+
staffId,
|
|
2405
|
+
ccId,
|
|
2406
|
+
pageNo = 1,
|
|
2407
|
+
pageSize = 1e4,
|
|
2408
|
+
service,
|
|
2409
|
+
sortDir = "ASC",
|
|
2410
|
+
startDate,
|
|
2411
|
+
endDate,
|
|
2412
|
+
searchText = "",
|
|
2413
|
+
status = [0 /* PENDING */, 1 /* PARTIALLY_APPROVED */],
|
|
2414
|
+
flowType
|
|
2415
|
+
}) {
|
|
2416
|
+
const offset = (pageNo - 1) * pageSize;
|
|
2417
|
+
const serviceLike = `%${service}%`;
|
|
2418
|
+
const pattern = searchText ? `%${searchText.replace(/[%_]/g, "\\$&")}%` : "%";
|
|
2419
|
+
const validSortDir = sortDir === "DESC" ? "DESC" : "ASC";
|
|
2420
|
+
const baseWhereConditions = import_client.Prisma.sql`
|
|
2421
|
+
( cam.staff_id = ${staffId} or scc.staff_id = ${staffId} )
|
|
2422
|
+
and cai.status in (${import_client.Prisma.join(status)})
|
|
2423
|
+
and LOWER(cai.service) like LOWER(${serviceLike})
|
|
2424
|
+
and LOWER(cai.ref_no) like LOWER(${pattern})
|
|
2425
|
+
and cam.cc_id = ${ccId}
|
|
2426
|
+
and cai.is_active = 1
|
|
2427
|
+
and cas.is_active = 1
|
|
2428
|
+
and cam.is_active = 1`;
|
|
2429
|
+
let dateFilter = import_client.Prisma.empty;
|
|
2430
|
+
if (startDate && endDate) {
|
|
2431
|
+
const startDateTime = fromTimestampToSqlDatetime(startDate);
|
|
2432
|
+
const endDateTime = fromTimestampToSqlDatetime(endDate);
|
|
2433
|
+
dateFilter = import_client.Prisma.sql`and cai.created_at between ${startDateTime} and ${endDateTime}`;
|
|
2434
|
+
}
|
|
2435
|
+
let flowTypeFilter = import_client.Prisma.empty;
|
|
2436
|
+
if (flowType) {
|
|
2437
|
+
flowTypeFilter = import_client.Prisma.sql`and caf.flow_type = ${flowType}`;
|
|
2438
|
+
}
|
|
2439
|
+
const countQuery = import_client.Prisma.sql`
|
|
2440
|
+
SELECT COUNT(DISTINCT cai.id) as total
|
|
2441
|
+
FROM
|
|
2442
|
+
core_approval_instance cai
|
|
2443
|
+
JOIN core_approval_step cas on cai.current_step = cas.id
|
|
2444
|
+
JOIN core_approval_flow caf on cas.flow_id = caf.id
|
|
2445
|
+
JOIN core_approver_mapping cam on cas.id = cam.step_id and cam.is_active = 1
|
|
2446
|
+
LEFT JOIN staff_roles sr on sr.role_id = cam.role_id
|
|
2447
|
+
LEFT JOIN staff_collection_center scc on (scc.collection_center_id = cam.cc_id and scc.staff_id = sr.staff_id)
|
|
2448
|
+
LEFT JOIN staff s on s.id = cai.created_by
|
|
2449
|
+
WHERE
|
|
2450
|
+
${baseWhereConditions}
|
|
2451
|
+
${flowTypeFilter}
|
|
2452
|
+
${dateFilter}`;
|
|
2453
|
+
const countResult = await tx.$queryRaw(countQuery);
|
|
2454
|
+
const total = countResult[0]?.total ?? 0n;
|
|
2455
|
+
const dataQuery = import_client.Prisma.sql`
|
|
2456
|
+
SELECT DISTINCT
|
|
2457
|
+
cai.id,
|
|
2458
|
+
cai.flow_id as flowId,
|
|
2459
|
+
cai.subject_type as subjectType,
|
|
2460
|
+
cai.service as service,
|
|
2461
|
+
cai.subject_id as subjectId,
|
|
2462
|
+
cai.ref_no as refNo,
|
|
2463
|
+
cai.current_step as currentStepId,
|
|
2464
|
+
cai.net_total as netTotal,
|
|
2465
|
+
cai.status,
|
|
2466
|
+
cai.extra,
|
|
2467
|
+
s.name as createdBy,
|
|
2468
|
+
caf.flow_type as flowType,
|
|
2469
|
+
caf.name as flowName,
|
|
2470
|
+
cai.created_at as createdAt,
|
|
2471
|
+
cas.level
|
|
2472
|
+
FROM
|
|
2473
|
+
core_approval_instance cai
|
|
2474
|
+
JOIN core_approval_step cas on cai.current_step = cas.id
|
|
2475
|
+
JOIN core_approval_flow caf on cas.flow_id = caf.id
|
|
2476
|
+
JOIN core_approver_mapping cam on cas.id = cam.step_id and cam.is_active = 1
|
|
2477
|
+
LEFT JOIN staff_roles sr on sr.role_id = cam.role_id
|
|
2478
|
+
LEFT JOIN staff_collection_center scc on (scc.collection_center_id = cam.cc_id and scc.staff_id = sr.staff_id)
|
|
2479
|
+
LEFT JOIN staff s on s.id = cai.created_by
|
|
2480
|
+
WHERE
|
|
2481
|
+
${baseWhereConditions}
|
|
2482
|
+
${flowTypeFilter}
|
|
2483
|
+
${dateFilter}
|
|
2484
|
+
GROUP BY cai.id
|
|
2485
|
+
ORDER BY cai.id ${import_client.Prisma.raw(validSortDir)}
|
|
2486
|
+
LIMIT ${pageSize}
|
|
2487
|
+
OFFSET ${offset}`;
|
|
2488
|
+
const result = await tx.$queryRaw(dataQuery);
|
|
2489
|
+
return {
|
|
2490
|
+
data: result,
|
|
2491
|
+
totalRecords: Number(total),
|
|
2492
|
+
currentPageNumber: pageNo,
|
|
2493
|
+
lastPageNumber: Math.ceil(Number(total) / pageSize),
|
|
2494
|
+
pageSize
|
|
2495
|
+
};
|
|
2496
|
+
},
|
|
2497
|
+
async getApprovalActDetailsBySubjectId(tx, { subjectId, subjectType, service }) {
|
|
2498
|
+
return tx.approvalAction.findMany({
|
|
2499
|
+
where: {
|
|
2500
|
+
approvalInstance: {
|
|
2501
|
+
subjectType,
|
|
2502
|
+
subjectId,
|
|
2503
|
+
service
|
|
2504
|
+
},
|
|
2505
|
+
isActive: true
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2335
2508
|
}
|
|
2336
2509
|
};
|
|
2337
2510
|
};
|
|
2338
2511
|
|
|
2339
|
-
// src/types/approval.type.ts
|
|
2340
|
-
var ApprovalStatus = /* @__PURE__ */ ((ApprovalStatus2) => {
|
|
2341
|
-
ApprovalStatus2[ApprovalStatus2["PENDING"] = 0] = "PENDING";
|
|
2342
|
-
ApprovalStatus2[ApprovalStatus2["PARTIALLY_APPROVED"] = 1] = "PARTIALLY_APPROVED";
|
|
2343
|
-
ApprovalStatus2[ApprovalStatus2["APPROVED"] = 2] = "APPROVED";
|
|
2344
|
-
ApprovalStatus2[ApprovalStatus2["REJECTED"] = 3] = "REJECTED";
|
|
2345
|
-
ApprovalStatus2[ApprovalStatus2["CANCELLED"] = 4] = "CANCELLED";
|
|
2346
|
-
return ApprovalStatus2;
|
|
2347
|
-
})(ApprovalStatus || {});
|
|
2348
|
-
var FlowType = /* @__PURE__ */ ((FlowType3) => {
|
|
2349
|
-
FlowType3[FlowType3["STATUS"] = 0] = "STATUS";
|
|
2350
|
-
FlowType3[FlowType3["CO_PAY"] = 1] = "CO_PAY";
|
|
2351
|
-
FlowType3[FlowType3["INDIVIDUAL_DISCOUNT"] = 2] = "INDIVIDUAL_DISCOUNT";
|
|
2352
|
-
FlowType3[FlowType3["OVERALL_DISCOUNT"] = 3] = "OVERALL_DISCOUNT";
|
|
2353
|
-
FlowType3[FlowType3["SPECIAL_DISCOUNT"] = 4] = "SPECIAL_DISCOUNT";
|
|
2354
|
-
FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
|
|
2355
|
-
return FlowType3;
|
|
2356
|
-
})(FlowType || {});
|
|
2357
|
-
|
|
2358
2512
|
// src/services/approval.service.ts
|
|
2359
2513
|
var ApprovalService = class {
|
|
2360
2514
|
constructor(deps) {
|
|
@@ -2610,9 +2764,22 @@ var ApprovalService = class {
|
|
|
2610
2764
|
}
|
|
2611
2765
|
return step;
|
|
2612
2766
|
}
|
|
2767
|
+
async getAllApprovalFlow(input) {
|
|
2768
|
+
this.deps.logger.info("entering:getAllApprovalFlow --" + JSON.stringify({ input }));
|
|
2769
|
+
const instance = await this.approvalRepo.getAllApprovalFlow(this.deps.prisma, input);
|
|
2770
|
+
this.deps.logger.info("exiting:getAllApprovalFlow --" + JSON.stringify({ instance }));
|
|
2771
|
+
return instance;
|
|
2772
|
+
}
|
|
2773
|
+
async getApprovalActDetailsBySubjectId(subjectId, subjectType, service) {
|
|
2774
|
+
this.deps.logger.info(
|
|
2775
|
+
"entering:getApprovalActDetailsBySubjectId --" + JSON.stringify({ subjectId, subjectType, service })
|
|
2776
|
+
);
|
|
2777
|
+
return this.approvalRepo.getApprovalActDetailsBySubjectId(this.deps.prisma, { subjectId, subjectType, service });
|
|
2778
|
+
}
|
|
2613
2779
|
};
|
|
2614
2780
|
|
|
2615
2781
|
// src/utils/audit.utils.ts
|
|
2782
|
+
init_cjs_shims();
|
|
2616
2783
|
function isValidDate(value) {
|
|
2617
2784
|
if (value instanceof Date) {
|
|
2618
2785
|
return !isNaN(value.getTime());
|
|
@@ -2660,6 +2827,7 @@ function findDifferences(obj1, obj2) {
|
|
|
2660
2827
|
}
|
|
2661
2828
|
|
|
2662
2829
|
// src/utils/renderer.ts
|
|
2830
|
+
init_cjs_shims();
|
|
2663
2831
|
var import_handlebars = __toESM(require("handlebars"));
|
|
2664
2832
|
function renderTemplate(tpl, data) {
|
|
2665
2833
|
return import_handlebars.default.compile(tpl)(data);
|
|
@@ -2693,7 +2861,17 @@ var convertArrayPatternToEachBlocksGeneric = (html) => {
|
|
|
2693
2861
|
return output;
|
|
2694
2862
|
};
|
|
2695
2863
|
|
|
2864
|
+
// src/types/common.ts
|
|
2865
|
+
init_cjs_shims();
|
|
2866
|
+
|
|
2867
|
+
// src/types/dynamicCreateUpdate.type.ts
|
|
2868
|
+
init_cjs_shims();
|
|
2869
|
+
|
|
2870
|
+
// src/services/uinConfig.service.ts
|
|
2871
|
+
init_cjs_shims();
|
|
2872
|
+
|
|
2696
2873
|
// src/mapper/uinConfig.mapper.ts
|
|
2874
|
+
init_cjs_shims();
|
|
2697
2875
|
var toUINConfigDTO = (model) => {
|
|
2698
2876
|
return {
|
|
2699
2877
|
id: model.id,
|
|
@@ -2711,6 +2889,7 @@ var toUINConfigDTO = (model) => {
|
|
|
2711
2889
|
};
|
|
2712
2890
|
|
|
2713
2891
|
// src/repository/uinConfig.repository.ts
|
|
2892
|
+
init_cjs_shims();
|
|
2714
2893
|
var uinConfigRepository = (uinDeps) => {
|
|
2715
2894
|
const db = uinDeps.db;
|
|
2716
2895
|
const logger = uinDeps.logger;
|
|
@@ -2796,6 +2975,7 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2796
2975
|
};
|
|
2797
2976
|
|
|
2798
2977
|
// src/validation/uinConfig.service.validation.ts
|
|
2978
|
+
init_cjs_shims();
|
|
2799
2979
|
var uinConfigServiceValidation = (uinDeps) => {
|
|
2800
2980
|
const { generateErrorMessage, ErrorHandler } = uinDeps.helpers;
|
|
2801
2981
|
const logger = uinDeps.logger;
|
|
@@ -2997,7 +3177,20 @@ var uinConfigService = (uinDeps) => {
|
|
|
2997
3177
|
};
|
|
2998
3178
|
};
|
|
2999
3179
|
|
|
3180
|
+
// src/types/uinConfig.ts
|
|
3181
|
+
init_cjs_shims();
|
|
3182
|
+
|
|
3183
|
+
// src/events/eventEmitter.ts
|
|
3184
|
+
init_cjs_shims();
|
|
3185
|
+
|
|
3186
|
+
// src/services/audit.service.ts
|
|
3187
|
+
init_cjs_shims();
|
|
3188
|
+
|
|
3189
|
+
// src/services/notification.service.ts
|
|
3190
|
+
init_cjs_shims();
|
|
3191
|
+
|
|
3000
3192
|
// src/providers/app.provider.ts
|
|
3193
|
+
init_cjs_shims();
|
|
3001
3194
|
var ExpoAppNotificationProvider = class {
|
|
3002
3195
|
constructor(logger = console, url = "https://api.expo.dev/v2/push/send") {
|
|
3003
3196
|
this.logger = logger;
|
|
@@ -3035,7 +3228,11 @@ var ExpoAppNotificationProvider = class {
|
|
|
3035
3228
|
}
|
|
3036
3229
|
};
|
|
3037
3230
|
|
|
3231
|
+
// src/providers/email.providers.ts
|
|
3232
|
+
init_cjs_shims();
|
|
3233
|
+
|
|
3038
3234
|
// src/types/notification.ts
|
|
3235
|
+
init_cjs_shims();
|
|
3039
3236
|
var TemplateType = /* @__PURE__ */ ((TemplateType2) => {
|
|
3040
3237
|
TemplateType2["EMAIL"] = "EMAIL";
|
|
3041
3238
|
TemplateType2["SMS"] = "SMS";
|
|
@@ -3125,6 +3322,7 @@ var EmailProvider = class {
|
|
|
3125
3322
|
};
|
|
3126
3323
|
|
|
3127
3324
|
// src/providers/sms.provider.ts
|
|
3325
|
+
init_cjs_shims();
|
|
3128
3326
|
var import_axios2 = __toESM(require("axios"));
|
|
3129
3327
|
var import_node_https = __toESM(require("https"));
|
|
3130
3328
|
var import_promises = __toESM(require("dns/promises"));
|
|
@@ -3275,6 +3473,7 @@ var SmsProvider = class {
|
|
|
3275
3473
|
};
|
|
3276
3474
|
|
|
3277
3475
|
// src/providers/web.provider.ts
|
|
3476
|
+
init_cjs_shims();
|
|
3278
3477
|
var WebNotificationProvider = class {
|
|
3279
3478
|
constructor(prisma, logger = console) {
|
|
3280
3479
|
this.prisma = prisma;
|
|
@@ -3318,9 +3517,11 @@ var WebNotificationProvider = class {
|
|
|
3318
3517
|
};
|
|
3319
3518
|
|
|
3320
3519
|
// src/providers/whatsapp.provider.ts
|
|
3520
|
+
init_cjs_shims();
|
|
3321
3521
|
var import_axios3 = __toESM(require("axios"));
|
|
3322
3522
|
|
|
3323
3523
|
// src/utils/notification.utils.ts
|
|
3524
|
+
init_cjs_shims();
|
|
3324
3525
|
function defaultValueField(t) {
|
|
3325
3526
|
if (t === "EMAIL") return "EMAIL";
|
|
3326
3527
|
if (t === "APP_NOTIFICATION") return "USER_ID";
|
|
@@ -4479,7 +4680,11 @@ var NotificationEmitter = class {
|
|
|
4479
4680
|
}
|
|
4480
4681
|
};
|
|
4481
4682
|
|
|
4683
|
+
// src/types/audit.ts
|
|
4684
|
+
init_cjs_shims();
|
|
4685
|
+
|
|
4482
4686
|
// src/audit/audit.core.ts
|
|
4687
|
+
init_cjs_shims();
|
|
4483
4688
|
var AuditCore = class {
|
|
4484
4689
|
prisma;
|
|
4485
4690
|
contextProvider;
|
|
@@ -4501,6 +4706,7 @@ var AuditCore = class {
|
|
|
4501
4706
|
};
|
|
4502
4707
|
|
|
4503
4708
|
// src/audit/audit.logger.ts
|
|
4709
|
+
init_cjs_shims();
|
|
4504
4710
|
var AuditLogger = class {
|
|
4505
4711
|
core;
|
|
4506
4712
|
constructor(core) {
|
|
@@ -4552,6 +4758,7 @@ var AuditLogger = class {
|
|
|
4552
4758
|
};
|
|
4553
4759
|
|
|
4554
4760
|
// src/audit/audit.proxy.ts
|
|
4761
|
+
init_cjs_shims();
|
|
4555
4762
|
var AuditProxy = class {
|
|
4556
4763
|
logger;
|
|
4557
4764
|
constructor(logger) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __esm = (fn, res) => function __init() {
|
|
14
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
+
};
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
+
mod
|
|
34
|
+
));
|
|
35
|
+
|
|
36
|
+
// node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
37
|
+
import path from "path";
|
|
38
|
+
import { fileURLToPath } from "url";
|
|
39
|
+
var init_esm_shims = __esm({
|
|
40
|
+
"node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
41
|
+
"use strict";
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// node_modules/.pnpm/@prisma+client@6.19.3_prisma@6.19.3_typescript@5.9.3__typescript@5.9.3/node_modules/@prisma/client/default.js
|
|
46
|
+
var require_default = __commonJS({
|
|
47
|
+
"node_modules/.pnpm/@prisma+client@6.19.3_prisma@6.19.3_typescript@5.9.3__typescript@5.9.3/node_modules/@prisma/client/default.js"(exports, module) {
|
|
48
|
+
"use strict";
|
|
49
|
+
init_esm_shims();
|
|
50
|
+
module.exports = {
|
|
51
|
+
...__require(".prisma/client/default")
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// src/index.ts
|
|
57
|
+
init_esm_shims();
|
|
58
|
+
|
|
59
|
+
// src/services/common.service.ts
|
|
60
|
+
init_esm_shims();
|
|
61
|
+
|
|
62
|
+
// src/repository/common.repository.ts
|
|
63
|
+
init_esm_shims();
|
|
64
|
+
|
|
1
65
|
// src/utils/dynamicSearchHelper.ts
|
|
66
|
+
init_esm_shims();
|
|
2
67
|
import { deepStrictEqual as deepEqual } from "assert";
|
|
3
68
|
import { isDeepStrictEqual } from "util";
|
|
4
69
|
function buildNestedCondition(keys, searchText, isNot = false) {
|
|
@@ -203,9 +268,9 @@ function buildNestedConditionForSingleValue(keys, fieldType, val, isNot = false)
|
|
|
203
268
|
}
|
|
204
269
|
function buildPrismaSelect(mapping) {
|
|
205
270
|
const select = {};
|
|
206
|
-
for (const
|
|
207
|
-
if (typeof
|
|
208
|
-
const parts =
|
|
271
|
+
for (const path2 of Object.values(mapping)) {
|
|
272
|
+
if (typeof path2 !== "string") continue;
|
|
273
|
+
const parts = path2.split(".").map((s) => s.trim()).filter(Boolean);
|
|
209
274
|
if (!parts.length) continue;
|
|
210
275
|
let cur = select;
|
|
211
276
|
for (let i = 0; i < parts.length; i++) {
|
|
@@ -232,8 +297,8 @@ function buildPrismaSelect(mapping) {
|
|
|
232
297
|
}
|
|
233
298
|
return select;
|
|
234
299
|
}
|
|
235
|
-
function getByPathOrNull(row,
|
|
236
|
-
const parts = String(
|
|
300
|
+
function getByPathOrNull(row, path2) {
|
|
301
|
+
const parts = String(path2 || "").split(".").map((p) => p.trim()).filter(Boolean);
|
|
237
302
|
let cur = row;
|
|
238
303
|
for (const key of parts) {
|
|
239
304
|
if (cur == null) return null;
|
|
@@ -243,8 +308,8 @@ function getByPathOrNull(row, path) {
|
|
|
243
308
|
}
|
|
244
309
|
function toDynamicDropdownDto(mapping, row) {
|
|
245
310
|
const out = {};
|
|
246
|
-
for (const [dtoKey,
|
|
247
|
-
out[dtoKey] = getByPathOrNull(row,
|
|
311
|
+
for (const [dtoKey, path2] of Object.entries(mapping)) {
|
|
312
|
+
out[dtoKey] = getByPathOrNull(row, path2);
|
|
248
313
|
}
|
|
249
314
|
return out;
|
|
250
315
|
}
|
|
@@ -952,11 +1017,15 @@ var commonRepository = (serviceDeps) => {
|
|
|
952
1017
|
};
|
|
953
1018
|
};
|
|
954
1019
|
|
|
1020
|
+
// src/repository/commonCreateUpdate.repository.ts
|
|
1021
|
+
init_esm_shims();
|
|
1022
|
+
|
|
955
1023
|
// src/utils/dynamicCreateUpdate.utils.ts
|
|
1024
|
+
init_esm_shims();
|
|
956
1025
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
957
|
-
var getByPath = (root,
|
|
958
|
-
if (!
|
|
959
|
-
const parts =
|
|
1026
|
+
var getByPath = (root, path2) => {
|
|
1027
|
+
if (!path2) return void 0;
|
|
1028
|
+
const parts = path2.split(".");
|
|
960
1029
|
let cur = root;
|
|
961
1030
|
for (const p of parts) {
|
|
962
1031
|
if (!isRecord(cur)) return void 0;
|
|
@@ -973,6 +1042,7 @@ var omitUndefined = (obj) => {
|
|
|
973
1042
|
};
|
|
974
1043
|
|
|
975
1044
|
// src/utils/dynamicPrismaBuilder.utils.ts
|
|
1045
|
+
init_esm_shims();
|
|
976
1046
|
var resolveSrc = (f, env) => {
|
|
977
1047
|
const src = f.src ?? `body.${f.db}`;
|
|
978
1048
|
if (src.startsWith("body.")) return getByPath(env.body, src.slice(5));
|
|
@@ -1256,10 +1326,12 @@ var commonCreateUpdateRepository = (serviceDeps) => {
|
|
|
1256
1326
|
};
|
|
1257
1327
|
|
|
1258
1328
|
// src/utils/dynamicJoiBuilder.utils.ts
|
|
1329
|
+
init_esm_shims();
|
|
1259
1330
|
import Joi from "joi";
|
|
1260
1331
|
import dayjs2 from "dayjs";
|
|
1261
1332
|
|
|
1262
1333
|
// src/utils/helper.utils.ts
|
|
1334
|
+
init_esm_shims();
|
|
1263
1335
|
import dayjs from "dayjs";
|
|
1264
1336
|
function customOmit(obj, keys) {
|
|
1265
1337
|
const rest = { ...obj };
|
|
@@ -1282,18 +1354,18 @@ function getDynamicValue(obj, accessorKey) {
|
|
|
1282
1354
|
}
|
|
1283
1355
|
return result === void 0 ? null : result;
|
|
1284
1356
|
}
|
|
1285
|
-
function getNestedValue(obj,
|
|
1286
|
-
if (!obj || !
|
|
1287
|
-
const normalizedPath =
|
|
1357
|
+
function getNestedValue(obj, path2, defaultValue) {
|
|
1358
|
+
if (!obj || !path2) return defaultValue;
|
|
1359
|
+
const normalizedPath = path2.replace(/\[(\d+)\]/g, ".$1");
|
|
1288
1360
|
const result = normalizedPath.split(".").reduce((acc, key) => {
|
|
1289
1361
|
if (acc == null) return void 0;
|
|
1290
1362
|
return acc[key];
|
|
1291
1363
|
}, obj);
|
|
1292
1364
|
return result === void 0 ? defaultValue : result;
|
|
1293
1365
|
}
|
|
1294
|
-
function getNestedValueV2(obj,
|
|
1295
|
-
if (!obj || !
|
|
1296
|
-
const normalizedPath =
|
|
1366
|
+
function getNestedValueV2(obj, path2, defaultValue) {
|
|
1367
|
+
if (!obj || !path2) return defaultValue;
|
|
1368
|
+
const normalizedPath = path2.replace(/\[(\d+)\]/g, ".$1");
|
|
1297
1369
|
const keys = normalizedPath.split(".");
|
|
1298
1370
|
const resolve = (current, index) => {
|
|
1299
1371
|
if (current == null) return void 0;
|
|
@@ -1591,6 +1663,7 @@ var buildJoiSchemaForOp = (cfg, op, ctx) => {
|
|
|
1591
1663
|
};
|
|
1592
1664
|
|
|
1593
1665
|
// src/utils/dynamicOperation.utils.ts
|
|
1666
|
+
init_esm_shims();
|
|
1594
1667
|
import { applyRound } from "av6-utils";
|
|
1595
1668
|
var OP_PRECEDENCE = {
|
|
1596
1669
|
"u-": 3,
|
|
@@ -2244,7 +2317,34 @@ var commonService = (serviceDeps) => {
|
|
|
2244
2317
|
};
|
|
2245
2318
|
};
|
|
2246
2319
|
|
|
2320
|
+
// src/services/approval.service.ts
|
|
2321
|
+
init_esm_shims();
|
|
2322
|
+
|
|
2323
|
+
// src/repository/approval.repository.ts
|
|
2324
|
+
init_esm_shims();
|
|
2325
|
+
|
|
2326
|
+
// src/types/approval.type.ts
|
|
2327
|
+
init_esm_shims();
|
|
2328
|
+
var ApprovalStatus = /* @__PURE__ */ ((ApprovalStatus2) => {
|
|
2329
|
+
ApprovalStatus2[ApprovalStatus2["PENDING"] = 0] = "PENDING";
|
|
2330
|
+
ApprovalStatus2[ApprovalStatus2["PARTIALLY_APPROVED"] = 1] = "PARTIALLY_APPROVED";
|
|
2331
|
+
ApprovalStatus2[ApprovalStatus2["APPROVED"] = 2] = "APPROVED";
|
|
2332
|
+
ApprovalStatus2[ApprovalStatus2["REJECTED"] = 3] = "REJECTED";
|
|
2333
|
+
ApprovalStatus2[ApprovalStatus2["CANCELLED"] = 4] = "CANCELLED";
|
|
2334
|
+
return ApprovalStatus2;
|
|
2335
|
+
})(ApprovalStatus || {});
|
|
2336
|
+
var FlowType = /* @__PURE__ */ ((FlowType3) => {
|
|
2337
|
+
FlowType3[FlowType3["STATUS"] = 0] = "STATUS";
|
|
2338
|
+
FlowType3[FlowType3["CO_PAY"] = 1] = "CO_PAY";
|
|
2339
|
+
FlowType3[FlowType3["INDIVIDUAL_DISCOUNT"] = 2] = "INDIVIDUAL_DISCOUNT";
|
|
2340
|
+
FlowType3[FlowType3["OVERALL_DISCOUNT"] = 3] = "OVERALL_DISCOUNT";
|
|
2341
|
+
FlowType3[FlowType3["SPECIAL_DISCOUNT"] = 4] = "SPECIAL_DISCOUNT";
|
|
2342
|
+
FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
|
|
2343
|
+
return FlowType3;
|
|
2344
|
+
})(FlowType || {});
|
|
2345
|
+
|
|
2247
2346
|
// src/repository/approval.repository.ts
|
|
2347
|
+
var import_client = __toESM(require_default());
|
|
2248
2348
|
var approvalRepository = (helpers) => {
|
|
2249
2349
|
return {
|
|
2250
2350
|
async findMatchingFlow(tx, type, service, ccId, netTotal, level = 1) {
|
|
@@ -2272,29 +2372,116 @@ var approvalRepository = (helpers) => {
|
|
|
2272
2372
|
throw new helpers.ErrorHandler(400, "No matching flow found.");
|
|
2273
2373
|
}
|
|
2274
2374
|
return result[0];
|
|
2375
|
+
},
|
|
2376
|
+
async getAllApprovalFlow(tx, {
|
|
2377
|
+
staffId,
|
|
2378
|
+
ccId,
|
|
2379
|
+
pageNo = 1,
|
|
2380
|
+
pageSize = 1e4,
|
|
2381
|
+
service,
|
|
2382
|
+
sortDir = "ASC",
|
|
2383
|
+
startDate,
|
|
2384
|
+
endDate,
|
|
2385
|
+
searchText = "",
|
|
2386
|
+
status = [0 /* PENDING */, 1 /* PARTIALLY_APPROVED */],
|
|
2387
|
+
flowType
|
|
2388
|
+
}) {
|
|
2389
|
+
const offset = (pageNo - 1) * pageSize;
|
|
2390
|
+
const serviceLike = `%${service}%`;
|
|
2391
|
+
const pattern = searchText ? `%${searchText.replace(/[%_]/g, "\\$&")}%` : "%";
|
|
2392
|
+
const validSortDir = sortDir === "DESC" ? "DESC" : "ASC";
|
|
2393
|
+
const baseWhereConditions = import_client.Prisma.sql`
|
|
2394
|
+
( cam.staff_id = ${staffId} or scc.staff_id = ${staffId} )
|
|
2395
|
+
and cai.status in (${import_client.Prisma.join(status)})
|
|
2396
|
+
and LOWER(cai.service) like LOWER(${serviceLike})
|
|
2397
|
+
and LOWER(cai.ref_no) like LOWER(${pattern})
|
|
2398
|
+
and cam.cc_id = ${ccId}
|
|
2399
|
+
and cai.is_active = 1
|
|
2400
|
+
and cas.is_active = 1
|
|
2401
|
+
and cam.is_active = 1`;
|
|
2402
|
+
let dateFilter = import_client.Prisma.empty;
|
|
2403
|
+
if (startDate && endDate) {
|
|
2404
|
+
const startDateTime = fromTimestampToSqlDatetime(startDate);
|
|
2405
|
+
const endDateTime = fromTimestampToSqlDatetime(endDate);
|
|
2406
|
+
dateFilter = import_client.Prisma.sql`and cai.created_at between ${startDateTime} and ${endDateTime}`;
|
|
2407
|
+
}
|
|
2408
|
+
let flowTypeFilter = import_client.Prisma.empty;
|
|
2409
|
+
if (flowType) {
|
|
2410
|
+
flowTypeFilter = import_client.Prisma.sql`and caf.flow_type = ${flowType}`;
|
|
2411
|
+
}
|
|
2412
|
+
const countQuery = import_client.Prisma.sql`
|
|
2413
|
+
SELECT COUNT(DISTINCT cai.id) as total
|
|
2414
|
+
FROM
|
|
2415
|
+
core_approval_instance cai
|
|
2416
|
+
JOIN core_approval_step cas on cai.current_step = cas.id
|
|
2417
|
+
JOIN core_approval_flow caf on cas.flow_id = caf.id
|
|
2418
|
+
JOIN core_approver_mapping cam on cas.id = cam.step_id and cam.is_active = 1
|
|
2419
|
+
LEFT JOIN staff_roles sr on sr.role_id = cam.role_id
|
|
2420
|
+
LEFT JOIN staff_collection_center scc on (scc.collection_center_id = cam.cc_id and scc.staff_id = sr.staff_id)
|
|
2421
|
+
LEFT JOIN staff s on s.id = cai.created_by
|
|
2422
|
+
WHERE
|
|
2423
|
+
${baseWhereConditions}
|
|
2424
|
+
${flowTypeFilter}
|
|
2425
|
+
${dateFilter}`;
|
|
2426
|
+
const countResult = await tx.$queryRaw(countQuery);
|
|
2427
|
+
const total = countResult[0]?.total ?? 0n;
|
|
2428
|
+
const dataQuery = import_client.Prisma.sql`
|
|
2429
|
+
SELECT DISTINCT
|
|
2430
|
+
cai.id,
|
|
2431
|
+
cai.flow_id as flowId,
|
|
2432
|
+
cai.subject_type as subjectType,
|
|
2433
|
+
cai.service as service,
|
|
2434
|
+
cai.subject_id as subjectId,
|
|
2435
|
+
cai.ref_no as refNo,
|
|
2436
|
+
cai.current_step as currentStepId,
|
|
2437
|
+
cai.net_total as netTotal,
|
|
2438
|
+
cai.status,
|
|
2439
|
+
cai.extra,
|
|
2440
|
+
s.name as createdBy,
|
|
2441
|
+
caf.flow_type as flowType,
|
|
2442
|
+
caf.name as flowName,
|
|
2443
|
+
cai.created_at as createdAt,
|
|
2444
|
+
cas.level
|
|
2445
|
+
FROM
|
|
2446
|
+
core_approval_instance cai
|
|
2447
|
+
JOIN core_approval_step cas on cai.current_step = cas.id
|
|
2448
|
+
JOIN core_approval_flow caf on cas.flow_id = caf.id
|
|
2449
|
+
JOIN core_approver_mapping cam on cas.id = cam.step_id and cam.is_active = 1
|
|
2450
|
+
LEFT JOIN staff_roles sr on sr.role_id = cam.role_id
|
|
2451
|
+
LEFT JOIN staff_collection_center scc on (scc.collection_center_id = cam.cc_id and scc.staff_id = sr.staff_id)
|
|
2452
|
+
LEFT JOIN staff s on s.id = cai.created_by
|
|
2453
|
+
WHERE
|
|
2454
|
+
${baseWhereConditions}
|
|
2455
|
+
${flowTypeFilter}
|
|
2456
|
+
${dateFilter}
|
|
2457
|
+
GROUP BY cai.id
|
|
2458
|
+
ORDER BY cai.id ${import_client.Prisma.raw(validSortDir)}
|
|
2459
|
+
LIMIT ${pageSize}
|
|
2460
|
+
OFFSET ${offset}`;
|
|
2461
|
+
const result = await tx.$queryRaw(dataQuery);
|
|
2462
|
+
return {
|
|
2463
|
+
data: result,
|
|
2464
|
+
totalRecords: Number(total),
|
|
2465
|
+
currentPageNumber: pageNo,
|
|
2466
|
+
lastPageNumber: Math.ceil(Number(total) / pageSize),
|
|
2467
|
+
pageSize
|
|
2468
|
+
};
|
|
2469
|
+
},
|
|
2470
|
+
async getApprovalActDetailsBySubjectId(tx, { subjectId, subjectType, service }) {
|
|
2471
|
+
return tx.approvalAction.findMany({
|
|
2472
|
+
where: {
|
|
2473
|
+
approvalInstance: {
|
|
2474
|
+
subjectType,
|
|
2475
|
+
subjectId,
|
|
2476
|
+
service
|
|
2477
|
+
},
|
|
2478
|
+
isActive: true
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2275
2481
|
}
|
|
2276
2482
|
};
|
|
2277
2483
|
};
|
|
2278
2484
|
|
|
2279
|
-
// src/types/approval.type.ts
|
|
2280
|
-
var ApprovalStatus = /* @__PURE__ */ ((ApprovalStatus2) => {
|
|
2281
|
-
ApprovalStatus2[ApprovalStatus2["PENDING"] = 0] = "PENDING";
|
|
2282
|
-
ApprovalStatus2[ApprovalStatus2["PARTIALLY_APPROVED"] = 1] = "PARTIALLY_APPROVED";
|
|
2283
|
-
ApprovalStatus2[ApprovalStatus2["APPROVED"] = 2] = "APPROVED";
|
|
2284
|
-
ApprovalStatus2[ApprovalStatus2["REJECTED"] = 3] = "REJECTED";
|
|
2285
|
-
ApprovalStatus2[ApprovalStatus2["CANCELLED"] = 4] = "CANCELLED";
|
|
2286
|
-
return ApprovalStatus2;
|
|
2287
|
-
})(ApprovalStatus || {});
|
|
2288
|
-
var FlowType = /* @__PURE__ */ ((FlowType3) => {
|
|
2289
|
-
FlowType3[FlowType3["STATUS"] = 0] = "STATUS";
|
|
2290
|
-
FlowType3[FlowType3["CO_PAY"] = 1] = "CO_PAY";
|
|
2291
|
-
FlowType3[FlowType3["INDIVIDUAL_DISCOUNT"] = 2] = "INDIVIDUAL_DISCOUNT";
|
|
2292
|
-
FlowType3[FlowType3["OVERALL_DISCOUNT"] = 3] = "OVERALL_DISCOUNT";
|
|
2293
|
-
FlowType3[FlowType3["SPECIAL_DISCOUNT"] = 4] = "SPECIAL_DISCOUNT";
|
|
2294
|
-
FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
|
|
2295
|
-
return FlowType3;
|
|
2296
|
-
})(FlowType || {});
|
|
2297
|
-
|
|
2298
2485
|
// src/services/approval.service.ts
|
|
2299
2486
|
var ApprovalService = class {
|
|
2300
2487
|
constructor(deps) {
|
|
@@ -2550,9 +2737,22 @@ var ApprovalService = class {
|
|
|
2550
2737
|
}
|
|
2551
2738
|
return step;
|
|
2552
2739
|
}
|
|
2740
|
+
async getAllApprovalFlow(input) {
|
|
2741
|
+
this.deps.logger.info("entering:getAllApprovalFlow --" + JSON.stringify({ input }));
|
|
2742
|
+
const instance = await this.approvalRepo.getAllApprovalFlow(this.deps.prisma, input);
|
|
2743
|
+
this.deps.logger.info("exiting:getAllApprovalFlow --" + JSON.stringify({ instance }));
|
|
2744
|
+
return instance;
|
|
2745
|
+
}
|
|
2746
|
+
async getApprovalActDetailsBySubjectId(subjectId, subjectType, service) {
|
|
2747
|
+
this.deps.logger.info(
|
|
2748
|
+
"entering:getApprovalActDetailsBySubjectId --" + JSON.stringify({ subjectId, subjectType, service })
|
|
2749
|
+
);
|
|
2750
|
+
return this.approvalRepo.getApprovalActDetailsBySubjectId(this.deps.prisma, { subjectId, subjectType, service });
|
|
2751
|
+
}
|
|
2553
2752
|
};
|
|
2554
2753
|
|
|
2555
2754
|
// src/utils/audit.utils.ts
|
|
2755
|
+
init_esm_shims();
|
|
2556
2756
|
function isValidDate(value) {
|
|
2557
2757
|
if (value instanceof Date) {
|
|
2558
2758
|
return !isNaN(value.getTime());
|
|
@@ -2600,6 +2800,7 @@ function findDifferences(obj1, obj2) {
|
|
|
2600
2800
|
}
|
|
2601
2801
|
|
|
2602
2802
|
// src/utils/renderer.ts
|
|
2803
|
+
init_esm_shims();
|
|
2603
2804
|
import Handlebars from "handlebars";
|
|
2604
2805
|
function renderTemplate(tpl, data) {
|
|
2605
2806
|
return Handlebars.compile(tpl)(data);
|
|
@@ -2633,7 +2834,17 @@ var convertArrayPatternToEachBlocksGeneric = (html) => {
|
|
|
2633
2834
|
return output;
|
|
2634
2835
|
};
|
|
2635
2836
|
|
|
2837
|
+
// src/types/common.ts
|
|
2838
|
+
init_esm_shims();
|
|
2839
|
+
|
|
2840
|
+
// src/types/dynamicCreateUpdate.type.ts
|
|
2841
|
+
init_esm_shims();
|
|
2842
|
+
|
|
2843
|
+
// src/services/uinConfig.service.ts
|
|
2844
|
+
init_esm_shims();
|
|
2845
|
+
|
|
2636
2846
|
// src/mapper/uinConfig.mapper.ts
|
|
2847
|
+
init_esm_shims();
|
|
2637
2848
|
var toUINConfigDTO = (model) => {
|
|
2638
2849
|
return {
|
|
2639
2850
|
id: model.id,
|
|
@@ -2651,6 +2862,7 @@ var toUINConfigDTO = (model) => {
|
|
|
2651
2862
|
};
|
|
2652
2863
|
|
|
2653
2864
|
// src/repository/uinConfig.repository.ts
|
|
2865
|
+
init_esm_shims();
|
|
2654
2866
|
var uinConfigRepository = (uinDeps) => {
|
|
2655
2867
|
const db = uinDeps.db;
|
|
2656
2868
|
const logger = uinDeps.logger;
|
|
@@ -2736,6 +2948,7 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2736
2948
|
};
|
|
2737
2949
|
|
|
2738
2950
|
// src/validation/uinConfig.service.validation.ts
|
|
2951
|
+
init_esm_shims();
|
|
2739
2952
|
var uinConfigServiceValidation = (uinDeps) => {
|
|
2740
2953
|
const { generateErrorMessage, ErrorHandler } = uinDeps.helpers;
|
|
2741
2954
|
const logger = uinDeps.logger;
|
|
@@ -2937,7 +3150,20 @@ var uinConfigService = (uinDeps) => {
|
|
|
2937
3150
|
};
|
|
2938
3151
|
};
|
|
2939
3152
|
|
|
3153
|
+
// src/types/uinConfig.ts
|
|
3154
|
+
init_esm_shims();
|
|
3155
|
+
|
|
3156
|
+
// src/events/eventEmitter.ts
|
|
3157
|
+
init_esm_shims();
|
|
3158
|
+
|
|
3159
|
+
// src/services/audit.service.ts
|
|
3160
|
+
init_esm_shims();
|
|
3161
|
+
|
|
3162
|
+
// src/services/notification.service.ts
|
|
3163
|
+
init_esm_shims();
|
|
3164
|
+
|
|
2940
3165
|
// src/providers/app.provider.ts
|
|
3166
|
+
init_esm_shims();
|
|
2941
3167
|
var ExpoAppNotificationProvider = class {
|
|
2942
3168
|
constructor(logger = console, url = "https://api.expo.dev/v2/push/send") {
|
|
2943
3169
|
this.logger = logger;
|
|
@@ -2975,7 +3201,11 @@ var ExpoAppNotificationProvider = class {
|
|
|
2975
3201
|
}
|
|
2976
3202
|
};
|
|
2977
3203
|
|
|
3204
|
+
// src/providers/email.providers.ts
|
|
3205
|
+
init_esm_shims();
|
|
3206
|
+
|
|
2978
3207
|
// src/types/notification.ts
|
|
3208
|
+
init_esm_shims();
|
|
2979
3209
|
var TemplateType = /* @__PURE__ */ ((TemplateType2) => {
|
|
2980
3210
|
TemplateType2["EMAIL"] = "EMAIL";
|
|
2981
3211
|
TemplateType2["SMS"] = "SMS";
|
|
@@ -3065,6 +3295,7 @@ var EmailProvider = class {
|
|
|
3065
3295
|
};
|
|
3066
3296
|
|
|
3067
3297
|
// src/providers/sms.provider.ts
|
|
3298
|
+
init_esm_shims();
|
|
3068
3299
|
import axios2 from "axios";
|
|
3069
3300
|
import https from "https";
|
|
3070
3301
|
import dns from "dns/promises";
|
|
@@ -3215,6 +3446,7 @@ var SmsProvider = class {
|
|
|
3215
3446
|
};
|
|
3216
3447
|
|
|
3217
3448
|
// src/providers/web.provider.ts
|
|
3449
|
+
init_esm_shims();
|
|
3218
3450
|
var WebNotificationProvider = class {
|
|
3219
3451
|
constructor(prisma, logger = console) {
|
|
3220
3452
|
this.prisma = prisma;
|
|
@@ -3258,9 +3490,11 @@ var WebNotificationProvider = class {
|
|
|
3258
3490
|
};
|
|
3259
3491
|
|
|
3260
3492
|
// src/providers/whatsapp.provider.ts
|
|
3493
|
+
init_esm_shims();
|
|
3261
3494
|
import axios3 from "axios";
|
|
3262
3495
|
|
|
3263
3496
|
// src/utils/notification.utils.ts
|
|
3497
|
+
init_esm_shims();
|
|
3264
3498
|
function defaultValueField(t) {
|
|
3265
3499
|
if (t === "EMAIL") return "EMAIL";
|
|
3266
3500
|
if (t === "APP_NOTIFICATION") return "USER_ID";
|
|
@@ -4419,7 +4653,11 @@ var NotificationEmitter = class {
|
|
|
4419
4653
|
}
|
|
4420
4654
|
};
|
|
4421
4655
|
|
|
4656
|
+
// src/types/audit.ts
|
|
4657
|
+
init_esm_shims();
|
|
4658
|
+
|
|
4422
4659
|
// src/audit/audit.core.ts
|
|
4660
|
+
init_esm_shims();
|
|
4423
4661
|
var AuditCore = class {
|
|
4424
4662
|
prisma;
|
|
4425
4663
|
contextProvider;
|
|
@@ -4441,6 +4679,7 @@ var AuditCore = class {
|
|
|
4441
4679
|
};
|
|
4442
4680
|
|
|
4443
4681
|
// src/audit/audit.logger.ts
|
|
4682
|
+
init_esm_shims();
|
|
4444
4683
|
var AuditLogger = class {
|
|
4445
4684
|
core;
|
|
4446
4685
|
constructor(core) {
|
|
@@ -4492,6 +4731,7 @@ var AuditLogger = class {
|
|
|
4492
4731
|
};
|
|
4493
4732
|
|
|
4494
4733
|
// src/audit/audit.proxy.ts
|
|
4734
|
+
init_esm_shims();
|
|
4495
4735
|
var AuditProxy = class {
|
|
4496
4736
|
logger;
|
|
4497
4737
|
constructor(logger) {
|
package/package.json
CHANGED
package/prisma-client.d.ts
CHANGED
|
@@ -8,5 +8,21 @@ declare module "@prisma/client" {
|
|
|
8
8
|
export type JsonValue = any;
|
|
9
9
|
export type JsonObject = any;
|
|
10
10
|
export type JsonArray = any;
|
|
11
|
+
|
|
12
|
+
export interface Sql {
|
|
13
|
+
readonly values: unknown[];
|
|
14
|
+
readonly strings: string[];
|
|
15
|
+
readonly sql: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const empty: Sql;
|
|
19
|
+
export function sql(strings: readonly string[], ...values: unknown[]): Sql;
|
|
20
|
+
export function join(
|
|
21
|
+
values: readonly unknown[],
|
|
22
|
+
separator?: string,
|
|
23
|
+
prefix?: string,
|
|
24
|
+
suffix?: string
|
|
25
|
+
): Sql;
|
|
26
|
+
export function raw(value: string): Sql;
|
|
11
27
|
}
|
|
12
28
|
}
|