Skip to content

High performance self-hosted photo and video management solution.

23.5 KB
Raw Blame
import { Injectable } from '@nestjs/common';
import { type Kysely, type NotNull, sql } from 'kysely';
import { InjectKysely } from 'nestjs-kysely';
import { ChunkedSet, DummyValue, GenerateSql } from 'src/decorators.js';
import { PersonUserRole } from 'src/dtos/person.dto.js';
import { AlbumUserRole, AssetVisibility } from 'src/enum.js';
import { PersonId } from 'src/repositories/person.repository.js';
import { DB } from 'src/schema/index.js';
import { asUuid } from 'src/utils/database.js';

class ActivityAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, activityIds: Set<string>) {
    if (activityIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('activity')
      .select('activity.id')
      .where('activity.id', 'in', [...activityIds])
      .where('activity.userId', '=', userId)
      .execute()
      .then((activities) => new Set(activities.map((activity) => activity.id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkAlbumOwnerAccess(userId: string, activityIds: Set<string>) {
    if (activityIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('activity')
      .select('activity.id')
      .innerJoin('album', (join) => join.onRef('activity.albumId', '=', 'album.id').on('album.deletedAt', 'is', null))
      .innerJoin('album_user', (join) =>
        join
          .onRef('album.id', '=', 'album_user.albumId')
          .on('album_user.role', '=', sql.lit(AlbumUserRole.Owner))
          .on('album_user.userId', '=', asUuid(userId)),
      )
      .where('activity.id', 'in', [...activityIds])
      .execute()
      .then((activities) => new Set(activities.map((activity) => activity.id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkCreateAccess(userId: string, albumIds: Set<string>) {
    if (albumIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('album')
      .select('album.id')
      .innerJoin('album_user as albumUsers', 'albumUsers.albumId', 'album.id')
      .innerJoin('user', (join) => join.onRef('user.id', '=', 'albumUsers.userId').on('user.deletedAt', 'is', null))
      .where('album.id', 'in', [...albumIds])
      .where('album.isActivityEnabled', '=', true)
      .where((eb) => eb('user.id', '=', userId))
      .where('album.deletedAt', 'is', null)
      .execute()
      .then((albums) => new Set(albums.map((album) => album.id)));
  }
}

class AlbumAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, albumIds: Set<string>) {
    if (albumIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('album')
      .select('album.id')
      .where('album.id', 'in', [...albumIds])
      .innerJoin('album_user', (join) =>
        join
          .onRef('album.id', '=', 'album_user.albumId')
          .on('album_user.role', '=', sql.lit(AlbumUserRole.Owner))
          .on('album_user.userId', '=', userId),
      )
      .where('album.deletedAt', 'is', null)
      .execute()
      .then((albums) => new Set(albums.map((album) => album.id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkSharedAlbumAccess(userId: string, albumIds: Set<string>, access: AlbumUserRole) {
    if (albumIds.size === 0) {
      return new Set<string>();
    }

    const accessRole =
      access === AlbumUserRole.Editor ? [AlbumUserRole.Editor] : [AlbumUserRole.Editor, AlbumUserRole.Viewer];

    return this.db
      .selectFrom('album')
      .select('album.id')
      .innerJoin('album_user', 'album_user.albumId', 'album.id')
      .innerJoin('user', (join) => join.onRef('user.id', '=', 'album_user.userId').on('user.deletedAt', 'is', null))
      .where('album.id', 'in', [...albumIds])
      .where('album.deletedAt', 'is', null)
      .where('user.id', '=', userId)
      .where('album_user.role', 'in', [...accessRole])
      .execute()
      .then((albums) => new Set(albums.map((album) => album.id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkSharedLinkAccess(sharedLinkId: string, albumIds: Set<string>) {
    if (albumIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('shared_link')
      .select('shared_link.albumId')
      .where('shared_link.id', '=', sharedLinkId)
      .where('shared_link.albumId', 'in', [...albumIds])
      .execute()
      .then(
        (sharedLinks) =>
          new Set(
            sharedLinks.filter((sharedLink) => sharedLink.albumId).map((sharedLink) => sharedLink.albumId),
          ) as Set<string>,
      );
  }
}

class AssetAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkAlbumAccess(userId: string, assetIds: Set<string>) {
    if (assetIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .with('target', (qb) => qb.selectNoFrom(sql`array[${sql.join([...assetIds])}]::uuid[]`.as('ids')))
      .selectFrom('album')
      .innerJoin('album_asset as albumAssets', 'album.id', 'albumAssets.albumId')
      .innerJoin('asset', (join) =>
        join.onRef('asset.id', '=', 'albumAssets.assetId').on('asset.deletedAt', 'is', null),
      )
      .leftJoin('album_user as albumUsers', 'albumUsers.albumId', 'album.id')
      .leftJoin('user', (join) => join.onRef('user.id', '=', 'albumUsers.userId').on('user.deletedAt', 'is', null))
      .crossJoin('target')
      .select(['asset.id', 'asset.livePhotoVideoId'])
      .where((eb) =>
        eb.or([
          eb('asset.id', '=', sql<string>`any(target.ids)`),
          eb('asset.livePhotoVideoId', '=', sql<string>`any(target.ids)`),
        ]),
      )
      .where('user.id', '=', userId)
      .where('album.deletedAt', 'is', null)
      .execute()
      .then((assets) => {
        const allowedIds = new Set<string>();
        for (const asset of assets) {
          if (asset.id && assetIds.has(asset.id)) {
            allowedIds.add(asset.id);
          }
          if (asset.livePhotoVideoId && assetIds.has(asset.livePhotoVideoId)) {
            allowedIds.add(asset.livePhotoVideoId);
          }
        }
        return allowedIds;
      });
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, assetIds: Set<string>, hasElevatedPermission: boolean | undefined) {
    if (assetIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('asset')
      .select('asset.id')
      .where('asset.id', 'in', [...assetIds])
      .where('asset.ownerId', '=', userId)
      .$if(!hasElevatedPermission, (eb) => eb.where('asset.visibility', '!=', AssetVisibility.Locked))
      .execute()
      .then((assets) => new Set(assets.map((asset) => asset.id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkPartnerAccess(userId: string, assetIds: Set<string>) {
    if (assetIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('partner')
      .innerJoin('user as sharedBy', (join) =>
        join.onRef('sharedBy.id', '=', 'partner.sharedById').on('sharedBy.deletedAt', 'is', null),
      )
      .innerJoin('asset', (join) => join.onRef('asset.ownerId', '=', 'sharedBy.id').on('asset.deletedAt', 'is', null))
      .select('asset.id')
      .where('partner.sharedWithId', '=', userId)
      .where((eb) =>
        eb.or([
          eb('asset.visibility', '=', sql.lit(AssetVisibility.Timeline)),
          eb('asset.visibility', '=', sql.lit(AssetVisibility.Hidden)),
        ]),
      )

      .where('asset.id', 'in', [...assetIds])
      .execute()
      .then((assets) => new Set(assets.map((asset) => asset.id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkSharedLinkAccess(sharedLinkId: string, assetIds: Set<string>) {
    if (assetIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .with('target', (qb) => qb.selectNoFrom(sql<string[]>`array[${sql.join([...assetIds])}]::uuid[]`.as('ids')))
      .with('link', (qb) =>
        qb
          .selectFrom('shared_link')
          .select(['shared_link.id', 'shared_link.albumId'])
          .where('shared_link.id', '=', sharedLinkId),
      )
      .selectFrom('asset')
      .crossJoin('target')
      .innerJoinLateral(
        (eb) =>
          eb
            .selectFrom('link')
            .innerJoin('shared_link_asset', 'shared_link_asset.sharedLinkId', 'link.id')
            .select(sql.lit(1).as('match'))
            .whereRef('shared_link_asset.assetId', '=', 'asset.id')
            .unionAll(
              eb
                .selectFrom('link')
                .innerJoin('album', (join) =>
                  join.onRef('album.id', '=', 'link.albumId').on('album.deletedAt', 'is', null),
                )
                .innerJoin('album_asset', 'album_asset.albumId', 'album.id')
                .select(sql.lit(1).as('match'))
                .whereRef('album_asset.assetId', '=', 'asset.id'),
            )
            .limit(1)
            .as('membership'),
        (join) => join.onTrue(),
      )
      .select(['asset.id', 'asset.livePhotoVideoId'])
      .where('asset.deletedAt', 'is', null)
      .where((eb) =>
        eb.or([
          eb('asset.id', '=', eb.fn.any('target.ids')),
          eb('asset.livePhotoVideoId', '=', eb.fn.any('target.ids')),
        ]),
      )
      .execute()
      .then((rows) => {
        const allowedIds = new Set<string>();
        for (const row of rows) {
          if (assetIds.has(row.id)) {
            allowedIds.add(row.id);
          }
          if (row.livePhotoVideoId && assetIds.has(row.livePhotoVideoId)) {
            allowedIds.add(row.livePhotoVideoId);
          }
        }
        return allowedIds;
      });
  }
}

class AssetFileAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, fileIds: Set<string>, hasElevatedPermission: boolean | undefined) {
    if (fileIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('asset_file')
      .select('asset_file.id')
      .innerJoin('asset', 'asset.id', 'asset_file.assetId')
      .$if(!hasElevatedPermission, (eb) => eb.where('asset.visibility', '!=', AssetVisibility.Locked))
      .where('asset.ownerId', '=', userId)
      .where('asset_file.id', 'in', [...fileIds])
      .execute()
      .then((files) => new Set(files.map(({ id }) => id)));
  }
}

class AuthDeviceAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, deviceIds: Set<string>) {
    if (deviceIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('session')
      .select('session.id')
      .where('session.userId', '=', userId)
      .where('session.id', 'in', [...deviceIds])
      .execute()
      .then((tokens) => new Set(tokens.map((token) => token.id)));
  }
}

class DuplicateAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, duplicateIds: Set<string>) {
    if (duplicateIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('asset')
      .select('asset.duplicateId')
      .where('asset.duplicateId', 'in', [...duplicateIds])
      .where('asset.ownerId', '=', userId)
      .where('asset.deletedAt', 'is', null)
      .$narrowType<{ duplicateId: NotNull }>()
      .execute()
      .then((assets) => new Set(assets.map((asset) => asset.duplicateId)));
  }
}

class NotificationAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, notificationIds: Set<string>) {
    if (notificationIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('notification')
      .select('notification.id')
      .where('notification.id', 'in', [...notificationIds])
      .where('notification.userId', '=', userId)
      .execute()
      .then((stacks) => new Set(stacks.map((stack) => stack.id)));
  }
}

class SessionAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, sessionIds: Set<string>) {
    if (sessionIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('session')
      .select('session.id')
      .where('session.id', 'in', [...sessionIds])
      .where('session.userId', '=', userId)
      .execute()
      .then((sessions) => new Set(sessions.map((session) => session.id)));
  }
}
class StackAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, stackIds: Set<string>) {
    if (stackIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('stack')
      .select('stack.id')
      .where('stack.id', 'in', [...stackIds])
      .where('stack.ownerId', '=', userId)
      .execute()
      .then((stacks) => new Set(stacks.map((stack) => stack.id)));
  }
}

class TimelineAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkPartnerAccess(userId: string, partnerIds: Set<string>) {
    if (partnerIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('partner')
      .select('partner.sharedById')
      .where('partner.sharedById', 'in', [...partnerIds])
      .where('partner.sharedWithId', '=', userId)
      .execute()
      .then((partners) => new Set(partners.map((partner) => partner.sharedById)));
  }
}

class MemoryAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, memoryIds: Set<string>) {
    if (memoryIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('memory')
      .select('memory.id')
      .where('memory.id', 'in', [...memoryIds])
      .where('memory.ownerId', '=', userId)
      .where('memory.deletedAt', 'is', null)
      .execute()
      .then((memories) => new Set(memories.map((memory) => memory.id)));
  }
}

class ClusterGroupAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  checkInviteAccess(userId: string, clusterGroupIds: Set<string>) {
    if (clusterGroupIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('cluster_group_request')
      .select('cluster_group_request.clusterGroupId')
      .where('cluster_group_request.clusterGroupId', 'in', [...clusterGroupIds])
      .where('cluster_group_request.userId', '=', userId)
      .execute()
      .then((requests) => new Set(requests.map((request) => request.clusterGroupId)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, clusterGroupIds: Set<string>) {
    if (clusterGroupIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('user')
      .select('user.clusterGroupId')
      .where('user.clusterGroupId', 'in', [...clusterGroupIds])
      .where('user.id', '=', userId)
      .execute()
      .then((users) => new Set(users.map((user) => user.clusterGroupId)));
  }
}

class ClusterGroupRequestAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  checkOwnerAccess(userId: string, clusterGroupRequestIds: Set<string>) {
    if (clusterGroupRequestIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('cluster_group_request')
      .select('cluster_group_request.id')
      .where('cluster_group_request.id', 'in', [...clusterGroupRequestIds])
      .where('cluster_group_request.userId', '=', userId)
      .execute()
      .then((requests) => new Set(requests.map(({ id }) => id)));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  checkGroupAccess(userId: string, clusterGroupRequestIds: Set<string>) {
    if (clusterGroupRequestIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('cluster_group_request')
      .select('cluster_group_request.id')
      .where('cluster_group_request.id', 'in', [...clusterGroupRequestIds])
      .where('cluster_group_request.clusterGroupId', '=', (eb) =>
        eb.selectFrom('user').select('user.clusterGroupId').where('user.id', '=', userId),
      )
      .execute()
      .then((requests) => new Set(requests.map(({ id }) => id)));
  }
}

class PasskeyAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, passkeyIds: Set<string>) {
    if (passkeyIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('passkey')
      .select('passkey.id')
      .where('passkey.id', 'in', [...passkeyIds])
      .where('passkey.userId', '=', userId)
      .execute()
      .then((passkeys) => new Set(passkeys.map((passkey) => passkey.id)));
  }
}

class PersonAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET, [PersonUserRole.Admin]] })
  @ChunkedSet({ paramIndex: 1 })
  async checkAccess(userId: string, personIds: Set<PersonId>, roles: PersonUserRole[]) {
    if (personIds.size === 0 || roles.length === 0) {
      return new Set<PersonId>();
    }

    const personGroupIds = personIds
      .values()
      .map(({ personGroupId }) => personGroupId)
      .toArray();
    const ownerIds = personIds
      .values()
      .map(({ ownerId }) => ownerId)
      .toArray();

    return this.db
      .selectFrom(
        sql<{ personGroupId: string; ownerId: string }>`(
      select
        unnest(${personGroupIds}::uuid[]) as "personGroupId",
        unnest(${ownerIds}::uuid[]) as "ownerId"
    )`.as('people'),
      )
      .select(['personGroupId', 'ownerId'])
      .where((eb) =>
        eb.or([
          eb.exists(
            eb
              .selectFrom('person')
              .whereRef('people.personGroupId', '=', 'person.personGroupId')
              .whereRef('people.ownerId', '=', 'person.ownerId')
              .where('person.ownerId', '=', userId)
              .selectAll(),
          ),
          eb.exists(
            eb
              .selectFrom('person_user')
              .where('person_user.sharedWithId', '=', userId)
              .where('person_user.role', 'in', roles)
              .whereRef('people.personGroupId', '=', 'person_user.personGroupId')
              .whereRef('people.ownerId', '=', 'person_user.sharedById')
              .selectAll(),
          ),
        ]),
      )
      .execute()
      .then((items) => new Set(items));
  }

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkFaceOwnerAccess(userId: string, assetFaceIds: Set<string>) {
    if (assetFaceIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('asset_face')
      .select('asset_face.id')
      .leftJoin('asset', (join) => join.onRef('asset.id', '=', 'asset_face.assetId').on('asset.deletedAt', 'is', null))
      .where('asset_face.id', 'in', [...assetFaceIds])
      .where('asset.ownerId', '=', userId)
      .execute()
      .then((faces) => new Set(faces.map((face) => face.id)));
  }
}

class PartnerAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkUpdateAccess(userId: string, partnerIds: Set<string>) {
    if (partnerIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('partner')
      .select('partner.sharedById')
      .where('partner.sharedById', 'in', [...partnerIds])
      .where('partner.sharedWithId', '=', userId)
      .execute()
      .then((partners) => new Set(partners.map((partner) => partner.sharedById)));
  }
}

class TagAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, tagIds: Set<string>) {
    if (tagIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('tag')
      .select('tag.id')
      .where('tag.id', 'in', [...tagIds])
      .where('tag.userId', '=', userId)
      .execute()
      .then((tags) => new Set(tags.map((tag) => tag.id)));
  }
}

class WorkflowAccess {
  constructor(private db: Kysely<DB>) {}

  @GenerateSql({ params: [DummyValue.UUID, DummyValue.UUID_SET] })
  @ChunkedSet({ paramIndex: 1 })
  async checkOwnerAccess(userId: string, workflowIds: Set<string>) {
    if (workflowIds.size === 0) {
      return new Set<string>();
    }

    return this.db
      .selectFrom('workflow')
      .select('workflow.id')
      .where('workflow.id', 'in', [...workflowIds])
      .where('workflow.ownerId', '=', userId)
      .execute()
      .then((workflows) => new Set(workflows.map((workflow) => workflow.id)));
  }
}

@Injectable()
export class AccessRepository {
  activity: ActivityAccess;
  album: AlbumAccess;
  asset: AssetAccess;
  assetFile: AssetFileAccess;
  authDevice: AuthDeviceAccess;
  duplicate: DuplicateAccess;
  memory: MemoryAccess;
  notification: NotificationAccess;
  clusterGroup: ClusterGroupAccess;
  clusterGroupRequest: ClusterGroupRequestAccess;
  person: PersonAccess;
  partner: PartnerAccess;
  passkey: PasskeyAccess;
  session: SessionAccess;
  stack: StackAccess;
  tag: TagAccess;
  timeline: TimelineAccess;
  workflow: WorkflowAccess;

  constructor(@InjectKysely() db: Kysely<DB>) {
    this.activity = new ActivityAccess(db);
    this.album = new AlbumAccess(db);
    this.asset = new AssetAccess(db);
    this.assetFile = new AssetFileAccess(db);
    this.authDevice = new AuthDeviceAccess(db);
    this.duplicate = new DuplicateAccess(db);
    this.memory = new MemoryAccess(db);
    this.notification = new NotificationAccess(db);
    this.clusterGroup = new ClusterGroupAccess(db);
    this.clusterGroupRequest = new ClusterGroupRequestAccess(db);
    this.person = new PersonAccess(db);
    this.partner = new PartnerAccess(db);
    this.passkey = new PasskeyAccess(db);
    this.session = new SessionAccess(db);
    this.stack = new StackAccess(db);
    this.tag = new TagAccess(db);
    this.timeline = new TimelineAccess(db);
    this.workflow = new WorkflowAccess(db);
  }
}