vr-commons 1.0.161 → 1.0.163

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.
@@ -7,6 +7,10 @@ const sequelize_1 = require("sequelize");
7
7
  const eventLog_utils_1 = require("./eventLog.utils");
8
8
  const admin_devices_validations_1 = require("../validations/admin.devices.validations");
9
9
  const systemLog_utils_1 = require("./systemLog.utils");
10
+ const isValidUUID = (str) => {
11
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12
+ return uuidRegex.test(str);
13
+ };
10
14
  /**
11
15
  * Extract dedication from serial number
12
16
  */
@@ -411,7 +415,7 @@ exports.stockUtil = {
411
415
  return await vr_models_1.Device.findAll({
412
416
  where: {
413
417
  pairId: { [sequelize_1.Op.in]: pairIds },
414
- deletedAt: null, // ✅ Exclude soft deleted
418
+ // ✅ Exclude soft deleted
415
419
  },
416
420
  include: [{ model: vr_models_1.DevicePaymentPlan, as: "paymentPlan" }],
417
421
  transaction,
@@ -456,7 +460,6 @@ exports.stockUtil = {
456
460
  const devices = await vr_models_1.Device.findAll({
457
461
  where: {
458
462
  pairId: pairId,
459
- deletedAt: null, // ✅ Exclude soft deleted
460
463
  },
461
464
  transaction,
462
465
  });
@@ -514,7 +517,6 @@ exports.stockUtil = {
514
517
  const devices = await vr_models_1.Device.findAll({
515
518
  where: {
516
519
  pairId: pairId,
517
- deletedAt: null,
518
520
  },
519
521
  include: [{ model: vr_models_1.DevicePaymentPlan, as: "paymentPlan" }],
520
522
  transaction,
@@ -564,7 +566,6 @@ exports.stockUtil = {
564
566
  const devices = await vr_models_1.Device.findAll({
565
567
  where: {
566
568
  pairId: pairId,
567
- deletedAt: null,
568
569
  },
569
570
  include: [{ model: vr_models_1.DevicePaymentPlan, as: "paymentPlan" }],
570
571
  transaction,
@@ -620,40 +621,25 @@ exports.stockUtil = {
620
621
  let batchNumber = 0;
621
622
  let hasMore = true;
622
623
  let offset = 0;
623
- // Build WHERE clause for the query
624
624
  const whereClause = buildWhereClause(condition);
625
- // Build UPDATE SET clause
626
625
  const setClause = buildSetClause(update);
627
626
  console.log(`🔄 Resetting device pairs at ${new Date().toISOString()}`);
628
627
  console.log(`📋 WHERE: ${whereClause}`);
629
628
  console.log(`📝 SET: ${setClause}`);
630
- // Log start
631
- if (isSystem) {
632
- await (0, systemLog_utils_1.logInfo)(`Reset device pairs job started`, {
633
- category: "CRONJOB",
634
- source: "device-reset.cronjob",
635
- details: { triggeredBy, batchSize, maxRetries, condition, update },
636
- });
637
- }
638
- else {
639
- await (0, systemLog_utils_1.logInfo)(`Reset device pairs triggered by ${actorRole}`, {
640
- category: "DEVICE",
641
- userId: actorId || undefined,
642
- userRole: actorRole,
643
- source: "device-reset.manual",
644
- details: { triggeredBy, batchSize, maxRetries, condition, update },
645
- });
646
- }
629
+ // Log start - SystemLog only
630
+ await (0, systemLog_utils_1.logInfo)(`Reset device pairs job started`, {
631
+ category: isSystem ? "CRONJOB" : "DEVICE",
632
+ source: isSystem ? "device-reset.cronjob" : "device-reset.manual",
633
+ details: { triggeredBy, batchSize, maxRetries, condition, update },
634
+ });
647
635
  const sequelizeInstance = vr_models_1.Device.sequelize;
648
636
  if (!sequelizeInstance) {
649
637
  throw new Error("Sequelize instance not available");
650
638
  }
651
- // Process in batches
652
639
  while (hasMore) {
653
640
  batchNumber++;
654
641
  offset = (batchNumber - 1) * batchSize;
655
- // Get distinct pairIds that match the condition
656
- const [pairIdsResult] = await sequelizeInstance.query(`
642
+ const pairIdsResult = await sequelizeInstance.query(`
657
643
  SELECT "pairId"
658
644
  FROM "devices"
659
645
  WHERE "deletedAt" IS NULL
@@ -661,17 +647,21 @@ exports.stockUtil = {
661
647
  GROUP BY "pairId"
662
648
  HAVING COUNT(*) = 2
663
649
  ORDER BY "pairId" ASC
664
- LIMIT :limit
665
- OFFSET :offset
650
+ LIMIT $1
651
+ OFFSET $2
666
652
  `, {
667
- replacements: {
668
- limit: batchSize,
669
- offset: offset,
670
- },
653
+ bind: [batchSize, offset],
671
654
  type: "SELECT",
672
655
  transaction: transaction,
673
656
  });
674
- const pairIds = pairIdsResult.map((p) => p.pairId);
657
+ let pairIds = [];
658
+ if (Array.isArray(pairIdsResult)) {
659
+ pairIds = pairIdsResult.map((p) => p.pairId);
660
+ }
661
+ else if (pairIdsResult && typeof pairIdsResult === "object") {
662
+ const rows = pairIdsResult.rows || [];
663
+ pairIds = rows.map((p) => p.pairId);
664
+ }
675
665
  if (pairIds.length === 0) {
676
666
  hasMore = false;
677
667
  break;
@@ -686,7 +676,6 @@ exports.stockUtil = {
686
676
  const devices = await vr_models_1.Device.findAll({
687
677
  where: {
688
678
  pairId: pairId,
689
- deletedAt: null,
690
679
  ...buildSequelizeWhere(condition),
691
680
  },
692
681
  transaction: transaction,
@@ -694,7 +683,6 @@ exports.stockUtil = {
694
683
  if (devices.length !== 2) {
695
684
  throw new Error(`Incomplete pair ${pairId}: expected 2 devices, found ${devices.length}`);
696
685
  }
697
- // Check if update would be a no-op
698
686
  const shouldUpdate = devices.some((d) => {
699
687
  const updateObj = buildUpdateObject(update);
700
688
  return Object.keys(updateObj).some((key) => d[key] !== updateObj[key]);
@@ -747,78 +735,61 @@ exports.stockUtil = {
747
735
  : ""}`,
748
736
  };
749
737
  console.log(`✅ Reset device pairs completed:`, result);
750
- // Log single event with summary
751
- await (0, eventLog_utils_1.logEvent)({
752
- actorId: isSystem ? null : actorId,
753
- actorType: isSystem ? "ADMIN" : actorRole,
754
- action: "DEVICES_UPDATED",
755
- entity: "Device",
756
- entityId: null,
757
- metadata: {
758
- action: "RESET_DEVICES_STATUS",
759
- triggeredBy: triggeredBy,
760
- condition: condition,
761
- update: update,
762
- summary: {
763
- totalPairsProcessed: result.pairsProcessed,
764
- totalDevicesUpdated: result.updatedCount,
765
- totalPairsUpdated: updatedPairIds.length,
766
- failedPairs: result.failedCount,
767
- failedPairIds: result.failedPairIds,
768
- errors: result.errors,
769
- deviceIds: allDeviceIds.slice(0, 100),
770
- },
771
- batchDetails: {
772
- totalBatches: batchNumber,
773
- batchSize: batchSize,
774
- maxRetries: maxRetries,
775
- },
776
- timestamp: new Date().toISOString(),
738
+ // Log completion - SystemLog only
739
+ await (0, systemLog_utils_1.logInfo)(`Reset device pairs job completed`, {
740
+ category: isSystem ? "CRONJOB" : "DEVICE",
741
+ source: isSystem ? "device-reset.cronjob" : "device-reset.manual",
742
+ details: {
743
+ updatedDevices: result.updatedCount,
744
+ updatedPairs: updatedPairIds.length,
745
+ failedPairs: result.failedCount,
746
+ totalPairs: result.pairsProcessed,
747
+ hasErrors: result.errors.length > 0,
777
748
  },
778
- deviceSession: null,
779
- transaction: transaction,
780
749
  });
781
- // Log to system logs
782
- if (isSystem) {
783
- await (0, systemLog_utils_1.logInfo)(`Reset device pairs job completed`, {
784
- category: "CRONJOB",
785
- source: "device-reset.cronjob",
786
- details: {
787
- updatedDevices: result.updatedCount,
788
- updatedPairs: updatedPairIds.length,
789
- failedPairs: result.failedCount,
790
- totalPairs: result.pairsProcessed,
791
- hasErrors: result.errors.length > 0,
792
- },
793
- });
794
- }
795
- else {
796
- await (0, systemLog_utils_1.logInfo)(`Reset device pairs completed by ${actorRole}`, {
797
- category: "DEVICE",
798
- userId: actorId || undefined,
799
- userRole: actorRole,
800
- source: "device-reset.manual",
801
- details: {
802
- updatedDevices: result.updatedCount,
803
- updatedPairs: updatedPairIds.length,
804
- failedPairs: result.failedCount,
805
- totalPairs: result.pairsProcessed,
806
- hasErrors: result.errors.length > 0,
807
- },
808
- });
809
- }
810
750
  if (result.errors.length > 0) {
811
751
  await (0, systemLog_utils_1.logError)(`Reset device pairs had ${result.errors.length} failures`, {
812
752
  category: isSystem ? "CRONJOB" : "DEVICE",
813
753
  source: isSystem ? "device-reset.cronjob" : "device-reset.manual",
814
- userId: isSystem ? null : actorId || undefined,
815
- userRole: isSystem ? null : actorRole,
816
754
  details: {
817
755
  failedPairs: result.failedPairIds,
818
756
  errors: result.errors,
819
757
  },
820
758
  });
821
759
  }
760
+ // Log EventLog ONLY for user-triggered actions
761
+ if (!isSystem && actorId && isValidUUID(actorId)) {
762
+ await (0, eventLog_utils_1.logEvent)({
763
+ actorId: actorId,
764
+ actorType: actorRole,
765
+ action: "DEVICES_UPDATED",
766
+ entity: "Device",
767
+ entityId: null,
768
+ metadata: {
769
+ action: "RESET_DEVICES_STATUS",
770
+ triggeredBy: triggeredBy,
771
+ condition: condition,
772
+ update: update,
773
+ summary: {
774
+ totalPairsProcessed: result.pairsProcessed,
775
+ totalDevicesUpdated: result.updatedCount,
776
+ totalPairsUpdated: updatedPairIds.length,
777
+ failedPairs: result.failedCount,
778
+ failedPairIds: result.failedPairIds,
779
+ errors: result.errors,
780
+ deviceIds: allDeviceIds.slice(0, 100),
781
+ },
782
+ batchDetails: {
783
+ totalBatches: batchNumber,
784
+ batchSize: batchSize,
785
+ maxRetries: maxRetries,
786
+ },
787
+ timestamp: new Date().toISOString(),
788
+ },
789
+ deviceSession: null,
790
+ transaction: transaction,
791
+ });
792
+ }
822
793
  return result;
823
794
  }
824
795
  catch (err) {
@@ -834,22 +805,11 @@ exports.stockUtil = {
834
805
  pairsProcessed: 0,
835
806
  message: `Reset device pairs job failed: ${errorMessage}`,
836
807
  };
837
- if (isSystem) {
838
- await (0, systemLog_utils_1.logError)(`Reset device pairs job failed`, {
839
- category: "CRONJOB",
840
- source: "device-reset.cronjob",
841
- details: { error: errorMessage },
842
- });
843
- }
844
- else {
845
- await (0, systemLog_utils_1.logError)(`Reset device pairs failed`, {
846
- category: "DEVICE",
847
- userId: actorId || undefined,
848
- userRole: actorRole,
849
- source: "device-reset.manual",
850
- details: { error: errorMessage },
851
- });
852
- }
808
+ await (0, systemLog_utils_1.logError)(`Reset device pairs job failed`, {
809
+ category: isSystem ? "CRONJOB" : "DEVICE",
810
+ source: isSystem ? "device-reset.cronjob" : "device-reset.manual",
811
+ details: { error: errorMessage },
812
+ });
853
813
  return result;
854
814
  }
855
815
  },
@@ -15,4 +15,4 @@ export { DPP_OperationsUtil } from "./admin.devicePayment.utils";
15
15
  export { PendingRegistration, VerificationMethod, ConfirmResponse, UploadResult, StockChangeResult, } from "./types";
16
16
  export { formatDeviceSession, formatEventLog, formatEventLogs, buildEventLogWhereClause, buildSearchConditions, buildUserSearchConditions, } from "./eventlogs.admin.utils";
17
17
  export { extractDedicatedUserFromSerial } from "./deviceUtils";
18
- export { logApi, logAuth, logCronjob, logDebug, logDevice, logError, logInfo, logPayment, logSecurity, logSystem, logWarning, } from "./systemLog.utils";
18
+ export { logDebug, logError, logInfo, logSystem, logWarning, } from "./systemLog.utils";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateContactValue = exports.detectContactType = exports.sendVerificationCode = exports.sendSMS = exports.sendEmail = exports.getVerificationMethod = exports.getOTPExpiry = exports.generateOTP = exports.createDeviceSession = exports.suspensionUtil = exports.banUtil = exports.hasHigherAuthority = exports.getModeratableRoles = exports.canModerateUser = exports.canModerate = exports.softDeleteUser = exports.hashPassword = exports.validatePassword = exports.validateUniqueFields = exports.generateJacketId = exports.getSortOrder = exports.generateEventSearchConditions = exports.generateUserSearchConditions = exports.findSecurityClearanceByRole = exports.getUsersByRole = exports.getUserById = exports.isAccountAccessible = exports.canModifyAccount = exports.hasAllPermissions = exports.hasAnyPermission = exports.hasPermission = exports.hasRole = exports.formatUserListResponse = exports.formatUserProfile = exports.sendErrorResponse = exports.sendSuccessResponse = exports.logEvent = exports.formatTimeRemaining = exports.getTokenTimeRemaining = exports.generateToken = exports.shouldRefreshToken = exports.verifyToken = exports.generateRiderToken = exports.generatePassengerToken = exports.generateAdminToken = exports.checkSuspensionStatus = exports.checkIsUserBannedOrSuspended = exports.checkBanStatus = exports.hasActiveDependencies = exports.checkAccountDependencies = void 0;
4
- exports.logWarning = exports.logSystem = exports.logSecurity = exports.logPayment = exports.logInfo = exports.logError = exports.logDevice = exports.logDebug = exports.logCronjob = exports.logAuth = exports.logApi = exports.extractDedicatedUserFromSerial = exports.buildUserSearchConditions = exports.buildSearchConditions = exports.buildEventLogWhereClause = exports.formatEventLogs = exports.formatEventLog = exports.formatDeviceSession = exports.DPP_OperationsUtil = exports.cloudinaryUtil = exports.stockUtil = exports.hierarchicalView = exports.validateHierarchy = exports.isSuperiorOrEqual = exports.isSuperior = exports.isSubordinateOrEqual = exports.isSubordinate = exports.isRankEqual = exports.getUserLevel = void 0;
4
+ exports.logWarning = exports.logSystem = exports.logInfo = exports.logError = exports.logDebug = exports.extractDedicatedUserFromSerial = exports.buildUserSearchConditions = exports.buildSearchConditions = exports.buildEventLogWhereClause = exports.formatEventLogs = exports.formatEventLog = exports.formatDeviceSession = exports.DPP_OperationsUtil = exports.cloudinaryUtil = exports.stockUtil = exports.hierarchicalView = exports.validateHierarchy = exports.isSuperiorOrEqual = exports.isSuperior = exports.isSubordinateOrEqual = exports.isSubordinate = exports.isRankEqual = exports.getUserLevel = void 0;
5
5
  var account_utils_1 = require("./account.utils");
6
6
  Object.defineProperty(exports, "checkAccountDependencies", { enumerable: true, get: function () { return account_utils_1.checkAccountDependencies; } });
7
7
  Object.defineProperty(exports, "hasActiveDependencies", { enumerable: true, get: function () { return account_utils_1.hasActiveDependencies; } });
@@ -94,14 +94,8 @@ Object.defineProperty(exports, "buildUserSearchConditions", { enumerable: true,
94
94
  var deviceUtils_1 = require("./deviceUtils");
95
95
  Object.defineProperty(exports, "extractDedicatedUserFromSerial", { enumerable: true, get: function () { return deviceUtils_1.extractDedicatedUserFromSerial; } });
96
96
  var systemLog_utils_1 = require("./systemLog.utils");
97
- Object.defineProperty(exports, "logApi", { enumerable: true, get: function () { return systemLog_utils_1.logApi; } });
98
- Object.defineProperty(exports, "logAuth", { enumerable: true, get: function () { return systemLog_utils_1.logAuth; } });
99
- Object.defineProperty(exports, "logCronjob", { enumerable: true, get: function () { return systemLog_utils_1.logCronjob; } });
100
97
  Object.defineProperty(exports, "logDebug", { enumerable: true, get: function () { return systemLog_utils_1.logDebug; } });
101
- Object.defineProperty(exports, "logDevice", { enumerable: true, get: function () { return systemLog_utils_1.logDevice; } });
102
98
  Object.defineProperty(exports, "logError", { enumerable: true, get: function () { return systemLog_utils_1.logError; } });
103
99
  Object.defineProperty(exports, "logInfo", { enumerable: true, get: function () { return systemLog_utils_1.logInfo; } });
104
- Object.defineProperty(exports, "logPayment", { enumerable: true, get: function () { return systemLog_utils_1.logPayment; } });
105
- Object.defineProperty(exports, "logSecurity", { enumerable: true, get: function () { return systemLog_utils_1.logSecurity; } });
106
100
  Object.defineProperty(exports, "logSystem", { enumerable: true, get: function () { return systemLog_utils_1.logSystem; } });
107
101
  Object.defineProperty(exports, "logWarning", { enumerable: true, get: function () { return systemLog_utils_1.logWarning; } });
@@ -1,4 +1,4 @@
1
- import { LogLevel, LogCategory, UserRole } from "vr-models";
1
+ import { LogLevel, LogCategory } from "vr-models";
2
2
  import { Transaction } from "sequelize";
3
3
  export interface SystemLogInput {
4
4
  level?: LogLevel;
@@ -6,55 +6,13 @@ export interface SystemLogInput {
6
6
  message: string;
7
7
  details?: Record<string, any> | null;
8
8
  source?: string | null;
9
- userId?: string | null;
10
- userRole?: UserRole | null;
11
9
  ipAddress?: string | null;
12
10
  userAgent?: string | null;
13
11
  timestamp?: Date;
14
12
  transaction?: Transaction;
15
13
  }
16
- /**
17
- * Create a system log entry
18
- * Uses the static methods from SystemLog model
19
- */
20
- export declare const logSystem: ({ level, category, message, details, source, userId, userRole, ipAddress, userAgent, timestamp, transaction, }: SystemLogInput) => Promise<void>;
21
- /**
22
- * Log an error
23
- */
14
+ export declare const logSystem: ({ level, category, message, details, source, ipAddress, userAgent, timestamp, transaction, }: SystemLogInput) => Promise<void>;
24
15
  export declare const logError: (message: string, options?: Omit<SystemLogInput, "level" | "message">) => Promise<void>;
25
- /**
26
- * Log a warning
27
- */
28
16
  export declare const logWarning: (message: string, options?: Omit<SystemLogInput, "level" | "message">) => Promise<void>;
29
- /**
30
- * Log an info message
31
- */
32
17
  export declare const logInfo: (message: string, options?: Omit<SystemLogInput, "level" | "message">) => Promise<void>;
33
- /**
34
- * Log debug info
35
- */
36
18
  export declare const logDebug: (message: string, options?: Omit<SystemLogInput, "level" | "message">) => Promise<void>;
37
- /**
38
- * Log a cronjob event
39
- */
40
- export declare const logCronjob: (message: string, options?: Omit<SystemLogInput, "level" | "category" | "message">) => Promise<void>;
41
- /**
42
- * Log a payment event
43
- */
44
- export declare const logPayment: (message: string, options?: Omit<SystemLogInput, "level" | "category" | "message">) => Promise<void>;
45
- /**
46
- * Log a device event
47
- */
48
- export declare const logDevice: (message: string, options?: Omit<SystemLogInput, "level" | "category" | "message">) => Promise<void>;
49
- /**
50
- * Log an auth event
51
- */
52
- export declare const logAuth: (message: string, options?: Omit<SystemLogInput, "level" | "category" | "message">) => Promise<void>;
53
- /**
54
- * Log a security event
55
- */
56
- export declare const logSecurity: (message: string, options?: Omit<SystemLogInput, "level" | "category" | "message">) => Promise<void>;
57
- /**
58
- * Log an API request
59
- */
60
- export declare const logApi: (message: string, options?: Omit<SystemLogInput, "level" | "category" | "message">) => Promise<void>;
@@ -1,148 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logApi = exports.logSecurity = exports.logAuth = exports.logDevice = exports.logPayment = exports.logCronjob = exports.logDebug = exports.logInfo = exports.logWarning = exports.logError = exports.logSystem = void 0;
3
+ exports.logDebug = exports.logInfo = exports.logWarning = exports.logError = exports.logSystem = void 0;
4
4
  // src/utils/systemLog.utils.ts
5
5
  const vr_models_1 = require("vr-models");
6
- /**
7
- * Create a system log entry
8
- * Uses the static methods from SystemLog model
9
- */
10
- const logSystem = async ({ level = "INFO", category = "SYSTEM", message, details = null, source = null, userId = null, userRole = null, ipAddress = null, userAgent = null, timestamp, transaction, }) => {
6
+ const logSystem = async ({ level = "INFO", category = "SYSTEM", message, details = null, source = null, ipAddress = null, userAgent = null, timestamp, transaction, }) => {
11
7
  try {
12
8
  const logData = {
13
9
  level,
14
10
  category,
15
11
  message,
16
- details,
17
- source,
18
- userId,
19
- userRole,
20
- ipAddress,
21
- userAgent,
22
- timestamp,
12
+ details: details || null,
13
+ source: source || null,
14
+ ipAddress: ipAddress || null,
15
+ userAgent: userAgent || null,
16
+ timestamp: timestamp || new Date(),
23
17
  };
24
- // Create log entry with optional transaction
25
18
  await vr_models_1.SystemLog.create(logData, { transaction });
26
19
  }
27
20
  catch (err) {
28
21
  console.error("❌ Failed to create system log:", err);
29
- // Don't throw - system logging should not break the main operation
30
22
  }
31
23
  };
32
24
  exports.logSystem = logSystem;
33
- /**
34
- * Log an error
35
- */
36
25
  const logError = async (message, options = {}) => {
37
- await (0, exports.logSystem)({
38
- level: "ERROR",
39
- message,
40
- ...options,
41
- });
26
+ await (0, exports.logSystem)({ level: "ERROR", message, ...options });
42
27
  };
43
28
  exports.logError = logError;
44
- /**
45
- * Log a warning
46
- */
47
29
  const logWarning = async (message, options = {}) => {
48
- await (0, exports.logSystem)({
49
- level: "WARNING",
50
- message,
51
- ...options,
52
- });
30
+ await (0, exports.logSystem)({ level: "WARNING", message, ...options });
53
31
  };
54
32
  exports.logWarning = logWarning;
55
- /**
56
- * Log an info message
57
- */
58
33
  const logInfo = async (message, options = {}) => {
59
- await (0, exports.logSystem)({
60
- level: "INFO",
61
- message,
62
- ...options,
63
- });
34
+ await (0, exports.logSystem)({ level: "INFO", message, ...options });
64
35
  };
65
36
  exports.logInfo = logInfo;
66
- /**
67
- * Log debug info
68
- */
69
37
  const logDebug = async (message, options = {}) => {
70
- await (0, exports.logSystem)({
71
- level: "DEBUG",
72
- message,
73
- ...options,
74
- });
38
+ await (0, exports.logSystem)({ level: "DEBUG", message, ...options });
75
39
  };
76
40
  exports.logDebug = logDebug;
77
- /**
78
- * Log a cronjob event
79
- */
80
- const logCronjob = async (message, options = {}) => {
81
- await (0, exports.logSystem)({
82
- level: "INFO",
83
- category: "CRONJOB",
84
- message,
85
- ...options,
86
- });
87
- };
88
- exports.logCronjob = logCronjob;
89
- /**
90
- * Log a payment event
91
- */
92
- const logPayment = async (message, options = {}) => {
93
- await (0, exports.logSystem)({
94
- level: "INFO",
95
- category: "PAYMENT",
96
- message,
97
- ...options,
98
- });
99
- };
100
- exports.logPayment = logPayment;
101
- /**
102
- * Log a device event
103
- */
104
- const logDevice = async (message, options = {}) => {
105
- await (0, exports.logSystem)({
106
- level: "INFO",
107
- category: "DEVICE",
108
- message,
109
- ...options,
110
- });
111
- };
112
- exports.logDevice = logDevice;
113
- /**
114
- * Log an auth event
115
- */
116
- const logAuth = async (message, options = {}) => {
117
- await (0, exports.logSystem)({
118
- level: "INFO",
119
- category: "AUTH",
120
- message,
121
- ...options,
122
- });
123
- };
124
- exports.logAuth = logAuth;
125
- /**
126
- * Log a security event
127
- */
128
- const logSecurity = async (message, options = {}) => {
129
- await (0, exports.logSystem)({
130
- level: "INFO",
131
- category: "SECURITY",
132
- message,
133
- ...options,
134
- });
135
- };
136
- exports.logSecurity = logSecurity;
137
- /**
138
- * Log an API request
139
- */
140
- const logApi = async (message, options = {}) => {
141
- await (0, exports.logSystem)({
142
- level: "INFO",
143
- category: "API",
144
- message,
145
- ...options,
146
- });
147
- };
148
- exports.logApi = logApi;
@@ -59,53 +59,53 @@ export declare const getDevicesSchema: z.ZodObject<{
59
59
  sortBy: z.ZodOptional<z.ZodEnum<["serialNumber", "status", "createdAt", "updatedAt"]>>;
60
60
  sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
61
61
  }, "strip", z.ZodTypeAny, {
62
- productId?: string | undefined;
62
+ search?: string | undefined;
63
+ limit?: number | undefined;
63
64
  status?: "locked" | "unlocked" | "disabled" | undefined;
64
65
  page?: number | undefined;
65
- limit?: number | undefined;
66
+ sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
67
+ sortOrder?: "DESC" | "ASC" | undefined;
68
+ productId?: string | undefined;
66
69
  dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
67
70
  isPermanentlyUnlocked?: "true" | "false" | undefined;
68
71
  isAssigned?: "true" | "false" | undefined;
69
- search?: string | undefined;
70
- sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
71
- sortOrder?: "ASC" | "DESC" | undefined;
72
72
  }, {
73
- productId?: string | undefined;
73
+ search?: string | undefined;
74
+ limit?: string | undefined;
74
75
  status?: "locked" | "unlocked" | "disabled" | undefined;
75
76
  page?: string | undefined;
76
- limit?: string | undefined;
77
+ sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
78
+ sortOrder?: "DESC" | "ASC" | undefined;
79
+ productId?: string | undefined;
77
80
  dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
78
81
  isPermanentlyUnlocked?: "true" | "false" | undefined;
79
82
  isAssigned?: "true" | "false" | undefined;
80
- search?: string | undefined;
81
- sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
82
- sortOrder?: "ASC" | "DESC" | undefined;
83
83
  }>;
84
84
  }, "strip", z.ZodTypeAny, {
85
85
  query: {
86
- productId?: string | undefined;
86
+ search?: string | undefined;
87
+ limit?: number | undefined;
87
88
  status?: "locked" | "unlocked" | "disabled" | undefined;
88
89
  page?: number | undefined;
89
- limit?: number | undefined;
90
+ sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
91
+ sortOrder?: "DESC" | "ASC" | undefined;
92
+ productId?: string | undefined;
90
93
  dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
91
94
  isPermanentlyUnlocked?: "true" | "false" | undefined;
92
95
  isAssigned?: "true" | "false" | undefined;
93
- search?: string | undefined;
94
- sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
95
- sortOrder?: "ASC" | "DESC" | undefined;
96
96
  };
97
97
  }, {
98
98
  query: {
99
- productId?: string | undefined;
99
+ search?: string | undefined;
100
+ limit?: string | undefined;
100
101
  status?: "locked" | "unlocked" | "disabled" | undefined;
101
102
  page?: string | undefined;
102
- limit?: string | undefined;
103
+ sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
104
+ sortOrder?: "DESC" | "ASC" | undefined;
105
+ productId?: string | undefined;
103
106
  dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
104
107
  isPermanentlyUnlocked?: "true" | "false" | undefined;
105
108
  isAssigned?: "true" | "false" | undefined;
106
- search?: string | undefined;
107
- sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
108
- sortOrder?: "ASC" | "DESC" | undefined;
109
109
  };
110
110
  }>;
111
111
  export declare const deleteDevicesByPairsSchema: z.ZodObject<{
@@ -153,32 +153,32 @@ export declare const lockDevicesSchema: z.ZodObject<{
153
153
  pairIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
154
154
  serialNumbers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
155
155
  }, "strip", z.ZodTypeAny, {
156
- pairIds?: string[] | undefined;
157
156
  reason?: string | undefined;
157
+ pairIds?: string[] | undefined;
158
158
  serialNumbers?: string[] | undefined;
159
159
  }, {
160
- pairIds?: string[] | undefined;
161
160
  reason?: string | undefined;
161
+ pairIds?: string[] | undefined;
162
162
  serialNumbers?: string[] | undefined;
163
163
  }>, {
164
- pairIds?: string[] | undefined;
165
164
  reason?: string | undefined;
165
+ pairIds?: string[] | undefined;
166
166
  serialNumbers?: string[] | undefined;
167
167
  }, {
168
- pairIds?: string[] | undefined;
169
168
  reason?: string | undefined;
169
+ pairIds?: string[] | undefined;
170
170
  serialNumbers?: string[] | undefined;
171
171
  }>;
172
172
  }, "strip", z.ZodTypeAny, {
173
173
  body: {
174
- pairIds?: string[] | undefined;
175
174
  reason?: string | undefined;
175
+ pairIds?: string[] | undefined;
176
176
  serialNumbers?: string[] | undefined;
177
177
  };
178
178
  }, {
179
179
  body: {
180
- pairIds?: string[] | undefined;
181
180
  reason?: string | undefined;
181
+ pairIds?: string[] | undefined;
182
182
  serialNumbers?: string[] | undefined;
183
183
  };
184
184
  }>;
@@ -328,8 +328,8 @@ export declare const customDeviceResetSchema: z.ZodObject<{
328
328
  createdBefore: z.ZodOptional<z.ZodString>;
329
329
  createdAfter: z.ZodOptional<z.ZodString>;
330
330
  }, "strip", z.ZodTypeAny, {
331
- productId?: string | string[] | undefined;
332
331
  status?: string | string[] | undefined;
332
+ productId?: string | string[] | undefined;
333
333
  dedicatedUser?: string | string[] | undefined;
334
334
  isPermanentlyUnlocked?: boolean | undefined;
335
335
  excludeStatus?: string | string[] | undefined;
@@ -338,8 +338,8 @@ export declare const customDeviceResetSchema: z.ZodObject<{
338
338
  createdBefore?: string | undefined;
339
339
  createdAfter?: string | undefined;
340
340
  }, {
341
- productId?: string | string[] | undefined;
342
341
  status?: string | string[] | undefined;
342
+ productId?: string | string[] | undefined;
343
343
  dedicatedUser?: string | string[] | undefined;
344
344
  isPermanentlyUnlocked?: boolean | undefined;
345
345
  excludeStatus?: string | string[] | undefined;
@@ -356,25 +356,32 @@ export declare const customDeviceResetSchema: z.ZodObject<{
356
356
  activatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
357
357
  }, "strip", z.ZodTypeAny, {
358
358
  status?: string | undefined;
359
+ devicePaymentPlanId?: string | null | undefined;
359
360
  dedicatedUser?: string | undefined;
360
361
  isPermanentlyUnlocked?: boolean | undefined;
361
- devicePaymentPlanId?: string | null | undefined;
362
362
  activatedAt?: string | null | undefined;
363
363
  }, {
364
364
  status?: string | undefined;
365
+ devicePaymentPlanId?: string | null | undefined;
365
366
  dedicatedUser?: string | undefined;
366
367
  isPermanentlyUnlocked?: boolean | undefined;
367
- devicePaymentPlanId?: string | null | undefined;
368
368
  activatedAt?: string | null | undefined;
369
369
  }>>;
370
370
  batchSize: z.ZodOptional<z.ZodNumber>;
371
371
  maxRetries: z.ZodOptional<z.ZodNumber>;
372
372
  }, "strip", z.ZodTypeAny, {
373
+ update?: {
374
+ status?: string | undefined;
375
+ devicePaymentPlanId?: string | null | undefined;
376
+ dedicatedUser?: string | undefined;
377
+ isPermanentlyUnlocked?: boolean | undefined;
378
+ activatedAt?: string | null | undefined;
379
+ } | undefined;
373
380
  batchSize?: number | undefined;
374
381
  maxRetries?: number | undefined;
375
382
  condition?: {
376
- productId?: string | string[] | undefined;
377
383
  status?: string | string[] | undefined;
384
+ productId?: string | string[] | undefined;
378
385
  dedicatedUser?: string | string[] | undefined;
379
386
  isPermanentlyUnlocked?: boolean | undefined;
380
387
  excludeStatus?: string | string[] | undefined;
@@ -383,19 +390,19 @@ export declare const customDeviceResetSchema: z.ZodObject<{
383
390
  createdBefore?: string | undefined;
384
391
  createdAfter?: string | undefined;
385
392
  } | undefined;
393
+ }, {
386
394
  update?: {
387
395
  status?: string | undefined;
396
+ devicePaymentPlanId?: string | null | undefined;
388
397
  dedicatedUser?: string | undefined;
389
398
  isPermanentlyUnlocked?: boolean | undefined;
390
- devicePaymentPlanId?: string | null | undefined;
391
399
  activatedAt?: string | null | undefined;
392
400
  } | undefined;
393
- }, {
394
401
  batchSize?: number | undefined;
395
402
  maxRetries?: number | undefined;
396
403
  condition?: {
397
- productId?: string | string[] | undefined;
398
404
  status?: string | string[] | undefined;
405
+ productId?: string | string[] | undefined;
399
406
  dedicatedUser?: string | string[] | undefined;
400
407
  isPermanentlyUnlocked?: boolean | undefined;
401
408
  excludeStatus?: string | string[] | undefined;
@@ -404,21 +411,21 @@ export declare const customDeviceResetSchema: z.ZodObject<{
404
411
  createdBefore?: string | undefined;
405
412
  createdAfter?: string | undefined;
406
413
  } | undefined;
414
+ }>;
415
+ }, "strip", z.ZodTypeAny, {
416
+ body: {
407
417
  update?: {
408
418
  status?: string | undefined;
419
+ devicePaymentPlanId?: string | null | undefined;
409
420
  dedicatedUser?: string | undefined;
410
421
  isPermanentlyUnlocked?: boolean | undefined;
411
- devicePaymentPlanId?: string | null | undefined;
412
422
  activatedAt?: string | null | undefined;
413
423
  } | undefined;
414
- }>;
415
- }, "strip", z.ZodTypeAny, {
416
- body: {
417
424
  batchSize?: number | undefined;
418
425
  maxRetries?: number | undefined;
419
426
  condition?: {
420
- productId?: string | string[] | undefined;
421
427
  status?: string | string[] | undefined;
428
+ productId?: string | string[] | undefined;
422
429
  dedicatedUser?: string | string[] | undefined;
423
430
  isPermanentlyUnlocked?: boolean | undefined;
424
431
  excludeStatus?: string | string[] | undefined;
@@ -427,21 +434,21 @@ export declare const customDeviceResetSchema: z.ZodObject<{
427
434
  createdBefore?: string | undefined;
428
435
  createdAfter?: string | undefined;
429
436
  } | undefined;
437
+ };
438
+ }, {
439
+ body: {
430
440
  update?: {
431
441
  status?: string | undefined;
442
+ devicePaymentPlanId?: string | null | undefined;
432
443
  dedicatedUser?: string | undefined;
433
444
  isPermanentlyUnlocked?: boolean | undefined;
434
- devicePaymentPlanId?: string | null | undefined;
435
445
  activatedAt?: string | null | undefined;
436
446
  } | undefined;
437
- };
438
- }, {
439
- body: {
440
447
  batchSize?: number | undefined;
441
448
  maxRetries?: number | undefined;
442
449
  condition?: {
443
- productId?: string | string[] | undefined;
444
450
  status?: string | string[] | undefined;
451
+ productId?: string | string[] | undefined;
445
452
  dedicatedUser?: string | string[] | undefined;
446
453
  isPermanentlyUnlocked?: boolean | undefined;
447
454
  excludeStatus?: string | string[] | undefined;
@@ -450,12 +457,5 @@ export declare const customDeviceResetSchema: z.ZodObject<{
450
457
  createdBefore?: string | undefined;
451
458
  createdAfter?: string | undefined;
452
459
  } | undefined;
453
- update?: {
454
- status?: string | undefined;
455
- dedicatedUser?: string | undefined;
456
- isPermanentlyUnlocked?: boolean | undefined;
457
- devicePaymentPlanId?: string | null | undefined;
458
- activatedAt?: string | null | undefined;
459
- } | undefined;
460
460
  };
461
461
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-commons",
3
- "version": "1.0.161",
3
+ "version": "1.0.163",
4
4
  "description": "Shared functions package",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -103,7 +103,7 @@
103
103
  "rimraf": "^5.0.5",
104
104
  "streamifier": "^0.1.1",
105
105
  "typescript": "^5.3.3",
106
- "vr-models": "^1.0.83",
106
+ "vr-models": "^1.0.85",
107
107
  "zod": "^3.25.20"
108
108
  },
109
109
  "dependencies": {