vr-models 1.0.19 → 1.0.20
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.
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, ModelStatic, NonAttribute } from "vr-migrations";
|
|
2
|
+
import { User } from "./user.models";
|
|
3
|
+
export interface BanAttributes {
|
|
4
|
+
id?: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
adminId: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
bannedAt: Date;
|
|
9
|
+
isPermanent: boolean;
|
|
10
|
+
appealedAt?: Date;
|
|
11
|
+
appealReason?: string;
|
|
12
|
+
appealStatus?: "pending" | "approved" | "rejected";
|
|
13
|
+
revokedAt?: Date;
|
|
14
|
+
revokedBy?: string;
|
|
15
|
+
revocationReason?: string;
|
|
16
|
+
user?: User;
|
|
17
|
+
}
|
|
18
|
+
export interface BanCreationAttributes extends Omit<BanAttributes, "id" | "createdAt" | "updatedAt"> {
|
|
19
|
+
id?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class Ban extends Model<InferAttributes<Ban>, InferCreationAttributes<Ban>> implements BanAttributes {
|
|
22
|
+
id: CreationOptional<string>;
|
|
23
|
+
userId: string;
|
|
24
|
+
adminId: string;
|
|
25
|
+
reason: string;
|
|
26
|
+
bannedAt: Date;
|
|
27
|
+
isPermanent: boolean;
|
|
28
|
+
appealedAt: CreationOptional<Date | undefined>;
|
|
29
|
+
appealReason: CreationOptional<string | undefined>;
|
|
30
|
+
appealStatus: CreationOptional<"pending" | "approved" | "rejected" | undefined>;
|
|
31
|
+
revokedAt: CreationOptional<Date | undefined>;
|
|
32
|
+
revokedBy: CreationOptional<string | undefined>;
|
|
33
|
+
revocationReason: CreationOptional<string | undefined>;
|
|
34
|
+
user: NonAttribute<User>;
|
|
35
|
+
static initialize(sequelize: any): void;
|
|
36
|
+
static associate(models: Record<string, ModelStatic<Model>>): void;
|
|
37
|
+
}
|
|
38
|
+
export type BanModel = typeof Ban;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ban = void 0;
|
|
4
|
+
const vr_migrations_1 = require("vr-migrations");
|
|
5
|
+
class Ban extends vr_migrations_1.Model {
|
|
6
|
+
static initialize(sequelize) {
|
|
7
|
+
this.init({
|
|
8
|
+
id: {
|
|
9
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
10
|
+
defaultValue: vr_migrations_1.DataTypes.UUIDV4,
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
userId: {
|
|
15
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
16
|
+
allowNull: true,
|
|
17
|
+
},
|
|
18
|
+
adminId: {
|
|
19
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
},
|
|
22
|
+
reason: {
|
|
23
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
24
|
+
allowNull: false,
|
|
25
|
+
},
|
|
26
|
+
bannedAt: {
|
|
27
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
30
|
+
},
|
|
31
|
+
isPermanent: {
|
|
32
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
defaultValue: false,
|
|
35
|
+
},
|
|
36
|
+
appealedAt: {
|
|
37
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
38
|
+
allowNull: true,
|
|
39
|
+
},
|
|
40
|
+
appealReason: {
|
|
41
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
42
|
+
allowNull: true,
|
|
43
|
+
},
|
|
44
|
+
appealStatus: {
|
|
45
|
+
type: vr_migrations_1.DataTypes.ENUM("pending", "approved", "rejected"),
|
|
46
|
+
allowNull: true,
|
|
47
|
+
},
|
|
48
|
+
revokedAt: {
|
|
49
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
50
|
+
allowNull: true,
|
|
51
|
+
},
|
|
52
|
+
revokedBy: {
|
|
53
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
54
|
+
allowNull: true,
|
|
55
|
+
},
|
|
56
|
+
revocationReason: {
|
|
57
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
58
|
+
allowNull: true,
|
|
59
|
+
},
|
|
60
|
+
}, {
|
|
61
|
+
sequelize,
|
|
62
|
+
modelName: "Ban",
|
|
63
|
+
tableName: "bans",
|
|
64
|
+
timestamps: true,
|
|
65
|
+
paranoid: false,
|
|
66
|
+
underscored: false,
|
|
67
|
+
freezeTableName: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
static associate(models) {
|
|
71
|
+
this.belongsTo(models.User, {
|
|
72
|
+
foreignKey: "userId",
|
|
73
|
+
as: "user",
|
|
74
|
+
onDelete: "CASCADE",
|
|
75
|
+
onUpdate: "CASCADE",
|
|
76
|
+
});
|
|
77
|
+
this.belongsTo(models.User, {
|
|
78
|
+
foreignKey: "adminId",
|
|
79
|
+
as: "admin",
|
|
80
|
+
onDelete: "CASCADE",
|
|
81
|
+
onUpdate: "CASCADE",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.Ban = Ban;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Model, InferAttributes, InferCreationAttributes, CreationOptional, ModelStatic, NonAttribute } from "vr-migrations";
|
|
2
|
+
import { User } from "./user.models";
|
|
3
|
+
export interface SuspensionAttributes {
|
|
4
|
+
id: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
adminId: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
startedAt: Date;
|
|
9
|
+
endsAt: Date;
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
appealedAt?: Date;
|
|
12
|
+
appealReason?: string;
|
|
13
|
+
appealStatus?: "pending" | "approved" | "rejected";
|
|
14
|
+
revokedAt?: Date;
|
|
15
|
+
revokedBy?: string;
|
|
16
|
+
revocationReason?: string;
|
|
17
|
+
createdAt?: Date;
|
|
18
|
+
updatedAt?: Date;
|
|
19
|
+
admin: NonAttribute<User>;
|
|
20
|
+
user: NonAttribute<User>;
|
|
21
|
+
}
|
|
22
|
+
export declare class Suspension extends Model<InferAttributes<Suspension>, InferCreationAttributes<Suspension>> implements SuspensionAttributes {
|
|
23
|
+
id: CreationOptional<string>;
|
|
24
|
+
userId: string;
|
|
25
|
+
adminId: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
startedAt: Date;
|
|
28
|
+
endsAt: Date;
|
|
29
|
+
isActive: boolean;
|
|
30
|
+
appealedAt: CreationOptional<Date | undefined>;
|
|
31
|
+
appealReason: CreationOptional<string | undefined>;
|
|
32
|
+
appealStatus: CreationOptional<"pending" | "approved" | "rejected" | undefined>;
|
|
33
|
+
revokedAt: CreationOptional<Date | undefined>;
|
|
34
|
+
revokedBy: CreationOptional<string | undefined>;
|
|
35
|
+
revocationReason: CreationOptional<string | undefined>;
|
|
36
|
+
createdAt: CreationOptional<Date | undefined>;
|
|
37
|
+
updatedAt: CreationOptional<Date | undefined>;
|
|
38
|
+
admin: NonAttribute<User>;
|
|
39
|
+
user: NonAttribute<User>;
|
|
40
|
+
static initialize(sequelize: any): void;
|
|
41
|
+
static associate(models: Record<string, ModelStatic<Model>>): void;
|
|
42
|
+
}
|
|
43
|
+
export type SuspensionModel = typeof Suspension;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Suspension = void 0;
|
|
4
|
+
const vr_migrations_1 = require("vr-migrations");
|
|
5
|
+
class Suspension extends vr_migrations_1.Model {
|
|
6
|
+
static initialize(sequelize) {
|
|
7
|
+
this.init({
|
|
8
|
+
id: {
|
|
9
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
10
|
+
defaultValue: vr_migrations_1.DataTypes.UUIDV4,
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
userId: {
|
|
15
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
16
|
+
allowNull: true,
|
|
17
|
+
},
|
|
18
|
+
adminId: {
|
|
19
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
},
|
|
22
|
+
reason: {
|
|
23
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
24
|
+
allowNull: false,
|
|
25
|
+
},
|
|
26
|
+
startedAt: {
|
|
27
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
30
|
+
},
|
|
31
|
+
endsAt: {
|
|
32
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
},
|
|
35
|
+
isActive: {
|
|
36
|
+
type: vr_migrations_1.DataTypes.BOOLEAN,
|
|
37
|
+
allowNull: false,
|
|
38
|
+
defaultValue: true,
|
|
39
|
+
},
|
|
40
|
+
appealedAt: {
|
|
41
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
42
|
+
allowNull: true,
|
|
43
|
+
},
|
|
44
|
+
appealReason: {
|
|
45
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
46
|
+
allowNull: true,
|
|
47
|
+
},
|
|
48
|
+
appealStatus: {
|
|
49
|
+
type: vr_migrations_1.DataTypes.ENUM("pending", "approved", "rejected"),
|
|
50
|
+
allowNull: true,
|
|
51
|
+
},
|
|
52
|
+
revokedAt: {
|
|
53
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
54
|
+
allowNull: true,
|
|
55
|
+
},
|
|
56
|
+
revokedBy: {
|
|
57
|
+
type: vr_migrations_1.DataTypes.UUID,
|
|
58
|
+
allowNull: true,
|
|
59
|
+
},
|
|
60
|
+
revocationReason: {
|
|
61
|
+
type: vr_migrations_1.DataTypes.TEXT,
|
|
62
|
+
allowNull: true,
|
|
63
|
+
},
|
|
64
|
+
createdAt: {
|
|
65
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
66
|
+
allowNull: false,
|
|
67
|
+
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
68
|
+
},
|
|
69
|
+
updatedAt: {
|
|
70
|
+
type: vr_migrations_1.DataTypes.DATE,
|
|
71
|
+
allowNull: false,
|
|
72
|
+
defaultValue: vr_migrations_1.DataTypes.NOW,
|
|
73
|
+
},
|
|
74
|
+
}, {
|
|
75
|
+
sequelize,
|
|
76
|
+
modelName: "Suspension",
|
|
77
|
+
tableName: "suspensions",
|
|
78
|
+
timestamps: true,
|
|
79
|
+
paranoid: false,
|
|
80
|
+
underscored: false,
|
|
81
|
+
freezeTableName: true,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static associate(models) {
|
|
85
|
+
this.belongsTo(models.User, {
|
|
86
|
+
foreignKey: "userId",
|
|
87
|
+
as: "user",
|
|
88
|
+
onDelete: "CASCADE",
|
|
89
|
+
onUpdate: "CASCADE",
|
|
90
|
+
});
|
|
91
|
+
this.belongsTo(models.User, {
|
|
92
|
+
foreignKey: "adminId",
|
|
93
|
+
as: "admin",
|
|
94
|
+
onDelete: "CASCADE",
|
|
95
|
+
onUpdate: "CASCADE",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.Suspension = Suspension;
|
|
@@ -148,6 +148,20 @@ class User extends vr_migrations_1.Model {
|
|
|
148
148
|
onDelete: "CASCADE",
|
|
149
149
|
onUpdate: "CASCADE",
|
|
150
150
|
});
|
|
151
|
+
// Suspensions
|
|
152
|
+
this.hasMany(models.Suspension, {
|
|
153
|
+
foreignKey: "userId",
|
|
154
|
+
as: "suspensions",
|
|
155
|
+
onDelete: "CASCADE",
|
|
156
|
+
onUpdate: "CASCADE",
|
|
157
|
+
});
|
|
158
|
+
// Bans
|
|
159
|
+
this.hasMany(models.Ban, {
|
|
160
|
+
foreignKey: "userId",
|
|
161
|
+
as: "bans",
|
|
162
|
+
onDelete: "CASCADE",
|
|
163
|
+
onUpdate: "CASCADE",
|
|
164
|
+
});
|
|
151
165
|
}
|
|
152
166
|
// Custom instance methods (example methods)
|
|
153
167
|
async softDelete(deletedBy, reason) {
|