av6-core 1.9.2 → 2.0.0
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 +15 -11
- package/dist/index.d.ts +15 -11
- package/dist/index.js +14 -11
- package/dist/index.mjs +14 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { JsonValue, Decimal, DecimalJsLike, InputJsonValue } from '@prisma/client/runtime/library';
|
|
2
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
2
|
import { AxiosResponse } from 'axios';
|
|
4
3
|
import ExcelJs from 'exceljs';
|
|
@@ -306,9 +305,9 @@ type DynamicShortCode = {
|
|
|
306
305
|
isSingleDto?: boolean;
|
|
307
306
|
isDropDown?: boolean;
|
|
308
307
|
permission?: string | null;
|
|
309
|
-
whereClause?: JsonValue | null;
|
|
310
|
-
selectClause?: JsonValue | null;
|
|
311
|
-
config?: JsonValue | null;
|
|
308
|
+
whereClause?: Prisma.JsonValue | null;
|
|
309
|
+
selectClause?: Prisma.JsonValue | null;
|
|
310
|
+
config?: Prisma.JsonValue | null;
|
|
312
311
|
};
|
|
313
312
|
interface UpdateConfigByCodeInput extends Pick<DynamicShortCode, "config"> {
|
|
314
313
|
shortCode: string;
|
|
@@ -441,7 +440,7 @@ type DataType = {
|
|
|
441
440
|
interface CacheAdapter {
|
|
442
441
|
getCacheById(key: string, id: number | string): Promise<any | undefined>;
|
|
443
442
|
updateCache(key: string, id: number | string, value: unknown): Promise<void>;
|
|
444
|
-
createCache(table: string, data: DataType[]): Promise<void>;
|
|
443
|
+
createCache?(table: string, data: DataType[]): Promise<void>;
|
|
445
444
|
deleteCache(key: string, id: number | string): Promise<void>;
|
|
446
445
|
addToCache(key: string, id: number | string, data: unknown): Promise<void>;
|
|
447
446
|
}
|
|
@@ -499,6 +498,7 @@ interface Deps {
|
|
|
499
498
|
cacheAdapter: CacheAdapter;
|
|
500
499
|
requestStorage: AsyncLocalStorage<Store>;
|
|
501
500
|
db: TxClient;
|
|
501
|
+
getDb?: () => PrismaClient;
|
|
502
502
|
}
|
|
503
503
|
interface CommonServiceResponse {
|
|
504
504
|
search: (searchParams: SearchRequestService<DynamicShortCode>) => Promise<unknown>;
|
|
@@ -545,11 +545,11 @@ type ApprovalStep = {
|
|
|
545
545
|
id?: number;
|
|
546
546
|
flowId: number;
|
|
547
547
|
level: number;
|
|
548
|
-
minAmount?: Decimal | DecimalJsLike | number | string | null;
|
|
549
|
-
maxAmount?: Decimal | DecimalJsLike | number | string | null;
|
|
548
|
+
minAmount?: Prisma.Decimal | Prisma.DecimalJsLike | number | string | null;
|
|
549
|
+
maxAmount?: Prisma.Decimal | Prisma.DecimalJsLike | number | string | null;
|
|
550
550
|
stepType?: StepType;
|
|
551
|
-
config?:
|
|
552
|
-
childConfig?:
|
|
551
|
+
config?: Prisma.JsonValue;
|
|
552
|
+
childConfig?: Prisma.JsonValue;
|
|
553
553
|
isActive?: boolean;
|
|
554
554
|
createdBy?: number | null;
|
|
555
555
|
updatedBy?: number | null;
|
|
@@ -576,9 +576,9 @@ type ApprovalInstance = {
|
|
|
576
576
|
subjectId: number;
|
|
577
577
|
refNo?: string | null;
|
|
578
578
|
currentStep: number;
|
|
579
|
-
netTotal?: Decimal | DecimalJsLike | number | string | null;
|
|
579
|
+
netTotal?: Prisma.Decimal | Prisma.DecimalJsLike | number | string | null;
|
|
580
580
|
status?: ApprovalStatus;
|
|
581
|
-
extra?: JsonValue |
|
|
581
|
+
extra?: Prisma.JsonValue | null;
|
|
582
582
|
isActive?: boolean;
|
|
583
583
|
createdBy?: number | null;
|
|
584
584
|
updatedBy?: number | null;
|
|
@@ -804,12 +804,14 @@ interface ApprovalDeps {
|
|
|
804
804
|
requestStorage: AsyncLocalStorage<Store>;
|
|
805
805
|
prisma: PrismaClient;
|
|
806
806
|
eventBus: EventEmitter;
|
|
807
|
+
getDb?: () => PrismaClient;
|
|
807
808
|
}
|
|
808
809
|
type PrismaTransactionClient = Omit<PrismaClient, "$connect" | "$disconnect" | "$on" | "$transaction" | "$use" | "$extends">;
|
|
809
810
|
|
|
810
811
|
declare class ApprovalService {
|
|
811
812
|
private deps;
|
|
812
813
|
private approvalRepo;
|
|
814
|
+
private prisma;
|
|
813
815
|
constructor(deps: ApprovalDeps);
|
|
814
816
|
startFlow(tx: PrismaClient | PrismaTransactionClient, { service, subjectType, subjectId, netTotal, ccId, refNo, level, extra }: StartFlowReq): Promise<void>;
|
|
815
817
|
lastLevel(steps: ApprovalStep[]): Promise<number>;
|
|
@@ -897,6 +899,7 @@ interface UinDeps {
|
|
|
897
899
|
db: PrismaClient;
|
|
898
900
|
prisma: typeof PrismaNamespace;
|
|
899
901
|
modelName?: string;
|
|
902
|
+
getDb?: () => PrismaClient;
|
|
900
903
|
}
|
|
901
904
|
type UINSegmentType = "text" | "separator" | "dateFormat" | "sequenceNo";
|
|
902
905
|
type UIN_RESET_POLICY = "daily" | "weekly" | "monthly" | "yearly" | "no";
|
|
@@ -968,6 +971,7 @@ type NotificationEmitterDeps = {
|
|
|
968
971
|
logger?: ILogger;
|
|
969
972
|
envMode?: "Production" | "Development";
|
|
970
973
|
helpers: Helpers;
|
|
974
|
+
getDb?: () => PrismaClient;
|
|
971
975
|
};
|
|
972
976
|
|
|
973
977
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { JsonValue, Decimal, DecimalJsLike, InputJsonValue } from '@prisma/client/runtime/library';
|
|
2
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
2
|
import { AxiosResponse } from 'axios';
|
|
4
3
|
import ExcelJs from 'exceljs';
|
|
@@ -306,9 +305,9 @@ type DynamicShortCode = {
|
|
|
306
305
|
isSingleDto?: boolean;
|
|
307
306
|
isDropDown?: boolean;
|
|
308
307
|
permission?: string | null;
|
|
309
|
-
whereClause?: JsonValue | null;
|
|
310
|
-
selectClause?: JsonValue | null;
|
|
311
|
-
config?: JsonValue | null;
|
|
308
|
+
whereClause?: Prisma.JsonValue | null;
|
|
309
|
+
selectClause?: Prisma.JsonValue | null;
|
|
310
|
+
config?: Prisma.JsonValue | null;
|
|
312
311
|
};
|
|
313
312
|
interface UpdateConfigByCodeInput extends Pick<DynamicShortCode, "config"> {
|
|
314
313
|
shortCode: string;
|
|
@@ -441,7 +440,7 @@ type DataType = {
|
|
|
441
440
|
interface CacheAdapter {
|
|
442
441
|
getCacheById(key: string, id: number | string): Promise<any | undefined>;
|
|
443
442
|
updateCache(key: string, id: number | string, value: unknown): Promise<void>;
|
|
444
|
-
createCache(table: string, data: DataType[]): Promise<void>;
|
|
443
|
+
createCache?(table: string, data: DataType[]): Promise<void>;
|
|
445
444
|
deleteCache(key: string, id: number | string): Promise<void>;
|
|
446
445
|
addToCache(key: string, id: number | string, data: unknown): Promise<void>;
|
|
447
446
|
}
|
|
@@ -499,6 +498,7 @@ interface Deps {
|
|
|
499
498
|
cacheAdapter: CacheAdapter;
|
|
500
499
|
requestStorage: AsyncLocalStorage<Store>;
|
|
501
500
|
db: TxClient;
|
|
501
|
+
getDb?: () => PrismaClient;
|
|
502
502
|
}
|
|
503
503
|
interface CommonServiceResponse {
|
|
504
504
|
search: (searchParams: SearchRequestService<DynamicShortCode>) => Promise<unknown>;
|
|
@@ -545,11 +545,11 @@ type ApprovalStep = {
|
|
|
545
545
|
id?: number;
|
|
546
546
|
flowId: number;
|
|
547
547
|
level: number;
|
|
548
|
-
minAmount?: Decimal | DecimalJsLike | number | string | null;
|
|
549
|
-
maxAmount?: Decimal | DecimalJsLike | number | string | null;
|
|
548
|
+
minAmount?: Prisma.Decimal | Prisma.DecimalJsLike | number | string | null;
|
|
549
|
+
maxAmount?: Prisma.Decimal | Prisma.DecimalJsLike | number | string | null;
|
|
550
550
|
stepType?: StepType;
|
|
551
|
-
config?:
|
|
552
|
-
childConfig?:
|
|
551
|
+
config?: Prisma.JsonValue;
|
|
552
|
+
childConfig?: Prisma.JsonValue;
|
|
553
553
|
isActive?: boolean;
|
|
554
554
|
createdBy?: number | null;
|
|
555
555
|
updatedBy?: number | null;
|
|
@@ -576,9 +576,9 @@ type ApprovalInstance = {
|
|
|
576
576
|
subjectId: number;
|
|
577
577
|
refNo?: string | null;
|
|
578
578
|
currentStep: number;
|
|
579
|
-
netTotal?: Decimal | DecimalJsLike | number | string | null;
|
|
579
|
+
netTotal?: Prisma.Decimal | Prisma.DecimalJsLike | number | string | null;
|
|
580
580
|
status?: ApprovalStatus;
|
|
581
|
-
extra?: JsonValue |
|
|
581
|
+
extra?: Prisma.JsonValue | null;
|
|
582
582
|
isActive?: boolean;
|
|
583
583
|
createdBy?: number | null;
|
|
584
584
|
updatedBy?: number | null;
|
|
@@ -804,12 +804,14 @@ interface ApprovalDeps {
|
|
|
804
804
|
requestStorage: AsyncLocalStorage<Store>;
|
|
805
805
|
prisma: PrismaClient;
|
|
806
806
|
eventBus: EventEmitter;
|
|
807
|
+
getDb?: () => PrismaClient;
|
|
807
808
|
}
|
|
808
809
|
type PrismaTransactionClient = Omit<PrismaClient, "$connect" | "$disconnect" | "$on" | "$transaction" | "$use" | "$extends">;
|
|
809
810
|
|
|
810
811
|
declare class ApprovalService {
|
|
811
812
|
private deps;
|
|
812
813
|
private approvalRepo;
|
|
814
|
+
private prisma;
|
|
813
815
|
constructor(deps: ApprovalDeps);
|
|
814
816
|
startFlow(tx: PrismaClient | PrismaTransactionClient, { service, subjectType, subjectId, netTotal, ccId, refNo, level, extra }: StartFlowReq): Promise<void>;
|
|
815
817
|
lastLevel(steps: ApprovalStep[]): Promise<number>;
|
|
@@ -897,6 +899,7 @@ interface UinDeps {
|
|
|
897
899
|
db: PrismaClient;
|
|
898
900
|
prisma: typeof PrismaNamespace;
|
|
899
901
|
modelName?: string;
|
|
902
|
+
getDb?: () => PrismaClient;
|
|
900
903
|
}
|
|
901
904
|
type UINSegmentType = "text" | "separator" | "dateFormat" | "sequenceNo";
|
|
902
905
|
type UIN_RESET_POLICY = "daily" | "weekly" | "monthly" | "yearly" | "no";
|
|
@@ -968,6 +971,7 @@ type NotificationEmitterDeps = {
|
|
|
968
971
|
logger?: ILogger;
|
|
969
972
|
envMode?: "Production" | "Development";
|
|
970
973
|
helpers: Helpers;
|
|
974
|
+
getDb?: () => PrismaClient;
|
|
971
975
|
};
|
|
972
976
|
|
|
973
977
|
/**
|
package/dist/index.js
CHANGED
|
@@ -462,10 +462,9 @@ function normalizeWhere(where) {
|
|
|
462
462
|
var import_util2 = require("util");
|
|
463
463
|
var commonRepository = (serviceDeps) => {
|
|
464
464
|
const { mappingExport, mappingImport, dtoMapping } = serviceDeps.mapper;
|
|
465
|
-
const db = serviceDeps.db;
|
|
465
|
+
const db = serviceDeps?.getDb?.() ?? serviceDeps.db;
|
|
466
466
|
const { generateErrorMessage, ErrorHandler } = serviceDeps.helpers;
|
|
467
467
|
const logger = serviceDeps.logger;
|
|
468
|
-
const createCache = serviceDeps.cacheAdapter.createCache;
|
|
469
468
|
const requestStorage = serviceDeps.requestStorage;
|
|
470
469
|
return {
|
|
471
470
|
async commonSearch({
|
|
@@ -1161,7 +1160,7 @@ var buildPrismaData = (cfg, op, validatedBody, ctx) => {
|
|
|
1161
1160
|
|
|
1162
1161
|
// src/repository/commonCreateUpdate.repository.ts
|
|
1163
1162
|
var commonCreateUpdateRepository = (serviceDeps) => {
|
|
1164
|
-
const db = serviceDeps.db;
|
|
1163
|
+
const db = serviceDeps?.getDb?.() ?? serviceDeps.db;
|
|
1165
1164
|
const { ErrorHandler } = serviceDeps.helpers;
|
|
1166
1165
|
return {
|
|
1167
1166
|
getDelegate(tableName) {
|
|
@@ -1896,7 +1895,7 @@ var import_joi2 = __toESM(require("joi"));
|
|
|
1896
1895
|
var commonService = (serviceDeps) => {
|
|
1897
1896
|
const generateErrorMessage = serviceDeps.helpers.generateErrorMessage;
|
|
1898
1897
|
const ErrorHandler = serviceDeps.helpers.ErrorHandler;
|
|
1899
|
-
const { deleteCache, getCacheById, updateCache,
|
|
1898
|
+
const { deleteCache, getCacheById, updateCache, addToCache } = serviceDeps.cacheAdapter;
|
|
1900
1899
|
const logger = serviceDeps.logger;
|
|
1901
1900
|
const dtoMapping = serviceDeps.mapper.dtoMapping;
|
|
1902
1901
|
const validationMapping = serviceDeps.mapper.validationMapping;
|
|
@@ -2345,6 +2344,7 @@ var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
|
|
|
2345
2344
|
// src/repository/approval.repository.ts
|
|
2346
2345
|
var import_client = require("@prisma/client");
|
|
2347
2346
|
var approvalRepository = (deps) => {
|
|
2347
|
+
const prisma = deps.getDb?.() ?? deps.prisma;
|
|
2348
2348
|
return {
|
|
2349
2349
|
async findMatchingFlow(tx, type, service, ccId, netTotal, level = 1) {
|
|
2350
2350
|
const result = await tx.$queryRaw`
|
|
@@ -2493,14 +2493,14 @@ var approvalRepository = (deps) => {
|
|
|
2493
2493
|
SET ${import_client.Prisma.join(setFragments, ", ")}
|
|
2494
2494
|
WHERE id = ${data.id};
|
|
2495
2495
|
`;
|
|
2496
|
-
await
|
|
2496
|
+
await prisma.$queryRaw(query);
|
|
2497
2497
|
},
|
|
2498
2498
|
async commonParentChildUpdate(config, childConfig, inst) {
|
|
2499
2499
|
deps.logger.info("entering::commonRefundUpdate::repository");
|
|
2500
2500
|
const { tableName: parentTableName, ...parentTableConfig } = config;
|
|
2501
2501
|
const { tableName: childTableName, ...childTableConfig } = childConfig ?? {};
|
|
2502
2502
|
const parentId = inst.subjectId;
|
|
2503
|
-
await
|
|
2503
|
+
await prisma.$transaction(async (tx) => {
|
|
2504
2504
|
const commonDetails = await this.getChildCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2505
2505
|
const parentDetails = await this.getParentCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2506
2506
|
if (!parentDetails) {
|
|
@@ -2596,10 +2596,12 @@ var externalInterceptor = () => {
|
|
|
2596
2596
|
var ApprovalService = class {
|
|
2597
2597
|
constructor(deps) {
|
|
2598
2598
|
this.deps = deps;
|
|
2599
|
+
this.prisma = deps.getDb?.() ?? deps.prisma;
|
|
2599
2600
|
this.approvalRepo = approvalRepository(deps);
|
|
2600
2601
|
}
|
|
2601
2602
|
deps;
|
|
2602
2603
|
approvalRepo;
|
|
2604
|
+
prisma;
|
|
2603
2605
|
async startFlow(tx, { service, subjectType, subjectId, netTotal, ccId, refNo, level = 1, extra }) {
|
|
2604
2606
|
const store = this.deps.requestStorage.getStore();
|
|
2605
2607
|
const currentUser = store?.user?.id;
|
|
@@ -2648,7 +2650,7 @@ var ApprovalService = class {
|
|
|
2648
2650
|
}
|
|
2649
2651
|
/** Approver clicks “Approve” or “Reject”. */
|
|
2650
2652
|
async act({ instanceId, approverId, action, ccId, comment }) {
|
|
2651
|
-
return this.
|
|
2653
|
+
return this.prisma.$transaction(async (tx) => {
|
|
2652
2654
|
const inst = await tx.approvalInstance.findUnique({
|
|
2653
2655
|
where: { id: instanceId },
|
|
2654
2656
|
include: { flow: { where: { isActive: true }, include: { steps: { where: { isActive: true } } } } }
|
|
@@ -2929,7 +2931,7 @@ var ApprovalService = class {
|
|
|
2929
2931
|
}
|
|
2930
2932
|
async getAllApprovalFlow(input) {
|
|
2931
2933
|
this.deps.logger.info("entering:getAllApprovalFlow --" + JSON.stringify({ input }));
|
|
2932
|
-
const instance = await this.approvalRepo.getAllApprovalFlow(this.
|
|
2934
|
+
const instance = await this.approvalRepo.getAllApprovalFlow(this.prisma, input);
|
|
2933
2935
|
this.deps.logger.info("exiting:getAllApprovalFlow --" + JSON.stringify({ instance }));
|
|
2934
2936
|
return instance;
|
|
2935
2937
|
}
|
|
@@ -2937,7 +2939,7 @@ var ApprovalService = class {
|
|
|
2937
2939
|
this.deps.logger.info(
|
|
2938
2940
|
"entering:getApprovalActDetailsBySubjectId --" + JSON.stringify({ subjectId, subjectType, service })
|
|
2939
2941
|
);
|
|
2940
|
-
return this.approvalRepo.getApprovalActDetailsBySubjectId(this.
|
|
2942
|
+
return this.approvalRepo.getApprovalActDetailsBySubjectId(this.prisma, { subjectId, subjectType, service });
|
|
2941
2943
|
}
|
|
2942
2944
|
async commonStatusUpdate(config, data) {
|
|
2943
2945
|
return this.approvalRepo.commonStatusUpdate(config, data);
|
|
@@ -3047,7 +3049,7 @@ var toUINConfigDTO = (model) => {
|
|
|
3047
3049
|
|
|
3048
3050
|
// src/repository/uinConfig.repository.ts
|
|
3049
3051
|
var uinConfigRepository = (uinDeps) => {
|
|
3050
|
-
const db = uinDeps.db;
|
|
3052
|
+
const db = uinDeps?.getDb?.() ?? uinDeps.db;
|
|
3051
3053
|
const logger = uinDeps.logger;
|
|
3052
3054
|
const requestStorage = uinDeps.requestStorage;
|
|
3053
3055
|
const modelName = uinDeps.modelName || "uINConfig";
|
|
@@ -4789,7 +4791,8 @@ var NotificationEmitter = class {
|
|
|
4789
4791
|
service;
|
|
4790
4792
|
constructor(deps) {
|
|
4791
4793
|
this.emitter = new import_events.EventEmitter();
|
|
4792
|
-
|
|
4794
|
+
const prisma = deps.getDb?.() ?? deps.prisma;
|
|
4795
|
+
this.service = new NotificationService(prisma, deps.logger ?? console, deps.helpers);
|
|
4793
4796
|
this.emitter.on("notify", async (payload) => {
|
|
4794
4797
|
try {
|
|
4795
4798
|
await this.service.handleEvent(payload);
|
package/dist/index.mjs
CHANGED
|
@@ -399,10 +399,9 @@ function normalizeWhere(where) {
|
|
|
399
399
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
|
|
400
400
|
var commonRepository = (serviceDeps) => {
|
|
401
401
|
const { mappingExport, mappingImport, dtoMapping } = serviceDeps.mapper;
|
|
402
|
-
const db = serviceDeps.db;
|
|
402
|
+
const db = serviceDeps?.getDb?.() ?? serviceDeps.db;
|
|
403
403
|
const { generateErrorMessage, ErrorHandler } = serviceDeps.helpers;
|
|
404
404
|
const logger = serviceDeps.logger;
|
|
405
|
-
const createCache = serviceDeps.cacheAdapter.createCache;
|
|
406
405
|
const requestStorage = serviceDeps.requestStorage;
|
|
407
406
|
return {
|
|
408
407
|
async commonSearch({
|
|
@@ -1098,7 +1097,7 @@ var buildPrismaData = (cfg, op, validatedBody, ctx) => {
|
|
|
1098
1097
|
|
|
1099
1098
|
// src/repository/commonCreateUpdate.repository.ts
|
|
1100
1099
|
var commonCreateUpdateRepository = (serviceDeps) => {
|
|
1101
|
-
const db = serviceDeps.db;
|
|
1100
|
+
const db = serviceDeps?.getDb?.() ?? serviceDeps.db;
|
|
1102
1101
|
const { ErrorHandler } = serviceDeps.helpers;
|
|
1103
1102
|
return {
|
|
1104
1103
|
getDelegate(tableName) {
|
|
@@ -1833,7 +1832,7 @@ import Joi2 from "joi";
|
|
|
1833
1832
|
var commonService = (serviceDeps) => {
|
|
1834
1833
|
const generateErrorMessage = serviceDeps.helpers.generateErrorMessage;
|
|
1835
1834
|
const ErrorHandler = serviceDeps.helpers.ErrorHandler;
|
|
1836
|
-
const { deleteCache, getCacheById, updateCache,
|
|
1835
|
+
const { deleteCache, getCacheById, updateCache, addToCache } = serviceDeps.cacheAdapter;
|
|
1837
1836
|
const logger = serviceDeps.logger;
|
|
1838
1837
|
const dtoMapping = serviceDeps.mapper.dtoMapping;
|
|
1839
1838
|
const validationMapping = serviceDeps.mapper.validationMapping;
|
|
@@ -2282,6 +2281,7 @@ var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
|
|
|
2282
2281
|
// src/repository/approval.repository.ts
|
|
2283
2282
|
import { Prisma } from "@prisma/client";
|
|
2284
2283
|
var approvalRepository = (deps) => {
|
|
2284
|
+
const prisma = deps.getDb?.() ?? deps.prisma;
|
|
2285
2285
|
return {
|
|
2286
2286
|
async findMatchingFlow(tx, type, service, ccId, netTotal, level = 1) {
|
|
2287
2287
|
const result = await tx.$queryRaw`
|
|
@@ -2430,14 +2430,14 @@ var approvalRepository = (deps) => {
|
|
|
2430
2430
|
SET ${Prisma.join(setFragments, ", ")}
|
|
2431
2431
|
WHERE id = ${data.id};
|
|
2432
2432
|
`;
|
|
2433
|
-
await
|
|
2433
|
+
await prisma.$queryRaw(query);
|
|
2434
2434
|
},
|
|
2435
2435
|
async commonParentChildUpdate(config, childConfig, inst) {
|
|
2436
2436
|
deps.logger.info("entering::commonRefundUpdate::repository");
|
|
2437
2437
|
const { tableName: parentTableName, ...parentTableConfig } = config;
|
|
2438
2438
|
const { tableName: childTableName, ...childTableConfig } = childConfig ?? {};
|
|
2439
2439
|
const parentId = inst.subjectId;
|
|
2440
|
-
await
|
|
2440
|
+
await prisma.$transaction(async (tx) => {
|
|
2441
2441
|
const commonDetails = await this.getChildCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2442
2442
|
const parentDetails = await this.getParentCommonDetailsByParentId(tx, parentId, inst.subjectType, inst.service);
|
|
2443
2443
|
if (!parentDetails) {
|
|
@@ -2533,10 +2533,12 @@ var externalInterceptor = () => {
|
|
|
2533
2533
|
var ApprovalService = class {
|
|
2534
2534
|
constructor(deps) {
|
|
2535
2535
|
this.deps = deps;
|
|
2536
|
+
this.prisma = deps.getDb?.() ?? deps.prisma;
|
|
2536
2537
|
this.approvalRepo = approvalRepository(deps);
|
|
2537
2538
|
}
|
|
2538
2539
|
deps;
|
|
2539
2540
|
approvalRepo;
|
|
2541
|
+
prisma;
|
|
2540
2542
|
async startFlow(tx, { service, subjectType, subjectId, netTotal, ccId, refNo, level = 1, extra }) {
|
|
2541
2543
|
const store = this.deps.requestStorage.getStore();
|
|
2542
2544
|
const currentUser = store?.user?.id;
|
|
@@ -2585,7 +2587,7 @@ var ApprovalService = class {
|
|
|
2585
2587
|
}
|
|
2586
2588
|
/** Approver clicks “Approve” or “Reject”. */
|
|
2587
2589
|
async act({ instanceId, approverId, action, ccId, comment }) {
|
|
2588
|
-
return this.
|
|
2590
|
+
return this.prisma.$transaction(async (tx) => {
|
|
2589
2591
|
const inst = await tx.approvalInstance.findUnique({
|
|
2590
2592
|
where: { id: instanceId },
|
|
2591
2593
|
include: { flow: { where: { isActive: true }, include: { steps: { where: { isActive: true } } } } }
|
|
@@ -2866,7 +2868,7 @@ var ApprovalService = class {
|
|
|
2866
2868
|
}
|
|
2867
2869
|
async getAllApprovalFlow(input) {
|
|
2868
2870
|
this.deps.logger.info("entering:getAllApprovalFlow --" + JSON.stringify({ input }));
|
|
2869
|
-
const instance = await this.approvalRepo.getAllApprovalFlow(this.
|
|
2871
|
+
const instance = await this.approvalRepo.getAllApprovalFlow(this.prisma, input);
|
|
2870
2872
|
this.deps.logger.info("exiting:getAllApprovalFlow --" + JSON.stringify({ instance }));
|
|
2871
2873
|
return instance;
|
|
2872
2874
|
}
|
|
@@ -2874,7 +2876,7 @@ var ApprovalService = class {
|
|
|
2874
2876
|
this.deps.logger.info(
|
|
2875
2877
|
"entering:getApprovalActDetailsBySubjectId --" + JSON.stringify({ subjectId, subjectType, service })
|
|
2876
2878
|
);
|
|
2877
|
-
return this.approvalRepo.getApprovalActDetailsBySubjectId(this.
|
|
2879
|
+
return this.approvalRepo.getApprovalActDetailsBySubjectId(this.prisma, { subjectId, subjectType, service });
|
|
2878
2880
|
}
|
|
2879
2881
|
async commonStatusUpdate(config, data) {
|
|
2880
2882
|
return this.approvalRepo.commonStatusUpdate(config, data);
|
|
@@ -2984,7 +2986,7 @@ var toUINConfigDTO = (model) => {
|
|
|
2984
2986
|
|
|
2985
2987
|
// src/repository/uinConfig.repository.ts
|
|
2986
2988
|
var uinConfigRepository = (uinDeps) => {
|
|
2987
|
-
const db = uinDeps.db;
|
|
2989
|
+
const db = uinDeps?.getDb?.() ?? uinDeps.db;
|
|
2988
2990
|
const logger = uinDeps.logger;
|
|
2989
2991
|
const requestStorage = uinDeps.requestStorage;
|
|
2990
2992
|
const modelName = uinDeps.modelName || "uINConfig";
|
|
@@ -4726,7 +4728,8 @@ var NotificationEmitter = class {
|
|
|
4726
4728
|
service;
|
|
4727
4729
|
constructor(deps) {
|
|
4728
4730
|
this.emitter = new EventEmitter();
|
|
4729
|
-
|
|
4731
|
+
const prisma = deps.getDb?.() ?? deps.prisma;
|
|
4732
|
+
this.service = new NotificationService(prisma, deps.logger ?? console, deps.helpers);
|
|
4730
4733
|
this.emitter.on("notify", async (payload) => {
|
|
4731
4734
|
try {
|
|
4732
4735
|
await this.service.handleEvent(payload);
|