av6-core 1.2.4 → 1.2.6
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 +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +9 -4
- package/dist/index.mjs +9 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -253,6 +253,9 @@ type Store = {
|
|
|
253
253
|
userName: string;
|
|
254
254
|
id: number;
|
|
255
255
|
};
|
|
256
|
+
level1Id?: number;
|
|
257
|
+
level2Id?: number;
|
|
258
|
+
[key: string]: any;
|
|
256
259
|
};
|
|
257
260
|
interface Context {
|
|
258
261
|
[key: string]: any;
|
|
@@ -431,8 +434,6 @@ declare class NotificationEmitter {
|
|
|
431
434
|
interface AuditContext<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
432
435
|
userId: number | null;
|
|
433
436
|
traceId: string | null;
|
|
434
|
-
level1Id: number | null;
|
|
435
|
-
level2Id: number | null;
|
|
436
437
|
module: Module;
|
|
437
438
|
}
|
|
438
439
|
type AuditContextProvider<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> = () => AuditContext<Module>;
|
|
@@ -447,9 +448,11 @@ interface AuditLogPayload {
|
|
|
447
448
|
declare class AuditCore<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
448
449
|
private prisma;
|
|
449
450
|
private contextProvider;
|
|
450
|
-
|
|
451
|
+
private requestStorage;
|
|
452
|
+
constructor(prisma: PrismaClient, contextProvider: AuditContextProvider<Module>, requestStorage: AsyncLocalStorage<Store>);
|
|
451
453
|
getPrisma(): PrismaClient;
|
|
452
454
|
getContext(): AuditContext<Module>;
|
|
455
|
+
getRequestStore(): Store | undefined;
|
|
453
456
|
}
|
|
454
457
|
|
|
455
458
|
declare class AuditLogger<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
package/dist/index.d.ts
CHANGED
|
@@ -253,6 +253,9 @@ type Store = {
|
|
|
253
253
|
userName: string;
|
|
254
254
|
id: number;
|
|
255
255
|
};
|
|
256
|
+
level1Id?: number;
|
|
257
|
+
level2Id?: number;
|
|
258
|
+
[key: string]: any;
|
|
256
259
|
};
|
|
257
260
|
interface Context {
|
|
258
261
|
[key: string]: any;
|
|
@@ -431,8 +434,6 @@ declare class NotificationEmitter {
|
|
|
431
434
|
interface AuditContext<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
432
435
|
userId: number | null;
|
|
433
436
|
traceId: string | null;
|
|
434
|
-
level1Id: number | null;
|
|
435
|
-
level2Id: number | null;
|
|
436
437
|
module: Module;
|
|
437
438
|
}
|
|
438
439
|
type AuditContextProvider<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> = () => AuditContext<Module>;
|
|
@@ -447,9 +448,11 @@ interface AuditLogPayload {
|
|
|
447
448
|
declare class AuditCore<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
|
448
449
|
private prisma;
|
|
449
450
|
private contextProvider;
|
|
450
|
-
|
|
451
|
+
private requestStorage;
|
|
452
|
+
constructor(prisma: PrismaClient, contextProvider: AuditContextProvider<Module>, requestStorage: AsyncLocalStorage<Store>);
|
|
451
453
|
getPrisma(): PrismaClient;
|
|
452
454
|
getContext(): AuditContext<Module>;
|
|
455
|
+
getRequestStore(): Store | undefined;
|
|
453
456
|
}
|
|
454
457
|
|
|
455
458
|
declare class AuditLogger<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_BILL" | "PHARMACY" | "LAB" | "IPD"> {
|
package/dist/index.js
CHANGED
|
@@ -2496,9 +2496,11 @@ var NotificationEmitter = class {
|
|
|
2496
2496
|
var AuditCore = class {
|
|
2497
2497
|
prisma;
|
|
2498
2498
|
contextProvider;
|
|
2499
|
-
|
|
2499
|
+
requestStorage;
|
|
2500
|
+
constructor(prisma, contextProvider, requestStorage) {
|
|
2500
2501
|
this.prisma = prisma;
|
|
2501
2502
|
this.contextProvider = contextProvider;
|
|
2503
|
+
this.requestStorage = requestStorage;
|
|
2502
2504
|
}
|
|
2503
2505
|
getPrisma() {
|
|
2504
2506
|
return this.prisma;
|
|
@@ -2506,6 +2508,9 @@ var AuditCore = class {
|
|
|
2506
2508
|
getContext() {
|
|
2507
2509
|
return this.contextProvider();
|
|
2508
2510
|
}
|
|
2511
|
+
getRequestStore() {
|
|
2512
|
+
return this.requestStorage.getStore();
|
|
2513
|
+
}
|
|
2509
2514
|
};
|
|
2510
2515
|
|
|
2511
2516
|
// src/audit/audit.logger.ts
|
|
@@ -2520,7 +2525,7 @@ var AuditLogger = class {
|
|
|
2520
2525
|
async logIfEnabled(params) {
|
|
2521
2526
|
const { service, method, payload } = params;
|
|
2522
2527
|
const prisma = this.core.getPrisma();
|
|
2523
|
-
const { userId, traceId,
|
|
2528
|
+
const { userId, traceId, module: module2 } = this.core.getContext();
|
|
2524
2529
|
try {
|
|
2525
2530
|
const config = await prisma.auditConfig.findFirst({
|
|
2526
2531
|
where: {
|
|
@@ -2535,8 +2540,8 @@ var AuditLogger = class {
|
|
|
2535
2540
|
}
|
|
2536
2541
|
const message = payload.type === "ERROR" ? payload.message : config.message;
|
|
2537
2542
|
const type = payload.type ?? "INFO";
|
|
2538
|
-
const level1Id =
|
|
2539
|
-
const level2Id =
|
|
2543
|
+
const level1Id = this.core.getRequestStore()?.level1Id ?? 0;
|
|
2544
|
+
const level2Id = this.core.getRequestStore()?.level2Id ?? 0;
|
|
2540
2545
|
await prisma.commonAudit.create({
|
|
2541
2546
|
data: {
|
|
2542
2547
|
service,
|
package/dist/index.mjs
CHANGED
|
@@ -2446,9 +2446,11 @@ var NotificationEmitter = class {
|
|
|
2446
2446
|
var AuditCore = class {
|
|
2447
2447
|
prisma;
|
|
2448
2448
|
contextProvider;
|
|
2449
|
-
|
|
2449
|
+
requestStorage;
|
|
2450
|
+
constructor(prisma, contextProvider, requestStorage) {
|
|
2450
2451
|
this.prisma = prisma;
|
|
2451
2452
|
this.contextProvider = contextProvider;
|
|
2453
|
+
this.requestStorage = requestStorage;
|
|
2452
2454
|
}
|
|
2453
2455
|
getPrisma() {
|
|
2454
2456
|
return this.prisma;
|
|
@@ -2456,6 +2458,9 @@ var AuditCore = class {
|
|
|
2456
2458
|
getContext() {
|
|
2457
2459
|
return this.contextProvider();
|
|
2458
2460
|
}
|
|
2461
|
+
getRequestStore() {
|
|
2462
|
+
return this.requestStorage.getStore();
|
|
2463
|
+
}
|
|
2459
2464
|
};
|
|
2460
2465
|
|
|
2461
2466
|
// src/audit/audit.logger.ts
|
|
@@ -2470,7 +2475,7 @@ var AuditLogger = class {
|
|
|
2470
2475
|
async logIfEnabled(params) {
|
|
2471
2476
|
const { service, method, payload } = params;
|
|
2472
2477
|
const prisma = this.core.getPrisma();
|
|
2473
|
-
const { userId, traceId,
|
|
2478
|
+
const { userId, traceId, module } = this.core.getContext();
|
|
2474
2479
|
try {
|
|
2475
2480
|
const config = await prisma.auditConfig.findFirst({
|
|
2476
2481
|
where: {
|
|
@@ -2485,8 +2490,8 @@ var AuditLogger = class {
|
|
|
2485
2490
|
}
|
|
2486
2491
|
const message = payload.type === "ERROR" ? payload.message : config.message;
|
|
2487
2492
|
const type = payload.type ?? "INFO";
|
|
2488
|
-
const level1Id =
|
|
2489
|
-
const level2Id =
|
|
2493
|
+
const level1Id = this.core.getRequestStore()?.level1Id ?? 0;
|
|
2494
|
+
const level2Id = this.core.getRequestStore()?.level2Id ?? 0;
|
|
2490
2495
|
await prisma.commonAudit.create({
|
|
2491
2496
|
data: {
|
|
2492
2497
|
service,
|