vr-commons 1.0.145 → 1.0.147
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const PAIR_ID_REGEX: RegExp;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const deduplicatePairIds: (pairIds: string[]) => string[];
|
|
4
4
|
export declare const createDevicePairsSchema: z.ZodObject<{
|
|
5
5
|
body: z.ZodEffects<z.ZodObject<{
|
|
6
6
|
productId: z.ZodString;
|
|
@@ -12,83 +12,21 @@ export declare const createDevicePairsSchema: z.ZodObject<{
|
|
|
12
12
|
productId: string;
|
|
13
13
|
pairIds: string[];
|
|
14
14
|
}>, {
|
|
15
|
-
productId: string;
|
|
16
15
|
pairIds: string[];
|
|
16
|
+
productId: string;
|
|
17
17
|
}, {
|
|
18
18
|
productId: string;
|
|
19
19
|
pairIds: string[];
|
|
20
20
|
}>;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
22
22
|
body: {
|
|
23
|
-
productId: string;
|
|
24
23
|
pairIds: string[];
|
|
25
|
-
};
|
|
26
|
-
}, {
|
|
27
|
-
body: {
|
|
28
24
|
productId: string;
|
|
29
|
-
pairIds: string[];
|
|
30
|
-
};
|
|
31
|
-
}>;
|
|
32
|
-
export declare const createDeviceSchema: z.ZodObject<{
|
|
33
|
-
body: z.ZodObject<{
|
|
34
|
-
serialNumber: z.ZodString;
|
|
35
|
-
productId: z.ZodString;
|
|
36
|
-
}, "strip", z.ZodTypeAny, {
|
|
37
|
-
productId: string;
|
|
38
|
-
serialNumber: string;
|
|
39
|
-
}, {
|
|
40
|
-
productId: string;
|
|
41
|
-
serialNumber: string;
|
|
42
|
-
}>;
|
|
43
|
-
}, "strip", z.ZodTypeAny, {
|
|
44
|
-
body: {
|
|
45
|
-
productId: string;
|
|
46
|
-
serialNumber: string;
|
|
47
25
|
};
|
|
48
26
|
}, {
|
|
49
27
|
body: {
|
|
50
28
|
productId: string;
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
}>;
|
|
54
|
-
export declare const updateDeviceSchema: z.ZodObject<{
|
|
55
|
-
params: z.ZodObject<{
|
|
56
|
-
id: z.ZodString;
|
|
57
|
-
}, "strip", z.ZodTypeAny, {
|
|
58
|
-
id: string;
|
|
59
|
-
}, {
|
|
60
|
-
id: string;
|
|
61
|
-
}>;
|
|
62
|
-
body: z.ZodObject<{
|
|
63
|
-
serialNumber: z.ZodOptional<z.ZodString>;
|
|
64
|
-
status: z.ZodOptional<z.ZodEnum<["locked", "unlocked", "disabled"]>>;
|
|
65
|
-
dedicatedUser: z.ZodOptional<z.ZodNullable<z.ZodEnum<["PASSENGER", "RIDER", "N/A"]>>>;
|
|
66
|
-
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
68
|
-
serialNumber?: string | undefined;
|
|
69
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
70
|
-
}, {
|
|
71
|
-
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
72
|
-
serialNumber?: string | undefined;
|
|
73
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
74
|
-
}>;
|
|
75
|
-
}, "strip", z.ZodTypeAny, {
|
|
76
|
-
params: {
|
|
77
|
-
id: string;
|
|
78
|
-
};
|
|
79
|
-
body: {
|
|
80
|
-
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
81
|
-
serialNumber?: string | undefined;
|
|
82
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
83
|
-
};
|
|
84
|
-
}, {
|
|
85
|
-
params: {
|
|
86
|
-
id: string;
|
|
87
|
-
};
|
|
88
|
-
body: {
|
|
89
|
-
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
90
|
-
serialNumber?: string | undefined;
|
|
91
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
29
|
+
pairIds: string[];
|
|
92
30
|
};
|
|
93
31
|
}>;
|
|
94
32
|
export declare const getDeviceSchema: z.ZodObject<{
|
|
@@ -123,9 +61,9 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
123
61
|
}, "strip", z.ZodTypeAny, {
|
|
124
62
|
productId?: string | undefined;
|
|
125
63
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
126
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
127
64
|
page?: number | undefined;
|
|
128
65
|
limit?: number | undefined;
|
|
66
|
+
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
129
67
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
130
68
|
isAssigned?: "true" | "false" | undefined;
|
|
131
69
|
search?: string | undefined;
|
|
@@ -134,9 +72,9 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
134
72
|
}, {
|
|
135
73
|
productId?: string | undefined;
|
|
136
74
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
137
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
138
75
|
page?: string | undefined;
|
|
139
76
|
limit?: string | undefined;
|
|
77
|
+
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
140
78
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
141
79
|
isAssigned?: "true" | "false" | undefined;
|
|
142
80
|
search?: string | undefined;
|
|
@@ -147,9 +85,9 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
147
85
|
query: {
|
|
148
86
|
productId?: string | undefined;
|
|
149
87
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
150
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
151
88
|
page?: number | undefined;
|
|
152
89
|
limit?: number | undefined;
|
|
90
|
+
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
153
91
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
154
92
|
isAssigned?: "true" | "false" | undefined;
|
|
155
93
|
search?: string | undefined;
|
|
@@ -160,9 +98,9 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
160
98
|
query: {
|
|
161
99
|
productId?: string | undefined;
|
|
162
100
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
163
|
-
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
164
101
|
page?: string | undefined;
|
|
165
102
|
limit?: string | undefined;
|
|
103
|
+
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
166
104
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
167
105
|
isAssigned?: "true" | "false" | undefined;
|
|
168
106
|
search?: string | undefined;
|
|
@@ -284,22 +222,17 @@ export declare const makePermanentSchema: z.ZodObject<{
|
|
|
284
222
|
export declare const checkAvailabilitySchema: z.ZodObject<{
|
|
285
223
|
query: z.ZodObject<{
|
|
286
224
|
productId: z.ZodString;
|
|
287
|
-
quantity: z.ZodEffects<z.ZodEnum<["1", "2"]>, number, "1" | "2">;
|
|
288
225
|
}, "strip", z.ZodTypeAny, {
|
|
289
226
|
productId: string;
|
|
290
|
-
quantity: number;
|
|
291
227
|
}, {
|
|
292
228
|
productId: string;
|
|
293
|
-
quantity: "1" | "2";
|
|
294
229
|
}>;
|
|
295
230
|
}, "strip", z.ZodTypeAny, {
|
|
296
231
|
query: {
|
|
297
232
|
productId: string;
|
|
298
|
-
quantity: number;
|
|
299
233
|
};
|
|
300
234
|
}, {
|
|
301
235
|
query: {
|
|
302
236
|
productId: string;
|
|
303
|
-
quantity: "1" | "2";
|
|
304
237
|
};
|
|
305
238
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkAvailabilitySchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.
|
|
3
|
+
exports.checkAvailabilitySchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.deleteDeviceSchema = 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");
|
|
@@ -22,14 +22,13 @@ const deviceBaseSchema = {
|
|
|
22
22
|
// No letter 'O' to avoid confusion with 0
|
|
23
23
|
exports.PAIR_ID_REGEX = /^[A-NP-Z]{2}[0-9]{3}[A-NP-Z]{1}$/;
|
|
24
24
|
const PAIR_ID_ERROR = "Pair ID must be 6 characters: 2 letters (A-Z, excluding O) + 3 digits + 1 letter (A-Z, excluding O). Example: AA001A";
|
|
25
|
-
// ✅ Helper to
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return unique.size === pairIds.length;
|
|
25
|
+
// ✅ Helper to remove duplicates and return unique pair IDs
|
|
26
|
+
const deduplicatePairIds = (pairIds) => {
|
|
27
|
+
return [...new Set(pairIds)];
|
|
29
28
|
};
|
|
30
|
-
exports.
|
|
29
|
+
exports.deduplicatePairIds = deduplicatePairIds;
|
|
31
30
|
// ✅ ONLY bulk create - no single device creation
|
|
32
|
-
// ✅
|
|
31
|
+
// ✅ Removes duplicates automatically instead of rejecting
|
|
33
32
|
exports.createDevicePairsSchema = zod_1.z.object({
|
|
34
33
|
body: zod_1.z
|
|
35
34
|
.object({
|
|
@@ -37,35 +36,15 @@ exports.createDevicePairsSchema = zod_1.z.object({
|
|
|
37
36
|
pairIds: zod_1.z
|
|
38
37
|
.array(zod_1.z.string().regex(exports.PAIR_ID_REGEX, PAIR_ID_ERROR))
|
|
39
38
|
.min(1, "At least one pair ID required")
|
|
40
|
-
.max(
|
|
39
|
+
.max(100, "Cannot create more than 100 pairs at once"),
|
|
41
40
|
})
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
51
|
-
// Create device schema (admin adds new stock)
|
|
52
|
-
exports.createDeviceSchema = zod_1.z.object({
|
|
53
|
-
body: zod_1.z.object({
|
|
54
|
-
serialNumber: deviceBaseSchema.serialNumber,
|
|
55
|
-
productId: deviceBaseSchema.productId,
|
|
56
|
-
// Status defaults to "locked" in model
|
|
57
|
-
// dedicatedUser starts as null
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
// Update device schema
|
|
61
|
-
exports.updateDeviceSchema = zod_1.z.object({
|
|
62
|
-
params: zod_1.z.object({
|
|
63
|
-
id: zod_1.z.string().uuid("Invalid device ID"),
|
|
64
|
-
}),
|
|
65
|
-
body: zod_1.z.object({
|
|
66
|
-
serialNumber: deviceBaseSchema.serialNumber.optional(),
|
|
67
|
-
status: deviceBaseSchema.status,
|
|
68
|
-
dedicatedUser: deviceBaseSchema.dedicatedUser,
|
|
41
|
+
.transform((data) => {
|
|
42
|
+
// ✅ Remove duplicates and keep unique pair IDs
|
|
43
|
+
const uniquePairIds = (0, exports.deduplicatePairIds)(data.pairIds);
|
|
44
|
+
return {
|
|
45
|
+
...data,
|
|
46
|
+
pairIds: uniquePairIds,
|
|
47
|
+
};
|
|
69
48
|
}),
|
|
70
49
|
});
|
|
71
50
|
// Get device by ID schema
|
|
@@ -131,6 +110,5 @@ exports.makePermanentSchema = zod_1.z.object({
|
|
|
131
110
|
exports.checkAvailabilitySchema = zod_1.z.object({
|
|
132
111
|
query: zod_1.z.object({
|
|
133
112
|
productId: zod_1.z.string().uuid("Invalid product ID"),
|
|
134
|
-
quantity: zod_1.z.enum(["1", "2"]).transform(Number), // 1 or 2 devices
|
|
135
113
|
}),
|
|
136
114
|
});
|
|
@@ -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, adminLockDeviceSchema, adminUnlockDeviceSchema,
|
|
13
|
+
export { checkAvailabilitySchema, createDevicePairsSchema, adminLockDeviceSchema, adminUnlockDeviceSchema, getDeviceSchema, getDevicesSchema, deleteDeviceSchema, disableDeviceSchema, makePermanentSchema, } 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";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
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
|
-
exports.makePermanentSchema = exports.disableDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.
|
|
5
|
-
exports.getEventLogSchema = exports.listEventLogsSchema = exports.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema =
|
|
4
|
+
exports.createPlanSchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = 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 = 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");
|
|
@@ -118,7 +118,6 @@ Object.defineProperty(exports, "checkAvailabilitySchema", { enumerable: true, ge
|
|
|
118
118
|
Object.defineProperty(exports, "createDevicePairsSchema", { enumerable: true, get: function () { return admin_devices_validations_1.createDevicePairsSchema; } });
|
|
119
119
|
Object.defineProperty(exports, "adminLockDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.adminLockDeviceSchema; } });
|
|
120
120
|
Object.defineProperty(exports, "adminUnlockDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.adminUnlockDeviceSchema; } });
|
|
121
|
-
Object.defineProperty(exports, "updateDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.updateDeviceSchema; } });
|
|
122
121
|
Object.defineProperty(exports, "getDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.getDeviceSchema; } });
|
|
123
122
|
Object.defineProperty(exports, "getDevicesSchema", { enumerable: true, get: function () { return admin_devices_validations_1.getDevicesSchema; } });
|
|
124
123
|
Object.defineProperty(exports, "deleteDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.deleteDeviceSchema; } });
|