mirror of
https://github.com/immich-app/immich.git
synced 2025-11-25 05:50:43 +09:00
refactor: better types for getList and getDeletedAfter (#16926)
This commit is contained in:
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user