vr-commons 1.0.140 → 1.0.141
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,46 +1,34 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const createDevicePairsSchema: z.ZodEffects<z.ZodObject<{
|
|
3
3
|
body: z.ZodObject<{
|
|
4
|
-
serialNumber: z.ZodString;
|
|
5
4
|
productId: z.ZodString;
|
|
5
|
+
pairIds: z.ZodArray<z.ZodString, "many">;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
7
|
productId: string;
|
|
8
|
-
|
|
8
|
+
pairIds: string[];
|
|
9
9
|
}, {
|
|
10
10
|
productId: string;
|
|
11
|
-
|
|
11
|
+
pairIds: string[];
|
|
12
12
|
}>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
body: {
|
|
15
15
|
productId: string;
|
|
16
|
-
|
|
16
|
+
pairIds: string[];
|
|
17
17
|
};
|
|
18
18
|
}, {
|
|
19
19
|
body: {
|
|
20
20
|
productId: string;
|
|
21
|
-
|
|
21
|
+
pairIds: string[];
|
|
22
22
|
};
|
|
23
|
-
}
|
|
24
|
-
export declare const bulkCreateDevicesSchema: z.ZodObject<{
|
|
25
|
-
body: z.ZodObject<{
|
|
26
|
-
productId: z.ZodString;
|
|
27
|
-
serialNumbers: z.ZodArray<z.ZodString, "many">;
|
|
28
|
-
}, "strip", z.ZodTypeAny, {
|
|
29
|
-
productId: string;
|
|
30
|
-
serialNumbers: string[];
|
|
31
|
-
}, {
|
|
32
|
-
productId: string;
|
|
33
|
-
serialNumbers: string[];
|
|
34
|
-
}>;
|
|
35
|
-
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
}>, {
|
|
36
24
|
body: {
|
|
37
25
|
productId: string;
|
|
38
|
-
|
|
26
|
+
pairIds: string[];
|
|
39
27
|
};
|
|
40
28
|
}, {
|
|
41
29
|
body: {
|
|
42
30
|
productId: string;
|
|
43
|
-
|
|
31
|
+
pairIds: string[];
|
|
44
32
|
};
|
|
45
33
|
}>;
|
|
46
34
|
export declare const updateDeviceSchema: z.ZodObject<{
|
|
@@ -65,23 +53,23 @@ export declare const updateDeviceSchema: z.ZodObject<{
|
|
|
65
53
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
66
54
|
}>;
|
|
67
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
params: {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
68
59
|
body: {
|
|
69
60
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
70
61
|
serialNumber?: string | undefined;
|
|
71
62
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
72
63
|
};
|
|
64
|
+
}, {
|
|
73
65
|
params: {
|
|
74
66
|
id: string;
|
|
75
67
|
};
|
|
76
|
-
}, {
|
|
77
68
|
body: {
|
|
78
69
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
79
70
|
serialNumber?: string | undefined;
|
|
80
71
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | null | undefined;
|
|
81
72
|
};
|
|
82
|
-
params: {
|
|
83
|
-
id: string;
|
|
84
|
-
};
|
|
85
73
|
}>;
|
|
86
74
|
export declare const getDeviceSchema: z.ZodObject<{
|
|
87
75
|
params: z.ZodObject<{
|
|
@@ -113,53 +101,53 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
113
101
|
sortBy: z.ZodOptional<z.ZodEnum<["serialNumber", "status", "createdAt", "updatedAt"]>>;
|
|
114
102
|
sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
|
|
115
103
|
}, "strip", z.ZodTypeAny, {
|
|
116
|
-
search?: string | undefined;
|
|
117
|
-
limit?: number | undefined;
|
|
118
104
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
119
|
-
page?: number | undefined;
|
|
120
|
-
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
121
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
122
105
|
productId?: string | undefined;
|
|
123
106
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
107
|
+
page?: number | undefined;
|
|
108
|
+
limit?: number | undefined;
|
|
124
109
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
125
110
|
isAssigned?: "true" | "false" | undefined;
|
|
126
|
-
}, {
|
|
127
111
|
search?: string | undefined;
|
|
128
|
-
|
|
112
|
+
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
113
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
114
|
+
}, {
|
|
129
115
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
130
|
-
page?: string | undefined;
|
|
131
|
-
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
132
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
133
116
|
productId?: string | undefined;
|
|
134
117
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
118
|
+
page?: string | undefined;
|
|
119
|
+
limit?: string | undefined;
|
|
135
120
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
136
121
|
isAssigned?: "true" | "false" | undefined;
|
|
122
|
+
search?: string | undefined;
|
|
123
|
+
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
124
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
137
125
|
}>;
|
|
138
126
|
}, "strip", z.ZodTypeAny, {
|
|
139
127
|
query: {
|
|
140
|
-
search?: string | undefined;
|
|
141
|
-
limit?: number | undefined;
|
|
142
128
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
143
|
-
page?: number | undefined;
|
|
144
|
-
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
145
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
146
129
|
productId?: string | undefined;
|
|
147
130
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
131
|
+
page?: number | undefined;
|
|
132
|
+
limit?: number | undefined;
|
|
148
133
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
149
134
|
isAssigned?: "true" | "false" | undefined;
|
|
135
|
+
search?: string | undefined;
|
|
136
|
+
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
137
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
150
138
|
};
|
|
151
139
|
}, {
|
|
152
140
|
query: {
|
|
153
|
-
search?: string | undefined;
|
|
154
|
-
limit?: string | undefined;
|
|
155
141
|
status?: "locked" | "unlocked" | "disabled" | undefined;
|
|
156
|
-
page?: string | undefined;
|
|
157
|
-
sortBy?: "createdAt" | "updatedAt" | "status" | "serialNumber" | undefined;
|
|
158
|
-
sortOrder?: "DESC" | "ASC" | undefined;
|
|
159
142
|
productId?: string | undefined;
|
|
160
143
|
dedicatedUser?: "PASSENGER" | "RIDER" | "N/A" | undefined;
|
|
144
|
+
page?: string | undefined;
|
|
145
|
+
limit?: string | undefined;
|
|
161
146
|
isPermanentlyUnlocked?: "true" | "false" | undefined;
|
|
162
147
|
isAssigned?: "true" | "false" | undefined;
|
|
148
|
+
search?: string | undefined;
|
|
149
|
+
sortBy?: "status" | "serialNumber" | "createdAt" | "updatedAt" | undefined;
|
|
150
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
163
151
|
};
|
|
164
152
|
}>;
|
|
165
153
|
export declare const deleteDeviceSchema: z.ZodObject<{
|
|
@@ -242,19 +230,19 @@ export declare const disableDeviceSchema: z.ZodObject<{
|
|
|
242
230
|
reason: string;
|
|
243
231
|
}>;
|
|
244
232
|
}, "strip", z.ZodTypeAny, {
|
|
245
|
-
body: {
|
|
246
|
-
reason: string;
|
|
247
|
-
};
|
|
248
233
|
params: {
|
|
249
234
|
id: string;
|
|
250
235
|
};
|
|
251
|
-
}, {
|
|
252
236
|
body: {
|
|
253
237
|
reason: string;
|
|
254
238
|
};
|
|
239
|
+
}, {
|
|
255
240
|
params: {
|
|
256
241
|
id: string;
|
|
257
242
|
};
|
|
243
|
+
body: {
|
|
244
|
+
reason: string;
|
|
245
|
+
};
|
|
258
246
|
}>;
|
|
259
247
|
export declare const makePermanentSchema: z.ZodObject<{
|
|
260
248
|
params: z.ZodObject<{
|
|
@@ -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.updateDeviceSchema = exports.
|
|
3
|
+
exports.checkAvailabilitySchema = exports.makePermanentSchema = exports.disableDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.updateDeviceSchema = exports.createDevicePairsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const vr_models_1 = require("vr-models");
|
|
6
6
|
// Constants
|
|
@@ -16,28 +16,37 @@ const deviceBaseSchema = {
|
|
|
16
16
|
isPermanentlyUnlocked: zod_1.z.boolean().optional(),
|
|
17
17
|
dedicatedUser: zod_1.z.enum(vr_models_1.DEVICE_DEDICATION).nullable().optional(),
|
|
18
18
|
};
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
// ✅ Pair ID format: 2 letters + 3 numbers + 1 letter
|
|
20
|
+
// Example: AA001A, AB123B, XZ999Z
|
|
21
|
+
// No letter 'O' to avoid confusion with 0
|
|
22
|
+
const PAIR_ID_REGEX = /^[A-NP-Z]{2}[0-9]{3}[A-NP-Z]{1}$/;
|
|
23
|
+
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";
|
|
24
|
+
// ✅ Helper to validate pair IDs are unique in body
|
|
25
|
+
const validateUniquePairIds = (pairIds) => {
|
|
26
|
+
const unique = new Set(pairIds);
|
|
27
|
+
return unique.size === pairIds.length;
|
|
28
|
+
};
|
|
29
|
+
// ✅ ONLY bulk create - no single device creation
|
|
30
|
+
exports.createDevicePairsSchema = zod_1.z
|
|
31
|
+
.object({
|
|
30
32
|
body: zod_1.z.object({
|
|
31
|
-
productId:
|
|
32
|
-
|
|
33
|
-
.array(zod_1.z
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.max(64, "Serial number too long")
|
|
37
|
-
.regex(/^[A-Z0-9-]+$/, "Serial number must contain only uppercase letters, numbers, and hyphens"))
|
|
38
|
-
.min(1, "At least one serial number required")
|
|
39
|
-
.max(100, "Cannot create more than 100 devices at once"),
|
|
33
|
+
productId: zod_1.z.string().uuid("Invalid product ID"),
|
|
34
|
+
pairIds: zod_1.z
|
|
35
|
+
.array(zod_1.z.string().regex(PAIR_ID_REGEX, PAIR_ID_ERROR))
|
|
36
|
+
.min(1, "At least one pair ID required")
|
|
37
|
+
.max(50, "Cannot create more than 50 pairs at once"),
|
|
40
38
|
}),
|
|
39
|
+
})
|
|
40
|
+
.superRefine((data, ctx) => {
|
|
41
|
+
const { pairIds } = data.body;
|
|
42
|
+
// ✅ Ensure no duplicate pair IDs in the request body
|
|
43
|
+
if (!validateUniquePairIds(pairIds)) {
|
|
44
|
+
ctx.addIssue({
|
|
45
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
46
|
+
message: `Duplicate pair IDs found. Please ensure all pair IDs are unique.`,
|
|
47
|
+
path: ["pairIds"],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
41
50
|
});
|
|
42
51
|
// Update device schema
|
|
43
52
|
exports.updateDeviceSchema = zod_1.z.object({
|
|
@@ -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,
|
|
13
|
+
export { checkAvailabilitySchema, createDevicePairsSchema, adminLockDeviceSchema, adminUnlockDeviceSchema, updateDeviceSchema, 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.updateDeviceSchema = exports.adminUnlockDeviceSchema = exports.adminLockDeviceSchema = exports.
|
|
5
|
-
exports.getEventLogSchema = exports.listEventLogsSchema = exports.deletePlanSchema = exports.recordPaymentSchema = exports.listPlansSchema = exports.getUserPlansSchema = exports.getPlanSchema = exports.getDevicePlanSchema = exports.limitedUpdateSchema = exports.createPlanSchema =
|
|
4
|
+
exports.makePermanentSchema = exports.disableDeviceSchema = exports.deleteDeviceSchema = exports.getDevicesSchema = exports.getDeviceSchema = exports.updateDeviceSchema = 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 = exports.createPlanSchema = 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");
|
|
@@ -115,7 +115,7 @@ Object.defineProperty(exports, "getPricingsSchema", { enumerable: true, get: fun
|
|
|
115
115
|
Object.defineProperty(exports, "deletePricingSchema", { enumerable: true, get: function () { return pricings_validations_1.deletePricingSchema; } });
|
|
116
116
|
var admin_devices_validations_1 = require("./admin.devices.validations");
|
|
117
117
|
Object.defineProperty(exports, "checkAvailabilitySchema", { enumerable: true, get: function () { return admin_devices_validations_1.checkAvailabilitySchema; } });
|
|
118
|
-
Object.defineProperty(exports, "
|
|
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
121
|
Object.defineProperty(exports, "updateDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.updateDeviceSchema; } });
|
|
@@ -124,7 +124,6 @@ Object.defineProperty(exports, "getDevicesSchema", { enumerable: true, get: func
|
|
|
124
124
|
Object.defineProperty(exports, "deleteDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.deleteDeviceSchema; } });
|
|
125
125
|
Object.defineProperty(exports, "disableDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.disableDeviceSchema; } });
|
|
126
126
|
Object.defineProperty(exports, "makePermanentSchema", { enumerable: true, get: function () { return admin_devices_validations_1.makePermanentSchema; } });
|
|
127
|
-
Object.defineProperty(exports, "createDeviceSchema", { enumerable: true, get: function () { return admin_devices_validations_1.createDeviceSchema; } });
|
|
128
127
|
var admin_devicePayment_validations_1 = require("./admin.devicePayment.validations");
|
|
129
128
|
Object.defineProperty(exports, "createPlanSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.createPlanSchema; } });
|
|
130
129
|
Object.defineProperty(exports, "limitedUpdateSchema", { enumerable: true, get: function () { return admin_devicePayment_validations_1.limitedUpdateSchema; } });
|