vr-commons 1.0.46 → 1.0.48
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/bans.utils.d.ts +36 -0
- package/dist/utils/bans.utils.js +55 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +10 -1
- package/dist/utils/moderation.utils.d.ts +25 -0
- package/dist/utils/moderation.utils.js +100 -0
- package/dist/utils/suspension.utils.d.ts +41 -0
- package/dist/utils/suspension.utils.js +79 -0
- package/dist/validations/appeals.validations.d.ts +61 -0
- package/dist/validations/appeals.validations.js +31 -0
- package/dist/validations/bans.validations.d.ts +83 -0
- package/dist/validations/bans.validations.js +33 -0
- package/dist/validations/dateRange.validations.d.ts +39 -0
- package/dist/validations/dateRange.validations.js +115 -0
- package/dist/validations/index.d.ts +4 -0
- package/dist/validations/index.js +21 -1
- package/dist/validations/moderation.validations.d.ts +404 -0
- package/dist/validations/moderation.validations.js +138 -0
- package/dist/validations/suspensions.validations.d.ts +88 -0
- package/dist/validations/suspensions.validations.js +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportBansSchema = exports.reviewAppealSchema = exports.listPendingAppealsSchema = exports.extendSuspensionSchema = exports.revokeSuspensionSchema = exports.revokeBanSchema = exports.listSuspensionsSchema = exports.listBansSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const dateRange_validations_1 = require("./dateRange.validations");
|
|
6
|
+
const uuidSchema = zod_1.z.string().uuid("Invalid UUID format");
|
|
7
|
+
// Base query schema with common pagination fields
|
|
8
|
+
const paginationSchema = zod_1.z.object({
|
|
9
|
+
page: zod_1.z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.transform((val) => (val ? parseInt(val) : 1))
|
|
13
|
+
.pipe(zod_1.z.number().min(1)),
|
|
14
|
+
limit: zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.transform((val) => (val ? parseInt(val) : 20))
|
|
18
|
+
.pipe(zod_1.z.number().min(1).max(100)),
|
|
19
|
+
});
|
|
20
|
+
exports.listBansSchema = zod_1.z.object({
|
|
21
|
+
query: paginationSchema
|
|
22
|
+
.extend({
|
|
23
|
+
userId: zod_1.z.string().uuid("Invalid user ID").optional(),
|
|
24
|
+
status: zod_1.z.enum(["active", "revoked"]).optional(),
|
|
25
|
+
appealStatus: zod_1.z.enum(["pending", "approved", "rejected"]).optional(),
|
|
26
|
+
isPermanent: zod_1.z.enum(["true", "false"]).optional(),
|
|
27
|
+
fromDate: dateRange_validations_1.dateValidator.optional(),
|
|
28
|
+
toDate: dateRange_validations_1.dateValidator.optional(),
|
|
29
|
+
search: zod_1.z.string().optional(),
|
|
30
|
+
sortBy: zod_1.z.enum(["bannedAt", "createdAt", "reason"]).optional(),
|
|
31
|
+
sortOrder: zod_1.z.enum(["ASC", "DESC"]).optional(),
|
|
32
|
+
})
|
|
33
|
+
.transform((data) => {
|
|
34
|
+
// Normalize dates for DB queries
|
|
35
|
+
if (data.fromDate) {
|
|
36
|
+
data.fromDate = (0, dateRange_validations_1.normalizeDate)(data.fromDate);
|
|
37
|
+
}
|
|
38
|
+
if (data.toDate) {
|
|
39
|
+
data.toDate = (0, dateRange_validations_1.normalizeDate)(data.toDate);
|
|
40
|
+
}
|
|
41
|
+
return data;
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
exports.listSuspensionsSchema = zod_1.z.object({
|
|
45
|
+
query: paginationSchema
|
|
46
|
+
.extend({
|
|
47
|
+
userId: zod_1.z.string().uuid("Invalid user ID").optional(),
|
|
48
|
+
status: zod_1.z.enum(["active", "expired", "revoked"]).optional(),
|
|
49
|
+
appealStatus: zod_1.z.enum(["pending", "approved", "rejected"]).optional(),
|
|
50
|
+
fromDate: dateRange_validations_1.dateValidator.optional(),
|
|
51
|
+
toDate: dateRange_validations_1.dateValidator.optional(),
|
|
52
|
+
search: zod_1.z.string().optional(),
|
|
53
|
+
sortBy: zod_1.z.enum(["startedAt", "endsAt", "createdAt", "reason"]).optional(),
|
|
54
|
+
sortOrder: zod_1.z.enum(["ASC", "DESC"]).optional(),
|
|
55
|
+
})
|
|
56
|
+
.transform((data) => {
|
|
57
|
+
// Normalize dates for DB queries
|
|
58
|
+
if (data.fromDate) {
|
|
59
|
+
data.fromDate = (0, dateRange_validations_1.normalizeDate)(data.fromDate);
|
|
60
|
+
}
|
|
61
|
+
if (data.toDate) {
|
|
62
|
+
data.toDate = (0, dateRange_validations_1.normalizeDate)(data.toDate);
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
exports.revokeBanSchema = zod_1.z.object({
|
|
68
|
+
params: zod_1.z.object({ banId: uuidSchema }),
|
|
69
|
+
body: zod_1.z.object({ revocationReason: zod_1.z.string().max(500).optional() }).strict(),
|
|
70
|
+
});
|
|
71
|
+
exports.revokeSuspensionSchema = zod_1.z.object({
|
|
72
|
+
params: zod_1.z.object({ suspensionId: uuidSchema }),
|
|
73
|
+
body: zod_1.z.object({ revocationReason: zod_1.z.string().max(500).optional() }).strict(),
|
|
74
|
+
});
|
|
75
|
+
exports.extendSuspensionSchema = zod_1.z.object({
|
|
76
|
+
params: zod_1.z.object({ suspensionId: uuidSchema }),
|
|
77
|
+
body: zod_1.z
|
|
78
|
+
.object({
|
|
79
|
+
newEndDate: dateRange_validations_1.dateValidator.refine((date) => {
|
|
80
|
+
const normalizedDate = (0, dateRange_validations_1.normalizeDate)(date);
|
|
81
|
+
return new Date(normalizedDate) > new Date();
|
|
82
|
+
}, { message: "New end date must be in the future" }),
|
|
83
|
+
extensionReason: zod_1.z.string().max(500).optional(),
|
|
84
|
+
})
|
|
85
|
+
.strict()
|
|
86
|
+
.transform((data) => ({
|
|
87
|
+
...data,
|
|
88
|
+
newEndDate: (0, dateRange_validations_1.normalizeDate)(data.newEndDate), // Normalize for DB
|
|
89
|
+
})),
|
|
90
|
+
});
|
|
91
|
+
exports.listPendingAppealsSchema = zod_1.z.object({
|
|
92
|
+
query: paginationSchema
|
|
93
|
+
.extend({
|
|
94
|
+
type: zod_1.z.enum(["ban", "suspension"]).optional(),
|
|
95
|
+
fromDate: dateRange_validations_1.dateValidator.optional(),
|
|
96
|
+
toDate: dateRange_validations_1.dateValidator.optional(),
|
|
97
|
+
})
|
|
98
|
+
.transform((data) => {
|
|
99
|
+
// Normalize dates for DB queries
|
|
100
|
+
if (data.fromDate) {
|
|
101
|
+
data.fromDate = (0, dateRange_validations_1.normalizeDate)(data.fromDate);
|
|
102
|
+
}
|
|
103
|
+
if (data.toDate) {
|
|
104
|
+
data.toDate = (0, dateRange_validations_1.normalizeDate)(data.toDate);
|
|
105
|
+
}
|
|
106
|
+
return data;
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
exports.reviewAppealSchema = zod_1.z.object({
|
|
110
|
+
params: zod_1.z.object({
|
|
111
|
+
banId: uuidSchema.optional(),
|
|
112
|
+
suspensionId: uuidSchema.optional(),
|
|
113
|
+
}),
|
|
114
|
+
body: zod_1.z
|
|
115
|
+
.object({
|
|
116
|
+
appealStatus: zod_1.z.enum(["approved", "rejected"]),
|
|
117
|
+
adminNotes: zod_1.z.string().max(1000).optional(),
|
|
118
|
+
})
|
|
119
|
+
.strict(),
|
|
120
|
+
});
|
|
121
|
+
exports.exportBansSchema = zod_1.z.object({
|
|
122
|
+
query: zod_1.z
|
|
123
|
+
.object({
|
|
124
|
+
fromDate: dateRange_validations_1.dateValidator.optional(),
|
|
125
|
+
toDate: dateRange_validations_1.dateValidator.optional(),
|
|
126
|
+
format: zod_1.z.enum(["csv"]).default("csv"),
|
|
127
|
+
})
|
|
128
|
+
.transform((data) => {
|
|
129
|
+
// Normalize dates for DB queries
|
|
130
|
+
if (data.fromDate) {
|
|
131
|
+
data.fromDate = (0, dateRange_validations_1.normalizeDate)(data.fromDate);
|
|
132
|
+
}
|
|
133
|
+
if (data.toDate) {
|
|
134
|
+
data.toDate = (0, dateRange_validations_1.normalizeDate)(data.toDate);
|
|
135
|
+
}
|
|
136
|
+
return data;
|
|
137
|
+
}),
|
|
138
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const getSuspensionSchema: z.ZodObject<{
|
|
3
|
+
params: z.ZodObject<{
|
|
4
|
+
suspensionId: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
suspensionId: string;
|
|
7
|
+
}, {
|
|
8
|
+
suspensionId: string;
|
|
9
|
+
}>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
params: {
|
|
12
|
+
suspensionId: string;
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
params: {
|
|
16
|
+
suspensionId: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export declare const getUserSuspensionsSchema: z.ZodObject<{
|
|
20
|
+
params: z.ZodObject<{
|
|
21
|
+
userId: z.ZodString;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
userId: string;
|
|
24
|
+
}, {
|
|
25
|
+
userId: string;
|
|
26
|
+
}>;
|
|
27
|
+
query: z.ZodObject<{
|
|
28
|
+
includeResolved: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
29
|
+
status: z.ZodOptional<z.ZodEnum<["active", "expired", "revoked"]>>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
status?: "active" | "revoked" | "expired" | undefined;
|
|
32
|
+
includeResolved?: "true" | "false" | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
status?: "active" | "revoked" | "expired" | undefined;
|
|
35
|
+
includeResolved?: "true" | "false" | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
params: {
|
|
39
|
+
userId: string;
|
|
40
|
+
};
|
|
41
|
+
query: {
|
|
42
|
+
status?: "active" | "revoked" | "expired" | undefined;
|
|
43
|
+
includeResolved?: "true" | "false" | undefined;
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
params: {
|
|
47
|
+
userId: string;
|
|
48
|
+
};
|
|
49
|
+
query: {
|
|
50
|
+
status?: "active" | "revoked" | "expired" | undefined;
|
|
51
|
+
includeResolved?: "true" | "false" | undefined;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
export declare const createSuspensionSchema: z.ZodObject<{
|
|
55
|
+
params: z.ZodObject<{
|
|
56
|
+
userId: z.ZodString;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
userId: string;
|
|
59
|
+
}, {
|
|
60
|
+
userId: string;
|
|
61
|
+
}>;
|
|
62
|
+
body: z.ZodObject<{
|
|
63
|
+
reason: z.ZodString;
|
|
64
|
+
endsAt: z.ZodEffects<z.ZodString, string, string>;
|
|
65
|
+
}, "strict", z.ZodTypeAny, {
|
|
66
|
+
reason: string;
|
|
67
|
+
endsAt: string;
|
|
68
|
+
}, {
|
|
69
|
+
reason: string;
|
|
70
|
+
endsAt: string;
|
|
71
|
+
}>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
params: {
|
|
74
|
+
userId: string;
|
|
75
|
+
};
|
|
76
|
+
body: {
|
|
77
|
+
reason: string;
|
|
78
|
+
endsAt: string;
|
|
79
|
+
};
|
|
80
|
+
}, {
|
|
81
|
+
params: {
|
|
82
|
+
userId: string;
|
|
83
|
+
};
|
|
84
|
+
body: {
|
|
85
|
+
reason: string;
|
|
86
|
+
endsAt: string;
|
|
87
|
+
};
|
|
88
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSuspensionSchema = exports.getUserSuspensionsSchema = exports.getSuspensionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// Base schemas
|
|
6
|
+
const uuidSchema = zod_1.z.string().uuid("Invalid UUID format");
|
|
7
|
+
exports.getSuspensionSchema = zod_1.z.object({
|
|
8
|
+
params: zod_1.z.object({
|
|
9
|
+
suspensionId: uuidSchema,
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
exports.getUserSuspensionsSchema = zod_1.z.object({
|
|
13
|
+
params: zod_1.z.object({
|
|
14
|
+
userId: uuidSchema,
|
|
15
|
+
}),
|
|
16
|
+
query: zod_1.z.object({
|
|
17
|
+
includeResolved: zod_1.z.enum(["true", "false"]).optional(),
|
|
18
|
+
status: zod_1.z.enum(["active", "expired", "revoked"]).optional(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
exports.createSuspensionSchema = zod_1.z.object({
|
|
22
|
+
params: zod_1.z.object({
|
|
23
|
+
userId: uuidSchema,
|
|
24
|
+
}),
|
|
25
|
+
body: zod_1.z
|
|
26
|
+
.object({
|
|
27
|
+
reason: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.min(5, "Reason must be at least 5 characters")
|
|
30
|
+
.max(1000, "Reason cannot exceed 1000 characters"),
|
|
31
|
+
endsAt: zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.datetime("Invalid date format")
|
|
34
|
+
.refine((date) => new Date(date) > new Date(), {
|
|
35
|
+
message: "End date must be in the future",
|
|
36
|
+
}),
|
|
37
|
+
})
|
|
38
|
+
.strict(),
|
|
39
|
+
});
|