@remnawave/backend-contract 0.0.49 → 0.0.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,8 +10,7 @@ var UpdateNodeCommand;
10
10
  UpdateNodeCommand.TSQ_url = UpdateNodeCommand.url;
11
11
  UpdateNodeCommand.RequestSchema = models_1.NodesSchema.pick({
12
12
  uuid: true,
13
- })
14
- .extend({
13
+ }).extend({
15
14
  name: zod_1.z.optional(zod_1.z.string().min(5, 'Min. 5 characters')),
16
15
  address: zod_1.z.optional(zod_1.z.string().min(2, 'Min. 2 characters')),
17
16
  port: zod_1.z.optional(zod_1.z.number()),
@@ -25,17 +24,6 @@ var UpdateNodeCommand;
25
24
  .number()
26
25
  .min(1, 'Traffic reset day must be greater than 0')
27
26
  .max(31, 'Traffic reset day must be less than 31')),
28
- })
29
- .refine((data) => {
30
- if (data.isTrafficTrackingActive) {
31
- return (data.trafficLimitBytes != null &&
32
- data.notifyPercent != null &&
33
- data.trafficResetDay != null);
34
- }
35
- return true;
36
- }, {
37
- message: 'Traffic tracking fields are required when isTrafficTrackingActive is true',
38
- path: ['trafficLimitBytes', 'notifyPercent', 'trafficResetDay'],
39
27
  });
40
28
  UpdateNodeCommand.ResponseSchema = zod_1.z.object({
41
29
  response: models_1.NodesSchema,
@@ -21,10 +21,12 @@ var GetAllUsersV2Command;
21
21
  start: zod_1.z.coerce.number().optional(),
22
22
  size: zod_1.z.coerce.number().optional(),
23
23
  filters: zod_1.z
24
- .preprocess((str) => (typeof str === 'string' ? JSON.parse(str) : str), zod_1.z.array(FilterSchema))
24
+ .union([zod_1.z.string(), zod_1.z.array(FilterSchema)])
25
+ .transform((val) => (typeof val === 'string' ? JSON.parse(val) : val))
25
26
  .optional(),
26
27
  filterModes: zod_1.z
27
- .preprocess((str) => (typeof str === 'string' ? JSON.parse(str) : str), zod_1.z.record(zod_1.z.string(), zod_1.z.string()))
28
+ .union([zod_1.z.string(), zod_1.z.record(zod_1.z.string(), zod_1.z.string())])
29
+ .transform((val) => (typeof val === 'string' ? JSON.parse(val) : val))
28
30
  .optional(),
29
31
  globalFilterMode: zod_1.z.string().optional(),
30
32
  sorting: zod_1.z
@@ -8,45 +8,25 @@ export namespace UpdateNodeCommand {
8
8
 
9
9
  export const RequestSchema = NodesSchema.pick({
10
10
  uuid: true,
11
- })
12
- .extend({
13
- name: z.optional(z.string().min(5, 'Min. 5 characters')),
14
- address: z.optional(z.string().min(2, 'Min. 2 characters')),
15
- port: z.optional(z.number()),
16
- isTrafficTrackingActive: z.optional(z.boolean()),
17
- trafficLimitBytes: z.optional(
18
- z.number().min(0, 'Traffic limit must be greater than 0'),
19
- ),
20
- notifyPercent: z.optional(
21
- z
22
- .number()
23
- .min(0, 'Notify percent must be greater than 0')
24
- .max(100, 'Notify percent must be less than 100'),
25
- ),
26
- trafficResetDay: z.optional(
27
- z
28
- .number()
29
- .min(1, 'Traffic reset day must be greater than 0')
30
- .max(31, 'Traffic reset day must be less than 31'),
31
- ),
32
- })
33
- .refine(
34
- (data) => {
35
- if (data.isTrafficTrackingActive) {
36
- return (
37
- data.trafficLimitBytes != null &&
38
- data.notifyPercent != null &&
39
- data.trafficResetDay != null
40
- );
41
- }
42
- return true;
43
- },
44
- {
45
- message:
46
- 'Traffic tracking fields are required when isTrafficTrackingActive is true',
47
- path: ['trafficLimitBytes', 'notifyPercent', 'trafficResetDay'],
48
- },
49
- );
11
+ }).extend({
12
+ name: z.optional(z.string().min(5, 'Min. 5 characters')),
13
+ address: z.optional(z.string().min(2, 'Min. 2 characters')),
14
+ port: z.optional(z.number()),
15
+ isTrafficTrackingActive: z.optional(z.boolean()),
16
+ trafficLimitBytes: z.optional(z.number().min(0, 'Traffic limit must be greater than 0')),
17
+ notifyPercent: z.optional(
18
+ z
19
+ .number()
20
+ .min(0, 'Notify percent must be greater than 0')
21
+ .max(100, 'Notify percent must be less than 100'),
22
+ ),
23
+ trafficResetDay: z.optional(
24
+ z
25
+ .number()
26
+ .min(1, 'Traffic reset day must be greater than 0')
27
+ .max(31, 'Traffic reset day must be less than 31'),
28
+ ),
29
+ });
50
30
 
51
31
  export type Request = z.infer<typeof RequestSchema>;
52
32
 
@@ -21,17 +21,13 @@ export namespace GetAllUsersV2Command {
21
21
  start: z.coerce.number().optional(),
22
22
  size: z.coerce.number().optional(),
23
23
  filters: z
24
- .preprocess(
25
- (str) => (typeof str === 'string' ? JSON.parse(str) : str),
26
- z.array(FilterSchema),
27
- )
24
+ .union([z.string(), z.array(FilterSchema)])
25
+ .transform((val) => (typeof val === 'string' ? JSON.parse(val) : val))
28
26
  .optional(),
29
27
 
30
28
  filterModes: z
31
- .preprocess(
32
- (str) => (typeof str === 'string' ? JSON.parse(str) : str),
33
- z.record(z.string(), z.string()),
34
- )
29
+ .union([z.string(), z.record(z.string(), z.string())])
30
+ .transform((val) => (typeof val === 'string' ? JSON.parse(val) : val))
35
31
  .optional(),
36
32
  globalFilterMode: z.string().optional(),
37
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnawave/backend-contract",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "A contract library for Remnawave",
5
5
  "main": "index.js",
6
6
  "scripts": {