av6-core 1.4.9 → 1.4.10

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.js CHANGED
@@ -2517,15 +2517,15 @@ var getUsersFromRoleAndLevel1Level2 = async (args) => {
2517
2517
  case "FIXUJI":
2518
2518
  const users = await args.prisma.userAreaMapping.findMany({
2519
2519
  where: {
2520
- areaId: {
2520
+ areaId: args.level1Ids.length ? {
2521
2521
  in: args.level1Ids
2522
- },
2522
+ } : void 0,
2523
2523
  isActive: true,
2524
2524
  userAreaDeptMappings: {
2525
2525
  some: {
2526
- deptId: {
2526
+ deptId: args.level2Ids.length ? {
2527
2527
  in: args.level2Ids
2528
- },
2528
+ } : void 0,
2529
2529
  isActive: true,
2530
2530
  userRoleMappings: {
2531
2531
  some: {
@@ -2573,13 +2573,17 @@ var getUsersFromRoleAndLevel1Level2 = async (args) => {
2573
2573
  const users2 = await args.prisma.userLevel1Mapping.findMany({
2574
2574
  where: {
2575
2575
  level1Id: {
2576
- in: args.level1Ids
2576
+ in: args.level1Ids.length ? {
2577
+ in: args.level1Ids
2578
+ } : void 0
2577
2579
  },
2578
2580
  isActive: true,
2579
2581
  userLevel1Level2Mappings: {
2580
2582
  some: {
2581
2583
  level2Id: {
2582
- in: args.level2Ids
2584
+ in: args.level2Ids.length ? {
2585
+ in: args.level2Ids
2586
+ } : void 0
2583
2587
  },
2584
2588
  isActive: true,
2585
2589
  userRoleMappings: {
@@ -2663,6 +2667,8 @@ async function resolveAllRecipients(args) {
2663
2667
  });
2664
2668
  const staffIdsFromStaffRules = /* @__PURE__ */ new Set();
2665
2669
  const roleIdsNeeded = /* @__PURE__ */ new Set();
2670
+ const level1IdsNeeded = /* @__PURE__ */ new Set();
2671
+ const level2IdsNeeded = /* @__PURE__ */ new Set();
2666
2672
  const onlyActiveByRuleId = /* @__PURE__ */ new Map();
2667
2673
  for (const r of rules) {
2668
2674
  const cfg = r.config ?? {};
@@ -2673,6 +2679,8 @@ async function resolveAllRecipients(args) {
2673
2679
  for (const id of toArray(cfg.roleIds)) roleIdsNeeded.add(Number(id));
2674
2680
  onlyActiveByRuleId.set(r.id, cfg.onlyActive ?? true);
2675
2681
  }
2682
+ for (const id of toArray(cfg.level1Ids)) level1IdsNeeded.add(Number(id));
2683
+ for (const id of toArray(cfg.level2Ids)) level2IdsNeeded.add(Number(id));
2676
2684
  }
2677
2685
  const staffIdsFromRoleRules = /* @__PURE__ */ new Set();
2678
2686
  const serviceDomain = args.eventConfig.serviceEvent.serviceDomain;
@@ -2680,8 +2688,8 @@ async function resolveAllRecipients(args) {
2680
2688
  const mappings = await getUsersFromRoleAndLevel1Level2({
2681
2689
  prisma: args.prisma,
2682
2690
  roles: Array.from(roleIdsNeeded),
2683
- level1Ids: args.eventConfig.level1Ids ?? [],
2684
- level2Ids: args.eventConfig.level2Ids ?? [],
2691
+ level1Ids: Array.from(level1IdsNeeded),
2692
+ level2Ids: Array.from(level2IdsNeeded),
2685
2693
  serviceDomain
2686
2694
  });
2687
2695
  for (const id of mappings) {
package/dist/index.mjs CHANGED
@@ -2467,15 +2467,15 @@ var getUsersFromRoleAndLevel1Level2 = async (args) => {
2467
2467
  case "FIXUJI":
2468
2468
  const users = await args.prisma.userAreaMapping.findMany({
2469
2469
  where: {
2470
- areaId: {
2470
+ areaId: args.level1Ids.length ? {
2471
2471
  in: args.level1Ids
2472
- },
2472
+ } : void 0,
2473
2473
  isActive: true,
2474
2474
  userAreaDeptMappings: {
2475
2475
  some: {
2476
- deptId: {
2476
+ deptId: args.level2Ids.length ? {
2477
2477
  in: args.level2Ids
2478
- },
2478
+ } : void 0,
2479
2479
  isActive: true,
2480
2480
  userRoleMappings: {
2481
2481
  some: {
@@ -2523,13 +2523,17 @@ var getUsersFromRoleAndLevel1Level2 = async (args) => {
2523
2523
  const users2 = await args.prisma.userLevel1Mapping.findMany({
2524
2524
  where: {
2525
2525
  level1Id: {
2526
- in: args.level1Ids
2526
+ in: args.level1Ids.length ? {
2527
+ in: args.level1Ids
2528
+ } : void 0
2527
2529
  },
2528
2530
  isActive: true,
2529
2531
  userLevel1Level2Mappings: {
2530
2532
  some: {
2531
2533
  level2Id: {
2532
- in: args.level2Ids
2534
+ in: args.level2Ids.length ? {
2535
+ in: args.level2Ids
2536
+ } : void 0
2533
2537
  },
2534
2538
  isActive: true,
2535
2539
  userRoleMappings: {
@@ -2613,6 +2617,8 @@ async function resolveAllRecipients(args) {
2613
2617
  });
2614
2618
  const staffIdsFromStaffRules = /* @__PURE__ */ new Set();
2615
2619
  const roleIdsNeeded = /* @__PURE__ */ new Set();
2620
+ const level1IdsNeeded = /* @__PURE__ */ new Set();
2621
+ const level2IdsNeeded = /* @__PURE__ */ new Set();
2616
2622
  const onlyActiveByRuleId = /* @__PURE__ */ new Map();
2617
2623
  for (const r of rules) {
2618
2624
  const cfg = r.config ?? {};
@@ -2623,6 +2629,8 @@ async function resolveAllRecipients(args) {
2623
2629
  for (const id of toArray(cfg.roleIds)) roleIdsNeeded.add(Number(id));
2624
2630
  onlyActiveByRuleId.set(r.id, cfg.onlyActive ?? true);
2625
2631
  }
2632
+ for (const id of toArray(cfg.level1Ids)) level1IdsNeeded.add(Number(id));
2633
+ for (const id of toArray(cfg.level2Ids)) level2IdsNeeded.add(Number(id));
2626
2634
  }
2627
2635
  const staffIdsFromRoleRules = /* @__PURE__ */ new Set();
2628
2636
  const serviceDomain = args.eventConfig.serviceEvent.serviceDomain;
@@ -2630,8 +2638,8 @@ async function resolveAllRecipients(args) {
2630
2638
  const mappings = await getUsersFromRoleAndLevel1Level2({
2631
2639
  prisma: args.prisma,
2632
2640
  roles: Array.from(roleIdsNeeded),
2633
- level1Ids: args.eventConfig.level1Ids ?? [],
2634
- level2Ids: args.eventConfig.level2Ids ?? [],
2641
+ level1Ids: Array.from(level1IdsNeeded),
2642
+ level2Ids: Array.from(level2IdsNeeded),
2635
2643
  serviceDomain
2636
2644
  });
2637
2645
  for (const id of mappings) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",