@fnlb-project/database 1.0.82 → 1.0.84
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/index.d.ts +51 -106
- package/dist/index.js +404 -404
- package/package.json +34 -34
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
import { GenericErrorSender } from '@fnlb-project/shared/errors';
|
|
4
|
+
import { CategoryConfigSupportedPlatforms, CommunityListingKind, CommunityListingStatus, Locales } from '@fnlb-project/shared/types';
|
|
3
5
|
import { ConnectOptions, HydratedDocument, Model, Schema, connection } from 'mongoose';
|
|
4
6
|
|
|
5
7
|
export declare class DatabaseClient {
|
|
@@ -8,63 +10,6 @@ export declare class DatabaseClient {
|
|
|
8
10
|
connect(options?: ConnectOptions): Promise<void>;
|
|
9
11
|
private connectWithRetry;
|
|
10
12
|
}
|
|
11
|
-
declare enum GeneralErrorCodes {
|
|
12
|
-
GenericUnknown = "net.fnlb.errors.generic.unknown",
|
|
13
|
-
GenericInternalError = "net.fnlb.errors.generic.internal_error",
|
|
14
|
-
GenericValidationFailed = "net.fnlb.errors.generic.validation_failed",
|
|
15
|
-
GenericParseFailed = "net.fnlb.errors.generic.parse_failed",
|
|
16
|
-
GenericNotFound = "net.fnlb.errors.generic.not_found",
|
|
17
|
-
GenericAlreadyExists = "net.fnlb.errors.generic.already_exists",
|
|
18
|
-
CommonInvalidRequest = "net.fnlb.errors.common.invalid_request",
|
|
19
|
-
CommonUnableToProcessRequest = "net.fnlb.errors.common.unable_to_process_request",
|
|
20
|
-
CommonInvalidFieldsLength = "net.fnlb.errors.common.invalid_body_fields_length",
|
|
21
|
-
CommonRateLimitExceeded = "net.fnlb.errors.common.rate_limit_exceeded",
|
|
22
|
-
CommonLimitExceeded = "net.fnlb.errors.common.limit_exceeded",
|
|
23
|
-
CommonUnableToSaveToDatabase = "net.fnlb.errors.common.unable_to_save_to_database",
|
|
24
|
-
CommonUpdateRequired = "net.fnlb.errors.common.update_required",
|
|
25
|
-
CommonMaintenanceMode = "net.fnlb.errors.common.maintenance_mode",
|
|
26
|
-
AuthInvalidToken = "net.fnlb.errors.auth.invalid_token",
|
|
27
|
-
AuthInvalidAPIToken = "net.fnlb.errors.auth.invalid_api_token",
|
|
28
|
-
AuthManagedAuthRefused = "net.fnlb.errors.auth.managed_auth_refused",
|
|
29
|
-
AuthInvalidCaptchaToken = "net.fnlb.errors.auth.invalid_captcha_token",
|
|
30
|
-
AuthUnauthorized = "net.fnlb.errors.auth.unauthorized",
|
|
31
|
-
AuthForbidden = "net.fnlb.errors.auth.forbidden",
|
|
32
|
-
AuthUserBanned = "net.fnlb.errors.auth.user_banned",
|
|
33
|
-
Oauth2InvalidCode = "net.fnlb.errors.oauth2.invalid_code",
|
|
34
|
-
Oauth2InvalidScope = "net.fnlb.errors.oauth2.invalid_scope",
|
|
35
|
-
Oauth2TokenInvalid = "net.fnlb.errors.oauth2.token_invalid",
|
|
36
|
-
Oauth2UnableToFetchUser = "net.fnlb.errors.oauth2.unable_to_fetch_user",
|
|
37
|
-
Oauth2UnableToFetchConnections = "net.fnlb.errors.oauth2.unable_to_fetch_connections",
|
|
38
|
-
Oauth2UserWithoutConnection = "net.fnlb.errors.oauth2.user_without_connection",
|
|
39
|
-
Oauth2ConnectionNotVerified = "net.fnlb.errors.oauth2.connection_not_verified",
|
|
40
|
-
ReleaseNotFound = "net.fnlb.errors.release.no_release_found",
|
|
41
|
-
ReleaseVersionAlreadyExists = "net.fnlb.errors.release.version_already_exists",
|
|
42
|
-
ReleaseHashMismatch = "net.fnlb.errors.release.hash_mismatch",
|
|
43
|
-
MfaNotEnabled = "net.fnlb.errors.mfa.not_enabled",
|
|
44
|
-
MfaAlreadyEnabled = "net.fnlb.errors.mfa.already_enabled",
|
|
45
|
-
MfaChallengeExpired = "net.fnlb.errors.mfa.challenge_expired",
|
|
46
|
-
MfaSetupExpired = "net.fnlb.errors.mfa.setup_expired"
|
|
47
|
-
}
|
|
48
|
-
declare enum InputErrorCodes {
|
|
49
|
-
LoginInvalidCredentials = "net.fnlb.errors.login.invalid_credentials",
|
|
50
|
-
LoginInvalidEmail = "net.fnlb.errors.login.invalid_email",
|
|
51
|
-
LoginInvalidOrUsedEmail = "net.fnlb.errors.login.invalid_or_used_email",
|
|
52
|
-
AuthPasswordConfirmationInvalid = "net.fnlb.errors.auth.invalid_password_confirmation",
|
|
53
|
-
MfaInvalidCode = "net.fnlb.errors.mfa.invalid_code",
|
|
54
|
-
MfaRequired = "net.fnlb.errors.mfa.required"
|
|
55
|
-
}
|
|
56
|
-
export type ErrorCodes = GeneralErrorCodes | InputErrorCodes;
|
|
57
|
-
declare enum ErrorInputTypes {
|
|
58
|
-
Username = "username",
|
|
59
|
-
Email = "email",
|
|
60
|
-
Password = "password",
|
|
61
|
-
Shared = "shared",
|
|
62
|
-
MfaCode = "mfaCode"
|
|
63
|
-
}
|
|
64
|
-
export type ErrorSenderErrors = GeneralErrorCodes | GeneralErrorCodes[] | InputErrorCodes | InputErrorCodes[] | ErrorCodes | ErrorCodes[];
|
|
65
|
-
declare abstract class GenericErrorSender {
|
|
66
|
-
abstract sendError(code: number, errors: ErrorSenderErrors, input?: ErrorInputTypes): unknown;
|
|
67
|
-
}
|
|
68
13
|
export declare class DatabaseErrorHandler {
|
|
69
14
|
static handleError(err: any, errorSender: GenericErrorSender): unknown;
|
|
70
15
|
}
|
|
@@ -230,55 +175,6 @@ export declare const BotModel: import("mongoose").Model<{
|
|
|
230
175
|
} & {
|
|
231
176
|
__v: number;
|
|
232
177
|
}>>;
|
|
233
|
-
declare enum CategoryConfigSupportedPlatforms {
|
|
234
|
-
Win = "WIN",
|
|
235
|
-
Mac = "MAC",
|
|
236
|
-
Psn = "PSN",
|
|
237
|
-
Xbl = "XBL",
|
|
238
|
-
Swt = "SWT",
|
|
239
|
-
Swt2 = "SWT2",
|
|
240
|
-
Ios = "IOS",
|
|
241
|
-
And = "AND",
|
|
242
|
-
Ps5 = "PS5",
|
|
243
|
-
Xsx = "XSX"
|
|
244
|
-
}
|
|
245
|
-
declare enum CommunityListingKind {
|
|
246
|
-
Bot = "bot",
|
|
247
|
-
Preset = "preset",
|
|
248
|
-
Category = "category",
|
|
249
|
-
Event = "event",
|
|
250
|
-
CustomCommand = "custom_command",
|
|
251
|
-
Scheduled = "scheduled"
|
|
252
|
-
}
|
|
253
|
-
declare enum CommunityListingStatus {
|
|
254
|
-
Pending = "pending",
|
|
255
|
-
Published = "published",
|
|
256
|
-
Rejected = "rejected",
|
|
257
|
-
Unlisted = "unlisted"
|
|
258
|
-
}
|
|
259
|
-
declare enum Locales {
|
|
260
|
-
Default = "en",
|
|
261
|
-
EnUS = "en-US",
|
|
262
|
-
Es = "es",
|
|
263
|
-
Es419 = "es-419",
|
|
264
|
-
Ar = "ar",
|
|
265
|
-
De = "de",
|
|
266
|
-
Fr = "fr",
|
|
267
|
-
He = "he",
|
|
268
|
-
Id = "id",
|
|
269
|
-
It = "it",
|
|
270
|
-
Ja = "ja",
|
|
271
|
-
Ko = "ko",
|
|
272
|
-
Pl = "pl",
|
|
273
|
-
Pt = "pt",
|
|
274
|
-
PtBR = "pt-BR",
|
|
275
|
-
Ru = "ru",
|
|
276
|
-
Th = "th",
|
|
277
|
-
Tr = "tr",
|
|
278
|
-
Vi = "vi",
|
|
279
|
-
Zh = "zh",
|
|
280
|
-
ZhHant = "zh-Hant"
|
|
281
|
-
}
|
|
282
178
|
export declare const CategoryModel: import("mongoose").Model<{
|
|
283
179
|
owner: import("mongoose").Types.ObjectId;
|
|
284
180
|
name: string;
|
|
@@ -3703,9 +3599,12 @@ export interface IUser {
|
|
|
3703
3599
|
username: string;
|
|
3704
3600
|
avatar?: string;
|
|
3705
3601
|
email: string;
|
|
3602
|
+
/** Encrypted personal email kept for account recovery when `email` is a staff @fnlb.net address. */
|
|
3603
|
+
recoveryEmail?: string;
|
|
3706
3604
|
password: string;
|
|
3707
3605
|
apiToken: string;
|
|
3708
3606
|
flags?: number;
|
|
3607
|
+
vipExpiresAt?: Date;
|
|
3709
3608
|
connections?: {
|
|
3710
3609
|
discord?: {
|
|
3711
3610
|
id?: string;
|
|
@@ -3735,6 +3634,24 @@ export interface IUser {
|
|
|
3735
3634
|
}[];
|
|
3736
3635
|
};
|
|
3737
3636
|
}
|
|
3637
|
+
export type VipGrantResult = {
|
|
3638
|
+
ok: true;
|
|
3639
|
+
permanent: boolean;
|
|
3640
|
+
vipExpiresAt: Date | null;
|
|
3641
|
+
modified: boolean;
|
|
3642
|
+
user: HydratedDocument<IUser>;
|
|
3643
|
+
};
|
|
3644
|
+
export type VipRevokeResult = {
|
|
3645
|
+
ok: true;
|
|
3646
|
+
modified: boolean;
|
|
3647
|
+
user: HydratedDocument<IUser>;
|
|
3648
|
+
};
|
|
3649
|
+
export type ExpiredVipUser = {
|
|
3650
|
+
id: string;
|
|
3651
|
+
username: string;
|
|
3652
|
+
email: string;
|
|
3653
|
+
discordId?: string;
|
|
3654
|
+
};
|
|
3738
3655
|
export interface IUserStatics {
|
|
3739
3656
|
verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
3740
3657
|
findByToken(id: string, auth: string): Promise<HydratedDocument<IUser> | null>;
|
|
@@ -3743,6 +3660,10 @@ export interface IUserStatics {
|
|
|
3743
3660
|
user: HydratedDocument<IUser>;
|
|
3744
3661
|
app: IUserApplication;
|
|
3745
3662
|
} | null>;
|
|
3663
|
+
expireVipIfNeeded(user: HydratedDocument<IUser>): Promise<boolean>;
|
|
3664
|
+
grantVip(userId: string, expiresInDays?: number | null): Promise<VipGrantResult | null>;
|
|
3665
|
+
revokeVip(userId: string): Promise<VipRevokeResult | null>;
|
|
3666
|
+
expireDueVips(limit?: number): Promise<ExpiredVipUser[]>;
|
|
3746
3667
|
}
|
|
3747
3668
|
export interface IUserModel extends Model<IUser>, IUserStatics {
|
|
3748
3669
|
}
|
|
@@ -3754,6 +3675,30 @@ export declare enum DatabaseErrors {
|
|
|
3754
3675
|
KeyNotFound = 211,
|
|
3755
3676
|
DuplicateKey = 11000
|
|
3756
3677
|
}
|
|
3678
|
+
export type VipGrantUpdate = {
|
|
3679
|
+
$set: {
|
|
3680
|
+
flags: number;
|
|
3681
|
+
vipExpiresAt?: Date;
|
|
3682
|
+
};
|
|
3683
|
+
$unset?: {
|
|
3684
|
+
vipExpiresAt: 1;
|
|
3685
|
+
};
|
|
3686
|
+
};
|
|
3687
|
+
export type VipClearUpdate = {
|
|
3688
|
+
$set: {
|
|
3689
|
+
flags: number;
|
|
3690
|
+
};
|
|
3691
|
+
$unset: {
|
|
3692
|
+
vipExpiresAt: 1;
|
|
3693
|
+
};
|
|
3694
|
+
};
|
|
3695
|
+
export declare function buildVipGrantUpdate(currentFlags: number | undefined, currentVipExpiresAt: Date | null | undefined, expiresInDays?: number | null): {
|
|
3696
|
+
update: VipGrantUpdate;
|
|
3697
|
+
vipExpiresAt: Date | null;
|
|
3698
|
+
permanent: boolean;
|
|
3699
|
+
};
|
|
3700
|
+
export declare function buildVipClearUpdate(currentFlags: number | undefined): VipClearUpdate;
|
|
3701
|
+
export declare function shouldExpireVip(flags: number | undefined, vipExpiresAt: Date | null | undefined, now?: number): "none" | "cleanup" | "expire";
|
|
3757
3702
|
|
|
3758
3703
|
export {
|
|
3759
3704
|
connection,
|