refactor: better types for getList and getDeletedAfter (#16926)

This commit is contained in:
Jason Rasmussen 2025-03-17 15:32:12 -04:00 committed by GitHub
parent 93907a89d8
commit 6a40aa83b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 342 additions and 194 deletions

View file

@ -1,5 +1,5 @@
import { sql } from 'kysely';
import { AssetStatus, AssetType, Permission } from 'src/enum';
import { UserMetadataEntity } from 'src/entities/user-metadata.entity';
import { AssetStatus, AssetType, Permission, UserStatus } from 'src/enum';
export type AuthUser = {
id: string;
@ -46,6 +46,20 @@ export type User = {
profileChangedAt: Date;
};
export type UserAdmin = User & {
storageLabel: string | null;
shouldChangePassword: boolean;
isAdmin: boolean;
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
oauthId: string;
quotaSizeInBytes: number | null;
quotaUsageInBytes: number;
status: UserStatus;
metadata: UserMetadataEntity[];
};
export type Asset = {
createdAt: Date;
updatedAt: Date;
@ -103,9 +117,9 @@ export type Partner = {
inTimeline: boolean;
};
const userColumns = ['id', 'name', 'email', 'profileImagePath', 'profileChangedAt'] as const;
export const columns = {
ackEpoch: (columnName: 'createdAt' | 'updatedAt' | 'deletedAt') =>
sql.raw<string>(`extract(epoch from "${columnName}")::text`).as('ackEpoch'),
authUser: [
'users.id',
'users.name',
@ -125,7 +139,21 @@ export const columns = {
'shared_links.allowDownload',
'shared_links.password',
],
userDto: ['id', 'name', 'email', 'profileImagePath', 'profileChangedAt'],
user: userColumns,
userAdmin: [
...userColumns,
'createdAt',
'updatedAt',
'deletedAt',
'isAdmin',
'status',
'oauthId',
'profileImagePath',
'shouldChangePassword',
'storageLabel',
'quotaSizeInBytes',
'quotaUsageInBytes',
],
tagDto: ['id', 'value', 'createdAt', 'updatedAt', 'color', 'parentId'],
apiKey: ['id', 'name', 'userId', 'createdAt', 'updatedAt', 'permissions'],
syncAsset: [