Skip to content

Commit 3187303

Browse files
committed
chore: update prisma version and enhance schema validations
- Changed prisma version in package.json and package-lock.json to a fixed version. - Improved validation for hwidDeviceLimit in CreateUserCommand and UpdateUserCommand to enforce non-negative integers. - Updated userUuid in HwidUserDeviceSchema to require a valid UUID format. - Enhanced customResponseHeaders validation in SubscriptionSettingsSchema to ensure valid header names. - Refactored HwidUserDeviceEntity to use public access modifiers for properties. - Simplified hwid existence check in HwidUserDevicesRepository by using count method. - Removed unused createHwidUserDevice method from SubscriptionService and replaced it with upsert logic.
1 parent f5269bc commit 3187303

File tree

12 files changed

+48
-37
lines changed

12 files changed

+48
-37
lines changed

.github/workflows/release-to-panel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
8686
### 📋 Changes
8787
- [View full changelog](https://github.com/remnawave/frontend/releases/tag/${{ steps.frontend-tag.outputs.release }})
88-
- [Compare changes (${steps.frontend-prev-tag.outputs.tag}...${{ steps.frontend-tag.outputs.release }})](https://github.com/remnawave/frontend/compare/${{steps.frontend-prev-tag.outputs.tag}}...${{ steps.frontend-tag.outputs.release }})
88+
- [Compare changes (${{ steps.frontend-prev-tag.outputs.tag }}...${{ steps.frontend-tag.outputs.release }})](https://github.com/remnawave/frontend/compare/${{steps.frontend-prev-tag.outputs.tag}}...${{ steps.frontend-tag.outputs.release }})
8989
9090
---
9191

libs/contract/commands/users/create-user.command.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ export namespace CreateUserCommand {
109109
telegramId: z.optional(z.number().int()),
110110
email: z.string().email('Invalid email format').optional(),
111111

112-
hwidDeviceLimit: z.optional(z.number().int()),
112+
hwidDeviceLimit: z.optional(
113+
z
114+
.number({ invalid_type_error: 'Device limit must be a number' })
115+
.int('Device limit must be an integer')
116+
.min(0, 'Device limit must be greater than 0')
117+
.describe('Device limit'),
118+
),
113119

114120
activateAllInbounds: z.boolean().optional(),
115121
});

libs/contract/commands/users/update-user.command.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export namespace UpdateUserCommand {
5151
description: z.optional(z.string().nullable()),
5252
telegramId: z.optional(z.number().int().nullable()),
5353
email: z.optional(z.string().email('Invalid email format').nullable()),
54-
hwidDeviceLimit: z.optional(z.number().int().nullable()),
54+
hwidDeviceLimit: z.optional(
55+
z.number().int().min(0, 'Device limit must be non-negative').nullable(),
56+
),
5557
});
5658

5759
export type Request = z.infer<typeof RequestSchema>;

libs/contract/models/hwid-user-device.schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { z } from 'zod';
22

33
export const HwidUserDeviceSchema = z.object({
44
hwid: z.string(),
5-
userUuid: z.string(),
5+
userUuid: z.string().uuid(),
66
platform: z.nullable(z.string()),
77
osVersion: z.nullable(z.string()),
88
deviceModel: z.nullable(z.string()),

libs/contract/models/subscription-settings.schema.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ export const SubscriptionSettingsSchema = z.object({
2222
limitedUsersRemarks: z.array(z.string()),
2323
disabledUsersRemarks: z.array(z.string()),
2424

25-
customResponseHeaders: z.nullable(z.record(z.string(), z.string())),
25+
customResponseHeaders: z.nullable(
26+
z.record(
27+
z.string().regex(/^[!#$%&'*+-.^_`|~0-9a-zA-Z]+$/, 'Invalid header name'),
28+
z.string(),
29+
),
30+
),
2631

2732
createdAt: z
2833
.string()

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": "0.4.4",
3+
"version": "0.4.5",
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.",

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"passport-jwt": "4.0.1",
9898
"pkg-types": "2.1.0",
9999
"pm2": "5.4.3",
100-
"prisma": "^6.5.0",
100+
"prisma": "6.5.0",
101101
"prom-client": "^15.1.3",
102102
"reflect-metadata": "0.2.2",
103103
"rxjs": "7.8.2",

src/modules/hwid-user-devices/commands/upsert-hwid-user-device/upsert-hwid-user-device.handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class UpsertHwidUserDeviceHandler
2727
isOk: true,
2828
response: result,
2929
};
30-
} catch (error: unknown) {
30+
} catch (error) {
3131
this.logger.error(error);
3232
return {
3333
isOk: false,
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { HwidUserDevices } from '@prisma/client';
22

33
export class HwidUserDeviceEntity implements HwidUserDevices {
4-
hwid: string;
5-
userUuid: string;
6-
platform: string | null;
7-
osVersion: string | null;
8-
deviceModel: string | null;
9-
userAgent: string | null;
4+
public hwid: string;
5+
public userUuid: string;
6+
public platform: string | null;
7+
public osVersion: string | null;
8+
public deviceModel: string | null;
9+
public userAgent: string | null;
1010

11-
createdAt: Date;
12-
updatedAt: Date;
11+
public createdAt: Date;
12+
public updatedAt: Date;
1313

14-
constructor(history: Partial<HwidUserDevices>) {
15-
Object.assign(this, history);
14+
constructor(hwidUserDevice: Partial<HwidUserDevices>) {
15+
Object.assign(this, hwidUserDevice);
1616
return this;
1717
}
1818
}

0 commit comments

Comments
 (0)