2025-04-10 18:36:29 +02:00
|
|
|
import { Selectable } from 'kysely';
|
|
|
|
import { Exif as DatabaseExif } from 'src/db';
|
2025-04-10 11:53:21 -04:00
|
|
|
import { AlbumUserRole, AssetStatus, AssetType, MemoryType, Permission, UserStatus } from 'src/enum';
|
2025-04-09 11:45:30 -04:00
|
|
|
import { OnThisDayData, UserMetadataItem } from 'src/types';
|
2025-02-12 15:23:08 -05:00
|
|
|
|
|
|
|
export type AuthUser = {
|
|
|
|
id: string;
|
|
|
|
isAdmin: boolean;
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
quotaUsageInBytes: number;
|
|
|
|
quotaSizeInBytes: number | null;
|
|
|
|
};
|
|
|
|
|
2025-04-10 11:53:21 -04:00
|
|
|
export type AlbumUser = {
|
|
|
|
user: User;
|
|
|
|
role: AlbumUserRole;
|
|
|
|
};
|
|
|
|
|
2025-03-08 13:44:36 -05:00
|
|
|
export type Library = {
|
|
|
|
id: string;
|
|
|
|
ownerId: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
updateId: string;
|
|
|
|
name: string;
|
|
|
|
importPaths: string[];
|
|
|
|
exclusionPatterns: string[];
|
|
|
|
deletedAt: Date | null;
|
|
|
|
refreshedAt: Date | null;
|
|
|
|
assets?: Asset[];
|
|
|
|
};
|
|
|
|
|
2025-02-12 15:23:08 -05:00
|
|
|
export type AuthApiKey = {
|
|
|
|
id: string;
|
|
|
|
permissions: Permission[];
|
|
|
|
};
|
|
|
|
|
2025-04-09 08:35:20 -04:00
|
|
|
export type Activity = {
|
|
|
|
id: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
albumId: string;
|
|
|
|
userId: string;
|
|
|
|
user: User;
|
|
|
|
assetId: string | null;
|
|
|
|
comment: string | null;
|
|
|
|
isLiked: boolean;
|
|
|
|
updateId: string;
|
|
|
|
};
|
|
|
|
|
2025-03-10 12:04:35 -04:00
|
|
|
export type ApiKey = {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
userId: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
permissions: Permission[];
|
|
|
|
};
|
|
|
|
|
2025-04-08 12:40:03 -04:00
|
|
|
export type Tag = {
|
|
|
|
id: string;
|
|
|
|
value: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
color: string | null;
|
|
|
|
parentId: string | null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type Memory = {
|
|
|
|
id: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
deletedAt: Date | null;
|
|
|
|
memoryAt: Date;
|
|
|
|
seenAt: Date | null;
|
|
|
|
showAt: Date | null;
|
|
|
|
hideAt: Date | null;
|
|
|
|
type: MemoryType;
|
|
|
|
data: OnThisDayData;
|
|
|
|
ownerId: string;
|
|
|
|
isSaved: boolean;
|
|
|
|
assets: Asset[];
|
|
|
|
};
|
|
|
|
|
2025-03-07 15:20:04 -05:00
|
|
|
export type User = {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
profileImagePath: string;
|
|
|
|
profileChangedAt: Date;
|
|
|
|
};
|
|
|
|
|
2025-03-17 15:32:12 -04:00
|
|
|
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;
|
2025-04-09 11:45:30 -04:00
|
|
|
metadata: UserMetadataItem[];
|
2025-03-17 15:32:12 -04:00
|
|
|
};
|
|
|
|
|
2025-03-07 16:03:34 -05:00
|
|
|
export type Asset = {
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
deletedAt: Date | null;
|
|
|
|
id: string;
|
|
|
|
updateId: string;
|
|
|
|
status: AssetStatus;
|
|
|
|
checksum: Buffer<ArrayBufferLike>;
|
|
|
|
deviceAssetId: string;
|
|
|
|
deviceId: string;
|
|
|
|
duplicateId: string | null;
|
|
|
|
duration: string | null;
|
|
|
|
encodedVideoPath: string | null;
|
|
|
|
fileCreatedAt: Date | null;
|
|
|
|
fileModifiedAt: Date | null;
|
|
|
|
isArchived: boolean;
|
|
|
|
isExternal: boolean;
|
|
|
|
isFavorite: boolean;
|
|
|
|
isOffline: boolean;
|
|
|
|
isVisible: boolean;
|
|
|
|
libraryId: string | null;
|
|
|
|
livePhotoVideoId: string | null;
|
|
|
|
localDateTime: Date | null;
|
|
|
|
originalFileName: string;
|
|
|
|
originalPath: string;
|
|
|
|
ownerId: string;
|
|
|
|
sidecarPath: string | null;
|
|
|
|
stackId: string | null;
|
|
|
|
thumbhash: Buffer<ArrayBufferLike> | null;
|
|
|
|
type: AssetType;
|
|
|
|
};
|
|
|
|
|
2025-04-08 10:52:54 -04:00
|
|
|
export type SidecarWriteAsset = {
|
|
|
|
id: string;
|
|
|
|
sidecarPath: string | null;
|
|
|
|
originalPath: string;
|
|
|
|
tags: Array<{ value: string }>;
|
|
|
|
};
|
|
|
|
|
2025-02-12 15:23:08 -05:00
|
|
|
export type AuthSharedLink = {
|
|
|
|
id: string;
|
|
|
|
expiresAt: Date | null;
|
|
|
|
userId: string;
|
|
|
|
showExif: boolean;
|
|
|
|
allowUpload: boolean;
|
|
|
|
allowDownload: boolean;
|
|
|
|
password: string | null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type AuthSession = {
|
|
|
|
id: string;
|
|
|
|
};
|
|
|
|
|
2025-03-11 16:29:56 -04:00
|
|
|
export type Partner = {
|
|
|
|
sharedById: string;
|
|
|
|
sharedBy: User;
|
|
|
|
sharedWithId: string;
|
|
|
|
sharedWith: User;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
updateId: string;
|
|
|
|
inTimeline: boolean;
|
|
|
|
};
|
|
|
|
|
2025-04-09 10:24:38 -04:00
|
|
|
export type Place = {
|
|
|
|
admin1Code: string | null;
|
|
|
|
admin1Name: string | null;
|
|
|
|
admin2Code: string | null;
|
|
|
|
admin2Name: string | null;
|
|
|
|
alternateNames: string | null;
|
|
|
|
countryCode: string;
|
|
|
|
id: number;
|
|
|
|
latitude: number;
|
|
|
|
longitude: number;
|
|
|
|
modificationDate: Date;
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type Session = {
|
|
|
|
id: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
deviceOS: string;
|
|
|
|
deviceType: string;
|
|
|
|
};
|
|
|
|
|
2025-04-10 18:36:29 +02:00
|
|
|
export type Exif = Omit<Selectable<DatabaseExif>, 'updatedAt' | 'updateId'>;
|
|
|
|
|
2025-03-17 15:32:12 -04:00
|
|
|
const userColumns = ['id', 'name', 'email', 'profileImagePath', 'profileChangedAt'] as const;
|
|
|
|
|
2025-01-15 23:31:26 -05:00
|
|
|
export const columns = {
|
2025-02-12 15:23:08 -05:00
|
|
|
authUser: [
|
|
|
|
'users.id',
|
|
|
|
'users.name',
|
|
|
|
'users.email',
|
|
|
|
'users.isAdmin',
|
|
|
|
'users.quotaUsageInBytes',
|
|
|
|
'users.quotaSizeInBytes',
|
|
|
|
],
|
|
|
|
authApiKey: ['api_keys.id', 'api_keys.permissions'],
|
|
|
|
authSession: ['sessions.id', 'sessions.updatedAt'],
|
|
|
|
authSharedLink: [
|
|
|
|
'shared_links.id',
|
|
|
|
'shared_links.userId',
|
|
|
|
'shared_links.expiresAt',
|
|
|
|
'shared_links.showExif',
|
|
|
|
'shared_links.allowUpload',
|
|
|
|
'shared_links.allowDownload',
|
|
|
|
'shared_links.password',
|
|
|
|
],
|
2025-03-17 15:32:12 -04:00
|
|
|
user: userColumns,
|
2025-04-09 08:35:20 -04:00
|
|
|
userWithPrefix: ['users.id', 'users.name', 'users.email', 'users.profileImagePath', 'users.profileChangedAt'],
|
2025-03-17 15:32:12 -04:00
|
|
|
userAdmin: [
|
|
|
|
...userColumns,
|
|
|
|
'createdAt',
|
|
|
|
'updatedAt',
|
|
|
|
'deletedAt',
|
|
|
|
'isAdmin',
|
|
|
|
'status',
|
|
|
|
'oauthId',
|
|
|
|
'profileImagePath',
|
|
|
|
'shouldChangePassword',
|
|
|
|
'storageLabel',
|
|
|
|
'quotaSizeInBytes',
|
|
|
|
'quotaUsageInBytes',
|
|
|
|
],
|
2025-03-03 13:41:19 -05:00
|
|
|
tagDto: ['id', 'value', 'createdAt', 'updatedAt', 'color', 'parentId'],
|
2025-02-12 15:23:08 -05:00
|
|
|
apiKey: ['id', 'name', 'userId', 'createdAt', 'updatedAt', 'permissions'],
|
2025-03-10 12:05:39 -04:00
|
|
|
syncAsset: [
|
|
|
|
'id',
|
|
|
|
'ownerId',
|
|
|
|
'thumbhash',
|
|
|
|
'checksum',
|
|
|
|
'fileCreatedAt',
|
|
|
|
'fileModifiedAt',
|
|
|
|
'localDateTime',
|
|
|
|
'type',
|
|
|
|
'deletedAt',
|
|
|
|
'isFavorite',
|
|
|
|
'isVisible',
|
|
|
|
'updateId',
|
|
|
|
],
|
|
|
|
syncAssetExif: [
|
|
|
|
'exif.assetId',
|
|
|
|
'exif.description',
|
|
|
|
'exif.exifImageWidth',
|
|
|
|
'exif.exifImageHeight',
|
|
|
|
'exif.fileSizeInByte',
|
|
|
|
'exif.orientation',
|
|
|
|
'exif.dateTimeOriginal',
|
|
|
|
'exif.modifyDate',
|
|
|
|
'exif.timeZone',
|
|
|
|
'exif.latitude',
|
|
|
|
'exif.longitude',
|
|
|
|
'exif.projectionType',
|
|
|
|
'exif.city',
|
|
|
|
'exif.state',
|
|
|
|
'exif.country',
|
|
|
|
'exif.make',
|
|
|
|
'exif.model',
|
|
|
|
'exif.lensModel',
|
|
|
|
'exif.fNumber',
|
|
|
|
'exif.focalLength',
|
|
|
|
'exif.iso',
|
|
|
|
'exif.exposureTime',
|
|
|
|
'exif.profileDescription',
|
|
|
|
'exif.rating',
|
|
|
|
'exif.fps',
|
|
|
|
'exif.updateId',
|
|
|
|
],
|
2025-01-15 23:31:26 -05:00
|
|
|
} as const;
|