vr-commons 1.0.103 → 1.0.104
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.
|
@@ -2,33 +2,28 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const createProductSchema: z.ZodObject<{
|
|
3
3
|
body: z.ZodObject<{
|
|
4
4
|
name: z.ZodString;
|
|
5
|
-
stock: z.ZodDefault<z.ZodOptional<z.ZodNumber
|
|
5
|
+
stock: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodNumber>>, number, unknown>;
|
|
6
6
|
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
8
7
|
}, "strip", z.ZodTypeAny, {
|
|
9
8
|
name: string;
|
|
10
9
|
stock: number;
|
|
11
|
-
isActive?: boolean | undefined;
|
|
12
10
|
description?: string | null | undefined;
|
|
13
11
|
}, {
|
|
14
12
|
name: string;
|
|
15
|
-
|
|
13
|
+
stock?: unknown;
|
|
16
14
|
description?: string | null | undefined;
|
|
17
|
-
stock?: number | undefined;
|
|
18
15
|
}>;
|
|
19
16
|
}, "strip", z.ZodTypeAny, {
|
|
20
17
|
body: {
|
|
21
18
|
name: string;
|
|
22
19
|
stock: number;
|
|
23
|
-
isActive?: boolean | undefined;
|
|
24
20
|
description?: string | null | undefined;
|
|
25
21
|
};
|
|
26
22
|
}, {
|
|
27
23
|
body: {
|
|
28
24
|
name: string;
|
|
29
|
-
|
|
25
|
+
stock?: unknown;
|
|
30
26
|
description?: string | null | undefined;
|
|
31
|
-
stock?: number | undefined;
|
|
32
27
|
};
|
|
33
28
|
}>;
|
|
34
29
|
export declare const updateProductSchema: z.ZodObject<{
|
|
@@ -40,41 +35,41 @@ export declare const updateProductSchema: z.ZodObject<{
|
|
|
40
35
|
id: string;
|
|
41
36
|
}>;
|
|
42
37
|
body: z.ZodObject<{
|
|
43
|
-
name: z.ZodOptional<z.ZodString>;
|
|
44
|
-
description: z.ZodNullable<z.ZodOptional<z.ZodString
|
|
45
|
-
stock: z.ZodOptional<z.ZodNumber>;
|
|
46
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
name: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, unknown>;
|
|
39
|
+
description: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string | null | undefined, unknown>;
|
|
40
|
+
stock: z.ZodEffects<z.ZodOptional<z.ZodNumber>, number | undefined, unknown>;
|
|
41
|
+
isActive: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
|
|
47
42
|
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
isActive?: boolean | undefined;
|
|
49
|
-
description?: string | null | undefined;
|
|
50
43
|
name?: string | undefined;
|
|
51
44
|
stock?: number | undefined;
|
|
52
|
-
}, {
|
|
53
|
-
isActive?: boolean | undefined;
|
|
54
45
|
description?: string | null | undefined;
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
isActive?: boolean | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
name?: unknown;
|
|
49
|
+
stock?: unknown;
|
|
50
|
+
description?: unknown;
|
|
51
|
+
isActive?: unknown;
|
|
57
52
|
}>;
|
|
58
53
|
}, "strip", z.ZodTypeAny, {
|
|
59
|
-
body: {
|
|
60
|
-
isActive?: boolean | undefined;
|
|
61
|
-
description?: string | null | undefined;
|
|
62
|
-
name?: string | undefined;
|
|
63
|
-
stock?: number | undefined;
|
|
64
|
-
};
|
|
65
54
|
params: {
|
|
66
55
|
id: string;
|
|
67
56
|
};
|
|
68
|
-
}, {
|
|
69
57
|
body: {
|
|
70
|
-
isActive?: boolean | undefined;
|
|
71
|
-
description?: string | null | undefined;
|
|
72
58
|
name?: string | undefined;
|
|
73
59
|
stock?: number | undefined;
|
|
60
|
+
description?: string | null | undefined;
|
|
61
|
+
isActive?: boolean | undefined;
|
|
74
62
|
};
|
|
63
|
+
}, {
|
|
75
64
|
params: {
|
|
76
65
|
id: string;
|
|
77
66
|
};
|
|
67
|
+
body: {
|
|
68
|
+
name?: unknown;
|
|
69
|
+
stock?: unknown;
|
|
70
|
+
description?: unknown;
|
|
71
|
+
isActive?: unknown;
|
|
72
|
+
};
|
|
78
73
|
}>;
|
|
79
74
|
export declare const getProductSchema: z.ZodObject<{
|
|
80
75
|
params: z.ZodObject<{
|
|
@@ -103,41 +98,41 @@ export declare const getProductsSchema: z.ZodObject<{
|
|
|
103
98
|
sortBy: z.ZodOptional<z.ZodEnum<["name", "stock", "createdAt", "updatedAt"]>>;
|
|
104
99
|
sortOrder: z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>;
|
|
105
100
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
search?: string | undefined;
|
|
107
|
-
limit?: number | undefined;
|
|
108
101
|
isActive?: "true" | "false" | undefined;
|
|
109
102
|
page?: number | undefined;
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
limit?: number | undefined;
|
|
104
|
+
search?: string | undefined;
|
|
112
105
|
minStock?: number | undefined;
|
|
106
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
107
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
113
108
|
}, {
|
|
114
|
-
search?: string | undefined;
|
|
115
|
-
limit?: string | undefined;
|
|
116
109
|
isActive?: "true" | "false" | undefined;
|
|
117
110
|
page?: string | undefined;
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
limit?: string | undefined;
|
|
112
|
+
search?: string | undefined;
|
|
120
113
|
minStock?: string | undefined;
|
|
114
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
115
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
121
116
|
}>;
|
|
122
117
|
}, "strip", z.ZodTypeAny, {
|
|
123
118
|
query: {
|
|
124
|
-
search?: string | undefined;
|
|
125
|
-
limit?: number | undefined;
|
|
126
119
|
isActive?: "true" | "false" | undefined;
|
|
127
120
|
page?: number | undefined;
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
limit?: number | undefined;
|
|
122
|
+
search?: string | undefined;
|
|
130
123
|
minStock?: number | undefined;
|
|
124
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
125
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
131
126
|
};
|
|
132
127
|
}, {
|
|
133
128
|
query: {
|
|
134
|
-
search?: string | undefined;
|
|
135
|
-
limit?: string | undefined;
|
|
136
129
|
isActive?: "true" | "false" | undefined;
|
|
137
130
|
page?: string | undefined;
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
limit?: string | undefined;
|
|
132
|
+
search?: string | undefined;
|
|
140
133
|
minStock?: string | undefined;
|
|
134
|
+
sortBy?: "name" | "stock" | "createdAt" | "updatedAt" | undefined;
|
|
135
|
+
sortOrder?: "ASC" | "DESC" | undefined;
|
|
141
136
|
};
|
|
142
137
|
}>;
|
|
143
138
|
export declare const deleteProductSchema: z.ZodObject<{
|
|
@@ -203,26 +198,26 @@ export declare const updateStockSchema: z.ZodObject<{
|
|
|
203
198
|
operation: z.ZodEnum<["increment", "decrement", "set"]>;
|
|
204
199
|
amount: z.ZodNumber;
|
|
205
200
|
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
operation: "set" | "increment" | "decrement";
|
|
206
202
|
amount: number;
|
|
207
|
-
operation: "increment" | "decrement" | "set";
|
|
208
203
|
}, {
|
|
204
|
+
operation: "set" | "increment" | "decrement";
|
|
209
205
|
amount: number;
|
|
210
|
-
operation: "increment" | "decrement" | "set";
|
|
211
206
|
}>;
|
|
212
207
|
}, "strip", z.ZodTypeAny, {
|
|
213
|
-
body: {
|
|
214
|
-
amount: number;
|
|
215
|
-
operation: "increment" | "decrement" | "set";
|
|
216
|
-
};
|
|
217
208
|
params: {
|
|
218
209
|
id: string;
|
|
219
210
|
};
|
|
220
|
-
}, {
|
|
221
211
|
body: {
|
|
212
|
+
operation: "set" | "increment" | "decrement";
|
|
222
213
|
amount: number;
|
|
223
|
-
operation: "increment" | "decrement" | "set";
|
|
224
214
|
};
|
|
215
|
+
}, {
|
|
225
216
|
params: {
|
|
226
217
|
id: string;
|
|
227
218
|
};
|
|
219
|
+
body: {
|
|
220
|
+
operation: "set" | "increment" | "decrement";
|
|
221
|
+
amount: number;
|
|
222
|
+
};
|
|
228
223
|
}>;
|
|
@@ -12,24 +12,25 @@ const productBaseSchema = {
|
|
|
12
12
|
stock: zod_1.z.number().int().min(0, "Stock cannot be negative").optional(),
|
|
13
13
|
isActive: zod_1.z.boolean().optional(),
|
|
14
14
|
};
|
|
15
|
-
//
|
|
15
|
+
// Update product schema to handle FormData strings
|
|
16
16
|
exports.createProductSchema = zod_1.z.object({
|
|
17
17
|
body: zod_1.z.object({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
name: productBaseSchema.name,
|
|
19
|
+
stock: zod_1.z.preprocess((val) => (val ? Number(val) : 1), productBaseSchema.stock.default(1)),
|
|
20
|
+
description: productBaseSchema.description,
|
|
21
|
+
// image is handled by multer, not in validation
|
|
21
22
|
}),
|
|
22
23
|
});
|
|
23
|
-
// Update product schema
|
|
24
|
+
// Update product schema to handle FormData strings
|
|
24
25
|
exports.updateProductSchema = zod_1.z.object({
|
|
25
26
|
params: zod_1.z.object({
|
|
26
27
|
id: zod_1.z.string().uuid("Invalid product ID"),
|
|
27
28
|
}),
|
|
28
29
|
body: zod_1.z.object({
|
|
29
|
-
name: productBaseSchema.name.optional(),
|
|
30
|
-
description: productBaseSchema.description,
|
|
31
|
-
stock: productBaseSchema.stock,
|
|
32
|
-
isActive: productBaseSchema.isActive,
|
|
30
|
+
name: zod_1.z.preprocess((val) => (val === "" ? undefined : val), productBaseSchema.name.optional()),
|
|
31
|
+
description: zod_1.z.preprocess((val) => (val === "" ? null : val), productBaseSchema.description),
|
|
32
|
+
stock: zod_1.z.preprocess((val) => (val ? Number(val) : undefined), productBaseSchema.stock),
|
|
33
|
+
isActive: zod_1.z.preprocess((val) => (val === "true" ? true : val === "false" ? false : undefined), productBaseSchema.isActive),
|
|
33
34
|
}),
|
|
34
35
|
});
|
|
35
36
|
// Get product by ID schema
|