From 97d271b2958f28613e5f99e5fed9e296c4653e17 Mon Sep 17 00:00:00 2001 From: whinis Date: Wed, 18 Feb 2026 07:56:24 -0500 Subject: [PATCH] Renamed to JsonNumber and removed from incorrectly typed date field --- src/util/entities/BaseClass.ts | 4 ++-- src/util/entities/Member.ts | 3 +-- src/util/entities/User.ts | 10 +++++----- src/util/util/Decorators.ts | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/util/entities/BaseClass.ts b/src/util/entities/BaseClass.ts index 2b6c651b0..b8bf73c4c 100644 --- a/src/util/entities/BaseClass.ts +++ b/src/util/entities/BaseClass.ts @@ -20,7 +20,7 @@ import { BaseEntity, BeforeInsert, BeforeUpdate, Column, ColumnOptions, FindOpti import { Snowflake } from "../util/Snowflake"; import { getDatabase } from "../util/Database"; import { OrmUtils } from "../imports/OrmUtils"; -import { annotationsKey } from "../util/Decorators"; +import { annotationsKey, JsonNumber } from "../util/Decorators"; export class BaseClassWithoutId extends BaseEntity { private get construct() { @@ -56,7 +56,7 @@ export class BaseClassWithoutId extends BaseEntity { if ( key in this && // This object has this property, should never fail but better to be safe key in annotations && // If this property has an annotation - annotations[key].indexOf("BigintToLong") > -1 && // if one of the annotations is JsonRemoveEmpty + annotations[key].indexOf("JsonNumber") > -1 && // if one of the annotations is JsonRemoveEmpty typeof this[key] == "string" // and its a String ) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 5d2de478c..163c25f75 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -29,7 +29,7 @@ import { Message } from "./Message"; import { Role } from "./Role"; import { User } from "./User"; import { AvatarDecorationData, Collectibles, DisplayNameStyle, PrimaryGuild, PublicMember, PublicMemberProjection, UserGuildSettings } from "@spacebar/schemas"; -import { BigintToLong } from "../util/Decorators"; +import { JsonNumber } from "../util/Decorators"; export const MemberPrivateProjection: (keyof Member)[] = [ "id", @@ -99,7 +99,6 @@ export class Member extends BaseClassWithoutId { joined_at: Date; @Column({ type: "bigint", nullable: true }) - @BigintToLong premium_since?: number; @Column() diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index 57b90ee12..9a5f0d950 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -38,7 +38,7 @@ import { PublicUserProjection, UserPrivate, } from "@spacebar/schemas"; -import { BigintToLong } from "../util/Decorators"; +import { JsonNumber } from "../util/Decorators"; @Entity({ name: "users", @@ -125,22 +125,22 @@ export class User extends BaseClass { email?: string; // email of the user @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber flags: number = 0; // UserFlags // TODO: generate @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber public_flags: number = 0; @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber purchased_flags: number = 0; @Column() premium_usage_flags: number = 0; @Column({ type: "bigint" }) - @BigintToLong + @JsonNumber rights: string; @OneToMany(() => Session, (session: Session) => session.user) diff --git a/src/util/util/Decorators.ts b/src/util/util/Decorators.ts index 0b7a67b61..dd2ec1b27 100644 --- a/src/util/util/Decorators.ts +++ b/src/util/util/Decorators.ts @@ -20,7 +20,7 @@ export function JsonRemoveEmpty(target: BaseClassWithoutId, propertyKey: string) addAnnotationMetadata(target, propertyKey, "JsonRemoveEmpty"); } -export function BigintToLong(target: BaseClassWithoutId, propertyKey: string) { +export function JsonNumber(target: BaseClassWithoutId, propertyKey: string) { initAnnotationMetadata(target, propertyKey); - addAnnotationMetadata(target, propertyKey, "BigintToLong"); + addAnnotationMetadata(target, propertyKey, "JsonNumber"); }