vr-commons 1.0.147 → 1.0.149
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 +17 -1
- package/dist/utils/admin.device.utils.js +45 -0
- package/dist/validations/admin.devicePayment.validations.d.ts +20 -20
- package/dist/validations/admin.devices.validations.d.ts +108 -59
- package/dist/validations/admin.devices.validations.js +66 -36
- package/dist/validations/appSpecs.validations.d.ts +2 -2
- package/dist/validations/auth.validations.d.ts +8 -8
- package/dist/validations/devicePaymentPlan.validations.d.ts +4 -4
- package/dist/validations/eventlogs.admin.validations.d.ts +22 -22
- package/dist/validations/index.d.ts +1 -1
- package/dist/validations/index.js +8 -7
- package/dist/validations/moderation.validations.d.ts +21 -21
- package/dist/validations/pricings.validations.d.ts +22 -22
- package/dist/validations/product.validations.d.ts +16 -16
- package/dist/validations/profiles.validations.d.ts +30 -30
- package/dist/validations/users.admin.validations.d.ts +12 -12
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserRole } from "vr-models";
|
|
1
|
+
import { Device, UserRole } from "vr-models";
|
|
2
2
|
import { Transaction } from "sequelize";
|
|
3
3
|
import { StockChangeResult } from "./types";
|
|
4
4
|
export declare const stockUtil: {
|
|
@@ -66,4 +66,20 @@ export declare const stockUtil: {
|
|
|
66
66
|
* No letter 'O' to avoid confusion with 0
|
|
67
67
|
*/
|
|
68
68
|
validatePairIdFormat(pairId: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get devices by pair IDs (returns both RIDER and PASSENGER)
|
|
71
|
+
*/
|
|
72
|
+
getDevicesByPairIds(pairIds: string[], transaction?: any): Promise<Device[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Get devices by serial numbers
|
|
75
|
+
*/
|
|
76
|
+
getDevicesBySerialNumbers(serialNumbers: string[], transaction?: any): Promise<Device[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Validate that exactly one identifier type is provided
|
|
79
|
+
*/
|
|
80
|
+
validateIdentifiers(pairIds?: string[], serialNumbers?: string[]): {
|
|
81
|
+
valid: boolean;
|
|
82
|
+
error?: string | undefined;
|
|
83
|
+
devices?: Device[] | undefined;
|
|
84
|
+
};
|
|
69
85
|
};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.stockUtil = void 0;
|
|
4
4
|
// src/utils/stock.util.ts
|
|
5
5
|
const vr_models_1 = require("vr-models");
|
|
6
|
+
const sequelize_1 = require("sequelize");
|
|
6
7
|
const eventLog_utils_1 = require("./eventLog.utils");
|
|
7
8
|
const admin_devices_validations_1 = require("../validations/admin.devices.validations");
|
|
8
9
|
exports.stockUtil = {
|
|
@@ -243,4 +244,48 @@ exports.stockUtil = {
|
|
|
243
244
|
validatePairIdFormat(pairId) {
|
|
244
245
|
return admin_devices_validations_1.PAIR_ID_REGEX.test(pairId);
|
|
245
246
|
},
|
|
247
|
+
/**
|
|
248
|
+
* Get devices by pair IDs (returns both RIDER and PASSENGER)
|
|
249
|
+
*/
|
|
250
|
+
async getDevicesByPairIds(pairIds, transaction) {
|
|
251
|
+
return await vr_models_1.Device.findAll({
|
|
252
|
+
where: {
|
|
253
|
+
pairId: { [sequelize_1.Op.in]: pairIds },
|
|
254
|
+
},
|
|
255
|
+
include: [{ model: vr_models_1.DevicePaymentPlan, as: "paymentPlan" }],
|
|
256
|
+
transaction,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
/**
|
|
260
|
+
* Get devices by serial numbers
|
|
261
|
+
*/
|
|
262
|
+
async getDevicesBySerialNumbers(serialNumbers, transaction) {
|
|
263
|
+
return await vr_models_1.Device.findAll({
|
|
264
|
+
where: {
|
|
265
|
+
serialNumber: { [sequelize_1.Op.in]: serialNumbers },
|
|
266
|
+
},
|
|
267
|
+
include: [{ model: vr_models_1.DevicePaymentPlan, as: "paymentPlan" }],
|
|
268
|
+
transaction,
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* Validate that exactly one identifier type is provided
|
|
273
|
+
*/
|
|
274
|
+
validateIdentifiers(pairIds, serialNumbers) {
|
|
275
|
+
const hasPairIds = pairIds && pairIds.length > 0;
|
|
276
|
+
const hasSerialNumbers = serialNumbers && serialNumbers.length > 0;
|
|
277
|
+
if (!hasPairIds && !hasSerialNumbers) {
|
|
278
|
+
return {
|
|
279
|
+
valid: false,
|
|
280
|
+
error: "Either pairIds or serialNumbers must be provided",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if (hasPairIds && hasSerialNumbers) {
|
|
284
|
+
return {
|
|
285
|
+
valid: false,
|
|
286
|
+
error: "Cannot provide both pairIds and serialNumbers. Choose one.",
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return { valid: true };
|
|
290
|
+
},
|
|
246
291
|
};
|
|
@@ -6,27 +6,27 @@ export declare const createPlanSchema: z.ZodObject<{
|
|
|
6
6
|
pricingId: z.ZodString;
|
|
7
7
|
productId: z.ZodString;
|
|
8
8
|
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
userId: string;
|
|
10
9
|
productId: string;
|
|
10
|
+
userId: string;
|
|
11
11
|
deviceIds: string[];
|
|
12
12
|
pricingId: string;
|
|
13
13
|
}, {
|
|
14
|
-
userId: string;
|
|
15
14
|
productId: string;
|
|
15
|
+
userId: string;
|
|
16
16
|
deviceIds: string[];
|
|
17
17
|
pricingId: string;
|
|
18
18
|
}>;
|
|
19
19
|
}, "strip", z.ZodTypeAny, {
|
|
20
20
|
body: {
|
|
21
|
-
userId: string;
|
|
22
21
|
productId: string;
|
|
22
|
+
userId: string;
|
|
23
23
|
deviceIds: string[];
|
|
24
24
|
pricingId: string;
|
|
25
25
|
};
|
|
26
26
|
}, {
|
|
27
27
|
body: {
|
|
28
|
-
userId: string;
|
|
29
28
|
productId: string;
|
|
29
|
+
userId: string;
|
|
30
30
|
deviceIds: string[];
|
|
31
31
|
pricingId: string;
|
|
32
32
|
};
|
|
@@ -46,17 +46,17 @@ export declare const listPlansSchema: z.ZodObject<{
|
|
|
46
46
|
limit: number;
|
|
47
47
|
page: number;
|
|
48
48
|
search?: string | undefined;
|
|
49
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
49
50
|
userId?: string | undefined;
|
|
50
|
-
status?: "ACTIVE" | "DEFAULTED" | "PENDING" | "COMPLETED" | "CANCELLED" | undefined;
|
|
51
51
|
isOverdue?: "true" | "false" | undefined;
|
|
52
52
|
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
53
53
|
sortOrder?: "DESC" | "ASC" | undefined;
|
|
54
54
|
deviceId?: string | undefined;
|
|
55
55
|
}, {
|
|
56
|
-
search?: string | undefined;
|
|
57
56
|
limit?: string | undefined;
|
|
57
|
+
search?: string | undefined;
|
|
58
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
58
59
|
userId?: string | undefined;
|
|
59
|
-
status?: "ACTIVE" | "DEFAULTED" | "PENDING" | "COMPLETED" | "CANCELLED" | undefined;
|
|
60
60
|
isOverdue?: "true" | "false" | undefined;
|
|
61
61
|
page?: string | undefined;
|
|
62
62
|
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
@@ -68,8 +68,8 @@ export declare const listPlansSchema: z.ZodObject<{
|
|
|
68
68
|
limit: number;
|
|
69
69
|
page: number;
|
|
70
70
|
search?: string | undefined;
|
|
71
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
71
72
|
userId?: string | undefined;
|
|
72
|
-
status?: "ACTIVE" | "DEFAULTED" | "PENDING" | "COMPLETED" | "CANCELLED" | undefined;
|
|
73
73
|
isOverdue?: "true" | "false" | undefined;
|
|
74
74
|
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
75
75
|
sortOrder?: "DESC" | "ASC" | undefined;
|
|
@@ -77,10 +77,10 @@ export declare const listPlansSchema: z.ZodObject<{
|
|
|
77
77
|
};
|
|
78
78
|
}, {
|
|
79
79
|
query: {
|
|
80
|
-
search?: string | undefined;
|
|
81
80
|
limit?: string | undefined;
|
|
81
|
+
search?: string | undefined;
|
|
82
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
82
83
|
userId?: string | undefined;
|
|
83
|
-
status?: "ACTIVE" | "DEFAULTED" | "PENDING" | "COMPLETED" | "CANCELLED" | undefined;
|
|
84
84
|
isOverdue?: "true" | "false" | undefined;
|
|
85
85
|
page?: string | undefined;
|
|
86
86
|
sortBy?: "createdAt" | "updatedAt" | "paidAmount" | "outstandingAmount" | "nextInstallmentDueAt" | undefined;
|
|
@@ -117,10 +117,10 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
117
117
|
status: z.ZodOptional<z.ZodEnum<["PENDING", "ACTIVE", "COMPLETED", "DEFAULTED", "CANCELLED"]>>;
|
|
118
118
|
includeCompleted: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
119
119
|
}, "strip", z.ZodTypeAny, {
|
|
120
|
-
status?: "ACTIVE" | "
|
|
120
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
121
121
|
includeCompleted?: "true" | "false" | undefined;
|
|
122
122
|
}, {
|
|
123
|
-
status?: "ACTIVE" | "
|
|
123
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
124
124
|
includeCompleted?: "true" | "false" | undefined;
|
|
125
125
|
}>>;
|
|
126
126
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -128,7 +128,7 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
128
128
|
userId: string;
|
|
129
129
|
};
|
|
130
130
|
query?: {
|
|
131
|
-
status?: "ACTIVE" | "
|
|
131
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
132
132
|
includeCompleted?: "true" | "false" | undefined;
|
|
133
133
|
} | undefined;
|
|
134
134
|
}, {
|
|
@@ -136,7 +136,7 @@ export declare const getUserPlansSchema: z.ZodObject<{
|
|
|
136
136
|
userId: string;
|
|
137
137
|
};
|
|
138
138
|
query?: {
|
|
139
|
-
status?: "ACTIVE" | "
|
|
139
|
+
status?: "ACTIVE" | "PENDING" | "COMPLETED" | "DEFAULTED" | "CANCELLED" | undefined;
|
|
140
140
|
includeCompleted?: "true" | "false" | undefined;
|
|
141
141
|
} | undefined;
|
|
142
142
|
}>;
|
|
@@ -171,30 +171,30 @@ export declare const limitedUpdateSchema: z.ZodObject<{
|
|
|
171
171
|
deviceIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
172
172
|
userId: z.ZodOptional<z.ZodString>;
|
|
173
173
|
}, "strip", z.ZodTypeAny, {
|
|
174
|
-
userId?: string | undefined;
|
|
175
174
|
productId?: string | undefined;
|
|
175
|
+
userId?: string | undefined;
|
|
176
176
|
deviceIds?: string[] | undefined;
|
|
177
177
|
pricingId?: string | undefined;
|
|
178
178
|
}, {
|
|
179
|
-
userId?: string | undefined;
|
|
180
179
|
productId?: string | undefined;
|
|
180
|
+
userId?: string | undefined;
|
|
181
181
|
deviceIds?: string[] | undefined;
|
|
182
182
|
pricingId?: string | undefined;
|
|
183
183
|
}>, {
|
|
184
|
-
userId?: string | undefined;
|
|
185
184
|
productId?: string | undefined;
|
|
185
|
+
userId?: string | undefined;
|
|
186
186
|
deviceIds?: string[] | undefined;
|
|
187
187
|
pricingId?: string | undefined;
|
|
188
188
|
}, {
|
|
189
|
-
userId?: string | undefined;
|
|
190
189
|
productId?: string | undefined;
|
|
190
|
+
userId?: string | undefined;
|
|
191
191
|
deviceIds?: string[] | undefined;
|
|
192
192
|
pricingId?: string | undefined;
|
|
193
193
|
}>;
|
|
194
194
|
}, "strip", z.ZodTypeAny, {
|
|
195
195
|
body: {
|
|
196
|
-
userId?: string | undefined;
|
|
197
196
|
productId?: string | undefined;
|
|
197
|
+
userId?: string | undefined;
|
|
198
198
|
deviceIds?: string[] | undefined;
|
|
199
199
|
pricingId?: string | undefined;
|
|
200
200
|
};
|
|
@@ -203,8 +203,8 @@ export declare const limitedUpdateSchema: z.ZodObject<{
|
|
|
203
203
|
};
|
|
204
204
|
}, {
|
|
205
205
|
body: {
|
|
206
|
-
userId?: string | undefined;
|
|
207
206
|
productId?: string | undefined;
|
|
207
|
+
userId?: string | undefined;
|
|
208
208
|
deviceIds?: string[] | undefined;
|
|
209
209
|
pricingId?: string | undefined;
|
|
210
210
|
};
|
|
@@ -108,115 +108,164 @@ export declare const getDevicesSchema: z.ZodObject<{
|
|
|
108
108
|
sortOrder?: "ASC" | "DESC" | undefined;
|
|
109
109
|
};
|
|
110
110
|
}>;
|
|
111
|
-
export declare const
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
export declare const deleteDevicesByPairsSchema: z.ZodObject<{
|
|
112
|
+
body: z.ZodObject<{
|
|
113
|
+
pairIds: z.ZodArray<z.ZodString, "many">;
|
|
114
114
|
}, "strip", z.ZodTypeAny, {
|
|
115
|
-
|
|
115
|
+
pairIds: string[];
|
|
116
116
|
}, {
|
|
117
|
-
|
|
117
|
+
pairIds: string[];
|
|
118
118
|
}>;
|
|
119
119
|
}, "strip", z.ZodTypeAny, {
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
body: {
|
|
121
|
+
pairIds: string[];
|
|
122
122
|
};
|
|
123
123
|
}, {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
body: {
|
|
125
|
+
pairIds: string[];
|
|
126
126
|
};
|
|
127
127
|
}>;
|
|
128
|
-
export declare const
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
export declare const permanentDeleteDevicesByPairsSchema: z.ZodObject<{
|
|
129
|
+
body: z.ZodObject<{
|
|
130
|
+
pairIds: z.ZodArray<z.ZodString, "many">;
|
|
131
131
|
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
|
|
132
|
+
pairIds: string[];
|
|
133
133
|
}, {
|
|
134
|
-
|
|
134
|
+
pairIds: string[];
|
|
135
135
|
}>;
|
|
136
|
-
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
body: {
|
|
138
|
+
pairIds: string[];
|
|
139
|
+
};
|
|
140
|
+
}, {
|
|
141
|
+
body: {
|
|
142
|
+
pairIds: string[];
|
|
143
|
+
};
|
|
144
|
+
}>;
|
|
145
|
+
export declare const lockDevicesSchema: z.ZodObject<{
|
|
146
|
+
body: z.ZodEffects<z.ZodObject<{
|
|
137
147
|
reason: z.ZodOptional<z.ZodString>;
|
|
148
|
+
pairIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
149
|
+
serialNumbers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
138
150
|
}, "strip", z.ZodTypeAny, {
|
|
151
|
+
pairIds?: string[] | undefined;
|
|
139
152
|
reason?: string | undefined;
|
|
153
|
+
serialNumbers?: string[] | undefined;
|
|
140
154
|
}, {
|
|
155
|
+
pairIds?: string[] | undefined;
|
|
156
|
+
reason?: string | undefined;
|
|
157
|
+
serialNumbers?: string[] | undefined;
|
|
158
|
+
}>, {
|
|
159
|
+
pairIds?: string[] | undefined;
|
|
141
160
|
reason?: string | undefined;
|
|
142
|
-
|
|
161
|
+
serialNumbers?: string[] | undefined;
|
|
162
|
+
}, {
|
|
163
|
+
pairIds?: string[] | undefined;
|
|
164
|
+
reason?: string | undefined;
|
|
165
|
+
serialNumbers?: string[] | undefined;
|
|
166
|
+
}>;
|
|
143
167
|
}, "strip", z.ZodTypeAny, {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
147
|
-
body?: {
|
|
168
|
+
body: {
|
|
169
|
+
pairIds?: string[] | undefined;
|
|
148
170
|
reason?: string | undefined;
|
|
149
|
-
|
|
150
|
-
}, {
|
|
151
|
-
params: {
|
|
152
|
-
id: string;
|
|
171
|
+
serialNumbers?: string[] | undefined;
|
|
153
172
|
};
|
|
154
|
-
|
|
173
|
+
}, {
|
|
174
|
+
body: {
|
|
175
|
+
pairIds?: string[] | undefined;
|
|
155
176
|
reason?: string | undefined;
|
|
156
|
-
|
|
177
|
+
serialNumbers?: string[] | undefined;
|
|
178
|
+
};
|
|
157
179
|
}>;
|
|
158
|
-
export declare const
|
|
159
|
-
|
|
160
|
-
|
|
180
|
+
export declare const unlockDevicesSchema: z.ZodObject<{
|
|
181
|
+
body: z.ZodEffects<z.ZodObject<{
|
|
182
|
+
pairIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
183
|
+
serialNumbers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
161
184
|
}, "strip", z.ZodTypeAny, {
|
|
162
|
-
|
|
185
|
+
pairIds?: string[] | undefined;
|
|
186
|
+
serialNumbers?: string[] | undefined;
|
|
163
187
|
}, {
|
|
164
|
-
|
|
188
|
+
pairIds?: string[] | undefined;
|
|
189
|
+
serialNumbers?: string[] | undefined;
|
|
190
|
+
}>, {
|
|
191
|
+
pairIds?: string[] | undefined;
|
|
192
|
+
serialNumbers?: string[] | undefined;
|
|
193
|
+
}, {
|
|
194
|
+
pairIds?: string[] | undefined;
|
|
195
|
+
serialNumbers?: string[] | undefined;
|
|
165
196
|
}>;
|
|
166
197
|
}, "strip", z.ZodTypeAny, {
|
|
167
|
-
|
|
168
|
-
|
|
198
|
+
body: {
|
|
199
|
+
pairIds?: string[] | undefined;
|
|
200
|
+
serialNumbers?: string[] | undefined;
|
|
169
201
|
};
|
|
170
202
|
}, {
|
|
171
|
-
|
|
172
|
-
|
|
203
|
+
body: {
|
|
204
|
+
pairIds?: string[] | undefined;
|
|
205
|
+
serialNumbers?: string[] | undefined;
|
|
173
206
|
};
|
|
174
207
|
}>;
|
|
175
|
-
export declare const
|
|
176
|
-
|
|
177
|
-
id: z.ZodString;
|
|
178
|
-
}, "strip", z.ZodTypeAny, {
|
|
179
|
-
id: string;
|
|
180
|
-
}, {
|
|
181
|
-
id: string;
|
|
182
|
-
}>;
|
|
183
|
-
body: z.ZodObject<{
|
|
208
|
+
export declare const disableDevicesSchema: z.ZodObject<{
|
|
209
|
+
body: z.ZodEffects<z.ZodObject<{
|
|
184
210
|
reason: z.ZodString;
|
|
211
|
+
pairIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
212
|
+
serialNumbers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
185
213
|
}, "strip", z.ZodTypeAny, {
|
|
186
214
|
reason: string;
|
|
215
|
+
pairIds?: string[] | undefined;
|
|
216
|
+
serialNumbers?: string[] | undefined;
|
|
187
217
|
}, {
|
|
188
218
|
reason: string;
|
|
219
|
+
pairIds?: string[] | undefined;
|
|
220
|
+
serialNumbers?: string[] | undefined;
|
|
221
|
+
}>, {
|
|
222
|
+
reason: string;
|
|
223
|
+
pairIds?: string[] | undefined;
|
|
224
|
+
serialNumbers?: string[] | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
reason: string;
|
|
227
|
+
pairIds?: string[] | undefined;
|
|
228
|
+
serialNumbers?: string[] | undefined;
|
|
189
229
|
}>;
|
|
190
230
|
}, "strip", z.ZodTypeAny, {
|
|
191
|
-
params: {
|
|
192
|
-
id: string;
|
|
193
|
-
};
|
|
194
231
|
body: {
|
|
195
232
|
reason: string;
|
|
233
|
+
pairIds?: string[] | undefined;
|
|
234
|
+
serialNumbers?: string[] | undefined;
|
|
196
235
|
};
|
|
197
236
|
}, {
|
|
198
|
-
params: {
|
|
199
|
-
id: string;
|
|
200
|
-
};
|
|
201
237
|
body: {
|
|
202
238
|
reason: string;
|
|
239
|
+
pairIds?: string[] | undefined;
|
|
240
|
+
serialNumbers?: string[] | undefined;
|
|
203
241
|
};
|
|
204
242
|
}>;
|
|
205
|
-
export declare const
|
|
206
|
-
|
|
207
|
-
|
|
243
|
+
export declare const makeDevicesPermanentSchema: z.ZodObject<{
|
|
244
|
+
body: z.ZodEffects<z.ZodObject<{
|
|
245
|
+
pairIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
246
|
+
serialNumbers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
208
247
|
}, "strip", z.ZodTypeAny, {
|
|
209
|
-
|
|
248
|
+
pairIds?: string[] | undefined;
|
|
249
|
+
serialNumbers?: string[] | undefined;
|
|
210
250
|
}, {
|
|
211
|
-
|
|
251
|
+
pairIds?: string[] | undefined;
|
|
252
|
+
serialNumbers?: string[] | undefined;
|
|
253
|
+
}>, {
|
|
254
|
+
pairIds?: string[] | undefined;
|
|
255
|
+
serialNumbers?: string[] | undefined;
|
|
256
|
+
}, {
|
|
257
|
+
pairIds?: string[] | undefined;
|
|
258
|
+
serialNumbers?: string[] | undefined;
|
|
212
259
|
}>;
|
|
213
260
|
}, "strip", z.ZodTypeAny, {
|
|
214
|
-
|
|
215
|
-
|
|
261
|
+
body: {
|
|
262
|
+
pairIds?: string[] | undefined;
|
|
263
|
+
serialNumbers?: string[] | undefined;
|
|
216
264
|
};
|
|
217
265
|
}, {
|
|
218
|
-
|
|
219
|
-
|
|
266
|
+
body: {
|
|
267
|
+
pairIds?: string[] | undefined;
|
|
268
|
+
serialNumbers?: string[] | undefined;
|
|
220
269
|
};
|
|
221
270
|
}>;
|
|
222
271
|
export declare const checkAvailabilitySchema: z.ZodObject<{
|
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkAvailabilitySchema = exports.
|
|
3
|
+
exports.checkAvailabilitySchema = exports.makeDevicesPermanentSchema = 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");
|
|
7
|
-
// Constants
|
|
8
|
-
// Base device schema
|
|
9
|
-
const deviceBaseSchema = {
|
|
10
|
-
serialNumber: zod_1.z
|
|
11
|
-
.string()
|
|
12
|
-
.min(5, "Serial number must be at least 5 characters")
|
|
13
|
-
.max(64, "Serial number too long")
|
|
14
|
-
.regex(/^[A-Z0-9-]+$/, "Serial number must contain only uppercase letters, numbers, and hyphens"),
|
|
15
|
-
productId: zod_1.z.string().uuid("Invalid product ID"),
|
|
16
|
-
status: zod_1.z.enum(vr_models_1.DEVICE_STATUS).optional(),
|
|
17
|
-
isPermanentlyUnlocked: zod_1.z.boolean().optional(),
|
|
18
|
-
dedicatedUser: zod_1.z.enum(vr_models_1.DEVICE_DEDICATION).nullable().optional(),
|
|
19
|
-
};
|
|
20
7
|
// ✅ Pair ID format: 2 letters + 3 numbers + 1 letter
|
|
21
8
|
// Example: AA001A, AB123B, XZ999Z
|
|
22
9
|
// No letter 'O' to avoid confusion with 0
|
|
@@ -71,39 +58,82 @@ exports.getDevicesSchema = zod_1.z.object({
|
|
|
71
58
|
sortOrder: zod_1.z.enum(["ASC", "DESC"]).optional(),
|
|
72
59
|
}),
|
|
73
60
|
});
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
// src/validations/device.validations.ts
|
|
62
|
+
// ==================== DELETE SCHEMAS (PAIR ONLY) ====================
|
|
63
|
+
// Soft delete by pair IDs
|
|
64
|
+
exports.deleteDevicesByPairsSchema = zod_1.z.object({
|
|
65
|
+
body: zod_1.z.object({
|
|
66
|
+
pairIds: zod_1.z
|
|
67
|
+
.array(zod_1.z.string().regex(exports.PAIR_ID_REGEX, PAIR_ID_ERROR))
|
|
68
|
+
.min(1, "At least one pair ID required"),
|
|
78
69
|
}),
|
|
79
70
|
});
|
|
80
|
-
//
|
|
81
|
-
exports.
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
// Permanent delete by pair IDs (SUPER_ADMIN only)
|
|
72
|
+
exports.permanentDeleteDevicesByPairsSchema = zod_1.z.object({
|
|
73
|
+
body: zod_1.z.object({
|
|
74
|
+
pairIds: zod_1.z
|
|
75
|
+
.array(zod_1.z.string().regex(exports.PAIR_ID_REGEX, PAIR_ID_ERROR))
|
|
76
|
+
.min(1, "At least one pair ID required"),
|
|
84
77
|
}),
|
|
78
|
+
});
|
|
79
|
+
// ==================== STATUS MANAGEMENT SCHEMAS (FLEXIBLE) ====================
|
|
80
|
+
// Base schema for flexible identifier (pairIds OR serialNumbers)
|
|
81
|
+
const flexibleIdentifiersSchema = {
|
|
82
|
+
pairIds: zod_1.z.array(zod_1.z.string().regex(exports.PAIR_ID_REGEX, PAIR_ID_ERROR)).optional(),
|
|
83
|
+
serialNumbers: zod_1.z.array(zod_1.z.string()).optional(),
|
|
84
|
+
};
|
|
85
|
+
// Lock devices schema
|
|
86
|
+
exports.lockDevicesSchema = zod_1.z.object({
|
|
85
87
|
body: zod_1.z
|
|
86
88
|
.object({
|
|
87
|
-
|
|
89
|
+
...flexibleIdentifiersSchema,
|
|
90
|
+
reason: zod_1.z.string().optional(),
|
|
88
91
|
})
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
.refine((data) => {
|
|
93
|
+
const hasPairIds = data.pairIds && data.pairIds.length > 0;
|
|
94
|
+
const hasSerialNumbers = data.serialNumbers && data.serialNumbers.length > 0;
|
|
95
|
+
return ((hasPairIds || hasSerialNumbers) && !(hasPairIds && hasSerialNumbers));
|
|
96
|
+
}, {
|
|
97
|
+
message: "Either pairIds or serialNumbers must be provided, but not both",
|
|
98
|
+
path: ["pairIds"],
|
|
94
99
|
}),
|
|
95
100
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
// Unlock devices schema
|
|
102
|
+
exports.unlockDevicesSchema = zod_1.z.object({
|
|
103
|
+
body: zod_1.z.object(flexibleIdentifiersSchema).refine((data) => {
|
|
104
|
+
const hasPairIds = data.pairIds && data.pairIds.length > 0;
|
|
105
|
+
const hasSerialNumbers = data.serialNumbers && data.serialNumbers.length > 0;
|
|
106
|
+
return ((hasPairIds || hasSerialNumbers) && !(hasPairIds && hasSerialNumbers));
|
|
107
|
+
}, {
|
|
108
|
+
message: "Either pairIds or serialNumbers must be provided, but not both",
|
|
109
|
+
path: ["pairIds"],
|
|
99
110
|
}),
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
});
|
|
112
|
+
// Disable devices schema
|
|
113
|
+
exports.disableDevicesSchema = zod_1.z.object({
|
|
114
|
+
body: zod_1.z
|
|
115
|
+
.object({
|
|
116
|
+
...flexibleIdentifiersSchema,
|
|
117
|
+
reason: zod_1.z.string().min(1, "Reason is required"),
|
|
118
|
+
})
|
|
119
|
+
.refine((data) => {
|
|
120
|
+
const hasPairIds = data.pairIds && data.pairIds.length > 0;
|
|
121
|
+
const hasSerialNumbers = data.serialNumbers && data.serialNumbers.length > 0;
|
|
122
|
+
return ((hasPairIds || hasSerialNumbers) && !(hasPairIds && hasSerialNumbers));
|
|
123
|
+
}, {
|
|
124
|
+
message: "Either pairIds or serialNumbers must be provided, but not both",
|
|
125
|
+
path: ["pairIds"],
|
|
102
126
|
}),
|
|
103
127
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
128
|
+
// Make permanent schema
|
|
129
|
+
exports.makeDevicesPermanentSchema = zod_1.z.object({
|
|
130
|
+
body: zod_1.z.object(flexibleIdentifiersSchema).refine((data) => {
|
|
131
|
+
const hasPairIds = data.pairIds && data.pairIds.length > 0;
|
|
132
|
+
const hasSerialNumbers = data.serialNumbers && data.serialNumbers.length > 0;
|
|
133
|
+
return ((hasPairIds || hasSerialNumbers) && !(hasPairIds && hasSerialNumbers));
|
|
134
|
+
}, {
|
|
135
|
+
message: "Either pairIds or serialNumbers must be provided, but not both",
|
|
136
|
+
path: ["pairIds"],
|
|
107
137
|
}),
|
|
108
138
|
});
|
|
109
139
|
// Check availability schema (for assignment flow)
|
|
@@ -792,8 +792,8 @@ export declare const listAppSpecsSchema: z.ZodObject<{
|
|
|
792
792
|
sortBy?: "createdAt" | "updatedAt" | "version" | undefined;
|
|
793
793
|
sortOrder?: "DESC" | "ASC" | undefined;
|
|
794
794
|
}, {
|
|
795
|
-
search?: string | undefined;
|
|
796
795
|
limit?: string | undefined;
|
|
796
|
+
search?: string | undefined;
|
|
797
797
|
isActive?: "true" | "false" | undefined;
|
|
798
798
|
page?: string | undefined;
|
|
799
799
|
sortBy?: "createdAt" | "updatedAt" | "version" | undefined;
|
|
@@ -810,8 +810,8 @@ export declare const listAppSpecsSchema: z.ZodObject<{
|
|
|
810
810
|
};
|
|
811
811
|
}, {
|
|
812
812
|
query: {
|
|
813
|
-
search?: string | undefined;
|
|
814
813
|
limit?: string | undefined;
|
|
814
|
+
search?: string | undefined;
|
|
815
815
|
isActive?: "true" | "false" | undefined;
|
|
816
816
|
page?: string | undefined;
|
|
817
817
|
sortBy?: "createdAt" | "updatedAt" | "version" | undefined;
|