@fnlb-project/database 1.0.81 → 1.0.83

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 CHANGED
@@ -3706,6 +3706,7 @@ export interface IUser {
3706
3706
  password: string;
3707
3707
  apiToken: string;
3708
3708
  flags?: number;
3709
+ vipExpiresAt?: Date;
3709
3710
  connections?: {
3710
3711
  discord?: {
3711
3712
  id?: string;
@@ -3735,6 +3736,24 @@ export interface IUser {
3735
3736
  }[];
3736
3737
  };
3737
3738
  }
3739
+ export type VipGrantResult = {
3740
+ ok: true;
3741
+ permanent: boolean;
3742
+ vipExpiresAt: Date | null;
3743
+ modified: boolean;
3744
+ user: HydratedDocument<IUser>;
3745
+ };
3746
+ export type VipRevokeResult = {
3747
+ ok: true;
3748
+ modified: boolean;
3749
+ user: HydratedDocument<IUser>;
3750
+ };
3751
+ export type ExpiredVipUser = {
3752
+ id: string;
3753
+ username: string;
3754
+ email: string;
3755
+ discordId?: string;
3756
+ };
3738
3757
  export interface IUserStatics {
3739
3758
  verifyPassword(password: string, hash: string): Promise<boolean>;
3740
3759
  findByToken(id: string, auth: string): Promise<HydratedDocument<IUser> | null>;
@@ -3743,6 +3762,10 @@ export interface IUserStatics {
3743
3762
  user: HydratedDocument<IUser>;
3744
3763
  app: IUserApplication;
3745
3764
  } | null>;
3765
+ expireVipIfNeeded(user: HydratedDocument<IUser>): Promise<boolean>;
3766
+ grantVip(userId: string, expiresInDays?: number | null): Promise<VipGrantResult | null>;
3767
+ revokeVip(userId: string): Promise<VipRevokeResult | null>;
3768
+ expireDueVips(limit?: number): Promise<ExpiredVipUser[]>;
3746
3769
  }
3747
3770
  export interface IUserModel extends Model<IUser>, IUserStatics {
3748
3771
  }
@@ -3754,6 +3777,30 @@ export declare enum DatabaseErrors {
3754
3777
  KeyNotFound = 211,
3755
3778
  DuplicateKey = 11000
3756
3779
  }
3780
+ export type VipGrantUpdate = {
3781
+ $set: {
3782
+ flags: number;
3783
+ vipExpiresAt?: Date;
3784
+ };
3785
+ $unset?: {
3786
+ vipExpiresAt: 1;
3787
+ };
3788
+ };
3789
+ export type VipClearUpdate = {
3790
+ $set: {
3791
+ flags: number;
3792
+ };
3793
+ $unset: {
3794
+ vipExpiresAt: 1;
3795
+ };
3796
+ };
3797
+ export declare function buildVipGrantUpdate(currentFlags: number | undefined, currentVipExpiresAt: Date | null | undefined, expiresInDays?: number | null): {
3798
+ update: VipGrantUpdate;
3799
+ vipExpiresAt: Date | null;
3800
+ permanent: boolean;
3801
+ };
3802
+ export declare function buildVipClearUpdate(currentFlags: number | undefined): VipClearUpdate;
3803
+ export declare function shouldExpireVip(flags: number | undefined, vipExpiresAt: Date | null | undefined, now?: number): "none" | "cleanup" | "expire";
3757
3804
 
3758
3805
  export {
3759
3806
  connection,