av6-core 1.2.1 → 1.2.3
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 +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +5 -3
- package/dist/index.mjs +5 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -428,26 +428,28 @@ declare class NotificationEmitter {
|
|
|
428
428
|
notifyNow(shortCode: string, body: Omit<EmitPayload, "shortCode">): Promise<void>;
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
-
interface AuditContext {
|
|
431
|
+
interface AuditContext<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
432
432
|
userId: number | null;
|
|
433
433
|
traceId: string | null;
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
level1Id: number | null;
|
|
435
|
+
level2Id: number | null;
|
|
436
|
+
module: Module;
|
|
436
437
|
}
|
|
437
|
-
type AuditContextProvider = () => AuditContext
|
|
438
|
+
type AuditContextProvider<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> = () => AuditContext<Module>;
|
|
438
439
|
interface AuditLogPayload {
|
|
439
440
|
message: string;
|
|
440
441
|
type?: "INFO" | "CREATE" | "UPDATE" | "DELETE" | "ERROR";
|
|
441
|
-
|
|
442
|
+
level1Id?: number | null;
|
|
443
|
+
level2Id?: number | null;
|
|
442
444
|
extra?: Record<string, any>;
|
|
443
445
|
}
|
|
444
446
|
|
|
445
|
-
declare class AuditCore {
|
|
447
|
+
declare class AuditCore<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
446
448
|
private prisma;
|
|
447
449
|
private contextProvider;
|
|
448
|
-
constructor(prisma: PrismaClient, contextProvider: AuditContextProvider);
|
|
450
|
+
constructor(prisma: PrismaClient, contextProvider: AuditContextProvider<Module>);
|
|
449
451
|
getPrisma(): PrismaClient;
|
|
450
|
-
getContext(): AuditContext
|
|
452
|
+
getContext(): AuditContext<Module>;
|
|
451
453
|
}
|
|
452
454
|
|
|
453
455
|
declare class AuditLogger {
|
package/dist/index.d.ts
CHANGED
|
@@ -428,26 +428,28 @@ declare class NotificationEmitter {
|
|
|
428
428
|
notifyNow(shortCode: string, body: Omit<EmitPayload, "shortCode">): Promise<void>;
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
-
interface AuditContext {
|
|
431
|
+
interface AuditContext<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
432
432
|
userId: number | null;
|
|
433
433
|
traceId: string | null;
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
level1Id: number | null;
|
|
435
|
+
level2Id: number | null;
|
|
436
|
+
module: Module;
|
|
436
437
|
}
|
|
437
|
-
type AuditContextProvider = () => AuditContext
|
|
438
|
+
type AuditContextProvider<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> = () => AuditContext<Module>;
|
|
438
439
|
interface AuditLogPayload {
|
|
439
440
|
message: string;
|
|
440
441
|
type?: "INFO" | "CREATE" | "UPDATE" | "DELETE" | "ERROR";
|
|
441
|
-
|
|
442
|
+
level1Id?: number | null;
|
|
443
|
+
level2Id?: number | null;
|
|
442
444
|
extra?: Record<string, any>;
|
|
443
445
|
}
|
|
444
446
|
|
|
445
|
-
declare class AuditCore {
|
|
447
|
+
declare class AuditCore<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
446
448
|
private prisma;
|
|
447
449
|
private contextProvider;
|
|
448
|
-
constructor(prisma: PrismaClient, contextProvider: AuditContextProvider);
|
|
450
|
+
constructor(prisma: PrismaClient, contextProvider: AuditContextProvider<Module>);
|
|
449
451
|
getPrisma(): PrismaClient;
|
|
450
|
-
getContext(): AuditContext
|
|
452
|
+
getContext(): AuditContext<Module>;
|
|
451
453
|
}
|
|
452
454
|
|
|
453
455
|
declare class AuditLogger {
|
package/dist/index.js
CHANGED
|
@@ -2520,7 +2520,7 @@ var AuditLogger = class {
|
|
|
2520
2520
|
async logIfEnabled(params) {
|
|
2521
2521
|
const { service, method, payload } = params;
|
|
2522
2522
|
const prisma = this.core.getPrisma();
|
|
2523
|
-
const { userId, traceId,
|
|
2523
|
+
const { userId, traceId, level1Id: ctxLvl1Id, level2Id: ctxLvl2Id, module: module2 } = this.core.getContext();
|
|
2524
2524
|
try {
|
|
2525
2525
|
const config = await prisma.auditConfig.findFirst({
|
|
2526
2526
|
where: {
|
|
@@ -2535,14 +2535,16 @@ var AuditLogger = class {
|
|
|
2535
2535
|
}
|
|
2536
2536
|
const message = payload.type === "ERROR" ? payload.message : config.message;
|
|
2537
2537
|
const type = payload.type ?? "INFO";
|
|
2538
|
-
const
|
|
2538
|
+
const level1Id = payload.level1Id ?? ctxLvl1Id ?? 0;
|
|
2539
|
+
const level2Id = payload.level2Id ?? ctxLvl2Id ?? 0;
|
|
2539
2540
|
await prisma.commonAudit.create({
|
|
2540
2541
|
data: {
|
|
2541
2542
|
service,
|
|
2542
2543
|
module: module2,
|
|
2543
2544
|
type,
|
|
2544
2545
|
message,
|
|
2545
|
-
|
|
2546
|
+
level1Id,
|
|
2547
|
+
level2Id,
|
|
2546
2548
|
methodName: method,
|
|
2547
2549
|
traceId,
|
|
2548
2550
|
createdBy: userId ?? void 0
|
package/dist/index.mjs
CHANGED
|
@@ -2470,7 +2470,7 @@ var AuditLogger = class {
|
|
|
2470
2470
|
async logIfEnabled(params) {
|
|
2471
2471
|
const { service, method, payload } = params;
|
|
2472
2472
|
const prisma = this.core.getPrisma();
|
|
2473
|
-
const { userId, traceId,
|
|
2473
|
+
const { userId, traceId, level1Id: ctxLvl1Id, level2Id: ctxLvl2Id, module } = this.core.getContext();
|
|
2474
2474
|
try {
|
|
2475
2475
|
const config = await prisma.auditConfig.findFirst({
|
|
2476
2476
|
where: {
|
|
@@ -2485,14 +2485,16 @@ var AuditLogger = class {
|
|
|
2485
2485
|
}
|
|
2486
2486
|
const message = payload.type === "ERROR" ? payload.message : config.message;
|
|
2487
2487
|
const type = payload.type ?? "INFO";
|
|
2488
|
-
const
|
|
2488
|
+
const level1Id = payload.level1Id ?? ctxLvl1Id ?? 0;
|
|
2489
|
+
const level2Id = payload.level2Id ?? ctxLvl2Id ?? 0;
|
|
2489
2490
|
await prisma.commonAudit.create({
|
|
2490
2491
|
data: {
|
|
2491
2492
|
service,
|
|
2492
2493
|
module,
|
|
2493
2494
|
type,
|
|
2494
2495
|
message,
|
|
2495
|
-
|
|
2496
|
+
level1Id,
|
|
2497
|
+
level2Id,
|
|
2496
2498
|
methodName: method,
|
|
2497
2499
|
traceId,
|
|
2498
2500
|
createdBy: userId ?? void 0
|