📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Upgrade typeorm
Blue Mouseedd384f31656
diff --git a/backend/apps/production/src/action-tokens/action-tokens.service.ts b/backend/apps/production/src/action-tokens/action-tokens.service.tsindex 4e855440a..487ac4953 100644--- a/backend/apps/production/src/action-tokens/action-tokens.service.ts+++ b/backend/apps/production/src/action-tokens/action-tokens.service.ts@@ -29,7 +29,8 @@ export class ActionTokensService {}async find(id: string): Promise<ActionToken> {- return this.actionTokensRepository.findOneOrFail(id, {+ return this.actionTokensRepository.findOneOrFail({+ where: { id },relations: ['user'],})}@@ -51,7 +52,8 @@ export class ActionTokensService {}public async findActionToken(token: string) {- return this.actionTokensRepository.findOne(token, {+ return this.actionTokensRepository.findOne({+ where: { id: token },relations: ['user'],})}diff --git a/backend/apps/production/src/alert/alert.controller.ts b/backend/apps/production/src/alert/alert.controller.tsindex 58532006c..be8a6ca7f 100644--- a/backend/apps/production/src/alert/alert.controller.ts+++ b/backend/apps/production/src/alert/alert.controller.ts@@ -91,7 +91,10 @@ export class AlertController {) {this.logger.log({ uid }, 'POST /alert')- const user = await this.userService.findOneWithRelations(uid, ['projects'])+ const user = await this.userService.findOne({+ where: { id: uid },+ relations: ['projects'],+ })const maxAlerts = ACCOUNT_PLANS[user.planCode]?.maxAlerts@@ -182,7 +185,7 @@ export class AlertController {throw new NotFoundException()}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })this.projectService.allowedToManage(alert.project,@@ -229,7 +232,7 @@ export class AlertController {throw new NotFoundException()}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })this.projectService.allowedToManage(alert.project,diff --git a/backend/apps/production/src/alert/alert.service.ts b/backend/apps/production/src/alert/alert.service.tsindex ec592e99c..d49bc34e9 100644--- a/backend/apps/production/src/alert/alert.service.ts+++ b/backend/apps/production/src/alert/alert.service.ts@@ -1,6 +1,6 @@import { Injectable } from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'-import { Repository } from 'typeorm'+import { FindOneOptions, Repository } from 'typeorm'import { Pagination, PaginationOptionsInterface } from '../common/pagination'import { Alert } from './entity/alert.entity'import { AlertDTO } from './dto/alert.dto'@@ -34,7 +34,8 @@ export class AlertService {}findOneWithRelations(id: string): Promise<Alert | null> {- return this.alertsReporsitory.findOne(id, {+ return this.alertsReporsitory.findOne({+ where: { id },relations: ['project', 'project.admin'],})}@@ -43,8 +44,8 @@ export class AlertService {return this.alertsReporsitory.count(options)}- findOne(id: string, params: object = {}): Promise<Alert | null> {- return this.alertsReporsitory.findOne(id, params)+ findOne(options: FindOneOptions<Alert>): Promise<Alert | null> {+ return this.alertsReporsitory.findOne(options)}findWhere(diff --git a/backend/apps/production/src/analytics/analytics.service.ts b/backend/apps/production/src/analytics/analytics.service.tsindex 344e5ba81..de318c695 100644--- a/backend/apps/production/src/analytics/analytics.service.ts+++ b/backend/apps/production/src/analytics/analytics.service.ts@@ -379,10 +379,7 @@ export class AnalyticsService {}async checkUptimeAccess(pid: string, monitorId: number) {- const monitor = await this.projectService.findMonitorById(- monitorId as unknown as string,- pid,- )+ const monitor = await this.projectService.findMonitorById(monitorId, pid)if (!monitor) {throw new ForbiddenException('You are not allowed to view this project')diff --git a/backend/apps/production/src/integrations/telegram/telegram.service.ts b/backend/apps/production/src/integrations/telegram/telegram.service.tsindex 07f1f6c59..31a8f14fd 100644--- a/backend/apps/production/src/integrations/telegram/telegram.service.ts+++ b/backend/apps/production/src/integrations/telegram/telegram.service.ts@@ -18,8 +18,10 @@ export class TelegramService {private readonly messageRepository: Repository<Message>,) {}- async getStartMessage(telgramId: number) {- const user = await this.userService.getUserByTelegramId(telgramId)+ async getStartMessage(telegramId: number) {+ const user = await this.userService.getUserByTelegramId(+ telegramId.toString(),+ )let text: stringlet extra: unknown = {}@@ -29,7 +31,7 @@ export class TelegramService {'Welcome to the Swetrix Bot!' +'\n\n' +'Your Telegram ID is: ' +- `<code>${telgramId.toString()}</code>` ++ `<code>${telegramId.toString()}</code>` +'\n\n' +'You can use this ID to link your Telegram account with your Swetrix account.' +'\n\n' +@@ -84,7 +86,7 @@ export class TelegramService {return}- const user = await this.userService.getUserByTelegramId(chatId)+ const user = await this.userService.getUserByTelegramId(chatId.toString())await this.userService.updateUserTelegramId(user.id, null)}diff --git a/backend/apps/production/src/marketplace/comments/comments.controller.ts b/backend/apps/production/src/marketplace/comments/comments.controller.tsindex 86a884d6a..90b08fc5e 100644--- a/backend/apps/production/src/marketplace/comments/comments.controller.ts+++ b/backend/apps/production/src/marketplace/comments/comments.controller.ts@@ -68,7 +68,7 @@ export class CommentsController {@Body() body: CreateCommentBodyDto,@CurrentUserId() userId: string,): Promise<Comment> {- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found.')@@ -124,7 +124,7 @@ export class CommentsController {throw new NotFoundException('Comment not found.')}- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!_includes(user.roles, UserType.ADMIN) && comment.user.id !== userId) {throw new ConflictException('You are not allowed to do this.')@@ -139,7 +139,7 @@ export class CommentsController {@Body() commentReplyDto: CreateReplyCommentBodyDto,@CurrentUserId() userId: string,): Promise<CommentReply & { isOwner?: boolean }> {- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found.')@@ -222,7 +222,7 @@ export class CommentsController {throw new NotFoundException('Comment reply not found.')}- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!(diff --git a/backend/apps/production/src/marketplace/comments/comments.service.ts b/backend/apps/production/src/marketplace/comments/comments.service.tsindex 88462bcfd..8abca4607 100644--- a/backend/apps/production/src/marketplace/comments/comments.service.ts+++ b/backend/apps/production/src/marketplace/comments/comments.service.ts@@ -61,7 +61,7 @@ export class CommentsService {async update(id: string, comment: Partial<Comment>): Promise<Comment> {await this.commentsRepository.update(id, comment)- return this.commentsRepository.findOne(id)+ return this.commentsRepository.findOne({ where: { id } })}async createCommentReply(diff --git a/backend/apps/production/src/marketplace/complaints/complaints.controller.ts b/backend/apps/production/src/marketplace/complaints/complaints.controller.tsindex cfa75b386..fe71fdbcd 100644--- a/backend/apps/production/src/marketplace/complaints/complaints.controller.ts+++ b/backend/apps/production/src/marketplace/complaints/complaints.controller.ts@@ -66,7 +66,7 @@ export class ComplaintsController {@Param() params: GetComplaintParamDto,): Promise<Complaint> {const complaint = await this.complaintsService.findOne({- where: { id: params.complaintId },+ where: { id: parseInt(params.complaintId, 10) },})if (!complaint) {@@ -82,14 +82,16 @@ export class ComplaintsController {@Query() queries: CreateComplaintQueryDto,@Body() body: CreateComplaintBodyDto,): Promise<Complaint> {- const user = await this.userService.findOne(queries.userId)+ const user = await this.userService.findOne({+ where: { id: queries.userId },+ })if (!user) {throw new NotFoundException('User not found.')}const extension = await this.extensionsService.findOne({- where: { id: body.extensionId },+ where: { id: body.extensionId.toString() },})if (!extension) {@@ -113,7 +115,7 @@ export class ComplaintsController {@Body() body: ResolveComplaintBodyDto,) {const complaint = await this.complaintsService.findOne({- where: { id: params.complaintId },+ where: { id: parseInt(params.complaintId, 10) },})if (!complaint) {diff --git a/backend/apps/production/src/marketplace/complaints/complaints.service.ts b/backend/apps/production/src/marketplace/complaints/complaints.service.tsindex e5b59201b..09fd4bb75 100644--- a/backend/apps/production/src/marketplace/complaints/complaints.service.ts+++ b/backend/apps/production/src/marketplace/complaints/complaints.service.ts@@ -13,11 +13,11 @@ export class ComplaintsService {async findAndCount(options: FindManyOptions<Complaint>,): Promise<[Complaint[], number]> {- return this.complaintsRepository.findAndCount({ ...options })+ return this.complaintsRepository.findAndCount(options)}async findOne(options: FindOneOptions<Complaint>): Promise<Complaint> {- return this.complaintsRepository.findOne({ ...options })+ return this.complaintsRepository.findOne(options)}async save(complaint: Partial<Complaint>): Promise<Complaint> {diff --git a/backend/apps/production/src/marketplace/extensions/extensions.controller.ts b/backend/apps/production/src/marketplace/extensions/extensions.controller.tsindex a25c9e1bc..d4b5beb6b 100644--- a/backend/apps/production/src/marketplace/extensions/extensions.controller.ts+++ b/backend/apps/production/src/marketplace/extensions/extensions.controller.ts@@ -177,13 +177,11 @@ export class ExtensionsController {count: number}> {// eslint-disable-next-line prefer-const- let [extensions, count] = await this.extensionsService.findAndCount(- {- skip: queries.offset || 0,- take: queries.limit > 100 ? 25 : queries.limit || 25,- },- ['owner', 'users', 'category'],- )+ let [extensions, count] = await this.extensionsService.findAndCount({+ skip: queries.offset || 0,+ take: queries.limit > 100 ? 25 : queries.limit || 25,+ relations: ['owner', 'users', 'category'],+ })extensions = _map(extensions, extension => {// @ts-expect-error@@ -254,16 +252,14 @@ export class ExtensionsController {}// eslint-disable-next-line prefer-const- let [extensions, count] = await this.extensionsService.findAndCount(- {- skip: queries.offset || 0,- take: queries.limit > 100 ? 100 : queries.limit || 10,- where: {- owner: userId,- },+ let [extensions, count] = await this.extensionsService.findAndCount({+ skip: queries.offset || 0,+ take: queries.limit > 100 ? 100 : queries.limit || 10,+ where: {+ owner: { id: userId },},- ['owner', 'users', 'category'],- )+ relations: ['owner', 'users', 'category'],+ })extensions = _map(extensions, extension => {// @ts-expect-error@@ -568,7 +564,7 @@ export class ExtensionsController {throw new NotFoundException('Extension not found.')}- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found.')}@@ -591,7 +587,9 @@ export class ExtensionsController {})}- const project = await this.projectService.findOne(body.projectId)+ const project = await this.projectService.findOne({+ where: { id: body.projectId },+ })if (!project) {throw new NotFoundException('Project not found.')}@@ -640,7 +638,7 @@ export class ExtensionsController {throw new NotFoundException('Extension not found.')}- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new NotFoundException('User not found.')}@@ -660,7 +658,9 @@ export class ExtensionsController {return this.extensionsService.deleteExtensionToUser(extension.id, user.id)}- const project = await this.projectService.findOne(body.projectId)+ const project = await this.projectService.findOne({+ where: { id: body.projectId },+ })if (!project) {throw new NotFoundException('Project not found.')}diff --git a/backend/apps/production/src/marketplace/extensions/extensions.service.ts b/backend/apps/production/src/marketplace/extensions/extensions.service.tsindex 09b616b18..d4efb66d2 100644--- a/backend/apps/production/src/marketplace/extensions/extensions.service.ts+++ b/backend/apps/production/src/marketplace/extensions/extensions.service.ts@@ -141,7 +141,7 @@ export class ExtensionsService {async allowedToManage(ownerId: string, id: string): Promise<any> {const extension = await this.findOne({- where: { owner: ownerId, id },+ where: { owner: { id: ownerId }, id },})if (!extension) {@@ -169,12 +169,8 @@ export class ExtensionsService {async findAndCount(options: FindManyOptions<Extension>,- relations: string[] = [],): Promise<[Extension[], number]> {- return this.extensionRepository.findAndCount({- ...options,- relations,- })+ return this.extensionRepository.findAndCount(options)}async createExtension(extension: CreateExtensionType) {diff --git a/backend/apps/production/src/project/project.controller.ts b/backend/apps/production/src/project/project.controller.tsindex 602c22640..7022f02eb 100644--- a/backend/apps/production/src/project/project.controller.ts+++ b/backend/apps/production/src/project/project.controller.ts@@ -34,7 +34,7 @@ import {ApiOkResponse,ApiNoContentResponse,} from '@nestjs/swagger'-import { Equal, FindConditions, ILike, In } from 'typeorm'+import { Equal, FindOptionsWhere, ILike, In } from 'typeorm'import _isEmpty from 'lodash/isEmpty'import _map from 'lodash/map'import _trim from 'lodash/trim'@@ -158,9 +158,7 @@ export class ProjectController {this.logger.log({ userId, take, skip }, 'GET /project')const isCaptcha = isCaptchaStr === 'true'- let where: FindConditions<- Project & (Project & { admin?: string })[] & { admin?: string }- >+ let where: FindOptionsWhere<Project> | FindOptionsWhere<Project>[]if (search) {where = [@@ -180,11 +178,11 @@ export class ProjectController {isArchived: showArchived,// id: ILike(`%${mysql.escape(search).slice(1, 0).slice(0, -1)}%`),},- ]+ ] as FindOptionsWhere<Project>[]} else {where = {admin: userId,- }+ } as FindOptionsWhere<Project>if (isCaptcha) {where.isCaptchaProject = true@@ -200,7 +198,7 @@ export class ProjectController {const [paginated, totalMonthlyEvents, user] = await Promise.all([this.projectService.paginate({ take, skip }, where),this.projectService.getRedisCount(userId),- this.userService.findOne(userId),+ this.userService.findOne({ where: { id: userId } }),])const pidsWithData =@@ -371,9 +369,10 @@ export class ProjectController {): Promise<Project> {this.logger.log({ userId, projectDTO }, 'POST /project/admin/:id')- const user = await this.userService.findOneWithRelations(userId, [- 'projects',- ])+ const user = await this.userService.findOne({+ where: { id: userId },+ relations: ['projects'],+ })const { maxProjects = PROJECTS_MAXIMUM } = userif (!user.isActive) {@@ -429,9 +428,10 @@ export class ProjectController {throw new UnauthorizedException('Please auth first')}- const user = await this.userService.findOneWithRelations(userId, [- 'projects',- ])+ const user = await this.userService.findOne({+ where: { id: userId },+ relations: ['projects'],+ })const { maxProjects = PROJECTS_MAXIMUM } = userif (!user.isActive) {@@ -552,9 +552,10 @@ export class ProjectController {throw new UnauthorizedException('Please auth first')}- const user = await this.userService.findOneWithRelations(userId, [- 'projects',- ])+ const user = await this.userService.findOne({+ where: { id: userId },+ relations: ['projects'],+ })if (!user.isActive) {throw new ForbiddenException('Please, verify your email address first')@@ -606,9 +607,10 @@ export class ProjectController {throw new UnauthorizedException('Please auth first')}- const user = await this.userService.findOneWithRelations(userId, [- 'projects',- ])+ const user = await this.userService.findOne({+ where: { id: userId },+ relations: ['projects'],+ })if (!user.isActive) {throw new ForbiddenException('Please, verify your email address first')@@ -747,7 +749,7 @@ export class ProjectController {)}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })const project = await this.projectService.findOneWhere({ id },{@@ -805,7 +807,7 @@ export class ProjectController {)}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })const project = await this.projectService.findOneWhere({ id },{@@ -852,10 +854,11 @@ export class ProjectController {)}- const project = await this.projectService.findOne(pid, {+ const project = await this.projectService.findOne({+ where: { id: pid },relations: ['admin'],})- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })if (_isEmpty(project)) {throw new NotFoundException()@@ -891,7 +894,7 @@ export class ProjectController {)}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })const project = await this.projectService.findOneWhere({ id },{@@ -970,7 +973,8 @@ export class ProjectController {throw new BadRequestException("The provided 'to' date is incorrect")}- const project = await this.projectService.findOne(pid, {+ const project = await this.projectService.findOne({+ where: { id: pid },relations: ['admin', 'share'],})@@ -1004,7 +1008,8 @@ export class ProjectController {)}- const project = await this.projectService.findOne(pid, {+ const project = await this.projectService.findOne({+ where: { id: pid },relations: ['admin', 'share'],})@@ -1030,7 +1035,8 @@ export class ProjectController {): Promise<BulkAddUsersResponse[]> {this.logger.log({ uid, bulkAddUsersDto }, 'POST /project/bulk-add-users')- const inviter = await this.userService.findOne(uid, {+ const inviter = await this.userService.findOne({+ where: { id: uid },relations: ['projects', 'sharedProjects', 'sharedProjects.project'],})@@ -1200,7 +1206,7 @@ export class ProjectController {throw new BadRequestException('The provided ShareDTO is incorrect')}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })const project = await this.projectService.findOneWhere({ id: pid },{@@ -1279,7 +1285,8 @@ export class ProjectController {},)- const updatedProject = await this.projectService.findOne(pid, {+ const updatedProject = await this.projectService.findOne({+ where: { id: pid },relations: ['share', 'share.user'],})@@ -1310,8 +1317,9 @@ export class ProjectController {throw new BadRequestException('The provided ShareUpdateDTO is incorrect')}- const user = await this.userService.findOne(uid)- const share = await this.projectService.findOneShare(shareId, {+ const user = await this.userService.findOne({ where: { id: uid } })+ const share = await this.projectService.findOneShare({+ where: { id: shareId },relations: ['project','project.admin',@@ -1341,7 +1349,9 @@ export class ProjectController {})await deleteProjectRedis(share.project.id)- return this.projectService.findOneShare(shareId)+ return this.projectService.findOneShare({+ where: { id: shareId },+ })}@ApiBearerAuth()@@ -1364,7 +1374,9 @@ export class ProjectController {if (actionToken.action === ActionTokenType.PROJECT_SHARE) {const { newValue: shareId, id: tokenID } = actionToken- const share = await this.projectService.findOneShare(shareId)+ const share = await this.projectService.findOneShare({+ where: { id: shareId },+ })share.confirmed = trueif (_isEmpty(share)) {@@ -1490,7 +1502,8 @@ export class ProjectController {'DELETE /project/:projectId/subscribers/:subscriberId',)- const project = await this.projectService.findOne(params.projectId, {+ const project = await this.projectService.findOne({+ where: { id: params.projectId },relations: ['share', 'share.user', 'admin'],})@@ -1530,7 +1543,8 @@ export class ProjectController {) {this.logger.log({ params, body }, 'POST /project/:projectId/subscribers')- const project = await this.projectService.findOne(params.projectId, {+ const project = await this.projectService.findOne({+ where: { id: params.projectId },relations: ['share', 'share.user', 'admin'],})@@ -1648,7 +1662,8 @@ export class ProjectController {) {this.logger.log({ params, queries }, 'GET /project/:projectId/subscribers')- const project = await this.projectService.findOne(params.projectId, {+ const project = await this.projectService.findOne({+ where: { id: params.projectId },relations: ['share', 'share.user', 'admin'],})@@ -1673,7 +1688,8 @@ export class ProjectController {'PATCH /project/:projectId/subscribers/:subscriberId',)- const project = await this.projectService.findOne(params.projectId, {+ const project = await this.projectService.findOne({+ where: { id: params.projectId },relations: ['share', 'share.user', 'admin'],})@@ -1723,7 +1739,7 @@ export class ProjectController {'The provided Project ID (pid) is incorrect',)}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })const project = await this.projectService.findOneWhere({ id },{@@ -1800,10 +1816,11 @@ export class ProjectController {)}- const project = await this.projectService.findOne(id, {+ const project = await this.projectService.findOne({+ where: { id },relations: ['admin', 'share', 'share.user'],})- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })if (_isEmpty(project)) {throw new NotFoundException()@@ -1886,7 +1903,7 @@ export class ProjectController {)}- const project = await this.projectService.findOne(id)+ const project = await this.projectService.findOne({ where: { id } })if (_isEmpty(project)) {// TODO: Return default image@@ -1919,7 +1936,7 @@ export class ProjectController {)}- const project = await this.projectService.findOne(id)+ const project = await this.projectService.findOne({ where: { id } })if (_isEmpty(project)) {throw new NotFoundException('Project not found')@@ -1950,10 +1967,11 @@ export class ProjectController {}this.projectService.validateProject(projectDTO)- const project = await this.projectService.findOne(id, {+ const project = await this.projectService.findOne({+ where: { id },relations: ['admin', 'share', 'share.user'],})- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })if (_isEmpty(project)) {throw new NotFoundException()@@ -2046,7 +2064,7 @@ export class ProjectController {throw new NotFoundException(`Project with ID ${pid} does not exist`)}- const user = await this.userService.findOne(uid)+ const user = await this.userService.findOne({ where: { id: uid } })this.projectService.allowedToManage(project, uid, user.roles)@@ -2111,7 +2129,8 @@ export class ProjectController {)}- const project = await this.projectService.findOne(id, {+ const project = await this.projectService.findOne({+ where: { id },relations: ['admin', 'share', 'share.user', 'funnels'],})diff --git a/backend/apps/production/src/project/project.service.ts b/backend/apps/production/src/project/project.service.tsindex 18a139d7a..d17d8df2d 100644--- a/backend/apps/production/src/project/project.service.ts+++ b/backend/apps/production/src/project/project.service.ts@@ -9,7 +9,7 @@ import {NotFoundException,} from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'-import { FindOneOptions, Repository } from 'typeorm'+import { FindOneOptions, FindOptionsWhere, Repository } from 'typeorm'import { customAlphabet } from 'nanoid'import handlebars from 'handlebars'import puppeteer from 'puppeteer'@@ -369,7 +369,7 @@ export class ProjectService {async paginate(options: PaginationOptionsInterface,- where: Record<string, unknown> | undefined,+ where: FindOptionsWhere<Project> | FindOptionsWhere<Project>[] | undefined,): Promise<Pagination<Project>> {const [results, total] = await this.projectsRepository.findAndCount({take: options.take || 100,@@ -389,7 +389,7 @@ export class ProjectService {async paginateShared(options: PaginationOptionsInterface,- where: Record<string, unknown> | undefined,+ where: FindOptionsWhere<Project> | FindOptionsWhere<Project>[] | undefined,): Promise<Pagination<ProjectShare>> {const [results, total] = await this.projectShareRepository.findAndCount({take: options.take || 100,@@ -462,24 +462,20 @@ export class ProjectService {}async findOneShare(- id: string,- params: object = {},+ options: FindOneOptions<ProjectShare>,): Promise<ProjectShare | null> {- return this.projectShareRepository.findOne(id, params)+ return this.projectShareRepository.findOne(options)}findOneWithRelations(id: string,relations = ['admin'],): Promise<Project | null> {- return this.projectsRepository.findOne(id, { relations })+ return this.projectsRepository.findOne({ where: { id }, relations })}- findOne(- id: string,- params: FindOneOptions<Project> = {},- ): Promise<Project | null> {- return this.projectsRepository.findOne(id, params)+ findOne(options: FindOneOptions<Project>): Promise<Project | null> {+ return this.projectsRepository.findOne(options)}findWhere(@@ -552,9 +548,12 @@ export class ProjectService {}async isPIDUnique(pid: string): Promise<boolean> {- const project = await this.findOne(pid)+ const exists = await this.projectsRepository.findOne({+ where: { id: pid },+ select: ['id'],+ })- return !project+ return !exists}async checkIfIDUnique(pid: string): Promise<void> {@@ -1446,7 +1445,7 @@ export class ProjectService {}async findMonitorById(- id: string,+ id: number,projectId: string,options?: Omit<FindOneOptions<MonitorEntity>, 'where'>,): Promise<MonitorEntity | undefined> {diff --git a/backend/apps/production/src/task-manager/task-manager.service.ts b/backend/apps/production/src/task-manager/task-manager.service.tsindex 0a44b4169..892183dc7 100644--- a/backend/apps/production/src/task-manager/task-manager.service.ts+++ b/backend/apps/production/src/task-manager/task-manager.service.ts@@ -42,6 +42,7 @@ import {User,getNextPlan,DashboardBlockReason,+ ReportFrequency as UserReportFrequency,} from '../user/entities/user.entity'import {redis,@@ -1252,7 +1253,7 @@ export class TaskManagerService {async disableReportsForInactiveUsers() {const users = await this.userService.find({where: {- reportFrequency: Not(ReportFrequency.NEVER),+ reportFrequency: Not(UserReportFrequency.Never),},relations: ['projects'],select: ['id'],diff --git a/backend/apps/production/src/user/entities/user.entity.ts b/backend/apps/production/src/user/entities/user.entity.tsindex a272be6b3..459feaf4a 100644--- a/backend/apps/production/src/user/entities/user.entity.ts+++ b/backend/apps/production/src/user/entities/user.entity.ts@@ -174,7 +174,7 @@ export enum UserType {ADMIN = 'admin',}-enum ReportFrequency {+export enum ReportFrequency {Never = 'never',Weekly = 'weekly',Monthly = 'monthly',diff --git a/backend/apps/production/src/user/user.controller.ts b/backend/apps/production/src/user/user.controller.tsindex d495fd04c..cc124cd83 100644--- a/backend/apps/production/src/user/user.controller.ts+++ b/backend/apps/production/src/user/user.controller.ts@@ -110,7 +110,7 @@ export class UserController {relations: ['project'],})const user = this.userService.omitSensitiveData(- await this.userService.findOne(user_id),+ await this.userService.findOne({ where: { id: user_id } }),)user.sharedProjects = sharedProjects@@ -230,7 +230,7 @@ export class UserController {await checkRateLimit(ip, 'set-paypal-email', 10, 3600)- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!user) {throw new BadRequestException('User not found')@@ -263,7 +263,7 @@ export class UserController {await checkRateLimit(ip, 'generate-api-key', 5, 3600)- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (!_isNull(user.apiKey)) {throw new ConflictException('You already have an API key')@@ -283,7 +283,7 @@ export class UserController {async deleteApiKey(@CurrentUserId() userId: string): Promise<void> {this.logger.log({ userId }, 'DELETE /user/api-key')- const user = await this.userService.findOne(userId)+ const user = await this.userService.findOne({ where: { id: userId } })if (_isNull(user.apiKey)) {throw new ConflictException("You don't have an API key")@@ -302,7 +302,8 @@ export class UserController {@CurrentUserId() uid: string,): Promise<any> {this.logger.log({ id, uid }, 'DELETE /user/:id')- const user = await this.userService.findOne(id, {+ const user = await this.userService.findOne({+ where: { id },relations: ['projects'],select: ['id', 'planCode'],})@@ -363,7 +364,8 @@ export class UserController {): Promise<any> {this.logger.log({ id }, 'DELETE /user')- const user = await this.userService.findOne(id, {+ const user = await this.userService.findOne({+ where: { id },relations: ['projects'],select: ['id', 'planCode'],})@@ -434,7 +436,8 @@ export class UserController {): Promise<any> {this.logger.log({ uid, shareId }, 'DELETE /user/share/:shareId')- const share = await this.projectService.findOneShare(shareId, {+ const share = await this.projectService.findOneShare({+ where: { id: shareId },relations: ['user', 'project'],})@@ -464,7 +467,8 @@ export class UserController {): Promise<any> {this.logger.log({ uid, shareId }, 'GET /user/share/:shareId')- const share = await this.projectService.findOneShare(shareId, {+ const share = await this.projectService.findOneShare({+ where: { id: shareId },relations: ['user', 'project'],})@@ -544,7 +548,7 @@ export class UserController {await this.userService.update(id, { ...user, ...userDTO })// omit sensitive data before returning using this.userService.omitSensitiveData functionreturn this.userService.omitSensitiveData(- await this.userService.findOne(id),+ await this.userService.findOne({ where: { id } }),)} catch (e) {if (e.code === 'ER_DUP_ENTRY') {diff --git a/backend/apps/production/src/user/user.service.ts b/backend/apps/production/src/user/user.service.tsindex 00673fbd9..b376c2cec 100644--- a/backend/apps/production/src/user/user.service.ts+++ b/backend/apps/production/src/user/user.service.ts@@ -180,15 +180,8 @@ export class UserService {return this.usersRepository.findOne({ where, relations, select })}- findOne(id: string, params: FindOneOptions<User> = {}): Promise<User> {- return this.usersRepository.findOne({- where: { id },- ...params,- })- }-- findOneWithRelations(id: string, relations: string[]): Promise<User> {- return this.usersRepository.findOne(id, { relations })+ findOne(options: FindOneOptions<User> = {}): Promise<User> {+ return this.usersRepository.findOne(options)}findWhereWithRelations(@@ -245,7 +238,7 @@ export class UserService {}public async findUser(email: string) {- return this.usersRepository.findOne({ email })+ return this.usersRepository.findOne({ where: { email } })}public async createUser(@@ -261,7 +254,7 @@ export class UserService {}public async findUserById(id: string) {- return this.usersRepository.findOne({ id })+ return this.usersRepository.findOne({ where: { id } })}public async updateUser(id: string, user: Partial<Omit<User, 'id'>>) {@@ -275,7 +268,7 @@ export class UserService {}public async findDeleteFeedback(id: string) {- return this.deleteFeedbackRepository.findOne({ id })+ return this.deleteFeedbackRepository.findOne({ where: { id } })}public async deleteDeleteFeedback(id: string) {@@ -320,16 +313,16 @@ export class UserService {}async getUser(id: string) {- return this.usersRepository.findOne({ id })+ return this.usersRepository.findOne({ where: { id } })}async getUserByEmail(email: string) {return this.usersRepository.findOne({ where: { email } })}- async getUserByTelegramId(telegramId: number) {+ async getUserByTelegramId(telegramId: string | number) {return this.usersRepository.findOne({- where: { telegramChatId: telegramId },+ where: { telegramChatId: telegramId.toString() },})}diff --git a/backend/apps/production/src/webhook/webhook.controller.ts b/backend/apps/production/src/webhook/webhook.controller.tsindex 099098544..397fb4e36 100644--- a/backend/apps/production/src/webhook/webhook.controller.ts+++ b/backend/apps/production/src/webhook/webhook.controller.ts@@ -129,7 +129,7 @@ export class WebhookController {}const currentUser = uid- ? await this.userService.findOne(uid)+ ? await this.userService.findOne({ where: { id: uid } }): await this.userService.findOneWhere({ email })const unlockDashboardParams =body.alert_name === 'subscription_created' ||diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex e87147aae..e0c620b0a 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -1,12 +1,10 @@{- "name": "swetrix-api",+ "name": "backend","version": "3.2.0","lockfileVersion": 3,"requires": true,"packages": {"": {- "name": "swetrix-api",- "version": "3.2.0","license": "AGPL-3.0","dependencies": {"@clickhouse/client": "^1.8.0",@@ -78,7 +76,7 @@"sns-payload-validator": "^2.1.0","svg-captcha": "^1.4.0","telegraf": "^4.16.3",- "typeorm": "^0.2.45",+ "typeorm": "^0.3.20","ua-parser-js": "^1.0.39","uuid": "^11.0.2","validator": "^13.12.0"@@ -3830,11 +3828,6 @@"@types/node": "*"}},- "node_modules/@types/zen-observable": {- "version": "0.8.3",- "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.3.tgz",- "integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw=="- },"node_modules/@typescript-eslint/eslint-plugin": {"version": "8.13.0","resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.13.0.tgz",@@ -7865,7 +7858,6 @@"version": "10.4.2","resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz","integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==",- "devOptional": true,"dependencies": {"foreground-child": "^3.1.0","jackspeak": "^3.1.2",@@ -7905,7 +7897,6 @@"version": "2.0.1","resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz","integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",- "devOptional": true,"dependencies": {"balanced-match": "^1.0.0"}@@ -7914,7 +7905,6 @@"version": "3.4.3","resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz","integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==",- "devOptional": true,"dependencies": {"@isaacs/cliui": "^8.0.2"},@@ -7929,7 +7919,6 @@"version": "9.0.5","resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz","integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",- "devOptional": true,"dependencies": {"brace-expansion": "^2.0.1"},@@ -12360,11 +12349,6 @@"node": ">= 0.10"}},- "node_modules/sax": {- "version": "1.2.4",- "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",- "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="- },"node_modules/schema-utils": {"version": "3.3.0","resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",@@ -13577,52 +13561,61 @@"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="},"node_modules/typeorm": {- "version": "0.2.45",- "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.2.45.tgz",- "integrity": "sha512-c0rCO8VMJ3ER7JQ73xfk0zDnVv0WDjpsP6Q1m6CVKul7DB9iVdWLRjPzc8v2eaeBuomsbZ2+gTaYr8k1gm3bYA==",+ "version": "0.3.20",+ "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.20.tgz",+ "integrity": "sha512-sJ0T08dV5eoZroaq9uPKBoNcGslHBR4E4y+EBHs//SiGbblGe7IeduP/IH4ddCcj0qp3PHwDwGnuvqEAnKlq/Q==",+ "license": "MIT","dependencies": {- "@sqltools/formatter": "^1.2.2",- "app-root-path": "^3.0.0",+ "@sqltools/formatter": "^1.2.5",+ "app-root-path": "^3.1.0","buffer": "^6.0.3",- "chalk": "^4.1.0",+ "chalk": "^4.1.2","cli-highlight": "^2.1.11",- "debug": "^4.3.1",- "dotenv": "^8.2.0",- "glob": "^7.1.6",- "js-yaml": "^4.0.0",- "mkdirp": "^1.0.4",- "reflect-metadata": "^0.1.13",+ "dayjs": "^1.11.9",+ "debug": "^4.3.4",+ "dotenv": "^16.0.3",+ "glob": "^10.3.10",+ "mkdirp": "^2.1.3",+ "reflect-metadata": "^0.2.1","sha.js": "^2.4.11",- "tslib": "^2.1.0",- "uuid": "^8.3.2",- "xml2js": "^0.4.23",- "yargs": "^17.0.1",- "zen-observable-ts": "^1.0.0"+ "tslib": "^2.5.0",+ "uuid": "^9.0.0",+ "yargs": "^17.6.2"},"bin": {- "typeorm": "cli.js"+ "typeorm": "cli.js",+ "typeorm-ts-node-commonjs": "cli-ts-node-commonjs.js",+ "typeorm-ts-node-esm": "cli-ts-node-esm.js"+ },+ "engines": {+ "node": ">=16.13.0"},"funding": {"url": "https://opencollective.com/typeorm"},"peerDependencies": {- "@sap/hana-client": "^2.11.14",- "better-sqlite3": "^7.1.2",+ "@google-cloud/spanner": "^5.18.0",+ "@sap/hana-client": "^2.12.25",+ "better-sqlite3": "^7.1.2 || ^8.0.0 || ^9.0.0","hdb-pool": "^0.1.6",- "ioredis": "^4.28.3",- "mongodb": "^3.6.0",- "mssql": "^6.3.1",- "mysql2": "^2.2.5",- "oracledb": "^5.1.0",+ "ioredis": "^5.0.4",+ "mongodb": "^5.8.0",+ "mssql": "^9.1.1 || ^10.0.1",+ "mysql2": "^2.2.5 || ^3.0.1",+ "oracledb": "^6.3.0","pg": "^8.5.1","pg-native": "^3.0.0","pg-query-stream": "^4.0.0",- "redis": "^3.1.1",+ "redis": "^3.1.1 || ^4.0.0","sql.js": "^1.4.0",- "sqlite3": "^5.0.2",+ "sqlite3": "^5.0.3",+ "ts-node": "^10.7.0","typeorm-aurora-data-api-driver": "^2.0.0"},"peerDependenciesMeta": {+ "@google-cloud/spanner": {+ "optional": true+ },"@sap/hana-client": {"optional": true},@@ -13665,6 +13658,9 @@"sqlite3": {"optional": true},+ "ts-node": {+ "optional": true+ },"typeorm-aurora-data-api-driver": {"optional": true}@@ -13693,53 +13689,30 @@"ieee754": "^1.2.1"}},- "node_modules/typeorm/node_modules/dotenv": {- "version": "8.6.0",- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz",- "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==",- "engines": {- "node": ">=10"- }- },- "node_modules/typeorm/node_modules/glob": {- "version": "7.2.3",- "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",- "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",- "dependencies": {- "fs.realpath": "^1.0.0",- "inflight": "^1.0.4",- "inherits": "2",- "minimatch": "^3.1.1",- "once": "^1.3.0",- "path-is-absolute": "^1.0.0"- },- "engines": {- "node": "*"- },- "funding": {- "url": "https://github.com/sponsors/isaacs"- }- },"node_modules/typeorm/node_modules/mkdirp": {- "version": "1.0.4",- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",- "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",+ "version": "2.1.6",+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.6.tgz",+ "integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==",+ "license": "MIT","bin": {- "mkdirp": "bin/cmd.js"+ "mkdirp": "dist/cjs/src/bin.js"},"engines": {"node": ">=10"+ },+ "funding": {+ "url": "https://github.com/sponsors/isaacs"}},- "node_modules/typeorm/node_modules/reflect-metadata": {- "version": "0.1.14",- "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz",- "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A=="- },"node_modules/typeorm/node_modules/uuid": {- "version": "8.3.2",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",- "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",+ "version": "9.0.1",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",+ "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",+ "funding": [+ "https://github.com/sponsors/broofa",+ "https://github.com/sponsors/ctavan"+ ],+ "license": "MIT","bin": {"uuid": "dist/bin/uuid"}@@ -14375,26 +14348,6 @@}}},- "node_modules/xml2js": {- "version": "0.4.23",- "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",- "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",- "dependencies": {- "sax": ">=0.6.0",- "xmlbuilder": "~11.0.0"- },- "engines": {- "node": ">=4.0.0"- }- },- "node_modules/xmlbuilder": {- "version": "11.0.1",- "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",- "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",- "engines": {- "node": ">=4.0"- }- },"node_modules/xtend": {"version": "4.0.2","resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",@@ -14471,20 +14424,6 @@"url": "https://github.com/sponsors/sindresorhus"}},- "node_modules/zen-observable": {- "version": "0.8.15",- "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz",- "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ=="- },- "node_modules/zen-observable-ts": {- "version": "1.1.0",- "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.1.0.tgz",- "integrity": "sha512-1h4zlLSqI2cRLPJUHJFL8bCWHhkpuXkF+dbGkRaWjgDIG26DmzyshUMrdV/rL3UnR+mhaX4fRq8LPouq0MYYIA==",- "dependencies": {- "@types/zen-observable": "0.8.3",- "zen-observable": "0.8.15"- }- },"node_modules/zod": {"version": "3.23.8","resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",diff --git a/backend/package.json b/backend/package.jsonindex d3af1df45..bda631275 100644--- a/backend/package.json+++ b/backend/package.json@@ -95,7 +95,7 @@"sns-payload-validator": "^2.1.0","svg-captcha": "^1.4.0","telegraf": "^4.16.3",- "typeorm": "^0.2.45",+ "typeorm": "^0.3.20","ua-parser-js": "^1.0.39","uuid": "^11.0.2","validator": "^13.12.0"