Skip to content

Commit aea5370

Browse files
committed
chore: bump backend-contract version to 2.1.58 in package.json and update validation for name fields
- Updated version in package.json to 2.1.58. - Increased maximum length for name fields from 20 to 30 characters across multiple command schemas. - Enhanced regex validation to allow spaces in name fields for better user input flexibility. - Added port validation to ensure it is less than 65535 in node creation and update schemas. - Implemented UUID filtering in UsersRepository for improved query capabilities.
1 parent 39e2ddc commit aea5370

File tree

8 files changed

+45
-17
lines changed

8 files changed

+45
-17
lines changed

libs/contract/commands/config-profiles/create-config-profile.command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export namespace CreateConfigProfileCommand {
1818
name: z
1919
.string()
2020
.min(2, 'Name must be at least 2 characters')
21-
.max(20, 'Name must be less than 20 characters')
21+
.max(30, 'Name must be less than 30 characters')
2222
.regex(
23-
/^[A-Za-z0-9_-]+$/,
24-
'Name can only contain letters, numbers, underscores and dashes',
23+
/^[A-Za-z0-9_\s-]+$/,
24+
'Name can only contain letters, numbers, underscores, dashes and spaces',
2525
),
2626
config: z.object({}).passthrough(),
2727
});

libs/contract/commands/config-profiles/update-config-profile.command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export namespace UpdateConfigProfileCommand {
1919
name: z
2020
.string()
2121
.min(2, 'Name must be at least 2 characters')
22-
.max(20, 'Name must be less than 20 characters')
22+
.max(30, 'Name must be less than 30 characters')
2323
.regex(
24-
/^[A-Za-z0-9_-]+$/,
25-
'Name can only contain letters, numbers, underscores and dashes',
24+
/^[A-Za-z0-9_\s-]+$/,
25+
'Name can only contain letters, numbers, underscores, dashes and spaces',
2626
)
2727
.optional(),
2828
config: z.object({}).passthrough().optional(),

libs/contract/commands/internal-squads/create-internal-squad.command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export namespace CreateInternalSquadCommand {
1818
name: z
1919
.string()
2020
.min(2, 'Name must be at least 2 characters')
21-
.max(20, 'Name must be less than 20 characters')
21+
.max(30, 'Name must be less than 30 characters')
2222
.regex(
23-
/^[A-Za-z0-9_-]+$/,
24-
'Name can only contain letters, numbers, underscores and dashes',
23+
/^[A-Za-z0-9_\s-]+$/,
24+
'Name can only contain letters, numbers, underscores, dashes and spaces',
2525
),
2626
inbounds: z.array(z.string().uuid()),
2727
});

libs/contract/commands/internal-squads/update-internal-squad.command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export namespace UpdateInternalSquadCommand {
1919
name: z
2020
.string()
2121
.min(2, 'Name must be at least 2 characters')
22-
.max(20, 'Name must be less than 20 characters')
22+
.max(30, 'Name must be less than 30 characters')
2323
.regex(
24-
/^[A-Za-z0-9_-]+$/,
25-
'Name can only contain letters, numbers, underscores and dashes',
24+
/^[A-Za-z0-9_\s-]+$/,
25+
'Name can only contain letters, numbers, underscores, dashes and spaces',
2626
)
2727
.optional(),
2828
inbounds: z.array(z.string().uuid()).optional(),

libs/contract/commands/nodes/create.command.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ export namespace CreateNodeCommand {
1414
);
1515

1616
export const RequestSchema = z.object({
17-
name: z.string().min(3, 'Minimum 3 characters!'),
17+
name: z.string().min(3, 'Minimum 3 characters!').max(30, 'Maximum 30 characters!'),
1818
address: z.string().min(2, 'Minimum 2 characters!'),
19-
port: z.number().int().min(1, 'Port is required').optional(),
19+
port: z
20+
.number()
21+
.int()
22+
.min(1, 'Port is required')
23+
.max(65535, 'Port must be less than 65535')
24+
.optional(),
2025
isTrafficTrackingActive: z.boolean().optional().default(false),
2126
trafficLimitBytes: z.optional(
2227
z.number().int().min(0, 'Traffic limit must be greater than 0'),

libs/contract/commands/nodes/update.command.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ export namespace UpdateNodeCommand {
1313
export const RequestSchema = NodesSchema.pick({
1414
uuid: true,
1515
}).extend({
16-
name: z.optional(z.string().min(3, 'Min. 3 characters')),
16+
name: z.optional(z.string().min(3, 'Min. 3 characters').max(30, 'Max. 30 characters')),
1717
address: z.optional(z.string().min(2, 'Min. 2 characters')),
18-
port: z.optional(z.number()),
18+
port: z.optional(
19+
z
20+
.number()
21+
.min(1, 'Port must be greater than 0')
22+
.max(65535, 'Port must be less than 65535'),
23+
),
1924
isTrafficTrackingActive: z.optional(z.boolean()),
2025
trafficLimitBytes: z.optional(z.number().min(0, 'Traffic limit must be greater than 0')),
2126
notifyPercent: z.optional(

libs/contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remnawave/backend-contract",
3-
"version": "2.1.57",
3+
"version": "2.1.58",
44
"public": true,
55
"license": "AGPL-3.0-only",
66
"description": "A contract library for Remnawave Backend. It can be used in backend and frontend.",

src/modules/users/repositories/users.repository.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ export class UsersRepository implements ICrud<BaseUserEntity> {
276276
continue;
277277
}
278278

279+
if (filter.id === 'uuid') {
280+
whereBuilder = whereBuilder.where(
281+
sql`"uuid"::text`,
282+
'ilike',
283+
`%${filter.value}%`,
284+
);
285+
continue;
286+
}
287+
279288
const field = filter.id as keyof DB['users'];
280289

281290
switch (mode) {
@@ -379,6 +388,15 @@ export class UsersRepository implements ICrud<BaseUserEntity> {
379388
continue;
380389
}
381390

391+
if (filter.id === 'uuid') {
392+
countBuilder = countBuilder.where(
393+
sql`"uuid"::text`,
394+
'ilike',
395+
`%${filter.value}%`,
396+
);
397+
continue;
398+
}
399+
382400
const field = filter.id as keyof DB['users'];
383401

384402
switch (mode) {

0 commit comments

Comments
 (0)