vr-commons 1.0.156 → 1.0.157
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/utils/admin.device.utils.d.ts +23 -0
- package/dist/utils/admin.device.utils.js +200 -0
- package/dist/validations/admin.devices.validations.d.ts +65 -26
- package/dist/validations/admin.devices.validations.js +28 -1
- package/dist/validations/index.d.ts +1 -1
- package/dist/validations/index.js +3 -1
- package/package.json +1 -1
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { Device, UserRole } from "vr-models";
|
|
2
2
|
import { Transaction } from "sequelize";
|
|
3
3
|
import { StockChangeResult } from "./types";
|
|
4
|
+
export interface LockAllDevicesResult {
|
|
5
|
+
success: boolean;
|
|
6
|
+
lockedCount: number;
|
|
7
|
+
failedCount: number;
|
|
8
|
+
failedDeviceIds: string[];
|
|
9
|
+
errors: string[];
|
|
10
|
+
message: string;
|
|
11
|
+
totalProcessed: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LockDevicesOptions {
|
|
14
|
+
actorId?: string;
|
|
15
|
+
actorRole?: UserRole | string;
|
|
16
|
+
transaction?: any;
|
|
17
|
+
batchSize?: number;
|
|
18
|
+
maxRetries?: number;
|
|
19
|
+
triggeredBy?: "cronjob" | "manual";
|
|
20
|
+
}
|
|
4
21
|
export declare const stockUtil: {
|
|
5
22
|
/**
|
|
6
23
|
* Increment stock when devices are added/created
|
|
@@ -120,4 +137,10 @@ export declare const stockUtil: {
|
|
|
120
137
|
message: string;
|
|
121
138
|
devices: Device[];
|
|
122
139
|
}>;
|
|
140
|
+
/**
|
|
141
|
+
* Lock ALL devices regardless of payment plan status
|
|
142
|
+
* Uses batch processing for large datasets
|
|
143
|
+
* If no transaction is provided, runs without transaction
|
|
144
|
+
*/
|
|
145
|
+
lockAllDevices(options?: LockDevicesOptions): Promise<LockAllDevicesResult>;
|
|
123
146
|
};
|
|
@@ -6,6 +6,7 @@ const vr_models_1 = require("vr-models");
|
|
|
6
6
|
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
|
+
const systemLog_utils_1 = require("./systemLog.utils");
|
|
9
10
|
/**
|
|
10
11
|
* Extract dedication from serial number
|
|
11
12
|
*/
|
|
@@ -451,4 +452,203 @@ exports.stockUtil = {
|
|
|
451
452
|
devices: updatedDevices,
|
|
452
453
|
};
|
|
453
454
|
},
|
|
455
|
+
/**
|
|
456
|
+
* Lock ALL devices regardless of payment plan status
|
|
457
|
+
* Uses batch processing for large datasets
|
|
458
|
+
* If no transaction is provided, runs without transaction
|
|
459
|
+
*/
|
|
460
|
+
async lockAllDevices(options = {}) {
|
|
461
|
+
const { actorId = "SYSTEM", actorRole = "SYSTEM", transaction, batchSize = 100, maxRetries = 3, triggeredBy = "manual", } = options;
|
|
462
|
+
const isSystem = actorRole === "SYSTEM" || triggeredBy === "cronjob";
|
|
463
|
+
const isAdmin = !isSystem;
|
|
464
|
+
try {
|
|
465
|
+
const lockedDeviceIds = [];
|
|
466
|
+
const failedDeviceIds = [];
|
|
467
|
+
const errors = [];
|
|
468
|
+
let totalLocked = 0;
|
|
469
|
+
let totalProcessed = 0;
|
|
470
|
+
let batchNumber = 0;
|
|
471
|
+
let hasMore = true;
|
|
472
|
+
console.log(`🔒 Locking ALL devices at ${new Date().toISOString()}`);
|
|
473
|
+
// Log start of job
|
|
474
|
+
if (isSystem) {
|
|
475
|
+
await (0, systemLog_utils_1.logInfo)(`Lock all devices job started`, {
|
|
476
|
+
category: "CRONJOB",
|
|
477
|
+
source: "device-lock.cronjob",
|
|
478
|
+
details: { triggeredBy, batchSize, maxRetries },
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
await (0, systemLog_utils_1.logInfo)(`Lock all devices triggered by ${actorRole}`, {
|
|
483
|
+
category: "DEVICE",
|
|
484
|
+
userId: actorId || undefined,
|
|
485
|
+
userRole: actorRole,
|
|
486
|
+
source: "device-lock.manual",
|
|
487
|
+
details: { triggeredBy, batchSize, maxRetries },
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// Process in batches
|
|
491
|
+
while (hasMore) {
|
|
492
|
+
batchNumber++;
|
|
493
|
+
const offset = (batchNumber - 1) * batchSize;
|
|
494
|
+
// Get devices for current batch (ALL devices except disabled)
|
|
495
|
+
const devices = await vr_models_1.Device.findAll({
|
|
496
|
+
where: {
|
|
497
|
+
status: { [sequelize_1.Op.ne]: "disabled" },
|
|
498
|
+
deletedAt: null,
|
|
499
|
+
},
|
|
500
|
+
limit: batchSize,
|
|
501
|
+
offset: offset,
|
|
502
|
+
transaction: transaction, // Use transaction if provided, otherwise undefined
|
|
503
|
+
});
|
|
504
|
+
if (devices.length === 0) {
|
|
505
|
+
hasMore = false;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
totalProcessed += devices.length;
|
|
509
|
+
console.log(`📦 Batch ${batchNumber}: Processing ${devices.length} devices (Total: ${totalProcessed})`);
|
|
510
|
+
// Process each device with retry logic
|
|
511
|
+
for (const device of devices) {
|
|
512
|
+
let retries = 0;
|
|
513
|
+
let locked = false;
|
|
514
|
+
while (!locked && retries < maxRetries) {
|
|
515
|
+
try {
|
|
516
|
+
// Skip if already locked
|
|
517
|
+
if (device.status === "locked") {
|
|
518
|
+
console.log(`🔒 Device ${device.serialNumber} already locked`);
|
|
519
|
+
locked = true;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
// Lock the device
|
|
523
|
+
await device.update({ status: "locked" }, { transaction: transaction } // Use transaction if provided
|
|
524
|
+
);
|
|
525
|
+
lockedDeviceIds.push(device.id);
|
|
526
|
+
totalLocked++;
|
|
527
|
+
locked = true;
|
|
528
|
+
console.log(`🔒 Locked device ${device.serialNumber} (${device.id})`);
|
|
529
|
+
// Log event for each lock
|
|
530
|
+
await (0, eventLog_utils_1.logEvent)({
|
|
531
|
+
actorId: isSystem ? null : actorId,
|
|
532
|
+
actorType: isSystem ? "ADMIN" : actorRole,
|
|
533
|
+
action: "DEVICES_LOCKED",
|
|
534
|
+
entity: "Device",
|
|
535
|
+
entityId: device.id,
|
|
536
|
+
metadata: {
|
|
537
|
+
serialNumber: device.serialNumber,
|
|
538
|
+
pairId: device.pairId,
|
|
539
|
+
productId: device.productId,
|
|
540
|
+
lockedAt: new Date().toISOString(),
|
|
541
|
+
reason: "Scheduled lock all devices",
|
|
542
|
+
triggeredBy: triggeredBy,
|
|
543
|
+
batchNumber,
|
|
544
|
+
previousStatus: device.status,
|
|
545
|
+
},
|
|
546
|
+
deviceSession: null,
|
|
547
|
+
transaction: transaction,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
catch (err) {
|
|
551
|
+
retries++;
|
|
552
|
+
console.error(`❌ Failed to lock device ${device.serialNumber} (attempt ${retries}/${maxRetries}):`, err instanceof Error ? err.message : "Unknown error");
|
|
553
|
+
if (retries >= maxRetries) {
|
|
554
|
+
failedDeviceIds.push(device.id);
|
|
555
|
+
errors.push(`Device ${device.serialNumber} (${device.id}): ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
// Wait before retry (exponential backoff)
|
|
559
|
+
await new Promise((resolve) => setTimeout(resolve, retries * 1000));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
// If we got fewer devices than batch size, we're done
|
|
565
|
+
if (devices.length < batchSize) {
|
|
566
|
+
hasMore = false;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
const result = {
|
|
570
|
+
success: true,
|
|
571
|
+
lockedCount: totalLocked,
|
|
572
|
+
failedCount: failedDeviceIds.length,
|
|
573
|
+
failedDeviceIds,
|
|
574
|
+
errors,
|
|
575
|
+
totalProcessed,
|
|
576
|
+
message: `Successfully locked ${totalLocked} devices out of ${totalProcessed} processed${failedDeviceIds.length > 0 ? `, ${failedDeviceIds.length} failed` : ""}`,
|
|
577
|
+
};
|
|
578
|
+
console.log(`✅ Lock all devices completed:`, result);
|
|
579
|
+
// Log completion
|
|
580
|
+
if (isSystem) {
|
|
581
|
+
await (0, systemLog_utils_1.logInfo)(`Lock all devices job completed`, {
|
|
582
|
+
category: "CRONJOB",
|
|
583
|
+
source: "device-lock.cronjob",
|
|
584
|
+
details: {
|
|
585
|
+
lockedCount: result.lockedCount,
|
|
586
|
+
failedCount: result.failedCount,
|
|
587
|
+
totalProcessed: result.totalProcessed,
|
|
588
|
+
hasErrors: result.errors.length > 0,
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
await (0, systemLog_utils_1.logInfo)(`Lock all devices completed by ${actorRole}`, {
|
|
594
|
+
category: "DEVICE",
|
|
595
|
+
userId: actorId || undefined,
|
|
596
|
+
userRole: actorRole,
|
|
597
|
+
source: "device-lock.manual",
|
|
598
|
+
details: {
|
|
599
|
+
lockedCount: result.lockedCount,
|
|
600
|
+
failedCount: result.failedCount,
|
|
601
|
+
totalProcessed: result.totalProcessed,
|
|
602
|
+
hasErrors: result.errors.length > 0,
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
// Log errors if any
|
|
607
|
+
if (result.errors.length > 0) {
|
|
608
|
+
await (0, systemLog_utils_1.logError)(`Lock all devices had ${result.errors.length} failures`, {
|
|
609
|
+
category: isSystem ? "CRONJOB" : "DEVICE",
|
|
610
|
+
source: isSystem ? "device-lock.cronjob" : "device-lock.manual",
|
|
611
|
+
userId: isSystem ? null : actorId || undefined,
|
|
612
|
+
userRole: isSystem ? null : actorRole,
|
|
613
|
+
details: {
|
|
614
|
+
failedCount: result.failedCount,
|
|
615
|
+
failedDeviceIds: result.failedDeviceIds,
|
|
616
|
+
errors: result.errors,
|
|
617
|
+
},
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return result;
|
|
621
|
+
}
|
|
622
|
+
catch (err) {
|
|
623
|
+
console.error("❌ Lock all devices failed:", err);
|
|
624
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occurred";
|
|
625
|
+
const result = {
|
|
626
|
+
success: false,
|
|
627
|
+
lockedCount: 0,
|
|
628
|
+
failedCount: 0,
|
|
629
|
+
failedDeviceIds: [],
|
|
630
|
+
errors: [errorMessage],
|
|
631
|
+
totalProcessed: 0,
|
|
632
|
+
message: `Lock all devices job failed: ${errorMessage}`,
|
|
633
|
+
};
|
|
634
|
+
// Log failure
|
|
635
|
+
if (isSystem) {
|
|
636
|
+
await (0, systemLog_utils_1.logError)(`Lock all devices job failed`, {
|
|
637
|
+
category: "CRONJOB",
|
|
638
|
+
source: "device-lock.cronjob",
|
|
639
|
+
details: { error: errorMessage },
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
await (0, systemLog_utils_1.logError)(`Lock all devices failed`, {
|
|
644
|
+
category: "DEVICE",
|
|
645
|
+
userId: actorId || undefined,
|
|
646
|
+
userRole: actorRole,
|
|
647
|
+
source: "device-lock.manual",
|
|
648
|
+
details: { error: errorMessage },
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return result;
|
|
652
|
+
}
|
|
653
|
+
},
|
|
454
654
|
};
|
|
@@ -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
|
-
|
|
63
|
-
limit?: number | undefined;
|
|
62
|
+
productId?: string | undefined;
|
|
64
63
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
65
64
|
page?: number | undefined;
|
|
66
|
-
|
|
67
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
68
|
-
productId?: string | undefined;
|
|
65
|
+
limit?: number | undefined;
|
|
69
66
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
70
67
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
71
68
|
isAssigned?: "true" | "false" | undefined;
|
|
72
|
-
}, {
|
|
73
69
|
search?: string | undefined;
|
|
74
|
-
|
|
70
|
+
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
71
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
productId?: string | undefined;
|
|
75
74
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
76
75
|
page?: string | undefined;
|
|
77
|
-
|
|
78
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
79
|
-
productId?: string | undefined;
|
|
76
|
+
limit?: string | undefined;
|
|
80
77
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
81
78
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
82
79
|
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
|
-
|
|
87
|
-
limit?: number | undefined;
|
|
86
|
+
productId?: string | undefined;
|
|
88
87
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
89
88
|
page?: number | undefined;
|
|
90
|
-
|
|
91
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
92
|
-
productId?: string | undefined;
|
|
89
|
+
limit?: number | undefined;
|
|
93
90
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
94
91
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
95
92
|
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
|
-
|
|
100
|
-
limit?: string | undefined;
|
|
99
|
+
productId?: string | undefined;
|
|
101
100
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
102
101
|
page?: string | undefined;
|
|
103
|
-
|
|
104
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
105
|
-
productId?: string | undefined;
|
|
102
|
+
limit?: string | undefined;
|
|
106
103
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
107
104
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
108
105
|
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
|
-
reason?: string | undefined;
|
|
157
156
|
pairIds?: string[] | undefined;
|
|
157
|
+
reason?: string | undefined;
|
|
158
158
|
serialNumbers?: string[] | undefined;
|
|
159
159
|
}, {
|
|
160
|
-
reason?: string | undefined;
|
|
161
160
|
pairIds?: string[] | undefined;
|
|
161
|
+
reason?: string | undefined;
|
|
162
162
|
serialNumbers?: string[] | undefined;
|
|
163
163
|
}>, {
|
|
164
|
-
reason?: string | undefined;
|
|
165
164
|
pairIds?: string[] | undefined;
|
|
165
|
+
reason?: string | undefined;
|
|
166
166
|
serialNumbers?: string[] | undefined;
|
|
167
167
|
}, {
|
|
168
|
-
reason?: string | undefined;
|
|
169
168
|
pairIds?: string[] | undefined;
|
|
169
|
+
reason?: string | undefined;
|
|
170
170
|
serialNumbers?: string[] | undefined;
|
|
171
171
|
}>;
|
|
172
172
|
}, "strip", z.ZodTypeAny, {
|
|
173
173
|
body: {
|
|
174
|
-
reason?: string | undefined;
|
|
175
174
|
pairIds?: string[] | undefined;
|
|
175
|
+
reason?: string | undefined;
|
|
176
176
|
serialNumbers?: string[] | undefined;
|
|
177
177
|
};
|
|
178
178
|
}, {
|
|
179
179
|
body: {
|
|
180
|
-
reason?: string | undefined;
|
|
181
180
|
pairIds?: string[] | undefined;
|
|
181
|
+
reason?: string | undefined;
|
|
182
182
|
serialNumbers?: string[] | undefined;
|
|
183
183
|
};
|
|
184
184
|
}>;
|
|
@@ -293,3 +293,42 @@ export declare const checkAvailabilitySchema: z.ZodObject<{
|
|
|
293
293
|
productId: string;
|
|
294
294
|
};
|
|
295
295
|
}>;
|
|
296
|
+
export declare const triggerDeviceLockSchema: z.ZodObject<{
|
|
297
|
+
body: z.ZodOptional<z.ZodObject<{
|
|
298
|
+
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
299
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
300
|
+
}, "strip", z.ZodTypeAny, {
|
|
301
|
+
batchSize?: number | undefined;
|
|
302
|
+
maxRetries?: number | undefined;
|
|
303
|
+
}, {
|
|
304
|
+
batchSize?: number | undefined;
|
|
305
|
+
maxRetries?: number | undefined;
|
|
306
|
+
}>>;
|
|
307
|
+
}, "strip", z.ZodTypeAny, {
|
|
308
|
+
body?: {
|
|
309
|
+
batchSize?: number | undefined;
|
|
310
|
+
maxRetries?: number | undefined;
|
|
311
|
+
} | undefined;
|
|
312
|
+
}, {
|
|
313
|
+
body?: {
|
|
314
|
+
batchSize?: number | undefined;
|
|
315
|
+
maxRetries?: number | undefined;
|
|
316
|
+
} | undefined;
|
|
317
|
+
}>;
|
|
318
|
+
export declare const retryFailedLocksSchema: z.ZodObject<{
|
|
319
|
+
body: z.ZodObject<{
|
|
320
|
+
pairIds: z.ZodArray<z.ZodString, "many">;
|
|
321
|
+
}, "strip", z.ZodTypeAny, {
|
|
322
|
+
pairIds: string[];
|
|
323
|
+
}, {
|
|
324
|
+
pairIds: string[];
|
|
325
|
+
}>;
|
|
326
|
+
}, "strip", z.ZodTypeAny, {
|
|
327
|
+
body: {
|
|
328
|
+
pairIds: string[];
|
|
329
|
+
};
|
|
330
|
+
}, {
|
|
331
|
+
body: {
|
|
332
|
+
pairIds: string[];
|
|
333
|
+
};
|
|
334
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkAvailabilitySchema = exports.makeDevicesPermanentSchema = exports.enableDevicesSchema = exports.disableDevicesSchema = exports.unlockDevicesSchema = exports.lockDevicesSchema = exports.permanentDeleteDevicesByPairsSchema = exports.deleteDevicesByPairsSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.createDevicePairsSchema = exports.deduplicatePairIds = exports.PAIR_ID_REGEX = void 0;
|
|
3
|
+
exports.retryFailedLocksSchema = exports.triggerDeviceLockSchema = exports.checkAvailabilitySchema = exports.makeDevicesPermanentSchema = exports.enableDevicesSchema = exports.disableDevicesSchema = exports.unlockDevicesSchema = exports.lockDevicesSchema = exports.permanentDeleteDevicesByPairsSchema = exports.deleteDevicesByPairsSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.createDevicePairsSchema = exports.deduplicatePairIds = exports.PAIR_ID_REGEX = void 0;
|
|
4
4
|
// src/validations/device.validations.ts
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const vr_models_1 = require("vr-models");
|
|
@@ -143,3 +143,30 @@ exports.checkAvailabilitySchema = zod_1.z.object({
|
|
|
143
143
|
productId: zod_1.z.string().uuid("Invalid product ID"),
|
|
144
144
|
}),
|
|
145
145
|
});
|
|
146
|
+
// ======================== CRON JOB RELATED VALIDATIONS ===========================
|
|
147
|
+
exports.triggerDeviceLockSchema = zod_1.z.object({
|
|
148
|
+
body: zod_1.z
|
|
149
|
+
.object({
|
|
150
|
+
batchSize: zod_1.z
|
|
151
|
+
.number()
|
|
152
|
+
.int()
|
|
153
|
+
.min(1, "Batch size must be at least 1")
|
|
154
|
+
.max(500, "Batch size cannot exceed 500")
|
|
155
|
+
.optional(),
|
|
156
|
+
maxRetries: zod_1.z
|
|
157
|
+
.number()
|
|
158
|
+
.int()
|
|
159
|
+
.min(1, "Max retries must be at least 1")
|
|
160
|
+
.max(5, "Max retries cannot exceed 5")
|
|
161
|
+
.optional(),
|
|
162
|
+
})
|
|
163
|
+
.optional(),
|
|
164
|
+
});
|
|
165
|
+
exports.retryFailedLocksSchema = zod_1.z.object({
|
|
166
|
+
body: zod_1.z.object({
|
|
167
|
+
pairIds: zod_1.z
|
|
168
|
+
.array(zod_1.z.string().regex(exports.PAIR_ID_REGEX, PAIR_ID_ERROR))
|
|
169
|
+
.min(1, "At least one pair ID required")
|
|
170
|
+
.max(500, "Cannot LOCK more than 500 pairs at once"),
|
|
171
|
+
}),
|
|
172
|
+
});
|
|
@@ -10,6 +10,6 @@ export { updateProfileSchema, requestPhoneChangeSchema, verifyPhoneChangeSchema,
|
|
|
10
10
|
export { updateAdminSchema, updateRiderSchema, deleteUserSchema, getUserSchema, getUsersSchema, hireAdminSchema, promoteAdminSchema, demoteAdminSchema, fireEmployeeSchema, upgradeToRiderSchema, resetPasswordSchema, } from "./users.admin.validations";
|
|
11
11
|
export { createProductSchema, updateProductSchema, getProductSchema, getProductsSchema, deactivateProductSchema, activateProductSchema, deleteProductSchema, updateStockSchema, } from "./product.validations";
|
|
12
12
|
export { createPricingSchema, updatePricingSchema, getPricingSchema, getPricingsSchema, deletePricingSchema, } from "./pricings.validations";
|
|
13
|
-
export { checkAvailabilitySchema, createDevicePairsSchema, lockDevicesSchema, unlockDevicesSchema, deleteDevicesByPairsSchema, makeDevicesPermanentSchema, permanentDeleteDevicesByPairsSchema, disableDevicesSchema, enableDevicesSchema, getDeviceSchema, getDevicesSchema, } from "./admin.devices.validations";
|
|
13
|
+
export { checkAvailabilitySchema, createDevicePairsSchema, lockDevicesSchema, unlockDevicesSchema, deleteDevicesByPairsSchema, makeDevicesPermanentSchema, permanentDeleteDevicesByPairsSchema, disableDevicesSchema, enableDevicesSchema, getDeviceSchema, getDevicesSchema, retryFailedLocksSchema, triggerDeviceLockSchema, } from "./admin.devices.validations";
|
|
14
14
|
export { createPlanSchema, limitedUpdateSchema, getDevicePlanSchema, getPlanSchema, getUserPlansSchema, listPlansSchema, recordPaymentSchema, deletePlanSchema, } from "./admin.devicePayment.validations";
|
|
15
15
|
export { listEventLogsSchema, getEventLogSchema, } from "./eventlogs.admin.validations";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAppSpecsSchema = exports.activateAppSpecsSchema = exports.getActiveAppSpecsSchema = exports.listAppSpecsSchema = exports.updateAppSpecsSchema = exports.createAppSpecsSchema = exports.exportBansSchema = exports.createSuspensionSchema = exports.createBanSchema = exports.extendSuspensionSchema = exports.revokeSuspensionSchema = exports.revokeBanSchema = exports.reviewAppealSchema = exports.listSuspensionsSchema = exports.listPendingAppealsSchema = exports.listBansSchema = exports.getUserBansSchema = exports.getUserSuspensionsSchema = exports.getSuspensionSchema = exports.getUserRestrictionsSchema = exports.getBanSchema = exports.submitSuspensionAppealSchema = exports.submitBanAppealSchema = exports.deactivateAccountSchema = exports.createRiderSchema = exports.updateRiderProfileSchema = exports.updatePassengerProfileSchema = exports.passengerSignupSchema = exports.viewProfileSchema = exports.getAllUsersSchema = exports.updateUserProfileSchema = exports.getUserByIdSchema = exports.createUserSchema = exports.googleLoginSchema = exports.completePassengerProfileSchema = exports.checkRiderAccountSchema = exports.setRiderPasswordSchema = exports.riderPasswordRegex = exports.passwordRegex = exports.emailRegex = exports.phoneRegex = exports.requestOtpSchema = exports.resendOtpSchema = exports.verifyOtpSchema = exports.registerSchema = exports.refreshTokenSchema = exports.userLoginSchema = exports.forgotPasswordSchema = exports.riderLoginSchema = exports.validate = void 0;
|
|
4
4
|
exports.getDeviceSchema = exports.enableDevicesSchema = exports.disableDevicesSchema = exports.permanentDeleteDevicesByPairsSchema = exports.makeDevicesPermanentSchema = exports.deleteDevicesByPairsSchema = exports.unlockDevicesSchema = exports.lockDevicesSchema = exports.createDevicePairsSchema = exports.checkAvailabilitySchema = exports.deletePricingSchema = exports.getPricingsSchema = exports.getPricingSchema = exports.updatePricingSchema = exports.createPricingSchema = exports.updateStockSchema = exports.deleteProductSchema = exports.activateProductSchema = exports.deactivateProductSchema = exports.getProductsSchema = exports.getProductSchema = exports.updateProductSchema = exports.createProductSchema = exports.resetPasswordSchema = exports.upgradeToRiderSchema = exports.fireEmployeeSchema = exports.demoteAdminSchema = exports.promoteAdminSchema = exports.hireAdminSchema = exports.getUsersSchema = exports.getUserSchema = exports.deleteUserSchema = exports.updateRiderSchema = exports.updateAdminSchema = exports.registerRiderSchema = exports.riderPasswordSchema = exports.changePasswordSchema = exports.strongPasswordRegex = exports.deleteAccountSchema = exports.verifyPhoneChangeSchema = exports.requestPhoneChangeSchema = exports.updateProfileSchema = exports.getInstallmentsSchema = exports.getInstallmentByIdSchema = exports.payInstallmentSchema = exports.serialRegex = exports.extendSessionSchema = exports.unlockDeviceSchema = exports.getUserPaymentPlanSchema = exports.listUserPaymentPlansSchema = void 0;
|
|
5
|
-
exports.getEventLogSchema = exports.listEventLogsSchema = exports.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema = exports.createPlanSchema = exports.getDevicesSchema = void 0;
|
|
5
|
+
exports.getEventLogSchema = exports.listEventLogsSchema = exports.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema = exports.createPlanSchema = exports.triggerDeviceLockSchema = exports.retryFailedLocksSchema = exports.getDevicesSchema = void 0;
|
|
6
6
|
var validate_validations_1 = require("./validate.validations");
|
|
7
7
|
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_validations_1.validate; } });
|
|
8
8
|
var auth_validations_1 = require("./auth.validations");
|
|
@@ -125,6 +125,8 @@ Object.defineProperty(exports, "disableDevicesSchema", { enumerable: true, get:
|
|
|
125
125
|
Object.defineProperty(exports, "enableDevicesSchema", { enumerable: true, get: function () { return admin_devices_validations_1.enableDevicesSchema; } });
|
|
126
126
|
Object.defineProperty(exports, "getDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.getDeviceSchema; } });
|
|
127
127
|
Object.defineProperty(exports, "getDevicesSchema", { enumerable: true, get: function () { return admin_devices_validations_1.getDevicesSchema; } });
|
|
128
|
+
Object.defineProperty(exports, "retryFailedLocksSchema", { enumerable: true, get: function () { return admin_devices_validations_1.retryFailedLocksSchema; } });
|
|
129
|
+
Object.defineProperty(exports, "triggerDeviceLockSchema", { enumerable: true, get: function () { return admin_devices_validations_1.triggerDeviceLockSchema; } });
|
|
128
130
|
var admin_devicePayment_validations_1 = require("./admin.devicePayment.validations");
|
|
129
131
|
Object.defineProperty(exports, "createPlanSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.createPlanSchema; } });
|
|
130
132
|
Object.defineProperty(exports, "limitedUpdateSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.limitedUpdateSchema; } });
|